Get HL2SB compiling
Pardon the messy commit. I turned off code formatting too late and checking every file line-by-line to fix it is too time consuming (plus I've been at that for some time, getting this to compile).
This PR is the result of my own project being merged over top HL2SB. My own project is the result of a fresh clone from [SourceSDK 2013 by Valve] (https://github.com/ValveSoftware/source-sdk-2013) with HL2SB code slowly copied over to it.
It is pretty late, so I'm just info dumping a bit now, some notes/todo's:
- [ ] I commented the mounting of games and addons, because I wasn't using it in my project. Its still disabled here
- [ ] Same goes for the ARGG, I have yet to enable it:
- [ ] On launching the game you'll get two asserts which you can pass by clicking "Ignore Asserts in This File" (the second assert repeats a hundred times and ends up spamming your console)
- [ ] It seems I commented the player model selectionin hl2mp_gamerules.cpp under ClientSettingsChanged because my project didnt require it
- [ ] Same for episodic content like IsAlyxInDarknessMode
- [ ] I included the HL2SB game project here, because its required to test and play. Having it in a seperate repo seems cumbersome to me, besides I:
- [x] made some changes to the
cfg/settings*.srcfiles to enable the gamemode picker. - [x] I fixed the
gameinfo.txtusing deprecated keyvalues - [x] Fixed the Lua code which didn't provide the required first argument to
surface.AddCustomFontFile - [ ] Do let me know if you all want to keep it separated. But I think a monorepo might be more useful to keep every souce file in sync. We could create a GitHub action to compile and zip a release here as well, to make it easier to download for non-technical users.
- [x] made some changes to the
- [ ] To prevent future formatting trouble, I propose including a
.clang-format. We can direct our IDE's to respect that in the future. I've included an example. - [x] These changes by tonysergi are included, since I copied those over in my project, on which this merge is based.
- [x] I called the missing
PlayerUpdateFlashlight - [x] Added a getting started, to help contributors going
- [x] Added a little bash script (
src/setupprojects.sh) to quickly setup debugging (because the vpc scripts mess that up when they touch the vs project files) - [ ] There's an occasional heap error in CClassMap::Add and RemoveAllScripted caused by removing items whilst iterating forward. Should reverse the loop instead, e.g:
void CClassMap::RemoveAllScripted(void) {
int c = m_ClassDict.Count();
int i;
for ( i = c - 1; i >= 0; i-- )
{
classentry_t *lookup = &m_ClassDict[i];
if ( !lookup )
continue;
if ( lookup->scripted )
{
m_ClassDict.RemoveAt( i );
}
}
}
I've done my best to remove any changes I made that are irrelevant to this project. However I've likely missed some.
I'm making this a draft merge. I'd like some guidance on how to best clean this PR up, so the merge becomes reviewable.
Additional notes
I'll use this list to track additional issues I find in my own project, that need fixing in HL2SB as well. They're not all related to this PR, so feel free to ask me to make separate PR's/issues for each of them.
- [ ] Implement this fix for animations: https://developer.valvesoftware.com/wiki/SDK_Known_Issues_List_Fixed#Thirdperson_player_animations_look_like_.22Ice_Skating.22
- [ ] Change
const char *zipPath = NULL;toconst char *zipPath = relativePath;in luacachefile.cpp to fix constructing cache files - [ ]
Ensure the lua_cache path is added as a search path, so downloaded gamemodes actually load if the client doesn't already have it in their gamemodes folder. I did this by adding this to the end ofThis can also be done by properly implementing mountaddons.cpp (which I had removed in my mod)luasrc_ExtractLcf(and refactoring it slightly so thegamePathvar is available in the same scope):
#ifdef CLIENT_DLL
// Add the cache folder to the Lua path, so clients can load files from it.
char cacheDirectoryPath[MAX_PATH];
Q_strncpy( cacheDirectoryPath, gamePath, sizeof( cacheDirectoryPath ) );
Q_strncat( cacheDirectoryPath, "\\" LUA_PATH_CACHE, sizeof( cacheDirectoryPath ), COPY_ALL_CHARACTERS );
filesystem->AddSearchPath( cacheDirectoryPath, "MOD" );
#endif
- [ ] In luamanager.cpp the content path is incorrectly added relatively (should be absolute). Replace
filesystem->AddSearchPath( contentSearchPath, "MOD" );with something like:
#ifdef CLIENT_DLL
const char *gamePath = engine->GetGameDirectory();
#else
char gamePath[256];
engine->GetGameDir( gamePath, 256 );
#endif
Q_strncpy( contentSearchPath, gamePath, sizeof( contentSearchPath ) );
Q_strncat( contentSearchPath, "\\gamemodes\\", sizeof( contentSearchPath ) );
Q_strncat( contentSearchPath, gamemode, sizeof( contentSearchPath ) );
Q_strncat( contentSearchPath, "\\content", sizeof( contentSearchPath ) );
filesystem->AddSearchPath( contentSearchPath, "GAME" ); // I made this GAME, so the source engine is able to download content to clients