diff --git a/polymer/eduke32/build/include/m32script.h b/polymer/eduke32/build/include/m32script.h
index a5111d731..0c498d502 100644
--- a/polymer/eduke32/build/include/m32script.h
+++ b/polymer/eduke32/build/include/m32script.h
@@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
typedef int32_t instype;
typedef int32_t ofstype;
-extern char *ScriptQuotes[MAXQUOTES+1], *ScriptQuoteRedefinitions[MAXQUOTES+1];
+extern char *apStrings[MAXQUOTES+1], *apXStrings[MAXQUOTES+1];
extern int32_t g_numQuoteRedefinitions;
extern int32_t VM_Execute(int32_t once);
@@ -58,7 +58,7 @@ extern void SetGamePalette(int32_t);
extern int32_t *constants, constants_allocsize;
extern int32_t g_numSavedConstants;
-extern instype *script ,*insptr;
+extern instype *apScript ,*insptr;
extern int32_t *labelval;
extern uint8_t *labeltype;
extern int32_t g_numLabels, g_numDefaultLabels;
diff --git a/polymer/eduke32/build/src/jwzgles.c b/polymer/eduke32/build/src/jwzgles.c
index e71e66e0e..77caf52a0 100644
--- a/polymer/eduke32/build/src/jwzgles.c
+++ b/polymer/eduke32/build/src/jwzgles.c
@@ -310,174 +310,174 @@ static const char *
mode_desc (int mode) /* for debugging messages */
{
switch (mode) {
-# define SS(X) case GL_##X: return STRINGIFY(X);
- SS(ALPHA)
- SS(ALPHA_TEST)
- SS(AMBIENT)
- SS(AMBIENT_AND_DIFFUSE)
- SS(ARRAY_BUFFER)
- SS(AUTO_NORMAL)
- SS(BACK)
- SS(BLEND)
- SS(BLEND_DST)
- SS(BLEND_SRC)
- SS(BLEND_SRC_ALPHA)
- SS(BYTE)
- SS(C3F_V3F)
- SS(C4F_N3F_V3F)
- SS(C4UB_V2F)
- SS(C4UB_V3F)
- SS(CCW)
- SS(CLAMP)
- SS(COLOR_ARRAY)
- SS(COLOR_ARRAY_BUFFER_BINDING);
- SS(COLOR_MATERIAL)
- SS(COLOR_MATERIAL_FACE)
- SS(COLOR_MATERIAL_PARAMETER)
- SS(COMPILE)
- SS(CULL_FACE)
- SS(CW)
- SS(DECAL)
- SS(DEPTH_BUFFER_BIT)
- SS(DEPTH_TEST)
- SS(DIFFUSE)
- SS(DOUBLEBUFFER)
- SS(DST_ALPHA)
- SS(DST_COLOR)
- SS(DYNAMIC_DRAW)
- SS(ELEMENT_ARRAY_BUFFER)
- SS(EYE_LINEAR)
- SS(EYE_PLANE)
- SS(FEEDBACK)
- SS(FILL)
- SS(FLAT)
- SS(FLOAT)
- SS(FOG)
- SS(FRONT)
- SS(FRONT_AND_BACK)
- SS(GREATER)
- SS(INTENSITY)
- SS(INVALID_ENUM)
- SS(INVALID_OPERATION)
- SS(INVALID_VALUE)
- SS(LESS)
- SS(LIGHT0)
- SS(LIGHT1)
- SS(LIGHT2)
- SS(LIGHT3)
- SS(LIGHTING)
- SS(LIGHT_MODEL_AMBIENT)
- SS(LIGHT_MODEL_COLOR_CONTROL)
- SS(LIGHT_MODEL_LOCAL_VIEWER)
- SS(LIGHT_MODEL_TWO_SIDE)
- SS(LINE)
- SS(LINEAR)
- SS(LINEAR_MIPMAP_LINEAR)
- SS(LINEAR_MIPMAP_NEAREST)
- SS(LINES)
- SS(LINE_LOOP)
- SS(LINE_STRIP)
- SS(LUMINANCE)
- SS(LUMINANCE_ALPHA)
- SS(MATRIX_MODE)
- SS(MODELVIEW)
- SS(MODULATE)
- SS(N3F_V3F)
- SS(NEAREST)
- SS(NEAREST_MIPMAP_LINEAR)
- SS(NEAREST_MIPMAP_NEAREST)
- SS(NORMALIZE)
- SS(NORMAL_ARRAY)
- SS(NORMAL_ARRAY_BUFFER_BINDING);
- SS(OBJECT_LINEAR)
- SS(OBJECT_PLANE)
- SS(ONE_MINUS_DST_ALPHA)
- SS(ONE_MINUS_DST_COLOR)
- SS(ONE_MINUS_SRC_ALPHA)
- SS(ONE_MINUS_SRC_COLOR)
- SS(OUT_OF_MEMORY)
- SS(PACK_ALIGNMENT)
- SS(POINTS)
- SS(POLYGON)
- SS(POLYGON_OFFSET_FILL)
- SS(POLYGON_SMOOTH)
- SS(POLYGON_STIPPLE)
- SS(POSITION)
- SS(PROJECTION)
- SS(Q)
- SS(QUADS)
- SS(QUAD_STRIP)
- SS(R)
- SS(RENDER)
- SS(REPEAT)
- SS(RGB)
- SS(RGBA)
- SS(RGBA_MODE)
- SS(S)
- SS(SELECT)
- SS(SEPARATE_SPECULAR_COLOR)
- SS(SHADE_MODEL)
- SS(SHININESS)
- SS(SHORT)
- SS(SINGLE_COLOR)
- SS(SMOOTH)
- SS(SPECULAR)
- SS(SPHERE_MAP)
- SS(SRC_ALPHA)
- SS(SRC_ALPHA_SATURATE)
- SS(SRC_COLOR)
- SS(STACK_OVERFLOW)
- SS(STACK_UNDERFLOW)
- SS(STATIC_DRAW)
- SS(STENCIL_BUFFER_BIT)
- SS(T)
- SS(T2F_C3F_V3F)
- SS(T2F_C4F_N3F_V3F)
- SS(T2F_C4UB_V3F)
- SS(T2F_N3F_V3F)
- SS(T2F_V3F)
- SS(T4F_C4F_N3F_V4F)
- SS(T4F_V4F)
- SS(TEXTURE)
- SS(TEXTURE_1D)
- SS(TEXTURE_2D)
- SS(TEXTURE_ALPHA_SIZE)
- SS(TEXTURE_BINDING_2D)
- SS(TEXTURE_BLUE_SIZE)
- SS(TEXTURE_BORDER)
- SS(TEXTURE_BORDER_COLOR)
- SS(TEXTURE_COMPONENTS)
- SS(TEXTURE_COORD_ARRAY)
- SS(TEXTURE_COORD_ARRAY_BUFFER_BINDING);
- SS(TEXTURE_ENV)
- SS(TEXTURE_ENV_COLOR)
- SS(TEXTURE_ENV_MODE)
- SS(TEXTURE_GEN_MODE)
- SS(TEXTURE_GEN_Q)
- SS(TEXTURE_GEN_R)
- SS(TEXTURE_GEN_S)
- SS(TEXTURE_GEN_T)
- SS(TEXTURE_GREEN_SIZE)
- SS(TEXTURE_HEIGHT)
- SS(TEXTURE_INTENSITY_SIZE)
- SS(TEXTURE_LUMINANCE_SIZE)
- SS(TEXTURE_MAG_FILTER)
- SS(TEXTURE_MIN_FILTER)
- SS(TEXTURE_RED_SIZE)
- SS(TEXTURE_WRAP_S)
- SS(TEXTURE_WRAP_T)
- SS(TRIANGLES)
- SS(TRIANGLE_FAN)
- SS(TRIANGLE_STRIP)
- SS(UNPACK_ALIGNMENT)
- SS(UNPACK_ROW_LENGTH)
- SS(UNSIGNED_BYTE)
- SS(UNSIGNED_INT_8_8_8_8_REV)
- SS(UNSIGNED_SHORT)
- SS(V2F)
- SS(V3F)
- SS(VERTEX_ARRAY)
- SS(VERTEX_ARRAY_BUFFER_BINDING);
+# define SS(i)(X) case GL_##X: return STRINGIFY(X);
+ SS(i)(ALPHA)
+ SS(i)(ALPHA_TEST)
+ SS(i)(AMBIENT)
+ SS(i)(AMBIENT_AND_DIFFUSE)
+ SS(i)(ARRAY_BUFFER)
+ SS(i)(AUTO_NORMAL)
+ SS(i)(BACK)
+ SS(i)(BLEND)
+ SS(i)(BLEND_DST)
+ SS(i)(BLEND_SRC)
+ SS(i)(BLEND_SRC_ALPHA)
+ SS(i)(BYTE)
+ SS(i)(C3F_V3F)
+ SS(i)(C4F_N3F_V3F)
+ SS(i)(C4UB_V2F)
+ SS(i)(C4UB_V3F)
+ SS(i)(CCW)
+ SS(i)(CLAMP)
+ SS(i)(COLOR_ARRAY)
+ SS(i)(COLOR_ARRAY_BUFFER_BINDING);
+ SS(i)(COLOR_MATERIAL)
+ SS(i)(COLOR_MATERIAL_FACE)
+ SS(i)(COLOR_MATERIAL_PARAMETER)
+ SS(i)(COMPILE)
+ SS(i)(CULL_FACE)
+ SS(i)(CW)
+ SS(i)(DECAL)
+ SS(i)(DEPTH_BUFFER_BIT)
+ SS(i)(DEPTH_TEST)
+ SS(i)(DIFFUSE)
+ SS(i)(DOUBLEBUFFER)
+ SS(i)(DST_ALPHA)
+ SS(i)(DST_COLOR)
+ SS(i)(DYNAMIC_DRAW)
+ SS(i)(ELEMENT_ARRAY_BUFFER)
+ SS(i)(EYE_LINEAR)
+ SS(i)(EYE_PLANE)
+ SS(i)(FEEDBACK)
+ SS(i)(FILL)
+ SS(i)(FLAT)
+ SS(i)(FLOAT)
+ SS(i)(FOG)
+ SS(i)(FRONT)
+ SS(i)(FRONT_AND_BACK)
+ SS(i)(GREATER)
+ SS(i)(INTENSITY)
+ SS(i)(INVALID_ENUM)
+ SS(i)(INVALID_OPERATION)
+ SS(i)(INVALID_VALUE)
+ SS(i)(LESS)
+ SS(i)(LIGHT0)
+ SS(i)(LIGHT1)
+ SS(i)(LIGHT2)
+ SS(i)(LIGHT3)
+ SS(i)(LIGHTING)
+ SS(i)(LIGHT_MODEL_AMBIENT)
+ SS(i)(LIGHT_MODEL_COLOR_CONTROL)
+ SS(i)(LIGHT_MODEL_LOCAL_VIEWER)
+ SS(i)(LIGHT_MODEL_TWO_SIDE)
+ SS(i)(LINE)
+ SS(i)(LINEAR)
+ SS(i)(LINEAR_MIPMAP_LINEAR)
+ SS(i)(LINEAR_MIPMAP_NEAREST)
+ SS(i)(LINES)
+ SS(i)(LINE_LOOP)
+ SS(i)(LINE_STRIP)
+ SS(i)(LUMINANCE)
+ SS(i)(LUMINANCE_ALPHA)
+ SS(i)(MATRIX_MODE)
+ SS(i)(MODELVIEW)
+ SS(i)(MODULATE)
+ SS(i)(N3F_V3F)
+ SS(i)(NEAREST)
+ SS(i)(NEAREST_MIPMAP_LINEAR)
+ SS(i)(NEAREST_MIPMAP_NEAREST)
+ SS(i)(NORMALIZE)
+ SS(i)(NORMAL_ARRAY)
+ SS(i)(NORMAL_ARRAY_BUFFER_BINDING);
+ SS(i)(OBJECT_LINEAR)
+ SS(i)(OBJECT_PLANE)
+ SS(i)(ONE_MINUS_DST_ALPHA)
+ SS(i)(ONE_MINUS_DST_COLOR)
+ SS(i)(ONE_MINUS_SRC_ALPHA)
+ SS(i)(ONE_MINUS_SRC_COLOR)
+ SS(i)(OUT_OF_MEMORY)
+ SS(i)(PACK_ALIGNMENT)
+ SS(i)(POINTS)
+ SS(i)(POLYGON)
+ SS(i)(POLYGON_OFFSET_FILL)
+ SS(i)(POLYGON_SMOOTH)
+ SS(i)(POLYGON_STIPPLE)
+ SS(i)(POSITION)
+ SS(i)(PROJECTION)
+ SS(i)(Q)
+ SS(i)(QUADS)
+ SS(i)(QUAD_STRIP)
+ SS(i)(R)
+ SS(i)(RENDER)
+ SS(i)(REPEAT)
+ SS(i)(RGB)
+ SS(i)(RGBA)
+ SS(i)(RGBA_MODE)
+ SS(i)(S)
+ SS(i)(SELECT)
+ SS(i)(SEPARATE_SPECULAR_COLOR)
+ SS(i)(SHADE_MODEL)
+ SS(i)(SHININESS)
+ SS(i)(SHORT)
+ SS(i)(SINGLE_COLOR)
+ SS(i)(SMOOTH)
+ SS(i)(SPECULAR)
+ SS(i)(SPHERE_MAP)
+ SS(i)(SRC_ALPHA)
+ SS(i)(SRC_ALPHA_SATURATE)
+ SS(i)(SRC_COLOR)
+ SS(i)(STACK_OVERFLOW)
+ SS(i)(STACK_UNDERFLOW)
+ SS(i)(STATIC_DRAW)
+ SS(i)(STENCIL_BUFFER_BIT)
+ SS(i)(T)
+ SS(i)(T2F_C3F_V3F)
+ SS(i)(T2F_C4F_N3F_V3F)
+ SS(i)(T2F_C4UB_V3F)
+ SS(i)(T2F_N3F_V3F)
+ SS(i)(T2F_V3F)
+ SS(i)(T4F_C4F_N3F_V4F)
+ SS(i)(T4F_V4F)
+ SS(i)(TEXTURE)
+ SS(i)(TEXTURE_1D)
+ SS(i)(TEXTURE_2D)
+ SS(i)(TEXTURE_ALPHA_SIZE)
+ SS(i)(TEXTURE_BINDING_2D)
+ SS(i)(TEXTURE_BLUE_SIZE)
+ SS(i)(TEXTURE_BORDER)
+ SS(i)(TEXTURE_BORDER_COLOR)
+ SS(i)(TEXTURE_COMPONENTS)
+ SS(i)(TEXTURE_COORD_ARRAY)
+ SS(i)(TEXTURE_COORD_ARRAY_BUFFER_BINDING);
+ SS(i)(TEXTURE_ENV)
+ SS(i)(TEXTURE_ENV_COLOR)
+ SS(i)(TEXTURE_ENV_MODE)
+ SS(i)(TEXTURE_GEN_MODE)
+ SS(i)(TEXTURE_GEN_Q)
+ SS(i)(TEXTURE_GEN_R)
+ SS(i)(TEXTURE_GEN_S)
+ SS(i)(TEXTURE_GEN_T)
+ SS(i)(TEXTURE_GREEN_SIZE)
+ SS(i)(TEXTURE_HEIGHT)
+ SS(i)(TEXTURE_INTENSITY_SIZE)
+ SS(i)(TEXTURE_LUMINANCE_SIZE)
+ SS(i)(TEXTURE_MAG_FILTER)
+ SS(i)(TEXTURE_MIN_FILTER)
+ SS(i)(TEXTURE_RED_SIZE)
+ SS(i)(TEXTURE_WRAP_S)
+ SS(i)(TEXTURE_WRAP_T)
+ SS(i)(TRIANGLES)
+ SS(i)(TRIANGLE_FAN)
+ SS(i)(TRIANGLE_STRIP)
+ SS(i)(UNPACK_ALIGNMENT)
+ SS(i)(UNPACK_ROW_LENGTH)
+ SS(i)(UNSIGNED_BYTE)
+ SS(i)(UNSIGNED_INT_8_8_8_8_REV)
+ SS(i)(UNSIGNED_SHORT)
+ SS(i)(V2F)
+ SS(i)(V3F)
+ SS(i)(VERTEX_ARRAY)
+ SS(i)(VERTEX_ARRAY_BUFFER_BINDING);
/*SS(COLOR_BUFFER_BIT) -- same value as GL_LIGHT0 */
# undef SS
case (GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT):
diff --git a/polymer/eduke32/eduke32.vcxproj b/polymer/eduke32/eduke32.vcxproj
index 903e88d6f..280505858 100644
--- a/polymer/eduke32/eduke32.vcxproj
+++ b/polymer/eduke32/eduke32.vcxproj
@@ -124,6 +124,7 @@
+
diff --git a/polymer/eduke32/eduke32.vcxproj.filters b/polymer/eduke32/eduke32.vcxproj.filters
index caac5058e..89e81bbb7 100644
--- a/polymer/eduke32/eduke32.vcxproj.filters
+++ b/polymer/eduke32/eduke32.vcxproj.filters
@@ -540,6 +540,9 @@
jaudiolib\headers
+
+ eduke32\headers\editor
+
diff --git a/polymer/eduke32/source/_midi.h b/polymer/eduke32/source/_midi.h
index 84ae5bf25..580f0584f 100644
--- a/polymer/eduke32/source/_midi.h
+++ b/polymer/eduke32/source/_midi.h
@@ -141,7 +141,6 @@ static int32_t _MIDI_InterpretControllerInfo(track *Track, int32_t TimeSet, int3
static int32_t _MIDI_SendControlChange(int32_t channel, int32_t c1, int32_t c2);
static void _MIDI_SetChannelVolume(int32_t channel, int32_t volume);
static void _MIDI_SendChannelVolumes(void);
-static int32_t _MIDI_ProcessNextTick(void);
static void _MIDI_InitEMIDI(void);
#endif
diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c
index ad1e8149e..17cca78dd 100644
--- a/polymer/eduke32/source/actors.c
+++ b/polymer/eduke32/source/actors.c
@@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# define ACTOR_STATIC static
#endif
-#define KILLIT(KX) do { A_DeleteSprite(KX); goto BOLT; } while (0)
+#define KILLIT(KX) do { A_DeleteSprite(KX); goto next_sprite; } while (0)
extern int32_t g_numEnvSoundsPlaying;
extern int32_t g_noEnemies;
@@ -102,198 +102,203 @@ 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 i, int32_t r, int32_t hp1, int32_t hp2, int32_t hp3, int32_t hp4)
+void A_RadiusDamage(int32_t spriteNum, int32_t blastRadius, int32_t dmg1, int32_t dmg2, int32_t dmg3, int32_t dmg4)
{
- int32_t d, q, stati;
- uspritetype const *const s = (uspritetype *)&sprite[i];
+ int32_t d, q;
+ uspritetype const *const pSprite = (uspritetype *)&sprite[spriteNum];
- static const int32_t statlist[] = {
+ static const int32_t statnumList[] = {
STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE,
STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC
};
// XXX: accesses to 'sectorlist' potentially unaligned
- int16_t *const sectorlist = (int16_t *)tempbuf;
- const int32_t maxsects = sizeof(tempbuf)/sizeof(int16_t);
+ int16_t *const sectorList = (int16_t *)tempbuf;
+ const int32_t maxSectors = sizeof(tempbuf)/sizeof(int16_t);
- if (s->picnum == RPG && s->xrepeat < 11)
+ if (pSprite->picnum == RPG && pSprite->xrepeat < 11)
goto SKIPWALLCHECK;
- if (s->picnum != SHRINKSPARK)
+ if (pSprite->picnum != SHRINKSPARK)
{
- int32_t sectcnt = 0;
- int32_t sectend = 1;
+ int32_t sectorCount = 0;
+ int32_t numSectors = 1;
- sectorlist[0] = s->sectnum;
+ sectorList[0] = pSprite->sectnum;
do
{
- const uwalltype *wal;
- const int32_t dasect = sectorlist[sectcnt++];
- const int32_t startwall = sector[dasect].wallptr;
- const int32_t endwall = startwall+sector[dasect].wallnum;
-
- int32_t w;
- const int32_t w2 = wall[startwall].point2;
+ int const sectorNum = sectorList[sectorCount++];
+ int const startWall = sector[sectorNum].wallptr;
+ int const endWall = startWall + sector[sectorNum].wallnum;
+ int const w2 = wall[startWall].point2;
// Check if "hit" 1st or 3rd wall-point. This mainly makes sense
// for rectangular "ceiling light"-style sectors.
- if (G_WallSpriteDist((uwalltype *)&wall[startwall], s) < r ||
- G_WallSpriteDist((uwalltype *)&wall[wall[w2].point2], s) < r)
+ if (G_WallSpriteDist((uwalltype *)&wall[startWall], pSprite) < blastRadius ||
+ G_WallSpriteDist((uwalltype *)&wall[wall[w2].point2], pSprite) < blastRadius)
{
- if (((sector[dasect].ceilingz-s->z)>>8) < r)
- Sect_DamageCeilingOrFloor(0, dasect);
- if (((s->z-sector[dasect].floorz)>>8) < r)
- Sect_DamageCeilingOrFloor(1, dasect);
+ if (((sector[sectorNum].ceilingz-pSprite->z)>>8) < blastRadius)
+ Sect_DamageCeilingOrFloor(0, sectorNum);
+ if (((pSprite->z-sector[sectorNum].floorz)>>8) < blastRadius)
+ Sect_DamageCeilingOrFloor(1, sectorNum);
}
- for (w=startwall,wal=(uwalltype *)&wall[startwall]; wnextsector;
- int32_t x1, y1;
+ int16_t damageSector = -1;
+ int const nextSector = pWall->nextsector;
- if (nextsect >= 0)
+ if (nextSector >= 0)
{
int32_t dasect2;
- for (dasect2=sectend-1; dasect2>=0; dasect2--)
- if (sectorlist[dasect2] == nextsect)
+
+ for (dasect2=numSectors-1; dasect2>=0; dasect2--)
+ if (sectorList[dasect2] == nextSector)
break;
if (dasect2 < 0)
{
- if (sectend == maxsects)
+ if (numSectors == maxSectors)
goto SKIPWALLCHECK; // prevent oob access of 'sectorlist'
- sectorlist[sectend++] = nextsect;
+ sectorList[numSectors++] = nextSector;
}
}
- x1 = (((wal->x+wall[wal->point2].x)>>1)+s->x)>>1;
- y1 = (((wal->y+wall[wal->point2].y)>>1)+s->y)>>1;
+ vec2_t const vect = { (((pWall->x + wall[pWall->point2].x) >> 1) + pSprite->x) >> 1,
+ (((pWall->y + wall[pWall->point2].y) >> 1) + pSprite->y) >> 1 };
- updatesector(x1,y1,§);
+ updatesector(vect.x, vect.y, &damageSector);
- if (sect >= 0 && cansee(x1,y1,s->z,sect,s->x,s->y,s->z,s->sectnum))
+ if (damageSector >= 0 && cansee(vect.x, vect.y, pSprite->z, damageSector,
+ pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum))
{
- vec3_t tmpvect = { wal->x, wal->y, s->z };
- A_DamageWall(i, w, &tmpvect, s->picnum);
+ vec3_t const tmpvect = { pWall->x, pWall->y, pSprite->z };
+ A_DamageWall(spriteNum, w, &tmpvect, pSprite->picnum);
}
}
+ }
}
- while (sectcnt < sectend);
+ while (sectorCount < numSectors);
}
SKIPWALLCHECK:
q = -ZOFFSET2 + (krand()&((32<<8)-1));
- for (stati=0; stati < ARRAY_SSIZE(statlist); stati++)
+ for (int stati=0; stati < ARRAY_SSIZE(statnumList); stati++)
{
- int32_t j = headspritestat[statlist[stati]];
-
- while (j >= 0)
+ int32_t otherSprite = headspritestat[statnumList[stati]];
+
+ while (otherSprite >= 0)
{
- const int32_t nextj = nextspritestat[j];
- spritetype *const sj = &sprite[j];
+ int const nextOther = nextspritestat[otherSprite];
+ spritetype *const pOther = &sprite[otherSprite];
// DEFAULT, ZOMBIEACTOR, MISC
- if (stati == 0 || stati >= 5 || AFLAMABLE(sj->picnum))
+ if (stati == 0 || stati >= 5 || AFLAMABLE(pOther->picnum))
{
- if (s->picnum != SHRINKSPARK || (sj->cstat&257))
- if (dist(s, sj) < r)
+ if (pSprite->picnum != SHRINKSPARK || (pOther->cstat&257))
+ if (dist(pSprite, pOther) < blastRadius)
{
- if (A_CheckEnemySprite(sj) && !cansee(sj->x, sj->y,sj->z+q, sj->sectnum, s->x, s->y, s->z+q, s->sectnum))
- goto BOLT;
- A_DamageObject(j, i);
+ if (A_CheckEnemySprite(pOther) && !cansee(pOther->x, pOther->y,pOther->z+q, pOther->sectnum, pSprite->x, pSprite->y, pSprite->z+q, pSprite->sectnum))
+ goto next_sprite;
+ A_DamageObject(otherSprite, spriteNum);
}
}
- else if (sj->extra >= 0 && (uspritetype *)sj != s && (sj->picnum == TRIPBOMB || A_CheckEnemySprite(sj) || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL || (sj->cstat&257) || sj->picnum == DUKELYINGDEAD))
+ else if (pOther->extra >= 0 && (uspritetype *)pOther != pSprite &&
+ (pOther->picnum == TRIPBOMB || A_CheckEnemySprite(pOther) || pOther->picnum == QUEBALL ||
+ pOther->picnum == STRIPEBALL || (pOther->cstat & 257) || pOther->picnum == DUKELYINGDEAD))
{
- if (s->picnum == SHRINKSPARK && sj->picnum != SHARK && (j == s->owner || sj->xrepeat < 24))
+ if ((pSprite->picnum == SHRINKSPARK && pOther->picnum != SHARK &&
+ (otherSprite == pSprite->owner || pOther->xrepeat < 24)) ||
+ (pSprite->picnum == MORTER && otherSprite == pSprite->owner))
{
- j = nextj;
- continue;
- }
- if (s->picnum == MORTER && j == s->owner)
- {
- j = nextj;
+ otherSprite = nextOther;
continue;
}
- if (sj->picnum == APLAYER) sj->z -= PHEIGHT;
- d = dist(s, sj);
- if (sj->picnum == APLAYER) sj->z += PHEIGHT;
+ if (pOther->picnum == APLAYER)
+ pOther->z -= PHEIGHT;
- if (d < r && cansee(sj->x, sj->y, sj->z-(8<<8), sj->sectnum, s->x, s->y, s->z-(12<<8), s->sectnum))
+ d = dist(pSprite, pOther);
+
+ if (pOther->picnum == APLAYER)
+ pOther->z += PHEIGHT;
+
+ if (d < blastRadius && cansee(pOther->x, pOther->y, pOther->z - ZOFFSET3, pOther->sectnum, pSprite->x,
+ pSprite->y, pSprite->z - ZOFFSET4, pSprite->sectnum))
{
- actor[j].ang = getangle(sj->x-s->x,sj->y-s->y);
+ actor[otherSprite].ang = getangle(pOther->x-pSprite->x,pOther->y-pSprite->y);
- if (s->picnum == RPG && sj->extra > 0)
- actor[j].picnum = RPG;
- else if (A_CheckSpriteFlags(i,SFLAG_PROJECTILE) && SpriteProjectile[i].workslike & PROJECTILE_RADIUS_PICNUM && sj->extra > 0)
- actor[j].picnum = s->picnum;
+ if (pSprite->picnum == RPG && pOther->extra > 0)
+ actor[otherSprite].picnum = RPG;
+ else if (A_CheckSpriteFlags(spriteNum,SFLAG_PROJECTILE) && SpriteProjectile[spriteNum].workslike & PROJECTILE_RADIUS_PICNUM && pOther->extra > 0)
+ actor[otherSprite].picnum = pSprite->picnum;
else
{
- if (s->picnum == SHRINKSPARK)
- actor[j].picnum = SHRINKSPARK;
- else actor[j].picnum = RADIUSEXPLOSION;
+ if (pSprite->picnum == SHRINKSPARK)
+ actor[otherSprite].picnum = SHRINKSPARK;
+ else actor[otherSprite].picnum = RADIUSEXPLOSION;
}
- if (s->picnum != SHRINKSPARK)
+ if (pSprite->picnum != SHRINKSPARK)
{
- const int32_t k = r/3;
+ const int32_t k = blastRadius/3;
if (d < k)
{
- if (hp4 == hp3) hp4++;
- actor[j].extra = hp3 + (krand()%(hp4-hp3));
+ if (dmg4 == dmg3) dmg4++;
+ actor[otherSprite].extra = dmg3 + (krand()%(dmg4-dmg3));
}
else if (d < k*2)
{
- if (hp3 == hp2) hp3++;
- actor[j].extra = hp2 + (krand()%(hp3-hp2));
+ if (dmg3 == dmg2) dmg3++;
+ actor[otherSprite].extra = dmg2 + (krand()%(dmg3-dmg2));
}
- else if (d < r)
+ else if (d < blastRadius)
{
- if (hp2 == hp1) hp2++;
- actor[j].extra = hp1 + (krand()%(hp2-hp1));
+ if (dmg2 == dmg1) dmg2++;
+ actor[otherSprite].extra = dmg1 + (krand()%(dmg2-dmg1));
}
- if (!A_CheckSpriteFlags(j, SFLAG_NODAMAGEPUSH))
+ if (!A_CheckSpriteFlags(otherSprite, SFLAG_NODAMAGEPUSH))
{
- if (sj->xvel < 0) sj->xvel = 0;
- sj->xvel += (s->extra<<2);
+ if (pOther->xvel < 0) pOther->xvel = 0;
+ pOther->xvel += (pSprite->extra<<2);
}
- if (sj->picnum == PODFEM1 || sj->picnum == FEM1 ||
- sj->picnum == FEM2 || sj->picnum == FEM3 ||
- sj->picnum == FEM4 || sj->picnum == FEM5 ||
- sj->picnum == FEM6 || sj->picnum == FEM7 ||
- sj->picnum == FEM8 || sj->picnum == FEM9 ||
- sj->picnum == FEM10 || sj->picnum == STATUE ||
- sj->picnum == STATUEFLASH || sj->picnum == SPACEMARINE || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL)
- A_DamageObject(j, i);
+ if (pOther->picnum == PODFEM1 || pOther->picnum == FEM1 || pOther->picnum == FEM2 ||
+ pOther->picnum == FEM3 || pOther->picnum == FEM4 || pOther->picnum == FEM5 ||
+ pOther->picnum == FEM6 || pOther->picnum == FEM7 || pOther->picnum == FEM8 ||
+ pOther->picnum == FEM9 || pOther->picnum == FEM10 || pOther->picnum == STATUE ||
+ pOther->picnum == STATUEFLASH || pOther->picnum == SPACEMARINE || pOther->picnum == QUEBALL ||
+ pOther->picnum == STRIPEBALL)
+ A_DamageObject(otherSprite, spriteNum);
}
- else if (s->extra == 0) actor[j].extra = 0;
+ else if (pSprite->extra == 0) actor[otherSprite].extra = 0;
- if (sj->picnum != RADIUSEXPLOSION &&
- s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS)
+ if (pOther->picnum != RADIUSEXPLOSION &&
+ pSprite->owner >= 0 && sprite[pSprite->owner].statnum < MAXSTATUS)
{
- if (sj->picnum == APLAYER)
+ if (pOther->picnum == APLAYER)
{
- DukePlayer_t *ps = g_player[P_GetP(sj)].ps;
+ DukePlayer_t *ps = g_player[P_GetP(pOther)].ps;
if (ps->newowner >= 0)
G_ClearCameraView(ps);
}
- actor[j].owner = s->owner;
+ actor[otherSprite].owner = pSprite->owner;
}
}
}
-BOLT:
- j = nextj;
+next_sprite:
+ otherSprite = nextOther;
}
}
}
@@ -302,50 +307,47 @@ BOLT:
// : the projectile
// : the SE7
// : below->above change?
-static int32_t Proj_MaybeDoTransport(int32_t spritenum, const uspritetype * const effector, int32_t fromunderp, int32_t daz)
+static int32_t Proj_MaybeDoTransport(int32_t spriteNum, const uspritetype * const pSEffector, int32_t fromunderp, int32_t daz)
{
- if (totalclock <= actor[spritenum].lasttransport)
+ if (totalclock <= actor[spriteNum].lasttransport)
return 0;
- spritetype *const spr = &sprite[spritenum];
- const uspritetype *const otherse = (uspritetype *)&sprite[effector->owner];
+ spritetype *const pSprite = &sprite[spriteNum];
+ const uspritetype *const otherse = (uspritetype *)&sprite[pSEffector->owner];
+ actor[spriteNum].lasttransport = totalclock + (TICSPERFRAME << 2);
- actor[spritenum].lasttransport = totalclock + (TICSPERFRAME<<2);
+ pSprite->x += (otherse->x - pSEffector->x);
+ pSprite->y += (otherse->y - pSEffector->y);
- spr->x += (otherse->x - effector->x);
- spr->y += (otherse->y - effector->y);
+ // above->below
+ pSprite->z = (!fromunderp) ? sector[otherse->sectnum].ceilingz - daz + sector[pSEffector->sectnum].floorz
+ : sector[otherse->sectnum].floorz - daz + sector[pSEffector->sectnum].ceilingz;
+ // below->above
- // above->below
- spr->z = (!fromunderp) ? sector[otherse->sectnum].ceilingz - daz + sector[effector->sectnum].floorz :
- sector[otherse->sectnum].floorz - daz + sector[effector->sectnum].ceilingz;
- // below->above
-
- actor[spritenum].bpos = *(vec3_t *)&sprite[spritenum];
- changespritesect(spritenum, otherse->sectnum);
+ actor[spriteNum].bpos = *(vec3_t *)&sprite[spriteNum];
+ changespritesect(spriteNum, otherse->sectnum);
return 1;
}
// Check whether sprite is on/in a non-SE7 water sector.
// : if not NULL, the sector on the other side.
-int32_t A_CheckNoSE7Water(const spritetype *s, int32_t sectnum, int32_t slotag, int32_t *othersectptr)
+int32_t A_CheckNoSE7Water(uspritetype const * const pSprite, int32_t sectNum, int32_t sectLotag, int32_t *pOther)
{
- if (slotag==ST_1_ABOVE_WATER || slotag==ST_2_UNDERWATER)
+ if (sectLotag == ST_1_ABOVE_WATER || sectLotag == ST_2_UNDERWATER)
{
- int32_t othersect = yax_getneighborsect(
- s->x, s->y, sectnum, slotag==ST_1_ABOVE_WATER ? YAX_FLOOR : YAX_CEILING);
-
- int32_t othertag = (slotag==ST_1_ABOVE_WATER) ?
- ST_2_UNDERWATER : ST_1_ABOVE_WATER;
+ int const otherSect =
+ yax_getneighborsect(pSprite->x, pSprite->y, sectNum, sectLotag == ST_1_ABOVE_WATER ? YAX_FLOOR : YAX_CEILING);
+ int const otherLotag = (sectLotag == ST_1_ABOVE_WATER) ? ST_2_UNDERWATER : ST_1_ABOVE_WATER;
// If submerging, the lower sector MUST have lotag 2.
// If emerging, the upper sector MUST have lotag 1.
// This way, the x/y coordinates where above/below water
// changes can happen are the same.
- if (othersect >= 0 && sector[othersect].lotag==othertag)
+ if (otherSect >= 0 && sector[otherSect].lotag == otherLotag)
{
- if (othersectptr)
- *othersectptr = othersect;
+ if (pOther)
+ *pOther = otherSect;
return 1;
}
}
@@ -359,146 +361,145 @@ int32_t A_CheckNoSE7Water(const spritetype *s, int32_t sectnum, int32_t slotag,
// 1 if yes, but stayed inside [actor[].ceilingz+1, actor[].floorz].
// <0 if yes, but passed a TROR no-SE7 water boundary. -returnvalue-1 is the
// other-side sector number.
-static int32_t A_CheckNeedZUpdate(int32_t spritenum, int32_t changez, int32_t *dazptr)
+static int32_t A_CheckNeedZUpdate(int32_t spriteNum, int32_t zChange, int32_t *pZcoord)
{
- const spritetype *spr = &sprite[spritenum];
- const int32_t daz = spr->z + (changez>>1);
-
- *dazptr = daz;
-
- if (changez == 0)
+ if (zChange == 0)
return 0;
- if (daz > actor[spritenum].ceilingz && daz <= actor[spritenum].floorz)
+ uspritetype const *const pSprite = (uspritetype *)&sprite[spriteNum];
+ int const newZ = pSprite->z + (zChange >> 1);
+
+ *pZcoord = newZ;
+
+ if (newZ > actor[spriteNum].ceilingz && newZ <= actor[spriteNum].floorz)
return 1;
#ifdef YAX_ENABLE
- const int32_t psect=spr->sectnum, slotag=sector[psect].lotag;
- int32_t othersect;
+ int const sectNum = pSprite->sectnum;
+ int const sectLotag = sector[sectNum].lotag;
+ int32_t otherSect;
// Non-SE7 water.
// PROJECTILE_CHSECT
- if ((changez < 0 && slotag==ST_2_UNDERWATER) || (changez > 0 && slotag==ST_1_ABOVE_WATER))
- if (A_CheckNoSE7Water(spr, sprite[spritenum].sectnum, slotag, &othersect))
+ if ((zChange < 0 && sectLotag == ST_2_UNDERWATER) || (zChange > 0 && sectLotag == ST_1_ABOVE_WATER))
+ {
+ if (A_CheckNoSE7Water(pSprite, sprite[spriteNum].sectnum, sectLotag, &otherSect))
{
- A_Spawn(spritenum, WATERSPLASH2);
+ A_Spawn(spriteNum, WATERSPLASH2);
// NOTE: Don't tweak its z position afterwards like with
// SE7-induced projectile teleportation. It doesn't look good
// with TROR water.
- actor[spritenum].flags |= SFLAG_DIDNOSE7WATER;
- return -othersect-1;
+ actor[spriteNum].flags |= SFLAG_DIDNOSE7WATER;
+ return -otherSect-1;
}
+ }
#endif
return 0;
}
-int32_t A_MoveSpriteClipdist(int32_t spritenum, vec3_t const * const change, uint32_t cliptype, int32_t clipdist)
+int32_t A_MoveSpriteClipdist(int32_t spriteNum, vec3_t const * const change, uint32_t clipType, int32_t clipDist)
{
- spritetype * const spr = &sprite[spritenum];
- const int32_t badguy = A_CheckEnemySprite(spr);
- const int32_t oldx = spr->x, oldy = spr->y;
+ spritetype *const pSprite = &sprite[spriteNum];
+ int const isEnemy = A_CheckEnemySprite(pSprite);
+ vec2_t const oldPos = *(vec2_t *)pSprite;
- if (spr->statnum == STAT_MISC || (badguy && spr->xrepeat < 4))
+ if (pSprite->statnum == STAT_MISC || (isEnemy && pSprite->xrepeat < 4))
{
- spr->x += change->x;
- spr->y += change->y;
- spr->z += change->z;
+ pSprite->x += change->x;
+ pSprite->y += change->y;
+ pSprite->z += change->z;
- if (badguy)
- setsprite(spritenum, (vec3_t *)spr);
+ if (isEnemy)
+ setsprite(spriteNum, (vec3_t *)pSprite);
return 0;
}
- if (clipdist >= 0)
+ if (clipDist >= 0)
{
// use that value
}
- else if (A_CheckSpriteFlags(spritenum, SFLAG_REALCLIPDIST))
- clipdist = spr->clipdist<<2;
- else if (badguy)
+ else if (A_CheckSpriteFlags(spriteNum, SFLAG_REALCLIPDIST))
+ clipDist = pSprite->clipdist<<2;
+ else if (isEnemy)
{
- if (spr->xrepeat > 60)
- clipdist = 1024;
- else if (spr->picnum == LIZMAN)
- clipdist = 292;
- else if (A_CheckSpriteFlags(spritenum, SFLAG_BADGUY))
- clipdist = spr->clipdist<<2;
+ if (pSprite->xrepeat > 60)
+ clipDist = 1024;
+ else if (pSprite->picnum == LIZMAN)
+ clipDist = 292;
+ else if (A_CheckSpriteFlags(spriteNum, SFLAG_BADGUY))
+ clipDist = pSprite->clipdist<<2;
else
- clipdist = 192;
+ clipDist = 192;
}
else
{
- if (spr->statnum == STAT_PROJECTILE && (SpriteProjectile[spritenum].workslike & PROJECTILE_REALCLIPDIST) == 0)
- clipdist = 8;
+ if (pSprite->statnum == STAT_PROJECTILE && (SpriteProjectile[spriteNum].workslike & PROJECTILE_REALCLIPDIST) == 0)
+ clipDist = 8;
else
- clipdist = spr->clipdist<<2;
+ clipDist = pSprite->clipdist<<2;
}
- int16_t dasectnum = spr->sectnum;
- const int16_t osectnum = dasectnum;
- int32_t daz = spr->z - 2*tilesiz[spr->picnum].y*spr->yrepeat;
- const int32_t oldz = spr->z;
+ int16_t newSectnum = pSprite->sectnum;
+ int const oldSectnum = newSectnum;
+ int32_t newZ = pSprite->z - 2 * tilesiz[pSprite->picnum].y * pSprite->yrepeat;
+ int const oldZ = pSprite->z;
// Handle horizontal movement first.
- spr->z = daz;
- int32_t retval = clipmove((vec3_t *)spr, &dasectnum,
- change->x<<13, change->y<<13,
- clipdist, 4<<8, 4<<8, cliptype);
- spr->z = oldz;
+ pSprite->z = newZ;
+ int returnValue =
+ clipmove((vec3_t *)pSprite, &newSectnum, change->x << 13, change->y << 13, clipDist, 4 << 8, 4 << 8, clipType);
+ pSprite->z = oldZ;
- if (badguy)
+ if (isEnemy)
{
// Handle potential stayput condition (map-provided or hard-coded).
- if (dasectnum < 0 ||
- ((actor[spritenum].actorstayput >= 0 && actor[spritenum].actorstayput != dasectnum) ||
- (spr->picnum == BOSS2 && spr->pal == 0 && sector[dasectnum].lotag != ST_3) ||
- ((spr->picnum == BOSS1 || spr->picnum == BOSS2) && sector[dasectnum].lotag == ST_1_ABOVE_WATER)
- || (sector[osectnum].lotag != ST_1_ABOVE_WATER && sector[dasectnum].lotag == ST_1_ABOVE_WATER &&
- (spr->picnum == LIZMAN || (spr->picnum == LIZTROOP && spr->zvel == 0)))
- )
- )
+ if (newSectnum < 0 ||
+ ((actor[spriteNum].actorstayput >= 0 && actor[spriteNum].actorstayput != newSectnum) ||
+ (pSprite->picnum == BOSS2 && pSprite->pal == 0 && sector[newSectnum].lotag != ST_3) ||
+ ((pSprite->picnum == BOSS1 || pSprite->picnum == BOSS2) && sector[newSectnum].lotag == ST_1_ABOVE_WATER) ||
+ (sector[oldSectnum].lotag != ST_1_ABOVE_WATER && sector[newSectnum].lotag == ST_1_ABOVE_WATER &&
+ (pSprite->picnum == LIZMAN || (pSprite->picnum == LIZTROOP && pSprite->zvel == 0)))))
{
- spr->x = oldx;
- spr->y = oldy;
+ *(vec2_t *) pSprite = oldPos;
// NOTE: in Duke3D, LIZMAN on water takes on random angle here.
- setsprite(spritenum, (vec3_t *)spr);
+ setsprite(spriteNum, (vec3_t *)pSprite);
- if (dasectnum < 0)
- dasectnum = 0;
+ if (newSectnum < 0)
+ newSectnum = 0;
- return 16384+dasectnum;
+ return 16384+newSectnum;
}
- if ((retval&49152) >= 32768 && actor[spritenum].cgg==0)
- spr->ang += 768;
+ if ((returnValue&49152) >= 32768 && actor[spriteNum].cgg==0)
+ pSprite->ang += 768;
}
- if (dasectnum == -1)
+ if (newSectnum == -1)
{
- dasectnum = spr->sectnum;
+ newSectnum = pSprite->sectnum;
// OSD_Printf("%s:%d wtf\n",__FILE__,__LINE__);
}
- else if (dasectnum != spr->sectnum)
+ else if (newSectnum != pSprite->sectnum)
{
- changespritesect(spritenum, dasectnum);
+ changespritesect(spriteNum, newSectnum);
// A_GetZLimits(spritenum);
}
- Bassert(dasectnum == spr->sectnum);
+ Bassert(newSectnum == pSprite->sectnum);
- int dozupdate = A_CheckNeedZUpdate(spritenum, change->z, &daz);
+ int doZUpdate = A_CheckNeedZUpdate(spriteNum, change->z, &newZ);
// Update sprite's z positions and (for TROR) maybe the sector number.
- if (dozupdate)
+ if (doZUpdate)
{
- spr->z = daz;
+ pSprite->z = newZ;
#ifdef YAX_ENABLE
- if (dozupdate < 0)
+ if (doZUpdate < 0)
{
// If we passed a TROR no-SE7 water boundary, signal to the outside
// that the ceiling/floor was not hit. However, this is not enough:
@@ -508,45 +509,45 @@ int32_t A_MoveSpriteClipdist(int32_t spritenum, vec3_t const * const change, uin
// actor[].flags |= SFLAG_DIDNOSE7WATER in A_CheckNeedZUpdate()
// previously.
// XXX: Why is this contrived data flow necessary? (If at all.)
- changespritesect(spritenum, -dozupdate-1);
+ changespritesect(spriteNum, -doZUpdate-1);
return 0;
}
- if (yax_getbunch(dasectnum, (change->z>0))>=0
- && (SECTORFLD(dasectnum,stat, (change->z>0))&yax_waltosecmask(cliptype))==0)
+ if (yax_getbunch(newSectnum, (change->z>0))>=0
+ && (SECTORFLD(newSectnum,stat, (change->z>0))&yax_waltosecmask(clipType))==0)
{
- setspritez(spritenum, (vec3_t *)spr);
+ setspritez(spriteNum, (vec3_t *)pSprite);
}
#endif
}
- else if (change->z != 0 && retval == 0)
- retval = 16384+dasectnum;
+ else if (change->z != 0 && returnValue == 0)
+ returnValue = 16384+newSectnum;
- if (retval == 16384+dasectnum)
- if (spr->statnum == STAT_PROJECTILE)
+ if (returnValue == 16384 + newSectnum)
+ {
+ if (pSprite->statnum == STAT_PROJECTILE)
{
- int32_t i;
-
// Projectile sector changes due to transport SEs (SE7_PROJECTILE).
// PROJECTILE_CHSECT
- for (SPRITES_OF(STAT_TRANSPORT, i))
- if (sprite[i].sectnum == dasectnum)
+ for (int SPRITES_OF(STAT_TRANSPORT, otherSpriteNum))
+ {
+ if (sprite[otherSpriteNum].sectnum == newSectnum)
{
- const int32_t lotag = sector[dasectnum].lotag;
+ int const sectLotag = sector[newSectnum].lotag;
- if (lotag == ST_1_ABOVE_WATER)
- if (daz >= actor[spritenum].floorz)
- if (Proj_MaybeDoTransport(spritenum, (uspritetype *)&sprite[i], 0, daz))
- return 0;
+ if (sectLotag == ST_1_ABOVE_WATER && newZ >= actor[spriteNum].floorz)
+ if (Proj_MaybeDoTransport(spriteNum, (uspritetype *)&sprite[otherSpriteNum], 0, newZ))
+ return 0;
- if (lotag == ST_2_UNDERWATER)
- if (daz <= actor[spritenum].ceilingz)
- if (Proj_MaybeDoTransport(spritenum, (uspritetype *)&sprite[i], 1, daz))
- return 0;
+ if (sectLotag == ST_2_UNDERWATER && newZ <= actor[spriteNum].ceilingz)
+ if (Proj_MaybeDoTransport(spriteNum, (uspritetype *)&sprite[otherSpriteNum], 1, newZ))
+ return 0;
}
+ }
}
+ }
- return retval;
+ return returnValue;
}
int32_t block_deletesprite = 0;
@@ -570,204 +571,202 @@ void G_Polymer_UnInit(void)
#endif
// deletesprite() game wrapper
-void A_DeleteSprite(int32_t s)
+void A_DeleteSprite(int spriteNum)
{
if (EDUKE32_PREDICT_FALSE(block_deletesprite))
{
- OSD_Printf(OSD_ERROR "A_DeleteSprite(): tried to remove sprite %d in EVENT_EGS\n", s);
+ OSD_Printf(OSD_ERROR "A_DeleteSprite(): tried to remove sprite %d in EVENT_EGS\n", spriteNum);
return;
}
if (VM_HaveEvent(EVENT_KILLIT))
{
- int32_t p, pl = A_FindPlayer(&sprite[s], &p);
+ int32_t playerDist;
+ int playerNum = A_FindPlayer(&sprite[spriteNum], &playerDist);
- if (VM_OnEventWithDist_(EVENT_KILLIT, s, pl, p))
+ if (VM_OnEventWithDist_(EVENT_KILLIT, spriteNum, playerNum, playerDist))
return;
}
#ifdef POLYMER
- if (actor[s].lightptr != NULL && getrendermode() == REND_POLYMER)
- A_DeleteLight(s);
+ if (actor[spriteNum].lightptr != NULL && getrendermode() == REND_POLYMER)
+ A_DeleteLight(spriteNum);
#endif
// AMBIENT_SFX_PLAYING
- if (sprite[s].picnum == MUSICANDSFX && actor[s].t_data[0] == 1)
- S_StopEnvSound(sprite[s].lotag, s);
+ if (sprite[spriteNum].picnum == MUSICANDSFX && actor[spriteNum].t_data[0] == 1)
+ S_StopEnvSound(sprite[spriteNum].lotag, spriteNum);
// NetAlloc
- if (Net_IsRelevantSprite(s))
+ if (Net_IsRelevantSprite(spriteNum))
{
- Net_DeleteSprite(s);
+ Net_DeleteSprite(spriteNum);
return;
}
- deletesprite(s);
+ deletesprite(spriteNum);
}
-void A_AddToDeleteQueue(int32_t i)
+void A_AddToDeleteQueue(int32_t spriteNum)
{
- if (g_spriteDeleteQueueSize == 0)
+ if (g_deleteQueueSize == 0)
{
- A_DeleteSprite(i);
+ A_DeleteSprite(spriteNum);
return;
}
if (SpriteDeletionQueue[g_spriteDeleteQueuePos] >= 0)
sprite[SpriteDeletionQueue[g_spriteDeleteQueuePos]].xrepeat = 0;
- SpriteDeletionQueue[g_spriteDeleteQueuePos] = i;
- g_spriteDeleteQueuePos = (g_spriteDeleteQueuePos+1)%g_spriteDeleteQueueSize;
+ SpriteDeletionQueue[g_spriteDeleteQueuePos] = spriteNum;
+ g_spriteDeleteQueuePos = (g_spriteDeleteQueuePos+1)%g_deleteQueueSize;
}
-void A_SpawnMultiple(int32_t sp, int32_t pic, int32_t n)
+void A_SpawnMultiple(int32_t spriteNum, int32_t tileNum, int32_t spawnCnt)
{
- int32_t j;
- spritetype *s = &sprite[sp];
+ spritetype *pSprite = &sprite[spriteNum];
- for (; n>0; n--)
+ for (; spawnCnt>0; spawnCnt--)
{
- j = A_InsertSprite(s->sectnum,s->x,s->y,s->z-(krand()%(47<<8)),pic,-32,8,8,krand()&2047,0,0,sp,5);
+ int const j = A_InsertSprite(pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z - (krand() % (47 << 8)), tileNum, -32, 8,
+ 8, krand() & 2047, 0, 0, spriteNum, 5);
A_Spawn(-1, j);
sprite[j].cstat = krand()&12;
}
}
-void A_DoGuts(int32_t sp, int32_t gtype, int32_t n)
+void A_DoGuts(int32_t spriteNum, int32_t tileNum, int32_t spawnCnt)
{
- int32_t gutz,floorz;
- int32_t i,a,j,sx = 32,sy = 32;
+ uspritetype const *const pSprite = (uspritetype *)&sprite[spriteNum];
+ vec2_t repeat = { 32, 32 };
- uspritetype const * const s = (uspritetype *)&sprite[sp];
+ if (A_CheckEnemySprite(pSprite) && pSprite->xrepeat < 16)
+ repeat.x = repeat.y = 8;
- if (A_CheckEnemySprite(s) && s->xrepeat < 16)
- sx = sy = 8;
+ int gutZ = pSprite->z - ZOFFSET3;
+ int floorz = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y);
- gutz = s->z-(8<<8);
- floorz = getflorzofslope(s->sectnum,s->x,s->y);
+ if (gutZ > (floorz-ZOFFSET3))
+ gutZ = floorz-ZOFFSET3;
- if (gutz > (floorz-(8<<8)))
- gutz = floorz-(8<<8);
+ if (pSprite->picnum == COMMANDER)
+ gutZ -= (24<<8);
- if (s->picnum == COMMANDER)
- gutz -= (24<<8);
-
- for (j=n; j>0; j--)
+ for (int j=spawnCnt; j>0; j--)
{
- a = krand()&2047;
- i = A_InsertSprite(s->sectnum,s->x+(krand()&255)-128,s->y+(krand()&255)-128,gutz-(krand()&8191),gtype,-32,sx,sy,a,48+(krand()&31),-512-(krand()&2047),sp,5);
- if (PN == JIBS2)
+ int const i = A_InsertSprite(pSprite->sectnum, pSprite->x + (krand() & 255) - 128,
+ pSprite->y + (krand() & 255) - 128, gutZ - (krand() & 8191), tileNum, -32, repeat.x,
+ repeat.y, krand() & 2047, 48 + (krand() & 31), -512 - (krand() & 2047), spriteNum, 5);
+
+ if (PN(i) == JIBS2)
{
sprite[i].xrepeat >>= 2;
sprite[i].yrepeat >>= 2;
}
- sprite[i].pal = s->pal;
+ sprite[i].pal = pSprite->pal;
}
}
-void A_DoGutsDir(int32_t sp, int32_t gtype, int32_t n)
+void A_DoGutsDir(int32_t spriteNum, int32_t tileNum, int32_t spawnCnt)
{
- int32_t gutz,floorz;
- int32_t i,a,j,sx = 32,sy = 32;
- uspritetype const * const s = (uspritetype *)&sprite[sp];
+ uspritetype const * const s = (uspritetype *)&sprite[spriteNum];
+ vec2_t repeat ={ 32, 32 };
if (A_CheckEnemySprite(s) && s->xrepeat < 16)
- sx = sy = 8;
+ repeat.x = repeat.y = 8;
- gutz = s->z-(8<<8);
- floorz = getflorzofslope(s->sectnum,s->x,s->y);
+ int gutZ = s->z-ZOFFSET3;
+ int floorZ = getflorzofslope(s->sectnum,s->x,s->y);
- if (gutz > (floorz-(8<<8)))
- gutz = floorz-(8<<8);
+ if (gutZ > (floorZ-ZOFFSET3))
+ gutZ = floorZ-ZOFFSET3;
if (s->picnum == COMMANDER)
- gutz -= (24<<8);
+ gutZ -= (24<<8);
- for (j=n; j>0; j--)
+ for (int j=spawnCnt; j>0; j--)
{
- a = krand()&2047;
- i = A_InsertSprite(s->sectnum,s->x,s->y,gutz,gtype,-32,sx,sy,a,256+(krand()&127),-512-(krand()&2047),sp,5);
+ int const i = A_InsertSprite(s->sectnum, s->x, s->y, gutZ, tileNum, -32, repeat.x, repeat.y, krand() & 2047,
+ 256 + (krand() & 127), -512 - (krand() & 2047), spriteNum, 5);
sprite[i].pal = s->pal;
}
}
-LUNATIC_EXTERN int32_t G_ToggleWallInterpolation(int32_t w, int32_t doset)
+LUNATIC_EXTERN int32_t G_ToggleWallInterpolation(int32_t wallNum, int32_t setInterpolation)
{
- if (doset)
+ if (setInterpolation)
{
- return G_SetInterpolation(&wall[w].x)
- || G_SetInterpolation(&wall[w].y);
+ return G_SetInterpolation(&wall[wallNum].x) || G_SetInterpolation(&wall[wallNum].y);
}
else
{
- G_StopInterpolation(&wall[w].x);
- G_StopInterpolation(&wall[w].y);
+ G_StopInterpolation(&wall[wallNum].x);
+ G_StopInterpolation(&wall[wallNum].y);
return 0;
}
}
-void Sect_ToggleInterpolation(int sectnum, int doset)
+void Sect_ToggleInterpolation(int sectNum, int setInterpolation)
{
- int k, j = sector[sectnum].wallptr;
- const int endwall = sector[sectnum].wallptr + sector[sectnum].wallnum;
-
- for (; j= 0)
+ int const nextWall = wall[j].nextwall;
+
+ if (nextWall >= 0)
{
- G_ToggleWallInterpolation(k, doset);
- G_ToggleWallInterpolation(wall[k].point2, doset);
+ G_ToggleWallInterpolation(nextWall, setInterpolation);
+ G_ToggleWallInterpolation(wall[nextWall].point2, setInterpolation);
}
}
}
-static int32_t move_rotfixed_sprite(int32_t j, int32_t pivotspr, int32_t daang)
+static int32_t move_rotfixed_sprite(int32_t spriteNum, int32_t pivotSpriteNum, int32_t pivotAngle)
{
- if ((ROTFIXSPR_STATNUMP(sprite[j].statnum) ||
- ((sprite[j].statnum == STAT_ACTOR || sprite[j].statnum == STAT_ZOMBIEACTOR) &&
- A_CheckSpriteFlags(j, SFLAG_ROTFIXED))) &&
- actor[j].t_data[7] == (ROTFIXSPR_MAGIC | pivotspr))
+ if ((ROTFIXSPR_STATNUMP(sprite[spriteNum].statnum) ||
+ ((sprite[spriteNum].statnum == STAT_ACTOR || sprite[spriteNum].statnum == STAT_ZOMBIEACTOR) &&
+ A_CheckSpriteFlags(spriteNum, SFLAG_ROTFIXED))) &&
+ actor[spriteNum].t_data[7] == (ROTFIXSPR_MAGIC | pivotSpriteNum))
{
- rotatepoint(zerovec, *(vec2_t *)&actor[j].t_data[8], daang & 2047, (vec2_t *)&sprite[j].x);
- sprite[j].x += sprite[pivotspr].x;
- sprite[j].y += sprite[pivotspr].y;
+ rotatepoint(zerovec, *(vec2_t *)&actor[spriteNum].t_data[8], pivotAngle & 2047, (vec2_t *)&sprite[spriteNum].x);
+ sprite[spriteNum].x += sprite[pivotSpriteNum].x;
+ sprite[spriteNum].y += sprite[pivotSpriteNum].y;
return 0;
}
return 1;
}
-void A_MoveSector(int i)
+void A_MoveSector(int spriteNum)
{
// T1,T2 and T3 are used for all the sector moving stuff!!!
- spritetype * const s = &sprite[i];
- int32_t p, pl = A_FindPlayer(s, &p);
- int const k = VM_OnEventWithBoth(EVENT_MOVESECTOR, i, pl, p, T3);
- int j = T2;
+ int32_t playerDist;
+ spritetype *const pSprite = &sprite[spriteNum];
+ int const playerNum = A_FindPlayer(pSprite, &playerDist);
+ int const rotateAngle = VM_OnEventWithBoth(EVENT_MOVESECTOR, spriteNum, playerNum, playerDist, T3(spriteNum));
+ int originIdx = T2(spriteNum);
- s->x += (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14;
- s->y += (s->xvel * (sintable[s->ang & 2047])) >> 14;
+ pSprite->x += (pSprite->xvel * (sintable[(pSprite->ang + 512) & 2047])) >> 14;
+ pSprite->y += (pSprite->xvel * (sintable[pSprite->ang & 2047])) >> 14;
- const int endwall = sector[s->sectnum].wallptr + sector[s->sectnum].wallnum;
+ int const endWall = sector[pSprite->sectnum].wallptr + sector[pSprite->sectnum].wallnum;
- for (i = sector[s->sectnum].wallptr; i < endwall; i++)
+ for (int wallNum = sector[pSprite->sectnum].wallptr; wallNum < endWall; wallNum++)
{
- vec2_t const v = g_origins[j];
- vec2_t t;
- rotatepoint(zerovec, v, k & 2047, &t);
- dragpoint(i, s->x + t.x, s->y + t.y, 0);
+ vec2_t const origin = g_origins[originIdx];
+ vec2_t result;
+ rotatepoint(zerovec, origin, rotateAngle & 2047, &result);
+ dragpoint(wallNum, pSprite->x + result.x, pSprite->y + result.y, 0);
- j++;
+ originIdx++;
}
}
#if !defined LUNATIC
// NOTE: T5 is AC_ACTION_ID
-# define LIGHTRAD_PICOFS (T5 ? *(script + T5) + (*(script + T5 + 2)) * AC_CURFRAME(actor[i].t_data) : 0)
+# define LIGHTRAD_PICOFS (T5(i) ? *(apScript + T5(i)) + (*(apScript + T5(i) + 2)) * AC_CURFRAME(actor[i].t_data) : 0)
#else
// startframe + viewtype*[cyclic counter]
# define LIGHTRAD_PICOFS (actor[i].ac.startframe + actor[i].ac.viewtype * AC_CURFRAME(actor[i].t_data))
@@ -852,58 +851,60 @@ void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t
// sleeping monsters, etc
ACTOR_STATIC void G_MoveZombieActors(void)
{
- int32_t i = headspritestat[STAT_ZOMBIEACTOR], j;
+ int32_t spriteNum = headspritestat[STAT_ZOMBIEACTOR], j;
- while (i >= 0)
+ while (spriteNum >= 0)
{
- const int32_t nexti = nextspritestat[i];
+ int const nextSprite = nextspritestat[spriteNum];
- int32_t x;
- spritetype *const s = &sprite[i];
- const int32_t p = A_FindPlayer(s,&x);
+ int32_t playerDist;
+ spritetype *const pSprite = &sprite[spriteNum];
+ int const playerNum = A_FindPlayer(pSprite,&playerDist);
- int16_t ssect = s->sectnum;
- int16_t psect = s->sectnum;
-
- if (sprite[g_player[p].ps->i].extra > 0)
+ if (sprite[g_player[playerNum].ps->i].extra > 0)
{
- if (x < 30000)
+ if (playerDist < 30000)
{
- actor[i].timetosleep++;
- if (actor[i].timetosleep >= (x>>8))
+ actor[spriteNum].timetosleep++;
+ if (actor[spriteNum].timetosleep >= (playerDist>>8))
{
- if (A_CheckEnemySprite(s))
+ if (A_CheckEnemySprite(pSprite))
{
- const int32_t px = g_player[p].ps->opos.x+64-(krand()&127);
- const int32_t py = g_player[p].ps->opos.y+64-(krand()&127);
- int32_t sx, sy;
+ vec2_t const p = { g_player[playerNum].ps->opos.x + 64 - (krand() & 127),
+ g_player[playerNum].ps->opos.y + 64 - (krand() & 127) };
+ int16_t pSectnum = g_player[playerNum].ps->cursectnum;
- updatesector(px,py,&psect);
- if (psect == -1)
+ updatesector(p.x, p.y, &pSectnum);
+
+ if (pSectnum == -1)
{
- i = nexti;
+ spriteNum = nextSprite;
continue;
}
- sx = s->x+64-(krand()&127);
- sy = s->y+64-(krand()&127);
- updatesector(px,py,&ssect);
- if (ssect == -1)
+ vec2_t const s = { pSprite->x + 64 - (krand() & 127), pSprite->y + 64 - (krand() & 127) };
+ int16_t sectNum = pSprite->sectnum;
+
+ updatesector(p.x,p.y,§Num);
+
+ if (sectNum == -1)
{
- i = nexti;
+ spriteNum = nextSprite;
continue;
}
- j = cansee(sx,sy,s->z-(krand()%(52<<8)),s->sectnum, px,py,
- g_player[p].ps->opos.z-(krand()%(32<<8)),g_player[p].ps->cursectnum);
+ j = cansee(s.x, s.y, pSprite->z - (krand() % (52 << 8)), sectNum, p.x, p.y,
+ g_player[playerNum].ps->opos.z - (krand() % (32 << 8)), pSectnum);
}
else
- j = cansee(s->x,s->y,s->z-((krand()&31)<<8),s->sectnum, g_player[p].ps->opos.x,g_player[p].ps->opos.y,
- g_player[p].ps->opos.z-((krand()&31)<<8), g_player[p].ps->cursectnum);
+ j =
+ cansee(pSprite->x, pSprite->y, pSprite->z - ((krand() & 31) << 8), pSprite->sectnum,
+ g_player[playerNum].ps->opos.x, g_player[playerNum].ps->opos.y,
+ g_player[playerNum].ps->opos.z - ((krand() & 31) << 8), g_player[playerNum].ps->cursectnum);
if (j)
{
- switch (DYNAMICTILEMAP(s->picnum))
+ switch (DYNAMICTILEMAP(pSprite->picnum))
{
case RUBBERCAN__STATIC:
case EXPLODINGBARREL__STATIC:
@@ -919,39 +920,39 @@ ACTOR_STATIC void G_MoveZombieActors(void)
case NUKEBARRELDENTED__STATIC:
case NUKEBARRELLEAKED__STATIC:
case TRIPBOMB__STATIC:
- if (sector[s->sectnum].ceilingstat&1 && A_CheckSpriteFlags(i,SFLAG_NOSHADE) == 0)
- s->shade = sector[s->sectnum].ceilingshade;
- else s->shade = sector[s->sectnum].floorshade;
+ if (sector[pSprite->sectnum].ceilingstat&1 && A_CheckSpriteFlags(spriteNum,SFLAG_NOSHADE) == 0)
+ pSprite->shade = sector[pSprite->sectnum].ceilingshade;
+ else pSprite->shade = sector[pSprite->sectnum].floorshade;
- actor[i].timetosleep = 0;
- changespritestat(i, STAT_STANDABLE);
+ actor[spriteNum].timetosleep = 0;
+ changespritestat(spriteNum, STAT_STANDABLE);
break;
case RECON__STATIC:
- CS |= 257;
+ CS(spriteNum) |= 257;
// fall-through
default:
- if (A_CheckSpriteFlags(i, SFLAG_USEACTIVATOR) && sector[sprite[i].sectnum].lotag & 16384)
+ if (A_CheckSpriteFlags(spriteNum, SFLAG_USEACTIVATOR) && sector[sprite[spriteNum].sectnum].lotag & 16384)
break;
- actor[i].timetosleep = 0;
- A_PlayAlertSound(i);
- changespritestat(i, STAT_ACTOR);
+ actor[spriteNum].timetosleep = 0;
+ A_PlayAlertSound(spriteNum);
+ changespritestat(spriteNum, STAT_ACTOR);
break;
}
}
- else actor[i].timetosleep = 0;
+ else actor[spriteNum].timetosleep = 0;
}
}
- if (A_CheckEnemySprite(s) && A_CheckSpriteFlags(i,SFLAG_NOSHADE) == 0)
+ if (A_CheckEnemySprite(pSprite) && A_CheckSpriteFlags(spriteNum,SFLAG_NOSHADE) == 0)
{
- if (sector[s->sectnum].ceilingstat&1)
- s->shade = sector[s->sectnum].ceilingshade;
- else s->shade = sector[s->sectnum].floorshade;
+ if (sector[pSprite->sectnum].ceilingstat&1)
+ pSprite->shade = sector[pSprite->sectnum].ceilingshade;
+ else pSprite->shade = sector[pSprite->sectnum].floorshade;
}
}
- i = nexti;
+ spriteNum = nextSprite;
}
}
@@ -959,59 +960,58 @@ ACTOR_STATIC void G_MoveZombieActors(void)
FORCE_INLINE int G_FindExplosionInSector(int sectnum)
{
for (int SPRITES_OF(STAT_MISC, i))
- if (PN == EXPLOSION2 && sectnum == SECT)
+ if (PN(i) == EXPLOSION2 && sectnum == SECT(i))
return i;
return -1;
}
-FORCE_INLINE void P_Nudge(int p, int sn, int shl)
+FORCE_INLINE void P_Nudge(int playerNum, int spriteNum, int shiftLeft)
{
- g_player[p].ps->vel.x += actor[sn].extra * (sintable[(actor[sn].ang + 512) & 2047]) << shl;
- g_player[p].ps->vel.y += actor[sn].extra * (sintable[actor[sn].ang & 2047]) << shl;
+ g_player[playerNum].ps->vel.x += actor[spriteNum].extra * (sintable[(actor[spriteNum].ang + 512) & 2047]) << shiftLeft;
+ g_player[playerNum].ps->vel.y += actor[spriteNum].extra * (sintable[actor[spriteNum].ang & 2047]) << shiftLeft;
}
-int32_t A_IncurDamage(int32_t sn)
+int32_t A_IncurDamage(int32_t spriteNum)
{
- spritetype *const targ = &sprite[sn];
- actor_t *const dmg = &actor[sn];
+ spritetype *const pSprite = &sprite[spriteNum];
+ actor_t *const pActor = &actor[spriteNum];
// dmg->picnum check: safety, since it might have been set to <0 from CON.
- if (dmg->extra < 0 || targ->extra < 0 || dmg->picnum < 0)
+ if (pActor->extra < 0 || pSprite->extra < 0 || pActor->picnum < 0)
{
- dmg->extra = -1;
+ pActor->extra = -1;
return -1;
}
- if (targ->picnum == APLAYER)
+ if (pSprite->picnum == APLAYER)
{
- const int p = P_GetP(targ);
-
- if (ud.god && dmg->picnum != SHRINKSPARK)
+ if (ud.god && pActor->picnum != SHRINKSPARK)
return -1;
- if (dmg->owner >= 0 && ud.ffire == 0 && sprite[dmg->owner].picnum == APLAYER &&
+ const int 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[p].ps->team == g_player[P_Get(dmg->owner)].ps->team)))
+ (GametypeFlags[ud.coop] & GAMETYPE_TDM && g_player[playerNum].ps->team == g_player[P_Get(pActor->owner)].ps->team)))
return -1;
- targ->extra -= dmg->extra;
+ pSprite->extra -= pActor->extra;
- if (dmg->owner >= 0 && targ->extra <= 0 && dmg->picnum != FREEZEBLAST)
+ if (pActor->owner >= 0 && pSprite->extra <= 0 && pActor->picnum != FREEZEBLAST)
{
- const int32_t ow = dmg->owner;
+ int const damageOwner = pActor->owner;
- targ->extra = 0;
+ pSprite->extra = 0;
+ g_player[playerNum].ps->wackedbyactor = damageOwner;
- g_player[p].ps->wackedbyactor = ow;
+ if (sprite[damageOwner].picnum == APLAYER && playerNum != P_Get(damageOwner))
+ g_player[playerNum].ps->frag_ps = P_Get(damageOwner);
- if (sprite[ow].picnum == APLAYER && p != P_Get(ow))
- g_player[p].ps->frag_ps = P_Get(ow);
-
- dmg->owner = g_player[p].ps->i;
+ pActor->owner = g_player[playerNum].ps->i;
}
- switch (DYNAMICTILEMAP(dmg->picnum))
+ switch (DYNAMICTILEMAP(pActor->picnum))
{
case RADIUSEXPLOSION__STATIC:
case RPG__STATIC:
@@ -1020,116 +1020,111 @@ int32_t A_IncurDamage(int32_t sn)
case SEENINE__STATIC:
case OOZFILTER__STATIC:
case EXPLODINGBARREL__STATIC:
- P_Nudge(p, sn, 2);
+ P_Nudge(playerNum, spriteNum, 2);
break;
default:
- if (A_CheckSpriteFlags(dmg->owner, SFLAG_PROJECTILE) &&
- (SpriteProjectile[dmg->owner].workslike & PROJECTILE_RPG))
- P_Nudge(p, sn, 2);
- else
- P_Nudge(p, sn, 1);
+ P_Nudge(playerNum, spriteNum, (A_CheckSpriteFlags(pActor->owner, SFLAG_PROJECTILE) &&
+ (SpriteProjectile[pActor->owner].workslike & PROJECTILE_RPG))
+ ? 2
+ : 1);
break;
}
- dmg->extra = -1;
- return dmg->picnum;
+ pActor->extra = -1;
+ return pActor->picnum;
}
- if (dmg->extra == 0 && dmg->picnum == SHRINKSPARK && targ->xrepeat < 24)
+ if (pActor->extra == 0 && pActor->picnum == SHRINKSPARK && pSprite->xrepeat < 24)
return -1;
- targ->extra -= dmg->extra;
+ pSprite->extra -= pActor->extra;
- if (targ->picnum != RECON && targ->owner >= 0 && sprite[targ->owner].statnum < MAXSTATUS)
- targ->owner = dmg->owner;
+ if (pSprite->picnum != RECON && pSprite->owner >= 0 && sprite[pSprite->owner].statnum < MAXSTATUS)
+ pSprite->owner = pActor->owner;
- dmg->extra = -1;
+ pActor->extra = -1;
- return dmg->picnum;
+ return pActor->picnum;
}
void A_MoveCyclers(void)
{
- int32_t i;
-
- for (i=g_numCyclers-1; i>=0; i--)
+ for (int i=g_numCyclers-1; i>=0; i--)
{
- int16_t *const c = cyclers[i];
- const int32_t sect = c[0];
- const int32_t t = c[3];
- int32_t j = t + (sintable[c[1]&2047]>>10);
- int32_t cshade = c[2];
+ int16_t *const pCycler = cyclers[i];
+ const int32_t sectNum = pCycler[0];
+ const int32_t t = pCycler[3];
+ int32_t j = t + (sintable[pCycler[1] & 2047] >> 10);
+ int32_t cshade = pCycler[2];
if (j < cshade)
j = cshade;
else if (j > t)
j = t;
- c[1] += sector[sect].extra;
+ pCycler[1] += sector[sectNum].extra;
- if (c[5])
+ if (pCycler[5])
{
- walltype *wal = &wall[sector[sect].wallptr];
- int32_t x;
+ walltype *pWall = &wall[sector[sectNum].wallptr];
- for (x = sector[sect].wallnum; x>0; x--,wal++)
+ for (int wallsLeft = sector[sectNum].wallnum; wallsLeft > 0; wallsLeft--, pWall++)
{
- if (wal->hitag != 1)
+ if (pWall->hitag != 1)
{
- wal->shade = j;
+ pWall->shade = j;
- if ((wal->cstat&2) && wal->nextwall >= 0)
- wall[wal->nextwall].shade = j;
+ if ((pWall->cstat&2) && pWall->nextwall >= 0)
+ wall[pWall->nextwall].shade = j;
}
}
- sector[sect].floorshade = sector[sect].ceilingshade = j;
+ sector[sectNum].floorshade = sector[sectNum].ceilingshade = j;
}
}
}
void A_MoveDummyPlayers(void)
{
- int32_t i = headspritestat[STAT_DUMMYPLAYER];
+ int32_t spriteNum = headspritestat[STAT_DUMMYPLAYER];
- while (i >= 0)
+ while (spriteNum >= 0)
{
- const int32_t p = P_Get(OW);
- DukePlayer_t *const ps = g_player[p].ps;
+ int const playerNum = P_Get(OW(spriteNum));
+ DukePlayer_t *const pPlayer = g_player[playerNum].ps;
+ int const nextSprite = nextspritestat[spriteNum];
+ int const playerSectnum = pPlayer->cursectnum;
- const int32_t nexti = nextspritestat[i];
- const int32_t psectnum = ps->cursectnum;
-
- if (ps->on_crane >= 0 || (psectnum >= 0 && sector[psectnum].lotag != ST_1_ABOVE_WATER) || sprite[ps->i].extra <= 0)
+ if (pPlayer->on_crane >= 0 || (playerSectnum >= 0 && sector[playerSectnum].lotag != ST_1_ABOVE_WATER) || sprite[pPlayer->i].extra <= 0)
{
- ps->dummyplayersprite = -1;
- KILLIT(i);
+ pPlayer->dummyplayersprite = -1;
+ KILLIT(spriteNum);
}
else
{
- if (ps->on_ground && ps->on_warping_sector == 1 && psectnum >= 0 && sector[psectnum].lotag == ST_1_ABOVE_WATER)
+ if (pPlayer->on_ground && pPlayer->on_warping_sector == 1 && playerSectnum >= 0 && sector[playerSectnum].lotag == ST_1_ABOVE_WATER)
{
- CS = 257;
- SZ = sector[SECT].ceilingz+(27<<8);
- SA = ps->ang;
- if (T1 == 8)
- T1 = 0;
- else T1++;
+ CS(spriteNum) = 257;
+ SZ(spriteNum) = sector[SECT(spriteNum)].ceilingz+(27<<8);
+ SA(spriteNum) = pPlayer->ang;
+ if (T1(spriteNum) == 8)
+ T1(spriteNum) = 0;
+ else T1(spriteNum)++;
}
else
{
- if (sector[SECT].lotag != ST_2_UNDERWATER) SZ = sector[SECT].floorz;
- CS = 32768;
+ if (sector[SECT(spriteNum)].lotag != ST_2_UNDERWATER) SZ(spriteNum) = sector[SECT(spriteNum)].floorz;
+ CS(spriteNum) = 32768;
}
}
- SX += (ps->pos.x-ps->opos.x);
- SY += (ps->pos.y-ps->opos.y);
- setsprite(i, (vec3_t *)&sprite[i]);
+ SX(spriteNum) += (pPlayer->pos.x-pPlayer->opos.x);
+ SY(spriteNum) += (pPlayer->pos.y-pPlayer->opos.y);
+ setsprite(spriteNum, (vec3_t *)&sprite[spriteNum]);
-BOLT:
- i = nexti;
+next_sprite:
+ spriteNum = nextSprite;
}
}
@@ -1140,283 +1135,286 @@ static void P_FinishWaterChange(int32_t j, DukePlayer_t *ps, int32_t sectlotag,
ACTOR_STATIC void G_MovePlayers(void)
{
- int32_t i = headspritestat[STAT_PLAYER];
+ int32_t spriteNum = headspritestat[STAT_PLAYER];
- while (i >= 0)
+ while (spriteNum >= 0)
{
- const int32_t nexti = nextspritestat[i];
+ int const nextSprite = nextspritestat[spriteNum];
+ spritetype *const pSprite = &sprite[spriteNum];
+ DukePlayer_t *const pPlayer = g_player[P_GetP(pSprite)].ps;
- spritetype *const s = &sprite[i];
- DukePlayer_t *const p = g_player[P_GetP(s)].ps;
-
- if (s->owner >= 0)
+ if (pSprite->owner >= 0)
{
- if (p->newowner >= 0) //Looking thru the camera
+ if (pPlayer->newowner >= 0) //Looking thru the camera
{
- s->x = p->opos.x;
- s->y = p->opos.y;
- actor[i].bpos.z = s->z = p->opos.z+PHEIGHT;
- s->ang = p->oang;
- setsprite(i,(vec3_t *)s);
+ pSprite->x = pPlayer->opos.x;
+ pSprite->y = pPlayer->opos.y;
+ pSprite->z = pPlayer->opos.z + PHEIGHT;
+ actor[spriteNum].bpos.z = pSprite->z;
+ pSprite->ang = pPlayer->oang;
+
+ setsprite(spriteNum, (vec3_t *)pSprite);
}
else
{
int32_t otherx;
#ifdef YAX_ENABLE
// TROR water submerge/emerge
- const int32_t psect=s->sectnum, slotag=sector[psect].lotag;
- int32_t othersect;
+ int const playerSectnum = pSprite->sectnum;
+ int const sectorLotag = sector[playerSectnum].lotag;
+ int32_t otherSector;
- if (A_CheckNoSE7Water(s, psect, slotag, &othersect))
+ if (A_CheckNoSE7Water((uspritetype const *)pSprite, playerSectnum, sectorLotag, &otherSector))
{
int32_t k = 0;
// NOTE: Compare with G_MoveTransports().
- p->on_warping_sector = 1;
+ pPlayer->on_warping_sector = 1;
- if (slotag==ST_1_ABOVE_WATER)
- k = P_Submerge(i, P_GetP(s), p, psect, othersect);
+ if (sectorLotag==ST_1_ABOVE_WATER)
+ k = P_Submerge(spriteNum, P_GetP(pSprite), pPlayer, playerSectnum, otherSector);
else
- k = P_Emerge(i, P_GetP(s), p, psect, othersect);
+ k = P_Emerge(spriteNum, P_GetP(pSprite), pPlayer, playerSectnum, otherSector);
if (k == 1)
- P_FinishWaterChange(i, p, slotag, -1, othersect);
+ P_FinishWaterChange(spriteNum, pPlayer, sectorLotag, -1, otherSector);
}
#endif
if (g_netServer || ud.multimode > 1)
- otherp = P_FindOtherPlayer(P_GetP(s), &otherx);
+ otherp = P_FindOtherPlayer(P_GetP(pSprite), &otherx);
else
{
- otherp = P_GetP(s);
+ otherp = P_GetP(pSprite);
otherx = 0;
}
- if (G_HaveActor(sprite[i].picnum))
- A_Execute(i, P_GetP(s), otherx);
+ if (G_HaveActor(sprite[spriteNum].picnum))
+ A_Execute(spriteNum, P_GetP(pSprite), otherx);
if (g_netServer || ud.multimode > 1)
+ {
if (sprite[g_player[otherp].ps->i].extra > 0)
{
- if (s->yrepeat > 32 && sprite[g_player[otherp].ps->i].yrepeat < 32)
+ if (pSprite->yrepeat > 32 && sprite[g_player[otherp].ps->i].yrepeat < 32)
{
- if (otherx < 1400 && p->knee_incs == 0)
+ if (otherx < 1400 && pPlayer->knee_incs == 0)
{
- p->knee_incs = 1;
- p->weapon_pos = -1;
- p->actorsqu = g_player[otherp].ps->i;
+ pPlayer->knee_incs = 1;
+ pPlayer->weapon_pos = -1;
+ pPlayer->actorsqu = g_player[otherp].ps->i;
}
}
}
+ }
if (ud.god)
{
- s->extra = p->max_player_health;
- s->cstat = 257;
+ pSprite->extra = pPlayer->max_player_health;
+ pSprite->cstat = 257;
if (!WW2GI)
- p->inv_amount[GET_JETPACK] = 1599;
+ pPlayer->inv_amount[GET_JETPACK] = 1599;
}
- if (s->extra > 0)
+ if (pSprite->extra > 0)
{
- actor[i].owner = i;
+ actor[spriteNum].owner = spriteNum;
if (ud.god == 0)
- if (G_CheckForSpaceCeiling(s->sectnum) || G_CheckForSpaceFloor(s->sectnum))
- P_QuickKill(p);
+ if (G_CheckForSpaceCeiling(pSprite->sectnum) || G_CheckForSpaceFloor(pSprite->sectnum))
+ P_QuickKill(pPlayer);
}
else
{
- p->pos.x = s->x;
- p->pos.y = s->y;
- p->pos.z = s->z-(20<<8);
+ pPlayer->pos.x = pSprite->x;
+ pPlayer->pos.y = pSprite->y;
+ pPlayer->pos.z = pSprite->z-(20<<8);
- p->newowner = -1;
+ pPlayer->newowner = -1;
- if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS)
+ if (pPlayer->wackedbyactor >= 0 && sprite[pPlayer->wackedbyactor].statnum < MAXSTATUS)
{
- p->ang += G_GetAngleDelta(p->ang,getangle(sprite[p->wackedbyactor].x-p->pos.x,sprite[p->wackedbyactor].y-p->pos.y))>>1;
- p->ang &= 2047;
+ pPlayer->ang += G_GetAngleDelta(pPlayer->ang,getangle(sprite[pPlayer->wackedbyactor].x-pPlayer->pos.x,sprite[pPlayer->wackedbyactor].y-pPlayer->pos.y))>>1;
+ pPlayer->ang &= 2047;
}
}
- s->ang = p->ang;
+ pSprite->ang = pPlayer->ang;
}
}
else
{
- if (p->holoduke_on == -1)
- KILLIT(i);
+ if (pPlayer->holoduke_on == -1)
+ KILLIT(spriteNum);
- Bmemcpy(&actor[i].bpos, s, sizeof(vec3_t));
- s->cstat = 0;
+ Bmemcpy(&actor[spriteNum].bpos, pSprite, sizeof(vec3_t));
+ pSprite->cstat = 0;
- if (s->xrepeat < 42)
+ if (pSprite->xrepeat < 42)
{
- s->xrepeat += 4;
- s->cstat |= 2;
+ pSprite->xrepeat += 4;
+ pSprite->cstat |= 2;
}
- else s->xrepeat = 42;
+ else pSprite->xrepeat = 42;
- if (s->yrepeat < 36)
- s->yrepeat += 4;
+ if (pSprite->yrepeat < 36)
+ pSprite->yrepeat += 4;
else
{
- s->yrepeat = 36;
- if (sector[s->sectnum].lotag != ST_2_UNDERWATER)
- A_Fall(i);
- if (s->zvel == 0 && sector[s->sectnum].lotag == ST_1_ABOVE_WATER)
- s->z += (32<<8);
+ pSprite->yrepeat = 36;
+ if (sector[pSprite->sectnum].lotag != ST_2_UNDERWATER)
+ A_Fall(spriteNum);
+ if (pSprite->zvel == 0 && sector[pSprite->sectnum].lotag == ST_1_ABOVE_WATER)
+ pSprite->z += (32<<8);
}
- if (s->extra < 8)
+ if (pSprite->extra < 8)
{
- s->xvel = 128;
- s->ang = p->ang;
- s->extra++;
- A_SetSprite(i,CLIPMASK0);
+ pSprite->xvel = 128;
+ pSprite->ang = pPlayer->ang;
+ pSprite->extra++;
+ A_SetSprite(spriteNum,CLIPMASK0);
}
else
{
- s->ang = 2047-p->ang;
- setsprite(i,(vec3_t *)s);
+ pSprite->ang = 2047-pPlayer->ang;
+ setsprite(spriteNum,(vec3_t *)pSprite);
}
}
- if (sector[s->sectnum].ceilingstat&1)
- s->shade = logapproach(s->shade, sector[s->sectnum].ceilingshade);
- else
- s->shade = logapproach(s->shade, sector[s->sectnum].floorshade);
+ pSprite->shade =
+ logapproach(pSprite->shade, (sector[pSprite->sectnum].ceilingstat & 1) ? sector[pSprite->sectnum].ceilingshade
+ : sector[pSprite->sectnum].floorshade);
-BOLT:
- i = nexti;
+next_sprite:
+ spriteNum = nextSprite;
}
}
ACTOR_STATIC void G_MoveFX(void)
{
- int32_t i = headspritestat[STAT_FX];
+ int spriteNum = headspritestat[STAT_FX];
- while (i >= 0)
+ while (spriteNum >= 0)
{
- spritetype *const s = &sprite[i];
- const int32_t nexti = nextspritestat[i];
+ spritetype *const pSprite = &sprite[spriteNum];
+ int const nextSprite = nextspritestat[spriteNum];
- switch (DYNAMICTILEMAP(s->picnum))
+ switch (DYNAMICTILEMAP(pSprite->picnum))
{
case RESPAWN__STATIC:
- if (sprite[i].extra == 66)
+ if (pSprite->extra == 66)
{
- /*int32_t j =*/ A_Spawn(i,SHT);
+ /*int32_t j =*/ A_Spawn(spriteNum,SHT(spriteNum));
// sprite[j].pal = sprite[i].pal;
- KILLIT(i);
+ KILLIT(spriteNum);
}
- else if (sprite[i].extra > (66-13))
- sprite[i].extra++;
+ else if (pSprite->extra > (66-13))
+ sprite[spriteNum].extra++;
break;
case MUSICANDSFX__STATIC:
{
- const int32_t ht = s->hitag;
- DukePlayer_t *const peekps = g_player[screenpeek].ps;
+ int const spriteHitag = pSprite->hitag;
+ DukePlayer_t *const pPlayer = g_player[screenpeek].ps;
- if (T2 != ud.config.SoundToggle)
+ if (T2(spriteNum) != ud.config.SoundToggle)
{
// If sound playback was toggled, restart.
- T2 = ud.config.SoundToggle;
- T1 = 0;
+ T2(spriteNum) = ud.config.SoundToggle;
+ T1(spriteNum) = 0;
}
- if (s->lotag >= 1000 && s->lotag < 2000)
+ if (pSprite->lotag >= 1000 && pSprite->lotag < 2000)
{
- int32_t x = ldist(&sprite[peekps->i],s);
+ int32_t x = ldist(&sprite[pPlayer->i],pSprite);
#ifdef SPLITSCREEN_MOD_HACKS
if (g_fakeMultiMode==2)
{
// HACK for splitscreen mod
- int32_t otherdist = ldist(&sprite[g_player[1].ps->i],s);
+ int32_t otherdist = ldist(&sprite[g_player[1].ps->i],pSprite);
x = min(x, otherdist);
}
#endif
- if (x < ht && T1 == 0)
+ if (x < spriteHitag && T1(spriteNum) == 0)
{
- FX_SetReverb(s->lotag - 1000);
- T1 = 1;
+ FX_SetReverb(pSprite->lotag - 1000);
+ T1(spriteNum) = 1;
}
- if (x >= ht && T1 == 1)
+ if (x >= spriteHitag && T1(spriteNum) == 1)
{
FX_SetReverb(0);
FX_SetReverbDelay(0);
- T1 = 0;
+ T1(spriteNum) = 0;
}
}
- else if (s->lotag < 999 && (unsigned)sector[s->sectnum].lotag < 9 && // ST_9_SLIDING_ST_DOOR
- ud.config.AmbienceToggle && sector[SECT].floorz != sector[SECT].ceilingz)
+ else if (pSprite->lotag < 999 && (unsigned)sector[pSprite->sectnum].lotag < 9 && // ST_9_SLIDING_ST_DOOR
+ ud.config.AmbienceToggle && sector[SECT(spriteNum)].floorz != sector[SECT(spriteNum)].ceilingz)
{
- if (g_sounds[s->lotag].m & SF_MSFX)
+ if (g_sounds[pSprite->lotag].m & SF_MSFX)
{
- int32_t x = dist(&sprite[peekps->i],s);
+ int32_t playerDist = dist(&sprite[pPlayer->i], pSprite);
#ifdef SPLITSCREEN_MOD_HACKS
if (g_fakeMultiMode==2)
{
// HACK for splitscreen mod
- int32_t otherdist = dist(&sprite[g_player[1].ps->i],s);
- x = min(x, otherdist);
+ int32_t otherdist = dist(&sprite[g_player[1].ps->i],pSprite);
+ playerDist = min(playerDist, otherdist);
}
#endif
- if (x < ht && T1 == 0 && FX_VoiceAvailable(g_sounds[s->lotag].pr-1))
+ if (playerDist < spriteHitag && T1(spriteNum) == 0 && FX_VoiceAvailable(g_sounds[pSprite->lotag].pr-1))
{
// Start playing an ambience sound.
- char om = g_sounds[s->lotag].m;
+ char om = g_sounds[pSprite->lotag].m;
if (g_numEnvSoundsPlaying == ud.config.NumVoices)
{
int32_t j;
for (SPRITES_OF(STAT_FX, j))
- if (j != i && S_IsAmbientSFX(j) && actor[j].t_data[0] == 1 &&
- dist(&sprite[j], &sprite[peekps->i]) > x)
+ if (j != spriteNum && S_IsAmbientSFX(j) && actor[j].t_data[0] == 1 &&
+ dist(&sprite[j], &sprite[pPlayer->i]) > playerDist)
{
S_StopEnvSound(sprite[j].lotag,j);
break;
}
if (j == -1)
- goto BOLT;
+ goto next_sprite;
}
- g_sounds[s->lotag].m |= SF_LOOP;
- A_PlaySound(s->lotag,i);
- g_sounds[s->lotag].m = om;
- T1 = 1; // AMBIENT_SFX_PLAYING
+ g_sounds[pSprite->lotag].m |= SF_LOOP;
+ A_PlaySound(pSprite->lotag,spriteNum);
+ g_sounds[pSprite->lotag].m = om;
+ T1(spriteNum) = 1; // AMBIENT_SFX_PLAYING
}
- else if (x >= ht && T1 == 1)
+ else if (playerDist >= spriteHitag && T1(spriteNum) == 1)
{
// Stop playing ambience sound because we're out of its range.
// T1 will be reset in sounds.c: CLEAR_SOUND_T0
// T1 = 0;
- S_StopEnvSound(s->lotag,i);
+ S_StopEnvSound(pSprite->lotag,spriteNum);
}
}
- if (g_sounds[s->lotag].m & SF_GLOBAL)
+ if (g_sounds[pSprite->lotag].m & SF_GLOBAL)
{
// Randomly playing global sounds (flyby of planes, screams, ...)
- if (T5 > 0)
- T5--;
+ if (T5(spriteNum) > 0)
+ T5(spriteNum)--;
else
{
int32_t p;
for (TRAVERSE_CONNECT(p))
- if (p == myconnectindex && g_player[p].ps->cursectnum == s->sectnum)
+ if (p == myconnectindex && g_player[p].ps->cursectnum == pSprite->sectnum)
{
- S_PlaySound(s->lotag + (unsigned)g_globalRandom % (s->hitag+1));
- T5 = GAMETICSPERSEC*40 + g_globalRandom%(GAMETICSPERSEC*40);
+ S_PlaySound(pSprite->lotag + (unsigned)g_globalRandom % (pSprite->hitag+1));
+ T5(spriteNum) = GAMETICSPERSEC*40 + g_globalRandom%(GAMETICSPERSEC*40);
}
}
}
@@ -1424,40 +1422,39 @@ ACTOR_STATIC void G_MoveFX(void)
break;
}
}
-BOLT:
- i = nexti;
+next_sprite:
+ spriteNum = nextSprite;
}
}
ACTOR_STATIC void G_MoveFallers(void)
{
- int32_t i = headspritestat[STAT_FALLER];
+ int32_t spriteNum = headspritestat[STAT_FALLER];
- while (i >= 0)
+ while (spriteNum >= 0)
{
- const int32_t nexti = nextspritestat[i];
- spritetype *const s = &sprite[i];
+ int const nextSprite = nextspritestat[spriteNum];
+ spritetype *const pSprite = &sprite[spriteNum];
+ int const sectNum = pSprite->sectnum;
- const int32_t sect = s->sectnum;
-
- if (T1 == 0)
+ if (T1(spriteNum) == 0)
{
- int32_t j;
- const int32_t oextra = s->extra;
+ const int32_t oextra = pSprite->extra;
+ int j;
- s->z -= ZOFFSET2;
- T2 = s->ang;
- if ((j = A_IncurDamage(i)) >= 0)
+ pSprite->z -= ZOFFSET2;
+ T2(spriteNum) = pSprite->ang;
+ if ((j = A_IncurDamage(spriteNum)) >= 0)
{
if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER)
{
- if (s->extra <= 0)
+ if (pSprite->extra <= 0)
{
- T1 = 1;
+ T1(spriteNum) = 1;
- for (SPRITES_OF(STAT_FALLER, j))
+ for (int SPRITES_OF(STAT_FALLER, j))
{
- if (sprite[j].hitag == SHT)
+ if (sprite[j].hitag == SHT(spriteNum))
{
actor[j].t_data[0] = 1;
sprite[j].cstat &= (65535-64);
@@ -1469,443 +1466,438 @@ ACTOR_STATIC void G_MoveFallers(void)
}
else
{
- actor[i].extra = 0;
- s->extra = oextra;
+ actor[spriteNum].extra = 0;
+ pSprite->extra = oextra;
}
}
- s->ang = T2;
- s->z += ZOFFSET2;
+ pSprite->ang = T2(spriteNum);
+ pSprite->z += ZOFFSET2;
}
- else if (T1 == 1)
+ else if (T1(spriteNum) == 1)
{
- if ((int16_t)s->lotag > 0)
+ if ((int16_t)pSprite->lotag > 0)
{
- s->lotag-=3;
- if ((int16_t)s->lotag <= 0)
+ pSprite->lotag-=3;
+ if ((int16_t)pSprite->lotag <= 0)
{
- s->xvel = (32+(krand()&63));
- s->zvel = -(1024+(krand()&1023));
+ pSprite->xvel = (32+(krand()&63));
+ pSprite->zvel = -(1024+(krand()&1023));
}
}
else
{
int32_t x;
- if (s->xvel > 0)
+ if (pSprite->xvel > 0)
{
- s->xvel -= 8;
- A_SetSprite(i,CLIPMASK0);
+ pSprite->xvel -= 8;
+ A_SetSprite(spriteNum,CLIPMASK0);
}
- if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(s->sectnum)))
+ if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(pSprite->sectnum)))
x = 0;
else
{
- if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(s->sectnum)))
+ if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(pSprite->sectnum)))
x = g_spriteGravity/6;
else
x = g_spriteGravity;
}
- if (s->z < (sector[sect].floorz-ZOFFSET))
+ if (pSprite->z < (sector[sectNum].floorz-ZOFFSET))
{
- s->zvel += x;
- if (s->zvel > 6144)
- s->zvel = 6144;
- s->z += s->zvel;
+ pSprite->zvel += x;
+ if (pSprite->zvel > 6144)
+ pSprite->zvel = 6144;
+ pSprite->z += pSprite->zvel;
}
- if ((sector[sect].floorz-s->z) < ZOFFSET2)
+ if ((sector[sectNum].floorz-pSprite->z) < ZOFFSET2)
{
int32_t j = 1+(krand()&7);
- for (x=0; x= 0)
+ while (spriteNum >= 0)
{
- const int32_t nexti = nextspritestat[i];
+ const int32_t nextSprite = nextspritestat[spriteNum];
+ int32_t *const pData = &actor[spriteNum].t_data[0];
+ spritetype *const pSprite = &sprite[spriteNum];
+ const int32_t sectNum = pSprite->sectnum;
- int32_t *const t = &actor[i].t_data[0];
- spritetype *const s = &sprite[i];
- const int32_t sect = s->sectnum;
-
- if (sect < 0)
- KILLIT(i);
+ if (sectNum < 0)
+ KILLIT(spriteNum);
// Rotation-fixed sprites in rotating sectors already have bpos* updated.
- if ((t[7]&(0xffff0000))!=ROTFIXSPR_MAGIC)
- Bmemcpy(&actor[i].bpos, s, sizeof(vec3_t));
+ if ((pData[7]&(0xffff0000))!=ROTFIXSPR_MAGIC)
+ Bmemcpy(&actor[spriteNum].bpos, pSprite, sizeof(vec3_t));
- if (PN >= CRANE && PN <= CRANE+3)
+ if (PN(spriteNum) >= CRANE && PN(spriteNum) <= CRANE+3)
{
int32_t nextj;
//t[0] = state
//t[1] = checking sector number
- if (s->xvel) A_GetZLimits(i);
+ if (pSprite->xvel) A_GetZLimits(spriteNum);
- if (t[0] == 0) //Waiting to check the sector
+ if (pData[0] == 0) //Waiting to check the sector
{
- for (SPRITES_OF_SECT_SAFE(t[1], j, nextj))
+ for (SPRITES_OF_SECT_SAFE(pData[1], j, nextj))
{
switch (sprite[j].statnum)
{
- case STAT_ACTOR:
- case STAT_ZOMBIEACTOR:
- case STAT_STANDABLE:
- case STAT_PLAYER:
- {
- vec3_t vect = { g_origins[t[4]+1].x, g_origins[t[4]+1].y, sprite[j].z };
-
- s->ang = getangle(vect.x-s->x, vect.y-s->y);
- setsprite(j, &vect);
- t[0]++;
- goto BOLT;
- }
- }
- }
- }
-
- else if (t[0]==1)
- {
- if (s->xvel < 184)
- {
- s->picnum = CRANE+1;
- s->xvel += 8;
- }
- A_SetSprite(i,CLIPMASK0);
- if (sect == t[1])
- t[0]++;
- }
- else if (t[0]==2 || t[0]==7)
- {
- s->z += (1024+512);
-
- if (t[0]==2)
- {
- if (sector[sect].floorz - s->z < (64<<8))
- if (s->picnum > CRANE) s->picnum--;
-
- if (sector[sect].floorz - s->z < 4096+1024)
- t[0]++;
- }
-
- if (t[0]==7)
- {
- if (sector[sect].floorz - s->z < (64<<8))
- {
- if (s->picnum > CRANE) s->picnum--;
- else
+ case STAT_ACTOR:
+ case STAT_ZOMBIEACTOR:
+ case STAT_STANDABLE:
+ case STAT_PLAYER:
{
- if (s->owner==-2)
- {
- int32_t p = A_FindPlayer(s, NULL);
- A_PlaySound(DUKE_GRUNT,g_player[p].ps->i);
- if (g_player[p].ps->on_crane == i)
- g_player[p].ps->on_crane = -1;
- }
+ vec3_t vect = { g_origins[pData[4]+1].x, g_origins[pData[4]+1].y, sprite[j].z };
- t[0]++;
- s->owner = -1;
+ pSprite->ang = getangle(vect.x-pSprite->x, vect.y-pSprite->y);
+ setsprite(j, &vect);
+ pData[0]++;
+ goto next_sprite;
}
}
}
}
- else if (t[0]==3)
+
+ else if (pData[0]==1)
{
- s->picnum++;
- if (s->picnum == CRANE+2)
+ if (pSprite->xvel < 184)
{
- int32_t p = G_CheckPlayerInSector(t[1]);
+ pSprite->picnum = CRANE+1;
+ pSprite->xvel += 8;
+ }
+ A_SetSprite(spriteNum,CLIPMASK0);
+ if (sectNum == pData[1])
+ pData[0]++;
+ }
+ else if (pData[0]==2 || pData[0]==7)
+ {
+ pSprite->z += (1024+512);
+
+ if (pData[0]==2)
+ {
+ if (sector[sectNum].floorz - pSprite->z < (64<<8))
+ if (pSprite->picnum > CRANE) pSprite->picnum--;
+
+ if (sector[sectNum].floorz - pSprite->z < 4096+1024)
+ pData[0]++;
+ }
+
+ if (pData[0]==7)
+ {
+ if (sector[sectNum].floorz - pSprite->z < (64<<8))
+ {
+ if (pSprite->picnum > CRANE) pSprite->picnum--;
+ else
+ {
+ if (pSprite->owner==-2)
+ {
+ int32_t p = A_FindPlayer(pSprite, NULL);
+ A_PlaySound(DUKE_GRUNT,g_player[p].ps->i);
+ if (g_player[p].ps->on_crane == spriteNum)
+ g_player[p].ps->on_crane = -1;
+ }
+
+ pData[0]++;
+ pSprite->owner = -1;
+ }
+ }
+ }
+ }
+ else if (pData[0]==3)
+ {
+ pSprite->picnum++;
+ if (pSprite->picnum == CRANE+2)
+ {
+ int32_t p = G_CheckPlayerInSector(pData[1]);
if (p >= 0 && g_player[p].ps->on_ground)
{
- s->owner = -2;
- g_player[p].ps->on_crane = i;
+ pSprite->owner = -2;
+ g_player[p].ps->on_crane = spriteNum;
A_PlaySound(DUKE_GRUNT,g_player[p].ps->i);
- g_player[p].ps->ang = s->ang+1024;
+ g_player[p].ps->ang = pSprite->ang+1024;
}
else
{
- for (SPRITES_OF_SECT(t[1], j))
+ for (SPRITES_OF_SECT(pData[1], j))
{
switch (sprite[j].statnum)
{
case STAT_ACTOR:
case STAT_STANDABLE:
- s->owner = j;
+ pSprite->owner = j;
break;
}
}
}
- t[0]++;//Grabbed the sprite
- t[2]=0;
- goto BOLT;
+ pData[0]++;//Grabbed the sprite
+ pData[2]=0;
+ goto next_sprite;
}
}
- else if (t[0]==4) //Delay before going up
+ else if (pData[0]==4) //Delay before going up
{
- t[2]++;
- if (t[2] > 10)
- t[0]++;
+ pData[2]++;
+ if (pData[2] > 10)
+ pData[0]++;
}
- else if (t[0]==5 || t[0] == 8)
+ else if (pData[0]==5 || pData[0] == 8)
{
- if (t[0]==8 && s->picnum < (CRANE+2))
- if ((sector[sect].floorz-s->z) > 8192)
- s->picnum++;
+ if (pData[0]==8 && pSprite->picnum < (CRANE+2))
+ if ((sector[sectNum].floorz-pSprite->z) > 8192)
+ pSprite->picnum++;
- if (s->z < g_origins[t[4]+2].x)
+ if (pSprite->z < g_origins[pData[4]+2].x)
{
- t[0]++;
- s->xvel = 0;
+ pData[0]++;
+ pSprite->xvel = 0;
}
else
- s->z -= (1024+512);
+ pSprite->z -= (1024+512);
}
- else if (t[0]==6)
+ else if (pData[0]==6)
{
- if (s->xvel < 192)
- s->xvel += 8;
- s->ang = getangle(g_origins[t[4]].x - s->x, g_origins[t[4]].y - s->y);
- A_SetSprite(i,CLIPMASK0);
- if (((s->x-g_origins[t[4]].x)*(s->x-g_origins[t[4]].x)+(s->y-g_origins[t[4]].y)*(s->y-g_origins[t[4]].y)) < (128*128))
- t[0]++;
+ if (pSprite->xvel < 192)
+ pSprite->xvel += 8;
+ pSprite->ang = getangle(g_origins[pData[4]].x - pSprite->x, g_origins[pData[4]].y - pSprite->y);
+ A_SetSprite(spriteNum,CLIPMASK0);
+ if (((pSprite->x-g_origins[pData[4]].x)*(pSprite->x-g_origins[pData[4]].x)+(pSprite->y-g_origins[pData[4]].y)*(pSprite->y-g_origins[pData[4]].y)) < (128*128))
+ pData[0]++;
}
- else if (t[0]==9)
- t[0] = 0;
+ else if (pData[0]==9)
+ pData[0] = 0;
{
vec3_t vect;
- Bmemcpy(&vect,s,sizeof(vec3_t));
+ Bmemcpy(&vect,pSprite,sizeof(vec3_t));
vect.z -= (34<<8);
- setsprite(g_origins[t[4]+2].y, &vect);
+ setsprite(g_origins[pData[4]+2].y, &vect);
}
- if (s->owner != -1)
+ if (pSprite->owner != -1)
{
- int32_t p = A_FindPlayer(s, NULL);
+ int32_t p = A_FindPlayer(pSprite, NULL);
- if (A_IncurDamage(i) >= 0)
+ if (A_IncurDamage(spriteNum) >= 0)
{
- if (s->owner == -2)
- if (g_player[p].ps->on_crane == i)
+ if (pSprite->owner == -2)
+ if (g_player[p].ps->on_crane == spriteNum)
g_player[p].ps->on_crane = -1;
- s->owner = -1;
- s->picnum = CRANE;
- goto BOLT;
+ pSprite->owner = -1;
+ pSprite->picnum = CRANE;
+ goto next_sprite;
}
- if (s->owner >= 0)
+ if (pSprite->owner >= 0)
{
- setsprite(s->owner,(vec3_t *)s);
+ setsprite(pSprite->owner,(vec3_t *)pSprite);
- Bmemcpy(&actor[s->owner].bpos, s, sizeof(vec3_t));
+ Bmemcpy(&actor[pSprite->owner].bpos, pSprite, sizeof(vec3_t));
- s->zvel = 0;
+ pSprite->zvel = 0;
}
- else if (s->owner == -2)
+ else if (pSprite->owner == -2)
{
DukePlayer_t *const ps = g_player[p].ps;
- ps->opos.x = ps->pos.x = s->x-(sintable[(ps->ang+512)&2047]>>6);
- ps->opos.y = ps->pos.y = s->y-(sintable[ps->ang&2047]>>6);
- ps->opos.z = ps->pos.z = s->z+(2<<8);
+ ps->opos.x = ps->pos.x = pSprite->x-(sintable[(ps->ang+512)&2047]>>6);
+ ps->opos.y = ps->pos.y = pSprite->y-(sintable[ps->ang&2047]>>6);
+ ps->opos.z = ps->pos.z = pSprite->z+(2<<8);
setsprite(ps->i, (vec3_t *)ps);
ps->cursectnum = sprite[ps->i].sectnum;
}
}
- goto BOLT;
+ goto next_sprite;
}
-
- if (PN >= WATERFOUNTAIN && PN <= WATERFOUNTAIN+3)
+ else if (PN(spriteNum) >= WATERFOUNTAIN && PN(spriteNum) <= WATERFOUNTAIN+3)
{
- if (t[0] > 0)
+ if (pData[0] > 0)
{
- if (t[0] < 20)
+ if (pData[0] < 20)
{
- t[0]++;
+ pData[0]++;
- s->picnum++;
+ pSprite->picnum++;
- if (s->picnum == (WATERFOUNTAIN+3))
- s->picnum = WATERFOUNTAIN+1;
+ if (pSprite->picnum == (WATERFOUNTAIN+3))
+ pSprite->picnum = WATERFOUNTAIN+1;
}
else
{
- A_FindPlayer(s,&x);
+ A_FindPlayer(pSprite,&x);
if (x > 512)
{
- t[0] = 0;
- s->picnum = WATERFOUNTAIN;
+ pData[0] = 0;
+ pSprite->picnum = WATERFOUNTAIN;
}
- else t[0] = 1;
+ else pData[0] = 1;
}
}
- goto BOLT;
+ goto next_sprite;
}
-
- if (AFLAMABLE(s->picnum))
+ else if (AFLAMABLE(pSprite->picnum))
{
- if (T1 == 1)
+ if (T1(spriteNum) == 1)
{
- T2++;
- if ((T2&3) > 0) goto BOLT;
+ if ((++T2(spriteNum)&3) > 0) goto next_sprite;
- if (s->picnum == TIRE && T2 == 32)
+ if (pSprite->picnum == TIRE && T2(spriteNum) == 32)
{
- s->cstat = 0;
- j = A_Spawn(i,BLOODPOOL);
+ pSprite->cstat = 0;
+ j = A_Spawn(spriteNum,BLOODPOOL);
sprite[j].shade = 127;
}
else
{
- if (s->shade < 64) s->shade++;
- else KILLIT(i);
+ if (pSprite->shade < 64) pSprite->shade++;
+ else KILLIT(spriteNum);
}
- j = s->xrepeat-(krand()&7);
+ j = pSprite->xrepeat-(krand()&7);
if (j < 10)
- KILLIT(i);
+ KILLIT(spriteNum);
- s->xrepeat = j;
+ pSprite->xrepeat = j;
- j = s->yrepeat-(krand()&7);
+ j = pSprite->yrepeat-(krand()&7);
if (j < 4)
- KILLIT(i);
+ KILLIT(spriteNum);
- s->yrepeat = j;
+ pSprite->yrepeat = j;
}
- if (s->picnum == BOX)
+ if (pSprite->picnum == BOX)
{
- A_Fall(i);
- actor[i].ceilingz = sector[s->sectnum].ceilingz;
+ A_Fall(spriteNum);
+ actor[spriteNum].ceilingz = sector[pSprite->sectnum].ceilingz;
}
- goto BOLT;
+ goto next_sprite;
}
-
- if (s->picnum == TRIPBOMB)
+ else if (pSprite->picnum == TRIPBOMB)
{
// TIMER_CONTROL
- if (actor[i].t_data[6] == 1)
+ if (actor[spriteNum].t_data[6] == 1)
{
- if (actor[i].t_data[7] >= 1)
+ if (actor[spriteNum].t_data[7] >= 1)
{
- actor[i].t_data[7]--;
+ actor[spriteNum].t_data[7]--;
}
- if (actor[i].t_data[7] <= 0)
+ if (actor[spriteNum].t_data[7] <= 0)
{
- T3=16;
- actor[i].t_data[6]=3;
- A_PlaySound(LASERTRIP_ARMING,i);
+ T3(spriteNum)=16;
+ actor[spriteNum].t_data[6]=3;
+ A_PlaySound(LASERTRIP_ARMING,spriteNum);
}
// we're on a timer....
}
- if (T3 > 0 && actor[i].t_data[6] == 3)
+ if (T3(spriteNum) > 0 && actor[spriteNum].t_data[6] == 3)
{
- T3--;
+ T3(spriteNum)--;
- if (T3 == 8)
+ if (T3(spriteNum) == 8)
{
- for (j=0; j<5; j++) RANDOMSCRAP;
- x = s->extra;
- A_RadiusDamage(i, g_tripbombBlastRadius, x>>2,x>>1,x-(x>>2),x);
+ 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);
- j = A_Spawn(i,EXPLOSION2);
+ j = A_Spawn(spriteNum,EXPLOSION2);
A_PlaySound(LASERTRIP_EXPLODE,j);
- sprite[j].ang = s->ang;
+ sprite[j].ang = pSprite->ang;
sprite[j].xvel = 348;
A_SetSprite(j,CLIPMASK0);
for (SPRITES_OF(STAT_MISC, j))
{
- if (sprite[j].picnum == LASERLINE && s->hitag == sprite[j].hitag)
+ if (sprite[j].picnum == LASERLINE && pSprite->hitag == sprite[j].hitag)
sprite[j].xrepeat = sprite[j].yrepeat = 0;
}
- KILLIT(i);
+ KILLIT(spriteNum);
}
- goto BOLT;
+ goto next_sprite;
}
else
{
- const int32_t oextra = s->extra;
- s->extra = 1;
- l = s->ang;
- if (A_IncurDamage(i) >= 0)
+ const int32_t oextra = pSprite->extra;
+ pSprite->extra = 1;
+ l = pSprite->ang;
+ if (A_IncurDamage(spriteNum) >= 0)
{
- actor[i].t_data[6] = 3;
- T3 = 16;
+ actor[spriteNum].t_data[6] = 3;
+ T3(spriteNum) = 16;
}
- s->extra = oextra;
- s->ang = l;
+ pSprite->extra = oextra;
+ pSprite->ang = l;
}
- switch (T1)
+ switch (T1(spriteNum))
{
default:
- A_FindPlayer(s,&x);
- if (x > 768 || T1 > 16) T1++;
+ A_FindPlayer(pSprite,&x);
+ if (x > 768 || T1(spriteNum) > 16) T1(spriteNum)++;
break;
case 32:
{
int16_t m;
- l = s->ang;
- s->ang = T6;
+ l = pSprite->ang;
+ pSprite->ang = T6(spriteNum);
- T4 = s->x;
- T5 = s->y;
+ T4(spriteNum) = pSprite->x;
+ T5(spriteNum) = pSprite->y;
- s->x += sintable[(T6+512)&2047]>>9;
- s->y += sintable[(T6)&2047]>>9;
- s->z -= (3<<8);
+ pSprite->x += sintable[(T6(spriteNum)+512)&2047]>>9;
+ pSprite->y += sintable[(T6(spriteNum))&2047]>>9;
+ pSprite->z -= (3<<8);
- setsprite(i,(vec3_t *)s);
+ setsprite(spriteNum,(vec3_t *)pSprite);
- x = A_CheckHitSprite(i, &m);
+ x = A_CheckHitSprite(spriteNum, &m);
- actor[i].lastvx = x;
+ actor[spriteNum].lastvx = x;
- s->ang = l;
+ pSprite->ang = l;
// if(lTripBombControl & TRIPBOMB_TRIPWIRE)
- if (actor[i].t_data[6] != 1)
+ if (actor[spriteNum].t_data[6] != 1)
{
// we're on a trip wire
int16_t cursectnum;
while (x > 0)
{
- j = A_Spawn(i,LASERLINE);
+ j = A_Spawn(spriteNum,LASERLINE);
setsprite(j,(vec3_t *)&sprite[j]);
- sprite[j].hitag = s->hitag;
+ sprite[j].hitag = pSprite->hitag;
actor[j].t_data[1] = sprite[j].z;
- s->x += sintable[(T6+512)&2047]>>4;
- s->y += sintable[(T6)&2047]>>4;
+ pSprite->x += sintable[(T6(spriteNum)+512)&2047]>>4;
+ pSprite->y += sintable[(T6(spriteNum))&2047]>>4;
if (x < 1024)
{
@@ -1914,206 +1906,203 @@ ACTOR_STATIC void G_MoveStandables(void)
}
x -= 1024;
- cursectnum = s->sectnum;
- updatesector(s->x, s->y, &cursectnum);
+ cursectnum = pSprite->sectnum;
+ updatesector(pSprite->x, pSprite->y, &cursectnum);
if (cursectnum < 0)
break;
}
}
- T1++;
+ T1(spriteNum)++;
- s->x = T4;
- s->y = T5;
- s->z += (3<<8);
+ pSprite->x = T4(spriteNum);
+ pSprite->y = T5(spriteNum);
+ pSprite->z += (3<<8);
- setsprite(i,(vec3_t *)s);
- T4 = T3 = 0;
+ setsprite(spriteNum,(vec3_t *)pSprite);
+ T4(spriteNum) = T3(spriteNum) = 0;
- if (m >= 0 && actor[i].t_data[6] != 1)
+ if (m >= 0 && actor[spriteNum].t_data[6] != 1)
{
- actor[i].t_data[6] = 3;
- T3 = 13;
- A_PlaySound(LASERTRIP_ARMING,i);
+ actor[spriteNum].t_data[6] = 3;
+ T3(spriteNum) = 13;
+ A_PlaySound(LASERTRIP_ARMING,spriteNum);
}
break;
}
case 33:
- T2++;
+ T2(spriteNum)++;
- T4 = s->x;
- T5 = s->y;
+ T4(spriteNum) = pSprite->x;
+ T5(spriteNum) = pSprite->y;
- s->x += sintable[(T6+512)&2047]>>9;
- s->y += sintable[(T6)&2047]>>9;
- s->z -= (3<<8);
+ pSprite->x += sintable[(T6(spriteNum)+512)&2047]>>9;
+ pSprite->y += sintable[(T6(spriteNum))&2047]>>9;
+ pSprite->z -= (3<<8);
- setsprite(i,(vec3_t *)s);
+ setsprite(spriteNum,(vec3_t *)pSprite);
- x = A_CheckHitSprite(i, NULL);
+ x = A_CheckHitSprite(spriteNum, NULL);
- s->x = T4;
- s->y = T5;
- s->z += (3<<8);
- setsprite(i,(vec3_t *)s);
+ pSprite->x = T4(spriteNum);
+ pSprite->y = T5(spriteNum);
+ pSprite->z += (3<<8);
+ setsprite(spriteNum,(vec3_t *)pSprite);
// if( Actor[i].lastvx != x && lTripBombControl & TRIPBOMB_TRIPWIRE)
- if (actor[i].lastvx != x && actor[i].t_data[6] != 1)
+ if (actor[spriteNum].lastvx != x && actor[spriteNum].t_data[6] != 1)
{
- actor[i].t_data[6] = 3;
- T3 = 13;
- A_PlaySound(LASERTRIP_ARMING,i);
+ actor[spriteNum].t_data[6] = 3;
+ T3(spriteNum) = 13;
+ A_PlaySound(LASERTRIP_ARMING,spriteNum);
}
break;
}
- goto BOLT;
+ goto next_sprite;
}
-
- if (s->picnum >= CRACK1 && s->picnum <= CRACK4)
+ else if (pSprite->picnum >= CRACK1 && pSprite->picnum <= CRACK4)
{
- if (s->hitag > 0)
+ if (pSprite->hitag > 0)
{
- int32_t k;
+ pData[0] = pSprite->cstat;
+ pData[1] = pSprite->ang;
- t[0] = s->cstat;
- t[1] = s->ang;
+ int const dmgTile = A_IncurDamage(spriteNum);
- k = A_IncurDamage(i);
- if (k < 0)
+ if (dmgTile < 0)
goto crack_default;
- switch (DYNAMICTILEMAP(k))
+ switch (DYNAMICTILEMAP(dmgTile))
{
- case FIREEXT__STATIC:
- case RPG__STATIC:
- case RADIUSEXPLOSION__STATIC:
- case SEENINE__STATIC:
- case OOZFILTER__STATIC:
- for (SPRITES_OF(STAT_STANDABLE, j))
- {
- if (s->hitag == sprite[j].hitag && (sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE))
- if (sprite[j].shade != -32)
- sprite[j].shade = -32;
- }
+ case FIREEXT__STATIC:
+ case RPG__STATIC:
+ case RADIUSEXPLOSION__STATIC:
+ case SEENINE__STATIC:
+ case OOZFILTER__STATIC:
+ for (SPRITES_OF(STAT_STANDABLE, j))
+ {
+ if (pSprite->hitag == sprite[j].hitag &&
+ (sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE))
+ if (sprite[j].shade != -32)
+ sprite[j].shade = -32;
+ }
- goto DETONATE;
+ goto DETONATE;
- crack_default:
- default:
- s->cstat = t[0];
- s->ang = t[1];
- s->extra = 0;
+crack_default:
+ default:
+ pSprite->cstat = pData[0];
+ pSprite->ang = pData[1];
+ pSprite->extra = 0;
- goto BOLT;
+ goto next_sprite;
}
}
- goto BOLT;
+ goto next_sprite;
}
-
- if (s->picnum == FIREEXT)
+ else if (pSprite->picnum == FIREEXT)
{
int32_t k;
- if (A_IncurDamage(i) < 0)
- goto BOLT;
+ if (A_IncurDamage(spriteNum) < 0)
+ goto next_sprite;
for (k=0; k<16; k++)
{
- j = A_InsertSprite(SECT,SX,SY,SZ-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[i].zvel>>2),i,5);
+ j = A_InsertSprite(SECT(spriteNum),SX(spriteNum),SY(spriteNum),SZ(spriteNum)-(krand()%(48<<8)),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(sprite[spriteNum].zvel>>2),spriteNum,5);
sprite[j].pal = 2;
}
- j = A_Spawn(i,EXPLOSION2);
+ j = A_Spawn(spriteNum,EXPLOSION2);
A_PlaySound(PIPEBOMB_EXPLODE,j);
A_PlaySound(GLASS_HEAVYBREAK,j);
- if ((int16_t)s->hitag > 0)
+ if ((int16_t)pSprite->hitag > 0)
{
for (SPRITES_OF(STAT_STANDABLE, j))
{
// XXX: This block seems to be CODEDUP'd a lot of times.
- if (s->hitag == sprite[j].hitag && (sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE))
+ if (pSprite->hitag == sprite[j].hitag && (sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE))
if (sprite[j].shade != -32)
sprite[j].shade = -32;
}
- x = s->extra;
- A_RadiusDamage(i, g_pipebombBlastRadius,x>>2, x-(x>>1),x-(x>>2), x);
- j = A_Spawn(i,EXPLOSION2);
+ x = pSprite->extra;
+ A_RadiusDamage(spriteNum, g_pipebombBlastRadius,x>>2, x-(x>>1),x-(x>>2), x);
+ j = A_Spawn(spriteNum,EXPLOSION2);
A_PlaySound(PIPEBOMB_EXPLODE,j);
goto DETONATE;
}
else
{
- A_RadiusDamage(i,g_seenineBlastRadius,10,15,20,25);
- KILLIT(i);
+ A_RadiusDamage(spriteNum,g_seenineBlastRadius,10,15,20,25);
+ KILLIT(spriteNum);
}
- goto BOLT;
+ goto next_sprite;
}
-
- if (s->picnum == OOZFILTER || s->picnum == SEENINE || s->picnum == SEENINEDEAD || s->picnum == SEENINEDEAD+1)
+ else if (pSprite->picnum == OOZFILTER || pSprite->picnum == SEENINE || pSprite->picnum == SEENINEDEAD || pSprite->picnum == SEENINEDEAD+1)
{
- if (s->shade != -32 && s->shade != -33)
+ if (pSprite->shade != -32 && pSprite->shade != -33)
{
- if (s->xrepeat)
- j = (A_IncurDamage(i) >= 0);
+ if (pSprite->xrepeat)
+ j = (A_IncurDamage(spriteNum) >= 0);
else
j = 0;
- if (j || s->shade == -31)
+ if (j || pSprite->shade == -31)
{
- if (j) s->lotag = 0;
+ if (j) pSprite->lotag = 0;
- t[3] = 1;
+ pData[3] = 1;
for (SPRITES_OF(STAT_STANDABLE, j))
{
- if (s->hitag == sprite[j].hitag && (sprite[j].picnum == SEENINE || sprite[j].picnum == OOZFILTER))
+ if (pSprite->hitag == sprite[j].hitag && (sprite[j].picnum == SEENINE || sprite[j].picnum == OOZFILTER))
sprite[j].shade = -32;
}
}
}
else
{
- if (s->shade == -32)
+ if (pSprite->shade == -32)
{
- if ((int16_t)s->lotag > 0)
+ if ((int16_t)pSprite->lotag > 0)
{
- s->lotag -= 3;
- if ((int16_t)s->lotag <= 0)
- s->lotag = (uint16_t)(-99);
+ pSprite->lotag -= 3;
+ if ((int16_t)pSprite->lotag <= 0)
+ pSprite->lotag = (uint16_t)(-99);
}
else
- s->shade = -33;
+ pSprite->shade = -33;
}
else
{
- if (s->xrepeat > 0)
+ if (pSprite->xrepeat > 0)
{
- T3++;
- if (T3 == 3)
+ T3(spriteNum)++;
+ if (T3(spriteNum) == 3)
{
- if (s->picnum == OOZFILTER)
+ if (pSprite->picnum == OOZFILTER)
{
- T3 = 0;
+ T3(spriteNum) = 0;
goto DETONATE;
}
- if (s->picnum != (SEENINEDEAD+1))
+ if (pSprite->picnum != (SEENINEDEAD+1))
{
- T3 = 0;
+ T3(spriteNum) = 0;
- if (s->picnum == SEENINEDEAD)
- s->picnum++;
- else if (s->picnum == SEENINE)
- s->picnum = SEENINEDEAD;
+ if (pSprite->picnum == SEENINEDEAD)
+ pSprite->picnum++;
+ else if (pSprite->picnum == SEENINE)
+ pSprite->picnum = SEENINEDEAD;
}
else goto DETONATE;
}
- goto BOLT;
+ goto next_sprite;
}
DETONATE:
@@ -2121,7 +2110,7 @@ DETONATE:
for (SPRITES_OF(STAT_EFFECTOR, j))
{
- if (s->hitag == sprite[j].hitag)
+ if (pSprite->hitag == sprite[j].hitag)
{
if (sprite[j].lotag == SE_13_EXPLOSIVE)
{
@@ -2140,35 +2129,34 @@ DETONATE:
}
}
- s->z -= (32<<8);
+ pSprite->z -= (32<<8);
- if (s->xrepeat)
- for (x=0; x<8; x++) RANDOMSCRAP;
+ if (pSprite->xrepeat)
+ for (x=0; x<8; x++) RANDOMSCRAP(pSprite, spriteNum);
- if ((t[3] == 1 && s->xrepeat) || (int16_t)s->lotag == -99)
+ if ((pData[3] == 1 && pSprite->xrepeat) || (int16_t)pSprite->lotag == -99)
{
- int32_t j = A_Spawn(i,EXPLOSION2);
- x = s->extra;
- A_RadiusDamage(i,g_seenineBlastRadius,x>>2, x-(x>>1),x-(x>>2), x);
+ 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_PlaySound(PIPEBOMB_EXPLODE,j);
}
- KILLIT(i);
+ KILLIT(spriteNum);
}
}
- goto BOLT;
+ goto next_sprite;
}
-
- if (s->picnum == MASTERSWITCH)
+ else if (pSprite->picnum == MASTERSWITCH)
{
- if (s->yvel == 1)
+ if (pSprite->yvel == 1)
{
- s->hitag--;
- if ((int16_t)s->hitag <= 0)
+ pSprite->hitag--;
+ if ((int16_t)pSprite->hitag <= 0)
{
- G_OperateSectors(sect,i);
+ G_OperateSectors(sectNum,spriteNum);
- for (SPRITES_OF_SECT(sect, j))
+ for (SPRITES_OF_SECT(sectNum, j))
{
if (sprite[j].statnum == STAT_EFFECTOR)
{
@@ -2198,358 +2186,367 @@ DETONATE:
}
}
- KILLIT(i);
+ KILLIT(spriteNum);
}
}
- goto BOLT;
+ goto next_sprite;
}
-
- switchpicnum = s->picnum;
-
- if (switchpicnum > SIDEBOLT1 && switchpicnum <= SIDEBOLT1+3)
- switchpicnum = SIDEBOLT1;
- else if (switchpicnum > BOLT1 && switchpicnum <= BOLT1+3)
- switchpicnum = BOLT1;
-
- switch (DYNAMICTILEMAP(switchpicnum))
+ else
{
- case VIEWSCREEN__STATIC:
- case VIEWSCREEN2__STATIC:
+ switchPic = pSprite->picnum;
- if (s->xrepeat == 0)
- KILLIT(i);
+ if (switchPic > SIDEBOLT1 && switchPic <= SIDEBOLT1 + 3)
+ switchPic = SIDEBOLT1;
+ else if (switchPic > BOLT1 && switchPic <= BOLT1 + 3)
+ switchPic = BOLT1;
+ switch (DYNAMICTILEMAP(switchPic))
{
- const int32_t p = A_FindPlayer(s, &x);
- const DukePlayer_t *const ps = g_player[p].ps;
+ case VIEWSCREEN__STATIC:
+ case VIEWSCREEN2__STATIC:
- if (dist(&sprite[ps->i], s) < VIEWSCREEN_ACTIVE_DISTANCE)
- {
-#if 0
- if (sprite[i].yvel == 1) // VIEWSCREEN_YVEL
- g_curViewscreen = i;
-#endif
- }
- else if (g_curViewscreen == i /*&& T1 == 1*/)
- {
- g_curViewscreen = -1;
- sprite[i].yvel = 0; // VIEWSCREEN_YVEL
- T1 = 0;
+ if (pSprite->xrepeat == 0)
+ KILLIT(spriteNum);
- for (int ii=0; ii < VIEWSCREENFACTOR; ii++)
- walock[TILE_VIEWSCR-ii] = 199;
- }
- }
-
- goto BOLT;
-
- case TRASH__STATIC:
-
- if (s->xvel == 0) s->xvel = 1;
- if (A_SetSprite(i, CLIPMASK0))
- {
- A_Fall(i);
- if (krand()&1) s->zvel -= 256;
- if ((s->xvel) < 48)
- s->xvel += (krand()&3);
- }
- else KILLIT(i);
- break;
-
- case SIDEBOLT1__STATIC:
- // case SIDEBOLT1+1:
- // case SIDEBOLT1+2:
- // case SIDEBOLT1+3:
- A_FindPlayer(s, &x);
- if (x > 20480) goto BOLT;
-
-CLEAR_THE_BOLT2:
- if (t[2])
- {
- t[2]--;
- goto BOLT;
- }
- if ((s->xrepeat|s->yrepeat) == 0)
- {
- s->xrepeat=t[0];
- s->yrepeat=t[1];
- }
- if ((krand()&8) == 0)
- {
- t[0]=s->xrepeat;
- t[1]=s->yrepeat;
- t[2] = g_globalRandom&4;
- s->xrepeat=s->yrepeat=0;
- goto CLEAR_THE_BOLT2;
- }
- s->picnum++;
-
- // NOTE: Um, this 'l' was assigned to last at the beginning of this function.
- // SIDEBOLT1 never gets translucent as a consequence, unlike BOLT1.
- if (l&1) s->cstat ^= 2;
-
- if ((krand()&1) && sector[sect].floorpicnum == HURTRAIL)
- A_PlaySound(SHORT_CIRCUIT,i);
-
- if (s->picnum == SIDEBOLT1+4) s->picnum = SIDEBOLT1;
-
- goto BOLT;
-
- case BOLT1__STATIC:
- // case BOLT1+1:
- // case BOLT1+2:
- // case BOLT1+3:
- A_FindPlayer(s, &x);
- if (x > 20480) goto BOLT;
-
- if (t[3] == 0)
- t[3]=sector[sect].floorshade;
-
-CLEAR_THE_BOLT:
- if (t[2])
- {
- t[2]--;
- sector[sect].floorshade = 20;
- sector[sect].ceilingshade = 20;
- goto BOLT;
- }
- if ((s->xrepeat|s->yrepeat) == 0)
- {
- s->xrepeat=t[0];
- s->yrepeat=t[1];
- }
- else if ((krand()&8) == 0)
- {
- t[0]=s->xrepeat;
- t[1]=s->yrepeat;
- t[2] = g_globalRandom&4;
- s->xrepeat=s->yrepeat=0;
- goto CLEAR_THE_BOLT;
- }
- s->picnum++;
-
- l = g_globalRandom&7;
- s->xrepeat=l+8;
-
- if (l&1) s->cstat ^= 2;
-
- if (s->picnum == (BOLT1+1) && (krand()&7) == 0 && sector[sect].floorpicnum == HURTRAIL)
- A_PlaySound(SHORT_CIRCUIT,i);
-
- if (s->picnum==BOLT1+4) s->picnum=BOLT1;
-
- if (s->picnum&1)
- {
- sector[sect].floorshade = 0;
- sector[sect].ceilingshade = 0;
- }
- else
- {
- sector[sect].floorshade = 20;
- sector[sect].ceilingshade = 20;
- }
- goto BOLT;
-
- case WATERDRIP__STATIC:
-
- if (t[1])
- {
- if (--t[1] == 0)
- s->cstat &= 32767;
- }
- else
- {
- A_Fall(i);
- A_SetSprite(i,CLIPMASK0);
- if (s->xvel > 0) s->xvel -= 2;
-
- if (s->zvel == 0)
- {
- s->cstat |= 32768;
-
- if (s->pal != 2 && s->hitag == 0)
- A_PlaySound(SOMETHING_DRIPPING,i);
-
- if (sprite[s->owner].picnum != WATERDRIP)
{
- KILLIT(i);
- }
- else
- {
- actor[i].bpos.z = s->z = t[0];
- t[1] = 48+(krand()&31);
- }
- }
- }
+ const int32_t p = A_FindPlayer(pSprite, &x);
+ const DukePlayer_t *const ps = g_player[p].ps;
-
- goto BOLT;
-
- case DOORSHOCK__STATIC:
- j = klabs(sector[sect].ceilingz-sector[sect].floorz)>>9;
- s->yrepeat = j+4;
- s->xrepeat = 16;
- s->z = sector[sect].floorz;
- goto BOLT;
-
- case TOUCHPLATE__STATIC:
- if (t[1] == 1 && (int16_t)s->hitag >= 0) //Move the sector floor
- {
- x = sector[sect].floorz;
-
- if (t[3] == 1)
- {
- if (x >= t[2])
- {
- sector[sect].floorz = x;
- t[1] = 0;
- }
- else
- {
- int32_t p;
- sector[sect].floorz += sector[sect].extra;
- p = G_CheckPlayerInSector(sect);
- if (p >= 0) g_player[p].ps->pos.z += sector[sect].extra;
- }
- }
- else
- {
- if (x <= s->z)
- {
- sector[sect].floorz = s->z;
- t[1] = 0;
- }
- else
- {
- int32_t p;
- sector[sect].floorz -= sector[sect].extra;
- p = G_CheckPlayerInSector(sect);
- if (p >= 0)
- g_player[p].ps->pos.z -= sector[sect].extra;
- }
- }
- goto BOLT;
- }
-
- if (t[5] == 1) goto BOLT;
-
- {
- int32_t p = G_CheckPlayerInSector(sect);
-
- if (p >= 0 &&
- (g_player[p].ps->on_ground || s->ang == 512))
- {
- if (t[0] == 0 && !G_CheckActivatorMotion(s->lotag))
- {
- t[0] = 1;
- t[1] = 1;
- t[3] = !t[3];
- G_OperateMasterSwitches(s->lotag);
- G_OperateActivators(s->lotag,p);
- if ((int16_t)s->hitag > 0)
+ if (dist(&sprite[ps->i], pSprite) < VIEWSCREEN_ACTIVE_DISTANCE)
{
- s->hitag--;
- if (s->hitag == 0) t[5] = 1;
+#if 0
+ if (sprite[i].yvel == 1) // VIEWSCREEN_YVEL
+ g_curViewscreen = i;
+#endif
+ }
+ else if (g_curViewscreen == spriteNum /*&& T1 == 1*/)
+ {
+ g_curViewscreen = -1;
+ sprite[spriteNum].yvel = 0; // VIEWSCREEN_YVEL
+ T1(spriteNum) = 0;
+
+ for (int ii = 0; ii < VIEWSCREENFACTOR; ii++) walock[TILE_VIEWSCR - ii] = 199;
}
}
- }
- else t[0] = 0;
- }
- if (t[1] == 1)
- {
- for (SPRITES_OF(STAT_STANDABLE, j))
- {
- if (j != i && sprite[j].picnum == TOUCHPLATE && sprite[j].lotag == s->lotag)
+ goto next_sprite;
+
+ case TRASH__STATIC:
+
+ if (pSprite->xvel == 0)
+ pSprite->xvel = 1;
+ if (A_SetSprite(spriteNum, CLIPMASK0))
{
- actor[j].t_data[1] = 1;
- actor[j].t_data[3] = t[3];
+ A_Fall(spriteNum);
+ if (krand() & 1)
+ pSprite->zvel -= 256;
+ if ((pSprite->xvel) < 48)
+ pSprite->xvel += (krand() & 3);
}
- }
+ else
+ KILLIT(spriteNum);
+ break;
+
+ case SIDEBOLT1__STATIC:
+ // case SIDEBOLT1+1:
+ // case SIDEBOLT1+2:
+ // case SIDEBOLT1+3:
+ A_FindPlayer(pSprite, &x);
+ if (x > 20480)
+ goto next_sprite;
+
+ CLEAR_THE_BOLT2:
+ if (pData[2])
+ {
+ pData[2]--;
+ goto next_sprite;
+ }
+ if ((pSprite->xrepeat | pSprite->yrepeat) == 0)
+ {
+ pSprite->xrepeat = pData[0];
+ pSprite->yrepeat = pData[1];
+ }
+ if ((krand() & 8) == 0)
+ {
+ pData[0] = pSprite->xrepeat;
+ pData[1] = pSprite->yrepeat;
+ pData[2] = g_globalRandom & 4;
+ pSprite->xrepeat = pSprite->yrepeat = 0;
+ goto CLEAR_THE_BOLT2;
+ }
+ pSprite->picnum++;
+
+ // NOTE: Um, this 'l' was assigned to last at the beginning of this function.
+ // SIDEBOLT1 never gets translucent as a consequence, unlike BOLT1.
+ if (l & 1)
+ pSprite->cstat ^= 2;
+
+ if ((krand() & 1) && sector[sectNum].floorpicnum == HURTRAIL)
+ A_PlaySound(SHORT_CIRCUIT, spriteNum);
+
+ if (pSprite->picnum == SIDEBOLT1 + 4)
+ pSprite->picnum = SIDEBOLT1;
+
+ goto next_sprite;
+
+ case BOLT1__STATIC:
+ // case BOLT1+1:
+ // case BOLT1+2:
+ // case BOLT1+3:
+ A_FindPlayer(pSprite, &x);
+ if (x > 20480)
+ goto next_sprite;
+
+ if (pData[3] == 0)
+ pData[3] = sector[sectNum].floorshade;
+
+ CLEAR_THE_BOLT:
+ if (pData[2])
+ {
+ pData[2]--;
+ sector[sectNum].floorshade = 20;
+ sector[sectNum].ceilingshade = 20;
+ goto next_sprite;
+ }
+ if ((pSprite->xrepeat | pSprite->yrepeat) == 0)
+ {
+ pSprite->xrepeat = pData[0];
+ pSprite->yrepeat = pData[1];
+ }
+ else if ((krand() & 8) == 0)
+ {
+ pData[0] = pSprite->xrepeat;
+ pData[1] = pSprite->yrepeat;
+ pData[2] = g_globalRandom & 4;
+ pSprite->xrepeat = pSprite->yrepeat = 0;
+ goto CLEAR_THE_BOLT;
+ }
+ pSprite->picnum++;
+
+ l = g_globalRandom & 7;
+ pSprite->xrepeat = l + 8;
+
+ if (l & 1)
+ pSprite->cstat ^= 2;
+
+ if (pSprite->picnum == (BOLT1 + 1) && (krand() & 7) == 0 && sector[sectNum].floorpicnum == HURTRAIL)
+ A_PlaySound(SHORT_CIRCUIT, spriteNum);
+
+ if (pSprite->picnum == BOLT1 + 4)
+ pSprite->picnum = BOLT1;
+
+ if (pSprite->picnum & 1)
+ {
+ sector[sectNum].floorshade = 0;
+ sector[sectNum].ceilingshade = 0;
+ }
+ else
+ {
+ sector[sectNum].floorshade = 20;
+ sector[sectNum].ceilingshade = 20;
+ }
+ goto next_sprite;
+
+ case WATERDRIP__STATIC:
+
+ if (pData[1])
+ {
+ if (--pData[1] == 0)
+ pSprite->cstat &= 32767;
+ }
+ else
+ {
+ A_Fall(spriteNum);
+ A_SetSprite(spriteNum, CLIPMASK0);
+ if (pSprite->xvel > 0)
+ pSprite->xvel -= 2;
+
+ if (pSprite->zvel == 0)
+ {
+ pSprite->cstat |= 32768;
+
+ if (pSprite->pal != 2 && pSprite->hitag == 0)
+ A_PlaySound(SOMETHING_DRIPPING, spriteNum);
+
+ if (sprite[pSprite->owner].picnum != WATERDRIP)
+ {
+ KILLIT(spriteNum);
+ }
+ else
+ {
+ actor[spriteNum].bpos.z = pSprite->z = pData[0];
+ pData[1] = 48 + (krand() & 31);
+ }
+ }
+ }
+
+
+ goto next_sprite;
+
+ case DOORSHOCK__STATIC:
+ j = klabs(sector[sectNum].ceilingz - sector[sectNum].floorz) >> 9;
+ pSprite->yrepeat = j + 4;
+ pSprite->xrepeat = 16;
+ pSprite->z = sector[sectNum].floorz;
+ goto next_sprite;
+
+ case TOUCHPLATE__STATIC:
+ if (pData[1] == 1 && (int16_t)pSprite->hitag >= 0) // Move the sector floor
+ {
+ x = sector[sectNum].floorz;
+
+ if (pData[3] == 1)
+ {
+ if (x >= pData[2])
+ {
+ sector[sectNum].floorz = x;
+ pData[1] = 0;
+ }
+ else
+ {
+ int32_t p;
+ sector[sectNum].floorz += sector[sectNum].extra;
+ p = G_CheckPlayerInSector(sectNum);
+ if (p >= 0)
+ g_player[p].ps->pos.z += sector[sectNum].extra;
+ }
+ }
+ else
+ {
+ if (x <= pSprite->z)
+ {
+ sector[sectNum].floorz = pSprite->z;
+ pData[1] = 0;
+ }
+ else
+ {
+ int32_t p;
+ sector[sectNum].floorz -= sector[sectNum].extra;
+ p = G_CheckPlayerInSector(sectNum);
+ if (p >= 0)
+ g_player[p].ps->pos.z -= sector[sectNum].extra;
+ }
+ }
+ goto next_sprite;
+ }
+
+ if (pData[5] == 1)
+ goto next_sprite;
+
+ {
+ int32_t p = G_CheckPlayerInSector(sectNum);
+
+ if (p >= 0 && (g_player[p].ps->on_ground || pSprite->ang == 512))
+ {
+ if (pData[0] == 0 && !G_CheckActivatorMotion(pSprite->lotag))
+ {
+ pData[0] = 1;
+ pData[1] = 1;
+ pData[3] = !pData[3];
+ G_OperateMasterSwitches(pSprite->lotag);
+ G_OperateActivators(pSprite->lotag, p);
+ if ((int16_t)pSprite->hitag > 0)
+ {
+ pSprite->hitag--;
+ if (pSprite->hitag == 0)
+ pData[5] = 1;
+ }
+ }
+ }
+ else
+ pData[0] = 0;
+ }
+
+ if (pData[1] == 1)
+ {
+ for (SPRITES_OF(STAT_STANDABLE, j))
+ {
+ if (j != spriteNum && sprite[j].picnum == TOUCHPLATE && sprite[j].lotag == pSprite->lotag)
+ {
+ actor[j].t_data[1] = 1;
+ actor[j].t_data[3] = pData[3];
+ }
+ }
+ }
+ goto next_sprite;
+
+ case CANWITHSOMETHING__STATIC:
+ case CANWITHSOMETHING2__STATIC:
+ case CANWITHSOMETHING3__STATIC:
+ case CANWITHSOMETHING4__STATIC:
+ A_Fall(spriteNum);
+ if (A_IncurDamage(spriteNum) >= 0)
+ {
+ A_PlaySound(VENT_BUST, spriteNum);
+
+ for (j = 9; j >= 0; j--) RANDOMSCRAP(pSprite, spriteNum);
+
+ if (pSprite->lotag)
+ A_Spawn(spriteNum, pSprite->lotag);
+
+ KILLIT(spriteNum);
+ }
+ goto next_sprite;
+
+ case FLOORFLAME__STATIC:
+ case FIREBARREL__STATIC:
+ case FIREVASE__STATIC:
+ case EXPLODINGBARREL__STATIC:
+ case WOODENHORSE__STATIC:
+ case HORSEONSIDE__STATIC:
+ case NUKEBARREL__STATIC:
+ case NUKEBARRELDENTED__STATIC:
+ case NUKEBARRELLEAKED__STATIC:
+ case TOILETWATER__STATIC:
+ case RUBBERCAN__STATIC:
+ case STEAM__STATIC:
+ case CEILINGSTEAM__STATIC:
+ case WATERBUBBLEMAKER__STATIC:
+ if (!G_HaveActor(sprite[spriteNum].picnum))
+ goto next_sprite;
+ {
+ int32_t p = A_FindPlayer(pSprite, &x);
+ A_Execute(spriteNum, p, x);
+ }
+ goto next_sprite;
}
- goto BOLT;
-
- case CANWITHSOMETHING__STATIC:
- case CANWITHSOMETHING2__STATIC:
- case CANWITHSOMETHING3__STATIC:
- case CANWITHSOMETHING4__STATIC:
- A_Fall(i);
- if (A_IncurDamage(i) >= 0)
- {
- A_PlaySound(VENT_BUST,i);
-
- for (j=9; j>=0; j--)
- RANDOMSCRAP;
-
- if (s->lotag) A_Spawn(i,s->lotag);
-
- KILLIT(i);
- }
- goto BOLT;
-
- case FLOORFLAME__STATIC:
- case FIREBARREL__STATIC:
- case FIREVASE__STATIC:
- case EXPLODINGBARREL__STATIC:
- case WOODENHORSE__STATIC:
- case HORSEONSIDE__STATIC:
- case NUKEBARREL__STATIC:
- case NUKEBARRELDENTED__STATIC:
- case NUKEBARRELLEAKED__STATIC:
- case TOILETWATER__STATIC:
- case RUBBERCAN__STATIC:
- case STEAM__STATIC:
- case CEILINGSTEAM__STATIC:
- case WATERBUBBLEMAKER__STATIC:
- if (!G_HaveActor(sprite[i].picnum))
- goto BOLT;
- {
- int32_t p = A_FindPlayer(s, &x);
- A_Execute(i,p,x);
- }
- goto BOLT;
}
-BOLT:
- i = nexti;
+ next_sprite:
+ spriteNum = nextSprite;
}
}
ACTOR_STATIC void A_DoProjectileBounce(int32_t i)
{
- spritetype * const s = &sprite[i];
- int32_t const hitsect = s->sectnum;
- int32_t k = sector[hitsect].wallptr;
- int32_t l = wall[k].point2;
+ spritetype * const pSprite = &sprite[i];
+ int32_t const hitSectnum = pSprite->sectnum;
+ int const firstWall = sector[hitSectnum].wallptr;
+ int const secondWall = wall[firstWall].point2;
+ int const wallAngle = getangle(wall[secondWall].x - wall[firstWall].x, wall[secondWall].y - wall[firstWall].y);
+ vec3_t vect = { mulscale10(pSprite->xvel, sintable[(pSprite->ang + 512) & 2047]),
+ mulscale10(pSprite->xvel, sintable[pSprite->ang & 2047]), pSprite->zvel };
- vec3_t vect = { mulscale10(s->xvel, sintable[(s->ang + 512) & 2047]),
- mulscale10(s->xvel, sintable[s->ang & 2047]),
- s->zvel };
+ int k = (pSprite->z<(actor[i].floorz + actor[i].ceilingz)>> 1) ? sector[hitSectnum].ceilingheinum
+ : sector[hitSectnum].floorheinum;
- int32_t const daang = getangle(wall[l].x-wall[k].x,wall[l].y-wall[k].y);
+ vec3_t const da = { mulscale14(k, sintable[(wallAngle)&2047]),
+ mulscale14(k, sintable[(wallAngle + 1536) & 2047]), 4096 };
- k = (s->z<(actor[i].floorz + actor[i].ceilingz)>> 1) ?
- sector[hitsect].ceilingheinum :
- sector[hitsect].floorheinum;
+ k = vect.x * da.x + vect.y * da.y + vect.z * da.z;
+ int l = da.x * da.x + da.y * da.y + da.z * da.z;
- vec3_t const da = { mulscale14(k, sintable[(daang)&2047]),
- mulscale14(k, sintable[(daang + 1536) & 2047]),
- 4096 };
-
- k = vect.x * da.x + vect.y * da.y + vect.z * da.z;
- l = da.x * da.x + da.y * da.y + da.z * da.z;
-
- if ((klabs(k)>>14) < l)
+ if ((klabs(k) >> 14) < l)
{
- k = divscale17(k,l);
- vect.x -= mulscale16(da.x,k);
- vect.y -= mulscale16(da.y,k);
- vect.z -= mulscale16(da.z,k);
+ k = divscale17(k, l);
+ vect.x -= mulscale16(da.x, k);
+ vect.y -= mulscale16(da.y, k);
+ vect.z -= mulscale16(da.z, k);
}
- s->zvel = vect.z;
- s->xvel = ksqrt(dmulscale8(vect.x, vect.x, vect.y, vect.y));
- s->ang = getangle(vect.x, vect.y);
+ pSprite->zvel = vect.z;
+ pSprite->xvel = ksqrt(dmulscale8(vect.x, vect.x, vect.y, vect.y));
+ pSprite->ang = getangle(vect.x, vect.y);
}
ACTOR_STATIC void P_HandleBeingSpitOn(DukePlayer_t * const ps)
@@ -2573,38 +2570,35 @@ ACTOR_STATIC void P_HandleBeingSpitOn(DukePlayer_t * const ps)
}
}
-static void A_DoProjectileEffects(int32_t i, const vec3_t *davect, int32_t do_radius_damage)
+static void A_DoProjectileEffects(int32_t spriteNum, const vec3_t *davect, int32_t radiusDamage)
{
- const projectile_t *proj = &SpriteProjectile[i];
+ const projectile_t *pProj = &SpriteProjectile[spriteNum];
- if (proj->spawns >= 0)
+ if (pProj->spawns >= 0)
{
- int k = A_Spawn(i,proj->spawns);
+ int const k = A_Spawn(spriteNum,pProj->spawns);
if (davect)
Bmemcpy(&sprite[k],davect,sizeof(vec3_t));
- if (proj->sxrepeat > 4)
- sprite[k].xrepeat=proj->sxrepeat;
- if (proj->syrepeat > 4)
- sprite[k].yrepeat=proj->syrepeat;
+ if (pProj->sxrepeat > 4)
+ sprite[k].xrepeat=pProj->sxrepeat;
+ if (pProj->syrepeat > 4)
+ sprite[k].yrepeat=pProj->syrepeat;
}
- if (proj->isound >= 0)
- A_PlaySound(proj->isound,i);
+ if (pProj->isound >= 0)
+ A_PlaySound(pProj->isound,spriteNum);
- if (!do_radius_damage)
+ if (!radiusDamage)
return;
- spritetype *const s = &sprite[i];
+ spritetype *const pSprite = &sprite[spriteNum];
- s->extra=proj->extra;
+ pSprite->extra = Proj_GetDamage(pProj);
- if (proj->extra_rand > 0)
- s->extra += (krand()&proj->extra_rand);
-
- int const x = s->extra;
- A_RadiusDamage(i,proj->hitradius, x>>2,x>>1,x-(x>>2),x);
+ A_RadiusDamage(spriteNum, pProj->hitradius, pSprite->extra >> 2, pSprite->extra >> 1,
+ pSprite->extra - (pSprite->extra >> 2), pSprite->extra);
}
static void G_WeaponHitCeilingOrFloor(int32_t i, spritetype *s, int32_t *j)
@@ -2666,231 +2660,225 @@ static int Proj_MaybeDamageCF(uspritetype const * const s)
return 0;
}
-ACTOR_STATIC void Proj_MoveCustom(int i)
+ACTOR_STATIC void Proj_MoveCustom(int spriteNum)
{
- int const m = SpriteProjectile[i].workslike & PROJECTILE_MOVED;
- SpriteProjectile[i].workslike |= PROJECTILE_MOVED;
+ int const projectileMoved = SpriteProjectile[spriteNum].workslike & PROJECTILE_MOVED;
+ SpriteProjectile[spriteNum].workslike |= PROJECTILE_MOVED;
+ const projectile_t *const pProj = &SpriteProjectile[spriteNum];
+ spritetype *const pSprite = &sprite[spriteNum];
+ vec3_t davect;
+ int32_t otherSprite=0;
- const projectile_t *const proj = &SpriteProjectile[i];
- spritetype *const s = &sprite[i];
- vec3_t davect;
- int32_t j=0;
-
- switch (proj->workslike & PROJECTILE_TYPE_MASK)
+ switch (pProj->workslike & PROJECTILE_TYPE_MASK)
{
case PROJECTILE_HITSCAN:
- if (!G_HaveActor(sprite[i].picnum))
+ if (!G_HaveActor(sprite[spriteNum].picnum))
return;
{
- int32_t x, p = A_FindPlayer(s, &x);
- A_Execute(i, p, x);
+ int32_t x, p = A_FindPlayer(pSprite, &x);
+ A_Execute(spriteNum, p, x);
}
return;
case PROJECTILE_KNEE:
case PROJECTILE_BLOOD:
- A_DeleteSprite(i);
+ A_DeleteSprite(spriteNum);
return;
default:
case PROJECTILE_RPG:
- Bmemcpy(&davect, s, sizeof(vec3_t));
+ Bmemcpy(&davect, pSprite, sizeof(vec3_t));
- if (proj->flashcolor)
- G_AddGameLight(0, i, ((s->yrepeat*tilesiz[s->picnum].y)<<1), 2048, proj->flashcolor, PR_LIGHT_PRIO_LOW_GAME);
+ if (pProj->flashcolor)
+ G_AddGameLight(0, spriteNum, ((pSprite->yrepeat*tilesiz[pSprite->picnum].y)<<1), 2048, pProj->flashcolor, PR_LIGHT_PRIO_LOW_GAME);
- if (proj->workslike & PROJECTILE_BOUNCESOFFWALLS && s->yvel < 1)
+ if ((pProj->workslike & (PROJECTILE_BOUNCESOFFWALLS|PROJECTILE_EXPLODEONTIMER)) == PROJECTILE_BOUNCESOFFWALLS && pSprite->yvel < 1)
{
- A_DoProjectileEffects(i, NULL, 1);
- A_DeleteSprite(i);
+ A_DoProjectileEffects(spriteNum, &davect, 1);
+ A_DeleteSprite(spriteNum);
return;
}
- if (proj->workslike & PROJECTILE_COOLEXPLOSION1 && ++s->shade >= 40)
+ if (pProj->workslike & PROJECTILE_COOLEXPLOSION1 && ++pSprite->shade >= 40)
{
- A_DeleteSprite(i);
+ A_DeleteSprite(spriteNum);
return;
}
- s->zvel -= proj->drop;
+ pSprite->zvel -= pProj->drop;
- if (proj->workslike & PROJECTILE_SPIT && s->zvel < 6144)
- s->zvel += g_spriteGravity-112;
+ if (pProj->workslike & PROJECTILE_SPIT && pSprite->zvel < 6144)
+ pSprite->zvel += g_spriteGravity-112;
- A_GetZLimits(i);
+ A_GetZLimits(spriteNum);
- if (proj->trail >= 0)
+ if (pProj->trail >= 0)
{
- for (int cnt=0; cnt<=proj->tnum; cnt++)
+ for (int cnt=0; cnt<=pProj->tnum; cnt++)
{
- j = A_Spawn(i, proj->trail);
+ otherSprite = A_Spawn(spriteNum, pProj->trail);
- sprite[j].z += (proj->toffset<<8);
+ sprite[otherSprite].z += (pProj->toffset<<8);
- if (proj->txrepeat >= 0)
- sprite[j].xrepeat=proj->txrepeat;
+ if (pProj->txrepeat >= 0)
+ sprite[otherSprite].xrepeat=pProj->txrepeat;
- if (proj->tyrepeat >= 0)
- sprite[j].yrepeat=proj->tyrepeat;
+ if (pProj->tyrepeat >= 0)
+ sprite[otherSprite].yrepeat=pProj->tyrepeat;
}
}
{
- int32_t cnt = proj->movecnt;
- int32_t k = s->xvel;
- int32_t ll = s->zvel;
+ int32_t projMoveCnt = pProj->movecnt;
+ int32_t projVel = pSprite->xvel;
+ int32_t projZvel = pSprite->zvel;
- if (sector[s->sectnum].lotag == ST_2_UNDERWATER)
+ if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER)
{
- k >>= 1;
- ll >>= 1;
+ projVel >>= 1;
+ projZvel >>= 1;
}
- uint16_t cst = 0;
+ uint16_t backupCstat = 0;
- if (!m && (unsigned) s->owner < MAXSPRITES)
+ if (!projectileMoved && (unsigned) pSprite->owner < MAXSPRITES)
{
- cst = sprite[s->owner].cstat;
- sprite[s->owner].cstat &= (uint16_t)~CSTAT_SPRITE_BLOCK;
+ backupCstat = sprite[pSprite->owner].cstat;
+ sprite[pSprite->owner].cstat &= (uint16_t)~CSTAT_SPRITE_BLOCK;
}
do
{
- vec3_t tmpvect;
- Bmemcpy(&davect, s, sizeof(vec3_t));
+ vec3_t tmpvect = { (projVel * (sintable[(pSprite->ang + 512) & 2047])) >> 14,
+ (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);
- tmpvect.x = (k*(sintable[(s->ang+512)&2047]))>>14;
- tmpvect.y = (k*(sintable[s->ang&2047]))>>14;
- tmpvect.z = ll;
-
- j = A_MoveSprite(i, &tmpvect, (A_CheckSpriteFlags(i, SFLAG_NOCLIP) ? 0 : CLIPMASK1));
- } while (!j && --cnt > 0);
-
- if (cst) sprite[s->owner].cstat = cst;
+ if (backupCstat)
+ sprite[pSprite->owner].cstat = backupCstat;
}
- if (!(proj->workslike & PROJECTILE_BOUNCESOFFWALLS) && // NOT_BOUNCESOFFWALLS_YVEL
- (unsigned)s->yvel < MAXSPRITES && sprite[s->yvel].sectnum != MAXSECTORS)
- if (FindDistance2D(s->x-sprite[s->yvel].x, s->y-sprite[s->yvel].y) < 256)
- j = 49152|s->yvel;
+ if (!(pProj->workslike & PROJECTILE_BOUNCESOFFWALLS) && // NOT_BOUNCESOFFWALLS_YVEL
+ (unsigned)pSprite->yvel < MAXSPRITES && sprite[pSprite->yvel].sectnum != MAXSECTORS)
+ if (FindDistance2D(pSprite->x - sprite[pSprite->yvel].x, pSprite->y - sprite[pSprite->yvel].y) < 256)
+ otherSprite = 49152 | pSprite->yvel;
- actor[i].movflag = j;
+ actor[spriteNum].movflag = otherSprite;
- if (s->sectnum < 0)
+ if (pSprite->sectnum < 0)
{
- A_DeleteSprite(i);
+ A_DeleteSprite(spriteNum);
return;
}
- if (proj->workslike & PROJECTILE_TIMED && proj->range > 0)
+ if (pProj->workslike & PROJECTILE_TIMED && pProj->range > 0)
{
- if (++actor[i].t_data[8] > proj->range)
+ if (++actor[spriteNum].t_data[8] > pProj->range)
{
- if (proj->workslike & PROJECTILE_EXPLODEONTIMER)
- A_DoProjectileEffects(i, &davect, 1);
+ if (pProj->workslike & PROJECTILE_EXPLODEONTIMER)
+ A_DoProjectileEffects(spriteNum, &davect, 1);
- A_DeleteSprite(i);
+ A_DeleteSprite(spriteNum);
return;
}
}
- if ((j&49152) != 49152 && !(proj->workslike & PROJECTILE_BOUNCESOFFWALLS))
- G_WeaponHitCeilingOrFloor(i, s, &j);
+ if ((otherSprite&49152) != 49152 && !(pProj->workslike & PROJECTILE_BOUNCESOFFWALLS))
+ G_WeaponHitCeilingOrFloor(spriteNum, pSprite, &otherSprite);
- if (proj->workslike & PROJECTILE_WATERBUBBLES && sector[s->sectnum].lotag == ST_2_UNDERWATER && rnd(140))
- A_Spawn(i, WATERBUBBLE);
+ if (pProj->workslike & PROJECTILE_WATERBUBBLES && sector[pSprite->sectnum].lotag == ST_2_UNDERWATER && rnd(140))
+ A_Spawn(spriteNum, WATERBUBBLE);
- if (j != 0)
+ if (otherSprite != 0)
{
- int32_t k;
-
- if (proj->workslike & PROJECTILE_COOLEXPLOSION1)
+ if (pProj->workslike & PROJECTILE_COOLEXPLOSION1)
{
- s->xvel = 0;
- s->zvel = 0;
+ pSprite->xvel = 0;
+ pSprite->zvel = 0;
}
- switch (j&49152)
+ switch (otherSprite&49152)
{
case 49152:
- j &= (MAXSPRITES-1);
+ otherSprite &= (MAXSPRITES-1);
- if (proj->workslike & PROJECTILE_BOUNCESOFFSPRITES)
+ if (pProj->workslike & PROJECTILE_BOUNCESOFFSPRITES)
{
- s->yvel--;
+ pSprite->yvel--;
- k = getangle(sprite[j].x-s->x, sprite[j].y-s->y)+(sprite[j].cstat&16 ? 0 : 512);
- s->ang = ((k<<1) - s->ang)&2047;
+ int const projAngle = getangle(sprite[otherSprite].x-pSprite->x, sprite[otherSprite].y-pSprite->y)+(sprite[otherSprite].cstat&16 ? 0 : 512);
+ pSprite->ang = ((projAngle<<1) - pSprite->ang)&2047;
- if (proj->bsound >= 0)
- A_PlaySound(proj->bsound, i);
+ if (pProj->bsound >= 0)
+ A_PlaySound(pProj->bsound, spriteNum);
- if (proj->workslike & PROJECTILE_LOSESVELOCITY)
- PROJ_DECAYVELOCITY(s);
+ if (pProj->workslike & PROJECTILE_LOSESVELOCITY)
+ PROJ_DECAYVELOCITY(pSprite);
- if (!(proj->workslike & PROJECTILE_FORCEIMPACT))
+ if (!(pProj->workslike & PROJECTILE_FORCEIMPACT))
return;
}
- A_DamageObject(j, i);
+ A_DamageObject(otherSprite, spriteNum);
- if (sprite[j].picnum == APLAYER)
+ if (sprite[otherSprite].picnum == APLAYER)
{
- int32_t p = P_Get(j);
+ int playerNum = P_Get(otherSprite);
- A_PlaySound(PISTOL_BODYHIT, j);
+ A_PlaySound(PISTOL_BODYHIT, otherSprite);
- if (proj->workslike & PROJECTILE_SPIT)
- P_HandleBeingSpitOn(g_player[p].ps);
+ if (pProj->workslike & PROJECTILE_SPIT)
+ P_HandleBeingSpitOn(g_player[playerNum].ps);
}
- if (proj->workslike & PROJECTILE_RPG_IMPACT)
+ if (pProj->workslike & PROJECTILE_RPG_IMPACT)
{
- actor[j].owner = s->owner;
- actor[j].picnum = s->picnum;
- actor[j].extra += proj->extra;
+ actor[otherSprite].owner = pSprite->owner;
+ actor[otherSprite].picnum = pSprite->picnum;
+ actor[otherSprite].extra += pProj->extra;
- A_DoProjectileEffects(i, &davect, 0);
+ A_DoProjectileEffects(spriteNum, &davect, 0);
- if (!(proj->workslike & PROJECTILE_FORCEIMPACT))
+ if (!(pProj->workslike & PROJECTILE_FORCEIMPACT))
{
- A_DeleteSprite(i);
+ A_DeleteSprite(spriteNum);
return;
}
}
- if (proj->workslike & PROJECTILE_FORCEIMPACT)
+ if (pProj->workslike & PROJECTILE_FORCEIMPACT)
return;
break;
case 32768:
- j &= (MAXWALLS-1);
+ otherSprite &= (MAXWALLS-1);
- if (proj->workslike & PROJECTILE_BOUNCESOFFMIRRORS &&
- (wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR))
+ if (pProj->workslike & PROJECTILE_BOUNCESOFFMIRRORS &&
+ (wall[otherSprite].overpicnum == MIRROR || wall[otherSprite].picnum == MIRROR))
{
- Proj_BounceOffWall(s, j);
- s->owner = i;
- A_Spawn(i, TRANSPORTERSTAR);
+ Proj_BounceOffWall(pSprite, otherSprite);
+ pSprite->owner = spriteNum;
+ A_Spawn(spriteNum, TRANSPORTERSTAR);
return;
}
else
{
- setsprite(i, &davect);
- A_DamageWall(i, j, (vec3_t *) s, s->picnum);
+ setsprite(spriteNum, &davect);
+ A_DamageWall(spriteNum, otherSprite, (vec3_t *) pSprite, pSprite->picnum);
- if (proj->workslike & PROJECTILE_BOUNCESOFFWALLS)
+ if (pProj->workslike & PROJECTILE_BOUNCESOFFWALLS)
{
- if (wall[j].overpicnum != MIRROR && wall[j].picnum != MIRROR)
- s->yvel--;
+ if (wall[otherSprite].overpicnum != MIRROR && wall[otherSprite].picnum != MIRROR)
+ pSprite->yvel--;
- Proj_BounceOffWall(s, j);
+ Proj_BounceOffWall(pSprite, otherSprite);
- if (proj->bsound >= 0)
- A_PlaySound(proj->bsound, i);
+ if (pProj->bsound >= 0)
+ A_PlaySound(pProj->bsound, spriteNum);
- if (proj->workslike & PROJECTILE_LOSESVELOCITY)
- PROJ_DECAYVELOCITY(s);
+ if (pProj->workslike & PROJECTILE_LOSESVELOCITY)
+ PROJ_DECAYVELOCITY(pSprite);
return;
}
@@ -2898,34 +2886,34 @@ ACTOR_STATIC void Proj_MoveCustom(int i)
break;
case 16384:
- setsprite(i, &davect);
+ setsprite(spriteNum, &davect);
- if (Proj_MaybeDamageCF((uspritetype *)s))
+ if (Proj_MaybeDamageCF((uspritetype *)pSprite))
{
- A_DeleteSprite(i);
+ A_DeleteSprite(spriteNum);
return;
}
- if (proj->workslike & PROJECTILE_BOUNCESOFFWALLS)
+ if (pProj->workslike & PROJECTILE_BOUNCESOFFWALLS)
{
- A_DoProjectileBounce(i);
- A_SetSprite(i, CLIPMASK1);
+ A_DoProjectileBounce(spriteNum);
+ A_SetSprite(spriteNum, CLIPMASK1);
- s->yvel--;
+ pSprite->yvel--;
- if (proj->bsound >= 0)
- A_PlaySound(proj->bsound, i);
+ if (pProj->bsound >= 0)
+ A_PlaySound(pProj->bsound, spriteNum);
- if (proj->workslike & PROJECTILE_LOSESVELOCITY)
- PROJ_DECAYVELOCITY(s);
+ if (pProj->workslike & PROJECTILE_LOSESVELOCITY)
+ PROJ_DECAYVELOCITY(pSprite);
return;
}
break;
}
- A_DoProjectileEffects(i, &davect, 1);
- A_DeleteSprite(i);
+ A_DoProjectileEffects(spriteNum, &davect, 1);
+ A_DeleteSprite(spriteNum);
return;
}
return;
@@ -2952,7 +2940,7 @@ ACTOR_STATIC void G_MoveWeapons(void)
if (A_CheckSpriteFlags(i, SFLAG_PROJECTILE))
{
Proj_MoveCustom(i);
- goto BOLT;
+ goto next_sprite;
}
// hard coded projectiles
@@ -3085,7 +3073,7 @@ ACTOR_STATIC void G_MoveWeapons(void)
Proj_BounceOffWall(s, j);
s->owner = i;
A_Spawn(i, TRANSPORTERSTAR);
- goto BOLT;
+ goto next_sprite;
}
else
{
@@ -3101,7 +3089,7 @@ ACTOR_STATIC void G_MoveWeapons(void)
}
Proj_BounceOffWall(s, j);
- goto BOLT;
+ goto next_sprite;
}
}
break;
@@ -3128,7 +3116,7 @@ ACTOR_STATIC void G_MoveWeapons(void)
s->yrepeat -= 2;
}
- goto BOLT;
+ goto next_sprite;
}
break;
default:
@@ -3210,18 +3198,18 @@ COOLEXPLOSION:
else if (s->picnum == RPG && sector[s->sectnum].lotag == ST_2_UNDERWATER && s->xrepeat >= 10 && rnd(140))
A_Spawn(i,WATERBUBBLE);
- goto BOLT;
+ goto next_sprite;
case SHOTSPARK1__STATIC:
if (!G_HaveActor(sprite[i].picnum))
- goto BOLT;
+ goto next_sprite;
{
int32_t p = A_FindPlayer(s,&x);
A_Execute(i,p,x);
}
- goto BOLT;
+ goto next_sprite;
}
-BOLT:
+next_sprite:
i = nexti;
}
}
@@ -3326,21 +3314,21 @@ ACTOR_STATIC void G_MoveTransports(void)
while (i >= 0)
{
- const int32_t sect = SECT;
+ const int32_t sect = SECT(i);
const int32_t sectlotag = sector[sect].lotag;
const int32_t nexti = nextspritestat[i];
int32_t j, k;
- const int32_t onfloorz = T5; // ONFLOORZ
+ const int32_t onfloorz = T5(i); // ONFLOORZ
- if (OW == i)
+ if (OW(i) == i)
{
i = nexti;
continue;
}
- if (T1 > 0) T1--;
+ if (T1(i) > 0) T1(i)--;
j = headspritesect[sect];
while (j >= 0)
@@ -3368,31 +3356,31 @@ ACTOR_STATIC void G_MoveTransports(void)
}
for (TRAVERSE_CONNECT(k))
- if (g_player[k].ps->cursectnum == sprite[OW].sectnum)
+ if (g_player[k].ps->cursectnum == sprite[OW(i)].sectnum)
{
g_player[k].ps->frag_ps = p;
sprite[g_player[k].ps->i].extra = 0;
}
- ps->ang = sprite[OW].ang;
+ ps->ang = sprite[OW(i)].ang;
- if (sprite[OW].owner != OW)
+ if (sprite[OW(i)].owner != OW(i))
{
- T1 = 13;
- actor[OW].t_data[0] = 13;
+ T1(i) = 13;
+ actor[OW(i)].t_data[0] = 13;
ps->transporter_hold = 13;
}
- ps->bobpos.x = ps->opos.x = ps->pos.x = sprite[OW].x;
- ps->bobpos.y = ps->opos.y = ps->pos.y = sprite[OW].y;
- ps->opos.z = ps->pos.z = sprite[OW].z-PHEIGHT;
+ ps->bobpos.x = ps->opos.x = ps->pos.x = sprite[OW(i)].x;
+ ps->bobpos.y = ps->opos.y = ps->pos.y = sprite[OW(i)].y;
+ ps->opos.z = ps->pos.z = sprite[OW(i)].z-PHEIGHT;
- changespritesect(j,sprite[OW].sectnum);
+ changespritesect(j,sprite[OW(i)].sectnum);
ps->cursectnum = sprite[j].sectnum;
if (sprite[i].pal == 0)
{
- k = A_Spawn(OW,TRANSPORTERBEAM);
+ k = A_Spawn(OW(i),TRANSPORTERBEAM);
A_PlaySound(TELEPORTER,k);
}
@@ -3401,22 +3389,22 @@ ACTOR_STATIC void G_MoveTransports(void)
}
else if (!(sectlotag == ST_1_ABOVE_WATER && ps->on_ground == 1)) break;
- if (onfloorz == 0 && klabs(SZ-ps->pos.z) < 6144)
+ if (onfloorz == 0 && klabs(SZ(i)-ps->pos.z) < 6144)
if (!ps->jetpack_on || TEST_SYNC_KEY(g_player[p].sync->bits, SK_JUMP) ||
TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH))
{
- ps->bobpos.x = ps->opos.x = ps->pos.x += sprite[OW].x-SX;
- ps->bobpos.y = ps->opos.y = ps->pos.y += sprite[OW].y-SY;
+ ps->bobpos.x = ps->opos.x = ps->pos.x += sprite[OW(i)].x-SX(i);
+ ps->bobpos.y = ps->opos.y = ps->pos.y += sprite[OW(i)].y-SY(i);
if (ps->jetpack_on && (TEST_SYNC_KEY(g_player[p].sync->bits, SK_JUMP) || ps->jetpack_on < 11))
- ps->pos.z = sprite[OW].z-6144;
- else ps->pos.z = sprite[OW].z+6144;
+ ps->pos.z = sprite[OW(i)].z-6144;
+ else ps->pos.z = sprite[OW(i)].z+6144;
ps->opos.z = ps->pos.z;
actor[ps->i].bpos = ps->pos;
- changespritesect(j,sprite[OW].sectnum);
- ps->cursectnum = sprite[OW].sectnum;
+ changespritesect(j,sprite[OW(i)].sectnum);
+ ps->cursectnum = sprite[OW(i)].sectnum;
break;
}
@@ -3425,17 +3413,17 @@ ACTOR_STATIC void G_MoveTransports(void)
if (onfloorz)
{
if (sectlotag==ST_1_ABOVE_WATER)
- k = P_Submerge(j, p, ps, sect, sprite[OW].sectnum);
+ k = P_Submerge(j, p, ps, sect, sprite[OW(i)].sectnum);
else if (sectlotag==ST_2_UNDERWATER)
- k = P_Emerge(j, p, ps, sect, sprite[OW].sectnum);
+ k = P_Emerge(j, p, ps, sect, sprite[OW(i)].sectnum);
}
if (k == 1)
{
- ps->pos.x += sprite[OW].x-SX;
- ps->pos.y += sprite[OW].y-SY;
+ ps->pos.x += sprite[OW(i)].x-SX(i);
+ ps->pos.y += sprite[OW(i)].y-SY(i);
- P_FinishWaterChange(j, ps, sectlotag, OW, sprite[OW].sectnum);
+ P_FinishWaterChange(j, ps, sectlotag, OW(i), sprite[OW(i)].sectnum);
}
}
break;
@@ -3468,12 +3456,12 @@ ACTOR_STATIC void G_MoveTransports(void)
warpspriteto = 1;
}
- if (sectlotag == 0 && (onfloorz || klabs(sprite[j].z-SZ) < 4096))
+ if (sectlotag == 0 && (onfloorz || klabs(sprite[j].z-SZ(i)) < 4096))
{
- if (sprite[OW].owner != OW && onfloorz && T1 > 0 && sprite[j].statnum != STAT_MISC)
+ if (sprite[OW(i)].owner != OW(i) && onfloorz && T1(i) > 0 && sprite[j].statnum != STAT_MISC)
{
- T1++;
- goto BOLT;
+ T1(i)++;
+ goto next_sprite;
}
warpspriteto = 1;
}
@@ -3516,7 +3504,7 @@ ACTOR_STATIC void G_MoveTransports(void)
if (sectlotag > 0)
{
// Water SE7 teleportation.
- const int32_t osect = sprite[OW].sectnum;
+ const int32_t osect = sprite[OW(i)].sectnum;
Bassert(sectlotag==ST_1_ABOVE_WATER || sectlotag==ST_2_UNDERWATER);
@@ -3531,14 +3519,14 @@ ACTOR_STATIC void G_MoveTransports(void)
//
actor[j].lasttransport = totalclock + (TICSPERFRAME<<2);
- sprite[j].x += (sprite[OW].x-SX);
- sprite[j].y += (sprite[OW].y-SY);
+ sprite[j].x += (sprite[OW(i)].x-SX(i));
+ sprite[j].y += (sprite[OW(i)].y-SY(i));
sprite[j].z = sectlotag==ST_1_ABOVE_WATER ?
sector[osect].ceilingz : sector[osect].floorz;
Bmemcpy(&actor[j].bpos, &sprite[j], sizeof(vec3_t));
- changespritesect(j, sprite[OW].sectnum);
+ changespritesect(j, sprite[OW(i)].sectnum);
}
else if (Bassert(sectlotag==0), 1)
{
@@ -3547,12 +3535,12 @@ ACTOR_STATIC void G_MoveTransports(void)
if (onfloorz)
{
if (sprite[j].statnum == STAT_PROJECTILE ||
- (G_CheckPlayerInSector(sect) == -1 && G_CheckPlayerInSector(sprite[OW].sectnum) == -1))
+ (G_CheckPlayerInSector(sect) == -1 && G_CheckPlayerInSector(sprite[OW(i)].sectnum) == -1))
{
- sprite[j].x += (sprite[OW].x-SX);
- sprite[j].y += (sprite[OW].y-SY);
- sprite[j].z -= SZ - sector[sprite[OW].sectnum].floorz;
- sprite[j].ang = sprite[OW].ang;
+ sprite[j].x += (sprite[OW(i)].x-SX(i));
+ sprite[j].y += (sprite[OW(i)].y-SY(i));
+ sprite[j].z -= SZ(i) - sector[sprite[OW(i)].sectnum].floorz;
+ sprite[j].ang = sprite[OW(i)].ang;
Bmemcpy(&actor[j].bpos, &sprite[j], sizeof(vec3_t));
@@ -3561,28 +3549,28 @@ ACTOR_STATIC void G_MoveTransports(void)
k = A_Spawn(i,TRANSPORTERBEAM);
A_PlaySound(TELEPORTER,k);
- k = A_Spawn(OW,TRANSPORTERBEAM);
+ k = A_Spawn(OW(i),TRANSPORTERBEAM);
A_PlaySound(TELEPORTER,k);
}
- if (sprite[OW].owner != OW)
+ if (sprite[OW(i)].owner != OW(i))
{
- T1 = 13;
- actor[OW].t_data[0] = 13;
+ T1(i) = 13;
+ actor[OW(i)].t_data[0] = 13;
}
- changespritesect(j,sprite[OW].sectnum);
+ changespritesect(j,sprite[OW(i)].sectnum);
}
}
else
{
- sprite[j].x += (sprite[OW].x-SX);
- sprite[j].y += (sprite[OW].y-SY);
- sprite[j].z = sprite[OW].z+4096;
+ sprite[j].x += (sprite[OW(i)].x-SX(i));
+ sprite[j].y += (sprite[OW(i)].y-SY(i));
+ sprite[j].z = sprite[OW(i)].z+4096;
Bmemcpy(&actor[j].bpos, &sprite[j], sizeof(vec3_t));
- changespritesect(j,sprite[OW].sectnum);
+ changespritesect(j,sprite[OW(i)].sectnum);
}
}
@@ -3598,7 +3586,7 @@ ACTOR_STATIC void G_MoveTransports(void)
JBOLT:
j = nextj;
}
-BOLT:
+next_sprite:
i = nexti;
}
}
@@ -3607,7 +3595,7 @@ static int16_t A_FindLocator(int32_t n, int32_t sn)
{
for (int SPRITES_OF(STAT_LOCATOR, i))
{
- if ((sn == -1 || sn == SECT) && n == SLT)
+ if ((sn == -1 || sn == SECT(i)) && n == SLT(i))
return i;
}
@@ -3619,53 +3607,53 @@ ACTOR_STATIC void G_MoveActors(void)
int32_t x, m, l;
int32_t j;
- int32_t i = headspritestat[STAT_ACTOR];
+ int32_t spriteNum = headspritestat[STAT_ACTOR];
- while (i >= 0)
+ while (spriteNum >= 0)
{
- const int32_t nexti = nextspritestat[i];
+ const int32_t nextSprite = nextspritestat[spriteNum];
- spritetype *const s = &sprite[i];
- const int32_t sect = s->sectnum;
+ spritetype *const pSprite = &sprite[spriteNum];
+ int const sectNum = pSprite->sectnum;
- int32_t switchpicnum;
- int32_t *const t = actor[i].t_data;
+ int32_t switchPic;
+ int32_t *const pData = actor[spriteNum].t_data;
- if (s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS)
- KILLIT(i);
+ if (pSprite->xrepeat == 0 || sectNum < 0 || sectNum >= MAXSECTORS)
+ KILLIT(spriteNum);
- Bmemcpy(&actor[i].bpos, s, sizeof(vec3_t));
+ Bmemcpy(&actor[spriteNum].bpos, pSprite, sizeof(vec3_t));
- switchpicnum = s->picnum;
+ switchPic = pSprite->picnum;
- if (s->picnum > GREENSLIME && s->picnum <= GREENSLIME+7)
- switchpicnum = GREENSLIME;
+ if (pSprite->picnum > GREENSLIME && pSprite->picnum <= GREENSLIME+7)
+ switchPic = GREENSLIME;
- switch (DYNAMICTILEMAP(switchpicnum))
+ switch (DYNAMICTILEMAP(switchPic))
{
case DUCK__STATIC:
case TARGET__STATIC:
- if (s->cstat&32)
+ if (pSprite->cstat&32)
{
- t[0]++;
- if (t[0] > 60)
+ pData[0]++;
+ if (pData[0] > 60)
{
- t[0] = 0;
- s->cstat = 128+257+16;
- s->extra = 1;
+ pData[0] = 0;
+ pSprite->cstat = 128+257+16;
+ pSprite->extra = 1;
}
}
else
{
- if (A_IncurDamage(i) >= 0)
+ if (A_IncurDamage(spriteNum) >= 0)
{
int32_t k = 1;
- s->cstat = 32+128;
+ pSprite->cstat = 32+128;
for (SPRITES_OF(STAT_ACTOR, j))
{
- if (sprite[j].lotag == s->lotag && sprite[j].picnum == s->picnum)
+ if (sprite[j].lotag == pSprite->lotag && sprite[j].picnum == pSprite->picnum)
{
if ((sprite[j].hitag!=0) ^ ((sprite[j].cstat&32)!=0))
{
@@ -3677,79 +3665,79 @@ ACTOR_STATIC void G_MoveActors(void)
if (k == 1)
{
- G_OperateActivators(s->lotag,-1);
- G_OperateForceFields(i,s->lotag);
- G_OperateMasterSwitches(s->lotag);
+ G_OperateActivators(pSprite->lotag,-1);
+ G_OperateForceFields(spriteNum,pSprite->lotag);
+ G_OperateMasterSwitches(pSprite->lotag);
}
}
}
- goto BOLT;
+ goto next_sprite;
case RESPAWNMARKERRED__STATIC:
case RESPAWNMARKERYELLOW__STATIC:
case RESPAWNMARKERGREEN__STATIC:
- if (++T1 > g_itemRespawnTime)
- KILLIT(i);
+ if (++T1(spriteNum) > g_itemRespawnTime)
+ KILLIT(spriteNum);
- if (T1 >= (g_itemRespawnTime>>1) && T1 < ((g_itemRespawnTime>>1)+(g_itemRespawnTime>>2)))
- PN = RESPAWNMARKERYELLOW;
- else if (T1 > ((g_itemRespawnTime>>1)+(g_itemRespawnTime>>2)))
- PN = RESPAWNMARKERGREEN;
+ if (T1(spriteNum) >= (g_itemRespawnTime>>1) && T1(spriteNum) < ((g_itemRespawnTime>>1)+(g_itemRespawnTime>>2)))
+ PN(spriteNum) = RESPAWNMARKERYELLOW;
+ else if (T1(spriteNum) > ((g_itemRespawnTime>>1)+(g_itemRespawnTime>>2)))
+ PN(spriteNum) = RESPAWNMARKERGREEN;
- A_Fall(i);
+ A_Fall(spriteNum);
break;
case HELECOPT__STATIC:
case DUKECAR__STATIC:
- s->z += s->zvel;
- t[0]++;
+ pSprite->z += pSprite->zvel;
+ pData[0]++;
- if (t[0] == 4) A_PlaySound(WAR_AMBIENCE2,i);
+ if (pData[0] == 4) A_PlaySound(WAR_AMBIENCE2,spriteNum);
- if (t[0] > (GAMETICSPERSEC*8))
+ if (pData[0] > (GAMETICSPERSEC*8))
{
S_PlaySound(RPG_EXPLODE);
- for (j=0; j<32; j++) RANDOMSCRAP;
+ for (j=0; j<32; j++) RANDOMSCRAP(pSprite, spriteNum);
g_earthquakeTime = 16;
- KILLIT(i);
+ KILLIT(spriteNum);
}
- else if ((t[0]&3) == 0)
- A_Spawn(i,EXPLOSION2);
- A_SetSprite(i,CLIPMASK0);
+ else if ((pData[0]&3) == 0)
+ A_Spawn(spriteNum,EXPLOSION2);
+ A_SetSprite(spriteNum,CLIPMASK0);
break;
case RAT__STATIC:
- A_Fall(i);
- if (A_SetSprite(i, CLIPMASK0))
+ A_Fall(spriteNum);
+ if (A_SetSprite(spriteNum, CLIPMASK0))
{
- if ((krand()&255) < 3) A_PlaySound(RATTY,i);
- s->ang += (krand()&31)-15+(sintable[(t[0]<<8)&2047]>>11);
+ if ((krand()&255) < 3) A_PlaySound(RATTY,spriteNum);
+ pSprite->ang += (krand()&31)-15+(sintable[(pData[0]<<8)&2047]>>11);
}
else
{
- T1++;
- if (T1 > 1)
+ T1(spriteNum)++;
+ if (T1(spriteNum) > 1)
{
- KILLIT(i);
+ KILLIT(spriteNum);
}
- else s->ang = (krand()&2047);
+ else pSprite->ang = (krand()&2047);
}
- if (s->xvel < 128)
- s->xvel+=2;
- s->ang += (krand()&3)-6;
+ if (pSprite->xvel < 128)
+ pSprite->xvel+=2;
+ pSprite->ang += (krand()&3)-6;
break;
case QUEBALL__STATIC:
case STRIPEBALL__STATIC:
- if (s->xvel)
+ if (pSprite->xvel)
{
for (SPRITES_OF(STAT_DEFAULT, j))
- if (sprite[j].picnum == POCKET && ldist(&sprite[j],s) < 52)
- KILLIT(i);
+ if (sprite[j].picnum == POCKET && ldist(&sprite[j],pSprite) < 52)
+ KILLIT(spriteNum);
- j = clipmove((vec3_t *)s,&s->sectnum,
- (((s->xvel*(sintable[(s->ang+512)&2047]))>>14)*TICSPERFRAME)<<11,
- (((s->xvel*(sintable[s->ang&2047]))>>14)*TICSPERFRAME)<<11,
+ j = clipmove((vec3_t *)pSprite,&pSprite->sectnum,
+ (((pSprite->xvel*(sintable[(pSprite->ang+512)&2047]))>>14)*TICSPERFRAME)<<11,
+ (((pSprite->xvel*(sintable[pSprite->ang&2047]))>>14)*TICSPERFRAME)<<11,
24L,(4<<8),(4<<8),CLIPMASK1);
if (j&49152)
@@ -3757,33 +3745,33 @@ ACTOR_STATIC void G_MoveActors(void)
if ((j&49152) == 32768)
{
j &= (MAXWALLS-1);
- Proj_BounceOffWall(s, j);
+ Proj_BounceOffWall(pSprite, j);
}
else if ((j&49152) == 49152)
{
j &= (MAXSPRITES-1);
- A_DamageObject(i,j);
+ A_DamageObject(spriteNum,j);
}
}
- s->xvel--;
- if (s->xvel < 0) s->xvel = 0;
+ pSprite->xvel--;
+ if (pSprite->xvel < 0) pSprite->xvel = 0;
- if (s->picnum == STRIPEBALL)
+ if (pSprite->picnum == STRIPEBALL)
{
- s->cstat = 257;
- s->cstat |= (4 & s->xvel) | (8 & s->xvel);
+ pSprite->cstat = 257;
+ pSprite->cstat |= (4 & pSprite->xvel) | (8 & pSprite->xvel);
}
}
else
{
- const int32_t p = A_FindPlayer(s,&x);
+ const int32_t p = A_FindPlayer(pSprite,&x);
DukePlayer_t *const ps = g_player[p].ps;
if (x < 1596)
// if (s->pal == 12)
{
- j = G_GetAngleDelta(ps->ang,getangle(s->x-ps->pos.x,s->y-ps->pos.y));
+ j = G_GetAngleDelta(ps->ang,getangle(pSprite->x-ps->pos.x,pSprite->y-ps->pos.y));
if (j > -64 && j < 64 && TEST_SYNC_KEY(g_player[p].sync->bits, SK_OPEN))
if (ps->toggle_key_flag == 1)
@@ -3805,77 +3793,77 @@ ACTOR_STATIC void G_MoveActors(void)
if (a == -1)
{
- if (s->pal == 12)
- s->xvel = 164;
- else s->xvel = 140;
- s->ang = ps->ang;
+ if (pSprite->pal == 12)
+ pSprite->xvel = 164;
+ else pSprite->xvel = 140;
+ pSprite->ang = ps->ang;
ps->toggle_key_flag = 2;
}
}
}
- if (x < 512 && s->sectnum == ps->cursectnum)
+ if (x < 512 && pSprite->sectnum == ps->cursectnum)
{
- s->ang = getangle(s->x-ps->pos.x,s->y-ps->pos.y);
- s->xvel = 48;
+ pSprite->ang = getangle(pSprite->x-ps->pos.x,pSprite->y-ps->pos.y);
+ pSprite->xvel = 48;
}
}
break;
case FORCESPHERE__STATIC:
- if (s->yvel == 0)
+ if (pSprite->yvel == 0)
{
- s->yvel = 1;
+ pSprite->yvel = 1;
for (l=512; l<(2048-512); l+= 128)
for (j=0; j<2048; j += 128)
{
- int32_t k = A_Spawn(i,FORCESPHERE);
+ int32_t k = A_Spawn(spriteNum,FORCESPHERE);
sprite[k].cstat = 257+128;
sprite[k].clipdist = 64;
sprite[k].ang = j;
sprite[k].zvel = sintable[l&2047]>>5;
sprite[k].xvel = sintable[(l+512)&2047]>>9;
- sprite[k].owner = i;
+ sprite[k].owner = spriteNum;
}
}
- if (t[3] > 0)
+ if (pData[3] > 0)
{
- if (s->zvel < 6144)
- s->zvel += 192;
- s->z += s->zvel;
- if (s->z > sector[sect].floorz)
- s->z = sector[sect].floorz;
- t[3]--;
- if (t[3] == 0)
- KILLIT(i);
+ if (pSprite->zvel < 6144)
+ pSprite->zvel += 192;
+ pSprite->z += pSprite->zvel;
+ if (pSprite->z > sector[sectNum].floorz)
+ pSprite->z = sector[sectNum].floorz;
+ pData[3]--;
+ if (pData[3] == 0)
+ KILLIT(spriteNum);
}
- else if (t[2] > 10)
+ else if (pData[2] > 10)
{
for (SPRITES_OF(STAT_MISC, j))
- if (sprite[j].owner == i && sprite[j].picnum == FORCESPHERE)
+ if (sprite[j].owner == spriteNum && sprite[j].picnum == FORCESPHERE)
actor[j].t_data[1] = 1+(krand()&63);
- t[3] = 64;
+ pData[3] = 64;
}
- goto BOLT;
+ goto next_sprite;
case RECON__STATIC:
{
int32_t p;
DukePlayer_t *ps;
- A_GetZLimits(i);
+ A_GetZLimits(spriteNum);
- if (sector[s->sectnum].ceilingstat&1)
- s->shade += (sector[s->sectnum].ceilingshade-s->shade)>>1;
- else s->shade += (sector[s->sectnum].floorshade-s->shade)>>1;
+ if (sector[pSprite->sectnum].ceilingstat&1)
+ pSprite->shade += (sector[pSprite->sectnum].ceilingshade-pSprite->shade)>>1;
+ else pSprite->shade += (sector[pSprite->sectnum].floorshade-pSprite->shade)>>1;
- if (s->z < sector[sect].ceilingz+(32<<8))
- s->z = sector[sect].ceilingz+(32<<8);
+ if (pSprite->z < sector[sectNum].ceilingz+(32<<8))
+ pSprite->z = sector[sectNum].ceilingz+(32<<8);
#if 0 //def POLYMER
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = s->sectnum;
@@ -3903,480 +3891,482 @@ ACTOR_STATIC void G_MoveActors(void)
{
if (g_noEnemies == 1)
{
- s->cstat = 32768;
- goto BOLT;
+ pSprite->cstat = 32768;
+ goto next_sprite;
}
- else if (g_noEnemies == 2) s->cstat = 257;
+ else if (g_noEnemies == 2) pSprite->cstat = 257;
}
- if (A_IncurDamage(i) >= 0)
+ if (A_IncurDamage(spriteNum) >= 0)
{
- if (s->extra < 0 && t[0] != -1)
+ if (pSprite->extra < 0 && pData[0] != -1)
{
- t[0] = -1;
- s->extra = 0;
+ pData[0] = -1;
+ pSprite->extra = 0;
}
- A_PlaySound(RECO_PAIN,i);
- RANDOMSCRAP;
+ A_PlaySound(RECO_PAIN,spriteNum);
+ RANDOMSCRAP(pSprite, spriteNum);
}
- if (t[0] == -1)
+ if (pData[0] == -1)
{
- s->z += 1024;
- t[2]++;
+ pSprite->z += 1024;
+ pData[2]++;
- if ((t[2]&3) == 0)
- A_Spawn(i,EXPLOSION2);
+ if ((pData[2]&3) == 0)
+ A_Spawn(spriteNum,EXPLOSION2);
- A_GetZLimits(i);
- s->ang += 96;
- s->xvel = 128;
- j = A_SetSprite(i,CLIPMASK0);
+ A_GetZLimits(spriteNum);
+ pSprite->ang += 96;
+ pSprite->xvel = 128;
+ j = A_SetSprite(spriteNum,CLIPMASK0);
- if (!j || s->z > actor[i].floorz)
+ if (!j || pSprite->z > actor[spriteNum].floorz)
{
for (l=0; l<16; l++)
- RANDOMSCRAP;
- j = A_Spawn(i,EXPLOSION2);
+ RANDOMSCRAP(pSprite, spriteNum);
+ j = A_Spawn(spriteNum,EXPLOSION2);
A_PlaySound(LASERTRIP_EXPLODE,j);
- A_Spawn(i,PIGCOP);
+ A_Spawn(spriteNum,PIGCOP);
g_player[myconnectindex].ps->actors_killed++;
- KILLIT(i);
+ KILLIT(spriteNum);
}
- goto BOLT;
+ goto next_sprite;
}
else
{
- if (s->z > actor[i].floorz-(48<<8))
- s->z = actor[i].floorz-(48<<8);
+ if (pSprite->z > actor[spriteNum].floorz-(48<<8))
+ pSprite->z = actor[spriteNum].floorz-(48<<8);
}
- p = A_FindPlayer(s,&x);
+ p = A_FindPlayer(pSprite,&x);
ps = g_player[p].ps;
- j = s->owner;
+ j = pSprite->owner;
// 3 = findplayerz, 4 = shoot
- if (t[0] >= 4)
+ if (pData[0] >= 4)
{
- t[2]++;
- if ((t[2]&15) == 0)
+ pData[2]++;
+ if ((pData[2]&15) == 0)
{
- int32_t a = s->ang;
- s->ang = actor[i].tempang;
- A_PlaySound(RECO_ATTACK,i);
- A_Shoot(i,FIRELASER);
- s->ang = a;
+ int32_t a = pSprite->ang;
+ pSprite->ang = actor[spriteNum].tempang;
+ A_PlaySound(RECO_ATTACK,spriteNum);
+ A_Shoot(spriteNum,FIRELASER);
+ pSprite->ang = a;
}
- if (t[2] > (GAMETICSPERSEC*3) || !cansee(s->x,s->y,s->z-ZOFFSET2,s->sectnum, ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum))
+ if (pData[2] > (GAMETICSPERSEC*3) || !cansee(pSprite->x,pSprite->y,pSprite->z-ZOFFSET2,pSprite->sectnum, ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum))
{
- t[0] = 0;
- t[2] = 0;
+ pData[0] = 0;
+ pData[2] = 0;
}
- else actor[i].tempang +=
- G_GetAngleDelta(actor[i].tempang,getangle(ps->pos.x-s->x,ps->pos.y-s->y))/3;
+ else actor[spriteNum].tempang +=
+ G_GetAngleDelta(actor[spriteNum].tempang,getangle(ps->pos.x-pSprite->x,ps->pos.y-pSprite->y))/3;
}
- else if (t[0] == 2 || t[0] == 3)
+ else if (pData[0] == 2 || pData[0] == 3)
{
- t[3] = 0;
- if (s->xvel > 0) s->xvel -= 16;
- else s->xvel = 0;
+ pData[3] = 0;
+ if (pSprite->xvel > 0) pSprite->xvel -= 16;
+ else pSprite->xvel = 0;
- if (t[0] == 2)
+ if (pData[0] == 2)
{
- l = ps->pos.z-s->z;
- if (klabs(l) < (48<<8)) t[0] = 3;
- else s->z += ksgn(ps->pos.z-s->z)<<10;
+ l = ps->pos.z-pSprite->z;
+ if (klabs(l) < (48<<8)) pData[0] = 3;
+ else pSprite->z += ksgn(ps->pos.z-pSprite->z)<<10;
}
else
{
- t[2]++;
- if (t[2] > (GAMETICSPERSEC*3) || !cansee(s->x,s->y,s->z-ZOFFSET2,s->sectnum, ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum))
+ pData[2]++;
+ if (pData[2] > (GAMETICSPERSEC*3) || !cansee(pSprite->x,pSprite->y,pSprite->z-ZOFFSET2,pSprite->sectnum, ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum))
{
- t[0] = 1;
- t[2] = 0;
+ pData[0] = 1;
+ pData[2] = 0;
}
- else if ((t[2]&15) == 0)
+ else if ((pData[2]&15) == 0)
{
- A_PlaySound(RECO_ATTACK,i);
- A_Shoot(i,FIRELASER);
+ A_PlaySound(RECO_ATTACK,spriteNum);
+ A_Shoot(spriteNum,FIRELASER);
}
}
- s->ang += G_GetAngleDelta(s->ang,getangle(ps->pos.x-s->x,ps->pos.y-s->y))>>2;
+ pSprite->ang += G_GetAngleDelta(pSprite->ang,getangle(ps->pos.x-pSprite->x,ps->pos.y-pSprite->y))>>2;
}
- if (t[0] != 2 && t[0] != 3)
+ if (pData[0] != 2 && pData[0] != 3)
{
int32_t a;
- l = ldist(&sprite[j],s);
+ l = ldist(&sprite[j],pSprite);
if (l <= 1524)
{
- a = s->ang;
- s->xvel >>= 1;
+ a = pSprite->ang;
+ pSprite->xvel >>= 1;
}
- else a = getangle(sprite[j].x-s->x,sprite[j].y-s->y);
+ else a = getangle(sprite[j].x-pSprite->x,sprite[j].y-pSprite->y);
- if (t[0] == 1 || t[0] == 4) // Found a locator and going with it
+ if (pData[0] == 1 || pData[0] == 4) // Found a locator and going with it
{
- l = dist(&sprite[j],s);
+ l = dist(&sprite[j],pSprite);
if (l <= 1524)
{
- if (t[0] == 1) t[0] = 0;
- else t[0] = 5;
+ if (pData[0] == 1) pData[0] = 0;
+ else pData[0] = 5;
}
else
{
// Control speed here
if (l > 1524)
{
- if (s->xvel < 256) s->xvel += 32;
+ if (pSprite->xvel < 256) pSprite->xvel += 32;
}
else
{
- if (s->xvel > 0) s->xvel -= 16;
- else s->xvel = 0;
+ if (pSprite->xvel > 0) pSprite->xvel -= 16;
+ else pSprite->xvel = 0;
}
}
- if (t[0] < 2) t[2]++;
+ if (pData[0] < 2) pData[2]++;
- if (x < 6144 && t[0] < 2 && t[2] > (GAMETICSPERSEC*4))
+ if (x < 6144 && pData[0] < 2 && pData[2] > (GAMETICSPERSEC*4))
{
- t[0] = 2+(krand()&2);
- t[2] = 0;
- actor[i].tempang = s->ang;
+ pData[0] = 2+(krand()&2);
+ pData[2] = 0;
+ actor[spriteNum].tempang = pSprite->ang;
}
}
- if (t[0] == 0 || t[0] == 5)
+ if (pData[0] == 0 || pData[0] == 5)
{
- if (t[0] == 0)
- t[0] = 1;
- else t[0] = 4;
+ if (pData[0] == 0)
+ pData[0] = 1;
+ else pData[0] = 4;
- j = s->owner = A_FindLocator(s->hitag,-1);
+ j = pSprite->owner = A_FindLocator(pSprite->hitag,-1);
if (j == -1)
{
- s->hitag = j = actor[i].t_data[5];
- s->owner = A_FindLocator(j,-1);
- j = s->owner;
+ pSprite->hitag = j = actor[spriteNum].t_data[5];
+ pSprite->owner = A_FindLocator(j,-1);
+ j = pSprite->owner;
if (j == -1)
- KILLIT(i);
+ KILLIT(spriteNum);
}
- else s->hitag++;
+ else pSprite->hitag++;
}
// RECON_T4
- t[3] = G_GetAngleDelta(s->ang,a);
- s->ang += t[3]>>3;
+ pData[3] = G_GetAngleDelta(pSprite->ang,a);
+ pSprite->ang += pData[3]>>3;
- if (s->z < sprite[j].z-512)
- s->z += 512;
- else if (s->z > sprite[j].z+512)
- s->z -= 512;
- else s->z = sprite[j].z;
+ if (pSprite->z < sprite[j].z-512)
+ pSprite->z += 512;
+ else if (pSprite->z > sprite[j].z+512)
+ pSprite->z -= 512;
+ else pSprite->z = sprite[j].z;
}
- if (!A_CheckSoundPlaying(i,RECO_ROAM))
- A_PlaySound(RECO_ROAM,i);
+ if (!A_CheckSoundPlaying(spriteNum,RECO_ROAM))
+ A_PlaySound(RECO_ROAM,spriteNum);
- A_SetSprite(i,CLIPMASK0);
+ A_SetSprite(spriteNum,CLIPMASK0);
- goto BOLT;
+ goto next_sprite;
}
case OOZ__STATIC:
case OOZ2__STATIC:
- A_GetZLimits(i);
+ A_GetZLimits(spriteNum);
- j = (actor[i].floorz-actor[i].ceilingz)>>9;
+ j = (actor[spriteNum].floorz-actor[spriteNum].ceilingz)>>9;
if (j > 255) j = 255;
x = 25-(j>>1);
if (x < 8) x = 8;
else if (x > 48) x = 48;
- s->yrepeat = j;
- s->xrepeat = x;
- s->z = actor[i].floorz;
+ pSprite->yrepeat = j;
+ pSprite->xrepeat = x;
+ pSprite->z = actor[spriteNum].floorz;
- goto BOLT;
+ goto next_sprite;
case GREENSLIME__STATIC:
{
- int32_t p;
- DukePlayer_t *ps;
-
// #ifndef VOLUMEONE
if (!g_netServer && ud.multimode < 2)
{
if (g_noEnemies == 1)
{
- s->cstat = 32768;
- goto BOLT;
+ pSprite->cstat = 32768;
+ goto next_sprite;
}
- else if (g_noEnemies == 2) s->cstat = 257;
+ else if (g_noEnemies == 2) pSprite->cstat = 257;
}
// #endif
- t[1]+=128;
+ pData[1]+=128;
- if (sector[sect].floorstat&1)
- KILLIT(i);
+ if (sector[sectNum].floorstat&1)
+ KILLIT(spriteNum);
- p = A_FindPlayer(s,&x);
- ps = g_player[p].ps;
+ int const playerNum = A_FindPlayer(pSprite, &x);
+ DukePlayer_t *const pPlayer = g_player[playerNum].ps;
if (x > 20480)
{
- actor[i].timetosleep++;
- if (actor[i].timetosleep > SLEEPTIME)
+ actor[spriteNum].timetosleep++;
+ if (actor[spriteNum].timetosleep > SLEEPTIME)
{
- actor[i].timetosleep = 0;
- changespritestat(i, STAT_ZOMBIEACTOR);
- goto BOLT;
+ actor[spriteNum].timetosleep = 0;
+ changespritestat(spriteNum, STAT_ZOMBIEACTOR);
+ goto next_sprite;
}
}
- if (t[0] == -5) // FROZEN
+ if (pData[0] == -5) // FROZEN
{
- t[3]++;
- if (t[3] > 280)
+ pData[3]++;
+ if (pData[3] > 280)
{
- s->pal = 0;
- t[0] = 0;
- goto BOLT;
+ pSprite->pal = 0;
+ pData[0] = 0;
+ goto next_sprite;
}
- A_Fall(i);
- s->cstat = 257;
- s->picnum = GREENSLIME+2;
- s->extra = 1;
- s->pal = 1;
- if ((j = A_IncurDamage(i)) >= 0)
+ A_Fall(spriteNum);
+
+ pSprite->cstat = 257;
+ pSprite->picnum = GREENSLIME + 2;
+ pSprite->extra = 1;
+ pSprite->pal = 1;
+
+ if ((j = A_IncurDamage(spriteNum)) >= 0)
{
- if (j == FREEZEBLAST) goto BOLT;
- for (j=16; j >= 0 ; j--)
+ if (j == FREEZEBLAST)
+ goto next_sprite;
+
+ for (j = 16; j >= 0; j--)
{
- int32_t k = A_InsertSprite(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,krand()&2047,32+(krand()&63),1024-(krand()&1023),i,5);
+ int32_t k = A_InsertSprite(SECT(spriteNum), SX(spriteNum), SY(spriteNum), SZ(spriteNum),
+ GLASSPIECES + (j % 3), -32, 36, 36, krand() & 2047, 32 + (krand() & 63),
+ 1024 - (krand() & 1023), spriteNum, 5);
sprite[k].pal = 1;
}
- A_PlaySound(GLASS_BREAKING,i);
- KILLIT(i);
+ A_PlaySound(GLASS_BREAKING, spriteNum);
+ KILLIT(spriteNum);
}
- else if (x < 1024 && ps->quick_kick == 0)
+ else if (x < 1024 && pPlayer->quick_kick == 0)
{
- j = G_GetAngleDelta(ps->ang,getangle(SX-ps->pos.x,SY-ps->pos.y));
+ j =
+ G_GetAngleDelta(pPlayer->ang, getangle(SX(spriteNum) - pPlayer->pos.x, SY(spriteNum) - pPlayer->pos.y));
if (j > -128 && j < 128)
- ps->quick_kick = 14;
+ pPlayer->quick_kick = 14;
}
- goto BOLT;
+ goto next_sprite;
}
- if (x < 1596)
- s->cstat = 0;
- else s->cstat = 257;
+ pSprite->cstat = (x < 1596) ? 0 : 257;
- if (t[0] == -4) //On the player
+ if (pData[0] == -4) //On the player
{
- if (sprite[ps->i].extra < 1)
+ if (sprite[pPlayer->i].extra < 1)
{
- t[0] = 0;
- goto BOLT;
+ pData[0] = 0;
+ goto next_sprite;
}
- setsprite(i,(vec3_t *)s);
+ setsprite(spriteNum,(vec3_t *)pSprite);
- s->ang = ps->ang;
+ pSprite->ang = pPlayer->ang;
- if ((TEST_SYNC_KEY(g_player[p].sync->bits, SK_FIRE) || (ps->quick_kick > 0)) && sprite[ps->i].extra > 0)
- if (ps->quick_kick > 0 ||
- (PWEAPON(p, ps->curr_weapon, WorksLike) != HANDREMOTE_WEAPON && PWEAPON(p, ps->curr_weapon, WorksLike) != HANDBOMB_WEAPON &&
- PWEAPON(p, ps->curr_weapon, WorksLike) != TRIPBOMB_WEAPON && ps->ammo_amount[ps->curr_weapon] >= 0))
+ if ((TEST_SYNC_KEY(g_player[playerNum].sync->bits, SK_FIRE) || (pPlayer->quick_kick > 0)) && sprite[pPlayer->i].extra > 0)
+ if (pPlayer->quick_kick > 0 ||
+ (PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) != HANDREMOTE_WEAPON && PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) != HANDBOMB_WEAPON &&
+ PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) != TRIPBOMB_WEAPON && pPlayer->ammo_amount[pPlayer->curr_weapon] >= 0))
{
for (x=0; x<8; x++)
{
- j = A_InsertSprite(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(s->zvel>>2),i,5);
+ j = A_InsertSprite(sectNum,pSprite->x,pSprite->y,pSprite->z-ZOFFSET3,SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(pSprite->zvel>>2),spriteNum,5);
sprite[j].pal = 6;
}
- A_PlaySound(SLIM_DYING,i);
- A_PlaySound(SQUISHED,i);
+ A_PlaySound(SLIM_DYING,spriteNum);
+ A_PlaySound(SQUISHED,spriteNum);
if ((krand()&255) < 32)
{
- j = A_Spawn(i,BLOODPOOL);
+ j = A_Spawn(spriteNum,BLOODPOOL);
sprite[j].pal = 0;
}
- ps->actors_killed ++;
- t[0] = -3;
- if (ps->somethingonplayer == i)
- ps->somethingonplayer = -1;
- KILLIT(i);
+ pPlayer->actors_killed ++;
+ pData[0] = -3;
+ if (pPlayer->somethingonplayer == spriteNum)
+ pPlayer->somethingonplayer = -1;
+ KILLIT(spriteNum);
}
- s->z = ps->pos.z+ps->pyoff-t[2]+(8<<8);
+ pSprite->z = pPlayer->pos.z + pPlayer->pyoff - pData[2] + ZOFFSET3 + ((100 - pPlayer->horiz) << 4);
- s->z += (100-ps->horiz)<<4;
+ if (pData[2] > 512)
+ pData[2] -= 128;
- if (t[2] > 512)
- t[2] -= 128;
+ if (pData[2] < 348)
+ pData[2] += 128;
- if (t[2] < 348)
- t[2] += 128;
+ if (pPlayer->newowner >= 0)
+ G_ClearCameraView(pPlayer);
- if (ps->newowner >= 0)
- G_ClearCameraView(ps);
-
- if (t[3]>0)
+ if (pData[3] > 0)
{
- static const char frames[] = {5,5,6,6,7,7,6,5};
+ static const char slimeFrames[] = { 5, 5, 6, 6, 7, 7, 6, 5 };
- s->picnum = GREENSLIME+frames[t[3]];
+ pSprite->picnum = GREENSLIME + slimeFrames[pData[3]];
- if (t[3] == 5)
+ if (pData[3] == 5)
{
- sprite[ps->i].extra += -(5+(krand()&3));
- A_PlaySound(SLIM_ATTACK,i);
+ sprite[pPlayer->i].extra += -(5 + (krand() & 3));
+ A_PlaySound(SLIM_ATTACK, spriteNum);
}
- if (t[3] < 7) t[3]++;
- else t[3] = 0;
-
+ if (pData[3] < 7)
+ pData[3]++;
+ else
+ pData[3] = 0;
}
else
{
- s->picnum = GREENSLIME+5;
+ pSprite->picnum = GREENSLIME + 5;
if (rnd(32))
- t[3] = 1;
+ pData[3] = 1;
}
- s->xrepeat = 20+(sintable[t[1]&2047]>>13);
- s->yrepeat = 15+(sintable[t[1]&2047]>>13);
+ pSprite->xrepeat = 20 + (sintable[pData[1] & 2047] >> 13);
+ pSprite->yrepeat = 15 + (sintable[pData[1] & 2047] >> 13);
+ pSprite->x = pPlayer->pos.x + (sintable[(pPlayer->ang + 512) & 2047] >> 7);
+ pSprite->y = pPlayer->pos.y + (sintable[pPlayer->ang & 2047] >> 7);
- s->x = ps->pos.x + (sintable[(ps->ang+512)&2047]>>7);
- s->y = ps->pos.y + (sintable[ps->ang&2047]>>7);
-
- goto BOLT;
+ goto next_sprite;
}
- else if (s->xvel < 64 && x < 768)
+ else if (pSprite->xvel < 64 && x < 768)
{
- if (ps->somethingonplayer == -1)
+ if (pPlayer->somethingonplayer == -1)
{
- ps->somethingonplayer = i;
- if (t[0] == 3 || t[0] == 2) //Falling downward
- t[2] = (12<<8);
- else t[2] = -(13<<8); //Climbing up duke
- t[0] = -4;
+ pPlayer->somethingonplayer = spriteNum;
+ if (pData[0] == 3 || pData[0] == 2) // Falling downward
+ pData[2] = (12 << 8);
+ else
+ pData[2] = -(13 << 8); // Climbing up player
+ pData[0] = -4;
}
}
- if ((j = A_IncurDamage(i)) >= 0)
+ if ((j = A_IncurDamage(spriteNum)) >= 0)
{
- A_PlaySound(SLIM_DYING,i);
+ A_PlaySound(SLIM_DYING,spriteNum);
- ps->actors_killed ++;
- if (ps->somethingonplayer == i)
- ps->somethingonplayer = -1;
+ pPlayer->actors_killed ++;
+ if (pPlayer->somethingonplayer == spriteNum)
+ pPlayer->somethingonplayer = -1;
if (j == FREEZEBLAST)
{
- A_PlaySound(SOMETHINGFROZE,i);
- t[0] = -5 ;
- t[3] = 0 ;
- goto BOLT;
+ A_PlaySound(SOMETHINGFROZE, spriteNum);
+ pData[0] = -5;
+ pData[3] = 0;
+ goto next_sprite;
}
if ((krand()&255) < 32)
{
- j = A_Spawn(i,BLOODPOOL);
+ j = A_Spawn(spriteNum,BLOODPOOL);
sprite[j].pal = 0;
}
for (x=0; x<8; x++)
{
- j = A_InsertSprite(sect,s->x,s->y,s->z-(8<<8),SCRAP3+(krand()&3),-8,48,48,krand()&2047,(krand()&63)+64,-(krand()&4095)-(s->zvel>>2),i,5);
+ j = A_InsertSprite(sectNum, pSprite->x, pSprite->y, pSprite->z - ZOFFSET3, SCRAP3 + (krand() & 3), -8,
+ 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (pSprite->zvel >> 2),
+ spriteNum, 5);
sprite[j].pal = 6;
}
- t[0] = -3;
- KILLIT(i);
+ pData[0] = -3;
+ KILLIT(spriteNum);
}
// All weap
- if (t[0] == -1) //Shrinking down
+ if (pData[0] == -1) //Shrinking down
{
- A_Fall(i);
+ A_Fall(spriteNum);
- s->cstat &= 65535-8;
- s->picnum = GREENSLIME+4;
+ pSprite->cstat &= 65535-8;
+ pSprite->picnum = GREENSLIME+4;
// if(s->yrepeat > 62)
// A_DoGuts(s,JIBS6,5,myconnectindex);
- if (s->xrepeat > 32) s->xrepeat -= krand()&7;
- if (s->yrepeat > 16) s->yrepeat -= krand()&7;
+ if (pSprite->xrepeat > 32) pSprite->xrepeat -= krand()&7;
+ if (pSprite->yrepeat > 16) pSprite->yrepeat -= krand()&7;
else
{
- s->xrepeat = 40;
- s->yrepeat = 16;
- t[5] = -1;
- t[0] = 0;
+ pSprite->xrepeat = 40;
+ pSprite->yrepeat = 16;
+ pData[5] = -1;
+ pData[0] = 0;
}
- goto BOLT;
+ goto next_sprite;
}
- else if (t[0] != -2) A_GetZLimits(i);
+ else if (pData[0] != -2) A_GetZLimits(spriteNum);
- if (t[0] == -2) //On top of somebody
+ if (pData[0] == -2) //On top of somebody
{
- A_Fall(i);
- sprite[t[5]].xvel = 0;
+ A_Fall(spriteNum);
+ sprite[pData[5]].xvel = 0;
- l = sprite[t[5]].ang;
+ l = sprite[pData[5]].ang;
+ pSprite->x = sprite[pData[5]].x + (sintable[(l + 512) & 2047] >> 11);
+ pSprite->y = sprite[pData[5]].y + (sintable[l & 2047] >> 11);
+ pSprite->z = sprite[pData[5]].z;
- s->z = sprite[t[5]].z;
- s->x = sprite[t[5]].x+(sintable[(l+512)&2047]>>11);
- s->y = sprite[t[5]].y+(sintable[l&2047]>>11);
+ pSprite->picnum = GREENSLIME+2+(g_globalRandom&1);
- s->picnum = GREENSLIME+2+(g_globalRandom&1);
-
- if (s->yrepeat < 64) s->yrepeat+=2;
+ if (pSprite->yrepeat < 64) pSprite->yrepeat+=2;
else
{
- if (s->xrepeat < 32) s->xrepeat += 4;
+ if (pSprite->xrepeat < 32) pSprite->xrepeat += 4;
else
{
- t[0] = -1;
- x = ldist(s,&sprite[t[5]]);
+ pData[0] = -1;
+ x = ldist(pSprite,&sprite[pData[5]]);
if (x < 768)
{
- sprite[t[5]].xrepeat = 0;
+ sprite[pData[5]].xrepeat = 0;
// JBF 20041129: a slimer eating another enemy really ought
// to decrease the maximum kill count by one.
- if (sprite[t[5]].extra > 0)
+ if (sprite[pData[5]].extra > 0)
g_player[myconnectindex].ps->max_actors_killed--;
}
}
}
- goto BOLT;
+ goto next_sprite;
}
//Check randomly to see of there is an actor near
if (rnd(32))
{
- for (SPRITES_OF_SECT(sect, j))
+ for (SPRITES_OF_SECT(sectNum, j))
{
if (A_CheckSpriteFlags(j, SFLAG_GREENSLIMEFOOD))
{
- if (ldist(s,&sprite[j]) < 768 && (klabs(s->z-sprite[j].z)<8192)) //Gulp them
+ if (ldist(pSprite, &sprite[j]) < 768 && (klabs(pSprite->z - sprite[j].z) < 8192)) // Gulp them
{
- t[5] = j;
- t[0] = -2;
- t[1] = 0;
- goto BOLT;
+ pData[5] = j;
+ pData[0] = -2;
+ pData[1] = 0;
+ goto next_sprite;
}
}
}
@@ -4384,261 +4374,247 @@ ACTOR_STATIC void G_MoveActors(void)
//Moving on the ground or ceiling
- if (t[0] == 0 || t[0] == 2)
+ if (pData[0] == 0 || pData[0] == 2)
{
- s->picnum = GREENSLIME;
+ pSprite->picnum = GREENSLIME;
if ((krand()&511) == 0)
- A_PlaySound(SLIM_ROAM,i);
+ A_PlaySound(SLIM_ROAM,spriteNum);
- if (t[0]==2)
+ if (pData[0]==2)
{
- s->zvel = 0;
- s->cstat &= (65535-8);
+ pSprite->zvel = 0;
+ pSprite->cstat &= (65535-8);
- if ((sector[sect].ceilingstat&1) || (actor[i].ceilingz+6144) < s->z)
+ if ((sector[sectNum].ceilingstat&1) || (actor[spriteNum].ceilingz+6144) < pSprite->z)
{
- s->z += 2048;
- t[0] = 3;
- goto BOLT;
+ pSprite->z += 2048;
+ pData[0] = 3;
+ goto next_sprite;
}
}
else
{
- s->cstat |= 8;
- A_Fall(i);
+ pSprite->cstat |= 8;
+ A_Fall(spriteNum);
}
- if (everyothertime&1) A_SetSprite(i,CLIPMASK0);
+ if (everyothertime&1) A_SetSprite(spriteNum,CLIPMASK0);
- if (s->xvel > 96)
+ if (pSprite->xvel > 96)
{
- s->xvel -= 2;
- goto BOLT;
+ pSprite->xvel -= 2;
+ goto next_sprite;
}
else
{
- if (s->xvel < 32) s->xvel += 4;
- s->xvel = 64 - (sintable[(t[1]+512)&2047]>>9);
+ if (pSprite->xvel < 32) pSprite->xvel += 4;
+ pSprite->xvel = 64 - (sintable[(pData[1]+512)&2047]>>9);
- s->ang += G_GetAngleDelta(s->ang,
- getangle(ps->pos.x-s->x,ps->pos.y-s->y))>>3;
+ pSprite->ang += G_GetAngleDelta(pSprite->ang,
+ getangle(pPlayer->pos.x-pSprite->x,pPlayer->pos.y-pSprite->y))>>3;
// TJR
}
- s->xrepeat = 36 + (sintable[(t[1]+512)&2047]>>11);
- s->yrepeat = 16 + (sintable[t[1]&2047]>>13);
+ pSprite->xrepeat = 36 + (sintable[(pData[1]+512)&2047]>>11);
+ pSprite->yrepeat = 16 + (sintable[pData[1]&2047]>>13);
- if (rnd(4) && (sector[sect].ceilingstat&1) == 0 &&
- klabs(actor[i].floorz-actor[i].ceilingz)
+ if (rnd(4) && (sector[sectNum].ceilingstat&1) == 0 &&
+ klabs(actor[spriteNum].floorz-actor[spriteNum].ceilingz)
< (192<<8))
{
- s->zvel = 0;
- t[0]++;
+ pSprite->zvel = 0;
+ pData[0]++;
}
}
- if (t[0]==1)
+ if (pData[0]==1)
{
- s->picnum = GREENSLIME;
- if (s->yrepeat < 40) s->yrepeat+=8;
- if (s->xrepeat > 8) s->xrepeat-=4;
- if (s->zvel > -(2048+1024))
- s->zvel -= 348;
- s->z += s->zvel;
- if (s->z < actor[i].ceilingz+4096)
+ pSprite->picnum = GREENSLIME;
+ if (pSprite->yrepeat < 40) pSprite->yrepeat+=8;
+ if (pSprite->xrepeat > 8) pSprite->xrepeat-=4;
+ if (pSprite->zvel > -(2048+1024))
+ pSprite->zvel -= 348;
+ pSprite->z += pSprite->zvel;
+ if (pSprite->z < actor[spriteNum].ceilingz+4096)
{
- s->z = actor[i].ceilingz+4096;
- s->xvel = 0;
- t[0] = 2;
+ pSprite->z = actor[spriteNum].ceilingz+4096;
+ pSprite->xvel = 0;
+ pData[0] = 2;
}
}
- if (t[0]==3)
+ if (pData[0]==3)
{
- s->picnum = GREENSLIME+1;
+ pSprite->picnum = GREENSLIME+1;
- A_Fall(i);
+ A_Fall(spriteNum);
- if (s->z > actor[i].floorz-(8<<8))
+ if (pSprite->z > actor[spriteNum].floorz-ZOFFSET3)
{
- s->yrepeat-=4;
- s->xrepeat+=2;
+ pSprite->yrepeat-=4;
+ pSprite->xrepeat+=2;
}
else
{
- if (s->yrepeat < (40-4)) s->yrepeat+=8;
- if (s->xrepeat > 8) s->xrepeat-=4;
+ if (pSprite->yrepeat < (40-4)) pSprite->yrepeat+=8;
+ if (pSprite->xrepeat > 8) pSprite->xrepeat-=4;
}
- if (s->z > actor[i].floorz-2048)
+ if (pSprite->z > actor[spriteNum].floorz-2048)
{
- s->z = actor[i].floorz-2048;
- t[0] = 0;
- s->xvel = 0;
+ pSprite->z = actor[spriteNum].floorz-2048;
+ pData[0] = 0;
+ pSprite->xvel = 0;
}
}
- goto BOLT;
+ goto next_sprite;
}
case BOUNCEMINE__STATIC:
- if (s->xvel != 0)
+ if (pSprite->xvel != 0)
case MORTER__STATIC:
{
- j = A_Spawn(i,(PLUTOPAK?FRAMEEFFECT1:FRAMEEFFECT1_13));
+ j = A_Spawn(spriteNum,(PLUTOPAK?FRAMEEFFECT1:FRAMEEFFECT1_13));
actor[j].t_data[0] = 3;
}
/* fall-through */
case HEAVYHBOMB__STATIC:
{
- int32_t p;
- DukePlayer_t *ps;
+ int playerNum;
+ DukePlayer_t *pPlayer;
- if ((s->cstat&32768))
+ if ((pSprite->cstat&32768))
{
- t[2]--;
- if (t[2] <= 0)
+ if (--pData[2] <= 0)
{
- A_PlaySound(TELEPORTER,i);
- A_Spawn(i,TRANSPORTERSTAR);
- s->cstat = 257;
+ A_PlaySound(TELEPORTER,spriteNum);
+ A_Spawn(spriteNum,TRANSPORTERSTAR);
+ pSprite->cstat = 257;
}
- goto BOLT;
+ goto next_sprite;
}
- p = A_FindPlayer(s,&x);
- ps = g_player[p].ps;
+ playerNum = A_FindPlayer(pSprite,&x);
+ pPlayer = g_player[playerNum].ps;
- if (x < 1220) s->cstat &= ~257;
- else s->cstat |= 257;
+ if (x < 1220)
+ pSprite->cstat &= ~257;
+ else
+ pSprite->cstat |= 257;
- if (t[3] == 0)
+ if (pData[3] == 0)
{
- if (A_IncurDamage(i) >= 0)
+ if (A_IncurDamage(spriteNum) >= 0)
{
- t[3] = 1;
- t[2] = 0;
+ pData[3] = 1;
+ pData[2] = 0;
l = 0;
- s->xvel = 0;
+ pSprite->xvel = 0;
goto DETONATEB;
}
}
- if (s->picnum != BOUNCEMINE)
+ if (pSprite->picnum != BOUNCEMINE)
{
- A_Fall(i);
+ A_Fall(spriteNum);
- if ((sector[sect].lotag != ST_1_ABOVE_WATER || actor[i].floorz != sector[sect].floorz) && s->z >= actor[i].floorz-(ZOFFSET) && s->yvel < 3)
+ if ((sector[sectNum].lotag != ST_1_ABOVE_WATER || actor[spriteNum].floorz != sector[sectNum].floorz) && pSprite->z >= actor[spriteNum].floorz-(ZOFFSET) && pSprite->yvel < 3)
{
- if (s->yvel > 0 || (s->yvel == 0 && actor[i].floorz == sector[sect].floorz))
- A_PlaySound(PIPEBOMB_BOUNCE,i);
- s->zvel = -((4-s->yvel)<<8);
- if (sector[s->sectnum].lotag == ST_2_UNDERWATER)
- s->zvel >>= 2;
- s->yvel++;
+ if (pSprite->yvel > 0 || (pSprite->yvel == 0 && actor[spriteNum].floorz == sector[sectNum].floorz))
+ A_PlaySound(PIPEBOMB_BOUNCE,spriteNum);
+ pSprite->zvel = -((4-pSprite->yvel)<<8);
+ if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER)
+ pSprite->zvel >>= 2;
+ pSprite->yvel++;
}
- if (s->z < actor[i].ceilingz) // && sector[sect].lotag != ST_2_UNDERWATER )
+ if (pSprite->z < actor[spriteNum].ceilingz) // && sector[sect].lotag != ST_2_UNDERWATER )
{
- s->z = actor[i].ceilingz+(3<<8);
- s->zvel = 0;
+ pSprite->z = actor[spriteNum].ceilingz+(3<<8);
+ pSprite->zvel = 0;
}
}
+ vec3_t tmpvect;
+ tmpvect.x = (pSprite->xvel * (sintable[(pSprite->ang + 512) & 2047])) >> 14;
+ tmpvect.y = (pSprite->xvel * (sintable[pSprite->ang & 2047])) >> 14;
+ tmpvect.z = pSprite->zvel;
+
+ j = A_MoveSprite(spriteNum, &tmpvect, CLIPMASK0);
+
+ actor[spriteNum].movflag = j;
+
+ if (sector[SECT(spriteNum)].lotag == ST_1_ABOVE_WATER && pSprite->zvel == 0 && actor[spriteNum].floorz == sector[sectNum].floorz)
{
- vec3_t tmpvect;
-
- tmpvect.x = (s->xvel*(sintable[(s->ang+512)&2047]))>>14;
- tmpvect.y = (s->xvel*(sintable[s->ang&2047]))>>14;
- tmpvect.z = s->zvel;
- j = A_MoveSprite(i,&tmpvect,CLIPMASK0);
- }
-
- actor[i].movflag = j;
-
- if (sector[SECT].lotag == ST_1_ABOVE_WATER && s->zvel == 0 && actor[i].floorz == sector[sect].floorz)
- {
- s->z += (32<<8);
- if (t[5] == 0)
+ pSprite->z += (32<<8);
+ if (pData[5] == 0)
{
- t[5] = 1;
- A_Spawn(i,WATERSPLASH2);
+ pData[5] = 1;
+ A_Spawn(spriteNum,WATERSPLASH2);
}
}
- else t[5] = 0;
+ else pData[5] = 0;
- if (t[3] == 0 && (s->picnum == BOUNCEMINE || s->picnum == MORTER) && (j || x < 844))
+ if (pData[3] == 0 && (pSprite->picnum == BOUNCEMINE || pSprite->picnum == MORTER) && (j || x < 844))
{
- t[3] = 1;
- t[2] = 0;
+ pData[3] = 1;
+ pData[2] = 0;
l = 0;
- s->xvel = 0;
+ pSprite->xvel = 0;
goto DETONATEB;
}
- if (sprite[s->owner].picnum == APLAYER)
- l = P_Get(s->owner);
+ if (sprite[pSprite->owner].picnum == APLAYER)
+ l = P_Get(pSprite->owner);
else l = -1;
- if (s->xvel > 0)
+ if (pSprite->xvel > 0)
{
- s->xvel -= 5;
- if (sector[sect].lotag == ST_2_UNDERWATER)
- s->xvel -= 10;
+ pSprite->xvel -= 5;
+ if (sector[sectNum].lotag == ST_2_UNDERWATER)
+ pSprite->xvel -= 10;
- if (s->xvel < 0)
- s->xvel = 0;
- if (s->xvel&8) s->cstat ^= 4;
+ if (pSprite->xvel < 0)
+ pSprite->xvel = 0;
+ if (pSprite->xvel&8) pSprite->cstat ^= 4;
}
if ((j&49152) == 32768)
{
- vec3_t davect;
-
- j &= (MAXWALLS-1);
-
- Bmemcpy(&davect, s, sizeof(vec3_t));
- A_DamageWall(i,j,&davect,s->picnum);
-
- Proj_BounceOffWall(s, j);
- s->xvel >>= 1;
+ vec3_t davect = *(vec3_t *)pSprite;
+ j &= (MAXWALLS - 1);
+ A_DamageWall(spriteNum, j, &davect, pSprite->picnum);
+ Proj_BounceOffWall(pSprite, j);
+ pSprite->xvel >>= 1;
}
DETONATEB:
// Pipebomb control set to timer? (see player.c)
// TIMER_CONTROL
- if (s->picnum == HEAVYHBOMB && t[6] == 1)
+ if (pSprite->picnum == HEAVYHBOMB && pData[6] == 1)
{
- /* if(s->extra >= 1)
- {
- s->extra--;
- }
+ if (pData[7] >= 1)
+ pData[7]--;
- if(s->extra <= 0)
- s->lotag=911;
- */
-
- if (t[7] >= 1)
- t[7]--;
-
- if (t[7] <= 0)
- t[6] = 3;
+ if (pData[7] <= 0)
+ pData[6] = 3;
}
- if ((l >= 0 && g_player[l].ps->hbomb_on == 0 && t[6] == 2) || t[3] == 1)
- t[6] = 3;
+ if ((l >= 0 && g_player[l].ps->hbomb_on == 0 && pData[6] == 2) || pData[3] == 1)
+ pData[6] = 3;
- if (t[6] == 3)
+ if (pData[6] == 3)
{
- t[2]++;
+ pData[2]++;
- if (t[2] == 2)
+ if (pData[2] == 2)
{
int32_t j;
- x = s->extra;
+ x = pSprite->extra;
m = 0;
- switch (DYNAMICTILEMAP(s->picnum))
+ switch (DYNAMICTILEMAP(pSprite->picnum))
{
case HEAVYHBOMB__STATIC:
m = g_pipebombBlastRadius;
@@ -4651,92 +4627,92 @@ DETONATEB:
break;
}
- A_RadiusDamage(i, m,x>>2,x>>1,x-(x>>2),x);
- j = A_Spawn(i,EXPLOSION2);
+ A_RadiusDamage(spriteNum, m,x>>2,x>>1,x-(x>>2),x);
+ j = A_Spawn(spriteNum,EXPLOSION2);
A_PlaySound(PIPEBOMB_EXPLODE,j);
- if (s->zvel == 0)
- A_Spawn(i,EXPLOSION2BOT);
+ if (pSprite->zvel == 0)
+ A_Spawn(spriteNum,EXPLOSION2BOT);
for (x=0; x<8; x++)
- RANDOMSCRAP;
+ RANDOMSCRAP(pSprite, spriteNum);
}
- if (s->yrepeat)
+ if (pSprite->yrepeat)
{
- s->yrepeat = 0;
- goto BOLT;
+ pSprite->yrepeat = 0;
+ goto next_sprite;
}
- if (t[2] > 20)
+ if (pData[2] > 20)
{
- if (s->owner != i || ud.respawn_items == 0)
+ if (pSprite->owner != spriteNum || ud.respawn_items == 0)
{
- KILLIT(i);
+ KILLIT(spriteNum);
}
else
{
- t[2] = g_itemRespawnTime;
- A_Spawn(i,RESPAWNMARKERRED);
- s->cstat = 32768;
- s->yrepeat = 9;
- goto BOLT;
+ pData[2] = g_itemRespawnTime;
+ A_Spawn(spriteNum,RESPAWNMARKERRED);
+ pSprite->cstat = 32768;
+ pSprite->yrepeat = 9;
+ goto next_sprite;
}
}
}
- else if (s->picnum == HEAVYHBOMB && x < 788 && t[0] > 7 && s->xvel == 0)
- if (cansee(s->x,s->y,s->z-(8<<8),s->sectnum,ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum))
- if (ps->ammo_amount[HANDBOMB_WEAPON] < ps->max_ammo_amount[HANDBOMB_WEAPON])
+ else if (pSprite->picnum == HEAVYHBOMB && x < 788 && pData[0] > 7 && pSprite->xvel == 0)
+ if (cansee(pSprite->x,pSprite->y,pSprite->z-ZOFFSET3,pSprite->sectnum,pPlayer->pos.x,pPlayer->pos.y,pPlayer->pos.z,pPlayer->cursectnum))
+ if (pPlayer->ammo_amount[HANDBOMB_WEAPON] < pPlayer->max_ammo_amount[HANDBOMB_WEAPON])
{
- if ((GametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY) && s->owner == i)
+ if ((GametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY) && pSprite->owner == spriteNum)
{
- for (j=0; jweapreccnt; j++)
- if (ps->weaprecs[j] == s->picnum)
- goto BOLT;
+ for (j=0; jweapreccnt; j++)
+ if (pPlayer->weaprecs[j] == pSprite->picnum)
+ goto next_sprite;
- if (ps->weapreccnt < MAX_WEAPONS)
- ps->weaprecs[ps->weapreccnt++] = s->picnum;
+ if (pPlayer->weapreccnt < MAX_WEAPONS)
+ pPlayer->weaprecs[pPlayer->weapreccnt++] = pSprite->picnum;
}
- P_AddAmmo(HANDBOMB_WEAPON,ps,1);
- A_PlaySound(DUKE_GET,ps->i);
+ P_AddAmmo(HANDBOMB_WEAPON,pPlayer,1);
+ A_PlaySound(DUKE_GET,pPlayer->i);
- if ((ps->gotweapon & (1<owner == ps->i)
+ if ((pPlayer->gotweapon & (1<owner == pPlayer->i)
{
- int32_t doswitch = ((ps->weaponswitch & 1) ||
- PWEAPON(p, ps->curr_weapon, WorksLike) == HANDREMOTE_WEAPON);
- P_AddWeapon(ps, HANDBOMB_WEAPON, doswitch);
+ int doSwitch = ((pPlayer->weaponswitch & 1) ||
+ PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == HANDREMOTE_WEAPON);
+ P_AddWeapon(pPlayer, HANDBOMB_WEAPON, doSwitch);
}
- if (sprite[s->owner].picnum != APLAYER)
- P_PalFrom(ps, 32, 0,32,0);
+ if (sprite[pSprite->owner].picnum != APLAYER)
+ P_PalFrom(pPlayer, 32, 0, 32, 0);
- if (s->owner != i || ud.respawn_items == 0)
+ if (pSprite->owner != spriteNum || ud.respawn_items == 0)
{
- if (s->owner == i && (GametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY))
- goto BOLT;
- KILLIT(i);
+ if (pSprite->owner == spriteNum && (GametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY))
+ goto next_sprite;
+ KILLIT(spriteNum);
}
else
{
- t[2] = g_itemRespawnTime;
- A_Spawn(i,RESPAWNMARKERRED);
- s->cstat = 32768;
+ pData[2] = g_itemRespawnTime;
+ A_Spawn(spriteNum, RESPAWNMARKERRED);
+ pSprite->cstat = 32768;
}
}
- if (t[0] < 8) t[0]++;
- goto BOLT;
+ if (pData[0] < 8) pData[0]++;
+ goto next_sprite;
}
case REACTORBURNT__STATIC:
case REACTOR2BURNT__STATIC:
- goto BOLT;
+ goto next_sprite;
case REACTOR__STATIC:
case REACTOR2__STATIC:
{
- if (t[4] == 1)
+ if (pData[4] == 1)
{
- for (SPRITES_OF_SECT(sect, j))
+ for (SPRITES_OF_SECT(sectNum, j))
{
switch (DYNAMICTILEMAP(sprite[j].picnum))
{
@@ -4760,20 +4736,20 @@ DETONATEB:
}
}
- goto BOLT;
+ goto next_sprite;
}
- if (t[1] >= 20)
+ if (pData[1] >= 20)
{
- t[4] = 1;
- goto BOLT;
+ pData[4] = 1;
+ goto next_sprite;
}
- int p = A_FindPlayer(s,&x);
+ int p = A_FindPlayer(pSprite,&x);
DukePlayer_t * const ps = g_player[p].ps;
- t[2]++;
- if (t[2] == 4) t[2]=0;
+ pData[2]++;
+ if (pData[2] == 4) pData[2]=0;
if (x < 4096)
{
@@ -4782,30 +4758,30 @@ DETONATEB:
if (!A_CheckSoundPlaying(ps->i, DUKE_LONGTERM_PAIN))
A_PlaySound(DUKE_LONGTERM_PAIN,ps->i);
- A_PlaySound(SHORT_CIRCUIT,i);
+ A_PlaySound(SHORT_CIRCUIT,spriteNum);
sprite[ps->i].extra --;
P_PalFrom(ps, 32, 32,0,0);
}
- t[0] += 128;
- if (t[3] == 0)
- t[3] = 1;
+ pData[0] += 128;
+ if (pData[3] == 0)
+ pData[3] = 1;
}
- else t[3] = 0;
+ else pData[3] = 0;
- if (t[1])
+ if (pData[1])
{
- t[1]++;
+ pData[1]++;
- t[4] = s->z;
- s->z = sector[sect].floorz-(krand()%(sector[sect].floorz-sector[sect].ceilingz));
+ pData[4] = pSprite->z;
+ pSprite->z = sector[sectNum].floorz-(krand()%(sector[sectNum].floorz-sector[sectNum].ceilingz));
- switch (t[1])
+ switch (pData[1])
{
case 3:
//Turn on all of those flashing sectoreffector.
- A_RadiusDamage(i, 4096,
+ A_RadiusDamage(spriteNum, 4096,
g_impactDamage<<2,
g_impactDamage<<2,
g_impactDamage<<2,
@@ -4814,7 +4790,7 @@ DETONATEB:
for (SPRITES_OF(STAT_STANDABLE, j))
{
if (sprite[j].picnum == MASTERSWITCH)
- if (sprite[j].hitag == s->hitag)
+ if (sprite[j].hitag == pSprite->hitag)
if (sprite[j].yvel == 0)
sprite[j].yvel = 1;
}
@@ -4824,8 +4800,8 @@ DETONATEB:
case 7:
case 10:
case 15:
- for (SPRITES_OF_SECT(sect, j))
- if (j != i)
+ for (SPRITES_OF_SECT(sectNum, j))
+ if (j != spriteNum)
{
A_DeleteSprite(j);
break;
@@ -4835,120 +4811,119 @@ DETONATEB:
}
for (x=0; x<16; x++)
- RANDOMSCRAP;
+ RANDOMSCRAP(pSprite, spriteNum);
- s->z = t[4];
- t[4] = 0;
+ pSprite->z = pData[4];
+ pData[4] = 0;
}
else
{
- if (A_IncurDamage(i) >= 0)
+ if (A_IncurDamage(spriteNum) >= 0)
{
for (x=0; x<32; x++)
- RANDOMSCRAP;
- if (s->extra < 0)
- t[1] = 1;
+ RANDOMSCRAP(pSprite, spriteNum);
+ if (pSprite->extra < 0)
+ pData[1] = 1;
}
}
- goto BOLT;
+ goto next_sprite;
}
case CAMERA1__STATIC:
- if (t[0] == 0)
+ if (pData[0] == 0)
{
- t[1]+=8;
+ pData[1]+=8;
if (g_damageCameras)
{
- if (A_IncurDamage(i) >= 0)
+ if (A_IncurDamage(spriteNum) >= 0)
{
- t[0] = 1; // static
- s->cstat = 32768;
- for (x=0; x<5; x++) RANDOMSCRAP;
- goto BOLT;
+ pData[0] = 1; // static
+ pSprite->cstat = 32768;
+ for (x=0; x<5; x++) RANDOMSCRAP(pSprite, spriteNum);
+ goto next_sprite;
}
}
- if (s->hitag > 0)
+ if (pSprite->hitag > 0)
{
- if (t[1] < s->hitag)
- s->ang+=8;
- else if (t[1] < s->hitag*3)
- s->ang-=8;
- else if (t[1] < (s->hitag<<2))
- s->ang+=8;
+ if (pData[1] < pSprite->hitag)
+ pSprite->ang+=8;
+ else if (pData[1] < pSprite->hitag*3)
+ pSprite->ang-=8;
+ else if (pData[1] < (pSprite->hitag<<2))
+ pSprite->ang+=8;
else
{
- t[1]=8;
- s->ang+=16;
+ pData[1]=8;
+ pSprite->ang+=16;
}
}
}
- goto BOLT;
+ goto next_sprite;
}
- if (!g_netServer && ud.multimode < 2 && A_CheckEnemySprite(s))
+ if (!g_netServer && ud.multimode < 2 && A_CheckEnemySprite(pSprite))
{
if (g_noEnemies == 1)
{
- s->cstat = 32768;
- goto BOLT;
+ pSprite->cstat = 32768;
+ goto next_sprite;
}
else if (g_noEnemies == 2)
{
- s->cstat = 0;
- if (s->extra)
- s->cstat = 257;
+ pSprite->cstat = 0;
+ if (pSprite->extra)
+ pSprite->cstat = 257;
}
}
- if (G_HaveActor(sprite[i].picnum))
+ if (G_HaveActor(sprite[spriteNum].picnum))
{
- int32_t p = A_FindPlayer(s,&x);
- A_Execute(i,p,x);
+ int32_t p = A_FindPlayer(pSprite,&x);
+ A_Execute(spriteNum,p,x);
}
-BOLT:
- i = nexti;
+next_sprite:
+ spriteNum = nextSprite;
}
}
ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
{
- int32_t i = headspritestat[STAT_MISC];
+ int32_t spriteNum = headspritestat[STAT_MISC];
- while (i >= 0)
+ while (spriteNum >= 0)
{
- const int32_t nexti = nextspritestat[i];
+ const int32_t nextSprite = nextspritestat[spriteNum];
+ int32_t l;
+ int32_t playerDist;
+ int32_t *const pData = actor[spriteNum].t_data;
+ spritetype *const pSprite = &sprite[spriteNum];
+ int32_t sectNum = pSprite->sectnum; // XXX: not const
+ int32_t switchPic;
- int32_t l, x;
- int32_t *const t = actor[i].t_data;
+ if (sectNum < 0 || pSprite->xrepeat == 0)
+ KILLIT(spriteNum);
- spritetype *const s = &sprite[i];
- int32_t sect = s->sectnum; // XXX: not const
- int32_t switchpicnum;
+ Bmemcpy(&actor[spriteNum].bpos, pSprite, sizeof(vec3_t));
- if (sect < 0 || s->xrepeat == 0)
- KILLIT(i);
+ switchPic = pSprite->picnum;
+ if (pSprite->picnum > NUKEBUTTON && pSprite->picnum <= NUKEBUTTON+3)
+ switchPic = NUKEBUTTON;
- Bmemcpy(&actor[i].bpos, s, sizeof(vec3_t));
+ if (pSprite->picnum > GLASSPIECES && pSprite->picnum <= GLASSPIECES+2)
+ switchPic = GLASSPIECES;
- switchpicnum = s->picnum;
- if (s->picnum > NUKEBUTTON && s->picnum <= NUKEBUTTON+3)
- switchpicnum = NUKEBUTTON;
+ if (pSprite->picnum == INNERJAW+1)
+ switchPic--;
- if (s->picnum > GLASSPIECES && s->picnum <= GLASSPIECES+2)
- switchpicnum = GLASSPIECES;
-
- if (s->picnum == INNERJAW+1)
- switchpicnum--;
-
- if ((s->picnum == MONEY+1) || (s->picnum == MAIL+1) || (s->picnum == PAPER+1))
- actor[i].floorz = s->z = getflorzofslope(s->sectnum,s->x,s->y);
- else switch (DYNAMICTILEMAP(switchpicnum))
+ if ((pSprite->picnum == MONEY+1) || (pSprite->picnum == MAIL+1) || (pSprite->picnum == PAPER+1))
+ actor[spriteNum].floorz = pSprite->z = getflorzofslope(pSprite->sectnum,pSprite->x,pSprite->y);
+ else switch (DYNAMICTILEMAP(switchPic))
{
case APLAYER__STATIC:
- s->cstat = 32768;
- goto BOLT;
+ pSprite->cstat = 32768;
+ goto next_sprite;
case NEON1__STATIC:
case NEON2__STATIC:
case NEON3__STATIC:
@@ -4956,95 +4931,91 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
case NEON5__STATIC:
case NEON6__STATIC:
- if ((tabledivide32_noinline(g_globalRandom, s->lotag+1)&31) > 4)
- s->shade = -127;
- else s->shade = 127;
- goto BOLT;
+ if ((tabledivide32_noinline(g_globalRandom, pSprite->lotag+1)&31) > 4)
+ pSprite->shade = -127;
+ else pSprite->shade = 127;
+ goto next_sprite;
case BLOODSPLAT1__STATIC:
case BLOODSPLAT2__STATIC:
case BLOODSPLAT3__STATIC:
case BLOODSPLAT4__STATIC:
- if (t[0] == 3*GAMETICSPERSEC) goto BOLT;
- actor[i].bpos.z -= s->z;
- t[0]++;
- if ((t[0]%9) == 0)
+ if (pData[0] == 3*GAMETICSPERSEC) goto next_sprite;
+ actor[spriteNum].bpos.z -= pSprite->z;
+ pData[0]++;
+ if ((pData[0]%9) == 0)
{
- s->yrepeat++;
- s->z += (tilesiz[s->picnum].y*s->yrepeat)>>2;
+ pSprite->yrepeat++;
+ pSprite->z += (tilesiz[pSprite->picnum].y*pSprite->yrepeat)>>2;
}
- else s->z += 16 + (krand() & 15);
- actor[i].bpos.z += s->z;
- goto BOLT;
+ else pSprite->z += 16 + (krand() & 15);
+ actor[spriteNum].bpos.z += pSprite->z;
+ goto next_sprite;
case NUKEBUTTON__STATIC:
// case NUKEBUTTON+1:
// case NUKEBUTTON+2:
// case NUKEBUTTON+3:
- if (t[0])
+ if (pData[0])
{
- t[0]++;
- if (t[0] == 8) s->picnum = NUKEBUTTON+1;
- else if (t[0] == 16)
+ pData[0]++;
+ if (pData[0] == 8) pSprite->picnum = NUKEBUTTON+1;
+ else if (pData[0] == 16)
{
- s->picnum = NUKEBUTTON+2;
- g_player[P_Get(s->owner)].ps->fist_incs = 1;
+ pSprite->picnum = NUKEBUTTON+2;
+ g_player[P_Get(pSprite->owner)].ps->fist_incs = 1;
}
- if (g_player[P_Get(s->owner)].ps->fist_incs == GAMETICSPERSEC)
- s->picnum = NUKEBUTTON+3;
+ if (g_player[P_Get(pSprite->owner)].ps->fist_incs == GAMETICSPERSEC)
+ pSprite->picnum = NUKEBUTTON+3;
}
- goto BOLT;
+ goto next_sprite;
case FORCESPHERE__STATIC:
{
- int32_t j;
-
- l = s->xrepeat;
- if (t[1] > 0)
+ l = pSprite->xrepeat;
+ if (pData[1] > 0)
{
- t[1]--;
- if (t[1] == 0)
- KILLIT(i);
+ pData[1]--;
+ if (pData[1] == 0)
+ KILLIT(spriteNum);
}
- if (actor[s->owner].t_data[1] == 0)
+ if (actor[pSprite->owner].t_data[1] == 0)
{
- if (t[0] < 64)
+ if (pData[0] < 64)
{
- t[0]++;
+ pData[0]++;
l += 3;
}
}
- else if (t[0] > 64)
+ else if (pData[0] > 64)
{
- t[0]--;
+ pData[0]--;
l -= 3;
}
- s->x = sprite[s->owner].x;
- s->y = sprite[s->owner].y;
- s->z = sprite[s->owner].z;
- s->ang += actor[s->owner].t_data[0];
+ *(vec3_t *) pSprite = *(vec3_t *) &sprite[pSprite->owner];
+ pSprite->ang += actor[pSprite->owner].t_data[0];
if (l > 64) l = 64;
else if (l < 1) l = 1;
- s->xrepeat = l;
- s->yrepeat = l;
- s->shade = (l>>1)-48;
+ pSprite->xrepeat = l;
+ pSprite->yrepeat = l;
+ pSprite->shade = (l>>1)-48;
- for (j=t[0]; j > 0; j--)
- A_SetSprite(i,CLIPMASK0);
- goto BOLT;
+ for (int j = pData[0]; j > 0; j--)
+ A_SetSprite(spriteNum, CLIPMASK0);
+ goto next_sprite;
}
case WATERSPLASH2__STATIC:
- t[0]++;
- if (t[0] == 1)
+ pData[0]++;
+ if (pData[0] == 1)
{
- if (sector[sect].lotag != ST_1_ABOVE_WATER && sector[sect].lotag != ST_2_UNDERWATER)
- KILLIT(i);
+ if (sector[sectNum].lotag != ST_1_ABOVE_WATER && sector[sectNum].lotag != ST_2_UNDERWATER)
+ KILLIT(spriteNum);
/*
else
{
@@ -5053,100 +5024,99 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
}
else
*/
- if (!S_CheckSoundPlaying(i,ITEM_SPLASH))
- A_PlaySound(ITEM_SPLASH,i);
+ if (!S_CheckSoundPlaying(spriteNum,ITEM_SPLASH))
+ A_PlaySound(ITEM_SPLASH,spriteNum);
}
- if (t[0] == 3)
+ if (pData[0] == 3)
{
- t[0] = 0;
- t[1]++; // WATERSPLASH_T2
+ pData[0] = 0;
+ pData[1]++; // WATERSPLASH_T2
}
- if (t[1] == 5)
- A_DeleteSprite(i);
- goto BOLT;
+ if (pData[1] == 5)
+ A_DeleteSprite(spriteNum);
+ goto next_sprite;
case FRAMEEFFECT1_13__STATIC:
- if (PLUTOPAK) goto BOLT; // JBF: ideally this should never happen...
+ if (PLUTOPAK) goto next_sprite; // JBF: ideally this should never happen...
case FRAMEEFFECT1__STATIC:
- if (s->owner >= 0)
+ if (pSprite->owner >= 0)
{
- t[0]++;
+ pData[0]++;
- if (t[0] > 7)
+ if (pData[0] > 7)
{
- KILLIT(i);
+ KILLIT(spriteNum);
}
- else if (t[0] > 4)
- s->cstat |= 512+2;
- else if (t[0] > 2)
- s->cstat |= 2;
- s->xoffset = sprite[s->owner].xoffset;
- s->yoffset = sprite[s->owner].yoffset;
+ else if (pData[0] > 4)
+ pSprite->cstat |= 512+2;
+ else if (pData[0] > 2)
+ pSprite->cstat |= 2;
+ pSprite->xoffset = sprite[pSprite->owner].xoffset;
+ pSprite->yoffset = sprite[pSprite->owner].yoffset;
}
- goto BOLT;
+ goto next_sprite;
case INNERJAW__STATIC:
{
// case INNERJAW+1:
+ int32_t playerDist, playerNum = A_FindPlayer(pSprite,&playerDist);
- int32_t p = A_FindPlayer(s,&x);
- if (x < 512)
+ if (playerDist < 512)
{
- P_PalFrom(g_player[p].ps, 32, 32,0,0);
- sprite[g_player[p].ps->i].extra -= 4;
+ P_PalFrom(g_player[playerNum].ps, 32, 32,0,0);
+ sprite[g_player[playerNum].ps->i].extra -= 4;
}
}
case FIRELASER__STATIC:
- if (s->extra != 5)
- s->extra = 5;
- else KILLIT(i);
+ if (pSprite->extra != 5)
+ pSprite->extra = 5;
+ else KILLIT(spriteNum);
break;
case TONGUE__STATIC:
- KILLIT(i);
+ KILLIT(spriteNum);
case MONEY__STATIC:
case MAIL__STATIC:
case PAPER__STATIC:
- s->xvel = (krand()&7)+(sintable[T1&2047]>>9);
- T1 += (krand()&63);
- if ((T1&2047) > 512 && (T1&2047) < 1596)
+ pSprite->xvel = (krand()&7)+(sintable[T1(spriteNum)&2047]>>9);
+ T1(spriteNum) += (krand()&63);
+ if ((T1(spriteNum)&2047) > 512 && (T1(spriteNum)&2047) < 1596)
{
- if (sector[sect].lotag == ST_2_UNDERWATER)
+ if (sector[sectNum].lotag == ST_2_UNDERWATER)
{
- if (s->zvel < 64)
- s->zvel += (g_spriteGravity>>5)+(krand()&7);
+ if (pSprite->zvel < 64)
+ pSprite->zvel += (g_spriteGravity>>5)+(krand()&7);
}
- else if (s->zvel < 144)
- s->zvel += (g_spriteGravity>>5)+(krand()&7);
+ else if (pSprite->zvel < 144)
+ pSprite->zvel += (g_spriteGravity>>5)+(krand()&7);
}
- A_SetSprite(i,CLIPMASK0);
+ A_SetSprite(spriteNum,CLIPMASK0);
if ((krand()&3) == 0)
- setsprite(i,(vec3_t *)s);
+ setsprite(spriteNum,(vec3_t *)pSprite);
- if (s->sectnum == -1)
- KILLIT(i);
- l = getflorzofslope(s->sectnum,s->x,s->y);
+ if (pSprite->sectnum == -1)
+ KILLIT(spriteNum);
+ l = getflorzofslope(pSprite->sectnum,pSprite->x,pSprite->y);
- if (s->z > l)
+ if (pSprite->z > l)
{
- int32_t j;
+ pSprite->z = l;
- s->z = l;
+ A_AddToDeleteQueue(spriteNum);
+ PN(spriteNum) ++;
- A_AddToDeleteQueue(i);
- PN ++;
-
- for (SPRITES_OF(STAT_MISC, j))
- if (sprite[j].picnum == BLOODPOOL)
- if (ldist(s,&sprite[j]) < 348)
- {
- s->pal = 2;
- break;
- }
+ for (int SPRITES_OF(STAT_MISC, j))
+ {
+ if (sprite[j].picnum == BLOODPOOL && ldist(pSprite, &sprite[j]) < 348)
+ {
+ pSprite->pal = 2;
+ break;
+ }
+ }
}
break;
@@ -5167,169 +5137,166 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
case DUKEGUN__STATIC:
case DUKELEG__STATIC:
- if (s->xvel > 0) s->xvel--;
- else s->xvel = 0;
+ if (pSprite->xvel > 0)
+ pSprite->xvel--;
+ else
+ pSprite->xvel = 0;
- if (++t[5] == (30*10))
- KILLIT(i);
+ if (++pData[5] == (30*10))
+ KILLIT(spriteNum);
- if (s->zvel > 1024 && s->zvel < 1280)
+ if (pSprite->zvel > 1024 && pSprite->zvel < 1280)
{
- setsprite(i,(vec3_t *)s);
- sect = s->sectnum;
+ setsprite(spriteNum,(vec3_t *)pSprite);
+ sectNum = pSprite->sectnum;
}
- getzsofslope(sect,s->x,s->y,&x,&l);
- if (x == l || sect < 0 || sect >= MAXSECTORS) KILLIT(i);
+ getzsofslope(sectNum,pSprite->x,pSprite->y,&playerDist,&l);
+ if (playerDist == l || sectNum < 0 || sectNum >= MAXSECTORS) KILLIT(spriteNum);
- if (s->z < l-(2<<8))
+ if (pSprite->z < l-(2<<8))
{
- if (t[1] < 2) t[1]++;
- else if (sector[sect].lotag != ST_2_UNDERWATER)
+ if (pData[1] < 2) pData[1]++;
+ else if (sector[sectNum].lotag != ST_2_UNDERWATER)
{
- t[1] = 0;
- if (s->picnum == DUKELEG || s->picnum == DUKETORSO || s->picnum == DUKEGUN)
+ pData[1] = 0;
+ if (pSprite->picnum == DUKELEG || pSprite->picnum == DUKETORSO || pSprite->picnum == DUKEGUN)
{
- if (t[0] > 6) t[0] = 0;
- else t[0]++;
+ if (pData[0] > 6) pData[0] = 0;
+ else pData[0]++;
}
else
{
- if (t[0] > 2)
- t[0] = 0;
- else t[0]++;
+ if (pData[0] > 2)
+ pData[0] = 0;
+ else pData[0]++;
}
}
- if (s->zvel < 6144)
+ if (pSprite->zvel < 6144)
{
- if (sector[sect].lotag == ST_2_UNDERWATER)
+ if (sector[sectNum].lotag == ST_2_UNDERWATER)
{
- if (s->zvel < 1024)
- s->zvel += 48;
- else s->zvel = 1024;
+ if (pSprite->zvel < 1024)
+ pSprite->zvel += 48;
+ else pSprite->zvel = 1024;
}
- else s->zvel += g_spriteGravity-50;
+ else pSprite->zvel += g_spriteGravity-50;
}
- s->x += (s->xvel*sintable[(s->ang+512)&2047])>>14;
- s->y += (s->xvel*sintable[s->ang&2047])>>14;
- s->z += s->zvel;
+ pSprite->x += (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14;
+ pSprite->y += (pSprite->xvel*sintable[pSprite->ang&2047])>>14;
+ pSprite->z += pSprite->zvel;
}
else
{
- if (t[2] == 0)
+ if (pData[2] == 0)
{
- if (s->sectnum == -1)
- KILLIT(i);
+ if (pSprite->sectnum == -1)
+ KILLIT(spriteNum);
- if ((sector[s->sectnum].floorstat&2))
- KILLIT(i);
+ if ((sector[pSprite->sectnum].floorstat&2))
+ KILLIT(spriteNum);
- t[2]++;
+ pData[2]++;
}
- l = getflorzofslope(s->sectnum,s->x,s->y);
+ l = getflorzofslope(pSprite->sectnum,pSprite->x,pSprite->y);
- s->z = l-(2<<8);
- s->xvel = 0;
+ pSprite->z = l-(2<<8);
+ pSprite->xvel = 0;
- if (s->picnum == JIBS6)
+ if (pSprite->picnum == JIBS6)
{
- t[1]++;
- if ((t[1]&3) == 0 && t[0] < 7)
- t[0]++;
- if (t[1] > 20)
- KILLIT(i);
+ pData[1]++;
+ if ((pData[1]&3) == 0 && pData[0] < 7)
+ pData[0]++;
+ if (pData[1] > 20)
+ KILLIT(spriteNum);
}
else
{
- s->picnum = JIBS6;
- t[0] = 0;
- t[1] = 0;
+ pSprite->picnum = JIBS6;
+ pData[0] = 0;
+ pData[1] = 0;
}
}
- goto BOLT;
+ goto next_sprite;
case BLOODPOOL__STATIC:
case PUKE__STATIC:
{
- int32_t p;
- DukePlayer_t *ps;
-
- if (t[0] == 0)
+ if (pData[0] == 0)
{
- t[0] = 1;
- if (sector[sect].floorstat&2)
+ pData[0] = 1;
+ if (sector[sectNum].floorstat&2)
{
- KILLIT(i);
+ KILLIT(spriteNum);
}
- else A_AddToDeleteQueue(i);
+ else A_AddToDeleteQueue(spriteNum);
}
- A_Fall(i);
+ A_Fall(spriteNum);
- p = A_FindPlayer(s,&x);
- ps = g_player[p].ps;
+ int32_t playerDist;
+ int32_t playerNum = A_FindPlayer(pSprite, &playerDist);
+ DukePlayer_t *pPlayer = g_player[playerNum].ps;
+ pSprite->z = actor[spriteNum].floorz - 1;
- s->z = actor[i].floorz - 1;
-
- if (t[2] < 32)
+ if (pData[2] < 32)
{
- t[2]++;
- if (actor[i].picnum == TIRE)
+ pData[2]++;
+ if (actor[spriteNum].picnum == TIRE)
{
- if (s->xrepeat < 64 && s->yrepeat < 64)
+ if (pSprite->xrepeat < 64 && pSprite->yrepeat < 64)
{
- s->xrepeat += krand()&3;
- s->yrepeat += krand()&3;
+ pSprite->xrepeat += krand()&3;
+ pSprite->yrepeat += krand()&3;
}
}
else
{
- if (s->xrepeat < 32 && s->yrepeat < 32)
+ if (pSprite->xrepeat < 32 && pSprite->yrepeat < 32)
{
- s->xrepeat += krand()&3;
- s->yrepeat += krand()&3;
+ pSprite->xrepeat += krand()&3;
+ pSprite->yrepeat += krand()&3;
}
}
}
- if (x < 844 && s->xrepeat > 6 && s->yrepeat > 6)
+ if (playerDist < 844 && pSprite->xrepeat > 6 && pSprite->yrepeat > 6)
{
- if (s->pal == 0 && s->picnum != PUKE && (krand()&255) < 16)
+ if (pSprite->pal == 0 && pSprite->picnum != PUKE && (krand()&255) < 16)
{
- if (ps->inv_amount[GET_BOOTS] > 0)
- ps->inv_amount[GET_BOOTS]--;
+ if (pPlayer->inv_amount[GET_BOOTS] > 0)
+ pPlayer->inv_amount[GET_BOOTS]--;
else
{
- if (!A_CheckSoundPlaying(ps->i,DUKE_LONGTERM_PAIN))
- A_PlaySound(DUKE_LONGTERM_PAIN,ps->i);
- sprite[ps->i].extra --;
+ if (!A_CheckSoundPlaying(pPlayer->i,DUKE_LONGTERM_PAIN))
+ A_PlaySound(DUKE_LONGTERM_PAIN,pPlayer->i);
+ sprite[pPlayer->i].extra --;
- P_PalFrom(ps, 32, 16,0,0);
+ P_PalFrom(pPlayer, 32, 16,0,0);
}
}
- if (t[1] == 1) goto BOLT;
- t[1] = 1;
+ if (pData[1] == 1) goto next_sprite;
- if (actor[i].picnum == TIRE)
- ps->footprintcount = 10;
- else ps->footprintcount = 3;
+ pData[1] = 1;
- ps->footprintpal = s->pal;
- ps->footprintshade = s->shade;
+ pPlayer->footprintcount = (actor[spriteNum].picnum == TIRE) ? 10 : 3;
+ pPlayer->footprintpal = pSprite->pal;
+ pPlayer->footprintshade = pSprite->shade;
- if (t[2] == 32)
+ if (pData[2] == 32)
{
- s->xrepeat -= 6;
- s->yrepeat -= 6;
+ pSprite->xrepeat -= 6;
+ pSprite->yrepeat -= 6;
}
}
- else t[1] = 0;
- goto BOLT;
+ else pData[1] = 0;
+ goto next_sprite;
}
case BURNING__STATIC:
@@ -5346,146 +5313,146 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
case TRANSPORTERSTAR__STATIC:
case TRANSPORTERBEAM__STATIC:
{
- if (!G_HaveActor(sprite[i].picnum))
- goto BOLT;
+ if (!G_HaveActor(sprite[spriteNum].picnum))
+ goto next_sprite;
{
- int32_t p = A_FindPlayer(s,&x);
- A_Execute(i,p,x);
+ int32_t playerNum = A_FindPlayer(pSprite,&playerDist);
+ A_Execute(spriteNum,playerNum,playerDist);
}
- goto BOLT;
+ goto next_sprite;
}
case SHELL__STATIC:
case SHOTGUNSHELL__STATIC:
- A_SetSprite(i,CLIPMASK0);
+ A_SetSprite(spriteNum,CLIPMASK0);
- if (sect < 0 || (sector[sect].floorz + 256) < s->z)
- KILLIT(i);
+ if (sectNum < 0 || (sector[sectNum].floorz + 256) < pSprite->z)
+ KILLIT(spriteNum);
- if (sector[sect].lotag == ST_2_UNDERWATER)
+ if (sector[sectNum].lotag == ST_2_UNDERWATER)
{
- t[1]++;
- if (t[1] > 8)
+ pData[1]++;
+ if (pData[1] > 8)
{
- t[1] = 0;
- t[0]++;
- t[0] &= 3;
+ pData[1] = 0;
+ pData[0]++;
+ pData[0] &= 3;
}
- if (s->zvel < 128) s->zvel += (g_spriteGravity/13); // 8
- else s->zvel -= 64;
- if (s->xvel > 0)
- s->xvel -= 4;
- else s->xvel = 0;
+ if (pSprite->zvel < 128) pSprite->zvel += (g_spriteGravity/13); // 8
+ else pSprite->zvel -= 64;
+ if (pSprite->xvel > 0)
+ pSprite->xvel -= 4;
+ else pSprite->xvel = 0;
}
else
{
- t[1]++;
- if (t[1] > 3)
+ pData[1]++;
+ if (pData[1] > 3)
{
- t[1] = 0;
- t[0]++;
- t[0] &= 3;
+ pData[1] = 0;
+ pData[0]++;
+ pData[0] &= 3;
}
- if (s->zvel < 512) s->zvel += (g_spriteGravity/3); // 52;
- if (s->xvel > 0)
- s->xvel --;
+ if (pSprite->zvel < 512) pSprite->zvel += (g_spriteGravity/3); // 52;
+ if (pSprite->xvel > 0)
+ pSprite->xvel --;
// else KILLIT(i);
}
- goto BOLT;
+ goto next_sprite;
case GLASSPIECES__STATIC:
// case GLASSPIECES+1:
// case GLASSPIECES+2:
- A_Fall(i);
+ A_Fall(spriteNum);
- if (s->zvel > 4096) s->zvel = 4096;
- if (sect < 0)
- KILLIT(i);
+ if (pSprite->zvel > 4096) pSprite->zvel = 4096;
+ if (sectNum < 0)
+ KILLIT(spriteNum);
- if (s->z == actor[i].floorz-(ZOFFSET) && t[0] < 3)
+ if (pSprite->z == actor[spriteNum].floorz-(ZOFFSET) && pData[0] < 3)
{
- s->zvel = -((3-t[0])<<8)-(krand()&511);
- if (sector[sect].lotag == ST_2_UNDERWATER)
- s->zvel >>= 1;
- s->xrepeat >>= 1;
- s->yrepeat >>= 1;
+ pSprite->zvel = -((3-pData[0])<<8)-(krand()&511);
+ if (sector[sectNum].lotag == ST_2_UNDERWATER)
+ pSprite->zvel >>= 1;
+ pSprite->xrepeat >>= 1;
+ pSprite->yrepeat >>= 1;
if (rnd(96))
- setsprite(i,(vec3_t *)s);
- t[0]++;//Number of bounces
+ setsprite(spriteNum,(vec3_t *)pSprite);
+ pData[0]++;//Number of bounces
}
- else if (t[0] == 3)
- KILLIT(i);
+ else if (pData[0] == 3)
+ KILLIT(spriteNum);
- if (s->xvel > 0)
+ if (pSprite->xvel > 0)
{
- s->xvel -= 2;
- s->cstat = ((s->xvel&3)<<2);
+ pSprite->xvel -= 2;
+ pSprite->cstat = ((pSprite->xvel&3)<<2);
}
- else s->xvel = 0;
+ else pSprite->xvel = 0;
- A_SetSprite(i,CLIPMASK0);
+ A_SetSprite(spriteNum,CLIPMASK0);
- goto BOLT;
+ goto next_sprite;
}
- if (PN >= SCRAP6 && PN <= SCRAP5+3)
+ if (PN(spriteNum) >= SCRAP6 && PN(spriteNum) <= SCRAP5+3)
{
- if (s->xvel > 0)
- s->xvel--;
- else s->xvel = 0;
+ if (pSprite->xvel > 0)
+ pSprite->xvel--;
+ else pSprite->xvel = 0;
- if (s->zvel > 1024 && s->zvel < 1280)
+ if (pSprite->zvel > 1024 && pSprite->zvel < 1280)
{
- setsprite(i,(vec3_t *)s);
- sect = s->sectnum;
+ setsprite(spriteNum,(vec3_t *)pSprite);
+ sectNum = pSprite->sectnum;
}
- if (s->z < sector[sect].floorz-(2<<8))
+ if (pSprite->z < sector[sectNum].floorz-(2<<8))
{
- if (t[1] < 1) t[1]++;
+ if (pData[1] < 1) pData[1]++;
else
{
- t[1] = 0;
+ pData[1] = 0;
- if (s->picnum < SCRAP6+8)
+ if (pSprite->picnum < SCRAP6+8)
{
- if (t[0] > 6)
- t[0] = 0;
- else t[0]++;
+ if (pData[0] > 6)
+ pData[0] = 0;
+ else pData[0]++;
}
else
{
- if (t[0] > 2)
- t[0] = 0;
- else t[0]++;
+ if (pData[0] > 2)
+ pData[0] = 0;
+ else pData[0]++;
}
}
- if (s->zvel < 4096) s->zvel += g_spriteGravity-50;
- s->x += (s->xvel*sintable[(s->ang+512)&2047])>>14;
- s->y += (s->xvel*sintable[s->ang&2047])>>14;
- s->z += s->zvel;
+ 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;
}
else
{
- if (s->picnum == SCRAP1 && s->yvel > 0 && s->yvel < MAXUSERTILES)
+ if (pSprite->picnum == SCRAP1 && pSprite->yvel > 0 && pSprite->yvel < MAXUSERTILES)
{
- int32_t j = A_Spawn(i, s->yvel);
+ int32_t j = A_Spawn(spriteNum, pSprite->yvel);
- setsprite(j,(vec3_t *)s);
+ setsprite(j,(vec3_t *)pSprite);
A_GetZLimits(j);
sprite[j].hitag = sprite[j].lotag = 0;
}
- KILLIT(i);
+ KILLIT(spriteNum);
}
- goto BOLT;
+ goto next_sprite;
}
-BOLT:
- i = nexti;
+next_sprite:
+ spriteNum = nextSprite;
}
}
@@ -5497,7 +5464,7 @@ static void HandleSE31(int32_t i, int32_t setfloorzp, int32_t zref, int32_t t2va
sectortype *const sc = §or[sprite[i].sectnum];
int32_t *const t = actor[i].t_data;
- if (klabs(sc->floorz - zref) < SP)
+ if (klabs(sc->floorz - zref) < SP(i))
{
if (setfloorzp)
sc->floorz = zref;
@@ -5510,7 +5477,7 @@ static void HandleSE31(int32_t i, int32_t setfloorzp, int32_t zref, int32_t t2va
else
{
int32_t j;
- int32_t l = ksgn(movesignexp)*SP;
+ int32_t l = ksgn(movesignexp)*SP(i);
sc->floorz += l;
@@ -5566,7 +5533,7 @@ static void MaybeTrainKillPlayer(const spritetype *s, int32_t dosetopos)
// i: SE spritenum
static void MaybeTrainKillEnemies(int32_t i, int32_t numguts)
{
- int32_t j = headspritesect[sprite[OW].sectnum];
+ int32_t j = headspritesect[sprite[OW(i)].sectnum];
while (j >= 0)
{
@@ -5591,147 +5558,146 @@ static void MaybeTrainKillEnemies(int32_t i, int32_t numguts)
ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
{
- walltype *wal;
- int32_t q=0, j, k, l, m, x;
- int32_t i = headspritestat[STAT_EFFECTOR];
+ int32_t q = 0, j, k, l, m, x;
+ int spriteNum = headspritestat[STAT_EFFECTOR];
- while (i >= 0)
+ while (spriteNum >= 0)
{
- const int32_t nexti = nextspritestat[i];
- spritetype *const s = &sprite[i];
+ int const nextSprite = nextspritestat[spriteNum];
+ spritetype *const pSprite = &sprite[spriteNum];
+ int32_t playerDist;
+ int32_t playerNum = A_FindPlayer(pSprite, &playerDist);
- int32_t p, pl = A_FindPlayer(s, &p);
-
- if (VM_OnEventWithBoth(EVENT_MOVEEFFECTORS, i, pl, p, 0))
+ if (VM_OnEventWithBoth(EVENT_MOVEEFFECTORS, spriteNum, playerNum, playerDist, 0))
{
- i = nexti;
+ spriteNum = nextSprite;
continue;
}
- sectortype *const sc = §or[s->sectnum];
- const int32_t st = s->lotag;
- const int32_t sh = s->hitag;
+ sectortype *const pSector = §or[pSprite->sectnum];
+ int const sectorLotag = pSprite->lotag;
+ int const sectorHitag = pSprite->hitag;
- int32_t *const t = &actor[i].t_data[0];
+ int32_t *const pData = &actor[spriteNum].t_data[0];
- switch (st)
+ switch (sectorLotag)
{
case SE_0_ROTATING_SECTOR:
{
int32_t zchange = 0;
- j = s->owner;
+ j = pSprite->owner;
if (sprite[j].lotag == UINT16_MAX)
- KILLIT(i);
+ KILLIT(spriteNum);
- q = sc->extra>>3;
+ q = pSector->extra>>3;
l = 0;
- if (sc->lotag == ST_30_ROTATE_RISE_BRIDGE)
+ if (pSector->lotag == ST_30_ROTATE_RISE_BRIDGE)
{
q >>= 2;
- if (sprite[i].extra == 1)
+ if (sprite[spriteNum].extra == 1)
{
- if (actor[i].tempang < 256)
+ if (actor[spriteNum].tempang < 256)
{
- actor[i].tempang += 4;
- if (actor[i].tempang >= 256)
- A_CallSound(s->sectnum,i);
- if (s->clipdist) l = 1;
+ actor[spriteNum].tempang += 4;
+ if (actor[spriteNum].tempang >= 256)
+ A_CallSound(pSprite->sectnum,spriteNum);
+ if (pSprite->clipdist) l = 1;
else l = -1;
}
- else actor[i].tempang = 256;
+ else actor[spriteNum].tempang = 256;
- if (sc->floorz > s->z) //z's are touching
+ if (pSector->floorz > pSprite->z) //z's are touching
{
- sc->floorz -= 512;
+ pSector->floorz -= 512;
zchange = -512;
- if (sc->floorz < s->z)
- sc->floorz = s->z;
+ if (pSector->floorz < pSprite->z)
+ pSector->floorz = pSprite->z;
}
- else if (sc->floorz < s->z) //z's are touching
+ else if (pSector->floorz < pSprite->z) //z's are touching
{
- sc->floorz += 512;
+ pSector->floorz += 512;
zchange = 512;
- if (sc->floorz > s->z)
- sc->floorz = s->z;
+ if (pSector->floorz > pSprite->z)
+ pSector->floorz = pSprite->z;
}
}
- else if (sprite[i].extra == 3)
+ else if (sprite[spriteNum].extra == 3)
{
- if (actor[i].tempang > 0)
+ if (actor[spriteNum].tempang > 0)
{
- actor[i].tempang -= 4;
- if (actor[i].tempang <= 0)
- A_CallSound(s->sectnum,i);
- if (s->clipdist) l = -1;
+ actor[spriteNum].tempang -= 4;
+ if (actor[spriteNum].tempang <= 0)
+ A_CallSound(pSprite->sectnum,spriteNum);
+ if (pSprite->clipdist) l = -1;
else l = 1;
}
- else actor[i].tempang = 0;
+ else actor[spriteNum].tempang = 0;
- if (sc->floorz > T4) //z's are touching
+ if (pSector->floorz > T4(spriteNum)) //z's are touching
{
- sc->floorz -= 512;
+ pSector->floorz -= 512;
zchange = -512;
- if (sc->floorz < T4)
- sc->floorz = T4;
+ if (pSector->floorz < T4(spriteNum))
+ pSector->floorz = T4(spriteNum);
}
- else if (sc->floorz < T4) //z's are touching
+ else if (pSector->floorz < T4(spriteNum)) //z's are touching
{
- sc->floorz += 512;
+ pSector->floorz += 512;
zchange = 512;
- if (sc->floorz > T4)
- sc->floorz = T4;
+ if (pSector->floorz > T4(spriteNum))
+ pSector->floorz = T4(spriteNum);
}
}
}
else
{
if (actor[j].t_data[0] == 0) break;
- if (actor[j].t_data[0] == 2) KILLIT(i);
+ if (actor[j].t_data[0] == 2) KILLIT(spriteNum);
if (sprite[j].ang > 1024)
l = -1;
else l = 1;
- if (t[3] == 0)
- t[3] = ldist(s,&sprite[j]);
- s->xvel = t[3];
- s->x = sprite[j].x;
- s->y = sprite[j].y;
+ if (pData[3] == 0)
+ pData[3] = ldist(pSprite,&sprite[j]);
+ pSprite->xvel = pData[3];
+ pSprite->x = sprite[j].x;
+ pSprite->y = sprite[j].y;
}
- s->ang += (l*q);
- t[2] += (l*q);
+ pSprite->ang += (l*q);
+ pData[2] += (l*q);
- if (l && (sc->floorstat&64))
+ if (l && (pSector->floorstat&64))
{
- 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 == s->sectnum && ps->on_ground == 1)
+ if (pPlayer->cursectnum == pSprite->sectnum && pPlayer->on_ground == 1)
{
- ps->ang += (l*q);
- ps->ang &= 2047;
+ pPlayer->ang += (l*q);
+ pPlayer->ang &= 2047;
- ps->pos.z += zchange;
+ pPlayer->pos.z += zchange;
vec2_t r;
- rotatepoint(*(vec2_t *)&sprite[j],*(vec2_t *)&ps->pos,(q*l),&r);
+ rotatepoint(*(vec2_t *)&sprite[j],*(vec2_t *)&pPlayer->pos,(q*l),&r);
- ps->bobpos.x += r.x-ps->pos.x;
- ps->bobpos.y += r.y-ps->pos.y;
+ pPlayer->bobpos.x += r.x-pPlayer->pos.x;
+ pPlayer->bobpos.y += r.y-pPlayer->pos.y;
- *(vec2_t *)&ps->pos = r;
+ *(vec2_t *)&pPlayer->pos = r;
- if (sprite[ps->i].extra <= 0)
- *(vec2_t *)&sprite[ps->i] = r;
+ if (sprite[pPlayer->i].extra <= 0)
+ *(vec2_t *)&sprite[pPlayer->i] = r;
}
}
- for (int SPRITES_OF_SECT(s->sectnum, p))
+ for (int SPRITES_OF_SECT(pSprite->sectnum, p))
{
// KEEPINSYNC1
if (sprite[p].statnum != STAT_EFFECTOR && sprite[p].statnum != STAT_PROJECTILE)
@@ -5749,16 +5715,16 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
actor[p].bpos.x = sprite[p].x;
actor[p].bpos.y = sprite[p].y;
- if (move_rotfixed_sprite(p, j, t[2]))
+ if (move_rotfixed_sprite(p, j, pData[2]))
rotatepoint(*(vec2_t *)&sprite[j], *(vec2_t *)&sprite[p], (q * l), (vec2_t *)&sprite[p].x);
}
}
}
- else if (l==0 && (sc->floorstat&64))
+ else if (l==0 && (pSector->floorstat&64))
{
// fix for jittering of sprites in halted rotating sectors
- for (int SPRITES_OF_SECT(s->sectnum, p))
+ for (int SPRITES_OF_SECT(pSprite->sectnum, p))
{
// KEEPINSYNC1
if (sprite[p].statnum != STAT_EFFECTOR && sprite[p].statnum != STAT_PROJECTILE)
@@ -5773,20 +5739,20 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
- A_MoveSector(i);
+ A_MoveSector(spriteNum);
}
break;
case SE_1_PIVOT: //Nothing for now used as the pivot
- if (s->owner == -1) //Init
+ if (pSprite->owner == -1) //Init
{
- s->owner = i;
+ pSprite->owner = spriteNum;
for (SPRITES_OF(STAT_EFFECTOR, j))
{
- if (sprite[j].lotag == SE_19_EXPLOSION_LOWERS_CEILING && sprite[j].hitag == sh)
+ if (sprite[j].lotag == SE_19_EXPLOSION_LOWERS_CEILING && sprite[j].hitag == sectorHitag)
{
- t[0] = 0;
+ pData[0] = 0;
break;
}
}
@@ -5794,117 +5760,117 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
break;
case 6:
- k = sc->extra;
+ k = pSector->extra;
- if (t[4] > 0)
+ if (pData[4] > 0)
{
- t[4]--;
- if (t[4] >= (k-(k>>3)))
- s->xvel -= (k>>5);
- if (t[4] > ((k>>1)-1) && t[4] < (k-(k>>3)))
- s->xvel = 0;
- if (t[4] < (k>>1))
- s->xvel += (k>>5);
- if (t[4] < ((k>>1)-(k>>3)))
+ pData[4]--;
+ if (pData[4] >= (k-(k>>3)))
+ pSprite->xvel -= (k>>5);
+ if (pData[4] > ((k>>1)-1) && pData[4] < (k-(k>>3)))
+ pSprite->xvel = 0;
+ if (pData[4] < (k>>1))
+ pSprite->xvel += (k>>5);
+ if (pData[4] < ((k>>1)-(k>>3)))
{
- t[4] = 0;
- s->xvel = k;
+ pData[4] = 0;
+ pSprite->xvel = k;
}
}
- else s->xvel = k;
+ else pSprite->xvel = k;
for (SPRITES_OF(STAT_EFFECTOR, j))
{
- if (sprite[j].lotag == SE_14_SUBWAY_CAR && sh == sprite[j].hitag && actor[j].t_data[0] == t[0])
+ if (sprite[j].lotag == SE_14_SUBWAY_CAR && sectorHitag == sprite[j].hitag && actor[j].t_data[0] == pData[0])
{
- sprite[j].xvel = s->xvel;
+ sprite[j].xvel = pSprite->xvel;
// if( t[4] == 1 )
{
if (actor[j].t_data[5] == 0)
- actor[j].t_data[5] = dist(&sprite[j],s);
- x = ksgn(dist(&sprite[j],s)-actor[j].t_data[5]);
+ actor[j].t_data[5] = dist(&sprite[j],pSprite);
+ x = ksgn(dist(&sprite[j],pSprite)-actor[j].t_data[5]);
if (sprite[j].extra)
x = -x;
- s->xvel += x;
+ pSprite->xvel += x;
}
- actor[j].t_data[4] = t[4];
+ actor[j].t_data[4] = pData[4];
}
}
x = 0; // XXX: This assignment is dead?
case SE_14_SUBWAY_CAR:
- if (s->owner==-1)
- s->owner = A_FindLocator((int16_t)t[3],(int16_t)t[0]);
+ if (pSprite->owner==-1)
+ pSprite->owner = A_FindLocator((int16_t)pData[3],(int16_t)pData[0]);
- if (s->owner == -1)
+ if (pSprite->owner == -1)
{
// debugging subway cars (mapping-wise) is freakin annoying
// let's at least have a helpful message...
Bsprintf(tempbuf,"Could not find any locators in sector %d"
- " for SE# 6 or 14 with hitag %d.\n", (int)t[0], (int)t[3]);
+ " for SE# 6 or 14 with hitag %d.\n", (int)pData[0], (int)pData[3]);
G_GameExit(tempbuf);
}
- j = ldist(&sprite[s->owner],s);
+ j = ldist(&sprite[pSprite->owner],pSprite);
if (j < 1024L)
{
- if (st==SE_6_SUBWAY)
- if (sprite[s->owner].hitag&1)
- t[4]=sc->extra; //Slow it down
- t[3]++;
- s->owner = A_FindLocator(t[3],t[0]);
- if (s->owner==-1)
+ if (sectorLotag==SE_6_SUBWAY)
+ if (sprite[pSprite->owner].hitag&1)
+ pData[4]=pSector->extra; //Slow it down
+ pData[3]++;
+ pSprite->owner = A_FindLocator(pData[3],pData[0]);
+ if (pSprite->owner==-1)
{
- t[3]=0;
- s->owner = A_FindLocator(0,t[0]);
+ pData[3]=0;
+ pSprite->owner = A_FindLocator(0,pData[0]);
}
}
- if (s->xvel)
+ if (pSprite->xvel)
{
int32_t p;
#ifdef YAX_ENABLE
int32_t firstrun = 1;
#endif
- x = getangle(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y);
- q = G_GetAngleDelta(s->ang,x)>>3;
+ x = getangle(sprite[pSprite->owner].x-pSprite->x,sprite[pSprite->owner].y-pSprite->y);
+ q = G_GetAngleDelta(pSprite->ang,x)>>3;
- t[2] += q;
- s->ang += q;
+ pData[2] += q;
+ pSprite->ang += q;
- if (s->xvel == sc->extra)
+ if (pSprite->xvel == pSector->extra)
{
- if ((sc->floorstat&1) == 0 && (sc->ceilingstat&1) == 0)
+ if ((pSector->floorstat&1) == 0 && (pSector->ceilingstat&1) == 0)
{
- if (!S_CheckSoundPlaying(i,actor[i].lastvx))
- A_PlaySound(actor[i].lastvx,i);
+ if (!S_CheckSoundPlaying(spriteNum,actor[spriteNum].lastvx))
+ A_PlaySound(actor[spriteNum].lastvx,spriteNum);
}
- else if (ud.monsters_off == 0 && sc->floorpal == 0 && (sc->floorstat&1) && rnd(8))
+ else if (ud.monsters_off == 0 && pSector->floorpal == 0 && (pSector->floorstat&1) && rnd(8))
{
- p = A_FindPlayer(s,&x);
+ p = A_FindPlayer(pSprite,&x);
if (x < 20480)
{
- j = s->ang;
- s->ang = getangle(s->x-g_player[p].ps->pos.x,s->y-g_player[p].ps->pos.y);
- A_Shoot(i,RPG);
- s->ang = j;
+ j = pSprite->ang;
+ pSprite->ang = getangle(pSprite->x-g_player[p].ps->pos.x,pSprite->y-g_player[p].ps->pos.y);
+ A_Shoot(spriteNum,RPG);
+ pSprite->ang = j;
}
}
}
- if (s->xvel <= 64 && (sc->floorstat&1) == 0 && (sc->ceilingstat&1) == 0)
- S_StopEnvSound(actor[i].lastvx,i);
+ if (pSprite->xvel <= 64 && (pSector->floorstat&1) == 0 && (pSector->ceilingstat&1) == 0)
+ S_StopEnvSound(actor[spriteNum].lastvx,spriteNum);
- if ((sc->floorz-sc->ceilingz) < (108<<8))
+ if ((pSector->floorz-pSector->ceilingz) < (108<<8))
{
- if (ud.noclip == 0 && s->xvel >= 192)
- MaybeTrainKillPlayer(s, 0);
+ if (ud.noclip == 0 && pSprite->xvel >= 192)
+ MaybeTrainKillPlayer(pSprite, 0);
}
- m = (s->xvel*sintable[(s->ang+512)&2047])>>14;
- x = (s->xvel*sintable[s->ang&2047])>>14;
+ m = (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14;
+ x = (pSprite->xvel*sintable[pSprite->ang&2047])>>14;
for (TRAVERSE_CONNECT(p))
{
@@ -5919,19 +5885,19 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
if (sector[ps->cursectnum].lotag != ST_2_UNDERWATER)
{
- if (g_playerSpawnPoints[p].sect == s->sectnum)
+ if (g_playerSpawnPoints[p].sect == pSprite->sectnum)
{
g_playerSpawnPoints[p].pos.x += m;
g_playerSpawnPoints[p].pos.y += x;
}
- if (s->sectnum == sprite[ps->i].sectnum
+ if (pSprite->sectnum == sprite[ps->i].sectnum
#ifdef YAX_ENABLE
- || (t[9]>=0 && t[9] == sprite[ps->i].sectnum)
+ || (pData[9]>=0 && pData[9] == sprite[ps->i].sectnum)
#endif
)
{
- rotatepoint(*(vec2_t *)s, *(vec2_t *)&ps->pos, q, (vec2_t *)&ps->pos);
+ rotatepoint(*(vec2_t *)pSprite, *(vec2_t *)&ps->pos, q, (vec2_t *)&ps->pos);
ps->pos.x += m;
ps->pos.y += x;
@@ -5957,7 +5923,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
// NOTE: special loop handling
- j = headspritesect[s->sectnum];
+ j = headspritesect[pSprite->sectnum];
while (j >= 0)
{
// KEEPINSYNC2
@@ -5973,8 +5939,8 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
actor[j].bpos.y = sprite[j].y;
}
- if (move_rotfixed_sprite(j, s-sprite, t[2]))
- rotatepoint(*(vec2_t *)s,*(vec2_t *)&sprite[j],q,(vec2_t *)&sprite[j].x);
+ if (move_rotfixed_sprite(j, pSprite-sprite, pData[2]))
+ rotatepoint(*(vec2_t *)pSprite,*(vec2_t *)&sprite[j],q,(vec2_t *)&sprite[j].x);
sprite[j].x+= m;
sprite[j].y+= x;
@@ -5991,30 +5957,30 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
#ifdef YAX_ENABLE
if (j < 0)
{
- if (t[9]>=0 && firstrun)
+ if (pData[9]>=0 && firstrun)
{
firstrun = 0;
- j = headspritesect[t[9]];
+ j = headspritesect[pData[9]];
}
}
#endif
}
- A_MoveSector(i);
- setsprite(i,(vec3_t *)s);
+ A_MoveSector(spriteNum);
+ setsprite(spriteNum,(vec3_t *)pSprite);
- if ((sc->floorz-sc->ceilingz) < (108<<8))
+ if ((pSector->floorz-pSector->ceilingz) < (108<<8))
{
- if (ud.noclip == 0 && s->xvel >= 192)
- MaybeTrainKillPlayer(s, 1);
+ if (ud.noclip == 0 && pSprite->xvel >= 192)
+ MaybeTrainKillPlayer(pSprite, 1);
- MaybeTrainKillEnemies(i, 72);
+ MaybeTrainKillEnemies(spriteNum, 72);
}
}
else
{
// fix for jittering of sprites in halted subways
- for (SPRITES_OF_SECT(s->sectnum, j))
+ for (SPRITES_OF_SECT(pSprite->sectnum, j))
{
// KEEPINSYNC2
if (sprite[j].statnum != STAT_PLAYER && sector[sprite[j].sectnum].lotag != ST_2_UNDERWATER &&
@@ -6030,45 +5996,45 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
break;
case SE_30_TWO_WAY_TRAIN:
- if (s->owner == -1)
+ if (pSprite->owner == -1)
{
- t[3] = !t[3];
- s->owner = A_FindLocator(t[3],t[0]);
+ pData[3] = !pData[3];
+ pSprite->owner = A_FindLocator(pData[3],pData[0]);
}
else
{
- if (t[4] == 1) // Starting to go
+ if (pData[4] == 1) // Starting to go
{
- if (ldist(&sprite[s->owner],s) < (2048-128))
- t[4] = 2;
+ if (ldist(&sprite[pSprite->owner],pSprite) < (2048-128))
+ pData[4] = 2;
else
{
- if (s->xvel == 0)
- G_OperateActivators(s->hitag+(!t[3]),-1);
- if (s->xvel < 256)
- s->xvel += 16;
+ if (pSprite->xvel == 0)
+ G_OperateActivators(pSprite->hitag+(!pData[3]),-1);
+ if (pSprite->xvel < 256)
+ pSprite->xvel += 16;
}
}
- if (t[4] == 2)
+ if (pData[4] == 2)
{
- l = FindDistance2D(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y);
+ l = FindDistance2D(sprite[pSprite->owner].x-pSprite->x,sprite[pSprite->owner].y-pSprite->y);
if (l <= 128)
- s->xvel = 0;
+ pSprite->xvel = 0;
- if (s->xvel > 0)
- s->xvel -= 16;
+ if (pSprite->xvel > 0)
+ pSprite->xvel -= 16;
else
{
- s->xvel = 0;
- G_OperateActivators(s->hitag+(int16_t)t[3],-1);
- s->owner = -1;
- s->ang += 1024;
- t[4] = 0;
- G_OperateForceFields(i,s->hitag);
+ pSprite->xvel = 0;
+ G_OperateActivators(pSprite->hitag+(int16_t)pData[3],-1);
+ pSprite->owner = -1;
+ pSprite->ang += 1024;
+ pData[4] = 0;
+ G_OperateForceFields(spriteNum,pSprite->hitag);
- for (SPRITES_OF_SECT(s->sectnum, j))
+ for (SPRITES_OF_SECT(pSprite->sectnum, j))
{
if (sprite[j].picnum != SECTOREFFECTOR && sprite[j].picnum != LOCATORS)
{
@@ -6081,22 +6047,22 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
- if (s->xvel)
+ if (pSprite->xvel)
{
int32_t p;
- l = (s->xvel*sintable[(s->ang+512)&2047])>>14;
- x = (s->xvel*sintable[s->ang&2047])>>14;
+ l = (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14;
+ x = (pSprite->xvel*sintable[pSprite->ang&2047])>>14;
- if ((sc->floorz-sc->ceilingz) < (108<<8))
+ if ((pSector->floorz-pSector->ceilingz) < (108<<8))
if (ud.noclip == 0)
- MaybeTrainKillPlayer(s, 0);
+ MaybeTrainKillPlayer(pSprite, 0);
for (TRAVERSE_CONNECT(p))
{
DukePlayer_t *const ps = g_player[p].ps;
- if (sprite[ps->i].sectnum == s->sectnum)
+ if (sprite[ps->i].sectnum == pSprite->sectnum)
{
ps->pos.x += l;
ps->pos.y += x;
@@ -6111,14 +6077,14 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
ps->bobpos.y += x;
}
- if (g_playerSpawnPoints[p].sect == s->sectnum)
+ if (g_playerSpawnPoints[p].sect == pSprite->sectnum)
{
g_playerSpawnPoints[p].pos.x += l;
g_playerSpawnPoints[p].pos.y += x;
}
}
- for (SPRITES_OF_SECT(s->sectnum, j))
+ for (SPRITES_OF_SECT(pSprite->sectnum, j))
{
// TODO: replace some checks for SE 49/50 with statnum LIGHT instead?
if ((sprite[j].picnum != SECTOREFFECTOR || sprite[j].lotag==SE_49_POINT_LIGHT || sprite[j].lotag==SE_50_SPOT_LIGHT)
@@ -6141,15 +6107,15 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
- A_MoveSector(i);
- setsprite(i,(vec3_t *)s);
+ A_MoveSector(spriteNum);
+ setsprite(spriteNum,(vec3_t *)pSprite);
- if (sc->floorz-sc->ceilingz < (108<<8))
+ if (pSector->floorz-pSector->ceilingz < (108<<8))
{
if (ud.noclip == 0)
- MaybeTrainKillPlayer(s, 1);
+ MaybeTrainKillPlayer(pSprite, 1);
- MaybeTrainKillEnemies(i, 24);
+ MaybeTrainKillEnemies(spriteNum, 24);
}
}
@@ -6157,49 +6123,49 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
case SE_2_EARTHQUAKE://Quakes
- if (t[4] > 0 && t[0] == 0)
+ if (pData[4] > 0 && pData[0] == 0)
{
- if (t[4] < sh)
- t[4]++;
- else t[0] = 1;
+ if (pData[4] < sectorHitag)
+ pData[4]++;
+ else pData[0] = 1;
}
- if (t[0] > 0)
+ if (pData[0] > 0)
{
int32_t p, nextj;
- t[0]++;
+ pData[0]++;
- s->xvel = 3;
+ pSprite->xvel = 3;
- if (t[0] > 96)
+ if (pData[0] > 96)
{
- t[0] = -1; //Stop the quake
- t[4] = -1;
- KILLIT(i);
+ pData[0] = -1; //Stop the quake
+ pData[4] = -1;
+ KILLIT(spriteNum);
}
else
{
- if ((t[0]&31) == 8)
+ if ((pData[0]&31) == 8)
{
g_earthquakeTime = 48;
A_PlaySound(EARTHQUAKE,g_player[screenpeek].ps->i);
}
- if (klabs(sc->floorheinum-t[5]) < 8)
- sc->floorheinum = t[5];
- else sc->floorheinum += (ksgn(t[5]-sc->floorheinum)<<4);
+ if (klabs(pSector->floorheinum-pData[5]) < 8)
+ pSector->floorheinum = pData[5];
+ else pSector->floorheinum += (ksgn(pData[5]-pSector->floorheinum)<<4);
}
- m = (s->xvel*sintable[(s->ang+512)&2047])>>14;
- x = (s->xvel*sintable[s->ang&2047])>>14;
+ m = (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14;
+ x = (pSprite->xvel*sintable[pSprite->ang&2047])>>14;
for (TRAVERSE_CONNECT(p))
{
DukePlayer_t *const ps = g_player[p].ps;
- if (ps->cursectnum == s->sectnum && ps->on_ground)
+ if (ps->cursectnum == pSprite->sectnum && ps->on_ground)
{
ps->pos.x += m;
ps->pos.y += x;
@@ -6209,7 +6175,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
- for (SPRITES_OF_SECT_SAFE(s->sectnum, j, nextj))
+ for (SPRITES_OF_SECT_SAFE(pSprite->sectnum, j, nextj))
{
if (sprite[j].picnum != SECTOREFFECTOR)
{
@@ -6219,8 +6185,8 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
- A_MoveSector(i);
- setsprite(i,(vec3_t *)s);
+ A_MoveSector(spriteNum);
+ setsprite(spriteNum,(vec3_t *)pSprite);
}
break;
@@ -6228,38 +6194,38 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT:
{
- if (t[4] == 0) break;
+ if (pData[4] == 0) break;
// if(t[5] > 0) { t[5]--; break; }
- if ((tabledivide32_noinline(g_globalRandom, sh+1)&31) < 4 && !t[2])
+ if ((tabledivide32_noinline(g_globalRandom, sectorHitag+1)&31) < 4 && !pData[2])
{
// t[5] = 4+(g_globalRandom&7);
- sc->ceilingpal = s->owner>>8;
- sc->floorpal = s->owner&0xff;
- t[0] = s->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);
- sc->ceilingpal = s->pal;
- sc->floorpal = s->pal;
- t[0] = t[3];
+ pSector->ceilingpal = pSprite->pal;
+ pSector->floorpal = pSprite->pal;
+ pData[0] = pData[3];
}
- sc->ceilingshade = t[0];
- sc->floorshade = t[0];
+ pSector->ceilingshade = pData[0];
+ pSector->floorshade = pData[0];
- wal = &wall[sc->wallptr];
+ walltype *pWall = &wall[pSector->wallptr];
- for (x=sc->wallnum; x > 0; x--,wal++)
+ for (x=pSector->wallnum; x > 0; x--,pWall++)
{
- if (wal->hitag != 1)
+ if (pWall->hitag != 1)
{
- wal->shade = t[0];
- if ((wal->cstat&2) && wal->nextwall >= 0)
+ pWall->shade = pData[0];
+ if ((pWall->cstat&2) && pWall->nextwall >= 0)
{
- wall[wal->nextwall].shade = wal->shade;
+ wall[pWall->nextwall].shade = pWall->shade;
}
}
}
@@ -6274,55 +6240,55 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
// t[2]: original floor shade
// t[3]: max wall shade
- if ((tabledivide32_noinline(g_globalRandom, sh+1)&31) < 4)
+ if ((tabledivide32_noinline(g_globalRandom, sectorHitag+1)&31) < 4)
{
- t[1] = s->shade + (g_globalRandom&15);//Got really bright
- t[0] = s->shade + (g_globalRandom&15);
- sc->ceilingpal = s->owner>>8;
- sc->floorpal = s->owner&0xff;
+ 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;
}
else
{
- t[1] = t[2];
- t[0] = t[3];
+ pData[1] = pData[2];
+ pData[0] = pData[3];
- sc->ceilingpal = s->pal;
- sc->floorpal = s->pal;
+ pSector->ceilingpal = pSprite->pal;
+ pSector->floorpal = pSprite->pal;
j = 0;
}
- sc->floorshade = t[1];
- sc->ceilingshade = t[1];
+ pSector->floorshade = pData[1];
+ pSector->ceilingshade = pData[1];
- wal = &wall[sc->wallptr];
+ walltype *pWall = &wall[pSector->wallptr];
- for (x=sc->wallnum; x > 0; x--,wal++)
+ for (x=pSector->wallnum; x > 0; x--,pWall++)
{
- if (j) wal->pal = (s->owner&0xff);
- else wal->pal = s->pal;
+ if (j) pWall->pal = (pSprite->owner&0xff);
+ else pWall->pal = pSprite->pal;
- if (wal->hitag != 1)
+ if (pWall->hitag != 1)
{
- wal->shade = t[0];
- if ((wal->cstat&2) && wal->nextwall >= 0)
- wall[wal->nextwall].shade = wal->shade;
+ pWall->shade = pData[0];
+ if ((pWall->cstat&2) && pWall->nextwall >= 0)
+ wall[pWall->nextwall].shade = pWall->shade;
}
}
- for (SPRITES_OF_SECT(SECT, j))
+ for (SPRITES_OF_SECT(SECT(spriteNum), j))
{
if (sprite[j].cstat&16 && A_CheckSpriteFlags(j,SFLAG_NOSHADE) == 0)
{
- if (sc->ceilingstat&1)
- sprite[j].shade = sc->ceilingshade;
- else sprite[j].shade = sc->floorshade;
+ if (pSector->ceilingstat&1)
+ sprite[j].shade = pSector->ceilingshade;
+ else sprite[j].shade = pSector->floorshade;
}
}
- if (t[4])
- KILLIT(i);
+ if (pData[4])
+ KILLIT(spriteNum);
break;
}
@@ -6330,83 +6296,83 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
//BOSS
case SE_5:
{
- const int32_t p = A_FindPlayer(s,&x);
+ const int32_t p = A_FindPlayer(pSprite,&x);
DukePlayer_t *const ps = g_player[p].ps;
if (x < 8192)
{
- j = s->ang;
- s->ang = getangle(s->x-ps->pos.x,s->y-ps->pos.y);
- A_Shoot(i,FIRELASER);
- s->ang = j;
+ j = pSprite->ang;
+ pSprite->ang = getangle(pSprite->x-ps->pos.x,pSprite->y-ps->pos.y);
+ A_Shoot(spriteNum,FIRELASER);
+ pSprite->ang = j;
}
- if (s->owner==-1) //Start search
+ if (pSprite->owner==-1) //Start search
{
- t[4]=0;
+ pData[4]=0;
l = INT32_MAX;
while (1) //Find the shortest dist
{
- s->owner = A_FindLocator((int16_t)t[4],-1); //t[0] hold sectnum
+ pSprite->owner = A_FindLocator((int16_t)pData[4],-1); //t[0] hold sectnum
- if (s->owner==-1) break;
+ if (pSprite->owner==-1) break;
- m = ldist(&sprite[ps->i],&sprite[s->owner]);
+ m = ldist(&sprite[ps->i],&sprite[pSprite->owner]);
if (l > m)
{
- q = s->owner;
+ q = pSprite->owner;
l = m;
}
- t[4]++;
+ pData[4]++;
}
- s->owner = q;
- s->zvel = ksgn(sprite[q].z-s->z)<<4;
+ pSprite->owner = q;
+ pSprite->zvel = ksgn(sprite[q].z-pSprite->z)<<4;
}
- if (ldist(&sprite[s->owner],s) < 1024)
+ if (ldist(&sprite[pSprite->owner],pSprite) < 1024)
{
int16_t ta;
- ta = s->ang;
- s->ang = getangle(ps->pos.x-s->x,ps->pos.y-s->y);
- s->ang = ta;
- s->owner = -1;
- goto BOLT;
+ ta = pSprite->ang;
+ pSprite->ang = getangle(ps->pos.x-pSprite->x,ps->pos.y-pSprite->y);
+ pSprite->ang = ta;
+ pSprite->owner = -1;
+ goto next_sprite;
}
- else s->xvel=256;
+ else pSprite->xvel=256;
- x = getangle(sprite[s->owner].x-s->x,sprite[s->owner].y-s->y);
- q = G_GetAngleDelta(s->ang,x)>>3;
- s->ang += q;
+ x = getangle(sprite[pSprite->owner].x-pSprite->x,sprite[pSprite->owner].y-pSprite->y);
+ q = G_GetAngleDelta(pSprite->ang,x)>>3;
+ pSprite->ang += q;
if (rnd(32))
{
- t[2]+=q;
- sc->ceilingshade = 127;
+ pData[2]+=q;
+ pSector->ceilingshade = 127;
}
else
{
- t[2] += G_GetAngleDelta(t[2]+512,getangle(ps->pos.x-s->x,ps->pos.y-s->y))>>2;
- sc->ceilingshade = 0;
+ pData[2] += G_GetAngleDelta(pData[2]+512,getangle(ps->pos.x-pSprite->x,ps->pos.y-pSprite->y))>>2;
+ pSector->ceilingshade = 0;
}
- if (A_IncurDamage(i) >= 0)
+ if (A_IncurDamage(spriteNum) >= 0)
{
- if (++t[3] == 5)
+ if (++pData[3] == 5)
{
- s->zvel += 1024;
+ pSprite->zvel += 1024;
P_DoQuote(QUOTE_WASTED, g_player[myconnectindex].ps);
}
}
- s->z += s->zvel;
- sc->ceilingz += s->zvel;
- sector[t[0]].ceilingz += s->zvel;
- A_MoveSector(i);
- setsprite(i,(vec3_t *)s);
+ pSprite->z += pSprite->zvel;
+ pSector->ceilingz += pSprite->zvel;
+ sector[pData[0]].ceilingz += pSprite->zvel;
+ A_MoveSector(spriteNum);
+ setsprite(spriteNum,(vec3_t *)pSprite);
break;
}
@@ -6417,49 +6383,49 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
j = -1;
- if (actor[i].t_data[4])
+ if (actor[spriteNum].t_data[4])
{
- actor[i].t_data[4]++;
- if (actor[i].t_data[4] > 8)
- KILLIT(i);
+ actor[spriteNum].t_data[4]++;
+ if (actor[spriteNum].t_data[4] > 8)
+ KILLIT(spriteNum);
j = 1;
}
- else j = GetAnimationGoal(&sc->ceilingz);
+ else j = GetAnimationGoal(&pSector->ceilingz);
if (j >= 0)
{
- if ((sc->lotag&0x8000) || actor[i].t_data[4])
- x = -t[3];
+ if ((pSector->lotag&0x8000) || actor[spriteNum].t_data[4])
+ x = -pData[3];
else
- x = t[3];
+ x = pData[3];
- if (st == SE_9_DOWN_OPEN_DOOR_LIGHTS)
+ if (sectorLotag == SE_9_DOWN_OPEN_DOOR_LIGHTS)
x = -x;
for (SPRITES_OF(STAT_EFFECTOR, j))
{
- if (sprite[j].lotag == st && sprite[j].hitag == sh)
+ if (sprite[j].lotag == sectorLotag && sprite[j].hitag == sectorHitag)
{
int32_t sn = sprite[j].sectnum;
m = sprite[j].shade;
- wal = &wall[sector[sn].wallptr];
+ walltype *pWall = &wall[sector[sn].wallptr];
- for (l=sector[sn].wallnum; l>0; l--,wal++)
+ for (l=sector[sn].wallnum; l>0; l--,pWall++)
{
- if (wal->hitag != 1)
+ if (pWall->hitag != 1)
{
- wal->shade+=x;
+ pWall->shade+=x;
- if (wal->shade < m)
- wal->shade = m;
- else if (wal->shade > actor[j].t_data[2])
- wal->shade = actor[j].t_data[2];
+ if (pWall->shade < m)
+ pWall->shade = m;
+ else if (pWall->shade > actor[j].t_data[2])
+ pWall->shade = actor[j].t_data[2];
- if (wal->nextwall >= 0)
- if (wall[wal->nextwall].hitag != 1)
- wall[wal->nextwall].shade = wal->shade;
+ if (pWall->nextwall >= 0)
+ if (wall[pWall->nextwall].hitag != 1)
+ wall[pWall->nextwall].shade = pWall->shade;
}
}
@@ -6483,151 +6449,151 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
case SE_10_DOOR_AUTO_CLOSE:
// XXX: 32791, what the hell?
- if ((sc->lotag&0xff) == ST_27_STRETCH_BRIDGE || (sc->floorz > sc->ceilingz && (sc->lotag&0xff) != ST_23_SWINGING_DOOR) || sc->lotag == 32791)
+ 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 ((sc->lotag&0xff) != ST_27_STRETCH_BRIDGE)
+ if ((pSector->lotag&0xff) != ST_27_STRETCH_BRIDGE)
for (TRAVERSE_CONNECT(p))
- if (sc->lotag != ST_30_ROTATE_RISE_BRIDGE && sc->lotag != ST_31_TWO_WAY_TRAIN && sc->lotag != 0)
- if (s->sectnum == sprite[g_player[p].ps->i].sectnum)
+ 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;
if (j == 1)
{
- if (t[0] > sh)
- switch (sector[s->sectnum].lotag)
+ if (pData[0] > sectorHitag)
+ switch (sector[pSprite->sectnum].lotag)
{
case ST_20_CEILING_DOOR:
case ST_21_FLOOR_DOOR:
case ST_22_SPLITTING_DOOR:
case ST_26_SPLITTING_ST_DOOR:
- if (GetAnimationGoal(§or[s->sectnum].ceilingz) >= 0)
+ if (GetAnimationGoal(§or[pSprite->sectnum].ceilingz) >= 0)
break;
default:
- G_ActivateBySector(s->sectnum,i);
- t[0] = 0;
+ G_ActivateBySector(pSprite->sectnum,spriteNum);
+ pData[0] = 0;
break;
}
- else t[0]++;
+ else pData[0]++;
}
}
- else t[0]=0;
+ else pData[0]=0;
break;
case SE_11_SWINGING_DOOR: //Swingdoor
- if (t[5] > 0)
+ if (pData[5] > 0)
{
- t[5]--;
+ pData[5]--;
break;
}
- if (t[4])
+ if (pData[4])
{
- int32_t endwall = sc->wallptr+sc->wallnum;
+ int32_t endwall = pSector->wallptr+pSector->wallnum;
- for (j=sc->wallptr; jwallptr; j 0 && A_CheckEnemySprite(&sprite[k])
&& clipinsidebox((vec2_t *)&sprite[k], j, 256) == 1)
- goto BOLT;
+ goto next_sprite;
}
for (SPRITES_OF(STAT_PLAYER, k))
{
if (sprite[k].owner >= 0 && clipinsidebox((vec2_t *)&sprite[k], j, 144) == 1)
{
- t[5] = 8; // Delay
- k = (SP>>3)*t[3];
- t[2] -= k;
- t[4] -= k;
- A_MoveSector(i);
- setsprite(i,(vec3_t *)s);
- goto BOLT;
+ pData[5] = 8; // Delay
+ k = (SP(spriteNum)>>3)*pData[3];
+ pData[2] -= k;
+ pData[4] -= k;
+ A_MoveSector(spriteNum);
+ setsprite(spriteNum,(vec3_t *)pSprite);
+ goto next_sprite;
}
}
}
- k = (SP>>3)*t[3];
- t[2]+=k;
- t[4]+=k;
- A_MoveSector(i);
- setsprite(i,(vec3_t *)s);
+ k = (SP(spriteNum)>>3)*pData[3];
+ pData[2]+=k;
+ pData[4]+=k;
+ A_MoveSector(spriteNum);
+ setsprite(spriteNum,(vec3_t *)pSprite);
- if (t[4] <= -511 || t[4] >= 512)
+ if (pData[4] <= -511 || pData[4] >= 512)
{
- t[4] = 0;
- t[2] &= 0xffffff00;
- A_MoveSector(i);
- setsprite(i,(vec3_t *)s);
+ pData[4] = 0;
+ pData[2] &= 0xffffff00;
+ A_MoveSector(spriteNum);
+ setsprite(spriteNum,(vec3_t *)pSprite);
break;
}
}
break;
case SE_12_LIGHT_SWITCH:
- if (t[0] == 3 || t[3] == 1) //Lights going off
+ if (pData[0] == 3 || pData[3] == 1) //Lights going off
{
- sc->floorpal = 0;
- sc->ceilingpal = 0;
+ pSector->floorpal = 0;
+ pSector->ceilingpal = 0;
- wal = &wall[sc->wallptr];
- for (j = sc->wallnum; j > 0; j--, wal++)
- if (wal->hitag != 1)
+ walltype *pWall = &wall[pSector->wallptr];
+ for (j = pSector->wallnum; j > 0; j--, pWall++)
+ if (pWall->hitag != 1)
{
- wal->shade = t[1];
- wal->pal = 0;
+ pWall->shade = pData[1];
+ pWall->pal = 0;
}
- sc->floorshade = t[1];
- sc->ceilingshade = t[2];
- t[0]=0;
+ pSector->floorshade = pData[1];
+ pSector->ceilingshade = pData[2];
+ pData[0]=0;
- for (SPRITES_OF_SECT(SECT, j))
+ for (SPRITES_OF_SECT(SECT(spriteNum), j))
{
if (sprite[j].cstat&16 && A_CheckSpriteFlags(j,SFLAG_NOSHADE) == 0)
{
- if (sc->ceilingstat&1)
- sprite[j].shade = sc->ceilingshade;
- else sprite[j].shade = sc->floorshade;
+ if (pSector->ceilingstat&1)
+ sprite[j].shade = pSector->ceilingshade;
+ else sprite[j].shade = pSector->floorshade;
}
}
- if (t[3] == 1)
- KILLIT(i);
+ if (pData[3] == 1)
+ KILLIT(spriteNum);
}
- if (t[0] == 1) //Lights flickering on
+ if (pData[0] == 1) //Lights flickering on
{
- if (sc->floorshade > s->shade)
+ if (pSector->floorshade > pSprite->shade)
{
- sc->floorpal = s->pal;
- sc->ceilingpal = s->pal;
+ pSector->floorpal = pSprite->pal;
+ pSector->ceilingpal = pSprite->pal;
- sc->floorshade -= 2;
- sc->ceilingshade -= 2;
+ pSector->floorshade -= 2;
+ pSector->ceilingshade -= 2;
- wal = &wall[sc->wallptr];
- for (j=sc->wallnum; j>0; j--,wal++)
- if (wal->hitag != 1)
+ walltype *pWall = &wall[pSector->wallptr];
+ for (j=pSector->wallnum; j>0; j--,pWall++)
+ if (pWall->hitag != 1)
{
- wal->pal = s->pal;
- wal->shade -= 2;
+ pWall->pal = pSprite->pal;
+ pWall->shade -= 2;
}
}
- else t[0] = 2;
+ else pData[0] = 2;
- for (SPRITES_OF_SECT(SECT, j))
+ for (SPRITES_OF_SECT(SECT(spriteNum), j))
{
if (sprite[j].cstat&16)
{
- if (sc->ceilingstat&1 && A_CheckSpriteFlags(j,SFLAG_NOSHADE) == 0)
- sprite[j].shade = sc->ceilingshade;
- else sprite[j].shade = sc->floorshade;
+ if (pSector->ceilingstat&1 && A_CheckSpriteFlags(j,SFLAG_NOSHADE) == 0)
+ sprite[j].shade = pSector->ceilingshade;
+ else sprite[j].shade = pSector->floorshade;
}
}
}
@@ -6635,44 +6601,44 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
case SE_13_EXPLOSIVE:
- if (t[2])
+ if (pData[2])
{
// t[0]: ceiling z
// t[1]: floor z
// s->owner: 1 if affect ceiling, 0 if affect floor
// t[3]: 1 if ceiling was parallaxed at premap, 0 else
- j = (SP<<5)|1;
+ j = (SP(spriteNum)<<5)|1;
- if (s->ang == 512)
+ if (pSprite->ang == 512)
{
- if (s->owner)
+ if (pSprite->owner)
{
- if (klabs(t[0]-sc->ceilingz) >= j)
- sc->ceilingz += ksgn(t[0]-sc->ceilingz)*j;
- else sc->ceilingz = t[0];
+ if (klabs(pData[0]-pSector->ceilingz) >= j)
+ pSector->ceilingz += ksgn(pData[0]-pSector->ceilingz)*j;
+ else pSector->ceilingz = pData[0];
}
else
{
- if (klabs(t[1]-sc->floorz) >= j)
- sc->floorz += ksgn(t[1]-sc->floorz)*j;
- else sc->floorz = t[1];
+ if (klabs(pData[1]-pSector->floorz) >= j)
+ pSector->floorz += ksgn(pData[1]-pSector->floorz)*j;
+ else pSector->floorz = pData[1];
}
}
else
{
- if (klabs(t[1]-sc->floorz) >= j)
- sc->floorz += ksgn(t[1]-sc->floorz)*j;
- else sc->floorz = t[1];
- if (klabs(t[0]-sc->ceilingz) >= j)
- sc->ceilingz += ksgn(t[0]-sc->ceilingz)*j;
- sc->ceilingz = t[0];
+ 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];
}
#ifdef YAX_ENABLE
- if (s->ang == 512)
+ if (pSprite->ang == 512)
{
- int16_t cf=!s->owner, bn=yax_getbunch(sc-sector, cf);
- int32_t jj, daz=SECTORFLD(sc-sector,z, cf);
+ int16_t cf=!pSprite->owner, bn=yax_getbunch(pSector-sector, cf);
+ int32_t jj, daz=SECTORFLD(pSector-sector,z, cf);
if (bn >= 0)
{
@@ -6689,79 +6655,79 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
#endif
- if (t[3] == 1)
+ if (pData[3] == 1)
{
//Change the shades
- t[3]++;
- sc->ceilingstat ^= 1;
+ pData[3]++;
+ pSector->ceilingstat ^= 1;
- if (s->ang == 512)
+ if (pSprite->ang == 512)
{
- wal = &wall[sc->wallptr];
- for (j=sc->wallnum; j>0; j--,wal++)
- wal->shade = s->shade;
+ walltype *pWall = &wall[pSector->wallptr];
+ for (j=pSector->wallnum; j>0; j--,pWall++)
+ pWall->shade = pSprite->shade;
- sc->floorshade = s->shade;
+ pSector->floorshade = pSprite->shade;
if (g_player[0].ps->one_parallax_sectnum >= 0)
{
- sc->ceilingpicnum =
+ pSector->ceilingpicnum =
sector[g_player[0].ps->one_parallax_sectnum].ceilingpicnum;
- sc->ceilingshade =
+ pSector->ceilingshade =
sector[g_player[0].ps->one_parallax_sectnum].ceilingshade;
}
}
}
- t[2]++;
- if (t[2] > 256)
- KILLIT(i);
+ pData[2]++;
+ if (pData[2] > 256)
+ KILLIT(spriteNum);
}
- if (t[2] == 4 && s->ang != 512)
- for (x=0; x<7; x++) RANDOMSCRAP;
+ if (pData[2] == 4 && pSprite->ang != 512)
+ for (x=0; x<7; x++) RANDOMSCRAP(pSprite, spriteNum);
break;
case SE_15_SLIDING_DOOR:
- if (t[4])
+ if (pData[4])
{
- s->xvel = 16;
+ pSprite->xvel = 16;
- if (t[4] == 1) //Opening
+ if (pData[4] == 1) //Opening
{
- if (t[3] >= (SP>>3))
+ if (pData[3] >= (SP(spriteNum)>>3))
{
- t[4] = 0; //Turn off the sliders
- A_CallSound(s->sectnum,i);
+ pData[4] = 0; //Turn off the sliders
+ A_CallSound(pSprite->sectnum,spriteNum);
break;
}
- t[3]++;
+ pData[3]++;
}
- else if (t[4] == 2)
+ else if (pData[4] == 2)
{
- if (t[3]<1)
+ if (pData[3]<1)
{
- t[4] = 0;
- A_CallSound(s->sectnum,i);
+ pData[4] = 0;
+ A_CallSound(pSprite->sectnum,spriteNum);
break;
}
- t[3]--;
+ pData[3]--;
}
- A_MoveSector(i);
- setsprite(i,(vec3_t *)s);
+ A_MoveSector(spriteNum);
+ setsprite(spriteNum,(vec3_t *)pSprite);
}
break;
case SE_16_REACTOR: //Reactor
- t[2]+=32;
- if (sc->floorzceilingz) s->shade=0;
+ pData[2]+=32;
+ if (pSector->floorzceilingz) pSprite->shade=0;
- else if (sc->ceilingz < t[3])
+ else if (pSector->ceilingz < pData[3])
{
//The following code check to see if
@@ -6769,23 +6735,23 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
//If there isn't, then kill this sectoreffector
//itself.....
- for (SPRITES_OF_SECT(s->sectnum, j))
+ for (SPRITES_OF_SECT(pSprite->sectnum, j))
{
if (sprite[j].picnum == REACTOR || sprite[j].picnum == REACTOR2)
break;
}
if (j == -1)
- KILLIT(i);
+ KILLIT(spriteNum);
- s->shade = 1;
+ pSprite->shade = 1;
}
- if (s->shade) sc->ceilingz+=1024;
- else sc->ceilingz-=512;
+ if (pSprite->shade) pSector->ceilingz+=1024;
+ else pSector->ceilingz-=512;
- A_MoveSector(i);
- setsprite(i,(vec3_t *)s);
+ A_MoveSector(spriteNum);
+ setsprite(spriteNum,(vec3_t *)pSprite);
break;
@@ -6793,12 +6759,12 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
{
int32_t nextk;
- q = t[0]*(SP<<2);
+ q = pData[0]*(SP(spriteNum)<<2);
- sc->ceilingz += q;
- sc->floorz += q;
+ pSector->ceilingz += q;
+ pSector->floorz += q;
- for (SPRITES_OF_SECT(s->sectnum, j))
+ for (SPRITES_OF_SECT(pSprite->sectnum, j))
{
if (sprite[j].statnum == STAT_PLAYER && sprite[j].owner >= 0)
{
@@ -6821,50 +6787,50 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
sprite[j].z += q;
}
- actor[j].floorz = sc->floorz;
- actor[j].ceilingz = sc->ceilingz;
+ actor[j].floorz = pSector->floorz;
+ actor[j].ceilingz = pSector->ceilingz;
}
- if (t[0]) //If in motion
+ if (pData[0]) //If in motion
{
- if (klabs(sc->floorz-t[2]) <= SP)
+ if (klabs(pSector->floorz-pData[2]) <= SP(spriteNum))
{
- G_ActivateWarpElevators(i,0);
+ G_ActivateWarpElevators(spriteNum,0);
break;
}
// If we still see the opening, we can't yet teleport.
- if (t[0]==-1)
+ if (pData[0]==-1)
{
- if (sc->floorz > t[3])
+ if (pSector->floorz > pData[3])
break;
}
- else if (sc->ceilingz < t[4]) break;
+ else if (pSector->ceilingz < pData[4]) break;
- if (t[1] == 0) break;
- t[1] = 0;
+ if (pData[1] == 0) break;
+ pData[1] = 0;
for (SPRITES_OF(STAT_EFFECTOR, j))
{
- if (i != j && sprite[j].lotag == SE_17_WARP_ELEVATOR)
- if (sc->hitag-t[0] == sector[sprite[j].sectnum].hitag
- && sh == sprite[j].hitag)
+ if (spriteNum != j && sprite[j].lotag == SE_17_WARP_ELEVATOR)
+ if (pSector->hitag-pData[0] == sector[sprite[j].sectnum].hitag
+ && sectorHitag == sprite[j].hitag)
break;
}
if (j == -1) break;
- for (SPRITES_OF_SECT_SAFE(s->sectnum, k, nextk))
+ for (SPRITES_OF_SECT_SAFE(pSprite->sectnum, k, nextk))
{
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;
- ps->pos.x += sprite[j].x-s->x;
- ps->pos.y += sprite[j].y-s->y;
+ 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-(sc->floorz-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;
@@ -6881,14 +6847,14 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
else if (sprite[k].statnum != STAT_EFFECTOR)
{
- sprite[k].x += sprite[j].x-s->x;
- sprite[k].y += sprite[j].y-s->y;
+ sprite[k].x += sprite[j].x-pSprite->x;
+ sprite[k].y += sprite[j].y-pSprite->y;
Bmemcpy(&actor[k].bpos, &sprite[k], sizeof(vec2_t));
actor[k].bpos.z -= sprite[k].z;
sprite[k].z = sector[sprite[j].sectnum].floorz-
- (sc->floorz-sprite[k].z);
+ (pSector->floorz-sprite[k].z);
actor[k].bpos.z += sprite[k].z;
changespritesect(k,sprite[j].sectnum);
@@ -6903,97 +6869,97 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
- if (t[0])
+ if (pData[0])
{
- if (s->pal)
+ if (pSprite->pal)
{
- if (s->ang == 512)
+ if (pSprite->ang == 512)
{
- sc->ceilingz -= sc->extra;
- if (sc->ceilingz <= t[1])
+ pSector->ceilingz -= pSector->extra;
+ if (pSector->ceilingz <= pData[1])
{
- sc->ceilingz = t[1];
- KILLIT(i);
+ pSector->ceilingz = pData[1];
+ KILLIT(spriteNum);
}
}
else
{
- sc->floorz += sc->extra;
+ pSector->floorz += pSector->extra;
- for (SPRITES_OF_SECT(s->sectnum, j))
+ for (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 += sc->extra;
+ g_player[P_Get(j)].ps->pos.z += pSector->extra;
if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE)
{
- actor[j].bpos.z = sprite[j].z += sc->extra;
- actor[j].floorz = sc->floorz;
+ actor[j].bpos.z = sprite[j].z += pSector->extra;
+ actor[j].floorz = pSector->floorz;
}
}
- if (sc->floorz >= t[1])
+ if (pSector->floorz >= pData[1])
{
- sc->floorz = t[1];
- KILLIT(i);
+ pSector->floorz = pData[1];
+ KILLIT(spriteNum);
}
}
}
else
{
- if (s->ang == 512)
+ if (pSprite->ang == 512)
{
- sc->ceilingz += sc->extra;
- if (sc->ceilingz >= s->z)
+ pSector->ceilingz += pSector->extra;
+ if (pSector->ceilingz >= pSprite->z)
{
- sc->ceilingz = s->z;
- KILLIT(i);
+ pSector->ceilingz = pSprite->z;
+ KILLIT(spriteNum);
}
}
else
{
- sc->floorz -= sc->extra;
+ pSector->floorz -= pSector->extra;
- for (SPRITES_OF_SECT(s->sectnum, j))
+ for (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 -= sc->extra;
+ g_player[P_Get(j)].ps->pos.z -= pSector->extra;
if (sprite[j].zvel == 0 && sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PROJECTILE)
{
- actor[j].bpos.z = sprite[j].z -= sc->extra;
- actor[j].floorz = sc->floorz;
+ actor[j].bpos.z = sprite[j].z -= pSector->extra;
+ actor[j].floorz = pSector->floorz;
}
}
- if (sc->floorz <= s->z)
+ if (pSector->floorz <= pSprite->z)
{
- sc->floorz = s->z;
- KILLIT(i);
+ pSector->floorz = pSprite->z;
+ KILLIT(spriteNum);
}
}
}
- t[2]++;
- if (t[2] >= s->hitag)
+ pData[2]++;
+ if (pData[2] >= pSprite->hitag)
{
- t[2] = 0;
- t[0] = 0;
+ pData[2] = 0;
+ pData[0] = 0;
}
}
break;
case SE_19_EXPLOSION_LOWERS_CEILING: //Battlestar galactia shields
- if (t[0])
+ if (pData[0])
{
- if (t[0] == 1)
+ if (pData[0] == 1)
{
- t[0]++;
- x = sc->wallptr;
- q = x+sc->wallnum;
+ pData[0]++;
+ x = pSector->wallptr;
+ q = x+pSector->wallnum;
for (j=x; jceilingz < sc->floorz)
- sc->ceilingz += SP;
+ if (pSector->ceilingz < pSector->floorz)
+ pSector->ceilingz += SP(spriteNum);
else
{
- sc->ceilingz = sc->floorz;
+ pSector->ceilingz = pSector->floorz;
for (SPRITES_OF(STAT_EFFECTOR, j))
{
- if (sprite[j].lotag == SE_0_ROTATING_SECTOR && sprite[j].hitag==sh)
+ if (sprite[j].lotag == SE_0_ROTATING_SECTOR && sprite[j].hitag==sectorHitag)
{
sectortype *const sec = §or[sprite[j].sectnum];
@@ -7027,12 +6993,12 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
- KILLIT(i);
+ KILLIT(spriteNum);
}
}
else //Not hit yet
{
- if (G_FindExplosionInSector(s->sectnum) >= 0)
+ if (G_FindExplosionInSector(pSprite->sectnum) >= 0)
{
P_DoQuote(QUOTE_UNLOCKED, g_player[myconnectindex].ps);
@@ -7042,7 +7008,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
switch (x)
{
case SE_0_ROTATING_SECTOR:
- if (sprite[l].hitag == sh)
+ if (sprite[l].hitag == sectorHitag)
{
int32_t ow = sprite[l].owner;
q = sprite[l].sectnum;
@@ -7055,11 +7021,11 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
case SE_12_LIGHT_SWITCH:
// case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
case SE_19_EXPLOSION_LOWERS_CEILING:
- if (sh == sprite[l].hitag)
+ 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 = i;
+ sprite[l].owner = spriteNum;
}
break;
@@ -7071,32 +7037,32 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
break;
case SE_20_STRETCH_BRIDGE: //Extend-o-bridge
- if (t[0] == 0) break;
- if (t[0] == 1) s->xvel = 8;
- else s->xvel = -8;
+ if (pData[0] == 0) break;
+ if (pData[0] == 1) pSprite->xvel = 8;
+ else pSprite->xvel = -8;
- if (s->xvel) //Moving
+ if (pSprite->xvel) //Moving
{
int32_t p, nextj;
- x = (s->xvel*sintable[(s->ang+512)&2047])>>14;
- l = (s->xvel*sintable[s->ang&2047])>>14;
+ x = (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14;
+ l = (pSprite->xvel*sintable[pSprite->ang&2047])>>14;
- t[3] += s->xvel;
+ pData[3] += pSprite->xvel;
- s->x += x;
- s->y += l;
+ pSprite->x += x;
+ pSprite->y += l;
- if (t[3] <= 0 || (t[3]>>6) >= (SP>>6))
+ if (pData[3] <= 0 || (pData[3]>>6) >= (SP(spriteNum)>>6))
{
- s->x -= x;
- s->y -= l;
- t[0] = 0;
- A_CallSound(s->sectnum,i);
+ pSprite->x -= x;
+ pSprite->y -= l;
+ pData[0] = 0;
+ A_CallSound(pSprite->sectnum,spriteNum);
break;
}
- for (SPRITES_OF_SECT_SAFE(s->sectnum, j, nextj))
+ for (SPRITES_OF_SECT_SAFE(pSprite->sectnum, j, nextj))
{
if (sprite[j].statnum != STAT_EFFECTOR && sprite[j].zvel == 0)
{
@@ -7109,14 +7075,14 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
- dragpoint((int16_t)t[1],wall[t[1]].x+x,wall[t[1]].y+l,0);
- dragpoint((int16_t)t[2],wall[t[2]].x+x,wall[t[2]].y+l,0);
+ 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);
for (TRAVERSE_CONNECT(p))
{
DukePlayer_t *const ps = g_player[p].ps;
- if (ps->cursectnum == s->sectnum && ps->on_ground)
+ if (ps->cursectnum == pSprite->sectnum && ps->on_ground)
{
ps->pos.x += x;
ps->pos.y += l;
@@ -7130,11 +7096,11 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
- sc->floorxpanning-=x>>3;
- sc->floorypanning-=l>>3;
+ pSector->floorxpanning-=x>>3;
+ pSector->floorypanning-=l>>3;
- sc->ceilingxpanning-=x>>3;
- sc->ceilingypanning-=l>>3;
+ pSector->ceilingxpanning-=x>>3;
+ pSector->ceilingypanning-=l>>3;
}
break;
@@ -7143,39 +7109,39 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
{
int32_t *zptr;
- if (t[0] == 0) break;
+ if (pData[0] == 0) break;
- if (s->ang == 1536)
- zptr = &sc->ceilingz;
+ if (pSprite->ang == 1536)
+ zptr = &pSector->ceilingz;
else
- zptr = &sc->floorz;
+ zptr = &pSector->floorz;
- if (t[0] == 1) //Decide if the s->sectnum should go up or down
+ if (pData[0] == 1) //Decide if the s->sectnum should go up or down
{
- s->zvel = ksgn(s->z-*zptr) * (SP<<4);
- t[0]++;
+ pSprite->zvel = ksgn(pSprite->z-*zptr) * (SP(spriteNum)<<4);
+ pData[0]++;
}
- if (sc->extra == 0)
+ if (pSector->extra == 0)
{
- *zptr += s->zvel;
+ *zptr += pSprite->zvel;
- if (klabs(*zptr-s->z) < 1024)
+ if (klabs(*zptr-pSprite->z) < 1024)
{
- *zptr = s->z;
- KILLIT(i); //All done // SE_21_KILLIT, see sector.c
+ *zptr = pSprite->z;
+ KILLIT(spriteNum); //All done // SE_21_KILLIT, see sector.c
}
}
- else sc->extra--;
+ else pSector->extra--;
break;
}
case SE_22_TEETH_DOOR:
- if (t[1])
+ if (pData[1])
{
- if (GetAnimationGoal(§or[t[0]].ceilingz) >= 0)
- sc->ceilingz += sc->extra*9;
- else t[1] = 0;
+ if (GetAnimationGoal(§or[pData[0]].ceilingz) >= 0)
+ pSector->ceilingz += pSector->extra*9;
+ else pData[1] = 0;
}
break;
@@ -7184,15 +7150,15 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
{
int32_t p, nextj;
- if (t[4])
+ if (pData[4])
break;
- x = (SP*sintable[(s->ang+512)&2047])>>18;
- l = (SP*sintable[s->ang&2047])>>18;
+ x = (SP(spriteNum)*sintable[(pSprite->ang+512)&2047])>>18;
+ l = (SP(spriteNum)*sintable[pSprite->ang&2047])>>18;
k = 0;
- for (SPRITES_OF_SECT_SAFE(s->sectnum, j, nextj))
+ for (SPRITES_OF_SECT_SAFE(pSprite->sectnum, j, nextj))
{
if (sprite[j].zvel >= 0)
switch (sprite[j].statnum)
@@ -7262,7 +7228,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
{
DukePlayer_t *const ps = g_player[p].ps;
- if (ps->cursectnum == s->sectnum && ps->on_ground)
+ if (ps->cursectnum == pSprite->sectnum && ps->on_ground)
{
if (klabs(ps->pos.z-ps->truefz) < PHEIGHT+(9<<8))
{
@@ -7271,63 +7237,63 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
}
}
- sc->floorxpanning += SP>>7;
+ pSector->floorxpanning += SP(spriteNum)>>7;
break;
}
case SE_35:
- if (sc->ceilingz > s->z)
+ if (pSector->ceilingz > pSprite->z)
for (j = 0; j < 8; j++)
{
- s->ang += krand()&511;
- k = A_Spawn(i,SMALLSMOKE);
+ pSprite->ang += krand()&511;
+ k = A_Spawn(spriteNum,SMALLSMOKE);
sprite[k].xvel = 96+(krand()&127);
A_SetSprite(k,CLIPMASK0);
setsprite(k,(vec3_t *)&sprite[k]);
if (rnd(16))
- A_Spawn(i,EXPLOSION2);
+ A_Spawn(spriteNum,EXPLOSION2);
}
- switch (t[0])
+ switch (pData[0])
{
case 0:
- sc->ceilingz += s->yvel;
- if (sc->ceilingz > sc->floorz)
- sc->floorz = sc->ceilingz;
- if (sc->ceilingz > s->z+(32<<8))
- t[0]++;
+ pSector->ceilingz += pSprite->yvel;
+ if (pSector->ceilingz > pSector->floorz)
+ pSector->floorz = pSector->ceilingz;
+ if (pSector->ceilingz > pSprite->z+(32<<8))
+ pData[0]++;
break;
case 1:
- sc->ceilingz-=(s->yvel<<2);
- if (sc->ceilingz < t[4])
+ pSector->ceilingz-=(pSprite->yvel<<2);
+ if (pSector->ceilingz < pData[4])
{
- sc->ceilingz = t[4];
- t[0] = 0;
+ pSector->ceilingz = pData[4];
+ pData[0] = 0;
}
break;
}
break;
case SE_25_PISTON: //PISTONS
- if (t[4] == 0) break;
+ if (pData[4] == 0) break;
- if (sc->floorz <= sc->ceilingz)
- s->shade = 0;
- else if (sc->ceilingz <= t[3])
- s->shade = 1;
+ if (pSector->floorz <= pSector->ceilingz)
+ pSprite->shade = 0;
+ else if (pSector->ceilingz <= pData[3])
+ pSprite->shade = 1;
- if (s->shade)
+ if (pSprite->shade)
{
- sc->ceilingz += SP<<4;
- if (sc->ceilingz > sc->floorz)
- sc->ceilingz = sc->floorz;
+ pSector->ceilingz += SP(spriteNum)<<4;
+ if (pSector->ceilingz > pSector->floorz)
+ pSector->ceilingz = pSector->floorz;
}
else
{
- sc->ceilingz -= SP<<4;
- if (sc->ceilingz < t[3])
- sc->ceilingz = t[3];
+ pSector->ceilingz -= SP(spriteNum)<<4;
+ if (pSector->ceilingz < pData[3])
+ pSector->ceilingz = pData[3];
}
break;
@@ -7336,22 +7302,22 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
{
int32_t p, nextj;
- s->xvel = 32;
- l = (s->xvel*sintable[(s->ang+512)&2047])>>14;
- x = (s->xvel*sintable[s->ang&2047])>>14;
+ pSprite->xvel = 32;
+ l = (pSprite->xvel*sintable[(pSprite->ang+512)&2047])>>14;
+ x = (pSprite->xvel*sintable[pSprite->ang&2047])>>14;
- s->shade++;
- if (s->shade > 7)
+ pSprite->shade++;
+ if (pSprite->shade > 7)
{
- s->x = t[3];
- s->y = t[4];
- sc->floorz -= ((s->zvel*s->shade)-s->zvel);
- s->shade = 0;
+ pSprite->x = pData[3];
+ pSprite->y = pData[4];
+ pSector->floorz -= ((pSprite->zvel*pSprite->shade)-pSprite->zvel);
+ pSprite->shade = 0;
}
else
- sc->floorz += s->zvel;
+ pSector->floorz += pSprite->zvel;
- for (SPRITES_OF_SECT_SAFE(s->sectnum, j, nextj))
+ for (SPRITES_OF_SECT_SAFE(pSprite->sectnum, j, nextj))
{
if (sprite[j].statnum != STAT_EFFECTOR && sprite[j].statnum != STAT_PLAYER)
{
@@ -7361,7 +7327,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
sprite[j].x += l;
sprite[j].y += x;
- sprite[j].z += s->zvel;
+ sprite[j].z += pSprite->zvel;
setsprite(j,(vec3_t *)&sprite[j]);
}
}
@@ -7370,15 +7336,15 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
{
DukePlayer_t *const ps = g_player[p].ps;
- if (sprite[ps->i].sectnum == s->sectnum && ps->on_ground)
+ if (sprite[ps->i].sectnum == pSprite->sectnum && ps->on_ground)
{
ps->fric.x += l<<5;
ps->fric.y += x<<5;
- ps->pos.z += s->zvel;
+ ps->pos.z += pSprite->zvel;
}
}
- A_MoveSector(i);
- setsprite(i,(vec3_t *)s);
+ A_MoveSector(spriteNum);
+ setsprite(spriteNum,(vec3_t *)pSprite);
break;
}
@@ -7390,49 +7356,49 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
if (ud.recstat == 0 || !ud.democams) break;
- actor[i].tempang = s->ang;
+ actor[spriteNum].tempang = pSprite->ang;
- p = A_FindPlayer(s,&x);
+ p = A_FindPlayer(pSprite,&x);
ps = g_player[p].ps;
if (sprite[ps->i].extra > 0 && myconnectindex == screenpeek)
{
- if (t[0] < 0)
+ if (pData[0] < 0)
{
- ud.camerasprite = i;
- t[0]++;
+ ud.camerasprite = spriteNum;
+ pData[0]++;
}
else if (ud.recstat == 2 && ps->newowner == -1)
{
- if (cansee(s->x,s->y,s->z,SECT,ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum))
+ if (cansee(pSprite->x,pSprite->y,pSprite->z,SECT(spriteNum),ps->pos.x,ps->pos.y,ps->pos.z,ps->cursectnum))
{
- if (x < (int32_t)((unsigned)sh))
+ if (x < (int32_t)((unsigned)sectorHitag))
{
- ud.camerasprite = i;
- t[0] = 999;
- s->ang += G_GetAngleDelta(s->ang,getangle(ps->pos.x-s->x,ps->pos.y-s->y))>>3;
- SP = 100+((s->z-ps->pos.z)/257);
+ ud.camerasprite = spriteNum;
+ pData[0] = 999;
+ pSprite->ang += G_GetAngleDelta(pSprite->ang,getangle(ps->pos.x-pSprite->x,ps->pos.y-pSprite->y))>>3;
+ SP(spriteNum) = 100+((pSprite->z-ps->pos.z)/257);
}
- else if (t[0] == 999)
+ else if (pData[0] == 999)
{
- if (ud.camerasprite == i)
- t[0] = 0;
- else t[0] = -10;
- ud.camerasprite = i;
+ if (ud.camerasprite == spriteNum)
+ pData[0] = 0;
+ else pData[0] = -10;
+ ud.camerasprite = spriteNum;
}
}
else
{
- s->ang = getangle(ps->pos.x-s->x,ps->pos.y-s->y);
+ pSprite->ang = getangle(ps->pos.x-pSprite->x,ps->pos.y-pSprite->y);
- if (t[0] == 999)
+ if (pData[0] == 999)
{
- if (ud.camerasprite == i)
- t[0] = 0;
- else t[0] = -20;
- ud.camerasprite = i;
+ if (ud.camerasprite == spriteNum)
+ pData[0] = 0;
+ else pData[0] = -20;
+ ud.camerasprite = spriteNum;
}
}
}
@@ -7442,47 +7408,47 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
case SE_28_LIGHTNING:
{
- if (t[5] > 0)
+ if (pData[5] > 0)
{
- t[5]--;
+ pData[5]--;
break;
}
- if (T1 == 0)
+ if (T1(spriteNum) == 0)
{
- A_FindPlayer(s,&x);
+ A_FindPlayer(pSprite,&x);
if (x > 15500)
break;
- T1 = 1;
- T2 = 64 + (krand()&511);
- T3 = 0;
+ T1(spriteNum) = 1;
+ T2(spriteNum) = 64 + (krand()&511);
+ T3(spriteNum) = 0;
}
else
{
- T3++;
- if (T3 > T2)
+ T3(spriteNum)++;
+ if (T3(spriteNum) > T2(spriteNum))
{
- T1 = 0;
+ T1(spriteNum) = 0;
g_player[screenpeek].ps->visibility = ud.const_visibility;
break;
}
- else if (T3 == (T2>>1))
- A_PlaySound(THUNDER,i);
- else if (T3 == (T2>>3))
- A_PlaySound(LIGHTNING_SLAP,i);
- else if (T3 == (T2>>2))
+ else if (T3(spriteNum) == (T2(spriteNum)>>1))
+ A_PlaySound(THUNDER,spriteNum);
+ else if (T3(spriteNum) == (T2(spriteNum)>>3))
+ A_PlaySound(LIGHTNING_SLAP,spriteNum);
+ else if (T3(spriteNum) == (T2(spriteNum)>>2))
{
for (SPRITES_OF(STAT_DEFAULT, j))
- if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag)
+ if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == pSprite->hitag)
sprite[j].cstat |= 32768;
}
- else if (T3 > (T2>>3) && T3 < (T2>>2))
+ else if (T3(spriteNum) > (T2(spriteNum)>>3) && T3(spriteNum) < (T2(spriteNum)>>2))
{
- if (cansee(s->x,s->y,s->z,s->sectnum,g_player[screenpeek].ps->pos.x,g_player[screenpeek].ps->pos.y,g_player[screenpeek].ps->pos.z,g_player[screenpeek].ps->cursectnum))
+ if (cansee(pSprite->x,pSprite->y,pSprite->z,pSprite->sectnum,g_player[screenpeek].ps->pos.x,g_player[screenpeek].ps->pos.y,g_player[screenpeek].ps->pos.z,g_player[screenpeek].ps->cursectnum))
j = 1;
else j = 0;
- if (rnd(192) && (T3&1))
+ if (rnd(192) && (T3(spriteNum)&1))
{
if (j)
g_player[screenpeek].ps->visibility = 0;
@@ -7492,9 +7458,9 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
for (SPRITES_OF(STAT_DEFAULT, j))
{
- if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == s->hitag)
+ if (sprite[j].picnum == NATURALLIGHTNING && sprite[j].hitag == pSprite->hitag)
{
- if (rnd(32) && (T3&1))
+ if (rnd(32) && (T3(spriteNum)&1))
{
int32_t p;
DukePlayer_t *ps;
@@ -7502,7 +7468,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
sprite[j].cstat &= 32767;
A_Spawn(j,SMALLSMOKE);
- p = A_FindPlayer(s, NULL);
+ p = A_FindPlayer(pSprite, NULL);
ps = g_player[p].ps;
x = ldist(&sprite[ps->i], &sprite[j]);
@@ -7526,163 +7492,165 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
case SE_29_WAVES:
- s->hitag += 64;
- l = mulscale12((int32_t)s->yvel,sintable[s->hitag&2047]);
- sc->floorz = s->z + l;
+ pSprite->hitag += 64;
+ l = mulscale12((int32_t)pSprite->yvel,sintable[pSprite->hitag&2047]);
+ pSector->floorz = pSprite->z + l;
break;
case SE_31_FLOOR_RISE_FALL: // True Drop Floor
- if (t[0] == 1)
+ if (pData[0] == 1)
{
// Choose dir
- if (t[3] > 0)
+ if (pData[3] > 0)
{
- t[3]--;
+ pData[3]--;
break;
}
- if (t[2] == 1) // Retract
+ if (pData[2] == 1) // Retract
{
- if (SA != 1536)
- HandleSE31(i, 1, s->z, 0, s->z-sc->floorz);
+ if (SA(spriteNum) != 1536)
+ HandleSE31(spriteNum, 1, pSprite->z, 0, pSprite->z-pSector->floorz);
else
- HandleSE31(i, 1, t[1], 0, t[1]-sc->floorz);
+ HandleSE31(spriteNum, 1, pData[1], 0, pData[1]-pSector->floorz);
- Yax_SetBunchZs(sc-sector, YAX_FLOOR, sc->floorz);
+ Yax_SetBunchZs(pSector-sector, YAX_FLOOR, pSector->floorz);
break;
}
- if ((s->ang&2047) == 1536)
- HandleSE31(i, 0, s->z, 1, s->z-sc->floorz);
+ if ((pSprite->ang&2047) == 1536)
+ HandleSE31(spriteNum, 0, pSprite->z, 1, pSprite->z-pSector->floorz);
else
- HandleSE31(i, 0, t[1], 1, t[1]-s->z);
+ HandleSE31(spriteNum, 0, pData[1], 1, pData[1]-pSprite->z);
- Yax_SetBunchZs(sc-sector, YAX_FLOOR, sc->floorz);
+ Yax_SetBunchZs(pSector-sector, YAX_FLOOR, pSector->floorz);
}
break;
case SE_32_CEILING_RISE_FALL: // True Drop Ceiling
- if (t[0] == 1)
+ if (pData[0] == 1)
{
// Choose dir
- if (t[2] == 1) // Retract
+ if (pData[2] == 1) // Retract
{
- if (SA != 1536)
+ if (SA(spriteNum) != 1536)
{
- if (klabs(sc->ceilingz - s->z) < (SP<<1))
+ if (klabs(pSector->ceilingz - pSprite->z) < (SP(spriteNum)<<1))
{
- sc->ceilingz = s->z;
- A_CallSound(s->sectnum,i);
- t[2] = 0;
- t[0] = 0;
+ pSector->ceilingz = pSprite->z;
+ A_CallSound(pSprite->sectnum,spriteNum);
+ pData[2] = 0;
+ pData[0] = 0;
}
- else sc->ceilingz += ksgn(s->z-sc->ceilingz)*SP;
+ else pSector->ceilingz += ksgn(pSprite->z-pSector->ceilingz)*SP(spriteNum);
}
else
{
- if (klabs(sc->ceilingz - t[1]) < (SP<<1))
+ if (klabs(pSector->ceilingz - pData[1]) < (SP(spriteNum)<<1))
{
- sc->ceilingz = t[1];
- A_CallSound(s->sectnum,i);
- t[2] = 0;
- t[0] = 0;
+ pSector->ceilingz = pData[1];
+ A_CallSound(pSprite->sectnum,spriteNum);
+ pData[2] = 0;
+ pData[0] = 0;
}
- else sc->ceilingz += ksgn(t[1]-sc->ceilingz)*SP;
+ else pSector->ceilingz += ksgn(pData[1]-pSector->ceilingz)*SP(spriteNum);
}
- Yax_SetBunchZs(sc-sector, YAX_CEILING, sc->ceilingz);
+ Yax_SetBunchZs(pSector-sector, YAX_CEILING, pSector->ceilingz);
break;
}
- if ((s->ang&2047) == 1536)
+ if ((pSprite->ang&2047) == 1536)
{
- if (klabs(sc->ceilingz-s->z) < (SP<<1))
+ if (klabs(pSector->ceilingz-pSprite->z) < (SP(spriteNum)<<1))
{
- t[0] = 0;
- t[2] = !t[2];
- A_CallSound(s->sectnum,i);
- sc->ceilingz = s->z;
+ pData[0] = 0;
+ pData[2] = !pData[2];
+ A_CallSound(pSprite->sectnum,spriteNum);
+ pSector->ceilingz = pSprite->z;
}
- else sc->ceilingz += ksgn(s->z-sc->ceilingz)*SP;
+ else pSector->ceilingz += ksgn(pSprite->z-pSector->ceilingz)*SP(spriteNum);
}
else
{
- if (klabs(sc->ceilingz-t[1]) < (SP<<1))
+ if (klabs(pSector->ceilingz-pData[1]) < (SP(spriteNum)<<1))
{
- t[0] = 0;
- t[2] = !t[2];
- A_CallSound(s->sectnum,i);
+ pData[0] = 0;
+ pData[2] = !pData[2];
+ A_CallSound(pSprite->sectnum,spriteNum);
}
- else sc->ceilingz -= ksgn(s->z-t[1])*SP;
+ else pSector->ceilingz -= ksgn(pSprite->z-pData[1])*SP(spriteNum);
}
- Yax_SetBunchZs(sc-sector, YAX_CEILING, sc->ceilingz);
+ Yax_SetBunchZs(pSector-sector, YAX_CEILING, pSector->ceilingz);
}
break;
case SE_33_QUAKE_DEBRIS:
if (g_earthquakeTime > 0 && (krand()&7) == 0)
- RANDOMSCRAP;
+ RANDOMSCRAP(pSprite, spriteNum);
break;
case SE_36_PROJ_SHOOTER:
- if (t[0])
+ if (pData[0])
{
- if (t[0] == 1)
- A_Shoot(i,sc->extra);
- else if (t[0] == GAMETICSPERSEC*5)
- t[0] = 0;
- t[0]++;
+ if (pData[0] == 1)
+ A_Shoot(spriteNum,pSector->extra);
+ else if (pData[0] == GAMETICSPERSEC*5)
+ pData[0] = 0;
+ pData[0]++;
}
break;
case 128: //SE to control glass breakage
- wal = &wall[t[2]];
-
- if (wal->cstat|32)
{
- wal->cstat &= (255-32);
- wal->cstat |= 16;
- if (wal->nextwall >= 0)
+ walltype *pWall = &wall[pData[2]];
+
+ if (pWall->cstat|32)
{
- wall[wal->nextwall].cstat &= (255-32);
- wall[wal->nextwall].cstat |= 16;
+ pWall->cstat &= (255-32);
+ pWall->cstat |= 16;
+ if (pWall->nextwall >= 0)
+ {
+ wall[pWall->nextwall].cstat &= (255-32);
+ wall[pWall->nextwall].cstat |= 16;
+ }
}
- }
- else break;
+ else break;
- wal->overpicnum++;
- if (wal->nextwall >= 0)
- wall[wal->nextwall].overpicnum++;
+ pWall->overpicnum++;
+ if (pWall->nextwall >= 0)
+ wall[pWall->nextwall].overpicnum++;
- if (t[0] < t[1]) t[0]++;
- else
- {
- wal->cstat &= (128+32+8+4+2);
- if (wal->nextwall >= 0)
- wall[wal->nextwall].cstat &= (128+32+8+4+2);
- KILLIT(i);
+ if (pData[0] < pData[1]) pData[0]++;
+ else
+ {
+ pWall->cstat &= (128+32+8+4+2);
+ if (pWall->nextwall >= 0)
+ wall[pWall->nextwall].cstat &= (128+32+8+4+2);
+ KILLIT(spriteNum);
+ }
}
break;
case SE_130:
- if (t[0] > 80)
+ if (pData[0] > 80)
{
- KILLIT(i);
+ KILLIT(spriteNum);
}
- else t[0]++;
+ else pData[0]++;
- x = sc->floorz-sc->ceilingz;
+ x = pSector->floorz-pSector->ceilingz;
if (rnd(64))
{
- k = A_Spawn(i,EXPLOSION2);
+ k = A_Spawn(spriteNum,EXPLOSION2);
sprite[k].xrepeat = sprite[k].yrepeat = 2+(krand()&7);
- sprite[k].z = sc->floorz-(krand()%x);
+ sprite[k].z = pSector->floorz-(krand()%x);
sprite[k].ang += 256-(krand()%511);
sprite[k].xvel = krand()&127;
A_SetSprite(k,CLIPMASK0);
@@ -7690,19 +7658,19 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
break;
case SE_131:
- if (t[0] > 40)
+ if (pData[0] > 40)
{
- KILLIT(i);
+ KILLIT(spriteNum);
}
- else t[0]++;
+ else pData[0]++;
- x = sc->floorz-sc->ceilingz;
+ x = pSector->floorz-pSector->ceilingz;
if (rnd(32))
{
- k = A_Spawn(i,EXPLOSION2);
+ k = A_Spawn(spriteNum,EXPLOSION2);
sprite[k].xrepeat = sprite[k].yrepeat = 2+(krand()&3);
- sprite[k].z = sc->floorz-(krand()%x);
+ sprite[k].z = pSector->floorz-(krand()%x);
sprite[k].ang += 256-(krand()%511);
sprite[k].xvel = krand()&127;
A_SetSprite(k,CLIPMASK0);
@@ -7711,17 +7679,17 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
case SE_49_POINT_LIGHT:
case SE_50_SPOT_LIGHT:
- changespritestat(i, STAT_LIGHT);
+ changespritestat(spriteNum, STAT_LIGHT);
break;
}
-BOLT:
- i = nexti;
+next_sprite:
+ spriteNum = nextSprite;
}
//Sloped sin-wave floors!
- for (SPRITES_OF(STAT_EFFECTOR, i))
+ for (SPRITES_OF(STAT_EFFECTOR, spriteNum))
{
- const spritetype *s = &sprite[i];
+ const spritetype *s = &sprite[spriteNum];
if (s->lotag == SE_29_WAVES)
{
@@ -7729,9 +7697,9 @@ BOLT:
if (sc->wallnum == 4)
{
- wal = &wall[sc->wallptr+2];
- if (wal->nextsector >= 0)
- alignflorslope(s->sectnum, wal->x,wal->y, sector[wal->nextsector].floorz);
+ walltype *const pWall = &wall[sc->wallptr+2];
+ if (pWall->nextsector >= 0)
+ alignflorslope(s->sectnum, pWall->x,pWall->y, sector[pWall->nextsector].floorz);
}
}
}
@@ -7756,24 +7724,24 @@ static void G_DoEffectorLights(void) // STATNUM 14
#pragma pack(push,1)
_prlight mylight;
#pragma pack(pop)
- mylight.sector = SECT;
+ mylight.sector = SECT(i);
Bmemcpy(&mylight, &sprite[i], sizeof(int32_t) * 3);
- mylight.range = SHT;
+ mylight.range = SHT(i);
mylight.color[0] = sprite[i].xvel;
mylight.color[1] = sprite[i].yvel;
mylight.color[2] = sprite[i].zvel;
mylight.radius = 0;
- mylight.angle = SA;
- mylight.horiz = SH;
+ mylight.angle = SA(i);
+ mylight.horiz = SH(i);
mylight.minshade = sprite[i].xoffset;
mylight.maxshade = sprite[i].yoffset;
mylight.tilenum = 0;
mylight.publicflags.emitshadow = 0;
- mylight.publicflags.negative = !!(CS & 128);
+ mylight.publicflags.negative = !!(CS(i) & 128);
- if (CS & 2)
+ if (CS(i) & 2)
{
- if (CS & 512)
+ if (CS(i) & 512)
mylight.priority = PR_LIGHT_PRIO_LOW;
else
mylight.priority = PR_LIGHT_PRIO_HIGH;
@@ -7793,9 +7761,9 @@ static void G_DoEffectorLights(void) // STATNUM 14
actor[i].lightptr->sector = sprite[i].sectnum;
actor[i].lightptr->flags.invalidate = 1;
}
- if (SHT != actor[i].lightptr->range)
+ if (SHT(i) != actor[i].lightptr->range)
{
- actor[i].lightptr->range = SHT;
+ actor[i].lightptr->range = SHT(i);
actor[i].lightptr->flags.invalidate = 1;
}
if ((sprite[i].xvel != actor[i].lightptr->color[0]) ||
@@ -7806,8 +7774,8 @@ static void G_DoEffectorLights(void) // STATNUM 14
actor[i].lightptr->color[1] = sprite[i].yvel;
actor[i].lightptr->color[2] = sprite[i].zvel;
}
- if ((int)!!(CS & 128) != actor[i].lightptr->publicflags.negative) {
- actor[i].lightptr->publicflags.negative = !!(CS & 128);
+ if ((int)!!(CS(i) & 128) != actor[i].lightptr->publicflags.negative) {
+ actor[i].lightptr->publicflags.negative = !!(CS(i) & 128);
}
}
break;
@@ -7823,25 +7791,25 @@ static void G_DoEffectorLights(void) // STATNUM 14
_prlight mylight;
#pragma pack(pop)
- mylight.sector = SECT;
+ mylight.sector = SECT(i);
Bmemcpy(&mylight, &sprite[i], sizeof(int32_t) * 3);
- mylight.range = SHT;
+ mylight.range = SHT(i);
mylight.color[0] = sprite[i].xvel;
mylight.color[1] = sprite[i].yvel;
mylight.color[2] = sprite[i].zvel;
- mylight.radius = (256-(SS+128))<<1;
+ mylight.radius = (256-(SS(i)+128))<<1;
mylight.faderadius = (int16_t)(mylight.radius * 0.75f);
- mylight.angle = SA;
- mylight.horiz = SH;
+ mylight.angle = SA(i);
+ mylight.horiz = SH(i);
mylight.minshade = sprite[i].xoffset;
mylight.maxshade = sprite[i].yoffset;
mylight.tilenum = actor[i].picnum;
- mylight.publicflags.emitshadow = !(CS & 64);
- mylight.publicflags.negative = !!(CS & 128);
+ mylight.publicflags.emitshadow = !(CS(i) & 64);
+ mylight.publicflags.negative = !!(CS(i) & 128);
- if (CS & 2)
+ if (CS(i) & 2)
{
- if (CS & 512)
+ if (CS(i) & 512)
mylight.priority = PR_LIGHT_PRIO_LOW;
else
mylight.priority = PR_LIGHT_PRIO_HIGH;
@@ -7855,8 +7823,8 @@ static void G_DoEffectorLights(void) // STATNUM 14
actor[i].lightptr = &prlights[actor[i].lightId];
// Hack in case polymer_addlight tweaked the horiz value
- if (actor[i].lightptr->horiz != SH)
- SH = actor[i].lightptr->horiz;
+ if (actor[i].lightptr->horiz != SH(i))
+ SH(i) = actor[i].lightptr->horiz;
}
break;
}
@@ -7867,9 +7835,9 @@ static void G_DoEffectorLights(void) // STATNUM 14
actor[i].lightptr->sector = sprite[i].sectnum;
actor[i].lightptr->flags.invalidate = 1;
}
- if (SHT != actor[i].lightptr->range)
+ if (SHT(i) != actor[i].lightptr->range)
{
- actor[i].lightptr->range = SHT;
+ actor[i].lightptr->range = SHT(i);
actor[i].lightptr->flags.invalidate = 1;
}
if ((sprite[i].xvel != actor[i].lightptr->color[0]) ||
@@ -7880,27 +7848,27 @@ static void G_DoEffectorLights(void) // STATNUM 14
actor[i].lightptr->color[1] = sprite[i].yvel;
actor[i].lightptr->color[2] = sprite[i].zvel;
}
- if (((256-(SS+128))<<1) != actor[i].lightptr->radius)
+ if (((256-(SS(i)+128))<<1) != actor[i].lightptr->radius)
{
- actor[i].lightptr->radius = (256-(SS+128))<<1;
+ actor[i].lightptr->radius = (256-(SS(i)+128))<<1;
actor[i].lightptr->faderadius = (int16_t)(actor[i].lightptr->radius * 0.75f);
actor[i].lightptr->flags.invalidate = 1;
}
- if (SA != actor[i].lightptr->angle)
+ if (SA(i) != actor[i].lightptr->angle)
{
- actor[i].lightptr->angle = SA;
+ actor[i].lightptr->angle = SA(i);
actor[i].lightptr->flags.invalidate = 1;
}
- if (SH != actor[i].lightptr->horiz)
+ if (SH(i) != actor[i].lightptr->horiz)
{
- actor[i].lightptr->horiz = SH;
+ actor[i].lightptr->horiz = SH(i);
actor[i].lightptr->flags.invalidate = 1;
}
- if ((int)!(CS & 64) != actor[i].lightptr->publicflags.emitshadow) {
- actor[i].lightptr->publicflags.emitshadow = !(CS & 64);
+ if ((int)!(CS(i) & 64) != actor[i].lightptr->publicflags.emitshadow) {
+ actor[i].lightptr->publicflags.emitshadow = !(CS(i) & 64);
}
- if ((int)!!(CS & 128) != actor[i].lightptr->publicflags.negative) {
- actor[i].lightptr->publicflags.negative = !!(CS & 128);
+ if ((int)!!(CS(i) & 128) != actor[i].lightptr->publicflags.negative) {
+ actor[i].lightptr->publicflags.negative = !!(CS(i) & 128);
}
actor[i].lightptr->tilenum = actor[i].picnum;
}
@@ -8136,7 +8104,7 @@ static void A_DoLight(int32_t i)
void A_PlayAlertSound(int32_t i)
{
if (sprite[i].extra > 0)
- switch (DYNAMICTILEMAP(PN))
+ switch (DYNAMICTILEMAP(PN(i)))
{
case LIZTROOPONTOILET__STATIC:
case LIZTROOPJUSTSIT__STATIC:
@@ -8207,13 +8175,13 @@ int32_t A_CheckSwitchTile(int32_t i)
// ACCESSSWITCH and ACCESSSWITCH2 are only active in one state so deal with
// them separately.
- if ((PN <= 0) || (PN >= MULTISWITCH && PN <= MULTISWITCH + 3) || (PN == ACCESSSWITCH || PN == ACCESSSWITCH2))
+ if ((PN(i) <= 0) || (PN(i) >= MULTISWITCH && PN(i) <= MULTISWITCH + 3) || (PN(i) == ACCESSSWITCH || PN(i) == ACCESSSWITCH2))
return 1;
// Loop to catch both states of switches.
for (int j=1; j>=0; j--)
{
- switch (DYNAMICTILEMAP(PN-j))
+ switch (DYNAMICTILEMAP(PN(i)-j))
{
case HANDPRINTSWITCH__STATIC:
case ALIENSWITCH__STATIC:
diff --git a/polymer/eduke32/source/actors.h b/polymer/eduke32/source/actors.h
index d1a064945..131ac4e23 100644
--- a/polymer/eduke32/source/actors.h
+++ b/polymer/eduke32/source/actors.h
@@ -33,6 +33,8 @@ extern "C" {
#define SLEEPTIME 1536
#define ZOFFSET (1<<8)
#define ZOFFSET2 (16<<8)
+#define ZOFFSET3 (8<<8)
+#define ZOFFSET4 (12<<8)
#define ACTOR_MAXFALLINGZVEL 6144
#define ACTOR_ONWATER_ADDZ (24<<8)
@@ -302,9 +304,9 @@ extern projectile_t SpriteProjectile[MAXSPRITES];
void A_AddToDeleteQueue(int32_t i);
-int32_t A_CheckNoSE7Water(const spritetype *s, int32_t sectnum, int32_t slotag, int32_t *othersectptr);
+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(int32_t s);
+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);
int32_t A_IncurDamage(int32_t sn);
@@ -395,7 +397,7 @@ EXTERN_INLINE int32_t G_CheckForSpaceFloor(int32_t sectnum)
EXTERN_INLINE int A_CheckEnemySprite(void const * const pSprite)
{
- return A_CheckEnemyTile(((uspritetype *) pSprite)->picnum);
+ return A_CheckEnemyTile(((uspritetype const *) pSprite)->picnum);
}
#endif
diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c
index dd112a35b..b54df7d55 100644
--- a/polymer/eduke32/source/astub.c
+++ b/polymer/eduke32/source/astub.c
@@ -264,21 +264,21 @@ static void copy_prlight_colors(_prlight *mylightptr, int32_t i)
static void addprlight_common1(_prlight *mylightptr, int32_t i)
{
- mylightptr->sector = SECT;
+ mylightptr->sector = SECT(i);
Bmemcpy(mylightptr, &sprite[i], sizeof(vec3_t));
- mylightptr->range = SHT;
+ mylightptr->range = SHT(i);
copy_prlight_colors(mylightptr, i);
- mylightptr->angle = SA;
- mylightptr->horiz = SH;
+ mylightptr->angle = SA(i);
+ mylightptr->horiz = SH(i);
mylightptr->minshade = sprite[i].xoffset;
mylightptr->maxshade = sprite[i].yoffset;
// overridden for spot lights
mylightptr->radius = mylightptr->faderadius = mylightptr->tilenum = 0;
- if (CS & 2)
+ if (CS(i) & 2)
{
- if (CS & 512)
+ if (CS(i) & 512)
mylightptr->priority = PR_LIGHT_PRIO_LOW;
else
mylightptr->priority = PR_LIGHT_PRIO_HIGH;
@@ -286,7 +286,7 @@ static void addprlight_common1(_prlight *mylightptr, int32_t i)
else
mylightptr->priority = PR_LIGHT_PRIO_MAX;
- mylightptr->publicflags.negative = !!(CS & 128);
+ mylightptr->publicflags.negative = !!(CS(i) & 128);
spritelightid[i] = polymer_addlight(mylightptr);
if (spritelightid[i] >= 0)
@@ -2483,8 +2483,8 @@ static int32_t SelectAllTiles(int32_t iCurrentTile)
return iCurrentTile;
}
-static int32_t OnGotoTile(int32_t iTile);
-static int32_t OnSelectTile(int32_t iTile);
+static int32_t OnGotoTile(int32_t tileNum);
+static int32_t OnSelectTile(int32_t tileNum);
static int32_t OnSaveTileGroup();
static int32_t loadtilegroups(const char *fn);
static int32_t s_Zoom = INITIAL_ZOOM;
@@ -2533,7 +2533,7 @@ static int32_t m32gettile(int32_t idInitialTile)
int32_t gap, temp, zoomsz;
int32_t nXTiles, nYTiles, nDisplayedTiles;
int32_t i;
- int32_t iTile, iTopLeftTile, iLastTile;
+ int32_t tileNum, iTopLeftTile, iLastTile;
int32_t idSelectedTile;
int32_t scrollmode;
int32_t mousedx, mousedy, mtile, omousex=searchx, omousey=searchy, moffset=0;
@@ -2574,7 +2574,7 @@ static int32_t m32gettile(int32_t idInitialTile)
localartlookup[i] = i;
}
- iLastTile = iTile = idSelectedTile = idInitialTile;
+ iLastTile = tileNum = idSelectedTile = idInitialTile;
switch (searchstat)
{
@@ -2631,10 +2631,10 @@ static int32_t m32gettile(int32_t idInitialTile)
localartlookup[temp] = localartlookup[temp+gap];
localartlookup[temp+gap] = tempint;
- if (iTile == temp)
- iTile = temp + gap;
- else if (iTile == temp + gap)
- iTile = temp;
+ if (tileNum == temp)
+ tileNum = temp + gap;
+ else if (tileNum == temp + gap)
+ tileNum = temp;
temp -= gap;
}
@@ -2665,20 +2665,20 @@ static int32_t m32gettile(int32_t idInitialTile)
localartfreq[i] = 0; // Terrible bodge : zero tilefreq's not displayed in tile view. Still, when in Rome ... :-)
}
- iTile = idInitialTile;
+ tileNum = idInitialTile;
}
//
//
//
- iTopLeftTile = iTile - (iTile % nXTiles);
+ iTopLeftTile = tileNum - (tileNum % nXTiles);
iTopLeftTile = clamp(iTopLeftTile, 0, MAXTILES-nDisplayedTiles);
zoomsz = ZoomToThumbSize[s_Zoom];
- searchx = ((iTile-iTopLeftTile)%nXTiles)*zoomsz + zoomsz/2;
- searchy = ((iTile-iTopLeftTile)/nXTiles)*zoomsz + zoomsz/2;
+ searchx = ((tileNum-iTopLeftTile)%nXTiles)*zoomsz + zoomsz/2;
+ searchy = ((tileNum-iTopLeftTile)/nXTiles)*zoomsz + zoomsz/2;
////////////////////////////////
// Start of key handling code //
@@ -2689,9 +2689,9 @@ static int32_t m32gettile(int32_t idInitialTile)
int32_t ret;
zoomsz = ZoomToThumbSize[s_Zoom];
- ret = DrawTiles(iTopLeftTile, (iTile >= localartlookupnum) ? localartlookupnum-1 : iTile,
+ ret = DrawTiles(iTopLeftTile, (tileNum >= localartlookupnum) ? localartlookupnum-1 : tileNum,
nXTiles, nYTiles, zoomsz, moffset,
- (tilesel_showerr && (iTile==iLastTile || (tilesel_showerr=0))));
+ (tilesel_showerr && (tileNum==iLastTile || (tilesel_showerr=0))));
if (ret==0)
{
@@ -2703,7 +2703,7 @@ static int32_t m32gettile(int32_t idInitialTile)
}
getmousevalues(&mousedx,&mousedy,&bstatus);
- iLastTile = iTile;
+ iLastTile = tileNum;
searchx += mousedx;
searchy += mousedy;
@@ -2750,11 +2750,11 @@ static int32_t m32gettile(int32_t idInitialTile)
iTopLeftTile += (nXTiles*scrollamount);
}
- mtile = iTile = searchx/zoomsz + ((searchy-moffset)/zoomsz)*nXTiles + iTopLeftTile;
- while (iTile >= iTopLeftTile + nDisplayedTiles)
+ mtile = tileNum = searchx/zoomsz + ((searchy-moffset)/zoomsz)*nXTiles + iTopLeftTile;
+ while (tileNum >= iTopLeftTile + nDisplayedTiles)
{
- iTile -= nXTiles;
- mtile = iTile;
+ tileNum -= nXTiles;
+ mtile = tileNum;
}
// These two lines are so obvious I don't need to comment them ...;-)
@@ -2788,8 +2788,8 @@ static int32_t m32gettile(int32_t idInitialTile)
zoomsz = ZoomToThumbSize[s_Zoom];
- if (iTile >= localartlookupnum)
- iTile = localartlookupnum-1;
+ if (tileNum >= localartlookupnum)
+ tileNum = localartlookupnum-1;
// Calculate new num of tiles to display
nXTiles = xdim / zoomsz;
@@ -2801,82 +2801,82 @@ static int32_t m32gettile(int32_t idInitialTile)
// Determine if the top-left displayed tile needs to
// alter in order to display selected tile
- iTopLeftTile = iTile - (iTile % nXTiles);
+ iTopLeftTile = tileNum - (tileNum % nXTiles);
iTopLeftTile = clamp(iTopLeftTile, 0, MAXTILES - nDisplayedTiles);
// scroll window so mouse points the same tile as it was before zooming
- iTopLeftTile -= searchx/zoomsz + ((searchy-moffset)/zoomsz)*nXTiles + iTopLeftTile-iTile;
+ iTopLeftTile -= searchx/zoomsz + ((searchy-moffset)/zoomsz)*nXTiles + iTopLeftTile-tileNum;
}
if (PRESSED_KEYSC(LEFT))
{
if (eitherCTRL) // same as HOME, for consistency with CTRL-UP/DOWN
- iTile = (iTile/nXTiles)*nXTiles;
+ tileNum = (tileNum/nXTiles)*nXTiles;
else
- iTile--;
+ tileNum--;
}
if (PRESSED_KEYSC(RIGHT))
{
if (eitherCTRL) // same as END, for consistency with CTRL-UP/DOWN
- iTile = ((iTile+nXTiles)/nXTiles)*nXTiles - 1;
+ tileNum = ((tileNum+nXTiles)/nXTiles)*nXTiles - 1;
else
- iTile++;
+ tileNum++;
}
if (PRESSED_KEYSC(UP))
{
if (eitherCTRL)
- while (iTile-nXTiles >= iTopLeftTile)
- iTile -= nXTiles;
+ while (tileNum-nXTiles >= iTopLeftTile)
+ tileNum -= nXTiles;
else
- iTile -= nXTiles;
+ tileNum -= nXTiles;
}
if (PRESSED_KEYSC(DOWN))
{
if (eitherCTRL)
- while (iTile+nXTiles < iTopLeftTile + nDisplayedTiles)
- iTile += nXTiles;
+ while (tileNum+nXTiles < iTopLeftTile + nDisplayedTiles)
+ tileNum += nXTiles;
else
- iTile += nXTiles;
+ tileNum += nXTiles;
}
if (PRESSED_KEYSC(PGUP))
{
if (eitherCTRL)
- iTile = 0;
+ tileNum = 0;
else
- iTile -= nDisplayedTiles;
+ tileNum -= nDisplayedTiles;
}
if (PRESSED_KEYSC(PGDN))
{
if (eitherCTRL)
- iTile = localartlookupnum-1;
+ tileNum = localartlookupnum-1;
else
- iTile += nDisplayedTiles;
+ tileNum += nDisplayedTiles;
}
if (PRESSED_KEYSC(HOME))
{
if (eitherCTRL)
- iTile = iTopLeftTile;
+ tileNum = iTopLeftTile;
else
- iTile = (iTile/nXTiles)*nXTiles;
+ tileNum = (tileNum/nXTiles)*nXTiles;
}
if (PRESSED_KEYSC(END))
{
if (eitherCTRL)
- iTile = iTopLeftTile + nDisplayedTiles - 1;
+ tileNum = iTopLeftTile + nDisplayedTiles - 1;
else
- iTile = ((iTile+nXTiles)/nXTiles)*nXTiles - 1;
+ tileNum = ((tileNum+nXTiles)/nXTiles)*nXTiles - 1;
}
// 'V' KEYPRESS
if (PRESSED_KEYSC(V))
- iTile = SelectAllTiles(iTile);
+ tileNum = SelectAllTiles(tileNum);
// 'G' KEYPRESS - Goto frame
if (PRESSED_KEYSC(G))
@@ -2885,43 +2885,43 @@ static int32_t m32gettile(int32_t idInitialTile)
{
if (OnSaveTileGroup() == 0)
{
-// iTile = SelectAllTiles(iTile);
+// tileNum = SelectAllTiles(tileNum);
Bmemset(tilemarked, 0, sizeof(tilemarked));
mark_lastk = -1;
noTilesMarked = 1;
}
}
else
- iTile = OnGotoTile(iTile);
+ tileNum = OnGotoTile(tileNum);
}
// 'U' KEYPRESS : go straight to user defined art
if (PRESSED_KEYSC(U))
{
- SelectAllTiles(iTile);
- iTile = FIRST_USER_ART_TILE;
+ SelectAllTiles(tileNum);
+ tileNum = FIRST_USER_ART_TILE;
}
// 'A' KEYPRESS : Go straight to start of Atomic edition's art
if (PRESSED_KEYSC(A))
{
- SelectAllTiles(iTile);
- iTile = FIRST_ATOMIC_TILE;
+ SelectAllTiles(tileNum);
+ tileNum = FIRST_ATOMIC_TILE;
}
// 'E' KEYPRESS : Go straight to start of extended art
if (PRESSED_KEYSC(E))
{
- SelectAllTiles(iTile);
+ SelectAllTiles(tileNum);
- if (iTile == FIRST_EXTENDED_TILE)
- iTile = SECOND_EXTENDED_TILE;
- else iTile = FIRST_EXTENDED_TILE;
+ if (tileNum == FIRST_EXTENDED_TILE)
+ tileNum = SECOND_EXTENDED_TILE;
+ else tileNum = FIRST_EXTENDED_TILE;
}
// 'T' KEYPRESS = Select from pre-defined tileset
if (PRESSED_KEYSC(T))
- iTile = OnSelectTile(iTile);
+ tileNum = OnSelectTile(tileNum);
if (PRESSED_KEYSC(Z))
s_TileZoom = !s_TileZoom;
@@ -2929,7 +2929,7 @@ static int32_t m32gettile(int32_t idInitialTile)
//
// Ensure tilenum is within valid range
//
- iTile = clamp(iTile, 0, min(MAXTILES-1, localartlookupnum+nDisplayedTiles-1));
+ tileNum = clamp(tileNum, 0, min(MAXTILES-1, localartlookupnum+nDisplayedTiles-1));
// 'S' KEYPRESS: search for named tile
if (PRESSED_KEYSC(S))
@@ -2943,7 +2943,7 @@ static int32_t m32gettile(int32_t idInitialTile)
int32_t i, i0, slen=Bstrlen(searchstr)-1;
Bstrncpyz(laststr, searchstr, 25);
- i0 = localartlookup[iTile];
+ i0 = localartlookup[tileNum];
Bmemcpy(buf[0], laststr, 25);
Bstrupr(buf[0]);
@@ -2958,7 +2958,7 @@ static int32_t m32gettile(int32_t idInitialTile)
(searchstr[0]!='^' && Bstrstr(buf[1], buf[0])))
{
SelectAllTiles(i);
- iTile = i;
+ tileNum = i;
break;
}
}
@@ -2971,10 +2971,10 @@ static int32_t m32gettile(int32_t idInitialTile)
// Adjust top-left to ensure tilenum is within displayed range of tiles
//
- while (iTile < iTopLeftTile - (moffset<0)?nXTiles:0)
+ while (tileNum < iTopLeftTile - (moffset<0)?nXTiles:0)
iTopLeftTile -= nXTiles;
- while (iTile >= iTopLeftTile + nDisplayedTiles)
+ while (tileNum >= iTopLeftTile + nDisplayedTiles)
iTopLeftTile += nXTiles;
iTopLeftTile = clamp(iTopLeftTile, 0, MAXTILES - nDisplayedTiles);
@@ -2983,7 +2983,7 @@ static int32_t m32gettile(int32_t idInitialTile)
// SPACE keypress: mark/unmark selected tile
if (PRESSED_KEYSC(SPACE))
{
- if (iTile < localartlookupnum && IsValidTile(localartlookup[iTile]))
+ if (tileNum < localartlookupnum && IsValidTile(localartlookup[tileNum]))
{
if (keystatus[KEYSC_LCTRL] && keystatus[KEYSC_RSHIFT])
{
@@ -2993,7 +2993,7 @@ static int32_t m32gettile(int32_t idInitialTile)
}
else
{
- int32_t k=iTile, kend, dir;
+ int32_t k=tileNum, kend, dir;
if (noTilesMarked)
{
@@ -3031,10 +3031,10 @@ static int32_t m32gettile(int32_t idInitialTile)
}
else
{
- if (iTile < localartlookupnum)
+ if (tileNum < localartlookupnum)
{
// Convert tile num from index to actual tile num
- idSelectedTile = localartlookup[iTile];
+ idSelectedTile = localartlookup[tileNum];
// Check : if invalid tile selected, return original tile num
if (!IsValidTile(idSelectedTile))
@@ -3045,10 +3045,10 @@ static int32_t m32gettile(int32_t idInitialTile)
idSelectedTile = idInitialTile;
}
}
- if (mtile!=iTile) // if changed by keyboard, update mouse cursor
+ if (mtile!=tileNum) // if changed by keyboard, update mouse cursor
{
- searchx = ((iTile-iTopLeftTile)%nXTiles) * zoomsz + zoomsz/2;
- searchy = ((iTile-iTopLeftTile)/nXTiles) * zoomsz + zoomsz/2 + moffset;
+ searchx = ((tileNum-iTopLeftTile)%nXTiles) * zoomsz + zoomsz/2;
+ searchy = ((tileNum-iTopLeftTile)/nXTiles) * zoomsz + zoomsz/2 + moffset;
}
}
@@ -3223,10 +3223,10 @@ static int32_t OnSaveTileGroup(void)
}
-static int32_t OnGotoTile(int32_t iTile)
+static int32_t OnGotoTile(int32_t tileNum)
{
//Automatically press 'V'
- iTile = SelectAllTiles(iTile);
+ tileNum = SelectAllTiles(tileNum);
return getnumber256("Goto tile: ", 0, MAXTILES-1, 0+2+16);
}
@@ -3253,7 +3253,7 @@ static int32_t LoadTileSet(const int32_t idCurrentTile, const int32_t *pIds, con
return iNewTile;
}
-static int32_t OnSelectTile(int32_t iTile)
+static int32_t OnSelectTile(int32_t tileNum)
{
int32_t bDone = 0;
int32_t i;
@@ -3262,10 +3262,10 @@ static int32_t OnSelectTile(int32_t iTile)
if (tile_groups <= 0)
{
TMPERRMSG_PRINT("No tile groups loaded. Check for existence of `%s'.", default_tiles_cfg);
- return iTile;
+ return tileNum;
}
- SelectAllTiles(iTile);
+ SelectAllTiles(tileNum);
bflushchars();
@@ -3316,7 +3316,7 @@ static int32_t OnSelectTile(int32_t iTile)
if (s_TileGroups[i].pIds != NULL && s_TileGroups[i].key1)
if (ch == s_TileGroups[i].key1 || ch == s_TileGroups[i].key2)
{
- iTile = LoadTileSet(iTile, s_TileGroups[i].pIds, s_TileGroups[i].nIds);
+ tileNum = LoadTileSet(tileNum, s_TileGroups[i].pIds, s_TileGroups[i].nIds);
bDone = 1;
}
}
@@ -3326,7 +3326,7 @@ static int32_t OnSelectTile(int32_t iTile)
clearkeys();
- return iTile;
+ return tileNum;
}
static const char *GetTilePixels(int32_t idTile)
@@ -3387,7 +3387,7 @@ static void classic_drawtilescreen(int32_t x, int32_t y, int32_t idTile, int32_t
static void tilescreen_drawbox(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles,
int32_t TileDim, int32_t offset,
- int32_t iTile, int32_t idTile)
+ int32_t tileNum, int32_t idTile)
{
int32_t marked = (IsValidTile(idTile) && tilemarked[idTile>>3]&(1<<(idTile&7)));
@@ -3395,10 +3395,10 @@ static void tilescreen_drawbox(int32_t iTopLeft, int32_t iSelected, int32_t nXTi
// Draw white box around currently selected tile or marked tile
// p1=(x1, y1), p2=(x1+TileDim-1, y1+TileDim-1)
//
- if (iTile == iSelected || marked)
+ if (tileNum == iSelected || marked)
{
- int32_t x1 = ((iTile-iTopLeft) % nXTiles)*TileDim;
- int32_t y1 = ((iTile - ((iTile-iTopLeft) % nXTiles) - iTopLeft)/nXTiles)*TileDim + offset;
+ int32_t x1 = ((tileNum-iTopLeft) % nXTiles)*TileDim;
+ int32_t y1 = ((tileNum - ((tileNum-iTopLeft) % nXTiles) - iTopLeft)/nXTiles)*TileDim + offset;
int32_t x2 = x1+TileDim-1;
int32_t y2 = y1+TileDim-1, oydim16=ydim16;
@@ -3416,7 +3416,7 @@ static void tilescreen_drawbox(int32_t iTopLeft, int32_t iSelected, int32_t nXTi
// box
int32_t xx[] = {x1, x1, x2, x2, x1};
int32_t yy[] = {y1, y2, y2, y1, y1};
- plotlines2d(xx, yy, 5, iTile==iSelected ? whitecol : markedcol);
+ plotlines2d(xx, yy, 5, tileNum==iSelected ? whitecol : markedcol);
}
// cross
@@ -3486,7 +3486,7 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i
int32_t TileDim, int32_t offset, int32_t showmsg)
{
int32_t XTile, YTile;
- int32_t iTile, idTile;
+ int32_t tileNum, idTile;
int32_t i, x, y;
const char *pRawPixels;
char szT[128];
@@ -3519,15 +3519,15 @@ restart:
{
for (XTile = 0; XTile < nXTiles; XTile++)
{
- iTile = iTopLeft + XTile + (YTile * nXTiles);
+ tileNum = iTopLeft + XTile + (YTile * nXTiles);
- if (iTile < 0 || iTile >= localartlookupnum)
+ if (tileNum < 0 || tileNum >= localartlookupnum)
continue;
#ifdef USE_OPENGL
usehitile = (runi || !lazyselector);
#endif
- idTile = localartlookup[ iTile ];
+ idTile = localartlookup[ tileNum ];
if (loadedhitile[idTile>>3]&(1<<(idTile&7)))
{
if (runi==1)
@@ -3552,14 +3552,14 @@ restart:
#endif
classic_drawtilescreen(x, y, idTile, TileDim, pRawPixels);
- if (localartfreq[iTile] != 0 && y >= 0 && y <= ydim-20)
+ if (localartfreq[tileNum] != 0 && y >= 0 && y <= ydim-20)
{
- Bsprintf(szT, "%d", localartfreq[iTile]);
+ Bsprintf(szT, "%d", localartfreq[tileNum]);
printext256(x, y, whitecol, -1, szT, 1);
}
}
- tilescreen_drawbox(iTopLeft, iSelected, nXTiles, TileDim, offset, iTile, idTile);
+ tilescreen_drawbox(iTopLeft, iSelected, nXTiles, TileDim, offset, tileNum, idTile);
if (runi==1 && lazyselector)
{
@@ -8995,7 +8995,7 @@ static int32_t osdcmd_do(const osdfuncparm_t *parm)
if (parm->numparms==0)
return OSDCMD_SHOWHELP;
- oscrofs = (g_scriptPtr-script);
+ oscrofs = (g_scriptPtr-apScript);
ofs = 2*(parm->numparms>0); // true if "do" command
slen = Bstrlen(parm->raw+ofs);
@@ -9032,15 +9032,15 @@ static int32_t osdcmd_do(const osdfuncparm_t *parm)
g_numSavedConstants = onumconstants;
*g_scriptPtr = CON_RETURN + (g_lineNumber<<12);
- g_scriptPtr = script + oscrofs;
+ g_scriptPtr = apScript + oscrofs;
- insptr = script + oscrofs;
+ insptr = apScript + oscrofs;
Bmemcpy(&vm, &vm_default, sizeof(vmstate_t));
if (in3dmode() && AIMING_AT_SPRITE)
{
- vm.g_i = searchwall;
- vm.g_sp = (uspritetype *)&sprite[vm.g_i];
+ vm.spriteNum = searchwall;
+ vm.pSprite = &sprite[vm.spriteNum];
}
// If OSD is down, that would interfere with user input, so don't consider
@@ -10166,16 +10166,16 @@ void ExtPreCheckKeys(void) // just before drawrooms
spritelightptr[i]->sector = sprite[i].sectnum;
spritelightptr[i]->flags.invalidate = 1;
}
- if (SHT != spritelightptr[i]->range)
+ if (SHT(i) != spritelightptr[i]->range)
{
- spritelightptr[i]->range = SHT;
+ spritelightptr[i]->range = SHT(i);
spritelightptr[i]->flags.invalidate = 1;
}
if (check_prlight_colors(i))
copy_prlight_colors(spritelightptr[i], i);
- if ((int)!!(CS & 128) != spritelightptr[i]->publicflags.negative)
+ if ((int)!!(CS(i) & 128) != spritelightptr[i]->publicflags.negative)
{
- spritelightptr[i]->publicflags.negative = !!(CS & 128);
+ spritelightptr[i]->publicflags.negative = !!(CS(i) & 128);
}
}
}
@@ -10189,10 +10189,10 @@ void ExtPreCheckKeys(void) // just before drawrooms
#pragma pack(push,1)
_prlight mylight;
#pragma pack(pop)
- mylight.radius = (256-(SS+128))<<1;
+ mylight.radius = (256-(SS(i)+128))<<1;
mylight.faderadius = (int16_t)(mylight.radius * 0.75f);
- mylight.tilenum = OW;
- mylight.publicflags.emitshadow = !(CS & 64);
+ mylight.tilenum = OW(i);
+ mylight.publicflags.emitshadow = !(CS(i) & 64);
addprlight_common1(&mylight, i);
}
@@ -10204,38 +10204,38 @@ void ExtPreCheckKeys(void) // just before drawrooms
spritelightptr[i]->sector = sprite[i].sectnum;
spritelightptr[i]->flags.invalidate = 1;
}
- if (SHT != spritelightptr[i]->range)
+ if (SHT(i) != spritelightptr[i]->range)
{
- spritelightptr[i]->range = SHT;
+ spritelightptr[i]->range = SHT(i);
spritelightptr[i]->flags.invalidate = 1;
}
if (check_prlight_colors(i))
copy_prlight_colors(spritelightptr[i], i);
- if (((256-(SS+128))<<1) != spritelightptr[i]->radius)
+ if (((256-(SS(i)+128))<<1) != spritelightptr[i]->radius)
{
- spritelightptr[i]->radius = (256-(SS+128))<<1;
+ spritelightptr[i]->radius = (256-(SS(i)+128))<<1;
spritelightptr[i]->faderadius = (int16_t)(spritelightptr[i]->radius * 0.75f);
spritelightptr[i]->flags.invalidate = 1;
}
- if (SA != spritelightptr[i]->angle)
+ if (SA(i) != spritelightptr[i]->angle)
{
- spritelightptr[i]->angle = SA;
+ spritelightptr[i]->angle = SA(i);
spritelightptr[i]->flags.invalidate = 1;
}
- if (SH != spritelightptr[i]->horiz)
+ if (SH(i) != spritelightptr[i]->horiz)
{
- spritelightptr[i]->horiz = SH;
+ spritelightptr[i]->horiz = SH(i);
spritelightptr[i]->flags.invalidate = 1;
}
- if ((int)!(CS & 64) != spritelightptr[i]->publicflags.emitshadow)
+ if ((int)!(CS(i) & 64) != spritelightptr[i]->publicflags.emitshadow)
{
- spritelightptr[i]->publicflags.emitshadow = !(CS & 64);
+ spritelightptr[i]->publicflags.emitshadow = !(CS(i) & 64);
}
- if ((int)!!(CS & 128) != spritelightptr[i]->publicflags.negative)
+ if ((int)!!(CS(i) & 128) != spritelightptr[i]->publicflags.negative)
{
- spritelightptr[i]->publicflags.negative = !!(CS & 128);
+ spritelightptr[i]->publicflags.negative = !!(CS(i) & 128);
}
- spritelightptr[i]->tilenum = OW;
+ spritelightptr[i]->tilenum = OW(i);
}
}
}
diff --git a/polymer/eduke32/source/cheats.c b/polymer/eduke32/source/cheats.c
index e3c660027..02b3e9cf0 100644
--- a/polymer/eduke32/source/cheats.c
+++ b/polymer/eduke32/source/cheats.c
@@ -392,7 +392,7 @@ void G_DoCheats(void)
}
else
{
- Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "Come Get Some!");
+ Bstrcpy(apStrings[QUOTE_RESERVED4], "Come Get Some!");
S_PlaySound(DUKE_GETWEAPON2);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
@@ -471,7 +471,7 @@ void G_DoCheats(void)
levnume--;
if ((VOLUMEONE && volnume > 0) || volnume > g_numVolumes-1 ||
- levnume >= MAXLEVELS || MapInfo[volnume *MAXLEVELS+levnume].filename == NULL)
+ levnume >= MAXLEVELS || aMapInfo[volnume *MAXLEVELS+levnume].filename == NULL)
{
end_cheat();
return;
@@ -581,7 +581,7 @@ void G_DoCheats(void)
case CHEAT_TODD:
if (NAM)
{
- Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], g_NAMMattCheatQuote);
+ Bstrcpy(apStrings[QUOTE_RESERVED4], g_NAMMattCheatQuote);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
}
else
@@ -619,7 +619,7 @@ void G_DoCheats(void)
if (++g_noEnemies == 3)
g_noEnemies = 0;
- Bsprintf(ScriptQuotes[QUOTE_RESERVED4], "Monsters: %s", s[g_noEnemies]);
+ Bsprintf(apStrings[QUOTE_RESERVED4], "Monsters: %s", s[g_noEnemies]);
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
end_cheat();
diff --git a/polymer/eduke32/source/demo.c b/polymer/eduke32/source/demo.c
index a20bcf2bb..b9321aca3 100644
--- a/polymer/eduke32/source/demo.c
+++ b/polymer/eduke32/source/demo.c
@@ -137,7 +137,7 @@ void G_OpenDemoWrite(void)
{
#ifdef LUNATIC
// TODO: Currently, we can't diff gamevars in Lunatic...
- Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "DEMOS UNSUPPORTED IN LUNATIC BUILD");
+ Bstrcpy(apStrings[QUOTE_RESERVED4], "DEMOS UNSUPPORTED IN LUNATIC BUILD");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
ud.recstat = ud.m_recstat = 0;
return;
@@ -153,7 +153,7 @@ void G_OpenDemoWrite(void)
if ((g_player[myconnectindex].ps->gm&MODE_GAME) && g_player[myconnectindex].ps->dead_flag)
{
- Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "CANNOT START DEMO RECORDING WHEN DEAD!");
+ Bstrcpy(apStrings[QUOTE_RESERVED4], "CANNOT START DEMO RECORDING WHEN DEAD!");
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
ud.recstat = ud.m_recstat = 0;
return;
@@ -162,8 +162,8 @@ void G_OpenDemoWrite(void)
if (demorec_diffs_cvar && !demorec_force_cvar)
for (i=1; i>12) && script[i+1]>=0 && script[i+1]>12) && apScript[i+1]>=0 && apScript[i+1]strength;
+ SH(i) = a->strength;
AC_ACTION_ID(actor[i].t_data) = a->act.id;
AC_MOVE_ID(actor[i].t_data) = a->mov.id;
Bmemcpy(&actor[i].ac, &a->act.ac, sizeof(struct action));
@@ -1405,58 +1405,58 @@ int32_t A_Spawn(int32_t j, int32_t pn)
Bmemset(&actor[i], 0, sizeof(actor_t));
Bmemcpy(&actor[i].bpos, &sprite[i], sizeof(vec3_t));
- actor[i].picnum = PN;
+ actor[i].picnum = PN(i);
- if (PN == SECTOREFFECTOR && SLT == 50)
- actor[i].picnum = OW;
+ if (PN(i) == SECTOREFFECTOR && SLT(i) == 50)
+ actor[i].picnum = OW(i);
- OW = actor[i].owner = i;
+ OW(i) = actor[i].owner = i;
- actor[i].floorz = sector[SECT].floorz;
- actor[i].ceilingz = sector[SECT].ceilingz;
+ actor[i].floorz = sector[SECT(i)].floorz;
+ actor[i].ceilingz = sector[SECT(i)].ceilingz;
actor[i].actorstayput = actor[i].lightId = actor[i].extra = -1;
- if ((CS&48) && PN != SPEAKER && PN != LETTER && PN != DUCK && PN != TARGET && PN != TRIPBOMB && PN != VIEWSCREEN && PN != VIEWSCREEN2)
- if (!(PN >= CRACK1 && PN <= CRACK4))
+ if ((CS(i)&48) && PN(i) != SPEAKER && PN(i) != LETTER && PN(i) != DUCK && PN(i) != TARGET && PN(i) != TRIPBOMB && PN(i) != VIEWSCREEN && PN(i) != VIEWSCREEN2)
+ if (!(PN(i) >= CRACK1 && PN(i) <= CRACK4))
{
- if (SS == 127)
+ if (SS(i) == 127)
goto SPAWN_END;
- if (A_CheckSwitchTile(i) && (CS&16))
+ if (A_CheckSwitchTile(i) && (CS(i)&16))
{
- if (sprite[i].pal && PN != ACCESSSWITCH && PN != ACCESSSWITCH2)
+ if (sprite[i].pal && PN(i) != ACCESSSWITCH && PN(i) != ACCESSSWITCH2)
{
if (((!g_netServer && ud.multimode < 2)) || ((g_netServer || ud.multimode > 1) && !GTFLAGS(GAMETYPE_DMSWITCHES)))
{
sprite[i].xrepeat = sprite[i].yrepeat = 0;
- SLT = SHT = 0;
+ SLT(i) = SHT(i) = 0;
sprite[i].cstat = 32768;
goto SPAWN_END;
}
}
- CS |= 257;
+ CS(i) |= 257;
- if (sprite[i].pal && PN != ACCESSSWITCH && PN != ACCESSSWITCH2)
+ if (sprite[i].pal && PN(i) != ACCESSSWITCH && PN(i) != ACCESSSWITCH2)
sprite[i].pal = 0;
goto SPAWN_END;
}
- if (SHT)
+ if (SHT(i))
{
changespritestat(i, STAT_FALLER);
- CS |= 257;
- SH = g_impactDamage;
+ CS(i) |= 257;
+ SH(i) = g_impactDamage;
goto SPAWN_END;
}
}
- if (CS&1)
- CS |= 256;
+ if (CS(i)&1)
+ CS(i) |= 256;
if (!G_InitActor(i, sprite[i].picnum, 0))
- T2 = T5 = 0; // AC_MOVE_ID, AC_ACTION_ID
+ T2(i) = T5(i) = 0; // AC_MOVE_ID, AC_ACTION_ID
}
sp = &sprite[i];
@@ -1466,8 +1466,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
if ((sp->picnum >= BOLT1 && sp->picnum <= BOLT1+3) ||
(sp->picnum >= SIDEBOLT1 && sp->picnum <= SIDEBOLT1+3))
{
- T1 = sp->xrepeat;
- T2 = sp->yrepeat;
+ T1(i) = sp->xrepeat;
+ T2(i) = sp->yrepeat;
sp->yvel = 0;
changespritestat(i, STAT_STANDABLE);
}
@@ -1567,11 +1567,11 @@ int32_t A_Spawn(int32_t j, int32_t pn)
{
if (sector[sprite[j].sectnum].lotag == ST_2_UNDERWATER)
{
- sp->z = getceilzofslope(SECT,SX,SY)+(16<<8);
+ sp->z = getceilzofslope(SECT(i),SX(i),SY(i))+(16<<8);
sp->cstat |= 8;
}
else if (sector[sprite[j].sectnum].lotag == ST_1_ABOVE_WATER)
- sp->z = getflorzofslope(SECT,SX,SY);
+ sp->z = getflorzofslope(SECT(i),SX(i),SY(i));
}
if (sector[sect].floorpicnum == FLOORSLIME ||
@@ -1657,7 +1657,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
{
sp->xrepeat = sprite[j].xrepeat;
sp->yrepeat = sprite[j].yrepeat;
- T2 = sprite[j].picnum;
+ T2(i) = sprite[j].picnum;
}
else sp->xrepeat = sp->yrepeat = 0;
@@ -1752,7 +1752,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
}
- if (sector[SECT].lotag == ST_1_ABOVE_WATER)
+ if (sector[SECT(i)].lotag == ST_1_ABOVE_WATER)
{
changespritestat(i, STAT_MISC);
break;
@@ -2047,8 +2047,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
case SPOTLITE__STATIC:
- T1 = sp->x;
- T2 = sp->y;
+ T1(i) = sp->x;
+ T2(i) = sp->y;
break;
case BULLETHOLE__STATIC:
sp->xrepeat = sp->yrepeat = 3;
@@ -2087,7 +2087,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
a = ps->ang-(krand()&63)+8; //Fine tune
- T1 = krand()&1;
+ T1(i) = krand()&1;
sp->z = (3<<8) + ps->pyoff + ps->pos.z - ((ps->horizoff + ps->horiz-100)<<4);
if (sp->picnum == SHOTGUNSHELL)
sp->z += (3<<8);
@@ -2174,8 +2174,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
if (j >= 0)
{
int32_t z = getflorzofslope(sp->sectnum,sp->x,sp->y);
- if (sp->z > z-(12<<8))
- sp->z = z-(12<<8);
+ if (sp->z > z-ZOFFSET4)
+ sp->z = z-ZOFFSET4;
}
changespritestat(i, STAT_MISC);
@@ -2223,7 +2223,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
sp->picnum += 2;
sp->z = sector[sect].ceilingz+(48<<8);
- T5 = tempwallptr;
+ T5(i) = tempwallptr;
g_origins[tempwallptr] = *(vec2_t *) sp;
g_origins[tempwallptr+2].x = sp->z;
@@ -2231,11 +2231,11 @@ int32_t A_Spawn(int32_t j, int32_t pn)
s = headspritestat[STAT_DEFAULT];
while (s >= 0)
{
- if (sprite[s].picnum == CRANEPOLE && SHT == (sprite[s].hitag))
+ if (sprite[s].picnum == CRANEPOLE && SHT(i) == (sprite[s].hitag))
{
g_origins[tempwallptr+2].y = s;
- T2 = sprite[s].sectnum;
+ T2(i) = sprite[s].sectnum;
sprite[s].xrepeat = 48;
sprite[s].yrepeat = 128;
@@ -2279,8 +2279,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
else if (j == -1)
{
sp->z += (4<<8);
- T1 = sp->z;
- T2 = krand()&127;
+ T1(i) = sp->z;
+ T2(i) = krand()&127;
}
case WATERDRIPSPLASH__STATIC:
sp->xrepeat = sp->yrepeat = 24;
@@ -2292,7 +2292,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
changespritestat(i, STAT_STANDABLE);
break;
case TOUCHPLATE__STATIC:
- T3 = sector[sect].floorz;
+ T3(i) = sector[sect].floorz;
if (sector[sect].lotag != ST_1_ABOVE_WATER && sector[sect].lotag != ST_2_UNDERWATER)
sector[sect].floorz = sp->z;
if (sp->pal && (g_netServer || ud.multimode > 1))
@@ -2502,7 +2502,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case REACTOR2__STATIC:
case REACTOR__STATIC:
sp->extra = g_impactDamage;
- CS |= 257;
+ CS(i) |= 257;
if ((!g_netServer && ud.multimode < 2) && sp->pal != 0)
{
sp->xrepeat = sp->yrepeat = 0;
@@ -2510,7 +2510,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
}
sp->pal = 0;
- SS = -17;
+ SS(i) = -17;
changespritestat(i, STAT_ZOMBIEACTOR);
break;
@@ -2522,7 +2522,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
sp->xrepeat = sp->yrepeat = 9;
sp->yvel = 4;
- CS |= 257;
+ CS(i) |= 257;
if ((!g_netServer && ud.multimode < 2) && sp->pal != 0)
{
@@ -2531,7 +2531,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
}
sp->pal = 0;
- SS = -17;
+ SS(i) = -17;
changespritestat(i, STAT_ZOMBIEACTOR);
break;
@@ -2552,7 +2552,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
}
sp->extra = 130;
- CS |= 256; // Make it hitable
+ CS(i) |= 256; // Make it hitable
if ((!g_netServer && ud.multimode < 2) && sp->pal != 0)
{
@@ -2561,7 +2561,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
}
sp->pal = 0;
- SS = -17;
+ SS(i) = -17;
changespritestat(i, STAT_ZOMBIEACTOR);
break;
@@ -2650,14 +2650,14 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
case WATERFOUNTAIN__STATIC:
- SLT = 1;
+ SLT(i) = 1;
case TREE1__STATIC:
case TREE2__STATIC:
case TIRE__STATIC:
case CONE__STATIC:
case BOX__STATIC:
- CS = 257; // Make it hitable
+ CS(i) = 257; // Make it hitable
sprite[i].extra = 1;
changespritestat(i, STAT_STANDABLE);
break;
@@ -2734,7 +2734,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
switch (sp->lotag)
{
case SE_28_LIGHTNING:
- T6 = 65;// Delay for lightning
+ T6(i) = 65;// Delay for lightning
break;
case SE_7_TELEPORT: // Transporters!!!!
case SE_23_ONE_WAY_TELEPORT:// XPTR END
@@ -2742,33 +2742,33 @@ int32_t A_Spawn(int32_t j, int32_t pn)
{
for (j=0; jcstat = 0;
changespritestat(i, STAT_TRANSPORT);
goto SPAWN_END;
case SE_1_PIVOT:
sp->owner = -1;
- T1 = 1;
+ T1(i) = 1;
break;
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
if (sp->ang == 512)
{
- T2 = sector[sect].ceilingz;
+ T2(i) = sector[sect].ceilingz;
if (sp->pal)
sector[sect].ceilingz = sp->z;
}
else
{
- T2 = sector[sect].floorz;
+ T2(i) = sector[sect].floorz;
if (sp->pal)
sector[sect].floorz = sp->z;
}
@@ -2780,8 +2780,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
sp->owner = -1;
break;
case SE_25_PISTON: // Pistons
- T4 = sector[sect].ceilingz;
- T5 = 1;
+ T4(i) = sector[sect].ceilingz;
+ T5(i) = 1;
sector[sect].ceilingz = sp->z;
G_SetInterpolation(§or[sect].ceilingz);
break;
@@ -2797,16 +2797,16 @@ int32_t A_Spawn(int32_t j, int32_t pn)
break;
case SE_12_LIGHT_SWITCH:
- T2 = sector[sect].floorshade;
- T3 = sector[sect].ceilingshade;
+ T2(i) = sector[sect].floorshade;
+ T3(i) = sector[sect].ceilingshade;
break;
case SE_13_EXPLOSIVE:
- T1 = sector[sect].ceilingz;
- T2 = sector[sect].floorz;
+ T1(i) = sector[sect].ceilingz;
+ T2(i) = sector[sect].floorz;
- if (klabs(T1-sp->z) < klabs(T2-sp->z))
+ if (klabs(T1(i)-sp->z) < klabs(T2(i)-sp->z))
sp->owner = 1;
else sp->owner = 0;
@@ -2845,12 +2845,12 @@ int32_t A_Spawn(int32_t j, int32_t pn)
if (sector[sect].ceilingstat&1)
{
sector[sect].ceilingstat ^= 1;
- T4 = 1;
+ T4(i) = 1;
if (!sp->owner && sp->ang==512)
{
sector[sect].ceilingstat ^= 1;
- T4 = 0;
+ T4(i) = 0;
}
sector[sect].ceilingshade =
@@ -2880,16 +2880,16 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case SE_17_WARP_ELEVATOR:
- T3 = sector[sect].floorz; //Stopping loc
+ T3(i) = sector[sect].floorz; //Stopping loc
j = nextsectorneighborz(sect,sector[sect].floorz,-1,-1);
if (EDUKE32_PREDICT_TRUE(j >= 0))
- T4 = sector[j].ceilingz;
+ T4(i) = sector[j].ceilingz;
else
{
// use elevator sector's ceiling as heuristic
- T4 = sector[sect].ceilingz;
+ T4(i) = sector[sect].ceilingz;
OSD_Printf(OSD_ERROR "WARNING: SE17 sprite %d using own sector's ceilingz to "
"determine when to warp. Sector %d adjacent to a door?\n", i, sect);
@@ -2898,7 +2898,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
j = nextsectorneighborz(sect,sector[sect].ceilingz,1,1);
if (EDUKE32_PREDICT_TRUE(j >= 0))
- T5 = sector[j].floorz;
+ T5(i) = sector[j].floorz;
else
{
// XXX: we should return to the menu for this and similar failures
@@ -2942,7 +2942,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
}
}
- T2 = clostest;
+ T2(i) = clostest;
q = INT32_MAX;
@@ -2952,21 +2952,21 @@ int32_t A_Spawn(int32_t j, int32_t pn)
y = wall[s].y;
d = FindDistance2D(sp->x-x,sp->y-y);
- if (d < q && s != T2)
+ if (d < q && s != T2(i))
{
q = d;
clostest = s;
}
}
- T3 = clostest;
+ T3(i) = clostest;
}
break;
case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT:
- T4=sector[sect].floorshade;
+ T4(i)=sector[sect].floorshade;
sector[sect].floorshade = sp->shade;
sector[sect].ceilingshade = sp->shade;
@@ -2990,7 +2990,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case SE_31_FLOOR_RISE_FALL:
{
- T2 = sector[sect].floorz;
+ T2(i) = sector[sect].floorz;
// T3 = sp->hitag;
if (sp->ang != 1536)
{
@@ -3011,8 +3011,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case SE_32_CEILING_RISE_FALL:
{
- T2 = sector[sect].ceilingz;
- T3 = sp->hitag;
+ T2(i) = sector[sect].ceilingz;
+ T3(i) = sp->hitag;
if (sp->ang != 1536)
{
sector[sect].ceilingz = sp->z;
@@ -3032,7 +3032,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case SE_4_RANDOM_LIGHTS: //Flashing lights
- T3 = sector[sect].floorshade;
+ T3(i) = sector[sect].floorshade;
startwall = sector[sect].wallptr;
endwall = startwall+sector[sect].wallnum;
@@ -3041,8 +3041,8 @@ int32_t A_Spawn(int32_t j, int32_t pn)
sp->owner |= sector[sect].floorpal;
for (s=startwall; s T4)
- T4 = wall[s].shade;
+ if (wall[s].shade > T4(i))
+ T4(i) = wall[s].shade;
break;
@@ -3053,22 +3053,22 @@ int32_t A_Spawn(int32_t j, int32_t pn)
case SE_8_UP_OPEN_DOOR_LIGHTS:
//First, get the ceiling-floor shade
- T1 = sector[sect].floorshade;
- T2 = sector[sect].ceilingshade;
+ T1(i) = sector[sect].floorshade;
+ T2(i) = sector[sect].ceilingshade;
startwall = sector[sect].wallptr;
endwall = startwall+sector[sect].wallnum;
for (s=startwall; s T3)
- T3 = wall[s].shade;
+ if (wall[s].shade > T3(i))
+ T3(i) = wall[s].shade;
- T4 = 1; //Take Out;
+ T4(i) = 1; //Take Out;
break;
case SE_11_SWINGING_DOOR://Pivitor rotater
- T4 = (sp->ang > 1024) ? 2 : -2;
+ T4(i) = (sp->ang > 1024) ? 2 : -2;
/* fall-through */
case SE_0_ROTATING_SECTOR:
case SE_2_EARTHQUAKE://Earthquakemakers
@@ -3084,7 +3084,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
if (sector[sect].lotag == ST_30_ROTATE_RISE_BRIDGE)
{
sprite[i].clipdist = (sp->pal) ? 1 : 0;
- T4 = sector[sect].floorz;
+ T4(i) = sector[sect].floorz;
sector[sect].hitag = i;
}
@@ -3116,7 +3116,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
startwall = sector[sect].wallptr;
endwall = startwall+sector[sect].wallnum;
- T2 = tempwallptr;
+ T2(i) = tempwallptr;
for (s=startwall; sx;
@@ -3191,19 +3191,19 @@ int32_t A_Spawn(int32_t j, int32_t pn)
}
sp->owner = -1;
- T1 = s;
+ T1(i) = s;
if (sp->lotag != SE_30_TWO_WAY_TRAIN)
- T4 = sp->hitag;
+ T4(i) = sp->hitag;
}
else if (sp->lotag == SE_16_REACTOR)
- T4 = sector[sect].ceilingz;
+ T4(i) = sector[sect].ceilingz;
else if (sp->lotag == SE_26)
{
- T4 = sp->x;
- T5 = sp->y;
+ T4(i) = sp->x;
+ T5(i) = sp->y;
if (sp->shade==sector[sect].floorshade) //UP
sp->zvel = -256;
else
@@ -3213,7 +3213,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
}
else if (sp->lotag == SE_2_EARTHQUAKE)
{
- T6 = sector[sp->sectnum].floorheinum;
+ T6(i) = sector[sp->sectnum].floorheinum;
sector[sp->sectnum].floorheinum = 0;
}
}
@@ -3743,7 +3743,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
const int viewscrShift = G_GetViewscreenSizeShift(t);
const int viewscrTile = TILE_VIEWSCR-viewscrShift;
- if (g_curViewscreen >= 0 && actor[OW].t_data[0] == 1)
+ if (g_curViewscreen >= 0 && actor[OW(i)].t_data[0] == 1)
{
t->picnum = STATIC;
t->cstat |= (rand()&12);
@@ -3875,7 +3875,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
newt->picnum = (curweap==GROW_WEAPON ? GROWSPRITEICON : WeaponPickupSprites[curweap]);
if (s->owner >= 0)
- newt->z = g_player[p].ps->pos.z-(12<<8);
+ newt->z = g_player[p].ps->pos.z-ZOFFSET4;
else
newt->z = s->z-(51<<8);
@@ -4025,7 +4025,7 @@ PALONLY:
case SCRAP5__STATIC:
if (actor[i].picnum == BLIMP && t->picnum == SCRAP1 && s->yvel >= 0)
t->picnum = s->yvel < MAXUSERTILES ? s->yvel : 0;
- else t->picnum += T1;
+ else t->picnum += T1(i);
t->shade -= 6;
G_MaybeTakeOnFloorPal(t, sect);
@@ -4048,7 +4048,7 @@ PALONLY:
if ((unsigned)scrofs_action + 2 >= (unsigned)g_scriptSize)
goto skip;
- l = script[scrofs_action + 2];
+ l = apScript[scrofs_action + 2];
#else
l = viewtype;
#endif
@@ -4102,7 +4102,7 @@ PALONLY:
l = klabs(l);
#if !defined LUNATIC
- t->picnum += k + script[scrofs_action] + l*curframe;
+ t->picnum += k + apScript[scrofs_action] + l*curframe;
#else
t->picnum += k + startframe + l*curframe;
#endif
@@ -4162,7 +4162,7 @@ skip:
else
daz = actor[i].floorz;
- if ((s->z-daz) < (8<<8) && g_player[screenpeek].ps->pos.z < daz)
+ if ((s->z-daz) < ZOFFSET3 && g_player[screenpeek].ps->pos.z < daz)
{
uspritetype *const newt = &tsprite[spritesortcnt];
@@ -4259,21 +4259,21 @@ skip:
#endif
k = getofs_viewtype5(t, t, oura, 0);
- t->picnum = s->picnum+k+((T1<4)*5);
+ t->picnum = s->picnum+k+((T1(i)<4)*5);
t->shade = sprite[s->owner].shade;
break;
case WATERSPLASH2__STATIC:
// WATERSPLASH_T2
- t->picnum = WATERSPLASH2+T2;
+ t->picnum = WATERSPLASH2+T2(i);
break;
case SHELL__STATIC:
- t->picnum = s->picnum+(T1&1);
+ t->picnum = s->picnum+(T1(i)&1);
case SHOTGUNSHELL__STATIC:
t->cstat |= 12;
- if (T1 > 2) t->cstat &= ~16;
- else if (T1 > 1) t->cstat &= ~4;
+ if (T1(i) > 2) t->cstat &= ~16;
+ else if (T1(i) > 1) t->cstat &= ~4;
break;
case FRAMEEFFECT1_13__STATIC:
if (PLUTOPAK) break;
@@ -4383,12 +4383,12 @@ int32_t G_StartRTS(int32_t i, int localp)
void G_StartMusic(void)
{
const int32_t i = g_musicIndex;
- Bassert(MapInfo[i].musicfn != NULL);
+ Bassert(aMapInfo[i].musicfn != NULL);
{
- S_PlayMusic(MapInfo[i].musicfn);
+ S_PlayMusic(aMapInfo[i].musicfn);
- Bsnprintf(ScriptQuotes[QUOTE_MUSIC], MAXQUOTELEN, "Playing %s", MapInfo[i].musicfn);
+ Bsnprintf(apStrings[QUOTE_MUSIC], MAXQUOTELEN, "Playing %s", aMapInfo[i].musicfn);
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
}
}
@@ -4619,7 +4619,7 @@ void G_HandleLocalKeys(void)
if (g_musicIndex >= maxi)
g_musicIndex = 0;
}
- while (MapInfo[g_musicIndex].musicfn == NULL);
+ while (aMapInfo[g_musicIndex].musicfn == NULL);
G_StartMusic();
@@ -4788,8 +4788,8 @@ FAKE_F3:
if (KB_UnBoundKeyPressed(sc_F5) && ud.config.MusicToggle)
{
- map_t *map = &MapInfo[g_musicIndex];
- char *const qmusic = ScriptQuotes[QUOTE_MUSIC];
+ map_t *map = &aMapInfo[g_musicIndex];
+ char *const qmusic = apStrings[QUOTE_MUSIC];
KB_ClearKeyDown(sc_F5);
@@ -4825,7 +4825,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], MapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, 19);
+ Bstrncpy(&ud.savegame[g_lastSaveSlot][0], aMapInfo[ud.volume_number * MAXLEVELS + ud.level_number].name, 19);
ud.savegame[g_lastSaveSlot][MAXSAVEGAMENAME-2] = 127;
}
@@ -5020,7 +5020,7 @@ static int32_t S_DefineMusic(const char *ID, const char *name)
return -1;
}
- return S_DefineAudioIfSupported(&MapInfo[sel].musicfn, name);
+ return S_DefineAudioIfSupported(&aMapInfo[sel].musicfn, name);
}
static int32_t parsedefinitions_game(scriptfile *script, int32_t preload);
@@ -5447,17 +5447,17 @@ static void G_Cleanup(void)
for (i=(MAXLEVELS*(MAXVOLUMES+1))-1; i>=0; i--) // +1 volume for "intro", "briefing" music
{
- Bfree(MapInfo[i].name);
- Bfree(MapInfo[i].filename);
- Bfree(MapInfo[i].musicfn);
+ Bfree(aMapInfo[i].name);
+ Bfree(aMapInfo[i].filename);
+ Bfree(aMapInfo[i].musicfn);
G_FreeMapState(i);
}
for (i=MAXQUOTES-1; i>=0; i--)
{
- Bfree(ScriptQuotes[i]);
- Bfree(ScriptQuoteRedefinitions[i]);
+ Bfree(apStrings[i]);
+ Bfree(apXStrings[i]);
}
for (i=MAXPLAYERS-1; i>=0; i--)
@@ -5473,7 +5473,7 @@ static void G_Cleanup(void)
#if !defined LUNATIC
if (label != (char *)&sprite[0]) Bfree(label);
if (labelcode != (int32_t *)§or[0]) Bfree(labelcode);
- Bfree(script);
+ Bfree(apScript);
Bfree(bitptr);
// Bfree(MusicPtr);
@@ -6768,7 +6768,7 @@ int32_t G_DoMoveThings(void)
{
if (ldist(&sprite[p->i], &sprite[hit.sprite]) < 9216)
{
- Bsprintf(ScriptQuotes[QUOTE_RESERVED3], "%s", &g_player[snum].user_name[0]);
+ Bsprintf(apStrings[QUOTE_RESERVED3], "%s", &g_player[snum].user_name[0]);
p->fta = 12, p->ftq = QUOTE_RESERVED3;
}
}
@@ -6908,8 +6908,8 @@ void A_SpawnWallGlass(int32_t i,int32_t wallnum,int32_t n)
{
for (j=n-1; j >= 0 ; j--)
{
- a = SA-256+(krand()&511)+1024;
- A_InsertSprite(SECT,SX,SY,SZ,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&1023),i,5);
+ a = SA(i)-256+(krand()&511)+1024;
+ A_InsertSprite(SECT(i),SX(i),SY(i),SZ(i),GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&1023),i,5);
}
return;
}
@@ -6938,9 +6938,9 @@ void A_SpawnWallGlass(int32_t i,int32_t wallnum,int32_t n)
{
z = sector[sect].floorz-(krand()&(klabs(sector[sect].ceilingz-sector[sect].floorz)));
if (z < -(32<<8) || z > (32<<8))
- z = SZ-(32<<8)+(krand()&((64<<8)-1));
- a = SA-1024;
- A_InsertSprite(SECT,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&1023),i,5);
+ z = SZ(i)-(32<<8)+(krand()&((64<<8)-1));
+ a = SA(i)-1024;
+ A_InsertSprite(SECT(i),x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&1023),i,5);
}
}
}
@@ -6949,7 +6949,7 @@ void A_SpawnGlass(int32_t i,int32_t n)
{
for (; n>0; n--)
{
- int32_t k = A_InsertSprite(SECT,SX,SY,SZ-((krand()&16)<<8),GLASSPIECES+(n%3),
+ int32_t k = A_InsertSprite(SECT(i),SX(i),SY(i),SZ(i)-((krand()&16)<<8),GLASSPIECES+(n%3),
krand()&15,36,36,krand()&2047,32+(krand()&63),-512-(krand()&2047),i,5);
sprite[k].pal = sprite[i].pal;
}
@@ -6991,7 +6991,7 @@ void A_SpawnRandomGlass(int32_t i,int32_t wallnum,int32_t n)
for (j=n-1; j >= 0 ; j--)
{
a = krand()&2047;
- k = A_InsertSprite(SECT,SX,SY,SZ-(krand()&(63<<8)),GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&2047),i,5);
+ k = A_InsertSprite(SECT(i),SX(i),SY(i),SZ(i)-(krand()&(63<<8)),GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),1024-(krand()&2047),i,5);
sprite[k].pal = krand()&15;
}
return;
@@ -7012,9 +7012,9 @@ void A_SpawnRandomGlass(int32_t i,int32_t wallnum,int32_t n)
updatesector(x1,y1,§);
z = sector[sect].floorz-(krand()&(klabs(sector[sect].ceilingz-sector[sect].floorz)));
if (z < -(32<<8) || z > (32<<8))
- z = SZ-(32<<8)+(krand()&((64<<8)-1));
- a = SA-1024;
- k = A_InsertSprite(SECT,x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&2047),i,5);
+ z = SZ(i)-(32<<8)+(krand()&((64<<8)-1));
+ a = SA(i)-1024;
+ k = A_InsertSprite(SECT(i),x1,y1,z,GLASSPIECES+(j%3),-32,36,36,a,32+(krand()&63),-(krand()&2047),i,5);
sprite[k].pal = krand()&7;
}
}
diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h
index d01bba390..d6352f00f 100644
--- a/polymer/eduke32/source/game.h
+++ b/polymer/eduke32/source/game.h
@@ -98,7 +98,7 @@ enum LogoFlags_t {
LOGO_NODUKETEAMPIC = 0x00100000,
};
-void A_DeleteSprite(int32_t s);
+void A_DeleteSprite(int spriteNum);
static inline int32_t G_GetLogoFlags(void)
{
@@ -366,7 +366,7 @@ static inline int32_t G_GetTeamPalette(int32_t team)
return pal[team];
}
-#define A_CheckSpriteFlags(iActor, iType) (((g_tile[sprite[iActor].picnum].flags^actor[iActor].flags) & iType) != 0)
+#define A_CheckSpriteFlags(spriteNum, iType) (((g_tile[sprite[spriteNum].picnum].flags^actor[spriteNum].flags) & iType) != 0)
// (unsigned)iPicnum check: AMC TC Rusty Nails, bayonet MG alt. fire, iPicnum == -1 (via aplWeaponShoots)
#define A_CheckSpriteTileFlags(iPicnum, iType) (((unsigned)iPicnum < MAXTILES) && (g_tile[iPicnum].flags & iType) != 0)
#define S_StopSound(num) S_StopEnvSound(num, -1)
diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c
index 850e93fe0..cc9365efb 100644
--- a/polymer/eduke32/source/gamedef.c
+++ b/polymer/eduke32/source/gamedef.c
@@ -63,7 +63,7 @@ static int32_t C_ParseCommand(int32_t loop);
static int32_t C_SetScriptSize(int32_t size);
#endif
-int32_t g_numQuoteRedefinitions = 0;
+int32_t g_numXStrings = 0;
#ifdef LUNATIC
weapondata_t g_playerWeapon[MAXPLAYERS][MAX_WEAPONS];
@@ -1322,7 +1322,7 @@ static int32_t g_ifElseAborted;
static int32_t C_SetScriptSize(int32_t newsize)
{
- intptr_t const oscript = (intptr_t)script;
+ intptr_t const oscript = (intptr_t)apScript;
intptr_t *newscript;
intptr_t i, j;
int32_t osize = g_scriptSize;
@@ -1335,23 +1335,23 @@ static int32_t C_SetScriptSize(int32_t newsize)
{
if (BITPTR_IS_POINTER(i))
{
- if (EDUKE32_PREDICT_FALSE((intptr_t)script[i] < (intptr_t)&script[0] || (intptr_t)script[i] >= (intptr_t)&script[g_scriptSize]))
+ if (EDUKE32_PREDICT_FALSE((intptr_t)apScript[i] < (intptr_t)&apScript[0] || (intptr_t)apScript[i] >= (intptr_t)&apScript[g_scriptSize]))
{
g_numCompilerErrors++;
initprintf("Internal compiler error at %" PRIdPTR " (0x%" PRIxPTR ")\n",i,i);
- VM_ScriptInfo(&script[i], 16);
+ VM_ScriptInfo(&apScript[i], 16);
}
scriptptrs[i] = 1;
- script[i] -= (intptr_t)&script[0];
+ apScript[i] -= (intptr_t)&apScript[0];
}
else scriptptrs[i] = 0;
}
- G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), script, P2I_FWD_NON0);
- G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), script, P2I_FWD_NON0);
+ G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_FWD_NON0);
+ G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_FWD_NON0);
- newscript = (intptr_t *)Xrealloc(script, newsize * sizeof(intptr_t));
+ newscript = (intptr_t *)Xrealloc(apScript, newsize * sizeof(intptr_t));
newbitptr = (char *)Xcalloc(1,(((newsize+7)>>3)+1) * sizeof(uint8_t));
if (newsize >= osize)
@@ -1364,27 +1364,27 @@ static int32_t C_SetScriptSize(int32_t newsize)
Bfree(bitptr);
bitptr = newbitptr;
- if (script != newscript)
+ if (apScript != newscript)
{
- initprintf("Relocating compiled code from to 0x%" PRIxPTR " to 0x%" PRIxPTR "\n", (intptr_t)script, (intptr_t)newscript);
- script = newscript;
+ initprintf("Relocating compiled code from to 0x%" PRIxPTR " to 0x%" PRIxPTR "\n", (intptr_t)apScript, (intptr_t)newscript);
+ apScript = newscript;
}
g_scriptSize = newsize;
- g_scriptPtr = script + (intptr_t)g_scriptPtr - oscript;
+ g_scriptPtr = apScript + (intptr_t)g_scriptPtr - oscript;
if (g_caseScriptPtr)
- g_caseScriptPtr = script + (intptr_t)g_caseScriptPtr - oscript;
+ g_caseScriptPtr = apScript + (intptr_t)g_caseScriptPtr - oscript;
for (i=(((newsize>=osize)?osize:newsize))-1; i>=0; i--)
if (scriptptrs[i])
{
- j = (intptr_t)script[i]+(intptr_t)&script[0];
- script[i] = j;
+ j = (intptr_t)apScript[i]+(intptr_t)&apScript[0];
+ apScript[i] = j;
}
- G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), script, P2I_BACK_NON0);
- G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), script, P2I_BACK_NON0);
+ G_Util_PtrToIdx2(&g_tile[0].execPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_BACK_NON0);
+ G_Util_PtrToIdx2(&g_tile[0].loadPtr, MAXTILES, sizeof(tiledata_t), apScript, P2I_BACK_NON0);
Bfree(scriptptrs);
return 0;
@@ -1473,7 +1473,7 @@ static int32_t C_SkipComments(void)
continue;
}
case 0: // EOF
- return ((g_scriptPtr-script) > (g_scriptSize-32)) ? C_SetScriptSize(g_scriptSize<<1) : 0;
+ return ((g_scriptPtr-apScript) > (g_scriptSize-32)) ? C_SetScriptSize(g_scriptSize<<1) : 0;
}
}
while (1);
@@ -1576,7 +1576,7 @@ static int32_t C_GetNextKeyword(void) //Returns its code #
*g_scriptPtr = i + (IFELSE_MAGIC<<12);
else *g_scriptPtr = i + (g_lineNumber<<12);
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
textptr += l;
g_scriptPtr++;
@@ -1653,7 +1653,7 @@ static void C_GetNextVarType(int32_t type)
if (!type && !g_labelsOnly && (isdigit(*textptr) || ((*textptr == '-') && (isdigit(*(textptr+1))))))
{
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++ = MAXGAMEVARS;
@@ -1666,7 +1666,7 @@ static void C_GetNextVarType(int32_t type)
initprintf("%s:%d: debug: constant %ld in place of gamevar.\n",
g_szScriptFileName,g_lineNumber,(long)*g_scriptPtr);
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
g_scriptPtr++;
#if 1
while (!ispecial(*textptr) && *textptr != ']') textptr++;
@@ -1704,7 +1704,7 @@ static void C_GetNextVarType(int32_t type)
C_SkipComments(); //skip comments and whitespace
if (*textptr == '[') //read of array as a gamevar
{
- int32_t lLabelID = -1;
+ int32_t labelNum = -1;
f |= (MAXGAMEVARS<<2);
textptr++;
@@ -1712,7 +1712,7 @@ static void C_GetNextVarType(int32_t type)
if (i < 0)
{
i=GetDefID(label+(g_numLabels<<6));
- if ((unsigned) (i - g_iStructVarIDs) >= NUMQUICKSTRUCTS)
+ if ((unsigned) (i - g_structVarIDs) >= NUMQUICKSTRUCTS)
i = -1;
if (EDUKE32_PREDICT_FALSE(i < 0))
@@ -1725,10 +1725,10 @@ static void C_GetNextVarType(int32_t type)
f |= (MAXGAMEVARS<<3);
}
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=(i|f);
- if ((f & (MAXGAMEVARS<<3)) && i - g_iStructVarIDs == STRUCT_USERDEF)
+ if ((f & (MAXGAMEVARS<<3)) && i - g_structVarIDs == STRUCT_USERDEF)
{
// userdef doesn't really have an array index
while (*textptr != ']')
@@ -1741,15 +1741,15 @@ static void C_GetNextVarType(int32_t type)
textptr++;
}
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++ = 0; // help out the VM by inserting a dummy index
}
else
{
if (*textptr == ']')
{
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++ = g_iThisActorID;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++ = g_thisActorVarID;
}
else
C_GetNextVarType(0);
@@ -1797,96 +1797,96 @@ static void C_GetNextVarType(int32_t type)
C_GetNextLabelName();
/*initprintf("found xxx label of \"%s\"\n", label+(g_numLabels<<6));*/
- switch (i - g_iStructVarIDs)
+ switch (i - g_structVarIDs)
{
case STRUCT_SPRITE:
- lLabelID=C_GetLabelNameOffset(&h_actor,Bstrtolower(label+(g_numLabels<<6)));
+ labelNum=C_GetLabelNameOffset(&h_actor,Bstrtolower(label+(g_numLabels<<6)));
break;
case STRUCT_SECTOR:
- lLabelID=C_GetLabelNameOffset(&h_sector,Bstrtolower(label+(g_numLabels<<6)));
+ labelNum=C_GetLabelNameOffset(&h_sector,Bstrtolower(label+(g_numLabels<<6)));
break;
case STRUCT_WALL:
- lLabelID=C_GetLabelNameOffset(&h_wall,Bstrtolower(label+(g_numLabels<<6)));
+ labelNum=C_GetLabelNameOffset(&h_wall,Bstrtolower(label+(g_numLabels<<6)));
break;
case STRUCT_PLAYER:
- lLabelID=C_GetLabelNameOffset(&h_player,Bstrtolower(label+(g_numLabels<<6)));
+ labelNum=C_GetLabelNameOffset(&h_player,Bstrtolower(label+(g_numLabels<<6)));
break;
case STRUCT_ACTORVAR:
case STRUCT_PLAYERVAR:
- lLabelID=GetDefID(label+(g_numLabels<<6));
+ labelNum=GetDefID(label+(g_numLabels<<6));
break;
case STRUCT_TSPR:
- lLabelID=C_GetLabelNameOffset(&h_tsprite,Bstrtolower(label+(g_numLabels<<6)));
+ labelNum=C_GetLabelNameOffset(&h_tsprite,Bstrtolower(label+(g_numLabels<<6)));
break;
case STRUCT_PROJECTILE:
case STRUCT_THISPROJECTILE:
- lLabelID=C_GetLabelNameOffset(&h_projectile,Bstrtolower(label+(g_numLabels<<6)));
+ labelNum=C_GetLabelNameOffset(&h_projectile,Bstrtolower(label+(g_numLabels<<6)));
break;
case STRUCT_USERDEF:
- lLabelID=C_GetLabelNameOffset(&h_userdef,Bstrtolower(label+(g_numLabels<<6)));
+ labelNum=C_GetLabelNameOffset(&h_userdef,Bstrtolower(label+(g_numLabels<<6)));
break;
case STRUCT_INPUT:
- lLabelID=C_GetLabelNameOffset(&h_input,Bstrtolower(label+(g_numLabels<<6)));
+ labelNum=C_GetLabelNameOffset(&h_input,Bstrtolower(label+(g_numLabels<<6)));
break;
case STRUCT_TILEDATA:
- lLabelID=C_GetLabelNameOffset(&h_tiledata,Bstrtolower(label+(g_numLabels<<6)));
+ labelNum=C_GetLabelNameOffset(&h_tiledata,Bstrtolower(label+(g_numLabels<<6)));
break;
case STRUCT_PALDATA:
- lLabelID=C_GetLabelNameOffset(&h_paldata,Bstrtolower(label+(g_numLabels<<6)));
+ labelNum=C_GetLabelNameOffset(&h_paldata,Bstrtolower(label+(g_numLabels<<6)));
break;
}
- if (EDUKE32_PREDICT_FALSE(lLabelID == -1))
+ if (EDUKE32_PREDICT_FALSE(labelNum == -1))
{
g_numCompilerErrors++;
C_ReportError(ERROR_NOTAMEMBER);
return;
}
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
- switch (i - g_iStructVarIDs)
+ switch (i - g_structVarIDs)
{
case STRUCT_SPRITE:
- *g_scriptPtr++=ActorLabels[lLabelID].lId;
+ *g_scriptPtr++=ActorLabels[labelNum].lId;
- if (ActorLabels[lLabelID].flags & LABEL_HASPARM2)
+ if (ActorLabels[labelNum].flags & LABEL_HASPARM2)
C_GetNextVarType(0);
break;
case STRUCT_SECTOR:
- *g_scriptPtr++=SectorLabels[lLabelID].lId;
+ *g_scriptPtr++=SectorLabels[labelNum].lId;
break;
case STRUCT_WALL:
- *g_scriptPtr++=WallLabels[lLabelID].lId;
+ *g_scriptPtr++=WallLabels[labelNum].lId;
break;
case STRUCT_PLAYER:
- *g_scriptPtr++=PlayerLabels[lLabelID].lId;
+ *g_scriptPtr++=PlayerLabels[labelNum].lId;
- if (PlayerLabels[lLabelID].flags & LABEL_HASPARM2)
+ if (PlayerLabels[labelNum].flags & LABEL_HASPARM2)
C_GetNextVarType(0);
break;
case STRUCT_ACTORVAR:
case STRUCT_PLAYERVAR:
- *g_scriptPtr++=lLabelID;
+ *g_scriptPtr++=labelNum;
break;
case STRUCT_TSPR:
- *g_scriptPtr++=TsprLabels[lLabelID].lId;
+ *g_scriptPtr++=TsprLabels[labelNum].lId;
break;
case STRUCT_PROJECTILE:
case STRUCT_THISPROJECTILE:
- *g_scriptPtr++=ProjectileLabels[lLabelID].lId;
+ *g_scriptPtr++=ProjectileLabels[labelNum].lId;
break;
case STRUCT_USERDEF:
- *g_scriptPtr++=UserdefsLabels[lLabelID].lId;
+ *g_scriptPtr++=UserdefsLabels[labelNum].lId;
break;
case STRUCT_INPUT:
- *g_scriptPtr++=InputLabels[lLabelID].lId;
+ *g_scriptPtr++=InputLabels[labelNum].lId;
break;
case STRUCT_TILEDATA:
- *g_scriptPtr++=TileDataLabels[lLabelID].lId;
+ *g_scriptPtr++=TileDataLabels[labelNum].lId;
break;
case STRUCT_PALDATA:
- *g_scriptPtr++=PalDataLabels[lLabelID].lId;
+ *g_scriptPtr++=PalDataLabels[labelNum].lId;
break;
}
}
@@ -1907,9 +1907,9 @@ static void C_GetNextVarType(int32_t type)
{
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));
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++ = MAXGAMEVARS;
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++ = labelcode[i];
return;
}
@@ -1924,13 +1924,13 @@ static void C_GetNextVarType(int32_t type)
return;
}
- if (EDUKE32_PREDICT_FALSE(type == GAMEVAR_READONLY && aGameVars[i].nFlags & GAMEVAR_READONLY))
+ if (EDUKE32_PREDICT_FALSE(type == GAMEVAR_READONLY && aGameVars[i].flags & GAMEVAR_READONLY))
{
g_numCompilerErrors++;
C_ReportError(ERROR_VARREADONLY);
return;
}
- else if (EDUKE32_PREDICT_FALSE(aGameVars[i].nFlags & type))
+ else if (EDUKE32_PREDICT_FALSE(aGameVars[i].flags & type))
{
g_numCompilerErrors++;
C_ReportError(ERROR_VARTYPEMISMATCH);
@@ -1940,7 +1940,7 @@ static void C_GetNextVarType(int32_t type)
if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
initprintf("%s:%d: debug: gamevar `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6));
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=(i|f);
}
@@ -1997,14 +1997,14 @@ static int32_t C_GetNextValue(int32_t type)
Bfree(gl);
}
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = labelcode[i];
textptr += l;
return labeltype[i];
}
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = 0;
textptr += l;
char *el = C_GetLabelType(type);
@@ -2021,7 +2021,7 @@ static int32_t C_GetNextValue(int32_t type)
{
C_ReportError(ERROR_PARAMUNDEFINED);
g_numCompilerErrors++;
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr = 0;
g_scriptPtr++;
textptr+=l;
@@ -2049,7 +2049,7 @@ static int32_t C_GetNextValue(int32_t type)
}
while (i > 0);
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
if (tolower(textptr[1])=='x')
*g_scriptPtr = parse_hex_constant(textptr+2);
@@ -2082,8 +2082,8 @@ static int32_t C_GetStructureIndexes(int32_t const labelsonly, hashtable_t const
if (*textptr == ']')
{
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++ = g_iThisActorID;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++ = g_thisActorVarID;
}
else
{
@@ -2112,16 +2112,16 @@ static int32_t C_GetStructureIndexes(int32_t const labelsonly, hashtable_t const
C_GetNextLabelName();
- int32_t const lLabelID = C_GetLabelNameOffset(table, Bstrtolower(label + (g_numLabels << 6)));
+ int32_t const labelNum = C_GetLabelNameOffset(table, Bstrtolower(label + (g_numLabels << 6)));
- if (EDUKE32_PREDICT_FALSE(lLabelID == -1))
+ if (EDUKE32_PREDICT_FALSE(labelNum == -1))
{
g_numCompilerErrors++;
C_ReportError(ERROR_NOTAMEMBER);
return -1;
}
- return lLabelID;
+ return labelNum;
}
static inline int32_t C_IntPow2(int32_t const v)
@@ -2152,7 +2152,7 @@ static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr)
case CON_ENDEVENT:
case CON_ENDS:
case CON_ELSE:
- g_scriptPtr = lastScriptPtr + &script[0];
+ g_scriptPtr = lastScriptPtr + &apScript[0];
g_ifElseAborted = 1;
C_ReportError(-1);
g_numCompilerWarnings++;
@@ -2181,7 +2181,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr)
{
C_ReportError(-1);
g_numCompilerWarnings++;
- g_scriptPtr = lastScriptPtr + &script[0];
+ g_scriptPtr = lastScriptPtr + &apScript[0];
initprintf("%s:%d: warning: empty `%s' branch\n",g_szScriptFileName,g_lineNumber,
keyw[*(g_scriptPtr) & VM_INSTMASK]);
*(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12));
@@ -2194,8 +2194,8 @@ static int32_t C_CountCaseStatements()
{
char *temptextptr = textptr;
int32_t temp_ScriptLineNumber = g_lineNumber;
- intptr_t scriptoffset = (unsigned)(g_scriptPtr-script);
- intptr_t caseoffset = (unsigned)(g_caseScriptPtr-script);
+ intptr_t scriptoffset = (unsigned)(g_scriptPtr-apScript);
+ intptr_t caseoffset = (unsigned)(g_caseScriptPtr-apScript);
// int32_t i;
g_numCases=0;
@@ -2207,13 +2207,13 @@ static int32_t C_CountCaseStatements()
g_checkingSwitch++;
textptr=temptextptr;
- g_scriptPtr = (intptr_t *)(script+scriptoffset);
+ g_scriptPtr = (intptr_t *)(apScript+scriptoffset);
g_lineNumber = temp_ScriptLineNumber;
int32_t const lCount=g_numCases;
g_numCases=0;
- g_caseScriptPtr = (intptr_t *)(script+caseoffset);
+ g_caseScriptPtr = (intptr_t *)(apScript+caseoffset);
g_numCases = 0;
return lCount;
}
@@ -2336,8 +2336,8 @@ void G_DoGameStartup(const int32_t *params)
if (g_scriptVersion == 14)
{
- g_spriteDeleteQueueSize = params[j++];
- g_spriteDeleteQueueSize = clamp(g_spriteDeleteQueueSize, 0, 1024);
+ g_deleteQueueSize = params[j++];
+ g_deleteQueueSize = clamp(g_deleteQueueSize, 0, 1024);
g_tripbombLaserMode = params[j++];
}
@@ -2349,7 +2349,7 @@ void C_DefineMusic(int32_t vol, int32_t lev, const char *fn)
Bassert((unsigned)vol < MAXVOLUMES+1);
Bassert((unsigned)lev < MAXLEVELS);
- map_t *const map = &MapInfo[(MAXLEVELS*vol)+lev];
+ map_t *const map = &aMapInfo[(MAXLEVELS*vol)+lev];
Bfree(map->musicfn);
map->musicfn = dup_filename(fn);
@@ -2384,7 +2384,7 @@ void C_DefineSound(int32_t sndidx, const char *fn, int32_t args[5])
void C_DefineQuote(int32_t qnum, const char *qstr)
{
C_AllocQuote(qnum);
- Bstrncpyz(ScriptQuotes[qnum], qstr, MAXQUOTELEN);
+ Bstrncpyz(apStrings[qnum], qstr, MAXQUOTELEN);
}
void C_DefineVolumeName(int32_t vol, const char *name)
@@ -2409,7 +2409,7 @@ void C_DefineLevelName(int32_t vol, int32_t lev, const char *fn,
Bassert((unsigned)lev < MAXLEVELS);
{
- map_t *const map = &MapInfo[(MAXLEVELS*vol)+lev];
+ map_t *const map = &aMapInfo[(MAXLEVELS*vol)+lev];
Bfree(map->filename);
map->filename = dup_filename(fn);
@@ -2492,7 +2492,7 @@ void C_UndefineLevel(int32_t vol, int32_t lev)
Bassert((unsigned)vol < MAXVOLUMES);
Bassert((unsigned)lev < MAXLEVELS);
- map_t *const map = &MapInfo[(MAXLEVELS*vol)+lev];
+ map_t *const map = &aMapInfo[(MAXLEVELS*vol)+lev];
DO_FREE_AND_NULL(map->filename);
DO_FREE_AND_NULL(map->name);
@@ -2612,9 +2612,9 @@ int32_t C_AllocQuote(int32_t qnum)
{
Bassert((unsigned)qnum < MAXQUOTES);
- if (ScriptQuotes[qnum] == NULL)
+ if (apStrings[qnum] == NULL)
{
- ScriptQuotes[qnum] = (char *)Xcalloc(MAXQUOTELEN,sizeof(uint8_t));
+ apStrings[qnum] = (char *)Xcalloc(MAXQUOTELEN,sizeof(uint8_t));
return 1;
}
@@ -2627,13 +2627,13 @@ static void C_ReplaceQuoteSubstring(const size_t q, char const * const query, ch
size_t querylength = Bstrlen(query);
for (int i = MAXQUOTELEN - querylength - 2; i >= 0; i--)
- if (Bstrncmp(&ScriptQuotes[q][i], query, querylength) == 0)
+ if (Bstrncmp(&apStrings[q][i], query, querylength) == 0)
{
Bmemset(tempbuf, 0, sizeof(tempbuf));
- Bstrncpy(tempbuf, ScriptQuotes[q], i);
+ Bstrncpy(tempbuf, apStrings[q], i);
Bstrcat(tempbuf, replacement);
- Bstrcat(tempbuf, &ScriptQuotes[q][i + querylength]);
- Bstrncpy(ScriptQuotes[q], tempbuf, MAXQUOTELEN - 1);
+ Bstrcat(tempbuf, &apStrings[q][i + querylength]);
+ Bstrncpy(apStrings[q], tempbuf, MAXQUOTELEN - 1);
i = MAXQUOTELEN - querylength - 2;
}
}
@@ -2644,10 +2644,10 @@ void C_InitQuotes(void)
for (int i = 0; i < 128; i++) C_AllocQuote(i);
#ifdef EDUKE32_TOUCH_DEVICES
- ScriptQuotes[QUOTE_DEAD] = 0;
+ apStrings[QUOTE_DEAD] = 0;
#else
char const * const replacement_USE = "USE";
- if (!Bstrstr(ScriptQuotes[QUOTE_DEAD], replacement_USE))
+ if (!Bstrstr(apStrings[QUOTE_DEAD], replacement_USE))
{
C_ReplaceQuoteSubstring(QUOTE_DEAD, "SPACE", replacement_USE);
C_ReplaceQuoteSubstring(QUOTE_DEAD, "OPEN", replacement_USE);
@@ -2725,14 +2725,14 @@ void C_InitQuotes(void)
for (int i = g_numObituaries - 1; i >= 0; i--)
{
if (C_AllocQuote(i + OBITQUOTEINDEX))
- Bstrcpy(ScriptQuotes[i + OBITQUOTEINDEX], PlayerObituaries[i]);
+ Bstrcpy(apStrings[i + OBITQUOTEINDEX], PlayerObituaries[i]);
}
g_numSelfObituaries = ARRAY_SIZE(PlayerSelfObituaries);
for (int i = g_numSelfObituaries - 1; i >= 0; i--)
{
if (C_AllocQuote(i + SUICIDEQUOTEINDEX))
- Bstrcpy(ScriptQuotes[i + SUICIDEQUOTEINDEX], PlayerSelfObituaries[i]);
+ Bstrcpy(apStrings[i + SUICIDEQUOTEINDEX], PlayerSelfObituaries[i]);
}
}
@@ -2808,7 +2808,7 @@ static inline void C_BitOrNextValue(int32_t *valptr)
static inline void C_FinishBitOr(int32_t value)
{
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr = value;
g_scriptPtr++;
}
@@ -2817,9 +2817,9 @@ static void C_FillEventBreakStackWithJump(intptr_t *breakPtr, intptr_t destinati
{
while (breakPtr)
{
- breakPtr = script + (intptr_t)breakPtr;
+ breakPtr = apScript + (intptr_t)breakPtr;
intptr_t const tempPtr = *breakPtr;
- BITPTR_CLEAR(breakPtr-script);
+ BITPTR_CLEAR(breakPtr-apScript);
*breakPtr = destination;
breakPtr = (intptr_t *)tempPtr;
}
@@ -2859,7 +2859,7 @@ static int32_t C_ParseCommand(int32_t loop)
DO_DEFSTATE:
C_GetNextLabelName();
g_scriptPtr--;
- labelcode[g_numLabels] = g_scriptPtr-script;
+ labelcode[g_numLabels] = g_scriptPtr-apScript;
labeltype[g_numLabels] = LABEL_STATE;
g_processingState = 1;
@@ -2902,16 +2902,16 @@ DO_DEFSTATE:
g_numCompilerWarnings++;
Bfree(gl);
*(g_scriptPtr-1) = CON_NULLOP; // get rid of the state, leaving a nullop to satisfy if conditions
- BITPTR_CLEAR(g_scriptPtr-script-1);
+ 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));
- *g_scriptPtr = (intptr_t) (script+labelcode[j]);
+ *g_scriptPtr = (intptr_t) (apScript+labelcode[j]);
// 'state' type labels are always script addresses, as far as I can see
- BITPTR_SET(g_scriptPtr-script);
+ BITPTR_SET(g_scriptPtr-apScript);
g_scriptPtr++;
continue;
@@ -2954,13 +2954,13 @@ DO_DEFSTATE:
case CON_GETTHISPROJECTILE:
case CON_GETPROJECTILE:
{
- int32_t const lLabelID = C_GetStructureIndexes(tw == CON_SETTHISPROJECTILE || tw == CON_GETTHISPROJECTILE, &h_projectile);
+ int32_t const labelNum = C_GetStructureIndexes(tw == CON_SETTHISPROJECTILE || tw == CON_GETTHISPROJECTILE, &h_projectile);
- if (lLabelID == -1)
+ if (labelNum == -1)
continue;
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++=ProjectileLabels[lLabelID].lId;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++=ProjectileLabels[labelNum].lId;
switch (tw)
{
@@ -3102,7 +3102,7 @@ DO_DEFSTATE:
while (j>-1)
{
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++ = 0;
j--;
}
@@ -3114,7 +3114,7 @@ DO_DEFSTATE:
if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1)))
{
C_ReportError(-1);
- BITPTR_CLEAR(g_scriptPtr-script-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++;
@@ -3154,7 +3154,7 @@ DO_DEFSTATE:
{
hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0);
labeltype[g_numLabels] = LABEL_MOVE;
- labelcode[g_numLabels++] = g_scriptPtr-script;
+ labelcode[g_numLabels++] = g_scriptPtr-apScript;
}
for (j=1; j>=0; j--)
@@ -3165,7 +3165,7 @@ DO_DEFSTATE:
for (k=j; k>=0; k--)
{
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr = 0;
g_scriptPtr++;
}
@@ -3277,7 +3277,7 @@ DO_DEFSTATE:
{
labeltype[g_numLabels] = LABEL_AI;
hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0);
- labelcode[g_numLabels++] = g_scriptPtr-script;
+ labelcode[g_numLabels++] = g_scriptPtr-apScript;
}
for (j=0; j<3; j++)
@@ -3291,7 +3291,7 @@ DO_DEFSTATE:
(*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1)))
{
C_ReportError(-1);
- BITPTR_CLEAR(g_scriptPtr-script-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++;
@@ -3312,7 +3312,7 @@ DO_DEFSTATE:
for (k=j; k<3; k++)
{
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr = 0;
g_scriptPtr++;
}
@@ -3353,7 +3353,7 @@ DO_DEFSTATE:
else
{
labeltype[g_numLabels] = LABEL_ACTION;
- labelcode[g_numLabels] = g_scriptPtr-script;
+ labelcode[g_numLabels] = g_scriptPtr-apScript;
hash_add(&h_labels,label+(g_numLabels<<6),g_numLabels,0);
g_numLabels++;
}
@@ -3365,7 +3365,7 @@ DO_DEFSTATE:
}
for (k=j; k>=0; k--)
{
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = 0;
}
}
@@ -3382,7 +3382,7 @@ DO_DEFSTATE:
g_numBraces = 0;
g_scriptPtr--;
- g_parsingActorPtr = g_scriptPtr - script;
+ g_parsingActorPtr = g_scriptPtr - apScript;
if (tw == CON_USERACTOR)
{
@@ -3427,12 +3427,12 @@ DO_DEFSTATE:
if (tw == CON_EVENTLOADACTOR)
{
- g_tile[*g_scriptPtr].loadPtr = script + g_parsingActorPtr;
+ g_tile[*g_scriptPtr].loadPtr = apScript + g_parsingActorPtr;
g_checkingIfElse = 0;
continue;
}
- g_tile[*g_scriptPtr].execPtr = script + g_parsingActorPtr;
+ g_tile[*g_scriptPtr].execPtr = apScript + g_parsingActorPtr;
if (tw == CON_USERACTOR)
{
@@ -3449,7 +3449,7 @@ DO_DEFSTATE:
for (j=0; j<4; j++)
{
BITPTR_CLEAR(g_parsingActorPtr+j);
- *((script+j)+g_parsingActorPtr) = 0;
+ *((apScript+j)+g_parsingActorPtr) = 0;
if (j == 3)
{
j = 0;
@@ -3465,7 +3465,7 @@ DO_DEFSTATE:
{
for (i=4-j; i; i--)
{
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = 0;
}
break;
@@ -3484,17 +3484,17 @@ DO_DEFSTATE:
if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1)))
{
C_ReportError(-1);
- BITPTR_CLEAR(g_scriptPtr-script-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++;
}
break;
}
- if (*(g_scriptPtr-1) >= (intptr_t)&script[0] && *(g_scriptPtr-1) < (intptr_t)&script[g_scriptSize])
+ if (*(g_scriptPtr-1) >= (intptr_t)&apScript[0] && *(g_scriptPtr-1) < (intptr_t)&apScript[g_scriptSize])
BITPTR_SET(g_parsingActorPtr+j);
else BITPTR_CLEAR(g_parsingActorPtr+j);
- *((script+j)+g_parsingActorPtr) = *(g_scriptPtr-1);
+ *((apScript+j)+g_parsingActorPtr) = *(g_scriptPtr-1);
}
}
g_checkingIfElse = 0;
@@ -3510,7 +3510,7 @@ DO_DEFSTATE:
g_numBraces = 0;
g_scriptPtr--;
- g_parsingEventPtr = g_parsingActorPtr = g_scriptPtr - script;
+ g_parsingEventPtr = g_parsingActorPtr = g_scriptPtr - apScript;
C_SkipComments();
j = 0;
@@ -3535,24 +3535,24 @@ DO_DEFSTATE:
continue;
}
// if event has already been declared then store previous script location
- if (!apScriptGameEvent[j])
+ if (!apScriptEvents[j])
{
- apScriptGameEvent[j] = g_parsingEventPtr;
+ apScriptEvents[j] = g_parsingEventPtr;
}
else if (tw == CON_ONEVENT)
{
- previous_event = apScriptGameEvent[j];
- apScriptGameEvent[j] = g_parsingEventPtr;
+ previous_event = apScriptEvents[j];
+ apScriptEvents[j] = g_parsingEventPtr;
}
else // if (tw == CON_APPENDEVENT)
{
- intptr_t *previous_event_end = script + apScriptGameEventEnd[j];
- BITPTR_CLEAR(previous_event_end-script);
+ intptr_t *previous_event_end = apScript + apScriptGameEventEnd[j];
+ BITPTR_CLEAR(previous_event_end-apScript);
*(previous_event_end++) = CON_JUMP | (g_lineNumber << 12);
- BITPTR_CLEAR(previous_event_end-script);
+ BITPTR_CLEAR(previous_event_end-apScript);
*(previous_event_end++) = MAXGAMEVARS;
C_FillEventBreakStackWithJump((intptr_t *)*previous_event_end, g_parsingEventPtr);
- BITPTR_CLEAR(previous_event_end-script);
+ BITPTR_CLEAR(previous_event_end-apScript);
*(previous_event_end++) = g_parsingEventPtr;
}
@@ -3666,7 +3666,7 @@ DO_DEFSTATE:
continue;
}
- intptr_t const lastScriptPtr = g_scriptPtr - script - 1;
+ intptr_t const lastScriptPtr = g_scriptPtr - apScript - 1;
g_ifElseAborted = 0;
g_checkingIfElse--;
@@ -3674,7 +3674,7 @@ DO_DEFSTATE:
if (C_CheckMalformedBranch(lastScriptPtr))
continue;
- intptr_t const offset = (unsigned) (g_scriptPtr-script);
+ intptr_t const offset = (unsigned) (g_scriptPtr-apScript);
g_scriptPtr++; //Leave a spot for the fail location
@@ -3683,9 +3683,9 @@ DO_DEFSTATE:
if (C_CheckEmptyBranch(tw, lastScriptPtr))
continue;
- intptr_t *tempscrptr = (intptr_t *) script+offset;
+ intptr_t *tempscrptr = (intptr_t *) apScript+offset;
*tempscrptr = (intptr_t) g_scriptPtr;
- BITPTR_SET(tempscrptr-script);
+ BITPTR_SET(tempscrptr-apScript);
continue;
}
@@ -3693,13 +3693,13 @@ DO_DEFSTATE:
case CON_SETSECTOR:
case CON_GETSECTOR:
{
- int32_t const lLabelID = C_GetStructureIndexes(1, &h_sector);
+ int32_t const labelNum = C_GetStructureIndexes(1, &h_sector);
- if (lLabelID == -1)
+ if (labelNum == -1)
continue;
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++=SectorLabels[lLabelID].lId;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++=SectorLabels[labelNum].lId;
C_GetNextVarType((tw == CON_GETSECTOR) ? GAMEVAR_READONLY : 0);
continue;
@@ -3763,13 +3763,13 @@ DO_DEFSTATE:
case CON_SETWALL:
case CON_GETWALL:
{
- int32_t const lLabelID = C_GetStructureIndexes(1, &h_wall);
+ int32_t const labelNum = C_GetStructureIndexes(1, &h_wall);
- if (lLabelID == -1)
+ if (labelNum == -1)
continue;
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++=WallLabels[lLabelID].lId;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++=WallLabels[labelNum].lId;
C_GetNextVarType((tw == CON_GETWALL) ? GAMEVAR_READONLY : 0);
continue;
@@ -3778,15 +3778,15 @@ DO_DEFSTATE:
case CON_SETPLAYER:
case CON_GETPLAYER:
{
- int32_t const lLabelID = C_GetStructureIndexes(1, &h_player);
+ int32_t const labelNum = C_GetStructureIndexes(1, &h_player);
- if (lLabelID == -1)
+ if (labelNum == -1)
continue;
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++=PlayerLabels[lLabelID].lId;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++=PlayerLabels[labelNum].lId;
- if (PlayerLabels[lLabelID].flags & LABEL_HASPARM2)
+ if (PlayerLabels[labelNum].flags & LABEL_HASPARM2)
C_GetNextVar();
C_GetNextVarType((tw == CON_GETPLAYER) ? GAMEVAR_READONLY : 0);
@@ -3796,13 +3796,13 @@ DO_DEFSTATE:
case CON_SETINPUT:
case CON_GETINPUT:
{
- int32_t const lLabelID = C_GetStructureIndexes(1, &h_input);
+ int32_t const labelNum = C_GetStructureIndexes(1, &h_input);
- if (lLabelID == -1)
+ if (labelNum == -1)
continue;
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++=InputLabels[lLabelID].lId;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++=InputLabels[labelNum].lId;
C_GetNextVarType(tw == CON_GETINPUT ? GAMEVAR_READONLY : 0);
continue;
@@ -3829,16 +3829,16 @@ DO_DEFSTATE:
textptr++;
C_GetNextLabelName();
- int32_t const lLabelID=C_GetLabelNameID(UserdefsLabels,&h_userdef,Bstrtolower(label+(g_numLabels<<6)));
+ int32_t const labelNum=C_GetLabelNameID(UserdefsLabels,&h_userdef,Bstrtolower(label+(g_numLabels<<6)));
- if (EDUKE32_PREDICT_FALSE(lLabelID == -1))
+ if (EDUKE32_PREDICT_FALSE(labelNum == -1))
{
g_numCompilerErrors++;
C_ReportError(ERROR_NOTAMEMBER);
continue;
}
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++=lLabelID;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++=labelNum;
C_GetNextVarType((tw == CON_GETUSERDEF) ? GAMEVAR_READONLY : 0);
continue;
@@ -3855,7 +3855,7 @@ DO_DEFSTATE:
if (C_GetStructureIndexes(1, NULL) == -1)
continue;
- if (g_scriptPtr[-1] == g_iThisActorID) // convert to "setvarvar"
+ if (g_scriptPtr[-1] == g_thisActorVarID) // convert to "setvarvar"
{
g_scriptPtr--;
g_scriptPtr[-1]=CON_SETVARVAR;
@@ -3894,7 +3894,7 @@ DO_DEFSTATE:
C_ReportError(ERROR_NOTAGAMEVAR);
continue;
}
- if (EDUKE32_PREDICT_FALSE(aGameVars[i].nFlags & GAMEVAR_READONLY))
+ if (EDUKE32_PREDICT_FALSE(aGameVars[i].flags & GAMEVAR_READONLY))
{
g_numCompilerErrors++;
C_ReportError(ERROR_VARREADONLY);
@@ -3904,7 +3904,7 @@ DO_DEFSTATE:
switch (tw)
{
case CON_SETACTORVAR:
- if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].nFlags & GAMEVAR_PERACTOR)))
+ if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].flags & GAMEVAR_PERACTOR)))
{
g_numCompilerErrors++;
C_ReportError(-1);
@@ -3913,7 +3913,7 @@ DO_DEFSTATE:
}
break;
case CON_SETPLAYERVAR:
- if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].nFlags & GAMEVAR_PERPLAYER)))
+ if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].flags & GAMEVAR_PERPLAYER)))
{
g_numCompilerErrors++;
C_ReportError(-1);
@@ -3923,7 +3923,7 @@ DO_DEFSTATE:
break;
}
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=i; // the ID of the DEF (offset into array...)
switch (tw)
@@ -3942,15 +3942,15 @@ DO_DEFSTATE:
case CON_SETACTOR:
case CON_GETACTOR:
{
- int32_t const lLabelID = C_GetStructureIndexes(1, &h_actor);
+ int32_t const labelNum = C_GetStructureIndexes(1, &h_actor);
- if (lLabelID == -1)
+ if (labelNum == -1)
continue;
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++=ActorLabels[lLabelID].lId;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++=ActorLabels[labelNum].lId;
- if (ActorLabels[lLabelID].flags & LABEL_HASPARM2)
+ if (ActorLabels[labelNum].flags & LABEL_HASPARM2)
C_GetNextVar();
C_GetNextVarType((tw == CON_GETACTOR) ? GAMEVAR_READONLY : 0);
@@ -3968,13 +3968,13 @@ DO_DEFSTATE:
g_numCompilerWarnings++;
}
#endif
- int32_t const lLabelID = C_GetStructureIndexes(1, &h_tsprite);
+ int32_t const labelNum = C_GetStructureIndexes(1, &h_tsprite);
- if (lLabelID == -1)
+ if (labelNum == -1)
continue;
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++=TsprLabels[lLabelID].lId;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++=TsprLabels[labelNum].lId;
C_GetNextVarType((tw == CON_GETTSPR) ? GAMEVAR_READONLY : 0);
continue;
@@ -4192,7 +4192,7 @@ DO_DEFSTATE:
return 1;
}
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=i;
C_GetNextValue(LABEL_DEFINE);
@@ -4207,7 +4207,7 @@ DO_DEFSTATE:
C_ReportError(ERROR_NOTAGAMEARRAY);
return 1;
}
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=i;
C_SkipComments();// skip comments and whitespace
if (EDUKE32_PREDICT_FALSE(*textptr != '['))
@@ -4236,10 +4236,10 @@ DO_DEFSTATE:
return 1;
}
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=i;
- if (EDUKE32_PREDICT_FALSE(aGameArrays[i].nFlags & GAMEARRAY_READONLY))
+ if (EDUKE32_PREDICT_FALSE(aGameArrays[i].flags & GAMEARRAY_READONLY))
{
C_ReportError(ERROR_ARRAYREADONLY);
g_numCompilerErrors++;
@@ -4277,9 +4277,9 @@ DO_DEFSTATE:
return 1;
}
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++ = i;
- if (tw==CON_RESIZEARRAY && (aGameArrays[i].nFlags & GAMEARRAY_TYPE_MASK))
+ if (tw==CON_RESIZEARRAY && (aGameArrays[i].flags & GAMEARRAY_TYPE_MASK))
{
C_ReportError(-1);
initprintf("can't resize system array `%s'.", label+(g_numLabels<<6));
@@ -4496,7 +4496,7 @@ DO_DEFSTATE:
case CON_WHILEVARVARL:
{
intptr_t offset;
- intptr_t lastScriptPtr = g_scriptPtr - &script[0] - 1;
+ intptr_t lastScriptPtr = g_scriptPtr - &apScript[0] - 1;
g_ifElseAborted = 0;
@@ -4505,7 +4505,7 @@ DO_DEFSTATE:
if (C_CheckMalformedBranch(lastScriptPtr))
continue;
- offset = (unsigned)(g_scriptPtr-script);
+ offset = (unsigned)(g_scriptPtr-apScript);
g_scriptPtr++; // Leave a spot for the fail location
C_ParseCommand(0);
@@ -4513,9 +4513,9 @@ DO_DEFSTATE:
if (C_CheckEmptyBranch(tw, lastScriptPtr))
continue;
- intptr_t *tempscrptr = (intptr_t *)script+offset;
+ intptr_t *tempscrptr = (intptr_t *)apScript+offset;
*tempscrptr = (intptr_t) g_scriptPtr;
- BITPTR_SET(tempscrptr-script);
+ BITPTR_SET(tempscrptr-apScript);
if (tw != CON_WHILEVARVARN)
{
@@ -4546,7 +4546,7 @@ DO_DEFSTATE:
case CON_WHILEVARN:
case CON_WHILEVARL:
{
- intptr_t lastScriptPtr = (g_scriptPtr-script-1);
+ intptr_t lastScriptPtr = (g_scriptPtr-apScript-1);
g_ifElseAborted = 0;
// get the ID of the DEF
@@ -4557,7 +4557,7 @@ DO_DEFSTATE:
continue;
intptr_t *tempscrptr = g_scriptPtr;
- intptr_t offset = (unsigned)(tempscrptr-script);
+ intptr_t offset = (unsigned)(tempscrptr-apScript);
g_scriptPtr++; //Leave a spot for the fail location
C_ParseCommand(0);
@@ -4565,9 +4565,9 @@ DO_DEFSTATE:
if (C_CheckEmptyBranch(tw, lastScriptPtr))
continue;
- tempscrptr = (intptr_t *)script+offset;
+ tempscrptr = (intptr_t *)apScript+offset;
*tempscrptr = (intptr_t) g_scriptPtr;
- BITPTR_SET(tempscrptr-script);
+ BITPTR_SET(tempscrptr-apScript);
if (tw != CON_WHILEVARN && tw != CON_WHILEVARL)
{
@@ -4597,13 +4597,13 @@ DO_DEFSTATE:
if (how >= ITER_SPRITESOFSECTOR)
C_GetNextVar();
- intptr_t offset = g_scriptPtr-script;
+ intptr_t offset = g_scriptPtr-apScript;
g_scriptPtr++; //Leave a spot for the location to jump to after completion
C_ParseCommand(0);
- intptr_t *tscrptr = (intptr_t *) script+offset;
- *tscrptr = (g_scriptPtr-script)-offset; // relative offset
+ intptr_t *tscrptr = (intptr_t *) apScript+offset;
+ *tscrptr = (g_scriptPtr-apScript)-offset; // relative offset
continue;
}
@@ -4780,13 +4780,13 @@ DO_DEFSTATE:
C_GetNextVar();
intptr_t *tempscrptr= g_scriptPtr;
- tempoffset = (unsigned)(tempscrptr-script);
- BITPTR_CLEAR(g_scriptPtr-script);
+ tempoffset = (unsigned)(tempscrptr-apScript);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=0; // leave spot for end location (for after processing)
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=0; // count of case statements
g_caseScriptPtr=g_scriptPtr; // the first case's pointer.
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=0; // leave spot for 'default' location (null if none)
// temptextptr=textptr;
@@ -4797,7 +4797,7 @@ DO_DEFSTATE:
g_scriptPtr+=j*2;
C_SkipComments();
g_scriptPtr-=j*2; // allocate buffer for the table
- tempscrptr = (intptr_t *)(script+tempoffset);
+ tempscrptr = (intptr_t *)(apScript+tempoffset);
//AddLog(g_szBuf);
@@ -4819,16 +4819,16 @@ DO_DEFSTATE:
while (j--)
{
// leave room for statements
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=0; // value check
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr++=0; // code offset
C_SkipComments();
}
g_numCases=0;
C_ParseCommand(1);
- tempscrptr = (intptr_t *)(script+tempoffset);
+ tempscrptr = (intptr_t *)(apScript+tempoffset);
//Bsprintf(g_szBuf,"SWITCHXX: '%.22s'",textptr);
//AddLog(g_szBuf);
@@ -4854,7 +4854,7 @@ DO_DEFSTATE:
}
}
// for (j=3;j<3+tempscrptr[1]*2;j+=2)initprintf("%5d %8x\n",tempscrptr[j],tempscrptr[j+1]);
- tempscrptr[0]= (intptr_t)g_scriptPtr - (intptr_t)&script[0]; // save 'end' location
+ tempscrptr[0]= (intptr_t)g_scriptPtr - (intptr_t)&apScript[0]; // save 'end' location
// BITPTR_POINTER_SET(tempscrptr-script);
}
else
@@ -4922,7 +4922,7 @@ repeatcase:
C_ReportError(-1);
initprintf("%s:%d: error: multiple `default' statements found in switch\n", g_szScriptFileName, g_lineNumber);
}
- g_caseScriptPtr[0]=(intptr_t) (g_scriptPtr-&script[0]); // save offset
+ g_caseScriptPtr[0]=(intptr_t) (g_scriptPtr-&apScript[0]); // save offset
}
else
{
@@ -4934,7 +4934,7 @@ repeatcase:
break;
}
g_caseScriptPtr[g_numCases++]=j;
- g_caseScriptPtr[g_numCases]=(intptr_t) ((intptr_t *) g_scriptPtr-&script[0]);
+ g_caseScriptPtr[g_numCases]=(intptr_t) ((intptr_t *) g_scriptPtr-&apScript[0]);
}
}
@@ -4948,7 +4948,7 @@ repeatcase:
goto repeatcase;
}
- tempoffset = (unsigned)(tempscrptr-script);
+ tempoffset = (unsigned)(tempscrptr-apScript);
while (C_ParseCommand(0) == 0)
{
@@ -4957,7 +4957,7 @@ repeatcase:
if (j == CON_CASE || j == CON_DEFAULT)
{
C_GetNextKeyword(); // eat keyword
- tempscrptr = (intptr_t *)(script+tempoffset);
+ tempscrptr = (intptr_t *)(apScript+tempoffset);
tw = j;
goto repeatcase;
}
@@ -5042,7 +5042,7 @@ repeatcase:
case CON_IFCUTSCENE:
{
intptr_t offset;
- intptr_t lastScriptPtr = (g_scriptPtr-&script[0]-1);
+ intptr_t lastScriptPtr = (g_scriptPtr-&apScript[0]-1);
g_ifElseAborted = 0;
@@ -5088,7 +5088,7 @@ repeatcase:
continue;
intptr_t *tempscrptr = g_scriptPtr;
- offset = (unsigned)(tempscrptr-script);
+ offset = (unsigned)(tempscrptr-apScript);
g_scriptPtr++; //Leave a spot for the fail location
@@ -5097,9 +5097,9 @@ repeatcase:
if (C_CheckEmptyBranch(tw, lastScriptPtr))
continue;
- tempscrptr = (intptr_t *)script+offset;
+ tempscrptr = (intptr_t *)apScript+offset;
*tempscrptr = (intptr_t) g_scriptPtr;
- BITPTR_SET(tempscrptr-script);
+ BITPTR_SET(tempscrptr-apScript);
j = C_GetKeyword();
@@ -5132,7 +5132,7 @@ repeatcase:
case CON_IFNOSOUNDS:
{
intptr_t offset;
- intptr_t lastScriptPtr = (g_scriptPtr-&script[0]-1);
+ intptr_t lastScriptPtr = (g_scriptPtr-&apScript[0]-1);
g_ifElseAborted = 0;
@@ -5140,7 +5140,7 @@ repeatcase:
continue;
intptr_t *tempscrptr = g_scriptPtr;
- offset = (unsigned)(tempscrptr-script);
+ offset = (unsigned)(tempscrptr-apScript);
g_scriptPtr++; //Leave a spot for the fail location
@@ -5149,9 +5149,9 @@ repeatcase:
if (C_CheckEmptyBranch(tw, lastScriptPtr))
continue;
- tempscrptr = (intptr_t *)script+offset;
+ tempscrptr = (intptr_t *)apScript+offset;
*tempscrptr = (intptr_t) g_scriptPtr;
- BITPTR_SET(tempscrptr-script);
+ BITPTR_SET(tempscrptr-apScript);
j = C_GetKeyword();
@@ -5581,16 +5581,16 @@ repeatcase:
Bcorrectfilename(tempbuf,0);
- if (MapInfo[j *MAXLEVELS+k].filename == NULL)
- MapInfo[j *MAXLEVELS+k].filename = (char *)Xcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t));
- else if ((Bstrlen(tempbuf)+1) > sizeof(MapInfo[j*MAXLEVELS+k].filename))
- MapInfo[j *MAXLEVELS+k].filename = (char *)Xrealloc(MapInfo[j*MAXLEVELS+k].filename,(Bstrlen(tempbuf)+1));
+ 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));
- Bstrcpy(MapInfo[j*MAXLEVELS+k].filename,tempbuf);
+ Bstrcpy(aMapInfo[j*MAXLEVELS+k].filename,tempbuf);
C_SkipComments();
- MapInfo[j *MAXLEVELS+k].partime =
+ aMapInfo[j *MAXLEVELS+k].partime =
(((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*REALGAMETICSPERSEC*60)+
(((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*REALGAMETICSPERSEC);
@@ -5600,7 +5600,7 @@ repeatcase:
// cheap hack, 0.99 doesn't have the 3D Realms time
if (*(textptr+2) == ':')
{
- MapInfo[j *MAXLEVELS+k].designertime =
+ aMapInfo[j *MAXLEVELS+k].designertime =
(((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*REALGAMETICSPERSEC*60)+
(((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))*REALGAMETICSPERSEC);
@@ -5627,14 +5627,14 @@ repeatcase:
tempbuf[i] = '\0';
- if (MapInfo[j*MAXLEVELS+k].name == NULL)
- MapInfo[j*MAXLEVELS+k].name = (char *)Xcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t));
- else if ((Bstrlen(tempbuf)+1) > sizeof(MapInfo[j*MAXLEVELS+k].name))
- MapInfo[j *MAXLEVELS+k].name = (char *)Xrealloc(MapInfo[j*MAXLEVELS+k].name,(Bstrlen(tempbuf)+1));
+ 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));
/* initprintf("level name string len: %d\n",Bstrlen(tempbuf)); */
- Bstrcpy(MapInfo[j*MAXLEVELS+k].name,tempbuf);
+ Bstrcpy(aMapInfo[j*MAXLEVELS+k].name,tempbuf);
continue;
@@ -5668,8 +5668,8 @@ repeatcase:
if (tw == CON_REDEFINEQUOTE)
{
- if (ScriptQuoteRedefinitions[g_numQuoteRedefinitions] == NULL)
- ScriptQuoteRedefinitions[g_numQuoteRedefinitions] = (char *)Xcalloc(MAXQUOTELEN,sizeof(uint8_t));
+ if (apXStrings[g_numXStrings] == NULL)
+ apXStrings[g_numXStrings] = (char *)Xcalloc(MAXQUOTELEN,sizeof(uint8_t));
}
while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0)
@@ -5684,9 +5684,9 @@ repeatcase:
}
*/
if (tw == CON_DEFINEQUOTE)
- *(ScriptQuotes[k]+i) = *textptr;
+ *(apStrings[k]+i) = *textptr;
else
- *(ScriptQuoteRedefinitions[g_numQuoteRedefinitions]+i) = *textptr;
+ *(apXStrings[g_numXStrings]+i) = *textptr;
textptr++,i++;
if (EDUKE32_PREDICT_FALSE(i >= MAXQUOTELEN-1))
{
@@ -5700,14 +5700,14 @@ repeatcase:
if (tw == CON_DEFINEQUOTE)
{
if ((unsigned)k < MAXQUOTES)
- *(ScriptQuotes[k]+i) = '\0';
+ *(apStrings[k]+i) = '\0';
}
else
{
- *(ScriptQuoteRedefinitions[g_numQuoteRedefinitions]+i) = '\0';
- BITPTR_CLEAR(g_scriptPtr-script);
- *g_scriptPtr++=g_numQuoteRedefinitions;
- g_numQuoteRedefinitions++;
+ *(apXStrings[g_numXStrings]+i) = '\0';
+ BITPTR_CLEAR(g_scriptPtr-apScript);
+ *g_scriptPtr++=g_numXStrings;
+ g_numXStrings++;
}
continue;
@@ -5848,13 +5848,13 @@ repeatcase:
if (previous_event)
{
g_scriptPtr--;
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = CON_JUMP | (g_lineNumber << 12);
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = MAXGAMEVARS;
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = previous_event;
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = CON_ENDEVENT | (g_lineNumber << 12);
C_FillEventBreakStackWithJump((intptr_t *)g_parsingEventBreakPtr, previous_event);
@@ -5864,12 +5864,12 @@ repeatcase:
else
{
// pad space for the next potential appendevent
- apScriptGameEventEnd[g_currentEvent] = (g_scriptPtr-1)-script;
- BITPTR_CLEAR(g_scriptPtr-script);
+ apScriptGameEventEnd[g_currentEvent] = (g_scriptPtr-1)-apScript;
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = CON_ENDEVENT | (g_lineNumber << 12);
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = g_parsingEventBreakPtr;
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = CON_ENDEVENT | (g_lineNumber << 12);
}
@@ -5921,13 +5921,13 @@ repeatcase:
else if (g_parsingEventPtr)
{
g_scriptPtr--;
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = CON_JUMP | (g_lineNumber << 12);
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*(g_scriptPtr++) = MAXGAMEVARS;
- BITPTR_CLEAR(g_scriptPtr-script);
+ BITPTR_CLEAR(g_scriptPtr-apScript);
*g_scriptPtr = g_parsingEventBreakPtr;
- g_parsingEventBreakPtr = g_scriptPtr++ - script;
+ g_parsingEventBreakPtr = g_scriptPtr++ - apScript;
}
continue;
@@ -6229,14 +6229,14 @@ void C_PrintStats(void)
MAXSPRITES * sizeof(spritetype)/(1<<6)),
g_gameVarCount, MAXGAMEVARS, g_gameArrayCount, MAXGAMEARRAYS);
- if (g_numQuoteRedefinitions)
- initprintf("%d strings, ", g_numQuoteRedefinitions);
+ if (g_numXStrings)
+ initprintf("%d strings, ", g_numXStrings);
int i, j;
for (i=MAXQUOTES-1, j=0; i>=0; i--)
{
- if (ScriptQuotes[i])
+ if (apStrings[i])
j++;
}
@@ -6244,7 +6244,7 @@ void C_PrintStats(void)
for (i=MAXGAMEEVENTS-1, j=0; i>=0; i--)
{
- if (apScriptGameEvent[i])
+ if (apScriptEvents[i])
j++;
}
if (j) initprintf("%d events, ", j);
@@ -6263,7 +6263,7 @@ void C_Compile(const char *filenam)
{
int32_t i;
- Bmemset(apScriptGameEvent, 0, sizeof(apScriptGameEvent));
+ Bmemset(apScriptEvents, 0, sizeof(apScriptEvents));
Bmemset(apScriptGameEventEnd, 0, sizeof(apScriptGameEventEnd));
for (i=MAXTILES-1; i>=0; i--)
@@ -6313,14 +6313,14 @@ void C_Compile(const char *filenam)
kread(fp,(char *)textptr,fs);
kclose(fp);
- Bfree(script);
+ Bfree(apScript);
- script = (intptr_t *)Xcalloc(1,g_scriptSize * sizeof(intptr_t));
+ apScript = (intptr_t *)Xcalloc(1,g_scriptSize * sizeof(intptr_t));
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_scriptPtr = script+3; // move permits constants 0 and 1; moveptr[1] would be script[2] (reachable?)
+ g_scriptPtr = apScript+3; // move permits constants 0 and 1; moveptr[1] would be script[2] (reachable?)
g_numCompilerWarnings = 0;
g_numCompilerErrors = 0;
g_lineNumber = 1;
@@ -6389,14 +6389,14 @@ void C_Compile(const char *filenam)
{
for (i = 0; i < MAXEVENTS; ++i)
{
- intptr_t *eventEnd = script + apScriptGameEventEnd[i];
+ intptr_t *eventEnd = apScript + apScriptGameEventEnd[i];
if (eventEnd)
{
// C_FillEventBreakStackWithEndEvent
intptr_t *breakPtr = (intptr_t*)*(eventEnd + 2);
while (breakPtr)
{
- breakPtr = script + (intptr_t)breakPtr;
+ breakPtr = apScript + (intptr_t)breakPtr;
*(breakPtr-2) = CON_ENDEVENT | (g_lineNumber << 12);
breakPtr = (intptr_t*)*breakPtr;
}
@@ -6405,10 +6405,10 @@ void C_Compile(const char *filenam)
g_totalLines += g_lineNumber;
- C_SetScriptSize(g_scriptPtr-script+8);
+ C_SetScriptSize(g_scriptPtr-apScript+8);
initprintf("Script compiled in %dms, %ld bytes%s\n", getticks() - startcompiletime,
- (unsigned long)(g_scriptPtr-script), C_ScriptVersionString(g_scriptVersion));
+ (unsigned long)(g_scriptPtr-apScript), C_ScriptVersionString(g_scriptVersion));
for (i=0; (unsigned)i < ARRAY_SIZE(tables_free); i++)
hash_free(tables_free[i]);
diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h
index f33d8178a..e14bd3fa4 100644
--- a/polymer/eduke32/source/gamedef.h
+++ b/polymer/eduke32/source/gamedef.h
@@ -40,15 +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_szScriptFileName, g_lineNumber, ##__VA_ARGS__); \
+ g_numCompilerErrors++; \
} 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_szScriptFileName, g_lineNumber, ##__VA_ARGS__); \
+ g_numCompilerWarnings++; \
} while (0)
#if !defined LUNATIC
@@ -63,19 +68,20 @@ extern hashtable_t h_gamevars;
extern hashtable_t h_arrays;
extern hashtable_t h_labels;
-extern int32_t g_iReturnVarID; // var ID of "RETURN"
-extern int32_t g_iWeaponVarID; // var ID of "WEAPON"
-extern int32_t g_iWorksLikeVarID; // var ID of "WORKSLIKE"
-extern int32_t g_iZRangeVarID; // var ID of "ZRANGE"
-extern int32_t g_iAngRangeVarID; // var ID of "ANGRANGE"
-extern int32_t g_iAimAngleVarID; // var ID of "AUTOAIMANGLE"
-extern int32_t g_iLoTagID; // var ID of "LOTAG"
-extern int32_t g_iHiTagID; // var ID of "HITAG"
-extern int32_t g_iTextureID; // var ID of "TEXTURE"
-extern int32_t g_iThisActorID; // var ID of "THISACTOR"
+extern int32_t g_returnVarID; // var ID of "RETURN"
+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 {
+enum QuickStructureAccess_t
+{
STRUCT_SPRITE,
STRUCT_SECTOR,
STRUCT_WALL,
@@ -92,20 +98,20 @@ enum QuickStructureAccess_t {
NUMQUICKSTRUCTS,
};
-extern int32_t g_iStructVarIDs;
+extern int32_t g_structVarIDs;
-extern intptr_t apScriptGameEvent[MAXGAMEEVENTS];
+extern intptr_t apScriptEvents[MAXGAMEEVENTS];
#endif
-extern int32_t otherp;
-extern char CheatStrings[][MAXCHEATLEN];
+extern int32_t otherp;
+extern char CheatStrings[][MAXCHEATLEN];
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_numQuoteRedefinitions;
-extern int32_t g_scriptVersion;
-extern char g_szBuf[1024];
+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 const char *EventNames[]; // MAXEVENTS
@@ -142,11 +148,19 @@ void C_InitProjectiles(void);
extern int32_t g_numProjectiles;
typedef struct {
- int g_i, g_p, g_x;
- int32_t *g_t;
- spritetype *g_sp;
- DukePlayer_t *g_pp;
- int g_flags;
+ int spriteNum;
+ int playerNum;
+ int playerDist;
+ int flags;
+
+ union {
+ spritetype * pSprite;
+ uspritetype *pUSprite;
+ };
+
+ int32_t * pData;
+ DukePlayer_t *pPlayer;
+
} vmstate_t;
extern vmstate_t vm;
diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c
index b53cf0d40..408775080 100644
--- a/polymer/eduke32/source/gameexec.c
+++ b/polymer/eduke32/source/gameexec.c
@@ -59,17 +59,17 @@ int32_t g_currentEventExec = -1;
intptr_t const *insptr;
-int32_t g_iReturnVarID = -1; // var ID of "RETURN"
-int32_t g_iWeaponVarID = -1; // var ID of "WEAPON"
-int32_t g_iWorksLikeVarID = -1; // var ID of "WORKSLIKE"
-int32_t g_iZRangeVarID = -1; // var ID of "ZRANGE"
-int32_t g_iAngRangeVarID = -1; // var ID of "ANGRANGE"
-int32_t g_iAimAngleVarID = -1; // var ID of "AUTOAIMANGLE"
-int32_t g_iLoTagID = -1; // var ID of "LOTAG"
-int32_t g_iHiTagID = -1; // var ID of "HITAG"
-int32_t g_iTextureID = -1; // var ID of "TEXTURE"
-int32_t g_iThisActorID = -1; // var ID of "THISACTOR"
-int32_t g_iStructVarIDs = -1;
+int32_t g_returnVarID = -1; // var ID of "RETURN"
+int32_t g_weaponVarID = -1; // var ID of "WEAPON"
+int32_t g_worksLikeVarID = -1; // var ID of "WORKSLIKE"
+int32_t g_zRangeVarID = -1; // var ID of "ZRANGE"
+int32_t g_angRangeVarID = -1; // var ID of "ANGRANGE"
+int32_t g_aimAngleVarID = -1; // var ID of "AUTOAIMANGLE"
+int32_t g_lotagVarID = -1; // var ID of "LOTAG"
+int32_t g_hitagVarID = -1; // var ID of "HITAG"
+int32_t g_textureVarID = -1; // var ID of "TEXTURE"
+int32_t g_thisActorVarID = -1; // var ID of "THISACTOR"
+int32_t g_structVarIDs = -1;
GAMEEXEC_STATIC void VM_Execute(int loop);
@@ -88,21 +88,23 @@ GAMEEXEC_STATIC void VM_Execute(int loop);
#if !defined LUNATIC
void VM_ScriptInfo(intptr_t const *ptr, int range)
{
- if (!script)
+ if (!apScript)
return;
if (ptr)
{
initprintf("\n");
- for (intptr_t const *p = max(ptr - (range>>1), script), *p_end = min(ptr + (range>>1), script + g_scriptSize); p < p_end; p++)
+ for (intptr_t const *pScript = max(ptr - (range >> 1), apScript),
+ *p_end = min(ptr + (range >> 1), apScript + g_scriptSize);
+ pScript < p_end; pScript++)
{
- initprintf("%5d: %3d: ", (int32_t) (p - script), (int32_t) (p - ptr));
+ initprintf("%5d: %3d: ", (int32_t) (pScript - apScript), (int32_t) (pScript - ptr));
- if (*p >> 12 && (*p & VM_INSTMASK) < CON_END)
- initprintf("%5d %s\n", (int32_t) (*p >> 12), keyw[*p & VM_INSTMASK]);
+ if (*pScript >> 12 && (*pScript & VM_INSTMASK) < CON_END)
+ initprintf("%5d %s\n", (int32_t) (*pScript >> 12), keyw[*pScript & VM_INSTMASK]);
else
- initprintf("%d\n", (int32_t) *p);
+ initprintf("%d\n", (int32_t) *pScript);
}
initprintf("\n");
@@ -110,53 +112,58 @@ void VM_ScriptInfo(intptr_t const *ptr, int range)
if (ptr == insptr)
{
- if (vm.g_i)
- initprintf("current actor: %d (%d)\n", vm.g_i, TrackerCast(vm.g_sp->picnum));
+ if (vm.spriteNum)
+ initprintf("current actor: %d (%d)\n", vm.spriteNum, TrackerCast(vm.pSprite->picnum));
initprintf("g_errorLineNum: %d, g_tw: %d\n", g_errorLineNum, g_tw);
}
}
#endif
-static void VM_DeleteSprite(int nSprite, int nPlayer)
+static void VM_DeleteSprite(int spriteNum, int playerNum)
{
- if (EDUKE32_PREDICT_FALSE((unsigned) nSprite >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum >= MAXSPRITES))
return;
// if player was set to squish, first stop that...
- if (EDUKE32_PREDICT_FALSE(nPlayer >= 0 && g_player[nPlayer].ps->actorsqu == nSprite))
- g_player[nPlayer].ps->actorsqu = -1;
+ if (EDUKE32_PREDICT_FALSE(playerNum >= 0 && g_player[playerNum].ps->actorsqu == spriteNum))
+ g_player[playerNum].ps->actorsqu = -1;
- A_DeleteSprite(nSprite);
+ A_DeleteSprite(spriteNum);
}
-intptr_t apScriptGameEvent[MAXGAMEEVENTS];
+intptr_t apScriptEvents[MAXGAMEEVENTS];
// May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT
#ifdef LUNATIC
-FORCE_INLINE int32_t VM_EventCommon_(int nEventID, int nSprite, int nPlayer, int nDist, int32_t nReturn)
+FORCE_INLINE int32_t VM_EventCommon_(int eventNum, int spriteNum, int playerNum, int playerDist, int32_t returnValue)
{
const double t = gethiticks();
- int32_t ret = El_CallEvent(&g_ElState, nEventID, nSprite, nPlayer, nDist, &nReturn);
+ int32_t ret = El_CallEvent(&g_ElState, eventNum, spriteNum, playerNum, playerDist, &returnValue);
// NOTE: the run times are those of the called event plus any events
// called by it, *not* "self" time.
- g_eventTotalMs[nEventID] += gethiticks()-t;
- g_eventCalls[nEventID]++;
+ g_eventTotalMs[eventNum] += gethiticks()-t;
+ g_eventCalls[eventNum]++;
if (ret == 1)
- VM_DeleteSprite(nSprite, nPlayer);
+ VM_DeleteSprite(spriteNum, playerNum);
- return nReturn;
+ return returnValue;
}
#else
-FORCE_INLINE int32_t VM_EventCommon_(int const nEventID, int const nSprite, int const nPlayer,
- int const nDist, int32_t nReturn)
+FORCE_INLINE int32_t VM_EventCommon_(int const eventNum, int const spriteNum, int const playerNum,
+ int const playerDist, int32_t returnValue)
{
- // this is initialized first thing because iActor, iPlayer, lDist, etc are already right there on the stack
+ // this is initialized first thing because spriteNum, playerNum, lDist, etc are already right there on the stack
// from the function call
- const vmstate_t tempvm = { nSprite, nPlayer, nDist, &actor[(unsigned)nSprite].t_data[0],
- &sprite[(unsigned)nSprite], g_player[nPlayer].ps, 0 };
+ const vmstate_t tempvm = { spriteNum,
+ playerNum,
+ playerDist,
+ 0,
+ &sprite[(unsigned)spriteNum],
+ &actor[(unsigned)spriteNum].t_data[0],
+ g_player[playerNum].ps };
// since we're targeting C99 and C++ now, we can interweave these to avoid
// having to load addresses for things twice
@@ -165,36 +172,34 @@ FORCE_INLINE int32_t VM_EventCommon_(int const nEventID, int const nSprite, int
// reload the address of aGameVars[g_iReturnVarID].lValue in order to
// set it to the value of iReturn (...which should still be on the stack!)
- int const backupReturnVar = aGameVars[g_iReturnVarID].nValue;
- aGameVars[g_iReturnVarID].nValue = nReturn;
+ int const backupReturnVar = aGameVars[g_returnVarID].global;
+ aGameVars[g_returnVarID].global = returnValue;
+ int const backupEventExec = g_currentEventExec;
+ g_currentEventExec = eventNum;
+ intptr_t const *oinsptr = insptr;
+ insptr = apScript + apScriptEvents[eventNum];
+ const vmstate_t vm_backup = vm;
- int const backupEventExec = g_currentEventExec;
- g_currentEventExec = nEventID;
-
- intptr_t const *oinsptr = insptr;
- insptr = script + apScriptGameEvent[nEventID];
-
- const vmstate_t vm_backup = vm;
vm = tempvm;
// check tempvm instead of vm... this way, we are not actually loading
// FROM vm anywhere until VM_Execute() is called
- if ((unsigned)tempvm.g_i >= MAXSPRITES)
+ if ((unsigned)tempvm.spriteNum >= MAXSPRITES)
{
static spritetype dummy_sprite;
static int32_t dummy_t[ARRAY_SIZE(actor[0].t_data)];
- vm.g_sp = &dummy_sprite;
- vm.g_t = dummy_t;
+ vm.pSprite = &dummy_sprite;
+ vm.pData = dummy_t;
}
- if ((unsigned)nPlayer >= (unsigned)playerswhenstarted)
- vm.g_pp = g_player[0].ps;
+ if ((unsigned)playerNum >= (unsigned)playerswhenstarted)
+ vm.pPlayer = g_player[0].ps;
VM_Execute(1);
- if (vm.g_flags & VM_KILL)
- VM_DeleteSprite(vm.g_i, vm.g_p);
+ if (vm.flags & VM_KILL)
+ VM_DeleteSprite(vm.spriteNum, vm.playerNum);
// this needs to happen after VM_DeleteSprite() because VM_DeleteSprite()
// can trigger additional events
@@ -202,10 +207,10 @@ FORCE_INLINE int32_t VM_EventCommon_(int const nEventID, int const nSprite, int
vm = vm_backup;
insptr = oinsptr;
g_currentEventExec = backupEventExec;
- nReturn = aGameVars[g_iReturnVarID].nValue;
- aGameVars[g_iReturnVarID].nValue = backupReturnVar;
+ returnValue = aGameVars[g_returnVarID].global;
+ aGameVars[g_returnVarID].global = backupReturnVar;
- return nReturn;
+ return returnValue;
}
#endif
@@ -213,61 +218,63 @@ FORCE_INLINE int32_t VM_EventCommon_(int const nEventID, int const nSprite, int
// which are not only optimized further based on lDist or iReturn (or both) having values known at compile time,
// but are called faster due to having less parameters
-int32_t VM_OnEventWithBoth_(int nEventID, int nSprite, int nPlayer, int nDist, int32_t nReturn)
+int32_t VM_OnEventWithBoth_(int eventNum, int spriteNum, int playerNum, int playerDist, int32_t returnValue)
{
- return VM_EventCommon_(nEventID, nSprite, nPlayer, nDist, nReturn);
+ return VM_EventCommon_(eventNum, spriteNum, playerNum, playerDist, returnValue);
}
-int32_t VM_OnEventWithReturn_(int nEventID, int nSprite, int nPlayer, int32_t nReturn)
+int32_t VM_OnEventWithReturn_(int eventNum, int spriteNum, int playerNum, int32_t returnValue)
{
- return VM_EventCommon_(nEventID, nSprite, nPlayer, -1, nReturn);
+ return VM_EventCommon_(eventNum, spriteNum, playerNum, -1, returnValue);
}
-int32_t VM_OnEventWithDist_(int nEventID, int nSprite, int nPlayer, int nDist)
+int32_t VM_OnEventWithDist_(int eventNum, int spriteNum, int playerNum, int playerDist)
{
- return VM_EventCommon_(nEventID, nSprite, nPlayer, nDist, 0);
+ return VM_EventCommon_(eventNum, spriteNum, playerNum, playerDist, 0);
}
-int32_t VM_OnEvent_(int nEventID, int nSprite, int nPlayer)
+int32_t VM_OnEvent_(int eventNum, int spriteNum, int playerNum)
{
- return VM_EventCommon_(nEventID, nSprite, nPlayer, -1, 0);
+ return VM_EventCommon_(eventNum, spriteNum, playerNum, -1, 0);
}
static int32_t VM_CheckSquished(void)
{
- sectortype const * const sc = §or[vm.g_sp->sectnum];
+ usectortype const * const pSector = (usectortype *)§or[vm.pSprite->sectnum];
- if (sc->lotag == ST_23_SWINGING_DOOR ||
- (sc->lotag == ST_1_ABOVE_WATER && !A_CheckNoSE7Water(vm.g_sp, vm.g_sp->sectnum, sc->lotag, NULL)) ||
- (vm.g_sp->picnum == APLAYER && ud.noclip))
+ if (pSector->lotag == ST_23_SWINGING_DOOR ||
+ (pSector->lotag == ST_1_ABOVE_WATER &&
+ !A_CheckNoSE7Water((uspritetype const *)vm.pSprite, vm.pSprite->sectnum, pSector->lotag, NULL)) ||
+ (vm.pSprite->picnum == APLAYER && ud.noclip))
return 0;
- int32_t fz=sc->floorz, cz=sc->ceilingz;
+ int32_t floorZ = pSector->floorz;
+ int32_t ceilZ = pSector->ceilingz;
#ifdef YAX_ENABLE
int16_t cb, fb;
- yax_getbunches(vm.g_sp->sectnum, &cb, &fb);
+ yax_getbunches(vm.pSprite->sectnum, &cb, &fb);
- if (cb >= 0 && (sc->ceilingstat&512)==0) // if ceiling non-blocking...
- cz -= (32<<8); // unconditionally don't squish... yax_getneighborsect is slowish :/
- if (fb >= 0 && (sc->floorstat&512)==0)
- fz += (32<<8);
+ if (cb >= 0 && (pSector->ceilingstat&512)==0) // if ceiling non-blocking...
+ ceilZ -= (32<<8); // unconditionally don't squish... yax_getneighborsect is slowish :/
+ if (fb >= 0 && (pSector->floorstat&512)==0)
+ floorZ += (32<<8);
#endif
- if (vm.g_sp->pal == 1 ?
- (fz - cz >= (32<<8) || (sc->lotag&32768)) :
- (fz - cz >= (12<<8)))
+ if (vm.pSprite->pal == 1 ?
+ (floorZ - ceilZ >= (32<<8) || (pSector->lotag&32768)) :
+ (floorZ - ceilZ >= ZOFFSET4))
return 0;
- P_DoQuote(QUOTE_SQUISHED, vm.g_pp);
+ P_DoQuote(QUOTE_SQUISHED, vm.pPlayer);
- if (A_CheckEnemySprite(vm.g_sp))
- vm.g_sp->xvel = 0;
+ if (A_CheckEnemySprite(vm.pSprite))
+ vm.pSprite->xvel = 0;
- if (EDUKE32_PREDICT_FALSE(vm.g_sp->pal == 1)) // frozen
+ if (EDUKE32_PREDICT_FALSE(vm.pSprite->pal == 1)) // frozen
{
- actor[vm.g_i].picnum = SHOTSPARK1;
- actor[vm.g_i].extra = 1;
+ actor[vm.spriteNum].picnum = SHOTSPARK1;
+ actor[vm.spriteNum].extra = 1;
return 0;
}
@@ -275,13 +282,14 @@ static int32_t VM_CheckSquished(void)
}
#if !defined LUNATIC
-GAMEEXEC_STATIC GAMEEXEC_INLINE void P_ForceAngle(DukePlayer_t *p)
+GAMEEXEC_STATIC GAMEEXEC_INLINE void P_ForceAngle(DukePlayer_t *pPlayer)
{
int const nAngle = 128-(krand()&255);
- p->horiz += 64;
- p->return_to_center = 9;
- p->look_ang = p->rotscrnang = nAngle>>1;
+ pPlayer->horiz += 64;
+ pPlayer->return_to_center = 9;
+ pPlayer->rotscrnang = nAngle >> 1;
+ pPlayer->look_ang = pPlayer->rotscrnang;
}
#endif
@@ -295,11 +303,11 @@ int32_t A_Dodge(spritetype *pSprite)
for (int nexti, SPRITES_OF_STAT_SAFE(STAT_PROJECTILE, i, nexti)) //weapons list
{
- if (OW == i)
+ if (OW(i) == i)
continue;
- vec2_t const b = { SX - m.x, SY - m.y };
- vec2_t const v = { sintable[(SA + 512) & 2047], sintable[SA & 2047] };
+ vec2_t const b = { SX(i) - m.x, SY(i) - m.y };
+ vec2_t const v = { sintable[(SA(i) + 512) & 2047], sintable[SA(i) & 2047] };
if (((msin.x * b.x) + (msin.y * b.y) >= 0) && ((v.x * b.x) + (v.y * b.y) < 0))
{
@@ -314,27 +322,28 @@ int32_t A_Dodge(spritetype *pSprite)
return 0;
}
-int32_t A_GetFurthestAngle(int32_t iActor, int32_t angs)
+int32_t A_GetFurthestAngle(int spriteNum, int angDiv)
{
- spritetype *const s = &sprite[iActor];
+ uspritetype *const pSprite = (uspritetype *)&sprite[spriteNum];
- if (s->picnum != APLAYER && (AC_COUNT(actor[iActor].t_data)&63) > 2)
- return s->ang + 1024;
+ if (pSprite->picnum != APLAYER && (AC_COUNT(actor[spriteNum].t_data)&63) > 2)
+ return pSprite->ang + 1024;
- int32_t furthest_angle = 0, greatestd = INT32_MIN;
- int const angincs = tabledivide32_noinline(2048, angs);
+ int32_t furthest_angle = 0;
+ int32_t greatestd = INT32_MIN;
+ int const angincs = tabledivide32_noinline(2048, angDiv);
hitdata_t hit;
- for (int32_t j=s->ang; j<(2048+s->ang); j+=angincs)
+ for (int j = pSprite->ang; j < (2048 + pSprite->ang); j += angincs)
{
- s->z -= (8<<8);
- hitscan((const vec3_t *)s, s->sectnum,
+ pSprite->z -= ZOFFSET3;
+ hitscan((const vec3_t *)pSprite, pSprite->sectnum,
sintable[(j+512)&2047],
sintable[j&2047], 0,
&hit, CLIPMASK1);
- s->z += (8<<8);
+ pSprite->z += ZOFFSET3;
- int const d = klabs(hit.pos.x-s->x) + klabs(hit.pos.y-s->y);
+ int const d = klabs(hit.pos.x-pSprite->x) + klabs(hit.pos.y-pSprite->y);
if (d > greatestd)
{
@@ -346,12 +355,12 @@ int32_t A_GetFurthestAngle(int32_t iActor, int32_t angs)
return furthest_angle&2047;
}
-int32_t A_FurthestVisiblePoint(int32_t nSprite, uspritetype * const pSprite, int32_t *dax, int32_t *day)
+int32_t A_FurthestVisiblePoint(int32_t spriteNum, uspritetype * const pSprite, int32_t *dax, int32_t *day)
{
- if (AC_COUNT(actor[nSprite].t_data)&63)
+ if (AC_COUNT(actor[spriteNum].t_data)&63)
return -1;
- const uspritetype *const pnSprite = (uspritetype *)&sprite[nSprite];
+ const uspritetype *const pnSprite = (uspritetype *)&sprite[spriteNum];
hitdata_t hit;
int const angincs = 128;
@@ -385,30 +394,30 @@ int32_t A_FurthestVisiblePoint(int32_t nSprite, uspritetype * const pSprite, int
return -1;
}
-static void VM_GetZRange(int32_t iActor, int32_t *ceilhit, int32_t *florhit, int walldist)
+static void VM_GetZRange(int32_t spriteNum, int32_t *ceilhit, int32_t *florhit, int wallDist)
{
- spritetype *const s = &sprite[iActor];
- int const ocstat = s->cstat;
+ uspritetype *const pSprite = (uspritetype *)&sprite[spriteNum];
+ int const ocstat = pSprite->cstat;
- s->cstat = 0;
- s->z -= ZOFFSET;
+ pSprite->cstat = 0;
+ pSprite->z -= ZOFFSET;
- getzrange((vec3_t *)s, s->sectnum,
- &actor[iActor].ceilingz, ceilhit,
- &actor[iActor].floorz, florhit,
- walldist, CLIPMASK0);
+ getzrange((vec3_t *)pSprite, pSprite->sectnum,
+ &actor[spriteNum].ceilingz, ceilhit,
+ &actor[spriteNum].floorz, florhit,
+ wallDist, CLIPMASK0);
- s->z += ZOFFSET;
- s->cstat = ocstat;
+ pSprite->z += ZOFFSET;
+ pSprite->cstat = ocstat;
}
-void A_GetZLimits(int32_t nSprite)
+void A_GetZLimits(int32_t spriteNum)
{
- spritetype *const pSprite = &sprite[nSprite];
+ spritetype *const pSprite = &sprite[spriteNum];
int32_t ceilhit, florhit;
- VM_GetZRange(nSprite, &ceilhit, &florhit, (pSprite->statnum == STAT_PROJECTILE) ? 4 : 127);
- actor[nSprite].flags &= ~SFLAG_NOFLOORSHADOW;
+ VM_GetZRange(spriteNum, &ceilhit, &florhit, (pSprite->statnum == STAT_PROJECTILE) ? 4 : 127);
+ actor[spriteNum].flags &= ~SFLAG_NOFLOORSHADOW;
if ((florhit&49152) == 49152 && (sprite[florhit&(MAXSPRITES-1)].cstat&48) == 0)
{
@@ -420,44 +429,44 @@ void A_GetZLimits(int32_t nSprite)
if ((A_CheckEnemySprite(hitspr) && hitspr->pal != 1 && pSprite->statnum != STAT_PROJECTILE)
|| (hitspr->picnum == APLAYER && A_CheckEnemySprite(pSprite)))
{
- actor[nSprite].flags |= SFLAG_NOFLOORSHADOW; // No shadows on actors
+ actor[spriteNum].flags |= SFLAG_NOFLOORSHADOW; // No shadows on actors
pSprite->xvel = -256; // SLIDE_ABOVE_ENEMY
- A_SetSprite(nSprite, CLIPMASK0);
+ A_SetSprite(spriteNum, CLIPMASK0);
}
else if (pSprite->statnum == STAT_PROJECTILE && hitspr->picnum == APLAYER && pSprite->owner==florhit)
{
- actor[nSprite].ceilingz = sector[pSprite->sectnum].ceilingz;
- actor[nSprite].floorz = sector[pSprite->sectnum].floorz;
+ actor[spriteNum].ceilingz = sector[pSprite->sectnum].ceilingz;
+ actor[spriteNum].floorz = sector[pSprite->sectnum].floorz;
}
}
}
-void A_Fall(int nSprite)
+void A_Fall(int spriteNum)
{
- spritetype *const pSprite = &sprite[nSprite];
- int nGravity = g_spriteGravity;
+ spritetype *const pSprite = &sprite[spriteNum];
+ int spriteGravity = g_spriteGravity;
if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(pSprite->sectnum)))
- nGravity = 0;
+ spriteGravity = 0;
else if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER || EDUKE32_PREDICT_FALSE(G_CheckForSpaceCeiling(pSprite->sectnum)))
- nGravity = g_spriteGravity/6;
+ spriteGravity = g_spriteGravity/6;
if (pSprite->statnum == STAT_ACTOR || pSprite->statnum == STAT_PLAYER || pSprite->statnum == STAT_ZOMBIEACTOR || pSprite->statnum == STAT_STANDABLE)
{
int32_t ceilhit, florhit;
- VM_GetZRange(nSprite, &ceilhit, &florhit, 127);
+ VM_GetZRange(spriteNum, &ceilhit, &florhit, 127);
}
else
{
- actor[nSprite].ceilingz = sector[pSprite->sectnum].ceilingz;
- actor[nSprite].floorz = sector[pSprite->sectnum].floorz;
+ actor[spriteNum].ceilingz = sector[pSprite->sectnum].ceilingz;
+ actor[spriteNum].floorz = sector[pSprite->sectnum].floorz;
}
#ifdef YAX_ENABLE
int fbunch = (sector[pSprite->sectnum].floorstat&512) ? -1 : yax_getbunch(pSprite->sectnum, YAX_FLOOR);
#endif
- if (pSprite->z < actor[nSprite].floorz-ZOFFSET
+ if (pSprite->z < actor[spriteNum].floorz-ZOFFSET
#ifdef YAX_ENABLE
|| fbunch >= 0
#endif
@@ -465,135 +474,136 @@ void A_Fall(int nSprite)
{
if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER && pSprite->zvel > 3122)
pSprite->zvel = 3144;
- pSprite->z += pSprite->zvel = min(6144, pSprite->zvel+nGravity);
+ pSprite->z += pSprite->zvel = min(6144, pSprite->zvel+spriteGravity);
}
#ifdef YAX_ENABLE
if (fbunch >= 0)
- setspritez(nSprite, (vec3_t *)pSprite);
+ setspritez(spriteNum, (vec3_t *)pSprite);
else
#endif
- if (pSprite->z >= actor[nSprite].floorz-ZOFFSET)
+ if (pSprite->z >= actor[spriteNum].floorz-ZOFFSET)
{
- pSprite->z = actor[nSprite].floorz-ZOFFSET;
+ pSprite->z = actor[spriteNum].floorz-ZOFFSET;
pSprite->zvel = 0;
}
}
-int G_GetAngleDelta(int a, int na)
+int G_GetAngleDelta(int currAngle, int newAngle)
{
- a &= 2047;
- na &= 2047;
+ currAngle &= 2047;
+ newAngle &= 2047;
- if (klabs(a-na) < 1024)
+ if (klabs(currAngle-newAngle) < 1024)
{
// OSD_Printf("G_GetAngleDelta() returning %d\n",na-a);
- return na-a;
+ return newAngle-currAngle;
}
- if (na > 1024) na -= 2048;
- if (a > 1024) a -= 2048;
+ if (newAngle > 1024) newAngle -= 2048;
+ if (currAngle > 1024) currAngle -= 2048;
// OSD_Printf("G_GetAngleDelta() returning %d\n",na-a);
- return na-a;
+ return newAngle-currAngle;
}
-GAMEEXEC_STATIC void VM_AlterAng(int32_t movflags)
+GAMEEXEC_STATIC void VM_AlterAng(int32_t moveFlags)
{
- int const nElapsedTics = (AC_COUNT(vm.g_t))&31;
+ int const elapsedTics = (AC_COUNT(vm.pData))&31;
#if !defined LUNATIC
const intptr_t *moveptr;
- if (EDUKE32_PREDICT_FALSE((unsigned)AC_MOVE_ID(vm.g_t) >= (unsigned)g_scriptSize-1))
+ if (EDUKE32_PREDICT_FALSE((unsigned)AC_MOVE_ID(vm.pData) >= (unsigned)g_scriptSize-1))
{
- AC_MOVE_ID(vm.g_t) = 0;
- OSD_Printf(OSD_ERROR "bad moveptr for actor %d (%d)!\n", vm.g_i, TrackerCast(vm.g_sp->picnum));
+ AC_MOVE_ID(vm.pData) = 0;
+ OSD_Printf(OSD_ERROR "bad moveptr for actor %d (%d)!\n", vm.spriteNum, TrackerCast(vm.pSprite->picnum));
return;
}
- moveptr = script + AC_MOVE_ID(vm.g_t);
+ moveptr = apScript + AC_MOVE_ID(vm.pData);
- vm.g_sp->xvel += (moveptr[0] - vm.g_sp->xvel)/5;
- if (vm.g_sp->zvel < 648)
- vm.g_sp->zvel += ((moveptr[1]<<4) - vm.g_sp->zvel)/5;
+ vm.pSprite->xvel += (moveptr[0] - vm.pSprite->xvel)/5;
+ if (vm.pSprite->zvel < 648)
+ vm.pSprite->zvel += ((moveptr[1]<<4) - vm.pSprite->zvel)/5;
#else
- vm.g_sp->xvel += (actor[vm.g_i].mv.hvel - vm.g_sp->xvel)/5;
- if (vm.g_sp->zvel < 648)
- vm.g_sp->zvel += ((actor[vm.g_i].mv.vvel<<4) - vm.g_sp->zvel)/5;
+ vm.pSprite->xvel += (actor[vm.spriteNum].mv.hvel - vm.pSprite->xvel)/5;
+ if (vm.pSprite->zvel < 648)
+ vm.pSprite->zvel += ((actor[vm.spriteNum].mv.vvel<<4) - vm.pSprite->zvel)/5;
#endif
- if (A_CheckEnemySprite(vm.g_sp) && vm.g_sp->extra <= 0) // hack
+ if (A_CheckEnemySprite(vm.pSprite) && vm.pSprite->extra <= 0) // hack
return;
- if (movflags&seekplayer)
+ if (moveFlags&seekplayer)
{
- int nAngDiff;
- int nGoalAng;
- int const nAngle = vm.g_sp->ang;
- int32_t nHoloDuke = vm.g_pp->holoduke_on;
+ int angDiff;
+ int goalAng;
+ int const spriteAngle = vm.pSprite->ang;
+ int32_t holoDukeSprite = vm.pPlayer->holoduke_on;
// NOTE: looks like 'owner' is set to target sprite ID...
- if (nHoloDuke >= 0 && cansee(sprite[nHoloDuke].x, sprite[nHoloDuke].y, sprite[nHoloDuke].z, sprite[nHoloDuke].sectnum,
- vm.g_sp->x, vm.g_sp->y, vm.g_sp->z, vm.g_sp->sectnum))
- vm.g_sp->owner = nHoloDuke;
- else vm.g_sp->owner = vm.g_pp->i;
+ if (holoDukeSprite >= 0 &&
+ cansee(sprite[holoDukeSprite].x, sprite[holoDukeSprite].y, sprite[holoDukeSprite].z,
+ sprite[holoDukeSprite].sectnum, vm.pSprite->x, vm.pSprite->y, vm.pSprite->z, vm.pSprite->sectnum))
+ vm.pSprite->owner = holoDukeSprite;
+ else vm.pSprite->owner = vm.pPlayer->i;
- nGoalAng = (sprite[vm.g_sp->owner].picnum == APLAYER)
- ? getangle(actor[vm.g_i].lastvx - vm.g_sp->x, actor[vm.g_i].lastvy - vm.g_sp->y)
- : getangle(sprite[vm.g_sp->owner].x - vm.g_sp->x, sprite[vm.g_sp->owner].y - vm.g_sp->y);
+ goalAng = (sprite[vm.pSprite->owner].picnum == APLAYER)
+ ? getangle(actor[vm.spriteNum].lastvx - vm.pSprite->x, actor[vm.spriteNum].lastvy - vm.pSprite->y)
+ : getangle(sprite[vm.pSprite->owner].x - vm.pSprite->x, sprite[vm.pSprite->owner].y - vm.pSprite->y);
- if (vm.g_sp->xvel && vm.g_sp->picnum != DRONE)
+ if (vm.pSprite->xvel && vm.pSprite->picnum != DRONE)
{
- nAngDiff = G_GetAngleDelta(nAngle,nGoalAng);
+ angDiff = G_GetAngleDelta(spriteAngle,goalAng);
- if (nElapsedTics < 2)
+ if (elapsedTics < 2)
{
- if (klabs(nAngDiff) < 256)
+ if (klabs(angDiff) < 256)
{
int const j = 128-(krand()&256);
- vm.g_sp->ang += j;
- if (A_GetHitscanRange(vm.g_i) < 844)
- vm.g_sp->ang -= j;
+ vm.pSprite->ang += j;
+ if (A_GetHitscanRange(vm.spriteNum) < 844)
+ vm.pSprite->ang -= j;
}
}
- else if (nElapsedTics > 18 && nElapsedTics < GAMETICSPERSEC) // choose
+ else if (elapsedTics > 18 && elapsedTics < GAMETICSPERSEC) // choose
{
- if (klabs(nAngDiff>>2) < 128) vm.g_sp->ang = nGoalAng;
- else vm.g_sp->ang += nAngDiff>>2;
+ if (klabs(angDiff>>2) < 128) vm.pSprite->ang = goalAng;
+ else vm.pSprite->ang += angDiff>>2;
}
}
- else vm.g_sp->ang = nGoalAng;
+ else vm.pSprite->ang = goalAng;
}
- if (nElapsedTics < 1)
+ if (elapsedTics < 1)
{
- if (movflags&furthestdir)
+ if (moveFlags&furthestdir)
{
- vm.g_sp->ang = A_GetFurthestAngle(vm.g_i, 2);
- vm.g_sp->owner = vm.g_pp->i;
+ vm.pSprite->ang = A_GetFurthestAngle(vm.spriteNum, 2);
+ vm.pSprite->owner = vm.pPlayer->i;
}
- if (movflags&fleeenemy)
- vm.g_sp->ang = A_GetFurthestAngle(vm.g_i, 2);
+ if (moveFlags&fleeenemy)
+ vm.pSprite->ang = A_GetFurthestAngle(vm.spriteNum, 2);
}
}
-static inline void VM_AddAngle(int nShift, int nGoalAng)
+static inline void VM_AddAngle(int shift, int goalAng)
{
- int nAngDiff = G_GetAngleDelta(vm.g_sp->ang, nGoalAng) >> nShift;
+ int angDiff = G_GetAngleDelta(vm.pSprite->ang, goalAng) >> shift;
- if ((nAngDiff > -8 && nAngDiff < 0) || (nAngDiff < 8 && nAngDiff > 0))
- nAngDiff <<= 1;
+ if ((angDiff > -8 && angDiff < 0) || (angDiff < 8 && angDiff > 0))
+ angDiff <<= 1;
- vm.g_sp->ang += nAngDiff;
+ vm.pSprite->ang += angDiff;
}
-static inline void VM_FacePlayer(int nShift)
+static inline void VM_FacePlayer(int shift)
{
- VM_AddAngle(nShift, (vm.g_pp->newowner >= 0) ? getangle(vm.g_pp->opos.x - vm.g_sp->x, vm.g_pp->opos.y - vm.g_sp->y)
- : getangle(vm.g_pp->pos.x - vm.g_sp->x, vm.g_pp->pos.y - vm.g_sp->y));
+ VM_AddAngle(shift, (vm.pPlayer->newowner >= 0) ? getangle(vm.pPlayer->opos.x - vm.pSprite->x, vm.pPlayer->opos.y - vm.pSprite->y)
+ : getangle(vm.pPlayer->pos.x - vm.pSprite->x, vm.pPlayer->pos.y - vm.pSprite->y));
}
////////// TROR get*zofslope //////////
@@ -601,8 +611,8 @@ static inline void VM_FacePlayer(int nShift)
static int32_t VM_GetCeilZOfSlope(void)
{
- vec2_t const vect = *(vec2_t *)vm.g_sp;
- int const sectnum = vm.g_sp->sectnum;
+ vec2_t const vect = *(vec2_t *)vm.pSprite;
+ int const sectnum = vm.pSprite->sectnum;
#ifdef YAX_ENABLE
if ((sector[sectnum].ceilingstat&512)==0)
@@ -617,8 +627,8 @@ static int32_t VM_GetCeilZOfSlope(void)
static int32_t VM_GetFlorZOfSlope(void)
{
- vec2_t const vect = *(vec2_t *)vm.g_sp;
- int const sectnum = vm.g_sp->sectnum;
+ vec2_t const vect = *(vec2_t *)vm.pSprite;
+ int const sectnum = vm.pSprite->sectnum;
#ifdef YAX_ENABLE
if ((sector[sectnum].floorstat&512)==0)
@@ -642,19 +652,19 @@ GAMEEXEC_STATIC void VM_Move(void)
#endif
// NOTE: commented out condition is dead since r3159 (making hi/lotag unsigned).
// XXX: Does it break anything? Where are movflags with all bits set created?
- const uint16_t *movflagsptr = &AC_MOVFLAGS(vm.g_sp, &actor[vm.g_i]);
+ const uint16_t *movflagsptr = &AC_MOVFLAGS(vm.pSprite, &actor[vm.spriteNum]);
int const movflags = /*(*movflagsptr==-1) ? 0 :*/ *movflagsptr;
- int const deadflag = (A_CheckEnemySprite(vm.g_sp) && vm.g_sp->extra <= 0);
+ int const deadflag = (A_CheckEnemySprite(vm.pSprite) && vm.pSprite->extra <= 0);
- AC_COUNT(vm.g_t)++;
+ AC_COUNT(vm.pData)++;
- if (AC_MOVE_ID(vm.g_t) == 0 || movflags == 0)
+ if (AC_MOVE_ID(vm.pData) == 0 || movflags == 0)
{
- if (deadflag || (actor[vm.g_i].bpos.x != vm.g_sp->x) || (actor[vm.g_i].bpos.y != vm.g_sp->y))
+ if (deadflag || (actor[vm.spriteNum].bpos.x != vm.pSprite->x) || (actor[vm.spriteNum].bpos.y != vm.pSprite->y))
{
- actor[vm.g_i].bpos.x = vm.g_sp->x;
- actor[vm.g_i].bpos.y = vm.g_sp->y;
- setsprite(vm.g_i, (vec3_t *)vm.g_sp);
+ actor[vm.spriteNum].bpos.x = vm.pSprite->x;
+ actor[vm.spriteNum].bpos.y = vm.pSprite->y;
+ setsprite(vm.spriteNum, (vec3_t *)vm.pSprite);
}
return;
}
@@ -666,181 +676,181 @@ GAMEEXEC_STATIC void VM_Move(void)
VM_FacePlayer(2);
if (movflags&spin)
- vm.g_sp->ang += sintable[((AC_COUNT(vm.g_t)<<3)&2047)]>>6;
+ vm.pSprite->ang += sintable[((AC_COUNT(vm.pData)<<3)&2047)]>>6;
if (movflags&face_player_slow)
VM_FacePlayer(4);
if ((movflags&jumptoplayer_bits) == jumptoplayer_bits)
{
- if (AC_COUNT(vm.g_t) < 16)
- vm.g_sp->zvel -= (sintable[(512+(AC_COUNT(vm.g_t)<<4))&2047]>>5);
+ if (AC_COUNT(vm.pData) < 16)
+ vm.pSprite->zvel -= (sintable[(512+(AC_COUNT(vm.pData)<<4))&2047]>>5);
}
if (movflags&face_player_smart)
{
- vec2_t const vect = { vm.g_pp->pos.x + (vm.g_pp->vel.x / 768),
- vm.g_pp->pos.y + (vm.g_pp->vel.y / 768) };
- VM_AddAngle(2, getangle(vect.x - vm.g_sp->x, vect.y - vm.g_sp->y));
+ vec2_t const vect = { vm.pPlayer->pos.x + (vm.pPlayer->vel.x / 768),
+ vm.pPlayer->pos.y + (vm.pPlayer->vel.y / 768) };
+ VM_AddAngle(2, getangle(vect.x - vm.pSprite->x, vect.y - vm.pSprite->y));
}
dead:
#if !defined LUNATIC
- if (EDUKE32_PREDICT_FALSE((unsigned)AC_MOVE_ID(vm.g_t) >= (unsigned)g_scriptSize-1))
+ if (EDUKE32_PREDICT_FALSE((unsigned)AC_MOVE_ID(vm.pData) >= (unsigned)g_scriptSize-1))
{
- AC_MOVE_ID(vm.g_t) = 0;
- OSD_Printf(OSD_ERROR "clearing bad moveptr for actor %d (%d)\n", vm.g_i, TrackerCast(vm.g_sp->picnum));
+ AC_MOVE_ID(vm.pData) = 0;
+ OSD_Printf(OSD_ERROR "clearing bad moveptr for actor %d (%d)\n", vm.spriteNum, TrackerCast(vm.pSprite->picnum));
return;
}
- moveptr = script + AC_MOVE_ID(vm.g_t);
+ moveptr = apScript + AC_MOVE_ID(vm.pData);
- if (movflags&geth) vm.g_sp->xvel += ((moveptr[0])-vm.g_sp->xvel)>>1;
- if (movflags&getv) vm.g_sp->zvel += ((moveptr[1]<<4)-vm.g_sp->zvel)>>1;
+ if (movflags&geth) vm.pSprite->xvel += ((moveptr[0])-vm.pSprite->xvel)>>1;
+ if (movflags&getv) vm.pSprite->zvel += ((moveptr[1]<<4)-vm.pSprite->zvel)>>1;
#else
- if (movflags&geth) vm.g_sp->xvel += (actor[vm.g_i].mv.hvel - vm.g_sp->xvel)>>1;
- if (movflags&getv) vm.g_sp->zvel += (16*actor[vm.g_i].mv.vvel - vm.g_sp->zvel)>>1;
+ if (movflags&geth) vm.pSprite->xvel += (actor[vm.spriteNum].mv.hvel - vm.pSprite->xvel)>>1;
+ if (movflags&getv) vm.pSprite->zvel += (16*actor[vm.spriteNum].mv.vvel - vm.pSprite->zvel)>>1;
#endif
if (movflags&dodgebullet && !deadflag)
- A_Dodge(vm.g_sp);
+ A_Dodge(vm.pSprite);
- if (vm.g_sp->picnum != APLAYER)
+ if (vm.pSprite->picnum != APLAYER)
VM_AlterAng(movflags);
- if (vm.g_sp->xvel > -6 && vm.g_sp->xvel < 6)
- vm.g_sp->xvel = 0;
+ if (vm.pSprite->xvel > -6 && vm.pSprite->xvel < 6)
+ vm.pSprite->xvel = 0;
- int badguyp = A_CheckEnemySprite(vm.g_sp);
+ int badguyp = A_CheckEnemySprite(vm.pSprite);
- if (vm.g_sp->xvel || vm.g_sp->zvel)
+ if (vm.pSprite->xvel || vm.pSprite->zvel)
{
- int nXvel = vm.g_sp->xvel;
- int nAngDiff = vm.g_sp->ang;
+ int nXvel = vm.pSprite->xvel;
+ int angDiff = vm.pSprite->ang;
- if (badguyp && vm.g_sp->picnum != ROTATEGUN)
+ if (badguyp && vm.pSprite->picnum != ROTATEGUN)
{
- if ((vm.g_sp->picnum == DRONE || vm.g_sp->picnum == COMMANDER) && vm.g_sp->extra > 0)
+ if ((vm.pSprite->picnum == DRONE || vm.pSprite->picnum == COMMANDER) && vm.pSprite->extra > 0)
{
- if (vm.g_sp->picnum == COMMANDER)
+ if (vm.pSprite->picnum == COMMANDER)
{
int32_t nSectorZ;
// NOTE: COMMANDER updates both actor[].floorz and
// .ceilingz regardless of its zvel.
- actor[vm.g_i].floorz = nSectorZ = VM_GetFlorZOfSlope();
- if (vm.g_sp->z > nSectorZ-(8<<8))
+ actor[vm.spriteNum].floorz = nSectorZ = VM_GetFlorZOfSlope();
+ if (vm.pSprite->z > nSectorZ-ZOFFSET3)
{
- vm.g_sp->z = nSectorZ-(8<<8);
- vm.g_sp->zvel = 0;
+ vm.pSprite->z = nSectorZ-ZOFFSET3;
+ vm.pSprite->zvel = 0;
}
- actor[vm.g_i].ceilingz = nSectorZ = VM_GetCeilZOfSlope();
- if (vm.g_sp->z < nSectorZ+(80<<8))
+ actor[vm.spriteNum].ceilingz = nSectorZ = VM_GetCeilZOfSlope();
+ if (vm.pSprite->z < nSectorZ+(80<<8))
{
- vm.g_sp->z = nSectorZ+(80<<8);
- vm.g_sp->zvel = 0;
+ vm.pSprite->z = nSectorZ+(80<<8);
+ vm.pSprite->zvel = 0;
}
}
else
{
int32_t nSectorZ;
// The DRONE updates either .floorz or .ceilingz, not both.
- if (vm.g_sp->zvel > 0)
+ if (vm.pSprite->zvel > 0)
{
- actor[vm.g_i].floorz = nSectorZ = VM_GetFlorZOfSlope();
- if (vm.g_sp->z > nSectorZ-(30<<8))
- vm.g_sp->z = nSectorZ-(30<<8);
+ actor[vm.spriteNum].floorz = nSectorZ = VM_GetFlorZOfSlope();
+ if (vm.pSprite->z > nSectorZ-(30<<8))
+ vm.pSprite->z = nSectorZ-(30<<8);
}
else
{
- actor[vm.g_i].ceilingz = nSectorZ = VM_GetCeilZOfSlope();
- if (vm.g_sp->z < nSectorZ+(50<<8))
+ actor[vm.spriteNum].ceilingz = nSectorZ = VM_GetCeilZOfSlope();
+ if (vm.pSprite->z < nSectorZ+(50<<8))
{
- vm.g_sp->z = nSectorZ+(50<<8);
- vm.g_sp->zvel = 0;
+ vm.pSprite->z = nSectorZ+(50<<8);
+ vm.pSprite->zvel = 0;
}
}
}
}
- else if (vm.g_sp->picnum != ORGANTIC)
+ else if (vm.pSprite->picnum != ORGANTIC)
{
// All other actors besides ORGANTIC don't update .floorz or
// .ceilingz here.
- if (vm.g_sp->zvel > 0)
+ if (vm.pSprite->zvel > 0)
{
- if (vm.g_sp->z > actor[vm.g_i].floorz)
- vm.g_sp->z = actor[vm.g_i].floorz;
- vm.g_sp->z += A_GetWaterZOffset(vm.g_i);
+ if (vm.pSprite->z > actor[vm.spriteNum].floorz)
+ vm.pSprite->z = actor[vm.spriteNum].floorz;
+ vm.pSprite->z += A_GetWaterZOffset(vm.spriteNum);
}
- else if (vm.g_sp->zvel < 0)
+ else if (vm.pSprite->zvel < 0)
{
int const l = VM_GetCeilZOfSlope();
- if (vm.g_sp->z < l+(66<<8))
+ if (vm.pSprite->z < l+(66<<8))
{
- vm.g_sp->z = l+(66<<8);
- vm.g_sp->zvel >>= 1;
+ vm.pSprite->z = l+(66<<8);
+ vm.pSprite->zvel >>= 1;
}
}
}
- if (vm.g_x < 960 && vm.g_sp->xrepeat > 16)
+ if (vm.playerDist < 960 && vm.pSprite->xrepeat > 16)
{
- nXvel = -(1024 - vm.g_x);
- nAngDiff = getangle(vm.g_pp->pos.x - vm.g_sp->x, vm.g_pp->pos.y - vm.g_sp->y);
+ nXvel = -(1024 - vm.playerDist);
+ angDiff = getangle(vm.pPlayer->pos.x - vm.pSprite->x, vm.pPlayer->pos.y - vm.pSprite->y);
- if (vm.g_x < 512)
+ if (vm.playerDist < 512)
{
- vm.g_pp->vel.x = 0;
- vm.g_pp->vel.y = 0;
+ vm.pPlayer->vel.x = 0;
+ vm.pPlayer->vel.y = 0;
}
else
{
- vm.g_pp->vel.x = mulscale16(vm.g_pp->vel.x, vm.g_pp->runspeed - 0x2000);
- vm.g_pp->vel.y = mulscale16(vm.g_pp->vel.y, vm.g_pp->runspeed - 0x2000);
+ vm.pPlayer->vel.x = mulscale16(vm.pPlayer->vel.x, vm.pPlayer->runspeed - 0x2000);
+ vm.pPlayer->vel.y = mulscale16(vm.pPlayer->vel.y, vm.pPlayer->runspeed - 0x2000);
}
}
- else if (vm.g_sp->picnum != DRONE && vm.g_sp->picnum != SHARK && vm.g_sp->picnum != COMMANDER)
+ else if (vm.pSprite->picnum != DRONE && vm.pSprite->picnum != SHARK && vm.pSprite->picnum != COMMANDER)
{
- if (vm.g_pp->actorsqu == vm.g_i)
+ if (vm.pPlayer->actorsqu == vm.spriteNum)
return;
- if (!A_CheckSpriteFlags(vm.g_i, SFLAG_SMOOTHMOVE))
+ if (!A_CheckSpriteFlags(vm.spriteNum, SFLAG_SMOOTHMOVE))
{
- if (AC_COUNT(vm.g_t) & 1)
+ if (AC_COUNT(vm.pData) & 1)
return;
nXvel <<= 1;
}
}
}
- else if (vm.g_sp->picnum == APLAYER)
- if (vm.g_sp->z < actor[vm.g_i].ceilingz+(32<<8))
- vm.g_sp->z = actor[vm.g_i].ceilingz+(32<<8);
+ else if (vm.pSprite->picnum == APLAYER)
+ if (vm.pSprite->z < actor[vm.spriteNum].ceilingz+(32<<8))
+ vm.pSprite->z = actor[vm.spriteNum].ceilingz+(32<<8);
- vec3_t const vect = { (nXvel * (sintable[(nAngDiff + 512) & 2047])) >> 14,
- (nXvel * (sintable[nAngDiff & 2047])) >> 14, vm.g_sp->zvel };
+ vec3_t const vect = { (nXvel * (sintable[(angDiff + 512) & 2047])) >> 14,
+ (nXvel * (sintable[angDiff & 2047])) >> 14, vm.pSprite->zvel };
- actor[vm.g_i].movflag = A_MoveSprite(vm.g_i, &vect, (A_CheckSpriteFlags(vm.g_i, SFLAG_NOCLIP) ? 0 : CLIPMASK0));
+ actor[vm.spriteNum].movflag = A_MoveSprite(vm.spriteNum, &vect, (A_CheckSpriteFlags(vm.spriteNum, SFLAG_NOCLIP) ? 0 : CLIPMASK0));
}
if (!badguyp)
return;
- vm.g_sp->shade += (sector[vm.g_sp->sectnum].ceilingstat & 1) ? (sector[vm.g_sp->sectnum].ceilingshade - vm.g_sp->shade) >> 1
- : (sector[vm.g_sp->sectnum].floorshade - vm.g_sp->shade) >> 1;
+ vm.pSprite->shade += (sector[vm.pSprite->sectnum].ceilingstat & 1) ? (sector[vm.pSprite->sectnum].ceilingshade - vm.pSprite->shade) >> 1
+ : (sector[vm.pSprite->sectnum].floorshade - vm.pSprite->shade) >> 1;
}
-static void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int nWeapon)
+static void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int weaponNum)
{
if ((ps->weaponswitch & (1|4)) == (1|4))
{
- int const nPlayer = P_Get(ps->i);
+ int const playerNum = P_Get(ps->i);
int new_wchoice = -1;
int curr_wchoice = -1;
for (int i=0; i<=FREEZE_WEAPON && (new_wchoice < 0 || curr_wchoice < 0); i++)
{
- int w = g_player[nPlayer].wchoice[i];
+ int w = g_player[playerNum].wchoice[i];
if (w == KNEE_WEAPON)
w = FREEZE_WEAPON;
@@ -848,15 +858,15 @@ static void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int nWeapon)
if (w == ps->curr_weapon)
curr_wchoice = i;
- if (w == nWeapon)
+ if (w == weaponNum)
new_wchoice = i;
}
- P_AddWeapon(ps, nWeapon, (new_wchoice < curr_wchoice));
+ P_AddWeapon(ps, weaponNum, (new_wchoice < curr_wchoice));
}
else
{
- P_AddWeapon(ps, nWeapon, (ps->weaponswitch & 1));
+ P_AddWeapon(ps, weaponNum, (ps->weaponswitch & 1));
}
}
@@ -866,33 +876,33 @@ void P_AddWeaponMaybeSwitchI(int32_t snum, int32_t weap)
P_AddWeaponMaybeSwitch(g_player[snum].ps, weap);
}
#else
-static void P_AddWeaponAmmoCommon(DukePlayer_t *ps, int nWeapon, int nAmount)
+static void P_AddWeaponAmmoCommon(DukePlayer_t *pPlayer, int weaponNum, int nAmount)
{
- P_AddAmmo(nWeapon, ps, nAmount);
+ P_AddAmmo(weaponNum, pPlayer, nAmount);
- if (PWEAPON(vm.g_p, ps->curr_weapon, WorksLike) == KNEE_WEAPON && (ps->gotweapon & (1 << nWeapon)))
- P_AddWeaponMaybeSwitch(ps, nWeapon);
+ if (PWEAPON(vm.playerNum, pPlayer->curr_weapon, WorksLike) == KNEE_WEAPON && (pPlayer->gotweapon & (1 << weaponNum)))
+ P_AddWeaponMaybeSwitch(pPlayer, weaponNum);
}
-static int VM_AddWeapon(DukePlayer_t *ps, int nWeapon, int nAmount)
+static int VM_AddWeapon(DukePlayer_t *pPlayer, int weaponNum, int nAmount)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)nWeapon >= MAX_WEAPONS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)weaponNum >= MAX_WEAPONS))
{
- CON_ERRPRINTF("Invalid weapon ID %d\n", nWeapon);
+ CON_ERRPRINTF("Invalid weapon ID %d\n", weaponNum);
return 1;
}
- if ((ps->gotweapon & (1 << nWeapon)) == 0)
+ if ((pPlayer->gotweapon & (1 << weaponNum)) == 0)
{
- P_AddWeaponMaybeSwitch(ps, nWeapon);
+ P_AddWeaponMaybeSwitch(pPlayer, weaponNum);
}
- else if (ps->ammo_amount[nWeapon] >= ps->max_ammo_amount[nWeapon])
+ else if (pPlayer->ammo_amount[weaponNum] >= pPlayer->max_ammo_amount[weaponNum])
{
- vm.g_flags |= VM_NOEXECUTE;
+ vm.flags |= VM_NOEXECUTE;
return 2;
}
- P_AddWeaponAmmoCommon(ps, nWeapon, nAmount);
+ P_AddWeaponAmmoCommon(pPlayer, weaponNum, nAmount);
return 0;
}
@@ -905,18 +915,18 @@ static int32_t A_GetVerticalVel(actor_t const * const pActor)
#else
int32_t moveScriptOfs = AC_MOVE_ID(pActor->t_data);
- return ((unsigned) moveScriptOfs < (unsigned) g_scriptSize - 1) ? script[moveScriptOfs + 1] : 0;
+ return ((unsigned) moveScriptOfs < (unsigned) g_scriptSize - 1) ? apScript[moveScriptOfs + 1] : 0;
#endif
}
-static int32_t A_GetWaterZOffset(int nSprite)
+static int32_t A_GetWaterZOffset(int spriteNum)
{
- uspritetype const *const pSprite = (uspritetype *)&sprite[nSprite];
- actor_t const *const pActor = &actor[nSprite];
+ uspritetype const *const pSprite = (uspritetype *)&sprite[spriteNum];
+ actor_t const *const pActor = &actor[spriteNum];
if (sector[pSprite->sectnum].lotag == ST_1_ABOVE_WATER)
{
- if (A_CheckSpriteFlags(nSprite, SFLAG_NOWATERDIP))
+ if (A_CheckSpriteFlags(spriteNum, SFLAG_NOWATERDIP))
return 0;
// fix for flying/jumping monsters getting stuck in water
@@ -929,7 +939,7 @@ static int32_t A_GetWaterZOffset(int nSprite)
return 0;
}
-static void VM_Fall(int nSprite, spritetype *pSprite)
+static void VM_Fall(int spriteNum, spritetype *pSprite)
{
int nGravity = g_spriteGravity;
@@ -940,33 +950,33 @@ static void VM_Fall(int nSprite, spritetype *pSprite)
else if (EDUKE32_PREDICT_FALSE(G_CheckForSpaceFloor(pSprite->sectnum)))
nGravity = 0;
- if (!actor[nSprite].cgg-- || (sector[pSprite->sectnum].floorstat&2))
+ if (!actor[spriteNum].cgg-- || (sector[pSprite->sectnum].floorstat&2))
{
- A_GetZLimits(nSprite);
- actor[nSprite].cgg = 3;
+ A_GetZLimits(spriteNum);
+ actor[spriteNum].cgg = 3;
}
- if (pSprite->z < actor[nSprite].floorz-ZOFFSET)
+ if (pSprite->z < actor[spriteNum].floorz-ZOFFSET)
{
// Free fall.
pSprite->zvel = min(pSprite->zvel+nGravity, ACTOR_MAXFALLINGZVEL);
- int32_t z = pSprite->z + pSprite->zvel;
+ int32_t newZ = pSprite->z + pSprite->zvel;
#ifdef YAX_ENABLE
if (yax_getbunch(pSprite->sectnum, YAX_FLOOR) >= 0 &&
(sector[pSprite->sectnum].floorstat&512)==0)
- setspritez(nSprite, (vec3_t *)pSprite);
+ setspritez(spriteNum, (vec3_t *)pSprite);
else
#endif
- if (z > actor[nSprite].floorz - ZOFFSET)
- z = actor[nSprite].floorz - ZOFFSET;
+ if (newZ > actor[spriteNum].floorz - ZOFFSET)
+ newZ = actor[spriteNum].floorz - ZOFFSET;
- pSprite->z = z;
+ pSprite->z = newZ;
return;
}
// Preliminary new z position of the actor.
- int32_t z = actor[nSprite].floorz - ZOFFSET;
+ int32_t newZ = actor[spriteNum].floorz - ZOFFSET;
if (A_CheckEnemySprite(pSprite) || (pSprite->picnum == APLAYER && pSprite->owner >= 0))
{
@@ -976,13 +986,13 @@ static void VM_Fall(int nSprite, spritetype *pSprite)
// where they crashed into the ground when killed
if (!(pSprite->picnum == APLAYER && pSprite->extra > 0) && pSprite->pal != 1 && pSprite->picnum != DRONE)
{
- A_DoGuts(nSprite,JIBS6,15);
- A_PlaySound(SQUISHED,nSprite);
- A_Spawn(nSprite,BLOODPOOL);
+ A_DoGuts(spriteNum,JIBS6,15);
+ A_PlaySound(SQUISHED,spriteNum);
+ A_Spawn(spriteNum,BLOODPOOL);
}
- actor[nSprite].picnum = SHOTSPARK1;
- actor[nSprite].extra = 1;
+ actor[spriteNum].picnum = SHOTSPARK1;
+ actor[spriteNum].extra = 1;
pSprite->zvel = 0;
}
else if (pSprite->zvel > 2048 && sector[pSprite->sectnum].lotag != ST_1_ABOVE_WATER)
@@ -991,93 +1001,93 @@ static void VM_Fall(int nSprite, spritetype *pSprite)
pushmove((vec3_t *)pSprite, &newsect, 128, 4<<8, 4<<8, CLIPMASK0);
if ((unsigned)newsect < MAXSECTORS)
- changespritesect(nSprite, newsect);
+ changespritesect(spriteNum, newsect);
- A_PlaySound(THUD, nSprite);
+ A_PlaySound(THUD, spriteNum);
}
}
if (sector[pSprite->sectnum].lotag == ST_1_ABOVE_WATER)
{
- pSprite->z = z + A_GetWaterZOffset(nSprite);
+ pSprite->z = newZ + A_GetWaterZOffset(spriteNum);
return;
}
- pSprite->z = z;
+ pSprite->z = newZ;
pSprite->zvel = 0;
}
-static int32_t VM_ResetPlayer(int nPlayer, int32_t g_flags, int32_t nFlags)
+static int32_t VM_ResetPlayer(int playerNum, int32_t vmFlags, int32_t resetFlags)
{
//AddLog("resetplayer");
- if (!g_netServer && ud.multimode < 2 && !(nFlags & 2))
+ if (!g_netServer && ud.multimode < 2 && !(resetFlags & 2))
{
- if (g_lastSaveSlot >= 0 && ud.recstat != 2 && !(nFlags & 1))
+ if (g_lastSaveSlot >= 0 && ud.recstat != 2 && !(resetFlags & 1))
{
- M_OpenMenu(nPlayer);
+ M_OpenMenu(playerNum);
KB_ClearKeyDown(sc_Space);
I_AdvanceTriggerClear();
M_ChangeMenu(MENU_RESETPLAYER);
}
- else g_player[nPlayer].ps->gm = MODE_RESTART;
+ else g_player[playerNum].ps->gm = MODE_RESTART;
#if !defined LUNATIC
- g_flags |= VM_NOEXECUTE;
+ vmFlags |= VM_NOEXECUTE;
#endif
}
else
{
- if (nPlayer == myconnectindex)
+ if (playerNum == myconnectindex)
{
CAMERADIST = 0;
CAMERACLOCK = totalclock;
}
if (g_fakeMultiMode)
- P_ResetPlayer(nPlayer);
+ P_ResetPlayer(playerNum);
#ifndef NETCODE_DISABLE
if (g_netServer)
{
- P_ResetPlayer(nPlayer);
- Net_SpawnPlayer(nPlayer);
+ P_ResetPlayer(playerNum);
+ Net_SpawnPlayer(playerNum);
}
#endif
}
- P_UpdateScreenPal(g_player[nPlayer].ps);
+ P_UpdateScreenPal(g_player[playerNum].ps);
//AddLog("EOF: resetplayer");
- return g_flags;
+ return vmFlags;
}
-void G_GetTimeDate(int32_t *vals)
+void G_GetTimeDate(int32_t *pValues)
{
- time_t rawtime;
- time(&rawtime);
- struct tm *ti = localtime(&rawtime);
+ time_t timeStruct;
+ time(&timeStruct);
+ struct tm *pTime = localtime(&timeStruct);
// initprintf("Time&date: %s\n",asctime (ti));
- vals[0] = ti->tm_sec;
- vals[1] = ti->tm_min;
- vals[2] = ti->tm_hour;
- vals[3] = ti->tm_mday;
- vals[4] = ti->tm_mon;
- vals[5] = ti->tm_year+1900;
- vals[6] = ti->tm_wday;
- vals[7] = ti->tm_yday;
+ pValues[0] = pTime->tm_sec;
+ pValues[1] = pTime->tm_min;
+ pValues[2] = pTime->tm_hour;
+ pValues[3] = pTime->tm_mday;
+ pValues[4] = pTime->tm_mon;
+ pValues[5] = pTime->tm_year+1900;
+ pValues[6] = pTime->tm_wday;
+ pValues[7] = pTime->tm_yday;
}
-int G_StartTrack(int nLevel)
+int G_StartTrack(int levelNum)
{
- if ((unsigned)nLevel < MAXLEVELS)
+ if ((unsigned)levelNum < MAXLEVELS)
{
- int nTrackNum = MAXLEVELS*ud.volume_number + nLevel;
+ int trackNum = MAXLEVELS*ud.volume_number + levelNum;
- if (MapInfo[nTrackNum].musicfn != NULL)
+ if (aMapInfo[trackNum].musicfn != NULL)
{
// Only set g_musicIndex on success.
- g_musicIndex = nTrackNum;
- S_PlayMusic(MapInfo[nTrackNum].musicfn);
+ g_musicIndex = trackNum;
+ S_PlayMusic(aMapInfo[trackNum].musicfn);
return 0;
}
@@ -1160,14 +1170,14 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sec
GAMEEXEC_STATIC void VM_Execute(int loop)
{
int tw = *insptr;
- DukePlayer_t * const ps = vm.g_pp;
+ DukePlayer_t * const pPlayer = vm.pPlayer;
// jump directly into the loop, saving us from the checks during the first iteration
goto skip_check;
while (loop)
{
- if (vm.g_flags & (VM_RETURN | VM_KILL | VM_NOEXECUTE))
+ if (vm.flags & (VM_RETURN | VM_KILL | VM_NOEXECUTE))
break;
tw = *insptr;
@@ -1214,14 +1224,15 @@ skip_check:
case CON_REDEFINEQUOTE:
insptr++;
{
- int const nDestQuote = *insptr++;
- int const nRedef = *insptr++;
- if (EDUKE32_PREDICT_FALSE((ScriptQuotes[nDestQuote] == NULL || ScriptQuoteRedefinitions[nRedef] == NULL)))
+ int const strIndex = *insptr++;
+ int const XstrIndex = *insptr++;
+
+ if (EDUKE32_PREDICT_FALSE((apStrings[strIndex] == NULL || apXStrings[XstrIndex] == NULL)))
{
- CON_ERRPRINTF("%d %d null quote\n", nDestQuote,nRedef);
+ CON_ERRPRINTF("%d %d null quote\n", strIndex,XstrIndex);
break;
}
- Bstrcpy(ScriptQuotes[nDestQuote],ScriptQuoteRedefinitions[nRedef]);
+ Bstrcpy(apStrings[strIndex],apXStrings[XstrIndex]);
continue;
}
@@ -1229,10 +1240,10 @@ skip_check:
insptr++;
{
tw = *insptr++;
- int const nSprite = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i;
- int const nLabel = *insptr++;
+ int const spriteNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : vm.spriteNum;
+ int const labelNum = *insptr++;
- Gv_SetVarX(*insptr++, VM_GetActiveProjectile(nSprite, nLabel));
+ Gv_SetVarX(*insptr++, VM_GetActiveProjectile(spriteNum, labelNum));
continue;
}
@@ -1240,10 +1251,10 @@ skip_check:
insptr++;
{
tw = *insptr++;
- int const nSprite = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i;
- int const nLabel = *insptr++;
+ int const spriteNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : vm.spriteNum;
+ int const labelNum = *insptr++;
- VM_SetActiveProjectile(nSprite, nLabel, Gv_GetVarX(*insptr++));
+ VM_SetActiveProjectile(spriteNum, labelNum, Gv_GetVarX(*insptr++));
continue;
}
@@ -1253,37 +1264,48 @@ skip_check:
case CON_IFCANSHOOTTARGET:
{
- if (vm.g_x > 1024)
+ if (vm.playerDist > 1024)
{
int16_t temphit;
- if ((tw = A_CheckHitSprite(vm.g_i, &temphit)) == (1 << 30))
+ if ((tw = A_CheckHitSprite(vm.spriteNum, &temphit)) == (1 << 30))
{
VM_CONDITIONAL(1);
continue;
}
- int nClip = 768;
- int nAngDiff = 16;
+ int nDist = 768;
+ int angDiff = 16;
- if (A_CheckEnemySprite(vm.g_sp) && vm.g_sp->xrepeat > 56)
+ if (A_CheckEnemySprite(vm.pSprite) && vm.pSprite->xrepeat > 56)
{
- nClip = 3084;
- nAngDiff = 48;
+ nDist = 3084;
+ angDiff = 48;
}
-#define CHECK(x) if (x >= 0 && sprite[x].picnum == vm.g_sp->picnum) { VM_CONDITIONAL(0); continue; }
-#define CHECK2(x) do { vm.g_sp->ang += x; tw = A_CheckHitSprite(vm.g_i, &temphit); vm.g_sp->ang -= x; } while(0)
+#define CHECK(x) \
+ if (x >= 0 && sprite[x].picnum == vm.pSprite->picnum) \
+ { \
+ VM_CONDITIONAL(0); \
+ continue; \
+ }
+#define CHECK2(x) \
+ do \
+ { \
+ vm.pSprite->ang += x; \
+ tw = A_CheckHitSprite(vm.spriteNum, &temphit); \
+ vm.pSprite->ang -= x; \
+ } while (0)
- if (tw > nClip)
+ if (tw > nDist)
{
CHECK(temphit);
- CHECK2(nAngDiff);
+ CHECK2(angDiff);
- if (tw > nClip)
+ if (tw > nDist)
{
CHECK(temphit);
- CHECK2(-nAngDiff);
+ CHECK2(-angDiff);
if (tw > 768)
{
@@ -1299,41 +1321,41 @@ skip_check:
continue;
case CON_IFCANSEETARGET:
- tw = cansee(vm.g_sp->x, vm.g_sp->y, vm.g_sp->z-((krand()&41)<<8),
- vm.g_sp->sectnum, ps->pos.x, ps->pos.y,
- ps->pos.z/*-((krand()&41)<<8)*/, sprite[ps->i].sectnum);
+ tw = cansee(vm.pSprite->x, vm.pSprite->y, vm.pSprite->z-((krand()&41)<<8),
+ vm.pSprite->sectnum, pPlayer->pos.x, pPlayer->pos.y,
+ pPlayer->pos.z/*-((krand()&41)<<8)*/, sprite[pPlayer->i].sectnum);
VM_CONDITIONAL(tw);
- if (tw) actor[vm.g_i].timetosleep = SLEEPTIME;
+ if (tw) actor[vm.spriteNum].timetosleep = SLEEPTIME;
continue;
case CON_IFACTORNOTSTAYPUT:
- VM_CONDITIONAL(actor[vm.g_i].actorstayput == -1);
+ VM_CONDITIONAL(actor[vm.spriteNum].actorstayput == -1);
continue;
case CON_IFCANSEE:
{
- uspritetype *s = (uspritetype *)&sprite[ps->i];
+ uspritetype *pSprite = (uspritetype *)&sprite[pPlayer->i];
// select sprite for monster to target
// if holoduke is on, let them target holoduke first.
//
- if (ps->holoduke_on >= 0)
+ if (pPlayer->holoduke_on >= 0)
{
- s = (uspritetype *)&sprite[ps->holoduke_on];
- tw = cansee(vm.g_sp->x,vm.g_sp->y,vm.g_sp->z-(krand()&((32<<8)-1)),vm.g_sp->sectnum,
- s->x,s->y,s->z,s->sectnum);
+ pSprite = (uspritetype *)&sprite[pPlayer->holoduke_on];
+ tw = cansee(vm.pSprite->x,vm.pSprite->y,vm.pSprite->z-(krand()&((32<<8)-1)),vm.pSprite->sectnum,
+ pSprite->x,pSprite->y,pSprite->z,pSprite->sectnum);
if (tw == 0)
{
// they can't see player's holoduke
// check for player...
- s = (uspritetype *)&sprite[ps->i];
+ pSprite = (uspritetype *)&sprite[pPlayer->i];
}
}
// can they see player, (or player's holoduke)
- tw = cansee(vm.g_sp->x,vm.g_sp->y,vm.g_sp->z-(krand()&((47<<8))),vm.g_sp->sectnum,
- s->x,s->y,s->z-(24<<8),s->sectnum);
+ tw = cansee(vm.pSprite->x,vm.pSprite->y,vm.pSprite->z-(krand()&((47<<8))),vm.pSprite->sectnum,
+ pSprite->x,pSprite->y,pSprite->z-(24<<8),pSprite->sectnum);
if (tw == 0)
{
@@ -1342,26 +1364,26 @@ skip_check:
// also modifies 'target' x&y if found..
tw = 1;
- if (A_FurthestVisiblePoint(vm.g_i,s,&actor[vm.g_i].lastvx,&actor[vm.g_i].lastvy) == -1)
+ if (A_FurthestVisiblePoint(vm.spriteNum,pSprite,&actor[vm.spriteNum].lastvx,&actor[vm.spriteNum].lastvy) == -1)
tw = 0;
}
else
{
// else, they did see it.
// save where we were looking...
- actor[vm.g_i].lastvx = s->x;
- actor[vm.g_i].lastvy = s->y;
+ actor[vm.spriteNum].lastvx = pSprite->x;
+ actor[vm.spriteNum].lastvy = pSprite->y;
}
- if (tw && (vm.g_sp->statnum == STAT_ACTOR || vm.g_sp->statnum == STAT_STANDABLE))
- actor[vm.g_i].timetosleep = SLEEPTIME;
+ if (tw && (vm.pSprite->statnum == STAT_ACTOR || vm.pSprite->statnum == STAT_STANDABLE))
+ actor[vm.spriteNum].timetosleep = SLEEPTIME;
VM_CONDITIONAL(tw);
continue;
}
case CON_IFHITWEAPON:
- VM_CONDITIONAL(A_IncurDamage(vm.g_i) >= 0);
+ VM_CONDITIONAL(A_IncurDamage(vm.spriteNum) >= 0);
continue;
case CON_IFSQUISHED:
@@ -1369,33 +1391,35 @@ skip_check:
continue;
case CON_IFDEAD:
- VM_CONDITIONAL(vm.g_sp->extra <= 0);
+ VM_CONDITIONAL(vm.pSprite->extra <= 0);
continue;
case CON_AI:
insptr++;
//Following changed to use pointersizes
- AC_AI_ID(vm.g_t) = *insptr++; // Ai
-
- AC_ACTION_ID(vm.g_t) = *(script + AC_AI_ID(vm.g_t)); // Action
+ AC_AI_ID(vm.pData) = *insptr++; // Ai
+ AC_ACTION_ID(vm.pData) = *(apScript + AC_AI_ID(vm.pData)); // Action
// NOTE: "if" check added in r1155. It used to be a pointer though.
- if (AC_AI_ID(vm.g_t))
- AC_MOVE_ID(vm.g_t) = *(script + AC_AI_ID(vm.g_t) + 1); // move
+ if (AC_AI_ID(vm.pData))
+ AC_MOVE_ID(vm.pData) = *(apScript + AC_AI_ID(vm.pData) + 1); // move
- vm.g_sp->hitag = *(script + AC_AI_ID(vm.g_t) + 2); // move flags
+ vm.pSprite->hitag = *(apScript + AC_AI_ID(vm.pData) + 2); // move flags
- AC_COUNT(vm.g_t) = AC_ACTION_COUNT(vm.g_t) = AC_CURFRAME(vm.g_t) = 0;
+ AC_COUNT(vm.pData) = 0;
+ AC_ACTION_COUNT(vm.pData) = 0;
+ AC_CURFRAME(vm.pData) = 0;
- if (!A_CheckEnemySprite(vm.g_sp) || vm.g_sp->extra > 0) // hack
- if (vm.g_sp->hitag&random_angle)
- vm.g_sp->ang = krand()&2047;
+ if (!A_CheckEnemySprite(vm.pSprite) || vm.pSprite->extra > 0) // hack
+ if (vm.pSprite->hitag&random_angle)
+ vm.pSprite->ang = krand()&2047;
continue;
case CON_ACTION:
insptr++;
- AC_ACTION_COUNT(vm.g_t) = AC_CURFRAME(vm.g_t) = 0;
- AC_ACTION_ID(vm.g_t) = *insptr++;
+ AC_ACTION_COUNT(vm.pData) = 0;
+ AC_CURFRAME(vm.pData) = 0;
+ AC_ACTION_ID(vm.pData) = *insptr++;
continue;
case CON_IFPLAYERSL:
@@ -1403,25 +1427,25 @@ skip_check:
continue;
case CON_IFPDISTL:
- VM_CONDITIONAL(vm.g_x < *(++insptr));
- if (vm.g_x > MAXSLEEPDIST && actor[vm.g_i].timetosleep == 0)
- actor[vm.g_i].timetosleep = SLEEPTIME;
+ VM_CONDITIONAL(vm.playerDist < *(++insptr));
+ if (vm.playerDist > MAXSLEEPDIST && actor[vm.spriteNum].timetosleep == 0)
+ actor[vm.spriteNum].timetosleep = SLEEPTIME;
continue;
case CON_IFPDISTG:
- VM_CONDITIONAL(vm.g_x > *(++insptr));
- if (vm.g_x > MAXSLEEPDIST && actor[vm.g_i].timetosleep == 0)
- actor[vm.g_i].timetosleep = SLEEPTIME;
+ VM_CONDITIONAL(vm.playerDist > *(++insptr));
+ if (vm.playerDist > MAXSLEEPDIST && actor[vm.spriteNum].timetosleep == 0)
+ actor[vm.spriteNum].timetosleep = SLEEPTIME;
continue;
case CON_ADDSTRENGTH:
insptr++;
- vm.g_sp->extra += *insptr++;
+ vm.pSprite->extra += *insptr++;
continue;
case CON_STRENGTH:
insptr++;
- vm.g_sp->extra = *insptr++;
+ vm.pSprite->extra = *insptr++;
continue;
case CON_IFGOTWEAPONCE:
@@ -1432,17 +1456,17 @@ skip_check:
if (*insptr == 0)
{
int j = 0;
- for (; j < ps->weapreccnt; j++)
- if (ps->weaprecs[j] == vm.g_sp->picnum)
+ for (; j < pPlayer->weapreccnt; ++j)
+ if (pPlayer->weaprecs[j] == vm.pSprite->picnum)
break;
- VM_CONDITIONAL(j < ps->weapreccnt && vm.g_sp->owner == vm.g_i);
+ VM_CONDITIONAL(j < pPlayer->weapreccnt && vm.pSprite->owner == vm.spriteNum);
continue;
}
- else if (ps->weapreccnt < MAX_WEAPONS)
+ else if (pPlayer->weapreccnt < MAX_WEAPONS)
{
- ps->weaprecs[ps->weapreccnt++] = vm.g_sp->picnum;
- VM_CONDITIONAL(vm.g_sp->owner == vm.g_i);
+ pPlayer->weaprecs[pPlayer->weapreccnt++] = vm.pSprite->picnum;
+ VM_CONDITIONAL(vm.pSprite->owner == vm.spriteNum);
continue;
}
}
@@ -1451,57 +1475,57 @@ skip_check:
case CON_GETLASTPAL:
insptr++;
- if (vm.g_sp->picnum == APLAYER)
- vm.g_sp->pal = g_player[P_GetP(vm.g_sp)].ps->palookup;
+ if (vm.pSprite->picnum == APLAYER)
+ vm.pSprite->pal = g_player[P_GetP(vm.pSprite)].ps->palookup;
else
{
- if (vm.g_sp->pal == 1 && vm.g_sp->extra == 0) // hack for frozen
- vm.g_sp->extra++;
- vm.g_sp->pal = actor[vm.g_i].tempang;
+ if (vm.pSprite->pal == 1 && vm.pSprite->extra == 0) // hack for frozen
+ vm.pSprite->extra++;
+ vm.pSprite->pal = actor[vm.spriteNum].tempang;
}
- actor[vm.g_i].tempang = 0;
+ actor[vm.spriteNum].tempang = 0;
continue;
case CON_TOSSWEAPON:
insptr++;
// NOTE: assumes that current actor is APLAYER
- P_DropWeapon(P_GetP(vm.g_sp));
+ P_DropWeapon(P_GetP(vm.pSprite));
continue;
case CON_MIKESND:
insptr++;
- if (EDUKE32_PREDICT_FALSE(((unsigned)vm.g_sp->yvel >= MAXSOUNDS)))
+ if (EDUKE32_PREDICT_FALSE(((unsigned)vm.pSprite->yvel >= MAXSOUNDS)))
{
- CON_ERRPRINTF("Invalid sound %d\n", TrackerCast(vm.g_sp->yvel));
+ CON_ERRPRINTF("Invalid sound %d\n", TrackerCast(vm.pSprite->yvel));
continue;
}
- if (!S_CheckSoundPlaying(vm.g_i,vm.g_sp->yvel))
- A_PlaySound(vm.g_sp->yvel,vm.g_i);
+ if (!S_CheckSoundPlaying(vm.spriteNum,vm.pSprite->yvel))
+ A_PlaySound(vm.pSprite->yvel,vm.spriteNum);
continue;
case CON_PKICK:
insptr++;
- if ((g_netServer || ud.multimode > 1) && vm.g_sp->picnum == APLAYER)
+ if ((g_netServer || ud.multimode > 1) && vm.pSprite->picnum == APLAYER)
{
if (g_player[otherp].ps->quick_kick == 0)
g_player[otherp].ps->quick_kick = 14;
}
- else if (vm.g_sp->picnum != APLAYER && ps->quick_kick == 0)
- ps->quick_kick = 14;
+ else if (vm.pSprite->picnum != APLAYER && pPlayer->quick_kick == 0)
+ pPlayer->quick_kick = 14;
continue;
case CON_SIZETO:
insptr++;
- tw = (*insptr++ - vm.g_sp->xrepeat)<<1;
- vm.g_sp->xrepeat += ksgn(tw);
+ tw = (*insptr++ - vm.pSprite->xrepeat)<<1;
+ vm.pSprite->xrepeat += ksgn(tw);
- if ((vm.g_sp->picnum == APLAYER && vm.g_sp->yrepeat < 36) || *insptr < vm.g_sp->yrepeat ||
- ((vm.g_sp->yrepeat*(tilesiz[vm.g_sp->picnum].y+8))<<2) < (actor[vm.g_i].floorz - actor[vm.g_i].ceilingz))
+ if ((vm.pSprite->picnum == APLAYER && vm.pSprite->yrepeat < 36) || *insptr < vm.pSprite->yrepeat ||
+ ((vm.pSprite->yrepeat*(tilesiz[vm.pSprite->picnum].y+8))<<2) < (actor[vm.spriteNum].floorz - actor[vm.spriteNum].ceilingz))
{
- tw = ((*insptr)-vm.g_sp->yrepeat)<<1;
- if (klabs(tw)) vm.g_sp->yrepeat += ksgn(tw);
+ tw = ((*insptr)-vm.pSprite->yrepeat)<<1;
+ if (klabs(tw)) vm.pSprite->yrepeat += ksgn(tw);
}
insptr++;
@@ -1510,13 +1534,13 @@ skip_check:
case CON_SIZEAT:
insptr++;
- vm.g_sp->xrepeat = (uint8_t) *insptr++;
- vm.g_sp->yrepeat = (uint8_t) *insptr++;
+ vm.pSprite->xrepeat = (uint8_t)*insptr++;
+ vm.pSprite->yrepeat = (uint8_t)*insptr++;
continue;
case CON_SHOOT:
insptr++;
- A_Shoot(vm.g_i,*insptr++);
+ A_Shoot(vm.spriteNum,*insptr++);
continue;
case CON_SOUNDONCE:
@@ -1526,25 +1550,26 @@ skip_check:
continue;
}
- if (!S_CheckSoundPlaying(vm.g_i, *insptr++))
- A_PlaySound(*(insptr-1),vm.g_i);
+ if (!S_CheckSoundPlaying(vm.spriteNum, *insptr++))
+ A_PlaySound(*(insptr-1),vm.spriteNum);
continue;
case CON_IFACTORSOUND:
insptr++;
{
- int const i = Gv_GetVarX(*insptr++), j = Gv_GetVarX(*insptr++);
+ int const spriteNum = Gv_GetVarX(*insptr++);
+ int const soundNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSOUNDS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)soundNum >= MAXSOUNDS))
{
- CON_ERRPRINTF("Invalid sound %d\n", j);
+ CON_ERRPRINTF("Invalid sound %d\n", soundNum);
insptr++;
continue;
}
insptr--;
- VM_CONDITIONAL(A_CheckSoundPlaying(i, j));
+ VM_CONDITIONAL(A_CheckSoundPlaying(spriteNum, soundNum));
}
continue;
@@ -1555,8 +1580,8 @@ skip_check:
insptr++;
continue;
}
- VM_CONDITIONAL(S_CheckSoundPlaying(vm.g_i,*insptr));
- // VM_DoConditional(SoundOwner[*insptr][0].ow == vm.g_i);
+ VM_CONDITIONAL(S_CheckSoundPlaying(vm.spriteNum,*insptr));
+ // VM_DoConditional(SoundOwner[*insptr][0].ow == vm.spriteNum);
continue;
case CON_STOPSOUND:
@@ -1566,7 +1591,7 @@ skip_check:
insptr++;
continue;
}
- if (S_CheckSoundPlaying(vm.g_i,*insptr))
+ if (S_CheckSoundPlaying(vm.spriteNum,*insptr))
S_StopSound((int16_t)*insptr);
insptr++;
continue;
@@ -1574,16 +1599,17 @@ skip_check:
case CON_STOPACTORSOUND:
insptr++;
{
- int const nSprite = Gv_GetVarX(*insptr++), nSound = Gv_GetVarX(*insptr++);
+ int const spriteNum = Gv_GetVarX(*insptr++);
+ int const soundNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSound >= MAXSOUNDS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)soundNum >= MAXSOUNDS))
{
- CON_ERRPRINTF("Invalid sound %d\n", nSound);
+ CON_ERRPRINTF("Invalid sound %d\n", soundNum);
continue;
}
- if (A_CheckSoundPlaying(nSprite, nSound))
- S_StopEnvSound(nSound, nSprite);
+ if (A_CheckSoundPlaying(spriteNum, soundNum))
+ S_StopEnvSound(soundNum, spriteNum);
continue;
}
@@ -1591,17 +1617,17 @@ skip_check:
case CON_SETACTORSOUNDPITCH:
insptr++;
{
- int const nSprite = Gv_GetVarX(*insptr++);
- int const nSound = Gv_GetVarX(*insptr++);
- int const nPitch = Gv_GetVarX(*insptr++);
+ int const spriteNum = Gv_GetVarX(*insptr++);
+ int const soundNum = Gv_GetVarX(*insptr++);
+ int const newPitch = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSound>=MAXSOUNDS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)soundNum>=MAXSOUNDS))
{
- CON_ERRPRINTF("Invalid sound %d\n", nSound);
+ CON_ERRPRINTF("Invalid sound %d\n", soundNum);
continue;
}
- S_ChangeSoundPitch(nSound, nSprite, nPitch);
+ S_ChangeSoundPitch(soundNum, spriteNum, newPitch);
continue;
}
@@ -1613,7 +1639,7 @@ skip_check:
insptr++;
continue;
}
- if (vm.g_p == screenpeek || (GametypeFlags[ud.coop]&GAMETYPE_COOPSOUND)
+ if (vm.playerNum == screenpeek || (GametypeFlags[ud.coop]&GAMETYPE_COOPSOUND)
#ifdef SPLITSCREEN_MOD_HACKS
|| (g_fakeMultiMode==2)
#endif
@@ -1629,21 +1655,21 @@ skip_check:
insptr++;
continue;
}
- A_PlaySound(*insptr++,vm.g_i);
+ A_PlaySound(*insptr++,vm.spriteNum);
continue;
case CON_TIP:
insptr++;
- ps->tipincs = GAMETICSPERSEC;
+ pPlayer->tipincs = GAMETICSPERSEC;
continue;
case CON_FALL:
insptr++;
- VM_Fall(vm.g_i, vm.g_sp);
+ VM_Fall(vm.spriteNum, vm.pSprite);
continue;
case CON_RETURN:
- vm.g_flags |= VM_RETURN;
+ vm.flags |= VM_RETURN;
case CON_ENDA:
case CON_BREAK:
case CON_ENDS:
@@ -1655,67 +1681,67 @@ skip_check:
case CON_ADDAMMO:
insptr++;
{
- int const nWeapon = *insptr++;
- int const nAmount = *insptr++;
+ int const weaponNum = *insptr++;
+ int const addAmount = *insptr++;
- if (EDUKE32_PREDICT_FALSE((unsigned)nWeapon >= MAX_WEAPONS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)weaponNum >= MAX_WEAPONS))
{
- CON_ERRPRINTF("Invalid weapon ID %d\n", nWeapon);
+ CON_ERRPRINTF("Invalid weapon ID %d\n", weaponNum);
break;
}
- if (ps->ammo_amount[nWeapon] >= ps->max_ammo_amount[nWeapon])
+ if (pPlayer->ammo_amount[weaponNum] >= pPlayer->max_ammo_amount[weaponNum])
{
- vm.g_flags |= VM_NOEXECUTE;
+ vm.flags |= VM_NOEXECUTE;
return;
}
- P_AddWeaponAmmoCommon(ps, nWeapon, nAmount);
+ P_AddWeaponAmmoCommon(pPlayer, weaponNum, addAmount);
continue;
}
case CON_MONEY:
insptr++;
- A_SpawnMultiple(vm.g_i, MONEY, *insptr++);
+ A_SpawnMultiple(vm.spriteNum, MONEY, *insptr++);
continue;
case CON_MAIL:
insptr++;
- A_SpawnMultiple(vm.g_i, MAIL, *insptr++);
+ A_SpawnMultiple(vm.spriteNum, MAIL, *insptr++);
continue;
case CON_SLEEPTIME:
insptr++;
- actor[vm.g_i].timetosleep = (int16_t)*insptr++;
+ actor[vm.spriteNum].timetosleep = (int16_t)*insptr++;
continue;
case CON_PAPER:
insptr++;
- A_SpawnMultiple(vm.g_i, PAPER, *insptr++);
+ A_SpawnMultiple(vm.spriteNum, PAPER, *insptr++);
continue;
case CON_ADDKILLS:
insptr++;
- ps->actors_killed += *insptr++;
- actor[vm.g_i].actorstayput = -1;
+ pPlayer->actors_killed += *insptr++;
+ actor[vm.spriteNum].actorstayput = -1;
continue;
case CON_LOTSOFGLASS:
insptr++;
- A_SpawnGlass(vm.g_i,*insptr++);
+ A_SpawnGlass(vm.spriteNum,*insptr++);
continue;
case CON_KILLIT:
insptr++;
- vm.g_flags |= VM_KILL;
+ vm.flags |= VM_KILL;
return;
case CON_ADDWEAPON:
insptr++;
{
- int const nWeapon = *insptr++;
- VM_AddWeapon(ps, nWeapon, *insptr++);
+ int const weaponNum = *insptr++;
+ VM_AddWeapon(pPlayer, weaponNum, *insptr++);
continue;
}
@@ -1727,8 +1753,8 @@ skip_check:
case CON_ENDOFGAME:
case CON_ENDOFLEVEL:
insptr++;
- ps->timebeforeexit = *insptr++;
- ps->customexitsound = -1;
+ pPlayer->timebeforeexit = *insptr++;
+ pPlayer->customexitsound = -1;
ud.eog = 1;
continue;
@@ -1736,48 +1762,48 @@ skip_check:
insptr++;
{
- if (ps->newowner >= 0)
- G_ClearCameraView(ps);
+ if (pPlayer->newowner >= 0)
+ G_ClearCameraView(pPlayer);
- int nHealth = sprite[ps->i].extra;
+ int newHealth = sprite[pPlayer->i].extra;
- if (vm.g_sp->picnum != ATOMICHEALTH)
+ if (vm.pSprite->picnum != ATOMICHEALTH)
{
- if (nHealth > ps->max_player_health && *insptr > 0)
+ if (newHealth > pPlayer->max_player_health && *insptr > 0)
{
insptr++;
continue;
}
else
{
- if (nHealth > 0)
- nHealth += *insptr;
- if (nHealth > ps->max_player_health && *insptr > 0)
- nHealth = ps->max_player_health;
+ if (newHealth > 0)
+ newHealth += *insptr;
+ if (newHealth > pPlayer->max_player_health && *insptr > 0)
+ newHealth = pPlayer->max_player_health;
}
}
else
{
- if (nHealth > 0)
- nHealth += *insptr;
- if (nHealth > (ps->max_player_health<<1))
- nHealth = (ps->max_player_health<<1);
+ if (newHealth > 0)
+ newHealth += *insptr;
+ if (newHealth > (pPlayer->max_player_health<<1))
+ newHealth = (pPlayer->max_player_health<<1);
}
- if (nHealth < 0) nHealth = 0;
+ if (newHealth < 0) newHealth = 0;
if (ud.god == 0)
{
if (*insptr > 0)
{
- if ((nHealth - *insptr) < (ps->max_player_health>>2) &&
- nHealth >= (ps->max_player_health>>2))
- A_PlaySound(DUKE_GOTHEALTHATLOW,ps->i);
+ if ((newHealth - *insptr) < (pPlayer->max_player_health>>2) &&
+ newHealth >= (pPlayer->max_player_health>>2))
+ A_PlaySound(DUKE_GOTHEALTHATLOW,pPlayer->i);
- ps->last_extra = nHealth;
+ pPlayer->last_extra = newHealth;
}
- sprite[ps->i].extra = nHealth;
+ sprite[pPlayer->i].extra = newHealth;
}
}
@@ -1786,88 +1812,88 @@ skip_check:
case CON_MOVE:
insptr++;
- AC_COUNT(vm.g_t) = 0;
- AC_MOVE_ID(vm.g_t) = *insptr++;
- vm.g_sp->hitag = *insptr++;
- if (A_CheckEnemySprite(vm.g_sp) && vm.g_sp->extra <= 0) // hack
+ AC_COUNT(vm.pData) = 0;
+ AC_MOVE_ID(vm.pData) = *insptr++;
+ vm.pSprite->hitag = *insptr++;
+ if (A_CheckEnemySprite(vm.pSprite) && vm.pSprite->extra <= 0) // hack
continue;
- if (vm.g_sp->hitag&random_angle)
- vm.g_sp->ang = krand()&2047;
+ if (vm.pSprite->hitag&random_angle)
+ vm.pSprite->ang = krand()&2047;
continue;
case CON_ADDWEAPONVAR:
insptr++;
{
- int const nWeapon = Gv_GetVarX(*insptr++);
- VM_AddWeapon(ps, nWeapon, Gv_GetVarX(*insptr++));
+ int const weaponNum = Gv_GetVarX(*insptr++);
+ VM_AddWeapon(pPlayer, weaponNum, Gv_GetVarX(*insptr++));
continue;
}
case CON_SETASPECT:
insptr++;
{
- int const nRange = Gv_GetVarX(*insptr++);
- setaspect(nRange, Gv_GetVarX(*insptr++));
+ int const xRange = Gv_GetVarX(*insptr++);
+ setaspect(xRange, Gv_GetVarX(*insptr++));
break;
}
case CON_SSP:
insptr++;
{
- int const nSprite = Gv_GetVarX(*insptr++);
- int const nClipType = Gv_GetVarX(*insptr++);
+ int const spriteNum = Gv_GetVarX(*insptr++);
+ int const clipType = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
- CON_ERRPRINTF("Invalid sprite %d\n", nSprite);
+ CON_ERRPRINTF("Invalid sprite %d\n", spriteNum);
break;
}
- A_SetSprite(nSprite, nClipType);
+ A_SetSprite(spriteNum, clipType);
break;
}
case CON_ACTIVATEBYSECTOR:
insptr++;
{
- int const nSector = Gv_GetVarX(*insptr++);
- int const nSprite = Gv_GetVarX(*insptr++);
+ int const sectNum = Gv_GetVarX(*insptr++);
+ int const spriteNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSector >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("Invalid sector %d\n", nSector);
+ CON_ERRPRINTF("Invalid sector %d\n", sectNum);
break;
}
- G_ActivateBySector(nSector, nSprite);
+ G_ActivateBySector(sectNum, spriteNum);
break;
}
case CON_OPERATESECTORS:
insptr++;
{
- int const nSector = Gv_GetVarX(*insptr++);
- int const nSprite = Gv_GetVarX(*insptr++);
+ int const sectNum = Gv_GetVarX(*insptr++);
+ int const spriteNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSector >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("Invalid sector %d\n", nSector);
+ CON_ERRPRINTF("Invalid sector %d\n", sectNum);
break;
}
- G_OperateSectors(nSector, nSprite);
+ G_OperateSectors(sectNum, spriteNum);
break;
}
case CON_OPERATEACTIVATORS:
insptr++;
{
- int const nTag = Gv_GetVarX(*insptr++);
- int const nPlayer = (*insptr++ == g_iThisActorID) ? vm.g_p : Gv_GetVarX(*(insptr-1));
+ int const nTag = Gv_GetVarX(*insptr++);
+ int const playerNum = (*insptr++ == g_thisActorVarID) ? vm.playerNum : Gv_GetVarX(*(insptr-1));
- if (EDUKE32_PREDICT_FALSE((unsigned)nPlayer >= (unsigned)playerswhenstarted))
+ if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted))
{
- CON_ERRPRINTF("Invalid player %d\n", nPlayer);
+ CON_ERRPRINTF("Invalid player %d\n", playerNum);
break;
}
- G_OperateActivators(nTag, nPlayer);
+ G_OperateActivators(nTag, playerNum);
break;
}
@@ -1877,7 +1903,7 @@ skip_check:
{
int const nSprite1 = Gv_GetVarX(*insptr++);
int const nSprite2 = Gv_GetVarX(*insptr++);
- int nResult = 0;
+ int nResult = 0;
if (EDUKE32_PREDICT_FALSE((unsigned)nSprite1 >= MAXSPRITES || (unsigned)nSprite2 >= MAXSPRITES))
CON_ERRPRINTF("Invalid sprite %d\n", (unsigned)nSprite1 >= MAXSPRITES ? nSprite1 : nSprite2);
@@ -1903,191 +1929,194 @@ skip_check:
case CON_CHECKACTIVATORMOTION:
insptr++;
- aGameVars[g_iReturnVarID].nValue = G_CheckActivatorMotion(Gv_GetVarX(*insptr++));
+ aGameVars[g_returnVarID].global = G_CheckActivatorMotion(Gv_GetVarX(*insptr++));
continue;
case CON_INSERTSPRITEQ:
insptr++;
- A_AddToDeleteQueue(vm.g_i);
+ A_AddToDeleteQueue(vm.spriteNum);
continue;
case CON_QSTRLEN:
insptr++;
{
- int const nGameVar = *insptr++;
- int const nQuote = Gv_GetVarX(*insptr++);
+ int const gameVar = *insptr++;
+ int const quoteNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE(ScriptQuotes[nQuote] == NULL))
+ if (EDUKE32_PREDICT_FALSE(apStrings[quoteNum] == NULL))
{
- CON_ERRPRINTF("null quote %d\n", nQuote);
- Gv_SetVarX(nGameVar, -1);
+ CON_ERRPRINTF("null quote %d\n", quoteNum);
+ Gv_SetVarX(gameVar, -1);
continue;
}
- Gv_SetVarX(nGameVar, Bstrlen(ScriptQuotes[nQuote]));
+ Gv_SetVarX(gameVar, Bstrlen(apStrings[quoteNum]));
continue;
}
case CON_QSTRDIM:
insptr++;
{
- vec2_t dim = { 0, 0, };
-
- int const w = *insptr++;
- int const h = *insptr++;
-
- int32_t params[16];
+ vec2_t dim = { 0, 0, };
+ int const widthVar = *insptr++;
+ int const heightVar = *insptr++;
+ int32_t params[16];
Gv_GetManyVars(16, params);
- int const tilenum = params[0], x = params[1], y = params[2], z = params[3];
- int const blockangle = params[4], q = params[5];
- int const orientation = params[6] & (ROTATESPRITE_MAX-1);
- int const xspace = params[7], yline = params[8], xbetween = params[9];
- int const ybetween = params[10], f = params[11];
- int const x1 = params[12], y1 = params[13], x2 = params[14], y2 = params[15];
+ int const tileNum = params[0];
+ vec3_t vect = { params[1], params[2], params[3] };
+ int const blockAngle = params[4];
+ int const quoteNum = params[5];
+ int const orientation = params[6] & (ROTATESPRITE_MAX - 1);
+ vec2_t offset = { params[7], params[8] };
+ vec2_t between = { params[9], params[10] };
+ int const f = params[11];
+ vec2_t upperLeft = { params[12], params[13] };
+ vec2_t lowerRight = { params[14], params[15] };
- if (EDUKE32_PREDICT_FALSE(tilenum < 0 || tilenum+255 >= MAXTILES))
- CON_ERRPRINTF("invalid base tilenum %d\n", tilenum);
- else if (EDUKE32_PREDICT_FALSE((unsigned)q >= MAXQUOTES || ScriptQuotes[q] == NULL))
- CON_ERRPRINTF("invalid quote ID %d\n", q);
+ if (EDUKE32_PREDICT_FALSE(tileNum < 0 || tileNum + 255 >= MAXTILES))
+ CON_ERRPRINTF("invalid base tilenum %d\n", tileNum);
+ else if (EDUKE32_PREDICT_FALSE((unsigned)quoteNum >= MAXQUOTES || apStrings[quoteNum] == NULL))
+ CON_ERRPRINTF("invalid quote ID %d\n", quoteNum);
else
- dim = G_ScreenTextSize(tilenum, x, y, z, blockangle, ScriptQuotes[q], 2 | orientation,
- xspace, yline, xbetween, ybetween, f, x1, y1, x2, y2);
+ dim = G_ScreenTextSize(tileNum, vect.x, vect.y, vect.z, blockAngle, apStrings[quoteNum],
+ 2 | orientation, offset.x, offset.y, between.x, between.y, f,
+ upperLeft.x, upperLeft.y, lowerRight.x, lowerRight.y);
- Gv_SetVarX(w, dim.x);
- Gv_SetVarX(h, dim.y);
+ Gv_SetVarX(widthVar, dim.x);
+ Gv_SetVarX(heightVar, dim.y);
continue;
}
case CON_HEADSPRITESTAT:
insptr++;
{
- int const nGameVar = *insptr++;
- int const nSprite = Gv_GetVarX(*insptr++);
+ int const gameVar = *insptr++;
+ int const spriteNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSprite > MAXSTATUS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum > MAXSTATUS))
{
- CON_ERRPRINTF("invalid status list %d\n", nSprite);
+ CON_ERRPRINTF("invalid status list %d\n", spriteNum);
continue;
}
- Gv_SetVarX(nGameVar,headspritestat[nSprite]);
+ Gv_SetVarX(gameVar, headspritestat[spriteNum]);
continue;
}
case CON_PREVSPRITESTAT:
insptr++;
{
- int const nGameVar = *insptr++;
- int const nSprite = Gv_GetVarX(*insptr++);
+ int const gameVar = *insptr++;
+ int const spriteNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
- CON_ERRPRINTF("invalid sprite ID %d\n", nSprite);
+ CON_ERRPRINTF("invalid sprite ID %d\n", spriteNum);
continue;
}
- Gv_SetVarX(nGameVar, prevspritestat[nSprite]);
+ Gv_SetVarX(gameVar, prevspritestat[spriteNum]);
continue;
}
case CON_NEXTSPRITESTAT:
insptr++;
{
- int const nGameVar = *insptr++;
- int const nSprite = Gv_GetVarX(*insptr++);
+ int const gameVar = *insptr++;
+ int const spriteNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
- CON_ERRPRINTF("invalid sprite ID %d\n", nSprite);
+ CON_ERRPRINTF("invalid sprite ID %d\n", spriteNum);
continue;
}
- Gv_SetVarX(nGameVar, nextspritestat[nSprite]);
+ Gv_SetVarX(gameVar, nextspritestat[spriteNum]);
continue;
}
case CON_HEADSPRITESECT:
insptr++;
{
- int const nGameVar = *insptr++,
- nSprite = Gv_GetVarX(*insptr++);
+ int const gameVar = *insptr++;
+ int const spriteNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("invalid sector %d\n", nSprite);
+ CON_ERRPRINTF("invalid sector %d\n", spriteNum);
continue;
}
- Gv_SetVarX(nGameVar, headspritesect[nSprite]);
+ Gv_SetVarX(gameVar, headspritesect[spriteNum]);
continue;
}
case CON_PREVSPRITESECT:
insptr++;
{
- int const nGameVar = *insptr++;
- int const nSprite = Gv_GetVarX(*insptr++);
+ int const gameVar = *insptr++;
+ int const spriteNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
- CON_ERRPRINTF("invalid sprite ID %d\n", nSprite);
+ CON_ERRPRINTF("invalid sprite ID %d\n", spriteNum);
continue;
}
- Gv_SetVarX(nGameVar, prevspritesect[nSprite]);
+ Gv_SetVarX(gameVar, prevspritesect[spriteNum]);
continue;
}
case CON_NEXTSPRITESECT:
insptr++;
{
- int const nGameVar = *insptr++;
- int const nSprite = Gv_GetVarX(*insptr++);
+ int const gameVar = *insptr++;
+ int const spriteNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
- CON_ERRPRINTF("invalid sprite ID %d\n", nSprite);
+ CON_ERRPRINTF("invalid sprite ID %d\n", spriteNum);
continue;
}
- Gv_SetVarX(nGameVar, nextspritesect[nSprite]);
+ Gv_SetVarX(gameVar, nextspritesect[spriteNum]);
continue;
}
case CON_GETKEYNAME:
insptr++;
{
- int const nQuoteIndex = Gv_GetVarX(*insptr++);
- int const nGameFunc = Gv_GetVarX(*insptr++);
- int const nFuncPos = Gv_GetVarX(*insptr++);
+ int const quoteIndex = Gv_GetVarX(*insptr++);
+ int const gameFunc = Gv_GetVarX(*insptr++);
+ int const funcPos = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nQuoteIndex >= MAXQUOTES || ScriptQuotes[nQuoteIndex] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)quoteIndex >= MAXQUOTES || apStrings[quoteIndex] == NULL))
{
- CON_ERRPRINTF("invalid quote ID %d\n", nQuoteIndex);
+ CON_ERRPRINTF("invalid quote ID %d\n", quoteIndex);
continue;
}
- else if (EDUKE32_PREDICT_FALSE((unsigned)nGameFunc >= NUMGAMEFUNCTIONS))
+ else if (EDUKE32_PREDICT_FALSE((unsigned)gameFunc >= NUMGAMEFUNCTIONS))
{
- CON_ERRPRINTF("invalid function %d\n", nGameFunc);
+ CON_ERRPRINTF("invalid function %d\n", gameFunc);
continue;
}
else
{
- if (nFuncPos < 2)
- Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[nGameFunc][nFuncPos]));
+ if (funcPos < 2)
+ Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[gameFunc][funcPos]));
else
{
- Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[nGameFunc][0]));
+ Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[gameFunc][0]));
if (!*tempbuf)
- Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[nGameFunc][1]));
+ Bstrcpy(tempbuf, KB_ScanCodeToString(ud.config.KeyboardKeys[gameFunc][1]));
}
}
if (*tempbuf)
- Bstrcpy(ScriptQuotes[nQuoteIndex], tempbuf);
+ Bstrcpy(apStrings[quoteIndex], tempbuf);
continue;
}
@@ -2099,44 +2128,46 @@ skip_check:
Gv_GetManyVars(4, params);
- const int nDestQuote = params[0], nSrcQuote = params[1];
+ int const outputQuote = params[0];
+ int const inputQuote = params[1];
- if (EDUKE32_PREDICT_FALSE((unsigned)nDestQuote>=MAXQUOTES || ScriptQuotes[nDestQuote] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)outputQuote>=MAXQUOTES || apStrings[outputQuote] == NULL))
{
- CON_ERRPRINTF("invalid quote ID %d\n", nDestQuote);
+ CON_ERRPRINTF("invalid quote ID %d\n", outputQuote);
continue;
}
- if (EDUKE32_PREDICT_FALSE((unsigned)nSrcQuote>=MAXQUOTES || ScriptQuotes[nSrcQuote] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)inputQuote>=MAXQUOTES || apStrings[inputQuote] == NULL))
{
- CON_ERRPRINTF("invalid quote ID %d\n", nSrcQuote);
+ CON_ERRPRINTF("invalid quote ID %d\n", inputQuote);
continue;
}
- int nPos = params[2], nLength = params[3];
+ int quotePos = params[2];
+ int quoteLength = params[3];
- if (EDUKE32_PREDICT_FALSE((unsigned)nPos >= MAXQUOTELEN))
+ if (EDUKE32_PREDICT_FALSE((unsigned)quotePos >= MAXQUOTELEN))
{
- CON_ERRPRINTF("invalid start position %d\n", nPos);
+ CON_ERRPRINTF("invalid start position %d\n", quotePos);
continue;
}
- if (EDUKE32_PREDICT_FALSE(nLength < 0))
+ if (EDUKE32_PREDICT_FALSE(quoteLength < 0))
{
- CON_ERRPRINTF("invalid length %d\n", nLength);
+ CON_ERRPRINTF("invalid length %d\n", quoteLength);
continue;
}
- char *pDestQuote = ScriptQuotes[nDestQuote];
- char const * pSrcQuote = ScriptQuotes[nSrcQuote];
+ char * pOutput = apStrings[outputQuote];
+ char const *pInput = apStrings[inputQuote];
- while (*pSrcQuote && nPos--) pSrcQuote++;
- while ((*pDestQuote = *pSrcQuote) && nLength--)
+ while (*pInput && quotePos--) pInput++;
+ while ((*pOutput = *pInput) && quoteLength--)
{
- pDestQuote++;
- pSrcQuote++;
+ pOutput++;
+ pInput++;
}
- *pDestQuote = 0;
+ *pOutput = 0;
continue;
}
@@ -2150,9 +2181,9 @@ skip_check:
insptr++;
{
int32_t i = Gv_GetVarX(*insptr++), j;
- if (tw == CON_GETPNAME && *insptr == g_iThisActorID)
+ if (tw == CON_GETPNAME && *insptr == g_thisActorVarID)
{
- j = vm.g_p;
+ j = vm.playerNum;
insptr++;
}
else j = Gv_GetVarX(*insptr++);
@@ -2160,17 +2191,17 @@ skip_check:
switch (tw)
{
case CON_GETPNAME:
- if (EDUKE32_PREDICT_FALSE((unsigned)i>=MAXQUOTES || ScriptQuotes[i] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)i>=MAXQUOTES || apStrings[i] == NULL))
{
CON_ERRPRINTF("invalid quote ID %d\n", i);
break;
}
if (g_player[j].user_name[0])
- Bstrcpy(ScriptQuotes[i],g_player[j].user_name);
- else Bsprintf(ScriptQuotes[i],"%d",j);
+ Bstrcpy(apStrings[i],g_player[j].user_name);
+ else Bsprintf(apStrings[i],"%d",j);
break;
case CON_QGETSYSSTR:
- if (EDUKE32_PREDICT_FALSE((unsigned)i>=MAXQUOTES || ScriptQuotes[i] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)i>=MAXQUOTES || apStrings[i] == NULL))
{
CON_ERRPRINTF("invalid quote ID %d\n", i);
break;
@@ -2180,18 +2211,19 @@ skip_check:
case STR_MAPNAME:
case STR_MAPFILENAME:
{
- int32_t idx = ud.volume_number*MAXLEVELS + ud.level_number;
- const char *src;
+ int32_t levelNum = ud.volume_number*MAXLEVELS + ud.level_number;
+ const char *pName;
- if (EDUKE32_PREDICT_FALSE((unsigned)idx >= ARRAY_SIZE(MapInfo)))
+ if (EDUKE32_PREDICT_FALSE((unsigned)levelNum >= ARRAY_SIZE(aMapInfo)))
{
CON_ERRPRINTF("out of bounds map number (vol=%d, lev=%d)\n",
ud.volume_number, ud.level_number);
break;
}
- src = j==STR_MAPNAME ? MapInfo[idx].name : MapInfo[idx].filename;
- if (EDUKE32_PREDICT_FALSE(src == NULL))
+ pName = j == STR_MAPNAME ? aMapInfo[levelNum].name : aMapInfo[levelNum].filename;
+
+ if (EDUKE32_PREDICT_FALSE(pName == NULL))
{
CON_ERRPRINTF("attempted access to %s of non-existent map (vol=%d, lev=%d)",
j==STR_MAPNAME ? "name" : "file name",
@@ -2199,23 +2231,23 @@ skip_check:
break;
}
- Bstrcpy(ScriptQuotes[i], j==STR_MAPNAME ? MapInfo[idx].name : MapInfo[idx].filename);
+ Bstrcpy(apStrings[i], j==STR_MAPNAME ? aMapInfo[levelNum].name : aMapInfo[levelNum].filename);
break;
}
case STR_PLAYERNAME:
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p >= (unsigned)playerswhenstarted))
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= (unsigned)playerswhenstarted))
{
- CON_ERRPRINTF("Invalid player ID %d\n", vm.g_p);
+ CON_ERRPRINTF("Invalid player ID %d\n", vm.playerNum);
break;
}
- Bstrcpy(ScriptQuotes[i],g_player[vm.g_p].user_name);
+ Bstrcpy(apStrings[i],g_player[vm.playerNum].user_name);
break;
case STR_VERSION:
Bsprintf(tempbuf,HEAD2 " %s",s_buildRev);
- Bstrcpy(ScriptQuotes[i],tempbuf);
+ Bstrcpy(apStrings[i],tempbuf);
break;
case STR_GAMETYPE:
- Bstrcpy(ScriptQuotes[i],GametypeNames[ud.coop]);
+ Bstrcpy(apStrings[i],GametypeNames[ud.coop]);
break;
case STR_VOLUMENAME:
if (EDUKE32_PREDICT_FALSE((unsigned)ud.volume_number >= MAXVOLUMES))
@@ -2223,36 +2255,36 @@ skip_check:
CON_ERRPRINTF("invalid volume (%d)\n", ud.volume_number);
break;
}
- Bstrcpy(ScriptQuotes[i],EpisodeNames[ud.volume_number]);
+ Bstrcpy(apStrings[i],EpisodeNames[ud.volume_number]);
break;
case STR_YOURTIME:
- Bstrcpy(ScriptQuotes[i],G_PrintYourTime());
+ Bstrcpy(apStrings[i],G_PrintYourTime());
break;
case STR_PARTIME:
- Bstrcpy(ScriptQuotes[i],G_PrintParTime());
+ Bstrcpy(apStrings[i],G_PrintParTime());
break;
case STR_DESIGNERTIME:
- Bstrcpy(ScriptQuotes[i],G_PrintDesignerTime());
+ Bstrcpy(apStrings[i],G_PrintDesignerTime());
break;
case STR_BESTTIME:
- Bstrcpy(ScriptQuotes[i],G_PrintBestTime());
+ Bstrcpy(apStrings[i],G_PrintBestTime());
break;
default:
CON_ERRPRINTF("unknown str ID %d %d\n", i,j);
}
break;
case CON_QSTRCAT:
- if (EDUKE32_PREDICT_FALSE(ScriptQuotes[i] == NULL || ScriptQuotes[j] == NULL)) goto nullquote;
- Bstrncat(ScriptQuotes[i],ScriptQuotes[j],(MAXQUOTELEN-1)-Bstrlen(ScriptQuotes[i]));
+ if (EDUKE32_PREDICT_FALSE(apStrings[i] == NULL || apStrings[j] == NULL)) goto nullquote;
+ Bstrncat(apStrings[i],apStrings[j],(MAXQUOTELEN-1)-Bstrlen(apStrings[i]));
break;
case CON_QSTRNCAT:
- if (EDUKE32_PREDICT_FALSE(ScriptQuotes[i] == NULL || ScriptQuotes[j] == NULL)) goto nullquote;
- Bstrncat(ScriptQuotes[i],ScriptQuotes[j],Gv_GetVarX(*insptr++));
+ if (EDUKE32_PREDICT_FALSE(apStrings[i] == NULL || apStrings[j] == NULL)) goto nullquote;
+ Bstrncat(apStrings[i],apStrings[j],Gv_GetVarX(*insptr++));
break;
case CON_QSTRCPY:
- if (EDUKE32_PREDICT_FALSE(ScriptQuotes[i] == NULL || ScriptQuotes[j] == NULL)) goto nullquote;
+ if (EDUKE32_PREDICT_FALSE(apStrings[i] == NULL || apStrings[j] == NULL)) goto nullquote;
if (i != j)
- Bstrcpy(ScriptQuotes[i],ScriptQuotes[j]);
+ Bstrcpy(apStrings[i],apStrings[j]);
break;
case CON_CHANGESPRITESECT:
if (EDUKE32_PREDICT_FALSE((unsigned)i >= MAXSPRITES))
@@ -2269,7 +2301,7 @@ skip_check:
break;
default:
nullquote:
- CON_ERRPRINTF("null quote %d\n", ScriptQuotes[i] ? j : i);
+ CON_ERRPRINTF("null quote %d\n", apStrings[i] ? j : i);
break;
}
continue;
@@ -2278,51 +2310,51 @@ nullquote:
case CON_CHANGESPRITESTAT:
insptr++;
{
- int32_t const nSprite = Gv_GetVarX(*insptr++);
- int32_t nStatnum = Gv_GetVarX(*insptr++);
+ int32_t const spriteNum = Gv_GetVarX(*insptr++);
+ int32_t statNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSprite >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
- CON_ERRPRINTF("Invalid sprite: %d\n", nSprite);
+ CON_ERRPRINTF("Invalid sprite: %d\n", spriteNum);
continue;
}
- if (EDUKE32_PREDICT_FALSE((unsigned)nStatnum >= MAXSTATUS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)statNum >= MAXSTATUS))
{
- CON_ERRPRINTF("Invalid statnum: %d\n", nStatnum);
+ CON_ERRPRINTF("Invalid statnum: %d\n", statNum);
continue;
}
- if (sprite[nSprite].statnum == nStatnum)
+ if (sprite[spriteNum].statnum == statNum)
continue;
/* initialize actor data when changing to an actor statnum because there's usually
garbage left over from being handled as a hard coded object */
- if (sprite[nSprite].statnum > STAT_ZOMBIEACTOR && (nStatnum == STAT_ACTOR || nStatnum == STAT_ZOMBIEACTOR))
+ if (sprite[spriteNum].statnum > STAT_ZOMBIEACTOR && (statNum == STAT_ACTOR || statNum == STAT_ZOMBIEACTOR))
{
- actor_t * const a = &actor[nSprite];
+ actor_t * const pActor = &actor[spriteNum];
- a->lastvx = 0;
- a->lastvy = 0;
- a->timetosleep = 0;
- a->cgg = 0;
- a->movflag = 0;
- a->tempang = 0;
- a->dispicnum = 0;
- Bmemset(&a->t_data, 0, sizeof a->t_data);
- a->flags = 0;
- sprite[nSprite].hitag = 0;
+ Bmemset(&pActor->t_data, 0, sizeof pActor->t_data);
+ pActor->lastvx = 0;
+ pActor->lastvy = 0;
+ pActor->timetosleep = 0;
+ pActor->cgg = 0;
+ pActor->movflag = 0;
+ pActor->tempang = 0;
+ pActor->dispicnum = 0;
+ pActor->flags = 0;
+ sprite[spriteNum].hitag = 0;
- if (G_HaveActor(sprite[nSprite].picnum))
+ if (G_HaveActor(sprite[spriteNum].picnum))
{
- const intptr_t *actorptr = g_tile[sprite[nSprite].picnum].execPtr;
+ const intptr_t *actorptr = g_tile[sprite[spriteNum].picnum].execPtr;
// offsets
- AC_ACTION_ID(a->t_data) = actorptr[1];
- AC_MOVE_ID(a->t_data) = actorptr[2];
- AC_MOVFLAGS(&sprite[nSprite], &actor[nSprite]) = actorptr[3]; // ai bits (movflags)
+ AC_ACTION_ID(pActor->t_data) = actorptr[1];
+ AC_MOVE_ID(pActor->t_data) = actorptr[2];
+ AC_MOVFLAGS(&sprite[spriteNum], &actor[spriteNum]) = actorptr[3]; // ai bits (movflags)
}
}
- changespritestat(nSprite, nStatnum);
+ changespritestat(spriteNum, statNum);
continue;
}
@@ -2330,23 +2362,23 @@ nullquote:
insptr++; // skip command
{
// from 'level' cheat in game.c (about line 6250)
- int const nVolume = Gv_GetVarX(*insptr++);
- int const nLevel = Gv_GetVarX(*insptr++);
+ int const volumeNum = Gv_GetVarX(*insptr++);
+ int const levelNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nVolume >= MAXVOLUMES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)volumeNum >= MAXVOLUMES))
{
- CON_ERRPRINTF("invalid volume (%d)\n", nVolume);
+ CON_ERRPRINTF("invalid volume (%d)\n", volumeNum);
continue;
}
- if (EDUKE32_PREDICT_FALSE((unsigned)nLevel >= MAXLEVELS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)levelNum >= MAXLEVELS))
{
- CON_ERRPRINTF("invalid level (%d)\n", nLevel);
+ CON_ERRPRINTF("invalid level (%d)\n", levelNum);
continue;
}
- ud.m_volume_number = ud.volume_number = nVolume;
- ud.m_level_number = ud.level_number = nLevel;
+ ud.m_volume_number = ud.volume_number = volumeNum;
+ ud.m_level_number = ud.level_number = levelNum;
//if (numplayers > 1 && g_netServer)
// Net_NewGame(volnume,levnume);
//else
@@ -2367,10 +2399,10 @@ nullquote:
int32_t values[5];
Gv_GetManyVars(5, values);
- vec2_t const pos = *(vec2_t *)values;
- int const tilenum = values[2];
- int const shade = values[3];
- int const orientation = values[4];
+ vec2_t const pos = *(vec2_t *)values;
+ int const tilenum = values[2];
+ int const shade = values[3];
+ int const orientation = values[4];
switch (tw)
{
@@ -2416,7 +2448,7 @@ nullquote:
else if (lpCases[lCheckCase << 1] == lValue)
{
// fake a 2-d Array
- insptr = (intptr_t *)(lpCases[(lCheckCase << 1) + 1] + &script[0]);
+ insptr = (intptr_t *)(lpCases[(lCheckCase << 1) + 1] + &apScript[0]);
VM_Execute(1);
goto matched;
}
@@ -2428,12 +2460,12 @@ nullquote:
if (*lpDefault)
{
- insptr = (intptr_t *)(*lpDefault + &script[0]);
+ insptr = (intptr_t *)(*lpDefault + &apScript[0]);
VM_Execute(1);
}
matched:
- insptr = (intptr_t *)(lEnd + (intptr_t)&script[0]);
+ insptr = (intptr_t *)(lEnd + (intptr_t)&apScript[0]);
continue;
}
@@ -2545,7 +2577,7 @@ nullquote:
{
int32_t params[4];
Gv_GetManyVars(4, params);
- aGameVars[g_iReturnVarID].nValue = nextsectorneighborz(params[0], params[1], params[2], params[3]);
+ aGameVars[g_returnVarID].global = nextsectorneighborz(params[0], params[1], params[2], params[3]);
}
continue;
@@ -2565,25 +2597,25 @@ nullquote:
{
int const nPicnum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.pSprite->sectnum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.g_sp->sectnum));
+ CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.pSprite->sectnum));
continue;
}
- int const nSprite = A_Spawn(vm.g_i, nPicnum);
+ int const spriteNum = A_Spawn(vm.spriteNum, nPicnum);
switch (tw)
{
case CON_EQSPAWNVAR:
- if (nSprite != -1)
- A_AddToDeleteQueue(nSprite);
+ if (spriteNum != -1)
+ A_AddToDeleteQueue(spriteNum);
case CON_ESPAWNVAR:
- aGameVars[g_iReturnVarID].nValue = nSprite;
+ aGameVars[g_returnVarID].global = spriteNum;
break;
case CON_QSPAWNVAR:
- if (nSprite != -1)
- A_AddToDeleteQueue(nSprite);
+ if (spriteNum != -1)
+ A_AddToDeleteQueue(spriteNum);
break;
}
continue;
@@ -2595,26 +2627,26 @@ nullquote:
insptr++;
{
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.pSprite->sectnum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.g_sp->sectnum));
+ CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.pSprite->sectnum));
insptr++;
continue;
}
- int const nSprite = A_Spawn(vm.g_i,*insptr++);
+ int const spriteNum = A_Spawn(vm.spriteNum,*insptr++);
switch (tw)
{
case CON_EQSPAWN:
- if (nSprite != -1)
- A_AddToDeleteQueue(nSprite);
+ if (spriteNum != -1)
+ A_AddToDeleteQueue(spriteNum);
case CON_ESPAWN:
- aGameVars[g_iReturnVarID].nValue = nSprite;
+ aGameVars[g_returnVarID].global = spriteNum;
break;
case CON_QSPAWN:
- if (nSprite != -1)
- A_AddToDeleteQueue(nSprite);
+ if (spriteNum != -1)
+ A_AddToDeleteQueue(spriteNum);
break;
}
}
@@ -2630,17 +2662,17 @@ nullquote:
int const zvel = (tw == CON_ESHOOT) ?
SHOOT_HARDCODED_ZVEL : (int16_t)Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.pSprite->sectnum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.g_sp->sectnum));
+ CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.pSprite->sectnum));
insptr++;
continue;
}
- int const nSprite = A_ShootWithZvel(vm.g_i,*insptr++,zvel);
+ int const spriteNum = A_ShootWithZvel(vm.spriteNum,*insptr++,zvel);
if (tw != CON_ZSHOOT)
- aGameVars[g_iReturnVarID].nValue = nSprite;
+ aGameVars[g_returnVarID].global = spriteNum;
}
continue;
@@ -2650,16 +2682,16 @@ nullquote:
{
int j = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.pSprite->sectnum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.g_sp->sectnum));
+ CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.pSprite->sectnum));
continue;
}
- j = A_Shoot(vm.g_i, j);
+ j = A_Shoot(vm.spriteNum, j);
if (tw == CON_ESHOOTVAR)
- aGameVars[g_iReturnVarID].nValue = j;
+ aGameVars[g_returnVarID].global = j;
continue;
}
@@ -2671,16 +2703,16 @@ nullquote:
int const zvel = (int16_t)Gv_GetVarX(*insptr++);
int j = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.pSprite->sectnum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.g_sp->sectnum));
+ CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.pSprite->sectnum));
continue;
}
- j = A_ShootWithZvel(vm.g_i, j, zvel);
+ j = A_ShootWithZvel(vm.spriteNum, j, zvel);
if (tw == CON_EZSHOOTVAR)
- aGameVars[g_iReturnVarID].nValue = j;
+ aGameVars[g_returnVarID].global = j;
continue;
}
@@ -2697,30 +2729,30 @@ nullquote:
case CON_SCREENSOUND:
insptr++;
{
- int const nSound = Gv_GetVarX(*insptr++);
+ int const soundNum = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nSound>=MAXSOUNDS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)soundNum>=MAXSOUNDS))
{
- CON_ERRPRINTF("Invalid sound %d\n", nSound);
+ CON_ERRPRINTF("Invalid sound %d\n", soundNum);
continue;
}
switch (tw)
{
case CON_SOUNDONCEVAR: // falls through to CON_SOUNDVAR
- if (!S_CheckSoundPlaying(vm.g_i, nSound))
+ if (!S_CheckSoundPlaying(vm.spriteNum, soundNum))
case CON_SOUNDVAR:
- A_PlaySound((int16_t)nSound, vm.g_i);
+ A_PlaySound((int16_t)soundNum, vm.spriteNum);
continue;
case CON_GLOBALSOUNDVAR:
- A_PlaySound((int16_t)nSound, g_player[screenpeek].ps->i);
+ A_PlaySound((int16_t)soundNum, g_player[screenpeek].ps->i);
continue;
case CON_STOPSOUNDVAR:
- if (S_CheckSoundPlaying(vm.g_i, nSound))
- S_StopSound((int16_t)nSound);
+ if (S_CheckSoundPlaying(vm.spriteNum, soundNum))
+ S_StopSound((int16_t)soundNum);
continue;
case CON_SCREENSOUND:
- A_PlaySound(nSound, -1);
+ A_PlaySound(soundNum, -1);
continue;
}
}
@@ -2732,7 +2764,7 @@ nullquote:
{
int const nQuote = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || ScriptQuotes[nQuote] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || apStrings[nQuote] == NULL))
{
CON_ERRPRINTF("invalid quote ID %d for anim!\n", nQuote);
continue;
@@ -2741,13 +2773,13 @@ nullquote:
if (tw == CON_IFCUTSCENE)
{
insptr--;
- VM_CONDITIONAL(g_animPtr == Anim_Find(ScriptQuotes[nQuote]));
+ VM_CONDITIONAL(g_animPtr == Anim_Find(apStrings[nQuote]));
continue;
}
- tw = ps->palette;
- Anim_Play(ScriptQuotes[nQuote]);
- P_SetGamePalette(ps, tw, 2 + 16);
+ tw = pPlayer->palette;
+ Anim_Play(apStrings[nQuote]);
+ P_SetGamePalette(pPlayer, tw, 2 + 16);
continue;
}
continue;
@@ -2889,13 +2921,13 @@ nullquote:
continue;
}
- if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || ScriptQuotes[nQuote] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || apStrings[nQuote] == NULL))
{
CON_ERRPRINTF("invalid quote ID %d\n", nQuote);
continue;
}
- G_PrintGameText(0, tilenum, pos.x >> 1, pos.y, ScriptQuotes[nQuote], shade, pal, orientation, bound1.x, bound1.y, bound2.x, bound2.y, z, 0);
+ G_PrintGameText(0, tilenum, pos.x >> 1, pos.y, apStrings[nQuote], shade, pal, orientation, bound1.x, bound1.y, bound2.x, bound2.y, z, 0);
continue;
}
@@ -2937,13 +2969,13 @@ nullquote:
int const nQuote = params[2];
int const shade = params[3], pal = params[4];
- if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || ScriptQuotes[nQuote] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || apStrings[nQuote] == NULL))
{
CON_ERRPRINTF("invalid quote ID %d\n", nQuote);
continue;
}
- minitextshade(pos.x, pos.y, ScriptQuotes[nQuote], shade, pal, 2+8+16);
+ minitextshade(pos.x, pos.y, apStrings[nQuote], shade, pal, 2+8+16);
continue;
}
@@ -2962,9 +2994,9 @@ nullquote:
int const pal = params[8];
int const orientation = params[9] & (ROTATESPRITE_MAX - 1);
int const alpha = params[10];
- vec2_t const spacing = { params[11], params[12] };
- vec2_t const between = { params[13], params[14] };
- int const f = params[15];
+ vec2_t const spacing = *(vec2_t *) ¶ms[11];
+ vec2_t const between = *(vec2_t *) ¶ms[13];
+ int const nFlags = params[15];
vec2_t const scrn[2] = { *(vec2_t *)¶ms[16], *(vec2_t *)¶ms[18] };
if (EDUKE32_PREDICT_FALSE(tilenum < 0 || tilenum+255 >= MAXTILES))
@@ -2973,20 +3005,20 @@ nullquote:
continue;
}
- if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || ScriptQuotes[nQuote] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || apStrings[nQuote] == NULL))
{
CON_ERRPRINTF("invalid quote ID %d\n", nQuote);
continue;
}
- G_ScreenText(tilenum, v.x, v.y, v.z, blockangle, charangle, ScriptQuotes[nQuote], shade, pal, 2 | orientation,
- alpha, spacing.x, spacing.y, between.x, between.y, f, scrn[0].x, scrn[0].y, scrn[1].x, scrn[1].y);
+ G_ScreenText(tilenum, v.x, v.y, v.z, blockangle, charangle, apStrings[nQuote], shade, pal, 2 | orientation,
+ alpha, spacing.x, spacing.y, between.x, between.y, nFlags, scrn[0].x, scrn[0].y, scrn[1].x, scrn[1].y);
continue;
}
case CON_ANGOFF:
insptr++;
- spriteext[vm.g_i].angoff=*insptr++;
+ spriteext[vm.spriteNum].angoff=*insptr++;
continue;
case CON_GETZRANGE:
@@ -3043,16 +3075,14 @@ nullquote:
case CON_CALCHYPOTENUSE:
insptr++;
{
- int32_t retvar=*insptr++;
- vec2_t da;
+ int32_t returnVar = *insptr++;
+ vec2_t da;
Gv_GetManyVars(2, (int32_t *)&da);
int64_t const hypsq = (int64_t)da.x*da.x + (int64_t)da.y*da.y;
- if (hypsq > (int64_t)INT32_MAX)
- Gv_SetVarX(retvar, (int32_t)sqrt((double)hypsq));
- else
- Gv_SetVarX(retvar, ksqrt((uint32_t)hypsq));
-
+ Gv_SetVarX(returnVar, (hypsq > (int64_t) INT32_MAX)
+ ? (int32_t)sqrt((double)hypsq)
+ : ksqrt((uint32_t)hypsq));
continue;
}
@@ -3097,16 +3127,16 @@ nullquote:
int32_t w, f, c;
} vec3dist_t;
- int const retvar = *insptr++;
- int const xvar = *insptr++;
- int const yvar = *insptr++;
+ int const returnVar = *insptr++;
+ int const xReturn = *insptr++;
+ int const yReturn = *insptr++;
insptr -= 2;
vec3_t vec3;
Gv_GetManyVars(3, (int32_t *)&vec3);
- int const sectnumvar = *insptr++;
+ int const sectReturn = *insptr++;
vec2_t vec2;
Gv_GetManyVars(2, (int32_t *)&vec2);
@@ -3114,20 +3144,21 @@ nullquote:
vec3dist_t dist;
Gv_GetManyVars(3, (int32_t *)&dist);
- int const clipmask = Gv_GetVarX(*insptr++);
- int16_t sectnum = Gv_GetVarX(sectnumvar);
+ int const clipMask = Gv_GetVarX(*insptr++);
+ int16_t sectNum = Gv_GetVarX(sectReturn);
- if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("Invalid sector %d\n", sectnum);
- Gv_SetVarX(retvar, 0);
+ CON_ERRPRINTF("Invalid sector %d\n", sectNum);
+ Gv_SetVarX(returnVar, 0);
continue;
}
- Gv_SetVarX(retvar, clipmovex(&vec3, §num, vec2.x, vec2.y, dist.w, dist.f, dist.c, clipmask, (tw == CON_CLIPMOVENOSLIDE)));
- Gv_SetVarX(sectnumvar, sectnum);
- Gv_SetVarX(xvar, vec3.x);
- Gv_SetVarX(yvar, vec3.y);
+ Gv_SetVarX(returnVar,
+ clipmovex(&vec3, §Num, vec2.x, vec2.y, dist.w, dist.f, dist.c, clipMask, (tw == CON_CLIPMOVENOSLIDE)));
+ Gv_SetVarX(sectReturn, sectNum);
+ Gv_SetVarX(xReturn, vec3.x);
+ Gv_SetVarX(yReturn, vec3.y);
continue;
}
@@ -3143,13 +3174,13 @@ nullquote:
vec3_t v;
Gv_GetManyVars(3, (int32_t *) &v);
- int const hitsectvar = *insptr++;
- int const hitwallvar = *insptr++;
- int const hitspritevar = *insptr++;
- int const hitxvar = *insptr++;
- int const hityvar = *insptr++;
- int const hitzvar = *insptr++;
- int const cliptype = Gv_GetVarX(*insptr++);
+ int const sectReturn = *insptr++;
+ int const wallReturn = *insptr++;
+ int const spriteReturn = *insptr++;
+ int const xReturn = *insptr++;
+ int const yReturn = *insptr++;
+ int const zReturn = *insptr++;
+ int const clipType = Gv_GetVarX(*insptr++);
if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors))
{
@@ -3158,14 +3189,14 @@ nullquote:
}
hitdata_t hit;
- hitscan((const vec3_t *)&vect, sectnum, v.x, v.y, v.z, &hit, cliptype);
+ hitscan((const vec3_t *)&vect, sectnum, v.x, v.y, v.z, &hit, clipType);
- Gv_SetVarX(hitsectvar, hit.sect);
- Gv_SetVarX(hitwallvar, hit.wall);
- Gv_SetVarX(hitspritevar, hit.sprite);
- Gv_SetVarX(hitxvar, hit.pos.x);
- Gv_SetVarX(hityvar, hit.pos.y);
- Gv_SetVarX(hitzvar, hit.pos.z);
+ Gv_SetVarX(sectReturn, hit.sect);
+ Gv_SetVarX(wallReturn, hit.wall);
+ Gv_SetVarX(spriteReturn, hit.sprite);
+ Gv_SetVarX(xReturn, hit.pos.x);
+ Gv_SetVarX(yReturn, hit.pos.y);
+ Gv_SetVarX(zReturn, hit.pos.z);
continue;
}
@@ -3175,20 +3206,22 @@ nullquote:
vec3_t vec1;
Gv_GetManyVars(3, (int32_t *) &vec1);
- int const sect1 = Gv_GetVarX(*insptr++);
+ int const firstSector = Gv_GetVarX(*insptr++);
vec3_t vec2;
Gv_GetManyVars(3, (int32_t *) &vec2);
- int const sect2 = Gv_GetVarX(*insptr++), rvar = *insptr++;
+ int const secondSector = Gv_GetVarX(*insptr++);
+ int const returnVar = *insptr++;
- if (EDUKE32_PREDICT_FALSE((unsigned)sect1 >= (unsigned)numsectors || (unsigned)sect2 >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)firstSector >= (unsigned)numsectors ||
+ (unsigned)secondSector >= (unsigned)numsectors))
{
CON_ERRPRINTF("Invalid sector\n");
- Gv_SetVarX(rvar, 0);
+ Gv_SetVarX(returnVar, 0);
}
- Gv_SetVarX(rvar, cansee(vec1.x, vec1.y, vec1.z, sect1, vec2.x, vec2.y, vec2.z, sect2));
+ Gv_SetVarX(returnVar, cansee(vec1.x, vec1.y, vec1.z, firstSector, vec2.x, vec2.y, vec2.z, secondSector));
continue;
}
@@ -3198,15 +3231,15 @@ nullquote:
vec2_t point[2];
Gv_GetManyVars(4, (int32_t *)point);
- int const angle = Gv_GetVarX(*insptr++);
- int const x2var = *insptr++;
- int const y2var = *insptr++;
+ int const angle = Gv_GetVarX(*insptr++);
+ int const xReturn = *insptr++;
+ int const yReturn = *insptr++;
vec2_t result;
rotatepoint(point[0], point[1], angle, &result);
- Gv_SetVarX(x2var, result.x);
- Gv_SetVarX(y2var, result.y);
+ Gv_SetVarX(xReturn, result.x);
+ Gv_SetVarX(yReturn, result.y);
continue;
}
@@ -3223,43 +3256,42 @@ nullquote:
vec3_t point;
Gv_GetManyVars(3, (int32_t *)&point);
- int const sectnum = Gv_GetVarX(*insptr++);
- int const ang = Gv_GetVarX(*insptr++);
- int const neartagsectorvar = *insptr++;
- int const neartagwallvar = *insptr++;
- int const neartagspritevar = *insptr++;
- int const neartaghitdistvar = *insptr++;
- int const neartagrange = Gv_GetVarX(*insptr++);
- int const tagsearch = Gv_GetVarX(*insptr++);
+ int const sectNum = Gv_GetVarX(*insptr++);
+ int const nAngle = Gv_GetVarX(*insptr++);
+ int const sectReturn = *insptr++;
+ int const wallReturn = *insptr++;
+ int const spriteReturn = *insptr++;
+ int const distReturn = *insptr++;
+ int const tagRange = Gv_GetVarX(*insptr++);
+ int const tagSearch = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("Invalid sector %d\n", sectnum);
+ CON_ERRPRINTF("Invalid sector %d\n", sectNum);
continue;
}
int16_t neartagsector, neartagwall, neartagsprite;
int32_t neartaghitdist;
- neartag(point.x, point.y, point.z, sectnum, ang, &neartagsector, &neartagwall, &neartagsprite,
- &neartaghitdist, neartagrange, tagsearch, NULL);
+ neartag(point.x, point.y, point.z, sectNum, nAngle, &neartagsector, &neartagwall, &neartagsprite,
+ &neartaghitdist, tagRange, tagSearch, NULL);
- Gv_SetVarX(neartagsectorvar, neartagsector);
- Gv_SetVarX(neartagwallvar, neartagwall);
- Gv_SetVarX(neartagspritevar, neartagsprite);
- Gv_SetVarX(neartaghitdistvar, neartaghitdist);
+ Gv_SetVarX(sectReturn, neartagsector);
+ Gv_SetVarX(wallReturn, neartagwall);
+ Gv_SetVarX(spriteReturn, neartagsprite);
+ Gv_SetVarX(distReturn, neartaghitdist);
continue;
}
case CON_GETTIMEDATE:
insptr++;
{
- int32_t i, vals[8];
+ int32_t values[8];
+ G_GetTimeDate(values);
- G_GetTimeDate(vals);
-
- for (i=0; i<8; i++)
- Gv_SetVarX(*insptr++, vals[i]);
+ for (int i = 0; i < 8; i++)
+ Gv_SetVarX(*insptr++, values[i]);
continue;
}
@@ -3267,38 +3299,38 @@ nullquote:
case CON_MOVESPRITE:
insptr++;
{
- int const spritenum = Gv_GetVarX(*insptr++);
- vec3_t vect;
+ int const spriteNum = Gv_GetVarX(*insptr++);
+ vec3_t vect;
Gv_GetManyVars(3, (int32_t *)&vect);
- int const cliptype = Gv_GetVarX(*insptr++);
+ int const clipType = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)spritenum >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
- CON_ERRPRINTF("invalid sprite ID %d\n", spritenum);
+ CON_ERRPRINTF("invalid sprite ID %d\n", spriteNum);
insptr++;
continue;
}
- Gv_SetVarX(*insptr++, A_MoveSprite(spritenum, &vect, cliptype));
+ Gv_SetVarX(*insptr++, A_MoveSprite(spriteNum, &vect, clipType));
continue;
}
case CON_SETSPRITE:
insptr++;
{
- int const spritenum = Gv_GetVarX(*insptr++);
- vec3_t vect;
+ int const spriteNum = Gv_GetVarX(*insptr++);
+ vec3_t vect;
Gv_GetManyVars(3, (int32_t *)&vect);
- if (EDUKE32_PREDICT_FALSE((unsigned)spritenum >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
- CON_ERRPRINTF("invalid sprite ID %d\n", spritenum);
+ CON_ERRPRINTF("invalid sprite ID %d\n", spriteNum);
continue;
}
- setsprite(spritenum, &vect);
+ setsprite(spriteNum, &vect);
continue;
}
@@ -3306,109 +3338,105 @@ nullquote:
case CON_GETCEILZOFSLOPE:
insptr++;
{
- int const sectnum = Gv_GetVarX(*insptr++);
+ int const sectNum = Gv_GetVarX(*insptr++);
vec2_t vect;
Gv_GetManyVars(2, (int32_t *)&vect);
- if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("Invalid sector %d\n", sectnum);
+ CON_ERRPRINTF("Invalid sector %d\n", sectNum);
insptr++;
continue;
}
- Gv_SetVarX(*insptr++, (tw == CON_GETFLORZOFSLOPE) ? getflorzofslope(sectnum, vect.x, vect.y) :
- getceilzofslope(sectnum, vect.x, vect.y));
-
+ Gv_SetVarX(*insptr++, (tw == CON_GETFLORZOFSLOPE) ? getflorzofslope(sectNum, vect.x, vect.y) :
+ getceilzofslope(sectNum, vect.x, vect.y));
continue;
}
case CON_UPDATESECTOR:
insptr++;
{
- vec2_t vect = { 0, 0 };
+ vec2_t vect = { 0, 0 };
Gv_GetManyVars(2, (int32_t *)&vect);
- int const var = *insptr++;
- int16_t sectnum = sprite[vm.g_i].sectnum;
- updatesector(vect.x, vect.y, §num);
+ int const returnVar = *insptr++;
+ int16_t sectNum = sprite[vm.spriteNum].sectnum;
- Gv_SetVarX(var, sectnum);
+ updatesector(vect.x, vect.y, §Num);
+ Gv_SetVarX(returnVar, sectNum);
continue;
}
case CON_UPDATESECTORZ:
insptr++;
{
- vec3_t vect = { 0, 0, 0 };
+ vec3_t vect = { 0, 0, 0 };
Gv_GetManyVars(3, (int32_t *)&vect);
- int const var = *insptr++;
- int16_t sectnum = sprite[vm.g_i].sectnum;
- updatesectorz(vect.x, vect.y, vect.z, §num);
+ int const returnVar = *insptr++;
+ int16_t sectNum = sprite[vm.spriteNum].sectnum;
- Gv_SetVarX(var, sectnum);
+ updatesectorz(vect.x, vect.y, vect.z, §Num);
+ Gv_SetVarX(returnVar, sectNum);
continue;
}
case CON_SPAWN:
insptr++;
- if ((unsigned)vm.g_sp->sectnum >= MAXSECTORS)
+ if ((unsigned)vm.pSprite->sectnum >= MAXSECTORS)
{
- CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.g_sp->sectnum));
+ CON_ERRPRINTF("Invalid sector %d\n", TrackerCast(vm.pSprite->sectnum));
insptr++;
continue;
}
- A_Spawn(vm.g_i,*insptr++);
+ A_Spawn(vm.spriteNum,*insptr++);
continue;
case CON_IFWASWEAPON:
insptr++;
- VM_CONDITIONAL(actor[vm.g_i].picnum == *insptr);
+ VM_CONDITIONAL(actor[vm.spriteNum].picnum == *insptr);
continue;
case CON_IFAI:
insptr++;
- VM_CONDITIONAL(AC_AI_ID(vm.g_t) == *insptr);
+ VM_CONDITIONAL(AC_AI_ID(vm.pData) == *insptr);
continue;
case CON_IFACTION:
insptr++;
- VM_CONDITIONAL(AC_ACTION_ID(vm.g_t) == *insptr);
+ VM_CONDITIONAL(AC_ACTION_ID(vm.pData) == *insptr);
continue;
case CON_IFACTIONCOUNT:
insptr++;
- VM_CONDITIONAL(AC_ACTION_COUNT(vm.g_t) >= *insptr);
+ VM_CONDITIONAL(AC_ACTION_COUNT(vm.pData) >= *insptr);
continue;
case CON_RESETACTIONCOUNT:
insptr++;
- AC_ACTION_COUNT(vm.g_t) = 0;
+ AC_ACTION_COUNT(vm.pData) = 0;
continue;
case CON_DEBRIS:
insptr++;
{
- int32_t dnum = *insptr++;
- int32_t s, l, j;
+ int debrisTile = *insptr++;
- if ((unsigned)vm.g_sp->sectnum < MAXSECTORS)
- for (j=(*insptr)-1; j>=0; j--)
+ if ((unsigned)vm.pSprite->sectnum < MAXSECTORS)
+ for (int cnt = (*insptr) - 1; cnt >= 0; cnt--)
{
- if (vm.g_sp->picnum == BLIMP && dnum == SCRAP1)
- s = 0;
- else s = (krand()%3);
+ int const tileOffset = (vm.pSprite->picnum == BLIMP && debrisTile == SCRAP1) ? 0 : (krand() % 3);
- l = A_InsertSprite(vm.g_sp->sectnum,
- vm.g_sp->x+(krand()&255)-128,vm.g_sp->y+(krand()&255)-128,vm.g_sp->z-(8<<8)-(krand()&8191),
- dnum+s,vm.g_sp->shade,32+(krand()&15),32+(krand()&15),
- krand()&2047,(krand()&127)+32,
- -(krand()&2047),vm.g_i,5);
- if (vm.g_sp->picnum == BLIMP && dnum == SCRAP1)
- sprite[l].yvel = BlimpSpawnSprites[j%14];
- else sprite[l].yvel = -1;
- sprite[l].pal = vm.g_sp->pal;
+ int const spriteNum =
+ A_InsertSprite(vm.pSprite->sectnum, vm.pSprite->x + (krand() & 255) - 128,
+ vm.pSprite->y + (krand() & 255) - 128, vm.pSprite->z - (8 << 8) - (krand() & 8191),
+ debrisTile + tileOffset, vm.pSprite->shade, 32 + (krand() & 15), 32 + (krand() & 15),
+ krand() & 2047, (krand() & 127) + 32, -(krand() & 2047), vm.spriteNum, 5);
+
+ sprite[spriteNum].yvel =
+ (vm.pSprite->picnum == BLIMP && debrisTile == SCRAP1) ? BlimpSpawnSprites[cnt % 14] : -1;
+ sprite[spriteNum].pal = vm.pSprite->pal;
}
insptr++;
}
@@ -3416,22 +3444,22 @@ nullquote:
case CON_COUNT:
insptr++;
- AC_COUNT(vm.g_t) = (int16_t) *insptr++;
+ AC_COUNT(vm.pData) = (int16_t) *insptr++;
continue;
case CON_CSTATOR:
insptr++;
- vm.g_sp->cstat |= (int16_t) *insptr++;
+ vm.pSprite->cstat |= (int16_t) *insptr++;
continue;
case CON_CLIPDIST:
insptr++;
- vm.g_sp->clipdist = (int16_t) *insptr++;
+ vm.pSprite->clipdist = (int16_t) *insptr++;
continue;
case CON_CSTAT:
insptr++;
- vm.g_sp->cstat = (int16_t) *insptr++;
+ vm.pSprite->cstat = (int16_t) *insptr++;
continue;
case CON_SAVENN:
@@ -3445,12 +3473,12 @@ nullquote:
if (tw == CON_SAVE || ud.savegame[g_lastSaveSlot][0] == 0)
{
- time_t curtime = time(NULL);
- struct tm *timeptr = localtime(&curtime);
+ time_t timeStruct = time(NULL);
+ struct tm *pTime = localtime(&timeStruct);
Bsnprintf(ud.savegame[g_lastSaveSlot], sizeof(ud.savegame[g_lastSaveSlot]),
- "Auto %.4d%.2d%.2d %.2d%.2d%.2d\n", timeptr->tm_year + 1900, timeptr->tm_mon + 1, timeptr->tm_mday,
- timeptr->tm_hour, timeptr->tm_min, timeptr->tm_sec);
+ "Auto %.4d%.2d%.2d %.2d%.2d%.2d\n", pTime->tm_year + 1900, pTime->tm_mon + 1, pTime->tm_mday,
+ pTime->tm_hour, pTime->tm_min, pTime->tm_sec);
}
OSD_Printf("Saving to slot %d\n",g_lastSaveSlot);
@@ -3474,41 +3502,41 @@ nullquote:
case CON_IFMOVE:
insptr++;
- VM_CONDITIONAL(AC_MOVE_ID(vm.g_t) == *insptr);
+ VM_CONDITIONAL(AC_MOVE_ID(vm.pData) == *insptr);
continue;
case CON_RESETPLAYER:
insptr++;
- vm.g_flags = VM_ResetPlayer(vm.g_p, vm.g_flags, 0);
+ vm.flags = VM_ResetPlayer(vm.playerNum, vm.flags, 0);
continue;
case CON_RESETPLAYERFLAGS:
insptr++;
- vm.g_flags = VM_ResetPlayer(vm.g_p, vm.g_flags, Gv_GetVarX(*insptr++));
+ vm.flags = VM_ResetPlayer(vm.playerNum, vm.flags, Gv_GetVarX(*insptr++));
continue;
case CON_IFONWATER:
- VM_CONDITIONAL(sector[vm.g_sp->sectnum].lotag == ST_1_ABOVE_WATER &&
- klabs(vm.g_sp->z - sector[vm.g_sp->sectnum].floorz) < (32 << 8));
+ VM_CONDITIONAL(sector[vm.pSprite->sectnum].lotag == ST_1_ABOVE_WATER &&
+ klabs(vm.pSprite->z - sector[vm.pSprite->sectnum].floorz) < (32 << 8));
continue;
case CON_IFINWATER:
- VM_CONDITIONAL(sector[vm.g_sp->sectnum].lotag == ST_2_UNDERWATER);
+ VM_CONDITIONAL(sector[vm.pSprite->sectnum].lotag == ST_2_UNDERWATER);
continue;
case CON_IFCOUNT:
insptr++;
- VM_CONDITIONAL(AC_COUNT(vm.g_t) >= *insptr);
+ VM_CONDITIONAL(AC_COUNT(vm.pData) >= *insptr);
continue;
case CON_IFACTOR:
insptr++;
- VM_CONDITIONAL(vm.g_sp->picnum == *insptr);
+ VM_CONDITIONAL(vm.pSprite->picnum == *insptr);
continue;
case CON_RESETCOUNT:
insptr++;
- AC_COUNT(vm.g_t) = 0;
+ AC_COUNT(vm.pData) = 0;
continue;
case CON_ADDINVENTORY:
@@ -3526,25 +3554,25 @@ nullquote:
case GET_HEATS:
case GET_FIRSTAID:
case GET_BOOTS:
- ps->inven_icon = inv_to_icon[item];
- ps->inv_amount[item] = *insptr;
+ pPlayer->inven_icon = inv_to_icon[item];
+ pPlayer->inv_amount[item] = *insptr;
break;
case GET_SHIELD:
- ps->inv_amount[GET_SHIELD] = min(ps->inv_amount[GET_SHIELD] + *insptr, ps->max_shield_amount);
+ pPlayer->inv_amount[GET_SHIELD] = min(pPlayer->inv_amount[GET_SHIELD] + *insptr, pPlayer->max_shield_amount);
break;
case GET_ACCESS:
- switch (vm.g_sp->pal)
+ switch (vm.pSprite->pal)
{
case 0:
- ps->got_access |= 1;
+ pPlayer->got_access |= 1;
break;
case 21:
- ps->got_access |= 2;
+ pPlayer->got_access |= 2;
break;
case 23:
- ps->got_access |= 4;
+ pPlayer->got_access |= 4;
break;
}
break;
@@ -3562,78 +3590,78 @@ nullquote:
{
int32_t params[5];
Gv_GetManyVars(5, params);
- A_RadiusDamage(vm.g_i, params[0], params[1], params[2], params[3], params[4]);
+ A_RadiusDamage(vm.spriteNum, params[0], params[1], params[2], params[3], params[4]);
}
continue;
case CON_HITRADIUS:
- A_RadiusDamage(vm.g_i,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5));
+ A_RadiusDamage(vm.spriteNum,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5));
insptr += 6;
continue;
case CON_IFP:
{
- int const l = *(++insptr);
- int j = 0;
- int const s = sprite[ps->i].xvel;
- int const bits = g_player[vm.g_p].sync->bits;
+ int const moveFlags = *(++insptr);
+ int nResult = 0;
+ int const playerXVel = sprite[pPlayer->i].xvel;
+ int const syncBits = g_player[vm.playerNum].sync->bits;
- if (((l & pducking) && ps->on_ground && TEST_SYNC_KEY(bits, SK_CROUCH)) ||
- ((l & pfalling) && ps->jumping_counter == 0 && !ps->on_ground && ps->vel.z > 2048) ||
- ((l & pjumping) && ps->jumping_counter > 348) ||
- ((l & pstanding) && s >= 0 && s < 8) ||
- ((l & pwalking) && s >= 8 && !TEST_SYNC_KEY(bits, SK_RUN)) ||
- ((l & prunning) && s >= 8 && TEST_SYNC_KEY(bits, SK_RUN)) ||
- ((l & phigher) && ps->pos.z < (vm.g_sp->z - (48 << 8))) ||
- ((l & pwalkingback) && s <= -8 && !TEST_SYNC_KEY(bits, SK_RUN)) ||
- ((l & prunningback) && s <= -8 && TEST_SYNC_KEY(bits, SK_RUN)) ||
- ((l & pkicking) && (ps->quick_kick > 0 || (PWEAPON(vm.g_p, ps->curr_weapon, WorksLike) == KNEE_WEAPON &&
- ps->kickback_pic > 0))) ||
- ((l & pshrunk) && sprite[ps->i].xrepeat < 32) ||
- ((l & pjetpack) && ps->jetpack_on) ||
- ((l & ponsteroids) && ps->inv_amount[GET_STEROIDS] > 0 && ps->inv_amount[GET_STEROIDS] < 400) ||
- ((l & ponground) && ps->on_ground) ||
- ((l & palive) && sprite[ps->i].xrepeat > 32 && sprite[ps->i].extra > 0 && ps->timebeforeexit == 0) ||
- ((l & pdead) && sprite[ps->i].extra <= 0))
- j = 1;
- else if ((l & pfacing))
+ if (((moveFlags & pducking) && pPlayer->on_ground && TEST_SYNC_KEY(syncBits, SK_CROUCH)) ||
+ ((moveFlags & pfalling) && pPlayer->jumping_counter == 0 && !pPlayer->on_ground && pPlayer->vel.z > 2048) ||
+ ((moveFlags & pjumping) && pPlayer->jumping_counter > 348) ||
+ ((moveFlags & pstanding) && playerXVel >= 0 && playerXVel < 8) ||
+ ((moveFlags & pwalking) && playerXVel >= 8 && !TEST_SYNC_KEY(syncBits, SK_RUN)) ||
+ ((moveFlags & prunning) && playerXVel >= 8 && TEST_SYNC_KEY(syncBits, SK_RUN)) ||
+ ((moveFlags & phigher) && pPlayer->pos.z < (vm.pSprite->z - (48 << 8))) ||
+ ((moveFlags & pwalkingback) && playerXVel <= -8 && !TEST_SYNC_KEY(syncBits, SK_RUN)) ||
+ ((moveFlags & prunningback) && playerXVel <= -8 && TEST_SYNC_KEY(syncBits, SK_RUN)) ||
+ ((moveFlags & pkicking) && (pPlayer->quick_kick > 0 || (PWEAPON(vm.playerNum, pPlayer->curr_weapon, WorksLike) == KNEE_WEAPON &&
+ pPlayer->kickback_pic > 0))) ||
+ ((moveFlags & pshrunk) && sprite[pPlayer->i].xrepeat < 32) ||
+ ((moveFlags & pjetpack) && pPlayer->jetpack_on) ||
+ ((moveFlags & ponsteroids) && pPlayer->inv_amount[GET_STEROIDS] > 0 && pPlayer->inv_amount[GET_STEROIDS] < 400) ||
+ ((moveFlags & ponground) && pPlayer->on_ground) ||
+ ((moveFlags & palive) && sprite[pPlayer->i].xrepeat > 32 && sprite[pPlayer->i].extra > 0 && pPlayer->timebeforeexit == 0) ||
+ ((moveFlags & pdead) && sprite[pPlayer->i].extra <= 0))
+ nResult = 1;
+ else if ((moveFlags & pfacing))
{
- if (vm.g_sp->picnum == APLAYER && (g_netServer || ud.multimode > 1))
- j = G_GetAngleDelta(g_player[otherp].ps->ang, getangle(ps->pos.x - g_player[otherp].ps->pos.x,
- ps->pos.y - g_player[otherp].ps->pos.y));
- else
- j = G_GetAngleDelta(ps->ang, getangle(vm.g_sp->x - ps->pos.x, vm.g_sp->y - ps->pos.y));
+ nResult =
+ (vm.pSprite->picnum == APLAYER && (g_netServer || ud.multimode > 1))
+ ? G_GetAngleDelta(g_player[otherp].ps->ang, getangle(pPlayer->pos.x - g_player[otherp].ps->pos.x,
+ pPlayer->pos.y - g_player[otherp].ps->pos.y))
+ : G_GetAngleDelta(pPlayer->ang, getangle(vm.pSprite->x - pPlayer->pos.x, vm.pSprite->y - pPlayer->pos.y));
- j = (j > -128 && j < 128);
+ nResult = (nResult > -128 && nResult < 128);
}
- VM_CONDITIONAL(j);
+ VM_CONDITIONAL(nResult);
}
continue;
case CON_IFSTRENGTH:
insptr++;
- VM_CONDITIONAL(vm.g_sp->extra <= *insptr);
+ VM_CONDITIONAL(vm.pSprite->extra <= *insptr);
continue;
case CON_GUTS:
- A_DoGuts(vm.g_i,*(insptr+1),*(insptr+2));
+ A_DoGuts(vm.spriteNum,*(insptr+1),*(insptr+2));
insptr += 3;
continue;
case CON_IFSPAWNEDBY:
insptr++;
- VM_CONDITIONAL(actor[vm.g_i].picnum == *insptr);
+ VM_CONDITIONAL(actor[vm.spriteNum].picnum == *insptr);
continue;
case CON_WACKPLAYER:
insptr++;
- P_ForceAngle(ps);
+ P_ForceAngle(pPlayer);
continue;
case CON_FLASH:
insptr++;
- sprite[vm.g_i].shade = -127;
- ps->visibility = -127;
+ sprite[vm.spriteNum].shade = -127;
+ pPlayer->visibility = -127;
continue;
case CON_SAVEMAPSTATE:
@@ -3649,34 +3677,34 @@ nullquote:
case CON_CLEARMAPSTATE:
insptr++;
{
- int const j = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXVOLUMES*MAXLEVELS))
+ int const levelNum = Gv_GetVarX(*insptr++);
+ if (EDUKE32_PREDICT_FALSE((unsigned)levelNum >= MAXVOLUMES*MAXLEVELS))
{
- CON_ERRPRINTF("Invalid map number: %d\n", j);
+ CON_ERRPRINTF("Invalid map number: %d\n", levelNum);
continue;
}
- G_FreeMapState(j);
+ G_FreeMapState(levelNum);
}
continue;
case CON_STOPALLSOUNDS:
insptr++;
- if (screenpeek == vm.g_p)
+ if (screenpeek == vm.playerNum)
FX_StopAllSounds();
continue;
case CON_IFGAPZL:
insptr++;
- VM_CONDITIONAL(((actor[vm.g_i].floorz - actor[vm.g_i].ceilingz) >> 8) < *insptr);
+ VM_CONDITIONAL(((actor[vm.spriteNum].floorz - actor[vm.spriteNum].ceilingz) >> 8) < *insptr);
continue;
case CON_IFHITSPACE:
- VM_CONDITIONAL(TEST_SYNC_KEY(g_player[vm.g_p].sync->bits, SK_OPEN));
+ VM_CONDITIONAL(TEST_SYNC_KEY(g_player[vm.playerNum].sync->bits, SK_OPEN));
continue;
case CON_IFOUTSIDE:
- VM_CONDITIONAL(sector[vm.g_sp->sectnum].ceilingstat&1);
+ VM_CONDITIONAL(sector[vm.pSprite->sectnum].ceilingstat&1);
continue;
case CON_IFMULTIPLAYER:
@@ -3693,12 +3721,12 @@ nullquote:
case CON_OPERATE:
insptr++;
- if (sector[vm.g_sp->sectnum].lotag == 0)
+ if (sector[vm.pSprite->sectnum].lotag == 0)
{
int16_t neartagsector, neartagwall, neartagsprite;
int32_t neartaghitdist;
- neartag(vm.g_sp->x,vm.g_sp->y,vm.g_sp->z-(32<<8),vm.g_sp->sectnum,vm.g_sp->ang,
+ neartag(vm.pSprite->x,vm.pSprite->y,vm.pSprite->z-(32<<8),vm.pSprite->sectnum,vm.pSprite->ang,
&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist, 768, 4+1, NULL);
if (neartagsector >= 0 && isanearoperator(sector[neartagsector].lotag))
@@ -3712,52 +3740,52 @@ nullquote:
break;
if (j == -1)
- G_OperateSectors(neartagsector,vm.g_i);
+ G_OperateSectors(neartagsector,vm.spriteNum);
}
}
continue;
case CON_IFINSPACE:
- VM_CONDITIONAL(G_CheckForSpaceCeiling(vm.g_sp->sectnum));
+ VM_CONDITIONAL(G_CheckForSpaceCeiling(vm.pSprite->sectnum));
continue;
case CON_SPRITEPAL:
insptr++;
- if (vm.g_sp->picnum != APLAYER)
- actor[vm.g_i].tempang = vm.g_sp->pal;
- vm.g_sp->pal = *insptr++;
+ if (vm.pSprite->picnum != APLAYER)
+ actor[vm.spriteNum].tempang = vm.pSprite->pal;
+ vm.pSprite->pal = *insptr++;
continue;
case CON_CACTOR:
insptr++;
- vm.g_sp->picnum = *insptr++;
+ vm.pSprite->picnum = *insptr++;
continue;
case CON_IFBULLETNEAR:
- VM_CONDITIONAL(A_Dodge(vm.g_sp) == 1);
+ VM_CONDITIONAL(A_Dodge(vm.pSprite) == 1);
continue;
case CON_IFRESPAWN:
- if (A_CheckEnemySprite(vm.g_sp)) VM_CONDITIONAL(ud.respawn_monsters)
- else if (A_CheckInventorySprite(vm.g_sp)) VM_CONDITIONAL(ud.respawn_inventory)
+ if (A_CheckEnemySprite(vm.pSprite)) VM_CONDITIONAL(ud.respawn_monsters)
+ else if (A_CheckInventorySprite(vm.pSprite)) VM_CONDITIONAL(ud.respawn_inventory)
else VM_CONDITIONAL(ud.respawn_items)
continue;
case CON_IFFLOORDISTL:
insptr++;
- VM_CONDITIONAL((actor[vm.g_i].floorz - vm.g_sp->z) <= ((*insptr)<<8));
+ VM_CONDITIONAL((actor[vm.spriteNum].floorz - vm.pSprite->z) <= ((*insptr)<<8));
continue;
case CON_IFCEILINGDISTL:
insptr++;
- VM_CONDITIONAL((vm.g_sp->z - actor[vm.g_i].ceilingz) <= ((*insptr)<<8));
+ VM_CONDITIONAL((vm.pSprite->z - actor[vm.spriteNum].ceilingz) <= ((*insptr)<<8));
continue;
case CON_PALFROM:
insptr++;
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p >= (unsigned)playerswhenstarted))
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= (unsigned)playerswhenstarted))
{
- CON_ERRPRINTF("invalid player ID %d\n", vm.g_p);
+ CON_ERRPRINTF("invalid player ID %d\n", vm.playerNum);
insptr += 4;
}
else
@@ -3765,7 +3793,7 @@ nullquote:
palette_t const pal = { (uint8_t) * (insptr + 1), (uint8_t) * (insptr + 2), (uint8_t) * (insptr + 3),
(uint8_t) * (insptr) };
insptr += 4;
- P_PalFrom(ps, pal.f, pal.r, pal.g, pal.b);
+ P_PalFrom(pPlayer, pal.f, pal.r, pal.g, pal.b);
}
continue;
@@ -3778,12 +3806,12 @@ nullquote:
case CON_QSPRINTF:
insptr++;
{
- int const nDestQuote = Gv_GetVarX(*insptr++);
- int const nSrcQuote = Gv_GetVarX(*insptr++);
+ int const outputQuote = Gv_GetVarX(*insptr++);
+ int const inputQuote = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE(ScriptQuotes[nSrcQuote] == NULL || ScriptQuotes[nDestQuote] == NULL))
+ if (EDUKE32_PREDICT_FALSE(apStrings[inputQuote] == NULL || apStrings[outputQuote] == NULL))
{
- CON_ERRPRINTF("null quote %d\n", ScriptQuotes[nSrcQuote] ? nDestQuote : nSrcQuote);
+ CON_ERRPRINTF("null quote %d\n", apStrings[inputQuote] ? outputQuote : inputQuote);
while ((*insptr & VM_INSTMASK) != CON_NULLOP)
Gv_GetVarX(*insptr++);
@@ -3792,77 +3820,80 @@ nullquote:
continue;
}
- int32_t arg[32], i = 0, j = 0, k = 0, numargs;
- int const nQuoteLen = Bstrlen(ScriptQuotes[nSrcQuote]);
- char tempbuf[MAXQUOTELEN];
+ int32_t arg[32];
+ int const quoteLen = Bstrlen(apStrings[inputQuote]);
+ int inputPos = 0;
+ char outBuf[MAXQUOTELEN];
+ int outBufPos = 0;
+ int argIdx = 0;
- while ((*insptr & VM_INSTMASK) != CON_NULLOP && i < 32)
- arg[i++] = Gv_GetVarX(*insptr++);
+ while ((*insptr & VM_INSTMASK) != CON_NULLOP && argIdx < 32)
+ arg[argIdx++] = Gv_GetVarX(*insptr++);
- numargs = i;
+ int numArgs = argIdx;
insptr++; // skip the NOP
- i = 0;
+ argIdx = 0;
do
{
- while (k < nQuoteLen && j < MAXQUOTELEN && ScriptQuotes[nSrcQuote][k] != '%')
- tempbuf[j++] = ScriptQuotes[nSrcQuote][k++];
+ while (inputPos < quoteLen && outBufPos < MAXQUOTELEN && apStrings[inputQuote][inputPos] != '%')
+ outBuf[outBufPos++] = apStrings[inputQuote][inputPos++];
- if (ScriptQuotes[nSrcQuote][k] == '%')
+ if (apStrings[inputQuote][inputPos] == '%')
{
- k++;
- switch (ScriptQuotes[nSrcQuote][k])
+ inputPos++;
+ switch (apStrings[inputQuote][inputPos])
{
case 'l':
- if (ScriptQuotes[nSrcQuote][k+1] != 'd')
+ if (apStrings[inputQuote][inputPos+1] != 'd')
{
// write the % and l
- tempbuf[j++] = ScriptQuotes[nSrcQuote][k-1];
- tempbuf[j++] = ScriptQuotes[nSrcQuote][k++];
+ outBuf[outBufPos++] = apStrings[inputQuote][inputPos-1];
+ outBuf[outBufPos++] = apStrings[inputQuote][inputPos++];
break;
}
- k++;
+ inputPos++;
case 'd':
{
- if (i >= numargs)
+ if (argIdx >= numArgs)
goto finish_qsprintf;
char buf[16];
- Bsprintf(buf, "%d", arg[i++]);
+ Bsprintf(buf, "%d", arg[argIdx++]);
- int const ii = Bstrlen(buf);
- Bmemcpy(&tempbuf[j], buf, ii);
- j += ii;
- k++;
+ int const bufLen = Bstrlen(buf);
+ Bmemcpy(&outBuf[outBufPos], buf, bufLen);
+ outBufPos += bufLen;
+ inputPos++;
}
break;
case 's':
{
- if (i >= numargs)
+ if (argIdx >= numArgs)
goto finish_qsprintf;
- int const ii = Bstrlen(ScriptQuotes[arg[i]]);
+ int const argLen = Bstrlen(apStrings[arg[argIdx]]);
- Bmemcpy(&tempbuf[j], ScriptQuotes[arg[i]], ii);
- j += ii;
- i++;
- k++;
+ Bmemcpy(&outBuf[outBufPos], apStrings[arg[argIdx]], argLen);
+ outBufPos += argLen;
+ argIdx++;
+ inputPos++;
}
break;
default:
- tempbuf[j++] = ScriptQuotes[nSrcQuote][k-1];
+ outBuf[outBufPos++] = apStrings[inputQuote][inputPos-1];
break;
}
}
}
- while (k < nQuoteLen && j < MAXQUOTELEN);
+ while (inputPos < quoteLen && outBufPos < MAXQUOTELEN);
finish_qsprintf:
- tempbuf[j] = '\0';
- Bstrncpyz(ScriptQuotes[nDestQuote], tempbuf, MAXQUOTELEN);
+ outBuf[outBufPos] = '\0';
+ Bstrncpyz(apStrings[outputQuote], outBuf, MAXQUOTELEN);
continue;
}
@@ -3917,7 +3948,7 @@ finish_qsprintf:
else if (*insptr&(MAXGAMEVARS<<3))
{
// FIXME FIXME FIXME
- if ((lVarID & (MAXGAMEVARS-1)) == g_iStructVarIDs + STRUCT_ACTORVAR)
+ if ((lVarID & (MAXGAMEVARS-1)) == g_structVarIDs + STRUCT_ACTORVAR)
{
intptr_t const *oinsptr = insptr++;
int32_t index = Gv_GetVarX(*insptr++);
@@ -3928,7 +3959,7 @@ finish_qsprintf:
Gv_GetVarX(*insptr++);
continue;
}
- OSD_Printf(OSDTEXT_GREEN "%s: L=%d %d %d\n",keyw[g_tw],g_errorLineNum,index,Gv_GetVar(*insptr++,index,vm.g_p));
+ OSD_Printf(OSDTEXT_GREEN "%s: L=%d %d %d\n",keyw[g_tw],g_errorLineNum,index,Gv_GetVar(*insptr++,index,vm.playerNum));
continue;
}
}
@@ -3948,18 +3979,18 @@ finish_qsprintf:
Bsprintf(szBuf,"CONLOGVAR: L=%d %s ",g_errorLineNum, aGameVars[lVarID].szLabel);
strcpy(g_szBuf,szBuf);
- if (aGameVars[lVarID].nFlags & GAMEVAR_READONLY)
+ if (aGameVars[lVarID].flags & GAMEVAR_READONLY)
{
Bsprintf(szBuf," (read-only)");
strcat(g_szBuf,szBuf);
}
- if (aGameVars[lVarID].nFlags & GAMEVAR_PERPLAYER)
+ if (aGameVars[lVarID].flags & GAMEVAR_PERPLAYER)
{
- Bsprintf(szBuf," (Per Player. Player=%d)",vm.g_p);
+ Bsprintf(szBuf," (Per Player. Player=%d)",vm.playerNum);
}
- else if (aGameVars[lVarID].nFlags & GAMEVAR_PERACTOR)
+ else if (aGameVars[lVarID].flags & GAMEVAR_PERACTOR)
{
- Bsprintf(szBuf," (Per Actor. Actor=%d)",vm.g_i);
+ Bsprintf(szBuf," (Per Actor. Actor=%d)",vm.spriteNum);
}
else
{
@@ -3978,12 +4009,12 @@ finish_qsprintf:
{
tw = *insptr++;
- int const nLabel = *insptr++;
- int const lVar2 = *insptr++;
- register int32_t const nSector = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : sprite[vm.g_i].sectnum;
- register int32_t const nSet = Gv_GetVarX(lVar2);
+ int const labelNum = *insptr++;
+ int const lVar2 = *insptr++;
+ int const sectNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : sprite[vm.spriteNum].sectnum;
+ int32_t const nValue = Gv_GetVarX(lVar2);
- VM_SetSector(nSector, nLabel, nSet);
+ VM_SetSector(sectNum, labelNum, nValue);
continue;
}
@@ -3992,11 +4023,11 @@ finish_qsprintf:
{
tw = *insptr++;
- int const nLabel = *insptr++;
- int const lVar2 = *insptr++;
- register int32_t const nSector = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : sprite[vm.g_i].sectnum;
+ int const labelNum = *insptr++;
+ int const lVar2 = *insptr++;
+ int const sectNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : sprite[vm.spriteNum].sectnum;
- Gv_SetVarX(lVar2, VM_GetSector(nSector, nLabel));
+ Gv_SetVarX(lVar2, VM_GetSector(sectNum, labelNum));
continue;
}
@@ -4020,58 +4051,58 @@ finish_qsprintf:
// that is of into
// -1 for none found
//
- int const nType = *insptr++;
- int const nMaxDist = *insptr++;
- int const nGameVar = *insptr++;
- int lFound = -1;
- int nStatnum = MAXSTATUS - 1;
- int nSprite;
+ int const findPicnum = *insptr++;
+ int const maxDist = *insptr++;
+ int const returnVar = *insptr++;
+ int foundSprite = -1;
+ int findStatnum = MAXSTATUS - 1;
+ int spriteNum;
if (tw == CON_FINDNEARACTOR || tw == CON_FINDNEARACTOR3D)
- nStatnum = 1;
+ findStatnum = 1;
if (tw==CON_FINDNEARSPRITE3D || tw==CON_FINDNEARACTOR3D)
{
do
{
- nSprite=headspritestat[nStatnum]; // all sprites
- while (nSprite>=0)
+ spriteNum=headspritestat[findStatnum]; // all sprites
+ while (spriteNum>=0)
{
- if (sprite[nSprite].picnum == nType && nSprite != vm.g_i && dist(&sprite[vm.g_i], &sprite[nSprite]) < nMaxDist)
+ if (sprite[spriteNum].picnum == findPicnum && spriteNum != vm.spriteNum && dist(&sprite[vm.spriteNum], &sprite[spriteNum]) < maxDist)
{
- lFound=nSprite;
- nSprite = MAXSPRITES;
+ foundSprite=spriteNum;
+ spriteNum = MAXSPRITES;
break;
}
- nSprite = nextspritestat[nSprite];
+ spriteNum = nextspritestat[spriteNum];
}
- if (nSprite == MAXSPRITES || tw == CON_FINDNEARACTOR3D)
+ if (spriteNum == MAXSPRITES || tw == CON_FINDNEARACTOR3D)
break;
}
- while (nStatnum--);
- Gv_SetVarX(nGameVar, lFound);
+ while (findStatnum--);
+ Gv_SetVarX(returnVar, foundSprite);
continue;
}
do
{
- nSprite=headspritestat[nStatnum]; // all sprites
- while (nSprite>=0)
+ spriteNum=headspritestat[findStatnum]; // all sprites
+ while (spriteNum>=0)
{
- if (sprite[nSprite].picnum == nType && nSprite != vm.g_i && ldist(&sprite[vm.g_i], &sprite[nSprite]) < nMaxDist)
+ if (sprite[spriteNum].picnum == findPicnum && spriteNum != vm.spriteNum && ldist(&sprite[vm.spriteNum], &sprite[spriteNum]) < maxDist)
{
- lFound=nSprite;
- nSprite = MAXSPRITES;
+ foundSprite=spriteNum;
+ spriteNum = MAXSPRITES;
break;
}
- nSprite = nextspritestat[nSprite];
+ spriteNum = nextspritestat[spriteNum];
}
- if (nSprite == MAXSPRITES || tw == CON_FINDNEARACTOR)
+ if (spriteNum == MAXSPRITES || tw == CON_FINDNEARACTOR)
break;
}
- while (nStatnum--);
- Gv_SetVarX(nGameVar, lFound);
+ while (findStatnum--);
+ Gv_SetVarX(returnVar, foundSprite);
continue;
}
@@ -4086,60 +4117,60 @@ finish_qsprintf:
// that is of into
// -1 for none found
//
- int const nPicnum = *insptr++;
- int const nMaxDist = Gv_GetVarX(*insptr++);
- int const nGameVar = *insptr++;
- int lFound = -1;
- int nStatnum = 1;
- int nSprite;
+ int const findPicnum = *insptr++;
+ int const maxDist = Gv_GetVarX(*insptr++);
+ int const returnVar = *insptr++;
+ int foundSprite = -1;
+ int findStatnum = 1;
+ int spriteNum;
if (tw == CON_FINDNEARSPRITEVAR || tw == CON_FINDNEARSPRITE3DVAR)
- nStatnum = MAXSTATUS-1;
+ findStatnum = MAXSTATUS-1;
if (tw==CON_FINDNEARACTOR3DVAR || tw==CON_FINDNEARSPRITE3DVAR)
{
do
{
- nSprite=headspritestat[nStatnum]; // all sprites
+ spriteNum=headspritestat[findStatnum]; // all sprites
- while (nSprite >= 0)
+ while (spriteNum >= 0)
{
- if (sprite[nSprite].picnum == nPicnum && nSprite != vm.g_i && dist(&sprite[vm.g_i], &sprite[nSprite]) < nMaxDist)
+ if (sprite[spriteNum].picnum == findPicnum && spriteNum != vm.spriteNum && dist(&sprite[vm.spriteNum], &sprite[spriteNum]) < maxDist)
{
- lFound=nSprite;
- nSprite = MAXSPRITES;
+ foundSprite=spriteNum;
+ spriteNum = MAXSPRITES;
break;
}
- nSprite = nextspritestat[nSprite];
+ spriteNum = nextspritestat[spriteNum];
}
- if (nSprite == MAXSPRITES || tw==CON_FINDNEARACTOR3DVAR)
+ if (spriteNum == MAXSPRITES || tw==CON_FINDNEARACTOR3DVAR)
break;
}
- while (nStatnum--);
- Gv_SetVarX(nGameVar, lFound);
+ while (findStatnum--);
+ Gv_SetVarX(returnVar, foundSprite);
continue;
}
do
{
- nSprite=headspritestat[nStatnum]; // all sprites
+ spriteNum=headspritestat[findStatnum]; // all sprites
- while (nSprite >= 0)
+ while (spriteNum >= 0)
{
- if (sprite[nSprite].picnum == nPicnum && nSprite != vm.g_i && ldist(&sprite[vm.g_i], &sprite[nSprite]) < nMaxDist)
+ if (sprite[spriteNum].picnum == findPicnum && spriteNum != vm.spriteNum && ldist(&sprite[vm.spriteNum], &sprite[spriteNum]) < maxDist)
{
- lFound=nSprite;
- nSprite = MAXSPRITES;
+ foundSprite=spriteNum;
+ spriteNum = MAXSPRITES;
break;
}
- nSprite = nextspritestat[nSprite];
+ spriteNum = nextspritestat[spriteNum];
}
- if (nSprite == MAXSPRITES || tw==CON_FINDNEARACTORVAR)
+ if (spriteNum == MAXSPRITES || tw==CON_FINDNEARACTORVAR)
break;
}
- while (nStatnum--);
- Gv_SetVarX(nGameVar, lFound);
+ while (findStatnum--);
+ Gv_SetVarX(returnVar, foundSprite);
continue;
}
@@ -4152,41 +4183,41 @@ finish_qsprintf:
// that is of into
// -1 for none found
//
- int const lType = *insptr++;
- int const lMaxDist = Gv_GetVarX(*insptr++);
- int const lMaxZDist = Gv_GetVarX(*insptr++);
- int const nGameVar = *insptr++;
- int lFound = -1;
- int nStatnum = MAXSTATUS-1;
+ int const findPicnum = *insptr++;
+ int const maxDist = Gv_GetVarX(*insptr++);
+ int const maxZDist = Gv_GetVarX(*insptr++);
+ int const returnVar = *insptr++;
+ int foundSprite = -1;
+ int findStatnum = MAXSTATUS - 1;
do
{
- int nSprite = headspritestat[tw == CON_FINDNEARACTORZVAR ? 1 : nStatnum]; // all sprites
+ int spriteNum = headspritestat[tw == CON_FINDNEARACTORZVAR ? 1 : findStatnum]; // all sprites
- if (nSprite == -1)
+ if (spriteNum == -1)
continue;
do
{
- if (sprite[nSprite].picnum == lType && nSprite != vm.g_i)
+ if (sprite[spriteNum].picnum == findPicnum && spriteNum != vm.spriteNum)
{
- if (ldist(&sprite[vm.g_i], &sprite[nSprite]) < lMaxDist)
+ if (ldist(&sprite[vm.spriteNum], &sprite[spriteNum]) < maxDist)
{
- if (klabs(sprite[vm.g_i].z-sprite[nSprite].z) < lMaxZDist)
+ if (klabs(sprite[vm.spriteNum].z-sprite[spriteNum].z) < maxZDist)
{
- lFound = nSprite;
- nSprite = MAXSPRITES;
+ foundSprite = spriteNum;
+ spriteNum = MAXSPRITES;
break;
}
}
}
- nSprite = nextspritestat[nSprite];
+ spriteNum = nextspritestat[spriteNum];
}
- while (nSprite>=0);
- if (tw==CON_FINDNEARACTORZVAR || nSprite == MAXSPRITES)
+ while (spriteNum>=0);
+ if (tw==CON_FINDNEARACTORZVAR || spriteNum == MAXSPRITES)
break;
}
- while (nStatnum--);
- Gv_SetVarX(nGameVar, lFound);
+ while (findStatnum--);
+ Gv_SetVarX(returnVar, foundSprite);
continue;
}
@@ -4200,54 +4231,54 @@ finish_qsprintf:
// that is of into
// -1 for none found
//
- int const lType = *insptr++;
- int const lMaxDist = *insptr++;
- int const lMaxZDist = *insptr++;
- int const nGameVar = *insptr++;
- int lFound = -1;
- int nStatnum = MAXSTATUS - 1;
+ int const findPicnum = *insptr++;
+ int const maxDist = *insptr++;
+ int const maxZDist = *insptr++;
+ int const returnVar = *insptr++;
+ int foundSprite = -1;
+ int findStatnum = MAXSTATUS - 1;
do
{
- int nSprite = headspritestat[tw == CON_FINDNEARACTORZ ? 1 : nStatnum]; // all sprites
+ int spriteNum = headspritestat[tw == CON_FINDNEARACTORZ ? 1 : findStatnum]; // all sprites
- if (nSprite == -1)
+ if (spriteNum == -1)
continue;
do
{
- if (sprite[nSprite].picnum == lType && nSprite != vm.g_i)
+ if (sprite[spriteNum].picnum == findPicnum && spriteNum != vm.spriteNum)
{
- if (ldist(&sprite[vm.g_i], &sprite[nSprite]) < lMaxDist)
+ if (ldist(&sprite[vm.spriteNum], &sprite[spriteNum]) < maxDist)
{
- if (klabs(sprite[vm.g_i].z-sprite[nSprite].z) < lMaxZDist)
+ if (klabs(sprite[vm.spriteNum].z-sprite[spriteNum].z) < maxZDist)
{
- lFound=nSprite;
- nSprite = MAXSPRITES;
+ foundSprite=spriteNum;
+ spriteNum = MAXSPRITES;
break;
}
}
}
- nSprite = nextspritestat[nSprite];
+ spriteNum = nextspritestat[spriteNum];
}
- while (nSprite>=0);
+ while (spriteNum>=0);
- if (tw==CON_FINDNEARACTORZ || nSprite == MAXSPRITES)
+ if (tw==CON_FINDNEARACTORZ || spriteNum == MAXSPRITES)
break;
}
- while (nStatnum--);
- Gv_SetVarX(nGameVar, lFound);
+ while (findStatnum--);
+ Gv_SetVarX(returnVar, foundSprite);
continue;
}
case CON_FINDPLAYER:
insptr++;
- aGameVars[g_iReturnVarID].nValue = A_FindPlayer(&sprite[vm.g_i], &tw);
+ aGameVars[g_returnVarID].global = A_FindPlayer(&sprite[vm.spriteNum], &tw);
Gv_SetVarX(*insptr++, tw);
continue;
case CON_FINDOTHERPLAYER:
insptr++;
- aGameVars[g_iReturnVarID].nValue = P_FindOtherPlayer(vm.g_p,&tw);
+ aGameVars[g_returnVarID].global = P_FindOtherPlayer(vm.playerNum,&tw);
Gv_SetVarX(*insptr++, tw);
continue;
@@ -4256,13 +4287,12 @@ finish_qsprintf:
{
tw = *insptr++;
- int const lLabelID = *insptr++;
- int const lParm2 = (PlayerLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
- int const lVar2 = *insptr++;
- int const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p;
- int const iSet = Gv_GetVarX(lVar2);
+ int const playerNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : vm.playerNum;
+ int const labelNum = *insptr++;
+ int const lParm2 = (PlayerLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
+ int const nValue = Gv_GetVarX(*insptr++);
- VM_SetPlayer(iPlayer, lLabelID, lParm2, iSet);
+ VM_SetPlayer(playerNum, labelNum, lParm2, nValue);
continue;
}
@@ -4271,12 +4301,11 @@ finish_qsprintf:
{
tw = *insptr++;
- int const lLabelID = *insptr++;
- int const lParm2 = (PlayerLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
- int const lVar2 = *insptr++;
- int const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p;
+ int const playerNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : vm.playerNum;
+ int const labelNum = *insptr++;
+ int const lParm2 = (PlayerLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
- Gv_SetVarX(lVar2, VM_GetPlayer(iPlayer, lLabelID, lParm2));
+ Gv_SetVarX(*insptr++, VM_GetPlayer(playerNum, labelNum, lParm2));
continue;
}
@@ -4285,11 +4314,10 @@ finish_qsprintf:
{
tw = *insptr++;
- int const lLabelID = *insptr++;
- int const lVar2 = *insptr++;
- int const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p;
+ int const playerNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : vm.playerNum;
+ int const labelNum = *insptr++;
- Gv_SetVarX(lVar2, VM_GetPlayerInput(iPlayer, lLabelID));
+ Gv_SetVarX(*insptr++, VM_GetPlayerInput(playerNum, labelNum));
continue;
}
@@ -4298,12 +4326,11 @@ finish_qsprintf:
{
tw = *insptr++;
- int const lLabelID = *insptr++;
- int const lVar2 = *insptr++;
- int const iPlayer = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_p;
- int const iSet = Gv_GetVarX(lVar2);
+ int const playerNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : vm.playerNum;
+ int const labelNum = *insptr++;
+ int const iSet = Gv_GetVarX(*insptr++);
- VM_SetPlayerInput(iPlayer, lLabelID, iSet);
+ VM_SetPlayerInput(playerNum, labelNum, iSet);
continue;
}
@@ -4311,10 +4338,7 @@ finish_qsprintf:
insptr++;
{
tw = *insptr++;
-
- int const lVar2 = *insptr++;
-
- Gv_SetVarX(lVar2, VM_GetUserdef(tw));
+ Gv_SetVarX(*insptr++, VM_GetUserdef(tw));
continue;
}
@@ -4322,11 +4346,7 @@ finish_qsprintf:
insptr++;
{
tw = *insptr++;
-
- int const lVar2 = *insptr++;
- int const iSet = Gv_GetVarX(lVar2);
-
- VM_SetUserdef(tw, iSet);
+ VM_SetUserdef(tw, Gv_GetVarX(*insptr++));
continue;
}
@@ -4334,11 +4354,8 @@ finish_qsprintf:
insptr++;
{
tw = Gv_GetVarX(*insptr++);
-
- int const lLabelID = *insptr++;
- int const lVar2 = *insptr++;
-
- Gv_SetVarX(lVar2, VM_GetProjectile(tw, lLabelID));
+ int const labelNum = *insptr++;
+ Gv_SetVarX(*insptr++, VM_GetProjectile(tw, labelNum));
continue;
}
@@ -4346,12 +4363,8 @@ finish_qsprintf:
insptr++;
{
tw = Gv_GetVarX(*insptr++);
-
- int const lLabelID = *insptr++;
- int const lVar2 = *insptr++;
- int const iSet = Gv_GetVarX(lVar2);
-
- VM_SetProjectile(tw, lLabelID, iSet);
+ int const labelNum = *insptr++;
+ VM_SetProjectile(tw, labelNum, Gv_GetVarX(*insptr++));
continue;
}
@@ -4360,12 +4373,10 @@ finish_qsprintf:
{
tw = *insptr++;
- int const lLabelID = *insptr++;
- int const lVar2 = *insptr++;
- int const iWall = Gv_GetVarX(tw);
- int const iSet = Gv_GetVarX(lVar2);
+ int const wallNum = Gv_GetVarX(tw);
+ int const labelNum = *insptr++;
- VM_SetWall(iWall, lLabelID, iSet);
+ VM_SetWall(wallNum, labelNum, Gv_GetVarX(*insptr++));
continue;
}
@@ -4374,11 +4385,10 @@ finish_qsprintf:
{
tw = *insptr++;
- int const lLabelID = *insptr++;
- int const lVar2 = *insptr++;
- int const iWall = Gv_GetVarX(tw);
+ int const wallNum = Gv_GetVarX(tw);
+ int const labelNum = *insptr++;
- Gv_SetVarX(lVar2, VM_GetWall(iWall, lLabelID));
+ Gv_SetVarX(*insptr++, VM_GetWall(wallNum, labelNum));
continue;
}
@@ -4403,9 +4413,9 @@ finish_qsprintf:
}
if (tw == CON_SETACTORVAR)
- Gv_SetVar(lVar1, Gv_GetVarX(lVar2), lSprite, vm.g_p);
+ Gv_SetVar(lVar1, Gv_GetVarX(lVar2), lSprite, vm.playerNum);
else
- Gv_SetVarX(lVar2, Gv_GetVar(lVar1, lSprite, vm.g_p));
+ Gv_SetVarX(lVar2, Gv_GetVar(lVar1, lSprite, vm.playerNum));
continue;
}
@@ -4414,13 +4424,13 @@ finish_qsprintf:
case CON_GETPLAYERVAR:
insptr++;
{
- int const iPlayer = (*insptr++ != g_iThisActorID) ? Gv_GetVarX(*(insptr-1)) : vm.g_p;
+ int const playerNum = (*insptr++ != g_thisActorVarID) ? Gv_GetVarX(*(insptr-1)) : vm.playerNum;
int const lVar1 = *insptr++;
int const lVar2 = *insptr++;
- if (EDUKE32_PREDICT_FALSE((unsigned)iPlayer >= (unsigned)playerswhenstarted))
+ if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted))
{
- CON_ERRPRINTF("invalid player ID %d\n", iPlayer);
+ CON_ERRPRINTF("invalid player ID %d\n", playerNum);
if (lVar1 == MAXGAMEVARS || lVar1 & ((MAXGAMEVARS << 2) | (MAXGAMEVARS << 3)))
insptr++;
@@ -4432,9 +4442,9 @@ finish_qsprintf:
}
if (tw == CON_SETPLAYERVAR)
- Gv_SetVar(lVar1, Gv_GetVarX(lVar2), vm.g_i, iPlayer);
+ Gv_SetVar(lVar1, Gv_GetVarX(lVar2), vm.spriteNum, playerNum);
else
- Gv_SetVarX(lVar2, Gv_GetVar(lVar1, vm.g_i, iPlayer));
+ Gv_SetVarX(lVar2, Gv_GetVar(lVar1, vm.spriteNum, playerNum));
continue;
}
@@ -4444,13 +4454,11 @@ finish_qsprintf:
{
tw = *insptr++;
- int const lLabelID = *insptr++;
- int const lParm2 = (ActorLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
- int const lVar2 = *insptr++;
- int const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i;
- int const iSet = Gv_GetVarX(lVar2);
+ int const spriteNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : vm.spriteNum;
+ int const labelNum = *insptr++;
+ int const lParm2 = (ActorLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
- VM_SetSprite(iActor, lLabelID, lParm2, iSet);
+ VM_SetSprite(spriteNum, labelNum, lParm2, Gv_GetVarX(*insptr++));
continue;
}
@@ -4459,12 +4467,11 @@ finish_qsprintf:
{
tw = *insptr++;
- int const lLabelID = *insptr++;
- int const lParm2 = (ActorLabels[lLabelID].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
- int const lVar2 = *insptr++;
- int const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i;
+ int const spriteNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : vm.spriteNum;
+ int const labelNum = *insptr++;
+ int const lParm2 = (ActorLabels[labelNum].flags & LABEL_HASPARM2) ? Gv_GetVarX(*insptr++) : 0;
- Gv_SetVarX(lVar2, VM_GetSprite(iActor, lLabelID, lParm2));
+ Gv_SetVarX(*insptr++, VM_GetSprite(spriteNum, labelNum, lParm2));
continue;
}
@@ -4473,12 +4480,10 @@ finish_qsprintf:
{
tw = *insptr++;
- int const lLabelID = *insptr++;
- int const lVar2 = *insptr++;
- int const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i;
- int const iSet = Gv_GetVarX(lVar2);
+ int const spriteNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : vm.spriteNum;
+ int const labelNum = *insptr++;
- VM_SetTsprite(iActor, lLabelID, iSet);
+ VM_SetTsprite(spriteNum, labelNum, Gv_GetVarX(*insptr++));
continue;
}
@@ -4487,33 +4492,32 @@ finish_qsprintf:
{
tw = *insptr++;
- int const lLabelID = *insptr++;
- int const lVar2 = *insptr++;
- int const iActor = (tw != g_iThisActorID) ? Gv_GetVarX(tw) : vm.g_i;
+ int const spriteNum = (tw != g_thisActorVarID) ? Gv_GetVarX(tw) : vm.spriteNum;
+ int const labelNum = *insptr++;
- Gv_SetVarX(lVar2, VM_GetTsprite(iActor, lLabelID));
+ Gv_SetVarX(*insptr++, VM_GetTsprite(spriteNum, labelNum));
continue;
}
case CON_GETANGLETOTARGET:
insptr++;
- // Actor[vm.g_i].lastvx and lastvy are last known location of target.
- Gv_SetVarX(*insptr++, getangle(actor[vm.g_i].lastvx-vm.g_sp->x,actor[vm.g_i].lastvy-vm.g_sp->y));
+ // Actor[vm.spriteNum].lastvx and lastvy are last known location of target.
+ Gv_SetVarX(*insptr++, getangle(actor[vm.spriteNum].lastvx-vm.pSprite->x,actor[vm.spriteNum].lastvy-vm.pSprite->y));
continue;
case CON_ANGOFFVAR:
insptr++;
- spriteext[vm.g_i].angoff = Gv_GetVarX(*insptr++);
+ spriteext[vm.spriteNum].angoff = Gv_GetVarX(*insptr++);
continue;
case CON_LOCKPLAYER:
insptr++;
- ps->transporter_hold = Gv_GetVarX(*insptr++);
+ pPlayer->transporter_hold = Gv_GetVarX(*insptr++);
continue;
case CON_CHECKAVAILWEAPON:
insptr++;
- tw = (*insptr != g_iThisActorID) ? Gv_GetVarX(*insptr) : vm.g_p;
+ tw = (*insptr != g_thisActorVarID) ? Gv_GetVarX(*insptr) : vm.playerNum;
insptr++;
if (EDUKE32_PREDICT_FALSE((unsigned)tw >= (unsigned)playerswhenstarted))
@@ -4527,7 +4531,7 @@ finish_qsprintf:
case CON_CHECKAVAILINVEN:
insptr++;
- tw = (*insptr != g_iThisActorID) ? Gv_GetVarX(*insptr) : vm.g_p;
+ tw = (*insptr != g_thisActorVarID) ? Gv_GetVarX(*insptr) : vm.playerNum;
insptr++;
if (EDUKE32_PREDICT_FALSE((unsigned)tw >= (unsigned)playerswhenstarted))
@@ -4541,36 +4545,36 @@ finish_qsprintf:
case CON_GETPLAYERANGLE:
insptr++;
- Gv_SetVarX(*insptr++, ps->ang);
+ Gv_SetVarX(*insptr++, pPlayer->ang);
continue;
case CON_GETACTORANGLE:
insptr++;
- Gv_SetVarX(*insptr++, vm.g_sp->ang);
+ Gv_SetVarX(*insptr++, vm.pSprite->ang);
continue;
case CON_SETPLAYERANGLE:
insptr++;
- ps->ang = Gv_GetVarX(*insptr++) & 2047;
+ pPlayer->ang = Gv_GetVarX(*insptr++) & 2047;
continue;
case CON_SETACTORANGLE:
insptr++;
- vm.g_sp->ang = Gv_GetVarX(*insptr++) & 2047;
+ vm.pSprite->ang = Gv_GetVarX(*insptr++) & 2047;
continue;
case CON_SETVAR:
insptr++;
- if ((aGameVars[*insptr].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0)
- aGameVars[*insptr].nValue = *(insptr + 1);
+ if ((aGameVars[*insptr].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0)
+ aGameVars[*insptr].global = *(insptr + 1);
else
Gv_SetVarX(*insptr, *(insptr + 1));
insptr += 2;
continue;
case CON_KLABS:
- if ((aGameVars[*(insptr + 1)].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0)
- aGameVars[*(insptr + 1)].nValue = klabs(aGameVars[*(insptr + 1)].nValue);
+ if ((aGameVars[*(insptr + 1)].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0)
+ aGameVars[*(insptr + 1)].global = klabs(aGameVars[*(insptr + 1)].global);
else
Gv_SetVarX(*(insptr + 1), klabs(Gv_GetVarX(*(insptr + 1))));
insptr += 2;
@@ -4581,23 +4585,25 @@ finish_qsprintf:
{
tw = *insptr++;
- int const index = Gv_GetVarX(*insptr++);
- int const value = Gv_GetVarX(*insptr++);
+ int const arrayIndex = Gv_GetVarX(*insptr++);
+ int const newValue = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)tw >= (unsigned)g_gameArrayCount || (unsigned)index >= (unsigned)aGameArrays[tw].size))
+ if (EDUKE32_PREDICT_FALSE((unsigned)tw >= (unsigned)g_gameArrayCount ||
+ (unsigned)arrayIndex >= (unsigned)aGameArrays[tw].size))
{
- OSD_Printf(OSD_ERROR "Gv_SetVar(): tried to set invalid array ID (%d) or index out of bounds from sprite %d (%d), player %d\n",
- tw,vm.g_i,TrackerCast(sprite[vm.g_i].picnum),vm.g_p);
+ OSD_Printf(OSD_ERROR "Gv_SetVar(): tried to set invalid array ID (%d) or index out of bounds from "
+ "sprite %d (%d), player %d\n",
+ tw, vm.spriteNum, TrackerCast(sprite[vm.spriteNum].picnum), vm.playerNum);
continue;
}
- if (EDUKE32_PREDICT_FALSE(aGameArrays[tw].nFlags & GAMEARRAY_READONLY))
+ if (EDUKE32_PREDICT_FALSE(aGameArrays[tw].flags & GAMEARRAY_READONLY))
{
OSD_Printf("Tried to set on read-only array `%s'", aGameArrays[tw].szLabel);
continue;
}
- aGameArrays[tw].pValues[index]=value;
+ aGameArrays[tw].pValues[arrayIndex]=newValue;
continue;
}
@@ -4605,56 +4611,56 @@ finish_qsprintf:
case CON_READARRAYFROMFILE:
insptr++;
{
- int const nArray = *insptr++;
- int const qFilename = *insptr++;
+ int const arrayNum = *insptr++;
+ int const quoteFilename = *insptr++;
- if (EDUKE32_PREDICT_FALSE(ScriptQuotes[qFilename] == NULL))
+ if (EDUKE32_PREDICT_FALSE(apStrings[quoteFilename] == NULL))
{
- CON_ERRPRINTF("null quote %d\n", qFilename);
+ CON_ERRPRINTF("null quote %d\n", quoteFilename);
continue;
}
if (tw == CON_READARRAYFROMFILE)
{
- int32_t kfil = kopen4loadfrommod(ScriptQuotes[qFilename], 0);
+ int32_t kFile = kopen4loadfrommod(apStrings[quoteFilename], 0);
- if (kfil < 0)
+ if (kFile < 0)
continue;
- int32_t nElements = kfilelength(kfil) / sizeof(int32_t);
+ int32_t numElements = kfilelength(kFile) / sizeof(int32_t);
- if (nElements == 0)
+ if (numElements == 0)
{
- Baligned_free(aGameArrays[nArray].pValues);
- aGameArrays[nArray].pValues = NULL;
- aGameArrays[nArray].size = nElements;
+ Baligned_free(aGameArrays[arrayNum].pValues);
+ aGameArrays[arrayNum].pValues = NULL;
+ aGameArrays[arrayNum].size = numElements;
}
- else if (nElements > 0)
+ else if (numElements > 0)
{
- int const numbytes = nElements * sizeof(int32_t);
+ int const numBytes = numElements * sizeof(int32_t);
#ifdef BITNESS64
- int32_t *pArray = (int32_t *)Xcalloc(nElements, sizeof(int32_t));
- kread(kfil, pArray, numbytes);
+ int32_t *pArray = (int32_t *)Xcalloc(numElements, sizeof(int32_t));
+ kread(kFile, pArray, numBytes);
#endif
- Baligned_free(aGameArrays[nArray].pValues);
- aGameArrays[nArray].pValues = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, nElements * GAR_ELTSZ);
- aGameArrays[nArray].size = nElements;
+ Baligned_free(aGameArrays[arrayNum].pValues);
+ aGameArrays[arrayNum].pValues = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, numElements * GAR_ELTSZ);
+ aGameArrays[arrayNum].size = numElements;
#ifdef BITNESS64
- for (int i = 0; i < nElements; i++)
- aGameArrays[nArray].pValues[i] = pArray[i]; // int32_t --> int64_t
+ for (int i = 0; i < numElements; i++)
+ aGameArrays[arrayNum].pValues[i] = pArray[i]; // int32_t --> int64_t
Bfree(pArray);
#else
- kread(kfil, aGameArrays[nArray].pValues, numbytes);
+ kread(kFile, aGameArrays[arrayNum].pValues, numBytes);
#endif
}
- kclose(kfil);
+ kclose(kFile);
continue;
}
char temp[BMAX_PATH];
- if (EDUKE32_PREDICT_FALSE(G_ModDirSnprintf(temp, sizeof(temp), "%s", ScriptQuotes[qFilename])))
+ if (EDUKE32_PREDICT_FALSE(G_ModDirSnprintf(temp, sizeof(temp), "%s", apStrings[quoteFilename])))
{
CON_ERRPRINTF("file name too long\n");
continue;
@@ -4668,13 +4674,13 @@ finish_qsprintf:
continue;
}
- int const nSize = aGameArrays[nArray].size;
- int *const pArray = (int32_t *)Xmalloc(sizeof(int32_t) * nSize);
+ int const arraySize = aGameArrays[arrayNum].size;
+ int *const pArray = (int32_t *)Xmalloc(sizeof(int32_t) * arraySize);
- for (int k = 0; k < nSize; k++)
- pArray[k] = Gv_GetGameArrayValue(nArray, k);
+ for (int k = 0; k < arraySize; k++)
+ pArray[k] = Gv_GetGameArrayValue(arrayNum, k);
- fwrite(pArray, 1, sizeof(int32_t) * nSize, fil);
+ fwrite(pArray, 1, sizeof(int32_t) * arraySize, fil);
Bfree(pArray);
fclose(fil);
@@ -4684,8 +4690,8 @@ finish_qsprintf:
case CON_GETARRAYSIZE:
insptr++;
tw = *insptr++;
- Gv_SetVarX(*insptr++,(aGameArrays[tw].nFlags & GAMEARRAY_VARSIZE) ?
- Gv_GetVarX(aGameArrays[tw].size) : aGameArrays[tw].size);
+ Gv_SetVarX(*insptr++, (aGameArrays[tw].flags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[tw].size)
+ : aGameArrays[tw].size);
continue;
case CON_RESIZEARRAY:
@@ -4723,96 +4729,120 @@ finish_qsprintf:
case CON_COPY:
insptr++;
{
- int const aSrc = *insptr++;
- int nSrcIndex = Gv_GetVarX(*insptr++); //, vm.g_i, vm.g_p);
- int const aDest = *insptr++;
- int nDestIndex = Gv_GetVarX(*insptr++);
- int nElements = Gv_GetVarX(*insptr++);
+ int const srcArray = *insptr++;
+ int srcArrayIndex = Gv_GetVarX(*insptr++); //, vm.spriteNum, vm.playerNum);
+ int const destArray = *insptr++;
+ int destArrayIndex = Gv_GetVarX(*insptr++);
+ int numElements = Gv_GetVarX(*insptr++);
tw = 0;
- if (EDUKE32_PREDICT_FALSE((unsigned)aSrc>=(unsigned)g_gameArrayCount))
+ if (EDUKE32_PREDICT_FALSE((unsigned)srcArray>=(unsigned)g_gameArrayCount))
{
- CON_ERRPRINTF("Invalid array %d!", aSrc);
+ CON_ERRPRINTF("Invalid array %d!", srcArray);
tw = 1;
}
- if (EDUKE32_PREDICT_FALSE((unsigned)aDest>=(unsigned)g_gameArrayCount))
+ if (EDUKE32_PREDICT_FALSE((unsigned)destArray>=(unsigned)g_gameArrayCount))
{
- CON_ERRPRINTF("Invalid array %d!", aDest);
+ CON_ERRPRINTF("Invalid array %d!", destArray);
tw = 1;
}
- if (EDUKE32_PREDICT_FALSE(aGameArrays[aDest].nFlags & GAMEARRAY_READONLY))
+ if (EDUKE32_PREDICT_FALSE(aGameArrays[destArray].flags & GAMEARRAY_READONLY))
{
- CON_ERRPRINTF("Array %d is read-only!", aDest);
+ CON_ERRPRINTF("Array %d is read-only!", destArray);
tw = 1;
}
if (EDUKE32_PREDICT_FALSE(tw)) continue; // dirty replacement for VMFLAG_ERROR
- int const nSrcSize =
- (aGameArrays[aSrc].nFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[aSrc].size) : aGameArrays[aSrc].size;
- int const nDestSize =
- (aGameArrays[aDest].nFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[aSrc].size) : aGameArrays[aDest].size;
+ int const srcArraySize = (aGameArrays[srcArray].flags & GAMEARRAY_VARSIZE)
+ ? Gv_GetVarX(aGameArrays[srcArray].size)
+ : aGameArrays[srcArray].size;
- if (EDUKE32_PREDICT_FALSE(nSrcIndex > nSrcSize || nDestIndex > nDestSize))
+ int const destArraySize = (aGameArrays[destArray].flags & GAMEARRAY_VARSIZE)
+ ? Gv_GetVarX(aGameArrays[srcArray].size)
+ : aGameArrays[destArray].size;
+
+ if (EDUKE32_PREDICT_FALSE(srcArrayIndex > srcArraySize || destArrayIndex > destArraySize))
continue;
- if ((nSrcIndex + nElements) > nSrcSize)
- nElements = nSrcSize - nSrcIndex;
+ if ((srcArrayIndex + numElements) > srcArraySize)
+ numElements = srcArraySize - srcArrayIndex;
- if ((nDestIndex + nElements) > nDestSize)
- nElements = nDestSize - nDestIndex;
+ if ((destArrayIndex + numElements) > destArraySize)
+ numElements = destArraySize - destArrayIndex;
// Switch depending on the source array type.
- switch (aGameArrays[aSrc].nFlags & GAMEARRAY_TYPE_MASK)
+ switch (aGameArrays[srcArray].flags & GAMEARRAY_TYPE_MASK)
{
- case 0:
- // CON array to CON array.
- if (EDUKE32_PREDICT_FALSE(aGameArrays[aSrc].nFlags & GAMEARRAY_STRIDE2))
- {
- for (; nElements>0; --nElements)
- (aGameArrays[aDest].pValues)[nDestIndex++] = ((int32_t *)aGameArrays[aSrc].pValues)[nSrcIndex+=2];
+ case 0:
+ // CON array to CON array.
+ if (EDUKE32_PREDICT_FALSE(aGameArrays[srcArray].flags & GAMEARRAY_STRIDE2))
+ {
+ for (; numElements>0; --numElements)
+ {
+ (aGameArrays[destArray].pValues)[destArrayIndex++] =
+ ((int32_t *)aGameArrays[srcArray].pValues)[srcArrayIndex += 2];
+ }
+ break;
+ }
+ Bmemcpy(aGameArrays[destArray].pValues+destArrayIndex, aGameArrays[srcArray].pValues+srcArrayIndex, numElements*GAR_ELTSZ);
break;
- }
- Bmemcpy(aGameArrays[aDest].pValues+nDestIndex, aGameArrays[aSrc].pValues+nSrcIndex, nElements*GAR_ELTSZ);
- break;
- case GAMEARRAY_OFINT:
- // From int32-sized array. Note that the CON array element
- // type is intptr_t, so it is different-sized on 64-bit
- // archs, but same-sized on 32-bit ones.
- if (EDUKE32_PREDICT_FALSE(aGameArrays[aSrc].nFlags & GAMEARRAY_STRIDE2))
- {
- for (; nElements>0; --nElements)
- (aGameArrays[aDest].pValues)[nDestIndex++] = ((int32_t *)aGameArrays[aSrc].pValues)[nSrcIndex+=2];
+ case GAMEARRAY_OFINT:
+ // From int32-sized array. Note that the CON array element
+ // type is intptr_t, so it is different-sized on 64-bit
+ // archs, but same-sized on 32-bit ones.
+ if (EDUKE32_PREDICT_FALSE(aGameArrays[srcArray].flags & GAMEARRAY_STRIDE2))
+ {
+ for (; numElements>0; --numElements)
+ {
+ (aGameArrays[destArray].pValues)[destArrayIndex++] =
+ ((int32_t *)aGameArrays[srcArray].pValues)[srcArrayIndex += 2];
+ }
+ break;
+ }
+ for (; numElements>0; --numElements)
+ {
+ (aGameArrays[destArray].pValues)[destArrayIndex++] =
+ ((int32_t *)aGameArrays[srcArray].pValues)[srcArrayIndex++];
+ }
break;
- }
- for (; nElements>0; --nElements)
- (aGameArrays[aDest].pValues)[nDestIndex++] = ((int32_t *)aGameArrays[aSrc].pValues)[nSrcIndex++];
- break;
- case GAMEARRAY_OFSHORT:
- // From int16_t array. Always different-sized.
- if (EDUKE32_PREDICT_FALSE(aGameArrays[aSrc].nFlags & GAMEARRAY_STRIDE2))
- {
- for (; nElements>0; --nElements)
- (aGameArrays[aDest].pValues)[nDestIndex++] = ((int16_t *)aGameArrays[aSrc].pValues)[nSrcIndex+=2];
+ case GAMEARRAY_OFSHORT:
+ // From int16_t array. Always different-sized.
+ if (EDUKE32_PREDICT_FALSE(aGameArrays[srcArray].flags & GAMEARRAY_STRIDE2))
+ {
+ for (; numElements>0; --numElements)
+ {
+ (aGameArrays[destArray].pValues)[destArrayIndex++] =
+ ((int16_t *)aGameArrays[srcArray].pValues)[srcArrayIndex += 2];
+ }
+ break;
+ }
+ for (; numElements>0; --numElements)
+ {
+ (aGameArrays[destArray].pValues)[destArrayIndex++] =
+ ((int16_t *)aGameArrays[srcArray].pValues)[srcArrayIndex++];
+ }
break;
- }
- for (; nElements>0; --nElements)
- (aGameArrays[aDest].pValues)[nDestIndex++] = ((int16_t *)aGameArrays[aSrc].pValues)[nSrcIndex++];
- break;
- case GAMEARRAY_OFCHAR:
- // From char array. Always different-sized.
- if (EDUKE32_PREDICT_FALSE(aGameArrays[aSrc].nFlags & GAMEARRAY_STRIDE2))
- {
- for (; nElements>0; --nElements)
- (aGameArrays[aDest].pValues)[nDestIndex++] = ((uint8_t *)aGameArrays[aSrc].pValues)[nSrcIndex+=2];
+ case GAMEARRAY_OFCHAR:
+ // From char array. Always different-sized.
+ if (EDUKE32_PREDICT_FALSE(aGameArrays[srcArray].flags & GAMEARRAY_STRIDE2))
+ {
+ for (; numElements>0; --numElements)
+ {
+ (aGameArrays[destArray].pValues)[destArrayIndex++] =
+ ((uint8_t *)aGameArrays[srcArray].pValues)[srcArrayIndex += 2];
+ }
+ break;
+ }
+ for (; numElements>0; --numElements)
+ {
+ (aGameArrays[destArray].pValues)[destArrayIndex++] =
+ ((uint8_t *)aGameArrays[srcArray].pValues)[srcArrayIndex++];
+ }
break;
- }
- for (; nElements>0; --nElements)
- (aGameArrays[aDest].pValues)[nDestIndex++] = ((uint8_t *)aGameArrays[aSrc].pValues)[nSrcIndex++];
- break;
}
continue;
}
@@ -4839,8 +4869,8 @@ finish_qsprintf:
continue;
case CON_INV:
- if ((aGameVars[*(insptr + 1)].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0)
- aGameVars[*(insptr + 1)].nValue = -aGameVars[*(insptr + 1)].nValue;
+ if ((aGameVars[*(insptr + 1)].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0)
+ aGameVars[*(insptr + 1)].global = -aGameVars[*(insptr + 1)].global;
else
Gv_SetVarX(*(insptr + 1), -Gv_GetVarX(*(insptr + 1)));
insptr += 2;
@@ -4899,12 +4929,12 @@ finish_qsprintf:
insptr++;
{
tw = *insptr++;
- int const gv = Gv_GetVarX(*insptr++);
+ int const nValue = Gv_GetVarX(*insptr++);
- if ((aGameVars[tw].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0)
- aGameVars[tw].nValue = gv;
+ if ((aGameVars[tw].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) == 0)
+ aGameVars[tw].global = nValue;
else
- Gv_SetVarX(tw, gv);
+ Gv_SetVarX(tw, nValue);
}
continue;
@@ -4929,7 +4959,7 @@ finish_qsprintf:
insptr++;
continue;
}
- Gv_SetVarX(*insptr++, ps->max_ammo_amount[tw]);
+ Gv_SetVarX(*insptr++, pPlayer->max_ammo_amount[tw]);
continue;
case CON_SMAXAMMO:
@@ -4941,7 +4971,7 @@ finish_qsprintf:
insptr++;
continue;
}
- ps->max_ammo_amount[tw] = Gv_GetVarX(*insptr++);
+ pPlayer->max_ammo_amount[tw] = Gv_GetVarX(*insptr++);
continue;
case CON_MULVARVAR:
@@ -4954,31 +4984,33 @@ finish_qsprintf:
insptr++;
{
tw = *insptr++;
- int const l2 = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE(!l2))
+ int const nValue = Gv_GetVarX(*insptr++);
+
+ if (EDUKE32_PREDICT_FALSE(!nValue))
{
CON_ERRPRINTF("divide by zero!\n");
continue;
}
- Gv_DivVar(tw, l2);
+ Gv_DivVar(tw, nValue);
continue;
}
case CON_MODVARVAR:
insptr++;
{
- tw=*insptr++;
- int const l2 = Gv_GetVarX(*insptr++);
+ tw = *insptr++;
- if (EDUKE32_PREDICT_FALSE(!l2))
+ int const nValue = Gv_GetVarX(*insptr++);
+
+ if (EDUKE32_PREDICT_FALSE(!nValue))
{
CON_ERRPRINTF("mod by zero!\n");
continue;
}
- Gv_ModVar(tw, l2);
+ Gv_ModVar(tw, nValue);
continue;
}
@@ -5020,9 +5052,9 @@ finish_qsprintf:
case CON_SHIFTVARL:
insptr++;
- if ((aGameVars[*insptr].nFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK)) == 0)
+ if ((aGameVars[*insptr].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK)) == 0)
{
- aGameVars[*insptr].nValue <<= *(insptr+1);
+ aGameVars[*insptr].global <<= *(insptr+1);
insptr += 2;
continue;
}
@@ -5032,9 +5064,9 @@ finish_qsprintf:
case CON_SHIFTVARR:
insptr++;
- if ((aGameVars[*insptr].nFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK)) == 0)
+ if ((aGameVars[*insptr].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK)) == 0)
{
- aGameVars[*insptr].nValue >>= *(insptr+1);
+ aGameVars[*insptr].global >>= *(insptr+1);
insptr += 2;
continue;
}
@@ -5074,38 +5106,38 @@ finish_qsprintf:
case CON_SPGETLOTAG:
insptr++;
- aGameVars[g_iLoTagID].nValue = vm.g_sp->lotag;
+ aGameVars[g_lotagVarID].global = vm.pSprite->lotag;
continue;
case CON_SPGETHITAG:
insptr++;
- aGameVars[g_iHiTagID].nValue = vm.g_sp->hitag;
+ aGameVars[g_hitagVarID].global = vm.pSprite->hitag;
continue;
case CON_SECTGETLOTAG:
insptr++;
- aGameVars[g_iLoTagID].nValue = sector[vm.g_sp->sectnum].lotag;
+ aGameVars[g_lotagVarID].global = sector[vm.pSprite->sectnum].lotag;
continue;
case CON_SECTGETHITAG:
insptr++;
- aGameVars[g_iHiTagID].nValue = sector[vm.g_sp->sectnum].hitag;
+ aGameVars[g_hitagVarID].global = sector[vm.pSprite->sectnum].hitag;
continue;
case CON_GETTEXTUREFLOOR:
insptr++;
- aGameVars[g_iTextureID].nValue = sector[vm.g_sp->sectnum].floorpicnum;
+ aGameVars[g_textureVarID].global = sector[vm.pSprite->sectnum].floorpicnum;
continue;
case CON_STARTTRACK:
case CON_STARTTRACKVAR:
insptr++;
{
- int const level = (tw == CON_STARTTRACK) ? *(insptr++) : Gv_GetVarX(*(insptr++));
+ int const levelNum = (tw == CON_STARTTRACK) ? *(insptr++) : Gv_GetVarX(*(insptr++));
- if (EDUKE32_PREDICT_FALSE(G_StartTrack(level)))
+ if (EDUKE32_PREDICT_FALSE(G_StartTrack(levelNum)))
CON_ERRPRINTF("invalid level %d or null music for volume %d level %d\n",
- level, ud.volume_number, level);
+ levelNum, ud.volume_number, levelNum);
}
continue;
@@ -5132,12 +5164,12 @@ finish_qsprintf:
case CON_SETGAMEPALETTE:
insptr++;
- P_SetGamePalette(ps, Gv_GetVarX(*(insptr++)), 2+16);
+ P_SetGamePalette(pPlayer, Gv_GetVarX(*(insptr++)), 2+16);
continue;
case CON_GETTEXTURECEILING:
insptr++;
- aGameVars[g_iTextureID].nValue = sector[vm.g_sp->sectnum].ceilingpicnum;
+ aGameVars[g_textureVarID].global = sector[vm.pSprite->sectnum].ceilingpicnum;
continue;
case CON_IFVARVARAND:
@@ -5240,7 +5272,7 @@ finish_qsprintf:
do
{
insptr = savedinsptr;
- tw = (Gv_GetVarX(*(insptr - 1)) != *insptr);
+ tw = (Gv_GetVarX(*(insptr - 1)) != *insptr);
VM_CONDITIONAL(tw);
}
while (tw);
@@ -5253,7 +5285,7 @@ finish_qsprintf:
do
{
insptr = savedinsptr;
- tw = (Gv_GetVarX(*(insptr - 1)) < *insptr);
+ tw = (Gv_GetVarX(*(insptr - 1)) < *insptr);
VM_CONDITIONAL(tw);
} while (tw);
continue;
@@ -5265,8 +5297,8 @@ finish_qsprintf:
do
{
insptr = savedinsptr;
- tw = Gv_GetVarX(*(insptr - 1));
- tw = (tw != Gv_GetVarX(*insptr++));
+ tw = Gv_GetVarX(*(insptr - 1));
+ tw = (tw != Gv_GetVarX(*insptr++));
insptr--;
VM_CONDITIONAL(tw);
}
@@ -5280,8 +5312,8 @@ finish_qsprintf:
do
{
insptr = savedinsptr;
- tw = Gv_GetVarX(*(insptr - 1));
- tw = (tw < Gv_GetVarX(*insptr++));
+ tw = Gv_GetVarX(*(insptr - 1));
+ tw = (tw < Gv_GetVarX(*insptr++));
insptr--;
VM_CONDITIONAL(tw);
} while (tw);
@@ -5291,13 +5323,13 @@ finish_qsprintf:
case CON_FOR: // special-purpose iteration
insptr++;
{
- int const var = *insptr++;
- int const how = *insptr++;
- int const parm2 = how <= ITER_DRAWNSPRITES ? 0 : Gv_GetVarX(*insptr++);
- intptr_t const *const end = insptr + *insptr;
- intptr_t const *const beg = ++insptr;
+ int const returnVar = *insptr++;
+ int const iterType = *insptr++;
+ int const nIndex = iterType <= ITER_DRAWNSPRITES ? 0 : Gv_GetVarX(*insptr++);
+ intptr_t const *const pEnd = insptr + *insptr;
+ intptr_t const *const pNext = ++insptr;
- switch (how)
+ switch (iterType)
{
case ITER_ALLSPRITES:
for (int jj=0; jj= MAXSECTORS) goto badindex;
- for (int jj=headspritesect[parm2]; jj>=0; jj=nextspritesect[jj])
+ if ((unsigned)nIndex >= MAXSECTORS) goto badindex;
+ for (int jj=headspritesect[nIndex]; jj>=0; jj=nextspritesect[jj])
{
- Gv_SetVarX(var, jj);
- insptr = beg;
+ Gv_SetVarX(returnVar, jj);
+ insptr = pNext;
VM_Execute(0);
}
break;
case ITER_SPRITESOFSTATUS:
- if ((unsigned) parm2 >= MAXSTATUS) goto badindex;
- for (int jj=headspritestat[parm2]; jj>=0; jj=nextspritestat[jj])
+ if ((unsigned) nIndex >= MAXSTATUS) goto badindex;
+ for (int jj=headspritestat[nIndex]; jj>=0; jj=nextspritestat[jj])
{
- Gv_SetVarX(var, jj);
- insptr = beg;
+ Gv_SetVarX(returnVar, jj);
+ insptr = pNext;
VM_Execute(0);
}
break;
case ITER_WALLSOFSECTOR:
- if ((unsigned) parm2 >= MAXSECTORS) goto badindex;
- for (int jj=sector[parm2].wallptr, endwall=jj+sector[parm2].wallnum-1;
+ if ((unsigned) nIndex >= MAXSECTORS) goto badindex;
+ for (int jj=sector[nIndex].wallptr, endwall=jj+sector[nIndex].wallnum-1;
jj<=endwall; jj++)
{
- Gv_SetVarX(var, jj);
- insptr = beg;
+ Gv_SetVarX(returnVar, jj);
+ insptr = pNext;
VM_Execute(0);
}
break;
case ITER_LOOPOFWALL:
- if ((unsigned) parm2 >= (unsigned)numwalls) goto badindex;
+ if ((unsigned) nIndex >= (unsigned)numwalls) goto badindex;
{
- int jj = parm2;
+ int jj = nIndex;
do
{
- Gv_SetVarX(var, jj);
- insptr = beg;
+ Gv_SetVarX(returnVar, jj);
+ insptr = pNext;
VM_Execute(0);
jj = wall[jj].point2;
- } while (jj != parm2);
+ } while (jj != nIndex);
}
break;
case ITER_RANGE:
- for (int jj=0; jji].extra < *insptr);
+ VM_CONDITIONAL(sprite[pPlayer->i].extra < *insptr);
continue;
case CON_IFPINVENTORY:
@@ -5499,22 +5531,22 @@ finish_qsprintf:
switch (*insptr++)
{
- case GET_STEROIDS: tw = (ps->inv_amount[GET_STEROIDS] != *insptr); break;
- case GET_SHIELD: tw = (ps->inv_amount[GET_SHIELD] != ps->max_shield_amount); break;
- case GET_SCUBA: tw = (ps->inv_amount[GET_SCUBA] != *insptr); break;
- case GET_HOLODUKE: tw = (ps->inv_amount[GET_HOLODUKE] != *insptr); break;
- case GET_JETPACK: tw = (ps->inv_amount[GET_JETPACK] != *insptr); break;
+ case GET_STEROIDS: tw = (pPlayer->inv_amount[GET_STEROIDS] != *insptr); break;
+ case GET_SHIELD: tw = (pPlayer->inv_amount[GET_SHIELD] != pPlayer->max_shield_amount); break;
+ case GET_SCUBA: tw = (pPlayer->inv_amount[GET_SCUBA] != *insptr); break;
+ case GET_HOLODUKE: tw = (pPlayer->inv_amount[GET_HOLODUKE] != *insptr); break;
+ case GET_JETPACK: tw = (pPlayer->inv_amount[GET_JETPACK] != *insptr); break;
case GET_ACCESS:
- switch (vm.g_sp->pal)
+ switch (vm.pSprite->pal)
{
- case 0: tw = (ps->got_access & 1); break;
- case 21: tw = (ps->got_access & 2); break;
- case 23: tw = (ps->got_access & 4); break;
+ case 0: tw = (pPlayer->got_access & 1); break;
+ case 21: tw = (pPlayer->got_access & 2); break;
+ case 23: tw = (pPlayer->got_access & 4); break;
}
break;
- case GET_HEATS: tw = (ps->inv_amount[GET_HEATS] != *insptr); break;
- case GET_FIRSTAID: tw = (ps->inv_amount[GET_FIRSTAID] != *insptr); break;
- case GET_BOOTS: tw = (ps->inv_amount[GET_BOOTS] != *insptr); break;
+ case GET_HEATS: tw = (pPlayer->inv_amount[GET_HEATS] != *insptr); break;
+ case GET_FIRSTAID: tw = (pPlayer->inv_amount[GET_FIRSTAID] != *insptr); break;
+ case GET_BOOTS: tw = (pPlayer->inv_amount[GET_BOOTS] != *insptr); break;
default: tw = 0; CON_ERRPRINTF("invalid inventory ID: %d\n", (int32_t) * (insptr - 1));
}
@@ -5523,47 +5555,47 @@ finish_qsprintf:
case CON_PSTOMP:
insptr++;
- if (ps->knee_incs == 0 && sprite[ps->i].xrepeat >= 40)
- if (cansee(vm.g_sp->x, vm.g_sp->y, vm.g_sp->z - (4 << 8), vm.g_sp->sectnum, ps->pos.x,
- ps->pos.y, ps->pos.z + ZOFFSET2, sprite[ps->i].sectnum))
+ if (pPlayer->knee_incs == 0 && sprite[pPlayer->i].xrepeat >= 40)
+ if (cansee(vm.pSprite->x, vm.pSprite->y, vm.pSprite->z - (4 << 8), vm.pSprite->sectnum, pPlayer->pos.x,
+ pPlayer->pos.y, pPlayer->pos.z + ZOFFSET2, sprite[pPlayer->i].sectnum))
{
- int32_t j = playerswhenstarted - 1;
+ int32_t numPlayers = playerswhenstarted - 1;
- for (; j >= 0; j--)
+ for (; numPlayers >= 0; --numPlayers)
{
- if (g_player[j].ps->actorsqu == vm.g_i)
+ if (g_player[numPlayers].ps->actorsqu == vm.spriteNum)
break;
}
- if (j == -1)
+ if (numPlayers == -1)
{
- ps->knee_incs = 1;
- if (ps->weapon_pos == 0)
- ps->weapon_pos = -1;
- ps->actorsqu = vm.g_i;
+ if (pPlayer->weapon_pos == 0)
+ pPlayer->weapon_pos = -1;
+
+ pPlayer->actorsqu = vm.spriteNum;
+ pPlayer->knee_incs = 1;
}
}
-
continue;
case CON_IFAWAYFROMWALL:
{
- int16_t s1 = vm.g_sp->sectnum;
+ int16_t otherSectnum = vm.pSprite->sectnum;
tw = 0;
#define IFAWAYDIST 108
- updatesector(vm.g_sp->x + IFAWAYDIST, vm.g_sp->y + IFAWAYDIST, &s1);
- if (s1 == vm.g_sp->sectnum)
+ updatesector(vm.pSprite->x + IFAWAYDIST, vm.pSprite->y + IFAWAYDIST, &otherSectnum);
+ if (otherSectnum == vm.pSprite->sectnum)
{
- updatesector(vm.g_sp->x - IFAWAYDIST, vm.g_sp->y - IFAWAYDIST, &s1);
- if (s1 == vm.g_sp->sectnum)
+ updatesector(vm.pSprite->x - IFAWAYDIST, vm.pSprite->y - IFAWAYDIST, &otherSectnum);
+ if (otherSectnum == vm.pSprite->sectnum)
{
- updatesector(vm.g_sp->x + IFAWAYDIST, vm.g_sp->y - IFAWAYDIST, &s1);
- if (s1 == vm.g_sp->sectnum)
+ updatesector(vm.pSprite->x + IFAWAYDIST, vm.pSprite->y - IFAWAYDIST, &otherSectnum);
+ if (otherSectnum == vm.pSprite->sectnum)
{
- updatesector(vm.g_sp->x - IFAWAYDIST, vm.g_sp->y + IFAWAYDIST, &s1);
- if (s1 == vm.g_sp->sectnum)
+ updatesector(vm.pSprite->x - IFAWAYDIST, vm.pSprite->y + IFAWAYDIST, &otherSectnum);
+ if (otherSectnum == vm.pSprite->sectnum)
tw = 1;
}
}
@@ -5579,102 +5611,102 @@ finish_qsprintf:
case CON_QUOTE:
insptr++;
- if (EDUKE32_PREDICT_FALSE((unsigned)(*insptr) >= MAXQUOTES) || ScriptQuotes[*insptr] == NULL)
+ if (EDUKE32_PREDICT_FALSE((unsigned)(*insptr) >= MAXQUOTES) || apStrings[*insptr] == NULL)
{
CON_ERRPRINTF("invalid quote ID %d\n", (int32_t)(*insptr));
insptr++;
continue;
}
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p >= MAXPLAYERS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS))
{
- CON_ERRPRINTF("bad player for quote %d: (%d)\n", (int32_t)*insptr,vm.g_p);
+ CON_ERRPRINTF("bad player for quote %d: (%d)\n", (int32_t)*insptr,vm.playerNum);
insptr++;
continue;
}
- P_DoQuote(*(insptr++)|MAXQUOTES,ps);
+ P_DoQuote(*(insptr++) | MAXQUOTES, pPlayer);
continue;
case CON_USERQUOTE:
insptr++;
tw = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)tw >= MAXQUOTES || ScriptQuotes[tw] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)tw >= MAXQUOTES || apStrings[tw] == NULL))
{
CON_ERRPRINTF("invalid quote ID %d\n", tw);
continue;
}
- G_AddUserQuote(ScriptQuotes[tw]);
+ G_AddUserQuote(apStrings[tw]);
continue;
case CON_ECHO:
insptr++;
tw = Gv_GetVarX(*insptr++);
- if (EDUKE32_PREDICT_FALSE((unsigned)tw >= MAXQUOTES || ScriptQuotes[tw] == NULL))
+ if (EDUKE32_PREDICT_FALSE((unsigned)tw >= MAXQUOTES || apStrings[tw] == NULL))
{
CON_ERRPRINTF("invalid quote ID %d\n", tw);
continue;
}
- OSD_Printf("%s\n", ScriptQuotes[tw]);
+ OSD_Printf("%s\n", apStrings[tw]);
continue;
case CON_IFINOUTERSPACE:
- VM_CONDITIONAL(G_CheckForSpaceFloor(vm.g_sp->sectnum));
+ VM_CONDITIONAL(G_CheckForSpaceFloor(vm.pSprite->sectnum));
continue;
case CON_IFNOTMOVING:
- VM_CONDITIONAL((actor[vm.g_i].movflag&49152) > 16384);
+ VM_CONDITIONAL((actor[vm.spriteNum].movflag&49152) > 16384);
continue;
case CON_RESPAWNHITAG:
insptr++;
- switch (DYNAMICTILEMAP(vm.g_sp->picnum))
+ switch (DYNAMICTILEMAP(vm.pSprite->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:
- if (vm.g_sp->yvel)
- G_OperateRespawns(vm.g_sp->yvel);
- break;
- default:
-// if (vm.g_sp->hitag >= 0)
- G_OperateRespawns(vm.g_sp->hitag);
- break;
+ 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:
+ if (vm.pSprite->yvel)
+ G_OperateRespawns(vm.pSprite->yvel);
+ break;
+ default:
+ // if (vm.pSprite->hitag >= 0)
+ G_OperateRespawns(vm.pSprite->hitag);
+ break;
}
continue;
case CON_IFSPRITEPAL:
insptr++;
- VM_CONDITIONAL(vm.g_sp->pal == *insptr);
+ VM_CONDITIONAL(vm.pSprite->pal == *insptr);
continue;
case CON_IFANGDIFFL:
insptr++;
- tw = klabs(G_GetAngleDelta(ps->ang, vm.g_sp->ang));
+ tw = klabs(G_GetAngleDelta(pPlayer->ang, vm.pSprite->ang));
VM_CONDITIONAL(tw <= *insptr);
continue;
case CON_IFNOSOUNDS:
- VM_CONDITIONAL(!A_CheckAnySoundPlaying(vm.g_i));
+ VM_CONDITIONAL(!A_CheckAnySoundPlaying(vm.spriteNum));
continue;
case CON_SPRITEFLAGS:
insptr++;
- actor[vm.g_i].flags = Gv_GetVarX(*insptr++);
+ actor[vm.spriteNum].flags = Gv_GetVarX(*insptr++);
continue;
case CON_GETTICKS:
@@ -5685,13 +5717,13 @@ finish_qsprintf:
case CON_GETCURRADDRESS:
insptr++;
tw = *insptr++;
- Gv_SetVarX(tw, (intptr_t)(insptr - script));
+ Gv_SetVarX(tw, (intptr_t)(insptr - apScript));
continue;
case CON_JUMP: // XXX XXX XXX
insptr++;
- tw = Gv_GetVarX(*insptr++);
- insptr = (intptr_t *)(tw + script);
+ tw = Gv_GetVarX(*insptr++);
+ insptr = (intptr_t *)(tw + apScript);
continue;
default:
@@ -5709,40 +5741,42 @@ finish_qsprintf:
}
// NORECURSE
-void A_LoadActor(int32_t iActor)
+void A_LoadActor(int32_t spriteNum)
{
- vm.g_i = iActor; // Sprite ID
- vm.g_sp = &sprite[iActor]; // Pointer to sprite structure
+ vm.spriteNum = spriteNum; // Sprite ID
+ vm.pSprite = &sprite[spriteNum]; // Pointer to sprite structure
- if (g_tile[vm.g_sp->picnum].loadPtr == NULL)
+ if (g_tile[vm.pSprite->picnum].loadPtr == NULL)
return;
- vm.g_t = &actor[iActor].t_data[0]; // Sprite's 'extra' data
- vm.g_p = -1; // Player ID
- vm.g_x = -1; // Distance
- vm.g_pp = g_player[0].ps;
+ vm.pData = &actor[spriteNum].t_data[0]; // Sprite's 'extra' data
+ vm.playerNum = -1; // Player ID
+ vm.playerDist = -1; // Distance
+ vm.pPlayer = g_player[0].ps;
- vm.g_flags &= ~(VM_RETURN | VM_KILL | VM_NOEXECUTE);
+ vm.flags &= ~(VM_RETURN | VM_KILL | VM_NOEXECUTE);
- if ((unsigned)vm.g_sp->sectnum >= MAXSECTORS)
+ if ((unsigned)vm.pSprite->sectnum >= MAXSECTORS)
{
- A_DeleteSprite(vm.g_i);
+ A_DeleteSprite(vm.spriteNum);
return;
}
- insptr = g_tile[vm.g_sp->picnum].loadPtr;
+ insptr = g_tile[vm.pSprite->picnum].loadPtr;
VM_Execute(1);
insptr = NULL;
- if (vm.g_flags & VM_KILL)
- A_DeleteSprite(vm.g_i);
+ if (vm.flags & VM_KILL)
+ A_DeleteSprite(vm.spriteNum);
}
#endif
// NORECURSE
-void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
+void A_Execute(int32_t spriteNum, int32_t playerNum, int32_t lDist)
{
- vmstate_t tempvm = { iActor, iPlayer, lDist, &actor[iActor].t_data[0], &sprite[iActor], g_player[iPlayer].ps, 0 };
+ vmstate_t tempvm = {
+ spriteNum, playerNum, lDist, 0, &sprite[spriteNum], &actor[spriteNum].t_data[0], g_player[playerNum].ps
+ };
vm = tempvm;
#ifdef LUNATIC
@@ -5752,9 +5786,9 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
#endif
/*
- if (g_netClient && A_CheckSpriteFlags(iActor, SFLAG_NULL))
+ if (g_netClient && A_CheckSpriteFlags(spriteNum, SFLAG_NULL))
{
- A_DeleteSprite(iActor);
+ A_DeleteSprite(spriteNum);
return;
}
*/
@@ -5762,18 +5796,18 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
if (g_netServer || g_netClient)
randomseed = ticrandomseed;
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_sp->sectnum >= MAXSECTORS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.pSprite->sectnum >= MAXSECTORS))
{
- if (A_CheckEnemySprite(vm.g_sp))
- vm.g_pp->actors_killed++;
+ if (A_CheckEnemySprite(vm.pSprite))
+ vm.pPlayer->actors_killed++;
- A_DeleteSprite(vm.g_i);
+ A_DeleteSprite(vm.spriteNum);
return;
}
#if !defined LUNATIC
- actionofs = AC_ACTION_ID(vm.g_t);
- actionptr = (actionofs != 0 && actionofs + 4u < (unsigned)g_scriptSize) ? &script[actionofs] : NULL;
+ actionofs = AC_ACTION_ID(vm.pData);
+ actionptr = (actionofs != 0 && actionofs + 4u < (unsigned)g_scriptSize) ? &apScript[actionofs] : NULL;
if (actionptr != NULL)
#endif
@@ -5783,32 +5817,32 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
int const action_incval = actionptr[3];
int const action_delay = actionptr[4];
#else
- int const action_frames = actor[vm.g_i].ac.numframes;
- int const action_incval = actor[vm.g_i].ac.incval;
- int const action_delay = actor[vm.g_i].ac.delay;
+ int const action_frames = actor[vm.spriteNum].ac.numframes;
+ int const action_incval = actor[vm.spriteNum].ac.incval;
+ int const action_delay = actor[vm.spriteNum].ac.delay;
#endif
- uint16_t *actionticsptr = &AC_ACTIONTICS(vm.g_sp, &actor[vm.g_i]);
+ uint16_t *actionticsptr = &AC_ACTIONTICS(vm.pSprite, &actor[vm.spriteNum]);
*actionticsptr += TICSPERFRAME;
if (*actionticsptr > action_delay)
{
*actionticsptr = 0;
- AC_ACTION_COUNT(vm.g_t)++;
- AC_CURFRAME(vm.g_t) += action_incval;
+ AC_ACTION_COUNT(vm.pData)++;
+ AC_CURFRAME(vm.pData) += action_incval;
}
- if (klabs(AC_CURFRAME(vm.g_t)) >= klabs(action_frames * action_incval))
- AC_CURFRAME(vm.g_t) = 0;
+ if (klabs(AC_CURFRAME(vm.pData)) >= klabs(action_frames * action_incval))
+ AC_CURFRAME(vm.pData) = 0;
}
#ifdef LUNATIC
- int const picnum = vm.g_sp->picnum;
+ int const picnum = vm.pSprite->picnum;
if (L_IsInitialized(&g_ElState) && El_HaveActor(picnum))
{
double t = gethiticks();
- killit = (El_CallActor(&g_ElState, picnum, iActor, iPlayer, lDist)==1);
+ killit = (El_CallActor(&g_ElState, picnum, spriteNum, playerNum, lDist)==1);
t = gethiticks()-t;
g_actorTotalMs[picnum] += t;
@@ -5817,7 +5851,7 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
g_actorCalls[picnum]++;
}
#else
- insptr = 4 + (g_tile[vm.g_sp->picnum].execPtr);
+ insptr = 4 + (g_tile[vm.pSprite->picnum].execPtr);
VM_Execute(1);
insptr = NULL;
#endif
@@ -5825,20 +5859,20 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
#ifdef LUNATIC
if (killit)
#else
- if (vm.g_flags & VM_KILL)
+ if (vm.flags & VM_KILL)
#endif
{
- VM_DeleteSprite(iActor, iPlayer);
+ VM_DeleteSprite(spriteNum, playerNum);
return;
}
VM_Move();
- if (vm.g_sp->statnum != STAT_ACTOR)
+ if (vm.pSprite->statnum != STAT_ACTOR)
{
- if (vm.g_sp->statnum == STAT_STANDABLE)
+ if (vm.pSprite->statnum == STAT_STANDABLE)
{
- switch (DYNAMICTILEMAP(vm.g_sp->picnum))
+ switch (DYNAMICTILEMAP(vm.pSprite->picnum))
{
case RUBBERCAN__STATIC:
case EXPLODINGBARREL__STATIC:
@@ -5851,49 +5885,49 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
case NUKEBARRELLEAKED__STATIC:
case TRIPBOMB__STATIC:
case EGG__STATIC:
- if (actor[vm.g_i].timetosleep > 1)
- actor[vm.g_i].timetosleep--;
- else if (actor[vm.g_i].timetosleep == 1)
- changespritestat(vm.g_i, STAT_ZOMBIEACTOR);
+ if (actor[vm.spriteNum].timetosleep > 1)
+ actor[vm.spriteNum].timetosleep--;
+ else if (actor[vm.spriteNum].timetosleep == 1)
+ changespritestat(vm.spriteNum, STAT_ZOMBIEACTOR);
default: break;
}
}
return;
}
- if (A_CheckEnemySprite(vm.g_sp))
+ if (A_CheckEnemySprite(vm.pSprite))
{
- if (vm.g_sp->xrepeat > 60 || (ud.respawn_monsters == 1 && vm.g_sp->extra <= 0))
+ if (vm.pSprite->xrepeat > 60 || (ud.respawn_monsters == 1 && vm.pSprite->extra <= 0))
return;
}
- else if (EDUKE32_PREDICT_FALSE(ud.respawn_items == 1 && (vm.g_sp->cstat & 32768)))
+ else if (EDUKE32_PREDICT_FALSE(ud.respawn_items == 1 && (vm.pSprite->cstat & 32768)))
return;
- if (A_CheckSpriteFlags(vm.g_i, SFLAG_USEACTIVATOR) && sector[vm.g_sp->sectnum].lotag & 16384)
- changespritestat(vm.g_i, STAT_ZOMBIEACTOR);
- else if (actor[vm.g_i].timetosleep > 1)
- actor[vm.g_i].timetosleep--;
- else if (actor[vm.g_i].timetosleep == 1)
+ if (A_CheckSpriteFlags(vm.spriteNum, SFLAG_USEACTIVATOR) && sector[vm.pSprite->sectnum].lotag & 16384)
+ changespritestat(vm.spriteNum, STAT_ZOMBIEACTOR);
+ else if (actor[vm.spriteNum].timetosleep > 1)
+ actor[vm.spriteNum].timetosleep--;
+ else if (actor[vm.spriteNum].timetosleep == 1)
{
// hack for 1.3D fire sprites
- if (EDUKE32_PREDICT_FALSE(g_scriptVersion == 13 && (vm.g_sp->picnum == FIRE || vm.g_sp->picnum == FIRE2)))
+ if (EDUKE32_PREDICT_FALSE(g_scriptVersion == 13 && (vm.pSprite->picnum == FIRE || vm.pSprite->picnum == FIRE2)))
return;
- changespritestat(vm.g_i, STAT_ZOMBIEACTOR);
+ changespritestat(vm.spriteNum, STAT_ZOMBIEACTOR);
}
}
void G_SaveMapState(void)
{
- int32_t levelnum = ud.volume_number*MAXLEVELS+ud.level_number;
- map_t *mapinfo = &MapInfo[levelnum];
+ int32_t levelNum = ud.volume_number * MAXLEVELS + ud.level_number;
+ map_t *const pMapInfo = &aMapInfo[levelNum];
- if (mapinfo->savedstate == NULL)
+ if (pMapInfo->savedstate == NULL)
{
- mapinfo->savedstate = (mapstate_t *) Xaligned_alloc(16, sizeof(mapstate_t));
- Bmemset(mapinfo->savedstate, 0, sizeof(mapstate_t));
+ pMapInfo->savedstate = (mapstate_t *) Xaligned_alloc(16, sizeof(mapstate_t));
+ Bmemset(pMapInfo->savedstate, 0, sizeof(mapstate_t));
}
- mapstate_t *save = mapinfo->savedstate;
+ mapstate_t *save = pMapInfo->savedstate;
if (save == NULL)
return;
@@ -5967,24 +6001,24 @@ void G_SaveMapState(void)
#if !defined LUNATIC
for (int i=g_gameVarCount-1; i>=0; i--)
{
- if (aGameVars[i].nFlags & GAMEVAR_NORESET) continue;
- if (aGameVars[i].nFlags & GAMEVAR_PERPLAYER)
+ if (aGameVars[i].flags & GAMEVAR_NORESET) continue;
+ if (aGameVars[i].flags & GAMEVAR_PERPLAYER)
{
if (!save->vars[i])
save->vars[i] = (intptr_t *)Xaligned_alloc(16, MAXPLAYERS * sizeof(intptr_t));
Bmemcpy(&save->vars[i][0],&aGameVars[i].pValues[0],sizeof(intptr_t) * MAXPLAYERS);
}
- else if (aGameVars[i].nFlags & GAMEVAR_PERACTOR)
+ else if (aGameVars[i].flags & GAMEVAR_PERACTOR)
{
if (!save->vars[i])
save->vars[i] = (intptr_t *)Xaligned_alloc(16, MAXSPRITES * sizeof(intptr_t));
Bmemcpy(&save->vars[i][0],&aGameVars[i].pValues[0],sizeof(intptr_t) * MAXSPRITES);
}
- else save->vars[i] = (intptr_t *)aGameVars[i].nValue;
+ else save->vars[i] = (intptr_t *)aGameVars[i].global;
}
#else
int32_t slen;
- const char *svcode = El_SerializeGamevars(&slen, levelnum);
+ const char *svcode = El_SerializeGamevars(&slen, levelNum);
if (slen < 0)
{
@@ -6002,27 +6036,26 @@ void G_SaveMapState(void)
void G_RestoreMapState(void)
{
- int32_t levelnum = ud.volume_number*MAXLEVELS+ud.level_number;
- mapstate_t *save = MapInfo[levelnum].savedstate;
+ int32_t levelNum = ud.volume_number * MAXLEVELS + ud.level_number;
+ mapstate_t *pSavedState = aMapInfo[levelNum].savedstate;
- if (save != NULL)
+ if (pSavedState != NULL)
{
- int32_t i, x;
- char phealth[MAXPLAYERS];
+ int playerHealth[MAXPLAYERS];
- for (i=0; ii].extra;
+ for (int i=0; ii].extra;
pub = NUMPAGES;
pus = NUMPAGES;
G_UpdateScreenArea();
- Bmemcpy(&numwalls,&save->numwalls,sizeof(numwalls));
- Bmemcpy(&wall[0],&save->wall[0],sizeof(walltype)*MAXWALLS);
- Bmemcpy(&numsectors,&save->numsectors,sizeof(numsectors));
- Bmemcpy(§or[0],&save->sector[0],sizeof(sectortype)*MAXSECTORS);
- Bmemcpy(&sprite[0],&save->sprite[0],sizeof(spritetype)*MAXSPRITES);
- Bmemcpy(&spriteext[0],&save->spriteext[0],sizeof(spriteext_t)*MAXSPRITES);
+ Bmemcpy(&numwalls,&pSavedState->numwalls,sizeof(numwalls));
+ Bmemcpy(&wall[0],&pSavedState->wall[0],sizeof(walltype)*MAXWALLS);
+ Bmemcpy(&numsectors,&pSavedState->numsectors,sizeof(numsectors));
+ Bmemcpy(§or[0],&pSavedState->sector[0],sizeof(sectortype)*MAXSECTORS);
+ Bmemcpy(&sprite[0],&pSavedState->sprite[0],sizeof(spritetype)*MAXSPRITES);
+ Bmemcpy(&spriteext[0],&pSavedState->spriteext[0],sizeof(spriteext_t)*MAXSPRITES);
// If we're restoring from EVENT_ANIMATESPRITES, all spriteext[].tspr
// will be overwritten, so NULL them.
@@ -6030,79 +6063,79 @@ void G_RestoreMapState(void)
if (g_currentEventExec == EVENT_ANIMATESPRITES)
{
initprintf("Line %d: loadmapstate called from EVENT_ANIMATESPRITES. WHY?\n",g_errorLineNum);
- for (i=0; inumsprites;
- tailspritefree = save->tailspritefree;
- Bmemcpy(&headspritesect[0],&save->headspritesect[0],sizeof(headspritesect));
- Bmemcpy(&prevspritesect[0],&save->prevspritesect[0],sizeof(prevspritesect));
- Bmemcpy(&nextspritesect[0],&save->nextspritesect[0],sizeof(nextspritesect));
- Bmemcpy(&headspritestat[0],&save->headspritestat[0],sizeof(headspritestat));
- Bmemcpy(&prevspritestat[0],&save->prevspritestat[0],sizeof(prevspritestat));
- Bmemcpy(&nextspritestat[0],&save->nextspritestat[0],sizeof(nextspritestat));
+ Numsprites = pSavedState->numsprites;
+ tailspritefree = pSavedState->tailspritefree;
+ Bmemcpy(&headspritesect[0],&pSavedState->headspritesect[0],sizeof(headspritesect));
+ Bmemcpy(&prevspritesect[0],&pSavedState->prevspritesect[0],sizeof(prevspritesect));
+ Bmemcpy(&nextspritesect[0],&pSavedState->nextspritesect[0],sizeof(nextspritesect));
+ Bmemcpy(&headspritestat[0],&pSavedState->headspritestat[0],sizeof(headspritestat));
+ Bmemcpy(&prevspritestat[0],&pSavedState->prevspritestat[0],sizeof(prevspritestat));
+ Bmemcpy(&nextspritestat[0],&pSavedState->nextspritestat[0],sizeof(nextspritestat));
#ifdef YAX_ENABLE
- Bmemcpy(&numyaxbunches, &save->numyaxbunches, sizeof(numyaxbunches));
+ Bmemcpy(&numyaxbunches, &pSavedState->numyaxbunches, sizeof(numyaxbunches));
# if !defined NEW_MAP_FORMAT
- Bmemcpy(yax_bunchnum, save->yax_bunchnum, sizeof(yax_bunchnum));
- Bmemcpy(yax_nextwall, save->yax_nextwall, sizeof(yax_nextwall));
+ Bmemcpy(yax_bunchnum, pSavedState->yax_bunchnum, sizeof(yax_bunchnum));
+ Bmemcpy(yax_nextwall, pSavedState->yax_nextwall, sizeof(yax_nextwall));
# endif
#endif
- Bmemcpy(&actor[0],&save->actor[0],sizeof(actor_t)*MAXSPRITES);
+ Bmemcpy(&actor[0],&pSavedState->actor[0],sizeof(actor_t)*MAXSPRITES);
- Bmemcpy(&g_numCyclers,&save->g_numCyclers,sizeof(g_numCyclers));
- Bmemcpy(&cyclers[0],&save->cyclers[0],sizeof(cyclers));
- Bmemcpy(&g_playerSpawnPoints[0],&save->g_playerSpawnPoints[0],sizeof(g_playerSpawnPoints));
- Bmemcpy(&g_numAnimWalls,&save->g_numAnimWalls,sizeof(g_numAnimWalls));
- Bmemcpy(&SpriteDeletionQueue[0],&save->SpriteDeletionQueue[0],sizeof(SpriteDeletionQueue));
- Bmemcpy(&g_spriteDeleteQueuePos,&save->g_spriteDeleteQueuePos,sizeof(g_spriteDeleteQueuePos));
- Bmemcpy(&animwall[0],&save->animwall[0],sizeof(animwall));
- Bmemcpy(&g_origins[0],&save->origins[0],sizeof(g_origins));
- Bmemcpy(&g_mirrorWall[0],&save->g_mirrorWall[0],sizeof(g_mirrorWall));
- Bmemcpy(&g_mirrorSector[0],&save->g_mirrorSector[0],sizeof(g_mirrorSector));
- Bmemcpy(&g_mirrorCount,&save->g_mirrorCount,sizeof(g_mirrorCount));
- Bmemcpy(&show2dsector[0],&save->show2dsector[0],sizeof(show2dsector));
- Bmemcpy(&g_numClouds,&save->g_numClouds,sizeof(g_numClouds));
- Bmemcpy(&clouds[0],&save->clouds[0],sizeof(clouds));
- Bmemcpy(&cloudx,&save->cloudx,sizeof(cloudx));
- Bmemcpy(&cloudy,&save->cloudy,sizeof(cloudy));
- Bmemcpy(&g_pskyidx,&save->pskyidx,sizeof(g_pskyidx));
- Bmemcpy(&animategoal[0],&save->animategoal[0],sizeof(animategoal));
- Bmemcpy(&animatevel[0],&save->animatevel[0],sizeof(animatevel));
- Bmemcpy(&g_animateCount,&save->g_animateCount,sizeof(g_animateCount));
- Bmemcpy(&animatesect[0],&save->animatesect[0],sizeof(animatesect));
+ Bmemcpy(&g_numCyclers,&pSavedState->g_numCyclers,sizeof(g_numCyclers));
+ Bmemcpy(&cyclers[0],&pSavedState->cyclers[0],sizeof(cyclers));
+ Bmemcpy(&g_playerSpawnPoints[0],&pSavedState->g_playerSpawnPoints[0],sizeof(g_playerSpawnPoints));
+ Bmemcpy(&g_numAnimWalls,&pSavedState->g_numAnimWalls,sizeof(g_numAnimWalls));
+ 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));
+ Bmemcpy(&g_origins[0],&pSavedState->origins[0],sizeof(g_origins));
+ Bmemcpy(&g_mirrorWall[0],&pSavedState->g_mirrorWall[0],sizeof(g_mirrorWall));
+ 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_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(&animateptr[0],&save->animateptr[0],sizeof(animateptr));
+ Bmemcpy(&animateptr[0],&pSavedState->animateptr[0],sizeof(animateptr));
G_Util_PtrToIdx(animateptr, g_animateCount, sector, P2I_BACK);
- Bmemcpy(&g_numPlayerSprites,&save->g_numPlayerSprites,sizeof(g_numPlayerSprites));
- Bmemcpy(&g_earthquakeTime,&save->g_earthquakeTime,sizeof(g_earthquakeTime));
- Bmemcpy(&lockclock,&save->lockclock,sizeof(lockclock));
- Bmemcpy(&randomseed,&save->randomseed,sizeof(randomseed));
- Bmemcpy(&g_globalRandom,&save->g_globalRandom,sizeof(g_globalRandom));
+ Bmemcpy(&g_numPlayerSprites,&pSavedState->g_numPlayerSprites,sizeof(g_numPlayerSprites));
+ Bmemcpy(&g_earthquakeTime,&pSavedState->g_earthquakeTime,sizeof(g_earthquakeTime));
+ Bmemcpy(&lockclock,&pSavedState->lockclock,sizeof(lockclock));
+ Bmemcpy(&randomseed,&pSavedState->randomseed,sizeof(randomseed));
+ Bmemcpy(&g_globalRandom,&pSavedState->g_globalRandom,sizeof(g_globalRandom));
#if !defined LUNATIC
- for (i=g_gameVarCount-1; i>=0; i--)
+ for (int i=g_gameVarCount-1; i>=0; i--)
{
- if (aGameVars[i].nFlags & GAMEVAR_NORESET) continue;
- if (aGameVars[i].nFlags & GAMEVAR_PERPLAYER)
+ if (aGameVars[i].flags & GAMEVAR_NORESET) continue;
+ if (aGameVars[i].flags & GAMEVAR_PERPLAYER)
{
- if (!save->vars[i]) continue;
- Bmemcpy(&aGameVars[i].pValues[0],&save->vars[i][0],sizeof(intptr_t) * MAXPLAYERS);
+ if (!pSavedState->vars[i]) continue;
+ Bmemcpy(&aGameVars[i].pValues[0],&pSavedState->vars[i][0],sizeof(intptr_t) * MAXPLAYERS);
}
- else if (aGameVars[i].nFlags & GAMEVAR_PERACTOR)
+ else if (aGameVars[i].flags & GAMEVAR_PERACTOR)
{
- if (!save->vars[i]) continue;
- Bmemcpy(&aGameVars[i].pValues[0],&save->vars[i][0],sizeof(intptr_t) * MAXSPRITES);
+ if (!pSavedState->vars[i]) continue;
+ Bmemcpy(&aGameVars[i].pValues[0],&pSavedState->vars[i][0],sizeof(intptr_t) * MAXSPRITES);
}
- else aGameVars[i].nValue = (intptr_t)save->vars[i];
+ else aGameVars[i].global = (intptr_t)pSavedState->vars[i];
}
Gv_RefreshPointers();
#else
- if (save->savecode)
+ if (pSavedState->savecode)
{
- El_RestoreGamevars(save->savecode);
+ El_RestoreGamevars(pSavedState->savecode);
}
#endif
// Update g_player[].ps->i (sprite indices of players) to be consistent
@@ -6111,15 +6144,15 @@ void G_RestoreMapState(void)
// - walk forward (to door leading to other level "Shadowpine Forest")
// - in new level, walk backward to get back to the Spider Den
// - walk backward to the door leading to Shadowpine Forest --> crash.
- for (SPRITES_OF(STAT_PLAYER, i))
+ for (int SPRITES_OF(STAT_PLAYER, i))
{
int32_t snum = P_Get(i);
Bassert((unsigned)snum < MAXPLAYERS);
g_player[snum].ps->i = i;
}
- for (i=0; ii].extra = phealth[i];
+ for (int i=0; ii].extra = playerHealth[i];
if (g_player[myconnectindex].ps->over_shoulder_on != 0)
{
@@ -6132,7 +6165,7 @@ void G_RestoreMapState(void)
if (ud.lockout)
{
- for (x=g_numAnimWalls-1; x>=0; x--)
+ for (int x=g_numAnimWalls-1; x>=0; x--)
switch (DYNAMICTILEMAP(wall[animwall[x].wallnum].picnum))
{
case FEMPIC1__STATIC:
@@ -6147,7 +6180,7 @@ void G_RestoreMapState(void)
#if 0
else
{
- for (x=g_numAnimWalls-1; x>=0; x--)
+ for (int x=g_numAnimWalls-1; x>=0; x--)
if (wall[animwall[x].wallnum].extra >= 0)
wall[animwall[x].wallnum].picnum = wall[animwall[x].wallnum].extra;
}
@@ -6177,25 +6210,25 @@ int32_t VM_ResetPlayer2(int32_t snum, int32_t flags)
int32_t VM_CheckSquished2(int32_t i, int32_t snum)
{
- vm.g_i = i;
- vm.g_sp = &sprite[i];
- vm.g_p = snum;
- vm.g_pp = g_player[snum].ps;
+ vm.spriteNum = i;
+ vm.pSprite = &sprite[i];
+ vm.playerNum = snum;
+ vm.pPlayer = g_player[snum].ps;
return VM_CheckSquished();
}
#endif
// MYOS* CON commands.
-LUNATIC_EXTERN void VM_DrawTileGeneric(int32_t x, int32_t y, int32_t zoom, int32_t tilenum,
- int32_t shade, int32_t orientation, int32_t p)
+LUNATIC_EXTERN void VM_DrawTileGeneric(int32_t x, int32_t y, int32_t zoom, int32_t tilenum, int32_t shade,
+ int32_t orientation, int32_t p)
{
- int32_t a = 0;
+ int32_t rotAngle = 0;
orientation &= (ROTATESPRITE_MAX-1);
if (orientation&4)
- a = 1024;
+ rotAngle = 1024;
if (!(orientation&ROTATESPRITE_FULL16))
{
@@ -6203,16 +6236,16 @@ LUNATIC_EXTERN void VM_DrawTileGeneric(int32_t x, int32_t y, int32_t zoom, int32
y<<=16;
}
- rotatesprite_win(x, y, zoom, a, tilenum, shade, p, 2|orientation);
+ rotatesprite_win(x, y, zoom, rotAngle, tilenum, shade, p, 2|orientation);
}
#if !defined LUNATIC
void VM_DrawTile(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation)
{
- DukePlayer_t *ps = g_player[screenpeek].ps;
- int32_t p = ps->cursectnum >= 0 ? sector[ps->cursectnum].floorpal : 0;
+ DukePlayer_t *pPlayer = g_player[screenpeek].ps;
+ int32_t tilePal = pPlayer->cursectnum >= 0 ? sector[pPlayer->cursectnum].floorpal : 0;
- VM_DrawTileGeneric(x, y, 65536, tilenum, shade, orientation, p);
+ VM_DrawTileGeneric(x, y, 65536, tilenum, shade, orientation, tilePal);
}
void VM_DrawTilePal(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p)
@@ -6222,10 +6255,10 @@ void VM_DrawTilePal(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_
void VM_DrawTileSmall(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation)
{
- DukePlayer_t *ps = g_player[screenpeek].ps;
- int32_t p = ps->cursectnum >= 0 ? sector[ps->cursectnum].floorpal : 0;
+ DukePlayer_t *const pPlayer = g_player[screenpeek].ps;
+ int32_t tilePal = pPlayer->cursectnum >= 0 ? sector[pPlayer->cursectnum].floorpal : 0;
- VM_DrawTileGeneric(x, y, 32768, tilenum, shade, orientation, p);
+ VM_DrawTileGeneric(x, y, 32768, tilenum, shade, orientation, tilePal);
}
void VM_DrawTilePalSmall(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p)
diff --git a/polymer/eduke32/source/gameexec.h b/polymer/eduke32/source/gameexec.h
index 946cc1c53..e6f3d1832 100644
--- a/polymer/eduke32/source/gameexec.h
+++ b/polymer/eduke32/source/gameexec.h
@@ -44,14 +44,14 @@ extern int32_t g_tw;
extern int32_t g_errorLineNum;
extern int32_t g_currentEventExec;
-void A_LoadActor(int32_t iActor);
+void A_LoadActor(int32_t spriteNum);
#endif
-void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist);
-void A_Fall(int nSprite);
-int32_t A_FurthestVisiblePoint(int32_t iActor,uspritetype * const ts,int32_t *dax,int32_t *day);
-int32_t A_GetFurthestAngle(int32_t iActor,int32_t angs);
-void A_GetZLimits(int32_t iActor);
+void A_Execute(int32_t spriteNum, int32_t playerNum, int32_t lDist);
+void A_Fall(int spriteNum);
+int32_t A_FurthestVisiblePoint(int32_t spriteNum,uspritetype * const ts,int32_t *dax,int32_t *day);
+int32_t A_GetFurthestAngle(int spriteNum,int angDiv);
+void A_GetZLimits(int32_t spriteNum);
int G_GetAngleDelta(int a,int na);
void G_RestoreMapState();
void G_SaveMapState();
@@ -66,38 +66,38 @@ void VM_DrawTileGeneric(int32_t x, int32_t y, int32_t zoom, int32_t tilenum,
int32_t shade, int32_t orientation, int32_t p);
#endif
-int32_t VM_OnEventWithBoth_(int nEventID, int nSprite, int nPlayer, int nDist, int32_t nReturn);
-int32_t VM_OnEventWithReturn_(int nEventID, int nSprite, int nPlayer, int32_t nReturn);
-int32_t VM_OnEventWithDist_(int nEventID, int nSprite, int nPlayer, int nDist);
-int32_t VM_OnEvent_(int nEventID, int nSprite, int nPlayer);
+int32_t VM_OnEventWithBoth_(int nEventID, int spriteNum, int playerNum, int nDist, int32_t nReturn);
+int32_t VM_OnEventWithReturn_(int nEventID, int spriteNum, int playerNum, int32_t nReturn);
+int32_t VM_OnEventWithDist_(int nEventID, int spriteNum, int playerNum, int nDist);
+int32_t VM_OnEvent_(int nEventID, int spriteNum, int playerNum);
FORCE_INLINE int VM_HaveEvent(int nEventID)
{
#ifdef LUNATIC
return L_IsInitialized(&g_ElState) && El_HaveEvent(nEventID);
#else
- return !!apScriptGameEvent[nEventID];
+ return !!apScriptEvents[nEventID];
#endif
}
-FORCE_INLINE int32_t VM_OnEventWithBoth(int nEventID, int nSprite, int nPlayer, int nDist, int32_t nReturn)
+FORCE_INLINE int32_t VM_OnEventWithBoth(int nEventID, int spriteNum, int playerNum, int nDist, int32_t nReturn)
{
- return VM_HaveEvent(nEventID) ? VM_OnEventWithBoth_(nEventID, nSprite, nPlayer, nDist, nReturn) : nReturn;
+ return VM_HaveEvent(nEventID) ? VM_OnEventWithBoth_(nEventID, spriteNum, playerNum, nDist, nReturn) : nReturn;
}
-FORCE_INLINE int32_t VM_OnEventWithReturn(int nEventID, int nSprite, int nPlayer, int nReturn)
+FORCE_INLINE int32_t VM_OnEventWithReturn(int nEventID, int spriteNum, int playerNum, int nReturn)
{
- return VM_HaveEvent(nEventID) ? VM_OnEventWithReturn_(nEventID, nSprite, nPlayer, nReturn) : nReturn;
+ return VM_HaveEvent(nEventID) ? VM_OnEventWithReturn_(nEventID, spriteNum, playerNum, nReturn) : nReturn;
}
-FORCE_INLINE int32_t VM_OnEventWithDist(int nEventID, int nSprite, int nPlayer, int nDist)
+FORCE_INLINE int32_t VM_OnEventWithDist(int nEventID, int spriteNum, int playerNum, int nDist)
{
- return VM_HaveEvent(nEventID) ? VM_OnEventWithDist_(nEventID, nSprite, nPlayer, nDist) : 0;
+ return VM_HaveEvent(nEventID) ? VM_OnEventWithDist_(nEventID, spriteNum, playerNum, nDist) : 0;
}
-FORCE_INLINE int32_t VM_OnEvent(int nEventID, int nSprite, int nPlayer)
+FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNum)
{
- return VM_HaveEvent(nEventID) ? VM_OnEvent_(nEventID, nSprite, nPlayer) : 0;
+ return VM_HaveEvent(nEventID) ? VM_OnEvent_(nEventID, spriteNum, playerNum) : 0;
}
#define CON_ERRPRINTF(Text, ...) do { \
@@ -105,7 +105,7 @@ FORCE_INLINE int32_t VM_OnEvent(int nEventID, int nSprite, int nPlayer)
} while (0)
void G_GetTimeDate(int32_t *vals);
-int G_StartTrack(int nLevel);
+int G_StartTrack(int levelNum);
int32_t A_Dodge(spritetype *s);
#ifdef LUNATIC
void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sect,
diff --git a/polymer/eduke32/source/gamestructures.c b/polymer/eduke32/source/gamestructures.c
index 1fd8e8c5a..20568c329 100644
--- a/polymer/eduke32/source/gamestructures.c
+++ b/polymer/eduke32/source/gamestructures.c
@@ -24,160 +24,160 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// I got a 3-4 fps gain by inlining these...
#ifndef gamevars_c_
-int32_t __fastcall VM_GetUserdef(register int32_t lLabelID);
-void __fastcall VM_SetUserdef(register int32_t const lLabelID, register int32_t const iSet);
-int32_t __fastcall VM_GetActiveProjectile(register int32_t const iActor, register int32_t lLabelID);
-void __fastcall VM_SetActiveProjectile(register int32_t const iActor, register int32_t const lLabelID, register int32_t const iSet);
-int32_t __fastcall VM_GetPlayer(register int32_t const iPlayer, register int32_t lLabelID, register int32_t const lParm2);
-void __fastcall VM_SetPlayer(register int32_t const iPlayer, register int32_t const lLabelID, register int32_t const lParm2, register int32_t const iSet);
-int32_t __fastcall VM_GetPlayerInput(register int32_t const iPlayer, register int32_t lLabelID);
-void __fastcall VM_SetPlayerInput(register int32_t const iPlayer, register int32_t const lLabelID, register int32_t const iSet);
-int32_t __fastcall VM_GetWall(register int32_t const iWall, register int32_t lLabelID);
-void __fastcall VM_SetWall(register int32_t const iWall, register int32_t const lLabelID, register int32_t const iSet);
-int32_t __fastcall VM_GetSector(register int32_t const iSector, register int32_t lLabelID);
-void __fastcall VM_SetSector(register int32_t const iSector, register int32_t const lLabelID, register int32_t iSet);
-int32_t __fastcall VM_GetSprite(register int32_t const iActor, register int32_t lLabelID, register int32_t const lParm2);
-void __fastcall VM_SetSprite(register int32_t const iActor, register int32_t const lLabelID, register int32_t const lParm2, register int32_t const iSet);
-int32_t __fastcall VM_GetTsprite(register int32_t const iActor, register int32_t lLabelID);
-void __fastcall VM_SetTsprite(register int32_t const iActor, register int32_t const lLabelID, register int32_t const iSet);
-int32_t __fastcall VM_GetProjectile(register int32_t const iTile, register int32_t lLabelID);
-void __fastcall VM_SetProjectile(register int32_t const iTile, register int32_t const lLabelID, register int32_t const iSet);
-int32_t __fastcall VM_GetTileData(register int32_t const iTile, register int32_t lLabelID);
-int32_t __fastcall VM_GetPalData(register int32_t const iPal, register int32_t lLabelID);
+int32_t __fastcall VM_GetUserdef(register int32_t labelNum);
+void __fastcall VM_SetUserdef(register int32_t const labelNum, register int32_t const iSet);
+int32_t __fastcall VM_GetActiveProjectile(register int32_t const spriteNum, register int32_t labelNum);
+void __fastcall VM_SetActiveProjectile(register int32_t const spriteNum, register int32_t const labelNum, register int32_t const iSet);
+int32_t __fastcall VM_GetPlayer(register int32_t const playerNum, register int32_t labelNum, register int32_t const lParm2);
+void __fastcall VM_SetPlayer(register int32_t const playerNum, register int32_t const labelNum, register int32_t const lParm2, register int32_t const iSet);
+int32_t __fastcall VM_GetPlayerInput(register int32_t const playerNum, register int32_t labelNum);
+void __fastcall VM_SetPlayerInput(register int32_t const playerNum, register int32_t const labelNum, register int32_t const iSet);
+int32_t __fastcall VM_GetWall(register int32_t const wallNum, register int32_t labelNum);
+void __fastcall VM_SetWall(register int32_t const wallNum, register int32_t const labelNum, register int32_t const iSet);
+int32_t __fastcall VM_GetSector(register int32_t const sectNum, register int32_t labelNum);
+void __fastcall VM_SetSector(register int32_t const sectNum, register int32_t const labelNum, register int32_t iSet);
+int32_t __fastcall VM_GetSprite(register int32_t const spriteNum, register int32_t labelNum, register int32_t const lParm2);
+void __fastcall VM_SetSprite(register int32_t const spriteNum, register int32_t const labelNum, register int32_t const lParm2, register int32_t const iSet);
+int32_t __fastcall VM_GetTsprite(register int32_t const spriteNum, register int32_t labelNum);
+void __fastcall VM_SetTsprite(register int32_t const spriteNum, register int32_t const labelNum, register int32_t const iSet);
+int32_t __fastcall VM_GetProjectile(register int32_t const tileNum, register int32_t labelNum);
+void __fastcall VM_SetProjectile(register int32_t const tileNum, register int32_t const labelNum, register int32_t const iSet);
+int32_t __fastcall VM_GetTileData(register int32_t const tileNum, register int32_t labelNum);
+int32_t __fastcall VM_GetPalData(register int32_t const palNum, register int32_t labelNum);
#else
-int32_t __fastcall VM_GetUserdef(register int32_t lLabelID)
+int32_t __fastcall VM_GetUserdef(register int32_t labelNum)
{
- switch (lLabelID)
+ switch (labelNum)
{
- case USERDEFS_GOD: lLabelID = ud.god; break;
- case USERDEFS_WARP_ON: lLabelID = ud.warp_on; break;
- case USERDEFS_CASHMAN: lLabelID = ud.cashman; break;
- case USERDEFS_EOG: lLabelID = ud.eog; break;
- case USERDEFS_SHOWALLMAP: lLabelID = ud.showallmap; break;
- case USERDEFS_SHOW_HELP: lLabelID = ud.show_help; break;
- case USERDEFS_SCROLLMODE: lLabelID = ud.scrollmode; break;
- case USERDEFS_CLIPPING: lLabelID = ud.noclip; break;
- // case USERDEFS_USER_NAME: lLabelID= ud.user_name[MAXPLAYERS][32]; break;
- // case USERDEFS_RIDECULE: lLabelID= ud.ridecule; break;
- // case USERDEFS_SAVEGAME: lLabelID= ud.savegame; break;
- // case USERDEFS_PWLOCKOUT: lLabelID= ud.pwlockout; break;
- // case USERDEFS_RTSNAME: lLabelID= ud.rtsname; break;
- case USERDEFS_OVERHEAD_ON: lLabelID = ud.overhead_on; break;
- case USERDEFS_LAST_OVERHEAD: lLabelID = ud.last_overhead; break;
- case USERDEFS_SHOWWEAPONS: lLabelID = ud.showweapons; break;
- case USERDEFS_PAUSE_ON: lLabelID = ud.pause_on; break;
- case USERDEFS_FROM_BONUS: lLabelID = ud.from_bonus; break;
- case USERDEFS_CAMERASPRITE: lLabelID = ud.camerasprite; break;
- case USERDEFS_LAST_CAMSPRITE: lLabelID = ud.last_camsprite; break;
- case USERDEFS_LAST_LEVEL: lLabelID = ud.last_level; break;
- case USERDEFS_SECRETLEVEL: lLabelID = ud.secretlevel; break;
- case USERDEFS_CONST_VISIBILITY: lLabelID = ud.const_visibility; break;
- case USERDEFS_UW_FRAMERATE: lLabelID = ud.uw_framerate; break;
- case USERDEFS_CAMERA_TIME: lLabelID = ud.camera_time; break;
- case USERDEFS_FOLFVEL: lLabelID = ud.folfvel; break;
- case USERDEFS_FOLAVEL: lLabelID = ud.folavel; break;
- case USERDEFS_FOLX: lLabelID = ud.folx; break;
- case USERDEFS_FOLY: lLabelID = ud.foly; break;
- case USERDEFS_FOLA: lLabelID = ud.fola; break;
- case USERDEFS_RECCNT: lLabelID = ud.reccnt; break;
- case USERDEFS_ENTERED_NAME: lLabelID = ud.entered_name; break;
- case USERDEFS_SCREEN_TILTING: lLabelID = ud.screen_tilting; break;
- case USERDEFS_SHADOWS: lLabelID = ud.shadows; break;
- case USERDEFS_FTA_ON: lLabelID = ud.fta_on; break;
- case USERDEFS_EXECUTIONS: lLabelID = ud.executions; break;
- case USERDEFS_AUTO_RUN: lLabelID = ud.auto_run; break;
- case USERDEFS_COORDS: lLabelID = ud.coords; break;
- case USERDEFS_TICKRATE: lLabelID = ud.tickrate; break;
- case USERDEFS_M_COOP: lLabelID = ud.m_coop; break;
- case USERDEFS_COOP: lLabelID = ud.coop; break;
- case USERDEFS_SCREEN_SIZE: lLabelID = ud.screen_size; break;
- case USERDEFS_LOCKOUT: lLabelID = ud.lockout; break;
- case USERDEFS_CROSSHAIR: lLabelID = ud.crosshair; break;
- case USERDEFS_PLAYERAI: lLabelID = ud.playerai; break;
- case USERDEFS_RESPAWN_MONSTERS: lLabelID = ud.respawn_monsters; break;
- case USERDEFS_RESPAWN_ITEMS: lLabelID = ud.respawn_items; break;
- case USERDEFS_RESPAWN_INVENTORY: lLabelID = ud.respawn_inventory; break;
- case USERDEFS_RECSTAT: lLabelID = ud.recstat; break;
- case USERDEFS_MONSTERS_OFF: lLabelID = ud.monsters_off; break;
- case USERDEFS_BRIGHTNESS: lLabelID = ud.brightness; break;
- case USERDEFS_M_RESPAWN_ITEMS: lLabelID = ud.m_respawn_items; break;
- case USERDEFS_M_RESPAWN_MONSTERS: lLabelID = ud.m_respawn_monsters; break;
- case USERDEFS_M_RESPAWN_INVENTORY: lLabelID = ud.m_respawn_inventory; break;
- case USERDEFS_M_RECSTAT: lLabelID = ud.m_recstat; break;
- case USERDEFS_M_MONSTERS_OFF: lLabelID = ud.m_monsters_off; break;
- case USERDEFS_DETAIL: lLabelID = ud.detail; break;
- case USERDEFS_M_FFIRE: lLabelID = ud.m_ffire; break;
- case USERDEFS_FFIRE: lLabelID = ud.ffire; break;
- case USERDEFS_M_PLAYER_SKILL: lLabelID = ud.m_player_skill; break;
- case USERDEFS_M_LEVEL_NUMBER: lLabelID = ud.m_level_number; break;
- case USERDEFS_M_VOLUME_NUMBER: lLabelID = ud.m_volume_number; break;
- case USERDEFS_MULTIMODE: lLabelID = ud.multimode; break;
- case USERDEFS_PLAYER_SKILL: lLabelID = ud.player_skill; break;
- case USERDEFS_LEVEL_NUMBER: lLabelID = ud.level_number; break;
- case USERDEFS_VOLUME_NUMBER: lLabelID = ud.volume_number; break;
- case USERDEFS_M_MARKER: lLabelID = ud.m_marker; break;
- case USERDEFS_MARKER: lLabelID = ud.marker; break;
- case USERDEFS_MOUSEFLIP: lLabelID = ud.mouseflip; break;
- case USERDEFS_STATUSBARSCALE: lLabelID = ud.statusbarscale; break;
- case USERDEFS_DRAWWEAPON: lLabelID = ud.drawweapon; break;
- case USERDEFS_MOUSEAIMING: lLabelID = ud.mouseaiming; break;
- case USERDEFS_WEAPONSWITCH: lLabelID = ud.weaponswitch; break;
- case USERDEFS_DEMOCAMS: lLabelID = ud.democams; break;
- case USERDEFS_COLOR: lLabelID = ud.color; break;
- case USERDEFS_MSGDISPTIME: lLabelID = ud.msgdisptime; break;
- case USERDEFS_STATUSBARMODE: lLabelID = ud.statusbarmode; break;
- case USERDEFS_M_NOEXITS: lLabelID = ud.m_noexits; break;
- case USERDEFS_NOEXITS: lLabelID = ud.noexits; break;
- case USERDEFS_AUTOVOTE: lLabelID = ud.autovote; break;
- case USERDEFS_AUTOMSG: lLabelID = ud.automsg; break;
- case USERDEFS_IDPLAYERS: lLabelID = ud.idplayers; break;
- case USERDEFS_TEAM: lLabelID = ud.team; break;
- case USERDEFS_VIEWBOB: lLabelID = ud.viewbob; break;
- case USERDEFS_WEAPONSWAY: lLabelID = ud.weaponsway; break;
- case USERDEFS_ANGLEINTERPOLATION: lLabelID = ud.angleinterpolation; break;
- case USERDEFS_OBITUARIES: lLabelID = ud.obituaries; break;
- case USERDEFS_LEVELSTATS: lLabelID = ud.levelstats; break;
- case USERDEFS_CROSSHAIRSCALE: lLabelID = ud.crosshairscale; break;
- case USERDEFS_ALTHUD: lLabelID = ud.althud; break;
- case USERDEFS_DISPLAY_BONUS_SCREEN: lLabelID = ud.display_bonus_screen; break;
- case USERDEFS_SHOW_LEVEL_TEXT: lLabelID = ud.show_level_text; break;
- case USERDEFS_WEAPONSCALE: lLabelID = ud.weaponscale; break;
- case USERDEFS_TEXTSCALE: lLabelID = ud.textscale; break;
- case USERDEFS_RUNKEY_MODE: lLabelID = ud.runkey_mode; break;
- case USERDEFS_M_ORIGIN_X: lLabelID = ud.m_origin.x; break;
- case USERDEFS_M_ORIGIN_Y: lLabelID = ud.m_origin.y; break;
- case USERDEFS_PLAYERBEST: lLabelID = ud.playerbest; break;
- case USERDEFS_MUSICTOGGLE: lLabelID = ud.config.MusicToggle; break;
- case USERDEFS_USEVOXELS: lLabelID = usevoxels; break;
+ case USERDEFS_GOD: labelNum = ud.god; break;
+ case USERDEFS_WARP_ON: labelNum = ud.warp_on; break;
+ case USERDEFS_CASHMAN: labelNum = ud.cashman; break;
+ case USERDEFS_EOG: labelNum = ud.eog; break;
+ case USERDEFS_SHOWALLMAP: labelNum = ud.showallmap; break;
+ case USERDEFS_SHOW_HELP: labelNum = ud.show_help; break;
+ case USERDEFS_SCROLLMODE: labelNum = ud.scrollmode; break;
+ case USERDEFS_CLIPPING: labelNum = ud.noclip; break;
+ // case USERDEFS_USER_NAME: labelNum= ud.user_name[MAXPLAYERS][32]; break;
+ // case USERDEFS_RIDECULE: labelNum= ud.ridecule; break;
+ // case USERDEFS_SAVEGAME: labelNum= ud.savegame; break;
+ // case USERDEFS_PWLOCKOUT: labelNum= ud.pwlockout; break;
+ // case USERDEFS_RTSNAME: labelNum= ud.rtsname; break;
+ case USERDEFS_OVERHEAD_ON: labelNum = ud.overhead_on; break;
+ case USERDEFS_LAST_OVERHEAD: labelNum = ud.last_overhead; break;
+ case USERDEFS_SHOWWEAPONS: labelNum = ud.showweapons; break;
+ case USERDEFS_PAUSE_ON: labelNum = ud.pause_on; break;
+ case USERDEFS_FROM_BONUS: labelNum = ud.from_bonus; break;
+ case USERDEFS_CAMERASPRITE: labelNum = ud.camerasprite; break;
+ case USERDEFS_LAST_CAMSPRITE: labelNum = ud.last_camsprite; break;
+ case USERDEFS_LAST_LEVEL: labelNum = ud.last_level; break;
+ case USERDEFS_SECRETLEVEL: labelNum = ud.secretlevel; break;
+ case USERDEFS_CONST_VISIBILITY: labelNum = ud.const_visibility; break;
+ case USERDEFS_UW_FRAMERATE: labelNum = ud.uw_framerate; break;
+ case USERDEFS_CAMERA_TIME: labelNum = ud.camera_time; break;
+ case USERDEFS_FOLFVEL: labelNum = ud.folfvel; break;
+ case USERDEFS_FOLAVEL: labelNum = ud.folavel; break;
+ case USERDEFS_FOLX: labelNum = ud.folx; break;
+ case USERDEFS_FOLY: labelNum = ud.foly; break;
+ case USERDEFS_FOLA: labelNum = ud.fola; break;
+ case USERDEFS_RECCNT: labelNum = ud.reccnt; break;
+ case USERDEFS_ENTERED_NAME: labelNum = ud.entered_name; break;
+ case USERDEFS_SCREEN_TILTING: labelNum = ud.screen_tilting; break;
+ case USERDEFS_SHADOWS: labelNum = ud.shadows; break;
+ case USERDEFS_FTA_ON: labelNum = ud.fta_on; break;
+ case USERDEFS_EXECUTIONS: labelNum = ud.executions; break;
+ case USERDEFS_AUTO_RUN: labelNum = ud.auto_run; break;
+ case USERDEFS_COORDS: labelNum = ud.coords; break;
+ case USERDEFS_TICKRATE: labelNum = ud.tickrate; break;
+ case USERDEFS_M_COOP: labelNum = ud.m_coop; break;
+ case USERDEFS_COOP: labelNum = ud.coop; break;
+ case USERDEFS_SCREEN_SIZE: labelNum = ud.screen_size; break;
+ case USERDEFS_LOCKOUT: labelNum = ud.lockout; break;
+ case USERDEFS_CROSSHAIR: labelNum = ud.crosshair; break;
+ case USERDEFS_PLAYERAI: labelNum = ud.playerai; break;
+ case USERDEFS_RESPAWN_MONSTERS: labelNum = ud.respawn_monsters; break;
+ case USERDEFS_RESPAWN_ITEMS: labelNum = ud.respawn_items; break;
+ case USERDEFS_RESPAWN_INVENTORY: labelNum = ud.respawn_inventory; break;
+ case USERDEFS_RECSTAT: labelNum = ud.recstat; break;
+ case USERDEFS_MONSTERS_OFF: labelNum = ud.monsters_off; break;
+ case USERDEFS_BRIGHTNESS: labelNum = ud.brightness; break;
+ case USERDEFS_M_RESPAWN_ITEMS: labelNum = ud.m_respawn_items; break;
+ case USERDEFS_M_RESPAWN_MONSTERS: labelNum = ud.m_respawn_monsters; break;
+ case USERDEFS_M_RESPAWN_INVENTORY: labelNum = ud.m_respawn_inventory; break;
+ case USERDEFS_M_RECSTAT: labelNum = ud.m_recstat; break;
+ case USERDEFS_M_MONSTERS_OFF: labelNum = ud.m_monsters_off; break;
+ case USERDEFS_DETAIL: labelNum = ud.detail; break;
+ case USERDEFS_M_FFIRE: labelNum = ud.m_ffire; break;
+ case USERDEFS_FFIRE: labelNum = ud.ffire; break;
+ case USERDEFS_M_PLAYER_SKILL: labelNum = ud.m_player_skill; break;
+ case USERDEFS_M_LEVEL_NUMBER: labelNum = ud.m_level_number; break;
+ case USERDEFS_M_VOLUME_NUMBER: labelNum = ud.m_volume_number; break;
+ case USERDEFS_MULTIMODE: labelNum = ud.multimode; break;
+ case USERDEFS_PLAYER_SKILL: labelNum = ud.player_skill; break;
+ case USERDEFS_LEVEL_NUMBER: labelNum = ud.level_number; break;
+ case USERDEFS_VOLUME_NUMBER: labelNum = ud.volume_number; break;
+ case USERDEFS_M_MARKER: labelNum = ud.m_marker; break;
+ case USERDEFS_MARKER: labelNum = ud.marker; break;
+ case USERDEFS_MOUSEFLIP: labelNum = ud.mouseflip; break;
+ case USERDEFS_STATUSBARSCALE: labelNum = ud.statusbarscale; break;
+ case USERDEFS_DRAWWEAPON: labelNum = ud.drawweapon; break;
+ case USERDEFS_MOUSEAIMING: labelNum = ud.mouseaiming; break;
+ case USERDEFS_WEAPONSWITCH: labelNum = ud.weaponswitch; break;
+ case USERDEFS_DEMOCAMS: labelNum = ud.democams; break;
+ case USERDEFS_COLOR: labelNum = ud.color; break;
+ case USERDEFS_MSGDISPTIME: labelNum = ud.msgdisptime; break;
+ case USERDEFS_STATUSBARMODE: labelNum = ud.statusbarmode; break;
+ case USERDEFS_M_NOEXITS: labelNum = ud.m_noexits; break;
+ case USERDEFS_NOEXITS: labelNum = ud.noexits; break;
+ case USERDEFS_AUTOVOTE: labelNum = ud.autovote; break;
+ case USERDEFS_AUTOMSG: labelNum = ud.automsg; break;
+ case USERDEFS_IDPLAYERS: labelNum = ud.idplayers; break;
+ case USERDEFS_TEAM: labelNum = ud.team; break;
+ case USERDEFS_VIEWBOB: labelNum = ud.viewbob; break;
+ case USERDEFS_WEAPONSWAY: labelNum = ud.weaponsway; break;
+ case USERDEFS_ANGLEINTERPOLATION: labelNum = ud.angleinterpolation; break;
+ case USERDEFS_OBITUARIES: labelNum = ud.obituaries; break;
+ case USERDEFS_LEVELSTATS: labelNum = ud.levelstats; break;
+ case USERDEFS_CROSSHAIRSCALE: labelNum = ud.crosshairscale; break;
+ case USERDEFS_ALTHUD: labelNum = ud.althud; break;
+ case USERDEFS_DISPLAY_BONUS_SCREEN: labelNum = ud.display_bonus_screen; break;
+ case USERDEFS_SHOW_LEVEL_TEXT: labelNum = ud.show_level_text; break;
+ case USERDEFS_WEAPONSCALE: labelNum = ud.weaponscale; break;
+ case USERDEFS_TEXTSCALE: labelNum = ud.textscale; break;
+ case USERDEFS_RUNKEY_MODE: labelNum = ud.runkey_mode; break;
+ case USERDEFS_M_ORIGIN_X: labelNum = ud.m_origin.x; break;
+ case USERDEFS_M_ORIGIN_Y: labelNum = ud.m_origin.y; break;
+ case USERDEFS_PLAYERBEST: labelNum = ud.playerbest; break;
+ case USERDEFS_MUSICTOGGLE: labelNum = ud.config.MusicToggle; break;
+ case USERDEFS_USEVOXELS: labelNum = usevoxels; break;
case USERDEFS_USEHIGHTILE:
#ifdef USE_OPENGL
- lLabelID = usehightile;
+ labelNum = usehightile;
break;
#endif
case USERDEFS_USEMODELS:
#ifdef USE_OPENGL
- lLabelID = usemodels;
+ labelNum = usemodels;
#else
- lLabelID = 0;
+ labelNum = 0;
#endif
break;
- case USERDEFS_GAMETYPEFLAGS: lLabelID = GametypeFlags[ud.coop]; break;
- case USERDEFS_M_GAMETYPEFLAGS: lLabelID = GametypeFlags[ud.m_coop]; break;
- case USERDEFS_GLOBALFLAGS: lLabelID = globalflags; break;
- case USERDEFS_GLOBALGAMEFLAGS: lLabelID = duke3d_globalflags; break;
- case USERDEFS_VM_PLAYER: lLabelID = vm.g_p; break;
- case USERDEFS_VM_SPRITE: lLabelID = vm.g_i; break;
- case USERDEFS_VM_DISTANCE: lLabelID = vm.g_x; break;
- case USERDEFS_SOUNDTOGGLE: lLabelID = ud.config.SoundToggle; break;
- default: lLabelID = -1; break;
+ case USERDEFS_GAMETYPEFLAGS: labelNum = GametypeFlags[ud.coop]; break;
+ case USERDEFS_M_GAMETYPEFLAGS: labelNum = 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;
+ case USERDEFS_VM_SPRITE: labelNum = vm.spriteNum; break;
+ case USERDEFS_VM_DISTANCE: labelNum = vm.playerDist; break;
+ case USERDEFS_SOUNDTOGGLE: labelNum = ud.config.SoundToggle; break;
+ default: labelNum = -1; break;
}
- return lLabelID;
+ return labelNum;
}
-void __fastcall VM_SetUserdef(register int32_t const lLabelID, register int32_t const iSet)
+void __fastcall VM_SetUserdef(register int32_t const labelNum, register int32_t const iSet)
{
- switch (lLabelID)
+ switch (labelNum)
{
case USERDEFS_GOD: ud.god = iSet; break;
case USERDEFS_WARP_ON: ud.warp_on = iSet; break;
@@ -285,74 +285,74 @@ void __fastcall VM_SetUserdef(register int32_t const lLabelID, register int32_t
case USERDEFS_M_ORIGIN_Y: ud.m_origin.y = iSet; break;
case USERDEFS_GLOBALFLAGS: globalflags = iSet; break;
case USERDEFS_GLOBALGAMEFLAGS: duke3d_globalflags = iSet; break;
- case USERDEFS_VM_PLAYER: vm.g_p = iSet; vm.g_pp = g_player[iSet].ps; break;
- case USERDEFS_VM_SPRITE: vm.g_i = iSet; vm.g_sp = &sprite[iSet]; vm.g_t = &actor[iSet].t_data[0]; break;
- case USERDEFS_VM_DISTANCE: vm.g_x = iSet; break;
+ case USERDEFS_VM_PLAYER: vm.playerNum = iSet; vm.pPlayer = g_player[iSet].ps; break;
+ case USERDEFS_VM_SPRITE: vm.spriteNum = iSet; vm.pSprite = &sprite[iSet]; vm.pData = &actor[iSet].t_data[0]; break;
+ case USERDEFS_VM_DISTANCE: vm.playerDist = iSet; break;
default: break;
}
}
-int32_t __fastcall VM_GetActiveProjectile(register int32_t const iActor, register int32_t lLabelID)
+int32_t __fastcall VM_GetActiveProjectile(register int32_t const spriteNum, register int32_t labelNum)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iActor >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
CON_ERRPRINTF("tried to get %s on invalid target projectile (%d) %d %d\n",
- ProjectileLabels[lLabelID].name,iActor,vm.g_i,TrackerCast(vm.g_sp->picnum));
+ ProjectileLabels[labelNum].name,spriteNum,vm.spriteNum,TrackerCast(vm.pSprite->picnum));
return -1;
}
- projectile_t * const p = &SpriteProjectile[iActor];
+ projectile_t * const p = &SpriteProjectile[spriteNum];
- switch (lLabelID)
+ switch (labelNum)
{
- case PROJ_WORKSLIKE: lLabelID = p->workslike; break;
- case PROJ_SPAWNS: lLabelID = p->spawns; break;
- case PROJ_SXREPEAT: lLabelID = p->sxrepeat; break;
- case PROJ_SYREPEAT: lLabelID = p->syrepeat; break;
- case PROJ_SOUND: lLabelID = p->sound; break;
- case PROJ_ISOUND: lLabelID = p->isound; break;
- case PROJ_VEL: lLabelID = p->vel; break;
- case PROJ_EXTRA: lLabelID = p->extra; break;
- case PROJ_DECAL: lLabelID = p->decal; break;
- case PROJ_TRAIL: lLabelID = p->trail; break;
- case PROJ_TXREPEAT: lLabelID = p->txrepeat; break;
- case PROJ_TYREPEAT: lLabelID = p->tyrepeat; break;
- case PROJ_TOFFSET: lLabelID = p->toffset; break;
- case PROJ_TNUM: lLabelID = p->tnum; break;
- case PROJ_DROP: lLabelID = p->drop; break;
- case PROJ_CSTAT: lLabelID = p->cstat; break;
- case PROJ_CLIPDIST: lLabelID = p->clipdist; break;
- case PROJ_SHADE: lLabelID = p->shade; break;
- case PROJ_XREPEAT: lLabelID = p->xrepeat; break;
- case PROJ_YREPEAT: lLabelID = p->yrepeat; break;
- case PROJ_PAL: lLabelID = p->pal; break;
- case PROJ_EXTRA_RAND: lLabelID = p->extra_rand; break;
- case PROJ_HITRADIUS: lLabelID = p->hitradius; break;
- case PROJ_MOVECNT: lLabelID = p->movecnt; break;
- case PROJ_OFFSET: lLabelID = p->offset; break;
- case PROJ_BOUNCES: lLabelID = p->bounces; break;
- case PROJ_BSOUND: lLabelID = p->bsound; break;
- case PROJ_RANGE: lLabelID = p->range; break;
- case PROJ_FLASH_COLOR: lLabelID = p->flashcolor; break;
- case PROJ_USERDATA: lLabelID = p->userdata; break;
- default: lLabelID = -1; break;
+ case PROJ_WORKSLIKE: labelNum = p->workslike; break;
+ case PROJ_SPAWNS: labelNum = p->spawns; break;
+ case PROJ_SXREPEAT: labelNum = p->sxrepeat; break;
+ case PROJ_SYREPEAT: labelNum = p->syrepeat; break;
+ case PROJ_SOUND: labelNum = p->sound; break;
+ case PROJ_ISOUND: labelNum = p->isound; break;
+ case PROJ_VEL: labelNum = p->vel; break;
+ case PROJ_EXTRA: labelNum = p->extra; break;
+ case PROJ_DECAL: labelNum = p->decal; break;
+ case PROJ_TRAIL: labelNum = p->trail; break;
+ case PROJ_TXREPEAT: labelNum = p->txrepeat; break;
+ case PROJ_TYREPEAT: labelNum = p->tyrepeat; break;
+ case PROJ_TOFFSET: labelNum = p->toffset; break;
+ case PROJ_TNUM: labelNum = p->tnum; break;
+ case PROJ_DROP: labelNum = p->drop; break;
+ case PROJ_CSTAT: labelNum = p->cstat; break;
+ case PROJ_CLIPDIST: labelNum = p->clipdist; break;
+ case PROJ_SHADE: labelNum = p->shade; break;
+ case PROJ_XREPEAT: labelNum = p->xrepeat; break;
+ case PROJ_YREPEAT: labelNum = p->yrepeat; break;
+ case PROJ_PAL: labelNum = p->pal; break;
+ case PROJ_EXTRA_RAND: labelNum = p->extra_rand; break;
+ case PROJ_HITRADIUS: labelNum = p->hitradius; break;
+ case PROJ_MOVECNT: labelNum = p->movecnt; break;
+ case PROJ_OFFSET: labelNum = p->offset; break;
+ case PROJ_BOUNCES: labelNum = p->bounces; break;
+ case PROJ_BSOUND: labelNum = p->bsound; break;
+ case PROJ_RANGE: labelNum = p->range; break;
+ case PROJ_FLASH_COLOR: labelNum = p->flashcolor; break;
+ case PROJ_USERDATA: labelNum = p->userdata; break;
+ default: labelNum = -1; break;
}
- return lLabelID;
+ return labelNum;
}
-void __fastcall VM_SetActiveProjectile(register int32_t const iActor, register int32_t const lLabelID, register int32_t const iSet)
+void __fastcall VM_SetActiveProjectile(register int32_t const spriteNum, register int32_t const labelNum, register int32_t const iSet)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iActor >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
CON_ERRPRINTF("tried to set %s on invalid target projectile (%d) %d %d\n",
- ProjectileLabels[lLabelID].name,iActor,vm.g_i,TrackerCast(vm.g_sp->picnum));
+ ProjectileLabels[labelNum].name,spriteNum,vm.spriteNum,TrackerCast(vm.pSprite->picnum));
return;
}
- projectile_t * const p = &SpriteProjectile[iActor];
+ projectile_t * const p = &SpriteProjectile[spriteNum];
- switch (lLabelID)
+ switch (labelNum)
{
case PROJ_WORKSLIKE: p->workslike = iSet; break;
case PROJ_SPAWNS: p->spawns = iSet; break;
@@ -388,211 +388,211 @@ void __fastcall VM_SetActiveProjectile(register int32_t const iActor, register i
}
}
-int32_t __fastcall VM_GetPlayer(register int32_t const iPlayer, register int32_t lLabelID, register int32_t const lParm2)
+int32_t __fastcall VM_GetPlayer(register int32_t const playerNum, register int32_t labelNum, register int32_t const lParm2)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iPlayer >= (unsigned)playerswhenstarted))
+ if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted))
{
CON_ERRPRINTF("tried to get %s on invalid target player (%d) from spr %d\n",
- PlayerLabels[lLabelID].name,iPlayer,vm.g_i);
+ PlayerLabels[labelNum].name,playerNum,vm.spriteNum);
return -1;
}
- if (EDUKE32_PREDICT_FALSE(PlayerLabels[lLabelID].flags & LABEL_HASPARM2 &&
- (unsigned)lParm2 >= (unsigned)PlayerLabels[lLabelID].maxParm2))
+ if (EDUKE32_PREDICT_FALSE(PlayerLabels[labelNum].flags & LABEL_HASPARM2 &&
+ (unsigned)lParm2 >= (unsigned)PlayerLabels[labelNum].maxParm2))
{
CON_ERRPRINTF("tried to get invalid %s position %d on player (%d) from spr %d\n",
- PlayerLabels[lLabelID].name,lParm2,iPlayer,vm.g_i);
+ PlayerLabels[labelNum].name,lParm2,playerNum,vm.spriteNum);
return -1;
}
- DukePlayer_t *const ps = g_player[iPlayer].ps;
+ DukePlayer_t *const ps = g_player[playerNum].ps;
- switch (lLabelID)
+ switch (labelNum)
{
- case PLAYER_ZOOM: lLabelID = ps->zoom; break;
- case PLAYER_EXITX: lLabelID = ps->exitx; break;
- case PLAYER_EXITY: lLabelID = ps->exity; break;
- case PLAYER_LOOGIEX: lLabelID = ps->loogiex[lParm2]; break;
- case PLAYER_LOOGIEY: lLabelID = ps->loogiey[lParm2]; break;
- case PLAYER_NUMLOOGS: lLabelID = ps->numloogs; break;
- case PLAYER_LOOGCNT: lLabelID = ps->loogcnt; break;
- case PLAYER_POSX: lLabelID = ps->pos.x; break;
- case PLAYER_POSY: lLabelID = ps->pos.y; break;
- case PLAYER_POSZ: lLabelID = ps->pos.z; break;
- case PLAYER_HORIZ: lLabelID = ps->horiz; break;
- case PLAYER_OHORIZ: lLabelID = ps->ohoriz; break;
- case PLAYER_OHORIZOFF: lLabelID = ps->ohorizoff; break;
- case PLAYER_INVDISPTIME: lLabelID = ps->invdisptime; break;
- case PLAYER_BOBPOSX: lLabelID = ps->bobpos.x; break;
- case PLAYER_BOBPOSY: lLabelID = ps->bobpos.y; break;
- case PLAYER_OPOSX: lLabelID = ps->opos.x; break;
- case PLAYER_OPOSY: lLabelID = ps->opos.y; break;
- case PLAYER_OPOSZ: lLabelID = ps->opos.z; break;
- case PLAYER_PYOFF: lLabelID = ps->pyoff; break;
- case PLAYER_OPYOFF: lLabelID = ps->opyoff; break;
- case PLAYER_POSXV: lLabelID = ps->vel.x; break;
- case PLAYER_POSYV: lLabelID = ps->vel.y; break;
- case PLAYER_POSZV: lLabelID = ps->vel.z; break;
- case PLAYER_LAST_PISSED_TIME: lLabelID = ps->last_pissed_time; break;
- case PLAYER_TRUEFZ: lLabelID = ps->truefz; break;
- case PLAYER_TRUECZ: lLabelID = ps->truecz; break;
- case PLAYER_PLAYER_PAR: lLabelID = ps->player_par; break;
- case PLAYER_VISIBILITY: lLabelID = ps->visibility; break;
- case PLAYER_BOBCOUNTER: lLabelID = ps->bobcounter; break;
- case PLAYER_WEAPON_SWAY: lLabelID = ps->weapon_sway; break;
- case PLAYER_PALS_TIME: lLabelID = ps->pals.f; break;
- case PLAYER_RANDOMFLAMEX: lLabelID = ps->randomflamex; break;
- case PLAYER_CRACK_TIME: lLabelID = ps->crack_time; break;
- case PLAYER_AIM_MODE: lLabelID = ps->aim_mode; break;
- case PLAYER_ANG: lLabelID = ps->ang; break;
- case PLAYER_OANG: lLabelID = ps->oang; break;
- case PLAYER_ANGVEL: lLabelID = ps->angvel; break;
- case PLAYER_CURSECTNUM: lLabelID = ps->cursectnum; break;
- case PLAYER_LOOK_ANG: lLabelID = ps->look_ang; break;
- case PLAYER_LAST_EXTRA: lLabelID = ps->last_extra; break;
- case PLAYER_SUBWEAPON: lLabelID = ps->subweapon; break;
- case PLAYER_AMMO_AMOUNT: lLabelID = ps->ammo_amount[lParm2]; break;
- case PLAYER_WACKEDBYACTOR: lLabelID = ps->wackedbyactor; break;
- case PLAYER_FRAG: lLabelID = ps->frag; break;
- case PLAYER_FRAGGEDSELF: lLabelID = ps->fraggedself; break;
- case PLAYER_CURR_WEAPON: lLabelID = ps->curr_weapon; break;
- case PLAYER_LAST_WEAPON: lLabelID = ps->last_weapon; break;
- case PLAYER_TIPINCS: lLabelID = ps->tipincs; break;
- case PLAYER_HORIZOFF: lLabelID = ps->horizoff; break;
- case PLAYER_WANTWEAPONFIRE: lLabelID = ps->wantweaponfire; break;
- case PLAYER_HOLODUKE_AMOUNT: lLabelID = ps->inv_amount[GET_HOLODUKE]; break;
- case PLAYER_NEWOWNER: lLabelID = ps->newowner; break;
- case PLAYER_HURT_DELAY: lLabelID = ps->hurt_delay; break;
- case PLAYER_HBOMB_HOLD_DELAY: lLabelID = ps->hbomb_hold_delay; break;
- case PLAYER_JUMPING_COUNTER: lLabelID = ps->jumping_counter; break;
- case PLAYER_AIRLEFT: lLabelID = ps->airleft; break;
- case PLAYER_KNEE_INCS: lLabelID = ps->knee_incs; break;
- case PLAYER_ACCESS_INCS: lLabelID = ps->access_incs; break;
- case PLAYER_FTA: lLabelID = ps->fta; break;
- case PLAYER_FTQ: lLabelID = ps->ftq; break;
- case PLAYER_ACCESS_WALLNUM: lLabelID = ps->access_wallnum; break;
- case PLAYER_ACCESS_SPRITENUM: lLabelID = ps->access_spritenum; break;
- case PLAYER_KICKBACK_PIC: lLabelID = ps->kickback_pic; break;
- case PLAYER_GOT_ACCESS: lLabelID = ps->got_access; break;
- case PLAYER_WEAPON_ANG: lLabelID = ps->weapon_ang; break;
- case PLAYER_FIRSTAID_AMOUNT: lLabelID = ps->inv_amount[GET_FIRSTAID]; break;
- case PLAYER_SOMETHINGONPLAYER: lLabelID = ps->somethingonplayer; break;
- case PLAYER_ON_CRANE: lLabelID = ps->on_crane; break;
- case PLAYER_I: lLabelID = ps->i; break;
- case PLAYER_ONE_PARALLAX_SECTNUM: lLabelID = ps->one_parallax_sectnum; break;
- case PLAYER_OVER_SHOULDER_ON: lLabelID = ps->over_shoulder_on; break;
- case PLAYER_RANDOM_CLUB_FRAME: lLabelID = ps->random_club_frame; break;
- case PLAYER_FIST_INCS: lLabelID = ps->fist_incs; break;
- case PLAYER_ONE_EIGHTY_COUNT: lLabelID = ps->one_eighty_count; break;
- case PLAYER_CHEAT_PHASE: lLabelID = ps->cheat_phase; break;
- case PLAYER_DUMMYPLAYERSPRITE: lLabelID = ps->dummyplayersprite; break;
- case PLAYER_EXTRA_EXTRA8: lLabelID = ps->extra_extra8; break;
- case PLAYER_QUICK_KICK: lLabelID = ps->quick_kick; break;
- case PLAYER_HEAT_AMOUNT: lLabelID = ps->inv_amount[GET_HEATS]; break;
- case PLAYER_ACTORSQU: lLabelID = ps->actorsqu; break;
- case PLAYER_TIMEBEFOREEXIT: lLabelID = ps->timebeforeexit; break;
- case PLAYER_CUSTOMEXITSOUND: lLabelID = ps->customexitsound; break;
- case PLAYER_WEAPRECS: lLabelID = ps->weaprecs[lParm2]; break;
- case PLAYER_WEAPRECCNT: lLabelID = ps->weapreccnt; break;
- case PLAYER_INTERFACE_TOGGLE_FLAG: lLabelID = ps->interface_toggle_flag; break;
- case PLAYER_ROTSCRNANG: lLabelID = ps->rotscrnang; break;
- case PLAYER_DEAD_FLAG: lLabelID = ps->dead_flag; break;
- case PLAYER_SHOW_EMPTY_WEAPON: lLabelID = ps->show_empty_weapon; break;
- case PLAYER_SCUBA_AMOUNT: lLabelID = ps->inv_amount[GET_SCUBA]; break;
- case PLAYER_JETPACK_AMOUNT: lLabelID = ps->inv_amount[GET_JETPACK]; break;
- case PLAYER_STEROIDS_AMOUNT: lLabelID = ps->inv_amount[GET_STEROIDS]; break;
- case PLAYER_SHIELD_AMOUNT: lLabelID = ps->inv_amount[GET_SHIELD]; break;
- case PLAYER_HOLODUKE_ON: lLabelID = ps->holoduke_on; break;
- case PLAYER_PYCOUNT: lLabelID = ps->pycount; break;
- case PLAYER_WEAPON_POS: lLabelID = ps->weapon_pos; break;
- case PLAYER_FRAG_PS: lLabelID = ps->frag_ps; break;
- case PLAYER_TRANSPORTER_HOLD: lLabelID = ps->transporter_hold; break;
- case PLAYER_LAST_FULL_WEAPON: lLabelID = ps->last_full_weapon; break;
- case PLAYER_FOOTPRINTSHADE: lLabelID = ps->footprintshade; break;
- case PLAYER_BOOT_AMOUNT: lLabelID = ps->inv_amount[GET_BOOTS]; break;
- case PLAYER_SCREAM_VOICE: lLabelID = ps->scream_voice; break;
- case PLAYER_GM: lLabelID = ps->gm; break;
- case PLAYER_ON_WARPING_SECTOR: lLabelID = ps->on_warping_sector; break;
- case PLAYER_FOOTPRINTCOUNT: lLabelID = ps->footprintcount; break;
- case PLAYER_HBOMB_ON: lLabelID = ps->hbomb_on; break;
- case PLAYER_JUMPING_TOGGLE: lLabelID = ps->jumping_toggle; break;
- case PLAYER_RAPID_FIRE_HOLD: lLabelID = ps->rapid_fire_hold; break;
- case PLAYER_ON_GROUND: lLabelID = ps->on_ground; break;
- case PLAYER_INVEN_ICON: lLabelID = ps->inven_icon; break;
- case PLAYER_BUTTONPALETTE: lLabelID = ps->buttonpalette; break;
- case PLAYER_JETPACK_ON: lLabelID = ps->jetpack_on; break;
- case PLAYER_SPRITEBRIDGE: lLabelID = ps->spritebridge; break;
- case PLAYER_LASTRANDOMSPOT: lLabelID = ps->lastrandomspot; break;
- case PLAYER_SCUBA_ON: lLabelID = ps->scuba_on; break;
- case PLAYER_FOOTPRINTPAL: lLabelID = ps->footprintpal; break;
- case PLAYER_HEAT_ON: lLabelID = ps->heat_on; break;
- case PLAYER_HOLSTER_WEAPON: lLabelID = ps->holster_weapon; break;
- case PLAYER_FALLING_COUNTER: lLabelID = ps->falling_counter; break;
- case PLAYER_GOTWEAPON: lLabelID = (ps->gotweapon & (1 << lParm2)) != 0; break;
- case PLAYER_REFRESH_INVENTORY: lLabelID = ps->refresh_inventory; break;
- case PLAYER_PALETTE: lLabelID = ps->palette; break;
- case PLAYER_TOGGLE_KEY_FLAG: lLabelID = ps->toggle_key_flag; break;
- case PLAYER_KNUCKLE_INCS: lLabelID = ps->knuckle_incs; break;
- case PLAYER_WALKING_SND_TOGGLE: lLabelID = ps->walking_snd_toggle; break;
- case PLAYER_PALOOKUP: lLabelID = ps->palookup; break;
- case PLAYER_HARD_LANDING: lLabelID = ps->hard_landing; break;
- case PLAYER_MAX_SECRET_ROOMS: lLabelID = ps->max_secret_rooms; break;
- case PLAYER_SECRET_ROOMS: lLabelID = ps->secret_rooms; break;
+ case PLAYER_ZOOM: labelNum = ps->zoom; break;
+ case PLAYER_EXITX: labelNum = ps->exitx; break;
+ case PLAYER_EXITY: labelNum = ps->exity; break;
+ case PLAYER_LOOGIEX: labelNum = ps->loogiex[lParm2]; break;
+ case PLAYER_LOOGIEY: labelNum = ps->loogiey[lParm2]; break;
+ case PLAYER_NUMLOOGS: labelNum = ps->numloogs; break;
+ case PLAYER_LOOGCNT: labelNum = ps->loogcnt; break;
+ case PLAYER_POSX: labelNum = ps->pos.x; break;
+ case PLAYER_POSY: labelNum = ps->pos.y; break;
+ case PLAYER_POSZ: labelNum = ps->pos.z; break;
+ case PLAYER_HORIZ: labelNum = ps->horiz; break;
+ case PLAYER_OHORIZ: labelNum = ps->ohoriz; break;
+ case PLAYER_OHORIZOFF: labelNum = ps->ohorizoff; break;
+ case PLAYER_INVDISPTIME: labelNum = ps->invdisptime; break;
+ case PLAYER_BOBPOSX: labelNum = ps->bobpos.x; break;
+ case PLAYER_BOBPOSY: labelNum = ps->bobpos.y; break;
+ case PLAYER_OPOSX: labelNum = ps->opos.x; break;
+ case PLAYER_OPOSY: labelNum = ps->opos.y; break;
+ case PLAYER_OPOSZ: labelNum = ps->opos.z; break;
+ case PLAYER_PYOFF: labelNum = ps->pyoff; break;
+ case PLAYER_OPYOFF: labelNum = ps->opyoff; break;
+ case PLAYER_POSXV: labelNum = ps->vel.x; break;
+ case PLAYER_POSYV: labelNum = ps->vel.y; break;
+ case PLAYER_POSZV: labelNum = ps->vel.z; break;
+ case PLAYER_LAST_PISSED_TIME: labelNum = ps->last_pissed_time; break;
+ case PLAYER_TRUEFZ: labelNum = ps->truefz; break;
+ case PLAYER_TRUECZ: labelNum = ps->truecz; break;
+ case PLAYER_PLAYER_PAR: labelNum = ps->player_par; break;
+ case PLAYER_VISIBILITY: labelNum = ps->visibility; break;
+ case PLAYER_BOBCOUNTER: labelNum = ps->bobcounter; break;
+ case PLAYER_WEAPON_SWAY: labelNum = ps->weapon_sway; break;
+ case PLAYER_PALS_TIME: labelNum = ps->pals.f; break;
+ case PLAYER_RANDOMFLAMEX: labelNum = ps->randomflamex; break;
+ case PLAYER_CRACK_TIME: labelNum = ps->crack_time; break;
+ case PLAYER_AIM_MODE: labelNum = ps->aim_mode; break;
+ case PLAYER_ANG: labelNum = ps->ang; break;
+ case PLAYER_OANG: labelNum = ps->oang; break;
+ case PLAYER_ANGVEL: labelNum = ps->angvel; break;
+ case PLAYER_CURSECTNUM: labelNum = ps->cursectnum; break;
+ case PLAYER_LOOK_ANG: labelNum = ps->look_ang; break;
+ case PLAYER_LAST_EXTRA: labelNum = ps->last_extra; break;
+ case PLAYER_SUBWEAPON: labelNum = ps->subweapon; break;
+ case PLAYER_AMMO_AMOUNT: labelNum = ps->ammo_amount[lParm2]; break;
+ case PLAYER_WACKEDBYACTOR: labelNum = ps->wackedbyactor; break;
+ case PLAYER_FRAG: labelNum = ps->frag; break;
+ case PLAYER_FRAGGEDSELF: labelNum = ps->fraggedself; break;
+ case PLAYER_CURR_WEAPON: labelNum = ps->curr_weapon; break;
+ case PLAYER_LAST_WEAPON: labelNum = ps->last_weapon; break;
+ case PLAYER_TIPINCS: labelNum = ps->tipincs; break;
+ case PLAYER_HORIZOFF: labelNum = ps->horizoff; break;
+ case PLAYER_WANTWEAPONFIRE: labelNum = ps->wantweaponfire; break;
+ case PLAYER_HOLODUKE_AMOUNT: labelNum = ps->inv_amount[GET_HOLODUKE]; break;
+ case PLAYER_NEWOWNER: labelNum = ps->newowner; break;
+ case PLAYER_HURT_DELAY: labelNum = ps->hurt_delay; break;
+ case PLAYER_HBOMB_HOLD_DELAY: labelNum = ps->hbomb_hold_delay; break;
+ case PLAYER_JUMPING_COUNTER: labelNum = ps->jumping_counter; break;
+ case PLAYER_AIRLEFT: labelNum = ps->airleft; break;
+ case PLAYER_KNEE_INCS: labelNum = ps->knee_incs; break;
+ case PLAYER_ACCESS_INCS: labelNum = ps->access_incs; break;
+ case PLAYER_FTA: labelNum = ps->fta; break;
+ case PLAYER_FTQ: labelNum = ps->ftq; break;
+ case PLAYER_ACCESS_WALLNUM: labelNum = ps->access_wallnum; break;
+ case PLAYER_ACCESS_SPRITENUM: labelNum = ps->access_spritenum; break;
+ case PLAYER_KICKBACK_PIC: labelNum = ps->kickback_pic; break;
+ case PLAYER_GOT_ACCESS: labelNum = ps->got_access; break;
+ case PLAYER_WEAPON_ANG: labelNum = ps->weapon_ang; break;
+ case PLAYER_FIRSTAID_AMOUNT: labelNum = ps->inv_amount[GET_FIRSTAID]; break;
+ case PLAYER_SOMETHINGONPLAYER: labelNum = ps->somethingonplayer; break;
+ case PLAYER_ON_CRANE: labelNum = ps->on_crane; break;
+ case PLAYER_I: labelNum = ps->i; break;
+ case PLAYER_ONE_PARALLAX_SECTNUM: labelNum = ps->one_parallax_sectnum; break;
+ case PLAYER_OVER_SHOULDER_ON: labelNum = ps->over_shoulder_on; break;
+ case PLAYER_RANDOM_CLUB_FRAME: labelNum = ps->random_club_frame; break;
+ case PLAYER_FIST_INCS: labelNum = ps->fist_incs; break;
+ case PLAYER_ONE_EIGHTY_COUNT: labelNum = ps->one_eighty_count; break;
+ case PLAYER_CHEAT_PHASE: labelNum = ps->cheat_phase; break;
+ case PLAYER_DUMMYPLAYERSPRITE: labelNum = ps->dummyplayersprite; break;
+ case PLAYER_EXTRA_EXTRA8: labelNum = ps->extra_extra8; break;
+ case PLAYER_QUICK_KICK: labelNum = ps->quick_kick; break;
+ case PLAYER_HEAT_AMOUNT: labelNum = ps->inv_amount[GET_HEATS]; break;
+ case PLAYER_ACTORSQU: labelNum = ps->actorsqu; break;
+ case PLAYER_TIMEBEFOREEXIT: labelNum = ps->timebeforeexit; break;
+ case PLAYER_CUSTOMEXITSOUND: labelNum = ps->customexitsound; break;
+ case PLAYER_WEAPRECS: labelNum = ps->weaprecs[lParm2]; break;
+ case PLAYER_WEAPRECCNT: labelNum = ps->weapreccnt; break;
+ case PLAYER_INTERFACE_TOGGLE_FLAG: labelNum = ps->interface_toggle_flag; break;
+ case PLAYER_ROTSCRNANG: labelNum = ps->rotscrnang; break;
+ case PLAYER_DEAD_FLAG: labelNum = ps->dead_flag; break;
+ case PLAYER_SHOW_EMPTY_WEAPON: labelNum = ps->show_empty_weapon; break;
+ case PLAYER_SCUBA_AMOUNT: labelNum = ps->inv_amount[GET_SCUBA]; break;
+ case PLAYER_JETPACK_AMOUNT: labelNum = ps->inv_amount[GET_JETPACK]; break;
+ case PLAYER_STEROIDS_AMOUNT: labelNum = ps->inv_amount[GET_STEROIDS]; break;
+ case PLAYER_SHIELD_AMOUNT: labelNum = ps->inv_amount[GET_SHIELD]; break;
+ case PLAYER_HOLODUKE_ON: labelNum = ps->holoduke_on; break;
+ case PLAYER_PYCOUNT: labelNum = ps->pycount; break;
+ case PLAYER_WEAPON_POS: labelNum = ps->weapon_pos; break;
+ case PLAYER_FRAG_PS: labelNum = ps->frag_ps; break;
+ case PLAYER_TRANSPORTER_HOLD: labelNum = ps->transporter_hold; break;
+ case PLAYER_LAST_FULL_WEAPON: labelNum = ps->last_full_weapon; break;
+ case PLAYER_FOOTPRINTSHADE: labelNum = ps->footprintshade; break;
+ case PLAYER_BOOT_AMOUNT: labelNum = ps->inv_amount[GET_BOOTS]; break;
+ case PLAYER_SCREAM_VOICE: labelNum = ps->scream_voice; break;
+ case PLAYER_GM: labelNum = ps->gm; break;
+ case PLAYER_ON_WARPING_SECTOR: labelNum = ps->on_warping_sector; break;
+ case PLAYER_FOOTPRINTCOUNT: labelNum = ps->footprintcount; break;
+ case PLAYER_HBOMB_ON: labelNum = ps->hbomb_on; break;
+ case PLAYER_JUMPING_TOGGLE: labelNum = ps->jumping_toggle; break;
+ case PLAYER_RAPID_FIRE_HOLD: labelNum = ps->rapid_fire_hold; break;
+ case PLAYER_ON_GROUND: labelNum = ps->on_ground; break;
+ case PLAYER_INVEN_ICON: labelNum = ps->inven_icon; break;
+ case PLAYER_BUTTONPALETTE: labelNum = ps->buttonpalette; break;
+ case PLAYER_JETPACK_ON: labelNum = ps->jetpack_on; break;
+ case PLAYER_SPRITEBRIDGE: labelNum = ps->spritebridge; break;
+ case PLAYER_LASTRANDOMSPOT: labelNum = ps->lastrandomspot; break;
+ case PLAYER_SCUBA_ON: labelNum = ps->scuba_on; break;
+ case PLAYER_FOOTPRINTPAL: labelNum = ps->footprintpal; break;
+ case PLAYER_HEAT_ON: labelNum = ps->heat_on; break;
+ case PLAYER_HOLSTER_WEAPON: labelNum = ps->holster_weapon; break;
+ case PLAYER_FALLING_COUNTER: labelNum = ps->falling_counter; break;
+ case PLAYER_GOTWEAPON: labelNum = (ps->gotweapon & (1 << lParm2)) != 0; break;
+ case PLAYER_REFRESH_INVENTORY: labelNum = ps->refresh_inventory; break;
+ case PLAYER_PALETTE: labelNum = ps->palette; break;
+ case PLAYER_TOGGLE_KEY_FLAG: labelNum = ps->toggle_key_flag; break;
+ case PLAYER_KNUCKLE_INCS: labelNum = ps->knuckle_incs; break;
+ case PLAYER_WALKING_SND_TOGGLE: labelNum = ps->walking_snd_toggle; break;
+ case PLAYER_PALOOKUP: labelNum = ps->palookup; break;
+ case PLAYER_HARD_LANDING: labelNum = ps->hard_landing; break;
+ case PLAYER_MAX_SECRET_ROOMS: labelNum = ps->max_secret_rooms; break;
+ case PLAYER_SECRET_ROOMS: labelNum = ps->secret_rooms; break;
case PLAYER_PALS:
switch (lParm2)
{
- case 0: lLabelID = ps->pals.r; break;
- case 1: lLabelID = ps->pals.g; break;
- case 2: lLabelID = ps->pals.b; break;
- default: lLabelID = -1; break;
+ case 0: labelNum = ps->pals.r; break;
+ case 1: labelNum = ps->pals.g; break;
+ case 2: labelNum = ps->pals.b; break;
+ default: labelNum = -1; break;
}
break;
- case PLAYER_MAX_ACTORS_KILLED: lLabelID = ps->max_actors_killed; break;
- case PLAYER_ACTORS_KILLED: lLabelID = ps->actors_killed; break;
- case PLAYER_RETURN_TO_CENTER: lLabelID = ps->return_to_center; break;
- case PLAYER_RUNSPEED: lLabelID = ps->runspeed; break;
- case PLAYER_SBS: lLabelID = ps->sbs; break;
- case PLAYER_RELOADING: lLabelID = ps->reloading; break;
- case PLAYER_AUTO_AIM: lLabelID = ps->auto_aim; break;
- case PLAYER_MOVEMENT_LOCK: lLabelID = ps->movement_lock; break;
- case PLAYER_SOUND_PITCH: lLabelID = ps->sound_pitch; break;
- case PLAYER_WEAPONSWITCH: lLabelID = ps->weaponswitch; break;
- case PLAYER_TEAM: lLabelID = ps->team; break;
- case PLAYER_MAX_PLAYER_HEALTH: lLabelID = ps->max_player_health; break;
- case PLAYER_MAX_SHIELD_AMOUNT: lLabelID = ps->max_shield_amount; break;
- case PLAYER_MAX_AMMO_AMOUNT: lLabelID = ps->max_ammo_amount[lParm2]; break;
- case PLAYER_LAST_QUICK_KICK: lLabelID = ps->last_quick_kick; break;
- case PLAYER_AUTOSTEP: lLabelID = ps->autostep; break;
- case PLAYER_AUTOSTEP_SBW: lLabelID = ps->autostep_sbw; break;
- case PLAYER_HUDPAL: lLabelID = P_GetHudPal(ps); break;
- case PLAYER_INDEX: lLabelID = iPlayer; break;
- default: lLabelID = -1; break;
+ case PLAYER_MAX_ACTORS_KILLED: labelNum = ps->max_actors_killed; break;
+ case PLAYER_ACTORS_KILLED: labelNum = ps->actors_killed; break;
+ case PLAYER_RETURN_TO_CENTER: labelNum = ps->return_to_center; break;
+ case PLAYER_RUNSPEED: labelNum = ps->runspeed; break;
+ case PLAYER_SBS: labelNum = ps->sbs; break;
+ case PLAYER_RELOADING: labelNum = ps->reloading; break;
+ case PLAYER_AUTO_AIM: labelNum = ps->auto_aim; break;
+ case PLAYER_MOVEMENT_LOCK: labelNum = ps->movement_lock; break;
+ case PLAYER_SOUND_PITCH: labelNum = ps->sound_pitch; break;
+ case PLAYER_WEAPONSWITCH: labelNum = ps->weaponswitch; break;
+ case PLAYER_TEAM: labelNum = ps->team; break;
+ case PLAYER_MAX_PLAYER_HEALTH: labelNum = ps->max_player_health; break;
+ case PLAYER_MAX_SHIELD_AMOUNT: labelNum = ps->max_shield_amount; break;
+ case PLAYER_MAX_AMMO_AMOUNT: labelNum = ps->max_ammo_amount[lParm2]; break;
+ case PLAYER_LAST_QUICK_KICK: labelNum = ps->last_quick_kick; break;
+ case PLAYER_AUTOSTEP: labelNum = ps->autostep; break;
+ case PLAYER_AUTOSTEP_SBW: labelNum = ps->autostep_sbw; break;
+ case PLAYER_HUDPAL: labelNum = P_GetHudPal(ps); break;
+ case PLAYER_INDEX: labelNum = playerNum; break;
+ default: labelNum = -1; break;
}
- return lLabelID;
+ return labelNum;
}
-void __fastcall VM_SetPlayer(register int32_t const iPlayer, register int32_t const lLabelID, register int32_t const lParm2, register int32_t const iSet)
+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)iPlayer >= (unsigned)playerswhenstarted))
+ if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted))
{
CON_ERRPRINTF("tried to set %s on invalid target player (%d) from spr %d\n",
- PlayerLabels[lLabelID].name,iPlayer,vm.g_i);
+ PlayerLabels[labelNum].name,playerNum,vm.spriteNum);
return;
}
- if (EDUKE32_PREDICT_FALSE(PlayerLabels[lLabelID].flags & LABEL_HASPARM2 &&
- (unsigned)lParm2 >= (unsigned)PlayerLabels[lLabelID].maxParm2))
+ if (EDUKE32_PREDICT_FALSE(PlayerLabels[labelNum].flags & LABEL_HASPARM2 &&
+ (unsigned)lParm2 >= (unsigned)PlayerLabels[labelNum].maxParm2))
{
CON_ERRPRINTF("tried to set invalid %s position %d on player (%d) from spr %d\n",
- PlayerLabels[lLabelID].name,lParm2,iPlayer,vm.g_i);
+ PlayerLabels[labelNum].name,lParm2,playerNum,vm.spriteNum);
return;
}
- DukePlayer_t * const ps = g_player[iPlayer].ps;
+ DukePlayer_t * const ps = g_player[playerNum].ps;
- switch (lLabelID)
+ switch (labelNum)
{
case PLAYER_ZOOM: ps->zoom = iSet; break;
case PLAYER_EXITX: ps->exitx = iSet; break;
@@ -698,9 +698,9 @@ void __fastcall VM_SetPlayer(register int32_t const iPlayer, register int32_t co
case PLAYER_SCREAM_VOICE: ps->scream_voice = iSet; break;
case PLAYER_GM:
if (!(ps->gm & MODE_MENU) && (iSet & MODE_MENU))
- M_OpenMenu(iPlayer);
+ M_OpenMenu(playerNum);
else if ((ps->gm & MODE_MENU) && !(iSet & MODE_MENU))
- M_CloseMenu(iPlayer);
+ M_CloseMenu(playerNum);
ps->gm = iSet;
break;
case PLAYER_ON_WARPING_SECTOR: ps->on_warping_sector = iSet; break;
@@ -767,41 +767,41 @@ void __fastcall VM_SetPlayer(register int32_t const iPlayer, register int32_t co
}
}
-int32_t __fastcall VM_GetPlayerInput(register int32_t const iPlayer, register int32_t lLabelID)
+int32_t __fastcall VM_GetPlayerInput(register int32_t const playerNum, register int32_t labelNum)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iPlayer >= (unsigned)playerswhenstarted))
+ if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted))
{
- CON_ERRPRINTF("VM_GetPlayerInput: invalid target player (%d) %d\n", iPlayer,vm.g_i);
+ CON_ERRPRINTF("VM_GetPlayerInput: invalid target player (%d) %d\n", playerNum,vm.spriteNum);
return -1;
}
- input_t * const i = g_player[iPlayer].sync;
+ input_t * const i = g_player[playerNum].sync;
- switch (lLabelID)
+ switch (labelNum)
{
- case INPUT_AVEL: lLabelID = i->avel; break;
- case INPUT_HORZ: lLabelID = i->horz; break;
- case INPUT_FVEL: lLabelID = i->fvel; break;
- case INPUT_SVEL: lLabelID = i->svel; break;
- case INPUT_BITS: lLabelID = i->bits; break;
- case INPUT_EXTBITS: lLabelID = i->extbits; break;
- default: lLabelID = -1; break;
+ case INPUT_AVEL: labelNum = i->avel; break;
+ case INPUT_HORZ: labelNum = i->horz; break;
+ case INPUT_FVEL: labelNum = i->fvel; break;
+ case INPUT_SVEL: labelNum = i->svel; break;
+ case INPUT_BITS: labelNum = i->bits; break;
+ case INPUT_EXTBITS: labelNum = i->extbits; break;
+ default: labelNum = -1; break;
}
- return lLabelID;
+ return labelNum;
}
-void __fastcall VM_SetPlayerInput(register int32_t const iPlayer, register int32_t const lLabelID, register int32_t const iSet)
+void __fastcall VM_SetPlayerInput(register int32_t const playerNum, register int32_t const labelNum, register int32_t const iSet)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iPlayer >= (unsigned)playerswhenstarted))
+ if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)playerswhenstarted))
{
- CON_ERRPRINTF("VM_SetPlayerInput: invalid target player (%d) %d\n", iPlayer,vm.g_i);
+ CON_ERRPRINTF("VM_SetPlayerInput: invalid target player (%d) %d\n", playerNum,vm.spriteNum);
return;
}
- input_t * const i = g_player[iPlayer].sync;
+ input_t * const i = g_player[playerNum].sync;
- switch (lLabelID)
+ switch (labelNum)
{
case INPUT_AVEL: i->avel = iSet; break;
case INPUT_HORZ: i->horz = iSet; break;
@@ -815,54 +815,54 @@ void __fastcall VM_SetPlayerInput(register int32_t const iPlayer, register int32
-int32_t __fastcall VM_GetWall(register int32_t const iWall, register int32_t lLabelID)
+int32_t __fastcall VM_GetWall(register int32_t const wallNum, register int32_t labelNum)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iWall >= (unsigned)numwalls))
+ if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls))
{
- CON_ERRPRINTF("VM_GetWall: Invalid wall %d\n", iWall);
+ CON_ERRPRINTF("VM_GetWall: Invalid wall %d\n", wallNum);
return -1;
}
- walltype * const w = &wall[iWall];
+ walltype * const w = &wall[wallNum];
- switch (lLabelID)
+ switch (labelNum)
{
- case WALL_X: lLabelID = w->x; break;
- case WALL_Y: lLabelID = w->y; break;
- case WALL_POINT2: lLabelID = w->point2; break;
- case WALL_NEXTWALL: lLabelID = w->nextwall; break;
- case WALL_NEXTSECTOR: lLabelID = w->nextsector; break;
- case WALL_CSTAT: lLabelID = w->cstat; break;
- case WALL_PICNUM: lLabelID = w->picnum; break;
- case WALL_OVERPICNUM: lLabelID = w->overpicnum; break;
- case WALL_SHADE: lLabelID = w->shade; break;
- case WALL_PAL: lLabelID = w->pal; break;
- case WALL_XREPEAT: lLabelID = w->xrepeat; break;
- case WALL_YREPEAT: lLabelID = w->yrepeat; break;
- case WALL_XPANNING: lLabelID = w->xpanning; break;
- case WALL_YPANNING: lLabelID = w->ypanning; break;
- case WALL_LOTAG: lLabelID = (int16_t)w->lotag; break;
- case WALL_HITAG: lLabelID = (int16_t)w->hitag; break;
- case WALL_ULOTAG: lLabelID = w->lotag; break;
- case WALL_UHITAG: lLabelID = w->hitag; break;
- case WALL_EXTRA: lLabelID = w->extra; break;
- default: lLabelID = -1;
+ case WALL_X: labelNum = w->x; break;
+ case WALL_Y: labelNum = w->y; break;
+ case WALL_POINT2: labelNum = w->point2; break;
+ case WALL_NEXTWALL: labelNum = w->nextwall; break;
+ case WALL_NEXTSECTOR: labelNum = w->nextsector; break;
+ case WALL_CSTAT: labelNum = w->cstat; break;
+ case WALL_PICNUM: labelNum = w->picnum; break;
+ case WALL_OVERPICNUM: labelNum = w->overpicnum; break;
+ case WALL_SHADE: labelNum = w->shade; break;
+ case WALL_PAL: labelNum = w->pal; break;
+ case WALL_XREPEAT: labelNum = w->xrepeat; break;
+ case WALL_YREPEAT: labelNum = w->yrepeat; break;
+ case WALL_XPANNING: labelNum = w->xpanning; break;
+ case WALL_YPANNING: labelNum = w->ypanning; break;
+ case WALL_LOTAG: labelNum = (int16_t)w->lotag; break;
+ case WALL_HITAG: labelNum = (int16_t)w->hitag; break;
+ case WALL_ULOTAG: labelNum = w->lotag; break;
+ case WALL_UHITAG: labelNum = w->hitag; break;
+ case WALL_EXTRA: labelNum = w->extra; break;
+ default: labelNum = -1;
}
- return lLabelID;
+ return labelNum;
}
-void __fastcall VM_SetWall(register int32_t const iWall, register int32_t const lLabelID, register int32_t const iSet)
+void __fastcall VM_SetWall(register int32_t const wallNum, register int32_t const labelNum, register int32_t const iSet)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iWall >= (unsigned)numwalls))
+ if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls))
{
- CON_ERRPRINTF("VM_SetWall: Invalid wall %d\n", iWall);
+ CON_ERRPRINTF("VM_SetWall: Invalid wall %d\n", wallNum);
return;
}
- walltype * const w = &wall[iWall];
+ walltype * const w = &wall[wallNum];
- switch (lLabelID)
+ switch (labelNum)
{
case WALL_X: w->x = iSet; break;
case WALL_Y: w->y = iSet; break;
@@ -888,75 +888,75 @@ void __fastcall VM_SetWall(register int32_t const iWall, register int32_t const
return;
}
-int32_t __fastcall VM_GetSector(register int32_t const iSector, register int32_t lLabelID)
+int32_t __fastcall VM_GetSector(register int32_t const sectNum, register int32_t labelNum)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iSector >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("VM_GetSector: Invalid sector %d\n", iSector);
+ CON_ERRPRINTF("VM_GetSector: Invalid sector %d\n", sectNum);
return -1;
}
- sectortype * const s = §or[iSector];
+ sectortype * const s = §or[sectNum];
- switch (lLabelID)
+ switch (labelNum)
{
- case SECTOR_WALLPTR: lLabelID = s->wallptr; break;
- case SECTOR_WALLNUM: lLabelID = s->wallnum; break;
+ case SECTOR_WALLPTR: labelNum = s->wallptr; break;
+ case SECTOR_WALLNUM: labelNum = s->wallnum; break;
- case SECTOR_CEILINGZ: lLabelID = s->ceilingz; break;
- case SECTOR_CEILINGZVEL: lLabelID = (GetAnimationGoal(&s->ceilingz) == -1) ? 0 : s->extra; break;
- case SECTOR_CEILINGZGOAL: lLabelID = GetAnimationGoal(&s->ceilingz); break;
+ case SECTOR_CEILINGZ: labelNum = s->ceilingz; break;
+ case SECTOR_CEILINGZVEL: labelNum = (GetAnimationGoal(&s->ceilingz) == -1) ? 0 : s->extra; break;
+ case SECTOR_CEILINGZGOAL: labelNum = GetAnimationGoal(&s->ceilingz); break;
- case SECTOR_FLOORZ: lLabelID = s->floorz; break;
- case SECTOR_FLOORZVEL: lLabelID = (GetAnimationGoal(&s->floorz) == -1) ? 0 : s->extra; break;
- case SECTOR_FLOORZGOAL: lLabelID = GetAnimationGoal(&s->floorz); break;
+ case SECTOR_FLOORZ: labelNum = s->floorz; break;
+ case SECTOR_FLOORZVEL: labelNum = (GetAnimationGoal(&s->floorz) == -1) ? 0 : s->extra; break;
+ case SECTOR_FLOORZGOAL: labelNum = GetAnimationGoal(&s->floorz); break;
- case SECTOR_CEILINGSTAT: lLabelID = s->ceilingstat; break;
- case SECTOR_FLOORSTAT: lLabelID = s->floorstat; break;
- case SECTOR_CEILINGPICNUM: lLabelID = s->ceilingpicnum; break;
- case SECTOR_CEILINGSLOPE: lLabelID = s->ceilingheinum; break;
- case SECTOR_CEILINGSHADE: lLabelID = s->ceilingshade; break;
- case SECTOR_CEILINGPAL: lLabelID = s->ceilingpal; break;
- case SECTOR_CEILINGXPANNING: lLabelID = s->ceilingxpanning; break;
- case SECTOR_CEILINGYPANNING: lLabelID = s->ceilingypanning; break;
- case SECTOR_FLOORPICNUM: lLabelID = s->floorpicnum; break;
- case SECTOR_FLOORSLOPE: lLabelID = s->floorheinum; break;
- case SECTOR_FLOORSHADE: lLabelID = s->floorshade; break;
- case SECTOR_FLOORPAL: lLabelID = s->floorpal; break;
- case SECTOR_FLOORXPANNING: lLabelID = s->floorxpanning; break;
- case SECTOR_FLOORYPANNING: lLabelID = s->floorypanning; break;
- case SECTOR_VISIBILITY: lLabelID = s->visibility; break;
- case SECTOR_FOGPAL: lLabelID = s->fogpal; break;
- case SECTOR_LOTAG: lLabelID = (int16_t)s->lotag; break;
- case SECTOR_HITAG: lLabelID = (int16_t)s->hitag; break;
- case SECTOR_ULOTAG: lLabelID = s->lotag; break;
- case SECTOR_UHITAG: lLabelID = s->hitag; break;
- case SECTOR_EXTRA: lLabelID = s->extra; break;
+ case SECTOR_CEILINGSTAT: labelNum = s->ceilingstat; break;
+ case SECTOR_FLOORSTAT: labelNum = s->floorstat; break;
+ case SECTOR_CEILINGPICNUM: labelNum = s->ceilingpicnum; break;
+ case SECTOR_CEILINGSLOPE: labelNum = s->ceilingheinum; break;
+ case SECTOR_CEILINGSHADE: labelNum = s->ceilingshade; break;
+ case SECTOR_CEILINGPAL: labelNum = s->ceilingpal; break;
+ case SECTOR_CEILINGXPANNING: labelNum = s->ceilingxpanning; break;
+ case SECTOR_CEILINGYPANNING: labelNum = s->ceilingypanning; break;
+ case SECTOR_FLOORPICNUM: labelNum = s->floorpicnum; break;
+ case SECTOR_FLOORSLOPE: labelNum = s->floorheinum; break;
+ case SECTOR_FLOORSHADE: labelNum = s->floorshade; break;
+ case SECTOR_FLOORPAL: labelNum = s->floorpal; break;
+ case SECTOR_FLOORXPANNING: labelNum = s->floorxpanning; break;
+ case SECTOR_FLOORYPANNING: labelNum = s->floorypanning; break;
+ case SECTOR_VISIBILITY: labelNum = s->visibility; break;
+ case SECTOR_FOGPAL: labelNum = s->fogpal; break;
+ case SECTOR_LOTAG: labelNum = (int16_t)s->lotag; break;
+ case SECTOR_HITAG: labelNum = (int16_t)s->hitag; break;
+ case SECTOR_ULOTAG: labelNum = s->lotag; break;
+ case SECTOR_UHITAG: labelNum = s->hitag; break;
+ case SECTOR_EXTRA: labelNum = s->extra; break;
case SECTOR_CEILINGBUNCH:
case SECTOR_FLOORBUNCH:
#ifdef YAX_ENABLE
- lLabelID = yax_getbunch(iSector, lLabelID == SECTOR_FLOORBUNCH);
+ labelNum = yax_getbunch(sectNum, labelNum == SECTOR_FLOORBUNCH);
#else
- lLabelID = -1;
+ labelNum = -1;
#endif
break;
- default: lLabelID = -1; break;
+ default: labelNum = -1; break;
}
- return lLabelID;
+ return labelNum;
}
-void __fastcall VM_SetSector(register int32_t const iSector, register int32_t const lLabelID, register int32_t iSet)
+void __fastcall VM_SetSector(register int32_t const sectNum, register int32_t const labelNum, register int32_t iSet)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iSector >= (unsigned)numsectors))
+ if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
{
- CON_ERRPRINTF("VM_SetSector: Invalid sector %d\n", iSector);
+ CON_ERRPRINTF("VM_SetSector: Invalid sector %d\n", sectNum);
return;
}
- sectortype * const s = §or[iSector];
+ sectortype * const s = §or[sectNum];
- switch (lLabelID)
+ switch (labelNum)
{
case SECTOR_WALLPTR: s->wallptr = iSet; break;
case SECTOR_WALLNUM: s->wallnum = iSet; break;
@@ -965,14 +965,14 @@ void __fastcall VM_SetSector(register int32_t const iSector, register int32_t co
case SECTOR_CEILINGZVEL: s->extra = iSet;
if ((iSet = GetAnimationGoal(&s->ceilingz)) != -1)
case SECTOR_CEILINGZGOAL:
- SetAnimation(iSector, &s->ceilingz, iSet, s->extra);
+ SetAnimation(sectNum, &s->ceilingz, iSet, s->extra);
break;
case SECTOR_FLOORZ: s->floorz = iSet; break;
case SECTOR_FLOORZVEL: s->extra = iSet;
if ((iSet = GetAnimationGoal(&s->floorz)) != -1)
case SECTOR_FLOORZGOAL:
- SetAnimation(iSector, &s->floorz, iSet, s->extra);
+ SetAnimation(sectNum, &s->floorz, iSet, s->extra);
break;
case SECTOR_CEILINGSTAT: s->ceilingstat = iSet; break;
@@ -1002,172 +1002,172 @@ void __fastcall VM_SetSector(register int32_t const iSector, register int32_t co
}
}
-void __fastcall VM_SetSprite(register int32_t const iActor, register int32_t const lLabelID, register int32_t const lParm2, register int32_t const iSet)
+void __fastcall VM_SetSprite(register int32_t const spriteNum, register int32_t const labelNum, register int32_t const lParm2, register int32_t const iSet)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iActor >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
CON_ERRPRINTF("tried to set %s on invalid target sprite (%d) from spr %d pic %d\n",
- ActorLabels[lLabelID].name,iActor,vm.g_i,TrackerCast(vm.g_sp->picnum));
+ ActorLabels[labelNum].name,spriteNum,vm.spriteNum,TrackerCast(vm.pSprite->picnum));
return;
}
- if (EDUKE32_PREDICT_FALSE(ActorLabels[lLabelID].flags & LABEL_HASPARM2 && (unsigned)lParm2 >= (unsigned)ActorLabels[lLabelID].maxParm2))
+ if (EDUKE32_PREDICT_FALSE(ActorLabels[labelNum].flags & LABEL_HASPARM2 && (unsigned)lParm2 >= (unsigned)ActorLabels[labelNum].maxParm2))
{
CON_ERRPRINTF("tried to set invalid %s position %d on sprite (%d) from spr %d\n",
- ActorLabels[lLabelID].name,lParm2,iActor,vm.g_i);
+ ActorLabels[labelNum].name,lParm2,spriteNum,vm.spriteNum);
return;
}
- switch (lLabelID)
+ switch (labelNum)
{
- case ACTOR_X: sprite[iActor].x = iSet; break;
- case ACTOR_Y: sprite[iActor].y = iSet; break;
- case ACTOR_Z: sprite[iActor].z = iSet; break;
- case ACTOR_CSTAT: sprite[iActor].cstat = iSet; break;
- case ACTOR_PICNUM: sprite[iActor].picnum = iSet; break;
- case ACTOR_SHADE: sprite[iActor].shade = iSet; break;
- case ACTOR_PAL: sprite[iActor].pal = iSet; break;
- case ACTOR_CLIPDIST: sprite[iActor].clipdist = iSet; break;
- case ACTOR_DETAIL: sprite[iActor].blend = iSet; break;
- case ACTOR_XREPEAT: sprite[iActor].xrepeat = iSet; break;
- case ACTOR_YREPEAT: sprite[iActor].yrepeat = iSet; break;
- case ACTOR_XOFFSET: sprite[iActor].xoffset = iSet; break;
- case ACTOR_YOFFSET: sprite[iActor].yoffset = iSet; break;
- case ACTOR_SECTNUM: changespritesect(iActor, iSet); break;
- case ACTOR_STATNUM: changespritestat(iActor, iSet); break;
- case ACTOR_ANG: sprite[iActor].ang = iSet; break;
- case ACTOR_OWNER: sprite[iActor].owner = iSet; break;
- case ACTOR_XVEL: sprite[iActor].xvel = iSet; break;
- case ACTOR_YVEL: sprite[iActor].yvel = iSet; break;
- case ACTOR_ZVEL: sprite[iActor].zvel = iSet; break;
- case ACTOR_LOTAG: sprite[iActor].lotag = (int16_t)iSet; break;
- case ACTOR_HITAG: sprite[iActor].hitag = (int16_t)iSet; break;
- case ACTOR_ULOTAG: sprite[iActor].lotag = iSet; break;
- case ACTOR_UHITAG: sprite[iActor].hitag = iSet; break;
- case ACTOR_EXTRA: sprite[iActor].extra = iSet; break;
- case ACTOR_HTCGG: actor[iActor].cgg = iSet; break;
- case ACTOR_HTPICNUM: actor[iActor].picnum = iSet; break;
- case ACTOR_HTANG: actor[iActor].ang = iSet; break;
- case ACTOR_HTEXTRA: actor[iActor].extra = iSet; break;
- case ACTOR_HTOWNER: actor[iActor].owner = iSet; break;
- case ACTOR_HTMOVFLAG: actor[iActor].movflag = iSet; break;
- case ACTOR_HTTEMPANG: actor[iActor].tempang = iSet; break;
- case ACTOR_HTACTORSTAYPUT: actor[iActor].actorstayput = iSet; break;
- case ACTOR_HTDISPICNUM: actor[iActor].dispicnum = iSet; break;
- case ACTOR_HTTIMETOSLEEP: actor[iActor].timetosleep = iSet; break;
- case ACTOR_HTFLOORZ: actor[iActor].floorz = iSet; break;
- case ACTOR_HTCEILINGZ: actor[iActor].ceilingz = iSet; break;
- case ACTOR_HTLASTVX: actor[iActor].lastvx = iSet; break;
- case ACTOR_HTLASTVY: actor[iActor].lastvy = iSet; break;
- case ACTOR_HTBPOSX: actor[iActor].bpos.x = iSet; break;
- case ACTOR_HTBPOSY: actor[iActor].bpos.y = iSet; break;
- case ACTOR_HTBPOSZ: actor[iActor].bpos.z = iSet; break;
- case ACTOR_HTG_T: actor[iActor].t_data[lParm2] = iSet; break;
- case ACTOR_ANGOFF: spriteext[iActor].angoff = iSet; break;
- case ACTOR_PITCH: spriteext[iActor].pitch = iSet; break;
- case ACTOR_ROLL: spriteext[iActor].roll = iSet; break;
- case ACTOR_MDXOFF: spriteext[iActor].offset.x = iSet; break;
- case ACTOR_MDYOFF: spriteext[iActor].offset.y = iSet; break;
- case ACTOR_MDZOFF: spriteext[iActor].offset.z = iSet; break;
- case ACTOR_MDFLAGS: spriteext[iActor].flags = iSet; break;
- case ACTOR_XPANNING: spriteext[iActor].xpanning = iSet; break;
- case ACTOR_YPANNING: spriteext[iActor].ypanning = iSet; break;
- case ACTOR_HTFLAGS: actor[iActor].flags = iSet; break;
- case ACTOR_ALPHA: spriteext[iActor].alpha = (float)iSet * (1.f / 255.0f); break;
+ case ACTOR_X: sprite[spriteNum].x = iSet; break;
+ case ACTOR_Y: sprite[spriteNum].y = iSet; break;
+ case ACTOR_Z: sprite[spriteNum].z = iSet; break;
+ case ACTOR_CSTAT: sprite[spriteNum].cstat = iSet; break;
+ case ACTOR_PICNUM: sprite[spriteNum].picnum = iSet; break;
+ case ACTOR_SHADE: sprite[spriteNum].shade = iSet; break;
+ case ACTOR_PAL: sprite[spriteNum].pal = iSet; break;
+ case ACTOR_CLIPDIST: sprite[spriteNum].clipdist = iSet; break;
+ case ACTOR_DETAIL: sprite[spriteNum].blend = iSet; break;
+ case ACTOR_XREPEAT: sprite[spriteNum].xrepeat = iSet; break;
+ case ACTOR_YREPEAT: sprite[spriteNum].yrepeat = iSet; break;
+ case ACTOR_XOFFSET: sprite[spriteNum].xoffset = iSet; break;
+ case ACTOR_YOFFSET: sprite[spriteNum].yoffset = iSet; break;
+ case ACTOR_SECTNUM: changespritesect(spriteNum, iSet); break;
+ case ACTOR_STATNUM: changespritestat(spriteNum, iSet); break;
+ case ACTOR_ANG: sprite[spriteNum].ang = iSet; break;
+ case ACTOR_OWNER: sprite[spriteNum].owner = iSet; break;
+ case ACTOR_XVEL: sprite[spriteNum].xvel = iSet; break;
+ case ACTOR_YVEL: sprite[spriteNum].yvel = iSet; break;
+ case ACTOR_ZVEL: sprite[spriteNum].zvel = iSet; break;
+ case ACTOR_LOTAG: sprite[spriteNum].lotag = (int16_t)iSet; break;
+ case ACTOR_HITAG: sprite[spriteNum].hitag = (int16_t)iSet; break;
+ case ACTOR_ULOTAG: sprite[spriteNum].lotag = iSet; break;
+ case ACTOR_UHITAG: sprite[spriteNum].hitag = iSet; break;
+ case ACTOR_EXTRA: sprite[spriteNum].extra = iSet; break;
+ case ACTOR_HTCGG: actor[spriteNum].cgg = iSet; break;
+ case ACTOR_HTPICNUM: actor[spriteNum].picnum = iSet; break;
+ case ACTOR_HTANG: actor[spriteNum].ang = iSet; break;
+ case ACTOR_HTEXTRA: actor[spriteNum].extra = iSet; break;
+ case ACTOR_HTOWNER: actor[spriteNum].owner = iSet; break;
+ case ACTOR_HTMOVFLAG: actor[spriteNum].movflag = iSet; break;
+ case ACTOR_HTTEMPANG: actor[spriteNum].tempang = iSet; break;
+ case ACTOR_HTACTORSTAYPUT: actor[spriteNum].actorstayput = iSet; break;
+ case ACTOR_HTDISPICNUM: actor[spriteNum].dispicnum = iSet; break;
+ case ACTOR_HTTIMETOSLEEP: actor[spriteNum].timetosleep = iSet; break;
+ case ACTOR_HTFLOORZ: actor[spriteNum].floorz = iSet; break;
+ case ACTOR_HTCEILINGZ: actor[spriteNum].ceilingz = iSet; break;
+ case ACTOR_HTLASTVX: actor[spriteNum].lastvx = iSet; break;
+ case ACTOR_HTLASTVY: actor[spriteNum].lastvy = iSet; break;
+ case ACTOR_HTBPOSX: actor[spriteNum].bpos.x = iSet; break;
+ case ACTOR_HTBPOSY: actor[spriteNum].bpos.y = iSet; break;
+ case ACTOR_HTBPOSZ: actor[spriteNum].bpos.z = iSet; break;
+ case ACTOR_HTG_T: actor[spriteNum].t_data[lParm2] = iSet; break;
+ case ACTOR_ANGOFF: spriteext[spriteNum].angoff = iSet; break;
+ case ACTOR_PITCH: spriteext[spriteNum].pitch = iSet; break;
+ case ACTOR_ROLL: spriteext[spriteNum].roll = iSet; break;
+ case ACTOR_MDXOFF: spriteext[spriteNum].offset.x = iSet; break;
+ case ACTOR_MDYOFF: spriteext[spriteNum].offset.y = iSet; break;
+ case ACTOR_MDZOFF: spriteext[spriteNum].offset.z = iSet; break;
+ case ACTOR_MDFLAGS: spriteext[spriteNum].flags = iSet; break;
+ case ACTOR_XPANNING: spriteext[spriteNum].xpanning = iSet; break;
+ case ACTOR_YPANNING: spriteext[spriteNum].ypanning = iSet; break;
+ case ACTOR_HTFLAGS: actor[spriteNum].flags = iSet; break;
+ case ACTOR_ALPHA: spriteext[spriteNum].alpha = (float)iSet * (1.f / 255.0f); break;
default: break;
}
}
-int32_t __fastcall VM_GetSprite(register int32_t const iActor, register int32_t lLabelID, register int32_t const lParm2)
+int32_t __fastcall VM_GetSprite(register int32_t const spriteNum, register int32_t labelNum, register int32_t const lParm2)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iActor >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
CON_ERRPRINTF("tried to get %s on invalid target sprite (%d) from spr %d pic %d\n",
- ActorLabels[lLabelID].name,iActor,vm.g_i,TrackerCast(vm.g_sp->picnum));
+ ActorLabels[labelNum].name,spriteNum,vm.spriteNum,TrackerCast(vm.pSprite->picnum));
return -1;
}
- if (EDUKE32_PREDICT_FALSE(ActorLabels[lLabelID].flags & LABEL_HASPARM2 &&
- (unsigned)lParm2 >= (unsigned)ActorLabels[lLabelID].maxParm2))
+ if (EDUKE32_PREDICT_FALSE(ActorLabels[labelNum].flags & LABEL_HASPARM2 &&
+ (unsigned)lParm2 >= (unsigned)ActorLabels[labelNum].maxParm2))
{
CON_ERRPRINTF("tried to get invalid %s position %d on sprite (%d) from spr %d\n",
- ActorLabels[lLabelID].name,lParm2,iActor,vm.g_i);
+ ActorLabels[labelNum].name,lParm2,spriteNum,vm.spriteNum);
return -1;
}
- switch (lLabelID)
+ switch (labelNum)
{
- case ACTOR_X: lLabelID = sprite[iActor].x; break;
- case ACTOR_Y: lLabelID = sprite[iActor].y; break;
- case ACTOR_Z: lLabelID = sprite[iActor].z; break;
- case ACTOR_CSTAT: lLabelID = sprite[iActor].cstat; break;
- case ACTOR_PICNUM: lLabelID = sprite[iActor].picnum; break;
- case ACTOR_SHADE: lLabelID = sprite[iActor].shade; break;
- case ACTOR_PAL: lLabelID = sprite[iActor].pal; break;
- case ACTOR_CLIPDIST: lLabelID = sprite[iActor].clipdist; break;
- case ACTOR_DETAIL: lLabelID = sprite[iActor].blend; break;
- case ACTOR_XREPEAT: lLabelID = sprite[iActor].xrepeat; break;
- case ACTOR_YREPEAT: lLabelID = sprite[iActor].yrepeat; break;
- case ACTOR_XOFFSET: lLabelID = sprite[iActor].xoffset; break;
- case ACTOR_YOFFSET: lLabelID = sprite[iActor].yoffset; break;
- case ACTOR_SECTNUM: lLabelID = sprite[iActor].sectnum; break;
- case ACTOR_STATNUM: lLabelID = sprite[iActor].statnum; break;
- case ACTOR_ANG: lLabelID = sprite[iActor].ang; break;
- case ACTOR_OWNER: lLabelID = sprite[iActor].owner; break;
- case ACTOR_XVEL: lLabelID = sprite[iActor].xvel; break;
- case ACTOR_YVEL: lLabelID = sprite[iActor].yvel; break;
- case ACTOR_ZVEL: lLabelID = sprite[iActor].zvel; break;
- case ACTOR_LOTAG: lLabelID = (int16_t)sprite[iActor].lotag; break;
- case ACTOR_HITAG: lLabelID = (int16_t)sprite[iActor].hitag; break;
- case ACTOR_ULOTAG: lLabelID = sprite[iActor].lotag; break;
- case ACTOR_UHITAG: lLabelID = sprite[iActor].hitag; break;
- case ACTOR_EXTRA: lLabelID = sprite[iActor].extra; break;
- case ACTOR_HTCGG: lLabelID = actor[iActor].cgg; break;
- case ACTOR_HTPICNUM: lLabelID = actor[iActor].picnum; break;
- case ACTOR_HTANG: lLabelID = actor[iActor].ang; break;
- case ACTOR_HTEXTRA: lLabelID = actor[iActor].extra; break;
- case ACTOR_HTOWNER: lLabelID = actor[iActor].owner; break;
- case ACTOR_HTMOVFLAG: lLabelID = actor[iActor].movflag; break;
- case ACTOR_HTTEMPANG: lLabelID = actor[iActor].tempang; break;
- case ACTOR_HTACTORSTAYPUT: lLabelID = actor[iActor].actorstayput; break;
- case ACTOR_HTDISPICNUM: lLabelID = actor[iActor].dispicnum; break;
- case ACTOR_HTTIMETOSLEEP: lLabelID = actor[iActor].timetosleep; break;
- case ACTOR_HTFLOORZ: lLabelID = actor[iActor].floorz; break;
- case ACTOR_HTCEILINGZ: lLabelID = actor[iActor].ceilingz; break;
- case ACTOR_HTLASTVX: lLabelID = actor[iActor].lastvx; break;
- case ACTOR_HTLASTVY: lLabelID = actor[iActor].lastvy; break;
- case ACTOR_HTBPOSX: lLabelID = actor[iActor].bpos.x; break;
- case ACTOR_HTBPOSY: lLabelID = actor[iActor].bpos.y; break;
- case ACTOR_HTBPOSZ: lLabelID = actor[iActor].bpos.z; break;
- case ACTOR_HTG_T: lLabelID = actor[iActor].t_data[lParm2]; break;
- case ACTOR_ANGOFF: lLabelID = spriteext[iActor].angoff; break;
- case ACTOR_PITCH: lLabelID = spriteext[iActor].pitch; break;
- case ACTOR_ROLL: lLabelID = spriteext[iActor].roll; break;
- case ACTOR_MDXOFF: lLabelID = spriteext[iActor].offset.x; break;
- case ACTOR_MDYOFF: lLabelID = spriteext[iActor].offset.y; break;
- case ACTOR_MDZOFF: lLabelID = spriteext[iActor].offset.z; break;
- case ACTOR_MDFLAGS: lLabelID = spriteext[iActor].flags; break;
- case ACTOR_XPANNING: lLabelID = spriteext[iActor].xpanning; break;
- case ACTOR_YPANNING: lLabelID = spriteext[iActor].ypanning; break;
- case ACTOR_HTFLAGS: lLabelID = actor[iActor].flags; break;
- case ACTOR_ALPHA: lLabelID = (uint8_t)(spriteext[iActor].alpha * 255.0f); break;
- case ACTOR_ISVALID: lLabelID = (sprite[iActor].statnum != MAXSTATUS); break;
- default: lLabelID = -1; break;
+ case ACTOR_X: labelNum = sprite[spriteNum].x; break;
+ case ACTOR_Y: labelNum = sprite[spriteNum].y; break;
+ case ACTOR_Z: labelNum = sprite[spriteNum].z; break;
+ case ACTOR_CSTAT: labelNum = sprite[spriteNum].cstat; break;
+ case ACTOR_PICNUM: labelNum = sprite[spriteNum].picnum; break;
+ case ACTOR_SHADE: labelNum = sprite[spriteNum].shade; break;
+ case ACTOR_PAL: labelNum = sprite[spriteNum].pal; break;
+ case ACTOR_CLIPDIST: labelNum = sprite[spriteNum].clipdist; break;
+ case ACTOR_DETAIL: labelNum = sprite[spriteNum].blend; break;
+ case ACTOR_XREPEAT: labelNum = sprite[spriteNum].xrepeat; break;
+ case ACTOR_YREPEAT: labelNum = sprite[spriteNum].yrepeat; break;
+ case ACTOR_XOFFSET: labelNum = sprite[spriteNum].xoffset; break;
+ case ACTOR_YOFFSET: labelNum = sprite[spriteNum].yoffset; break;
+ case ACTOR_SECTNUM: labelNum = sprite[spriteNum].sectnum; break;
+ case ACTOR_STATNUM: labelNum = sprite[spriteNum].statnum; break;
+ case ACTOR_ANG: labelNum = sprite[spriteNum].ang; break;
+ case ACTOR_OWNER: labelNum = sprite[spriteNum].owner; break;
+ case ACTOR_XVEL: labelNum = sprite[spriteNum].xvel; break;
+ case ACTOR_YVEL: labelNum = sprite[spriteNum].yvel; break;
+ case ACTOR_ZVEL: labelNum = sprite[spriteNum].zvel; break;
+ case ACTOR_LOTAG: labelNum = (int16_t)sprite[spriteNum].lotag; break;
+ case ACTOR_HITAG: labelNum = (int16_t)sprite[spriteNum].hitag; break;
+ case ACTOR_ULOTAG: labelNum = sprite[spriteNum].lotag; break;
+ case ACTOR_UHITAG: labelNum = sprite[spriteNum].hitag; break;
+ case ACTOR_EXTRA: labelNum = sprite[spriteNum].extra; break;
+ case ACTOR_HTCGG: labelNum = actor[spriteNum].cgg; break;
+ case ACTOR_HTPICNUM: labelNum = actor[spriteNum].picnum; break;
+ case ACTOR_HTANG: labelNum = actor[spriteNum].ang; break;
+ case ACTOR_HTEXTRA: labelNum = actor[spriteNum].extra; break;
+ case ACTOR_HTOWNER: labelNum = actor[spriteNum].owner; break;
+ case ACTOR_HTMOVFLAG: labelNum = actor[spriteNum].movflag; break;
+ case ACTOR_HTTEMPANG: labelNum = actor[spriteNum].tempang; break;
+ case ACTOR_HTACTORSTAYPUT: labelNum = actor[spriteNum].actorstayput; break;
+ case ACTOR_HTDISPICNUM: labelNum = actor[spriteNum].dispicnum; break;
+ case ACTOR_HTTIMETOSLEEP: labelNum = actor[spriteNum].timetosleep; break;
+ case ACTOR_HTFLOORZ: labelNum = actor[spriteNum].floorz; break;
+ case ACTOR_HTCEILINGZ: labelNum = actor[spriteNum].ceilingz; break;
+ case ACTOR_HTLASTVX: labelNum = actor[spriteNum].lastvx; break;
+ case ACTOR_HTLASTVY: labelNum = actor[spriteNum].lastvy; break;
+ case ACTOR_HTBPOSX: labelNum = actor[spriteNum].bpos.x; break;
+ case ACTOR_HTBPOSY: labelNum = actor[spriteNum].bpos.y; break;
+ case ACTOR_HTBPOSZ: labelNum = actor[spriteNum].bpos.z; break;
+ case ACTOR_HTG_T: labelNum = actor[spriteNum].t_data[lParm2]; break;
+ case ACTOR_ANGOFF: labelNum = spriteext[spriteNum].angoff; break;
+ case ACTOR_PITCH: labelNum = spriteext[spriteNum].pitch; break;
+ case ACTOR_ROLL: labelNum = spriteext[spriteNum].roll; break;
+ case ACTOR_MDXOFF: labelNum = spriteext[spriteNum].offset.x; break;
+ case ACTOR_MDYOFF: labelNum = spriteext[spriteNum].offset.y; break;
+ case ACTOR_MDZOFF: labelNum = spriteext[spriteNum].offset.z; break;
+ case ACTOR_MDFLAGS: labelNum = spriteext[spriteNum].flags; break;
+ case ACTOR_XPANNING: labelNum = spriteext[spriteNum].xpanning; break;
+ case ACTOR_YPANNING: labelNum = spriteext[spriteNum].ypanning; break;
+ case ACTOR_HTFLAGS: labelNum = actor[spriteNum].flags; break;
+ case ACTOR_ALPHA: labelNum = (uint8_t)(spriteext[spriteNum].alpha * 255.0f); break;
+ case ACTOR_ISVALID: labelNum = (sprite[spriteNum].statnum != MAXSTATUS); break;
+ default: labelNum = -1; break;
}
- return lLabelID;
+ return labelNum;
}
-int32_t __fastcall VM_GetTsprite(register int32_t const iActor, register int32_t lLabelID)
+int32_t __fastcall VM_GetTsprite(register int32_t const spriteNum, register int32_t labelNum)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iActor >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
- CON_ERRPRINTF("VM_GetTsprite: invalid target sprite (%d) %d %d\n", iActor, vm.g_i, TrackerCast(vm.g_sp->picnum));
+ CON_ERRPRINTF("VM_GetTsprite: invalid target sprite (%d) %d %d\n", spriteNum, vm.spriteNum, TrackerCast(vm.pSprite->picnum));
return -1;
}
- uspritetype * const tspr = spriteext[iActor].tspr;
+ uspritetype * const tspr = spriteext[spriteNum].tspr;
if (EDUKE32_PREDICT_FALSE(!tspr))
{
@@ -1175,48 +1175,48 @@ int32_t __fastcall VM_GetTsprite(register int32_t const iActor, register int32_t
return -1;
}
- switch (lLabelID)
+ switch (labelNum)
{
- case ACTOR_X: lLabelID = tspr->x; break;
- case ACTOR_Y: lLabelID = tspr->y; break;
- case ACTOR_Z: lLabelID = tspr->z; break;
- case ACTOR_CSTAT: lLabelID = tspr->cstat; break;
- case ACTOR_PICNUM: lLabelID = tspr->picnum; break;
- case ACTOR_SHADE: lLabelID = tspr->shade; break;
- case ACTOR_PAL: lLabelID = tspr->pal; break;
- case ACTOR_CLIPDIST: lLabelID = tspr->clipdist; break;
- case ACTOR_DETAIL: lLabelID = tspr->blend; break;
- case ACTOR_XREPEAT: lLabelID = tspr->xrepeat; break;
- case ACTOR_YREPEAT: lLabelID = tspr->yrepeat; break;
- case ACTOR_XOFFSET: lLabelID = tspr->xoffset; break;
- case ACTOR_YOFFSET: lLabelID = tspr->yoffset; break;
- case ACTOR_SECTNUM: lLabelID = tspr->sectnum; break;
- case ACTOR_STATNUM: lLabelID = tspr->statnum; break;
- case ACTOR_ANG: lLabelID = tspr->ang; break;
- case ACTOR_OWNER: lLabelID = tspr->owner; break;
- case ACTOR_XVEL: lLabelID = tspr->xvel; break;
- case ACTOR_YVEL: lLabelID = tspr->yvel; break;
- case ACTOR_ZVEL: lLabelID = tspr->zvel; break;
- case ACTOR_LOTAG: lLabelID = (int16_t) tspr->lotag; break;
- case ACTOR_HITAG: lLabelID = (int16_t) tspr->hitag; break;
- case ACTOR_ULOTAG: lLabelID = tspr->lotag; break;
- case ACTOR_UHITAG: lLabelID = tspr->hitag; break;
- case ACTOR_EXTRA: lLabelID = tspr->extra; break;
- default: lLabelID = -1; break;
+ case ACTOR_X: labelNum = tspr->x; break;
+ case ACTOR_Y: labelNum = tspr->y; break;
+ case ACTOR_Z: labelNum = tspr->z; break;
+ case ACTOR_CSTAT: labelNum = tspr->cstat; break;
+ case ACTOR_PICNUM: labelNum = tspr->picnum; break;
+ case ACTOR_SHADE: labelNum = tspr->shade; break;
+ case ACTOR_PAL: labelNum = tspr->pal; break;
+ case ACTOR_CLIPDIST: labelNum = tspr->clipdist; break;
+ case ACTOR_DETAIL: labelNum = tspr->blend; break;
+ case ACTOR_XREPEAT: labelNum = tspr->xrepeat; break;
+ case ACTOR_YREPEAT: labelNum = tspr->yrepeat; break;
+ case ACTOR_XOFFSET: labelNum = tspr->xoffset; break;
+ case ACTOR_YOFFSET: labelNum = tspr->yoffset; break;
+ case ACTOR_SECTNUM: labelNum = tspr->sectnum; break;
+ case ACTOR_STATNUM: labelNum = tspr->statnum; break;
+ case ACTOR_ANG: labelNum = tspr->ang; break;
+ case ACTOR_OWNER: labelNum = tspr->owner; break;
+ case ACTOR_XVEL: labelNum = tspr->xvel; break;
+ case ACTOR_YVEL: labelNum = tspr->yvel; break;
+ case ACTOR_ZVEL: labelNum = tspr->zvel; break;
+ case ACTOR_LOTAG: labelNum = (int16_t) tspr->lotag; break;
+ case ACTOR_HITAG: labelNum = (int16_t) tspr->hitag; break;
+ case ACTOR_ULOTAG: labelNum = tspr->lotag; break;
+ case ACTOR_UHITAG: labelNum = tspr->hitag; break;
+ case ACTOR_EXTRA: labelNum = tspr->extra; break;
+ default: labelNum = -1; break;
}
- return lLabelID;
+ return labelNum;
}
-void __fastcall VM_SetTsprite(register int32_t const iActor, register int32_t const lLabelID, register int32_t const iSet)
+void __fastcall VM_SetTsprite(register int32_t const spriteNum, register int32_t const labelNum, register int32_t const iSet)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iActor >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{
- CON_ERRPRINTF("VM_SetTsprite: invalid target sprite (%d) %d %d\n", iActor, vm.g_i, TrackerCast(vm.g_sp->picnum));
+ CON_ERRPRINTF("VM_SetTsprite: invalid target sprite (%d) %d %d\n", spriteNum, vm.spriteNum, TrackerCast(vm.pSprite->picnum));
return;
}
- uspritetype * const tspr = spriteext[iActor].tspr;
+ uspritetype * const tspr = spriteext[spriteNum].tspr;
if (EDUKE32_PREDICT_FALSE(!tspr))
{
@@ -1224,7 +1224,7 @@ void __fastcall VM_SetTsprite(register int32_t const iActor, register int32_t co
return;
}
- switch (lLabelID)
+ switch (labelNum)
{
case ACTOR_X: tspr->x = iSet; break;
case ACTOR_Y: tspr->y = iSet; break;
@@ -1254,77 +1254,77 @@ void __fastcall VM_SetTsprite(register int32_t const iActor, register int32_t co
}
}
-int32_t __fastcall VM_GetProjectile(register int32_t const iTile, register int32_t lLabelID)
+int32_t __fastcall VM_GetProjectile(register int32_t const tileNum, register int32_t labelNum)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iTile >= MAXTILES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)tileNum >= MAXTILES))
{
- CON_ERRPRINTF("VM_GetProjectile: invalid projectile (%d)\n", iTile);
+ CON_ERRPRINTF("VM_GetProjectile: invalid projectile (%d)\n", tileNum);
return -1;
}
- projectile_t * const proj = g_tile[iTile].proj;
+ projectile_t * const proj = g_tile[tileNum].proj;
if (EDUKE32_PREDICT_FALSE(!proj))
{
- CON_ERRPRINTF("VM_GetProjectile: no projectile defined for tile %d\n", iTile);
+ CON_ERRPRINTF("VM_GetProjectile: no projectile defined for tile %d\n", tileNum);
return -1;
}
- switch (lLabelID)
+ switch (labelNum)
{
- case PROJ_WORKSLIKE: lLabelID = proj->workslike; break;
- case PROJ_SPAWNS: lLabelID = proj->spawns; break;
- case PROJ_SXREPEAT: lLabelID = proj->sxrepeat; break;
- case PROJ_SYREPEAT: lLabelID = proj->syrepeat; break;
- case PROJ_SOUND: lLabelID = proj->sound; break;
- case PROJ_ISOUND: lLabelID = proj->isound; break;
- case PROJ_VEL: lLabelID = proj->vel; break;
- case PROJ_EXTRA: lLabelID = proj->extra; break;
- case PROJ_DECAL: lLabelID = proj->decal; break;
- case PROJ_TRAIL: lLabelID = proj->trail; break;
- case PROJ_TXREPEAT: lLabelID = proj->txrepeat; break;
- case PROJ_TYREPEAT: lLabelID = proj->tyrepeat; break;
- case PROJ_TOFFSET: lLabelID = proj->toffset; break;
- case PROJ_TNUM: lLabelID = proj->tnum; break;
- case PROJ_DROP: lLabelID = proj->drop; break;
- case PROJ_CSTAT: lLabelID = proj->cstat; break;
- case PROJ_CLIPDIST: lLabelID = proj->clipdist; break;
- case PROJ_SHADE: lLabelID = proj->shade; break;
- case PROJ_XREPEAT: lLabelID = proj->xrepeat; break;
- case PROJ_YREPEAT: lLabelID = proj->yrepeat; break;
- case PROJ_PAL: lLabelID = proj->pal; break;
- case PROJ_EXTRA_RAND: lLabelID = proj->extra_rand; break;
- case PROJ_HITRADIUS: lLabelID = proj->hitradius; break;
- case PROJ_MOVECNT: lLabelID = proj->movecnt; break;
- case PROJ_OFFSET: lLabelID = proj->offset; break;
- case PROJ_BOUNCES: lLabelID = proj->bounces; break;
- case PROJ_BSOUND: lLabelID = proj->bsound; break;
- case PROJ_RANGE: lLabelID = proj->range; break;
- case PROJ_FLASH_COLOR: lLabelID = proj->flashcolor; break;
- case PROJ_USERDATA: lLabelID = proj->userdata; break;
- default: lLabelID = -1; break;
+ case PROJ_WORKSLIKE: labelNum = proj->workslike; break;
+ case PROJ_SPAWNS: labelNum = proj->spawns; break;
+ case PROJ_SXREPEAT: labelNum = proj->sxrepeat; break;
+ case PROJ_SYREPEAT: labelNum = proj->syrepeat; break;
+ case PROJ_SOUND: labelNum = proj->sound; break;
+ case PROJ_ISOUND: labelNum = proj->isound; break;
+ case PROJ_VEL: labelNum = proj->vel; break;
+ case PROJ_EXTRA: labelNum = proj->extra; break;
+ case PROJ_DECAL: labelNum = proj->decal; break;
+ case PROJ_TRAIL: labelNum = proj->trail; break;
+ case PROJ_TXREPEAT: labelNum = proj->txrepeat; break;
+ case PROJ_TYREPEAT: labelNum = proj->tyrepeat; break;
+ case PROJ_TOFFSET: labelNum = proj->toffset; break;
+ case PROJ_TNUM: labelNum = proj->tnum; break;
+ case PROJ_DROP: labelNum = proj->drop; break;
+ case PROJ_CSTAT: labelNum = proj->cstat; break;
+ case PROJ_CLIPDIST: labelNum = proj->clipdist; break;
+ case PROJ_SHADE: labelNum = proj->shade; break;
+ case PROJ_XREPEAT: labelNum = proj->xrepeat; break;
+ case PROJ_YREPEAT: labelNum = proj->yrepeat; break;
+ case PROJ_PAL: labelNum = proj->pal; break;
+ case PROJ_EXTRA_RAND: labelNum = proj->extra_rand; break;
+ case PROJ_HITRADIUS: labelNum = proj->hitradius; break;
+ case PROJ_MOVECNT: labelNum = proj->movecnt; break;
+ case PROJ_OFFSET: labelNum = proj->offset; break;
+ case PROJ_BOUNCES: labelNum = proj->bounces; break;
+ case PROJ_BSOUND: labelNum = proj->bsound; break;
+ case PROJ_RANGE: labelNum = proj->range; break;
+ case PROJ_FLASH_COLOR: labelNum = proj->flashcolor; break;
+ case PROJ_USERDATA: labelNum = proj->userdata; break;
+ default: labelNum = -1; break;
}
- return lLabelID;
+ return labelNum;
}
-void __fastcall VM_SetProjectile(register int32_t const iTile, register int32_t const lLabelID, register int32_t const iSet)
+void __fastcall VM_SetProjectile(register int32_t const tileNum, register int32_t const labelNum, register int32_t const iSet)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iTile >= MAXTILES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)tileNum >= MAXTILES))
{
- CON_ERRPRINTF("VM_SetProjectile: invalid projectile (%d)\n", iTile);
+ CON_ERRPRINTF("VM_SetProjectile: invalid projectile (%d)\n", tileNum);
return;
}
- projectile_t * const proj = g_tile[iTile].proj;
+ projectile_t * const proj = g_tile[tileNum].proj;
if (EDUKE32_PREDICT_FALSE(!proj))
{
- CON_ERRPRINTF("VM_SetProjectile: no projectile defined for tile %d\n", iTile);
+ CON_ERRPRINTF("VM_SetProjectile: no projectile defined for tile %d\n", tileNum);
return;
}
- switch (lLabelID)
+ switch (labelNum)
{
case PROJ_WORKSLIKE: proj->workslike = iSet; break;
case PROJ_SPAWNS: proj->spawns = iSet; break;
@@ -1359,49 +1359,49 @@ void __fastcall VM_SetProjectile(register int32_t const iTile, register int32_t
}
}
-int32_t __fastcall VM_GetTileData(register int32_t const iTile, register int32_t lLabelID)
+int32_t __fastcall VM_GetTileData(register int32_t const tileNum, register int32_t labelNum)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iTile >= MAXTILES))
+ if (EDUKE32_PREDICT_FALSE((unsigned)tileNum >= MAXTILES))
{
- CON_ERRPRINTF("VM_GetTileData: invalid tile (%d)\n", iTile);
+ CON_ERRPRINTF("VM_GetTileData: invalid tile (%d)\n", tileNum);
return -1;
}
- switch (lLabelID)
+ switch (labelNum)
{
- case TILEDATA_XSIZE: lLabelID = tilesiz[iTile].x; break;
- case TILEDATA_YSIZE: lLabelID = tilesiz[iTile].y; break;
+ case TILEDATA_XSIZE: labelNum = tilesiz[tileNum].x; break;
+ case TILEDATA_YSIZE: labelNum = tilesiz[tileNum].y; break;
- case TILEDATA_ANIMFRAMES: lLabelID = picanm[iTile].num; break;
- case TILEDATA_XOFFSET: lLabelID = picanm[iTile].xofs; break;
- case TILEDATA_YOFFSET: lLabelID = picanm[iTile].yofs; break;
- case TILEDATA_ANIMSPEED: lLabelID = picanm[iTile].sf & PICANM_ANIMSPEED_MASK; break;
- case TILEDATA_ANIMTYPE: lLabelID = (picanm[iTile].sf & PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT; break;
+ case TILEDATA_ANIMFRAMES: labelNum = picanm[tileNum].num; break;
+ case TILEDATA_XOFFSET: labelNum = picanm[tileNum].xofs; break;
+ case TILEDATA_YOFFSET: labelNum = picanm[tileNum].yofs; break;
+ case TILEDATA_ANIMSPEED: labelNum = picanm[tileNum].sf & PICANM_ANIMSPEED_MASK; break;
+ case TILEDATA_ANIMTYPE: labelNum = (picanm[tileNum].sf & PICANM_ANIMTYPE_MASK) >> PICANM_ANIMTYPE_SHIFT; break;
- case TILEDATA_GAMEFLAGS: lLabelID = g_tile[iTile].flags; break;
+ case TILEDATA_GAMEFLAGS: labelNum = g_tile[tileNum].flags; break;
- default: lLabelID = -1; break;
+ default: labelNum = -1; break;
}
- return lLabelID;
+ return labelNum;
}
-int32_t __fastcall VM_GetPalData(register int32_t const iPal, register int32_t lLabelID)
+int32_t __fastcall VM_GetPalData(register int32_t const palNum, register int32_t labelNum)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)iPal >= MAXPALOOKUPS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)palNum >= MAXPALOOKUPS))
{
- CON_ERRPRINTF("VM_GetPalData: invalid pal (%d)\n", iPal);
+ CON_ERRPRINTF("VM_GetPalData: invalid pal (%d)\n", palNum);
return -1;
}
- switch (lLabelID)
+ switch (labelNum)
{
- case PALDATA_NOFLOORPAL: lLabelID = g_noFloorPal[iPal]; break;
+ case PALDATA_NOFLOORPAL: labelNum = g_noFloorPal[palNum]; break;
- default: lLabelID = -1; break;
+ default: labelNum = -1; break;
}
- return lLabelID;
+ return labelNum;
}
#endif
diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c
index 17d204028..48c752a98 100644
--- a/polymer/eduke32/source/gamevars.c
+++ b/polymer/eduke32/source/gamevars.c
@@ -27,33 +27,33 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef LUNATIC
int32_t g_noResetVars;
-LUNATIC_CB void (*A_ResetVars)(int32_t iActor);
+LUNATIC_CB void (*A_ResetVars)(int32_t spriteNum);
#else
-gamevar_t aGameVars[MAXGAMEVARS];
+gamevar_t aGameVars[MAXGAMEVARS];
gamearray_t aGameArrays[MAXGAMEARRAYS];
-int32_t g_gameVarCount=0;
-int32_t g_gameArrayCount=0;
+int32_t g_gameVarCount = 0;
+int32_t g_gameArrayCount = 0;
// pointers to weapon gamevar data
-intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine
-intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire)
+intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine
+intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire)
intptr_t *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire
intptr_t *aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none)
intptr_t *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire.
-intptr_t *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon
-intptr_t *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots
+intptr_t *aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon
+intptr_t *aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots
intptr_t *aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item
-intptr_t *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn
+intptr_t *aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn
intptr_t *aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst')
intptr_t *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like
intptr_t *aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when weapon starts firing. zero for no sound
intptr_t *aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic)
intptr_t *aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time
intptr_t *aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID
-intptr_t *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed
-intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted
-intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound of weapon being selected
+intptr_t *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being removed
+intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted
+intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound of weapon being selected
intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Muzzle flash color
# include "gamestructures.c"
@@ -64,30 +64,30 @@ intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Muzzle flash color
// Returns: old g_gameVarCount | (g_gameArrayCount<<16).
static int32_t Gv_Free(void)
{
- for (int32_t i=0; i>16;
+ int gameVarCount = Gv_Free();
+ int const gameArrayCount = gameVarCount >> 16;
+ gameVarCount &= 65535;
// Now, only do work that Gv_Free() hasn't done.
- for (int32_t i=0; ivars[j])
- MapInfo[i].savedstate->vars[j] = (intptr_t *)Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t));
- if (kdfread(&MapInfo[i].savedstate->vars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, fil) != 1) goto corrupt;
+ 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;
}
- else if (aGameVars[j].nFlags & GAMEVAR_PERACTOR)
+ else if (aGameVars[j].flags & GAMEVAR_PERACTOR)
{
// if (!MapInfo[i].savedstate->vars[j])
- MapInfo[i].savedstate->vars[j] = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t));
- if (kdfread(&MapInfo[i].savedstate->vars[j][0],sizeof(intptr_t), MAXSPRITES, fil) != MAXSPRITES) goto corrupt;
+ 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;
}
}
}
@@ -233,20 +231,8 @@ int32_t Gv_ReadSave(int32_t fil, int32_t newbehav)
}
}
- if (!newbehav)
- {
- intptr_t l;
-
- if (kdfread(&l,sizeof(l),1,fil) != 1) goto corrupt;
- if (kdfread(g_szBuf,l,1,fil) != 1) goto corrupt;
- g_szBuf[l]=0;
- OSD_Printf("%s\n",g_szBuf);
- }
- else
- {
- if (kread(fil, tbuf, 12)!=12) goto corrupt;
- if (Bmemcmp(tbuf, "EOF: EDuke32", 12)) { OSD_Printf("EOF ERR\n"); return 2; }
- }
+ if (kread(kFile, tbuf, 12)!=12) goto corrupt;
+ if (Bmemcmp(tbuf, "EOF: EDuke32", 12)) { OSD_Printf("EOF ERR\n"); return 2; }
# if 0
{
@@ -266,15 +252,14 @@ corrupt:
return 1;
}
-void Gv_WriteSave(FILE *fil, int32_t newbehav)
+void Gv_WriteSave(FILE *fil)
{
char savedstate[MAXVOLUMES*MAXLEVELS];
Bmemset(&savedstate,0,sizeof(savedstate));
// AddLog("Saving Game Vars to File");
- if (newbehav)
- fwrite("BEG: EDuke32", 12, 1, fil);
+ fwrite("BEG: EDuke32", 12, 1, fil);
dfwrite(&g_gameVarCount,sizeof(g_gameVarCount),1,fil);
@@ -283,13 +268,13 @@ void Gv_WriteSave(FILE *fil, int32_t newbehav)
dfwrite(&(aGameVars[i]),sizeof(gamevar_t),1,fil);
dfwrite(aGameVars[i].szLabel,sizeof(uint8_t) * MAXVARLABEL, 1, fil);
- if (aGameVars[i].nFlags & GAMEVAR_PERPLAYER)
+ if (aGameVars[i].flags & GAMEVAR_PERPLAYER)
{
//Bsprintf(g_szBuf,"Writing value array for %s (%d)",aGameVars[i].szLabel,sizeof(int32_t) * MAXPLAYERS);
//AddLog(g_szBuf);
dfwrite(aGameVars[i].pValues,sizeof(intptr_t) * MAXPLAYERS, 1, fil);
}
- else if (aGameVars[i].nFlags & GAMEVAR_PERACTOR)
+ else if (aGameVars[i].flags & GAMEVAR_PERACTOR)
{
//Bsprintf(g_szBuf,"Writing value array for %s (%d)",aGameVars[i].szLabel,sizeof(int32_t) * MAXSPRITES);
//AddLog(g_szBuf);
@@ -301,7 +286,7 @@ void Gv_WriteSave(FILE *fil, int32_t newbehav)
for (int i=0; ivars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, fil);
+ dfwrite(&aMapInfo[i].savedstate->vars[j][0],sizeof(intptr_t) * MAXPLAYERS, 1, fil);
}
- else if (aGameVars[j].nFlags & GAMEVAR_PERACTOR)
+ else if (aGameVars[j].flags & GAMEVAR_PERACTOR)
{
- dfwrite(&MapInfo[i].savedstate->vars[j][0],sizeof(intptr_t), MAXSPRITES, fil);
+ dfwrite(&aMapInfo[i].savedstate->vars[j][0],sizeof(intptr_t), MAXSPRITES, fil);
}
}
}
- if (!newbehav)
- {
- intptr_t l;
-
- Bsprintf(g_szBuf,"EOF: EDuke32");
- l=Bstrlen(g_szBuf);
- dfwrite(&l,sizeof(l),1,fil);
- dfwrite(g_szBuf,l,1,fil);
- }
- else
- fwrite("EOF: EDuke32", 12, 1, fil);
+ fwrite("EOF: EDuke32", 12, 1, fil);
}
void Gv_DumpValues(void)
{
- int32_t i;
-
OSD_Printf("// Current Game Definitions\n\n");
- for (i=0; i=0 && !(aGameArrays[i].nFlags & GAMEARRAY_RESET)))
+ if (EDUKE32_PREDICT_FALSE(i >=0 && !(aGameArrays[i].flags & GAMEARRAY_RESET)))
{
// found it it's a duplicate in error
g_numCompilerWarnings++;
- if (aGameArrays[i].nFlags&GAMEARRAY_TYPE_MASK)
+ if (aGameArrays[i].flags&GAMEARRAY_TYPE_MASK)
{
C_ReportError(-1);
initprintf("ignored redefining system array `%s'.", pszLabel);
@@ -458,22 +431,22 @@ int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32
if (aGameArrays[i].szLabel != pszLabel)
Bstrcpy(aGameArrays[i].szLabel,pszLabel);
- if (!(dwFlags & GAMEARRAY_TYPE_MASK))
+ if (!(nFlags & GAMEARRAY_TYPE_MASK))
{
Baligned_free(aGameArrays[i].pValues);
- if (asize != 0)
+ if (arraySize != 0)
{
- aGameArrays[i].pValues = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, asize * GAR_ELTSZ);
- Bmemset(aGameArrays[i].pValues, 0, asize * GAR_ELTSZ);
+ aGameArrays[i].pValues = (intptr_t *)Xaligned_alloc(ACTOR_VAR_ALIGNMENT, arraySize * GAR_ELTSZ);
+ Bmemset(aGameArrays[i].pValues, 0, arraySize * GAR_ELTSZ);
}
else
aGameArrays[i].pValues = NULL;
}
else
- aGameArrays[i].pValues=(intptr_t *)arrayptr;
+ aGameArrays[i].pValues=(intptr_t *)pArray;
- aGameArrays[i].size=asize;
- aGameArrays[i].nFlags = dwFlags & ~GAMEARRAY_RESET;
+ aGameArrays[i].size = arraySize;
+ aGameArrays[i].flags = nFlags & ~GAMEARRAY_RESET;
g_gameArrayCount++;
hash_add(&h_arrays, aGameArrays[i].szLabel, i, 1);
@@ -483,8 +456,6 @@ int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32
int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags)
{
- int32_t i, j;
-
//Bsprintf(g_szBuf,"Gv_NewVar(%s, %d, %X)",pszLabel, lValue, dwFlags);
//AddLog(g_szBuf);
@@ -504,18 +475,18 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags)
return 0;
}
- i = hash_find(&h_gamevars,pszLabel);
+ int gV = hash_find(&h_gamevars,pszLabel);
- if (i >= 0 && !(aGameVars[i].nFlags & GAMEVAR_RESET))
+ if (gV >= 0 && !(aGameVars[gV].flags & GAMEVAR_RESET))
{
// found it...
- if (EDUKE32_PREDICT_FALSE(aGameVars[i].nFlags & (GAMEVAR_PTR_MASK)))
+ 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));
return 0;
}
- else if (EDUKE32_PREDICT_FALSE(!(aGameVars[i].nFlags & GAMEVAR_SYSTEM)))
+ else if (EDUKE32_PREDICT_FALSE(!(aGameVars[gV].flags & GAMEVAR_SYSTEM)))
{
// it's a duplicate in error
g_numCompilerWarnings++;
@@ -524,201 +495,201 @@ int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags)
}
}
- if (i == -1)
- i = g_gameVarCount;
+ if (gV == -1)
+ gV = g_gameVarCount;
// If it's a user gamevar...
- if ((aGameVars[i].nFlags & GAMEVAR_SYSTEM) == 0)
+ if ((aGameVars[gV].flags & GAMEVAR_SYSTEM) == 0)
{
// Allocate and set its label
- if (aGameVars[i].szLabel == NULL)
- aGameVars[i].szLabel = (char *)Xcalloc(MAXVARLABEL,sizeof(uint8_t));
+ if (aGameVars[gV].szLabel == NULL)
+ aGameVars[gV].szLabel = (char *)Xcalloc(MAXVARLABEL,sizeof(uint8_t));
- if (aGameVars[i].szLabel != pszLabel)
- Bstrcpy(aGameVars[i].szLabel,pszLabel);
+ if (aGameVars[gV].szLabel != pszLabel)
+ Bstrcpy(aGameVars[gV].szLabel,pszLabel);
// and the flags
- aGameVars[i].nFlags=dwFlags;
+ aGameVars[gV].flags=dwFlags;
// only free if per-{actor,player}
- if (aGameVars[i].nFlags & GAMEVAR_USER_MASK)
- ALIGNED_FREE_AND_NULL(aGameVars[i].pValues);
+ if (aGameVars[gV].flags & GAMEVAR_USER_MASK)
+ ALIGNED_FREE_AND_NULL(aGameVars[gV].pValues);
}
// if existing is system, they only get to change default value....
- aGameVars[i].nDefault = lValue;
- aGameVars[i].nFlags &= ~GAMEVAR_RESET;
+ aGameVars[gV].defaultValue = lValue;
+ aGameVars[gV].flags &= ~GAMEVAR_RESET;
- if (i == g_gameVarCount)
+ if (gV == g_gameVarCount)
{
// we're adding a new one.
- hash_add(&h_gamevars, aGameVars[i].szLabel, g_gameVarCount++, 0);
+ hash_add(&h_gamevars, aGameVars[gV].szLabel, g_gameVarCount++, 0);
}
// Set initial values. (Or, override values for system gamevars.)
- if (aGameVars[i].nFlags & GAMEVAR_PERPLAYER)
+ if (aGameVars[gV].flags & GAMEVAR_PERPLAYER)
{
- if (!aGameVars[i].pValues)
+ if (!aGameVars[gV].pValues)
{
- aGameVars[i].pValues = (intptr_t *) Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t));
- Bmemset(aGameVars[i].pValues, 0, MAXPLAYERS * sizeof(intptr_t));
+ aGameVars[gV].pValues = (intptr_t *) Xaligned_alloc(PLAYER_VAR_ALIGNMENT, MAXPLAYERS * sizeof(intptr_t));
+ Bmemset(aGameVars[gV].pValues, 0, MAXPLAYERS * sizeof(intptr_t));
}
- for (j=MAXPLAYERS-1; j>=0; j--)
- aGameVars[i].pValues[j]=lValue;
+ for (int j=MAXPLAYERS-1; j>=0; --j)
+ aGameVars[gV].pValues[j]=lValue;
}
- else if (aGameVars[i].nFlags & GAMEVAR_PERACTOR)
+ else if (aGameVars[gV].flags & GAMEVAR_PERACTOR)
{
- if (!aGameVars[i].pValues)
+ if (!aGameVars[gV].pValues)
{
- aGameVars[i].pValues = (intptr_t *) Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t));
- Bmemset(aGameVars[i].pValues, 0, MAXSPRITES * sizeof(intptr_t));
+ aGameVars[gV].pValues = (intptr_t *) Xaligned_alloc(ACTOR_VAR_ALIGNMENT, MAXSPRITES * sizeof(intptr_t));
+ Bmemset(aGameVars[gV].pValues, 0, MAXSPRITES * sizeof(intptr_t));
}
- for (j=MAXSPRITES-1; j>=0; j--)
- aGameVars[i].pValues[j]=lValue;
+ for (int j=MAXSPRITES-1; j>=0; --j)
+ aGameVars[gV].pValues[j]=lValue;
}
- else aGameVars[i].nValue = lValue;
+ else aGameVars[gV].global = lValue;
return 1;
}
static int32_t Gv_GetVarIndex(const char *szGameLabel)
{
- int32_t i = hash_find(&h_gamevars,szGameLabel);
+ int32_t gV = hash_find(&h_gamevars,szGameLabel);
- if (EDUKE32_PREDICT_FALSE(i == -1))
+ if (EDUKE32_PREDICT_FALSE(gV == -1))
{
OSD_Printf(OSD_ERROR "Gv_GetVarIndex(): INTERNAL ERROR: couldn't find gamevar %s!\n",szGameLabel);
return 0;
}
- return i;
+ return gV;
}
int32_t __fastcall Gv_GetGameArrayValue(int const id, int index)
{
- if (aGameArrays[id].nFlags & GAMEARRAY_STRIDE2)
+ if (aGameArrays[id].flags & GAMEARRAY_STRIDE2)
index <<= 1;
- int rv = -1;
+ int returnValue = -1;
- switch (aGameArrays[id].nFlags & GAMEARRAY_TYPE_MASK)
+ switch (aGameArrays[id].flags & GAMEARRAY_TYPE_MASK)
{
- case 0: rv = (aGameArrays[id].pValues)[index]; break;
- case GAMEARRAY_OFINT: rv = ((int32_t *)aGameArrays[id].pValues)[index]; break;
- case GAMEARRAY_OFSHORT: rv = ((int16_t *)aGameArrays[id].pValues)[index]; break;
- case GAMEARRAY_OFCHAR: rv = ((uint8_t *)aGameArrays[id].pValues)[index]; break;
+ case 0: returnValue = (aGameArrays[id].pValues)[index]; break;
+ case GAMEARRAY_OFINT: returnValue = ((int32_t *)aGameArrays[id].pValues)[index]; break;
+ case GAMEARRAY_OFSHORT: returnValue = ((int16_t *)aGameArrays[id].pValues)[index]; break;
+ case GAMEARRAY_OFCHAR: returnValue = ((uint8_t *)aGameArrays[id].pValues)[index]; break;
}
- return rv;
+ return returnValue;
}
-int32_t __fastcall Gv_GetVar(int nGameVar, int nSprite, int nPlayer)
+int32_t __fastcall Gv_GetVar(int gameVar, int spriteNum, int playerNum)
{
- if (nGameVar == g_iThisActorID)
- return nSprite;
+ if (gameVar == g_thisActorVarID)
+ return spriteNum;
- if (nGameVar == MAXGAMEVARS)
+ if (gameVar == MAXGAMEVARS)
return *insptr++;
- int nNegative = !!(nGameVar & (MAXGAMEVARS << 1));
+ int nNegative = !!(gameVar & (MAXGAMEVARS << 1));
- if (EDUKE32_PREDICT_FALSE((nGameVar & ~(MAXGAMEVARS << 1)) >= g_gameVarCount))
+ if (EDUKE32_PREDICT_FALSE((gameVar & ~(MAXGAMEVARS << 1)) >= g_gameVarCount))
goto nastyhacks;
- nGameVar &= (MAXGAMEVARS - 1);
+ gameVar &= (MAXGAMEVARS - 1);
int nReturn, nFlags;
- nFlags = aGameVars[nGameVar].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK);
+ nFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK);
if (nFlags == GAMEVAR_PERACTOR)
{
- if (EDUKE32_PREDICT_FALSE((unsigned) nSprite >= MAXSPRITES)) goto badindex;
- nReturn = aGameVars[nGameVar].pValues[nSprite];
+ if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum >= MAXSPRITES)) goto badindex;
+ nReturn = aGameVars[gameVar].pValues[spriteNum];
}
- else if (!nFlags) nReturn = aGameVars[nGameVar].nValue;
+ else if (!nFlags) nReturn = aGameVars[gameVar].global;
else if (nFlags == GAMEVAR_PERPLAYER)
{
- if (EDUKE32_PREDICT_FALSE((unsigned) nPlayer >= MAXPLAYERS))
+ if (EDUKE32_PREDICT_FALSE((unsigned) playerNum >= MAXPLAYERS))
{
- nSprite = nPlayer;
+ spriteNum = playerNum;
goto badindex;
}
- nReturn = aGameVars[nGameVar].pValues[nPlayer];
+ nReturn = aGameVars[gameVar].pValues[playerNum];
}
else switch (nFlags)
{
- case GAMEVAR_INTPTR: nReturn = *(int32_t *)aGameVars[nGameVar].nValue; break;
- case GAMEVAR_SHORTPTR: nReturn = *(int16_t *)aGameVars[nGameVar].nValue; break;
- case GAMEVAR_CHARPTR: nReturn = *(char *)aGameVars[nGameVar].nValue; break;
+ 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);
}
return (nReturn ^ -nNegative) + nNegative;
nastyhacks:
- if (nGameVar & (MAXGAMEVARS << 2)) // array
+ if (gameVar & (MAXGAMEVARS << 2)) // array
{
- nGameVar &= (MAXGAMEVARS - 1); // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1));
+ gameVar &= (MAXGAMEVARS - 1); // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1));
- int nArrayIndex = Gv_GetVar(*insptr++, nSprite, nPlayer);
+ int nArrayIndex = Gv_GetVar(*insptr++, spriteNum, playerNum);
- if (EDUKE32_PREDICT_FALSE((unsigned)nArrayIndex >= (unsigned)aGameArrays[nGameVar].size))
+ if (EDUKE32_PREDICT_FALSE((unsigned)nArrayIndex >= (unsigned)aGameArrays[gameVar].size))
{
- nSprite = nArrayIndex;
+ spriteNum = nArrayIndex;
goto badarrayindex;
}
- nReturn = Gv_GetGameArrayValue(nGameVar, nArrayIndex);
+ nReturn = Gv_GetGameArrayValue(gameVar, nArrayIndex);
}
- else if (nGameVar&(MAXGAMEVARS<<3)) // struct shortcut vars
+ else if (gameVar&(MAXGAMEVARS<<3)) // struct shortcut vars
{
- int nArrayIndexVar = *insptr++;
- int nArrayIndex = Gv_GetVar(nArrayIndexVar, nSprite, nPlayer);
+ int arrayIndexVar = *insptr++;
+ int arrayIndex = Gv_GetVar(arrayIndexVar, spriteNum, playerNum);
- nGameVar &= (MAXGAMEVARS - 1);
+ gameVar &= (MAXGAMEVARS - 1);
- switch (nGameVar - g_iStructVarIDs)
+ switch (gameVar - g_structVarIDs)
{
case STRUCT_SPRITE:
{
int const label = *insptr++;
- nArrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[label].flags & LABEL_HASPARM2)) ?
- Gv_GetVar(*insptr++, nSprite, nPlayer) : 0;
+ arrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[label].flags & LABEL_HASPARM2)) ?
+ Gv_GetVar(*insptr++, spriteNum, playerNum) : 0;
- if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXSPRITES))
{
- nSprite = nArrayIndex;
+ spriteNum = arrayIndex;
goto badindex;
}
- nReturn = VM_GetSprite(nArrayIndex, label, nArrayIndexVar);
+ nReturn = VM_GetSprite(arrayIndex, label, arrayIndexVar);
break;
}
case STRUCT_TSPR:
{
int const label = *insptr++;
- if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXSPRITES))
{
- nSprite = nArrayIndex;
+ spriteNum = arrayIndex;
goto badindex;
}
- nReturn = VM_GetTsprite(nArrayIndex, label);
+ nReturn = VM_GetTsprite(arrayIndex, label);
break;
}
case STRUCT_THISPROJECTILE:
{
int const label = *insptr++;
- if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES))
+ if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXSPRITES))
{
- nSprite = nArrayIndex;
+ spriteNum = arrayIndex;
goto badindex;
}
- nReturn = VM_GetActiveProjectile(nArrayIndex, label);
+ nReturn = VM_GetActiveProjectile(arrayIndex, label);
break;
}
@@ -726,26 +697,26 @@ nastyhacks:
{
int const label = *insptr++;
- if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXTILES))
+ if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXTILES))
{
- nSprite = nArrayIndex;
+ spriteNum = arrayIndex;
goto badindex;
}
- nReturn = VM_GetProjectile(nArrayIndex, label);
+ nReturn = VM_GetProjectile(arrayIndex, label);
break;
}
case STRUCT_TILEDATA:
{
int const label = *insptr++;
- if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXTILES))
+ if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXTILES))
{
- nSprite = nArrayIndex;
+ spriteNum = arrayIndex;
goto badindex;
}
- nReturn = VM_GetTileData(nArrayIndex, label);
+ nReturn = VM_GetTileData(arrayIndex, label);
break;
}
@@ -753,13 +724,13 @@ nastyhacks:
{
int const label = *insptr++;
- if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPALOOKUPS))
+ if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXPALOOKUPS))
{
- nSprite = nArrayIndex;
+ spriteNum = arrayIndex;
goto badindex;
}
- nReturn = VM_GetPalData(nArrayIndex, label);
+ nReturn = VM_GetPalData(arrayIndex, label);
break;
}
@@ -767,60 +738,60 @@ nastyhacks:
{
int const label = *insptr++;
- if (nArrayIndexVar == g_iThisActorID) nArrayIndex = vm.g_p;
+ if (arrayIndexVar == g_thisActorVarID) arrayIndex = vm.playerNum;
- nArrayIndexVar = (EDUKE32_PREDICT_FALSE(PlayerLabels[label].flags & LABEL_HASPARM2)) ?
- Gv_GetVar(*insptr++, nSprite, nPlayer) : 0;
+ arrayIndexVar = (EDUKE32_PREDICT_FALSE(PlayerLabels[label].flags & LABEL_HASPARM2)) ?
+ Gv_GetVar(*insptr++, spriteNum, playerNum) : 0;
- if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPLAYERS))
+ if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXPLAYERS))
{
- nSprite = nArrayIndex;
+ spriteNum = arrayIndex;
goto badindex;
}
- nReturn = VM_GetPlayer(nArrayIndex, label, nArrayIndexVar);
+ nReturn = VM_GetPlayer(arrayIndex, label, arrayIndexVar);
break;
}
case STRUCT_INPUT:
{
int const label = *insptr++;
- if (nArrayIndexVar == g_iThisActorID) nArrayIndex = vm.g_p;
+ if (arrayIndexVar == g_thisActorVarID) arrayIndex = vm.playerNum;
- if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPLAYERS))
+ if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXPLAYERS))
{
- nSprite = nArrayIndex;
+ spriteNum = arrayIndex;
goto badindex;
}
- nReturn = VM_GetPlayerInput(nArrayIndex, label);
+ nReturn = VM_GetPlayerInput(arrayIndex, label);
break;
}
case STRUCT_ACTORVAR:
case STRUCT_PLAYERVAR:
- nReturn = Gv_GetVar(*insptr++, nArrayIndex, nPlayer);
+ nReturn = Gv_GetVar(*insptr++, arrayIndex, playerNum);
break;
case STRUCT_SECTOR:
- if (nArrayIndexVar == g_iThisActorID) nArrayIndex = sprite[vm.g_i].sectnum;
- if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSECTORS))
+ if (arrayIndexVar == g_thisActorVarID) arrayIndex = sprite[vm.spriteNum].sectnum;
+ if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXSECTORS))
{
- nSprite = nArrayIndex;
+ spriteNum = arrayIndex;
insptr++;
goto badindex;
}
- nReturn = VM_GetSector(nArrayIndex, *insptr++);
+ nReturn = VM_GetSector(arrayIndex, *insptr++);
break;
case STRUCT_WALL:
- if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXWALLS))
+ if (EDUKE32_PREDICT_FALSE((unsigned) arrayIndex >= MAXWALLS))
{
- nSprite = nArrayIndex;
+ spriteNum = arrayIndex;
insptr++;
goto badindex;
}
- nReturn = VM_GetWall(nArrayIndex, *insptr++);
+ nReturn = VM_GetWall(arrayIndex, *insptr++);
break;
case STRUCT_USERDEF:
@@ -833,59 +804,59 @@ nastyhacks:
}
else
{
- CON_ERRPRINTF("Gv_GetVar(): invalid gamevar ID (%d)\n", nGameVar);
+ CON_ERRPRINTF("Gv_GetVar(): invalid gamevar ID (%d)\n", gameVar);
return -1;
}
return (nReturn ^ -nNegative) + nNegative;
badarrayindex:
- CON_ERRPRINTF("Gv_GetVar(): invalid array index (%s[%d])\n", aGameArrays[nGameVar].szLabel,nSprite);
+ CON_ERRPRINTF("Gv_GetVar(): invalid array index (%s[%d])\n", aGameArrays[gameVar].szLabel,spriteNum);
return -1;
badindex:
- CON_ERRPRINTF("Gv_GetVar(): invalid index %d for \"%s\"\n", nSprite, aGameVars[nGameVar].szLabel);
+ CON_ERRPRINTF("Gv_GetVar(): invalid index %d for \"%s\"\n", spriteNum, aGameVars[gameVar].szLabel);
return -1;
}
-void __fastcall Gv_SetVar(int const nGameVar, int32_t const nValue, int const nSprite, int const nPlayer)
+void __fastcall Gv_SetVar(int const gameVar, int32_t const nValue, int const spriteNum, int const playerNum)
{
- int const nFlags = aGameVars[nGameVar].nFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
+ int const nFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
- if (EDUKE32_PREDICT_FALSE((unsigned)nGameVar >= (unsigned)g_gameVarCount)) goto badvarid;
+ if (EDUKE32_PREDICT_FALSE((unsigned)gameVar >= (unsigned)g_gameVarCount)) goto badvarid;
- if (!nFlags) aGameVars[nGameVar].nValue=nValue;
+ if (!nFlags) aGameVars[gameVar].global=nValue;
else if (nFlags == GAMEVAR_PERPLAYER)
{
- if (EDUKE32_PREDICT_FALSE((unsigned) nPlayer > MAXPLAYERS-1)) goto badindex;
+ if (EDUKE32_PREDICT_FALSE((unsigned) playerNum > MAXPLAYERS-1)) goto badindex;
// for the current player
- aGameVars[nGameVar].pValues[nPlayer]=nValue;
+ aGameVars[gameVar].pValues[playerNum]=nValue;
}
else if (nFlags == GAMEVAR_PERACTOR)
{
- if (EDUKE32_PREDICT_FALSE((unsigned) nSprite > MAXSPRITES-1)) goto badindex;
- aGameVars[nGameVar].pValues[nSprite]=nValue;
+ if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum > MAXSPRITES-1)) goto badindex;
+ aGameVars[gameVar].pValues[spriteNum]=nValue;
}
else
{
switch (nFlags)
{
- case GAMEVAR_INTPTR: *((int32_t *)aGameVars[nGameVar].nValue) = (int32_t)nValue; break;
- case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[nGameVar].nValue) = (int16_t)nValue; break;
- case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[nGameVar].nValue) = (uint8_t)nValue; break;
+ 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;
}
}
return;
badvarid:
CON_ERRPRINTF("Gv_SetVar(): invalid gamevar (%d) from sprite %d (%d), player %d\n",
- nGameVar,vm.g_i,TrackerCast(sprite[vm.g_i].picnum),vm.g_p);
+ gameVar,vm.spriteNum,TrackerCast(sprite[vm.spriteNum].picnum),vm.playerNum);
return;
badindex:
CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s from sprite %d, player %d\n",
- aGameVars[nGameVar].nFlags & GAMEVAR_PERACTOR ? nSprite : nPlayer,
- aGameVars[nGameVar].szLabel,vm.g_i,vm.g_p);
+ aGameVars[gameVar].flags & GAMEVAR_PERACTOR ? spriteNum : playerNum,
+ aGameVars[gameVar].szLabel,vm.spriteNum,vm.playerNum);
}
enum
@@ -911,176 +882,176 @@ static const char *gvxerrs[] = {
"Gv_GetVarX(): invalid pal ID",
};
-int32_t __fastcall Gv_GetSpecialVarX(int nGameVar)
+int32_t __fastcall Gv_GetSpecialVarX(int gameVar)
{
int nReturn = -1;
- if (nGameVar & (MAXGAMEVARS << 2)) // array
+ if (gameVar & (MAXGAMEVARS << 2)) // array
{
int const nArrayIndex = Gv_GetVarX(*insptr++);
- nGameVar &= (MAXGAMEVARS - 1); // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1));
+ gameVar &= (MAXGAMEVARS - 1); // ~((MAXGAMEVARS<<2)|(MAXGAMEVARS<<1));
int const nArraySize =
- (aGameArrays[nGameVar].nFlags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[nGameVar].size) : aGameArrays[nGameVar].size;
+ (aGameArrays[gameVar].flags & GAMEARRAY_VARSIZE) ? Gv_GetVarX(aGameArrays[gameVar].size) : aGameArrays[gameVar].size;
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= (unsigned) nArraySize))
{
- CON_ERRPRINTF("%s %s[%d]\n", gvxerrs[GVX_BADINDEX], aGameArrays[nGameVar].szLabel, nArrayIndex);
+ CON_ERRPRINTF("%s %s[%d]\n", gvxerrs[GVX_BADINDEX], aGameArrays[gameVar].szLabel, nArrayIndex);
return -1;
}
- nReturn = Gv_GetGameArrayValue(nGameVar, nArrayIndex);
+ nReturn = Gv_GetGameArrayValue(gameVar, nArrayIndex);
}
- else if (nGameVar & (MAXGAMEVARS << 3)) // struct shortcut vars
+ else if (gameVar & (MAXGAMEVARS << 3)) // struct shortcut vars
{
int nArrayIndexVar = *insptr++;
int nArrayIndex = Gv_GetVarX(nArrayIndexVar);
- switch ((nGameVar & (MAXGAMEVARS - 1)) - g_iStructVarIDs)
+ switch ((gameVar & (MAXGAMEVARS - 1)) - g_structVarIDs)
{
case STRUCT_SPRITE:
{
- int const nLabel = *insptr++;
+ int const labelNum = *insptr++;
- nArrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[nLabel].flags & LABEL_HASPARM2)) ?
+ nArrayIndexVar = (EDUKE32_PREDICT_FALSE(ActorLabels[labelNum].flags & LABEL_HASPARM2)) ?
Gv_GetVarX(*insptr++) : 0;
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES))
{
- nGameVar = nArrayIndex;
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], nGameVar);
+ gameVar = nArrayIndex;
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], gameVar);
return -1;
}
- nReturn = VM_GetSprite(nArrayIndex, nLabel, nArrayIndexVar);
+ nReturn = VM_GetSprite(nArrayIndex, labelNum, nArrayIndexVar);
break;
}
case STRUCT_TSPR:
{
- int const nLabel = *insptr++;
+ int const labelNum = *insptr++;
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES))
{
- nGameVar = nArrayIndex;
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], nGameVar);
+ gameVar = nArrayIndex;
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], gameVar);
return -1;
}
- nReturn = VM_GetTsprite(nArrayIndex, nLabel);
+ nReturn = VM_GetTsprite(nArrayIndex, labelNum);
break;
}
case STRUCT_THISPROJECTILE:
{
- int const nLabel = *insptr++;
+ int const labelNum = *insptr++;
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSPRITES))
{
- nGameVar = nArrayIndex;
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], nGameVar);
+ gameVar = nArrayIndex;
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSPRITE], gameVar);
return -1;
}
- nReturn = VM_GetActiveProjectile(nArrayIndex, nLabel);
+ nReturn = VM_GetActiveProjectile(nArrayIndex, labelNum);
break;
}
case STRUCT_PROJECTILE:
{
- int const nLabel = *insptr++;
+ int const labelNum = *insptr++;
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXTILES))
{
- nGameVar = nArrayIndex;
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], nGameVar);
+ gameVar = nArrayIndex;
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], gameVar);
return -1;
}
- nReturn = VM_GetProjectile(nArrayIndex, nLabel);
+ nReturn = VM_GetProjectile(nArrayIndex, labelNum);
break;
}
case STRUCT_TILEDATA:
{
- int const nLabel = *insptr++;
+ int const labelNum = *insptr++;
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXTILES))
{
- nGameVar = nArrayIndex;
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], nGameVar);
+ gameVar = nArrayIndex;
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADTILE], gameVar);
return -1;
}
- nReturn = VM_GetTileData(nArrayIndex, nLabel);
+ nReturn = VM_GetTileData(nArrayIndex, labelNum);
break;
}
case STRUCT_PALDATA:
{
- int const nLabel = *insptr++;
+ int const labelNum = *insptr++;
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPALOOKUPS))
{
- nGameVar = nArrayIndex;
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPAL], nGameVar);
+ gameVar = nArrayIndex;
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPAL], gameVar);
return -1;
}
- nReturn = VM_GetPalData(nArrayIndex, nLabel);
+ nReturn = VM_GetPalData(nArrayIndex, labelNum);
break;
}
case STRUCT_PLAYER:
{
- int const nLabel = *insptr++;
+ int const labelNum = *insptr++;
- if (nArrayIndexVar == g_iThisActorID)
- nArrayIndex = vm.g_p;
+ if (nArrayIndexVar == g_thisActorVarID)
+ nArrayIndex = vm.playerNum;
- nArrayIndexVar = (EDUKE32_PREDICT_FALSE(PlayerLabels[nLabel].flags & LABEL_HASPARM2)) ?
+ nArrayIndexVar = (EDUKE32_PREDICT_FALSE(PlayerLabels[labelNum].flags & LABEL_HASPARM2)) ?
Gv_GetVarX(*insptr++) : 0;
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPLAYERS))
{
- nGameVar = nArrayIndex;
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], nGameVar);
+ gameVar = nArrayIndex;
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], gameVar);
return -1;
}
- nReturn = VM_GetPlayer(nArrayIndex, nLabel, nArrayIndexVar);
+ nReturn = VM_GetPlayer(nArrayIndex, labelNum, nArrayIndexVar);
break;
}
case STRUCT_INPUT:
{
- int const nLabel = *insptr++;
+ int const labelNum = *insptr++;
- if (nArrayIndexVar == g_iThisActorID)
- nArrayIndex = vm.g_p;
+ if (nArrayIndexVar == g_thisActorVarID)
+ nArrayIndex = vm.playerNum;
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXPLAYERS))
{
- nGameVar = nArrayIndex;
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], nGameVar);
+ gameVar = nArrayIndex;
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], gameVar);
return -1;
}
- nReturn = VM_GetPlayerInput(nArrayIndex, nLabel);
+ nReturn = VM_GetPlayerInput(nArrayIndex, labelNum);
break;
}
case STRUCT_ACTORVAR:
case STRUCT_PLAYERVAR:
- nReturn = Gv_GetVar(*insptr++, nArrayIndex, vm.g_p);
+ nReturn = Gv_GetVar(*insptr++, nArrayIndex, vm.playerNum);
break;
case STRUCT_SECTOR:
- if (nArrayIndexVar == g_iThisActorID)
- nArrayIndex = sprite[vm.g_i].sectnum;
+ if (nArrayIndexVar == g_thisActorVarID)
+ nArrayIndex = sprite[vm.spriteNum].sectnum;
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXSECTORS))
{
- nGameVar = nArrayIndex;
+ gameVar = nArrayIndex;
insptr++;
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSECTOR], nGameVar);
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADSECTOR], gameVar);
return -1;
}
nReturn = VM_GetSector(nArrayIndex, *insptr++);
@@ -1089,9 +1060,9 @@ int32_t __fastcall Gv_GetSpecialVarX(int nGameVar)
case STRUCT_WALL:
if (EDUKE32_PREDICT_FALSE((unsigned) nArrayIndex >= MAXWALLS))
{
- nGameVar = nArrayIndex;
+ gameVar = nArrayIndex;
insptr++;
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADWALL], nGameVar);
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADWALL], gameVar);
return -1;
}
nReturn = VM_GetWall(nArrayIndex, *insptr++);
@@ -1108,46 +1079,46 @@ int32_t __fastcall Gv_GetSpecialVarX(int nGameVar)
return nReturn;
}
-int32_t __fastcall Gv_GetVarX(int nGameVar)
+int32_t __fastcall Gv_GetVarX(int gameVar)
{
- if (nGameVar == g_iThisActorID)
- return vm.g_i;
+ if (gameVar == g_thisActorVarID)
+ return vm.spriteNum;
- if (nGameVar == MAXGAMEVARS)
+ if (gameVar == MAXGAMEVARS)
return *insptr++;
- int const nNegative = !!(nGameVar & (MAXGAMEVARS << 1));
+ int const nNegative = !!(gameVar & (MAXGAMEVARS << 1));
int nReturn = -1;
- if (EDUKE32_PREDICT_FALSE(nGameVar >= g_gameVarCount && nNegative == 0))
- nReturn = Gv_GetSpecialVarX(nGameVar);
+ if (EDUKE32_PREDICT_FALSE(gameVar >= g_gameVarCount && nNegative == 0))
+ nReturn = Gv_GetSpecialVarX(gameVar);
else
{
- nGameVar &= MAXGAMEVARS-1;
+ gameVar &= MAXGAMEVARS-1;
- int const nFlags = aGameVars[nGameVar].nFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
+ int const nFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
- if (!nFlags) nReturn = aGameVars[nGameVar].nValue;
+ if (!nFlags) nReturn = aGameVars[gameVar].global;
else if (nFlags == GAMEVAR_PERPLAYER)
{
- if (EDUKE32_PREDICT_FALSE((unsigned) vm.g_p >= MAXPLAYERS))
+ if (EDUKE32_PREDICT_FALSE((unsigned) vm.playerNum >= MAXPLAYERS))
goto perr;
- nReturn = aGameVars[nGameVar].pValues[vm.g_p];
+ nReturn = aGameVars[gameVar].pValues[vm.playerNum];
}
else if (nFlags == GAMEVAR_PERACTOR)
- nReturn = aGameVars[nGameVar].pValues[vm.g_i];
+ nReturn = aGameVars[gameVar].pValues[vm.spriteNum];
else switch (nFlags)
{
- case GAMEVAR_INTPTR: nReturn = (*((int32_t *)aGameVars[nGameVar].nValue)); break;
- case GAMEVAR_SHORTPTR: nReturn = (*((int16_t *)aGameVars[nGameVar].nValue)); break;
- case GAMEVAR_CHARPTR: nReturn = (*((uint8_t *)aGameVars[nGameVar].nValue)); break;
+ 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;
}
}
return (nReturn ^ -nNegative) + nNegative;
perr:
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], vm.g_p);
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], vm.playerNum);
return -1;
}
@@ -1155,48 +1126,48 @@ void __fastcall Gv_GetManyVars(int const count, int32_t * const rv)
{
for (int j = 0; j < count; ++j)
{
- int nGameVar = *insptr++;
+ int gameVar = *insptr++;
- if (nGameVar == g_iThisActorID)
+ if (gameVar == g_thisActorVarID)
{
- rv[j] = vm.g_i;
+ rv[j] = vm.spriteNum;
continue;
}
- if (nGameVar == MAXGAMEVARS)
+ if (gameVar == MAXGAMEVARS)
{
rv[j] = *insptr++;
continue;
}
- int const nNegative = !!(nGameVar & (MAXGAMEVARS << 1));
+ int const nNegative = !!(gameVar & (MAXGAMEVARS << 1));
- if (EDUKE32_PREDICT_FALSE(nGameVar >= g_gameVarCount && nNegative == 0))
+ if (EDUKE32_PREDICT_FALSE(gameVar >= g_gameVarCount && nNegative == 0))
{
- rv[j] = Gv_GetSpecialVarX(nGameVar);
+ rv[j] = Gv_GetSpecialVarX(gameVar);
continue;
}
- nGameVar &= MAXGAMEVARS - 1;
+ gameVar &= MAXGAMEVARS - 1;
- int const nFlags = aGameVars[nGameVar].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK);
- int nValue = aGameVars[nGameVar].nValue;
+ int const nFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK);
+ int nValue = aGameVars[gameVar].global;
if (nFlags == GAMEVAR_PERPLAYER)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p >= MAXPLAYERS))
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS))
goto perr;
- nValue = aGameVars[nGameVar].pValues[vm.g_p];
+ nValue = aGameVars[gameVar].pValues[vm.playerNum];
}
else if (nFlags == GAMEVAR_PERACTOR)
- nValue = aGameVars[nGameVar].pValues[vm.g_i];
+ nValue = aGameVars[gameVar].pValues[vm.spriteNum];
else
{
switch (nFlags)
{
- case GAMEVAR_INTPTR: nValue = (*((int32_t *)aGameVars[nGameVar].nValue)); break;
- case GAMEVAR_SHORTPTR: nValue = (*((int16_t *)aGameVars[nGameVar].nValue)); break;
- case GAMEVAR_CHARPTR: nValue = (*((uint8_t *)aGameVars[nGameVar].nValue)); break;
+ 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;
}
}
@@ -1204,61 +1175,61 @@ void __fastcall Gv_GetManyVars(int const count, int32_t * const rv)
continue;
perr:
- CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], vm.g_p);
+ CON_ERRPRINTF("%s %d\n", gvxerrs[GVX_BADPLAYER], vm.playerNum);
}
}
-void __fastcall Gv_SetVarX(int const nGameVar, int32_t const nValue)
+void __fastcall Gv_SetVarX(int const gameVar, int32_t const nValue)
{
- int const nFlags = aGameVars[nGameVar].nFlags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
+ int const nFlags = aGameVars[gameVar].flags & (GAMEVAR_USER_MASK|GAMEVAR_PTR_MASK);
- if (!nFlags) aGameVars[nGameVar].nValue = nValue;
+ if (!nFlags) aGameVars[gameVar].global = nValue;
else if (nFlags == GAMEVAR_PERPLAYER)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p >= MAXPLAYERS)) goto badindex;
- aGameVars[nGameVar].pValues[vm.g_p] = nValue;
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS)) goto badindex;
+ aGameVars[gameVar].pValues[vm.playerNum] = nValue;
}
else if (nFlags == GAMEVAR_PERACTOR)
{
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_i >= MAXSPRITES)) goto badindex;
- aGameVars[nGameVar].pValues[vm.g_i] = nValue;
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.spriteNum >= MAXSPRITES)) goto badindex;
+ aGameVars[gameVar].pValues[vm.spriteNum] = nValue;
}
else switch (nFlags)
{
- case GAMEVAR_INTPTR: *((int32_t *)aGameVars[nGameVar].nValue) = (int32_t)nValue; break;
- case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[nGameVar].nValue) = (int16_t)nValue; break;
- case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[nGameVar].nValue) = (uint8_t)nValue; break;
+ 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;
}
return;
badindex:
CON_ERRPRINTF("Gv_SetVar(): invalid index (%d) for gamevar %s\n",
- aGameVars[nGameVar].nFlags & GAMEVAR_PERACTOR ? vm.g_i : vm.g_p,
- aGameVars[nGameVar].szLabel);
+ aGameVars[gameVar].flags & GAMEVAR_PERACTOR ? vm.spriteNum : vm.playerNum,
+ aGameVars[gameVar].szLabel);
}
-int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t const nDefault, int const nSprite, int const nPlayer)
+int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t const nDefault, int const spriteNum, int const playerNum)
{
- int const nGameVar = hash_find(&h_gamevars, szGameLabel);
- return EDUKE32_PREDICT_FALSE(nGameVar < 0) ? nDefault : Gv_GetVar(nGameVar, nSprite, nPlayer);
+ int const gameVar = hash_find(&h_gamevars, szGameLabel);
+ return EDUKE32_PREDICT_FALSE(gameVar < 0) ? nDefault : Gv_GetVar(gameVar, spriteNum, playerNum);
}
static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel)
{
- int const nGameVar = hash_find(&h_gamevars, szGameLabel);
+ int const gameVar = hash_find(&h_gamevars, szGameLabel);
- if (EDUKE32_PREDICT_FALSE(nGameVar < 0))
+ if (EDUKE32_PREDICT_FALSE(gameVar < 0))
return NULL;
- if (aGameVars[nGameVar].nFlags & (GAMEVAR_PERACTOR | GAMEVAR_PERPLAYER))
+ if (aGameVars[gameVar].flags & (GAMEVAR_PERACTOR | GAMEVAR_PERPLAYER))
{
- if (EDUKE32_PREDICT_FALSE(!aGameVars[nGameVar].pValues))
+ if (EDUKE32_PREDICT_FALSE(!aGameVars[gameVar].pValues))
CON_ERRPRINTF("Gv_GetVarDataPtr(): INTERNAL ERROR: NULL array !!!\n");
- return aGameVars[nGameVar].pValues;
+ return aGameVars[gameVar].pValues;
}
- return &(aGameVars[nGameVar].nValue);
+ return &(aGameVars[gameVar].global);
}
#endif // !defined LUNATIC
@@ -1270,69 +1241,69 @@ void Gv_ResetSystemDefaults(void)
//AddLog("ResetWeaponDefaults");
- for (int nWeapon = 0; nWeapon < MAX_WEAPONS; ++nWeapon)
+ for (int weaponNum = 0; weaponNum < MAX_WEAPONS; ++weaponNum)
{
- for (int nPlayer = 0; nPlayer < MAXPLAYERS; ++nPlayer)
+ for (int playerNum = 0; playerNum < MAXPLAYERS; ++playerNum)
{
- Bsprintf(aszBuf, "WEAPON%d_CLIP", nWeapon);
- aplWeaponClip[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_RELOAD", nWeapon);
- aplWeaponReload[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_FIREDELAY", nWeapon);
- aplWeaponFireDelay[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_TOTALTIME", nWeapon);
- aplWeaponTotalTime[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_HOLDDELAY", nWeapon);
- aplWeaponHoldDelay[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_FLAGS", nWeapon);
- aplWeaponFlags[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_SHOOTS", nWeapon);
- aplWeaponShoots[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- if ((unsigned)aplWeaponShoots[nWeapon][nPlayer] >= MAXTILES)
- aplWeaponShoots[nWeapon][nPlayer] = 0;
- Bsprintf(aszBuf, "WEAPON%d_SPAWNTIME", nWeapon);
- aplWeaponSpawnTime[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_SPAWN", nWeapon);
- aplWeaponSpawn[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_SHOTSPERBURST", nWeapon);
- aplWeaponShotsPerBurst[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_WORKSLIKE", nWeapon);
- aplWeaponWorksLike[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_INITIALSOUND", nWeapon);
- aplWeaponInitialSound[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_FIRESOUND", nWeapon);
- aplWeaponFireSound[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_SOUND2TIME", nWeapon);
- aplWeaponSound2Time[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_SOUND2SOUND", nWeapon);
- aplWeaponSound2Sound[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_RELOADSOUND1", nWeapon);
- aplWeaponReloadSound1[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_RELOADSOUND2", nWeapon);
- aplWeaponReloadSound2[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_SELECTSOUND", nWeapon);
- aplWeaponSelectSound[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
- Bsprintf(aszBuf, "WEAPON%d_FLASHCOLOR", nWeapon);
- aplWeaponFlashColor[nWeapon][nPlayer] = Gv_GetVarByLabel(aszBuf, 0, -1, nPlayer);
+ Bsprintf(aszBuf, "WEAPON%d_CLIP", weaponNum);
+ aplWeaponClip[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_RELOAD", weaponNum);
+ aplWeaponReload[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_FIREDELAY", weaponNum);
+ aplWeaponFireDelay[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_TOTALTIME", weaponNum);
+ aplWeaponTotalTime[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_HOLDDELAY", weaponNum);
+ aplWeaponHoldDelay[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_FLAGS", weaponNum);
+ aplWeaponFlags[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_SHOOTS", weaponNum);
+ aplWeaponShoots[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ if ((unsigned)aplWeaponShoots[weaponNum][playerNum] >= MAXTILES)
+ aplWeaponShoots[weaponNum][playerNum] = 0;
+ Bsprintf(aszBuf, "WEAPON%d_SPAWNTIME", weaponNum);
+ aplWeaponSpawnTime[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_SPAWN", weaponNum);
+ aplWeaponSpawn[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_SHOTSPERBURST", weaponNum);
+ aplWeaponShotsPerBurst[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_WORKSLIKE", weaponNum);
+ aplWeaponWorksLike[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_INITIALSOUND", weaponNum);
+ aplWeaponInitialSound[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_FIRESOUND", weaponNum);
+ aplWeaponFireSound[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_SOUND2TIME", weaponNum);
+ aplWeaponSound2Time[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_SOUND2SOUND", weaponNum);
+ aplWeaponSound2Sound[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_RELOADSOUND1", weaponNum);
+ aplWeaponReloadSound1[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_RELOADSOUND2", weaponNum);
+ aplWeaponReloadSound2[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_SELECTSOUND", weaponNum);
+ aplWeaponSelectSound[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
+ Bsprintf(aszBuf, "WEAPON%d_FLASHCOLOR", weaponNum);
+ aplWeaponFlashColor[weaponNum][playerNum] = Gv_GetVarByLabel(aszBuf, 0, -1, playerNum);
}
}
- g_iReturnVarID = Gv_GetVarIndex("RETURN");
- g_iWeaponVarID = Gv_GetVarIndex("WEAPON");
- g_iWorksLikeVarID = Gv_GetVarIndex("WORKSLIKE");
- g_iZRangeVarID = Gv_GetVarIndex("ZRANGE");
- g_iAngRangeVarID = Gv_GetVarIndex("ANGRANGE");
- g_iAimAngleVarID = Gv_GetVarIndex("AUTOAIMANGLE");
- g_iLoTagID = Gv_GetVarIndex("LOTAG");
- g_iHiTagID = Gv_GetVarIndex("HITAG");
- g_iTextureID = Gv_GetVarIndex("TEXTURE");
- g_iThisActorID = Gv_GetVarIndex("THISACTOR");
- g_iStructVarIDs = Gv_GetVarIndex("sprite");
+ g_returnVarID = Gv_GetVarIndex("RETURN");
+ g_weaponVarID = Gv_GetVarIndex("WEAPON");
+ g_worksLikeVarID = Gv_GetVarIndex("WORKSLIKE");
+ g_zRangeVarID = Gv_GetVarIndex("ZRANGE");
+ g_angRangeVarID = Gv_GetVarIndex("ANGRANGE");
+ g_aimAngleVarID = Gv_GetVarIndex("AUTOAIMANGLE");
+ g_lotagVarID = Gv_GetVarIndex("LOTAG");
+ g_hitagVarID = Gv_GetVarIndex("HITAG");
+ g_textureVarID = Gv_GetVarIndex("TEXTURE");
+ g_thisActorVarID = Gv_GetVarIndex("THISACTOR");
+ g_structVarIDs = Gv_GetVarIndex("sprite");
#endif
- for (int nWeapon = 0; nWeapon <= MAXTILES - 1; nWeapon++)
- if (g_tile[nWeapon].defproj)
- *g_tile[nWeapon].proj = *g_tile[nWeapon].defproj;
+ for (int weaponNum = 0; weaponNum <= MAXTILES - 1; weaponNum++)
+ if (g_tile[weaponNum].defproj)
+ *g_tile[weaponNum].proj = *g_tile[weaponNum].defproj;
//AddLog("EOF:ResetWeaponDefaults");
}
@@ -1736,7 +1707,7 @@ void Gv_Init(void)
{
#if !defined LUNATIC
// already initialized
- if (aGameVars[0].nFlags)
+ if (aGameVars[0].flags)
return;
Gv_Clear();
@@ -1814,87 +1785,87 @@ void Gv_InitWeaponPointers(void)
void Gv_RefreshPointers(void)
{
- aGameVars[Gv_GetVarIndex("RESPAWN_MONSTERS")].nValue = (intptr_t)&ud.respawn_monsters;
- aGameVars[Gv_GetVarIndex("RESPAWN_ITEMS")].nValue = (intptr_t)&ud.respawn_items;
- aGameVars[Gv_GetVarIndex("RESPAWN_INVENTORY")].nValue = (intptr_t)&ud.respawn_inventory;
- aGameVars[Gv_GetVarIndex("MONSTERS_OFF")].nValue = (intptr_t)&ud.monsters_off;
- aGameVars[Gv_GetVarIndex("MARKER")].nValue = (intptr_t)&ud.marker;
- aGameVars[Gv_GetVarIndex("FFIRE")].nValue = (intptr_t)&ud.ffire;
- aGameVars[Gv_GetVarIndex("LEVEL")].nValue = (intptr_t)&ud.level_number;
- aGameVars[Gv_GetVarIndex("VOLUME")].nValue = (intptr_t)&ud.volume_number;
+ aGameVars[Gv_GetVarIndex("RESPAWN_MONSTERS")].global = (intptr_t)&ud.respawn_monsters;
+ aGameVars[Gv_GetVarIndex("RESPAWN_ITEMS")].global = (intptr_t)&ud.respawn_items;
+ aGameVars[Gv_GetVarIndex("RESPAWN_INVENTORY")].global = (intptr_t)&ud.respawn_inventory;
+ aGameVars[Gv_GetVarIndex("MONSTERS_OFF")].global = (intptr_t)&ud.monsters_off;
+ aGameVars[Gv_GetVarIndex("MARKER")].global = (intptr_t)&ud.marker;
+ aGameVars[Gv_GetVarIndex("FFIRE")].global = (intptr_t)&ud.ffire;
+ aGameVars[Gv_GetVarIndex("LEVEL")].global = (intptr_t)&ud.level_number;
+ aGameVars[Gv_GetVarIndex("VOLUME")].global = (intptr_t)&ud.volume_number;
- aGameVars[Gv_GetVarIndex("COOP")].nValue = (intptr_t)&ud.coop;
- aGameVars[Gv_GetVarIndex("MULTIMODE")].nValue = (intptr_t)&ud.multimode;
+ aGameVars[Gv_GetVarIndex("COOP")].global = (intptr_t)&ud.coop;
+ aGameVars[Gv_GetVarIndex("MULTIMODE")].global = (intptr_t)&ud.multimode;
- aGameVars[Gv_GetVarIndex("myconnectindex")].nValue = (intptr_t)&myconnectindex;
- aGameVars[Gv_GetVarIndex("screenpeek")].nValue = (intptr_t)&screenpeek;
- aGameVars[Gv_GetVarIndex("currentweapon")].nValue = (intptr_t)&hudweap.cur;
- aGameVars[Gv_GetVarIndex("gs")].nValue = (intptr_t)&hudweap.shade;
- aGameVars[Gv_GetVarIndex("looking_arc")].nValue = (intptr_t)&hudweap.lookhoriz;
- aGameVars[Gv_GetVarIndex("gun_pos")].nValue = (intptr_t)&hudweap.gunposy;
- aGameVars[Gv_GetVarIndex("weapon_xoffset")].nValue = (intptr_t)&hudweap.gunposx;
- aGameVars[Gv_GetVarIndex("weaponcount")].nValue = (intptr_t)&hudweap.count;
- aGameVars[Gv_GetVarIndex("looking_angSR1")].nValue = (intptr_t)&hudweap.lookhalfang;
- aGameVars[Gv_GetVarIndex("xdim")].nValue = (intptr_t)&xdim;
- aGameVars[Gv_GetVarIndex("ydim")].nValue = (intptr_t)&ydim;
- aGameVars[Gv_GetVarIndex("windowx1")].nValue = (intptr_t)&windowxy1.x;
- aGameVars[Gv_GetVarIndex("windowx2")].nValue = (intptr_t)&windowxy2.x;
- aGameVars[Gv_GetVarIndex("windowy1")].nValue = (intptr_t)&windowxy1.y;
- aGameVars[Gv_GetVarIndex("windowy2")].nValue = (intptr_t)&windowxy2.y;
- aGameVars[Gv_GetVarIndex("totalclock")].nValue = (intptr_t)&totalclock;
- aGameVars[Gv_GetVarIndex("lastvisinc")].nValue = (intptr_t)&lastvisinc;
- aGameVars[Gv_GetVarIndex("numsectors")].nValue = (intptr_t)&numsectors;
- aGameVars[Gv_GetVarIndex("numplayers")].nValue = (intptr_t)&numplayers;
- aGameVars[Gv_GetVarIndex("current_menu")].nValue = (intptr_t)&g_currentMenu;
- aGameVars[Gv_GetVarIndex("viewingrange")].nValue = (intptr_t)&viewingrange;
- aGameVars[Gv_GetVarIndex("yxaspect")].nValue = (intptr_t)&yxaspect;
- aGameVars[Gv_GetVarIndex("gravitationalconstant")].nValue = (intptr_t)&g_spriteGravity;
- aGameVars[Gv_GetVarIndex("gametype_flags")].nValue = (intptr_t)&GametypeFlags[ud.coop];
- aGameVars[Gv_GetVarIndex("framerate")].nValue = (intptr_t)&g_currentFrameRate;
+ aGameVars[Gv_GetVarIndex("myconnectindex")].global = (intptr_t)&myconnectindex;
+ aGameVars[Gv_GetVarIndex("screenpeek")].global = (intptr_t)&screenpeek;
+ aGameVars[Gv_GetVarIndex("currentweapon")].global = (intptr_t)&hudweap.cur;
+ aGameVars[Gv_GetVarIndex("gs")].global = (intptr_t)&hudweap.shade;
+ aGameVars[Gv_GetVarIndex("looking_arc")].global = (intptr_t)&hudweap.lookhoriz;
+ aGameVars[Gv_GetVarIndex("gun_pos")].global = (intptr_t)&hudweap.gunposy;
+ aGameVars[Gv_GetVarIndex("weapon_xoffset")].global = (intptr_t)&hudweap.gunposx;
+ aGameVars[Gv_GetVarIndex("weaponcount")].global = (intptr_t)&hudweap.count;
+ aGameVars[Gv_GetVarIndex("looking_angSR1")].global = (intptr_t)&hudweap.lookhalfang;
+ aGameVars[Gv_GetVarIndex("xdim")].global = (intptr_t)&xdim;
+ aGameVars[Gv_GetVarIndex("ydim")].global = (intptr_t)&ydim;
+ aGameVars[Gv_GetVarIndex("windowx1")].global = (intptr_t)&windowxy1.x;
+ aGameVars[Gv_GetVarIndex("windowx2")].global = (intptr_t)&windowxy2.x;
+ aGameVars[Gv_GetVarIndex("windowy1")].global = (intptr_t)&windowxy1.y;
+ aGameVars[Gv_GetVarIndex("windowy2")].global = (intptr_t)&windowxy2.y;
+ aGameVars[Gv_GetVarIndex("totalclock")].global = (intptr_t)&totalclock;
+ aGameVars[Gv_GetVarIndex("lastvisinc")].global = (intptr_t)&lastvisinc;
+ aGameVars[Gv_GetVarIndex("numsectors")].global = (intptr_t)&numsectors;
+ aGameVars[Gv_GetVarIndex("numplayers")].global = (intptr_t)&numplayers;
+ 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("gravitationalconstant")].global = (intptr_t)&g_spriteGravity;
+ aGameVars[Gv_GetVarIndex("gametype_flags")].global = (intptr_t)&GametypeFlags[ud.coop];
+ aGameVars[Gv_GetVarIndex("framerate")].global = (intptr_t)&g_currentFrameRate;
- aGameVars[Gv_GetVarIndex("camerax")].nValue = (intptr_t)&ud.camerapos.x;
- aGameVars[Gv_GetVarIndex("cameray")].nValue = (intptr_t)&ud.camerapos.y;
- aGameVars[Gv_GetVarIndex("cameraz")].nValue = (intptr_t)&ud.camerapos.z;
- aGameVars[Gv_GetVarIndex("cameraang")].nValue = (intptr_t)&ud.cameraang;
- aGameVars[Gv_GetVarIndex("camerahoriz")].nValue = (intptr_t)&ud.camerahoriz;
- aGameVars[Gv_GetVarIndex("camerasect")].nValue = (intptr_t)&ud.camerasect;
- aGameVars[Gv_GetVarIndex("cameradist")].nValue = (intptr_t)&g_cameraDistance;
- aGameVars[Gv_GetVarIndex("cameraclock")].nValue = (intptr_t)&g_cameraClock;
+ aGameVars[Gv_GetVarIndex("camerax")].global = (intptr_t)&ud.camerapos.x;
+ aGameVars[Gv_GetVarIndex("cameray")].global = (intptr_t)&ud.camerapos.y;
+ aGameVars[Gv_GetVarIndex("cameraz")].global = (intptr_t)&ud.camerapos.z;
+ aGameVars[Gv_GetVarIndex("cameraang")].global = (intptr_t)&ud.cameraang;
+ aGameVars[Gv_GetVarIndex("camerahoriz")].global = (intptr_t)&ud.camerahoriz;
+ aGameVars[Gv_GetVarIndex("camerasect")].global = (intptr_t)&ud.camerasect;
+ aGameVars[Gv_GetVarIndex("cameradist")].global = (intptr_t)&g_cameraDistance;
+ aGameVars[Gv_GetVarIndex("cameraclock")].global = (intptr_t)&g_cameraClock;
- aGameVars[Gv_GetVarIndex("myx")].nValue = (intptr_t)&my.x;
- aGameVars[Gv_GetVarIndex("myy")].nValue = (intptr_t)&my.y;
- aGameVars[Gv_GetVarIndex("myz")].nValue = (intptr_t)&my.z;
- aGameVars[Gv_GetVarIndex("omyx")].nValue = (intptr_t)&omy.x;
- aGameVars[Gv_GetVarIndex("omyy")].nValue = (intptr_t)&omy.y;
- aGameVars[Gv_GetVarIndex("omyz")].nValue = (intptr_t)&omy.z;
- aGameVars[Gv_GetVarIndex("myvelx")].nValue = (intptr_t)&myvel.x;
- aGameVars[Gv_GetVarIndex("myvely")].nValue = (intptr_t)&myvel.y;
- aGameVars[Gv_GetVarIndex("myvelz")].nValue = (intptr_t)&myvel.z;
+ aGameVars[Gv_GetVarIndex("myx")].global = (intptr_t)&my.x;
+ aGameVars[Gv_GetVarIndex("myy")].global = (intptr_t)&my.y;
+ aGameVars[Gv_GetVarIndex("myz")].global = (intptr_t)&my.z;
+ aGameVars[Gv_GetVarIndex("omyx")].global = (intptr_t)&omy.x;
+ aGameVars[Gv_GetVarIndex("omyy")].global = (intptr_t)&omy.y;
+ aGameVars[Gv_GetVarIndex("omyz")].global = (intptr_t)&omy.z;
+ aGameVars[Gv_GetVarIndex("myvelx")].global = (intptr_t)&myvel.x;
+ aGameVars[Gv_GetVarIndex("myvely")].global = (intptr_t)&myvel.y;
+ aGameVars[Gv_GetVarIndex("myvelz")].global = (intptr_t)&myvel.z;
- aGameVars[Gv_GetVarIndex("myhoriz")].nValue = (intptr_t)&myhoriz;
- aGameVars[Gv_GetVarIndex("myhorizoff")].nValue = (intptr_t)&myhorizoff;
- aGameVars[Gv_GetVarIndex("omyhoriz")].nValue = (intptr_t)&omyhoriz;
- aGameVars[Gv_GetVarIndex("omyhorizoff")].nValue = (intptr_t)&omyhorizoff;
- aGameVars[Gv_GetVarIndex("myang")].nValue = (intptr_t)&myang;
- aGameVars[Gv_GetVarIndex("omyang")].nValue = (intptr_t)&omyang;
- aGameVars[Gv_GetVarIndex("mycursectnum")].nValue = (intptr_t)&mycursectnum;
- aGameVars[Gv_GetVarIndex("myjumpingcounter")].nValue = (intptr_t)&myjumpingcounter;
+ aGameVars[Gv_GetVarIndex("myhoriz")].global = (intptr_t)&myhoriz;
+ aGameVars[Gv_GetVarIndex("myhorizoff")].global = (intptr_t)&myhorizoff;
+ aGameVars[Gv_GetVarIndex("omyhoriz")].global = (intptr_t)&omyhoriz;
+ aGameVars[Gv_GetVarIndex("omyhorizoff")].global = (intptr_t)&omyhorizoff;
+ aGameVars[Gv_GetVarIndex("myang")].global = (intptr_t)&myang;
+ aGameVars[Gv_GetVarIndex("omyang")].global = (intptr_t)&omyang;
+ aGameVars[Gv_GetVarIndex("mycursectnum")].global = (intptr_t)&mycursectnum;
+ aGameVars[Gv_GetVarIndex("myjumpingcounter")].global = (intptr_t)&myjumpingcounter;
- aGameVars[Gv_GetVarIndex("myjumpingtoggle")].nValue = (intptr_t)&myjumpingtoggle;
- aGameVars[Gv_GetVarIndex("myonground")].nValue = (intptr_t)&myonground;
- aGameVars[Gv_GetVarIndex("myhardlanding")].nValue = (intptr_t)&myhardlanding;
- aGameVars[Gv_GetVarIndex("myreturntocenter")].nValue = (intptr_t)&myreturntocenter;
+ aGameVars[Gv_GetVarIndex("myjumpingtoggle")].global = (intptr_t)&myjumpingtoggle;
+ aGameVars[Gv_GetVarIndex("myonground")].global = (intptr_t)&myonground;
+ aGameVars[Gv_GetVarIndex("myhardlanding")].global = (intptr_t)&myhardlanding;
+ aGameVars[Gv_GetVarIndex("myreturntocenter")].global = (intptr_t)&myreturntocenter;
- aGameVars[Gv_GetVarIndex("display_mirror")].nValue = (intptr_t)&display_mirror;
- aGameVars[Gv_GetVarIndex("randomseed")].nValue = (intptr_t)&randomseed;
+ aGameVars[Gv_GetVarIndex("display_mirror")].global = (intptr_t)&display_mirror;
+ aGameVars[Gv_GetVarIndex("randomseed")].global = (intptr_t)&randomseed;
- aGameVars[Gv_GetVarIndex("NUMWALLS")].nValue = (intptr_t)&numwalls;
- aGameVars[Gv_GetVarIndex("NUMSECTORS")].nValue = (intptr_t)&numsectors;
- aGameVars[Gv_GetVarIndex("Numsprites")].nValue = (intptr_t)&Numsprites;
+ aGameVars[Gv_GetVarIndex("NUMWALLS")].global = (intptr_t)&numwalls;
+ aGameVars[Gv_GetVarIndex("NUMSECTORS")].global = (intptr_t)&numsectors;
+ aGameVars[Gv_GetVarIndex("Numsprites")].global = (intptr_t)&Numsprites;
- aGameVars[Gv_GetVarIndex("lastsavepos")].nValue = (intptr_t)&g_lastSaveSlot;
+ aGameVars[Gv_GetVarIndex("lastsavepos")].global = (intptr_t)&g_lastSaveSlot;
# ifdef USE_OPENGL
- aGameVars[Gv_GetVarIndex("rendmode")].nValue = (intptr_t)&rendmode;
+ aGameVars[Gv_GetVarIndex("rendmode")].global = (intptr_t)&rendmode;
# endif
}
#endif
diff --git a/polymer/eduke32/source/gamevars.h b/polymer/eduke32/source/gamevars.h
index 6883add25..87872fe55 100644
--- a/polymer/eduke32/source/gamevars.h
+++ b/polymer/eduke32/source/gamevars.h
@@ -76,11 +76,11 @@ enum GamearrayFlags_t
typedef struct
{
union {
- intptr_t nValue;
+ intptr_t global;
intptr_t *pValues; // array of values when 'per-player', or 'per-actor'
};
- intptr_t nDefault;
- uintptr_t nFlags;
+ intptr_t defaultValue;
+ uintptr_t flags;
char * szLabel;
} gamevar_t;
@@ -89,7 +89,7 @@ typedef struct
char * szLabel;
intptr_t *pValues; // array of values
intptr_t size;
- intptr_t nFlags;
+ uintptr_t flags;
} gamearray_t;
#pragma pack(pop)
@@ -101,23 +101,23 @@ extern int32_t g_gameVarCount;
extern int32_t g_gameArrayCount;
int32_t __fastcall Gv_GetGameArrayValue(int const id, int index);
-int32_t __fastcall Gv_GetVar(int id, int nSprite, int nPlayer);
-void __fastcall Gv_SetVar(int const id, int32_t const lValue, int const nSprite, int const nPlayer);
+int32_t __fastcall Gv_GetVar(int id, int spriteNum, int playerNum);
+void __fastcall Gv_SetVar(int const id, int32_t const lValue, int const spriteNum, int const playerNum);
int32_t __fastcall Gv_GetVarX(int id);
void __fastcall Gv_GetManyVars(int const count, int32_t * const rv);
void __fastcall Gv_SetVarX(int const id, int32_t const lValue);
-int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t const lDefault,int32_t const iActor,int32_t const iPlayer);
+int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t const lDefault,int32_t const spriteNum,int32_t const playerNum);
int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags);
int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);
-FORCE_INLINE void A_ResetVars(int const nSprite)
+FORCE_INLINE void A_ResetVars(int const spriteNum)
{
for (int i = 0; i < g_gameVarCount; ++i)
{
- if ((aGameVars[i].nFlags & (GAMEVAR_PERACTOR | GAMEVAR_NODEFAULT)) != GAMEVAR_PERACTOR)
+ if ((aGameVars[i].flags & (GAMEVAR_PERACTOR | GAMEVAR_NODEFAULT)) != GAMEVAR_PERACTOR)
continue;
- aGameVars[i].pValues[nSprite] = aGameVars[i].nDefault;
+ aGameVars[i].pValues[spriteNum] = aGameVars[i].defaultValue;
}
}
@@ -125,11 +125,11 @@ void Gv_DumpValues(void);
void Gv_InitWeaponPointers(void);
void Gv_RefreshPointers(void);
void Gv_ResetVars(void);
-int32_t Gv_ReadSave(int32_t fil,int32_t newbehav);
-void Gv_WriteSave(FILE *fil,int32_t newbehav);
+int32_t Gv_ReadSave(int32_t kFile);
+void Gv_WriteSave(FILE *fil);
#else
extern int32_t g_noResetVars;
-extern LUNATIC_CB void (*A_ResetVars)(int32_t iActor);
+extern LUNATIC_CB void (*A_ResetVars)(int32_t spriteNum);
#endif
void Gv_ResetSystemDefaults(void);
@@ -137,62 +137,62 @@ void Gv_Init(void);
void Gv_FinalizeWeaponDefaults(void);
#if !defined LUNATIC
-#define VM_GAMEVAR_OPERATOR(func, operator) \
- FORCE_INLINE void __fastcall func(int const id, int32_t const nValue) \
- { \
- switch (aGameVars[id].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) \
- { \
- default: aGameVars[id].nValue operator nValue; break; \
- case GAMEVAR_PERPLAYER: \
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p > MAXPLAYERS - 1)) \
- break; \
- aGameVars[id].pValues[vm.g_p] operator nValue; \
- break; \
- case GAMEVAR_PERACTOR: \
- if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_i > MAXSPRITES - 1)) \
- break; \
- aGameVars[id].pValues[vm.g_i] operator nValue; \
- break; \
- case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].nValue) operator(int32_t) nValue; break; \
- case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].nValue) operator(int16_t) nValue; break; \
- case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].nValue) operator(uint8_t) nValue; break; \
- } \
+#define VM_GAMEVAR_OPERATOR(func, operator) \
+ FORCE_INLINE void __fastcall func(int const id, int32_t const operand) \
+ { \
+ switch (aGameVars[id].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) \
+ { \
+ default: aGameVars[id].global operator operand; break; \
+ case GAMEVAR_PERPLAYER: \
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum > MAXPLAYERS - 1)) \
+ break; \
+ aGameVars[id].pValues[vm.playerNum] operator operand; \
+ break; \
+ case GAMEVAR_PERACTOR: \
+ if (EDUKE32_PREDICT_FALSE((unsigned)vm.spriteNum > MAXSPRITES - 1)) \
+ break; \
+ aGameVars[id].pValues[vm.spriteNum] operator operand; \
+ break; \
+ case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].global) operator(int32_t) operand; break; \
+ case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].global) operator(int16_t) operand; break; \
+ case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].global) operator(uint8_t) operand; break; \
+ } \
}
#if defined(__arm__) || defined(LIBDIVIDE_ALWAYS)
-FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const nValue)
+FORCE_INLINE void __fastcall Gv_DivVar(int const id, int32_t const operand)
{
- if (EDUKE32_PREDICT_FALSE((aGameVars[id].nFlags & GAMEVAR_PERPLAYER && (unsigned) vm.g_p > MAXPLAYERS - 1) ||
- (aGameVars[id].nFlags & GAMEVAR_PERACTOR && (unsigned) vm.g_i > MAXSPRITES - 1)))
+ if (EDUKE32_PREDICT_FALSE((aGameVars[id].flags & GAMEVAR_PERPLAYER && (unsigned) vm.playerNum > MAXPLAYERS - 1) ||
+ (aGameVars[id].flags & GAMEVAR_PERACTOR && (unsigned) vm.spriteNum > MAXSPRITES - 1)))
return;
static libdivide_s32_t sdiv;
- static int32_t nLastValue;
- libdivide_s32_t *dptr = ((unsigned) nValue < DIVTABLESIZE) ? (libdivide_s32_t *) &divtable32[nValue] : &sdiv;
- intptr_t *iptr = &aGameVars[id].nValue;
+ static int32_t lastValue;
+ libdivide_s32_t *dptr = ((unsigned) operand < DIVTABLESIZE) ? (libdivide_s32_t *) &divtable32[operand] : &sdiv;
+ intptr_t *iptr = &aGameVars[id].global;
- if (nValue == nLastValue || dptr != &sdiv)
+ if (operand == lastValue || dptr != &sdiv)
goto skip;
- sdiv = libdivide_s32_gen((nLastValue = nValue));
+ sdiv = libdivide_s32_gen((lastValue = operand));
skip:
- switch (aGameVars[id].nFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK))
+ switch (aGameVars[id].flags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK))
{
- case GAMEVAR_PERPLAYER: iptr = &aGameVars[id].pValues[vm.g_p];
+ case GAMEVAR_PERPLAYER: iptr = &aGameVars[id].pValues[vm.playerNum];
default: break;
- case GAMEVAR_PERACTOR: iptr = &aGameVars[id].pValues[vm.g_i]; break;
+ case GAMEVAR_PERACTOR: iptr = &aGameVars[id].pValues[vm.spriteNum]; break;
case GAMEVAR_INTPTR:
- *((int32_t *)aGameVars[id].nValue) =
- (int32_t)libdivide_s32_do(*((int32_t *)aGameVars[id].nValue), dptr);
+ *((int32_t *)aGameVars[id].global) =
+ (int32_t)libdivide_s32_do(*((int32_t *)aGameVars[id].global), dptr);
return;
case GAMEVAR_SHORTPTR:
- *((int16_t *)aGameVars[id].nValue) =
- (int16_t)libdivide_s32_do(*((int16_t *)aGameVars[id].nValue), dptr);
+ *((int16_t *)aGameVars[id].global) =
+ (int16_t)libdivide_s32_do(*((int16_t *)aGameVars[id].global), dptr);
return;
case GAMEVAR_CHARPTR:
- *((uint8_t *)aGameVars[id].nValue) =
- (uint8_t)libdivide_s32_do(*((uint8_t *)aGameVars[id].nValue), dptr);
+ *((uint8_t *)aGameVars[id].global) =
+ (uint8_t)libdivide_s32_do(*((uint8_t *)aGameVars[id].global), dptr);
return;
}
diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c
index b12de4f78..1cd369e5b 100644
--- a/polymer/eduke32/source/global.c
+++ b/polymer/eduke32/source/global.c
@@ -35,7 +35,7 @@ extern "C" {
// JBF: g_spriteGravity modified to default to Atomic ed. default when using 1.3d CONs
int32_t g_spriteGravity=176;
-int16_t g_spriteDeleteQueueSize = 64;
+int16_t g_deleteQueueSize = 64;
char EpisodeNames[MAXVOLUMES][33] = { "L.A. Meltdown", "Lunar Apocalypse", "Shrapnel City" };
int32_t EpisodeFlags[MAXVOLUMES]; // all initialize to zero
diff --git a/polymer/eduke32/source/global.h b/polymer/eduke32/source/global.h
index 8e4875315..04e81d751 100644
--- a/polymer/eduke32/source/global.h
+++ b/polymer/eduke32/source/global.h
@@ -69,7 +69,7 @@ G_EXTERN actor_t actor[MAXSPRITES];
// g_tile: tile-specific data THAT DOES NOT CHANGE during the course of a game
G_EXTERN tiledata_t g_tile[MAXTILES];
G_EXTERN animwalltype animwall[MAXANIMWALLS];
-G_EXTERN char *ScriptQuotes[MAXQUOTES],*ScriptQuoteRedefinitions[MAXQUOTES];
+G_EXTERN char *apStrings[MAXQUOTES],*apXStrings[MAXQUOTES];
G_EXTERN char *label;
G_EXTERN int32_t g_musicIndex;
G_EXTERN char g_loadFromGroupOnly;
@@ -83,6 +83,7 @@ G_EXTERN char szPlayerName[MAXPLAYERNAME];
G_EXTERN char tempbuf[MAXSECTORS<<1],packbuf[PACKBUF_SIZE],menutextbuf[128],buf[1024];
#define TYPEBUFSIZE 141
G_EXTERN char typebuf[TYPEBUFSIZE];
+
G_EXTERN input_t avg;
G_EXTERN input_t loc;
G_EXTERN input_t recsync[RECSYNCBUFSIZ];
@@ -119,8 +120,8 @@ G_EXTERN int32_t startofdynamicinterpolations;
G_EXTERN int32_t ototalclock;
G_EXTERN intptr_t *g_scriptPtr;
G_EXTERN int32_t *labelcode,*labeltype;
-G_EXTERN intptr_t *script;
-G_EXTERN map_t MapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" and "loading" music
+G_EXTERN intptr_t *apScript;
+G_EXTERN map_t aMapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" and "loading" music
// XXX: I think this pragma pack is meaningless here.
// MSDN (https://msdn.microsoft.com/en-us/library/2e70t5y1%28VS.80%29.aspx) says:
@@ -142,39 +143,39 @@ G_EXTERN sound_t g_sounds[MAXSOUNDS];
G_EXTERN uint32_t everyothertime;
G_EXTERN uint32_t g_moveThingsCount;
G_EXTERN vec3_t my,omy,myvel;
-G_EXTERN char g_soundlocks[MAXSOUNDS];
+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 const char *s_buildDate;
-extern int32_t g_spriteGravity;
-extern int16_t g_spriteDeleteQueueSize;
-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];
+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
diff --git a/polymer/eduke32/source/jmact/_scrplib.h b/polymer/eduke32/source/jmact/_scrplib.h
index 5de43a636..5788c99cd 100644
--- a/polymer/eduke32/source/jmact/_scrplib.h
+++ b/polymer/eduke32/source/jmact/_scrplib.h
@@ -83,7 +83,7 @@ typedef struct scriptsection
typedef struct
{
- ScriptSectionType * script;
+ ScriptSectionType * apScript;
ScriptSectionType * lastsection;
ScriptLineType * scriptlines;
char scriptfilename[128];
diff --git a/polymer/eduke32/source/jmact/scriplib.c b/polymer/eduke32/source/jmact/scriplib.c
index b090a1c9e..82a95824d 100644
--- a/polymer/eduke32/source/jmact/scriplib.c
+++ b/polymer/eduke32/source/jmact/scriplib.c
@@ -73,17 +73,17 @@ void SCRIPT_Delete(int32_t scripthandle)
if (!SC(scripthandle)) return;
- if (SCRIPT(scripthandle,script))
+ if (SCRIPT(scripthandle,apScript))
{
- while (SCRIPT(scripthandle,script)->nextsection != SCRIPT(scripthandle,script))
+ while (SCRIPT(scripthandle,apScript)->nextsection != SCRIPT(scripthandle,apScript))
{
- s = SCRIPT(scripthandle,script)->nextsection;
- SCRIPT_FreeSection(SCRIPT(scripthandle,script));
- Bfree(SCRIPT(scripthandle,script));
- SCRIPT(scripthandle,script) = s;
+ s = SCRIPT(scripthandle,apScript)->nextsection;
+ SCRIPT_FreeSection(SCRIPT(scripthandle,apScript));
+ Bfree(SCRIPT(scripthandle,apScript));
+ SCRIPT(scripthandle,apScript) = s;
}
- Bfree(SCRIPT(scripthandle,script));
+ Bfree(SCRIPT(scripthandle,apScript));
}
Bfree(SC(scripthandle));
@@ -138,9 +138,9 @@ ScriptSectionType * SCRIPT_SectionExists(int32_t scripthandle, const char * sect
if (scripthandle < 0 || scripthandle >= MAXSCRIPTFILES) return NULL;
if (!sectionname) return NULL;
if (!SC(scripthandle)) return NULL;
- if (!SCRIPT(scripthandle,script)) return NULL;
+ if (!SCRIPT(scripthandle,apScript)) return NULL;
- for (s = SCRIPT(scripthandle,script); ls != s; ls=s,s=s->nextsection)
+ for (s = SCRIPT(scripthandle,apScript); ls != s; ls=s,s=s->nextsection)
if (!Bstrcasecmp(s->name, sectionname)) return s;
return NULL;
@@ -159,13 +159,13 @@ ScriptSectionType * SCRIPT_AddSection(int32_t scripthandle, const char * section
AllocSection(s);
s->name = Bstrdup(sectionname);
- if (!SCRIPT(scripthandle,script))
+ if (!SCRIPT(scripthandle,apScript))
{
- SCRIPT(scripthandle,script) = s;
+ SCRIPT(scripthandle,apScript) = s;
}
else
{
- s2 = SCRIPT(scripthandle,script);
+ s2 = SCRIPT(scripthandle,apScript);
while (s2->nextsection != s2) s2=s2->nextsection;
s2->nextsection = s;
s->prevsection = s2;
@@ -503,9 +503,9 @@ int32_t SCRIPT_NumberSections(int32_t scripthandle)
ScriptSectionType *s,*ls=NULL;
if (!SC(scripthandle)) return 0;
- if (!SCRIPT(scripthandle,script)) return 0;
+ if (!SCRIPT(scripthandle,apScript)) return 0;
- for (s = SCRIPT(scripthandle,script); ls != s; ls=s,s=s->nextsection) c++;
+ for (s = SCRIPT(scripthandle,apScript); ls != s; ls=s,s=s->nextsection) c++;
return c;
}
@@ -515,9 +515,9 @@ char const * SCRIPT_Section(int32_t scripthandle, int32_t which)
ScriptSectionType *s,*ls=NULL;
if (!SC(scripthandle)) return "";
- if (!SCRIPT(scripthandle,script)) return "";
+ if (!SCRIPT(scripthandle,apScript)) return "";
- for (s = SCRIPT(scripthandle,script); which>0 && ls != s; ls=s, s=s->nextsection, which--) ;
+ for (s = SCRIPT(scripthandle,apScript); which>0 && ls != s; ls=s, s=s->nextsection, which--) ;
return s->name;
}
@@ -529,7 +529,7 @@ int32_t SCRIPT_NumberEntries(int32_t scripthandle, char const * sectionname)
int32_t c=0;
if (!SC(scripthandle)) return 0;
- if (!SCRIPT(scripthandle,script)) return 0;
+ if (!SCRIPT(scripthandle,apScript)) return 0;
s = SCRIPT_SectionExists(scripthandle, sectionname);
if (!s) return 0;
@@ -544,7 +544,7 @@ char const * SCRIPT_Entry(int32_t scripthandle, char const * sectionname, int32_
ScriptEntryType *e,*le=NULL;
if (!SC(scripthandle)) return 0;
- if (!SCRIPT(scripthandle,script)) return 0;
+ if (!SCRIPT(scripthandle,apScript)) return 0;
s = SCRIPT_SectionExists(scripthandle, sectionname);
if (!s) return "";
@@ -559,7 +559,7 @@ char const * SCRIPT_GetRaw(int32_t scripthandle, char const * sectionname, char
ScriptEntryType *e;
if (!SC(scripthandle)) return 0;
- if (!SCRIPT(scripthandle,script)) return 0;
+ if (!SCRIPT(scripthandle,apScript)) return 0;
s = SCRIPT_SectionExists(scripthandle, sectionname);
e = SCRIPT_EntryExists(s, entryname);
@@ -654,7 +654,7 @@ int32_t SCRIPT_GetStringPtr(int32_t scripthandle, char const * sectionname, char
char *p;
if (!SC(scripthandle)) return 1;
- if (!SCRIPT(scripthandle,script)) return 1;
+ if (!SCRIPT(scripthandle,apScript)) return 1;
s = SCRIPT_SectionExists(scripthandle, sectionname);
e = SCRIPT_EntryExists(s, entryname);
@@ -681,7 +681,7 @@ int32_t SCRIPT_GetDoubleString(int32_t scripthandle, const char * sectionname, c
char *p;
if (!SC(scripthandle)) return 1;
- if (!SCRIPT(scripthandle,script)) return 1;
+ if (!SCRIPT(scripthandle,apScript)) return 1;
s = SCRIPT_SectionExists(scripthandle, sectionname);
e = SCRIPT_EntryExists(s, entryname);
@@ -712,7 +712,7 @@ int32_t SCRIPT_GetNumber(int32_t scripthandle, const char * sectionname, const c
char *p;
if (!SC(scripthandle)) return 1;
- if (!SCRIPT(scripthandle,script)) return 1;
+ if (!SCRIPT(scripthandle,apScript)) return 1;
s = SCRIPT_SectionExists(scripthandle, sectionname);
e = SCRIPT_EntryExists(s, entryname);
@@ -743,7 +743,7 @@ int32_t SCRIPT_GetBoolean(int32_t scripthandle, char const * sectionname, char c
ScriptEntryType *e;
if (!SC(scripthandle)) return 1;
- if (!SCRIPT(scripthandle,script)) return 1;
+ if (!SCRIPT(scripthandle,apScript)) return 1;
s = SCRIPT_SectionExists(scripthandle, sectionname);
e = SCRIPT_EntryExists(s, entryname);
diff --git a/polymer/eduke32/source/lunatic/lunatic_game.c b/polymer/eduke32/source/lunatic/lunatic_game.c
index 07a8f6113..a64e18b1e 100644
--- a/polymer/eduke32/source/lunatic/lunatic_game.c
+++ b/polymer/eduke32/source/lunatic/lunatic_game.c
@@ -364,7 +364,7 @@ int32_t A_InsertSprite(int16_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int1
uint8_t s_xr,uint8_t s_yr,int16_t s_a,int16_t s_ve,int16_t s_zv,int16_t s_ow,int16_t s_ss);
extern void A_AddToDeleteQueue(int32_t i);
extern int32_t A_PlaySound(uint32_t num, int32_t i);
-extern void A_DeleteSprite(int32_t s);
+void A_DeleteSprite(int spriteNum);
extern void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sect,
int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t unbiasedp);
extern void G_GameExit(const char *msg);
@@ -575,7 +575,7 @@ static int32_t SetActor_CF(lua_State *L)
//////////////////////////////
static int32_t call_regd_function3(lua_State *L, void *keyaddr,
- int32_t iActor, int32_t iPlayer, int32_t lDist)
+ int32_t spriteNum, int32_t playerNum, int32_t lDist)
{
#if !defined NDEBUG
const int32_t top = lua_gettop(L);
@@ -586,8 +586,8 @@ static int32_t call_regd_function3(lua_State *L, void *keyaddr,
lua_pushlightuserdata(L, keyaddr);
lua_gettable(L, LUA_REGISTRYINDEX);
- lua_pushinteger(L, iActor);
- lua_pushinteger(L, iPlayer);
+ lua_pushinteger(L, spriteNum);
+ lua_pushinteger(L, playerNum);
lua_pushinteger(L, lDist);
// -- call it! --
@@ -611,7 +611,7 @@ static void El_EventErrorPrint(const char *errmsg)
EventNames[g_eventIdx], errmsg);
}
-int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t *iReturn)
+int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t spriteNum, int32_t playerNum, int32_t lDist, int32_t *iReturn)
{
// XXX: estate must be the one where the events were registered...
// make a global?
@@ -623,7 +623,7 @@ int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t
g_RETURN = *iReturn;
g_elCallDepth++;
- i = call_regd_function3(L, &g_elEvents[eventidx], iActor, iPlayer, lDist);
+ i = call_regd_function3(L, &g_elEvents[eventidx], spriteNum, playerNum, lDist);
g_elCallDepth--;
*iReturn = g_RETURN;
@@ -646,19 +646,19 @@ static void El_ActorErrorPrint(const char *errmsg)
g_actorTile, g_iActor, errmsg);
}
-int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t iActor, int32_t iPlayer, int32_t lDist)
+int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t spriteNum, int32_t playerNum, int32_t lDist)
{
lua_State *const L = estate->L;
int32_t i;
g_elCallDepth++;
- i = call_regd_function3(L, &g_elActors[actortile], iActor, iPlayer, lDist);
+ i = call_regd_function3(L, &g_elActors[actortile], spriteNum, playerNum, lDist);
g_elCallDepth--;
if (i != 0)
{
g_actorTile = actortile;
- g_iActor = iActor;
+ g_iActor = spriteNum;
return L_HandleError(L, i, &El_ActorErrorPrint);
}
diff --git a/polymer/eduke32/source/lunatic/lunatic_game.h b/polymer/eduke32/source/lunatic/lunatic_game.h
index bee71049c..1bccbd401 100644
--- a/polymer/eduke32/source/lunatic/lunatic_game.h
+++ b/polymer/eduke32/source/lunatic/lunatic_game.h
@@ -40,8 +40,8 @@ void El_DisplayErrors(void);
int32_t El_CreateState(L_State *estate, const char *name);
void El_DestroyState(L_State *estate);
-int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t *iReturn);
-int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t iActor, int32_t iPlayer, int32_t lDist);
+int32_t El_CallEvent(L_State *estate, int32_t eventidx, int32_t spriteNum, int32_t playerNum, int32_t lDist, int32_t *iReturn);
+int32_t El_CallActor(L_State *estate, int32_t actortile, int32_t spriteNum, int32_t playerNum, int32_t lDist);
extern int8_t el_addNewErrors; // add new errors to display?
void El_OnError(const char *str);
diff --git a/polymer/eduke32/source/m32def.c b/polymer/eduke32/source/m32def.c
index 2103724b2..1473c9c30 100644
--- a/polymer/eduke32/source/m32def.c
+++ b/polymer/eduke32/source/m32def.c
@@ -28,16 +28,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//#include "osd.h"
#include "keys.h"
-char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling
-static char g_szCurrentBlockName[BMAX_PATH] = "(none)", g_szLastBlockName[BMAX_PATH] = "NULL";
+char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling
+static char g_szCurrentBlockName[BMAX_PATH] = "(none)";
+static char g_szLastBlockName[BMAX_PATH] = "NULL";
////// compiler state vvv
-static const char *textptr, *start_textptr, *g_curkwptr;
-static int32_t def_tw;
-int32_t g_totalLines, g_lineNumber;
-int32_t g_numCompilerErrors, g_numCompilerWarnings;
-
-int32_t g_didDefineSomething;
+static char const *textptr;
+static char const *start_textptr;
+static char const *g_curkwptr;
+static int32_t def_tw;
+int32_t g_totalLines;
+int32_t g_lineNumber;
+int32_t g_numCompilerErrors;
+int32_t g_numCompilerWarnings;
+int32_t g_didDefineSomething;
typedef struct
{
@@ -61,42 +65,46 @@ static compilerstate_t cs;
static compilerstate_t cs_default = {-1, -1, NULL, -1, -1, 0, 0, NULL, NULL, 0, 0, 0, 0};
////// -------------------
-instype *script = NULL;
-instype *g_scriptPtr;
-int32_t g_scriptSize = 65536;
-
-int32_t *constants, constants_allocsize=1024;
-int32_t g_numSavedConstants=0;
-static int32_t g_wasConstant=0;
-
-char *label;
-int32_t *labelval;
-uint8_t *labeltype;
-int32_t g_numLabels=0, g_numDefaultLabels=0;
-static int32_t label_allocsize = 512;
-
-int32_t g_stateCount = 0;
-statesinfo_t *statesinfo = NULL;
-static int32_t statesinfo_allocsize = 512;
+instype * apScript = NULL;
+instype * g_scriptPtr;
+int32_t g_scriptSize = 65536;
+int32_t * constants;
+int32_t constants_allocsize = 1024;
+int32_t g_numSavedConstants = 0;
+static int32_t g_wasConstant = 0;
+char * label;
+int32_t * labelval;
+uint8_t * labeltype;
+int32_t g_numLabels = 0;
+int32_t g_numDefaultLabels = 0;
+static int32_t label_allocsize = 512;
+int32_t g_stateCount = 0;
+statesinfo_t * statesinfo = NULL;
+static int32_t statesinfo_allocsize = 512;
static int32_t interactive_compilation = 0;
static char tempbuf[2048];
-static char tlabel[MAXLABELLEN], tlabel2[MAXLABELLEN];
+static char tlabel[MAXLABELLEN];
+static char tlabel2[MAXLABELLEN];
-int32_t g_iReturnVar=0;
-int32_t m32_sortvar1, m32_sortvar2;
+int32_t g_iReturnVar = 0;
-char *ScriptQuotes[MAXQUOTES+1], *ScriptQuoteRedefinitions[MAXQUOTES+1];
-int32_t g_numQuoteRedefinitions = 0;
+int32_t m32_sortvar1;
+int32_t m32_sortvar2;
-ofstype aEventOffsets[MAXEVENTS];
-int32_t aEventSizes[MAXEVENTS];
-uint16_t aEventNumLocals[MAXEVENTS];
+char * apStrings[MAXQUOTES + 1];
+char * apXStrings[MAXQUOTES + 1];
+int32_t g_numXStrings = 0;
-gamevar_t aGameVars[MAXGAMEVARS];
+ofstype aEventOffsets[MAXEVENTS];
+int32_t aEventSizes[MAXEVENTS];
+uint16_t aEventNumLocals[MAXEVENTS];
+gamevar_t aGameVars[MAXGAMEVARS];
gamearray_t aGameArrays[MAXGAMEARRAYS];
-int32_t g_gameVarCount=0, g_systemVarCount=0;
-int32_t g_gameArrayCount=0, g_systemArrayCount=0;
+int32_t g_gameVarCount = 0;
+int32_t g_systemVarCount = 0;
+int32_t g_gameArrayCount = 0;
+int32_t g_systemArrayCount = 0;
// "magic" number for { and }, overrides line number in compiled code for later detection
@@ -611,9 +619,9 @@ static void C_InitHashes()
// returns: 0:success, 1:failure
static int32_t C_SetScriptSize(int32_t size)
{
- ofstype oscriptOfs = (unsigned)(g_scriptPtr-script);
- ofstype ocaseScriptOfs = (unsigned)(cs.caseScriptPtr-script);
- ofstype ocaseCodeOfs = (unsigned)(cs.caseCodePtr-script);
+ ofstype oscriptOfs = (unsigned)(g_scriptPtr-apScript);
+ ofstype ocaseScriptOfs = (unsigned)(cs.caseScriptPtr-apScript);
+ ofstype ocaseCodeOfs = (unsigned)(cs.caseCodePtr-apScript);
instype *newscript;
int32_t osize = g_scriptSize;
@@ -625,24 +633,24 @@ static int32_t C_SetScriptSize(int32_t size)
g_scriptSize = size;
initprintf("Resizing code buffer to %d*%d bytes\n", g_scriptSize, (int32_t)sizeof(instype));
- newscript = (instype *)Xrealloc(script, g_scriptSize * sizeof(instype));
+ newscript = (instype *)Xrealloc(apScript, g_scriptSize * sizeof(instype));
if (size >= osize)
Bmemset(&newscript[osize], 0, (size-osize) * sizeof(instype));
- if (script != newscript)
+ if (apScript != newscript)
{
- initprintf("Relocating compiled code from to 0x%" PRIxPTR " to 0x%" PRIxPTR "\n", (intptr_t)script, (intptr_t)newscript);
- script = newscript;
+ initprintf("Relocating compiled code from to 0x%" PRIxPTR " to 0x%" PRIxPTR "\n", (intptr_t)apScript, (intptr_t)newscript);
+ apScript = newscript;
}
- g_scriptPtr = (instype *)(script+oscriptOfs);
+ g_scriptPtr = (instype *)(apScript+oscriptOfs);
// initprintf("script: %d, \n",script); initprintf("offset: %d\n",(unsigned)(g_scriptPtr-script));
if (cs.caseScriptPtr != NULL)
- cs.caseScriptPtr = (instype *)(script+ocaseScriptOfs);
+ cs.caseScriptPtr = (instype *)(apScript+ocaseScriptOfs);
if (cs.caseCodePtr != NULL)
- cs.caseCodePtr = (instype *)(script+ocaseCodeOfs);
+ cs.caseCodePtr = (instype *)(apScript+ocaseCodeOfs);
return 0;
}
@@ -703,7 +711,7 @@ static int32_t C_SkipComments(void)
// Be sure to have enough space allocated for the command to be parsed next.
// Currently, the commands that potentially need the most space are
// various string handling function that accept inline strings.
- if ((unsigned)(g_scriptPtr-script) > (unsigned)(g_scriptSize - max(40, MAXQUOTELEN/sizeof(instype)+8)))
+ if ((unsigned)(g_scriptPtr-apScript) > (unsigned)(g_scriptSize - max(40, MAXQUOTELEN/sizeof(instype)+8)))
return C_SetScriptSize(g_scriptSize<<1);
return 0;
@@ -1032,7 +1040,7 @@ static void C_GetNextVarType(int32_t type)
{
// current sprite shortcut access
- int32_t lLabelID;
+ int32_t labelNum;
flags = M32_FLAG_STRUCT;
if (*textptr=='-')
@@ -1045,16 +1053,16 @@ static void C_GetNextVarType(int32_t type)
/// now pointing at 'xxx'
C_GetNextLabelName(0);
- lLabelID = C_GetLabelNameID(SpriteLabels, &h_sprite, Bstrtolower(tlabel));
+ labelNum = C_GetLabelNameID(SpriteLabels, &h_sprite, Bstrtolower(tlabel));
- if (lLabelID == -1)
+ if (labelNum == -1)
{
g_numCompilerErrors++;
C_ReportError(ERROR_SYMBOLNOTRECOGNIZED);
return;
}
- *g_scriptPtr++ = ((M32_THISACTOR_VAR_ID<<16) | flags | (lLabelID<<2) | M32_SPRITE_VAR_ID);
+ *g_scriptPtr++ = ((M32_THISACTOR_VAR_ID<<16) | flags | (labelNum<<2) | M32_SPRITE_VAR_ID);
return;
}
@@ -1091,7 +1099,7 @@ static void C_GetNextVarType(int32_t type)
if (*textptr == '[') //read of array as a gamevar
{
- int32_t lLabelID = -1, aridx;
+ int32_t labelNum = -1, aridx;
int32_t lightp = 0;
textptr++;
@@ -1218,16 +1226,16 @@ static void C_GetNextVarType(int32_t type)
/*initprintf("found xxx label of \"%s\"\n", label+(g_numLabels*MAXLABELLEN));*/
if (lightp)
- lLabelID = C_GetLabelNameID(LightLabels, &h_light, Bstrtolower(tlabel));
+ labelNum = C_GetLabelNameID(LightLabels, &h_light, Bstrtolower(tlabel));
else if (id==M32_SPRITE_VAR_ID || id==M32_TSPRITE_VAR_ID)
- lLabelID = C_GetLabelNameID(SpriteLabels, &h_sprite, Bstrtolower(tlabel));
+ labelNum = C_GetLabelNameID(SpriteLabels, &h_sprite, Bstrtolower(tlabel));
else if (id==M32_SECTOR_VAR_ID)
- lLabelID = C_GetLabelNameID(SectorLabels, &h_sector, Bstrtolower(tlabel));
+ labelNum = C_GetLabelNameID(SectorLabels, &h_sector, Bstrtolower(tlabel));
else if (id==M32_WALL_VAR_ID)
- lLabelID = C_GetLabelNameID(WallLabels, &h_wall, Bstrtolower(tlabel));
- //printf("LabelID is %d\n",lLabelID);
+ labelNum = C_GetLabelNameID(WallLabels, &h_wall, Bstrtolower(tlabel));
+ //printf("LabelID is %d\n",labelNum);
- if (lLabelID == -1)
+ if (labelNum == -1)
{
g_numCompilerErrors++;
C_ReportError(ERROR_SYMBOLNOTRECOGNIZED);
@@ -1235,9 +1243,9 @@ static void C_GetNextVarType(int32_t type)
}
if ((aridx & M32_BITS_MASK) == M32_FLAG_CONSTANTINDEX)
- *g_scriptPtr++ = (aridx | flags | (lLabelID<<2) | id);
+ *g_scriptPtr++ = (aridx | flags | (labelNum<<2) | id);
else // simple or local gamevar
- *g_scriptPtr++ = (aridx<<16 | flags | (lLabelID<<2) | id);
+ *g_scriptPtr++ = (aridx<<16 | flags | (labelNum<<2) | id);
}
return;
@@ -1537,7 +1545,7 @@ static int32_t C_CheckMalformedBranch(ofstype lastScriptOfs)
case CON_ENDEVENT:
case CON_ENDS:
case CON_ELSE:
- g_scriptPtr = script + lastScriptOfs;
+ g_scriptPtr = apScript + lastScriptOfs;
cs.ifElseAborted = 1;
C_CUSTOMWARNING("malformed `%s' branch", keyw[*g_scriptPtr & 0xFFF]);
return 1;
@@ -1559,7 +1567,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, ofstype lastScriptOfs)
if (cs.ifElseAborted)
{
- g_scriptPtr = script + lastScriptOfs;
+ g_scriptPtr = apScript + lastScriptOfs;
C_CUSTOMWARNING("empty `%s' branch", keyw[*g_scriptPtr & 0xFFF]);
*g_scriptPtr = (CON_NULLOP + (IFELSE_MAGIC<<12));
return 1;
@@ -1574,8 +1582,8 @@ static int32_t C_CountCaseStatements()
int32_t lCount;
const char *temptextptr = textptr;
int32_t temp_ScriptLineNumber = g_lineNumber;
- ofstype scriptoffset = (unsigned)(g_scriptPtr-script);
- ofstype caseoffset = (unsigned)(cs.caseScriptPtr-script);
+ ofstype scriptoffset = (unsigned)(g_scriptPtr-apScript);
+ ofstype caseoffset = (unsigned)(cs.caseScriptPtr-apScript);
cs.numCases=0;
cs.caseScriptPtr=NULL;
@@ -1590,13 +1598,13 @@ static int32_t C_CountCaseStatements()
cs.checkingSwitch++;
textptr = temptextptr;
- g_scriptPtr = (instype *)(script+scriptoffset);
+ g_scriptPtr = (instype *)(apScript+scriptoffset);
g_lineNumber = temp_ScriptLineNumber;
lCount = cs.numCases;
cs.numCases = 0;
- cs.caseScriptPtr = (instype *)(script+caseoffset);
+ cs.caseScriptPtr = (instype *)(apScript+caseoffset);
return lCount;
}
@@ -1786,7 +1794,7 @@ static int32_t C_ParseCommand(void)
}
- cs.currentStateOfs = (g_scriptPtr-script);
+ cs.currentStateOfs = (g_scriptPtr-apScript);
j = hash_find(&h_states, tlabel);
if (j>=0) // only redefining
@@ -1866,7 +1874,7 @@ static int32_t C_ParseCommand(void)
if (g_numCompilerErrors)
{
- g_scriptPtr = script+cs.currentStateOfs;
+ g_scriptPtr = apScript+cs.currentStateOfs;
cs.currentStateOfs = -1;
cs.currentStateIdx = -1;
Bsprintf(g_szCurrentBlockName,"(none)");
@@ -1878,7 +1886,7 @@ static int32_t C_ParseCommand(void)
if (cs.currentStateIdx == g_stateCount) // we were defining a new state
{
statesinfo[j].ofs = cs.currentStateOfs;
- statesinfo[j].codesize = (g_scriptPtr-script) - cs.currentStateOfs;
+ statesinfo[j].codesize = (g_scriptPtr-apScript) - cs.currentStateOfs;
g_stateCount++;
@@ -1890,7 +1898,7 @@ static int32_t C_ParseCommand(void)
int32_t oofs = statesinfo[j].ofs;
int32_t nofs = cs.currentStateOfs;
int32_t osize = statesinfo[j].codesize;
- int32_t nsize = (g_scriptPtr-script) - nofs;
+ int32_t nsize = (g_scriptPtr-apScript) - nofs;
if (nsize == osize)
{
@@ -1898,8 +1906,8 @@ static int32_t C_ParseCommand(void)
for (ii=0; ii>12) - (ow>>12);
@@ -1918,7 +1926,7 @@ static int32_t C_ParseCommand(void)
}
if (equal!=2)
- Bmemcpy(script+oofs, script+nofs, nsize*sizeof(instype));
+ Bmemcpy(apScript+oofs, apScript+nofs, nsize*sizeof(instype));
if (equal==0)
initprintf(" Redefined State %3d `%s'.\n", j, g_szCurrentBlockName);
// initprintf(" oo:%d os:%d, no:%d ns:%d\n", oofs, osize, nofs, nsize);
@@ -1926,9 +1934,9 @@ static int32_t C_ParseCommand(void)
else
{
int32_t ii;
- uint32_t movedcodesize = g_scriptPtr - (script+oofs+osize);
+ uint32_t movedcodesize = g_scriptPtr - (apScript+oofs+osize);
- Bmemmove(script+oofs, script+oofs+osize, movedcodesize*sizeof(instype));
+ Bmemmove(apScript+oofs, apScript+oofs+osize, movedcodesize*sizeof(instype));
for (ii=0; ii= MAXEVENTS)
@@ -2086,7 +2094,7 @@ static int32_t C_ParseCommand(void)
if (g_numCompilerErrors)
{
- g_scriptPtr = script+cs.parsingEventOfs;
+ g_scriptPtr = apScript+cs.parsingEventOfs;
cs.parsingEventOfs = -1;
cs.currentEvent = -1;
Bsprintf(g_szCurrentBlockName, "(none)");
@@ -2097,7 +2105,7 @@ static int32_t C_ParseCommand(void)
if (aEventOffsets[j] >= 0) // if event was previously declared, overwrite it
{
int32_t oofs = aEventOffsets[j], nofs = cs.parsingEventOfs;
- int32_t osize = aEventSizes[j], nsize = (g_scriptPtr-script) - nofs;
+ int32_t osize = aEventSizes[j], nsize = (g_scriptPtr-apScript) - nofs;
if (osize == nsize)
{
@@ -2105,8 +2113,8 @@ static int32_t C_ParseCommand(void)
for (ii=0; ii>12) - (ow>>12);
@@ -2125,7 +2133,7 @@ static int32_t C_ParseCommand(void)
}
if (equal!=2)
- Bmemcpy(script+oofs, script+nofs, nsize*sizeof(instype));
+ Bmemcpy(apScript+oofs, apScript+nofs, nsize*sizeof(instype));
if (equal==0)
initprintf(" Redefined Event %3d `%s'.\n", j, g_szCurrentBlockName);
// initprintf(" oo:%d os:%d, no:%d ns:%d\n", oofs, osize, nofs, nsize);
@@ -2133,9 +2141,9 @@ static int32_t C_ParseCommand(void)
else
{
int32_t ii;
- uint32_t movedcodesize = g_scriptPtr - (script+oofs + osize);
+ uint32_t movedcodesize = g_scriptPtr - (apScript+oofs + osize);
- Bmemmove(script+oofs, script+oofs + osize, movedcodesize*sizeof(instype));
+ Bmemmove(apScript+oofs, apScript+oofs + osize, movedcodesize*sizeof(instype));
for (ii=0; ii1) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf);
if (j<0)
return 1;
@@ -2283,7 +2291,7 @@ static int32_t C_ParseCommand(void)
//Bsprintf(g_szBuf,"SWITCH2: '%.22s'",textptr); AddLog(g_szBuf);
}
- tempscrptr = (instype *)(script+tempoffset);
+ tempscrptr = (instype *)(apScript+tempoffset);
//Bsprintf(g_szBuf,"SWITCHXX: '%.22s'",textptr); AddLog(g_szBuf);
// done processing switch. clean up.
// if (cs.checkingSwitch < 1) Bsprintf(g_szBuf,"ERROR::%s %d: cs.checkingSwitch=%d",__FILE__,__LINE__, cs.checkingSwitch); AddLog(g_szBuf);
@@ -2364,7 +2372,7 @@ repeatcase:
goto repeatcase;
}
//Bsprintf(g_szBuf,"case4: '%.12s'",textptr); AddLog(g_szBuf);
- tempoffset = (unsigned)(tempscrptr-script);
+ tempoffset = (unsigned)(tempscrptr-apScript);
while (C_ParseCommand() == 0)
{
//Bsprintf(g_szBuf,"case5 '%.25s'",textptr); AddLog(g_szBuf);
@@ -2373,11 +2381,11 @@ repeatcase:
{
//AddLog("Found Repeat Case");
C_GetNextKeyword(); // eat 'case'
- tempscrptr = (instype *)(script+tempoffset);
+ tempscrptr = (instype *)(apScript+tempoffset);
goto repeatcase;
}
}
- tempscrptr = (instype *)(script+tempoffset);
+ tempscrptr = (instype *)(apScript+tempoffset);
//AddLog("End Case");
return 0;
// break;
@@ -2854,13 +2862,13 @@ repeatcase:
if (how >= ITER_SPRITESOFSECTOR)
C_GetNextVar();
- offset = g_scriptPtr-script;
+ offset = g_scriptPtr-apScript;
g_scriptPtr++; //Leave a spot for the location to jump to after completion
C_ParseCommand();
- tscrptr = (instype *)script+offset;
- *tscrptr = (g_scriptPtr-script)-offset; // relative offset
+ tscrptr = (instype *)apScript+offset;
+ *tscrptr = (g_scriptPtr-apScript)-offset; // relative offset
return 0;
}
@@ -2930,7 +2938,7 @@ repeatcase:
case CON_IFINTERACTIVE:
{
ofstype offset;
- ofstype lastScriptOfs = (g_scriptPtr-script-1);
+ ofstype lastScriptOfs = (g_scriptPtr-apScript-1);
instype *tscrptr;
cs.ifElseAborted = 0;
@@ -2989,7 +2997,7 @@ repeatcase:
if (C_CheckMalformedBranch(lastScriptOfs))
return 0;
- offset = (g_scriptPtr-script);
+ offset = (g_scriptPtr-apScript);
g_scriptPtr++; //Leave a spot for the fail location
C_ParseCommand();
@@ -2997,8 +3005,8 @@ repeatcase:
if (C_CheckEmptyBranch(tw, lastScriptOfs))
return 0;
- tscrptr = (instype *)script+offset;
- *tscrptr = (g_scriptPtr-script)-offset; // relative offset
+ tscrptr = (instype *)apScript+offset;
+ *tscrptr = (g_scriptPtr-apScript)-offset; // relative offset
if (tw != CON_WHILEVARN && tw != CON_WHILEVARVARN)
{
@@ -3182,8 +3190,8 @@ repeatcase:
k = MAXQUOTES;
}
- if (ScriptQuotes[k] == NULL)
- ScriptQuotes[k] = (char *)Xcalloc(MAXQUOTELEN, sizeof(uint8_t));
+ if (apStrings[k] == NULL)
+ apStrings[k] = (char *)Xcalloc(MAXQUOTELEN, sizeof(uint8_t));
if (tw == CON_DEFINEQUOTE)
g_scriptPtr--;
@@ -3193,8 +3201,8 @@ repeatcase:
if (tw == CON_REDEFINEQUOTE)
{
- if (ScriptQuoteRedefinitions[g_numQuoteRedefinitions] == NULL)
- ScriptQuoteRedefinitions[g_numQuoteRedefinitions] = (char *)Xcalloc(MAXQUOTELEN, sizeof(uint8_t));
+ if (apXStrings[g_numXStrings] == NULL)
+ apXStrings[g_numXStrings] = (char *)Xcalloc(MAXQUOTELEN, sizeof(uint8_t));
}
i = 0;
@@ -3208,9 +3216,9 @@ repeatcase:
// break;
// }
if (tw == CON_DEFINEQUOTE)
- *(ScriptQuotes[k]+i) = *textptr;
+ *(apStrings[k]+i) = *textptr;
else
- *(ScriptQuoteRedefinitions[g_numQuoteRedefinitions]+i) = *textptr;
+ *(apXStrings[g_numXStrings]+i) = *textptr;
textptr++;
i++;
@@ -3225,12 +3233,12 @@ repeatcase:
}
if (tw == CON_DEFINEQUOTE)
- *(ScriptQuotes[k]+i) = '\0';
+ *(apStrings[k]+i) = '\0';
else
{
- *(ScriptQuoteRedefinitions[g_numQuoteRedefinitions]+i) = '\0';
- *g_scriptPtr++ = g_numQuoteRedefinitions;
- g_numQuoteRedefinitions++;
+ *(apXStrings[g_numXStrings]+i) = '\0';
+ *g_scriptPtr++ = g_numXStrings;
+ g_numXStrings++;
}
return 0;
@@ -3612,7 +3620,7 @@ void C_CompilationInfo(void)
int32_t j, k=0;
initprintf(" \n");
initprintf("Compiled code info: (size=%ld*%d bytes)\n",
- (unsigned long)(g_scriptPtr-script), (int32_t)sizeof(instype));
+ (unsigned long)(g_scriptPtr-apScript), (int32_t)sizeof(instype));
initprintf(" %d/%d user labels, %d/65536 indirect constants,\n",
g_numLabels-g_numDefaultLabels, 65536-g_numDefaultLabels,
g_numSavedConstants);
@@ -3625,10 +3633,10 @@ void C_CompilationInfo(void)
initprintf(" %d states, %d/%d defined events\n", g_stateCount, k,MAXEVENTS);
for (k=0, j=MAXQUOTES-1; j>=0; j--)
- if (ScriptQuotes[j])
+ if (apStrings[j])
k++;
- if (k || g_numQuoteRedefinitions)
- initprintf(" %d/%d quotes, %d/%d quote redefinitions\n", k,MAXQUOTES, g_numQuoteRedefinitions,MAXQUOTES);
+ if (k || g_numXStrings)
+ initprintf(" %d/%d quotes, %d/%d quote redefinitions\n", k,MAXQUOTES, g_numXStrings,MAXQUOTES);
}
EDUKE32_STATIC_ASSERT(ARRAY_SIZE(keyw)-1 == CON_END);
@@ -3666,9 +3674,9 @@ void C_Compile(const char *filenameortext, int32_t isfilename)
Gv_Init();
C_AddDefaultDefinitions();
- script = (instype *)Xcalloc(g_scriptSize, sizeof(instype));
+ apScript = (instype *)Xcalloc(g_scriptSize, sizeof(instype));
- g_scriptPtr = script+1;
+ g_scriptPtr = apScript+1;
firstime = 0;
}
diff --git a/polymer/eduke32/source/m32def.h b/polymer/eduke32/source/m32def.h
index 77eea5db1..bb328e08a 100644
--- a/polymer/eduke32/source/m32def.h
+++ b/polymer/eduke32/source/m32def.h
@@ -107,12 +107,15 @@ enum miscvmflags
};
typedef struct {
- int32_t g_i;
+ int32_t spriteNum;
// VM state: either ==0 (top-level), >=1 and < MAXEVENTS+1 (event),
// or >= MAXEVENTS+1 and < MAXEVENTS+1+g_stateCount (state)
int32_t g_st;
- uspritetype *g_sp;
- uint32_t flags; //g_errorFlag, g_returnFlag;
+ union {
+ spritetype * pSprite;
+ uspritetype *pUSprite;
+ };
+ uint32_t flags; // g_errorFlag, g_returnFlag;
// 1:updatehighlight, 2:updatehighlightsector, 4:interactive (from menu)?
uint32_t miscflags;
diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c
index 5f35d1a05..2212d613b 100644
--- a/polymer/eduke32/source/m32exec.c
+++ b/polymer/eduke32/source/m32exec.c
@@ -66,11 +66,11 @@ void X_Disasm(ofstype beg, int32_t size)
{
instype *p;
- if (!script) return;
+ if (!apScript) return;
if (beg<0 || beg+size>g_scriptSize) return;
initprintf("beg=%d, size=%d: ", beg, size);
- for (p=script+beg; p