- safety commit

This commit is contained in:
Christoph Oelckers 2020-05-14 09:07:07 +02:00
parent 15c744f3da
commit e007b9bceb
15 changed files with 1207 additions and 944 deletions

View file

@ -1077,6 +1077,10 @@ inline int32_t setsprite(int16_t spritenum, int x, int y, int z)
return setsprite(spritenum, &v);
}
void setspritepos(int spnum, int x, int y, int z)
{
sprite[spnum].pos = { x,y,z };
}
int32_t setspritez(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyofs);

View file

@ -68,6 +68,8 @@ int ifhitsectors_r(int sectnum);
int ifhitbyweapon_r(int sn);
int ifhitbyweapon_d(int sn);
int adjustfall(spritetype* s, int c);
void fall_d(int g_i, int g_p);
void fall_r(int g_i, int g_p);
bool ceilingspace(int sectnum)
{
@ -137,6 +139,11 @@ int ifhitbyweapon(int sectnum)
return isRR()? ifhitbyweapon_r(sectnum) : ifhitbyweapon_d(sectnum);
}
void fall(int g_i, int g_p)
{
if (isRR()) fall_r(g_i, g_p); else fall_d(g_i, g_p);
}
//---------------------------------------------------------------------------
//
//
@ -5050,6 +5057,98 @@ void alterang(int a, int g_i, int g_p)
}
}
//---------------------------------------------------------------------------
//
// the indirections here are to keep this core function free of game references
//
//---------------------------------------------------------------------------
void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*))
{
int j;
auto g_sp = &sprite[g_i];
g_sp->xoffset = 0;
g_sp->yoffset = 0;
// if(!gotz)
{
long c;
int sphit = fallspecial? fallspecial(g_i, g_p) : 0;
if (floorspace(g_sp->sectnum))
c = 0;
else
{
if (ceilingspace(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2)
c = gc / 6;
else c = gc;
}
if (hittype[g_i].cgg <= 0 || (sector[g_sp->sectnum].floorstat & 2))
{
getglobalz(g_i);
hittype[g_i].cgg = 6;
}
else hittype[g_i].cgg--;
if (g_sp->z < (hittype[g_i].floorz - FOURSLEIGHT))
{
g_sp->zvel += c;
g_sp->z += g_sp->zvel;
if (g_sp->zvel > 6144) g_sp->zvel = 6144;
}
else
{
g_sp->z = hittype[g_i].floorz - FOURSLEIGHT;
if (badguy(g_sp) || (g_sp->picnum == APLAYER && g_sp->owner >= 0))
{
if (g_sp->zvel > 3084 && g_sp->extra <= 1)
{
if (g_sp->pal != 1 && g_sp->picnum != DRONE)
{
if (g_sp->picnum == APLAYER && g_sp->extra > 0)
goto SKIPJIBS;
if (sphit)
{
guts(g_sp, JIBS6, 5, g_p);
spritesound(squished, g_i);
}
else
{
guts(g_sp, JIBS6, 15, g_p);
spritesound(squished, g_i);
spawn(g_i, BLOODPOOL);
}
}
SKIPJIBS:
hittype[g_i].picnum = SHOTSPARK1;
hittype[g_i].extra = 1;
g_sp->zvel = 0;
}
else if (g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != 1)
{
short j = g_sp->sectnum;
int x = g_sp->x, y = g_sp->y, z = g_sp->z;
pushmove(&x, &y, &z, &j, 128, (4 << 8), (4 << 8), CLIPMASK0);
setspritepos(g_i, x, y, z); // wrap this for safety. The renderer may need processing of the new position.
if (j != g_sp->sectnum && j >= 0 && j < MAXSECTORS)
changespritesect(g_i, j);
spritesound(thud, g_i);
}
}
if (sector[g_sp->sectnum].lotag == 1)
falladjustz(g_sp);
else g_sp->zvel = 0;
}
}
}

View file

@ -460,6 +460,8 @@ void lotsofmoney(spritetype* s, short n);
int dodge(spritetype*);
void alterang(int a, int g_i, int g_p);
void fall(int g_i, int g_p);
void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*));
// tile names which are identical for all games.
enum

View file

@ -4156,4 +4156,29 @@ void move_d(int g_i, int g_p, int g_x)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void falladjustz(spritetype* g_sp)
{
switch (g_sp->picnum)
{
case OCTABRAIN:
case COMMANDER:
case DRONE:
break;
default:
g_sp->z += (24 << 8);
break;
}
}
void fall_d(int g_i, int g_p)
{
fall_common(g_i, g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, SQUISHED, THUD, nullptr, falladjustz);
}
END_DUKE_NS

View file

@ -2115,10 +2115,10 @@ static void rrra_specialstats()
i = nexti;
}
if (ps[screenpeek].raat609 > 0)
if (ps[screenpeek].MamaEnd > 0)
{
ps[screenpeek].raat609--;
if (ps[screenpeek].raat609 == 0)
ps[screenpeek].MamaEnd--;
if (ps[screenpeek].MamaEnd == 0)
{
ps[screenpeek].gm = MODE_EOL;
ud.eog = 1;
@ -4350,4 +4350,134 @@ void move_r(int g_i, int g_p, int g_x)
}
}
void fakebubbaspawn(int g_i, int g_p)
{
fakebubba_spawn++;
switch (fakebubba_spawn)
{
default:
break;
case 1:
spawn(g_i, PIG);
break;
case 2:
spawn(g_i, MINION);
break;
case 3:
spawn(g_i, CHEER);
break;
case 4:
spawn(g_i, VIXEN);
operateactivators(666, ps[g_p].i);
break;
}
}
//---------------------------------------------------------------------------
//
// special checks in fall that only apply to RR.
//
//---------------------------------------------------------------------------
static int fallspecial(int g_i, int g_p)
{
int sphit = 0;
auto g_sp = &sprite[g_i];
if (isRRRA())
{
if (sector[g_sp->sectnum].lotag == 801)
{
if (g_sp->picnum == ROCK)
{
spawn(g_i, ROCK2);
spawn(g_i, ROCK2);
deletesprite(g_i);
}
return 0;
}
else if (sector[g_sp->sectnum].lotag == 802)
{
if (g_sp->picnum != APLAYER && badguy(g_sp) && g_sp->z == hittype[g_i].floorz - FOURSLEIGHT)
{
guts(g_sp, JIBS6, 5, g_p);
spritesound(SQUISHED, g_i);
deletesprite(g_i);
}
return 0;
}
else if (sector[g_sp->sectnum].lotag == 803)
{
if (g_sp->picnum == ROCK2)
deletesprite(g_i);
return 0;
}
}
if (sector[g_sp->sectnum].lotag == 800)
{
if (g_sp->picnum == 40)
{
deletesprite(g_i);
return 0;
}
if (g_sp->picnum != APLAYER && (badguy(g_sp) || g_sp->picnum == HEN || g_sp->picnum == COW || g_sp->picnum == PIG || g_sp->picnum == DOGRUN || g_sp->picnum == RABBIT) && (!isRRRA() || g_spriteExtra[g_i] < 128))
{
g_sp->z = hittype[g_i].floorz - FOURSLEIGHT;
g_sp->zvel = 8000;
g_sp->extra = 0;
g_spriteExtra[g_i]++;
sphit = 1;
}
else if (g_sp->picnum != APLAYER)
{
if (!g_spriteExtra[g_i])
deletesprite(g_i);
return 0;
}
hittype[g_i].picnum = SHOTSPARK1;
hittype[g_i].extra = 1;
}
else if (isRRRA() && sector[g_sp->sectnum].floorpicnum == RRTILE7820 || sector[g_sp->sectnum].floorpicnum == RRTILE7768)
{
if (g_sp->picnum != MINION && g_sp->pal != 19)
{
if ((krand() & 3) == 1)
{
hittype[g_i].picnum = SHOTSPARK1;
hittype[g_i].extra = 5;
}
}
}
return sphit;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void falladjustz(spritetype* g_sp)
{
if (isRRRA()) switch (g_sp->picnum)
{
case HULKBOAT:
g_sp->z += (12 << 8);
return;
case MINIONBOAT:
g_sp->z += (3 << 8);
return;
case CHEERBOAT:
case EMPTYBOAT:
g_sp->z += (6 << 8);
return;
}
if (g_sp->picnum != DRONE)
g_sp->z += (24 << 8);
}
void fall_r(int g_i, int g_p)
{
fall_common(g_i, g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, 69, 158, fallspecial, falladjustz);
}
END_DUKE_NS

File diff suppressed because it is too large Load diff

View file

@ -56,16 +56,8 @@ extern int errorcount, warningcount, line_count;
intptr_t *actorLoadEventScrptr[MAXTILES];
intptr_t *apScriptGameEvent[MAXGAMEEVENTS];
// global crap for event management
int g_i,g_p;
int g_x;
int *g_t;
uint8_t killit_flag;
spritetype *g_sp;
#endif
//---------------------------------------------------------------------------
//
//

View file

@ -197,8 +197,8 @@ G_EXTERN int32_t g_winderFlash;
G_EXTERN int32_t g_winderTime;
G_EXTERN int32_t g_brightness;
G_EXTERN int16_t g_ambientLotag[64];
G_EXTERN int16_t g_ambientHitag[64];
G_EXTERN int16_t ambientlotag[64];
G_EXTERN int16_t ambienthitag[64];
G_EXTERN uint32_t g_ambientCnt;
G_EXTERN intptr_t *apScript;
@ -217,7 +217,7 @@ G_EXTERN msx_ msx;
G_EXTERN msy_ msy;
G_EXTERN int32_t g_windTime, WindDir;
G_EXTERN int16_t g_fakeBubbaCnt, g_mamaSpawnCnt, g_banjoSong, g_bellTime, g_bellSprite;
G_EXTERN int16_t fakebubba_spawn, mamaspawn_count, banjosound, g_bellTime, g_bellSprite;
#define BellTime g_bellTime
#define word_119BE0 g_bellSprite
G_EXTERN uint8_t g_spriteExtra[MAXSPRITES], g_sectorExtra[MAXSECTORS]; // move these back into the base structs!

View file

@ -250,7 +250,7 @@ typedef struct player_struct {
int16_t yehaa_timer;
int16_t drink_amt, eat_amt, drink_ang, eat_ang;
int32_t drink_timer, eat_timer;
int16_t level_end_timer;
int16_t MamaEnd;
int16_t MotoSpeed, tilt_status, moto_drink;
uint8_t OnMotorcycle, OnBoat, moto_underwater, not_on_water, moto_on_ground;
uint8_t moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud;
@ -278,7 +278,7 @@ typedef struct player_struct {
#define heat_amount inv_amount[GET_HEATS]
#define scuba_amount inv_amount[GET_SCUBA]
#define boot_amount inv_amount[GET_BOOTS]
#define raat609 level_end_timer // name in RRGDX is 'MamaEnd'
#define raat609 MamaEnd
#define raat5dd sea_sick_stat
@ -396,7 +396,7 @@ void addweapon(DukePlayer_t* pPlayer, int weaponNum);
void P_CheckWeapon(DukePlayer_t *pPlayer);
void P_DisplayScuba(void);
void P_DisplayWeapon(void);
void P_DropWeapon(int playerNum);
void checkweapons(DukePlayer_t* const pPlayer);
int findotherplayer(int p, int* d);
void P_FragPlayer(int playerNum);
#ifdef YAX_ENABLE

View file

@ -25,8 +25,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_DUKE_NS
extern int16_t g_ambientLotag[64];
extern int16_t g_ambientHitag[64];
extern int16_t ambientlotag[64];
extern int16_t ambienthitag[64];
extern int32_t g_levelTextTime;
extern int32_t voting,vote_map,vote_episode;
int G_EnterLevel(int gameMode);

View file

@ -2866,4 +2866,24 @@ void dofurniture(int wl, int sect, int snum)
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void tearitup(int sect)
{
int j = headspritesect[sect];
while (j != -1)
{
int nextj = nextspritesect[j];
if (sprite[j].picnum == DESTRUCTO)
{
hittype[j].picnum = SHOTSPARK1;
hittype[j].extra = 1;
}
j = nextj;
}
}
END_DUKE_NS

View file

@ -894,7 +894,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_fakebubba:
insptr++;
switch (++g_fakeBubbaCnt)
switch (++fakebubba_spawn)
{
case 1:
A_Spawn(vm.spriteNum, TILE_PIG);
@ -925,9 +925,9 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_mamaspawn:
insptr++;
if (g_mamaSpawnCnt)
if (mamaspawn_count)
{
g_mamaSpawnCnt--;
mamaspawn_count--;
A_Spawn(vm.spriteNum, TILE_RABBIT);
}
continue;
@ -942,24 +942,24 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_garybanjo:
insptr++;
if (g_banjoSong == 0)
if (banjosound == 0)
{
switch (krand2()&3)
{
case 3:
g_banjoSong = 262;
banjosound = 262;
break;
case 0:
g_banjoSong = 272;
banjosound = 272;
break;
default:
g_banjoSong = 273;
banjosound = 273;
break;
}
A_PlaySound(g_banjoSong, vm.spriteNum);
A_PlaySound(banjosound, vm.spriteNum, CHAN_WEAPON);
}
else if (!S_CheckSoundPlaying(vm.spriteNum, g_banjoSong))
A_PlaySound(g_banjoSong, vm.spriteNum, CHAN_WEAPON);
else if (!S_CheckSoundPlaying(vm.spriteNum, banjosound))
A_PlaySound(banjosound, vm.spriteNum, CHAN_WEAPON);
continue;
case concmd_motoloopsnd:
insptr++;
@ -1004,7 +1004,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_tossweapon:
insptr++;
// NOTE: assumes that current actor is TILE_APLAYER
P_DropWeapon(P_GetP(vm.pSprite));
checkweapons(&ps[P_GetP(vm.pSprite)]);
continue;
case concmd_mikesnd:
@ -1066,18 +1066,18 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_ifsoundid:
insptr++;
VM_CONDITIONAL((int16_t)*insptr == g_ambientLotag[vm.pSprite->ang]);
VM_CONDITIONAL((int16_t)*insptr == ambientlotag[vm.pSprite->ang]);
continue;
case concmd_ifsounddist:
insptr++;
if (*insptr == 0)
{
VM_CONDITIONAL(g_ambientHitag[vm.pSprite->ang] > vm.playerDist);
VM_CONDITIONAL(ambienthitag[vm.pSprite->ang] > vm.playerDist);
}
else if (*insptr == 1)
{
VM_CONDITIONAL(g_ambientHitag[vm.pSprite->ang] < vm.playerDist);
VM_CONDITIONAL(ambienthitag[vm.pSprite->ang] < vm.playerDist);
}
else
{
@ -1088,13 +1088,13 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_soundtag:
insptr++;
A_PlaySound(g_ambientLotag[vm.pSprite->ang], vm.spriteNum);
A_PlaySound(ambientlotag[vm.pSprite->ang], vm.spriteNum);
continue;
case concmd_soundtagonce:
insptr++;
if (!S_CheckSoundPlaying(vm.spriteNum, g_ambientLotag[vm.pSprite->ang]))
A_PlaySound(g_ambientLotag[vm.pSprite->ang], vm.spriteNum);
if (!S_CheckSoundPlaying(vm.spriteNum, ambientlotag[vm.pSprite->ang]))
A_PlaySound(ambientlotag[vm.pSprite->ang], vm.spriteNum);
continue;
case concmd_soundonce:
@ -1158,7 +1158,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop)
case concmd_mamaend:
insptr++;
g_player[myconnectindex].ps->level_end_timer = 150;
g_player[myconnectindex].ps->MamaEnd = 150;
continue;
case concmd_ifactorhealthg:

View file

@ -4593,9 +4593,9 @@ int16_t WeaponPickupSprites[MAX_WEAPONS] = { KNEE__STATIC, FIRSTGUNSPRITE__STATI
TRIPBOMBSPRITE__STATIC, FREEZESPRITE__STATIC, HEAVYHBOMB__STATIC, SHRINKERSPRITE__STATIC
};
// this is used for player deaths
void P_DropWeapon(int const playerNum)
void checkweapons(DukePlayer_t* const pPlayer)
{
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
int playerNum = sprite[pPlayer->i].yvel;
int const currentWeapon = WW2GI ? PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) : pPlayer->curr_weapon;
if (RRRA && (g_netServer || numplayers > 1))

View file

@ -1165,7 +1165,7 @@ static void resetprestat(int playerNum, int gameMode)
{
g_windTime = 0;
WindDir = 0;
g_fakeBubbaCnt = 0;
fakebubba_spawn = 0;
RRRA_ExitedLevel = 0;
g_bellTime = 0;
g_bellSprite = 0;
@ -1278,9 +1278,9 @@ static void prelevel(char g)
ufospawnsminion = 0;
pistonsound = 0;
enemysizecheat = 0;
g_player[myconnectindex].ps->level_end_timer = 0;
g_mamaSpawnCnt = 15;
g_banjoSong = 0;
g_player[myconnectindex].ps->MamaEnd = 0;
mamaspawn_count = 15;
banjosound = 0;
RRRA_ExitedLevel = 0;
if (!DEER)
{
@ -1293,11 +1293,11 @@ static void prelevel(char g)
ps->inv_amount[GET_STEROIDS] = 0;
}
if (ud.level_number == 3 && ud.volume_number == 0)
g_mamaSpawnCnt = 5;
mamaspawn_count = 5;
else if (ud.level_number == 2 && ud.volume_number == 1)
g_mamaSpawnCnt = 10;
mamaspawn_count = 10;
else if (ud.level_number == 6 && ud.volume_number == 1)
g_mamaSpawnCnt = 15;
mamaspawn_count = 15;
}
}
@ -1306,8 +1306,8 @@ static void prelevel(char g)
Bmemset(shadedsector, 0, sizeof(shadedsector));
Bmemset(g_geoSectorWarp, -1, sizeof(g_geoSectorWarp));
Bmemset(g_geoSectorWarp2, -1, sizeof(g_geoSectorWarp2));
Bmemset(g_ambientHitag, -1, sizeof(g_ambientHitag));
Bmemset(g_ambientLotag, -1, sizeof(g_ambientLotag));
Bmemset(ambienthitag, -1, sizeof(ambienthitag));
Bmemset(ambientlotag, -1, sizeof(ambientlotag));
show2dsector.Zero();
#ifdef LEGACY_ROR
Bmemset(ror_protectedsectors, 0, MAXSECTORS);
@ -1324,9 +1324,9 @@ static void prelevel(char g)
{
g_windTime = 0;
WindDir = 0;
g_fakeBubbaCnt = 0;
fakebubba_spawn = 0;
RRRA_ExitedLevel = 0;
g_mamaSpawnCnt = 15; // ???
mamaspawn_count = 15; // ???
g_bellTime = 0;
g_bellSprite = 0;
@ -1532,8 +1532,8 @@ static void prelevel(char g)
G_GameExit("\nToo many ambient effects");
else
{
g_ambientHitag[g_ambientCnt] = SHT(i);
g_ambientLotag[g_ambientCnt] = SLT(i);
ambienthitag[g_ambientCnt] = SHT(i);
ambientlotag[g_ambientCnt] = SLT(i);
sprite[i].ang = g_ambientCnt++;
sprite[i].lotag = 0;
sprite[i].hitag = 0;

View file

@ -877,8 +877,8 @@ static const dataspec_t svgm_anmisc[] =
{ 0, &shadedsector[0], sizeof(shadedsector[0]), MAXSECTORS },
{ 0, &g_ambientCnt, sizeof(g_ambientCnt), 1 },
{ 0, &g_ambientHitag[0], sizeof(g_ambientHitag[0]), ARRAY_SIZE(g_ambientHitag) },
{ 0, &g_ambientLotag[0], sizeof(g_ambientLotag[0]), ARRAY_SIZE(g_ambientLotag) },
{ 0, &ambienthitag[0], sizeof(ambienthitag[0]), ARRAY_SIZE(ambienthitag) },
{ 0, &ambientlotag[0], sizeof(ambientlotag[0]), ARRAY_SIZE(ambientlotag) },
{ 0, &g_ufoSpawn, sizeof(g_ufoSpawn), 1 },
{ 0, &g_ufoCnt, sizeof(g_ufoCnt), 1 },
@ -896,9 +896,9 @@ static const dataspec_t svgm_anmisc[] =
{ 0, &g_windTime, sizeof(g_windTime), 1 },
{ 0, &WindDir, sizeof(WindDir), 1 },
{ 0, &g_fakeBubbaCnt, sizeof(g_fakeBubbaCnt), 1 },
{ 0, &g_mamaSpawnCnt, sizeof(g_mamaSpawnCnt), 1 },
{ 0, &g_banjoSong, sizeof(g_banjoSong), 1 },
{ 0, &fakebubba_spawn, sizeof(fakebubba_spawn), 1 },
{ 0, &mamaspawn_count, sizeof(mamaspawn_count), 1 },
{ 0, &banjosound, sizeof(banjosound), 1 },
{ 0, &g_bellTime, sizeof(g_bellTime), 1 },
{ 0, &g_bellSprite, sizeof(g_bellSprite), 1 },