Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for client_mods folder + allow clientside mods to edit safe tbl files #269

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Version 1.9.0 (not released yet)
- Add Kill Reward settings for dedicated servers
- Do not load unnecessary VPPs in dedicated server mode
- Add level filename to "Level Initializing" console message
- Allow clientside mods to edit table files that can't be used to cheat (strings, hud, hud_personas, personas, credits, endgame, ponr)
- Properly handle WM_PAINT in dedicated server, may improve performance (DF bug)

Version 1.8.0 (released 2022-09-17)
Expand Down
37 changes: 32 additions & 5 deletions game_patch/misc/vpackfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ static bool g_is_overriding_disabled = false;

const char* mod_file_allow_list[] = {
"reticle_0.tga",
"reticle_1.tga",
"scope_ret_0.tga",
"scope_ret_1.tga",
"reticle_rocket_0.tga",
"reticle_rocket_1.tga",
};

static bool is_mod_file_in_whitelist(const char* Filename)
Expand All @@ -61,6 +64,26 @@ static bool is_mod_file_in_whitelist(const char* Filename)

#endif // MOD_FILE_WHITELIST

// allow list of table files that can't be used for cheating, but for which modding in clientside mods has utility
// Examples include translation packs (translated strings, endgame, etc.) and custom HUD mods that change coords of HUD elements
const char* tbl_mod_allow_list[] = {
GooberRF marked this conversation as resolved.
Show resolved Hide resolved
"strings.tbl",
"hud.tbl",
"hud_personas.tbl",
"personas.tbl",
"credits.tbl",
"endgame.tbl",
"ponr.tbl",
};

static bool is_tbl_file_in_allowlist(const char* Filename)
{
for (unsigned i = 0; i < std::size(tbl_mod_allow_list); ++i)
if (!stricmp(tbl_mod_allow_list[i], Filename))
return true;
return false;
}

#if CHECK_PACKFILE_CHECKSUM

static unsigned hash_file(const char* Filename)
Expand Down Expand Up @@ -299,19 +322,23 @@ static bool is_lookup_table_entry_override_allowed(rf::VPackfileEntry* old_entry
// Allow overriding by packfiles from game root and from mods
return true;
}
if (!old_entry->parent->is_user_maps && !stricmp(rf::file_get_ext(new_entry->name), ".tbl")) {
// Always skip overriding tbl files from game by user_maps
return false;
}
#ifdef MOD_FILE_WHITELIST
if (is_mod_file_in_whitelist(new_entry->file_name)) {
if (is_mod_file_in_whitelist(new_entry->name)) {
// Always allow overriding for specific files
return true;
}
#endif
if (!g_game_config.allow_overwrite_game_files) {
return false;
}
if (!old_entry->parent->is_user_maps && is_tbl_file_in_allowlist(new_entry->name)) {
// Allow overriding of tbl files from user_maps if they are on allow list
return true;
}
if (!old_entry->parent->is_user_maps && !stricmp(rf::file_get_ext(new_entry->name), ".tbl")) {
// Skip overriding of all other tbl files from user_maps
return false;
}
GooberRF marked this conversation as resolved.
Show resolved Hide resolved
g_is_modded_game = true;
return true;
}
Expand Down