From cd7986b1b122aa39e561c0ab170b018552c24a93 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 8 Jan 2017 18:45:30 +0100 Subject: [PATCH] - refactored global sides array to be more VM friendly. - moved FLevelLocals to its own header to resolve some circular include conflicts. --- src/actor.h | 9 +-- src/am_map.cpp | 1 + src/bbannouncer.cpp | 1 + src/c_cmds.cpp | 1 + src/c_console.cpp | 1 + src/compatibility.cpp | 1 + src/d_main.cpp | 1 + src/d_net.cpp | 1 + src/decallib.cpp | 1 + src/dobject.cpp | 1 + src/dobjgc.cpp | 9 +-- src/doomstat.cpp | 1 + src/edata.cpp | 1 + src/fragglescript/t_cmd.cpp | 1 + src/fragglescript/t_func.cpp | 1 + src/fragglescript/t_load.cpp | 1 + src/fragglescript/t_script.cpp | 1 + src/g_game.cpp | 1 + src/g_hub.cpp | 1 + src/g_inventory/a_artifacts.cpp | 1 + src/g_inventory/a_pickups.cpp | 1 + src/g_level.cpp | 1 + src/g_level.h | 74 --------------------- src/g_levellocals.h | 95 +++++++++++++++++++++++++++ src/g_mapinfo.cpp | 1 + src/g_shared/a_decals.cpp | 5 +- src/g_shared/a_fastprojectile.cpp | 1 + src/g_shared/a_flashfader.cpp | 1 + src/g_shared/a_lightning.cpp | 1 + src/g_shared/a_morph.cpp | 1 + src/g_shared/a_movingcamera.cpp | 1 + src/g_shared/a_randomspawner.cpp | 1 + src/g_shared/sbarinfo.cpp | 1 + src/g_shared/shared_hud.cpp | 1 + src/g_shared/shared_sbar.cpp | 1 + src/g_skill.cpp | 1 + src/g_strife/strife_sbar.cpp | 1 + src/gl/compatibility/gl_20.cpp | 1 + src/gl/data/gl_data.cpp | 1 + src/gl/data/gl_portaldata.cpp | 1 + src/gl/data/gl_setup.cpp | 24 +++---- src/gl/data/gl_vertexbuffer.cpp | 1 + src/gl/dynlights/a_dynlight.cpp | 1 + src/gl/dynlights/gl_dynlight.cpp | 1 + src/gl/models/gl_models.cpp | 1 + src/gl/renderer/gl_lightdata.cpp | 1 + src/gl/scene/gl_drawinfo.cpp | 1 + src/gl/scene/gl_flats.cpp | 1 + src/gl/scene/gl_renderhacks.cpp | 2 +- src/gl/scene/gl_scene.cpp | 1 + src/gl/scene/gl_sky.cpp | 1 + src/gl/scene/gl_sprite.cpp | 1 + src/gl/scene/gl_walls.cpp | 1 + src/gl/scene/gl_weapon.cpp | 1 + src/gl/utility/gl_clock.cpp | 1 + src/hu_scores.cpp | 1 + src/intermission/intermission.cpp | 1 + src/m_cheat.cpp | 1 + src/menu/readthis.cpp | 1 + src/nodebuild_utility.cpp | 2 +- src/p_3dfloors.cpp | 1 + src/p_3dmidtex.cpp | 1 + src/p_acs.cpp | 13 ++-- src/p_actionfunctions.cpp | 1 + src/p_ceiling.cpp | 1 + src/p_conversation.cpp | 1 + src/p_doors.cpp | 1 + src/p_effect.cpp | 1 + src/p_enemy.cpp | 1 + src/p_floor.cpp | 1 + src/p_glnodes.cpp | 10 +-- src/p_interaction.cpp | 1 + src/p_lights.cpp | 1 + src/p_linkedsectors.cpp | 1 + src/p_lnspec.cpp | 1 + src/p_map.cpp | 1 + src/p_maputl.cpp | 1 + src/p_mobj.cpp | 24 +++++-- src/p_pillar.cpp | 1 + src/p_plats.cpp | 1 + src/p_pspr.cpp | 1 + src/p_pusher.cpp | 1 + src/p_saveg.cpp | 10 +-- src/p_scroll.cpp | 69 +++++++++---------- src/p_sectors.cpp | 7 +- src/p_setup.cpp | 84 ++++++++++------------- src/p_sight.cpp | 1 + src/p_slopes.cpp | 1 + src/p_spec.cpp | 1 + src/p_tags.cpp | 16 +---- src/p_teleport.cpp | 1 + src/p_things.cpp | 1 + src/p_tick.cpp | 1 + src/p_trace.cpp | 1 + src/p_udmf.cpp | 14 ++-- src/p_user.cpp | 1 + src/p_xlat.cpp | 1 + src/po_man.cpp | 25 +++---- src/portal.cpp | 1 + src/r_bsp.cpp | 1 + src/r_defs.h | 11 ++-- src/r_plane.cpp | 1 + src/r_sky.cpp | 1 + src/r_state.h | 3 - src/r_things.cpp | 1 + src/s_advsound.cpp | 1 + src/s_sndseq.cpp | 1 + src/s_sound.cpp | 1 + src/scripting/thingdef_data.cpp | 1 + src/scripting/thingdef_properties.cpp | 1 + src/serializer.cpp | 3 +- src/st_stuff.cpp | 1 + src/statistics.cpp | 1 + src/v_draw.cpp | 1 + src/v_palette.cpp | 1 + src/wi_stuff.cpp | 1 + src/win32/i_main.cpp | 1 + 117 files changed, 354 insertions(+), 251 deletions(-) create mode 100644 src/g_levellocals.h diff --git a/src/actor.h b/src/actor.h index 439ae2644..d4f5f27c5 100644 --- a/src/actor.h +++ b/src/actor.h @@ -779,14 +779,7 @@ public: // set translation void SetTranslation(FName trname); - double GetBobOffset(double ticfrac = 0) const - { - if (!(flags2 & MF2_FLOATBOB)) - { - return 0; - } - return BobSin(FloatBobPhase + level.maptime + ticfrac); - } + double GetBobOffset(double ticfrac = 0) const; // Enter the crash state void Crash(); diff --git a/src/am_map.cpp b/src/am_map.cpp index 505d5f303..90d84360b 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -70,6 +70,7 @@ #include "po_man.h" #include "a_keys.h" #include "r_data/colormaps.h" +#include "g_levellocals.h" //============================================================================= diff --git a/src/bbannouncer.cpp b/src/bbannouncer.cpp index a19ba72f4..6fbf31479 100644 --- a/src/bbannouncer.cpp +++ b/src/bbannouncer.cpp @@ -49,6 +49,7 @@ #include "d_player.h" #include "g_level.h" #include "doomstat.h" +#include "g_levellocals.h" // MACROS ------------------------------------------------------------------ diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 2923a8ae8..be4944b8c 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -72,6 +72,7 @@ #include "r_utility.h" #include "r_data/r_interpolate.h" #include "c_functions.h" +#include "g_levellocals.h" extern FILE *Logfile; extern bool insave; diff --git a/src/c_console.cpp b/src/c_console.cpp index faeec0a68..a3f84723b 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -67,6 +67,7 @@ #include "d_player.h" #include "gstrings.h" #include "c_consolebuffer.h" +#include "g_levellocals.h" #include "gi.h" diff --git a/src/compatibility.cpp b/src/compatibility.cpp index 9a29457eb..0b27a1efa 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -52,6 +52,7 @@ #include "p_tags.h" #include "r_state.h" #include "w_wad.h" +#include "g_levellocals.h" // MACROS ------------------------------------------------------------------ diff --git a/src/d_main.cpp b/src/d_main.cpp index 1ea2d2707..2c6b1c9e9 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -109,6 +109,7 @@ #include "p_local.h" #include "autosegs.h" #include "fragglescript/t_fs.h" +#include "g_levellocals.h" EXTERN_CVAR(Bool, hud_althud) void DrawHUD(); diff --git a/src/d_net.cpp b/src/d_net.cpp index 4bda25510..0ebb7de38 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -63,6 +63,7 @@ #include "r_utility.h" #include "a_keys.h" #include "intermission/intermission.h" +#include "g_levellocals.h" EXTERN_CVAR (Int, disableautosave) EXTERN_CVAR (Int, autosavecount) diff --git a/src/decallib.cpp b/src/decallib.cpp index 7bfdfc3e7..52a4eadf5 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -49,6 +49,7 @@ #include "colormatcher.h" #include "b_bot.h" #include "serializer.h" +#include "g_levellocals.h" FDecalLib DecalLibrary; diff --git a/src/dobject.cpp b/src/dobject.cpp index c6e20be5e..b96cc5ff9 100644 --- a/src/dobject.cpp +++ b/src/dobject.cpp @@ -49,6 +49,7 @@ #include "dsectoreffect.h" #include "serializer.h" #include "virtual.h" +#include "g_levellocals.h" //========================================================================== // diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp index 11cfdc8c2..625f80678 100644 --- a/src/dobjgc.cpp +++ b/src/dobjgc.cpp @@ -77,6 +77,7 @@ #include "r_utility.h" #include "menu/menu.h" #include "intermission/intermission.h" +#include "g_levellocals.h" // MACROS ------------------------------------------------------------------ @@ -709,15 +710,15 @@ size_t DSectorMarker::PropagateMark() moretodo = true; } } - if (!moretodo && sides != NULL) + if (!moretodo && level.sides.Size() > 0) { - for (i = 0; i < SIDEDEFSTEPSIZE && SideNum + i < numsides; ++i) + for (i = 0; i < SIDEDEFSTEPSIZE && SideNum + i < (int)level.sides.Size(); ++i) { - side_t *side = &sides[SideNum + i]; + side_t *side = &level.sides[SideNum + i]; for(int j=0;j<3;j++) GC::Mark(side->textures[j].interpolation); } marked += i * sizeof(side_t); - if (SideNum + i < numsides) + if (SideNum + i < (int)level.sides.Size()) { SideNum += i; moretodo = true; diff --git a/src/doomstat.cpp b/src/doomstat.cpp index 87ca50a16..309398331 100644 --- a/src/doomstat.cpp +++ b/src/doomstat.cpp @@ -29,6 +29,7 @@ #include "i_system.h" #include "g_level.h" #include "p_local.h" +#include "g_levellocals.h" int SaveVersion; diff --git a/src/edata.cpp b/src/edata.cpp index 4940bb8f2..015be0bb1 100644 --- a/src/edata.cpp +++ b/src/edata.cpp @@ -49,6 +49,7 @@ #include "v_palette.h" #include "p_acs.h" #include "r_data/colormaps.h" +#include "g_levellocals.h" struct FEDOptions : public FOptionalMapinfoData diff --git a/src/fragglescript/t_cmd.cpp b/src/fragglescript/t_cmd.cpp index 1434870d1..691740024 100644 --- a/src/fragglescript/t_cmd.cpp +++ b/src/fragglescript/t_cmd.cpp @@ -48,6 +48,7 @@ #include "g_level.h" #include "r_renderer.h" #include "d_player.h" +#include "g_levellocals.h" //========================================================================== // diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 816af43d0..514d9aaea 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -71,6 +71,7 @@ #include "r_utility.h" #include "a_ammo.h" #include "math/cmath.h" +#include "g_levellocals.h" static FRandom pr_script("FScript"); diff --git a/src/fragglescript/t_load.cpp b/src/fragglescript/t_load.cpp index 0f3d8417b..b3b38543d 100644 --- a/src/fragglescript/t_load.cpp +++ b/src/fragglescript/t_load.cpp @@ -43,6 +43,7 @@ #include "cmdlib.h" #include "p_lnspec.h" #include "gi.h" +#include "g_levellocals.h" #include "xlat/xlat.h" void T_Init(); diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp index 0469e5063..b5c21632b 100644 --- a/src/fragglescript/t_script.cpp +++ b/src/fragglescript/t_script.cpp @@ -55,6 +55,7 @@ #include "doomerrors.h" #include "doomstat.h" #include "serializer.h" +#include "g_levellocals.h" //========================================================================== // diff --git a/src/g_game.cpp b/src/g_game.cpp index dbf2f2636..6565d5324 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -91,6 +91,7 @@ #include #include "g_hub.h" +#include "g_levellocals.h" static FRandom pr_dmspawn ("DMSpawn"); diff --git a/src/g_hub.cpp b/src/g_hub.cpp index cabcef2d3..e87dcff7d 100644 --- a/src/g_hub.cpp +++ b/src/g_hub.cpp @@ -44,6 +44,7 @@ #include "gstrings.h" #include "wi_stuff.h" #include "serializer.h" +#include "g_levellocals.h" //========================================================================== diff --git a/src/g_inventory/a_artifacts.cpp b/src/g_inventory/a_artifacts.cpp index 9b67e2dc9..6ece99b38 100644 --- a/src/g_inventory/a_artifacts.cpp +++ b/src/g_inventory/a_artifacts.cpp @@ -22,6 +22,7 @@ #include "serializer.h" #include "r_utility.h" #include "virtual.h" +#include "g_levellocals.h" #include "r_data/colormaps.h" diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index c963fd918..e7a21fee6 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -22,6 +22,7 @@ #include "virtual.h" #include "a_ammo.h" #include "c_functions.h" +#include "g_levellocals.h" EXTERN_CVAR(Bool, sv_unlimited_pickup) diff --git a/src/g_level.cpp b/src/g_level.cpp index a664e02b9..b8d73727c 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -88,6 +88,7 @@ #include "gi.h" #include "g_hub.h" +#include "g_levellocals.h" #include diff --git a/src/g_level.h b/src/g_level.h index d949b1604..6274c22b0 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -376,78 +376,6 @@ struct level_info_t } }; -struct FLevelLocals -{ - void Tick (); - void AddScroller (int secnum); - - BYTE md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded. - int time; // time in the hub - int maptime; // time in the map - int totaltime; // time in the game - int starttime; - int partime; - int sucktime; - - level_info_t *info; - int cluster; - int clusterflags; - int levelnum; - int lumpnum; - FString LevelName; - FString MapName; // the lump name (E1M1, MAP01, etc) - FString NextMap; // go here when using the regular exit - FString NextSecretMap; // map to go to when used secret exit - EMapType maptype; - - TStaticArray sectors; - TStaticArray lines; - - DWORD flags; - DWORD flags2; - DWORD flags3; - - DWORD fadeto; // The color the palette fades to (usually black) - DWORD outsidefog; // The fog for sectors with sky ceilings - - FString Music; - int musicorder; - int cdtrack; - unsigned int cdid; - FTextureID skytexture1; - FTextureID skytexture2; - - float skyspeed1; // Scrolling speed of sky textures, in pixels per ms - float skyspeed2; - - int total_secrets; - int found_secrets; - - int total_items; - int found_items; - - int total_monsters; - int killed_monsters; - - double gravity; - double aircontrol; - double airfriction; - int airsupply; - int DefaultEnvironment; // Default sound environment. - - TArray Scrolls; // NULL if no DScrollers in this level - - SBYTE WallVertLight; // Light diffs for vert/horiz walls - SBYTE WallHorizLight; - - bool FromSnapshot; // The current map was restored from a snapshot - - double teamdamage; - - bool IsJumpingAllowed() const; - bool IsCrouchingAllowed() const; - bool IsFreelookAllowed() const; -}; struct cluster_info_t { @@ -477,8 +405,6 @@ struct cluster_info_t #define CLUSTER_LOOKUPCLUSTERNAME 0x00000080 // Cluster name is the name of a language string #define CLUSTER_ALLOWINTERMISSION 0x00000100 // Allow intermissions between levels in a hub. -extern FLevelLocals level; - extern TArray wadlevelinfos; extern TArray wadclusterinfos; diff --git a/src/g_levellocals.h b/src/g_levellocals.h new file mode 100644 index 000000000..c49be313b --- /dev/null +++ b/src/g_levellocals.h @@ -0,0 +1,95 @@ +#pragma once + +#include "g_level.h" +#include "r_defs.h" + +struct FLevelLocals +{ + void Tick (); + void AddScroller (int secnum); + + BYTE md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded. + int time; // time in the hub + int maptime; // time in the map + int totaltime; // time in the game + int starttime; + int partime; + int sucktime; + + level_info_t *info; + int cluster; + int clusterflags; + int levelnum; + int lumpnum; + FString LevelName; + FString MapName; // the lump name (E1M1, MAP01, etc) + FString NextMap; // go here when using the regular exit + FString NextSecretMap; // map to go to when used secret exit + EMapType maptype; + + TStaticArray sectors; + TStaticArray lines; + TStaticArray sides; + + DWORD flags; + DWORD flags2; + DWORD flags3; + + DWORD fadeto; // The color the palette fades to (usually black) + DWORD outsidefog; // The fog for sectors with sky ceilings + + FString Music; + int musicorder; + int cdtrack; + unsigned int cdid; + FTextureID skytexture1; + FTextureID skytexture2; + + float skyspeed1; // Scrolling speed of sky textures, in pixels per ms + float skyspeed2; + + int total_secrets; + int found_secrets; + + int total_items; + int found_items; + + int total_monsters; + int killed_monsters; + + double gravity; + double aircontrol; + double airfriction; + int airsupply; + int DefaultEnvironment; // Default sound environment. + + TArray Scrolls; // NULL if no DScrollers in this level + + SBYTE WallVertLight; // Light diffs for vert/horiz walls + SBYTE WallHorizLight; + + bool FromSnapshot; // The current map was restored from a snapshot + + double teamdamage; + + bool IsJumpingAllowed() const; + bool IsCrouchingAllowed() const; + bool IsFreelookAllowed() const; +}; + +extern FLevelLocals level; + +inline int side_t::Index() const +{ + return int(this - &level.sides[0]); +} + +inline int line_t::Index() const +{ + return int(this - &level.lines[0]); +} + +inline int sector_t::Index() const +{ + return int(this - &level.sectors[0]); +} diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 6a6076565..3fab0bd0d 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -51,6 +51,7 @@ #include "autosegs.h" #include "version.h" #include "v_text.h" +#include "g_levellocals.h" TArray wadclusterinfos; TArray wadlevelinfos; diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index bfbe6d13d..5ac3cb452 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -47,6 +47,7 @@ #include "serializer.h" #include "doomdata.h" #include "r_state.h" +#include "g_levellocals.h" static double DecalWidth, DecalLeft, DecalRight; static double SpreadZ; @@ -415,7 +416,7 @@ void DBaseDecal::SpreadLeft (double r, vertex_t *v1, side_t *feelwall, F3DFloor double x = v1->fX(); double y = v1->fY(); - feelwall = &sides[feelwall->LeftSide]; + feelwall = &level.sides[feelwall->LeftSide]; GetWallStuff (feelwall, v1, ldx, ldy); double wallsize = Length (ldx, ldy); r += DecalLeft; @@ -455,7 +456,7 @@ void DBaseDecal::SpreadRight (double r, side_t *feelwall, double wallsize, F3DFl while (r > wallsize && feelwall->RightSide != NO_SIDE) { - feelwall = &sides[feelwall->RightSide]; + feelwall = &level.sides[feelwall->RightSide]; side_t *nextwall = NextWall (feelwall); if (nextwall != NULL && nextwall->LeftSide != NO_SIDE) diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index fb0faef0f..3bfaf8d94 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -7,6 +7,7 @@ #include "b_bot.h" #include "p_checkposition.h" #include "virtual.h" +#include "g_levellocals.h" IMPLEMENT_CLASS(AFastProjectile, false, false) diff --git a/src/g_shared/a_flashfader.cpp b/src/g_shared/a_flashfader.cpp index 3e0b939e0..006b7ef84 100644 --- a/src/g_shared/a_flashfader.cpp +++ b/src/g_shared/a_flashfader.cpp @@ -2,6 +2,7 @@ #include "g_level.h" #include "d_player.h" #include "serializer.h" +#include "g_levellocals.h" IMPLEMENT_CLASS(DFlashFader, false, true) diff --git a/src/g_shared/a_lightning.cpp b/src/g_shared/a_lightning.cpp index 1598b87f0..deeb8405b 100644 --- a/src/g_shared/a_lightning.cpp +++ b/src/g_shared/a_lightning.cpp @@ -10,6 +10,7 @@ #include "g_level.h" #include "r_state.h" #include "serializer.h" +#include "g_levellocals.h" static FRandom pr_lightning ("Lightning"); diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index 935efa2db..b48a126cd 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -16,6 +16,7 @@ #include "d_player.h" #include "a_armor.h" #include "r_data/sprites.h" +#include "g_levellocals.h" static FRandom pr_morphmonst ("MorphMonster"); diff --git a/src/g_shared/a_movingcamera.cpp b/src/g_shared/a_movingcamera.cpp index c09d93fd5..f32550f2d 100644 --- a/src/g_shared/a_movingcamera.cpp +++ b/src/g_shared/a_movingcamera.cpp @@ -38,6 +38,7 @@ #include "p_lnspec.h" #include "doomstat.h" #include "serializer.h" +#include "g_levellocals.h" /* == InterpolationPoint: node along a camera's path diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index d5a396d0d..9be5cac7b 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -16,6 +16,7 @@ #include "v_text.h" #include "doomstat.h" #include "doomdata.h" +#include "g_levellocals.h" #define MAX_RANDOMSPAWNERS_RECURSION 32 // Should be largely more than enough, honestly. static FRandom pr_randomspawn("RandomSpawn"); diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index c06abf90d..fb7d42a46 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -60,6 +60,7 @@ #include "version.h" #include "cmdlib.h" #include "a_ammo.h" +#include "g_levellocals.h" #define ARTIFLASH_OFFSET (statusBar->invBarOffset+6) enum diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index a061dbf59..0c9b74255 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -55,6 +55,7 @@ #include "d_player.h" #include "r_utility.h" #include "cmdlib.h" +#include "g_levellocals.h" #include diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index c288a05c8..cb3ada8e9 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -55,6 +55,7 @@ #include "gstrings.h" #include "r_utility.h" #include "cmdlib.h" +#include "g_levellocals.h" #include "../version.h" diff --git a/src/g_skill.cpp b/src/g_skill.cpp index 70daadc23..d158fa4cd 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -43,6 +43,7 @@ #include "v_font.h" #include "m_fixed.h" #include "gstrings.h" +#include "g_levellocals.h" TArray AllSkills; int DefaultSkill = -1; diff --git a/src/g_strife/strife_sbar.cpp b/src/g_strife/strife_sbar.cpp index 46dd63ff7..1a8e216fd 100644 --- a/src/g_strife/strife_sbar.cpp +++ b/src/g_strife/strife_sbar.cpp @@ -19,6 +19,7 @@ #include "colormatcher.h" #include "v_palette.h" #include "cmdlib.h" +#include "g_levellocals.h" // Number of tics to move the popscreen up and down. #define POP_TIME (TICRATE/8) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 0f9ee5f43..eeb5572c1 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -38,6 +38,7 @@ #include "i_system.h" #include "v_text.h" #include "r_utility.h" +#include "g_levellocals.h" #include "gl/dynlights/gl_dynlight.h" #include "gl/utility/gl_geometric.h" #include "gl/renderer/gl_renderer.h" diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index b1696f8ff..07fac1b2e 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -41,6 +41,7 @@ #include "g_level.h" #include "doomstat.h" #include "d_player.h" +#include "g_levellocals.h" #include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp index 71b10b4bb..c705da589 100644 --- a/src/gl/data/gl_portaldata.cpp +++ b/src/gl/data/gl_portaldata.cpp @@ -38,6 +38,7 @@ #include "gi.h" #include "g_level.h" #include "a_sharedglobal.h" +#include "g_levellocals.h" #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp index 6207f53a4..e41181228 100644 --- a/src/gl/data/gl_setup.cpp +++ b/src/gl/data/gl_setup.cpp @@ -40,6 +40,7 @@ #include "gi.h" #include "p_setup.h" #include "g_level.h" +#include "g_levellocals.h" #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" @@ -459,8 +460,8 @@ static void InitVertexData() static void GetSideVertices(int sdnum, DVector2 *v1, DVector2 *v2) { - line_t *ln = sides[sdnum].linedef; - if (ln->sidedef[0] == &sides[sdnum]) + line_t *ln = level.sides[sdnum].linedef; + if (ln->sidedef[0] == &level.sides[sdnum]) { *v1 = ln->v1->fPos(); *v2 = ln->v2->fPos(); @@ -487,6 +488,7 @@ static int segcmp(const void *a, const void *b) static void PrepareSegs() { + auto numsides = level.sides.Size(); int *segcount = new int[numsides]; int realsegs = 0; @@ -534,7 +536,7 @@ static void PrepareSegs() seg_t *seg = &segs[i]; if (seg->sidedef == NULL) continue; // miniseg - int sidenum = int(seg->sidedef - sides); + int sidenum = seg->sidedef->Index(); realsegs++; segcount[sidenum]++; @@ -548,13 +550,13 @@ static void PrepareSegs() } // allocate memory - sides[0].segs = new seg_t*[realsegs]; - sides[0].numsegs = 0; + level.sides[0].segs = new seg_t*[realsegs]; + level.sides[0].numsegs = 0; for(int i = 1; i < numsides; i++) { - sides[i].segs = sides[i-1].segs + segcount[i-1]; - sides[i].numsegs = 0; + level.sides[i].segs = level.sides[i-1].segs + segcount[i-1]; + level.sides[i].numsegs = 0; } delete [] segcount; @@ -568,7 +570,7 @@ static void PrepareSegs() // sort the segs for(int i = 0; i < numsides; i++) { - if (sides[i].numsegs > 1) qsort(sides[i].segs, sides[i].numsegs, sizeof(seg_t*), segcmp); + if (level.sides[i].numsegs > 1) qsort(level.sides[i].segs, level.sides[i].numsegs, sizeof(seg_t*), segcmp); } } @@ -667,10 +669,10 @@ void gl_CleanLevelData() } } - if (sides && sides[0].segs) + if (level.sides.Size() > 0 && level.sides[0].segs) { - delete [] sides[0].segs; - sides[0].segs = NULL; + delete [] level.sides[0].segs; + level.sides[0].segs = NULL; } if (level.sectors.Size() > 0 && level.sectors[0].subsectors) { diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index a645fbff4..4973ad39d 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -31,6 +31,7 @@ #include "r_state.h" #include "m_argv.h" #include "c_cvars.h" +#include "g_levellocals.h" #include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/shaders/gl_shader.h" diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 15d9291bd..5f0d31552 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -71,6 +71,7 @@ #include "portal.h" #include "doomstat.h" #include "serializer.h" +#include "g_levellocals.h" #include "gl/renderer/gl_renderer.h" diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp index bc107c60e..a0d9292a9 100644 --- a/src/gl/dynlights/gl_dynlight.cpp +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -49,6 +49,7 @@ #include "zstring.h" #include "d_dehacked.h" #include "v_text.h" +#include "g_levellocals.h" #include "gl/dynlights/gl_dynlight.h" diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index f3dfbd569..ce6b22ee8 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -37,6 +37,7 @@ #include "g_level.h" #include "r_state.h" #include "d_player.h" +#include "g_levellocals.h" //#include "resources/voxels.h" //#include "gl/gl_intern.h" diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index d09484a1f..3ba557737 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -38,6 +38,7 @@ #include "p_local.h" #include "g_level.h" #include "r_sky.h" +#include "g_levellocals.h" // externally settable lighting properties static float distfogtable[2][256]; // light to fog conversion table for black fog diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 5fc775603..7e9a3e6d2 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -32,6 +32,7 @@ #include "r_utility.h" #include "r_state.h" #include "doomstat.h" +#include "g_levellocals.h" #include "gl/system/gl_cvars.h" #include "gl/data/gl_data.h" diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index efadbcebe..c4296c50d 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -35,6 +35,7 @@ #include "d_player.h" #include "portal.h" #include "templates.h" +#include "g_levellocals.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp index 9242df2a9..4dd7b7d81 100644 --- a/src/gl/scene/gl_renderhacks.cpp +++ b/src/gl/scene/gl_renderhacks.cpp @@ -30,7 +30,7 @@ #include "r_defs.h" #include "r_sky.h" #include "g_level.h" - +#include "g_levellocals.h" #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index b4efe736e..cfd3f017e 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -43,6 +43,7 @@ #include "p_local.h" #include "gl/gl_functions.h" #include "serializer.h" +#include "g_levellocals.h" #include "gl/dynlights/gl_lightbuffer.h" #include "gl/system/gl_interface.h" diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp index 7fa261d36..19d1c9127 100644 --- a/src/gl/scene/gl_sky.cpp +++ b/src/gl/scene/gl_sky.cpp @@ -28,6 +28,7 @@ #include "r_utility.h" #include "doomdata.h" #include "portal.h" +#include "g_levellocals.h" #include "gl/gl_functions.h" #include "gl/data/gl_data.h" diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index b0cfcebe3..198dfea6e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -36,6 +36,7 @@ #include "r_utility.h" #include "a_pickups.h" #include "d_player.h" +#include "g_levellocals.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp index 89eb1d67f..5965eebc3 100644 --- a/src/gl/scene/gl_walls.cpp +++ b/src/gl/scene/gl_walls.cpp @@ -33,6 +33,7 @@ #include "p_maputl.h" #include "doomdata.h" #include "portal.h" +#include "g_levellocals.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 7662c7876..953509495 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -32,6 +32,7 @@ #include "doomstat.h" #include "d_player.h" #include "g_level.h" +#include "g_levellocals.h" #include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp index 0dc9fd76c..68a2b06e5 100644 --- a/src/gl/utility/gl_clock.cpp +++ b/src/gl/utility/gl_clock.cpp @@ -48,6 +48,7 @@ #include "c_dispatch.h" #include "r_utility.h" #include "v_video.h" +#include "g_levellocals.h" #include "gl/utility/gl_clock.h" #include "gl/utility/gl_convert.h" diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index 35e18006d..1164eaf1c 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -50,6 +50,7 @@ #include "gstrings.h" #include "d_net.h" #include "c_dispatch.h" +#include "g_levellocals.h" // MACROS ------------------------------------------------------------------ diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index 2aacd215b..2416f01c4 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -51,6 +51,7 @@ #include "p_conversation.h" #include "menu/menu.h" #include "d_net.h" +#include "g_levellocals.h" FIntermissionDescriptorList IntermissionDescriptors; diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 53ae789c6..414fafba9 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -49,6 +49,7 @@ #include "a_morph.h" #include "a_armor.h" #include "a_ammo.h" +#include "g_levellocals.h" // [RH] Actually handle the cheat. The cheat code in st_stuff.c now just // writes some bytes to the network data stream, and the network code diff --git a/src/menu/readthis.cpp b/src/menu/readthis.cpp index b8a3837ee..f1e82cd51 100644 --- a/src/menu/readthis.cpp +++ b/src/menu/readthis.cpp @@ -37,6 +37,7 @@ #include "v_video.h" #include "g_level.h" #include "gi.h" +#include "g_levellocals.h" #include "textures/textures.h" class DReadThisMenu : public DMenu diff --git a/src/nodebuild_utility.cpp b/src/nodebuild_utility.cpp index 02e280261..85dea384f 100644 --- a/src/nodebuild_utility.cpp +++ b/src/nodebuild_utility.cpp @@ -186,7 +186,7 @@ int FNodeBuilder::CreateSeg (int linenum, int sidenum) } seg.linedef = linenum; side_t *sd = Level.Lines[linenum].sidedef[sidenum]; - seg.sidedef = sd != NULL? int(sd - sides) : int(NO_SIDE); + seg.sidedef = sd != NULL? sd->Index() : int(NO_SIDE); seg.nextforvert = Vertices[seg.v1].segs; seg.nextforvert2 = Vertices[seg.v2].segs2; diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 2f8b3b15c..c25d4a532 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -47,6 +47,7 @@ #include "r_utility.h" #include "p_spec.h" #include "r_data/colormaps.h" +#include "g_levellocals.h" EXTERN_CVAR(Int, vid_renderer) diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index adc487abb..cb7f27a08 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -41,6 +41,7 @@ #include "p_terrain.h" #include "p_maputl.h" #include "p_spec.h" +#include "g_levellocals.h" //============================================================================ diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 0f1feb7b5..f1a0ae8bf 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -86,6 +86,7 @@ #include "a_armor.h" #include "a_ammo.h" #include "r_data/colormaps.h" +#include "g_levellocals.h" extern FILE *Logfile; @@ -3332,16 +3333,14 @@ void DLevelScript::ReplaceTextures (int fromnamei, int tonamei, int flags) picnum1 = TexMan.GetTexture (fromname, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable); picnum2 = TexMan.GetTexture (toname, FTexture::TEX_Wall, FTextureManager::TEXMAN_Overridable); - for (int i = 0; i < numsides; ++i) + for (auto &side : level.sides) { - side_t *wal = &sides[i]; - for(int j=0;j<3;j++) { static BYTE bits[]={NOT_TOP, NOT_MIDDLE, NOT_BOTTOM}; - if (!(flags & bits[j]) && wal->GetTexture(j) == picnum1) + if (!(flags & bits[j]) && side.GetTexture(j) == picnum1) { - wal->SetTexture(j, picnum2); + side.SetTexture(j, picnum2); } } } @@ -4428,14 +4427,14 @@ int DLevelScript::SideFromID(int id, int side) { if (activationline == NULL) return -1; if (activationline->sidedef[side] == NULL) return -1; - return activationline->sidedef[side]->Index; + return activationline->sidedef[side]->UDMFIndex; } else { int line = P_FindFirstLineFromID(id); if (line == -1) return -1; if (level.lines[line].sidedef[side] == NULL) return -1; - return level.lines[line].sidedef[side]->Index; + return level.lines[line].sidedef[side]->UDMFIndex; } } diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index f4b2f8103..b90f656c1 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -80,6 +80,7 @@ #include "math/cmath.h" #include "a_armor.h" #include "a_health.h" +#include "g_levellocals.h" AActor *SingleActorFromTID(int tid, AActor *defactor); diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index 79fd29591..7bf1f9099 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -31,6 +31,7 @@ #include "gi.h" #include "serializer.h" #include "p_spec.h" +#include "g_levellocals.h" //============================================================================ // diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 5fd21e73b..4f7f2fea7 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -60,6 +60,7 @@ #include "r_utility.h" #include "p_local.h" #include "menu/menu.h" +#include "g_levellocals.h" // The conversations as they exist inside a SCRIPTxx lump. struct Response diff --git a/src/p_doors.cpp b/src/p_doors.cpp index 1490647fc..3101be1c7 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -38,6 +38,7 @@ #include "serializer.h" #include "d_player.h" #include "p_spec.h" +#include "g_levellocals.h" //============================================================================ // diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 107759427..44dc17971 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -53,6 +53,7 @@ #include "colormatcher.h" #include "d_player.h" #include "r_utility.h" +#include "g_levellocals.h" CVAR (Int, cl_rockettrails, 1, CVAR_ARCHIVE); CVAR (Bool, r_rail_smartspiral, 0, CVAR_ARCHIVE); diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index a3d48a7ac..ac4e0f04b 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -52,6 +52,7 @@ #include "p_checkposition.h" #include "math/cmath.h" #include "a_ammo.h" +#include "g_levellocals.h" #include "gi.h" diff --git a/src/p_floor.cpp b/src/p_floor.cpp index dbe3792da..48c73f131 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -32,6 +32,7 @@ #include "p_3dmidtex.h" #include "p_spec.h" #include "r_data/r_interpolate.h" +#include "g_levellocals.h" //========================================================================== // diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index 7c76836e9..c68b0d5b0 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -67,6 +67,7 @@ #include "m_misc.h" #include "r_utility.h" #include "cmdlib.h" +#include "g_levellocals.h" void P_GetPolySpots (MapData * lump, TArray &spots, TArray &anchors); @@ -129,6 +130,7 @@ struct gl5_mapnode_t static int CheckForMissingSegs() { + auto numsides = level.sides.Size(); double *added_seglen = new double[numsides]; int missing = 0; @@ -141,13 +143,13 @@ static int CheckForMissingSegs() { // check all the segs and calculate the length they occupy on their sidedef DVector2 vec1(seg->v2->fX() - seg->v1->fX(), seg->v2->fY() - seg->v1->fY()); - added_seglen[seg->sidedef - sides] += vec1.Length(); + added_seglen[seg->sidedef->Index()] += vec1.Length(); } } - for(int i=0;iDelta().Length(); + double linelen = level.sides[i].linedef->Delta().Length(); missing += (added_seglen[i] < linelen - 1.); } @@ -1001,7 +1003,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime) FNodeBuilder::FLevel leveldata = { vertexes, numvertexes, - sides, numsides, + &level.sides[0], (int)level.sides.Size(), &level.lines[0], (int)level.lines.Size(), 0, 0, 0, 0 }; diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 9aa178e64..b6ffcb699 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -60,6 +60,7 @@ #include "a_morph.h" #include "virtual.h" #include "a_health.h" +#include "g_levellocals.h" static FRandom pr_obituary ("Obituary"); static FRandom pr_botrespawn ("BotRespawn"); diff --git a/src/p_lights.cpp b/src/p_lights.cpp index d9fc19c79..5442809e4 100644 --- a/src/p_lights.cpp +++ b/src/p_lights.cpp @@ -32,6 +32,7 @@ #include "p_lnspec.h" #include "doomstat.h" #include "p_maputl.h" +#include "g_levellocals.h" // State. #include "r_state.h" diff --git a/src/p_linkedsectors.cpp b/src/p_linkedsectors.cpp index 03cd5af4e..0dd29c10e 100644 --- a/src/p_linkedsectors.cpp +++ b/src/p_linkedsectors.cpp @@ -37,6 +37,7 @@ #include "p_local.h" #include "p_lnspec.h" #include "p_spec.h" +#include "g_levellocals.h" enum { diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 8d08f8575..77682d1e3 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -61,6 +61,7 @@ #include "r_data/colormaps.h" #include "fragglescript/t_fs.h" #include "p_spec.h" +#include "g_levellocals.h" // Remaps EE sector change types to Generic_Floor values. According to the Eternity Wiki: /* diff --git a/src/p_map.cpp b/src/p_map.cpp index 342e8cb9d..d48fb4e5a 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -63,6 +63,7 @@ #include "r_data/r_translate.h" #include "g_level.h" #include "r_sky.h" +#include "g_levellocals.h" CVAR(Bool, cl_bloodsplats, true, CVAR_ARCHIVE) CVAR(Int, sv_smartaim, 0, CVAR_ARCHIVE | CVAR_SERVERINFO) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 5c7c39051..e6b2aebea 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -44,6 +44,7 @@ #include "r_state.h" #include "templates.h" #include "po_man.h" +#include "g_levellocals.h" sector_t *P_PointInSectorBuggy(double x, double y); int P_VanillaPointOnDivlineSide(double x, double y, const divline_t* line); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 3bdf3718d..d5ec020a0 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -72,6 +72,7 @@ #include "a_armor.h" #include "a_ammo.h" #include "a_health.h" +#include "g_levellocals.h" // MACROS ------------------------------------------------------------------ @@ -7539,6 +7540,22 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) return 0; } +double AActor::GetBobOffset(double ticfrac) const +{ + if (!(flags2 & MF2_FLOATBOB)) + { + return 0; + } + return BobSin(FloatBobPhase + level.maptime + ticfrac); +} + +DEFINE_ACTION_FUNCTION(AActor, GetBobOffset) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT_DEF(frac); + ACTION_RETURN_FLOAT(self->GetBobOffset(frac)); +} + @@ -7639,13 +7656,6 @@ DEFINE_ACTION_FUNCTION(AActor, GetDefaultByType) ACTION_RETURN_OBJECT(cls == nullptr? nullptr : GetDefaultByType(cls)); } -DEFINE_ACTION_FUNCTION(AActor, GetBobOffset) -{ - PARAM_SELF_PROLOGUE(AActor); - PARAM_FLOAT_DEF(frac); - ACTION_RETURN_FLOAT(self->GetBobOffset(frac)); -} - // This combines all 3 variations of the internal function DEFINE_ACTION_FUNCTION(AActor, VelFromAngle) { diff --git a/src/p_pillar.cpp b/src/p_pillar.cpp index d4682e570..d603edc8a 100644 --- a/src/p_pillar.cpp +++ b/src/p_pillar.cpp @@ -39,6 +39,7 @@ #include "s_sndseq.h" #include "serializer.h" #include "r_data/r_interpolate.h" +#include "g_levellocals.h" IMPLEMENT_CLASS(DPillar, false, true) diff --git a/src/p_plats.cpp b/src/p_plats.cpp index 7bbf33b27..8dd82c024 100644 --- a/src/p_plats.cpp +++ b/src/p_plats.cpp @@ -32,6 +32,7 @@ #include "gi.h" #include "serializer.h" #include "p_spec.h" +#include "g_levellocals.h" static FRandom pr_doplat ("DoPlat"); diff --git a/src/p_pspr.cpp b/src/p_pspr.cpp index a6a581228..4349a7c02 100644 --- a/src/p_pspr.cpp +++ b/src/p_pspr.cpp @@ -30,6 +30,7 @@ #include "serializer.h" #include "v_text.h" #include "cmdlib.h" +#include "g_levellocals.h" // MACROS ------------------------------------------------------------------ diff --git a/src/p_pusher.cpp b/src/p_pusher.cpp index 928d9bc5e..5190b5ced 100644 --- a/src/p_pusher.cpp +++ b/src/p_pusher.cpp @@ -32,6 +32,7 @@ #include "p_maputl.h" #include "p_local.h" #include "d_player.h" +#include "g_levellocals.h" CVAR(Bool, var_pushers, true, CVAR_SERVERINFO); diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 2c2cd34ba..33f65bfa7 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -62,10 +62,11 @@ #include "r_sky.h" #include "r_renderer.h" #include "serializer.h" +#include "g_levellocals.h" static TStaticArray loadsectors; static TStaticArray loadlines; -static TArray loadsides; +static TStaticArray loadsides; //========================================================================== @@ -903,7 +904,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload) BYTE chk[16] = { 0 }; arc.Array("checksum", chk, 16); if (arc.GetSize("linedefs") != level.lines.Size() || - arc.GetSize("sidedefs") != (unsigned)numsides || + arc.GetSize("sidedefs") != level.sides.Size() || arc.GetSize("sectors") != level.sectors.Size() || arc.GetSize("polyobjs") != (unsigned)po_NumPolyobjs || memcmp(chk, level.md5, 16)) @@ -957,7 +958,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload) FBehavior::StaticSerializeModuleStates(arc); // The order here is important: First world state, then portal state, then thinkers, and last polyobjects. arc.Array("linedefs", &level.lines[0], &loadlines[0], level.lines.Size()); - arc.Array("sidedefs", sides, &loadsides[0], numsides); + arc.Array("sidedefs", &level.sides[0], &loadsides[0], level.sides.Size()); arc.Array("sectors", &level.sectors[0], &loadsectors[0], level.sectors.Size()); arc("zones", Zones); arc("lineportals", linePortals); @@ -998,8 +999,7 @@ void P_BackupMapData() { loadsectors = level.sectors; loadlines = level.lines; - loadsides.Resize(numsides); - memcpy(&loadsides[0], sides, numsides * sizeof(side_t)); + loadsides = level.sides; } void P_FreeMapDataBackup() diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp index 95adb2b38..403eb3087 100644 --- a/src/p_scroll.cpp +++ b/src/p_scroll.cpp @@ -29,6 +29,7 @@ #include "serializer.h" #include "p_lnspec.h" #include "r_data/r_interpolate.h" +#include "g_levellocals.h" //----------------------------------------------------------------------------- // @@ -191,19 +192,19 @@ void DScroller::Tick () case EScroll::sc_side: // killough 3/7/98: Scroll wall texture if (m_Parts & EScrollPos::scw_top) { - sides[m_Affectee].AddTextureXOffset(side_t::top, dx); - sides[m_Affectee].AddTextureYOffset(side_t::top, dy); + level.sides[m_Affectee].AddTextureXOffset(side_t::top, dx); + level.sides[m_Affectee].AddTextureYOffset(side_t::top, dy); } - if (m_Parts & EScrollPos::scw_mid && (sides[m_Affectee].linedef->backsector == NULL || - !(sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) + if (m_Parts & EScrollPos::scw_mid && (level.sides[m_Affectee].linedef->backsector == NULL || + !(level.sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) { - sides[m_Affectee].AddTextureXOffset(side_t::mid, dx); - sides[m_Affectee].AddTextureYOffset(side_t::mid, dy); + level.sides[m_Affectee].AddTextureXOffset(side_t::mid, dx); + level.sides[m_Affectee].AddTextureYOffset(side_t::mid, dy); } if (m_Parts & EScrollPos::scw_bottom) { - sides[m_Affectee].AddTextureXOffset(side_t::bottom, dx); - sides[m_Affectee].AddTextureYOffset(side_t::bottom, dy); + level.sides[m_Affectee].AddTextureXOffset(side_t::bottom, dx); + level.sides[m_Affectee].AddTextureYOffset(side_t::bottom, dy); } break; @@ -276,19 +277,19 @@ DScroller::DScroller (EScroll type, double dx, double dy, break; case EScroll::sc_side: - sides[affectee].Flags |= WALLF_NOAUTODECALS; + level.sides[affectee].Flags |= WALLF_NOAUTODECALS; if (m_Parts & EScrollPos::scw_top) { - m_Interpolations[0] = sides[m_Affectee].SetInterpolation(side_t::top); + m_Interpolations[0] = level.sides[m_Affectee].SetInterpolation(side_t::top); } - if (m_Parts & EScrollPos::scw_mid && (sides[m_Affectee].linedef->backsector == NULL || - !(sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) + if (m_Parts & EScrollPos::scw_mid && (level.sides[m_Affectee].linedef->backsector == nullptr || + !(level.sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) { - m_Interpolations[1] = sides[m_Affectee].SetInterpolation(side_t::mid); + m_Interpolations[1] = level.sides[m_Affectee].SetInterpolation(side_t::mid); } if (m_Parts & EScrollPos::scw_bottom) { - m_Interpolations[2] = sides[m_Affectee].SetInterpolation(side_t::bottom); + m_Interpolations[2] = level.sides[m_Affectee].SetInterpolation(side_t::bottom); } break; @@ -349,22 +350,22 @@ DScroller::DScroller (double dx, double dy, const line_t *l, m_LastHeight = 0; if ((m_Control = control) != -1) m_LastHeight = level.sectors[control].CenterFloor() + level.sectors[control].CenterCeiling(); - m_Affectee = int(l->sidedef[0] - sides); - sides[m_Affectee].Flags |= WALLF_NOAUTODECALS; + m_Affectee = l->sidedef[0]->Index(); + level.sides[m_Affectee].Flags |= WALLF_NOAUTODECALS; m_Interpolations[0] = m_Interpolations[1] = m_Interpolations[2] = NULL; if (m_Parts & EScrollPos::scw_top) { - m_Interpolations[0] = sides[m_Affectee].SetInterpolation(side_t::top); + m_Interpolations[0] = level.sides[m_Affectee].SetInterpolation(side_t::top); } - if (m_Parts & EScrollPos::scw_mid && (sides[m_Affectee].linedef->backsector == NULL || - !(sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) + if (m_Parts & EScrollPos::scw_mid && (level.sides[m_Affectee].linedef->backsector == NULL || + !(level.sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) { - m_Interpolations[1] = sides[m_Affectee].SetInterpolation(side_t::mid); + m_Interpolations[1] = level.sides[m_Affectee].SetInterpolation(side_t::mid); } if (m_Parts & EScrollPos::scw_bottom) { - m_Interpolations[2] = sides[m_Affectee].SetInterpolation(side_t::bottom); + m_Interpolations[2] = level.sides[m_Affectee].SetInterpolation(side_t::bottom); } } @@ -536,41 +537,41 @@ void P_SpawnScrollers(void) case Scroll_Texture_Offsets: // killough 3/2/98: scroll according to sidedef offsets - s = int(level.lines[i].sidedef[0] - sides); - new DScroller (EScroll::sc_side, -sides[s].GetTextureXOffset(side_t::mid), - sides[s].GetTextureYOffset(side_t::mid), -1, s, accel, SCROLLTYPE(l->args[0])); + s = level.lines[i].sidedef[0]->Index(); + new DScroller (EScroll::sc_side, -level.sides[s].GetTextureXOffset(side_t::mid), + level.sides[s].GetTextureYOffset(side_t::mid), -1, s, accel, SCROLLTYPE(l->args[0])); break; case Scroll_Texture_Left: l->special = special; // Restore the special, for compat_useblocking's benefit. - s = int(level.lines[i].sidedef[0] - sides); + s = level.lines[i].sidedef[0]->Index(); new DScroller (EScroll::sc_side, l->args[0] / 64., 0, -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Right: l->special = special; - s = int(level.lines[i].sidedef[0] - sides); + s = level.lines[i].sidedef[0]->Index(); new DScroller (EScroll::sc_side, -l->args[0] / 64., 0, -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Up: l->special = special; - s = int(level.lines[i].sidedef[0] - sides); + s = level.lines[i].sidedef[0]->Index(); new DScroller (EScroll::sc_side, 0, l->args[0] / 64., -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Down: l->special = special; - s = int(level.lines[i].sidedef[0] - sides); + s = level.lines[i].sidedef[0]->Index(); new DScroller (EScroll::sc_side, 0, -l->args[0] / 64., -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Both: - s = int(level.lines[i].sidedef[0] - sides); + s = level.lines[i].sidedef[0]->Index(); if (l->args[0] == 0) { dx = (l->args[1] - l->args[2]) / 64.; dy = (l->args[4] - l->args[3]) / 64.; @@ -607,8 +608,8 @@ void SetWallScroller (int id, int sidechoice, double dx, double dy, EScrollPos W { int wallnum = scroller->GetWallNum (); - if (wallnum >= 0 && tagManager.LineHasID(sides[wallnum].linedef, id) && - int(sides[wallnum].linedef->sidedef[sidechoice] - sides) == wallnum && + if (wallnum >= 0 && tagManager.LineHasID(level.sides[wallnum].linedef, id) && + level.sides[wallnum].linedef->sidedef[sidechoice]->Index() == wallnum && Where == scroller->GetScrollParts()) { scroller->Destroy (); @@ -627,8 +628,8 @@ void SetWallScroller (int id, int sidechoice, double dx, double dy, EScrollPos W while ( (collect.Obj = iterator.Next ()) ) { if ((collect.RefNum = ((DScroller *)collect.Obj)->GetWallNum ()) != -1 && - tagManager.LineHasID(sides[collect.RefNum].linedef, id) && - int(sides[collect.RefNum].linedef->sidedef[sidechoice] - sides) == collect.RefNum && + tagManager.LineHasID(level.sides[collect.RefNum].linedef, id) && + level.sides[collect.RefNum].linedef->sidedef[sidechoice]->Index() == collect.RefNum && Where == ((DScroller *)collect.Obj)->GetScrollParts()) { ((DScroller *)collect.Obj)->SetRate (dx, dy); @@ -646,7 +647,7 @@ void SetWallScroller (int id, int sidechoice, double dx, double dy, EScrollPos W { if (level.lines[linenum].sidedef[sidechoice] != NULL) { - int sidenum = int(level.lines[linenum].sidedef[sidechoice] - sides); + int sidenum = level.lines[linenum].sidedef[sidechoice]->Index(); unsigned int i; for (i = 0; i < numcollected; i++) { diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 8be0862b6..daccbf06f 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -35,6 +35,7 @@ #include "p_local.h" #include "r_sky.h" #include "r_data/colormaps.h" +#include "g_levellocals.h" // [RH] @@ -1925,10 +1926,10 @@ void subsector_t::BuildPolyBSP() assert((BSP == NULL || BSP->bDirty) && "BSP computed more than once"); // Set up level information for the node builder. - PolyNodeLevel.Sides = sides; - PolyNodeLevel.NumSides = numsides; + PolyNodeLevel.Sides = &level.sides[0]; + PolyNodeLevel.NumSides = level.sides.Size(); PolyNodeLevel.Lines = &level.lines[0]; - PolyNodeLevel.NumLines = numlines; + PolyNodeLevel.NumLines = numlines; // is this correct??? // Feed segs to the nodebuilder and build the nodes. PolyNodeBuilder.Clear(); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 10f4265d3..58b934438 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -74,6 +74,7 @@ #include "r_utility.h" #include "p_spec.h" #include "p_saveg.h" +#include "g_levellocals.h" #ifndef NO_EDATA #include "edata.h" #endif @@ -136,9 +137,6 @@ subsector_t* subsectors; int numnodes; node_t* nodes; -int numsides; -side_t* sides; - TArray Zones; node_t * gamenodes; @@ -194,7 +192,7 @@ TArray deathmatchstarts (16); FPlayerStart playerstarts[MAXPLAYERS]; TArray AllPlayerStarts; -static void P_AllocateSideDefs (int count); +static void P_AllocateSideDefs (MapData *map, int count); //=========================================================================== @@ -1336,9 +1334,9 @@ void P_LoadSegs (MapData * map) ldef = &level.lines[linedef]; li->linedef = ldef; side = LittleShort(ml->side); - if ((unsigned)(ldef->sidedef[side] - sides) >= level.lines.Size()) + if ((unsigned)(ldef->sidedef[side]->Index()) >= level.sides.Size()) { - throw badseg(2, i, int(ldef->sidedef[side] - sides)); + throw badseg(2, i, ldef->sidedef[side]->Index()); } li->sidedef = ldef->sidedef[side]; li->frontsector = ldef->sidedef[side]->sector; @@ -1368,7 +1366,7 @@ void P_LoadSegs (MapData * map) break; case 2: - Printf ("The linedef for seg %d references a nonexistant sidedef %d (max %d).\n", bad.badsegnum, bad.baddata, numsides); + Printf ("The linedef for seg %d references a nonexistant sidedef %d (max %d).\n", bad.badsegnum, bad.baddata, level.sides.Size()); break; } Printf ("The BSP will be rebuilt.\n"); @@ -1978,7 +1976,7 @@ void P_SaveLineSpecial (line_t *ld) if (ld->sidedef[0] == NULL) return; - DWORD sidenum = DWORD(ld->sidedef[0]-sides); + DWORD sidenum = ld->sidedef[0]->Index(); // killough 4/4/98: support special sidedef interpretation below // [RH] Save Static_Init only if it's interested in the textures if (ld->special != Static_Init || ld->args[1] == Init_Color) @@ -2069,7 +2067,7 @@ void P_FinishLoadingLineDefs () { for (auto &line : level.lines) { - P_FinishLoadingLineDef(&line, sidetemp[line.sidedef[0]-sides].a.alpha); + P_FinishLoadingLineDef(&line, sidetemp[line.sidedef[0]->Index()].a.alpha); } } @@ -2079,10 +2077,10 @@ static void P_SetSideNum (side_t **sidenum_p, WORD sidenum) { *sidenum_p = NULL; } - else if (sidecount < numsides) + else if (sidecount < (int)level.sides.Size()) { sidetemp[sidecount].a.map = sidenum; - *sidenum_p = &sides[sidecount++]; + *sidenum_p = &level.sides[sidecount++]; } else { @@ -2148,7 +2146,7 @@ void P_LoadLineDefs (MapData * map) } } - P_AllocateSideDefs (sidecount); + P_AllocateSideDefs (map, sidecount); mld = (maplinedef_t *)mldf; ld = &level.lines[0]; @@ -2241,7 +2239,7 @@ void P_LoadLineDefs2 (MapData * map) ForceNodeBuild = true; } - P_AllocateSideDefs (sidecount); + P_AllocateSideDefs (map, sidecount); mld = (maplinedef2_t *)mldf; ld = &level.lines[0]; @@ -2291,18 +2289,13 @@ void P_LoadLineDefs2 (MapData * map) // // P_LoadSideDefs // -// killough 4/4/98: split into two functions -void P_LoadSideDefs (MapData * map) -{ - numsides = map->Size(ML_SIDEDEFS) / sizeof(mapsidedef_t); -} -static void P_AllocateSideDefs (int count) +static void P_AllocateSideDefs (MapData *map, int count) { int i; - sides = new side_t[count]; - memset (sides, 0, count*sizeof(side_t)); + level.sides.Alloc(count); + memset(&level.sides[0], 0, count * sizeof(side_t)); sidetemp = new sidei_t[MAX(count,numvertexes)]; for (i = 0; i < count; i++) @@ -2311,6 +2304,7 @@ static void P_AllocateSideDefs (int count) sidetemp[i].a.alpha = SHRT_MIN; sidetemp[i].a.map = NO_SIDE; } + auto numsides = map->Size(ML_SIDEDEFS) / sizeof(mapsidedef_t); if (count < numsides) { Printf ("Map has %d unused sidedefs\n", numsides - count); @@ -2331,6 +2325,7 @@ static void P_LoopSidedefs (bool firstloop) { delete[] sidetemp; } + int numsides = level.sides.Size(); sidetemp = new sidei_t[MAX(numvertexes, numsides)]; for (i = 0; i < numvertexes; ++i) @@ -2347,8 +2342,8 @@ static void P_LoopSidedefs (bool firstloop) { // For each vertex, build a list of sidedefs that use that vertex // as their left edge. - line_t *line = sides[i].linedef; - int lineside = (line->sidedef[0] != &sides[i]); + line_t *line = level.sides[i].linedef; + int lineside = (line->sidedef[0] != &level.sides[i]); int vert = int((lineside ? line->v2 : line->v1) - vertexes); sidetemp[i].b.lineside = lineside; @@ -2356,8 +2351,8 @@ static void P_LoopSidedefs (bool firstloop) sidetemp[vert].b.first = i; // Set each side so that it is the only member of its loop - sides[i].LeftSide = NO_SIDE; - sides[i].RightSide = NO_SIDE; + level.sides[i].LeftSide = NO_SIDE; + level.sides[i].RightSide = NO_SIDE; } // For each side, find the side that is to its right and set the @@ -2366,7 +2361,7 @@ static void P_LoopSidedefs (bool firstloop) for (i = 0; i < numsides; ++i) { DWORD right; - line_t *line = sides[i].linedef; + line_t *line = level.sides[i].linedef; // If the side's line only exists in a single sector, // then consider that line to be a self-contained loop @@ -2382,7 +2377,7 @@ static void P_LoopSidedefs (bool firstloop) continue; } - right = DWORD(rightside - sides); + right = rightside->Index(); } else { @@ -2411,7 +2406,7 @@ static void P_LoopSidedefs (bool firstloop) line_t *leftline, *rightline; DAngle ang1, ang2, ang; - leftline = sides[i].linedef; + leftline = level.sides[i].linedef; ang1 = leftline->Delta().Angle(); if (!sidetemp[i].b.lineside) { @@ -2420,9 +2415,9 @@ static void P_LoopSidedefs (bool firstloop) while (right != NO_SIDE) { - if (sides[right].LeftSide == NO_SIDE) + if (level.sides[right].LeftSide == NO_SIDE) { - rightline = sides[right].linedef; + rightline = level.sides[right].linedef; if (rightline->frontsector != rightline->backsector) { ang2 = rightline->Delta().Angle(); @@ -2447,8 +2442,8 @@ static void P_LoopSidedefs (bool firstloop) } assert((unsigned)i<(unsigned)numsides); assert(right<(unsigned)numsides); - sides[i].RightSide = right; - sides[right].LeftSide = i; + level.sides[i].RightSide = right; + level.sides[right].LeftSide = i; } // We keep the sidedef init info around until after polyobjects are initialized, @@ -2604,14 +2599,13 @@ void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmaps void P_LoadSideDefs2 (MapData *map, FMissingTextureTracker &missingtex) { - int i; char * msdf = new char[map->Size(ML_SIDEDEFS)]; map->Read(ML_SIDEDEFS, msdf); - for (i = 0; i < numsides; i++) + for (unsigned i = 0; i < level.sides.Size(); i++) { mapsidedef_t *msd = ((mapsidedef_t*)msdf) + sidetemp[i].a.map; - side_t *sd = sides + i; + side_t *sd = &level.sides[i]; sector_t *sec; // [RH] The Doom renderer ignored the patch y locations when @@ -2628,7 +2622,7 @@ void P_LoadSideDefs2 (MapData *map, FMissingTextureTracker &missingtex) sd->SetTextureYScale(1.); sd->linedef = NULL; sd->Flags = 0; - sd->Index = i; + sd->UDMFIndex = i; // killough 4/4/98: allow sidedef texture names to be overloaded // killough 4/11/98: refined to allow colormaps to work as wall @@ -3390,11 +3384,11 @@ static void P_PrecacheLevel() hitlist[level.sectors[i].GetTexture(sector_t::ceiling).GetIndex()] |= FTextureManager::HIT_Flat; } - for (i = numsides - 1; i >= 0; i--) + for (i = level.sides.Size() - 1; i >= 0; i--) { - hitlist[sides[i].GetTexture(side_t::top).GetIndex()] |= FTextureManager::HIT_Wall; - hitlist[sides[i].GetTexture(side_t::mid).GetIndex()] |= FTextureManager::HIT_Wall; - hitlist[sides[i].GetTexture(side_t::bottom).GetIndex()] |= FTextureManager::HIT_Wall; + hitlist[level.sides[i].GetTexture(side_t::top).GetIndex()] |= FTextureManager::HIT_Wall; + hitlist[level.sides[i].GetTexture(side_t::mid).GetIndex()] |= FTextureManager::HIT_Wall; + hitlist[level.sides[i].GetTexture(side_t::bottom).GetIndex()] |= FTextureManager::HIT_Wall; } // Sky texture is always present. @@ -3464,6 +3458,7 @@ void P_FreeLevelData () } level.sectors.Clear(); level.lines.Clear(); + level.sides.Clear(); if (gamenodes != NULL && gamenodes != nodes) { @@ -3492,12 +3487,6 @@ void P_FreeLevelData () numsubsectors = numgamesubsectors = 0; nodes = gamenodes = NULL; numnodes = numgamenodes = 0; - if (sides != NULL) - { - delete[] sides; - sides = NULL; - } - numsides = 0; if (blockmaplump != NULL) { @@ -3754,7 +3743,6 @@ void P_SetupLevel (const char *lumpname, int position) times[1].Unclock(); times[2].Clock(); - P_LoadSideDefs (map); times[2].Unclock(); times[3].Clock(); @@ -3919,7 +3907,7 @@ void P_SetupLevel (const char *lumpname, int position) FNodeBuilder::FLevel leveldata = { vertexes, numvertexes, - sides, numsides, + &level.sides[0], (int)level.sides.Size(), &level.lines[0], (int)level.lines.Size(), 0, 0, 0, 0 }; diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 9cbf1f69e..a482f602d 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -29,6 +29,7 @@ #include "r_state.h" #include "stats.h" +#include "g_levellocals.h" static FRandom pr_botchecksight ("BotCheckSight"); static FRandom pr_checksight ("CheckSight"); diff --git a/src/p_slopes.cpp b/src/p_slopes.cpp index cc116b692..672c9e77b 100644 --- a/src/p_slopes.cpp +++ b/src/p_slopes.cpp @@ -38,6 +38,7 @@ #include "p_lnspec.h" #include "p_maputl.h" #include "p_spec.h" +#include "g_levellocals.h" //=========================================================================== // diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 15eae0146..b3953b1bd 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -70,6 +70,7 @@ #include "d_player.h" #include "p_maputl.h" #include "p_blockmap.h" +#include "g_levellocals.h" #ifndef NO_EDATA #include "edata.h" #endif diff --git a/src/p_tags.cpp b/src/p_tags.cpp index fb0efa81c..9e7d60d60 100644 --- a/src/p_tags.cpp +++ b/src/p_tags.cpp @@ -36,6 +36,7 @@ #include "p_tags.h" #include "c_dispatch.h" +#include "g_levellocals.h" FTagManager tagManager; @@ -45,17 +46,6 @@ FTagManager tagManager; // //----------------------------------------------------------------------------- -static inline int lineindex(const line_t *line) -{ - return level.lines.Size(); -} - -//----------------------------------------------------------------------------- -// -// -// -//----------------------------------------------------------------------------- - void FTagManager::AddSectorTag(int sector, int tag) { if (tag == 0) return; @@ -244,7 +234,7 @@ bool FTagManager::SectorHasTag(const sector_t *sector, int tag) const int FTagManager::GetFirstLineID(const line_t *line) const { - int i = lineindex(line); + int i = line->Index(); return LineHasIDs(i) ? allIDs[startForLine[i]].tag : 0; } @@ -276,7 +266,7 @@ bool FTagManager::LineHasID(int i, int tag) const bool FTagManager::LineHasID(const line_t *line, int tag) const { - return LineHasID(lineindex(line), tag); + return LineHasID(line->Index(), tag); } //----------------------------------------------------------------------------- diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 131169773..5eb63e4ce 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -38,6 +38,7 @@ #include "p_maputl.h" #include "r_utility.h" #include "p_spec.h" +#include "g_levellocals.h" #define FUDGEFACTOR 10 diff --git a/src/p_things.cpp b/src/p_things.cpp index 6aac786f0..f6c06a1e5 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -51,6 +51,7 @@ #include "p_spec.h" #include "math/cmath.h" #include "actorptrselect.h" +#include "g_levellocals.h" // Set of spawnable things for the Thing_Spawn and Thing_Projectile specials. FClassMap SpawnableThings; diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 332b7af81..2f8151425 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -35,6 +35,7 @@ #include "g_level.h" #include "r_utility.h" #include "p_spec.h" +#include "g_levellocals.h" extern gamestate_t wipegamestate; diff --git a/src/p_trace.cpp b/src/p_trace.cpp index 4b0a5f3bd..3597535e5 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -40,6 +40,7 @@ #include "p_maputl.h" #include "r_defs.h" #include "p_spec.h" +#include "g_levellocals.h" //========================================================================== // diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index bbe7153f9..d86e83a39 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -48,6 +48,7 @@ #include "w_wad.h" #include "p_tags.h" #include "p_terrain.h" +#include "g_levellocals.h" //=========================================================================== // @@ -1136,7 +1137,7 @@ public: sdt->midtexture = "-"; sd->SetTextureXScale(1.); sd->SetTextureYScale(1.); - sd->Index = index; + sd->UDMFIndex = index; sc.MustGetToken('{'); while (!sc.CheckToken('}')) @@ -1815,11 +1816,11 @@ public: } } unsigned numlines = ParsedLines.Size(); - numsides = sidecount; + level.sides.Alloc(sidecount); level.lines.Alloc(numlines); - sides = new side_t[numsides]; int line, side; auto lines = &level.lines[0]; + auto sides = &level.sides[0]; for(line = 0, side = 0; line < (int)numlines; line++) { @@ -1854,11 +1855,10 @@ public: P_AdjustLine(&lines[line]); P_FinishLoadingLineDef(&lines[line], tempalpha[0]); } - assert(side <= numsides); - if (side < numsides) + assert((unsigned)side <= level.sides.Size()); + if ((unsigned)side > level.sides.Size()) { - Printf("Map had %d invalid side references\n", numsides - side); - numsides = side; + Printf("Map had %d invalid side references\n", (int)level.sides.Size() - side); } } diff --git a/src/p_user.cpp b/src/p_user.cpp index 98108f780..662e60a28 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -61,6 +61,7 @@ #include "virtual.h" #include "a_armor.h" #include "a_ammo.h" +#include "g_levellocals.h" static FRandom pr_skullpop ("SkullPop"); diff --git a/src/p_xlat.cpp b/src/p_xlat.cpp index 01c09f450..29ccf966f 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -44,6 +44,7 @@ #include "w_wad.h" #include "sc_man.h" #include "cmdlib.h" +#include "g_levellocals.h" #include "xlat/xlat.h" // define names for the TriggerType field of the general linedefs diff --git a/src/po_man.cpp b/src/po_man.cpp index 3b70fad9c..d9e15d1be 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -32,6 +32,7 @@ #include "p_maputl.h" #include "r_utility.h" #include "p_blockmap.h" +#include "g_levellocals.h" // MACROS ------------------------------------------------------------------ @@ -1429,11 +1430,11 @@ static void InitBlockMap (void) static void InitSideLists () { - for (int i = 0; i < numsides; ++i) + for (unsigned i = 0; i < level.sides.Size(); ++i) { - if (sides[i].linedef != NULL && - (sides[i].linedef->special == Polyobj_StartLine || - sides[i].linedef->special == Polyobj_ExplicitLine)) + if (level.sides[i].linedef != NULL && + (level.sides[i].linedef->special == Polyobj_StartLine || + level.sides[i].linedef->special == Polyobj_ExplicitLine)) { KnownPolySides.Push (i); } @@ -1499,8 +1500,8 @@ static void IterFindPolySides (FPolyObj *po, side_t *side) DWORD sidenum = sidetemp[vnum[vnumat++]].b.first; while (sidenum != NO_SIDE) { - po->Sidedefs.Push(&sides[sidenum]); - AddPolyVert(vnum, DWORD(sides[sidenum].V2() - vertexes)); + po->Sidedefs.Push(&level.sides[sidenum]); + AddPolyVert(vnum, DWORD(level.sides[sidenum].V2() - vertexes)); sidenum = sidetemp[sidenum].b.next; } } @@ -1534,7 +1535,7 @@ static void SpawnPolyobj (int index, int tag, int type) po->bBlocked = false; po->bHasPortals = 0; - side_t *sd = &sides[i]; + side_t *sd = &level.sides[i]; if (sd->linedef->special == Polyobj_StartLine && sd->linedef->args[0] == tag) @@ -1570,14 +1571,14 @@ static void SpawnPolyobj (int index, int tag, int type) i = KnownPolySides[ii]; if (i >= 0 && - sides[i].linedef->special == Polyobj_ExplicitLine && - sides[i].linedef->args[0] == tag) + level.sides[i].linedef->special == Polyobj_ExplicitLine && + level.sides[i].linedef->args[0] == tag) { - if (!sides[i].linedef->args[1]) + if (!level.sides[i].linedef->args[1]) { - I_Error("SpawnPolyobj: Explicit line missing order number in poly %d, linedef %d.\n", tag, sides[i].linedef->Index()); + I_Error("SpawnPolyobj: Explicit line missing order number in poly %d, linedef %d.\n", tag, level.sides[i].linedef->Index()); } - po->Sidedefs.Push (&sides[i]); + po->Sidedefs.Push (&level.sides[i]); } } qsort(&po->Sidedefs[0], po->Sidedefs.Size(), sizeof(po->Sidedefs[0]), posicmp); diff --git a/src/portal.cpp b/src/portal.cpp index 9d07666af..abe442554 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -51,6 +51,7 @@ #include "p_spec.h" #include "p_checkposition.h" #include "math/cmath.h" +#include "g_levellocals.h" // simulation recurions maximum CVAR(Int, sv_portal_recursions, 4, CVAR_ARCHIVE|CVAR_SERVERINFO) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index fef7271e1..14a2f153f 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -51,6 +51,7 @@ #include "r_sky.h" #include "po_man.h" #include "r_data/colormaps.h" +#include "g_levellocals.h" CVAR (Bool, r_drawflat, false, 0) // [RH] Don't texture segs? EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); diff --git a/src/r_defs.h b/src/r_defs.h index 8b760d62e..66fafe4cd 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -656,7 +656,7 @@ public: double FindLowestCeilingPoint(vertex_t **v) const; double FindHighestFloorPoint(vertex_t **v) const; void RemoveForceField(); - int Index() const { return int(this - &level.sectors[0]); } + int Index() const; void AdjustFloorClip () const; void SetColor(int r, int g, int b, int desat); @@ -1158,7 +1158,7 @@ struct side_t WORD TexelLength; SWORD Light; BYTE Flags; - int Index; // needed to access custom UDMF fields which are stored in loading order. + int UDMFIndex; // needed to access custom UDMF fields which are stored in loading order. int GetLightLevel (bool foggy, int baselight, bool is3dlight=false, int *pfakecontrast_usedbygzdoom=NULL) const; @@ -1266,6 +1266,8 @@ struct side_t vertex_t *V1() const; vertex_t *V2() const; + int Index() const; + //For GL FLightNode * lighthead; // all blended lights that may affect this wall @@ -1338,10 +1340,7 @@ struct line_t return portalindex >= linePortals.Size() ? 0 : linePortals[portalindex].mAlign; } - int Index() const - { - return int(this - &level.lines[0]); - } + int Index() const; }; // phares 3/14/98 diff --git a/src/r_plane.cpp b/src/r_plane.cpp index add2d6bf8..c57a6ac5b 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -58,6 +58,7 @@ #include "r_3dfloors.h" #include "v_palette.h" #include "r_data/colormaps.h" +#include "g_levellocals.h" #ifdef _MSC_VER #pragma warning(disable:4244) diff --git a/src/r_sky.cpp b/src/r_sky.cpp index f29929c26..89a2bc44c 100644 --- a/src/r_sky.cpp +++ b/src/r_sky.cpp @@ -34,6 +34,7 @@ #include "r_utility.h" #include "v_text.h" #include "gi.h" +#include "g_levellocals.h" // // sky mapping diff --git a/src/r_state.h b/src/r_state.h index a8476b52f..743bc11a0 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -56,9 +56,6 @@ extern subsector_t* subsectors; extern int numnodes; extern node_t* nodes; -extern int numsides; -extern side_t* sides; - extern TArray Zones; extern node_t * gamenodes; diff --git a/src/r_things.cpp b/src/r_things.cpp index 51b8221ec..62b424327 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -64,6 +64,7 @@ #include "r_data/voxels.h" #include "p_local.h" #include "p_maputl.h" +#include "g_levellocals.h" #include "r_thread.h" EXTERN_CVAR(Bool, st_scale) diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 083e0eeef..d2c40109a 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -52,6 +52,7 @@ #include "d_player.h" #include "serializer.h" #include "v_text.h" +#include "g_levellocals.h" // MACROS ------------------------------------------------------------------ diff --git a/src/s_sndseq.cpp b/src/s_sndseq.cpp index 28786ef8f..31ed314b7 100644 --- a/src/s_sndseq.cpp +++ b/src/s_sndseq.cpp @@ -29,6 +29,7 @@ #include "g_level.h" #include "serializer.h" #include "d_player.h" +#include "g_levellocals.h" // MACROS ------------------------------------------------------------------ diff --git a/src/s_sound.cpp b/src/s_sound.cpp index a37182e20..3888ee3dc 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -53,6 +53,7 @@ #include "serializer.h" #include "d_player.h" #include "r_state.h" +#include "g_levellocals.h" // MACROS ------------------------------------------------------------------ diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 621892a4e..30b998beb 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -49,6 +49,7 @@ #include "gstrings.h" #include "zstring.h" #include "d_event.h" +#include "g_levellocals.h" static TArray properties; static TArray AFTable; diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index e54a00963..c4c44a709 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -73,6 +73,7 @@ #include "a_ammo.h" #include "a_health.h" #include "a_keys.h" +#include "g_levellocals.h" //========================================================================== // diff --git a/src/serializer.cpp b/src/serializer.cpp index e0f8517b9..181d4b741 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -64,6 +64,7 @@ #include "doomerrors.h" #include "v_text.h" #include "cmdlib.h" +#include "g_levellocals.h" char nulspace[1024 * 1024 * 4]; bool save_full = false; // for testing. Should be removed afterward. @@ -1458,7 +1459,7 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, const FPoly template<> FSerializer &Serialize(FSerializer &arc, const char *key, side_t *&value, side_t **defval) { - return SerializePointer(arc, key, value, defval, sides); + return SerializePointer(arc, key, value, defval, &level.sides[0]); } template<> FSerializer &Serialize(FSerializer &arc, const char *key, sector_t *&value, sector_t **defval) diff --git a/src/st_stuff.cpp b/src/st_stuff.cpp index 31cf9b3a7..632eaadf8 100644 --- a/src/st_stuff.cpp +++ b/src/st_stuff.cpp @@ -30,6 +30,7 @@ #include "d_net.h" #include "doomstat.h" #include "g_level.h" +#include "g_levellocals.h" EXTERN_CVAR (Bool, ticker); EXTERN_CVAR (Bool, noisedebug); diff --git a/src/statistics.cpp b/src/statistics.cpp index 92a459e15..e96f10327 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -71,6 +71,7 @@ #include "p_lnspec.h" #include "m_crc32.h" #include "serializer.h" +#include "g_levellocals.h" CVAR(Int, savestatistics, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(String, statfile, "zdoomstat.txt", CVAR_ARCHIVE|CVAR_GLOBALCONFIG) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 6f8bc5198..16b0e405a 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -61,6 +61,7 @@ #include "d_net.h" #include "colormatcher.h" #include "r_data/colormaps.h" +#include "g_levellocals.h" CUSTOM_CVAR(Int, uiscale, 2, CVAR_ARCHIVE | CVAR_NOINITCALL) { diff --git a/src/v_palette.cpp b/src/v_palette.cpp index aa39ba791..4f4c9cb18 100644 --- a/src/v_palette.cpp +++ b/src/v_palette.cpp @@ -56,6 +56,7 @@ #include "x86.h" #include "colormatcher.h" #include "v_palette.h" +#include "g_levellocals.h" #include "r_data/colormaps.h" FPalette GPalette; diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index 12ca10e32..eb1c7d2fa 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -52,6 +52,7 @@ #include "templates.h" #include "gstrings.h" #include "cmdlib.h" +#include "g_levellocals.h" // States for the intermission typedef enum diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 2a99f4364..14c4791c6 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -81,6 +81,7 @@ #include "g_level.h" #include "doomstat.h" #include "r_utility.h" +#include "g_levellocals.h" #include "stats.h" #include "st_start.h"