Skip to content

Commit

Permalink
set cmod "nativeUI" flag on server
Browse files Browse the repository at this point in the history
Adds "nativeUI" flag to server config string for better compatibility with cMod client in certain cases.

Implemented using new "misc" server module to support the convention of using the mod system for non-essential features when possible.
  • Loading branch information
Chomenor committed Feb 7, 2023
1 parent 0398972 commit 3cf1554
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/msvc_2019/game.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
<ClCompile Include="..\..\code\game\mods\components\comp_warmup_sequence.c" />
<ClCompile Include="..\..\code\game\mods\features\feat_altswap_handler.c" />
<ClCompile Include="..\..\code\game\mods\features\feat_bot_adding.c" />
<ClCompile Include="..\..\code\game\mods\features\feat_misc.c" />
<ClCompile Include="..\..\code\game\mods\features\feat_player_move.c" />
<ClCompile Include="..\..\code\game\mods\features\feat_spawn_protect.c" />
<ClCompile Include="..\..\code\game\mods\features\feat_spect_passthrough.c" />
Expand Down
3 changes: 3 additions & 0 deletions build/msvc_2019/game.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@
<ClCompile Include="..\..\code\game\mods\features\feat_bot_adding.c">
<Filter>game\mods\features</Filter>
</ClCompile>
<ClCompile Include="..\..\code\game\mods\features\feat_misc.c">
<Filter>game\mods\features</Filter>
</ClCompile>
<ClCompile Include="..\..\code\game\mods\features\feat_player_move.c">
<Filter>game\mods\features</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions build/qvm_build/build_game.bat
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ set src=game\mods\components&set name=comp_pending_item&call :compile
set src=game\mods\components&set name=comp_warmup_sequence&call :compile
set src=game\mods\features&set name=feat_altswap_handler&call :compile
set src=game\mods\features&set name=feat_bot_adding&call :compile
set src=game\mods\features&set name=feat_misc&call :compile
set src=game\mods\features&set name=feat_player_move&call :compile
set src=game\mods\features&set name=feat_spect_passthrough&call :compile
set src=game\mods\features&set name=feat_spawn_protect&call :compile
Expand Down
42 changes: 42 additions & 0 deletions code/game/mods/features/feat_misc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Misc Features
*
* This module can be used to add minor tweaks or cvar-controlled options that
* don't fit anywhere else and are too minor to justify their own mod file.
*/

#define MOD_PREFIX( x ) ModMiscFeatures_##x

#include "mods/g_mod_local.h"

static struct {
// For mod function stacking
ModFNType_AddModConfigInfo Prev_AddModConfigInfo;
} *MOD_STATE;

/*
==============
(ModFN) AddModConfigInfo
==============
*/
LOGFUNCTION_VOID( MOD_PREFIX(AddModConfigInfo), ( char *info ), ( info ), "G_MODFN_ADDMODCONFIGINFO" ) {
// Indicate to cMod client to use preferred default UI module if possible, to avoid
// potential settings reset on disconnect or other engine incompatibilities.
// This should be disabled if creating a mod that has a need for a customized UI.
Info_SetValueForKey( info, "nativeUI", "1" );

MOD_STATE->Prev_AddModConfigInfo( info );
}

/*
================
ModMiscFeatures_Init
================
*/
LOGFUNCTION_VOID( ModMiscFeatures_Init, ( void ), (), "G_MOD_INIT" ) {
if ( !MOD_STATE ) {
MOD_STATE = G_Alloc( sizeof( *MOD_STATE ) );

INIT_FN_STACKABLE( AddModConfigInfo );
}
}
1 change: 1 addition & 0 deletions code/game/mods/g_mod_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void ModTournament_Init( void );

void ModAltSwapHandler_Init( void );
void ModBotAdding_Init( void );
void ModMiscFeatures_Init( void );
void ModPingcomp_Init( void );
void ModPlayerMove_Init( void );
void ModSpawnProtect_Init( void );
Expand Down
1 change: 1 addition & 0 deletions code/game/mods/g_mod_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ LOGFUNCTION_VOID( G_ModsInit, ( void ), (), "G_MOD_INIT" ) {

// Default mods
if ( modsEnabled >= 2 ) {
ModMiscFeatures_Init();
ModPlayerMove_Init();
ModAltSwapHandler_Init();
ModPingcomp_Init();
Expand Down

0 comments on commit 3cf1554

Please sign in to comment.