- bomberman refactoring update

This commit is contained in:
Ilya Shurumov 2020-10-07 20:54:48 +06:00
parent 7d3a4083e6
commit b7f7363f79
6 changed files with 30 additions and 26 deletions

View File

@ -23,8 +23,9 @@
#include "RAND.H"
MODEL* gBombModel;
_ExOBJECT explosion[5];
static BOMB ThrownBombs[5];
static BOMB ThrownBombs[MAX_THROWN_BOMBS];
static int ThrownBombDelay = 0;
static int CurrentBomb = 0;
static int gWantFlash = 0;
@ -71,7 +72,7 @@ void InitThrownBombs(void)
{
int i;
for (i = 0; i < 5; i++)
for (i = 0; i < MAX_THROWN_BOMBS; i++)
ThrownBombs[i].flags = 0;
ThrownBombDelay = Random2(0) % 45 + 8;
@ -153,7 +154,7 @@ void HandleThrownBombs(void)
ThrownBombDelay = Random2(0) % 45 + 8;
bomb = &ThrownBombs[CurrentBomb++];
CurrentBomb = CurrentBomb % 5;
CurrentBomb = CurrentBomb % MAX_THROWN_BOMBS;
bomb->flags = 1;
bomb->active = 1;
@ -182,7 +183,7 @@ void HandleThrownBombs(void)
bomb = ThrownBombs;
i = 0;
while (i < 5)
while (i < MAX_THROWN_BOMBS)
{
if ((bomb->flags & 1) != 0)
{
@ -303,7 +304,7 @@ void DrawThrownBombs(void)
bomb = ThrownBombs;
i = 0;
while (i < 5)
while (i < MAX_THROWN_BOMBS)
{
if ((bomb->flags & 1) != 0)
{
@ -406,7 +407,7 @@ void BombThePlayerToHellAndBack(int car)
gBombTargetVehicle = &car_data[(car + 1) % maxCivCars];
bomb = &ThrownBombs[CurrentBomb++];
CurrentBomb = CurrentBomb % 5;
CurrentBomb = CurrentBomb % MAX_THROWN_BOMBS;
bomb->flags = 1;
bomb->active = 1;
@ -420,7 +421,7 @@ void BombThePlayerToHellAndBack(int car)
bomb->velocity.vz = 0;
bomb = &ThrownBombs[CurrentBomb++];
CurrentBomb = CurrentBomb % 5;
CurrentBomb = CurrentBomb % MAX_THROWN_BOMBS;
bomb->flags = 1;
bomb->active = 1;
@ -434,7 +435,7 @@ void BombThePlayerToHellAndBack(int car)
bomb->velocity.vz = 0;
bomb = &ThrownBombs[CurrentBomb++];
CurrentBomb = CurrentBomb % 5;
CurrentBomb = CurrentBomb % MAX_THROWN_BOMBS;
bomb->flags = 1;
bomb->active = 1;
@ -769,13 +770,13 @@ void ExplosionCollisionCheck(_CAR_DATA *cp, _ExOBJECT *pE)
pointVel[1] = denom * (collisionResult.surfNormal.vy >> 6);
pointVel[2] = denom * (collisionResult.surfNormal.vz >> 6);
cp->st.n.linearVelocity[0] = cp->st.n.linearVelocity[0] + pointVel[0];
cp->st.n.linearVelocity[1] = cp->st.n.linearVelocity[1] + pointVel[1];
cp->st.n.linearVelocity[2] = cp->st.n.linearVelocity[2] + pointVel[2];
cp->st.n.linearVelocity[0] += pointVel[0];
cp->st.n.linearVelocity[1] += pointVel[1];
cp->st.n.linearVelocity[2] += pointVel[2];
cp->hd.aacc[0] = (cp->hd.aacc[0] + FIXEDH(lever[1] * pointVel[2])) - FIXEDH(lever[2] * pointVel[1]);
cp->hd.aacc[1] = (cp->hd.aacc[1] + FIXEDH(lever[2] * pointVel[0])) - FIXEDH(lever[0] * pointVel[2]);
cp->hd.aacc[2] = (cp->hd.aacc[2] + FIXEDH(lever[0] * pointVel[1])) - FIXEDH(lever[1] * pointVel[0]);
cp->hd.aacc[0] += FIXEDH(lever[1] * pointVel[2]) - FIXEDH(lever[2] * pointVel[1]);
cp->hd.aacc[1] += FIXEDH(lever[2] * pointVel[0]) - FIXEDH(lever[0] * pointVel[2]);
cp->hd.aacc[2] += FIXEDH(lever[0] * pointVel[1]) - FIXEDH(lever[1] * pointVel[0]);
}
}

View File

@ -2,7 +2,6 @@
#define BOMBERMAN_H
extern MODEL* gBombModel;
extern _ExOBJECT explosion[5];
extern _CAR_DATA *gBombTargetVehicle;
extern void InitThrownBombs(); // 0x0001F570

View File

@ -12,6 +12,8 @@
#include "INLINE_C.H"
_ExOBJECT explosion[MAX_EXPLOSION_OBJECTS];
MATRIX SS = { 0 };
// decompiled code
@ -54,7 +56,7 @@ void InitExObjects(void)
{
int i;
for (i = 0; i < 5; i++)
for (i = 0; i < MAX_EXPLOSION_OBJECTS; i++)
explosion[i].time = -1;
initExplosion();
@ -186,7 +188,7 @@ void HandleExplosion(void)
i = 0;
exp = explosion;
while (i < 5)
while (i < MAX_EXPLOSION_OBJECTS)
{
if (exp->time != -1 && exp->type != BANG_USED)
{
@ -207,7 +209,7 @@ void HandleExplosion(void)
i = 0;
exp = explosion;
while (i < 5)
while (i < MAX_EXPLOSION_OBJECTS)
{
if (exp->time != -1)
{
@ -277,7 +279,7 @@ void DrawAllExplosions(void)
{
int i;
i = 0;
while (i < 5)
while (i < MAX_EXPLOSION_OBJECTS)
{
if (explosion[i].time != -1)
DrawExplosion(explosion[i].time, explosion[i].pos, explosion[i].hscale, explosion[i].rscale);

View File

@ -1,6 +1,7 @@
#ifndef JOB_FX_H
#define JOB_FX_H
extern _ExOBJECT explosion[MAX_EXPLOSION_OBJECTS];
extern void InitExObjects(); // 0x00057B0C

View File

@ -8,7 +8,6 @@
#include "DR2ROADS.H"
#include "MOTION_C.H"
#include "CONVERT.H"
#include "GAMESND.H"
#include "SOUND.H"
#include "PAD.H"
#include "CIV_AI.H"
@ -19,7 +18,7 @@
#include "AI.H"
#include "CARS.H"
#include "FELONY.H"
#include "BOMBERMAN.H"
#include "JOB_FX.H"
#include "BCOLLIDE.H"
#include "MAP.H"
#include "SYSTEM.H"

View File

@ -4,9 +4,11 @@
// DRIVER 2 game engine limits
// please populate this file only with engine limits during refactoring
#define MAX_CARS 20
#define MAX_CAR_MODELS 5
#define MAX_PEDESTRIANS 28
#define MAX_TRAFFIC_CARS 19
#define MAX_CARS 20
#define MAX_CAR_MODELS 5
#define MAX_PEDESTRIANS 28
#define MAX_TRAFFIC_CARS 19
#define MAX_EXPLOSION_OBJECTS 5
#define MAX_THROWN_BOMBS 5
#endif // DRLIMITS_H