Skip to content

Rewrite of archaic Mapbase code - #563

Draft
Blixibon wants to merge 8 commits into
mapbase-source:feature/combined-sp-mpfrom
Blixibon:mapbase/feature/archaic-mapbase-code-rewrite
Draft

Blixibon wants to merge 8 commits into
mapbase-source:feature/combined-sp-mpfrom
Blixibon:mapbase/feature/archaic-mapbase-code-rewrite

Conversation

@Blixibon

@Blixibon Blixibon commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

This PR rewrites and refactors Mapbase code of various origin that was written early in the project to be more efficient and less janky. This targets the combined SP/MP branch due to the MP branch already containing some refactors that were needed to support TF2.

As part of this refactor, a number of particularly obscure features have been removed. Instances of this are in bold.


mapbase_shared (generic code, map-specific files)

  • Some of mapbase_shared has been split into a header file. Mainly to declutter it, but also to move the MODTITLECOMMENT structs out of gameinterface.
  • Support for an automatically loaded manifest file (%mapname%_manifest.txt) to override the default map-specific file paths has been removed, as has the mapbase_manifest entity. These were very seldom used and documented, and there was a report that the latter may not have been functional. If you need to load non-standard files, use the exposed VScript functions.
  • Map-specific file manifest keyvalues now use symbol comparisons instead of string comparisons (symbols looked up on level init).
  • Cvars to enable specific map-specific files have been removed. These were causing server/client conflicts and weren't particularly useful. The mapbase_load_default_manifest cvar (which could disable all default map-specific files) is retained.

Most other changes are general refactoring or organization. I would have liked to do more to revisit the way the map-specific file enum and array are defined due to how messy the #ifdefs are, but I don't think a more intricate solution is necessary for it.

mapbase_game_log

Completely removed. Was not finished or documented. A similar system should use a modified gamestats.

mapbase_con_groups (console groups)

The original idea behind console groups was to achieve a Source 2-style system where you not only have custom colors and separation for groups of console messages, but can also configure them by editing a script file. However, this feature is neither well-documented nor have I felt that this has been useful under its past implementation, as all console groups were in a hardcoded array.

Console groups are now defined as direct struct objects, and then passed by reference to CGMsg. This allows custom console groups to be declared quickly and easily. CGMsg itself has also been refactored to use a macro instead of a dedicated function that always has to use va_list. Performance is proven to be near-identical to calling Msg directly.

To avoid linker issues, the console group code has been pulled out of tier1 and moved into common to be included directly by the projects that use it. Game-related console groups have also been moved into their own file (game_con_groups) to partition them further.

The compiler will throw an error if a file includes the original tier version of mapbase_con_groups.h.

Additionally, two new console groups have been added for MP: Death Notices and Game Coordinator, with the latter being TF2-specific.

mapbase_matchers_base/matchers

Mainly pulled the matcher cvars out of tier1 and into mapbase_shared.cpp, since they had conflicts between the client/server. For now, I've only defined cvars for the server. Also cleaned up some of the comments.

Remove CHudIcons

CHudIcons was added from the VDC tutorial for adding the Game Instructor. However, this actually contains duplicated functionality for loading HUD textures. In the Alien Swarm SDK, CHudIcons replaced all HUD texture functionality, but that isn't the case in Source 2013, which appears to have been a mistake in the tutorial. The calls for loading instructor textures have been moved to CHud, as have the calls for loading them in the instructor HUD.

Projected textures

The ASW_PROJECTED_TEXTURES preprocessor has been removed, with its associated code folded either into base code or into the MAPBASE preprocessor. Additionally, to avoid data from being lost across the engine divide (and other ABI issues), the new variables in FlashlightState_t have been moved into a separate FlashlightStateExtras_t struct managed directly by the client shadow manager for each projected texture. (technically it's used on every shadow as well, which isn't necessary and allocates a few extra bytes, but I felt that this was easier and less risky than a pointer to data in the projected textures)

Additionally, shadow depth textures are passed to the shader via render parms again, as is the case in SP branch Mapbase. This was lost in the initial MP port because the render parms sent pointers, which weren't sent properly in 64-bit, but that led to issues with decals flickering when multiple projected textures are shining at once. This has been fixed and restored.

There's also a feature riding with this that's more-or-less completely new: Shadow depth textures are now split into 4 different sets of different resolutions, which by default are 2048x2048, 1024x1024, 512x512, and 256x256 (as opposed to just 2048x2048). The idea is that more shadow maps can be allocated for lower resolutions without a significant increase in overall memory; for example, 4 instances of 1024x1024 shadow maps can fit into one 2048x2048 shadow map. Mappers can use specific resolutions via keyvalues, or they would otherwise fall back automatically if there's too many projected textures visible at once. The number of textures allocated for each resolution can also be set in a script file, rather than through command line params.

Global strings

Mapbase's "global strings" feature (hardcoded micro-optimizations in GlobalStrings.h/.cpp adapted from HL2 code) has been completely removed and replaced with a new base entity function called ClassMatchesDirect(), which uses the pre-existing AllocPooledString_StaticConstantStringPointer to find pooled strings extremely quickly and when using string literals. There's also an overload which takes a string_t directly and just compares the pointers.

Instances of global strings filling in for base code have been reverted, but the original code calls ClassMatchesDirect instead when applicable.

The compiler will throw an error if a file includes GlobalStrings.h or uses any of its functions or variables.

Weapon data parsing

HL2-specific weapon data values have been moved to a new custom weapon parse class, as is the case in TF2 and HL2DM.

@Blixibon

Blixibon commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

A couple other notes:

  • I want to either get rid of GlobalStrings.cpp/.h or find a better way to implement it. Not sure what to do with it yet Done this
  • Something should probably be done about MapEdit.cpp, although maybe in a separate PR depending on how many changes are needed

@Blixibon
Blixibon force-pushed the mapbase/feature/archaic-mapbase-code-rewrite branch 10 times, most recently from 27d5bd3 to a491a02 Compare November 16, 2026 05:40
@Blixibon
Blixibon force-pushed the feature/combined-sp-mp branch from e993b91 to 6da1e0b Compare November 16, 2026 05:56
@Blixibon
Blixibon force-pushed the mapbase/feature/archaic-mapbase-code-rewrite branch from a491a02 to 5585bd4 Compare November 16, 2026 06:19
@Blixibon
Blixibon force-pushed the feature/combined-sp-mp branch 4 times, most recently from e7d9834 to 91de33e Compare November 17, 2026 00:47
@Blixibon
Blixibon force-pushed the mapbase/feature/archaic-mapbase-code-rewrite branch from 5585bd4 to 563c1c8 Compare November 17, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant