Mainly misc cleanups (and a fix for the C++ build), but there are a few important changes in here.

VM_OnEvent() has become VM_OnEvent(), VM_OnEventWithReturn(), VM_OnEventWithDist(), and VM_OnEventWithBoth() (the latter of which is only ever used once...). Of course, this required every call to VM_OnEvent() be changed.

memberlabel_t and vmstate_t have been changed to use the regular "int" type versus explicitly specifying int32_t as they did previously. The rationale for this change is simply that it looks cleaner, and I think we should move toward just using "int" in most cases where there's no particular reason to specify an explicit data type.

Also changes CON_KILLIT to just "return" instead of "continue". DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@4745 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2014-11-22 12:29:25 +00:00
parent 9b91aac48c
commit bf3c0de73a
13 changed files with 369 additions and 343 deletions

View file

@ -592,38 +592,35 @@ void A_DeleteSprite(int32_t s)
{ {
if (EDUKE32_PREDICT_FALSE(block_deletesprite)) 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", s);
return; return;
} }
if (VM_HaveEvent(EVENT_KILLIT)) if (VM_HaveEvent(EVENT_KILLIT))
{ {
int32_t p, pl=A_FindPlayer(&sprite[s],&p); int32_t p, pl = A_FindPlayer(&sprite[s], &p);
if (VM_OnEvent_(EVENT_KILLIT, s, pl, p, 0)) if (VM_OnEventWithDist_(EVENT_KILLIT, s, pl, p))
return; return;
} }
#ifdef POLYMER #ifdef POLYMER
if (getrendermode() == REND_POLYMER && actor[s].lightptr != NULL) if (actor[s].lightptr != NULL && getrendermode() == REND_POLYMER)
A_DeleteLight(s); A_DeleteLight(s);
#endif #endif
if (sprite[s].picnum == MUSICANDSFX && actor[s].t_data[0]==1) // AMBIENT_SFX_PLAYING
{ if (sprite[s].picnum == MUSICANDSFX && actor[s].t_data[0] == 1)
// AMBIENT_SFX_PLAYING
S_StopEnvSound(sprite[s].lotag, s); S_StopEnvSound(sprite[s].lotag, s);
}
// NetAlloc // NetAlloc
if (Net_IsRelevantSprite(s)) if (Net_IsRelevantSprite(s))
{ {
Net_DeleteSprite(s); Net_DeleteSprite(s);
return;
} }
else
{ deletesprite(s);
deletesprite(s);
}
} }
void A_AddToDeleteQueue(int32_t i) void A_AddToDeleteQueue(int32_t i)
@ -727,9 +724,10 @@ LUNATIC_EXTERN int32_t G_ToggleWallInterpolation(int32_t w, int32_t doset)
} }
} }
static void Sect_ToggleInterpolation(int32_t sectnum, int32_t doset) void Sect_ToggleInterpolation(int sectnum, int doset)
{ {
int32_t k, j = sector[sectnum].wallptr, endwall = j+sector[sectnum].wallnum; int k, j = sector[sectnum].wallptr;
const int endwall = sector[sectnum].wallptr + sector[sectnum].wallnum;
for (; j<endwall; j++) for (; j<endwall; j++)
{ {
@ -744,24 +742,14 @@ static void Sect_ToggleInterpolation(int32_t sectnum, int32_t doset)
} }
} }
void Sect_SetInterpolation(int32_t sectnum)
{
Sect_ToggleInterpolation(sectnum, 1);
}
void Sect_ClearInterpolation(int32_t sectnum)
{
Sect_ToggleInterpolation(sectnum, 0);
}
static int32_t move_rotfixed_sprite(int32_t j, int32_t pivotspr, int32_t daang) static int32_t move_rotfixed_sprite(int32_t j, int32_t pivotspr, int32_t daang)
{ {
if ((ROTFIXSPR_STATNUMP(sprite[j].statnum) || if ((ROTFIXSPR_STATNUMP(sprite[j].statnum) ||
((sprite[j].statnum==STAT_ACTOR || sprite[j].statnum==STAT_ZOMBIEACTOR) && ((sprite[j].statnum == STAT_ACTOR || sprite[j].statnum == STAT_ZOMBIEACTOR) &&
A_CheckSpriteTileFlags(sprite[j].picnum, SFLAG_ROTFIXED))) A_CheckSpriteTileFlags(sprite[j].picnum, SFLAG_ROTFIXED))) &&
&& actor[j].t_data[7]==(ROTFIXSPR_MAGIC|pivotspr)) actor[j].t_data[7] == (ROTFIXSPR_MAGIC | pivotspr))
{ {
rotatepoint(0,0, actor[j].t_data[8],actor[j].t_data[9], daang&2047, &sprite[j].x,&sprite[j].y); rotatepoint(0, 0, actor[j].t_data[8], actor[j].t_data[9], daang & 2047, &sprite[j].x, &sprite[j].y);
sprite[j].x += sprite[pivotspr].x; sprite[j].x += sprite[pivotspr].x;
sprite[j].y += sprite[pivotspr].y; sprite[j].y += sprite[pivotspr].y;
return 0; return 0;
@ -770,42 +758,39 @@ static int32_t move_rotfixed_sprite(int32_t j, int32_t pivotspr, int32_t daang)
return 1; return 1;
} }
static void A_MoveSector(int32_t i) static void A_MoveSector(int i)
{ {
//T1,T2 and T3 are used for all the sector moving stuff!!! // T1,T2 and T3 are used for all the sector moving stuff!!!
spritetype * const s = &sprite[i];
int j = T2, k = T3;
int32_t tx, ty;
int32_t tx,ty; s->x += (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14;
spritetype *s = &sprite[i]; s->y += (s->xvel * (sintable[s->ang & 2047])) >> 14;
int32_t j = T2, k = T3;
s->x += (s->xvel*(sintable[(s->ang+512)&2047]))>>14; const int endwall = sector[s->sectnum].wallptr + sector[s->sectnum].wallnum;
s->y += (s->xvel*(sintable[s->ang&2047]))>>14;
for (i = sector[s->sectnum].wallptr; i < endwall; i++)
{ {
int32_t x = sector[s->sectnum].wallptr, endwall = x+sector[s->sectnum].wallnum; rotatepoint(0, 0, msx[j], msy[j], k & 2047, &tx, &ty);
dragpoint(i, s->x + tx, s->y + ty, 0);
for (; x<endwall; x++) j++;
{
rotatepoint(0,0,msx[j],msy[j],k&2047,&tx,&ty);
dragpoint(x,s->x+tx,s->y+ty,0);
j++;
}
} }
} }
#if !defined LUNATIC #if !defined LUNATIC
// NOTE: T5 is AC_ACTION_ID // 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 ? *(script + T5) + (*(script + T5 + 2)) * AC_CURFRAME(actor[i].t_data) : 0)
#else #else
// startframe + viewtype*[cyclic counter] // startframe + viewtype*[cyclic counter]
# define LIGHTRAD_PICOFS (actor[i].ac.startframe + actor[i].ac.viewtype*AC_CURFRAME(actor[i].t_data)) # define LIGHTRAD_PICOFS (actor[i].ac.startframe + actor[i].ac.viewtype * AC_CURFRAME(actor[i].t_data))
#endif #endif
// this is the same crap as in game.c's tspr manipulation. puke. // this is the same crap as in game.c's tspr manipulation. puke.
// XXX: may access tilesizy out-of-bounds by bad user code. // XXX: may access tilesizy out-of-bounds by bad user code.
#define LIGHTRAD (s->yrepeat * tilesiz[s->picnum + LIGHTRAD_PICOFS].y) #define LIGHTRAD (s->yrepeat * tilesiz[s->picnum + LIGHTRAD_PICOFS].y)
#define LIGHTRAD2 (((s->yrepeat) + (rand()%(s->yrepeat>>2))) * tilesiz[s->picnum + LIGHTRAD_PICOFS].y) #define LIGHTRAD2 (((s->yrepeat) + (rand() % (s->yrepeat >> 2))) * tilesiz[s->picnum + LIGHTRAD_PICOFS].y)
void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t range, int32_t color, int32_t priority) void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t range, int32_t color, int32_t priority)
{ {
@ -817,7 +802,7 @@ void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t
if (actor[srcsprite].lightptr == NULL) if (actor[srcsprite].lightptr == NULL)
{ {
#pragma pack(push,1) #pragma pack(push, 1)
_prlight mylight; _prlight mylight;
#pragma pack(pop) #pragma pack(pop)
Bmemset(&mylight, 0, sizeof(mylight)); Bmemset(&mylight, 0, sizeof(mylight));
@ -825,10 +810,10 @@ void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t
mylight.sector = s->sectnum; mylight.sector = s->sectnum;
mylight.x = s->x; mylight.x = s->x;
mylight.y = s->y; mylight.y = s->y;
mylight.z = s->z-zoffset; mylight.z = s->z - zoffset;
mylight.color[0] = color&255; mylight.color[0] = color & 255;
mylight.color[1] = (color>>8)&255; mylight.color[1] = (color >> 8) & 255;
mylight.color[2] = (color>>16)&255; mylight.color[2] = (color >> 16) & 255;
mylight.radius = radius; mylight.radius = radius;
actor[srcsprite].lightmaxrange = mylight.range = range; actor[srcsprite].lightmaxrange = mylight.range = range;
@ -846,12 +831,11 @@ void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t
s->z -= zoffset; s->z -= zoffset;
if (range < actor[srcsprite].lightmaxrange>>1) if (range<actor[srcsprite].lightmaxrange>> 1)
actor[srcsprite].lightmaxrange = 0; actor[srcsprite].lightmaxrange = 0;
if (range > actor[srcsprite].lightmaxrange || if (range > actor[srcsprite].lightmaxrange || priority != actor[srcsprite].lightptr->priority ||
priority != actor[srcsprite].lightptr->priority || Bmemcmp(&sprite[srcsprite], actor[srcsprite].lightptr, sizeof(int32_t) * 3))
Bmemcmp(&sprite[srcsprite], actor[srcsprite].lightptr, sizeof(int32_t) * 3))
{ {
if (range > actor[srcsprite].lightmaxrange) if (range > actor[srcsprite].lightmaxrange)
actor[srcsprite].lightmaxrange = range; actor[srcsprite].lightmaxrange = range;
@ -863,9 +847,9 @@ void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zoffset, int32_t
actor[srcsprite].lightptr->priority = priority; actor[srcsprite].lightptr->priority = priority;
actor[srcsprite].lightptr->range = range; actor[srcsprite].lightptr->range = range;
actor[srcsprite].lightptr->color[0] = color&255; actor[srcsprite].lightptr->color[0] = color & 255;
actor[srcsprite].lightptr->color[1] = (color>>8)&255; actor[srcsprite].lightptr->color[1] = (color >> 8) & 255;
actor[srcsprite].lightptr->color[2] = (color>>16)&255; actor[srcsprite].lightptr->color[2] = (color >> 16) & 255;
s->z += zoffset; s->z += zoffset;
@ -986,21 +970,19 @@ ACTOR_STATIC void G_MoveZombieActors(void)
} }
// stupid name, but it's what the function does. // stupid name, but it's what the function does.
static inline int32_t G_FindExplosionInSector(int32_t sectnum) FORCE_INLINE int G_FindExplosionInSector(int sectnum)
{ {
int32_t i; for (int SPRITES_OF(STAT_MISC, i))
for (SPRITES_OF(STAT_MISC, i))
if (PN == EXPLOSION2 && sectnum == SECT) if (PN == EXPLOSION2 && sectnum == SECT)
return i; return i;
return -1; return -1;
} }
static void P_Nudge(int32_t p, int32_t sn, int32_t shl) FORCE_INLINE void P_Nudge(int p, int sn, int shl)
{ {
g_player[p].ps->vel.x += actor[sn].extra*(sintable[(actor[sn].ang+512)&2047])<<shl; 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[p].ps->vel.y += actor[sn].extra * (sintable[actor[sn].ang & 2047]) << shl;
} }
int32_t A_IncurDamage(int32_t sn) int32_t A_IncurDamage(int32_t sn)
@ -1017,9 +999,10 @@ int32_t A_IncurDamage(int32_t sn)
if (targ->picnum == APLAYER) if (targ->picnum == APLAYER)
{ {
int32_t p = P_GetP(targ); const int p = P_GetP(targ);
if (ud.god && dmg->picnum != SHRINKSPARK) return -1; if (ud.god && dmg->picnum != SHRINKSPARK)
return -1;
if (dmg->owner >= 0 && ud.ffire == 0 && sprite[dmg->owner].picnum == APLAYER && if (dmg->owner >= 0 && ud.ffire == 0 && sprite[dmg->owner].picnum == APLAYER &&
(GametypeFlags[ud.coop] & GAMETYPE_PLAYERSFRIENDLY || (GametypeFlags[ud.coop] & GAMETYPE_PLAYERSFRIENDLY ||
@ -1044,30 +1027,31 @@ int32_t A_IncurDamage(int32_t sn)
switch (DYNAMICTILEMAP(dmg->picnum)) switch (DYNAMICTILEMAP(dmg->picnum))
{ {
case RADIUSEXPLOSION__STATIC: case RADIUSEXPLOSION__STATIC:
case RPG__STATIC: case RPG__STATIC:
case HYDRENT__STATIC: case HYDRENT__STATIC:
case HEAVYHBOMB__STATIC: case HEAVYHBOMB__STATIC:
case SEENINE__STATIC: case SEENINE__STATIC:
case OOZFILTER__STATIC: case OOZFILTER__STATIC:
case EXPLODINGBARREL__STATIC: case EXPLODINGBARREL__STATIC:
P_Nudge(p, sn, 2);
break;
default:
if (A_CheckSpriteTileFlags(dmg->picnum, SFLAG_PROJECTILE) && (SpriteProjectile[sn].workslike & PROJECTILE_RPG))
P_Nudge(p, sn, 2); P_Nudge(p, sn, 2);
else P_Nudge(p, sn, 1); break;
break;
default:
if (A_CheckSpriteTileFlags(dmg->picnum, SFLAG_PROJECTILE) &&
(SpriteProjectile[sn].workslike & PROJECTILE_RPG))
P_Nudge(p, sn, 2);
else
P_Nudge(p, sn, 1);
break;
} }
dmg->extra = -1; dmg->extra = -1;
return dmg->picnum; return dmg->picnum;
} }
if (dmg->extra == 0) if (dmg->extra == 0 && dmg->picnum == SHRINKSPARK && targ->xrepeat < 24)
if (dmg->picnum == SHRINKSPARK && targ->xrepeat < 24) return -1;
return -1;
targ->extra -= dmg->extra; targ->extra -= dmg->extra;
@ -1075,6 +1059,7 @@ int32_t A_IncurDamage(int32_t sn)
targ->owner = dmg->owner; targ->owner = dmg->owner;
dmg->extra = -1; dmg->extra = -1;
return dmg->picnum; return dmg->picnum;
} }
@ -8278,7 +8263,7 @@ void G_MoveWorld(void)
} }
pl = A_FindPlayer(&sprite[i], &p); pl = A_FindPlayer(&sprite[i], &p);
VM_OnEvent_(EVENT_PREGAME, i, pl, p, 0); VM_OnEventWithDist_(EVENT_PREGAME, i, pl, p);
i = j; i = j;
} }
@ -8330,7 +8315,7 @@ void G_MoveWorld(void)
j = nextspritestat[i]; j = nextspritestat[i];
pl = A_FindPlayer(&sprite[i], &p); pl = A_FindPlayer(&sprite[i], &p);
VM_OnEvent_(EVENT_GAME, i, pl, p, 0); VM_OnEventWithDist_(EVENT_GAME, i, pl, p);
i = j; i = j;
} }

View file

@ -326,8 +326,9 @@ int32_t G_SetInterpolation(int32_t *posptr);
void G_StopInterpolation(int32_t *posptr); void G_StopInterpolation(int32_t *posptr);
// PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly // PK 20110701: changed input argument: int32_t i (== sprite, whose sectnum...) --> sectnum directly
void Sect_ClearInterpolation(int32_t sectnum); void Sect_ToggleInterpolation(int sectnum, int doset);
void Sect_SetInterpolation(int32_t sectnum); FORCE_INLINE void Sect_ClearInterpolation(int sectnum) { Sect_ToggleInterpolation(sectnum, 0); }
FORCE_INLINE void Sect_SetInterpolation(int sectnum) { Sect_ToggleInterpolation(sectnum, 1); }
#include "actors_inline.h" #include "actors_inline.h"

View file

@ -3676,7 +3676,7 @@ void G_DisplayRest(int32_t smoothratio)
if (pp->invdisptime > 0) G_DrawInventory(pp); if (pp->invdisptime > 0) G_DrawInventory(pp);
if (VM_OnEvent(EVENT_DISPLAYSBAR, g_player[screenpeek].ps->i, screenpeek, -1, 0) == 0) if (VM_OnEvent(EVENT_DISPLAYSBAR, g_player[screenpeek].ps->i, screenpeek) == 0)
G_DrawStatusBar(screenpeek); G_DrawStatusBar(screenpeek);
#ifdef SPLITSCREEN_MOD_HACKS #ifdef SPLITSCREEN_MOD_HACKS
@ -3740,13 +3740,13 @@ void G_DisplayRest(int32_t smoothratio)
if (VM_HaveEvent(EVENT_DISPLAYREST)) if (VM_HaveEvent(EVENT_DISPLAYREST))
{ {
int32_t vr=viewingrange, asp=yxaspect; int32_t vr=viewingrange, asp=yxaspect;
VM_OnEvent_(EVENT_DISPLAYREST, g_player[screenpeek].ps->i, screenpeek, -1, 0); VM_OnEvent_(EVENT_DISPLAYREST, g_player[screenpeek].ps->i, screenpeek);
setaspect(vr, asp); setaspect(vr, asp);
} }
if (g_player[myconnectindex].ps->newowner == -1 && ud.overhead_on == 0 && ud.crosshair && ud.camerasprite == -1) if (g_player[myconnectindex].ps->newowner == -1 && ud.overhead_on == 0 && ud.crosshair && ud.camerasprite == -1)
{ {
int32_t a = VM_OnEvent(EVENT_DISPLAYCROSSHAIR, g_player[screenpeek].ps->i, screenpeek, -1, 0); int32_t a = VM_OnEvent(EVENT_DISPLAYCROSSHAIR, g_player[screenpeek].ps->i, screenpeek);
if (a == 0 || a > 1) if (a == 0 || a > 1)
{ {
@ -4010,7 +4010,7 @@ void G_DrawBackground(void)
// when not rendering a game, fullscreen wipe // when not rendering a game, fullscreen wipe
// Gv_SetVar(g_iReturnVarID,tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE, -1, -1); // Gv_SetVar(g_iReturnVarID,tilesizx[MENUTILE]==320&&tilesizy[MENUTILE]==200?MENUTILE:BIGHOLE, -1, -1);
bgtile = VM_OnEvent(EVENT_GETMENUTILE, -1, myconnectindex, -1, bgtile); bgtile = VM_OnEventWithReturn(EVENT_GETMENUTILE, -1, myconnectindex, bgtile);
// MENU_TILE: is the menu tile tileable? // MENU_TILE: is the menu tile tileable?
#if !defined LUNATIC #if !defined LUNATIC
if (Gv_GetVarByLabel("MENU_TILE", !fstilep, -1, -1)) if (Gv_GetVarByLabel("MENU_TILE", !fstilep, -1, -1))
@ -4670,7 +4670,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio)
dont_draw = 0; dont_draw = 0;
// NOTE: might be rendering off-screen here, so CON commands that draw stuff // NOTE: might be rendering off-screen here, so CON commands that draw stuff
// like showview must cope with that situation or bail out! // like showview must cope with that situation or bail out!
dont_draw = VM_OnEvent(EVENT_DISPLAYROOMS, g_player[screenpeek].ps->i, screenpeek, -1, 0); dont_draw = VM_OnEvent(EVENT_DISPLAYROOMS, g_player[screenpeek].ps->i, screenpeek);
CAMERA(horiz) = clamp(CAMERA(horiz), HORIZ_MIN, HORIZ_MAX); CAMERA(horiz) = clamp(CAMERA(horiz), HORIZ_MIN, HORIZ_MAX);
@ -5035,7 +5035,7 @@ int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int3
int32_t pl=A_FindPlayer(s, &p); int32_t pl=A_FindPlayer(s, &p);
block_deletesprite++; block_deletesprite++;
VM_OnEvent_(EVENT_EGS, i, pl, p, 0); VM_OnEventWithDist_(EVENT_EGS, i, pl, p);
block_deletesprite--; block_deletesprite--;
} }
@ -7035,7 +7035,7 @@ SPAWN_END:
{ {
int32_t p; int32_t p;
int32_t pl=A_FindPlayer(&sprite[i],&p); int32_t pl=A_FindPlayer(&sprite[i],&p);
VM_OnEvent_(EVENT_SPAWN,i, pl, p, 0); VM_OnEventWithDist_(EVENT_SPAWN,i, pl, p);
} }
return i; return i;
@ -7165,7 +7165,7 @@ static void G_DoEventAnimSprites(int32_t j)
spriteext[ow].tspr = &tsprite[j]; spriteext[ow].tspr = &tsprite[j];
// XXX: wouldn't screenpeek be more meaningful as current player? // XXX: wouldn't screenpeek be more meaningful as current player?
VM_OnEvent_(EVENT_ANIMATESPRITES, ow, myconnectindex, -1, 0); VM_OnEvent_(EVENT_ANIMATESPRITES, ow, myconnectindex);
spriteext[ow].tspr = NULL; spriteext[ow].tspr = NULL;
} }
@ -8023,7 +8023,7 @@ skip:
} }
#ifdef LUNATIC #ifdef LUNATIC
VM_OnEvent(EVENT_ANIMATEALLSPRITES, -1, -1, -1, 0); VM_OnEvent(EVENT_ANIMATEALLSPRITES, -1, -1);
#endif #endif
#ifdef DEBUGGINGAIDS #ifdef DEBUGGINGAIDS
g_spriteStat.numonscreen = spritesortcnt; g_spriteStat.numonscreen = spritesortcnt;
@ -8065,7 +8065,7 @@ char CheatStrings[][MAXCHEATLEN] =
static void doinvcheat(int32_t invidx, int32_t defaultnum, int32_t event) static void doinvcheat(int32_t invidx, int32_t defaultnum, int32_t event)
{ {
defaultnum = VM_OnEvent(event, g_player[myconnectindex].ps->i, myconnectindex, -1, defaultnum); defaultnum = VM_OnEventWithReturn(event, g_player[myconnectindex].ps->i, myconnectindex, defaultnum);
if (defaultnum >= 0) if (defaultnum >= 0)
g_player[myconnectindex].ps->inv_amount[invidx] = defaultnum; g_player[myconnectindex].ps->inv_amount[invidx] = defaultnum;
} }
@ -8156,7 +8156,7 @@ GAME_STATIC void G_DoCheats(void)
FOUNDCHEAT: FOUNDCHEAT:
i = VM_OnEvent(EVENT_ACTIVATECHEAT, g_player[myconnectindex].ps->i, myconnectindex, -1, k); i = VM_OnEventWithReturn(EVENT_ACTIVATECHEAT, g_player[myconnectindex].ps->i, myconnectindex, k);
if (k != CHEAT_COMEGETSOME) // Users are not allowed to interfere with TX's debugging cheat. if (k != CHEAT_COMEGETSOME) // Users are not allowed to interfere with TX's debugging cheat.
k = i; k = i;
@ -10603,7 +10603,7 @@ static void G_DisplayLogo(void)
#ifdef LUNATIC #ifdef LUNATIC
g_elEventError = 0; g_elEventError = 0;
#endif #endif
VM_OnEvent(EVENT_LOGO, -1, screenpeek, -1, 0); VM_OnEvent(EVENT_LOGO, -1, screenpeek);
G_HandleAsync(); G_HandleAsync();
if (g_restorePalette) if (g_restorePalette)
@ -10755,7 +10755,7 @@ static void G_CompileScripts(void)
Bmemset(sector, 0, MAXSECTORS*sizeof(sectortype)); Bmemset(sector, 0, MAXSECTORS*sizeof(sectortype));
Bmemset(wall, 0, MAXWALLS*sizeof(walltype)); Bmemset(wall, 0, MAXWALLS*sizeof(walltype));
VM_OnEvent(EVENT_INIT, -1, -1, -1, 0); VM_OnEvent(EVENT_INIT, -1, -1);
pathsearchmode = psm; pathsearchmode = psm;
#endif #endif
} }
@ -10904,7 +10904,7 @@ static void G_Startup(void)
#ifdef LUNATIC #ifdef LUNATIC
// NOTE: This is only effective for CON-defined EVENT_INIT. See EVENT_INIT // NOTE: This is only effective for CON-defined EVENT_INIT. See EVENT_INIT
// not in defs.ilua. // not in defs.ilua.
VM_OnEvent(EVENT_INIT, -1, -1, -1, 0); VM_OnEvent(EVENT_INIT, -1, -1);
#endif #endif
if (g_netServer || ud.multimode > 1) G_CheckGametype(); if (g_netServer || ud.multimode > 1) G_CheckGametype();
@ -12827,7 +12827,7 @@ void G_BonusScreen(int32_t bonusonly)
else else
break; break;
VM_OnEvent(EVENT_DISPLAYBONUSSCREEN, g_player[screenpeek].ps->i, screenpeek, -1, 0); VM_OnEvent(EVENT_DISPLAYBONUSSCREEN, g_player[screenpeek].ps->i, screenpeek);
nextpage(); nextpage();
} }
while (1); while (1);

View file

@ -76,9 +76,7 @@ extern intptr_t *g_scriptPtr;
typedef struct typedef struct
{ {
const char *name; const char *name;
int32_t lId; int lId, flags, maxParm2;
int32_t flags;
int32_t maxParm2;
} memberlabel_t; } memberlabel_t;
extern const memberlabel_t SectorLabels[]; extern const memberlabel_t SectorLabels[];
@ -96,10 +94,10 @@ void C_InitQuotes(void);
void C_InitProjectiles(void); void C_InitProjectiles(void);
typedef struct { typedef struct {
int32_t g_i, g_p, g_x; int g_i, g_p, g_x;
int32_t *g_t; int32_t *g_t;
spritetype *g_sp; spritetype *g_sp;
int32_t g_flags; int g_flags;
} vmstate_t; } vmstate_t;
extern vmstate_t vm; extern vmstate_t vm;

View file

@ -68,12 +68,12 @@ GAMEEXEC_STATIC void VM_Execute(int32_t loop);
#endif #endif
#define VM_CONDITIONAL(xxx) \ #define VM_CONDITIONAL(xxx) \
{ \ { \
if ((xxx) || ((insptr = (intptr_t *)*(insptr + 1)) && (((*insptr) & 0xfff) == CON_ELSE))) \ if ((xxx) || ((insptr = (intptr_t *)*(insptr + 1)) && (((*insptr) & 0xfff) == CON_ELSE))) \
{ \ { \
insptr += 2; \ insptr += 2; \
VM_Execute(0); \ VM_Execute(0); \
} \ } \
} }
void VM_ScriptInfo(void) void VM_ScriptInfo(void)
@ -110,7 +110,7 @@ void VM_ScriptInfo(void)
#endif #endif
} }
static void VM_KillIt(int32_t iActor, int32_t iPlayer) static void VM_DeleteSprite(int32_t iActor, int32_t iPlayer)
{ {
if (EDUKE32_PREDICT_FALSE((unsigned) iActor >= MAXSPRITES)) if (EDUKE32_PREDICT_FALSE((unsigned) iActor >= MAXSPRITES))
return; return;
@ -123,9 +123,9 @@ static void VM_KillIt(int32_t iActor, int32_t iPlayer)
} }
// May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT // May recurse, e.g. through EVENT_XXX -> ... -> EVENT_KILLIT
int32_t VM_OnEvent_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn)
{
#ifdef LUNATIC #ifdef LUNATIC
FORCE_INLINE int32_t VM_EventCommon_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn)
{
const double t = gethiticks(); const double t = gethiticks();
int32_t ret = El_CallEvent(&g_ElState, iEventID, iActor, iPlayer, lDist, &iReturn); int32_t ret = El_CallEvent(&g_ElState, iEventID, iActor, iPlayer, lDist, &iReturn);
@ -135,54 +135,89 @@ int32_t VM_OnEvent_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t l
g_eventCalls[iEventID]++; g_eventCalls[iEventID]++;
if (ret == 1) if (ret == 1)
VM_KillIt(iActor, iPlayer); VM_DeleteSprite(iActor, iPlayer);
return iReturn;
}
#else #else
FORCE_INLINE int32_t VM_EventCommon_(const int32_t iEventID, const int32_t iActor, const int32_t iPlayer,
const int32_t lDist, int32_t iReturn)
{
// this is initialized first thing because iActor, iPlayer, lDist, etc are already right there on the stack
// from the function call
const vmstate_t tempvm = { iActor, iPlayer, lDist, &actor[(unsigned)iActor].t_data[0],
&sprite[(unsigned)iActor], 0 };
// since we're targeting C99 and C++ now, we can interweave these to avoid
// having to load addresses for things twice
// for example, because we are loading backupReturnVar with the value of
// aGameVars[g_iReturnVarID].val.lValue, the compiler can avoid having to
// reload the address of aGameVars[g_iReturnVarID].val.lValue in order to
// set it to the value of iReturn (...which should still be on the stack!)
const int32_t backupReturnVar = aGameVars[g_iReturnVarID].val.lValue;
aGameVars[g_iReturnVarID].val.lValue = iReturn;
const int32_t backupEventExec = g_currentEventExec;
g_currentEventExec = iEventID;
intptr_t *oinsptr = insptr;
insptr = apScriptGameEvent[iEventID];
const vmstate_t vm_backup = vm; const vmstate_t vm_backup = vm;
vmstate_t tempvm = { vm = tempvm;
iActor, iPlayer, lDist,
NULL, NULL, // to be set in a moment
0
};
int32_t backupReturnVar = aGameVars[g_iReturnVarID].val.lValue; // check tempvm instead of vm... this way, we are not actually loading
int32_t backupEventExec = g_currentEventExec; // FROM vm anywhere until VM_Execute() is called
intptr_t *oinsptr=insptr; if ((unsigned)tempvm.g_i >= MAXSPRITES)
if ((unsigned)iActor >= (unsigned)Numsprites)
{ {
static spritetype dummy_sprite; static spritetype dummy_sprite;
static int32_t dummy_t[ARRAY_SIZE(actor[0].t_data)]; static int32_t dummy_t[ARRAY_SIZE(actor[0].t_data)];
tempvm.g_sp = &dummy_sprite; vm.g_sp = &dummy_sprite;
tempvm.g_t = dummy_t; vm.g_t = dummy_t;
} }
else
{
tempvm.g_sp = &sprite[iActor];
tempvm.g_t = &actor[iActor].t_data[0];
}
vm = tempvm;
aGameVars[g_iReturnVarID].val.lValue = iReturn;
g_currentEventExec = iEventID;
insptr = apScriptGameEvent[iEventID];
VM_Execute(1); VM_Execute(1);
if (vm.g_flags & VM_KILL) if (vm.g_flags & VM_KILL)
VM_KillIt(iActor, iPlayer); VM_DeleteSprite(vm.g_i, vm.g_p);
// this needs to happen after VM_DeleteSprite() because VM_DeleteSprite()
// can trigger additional events
vm = vm_backup; vm = vm_backup;
insptr = oinsptr; insptr = oinsptr;
g_currentEventExec = backupEventExec; g_currentEventExec = backupEventExec;
iReturn = aGameVars[g_iReturnVarID].val.lValue; iReturn = aGameVars[g_iReturnVarID].val.lValue;
aGameVars[g_iReturnVarID].val.lValue = backupReturnVar; aGameVars[g_iReturnVarID].val.lValue = backupReturnVar;
#endif
return iReturn; return iReturn;
} }
#endif
// the idea here is that the compiler inlines the call to VM_EventCommon_() and gives us a set of full functions
// 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_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn)
{
return VM_EventCommon_(iEventID, iActor, iPlayer, lDist, iReturn);
}
int32_t VM_OnEventWithReturn_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t iReturn)
{
return VM_EventCommon_(iEventID, iActor, iPlayer, -1, iReturn);
}
int32_t VM_OnEventWithDist_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist)
{
return VM_EventCommon_(iEventID, iActor, iPlayer, lDist, 0);
}
int32_t VM_OnEvent_(int32_t iEventID, int32_t iActor, int32_t iPlayer)
{
return VM_EventCommon_(iEventID, iActor, iPlayer, -1, 0);
}
static int32_t VM_CheckSquished(void) static int32_t VM_CheckSquished(void)
{ {
@ -562,8 +597,11 @@ static void VM_FacePlayer(int32_t shr)
////////// TROR get*zofslope ////////// ////////// TROR get*zofslope //////////
// These rather belong into the engine. // These rather belong into the engine.
static int32_t yax_getceilzofslope(int16_t sectnum, int32_t dax, int32_t day) static int32_t VM_GetCeilZOfSlope(void)
{ {
const int dax = vm.g_sp->x, day = vm.g_sp->y;
const int sectnum = vm.g_sp->sectnum;
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
if ((sector[sectnum].ceilingstat&512)==0) if ((sector[sectnum].ceilingstat&512)==0)
{ {
@ -575,8 +613,11 @@ static int32_t yax_getceilzofslope(int16_t sectnum, int32_t dax, int32_t day)
return getceilzofslope(sectnum, dax, day); return getceilzofslope(sectnum, dax, day);
} }
static int32_t yax_getflorzofslope(int16_t sectnum, int32_t dax, int32_t day) static int32_t VM_GetFlorZOfSlope(void)
{ {
const int dax = vm.g_sp->x, day = vm.g_sp->y;
const int sectnum = vm.g_sp->sectnum;
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
if ((sector[sectnum].floorstat&512)==0) if ((sector[sectnum].floorstat&512)==0)
{ {
@ -600,11 +641,10 @@ GAMEEXEC_STATIC void VM_Move(void)
const uint16_t *movflagsptr = &AC_MOVFLAGS(vm.g_sp, &actor[vm.g_i]); const uint16_t *movflagsptr = &AC_MOVFLAGS(vm.g_sp, &actor[vm.g_i]);
const int32_t movflags = /*(*movflagsptr==-1) ? 0 :*/ *movflagsptr; const int32_t movflags = /*(*movflagsptr==-1) ? 0 :*/ *movflagsptr;
const int32_t deadflag = (A_CheckEnemySprite(vm.g_sp) && vm.g_sp->extra <= 0); const int32_t deadflag = (A_CheckEnemySprite(vm.g_sp) && vm.g_sp->extra <= 0);
int32_t badguyp, angdif; int32_t badguyp;
AC_COUNT(vm.g_t)++; AC_COUNT(vm.g_t)++;
// If the move ID is zero, or the movflags are 0
if (AC_MOVE_ID(vm.g_t) == 0 || movflags == 0) if (AC_MOVE_ID(vm.g_t) == 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.g_i].bpos.x != vm.g_sp->x) || (actor[vm.g_i].bpos.y != vm.g_sp->y))
@ -675,7 +715,8 @@ dead:
if (vm.g_sp->xvel || vm.g_sp->zvel) if (vm.g_sp->xvel || vm.g_sp->zvel)
{ {
int32_t daxvel; int32_t daxvel = vm.g_sp->xvel;
int32_t angdif = vm.g_sp->ang;
if (badguyp && vm.g_sp->picnum != ROTATEGUN) if (badguyp && vm.g_sp->picnum != ROTATEGUN)
{ {
@ -686,14 +727,14 @@ dead:
int32_t l; int32_t l;
// 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.g_i].floorz = l = yax_getflorzofslope(vm.g_sp->sectnum,vm.g_sp->x,vm.g_sp->y); actor[vm.g_i].floorz = l = VM_GetFlorZOfSlope();
if (vm.g_sp->z > l-(8<<8)) if (vm.g_sp->z > l-(8<<8))
{ {
vm.g_sp->z = l-(8<<8); vm.g_sp->z = l-(8<<8);
vm.g_sp->zvel = 0; vm.g_sp->zvel = 0;
} }
actor[vm.g_i].ceilingz = l = yax_getceilzofslope(vm.g_sp->sectnum,vm.g_sp->x,vm.g_sp->y); actor[vm.g_i].ceilingz = l = VM_GetCeilZOfSlope();
if (vm.g_sp->z < l+(80<<8)) if (vm.g_sp->z < l+(80<<8))
{ {
vm.g_sp->z = l+(80<<8); vm.g_sp->z = l+(80<<8);
@ -706,13 +747,13 @@ dead:
// The DRONE updates either .floorz or .ceilingz, not both. // The DRONE updates either .floorz or .ceilingz, not both.
if (vm.g_sp->zvel > 0) if (vm.g_sp->zvel > 0)
{ {
actor[vm.g_i].floorz = l = yax_getflorzofslope(vm.g_sp->sectnum,vm.g_sp->x,vm.g_sp->y); actor[vm.g_i].floorz = l = VM_GetFlorZOfSlope();
if (vm.g_sp->z > l-(30<<8)) if (vm.g_sp->z > l-(30<<8))
vm.g_sp->z = l-(30<<8); vm.g_sp->z = l-(30<<8);
} }
else else
{ {
actor[vm.g_i].ceilingz = l = yax_getceilzofslope(vm.g_sp->sectnum,vm.g_sp->x,vm.g_sp->y); actor[vm.g_i].ceilingz = l = VM_GetCeilZOfSlope();
if (vm.g_sp->z < l+(50<<8)) if (vm.g_sp->z < l+(50<<8))
{ {
vm.g_sp->z = l+(50<<8); vm.g_sp->z = l+(50<<8);
@ -729,7 +770,7 @@ dead:
vm.g_sp->z = actor[vm.g_i].floorz; vm.g_sp->z = actor[vm.g_i].floorz;
if (vm.g_sp->zvel < 0) if (vm.g_sp->zvel < 0)
{ {
const int32_t l = yax_getceilzofslope(vm.g_sp->sectnum,vm.g_sp->x,vm.g_sp->y); const int32_t l = VM_GetCeilZOfSlope();
if (vm.g_sp->z < l+(66<<8)) if (vm.g_sp->z < l+(66<<8))
{ {
@ -738,22 +779,13 @@ dead:
} }
} }
} }
}
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);
daxvel = vm.g_sp->xvel;
angdif = vm.g_sp->ang;
if (badguyp && vm.g_sp->picnum != ROTATEGUN)
{
DukePlayer_t *const ps = g_player[vm.g_p].ps; DukePlayer_t *const ps = g_player[vm.g_p].ps;
if (vm.g_x < 960 && vm.g_sp->xrepeat > 16) if (vm.g_x < 960 && vm.g_sp->xrepeat > 16)
{ {
daxvel = -(1024-vm.g_x); daxvel = -(1024 - vm.g_x);
angdif = getangle(ps->pos.x-vm.g_sp->x, ps->pos.y-vm.g_sp->y); angdif = getangle(ps->pos.x - vm.g_sp->x, ps->pos.y - vm.g_sp->y);
if (vm.g_x < 512) if (vm.g_x < 512)
{ {
@ -762,8 +794,8 @@ dead:
} }
else else
{ {
ps->vel.x = mulscale16(ps->vel.x, ps->runspeed-0x2000); ps->vel.x = mulscale16(ps->vel.x, ps->runspeed - 0x2000);
ps->vel.y = mulscale16(ps->vel.y, ps->runspeed-0x2000); ps->vel.y = mulscale16(ps->vel.y, ps->runspeed - 0x2000);
} }
} }
else if (vm.g_sp->picnum != DRONE && vm.g_sp->picnum != SHARK && vm.g_sp->picnum != COMMANDER) else if (vm.g_sp->picnum != DRONE && vm.g_sp->picnum != SHARK && vm.g_sp->picnum != COMMANDER)
@ -773,30 +805,29 @@ dead:
if (!A_CheckSpriteFlags(vm.g_i, SFLAG_SMOOTHMOVE)) if (!A_CheckSpriteFlags(vm.g_i, SFLAG_SMOOTHMOVE))
{ {
if (AC_COUNT(vm.g_t)&1) if (AC_COUNT(vm.g_t) & 1)
return; return;
daxvel <<= 1; daxvel <<= 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);
{ vec3_t tmpvect = { (daxvel * (sintable[(angdif + 512) & 2047])) >> 14,
vec3_t tmpvect = { (daxvel*(sintable[(angdif+512)&2047]))>>14, (daxvel * (sintable[angdif & 2047])) >> 14, vm.g_sp->zvel };
(daxvel*(sintable[angdif&2047]))>>14,
vm.g_sp->zvel
};
actor[vm.g_i].movflag = A_MoveSprite( actor[vm.g_i].movflag =
vm.g_i,&tmpvect, (A_CheckSpriteFlags(vm.g_i, SFLAG_NOCLIP) ? 0 : CLIPMASK0)); A_MoveSprite(vm.g_i, &tmpvect, (A_CheckSpriteFlags(vm.g_i, SFLAG_NOCLIP) ? 0 : CLIPMASK0));
}
} }
if (!badguyp) if (!badguyp)
return; return;
if (sector[vm.g_sp->sectnum].ceilingstat&1) vm.g_sp->shade += (sector[vm.g_sp->sectnum].ceilingstat & 1) ?
vm.g_sp->shade += (sector[vm.g_sp->sectnum].ceilingshade-vm.g_sp->shade)>>1; (sector[vm.g_sp->sectnum].ceilingshade - vm.g_sp->shade) >> 1 :
else vm.g_sp->shade += (sector[vm.g_sp->sectnum].floorshade-vm.g_sp->shade)>>1; (sector[vm.g_sp->sectnum].floorshade - vm.g_sp->shade) >> 1;
} }
static void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int32_t weap) static void P_AddWeaponMaybeSwitch(DukePlayer_t *ps, int32_t weap)
@ -1142,16 +1173,16 @@ LUNATIC_EXTERN void G_ShowView(int32_t x, int32_t y, int32_t z, int32_t a, int32
} }
#if !defined LUNATIC #if !defined LUNATIC
GAMEEXEC_STATIC void VM_Execute(int32_t loop) GAMEEXEC_STATIC void VM_Execute(int loop)
{ {
int32_t tw = *insptr; int tw = *insptr;
// jump directly into the loop, saving us from the checks during the first iteration // jump directly into the loop, saving us from the checks during the first iteration
goto skip_check; goto skip_check;
while (loop) while (loop)
{ {
if (vm.g_flags & (VM_RETURN|VM_KILL|VM_NOEXECUTE)) if (vm.g_flags & (VM_RETURN | VM_KILL | VM_NOEXECUTE))
return; return;
tw = *insptr; tw = *insptr;
@ -1161,7 +1192,7 @@ skip_check:
// AddLog(g_szBuf); // AddLog(g_szBuf);
g_errorLineNum = tw>>12; g_errorLineNum = tw>>12;
g_tw = tw &= 0xFFF; g_tw = tw &= 0xfff;
switch (tw) switch (tw)
{ {
@ -1641,7 +1672,7 @@ skip_check:
if (ps->ammo_amount[weap] >= ps->max_ammo_amount[weap]) if (ps->ammo_amount[weap] >= ps->max_ammo_amount[weap])
{ {
vm.g_flags |= VM_NOEXECUTE; vm.g_flags |= VM_NOEXECUTE;
break; return;
} }
P_AddWeaponAmmoCommon(ps, weap, amount); P_AddWeaponAmmoCommon(ps, weap, amount);
@ -1683,7 +1714,7 @@ skip_check:
case CON_KILLIT: case CON_KILLIT:
insptr++; insptr++;
vm.g_flags |= VM_KILL; vm.g_flags |= VM_KILL;
continue; return;
case CON_ADDWEAPON: case CON_ADDWEAPON:
insptr++; insptr++;
@ -4458,7 +4489,7 @@ finish_qsprintf:
aGameArrays[j].szLabel, aGameArrays[j].size, numelts);*/ aGameArrays[j].szLabel, aGameArrays[j].size, numelts);*/
int32_t numbytes = numelts * sizeof(int32_t); int32_t numbytes = numelts * sizeof(int32_t);
#ifdef BITNESS64 #ifdef BITNESS64
int32_t *tmpar = Xmalloc(numbytes); int32_t *tmpar = (int32_t *)Xmalloc(numbytes);
kread(fil, tmpar, numbytes); kread(fil, tmpar, numbytes);
#endif #endif
Baligned_free(aGameArrays[j].plValues); Baligned_free(aGameArrays[j].plValues);
@ -5368,21 +5399,19 @@ finish_qsprintf:
// NORECURSE // NORECURSE
void A_LoadActor(int32_t iActor) void A_LoadActor(int32_t iActor)
{ {
vm.g_i = iActor; // Sprite ID vm.g_i = iActor; // Sprite ID
vm.g_p = -1; // iPlayer; // Player ID vm.g_sp = &sprite[iActor]; // Pointer to sprite structure
vm.g_x = -1; // lDist; // ? vm.g_t = &actor[iActor].t_data[0]; // Sprite's 'extra' data
vm.g_sp = &sprite[vm.g_i]; // Pointer to sprite structure vm.g_p = -1; // Player ID
vm.g_t = &actor[vm.g_i].t_data[0]; // Sprite's 'extra' data vm.g_x = -1; // Distance
if (g_tile[vm.g_sp->picnum].loadPtr == NULL) if (g_tile[vm.g_sp->picnum].loadPtr == NULL)
return; return;
vm.g_flags &= ~(VM_RETURN|VM_KILL|VM_NOEXECUTE); vm.g_flags &= ~(VM_RETURN | VM_KILL | VM_NOEXECUTE);
if ((unsigned)vm.g_sp->sectnum >= MAXSECTORS) if ((unsigned)vm.g_sp->sectnum >= MAXSECTORS)
{ {
// if(A_CheckEnemySprite(vm.g_sp))
// g_player[vm.g_p].ps->actors_killed++;
A_DeleteSprite(vm.g_i); A_DeleteSprite(vm.g_i);
return; return;
} }
@ -5393,21 +5422,20 @@ void A_LoadActor(int32_t iActor)
if (vm.g_flags & VM_KILL) if (vm.g_flags & VM_KILL)
A_DeleteSprite(vm.g_i); A_DeleteSprite(vm.g_i);
} }
#endif #endif
// NORECURSE // NORECURSE
void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist) void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
{ {
vmstate_t tempvm = { iActor, iPlayer, lDist, &actor[iActor].t_data[0], &sprite[iActor], 0 };
vm = tempvm;
#ifdef LUNATIC #ifdef LUNATIC
int32_t killit=0; int32_t killit=0;
#else #else
intptr_t actionofs, *actionptr; intptr_t actionofs, *actionptr;
#endif #endif
vmstate_t tempvm = { iActor, iPlayer, lDist, &actor[iActor].t_data[0],
&sprite[iActor], 0
};
/* /*
if (g_netClient && A_CheckSpriteFlags(iActor, SFLAG_NULL)) if (g_netClient && A_CheckSpriteFlags(iActor, SFLAG_NULL))
@ -5420,24 +5448,18 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
if (g_netServer || g_netClient) if (g_netServer || g_netClient)
randomseed = ticrandomseed; randomseed = ticrandomseed;
Bmemcpy(&vm, &tempvm, sizeof(vmstate_t));
if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_sp->sectnum >= MAXSECTORS)) if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_sp->sectnum >= MAXSECTORS))
{ {
if (A_CheckEnemySprite(vm.g_sp)) if (A_CheckEnemySprite(vm.g_sp))
g_player[vm.g_p].ps->actors_killed++; g_player[vm.g_p].ps->actors_killed++;
A_DeleteSprite(vm.g_i); A_DeleteSprite(vm.g_i);
return; return;
} }
/* Qbix: Changed variables to be aware of the sizeof *insptr
* (whether it is int32_t vs intptr_t), Although it is specifically cast to intptr_t*
* which might be corrected if the code is converted to use offsets */
/* Helixhorned: let's do away with intptr_t's... */
#if !defined LUNATIC #if !defined LUNATIC
actionofs = AC_ACTION_ID(vm.g_t); actionofs = AC_ACTION_ID(vm.g_t);
actionptr = (actionofs!=0 && actionofs+4u < (unsigned)g_scriptSize) ? actionptr = (actionofs != 0 && actionofs + 4u < (unsigned)g_scriptSize) ? &script[actionofs] : NULL;
&script[actionofs] : NULL;
if (actionptr != NULL) if (actionptr != NULL)
#endif #endif
@ -5456,9 +5478,8 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
if (*actionticsptr > action_delay) if (*actionticsptr > action_delay)
{ {
AC_ACTION_COUNT(vm.g_t)++;
*actionticsptr = 0; *actionticsptr = 0;
AC_ACTION_COUNT(vm.g_t)++;
AC_CURFRAME(vm.g_t) += action_incval; AC_CURFRAME(vm.g_t) += action_incval;
} }
@ -5495,43 +5516,46 @@ void A_Execute(int32_t iActor, int32_t iPlayer, int32_t lDist)
if (vm.g_flags & VM_KILL) if (vm.g_flags & VM_KILL)
#endif #endif
{ {
VM_KillIt(iActor, iPlayer); VM_DeleteSprite(iActor, iPlayer);
return; return;
} }
VM_Move(); VM_Move();
if (vm.g_sp->statnum == STAT_STANDABLE)
switch (DYNAMICTILEMAP(vm.g_sp->picnum))
{
case RUBBERCAN__STATIC:
case EXPLODINGBARREL__STATIC:
case WOODENHORSE__STATIC:
case HORSEONSIDE__STATIC:
case CANWITHSOMETHING__STATIC:
case FIREBARREL__STATIC:
case NUKEBARREL__STATIC:
case NUKEBARRELDENTED__STATIC:
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);
default:
return;
}
if (vm.g_sp->statnum != STAT_ACTOR) if (vm.g_sp->statnum != STAT_ACTOR)
{
if (vm.g_sp->statnum == STAT_STANDABLE)
{
switch (DYNAMICTILEMAP(vm.g_sp->picnum))
{
case RUBBERCAN__STATIC:
case EXPLODINGBARREL__STATIC:
case WOODENHORSE__STATIC:
case HORSEONSIDE__STATIC:
case CANWITHSOMETHING__STATIC:
case FIREBARREL__STATIC:
case NUKEBARREL__STATIC:
case NUKEBARRELDENTED__STATIC:
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);
default: return;
}
}
return; return;
}
if (A_CheckEnemySprite(vm.g_sp)) if (A_CheckEnemySprite(vm.g_sp))
{ {
if (vm.g_sp->xrepeat > 60) return; if (vm.g_sp->xrepeat > 60 || (ud.respawn_monsters == 1 && vm.g_sp->extra <= 0))
if (ud.respawn_monsters == 1 && vm.g_sp->extra <= 0) return; return;
} }
else if (EDUKE32_PREDICT_FALSE(ud.respawn_items == 1 && (vm.g_sp->cstat&32768))) return; else if (EDUKE32_PREDICT_FALSE(ud.respawn_items == 1 && (vm.g_sp->cstat & 32768)))
return;
if (A_CheckSpriteFlags(vm.g_i, SFLAG_USEACTIVATOR) && sector[vm.g_sp->sectnum].lotag & 16384) if (A_CheckSpriteFlags(vm.g_i, SFLAG_USEACTIVATOR) && sector[vm.g_sp->sectnum].lotag & 16384)
changespritestat(vm.g_i, STAT_ZOMBIEACTOR); changespritestat(vm.g_i, STAT_ZOMBIEACTOR);

View file

@ -52,7 +52,10 @@ int32_t G_GetAngleDelta(int32_t a,int32_t na);
void G_RestoreMapState(); void G_RestoreMapState();
void G_SaveMapState(); void G_SaveMapState();
int32_t VM_OnEvent_(int32_t iEventID,int32_t iActor,int32_t iPlayer,int32_t lDist, int32_t iReturn); int32_t VM_OnEventWithBoth_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn);
int32_t VM_OnEventWithReturn_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t iReturn);
int32_t VM_OnEventWithDist_(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist);
int32_t VM_OnEvent_(int32_t iEventID, int32_t iActor, int32_t iPlayer);
static inline int32_t VM_HaveEvent(int32_t iEventID) static inline int32_t VM_HaveEvent(int32_t iEventID)
{ {
@ -63,9 +66,24 @@ static inline int32_t VM_HaveEvent(int32_t iEventID)
#endif #endif
} }
static inline int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn) static inline int32_t VM_OnEventWithBoth(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist, int32_t iReturn)
{ {
return VM_HaveEvent(iEventID) ? VM_OnEvent_(iEventID, iActor, iPlayer, lDist, iReturn) : iReturn; return VM_HaveEvent(iEventID) ? VM_OnEventWithBoth_(iEventID, iActor, iPlayer, lDist, iReturn) : iReturn;
}
static inline int32_t VM_OnEventWithReturn(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t iReturn)
{
return VM_HaveEvent(iEventID) ? VM_OnEventWithReturn_(iEventID, iActor, iPlayer, iReturn) : iReturn;
}
static inline int32_t VM_OnEventWithDist(int32_t iEventID, int32_t iActor, int32_t iPlayer, int32_t lDist)
{
return VM_HaveEvent(iEventID) ? VM_OnEventWithDist_(iEventID, iActor, iPlayer, lDist) : 0;
}
static inline int32_t VM_OnEvent(int32_t iEventID, int32_t iActor, int32_t iPlayer)
{
return VM_HaveEvent(iEventID) ? VM_OnEvent_(iEventID, iActor, iPlayer) : 0;
} }
void VM_ScriptInfo(void); void VM_ScriptInfo(void);

View file

@ -108,16 +108,16 @@ void __fastcall Gv_SetVarX(int32_t id, int32_t lValue);
int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t lDefault,int32_t iActor,int32_t iPlayer); int32_t Gv_GetVarByLabel(const char *szGameLabel,int32_t lDefault,int32_t iActor,int32_t iPlayer);
int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags); 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); int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);
static inline void A_ResetVars(int32_t iActor)
{
int32_t i;
for (i=0; i<g_gameVarCount; i++) static inline void A_ResetVars(const int32_t iActor)
{
for (int i = 0; i < g_gameVarCount; i++)
{ {
if ((aGameVars[i].dwFlags & (GAMEVAR_PERACTOR|GAMEVAR_NODEFAULT)) == GAMEVAR_PERACTOR) if ((aGameVars[i].dwFlags & (GAMEVAR_PERACTOR | GAMEVAR_NODEFAULT)) == GAMEVAR_PERACTOR)
aGameVars[i].val.plValues[iActor]=aGameVars[i].lDefault; aGameVars[i].val.plValues[iActor] = aGameVars[i].lDefault;
} }
} }
void Gv_DumpValues(void); void Gv_DumpValues(void);
void Gv_InitWeaponPointers(void); void Gv_InitWeaponPointers(void);
void Gv_RefreshPointers(void); void Gv_RefreshPointers(void);
@ -134,30 +134,30 @@ void Gv_Init(void);
void Gv_FinalizeWeaponDefaults(void); void Gv_FinalizeWeaponDefaults(void);
#if !defined LUNATIC #if !defined LUNATIC
#define VM_GAMEVAR_OPERATOR(func, operator) \ #define VM_GAMEVAR_OPERATOR(func, operator) \
static inline void __fastcall func(int32_t id, int32_t lValue) \ static inline void __fastcall func(const int32_t id, const int32_t lValue) \
{ \ { \
switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) \ switch (aGameVars[id].dwFlags & (GAMEVAR_USER_MASK | GAMEVAR_PTR_MASK)) \
{ \ { \
default: aGameVars[id].val.lValue operator lValue; break; \ default: aGameVars[id].val.lValue operator lValue; break; \
case GAMEVAR_PERPLAYER: \ case GAMEVAR_PERPLAYER: \
if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p > MAXPLAYERS - 1)) \ if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_p > MAXPLAYERS - 1)) \
break; \ break; \
aGameVars[id].val.plValues[vm.g_p] operator lValue; \ aGameVars[id].val.plValues[vm.g_p] operator lValue; \
break; \ break; \
case GAMEVAR_PERACTOR: \ case GAMEVAR_PERACTOR: \
if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_i > MAXSPRITES - 1)) \ if (EDUKE32_PREDICT_FALSE((unsigned)vm.g_i > MAXSPRITES - 1)) \
break; \ break; \
aGameVars[id].val.plValues[vm.g_i] operator lValue; \ aGameVars[id].val.plValues[vm.g_i] operator lValue; \
break; \ break; \
case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].val.lValue) operator(int32_t) lValue; break; \ case GAMEVAR_INTPTR: *((int32_t *)aGameVars[id].val.lValue) operator (int32_t) lValue; break; \
case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].val.lValue) operator(int16_t) lValue; break; \ case GAMEVAR_SHORTPTR: *((int16_t *)aGameVars[id].val.lValue) operator (int16_t) lValue; break; \
case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].val.lValue) operator(uint8_t) lValue; break; \ case GAMEVAR_CHARPTR: *((uint8_t *)aGameVars[id].val.lValue) operator (uint8_t) lValue; break; \
} \ } \
} }
#if defined(__arm__) || defined(LIBDIVIDE_ALWAYS) #if defined(__arm__) || defined(LIBDIVIDE_ALWAYS)
static inline void __fastcall Gv_DivVar(int32_t id, int32_t lValue) static inline void __fastcall Gv_DivVar(const int32_t id, const int32_t lValue)
{ {
static libdivide_s32_t sdiv; static libdivide_s32_t sdiv;
static int32_t lastlValue; static int32_t lastlValue;

View file

@ -3186,7 +3186,7 @@ void M_ChangeMenu(MenuID_t cm)
Menu_t *search; Menu_t *search;
int32_t i; int32_t i;
cm = VM_OnEvent(EVENT_CHANGEMENU, g_player[myconnectindex].ps->i, myconnectindex, -1, cm); cm = VM_OnEventWithReturn(EVENT_CHANGEMENU, g_player[myconnectindex].ps->i, myconnectindex, cm);
if (cm == MENU_PREVIOUS) if (cm == MENU_PREVIOUS)
{ {
@ -4950,7 +4950,7 @@ void M_DisplayMenus(void)
M_RunMenuInput(m_currentMenu); M_RunMenuInput(m_currentMenu);
VM_OnEvent(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek, -1, 0); VM_OnEvent(EVENT_DISPLAYMENU, g_player[screenpeek].ps->i, screenpeek);
g_player[myconnectindex].ps->gm &= (0xff-MODE_TYPE); g_player[myconnectindex].ps->gm &= (0xff-MODE_TYPE);
g_player[myconnectindex].ps->fta = 0; g_player[myconnectindex].ps->fta = 0;
@ -4986,7 +4986,7 @@ void M_DisplayMenus(void)
#endif #endif
if (VM_HaveEvent(EVENT_DISPLAYMENUREST)) if (VM_HaveEvent(EVENT_DISPLAYMENUREST))
VM_OnEvent(EVENT_DISPLAYMENUREST, g_player[screenpeek].ps->i, screenpeek, -1, 0); VM_OnEvent(EVENT_DISPLAYMENUREST, g_player[screenpeek].ps->i, screenpeek);
if (readmouseabsxy(&m_mousepos.x, &m_mousepos.y)) if (readmouseabsxy(&m_mousepos.x, &m_mousepos.y))
{ {

View file

@ -67,7 +67,7 @@ static void P_IncurDamage(DukePlayer_t *p)
{ {
int32_t damage; int32_t damage;
if (VM_OnEvent(EVENT_INCURDAMAGE, p->i, P_Get(p->i), -1, 0) != 0) if (VM_OnEvent(EVENT_INCURDAMAGE, p->i, P_Get(p->i)) != 0)
return; return;
sprite[p->i].extra -= p->extra_extra8>>8; sprite[p->i].extra -= p->extra_extra8>>8;
@ -350,7 +350,7 @@ static int32_t GetAutoAimAngle(int32_t i, int32_t p, int32_t atwith,
Gv_SetVar(g_iAimAngleVarID, g_player[p].ps->auto_aim == 3 ? AUTO_AIM_ANGLE<<1 : AUTO_AIM_ANGLE, i, p); Gv_SetVar(g_iAimAngleVarID, g_player[p].ps->auto_aim == 3 ? AUTO_AIM_ANGLE<<1 : AUTO_AIM_ANGLE, i, p);
#endif #endif
VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1, 0); VM_OnEvent(EVENT_GETAUTOAIMANGLE, i, p);
{ {
#ifdef LUNATIC #ifdef LUNATIC
@ -472,7 +472,7 @@ static void P_PreFireHitscan(int32_t i, int32_t p, int32_t atwith,
Gv_SetVar(g_iZRangeVarID,zRange,i,p); Gv_SetVar(g_iZRangeVarID,zRange,i,p);
#endif #endif
VM_OnEvent(EVENT_GETSHOTRANGE, i, p, -1, 0); VM_OnEvent(EVENT_GETSHOTRANGE, i, p);
#ifdef LUNATIC #ifdef LUNATIC
angRange = ps->angrange; angRange = ps->angrange;
@ -595,7 +595,7 @@ static int32_t SectorContainsSE13(int32_t sectnum)
// Maybe handle bit 2 (swap wall bottoms). // Maybe handle bit 2 (swap wall bottoms).
// (in that case walltype *hitwal may be stale) // (in that case walltype *hitwal may be stale)
static void HandleHitWall(hitdata_t *hit) static inline void HandleHitWall(hitdata_t *hit)
{ {
const walltype *const hitwal = &wall[hit->wall]; const walltype *const hitwal = &wall[hit->wall];
@ -1925,7 +1925,7 @@ static void P_FireWeapon(int32_t snum)
int32_t i; int32_t i;
DukePlayer_t *const p = g_player[snum].ps; DukePlayer_t *const p = g_player[snum].ps;
if (VM_OnEvent(EVENT_DOFIRE, p->i, snum, -1, 0) || p->weapon_pos != 0) if (VM_OnEvent(EVENT_DOFIRE, p->i, snum) || p->weapon_pos != 0)
return; return;
if (PWEAPON(snum, p->curr_weapon, WorksLike) != KNEE_WEAPON) if (PWEAPON(snum, p->curr_weapon, WorksLike) != KNEE_WEAPON)
@ -2145,7 +2145,7 @@ void P_DisplayWeapon(int32_t snum)
hudweap.count=*kb; hudweap.count=*kb;
hudweap.lookhalfang=p->look_ang>>1; hudweap.lookhalfang=p->look_ang>>1;
if (VM_OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek, -1, 0) == 0) if (VM_OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek) == 0)
{ {
j = 14-p->quick_kick; j = 14-p->quick_kick;
if (j != 14 || p->last_quick_kick) if (j != 14 || p->last_quick_kick)
@ -2194,7 +2194,7 @@ void P_DisplayWeapon(int32_t snum)
switch (cw) switch (cw)
{ {
case KNEE_WEAPON: case KNEE_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek, -1, 0) || *kb == 0) if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek) || *kb == 0)
break; break;
if (pal == 0) if (pal == 0)
@ -2211,7 +2211,7 @@ void P_DisplayWeapon(int32_t snum)
break; break;
case TRIPBOMB_WEAPON: case TRIPBOMB_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek, -1, 0)) if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek))
break; break;
weapon_xoffset += 8; weapon_xoffset += 8;
@ -2234,7 +2234,7 @@ void P_DisplayWeapon(int32_t snum)
break; break;
case RPG_WEAPON: case RPG_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0)) if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek))
break; break;
weapon_xoffset -= sintable[(768 + ((*kb) << 7)) & 2047] >> 11; weapon_xoffset -= sintable[(768 + ((*kb) << 7)) & 2047] >> 11;
@ -2251,7 +2251,7 @@ void P_DisplayWeapon(int32_t snum)
break; break;
case SHOTGUN_WEAPON: case SHOTGUN_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek, -1, 0)) if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek))
break; break;
weapon_xoffset -= 8; weapon_xoffset -= 8;
@ -2324,7 +2324,7 @@ void P_DisplayWeapon(int32_t snum)
break; break;
case CHAINGUN_WEAPON: case CHAINGUN_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek, -1, 0)) if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek))
break; break;
if (*kb > 0) if (*kb > 0)
@ -2374,7 +2374,7 @@ void P_DisplayWeapon(int32_t snum)
break; break;
case PISTOL_WEAPON: case PISTOL_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0)) if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek))
break; break;
if ((*kb) < PWEAPON(screenpeek, PISTOL_WEAPON, TotalTime)+1) if ((*kb) < PWEAPON(screenpeek, PISTOL_WEAPON, TotalTime)+1)
@ -2416,7 +2416,7 @@ void P_DisplayWeapon(int32_t snum)
break; break;
case HANDBOMB_WEAPON: case HANDBOMB_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek, -1, 0)) if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek))
break; break;
else else
{ {
@ -2443,7 +2443,7 @@ void P_DisplayWeapon(int32_t snum)
break; break;
case HANDREMOTE_WEAPON: case HANDREMOTE_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0)) if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek))
break; break;
else else
{ {
@ -2459,7 +2459,7 @@ void P_DisplayWeapon(int32_t snum)
break; break;
case DEVISTATOR_WEAPON: case DEVISTATOR_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek, -1, 0)) if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek))
break; break;
if ((*kb) < (PWEAPON(screenpeek, DEVISTATOR_WEAPON, TotalTime) + 1) && (*kb) > 0) if ((*kb) < (PWEAPON(screenpeek, DEVISTATOR_WEAPON, TotalTime) + 1) && (*kb) > 0)
@ -2498,7 +2498,7 @@ void P_DisplayWeapon(int32_t snum)
break; break;
case FREEZE_WEAPON: case FREEZE_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0)) if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek))
break; break;
if ((*kb) < (PWEAPON(snum, p->curr_weapon, TotalTime)+1) && (*kb) > 0) if ((*kb) < (PWEAPON(snum, p->curr_weapon, TotalTime)+1) && (*kb) > 0)
@ -2523,7 +2523,7 @@ void P_DisplayWeapon(int32_t snum)
case GROW_WEAPON: case GROW_WEAPON:
case SHRINKER_WEAPON: case SHRINKER_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek, -1, 0)) if (VM_OnEvent(EVENT_DRAWWEAPON, g_player[screenpeek].ps->i, screenpeek))
break; break;
weapon_xoffset += 28; weapon_xoffset += 28;
@ -3087,7 +3087,7 @@ static void P_ChangeWeapon(DukePlayer_t *p, int32_t weapon)
return; return;
if (p->curr_weapon != weapon && VM_HaveEvent(EVENT_CHANGEWEAPON)) if (p->curr_weapon != weapon && VM_HaveEvent(EVENT_CHANGEWEAPON))
i = VM_OnEvent(EVENT_CHANGEWEAPON,p->i, snum, -1, weapon); i = VM_OnEventWithReturn(EVENT_CHANGEWEAPON,p->i, snum, weapon);
if (i == -1) if (i == -1)
return; return;
@ -3216,7 +3216,7 @@ static void DoWallTouchDamage(const DukePlayer_t *p, int32_t obj)
static void P_CheckTouchDamage(DukePlayer_t *p, int32_t obj) static void P_CheckTouchDamage(DukePlayer_t *p, int32_t obj)
{ {
if ((obj = VM_OnEvent(EVENT_CHECKTOUCHDAMAGE, p->i, P_Get(p->i), -1, obj)) == -1) if ((obj = VM_OnEventWithReturn(EVENT_CHECKTOUCHDAMAGE, p->i, P_Get(p->i), obj)) == -1)
return; return;
if ((obj&49152) == 49152) if ((obj&49152) == 49152)
@ -3277,7 +3277,7 @@ static int32_t P_CheckFloorDamage(DukePlayer_t *p, int32_t tex)
{ {
spritetype *s = &sprite[p->i]; spritetype *s = &sprite[p->i];
if ((unsigned)(tex = VM_OnEvent(EVENT_CHECKFLOORDAMAGE, p->i, P_Get(p->i), -1, tex)) >= MAXTILES) if ((unsigned)(tex = VM_OnEventWithReturn(EVENT_CHECKFLOORDAMAGE, p->i, P_Get(p->i), tex)) >= MAXTILES)
return 0; return 0;
switch (DYNAMICTILEMAP(tex)) switch (DYNAMICTILEMAP(tex))
@ -3506,7 +3506,7 @@ static void P_ProcessWeapon(int32_t snum)
{ {
P_SetWeaponGamevars(snum, p); P_SetWeaponGamevars(snum, p);
if (VM_OnEvent(EVENT_PRESSEDFIRE, p->i, snum, -1, 0) != 0) if (VM_OnEvent(EVENT_PRESSEDFIRE, p->i, snum) != 0)
sb_snum &= ~BIT(SK_FIRE); sb_snum &= ~BIT(SK_FIRE);
} }
@ -3514,7 +3514,7 @@ static void P_ProcessWeapon(int32_t snum)
{ {
P_SetWeaponGamevars(snum, p); P_SetWeaponGamevars(snum, p);
if (VM_OnEvent(EVENT_HOLSTER, p->i, snum, -1, 0) == 0) if (VM_OnEvent(EVENT_HOLSTER, p->i, snum) == 0)
{ {
if (PWEAPON(snum, p->curr_weapon, WorksLike) != KNEE_WEAPON) if (PWEAPON(snum, p->curr_weapon, WorksLike) != KNEE_WEAPON)
{ {
@ -3616,10 +3616,10 @@ static void P_ProcessWeapon(int32_t snum)
{ {
P_SetWeaponGamevars(snum, p); P_SetWeaponGamevars(snum, p);
if (VM_OnEvent(EVENT_FIRE, p->i, snum, -1, 0) == 0) if (VM_OnEvent(EVENT_FIRE, p->i, snum) == 0)
{ {
// this event is deprecated // this event is deprecated
VM_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1, 0); VM_OnEvent(EVENT_FIREWEAPON, p->i, snum);
switch (PWEAPON(snum, p->curr_weapon, WorksLike)) switch (PWEAPON(snum, p->curr_weapon, WorksLike))
{ {
@ -4119,7 +4119,7 @@ void P_ProcessInput(int32_t snum)
p->player_par++; p->player_par++;
VM_OnEvent(EVENT_PROCESSINPUT, p->i, snum, -1, 0); VM_OnEvent(EVENT_PROCESSINPUT, p->i, snum);
if (p->cheat_phase > 0) sb_snum = 0; if (p->cheat_phase > 0) sb_snum = 0;
@ -4371,7 +4371,7 @@ void P_ProcessInput(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_LOOK_LEFT)) if (TEST_SYNC_KEY(sb_snum, SK_LOOK_LEFT))
{ {
// look_left // look_left
if (VM_OnEvent(EVENT_LOOKLEFT,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_LOOKLEFT,p->i,snum) == 0)
{ {
p->look_ang -= 152; p->look_ang -= 152;
p->rotscrnang += 24; p->rotscrnang += 24;
@ -4381,7 +4381,7 @@ void P_ProcessInput(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_LOOK_RIGHT)) if (TEST_SYNC_KEY(sb_snum, SK_LOOK_RIGHT))
{ {
// look_right // look_right
if (VM_OnEvent(EVENT_LOOKRIGHT,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_LOOKRIGHT,p->i,snum) == 0)
{ {
p->look_ang += 152; p->look_ang += 152;
p->rotscrnang -= 24; p->rotscrnang -= 24;
@ -4452,7 +4452,7 @@ void P_ProcessInput(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) if (TEST_SYNC_KEY(sb_snum, SK_JUMP))
{ {
if (VM_OnEvent(EVENT_SWIMUP,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_SWIMUP,p->i,snum) == 0)
{ {
// jump // jump
if (p->vel.z > 0) p->vel.z = 0; if (p->vel.z > 0) p->vel.z = 0;
@ -4462,7 +4462,7 @@ void P_ProcessInput(int32_t snum)
} }
else if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) else if (TEST_SYNC_KEY(sb_snum, SK_CROUCH))
{ {
if (VM_OnEvent(EVENT_SWIMDOWN,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_SWIMDOWN,p->i,snum) == 0)
{ {
// crouch // crouch
if (p->vel.z < 0) p->vel.z = 0; if (p->vel.z < 0) p->vel.z = 0;
@ -4538,7 +4538,7 @@ void P_ProcessInput(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) //A (soar high) if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) //A (soar high)
{ {
// jump // jump
if (VM_OnEvent(EVENT_SOARUP,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_SOARUP,p->i,snum) == 0)
{ {
p->pos.z -= j; p->pos.z -= j;
p->crack_time = 777; p->crack_time = 777;
@ -4548,7 +4548,7 @@ void P_ProcessInput(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) //Z (soar low) if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) //Z (soar low)
{ {
// crouch // crouch
if (VM_OnEvent(EVENT_SOARDOWN,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_SOARDOWN,p->i,snum) == 0)
{ {
p->pos.z += j; p->pos.z += j;
p->crack_time = 777; p->crack_time = 777;
@ -4735,7 +4735,7 @@ void P_ProcessInput(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) if (TEST_SYNC_KEY(sb_snum, SK_CROUCH))
{ {
// crouching // crouching
if (VM_OnEvent(EVENT_CROUCH,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_CROUCH,p->i,snum) == 0)
{ {
p->pos.z += (2048+768); p->pos.z += (2048+768);
p->crack_time = 777; p->crack_time = 777;
@ -4750,7 +4750,7 @@ void P_ProcessInput(int32_t snum)
if (p->jumping_counter == 0) if (p->jumping_counter == 0)
if ((fz-cz) > (56<<8)) if ((fz-cz) > (56<<8))
{ {
if (VM_OnEvent(EVENT_JUMP,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_JUMP,p->i,snum) == 0)
{ {
p->jumping_counter = 1; p->jumping_counter = 1;
p->jumping_toggle = 1; p->jumping_toggle = 1;
@ -4856,22 +4856,22 @@ void P_ProcessInput(int32_t snum)
} }
if (g_player[snum].sync->extbits&(1)) if (g_player[snum].sync->extbits&(1))
VM_OnEvent(EVENT_MOVEFORWARD,p->i,snum, -1, 0); VM_OnEvent(EVENT_MOVEFORWARD,p->i,snum);
if (g_player[snum].sync->extbits&(1<<1)) if (g_player[snum].sync->extbits&(1<<1))
VM_OnEvent(EVENT_MOVEBACKWARD,p->i,snum, -1, 0); VM_OnEvent(EVENT_MOVEBACKWARD,p->i,snum);
if (g_player[snum].sync->extbits&(1<<2)) if (g_player[snum].sync->extbits&(1<<2))
VM_OnEvent(EVENT_STRAFELEFT,p->i,snum, -1, 0); VM_OnEvent(EVENT_STRAFELEFT,p->i,snum);
if (g_player[snum].sync->extbits&(1<<3)) if (g_player[snum].sync->extbits&(1<<3))
VM_OnEvent(EVENT_STRAFERIGHT,p->i,snum, -1, 0); VM_OnEvent(EVENT_STRAFERIGHT,p->i,snum);
if (g_player[snum].sync->extbits&(1<<4) || g_player[snum].sync->avel < 0) if (g_player[snum].sync->extbits&(1<<4) || g_player[snum].sync->avel < 0)
VM_OnEvent(EVENT_TURNLEFT,p->i,snum, -1, 0); VM_OnEvent(EVENT_TURNLEFT,p->i,snum);
if (g_player[snum].sync->extbits&(1<<5) || g_player[snum].sync->avel > 0) if (g_player[snum].sync->extbits&(1<<5) || g_player[snum].sync->avel > 0)
VM_OnEvent(EVENT_TURNRIGHT,p->i,snum, -1, 0); VM_OnEvent(EVENT_TURNRIGHT,p->i,snum);
if (p->vel.x || p->vel.y || g_player[snum].sync->fvel || g_player[snum].sync->svel) if (p->vel.x || p->vel.y || g_player[snum].sync->fvel || g_player[snum].sync->svel)
{ {
@ -5056,12 +5056,12 @@ HORIZONLY:
i = 0; i = 0;
if (TEST_SYNC_KEY(sb_snum, SK_CENTER_VIEW) || p->hard_landing) if (TEST_SYNC_KEY(sb_snum, SK_CENTER_VIEW) || p->hard_landing)
if (VM_OnEvent(EVENT_RETURNTOCENTER,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_RETURNTOCENTER,p->i,snum) == 0)
p->return_to_center = 9; p->return_to_center = 9;
if (TEST_SYNC_KEY(sb_snum, SK_LOOK_UP)) if (TEST_SYNC_KEY(sb_snum, SK_LOOK_UP))
{ {
if (VM_OnEvent(EVENT_LOOKUP,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_LOOKUP,p->i,snum) == 0)
{ {
p->return_to_center = 9; p->return_to_center = 9;
if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz += 12; if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz += 12;
@ -5072,7 +5072,7 @@ HORIZONLY:
if (TEST_SYNC_KEY(sb_snum, SK_LOOK_DOWN)) if (TEST_SYNC_KEY(sb_snum, SK_LOOK_DOWN))
{ {
if (VM_OnEvent(EVENT_LOOKDOWN,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_LOOKDOWN,p->i,snum) == 0)
{ {
p->return_to_center = 9; p->return_to_center = 9;
if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz -= 12; if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz -= 12;
@ -5083,7 +5083,7 @@ HORIZONLY:
if (TEST_SYNC_KEY(sb_snum, SK_AIM_UP)) if (TEST_SYNC_KEY(sb_snum, SK_AIM_UP))
{ {
if (VM_OnEvent(EVENT_AIMUP,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_AIMUP,p->i,snum) == 0)
{ {
if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz += 6; if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz += 6;
p->horiz += 6; p->horiz += 6;
@ -5093,7 +5093,7 @@ HORIZONLY:
if (TEST_SYNC_KEY(sb_snum, SK_AIM_DOWN)) if (TEST_SYNC_KEY(sb_snum, SK_AIM_DOWN))
{ {
if (VM_OnEvent(EVENT_AIMDOWN,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_AIMDOWN,p->i,snum) == 0)
{ {
if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz -= 6; if (TEST_SYNC_KEY(sb_snum, SK_RUN)) p->horiz -= 6;
p->horiz -= 6; p->horiz -= 6;

View file

@ -334,7 +334,7 @@ static void G_DoLoadScreen(const char *statustext, int32_t percent)
if (ud.recstat != 2) if (ud.recstat != 2)
{ {
j = VM_OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1, LOADSCREEN); j = VM_OnEventWithReturn(EVENT_GETLOADTILE, -1, myconnectindex, LOADSCREEN);
//g_player[myconnectindex].ps->palette = palette; //g_player[myconnectindex].ps->palette = palette;
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 1); // JBF 20040308 P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 1); // JBF 20040308
@ -383,7 +383,7 @@ static void G_DoLoadScreen(const char *statustext, int32_t percent)
rotatesprite(158<<16,144<<16,65536,0,929,0,0,2+8+16,0,0,ii,ydim-1); rotatesprite(158<<16,144<<16,65536,0,929,0,0,2+8+16,0,0,ii,ydim-1);
} }
VM_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1, 0); VM_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek);
nextpage(); nextpage();
if (!statustext) if (!statustext)
@ -403,7 +403,7 @@ static void G_DoLoadScreen(const char *statustext, int32_t percent)
} }
/*Gv_SetVar(g_iReturnVarID,LOADSCREEN, -1, -1);*/ /*Gv_SetVar(g_iReturnVarID,LOADSCREEN, -1, -1);*/
j = VM_OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1, LOADSCREEN); j = VM_OnEventWithReturn(EVENT_GETLOADTILE, -1, myconnectindex, LOADSCREEN);
if ((uint32_t)j < 2*MAXTILES) if ((uint32_t)j < 2*MAXTILES)
{ {
@ -418,7 +418,7 @@ static void G_DoLoadScreen(const char *statustext, int32_t percent)
menutext(160,105,0,0,"Loading..."); menutext(160,105,0,0,"Loading...");
if (statustext) gametext(160,180,statustext,0,2+8+16); if (statustext) gametext(160,180,statustext,0,2+8+16);
VM_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1, 0); VM_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek);
nextpage(); nextpage();
} }
} }
@ -718,7 +718,7 @@ void P_ResetPlayer(int32_t snum)
pl->movement_lock = 0; pl->movement_lock = 0;
VM_OnEvent(EVENT_RESETPLAYER, pl->i, snum, -1, 0); VM_OnEvent(EVENT_RESETPLAYER, pl->i, snum);
} }
void P_ResetStatus(int32_t snum) void P_ResetStatus(int32_t snum)
@ -827,7 +827,7 @@ void P_ResetStatus(int32_t snum)
p->frag_ps = snum; p->frag_ps = snum;
P_UpdateScreenPal(p); P_UpdateScreenPal(p);
VM_OnEvent(EVENT_RESETPLAYER, p->i, snum, -1, 0); VM_OnEvent(EVENT_RESETPLAYER, p->i, snum);
} }
void P_ResetWeapons(int32_t snum) void P_ResetWeapons(int32_t snum)
@ -848,7 +848,7 @@ void P_ResetWeapons(int32_t snum)
p->show_empty_weapon= 0; p->show_empty_weapon= 0;
p->last_pissed_time = 0; p->last_pissed_time = 0;
p->holster_weapon = 0; p->holster_weapon = 0;
VM_OnEvent(EVENT_RESETWEAPONS, p->i, snum, -1, 0); VM_OnEvent(EVENT_RESETWEAPONS, p->i, snum);
} }
void P_ResetInventory(int32_t snum) void P_ResetInventory(int32_t snum)
@ -863,7 +863,7 @@ void P_ResetInventory(int32_t snum)
p->holoduke_on = -1; p->holoduke_on = -1;
p->inv_amount[GET_SHIELD] = g_startArmorAmount; p->inv_amount[GET_SHIELD] = g_startArmorAmount;
p->inven_icon = ICON_NONE; p->inven_icon = ICON_NONE;
VM_OnEvent(EVENT_RESETINVENTORY, p->i, snum, -1, 0); VM_OnEvent(EVENT_RESETINVENTORY, p->i, snum);
} }
static void resetprestat(int32_t snum,int32_t g) static void resetprestat(int32_t snum,int32_t g)
@ -1064,7 +1064,7 @@ static void prelevel(char g)
#if !defined LUNATIC #if !defined LUNATIC
A_LoadActor(i); A_LoadActor(i);
#endif #endif
VM_OnEvent(EVENT_LOADACTOR, i, -1, -1, 0); VM_OnEvent(EVENT_LOADACTOR, i, -1);
if (G_CheckExitSprite(i)) if (G_CheckExitSprite(i))
{ {
g_player[0].ps->exitx = SX; g_player[0].ps->exitx = SX;
@ -1447,7 +1447,7 @@ end_vol4a:
El_CreateGameState(); El_CreateGameState();
G_PostCreateGameState(); G_PostCreateGameState();
#endif #endif
VM_OnEvent(EVENT_NEWGAME, g_player[myconnectindex].ps->i, myconnectindex, -1, 0); VM_OnEvent(EVENT_NEWGAME, g_player[myconnectindex].ps->i, myconnectindex);
} }
static void resetpspritevars(char g) static void resetpspritevars(char g)
@ -1978,7 +1978,7 @@ int32_t G_EnterLevel(int32_t g)
// variables are set by pointer... // variables are set by pointer...
Bmemcpy(currentboardfilename, boardfilename, BMAX_PATH); Bmemcpy(currentboardfilename, boardfilename, BMAX_PATH);
VM_OnEvent(EVENT_ENTERLEVEL, -1, -1, -1, 0); VM_OnEvent(EVENT_ENTERLEVEL, -1, -1);
OSD_Printf(OSDTEXT_YELLOW "E%dL%d: %s\n", ud.volume_number+1, ud.level_number+1, OSD_Printf(OSDTEXT_YELLOW "E%dL%d: %s\n", ud.volume_number+1, ud.level_number+1,
MapInfo[mii].name); MapInfo[mii].name);

View file

@ -324,7 +324,7 @@ int32_t G_LoadPlayer(int32_t spot)
} }
sv_postudload(); // ud.m_XXX = ud.XXX sv_postudload(); // ud.m_XXX = ud.XXX
VM_OnEvent(EVENT_LOADGAME, g_player[myconnectindex].ps->i, myconnectindex, -1, 0); VM_OnEvent(EVENT_LOADGAME, g_player[myconnectindex].ps->i, myconnectindex);
return 0; return 0;
} }
@ -398,7 +398,7 @@ int32_t G_SavePlayer(int32_t spot)
polymer_resetlights(); polymer_resetlights();
#endif #endif
VM_OnEvent(EVENT_SAVEGAME, g_player[myconnectindex].ps->i, myconnectindex, -1, 0); VM_OnEvent(EVENT_SAVEGAME, g_player[myconnectindex].ps->i, myconnectindex);
// SAVE! // SAVE!
sv_saveandmakesnapshot(fil, spot, 0, 0, 0); sv_saveandmakesnapshot(fil, spot, 0, 0, 0);

View file

@ -1802,7 +1802,7 @@ int32_t Sect_DamageCeilingOrFloor(int32_t floorp, int32_t sn)
const int32_t RETURN_in = floorp ? 131072+sn : 65536+sn; const int32_t RETURN_in = floorp ? 131072+sn : 65536+sn;
// NOTE: pass RETURN in the dist argument, too. // NOTE: pass RETURN in the dist argument, too.
int32_t ret = VM_OnEvent(EVENT_DAMAGEHPLANE, g_player[screenpeek].ps->i, screenpeek, int32_t ret = VM_OnEventWithBoth(EVENT_DAMAGEHPLANE, g_player[screenpeek].ps->i, screenpeek,
RETURN_in, RETURN_in); RETURN_in, RETURN_in);
if (ret < 0) if (ret < 0)
@ -2424,7 +2424,7 @@ void P_HandleSharedKeys(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_QUICK_KICK) && p->quick_kick == 0) if (TEST_SYNC_KEY(sb_snum, SK_QUICK_KICK) && p->quick_kick == 0)
if (PWEAPON(snum, p->curr_weapon, WorksLike) != KNEE_WEAPON || p->kickback_pic == 0) if (PWEAPON(snum, p->curr_weapon, WorksLike) != KNEE_WEAPON || p->kickback_pic == 0)
{ {
if (VM_OnEvent(EVENT_QUICKKICK,g_player[snum].ps->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_QUICKKICK,g_player[snum].ps->i,snum) == 0)
{ {
p->quick_kick = 14; p->quick_kick = 14;
if (p->fta == 0 || p->ftq == 80) if (p->fta == 0 || p->ftq == 80)
@ -2467,7 +2467,7 @@ void P_HandleSharedKeys(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_INVENTORY) && p->newowner == -1) // inventory button generates event for selected item if (TEST_SYNC_KEY(sb_snum, SK_INVENTORY) && p->newowner == -1) // inventory button generates event for selected item
{ {
if (VM_OnEvent(EVENT_INVENTORY,g_player[snum].ps->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_INVENTORY,g_player[snum].ps->i,snum) == 0)
{ {
switch (p->inven_icon) switch (p->inven_icon)
{ {
@ -2492,7 +2492,7 @@ void P_HandleSharedKeys(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_NIGHTVISION)) if (TEST_SYNC_KEY(sb_snum, SK_NIGHTVISION))
{ {
if (VM_OnEvent(EVENT_USENIGHTVISION,g_player[snum].ps->i,snum, -1, 0) == 0 if (VM_OnEvent(EVENT_USENIGHTVISION,g_player[snum].ps->i,snum) == 0
&& p->inv_amount[GET_HEATS] > 0) && p->inv_amount[GET_HEATS] > 0)
{ {
p->heat_on = !p->heat_on; p->heat_on = !p->heat_on;
@ -2505,7 +2505,7 @@ void P_HandleSharedKeys(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_STEROIDS)) if (TEST_SYNC_KEY(sb_snum, SK_STEROIDS))
{ {
if (VM_OnEvent(EVENT_USESTEROIDS,g_player[snum].ps->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_USESTEROIDS,g_player[snum].ps->i,snum) == 0)
{ {
if (p->inv_amount[GET_STEROIDS] == 400) if (p->inv_amount[GET_STEROIDS] == 400)
{ {
@ -2590,12 +2590,12 @@ CHECKINV1:
if (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT)) // Inventory_Left if (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT)) // Inventory_Left
{ {
/*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/ /*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/
dainv = VM_OnEvent(EVENT_INVENTORYLEFT,g_player[snum].ps->i,snum, -1, dainv); dainv = VM_OnEventWithReturn(EVENT_INVENTORYLEFT,g_player[snum].ps->i,snum, dainv);
} }
else if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) // Inventory_Right else if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) // Inventory_Right
{ {
/*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/ /*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/
dainv = VM_OnEvent(EVENT_INVENTORYRIGHT,g_player[snum].ps->i,snum, -1, dainv); dainv = VM_OnEventWithReturn(EVENT_INVENTORYRIGHT,g_player[snum].ps->i,snum, dainv);
} }
if (dainv >= 1) if (dainv >= 1)
@ -2619,13 +2619,13 @@ CHECKINV1:
case -1: case -1:
break; break;
default: default:
j = VM_OnEvent(EVENT_WEAPKEY1+j,p->i,snum, -1, j); j = VM_OnEventWithReturn(EVENT_WEAPKEY1+j,p->i,snum, j);
break; break;
case 10: case 10:
j = VM_OnEvent(EVENT_PREVIOUSWEAPON,p->i,snum, -1, j); j = VM_OnEventWithReturn(EVENT_PREVIOUSWEAPON,p->i,snum, j);
break; break;
case 11: case 11:
j = VM_OnEvent(EVENT_NEXTWEAPON,p->i,snum, -1, j); j = VM_OnEventWithReturn(EVENT_NEXTWEAPON,p->i,snum, j);
break; break;
} }
@ -2723,7 +2723,7 @@ CHECKINV1:
P_SetWeaponGamevars(snum, p); P_SetWeaponGamevars(snum, p);
j = VM_OnEvent(EVENT_SELECTWEAPON,p->i,snum, -1, j); j = VM_OnEventWithReturn(EVENT_SELECTWEAPON,p->i,snum, j);
// XXX: any signifcance to "<= MAX_WEAPONS" instead of "<"? // XXX: any signifcance to "<= MAX_WEAPONS" instead of "<"?
if ((int32_t)j != -1 && j <= MAX_WEAPONS) if ((int32_t)j != -1 && j <= MAX_WEAPONS)
@ -2817,7 +2817,7 @@ CHECKINV1:
{ {
if (p->holoduke_on == -1) if (p->holoduke_on == -1)
{ {
if (VM_OnEvent(EVENT_HOLODUKEON,g_player[snum].ps->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_HOLODUKEON,g_player[snum].ps->i,snum) == 0)
{ {
if (p->inv_amount[GET_HOLODUKE] > 0) if (p->inv_amount[GET_HOLODUKE] > 0)
{ {
@ -2839,7 +2839,7 @@ CHECKINV1:
} }
else else
{ {
if (VM_OnEvent(EVENT_HOLODUKEOFF,g_player[snum].ps->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_HOLODUKEOFF,g_player[snum].ps->i,snum) == 0)
{ {
A_PlaySound(TELEPORTER,p->holoduke_on); A_PlaySound(TELEPORTER,p->holoduke_on);
p->holoduke_on = -1; p->holoduke_on = -1;
@ -2850,7 +2850,7 @@ CHECKINV1:
if (TEST_SYNC_KEY(sb_snum, SK_MEDKIT)) if (TEST_SYNC_KEY(sb_snum, SK_MEDKIT))
{ {
if (VM_OnEvent(EVENT_USEMEDKIT,g_player[snum].ps->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_USEMEDKIT,g_player[snum].ps->i,snum) == 0)
{ {
if (p->inv_amount[GET_FIRSTAID] > 0 && sprite[p->i].extra < p->max_player_health) if (p->inv_amount[GET_FIRSTAID] > 0 && sprite[p->i].extra < p->max_player_health)
{ {
@ -2875,7 +2875,7 @@ CHECKINV1:
if (p->newowner == -1 && TEST_SYNC_KEY(sb_snum, SK_JETPACK)) if (p->newowner == -1 && TEST_SYNC_KEY(sb_snum, SK_JETPACK))
{ {
if (VM_OnEvent(EVENT_USEJETPACK,g_player[snum].ps->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_USEJETPACK,g_player[snum].ps->i,snum) == 0)
{ {
if (p->inv_amount[GET_JETPACK] > 0) if (p->inv_amount[GET_JETPACK] > 0)
{ {
@ -2908,7 +2908,7 @@ CHECKINV1:
} }
if (TEST_SYNC_KEY(sb_snum, SK_TURNAROUND) && p->one_eighty_count == 0) if (TEST_SYNC_KEY(sb_snum, SK_TURNAROUND) && p->one_eighty_count == 0)
if (VM_OnEvent(EVENT_TURNAROUND,p->i,snum, -1, 0) == 0) if (VM_OnEvent(EVENT_TURNAROUND,p->i,snum) == 0)
p->one_eighty_count = -1024; p->one_eighty_count = -1024;
} }
} }
@ -3025,7 +3025,7 @@ void P_CheckSectors(int32_t snum)
if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_OPEN)) if (TEST_SYNC_KEY(g_player[snum].sync->bits, SK_OPEN))
{ {
if (VM_OnEvent(EVENT_USE, p->i, snum, -1, 0) != 0) if (VM_OnEvent(EVENT_USE, p->i, snum) != 0)
g_player[snum].sync->bits &= ~BIT(SK_OPEN); g_player[snum].sync->bits &= ~BIT(SK_OPEN);
} }

View file

@ -580,7 +580,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
const DukePlayer_t *const myps = g_player[myconnectindex].ps; const DukePlayer_t *const myps = g_player[myconnectindex].ps;
const DukePlayer_t *peekps; const DukePlayer_t *peekps;
j = VM_OnEvent(EVENT_SOUND, i, screenpeek, -1, num); j = VM_OnEventWithReturn(EVENT_SOUND, i, screenpeek, num);
if (j == -1 && num != -1) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn) if (j == -1 && num != -1) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn)
return -1; return -1;
@ -736,7 +736,7 @@ int32_t S_PlaySound(int32_t num)
int32_t pitch; int32_t pitch;
int32_t voice, j; int32_t voice, j;
j = VM_OnEvent(EVENT_SOUND, g_player[screenpeek].ps->i, screenpeek, -1, num); j = VM_OnEventWithReturn(EVENT_SOUND, g_player[screenpeek].ps->i, screenpeek, num);
if (j == -1 && num != -1) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn) if (j == -1 && num != -1) // check that the user returned -1, but only if -1 wasn't playing already (in which case, warn)
return -1; return -1;