Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit fe1aa47

Browse files
committed
Store player loadouts (BuyMenu presets) in the Userdata directory
Fix metagame loadout paths
1 parent a3a8fa0 commit fe1aa47

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
625625

626626
- Swapped to SDL2 for window management and input handling.
627627

628-
- `Settings.ini` is now stored in the `Userdata` directory instead of `Base.rte`.
628+
- `Settings.ini` and player loadouts (BuyMenu presets) are now stored in the `Userdata` directory instead of `Base.rte`.
629629

630630
- Lua scripts are now run in a more efficient way. As part of this change, `PieSlice` scripts need to be reloaded like `MovableObject` scripts (i.e. using `pieSlice:ReloadScripts()`, in order for their changes to be reflected in-game.
631631
`PresetMan:ReloadAllScripts()` will reload `PieSlice` preset scripts, like it does for `MovableObject`s.

Managers/SettingsMan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace RTE {
7272
int SettingsMan::Initialize() {
7373
if (const char *settingsTempPath = std::getenv("CCCP_SETTINGSPATH")) { m_SettingsPath = std::string(settingsTempPath); }
7474

75-
Reader settingsReader(m_SettingsPath, false, nullptr, true);
75+
Reader settingsReader(m_SettingsPath, false, nullptr, true, true);
7676

7777
if (!settingsReader.ReaderOK()) {
7878
Writer settingsWriter(m_SettingsPath);

Menus/BuyMenuGUI.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ bool BuyMenuGUI::LoadAllLoadoutsFromFile()
405405
if (m_MetaPlayer != Players::NoPlayer)
406406
{
407407
// Start loading any additional stuff from the custom user file
408-
std::snprintf(loadoutPath, sizeof(loadoutPath), "%s/%s - LoadoutsMP%d.ini", c_UserConquestSavesModuleName.c_str(), g_MetaMan.GetGameName().c_str(), m_MetaPlayer + 1);
408+
std::snprintf(loadoutPath, sizeof(loadoutPath), "%s/%s - LoadoutsMP%d.ini", (System::GetUserdataDirectory() + c_UserConquestSavesModuleName).c_str(), g_MetaMan.GetGameName().c_str(), m_MetaPlayer + 1);
409409

410410
if (!System::PathExistsCaseSensitive(loadoutPath))
411411
{
@@ -416,12 +416,12 @@ bool BuyMenuGUI::LoadAllLoadoutsFromFile()
416416
// Not a metagame player, just a regular scenario player
417417
else
418418
{
419-
std::snprintf(loadoutPath, sizeof(loadoutPath), "Base.rte/LoadoutsP%d.ini", m_pController->GetPlayer() + 1);
419+
std::snprintf(loadoutPath, sizeof(loadoutPath), "%sLoadoutsP%d.ini", System::GetUserdataDirectory().c_str(), m_pController->GetPlayer() + 1);
420420

421421
}
422422

423423
// Open the file
424-
Reader loadoutFile(loadoutPath, false, 0, true);
424+
Reader loadoutFile(loadoutPath, false, nullptr, true, true);
425425

426426
// Read any and all loadout presets from file
427427
while (loadoutFile.ReaderOK() && loadoutFile.NextProperty())
@@ -518,12 +518,12 @@ bool BuyMenuGUI::SaveAllLoadoutsToFile()
518518
// Since the players of a new game are likely to have different techs and therefore different default loadouts
519519
// So we should start fresh with new loadouts loaded from tech defaults for each player
520520
if (g_MetaMan.GetGameName() == DEFAULTGAMENAME)
521-
std::snprintf(loadoutPath, sizeof(loadoutPath), "%s/%s - LoadoutsMP%d.ini", c_UserConquestSavesModuleName.c_str(), AUTOSAVENAME, m_MetaPlayer + 1);
521+
std::snprintf(loadoutPath, sizeof(loadoutPath), "%s/%s - LoadoutsMP%d.ini", (System::GetUserdataDirectory() + c_UserConquestSavesModuleName).c_str(), AUTOSAVENAME, m_MetaPlayer + 1);
522522
else
523-
std::snprintf(loadoutPath, sizeof(loadoutPath), "%s/%s - LoadoutsMP%d.ini", c_UserConquestSavesModuleName.c_str(), g_MetaMan.GetGameName().c_str(), m_MetaPlayer + 1);
523+
std::snprintf(loadoutPath, sizeof(loadoutPath), "%s/%s - LoadoutsMP%d.ini", (System::GetUserdataDirectory() + c_UserConquestSavesModuleName).c_str(), g_MetaMan.GetGameName().c_str(), m_MetaPlayer + 1);
524524
}
525525
else
526-
std::snprintf(loadoutPath, sizeof(loadoutPath), "Base.rte/LoadoutsP%d.ini", m_pController->GetPlayer() + 1);
526+
std::snprintf(loadoutPath, sizeof(loadoutPath), "%sLoadoutsP%d.ini", System::GetUserdataDirectory().c_str(), m_pController->GetPlayer() + 1);
527527

528528
// Open the file
529529
Writer loadoutFile(loadoutPath, false);

0 commit comments

Comments
 (0)