mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 19:20:46 +00:00
gameexec: for VM_Fall and VM_ResetPlayer, pass VM sprite/player etc. as args.
Simplifying VM_FallSprite and VM_ResetPlayer2 used from Lunatic. git-svn-id: https://svn.eduke32.com/eduke32@3460 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
8e0c7b133e
commit
46fc753f6a
2 changed files with 71 additions and 68 deletions
|
@ -56,12 +56,11 @@ enum vmflags_t {
|
||||||
|
|
||||||
vmstate_t vm;
|
vmstate_t vm;
|
||||||
|
|
||||||
int32_t g_errorLineNum;
|
#if !defined LUNATIC
|
||||||
int32_t g_tw;
|
int32_t g_tw;
|
||||||
|
int32_t g_errorLineNum;
|
||||||
int32_t g_currentEventExec = -1;
|
int32_t g_currentEventExec = -1;
|
||||||
|
|
||||||
#if !defined LUNATIC
|
|
||||||
GAMEEXEC_STATIC void VM_Execute(int32_t loop);
|
GAMEEXEC_STATIC void VM_Execute(int32_t loop);
|
||||||
|
|
||||||
# include "gamestructures.c"
|
# include "gamestructures.c"
|
||||||
|
@ -812,76 +811,76 @@ static int32_t VM_AddWeapon(int32_t weap, int32_t amount, DukePlayer_t *ps)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void VM_Fall()
|
static void VM_Fall(int32_t g_i, spritetype *g_sp)
|
||||||
{
|
{
|
||||||
vm.g_sp->xoffset = vm.g_sp->yoffset = 0;
|
g_sp->xoffset = g_sp->yoffset = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t j = g_spriteGravity;
|
int32_t j = g_spriteGravity;
|
||||||
|
|
||||||
if (G_CheckForSpaceCeiling(vm.g_sp->sectnum) || sector[vm.g_sp->sectnum].lotag == ST_2_UNDERWATER)
|
if (G_CheckForSpaceCeiling(g_sp->sectnum) || sector[g_sp->sectnum].lotag == ST_2_UNDERWATER)
|
||||||
j = g_spriteGravity/6;
|
j = g_spriteGravity/6;
|
||||||
else if (G_CheckForSpaceFloor(vm.g_sp->sectnum))
|
else if (G_CheckForSpaceFloor(g_sp->sectnum))
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
if (!actor[vm.g_i].cgg-- || (sector[vm.g_sp->sectnum].floorstat&2))
|
if (!actor[g_i].cgg-- || (sector[g_sp->sectnum].floorstat&2))
|
||||||
{
|
{
|
||||||
A_GetZLimits(vm.g_i);
|
A_GetZLimits(g_i);
|
||||||
actor[vm.g_i].cgg = 3;
|
actor[g_i].cgg = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.g_sp->z < (actor[vm.g_i].floorz-ZOFFSET))
|
if (g_sp->z < (actor[g_i].floorz-ZOFFSET))
|
||||||
{
|
{
|
||||||
vm.g_sp->z += vm.g_sp->zvel = min(6144, vm.g_sp->zvel+j);
|
g_sp->z += g_sp->zvel = min(6144, g_sp->zvel+j);
|
||||||
#ifdef YAX_ENABLE
|
#ifdef YAX_ENABLE
|
||||||
j = yax_getbunch(vm.g_sp->sectnum, YAX_FLOOR);
|
j = yax_getbunch(g_sp->sectnum, YAX_FLOOR);
|
||||||
if (j >= 0 && (sector[vm.g_sp->sectnum].floorstat&512)==0)
|
if (j >= 0 && (sector[g_sp->sectnum].floorstat&512)==0)
|
||||||
setspritez(vm.g_i, (vec3_t *)vm.g_sp);
|
setspritez(g_i, (vec3_t *)g_sp);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (vm.g_sp->z > (actor[vm.g_i].floorz - ZOFFSET))
|
if (g_sp->z > (actor[g_i].floorz - ZOFFSET))
|
||||||
vm.g_sp->z = (actor[vm.g_i].floorz - ZOFFSET);
|
g_sp->z = (actor[g_i].floorz - ZOFFSET);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vm.g_sp->z = actor[vm.g_i].floorz - ZOFFSET;
|
g_sp->z = actor[g_i].floorz - ZOFFSET;
|
||||||
|
|
||||||
if (A_CheckEnemySprite(vm.g_sp) || (vm.g_sp->picnum == APLAYER && vm.g_sp->owner >= 0))
|
if (A_CheckEnemySprite(g_sp) || (g_sp->picnum == APLAYER && g_sp->owner >= 0))
|
||||||
{
|
{
|
||||||
if (vm.g_sp->zvel > 3084 && vm.g_sp->extra <= 1)
|
if (g_sp->zvel > 3084 && g_sp->extra <= 1)
|
||||||
{
|
{
|
||||||
// I'm guessing this DRONE check is from a beta version of the game
|
// I'm guessing this DRONE check is from a beta version of the game
|
||||||
// where they crashed into the ground when killed
|
// where they crashed into the ground when killed
|
||||||
if (!(vm.g_sp->picnum == APLAYER && vm.g_sp->extra > 0) && vm.g_sp->pal != 1 && vm.g_sp->picnum != DRONE)
|
if (!(g_sp->picnum == APLAYER && g_sp->extra > 0) && g_sp->pal != 1 && g_sp->picnum != DRONE)
|
||||||
{
|
{
|
||||||
A_DoGuts(vm.g_i,JIBS6,15);
|
A_DoGuts(g_i,JIBS6,15);
|
||||||
A_PlaySound(SQUISHED,vm.g_i);
|
A_PlaySound(SQUISHED,g_i);
|
||||||
A_Spawn(vm.g_i,BLOODPOOL);
|
A_Spawn(g_i,BLOODPOOL);
|
||||||
}
|
}
|
||||||
actor[vm.g_i].picnum = SHOTSPARK1;
|
actor[g_i].picnum = SHOTSPARK1;
|
||||||
actor[vm.g_i].extra = 1;
|
actor[g_i].extra = 1;
|
||||||
vm.g_sp->zvel = 0;
|
g_sp->zvel = 0;
|
||||||
}
|
}
|
||||||
else if (vm.g_sp->zvel > 2048 && sector[vm.g_sp->sectnum].lotag != ST_1_ABOVE_WATER)
|
else if (g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != ST_1_ABOVE_WATER)
|
||||||
{
|
{
|
||||||
j = vm.g_sp->sectnum;
|
j = g_sp->sectnum;
|
||||||
pushmove((vec3_t *)vm.g_sp,(int16_t *)&j,128L,(4L<<8),(4L<<8),CLIPMASK0);
|
pushmove((vec3_t *)g_sp,(int16_t *)&j,128L,(4L<<8),(4L<<8),CLIPMASK0);
|
||||||
if ((unsigned)j < MAXSECTORS)
|
if ((unsigned)j < MAXSECTORS)
|
||||||
changespritesect(vm.g_i,j);
|
changespritesect(g_i,j);
|
||||||
A_PlaySound(THUD,vm.g_i);
|
A_PlaySound(THUD,g_i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.g_sp->z > (actor[vm.g_i].floorz - ZOFFSET))
|
if (g_sp->z > (actor[g_i].floorz - ZOFFSET))
|
||||||
{
|
{
|
||||||
A_GetZLimits(vm.g_i);
|
A_GetZLimits(g_i);
|
||||||
if (actor[vm.g_i].floorz != sector[vm.g_sp->sectnum].floorz)
|
if (actor[g_i].floorz != sector[g_sp->sectnum].floorz)
|
||||||
vm.g_sp->z = (actor[vm.g_i].floorz - ZOFFSET);
|
g_sp->z = (actor[g_i].floorz - ZOFFSET);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (sector[vm.g_sp->sectnum].lotag == ST_1_ABOVE_WATER)
|
else if (sector[g_sp->sectnum].lotag == ST_1_ABOVE_WATER)
|
||||||
{
|
{
|
||||||
switch (DYNAMICTILEMAP(vm.g_sp->picnum))
|
switch (DYNAMICTILEMAP(g_sp->picnum))
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
// fix for flying/jumping monsters getting stuck in water
|
// fix for flying/jumping monsters getting stuck in water
|
||||||
|
@ -890,12 +889,12 @@ static void VM_Fall()
|
||||||
int32_t moveScriptOfs = vm.g_t[1];
|
int32_t moveScriptOfs = vm.g_t[1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((vm.g_sp->hitag & jumptoplayer) ||
|
if ((g_sp->hitag & jumptoplayer) ||
|
||||||
(G_HaveActor(vm.g_sp->picnum) &&
|
(G_HaveActor(g_sp->picnum) &&
|
||||||
#if !defined LUNATIC
|
#if !defined LUNATIC
|
||||||
(unsigned)moveScriptOfs < (unsigned)g_scriptSize-1 && script[moveScriptOfs + 1]
|
(unsigned)moveScriptOfs < (unsigned)g_scriptSize-1 && script[moveScriptOfs + 1]
|
||||||
#else
|
#else
|
||||||
actor[vm.g_i].mv.vvel != 0
|
actor[g_i].mv.vvel != 0
|
||||||
#endif
|
#endif
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
|
@ -904,8 +903,8 @@ static void VM_Fall()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// OSD_Printf("hitag: %d\n",vm.g_sp->hitag);
|
// OSD_Printf("hitag: %d\n",g_sp->hitag);
|
||||||
vm.g_sp->z += (24<<8);
|
g_sp->z += (24<<8);
|
||||||
case OCTABRAIN__STATIC:
|
case OCTABRAIN__STATIC:
|
||||||
case COMMANDER__STATIC:
|
case COMMANDER__STATIC:
|
||||||
case DRONE__STATIC:
|
case DRONE__STATIC:
|
||||||
|
@ -914,44 +913,45 @@ static void VM_Fall()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.g_sp->zvel = 0;
|
g_sp->zvel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void VM_ResetPlayer(void)
|
static int32_t VM_ResetPlayer(int32_t g_p, int32_t g_flags)
|
||||||
{
|
{
|
||||||
//AddLog("resetplayer");
|
//AddLog("resetplayer");
|
||||||
if ((!g_netServer && ud.multimode < 2))
|
if (!g_netServer && ud.multimode < 2)
|
||||||
{
|
{
|
||||||
if (g_lastSaveSlot >= 0 && ud.recstat != 2)
|
if (g_lastSaveSlot >= 0 && ud.recstat != 2)
|
||||||
{
|
{
|
||||||
g_player[vm.g_p].ps->gm |= MODE_MENU;
|
g_player[g_p].ps->gm |= MODE_MENU;
|
||||||
KB_ClearKeyDown(sc_Space);
|
KB_ClearKeyDown(sc_Space);
|
||||||
M_ChangeMenu(15000);
|
M_ChangeMenu(15000);
|
||||||
}
|
}
|
||||||
else g_player[vm.g_p].ps->gm = MODE_RESTART;
|
else g_player[g_p].ps->gm = MODE_RESTART;
|
||||||
vm.g_flags |= VM_NOEXECUTE;
|
|
||||||
|
g_flags |= VM_NOEXECUTE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (vm.g_p == myconnectindex)
|
if (g_p == myconnectindex)
|
||||||
{
|
{
|
||||||
CAMERADIST = 0;
|
CAMERADIST = 0;
|
||||||
CAMERACLOCK = totalclock;
|
CAMERACLOCK = totalclock;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_fakeMultiMode)
|
if (g_fakeMultiMode)
|
||||||
P_ResetPlayer(vm.g_p);
|
P_ResetPlayer(g_p);
|
||||||
#ifndef NETCODE_DISABLE
|
#ifndef NETCODE_DISABLE
|
||||||
if (g_netServer)
|
if (g_netServer)
|
||||||
{
|
{
|
||||||
int32_t jj = 0;
|
int32_t jj = 0;
|
||||||
|
|
||||||
P_ResetPlayer(vm.g_p);
|
P_ResetPlayer(g_p);
|
||||||
|
|
||||||
packbuf[jj++] = PACKET_PLAYER_SPAWN;
|
packbuf[jj++] = PACKET_PLAYER_SPAWN;
|
||||||
packbuf[jj++] = vm.g_p;
|
packbuf[jj++] = g_p;
|
||||||
|
|
||||||
Bmemcpy(&packbuf[jj], &g_player[vm.g_p].ps->pos.x, sizeof(vec3_t) * 2);
|
Bmemcpy(&packbuf[jj], &g_player[g_p].ps->pos.x, sizeof(vec3_t) * 2);
|
||||||
jj += sizeof(vec3_t) * 2;
|
jj += sizeof(vec3_t) * 2;
|
||||||
|
|
||||||
packbuf[jj++] = 0;
|
packbuf[jj++] = 0;
|
||||||
|
@ -961,8 +961,11 @@ static void VM_ResetPlayer(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
P_UpdateScreenPal(g_player[vm.g_p].ps);
|
|
||||||
|
P_UpdateScreenPal(g_player[g_p].ps);
|
||||||
//AddLog("EOF: resetplayer");
|
//AddLog("EOF: resetplayer");
|
||||||
|
|
||||||
|
return g_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined LUNATIC
|
#if !defined LUNATIC
|
||||||
|
@ -1433,7 +1436,7 @@ skip_check:
|
||||||
|
|
||||||
case CON_FALL:
|
case CON_FALL:
|
||||||
insptr++;
|
insptr++;
|
||||||
VM_Fall();
|
VM_Fall(vm.g_i, vm.g_sp);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case CON_RETURN:
|
case CON_RETURN:
|
||||||
|
@ -3137,7 +3140,7 @@ nullquote:
|
||||||
case CON_RESETPLAYER:
|
case CON_RESETPLAYER:
|
||||||
{
|
{
|
||||||
insptr++;
|
insptr++;
|
||||||
VM_ResetPlayer();
|
vm.g_flags = VM_ResetPlayer(vm.g_p, vm.g_flags);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -5312,8 +5315,10 @@ void G_SaveMapState(mapstate_t *save)
|
||||||
Bmemcpy(&save->sprite[0],&sprite[0],sizeof(spritetype)*MAXSPRITES);
|
Bmemcpy(&save->sprite[0],&sprite[0],sizeof(spritetype)*MAXSPRITES);
|
||||||
|
|
||||||
// If we're in EVENT_ANIMATESPRITES, we'll be saving pointer values to disk :-/
|
// If we're in EVENT_ANIMATESPRITES, we'll be saving pointer values to disk :-/
|
||||||
|
#if !defined LUNATIC
|
||||||
if (g_currentEventExec == EVENT_ANIMATESPRITES)
|
if (g_currentEventExec == EVENT_ANIMATESPRITES)
|
||||||
initprintf("Line %d: savemapstate called from EVENT_ANIMATESPRITES. WHY?\n", g_errorLineNum);
|
initprintf("Line %d: savemapstate called from EVENT_ANIMATESPRITES. WHY?\n", g_errorLineNum);
|
||||||
|
#endif
|
||||||
Bmemcpy(&save->spriteext[0],&spriteext[0],sizeof(spriteext_t)*MAXSPRITES);
|
Bmemcpy(&save->spriteext[0],&spriteext[0],sizeof(spriteext_t)*MAXSPRITES);
|
||||||
|
|
||||||
save->numsprites = Numsprites;
|
save->numsprites = Numsprites;
|
||||||
|
@ -5412,13 +5417,14 @@ void G_RestoreMapState(mapstate_t *save)
|
||||||
|
|
||||||
// If we're restoring from EVENT_ANIMATESPRITES, all spriteext[].tspr
|
// If we're restoring from EVENT_ANIMATESPRITES, all spriteext[].tspr
|
||||||
// will be overwritten, so NULL them.
|
// will be overwritten, so NULL them.
|
||||||
|
#if !defined LUNATIC
|
||||||
if (g_currentEventExec == EVENT_ANIMATESPRITES)
|
if (g_currentEventExec == EVENT_ANIMATESPRITES)
|
||||||
{
|
{
|
||||||
initprintf("Line %d: loadmapstate called from EVENT_ANIMATESPRITES. WHY?\n",g_errorLineNum);
|
initprintf("Line %d: loadmapstate called from EVENT_ANIMATESPRITES. WHY?\n",g_errorLineNum);
|
||||||
for (i=0; i<MAXSPRITES; i++)
|
for (i=0; i<MAXSPRITES; i++)
|
||||||
spriteext[i].tspr = NULL;
|
spriteext[i].tspr = NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
Numsprites = save->numsprites;
|
Numsprites = save->numsprites;
|
||||||
tailspritefree = save->tailspritefree;
|
tailspritefree = save->tailspritefree;
|
||||||
Bmemcpy(&headspritesect[0],&save->headspritesect[0],sizeof(headspritesect));
|
Bmemcpy(&headspritesect[0],&save->headspritesect[0],sizeof(headspritesect));
|
||||||
|
@ -5534,16 +5540,11 @@ void G_RestoreMapState(mapstate_t *save)
|
||||||
#ifdef LUNATIC
|
#ifdef LUNATIC
|
||||||
void VM_FallSprite(int32_t i)
|
void VM_FallSprite(int32_t i)
|
||||||
{
|
{
|
||||||
vm.g_i = i;
|
VM_Fall(i, &sprite[i]);
|
||||||
vm.g_sp = &sprite[i];
|
|
||||||
VM_Fall();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t VM_ResetPlayer2(int32_t snum)
|
int32_t VM_ResetPlayer2(int32_t snum)
|
||||||
{
|
{
|
||||||
vm.g_p = snum;
|
return VM_ResetPlayer(snum, 0);
|
||||||
vm.g_flags &= ~VM_NOEXECUTE;
|
|
||||||
VM_ResetPlayer();
|
|
||||||
return (vm.g_flags&VM_NOEXECUTE);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -128,12 +128,14 @@ enum GameEvent_t {
|
||||||
MAXEVENTS
|
MAXEVENTS
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int32_t g_errorLineNum;
|
|
||||||
extern int32_t g_tw;
|
|
||||||
extern int32_t ticrandomseed;
|
extern int32_t ticrandomseed;
|
||||||
extern vmstate_t vm;
|
|
||||||
|
|
||||||
|
extern vmstate_t vm;
|
||||||
|
#if !defined LUNATIC
|
||||||
|
extern int32_t g_tw;
|
||||||
|
extern int32_t g_errorLineNum;
|
||||||
extern int32_t g_currentEventExec;
|
extern int32_t g_currentEventExec;
|
||||||
|
#endif
|
||||||
|
|
||||||
void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist);
|
void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist);
|
||||||
void A_Fall(int32_t iActor);
|
void A_Fall(int32_t iActor);
|
||||||
|
|
Loading…
Reference in a new issue