From b4acb857ade5ce655e508f37a85ce9f3495ae106 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Jan 2019 21:59:19 +0100 Subject: [PATCH] - the final batch of easy level replacements. What's left will require a bit more work... --- src/c_bind.cpp | 1 - src/c_cmds.cpp | 20 +++++------ src/c_console.cpp | 2 +- src/fragglescript/t_func.cpp | 4 +-- src/g_level.cpp | 30 ++++++++-------- src/g_level.h | 2 -- src/g_levellocals.h | 18 ++++++++++ src/g_shared/a_quake.cpp | 12 +++---- src/maploader/maploader.cpp | 2 +- src/p_3dfloors.cpp | 4 +-- src/p_3dfloors.h | 1 - src/p_acs.cpp | 16 ++++----- src/p_actionfunctions.cpp | 4 +-- src/p_conversation.cpp | 2 +- src/p_lnspec.cpp | 40 ++++++++++----------- src/p_local.h | 7 ---- src/p_maputl.cpp | 36 +++++++++---------- src/p_mobj.cpp | 64 +++++++++++++++++++--------------- src/p_saveg.cpp | 14 ++++---- src/p_secnodes.cpp | 10 +++--- src/p_sectors.cpp | 32 ++++++++--------- src/p_spec.h | 10 ++---- src/p_teleport.cpp | 50 +++++++++++++------------- src/p_things.cpp | 31 ++++++++-------- src/p_user.cpp | 4 +-- src/r_data/a_dynlightdata.cpp | 2 +- src/r_data/r_canvastexture.cpp | 2 +- src/r_data/r_translate.cpp | 2 +- src/scripting/vmthunks.cpp | 10 +++--- wadsrc/static/zscript/base.txt | 6 +++- 30 files changed, 226 insertions(+), 212 deletions(-) diff --git a/src/c_bind.cpp b/src/c_bind.cpp index f2758ab13..0427d5c45 100644 --- a/src/c_bind.cpp +++ b/src/c_bind.cpp @@ -753,7 +753,6 @@ bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds) dclickmask = 1 << (ev->data1 & 7); dclick = false; - // This used level.time which didn't work outside a level. nowtime = (unsigned)I_msTime(); if (doublebinds != NULL && int(DClickTime[ev->data1] - nowtime) > 0 && ev->type == EV_KeyDown) { diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 4edf8e6ca..b9ec1228f 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -1099,9 +1099,9 @@ CCMD(nextmap) return; } - if (level.NextMap.Len() > 0 && level.NextMap.Compare("enDSeQ", 6)) + if (currentUILevel->NextMap.Len() > 0 && currentUILevel->NextMap.Compare("enDSeQ", 6)) { - G_DeferedInitNew(level.NextMap); + G_DeferedInitNew(currentUILevel->NextMap); } else { @@ -1123,9 +1123,9 @@ CCMD(nextsecret) return; } - if (level.NextSecretMap.Len() > 0 && level.NextSecretMap.Compare("enDSeQ", 6)) + if (currentUILevel->NextSecretMap.Len() > 0 && currentUILevel->NextSecretMap.Compare("enDSeQ", 6)) { - G_DeferedInitNew(level.NextSecretMap); + G_DeferedInitNew(currentUILevel->NextSecretMap); } else { @@ -1170,10 +1170,10 @@ static void PrintSecretString(const char *string, bool thislevel) { auto secnum = (unsigned)strtoull(string+2, (char**)&string, 10); if (*string == ';') string++; - if (thislevel && secnum < level.sectors.Size()) + if (thislevel && secnum < currentUILevel->sectors.Size()) { - if (level.sectors[secnum].isSecret()) colstr = TEXTCOLOR_RED; - else if (level.sectors[secnum].wasSecret()) colstr = TEXTCOLOR_GREEN; + if (currentUILevel->sectors[secnum].isSecret()) colstr = TEXTCOLOR_RED; + else if (currentUILevel->sectors[secnum].wasSecret()) colstr = TEXTCOLOR_GREEN; else colstr = TEXTCOLOR_ORANGE; } } @@ -1181,7 +1181,7 @@ static void PrintSecretString(const char *string, bool thislevel) { long tid = (long)strtoll(string+2, (char**)&string, 10); if (*string == ';') string++; - auto it = level.GetActorIterator(tid); + auto it = currentUILevel->GetActorIterator(tid); AActor *actor; bool foundone = false; if (thislevel) @@ -1214,8 +1214,8 @@ static void PrintSecretString(const char *string, bool thislevel) CCMD(secret) { - const char *mapname = argv.argc() < 2? level.MapName.GetChars() : argv[1]; - bool thislevel = !stricmp(mapname, level.MapName); + const char *mapname = argv.argc() < 2? currentUILevel->MapName.GetChars() : argv[1]; + bool thislevel = !stricmp(mapname, currentUILevel->MapName); bool foundsome = false; int lumpno=Wads.CheckNumForName("SECRETS"); diff --git a/src/c_console.cpp b/src/c_console.cpp index 8d2d1dfca..d72b29465 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -1243,7 +1243,7 @@ void C_FullConsole () if (gamestate != GS_STARTUP) { gamestate = GS_FULLCONSOLE; - level.Music = ""; + currentUILevel->Music = ""; S_Start (); P_FreeLevelData (); V_SetBlend (0,0,0,0); diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 90513d97d..2797191bc 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -1040,7 +1040,7 @@ void FParser::SF_Teleport(void) } if(mo) - EV_Teleport(0, tag, NULL, 0, mo, TELF_DESTFOG | TELF_SOURCEFOG); + Level->EV_Teleport(0, tag, NULL, 0, mo, TELF_DESTFOG | TELF_SOURCEFOG); } } @@ -1069,7 +1069,7 @@ void FParser::SF_SilentTeleport(void) } if(mo) - EV_Teleport(0, tag, NULL, 0, mo, TELF_KEEPORIENTATION); + Level->EV_Teleport(0, tag, NULL, 0, mo, TELF_KEEPORIENTATION); } } diff --git a/src/g_level.cpp b/src/g_level.cpp index aca407802..4f57af68a 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -885,7 +885,7 @@ void G_DoCompleted (void) ((level.flags & LEVEL_NOINTERMISSION) || ((nextcluster == thiscluster) && (thiscluster->flags & CLUSTER_HUB) && !(thiscluster->flags & CLUSTER_ALLOWINTERMISSION)))) { - G_WorldDone (); + level.WorldDone (); return; } @@ -1131,17 +1131,17 @@ void G_DoLoadLevel (int position, bool autosave, bool newGame) // //========================================================================== -void G_WorldDone (void) +void FLevelLocals::WorldDone (void) { cluster_info_t *nextcluster; cluster_info_t *thiscluster; gameaction = ga_worlddone; - if (level.flags & LEVEL_CHANGEMAPCHEAT) + if (flags & LEVEL_CHANGEMAPCHEAT) return; - thiscluster = FindClusterInfo (level.cluster); + thiscluster = FindClusterInfo (cluster); if (strncmp (nextlevel, "enDSeQ", 6) == 0) { @@ -1160,7 +1160,7 @@ void G_WorldDone (void) } } - auto ext = level.info->ExitMapTexts.CheckKey(level.flags3 & LEVEL3_EXITSECRETUSED ? NAME_Secret : NAME_Normal); + auto ext = info->ExitMapTexts.CheckKey(flags3 & LEVEL3_EXITSECRETUSED ? NAME_Secret : NAME_Normal); if (ext != nullptr && (ext->mDefined & FExitText::DEF_TEXT)) { F_StartFinale(ext->mDefined & FExitText::DEF_MUSIC ? ext->mMusic : gameinfo.finaleMusic, @@ -1188,9 +1188,9 @@ void G_WorldDone (void) { FExitText *ext = nullptr; - if (level.flags3 & LEVEL3_EXITSECRETUSED) ext = level.info->ExitMapTexts.CheckKey(NAME_Secret); - else if (level.flags3 & LEVEL3_EXITNORMALUSED) ext = level.info->ExitMapTexts.CheckKey(NAME_Normal); - if (ext == nullptr) ext = level.info->ExitMapTexts.CheckKey(nextlevel); + if (flags3 & LEVEL3_EXITSECRETUSED) ext = info->ExitMapTexts.CheckKey(NAME_Secret); + else if (flags3 & LEVEL3_EXITNORMALUSED) ext = info->ExitMapTexts.CheckKey(NAME_Normal); + if (ext == nullptr) ext = info->ExitMapTexts.CheckKey(nextlevel); if (ext != nullptr) { @@ -1211,7 +1211,7 @@ void G_WorldDone (void) nextcluster = FindClusterInfo (FindLevelInfo (nextlevel)->cluster); - if (nextcluster->cluster != level.cluster && !deathmatch) + if (nextcluster->cluster != cluster && !deathmatch) { // Only start the finale if the next level's cluster is different // than the current one and we're not in deathmatch. @@ -1241,7 +1241,7 @@ void G_WorldDone (void) DEFINE_ACTION_FUNCTION(FLevelLocals, WorldDone) { - G_WorldDone(); + currentUILevel->WorldDone(); return 0; } @@ -1492,7 +1492,7 @@ void FLevelLocals::Init() teamdamage = info->teamdamage; } - G_AirControlChanged (); + AirControlChanged (); cluster_info_t *clus = FindClusterInfo (info->cluster); @@ -1625,16 +1625,16 @@ FString CalcMapName (int episode, int level) // //========================================================================== -void G_AirControlChanged () +void FLevelLocals::AirControlChanged () { - if (level.aircontrol <= 1/256.) + if (aircontrol <= 1/256.) { - level.airfriction = 1.; + airfriction = 1.; } else { // Friction is inversely proportional to the amount of control - level.airfriction = level.aircontrol * -0.0941 + 1.0004; + airfriction = aircontrol * -0.0941 + 1.0004; } } diff --git a/src/g_level.h b/src/g_level.h index 5e42fcc44..9686a4e5c 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -477,8 +477,6 @@ int G_FinishTravel (); void G_DoLoadLevel (int position, bool autosave, bool newGame); -void G_AirControlChanged (); - cluster_info_t *FindClusterInfo (int cluster); level_info_t *FindLevelInfo (const char *mapname, bool allowdefault=true); level_info_t *FindLevelByNum (int num); diff --git a/src/g_levellocals.h b/src/g_levellocals.h index ac416ee70..79012fb58 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -209,6 +209,18 @@ public: AActor *SpawnPlayer(FPlayerStart *mthing, int playernum, int flags); void StartLightning(); void ForceLightning(int mode); + void ClearDynamic3DFloorData(); + void WorldDone(void); + void AirControlChanged(); + AActor *SelectTeleDest(int tid, int tag, bool norandom); + bool AlignFlat(int linenum, int side, int fc); + void ReplaceTextures(const char *fromname, const char *toname, int flags); + + bool EV_Thing_Spawn(int tid, AActor *source, int type, DAngle angle, bool fog, int newtid); + bool EV_Thing_Move(int tid, AActor *source, int mapspot, bool fog); + bool EV_Thing_Projectile(int tid, AActor *source, int type, const char *type_name, DAngle angle, + double speed, double vspeed, int dest, AActor *forcedest, int gravity, int newtid, bool leadTarget); + int EV_Thing_Damage(int tid, AActor *whofor0, int amount, FName type); bool EV_DoPlat(int tag, line_t *line, DPlat::EPlatType type, double height, double speed, int delay, int lip, int change); void EV_StopPlat(int tag, bool remove); @@ -238,6 +250,12 @@ public: void EV_StartLightFading(int tag, int value, int tics); void EV_StopLightEffect(int tag); + bool EV_Teleport(int tid, int tag, line_t *line, int side, AActor *thing, int flags); + bool EV_SilentLineTeleport(line_t *line, int side, AActor *thing, int id, INTBOOL reverse); + bool EV_TeleportOther(int other_tid, int dest_tid, bool fog); + bool EV_TeleportGroup(int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog); + bool EV_TeleportSector(int tag, int source_tid, int dest_tid, bool fog, int group_tid); + void RecalculateDrawnSubsectors(); FSerializer &SerializeSubsectors(FSerializer &arc, const char *key); void SpawnExtraPlayers(); diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 098e6d893..892ba586b 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -367,7 +367,7 @@ int DEarthquake::StaticGetQuakeIntensities(double ticFrac, AActor *victim, FQuak // //========================================================================== -bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, +bool P_StartQuakeXYZ(FLevelLocals *Level, AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave) @@ -383,18 +383,18 @@ bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, { if (activator != NULL) { - level.CreateThinker(activator, intensityX, intensityY, intensityZ, duration, damrad, tremrad, + Level->CreateThinker(activator, intensityX, intensityY, intensityZ, duration, damrad, tremrad, quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ, falloff, highpoint, rollIntensity, rollWave); return true; } } else { - auto iterator = level.GetActorIterator(tid); + auto iterator = Level->GetActorIterator(tid); while ( (center = iterator.Next ()) ) { res = true; - level.CreateThinker(center, intensityX, intensityY, intensityZ, duration, damrad, tremrad, + Level->CreateThinker(center, intensityX, intensityY, intensityZ, duration, damrad, tremrad, quakesfx, flags, waveSpeedX, waveSpeedY, waveSpeedZ, falloff, highpoint, rollIntensity, rollWave); } } @@ -402,7 +402,7 @@ bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, return res; } -bool P_StartQuake(AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx) +bool P_StartQuake(FLevelLocals *Level, AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx) { //Maintains original behavior by passing 0 to intensityZ, flags, and everything else after QSFX. - return P_StartQuakeXYZ(activator, tid, intensity, intensity, 0, duration, damrad, tremrad, quakesfx, 0, 0, 0, 0, 0, 0, 0, 0); + return P_StartQuakeXYZ(Level, activator, tid, intensity, intensity, 0, duration, damrad, tremrad, quakesfx, 0, 0, 0, 0, 0, 0, 0, 0); } diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 7b0c241f6..b3695754e 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -3275,7 +3275,7 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position) } InitRenderInfo(); // create hardware independent renderer resources for the level. This must be done BEFORE the PolyObj Spawn!!! - P_ClearDynamic3DFloorData(); // CreateVBO must be run on the plain 3D floor data. + Level->ClearDynamic3DFloorData(); // CreateVBO must be run on the plain 3D floor data. screen->mVertexData->CreateVBO(Level->sectors); for (auto &sec : Level->sectors) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index e71038fda..4da592cf4 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -558,9 +558,9 @@ void P_Recalculate3DFloors(sector_t * sector) // //========================================================================== -void P_ClearDynamic3DFloorData() +void FLevelLocals::ClearDynamic3DFloorData() { - for (auto &sec : level.sectors) + for (auto &sec : sectors) { TArray & ffloors = sec.e->XFloor.ffloors; diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 5a8abb807..fc82b7550 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -123,7 +123,6 @@ void P_Recalculate3DFloors(sector_t *); void P_RecalculateAttached3DFloors(sector_t * sec); void P_RecalculateLights(sector_t *sector); void P_RecalculateAttachedLights(sector_t *sector); -void P_ClearDynamic3DFloorData(); lightlist_t * P_GetPlaneLight(sector_t * , secplane_t * plane, bool underside); void P_Spawn3DFloors( void ); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 2ebdfd0b4..e589d8d07 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -5571,7 +5571,7 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, int32_t *args) } case ACSF_Radius_Quake2: - P_StartQuake(activator, args[0], args[1], args[2], args[3], args[4], Level->Behaviors.LookupString(args[5])); + P_StartQuake(Level, activator, args[0], args[1], args[2], args[3], args[4], Level->Behaviors.LookupString(args[5])); break; case ACSF_CheckActorClass: @@ -6150,7 +6150,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_QuakeEx: { - return P_StartQuakeXYZ(activator, args[0], args[1], args[2], args[3], args[4], args[5], args[6], Level->Behaviors.LookupString(args[7]), + return P_StartQuakeXYZ(Level, activator, args[0], args[1], args[2], args[3], args[4], args[5], args[6], Level->Behaviors.LookupString(args[7]), argCount > 8 ? args[8] : 0, argCount > 9 ? ACSToDouble(args[9]) : 1.0, argCount > 10 ? ACSToDouble(args[10]) : 1.0, @@ -8880,7 +8880,7 @@ scriptwait: const char *fromname = Level->Behaviors.LookupString(STACK(3)); const char *toname = Level->Behaviors.LookupString(STACK(2)); - P_ReplaceTextures(fromname, toname, STACK(1)); + Level->ReplaceTextures(fromname, toname, STACK(1)); sp -= 3; break; } @@ -9049,13 +9049,13 @@ scriptwait: case PCD_SETAIRCONTROL: Level->aircontrol = ACSToDouble(STACK(1)); sp--; - G_AirControlChanged (); + Level->AirControlChanged (); break; case PCD_SETAIRCONTROLDIRECT: Level->aircontrol = ACSToDouble(uallong(pc[0])); pc++; - G_AirControlChanged (); + Level->AirControlChanged (); break; case PCD_SPAWN: @@ -9689,14 +9689,14 @@ scriptwait: // Like Thing_Projectile(Gravity) specials, but you can give the // projectile a TID. // Thing_Projectile2 (tid, type, angle, speed, vspeed, gravity, newtid); - P_Thing_Projectile(STACK(7), activator, STACK(6), NULL, STACK(5) * (360. / 256.), + Level->EV_Thing_Projectile(STACK(7), activator, STACK(6), NULL, STACK(5) * (360. / 256.), STACK(4) / 8., STACK(3) / 8., 0, NULL, STACK(2), STACK(1), false); sp -= 7; break; case PCD_SPAWNPROJECTILE: // Same, but takes an actor name instead of a spawn ID. - P_Thing_Projectile(STACK(7), activator, 0, Level->Behaviors.LookupString(STACK(6)), STACK(5) * (360. / 256.), + Level->EV_Thing_Projectile(STACK(7), activator, 0, Level->Behaviors.LookupString(STACK(6)), STACK(5) * (360. / 256.), STACK(4) / 8., STACK(3) / 8., 0, NULL, STACK(2), STACK(1), false); sp -= 7; break; @@ -9913,7 +9913,7 @@ scriptwait: break; case PCD_THINGDAMAGE2: - STACK(3) = P_Thing_Damage (STACK(3), activator, STACK(2), FName(Level->Behaviors.LookupString(STACK(1)))); + STACK(3) = Level->EV_Thing_Damage (STACK(3), activator, STACK(2), FName(Level->Behaviors.LookupString(STACK(1)))); sp -= 2; break; diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 15cdf32ae..347b6ee01 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -3178,7 +3178,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Quake) PARAM_INT (tremrad); PARAM_SOUND (sound); - P_StartQuake(self, 0, intensity, duration, damrad, tremrad, sound); + P_StartQuake(self->Level, self, 0, intensity, duration, damrad, tremrad, sound); return 0; } @@ -3208,7 +3208,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_QuakeEx) PARAM_INT(highpoint); PARAM_FLOAT(rollIntensity); PARAM_FLOAT(rollWave); - P_StartQuakeXYZ(self, 0, intensityX, intensityY, intensityZ, duration, damrad, tremrad, sound, flags, mulWaveX, mulWaveY, mulWaveZ, falloff, highpoint, + P_StartQuakeXYZ(self->Level, self, 0, intensityX, intensityY, intensityZ, duration, damrad, tremrad, sound, flags, mulWaveX, mulWaveY, mulWaveZ, falloff, highpoint, rollIntensity, rollWave); return 0; } diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index e65321d8c..ed25f3c9c 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -1064,7 +1064,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply if (isconsole) { - I_SetMusicVolume (level.MusicVolume); + I_SetMusicVolume (player->mo->Level->MusicVolume); } } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index a29580fb9..ceebb43ee 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1103,7 +1103,7 @@ FUNC(LS_Teleport) { flags |= TELF_SOURCEFOG; } - return EV_Teleport (arg0, arg1, ln, backSide, it, flags); + return Level->EV_Teleport (arg0, arg1, ln, backSide, it, flags); } FUNC( LS_Teleport_NoStop ) @@ -1114,7 +1114,7 @@ FUNC( LS_Teleport_NoStop ) { flags |= TELF_SOURCEFOG; } - return EV_Teleport( arg0, arg1, ln, backSide, it, flags); + return Level->EV_Teleport( arg0, arg1, ln, backSide, it, flags); } FUNC(LS_Teleport_NoFog) @@ -1144,7 +1144,7 @@ FUNC(LS_Teleport_NoFog) { flags |= TELF_KEEPHEIGHT; } - return EV_Teleport (arg0, arg2, ln, backSide, it, flags); + return Level->EV_Teleport (arg0, arg2, ln, backSide, it, flags); } FUNC(LS_Teleport_ZombieChanger) @@ -1153,7 +1153,7 @@ FUNC(LS_Teleport_ZombieChanger) // This is practically useless outside of Strife, but oh well. if (it != NULL) { - EV_Teleport (arg0, arg1, ln, backSide, it, 0); + Level->EV_Teleport (arg0, arg1, ln, backSide, it, 0); if (it->health >= 0) it->SetState (it->FindState(NAME_Pain)); return true; } @@ -1163,19 +1163,19 @@ FUNC(LS_Teleport_ZombieChanger) FUNC(LS_TeleportOther) // TeleportOther (other_tid, dest_tid, fog?) { - return EV_TeleportOther (arg0, arg1, arg2?true:false); + return Level->EV_TeleportOther (arg0, arg1, arg2?true:false); } FUNC(LS_TeleportGroup) // TeleportGroup (group_tid, source_tid, dest_tid, move_source?, fog?) { - return EV_TeleportGroup (arg0, it, arg1, arg2, arg3?true:false, arg4?true:false); + return Level->EV_TeleportGroup (arg0, it, arg1, arg2, arg3?true:false, arg4?true:false); } FUNC(LS_TeleportInSector) // TeleportInSector (tag, source_tid, dest_tid, bFog, group_tid) { - return EV_TeleportSector (arg0, arg1, arg2, arg3?true:false, arg4); + return Level->EV_TeleportSector (arg0, arg1, arg2, arg3?true:false, arg4); } FUNC(LS_Teleport_EndGame) @@ -1192,7 +1192,7 @@ FUNC(LS_Teleport_EndGame) FUNC(LS_Teleport_Line) // Teleport_Line (thisid, destid, reversed) { - return EV_SilentLineTeleport (ln, backSide, it, arg1, arg2); + return Level->EV_SilentLineTeleport (ln, backSide, it, arg1, arg2); } static void ThrustThingHelper(AActor *it, DAngle angle, double force, INTBOOL nolimit) @@ -1544,21 +1544,21 @@ FUNC(LS_Thing_Destroy) FUNC(LS_Thing_Damage) // Thing_Damage (tid, amount, MOD) { - P_Thing_Damage (arg0, it, arg1, MODtoDamageType (arg2)); + Level->EV_Thing_Damage (arg0, it, arg1, MODtoDamageType (arg2)); return true; } FUNC(LS_Thing_Projectile) // Thing_Projectile (tid, type, angle, speed, vspeed) { - return P_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), SPEED(arg3), + return Level->EV_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), SPEED(arg3), SPEED(arg4), 0, NULL, 0, 0, false); } FUNC(LS_Thing_ProjectileGravity) // Thing_ProjectileGravity (tid, type, angle, speed, vspeed) { - return P_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), SPEED(arg3), + return Level->EV_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), SPEED(arg3), SPEED(arg4), 0, NULL, 1, 0, false); } @@ -1728,32 +1728,32 @@ FUNC(LS_Thing_Hate) FUNC(LS_Thing_ProjectileAimed) // Thing_ProjectileAimed (tid, type, speed, target, newtid) { - return P_Thing_Projectile (arg0, it, arg1, NULL, 0., SPEED(arg2), 0, arg3, it, 0, arg4, false); + return Level->EV_Thing_Projectile (arg0, it, arg1, NULL, 0., SPEED(arg2), 0, arg3, it, 0, arg4, false); } FUNC(LS_Thing_ProjectileIntercept) // Thing_ProjectileIntercept (tid, type, speed, target, newtid) { - return P_Thing_Projectile (arg0, it, arg1, NULL, 0., SPEED(arg2), 0, arg3, it, 0, arg4, true); + return Level->EV_Thing_Projectile (arg0, it, arg1, NULL, 0., SPEED(arg2), 0, arg3, it, 0, arg4, true); } // [BC] added newtid for next two FUNC(LS_Thing_Spawn) // Thing_Spawn (tid, type, angle, newtid) { - return P_Thing_Spawn (arg0, it, arg1, BYTEANGLE(arg2), true, arg3); + return Level->EV_Thing_Spawn (arg0, it, arg1, BYTEANGLE(arg2), true, arg3); } FUNC(LS_Thing_SpawnNoFog) // Thing_SpawnNoFog (tid, type, angle, newtid) { - return P_Thing_Spawn (arg0, it, arg1, BYTEANGLE(arg2), false, arg3); + return Level->EV_Thing_Spawn (arg0, it, arg1, BYTEANGLE(arg2), false, arg3); } FUNC(LS_Thing_SpawnFacing) // Thing_SpawnFacing (tid, type, nofog, newtid) { - return P_Thing_Spawn (arg0, it, arg1, 1000000., arg2 ? false : true, arg3); + return Level->EV_Thing_Spawn (arg0, it, arg1, 1000000., arg2 ? false : true, arg3); } FUNC(LS_Thing_Raise) @@ -1850,7 +1850,7 @@ FUNC(LS_Thing_SetGoal) FUNC(LS_Thing_Move) // [BC] // Thing_Move (tid, mapspot, nofog) { - return P_Thing_Move (arg0, it, arg1, arg2 ? false : true); + return Level->EV_Thing_Move (arg0, it, arg1, arg2 ? false : true); } enum @@ -2153,7 +2153,7 @@ FUNC(LS_Light_Stop) FUNC(LS_Radius_Quake) // Radius_Quake (intensity, duration, damrad, tremrad, tid) { - return P_StartQuake (it, arg4, arg0, arg1, arg2*64, arg3*64, "world/quake"); + return P_StartQuake (Level, it, arg4, arg0, arg1, arg2*64, arg3*64, "world/quake"); } FUNC(LS_UsePuzzleItem) @@ -2597,7 +2597,7 @@ FUNC(LS_Line_AlignCeiling) int line; while ((line = itr.Next()) >= 0) { - ret |= P_AlignFlat (line, !!arg1, 1); + ret |= Level->AlignFlat (line, !!arg1, 1); } return ret; } @@ -2611,7 +2611,7 @@ FUNC(LS_Line_AlignFloor) int line; while ((line = itr.Next()) >= 0) { - ret |= P_AlignFlat (line, !!arg1, 0); + ret |= Level->AlignFlat (line, !!arg1, 0); } return ret; } diff --git a/src/p_local.h b/src/p_local.h index 7b64fb807..e19581467 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -143,14 +143,7 @@ AActor *P_SpawnSubMissile (AActor *source, PClassActor *type, AActor *target); / extern FClassMap SpawnableThings; extern FClassMap StrifeTypes; -bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid); -bool P_Thing_Projectile (int tid, AActor *source, int type, const char * type_name, DAngle angle, - double speed, double vspeed, int dest, AActor *forcedest, int gravity, int newtid, - bool leadTarget); - bool P_MoveThing(AActor *source, const DVector3 &pos, bool fog); -bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog); -int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type); void P_Thing_SetVelocity(AActor *actor, const DVector3 &vec, bool add, bool setbob); void P_RemoveThing(AActor * actor); bool P_Thing_Raise(AActor *thing, AActor *raiser, int flags = 0); diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index cf4b3cf03..4d748aa72 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -356,17 +356,17 @@ bool AActor::FixMapthingPos() { sector_t *secstart = P_PointInSectorBuggy(X(), Y()); - int blockx = level.blockmap.GetBlockX(X()); - int blocky = level.blockmap.GetBlockY(Y()); + int blockx = Level->blockmap.GetBlockX(X()); + int blocky = Level->blockmap.GetBlockY(Y()); bool success = false; - if (level.blockmap.isValidBlock(blockx, blocky)) + if (Level->blockmap.isValidBlock(blockx, blocky)) { int *list; - for (list = level.blockmap.GetLines(blockx, blocky); *list != -1; ++list) + for (list = Level->blockmap.GetLines(blockx, blocky); *list != -1; ++list) { - line_t *ldef = &level.lines[*list]; + line_t *ldef = &Level->lines[*list]; if (ldef->frontsector == ldef->backsector) { // Skip two-sided lines inside a single sector @@ -504,7 +504,7 @@ void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sec { FPortalGroupArray check; - level.CollectConnectedGroups(Sector->PortalGroup, Pos(), Top(), radius, check); + Level->CollectConnectedGroups(Sector->PortalGroup, Pos(), Top(), radius, check); BlockNode = NULL; FBlockNode **alink = &this->BlockNode; @@ -512,25 +512,25 @@ void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sec { DVector3 pos = i==-1? Pos() : PosRelative(check[i] & ~FPortalGroupArray::FLAT); - int x1 = level.blockmap.GetBlockX(pos.X - radius); - int x2 = level.blockmap.GetBlockX(pos.X + radius); - int y1 = level.blockmap.GetBlockY(pos.Y - radius); - int y2 = level.blockmap.GetBlockY(pos.Y + radius); + int x1 = Level->blockmap.GetBlockX(pos.X - radius); + int x2 = Level->blockmap.GetBlockX(pos.X + radius); + int y1 = Level->blockmap.GetBlockY(pos.Y - radius); + int y2 = Level->blockmap.GetBlockY(pos.Y + radius); - if (x1 >= level.blockmap.bmapwidth || x2 < 0 || y1 >= level.blockmap.bmapheight || y2 < 0) + if (x1 >= Level->blockmap.bmapwidth || x2 < 0 || y1 >= Level->blockmap.bmapheight || y2 < 0) { // thing is off the map } else { // [RH] Link into every block this actor touches, not just the center one x1 = MAX(0, x1); y1 = MAX(0, y1); - x2 = MIN(level.blockmap.bmapwidth - 1, x2); - y2 = MIN(level.blockmap.bmapheight - 1, y2); + x2 = MIN(Level->blockmap.bmapwidth - 1, x2); + y2 = MIN(Level->blockmap.bmapheight - 1, y2); for (int y = y1; y <= y2; ++y) { for (int x = x1; x <= x2; ++x) { - FBlockNode **link = &level.blockmap.blocklinks[y*level.blockmap.bmapwidth + x]; + FBlockNode **link = &Level->blockmap.blocklinks[y*Level->blockmap.bmapwidth + x]; FBlockNode *node = FBlockNode::Create(this, x, y, this->Sector->PortalGroup); // Link in to block @@ -1459,13 +1459,13 @@ void FPathTraverse::init(double x1, double y1, double x2, double y2, int flags, y2 += y1; } - x1 -= level.blockmap.bmaporgx; - y1 -= level.blockmap.bmaporgy; + x1 -= Level->blockmap.bmaporgx; + y1 -= Level->blockmap.bmaporgy; xt1 = x1 / FBlockmap::MAPBLOCKUNITS; yt1 = y1 / FBlockmap::MAPBLOCKUNITS; - x2 -= level.blockmap.bmaporgx; - y2 -= level.blockmap.bmaporgy; + x2 -= Level->blockmap.bmaporgx; + y2 -= Level->blockmap.bmaporgy; xt2 = x2 / FBlockmap::MAPBLOCKUNITS; yt2 = y2 / FBlockmap::MAPBLOCKUNITS; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 9a3b747cd..fc2c43f02 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4331,7 +4331,7 @@ bool AActor::UpdateWaterLevel(bool dosplash) else if (oldlevel == 3 && waterlevel < 3) { // Our head just came up. - if (player->air_finished > level.time) + if (player->air_finished > Level->time) { // We hadn't run out of air yet. S_Sound(this, CHAN_VOICE, "*surface", 1, ATTN_NORM); @@ -4356,29 +4356,17 @@ DEFINE_ACTION_FUNCTION(AActor, UpdateWaterLevel) // //========================================================================== -AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing) +void ConstructActor(AActor *actor, const DVector3 &pos, bool SpawningMapThing) { - if (type == NULL) - { - I_Error ("Tried to spawn a class-less actor\n"); - } - - if (allowreplacement) - { - type = type->GetReplacement(); - } - - AActor *actor; - - actor = static_cast(level.CreateThinker(type)); - actor->SpawnTime = level.totaltime; - actor->SpawnOrder = level.spawnindex++; + auto Level = actor->Level; + actor->SpawnTime = Level->totaltime; + actor->SpawnOrder = Level->spawnindex++; // Set default dialogue - actor->ConversationRoot = level.GetConversation(actor->GetClass()->TypeName); + actor->ConversationRoot = Level->GetConversation(actor->GetClass()->TypeName); if (actor->ConversationRoot != -1) { - actor->Conversation = level.StrifeDialogues[actor->ConversationRoot]; + actor->Conversation = Level->StrifeDialogues[actor->ConversationRoot]; } else { @@ -4440,7 +4428,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a actor->SetZ(actor->ceilingz - actor->Height); } - if (SpawningMapThing || !type->IsDescendantOf (NAME_PlayerPawn)) + if (SpawningMapThing || !actor->IsKindOf (NAME_PlayerPawn)) { // Check if there's something solid to stand on between the current position and the // current sector's floor. For map spawns this must be delayed until after setting the @@ -4516,30 +4504,50 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a actor->CallBeginPlay (); if (actor->ObjectFlags & OF_EuthanizeMe) { - return NULL; + return; } } - if (level.flags & LEVEL_NOALLIES && !actor->player) + if (Level->flags & LEVEL_NOALLIES && !actor->player) { actor->flags &= ~MF_FRIENDLY; } // [RH] Count monsters whenever they are spawned. if (actor->CountsAsKill()) { - level.total_monsters++; + Level->total_monsters++; } // [RH] Same, for items if (actor->flags & MF_COUNTITEM) { - level.total_items++; + Level->total_items++; } // And for secrets if (actor->flags5 & MF5_COUNTSECRET) { - level.total_secrets++; + Level->total_secrets++; } // force scroller check in the first tic. actor->flags8 |= MF8_INSCROLLSEC; +} + + +AActor *AActor::StaticSpawn(PClassActor *type, const DVector3 &pos, replace_t allowreplacement, bool SpawningMapThing) +{ + if (type == NULL) + { + I_Error("Tried to spawn a class-less actor\n"); + } + + if (allowreplacement) + { + type = type->GetReplacement(); + } + + AActor *actor; + + actor = static_cast(level.CreateThinker(type)); + + ConstructActor(actor, pos, SpawningMapThing); return actor; } @@ -4604,7 +4612,7 @@ void AActor::HandleSpawnFlags () if (flags & MF_COUNTKILL) { flags &= ~MF_COUNTKILL; - level.total_monsters--; + Level->total_monsters--; } } if (SpawnFlags & MTF_SHADOW) @@ -4623,7 +4631,7 @@ void AActor::HandleSpawnFlags () { //Printf("Secret %s in sector %i!\n", GetTag(), Sector->sectornum); flags5 |= MF5_COUNTSECRET; - level.total_secrets++; + Level->total_secrets++; } } } @@ -7122,7 +7130,7 @@ void AActor::Revive() // [RH] If it's a monster, it gets to count as another kill if (CountsAsKill()) { - level.total_monsters++; + Level->total_monsters++; } // [ZZ] resurrect hook diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 56ac0f6c8..7972d06d3 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -525,13 +525,13 @@ FSerializer &Serialize(FSerializer &arc, const char *key, zone_t &z, zone_t *def // //========================================================================== -void P_SerializeSounds(FSerializer &arc) +void P_SerializeSounds(FLevelLocals *Level, FSerializer &arc) { S_SerializeSounds(arc); DSeqNode::SerializeSequences (arc); const char *name = NULL; uint8_t order; - float musvol = level.MusicVolume; + float musvol = Level->MusicVolume; if (arc.isWriting()) { @@ -544,9 +544,9 @@ void P_SerializeSounds(FSerializer &arc) if (arc.isReading()) { if (!S_ChangeMusic(name, order)) - if (level.cdtrack == 0 || !S_ChangeCDMusic(level.cdtrack, level.cdid)) - S_ChangeMusic(level.Music, level.musicorder); - level.SetMusicVolume(musvol); + if (Level->cdtrack == 0 || !S_ChangeCDMusic(Level->cdtrack, Level->cdid)) + S_ChangeMusic(Level->Music, Level->musicorder); + Level->SetMusicVolume(musvol); } } @@ -977,7 +977,7 @@ void FLevelLocals::Serialize(FSerializer &arc, bool hubload) sky1texture = skytexture1; sky2texture = skytexture2; R_InitSkyMap(); - G_AirControlChanged(); + AirControlChanged(); } Behaviors.SerializeModuleStates(arc); @@ -1004,7 +1004,7 @@ void FLevelLocals::Serialize(FSerializer &arc, bool hubload) FRemapTable::StaticSerializeTranslations(arc); canvasTextureInfo.Serialize(arc); P_SerializePlayers(this, arc, hubload); - P_SerializeSounds(arc); + P_SerializeSounds(this, arc); // Regenerate some data that wasn't saved if (arc.isReading()) diff --git a/src/p_secnodes.cpp b/src/p_secnodes.cpp index 4f7bd0ffe..4400960ad 100644 --- a/src/p_secnodes.cpp +++ b/src/p_secnodes.cpp @@ -386,16 +386,16 @@ void AActor::UpdateRenderSectorList() { // Only check if the map contains line portals ClearRenderLineList(); - if (level.PortalBlockmap.containsLines && Pos().XY() != OldRenderPos.XY()) + if (Level->PortalBlockmap.containsLines && Pos().XY() != OldRenderPos.XY()) { - int bx = level.blockmap.GetBlockX(X()); - int by = level.blockmap.GetBlockY(Y()); + int bx = Level->blockmap.GetBlockX(X()); + int by = Level->blockmap.GetBlockY(Y()); FBoundingBox bb(X(), Y(), MIN(radius*1.5, 128.)); // Don't go further than 128 map units, even for large actors // Are there any portals near the actor's position? - if (level.blockmap.isValidBlock(bx, by) && level.PortalBlockmap(bx, by).neighborContainsLines) + if (Level->blockmap.isValidBlock(bx, by) && Level->PortalBlockmap(bx, by).neighborContainsLines) { // Go through the entire list. In most cases this is faster than setting up a blockmap iterator - for (auto &p : level.linePortals) + for (auto &p : Level->linePortals) { if (p.mType == PORTT_VISUAL) continue; if (bb.inRange(p.mOrigin) && bb.BoxOnLineSide(p.mOrigin)) diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 3a43fbfa1..6001a3fe3 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -623,7 +623,7 @@ double FindHighestFloorPoint (const sector_t *sector, vertex_t **v) { if (v != NULL) { - if (sector->Lines.Size() == 0) *v = &level.vertexes[0]; + if (sector->Lines.Size() == 0) *v = §or->Level->vertexes[0]; else *v = sector->Lines[0]->v1; } return -sector->floorplane.fD(); @@ -663,7 +663,7 @@ double FindLowestCeilingPoint (const sector_t *sector, vertex_t **v) { if (v != nullptr) { - if (sector->Lines.Size() == 0) *v = &level.vertexes[0]; + if (sector->Lines.Size() == 0) *v = §or->Level->vertexes[0]; else *v = sector->Lines[0]->v1; } return sector->ceilingplane.fD(); @@ -1358,9 +1358,9 @@ bool secplane_t::CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) cons // //========================================================================== -bool P_AlignFlat (int linenum, int side, int fc) +bool FLevelLocals::AlignFlat (int linenum, int side, int fc) { - line_t *line = &level.lines[linenum]; + line_t *line = &lines[linenum]; sector_t *sec = side ? line->backsector : line->frontsector; if (!sec) @@ -1388,7 +1388,7 @@ bool P_AlignFlat (int linenum, int side, int fc) // //========================================================================== -void P_ReplaceTextures(const char *fromname, const char *toname, int flags) +void FLevelLocals::ReplaceTextures(const char *fromname, const char *toname, int flags) { FTextureID picnum1, picnum2; @@ -1400,7 +1400,7 @@ void P_ReplaceTextures(const char *fromname, const char *toname, int flags) picnum1 = TexMan.GetTextureID(fromname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable); picnum2 = TexMan.GetTextureID(toname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable); - for (auto &side : level.sides) + for (auto &side : sides) { for (int j = 0; j<3; j++) { @@ -1417,7 +1417,7 @@ void P_ReplaceTextures(const char *fromname, const char *toname, int flags) picnum1 = TexMan.GetTextureID(fromname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable); picnum2 = TexMan.GetTextureID(toname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable); - for (auto &sec : level.sectors) + for (auto &sec : sectors) { if (!(flags & NOT_FLOOR) && sec.GetTexture(sector_t::floor) == picnum1) sec.SetTexture(sector_t::floor, picnum2); @@ -1440,9 +1440,9 @@ void subsector_t::BuildPolyBSP() assert((BSP == NULL || BSP->bDirty) && "BSP computed more than once"); // Set up level information for the node builder. - PolyNodeLevel.Sides = &level.sides[0]; - PolyNodeLevel.NumSides = level.sides.Size(); - PolyNodeLevel.Lines = &level.lines[0]; + PolyNodeLevel.Sides = §or->Level->sides[0]; + PolyNodeLevel.NumSides = sector->Level->sides.Size(); + PolyNodeLevel.Lines = §or->Level->lines[0]; PolyNodeLevel.NumLines = numlines; // is this correct??? // Feed segs to the nodebuilder and build the nodes. @@ -1528,26 +1528,26 @@ int side_t::GetLightLevel (bool foggy, int baselight, bool is3dlight, int *pfake *pfakecontrast = 0; } - if (!foggy || level.flags3 & LEVEL3_FORCEFAKECONTRAST) // Don't do relative lighting in foggy sectors + if (!foggy || sector->Level->flags3 & LEVEL3_FORCEFAKECONTRAST) // Don't do relative lighting in foggy sectors { if (!(Flags & WALLF_NOFAKECONTRAST) && r_fakecontrast != 0) { DVector2 delta = linedef->Delta(); int rel; - if (((level.flags2 & LEVEL2_SMOOTHLIGHTING) || (Flags & WALLF_SMOOTHLIGHTING) || r_fakecontrast == 2) && + if (((sector->Level->flags2 & LEVEL2_SMOOTHLIGHTING) || (Flags & WALLF_SMOOTHLIGHTING) || r_fakecontrast == 2) && delta.X != 0) { rel = xs_RoundToInt // OMG LEE KILLOUGH LIVES! :/ ( - level.WallHorizLight + sector->Level->WallHorizLight + fabs(atan(delta.Y / delta.X) / 1.57079) - * (level.WallVertLight - level.WallHorizLight) + * (sector->Level->WallVertLight - sector->Level->WallHorizLight) ); } else { - rel = delta.X == 0 ? level.WallVertLight : - delta.Y == 0 ? level.WallHorizLight : 0; + rel = delta.X == 0 ? sector->Level->WallVertLight : + delta.Y == 0 ? sector->Level->WallHorizLight : 0; } if (pfakecontrast != NULL) { diff --git a/src/p_spec.h b/src/p_spec.h index 23414c33f..d959bf6ba 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -583,13 +583,7 @@ enum //Spawns teleport fog. Pass the actor to pluck TeleFogFromType and TeleFogToType. 'from' determines if this is the fog to spawn at the old position (true) or new (false). void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele = true, bool setTarget = false); - bool P_Teleport(AActor *thing, DVector3 pos, DAngle angle, int flags); -bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags); -bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse); -bool EV_TeleportOther (int other_tid, int dest_tid, bool fog); -bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog); -bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int group_tid); // @@ -608,7 +602,7 @@ void P_TerminateScript (int script, const char *map); // // [RH] p_quake.c // -bool P_StartQuakeXYZ(AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave); -bool P_StartQuake(AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx); +bool P_StartQuakeXYZ(FLevelLocals *Level, AActor *activator, int tid, int intensityX, int intensityY, int intensityZ, int duration, int damrad, int tremrad, FSoundID quakesfx, int flags, double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave); +bool P_StartQuake(FLevelLocals *Level, AActor *activator, int tid, int intensity, int duration, int damrad, int tremrad, FSoundID quakesfx); #endif diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 117245c67..4c423bdc8 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -186,7 +186,7 @@ bool P_Teleport (AActor *thing, DVector3 pos, DAngle angle, int flags) if (!predicting) { DVector2 vector = angle.ToVector(20); - DVector2 fogpos = level.GetPortalOffsetPosition(pos.X, pos.Y, vector.X, vector.Y); + DVector2 fogpos = thing->Level->GetPortalOffsetPosition(pos.X, pos.Y, vector.X, vector.Y); P_SpawnTeleportFog(thing, DVector3(fogpos, thing->Z()), false, true); } @@ -235,7 +235,7 @@ DEFINE_ACTION_FUNCTION(AActor, Teleport) ACTION_RETURN_BOOL(P_Teleport(self, DVector3(x, y, z), an, flags)); } -static AActor *SelectTeleDest (int tid, int tag, bool norandom) +AActor *FLevelLocals::SelectTeleDest (int tid, int tag, bool norandom) { AActor *searcher; @@ -250,11 +250,11 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) if (tid != 0) { - auto iterator = level.GetActorIterator(NAME_TeleportDest, tid); + auto iterator = GetActorIterator(NAME_TeleportDest, tid); int count = 0; while ( (searcher = iterator.Next ()) ) { - if (tag == 0 || level.SectorHasTag(searcher->Sector, tag)) + if (tag == 0 || SectorHasTag(searcher->Sector, tag)) { count++; } @@ -268,12 +268,12 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) if (tag == 0) { // Try to find a matching map spot (fixes Hexen MAP10) - auto it2 = level.GetActorIterator(NAME_MapSpot, tid); + auto it2 = GetActorIterator(NAME_MapSpot, tid); searcher = it2.Next (); if (searcher == nullptr) { // Try to find a matching non-blocking spot of any type (fixes Caldera MAP13) - auto it3 = level.GetActorIterator(tid); + auto it3 = GetActorIterator(tid); searcher = it3.Next (); while (searcher != NULL && (searcher->flags & MF_SOLID)) { @@ -293,7 +293,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) while (count > 0) { searcher = iterator.Next (); - if (tag == 0 || level.SectorHasTag(searcher->Sector, tag)) + if (tag == 0 || SectorHasTag(searcher->Sector, tag)) { count--; } @@ -306,7 +306,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) { int secnum; - auto itr = level.GetSectorTagIterator(tag); + auto itr = GetSectorTagIterator(tag); while ((secnum = itr.Next()) >= 0) { // Scanning the snext links of things in the sector will not work, because @@ -319,7 +319,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) TThinkerIterator it2(NAME_TeleportDest); while ((searcher = it2.Next()) != NULL) { - if (searcher->Sector == &level.sectors[secnum]) + if (searcher->Sector == §ors[secnum]) { return searcher; } @@ -330,7 +330,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) return NULL; } -bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags) +bool FLevelLocals::EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags) { AActor *searcher; double z; @@ -422,7 +422,7 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f // [RH] Modified to support different source and destination ids. // [RH] Modified some more to be accurate. -bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse) +bool FLevelLocals::EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse) { int i; line_t *l; @@ -430,13 +430,13 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO if (side || thing->flags2 & MF2_NOTELEPORT || !line || line->sidedef[1] == NULL) return false; - auto itr = level.GetLineIdIterator(id); + auto itr = GetLineIdIterator(id); while ((i = itr.Next()) >= 0) { if (line->Index() == i) continue; - if ((l=&level.lines[i]) != line && l->backsector) + if ((l=&lines[i]) != line && l->backsector) { // Get the thing's position along the source linedef double pos; @@ -600,14 +600,14 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO } // [RH] Teleport anything matching other_tid to dest_tid -bool EV_TeleportOther (int other_tid, int dest_tid, bool fog) +bool FLevelLocals::EV_TeleportOther (int other_tid, int dest_tid, bool fog) { bool didSomething = false; if (other_tid != 0 && dest_tid != 0) { AActor *victim; - auto iterator = level.GetActorIterator(other_tid); + auto iterator = GetActorIterator(other_tid); while ( (victim = iterator.Next ()) ) { @@ -619,7 +619,7 @@ bool EV_TeleportOther (int other_tid, int dest_tid, bool fog) return didSomething; } -static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool floorz, bool fog) +bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool floorz, bool fog) { DAngle an = dest->Angles.Yaw - source->Angles.Yaw; DVector2 off = victim->Pos() - source->Pos(); @@ -638,11 +638,11 @@ static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool fl // [RH] Teleport a group of actors centered around source_tid so // that they become centered around dest_tid instead. -bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog) +bool FLevelLocals::EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog) { AActor *sourceOrigin, *destOrigin; { - auto iterator = level.GetActorIterator(source_tid); + auto iterator = GetActorIterator(source_tid); sourceOrigin = iterator.Next (); } if (sourceOrigin == NULL) @@ -651,7 +651,7 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t } { - auto iterator = level.GetActorIterator(NAME_TeleportDest, dest_tid); + auto iterator = GetActorIterator(NAME_TeleportDest, dest_tid); destOrigin = iterator.Next (); } if (destOrigin == NULL) @@ -669,7 +669,7 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t } else { - auto iterator = level.GetActorIterator(group_tid); + auto iterator = GetActorIterator(group_tid); // For each actor with tid matching arg0, move it to the same // position relative to destOrigin as it is relative to sourceOrigin @@ -693,11 +693,11 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t // [RH] Teleport a group of actors in a sector. Source_tid is used as a // reference point so that they end up in the same position relative to // dest_tid. Group_tid can be used to not teleport all actors in the sector. -bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int group_tid) +bool FLevelLocals::EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int group_tid) { AActor *sourceOrigin, *destOrigin; { - auto iterator = level.GetActorIterator(source_tid); + auto iterator = GetActorIterator(source_tid); sourceOrigin = iterator.Next (); } if (sourceOrigin == NULL) @@ -705,7 +705,7 @@ bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int gro return false; } { - auto iterator = level.GetActorIterator(NAME_TeleportDest, dest_tid); + auto iterator = GetActorIterator(NAME_TeleportDest, dest_tid); destOrigin = iterator.Next (); } if (destOrigin == NULL) @@ -718,11 +718,11 @@ bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int gro int secnum; secnum = -1; - auto itr = level.GetSectorTagIterator(tag); + auto itr = GetSectorTagIterator(tag); while ((secnum = itr.Next()) >= 0) { msecnode_t *node; - const sector_t * const sec = &level.sectors[secnum]; + const sector_t * const sec = §ors[secnum]; for (node = sec->touching_thinglist; node; ) { diff --git a/src/p_things.cpp b/src/p_things.cpp index 1f9d6ed26..a65ff70b8 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -52,12 +52,12 @@ FClassMap SpawnableThings; static FRandom pr_leadtarget ("LeadTarget"); -bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid) +bool FLevelLocals::EV_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid) { int rtn = 0; PClassActor *kind; AActor *spot, *mobj; - auto iterator = level.GetActorIterator(tid); + auto iterator = GetActorIterator(tid); kind = P_GetSpawnableType(type); @@ -68,7 +68,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, i kind = kind->GetReplacement(); if ((GetDefaultByType(kind)->flags3 & MF3_ISMONSTER) && - ((dmflags & DF_NO_MONSTERS) || (level.flags2 & LEVEL2_NOMONSTERS))) + ((dmflags & DF_NO_MONSTERS) || (flags2 & LEVEL2_NOMONSTERS))) return false; if (tid == 0) @@ -144,16 +144,16 @@ bool P_MoveThing(AActor *source, const DVector3 &pos, bool fog) } } -bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog) +bool FLevelLocals::EV_Thing_Move (int tid, AActor *source, int mapspot, bool fog) { AActor *target; if (tid != 0) { - auto iterator1 = level.GetActorIterator(tid); + auto iterator1 = GetActorIterator(tid); source = iterator1.Next(); } - auto iterator2 = level.GetActorIterator(mapspot); + auto iterator2 = GetActorIterator(mapspot); target = iterator2.Next (); if (source != NULL && target != NULL) @@ -256,14 +256,14 @@ DEFINE_ACTION_FUNCTION(AActor, VelIntercept) return 0; } -bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_name, DAngle angle, +bool FLevelLocals::EV_Thing_Projectile (int tid, AActor *source, int type, const char *type_name, DAngle angle, double speed, double vspeed, int dest, AActor *forcedest, int gravity, int newtid, bool leadTarget) { int rtn = 0; PClassActor *kind; AActor *spot, *mobj, *targ = forcedest; - auto iterator = level.GetActorIterator(tid); + auto iterator = GetActorIterator(tid); int defflags3; if (type_name == NULL) @@ -284,7 +284,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam defflags3 = GetDefaultByType(kind)->flags3; if ((defflags3 & MF3_ISMONSTER) && - ((dmflags & DF_NO_MONSTERS) || (level.flags2 & LEVEL2_NOMONSTERS))) + ((dmflags & DF_NO_MONSTERS) || (flags2 & LEVEL2_NOMONSTERS))) return false; if (tid == 0) @@ -297,7 +297,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam } while (spot != NULL) { - auto tit = level.GetActorIterator(dest); + auto tit = GetActorIterator(dest); if (dest == 0 || (targ = tit.Next())) { @@ -394,9 +394,9 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam return rtn != 0; } -int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type) +int FLevelLocals::EV_Thing_Damage (int tid, AActor *whofor0, int amount, FName type) { - auto iterator = level.GetActorIterator(tid); + auto iterator = GetActorIterator(tid); int count = 0; AActor *actor; @@ -876,6 +876,7 @@ int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, do } DVector3 old = caller->Pos(); + auto Level = caller->Level; int oldpgroup = caller->Sector->PortalGroup; zofs += reference->Height * heightoffset; @@ -957,15 +958,15 @@ int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, do if (flags & WARPF_WARPINTERPOLATION) { // This just translates the movement but doesn't change the vector - DVector3 displacedold = old + level.Displacements.getOffset(oldpgroup, caller->Sector->PortalGroup); + DVector3 displacedold = old + Level->Displacements.getOffset(oldpgroup, caller->Sector->PortalGroup); caller->Prev += caller->Pos() - displacedold; caller->PrevPortalGroup = caller->Sector->PortalGroup; } else if (flags & WARPF_COPYINTERPOLATION) { // Map both positions of the reference actor to the current portal group - DVector3 displacedold = old + level.Displacements.getOffset(reference->PrevPortalGroup, caller->Sector->PortalGroup); - DVector3 displacedref = old + level.Displacements.getOffset(reference->Sector->PortalGroup, caller->Sector->PortalGroup); + DVector3 displacedold = old + Level->Displacements.getOffset(reference->PrevPortalGroup, caller->Sector->PortalGroup); + DVector3 displacedref = old + Level->Displacements.getOffset(reference->Sector->PortalGroup, caller->Sector->PortalGroup); caller->Prev = caller->Pos() + displacedold - displacedref; caller->PrevPortalGroup = caller->Sector->PortalGroup; } diff --git a/src/p_user.cpp b/src/p_user.cpp index 88f47db38..7e6ec3c0d 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -993,8 +993,8 @@ void P_CheckPlayerSprite(AActor *actor, int &spritenum, DVector2 &scale) CUSTOM_CVAR (Float, sv_aircontrol, 0.00390625f, CVAR_SERVERINFO|CVAR_NOSAVE) { - level.aircontrol = self; - G_AirControlChanged (); + currentUILevel->aircontrol = self; + currentUILevel->AirControlChanged (); } //========================================================================== diff --git a/src/r_data/a_dynlightdata.cpp b/src/r_data/a_dynlightdata.cpp index acddbe906..f0b66f972 100644 --- a/src/r_data/a_dynlightdata.cpp +++ b/src/r_data/a_dynlightdata.cpp @@ -89,7 +89,7 @@ void FLightDefaults::ApplyProperties(FDynamicLight * light) const { float pulseTime = float(m_Param / TICRATE); - light->m_lastUpdate = level.maptime; + light->m_lastUpdate = light->Level->maptime; if (m_swapped) light->m_cycler.SetParams(float(m_Args[LIGHT_SECONDARY_INTENSITY]), float(m_Args[LIGHT_INTENSITY]), pulseTime, oldtype == PulseLight); else light->m_cycler.SetParams(float(m_Args[LIGHT_INTENSITY]), float(m_Args[LIGHT_SECONDARY_INTENSITY]), pulseTime, oldtype == PulseLight); light->m_cycler.ShouldCycle(true); diff --git a/src/r_data/r_canvastexture.cpp b/src/r_data/r_canvastexture.cpp index a64f50b87..4a159170f 100644 --- a/src/r_data/r_canvastexture.cpp +++ b/src/r_data/r_canvastexture.cpp @@ -102,7 +102,7 @@ void SetCameraToTexture(AActor *viewpoint, const FString &texturename, double fo FTexture *tex = TexMan.GetTexture(textureid); if (tex && tex->isCanvas()) { - level.canvasTextureInfo.Add(viewpoint, textureid, fov); + viewpoint->Level->canvasTextureInfo.Add(viewpoint, textureid, fov); } } } diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index cb3cd28fd..e6a85c929 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -919,7 +919,7 @@ void R_InitTranslationTables () // Each player corpse has its own translation so they won't change // color if the player who created them changes theirs. - for (i = 0; i < level.BODYQUESIZE; ++i) + for (i = 0; i < FLevelLocals::BODYQUESIZE; ++i) { PushIdentityTable(TRANSLATION_PlayerCorpses); } diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index bcd250c83..ee7f3a89d 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -1621,18 +1621,18 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField) //===================================================================================== // This is needed to convert the strings to char pointers. - static void ReplaceTextures(const FString &from, const FString &to, int flags) + static void ReplaceTextures(FLevelLocals *self, const FString &from, const FString &to, int flags) { - P_ReplaceTextures(from, to, flags); + self->ReplaceTextures(from, to, flags); } -DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, ReplaceTextures, ReplaceTextures) +DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, ReplaceTextures, ReplaceTextures) { - PARAM_PROLOGUE; + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); PARAM_STRING(from); PARAM_STRING(to); PARAM_INT(flags); - P_ReplaceTextures(from, to, flags); + self->ReplaceTextures(from, to, flags); return 0; } diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index d449bfd34..5e52f3e5a 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -92,7 +92,10 @@ struct TexMan }; native static TextureID CheckForTexture(String name, int usetype, int flags = TryAny); - native static void ReplaceTextures(String from, String to, int flags); + deprecated("3.8") static void ReplaceTextures(String from, String to, int flags) + { + level.ReplaceTextures(from, to, flags); + } native static String GetName(TextureID tex); native static int, int GetSize(TextureID tex); native static Vector2 GetScaledSize(TextureID tex); @@ -699,6 +702,7 @@ struct LevelLocals native native SpotState GetSpotState(bool create = true); native int FindUniqueTid(int start = 0, int limit = 0); native uint GetSkyboxPortal(Actor actor); + native void ReplaceTextures(String from, String to, int flags); native static clearscope bool IsPointInMap(vector3 p);