Hack P_SpawnMapThing into tiny little pieces
It's impossible to follow the control flow of P_SpawnMapThing
because it's well over 1000 lines long, so I hacked it into tiny little pieces. It's now about 90 lines long, with the rest separated into various subfunctions. These include:
-
P_SpawnNonMobjMapThing
: Handles the spawning of mapthings that don't have an associated mobjtype. -
P_AllowMobjSpawn
: Checks if the mobj is allowed to be spawned. This was previously handled via early returning. -
P_GetMobjtypeSubstitute
: Handles the cases where the mobjtype is substituted for something else (e.g., extra lives turning into score monitors in Record Attack). This was previously mixed in with the early returning. Separating the two does technically make the code marginally slower because some mobjtype checks are now done twice, but the performance loss is miniscule and this isn't performance-critical code anyway. -
P_SetupSpawnedMapThing
: Contains all the mobjtype-specific post-spawn code, including the Lua hook. - Some of the longer cases in
P_SetupSpawnedMapThing
's giant switch-case statement were separated into their own functions. -
P_SetAmbush
andP_SetObjectSpecial
: Handling ofMTF_AMBUSH
andMTF_OBJECTSPECIAL
.
This is based on !562 (merged), so review that first.