More minor optimizations. Breaks savegames.

git-svn-id: https://svn.eduke32.com/eduke32@6236 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2017-06-23 03:59:19 +00:00
parent 302d6bdfd8
commit 4489e110de
8 changed files with 262 additions and 317 deletions

View file

@ -1912,7 +1912,7 @@ ACTOR_STATIC void G_MoveStandables(void)
x = A_CheckHitSprite(spriteNum, &m); x = A_CheckHitSprite(spriteNum, &m);
actor[spriteNum].lastvx = x; actor[spriteNum].lastv.x = x;
pSprite->ang = l; pSprite->ang = l;
@ -1984,7 +1984,7 @@ ACTOR_STATIC void G_MoveStandables(void)
setsprite(spriteNum,(vec3_t *)pSprite); setsprite(spriteNum,(vec3_t *)pSprite);
// if( Actor[i].lastvx != x && lTripBombControl & TRIPBOMB_TRIPWIRE) // if( Actor[i].lastvx != x && lTripBombControl & TRIPBOMB_TRIPWIRE)
if (actor[spriteNum].lastvx != x && actor[spriteNum].t_data[6] != 1) if (actor[spriteNum].lastv.x != x && actor[spriteNum].t_data[6] != 1)
{ {
actor[spriteNum].t_data[6] = 3; actor[spriteNum].t_data[6] = 3;
T3(spriteNum) = 13; T3(spriteNum) = 13;
@ -5919,8 +5919,8 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
{ {
if ((pSector->floorstat&1) == 0 && (pSector->ceilingstat&1) == 0) if ((pSector->floorstat&1) == 0 && (pSector->ceilingstat&1) == 0)
{ {
if (!S_CheckSoundPlaying(spriteNum,actor[spriteNum].lastvx)) if (!S_CheckSoundPlaying(spriteNum,actor[spriteNum].lastv.x))
A_PlaySound(actor[spriteNum].lastvx,spriteNum); A_PlaySound(actor[spriteNum].lastv.x,spriteNum);
} }
else if (ud.monsters_off == 0 && pSector->floorpal == 0 && (pSector->floorstat&1) && rnd(8)) else if (ud.monsters_off == 0 && pSector->floorpal == 0 && (pSector->floorstat&1) && rnd(8))
{ {
@ -5935,7 +5935,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
} }
if (pSprite->xvel <= 64 && (pSector->floorstat&1) == 0 && (pSector->ceilingstat&1) == 0) if (pSprite->xvel <= 64 && (pSector->floorstat&1) == 0 && (pSector->ceilingstat&1) == 0)
S_StopEnvSound(actor[spriteNum].lastvx,spriteNum); S_StopEnvSound(actor[spriteNum].lastv.x,spriteNum);
if ((pSector->floorz-pSector->ceilingz) < (108<<8)) if ((pSector->floorz-pSector->ceilingz) < (108<<8))
{ {

View file

@ -149,7 +149,6 @@ typedef struct { int32_t id; struct action ac; } con_action_t;
# define AC_MOVFLAGS(spr, a) ((spr)->hitag) # define AC_MOVFLAGS(spr, a) ((spr)->hitag)
#endif #endif
#pragma pack(push, 1)
// (+ 40 16 16 4 8 6 8 6 4 20) // (+ 40 16 16 4 8 6 8 6 4 20)
typedef struct typedef struct
{ {
@ -165,46 +164,30 @@ typedef struct
int32_t flags; // 4b int32_t flags; // 4b
vec3_t bpos; // 12b vec3_t bpos; // 12b
int32_t floorz, ceilingz, lastvx, lastvy; // 16b int32_t floorz, ceilingz; // 8b
vec2_t lastv; // 8b
int32_t lasttransport; // 4b int32_t lasttransport; // 4b
int16_t picnum, ang, extra, owner; // 8b int16_t picnum, ang, extra, owner; // 8b
int16_t movflag, tempang, timetosleep; // 6b int16_t movflag, tempang, timetosleep; // 6b
// NOTE: 'dispicnum' is updated locally, not in sync with the game! int16_t actorstayput;
int16_t actorstayput, dispicnum;
#ifdef LUNATIC #ifdef LUNATIC
// Movement flags, sprite[i].hitag in C-CON: // Movement flags, sprite[i].hitag in C-CON:
uint16_t movflags; uint16_t movflags;
#endif #endif
int16_t cgg; uint8_t cgg, lightcount;
int16_t lightId, lightcount, lightmaxrange; // 6b int16_t lightId, lightmaxrange; // 4b
// NOTE: 'dispicnum' is updated every frame, not in sync with game tics!
int16_t dispicnum;
#ifdef POLYMER #ifdef POLYMER
_prlight *lightptr; // 4b/8b _prlight *lightptr; // 4b/8b
#else #else
void * lightptr; void * lightptr;
#endif #endif
// pad struct to 128 bytes
#if !defined UINTPTR_MAX
# error Need UINTPTR_MAX define to select between 32- and 64-bit structs
#endif
#if UINTPTR_MAX == 0xffffffff
/* 32-bit */
# if !defined LUNATIC
int8_t filler[22];
# else
int8_t filler[4];
# endif
#else
/* 64-bit */
# if !defined LUNATIC
int8_t filler[18];
# else
/* no padding */
#endif
#endif
} actor_t; } actor_t;
#pragma pack(push, 1)
// this struct needs to match the beginning of actor_t above // this struct needs to match the beginning of actor_t above
typedef struct typedef struct
{ {
@ -218,16 +201,18 @@ typedef struct
int32_t flags; // 4b int32_t flags; // 4b
vec3_t bpos; // 12b vec3_t bpos; // 12b
int32_t floorz, ceilingz, lastvx, lastvy; // 16b int32_t floorz, ceilingz; // 8b
vec2_t lastv; // 8b
int32_t lasttransport; // 4b int32_t lasttransport; // 4b
int16_t picnum, ang, extra, owner; // 8b int16_t picnum, ang, extra, owner; // 8b
int16_t movflag, tempang, timetosleep; // 6b int16_t movflag, tempang, timetosleep; // 6b
int16_t actorstayput, dispicnum; int16_t actorstayput;
#ifdef LUNATIC #ifdef LUNATIC
uint16_t movflags; uint16_t movflags;
#endif #endif
int16_t cgg; uint8_t cgg;
spritetype sprite; spritetype sprite;
int16_t netIndex; int16_t netIndex;
} netactor_t; } netactor_t;

View file

@ -3272,7 +3272,7 @@ int A_Spawn(int spriteNum, int tileNum)
// XXX: uh.. what? // XXX: uh.. what?
if (spriteNum == -1) if (spriteNum == -1)
spriteNum = SUBWAY; spriteNum = SUBWAY;
actor[newSprite].lastvx = spriteNum; actor[newSprite].lastv.x = spriteNum;
case SE_30_TWO_WAY_TRAIN: case SE_30_TWO_WAY_TRAIN:
if (g_netServer || numplayers > 1) if (g_netServer || numplayers > 1)
break; break;

View file

@ -165,7 +165,7 @@ typedef struct {
int32_t * pData; int32_t * pData;
DukePlayer_t *pPlayer; DukePlayer_t *pPlayer;
actor_t * pActor;
} vmstate_t; } vmstate_t;
extern vmstate_t vm; extern vmstate_t vm;

View file

@ -150,6 +150,17 @@ static FORCE_INLINE int32_t VM_EventCommon_(int eventNum, int spriteNum, int pla
return returnValue; return returnValue;
} }
#else #else
// do not inline
static void VM_DummySprite(void)
{
static uspritetype dummy_sprite;
static actor_t dummy;
vm.pUSprite = &dummy_sprite;
vm.pActor = &dummy;
vm.pData = &dummy.t_data[0];
}
static FORCE_INLINE int32_t VM_EventCommon_(int const eventNum, int const spriteNum, int const playerNum, static FORCE_INLINE int32_t VM_EventCommon_(int const eventNum, int const spriteNum, int const playerNum,
int const playerDist, int32_t returnValue) int const playerDist, int32_t returnValue)
{ {
@ -161,7 +172,8 @@ static FORCE_INLINE int32_t VM_EventCommon_(int const eventNum, int const sprite
0, 0,
&sprite[(unsigned)spriteNum], &sprite[(unsigned)spriteNum],
&actor[(unsigned)spriteNum].t_data[0], &actor[(unsigned)spriteNum].t_data[0],
g_player[playerNum].ps }; g_player[playerNum].ps,
&actor[(unsigned) spriteNum] };
// since we're targeting C99 and C++ now, we can interweave these to avoid // since we're targeting C99 and C++ now, we can interweave these to avoid
// having to load addresses for things twice // having to load addresses for things twice
@ -183,13 +195,7 @@ static FORCE_INLINE int32_t VM_EventCommon_(int const eventNum, int const sprite
// check tempvm instead of vm... this way, we are not actually loading // check tempvm instead of vm... this way, we are not actually loading
// FROM vm anywhere until VM_Execute() is called // FROM vm anywhere until VM_Execute() is called
if (EDUKE32_PREDICT_FALSE((unsigned) tempvm.spriteNum >= MAXSPRITES)) if (EDUKE32_PREDICT_FALSE((unsigned) tempvm.spriteNum >= MAXSPRITES))
{ VM_DummySprite();
static uspritetype dummy_sprite;
static int32_t dummy_t[ARRAY_SIZE(actor[0].t_data)];
vm.pUSprite = &dummy_sprite;
vm.pData = dummy_t;
}
if ((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers) if ((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)
vm.pPlayer = g_player[0].ps; vm.pPlayer = g_player[0].ps;
@ -271,8 +277,8 @@ static int32_t VM_CheckSquished(void)
if (EDUKE32_PREDICT_FALSE(vm.pSprite->pal == 1)) // frozen if (EDUKE32_PREDICT_FALSE(vm.pSprite->pal == 1)) // frozen
{ {
actor[vm.spriteNum].picnum = SHOTSPARK1; vm.pActor->picnum = SHOTSPARK1;
actor[vm.spriteNum].extra = 1; vm.pActor->extra = 1;
return 0; return 0;
} }
@ -291,20 +297,20 @@ GAMEEXEC_STATIC GAMEEXEC_INLINE void P_ForceAngle(DukePlayer_t *pPlayer)
} }
#endif #endif
int32_t A_Dodge(spritetype *pSprite) // wow, this function sucks
static int32_t A_Dodge(spritetype * const pSprite)
{ {
vec2_t const m = *(vec2_t *)pSprite;
vec2_t const msin = { sintable[(pSprite->ang + 512) & 2047], sintable[pSprite->ang & 2047] };
if (A_CheckEnemySprite(pSprite) && pSprite->extra <= 0) // hack if (A_CheckEnemySprite(pSprite) && pSprite->extra <= 0) // hack
return 0; return 0;
vec2_t const msin = { sintable[(pSprite->ang + 512) & 2047], sintable[pSprite->ang & 2047] };
for (bssize_t nexti, SPRITES_OF_STAT_SAFE(STAT_PROJECTILE, i, nexti)) //weapons list for (bssize_t nexti, SPRITES_OF_STAT_SAFE(STAT_PROJECTILE, i, nexti)) //weapons list
{ {
if (OW(i) == i) if (OW(i) == i)
continue; continue;
vec2_t const b = { SX(i) - m.x, SY(i) - m.y }; vec2_t const b = { SX(i) - pSprite->x, SY(i) - pSprite->y };
vec2_t const v = { sintable[(SA(i) + 512) & 2047], sintable[SA(i) & 2047] }; 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)) if (((msin.x * b.x) + (msin.y * b.y) >= 0) && ((v.x * b.x) + (v.y * b.y) < 0))
@ -327,12 +333,12 @@ int32_t A_GetFurthestAngle(int const spriteNum, int const angDiv)
if (pSprite->picnum != APLAYER && (AC_COUNT(actor[spriteNum].t_data)&63) > 2) if (pSprite->picnum != APLAYER && (AC_COUNT(actor[spriteNum].t_data)&63) > 2)
return pSprite->ang + 1024; return pSprite->ang + 1024;
int32_t furthest_angle = 0; int32_t furthestAngle = 0;
int32_t greatestd = INT32_MIN; int32_t greatestDist = INT32_MIN;
int const angincs = tabledivide32_noinline(2048, angDiv); int const angIncs = tabledivide32_noinline(2048, angDiv);
hitdata_t hit; hitdata_t hit;
for (bssize_t j = pSprite->ang; j < (2048 + pSprite->ang); j += angincs) for (bssize_t j = pSprite->ang; j < (2048 + pSprite->ang); j += angIncs)
{ {
pSprite->z -= ZOFFSET3; pSprite->z -= ZOFFSET3;
hitscan((const vec3_t *)pSprite, pSprite->sectnum, hitscan((const vec3_t *)pSprite, pSprite->sectnum,
@ -341,19 +347,19 @@ int32_t A_GetFurthestAngle(int const spriteNum, int const angDiv)
&hit, CLIPMASK1); &hit, CLIPMASK1);
pSprite->z += ZOFFSET3; pSprite->z += ZOFFSET3;
int const d = klabs(hit.pos.x-pSprite->x) + klabs(hit.pos.y-pSprite->y); int const hitDist = klabs(hit.pos.x-pSprite->x) + klabs(hit.pos.y-pSprite->y);
if (d > greatestd) if (hitDist > greatestDist)
{ {
greatestd = d; greatestDist = hitDist;
furthest_angle = j; furthestAngle = j;
} }
} }
return furthest_angle&2047; return furthestAngle&2047;
} }
int A_FurthestVisiblePoint(int const spriteNum, uspritetype * const ts, int32_t * const dax, int32_t * const day) int A_FurthestVisiblePoint(int const spriteNum, uspritetype * const ts, vec2_t * const vect)
{ {
if (AC_COUNT(actor[spriteNum].t_data)&63) if (AC_COUNT(actor[spriteNum].t_data)&63)
return -1; return -1;
@ -382,8 +388,8 @@ int A_FurthestVisiblePoint(int const spriteNum, uspritetype * const ts, int32_t
if (cansee(hit.pos.x, hit.pos.y, hit.pos.z, hit.sect, if (cansee(hit.pos.x, hit.pos.y, hit.pos.z, hit.sect,
pnSprite->x, pnSprite->y, pnSprite->z - ZOFFSET2, pnSprite->sectnum)) pnSprite->x, pnSprite->y, pnSprite->z - ZOFFSET2, pnSprite->sectnum))
{ {
*dax = hit.pos.x; vect->x = hit.pos.x;
*day = hit.pos.y; vect->y = hit.pos.y;
return hit.sect; return hit.sect;
} }
} }
@ -409,7 +415,7 @@ static void VM_GetZRange(int const spriteNum, int32_t * const ceilhit, int32_t *
pSprite->cstat = ocstat; pSprite->cstat = ocstat;
} }
void A_GetZLimits(int spriteNum) void A_GetZLimits(int const spriteNum)
{ {
spritetype *const pSprite = &sprite[spriteNum]; spritetype *const pSprite = &sprite[spriteNum];
int32_t ceilhit, florhit; int32_t ceilhit, florhit;
@ -525,9 +531,9 @@ GAMEEXEC_STATIC void VM_AlterAng(int32_t const moveFlags)
if (vm.pSprite->zvel < 648) if (vm.pSprite->zvel < 648)
vm.pSprite->zvel += ((moveptr[1]<<4) - vm.pSprite->zvel)/5; vm.pSprite->zvel += ((moveptr[1]<<4) - vm.pSprite->zvel)/5;
#else #else
vm.pSprite->xvel += (actor[vm.spriteNum].mv.hvel - vm.pSprite->xvel)/5; vm.pSprite->xvel += (vm.pActor->mv.hvel - vm.pSprite->xvel)/5;
if (vm.pSprite->zvel < 648) if (vm.pSprite->zvel < 648)
vm.pSprite->zvel += ((actor[vm.spriteNum].mv.vvel<<4) - vm.pSprite->zvel)/5; vm.pSprite->zvel += ((vm.pActor->mv.vvel<<4) - vm.pSprite->zvel)/5;
#endif #endif
if (A_CheckEnemySprite(vm.pSprite) && vm.pSprite->extra <= 0) // hack if (A_CheckEnemySprite(vm.pSprite) && vm.pSprite->extra <= 0) // hack
@ -547,7 +553,7 @@ GAMEEXEC_STATIC void VM_AlterAng(int32_t const moveFlags)
: vm.pPlayer->i; : vm.pPlayer->i;
int const goalAng = (sprite[vm.pSprite->owner].picnum == APLAYER) int const goalAng = (sprite[vm.pSprite->owner].picnum == APLAYER)
? getangle(actor[vm.spriteNum].lastvx - vm.pSprite->x, actor[vm.spriteNum].lastvy - vm.pSprite->y) ? getangle(vm.pActor->lastv.x - vm.pSprite->x, vm.pActor->lastv.y - vm.pSprite->y)
: getangle(sprite[vm.pSprite->owner].x - vm.pSprite->x, sprite[vm.pSprite->owner].y - vm.pSprite->y); : getangle(sprite[vm.pSprite->owner].x - vm.pSprite->x, sprite[vm.pSprite->owner].y - vm.pSprite->y);
if (vm.pSprite->xvel && vm.pSprite->picnum != DRONE) if (vm.pSprite->xvel && vm.pSprite->picnum != DRONE)
@ -558,10 +564,10 @@ GAMEEXEC_STATIC void VM_AlterAng(int32_t const moveFlags)
{ {
if (klabs(angDiff) < 256) if (klabs(angDiff) < 256)
{ {
int const j = 128-(krand()&256); int const angInc = 128-(krand()&256);
vm.pSprite->ang += j; vm.pSprite->ang += angInc;
if (A_GetHitscanRange(vm.spriteNum) < 844) if (A_GetHitscanRange(vm.spriteNum) < 844)
vm.pSprite->ang -= j; vm.pSprite->ang -= angInc;
} }
} }
else if (elapsedTics > 18 && elapsedTics < GAMETICSPERSEC) // choose else if (elapsedTics > 18 && elapsedTics < GAMETICSPERSEC) // choose
@ -653,10 +659,10 @@ GAMEEXEC_STATIC void VM_Move(void)
if (AC_MOVE_ID(vm.pData) == 0 || movflags == 0) if (AC_MOVE_ID(vm.pData) == 0 || movflags == 0)
{ {
if (deadflag || (actor[vm.spriteNum].bpos.x != vm.pSprite->x) || (actor[vm.spriteNum].bpos.y != vm.pSprite->y)) if (deadflag || (vm.pActor->bpos.x != vm.pSprite->x) || (vm.pActor->bpos.y != vm.pSprite->y))
{ {
actor[vm.spriteNum].bpos.x = vm.pSprite->x; vm.pActor->bpos.x = vm.pSprite->x;
actor[vm.spriteNum].bpos.y = vm.pSprite->y; vm.pActor->bpos.y = vm.pSprite->y;
setsprite(vm.spriteNum, (vec3_t *)vm.pSprite); setsprite(vm.spriteNum, (vec3_t *)vm.pSprite);
} }
return; return;
@ -701,8 +707,8 @@ dead:
if (movflags&geth) vm.pSprite->xvel += ((moveptr[0])-vm.pSprite->xvel)>>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; if (movflags&getv) vm.pSprite->zvel += ((moveptr[1]<<4)-vm.pSprite->zvel)>>1;
#else #else
if (movflags&geth) vm.pSprite->xvel += (actor[vm.spriteNum].mv.hvel - vm.pSprite->xvel)>>1; if (movflags&geth) vm.pSprite->xvel += (vm.pActor->mv.hvel - vm.pSprite->xvel)>>1;
if (movflags&getv) vm.pSprite->zvel += (16*actor[vm.spriteNum].mv.vvel - vm.pSprite->zvel)>>1; if (movflags&getv) vm.pSprite->zvel += (16*vm.pActor->mv.vvel - vm.pSprite->zvel)>>1;
#endif #endif
if (movflags&dodgebullet && !deadflag) if (movflags&dodgebullet && !deadflag)
@ -730,14 +736,14 @@ dead:
int32_t nSectorZ; int32_t nSectorZ;
// NOTE: COMMANDER updates both actor[].floorz and // NOTE: COMMANDER updates both actor[].floorz and
// .ceilingz regardless of its zvel. // .ceilingz regardless of its zvel.
actor[vm.spriteNum].floorz = nSectorZ = VM_GetFlorZOfSlope(); vm.pActor->floorz = nSectorZ = VM_GetFlorZOfSlope();
if (vm.pSprite->z > nSectorZ-ZOFFSET3) if (vm.pSprite->z > nSectorZ-ZOFFSET3)
{ {
vm.pSprite->z = nSectorZ-ZOFFSET3; vm.pSprite->z = nSectorZ-ZOFFSET3;
vm.pSprite->zvel = 0; vm.pSprite->zvel = 0;
} }
actor[vm.spriteNum].ceilingz = nSectorZ = VM_GetCeilZOfSlope(); vm.pActor->ceilingz = nSectorZ = VM_GetCeilZOfSlope();
if (vm.pSprite->z < nSectorZ+(80<<8)) if (vm.pSprite->z < nSectorZ+(80<<8))
{ {
vm.pSprite->z = nSectorZ+(80<<8); vm.pSprite->z = nSectorZ+(80<<8);
@ -750,13 +756,13 @@ dead:
// The DRONE updates either .floorz or .ceilingz, not both. // The DRONE updates either .floorz or .ceilingz, not both.
if (vm.pSprite->zvel > 0) if (vm.pSprite->zvel > 0)
{ {
actor[vm.spriteNum].floorz = nSectorZ = VM_GetFlorZOfSlope(); vm.pActor->floorz = nSectorZ = VM_GetFlorZOfSlope();
if (vm.pSprite->z > nSectorZ-(30<<8)) if (vm.pSprite->z > nSectorZ-(30<<8))
vm.pSprite->z = nSectorZ-(30<<8); vm.pSprite->z = nSectorZ-(30<<8);
} }
else else
{ {
actor[vm.spriteNum].ceilingz = nSectorZ = VM_GetCeilZOfSlope(); vm.pActor->ceilingz = nSectorZ = VM_GetCeilZOfSlope();
if (vm.pSprite->z < nSectorZ+(50<<8)) if (vm.pSprite->z < nSectorZ+(50<<8))
{ {
vm.pSprite->z = nSectorZ+(50<<8); vm.pSprite->z = nSectorZ+(50<<8);
@ -771,8 +777,8 @@ dead:
// .ceilingz here. // .ceilingz here.
if (vm.pSprite->zvel > 0) if (vm.pSprite->zvel > 0)
{ {
if (vm.pSprite->z > actor[vm.spriteNum].floorz) if (vm.pSprite->z > vm.pActor->floorz)
vm.pSprite->z = actor[vm.spriteNum].floorz; vm.pSprite->z = vm.pActor->floorz;
vm.pSprite->z += A_GetWaterZOffset(vm.spriteNum); vm.pSprite->z += A_GetWaterZOffset(vm.spriteNum);
} }
else if (vm.pSprite->zvel < 0) else if (vm.pSprite->zvel < 0)
@ -817,13 +823,13 @@ dead:
} }
} }
else if (vm.pSprite->picnum == APLAYER) else if (vm.pSprite->picnum == APLAYER)
if (vm.pSprite->z < actor[vm.spriteNum].ceilingz+ZOFFSET5) if (vm.pSprite->z < vm.pActor->ceilingz+ZOFFSET5)
vm.pSprite->z = actor[vm.spriteNum].ceilingz+ZOFFSET5; vm.pSprite->z = vm.pActor->ceilingz+ZOFFSET5;
vec3_t const vect = { (spriteXvel * (sintable[(angDiff + 512) & 2047])) >> 14, vec3_t const vect = { (spriteXvel * (sintable[(angDiff + 512) & 2047])) >> 14,
(spriteXvel * (sintable[angDiff & 2047])) >> 14, vm.pSprite->zvel }; (spriteXvel * (sintable[angDiff & 2047])) >> 14, vm.pSprite->zvel };
actor[vm.spriteNum].movflag = A_MoveSprite(vm.spriteNum, &vect, (A_CheckSpriteFlags(vm.spriteNum, SFLAG_NOCLIP) ? 0 : CLIPMASK0)); vm.pActor->movflag = A_MoveSprite(vm.spriteNum, &vect, (A_CheckSpriteFlags(vm.spriteNum, SFLAG_NOCLIP) ? 0 : CLIPMASK0));
} }
if (!badguyp) if (!badguyp)
@ -1318,11 +1324,11 @@ skip_check:
vm.pSprite->sectnum, pPlayer->pos.x, pPlayer->pos.y, vm.pSprite->sectnum, pPlayer->pos.x, pPlayer->pos.y,
pPlayer->pos.z/*-((krand()&41)<<8)*/, sprite[pPlayer->i].sectnum); pPlayer->pos.z/*-((krand()&41)<<8)*/, sprite[pPlayer->i].sectnum);
VM_CONDITIONAL(tw); VM_CONDITIONAL(tw);
if (tw) actor[vm.spriteNum].timetosleep = SLEEPTIME; if (tw) vm.pActor->timetosleep = SLEEPTIME;
continue; continue;
case CON_IFACTORNOTSTAYPUT: case CON_IFACTORNOTSTAYPUT:
VM_CONDITIONAL(actor[vm.spriteNum].actorstayput == -1); VM_CONDITIONAL(vm.pActor->actorstayput == -1);
continue; continue;
case CON_IFCANSEE: case CON_IFCANSEE:
@ -1357,19 +1363,19 @@ skip_check:
// also modifies 'target' x&y if found.. // also modifies 'target' x&y if found..
tw = 1; tw = 1;
if (A_FurthestVisiblePoint(vm.spriteNum,pSprite,&actor[vm.spriteNum].lastvx,&actor[vm.spriteNum].lastvy) == -1) if (A_FurthestVisiblePoint(vm.spriteNum,pSprite,&vm.pActor->lastv) == -1)
tw = 0; tw = 0;
} }
else else
{ {
// else, they did see it. // else, they did see it.
// save where we were looking... // save where we were looking...
actor[vm.spriteNum].lastvx = pSprite->x; vm.pActor->lastv.x = pSprite->x;
actor[vm.spriteNum].lastvy = pSprite->y; vm.pActor->lastv.y = pSprite->y;
} }
if (tw && (vm.pSprite->statnum == STAT_ACTOR || vm.pSprite->statnum == STAT_STANDABLE)) if (tw && (vm.pSprite->statnum == STAT_ACTOR || vm.pSprite->statnum == STAT_STANDABLE))
actor[vm.spriteNum].timetosleep = SLEEPTIME; vm.pActor->timetosleep = SLEEPTIME;
VM_CONDITIONAL(tw); VM_CONDITIONAL(tw);
continue; continue;
@ -1421,14 +1427,14 @@ skip_check:
case CON_IFPDISTL: case CON_IFPDISTL:
VM_CONDITIONAL(vm.playerDist < *(++insptr)); VM_CONDITIONAL(vm.playerDist < *(++insptr));
if (vm.playerDist > MAXSLEEPDIST && actor[vm.spriteNum].timetosleep == 0) if (vm.playerDist > MAXSLEEPDIST && vm.pActor->timetosleep == 0)
actor[vm.spriteNum].timetosleep = SLEEPTIME; vm.pActor->timetosleep = SLEEPTIME;
continue; continue;
case CON_IFPDISTG: case CON_IFPDISTG:
VM_CONDITIONAL(vm.playerDist > *(++insptr)); VM_CONDITIONAL(vm.playerDist > *(++insptr));
if (vm.playerDist > MAXSLEEPDIST && actor[vm.spriteNum].timetosleep == 0) if (vm.playerDist > MAXSLEEPDIST && vm.pActor->timetosleep == 0)
actor[vm.spriteNum].timetosleep = SLEEPTIME; vm.pActor->timetosleep = SLEEPTIME;
continue; continue;
case CON_ADDSTRENGTH: case CON_ADDSTRENGTH:
@ -1474,9 +1480,9 @@ skip_check:
{ {
if (vm.pSprite->pal == 1 && vm.pSprite->extra == 0) // hack for frozen if (vm.pSprite->pal == 1 && vm.pSprite->extra == 0) // hack for frozen
vm.pSprite->extra++; vm.pSprite->extra++;
vm.pSprite->pal = actor[vm.spriteNum].tempang; vm.pSprite->pal = vm.pActor->tempang;
} }
actor[vm.spriteNum].tempang = 0; vm.pActor->tempang = 0;
continue; continue;
case CON_TOSSWEAPON: case CON_TOSSWEAPON:
@ -1515,7 +1521,7 @@ skip_check:
vm.pSprite->xrepeat += ksgn(tw); vm.pSprite->xrepeat += ksgn(tw);
if ((vm.pSprite->picnum == APLAYER && vm.pSprite->yrepeat < 36) || *insptr < vm.pSprite->yrepeat || 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)) ((vm.pSprite->yrepeat*(tilesiz[vm.pSprite->picnum].y+8))<<2) < (vm.pActor->floorz - vm.pActor->ceilingz))
{ {
tw = ((*insptr)-vm.pSprite->yrepeat)<<1; tw = ((*insptr)-vm.pSprite->yrepeat)<<1;
if (klabs(tw)) vm.pSprite->yrepeat += ksgn(tw); if (klabs(tw)) vm.pSprite->yrepeat += ksgn(tw);
@ -1706,7 +1712,7 @@ skip_check:
case CON_SLEEPTIME: case CON_SLEEPTIME:
insptr++; insptr++;
actor[vm.spriteNum].timetosleep = (int16_t)*insptr++; vm.pActor->timetosleep = (int16_t)*insptr++;
continue; continue;
case CON_PAPER: case CON_PAPER:
@ -1717,7 +1723,7 @@ skip_check:
case CON_ADDKILLS: case CON_ADDKILLS:
insptr++; insptr++;
pPlayer->actors_killed += *insptr++; pPlayer->actors_killed += *insptr++;
actor[vm.spriteNum].actorstayput = -1; vm.pActor->actorstayput = -1;
continue; continue;
case CON_LOTSOFGLASS: case CON_LOTSOFGLASS:
@ -2339,8 +2345,8 @@ nullquote:
actor_t * const pActor = &actor[spriteNum]; actor_t * const pActor = &actor[spriteNum];
Bmemset(&pActor->t_data, 0, sizeof pActor->t_data); Bmemset(&pActor->t_data, 0, sizeof pActor->t_data);
pActor->lastvx = 0; pActor->lastv.x = 0;
pActor->lastvy = 0; pActor->lastv.y = 0;
pActor->timetosleep = 0; pActor->timetosleep = 0;
pActor->cgg = 0; pActor->cgg = 0;
pActor->movflag = 0; pActor->movflag = 0;
@ -3415,7 +3421,7 @@ nullquote:
case CON_IFWASWEAPON: case CON_IFWASWEAPON:
insptr++; insptr++;
VM_CONDITIONAL(actor[vm.spriteNum].picnum == *insptr); VM_CONDITIONAL(vm.pActor->picnum == *insptr);
continue; continue;
case CON_IFAI: case CON_IFAI:
@ -3662,7 +3668,7 @@ nullquote:
case CON_IFSPAWNEDBY: case CON_IFSPAWNEDBY:
insptr++; insptr++;
VM_CONDITIONAL(actor[vm.spriteNum].picnum == *insptr); VM_CONDITIONAL(vm.pActor->picnum == *insptr);
continue; continue;
case CON_WACKPLAYER: case CON_WACKPLAYER:
@ -3708,7 +3714,7 @@ nullquote:
case CON_IFGAPZL: case CON_IFGAPZL:
insptr++; insptr++;
VM_CONDITIONAL(((actor[vm.spriteNum].floorz - actor[vm.spriteNum].ceilingz) >> 8) < *insptr); VM_CONDITIONAL(((vm.pActor->floorz - vm.pActor->ceilingz) >> 8) < *insptr);
continue; continue;
case CON_IFHITSPACE: case CON_IFHITSPACE:
@ -3768,7 +3774,7 @@ nullquote:
case CON_SPRITEPAL: case CON_SPRITEPAL:
insptr++; insptr++;
if (vm.pSprite->picnum != APLAYER) if (vm.pSprite->picnum != APLAYER)
actor[vm.spriteNum].tempang = vm.pSprite->pal; vm.pActor->tempang = vm.pSprite->pal;
vm.pSprite->pal = *insptr++; vm.pSprite->pal = *insptr++;
continue; continue;
@ -3789,12 +3795,12 @@ nullquote:
case CON_IFFLOORDISTL: case CON_IFFLOORDISTL:
insptr++; insptr++;
VM_CONDITIONAL((actor[vm.spriteNum].floorz - vm.pSprite->z) <= ((*insptr)<<8)); VM_CONDITIONAL((vm.pActor->floorz - vm.pSprite->z) <= ((*insptr)<<8));
continue; continue;
case CON_IFCEILINGDISTL: case CON_IFCEILINGDISTL:
insptr++; insptr++;
VM_CONDITIONAL((vm.pSprite->z - actor[vm.spriteNum].ceilingz) <= ((*insptr)<<8)); VM_CONDITIONAL((vm.pSprite->z - vm.pActor->ceilingz) <= ((*insptr)<<8));
continue; continue;
case CON_PALFROM: case CON_PALFROM:
@ -4516,8 +4522,8 @@ finish_qsprintf:
case CON_GETANGLETOTARGET: case CON_GETANGLETOTARGET:
insptr++; insptr++;
// Actor[vm.spriteNum].lastvx and lastvy are last known location of target. // vm.pActor->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)); Gv_SetVarX(*insptr++, getangle(vm.pActor->lastv.x-vm.pSprite->x,vm.pActor->lastv.y-vm.pSprite->y));
continue; continue;
case CON_ANGOFFVAR: case CON_ANGOFFVAR:
@ -5676,7 +5682,7 @@ finish_qsprintf:
continue; continue;
case CON_IFNOTMOVING: case CON_IFNOTMOVING:
VM_CONDITIONAL((actor[vm.spriteNum].movflag&49152) > 16384); VM_CONDITIONAL((vm.pActor->movflag&49152) > 16384);
continue; continue;
case CON_RESPAWNHITAG: case CON_RESPAWNHITAG:
@ -5723,7 +5729,7 @@ finish_qsprintf:
case CON_SPRITEFLAGS: case CON_SPRITEFLAGS:
insptr++; insptr++;
actor[vm.spriteNum].flags = Gv_GetVarX(*insptr++); vm.pActor->flags = Gv_GetVarX(*insptr++);
continue; continue;
case CON_GETTICKS: case CON_GETTICKS:
@ -5825,7 +5831,7 @@ void VM_UpdateAnim(int spriteNum, int32_t *pData)
void A_Execute(int spriteNum, int playerNum, int playerDist) void A_Execute(int spriteNum, int playerNum, int playerDist)
{ {
vmstate_t tempvm = { vmstate_t tempvm = {
spriteNum, playerNum, playerDist, 0, &sprite[spriteNum], &actor[spriteNum].t_data[0], g_player[playerNum].ps spriteNum, playerNum, playerDist, 0, &sprite[spriteNum], &actor[spriteNum].t_data[0], g_player[playerNum].ps, &actor[spriteNum]
}; };
vm = tempvm; vm = tempvm;
@ -5905,9 +5911,9 @@ void A_Execute(int spriteNum, int playerNum, int playerDist)
case NUKEBARRELLEAKED__STATIC: case NUKEBARRELLEAKED__STATIC:
case TRIPBOMB__STATIC: case TRIPBOMB__STATIC:
case EGG__STATIC: case EGG__STATIC:
if (actor[vm.spriteNum].timetosleep > 1) if (vm.pActor->timetosleep > 1)
actor[vm.spriteNum].timetosleep--; vm.pActor->timetosleep--;
else if (actor[vm.spriteNum].timetosleep == 1) else if (vm.pActor->timetosleep == 1)
changespritestat(vm.spriteNum, STAT_ZOMBIEACTOR); changespritestat(vm.spriteNum, STAT_ZOMBIEACTOR);
default: break; default: break;
} }
@ -5925,9 +5931,9 @@ void A_Execute(int spriteNum, int playerNum, int playerDist)
if (A_CheckSpriteFlags(vm.spriteNum, SFLAG_USEACTIVATOR) && sector[vm.pSprite->sectnum].lotag & 16384) if (A_CheckSpriteFlags(vm.spriteNum, SFLAG_USEACTIVATOR) && sector[vm.pSprite->sectnum].lotag & 16384)
changespritestat(vm.spriteNum, STAT_ZOMBIEACTOR); changespritestat(vm.spriteNum, STAT_ZOMBIEACTOR);
else if (actor[vm.spriteNum].timetosleep > 1) else if (vm.pActor->timetosleep > 1)
actor[vm.spriteNum].timetosleep--; vm.pActor->timetosleep--;
else if (actor[vm.spriteNum].timetosleep == 1) else if (vm.pActor->timetosleep == 1)
{ {
// hack for 1.3D fire sprites // hack for 1.3D fire sprites
if (EDUKE32_PREDICT_FALSE(g_scriptVersion == 13 && (vm.pSprite->picnum == FIRE || vm.pSprite->picnum == FIRE2))) if (EDUKE32_PREDICT_FALSE(g_scriptVersion == 13 && (vm.pSprite->picnum == FIRE || vm.pSprite->picnum == FIRE2)))

View file

@ -49,9 +49,8 @@ void A_LoadActor(int32_t spriteNum);
void A_Execute(int spriteNum, int playerNum, int playerDist); void A_Execute(int spriteNum, int playerNum, int playerDist);
void A_Fall(int const spriteNum); void A_Fall(int const spriteNum);
int A_FurthestVisiblePoint(int const spriteNum, uspritetype * const ts,int32_t * const dax,int32_t * const day);
int32_t A_GetFurthestAngle(int const spriteNum, int const angDiv); int32_t A_GetFurthestAngle(int const spriteNum, int const angDiv);
void A_GetZLimits(int spriteNum); void A_GetZLimits(int const spriteNum);
int G_GetAngleDelta(int a, int na); int G_GetAngleDelta(int a, int na);
void G_RestoreMapState(); void G_RestoreMapState();
void G_SaveMapState(); void G_SaveMapState();
@ -106,7 +105,6 @@ static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNu
void G_GetTimeDate(int32_t * const pValues); void G_GetTimeDate(int32_t * const pValues);
int G_StartTrack(int const levelNum); int G_StartTrack(int const levelNum);
int32_t A_Dodge(spritetype *s);
#ifdef LUNATIC #ifdef LUNATIC
void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sect, 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); int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t unbiasedp);

View file

@ -302,8 +302,7 @@ int32_t __fastcall VM_GetActiveProjectile(int32_t const spriteNum, int32_t label
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES)) if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{ {
CON_ERRPRINTF("tried to get %s on invalid target projectile (%d) %d %d\n", CON_ERRPRINTF("%s invalid for projectile %d\n", ProjectileLabels[labelNum].name, spriteNum);
ProjectileLabels[labelNum].name,spriteNum,vm.spriteNum,TrackerCast(vm.pSprite->picnum));
return -1; return -1;
} }
@ -351,8 +350,7 @@ void __fastcall VM_SetActiveProjectile(int32_t const spriteNum, int32_t const la
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES)) if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{ {
CON_ERRPRINTF("tried to set %s on invalid target projectile (%d) %d %d\n", CON_ERRPRINTF("%s invalid for projectile %d\n", ProjectileLabels[labelNum].name, spriteNum);
ProjectileLabels[labelNum].name,spriteNum,vm.spriteNum,TrackerCast(vm.pSprite->picnum));
return; return;
} }
@ -396,18 +394,10 @@ void __fastcall VM_SetActiveProjectile(int32_t const spriteNum, int32_t const la
int32_t __fastcall VM_GetPlayer(int32_t const playerNum, int32_t labelNum, int32_t const lParm2) int32_t __fastcall VM_GetPlayer(int32_t const playerNum, int32_t labelNum, int32_t const lParm2)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) if (EDUKE32_PREDICT_FALSE(((unsigned) playerNum >= (unsigned) g_mostConcurrentPlayers)
|| (PlayerLabels[labelNum].flags & LABEL_HASPARM2 && (unsigned) lParm2 >= (unsigned) PlayerLabels[labelNum].maxParm2)))
{ {
CON_ERRPRINTF("tried to get %s on invalid target player (%d) from spr %d\n", CON_ERRPRINTF("%s[%d] invalid for player %d\n", PlayerLabels[labelNum].name, lParm2, playerNum);
PlayerLabels[labelNum].name,playerNum,vm.spriteNum);
return -1;
}
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[labelNum].name,lParm2,playerNum,vm.spriteNum);
return -1; return -1;
} }
@ -551,7 +541,6 @@ int32_t __fastcall VM_GetPlayer(int32_t const playerNum, int32_t labelNum, int32
case 0: labelNum = ps->pals.r; break; case 0: labelNum = ps->pals.r; break;
case 1: labelNum = ps->pals.g; break; case 1: labelNum = ps->pals.g; break;
case 2: labelNum = ps->pals.b; break; case 2: labelNum = ps->pals.b; break;
default: labelNum = -1; break;
} }
break; break;
case PLAYER_MAX_ACTORS_KILLED: labelNum = ps->max_actors_killed; break; case PLAYER_MAX_ACTORS_KILLED: labelNum = ps->max_actors_killed; break;
@ -581,19 +570,10 @@ int32_t __fastcall VM_GetPlayer(int32_t const playerNum, int32_t labelNum, int32
void __fastcall VM_SetPlayer(int32_t const playerNum, int32_t const labelNum, int32_t const lParm2, int32_t const iSet) void __fastcall VM_SetPlayer(int32_t const playerNum, int32_t const labelNum, int32_t const lParm2, int32_t const iSet)
{ {
if (EDUKE32_PREDICT_FALSE(((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)
if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) || (PlayerLabels[labelNum].flags & LABEL_HASPARM2 && (unsigned)lParm2 >= (unsigned)PlayerLabels[labelNum].maxParm2)))
{ {
CON_ERRPRINTF("tried to set %s on invalid target player (%d) from spr %d\n", CON_ERRPRINTF("%s[%d] invalid for player %d\n", PlayerLabels[labelNum].name, lParm2, playerNum);
PlayerLabels[labelNum].name,playerNum,vm.spriteNum);
return;
}
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[labelNum].name,lParm2,playerNum,vm.spriteNum);
return; return;
} }
@ -779,7 +759,7 @@ int32_t __fastcall VM_GetPlayerInput(int32_t const playerNum, int32_t labelNum)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers))
{ {
CON_ERRPRINTF("VM_GetPlayerInput: invalid target player (%d) %d\n", playerNum,vm.spriteNum); CON_ERRPRINTF("invalid player %d\n", playerNum);
return -1; return -1;
} }
@ -803,7 +783,7 @@ void __fastcall VM_SetPlayerInput(int32_t const playerNum, int32_t const labelNu
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers)) if (EDUKE32_PREDICT_FALSE((unsigned)playerNum >= (unsigned)g_mostConcurrentPlayers))
{ {
CON_ERRPRINTF("VM_SetPlayerInput: invalid target player (%d) %d\n", playerNum,vm.spriteNum); CON_ERRPRINTF("invalid player %d\n", playerNum);
return; return;
} }
@ -827,33 +807,33 @@ int32_t __fastcall VM_GetWall(int32_t const wallNum, int32_t labelNum)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls)) if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls))
{ {
CON_ERRPRINTF("VM_GetWall: Invalid wall %d\n", wallNum); CON_ERRPRINTF("invalid wall %d\n", wallNum);
return -1; return -1;
} }
walltype * const w = &wall[wallNum]; uwalltype const * const pWall = (uwalltype *)&wall[wallNum];
switch (labelNum) switch (labelNum)
{ {
case WALL_X: labelNum = w->x; break; case WALL_X: labelNum = pWall->x; break;
case WALL_Y: labelNum = w->y; break; case WALL_Y: labelNum = pWall->y; break;
case WALL_POINT2: labelNum = w->point2; break; case WALL_POINT2: labelNum = pWall->point2; break;
case WALL_NEXTWALL: labelNum = w->nextwall; break; case WALL_NEXTWALL: labelNum = pWall->nextwall; break;
case WALL_NEXTSECTOR: labelNum = w->nextsector; break; case WALL_NEXTSECTOR: labelNum = pWall->nextsector; break;
case WALL_CSTAT: labelNum = w->cstat; break; case WALL_CSTAT: labelNum = pWall->cstat; break;
case WALL_PICNUM: labelNum = w->picnum; break; case WALL_PICNUM: labelNum = pWall->picnum; break;
case WALL_OVERPICNUM: labelNum = w->overpicnum; break; case WALL_OVERPICNUM: labelNum = pWall->overpicnum; break;
case WALL_SHADE: labelNum = w->shade; break; case WALL_SHADE: labelNum = pWall->shade; break;
case WALL_PAL: labelNum = w->pal; break; case WALL_PAL: labelNum = pWall->pal; break;
case WALL_XREPEAT: labelNum = w->xrepeat; break; case WALL_XREPEAT: labelNum = pWall->xrepeat; break;
case WALL_YREPEAT: labelNum = w->yrepeat; break; case WALL_YREPEAT: labelNum = pWall->yrepeat; break;
case WALL_XPANNING: labelNum = w->xpanning; break; case WALL_XPANNING: labelNum = pWall->xpanning; break;
case WALL_YPANNING: labelNum = w->ypanning; break; case WALL_YPANNING: labelNum = pWall->ypanning; break;
case WALL_LOTAG: labelNum = (int16_t)w->lotag; break; case WALL_LOTAG: labelNum = (int16_t)pWall->lotag; break;
case WALL_HITAG: labelNum = (int16_t)w->hitag; break; case WALL_HITAG: labelNum = (int16_t)pWall->hitag; break;
case WALL_ULOTAG: labelNum = w->lotag; break; case WALL_ULOTAG: labelNum = pWall->lotag; break;
case WALL_UHITAG: labelNum = w->hitag; break; case WALL_UHITAG: labelNum = pWall->hitag; break;
case WALL_EXTRA: labelNum = w->extra; break; case WALL_EXTRA: labelNum = pWall->extra; break;
default: labelNum = -1; default: labelNum = -1;
} }
@ -864,33 +844,33 @@ void __fastcall VM_SetWall(int32_t const wallNum, int32_t const labelNum, int32_
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls)) if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls))
{ {
CON_ERRPRINTF("VM_SetWall: Invalid wall %d\n", wallNum); CON_ERRPRINTF("invalid wall %d\n", wallNum);
return; return;
} }
walltype * const w = &wall[wallNum]; walltype * const pWall = &wall[wallNum];
switch (labelNum) switch (labelNum)
{ {
case WALL_X: w->x = iSet; break; case WALL_X: pWall->x = iSet; break;
case WALL_Y: w->y = iSet; break; case WALL_Y: pWall->y = iSet; break;
case WALL_POINT2: w->point2 = iSet; break; case WALL_POINT2: pWall->point2 = iSet; break;
case WALL_NEXTWALL: w->nextwall = iSet; break; case WALL_NEXTWALL: pWall->nextwall = iSet; break;
case WALL_NEXTSECTOR: w->nextsector = iSet; break; case WALL_NEXTSECTOR: pWall->nextsector = iSet; break;
case WALL_CSTAT: w->cstat = iSet; break; case WALL_CSTAT: pWall->cstat = iSet; break;
case WALL_PICNUM: w->picnum = iSet; break; case WALL_PICNUM: pWall->picnum = iSet; break;
case WALL_OVERPICNUM: w->overpicnum = iSet; break; case WALL_OVERPICNUM: pWall->overpicnum = iSet; break;
case WALL_SHADE: w->shade = iSet; break; case WALL_SHADE: pWall->shade = iSet; break;
case WALL_PAL: w->pal = iSet; break; case WALL_PAL: pWall->pal = iSet; break;
case WALL_XREPEAT: w->xrepeat = iSet; break; case WALL_XREPEAT: pWall->xrepeat = iSet; break;
case WALL_YREPEAT: w->yrepeat = iSet; break; case WALL_YREPEAT: pWall->yrepeat = iSet; break;
case WALL_XPANNING: w->xpanning = iSet; break; case WALL_XPANNING: pWall->xpanning = iSet; break;
case WALL_YPANNING: w->ypanning = iSet; break; case WALL_YPANNING: pWall->ypanning = iSet; break;
case WALL_LOTAG: w->lotag = (int16_t)iSet; break; case WALL_LOTAG: pWall->lotag = (int16_t)iSet; break;
case WALL_HITAG: w->hitag = (int16_t)iSet; break; case WALL_HITAG: pWall->hitag = (int16_t)iSet; break;
case WALL_ULOTAG: w->lotag = iSet; break; case WALL_ULOTAG: pWall->lotag = iSet; break;
case WALL_UHITAG: w->hitag = iSet; break; case WALL_UHITAG: pWall->hitag = iSet; break;
case WALL_EXTRA: w->extra = iSet; break; case WALL_EXTRA: pWall->extra = iSet; break;
} }
return; return;
@ -900,46 +880,46 @@ int32_t __fastcall VM_GetSector(int32_t const sectNum, int32_t labelNum)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors)) if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
{ {
CON_ERRPRINTF("VM_GetSector: Invalid sector %d\n", sectNum); CON_ERRPRINTF("invalid sector %d\n", sectNum);
return -1; return -1;
} }
sectortype * const s = &sector[sectNum]; usectortype const * const pSector = (usectortype *)&sector[sectNum];
switch (labelNum) switch (labelNum)
{ {
case SECTOR_WALLPTR: labelNum = s->wallptr; break; case SECTOR_WALLPTR: labelNum = pSector->wallptr; break;
case SECTOR_WALLNUM: labelNum = s->wallnum; break; case SECTOR_WALLNUM: labelNum = pSector->wallnum; break;
case SECTOR_CEILINGZ: labelNum = s->ceilingz; break; case SECTOR_CEILINGZ: labelNum = pSector->ceilingz; break;
case SECTOR_CEILINGZVEL: labelNum = (GetAnimationGoal(&s->ceilingz) == -1) ? 0 : s->extra; break; case SECTOR_CEILINGZVEL: labelNum = (GetAnimationGoal(&pSector->ceilingz) == -1) ? 0 : pSector->extra; break;
case SECTOR_CEILINGZGOAL: labelNum = GetAnimationGoal(&s->ceilingz); break; case SECTOR_CEILINGZGOAL: labelNum = GetAnimationGoal(&pSector->ceilingz); break;
case SECTOR_FLOORZ: labelNum = s->floorz; break; case SECTOR_FLOORZ: labelNum = pSector->floorz; break;
case SECTOR_FLOORZVEL: labelNum = (GetAnimationGoal(&s->floorz) == -1) ? 0 : s->extra; break; case SECTOR_FLOORZVEL: labelNum = (GetAnimationGoal(&pSector->floorz) == -1) ? 0 : pSector->extra; break;
case SECTOR_FLOORZGOAL: labelNum = GetAnimationGoal(&s->floorz); break; case SECTOR_FLOORZGOAL: labelNum = GetAnimationGoal(&pSector->floorz); break;
case SECTOR_CEILINGSTAT: labelNum = s->ceilingstat; break; case SECTOR_CEILINGSTAT: labelNum = pSector->ceilingstat; break;
case SECTOR_FLOORSTAT: labelNum = s->floorstat; break; case SECTOR_FLOORSTAT: labelNum = pSector->floorstat; break;
case SECTOR_CEILINGPICNUM: labelNum = s->ceilingpicnum; break; case SECTOR_CEILINGPICNUM: labelNum = pSector->ceilingpicnum; break;
case SECTOR_CEILINGSLOPE: labelNum = s->ceilingheinum; break; case SECTOR_CEILINGSLOPE: labelNum = pSector->ceilingheinum; break;
case SECTOR_CEILINGSHADE: labelNum = s->ceilingshade; break; case SECTOR_CEILINGSHADE: labelNum = pSector->ceilingshade; break;
case SECTOR_CEILINGPAL: labelNum = s->ceilingpal; break; case SECTOR_CEILINGPAL: labelNum = pSector->ceilingpal; break;
case SECTOR_CEILINGXPANNING: labelNum = s->ceilingxpanning; break; case SECTOR_CEILINGXPANNING: labelNum = pSector->ceilingxpanning; break;
case SECTOR_CEILINGYPANNING: labelNum = s->ceilingypanning; break; case SECTOR_CEILINGYPANNING: labelNum = pSector->ceilingypanning; break;
case SECTOR_FLOORPICNUM: labelNum = s->floorpicnum; break; case SECTOR_FLOORPICNUM: labelNum = pSector->floorpicnum; break;
case SECTOR_FLOORSLOPE: labelNum = s->floorheinum; break; case SECTOR_FLOORSLOPE: labelNum = pSector->floorheinum; break;
case SECTOR_FLOORSHADE: labelNum = s->floorshade; break; case SECTOR_FLOORSHADE: labelNum = pSector->floorshade; break;
case SECTOR_FLOORPAL: labelNum = s->floorpal; break; case SECTOR_FLOORPAL: labelNum = pSector->floorpal; break;
case SECTOR_FLOORXPANNING: labelNum = s->floorxpanning; break; case SECTOR_FLOORXPANNING: labelNum = pSector->floorxpanning; break;
case SECTOR_FLOORYPANNING: labelNum = s->floorypanning; break; case SECTOR_FLOORYPANNING: labelNum = pSector->floorypanning; break;
case SECTOR_VISIBILITY: labelNum = s->visibility; break; case SECTOR_VISIBILITY: labelNum = pSector->visibility; break;
case SECTOR_FOGPAL: labelNum = s->fogpal; break; case SECTOR_FOGPAL: labelNum = pSector->fogpal; break;
case SECTOR_LOTAG: labelNum = (int16_t)s->lotag; break; case SECTOR_LOTAG: labelNum = (int16_t)pSector->lotag; break;
case SECTOR_HITAG: labelNum = (int16_t)s->hitag; break; case SECTOR_HITAG: labelNum = (int16_t)pSector->hitag; break;
case SECTOR_ULOTAG: labelNum = s->lotag; break; case SECTOR_ULOTAG: labelNum = pSector->lotag; break;
case SECTOR_UHITAG: labelNum = s->hitag; break; case SECTOR_UHITAG: labelNum = pSector->hitag; break;
case SECTOR_EXTRA: labelNum = s->extra; break; case SECTOR_EXTRA: labelNum = pSector->extra; break;
case SECTOR_CEILINGBUNCH: case SECTOR_CEILINGBUNCH:
case SECTOR_FLOORBUNCH: case SECTOR_FLOORBUNCH:
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
@ -958,52 +938,52 @@ void __fastcall VM_SetSector(int32_t const sectNum, int32_t const labelNum, int3
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors)) if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
{ {
CON_ERRPRINTF("VM_SetSector: Invalid sector %d\n", sectNum); CON_ERRPRINTF("invalid sector %d\n", sectNum);
return; return;
} }
sectortype * const s = &sector[sectNum]; sectortype * const pSector = &sector[sectNum];
switch (labelNum) switch (labelNum)
{ {
case SECTOR_WALLPTR: s->wallptr = iSet; break; case SECTOR_WALLPTR: pSector->wallptr = iSet; break;
case SECTOR_WALLNUM: s->wallnum = iSet; break; case SECTOR_WALLNUM: pSector->wallnum = iSet; break;
case SECTOR_CEILINGZ: s->ceilingz = iSet; break; case SECTOR_CEILINGZ: pSector->ceilingz = iSet; break;
case SECTOR_CEILINGZVEL: s->extra = iSet; case SECTOR_CEILINGZVEL: pSector->extra = iSet;
if ((iSet = GetAnimationGoal(&s->ceilingz)) != -1) if ((iSet = GetAnimationGoal(&pSector->ceilingz)) != -1)
case SECTOR_CEILINGZGOAL: case SECTOR_CEILINGZGOAL:
SetAnimation(sectNum, &s->ceilingz, iSet, s->extra); SetAnimation(sectNum, &pSector->ceilingz, iSet, pSector->extra);
break; break;
case SECTOR_FLOORZ: s->floorz = iSet; break; case SECTOR_FLOORZ: pSector->floorz = iSet; break;
case SECTOR_FLOORZVEL: s->extra = iSet; case SECTOR_FLOORZVEL: pSector->extra = iSet;
if ((iSet = GetAnimationGoal(&s->floorz)) != -1) if ((iSet = GetAnimationGoal(&pSector->floorz)) != -1)
case SECTOR_FLOORZGOAL: case SECTOR_FLOORZGOAL:
SetAnimation(sectNum, &s->floorz, iSet, s->extra); SetAnimation(sectNum, &pSector->floorz, iSet, pSector->extra);
break; break;
case SECTOR_CEILINGSTAT: s->ceilingstat = iSet; break; case SECTOR_CEILINGSTAT: pSector->ceilingstat = iSet; break;
case SECTOR_FLOORSTAT: s->floorstat = iSet; break; case SECTOR_FLOORSTAT: pSector->floorstat = iSet; break;
case SECTOR_CEILINGPICNUM: s->ceilingpicnum = iSet; break; case SECTOR_CEILINGPICNUM: pSector->ceilingpicnum = iSet; break;
case SECTOR_CEILINGSLOPE: s->ceilingheinum = iSet; break; case SECTOR_CEILINGSLOPE: pSector->ceilingheinum = iSet; break;
case SECTOR_CEILINGSHADE: s->ceilingshade = iSet; break; case SECTOR_CEILINGSHADE: pSector->ceilingshade = iSet; break;
case SECTOR_CEILINGPAL: s->ceilingpal = iSet; break; case SECTOR_CEILINGPAL: pSector->ceilingpal = iSet; break;
case SECTOR_CEILINGXPANNING: s->ceilingxpanning = iSet; break; case SECTOR_CEILINGXPANNING: pSector->ceilingxpanning = iSet; break;
case SECTOR_CEILINGYPANNING: s->ceilingypanning = iSet; break; case SECTOR_CEILINGYPANNING: pSector->ceilingypanning = iSet; break;
case SECTOR_FLOORPICNUM: s->floorpicnum = iSet; break; case SECTOR_FLOORPICNUM: pSector->floorpicnum = iSet; break;
case SECTOR_FLOORSLOPE: s->floorheinum = iSet; break; case SECTOR_FLOORSLOPE: pSector->floorheinum = iSet; break;
case SECTOR_FLOORSHADE: s->floorshade = iSet; break; case SECTOR_FLOORSHADE: pSector->floorshade = iSet; break;
case SECTOR_FLOORPAL: s->floorpal = iSet; break; case SECTOR_FLOORPAL: pSector->floorpal = iSet; break;
case SECTOR_FLOORXPANNING: s->floorxpanning = iSet; break; case SECTOR_FLOORXPANNING: pSector->floorxpanning = iSet; break;
case SECTOR_FLOORYPANNING: s->floorypanning = iSet; break; case SECTOR_FLOORYPANNING: pSector->floorypanning = iSet; break;
case SECTOR_VISIBILITY: s->visibility = iSet; break; case SECTOR_VISIBILITY: pSector->visibility = iSet; break;
case SECTOR_FOGPAL: s->fogpal = iSet; break; case SECTOR_FOGPAL: pSector->fogpal = iSet; break;
case SECTOR_LOTAG: s->lotag = (int16_t) iSet; break; case SECTOR_LOTAG: pSector->lotag = (int16_t) iSet; break;
case SECTOR_HITAG: s->hitag = (int16_t) iSet; break; case SECTOR_HITAG: pSector->hitag = (int16_t) iSet; break;
case SECTOR_ULOTAG: s->lotag = iSet; break; case SECTOR_ULOTAG: pSector->lotag = iSet; break;
case SECTOR_UHITAG: s->hitag = iSet; break; case SECTOR_UHITAG: pSector->hitag = iSet; break;
case SECTOR_EXTRA: s->extra = iSet; break; case SECTOR_EXTRA: pSector->extra = iSet; break;
case SECTOR_CEILINGBUNCH: case SECTOR_CEILINGBUNCH:
case SECTOR_FLOORBUNCH: case SECTOR_FLOORBUNCH:
default: break; default: break;
@ -1012,17 +992,10 @@ void __fastcall VM_SetSector(int32_t const sectNum, int32_t const labelNum, int3
void __fastcall VM_SetSprite(int32_t const spriteNum, int32_t const labelNum, int32_t const lParm2, int32_t const iSet) void __fastcall VM_SetSprite(int32_t const spriteNum, int32_t const labelNum, int32_t const lParm2, int32_t const iSet)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES)) if (EDUKE32_PREDICT_FALSE(((unsigned)spriteNum >= MAXSPRITES) ||
(ActorLabels[labelNum].flags & LABEL_HASPARM2 && (unsigned)lParm2 >= (unsigned)ActorLabels[labelNum].maxParm2)))
{ {
CON_ERRPRINTF("tried to set %s on invalid target sprite (%d) from spr %d pic %d\n", CON_ERRPRINTF("%s[%d] invalid for sprite %d\n", ActorLabels[labelNum].name, lParm2, spriteNum);
ActorLabels[labelNum].name,spriteNum,vm.spriteNum,TrackerCast(vm.pSprite->picnum));
return;
}
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[labelNum].name,lParm2,spriteNum,vm.spriteNum);
return; return;
} }
@ -1065,8 +1038,8 @@ void __fastcall VM_SetSprite(int32_t const spriteNum, int32_t const labelNum, in
case ACTOR_HTTIMETOSLEEP: actor[spriteNum].timetosleep = iSet; break; case ACTOR_HTTIMETOSLEEP: actor[spriteNum].timetosleep = iSet; break;
case ACTOR_HTFLOORZ: actor[spriteNum].floorz = iSet; break; case ACTOR_HTFLOORZ: actor[spriteNum].floorz = iSet; break;
case ACTOR_HTCEILINGZ: actor[spriteNum].ceilingz = iSet; break; case ACTOR_HTCEILINGZ: actor[spriteNum].ceilingz = iSet; break;
case ACTOR_HTLASTVX: actor[spriteNum].lastvx = iSet; break; case ACTOR_HTLASTVX: actor[spriteNum].lastv.x = iSet; break;
case ACTOR_HTLASTVY: actor[spriteNum].lastvy = iSet; break; case ACTOR_HTLASTVY: actor[spriteNum].lastv.y = iSet; break;
case ACTOR_HTBPOSX: actor[spriteNum].bpos.x = iSet; break; case ACTOR_HTBPOSX: actor[spriteNum].bpos.x = iSet; break;
case ACTOR_HTBPOSY: actor[spriteNum].bpos.y = iSet; break; case ACTOR_HTBPOSY: actor[spriteNum].bpos.y = iSet; break;
case ACTOR_HTBPOSZ: actor[spriteNum].bpos.z = iSet; break; case ACTOR_HTBPOSZ: actor[spriteNum].bpos.z = iSet; break;
@ -1089,18 +1062,10 @@ void __fastcall VM_SetSprite(int32_t const spriteNum, int32_t const labelNum, in
int32_t __fastcall VM_GetSprite(int32_t const spriteNum, int32_t labelNum, int32_t const lParm2) int32_t __fastcall VM_GetSprite(int32_t const spriteNum, int32_t labelNum, int32_t const lParm2)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES)) if (EDUKE32_PREDICT_FALSE(((unsigned) spriteNum >= MAXSPRITES) ||
(ActorLabels[labelNum].flags & LABEL_HASPARM2 && (unsigned) lParm2 >= (unsigned) ActorLabels[labelNum].maxParm2)))
{ {
CON_ERRPRINTF("tried to get %s on invalid target sprite (%d) from spr %d pic %d\n", CON_ERRPRINTF("%s[%d] invalid for sprite %d\n", ActorLabels[labelNum].name, lParm2, spriteNum);
ActorLabels[labelNum].name,spriteNum,vm.spriteNum,TrackerCast(vm.pSprite->picnum));
return -1;
}
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[labelNum].name,lParm2,spriteNum,vm.spriteNum);
return -1; return -1;
} }
@ -1143,8 +1108,8 @@ int32_t __fastcall VM_GetSprite(int32_t const spriteNum, int32_t labelNum, int32
case ACTOR_HTTIMETOSLEEP: labelNum = actor[spriteNum].timetosleep; break; case ACTOR_HTTIMETOSLEEP: labelNum = actor[spriteNum].timetosleep; break;
case ACTOR_HTFLOORZ: labelNum = actor[spriteNum].floorz; break; case ACTOR_HTFLOORZ: labelNum = actor[spriteNum].floorz; break;
case ACTOR_HTCEILINGZ: labelNum = actor[spriteNum].ceilingz; break; case ACTOR_HTCEILINGZ: labelNum = actor[spriteNum].ceilingz; break;
case ACTOR_HTLASTVX: labelNum = actor[spriteNum].lastvx; break; case ACTOR_HTLASTVX: labelNum = actor[spriteNum].lastv.x; break;
case ACTOR_HTLASTVY: labelNum = actor[spriteNum].lastvy; break; case ACTOR_HTLASTVY: labelNum = actor[spriteNum].lastv.y; break;
case ACTOR_HTBPOSX: labelNum = actor[spriteNum].bpos.x; break; case ACTOR_HTBPOSX: labelNum = actor[spriteNum].bpos.x; break;
case ACTOR_HTBPOSY: labelNum = actor[spriteNum].bpos.y; break; case ACTOR_HTBPOSY: labelNum = actor[spriteNum].bpos.y; break;
case ACTOR_HTBPOSZ: labelNum = actor[spriteNum].bpos.z; break; case ACTOR_HTBPOSZ: labelNum = actor[spriteNum].bpos.z; break;
@ -1171,17 +1136,15 @@ int32_t __fastcall VM_GetTsprite(int32_t const spriteNum, int32_t labelNum)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES)) if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{ {
CON_ERRPRINTF("VM_GetTsprite: invalid target sprite (%d) %d %d\n", spriteNum, vm.spriteNum, TrackerCast(vm.pSprite->picnum)); error:
CON_ERRPRINTF("invalid sprite %d or no tsprite\n", spriteNum);
return -1; return -1;
} }
uspritetype * const tspr = spriteext[spriteNum].tspr; uspritetype const * const tspr = spriteext[spriteNum].tspr;
if (EDUKE32_PREDICT_FALSE(!tspr)) if (EDUKE32_PREDICT_FALSE(!tspr))
{ goto error;
CON_ERRPRINTF("VM_GetTsprite: Internal bug, tsprite is unavailable\n");
return -1;
}
switch (labelNum) switch (labelNum)
{ {
@ -1220,17 +1183,15 @@ void __fastcall VM_SetTsprite(int32_t const spriteNum, int32_t const labelNum, i
{ {
if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum >= MAXSPRITES)) if (EDUKE32_PREDICT_FALSE((unsigned) spriteNum >= MAXSPRITES))
{ {
CON_ERRPRINTF("VM_SetTsprite: invalid target sprite (%d) %d %d\n", spriteNum, vm.spriteNum, TrackerCast(vm.pSprite->picnum)); error:
CON_ERRPRINTF("invalid sprite %d or no tsprite\n", spriteNum);
return; return;
} }
uspritetype * const tspr = spriteext[spriteNum].tspr; uspritetype * const tspr = spriteext[spriteNum].tspr;
if (EDUKE32_PREDICT_FALSE(!tspr)) if (EDUKE32_PREDICT_FALSE(!tspr))
{ goto error;
CON_ERRPRINTF("VM_SetTsprite: Internal bug, tsprite is unavailable\n");
return;
}
switch (labelNum) switch (labelNum)
{ {
@ -1266,17 +1227,15 @@ int32_t __fastcall VM_GetProjectile(int32_t const tileNum, int32_t labelNum)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)tileNum >= MAXTILES)) if (EDUKE32_PREDICT_FALSE((unsigned)tileNum >= MAXTILES))
{ {
CON_ERRPRINTF("VM_GetProjectile: invalid projectile (%d)\n", tileNum); error:
CON_ERRPRINTF("invalid projectile %d\n", tileNum);
return -1; return -1;
} }
projectile_t * const proj = g_tile[tileNum].proj; projectile_t const * const proj = g_tile[tileNum].proj;
if (EDUKE32_PREDICT_FALSE(!proj)) if (EDUKE32_PREDICT_FALSE(!proj))
{ goto error;
CON_ERRPRINTF("VM_GetProjectile: no projectile defined for tile %d\n", tileNum);
return -1;
}
switch (labelNum) switch (labelNum)
{ {
@ -1320,17 +1279,15 @@ void __fastcall VM_SetProjectile(int32_t const tileNum, int32_t const labelNum,
{ {
if (EDUKE32_PREDICT_FALSE((unsigned) tileNum >= MAXTILES)) if (EDUKE32_PREDICT_FALSE((unsigned) tileNum >= MAXTILES))
{ {
CON_ERRPRINTF("VM_SetProjectile: invalid projectile (%d)\n", tileNum); error:
CON_ERRPRINTF("invalid projectile %d\n", tileNum);
return; return;
} }
projectile_t * const proj = g_tile[tileNum].proj; projectile_t * const proj = g_tile[tileNum].proj;
if (EDUKE32_PREDICT_FALSE(!proj)) if (EDUKE32_PREDICT_FALSE(!proj))
{ goto error;
CON_ERRPRINTF("VM_SetProjectile: no projectile defined for tile %d\n", tileNum);
return;
}
switch (labelNum) switch (labelNum)
{ {
@ -1371,7 +1328,7 @@ int32_t __fastcall VM_GetTileData(int32_t const tileNum, int32_t labelNum)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)tileNum >= MAXTILES)) if (EDUKE32_PREDICT_FALSE((unsigned)tileNum >= MAXTILES))
{ {
CON_ERRPRINTF("VM_GetTileData: invalid tile (%d)\n", tileNum); CON_ERRPRINTF("invalid tile %d\n", tileNum);
return -1; return -1;
} }
@ -1398,14 +1355,13 @@ int32_t __fastcall VM_GetPalData(int32_t const palNum, int32_t labelNum)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned)palNum >= MAXPALOOKUPS)) if (EDUKE32_PREDICT_FALSE((unsigned)palNum >= MAXPALOOKUPS))
{ {
CON_ERRPRINTF("VM_GetPalData: invalid pal (%d)\n", palNum); CON_ERRPRINTF("invalid palette %d\n", palNum);
return -1; return -1;
} }
switch (labelNum) switch (labelNum)
{ {
case PALDATA_NOFLOORPAL: labelNum = g_noFloorPal[palNum]; break; case PALDATA_NOFLOORPAL: labelNum = g_noFloorPal[palNum]; break;
default: labelNum = -1; break; default: labelNum = -1; break;
} }

View file

@ -1263,8 +1263,8 @@ void Net_CopyToNet(int32_t i, netactor_t *netactor)
netactor->timetosleep = actor[i].timetosleep; netactor->timetosleep = actor[i].timetosleep;
netactor->flags = actor[i].flags; netactor->flags = actor[i].flags;
netactor->floorz = actor[i].floorz; netactor->floorz = actor[i].floorz;
netactor->lastvx = actor[i].lastvx; netactor->lastv.x = actor[i].lastv.x;
netactor->lastvy = actor[i].lastvy; netactor->lastv.y = actor[i].lastv.y;
netactor->lasttransport = actor[i].lasttransport; netactor->lasttransport = actor[i].lasttransport;
netactor->actorstayput = actor[i].actorstayput; netactor->actorstayput = actor[i].actorstayput;
netactor->cgg = actor[i].cgg; netactor->cgg = actor[i].cgg;
@ -1303,8 +1303,8 @@ void Net_CopyFromNet(int32_t i, netactor_t *netactor)
actor[i].timetosleep = netactor->timetosleep; actor[i].timetosleep = netactor->timetosleep;
actor[i].flags = netactor->flags; actor[i].flags = netactor->flags;
actor[i].floorz = netactor->floorz; actor[i].floorz = netactor->floorz;
actor[i].lastvx = netactor->lastvx; actor[i].lastv.x = netactor->lastv.x;
actor[i].lastvy = netactor->lastvy; actor[i].lastv.y = netactor->lastv.y;
actor[i].lasttransport = netactor->lasttransport; actor[i].lasttransport = netactor->lasttransport;
actor[i].actorstayput = netactor->actorstayput; actor[i].actorstayput = netactor->actorstayput;
actor[i].cgg = netactor->cgg; actor[i].cgg = netactor->cgg;
@ -1331,8 +1331,8 @@ int32_t Net_ActorsAreDifferent(netactor_t *actor1, netactor_t *actor2)
//actor1->timetosleep != actor2->timetosleep || //actor1->timetosleep != actor2->timetosleep ||
actor1->flags != actor2->flags || actor1->flags != actor2->flags ||
actor1->floorz != actor2->floorz || actor1->floorz != actor2->floorz ||
actor1->lastvx != actor2->lastvx || actor1->lastv.x != actor2->lastv.x ||
actor1->lastvy != actor2->lastvy || actor1->lastv.y != actor2->lastv.y ||
actor1->lasttransport != actor2->lasttransport || actor1->lasttransport != actor2->lasttransport ||
actor1->actorstayput != actor2->actorstayput || actor1->actorstayput != actor2->actorstayput ||
//actor1->cgg != actor2->cgg || //actor1->cgg != actor2->cgg ||