Permalink
Browse files

- give P_ExecuteSpecial a Level parameter.

  • Loading branch information...
coelckers committed Jan 11, 2019
1 parent 1c4e3ae commit 4ec2d31e9f9954237a1a3ad266267473c362a9ee
@@ -2514,7 +2514,7 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
}
if (!CheckCheatmode(player == consoleplayer))
{
P_ExecuteSpecial(snum, NULL, players[player].mo, false, arg[0], arg[1], arg[2], arg[3], arg[4]);
P_ExecuteSpecial(players[player].mo->Level, snum, NULL, players[player].mo, false, arg[0], arg[1], arg[2], arg[3], arg[4]);
}
}
break;
@@ -290,7 +290,7 @@ void E_InitStaticHandlers(bool map)
return;

// initialize event handlers from mapinfo
for (const FString& typeName : level.info->EventHandlers)
for (const FString& typeName : currentSession->Levelinfo[0]->info->EventHandlers)
{
PClass* type = E_GetHandlerClass(typeName);
if (E_IsStaticType(type))
@@ -712,7 +712,7 @@ static FWorldEvent E_SetupWorldEvent()
{
FWorldEvent e;
e.IsSaveGame = savegamerestore;
e.IsReopen = level.FromSnapshot && !savegamerestore; // each one by itself isnt helpful, but with hub load we have savegamerestore==0 and level.FromSnapshot==1.
e.IsReopen = currentSession->Levelinfo[0]->FromSnapshot && !savegamerestore; // each one by itself isnt helpful, but with hub load we have savegamerestore==0 and level.FromSnapshot==1.
e.DamageAngle = 0.0;
return e;
}
@@ -664,6 +664,6 @@ CCMD(fpuke)
}
else
{
T_RunScript(&level, atoi(argv[1]), players[consoleplayer].mo);
T_RunScript(currentSession->Levelinfo[0] , atoi(argv[1]), players[consoleplayer].mo);
}
}
@@ -1683,13 +1683,14 @@ void G_DoPlayerPop(int playernum)
}
}
}
auto Level = players[playernum].mo->Level;

// [RH] Make the player disappear
players[playernum].mo->Level->Behaviors.StopMyScripts(players[playernum].mo);
Level->Behaviors.StopMyScripts(players[playernum].mo);
// [ZZ] fire player disconnect hook
E_PlayerDisconnected(playernum);
// [RH] Let the scripts know the player left
players[playernum].mo->Level->Behaviors.StartTypedScripts(&level, SCRIPT_Disconnect, players[playernum].mo, true, playernum, true);
Level->Behaviors.StartTypedScripts(Level, SCRIPT_Disconnect, players[playernum].mo, true, playernum, true);
if (players[playernum].mo != NULL)
{
P_DisconnectEffect(players[playernum].mo);
@@ -2027,14 +2028,14 @@ void G_DoAutoSave ()

file = G_BuildSaveName ("auto", nextautosave);

if (!(level.flags2 & LEVEL2_NOAUTOSAVEHINT))
if (!(currentSession->Levelinfo[0]->flags2 & LEVEL2_NOAUTOSAVEHINT))
{
nextautosave = (nextautosave + 1) % count;
}
else
{
// This flag can only be used once per level
level.flags2 &= ~LEVEL2_NOAUTOSAVEHINT;
currentSession->Levelinfo[0]->flags2 &= ~LEVEL2_NOAUTOSAVEHINT;
}

readableTime = myasctime ();
@@ -2112,7 +2113,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
ForAllLevels([&](FLevelLocals *Level) {

// Do not even try, if we're not in a map. (Can happen after a demo finishes playback.)
if (Level->lines.Size() == 0 || level.sectors.Size() == 0)
if (Level->lines.Size() == 0 || Level->sectors.Size() == 0)
{
checkok = false;
}
@@ -2391,7 +2392,8 @@ void G_BeginRecording (const char *startmap)

if (startmap == NULL)
{
startmap = level.MapName;
if (!currentSession) return;
startmap = currentSession->Levelinfo[0]->MapName;
}
demo_p = demobuffer;

@@ -483,7 +483,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
int i;

// did we have any level before?
if (level.info != nullptr)
if (currentSession->Levelinfo[0]->info)
E_WorldUnloadedUnsafe();

if (!savegamerestore)
@@ -616,13 +616,14 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill
return;
}

auto OldLevel = currentSession->Levelinfo[0]; // Only the primary level is relevant here.
if (levelname == NULL || *levelname == 0)
{
// end the game
levelname = NULL;
if (!level.NextMap.Compare("enDSeQ",6))
if (!OldLevel->NextMap.Compare("enDSeQ",6))
{
nextlevel = level.NextMap; // If there is already an end sequence please leave it alone!
nextlevel = OldLevel->NextMap; // If there is already an end sequence please leave it alone!
}
else
{
@@ -658,10 +659,10 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill

if (flags & CHANGELEVEL_NOINTERMISSION)
{
level.flags |= LEVEL_NOINTERMISSION;
OldLevel->flags |= LEVEL_NOINTERMISSION;
}

cluster_info_t *thiscluster = FindClusterInfo (level.cluster);
cluster_info_t *thiscluster = FindClusterInfo (OldLevel->cluster);
cluster_info_t *nextcluster = nextinfo? FindClusterInfo (nextinfo->cluster) : NULL;

startpos = position;
@@ -688,18 +689,18 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill

// [RH] Give scripts a chance to do something
unloading = true;
level.Behaviors.StartTypedScripts (&level, SCRIPT_Unloading, NULL, false, 0, true);
OldLevel->Behaviors.StartTypedScripts (OldLevel, SCRIPT_Unloading, NULL, false, 0, true);
// [ZZ] safe world unload
E_WorldUnloaded();
// [ZZ] unsafe world unload (changemap != map)
E_WorldUnloadedUnsafe();
unloading = false;

STAT_ChangeLevel(nextlevel, &level);
STAT_ChangeLevel(nextlevel, OldLevel);

if (thiscluster && (thiscluster->flags & CLUSTER_HUB))
{
if ((level.flags & LEVEL_NOINTERMISSION) || ((nextcluster == thiscluster) && !(thiscluster->flags & CLUSTER_ALLOWINTERMISSION)))
if ((OldLevel->flags & LEVEL_NOINTERMISSION) || ((nextcluster == thiscluster) && !(thiscluster->flags & CLUSTER_ALLOWINTERMISSION)))
NoWipe = 35;
D_DrawIcon = "TELEICON";
}
@@ -715,7 +716,7 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill

// If this is co-op, respawn any dead players now so they can
// keep their inventory on the next map.
if ((multiplayer || level.flags2 & LEVEL2_ALLOWRESPAWN || sv_singleplayerrespawn || !!G_SkillProperty(SKILLP_PlayerRespawn))
if ((multiplayer || OldLevel->flags2 & LEVEL2_ALLOWRESPAWN || sv_singleplayerrespawn || !!G_SkillProperty(SKILLP_PlayerRespawn))
&& !deathmatch && player->playerstate == PST_DEAD)
{
// Copied from the end of P_DeathThink [[
@@ -759,7 +760,7 @@ const char *G_GetSecretExitMap()

//==========================================================================
//
// The flags here must always be on the primary level.
// The flags here must always be on the primary map.
//
//==========================================================================

@@ -814,7 +815,7 @@ void G_DoCompleted ()
P_FreeStrifeConversations ();

wminfo.finished_ep = Level->cluster - 1;
wminfo.LName0 = TexMan.CheckForTexture(level.info->PName, ETextureType::MiscPatch);
wminfo.LName0 = TexMan.CheckForTexture(Level->info->PName, ETextureType::MiscPatch);
wminfo.current = Level->MapName;

if (deathmatch &&
@@ -864,7 +865,7 @@ void G_DoCompleted ()
}

// [RH] If we're in a hub and staying within that hub, take a snapshot
// of the level. If we're traveling to a new hub, take stuff from
// of the map. If we're traveling to a new hub, take stuff from
// the player and clear the world vars. If this is just an
// ordinary cluster (not a hub), take stuff from the player, but
// leave the world vars alone.
@@ -982,6 +983,7 @@ extern gamestate_t wipegamestate;
void G_DoLoadLevel (int position, bool autosave, bool newGame)
{
static int lastposition = 0;
auto &level = *currentSession->Levelinfo[0];
gamestate_t oldgs = gamestate;
int i;

@@ -1916,7 +1916,7 @@ void DPlaneWatcher::Tick ()
if ((LastD < WatchD && newd >= WatchD) ||
(LastD > WatchD && newd <= WatchD))
{
P_ExecuteSpecial(Special, Line, Activator, LineSide, Args[0], Args[1], Args[2], Args[3], Args[4]);
P_ExecuteSpecial(Level, Special, Line, Activator, LineSide, Args[0], Args[1], Args[2], Args[3], Args[4]);
Destroy ();
}

@@ -5762,7 +5762,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args)
int arg2 = argCount > 2 ? args[2] : 0;
int arg3 = argCount > 3 ? args[3] : 0;
int arg4 = argCount > 4 ? args[4] : 0;
return P_ExecuteSpecial(NamedACSToNormalACS[funcIndex - ACSF_ACS_NamedExecute],
return P_ExecuteSpecial(Level, NamedACSToNormalACS[funcIndex - ACSF_ACS_NamedExecute],
activationline, activator, backSide,
scriptnum, arg1, arg2, arg3, arg4);
}
@@ -6981,28 +6981,28 @@ int DLevelScript::RunScript ()
break;

case PCD_LSPEC1:
P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
P_ExecuteSpecial(Level, NEXTBYTE, activationline, activator, backSide,
STACK(1) & specialargmask, 0, 0, 0, 0);
sp -= 1;
break;

case PCD_LSPEC2:
P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
P_ExecuteSpecial(Level, NEXTBYTE, activationline, activator, backSide,
STACK(2) & specialargmask,
STACK(1) & specialargmask, 0, 0, 0);
sp -= 2;
break;

case PCD_LSPEC3:
P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
P_ExecuteSpecial(Level, NEXTBYTE, activationline, activator, backSide,
STACK(3) & specialargmask,
STACK(2) & specialargmask,
STACK(1) & specialargmask, 0, 0);
sp -= 3;
break;

case PCD_LSPEC4:
P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
P_ExecuteSpecial(Level, NEXTBYTE, activationline, activator, backSide,
STACK(4) & specialargmask,
STACK(3) & specialargmask,
STACK(2) & specialargmask,
@@ -7011,7 +7011,7 @@ int DLevelScript::RunScript ()
break;

case PCD_LSPEC5:
P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
P_ExecuteSpecial(Level, NEXTBYTE, activationline, activator, backSide,
STACK(5) & specialargmask,
STACK(4) & specialargmask,
STACK(3) & specialargmask,
@@ -7021,7 +7021,7 @@ int DLevelScript::RunScript ()
break;

case PCD_LSPEC5RESULT:
STACK(5) = P_ExecuteSpecial(NEXTBYTE, activationline, activator, backSide,
STACK(5) = P_ExecuteSpecial(Level, NEXTBYTE, activationline, activator, backSide,
STACK(5) & specialargmask,
STACK(4) & specialargmask,
STACK(3) & specialargmask,
@@ -7031,7 +7031,7 @@ int DLevelScript::RunScript ()
break;

case PCD_LSPEC5EX:
P_ExecuteSpecial(NEXTWORD, activationline, activator, backSide,
P_ExecuteSpecial(Level, NEXTWORD, activationline, activator, backSide,
STACK(5) & specialargmask,
STACK(4) & specialargmask,
STACK(3) & specialargmask,
@@ -7041,7 +7041,7 @@ int DLevelScript::RunScript ()
break;

case PCD_LSPEC5EXRESULT:
STACK(5) = P_ExecuteSpecial(NEXTWORD, activationline, activator, backSide,
STACK(5) = P_ExecuteSpecial(Level, NEXTWORD, activationline, activator, backSide,
STACK(5) & specialargmask,
STACK(4) & specialargmask,
STACK(3) & specialargmask,
@@ -7052,22 +7052,22 @@ int DLevelScript::RunScript ()

case PCD_LSPEC1DIRECT:
temp = NEXTBYTE;
P_ExecuteSpecial(temp, activationline, activator, backSide,
P_ExecuteSpecial(Level, temp, activationline, activator, backSide,
uallong(pc[0]) & specialargmask ,0, 0, 0, 0);
pc += 1;
break;

case PCD_LSPEC2DIRECT:
temp = NEXTBYTE;
P_ExecuteSpecial(temp, activationline, activator, backSide,
P_ExecuteSpecial(Level, temp, activationline, activator, backSide,
uallong(pc[0]) & specialargmask,
uallong(pc[1]) & specialargmask, 0, 0, 0);
pc += 2;
break;

case PCD_LSPEC3DIRECT:
temp = NEXTBYTE;
P_ExecuteSpecial(temp, activationline, activator, backSide,
P_ExecuteSpecial(Level, temp, activationline, activator, backSide,
uallong(pc[0]) & specialargmask,
uallong(pc[1]) & specialargmask,
uallong(pc[2]) & specialargmask, 0, 0);
@@ -7076,7 +7076,7 @@ int DLevelScript::RunScript ()

case PCD_LSPEC4DIRECT:
temp = NEXTBYTE;
P_ExecuteSpecial(temp, activationline, activator, backSide,
P_ExecuteSpecial(Level, temp, activationline, activator, backSide,
uallong(pc[0]) & specialargmask,
uallong(pc[1]) & specialargmask,
uallong(pc[2]) & specialargmask,
@@ -7086,7 +7086,7 @@ int DLevelScript::RunScript ()

case PCD_LSPEC5DIRECT:
temp = NEXTBYTE;
P_ExecuteSpecial(temp, activationline, activator, backSide,
P_ExecuteSpecial(Level, temp, activationline, activator, backSide,
uallong(pc[0]) & specialargmask,
uallong(pc[1]) & specialargmask,
uallong(pc[2]) & specialargmask,
@@ -7097,32 +7097,32 @@ int DLevelScript::RunScript ()

// Parameters for PCD_LSPEC?DIRECTB are by definition bytes so never need and-ing.
case PCD_LSPEC1DIRECTB:
P_ExecuteSpecial(((uint8_t *)pc)[0], activationline, activator, backSide,
P_ExecuteSpecial(Level, ((uint8_t *)pc)[0], activationline, activator, backSide,
((uint8_t *)pc)[1], 0, 0, 0, 0);
pc = (int *)((uint8_t *)pc + 2);
break;

case PCD_LSPEC2DIRECTB:
P_ExecuteSpecial(((uint8_t *)pc)[0], activationline, activator, backSide,
P_ExecuteSpecial(Level, ((uint8_t *)pc)[0], activationline, activator, backSide,
((uint8_t *)pc)[1], ((uint8_t *)pc)[2], 0, 0, 0);
pc = (int *)((uint8_t *)pc + 3);
break;

case PCD_LSPEC3DIRECTB:
P_ExecuteSpecial(((uint8_t *)pc)[0], activationline, activator, backSide,
P_ExecuteSpecial(Level, ((uint8_t *)pc)[0], activationline, activator, backSide,
((uint8_t *)pc)[1], ((uint8_t *)pc)[2], ((uint8_t *)pc)[3], 0, 0);
pc = (int *)((uint8_t *)pc + 4);
break;

case PCD_LSPEC4DIRECTB:
P_ExecuteSpecial(((uint8_t *)pc)[0], activationline, activator, backSide,
P_ExecuteSpecial(Level, ((uint8_t *)pc)[0], activationline, activator, backSide,
((uint8_t *)pc)[1], ((uint8_t *)pc)[2], ((uint8_t *)pc)[3],
((uint8_t *)pc)[4], 0);
pc = (int *)((uint8_t *)pc + 5);
break;

case PCD_LSPEC5DIRECTB:
P_ExecuteSpecial(((uint8_t *)pc)[0], activationline, activator, backSide,
P_ExecuteSpecial(Level, ((uint8_t *)pc)[0], activationline, activator, backSide,
((uint8_t *)pc)[1], ((uint8_t *)pc)[2], ((uint8_t *)pc)[3],
((uint8_t *)pc)[4], ((uint8_t *)pc)[5]);
pc = (int *)((uint8_t *)pc + 6);
@@ -3038,7 +3038,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Teleport)
}
}

DSpotState *state = GetSpotState(&level, false);
DSpotState *state = GetSpotState(self->Level, false);
if (state == NULL)
{
return numret;
@@ -989,7 +989,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply

if (reply->ActionSpecial != 0)
{
takestuff |= !!P_ExecuteSpecial(reply->ActionSpecial, NULL, player->mo, false,
takestuff |= !!P_ExecuteSpecial(player->mo->Level, reply->ActionSpecial, NULL, player->mo, false,
reply->Args[0], reply->Args[1], reply->Args[2], reply->Args[3], reply->Args[4]);
}

Oops, something went wrong.

0 comments on commit 4ec2d31

Please sign in to comment.