Permalink
Browse files

- added a level parameter to the thinker iterator.

Not used yet, but will be when the thinker lists are moved into FLevelLocals.
  • Loading branch information...
coelckers committed Jan 11, 2019
1 parent 4ec2d31 commit 1b1e2ef7d287a5f65eafbb37c809aa94ad2c4cca
Showing with 197 additions and 152 deletions.
  1. +4 −4 src/am_map.cpp
  2. +1 −1 src/b_think.cpp
  3. +35 −10 src/c_cmds.cpp
  4. +4 −4 src/d_net.cpp
  5. +2 −2 src/dthinker.cpp
  6. +11 −10 src/dthinker.h
  7. +1 −1 src/events.cpp
  8. +4 −4 src/fragglescript/t_func.cpp
  9. +2 −2 src/fragglescript/t_prepro.cpp
  10. +6 −4 src/g_game.cpp
  11. +3 −3 src/g_level.cpp
  12. +13 −9 src/g_shared/a_decals.cpp
  13. +23 −17 src/g_shared/a_dynlight.cpp
  14. +5 −5 src/g_shared/a_lightning.cpp
  15. +1 −1 src/g_shared/a_lightning.h
  16. +1 −1 src/g_shared/a_quake.cpp
  17. +2 −2 src/p_acs.cpp
  18. +10 −10 src/p_actionfunctions.cpp
  19. +2 −2 src/p_ceiling.cpp
  20. +1 −1 src/p_effect.cpp
  21. +14 −11 src/p_enemy.cpp
  22. +1 −1 src/p_lights.cpp
  23. +2 −2 src/p_lnspec.cpp
  24. +1 −1 src/p_map.cpp
  25. +1 −1 src/p_mobj.cpp
  26. +2 −2 src/p_plats.cpp
  27. +1 −1 src/p_pusher.cpp
  28. +3 −3 src/p_scroll.cpp
  29. +2 −2 src/p_setup.cpp
  30. +2 −2 src/p_spec.cpp
  31. +1 −1 src/p_switch.cpp
  32. +1 −1 src/p_teleport.cpp
  33. +1 −1 src/p_things.cpp
  34. +1 −1 src/p_tick.cpp
  35. +1 −1 src/p_xlat.cpp
  36. +1 −1 src/portal.cpp
  37. +1 −1 src/s_sound.cpp
  38. +1 −1 src/scripting/backend/codegen.cpp
  39. +7 −7 src/scripting/vmiterators.cpp
  40. +1 −1 src/statistics.cpp
  41. +4 −4 wadsrc/static/zscript/actor_inventory.txt
  42. +5 −1 wadsrc/static/zscript/base.txt
  43. +1 −1 wadsrc/static/zscript/doom/bossbrain.txt
  44. +1 −1 wadsrc/static/zscript/doom/keen.txt
  45. +1 −1 wadsrc/static/zscript/doom/painelemental.txt
  46. +1 −1 wadsrc/static/zscript/hexen/blastradius.txt
  47. +2 −2 wadsrc/static/zscript/raven/minotaur.txt
  48. +1 −1 wadsrc/static/zscript/shared/bridge.txt
  49. +1 −1 wadsrc/static/zscript/shared/soundsequence.txt
  50. +1 −1 wadsrc/static/zscript/strife/alienspectres.txt
  51. +1 −1 wadsrc/static/zscript/strife/oracle.txt
  52. +1 −1 wadsrc/static/zscript/strife/strifeitems.txt
  53. +1 −1 wadsrc/static/zscript/strife/svestuff.txt
@@ -2941,13 +2941,13 @@ void AM_drawPlayers ()
//
//=============================================================================

void AM_drawKeys ()
void AM_drawKeys (FLevelLocals *Level)
{
AMColor color;
mpoint_t p;
DAngle angle;

TThinkerIterator<AActor> it(NAME_Key);
TThinkerIterator<AActor> it(Level, NAME_Key);
AActor *key;

while ((key = it.Next()) != NULL)
@@ -3171,7 +3171,7 @@ void AM_drawAuthorMarkers (FLevelLocals *Level)
// [RH] Draw any actors derived from AMapMarker on the automap.
// If args[0] is 0, then the actor's sprite is drawn at its own location.
// Otherwise, its sprite is drawn at the location of any actors whose TIDs match args[0].
TThinkerIterator<AActor> it ("MapMarker", STAT_MAPMARKER);
TThinkerIterator<AActor> it (Level, "MapMarker", STAT_MAPMARKER);
AActor *mark;

while ((mark = it.Next()) != NULL)
@@ -3289,7 +3289,7 @@ void AM_Drawer (FLevelLocals *Level, int bottom)
AM_drawWalls(Level, allmap);
AM_drawPlayers();
if (G_SkillProperty(SKILLP_EasyKey))
AM_drawKeys();
AM_drawKeys(Level);
if ((am_cheat >= 2 && am_cheat != 4) || allthings)
AM_drawThings(Level);

@@ -289,7 +289,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd)
r = pr_botmove();
if (r < 128)
{
TThinkerIterator<AActor> it (NAME_Inventory, MAX_STATNUM+1, bglobal.firstthing);
TThinkerIterator<AActor> it (player->mo->Level, NAME_Inventory, MAX_STATNUM+1, bglobal.firstthing);
auto item = it.Next();

if (item != NULL || (item = it.Next()) != NULL)
@@ -919,13 +919,14 @@ static bool IsActor(AActor *mo)
}

// [SP] modified - now allows showing count only, new arg must be passed. Also now still counts regardless, if lists are printed.
static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const char *FilterName, bool countOnly)
static void PrintFilteredActorList(FLevelLocals *Level, const ActorTypeChecker IsActorType, const char *FilterName, bool countOnly)
{
AActor *mo;
const PClass *FilterClass = NULL;
int counter = 0;
int tid = 0;

Printf("%s:\n", Level->MapName.GetChars());
if (FilterName != NULL)
{
FilterClass = PClass::FindActor(FilterName);
@@ -940,7 +941,7 @@ static void PrintFilteredActorList(const ActorTypeChecker IsActorType, const cha
}
}
}
TThinkerIterator<AActor> it;
TThinkerIterator<AActor> it(Level);

while ( (mo = it.Next()) )
{
@@ -972,14 +973,20 @@ CCMD(actorlist) // [SP] print all actors (this can get quite big?)
{
if (CheckCheatmode ()) return;

PrintFilteredActorList(IsActor, argv.argc() > 1 ? argv[1] : NULL, false);
ForAllLevels([&](FLevelLocals *Level)
{
PrintFilteredActorList(Level, IsActor, argv.argc() > 1 ? argv[1] : NULL, false);
});
}

CCMD(actornum) // [SP] count all actors
{
if (CheckCheatmode ()) return;

PrintFilteredActorList(IsActor, argv.argc() > 1 ? argv[1] : NULL, true);
ForAllLevels([&](FLevelLocals *Level)
{
PrintFilteredActorList(Level, IsActor, argv.argc() > 1 ? argv[1] : NULL, true);
});
}

//-----------------------------------------------------------------------------
@@ -991,14 +998,20 @@ CCMD(monster)
{
if (CheckCheatmode ()) return;

PrintFilteredActorList(IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL, false);
ForAllLevels([&](FLevelLocals *Level)
{
PrintFilteredActorList(Level, IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL, false);
});
}

CCMD(monsternum) // [SP] count monsters
{
if (CheckCheatmode ()) return;

PrintFilteredActorList(IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL, true);
ForAllLevels([&](FLevelLocals *Level)
{
PrintFilteredActorList(Level, IsActorAMonster, argv.argc() > 1 ? argv[1] : NULL, true);
});
}

//-----------------------------------------------------------------------------
@@ -1010,14 +1023,20 @@ CCMD(items)
{
if (CheckCheatmode ()) return;

PrintFilteredActorList(IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL, false);
ForAllLevels([&](FLevelLocals *Level)
{
PrintFilteredActorList(Level, IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL, false);
});
}

CCMD(itemsnum) // [SP] # of any items
{
if (CheckCheatmode ()) return;

PrintFilteredActorList(IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL, true);
ForAllLevels([&](FLevelLocals *Level)
{
PrintFilteredActorList(Level, IsActorAnItem, argv.argc() > 1 ? argv[1] : NULL, true);
});
}

//-----------------------------------------------------------------------------
@@ -1029,14 +1048,20 @@ CCMD(countitems)
{
if (CheckCheatmode ()) return;

PrintFilteredActorList(IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL, false);
ForAllLevels([&](FLevelLocals *Level)
{
PrintFilteredActorList(Level, IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL, false);
});
}

CCMD(countitemsnum) // [SP] # of counted items
{
if (CheckCheatmode ()) return;

PrintFilteredActorList(IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL, true);
ForAllLevels([&](FLevelLocals *Level)
{
PrintFilteredActorList(Level, IsActorACountItem, argv.argc() > 1 ? argv[1] : NULL, true);
});
}

//-----------------------------------------------------------------------------
@@ -2085,12 +2085,12 @@ static int KillAll(PClassActor *cls)
return P_Massacre(false, cls);
}

static int RemoveClass(const PClass *cls)
static int RemoveClass(FLevelLocals *Level, const PClass *cls)
{
AActor *actor;
int removecount = 0;
bool player = false;
TThinkerIterator<AActor> iterator(cls);
TThinkerIterator<AActor> iterator(Level, cls);
while ((actor = iterator.Next()))
{
if (actor->IsA(cls))
@@ -2589,11 +2589,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player)
PClassActor *cls = PClass::FindActor(s);
if (cls != NULL && cls->IsDescendantOf(RUNTIME_CLASS(AActor)))
{
removecount = RemoveClass(cls);
removecount = RemoveClass(players[player].mo->Level, cls);
const PClass *cls_rep = cls->GetReplacement();
if (cls != cls_rep)
{
removecount += RemoveClass(cls_rep);
removecount += RemoveClass(players[player].mo->Level, cls_rep);
}
Printf("Removed %d actors of type %s.\n", removecount, s);
}
@@ -878,7 +878,7 @@ size_t DThinker::PropagateMark()
//
//==========================================================================

FThinkerIterator::FThinkerIterator (const PClass *type, int statnum)
FThinkerIterator::FThinkerIterator (FLevelLocals *Level, const PClass *type, int statnum)
{
if ((unsigned)statnum > MAX_STATNUM)
{
@@ -901,7 +901,7 @@ FThinkerIterator::FThinkerIterator (const PClass *type, int statnum)
//
//==========================================================================

FThinkerIterator::FThinkerIterator (const PClass *type, int statnum, DThinker *prev)
FThinkerIterator::FThinkerIterator (FLevelLocals *Level, const PClass *type, int statnum, DThinker *prev)
{
if ((unsigned)statnum > MAX_STATNUM)
{
@@ -128,10 +128,11 @@ class FThinkerIterator
uint8_t m_Stat;
bool m_SearchStats;
bool m_SearchingFresh;
FLevelLocals *Level;

public:
FThinkerIterator (const PClass *type, int statnum=MAX_STATNUM+1);
FThinkerIterator (const PClass *type, int statnum, DThinker *prev);
FThinkerIterator (FLevelLocals *Level, const PClass *type, int statnum=MAX_STATNUM+1);
FThinkerIterator (FLevelLocals *Level, const PClass *type, int statnum, DThinker *prev);
DThinker *Next (bool exact = false);
void Reinit ();

@@ -142,28 +143,28 @@ class FThinkerIterator
template <class T> class TThinkerIterator : public FThinkerIterator
{
public:
TThinkerIterator (int statnum=MAX_STATNUM+1) : FThinkerIterator (RUNTIME_CLASS(T), statnum)
TThinkerIterator (FLevelLocals *Level, int statnum=MAX_STATNUM+1) : FThinkerIterator (Level, RUNTIME_CLASS(T), statnum)
{
}
TThinkerIterator (int statnum, DThinker *prev) : FThinkerIterator (RUNTIME_CLASS(T), statnum, prev)
TThinkerIterator (FLevelLocals *Level, int statnum, DThinker *prev) : FThinkerIterator (Level, RUNTIME_CLASS(T), statnum, prev)
{
}
TThinkerIterator (const PClass *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(subclass, statnum)
TThinkerIterator (FLevelLocals *Level, const PClass *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(Level, subclass, statnum)
{
}
TThinkerIterator (FName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(PClass::FindClass(subclass), statnum)
TThinkerIterator (FLevelLocals *Level, FName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum)
{
}
TThinkerIterator (ENamedName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(PClass::FindClass(subclass), statnum)
TThinkerIterator (FLevelLocals *Level, ENamedName subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum)
{
}
TThinkerIterator (FName subclass, int statnum, DThinker *prev) : FThinkerIterator(PClass::FindClass(subclass), statnum, prev)
TThinkerIterator (FLevelLocals *Level, FName subclass, int statnum, DThinker *prev) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum, prev)
{
}
TThinkerIterator (ENamedName subclass, int statnum, DThinker *prev) : FThinkerIterator(PClass::FindClass(subclass), statnum, prev)
TThinkerIterator (FLevelLocals *Level, ENamedName subclass, int statnum, DThinker *prev) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum, prev)
{
}
TThinkerIterator (const char *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(PClass::FindClass(subclass), statnum)
TThinkerIterator (FLevelLocals *Level, const char *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(Level, PClass::FindClass(subclass), statnum)
{
}
T *Next (bool exact = false)
@@ -712,7 +712,7 @@ static FWorldEvent E_SetupWorldEvent()
{
FWorldEvent e;
e.IsSaveGame = savegamerestore;
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.IsReopen = currentSession->Levelinfo[0]->FromSnapshot && !savegamerestore; // each one by itself isnt helpful, but with hub load we have savegamerestore==0 and FromSnapshot==1.
e.DamageAngle = 0.0;
return e;
}
@@ -2098,7 +2098,7 @@ void FParser::SF_LineTrigger()
mld.special=intvalue(t_argv[0]);
mld.tag=t_argc > 1 ? intvalue(t_argv[1]) : 0;
P_TranslateLineDef(&line, &mld);
P_ExecuteSpecial(line.special, NULL, Script->trigger, false,
P_ExecuteSpecial(Level, line.special, NULL, Script->trigger, false,
line.args[0],line.args[1],line.args[2],line.args[3],line.args[4]);
}
}
@@ -3645,7 +3645,7 @@ void FParser::SF_ThingCount(void)
pClass = pClass->GetReplacement();

again:
TThinkerIterator<AActor> it;
TThinkerIterator<AActor> it(Level);

if (t_argc<2 || intvalue(t_argv[1])==0 || pClass->IsDescendantOf(NAME_Inventory))
{
@@ -3786,7 +3786,7 @@ void FParser::SF_KillInSector()
{
if (CheckArgs(1))
{
TThinkerIterator<AActor> it;
TThinkerIterator<AActor> it(Level);
AActor * mo;
int tag=intvalue(t_argv[0]);

@@ -3848,7 +3848,7 @@ void FParser::RunLineSpecial(const FLineSpecial *spec)
if (t_argc>i) args[i]=intvalue(t_argv[i]);
else args[i] = 0;
}
t_return.value.i = P_ExecuteSpecial(spec->number, NULL,Script->trigger,false, args[0],args[1],args[2],args[3],args[4]);
t_return.value.i = P_ExecuteSpecial(Level, spec->number, NULL,Script->trigger,false, args[0],args[1],args[2],args[3],args[4]);
}
}

@@ -339,7 +339,7 @@ void DFsScript::DryRunScript()
char *rover = data;

// allocate space for the tokens
FParser parse(&level, this);
FParser parse(Level, this);
try
{
while(rover < end && *rover)
@@ -429,7 +429,7 @@ void DFsScript::ParseInclude(char *lumpname)
ProcessFindChar(lump, 0);

// now parse the lump
FParser parse(&level, this);
FParser parse(Level, this);
parse.Run(lump, lump, lump+lumplen);

// free the lump
@@ -1103,7 +1103,7 @@ void G_Ticker ()
uint32_t rngsum = FRandom::StaticSumSeeds ();

//Added by MC: For some of that bot stuff. The main bot function.
bglobal.Main (&level);
bglobal.Main (currentSession->Levelinfo[0]);

for (i = 0; i < MAXPLAYERS; i++)
{
@@ -1429,7 +1429,7 @@ static FPlayerStart *SelectRandomDeathmatchSpot (FLevelLocals *Level, int player
DEFINE_ACTION_FUNCTION(DObject, G_PickDeathmatchStart)
{
PARAM_PROLOGUE;
auto Level = &level;
auto Level = currentSession->Levelinfo[0];
unsigned int selections = Level->deathmatchstarts.Size();
DVector3 pos;
int angle;
@@ -1600,7 +1600,7 @@ static void G_QueueBody (AActor *body)
EXTERN_CVAR(Bool, sv_singleplayerrespawn)
void G_DoReborn (int playernum, bool freshbot)
{
auto Level = &level;
auto Level = currentSession->Levelinfo[0];
if (!multiplayer && !(Level->flags2 & LEVEL2_ALLOWRESPAWN) && !sv_singleplayerrespawn &&
!G_SkillProperty(SKILLP_PlayerRespawn))
{
@@ -2718,10 +2718,12 @@ void G_DoPlayDemo (void)
{
G_InitNew (mapname, false);
}
else if (level.sectors.Size() == 0)
/*
else if (!currentSession || currenlevel.sectors.Size() == 0)
{
I_Error("Cannot play demo without its savegame\n");
}
*/
C_HideConsole ();
demonew = false;
precache = true;
@@ -387,7 +387,7 @@ void G_NewInit ()
int i;

// Destory all old player refrences that may still exist
TThinkerIterator<AActor> it(NAME_PlayerPawn, STAT_TRAVELLING);
TThinkerIterator<AActor> it(currentSession->Levelinfo[0], NAME_PlayerPawn, STAT_TRAVELLING);
AActor *pawn, *next;

next = it.Next();
@@ -1380,7 +1380,7 @@ void G_StartTravel ()

int G_FinishTravel ()
{
TThinkerIterator<AActor> it (NAME_PlayerPawn, STAT_TRAVELLING);
TThinkerIterator<AActor> it (currentSession->Levelinfo[0], NAME_PlayerPawn, STAT_TRAVELLING);
AActor *pawn, *pawndup, *oldpawn, *next;
AActor *inv;
FPlayerStart *start;
@@ -1744,7 +1744,7 @@ void G_UnSnapshotLevel (bool hubLoad)
arc.SetLevel(nullptr);
level.FromSnapshot = true;

TThinkerIterator<AActor> it(NAME_PlayerPawn);
TThinkerIterator<AActor> it(currentSession->Levelinfo[0], NAME_PlayerPawn);
AActor *pawn, *next;

next = it.Next();
Oops, something went wrong.

0 comments on commit 1b1e2ef

Please sign in to comment.