diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 3b6e4240c..dbbc5795c 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -263,19 +263,21 @@ static int32_t VM_CheckSquished(void) #endif if (vm.pSprite->pal == 1 ? (floorZ - ceilZ >= ZOFFSET5 || (pSector->lotag & 32768u)) : (floorZ - ceilZ >= ZOFFSET4)) - return 0; + return 0; P_DoQuote(QUOTE_SQUISHED, vm.pPlayer); if (A_CheckEnemySprite(vm.pSprite)) vm.pSprite->xvel = 0; +#ifndef EDUKE32_STANDALONE if (EDUKE32_PREDICT_FALSE(vm.pSprite->pal == 1)) // frozen { vm.pActor->picnum = SHOTSPARK1; vm.pActor->extra = 1; return 0; } +#endif return 1; } @@ -296,8 +298,8 @@ GAMEEXEC_STATIC GAMEEXEC_INLINE void P_ForceAngle(DukePlayer_t *pPlayer) #ifdef __cplusplus extern "C" #endif -int32_t A_Dodge(spritetype * const); -int32_t A_Dodge(spritetype * const pSprite) +bool A_Dodge(spritetype * const); +bool A_Dodge(spritetype * const pSprite) { if (A_CheckEnemySprite(pSprite) && pSprite->extra <= 0) // hack return 0; @@ -325,16 +327,16 @@ int32_t A_Dodge(spritetype * const pSprite) return 0; } -int32_t A_GetFurthestAngle(int const spriteNum, int const angDiv) +int A_GetFurthestAngle(int spriteNum, int angDiv) { - uspritetype *const pSprite = (uspritetype *)&sprite[spriteNum]; + auto const pSprite = (uspritetype *)&sprite[spriteNum]; if (pSprite->picnum != APLAYER && (AC_COUNT(actor[spriteNum].t_data)&63) > 2) return pSprite->ang + 1024; - int32_t furthestAngle = 0; - int32_t greatestDist = INT32_MIN; + int furthestAngle = 0; int const angIncs = tabledivide32_noinline(2048, angDiv); + int32_t greatestDist = INT32_MIN; hitdata_t hit; for (native_t j = pSprite->ang; j < (2048 + pSprite->ang); j += angIncs) @@ -352,7 +354,7 @@ int32_t A_GetFurthestAngle(int const spriteNum, int const angDiv) } } - return furthestAngle&2047; + return furthestAngle & 2047; } int A_FurthestVisiblePoint(int const spriteNum, uspritetype * const ts, vec2_t * const vect) @@ -485,7 +487,7 @@ void A_Fall(int const spriteNum) } } -int32_t __fastcall G_GetAngleDelta(int32_t currAngle, int32_t newAngle) +int __fastcall G_GetAngleDelta(int currAngle, int newAngle) { currAngle &= 2047; newAngle &= 2047; @@ -955,7 +957,7 @@ static void VM_AddInventory(DukePlayer_t * const pPlayer, int const itemNum, int } #endif -static int32_t A_GetVerticalVel(actor_t const * const pActor) +static int A_GetVerticalVel(actor_t const * const pActor) { #ifdef LUNATIC return pActor->mv.vvel; @@ -1236,7 +1238,7 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, fix16_t a, fix16_t horiz, int32_t sec void Screen_Play(void) { - int32_t running = 1; + bool running = true; I_ClearAllInput(); @@ -1250,10 +1252,9 @@ void Screen_Play(void) continue; videoClearScreen(0); - if (VM_OnEventWithReturn(EVENT_SCREEN, g_player[screenpeek].ps->i, screenpeek, I_CheckAllInput())) - running = 0; - // nextpage(); + if (VM_OnEventWithReturn(EVENT_SCREEN, g_player[screenpeek].ps->i, screenpeek, I_CheckAllInput())) + running = false; I_ClearAllInput(); } while (running); diff --git a/source/duke3d/src/gameexec.h b/source/duke3d/src/gameexec.h index 4aac19697..ebf00fac1 100644 --- a/source/duke3d/src/gameexec.h +++ b/source/duke3d/src/gameexec.h @@ -59,9 +59,9 @@ extern double g_eventTotalMs[MAXEVENTS], g_actorTotalMs[MAXTILES], g_actorMinMs[ void A_Execute(int spriteNum, int playerNum, int playerDist); void A_Fall(int spriteNum); -int32_t A_GetFurthestAngle(int spriteNum, int angDiv); +int A_GetFurthestAngle(int spriteNum, int angDiv); void A_GetZLimits(int spriteNum); -int32_t __fastcall G_GetAngleDelta(int32_t currAngle, int32_t newAngle); +int __fastcall G_GetAngleDelta(int currAngle, int newAngle); void G_RestoreMapState(); void G_SaveMapState(); diff --git a/source/duke3d/src/gamevars.cpp b/source/duke3d/src/gamevars.cpp index 85f96cd5f..4ca5ae481 100644 --- a/source/duke3d/src/gamevars.cpp +++ b/source/duke3d/src/gamevars.cpp @@ -38,24 +38,24 @@ int32_t g_gameArrayCount = 0; // pointers to weapon gamevar data intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine -intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) intptr_t *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire -intptr_t *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none) -intptr_t *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire. -intptr_t *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon -intptr_t *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots -intptr_t *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item -intptr_t *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn -intptr_t *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst') -intptr_t *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like -intptr_t *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when weapon starts firing. zero for no sound intptr_t *aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic) -intptr_t *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time -intptr_t *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID +intptr_t *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon +intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Muzzle flash color +intptr_t *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none) +intptr_t *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when weapon starts firing. zero for no sound +intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) intptr_t *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound of weapon being selected -intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Muzzle flash color +intptr_t *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots +intptr_t *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst') +intptr_t *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID +intptr_t *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time +intptr_t *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn +intptr_t *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item +intptr_t *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire. +intptr_t *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like # include "gamestructures.cpp" @@ -65,20 +65,18 @@ intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Muzzle flash color // Returns: old g_gameVarCount | (g_gameArrayCount<<16). int Gv_Free(void) { - for (bssize_t i=0; i> 16; - gameVarCount &= 65535; + Gv_Free(); // Now, only do work that Gv_Free() hasn't done. - for (bssize_t i=0; i= range)) \ - { \ - spriteNum = arrayIndex; \ - goto badindex; \ +#define CHECK_INDEX(range) \ + if (EDUKE32_PREDICT_FALSE((unsigned)arrayIndex >= (unsigned)range)) \ + { \ + spriteNum = arrayIndex; \ + goto badindex; \ } -int __fastcall Gv_GetSpecialVar(int gameVar, int spriteNum, int playerNum) +static int __fastcall Gv_GetSpecialVar(int gameVar, int spriteNum, int const playerNum) { int returnValue = 0; @@ -646,8 +642,8 @@ int __fastcall Gv_GetSpecialVar(int gameVar, int spriteNum, int playerNum) switch (gameVar - g_structVarIDs) { case STRUCT_SPRITE: - arrayIndexVar = (ActorLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVar(*insptr++, spriteNum, playerNum) : 0; CHECK_INDEX(MAXSPRITES); + arrayIndexVar = (ActorLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVar(*insptr++, spriteNum, playerNum) : 0; returnValue = VM_GetSprite(arrayIndex, labelNum, arrayIndexVar); break; @@ -1184,7 +1180,7 @@ void Gv_ResetSystemDefaults(void) for (int weaponNum = 0; weaponNum < MAX_WEAPONS; ++weaponNum) { - for (bssize_t playerNum = 0; playerNum < MAXPLAYERS; ++playerNum) + for (int playerNum = 0; playerNum < MAXPLAYERS; ++playerNum) { Bsprintf(aszBuf, "WEAPON%d_CLIP", weaponNum); aplWeaponClip[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum); @@ -1229,17 +1225,17 @@ void Gv_ResetSystemDefaults(void) } } + g_aimAngleVarID = Gv_GetVarIndex("AUTOAIMANGLE"); + g_angRangeVarID = Gv_GetVarIndex("ANGRANGE"); + g_hitagVarID = Gv_GetVarIndex("HITAG"); + g_lotagVarID = Gv_GetVarIndex("LOTAG"); g_returnVarID = Gv_GetVarIndex("RETURN"); + g_structVarIDs = Gv_GetVarIndex("sprite"); + g_textureVarID = Gv_GetVarIndex("TEXTURE"); + g_thisActorVarID = Gv_GetVarIndex("THISACTOR"); g_weaponVarID = Gv_GetVarIndex("WEAPON"); g_worksLikeVarID = Gv_GetVarIndex("WORKSLIKE"); g_zRangeVarID = Gv_GetVarIndex("ZRANGE"); - g_angRangeVarID = Gv_GetVarIndex("ANGRANGE"); - g_aimAngleVarID = Gv_GetVarIndex("AUTOAIMANGLE"); - g_lotagVarID = Gv_GetVarIndex("LOTAG"); - g_hitagVarID = Gv_GetVarIndex("HITAG"); - g_textureVarID = Gv_GetVarIndex("TEXTURE"); - g_thisActorVarID = Gv_GetVarIndex("THISACTOR"); - g_structVarIDs = Gv_GetVarIndex("sprite"); #endif for (auto & tile : g_tile) @@ -1462,22 +1458,22 @@ static void Gv_AddSystemVars(void) #if !defined LUNATIC // special vars for struct access // KEEPINSYNC gamedef.h: enum QuickStructureAccess_t (including order) - Gv_NewVar("sprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("__sprite__", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("__actor__", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("__spriteext__", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("sector", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("wall", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("player", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("actorvar", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("playervar", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("tspr", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("projectile", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("sprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("__sprite__", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("__actor__", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("__spriteext__", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("sector", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("wall", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("player", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("actorvar", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("playervar", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("tspr", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("projectile", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); Gv_NewVar("thisprojectile", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("userdef", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("input", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("tiledata", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); - Gv_NewVar("paldata", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("userdef", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("input", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("tiledata", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); + Gv_NewVar("paldata", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL); #endif if (NAM_WW2GI) @@ -1534,25 +1530,25 @@ static void Gv_AddSystemVars(void) for (int i=0; i