Fix a potential issue with nested event execution

git-svn-id: https://svn.eduke32.com/eduke32@2655 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2012-05-15 23:39:48 +00:00
parent 245c8c1fef
commit 3548c50724
4 changed files with 94 additions and 92 deletions

View file

@ -10895,7 +10895,7 @@ int32_t G_DoMoveThings(void)
if (sprite[g_player[i].ps->i].pal != 1) if (sprite[g_player[i].ps->i].pal != 1)
sprite[g_player[i].ps->i].pal = g_player[i].pcolor; sprite[g_player[i].ps->i].pal = g_player[i].pcolor;
G_HandleSharedKeys(i); P_HandleSharedKeys(i);
if (ud.pause_on == 0) if (ud.pause_on == 0)
{ {

View file

@ -110,6 +110,9 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int
iActor >= 0 ? &actor[iActor].t_data[0] : NULL, iActor >= 0 ? &actor[iActor].t_data[0] : NULL,
iActor >= 0 ? &sprite[iActor] : NULL, iActor >= 0 ? &sprite[iActor] : NULL,
0 }; 0 };
int32_t backupReturnVar = aGameVars[g_iReturnVarID].val.lValue;
int32_t backupEventExec = g_currentEventExec;
g_currentEventExec = iEventID; g_currentEventExec = iEventID;
insptr = apScriptGameEvent[iEventID]; insptr = apScriptGameEvent[iEventID];
@ -131,7 +134,8 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int
Bmemcpy(&vm, &vm_backup, sizeof(vmstate_t)); Bmemcpy(&vm, &vm_backup, sizeof(vmstate_t));
insptr = oinsptr; insptr = oinsptr;
g_currentEventExec = -1; g_currentEventExec = backupEventExec;
aGameVars[g_iReturnVarID].val.lValue = backupReturnVar;
} }
} }

View file

@ -2468,7 +2468,7 @@ void allignwarpelevators(void)
} }
} }
void G_HandleSharedKeys(int32_t snum) void P_HandleSharedKeys(int32_t snum)
{ {
int32_t i, k = 0, dainv; int32_t i, k = 0, dainv;
uint32_t sb_snum = g_player[snum].sync->bits, j; uint32_t sb_snum = g_player[snum].sync->bits, j;
@ -2618,104 +2618,102 @@ void G_HandleSharedKeys(int32_t snum)
return; // is there significance to returning? return; // is there significance to returning?
} }
if (p->refresh_inventory) if (p->refresh_inventory)
{
sb_snum |= BIT(SK_INV_LEFT); // emulate move left... sb_snum |= BIT(SK_INV_LEFT); // emulate move left...
}
if (p->newowner == -1)
if (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT) || TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT))
{
p->invdisptime = GAMETICSPERSEC*2;
if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) k = 1; if (p->newowner == -1 && (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT) || TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)))
else k = 0; {
p->invdisptime = GAMETICSPERSEC*2;
if (p->refresh_inventory) p->refresh_inventory = 0; if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) k = 1;
dainv = p->inven_icon; else k = 0;
i = 0; if (p->refresh_inventory) p->refresh_inventory = 0;
dainv = p->inven_icon;
i = 0;
CHECKINV1: CHECKINV1:
if (i < 9) if (i < 9)
{ {
i++; i++;
switch (dainv) switch (dainv)
{
case 4:
if (p->inv_amount[GET_JETPACK] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
goto CHECKINV1;
case 6:
if (p->inv_amount[GET_SCUBA] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
goto CHECKINV1;
case 2:
if (p->inv_amount[GET_STEROIDS] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
goto CHECKINV1;
case 3:
if (p->inv_amount[GET_HOLODUKE] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
goto CHECKINV1;
case 0:
case 1:
if (p->inv_amount[GET_FIRSTAID] > 0 && i > 1)
break;
if (k) dainv = 2;
else dainv = 7;
goto CHECKINV1;
case 5:
if (p->inv_amount[GET_HEATS] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
goto CHECKINV1;
case 7:
if (p->inv_amount[GET_BOOTS] > 0 && i > 1)
break;
if (k) dainv = 1;
else dainv = 6;
goto CHECKINV1;
}
}
else dainv = 0;
if (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT)) // Inventory_Left
{ {
/*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/ case 4:
aGameVars[g_iReturnVarID].val.lValue = dainv; if (p->inv_amount[GET_JETPACK] > 0 && i > 1)
VM_OnEvent(EVENT_INVENTORYLEFT,g_player[snum].ps->i,snum, -1); break;
dainv=aGameVars[g_iReturnVarID].val.lValue; if (k) dainv++;
} else dainv--;
else if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) // Inventory_Right goto CHECKINV1;
{ case 6:
/*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/ if (p->inv_amount[GET_SCUBA] > 0 && i > 1)
aGameVars[g_iReturnVarID].val.lValue = dainv; break;
VM_OnEvent(EVENT_INVENTORYRIGHT,g_player[snum].ps->i,snum, -1); if (k) dainv++;
dainv=aGameVars[g_iReturnVarID].val.lValue; else dainv--;
} goto CHECKINV1;
case 2:
if (dainv >= 1) if (p->inv_amount[GET_STEROIDS] > 0 && i > 1)
{ break;
p->inven_icon = dainv; if (k) dainv++;
else dainv--;
if (dainv || p->inv_amount[GET_FIRSTAID]) goto CHECKINV1;
{ case 3:
static const int32_t i[8] = { QUOTE_MEDKIT, QUOTE_STEROIDS, QUOTE_HOLODUKE, if (p->inv_amount[GET_HOLODUKE] > 0 && i > 1)
QUOTE_JETPACK, QUOTE_NVG, QUOTE_SCUBA, QUOTE_BOOTS, 0 }; break;
if (dainv>=1 && dainv<=9) if (k) dainv++;
P_DoQuote(i[dainv-1], p); else dainv--;
} goto CHECKINV1;
case 0:
case 1:
if (p->inv_amount[GET_FIRSTAID] > 0 && i > 1)
break;
if (k) dainv = 2;
else dainv = 7;
goto CHECKINV1;
case 5:
if (p->inv_amount[GET_HEATS] > 0 && i > 1)
break;
if (k) dainv++;
else dainv--;
goto CHECKINV1;
case 7:
if (p->inv_amount[GET_BOOTS] > 0 && i > 1)
break;
if (k) dainv = 1;
else dainv = 6;
goto CHECKINV1;
} }
} }
else dainv = 0;
if (TEST_SYNC_KEY(sb_snum, SK_INV_LEFT)) // Inventory_Left
{
/*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/
aGameVars[g_iReturnVarID].val.lValue = dainv;
VM_OnEvent(EVENT_INVENTORYLEFT,g_player[snum].ps->i,snum, -1);
dainv=aGameVars[g_iReturnVarID].val.lValue;
}
else if (TEST_SYNC_KEY(sb_snum, SK_INV_RIGHT)) // Inventory_Right
{
/*Gv_SetVar(g_iReturnVarID,dainv,g_player[snum].ps->i,snum);*/
aGameVars[g_iReturnVarID].val.lValue = dainv;
VM_OnEvent(EVENT_INVENTORYRIGHT,g_player[snum].ps->i,snum, -1);
dainv=aGameVars[g_iReturnVarID].val.lValue;
}
if (dainv >= 1)
{
p->inven_icon = dainv;
if (dainv || p->inv_amount[GET_FIRSTAID])
{
static const int32_t i[8] = { QUOTE_MEDKIT, QUOTE_STEROIDS, QUOTE_HOLODUKE,
QUOTE_JETPACK, QUOTE_NVG, QUOTE_SCUBA, QUOTE_BOOTS, 0 };
if (dainv>=1 && dainv<=9)
P_DoQuote(i[dainv-1], p);
}
}
}
j = ((sb_snum&(15<<SK_WEAPON_BITS))>>SK_WEAPON_BITS) - 1; j = ((sb_snum&(15<<SK_WEAPON_BITS))>>SK_WEAPON_BITS) - 1;

View file

@ -111,12 +111,12 @@ int32_t G_ActivateWarpElevators(int32_t s,int32_t d);
int32_t G_CheckActivatorMotion(int32_t lotag); int32_t G_CheckActivatorMotion(int32_t lotag);
extern inline int32_t G_CheckPlayerInSector(int32_t sect); extern inline int32_t G_CheckPlayerInSector(int32_t sect);
void G_DoSectorAnimations(void); void G_DoSectorAnimations(void);
void G_HandleSharedKeys(int32_t snum);
void G_OperateActivators(int32_t low,int32_t snum); void G_OperateActivators(int32_t low,int32_t snum);
void G_OperateForceFields(int32_t s,int32_t low); void G_OperateForceFields(int32_t s,int32_t low);
void G_OperateMasterSwitches(int32_t low); void G_OperateMasterSwitches(int32_t low);
void G_OperateRespawns(int32_t low); void G_OperateRespawns(int32_t low);
void G_OperateSectors(int32_t sn,int32_t ii); void G_OperateSectors(int32_t sn,int32_t ii);
void P_HandleSharedKeys(int32_t snum);
int32_t GetAnimationGoal(const int32_t *animptr); int32_t GetAnimationGoal(const int32_t *animptr);
int32_t isanearoperator(int32_t lotag); int32_t isanearoperator(int32_t lotag);
int32_t isanunderoperator(int32_t lotag); int32_t isanunderoperator(int32_t lotag);