diff --git a/polymer/eduke32/build/include/osd.h b/polymer/eduke32/build/include/osd.h index 8e3729b48..85f3a5c21 100644 --- a/polymer/eduke32/build/include/osd.h +++ b/polymer/eduke32/build/include/osd.h @@ -246,7 +246,7 @@ void OSD_ResizeDisplay(int32_t w,int32_t h); void OSD_CaptureInput(int32_t cap); // sets the console version string -void OSD_SetVersion(const char *version, int32_t shade, int32_t pal); +void OSD_SetVersion(const char *gameVersion, int osdShade, int osdPal); // shows or hides the onscreen display void OSD_ShowDisplay(int32_t onf); diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index f644fb661..c48843144 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -37,47 +37,47 @@ extern int32_t g_noEnemies; int32_t otherp; -int32_t G_SetInterpolation(int32_t * const posptr) +int G_SetInterpolation(int32_t *const posptr) { - if (g_numInterpolations >= MAXINTERPOLATIONS) + if (g_interpolationCnt >= MAXINTERPOLATIONS) return 1; - for (bssize_t i = 0; i < g_numInterpolations; ++i) + for (bssize_t i = 0; i < g_interpolationCnt; ++i) if (curipos[i] == posptr) return 0; - curipos[g_numInterpolations] = posptr; - oldipos[g_numInterpolations] = *posptr; - g_numInterpolations++; + curipos[g_interpolationCnt] = posptr; + oldipos[g_interpolationCnt] = *posptr; + g_interpolationCnt++; return 0; } void G_StopInterpolation(int32_t * const posptr) { - for (bssize_t i = 0; i < g_numInterpolations; ++i) + for (bssize_t i = 0; i < g_interpolationCnt; ++i) if (curipos[i] == posptr) { - g_numInterpolations--; - oldipos[i] = oldipos[g_numInterpolations]; - bakipos[i] = bakipos[g_numInterpolations]; - curipos[i] = curipos[g_numInterpolations]; + g_interpolationCnt--; + oldipos[i] = oldipos[g_interpolationCnt]; + bakipos[i] = bakipos[g_interpolationCnt]; + curipos[i] = curipos[g_interpolationCnt]; } } -void G_DoInterpolations(int32_t smoothratio) //Stick at beginning of drawscreen +void G_DoInterpolations(int smoothRatio) { if (g_interpolationLock++) return; int32_t odelta, ndelta = 0; - for (bssize_t i = 0, j = 0; i < g_numInterpolations; ++i) + for (bssize_t i = 0, j = 0; i < g_interpolationCnt; ++i) { odelta = ndelta; bakipos[i] = *curipos[i]; ndelta = (*curipos[i]) - oldipos[i]; if (odelta != ndelta) - j = mulscale16(ndelta, smoothratio); + j = mulscale16(ndelta, smoothRatio); *curipos[i] = oldipos[i] + j; } } @@ -102,7 +102,7 @@ FORCE_INLINE int32_t G_WallSpriteDist(uwalltype const * const wal, uspritetype c return klabs(wal->x - spr->x) + klabs(wal->y - spr->y); } -void A_RadiusDamage(int32_t spriteNum, int32_t blastRadius, int32_t dmg1, int32_t dmg2, int32_t dmg3, int32_t dmg4) +void A_RadiusDamage(int spriteNum, int blastRadius, int dmg1, int dmg2, int dmg3, int dmg4) { int32_t d, q; uspritetype const *const pSprite = (uspritetype *)&sprite[spriteNum]; @@ -332,7 +332,7 @@ static int32_t Proj_MaybeDoTransport(int32_t spriteNum, const uspritetype * cons // Check whether sprite is on/in a non-SE7 water sector. // : if not NULL, the sector on the other side. -int32_t A_CheckNoSE7Water(uspritetype const * const pSprite, int32_t sectNum, int32_t sectLotag, int32_t *pOther) +int A_CheckNoSE7Water(uspritetype const * const pSprite, int sectNum, int sectLotag, int32_t *pOther) { if (sectLotag == ST_1_ABOVE_WATER || sectLotag == ST_2_UNDERWATER) { @@ -607,7 +607,7 @@ void A_DeleteSprite(int spriteNum) deletesprite(spriteNum); } -void A_AddToDeleteQueue(int32_t spriteNum) +void A_AddToDeleteQueue(int spriteNum) { if (g_deleteQueueSize == 0) { @@ -621,7 +621,7 @@ void A_AddToDeleteQueue(int32_t spriteNum) g_spriteDeleteQueuePos = (g_spriteDeleteQueuePos+1)%g_deleteQueueSize; } -void A_SpawnMultiple(int32_t spriteNum, int32_t tileNum, int32_t spawnCnt) +void A_SpawnMultiple(int spriteNum, int tileNum, int spawnCnt) { spritetype *pSprite = &sprite[spriteNum]; @@ -634,7 +634,7 @@ void A_SpawnMultiple(int32_t spriteNum, int32_t tileNum, int32_t spawnCnt) } } -void A_DoGuts(int32_t spriteNum, int32_t tileNum, int32_t spawnCnt) +void A_DoGuts(int spriteNum, int tileNum, int spawnCnt) { uspritetype const *const pSprite = (uspritetype *)&sprite[spriteNum]; vec2_t repeat = { 32, 32 }; @@ -667,7 +667,7 @@ void A_DoGuts(int32_t spriteNum, int32_t tileNum, int32_t spawnCnt) } } -void A_DoGutsDir(int32_t spriteNum, int32_t tileNum, int32_t spawnCnt) +void A_DoGutsDir(int spriteNum, int tileNum, int spawnCnt) { uspritetype const * const s = (uspritetype *)&sprite[spriteNum]; vec2_t repeat ={ 32, 32 }; @@ -777,15 +777,15 @@ void A_MoveSector(int spriteNum) #define LIGHTRAD(spriteNum, s) (s->yrepeat * tilesiz[s->picnum + LIGHTRAD_PICOFS(spriteNum)].y) #define LIGHTRAD2(spriteNum, s) ((s->yrepeat + ((rand() % s->yrepeat)>>2)) * tilesiz[s->picnum + LIGHTRAD_PICOFS(spriteNum)].y) -void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t range, int32_t color, int32_t priority) +void G_AddGameLight(int lightRadius, int spriteNum, int zOffset, int lightRange, int lightColor, int lightPrio) { #ifdef POLYMER - spritetype *s = &sprite[srcsprite]; + spritetype *s = &sprite[spriteNum]; if (getrendermode() != REND_POLYMER || pr_lighting != 1) return; - if (actor[srcsprite].lightptr == NULL) + if (actor[spriteNum].lightptr == NULL) { #pragma pack(push, 1) _prlight mylight; @@ -795,56 +795,56 @@ void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t mylight.sector = s->sectnum; mylight.x = s->x; mylight.y = s->y; - mylight.z = s->z - zoffset; - mylight.color[0] = color & 255; - mylight.color[1] = (color >> 8) & 255; - mylight.color[2] = (color >> 16) & 255; - mylight.radius = radius; - actor[srcsprite].lightmaxrange = mylight.range = range; + mylight.z = s->z - zOffset; + mylight.color[0] = lightColor & 255; + mylight.color[1] = (lightColor >> 8) & 255; + mylight.color[2] = (lightColor >> 16) & 255; + mylight.radius = lightRadius; + actor[spriteNum].lightmaxrange = mylight.range = lightRange; - mylight.priority = priority; + mylight.priority = lightPrio; mylight.tilenum = 0; mylight.publicflags.emitshadow = 1; mylight.publicflags.negative = 0; - actor[srcsprite].lightId = polymer_addlight(&mylight); - if (actor[srcsprite].lightId >= 0) - actor[srcsprite].lightptr = &prlights[actor[srcsprite].lightId]; + actor[spriteNum].lightId = polymer_addlight(&mylight); + if (actor[spriteNum].lightId >= 0) + actor[spriteNum].lightptr = &prlights[actor[spriteNum].lightId]; return; } - s->z -= zoffset; + s->z -= zOffset; - if (range> 1) - actor[srcsprite].lightmaxrange = 0; + if (lightRange> 1) + actor[spriteNum].lightmaxrange = 0; - if (range > actor[srcsprite].lightmaxrange || priority != actor[srcsprite].lightptr->priority || - Bmemcmp(&sprite[srcsprite], actor[srcsprite].lightptr, sizeof(int32_t) * 3)) + if (lightRange > actor[spriteNum].lightmaxrange || lightPrio != actor[spriteNum].lightptr->priority || + Bmemcmp(&sprite[spriteNum], actor[spriteNum].lightptr, sizeof(int32_t) * 3)) { - if (range > actor[srcsprite].lightmaxrange) - actor[srcsprite].lightmaxrange = range; + if (lightRange > actor[spriteNum].lightmaxrange) + actor[spriteNum].lightmaxrange = lightRange; - Bmemcpy(actor[srcsprite].lightptr, &sprite[srcsprite], sizeof(int32_t) * 3); - actor[srcsprite].lightptr->sector = s->sectnum; - actor[srcsprite].lightptr->flags.invalidate = 1; + Bmemcpy(actor[spriteNum].lightptr, &sprite[spriteNum], sizeof(int32_t) * 3); + actor[spriteNum].lightptr->sector = s->sectnum; + actor[spriteNum].lightptr->flags.invalidate = 1; } - actor[srcsprite].lightptr->priority = priority; - actor[srcsprite].lightptr->range = range; - actor[srcsprite].lightptr->color[0] = color & 255; - actor[srcsprite].lightptr->color[1] = (color >> 8) & 255; - actor[srcsprite].lightptr->color[2] = (color >> 16) & 255; + actor[spriteNum].lightptr->priority = lightPrio; + actor[spriteNum].lightptr->range = lightRange; + actor[spriteNum].lightptr->color[0] = lightColor & 255; + actor[spriteNum].lightptr->color[1] = (lightColor >> 8) & 255; + actor[spriteNum].lightptr->color[2] = (lightColor >> 16) & 255; - s->z += zoffset; + s->z += zOffset; #else - UNREFERENCED_PARAMETER(radius); - UNREFERENCED_PARAMETER(srcsprite); - UNREFERENCED_PARAMETER(zoffset); - UNREFERENCED_PARAMETER(range); - UNREFERENCED_PARAMETER(color); - UNREFERENCED_PARAMETER(priority); + UNREFERENCED_PARAMETER(lightRadius); + UNREFERENCED_PARAMETER(spriteNum); + UNREFERENCED_PARAMETER(zOffset); + UNREFERENCED_PARAMETER(lightRange); + UNREFERENCED_PARAMETER(lightColor); + UNREFERENCED_PARAMETER(lightPrio); #endif } @@ -1030,8 +1030,8 @@ int A_IncurDamage(int spriteNum) int const playerNum = P_GetP(pSprite); if (pActor->owner >= 0 && ud.ffire == 0 && sprite[pActor->owner].picnum == APLAYER && - (GametypeFlags[ud.coop] & GAMETYPE_PLAYERSFRIENDLY || - (GametypeFlags[ud.coop] & GAMETYPE_TDM && g_player[playerNum].ps->team == g_player[P_Get(pActor->owner)].ps->team))) + (g_gametypeFlags[ud.coop] & GAMETYPE_PLAYERSFRIENDLY || + (g_gametypeFlags[ud.coop] & GAMETYPE_TDM && g_player[playerNum].ps->team == g_player[P_Get(pActor->owner)].ps->team))) return -1; pSprite->extra -= pActor->extra; @@ -1088,9 +1088,9 @@ int A_IncurDamage(int spriteNum) void A_MoveCyclers(void) { - for (bssize_t i=g_numCyclers-1; i>=0; i--) + for (bssize_t i=g_cyclerCnt-1; i>=0; i--) { - int16_t *const pCycler = cyclers[i]; + int16_t *const pCycler = g_cyclers[i]; int const sectNum = pCycler[0]; int spriteShade = pCycler[2]; int const floorShade = pCycler[3]; @@ -1855,7 +1855,7 @@ ACTOR_STATIC void G_MoveStandables(void) { for (j=0; j<5; j++) RANDOMSCRAP(pSprite, spriteNum); x = pSprite->extra; - A_RadiusDamage(spriteNum, g_tripbombBlastRadius, x>>2,x>>1,x-(x>>2),x); + A_RadiusDamage(spriteNum, g_tripbombRadius, x>>2,x>>1,x-(x>>2),x); j = A_Spawn(spriteNum,EXPLOSION2); A_PlaySound(LASERTRIP_EXPLODE,j); @@ -2063,7 +2063,7 @@ crack_default: } x = pSprite->extra; - A_RadiusDamage(spriteNum, g_pipebombBlastRadius,x>>2, x-(x>>1),x-(x>>2), x); + A_RadiusDamage(spriteNum, g_pipebombRadius,x>>2, x-(x>>1),x-(x>>2), x); j = A_Spawn(spriteNum,EXPLOSION2); A_PlaySound(PIPEBOMB_EXPLODE,j); @@ -2071,7 +2071,7 @@ crack_default: } else { - A_RadiusDamage(spriteNum,g_seenineBlastRadius,10,15,20,25); + A_RadiusDamage(spriteNum,g_seenineRadius,10,15,20,25); DELETE_SPRITE_AND_CONTINUE(spriteNum); } goto next_sprite; @@ -2171,7 +2171,7 @@ DETONATE: { int32_t j = A_Spawn(spriteNum,EXPLOSION2); x = pSprite->extra; - A_RadiusDamage(spriteNum,g_seenineBlastRadius,x>>2, x-(x>>1),x-(x>>2), x); + A_RadiusDamage(spriteNum,g_seenineRadius,x>>2, x-(x>>1),x-(x>>2), x); A_PlaySound(PIPEBOMB_EXPLODE,j); } @@ -2718,7 +2718,9 @@ ACTOR_STATIC void Proj_MoveCustom(int spriteNum) default: case PROJECTILE_RPG: { - Bmemcpy(&davect, pSprite, sizeof(vec3_t)); + davect = *(vec3_t *) pSprite; + + VM_UpdateAnim(spriteNum, &actor[spriteNum].t_data[0]); if (pProj->flashcolor) G_AddGameLight(0, spriteNum, ((pSprite->yrepeat * tilesiz[pSprite->picnum].y) << 1), 2048, pProj->flashcolor, @@ -2785,7 +2787,8 @@ ACTOR_STATIC void Proj_MoveCustom(int spriteNum) (projVel * (sintable[pSprite->ang & 2047])) >> 14, projZvel }; Bmemcpy(&davect, pSprite, sizeof(vec3_t)); otherSprite = A_MoveSprite(spriteNum, &tmpvect, (A_CheckSpriteFlags(spriteNum, SFLAG_NOCLIP) ? 0 : CLIPMASK1)); - } while (!otherSprite && --projMoveCnt > 0); + } + while (!otherSprite && --projMoveCnt > 0); if (backupCstat) sprite[pSprite->owner].cstat = backupCstat; @@ -3195,12 +3198,12 @@ ACTOR_STATIC void G_MoveWeapons(void) if (pSprite->xrepeat >= 10) { int const x = pSprite->extra; - A_RadiusDamage(spriteNum, g_rpgBlastRadius, x >> 2, x >> 1, x - (x >> 2), x); + A_RadiusDamage(spriteNum, g_rpgRadius, x >> 2, x >> 1, x - (x >> 2), x); } else { int const x = pSprite->extra + (g_globalRandom & 3); - A_RadiusDamage(spriteNum, (g_rpgBlastRadius >> 1), x >> 2, x >> 1, x - (x >> 2), x); + A_RadiusDamage(spriteNum, (g_rpgRadius >> 1), x >> 2, x >> 1, x - (x >> 2), x); } break; } @@ -3208,7 +3211,7 @@ ACTOR_STATIC void G_MoveWeapons(void) case SHRINKSPARK__STATIC: A_Spawn(spriteNum, SHRINKEREXPLOSION); A_PlaySound(SHRINKER_HIT, spriteNum); - A_RadiusDamage(spriteNum, g_shrinkerBlastRadius, 0, 0, 0, 0); + A_RadiusDamage(spriteNum, g_shrinkerRadius, 0, 0, 0, 0); break; default: @@ -4606,6 +4609,7 @@ ACTOR_STATIC void G_MoveActors(void) } } + // can't initialize this because of the goto above vec3_t tmpvect; tmpvect.x = (pSprite->xvel * (sintable[(pSprite->ang + 512) & 2047])) >> 14; tmpvect.y = (pSprite->xvel * (sintable[pSprite->ang & 2047])) >> 14; @@ -4686,9 +4690,9 @@ DETONATEB: switch (DYNAMICTILEMAP(pSprite->picnum)) { - case HEAVYHBOMB__STATIC: radius = g_pipebombBlastRadius; break; - case MORTER__STATIC: radius = g_morterBlastRadius; break; - case BOUNCEMINE__STATIC: radius = g_bouncemineBlastRadius; break; + case HEAVYHBOMB__STATIC: radius = g_pipebombRadius; break; + case MORTER__STATIC: radius = g_morterRadius; break; + case BOUNCEMINE__STATIC: radius = g_bouncemineRadius; break; } A_RadiusDamage(spriteNum, radius, x >> 2, x >> 1, x - (x >> 2), x); @@ -4732,7 +4736,7 @@ DETONATEB: { if (pPlayer->ammo_amount[HANDBOMB_WEAPON] < pPlayer->max_ammo_amount[HANDBOMB_WEAPON]) { - if ((GametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY) && pSprite->owner == spriteNum) + if ((g_gametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY) && pSprite->owner == spriteNum) { for (bssize_t j = 0; j < pPlayer->weapreccnt; j++) { @@ -4759,7 +4763,7 @@ DETONATEB: if (pSprite->owner != spriteNum || ud.respawn_items == 0) { - if (pSprite->owner == spriteNum && (GametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY)) + if (pSprite->owner == spriteNum && (g_gametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY)) goto next_sprite; DELETE_SPRITE_AND_CONTINUE(spriteNum); } @@ -4965,8 +4969,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 while (spriteNum >= 0) { - int const nextSprite = nextspritestat[spriteNum]; - int32_t l; + int const nextSprite = nextspritestat[spriteNum]; int32_t playerDist; int32_t *const pData = actor[spriteNum].t_data; spritetype *const pSprite = &sprite[spriteNum]; @@ -5044,7 +5047,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 case FORCESPHERE__STATIC: { - l = pSprite->xrepeat; + int forceRepeat = pSprite->xrepeat; if (pData[1] > 0) { pData[1]--; @@ -5056,25 +5059,25 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 if (pData[0] < 64) { pData[0]++; - l += 3; + forceRepeat += 3; } } else if (pData[0] > 64) { pData[0]--; - l -= 3; + forceRepeat -= 3; } *(vec3_t *)pSprite = *(vec3_t *)&sprite[pSprite->owner]; - pSprite->ang += actor[pSprite->owner].t_data[0]; + pSprite->ang += actor[pSprite->owner].t_data[0]; - l = clamp2(l, 1, 64); + forceRepeat = clamp2(forceRepeat, 1, 64); + pSprite->xrepeat = forceRepeat; + pSprite->yrepeat = forceRepeat; + pSprite->shade = (forceRepeat >> 1) - 48; - pSprite->xrepeat = l; - pSprite->yrepeat = l; - pSprite->shade = (l >> 1) - 48; - - for (bssize_t j = pData[0]; j > 0; j--) A_SetSprite(spriteNum, CLIPMASK0); + for (bsize_t j = pData[0]; j > 0; j--) + A_SetSprite(spriteNum, CLIPMASK0); goto next_sprite; } @@ -5147,7 +5150,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 case MONEY__STATIC: case MAIL__STATIC: case PAPER__STATIC: - + { pSprite->xvel = (krand()&7)+(sintable[T1(spriteNum)&2047]>>9); T1(spriteNum) += (krand()&63); if ((T1(spriteNum)&2047) > 512 && (T1(spriteNum)&2047) < 1596) @@ -5161,21 +5164,21 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 pSprite->zvel += (g_spriteGravity>>5)+(krand()&7); } - A_SetSprite(spriteNum,CLIPMASK0); + A_SetSprite(spriteNum, CLIPMASK0); if ((krand()&3) == 0) - setsprite(spriteNum,(vec3_t *)pSprite); + setsprite(spriteNum, (vec3_t *) pSprite); if (pSprite->sectnum == -1) DELETE_SPRITE_AND_CONTINUE(spriteNum); - l = getflorzofslope(pSprite->sectnum,pSprite->x,pSprite->y); - if (pSprite->z > l) + int const floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); + + if (pSprite->z > floorZ) { - pSprite->z = l; - + pSprite->z = floorZ; A_AddToDeleteQueue(spriteNum); - PN(spriteNum) ++; + PN(spriteNum)++; for (bssize_t SPRITES_OF(STAT_MISC, j)) { @@ -5188,6 +5191,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 } break; + } case JIBS1__STATIC: case JIBS2__STATIC: @@ -5204,40 +5208,38 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 case DUKETORSO__STATIC: case DUKEGUN__STATIC: case DUKELEG__STATIC: - - if (pSprite->xvel > 0) - pSprite->xvel--; - else - pSprite->xvel = 0; + { + pSprite->xvel = (pSprite->xvel > 0) ? pSprite->xvel - 1 : 0; if (++pData[5] == (30*10)) DELETE_SPRITE_AND_CONTINUE(spriteNum); if (pSprite->zvel > 1024 && pSprite->zvel < 1280) { - setsprite(spriteNum,(vec3_t *)pSprite); + setsprite(spriteNum, (vec3_t *) pSprite); sectNum = pSprite->sectnum; } - getzsofslope(sectNum,pSprite->x,pSprite->y,&playerDist,&l); - if (playerDist == l || sectNum < 0 || sectNum >= MAXSECTORS) DELETE_SPRITE_AND_CONTINUE(spriteNum); + int32_t floorZ, ceilZ; + getzsofslope(sectNum, pSprite->x, pSprite->y, &ceilZ, &floorZ); - if (pSprite->z < l-(2<<8)) + if (ceilZ == floorZ || sectNum < 0 || sectNum >= MAXSECTORS) + DELETE_SPRITE_AND_CONTINUE(spriteNum); + + if (pSprite->z < floorZ-(2<<8)) { if (pData[1] < 2) pData[1]++; else if (sector[sectNum].lotag != ST_2_UNDERWATER) { pData[1] = 0; + if (pSprite->picnum == DUKELEG || pSprite->picnum == DUKETORSO || pSprite->picnum == DUKEGUN) { - if (pData[0] > 6) pData[0] = 0; - else pData[0]++; + pData[0] = (pData[0] > 6) ? 0 : pData[0] + 1; } else { - if (pData[0] > 2) - pData[0] = 0; - else pData[0]++; + pData[0] = (pData[0] > 2) ? 0 : pData[0] + 1; } } @@ -5255,7 +5257,6 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 pSprite->x += (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14; pSprite->y += (pSprite->xvel*sintable[pSprite->ang&2047])>>14; pSprite->z += pSprite->zvel; - } else { @@ -5269,16 +5270,18 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 pData[2]++; } - l = getflorzofslope(pSprite->sectnum,pSprite->x,pSprite->y); - pSprite->z = l-(2<<8); + floorZ = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); + pSprite->z = floorZ - (2 << 8); pSprite->xvel = 0; if (pSprite->picnum == JIBS6) { pData[1]++; + if ((pData[1]&3) == 0 && pData[0] < 7) pData[0]++; + if (pData[1] > 20) DELETE_SPRITE_AND_CONTINUE(spriteNum); } @@ -5288,9 +5291,9 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 pData[0] = 0; pData[1] = 0; } - } goto next_sprite; + } case BLOODPOOL__STATIC: case PUKE__STATIC: @@ -5307,14 +5310,16 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 A_Fall(spriteNum); - int32_t playerDist; - int32_t playerNum = A_FindPlayer(pSprite, &playerDist); - DukePlayer_t *pPlayer = g_player[playerNum].ps; - pSprite->z = actor[spriteNum].floorz - 1; + int32_t playerDist; + int const playerNum = A_FindPlayer(pSprite, &playerDist); + pSprite->z = actor[spriteNum].floorz - 1; + + DukePlayer_t *const pPlayer = g_player[playerNum].ps; if (pData[2] < 32) { pData[2]++; + if (actor[spriteNum].picnum == TIRE) { if (pSprite->xrepeat < 64 && pSprite->yrepeat < 64) @@ -5343,6 +5348,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 { if (!A_CheckSoundPlaying(pPlayer->i,DUKE_LONGTERM_PAIN)) A_PlaySound(DUKE_LONGTERM_PAIN,pPlayer->i); + sprite[pPlayer->i].extra --; P_PalFrom(pPlayer, 32, 16,0,0); @@ -5383,10 +5389,8 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 { if (!G_HaveActor(sprite[spriteNum].picnum)) goto next_sprite; - { - int32_t playerNum = A_FindPlayer(pSprite,&playerDist); - A_Execute(spriteNum,playerNum,playerDist); - } + int const playerNum = A_FindPlayer(pSprite, &playerDist); + A_Execute(spriteNum, playerNum, playerDist); goto next_sprite; } @@ -5485,20 +5489,13 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 { pData[1] = 0; - if (pSprite->picnum < SCRAP6+8) - { - if (pData[0] > 6) - pData[0] = 0; - else pData[0]++; - } + if (pSprite->picnum < SCRAP6 + 8) + pData[0] = (pData[0] > 6) ? 0 : pData[0] + 1; else - { - if (pData[0] > 2) - pData[0] = 0; - else pData[0]++; - } + pData[0] = (pData[0] > 2) ? 0 : pData[0] + 1; } - if (pSprite->zvel < 4096) pSprite->zvel += g_spriteGravity-50; + if (pSprite->zvel < 4096) + pSprite->zvel += g_spriteGravity - 50; pSprite->x += (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14; pSprite->y += (pSprite->xvel*sintable[pSprite->ang&2047])>>14; pSprite->z += pSprite->zvel; @@ -5526,115 +5523,116 @@ next_sprite: // i: SE spritenum -static void HandleSE31(int32_t i, int32_t setfloorzp, int32_t zref, int32_t t2val, int32_t movesignexp) +static void HandleSE31(int spriteNum, int setFloorZ, int spriteZ, int SEdir, int zDifference) { - const spritetype *s = &sprite[i]; - sectortype *const sc = §or[sprite[i].sectnum]; - int32_t *const t = actor[i].t_data; + const spritetype *pSprite = &sprite[spriteNum]; + sectortype *const pSector = §or[sprite[spriteNum].sectnum]; + int32_t *const pData = actor[spriteNum].t_data; - if (klabs(sc->floorz - zref) < SP(i)) + if (klabs(pSector->floorz - spriteZ) < SP(spriteNum)) { - if (setfloorzp) - sc->floorz = zref; + if (setFloorZ) + pSector->floorz = spriteZ; - t[2] = t2val; - t[0] = 0; - t[3] = s->hitag; - A_CallSound(s->sectnum,i); + pData[2] = SEdir; + pData[0] = 0; + pData[3] = pSprite->hitag; + + A_CallSound(pSprite->sectnum, spriteNum); } else { - int32_t j; - int32_t l = ksgn(movesignexp)*SP(i); + int const zChange = ksgn(zDifference) * SP(spriteNum); - sc->floorz += l; + pSector->floorz += zChange; - for (SPRITES_OF_SECT(s->sectnum, j)) + for (bssize_t SPRITES_OF_SECT(pSprite->sectnum, j)) { if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) - if (g_player[P_Get(j)].ps->on_ground == 1) - g_player[P_Get(j)].ps->pos.z += l; + { + int const playerNum = P_Get(j); + + if (g_player[playerNum].ps->on_ground == 1) + g_player[playerNum].ps->pos.z += zChange; + } if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE) { - actor[j].bpos.z = sprite[j].z += l; - actor[j].floorz = sc->floorz; + actor[j].bpos.z = sprite[j].z += zChange; + actor[j].floorz = pSector->floorz; } } } } // s: SE sprite -static void MaybeTrainKillPlayer(const spritetype *s, int32_t dosetopos) +static void MaybeTrainKillPlayer(const spritetype *pSprite, int setOPos) { - int32_t p; - - for (TRAVERSE_CONNECT(p)) + for (bssize_t TRAVERSE_CONNECT(playerNum)) { - DukePlayer_t *const ps = g_player[p].ps; + DukePlayer_t *const pPlayer = g_player[playerNum].ps; - if (sprite[ps->i].extra > 0) + if (sprite[pPlayer->i].extra > 0) { - int16_t k = ps->cursectnum; + int16_t playerSectnum = pPlayer->cursectnum; - updatesector(ps->pos.x,ps->pos.y,&k); - if ((k == -1 && ud.noclip == 0) || (k == s->sectnum && ps->cursectnum != s->sectnum)) + updatesector(pPlayer->pos.x, pPlayer->pos.y, &playerSectnum); + + if ((playerSectnum == -1 && ud.noclip == 0) || (playerSectnum == pSprite->sectnum && pPlayer->cursectnum != pSprite->sectnum)) { - ps->pos.x = s->x; - ps->pos.y = s->y; + *(vec2_t *)pPlayer = *(vec2_t *)pSprite; - if (dosetopos) - { - ps->opos.x = ps->pos.x; - ps->opos.y = ps->pos.y; - } + if (setOPos) + *(vec2_t *)&pPlayer->opos = *(vec2_t *)pPlayer; - ps->cursectnum = s->sectnum; + pPlayer->cursectnum = pSprite->sectnum; - setsprite(ps->i,(vec3_t const *)s); - P_QuickKill(ps); + setsprite(pPlayer->i, (vec3_t const *)pSprite); + P_QuickKill(pPlayer); } } } } // i: SE spritenum -static void MaybeTrainKillEnemies(int32_t i, int32_t numguts) +static void MaybeTrainKillEnemies(int spriteNum, int numGuts) { - int32_t j = headspritesect[sprite[OW(i)].sectnum]; + int findSprite = headspritesect[sprite[OW(spriteNum)].sectnum]; - while (j >= 0) + while (findSprite >= 0) { - const int32_t nextj = nextspritesect[j]; + int const nextSprite = nextspritesect[findSprite]; - if (sprite[j].extra >= 0 && sprite[j].statnum == STAT_ACTOR && A_CheckEnemySprite(&sprite[j])) + if (sprite[findSprite].extra >= 0 && sprite[findSprite].statnum == STAT_ACTOR && A_CheckEnemySprite(&sprite[findSprite])) { - int16_t k = sprite[j].sectnum; + int16_t sectNum = sprite[findSprite].sectnum; - updatesector(sprite[j].x,sprite[j].y,&k); - if (k == sprite[i].sectnum) + updatesector(sprite[findSprite].x,sprite[findSprite].y,§Num); + + if (sectNum == sprite[spriteNum].sectnum) { - A_DoGutsDir(j,JIBS6,numguts); - A_PlaySound(SQUISHED,j); - A_DeleteSprite(j); + A_DoGutsDir(findSprite, JIBS6, numGuts); + A_PlaySound(SQUISHED, findSprite); + A_DeleteSprite(findSprite); } } - j = nextj; + findSprite = nextSprite; } } ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { - int32_t q = 0, j, k, l, m, x; - int spriteNum = headspritestat[STAT_EFFECTOR]; + int32_t q = 0, j, k, l, m, x; + int spriteNum = headspritestat[STAT_EFFECTOR]; while (spriteNum >= 0) { int const nextSprite = nextspritestat[spriteNum]; - spritetype *const pSprite = &sprite[spriteNum]; - int32_t playerDist; - int32_t playerNum = A_FindPlayer(pSprite, &playerDist); + spritetype *const pSprite = &sprite[spriteNum]; + int32_t playerDist; + int playerNum = A_FindPlayer(pSprite, &playerDist); + DukePlayer_t *const pPlayer = g_player[playerNum].ps; if (VM_OnEventWithBoth(EVENT_MOVEEFFECTORS, spriteNum, playerNum, playerDist, 0)) { @@ -5642,11 +5640,10 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 continue; } - sectortype *const pSector = §or[pSprite->sectnum]; - int const sectorLotag = pSprite->lotag; - int const sectorHitag = pSprite->hitag; - - int32_t *const pData = &actor[spriteNum].t_data[0]; + sectortype *const pSector = §or[pSprite->sectnum]; + int const sectorLotag = pSprite->lotag; + int const sectorHitag = pSprite->hitag; + int32_t *const pData = &actor[spriteNum].t_data[0]; switch (sectorLotag) { @@ -5898,7 +5895,6 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 if (pSprite->xvel) { - int32_t p; #ifdef YAX_ENABLE int32_t firstrun = 1; #endif @@ -5917,11 +5913,10 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 } else if (ud.monsters_off == 0 && pSector->floorpal == 0 && (pSector->floorstat&1) && rnd(8)) { - p = A_FindPlayer(pSprite,&x); - if (x < 20480) + if (playerDist < 20480) { j = pSprite->ang; - pSprite->ang = getangle(pSprite->x-g_player[p].ps->pos.x,pSprite->y-g_player[p].ps->pos.y); + pSprite->ang = getangle(pSprite->x-g_player[playerNum].ps->pos.x,pSprite->y-g_player[playerNum].ps->pos.y); A_Shoot(spriteNum,RPG); pSprite->ang = j; } @@ -5940,51 +5935,51 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 m = (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14; x = (pSprite->xvel*sintable[pSprite->ang&2047])>>14; - for (TRAVERSE_CONNECT(p)) + for (TRAVERSE_CONNECT(playerNum)) { - DukePlayer_t *const ps = g_player[p].ps; + DukePlayer_t *const pPlayer = g_player[playerNum].ps; - if (ps->cursectnum < 0) + if (pPlayer->cursectnum < 0) { // might happen when squished into void space // initprintf("cursectnum < 0!\n"); break; } - if (sector[ps->cursectnum].lotag != ST_2_UNDERWATER) + if (sector[pPlayer->cursectnum].lotag != ST_2_UNDERWATER) { - if (g_playerSpawnPoints[p].sect == pSprite->sectnum) + if (g_playerSpawnPoints[playerNum].sect == pSprite->sectnum) { - g_playerSpawnPoints[p].pos.x += m; - g_playerSpawnPoints[p].pos.y += x; + g_playerSpawnPoints[playerNum].pos.x += m; + g_playerSpawnPoints[playerNum].pos.y += x; } - if (pSprite->sectnum == sprite[ps->i].sectnum + if (pSprite->sectnum == sprite[pPlayer->i].sectnum #ifdef YAX_ENABLE - || (pData[9]>=0 && pData[9] == sprite[ps->i].sectnum) + || (pData[9]>=0 && pData[9] == sprite[pPlayer->i].sectnum) #endif ) { - rotatepoint(*(vec2_t *)pSprite, *(vec2_t *)&ps->pos, q, (vec2_t *)&ps->pos); + rotatepoint(*(vec2_t *)pSprite, *(vec2_t *)&pPlayer->pos, q, (vec2_t *)&pPlayer->pos); - ps->pos.x += m; - ps->pos.y += x; + pPlayer->pos.x += m; + pPlayer->pos.y += x; - ps->bobpos.x += m; - ps->bobpos.y += x; + pPlayer->bobpos.x += m; + pPlayer->bobpos.y += x; - ps->ang += q; - ps->ang &= 2047; + pPlayer->ang += q; + pPlayer->ang &= 2047; if (g_netServer || numplayers > 1) { - ps->opos.x = ps->pos.x; - ps->opos.y = ps->pos.y; + pPlayer->opos.x = pPlayer->pos.x; + pPlayer->opos.y = pPlayer->pos.y; } - if (sprite[ps->i].extra <= 0) + if (sprite[pPlayer->i].extra <= 0) { - sprite[ps->i].x = ps->pos.x; - sprite[ps->i].y = ps->pos.y; + sprite[pPlayer->i].x = pPlayer->pos.x; + sprite[pPlayer->i].y = pPlayer->pos.y; } } } @@ -6200,8 +6195,6 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 if (pData[0] > 0) { - int32_t p, nextj; - pData[0]++; pSprite->xvel = 3; @@ -6220,36 +6213,35 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 A_PlaySound(EARTHQUAKE,g_player[screenpeek].ps->i); } - if (klabs(pSector->floorheinum-pData[5]) < 8) - pSector->floorheinum = pData[5]; - else pSector->floorheinum += (ksgn(pData[5]-pSector->floorheinum)<<4); + pSector->floorheinum = (klabs(pSector->floorheinum - pData[5]) < 8) + ? pData[5] + : pSector->floorheinum + (ksgn(pData[5] - pSector->floorheinum) << 4); } - m = (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14; - x = (pSprite->xvel*sintable[pSprite->ang&2047])>>14; + vec2_t const vect = { (pSprite->xvel * sintable[(pSprite->ang + 512) & 2047]) >> 14, + (pSprite->xvel * sintable[pSprite->ang & 2047]) >> 14 }; - - for (TRAVERSE_CONNECT(p)) + for (TRAVERSE_CONNECT(playerNum)) { - DukePlayer_t *const ps = g_player[p].ps; + DukePlayer_t *const pPlayer = g_player[playerNum].ps; - if (ps->cursectnum == pSprite->sectnum && ps->on_ground) + if (pPlayer->cursectnum == pSprite->sectnum && pPlayer->on_ground) { - ps->pos.x += m; - ps->pos.y += x; + pPlayer->pos.x += vect.x; + pPlayer->pos.y += vect.y; - ps->bobpos.x += m; - ps->bobpos.y += x; + pPlayer->bobpos.x += vect.x; + pPlayer->bobpos.y += vect.y; } } - for (SPRITES_OF_SECT_SAFE(pSprite->sectnum, j, nextj)) + for (bssize_t nextSprite, SPRITES_OF_SECT_SAFE(pSprite->sectnum, sectSprite, nextSprite)) { - if (sprite[j].picnum != SECTOREFFECTOR) + if (sprite[sectSprite].picnum != SECTOREFFECTOR) { - sprite[j].x+=m; - sprite[j].y+=x; - setsprite(j,(vec3_t *)&sprite[j]); + sprite[sectSprite].x+=vect.x; + sprite[sectSprite].y+=vect.y; + setsprite(sectSprite,(vec3_t *)&sprite[sectSprite]); } } @@ -6269,20 +6261,20 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 if ((tabledivide32_noinline(g_globalRandom, sectorHitag+1)&31) < 4 && !pData[2]) { // t[5] = 4+(g_globalRandom&7); - pSector->ceilingpal = pSprite->owner>>8; - pSector->floorpal = pSprite->owner&0xff; - pData[0] = pSprite->shade + (g_globalRandom&15); + pSector->ceilingpal = pSprite->owner >> 8; + pSector->floorpal = pSprite->owner & 0xff; + pData[0] = pSprite->shade + (g_globalRandom & 15); } else { // t[5] = 4+(g_globalRandom&3); pSector->ceilingpal = pSprite->pal; - pSector->floorpal = pSprite->pal; - pData[0] = pData[3]; + pSector->floorpal = pSprite->pal; + pData[0] = pData[3]; } pSector->ceilingshade = pData[0]; - pSector->floorshade = pData[0]; + pSector->floorshade = pData[0]; walltype *pWall = &wall[pSector->wallptr]; @@ -6291,10 +6283,9 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 if (pWall->hitag != 1) { pWall->shade = pData[0]; - if ((pWall->cstat&2) && pWall->nextwall >= 0) - { + + if ((pWall->cstat & 2) && pWall->nextwall >= 0) wall[pWall->nextwall].shade = pWall->shade; - } } } @@ -6307,14 +6298,15 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 // s->owner: original ((ceilingpal<<8) | floorpal) // t[2]: original floor shade // t[3]: max wall shade + int lightFlag; if ((tabledivide32_noinline(g_globalRandom, sectorHitag+1)&31) < 4) { - pData[1] = pSprite->shade + (g_globalRandom&15);//Got really bright - pData[0] = pSprite->shade + (g_globalRandom&15); - pSector->ceilingpal = pSprite->owner>>8; - pSector->floorpal = pSprite->owner&0xff; - j = 1; + pData[1] = pSprite->shade + (g_globalRandom & 15); // Got really bright + pData[0] = pSprite->shade + (g_globalRandom & 15); + pSector->ceilingpal = pSprite->owner >> 8; + pSector->floorpal = pSprite->owner & 0xff; + lightFlag = 1; } else { @@ -6322,9 +6314,9 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 pData[0] = pData[3]; pSector->ceilingpal = pSprite->pal; - pSector->floorpal = pSprite->pal; + pSector->floorpal = pSprite->pal; - j = 0; + lightFlag = 0; } pSector->floorshade = pData[1]; @@ -6334,7 +6326,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 for (x=pSector->wallnum; x > 0; x--,pWall++) { - if (j) pWall->pal = (pSprite->owner&0xff); + if (lightFlag) pWall->pal = (pSprite->owner&0xff); else pWall->pal = pSprite->pal; if (pWall->hitag != 1) @@ -6345,14 +6337,10 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 } } - for (SPRITES_OF_SECT(SECT(spriteNum), j)) + for (bssize_t SPRITES_OF_SECT(SECT(spriteNum), sectSprite)) { - if (sprite[j].cstat&16 && A_CheckSpriteFlags(j,SFLAG_NOSHADE) == 0) - { - if (pSector->ceilingstat&1) - sprite[j].shade = pSector->ceilingshade; - else sprite[j].shade = pSector->floorshade; - } + if (sprite[sectSprite].cstat&16 && A_CheckSpriteFlags(sectSprite,SFLAG_NOSHADE) == 0) + sprite[sectSprite].shade = (pSector->ceilingstat & 1) ? pSector->ceilingshade : pSector->floorshade; } if (pData[4]) @@ -6364,66 +6352,66 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 //BOSS case SE_5: { - const int32_t p = A_FindPlayer(pSprite,&x); - DukePlayer_t *const ps = g_player[p].ps; - - if (x < 8192) + if (playerDist < 8192) { - j = pSprite->ang; - pSprite->ang = getangle(pSprite->x-ps->pos.x,pSprite->y-ps->pos.y); - A_Shoot(spriteNum,FIRELASER); - pSprite->ang = j; + int const saveAng = pSprite->ang; + pSprite->ang = getangle(pSprite->x - pPlayer->pos.x, pSprite->y - pPlayer->pos.y); + A_Shoot(spriteNum, FIRELASER); + pSprite->ang = saveAng; } if (pSprite->owner==-1) //Start search { - pData[4]=0; - l = INT32_MAX; - while (1) //Find the shortest dist + pData[4] = 0; + int closestLocatorDist = INT32_MAX; + int closestLocator = pSprite->owner; + + //Find the shortest dist + do { - pSprite->owner = A_FindLocator((int16_t)pData[4],-1); //t[0] hold sectnum + pSprite->owner = A_FindLocator((int16_t)pData[4], -1); // t[0] hold sectnum - if (pSprite->owner==-1) break; + if (pSprite->owner == -1) + break; - m = ldist(&sprite[ps->i],&sprite[pSprite->owner]); + int const locatorDist = ldist(&sprite[pPlayer->i],&sprite[pSprite->owner]); - if (l > m) + if (closestLocatorDist > locatorDist) { - q = pSprite->owner; - l = m; + closestLocator = pSprite->owner; + closestLocatorDist = locatorDist; } pData[4]++; } + while (1); - pSprite->owner = q; - pSprite->zvel = ksgn(sprite[q].z-pSprite->z)<<4; + pSprite->owner = closestLocator; + pSprite->zvel = ksgn(sprite[closestLocator].z - pSprite->z) << 4; } if (ldist(&sprite[pSprite->owner],pSprite) < 1024) { - int16_t ta; - ta = pSprite->ang; - pSprite->ang = getangle(ps->pos.x-pSprite->x,ps->pos.y-pSprite->y); - pSprite->ang = ta; - pSprite->owner = -1; + int const saveAng = pSprite->ang; + pSprite->ang = getangle(pPlayer->pos.x - pSprite->x, pPlayer->pos.y - pSprite->y); + pSprite->ang = saveAng; + pSprite->owner = -1; goto next_sprite; - } else pSprite->xvel=256; - x = getangle(sprite[pSprite->owner].x-pSprite->x,sprite[pSprite->owner].y-pSprite->y); - q = G_GetAngleDelta(pSprite->ang,x)>>3; - pSprite->ang += q; + int const angInc = G_GetAngleDelta(pSprite->ang, getangle(sprite[pSprite->owner].x-pSprite->x, + sprite[pSprite->owner].y-pSprite->y))>>3; + pSprite->ang += angInc; if (rnd(32)) { - pData[2]+=q; + pData[2] += angInc; pSector->ceilingshade = 127; } else { - pData[2] += G_GetAngleDelta(pData[2]+512,getangle(ps->pos.x-pSprite->x,ps->pos.y-pSprite->y))>>2; + pData[2] += G_GetAngleDelta(pData[2] + 512, getangle(pPlayer->pos.x - pSprite->x, pPlayer->pos.y - pSprite->y)) >> 2; pSector->ceilingshade = 0; } @@ -6436,98 +6424,93 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 } } - pSprite->z += pSprite->zvel; - pSector->ceilingz += pSprite->zvel; + pSprite->z += pSprite->zvel; + pSector->ceilingz += pSprite->zvel; sector[pData[0]].ceilingz += pSprite->zvel; + A_MoveSector(spriteNum); - setsprite(spriteNum,(vec3_t *)pSprite); + setsprite(spriteNum, (vec3_t *)pSprite); break; } case SE_8_UP_OPEN_DOOR_LIGHTS: case SE_9_DOWN_OPEN_DOOR_LIGHTS: + { // work only if its moving - j = -1; + int animGoal = -1; if (actor[spriteNum].t_data[4]) { - actor[spriteNum].t_data[4]++; - if (actor[spriteNum].t_data[4] > 8) + if (++actor[spriteNum].t_data[4] > 8) DELETE_SPRITE_AND_CONTINUE(spriteNum); - j = 1; - } - else j = GetAnimationGoal(&pSector->ceilingz); - if (j >= 0) + animGoal = 1; + } + else animGoal = GetAnimationGoal(&pSector->ceilingz); + + if (animGoal >= 0) { - if ((pSector->lotag&0x8000) || actor[spriteNum].t_data[4]) - x = -pData[3]; - else - x = pData[3]; + int shadeInc = ((pSector->lotag & 0x8000) || actor[spriteNum].t_data[4]) ? -pData[3] : pData[3]; if (sectorLotag == SE_9_DOWN_OPEN_DOOR_LIGHTS) - x = -x; + shadeInc = -shadeInc; - for (SPRITES_OF(STAT_EFFECTOR, j)) + for (bssize_t SPRITES_OF(STAT_EFFECTOR, sectorEffector)) { - if (sprite[j].lotag == sectorLotag && sprite[j].hitag == sectorHitag) + if (sprite[sectorEffector].lotag == sectorLotag && sprite[sectorEffector].hitag == sectorHitag) { - int32_t sn = sprite[j].sectnum; + int const sectNum = sprite[sectorEffector].sectnum; + int const spriteShade = sprite[sectorEffector].shade; - m = sprite[j].shade; + walltype *pWall = &wall[sector[sectNum].wallptr]; - walltype *pWall = &wall[sector[sn].wallptr]; - - for (l=sector[sn].wallnum; l>0; l--,pWall++) + for (bsize_t l=sector[sectNum].wallnum; l>0; l--, pWall++) { - if (pWall->hitag != 1) - { - pWall->shade+=x; + if (pWall->hitag == 1) + continue; - if (pWall->shade < m) - pWall->shade = m; - else if (pWall->shade > actor[j].t_data[2]) - pWall->shade = actor[j].t_data[2]; + pWall->shade += shadeInc; - if (pWall->nextwall >= 0) - if (wall[pWall->nextwall].hitag != 1) - wall[pWall->nextwall].shade = pWall->shade; - } + if (pWall->shade < spriteShade) + pWall->shade = spriteShade; + else if (pWall->shade > actor[sectorEffector].t_data[2]) + pWall->shade = actor[sectorEffector].t_data[2]; + + if (pWall->nextwall >= 0 && wall[pWall->nextwall].hitag != 1) + wall[pWall->nextwall].shade = pWall->shade; } - sector[sn].floorshade += x; - sector[sn].ceilingshade += x; + sector[sectNum].floorshade += shadeInc; + sector[sectNum].ceilingshade += shadeInc; - if (sector[sn].floorshade < m) - sector[sn].floorshade = m; - else if (sector[sn].floorshade > actor[j].t_data[0]) - sector[sn].floorshade = actor[j].t_data[0]; - - if (sector[sn].ceilingshade < m) - sector[sn].ceilingshade = m; - else if (sector[sn].ceilingshade > actor[j].t_data[1]) - sector[sn].ceilingshade = actor[j].t_data[1]; + if (sector[sectNum].floorshade < spriteShade) + sector[sectNum].floorshade = spriteShade; + else if (sector[sectNum].floorshade > actor[sectorEffector].t_data[0]) + sector[sectNum].floorshade = actor[sectorEffector].t_data[0]; + if (sector[sectNum].ceilingshade < spriteShade) + sector[sectNum].ceilingshade = spriteShade; + else if (sector[sectNum].ceilingshade > actor[sectorEffector].t_data[1]) + sector[sectNum].ceilingshade = actor[sectorEffector].t_data[1]; } } } break; + } case SE_10_DOOR_AUTO_CLOSE: // XXX: 32791, what the hell? if ((pSector->lotag&0xff) == ST_27_STRETCH_BRIDGE || (pSector->floorz > pSector->ceilingz && (pSector->lotag&0xff) != ST_23_SWINGING_DOOR) || pSector->lotag == 32791) { - int32_t p; - j = 1; if ((pSector->lotag&0xff) != ST_27_STRETCH_BRIDGE) - for (TRAVERSE_CONNECT(p)) - if (pSector->lotag != ST_30_ROTATE_RISE_BRIDGE && pSector->lotag != ST_31_TWO_WAY_TRAIN && pSector->lotag != 0) - if (pSprite->sectnum == sprite[g_player[p].ps->i].sectnum) - j = 0; + for (bssize_t TRAVERSE_CONNECT(playerNum)) + if (pSector->lotag != ST_30_ROTATE_RISE_BRIDGE && pSector->lotag != ST_31_TWO_WAY_TRAIN && pSector->lotag != 0 + && pSprite->sectnum == sprite[g_player[playerNum].ps->i].sectnum) + j = 0; if (j == 1) { @@ -6561,9 +6544,9 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 if (pData[4]) { - int32_t endwall = pSector->wallptr+pSector->wallnum; + int const endWall = pSector->wallptr+pSector->wallnum; - for (j=pSector->wallptr; jwallptr; j= 0 && clipinsidebox((vec2_t *)&sprite[k], j, 144) == 1) { - pData[5] = 8; // Delay - k = (SP(spriteNum)>>3)*pData[3]; + pData[5] = 8; // Delay + k = (SP(spriteNum) >> 3) * pData[3]; pData[2] -= k; pData[4] -= k; A_MoveSector(spriteNum); - setsprite(spriteNum,(vec3_t *)pSprite); + setsprite(spriteNum, (vec3_t *)pSprite); goto next_sprite; } } } - k = (SP(spriteNum)>>3)*pData[3]; - pData[2]+=k; - pData[4]+=k; + k = (SP(spriteNum) >> 3) * pData[3]; + pData[2] += k; + pData[4] += k; A_MoveSector(spriteNum); - setsprite(spriteNum,(vec3_t *)pSprite); + setsprite(spriteNum, (vec3_t *)pSprite); if (pData[4] <= -511 || pData[4] >= 512) { pData[4] = 0; pData[2] &= 0xffffff00; A_MoveSector(spriteNum); - setsprite(spriteNum,(vec3_t *)pSprite); + setsprite(spriteNum, (vec3_t *) pSprite); break; } } @@ -6607,51 +6590,53 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 case SE_12_LIGHT_SWITCH: if (pData[0] == 3 || pData[3] == 1) //Lights going off { - pSector->floorpal = 0; + pSector->floorpal = 0; pSector->ceilingpal = 0; walltype *pWall = &wall[pSector->wallptr]; + for (j = pSector->wallnum; j > 0; j--, pWall++) + { if (pWall->hitag != 1) { pWall->shade = pData[1]; - pWall->pal = 0; + pWall->pal = 0; } + } - pSector->floorshade = pData[1]; + pSector->floorshade = pData[1]; pSector->ceilingshade = pData[2]; - pData[0]=0; + pData[0] = 0; for (SPRITES_OF_SECT(SECT(spriteNum), j)) { - if (sprite[j].cstat&16 && A_CheckSpriteFlags(j,SFLAG_NOSHADE) == 0) - { - if (pSector->ceilingstat&1) - sprite[j].shade = pSector->ceilingshade; - else sprite[j].shade = pSector->floorshade; - } + if ((sprite[j].cstat & 16) && (A_CheckSpriteFlags(j, SFLAG_NOSHADE) == 0)) + sprite[j].shade = (pSector->ceilingstat & 1) ? pSector->ceilingshade : pSector->floorshade; } if (pData[3] == 1) DELETE_SPRITE_AND_CONTINUE(spriteNum); } + if (pData[0] == 1) //Lights flickering on { if (pSector->floorshade > pSprite->shade) { - pSector->floorpal = pSprite->pal; + pSector->floorpal = pSprite->pal; pSector->ceilingpal = pSprite->pal; - pSector->floorshade -= 2; + pSector->floorshade -= 2; pSector->ceilingshade -= 2; walltype *pWall = &wall[pSector->wallptr]; - for (j=pSector->wallnum; j>0; j--,pWall++) + for (j = pSector->wallnum; j > 0; j--, pWall++) + { if (pWall->hitag != 1) { pWall->pal = pSprite->pal; pWall->shade -= 2; } + } } else pData[0] = 2; @@ -6659,9 +6644,8 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { if (sprite[j].cstat&16) { - if (pSector->ceilingstat&1 && A_CheckSpriteFlags(j,SFLAG_NOSHADE) == 0) - sprite[j].shade = pSector->ceilingshade; - else sprite[j].shade = pSector->floorshade; + if ((sprite[j].cstat & 16) && (A_CheckSpriteFlags(j, SFLAG_NOSHADE) == 0)) + sprite[j].shade = (pSector->ceilingstat & 1) ? pSector->ceilingshade : pSector->floorshade; } } } @@ -6682,25 +6666,26 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { if (pSprite->owner) { - if (klabs(pData[0]-pSector->ceilingz) >= j) - pSector->ceilingz += ksgn(pData[0]-pSector->ceilingz)*j; - else pSector->ceilingz = pData[0]; + pSector->ceilingz = (klabs(pData[0] - pSector->ceilingz) >= j) + ? pSector->ceilingz + ksgn(pData[0] - pSector->ceilingz) * j + : pData[0]; } else { - if (klabs(pData[1]-pSector->floorz) >= j) - pSector->floorz += ksgn(pData[1]-pSector->floorz)*j; - else pSector->floorz = pData[1]; + pSector->floorz = (klabs(pData[1] - pSector->floorz) >= j) + ? pSector->floorz + ksgn(pData[1] - pSector->floorz) * j + : pData[1]; } } else { - if (klabs(pData[1]-pSector->floorz) >= j) - pSector->floorz += ksgn(pData[1]-pSector->floorz)*j; - else pSector->floorz = pData[1]; - if (klabs(pData[0]-pSector->ceilingz) >= j) - pSector->ceilingz += ksgn(pData[0]-pSector->ceilingz)*j; - pSector->ceilingz = pData[0]; + pSector->floorz = (klabs(pData[1] - pSector->floorz) >= j) + ? pSector->floorz + ksgn(pData[1] - pSector->floorz) * j + : pData[1]; + + pSector->ceilingz = (klabs(pData[0] - pSector->ceilingz) >= j) + ? pSector->ceilingz + ksgn(pData[0] - pSector->ceilingz) * j + : pData[0]; } #ifdef YAX_ENABLE if (pSprite->ang == 512) @@ -6733,28 +6718,28 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 if (pSprite->ang == 512) { walltype *pWall = &wall[pSector->wallptr]; - for (j=pSector->wallnum; j>0; j--,pWall++) + + for (j = pSector->wallnum; j > 0; j--, pWall++) pWall->shade = pSprite->shade; pSector->floorshade = pSprite->shade; if (g_player[0].ps->one_parallax_sectnum >= 0) { - pSector->ceilingpicnum = - sector[g_player[0].ps->one_parallax_sectnum].ceilingpicnum; - pSector->ceilingshade = - sector[g_player[0].ps->one_parallax_sectnum].ceilingshade; + pSector->ceilingpicnum = sector[g_player[0].ps->one_parallax_sectnum].ceilingpicnum; + pSector->ceilingshade = sector[g_player[0].ps->one_parallax_sectnum].ceilingshade; } } } - pData[2]++; - if (pData[2] > 256) + + if (++pData[2] > 256) DELETE_SPRITE_AND_CONTINUE(spriteNum); } if (pData[2] == 4 && pSprite->ang != 512) for (x=0; x<7; x++) RANDOMSCRAP(pSprite, spriteNum); + break; @@ -6793,11 +6778,11 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 case SE_16_REACTOR: //Reactor pData[2]+=32; - if (pSector->floorzceilingz) pSprite->shade=0; + if (pSector->floorz < pSector->ceilingz) + pSprite->shade = 0; else if (pSector->ceilingz < pData[3]) { - //The following code check to see if //there is any other sprites in the sector. //If there isn't, then kill this sectoreffector @@ -6815,8 +6800,9 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 pSprite->shade = 1; } - if (pSprite->shade) pSector->ceilingz+=1024; - else pSector->ceilingz-=512; + pSector->ceilingz = (pSprite->shade) + ? pSector->ceilingz + 1024 + : pSector->ceilingz - 512; A_MoveSector(spriteNum); setsprite(spriteNum,(vec3_t *)pSprite); @@ -6836,26 +6822,27 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { if (sprite[j].statnum == STAT_PLAYER && sprite[j].owner >= 0) { - const int32_t p = P_Get(j); - DukePlayer_t *const ps = g_player[p].ps; + int const warpPlayer = P_Get(j); + DukePlayer_t *const pPlayer = g_player[warpPlayer].ps; if (numplayers < 2 && !g_netServer) - ps->opos.z = ps->pos.z; + pPlayer->opos.z = pPlayer->pos.z; - ps->pos.z += q; - ps->truefz += q; - ps->truecz += q; + pPlayer->pos.z += q; + pPlayer->truefz += q; + pPlayer->truecz += q; if (g_netServer || numplayers > 1) - ps->opos.z = ps->pos.z; + pPlayer->opos.z = pPlayer->pos.z; } + if (sprite[j].statnum != STAT_EFFECTOR) { actor[j].bpos.z = sprite[j].z; sprite[j].z += q; } - actor[j].floorz = pSector->floorz; + actor[j].floorz = pSector->floorz; actor[j].ceilingz = pSector->ceilingz; } @@ -6892,26 +6879,25 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { if (sprite[k].statnum == STAT_PLAYER && sprite[k].owner >= 0) { - const int32_t p = P_Get(k); - DukePlayer_t *const ps = g_player[p].ps; + int const warpPlayer = P_Get(k); + DukePlayer_t *const pPlayer = g_player[warpPlayer].ps; - ps->pos.x += sprite[j].x-pSprite->x; - ps->pos.y += sprite[j].y-pSprite->y; - ps->opos.z -= ps->pos.z; - ps->pos.z = sector[sprite[j].sectnum].floorz-(pSector->floorz-ps->pos.z); - ps->opos.z += ps->pos.z; - actor[k].floorz = sector[sprite[j].sectnum].floorz; - actor[k].ceilingz = sector[sprite[j].sectnum].ceilingz; + pPlayer->pos.x += sprite[j].x - pSprite->x; + pPlayer->pos.y += sprite[j].y - pSprite->y; + pPlayer->opos.z -= pPlayer->pos.z; + pPlayer->pos.z = sector[sprite[j].sectnum].floorz - (pSector->floorz - pPlayer->pos.z); + pPlayer->opos.z += pPlayer->pos.z; - ps->bobpos.x = ps->opos.x = ps->pos.x; - ps->bobpos.y = ps->opos.y = ps->pos.y; + actor[k].floorz = sector[sprite[j].sectnum].floorz; + actor[k].ceilingz = sector[sprite[j].sectnum].ceilingz; + *(vec2_t *)&pPlayer->opos = *(vec2_t *)pPlayer; + *(vec2_t *)&pPlayer->bobpos = *(vec2_t *)pPlayer; + pPlayer->truefz = actor[k].floorz; + pPlayer->truecz = actor[k].ceilingz; + pPlayer->bobcounter = 0; - ps->truefz = actor[k].floorz; - ps->truecz = actor[k].ceilingz; - ps->bobcounter = 0; - - changespritesect(k,sprite[j].sectnum); - ps->cursectnum = sprite[j].sectnum; + changespritesect(k, sprite[j].sectnum); + pPlayer->cursectnum = sprite[j].sectnum; } else if (sprite[k].statnum != STAT_EFFECTOR) { @@ -6921,14 +6907,13 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 Bmemcpy(&actor[k].bpos, &sprite[k], sizeof(vec2_t)); actor[k].bpos.z -= sprite[k].z; - sprite[k].z = sector[sprite[j].sectnum].floorz- - (pSector->floorz-sprite[k].z); + sprite[k].z = sector[sprite[j].sectnum].floorz - (pSector->floorz - sprite[k].z); actor[k].bpos.z += sprite[k].z; changespritesect(k,sprite[j].sectnum); setsprite(k,(vec3_t *)&sprite[k]); - actor[k].floorz = sector[sprite[j].sectnum].floorz; + actor[k].floorz = sector[sprite[j].sectnum].floorz; actor[k].ceilingz = sector[sprite[j].sectnum].ceilingz; } } @@ -6954,16 +6939,15 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { pSector->floorz += pSector->extra; - for (SPRITES_OF_SECT(pSprite->sectnum, j)) + for (bssize_t SPRITES_OF_SECT(pSprite->sectnum, sectSprite)) { - if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) - if (g_player[P_Get(j)].ps->on_ground == 1) - g_player[P_Get(j)].ps->pos.z += pSector->extra; + if (sprite[sectSprite].picnum == APLAYER && sprite[sectSprite].owner >= 0 && g_player[P_Get(sectSprite)].ps->on_ground == 1) + g_player[P_Get(sectSprite)].ps->pos.z += pSector->extra; - if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE) + if (sprite[sectSprite].zvel == 0 && sprite[sectSprite].statnum != STAT_EFFECTOR && sprite[sectSprite].statnum != STAT_PROJECTILE) { - actor[j].bpos.z = sprite[j].z += pSector->extra; - actor[j].floorz = pSector->floorz; + actor[sectSprite].bpos.z = sprite[sectSprite].z += pSector->extra; + actor[sectSprite].floorz = pSector->floorz; } } @@ -6989,16 +6973,15 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { pSector->floorz -= pSector->extra; - for (SPRITES_OF_SECT(pSprite->sectnum, j)) + for (bssize_t SPRITES_OF_SECT(pSprite->sectnum, sectSprite)) { - if (sprite[j].picnum == APLAYER && sprite[j].owner >= 0) - if (g_player[P_Get(j)].ps->on_ground == 1) - g_player[P_Get(j)].ps->pos.z -= pSector->extra; + if (sprite[sectSprite].picnum == APLAYER && sprite[sectSprite].owner >= 0 &&g_player[P_Get(sectSprite)].ps->on_ground == 1) + g_player[P_Get(sectSprite)].ps->pos.z -= pSector->extra; - if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE) + if (sprite[sectSprite].zvel == 0 && sprite[sectSprite].statnum != STAT_EFFECTOR && sprite[sectSprite].statnum != STAT_PROJECTILE) { - actor[j].bpos.z = sprite[j].z -= pSector->extra; - actor[j].floorz = pSector->floorz; + actor[sectSprite].bpos.z = sprite[sectSprite].z -= pSector->extra; + actor[sectSprite].floorz = pSector->floorz; } } @@ -7010,8 +6993,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 } } - pData[2]++; - if (pData[2] >= pSprite->hitag) + if (++pData[2] >= pSprite->hitag) { pData[2] = 0; pData[0] = 0; @@ -7028,17 +7010,21 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 pData[0]++; x = pSector->wallptr; q = x+pSector->wallnum; + for (j=x; j= 0) { wall[wall[j].nextwall].overpicnum = 0; wall[wall[j].nextwall].cstat &= (128+32+8+4+2); } } + } } if (pSector->ceilingz < pSector->floorz) @@ -7051,11 +7037,13 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { if (sprite[j].lotag == SE_0_ROTATING_SECTOR && sprite[j].hitag==sectorHitag) { - sectortype *const sec = §or[sprite[j].sectnum]; + sectortype *const pSector = §or[sprite[j].sectnum]; + int const ownerSector = sprite[sprite[j].owner].sectnum; - q = sprite[sprite[j].owner].sectnum; - sec->floorpal = sec->ceilingpal = sector[q].floorpal; - sec->floorshade = sec->ceilingshade = sector[q].floorshade; + pSector->ceilingpal = sector[ownerSector].floorpal; + pSector->floorpal = pSector->ceilingpal; + pSector->ceilingshade = sector[ownerSector].floorshade; + pSector->floorshade = pSector->ceilingshade; actor[sprite[j].owner].t_data[0] = 2; } @@ -7072,16 +7060,18 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 for (SPRITES_OF(STAT_EFFECTOR, l)) { - x = sprite[l].lotag&0x7fff; - switch (x) + switch (sprite[l].lotag & 0x7fff) { case SE_0_ROTATING_SECTOR: if (sprite[l].hitag == sectorHitag) { - int32_t ow = sprite[l].owner; - q = sprite[l].sectnum; - sector[q].floorshade = sector[q].ceilingshade = sprite[ow].shade; - sector[q].floorpal = sector[q].ceilingpal = sprite[ow].pal; + int const spriteOwner = sprite[l].owner; + int const sectNum = sprite[l].sectnum; + + sector[sectNum].ceilingshade = sprite[spriteOwner].shade; + sector[sectNum].floorshade = sector[sectNum].ceilingshade; + sector[sectNum].ceilingpal = sprite[spriteOwner].pal; + sector[sectNum].floorpal = sector[sectNum].ceilingpal; } break; @@ -7092,8 +7082,8 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 if (sectorHitag == sprite[l].hitag) if (actor[l].t_data[0] == 0) { - actor[l].t_data[0] = 1; //Shut them all on - sprite[l].owner = spriteNum; + actor[l].t_data[0] = 1; // Shut them all on + sprite[l].owner = spriteNum; } break; @@ -7106,83 +7096,76 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 case SE_20_STRETCH_BRIDGE: //Extend-o-bridge if (pData[0] == 0) break; - if (pData[0] == 1) pSprite->xvel = 8; - else pSprite->xvel = -8; + pSprite->xvel = (pData[0] == 1) ? 8 : -8; if (pSprite->xvel) //Moving { - int32_t p, nextj; - - x = (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14; - l = (pSprite->xvel*sintable[pSprite->ang&2047])>>14; + vec2_t const vect = { (pSprite->xvel * sintable[(pSprite->ang + 512) & 2047]) >> 14, + (pSprite->xvel * sintable[pSprite->ang & 2047]) >> 14 }; pData[3] += pSprite->xvel; - pSprite->x += x; - pSprite->y += l; + pSprite->x += vect.x; + pSprite->y += vect.y; - if (pData[3] <= 0 || (pData[3]>>6) >= (SP(spriteNum)>>6)) + if (pData[3] <= 0 || (pData[3] >> 6) >= (SP(spriteNum) >> 6)) { - pSprite->x -= x; - pSprite->y -= l; + pSprite->x -= vect.x; + pSprite->y -= vect.y; pData[0] = 0; - A_CallSound(pSprite->sectnum,spriteNum); + A_CallSound(pSprite->sectnum, spriteNum); break; } - for (SPRITES_OF_SECT_SAFE(pSprite->sectnum, j, nextj)) + for (bssize_t nextSprite, SPRITES_OF_SECT_SAFE(pSprite->sectnum, sectSprite, nextSprite)) { - if (sprite[j].statnum != STAT_EFFECTOR && sprite[j].zvel == 0) + if (sprite[sectSprite].statnum != STAT_EFFECTOR && sprite[sectSprite].zvel == 0) { - sprite[j].x += x; - sprite[j].y += l; - setsprite(j,(vec3_t *)&sprite[j]); - if (sector[sprite[j].sectnum].floorstat&2) - if (sprite[j].statnum == STAT_ZOMBIEACTOR) - A_Fall(j); + sprite[sectSprite].x += vect.x; + sprite[sectSprite].y += vect.y; + + setsprite(sectSprite, (vec3_t *)&sprite[sectSprite]); + + if (sector[sprite[sectSprite].sectnum].floorstat & 2 && sprite[sectSprite].statnum == STAT_ZOMBIEACTOR) + A_Fall(sectSprite); } } - dragpoint((int16_t)pData[1],wall[pData[1]].x+x,wall[pData[1]].y+l,0); - dragpoint((int16_t)pData[2],wall[pData[2]].x+x,wall[pData[2]].y+l,0); + dragpoint((int16_t)pData[1], wall[pData[1]].x + vect.x, wall[pData[1]].y + vect.y, 0); + dragpoint((int16_t)pData[2], wall[pData[2]].x + vect.x, wall[pData[2]].y + vect.y, 0); - for (TRAVERSE_CONNECT(p)) + for (bssize_t TRAVERSE_CONNECT(playerNum)) { - DukePlayer_t *const ps = g_player[p].ps; + DukePlayer_t *const pPlayer = g_player[playerNum].ps; - if (ps->cursectnum == pSprite->sectnum && ps->on_ground) + if (pPlayer->cursectnum == pSprite->sectnum && pPlayer->on_ground) { - ps->pos.x += x; - ps->pos.y += l; + pPlayer->pos.x += vect.x; + pPlayer->pos.y += vect.y; - ps->opos.x = ps->pos.x; - ps->opos.y = ps->pos.y; + pPlayer->opos.x = pPlayer->pos.x; + pPlayer->opos.y = pPlayer->pos.y; - ps->pos.z += PHEIGHT; - setsprite(ps->i,(vec3_t *)ps); - ps->pos.z -= PHEIGHT; + pPlayer->pos.z += PHEIGHT; + setsprite(pPlayer->i, (vec3_t *)pPlayer); + pPlayer->pos.z -= PHEIGHT; } } - pSector->floorxpanning-=x>>3; - pSector->floorypanning-=l>>3; + pSector->floorxpanning -= vect.x >> 3; + pSector->floorypanning -= vect.y >> 3; - pSector->ceilingxpanning-=x>>3; - pSector->ceilingypanning-=l>>3; + pSector->ceilingxpanning -= vect.x >> 3; + pSector->ceilingypanning -= vect.y >> 3; } break; case SE_21_DROP_FLOOR: // Cascading effect { - int32_t *zptr; - if (pData[0] == 0) break; - if (pSprite->ang == 1536) - zptr = &pSector->ceilingz; - else - zptr = &pSector->floorz; + int32_t *zptr = (pSprite->ang == 1536) ? &pSector->ceilingz : &pSector->floorz; if (pData[0] == 1) //Decide if the s->sectnum should go up or down { @@ -7216,92 +7199,87 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 case SE_24_CONVEYOR: case SE_34: { - int32_t p, nextj; - if (pData[4]) break; - x = (SP(spriteNum)*sintable[(pSprite->ang+512)&2047])>>18; - l = (SP(spriteNum)*sintable[pSprite->ang&2047])>>18; + vec2_t const vect = { (SP(spriteNum) * sintable[(pSprite->ang + 512) & 2047]) >> 18, + (SP(spriteNum) * sintable[pSprite->ang & 2047]) >> 18 }; k = 0; - for (SPRITES_OF_SECT_SAFE(pSprite->sectnum, j, nextj)) + for (bssize_t nextSprite, SPRITES_OF_SECT_SAFE(pSprite->sectnum, sectSprite, nextSprite)) { - if (sprite[j].zvel >= 0) - switch (sprite[j].statnum) - { - case STAT_MISC: - switch (DYNAMICTILEMAP(sprite[j].picnum)) - { - case BLOODPOOL__STATIC: - case PUKE__STATIC: - case FOOTPRINTS__STATIC: - case FOOTPRINTS2__STATIC: - case FOOTPRINTS3__STATIC: - case FOOTPRINTS4__STATIC: - case BULLETHOLE__STATIC: - case BLOODSPLAT1__STATIC: - case BLOODSPLAT2__STATIC: - case BLOODSPLAT3__STATIC: - case BLOODSPLAT4__STATIC: - sprite[j].xrepeat = sprite[j].yrepeat = 0; - continue; + if (sprite[sectSprite].zvel < 0) + continue; - case LASERLINE__STATIC: - continue; + switch (sprite[sectSprite].statnum) + { + case STAT_MISC: + switch (DYNAMICTILEMAP(sprite[sectSprite].picnum)) + { + case BLOODPOOL__STATIC: + case PUKE__STATIC: + case FOOTPRINTS__STATIC: + case FOOTPRINTS2__STATIC: + case FOOTPRINTS3__STATIC: + case FOOTPRINTS4__STATIC: + case BULLETHOLE__STATIC: + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: sprite[sectSprite].xrepeat = sprite[sectSprite].yrepeat = 0; continue; + + case LASERLINE__STATIC: continue; } - // fall-through + // fall-through case STAT_STANDABLE: - if (sprite[j].picnum == TRIPBOMB) + if (sprite[sectSprite].picnum == TRIPBOMB) break; - // else, fall-through + // else, fall-through case STAT_ACTOR: case STAT_DEFAULT: - if ( - sprite[j].picnum == BOLT1 || - sprite[j].picnum == BOLT1+1 || - sprite[j].picnum == BOLT1+2 || - sprite[j].picnum == BOLT1+3 || - sprite[j].picnum == SIDEBOLT1 || - sprite[j].picnum == SIDEBOLT1+1 || - sprite[j].picnum == SIDEBOLT1+2 || - sprite[j].picnum == SIDEBOLT1+3 || - A_CheckSwitchTile(j) - ) + if (sprite[sectSprite].picnum == BOLT1 + || sprite[sectSprite].picnum == BOLT1 + 1 + || sprite[sectSprite].picnum == BOLT1 + 2 + || sprite[sectSprite].picnum == BOLT1 + 3 + || sprite[sectSprite].picnum == SIDEBOLT1 + || sprite[sectSprite].picnum == SIDEBOLT1 + 1 + || sprite[sectSprite].picnum == SIDEBOLT1 + 2 + || sprite[sectSprite].picnum == SIDEBOLT1 + 3 + || A_CheckSwitchTile(sectSprite)) break; - if (!(sprite[j].picnum >= CRANE && sprite[j].picnum <= CRANE+3)) + if (!(sprite[sectSprite].picnum >= CRANE && sprite[sectSprite].picnum <= CRANE + 3)) { - if (sprite[j].z > actor[j].floorz-ZOFFSET2) + if (sprite[sectSprite].z > actor[sectSprite].floorz - ZOFFSET2) { - actor[j].bpos.x = sprite[j].x; - actor[j].bpos.y = sprite[j].y; + actor[sectSprite].bpos.x = sprite[sectSprite].x; + actor[sectSprite].bpos.y = sprite[sectSprite].y; - sprite[j].x += x>>2; - sprite[j].y += l>>2; + sprite[sectSprite].x += vect.x >> 2; + sprite[sectSprite].y += vect.y >> 2; - setsprite(j,(vec3_t *)&sprite[j]); + setsprite(sectSprite, (vec3_t *)&sprite[sectSprite]); - if (sector[sprite[j].sectnum].floorstat&2) - if (sprite[j].statnum == STAT_ZOMBIEACTOR) - A_Fall(j); + if (sector[sprite[sectSprite].sectnum].floorstat & 2) + if (sprite[sectSprite].statnum == STAT_ZOMBIEACTOR) + A_Fall(sectSprite); } } break; - } + } } - for (TRAVERSE_CONNECT(p)) + for (bssize_t TRAVERSE_CONNECT(playerNum)) { - DukePlayer_t *const ps = g_player[p].ps; + DukePlayer_t *const pPlayer = g_player[playerNum].ps; - if (ps->cursectnum == pSprite->sectnum && ps->on_ground) + if (pPlayer->cursectnum == pSprite->sectnum && pPlayer->on_ground) { - if (klabs(ps->pos.z-ps->truefz) < PHEIGHT+(9<<8)) + if (klabs(pPlayer->pos.z - pPlayer->truefz) < PHEIGHT + (9 << 8)) { - ps->fric.x += x<<3; - ps->fric.y += l<<3; + pPlayer->fric.x += vect.x << 3; + pPlayer->fric.y += vect.y << 3; } } } @@ -7312,17 +7290,19 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 case SE_35: if (pSector->ceilingz > pSprite->z) + { for (j = 0; j < 8; j++) { pSprite->ang += krand()&511; - k = A_Spawn(spriteNum,SMALLSMOKE); + k = A_Spawn(spriteNum, SMALLSMOKE); sprite[k].xvel = 96+(krand()&127); - A_SetSprite(k,CLIPMASK0); - setsprite(k,(vec3_t *)&sprite[k]); + A_SetSprite(k, CLIPMASK0); + setsprite(k, (vec3_t *) &sprite[k]); if (rnd(16)) - A_Spawn(spriteNum,EXPLOSION2); + A_Spawn(spriteNum, EXPLOSION2); } + } switch (pData[0]) { case 0: @@ -7419,15 +7399,12 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 case SE_27_DEMO_CAM: { - int32_t p; - DukePlayer_t *ps; - if (ud.recstat == 0 || !ud.democams) break; actor[spriteNum].tempang = pSprite->ang; - p = A_FindPlayer(pSprite,&x); - ps = g_player[p].ps; + int const p = A_FindPlayer(pSprite,&x); + DukePlayer_t * const ps = g_player[p].ps; if (sprite[ps->i].extra > 0 && myconnectindex == screenpeek) { @@ -8167,87 +8144,57 @@ static void A_DoLight(int spriteNum) } #endif // POLYMER -void A_PlayAlertSound(int32_t i) +void A_PlayAlertSound(int spriteNum) { - if (sprite[i].extra > 0) - switch (DYNAMICTILEMAP(PN(i))) + if (sprite[spriteNum].extra > 0) + { + switch (DYNAMICTILEMAP(PN(spriteNum))) { - case LIZTROOPONTOILET__STATIC: - case LIZTROOPJUSTSIT__STATIC: - case LIZTROOPSHOOT__STATIC: - case LIZTROOPJETPACK__STATIC: - case LIZTROOPDUCKING__STATIC: - case LIZTROOPRUNNING__STATIC: - case LIZTROOP__STATIC: - A_PlaySound(PRED_RECOG,i); - break; - case LIZMAN__STATIC: - case LIZMANSPITTING__STATIC: - case LIZMANFEEDING__STATIC: - case LIZMANJUMP__STATIC: - A_PlaySound(CAPT_RECOG,i); - break; - case PIGCOP__STATIC: - case PIGCOPDIVE__STATIC: - A_PlaySound(PIG_RECOG,i); - break; - case RECON__STATIC: - A_PlaySound(RECO_RECOG,i); - break; - case DRONE__STATIC: - A_PlaySound(DRON_RECOG,i); - break; - case COMMANDER__STATIC: - case COMMANDERSTAYPUT__STATIC: - A_PlaySound(COMM_RECOG,i); - break; - case ORGANTIC__STATIC: - A_PlaySound(TURR_RECOG,i); - break; - case OCTABRAIN__STATIC: - case OCTABRAINSTAYPUT__STATIC: - A_PlaySound(OCTA_RECOG,i); - break; - case BOSS1__STATIC: - case BOSS1STAYPUT__STATIC: - S_PlaySound(BOS1_RECOG); - break; - case BOSS2__STATIC: - if (sprite[i].pal != 0) - S_PlaySound(BOS2_RECOG); - else S_PlaySound(WHIPYOURASS); - break; - case BOSS3__STATIC: - if (sprite[i].pal != 0) - S_PlaySound(BOS3_RECOG); - else S_PlaySound(RIPHEADNECK); - break; - case BOSS4__STATIC: - case BOSS4STAYPUT__STATIC: - if (sprite[i].pal != 0) - S_PlaySound(BOS4_RECOG); - else S_PlaySound(BOSS4_FIRSTSEE); - break; - case GREENSLIME__STATIC: - A_PlaySound(SLIM_RECOG,i); - break; + case LIZTROOPONTOILET__STATIC: + case LIZTROOPJUSTSIT__STATIC: + case LIZTROOPSHOOT__STATIC: + case LIZTROOPJETPACK__STATIC: + case LIZTROOPDUCKING__STATIC: + case LIZTROOPRUNNING__STATIC: + case LIZTROOP__STATIC: A_PlaySound(PRED_RECOG, spriteNum); break; + case LIZMAN__STATIC: + case LIZMANSPITTING__STATIC: + case LIZMANFEEDING__STATIC: + case LIZMANJUMP__STATIC: A_PlaySound(CAPT_RECOG, spriteNum); break; + case PIGCOP__STATIC: + case PIGCOPDIVE__STATIC: A_PlaySound(PIG_RECOG, spriteNum); break; + case RECON__STATIC: A_PlaySound(RECO_RECOG, spriteNum); break; + case DRONE__STATIC: A_PlaySound(DRON_RECOG, spriteNum); break; + case COMMANDER__STATIC: + case COMMANDERSTAYPUT__STATIC: A_PlaySound(COMM_RECOG, spriteNum); break; + case ORGANTIC__STATIC: A_PlaySound(TURR_RECOG, spriteNum); break; + case OCTABRAIN__STATIC: + case OCTABRAINSTAYPUT__STATIC: A_PlaySound(OCTA_RECOG, spriteNum); break; + case BOSS1__STATIC: + case BOSS1STAYPUT__STATIC: S_PlaySound(BOS1_RECOG); break; + case BOSS2__STATIC: S_PlaySound((sprite[spriteNum].pal != 0) ? BOS2_RECOG : WHIPYOURASS); break; + case BOSS3__STATIC: S_PlaySound((sprite[spriteNum].pal != 0) ? BOS3_RECOG : RIPHEADNECK); break; + case BOSS4__STATIC: + case BOSS4STAYPUT__STATIC: S_PlaySound((sprite[spriteNum].pal != 0) ? BOS4_RECOG : BOSS4_FIRSTSEE); break; + case GREENSLIME__STATIC: A_PlaySound(SLIM_RECOG, spriteNum); break; } + } } -int32_t A_CheckSwitchTile(int32_t i) +int A_CheckSwitchTile(int spriteNum) { // picnum 0 would oob in the switch below, // MULTISWITCH has 4 states so deal with it separately, // ACCESSSWITCH and ACCESSSWITCH2 are only active in one state so deal with // them separately. - if ((PN(i) <= 0) || (PN(i) >= MULTISWITCH && PN(i) <= MULTISWITCH + 3) || (PN(i) == ACCESSSWITCH || PN(i) == ACCESSSWITCH2)) + if ((PN(spriteNum) <= 0) || (PN(spriteNum) >= MULTISWITCH && PN(spriteNum) <= MULTISWITCH + 3) || (PN(spriteNum) == ACCESSSWITCH || PN(spriteNum) == ACCESSSWITCH2)) return 1; // Loop to catch both states of switches. for (bssize_t j=1; j>=0; j--) { - switch (DYNAMICTILEMAP(PN(i)-j)) + switch (DYNAMICTILEMAP(PN(spriteNum)-j)) { case HANDPRINTSWITCH__STATIC: case ALIENSWITCH__STATIC: diff --git a/polymer/eduke32/source/actors.h b/polymer/eduke32/source/actors.h index 5b389bdd5..48575f935 100644 --- a/polymer/eduke32/source/actors.h +++ b/polymer/eduke32/source/actors.h @@ -297,36 +297,36 @@ enum pflags_t PROJECTILE_TYPE_MASK = PROJECTILE_HITSCAN | PROJECTILE_RPG | PROJECTILE_KNEE | PROJECTILE_BLOOD, }; -extern tiledata_t g_tile[MAXTILES]; -extern actor_t actor[MAXSPRITES]; -extern int32_t block_deletesprite; -extern int32_t g_noEnemies; -extern int32_t otherp; -extern int32_t ticrandomseed; -extern projectile_t SpriteProjectile[MAXSPRITES]; +extern tiledata_t g_tile[MAXTILES]; +extern actor_t actor[MAXSPRITES]; +extern int32_t block_deletesprite; +extern int32_t g_noEnemies; +extern int32_t otherp; +extern int32_t ticrandomseed; +extern projectile_t SpriteProjectile[MAXSPRITES]; -void A_AddToDeleteQueue(int32_t i); -int32_t A_CheckNoSE7Water(uspritetype const * const pSprite, int32_t sectNum, int32_t sectLotag, int32_t *pOther); -int32_t A_CheckSwitchTile(int32_t i); -void A_DeleteSprite(int spriteNum); -void A_DoGuts(int32_t sp, int32_t gtype, int32_t n); -void A_DoGutsDir(int32_t sp, int32_t gtype, int32_t n); -int A_IncurDamage(int spriteNum); -void A_MoveCyclers(void); -void A_MoveDummyPlayers(void); -void A_MoveSector(int i); -void A_PlayAlertSound(int32_t i); -void A_RadiusDamage(int32_t i, int32_t r, int32_t hp1, int32_t hp2, int32_t hp3, int32_t hp4); -void A_SpawnMultiple(int32_t sp, int32_t pic, int32_t n); +int A_CheckNoSE7Water(uspritetype const *const pSprite, int sectNum, int sectLotag, int32_t *pOther); +int A_CheckSwitchTile(int spriteNum); +int A_IncurDamage(int spriteNum); +void A_AddToDeleteQueue(int spriteNum); +void A_DeleteSprite(int spriteNum); +void A_DoGuts(int spriteNum, int tileNum, int spawnCnt); +void A_DoGutsDir(int spriteNum, int tileNum, int spawnCnt); +void A_MoveCyclers(void); +void A_MoveDummyPlayers(void); +void A_MoveSector(int i); +void A_PlayAlertSound(int spriteNum); +void A_RadiusDamage(int spriteNum, int blastRadius, int dmg1, int dmg2, int dmg3, int dmg4); +void A_SpawnMultiple(int spriteNum, int tileNum, int spawnCnt); -void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t range, int32_t color, int32_t priority); -void G_ClearCameraView(DukePlayer_t *ps); -void G_DoInterpolations(int32_t smoothratio); -void G_MoveWorld(void); -void G_RefreshLights(void); -int32_t G_SetInterpolation(int32_t *const posptr); -void G_StopInterpolation(int32_t *const posptr); +int G_SetInterpolation(int32_t *const posptr); +void G_AddGameLight(int lightRadius, int spriteNum, int zOffset, int lightRange, int lightColor, int lightPrio); +void G_ClearCameraView(DukePlayer_t *ps); +void G_DoInterpolations(int smoothRatio); +void G_MoveWorld(void); +void G_RefreshLights(void); +void G_StopInterpolation(int32_t *const posptr); // PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly void Sect_ToggleInterpolation(int sectnum, int doset); diff --git a/polymer/eduke32/source/cheats.c b/polymer/eduke32/source/cheats.c index 5692c26b9..18822a8f9 100644 --- a/polymer/eduke32/source/cheats.c +++ b/polymer/eduke32/source/cheats.c @@ -153,8 +153,8 @@ void G_SetupCheats(void) Bstrcpy(CheatStrings[24], "2debug"); Bstrcpy(CheatStrings[26], "2cgs"); - Bstrcpy(GametypeNames[0], "GI Match (Spawn)"); - Bstrcpy(GametypeNames[2], "GI Match (No Spawn)"); + Bstrcpy(g_gametypeNames[0], "GI Match (Spawn)"); + Bstrcpy(g_gametypeNames[2], "GI Match (No Spawn)"); } else if (NAM) { @@ -185,8 +185,8 @@ void G_SetupCheats(void) Bstrcpy(CheatStrings[24], "adebug"); Bstrcpy(CheatStrings[26], "acgs"); - Bstrcpy(GametypeNames[0], "GruntMatch (Spawn)"); - Bstrcpy(GametypeNames[2], "GruntMatch (No Spawn)"); + Bstrcpy(g_gametypeNames[0], "GruntMatch (Spawn)"); + Bstrcpy(g_gametypeNames[2], "GruntMatch (No Spawn)"); } } @@ -472,8 +472,8 @@ void G_DoCheats(void) volnume--; levnume--; - if ((VOLUMEONE && volnume > 0) || volnume > g_numVolumes-1 || - levnume >= MAXLEVELS || aMapInfo[volnume *MAXLEVELS+levnume].filename == NULL) + if ((VOLUMEONE && volnume > 0) || volnume > g_volumeCnt-1 || + levnume >= MAXLEVELS || g_mapInfo[volnume *MAXLEVELS+levnume].filename == NULL) { end_cheat(pPlayer); return; diff --git a/polymer/eduke32/source/cmdline.c b/polymer/eduke32/source/cmdline.c index 0ead0186e..12039a7af 100644 --- a/polymer/eduke32/source/cmdline.c +++ b/polymer/eduke32/source/cmdline.c @@ -270,7 +270,7 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv) { if (argc > i+1) { - Bstrcpy(setupfilename, argv[i+1]); + Bstrcpy(g_setupFileName, argv[i+1]); i++; } i++; diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index fc39c16cf..4a9c5a08e 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -521,20 +521,20 @@ int32_t CONFIG_ReadSetup(void) pathsearchmode = 1; #ifndef EDUKE32_TOUCH_DEVICES - if (SafeFileExists(setupfilename) && ud.config.scripthandle < 0) // JBF 20031211 - ud.config.scripthandle = SCRIPT_Load(setupfilename); + if (SafeFileExists(g_setupFileName) && ud.config.scripthandle < 0) // JBF 20031211 + ud.config.scripthandle = SCRIPT_Load(g_setupFileName); else if (SafeFileExists(SETUPFILENAME) && ud.config.scripthandle < 0) { int32_t i; i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. " - "Import configuration data from \"%s\"?",setupfilename,SETUPFILENAME); + "Import configuration data from \"%s\"?",g_setupFileName,SETUPFILENAME); if (i) ud.config.scripthandle = SCRIPT_Load(SETUPFILENAME); } else if (SafeFileExists("duke3d.cfg") && ud.config.scripthandle < 0) { int32_t i; i=wm_ynbox("Import Configuration Settings", "The configuration file \"%s\" was not found. " - "Import configuration data from \"duke3d.cfg\"?",setupfilename); + "Import configuration data from \"duke3d.cfg\"?",g_setupFileName); if (i) ud.config.scripthandle = SCRIPT_Load("duke3d.cfg"); } #endif @@ -637,10 +637,10 @@ void CONFIG_WriteSettings(void) // save binds and aliases to _settings. { int32_t i; BFILE *fp; - char *ptr = Xstrdup(setupfilename); + char *ptr = Xstrdup(g_setupFileName); char tempbuf[128]; - if (!Bstrcmp(setupfilename, SETUPFILENAME)) + if (!Bstrcmp(g_setupFileName, SETUPFILENAME)) Bsprintf(tempbuf, "settings.cfg"); else Bsprintf(tempbuf, "%s_settings.cfg", strtok(ptr, ".")); @@ -673,7 +673,7 @@ void CONFIG_WriteSettings(void) // save binds and aliases to _settings. Bfclose(fp); - if (!Bstrcmp(setupfilename, SETUPFILENAME)) + if (!Bstrcmp(g_setupFileName, SETUPFILENAME)) OSD_Printf("Wrote settings.cfg\n"); else OSD_Printf("Wrote %s_settings.cfg\n",ptr); @@ -681,7 +681,7 @@ void CONFIG_WriteSettings(void) // save binds and aliases to _settings. return; } - if (!Bstrcmp(setupfilename, SETUPFILENAME)) + if (!Bstrcmp(g_setupFileName, SETUPFILENAME)) OSD_Printf("Error writing settings.cfg: %s\n", strerror(errno)); else OSD_Printf("Error writing %s_settings.cfg: %s\n",ptr,strerror(errno)); @@ -695,7 +695,7 @@ void CONFIG_WriteSetup(uint32_t flags) if (!ud.config.setupread) return; if (ud.config.scripthandle < 0) - ud.config.scripthandle = SCRIPT_Init(setupfilename); + ud.config.scripthandle = SCRIPT_Init(g_setupFileName); SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Executions",++ud.executions,FALSE,FALSE); @@ -723,9 +723,9 @@ void CONFIG_WriteSetup(uint32_t flags) // exit early after only updating the values that can be changed from the startup window if (flags & 1) { - SCRIPT_Save(ud.config.scripthandle, setupfilename); + SCRIPT_Save(ud.config.scripthandle, g_setupFileName); SCRIPT_Free(ud.config.scripthandle); - OSD_Printf("Updated %s\n",setupfilename); + OSD_Printf("Updated %s\n",g_setupFileName); return; } @@ -862,12 +862,12 @@ void CONFIG_WriteSetup(uint32_t flags) SCRIPT_PutString(ud.config.scripthandle, "Comm Setup",commmacro,&ud.ridecule[dummy][0]); } - SCRIPT_Save(ud.config.scripthandle, setupfilename); + SCRIPT_Save(ud.config.scripthandle, g_setupFileName); if ((flags & 2) == 0) SCRIPT_Free(ud.config.scripthandle); - OSD_Printf("Wrote %s\n",setupfilename); + OSD_Printf("Wrote %s\n",g_setupFileName); CONFIG_WriteSettings(); Bfflush(NULL); } @@ -916,7 +916,7 @@ int32_t CONFIG_GetMapBestTime(char const * const mapname, uint8_t const * const int32_t CONFIG_SetMapBestTime(uint8_t const * const mapmd4, int32_t const tm) { - if (ud.config.scripthandle < 0) ud.config.scripthandle = SCRIPT_Init(setupfilename); + if (ud.config.scripthandle < 0) ud.config.scripthandle = SCRIPT_Init(g_setupFileName); if (ud.config.scripthandle < 0) return -1; char m[37]; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index b8479fc93..e9ef87a05 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -273,7 +273,7 @@ void G_GameExit(const char *msg) if (!g_quickExit) { - if (playerswhenstarted > 1 && g_player[myconnectindex].ps->gm&MODE_GAME && GTFLAGS(GAMETYPE_SCORESHEET) && *msg == ' ') + if (g_mostConcurrentPlayers > 1 && g_player[myconnectindex].ps->gm&MODE_GAME && GTFLAGS(GAMETYPE_SCORESHEET) && *msg == ' ') { G_BonusScreen(1); setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP); @@ -404,7 +404,7 @@ static void G_OROR_DupeSprites(const spritetype *sp) int32_t k; const spritetype *refsp; - if ((unsigned)sp->yvel >= (unsigned)playerswhenstarted) + if ((unsigned)sp->yvel >= (unsigned)g_mostConcurrentPlayers) return; refsp = &sprite[sp->yvel]; @@ -2220,7 +2220,7 @@ int A_Spawn(int spriteNum, int tileNum) pSprite->cstat = 32768; changespritestat(newSprite, ((!g_netServer && ud.multimode < 2) - || ((GametypeFlags[ud.coop] & GAMETYPE_COOPSPAWN) / GAMETYPE_COOPSPAWN) != pSprite->lotag) + || ((g_gametypeFlags[ud.coop] & GAMETYPE_COOPSPAWN) / GAMETYPE_COOPSPAWN) != pSprite->lotag) ? STAT_MISC : STAT_PLAYER); break; @@ -4405,11 +4405,11 @@ extern int G_StartRTS(int lumpNum, int localPlayer) void G_StartMusic(void) { int const levelNum = g_musicIndex; - Bassert(aMapInfo[levelNum].musicfn != NULL); + Bassert(g_mapInfo[levelNum].musicfn != NULL); - S_PlayMusic(aMapInfo[levelNum].musicfn); + S_PlayMusic(g_mapInfo[levelNum].musicfn); - Bsnprintf(apStrings[QUOTE_MUSIC], MAXQUOTELEN, "Playing %s", aMapInfo[levelNum].musicfn); + Bsnprintf(apStrings[QUOTE_MUSIC], MAXQUOTELEN, "Playing %s", g_mapInfo[levelNum].musicfn); P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps); } @@ -4638,7 +4638,7 @@ void G_HandleLocalKeys(void) if (g_musicIndex >= maxi) g_musicIndex = 0; } - while (aMapInfo[g_musicIndex].musicfn == NULL); + while (g_mapInfo[g_musicIndex].musicfn == NULL); G_StartMusic(); @@ -4785,7 +4785,7 @@ FAKE_F3: if (KB_UnBoundKeyPressed(sc_F5) && ud.config.MusicToggle) { - map_t *const pMapInfo = &aMapInfo[g_musicIndex]; + map_t *const pMapInfo = &g_mapInfo[g_musicIndex]; char *const musicString = apStrings[QUOTE_MUSIC]; KB_ClearKeyDown(sc_F5); @@ -4824,7 +4824,7 @@ FAKE_F3: // dirty hack... char 127 in last position indicates an auto-filled name if (ud.savegame[g_lastSaveSlot][MAXSAVEGAMENAME-2] == 127) { - Bstrncpy(&ud.savegame[g_lastSaveSlot][0], aMapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, 19); + Bstrncpy(&ud.savegame[g_lastSaveSlot][0], g_mapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, 19); ud.savegame[g_lastSaveSlot][MAXSAVEGAMENAME-2] = 127; } @@ -5017,7 +5017,7 @@ static int32_t S_DefineMusic(const char *ID, const char *name) return -1; } - return S_DefineAudioIfSupported(&aMapInfo[sel].musicfn, name); + return S_DefineAudioIfSupported(&g_mapInfo[sel].musicfn, name); } static int32_t parsedefinitions_game(scriptfile *script, int32_t preload); @@ -5448,9 +5448,9 @@ static void G_Cleanup(void) for (i=(MAXLEVELS*(MAXVOLUMES+1))-1; i>=0; i--) // +1 volume for "intro", "briefing" music { - Bfree(aMapInfo[i].name); - Bfree(aMapInfo[i].filename); - Bfree(aMapInfo[i].musicfn); + Bfree(g_mapInfo[i].name); + Bfree(g_mapInfo[i].filename); + Bfree(g_mapInfo[i].musicfn); G_FreeMapState(i); } @@ -5545,18 +5545,18 @@ static void G_CompileScripts(void) if (g_loadFromGroupOnly) // g_loadFromGroupOnly is true only when compiling fails and internal defaults are utilized C_Compile(G_ConFile()); - if ((uint32_t)g_numLabels > MAXSPRITES*sizeof(spritetype)/64) // see the arithmetic above for why + if ((uint32_t)g_labelCnt > MAXSPRITES*sizeof(spritetype)/64) // see the arithmetic above for why G_GameExit("Error: too many labels defined!"); { char *newlabel; int32_t *newlabelcode; - newlabel = (char *)Xmalloc(g_numLabels<<6); - newlabelcode = (int32_t *)Xmalloc(g_numLabels*sizeof(int32_t)); + newlabel = (char *)Xmalloc(g_labelCnt<<6); + newlabelcode = (int32_t *)Xmalloc(g_labelCnt*sizeof(int32_t)); - Bmemcpy(newlabel, label, g_numLabels*64); - Bmemcpy(newlabelcode, labelcode, g_numLabels*sizeof(int32_t)); + Bmemcpy(newlabel, label, g_labelCnt*64); + Bmemcpy(newlabelcode, labelcode, g_labelCnt*sizeof(int32_t)); label = newlabel; labelcode = newlabelcode; @@ -5573,9 +5573,9 @@ static void G_CompileScripts(void) static inline void G_CheckGametype(void) { - ud.m_coop = clamp(ud.m_coop, 0, g_numGametypes-1); - initprintf("%s\n",GametypeNames[ud.m_coop]); - if (GametypeFlags[ud.m_coop] & GAMETYPE_ITEMRESPAWN) + ud.m_coop = clamp(ud.m_coop, 0, g_gametypeCnt-1); + initprintf("%s\n",g_gametypeNames[ud.m_coop]); + if (g_gametypeFlags[ud.m_coop] & GAMETYPE_ITEMRESPAWN) ud.m_respawn_items = ud.m_respawn_inventory = 1; } @@ -6101,7 +6101,7 @@ int app_main(int argc, char const * const * argv) if (!g_useCwd) G_AddSearchPaths(); - g_numSkills = 4; + g_skillCnt = 4; ud.multimode = 1; // This needs to happen before G_CheckCommandLine() because G_GameExit() @@ -6181,8 +6181,8 @@ int app_main(int argc, char const * const * argv) Bexit(2); } - if (Bstrcmp(setupfilename, SETUPFILENAME)) - initprintf("Using config file \"%s\".\n",setupfilename); + if (Bstrcmp(g_setupFileName, SETUPFILENAME)) + initprintf("Using config file \"%s\".\n",g_setupFileName); G_ScanGroups(); @@ -6238,7 +6238,7 @@ int app_main(int argc, char const * const * argv) } #endif numplayers = 1; - playerswhenstarted = ud.multimode; // Lunatic needs this (player[] bound) + g_mostConcurrentPlayers = ud.multimode; // Lunatic needs this (player[] bound) if (!g_fakeMultiMode) { @@ -6319,7 +6319,7 @@ int app_main(int argc, char const * const * argv) } } - playerswhenstarted = ud.multimode; // XXX: redundant? + g_mostConcurrentPlayers = ud.multimode; // XXX: redundant? ud.last_level = 0; // the point of this block is to avoid overwriting the default in the cfg while asserting our selection @@ -6389,10 +6389,10 @@ int app_main(int argc, char const * const * argv) system_getcvars(); - char *const setupFileName = Xstrdup(setupfilename); + char *const setupFileName = Xstrdup(g_setupFileName); char *const p = strtok(setupFileName, "."); - if (!Bstrcmp(setupfilename, SETUPFILENAME)) + if (!Bstrcmp(g_setupFileName, SETUPFILENAME)) Bsprintf(tempbuf, "settings.cfg"); else Bsprintf(tempbuf, "%s_settings.cfg", p); @@ -6531,7 +6531,7 @@ MAIN_LOOP_RESTART: P_SetupMiscInputSettings(); g_player[myconnectindex].pteam = ud.team; - if (GametypeFlags[ud.coop] & GAMETYPE_TDM) + if (g_gametypeFlags[ud.coop] & GAMETYPE_TDM) g_player[myconnectindex].ps->palookup = g_player[myconnectindex].pcolor = G_GetTeamPalette(g_player[myconnectindex].pteam); else { @@ -6601,15 +6601,7 @@ MAIN_LOOP_RESTART: P_GetInput(myconnectindex); } - avg.fvel += localInput.fvel; - avg.svel += localInput.svel; - avg.avel += localInput.avel; - avg.horz += localInput.horz; - avg.bits |= localInput.bits; - avg.extbits |= localInput.extbits; - - Bmemcpy(&inputfifo[0][myconnectindex], &avg, sizeof(input_t)); - Bmemset(&avg, 0, sizeof(input_t)); + Bmemcpy(&inputfifo[0][myconnectindex], &localInput, sizeof(input_t)); do { @@ -6827,13 +6819,13 @@ int G_DoMoveThings(void) if (g_player[i].inputBits->extbits&(1<<6)) { g_player[i].ps->team = g_player[i].pteam; - if (GametypeFlags[ud.coop] & GAMETYPE_TDM) + if (g_gametypeFlags[ud.coop] & GAMETYPE_TDM) { actor[g_player[i].ps->i].picnum = APLAYERTOP; P_QuickKill(g_player[i].ps); } } - if (GametypeFlags[ud.coop] & GAMETYPE_TDM) + if (g_gametypeFlags[ud.coop] & GAMETYPE_TDM) g_player[i].ps->palookup = g_player[i].pcolor = G_GetTeamPalette(g_player[i].ps->team); if (sprite[g_player[i].ps->i].pal != 1) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 6e1e88b77..503f8c47d 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -41,7 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. int32_t g_scriptVersion = 13; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files -char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling +char g_scriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling int32_t g_totalLines,g_lineNumber; char g_szBuf[1024]; @@ -77,7 +77,7 @@ static intptr_t apScriptGameEventEnd[MAXGAMEEVENTS]; static char *textptr; #endif -int32_t g_numCompilerErrors,g_numCompilerWarnings; +int32_t g_errorCnt,g_warningCnt; extern int32_t g_maxSoundPos; @@ -1337,7 +1337,7 @@ static int32_t C_SetScriptSize(int32_t newsize) { if (EDUKE32_PREDICT_FALSE((intptr_t)apScript[i] < (intptr_t)&apScript[0] || (intptr_t)apScript[i] >= (intptr_t)&apScript[g_scriptSize])) { - g_numCompilerErrors++; + g_errorCnt++; initprintf("Internal compiler error at %" PRIdPTR " (0x%" PRIxPTR ")\n",i,i); VM_ScriptInfo(&apScript[i], 16); } @@ -1426,13 +1426,13 @@ static int32_t C_SkipComments(void) switch (textptr[1]) { case '/': // C++ style comment - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) - initprintf("%s:%d: debug: got comment.\n",g_szScriptFileName,g_lineNumber); + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) + initprintf("%s:%d: debug: got comment.\n",g_scriptFileName,g_lineNumber); C_NextLine(); continue; case '*': // beginning of a C style comment - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) - initprintf("%s:%d: debug: got start of comment block.\n",g_szScriptFileName,g_lineNumber); + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) + initprintf("%s:%d: debug: got start of comment block.\n",g_scriptFileName,g_lineNumber); do { if (*textptr == '\n') @@ -1443,25 +1443,25 @@ static int32_t C_SkipComments(void) if (EDUKE32_PREDICT_FALSE(!*textptr)) { - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) - initprintf("%s:%d: debug: EOF in comment!\n",g_szScriptFileName,g_lineNumber); + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug) + initprintf("%s:%d: debug: EOF in comment!\n",g_scriptFileName,g_lineNumber); C_ReportError(-1); - initprintf("%s:%d: error: found `/*' with no `*/'.\n",g_szScriptFileName,g_lineNumber); + initprintf("%s:%d: error: found `/*' with no `*/'.\n",g_scriptFileName,g_lineNumber); g_parsingActorPtr = g_processingState = g_numBraces = 0; - g_numCompilerErrors++; + g_errorCnt++; continue; } - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) - initprintf("%s:%d: debug: got end of comment block.\n",g_szScriptFileName,g_lineNumber); + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) + initprintf("%s:%d: debug: got end of comment block.\n",g_scriptFileName,g_lineNumber); textptr+=2; continue; default: C_ReportError(-1); - initprintf("%s:%d: error: malformed comment.\n", g_szScriptFileName, g_lineNumber); + initprintf("%s:%d: error: malformed comment.\n", g_scriptFileName, g_lineNumber); C_NextLine(); - g_numCompilerErrors++; + g_errorCnt++; continue; } continue; @@ -1518,12 +1518,12 @@ static void C_GetNextLabelName(void) // while (ispecial(*textptr) == 0 && *textptr!='['&& *textptr!=']' && *textptr!='\t' && *textptr!='\n' && *textptr!='\r') while (C_IsLabelChar(*textptr, i)) - label[(g_numLabels<<6)+(i++)] = *(textptr++); + label[(g_labelCnt<<6)+(i++)] = *(textptr++); - label[(g_numLabels<<6)+i] = 0; + label[(g_labelCnt<<6)+i] = 0; - if (!(g_numCompilerErrors|g_numCompilerWarnings) && g_scriptDebug > 1) - initprintf("%s:%d: debug: label `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + if (!(g_errorCnt|g_warningCnt) && g_scriptDebug > 1) + initprintf("%s:%d: debug: label `%s'.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); } static int32_t C_GetKeyword(void) @@ -1580,18 +1580,18 @@ static int32_t C_GetNextKeyword(void) //Returns its code # textptr += l; g_scriptPtr++; - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) - initprintf("%s:%d: debug: keyword `%s'.\n",g_szScriptFileName,g_lineNumber,keyw[i]); + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug) + initprintf("%s:%d: debug: keyword `%s'.\n",g_scriptFileName,g_lineNumber,keyw[i]); return i; } textptr += l; - g_numCompilerErrors++; + g_errorCnt++; if (EDUKE32_PREDICT_FALSE((tempbuf[0] == '{' || tempbuf[0] == '}') && tempbuf[1] != 0)) { C_ReportError(-1); - initprintf("%s:%d: error: expected whitespace between `%c' and `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf[0],tempbuf+1); + initprintf("%s:%d: error: expected whitespace between `%c' and `%s'.\n",g_scriptFileName,g_lineNumber,tempbuf[0],tempbuf+1); } else C_ReportError(ERROR_EXPECTEDKEYWORD); @@ -1623,8 +1623,8 @@ static int32_t parse_decimal_number(void) // (textptr) // out of range, this is arguably worse initprintf("%s:%d: warning: number out of the range of a 32-bit integer encountered.\n", - g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber); + g_warningCnt++; } return (int32_t)num; @@ -1638,8 +1638,8 @@ static int32_t parse_hex_constant(const char *hexnum) if (EDUKE32_PREDICT_FALSE(x > UINT32_MAX)) { initprintf("%s:%d: warning: number 0x%" PRIx64 " truncated to 32 bits.\n", - g_szScriptFileName,g_lineNumber, x); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber, x); + g_warningCnt++; } return x; @@ -1662,9 +1662,9 @@ static void C_GetNextVarType(int32_t type) else *g_scriptPtr = parse_decimal_number(); - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug) initprintf("%s:%d: debug: constant %ld in place of gamevar.\n", - g_szScriptFileName,g_lineNumber,(long)*g_scriptPtr); + g_scriptFileName,g_lineNumber,(long)*g_scriptPtr); BITPTR_CLEAR(g_scriptPtr-apScript); g_scriptPtr++; @@ -1679,14 +1679,14 @@ static void C_GetNextVarType(int32_t type) { if (EDUKE32_PREDICT_FALSE(type)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_SYNTAXERROR); C_GetNextLabelName(); return; } - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) - initprintf("%s:%d: debug: flagging gamevar as negative.\n", g_szScriptFileName, g_lineNumber); //,Batol(textptr)); + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug) + initprintf("%s:%d: debug: flagging gamevar as negative.\n", g_scriptFileName, g_lineNumber); //,Batol(textptr)); f = (MAXGAMEVARS<<1); textptr++; @@ -1694,9 +1694,9 @@ static void C_GetNextVarType(int32_t type) C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE(!g_skipKeywordCheck && hash_find(&h_keywords,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(!g_skipKeywordCheck && hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); return; } @@ -1708,16 +1708,16 @@ static void C_GetNextVarType(int32_t type) f |= (MAXGAMEVARS<<2); textptr++; - i=GetADefID(label+(g_numLabels<<6)); + i=GetADefID(label+(g_labelCnt<<6)); if (i < 0) { - i=GetDefID(label+(g_numLabels<<6)); + i=GetDefID(label+(g_labelCnt<<6)); if ((unsigned) (i - g_structVarIDs) >= NUMQUICKSTRUCTS) i = -1; if (EDUKE32_PREDICT_FALSE(i < 0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAGAMEARRAY); return; } @@ -1759,7 +1759,7 @@ static void C_GetNextVarType(int32_t type) if (EDUKE32_PREDICT_FALSE(*textptr != ']')) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_GAMEARRAYBNC); return; } @@ -1769,7 +1769,7 @@ static void C_GetNextVarType(int32_t type) if (EDUKE32_PREDICT_FALSE(type)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_INVALIDARRAYWRITE); return; } @@ -1788,7 +1788,7 @@ static void C_GetNextVarType(int32_t type) if (EDUKE32_PREDICT_FALSE(*textptr != '.')) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_SYNTAXERROR); return; } @@ -1800,45 +1800,45 @@ static void C_GetNextVarType(int32_t type) switch (i - g_structVarIDs) { case STRUCT_SPRITE: - labelNum=C_GetLabelNameOffset(&h_actor,Bstrtolower(label+(g_numLabels<<6))); + labelNum=C_GetLabelNameOffset(&h_actor,Bstrtolower(label+(g_labelCnt<<6))); break; case STRUCT_SECTOR: - labelNum=C_GetLabelNameOffset(&h_sector,Bstrtolower(label+(g_numLabels<<6))); + labelNum=C_GetLabelNameOffset(&h_sector,Bstrtolower(label+(g_labelCnt<<6))); break; case STRUCT_WALL: - labelNum=C_GetLabelNameOffset(&h_wall,Bstrtolower(label+(g_numLabels<<6))); + labelNum=C_GetLabelNameOffset(&h_wall,Bstrtolower(label+(g_labelCnt<<6))); break; case STRUCT_PLAYER: - labelNum=C_GetLabelNameOffset(&h_player,Bstrtolower(label+(g_numLabels<<6))); + labelNum=C_GetLabelNameOffset(&h_player,Bstrtolower(label+(g_labelCnt<<6))); break; case STRUCT_ACTORVAR: case STRUCT_PLAYERVAR: - labelNum=GetDefID(label+(g_numLabels<<6)); + labelNum=GetDefID(label+(g_labelCnt<<6)); break; case STRUCT_TSPR: - labelNum=C_GetLabelNameOffset(&h_tsprite,Bstrtolower(label+(g_numLabels<<6))); + labelNum=C_GetLabelNameOffset(&h_tsprite,Bstrtolower(label+(g_labelCnt<<6))); break; case STRUCT_PROJECTILE: case STRUCT_THISPROJECTILE: - labelNum=C_GetLabelNameOffset(&h_projectile,Bstrtolower(label+(g_numLabels<<6))); + labelNum=C_GetLabelNameOffset(&h_projectile,Bstrtolower(label+(g_labelCnt<<6))); break; case STRUCT_USERDEF: - labelNum=C_GetLabelNameOffset(&h_userdef,Bstrtolower(label+(g_numLabels<<6))); + labelNum=C_GetLabelNameOffset(&h_userdef,Bstrtolower(label+(g_labelCnt<<6))); break; case STRUCT_INPUT: - labelNum=C_GetLabelNameOffset(&h_input,Bstrtolower(label+(g_numLabels<<6))); + labelNum=C_GetLabelNameOffset(&h_input,Bstrtolower(label+(g_labelCnt<<6))); break; case STRUCT_TILEDATA: - labelNum=C_GetLabelNameOffset(&h_tiledata,Bstrtolower(label+(g_numLabels<<6))); + labelNum=C_GetLabelNameOffset(&h_tiledata,Bstrtolower(label+(g_labelCnt<<6))); break; case STRUCT_PALDATA: - labelNum=C_GetLabelNameOffset(&h_paldata,Bstrtolower(label+(g_numLabels<<6))); + labelNum=C_GetLabelNameOffset(&h_paldata,Bstrtolower(label+(g_labelCnt<<6))); break; } if (EDUKE32_PREDICT_FALSE(labelNum == -1)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAMEMBER); return; } @@ -1893,20 +1893,20 @@ static void C_GetNextVarType(int32_t type) return; } // initprintf("not an array"); - i=GetDefID(label+(g_numLabels<<6)); + i=GetDefID(label+(g_labelCnt<<6)); if (i<0) //gamevar not found { if (!type && !g_labelsOnly) { //try looking for a define instead - Bstrcpy(tempbuf,label+(g_numLabels<<6)); + Bstrcpy(tempbuf,label+(g_labelCnt<<6)); i = hash_find(&h_labels,tempbuf); if (EDUKE32_PREDICT_TRUE(i>=0)) { if (EDUKE32_PREDICT_TRUE(labeltype[i] & LABEL_DEFINE)) { - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug) - initprintf("%s:%d: debug: label `%s' in place of gamevar.\n",g_szScriptFileName,g_lineNumber,label+(i<<6)); + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug) + initprintf("%s:%d: debug: label `%s' in place of gamevar.\n",g_scriptFileName,g_lineNumber,label+(i<<6)); BITPTR_CLEAR(g_scriptPtr-apScript); *g_scriptPtr++ = MAXGAMEVARS; BITPTR_CLEAR(g_scriptPtr-apScript); @@ -1914,11 +1914,11 @@ static void C_GetNextVarType(int32_t type) return; } } - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAGAMEVAR); return; } - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAGAMEVAR); textptr++; return; @@ -1926,19 +1926,19 @@ static void C_GetNextVarType(int32_t type) } if (EDUKE32_PREDICT_FALSE(type == GAMEVAR_READONLY && aGameVars[i].flags & GAMEVAR_READONLY)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_VARREADONLY); return; } else if (EDUKE32_PREDICT_FALSE(aGameVars[i].flags & type)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_VARTYPEMISMATCH); return; } - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) - initprintf("%s:%d: debug: gamevar `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) + initprintf("%s:%d: debug: gamevar `%s'.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); BITPTR_CLEAR(g_scriptPtr-apScript); *g_scriptPtr++=(i|f); @@ -1979,7 +1979,7 @@ static int32_t C_GetNextValue(int32_t type) if (EDUKE32_PREDICT_FALSE(!g_skipKeywordCheck && hash_find(&h_keywords,tempbuf /*label+(g_numLabels<<6)*/)>=0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); textptr+=l; } @@ -1990,10 +1990,10 @@ static int32_t C_GetNextValue(int32_t type) { if (EDUKE32_PREDICT_TRUE(labeltype[i] & type)) { - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) { char *gl = C_GetLabelType(labeltype[i]); - initprintf("%s:%d: debug: %s label `%s'.\n",g_szScriptFileName,g_lineNumber,gl,label+(i<<6)); + initprintf("%s:%d: debug: %s label `%s'.\n",g_scriptFileName,g_lineNumber,gl,label+(i<<6)); Bfree(gl); } @@ -2010,8 +2010,8 @@ static int32_t C_GetNextValue(int32_t type) char *el = C_GetLabelType(type); char *gl = C_GetLabelType(labeltype[i]); C_ReportError(-1); - initprintf("%s:%d: warning: expected %s, found %s.\n",g_szScriptFileName,g_lineNumber,el,gl); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: expected %s, found %s.\n",g_scriptFileName,g_lineNumber,el,gl); + g_warningCnt++; Bfree(el); Bfree(gl); return -1; // valid label name, but wrong type @@ -2020,7 +2020,7 @@ static int32_t C_GetNextValue(int32_t type) if (EDUKE32_PREDICT_FALSE(isdigit(*textptr) == 0 && *textptr != '-')) { C_ReportError(ERROR_PARAMUNDEFINED); - g_numCompilerErrors++; + g_errorCnt++; BITPTR_CLEAR(g_scriptPtr-apScript); *g_scriptPtr = 0; g_scriptPtr++; @@ -2031,7 +2031,7 @@ static int32_t C_GetNextValue(int32_t type) if (EDUKE32_PREDICT_FALSE(isdigit(*textptr) && g_labelsOnly)) { C_ReportError(WARNING_LABELSONLY); - g_numCompilerWarnings++; + g_warningCnt++; } i = l-1; @@ -2042,8 +2042,8 @@ static int32_t C_GetNextValue(int32_t type) if (EDUKE32_PREDICT_FALSE(!isdigit(textptr[i--]))) { C_ReportError(-1); - initprintf("%s:%d: warning: invalid character `%c' in definition!\n",g_szScriptFileName,g_lineNumber,textptr[i+1]); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: invalid character `%c' in definition!\n",g_scriptFileName,g_lineNumber,textptr[i+1]); + g_warningCnt++; break; } } @@ -2056,9 +2056,9 @@ static int32_t C_GetNextValue(int32_t type) else *g_scriptPtr = parse_decimal_number(); - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) initprintf("%s:%d: debug: constant %ld.\n", - g_szScriptFileName,g_lineNumber,(long)*g_scriptPtr); + g_scriptFileName,g_lineNumber,(long)*g_scriptPtr); g_scriptPtr++; @@ -2073,7 +2073,7 @@ static int32_t C_GetStructureIndexes(int32_t const labelsonly, hashtable_t const if (EDUKE32_PREDICT_FALSE(*textptr++ != '[')) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_SYNTAXERROR); return -1; } @@ -2100,7 +2100,7 @@ static int32_t C_GetStructureIndexes(int32_t const labelsonly, hashtable_t const if (EDUKE32_PREDICT_FALSE(*textptr++ != '.')) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_SYNTAXERROR); return -1; } @@ -2112,11 +2112,11 @@ static int32_t C_GetStructureIndexes(int32_t const labelsonly, hashtable_t const C_GetNextLabelName(); - int32_t const labelNum = C_GetLabelNameOffset(table, Bstrtolower(label + (g_numLabels << 6))); + int32_t const labelNum = C_GetLabelNameOffset(table, Bstrtolower(label + (g_labelCnt << 6))); if (EDUKE32_PREDICT_FALSE(labelNum == -1)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAMEMBER); return -1; } @@ -2155,8 +2155,8 @@ static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr) g_scriptPtr = lastScriptPtr + &apScript[0]; g_ifElseAborted = 1; C_ReportError(-1); - g_numCompilerWarnings++; - initprintf("%s:%d: warning: malformed `%s' branch\n",g_szScriptFileName,g_lineNumber, + g_warningCnt++; + initprintf("%s:%d: warning: malformed `%s' branch\n",g_scriptFileName,g_lineNumber, keyw[*(g_scriptPtr) & VM_INSTMASK]); return 1; } @@ -2180,9 +2180,9 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr) if (EDUKE32_PREDICT_FALSE(g_ifElseAborted)) { C_ReportError(-1); - g_numCompilerWarnings++; + g_warningCnt++; g_scriptPtr = lastScriptPtr + &apScript[0]; - initprintf("%s:%d: warning: empty `%s' branch\n",g_szScriptFileName,g_lineNumber, + initprintf("%s:%d: warning: empty `%s' branch\n",g_scriptFileName,g_lineNumber, keyw[*(g_scriptPtr) & VM_INSTMASK]); *(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12)); return 1; @@ -2224,8 +2224,8 @@ static void C_Include(const char *confile) if (EDUKE32_PREDICT_FALSE(fp < 0)) { - g_numCompilerErrors++; - initprintf("%s:%d: error: could not find file `%s'.\n",g_szScriptFileName,g_lineNumber,confile); + g_errorCnt++; + initprintf("%s:%d: error: could not find file `%s'.\n",g_scriptFileName,g_lineNumber,confile); return; } @@ -2245,8 +2245,8 @@ static void C_Include(const char *confile) char *origtptr = textptr; char parentScriptFileName[255]; - Bstrcpy(parentScriptFileName, g_szScriptFileName); - Bstrcpy(g_szScriptFileName, confile); + Bstrcpy(parentScriptFileName, g_scriptFileName); + Bstrcpy(g_scriptFileName, confile); int32_t temp_ScriptLineNumber = g_lineNumber; g_lineNumber = 1; @@ -2259,7 +2259,7 @@ static void C_Include(const char *confile) C_SkipComments(); C_ParseCommand(1); - Bstrcpy(g_szScriptFileName, parentScriptFileName); + Bstrcpy(g_scriptFileName, parentScriptFileName); g_totalLines += g_lineNumber; g_lineNumber = temp_ScriptLineNumber; @@ -2284,18 +2284,16 @@ static void check_filename_case(const char *fn) { UNREFERENCED_PARAMETER(fn); } void G_DoGameStartup(const int32_t *params) { - int32_t j = 0; + int j = 0; - ud.const_visibility = params[j++]; - g_impactDamage = params[j++]; - g_maxPlayerHealth = g_player[0].ps->max_player_health = g_player[0].ps->max_shield_amount = params[j++]; - g_startArmorAmount = params[j++]; - g_actorRespawnTime = params[j++]; - - if (g_scriptVersion >= 11) - g_itemRespawnTime = params[j++]; - else - g_itemRespawnTime = g_actorRespawnTime; + ud.const_visibility = params[j++]; + g_impactDamage = params[j++]; + g_player[0].ps->max_shield_amount = params[j++]; + g_player[0].ps->max_player_health = g_player[0].ps->max_shield_amount; + g_maxPlayerHealth = g_player[0].ps->max_player_health; + g_startArmorAmount = params[j++]; + g_actorRespawnTime = params[j++]; + g_itemRespawnTime = (g_scriptVersion >= 11) ? params[j++] : g_actorRespawnTime; if (g_scriptVersion >= 11) g_playerFriction = params[j++]; @@ -2305,23 +2303,23 @@ void G_DoGameStartup(const int32_t *params) if (g_scriptVersion >= 11) { - g_rpgBlastRadius = params[j++]; - g_pipebombBlastRadius = params[j++]; - g_shrinkerBlastRadius = params[j++]; - g_tripbombBlastRadius = params[j++]; - g_morterBlastRadius = params[j++]; - g_bouncemineBlastRadius = params[j++]; - g_seenineBlastRadius = params[j++]; + g_rpgRadius = params[j++]; + g_pipebombRadius = params[j++]; + g_shrinkerRadius = params[j++]; + g_tripbombRadius = params[j++]; + g_morterRadius = params[j++]; + g_bouncemineRadius = params[j++]; + g_seenineRadius = params[j++]; } - g_player[0].ps->max_ammo_amount[PISTOL_WEAPON] = params[j++]; - g_player[0].ps->max_ammo_amount[SHOTGUN_WEAPON] = params[j++]; - g_player[0].ps->max_ammo_amount[CHAINGUN_WEAPON] = params[j++]; - g_player[0].ps->max_ammo_amount[RPG_WEAPON] = params[j++]; - g_player[0].ps->max_ammo_amount[HANDBOMB_WEAPON] = params[j++]; - g_player[0].ps->max_ammo_amount[SHRINKER_WEAPON] = params[j++]; + g_player[0].ps->max_ammo_amount[PISTOL_WEAPON] = params[j++]; + g_player[0].ps->max_ammo_amount[SHOTGUN_WEAPON] = params[j++]; + g_player[0].ps->max_ammo_amount[CHAINGUN_WEAPON] = params[j++]; + g_player[0].ps->max_ammo_amount[RPG_WEAPON] = params[j++]; + g_player[0].ps->max_ammo_amount[HANDBOMB_WEAPON] = params[j++]; + g_player[0].ps->max_ammo_amount[SHRINKER_WEAPON] = params[j++]; g_player[0].ps->max_ammo_amount[DEVISTATOR_WEAPON] = params[j++]; - g_player[0].ps->max_ammo_amount[TRIPBOMB_WEAPON] = params[j++]; + g_player[0].ps->max_ammo_amount[TRIPBOMB_WEAPON] = params[j++]; if (g_scriptVersion >= 13) { @@ -2330,30 +2328,28 @@ void G_DoGameStartup(const int32_t *params) if (g_scriptVersion == 14) g_player[0].ps->max_ammo_amount[GROW_WEAPON] = params[j++]; - g_damageCameras = params[j++]; - g_numFreezeBounces = params[j++]; + g_damageCameras = params[j++]; + g_numFreezeBounces = params[j++]; g_freezerSelfDamage = params[j++]; if (g_scriptVersion == 14) { - g_deleteQueueSize = params[j++]; - g_deleteQueueSize = clamp(g_deleteQueueSize, 0, 1024); - + g_deleteQueueSize = clamp(params[j++], 0, 1024); g_tripbombLaserMode = params[j++]; } } } -void C_DefineMusic(int32_t vol, int32_t lev, const char *fn) +void C_DefineMusic(int volumeNum, int levelNum, const char *fileName) { - Bassert((unsigned)vol < MAXVOLUMES+1); - Bassert((unsigned)lev < MAXLEVELS); + Bassert((unsigned)volumeNum < MAXVOLUMES+1); + Bassert((unsigned)levelNum < MAXLEVELS); - map_t *const map = &aMapInfo[(MAXLEVELS*vol)+lev]; + map_t *const pMapInfo = &g_mapInfo[(MAXLEVELS*volumeNum)+levelNum]; - Bfree(map->musicfn); - map->musicfn = dup_filename(fn); - check_filename_case(map->musicfn); + Bfree(pMapInfo->musicfn); + pMapInfo->musicfn = dup_filename(fileName); + check_filename_case(pMapInfo->musicfn); } #ifdef LUNATIC @@ -2390,15 +2386,15 @@ void C_DefineQuote(int32_t qnum, const char *qstr) void C_DefineVolumeName(int32_t vol, const char *name) { Bassert((unsigned)vol < MAXVOLUMES); - Bstrncpyz(EpisodeNames[vol], name, sizeof(EpisodeNames[vol])); - g_numVolumes = vol+1; + Bstrncpyz(g_volumeNames[vol], name, sizeof(g_volumeNames[vol])); + g_volumeCnt = vol+1; } void C_DefineSkillName(int32_t skill, const char *name) { Bassert((unsigned)skill < MAXSKILLS); - Bstrncpyz(SkillNames[skill], name, sizeof(SkillNames[skill])); - g_numSkills = max(g_numSkills, skill+1); // TODO: bring in line with C-CON? + Bstrncpyz(g_skillNames[skill], name, sizeof(g_skillNames[skill])); + g_skillCnt = max(g_skillCnt, skill+1); // TODO: bring in line with C-CON? } void C_DefineLevelName(int32_t vol, int32_t lev, const char *fn, @@ -2409,7 +2405,7 @@ void C_DefineLevelName(int32_t vol, int32_t lev, const char *fn, Bassert((unsigned)lev < MAXLEVELS); { - map_t *const map = &aMapInfo[(MAXLEVELS*vol)+lev]; + map_t *const map = &g_mapInfo[(MAXLEVELS*vol)+lev]; Bfree(map->filename); map->filename = dup_filename(fn); @@ -2437,9 +2433,9 @@ void C_DefineGameType(int32_t idx, int32_t flags, const char *name) { Bassert((unsigned)idx < MAXGAMETYPES); - GametypeFlags[idx] = flags; - Bstrncpyz(GametypeNames[idx], name, sizeof(GametypeNames[idx])); - g_numGametypes = idx+1; + g_gametypeFlags[idx] = flags; + Bstrncpyz(g_gametypeNames[idx], name, sizeof(g_gametypeNames[idx])); + g_gametypeCnt = idx+1; } #endif @@ -2447,7 +2443,7 @@ void C_DefineVolumeFlags(int32_t vol, int32_t flags) { Bassert((unsigned)vol < MAXVOLUMES); - EpisodeFlags[vol] = flags; + g_volumeFlags[vol] = flags; } void C_UndefineVolume(int32_t vol) @@ -2457,14 +2453,14 @@ void C_UndefineVolume(int32_t vol) for (bssize_t i = 0; i < MAXLEVELS; i++) C_UndefineLevel(vol, i); - EpisodeNames[vol][0] = '\0'; + g_volumeNames[vol][0] = '\0'; - g_numVolumes = 0; + g_volumeCnt = 0; for (bssize_t i = MAXVOLUMES-1; i >= 0; i--) { - if (EpisodeNames[i][0]) + if (g_volumeNames[i][0]) { - g_numVolumes = i+1; + g_volumeCnt = i+1; break; } } @@ -2474,14 +2470,14 @@ void C_UndefineSkill(int32_t skill) { Bassert((unsigned)skill < MAXSKILLS); - SkillNames[skill][0] = '\0'; + g_skillNames[skill][0] = '\0'; - g_numSkills = 0; + g_skillCnt = 0; for (bssize_t i = MAXSKILLS-1; i >= 0; i--) { - if (SkillNames[i][0]) + if (g_skillNames[i][0]) { - g_numSkills = i+1; + g_skillCnt = i+1; break; } } @@ -2492,7 +2488,7 @@ void C_UndefineLevel(int32_t vol, int32_t lev) Bassert((unsigned)vol < MAXVOLUMES); Bassert((unsigned)lev < MAXLEVELS); - map_t *const map = &aMapInfo[(MAXLEVELS*vol)+lev]; + map_t *const map = &g_mapInfo[(MAXLEVELS*vol)+lev]; DO_FREE_AND_NULL(map->filename); DO_FREE_AND_NULL(map->name); @@ -2748,7 +2744,7 @@ LUNATIC_EXTERN void C_SetCfgName(const char *cfgname) int32_t glrm = glrendmode; #endif - if (Bstrcmp(setupfilename, SETUPFILENAME) != 0) // set to something else via -cfg + if (Bstrcmp(g_setupFileName, SETUPFILENAME) != 0) // set to something else via -cfg return; if (Bstat(g_modDir, &st) < 0) @@ -2779,11 +2775,11 @@ LUNATIC_EXTERN void C_SetCfgName(const char *cfgname) CONFIG_WriteSetup(1); if (g_modDir[0] != '/') - Bsnprintf(setupfilename, sizeof(setupfilename), "%s/%s", g_modDir, temp); + Bsnprintf(g_setupFileName, sizeof(g_setupFileName), "%s/%s", g_modDir, temp); else - Bstrncpyz(setupfilename, temp, sizeof(setupfilename)); + Bstrncpyz(g_setupFileName, temp, sizeof(g_setupFileName)); - initprintf("Using config file \"%s\".\n", setupfilename); + initprintf("Using config file \"%s\".\n", g_setupFileName); CONFIG_ReadSetup(); @@ -2831,7 +2827,7 @@ static int32_t C_ParseCommand(int32_t loop) do { - if (EDUKE32_PREDICT_FALSE(g_numCompilerErrors > 63 || (*textptr == '\0') || (*(textptr+1) == '\0') || C_SkipComments())) + if (EDUKE32_PREDICT_FALSE(g_errorCnt > 63 || (*textptr == '\0') || (*(textptr+1) == '\0') || C_SkipComments())) return 1; if (EDUKE32_PREDICT_FALSE(g_scriptDebug)) @@ -2849,7 +2845,7 @@ static int32_t C_ParseCommand(int32_t loop) if (EDUKE32_PREDICT_FALSE(g_processingState || g_parsingActorPtr)) { C_ReportError(ERROR_FOUNDWITHIN); - g_numCompilerErrors++; + g_errorCnt++; continue; } goto DO_DEFSTATE; @@ -2859,37 +2855,37 @@ static int32_t C_ParseCommand(int32_t loop) DO_DEFSTATE: C_GetNextLabelName(); g_scriptPtr--; - labelcode[g_numLabels] = g_scriptPtr-apScript; - labeltype[g_numLabels] = LABEL_STATE; + labelcode[g_labelCnt] = g_scriptPtr-apScript; + labeltype[g_labelCnt] = LABEL_STATE; g_processingState = 1; - Bsprintf(g_szCurrentBlockName,"%s",label+(g_numLabels<<6)); + Bsprintf(g_szCurrentBlockName,"%s",label+(g_labelCnt<<6)); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); continue; } - if (EDUKE32_PREDICT_FALSE(hash_find(&h_gamevars,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(hash_find(&h_gamevars,label+(g_labelCnt<<6))>=0)) { - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(WARNING_NAMEMATCHESVAR); } - hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0); - g_numLabels++; + hash_add(&h_labels,label+(g_labelCnt<<6),g_labelCnt,0); + g_labelCnt++; continue; } C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE((j = hash_find(&h_labels,label+(g_numLabels<<6))) < 0)) + if (EDUKE32_PREDICT_FALSE((j = hash_find(&h_labels,label+(g_labelCnt<<6))) < 0)) { C_ReportError(-1); - initprintf("%s:%d: error: state `%s' not found.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); - g_numCompilerErrors++; + initprintf("%s:%d: error: state `%s' not found.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); + g_errorCnt++; g_scriptPtr++; continue; } @@ -2898,16 +2894,16 @@ DO_DEFSTATE: { char *gl = (char *) C_GetLabelType(labeltype[j]); C_ReportError(-1); - initprintf("%s:%d: warning: expected state, found %s.\n", g_szScriptFileName, g_lineNumber, gl); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: expected state, found %s.\n", g_scriptFileName, g_lineNumber, gl); + g_warningCnt++; Bfree(gl); *(g_scriptPtr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions BITPTR_CLEAR(g_scriptPtr-apScript-1); continue; // valid label name, but wrong type } - if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) - initprintf("%s:%d: debug: state label `%s'.\n", g_szScriptFileName, g_lineNumber, label+(j<<6)); + if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1) + initprintf("%s:%d: debug: state label `%s'.\n", g_scriptFileName, g_lineNumber, label+(j<<6)); *g_scriptPtr = (intptr_t) (apScript+labelcode[j]); // 'state' type labels are always script addresses, as far as I can see @@ -2920,26 +2916,26 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(g_processingState == 0)) { C_ReportError(-1); - initprintf("%s:%d: error: found `ends' without open `state'.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: found `ends' without open `state'.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; } // else { if (EDUKE32_PREDICT_FALSE(g_numBraces > 0)) { C_ReportError(ERROR_OPENBRACKET); - g_numCompilerErrors++; + g_errorCnt++; } else if (EDUKE32_PREDICT_FALSE(g_numBraces < 0)) { C_ReportError(ERROR_CLOSEBRACKET); - g_numCompilerErrors++; + g_errorCnt++; } if (EDUKE32_PREDICT_FALSE(g_checkingSwitch > 0)) { C_ReportError(ERROR_NOENDSWITCH); - g_numCompilerErrors++; + g_errorCnt++; g_checkingSwitch = 0; // can't be checking anymore... } @@ -2984,7 +2980,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(isdigit(*textptr) || (*textptr == '-'))) { C_GetNextLabelName(); - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_SYNTAXERROR); C_GetNextValue(LABEL_DEFINE); C_GetNextValue(LABEL_DEFINE); @@ -2994,11 +2990,11 @@ DO_DEFSTATE: C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) { - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(WARNING_VARMASKSKEYWORD); - hash_delete(&h_keywords, label+(g_numLabels<<6)); + hash_delete(&h_keywords, label+(g_labelCnt<<6)); } C_GetNextValue(LABEL_DEFINE); // get initial value @@ -3006,12 +3002,12 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE((*(g_scriptPtr-1)&GAMEVAR_USER_MASK)==3)) { - g_numCompilerWarnings++; + g_warningCnt++; *(g_scriptPtr-1)^=GAMEVAR_PERPLAYER; C_ReportError(WARNING_BADGAMEVAR); } - Gv_NewVar(label+(g_numLabels<<6), *(g_scriptPtr-2), (*(g_scriptPtr-1)) & (~GAMEVAR_DEFAULT)); + Gv_NewVar(label+(g_labelCnt<<6), *(g_scriptPtr-2), (*(g_scriptPtr-1)) & (~GAMEVAR_DEFAULT)); g_scriptPtr -= 3; continue; @@ -3019,7 +3015,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(isdigit(*textptr) || (*textptr == '-'))) { C_GetNextLabelName(); - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_SYNTAXERROR); C_GetNextValue(LABEL_DEFINE); C_GetNextValue(LABEL_DEFINE); @@ -3028,22 +3024,22 @@ DO_DEFSTATE: } C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) { - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(WARNING_ARRAYMASKSKEYWORD); - hash_delete(&h_keywords, label+(g_numLabels<<6)); + hash_delete(&h_keywords, label+(g_labelCnt<<6)); } - i = hash_find(&h_gamevars,label+(g_numLabels<<6)); + i = hash_find(&h_gamevars,label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i>=0)) { - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(WARNING_NAMEMATCHESVAR); } C_GetNextValue(LABEL_DEFINE); - Gv_NewArray(label+(g_numLabels<<6),NULL,*(g_scriptPtr-1), GAMEARRAY_NORMAL); + Gv_NewArray(label+(g_labelCnt<<6),NULL,*(g_scriptPtr-1), GAMEARRAY_NORMAL); g_scriptPtr -= 2; // no need to save in script... continue; @@ -3052,41 +3048,41 @@ DO_DEFSTATE: { C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); continue; } - i = hash_find(&h_gamevars,label+(g_numLabels<<6)); + i = hash_find(&h_gamevars,label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i>=0)) { - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(WARNING_NAMEMATCHESVAR); } C_GetNextValue(LABEL_DEFINE); - i = hash_find(&h_labels,label+(g_numLabels<<6)); + i = hash_find(&h_labels,label+(g_labelCnt<<6)); if (i>=0) { // if (i >= g_numDefaultLabels) if (EDUKE32_PREDICT_FALSE(labelcode[i] != *(g_scriptPtr-1))) { - g_numCompilerWarnings++; - initprintf("%s:%d: warning: ignored redefinition of `%s' to %d (old: %d).\n",g_szScriptFileName, - g_lineNumber,label+(g_numLabels<<6), (int32_t)(*(g_scriptPtr-1)), labelcode[i]); + g_warningCnt++; + initprintf("%s:%d: warning: ignored redefinition of `%s' to %d (old: %d).\n",g_scriptFileName, + g_lineNumber,label+(g_labelCnt<<6), (int32_t)(*(g_scriptPtr-1)), labelcode[i]); } } else { - hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0); - labeltype[g_numLabels] = LABEL_DEFINE; - labelcode[g_numLabels++] = *(g_scriptPtr-1); + hash_add(&h_labels,label+(g_labelCnt<<6),g_labelCnt,0); + labeltype[g_labelCnt] = LABEL_DEFINE; + labelcode[g_labelCnt++] = *(g_scriptPtr-1); if (*(g_scriptPtr-1) >= 0 && *(g_scriptPtr-1) < MAXTILES && g_dynamicTileMapping) - G_ProcessDynamicTileMapping(label+((g_numLabels-1)<<6),*(g_scriptPtr-1)); + G_ProcessDynamicTileMapping(label+((g_labelCnt-1)<<6),*(g_scriptPtr-1)); } g_scriptPtr -= 2; continue; @@ -3116,8 +3112,8 @@ DO_DEFSTATE: C_ReportError(-1); BITPTR_CLEAR(g_scriptPtr-apScript-1); *(g_scriptPtr-1) = 0; - initprintf("%s:%d: warning: expected a move, found a constant.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,g_lineNumber); + g_warningCnt++; } j = 0; @@ -3132,29 +3128,29 @@ DO_DEFSTATE: C_GetNextLabelName(); // Check to see it's already defined - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); continue; } - if (EDUKE32_PREDICT_FALSE(hash_find(&h_gamevars,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(hash_find(&h_gamevars,label+(g_labelCnt<<6))>=0)) { - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(WARNING_NAMEMATCHESVAR); } - if (EDUKE32_PREDICT_FALSE((i = hash_find(&h_labels,label+(g_numLabels<<6))) >= 0)) + if (EDUKE32_PREDICT_FALSE((i = hash_find(&h_labels,label+(g_labelCnt<<6))) >= 0)) { - g_numCompilerWarnings++; - initprintf("%s:%d: warning: duplicate move `%s' ignored.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + g_warningCnt++; + initprintf("%s:%d: warning: duplicate move `%s' ignored.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); } else { - hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0); - labeltype[g_numLabels] = LABEL_MOVE; - labelcode[g_numLabels++] = g_scriptPtr-apScript; + hash_add(&h_labels,label+(g_labelCnt<<6),g_labelCnt,0); + labeltype[g_labelCnt] = LABEL_MOVE; + labelcode[g_labelCnt++] = g_scriptPtr-apScript; } for (j=1; j>=0; j--) @@ -3188,10 +3184,10 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE((unsigned)k >= MAXVOLUMES+1)) // if it's not background or special music { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); initprintf("%s:%d: error: volume number must be between 0 and MAXVOLUMES+1=%d.\n", - g_szScriptFileName, g_lineNumber, MAXVOLUMES+1); + g_scriptFileName, g_lineNumber, MAXVOLUMES+1); continue; } @@ -3253,31 +3249,31 @@ DO_DEFSTATE: g_scriptPtr--; C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); continue; } - i = hash_find(&h_gamevars,label+(g_numLabels<<6)); + i = hash_find(&h_gamevars,label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i>=0)) { - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(WARNING_NAMEMATCHESVAR); } - i = hash_find(&h_labels,label+(g_numLabels<<6)); + i = hash_find(&h_labels,label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i>=0)) { - g_numCompilerWarnings++; - initprintf("%s:%d: warning: duplicate ai `%s' ignored.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + g_warningCnt++; + initprintf("%s:%d: warning: duplicate ai `%s' ignored.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); } else { - labeltype[g_numLabels] = LABEL_AI; - hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0); - labelcode[g_numLabels++] = g_scriptPtr-apScript; + labeltype[g_labelCnt] = LABEL_AI; + hash_add(&h_labels,label+(g_labelCnt<<6),g_labelCnt,0); + labelcode[g_labelCnt++] = g_scriptPtr-apScript; } for (j=0; j<3; j++) @@ -3293,8 +3289,8 @@ DO_DEFSTATE: C_ReportError(-1); BITPTR_CLEAR(g_scriptPtr-apScript-1); *(g_scriptPtr-1) = 0; - initprintf("%s:%d: warning: expected a move, found a constant.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,g_lineNumber); + g_warningCnt++; } k = 0; @@ -3330,32 +3326,32 @@ DO_DEFSTATE: C_GetNextLabelName(); // Check to see it's already defined - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); continue; } - i = hash_find(&h_gamevars,label+(g_numLabels<<6)); + i = hash_find(&h_gamevars,label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i>=0)) { - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(WARNING_NAMEMATCHESVAR); } - i = hash_find(&h_labels,label+(g_numLabels<<6)); + i = hash_find(&h_labels,label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i>=0)) { - g_numCompilerWarnings++; - initprintf("%s:%d: warning: duplicate action `%s' ignored.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + g_warningCnt++; + initprintf("%s:%d: warning: duplicate action `%s' ignored.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); } else { - labeltype[g_numLabels] = LABEL_ACTION; - labelcode[g_numLabels] = g_scriptPtr-apScript; - hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0); - g_numLabels++; + labeltype[g_labelCnt] = LABEL_ACTION; + labelcode[g_labelCnt] = g_scriptPtr-apScript; + hash_add(&h_labels,label+(g_labelCnt<<6),g_labelCnt,0); + g_labelCnt++; } for (j=4; j>=0; j--) @@ -3377,7 +3373,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(g_processingState || g_parsingActorPtr)) { C_ReportError(ERROR_FOUNDWITHIN); - g_numCompilerErrors++; + g_errorCnt++; } g_numBraces = 0; @@ -3409,8 +3405,8 @@ DO_DEFSTATE: C_ReportError(-1); initprintf("%s:%d: warning: invalid useractor type. Must be 0, 1, 2" " (notenemy, enemy, enemystayput) or have 4 added (\"doesn't move\").\n", - g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber); + g_warningCnt++; j = 0; } } @@ -3421,7 +3417,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE((unsigned)*g_scriptPtr >= MAXTILES)) { C_ReportError(ERROR_EXCEEDSMAXTILES); - g_numCompilerErrors++; + g_errorCnt++; continue; } @@ -3486,8 +3482,8 @@ DO_DEFSTATE: C_ReportError(-1); BITPTR_CLEAR(g_scriptPtr-apScript-1); *(g_scriptPtr-1) = 0; - initprintf("%s:%d: warning: expected a move, found a constant.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,g_lineNumber); + g_warningCnt++; } break; } @@ -3505,7 +3501,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(g_processingState || g_parsingActorPtr)) { C_ReportError(ERROR_FOUNDWITHIN); - g_numCompilerErrors++; + g_errorCnt++; } g_numBraces = 0; @@ -3530,8 +3526,8 @@ DO_DEFSTATE: //AddLog(g_szBuf); if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXGAMEEVENTS-1)) { - initprintf("%s:%d: error: invalid event ID.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: invalid event ID.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; continue; } // if event has already been declared then store previous script location @@ -3578,16 +3574,16 @@ DO_DEFSTATE: { *(g_scriptPtr-1) = 32768; C_ReportError(-1); - initprintf("%s:%d: warning: tried to set cstat 32767, using 32768 instead.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: tried to set cstat 32767, using 32768 instead.\n",g_scriptFileName,g_lineNumber); + g_warningCnt++; } else if (EDUKE32_PREDICT_FALSE((*(g_scriptPtr-1) & 48) == 48)) { i = *(g_scriptPtr-1); *(g_scriptPtr-1) ^= 48; C_ReportError(-1); - initprintf("%s:%d: warning: tried to set cstat %d, using %d instead.\n",g_szScriptFileName,g_lineNumber,i,(int32_t)(*(g_scriptPtr-1))); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: tried to set cstat %d, using %d instead.\n",g_scriptFileName,g_lineNumber,i,(int32_t)(*(g_scriptPtr-1))); + g_warningCnt++; } continue; @@ -3647,10 +3643,10 @@ DO_DEFSTATE: { g_scriptPtr--; intptr_t *tempscrptr = g_scriptPtr; - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(-1); - initprintf("%s:%d: warning: found `else' with no `if'.\n", g_szScriptFileName, g_lineNumber); + initprintf("%s:%d: warning: found `else' with no `if'.\n", g_scriptFileName, g_lineNumber); if (C_GetKeyword() == CON_LEFTBRACE) { @@ -3822,18 +3818,18 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(*textptr!='.')) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_SYNTAXERROR); continue; } textptr++; C_GetNextLabelName(); - int32_t const labelNum=C_GetLabelNameID(UserdefsLabels,&h_userdef,Bstrtolower(label+(g_numLabels<<6))); + int32_t const labelNum=C_GetLabelNameID(UserdefsLabels,&h_userdef,Bstrtolower(label+(g_labelCnt<<6))); if (EDUKE32_PREDICT_FALSE(labelNum == -1)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAMEMBER); continue; } @@ -3879,24 +3875,24 @@ DO_DEFSTATE: C_GetNextLabelName(); - if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_numLabels<<6))>=0)) + if (EDUKE32_PREDICT_FALSE(hash_find(&h_keywords,label+(g_labelCnt<<6))>=0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_ISAKEYWORD); continue; } - i=GetDefID(label+(g_numLabels<<6)); + i=GetDefID(label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i<0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAGAMEVAR); continue; } if (EDUKE32_PREDICT_FALSE(aGameVars[i].flags & GAMEVAR_READONLY)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_VARREADONLY); continue; } @@ -3906,18 +3902,18 @@ DO_DEFSTATE: case CON_SETACTORVAR: if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].flags & GAMEVAR_PERACTOR))) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); - initprintf("%s:%d: error: variable `%s' is not per-actor.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: variable `%s' is not per-actor.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); continue; } break; case CON_SETPLAYERVAR: if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].flags & GAMEVAR_PERPLAYER))) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); - initprintf("%s:%d: error: variable `%s' is not per-player.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: variable `%s' is not per-player.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); continue; } break; @@ -4074,8 +4070,8 @@ DO_DEFSTATE: g_scriptPtr--; if (EDUKE32_PREDICT_FALSE(*g_scriptPtr > BYTEVERSION_EDUKE32)) { - g_numCompilerWarnings++; - initprintf("%s:%d: warning: need build %d, found build %d\n",g_szScriptFileName,g_lineNumber,k,BYTEVERSION_EDUKE32); + g_warningCnt++; + initprintf("%s:%d: warning: need build %d, found build %d\n",g_scriptFileName,g_lineNumber,k,BYTEVERSION_EDUKE32); } continue; @@ -4083,8 +4079,8 @@ DO_DEFSTATE: g_scriptPtr--; if (EDUKE32_PREDICT_FALSE(g_dynamicTileMapping)) { - initprintf("%s:%d: warning: duplicate dynamicremap statement\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: duplicate dynamicremap statement\n",g_scriptFileName,g_lineNumber); + g_warningCnt++; } else #ifdef DYNTILEREMAP_ENABLE @@ -4093,8 +4089,8 @@ DO_DEFSTATE: g_dynamicTileMapping = 1; #else { - initprintf("%s:%d: warning: dynamic tile remapping is disabled in this build\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: dynamic tile remapping is disabled in this build\n",g_scriptFileName,g_lineNumber); + g_warningCnt++; } #endif continue; @@ -4103,8 +4099,8 @@ DO_DEFSTATE: g_scriptPtr--; if (EDUKE32_PREDICT_FALSE(g_dynamicSoundMapping)) { - initprintf("%s:%d: warning: duplicate dynamicsoundremap statement\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: duplicate dynamicsoundremap statement\n",g_scriptFileName,g_lineNumber); + g_warningCnt++; } else #ifdef DYNSOUNDREMAP_ENABLE @@ -4113,8 +4109,8 @@ DO_DEFSTATE: g_dynamicSoundMapping = 1; #else { - initprintf("%s:%d: warning: dynamic sound remapping is disabled in this build\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: dynamic sound remapping is disabled in this build\n",g_scriptFileName,g_lineNumber); + g_warningCnt++; } #endif continue; @@ -4184,10 +4180,10 @@ DO_DEFSTATE: case CON_WRITEARRAYTOFILE: case CON_READARRAYFROMFILE: C_GetNextLabelName(); - i=GetADefID(label+(g_numLabels<<6)); + i=GetADefID(label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i < 0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAGAMEARRAY); return 1; } @@ -4200,10 +4196,10 @@ DO_DEFSTATE: case CON_COPY: C_GetNextLabelName(); - i=GetADefID(label+(g_numLabels<<6)); + i=GetADefID(label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i < 0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAGAMEARRAY); return 1; } @@ -4212,7 +4208,7 @@ DO_DEFSTATE: C_SkipComments();// skip comments and whitespace if (EDUKE32_PREDICT_FALSE(*textptr != '[')) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_GAMEARRAYBNO); return 1; } @@ -4221,17 +4217,17 @@ DO_DEFSTATE: C_SkipComments();// skip comments and whitespace if (EDUKE32_PREDICT_FALSE(*textptr != ']')) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_GAMEARRAYBNC); return 1; } textptr++; case CON_SETARRAY: C_GetNextLabelName(); - i=GetADefID(label+(g_numLabels<<6)); + i=GetADefID(label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i < 0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAGAMEARRAY); return 1; } @@ -4242,14 +4238,14 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(aGameArrays[i].flags & GAMEARRAY_READONLY)) { C_ReportError(ERROR_ARRAYREADONLY); - g_numCompilerErrors++; + g_errorCnt++; return 1; } C_SkipComments();// skip comments and whitespace if (EDUKE32_PREDICT_FALSE(*textptr != '[')) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_GAMEARRAYBNO); return 1; } @@ -4258,7 +4254,7 @@ DO_DEFSTATE: C_SkipComments();// skip comments and whitespace if (EDUKE32_PREDICT_FALSE(*textptr != ']')) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_GAMEARRAYBNC); return 1; } @@ -4269,10 +4265,10 @@ DO_DEFSTATE: case CON_GETARRAYSIZE: case CON_RESIZEARRAY: C_GetNextLabelName(); - i=GetADefID(label+(g_numLabels<<6)); + i=GetADefID(label+(g_labelCnt<<6)); if (EDUKE32_PREDICT_FALSE(i < 0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_NOTAGAMEARRAY); return 1; } @@ -4282,7 +4278,7 @@ DO_DEFSTATE: if (tw==CON_RESIZEARRAY && (aGameArrays[i].flags & GAMEARRAY_TYPE_MASK)) { C_ReportError(-1); - initprintf("can't resize system array `%s'.", label+(g_numLabels<<6)); + initprintf("can't resize system array `%s'.", label+(g_labelCnt<<6)); return 1; } @@ -4345,8 +4341,8 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(g_currentEvent == EVENT_ANIMATESPRITES)) { initprintf("%s:%d: warning: found `%s' inside EVENT_ANIMATESPRITES\n", - g_szScriptFileName,g_lineNumber,tempbuf); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber,tempbuf); + g_warningCnt++; } } continue; @@ -4370,7 +4366,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(g_processingState || g_parsingActorPtr)) { C_ReportError(ERROR_FOUNDWITHIN); - g_numCompilerErrors++; + g_errorCnt++; } g_scriptPtr--; @@ -4386,7 +4382,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXTILES)) { C_ReportError(ERROR_EXCEEDSMAXTILES); - g_numCompilerErrors++; + g_errorCnt++; continue; } @@ -4411,7 +4407,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXTILES)) { C_ReportError(ERROR_EXCEEDSMAXTILES); - g_numCompilerErrors++; + g_errorCnt++; continue; } @@ -4430,7 +4426,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(g_processingState || g_parsingActorPtr)) { C_ReportError(ERROR_FOUNDWITHIN); - g_numCompilerErrors++; + g_errorCnt++; } g_scriptPtr--; @@ -4442,7 +4438,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXTILES)) { C_ReportError(ERROR_EXCEEDSMAXTILES); - g_numCompilerErrors++; + g_errorCnt++; continue; } @@ -4467,7 +4463,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE((unsigned)i >= MAXTILES)) { C_ReportError(ERROR_EXCEEDSMAXTILES); - g_numCompilerErrors++; + g_errorCnt++; } g_tile[j].cacherange = i; @@ -4586,15 +4582,16 @@ DO_DEFSTATE: C_GetNextLabelName(); - int32_t how = hash_find(&h_iter, label + (g_numLabels << 6)); - if (how < 0) + int const iterType = hash_find(&h_iter, label + (g_labelCnt << 6)); + + if (iterType < 0) { - C_CUSTOMERROR("unknown iteration type `%s'.", label + (g_numLabels << 6)); + C_CUSTOMERROR("unknown iteration type `%s'.", label + (g_labelCnt << 6)); return 1; } - *g_scriptPtr++ = how; + *g_scriptPtr++ = iterType; - if (how >= ITER_SPRITESOFSECTOR) + if (iterType >= ITER_SPRITESOFSECTOR) C_GetNextVar(); intptr_t offset = g_scriptPtr-apScript; @@ -4612,7 +4609,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0)) { C_ReportError(ERROR_EVENTONLY); - g_numCompilerErrors++; + g_errorCnt++; } // syntax: @@ -4628,7 +4625,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0)) { C_ReportError(ERROR_EVENTONLY); - g_numCompilerErrors++; + g_errorCnt++; } C_GetManyVars(13); @@ -4639,7 +4636,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0)) { C_ReportError(ERROR_EVENTONLY); - g_numCompilerErrors++; + g_errorCnt++; } C_GetManyVars(10); @@ -4721,7 +4718,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0)) { C_ReportError(ERROR_EVENTONLY); - g_numCompilerErrors++; + g_errorCnt++; } switch (tw) @@ -4755,7 +4752,7 @@ DO_DEFSTATE: if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0)) { C_ReportError(ERROR_EVENTONLY); - g_numCompilerErrors++; + g_errorCnt++; } // syntax: @@ -4893,9 +4890,9 @@ DO_DEFSTATE: { if (EDUKE32_PREDICT_FALSE(g_checkingSwitch < 1)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); - initprintf("%s:%d: error: found `%s' statement when not in switch\n", g_szScriptFileName, + initprintf("%s:%d: error: found `%s' statement when not in switch\n", g_scriptFileName, g_lineNumber, tw == CON_CASE ? "case" : "default"); g_scriptPtr--; return 1; @@ -4931,9 +4928,9 @@ repeatcase: if (EDUKE32_PREDICT_FALSE(g_caseScriptPtr && g_caseScriptPtr[0]!=0)) { // duplicate default statement - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); - initprintf("%s:%d: error: multiple `default' statements found in switch\n", g_szScriptFileName, g_lineNumber); + initprintf("%s:%d: error: multiple `default' statements found in switch\n", g_scriptFileName, g_lineNumber); } g_caseScriptPtr[0]=(intptr_t) (g_scriptPtr-&apScript[0]); // save offset } @@ -4942,7 +4939,7 @@ repeatcase: for (i=(g_numCases/2)-1; i>=0; i--) if (EDUKE32_PREDICT_FALSE(g_caseScriptPtr[i*2+1]==j)) { - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(WARNING_DUPLICATECASE); break; } @@ -4985,17 +4982,17 @@ repeatcase: { if (EDUKE32_PREDICT_FALSE(g_checkingCase)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); - initprintf("%s:%d: error: found `endswitch' before `break' or `return'\n", g_szScriptFileName, g_lineNumber); + initprintf("%s:%d: error: found `endswitch' before `break' or `return'\n", g_scriptFileName, g_lineNumber); } } if (EDUKE32_PREDICT_FALSE(--g_checkingSwitch < 0)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); - initprintf("%s:%d: error: found `endswitch' without matching `switch'\n", g_szScriptFileName, g_lineNumber); + initprintf("%s:%d: error: found `endswitch' without matching `switch'\n", g_scriptFileName, g_lineNumber); } return 1; // end of block @@ -5075,8 +5072,8 @@ repeatcase: { C_ReportError(-1); *(g_scriptPtr-1) = 0; - initprintf("%s:%d: warning: expected a move, found a constant.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,g_lineNumber); + g_warningCnt++; } break; case CON_IFPINVENTORY: @@ -5177,7 +5174,7 @@ repeatcase: case CON_LEFTBRACE: if (EDUKE32_PREDICT_FALSE(!(g_processingState || g_parsingActorPtr || g_parsingEventPtr))) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(ERROR_SYNTAXERROR); } g_numBraces++; @@ -5215,8 +5212,8 @@ repeatcase: } C_ReportError(-1); - initprintf("%s:%d: error: found more `}' than `{'.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: found more `}' than `{'.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; } if (g_checkingIfElse && j != CON_ELSE) @@ -5242,15 +5239,15 @@ repeatcase: if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXVOLUMES-1)) { - initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; C_NextLine(); continue; } if (EDUKE32_PREDICT_FALSE((unsigned)k > MAXLEVELS-1)) { - initprintf("%s:%d: error: level number exceeds maximum number of levels per episode.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: level number exceeds maximum number of levels per episode.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; C_NextLine(); continue; } @@ -5268,8 +5265,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSKILLS)) { initprintf("%s:%d: error: skill number exceeds maximum skill count %d.\n", - g_szScriptFileName,g_lineNumber, MAXSKILLS); - g_numCompilerErrors++; + g_scriptFileName,g_lineNumber, MAXSKILLS); + g_errorCnt++; C_NextLine(); continue; } @@ -5287,8 +5284,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXVOLUMES-1)) { initprintf("%s:%d: error: volume number exceeds maximum volume count.\n", - g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + g_scriptFileName,g_lineNumber); + g_errorCnt++; C_NextLine(); continue; } @@ -5308,8 +5305,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXVOLUMES-1)) { initprintf("%s:%d: error: volume number exceeds maximum volume count.\n", - g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + g_scriptFileName,g_lineNumber); + g_errorCnt++; C_NextLine(); continue; } @@ -5318,19 +5315,19 @@ repeatcase: while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) { - EpisodeNames[j][i] = *textptr; + g_volumeNames[j][i] = *textptr; textptr++,i++; - if (EDUKE32_PREDICT_FALSE(i >= (signed)sizeof(EpisodeNames[j])-1)) + if (EDUKE32_PREDICT_FALSE(i >= (signed)sizeof(g_volumeNames[j])-1)) { initprintf("%s:%d: warning: truncating volume name to %d characters.\n", - g_szScriptFileName,g_lineNumber,(int32_t)sizeof(EpisodeNames[j])-1); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber,(int32_t)sizeof(g_volumeNames[j])-1); + g_warningCnt++; C_NextLine(); break; } } - g_numVolumes = j+1; - EpisodeNames[j][i] = '\0'; + g_volumeCnt = j+1; + g_volumeNames[j][i] = '\0'; continue; case CON_DEFINEVOLUMEFLAGS: @@ -5344,8 +5341,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXVOLUMES-1)) { - initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; C_NextLine(); continue; } @@ -5364,8 +5361,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE((unsigned)j > NUMGAMEFUNCTIONS-1)) { initprintf("%s:%d: error: function number exceeds number of game functions.\n", - g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + g_scriptFileName,g_lineNumber); + g_errorCnt++; C_NextLine(); continue; } @@ -5380,16 +5377,16 @@ repeatcase: if (EDUKE32_PREDICT_FALSE(*textptr != 0x0a && *textptr != 0x0d && ispecial(*textptr))) { initprintf("%s:%d: warning: invalid character in function name.\n", - g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber); + g_warningCnt++; C_NextLine(); break; } if (EDUKE32_PREDICT_FALSE(i >= MAXGAMEFUNCLEN-1)) { initprintf("%s:%d: warning: truncating function name to %d characters.\n", - g_szScriptFileName,g_lineNumber,MAXGAMEFUNCLEN); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber,MAXGAMEFUNCLEN); + g_warningCnt++; C_NextLine(); break; } @@ -5417,8 +5414,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSKILLS)) { initprintf("%s:%d: error: skill number exceeds maximum skill count %d.\n", - g_szScriptFileName,g_lineNumber, MAXSKILLS); - g_numCompilerErrors++; + g_scriptFileName,g_lineNumber, MAXSKILLS); + g_errorCnt++; C_NextLine(); continue; } @@ -5427,24 +5424,24 @@ repeatcase: while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) { - SkillNames[j][i] = *textptr; + g_skillNames[j][i] = *textptr; textptr++,i++; - if (EDUKE32_PREDICT_FALSE(i >= (signed)sizeof(SkillNames[j])-1)) + if (EDUKE32_PREDICT_FALSE(i >= (signed)sizeof(g_skillNames[j])-1)) { initprintf("%s:%d: warning: truncating skill name to %d characters.\n", - g_szScriptFileName,g_lineNumber,(int32_t)sizeof(SkillNames[j])-1); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber,(int32_t)sizeof(g_skillNames[j])-1); + g_warningCnt++; C_NextLine(); break; } } - SkillNames[j][i] = '\0'; + g_skillNames[j][i] = '\0'; for (i=0; i= (signed)sizeof(gamename)-1)) { initprintf("%s:%d: warning: truncating game name to %d characters.\n", - g_szScriptFileName,g_lineNumber,(int32_t)sizeof(gamename)-1); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber,(int32_t)sizeof(gamename)-1); + g_warningCnt++; C_NextLine(); break; } @@ -5518,35 +5515,35 @@ repeatcase: C_GetNextValue(LABEL_DEFINE); g_scriptPtr--; - GametypeFlags[j] = *g_scriptPtr; + g_gametypeFlags[j] = *g_scriptPtr; C_SkipComments(); if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXGAMETYPES-1)) { - initprintf("%s:%d: error: gametype number exceeds maximum gametype count.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: gametype number exceeds maximum gametype count.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; C_NextLine(); continue; } - g_numGametypes = j+1; + g_gametypeCnt = j+1; i = 0; while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) { - GametypeNames[j][i] = *textptr; + g_gametypeNames[j][i] = *textptr; textptr++,i++; - if (EDUKE32_PREDICT_FALSE(i >= (signed)sizeof(GametypeNames[j])-1)) + if (EDUKE32_PREDICT_FALSE(i >= (signed)sizeof(g_gametypeNames[j])-1)) { initprintf("%s:%d: warning: truncating gametype name to %d characters.\n", - g_szScriptFileName,g_lineNumber,(int32_t)sizeof(GametypeNames[j])-1); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber,(int32_t)sizeof(g_gametypeNames[j])-1); + g_warningCnt++; C_NextLine(); break; } } - GametypeNames[j][i] = '\0'; + g_gametypeNames[j][i] = '\0'; continue; case CON_DEFINELEVELNAME: @@ -5561,15 +5558,15 @@ repeatcase: if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXVOLUMES-1)) { - initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: volume number exceeds maximum volume count.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; C_NextLine(); continue; } if (EDUKE32_PREDICT_FALSE((unsigned)k > MAXLEVELS-1)) { - initprintf("%s:%d: error: level number exceeds maximum number of levels per episode.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: level number exceeds maximum number of levels per episode.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; C_NextLine(); continue; } @@ -5584,8 +5581,8 @@ repeatcase: textptr++,i++; if (EDUKE32_PREDICT_FALSE(i >= BMAX_PATH)) { - initprintf("%s:%d: error: level file name exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,BMAX_PATH); - g_numCompilerErrors++; + initprintf("%s:%d: error: level file name exceeds limit of %d characters.\n",g_scriptFileName,g_lineNumber,BMAX_PATH); + g_errorCnt++; C_SkipSpace(); break; } @@ -5594,16 +5591,16 @@ repeatcase: Bcorrectfilename(tempbuf,0); - if (aMapInfo[j *MAXLEVELS+k].filename == NULL) - aMapInfo[j *MAXLEVELS+k].filename = (char *)Xcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t)); - else if ((Bstrlen(tempbuf)+1) > sizeof(aMapInfo[j*MAXLEVELS+k].filename)) - aMapInfo[j *MAXLEVELS+k].filename = (char *)Xrealloc(aMapInfo[j*MAXLEVELS+k].filename,(Bstrlen(tempbuf)+1)); + if (g_mapInfo[j *MAXLEVELS+k].filename == NULL) + g_mapInfo[j *MAXLEVELS+k].filename = (char *)Xcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t)); + else if ((Bstrlen(tempbuf)+1) > sizeof(g_mapInfo[j*MAXLEVELS+k].filename)) + g_mapInfo[j *MAXLEVELS+k].filename = (char *)Xrealloc(g_mapInfo[j*MAXLEVELS+k].filename,(Bstrlen(tempbuf)+1)); - Bstrcpy(aMapInfo[j*MAXLEVELS+k].filename,tempbuf); + Bstrcpy(g_mapInfo[j*MAXLEVELS+k].filename,tempbuf); C_SkipComments(); - aMapInfo[j *MAXLEVELS+k].partime = + g_mapInfo[j *MAXLEVELS+k].partime = (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*REALGAMETICSPERSEC*60)+ (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*REALGAMETICSPERSEC); @@ -5613,7 +5610,7 @@ repeatcase: // cheap hack, 0.99 doesn't have the 3D Realms time if (*(textptr+2) == ':') { - aMapInfo[j *MAXLEVELS+k].designertime = + g_mapInfo[j *MAXLEVELS+k].designertime = (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*REALGAMETICSPERSEC*60)+ (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*REALGAMETICSPERSEC); @@ -5631,8 +5628,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE(i >= 32)) { initprintf("%s:%d: warning: truncating level name to %d characters.\n", - g_szScriptFileName,g_lineNumber,32); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber,32); + g_warningCnt++; C_NextLine(); break; } @@ -5640,14 +5637,14 @@ repeatcase: tempbuf[i] = '\0'; - if (aMapInfo[j*MAXLEVELS+k].name == NULL) - aMapInfo[j*MAXLEVELS+k].name = (char *)Xcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t)); - else if ((Bstrlen(tempbuf)+1) > sizeof(aMapInfo[j*MAXLEVELS+k].name)) - aMapInfo[j *MAXLEVELS+k].name = (char *)Xrealloc(aMapInfo[j*MAXLEVELS+k].name,(Bstrlen(tempbuf)+1)); + if (g_mapInfo[j*MAXLEVELS+k].name == NULL) + g_mapInfo[j*MAXLEVELS+k].name = (char *)Xcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t)); + else if ((Bstrlen(tempbuf)+1) > sizeof(g_mapInfo[j*MAXLEVELS+k].name)) + g_mapInfo[j *MAXLEVELS+k].name = (char *)Xrealloc(g_mapInfo[j*MAXLEVELS+k].name,(Bstrlen(tempbuf)+1)); /* initprintf("level name string len: %d\n",Bstrlen(tempbuf)); */ - Bstrcpy(aMapInfo[j*MAXLEVELS+k].name,tempbuf); + Bstrcpy(g_mapInfo[j*MAXLEVELS+k].name,tempbuf); continue; @@ -5664,8 +5661,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE((unsigned)k >= MAXQUOTES)) { - initprintf("%s:%d: error: quote number exceeds limit of %d.\n",g_szScriptFileName,g_lineNumber,MAXQUOTES); - g_numCompilerErrors++; + initprintf("%s:%d: error: quote number exceeds limit of %d.\n",g_scriptFileName,g_lineNumber,MAXQUOTES); + g_errorCnt++; } else { @@ -5703,8 +5700,8 @@ repeatcase: textptr++,i++; if (EDUKE32_PREDICT_FALSE(i >= MAXQUOTELEN-1)) { - initprintf("%s:%d: warning: truncating quote text to %d characters.\n",g_szScriptFileName,g_lineNumber,MAXQUOTELEN-1); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: truncating quote text to %d characters.\n",g_scriptFileName,g_lineNumber,MAXQUOTELEN-1); + g_warningCnt++; C_NextLine(); break; } @@ -5740,8 +5737,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE(k > 25)) { - initprintf("%s:%d: error: cheat redefinition attempts to redefine nonexistent cheat.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: cheat redefinition attempts to redefine nonexistent cheat.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; C_NextLine(); continue; } @@ -5755,8 +5752,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE(i >= (signed)sizeof(CheatStrings[k])-1)) { initprintf("%s:%d: warning: truncating cheat string to %d characters.\n", - g_szScriptFileName,g_lineNumber,(signed)sizeof(CheatStrings[k])-1); - g_numCompilerWarnings++; + g_scriptFileName,g_lineNumber,(signed)sizeof(CheatStrings[k])-1); + g_warningCnt++; C_NextLine(); break; } @@ -5775,8 +5772,8 @@ repeatcase: k = *(g_scriptPtr-1); if (EDUKE32_PREDICT_FALSE((unsigned)k >= MAXSOUNDS)) { - initprintf("%s:%d: error: exceeded sound limit of %d.\n",g_szScriptFileName,g_lineNumber,MAXSOUNDS); - g_numCompilerErrors++; + initprintf("%s:%d: error: exceeded sound limit of %d.\n",g_scriptFileName,g_lineNumber,MAXSOUNDS); + g_errorCnt++; } g_scriptPtr--; i = 0; @@ -5793,8 +5790,8 @@ repeatcase: g_sounds[k].filename[i++] = *textptr++; if (EDUKE32_PREDICT_FALSE(i >= BMAX_PATH-1)) { - initprintf("%s:%d: error: sound filename exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,BMAX_PATH-1); - g_numCompilerErrors++; + initprintf("%s:%d: error: sound filename exceeds limit of %d characters.\n",g_scriptFileName,g_lineNumber,BMAX_PATH-1); + g_errorCnt++; C_SkipComments(); break; } @@ -5806,8 +5803,8 @@ repeatcase: g_sounds[k].filename[i++] = *textptr++; if (EDUKE32_PREDICT_FALSE(i >= BMAX_PATH-1)) { - initprintf("%s:%d: error: sound filename exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,BMAX_PATH-1); - g_numCompilerErrors++; + initprintf("%s:%d: error: sound filename exceeds limit of %d characters.\n",g_scriptFileName,g_lineNumber,BMAX_PATH-1); + g_errorCnt++; C_SkipComments(); break; } @@ -5844,18 +5841,18 @@ repeatcase: if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr)) { C_ReportError(-1); - initprintf("%s:%d: error: found `endevent' without open `onevent'.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: found `endevent' without open `onevent'.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; } if (EDUKE32_PREDICT_FALSE(g_numBraces > 0)) { C_ReportError(ERROR_OPENBRACKET); - g_numCompilerErrors++; + g_errorCnt++; } else if (EDUKE32_PREDICT_FALSE(g_numBraces < 0)) { C_ReportError(ERROR_CLOSEBRACKET); - g_numCompilerErrors++; + g_errorCnt++; } // if event has already been declared then put a jump in instead if (previous_event) @@ -5895,14 +5892,14 @@ repeatcase: if (EDUKE32_PREDICT_FALSE(!g_parsingActorPtr || g_parsingEventPtr)) { C_ReportError(-1); - initprintf("%s:%d: error: found `enda' without open `actor'.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerErrors++; + initprintf("%s:%d: error: found `enda' without open `actor'.\n",g_scriptFileName,g_lineNumber); + g_errorCnt++; g_parsingEventPtr = 0; } if (EDUKE32_PREDICT_FALSE(g_numBraces != 0)) { C_ReportError(g_numBraces > 0 ? ERROR_OPENBRACKET : ERROR_CLOSEBRACKET); - g_numCompilerErrors++; + g_errorCnt++; } g_parsingActorPtr = 0; Bsprintf(g_szCurrentBlockName,"(none)"); @@ -5922,8 +5919,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE(otw == CON_BREAK)) { C_ReportError(-1); - initprintf("%s:%d: warning: duplicate `break'.\n",g_szScriptFileName, g_lineNumber); - g_numCompilerWarnings++; + initprintf("%s:%d: warning: duplicate `break'.\n",g_scriptFileName, g_lineNumber); + g_warningCnt++; g_scriptPtr--; continue; } @@ -5989,8 +5986,8 @@ repeatcase: if (EDUKE32_PREDICT_FALSE(C_GetKeyword() != CON_ELSE)) { C_ReportError(-1); - g_numCompilerWarnings++; - initprintf("%s:%d: warning: `nullop' found without `else'\n",g_szScriptFileName,g_lineNumber); + g_warningCnt++; + initprintf("%s:%d: warning: `nullop' found without `else'\n",g_scriptFileName,g_lineNumber); g_scriptPtr--; g_ifElseAborted = 1; } @@ -6070,11 +6067,11 @@ repeatcase: /* Anything added with C_AddDefinition() cannot be overwritten in the CONs */ static void C_AddDefinition(const char *lLabel,int32_t lValue,int32_t lType) { - Bstrcpy(label+(g_numLabels<<6),lLabel); - labeltype[g_numLabels] = lType; - hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0); - labelcode[g_numLabels++] = lValue; - g_numDefaultLabels++; + Bstrcpy(label+(g_labelCnt<<6),lLabel); + labeltype[g_labelCnt] = lType; + hash_add(&h_labels,label+(g_labelCnt<<6),g_labelCnt,0); + labelcode[g_labelCnt++] = lValue; + g_defaultLabelCnt++; } // KEEPINSYNC lunatic/con_lang.lua @@ -6237,7 +6234,7 @@ static char const * C_ScriptVersionString(int32_t version) void C_PrintStats(void) { - initprintf("%d/%d labels, %d/%d variables, %d/%d arrays\n", g_numLabels, + initprintf("%d/%d labels, %d/%d variables, %d/%d arrays\n", g_labelCnt, (int32_t) min((MAXSECTORS * sizeof(sectortype)/sizeof(int32_t)), MAXSPRITES * sizeof(spritetype)/(1<<6)), g_gameVarCount, MAXGAMEVARS, g_gameArrayCount, MAXGAMEARRAYS); @@ -6332,16 +6329,16 @@ void C_Compile(const char *filenam) bitptr = (char *)Xcalloc(1,(((g_scriptSize+7)>>3)+1) * sizeof(uint8_t)); // initprintf("script: %d, bitptr: %d\n",script,bitptr); - g_numLabels = g_numDefaultLabels = 0; + g_labelCnt = g_defaultLabelCnt = 0; g_scriptPtr = apScript+3; // move permits constants 0 and 1; moveptr[1] would be script[2] (reachable?) - g_numCompilerWarnings = 0; - g_numCompilerErrors = 0; + g_warningCnt = 0; + g_errorCnt = 0; g_lineNumber = 1; g_totalLines = 0; C_AddDefaultDefinitions(); - Bstrcpy(g_szScriptFileName, filenam); + Bstrcpy(g_scriptFileName, filenam); C_ParseCommand(1); @@ -6355,17 +6352,17 @@ void C_Compile(const char *filenam) flushlogwindow = 1; - if (g_numCompilerErrors > 63) + if (g_errorCnt > 63) initprintf("fatal error: too many errors: Aborted\n"); //*script = (intptr_t) g_scriptPtr; DO_FREE_AND_NULL(mptr); - if (g_numCompilerWarnings || g_numCompilerErrors) - initprintf("Found %d warning(s), %d error(s).\n", g_numCompilerWarnings, g_numCompilerErrors); + if (g_warningCnt || g_errorCnt) + initprintf("Found %d warning(s), %d error(s).\n", g_warningCnt, g_errorCnt); - if (g_numCompilerErrors) + if (g_errorCnt) { if (g_loadFromGroupOnly) { @@ -6441,95 +6438,95 @@ void C_ReportError(int32_t iError) if (Bstrcmp(g_szCurrentBlockName,g_szLastBlockName)) { if (g_parsingEventPtr || g_processingState || g_parsingActorPtr) - initprintf("%s: In %s `%s':\n",g_szScriptFileName,g_parsingEventPtr?"event":g_parsingActorPtr?"actor":"state",g_szCurrentBlockName); - else initprintf("%s: At top level:\n",g_szScriptFileName); + initprintf("%s: In %s `%s':\n",g_scriptFileName,g_parsingEventPtr?"event":g_parsingActorPtr?"actor":"state",g_szCurrentBlockName); + else initprintf("%s: At top level:\n",g_scriptFileName); Bstrcpy(g_szLastBlockName,g_szCurrentBlockName); } switch (iError) { case ERROR_CLOSEBRACKET: - initprintf("%s:%d: error: found more `}' than `{' before `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf); + initprintf("%s:%d: error: found more `}' than `{' before `%s'.\n",g_scriptFileName,g_lineNumber,tempbuf); break; case ERROR_EVENTONLY: - initprintf("%s:%d: error: keyword `%s' only available during events.\n",g_szScriptFileName,g_lineNumber,tempbuf); + initprintf("%s:%d: error: keyword `%s' only available during events.\n",g_scriptFileName,g_lineNumber,tempbuf); break; case ERROR_EXCEEDSMAXTILES: - initprintf("%s:%d: error: `%s' value exceeds MAXTILES. Maximum is %d.\n",g_szScriptFileName,g_lineNumber,tempbuf,MAXTILES-1); + initprintf("%s:%d: error: `%s' value exceeds MAXTILES. Maximum is %d.\n",g_scriptFileName,g_lineNumber,tempbuf,MAXTILES-1); break; case ERROR_EXPECTEDKEYWORD: - initprintf("%s:%d: error: expected a keyword but found `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf); + initprintf("%s:%d: error: expected a keyword but found `%s'.\n",g_scriptFileName,g_lineNumber,tempbuf); break; case ERROR_FOUNDWITHIN: - initprintf("%s:%d: error: found `%s' within %s.\n",g_szScriptFileName,g_lineNumber,tempbuf,g_parsingEventPtr?"an event":g_parsingActorPtr?"an actor":"a state"); + initprintf("%s:%d: error: found `%s' within %s.\n",g_scriptFileName,g_lineNumber,tempbuf,g_parsingEventPtr?"an event":g_parsingActorPtr?"an actor":"a state"); break; case ERROR_ISAKEYWORD: - initprintf("%s:%d: error: symbol `%s' is a keyword.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: symbol `%s' is a keyword.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case ERROR_NOENDSWITCH: - initprintf("%s:%d: error: did not find `endswitch' before `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: did not find `endswitch' before `%s'.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case ERROR_NOTAGAMEDEF: - initprintf("%s:%d: error: symbol `%s' is not a definition.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: symbol `%s' is not a definition.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case ERROR_NOTAGAMEVAR: - initprintf("%s:%d: error: symbol `%s' is not a variable.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: symbol `%s' is not a variable.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case ERROR_NOTAGAMEARRAY: - initprintf("%s:%d: error: symbol `%s' is not an array.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: symbol `%s' is not an array.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case ERROR_GAMEARRAYBNC: - initprintf("%s:%d: error: malformed array index: expected ], found %c\n",g_szScriptFileName,g_lineNumber,*textptr); + initprintf("%s:%d: error: malformed array index: expected ], found %c\n",g_scriptFileName,g_lineNumber,*textptr); break; case ERROR_GAMEARRAYBNO: - initprintf("%s:%d: error: malformed array index: expected [, found %c\n",g_szScriptFileName,g_lineNumber,*textptr); + initprintf("%s:%d: error: malformed array index: expected [, found %c\n",g_scriptFileName,g_lineNumber,*textptr); break; case ERROR_INVALIDARRAYWRITE: - initprintf("%s:%d: error: arrays can only be written to using `setarray'.\n",g_szScriptFileName,g_lineNumber); + initprintf("%s:%d: error: arrays can only be written to using `setarray'.\n",g_scriptFileName,g_lineNumber); break; case ERROR_OPENBRACKET: - initprintf("%s:%d: error: found more `{' than `}' before `%s'.\n",g_szScriptFileName,g_lineNumber,tempbuf); + initprintf("%s:%d: error: found more `{' than `}' before `%s'.\n",g_scriptFileName,g_lineNumber,tempbuf); break; case ERROR_PARAMUNDEFINED: - initprintf("%s:%d: error: parameter `%s' is undefined.\n",g_szScriptFileName,g_lineNumber,tempbuf); + initprintf("%s:%d: error: parameter `%s' is undefined.\n",g_scriptFileName,g_lineNumber,tempbuf); break; case ERROR_NOTAMEMBER: - initprintf("%s:%d: error: symbol `%s' is not a valid structure member.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: symbol `%s' is not a valid structure member.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case ERROR_SYNTAXERROR: - initprintf("%s:%d: error: syntax error.\n",g_szScriptFileName,g_lineNumber); + initprintf("%s:%d: error: syntax error.\n",g_scriptFileName,g_lineNumber); break; case ERROR_VARREADONLY: - initprintf("%s:%d: error: variable `%s' is read-only.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: variable `%s' is read-only.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case ERROR_ARRAYREADONLY: - initprintf("%s:%d: error: array `%s' is read-only.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: array `%s' is read-only.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case ERROR_VARTYPEMISMATCH: - initprintf("%s:%d: error: variable `%s' is of the wrong type.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: error: variable `%s' is of the wrong type.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case WARNING_BADGAMEVAR: - initprintf("%s:%d: warning: variable `%s' should be either per-player OR per-actor, not both.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: warning: variable `%s' should be either per-player OR per-actor, not both.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case WARNING_DUPLICATECASE: - initprintf("%s:%d: warning: duplicate case ignored.\n",g_szScriptFileName,g_lineNumber); + initprintf("%s:%d: warning: duplicate case ignored.\n",g_scriptFileName,g_lineNumber); break; case WARNING_DUPLICATEDEFINITION: - initprintf("%s:%d: warning: duplicate definition `%s' ignored.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: warning: duplicate definition `%s' ignored.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case WARNING_EVENTSYNC: - initprintf("%s:%d: warning: found `%s' within a local event.\n",g_szScriptFileName,g_lineNumber,tempbuf); + initprintf("%s:%d: warning: found `%s' within a local event.\n",g_scriptFileName,g_lineNumber,tempbuf); break; case WARNING_LABELSONLY: - initprintf("%s:%d: warning: expected a label, found a constant.\n",g_szScriptFileName,g_lineNumber); + initprintf("%s:%d: warning: expected a label, found a constant.\n",g_scriptFileName,g_lineNumber); break; case WARNING_NAMEMATCHESVAR: - initprintf("%s:%d: warning: symbol `%s' already used for variable.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: warning: symbol `%s' already used for variable.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); break; case WARNING_VARMASKSKEYWORD: - initprintf("%s:%d: warning: variable `%s' masks keyword.\n", g_szScriptFileName, g_lineNumber, label+(g_numLabels<<6)); + initprintf("%s:%d: warning: variable `%s' masks keyword.\n", g_scriptFileName, g_lineNumber, label+(g_labelCnt<<6)); break; case WARNING_ARRAYMASKSKEYWORD: - initprintf("%s:%d: warning: array `%s' masks keyword.\n", g_szScriptFileName, g_lineNumber, label+(g_numLabels<<6)); + initprintf("%s:%d: warning: array `%s' masks keyword.\n", g_scriptFileName, g_lineNumber, label+(g_labelCnt<<6)); break; } } diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index e14bd3fa4..212bbd268 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -40,20 +40,20 @@ extern "C" { #define VM_INSTMASK 0xfff -#define C_CUSTOMERROR(Text, ...) \ - do \ - { \ - C_ReportError(-1); \ - initprintf("%s:%d: error: " Text "\n", g_szScriptFileName, g_lineNumber, ##__VA_ARGS__); \ - g_numCompilerErrors++; \ +#define C_CUSTOMERROR(Text, ...) \ + do \ + { \ + C_ReportError(-1); \ + initprintf("%s:%d: error: " Text "\n", g_scriptFileName, g_lineNumber, ##__VA_ARGS__); \ + g_errorCnt++; \ } while (0) -#define C_CUSTOMWARNING(Text, ...) \ - do \ - { \ - C_ReportError(-1); \ - initprintf("%s:%d: warning: " Text "\n", g_szScriptFileName, g_lineNumber, ##__VA_ARGS__); \ - g_numCompilerWarnings++; \ +#define C_CUSTOMWARNING(Text, ...) \ + do \ + { \ + C_ReportError(-1); \ + initprintf("%s:%d: warning: " Text "\n", g_scriptFileName, g_lineNumber, ##__VA_ARGS__); \ + g_warningCnt++; \ } while (0) #if !defined LUNATIC @@ -68,16 +68,16 @@ extern hashtable_t h_gamevars; extern hashtable_t h_arrays; extern hashtable_t h_labels; +extern int32_t g_aimAngleVarID; // var ID of "AUTOAIMANGLE" +extern int32_t g_angRangeVarID; // var ID of "ANGRANGE" +extern int32_t g_hitagVarID; // var ID of "HITAG" +extern int32_t g_lotagVarID; // var ID of "LOTAG" extern int32_t g_returnVarID; // var ID of "RETURN" +extern int32_t g_textureVarID; // var ID of "TEXTURE" +extern int32_t g_thisActorVarID; // var ID of "THISACTOR" extern int32_t g_weaponVarID; // var ID of "WEAPON" extern int32_t g_worksLikeVarID; // var ID of "WORKSLIKE" extern int32_t g_zRangeVarID; // var ID of "ZRANGE" -extern int32_t g_angRangeVarID; // var ID of "ANGRANGE" -extern int32_t g_aimAngleVarID; // var ID of "AUTOAIMANGLE" -extern int32_t g_lotagVarID; // var ID of "LOTAG" -extern int32_t g_hitagVarID; // var ID of "HITAG" -extern int32_t g_textureVarID; // var ID of "TEXTURE" -extern int32_t g_thisActorVarID; // var ID of "THISACTOR" // KEEPINSYNC gamevars.c: "special vars for struct access" enum QuickStructureAccess_t @@ -103,15 +103,20 @@ extern int32_t g_structVarIDs; extern intptr_t apScriptEvents[MAXGAMEEVENTS]; #endif -extern int32_t otherp; -extern char CheatStrings[][MAXCHEATLEN]; +extern char CheatStrings[][MAXCHEATLEN]; +extern char g_scriptFileName[BMAX_PATH]; + extern const uint32_t CheatFunctionFlags[]; extern const uint8_t CheatFunctionIDs[]; -extern char g_szScriptFileName[BMAX_PATH]; -extern int32_t g_totalLines, g_lineNumber; -extern int32_t g_numCompilerErrors, g_numCompilerWarnings, g_numXStrings; -extern int32_t g_scriptVersion; -extern char g_szBuf[1024]; + +extern int g_errorCnt; +extern int g_lineNumber; +extern int g_numXStrings; +extern int g_scriptVersion; +extern int g_totalLines; +extern int g_warningCnt; + +extern int32_t otherp; extern const char *EventNames[]; // MAXEVENTS @@ -124,16 +129,16 @@ typedef struct int lId, flags, maxParm2; } memberlabel_t; -extern const memberlabel_t SectorLabels[]; -extern const memberlabel_t WallLabels[]; extern const memberlabel_t ActorLabels[]; +extern const memberlabel_t InputLabels[]; +extern const memberlabel_t PalDataLabels[]; extern const memberlabel_t PlayerLabels[]; extern const memberlabel_t ProjectileLabels[]; -extern const memberlabel_t UserdefsLabels[]; -extern const memberlabel_t InputLabels[]; -extern const memberlabel_t TsprLabels[]; +extern const memberlabel_t SectorLabels[]; extern const memberlabel_t TileDataLabels[]; -extern const memberlabel_t PalDataLabels[]; +extern const memberlabel_t TsprLabels[]; +extern const memberlabel_t UserdefsLabels[]; +extern const memberlabel_t WallLabels[]; #endif typedef projectile_t defaultprojectile_t; @@ -166,7 +171,7 @@ typedef struct { extern vmstate_t vm; void G_DoGameStartup(const int32_t *params); -void C_DefineMusic(int32_t vol, int32_t lev, const char *fn); +void C_DefineMusic(int volumeNum, int levelNum, const char *fileName); void C_DefineVolumeFlags(int32_t vol, int32_t flags); void C_UndefineVolume(int32_t vol); diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 950fb2afd..ba49838f0 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -193,7 +193,7 @@ FORCE_INLINE int32_t VM_EventCommon_(int const eventNum, int const spriteNum, in vm.pData = dummy_t; } - if ((unsigned)playerNum >= (unsigned)playerswhenstarted) + if ((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers) vm.pPlayer = g_player[0].ps; VM_Execute(1); @@ -1083,11 +1083,11 @@ int G_StartTrack(int levelNum) { int trackNum = MAXLEVELS*ud.volume_number + levelNum; - if (aMapInfo[trackNum].musicfn != NULL) + if (g_mapInfo[trackNum].musicfn != NULL) { // Only set g_musicIndex on success. g_musicIndex = trackNum; - S_PlayMusic(aMapInfo[trackNum].musicfn); + S_PlayMusic(g_mapInfo[trackNum].musicfn); return 0; } @@ -1451,7 +1451,7 @@ skip_check: case CON_IFGOTWEAPONCE: insptr++; - if ((GametypeFlags[ud.coop]&GAMETYPE_WEAPSTAY) && (g_netServer || ud.multimode > 1)) + if ((g_gametypeFlags[ud.coop]&GAMETYPE_WEAPSTAY) && (g_netServer || ud.multimode > 1)) { if (*insptr == 0) { @@ -1639,7 +1639,7 @@ skip_check: insptr++; continue; } - if (vm.playerNum == screenpeek || (GametypeFlags[ud.coop]&GAMETYPE_COOPSOUND) + if (vm.playerNum == screenpeek || (g_gametypeFlags[ud.coop]&GAMETYPE_COOPSOUND) #ifdef SPLITSCREEN_MOD_HACKS || (g_fakeMultiMode==2) #endif @@ -1888,7 +1888,7 @@ skip_check: int const nTag = Gv_GetVarX(*insptr++); int const playerNum = (*insptr++ == g_thisActorVarID) ? vm.playerNum : Gv_GetVarX(*(insptr-1)); - if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted)) + if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) { CON_ERRPRINTF("Invalid player %d\n", playerNum); break; @@ -2214,14 +2214,14 @@ skip_check: int32_t levelNum = ud.volume_number*MAXLEVELS + ud.level_number; const char *pName; - if (EDUKE32_PREDICT_FALSE((unsigned)levelNum >= ARRAY_SIZE(aMapInfo))) + if (EDUKE32_PREDICT_FALSE((unsigned)levelNum >= ARRAY_SIZE(g_mapInfo))) { CON_ERRPRINTF("out of bounds map number (vol=%d, lev=%d)\n", ud.volume_number, ud.level_number); break; } - pName = j == STR_MAPNAME ? aMapInfo[levelNum].name : aMapInfo[levelNum].filename; + pName = j == STR_MAPNAME ? g_mapInfo[levelNum].name : g_mapInfo[levelNum].filename; if (EDUKE32_PREDICT_FALSE(pName == NULL)) { @@ -2231,11 +2231,11 @@ skip_check: break; } - Bstrcpy(apStrings[i], j==STR_MAPNAME ? aMapInfo[levelNum].name : aMapInfo[levelNum].filename); + Bstrcpy(apStrings[i], j==STR_MAPNAME ? g_mapInfo[levelNum].name : g_mapInfo[levelNum].filename); break; } case STR_PLAYERNAME: - if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= (unsigned)playerswhenstarted)) + if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= (unsigned)g_mostConcurrentPlayers)) { CON_ERRPRINTF("Invalid player ID %d\n", vm.playerNum); break; @@ -2247,7 +2247,7 @@ skip_check: Bstrcpy(apStrings[i],tempbuf); break; case STR_GAMETYPE: - Bstrcpy(apStrings[i],GametypeNames[ud.coop]); + Bstrcpy(apStrings[i],g_gametypeNames[ud.coop]); break; case STR_VOLUMENAME: if (EDUKE32_PREDICT_FALSE((unsigned)ud.volume_number >= MAXVOLUMES)) @@ -2255,7 +2255,7 @@ skip_check: CON_ERRPRINTF("invalid volume (%d)\n", ud.volume_number); break; } - Bstrcpy(apStrings[i],EpisodeNames[ud.volume_number]); + Bstrcpy(apStrings[i],g_volumeNames[ud.volume_number]); break; case STR_YOURTIME: Bstrcpy(apStrings[i],G_PrintYourTime()); @@ -3435,7 +3435,7 @@ nullquote: krand() & 2047, (krand() & 127) + 32, -(krand() & 2047), vm.spriteNum, 5); sprite[spriteNum].yvel = - (vm.pSprite->picnum == BLIMP && debrisTile == SCRAP1) ? BlimpSpawnSprites[cnt % 14] : -1; + (vm.pSprite->picnum == BLIMP && debrisTile == SCRAP1) ? g_blimpSpawnItems[cnt % 14] : -1; sprite[spriteNum].pal = vm.pSprite->pal; } insptr++; @@ -3783,7 +3783,7 @@ nullquote: case CON_PALFROM: insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= (unsigned)playerswhenstarted)) + if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= (unsigned)g_mostConcurrentPlayers)) { CON_ERRPRINTF("invalid player ID %d\n", vm.playerNum); insptr += 4; @@ -3976,13 +3976,13 @@ finish_qsprintf: continue; // out of switch } } - Bsprintf(szBuf,"CONLOGVAR: L=%d %s ",g_errorLineNum, aGameVars[lVarID].szLabel); - strcpy(g_szBuf,szBuf); + Bsprintf(tempbuf,"CONLOGVAR: L=%d %s ",g_errorLineNum, aGameVars[lVarID].szLabel); + Bstrcpy(tempbuf,szBuf); if (aGameVars[lVarID].flags & GAMEVAR_READONLY) { Bsprintf(szBuf," (read-only)"); - strcat(g_szBuf,szBuf); + Bstrcat(tempbuf,szBuf); } if (aGameVars[lVarID].flags & GAMEVAR_PERPLAYER) { @@ -3996,10 +3996,10 @@ finish_qsprintf: { Bsprintf(szBuf," (Global)"); } - Bstrcat(g_szBuf,szBuf); - Bsprintf(szBuf," =%d\n", Gv_GetVarX(lVarID)*m); - Bstrcat(g_szBuf,szBuf); - OSD_Printf(OSDTEXT_GREEN "%s",g_szBuf); + Bstrcat(tempbuf, szBuf); + Bsprintf(szBuf, " =%d\n", Gv_GetVarX(lVarID) * m); + Bstrcat(tempbuf, szBuf); + OSD_Printf(OSDTEXT_GREEN "%s", tempbuf); insptr++; continue; } @@ -4428,7 +4428,7 @@ finish_qsprintf: int const lVar1 = *insptr++; int const lVar2 = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted)) + if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) { CON_ERRPRINTF("invalid player ID %d\n", playerNum); @@ -4520,7 +4520,7 @@ finish_qsprintf: tw = (*insptr != g_thisActorVarID) ? Gv_GetVarX(*insptr) : vm.playerNum; insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned)tw >= (unsigned)playerswhenstarted)) + if (EDUKE32_PREDICT_FALSE((unsigned)tw >= (unsigned)g_mostConcurrentPlayers)) { CON_ERRPRINTF("Invalid player ID %d\n", tw); continue; @@ -4534,7 +4534,7 @@ finish_qsprintf: tw = (*insptr != g_thisActorVarID) ? Gv_GetVarX(*insptr) : vm.playerNum; insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned)tw >= (unsigned)playerswhenstarted)) + if (EDUKE32_PREDICT_FALSE((unsigned)tw >= (unsigned)g_mostConcurrentPlayers)) { CON_ERRPRINTF("Invalid player ID %d\n", tw); continue; @@ -5559,7 +5559,7 @@ finish_qsprintf: if (cansee(vm.pSprite->x, vm.pSprite->y, vm.pSprite->z - ZOFFSET6, vm.pSprite->sectnum, pPlayer->pos.x, pPlayer->pos.y, pPlayer->pos.z + ZOFFSET2, sprite[pPlayer->i].sectnum)) { - int32_t numPlayers = playerswhenstarted - 1; + int32_t numPlayers = g_mostConcurrentPlayers - 1; for (; numPlayers >= 0; --numPlayers) { @@ -5921,8 +5921,8 @@ void A_Execute(int spriteNum, int playerNum, int32_t playerDist) void G_SaveMapState(void) { - int32_t levelNum = ud.volume_number * MAXLEVELS + ud.level_number; - map_t *const pMapInfo = &aMapInfo[levelNum]; + int const levelNum = ud.volume_number * MAXLEVELS + ud.level_number; + map_t *const pMapInfo = &g_mapInfo[levelNum]; if (pMapInfo->savedstate == NULL) { @@ -5965,10 +5965,10 @@ void G_SaveMapState(void) #endif Bmemcpy(&save->actor[0],&actor[0],sizeof(actor_t)*MAXSPRITES); - Bmemcpy(&save->g_numCyclers,&g_numCyclers,sizeof(g_numCyclers)); - Bmemcpy(&save->cyclers[0],&cyclers[0],sizeof(cyclers)); + Bmemcpy(&save->g_cyclerCnt,&g_cyclerCnt,sizeof(g_cyclerCnt)); + Bmemcpy(&save->g_cyclers[0],&g_cyclers[0],sizeof(g_cyclers)); Bmemcpy(&save->g_playerSpawnPoints[0],&g_playerSpawnPoints[0],sizeof(g_playerSpawnPoints)); - Bmemcpy(&save->g_numAnimWalls,&g_numAnimWalls,sizeof(g_numAnimWalls)); + Bmemcpy(&save->g_animWallCnt,&g_animWallCnt,sizeof(g_animWallCnt)); Bmemcpy(&save->SpriteDeletionQueue[0],&SpriteDeletionQueue[0],sizeof(SpriteDeletionQueue)); Bmemcpy(&save->g_spriteDeleteQueuePos,&g_spriteDeleteQueuePos,sizeof(g_spriteDeleteQueuePos)); Bmemcpy(&save->animwall[0],&animwall[0],sizeof(animwall)); @@ -5977,25 +5977,25 @@ void G_SaveMapState(void) Bmemcpy(&save->g_mirrorSector[0],&g_mirrorSector[0],sizeof(g_mirrorSector)); Bmemcpy(&save->g_mirrorCount,&g_mirrorCount,sizeof(g_mirrorCount)); Bmemcpy(&save->show2dsector[0],&show2dsector[0],sizeof(show2dsector)); - Bmemcpy(&save->g_numClouds,&g_numClouds,sizeof(g_numClouds)); - Bmemcpy(&save->clouds[0],&clouds[0],sizeof(clouds)); - Bmemcpy(&save->cloudx,&cloudx,sizeof(cloudx)); - Bmemcpy(&save->cloudy,&cloudy,sizeof(cloudy)); + Bmemcpy(&save->g_cloudCnt,&g_cloudCnt,sizeof(g_cloudCnt)); + Bmemcpy(&save->g_cloudSect[0],&g_cloudSect[0],sizeof(g_cloudSect)); + Bmemcpy(&save->g_cloudX,&g_cloudX,sizeof(g_cloudX)); + Bmemcpy(&save->g_cloudY,&g_cloudY,sizeof(g_cloudY)); Bmemcpy(&save->pskyidx,&g_pskyidx,sizeof(g_pskyidx)); - Bmemcpy(&save->animategoal[0],&animategoal[0],sizeof(animategoal)); - Bmemcpy(&save->animatevel[0],&animatevel[0],sizeof(animatevel)); - Bmemcpy(&save->g_animateCount,&g_animateCount,sizeof(g_animateCount)); - Bmemcpy(&save->animatesect[0],&animatesect[0],sizeof(animatesect)); + Bmemcpy(&save->g_animateGoal[0],&g_animateGoal[0],sizeof(g_animateGoal)); + Bmemcpy(&save->g_animateVel[0],&g_animateVel[0],sizeof(g_animateVel)); + Bmemcpy(&save->g_animateCnt,&g_animateCnt,sizeof(g_animateCnt)); + Bmemcpy(&save->g_animateSect[0],&g_animateSect[0],sizeof(g_animateSect)); - G_Util_PtrToIdx(animateptr, g_animateCount, sector, P2I_FWD); - Bmemcpy(&save->animateptr[0],&animateptr[0],sizeof(animateptr)); - G_Util_PtrToIdx(animateptr, g_animateCount, sector, P2I_BACK); + G_Util_PtrToIdx(g_animatePtr, g_animateCnt, sector, P2I_FWD); + Bmemcpy(&save->g_animatePtr[0],&g_animatePtr[0],sizeof(g_animatePtr)); + G_Util_PtrToIdx(g_animatePtr, g_animateCnt, sector, P2I_BACK); { - EDUKE32_STATIC_ASSERT(sizeof(save->animateptr) == sizeof(animateptr)); + EDUKE32_STATIC_ASSERT(sizeof(save->g_animatePtr) == sizeof(g_animatePtr)); } - Bmemcpy(&save->g_numPlayerSprites,&g_numPlayerSprites,sizeof(g_numPlayerSprites)); + Bmemcpy(&save->g_playerSpawnCnt,&g_playerSpawnCnt,sizeof(g_playerSpawnCnt)); Bmemcpy(&save->g_earthquakeTime,&g_earthquakeTime,sizeof(g_earthquakeTime)); Bmemcpy(&save->lockclock,&lockclock,sizeof(lockclock)); Bmemcpy(&save->randomseed,&randomseed,sizeof(randomseed)); @@ -6060,14 +6060,14 @@ void G_SaveMapState(void) void G_RestoreMapState(void) { - int32_t levelNum = ud.volume_number * MAXLEVELS + ud.level_number; - mapstate_t *pSavedState = aMapInfo[levelNum].savedstate; + int const levelNum = ud.volume_number * MAXLEVELS + ud.level_number; + mapstate_t *pSavedState = g_mapInfo[levelNum].savedstate; if (pSavedState != NULL) { int playerHealth[MAXPLAYERS]; - for (bssize_t i=0; ii].extra; pub = NUMPAGES; @@ -6108,10 +6108,10 @@ void G_RestoreMapState(void) #endif Bmemcpy(&actor[0],&pSavedState->actor[0],sizeof(actor_t)*MAXSPRITES); - Bmemcpy(&g_numCyclers,&pSavedState->g_numCyclers,sizeof(g_numCyclers)); - Bmemcpy(&cyclers[0],&pSavedState->cyclers[0],sizeof(cyclers)); + Bmemcpy(&g_cyclerCnt,&pSavedState->g_cyclerCnt,sizeof(g_cyclerCnt)); + Bmemcpy(&g_cyclers[0],&pSavedState->g_cyclers[0],sizeof(g_cyclers)); Bmemcpy(&g_playerSpawnPoints[0],&pSavedState->g_playerSpawnPoints[0],sizeof(g_playerSpawnPoints)); - Bmemcpy(&g_numAnimWalls,&pSavedState->g_numAnimWalls,sizeof(g_numAnimWalls)); + Bmemcpy(&g_animWallCnt,&pSavedState->g_animWallCnt,sizeof(g_animWallCnt)); Bmemcpy(&SpriteDeletionQueue[0],&pSavedState->SpriteDeletionQueue[0],sizeof(SpriteDeletionQueue)); Bmemcpy(&g_spriteDeleteQueuePos,&pSavedState->g_spriteDeleteQueuePos,sizeof(g_spriteDeleteQueuePos)); Bmemcpy(&animwall[0],&pSavedState->animwall[0],sizeof(animwall)); @@ -6120,20 +6120,20 @@ void G_RestoreMapState(void) Bmemcpy(&g_mirrorSector[0],&pSavedState->g_mirrorSector[0],sizeof(g_mirrorSector)); Bmemcpy(&g_mirrorCount,&pSavedState->g_mirrorCount,sizeof(g_mirrorCount)); Bmemcpy(&show2dsector[0],&pSavedState->show2dsector[0],sizeof(show2dsector)); - Bmemcpy(&g_numClouds,&pSavedState->g_numClouds,sizeof(g_numClouds)); - Bmemcpy(&clouds[0],&pSavedState->clouds[0],sizeof(clouds)); - Bmemcpy(&cloudx,&pSavedState->cloudx,sizeof(cloudx)); - Bmemcpy(&cloudy,&pSavedState->cloudy,sizeof(cloudy)); + Bmemcpy(&g_cloudCnt,&pSavedState->g_cloudCnt,sizeof(g_cloudCnt)); + Bmemcpy(&g_cloudSect[0],&pSavedState->g_cloudSect[0],sizeof(g_cloudSect)); + Bmemcpy(&g_cloudX,&pSavedState->g_cloudX,sizeof(g_cloudX)); + Bmemcpy(&g_cloudY,&pSavedState->g_cloudY,sizeof(g_cloudY)); Bmemcpy(&g_pskyidx,&pSavedState->pskyidx,sizeof(g_pskyidx)); - Bmemcpy(&animategoal[0],&pSavedState->animategoal[0],sizeof(animategoal)); - Bmemcpy(&animatevel[0],&pSavedState->animatevel[0],sizeof(animatevel)); - Bmemcpy(&g_animateCount,&pSavedState->g_animateCount,sizeof(g_animateCount)); - Bmemcpy(&animatesect[0],&pSavedState->animatesect[0],sizeof(animatesect)); + Bmemcpy(&g_animateGoal[0],&pSavedState->g_animateGoal[0],sizeof(g_animateGoal)); + Bmemcpy(&g_animateVel[0],&pSavedState->g_animateVel[0],sizeof(g_animateVel)); + Bmemcpy(&g_animateCnt,&pSavedState->g_animateCnt,sizeof(g_animateCnt)); + Bmemcpy(&g_animateSect[0],&pSavedState->g_animateSect[0],sizeof(g_animateSect)); - Bmemcpy(&animateptr[0],&pSavedState->animateptr[0],sizeof(animateptr)); - G_Util_PtrToIdx(animateptr, g_animateCount, sector, P2I_BACK); + Bmemcpy(&g_animatePtr[0],&pSavedState->g_animatePtr[0],sizeof(g_animatePtr)); + G_Util_PtrToIdx(g_animatePtr, g_animateCnt, sector, P2I_BACK); - Bmemcpy(&g_numPlayerSprites,&pSavedState->g_numPlayerSprites,sizeof(g_numPlayerSprites)); + Bmemcpy(&g_playerSpawnCnt,&pSavedState->g_playerSpawnCnt,sizeof(g_playerSpawnCnt)); Bmemcpy(&g_earthquakeTime,&pSavedState->g_earthquakeTime,sizeof(g_earthquakeTime)); Bmemcpy(&lockclock,&pSavedState->lockclock,sizeof(lockclock)); Bmemcpy(&randomseed,&pSavedState->randomseed,sizeof(randomseed)); @@ -6193,7 +6193,7 @@ void G_RestoreMapState(void) g_player[snum].ps->i = i; } - for (bssize_t i=0; ii].extra = playerHealth[i]; if (g_player[myconnectindex].ps->over_shoulder_on != 0) @@ -6207,7 +6207,7 @@ void G_RestoreMapState(void) if (ud.lockout) { - for (bssize_t x=g_numAnimWalls-1; x>=0; x--) + for (bssize_t x=g_animWallCnt-1; x>=0; x--) switch (DYNAMICTILEMAP(wall[animwall[x].wallnum].picnum)) { case FEMPIC1__STATIC: diff --git a/polymer/eduke32/source/gameexec.h b/polymer/eduke32/source/gameexec.h index 48c3a17b4..23f688a12 100644 --- a/polymer/eduke32/source/gameexec.h +++ b/polymer/eduke32/source/gameexec.h @@ -116,6 +116,8 @@ int32_t VM_ResetPlayer2(int32_t snum, int32_t flags); int32_t VM_CheckSquished2(int32_t i, int32_t snum); #endif +void VM_UpdateAnim(int spriteNum, int32_t *pData); + #ifdef __cplusplus } #endif diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c index 632010367..e612a65ab 100644 --- a/polymer/eduke32/source/gamestructures.c +++ b/polymer/eduke32/source/gamestructures.c @@ -161,8 +161,8 @@ int32_t __fastcall VM_GetUserdef(register int32_t labelNum) labelNum = 0; #endif break; - case USERDEFS_GAMETYPEFLAGS: labelNum = GametypeFlags[ud.coop]; break; - case USERDEFS_M_GAMETYPEFLAGS: labelNum = GametypeFlags[ud.m_coop]; break; + case USERDEFS_GAMETYPEFLAGS: labelNum = g_gametypeFlags[ud.coop]; break; + case USERDEFS_M_GAMETYPEFLAGS: labelNum = g_gametypeFlags[ud.m_coop]; break; case USERDEFS_GLOBALFLAGS: labelNum = globalflags; break; case USERDEFS_GLOBALGAMEFLAGS: labelNum = duke3d_globalflags; break; case USERDEFS_VM_PLAYER: labelNum = vm.playerNum; break; @@ -390,7 +390,7 @@ void __fastcall VM_SetActiveProjectile(register int32_t const spriteNum, registe int32_t __fastcall VM_GetPlayer(register int32_t const playerNum, register int32_t labelNum, register int32_t const lParm2) { - if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted)) + if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) { CON_ERRPRINTF("tried to get %s on invalid target player (%d) from spr %d\n", PlayerLabels[labelNum].name,playerNum,vm.spriteNum); @@ -575,7 +575,7 @@ int32_t __fastcall VM_GetPlayer(register int32_t const playerNum, register int32 void __fastcall VM_SetPlayer(register int32_t const playerNum, register int32_t const labelNum, register int32_t const lParm2, register int32_t const iSet) { - if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted)) + if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) { CON_ERRPRINTF("tried to set %s on invalid target player (%d) from spr %d\n", PlayerLabels[labelNum].name,playerNum,vm.spriteNum); @@ -769,7 +769,7 @@ void __fastcall VM_SetPlayer(register int32_t const playerNum, register int32_t int32_t __fastcall VM_GetPlayerInput(register int32_t const playerNum, register int32_t labelNum) { - if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted)) + if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) { CON_ERRPRINTF("VM_GetPlayerInput: invalid target player (%d) %d\n", playerNum,vm.spriteNum); return -1; @@ -793,7 +793,7 @@ int32_t __fastcall VM_GetPlayerInput(register int32_t const playerNum, register void __fastcall VM_SetPlayerInput(register int32_t const playerNum, register int32_t const labelNum, register int32_t const iSet) { - if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted)) + if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) { CON_ERRPRINTF("VM_SetPlayerInput: invalid target player (%d) %d\n", playerNum,vm.spriteNum); return; diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index e682ba22a..10738e2ee 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -205,23 +205,23 @@ int Gv_ReadSave(int32_t kFile) { if (savedstate[i]) { - if (aMapInfo[i].savedstate == NULL) - aMapInfo[i].savedstate = (mapstate_t *)Xaligned_alloc(16, sizeof(mapstate_t)); - if (kdfread(aMapInfo[i].savedstate,sizeof(mapstate_t),1,kFile) != sizeof(mapstate_t)) goto corrupt; + if (g_mapInfo[i].savedstate == NULL) + g_mapInfo[i].savedstate = (mapstate_t *)Xaligned_alloc(16, sizeof(mapstate_t)); + if (kdfread(g_mapInfo[i].savedstate,sizeof(mapstate_t),1,kFile) != sizeof(mapstate_t)) goto corrupt; for (bssize_t j=0; jvars[j]) - aMapInfo[i].savedstate->vars[j] = (intptr_t *)Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t)); - if (kdfread(&aMapInfo[i].savedstate->vars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, kFile) != 1) goto corrupt; + g_mapInfo[i].savedstate->vars[j] = (intptr_t *)Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t)); + if (kdfread(&g_mapInfo[i].savedstate->vars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, kFile) != 1) goto corrupt; } else if (aGameVars[j].flags & GAMEVAR_PERACTOR) { // if (!MapInfo[i].savedstate->vars[j]) - aMapInfo[i].savedstate->vars[j] = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t)); - if (kdfread(&aMapInfo[i].savedstate->vars[j][0],sizeof(intptr_t), MAXSPRITES, kFile) != MAXSPRITES) goto corrupt; + g_mapInfo[i].savedstate->vars[j] = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t)); + if (kdfread(&g_mapInfo[i].savedstate->vars[j][0],sizeof(intptr_t), MAXSPRITES, kFile) != MAXSPRITES) goto corrupt; } } } @@ -299,25 +299,25 @@ void Gv_WriteSave(FILE *fil) dfwrite(apScriptEvents,sizeof(apScriptEvents),1,fil); for (bssize_t i=0; i<(MAXVOLUMES*MAXLEVELS); i++) - if (aMapInfo[i].savedstate != NULL) + if (g_mapInfo[i].savedstate != NULL) savedstate[i] = 1; dfwrite(&savedstate[0],sizeof(savedstate),1,fil); for (bssize_t i=0; i<(MAXVOLUMES*MAXLEVELS); i++) - if (aMapInfo[i].savedstate) + if (g_mapInfo[i].savedstate) { - dfwrite(aMapInfo[i].savedstate,sizeof(mapstate_t),1,fil); + dfwrite(g_mapInfo[i].savedstate,sizeof(mapstate_t),1,fil); for (bssize_t j=0; jvars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, fil); + dfwrite(&g_mapInfo[i].savedstate->vars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, fil); } else if (aGameVars[j].flags & GAMEVAR_PERACTOR) { - dfwrite(&aMapInfo[i].savedstate->vars[j][0],sizeof(intptr_t), MAXSPRITES, fil); + dfwrite(&g_mapInfo[i].savedstate->vars[j][0],sizeof(intptr_t), MAXSPRITES, fil); } } } @@ -391,17 +391,17 @@ int32_t Gv_NewArray(const char *pszLabel, void *pArray, intptr_t arraySize, uint if (EDUKE32_PREDICT_FALSE(g_gameArrayCount >= MAXGAMEARRAYS)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); - initprintf("%s:%d: error: too many arrays!\n",g_szScriptFileName,g_lineNumber); + initprintf("%s:%d: error: too many arrays!\n",g_scriptFileName,g_lineNumber); return 0; } if (EDUKE32_PREDICT_FALSE(Bstrlen(pszLabel) > (MAXARRAYLABEL-1))) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); - initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,pszLabel, MAXARRAYLABEL); + initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",g_scriptFileName,g_lineNumber,pszLabel, MAXARRAYLABEL); return 0; } i = hash_find(&h_arrays,pszLabel); @@ -410,7 +410,7 @@ int32_t Gv_NewArray(const char *pszLabel, void *pArray, intptr_t arraySize, uint { // found it it's a duplicate in error - g_numCompilerWarnings++; + g_warningCnt++; if (aGameArrays[i].flags&GAMEARRAY_TYPE_MASK) { @@ -461,17 +461,17 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags) if (EDUKE32_PREDICT_FALSE(g_gameVarCount >= MAXGAMEVARS)) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); - initprintf("%s:%d: error: too many gamevars!\n",g_szScriptFileName,g_lineNumber); + initprintf("%s:%d: error: too many gamevars!\n",g_scriptFileName,g_lineNumber); return 0; } if (EDUKE32_PREDICT_FALSE(Bstrlen(pszLabel) > (MAXVARLABEL-1))) { - g_numCompilerErrors++; + g_errorCnt++; C_ReportError(-1); - initprintf("%s:%d: error: variable name `%s' exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,pszLabel, MAXVARLABEL); + initprintf("%s:%d: error: variable name `%s' exceeds limit of %d characters.\n",g_scriptFileName,g_lineNumber,pszLabel, MAXVARLABEL); return 0; } @@ -483,13 +483,13 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags) if (EDUKE32_PREDICT_FALSE(aGameVars[gV].flags & (GAMEVAR_PTR_MASK))) { C_ReportError(-1); - initprintf("%s:%d: warning: cannot redefine internal gamevar `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6)); + initprintf("%s:%d: warning: cannot redefine internal gamevar `%s'.\n",g_scriptFileName,g_lineNumber,label+(g_labelCnt<<6)); return 0; } else if (EDUKE32_PREDICT_FALSE(!(aGameVars[gV].flags & GAMEVAR_SYSTEM))) { // it's a duplicate in error - g_numCompilerWarnings++; + g_warningCnt++; C_ReportError(WARNING_DUPLICATEDEFINITION); return 0; } @@ -552,20 +552,20 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags) return 1; } -static int32_t Gv_GetVarIndex(const char *szGameLabel) +static int Gv_GetVarIndex(const char *szGameLabel) { - int32_t gV = hash_find(&h_gamevars,szGameLabel); + int gameVar = hash_find(&h_gamevars,szGameLabel); - if (EDUKE32_PREDICT_FALSE(gV == -1)) + if (EDUKE32_PREDICT_FALSE(gameVar == -1)) { OSD_Printf(OSD_ERROR "Gv_GetVarIndex(): INTERNAL ERROR: couldn't find gamevar %s!\n",szGameLabel); return 0; } - return gV; + return gameVar; } -int32_t __fastcall Gv_GetGameArrayValue(int const id, int index) +int __fastcall Gv_GetGameArrayValue(int const id, int index) { if (aGameArrays[id].flags & GAMEARRAY_STRIDE2) index <<= 1; @@ -583,7 +583,7 @@ int32_t __fastcall Gv_GetGameArrayValue(int const id, int index) return returnValue; } -int32_t __fastcall Gv_GetVar(int gameVar, int spriteNum, int playerNum) +int __fastcall Gv_GetVar(int gameVar, int spriteNum, int playerNum) { if (gameVar == g_thisActorVarID) return spriteNum; @@ -591,55 +591,55 @@ int32_t __fastcall Gv_GetVar(int gameVar, int spriteNum, int playerNum) if (gameVar == MAXGAMEVARS) return *insptr++; - int nNegative = !!(gameVar & (MAXGAMEVARS << 1)); + int invertResult = !!(gameVar & (MAXGAMEVARS << 1)); if (EDUKE32_PREDICT_FALSE((gameVar & ~(MAXGAMEVARS << 1)) >= g_gameVarCount)) goto nastyhacks; gameVar &= (MAXGAMEVARS - 1); - int nReturn, nFlags; - nFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK); + int returnValue, varFlags; + varFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK); - if (nFlags == GAMEVAR_PERACTOR) + if (varFlags == GAMEVAR_PERACTOR) { if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum >= MAXSPRITES)) goto badindex; - nReturn = aGameVars[gameVar].pValues[spriteNum]; + returnValue = aGameVars[gameVar].pValues[spriteNum]; } - else if (!nFlags) nReturn = aGameVars[gameVar].global; - else if (nFlags == GAMEVAR_PERPLAYER) + else if (!varFlags) returnValue = aGameVars[gameVar].global; + else if (varFlags == GAMEVAR_PERPLAYER) { if (EDUKE32_PREDICT_FALSE((unsigned) playerNum >= MAXPLAYERS)) { spriteNum = playerNum; goto badindex; } - nReturn = aGameVars[gameVar].pValues[playerNum]; + returnValue = aGameVars[gameVar].pValues[playerNum]; } - else switch (nFlags) + else switch (varFlags) { - case GAMEVAR_INTPTR: nReturn = *(int32_t *)aGameVars[gameVar].global; break; - case GAMEVAR_SHORTPTR: nReturn = *(int16_t *)aGameVars[gameVar].global; break; - case GAMEVAR_CHARPTR: nReturn = *(char *)aGameVars[gameVar].global; break; - default: EDUKE32_UNREACHABLE_SECTION(nReturn = 0; break); + case GAMEVAR_INTPTR: returnValue = *(int32_t *)aGameVars[gameVar].global; break; + case GAMEVAR_SHORTPTR: returnValue = *(int16_t *)aGameVars[gameVar].global; break; + case GAMEVAR_CHARPTR: returnValue = *(char *)aGameVars[gameVar].global; break; + default: EDUKE32_UNREACHABLE_SECTION(returnValue = 0; break); } - return (nReturn ^ -nNegative) + nNegative; + return (returnValue ^ -invertResult) + invertResult; nastyhacks: if (gameVar & (MAXGAMEVARS << 2)) // array { gameVar &= (MAXGAMEVARS - 1); // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1)); - int nArrayIndex = Gv_GetVar(*insptr++, spriteNum, playerNum); + int const arrayIndex = Gv_GetVar(*insptr++, spriteNum, playerNum); - if (EDUKE32_PREDICT_FALSE((unsigned)nArrayIndex >= (unsigned)aGameArrays[gameVar].size)) + if (EDUKE32_PREDICT_FALSE((unsigned)arrayIndex >= (unsigned)aGameArrays[gameVar].size)) { - spriteNum = nArrayIndex; + spriteNum = arrayIndex; goto badarrayindex; } - nReturn = Gv_GetGameArrayValue(gameVar, nArrayIndex); + returnValue = Gv_GetGameArrayValue(gameVar, arrayIndex); } else if (gameVar&(MAXGAMEVARS<<3)) // struct shortcut vars { @@ -663,7 +663,7 @@ nastyhacks: goto badindex; } - nReturn = VM_GetSprite(arrayIndex, label, arrayIndexVar); + returnValue = VM_GetSprite(arrayIndex, label, arrayIndexVar); break; } case STRUCT_TSPR: @@ -676,7 +676,7 @@ nastyhacks: goto badindex; } - nReturn = VM_GetTsprite(arrayIndex, label); + returnValue = VM_GetTsprite(arrayIndex, label); break; } case STRUCT_THISPROJECTILE: @@ -689,7 +689,7 @@ nastyhacks: goto badindex; } - nReturn = VM_GetActiveProjectile(arrayIndex, label); + returnValue = VM_GetActiveProjectile(arrayIndex, label); break; } @@ -703,7 +703,7 @@ nastyhacks: goto badindex; } - nReturn = VM_GetProjectile(arrayIndex, label); + returnValue = VM_GetProjectile(arrayIndex, label); break; } case STRUCT_TILEDATA: @@ -716,7 +716,7 @@ nastyhacks: goto badindex; } - nReturn = VM_GetTileData(arrayIndex, label); + returnValue = VM_GetTileData(arrayIndex, label); break; } @@ -730,7 +730,7 @@ nastyhacks: goto badindex; } - nReturn = VM_GetPalData(arrayIndex, label); + returnValue = VM_GetPalData(arrayIndex, label); break; } @@ -749,7 +749,7 @@ nastyhacks: goto badindex; } - nReturn = VM_GetPlayer(arrayIndex, label, arrayIndexVar); + returnValue = VM_GetPlayer(arrayIndex, label, arrayIndexVar); break; } case STRUCT_INPUT: @@ -764,13 +764,13 @@ nastyhacks: goto badindex; } - nReturn = VM_GetPlayerInput(arrayIndex, label); + returnValue = VM_GetPlayerInput(arrayIndex, label); break; } case STRUCT_ACTORVAR: case STRUCT_PLAYERVAR: - nReturn = Gv_GetVar(*insptr++, arrayIndex, playerNum); + returnValue = Gv_GetVar(*insptr++, arrayIndex, playerNum); break; case STRUCT_SECTOR: @@ -781,7 +781,7 @@ nastyhacks: insptr++; goto badindex; } - nReturn = VM_GetSector(arrayIndex, *insptr++); + returnValue = VM_GetSector(arrayIndex, *insptr++); break; case STRUCT_WALL: @@ -791,11 +791,11 @@ nastyhacks: insptr++; goto badindex; } - nReturn = VM_GetWall(arrayIndex, *insptr++); + returnValue = VM_GetWall(arrayIndex, *insptr++); break; case STRUCT_USERDEF: - nReturn = VM_GetUserdef(*insptr++); + returnValue = VM_GetUserdef(*insptr++); break; default: @@ -808,7 +808,7 @@ nastyhacks: return -1; } - return (nReturn ^ -nNegative) + nNegative; + return (returnValue ^ -invertResult) + invertResult; badarrayindex: CON_ERRPRINTF("Gv_GetVar(): invalid array index (%s[%d])\n", aGameArrays[gameVar].szLabel,spriteNum); @@ -819,31 +819,31 @@ badindex: return -1; } -void __fastcall Gv_SetVar(int const gameVar, int32_t const nValue, int const spriteNum, int const playerNum) +void __fastcall Gv_SetVar(int const gameVar, int const newValue, int const spriteNum, int const playerNum) { - int const nFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); + int const varFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); if (EDUKE32_PREDICT_FALSE((unsigned)gameVar >= (unsigned)g_gameVarCount)) goto badvarid; - if (!nFlags) aGameVars[gameVar].global=nValue; - else if (nFlags == GAMEVAR_PERPLAYER) + if (!varFlags) aGameVars[gameVar].global=newValue; + else if (varFlags == GAMEVAR_PERPLAYER) { if (EDUKE32_PREDICT_FALSE((unsigned) playerNum > MAXPLAYERS-1)) goto badindex; // for the current player - aGameVars[gameVar].pValues[playerNum]=nValue; + aGameVars[gameVar].pValues[playerNum]=newValue; } - else if (nFlags == GAMEVAR_PERACTOR) + else if (varFlags == GAMEVAR_PERACTOR) { if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum > MAXSPRITES-1)) goto badindex; - aGameVars[gameVar].pValues[spriteNum]=nValue; + aGameVars[gameVar].pValues[spriteNum]=newValue; } else { - switch (nFlags) + switch (varFlags) { - case GAMEVAR_INTPTR: *((int32_t *)aGameVars[gameVar].global) = (int32_t)nValue; break; - case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[gameVar].global) = (int16_t)nValue; break; - case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[gameVar].global) = (uint8_t)nValue; break; + case GAMEVAR_INTPTR: *((int32_t *)aGameVars[gameVar].global) = (int32_t)newValue; break; + case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[gameVar].global) = (int16_t)newValue; break; + case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[gameVar].global) = (uint8_t)newValue; break; } } return; @@ -882,31 +882,31 @@ static const char *gvxerrs[] = { "Gv_GetVarX(): invalid pal ID", }; -int32_t __fastcall Gv_GetSpecialVarX(int gameVar) +int __fastcall Gv_GetSpecialVarX(int gameVar) { - int nReturn = -1; + int returnValue = -1; if (gameVar & (MAXGAMEVARS << 2)) // array { - int const nArrayIndex = Gv_GetVarX(*insptr++); + int const arrayIndex = Gv_GetVarX(*insptr++); gameVar &= (MAXGAMEVARS - 1); // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1)); - int const nArraySize = - (aGameArrays[gameVar].flags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[gameVar].size) : aGameArrays[gameVar].size; + int const arraySiz + = (aGameArrays[gameVar].flags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[gameVar].size) : aGameArrays[gameVar].size; - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= (unsigned) nArraySize)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= (unsigned) arraySiz)) { - CON_ERRPRINTF("%s %s[%d]\n", gvxerrs[GVX_BADINDEX], aGameArrays[gameVar].szLabel, nArrayIndex); + CON_ERRPRINTF("%s %s[%d]\n", gvxerrs[GVX_BADINDEX], aGameArrays[gameVar].szLabel, arrayIndex); return -1; } - nReturn = Gv_GetGameArrayValue(gameVar, nArrayIndex); + returnValue = Gv_GetGameArrayValue(gameVar, arrayIndex); } else if (gameVar & (MAXGAMEVARS << 3)) // struct shortcut vars { - int nArrayIndexVar = *insptr++; - int nArrayIndex = Gv_GetVarX(nArrayIndexVar); + int arrayIndexVar = *insptr++; + int arrayIndex = Gv_GetVarX(arrayIndexVar); switch ((gameVar & (MAXGAMEVARS - 1)) - g_structVarIDs) { @@ -914,45 +914,44 @@ int32_t __fastcall Gv_GetSpecialVarX(int gameVar) { int const labelNum = *insptr++; - nArrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[labelNum].flags & LABEL_HASPARM2)) ? - Gv_GetVarX(*insptr++) : 0; + arrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[labelNum].flags & LABEL_HASPARM2)) ? Gv_GetVarX(*insptr++) : 0; - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXSPRITES)) { - gameVar = nArrayIndex; + gameVar = arrayIndex; CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], gameVar); return -1; } - nReturn = VM_GetSprite(nArrayIndex, labelNum, nArrayIndexVar); + returnValue = VM_GetSprite(arrayIndex, labelNum, arrayIndexVar); break; } case STRUCT_TSPR: { int const labelNum = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXSPRITES)) { - gameVar = nArrayIndex; + gameVar = arrayIndex; CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], gameVar); return -1; } - nReturn = VM_GetTsprite(nArrayIndex, labelNum); + returnValue = VM_GetTsprite(arrayIndex, labelNum); break; } case STRUCT_THISPROJECTILE: { int const labelNum = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXSPRITES)) { - gameVar = nArrayIndex; + gameVar = arrayIndex; CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], gameVar); return -1; } - nReturn = VM_GetActiveProjectile(nArrayIndex, labelNum); + returnValue = VM_GetActiveProjectile(arrayIndex, labelNum); break; } @@ -960,28 +959,28 @@ int32_t __fastcall Gv_GetSpecialVarX(int gameVar) { int const labelNum = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXTILES)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXTILES)) { - gameVar = nArrayIndex; + gameVar = arrayIndex; CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], gameVar); return -1; } - nReturn = VM_GetProjectile(nArrayIndex, labelNum); + returnValue = VM_GetProjectile(arrayIndex, labelNum); break; } case STRUCT_TILEDATA: { int const labelNum = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXTILES)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXTILES)) { - gameVar = nArrayIndex; + gameVar = arrayIndex; CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], gameVar); return -1; } - nReturn = VM_GetTileData(nArrayIndex, labelNum); + returnValue = VM_GetTileData(arrayIndex, labelNum); break; } @@ -989,14 +988,14 @@ int32_t __fastcall Gv_GetSpecialVarX(int gameVar) { int const labelNum = *insptr++; - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPALOOKUPS)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXPALOOKUPS)) { - gameVar = nArrayIndex; + gameVar = arrayIndex; CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPAL], gameVar); return -1; } - nReturn = VM_GetPalData(nArrayIndex, labelNum); + returnValue = VM_GetPalData(arrayIndex, labelNum); break; } @@ -1004,82 +1003,82 @@ int32_t __fastcall Gv_GetSpecialVarX(int gameVar) { int const labelNum = *insptr++; - if (nArrayIndexVar == g_thisActorVarID) - nArrayIndex = vm.playerNum; + if (arrayIndexVar == g_thisActorVarID) + arrayIndex = vm.playerNum; - nArrayIndexVar = (EDUKE32_PREDICT_FALSE(PlayerLabels[labelNum].flags & LABEL_HASPARM2)) ? + arrayIndexVar = (EDUKE32_PREDICT_FALSE(PlayerLabels[labelNum].flags & LABEL_HASPARM2)) ? Gv_GetVarX(*insptr++) : 0; - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPLAYERS)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXPLAYERS)) { - gameVar = nArrayIndex; + gameVar = arrayIndex; CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], gameVar); return -1; } - nReturn = VM_GetPlayer(nArrayIndex, labelNum, nArrayIndexVar); + returnValue = VM_GetPlayer(arrayIndex, labelNum, arrayIndexVar); break; } case STRUCT_INPUT: { int const labelNum = *insptr++; - if (nArrayIndexVar == g_thisActorVarID) - nArrayIndex = vm.playerNum; + if (arrayIndexVar == g_thisActorVarID) + arrayIndex = vm.playerNum; - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPLAYERS)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXPLAYERS)) { - gameVar = nArrayIndex; + gameVar = arrayIndex; CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], gameVar); return -1; } - nReturn = VM_GetPlayerInput(nArrayIndex, labelNum); + returnValue = VM_GetPlayerInput(arrayIndex, labelNum); break; } case STRUCT_ACTORVAR: case STRUCT_PLAYERVAR: - nReturn = Gv_GetVar(*insptr++, nArrayIndex, vm.playerNum); + returnValue = Gv_GetVar(*insptr++, arrayIndex, vm.playerNum); break; case STRUCT_SECTOR: - if (nArrayIndexVar == g_thisActorVarID) - nArrayIndex = sprite[vm.spriteNum].sectnum; + if (arrayIndexVar == g_thisActorVarID) + arrayIndex = sprite[vm.spriteNum].sectnum; - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSECTORS)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXSECTORS)) { - gameVar = nArrayIndex; + gameVar = arrayIndex; insptr++; CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSECTOR], gameVar); return -1; } - nReturn = VM_GetSector(nArrayIndex, *insptr++); + returnValue = VM_GetSector(arrayIndex, *insptr++); break; case STRUCT_WALL: - if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXWALLS)) + if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXWALLS)) { - gameVar = nArrayIndex; + gameVar = arrayIndex; insptr++; CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADWALL], gameVar); return -1; } - nReturn = VM_GetWall(nArrayIndex, *insptr++); + returnValue = VM_GetWall(arrayIndex, *insptr++); break; case STRUCT_USERDEF: - nReturn = VM_GetUserdef(*insptr++); + returnValue = VM_GetUserdef(*insptr++); break; default: EDUKE32_UNREACHABLE_SECTION(return -1); } } - return nReturn; + return returnValue; } -int32_t __fastcall Gv_GetVarX(int gameVar) +int __fastcall Gv_GetVarX(int gameVar) { if (gameVar == g_thisActorVarID) return vm.spriteNum; @@ -1087,35 +1086,35 @@ int32_t __fastcall Gv_GetVarX(int gameVar) if (gameVar == MAXGAMEVARS) return *insptr++; - int const nNegative = !!(gameVar & (MAXGAMEVARS << 1)); - int nReturn = -1; + int const invertResult = !!(gameVar & (MAXGAMEVARS << 1)); + int returnValue = -1; - if (EDUKE32_PREDICT_FALSE(gameVar >= g_gameVarCount && nNegative == 0)) - nReturn = Gv_GetSpecialVarX(gameVar); + if (EDUKE32_PREDICT_FALSE(gameVar >= g_gameVarCount && invertResult == 0)) + returnValue = Gv_GetSpecialVarX(gameVar); else { gameVar &= MAXGAMEVARS-1; - int const nFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); + int const varFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); - if (!nFlags) nReturn = aGameVars[gameVar].global; - else if (nFlags == GAMEVAR_PERPLAYER) + if (!varFlags) returnValue = aGameVars[gameVar].global; + else if (varFlags == GAMEVAR_PERPLAYER) { if (EDUKE32_PREDICT_FALSE((unsigned) vm.playerNum >= MAXPLAYERS)) goto perr; - nReturn = aGameVars[gameVar].pValues[vm.playerNum]; + returnValue = aGameVars[gameVar].pValues[vm.playerNum]; } - else if (nFlags == GAMEVAR_PERACTOR) - nReturn = aGameVars[gameVar].pValues[vm.spriteNum]; - else switch (nFlags) + else if (varFlags == GAMEVAR_PERACTOR) + returnValue = aGameVars[gameVar].pValues[vm.spriteNum]; + else switch (varFlags) { - case GAMEVAR_INTPTR: nReturn = (*((int32_t *)aGameVars[gameVar].global)); break; - case GAMEVAR_SHORTPTR: nReturn = (*((int16_t *)aGameVars[gameVar].global)); break; - case GAMEVAR_CHARPTR: nReturn = (*((uint8_t *)aGameVars[gameVar].global)); break; + case GAMEVAR_INTPTR: returnValue = (*((int32_t *)aGameVars[gameVar].global)); break; + case GAMEVAR_SHORTPTR: returnValue = (*((int16_t *)aGameVars[gameVar].global)); break; + case GAMEVAR_CHARPTR: returnValue = (*((uint8_t *)aGameVars[gameVar].global)); break; } } - return (nReturn ^ -nNegative) + nNegative; + return (returnValue ^ -invertResult) + invertResult; perr: CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], vm.playerNum); @@ -1140,9 +1139,9 @@ void __fastcall Gv_GetManyVars(int const count, int32_t * const rv) continue; } - int const nNegative = !!(gameVar & (MAXGAMEVARS << 1)); + int const invertResult = !!(gameVar & (MAXGAMEVARS << 1)); - if (EDUKE32_PREDICT_FALSE(gameVar >= g_gameVarCount && nNegative == 0)) + if (EDUKE32_PREDICT_FALSE(gameVar >= g_gameVarCount && invertResult == 0)) { rv[j] = Gv_GetSpecialVarX(gameVar); continue; @@ -1150,28 +1149,28 @@ void __fastcall Gv_GetManyVars(int const count, int32_t * const rv) gameVar &= MAXGAMEVARS - 1; - int const nFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK); - int nValue = aGameVars[gameVar].global; + int const varFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK); + int value = aGameVars[gameVar].global; - if (nFlags == GAMEVAR_PERPLAYER) + if (varFlags == GAMEVAR_PERPLAYER) { if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS)) goto perr; - nValue = aGameVars[gameVar].pValues[vm.playerNum]; + value = aGameVars[gameVar].pValues[vm.playerNum]; } - else if (nFlags == GAMEVAR_PERACTOR) - nValue = aGameVars[gameVar].pValues[vm.spriteNum]; + else if (varFlags == GAMEVAR_PERACTOR) + value = aGameVars[gameVar].pValues[vm.spriteNum]; else { - switch (nFlags) + switch (varFlags) { - case GAMEVAR_INTPTR: nValue = (*((int32_t *)aGameVars[gameVar].global)); break; - case GAMEVAR_SHORTPTR: nValue = (*((int16_t *)aGameVars[gameVar].global)); break; - case GAMEVAR_CHARPTR: nValue = (*((uint8_t *)aGameVars[gameVar].global)); break; + case GAMEVAR_INTPTR: value = (*((int32_t *)aGameVars[gameVar].global)); break; + case GAMEVAR_SHORTPTR: value = (*((int16_t *)aGameVars[gameVar].global)); break; + case GAMEVAR_CHARPTR: value = (*((uint8_t *)aGameVars[gameVar].global)); break; } } - rv[j] = (nValue ^ -nNegative) + nNegative; + rv[j] = (value ^ -invertResult) + invertResult; continue; perr: @@ -1179,26 +1178,26 @@ void __fastcall Gv_GetManyVars(int const count, int32_t * const rv) } } -void __fastcall Gv_SetVarX(int const gameVar, int32_t const nValue) +void __fastcall Gv_SetVarX(int const gameVar, int const newValue) { - int const nFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); + int const varFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK); - if (!nFlags) aGameVars[gameVar].global = nValue; - else if (nFlags == GAMEVAR_PERPLAYER) + if (!varFlags) aGameVars[gameVar].global = newValue; + else if (varFlags == GAMEVAR_PERPLAYER) { if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS)) goto badindex; - aGameVars[gameVar].pValues[vm.playerNum] = nValue; + aGameVars[gameVar].pValues[vm.playerNum] = newValue; } - else if (nFlags == GAMEVAR_PERACTOR) + else if (varFlags == GAMEVAR_PERACTOR) { if (EDUKE32_PREDICT_FALSE((unsigned)vm.spriteNum >= MAXSPRITES)) goto badindex; - aGameVars[gameVar].pValues[vm.spriteNum] = nValue; + aGameVars[gameVar].pValues[vm.spriteNum] = newValue; } - else switch (nFlags) + else switch (varFlags) { - case GAMEVAR_INTPTR: *((int32_t *)aGameVars[gameVar].global) = (int32_t)nValue; break; - case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[gameVar].global) = (int16_t)nValue; break; - case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[gameVar].global) = (uint8_t)nValue; break; + case GAMEVAR_INTPTR: *((int32_t *)aGameVars[gameVar].global) = (int32_t)newValue; break; + case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[gameVar].global) = (int16_t)newValue; break; + case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[gameVar].global) = (uint8_t)newValue; break; } return; @@ -1209,10 +1208,10 @@ badindex: aGameVars[gameVar].szLabel); } -int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t const nDefault, int const spriteNum, int const playerNum) +int Gv_GetVarByLabel(const char *szGameLabel, int const defaultValue, int const spriteNum, int const playerNum) { int const gameVar = hash_find(&h_gamevars, szGameLabel); - return EDUKE32_PREDICT_FALSE(gameVar < 0) ? nDefault : Gv_GetVar(gameVar, spriteNum, playerNum); + return EDUKE32_PREDICT_FALSE(gameVar < 0) ? defaultValue : Gv_GetVar(gameVar, spriteNum, playerNum); } static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel) @@ -1643,8 +1642,8 @@ static void Gv_AddSystemVars(void) Gv_NewVar("viewingrange",(intptr_t)&viewingrange, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); Gv_NewVar("yxaspect",(intptr_t)&yxaspect, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); Gv_NewVar("gravitationalconstant",(intptr_t)&g_spriteGravity, GAMEVAR_SYSTEM | GAMEVAR_INTPTR); - Gv_NewVar("gametype_flags",(intptr_t)&GametypeFlags[ud.coop], GAMEVAR_SYSTEM | GAMEVAR_INTPTR); - Gv_NewVar("framerate",(intptr_t)&g_currentFrameRate, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); + Gv_NewVar("gametype_flags",(intptr_t)&g_gametypeFlags[ud.coop], GAMEVAR_SYSTEM | GAMEVAR_INTPTR); + Gv_NewVar("framerate",(intptr_t)&g_frameRate, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); Gv_NewVar("CLIPMASK0", CLIPMASK0, GAMEVAR_SYSTEM|GAMEVAR_READONLY); Gv_NewVar("CLIPMASK1", CLIPMASK1, GAMEVAR_SYSTEM|GAMEVAR_READONLY); @@ -1797,8 +1796,8 @@ void Gv_RefreshPointers(void) aGameVars[Gv_GetVarIndex("current_menu")].global = (intptr_t)&g_currentMenu; aGameVars[Gv_GetVarIndex("viewingrange")].global = (intptr_t)&viewingrange; aGameVars[Gv_GetVarIndex("yxaspect")].global = (intptr_t)&yxaspect; - aGameVars[Gv_GetVarIndex("gametype_flags")].global = (intptr_t)&GametypeFlags[ud.coop]; - aGameVars[Gv_GetVarIndex("framerate")].global = (intptr_t)&g_currentFrameRate; + aGameVars[Gv_GetVarIndex("gametype_flags")].global = (intptr_t)&g_gametypeFlags[ud.coop]; + aGameVars[Gv_GetVarIndex("framerate")].global = (intptr_t)&g_frameRate; aGameVars[Gv_GetVarIndex("gravitationalconstant")].global = (intptr_t)&g_spriteGravity; diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index 1cd369e5b..f22918842 100644 --- a/polymer/eduke32/source/global.c +++ b/polymer/eduke32/source/global.c @@ -32,19 +32,13 @@ const char *s_buildDate = "20120522"; extern "C" { #endif -// JBF: g_spriteGravity modified to default to Atomic ed. default when using 1.3d CONs -int32_t g_spriteGravity=176; +char g_volumeNames[MAXVOLUMES][33] = { "L.A. Meltdown", "Lunar Apocalypse", "Shrapnel City" }; +int32_t g_volumeFlags[MAXVOLUMES]; // all initialize to zero +char g_skillNames[MAXSKILLS][33] = { "Piece Of Cake", "Let's Rock", "Come Get Some", "Damn I'm Good" }; +char g_gametypeNames[MAXGAMETYPES][33] += { "DukeMatch (Spawn)", "Cooperative Play", "DukeMatch (No Spawn)", "Team DM (Spawn)", "Team DM (No Spawn)" }; -int16_t g_deleteQueueSize = 64; - -char EpisodeNames[MAXVOLUMES][33] = { "L.A. Meltdown", "Lunar Apocalypse", "Shrapnel City" }; -int32_t EpisodeFlags[MAXVOLUMES]; // all initialize to zero - -char SkillNames[MAXSKILLS][33] = { "Piece Of Cake", "Let's Rock", "Come Get Some", "Damn I'm Good" }; - -char GametypeNames[MAXGAMETYPES][33] = { "DukeMatch (Spawn)", "Cooperative Play", "DukeMatch (No Spawn)", "Team DM (Spawn)", "Team DM (No Spawn)" }; - -int32_t GametypeFlags[MAXGAMETYPES] = +int32_t g_gametypeFlags[MAXGAMETYPES] = { /*4+*/8+16+1024+2048+16384, 1+2+32+64+128+256+512+4096+8192+32768, @@ -52,25 +46,27 @@ int32_t GametypeFlags[MAXGAMETYPES] = /*4+*/8+16+1024+2048+16384+65536+131072, 2+/*4+*/8+16+16384+65536+131072 }; -char g_numGametypes = 5; -char g_numVolumes = 3; +int g_actorRespawnTime = 768; +int g_bouncemineRadius = 2500; +int g_deleteQueueSize = 64; +int g_itemRespawnTime = 768; +int g_lastSaveSlot = -1; +int g_morterRadius = 2500; +int g_numFreezeBounces = 3; +int g_gametypeCnt = 5; +int g_volumeCnt = 3; +int g_pipebombRadius = 2500; +int g_playerFriction = 0xCFD0; +int g_rpgRadius = 1780; +int g_scriptSize = 1048576; +int g_seenineRadius = 2048; +int g_shrinkerRadius = 650; +int g_spriteGravity = 176; +int g_timerTicsPerSecond = TICRATE; +int g_tripbombRadius = 3880; -int32_t g_timerTicsPerSecond = TICRATE; - -int32_t g_actorRespawnTime = 768; -int32_t g_itemRespawnTime = 768; -int32_t g_rpgBlastRadius = 1780; -int32_t g_pipebombBlastRadius = 2500; -int32_t g_shrinkerBlastRadius = 650; -int32_t g_tripbombBlastRadius = 3880; -int32_t g_morterBlastRadius = 2500; -int32_t g_bouncemineBlastRadius = 2500; -int32_t g_seenineBlastRadius = 2048; - -int32_t g_scriptSize = 1048576; - -int16_t BlimpSpawnSprites[15] = +int16_t g_blimpSpawnItems[15] = { RPGSPRITE__STATIC, CHAINGUNSPRITE__STATIC, @@ -89,15 +85,9 @@ int16_t BlimpSpawnSprites[15] = FREEZEAMMO__STATIC }; -int32_t g_playerFriction = 0xCFD0; +char CheatKeys[2] = { sc_D, sc_N }; -int32_t g_numFreezeBounces = 3; - -int32_t g_lastSaveSlot = -1; - -char CheatKeys[2] = { sc_D, sc_N }; - -char setupfilename[BMAX_PATH] = SETUPFILENAME; +char g_setupFileName[BMAX_PATH] = SETUPFILENAME; #ifdef __cplusplus } diff --git a/polymer/eduke32/source/global.h b/polymer/eduke32/source/global.h index 0cfb577d4..e2ef5751e 100644 --- a/polymer/eduke32/source/global.h +++ b/polymer/eduke32/source/global.h @@ -39,7 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "compat.h" #include "build.h" -G_EXTERN int32_t g_numInterpolations; +G_EXTERN int32_t g_interpolationCnt; G_EXTERN int32_t g_interpolationLock; G_EXTERN int32_t oldipos[MAXINTERPOLATIONS]; G_EXTERN int32_t *curipos[MAXINTERPOLATIONS]; @@ -73,7 +73,7 @@ G_EXTERN char *apStrings[MAXQUOTES],*apXStrings[MAXQUOTES]; G_EXTERN char *label; G_EXTERN int32_t g_musicIndex; G_EXTERN char g_loadFromGroupOnly; -G_EXTERN char g_numSkills; +G_EXTERN char g_skillCnt; G_EXTERN char pus,pub; G_EXTERN char ready2send; #define MAXPLAYERNAME 32 @@ -83,41 +83,61 @@ G_EXTERN char tempbuf[MAXSECTORS<<1],packbuf[PACKBUF_SIZE],menutextbuf[128],buf[ #define TYPEBUFSIZE 141 G_EXTERN char typebuf[TYPEBUFSIZE]; -G_EXTERN input_t avg; + G_EXTERN input_t localInput; G_EXTERN input_t recsync[RECSYNCBUFSIZ]; -G_EXTERN int16_t SpriteDeletionQueue[1024],g_spriteDeleteQueuePos; -G_EXTERN int16_t animatesect[MAXANIMATES]; -G_EXTERN int16_t g_curViewscreen; -G_EXTERN int16_t cyclers[MAXCYCLERS][6],g_numCyclers; -G_EXTERN int16_t g_globalRandom; -G_EXTERN int16_t g_mirrorWall[64],g_mirrorSector[64],g_mirrorCount; -G_EXTERN int16_t g_numAnimWalls; -G_EXTERN int16_t g_numClouds,clouds[256],cloudx,cloudy; -G_EXTERN int32_t *animateptr[MAXANIMATES]; -G_EXTERN int32_t animategoal[MAXANIMATES],animatevel[MAXANIMATES],g_animateCount; -G_EXTERN int32_t cloudtotalclock; -G_EXTERN int32_t g_currentFrameRate; -G_EXTERN int32_t g_damageCameras,g_freezerSelfDamage; -G_EXTERN int32_t g_doQuickSave; -G_EXTERN uint16_t g_earthquakeTime; -G_EXTERN int32_t g_gameQuit; -G_EXTERN int32_t g_impactDamage,g_maxPlayerHealth; -G_EXTERN int32_t g_musicSize; -G_EXTERN int32_t g_numLabels,g_numDefaultLabels; -G_EXTERN int32_t g_scriptDebug; -G_EXTERN int32_t g_showShareware; -G_EXTERN int8_t g_numPlayerSprites; -G_EXTERN int32_t g_tripbombLaserMode; -G_EXTERN vec2_t g_origins[MAXANIMPOINTS]; -G_EXTERN int32_t neartaghitdist,lockclock,g_startArmorAmount; -G_EXTERN int32_t playerswhenstarted; -G_EXTERN int32_t screenpeek; + +G_EXTERN int g_animWallCnt; +G_EXTERN int g_animateCnt; +G_EXTERN int g_cloudCnt; +G_EXTERN int g_curViewscreen; +G_EXTERN int g_frameRate; +G_EXTERN int g_cyclerCnt; +G_EXTERN int g_damageCameras; +G_EXTERN int g_defaultLabelCnt; +G_EXTERN int g_doQuickSave; +G_EXTERN int g_earthquakeTime; +G_EXTERN int g_freezerSelfDamage; +G_EXTERN int g_gameQuit; +G_EXTERN int g_globalRandom; +G_EXTERN int g_impactDamage; +G_EXTERN int g_labelCnt; +G_EXTERN int g_maxPlayerHealth; +G_EXTERN int g_mirrorCount; +G_EXTERN int g_mostConcurrentPlayers; +G_EXTERN int g_musicSize; +G_EXTERN int g_playerSpawnCnt; +G_EXTERN int g_scriptDebug; +G_EXTERN int g_showShareware; +G_EXTERN int g_spriteDeleteQueuePos; +G_EXTERN int g_startArmorAmount; +G_EXTERN int g_tripbombLaserMode; +G_EXTERN int screenpeek; + +G_EXTERN int16_t g_animateSect[MAXANIMATES]; +G_EXTERN int32_t *g_animatePtr[MAXANIMATES]; +G_EXTERN int32_t g_animateGoal[MAXANIMATES]; +G_EXTERN int32_t g_animateVel[MAXANIMATES]; + +G_EXTERN int16_t g_cloudSect[256]; +G_EXTERN int16_t g_cloudX; +G_EXTERN int16_t g_cloudY; +G_EXTERN int32_t g_cloudClock; + +G_EXTERN int16_t SpriteDeletionQueue[1024]; +G_EXTERN int16_t g_cyclers[MAXCYCLERS][6]; +G_EXTERN int16_t g_mirrorSector[64]; +G_EXTERN int16_t g_mirrorWall[64]; +G_EXTERN int32_t *labelcode; +G_EXTERN int32_t *labeltype; +G_EXTERN int32_t lockclock; G_EXTERN int32_t ototalclock; -G_EXTERN intptr_t *g_scriptPtr; -G_EXTERN int32_t *labelcode,*labeltype; + G_EXTERN intptr_t *apScript; -G_EXTERN map_t aMapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" and "loading" music +G_EXTERN intptr_t *g_scriptPtr; + +G_EXTERN map_t g_mapInfo[(MAXVOLUMES + 1) * MAXLEVELS]; // +1 volume for "intro", "briefing" and "loading" music +G_EXTERN vec2_t g_origins[MAXANIMPOINTS]; // XXX: I think this pragma pack is meaningless here. // MSDN (https://msdn.microsoft.com/en-us/library/2e70t5y1%28VS.80%29.aspx) says: @@ -134,43 +154,46 @@ G_EXTERN playerspawn_t g_playerSpawnPoints[MAXPLAYERS]; G_EXTERN input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS]; #pragma pack(pop) +G_EXTERN char g_soundlocks[MAXSOUNDS]; +G_EXTERN int g_noEnemies; +G_EXTERN int g_restorePalette; +G_EXTERN int g_screenCapture; G_EXTERN projectile_t SpriteProjectile[MAXSPRITES]; G_EXTERN sound_t g_sounds[MAXSOUNDS]; G_EXTERN uint32_t everyothertime; G_EXTERN uint32_t g_moveThingsCount; -G_EXTERN char g_soundlocks[MAXSOUNDS]; -G_EXTERN int32_t g_restorePalette; -G_EXTERN int32_t g_screenCapture; -G_EXTERN int32_t g_noEnemies; #ifndef global_c_ +extern char CheatKeys[2]; +extern char g_gametypeNames[MAXGAMETYPES][33]; +extern char g_setupFileName[BMAX_PATH]; +extern char g_skillNames[MAXSKILLS][33]; +extern char g_volumeNames[MAXVOLUMES][33]; + +extern int g_actorRespawnTime; +extern int g_bouncemineRadius; +extern int g_deleteQueueSize; +extern int g_gametypeCnt; +extern int g_itemRespawnTime; +extern int g_lastSaveSlot; +extern int g_morterRadius; +extern int g_numFreezeBounces; +extern int g_pipebombRadius; +extern int g_playerFriction; +extern int g_rpgRadius; +extern int g_scriptSize; +extern int g_seenineRadius; +extern int g_shrinkerRadius; +extern int g_spriteGravity; +extern int g_timerTicsPerSecond; +extern int g_tripbombRadius; +extern int g_volumeCnt; + +extern int16_t g_blimpSpawnItems[15]; +extern int32_t g_gametypeFlags[MAXGAMETYPES]; +extern int32_t g_volumeFlags[MAXVOLUMES]; + extern const char *s_buildDate; -extern int32_t g_spriteGravity; -extern int16_t g_deleteQueueSize; -extern char EpisodeNames[MAXVOLUMES][33]; -extern int32_t EpisodeFlags[MAXVOLUMES]; -extern char SkillNames[MAXSKILLS][33]; -extern char GametypeNames[MAXGAMETYPES][33]; -extern int32_t GametypeFlags[MAXGAMETYPES]; -extern char g_numGametypes; -extern char g_numVolumes; -extern int32_t g_timerTicsPerSecond; -extern int32_t g_actorRespawnTime; -extern int32_t g_itemRespawnTime; -extern int32_t g_scriptSize; -extern int16_t BlimpSpawnSprites[15]; -extern int32_t g_playerFriction; -extern int32_t g_numFreezeBounces; -extern int32_t g_lastSaveSlot; -extern int32_t g_rpgBlastRadius; -extern int32_t g_pipebombBlastRadius; -extern int32_t g_tripbombBlastRadius; -extern int32_t g_shrinkerBlastRadius; -extern int32_t g_morterBlastRadius; -extern int32_t g_bouncemineBlastRadius; -extern int32_t g_seenineBlastRadius; -extern char CheatKeys[2]; -extern char setupfilename[BMAX_PATH]; #endif enum @@ -190,12 +213,12 @@ EXTERN_INLINE_HEADER void G_RestoreInterpolations(void); EXTERN_INLINE void G_UpdateInterpolations(void) //Stick at beginning of G_DoMoveThings { - for (bssize_t i=g_numInterpolations-1; i>=0; i--) oldipos[i] = *curipos[i]; + for (bssize_t i=g_interpolationCnt-1; i>=0; i--) oldipos[i] = *curipos[i]; } EXTERN_INLINE void G_RestoreInterpolations(void) //Stick at end of drawscreen { - int32_t i=g_numInterpolations-1; + int32_t i=g_interpolationCnt-1; if (--g_interpolationLock) return; diff --git a/polymer/eduke32/source/inv.h b/polymer/eduke32/source/inv.h index f731e5c5d..db1741d56 100644 --- a/polymer/eduke32/source/inv.h +++ b/polymer/eduke32/source/inv.h @@ -22,7 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #pragma once -enum dukeinv_t { +enum dukeinv_t +{ GET_STEROIDS, // 0 GET_SHIELD, GET_SCUBA, @@ -38,7 +39,8 @@ enum dukeinv_t { }; // these are not in the same order as the above, and it can't be changed for compat reasons. lame! -enum dukeinvicon_t { +enum dukeinvicon_t +{ ICON_NONE, // 0 ICON_FIRSTAID, ICON_STEROIDS, @@ -56,7 +58,8 @@ static int const icon_to_inv[ICON_MAX] = { GET_FIRSTAID, GET_FIRSTAID, GET_STERO static int const inv_to_icon[GET_MAX] = { ICON_STEROIDS, ICON_NONE, ICON_SCUBA, ICON_HOLODUKE, ICON_JETPACK, ICON_NONE, ICON_NONE, ICON_HEATS, ICON_NONE, ICON_FIRSTAID, ICON_BOOTS }; -enum dukeweapon_t { +enum dukeweapon_t +{ KNEE_WEAPON, // 0 PISTOL_WEAPON, SHOTGUN_WEAPON, diff --git a/polymer/eduke32/source/macros.h b/polymer/eduke32/source/macros.h index 08708acbb..baa31b1a5 100644 --- a/polymer/eduke32/source/macros.h +++ b/polymer/eduke32/source/macros.h @@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define RANDOMSCRAP(s, i) A_InsertSprite(s->sectnum,s->x+(krand()&255)-128,s->y+(krand()&255)-128,s->z-ZOFFSET3-(krand()&8191),\ SCRAP6+(krand()&15),-8,48,48,krand()&2047,(krand()&63)+64,-512-(krand()&2047),i,5) -#define GTFLAGS(x) (GametypeFlags[ud.coop] & x) +#define GTFLAGS(x) (g_gametypeFlags[ud.coop] & x) #define TRAVERSE_SPRITE_SECT(l, o, n) (o) = (l); ((o) != -1) && ((n) = nextspritesect[o]); (o) = (n) #define TRAVERSE_SPRITE_STAT(l, o, n) (o) = (l); ((o) != -1) && ((n) = nextspritestat[o]); (o) = (n) diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 5618b4ac1..91e32d478 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -1436,20 +1436,20 @@ void M_Init(void) // prepare episodes k = 0; - for (i = 0; i < g_numVolumes; ++i) + for (i = 0; i < g_volumeCnt; ++i) { - if (EpisodeNames[i][0]) + if (g_volumeNames[i][0]) { - if (!(EpisodeFlags[i] & EF_HIDEFROMSP)) + if (!(g_volumeFlags[i] & EF_HIDEFROMSP)) { MEL_EPISODE[i] = &ME_EPISODE[i]; ME_EPISODE[i] = ME_EPISODE_TEMPLATE; - ME_EPISODE[i].name = EpisodeNames[i]; + ME_EPISODE[i].name = g_volumeNames[i]; } // if (!(EpisodeFlags[i] & EF_HIDEFROMMP)) { - MEOSN_NetEpisodes[k] = EpisodeNames[i]; + MEOSN_NetEpisodes[k] = g_volumeNames[i]; MEOSV_NetEpisodes[k] = i; k++; @@ -1460,48 +1460,48 @@ void M_Init(void) MEOS_NETOPTIONS_LEVEL[i] = MEOS_NETOPTIONS_LEVEL_TEMPLATE; for (j = 0; j < MAXLEVELS; ++j) { - MEOSN_NetLevels[i][j] = aMapInfo[MAXLEVELS*i+j].name; - if (aMapInfo[i*MAXLEVELS+j].filename != NULL) + MEOSN_NetLevels[i][j] = g_mapInfo[MAXLEVELS*i+j].name; + if (g_mapInfo[i*MAXLEVELS+j].filename != NULL) MEOS_NETOPTIONS_LEVEL[i].numOptions = j+1; } MEOS_NETOPTIONS_LEVEL[i].optionNames = MEOSN_NetLevels[i]; } - M_EPISODE.numEntries = g_numVolumes+2; - MEL_EPISODE[g_numVolumes] = &ME_Space4; - MEL_EPISODE[g_numVolumes+1] = &ME_EPISODE_USERMAP; + M_EPISODE.numEntries = g_volumeCnt+2; + MEL_EPISODE[g_volumeCnt] = &ME_Space4; + MEL_EPISODE[g_volumeCnt+1] = &ME_EPISODE_USERMAP; MEOS_NETOPTIONS_EPISODE.numOptions = k + 1; MEOSN_NetEpisodes[k] = MenuUserMap; MEOSV_NetEpisodes[k] = MAXVOLUMES; NetEpisode = MEOSV_NetEpisodes[0]; - MMF_Top_Episode.pos.y = (48-(g_numVolumes*2))<<16; - if (g_numSkills == 0) + MMF_Top_Episode.pos.y = (48-(g_volumeCnt*2))<<16; + if (g_skillCnt == 0) MEO_EPISODE.linkID = MENU_NULL; // prepare skills k = -1; - for (i = 0; i < g_numSkills && SkillNames[i][0]; ++i) + for (i = 0; i < g_skillCnt && g_skillNames[i][0]; ++i) { MEL_SKILL[i] = &ME_SKILL[i]; ME_SKILL[i] = ME_SKILL_TEMPLATE; - ME_SKILL[i].name = SkillNames[i]; + ME_SKILL[i].name = g_skillNames[i]; - MEOSN_NetSkills[i] = SkillNames[i]; + MEOSN_NetSkills[i] = g_skillNames[i]; k = i; } ++k; - M_SKILL.numEntries = g_numSkills; // k; - MEOS_NETOPTIONS_MONSTERS.numOptions = g_numSkills + 1; // k+1; - MEOSN_NetSkills[g_numSkills] = MenuSkillNone; - MMF_Top_Skill.pos.y = (58 + (4-g_numSkills)*6)<<16; + M_SKILL.numEntries = g_skillCnt; // k; + MEOS_NETOPTIONS_MONSTERS.numOptions = g_skillCnt + 1; // k+1; + MEOSN_NetSkills[g_skillCnt] = MenuSkillNone; + MMF_Top_Skill.pos.y = (58 + (4-g_skillCnt)*6)<<16; M_SKILL.currentEntry = 1; // prepare multiplayer gametypes k = -1; for (i = 0; i < MAXGAMETYPES; ++i) - if (GametypeNames[i][0]) + if (g_gametypeNames[i][0]) { - MEOSN_NetGametypes[i] = GametypeNames[i]; + MEOSN_NetGametypes[i] = g_gametypeNames[i]; k = i; } ++k; @@ -1623,7 +1623,7 @@ void M_Init(void) if (VOLUMEONE) { // blue out episodes beyond the first - for (i = 1; i < g_numVolumes; ++i) + for (i = 1; i < g_volumeCnt; ++i) { if (MEL_EPISODE[i]) { @@ -1631,7 +1631,7 @@ void M_Init(void) ME_EPISODE[i].entry = &MEO_EPISODE_SHAREWARE; } } - M_EPISODE.numEntries = g_numVolumes; // remove User Map (and spacer) + M_EPISODE.numEntries = g_volumeCnt; // remove User Map (and spacer) MEOS_NETOPTIONS_EPISODE.numOptions = 1; MenuEntry_DisableOnCondition(&ME_NETOPTIONS_EPISODE, 1); } @@ -1762,8 +1762,8 @@ static void M_PreMenu(MenuID_t cm) MEL_NETOPTIONS[2] = &ME_NETOPTIONS_LEVEL; MEO_NETOPTIONS_LEVEL.options = &MEOS_NETOPTIONS_LEVEL[MEOSV_NetEpisodes[MEO_NETOPTIONS_EPISODE.currentOption]]; } - MEL_NETOPTIONS[4] = (GametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION) ? &ME_NETOPTIONS_MARKERS : &ME_NETOPTIONS_MARKERS_DISABLED; - MEL_NETOPTIONS[5] = (GametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM)) ? &ME_NETOPTIONS_FRFIRE : &ME_NETOPTIONS_MAPEXITS; + MEL_NETOPTIONS[4] = (g_gametypeFlags[ud.m_coop] & GAMETYPE_MARKEROPTION) ? &ME_NETOPTIONS_MARKERS : &ME_NETOPTIONS_MARKERS_DISABLED; + MEL_NETOPTIONS[5] = (g_gametypeFlags[ud.m_coop] & (GAMETYPE_PLAYERSFRIENDLY|GAMETYPE_TDM)) ? &ME_NETOPTIONS_FRFIRE : &ME_NETOPTIONS_MAPEXITS; break; case MENU_OPTIONS: @@ -1924,12 +1924,12 @@ static void M_PreMenuDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) mminitext(origin.x + (90<<16), origin.y + ((90+8+8+8+8)<<16), "Friendly Fire", 2); mminitext(origin.x + (90<<16), origin.y + ((90+8+8+8+8+8)<<16), "User Map", 2); - mminitext(origin.x + ((90+60)<<16), origin.y + (90<<16), GametypeNames[ud.m_coop], 0); + mminitext(origin.x + ((90+60)<<16), origin.y + (90<<16), g_gametypeNames[ud.m_coop], 0); - mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8)<<16), EpisodeNames[ud.m_volume_number], 0); - mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8+8)<<16), aMapInfo[MAXLEVELS*ud.m_volume_number+ud.m_level_number].name, 0); + mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8)<<16), g_volumeNames[ud.m_volume_number], 0); + mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8+8)<<16), g_mapInfo[MAXLEVELS*ud.m_volume_number+ud.m_level_number].name, 0); if (ud.m_monsters_off == 0 || ud.m_player_skill > 0) - mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8+8+8)<<16), SkillNames[ud.m_player_skill], 0); + mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8+8+8)<<16), g_skillNames[ud.m_player_skill], 0); else mminitext(origin.x + ((90+60)<<16), origin.y + ((90+8+8+8)<<16), "None", 0); if (ud.m_coop == 0) { @@ -2029,8 +2029,8 @@ static void M_PreMenuDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) } { - const char *name = aMapInfo[(savehead.volnum*MAXLEVELS) + savehead.levnum].name; - Bsprintf(tempbuf, "%s / %s", name ? name : "^10unnamed^0", SkillNames[savehead.skill-1]); + const char *name = g_mapInfo[(savehead.volnum*MAXLEVELS) + savehead.levnum].name; + Bsprintf(tempbuf, "%s / %s", name ? name : "^10unnamed^0", g_skillNames[savehead.skill-1]); } mgametextcenter(origin.x, origin.y + (168<<16), tempbuf); @@ -2083,7 +2083,7 @@ static void M_PreMenuDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) mgametextcenter(origin.x, origin.y + (156<<16), tempbuf); } - Bsprintf(tempbuf,"%s / %s",aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, SkillNames[ud.player_skill-1]); + Bsprintf(tempbuf,"%s / %s",g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, g_skillNames[ud.player_skill-1]); mgametextcenter(origin.x, origin.y + (168<<16), tempbuf); if (ud.volume_number == 0 && ud.level_number == 7) mgametextcenter(origin.x, origin.y + (180<<16), currentboardfilename); @@ -2104,7 +2104,7 @@ static void M_PreMenuDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) if (g_oldverSavegame[M_LOAD.currentEntry]) { mgametextcenter(origin.x, origin.y + (90<<16), "Start new game:"); - Bsprintf(tempbuf,"%s / %s",aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, SkillNames[ud.player_skill-1]); + Bsprintf(tempbuf,"%s / %s",g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, g_skillNames[ud.player_skill-1]); mgametextcenter(origin.x, origin.y + (99<<16), tempbuf); } else @@ -2566,8 +2566,8 @@ static int32_t M_Cheat_Warp(char const * const numbers) osdcmd_cheatsinfo_stat.volume--; osdcmd_cheatsinfo_stat.level--; - if ((VOLUMEONE && osdcmd_cheatsinfo_stat.volume > 0) || osdcmd_cheatsinfo_stat.volume > g_numVolumes-1 || - osdcmd_cheatsinfo_stat.level >= MAXLEVELS || aMapInfo[osdcmd_cheatsinfo_stat.volume *MAXLEVELS+osdcmd_cheatsinfo_stat.level].filename == NULL) + if ((VOLUMEONE && osdcmd_cheatsinfo_stat.volume > 0) || osdcmd_cheatsinfo_stat.volume > g_volumeCnt-1 || + osdcmd_cheatsinfo_stat.level >= MAXLEVELS || g_mapInfo[osdcmd_cheatsinfo_stat.volume *MAXLEVELS+osdcmd_cheatsinfo_stat.level].filename == NULL) return 1; osdcmd_cheatsinfo_stat.cheatnum = CHEAT_SCOTTY; @@ -2604,7 +2604,7 @@ static void M_MenuEntryLinkActivate(MenuEntry_t *entry) ud.m_volume_number = M_EPISODE.currentEntry; ud.m_level_number = 0; - if (g_numSkills == 0) + if (g_skillCnt == 0) M_StartGameWithoutSkill(); } break; @@ -2844,20 +2844,20 @@ static int32_t M_MenuEntryOptionModify(MenuEntry_t *entry, int32_t newOption) CONTROL_MapAnalogAxis(M_JOYSTICKAXES.currentEntry, newOption, controldevice_joystick); else if (entry == &ME_NETOPTIONS_EPISODE) { - if ((unsigned)newOption < g_numVolumes) + if (newOption < g_volumeCnt) ud.m_volume_number = newOption; } else if (entry == &ME_NETOPTIONS_MONSTERS) { - ud.m_monsters_off = (newOption == g_numSkills); - if (newOption < g_numSkills) + ud.m_monsters_off = (newOption == g_skillCnt); + if (newOption < g_skillCnt) ud.m_player_skill = newOption; } else if (entry == &ME_ADULTMODE) { if (newOption) { - for (x=0; x 0) + if (g_skillCnt > 0) M_ChangeMenuAnimate(MENU_SKILL, MA_Advance); else M_StartGameWithoutSkill(); diff --git a/polymer/eduke32/source/namesdyn.c b/polymer/eduke32/source/namesdyn.c index c5e7e4508..87d4921de 100644 --- a/polymer/eduke32/source/namesdyn.c +++ b/polymer/eduke32/source/namesdyn.c @@ -1290,21 +1290,21 @@ void G_InitDynamicTiles(void) DynamicTileMap[g_dynTileList[i].staticval] = g_dynTileList[i].staticval; #endif - BlimpSpawnSprites[0] = RPGSPRITE; - BlimpSpawnSprites[1] = CHAINGUNSPRITE; - BlimpSpawnSprites[2] = DEVISTATORAMMO; - BlimpSpawnSprites[3] = RPGAMMO; - BlimpSpawnSprites[4] = RPGAMMO; - BlimpSpawnSprites[5] = JETPACK; - BlimpSpawnSprites[6] = SHIELD; - BlimpSpawnSprites[7] = FIRSTAID; - BlimpSpawnSprites[8] = STEROIDS; - BlimpSpawnSprites[9] = RPGAMMO; - BlimpSpawnSprites[10] = RPGAMMO; - BlimpSpawnSprites[11] = RPGSPRITE; - BlimpSpawnSprites[12] = RPGAMMO; - BlimpSpawnSprites[13] = FREEZESPRITE; - BlimpSpawnSprites[14] = FREEZEAMMO; + g_blimpSpawnItems[0] = RPGSPRITE; + g_blimpSpawnItems[1] = CHAINGUNSPRITE; + g_blimpSpawnItems[2] = DEVISTATORAMMO; + g_blimpSpawnItems[3] = RPGAMMO; + g_blimpSpawnItems[4] = RPGAMMO; + g_blimpSpawnItems[5] = JETPACK; + g_blimpSpawnItems[6] = SHIELD; + g_blimpSpawnItems[7] = FIRSTAID; + g_blimpSpawnItems[8] = STEROIDS; + g_blimpSpawnItems[9] = RPGAMMO; + g_blimpSpawnItems[10] = RPGAMMO; + g_blimpSpawnItems[11] = RPGSPRITE; + g_blimpSpawnItems[12] = RPGAMMO; + g_blimpSpawnItems[13] = FREEZESPRITE; + g_blimpSpawnItems[14] = FREEZEAMMO; WeaponPickupSprites[0] = KNEE; WeaponPickupSprites[1] = FIRSTGUNSPRITE; diff --git a/polymer/eduke32/source/net.c b/polymer/eduke32/source/net.c index 4173eb34c..df4992dad 100644 --- a/polymer/eduke32/source/net.c +++ b/polymer/eduke32/source/net.c @@ -145,7 +145,7 @@ void Net_SyncPlayer(ENetEvent *event) if (i == -1) { - i = playerswhenstarted++; + i = g_mostConcurrentPlayers++; } event->peer->data = (void *)(intptr_t)i; @@ -154,12 +154,12 @@ void Net_SyncPlayer(ENetEvent *event) g_player[i].playerquitflag = 1; //g_player[i].revision = g_netMapRevision; - for (j=0; j g_numVolumes) + if (volume > g_volumeCnt) { - OSD_Printf("changelevel: invalid volume number (range 1-%d)\n",g_numVolumes); + OSD_Printf("changelevel: invalid volume number (range 1-%d)\n",g_volumeCnt); return OSDCMD_OK; } } - if (level > MAXLEVELS || aMapInfo[volume *MAXLEVELS+level].filename == NULL) + if (level > MAXLEVELS || g_mapInfo[volume *MAXLEVELS+level].filename == NULL) { OSD_Printf("changelevel: invalid level number\n"); return OSDCMD_SHOWHELP; @@ -141,15 +141,16 @@ static int32_t osdcmd_changelevel(const osdfuncparm_t *parm) // out-of-game behave like a menu command osdcmd_cheatsinfo_stat.cheatnum = -1; - ud.m_volume_number = volume; - ud.m_level_number = level; + ud.m_volume_number = volume; + ud.m_level_number = level; - ud.m_monsters_off = ud.monsters_off = 0; + ud.m_monsters_off = 0; + ud.monsters_off = 0; - ud.m_respawn_items = 0; + ud.m_respawn_items = 0; ud.m_respawn_inventory = 0; - ud.multimode = 1; + ud.multimode = 1; G_NewGame_EnterLevel(); } @@ -386,7 +387,7 @@ static int32_t osdcmd_music(const osdfuncparm_t *parm) return OSDCMD_OK; } - if (aMapInfo[sel].musicfn != NULL) + if (g_mapInfo[sel].musicfn != NULL) { g_musicIndex = sel; G_StartMusic(); @@ -517,7 +518,7 @@ static int32_t osdcmd_spawn(const osdfuncparm_t *parm) { int32_t i; #ifdef LUNATIC - i = g_numLabels; + i = g_labelCnt; picnum = El_GetLabelValue(parm->parms[0]); if (picnum != INT32_MIN) i = !i; @@ -526,7 +527,7 @@ static int32_t osdcmd_spawn(const osdfuncparm_t *parm) for (j=0; j<2; j++) { - for (i=0; iparms[0])) || (j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))) @@ -536,11 +537,11 @@ static int32_t osdcmd_spawn(const osdfuncparm_t *parm) } } - if (i < g_numLabels) + if (i < g_labelCnt) break; } #endif - if (i==g_numLabels) + if (i==g_labelCnt) { OSD_Printf("spawn: Invalid tile label given\n"); return OSDCMD_OK; diff --git a/polymer/eduke32/source/player.h b/polymer/eduke32/source/player.h index 9d8240cae..d55b498ec 100644 --- a/polymer/eduke32/source/player.h +++ b/polymer/eduke32/source/player.h @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. extern "C" { #endif -extern int32_t playerswhenstarted; +extern int32_t g_mostConcurrentPlayers; #define MOVEFIFOSIZ 2 @@ -248,8 +248,6 @@ typedef struct int32_t FlashColor; // Muzzle flash color } weapondata_t; -extern int8_t g_numPlayerSprites; - #ifdef LUNATIC # define PWEAPON(Player, Weapon, Wmember) (g_playerWeapon[Player][Weapon].Wmember) extern weapondata_t g_playerWeapon[MAXPLAYERS][MAX_WEAPONS]; @@ -383,7 +381,7 @@ static inline int P_GetP(const void *pSprite) return 0; #else int playerNum = ((const uspritetype *)pSprite)->yvel; - if ((unsigned)playerNum >= (unsigned)playerswhenstarted) + if ((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers) playerNum = 0; return playerNum; #endif diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 0b08c8ccf..1e9a50975 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -353,8 +353,8 @@ static void G_DoLoadScreen(const char *statustext, int32_t percent) else { menutext(160,90,0,0,"Loading"); - if (aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL) - menutext(160,90+16+8,0,0,aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name); + if (g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL) + menutext(160,90+16+8,0,0,g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name); } #ifndef EDUKE32_TOUCH_DEVICES @@ -426,10 +426,10 @@ void G_CacheMapData(void) S_PauseMusic(1); #endif - if (aMapInfo[MUS_LOADING].musicfn) + if (g_mapInfo[MUS_LOADING].musicfn) { S_StopMusic(); - S_PlayMusic(aMapInfo[MUS_LOADING].musicfn); + S_PlayMusic(g_mapInfo[MUS_LOADING].musicfn); } #if defined EDUKE32_TOUCH_DEVICES && defined USE_OPENGL @@ -580,7 +580,7 @@ void G_UpdateScreenArea(void) int32_t y1 = ss; int32_t y2 = 200; - if (ud.screen_size > 0 && (GametypeFlags[ud.coop]&GAMETYPE_FRAGBAR) && (g_netServer || ud.multimode > 1)) + if (ud.screen_size > 0 && (g_gametypeFlags[ud.coop]&GAMETYPE_FRAGBAR) && (g_netServer || ud.multimode > 1)) { int32_t i, j = 0; @@ -630,17 +630,17 @@ void P_RandomSpawnPoint(int playerNum) uint32_t dist; uint32_t pdist = -1; - if ((g_netServer || ud.multimode > 1) && !(GametypeFlags[ud.coop] & GAMETYPE_FIXEDRESPAWN)) + if ((g_netServer || ud.multimode > 1) && !(g_gametypeFlags[ud.coop] & GAMETYPE_FIXEDRESPAWN)) { - i = krand() % g_numPlayerSprites; + i = krand() % g_playerSpawnCnt; - if (GametypeFlags[ud.coop] & GAMETYPE_TDMSPAWN) + if (g_gametypeFlags[ud.coop] & GAMETYPE_TDMSPAWN) { for (bssize_t j=0; jteam == pPlayer->team && sprite[g_player[j].ps->i].extra > 0) { - for (bssize_t k=0; kpos.x - g_playerSpawnPoints[k].pos.x, g_player[j].ps->pos.y - g_playerSpawnPoints[k].pos.y); @@ -789,7 +789,7 @@ void P_ResetStatus(int playerNum) pPlayer->rapid_fire_hold = 0; pPlayer->toggle_key_flag = 0; pPlayer->access_spritenum = -1; - pPlayer->got_access = ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop] & GAMETYPE_ACCESSATSTART)) ? 7 : 0; + pPlayer->got_access = ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop] & GAMETYPE_ACCESSATSTART)) ? 7 : 0; pPlayer->random_club_frame = 0; pus = 1; pPlayer->on_warping_sector = 0; @@ -911,22 +911,22 @@ static void resetprestat(int playerNum, int gameMode) pPlayer->one_parallax_sectnum = -1; pPlayer->visibility = ud.const_visibility; - screenpeek = myconnectindex; - g_numAnimWalls = 0; - g_numCyclers = 0; - g_animateCount = 0; - parallaxtype = 0; - randomseed = 1996; - ud.pause_on = 0; - ud.camerasprite = -1; - ud.eog = 0; - tempwallptr = 0; - g_curViewscreen = -1; - g_earthquakeTime = 0; - g_numInterpolations = 0; + screenpeek = myconnectindex; + g_animWallCnt = 0; + g_cyclerCnt = 0; + g_animateCnt = 0; + parallaxtype = 0; + randomseed = 1996; + ud.pause_on = 0; + ud.camerasprite = -1; + ud.eog = 0; + tempwallptr = 0; + g_curViewscreen = -1; + g_earthquakeTime = 0; + g_interpolationCnt = 0; if (((gameMode & MODE_EOL) != MODE_EOL && numplayers < 2 && !g_netServer) - || (!(GametypeFlags[ud.coop] & GAMETYPE_PRESERVEINVENTORYDEATH) && numplayers > 1)) + || (!(g_gametypeFlags[ud.coop] & GAMETYPE_PRESERVEINVENTORYDEATH) && numplayers > 1)) { P_ResetWeapons(playerNum); P_ResetInventory(playerNum); @@ -1005,8 +1005,6 @@ static inline int G_CheckExitSprite(int spriteNum) { return (sprite[spriteNum].l static void prelevel(char g) { - int32_t i, nexti, j, startwall, endwall; - int32_t switchpicnum; uint8_t *tagbitmap = (uint8_t *)Xcalloc(65536>>3, 1); Bmemset(show2dsector, 0, sizeof(show2dsector)); @@ -1014,7 +1012,7 @@ static void prelevel(char g) Bmemset(ror_protectedsectors, 0, MAXSECTORS); #endif resetprestat(0,g); - g_numClouds = 0; + g_cloudCnt = 0; G_SetupGlobalPsky(); @@ -1022,7 +1020,7 @@ static void prelevel(char g) int missedCloudSectors = 0; - for (i=0; i= MAXCYCLERS) + if (g_cyclerCnt >= MAXCYCLERS) { Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS); G_GameExit(tempbuf); } - cyclers[g_numCyclers][0] = SECT(i); - cyclers[g_numCyclers][1] = SLT(i); - cyclers[g_numCyclers][2] = SS(i); - cyclers[g_numCyclers][3] = sector[SECT(i)].floorshade; - cyclers[g_numCyclers][4] = SHT(i); - cyclers[g_numCyclers][5] = (SA(i) == 1536); - g_numCyclers++; + g_cyclers[g_cyclerCnt][0] = SECT(i); + g_cyclers[g_cyclerCnt][1] = SLT(i); + g_cyclers[g_cyclerCnt][2] = SS(i); + g_cyclers[g_cyclerCnt][3] = sector[SECT(i)].floorshade; + g_cyclers[g_cyclerCnt][4] = SHT(i); + g_cyclers[g_cyclerCnt][5] = (SA(i) == 1536); + g_cyclerCnt++; break; case SECTOREFFECTOR__STATIC: @@ -1124,7 +1122,7 @@ static void prelevel(char g) // Delete some effector / effector modifier sprites AFTER the loop running // the LOADACTOR events. DELETE_AFTER_LOADACTOR. - for (SPRITES_OF_STAT_SAFE(STAT_DEFAULT, i, nexti)) + for (bssize_t nextSprite, SPRITES_OF_STAT_SAFE(STAT_DEFAULT, i, nextSprite)) if (!G_CheckExitSprite(i)) switch (DYNAMICTILEMAP(PN(i))) { @@ -1134,13 +1132,13 @@ static void prelevel(char g) break; } - for (i = 0; i < MAXSPRITES; i++) + for (size_t i = 0; i < MAXSPRITES; i++) { if (sprite[i].statnum < MAXSTATUS && (PN(i) != SECTOREFFECTOR || SLT(i) != SE_14_SUBWAY_CAR)) A_Spawn(-1, i); } - for (i = 0; i < MAXSPRITES; i++) + for (size_t i = 0; i < MAXSPRITES; i++) { if (sprite[i].statnum < MAXSTATUS && PN(i) == SECTOREFFECTOR && SLT(i) == SE_14_SUBWAY_CAR) A_Spawn(-1, i); @@ -1148,14 +1146,13 @@ static void prelevel(char g) G_SetupRotfixedSprites(); - for (i=headspritestat[STAT_DEFAULT]; i>=0; i=nextspritestat[i]) + for (bssize_t i=headspritestat[STAT_DEFAULT]; i>=0; i=nextspritestat[i]) { - int32_t ii; - if (PN(i) <= 0) // oob safety for switch below continue; - for (ii=0; ii<2; ii++) + for (bsize_t ii=0; ii<2; ii++) + { switch (DYNAMICTILEMAP(PN(i)-1+ii)) { case DIPSWITCH__STATIC: @@ -1174,20 +1171,21 @@ static void prelevel(char g) // the lower code only for the 'on' state (*) if (ii==0) { - j = sprite[i].lotag; - tagbitmap[j>>3] |= 1<<(j&7); + int const tag = sprite[i].lotag; + tagbitmap[tag>>3] |= 1<<(tag&7); } break; } + } } // initially 'on' SE 12 light (*) - for (j=headspritestat[STAT_EFFECTOR]; j>=0; j=nextspritestat[j]) + for (bssize_t j=headspritestat[STAT_EFFECTOR]; j>=0; j=nextspritestat[j]) { - int32_t t = sprite[j].hitag; + int const tag = sprite[j].hitag; - if (sprite[j].lotag == SE_12_LIGHT_SWITCH && tagbitmap[t>>3]&(1<<(t&7))) + if (sprite[j].lotag == SE_12_LIGHT_SWITCH && tagbitmap[tag>>3]&(1<<(tag&7))) actor[j].t_data[0] = 1; } @@ -1195,153 +1193,151 @@ static void prelevel(char g) g_mirrorCount = 0; - for (i = 0; i < numwalls; i++) + for (bssize_t i = 0; i < numwalls; i++) { - walltype *wal; - wal = &wall[i]; + walltype * const pWall = &wall[i]; - if (wal->overpicnum == MIRROR && (wal->cstat&32) != 0) + if (pWall->overpicnum == MIRROR && (pWall->cstat&32) != 0) { - j = wal->nextsector; + int const nextSectnum = pWall->nextsector; - if ((j >= 0) && sector[j].ceilingpicnum != MIRROR) + if ((nextSectnum >= 0) && sector[nextSectnum].ceilingpicnum != MIRROR) { if (g_mirrorCount > 63) + { G_GameExit("\nToo many mirrors (64 max.)"); + } - sector[j].ceilingpicnum = MIRROR; - sector[j].floorpicnum = MIRROR; - g_mirrorWall[g_mirrorCount] = i; - g_mirrorSector[g_mirrorCount] = j; + sector[nextSectnum].ceilingpicnum = MIRROR; + sector[nextSectnum].floorpicnum = MIRROR; + g_mirrorWall[g_mirrorCount] = i; + g_mirrorSector[g_mirrorCount] = nextSectnum; g_mirrorCount++; continue; } } - if (g_numAnimWalls >= MAXANIMWALLS) + if (g_animWallCnt >= MAXANIMWALLS) { Bsprintf(tempbuf,"\nToo many 'anim' walls (%d max).",MAXANIMWALLS); G_GameExit(tempbuf); } - animwall[g_numAnimWalls].tag = 0; - animwall[g_numAnimWalls].wallnum = 0; + animwall[g_animWallCnt].tag = 0; + animwall[g_animWallCnt].wallnum = 0; - switchpicnum = G_GetForcefieldPicnum(i); + int const switchPic = G_GetForcefieldPicnum(i); - if (switchpicnum >= 0) + if (switchPic >= 0) { - switch (DYNAMICTILEMAP(switchpicnum)) + switch (DYNAMICTILEMAP(switchPic)) { - case FANSHADOW__STATIC: - case FANSPRITE__STATIC: - wall->cstat |= 65; - animwall[g_numAnimWalls].wallnum = i; - g_numAnimWalls++; - break; + case FANSHADOW__STATIC: + case FANSPRITE__STATIC: + wall->cstat |= 65; + animwall[g_animWallCnt].wallnum = i; + g_animWallCnt++; + break; - case W_FORCEFIELD__STATIC: - if (wal->overpicnum==W_FORCEFIELD__STATIC) - for (j=0; j<3; j++) - tloadtile(W_FORCEFIELD+j, 0); - if (wal->shade > 31) - wal->cstat = 0; - else wal->cstat |= FORCEFIELD_CSTAT|256; + case W_FORCEFIELD__STATIC: + if (pWall->overpicnum == W_FORCEFIELD__STATIC) + for (bsize_t j = 0; j < 3; j++) tloadtile(W_FORCEFIELD + j, 0); + if (pWall->shade > 31) + pWall->cstat = 0; + else + pWall->cstat |= FORCEFIELD_CSTAT | 256; - if (wal->lotag && wal->nextwall >= 0) - wall[wal->nextwall].lotag = - wal->lotag; + if (pWall->lotag && pWall->nextwall >= 0) + wall[pWall->nextwall].lotag = pWall->lotag; - case BIGFORCE__STATIC: - animwall[g_numAnimWalls].wallnum = i; - g_numAnimWalls++; + case BIGFORCE__STATIC: + animwall[g_animWallCnt].wallnum = i; + g_animWallCnt++; - continue; + continue; } } - wal->extra = -1; + pWall->extra = -1; - switch (DYNAMICTILEMAP(wal->picnum)) + switch (DYNAMICTILEMAP(pWall->picnum)) { - case WATERTILE2__STATIC: - for (j=0; j<3; j++) - tloadtile(wal->picnum+j, 0); - break; + case WATERTILE2__STATIC: + for (bsize_t j = 0; j < 3; j++) + tloadtile(pWall->picnum + j, 0); + break; - case TECHLIGHT2__STATIC: - case TECHLIGHT4__STATIC: - tloadtile(wal->picnum, 0); - break; - case W_TECHWALL1__STATIC: - case W_TECHWALL2__STATIC: - case W_TECHWALL3__STATIC: - case W_TECHWALL4__STATIC: - animwall[g_numAnimWalls].wallnum = i; - // animwall[g_numAnimWalls].tag = -1; - g_numAnimWalls++; - break; - case SCREENBREAK6__STATIC: - case SCREENBREAK7__STATIC: - case SCREENBREAK8__STATIC: - for (j=SCREENBREAK6; jpicnum, 0); break; + case W_TECHWALL1__STATIC: + case W_TECHWALL2__STATIC: + case W_TECHWALL3__STATIC: + case W_TECHWALL4__STATIC: + animwall[g_animWallCnt].wallnum = i; + // animwall[g_numAnimWalls].tag = -1; + g_animWallCnt++; + break; + case SCREENBREAK6__STATIC: + case SCREENBREAK7__STATIC: + case SCREENBREAK8__STATIC: + for (bssize_t j = SCREENBREAK6; j < SCREENBREAK9; j++) + tloadtile(j, 0); - case FEMPIC1__STATIC: - case FEMPIC2__STATIC: - case FEMPIC3__STATIC: - wal->extra = wal->picnum; - animwall[g_numAnimWalls].tag = -1; - if (ud.lockout) - { - if (wal->picnum == FEMPIC1) - wal->picnum = BLANKSCREEN; - else wal->picnum = SCREENBREAK6; - } + animwall[g_animWallCnt].wallnum = i; + animwall[g_animWallCnt].tag = -1; + g_animWallCnt++; + break; - animwall[g_numAnimWalls].wallnum = i; - animwall[g_numAnimWalls].tag = wal->picnum; - g_numAnimWalls++; - break; + case FEMPIC1__STATIC: + case FEMPIC2__STATIC: + case FEMPIC3__STATIC: + pWall->extra = pWall->picnum; + animwall[g_animWallCnt].tag = -1; - case SCREENBREAK1__STATIC: - case SCREENBREAK2__STATIC: - case SCREENBREAK3__STATIC: - case SCREENBREAK4__STATIC: - case SCREENBREAK5__STATIC: + if (ud.lockout) + pWall->picnum = (pWall->picnum == FEMPIC1) ? BLANKSCREEN : SCREENBREAK6; + + animwall[g_animWallCnt].wallnum = i; + animwall[g_animWallCnt].tag = pWall->picnum; + g_animWallCnt++; + break; + + case SCREENBREAK1__STATIC: + case SCREENBREAK2__STATIC: + case SCREENBREAK3__STATIC: + case SCREENBREAK4__STATIC: + case SCREENBREAK5__STATIC: // - case SCREENBREAK9__STATIC: - case SCREENBREAK10__STATIC: - case SCREENBREAK11__STATIC: - case SCREENBREAK12__STATIC: - case SCREENBREAK13__STATIC: - case SCREENBREAK14__STATIC: - case SCREENBREAK15__STATIC: - case SCREENBREAK16__STATIC: - case SCREENBREAK17__STATIC: - case SCREENBREAK18__STATIC: - case SCREENBREAK19__STATIC: - animwall[g_numAnimWalls].wallnum = i; - animwall[g_numAnimWalls].tag = wal->picnum; - g_numAnimWalls++; - break; + case SCREENBREAK9__STATIC: + case SCREENBREAK10__STATIC: + case SCREENBREAK11__STATIC: + case SCREENBREAK12__STATIC: + case SCREENBREAK13__STATIC: + case SCREENBREAK14__STATIC: + case SCREENBREAK15__STATIC: + case SCREENBREAK16__STATIC: + case SCREENBREAK17__STATIC: + case SCREENBREAK18__STATIC: + case SCREENBREAK19__STATIC: + animwall[g_animWallCnt].wallnum = i; + animwall[g_animWallCnt].tag = pWall->picnum; + g_animWallCnt++; + break; } } //Invalidate textures in sector behind mirror - for (i=0; iaim_mode; autoaim[i] = g_player[i].ps->auto_aim; weaponswitch[i] = g_player[i].ps->weaponswitch; - if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) + if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) { for (j=0; jammo_amount[j]; @@ -1501,7 +1497,7 @@ static void resetpspritevars(char gameMode) g_player[i].ps->aim_mode = aimmode[i]; g_player[i].ps->auto_aim = autoaim[i]; g_player[i].ps->weaponswitch = weaponswitch[i]; - if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) + if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0) { for (j=0; jammo_amount[j] = tsbar[i].ammo_amount[j]; @@ -1513,7 +1509,7 @@ static void resetpspritevars(char gameMode) } } - g_numPlayerSprites = 0; + g_playerSpawnCnt = 0; // circ = 2048/ud.multimode; g_whichPalForPlayer = 9; @@ -1524,16 +1520,16 @@ static void resetpspritevars(char gameMode) const int32_t nexti = nextspritestat[i]; spritetype *const s = &sprite[i]; - if (g_numPlayerSprites == MAXPLAYERS) + if (g_playerSpawnCnt == MAXPLAYERS) G_GameExit("\nToo many player sprites (max 16.)"); - g_playerSpawnPoints[g_numPlayerSprites].pos.x = s->x; - g_playerSpawnPoints[g_numPlayerSprites].pos.y = s->y; - g_playerSpawnPoints[g_numPlayerSprites].pos.z = s->z; - g_playerSpawnPoints[g_numPlayerSprites].ang = s->ang; - g_playerSpawnPoints[g_numPlayerSprites].sect = s->sectnum; + g_playerSpawnPoints[g_playerSpawnCnt].pos.x = s->x; + g_playerSpawnPoints[g_playerSpawnCnt].pos.y = s->y; + g_playerSpawnPoints[g_playerSpawnCnt].pos.z = s->z; + g_playerSpawnPoints[g_playerSpawnCnt].ang = s->ang; + g_playerSpawnPoints[g_playerSpawnCnt].sect = s->sectnum; - g_numPlayerSprites++; + g_playerSpawnCnt++; if (j < MAXPLAYERS) { @@ -1560,7 +1556,7 @@ static void resetpspritevars(char gameMode) s->yvel = j; - if (!g_player[j].pcolor && (g_netServer || ud.multimode > 1) && !(GametypeFlags[ud.coop] & GAMETYPE_TDM)) + if (!g_player[j].pcolor && (g_netServer || ud.multimode > 1) && !(g_gametypeFlags[ud.coop] & GAMETYPE_TDM)) { if (s->pal == 0) { @@ -1586,7 +1582,7 @@ static void resetpspritevars(char gameMode) { int32_t k = g_player[j].pcolor; - if (GametypeFlags[ud.coop] & GAMETYPE_TDM) + if (g_gametypeFlags[ud.coop] & GAMETYPE_TDM) { k = G_GetTeamPalette(g_player[j].pteam); g_player[j].ps->team = g_player[j].pteam; @@ -1629,7 +1625,7 @@ static inline void clearfrags(void) void G_ResetTimers(uint8_t keepgtics) { - totalclock = cloudtotalclock = ototalclock = lockclock = 0; + totalclock = g_cloudClock = ototalclock = lockclock = 0; ready2send = 1; g_levelTextTime = 85; @@ -1642,20 +1638,16 @@ void G_ResetTimers(uint8_t keepgtics) void G_ClearFIFO(void) { - int32_t i = MAXPLAYERS-1; - g_emuJumpTics = 0; - Bmemset(&avg, 0, sizeof(input_t)); - clearbufbyte(&localInput, sizeof(input_t), 0L); clearbufbyte(&inputfifo, sizeof(input_t) * MOVEFIFOSIZ * MAXPLAYERS, 0L); - for (; i >= 0; i--) + for (bsize_t p = 0; p <= MAXPLAYERS - 1; ++p) { - if (g_player[i].inputBits != NULL) - Bmemset(g_player[i].inputBits, 0, sizeof(input_t)); - g_player[i].vote = g_player[i].gotvote = 0; + if (g_player[p].inputBits != NULL) + Bmemset(g_player[p].inputBits, 0, sizeof(input_t)); + g_player[p].vote = g_player[p].gotvote = 0; } } @@ -1663,15 +1655,15 @@ int G_FindLevelByFile(const char *fileName) { for (bssize_t volumeNum = 0; volumeNum < MAXVOLUMES; volumeNum++) { - int const volumeOffset = volumeNum * MAXLEVELS; + int const volOffset = volumeNum * MAXLEVELS; for (bssize_t levelNum = 0; levelNum < MAXLEVELS; levelNum++) { - if (aMapInfo[volumeOffset + levelNum].filename == NULL) + if (g_mapInfo[volOffset + levelNum].filename == NULL) continue; - if (!Bstrcasecmp(fileName, aMapInfo[volumeOffset + levelNum].filename)) - return volumeOffset + levelNum; + if (!Bstrcasecmp(fileName, g_mapInfo[volOffset + levelNum].filename)) + return volOffset + levelNum; } } @@ -1763,12 +1755,12 @@ void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName, int levelNum if ((kFile = kopen4loadfrommod(nameBuf, 0)) != -1) { kclose(kFile); - realloc_copy(&aMapInfo[levelNum].musicfn, nameBuf); + realloc_copy(&g_mapInfo[levelNum].musicfn, nameBuf); return; } } - realloc_copy(&aMapInfo[levelNum].musicfn, "dethtoll.mid"); + realloc_copy(&g_mapInfo[levelNum].musicfn, "dethtoll.mid"); } static inline int G_HaveUserMap(void) @@ -1829,14 +1821,14 @@ int G_EnterLevel(int gameMode) mii = (ud.volume_number*MAXLEVELS)+ud.level_number; - if (aMapInfo[mii].name == NULL || aMapInfo[mii].filename == NULL) + if (g_mapInfo[mii].name == NULL || g_mapInfo[mii].filename == NULL) { if (G_HaveUserMap()) { - if (aMapInfo[mii].filename == NULL) - aMapInfo[mii].filename = (char *)Xcalloc(BMAX_PATH, sizeof(uint8_t)); - if (aMapInfo[mii].name == NULL) - aMapInfo[mii].name = Xstrdup("User Map"); + if (g_mapInfo[mii].filename == NULL) + g_mapInfo[mii].filename = (char *)Xcalloc(BMAX_PATH, sizeof(uint8_t)); + if (g_mapInfo[mii].name == NULL) + g_mapInfo[mii].name = Xstrdup("User Map"); } else { @@ -1864,9 +1856,9 @@ int G_EnterLevel(int gameMode) else { if (g_gameNamePtr) - Bsprintf(apptitle,"%s - %s - " APPNAME,aMapInfo[mii].name,g_gameNamePtr); + Bsprintf(apptitle,"%s - %s - " APPNAME,g_mapInfo[mii].name,g_gameNamePtr); else - Bsprintf(apptitle,"%s - " APPNAME,aMapInfo[mii].name); + Bsprintf(apptitle,"%s - " APPNAME,g_mapInfo[mii].name); } Bstrcpy(tempbuf,apptitle); @@ -1886,14 +1878,14 @@ int G_EnterLevel(int gameMode) G_LoadMapHack(levelName, boardfilename); G_SetupFilenameBasedMusic(levelName, boardfilename, ud.m_level_number); } - else if (loadboard(aMapInfo[mii].filename, VOLUMEONE, &pPlayer->pos, &pPlayer->ang, &pPlayer->cursectnum) < 0) + else if (loadboard(g_mapInfo[mii].filename, VOLUMEONE, &pPlayer->pos, &pPlayer->ang, &pPlayer->cursectnum) < 0) { - OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n", aMapInfo[mii].filename); + OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n", g_mapInfo[mii].filename); return 1; } else { - G_LoadMapHack(levelName, aMapInfo[mii].filename); + G_LoadMapHack(levelName, g_mapInfo[mii].filename); } g_precacheCount = 0; @@ -1907,7 +1899,7 @@ int G_EnterLevel(int gameMode) G_AlignWarpElevators(); resetpspritevars(gameMode); - ud.playerbest = CONFIG_GetMapBestTime(G_HaveUserMap() ? boardfilename : aMapInfo[mii].filename, g_loadedMapHack.md4); + ud.playerbest = CONFIG_GetMapBestTime(G_HaveUserMap() ? boardfilename : g_mapInfo[mii].filename, g_loadedMapHack.md4); G_FadeLoad(0,0,0, 252,0, -28, 4, -1); G_CacheMapData(); @@ -1916,8 +1908,8 @@ int G_EnterLevel(int gameMode) if (ud.recstat != 2) { g_musicIndex = mii; - if (aMapInfo[g_musicIndex].musicfn != NULL) - S_PlayMusic(aMapInfo[g_musicIndex].musicfn); + if (g_mapInfo[g_musicIndex].musicfn != NULL) + S_PlayMusic(g_mapInfo[g_musicIndex].musicfn); } if (gameMode & (MODE_GAME|MODE_EOL)) @@ -1980,7 +1972,7 @@ int G_EnterLevel(int gameMode) G_ClearFIFO(); - for (i=g_numInterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; + for (i=g_interpolationCnt-1; i>=0; i--) bakipos[i] = *curipos[i]; g_player[myconnectindex].ps->over_shoulder_on = 0; @@ -2002,7 +1994,7 @@ int G_EnterLevel(int gameMode) } OSD_Printf(OSDTEXT_YELLOW "E%dL%d: %s\n", ud.volume_number+1, ud.level_number+1, - aMapInfo[mii].name); + g_mapInfo[mii].name); g_restorePalette = -1; @@ -2017,7 +2009,7 @@ int G_EnterLevel(int gameMode) void G_FreeMapState(int levelNum) { - map_t *const pMapInfo = &aMapInfo[levelNum]; + map_t *const pMapInfo = &g_mapInfo[levelNum]; if (pMapInfo->savedstate == NULL) return; diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index afaa5c745..80502fcc8 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -100,7 +100,7 @@ void G_ResetInterpolations(void) { int32_t k, i; - g_numInterpolations = 0; + g_interpolationCnt = 0; k = headspritestat[STAT_EFFECTOR]; while (k >= 0) @@ -134,9 +134,9 @@ void G_ResetInterpolations(void) k = nextspritestat[k]; } - for (i=g_numInterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; - for (i = g_animateCount-1; i>=0; i--) - G_SetInterpolation(animateptr[i]); + for (i=g_interpolationCnt-1; i>=0; i--) bakipos[i] = *curipos[i]; + for (i = g_animateCnt-1; i>=0; i--) + G_SetInterpolation(g_animatePtr[i]); } void ReadSaveGameHeaders(void) @@ -300,8 +300,8 @@ int32_t G_LoadPlayer(int32_t spot) if (boardfilename[0]) Bstrcpy(currentboardfilename, boardfilename); - else if (aMapInfo[mapIdx].filename) - Bstrcpy(currentboardfilename, aMapInfo[mapIdx].filename); + else if (g_mapInfo[mapIdx].filename) + Bstrcpy(currentboardfilename, g_mapInfo[mapIdx].filename); if (currentboardfilename[0]) { @@ -996,7 +996,7 @@ static const dataspec_t svgm_udnetw[] = { { DS_STRING, (void *)svgm_udnetw_string, 0, 1 }, { 0, &ud.multimode, sizeof(ud.multimode), 1 }, - { 0, &g_numPlayerSprites, sizeof(g_numPlayerSprites), 1 }, + { 0, &g_playerSpawnCnt, sizeof(g_playerSpawnCnt), 1 }, { 0, &g_playerSpawnPoints, sizeof(g_playerSpawnPoints), 1 }, { DS_NOCHK, &ud.volume_number, sizeof(ud.volume_number), 1 }, @@ -1074,10 +1074,10 @@ static const dataspec_t svgm_secwsp[] = #endif { 0, &DynamicTileMap[0], sizeof(DynamicTileMap[0]), MAXTILES }, // NOCHK? { 0, &DynamicSoundMap[0], sizeof(DynamicSoundMap[0]), MAXSOUNDS }, // NOCHK? - { DS_NOCHK, &g_numCyclers, sizeof(g_numCyclers), 1 }, - { DS_CNT(g_numCyclers), &cyclers[0][0], sizeof(cyclers[0]), (intptr_t)&g_numCyclers }, - { DS_NOCHK, &g_numAnimWalls, sizeof(g_numAnimWalls), 1 }, - { DS_CNT(g_numAnimWalls), &animwall, sizeof(animwall[0]), (intptr_t)&g_numAnimWalls }, + { DS_NOCHK, &g_cyclerCnt, sizeof(g_cyclerCnt), 1 }, + { DS_CNT(g_cyclerCnt), &g_cyclers[0][0], sizeof(g_cyclers[0]), (intptr_t)&g_cyclerCnt }, + { DS_NOCHK, &g_animWallCnt, sizeof(g_animWallCnt), 1 }, + { DS_CNT(g_animWallCnt), &animwall, sizeof(animwall[0]), (intptr_t)&g_animWallCnt }, { DS_NOCHK, &g_mirrorCount, sizeof(g_mirrorCount), 1 }, { DS_NOCHK, &g_mirrorWall[0], sizeof(g_mirrorWall[0]), ARRAY_SIZE(g_mirrorWall) }, { DS_NOCHK, &g_mirrorSector[0], sizeof(g_mirrorSector[0]), ARRAY_SIZE(g_mirrorSector) }, @@ -1125,12 +1125,12 @@ static char svgm_end_string [] = "savegame_end"; static const dataspec_t svgm_anmisc[] = { { DS_STRING, (void *)svgm_anmisc_string, 0, 1 }, - { 0, &g_animateCount, sizeof(g_animateCount), 1 }, - { 0, &animatesect[0], sizeof(animatesect[0]), MAXANIMATES }, - { 0, &animategoal[0], sizeof(animategoal[0]), MAXANIMATES }, - { 0, &animatevel[0], sizeof(animatevel[0]), MAXANIMATES }, + { 0, &g_animateCnt, sizeof(g_animateCnt), 1 }, + { 0, &g_animateSect[0], sizeof(g_animateSect[0]), MAXANIMATES }, + { 0, &g_animateGoal[0], sizeof(g_animateGoal[0]), MAXANIMATES }, + { 0, &g_animateVel[0], sizeof(g_animateVel[0]), MAXANIMATES }, { DS_SAVEFN, (void *)&sv_preanimateptrsave, 0, 1 }, - { 0, &animateptr[0], sizeof(animateptr[0]), MAXANIMATES }, + { 0, &g_animatePtr[0], sizeof(g_animatePtr[0]), MAXANIMATES }, { DS_SAVEFN|DS_LOADFN , (void *)&sv_postanimateptr, 0, 1 }, { 0, &g_curViewscreen, sizeof(g_curViewscreen), 1 }, { 0, &g_origins[0], sizeof(g_origins[0]), ARRAY_SIZE(g_origins) }, @@ -1138,10 +1138,10 @@ static const dataspec_t svgm_anmisc[] = { DS_NOCHK, &g_deleteQueueSize, sizeof(g_deleteQueueSize), 1 }, { DS_CNT(g_deleteQueueSize), &SpriteDeletionQueue[0], sizeof(int16_t), (intptr_t)&g_deleteQueueSize }, { 0, &show2dsector[0], sizeof(uint8_t), MAXSECTORS>>3 }, - { DS_NOCHK, &g_numClouds, sizeof(g_numClouds), 1 }, - { 0, &clouds[0], sizeof(clouds), 1 }, - { 0, &cloudx, sizeof(cloudx), 1 }, - { 0, &cloudy, sizeof(cloudy), 1 }, + { DS_NOCHK, &g_cloudCnt, sizeof(g_cloudCnt), 1 }, + { 0, &g_cloudSect[0], sizeof(g_cloudSect), 1 }, + { 0, &g_cloudX, sizeof(g_cloudX), 1 }, + { 0, &g_cloudY, sizeof(g_cloudY), 1 }, { 0, &g_pskyidx, sizeof(g_pskyidx), 1 }, // DS_NOCHK? { 0, &g_earthquakeTime, sizeof(g_earthquakeTime), 1 }, @@ -1325,8 +1325,8 @@ int32_t sv_saveandmakesnapshot(FILE *fil, int8_t spot, int8_t recdiffsp, int8_t // savegame Bstrncpyz(h.savename, ud.savegame[spot], sizeof(h.savename)); #ifdef __ANDROID__ - Bstrncpyz(h.volname, EpisodeNames[ud.volume_number], sizeof(h.volname)); - Bstrncpyz(h.skillname, SkillNames[ud.player_skill], sizeof(h.skillname)); + Bstrncpyz(h.volname, g_volumeNames[ud.volume_number], sizeof(h.volname)); + Bstrncpyz(h.skillname, g_skillNames[ud.player_skill], sizeof(h.skillname)); #endif } else @@ -1703,11 +1703,11 @@ static void sv_postactordata() static void sv_preanimateptrsave() { - G_Util_PtrToIdx(animateptr, g_animateCount, sector, P2I_FWD); + G_Util_PtrToIdx(g_animatePtr, g_animateCnt, sector, P2I_FWD); } static void sv_postanimateptr() { - G_Util_PtrToIdx(animateptr, g_animateCount, sector, P2I_BACK); + G_Util_PtrToIdx(g_animatePtr, g_animateCnt, sector, P2I_BACK); } static void sv_prequote() { @@ -2120,13 +2120,13 @@ static void postloadplayer(int32_t savegamep) if (ud.config.MusicToggle) { - if (aMapInfo[musicIdx].musicfn != NULL && + if (g_mapInfo[musicIdx].musicfn != NULL && (musicIdx != g_musicIndex /* || MapInfo[MUS_LOADING].musicfn */)) { S_StopMusic(); g_musicIndex = musicIdx; - S_PlayMusic(aMapInfo[g_musicIndex].musicfn); + S_PlayMusic(g_mapInfo[g_musicIndex].musicfn); } S_PauseMusic(0); @@ -2162,7 +2162,7 @@ static void postloadplayer(int32_t savegamep) { if (ud.lockout) { - for (i=0; i= REND_POLYMOST) pus = NUMPAGES; // JBF 20040101: always redraw in GL - if ((g_netServer || ud.multimode > 1) && ((GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR) || g_fakeMultiMode)) + if ((g_netServer || ud.multimode > 1) && ((g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR) || g_fakeMultiMode)) { if (pus) G_DrawFrags(); @@ -921,11 +921,11 @@ void G_DrawStatusBar(int32_t snum) if (u == -1) { G_PatchStatusBar(0, 0, 320, 200); - if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) + if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) rotatesprite_fs(sbarx(277+1), sbary(SBY+7-1), sb16, 0, KILLSICON, 0, 0, 10+16); } - if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) + if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) { if (u&32768) { @@ -1030,7 +1030,7 @@ void G_DrawBackground(void) if ((g_player[myconnectindex].ps->gm&MODE_GAME) || ud.recstat == 2) { - if (GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR) + if (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR) { if ((g_netServer || ud.multimode > 1)) y1 += scale(ydim, 8, 200); if (ud.multimode > 4) y1 += scale(ydim, 8, 200); @@ -1112,7 +1112,7 @@ void G_DrawBackground(void) if (ud.screen_size > 8) { y = 0; - if (GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR) + if (g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR) { if ((g_netServer || ud.multimode > 1)) y += 8; if (ud.multimode > 4) y += 8; diff --git a/polymer/eduke32/source/screens.c b/polymer/eduke32/source/screens.c index 787c876d5..5b61a5831 100644 --- a/polymer/eduke32/source/screens.c +++ b/polymer/eduke32/source/screens.c @@ -177,10 +177,10 @@ static void G_ShowScores(void) { int32_t t, i; - if (playerswhenstarted > 1 && (GametypeFlags[ud.coop]&GAMETYPE_SCORESHEET)) + if (g_mostConcurrentPlayers > 1 && (g_gametypeFlags[ud.coop]&GAMETYPE_SCORESHEET)) { gametext(160, SCORESHEETOFFSET+58+2, "Multiplayer Totals", 0, 2+8+16); - gametext(160, SCORESHEETOFFSET+58+10, aMapInfo[G_LastMapInfoIndex()].name, 0, 2+8+16); + gametext(160, SCORESHEETOFFSET+58+10, g_mapInfo[G_LastMapInfoIndex()].name, 0, 2+8+16); t = 0; minitext(70, SCORESHEETOFFSET+80, "Name", 8, 2+8+16+ROTATESPRITE_MAX); @@ -188,7 +188,7 @@ static void G_ShowScores(void) minitext(200, SCORESHEETOFFSET+80, "Deaths", 8, 2+8+16+ROTATESPRITE_MAX); minitext(235, SCORESHEETOFFSET+80, "Ping", 8, 2+8+16+ROTATESPRITE_MAX); - for (i=playerswhenstarted-1; i>=0; i--) + for (i=g_mostConcurrentPlayers-1; i>=0; i--) { if (!g_player[i].playerquitflag) continue; @@ -292,18 +292,18 @@ static inline void G_MoveClouds(void) { int32_t i; - if (totalclock <= cloudtotalclock && totalclock >= (cloudtotalclock-7)) + if (totalclock <= g_cloudClock && totalclock >= (g_cloudClock-7)) return; - cloudtotalclock = totalclock+6; + g_cloudClock = totalclock+6; - cloudx += sintable[(g_player[screenpeek].ps->ang+512)&2047]>>9; - cloudy += sintable[g_player[screenpeek].ps->ang&2047]>>9; + g_cloudX += sintable[(g_player[screenpeek].ps->ang+512)&2047]>>9; + g_cloudY += sintable[g_player[screenpeek].ps->ang&2047]>>9; - for (i=g_numClouds-1; i>=0; i--) + for (i=g_cloudCnt-1; i>=0; i--) { - sector[clouds[i]].ceilingxpanning = cloudx>>6; - sector[clouds[i]].ceilingypanning = cloudy>>6; + sector[g_cloudSect[i]].ceilingxpanning = g_cloudX>>6; + sector[g_cloudSect[i]].ceilingypanning = g_cloudY>>6; } } @@ -616,7 +616,7 @@ static void G_PrintCoords(int32_t snum) const DukePlayer_t *ps = g_player[snum].ps; const int32_t sectnum = ps->cursectnum; - if ((GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) + if ((g_gametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) { if (ud.multimode > 4) y = 32; @@ -821,7 +821,7 @@ static void G_PrintFPS(void) if (thisSec - LastSec) { - g_currentFrameRate = LastCount = tabledivide32_noinline(FrameCount, thisSec - LastSec); + g_frameRate = LastCount = tabledivide32_noinline(FrameCount, thisSec - LastSec); LastSec = thisSec; FrameCount = 0; @@ -1046,8 +1046,8 @@ void G_DisplayRest(int32_t smoothratio) if (ud.overhead_on == 2) { const int32_t a = (ud.screen_size > 0) ? 147 : 179; - minitext(5, a+6, EpisodeNames[ud.volume_number], 0, 2+8+16+256); - minitext(5, a+6+6, aMapInfo[ud.volume_number*MAXLEVELS + ud.level_number].name, 0, 2+8+16+256); + minitext(5, a+6, g_volumeNames[ud.volume_number], 0, 2+8+16+256); + minitext(5, a+6+6, g_mapInfo[ud.volume_number*MAXLEVELS + ud.level_number].name, 0, 2+8+16+256); } } } @@ -1077,11 +1077,11 @@ void G_DisplayRest(int32_t smoothratio) else if (g_levelTextTime < 5) bits |= 1; - if (aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL) + if (g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL) { if (currentboardfilename[0] != 0 && ud.volume_number == 0 && ud.level_number == 7) menutext_(160, 90+16+8, -g_levelTextTime+22/*quotepulseshade*/, 0, currentboardfilename, bits); - else menutext_(160, 90+16+8, -g_levelTextTime+22/*quotepulseshade*/, 0, aMapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, bits); + else menutext_(160, 90+16+8, -g_levelTextTime+22/*quotepulseshade*/, 0, g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name, bits); } } @@ -1221,7 +1221,7 @@ void G_DisplayRest(int32_t smoothratio) { Bsprintf(tempbuf, "%s^00 has called a vote for map", g_player[voting].user_name); gametext(160, 40, tempbuf, 0, 2+8+16); - Bsprintf(tempbuf, "%s (E%dL%d)", aMapInfo[vote_episode*MAXLEVELS + vote_map].name, vote_episode+1, vote_map+1); + Bsprintf(tempbuf, "%s (E%dL%d)", g_mapInfo[vote_episode*MAXLEVELS + vote_map].name, vote_episode+1, vote_map+1); gametext(160, 48, tempbuf, 0, 2+8+16); gametext(160, 70, "Press F1 to Accept, F2 to Decline", 0, 2+8+16); } @@ -1451,7 +1451,7 @@ void G_DisplayLogo(void) if (logoflags & LOGO_PLAYMUSIC) { g_musicIndex = MUS_INTRO; - S_PlayMusic(aMapInfo[g_musicIndex].musicfn); + S_PlayMusic(g_mapInfo[g_musicIndex].musicfn); } if (!NAM) @@ -1971,18 +1971,18 @@ static void G_DisplayMPResultsScreen(void) if (PLUTOPAK) // JBF 20030804 rotatesprite_fs((260)<<16, 36<<16, 65536L, 0, PLUTOPAKSPRITE+2, 0, 0, 2+8); gametext(160, 58+2, "Multiplayer Totals", 0, 2+8+16); - gametext(160, 58+10, aMapInfo[G_LastMapInfoIndex()].name, 0, 2+8+16); + gametext(160, 58+10, g_mapInfo[G_LastMapInfoIndex()].name, 0, 2+8+16); gametext(160, 165, "Press any key or button to continue", quotepulseshade, 2+8+16); minitext(23, 80, " Name Kills", 8, 2+8+16+128); - for (i=0; ipalookup, 2+8+16+128); - for (y=0; yfraggedself; @@ -2037,11 +2037,11 @@ static int32_t G_PrintTime_ClockPad(void) clockpad = max(clockpad, ij); if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0])) { - for (ii=aMapInfo[G_LastMapInfoIndex()].partime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { } + for (ii=g_mapInfo[G_LastMapInfoIndex()].partime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { } clockpad = max(clockpad, ij); - if (!NAM_WW2GI && aMapInfo[G_LastMapInfoIndex()].designertime) + if (!NAM_WW2GI && g_mapInfo[G_LastMapInfoIndex()].designertime) { - for (ii=aMapInfo[G_LastMapInfoIndex()].designertime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { } + for (ii=g_mapInfo[G_LastMapInfoIndex()].designertime/(REALGAMETICSPERSEC*60), ij=1; ii>9; ii/=10, ij++) { } clockpad = max(clockpad, ij); } } @@ -2070,13 +2070,13 @@ const char* G_PrintParTime(void) { if (ud.last_level < 1) return ""; - return G_PrintTime2(aMapInfo[G_LastMapInfoIndex()].partime); + return G_PrintTime2(g_mapInfo[G_LastMapInfoIndex()].partime); } const char* G_PrintDesignerTime(void) { if (ud.last_level < 1) return ""; - return G_PrintTime2(aMapInfo[G_LastMapInfoIndex()].designertime); + return G_PrintTime2(g_mapInfo[G_LastMapInfoIndex()].designertime); } const char* G_PrintBestTime(void) { @@ -2103,9 +2103,9 @@ void G_BonusScreen(int32_t bonusonly) } else { - lastmapname = aMapInfo[G_LastMapInfoIndex()].name; + lastmapname = g_mapInfo[G_LastMapInfoIndex()].name; if (!lastmapname) // this isn't right but it's better than no name at all - lastmapname = aMapInfo[G_LastMapInfoIndex()].name; + lastmapname = g_mapInfo[G_LastMapInfoIndex()].name; } @@ -2133,7 +2133,7 @@ void G_BonusScreen(int32_t bonusonly) FX_StopAllSounds(); S_ClearSoundLocks(); - if (playerswhenstarted > 1 && (GametypeFlags[ud.coop]&GAMETYPE_SCORESHEET)) + if (g_mostConcurrentPlayers > 1 && (g_gametypeFlags[ud.coop]&GAMETYPE_SCORESHEET)) { clearallviews(0); G_DisplayMPResultsScreen(); @@ -2269,12 +2269,12 @@ void G_BonusScreen(int32_t bonusonly) yy+=10; if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0])) { - if (aMapInfo[G_LastMapInfoIndex()].partime) + if (g_mapInfo[G_LastMapInfoIndex()].partime) { gametext(10, yy+9, "Par Time:", 0, 2+8+16); yy+=10; } - if (!NAM_WW2GI && !DUKEBETA && aMapInfo[G_LastMapInfoIndex()].designertime) + if (!NAM_WW2GI && !DUKEBETA && g_mapInfo[G_LastMapInfoIndex()].designertime) { // EDuke 2.0 / NAM source suggests "Green Beret's Time:" gametext(10, yy+9, "3D Realms' Time:", 0, 2+8+16); @@ -2313,13 +2313,13 @@ void G_BonusScreen(int32_t bonusonly) if (!(ud.volume_number == 0 && ud.last_level-1 == 7 && boardfilename[0])) { - if (aMapInfo[G_LastMapInfoIndex()].partime) + if (g_mapInfo[G_LastMapInfoIndex()].partime) { G_PrintParTime(); gametext((320>>2)+71, yy+9, tempbuf, 0, 2+8+16); yy+=10; } - if (!NAM_WW2GI && !DUKEBETA && aMapInfo[G_LastMapInfoIndex()].designertime) + if (!NAM_WW2GI && !DUKEBETA && g_mapInfo[G_LastMapInfoIndex()].designertime) { G_PrintDesignerTime(); gametext((320>>2)+71, yy+9, tempbuf, 0, 2+8+16); diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index cb881d09b..c37503492 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -27,21 +27,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // PRIMITIVE -static int32_t g_haltSoundHack = 0; +static int g_haltSoundHack = 0; -int32_t S_FindMusicSFX(int32_t sn, int32_t *sndptr) +int S_FindMusicSFX(int sectNum, int32_t *sndptr) { - int32_t i; - - for (SPRITES_OF_SECT(sn, i)) + for (bssize_t SPRITES_OF_SECT(sectNum, spriteNum)) { - const int32_t snd = sprite[i].lotag; + const int32_t snd = sprite[spriteNum].lotag; EDUKE32_STATIC_ASSERT(MAXSOUNDS >= 1000); - if (PN(i) == MUSICANDSFX && (unsigned)snd < 1000) // XXX: in other places, 999 + if (PN(spriteNum) == MUSICANDSFX && (unsigned)snd < 1000) // XXX: in other places, 999 { *sndptr = snd; - return i; + return spriteNum; } } @@ -50,383 +48,395 @@ int32_t S_FindMusicSFX(int32_t sn, int32_t *sndptr) } // this function activates a sector's MUSICANDSFX sprite -int32_t A_CallSound(int32_t sn, int32_t whatsprite) +int A_CallSound(int sectNum, int spriteNum) { - int32_t i, snd; - if (g_haltSoundHack) { g_haltSoundHack = 0; return -1; } - i = S_FindMusicSFX(sn, &snd); + int32_t soundNum; + int const SFXsprite = S_FindMusicSFX(sectNum, &soundNum); - if (i >= 0) + if (SFXsprite >= 0) { - if (whatsprite == -1) - whatsprite = i; + if (spriteNum == -1) + spriteNum = SFXsprite; - if (T1(i) == 0) + if (T1(SFXsprite) == 0) { - if ((g_sounds[snd].m & SF_GLOBAL) == 0) + if ((g_sounds[soundNum].m & SF_GLOBAL) == 0) { - if (snd) + if (soundNum) { - A_PlaySound(snd, whatsprite); - if (SHT(i) && snd != SHT(i) && SHT(i) < MAXSOUNDS) - S_StopEnvSound(SHT(i),T6(i)); - T6(i) = whatsprite; + A_PlaySound(soundNum, spriteNum); + + if (SHT(SFXsprite) && soundNum != SHT(SFXsprite) && SHT(SFXsprite) < MAXSOUNDS) + S_StopEnvSound(SHT(SFXsprite),T6(SFXsprite)); + + T6(SFXsprite) = spriteNum; } - if ((sector[SECT(i)].lotag&0xff) != ST_22_SPLITTING_DOOR) - T1(i) = 1; + if ((sector[SECT(SFXsprite)].lotag&0xff) != ST_22_SPLITTING_DOOR) + T1(SFXsprite) = 1; } } - else if (SHT(i) < MAXSOUNDS) + else if (SHT(SFXsprite) < MAXSOUNDS) { - if (SHT(i)) - A_PlaySound(SHT(i), whatsprite); - if ((g_sounds[snd].m & SF_LOOP) || (SHT(i) && SHT(i) != snd)) - S_StopEnvSound(snd, T6(i)); - T6(i) = whatsprite; - T1(i) = 0; + if (SHT(SFXsprite)) + A_PlaySound(SHT(SFXsprite), spriteNum); + + if ((g_sounds[soundNum].m & SF_LOOP) || (SHT(SFXsprite) && SHT(SFXsprite) != soundNum)) + S_StopEnvSound(soundNum, T6(SFXsprite)); + + T6(SFXsprite) = spriteNum; + T1(SFXsprite) = 0; } - return snd; + return soundNum; } return -1; } -int32_t G_CheckActivatorMotion(int32_t lotag) +int G_CheckActivatorMotion(int lotag) { - int32_t i = headspritestat[STAT_ACTIVATOR], j; - spritetype *s; + int spriteNum = headspritestat[STAT_ACTIVATOR]; - while (i >= 0) + while (spriteNum >= 0) { - if (sprite[i].lotag == lotag) + if (sprite[spriteNum].lotag == lotag) { - s = &sprite[i]; + spritetype *const pSprite = &sprite[spriteNum]; - for (j = g_animateCount-1; j >= 0; j--) - if (s->sectnum == animatesect[j]) + for (bssize_t j = g_animateCnt - 1; j >= 0; j--) + if (pSprite->sectnum == g_animateSect[j]) return 1; - j = headspritestat[STAT_EFFECTOR]; - while (j >= 0) - { - if (s->sectnum == sprite[j].sectnum) - switch (sprite[j].lotag) - { - case SE_11_SWINGING_DOOR: - case SE_30_TWO_WAY_TRAIN: - if (actor[j].t_data[4]) - return 1; - break; - case SE_20_STRETCH_BRIDGE: - case SE_31_FLOOR_RISE_FALL: - case SE_32_CEILING_RISE_FALL: - case SE_18_INCREMENTAL_SECTOR_RISE_FALL: - if (actor[j].t_data[0]) - return 1; - break; - } + int sectorEffector = headspritestat[STAT_EFFECTOR]; - j = nextspritestat[j]; + while (sectorEffector >= 0) + { + if (pSprite->sectnum == sprite[sectorEffector].sectnum) + { + switch (sprite[sectorEffector].lotag) + { + case SE_11_SWINGING_DOOR: + case SE_30_TWO_WAY_TRAIN: + if (actor[sectorEffector].t_data[4]) + return 1; + break; + case SE_20_STRETCH_BRIDGE: + case SE_31_FLOOR_RISE_FALL: + case SE_32_CEILING_RISE_FALL: + case SE_18_INCREMENTAL_SECTOR_RISE_FALL: + if (actor[sectorEffector].t_data[0]) + return 1; + break; + } + } + + sectorEffector = nextspritestat[sectorEffector]; } } - i = nextspritestat[i]; + spriteNum = nextspritestat[spriteNum]; } return 0; } -int32_t CheckDoorTile(int32_t dapic) +int CheckDoorTile(int tileNum) { - switch (DYNAMICTILEMAP(dapic)) + switch (DYNAMICTILEMAP(tileNum)) { - case DOORTILE1__STATIC: - case DOORTILE2__STATIC: - case DOORTILE3__STATIC: - case DOORTILE4__STATIC: - case DOORTILE5__STATIC: - case DOORTILE6__STATIC: - case DOORTILE7__STATIC: - case DOORTILE8__STATIC: - case DOORTILE9__STATIC: - case DOORTILE10__STATIC: - case DOORTILE11__STATIC: - case DOORTILE12__STATIC: - case DOORTILE14__STATIC: - case DOORTILE15__STATIC: - case DOORTILE16__STATIC: - case DOORTILE17__STATIC: - case DOORTILE18__STATIC: - case DOORTILE19__STATIC: - case DOORTILE20__STATIC: - case DOORTILE21__STATIC: - case DOORTILE22__STATIC: - case DOORTILE23__STATIC: - return 1; + case DOORTILE1__STATIC: + case DOORTILE2__STATIC: + case DOORTILE3__STATIC: + case DOORTILE4__STATIC: + case DOORTILE5__STATIC: + case DOORTILE6__STATIC: + case DOORTILE7__STATIC: + case DOORTILE8__STATIC: + case DOORTILE9__STATIC: + case DOORTILE10__STATIC: + case DOORTILE11__STATIC: + case DOORTILE12__STATIC: + case DOORTILE14__STATIC: + case DOORTILE15__STATIC: + case DOORTILE16__STATIC: + case DOORTILE17__STATIC: + case DOORTILE18__STATIC: + case DOORTILE19__STATIC: + case DOORTILE20__STATIC: + case DOORTILE21__STATIC: + case DOORTILE22__STATIC: + case DOORTILE23__STATIC: + return 1; } return 0; } -int32_t isanunderoperator(int32_t lotag) +int isanunderoperator(int lotag) { - switch (lotag&0xff) + switch (lotag & 0xff) { - case ST_15_WARP_ELEVATOR: - case ST_16_PLATFORM_DOWN: - case ST_17_PLATFORM_UP: - case ST_18_ELEVATOR_DOWN: - case ST_19_ELEVATOR_UP: - case ST_22_SPLITTING_DOOR: - case ST_26_SPLITTING_ST_DOOR: - return 1; + case ST_15_WARP_ELEVATOR: + case ST_16_PLATFORM_DOWN: + case ST_17_PLATFORM_UP: + case ST_18_ELEVATOR_DOWN: + case ST_19_ELEVATOR_UP: + case ST_22_SPLITTING_DOOR: + case ST_26_SPLITTING_ST_DOOR: + return 1; } return 0; } -int32_t isanearoperator(int32_t lotag) +int isanearoperator(int lotag) { - switch (lotag&0xff) + switch (lotag & 0xff) { - case ST_9_SLIDING_ST_DOOR: - case ST_15_WARP_ELEVATOR: - case ST_16_PLATFORM_DOWN: - case ST_17_PLATFORM_UP: - case ST_18_ELEVATOR_DOWN: - case ST_19_ELEVATOR_UP: - case ST_20_CEILING_DOOR: - case ST_21_FLOOR_DOOR: - case ST_22_SPLITTING_DOOR: - case ST_23_SWINGING_DOOR: - case ST_25_SLIDING_DOOR: - case ST_26_SPLITTING_ST_DOOR: - case ST_29_TEETH_DOOR://Toothed door - return 1; + case ST_9_SLIDING_ST_DOOR: + case ST_15_WARP_ELEVATOR: + case ST_16_PLATFORM_DOWN: + case ST_17_PLATFORM_UP: + case ST_18_ELEVATOR_DOWN: + case ST_19_ELEVATOR_UP: + case ST_20_CEILING_DOOR: + case ST_21_FLOOR_DOOR: + case ST_22_SPLITTING_DOOR: + case ST_23_SWINGING_DOOR: + case ST_25_SLIDING_DOOR: + case ST_26_SPLITTING_ST_DOOR: + case ST_29_TEETH_DOOR: + return 1; } return 0; } -static inline int32_t A_FP_ManhattanDist(const DukePlayer_t *ps, const spritetype *s) +static inline int32_t A_FP_ManhattanDist(const DukePlayer_t *pPlayer, const spritetype *pSprite) { - return klabs(ps->opos.x-s->x) - + klabs(ps->opos.y-s->y) - + ((klabs(ps->opos.z-s->z+(28<<8)))>>4); + return klabs(pPlayer->opos.x - pSprite->x) + + klabs(pPlayer->opos.y - pSprite->y) + + ((klabs(pPlayer->opos.z - pSprite->z + (28 << 8))) >> 4); } -int32_t __fastcall A_FindPlayer(const spritetype *s, int32_t *d) +int __fastcall A_FindPlayer(const spritetype *pSprite, int32_t *dist) { if (!g_netServer && ud.multimode < 2) { - DukePlayer_t *const myps = g_player[myconnectindex].ps; + DukePlayer_t *const pPlayer = g_player[myconnectindex].ps; + + if (dist) + *dist = A_FP_ManhattanDist(pPlayer, pSprite); - if (d) - *d = A_FP_ManhattanDist(myps, s); return myconnectindex; } + int closestPlayer = 0; + int32_t closestPlayerDist = INT32_MAX; + + for (bssize_t TRAVERSE_CONNECT(j)) { - int32_t j; - int32_t closest_player=0, closest=INT32_MAX; + DukePlayer_t *const pPlayer = g_player[j].ps; + int32_t playerDist = A_FP_ManhattanDist(pPlayer, pSprite); - for (TRAVERSE_CONNECT(j)) + if (playerDist < closestPlayerDist && sprite[pPlayer->i].extra > 0) { - DukePlayer_t *const ps = g_player[j].ps; - int32_t x = A_FP_ManhattanDist(ps, s); - - if (x < closest && sprite[ps->i].extra > 0) - { - closest_player = j; - closest = x; - } + closestPlayer = j; + closestPlayerDist = playerDist; } - - if (d) - *d = closest; - return closest_player; } + + if (dist) + *dist = closestPlayerDist; + + return closestPlayer; } void G_DoSectorAnimations(void) { - int32_t i, j, a, p, v, dasect; - - for (i=g_animateCount-1; i>=0; i--) + for (bssize_t animNum=g_animateCnt-1; animNum>=0; animNum--) { - a = *animateptr[i]; - v = animatevel[i]*TICSPERFRAME; - dasect = animatesect[i]; + int animPos = *g_animatePtr[animNum]; + int const animVel = g_animateVel[animNum] * TICSPERFRAME; + int const animSect = g_animateSect[animNum]; - if (a == animategoal[i]) + if (animPos == g_animateGoal[animNum]) { - G_StopInterpolation(animateptr[i]); + G_StopInterpolation(g_animatePtr[animNum]); // This fixes a bug where wall or floor sprites contained in // elevator sectors (ST 16-19) would jitter vertically after the // elevator had stopped. - if (animateptr[i] == §or[animatesect[i]].floorz) - for (j=headspritesect[dasect]; j>=0; j=nextspritesect[j]) + if (g_animatePtr[animNum] == §or[g_animateSect[animNum]].floorz) + { + for (bssize_t j=headspritesect[animSect]; j>=0; j=nextspritesect[j]) + { if (sprite[j].statnum != STAT_EFFECTOR) actor[j].bpos.z = sprite[j].z; + } + } - g_animateCount--; - animateptr[i] = animateptr[g_animateCount]; - animategoal[i] = animategoal[g_animateCount]; - animatevel[i] = animatevel[g_animateCount]; - animatesect[i] = animatesect[g_animateCount]; - if (sector[animatesect[i]].lotag == ST_18_ELEVATOR_DOWN || sector[animatesect[i]].lotag == ST_19_ELEVATOR_UP) - if (animateptr[i] == §or[animatesect[i]].ceilingz) - continue; + g_animateCnt--; - if ((sector[dasect].lotag&0xff) != ST_22_SPLITTING_DOOR) - A_CallSound(dasect,-1); + g_animatePtr[animNum] = g_animatePtr[g_animateCnt]; + g_animateGoal[animNum] = g_animateGoal[g_animateCnt]; + g_animateVel[animNum] = g_animateVel[g_animateCnt]; + g_animateSect[animNum] = g_animateSect[g_animateCnt]; + + if ((sector[g_animateSect[animNum]].lotag == ST_18_ELEVATOR_DOWN || sector[g_animateSect[animNum]].lotag == ST_19_ELEVATOR_UP) + && (g_animatePtr[animNum] == §or[g_animateSect[animNum]].ceilingz)) + continue; + + if ((sector[animSect].lotag&0xff) != ST_22_SPLITTING_DOOR) + A_CallSound(animSect,-1); continue; } - if (v > 0) - a = min(a+v, animategoal[i]); - else - a = max(a+v, animategoal[i]); + animPos = (animVel > 0) ? min(animPos + animVel, g_animateGoal[animNum]) + : max(animPos + animVel, g_animateGoal[animNum]); - if (animateptr[i] == §or[animatesect[i]].floorz) + if (g_animatePtr[animNum] == §or[g_animateSect[animNum]].floorz) { - for (TRAVERSE_CONNECT(p)) - if (g_player[p].ps->cursectnum == dasect) - if ((sector[dasect].floorz-g_player[p].ps->pos.z) < (64<<8)) - if (sprite[g_player[p].ps->i].owner >= 0) - { - g_player[p].ps->pos.z += v; - g_player[p].ps->vel.z = 0; -/* - if (p == myconnectindex) - { - my.z += v; - myvel.z = 0; - } -*/ - } + for (bssize_t TRAVERSE_CONNECT(playerNum)) + { + if ((g_player[playerNum].ps->cursectnum == animSect) + && ((sector[animSect].floorz - g_player[playerNum].ps->pos.z) < (64 << 8)) + && (sprite[g_player[playerNum].ps->i].owner >= 0)) + { + g_player[playerNum].ps->pos.z += animVel; + g_player[playerNum].ps->vel.z = 0; + /* + if (p == myconnectindex) + { + my.z += v; + myvel.z = 0; + } + */ + } + } - for (j=headspritesect[dasect]; j>=0; j=nextspritesect[j]) + for (bssize_t j=headspritesect[animSect]; j>=0; j=nextspritesect[j]) + { if (sprite[j].statnum != STAT_EFFECTOR) { actor[j].bpos.z = sprite[j].z; - sprite[j].z += v; - actor[j].floorz = sector[dasect].floorz+v; + sprite[j].z += animVel; + actor[j].floorz = sector[animSect].floorz+animVel; } + } } - *animateptr[i] = a; + *g_animatePtr[animNum] = animPos; } } -int32_t GetAnimationGoal(const int32_t *animptr) +int GetAnimationGoal(const int32_t *animPtr) { - int32_t i=0; - - for (; i= MAXANIMATES) + if (g_animateCnt >= MAXANIMATES) return -1; - for (; i= *animptr) ? thevel : -thevel; + g_animateSect[animNum] = sectNum; + g_animatePtr[animNum] = animPtr; + g_animateGoal[animNum] = goalVal; + g_animateVel[animNum] = (goalVal >= *animPtr) ? animVel : -animVel; - if (j == g_animateCount) - g_animateCount++; + if (animNum == g_animateCnt) + g_animateCnt++; - G_SetInterpolation(animptr); + G_SetInterpolation(animPtr); - return j; + return animNum; } -static void G_SetupCamTile(int32_t i, int32_t wn, int32_t smoothratio) +static void G_SetupCamTile(int spriteNum, int tileNum, int smoothRatio) { - vec3_t cam = G_GetCameraPosition(i, smoothratio); + vec3_t const camera = G_GetCameraPosition(spriteNum, smoothRatio); + int const saveMirror = display_mirror; - const int32_t mir = display_mirror; //if (waloff[wn] == 0) loadtile(wn); - setviewtotile(wn, tilesiz[wn].y, tilesiz[wn].x); + setviewtotile(tileNum, tilesiz[tileNum].y, tilesiz[tileNum].x); yax_preparedrawrooms(); - drawrooms(cam.x, cam.y, cam.z, SA(i), 100+sprite[i].shade, SECT(i)); - yax_drawrooms(G_DoSpriteAnimations, SECT(i), 0, smoothratio); + drawrooms(camera.x, camera.y, camera.z, SA(spriteNum), 100 + sprite[spriteNum].shade, SECT(spriteNum)); + yax_drawrooms(G_DoSpriteAnimations, SECT(spriteNum), 0, smoothRatio); display_mirror = 3; - G_DoSpriteAnimations(cam.x, cam.y, SA(i), smoothratio); - display_mirror = mir; + G_DoSpriteAnimations(camera.x, camera.y, SA(spriteNum), smoothRatio); + display_mirror = saveMirror; drawmasks(); setviewback(); - squarerotatetile(wn); - invalidatetile(wn, -1, 255); + squarerotatetile(tileNum); + invalidatetile(tileNum, -1, 255); } -void G_AnimateCamSprite(int32_t smoothratio) +void G_AnimateCamSprite(int smoothRatio) { - const int32_t i = g_curViewscreen; - #ifdef DEBUG_VALGRIND_NO_SMC return; #endif + if (g_curViewscreen < 0) return; - if (totalclock >= T1(i) + ud.camera_time) + int const spriteNum = g_curViewscreen; + + if (totalclock >= T1(spriteNum) + ud.camera_time) { - const DukePlayer_t *const ps = g_player[screenpeek].ps; + DukePlayer_t const *const pPlayer = g_player[screenpeek].ps; - if (ps->newowner >= 0) - OW(i) = ps->newowner; + if (pPlayer->newowner >= 0) + OW(spriteNum) = pPlayer->newowner; - if (OW(i) >= 0 && dist(&sprite[ps->i], &sprite[i]) < VIEWSCREEN_ACTIVE_DISTANCE) + if (OW(spriteNum) >= 0 && dist(&sprite[pPlayer->i], &sprite[spriteNum]) < VIEWSCREEN_ACTIVE_DISTANCE) { - const int viewscrShift = G_GetViewscreenSizeShift((const uspritetype *)&sprite[i]); - const int viewscrTile = TILE_VIEWSCR-viewscrShift; + int const viewscrShift = G_GetViewscreenSizeShift((const uspritetype *)&sprite[spriteNum]); + int const viewscrTile = TILE_VIEWSCR - viewscrShift; if (waloff[viewscrTile] == 0) - allocatepermanenttile(viewscrTile, tilesiz[PN(i)].x<=0; p--) + for (bssize_t animwallNum = g_animWallCnt-1; animwallNum>=0; animwallNum--) { - int const wallNum = animwall[p].wallnum; + int const wallNum = animwall[animwallNum].wallnum; switch (DYNAMICTILEMAP(wall[wallNum].picnum)) { @@ -449,17 +459,16 @@ void G_AnimateWalls(void) case SCREENBREAK19__STATIC: if ((krand()&255) < 16) { - animwall[p].tag = wall[wallNum].picnum; + animwall[animwallNum].tag = wall[wallNum].picnum; wall[wallNum].picnum = SCREENBREAK6; } - continue; case SCREENBREAK6__STATIC: case SCREENBREAK7__STATIC: case SCREENBREAK8__STATIC: - if (animwall[p].tag >= 0 && wall[wallNum].extra != FEMPIC2 && wall[wallNum].extra != FEMPIC3) - wall[wallNum].picnum = animwall[p].tag; + if (animwall[animwallNum].tag >= 0 && wall[wallNum].extra != FEMPIC2 && wall[wallNum].extra != FEMPIC3) + wall[wallNum].picnum = animwall[animwallNum].tag; else { wall[wallNum].picnum++; @@ -471,7 +480,7 @@ void G_AnimateWalls(void) if ((wall[wallNum].cstat&16) && G_GetForcefieldPicnum(wallNum)==W_FORCEFIELD) { - int const wallTag = animwall[p].tag; + int const wallTag = animwall[animwallNum].tag; if (wall[wallNum].cstat&254) { @@ -481,19 +490,18 @@ void G_AnimateWalls(void) if (wall[wallNum].extra == 1) { wall[wallNum].extra = 0; - animwall[p].tag = 0; + animwall[animwallNum].tag = 0; } - else - animwall[p].tag+=128; + else animwall[animwallNum].tag += 128; - if (animwall[p].tag < (128<<4)) + if (animwall[animwallNum].tag < (128 << 4)) { - wall[wallNum].overpicnum = (animwall[p].tag & 128) ? W_FORCEFIELD : W_FORCEFIELD + 1; + wall[wallNum].overpicnum = (animwall[animwallNum].tag & 128) ? W_FORCEFIELD : W_FORCEFIELD + 1; } else { if ((krand()&255) < 32) - animwall[p].tag = 128<<(krand()&3); + animwall[animwallNum].tag = 128<<(krand()&3); else wall[wallNum].overpicnum = W_FORCEFIELD+1; } } @@ -501,27 +509,27 @@ void G_AnimateWalls(void) } } -int32_t G_ActivateWarpElevators(int32_t s, int32_t d) //Parm = sectoreffectornum +int G_ActivateWarpElevators(int spriteNum, int warpDir) { - int32_t i; - const int32_t sn = sprite[s].sectnum; + bssize_t i; + int const sectNum = sprite[spriteNum].sectnum; for (SPRITES_OF(STAT_EFFECTOR, i)) - if (SLT(i) == SE_17_WARP_ELEVATOR && SHT(i) == sprite[s].hitag) + if (SLT(i) == SE_17_WARP_ELEVATOR && SHT(i) == sprite[spriteNum].hitag) { - if (klabs(sector[sn].floorz - actor[s].t_data[2]) > SP(i) || - sector[SECT(i)].hitag == sector[sn].hitag - d) + if (klabs(sector[sectNum].floorz - actor[spriteNum].t_data[2]) > SP(i) || + sector[SECT(i)].hitag == sector[sectNum].hitag - warpDir) break; } if (i == -1) return 1; // No find - A_PlaySound(d ? ELEVATOR_ON : ELEVATOR_OFF, s); + A_PlaySound(warpDir ? ELEVATOR_ON : ELEVATOR_OFF, spriteNum); for (SPRITES_OF(STAT_EFFECTOR, i)) - if (SLT(i) == SE_17_WARP_ELEVATOR && SHT(i) == sprite[s].hitag) - T1(i) = T2(i) = d; //Make all check warp + if (SLT(i) == SE_17_WARP_ELEVATOR && SHT(i) == sprite[spriteNum].hitag) + T1(i) = T2(i) = warpDir; //Make all check warp return 0; } @@ -574,32 +582,29 @@ void G_OperateSectors(int sectNum, int spriteNum) case ST_9_SLIDING_ST_DOOR: { - int32_t wallfind[2]; - - const int32_t startwall = pSector->wallptr; - const int32_t endwall = startwall+pSector->wallnum-1; - - const int32_t sp = pSector->extra>>4; + int const startWall = pSector->wallptr; + int const endWall = startWall + pSector->wallnum - 1; + int const doorSpeed = pSector->extra >> 4; //first find center point by averaging all points vec2_t vect = { 0, 0 }; - for (i = startwall; i <= endwall; i++) + for (i = startWall; i <= endWall; i++) { vect.x += wall[i].x; vect.y += wall[i].y; } - vect.x = tabledivide32_noinline(vect.x, (endwall-startwall+1)); - vect.y = tabledivide32_noinline(vect.y, (endwall-startwall+1)); + vect.x = tabledivide32_noinline(vect.x, (endWall-startWall+1)); + vect.y = tabledivide32_noinline(vect.y, (endWall-startWall+1)); //find any points with either same x or same y coordinate // as center (dax, day) - should be 2 points found. - wallfind[0] = -1; - wallfind[1] = -1; - for (i = startwall; i <= endwall; i++) + int wallfind[2] = { -1, -1 }; + + for (i = startWall; i <= endWall; i++) { if (wall[i].x == vect.x || wall[i].y == vect.y) { @@ -615,54 +620,54 @@ void G_OperateSectors(int sectNum, int spriteNum) for (j=0; j<2; j++) { - int const nFoundWall = wallfind[j]; + int const foundWall = wallfind[j]; - i = nFoundWall - 1; + i = foundWall - 1; - if (i < startwall) - i = endwall; + if (i < startWall) + i = endWall; - vec2_t vect2 = { ((wall[i].x + wall[wall[nFoundWall].point2].x) >> 1) - wall[nFoundWall].x, - ((wall[i].y + wall[wall[nFoundWall].point2].y) >> 1) - wall[nFoundWall].y }; + vec2_t vect2 = { ((wall[i].x + wall[wall[foundWall].point2].x) >> 1) - wall[foundWall].x, + ((wall[i].y + wall[wall[foundWall].point2].y) >> 1) - wall[foundWall].y }; - if (wall[nFoundWall].x == vect.x && wall[nFoundWall].y == vect.y) + if (wall[foundWall].x == vect.x && wall[foundWall].y == vect.y) { //find what direction door should open by averaging the // 2 neighboring points of wallfind[0] & wallfind[1]. if (vect2.x != 0) { - vect2.x = wall[wall[wall[nFoundWall].point2].point2].x; - vect2.x -= wall[wall[nFoundWall].point2].x; - SetAnimation(sectNum,&wall[nFoundWall].x,wall[nFoundWall].x+vect2.x,sp); - SetAnimation(sectNum,&wall[i].x,wall[i].x+vect2.x,sp); - SetAnimation(sectNum,&wall[wall[nFoundWall].point2].x,wall[wall[nFoundWall].point2].x+vect2.x,sp); - A_CallSound(sectNum,spriteNum); + vect2.x = wall[wall[wall[foundWall].point2].point2].x; + vect2.x -= wall[wall[foundWall].point2].x; + SetAnimation(sectNum, &wall[foundWall].x, wall[foundWall].x + vect2.x, doorSpeed); + SetAnimation(sectNum, &wall[i].x, wall[i].x + vect2.x, doorSpeed); + SetAnimation(sectNum, &wall[wall[foundWall].point2].x, wall[wall[foundWall].point2].x + vect2.x, doorSpeed); + A_CallSound(sectNum, spriteNum); } else if (vect2.y != 0) { - vect2.y = wall[wall[wall[nFoundWall].point2].point2].y; - vect2.y -= wall[wall[nFoundWall].point2].y; - SetAnimation(sectNum,&wall[nFoundWall].y,wall[nFoundWall].y+vect2.y,sp); - SetAnimation(sectNum,&wall[i].y,wall[i].y+vect2.y,sp); - SetAnimation(sectNum,&wall[wall[nFoundWall].point2].y,wall[wall[nFoundWall].point2].y+vect2.y,sp); - A_CallSound(sectNum,spriteNum); + vect2.y = wall[wall[wall[foundWall].point2].point2].y; + vect2.y -= wall[wall[foundWall].point2].y; + SetAnimation(sectNum, &wall[foundWall].y, wall[foundWall].y + vect2.y, doorSpeed); + SetAnimation(sectNum, &wall[i].y, wall[i].y + vect2.y, doorSpeed); + SetAnimation(sectNum, &wall[wall[foundWall].point2].y, wall[wall[foundWall].point2].y + vect2.y, doorSpeed); + A_CallSound(sectNum, spriteNum); } } else { if (vect2.x != 0) { - SetAnimation(sectNum,&wall[nFoundWall].x,vect.x,sp); - SetAnimation(sectNum,&wall[i].x,vect.x+vect2.x,sp); - SetAnimation(sectNum,&wall[wall[nFoundWall].point2].x,vect.x+vect2.x,sp); - A_CallSound(sectNum,spriteNum); + SetAnimation(sectNum, &wall[foundWall].x, vect.x, doorSpeed); + SetAnimation(sectNum, &wall[i].x, vect.x + vect2.x, doorSpeed); + SetAnimation(sectNum, &wall[wall[foundWall].point2].x, vect.x + vect2.x, doorSpeed); + A_CallSound(sectNum, spriteNum); } else if (vect2.y != 0) { - SetAnimation(sectNum,&wall[nFoundWall].y,vect.y,sp); - SetAnimation(sectNum,&wall[i].y,vect.y+vect2.y,sp); - SetAnimation(sectNum,&wall[wall[nFoundWall].point2].y,vect.y+vect2.y,sp); - A_CallSound(sectNum,spriteNum); + SetAnimation(sectNum, &wall[foundWall].y, vect.y, doorSpeed); + SetAnimation(sectNum, &wall[i].y, vect.y + vect2.y, doorSpeed); + SetAnimation(sectNum, &wall[wall[foundWall].point2].y, vect.y + vect2.y, doorSpeed); + A_CallSound(sectNum, spriteNum); } } } @@ -740,11 +745,11 @@ void G_OperateSectors(int sectNum, int spriteNum) j = sector[i].floorz; - int const nSectorExtra = pSector->extra; - int const nZdiff = pSector->ceilingz - pSector->floorz; + int const sectorExtra = pSector->extra; + int const zDiff = pSector->ceilingz - pSector->floorz; - SetAnimation(sectNum, &pSector->floorz, j, nSectorExtra); - SetAnimation(sectNum, &pSector->ceilingz, j + nZdiff, nSectorExtra); + SetAnimation(sectNum, &pSector->floorz, j, sectorExtra); + SetAnimation(sectNum, &pSector->ceilingz, j + zDiff, sectorExtra); A_CallSound(sectNum, spriteNum); } return; @@ -829,9 +834,9 @@ REDODOOR: i = GetAnimationGoal(&pSector->floorz); if (i >= 0) { - if (animategoal[sectNum] == pSector->ceilingz) - animategoal[i] = sector[nextsectorneighborz(sectNum,pSector->ceilingz,1,1)].floorz; - else animategoal[i] = pSector->ceilingz; + if (g_animateGoal[sectNum] == pSector->ceilingz) + g_animateGoal[i] = sector[nextsectorneighborz(sectNum,pSector->ceilingz,1,1)].floorz; + else g_animateGoal[i] = pSector->ceilingz; } else { @@ -850,24 +855,25 @@ REDODOOR: if (pSector->lotag&0x8000) { - int32_t q = (pSector->ceilingz+pSector->floorz)>>1; + // WTF? + int const q = (pSector->ceilingz + pSector->floorz) >> 1; j = SetAnimation(sectNum, &pSector->floorz, q, pSector->extra); j = SetAnimation(sectNum, &pSector->ceilingz, q, pSector->extra); } else { - int32_t fneigh = nextsectorneighborz(sectNum, pSector->floorz, 1, 1); - int32_t cneigh = nextsectorneighborz(sectNum, pSector->ceilingz, -1, -1); + int const floorNeighbor = nextsectorneighborz(sectNum, pSector->floorz, 1, 1); + int const ceilingNeighbor = nextsectorneighborz(sectNum, pSector->ceilingz, -1, -1); - if (fneigh>=0 && cneigh>=0) + if (floorNeighbor>=0 && ceilingNeighbor>=0) { - j = SetAnimation(sectNum, &pSector->floorz, sector[fneigh].floorz, pSector->extra); - j = SetAnimation(sectNum, &pSector->ceilingz, sector[cneigh].ceilingz, pSector->extra); + j = SetAnimation(sectNum, &pSector->floorz, sector[floorNeighbor].floorz, pSector->extra); + j = SetAnimation(sectNum, &pSector->ceilingz, sector[ceilingNeighbor].ceilingz, pSector->extra); } else { OSD_Printf("WARNING: ST22: null sector: floor neighbor=%d, ceiling neighbor=%d!\n", - fneigh, cneigh); + floorNeighbor, ceilingNeighbor); pSector->lotag ^= 0x8000; } } @@ -895,14 +901,15 @@ REDODOOR: return; } // JBF - int const nTag = sector[SECT(i)].lotag&0x8000; + int const tag = sector[SECT(i)].lotag&0x8000; if (j >= 0) { - int32_t playedsnd = 0; + int soundPlayed = 0; for (SPRITES_OF(STAT_EFFECTOR, i)) - if (nTag == (sector[SECT(i)].lotag&0x8000) && SLT(i) == SE_11_SWINGING_DOOR && sprite[j].hitag == SHT(i) && !T5(i)) + { + if (tag == (sector[SECT(i)].lotag&0x8000) && SLT(i) == SE_11_SWINGING_DOOR && sprite[j].hitag == SHT(i) && !T5(i)) { if (sector[SECT(i)].lotag&0x8000) sector[SECT(i)].lotag &= 0x7fff; else sector[SECT(i)].lotag |= 0x8000; @@ -910,12 +917,13 @@ REDODOOR: T5(i) = 1; T4(i) = -T4(i); - if (!playedsnd) + if (!soundPlayed) { A_CallSound(sectNum, i); - playedsnd = 1; + soundPlayed = 1; } } + } } } return; @@ -987,23 +995,21 @@ REDODOOR: } } -void G_OperateRespawns(int32_t low) +void G_OperateRespawns(int lotag) { - int32_t i, nexti; - - for (SPRITES_OF_STAT_SAFE(STAT_FX, i, nexti)) + for (bssize_t nextSprite, SPRITES_OF_STAT_SAFE(STAT_FX, spriteNum, nextSprite)) { - spritetype *respr = &sprite[i]; + spritetype * const pSprite = &sprite[spriteNum]; - if (respr->lotag == low && respr->picnum == RESPAWN) + if (pSprite->lotag == lotag && pSprite->picnum == RESPAWN) { - if (!ud.monsters_off || !A_CheckEnemyTile(respr->hitag)) + if (!ud.monsters_off || !A_CheckEnemyTile(pSprite->hitag)) { - int32_t j = A_Spawn(i, TRANSPORTERSTAR); + int const j = A_Spawn(spriteNum, TRANSPORTERSTAR); sprite[j].z -= ZOFFSET5; // Just a way to killit (see G_MoveFX(): RESPAWN__STATIC) - respr->extra = 66-12; + pSprite->extra = 66-12; } } } @@ -1011,73 +1017,74 @@ void G_OperateRespawns(int32_t low) void G_OperateActivators(int lotag, int playerNum) { - int32_t i, nexti, j, k; - - for (i=g_numCyclers-1; i>=0; i--) + for (bssize_t spriteNum=g_cyclerCnt-1; spriteNum>=0; spriteNum--) { - int16_t *const pCycler = &cyclers[i][0]; + int16_t *const pCycler = &g_cyclers[spriteNum][0]; if (pCycler[4] == lotag) { - pCycler[5] = !pCycler[5]; + pCycler[5] = !pCycler[5]; + sector[pCycler[0]].floorshade = pCycler[3]; + sector[pCycler[0]].ceilingshade = pCycler[3]; + walltype *pWall = &wall[sector[pCycler[0]].wallptr]; - sector[pCycler[0]].floorshade = sector[pCycler[0]].ceilingshade = pCycler[3]; - - walltype *pWall = &wall[sector[pCycler[0]].wallptr]; - - for (j = sector[pCycler[0]].wallnum; j > 0; j--, pWall++) + for (bsize_t j = sector[pCycler[0]].wallnum; j > 0; j--, pWall++) pWall->shade = pCycler[3]; } } - k = -1; + int soundPlayed = -1; - for (SPRITES_OF_STAT_SAFE(STAT_ACTIVATOR, i, nexti)) + for (bssize_t nextSprite, SPRITES_OF_STAT_SAFE(STAT_ACTIVATOR, spriteNum, nextSprite)) { - if (sprite[i].lotag == lotag) + if (sprite[spriteNum].lotag == lotag) { - if (sprite[i].picnum == ACTIVATORLOCKED) + if (sprite[spriteNum].picnum == ACTIVATORLOCKED) { - sector[SECT(i)].lotag ^= 16384; + sector[SECT(spriteNum)].lotag ^= 16384; if (playerNum >= 0 && playerNum < ud.multimode) - P_DoQuote((sector[SECT(i)].lotag & 16384) ? QUOTE_LOCKED : QUOTE_UNLOCKED, g_player[playerNum].ps); + P_DoQuote((sector[SECT(spriteNum)].lotag & 16384) ? QUOTE_LOCKED : QUOTE_UNLOCKED, g_player[playerNum].ps); } else { - switch (SHT(i)) + switch (SHT(spriteNum)) { case 1: - if (sector[SECT(i)].floorz != sector[SECT(i)].ceilingz) + if (sector[SECT(spriteNum)].floorz != sector[SECT(spriteNum)].ceilingz) continue; break; case 2: - if (sector[SECT(i)].floorz == sector[SECT(i)].ceilingz) + if (sector[SECT(spriteNum)].floorz == sector[SECT(spriteNum)].ceilingz) continue; break; } // ST_2_UNDERWATER - if (sector[sprite[i].sectnum].lotag < 3) + if (sector[sprite[spriteNum].sectnum].lotag < 3) { - for (SPRITES_OF_SECT(sprite[i].sectnum, j)) - if (sprite[j].statnum == STAT_EFFECTOR) - switch (sprite[j].lotag) + for (bssize_t SPRITES_OF_SECT(sprite[spriteNum].sectnum, foundSprite)) + { + if (sprite[foundSprite].statnum == STAT_EFFECTOR) + { + switch (sprite[foundSprite].lotag) { case SE_36_PROJ_SHOOTER: case SE_31_FLOOR_RISE_FALL: case SE_32_CEILING_RISE_FALL: case SE_18_INCREMENTAL_SECTOR_RISE_FALL: - actor[j].t_data[0] = 1 - actor[j].t_data[0]; - A_CallSound(SECT(i), j); + actor[foundSprite].t_data[0] = 1 - actor[foundSprite].t_data[0]; + A_CallSound(SECT(spriteNum), foundSprite); break; } + } + } } - if (k == -1 && (sector[SECT(i)].lotag&0xff) == ST_22_SPLITTING_DOOR) - k = A_CallSound(SECT(i),i); + if (soundPlayed == -1 && (sector[SECT(spriteNum)].lotag&0xff) == ST_22_SPLITTING_DOOR) + soundPlayed = A_CallSound(SECT(spriteNum),spriteNum); - G_OperateSectors(SECT(i),i); + G_OperateSectors(SECT(spriteNum),spriteNum); } } } @@ -1094,7 +1101,7 @@ void G_OperateMasterSwitches(int lotag) void G_OperateForceFields(int spriteNum, int wallTag) { - for (bssize_t animwallNum = 0; animwallNum < g_numAnimWalls; ++animwallNum) + for (bssize_t animwallNum = 0; animwallNum < g_animWallCnt; ++animwallNum) { int const wallNum = animwall[animwallNum].wallnum; @@ -1213,11 +1220,11 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType) // initprintf("P_ActivateSwitch called picnum=%i switchissprite=%i\n",picnum,switchissprite); - int nBasePicnum = G_GetBaseSwitch(nSwitchPicnum); - int nCorrectDips = 1; - int nNumDips = 0; + int basePicnum = G_GetBaseSwitch(nSwitchPicnum); + int correctDips = 1; + int numDips = 0; - switch (DYNAMICTILEMAP(nBasePicnum)) + switch (DYNAMICTILEMAP(basePicnum)) { case DIPSWITCH_LIKE_CASES: break; @@ -1270,23 +1277,23 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType) { // Put the tile number into a variable so later switches don't // trigger on the result of changes: - int const nSpritePicnum = PN(spriteNum); + int const spritePic = PN(spriteNum); - if (nSpritePicnum >= MULTISWITCH && nSpritePicnum <= MULTISWITCH+3) + if (spritePic >= MULTISWITCH && spritePic <= MULTISWITCH+3) { sprite[spriteNum].picnum++; if (sprite[spriteNum].picnum > MULTISWITCH+3) sprite[spriteNum].picnum = MULTISWITCH; } - switch (DYNAMICTILEMAP(nSpritePicnum)) + switch (DYNAMICTILEMAP(spritePic)) { case DIPSWITCH_LIKE_CASES: if (switchType == SWITCH_SPRITE && wallOrSprite == spriteNum) PN(spriteNum)++; else if (SHT(spriteNum) == 0) - nCorrectDips++; - nNumDips++; + correctDips++; + numDips++; break; case ACCESSSWITCH_CASES: @@ -1295,17 +1302,17 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType) break; default: - if (nSpritePicnum <= 0) // oob safety + if (spritePic <= 0) // oob safety break; - switch (DYNAMICTILEMAP(nSpritePicnum - 1)) + switch (DYNAMICTILEMAP(spritePic - 1)) { case DIPSWITCH_LIKE_CASES: if (switchType == SWITCH_SPRITE && wallOrSprite == spriteNum) PN(spriteNum)--; else if (SHT(spriteNum) == 1) - nCorrectDips++; - nNumDips++; + correctDips++; + numDips++; break; case REST_SWITCH_CASES: @@ -1334,8 +1341,8 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType) if (switchType == SWITCH_WALL && wallNum == wallOrSprite) wall[wallNum].picnum++; else if (wall[wallNum].hitag == 0) - nCorrectDips++; - nNumDips++; + correctDips++; + numDips++; break; case ACCESSSWITCH_CASES: @@ -1353,8 +1360,8 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType) if (switchType == SWITCH_WALL && wallNum == wallOrSprite) wall[wallNum].picnum--; else if (wall[wallNum].hitag == 1) - nCorrectDips++; - nNumDips++; + correctDips++; + numDips++; break; case REST_SWITCH_CASES: @@ -1372,9 +1379,9 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType) return 1; } - nBasePicnum = G_GetBaseSwitch(nSwitchPicnum); + basePicnum = G_GetBaseSwitch(nSwitchPicnum); - switch (DYNAMICTILEMAP(nBasePicnum)) + switch (DYNAMICTILEMAP(basePicnum)) { default: if (CheckDoorTile(nSwitchPicnum) == 0) @@ -1386,7 +1393,7 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType) S_PlaySound3D((nSwitchPicnum == ALIENSWITCH || nSwitchPicnum == ALIENSWITCH + 1) ? ALIEN_SWITCH1 : SWITCH_ON, (switchType == SWITCH_SPRITE) ? wallOrSprite : g_player[playerNum].ps->i, &davector); - if (nNumDips != nCorrectDips) + if (numDips != correctDips) break; S_PlaySound3D(END_OF_LEVEL_WARN, g_player[playerNum].ps->i, &davector); @@ -1452,16 +1459,16 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType) void G_ActivateBySector(int sectNum, int spriteNum) { - int nActivatedSectors = 0; + int activatedSectors = 0; for (bssize_t SPRITES_OF_SECT(sectNum, i)) if (PN(i) == ACTIVATOR) { G_OperateActivators(SLT(i),-1); - ++nActivatedSectors; + ++activatedSectors; } - if (!nActivatedSectors) + if (!activatedSectors) G_OperateSectors(sectNum, spriteNum); } @@ -1531,18 +1538,18 @@ void A_DamageWall(int spriteNum, int wallNum, const vec3_t *vPos, int weaponNum) if (sectNum < 0) return; - int nXrepeat = 32; - int nYrepeat = 32; + int xRepeat = 32; + int yRepeat = 32; if (weaponNum == -1) - nXrepeat = nYrepeat = 8; + xRepeat = yRepeat = 8; else if (weaponNum == CHAINGUN) { - nXrepeat = 16 + sprite[spriteNum].xrepeat; - nYrepeat = 16 + sprite[spriteNum].yrepeat; + xRepeat = 16 + sprite[spriteNum].xrepeat; + yRepeat = 16 + sprite[spriteNum].yrepeat; } - int const i = A_InsertSprite(sectNum, vPos->x, vPos->y, vPos->z, FORCERIPPLE, -127, nXrepeat, nYrepeat, 0, + int const i = A_InsertSprite(sectNum, vPos->x, vPos->y, vPos->z, FORCERIPPLE, -127, xRepeat, yRepeat, 0, 0, 0, spriteNum, 5); CS(i) |= 18 + 128; @@ -1724,21 +1731,21 @@ void A_DamageWall(int spriteNum, int wallNum, const vec3_t *vPos, int weaponNum) if (sectNum < 0) return; - int nDarkestWall = 0; + int darkestWall = 0; pWall = &wall[sector[sectNum].wallptr]; for (bssize_t i = sector[sectNum].wallnum; i > 0; i--, pWall++) - if (pWall->shade > nDarkestWall) - nDarkestWall = pWall->shade; + if (pWall->shade > darkestWall) + darkestWall = pWall->shade; - int const nRand = krand() & 1; + int const random = krand() & 1; for (bssize_t SPRITES_OF(STAT_EFFECTOR, i)) if (SHT(i) == wall[wallNum].lotag && SLT(i) == SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT) { - T3(i) = nRand; - T4(i) = nDarkestWall; + T3(i) = random; + T4(i) = darkestWall; T5(i) = 1; } @@ -2316,11 +2323,11 @@ void G_AlignWarpElevators(void) } -static int32_t P_CheckDetonatorSpecialCase(DukePlayer_t *const pPlayer, int32_t weaponNum) +static int P_CheckDetonatorSpecialCase(DukePlayer_t *const pPlayer, int weaponNum) { if (weaponNum == HANDBOMB_WEAPON && pPlayer->ammo_amount[HANDBOMB_WEAPON] == 0) { - int32_t spriteNum = headspritestat[STAT_ACTOR]; + int spriteNum = headspritestat[STAT_ACTOR]; while (spriteNum >= 0) { @@ -2334,7 +2341,7 @@ static int32_t P_CheckDetonatorSpecialCase(DukePlayer_t *const pPlayer, int32_t return 0; } -void P_HandleSharedKeys(int32_t playerNum) +void P_HandleSharedKeys(int playerNum) { DukePlayer_t *const pPlayer = g_player[playerNum].ps; @@ -2474,7 +2481,7 @@ void P_HandleSharedKeys(int32_t playerNum) { pPlayer->invdisptime = GAMETICSPERSEC*2; - int const nInventoryRight = !!(TEST_SYNC_KEY(playerBits, SK_INV_RIGHT)); + int const inventoryRight = !!(TEST_SYNC_KEY(playerBits, SK_INV_RIGHT)); if (pPlayer->refresh_inventory) pPlayer->refresh_inventory = 0; int32_t inventoryIcon = pPlayer->inven_icon; @@ -2495,7 +2502,7 @@ CHECKINV1: case ICON_HEATS: if (pPlayer->inv_amount[icon_to_inv[inventoryIcon]] > 0 && i > 1) break; - if (nInventoryRight) + if (inventoryRight) inventoryIcon++; else inventoryIcon--; @@ -2504,12 +2511,12 @@ CHECKINV1: case ICON_FIRSTAID: if (pPlayer->inv_amount[GET_FIRSTAID] > 0 && i > 1) break; - inventoryIcon = nInventoryRight ? 2 : 7; + inventoryIcon = inventoryRight ? 2 : 7; goto CHECKINV1; case ICON_BOOTS: if (pPlayer->inv_amount[GET_BOOTS] > 0 && i > 1) break; - inventoryIcon = nInventoryRight ? 1 : 6; + inventoryIcon = inventoryRight ? 1 : 6; goto CHECKINV1; } } @@ -2823,7 +2830,7 @@ CHECKINV1: } } -int32_t A_CheckHitSprite(int32_t spriteNum, int16_t *hitSprite) +int A_CheckHitSprite(int spriteNum, int16_t *hitSprite) { hitdata_t hitData; int32_t zOffset = 0; @@ -2847,7 +2854,7 @@ int32_t A_CheckHitSprite(int32_t spriteNum, int16_t *hitSprite) return FindDistance2D(hitData.pos.x-SX(spriteNum),hitData.pos.y-SY(spriteNum)); } -static int32_t P_FindWall(DukePlayer_t *pPlayer, int16_t *hitWall) +static int P_FindWall(DukePlayer_t *pPlayer, int *hitWall) { hitdata_t hitData; @@ -2863,7 +2870,7 @@ static int32_t P_FindWall(DukePlayer_t *pPlayer, int16_t *hitWall) } // returns 1 if sprite i should not be considered by neartag -static int32_t our_neartag_blacklist(int32_t spriteNum) +static int our_neartag_blacklist(int spriteNum) { return sprite[spriteNum].picnum >= SECTOREFFECTOR__STATIC && sprite[spriteNum].picnum <= GPSPEED__STATIC; } @@ -2905,7 +2912,7 @@ void P_CheckSectors(int playerNum) default: if (pSector->lotag >= 10000 && pSector->lotag < 16383) { - if (playerNum == screenpeek || (GametypeFlags[ud.coop] & GAMETYPE_COOPSOUND)) + if (playerNum == screenpeek || (g_gametypeFlags[ud.coop] & GAMETYPE_COOPSOUND)) A_PlaySound(pSector->lotag - 10000, pPlayer->i); pSector->lotag = 0; } @@ -2940,10 +2947,10 @@ void P_CheckSectors(int playerNum) pPlayer->toggle_key_flag = 0; else if (!pPlayer->toggle_key_flag) { - int16_t hitscanwall; + int foundWall; - int16_t neartagsector, neartagwall, neartagsprite; - int32_t neartaghitdist; + int16_t nearSector, nearWall, nearSprite; + int32_t nearDist; if (TEST_SYNC_KEY(g_player[playerNum].inputBits->bits, SK_ESCAPE)) { @@ -2952,92 +2959,91 @@ void P_CheckSectors(int playerNum) return; } - neartagsprite = -1; + nearSprite = -1; pPlayer->toggle_key_flag = 1; - hitscanwall = -1; + foundWall = -1; - int wallDist = P_FindWall(pPlayer,&hitscanwall); + int wallDist = P_FindWall(pPlayer, &foundWall); - if (hitscanwall >= 0 && wallDist < 1280 && wall[hitscanwall].overpicnum == MIRROR) - if (wall[hitscanwall].lotag > 0 && !A_CheckSoundPlaying(pPlayer->i,wall[hitscanwall].lotag) && playerNum == screenpeek) + if (foundWall >= 0 && wallDist < 1280 && wall[foundWall].overpicnum == MIRROR) + if (wall[foundWall].lotag > 0 && !A_CheckSoundPlaying(pPlayer->i,wall[foundWall].lotag) && playerNum == screenpeek) { - A_PlaySound(wall[hitscanwall].lotag,pPlayer->i); + A_PlaySound(wall[foundWall].lotag,pPlayer->i); return; } - if (hitscanwall >= 0 && (wall[hitscanwall].cstat&16)) - if (wall[hitscanwall].lotag) + if (foundWall >= 0 && (wall[foundWall].cstat&16)) + if (wall[foundWall].lotag) return; if (pPlayer->newowner >= 0) - neartag(pPlayer->opos.x,pPlayer->opos.y,pPlayer->opos.z,sprite[pPlayer->i].sectnum,pPlayer->oang,&neartagsector, - &neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist); + neartag(pPlayer->opos.x, pPlayer->opos.y, pPlayer->opos.z, sprite[pPlayer->i].sectnum, pPlayer->oang, &nearSector, + &nearWall, &nearSprite, &nearDist, 1280, 1, our_neartag_blacklist); else { - neartag(pPlayer->pos.x,pPlayer->pos.y,pPlayer->pos.z,sprite[pPlayer->i].sectnum,pPlayer->oang,&neartagsector, - &neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist); - if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) - neartag(pPlayer->pos.x,pPlayer->pos.y,pPlayer->pos.z+ZOFFSET3,sprite[pPlayer->i].sectnum,pPlayer->oang,&neartagsector, - &neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist); - if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) - neartag(pPlayer->pos.x,pPlayer->pos.y,pPlayer->pos.z+ZOFFSET2,sprite[pPlayer->i].sectnum,pPlayer->oang,&neartagsector, - &neartagwall,&neartagsprite,&neartaghitdist, 1280, 1, our_neartag_blacklist); - if (neartagsprite == -1 && neartagwall == -1 && neartagsector == -1) + neartag(pPlayer->pos.x, pPlayer->pos.y, pPlayer->pos.z, sprite[pPlayer->i].sectnum, pPlayer->oang, &nearSector, + &nearWall, &nearSprite, &nearDist, 1280, 1, our_neartag_blacklist); + if (nearSprite == -1 && nearWall == -1 && nearSector == -1) + neartag(pPlayer->pos.x, pPlayer->pos.y, pPlayer->pos.z+ZOFFSET3, sprite[pPlayer->i].sectnum, pPlayer->oang, &nearSector, + &nearWall, &nearSprite, &nearDist, 1280, 1, our_neartag_blacklist); + if (nearSprite == -1 && nearWall == -1 && nearSector == -1) + neartag(pPlayer->pos.x, pPlayer->pos.y, pPlayer->pos.z+ZOFFSET2, sprite[pPlayer->i].sectnum, pPlayer->oang, &nearSector, + &nearWall, &nearSprite, &nearDist, 1280, 1, our_neartag_blacklist); + if (nearSprite == -1 && nearWall == -1 && nearSector == -1) { - neartag(pPlayer->pos.x,pPlayer->pos.y,pPlayer->pos.z+ZOFFSET2,sprite[pPlayer->i].sectnum,pPlayer->oang,&neartagsector, - &neartagwall,&neartagsprite,&neartaghitdist, 1280, 3, our_neartag_blacklist); - if (neartagsprite >= 0) + neartag(pPlayer->pos.x, pPlayer->pos.y, pPlayer->pos.z+ZOFFSET2, sprite[pPlayer->i].sectnum, pPlayer->oang, &nearSector, + &nearWall, &nearSprite, &nearDist, 1280, 3, our_neartag_blacklist); + if (nearSprite >= 0) { - switch (DYNAMICTILEMAP(sprite[neartagsprite].picnum)) + switch (DYNAMICTILEMAP(sprite[nearSprite].picnum)) { - case FEM1__STATIC: - case FEM2__STATIC: - case FEM3__STATIC: - case FEM4__STATIC: - case FEM5__STATIC: - case FEM6__STATIC: - case FEM7__STATIC: - case FEM8__STATIC: - case FEM9__STATIC: - case FEM10__STATIC: - case PODFEM1__STATIC: - case NAKED1__STATIC: - case STATUE__STATIC: - case TOUGHGAL__STATIC: - return; + case FEM1__STATIC: + case FEM2__STATIC: + case FEM3__STATIC: + case FEM4__STATIC: + case FEM5__STATIC: + case FEM6__STATIC: + case FEM7__STATIC: + case FEM8__STATIC: + case FEM9__STATIC: + case FEM10__STATIC: + case PODFEM1__STATIC: + case NAKED1__STATIC: + case STATUE__STATIC: + case TOUGHGAL__STATIC: return; } } - neartagsprite = -1; - neartagwall = -1; - neartagsector = -1; + nearSprite = -1; + nearWall = -1; + nearSector = -1; } } - if (pPlayer->newowner == -1 && neartagsprite == -1 && neartagsector == -1 && neartagwall == -1) + if (pPlayer->newowner == -1 && nearSprite == -1 && nearSector == -1 && nearWall == -1) { if (isanunderoperator(sector[sprite[pPlayer->i].sectnum].lotag)) - neartagsector = sprite[pPlayer->i].sectnum; + nearSector = sprite[pPlayer->i].sectnum; } - if (neartagsector >= 0 && (sector[neartagsector].lotag&16384)) + if (nearSector >= 0 && (sector[nearSector].lotag&16384)) return; - if (neartagsprite == -1 && neartagwall == -1) + if (nearSprite == -1 && nearWall == -1) { if (pPlayer->cursectnum >= 0 && sector[pPlayer->cursectnum].lotag == 2) { - if (A_CheckHitSprite(pPlayer->i, &neartagsprite) > 1280) - neartagsprite = -1; + if (A_CheckHitSprite(pPlayer->i, &nearSprite) > 1280) + nearSprite = -1; } } - if (neartagsprite >= 0) + if (nearSprite >= 0) { - if (P_ActivateSwitch(playerNum, neartagsprite, 1)) + if (P_ActivateSwitch(playerNum, nearSprite, 1)) return; - switch (DYNAMICTILEMAP(sprite[neartagsprite].picnum)) + switch (DYNAMICTILEMAP(sprite[nearSprite].picnum)) { case TOILET__STATIC: case STALL__STATIC: @@ -3063,19 +3069,19 @@ void P_CheckSectors(int playerNum) else if (sprite[pPlayer->i].extra < pPlayer->max_player_health) sprite[pPlayer->i].extra = pPlayer->max_player_health; } - else if (!A_CheckSoundPlaying(neartagsprite,FLUSH_TOILET)) - A_PlaySound(FLUSH_TOILET,neartagsprite); + else if (!A_CheckSoundPlaying(nearSprite,FLUSH_TOILET)) + A_PlaySound(FLUSH_TOILET,nearSprite); return; case NUKEBUTTON__STATIC: { - int16_t wallNum; + int wallNum; P_FindWall(pPlayer, &wallNum); if (wallNum >= 0 && wall[wallNum].overpicnum == 0) { - if (actor[neartagsprite].t_data[0] == 0) + if (actor[nearSprite].t_data[0] == 0) { if (ud.noexits && (g_netServer || ud.multimode > 1)) { @@ -3085,10 +3091,10 @@ void P_CheckSectors(int playerNum) } else { - actor[neartagsprite].t_data[0] = 1; - sprite[neartagsprite].owner = pPlayer->i; + actor[nearSprite].t_data[0] = 1; + sprite[nearSprite].owner = pPlayer->i; ud.secretlevel = - (pPlayer->buttonpalette = sprite[neartagsprite].pal) ? sprite[neartagsprite].lotag : 0; + (pPlayer->buttonpalette = sprite[nearSprite].pal) ? sprite[nearSprite].lotag : 0; } } } @@ -3096,10 +3102,10 @@ void P_CheckSectors(int playerNum) } case WATERFOUNTAIN__STATIC: - if (actor[neartagsprite].t_data[0] != 1) + if (actor[nearSprite].t_data[0] != 1) { - actor[neartagsprite].t_data[0] = 1; - sprite[neartagsprite].owner = pPlayer->i; + actor[nearSprite].t_data[0] = 1; + sprite[nearSprite].owner = pPlayer->i; if (sprite[pPlayer->i].extra < pPlayer->max_player_health) { @@ -3121,13 +3127,13 @@ void P_CheckSectors(int playerNum) // Try to find a camera sprite for the viewscreen. for (bssize_t SPRITES_OF(STAT_ACTOR, spriteNum)) { - if (PN(spriteNum) == CAMERA1 && SP(spriteNum) == 0 && sprite[neartagsprite].hitag == SLT(spriteNum)) + if (PN(spriteNum) == CAMERA1 && SP(spriteNum) == 0 && sprite[nearSprite].hitag == SLT(spriteNum)) { - sprite[spriteNum].yvel = 1; // Using this camera - A_PlaySound(MONITOR_ACTIVE,pPlayer->i); - sprite[neartagsprite].owner = spriteNum; - sprite[neartagsprite].yvel = 1; // VIEWSCREEN_YVEL - g_curViewscreen = neartagsprite; + sprite[spriteNum].yvel = 1; // Using this camera + A_PlaySound(MONITOR_ACTIVE, pPlayer->i); + sprite[nearSprite].owner = spriteNum; + sprite[nearSprite].yvel = 1; // VIEWSCREEN_YVEL + g_curViewscreen = nearSprite; int const playerSectnum = pPlayer->cursectnum; pPlayer->cursectnum = SECT(spriteNum); @@ -3155,7 +3161,7 @@ void P_CheckSectors(int playerNum) return; } - if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) + if (nearWall == -1 && nearSector == -1 && nearSprite == -1) { if (klabs(A_GetHitscanRange(pPlayer->i)) < 512) { @@ -3164,12 +3170,12 @@ void P_CheckSectors(int playerNum) } } - if (neartagwall >= 0) + if (nearWall >= 0) { - if (wall[neartagwall].lotag > 0 && CheckDoorTile(wall[neartagwall].picnum)) + if (wall[nearWall].lotag > 0 && CheckDoorTile(wall[nearWall].picnum)) { - if (hitscanwall == neartagwall || hitscanwall == -1) - P_ActivateSwitch(playerNum,neartagwall,0); + if (foundWall == nearWall || foundWall == -1) + P_ActivateSwitch(playerNum,nearWall,0); return; } else if (pPlayer->newowner >= 0) @@ -3179,16 +3185,16 @@ void P_CheckSectors(int playerNum) } } - if (neartagsector >= 0 && (sector[neartagsector].lotag&16384) == 0 && - isanearoperator(sector[neartagsector].lotag)) + if (nearSector >= 0 && (sector[nearSector].lotag&16384) == 0 && + isanearoperator(sector[nearSector].lotag)) { - for (bssize_t SPRITES_OF_SECT(neartagsector, spriteNum)) + for (bssize_t SPRITES_OF_SECT(nearSector, spriteNum)) { if (PN(spriteNum) == ACTIVATOR || PN(spriteNum) == MASTERSWITCH) return; } - G_OperateSectors(neartagsector,pPlayer->i); + G_OperateSectors(nearSector,pPlayer->i); } else if ((sector[sprite[pPlayer->i].sectnum].lotag&16384) == 0) { @@ -3202,7 +3208,7 @@ void P_CheckSectors(int playerNum) G_OperateSectors(sprite[pPlayer->i].sectnum,pPlayer->i); } - else P_ActivateSwitch(playerNum,neartagwall,0); + else P_ActivateSwitch(playerNum,nearWall,0); } } } diff --git a/polymer/eduke32/source/sector.h b/polymer/eduke32/source/sector.h index 09077d076..63237bf35 100644 --- a/polymer/eduke32/source/sector.h +++ b/polymer/eduke32/source/sector.h @@ -46,20 +46,20 @@ typedef struct { typedef struct { // this needs to have a copy of everything related to the map/actor state // see savegame.c - int32_t animategoal[MAXANIMATES], animatevel[MAXANIMATES], g_animateCount; - intptr_t animateptr[MAXANIMATES]; + int32_t g_animateGoal[MAXANIMATES], g_animateVel[MAXANIMATES], g_animateCnt; + intptr_t g_animatePtr[MAXANIMATES]; int32_t lockclock; vec2_t origins[MAXANIMPOINTS]; int32_t randomseed, g_globalRandom; int32_t pskyidx; int16_t SpriteDeletionQueue[1024],g_spriteDeleteQueuePos; - int16_t animatesect[MAXANIMATES]; - int16_t cyclers[MAXCYCLERS][6]; + int16_t g_animateSect[MAXANIMATES]; + int16_t g_cyclers[MAXCYCLERS][6]; int16_t g_mirrorWall[64], g_mirrorSector[64], g_mirrorCount; - int16_t g_numAnimWalls; - int16_t g_numClouds,clouds[256],cloudx,cloudy; - int16_t g_numCyclers; + int16_t g_animWallCnt; + int16_t g_cloudCnt,g_cloudSect[256],g_cloudX,g_cloudY; + int16_t g_cyclerCnt; int32_t numsprites; int16_t tailspritefree; @@ -73,7 +73,7 @@ typedef struct { int16_t prevspritestat[MAXSPRITES]; uint16_t g_earthquakeTime; - int8_t g_numPlayerSprites; + int8_t g_playerSpawnCnt; uint8_t show2dsector[(MAXSECTORS+7)>>3]; @@ -111,32 +111,32 @@ typedef struct { //extern map_t MapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music void G_ActivateBySector(int32_t sect,int32_t j); -int32_t S_FindMusicSFX(int32_t sn, int32_t *sndptr); -int32_t A_CallSound(int32_t sn,int32_t whatsprite); -int32_t A_CheckHitSprite(int32_t i,int16_t *hitsp); +int S_FindMusicSFX(int sectNum, int32_t *sndptr); +int A_CallSound(int sectNum,int spriteNum); +int A_CheckHitSprite(int spriteNum,int16_t *hitSprite); void A_DamageObject(int32_t i,int32_t sn); void A_DamageWall(int32_t spr,int32_t dawallnum,const vec3_t *pos,int32_t atwith); -int32_t __fastcall A_FindPlayer(const spritetype *s,int32_t *d); +int __fastcall A_FindPlayer(const spritetype *pSprite,int32_t *dist); void G_AlignWarpElevators(void); -int32_t CheckDoorTile(int32_t dapic); -void G_AnimateCamSprite(int32_t smoothratio); +int CheckDoorTile(int tileNum); +void G_AnimateCamSprite(int smoothRatio); void G_AnimateWalls(void); -int32_t G_ActivateWarpElevators(int32_t s,int32_t d); -int32_t G_CheckActivatorMotion(int32_t lotag); +int G_ActivateWarpElevators(int s,int d); +int G_CheckActivatorMotion(int lotag); void G_DoSectorAnimations(void); void G_OperateActivators(int nTag, int playerNum); void G_OperateForceFields(int spriteNum,int wallTag); void G_OperateMasterSwitches(int nTag); -void G_OperateRespawns(int32_t low); -extern void G_OperateSectors(int sectNum,int spriteNum); -void P_HandleSharedKeys(int32_t snum); -int32_t GetAnimationGoal(const int32_t *animptr); -int32_t isanearoperator(int32_t lotag); -int32_t isanunderoperator(int32_t lotag); +void G_OperateRespawns(int lotag); +void G_OperateSectors(int sectNum,int spriteNum); +void P_HandleSharedKeys(int playerNum); +int GetAnimationGoal(const int32_t *animPtr); +int isanearoperator(int lotag); +int isanunderoperator(int lotag); int P_ActivateSwitch(int playerNum, int nObject, int nSwitchType); void P_CheckSectors(int32_t snum); int Sect_DamageCeilingOrFloor(int nDmgFloor, int const nSectnum); -int32_t SetAnimation(int32_t animsect,int32_t *animptr,int32_t thegoal,int32_t thevel); +int SetAnimation(int sectNum,int32_t *animPtr,int goalVal,int animVel); #define FORCEFIELD_CSTAT (64+16+4+1) diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 9cbe09e81..b90001c65 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -168,13 +168,13 @@ void S_RestartMusic(void) { if (ud.recstat != 2 && g_player[myconnectindex].ps->gm&MODE_GAME) { - if (aMapInfo[g_musicIndex].musicfn != NULL) - S_PlayMusic(aMapInfo[g_musicIndex].musicfn); + if (g_mapInfo[g_musicIndex].musicfn != NULL) + S_PlayMusic(g_mapInfo[g_musicIndex].musicfn); } - else if (aMapInfo[MUS_INTRO].musicfn != 0 && (G_GetLogoFlags() & LOGO_PLAYMUSIC)) + else if (g_mapInfo[MUS_INTRO].musicfn != 0 && (G_GetLogoFlags() & LOGO_PLAYMUSIC)) { g_musicIndex = MUS_INTRO; - S_PlayMusic(aMapInfo[MUS_INTRO].musicfn); + S_PlayMusic(g_mapInfo[MUS_INTRO].musicfn); } }