source-sdk-2013
source-sdk-2013 copied to clipboard
Player model selector is returning the wrong value (requires changes to source code)
So after spending all day trying to figure out what is wrong with the player model character selector in the mod I'm working on I figured out what the issue was.
Throwing in a few Msg()'s to display some debug info at run time showed that using cl_playermodel works just fine BUT if you use the one in the options menu it sets cl_playermodel to the string "models" instead of the proper file path.
Now this sounds like it would be rather easy to fix however modders are not given access to the options menu directly in 2013 (you can in ASW I believe though). The most we can do is change the .res files.
So for right now the solution is to hide Valves player model selector via OptionsSubMultiplayer.res and then make your own that is accessible from the main menu.
This shouldn't be a big deal on a modders part but THIS AFFECTS HL2DM AS WELL, meaning the live version of HL2DM is currently bugged!
To see the problem yourself add Msg("Player model is %s\n", pModel);
to hl2mp_player.cpp inside bool CHL2MP_Player::ValidatePlayerModel( const char *pModel )
after int i;
(should be around line 380)
Compile, load up the game and then start a listen server. Once in press escape and choose a model from the options menu. Once that's done look at the console window.
So I noticed this happening on my mod and it annoyed me enough to fix it myself by patching the binary.
Essentially what's happening is Valve has a strcmp() that checks for an extra OS-specific path separator - on Windows this is \
.
The path is already normalized to use Unix separators before that, so on Windows it fails and never removes the extra slash.
I simply fixed it in a hex editor to replace that \
with /
instead.
Patched DLL is here: GameUI_6982830.zip The exact same file is currently used on both HL2DM and Source SDK 2013 Base Multiplayer so it should work for mods as well.