Skip to content

Commit 2fc62e8

Browse files
committed
Add .conf file location fallback to current folder
1 parent 4f875dd commit 2fc62e8

5 files changed

Lines changed: 32 additions & 14 deletions

File tree

src/game/AuctionHouseBot/AuctionHouseBot.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,16 @@ bool AuctionBotConfig::Initialize()
437437
{
438438
if (!m_AhBotCfg.SetSource(m_configFileName.c_str()))
439439
{
440-
sLog.outString("AHBOT is Disabled. Unable to open configuration file %s. ", m_configFileName.c_str());
441-
setConfig(CONFIG_UINT32_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO, 0);
442-
setConfig(CONFIG_UINT32_AHBOT_HORDE_ITEM_AMOUNT_RATIO, 0);
443-
setConfig(CONFIG_UINT32_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO, 0);
444-
return false;
440+
// Try current folder as fallback
441+
if (!m_AhBotCfg.SetSource(AUCTIONHOUSEBOT_CONFIG_NAME))
442+
{
443+
sLog.outString("AHBOT is Disabled. Unable to open configuration file %s. ", m_configFileName.c_str());
444+
setConfig(CONFIG_UINT32_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO, 0);
445+
setConfig(CONFIG_UINT32_AHBOT_HORDE_ITEM_AMOUNT_RATIO, 0);
446+
setConfig(CONFIG_UINT32_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO, 0);
447+
return false;
448+
}
449+
m_configFileName = AUCTIONHOUSEBOT_CONFIG_NAME;
445450
}
446451
else
447452
{

src/mangosd/mangosd.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,17 @@ int main(int argc, char** argv)
371371
#endif
372372
if (!sConfig.SetSource(cfg_file))
373373
{
374-
sLog.outError("Could not find configuration file %s.", cfg_file);
375-
Log::WaitBeforeContinueIfNeed();
376-
return 1;
374+
// Try current folder as fallback if SYSCONFDIR path fails
375+
if (!sConfig.SetSource(MANGOSD_CONFIG_NAME))
376+
{
377+
sLog.outError("Could not find configuration file %s.", cfg_file);
378+
Log::WaitBeforeContinueIfNeed();
379+
return 1;
380+
}
381+
cfg_file = MANGOSD_CONFIG_NAME;
377382
}
378383

379-
#ifndef _WIN32 // posix daemon commands need apply after config read
384+
#ifndef _WIN32
380385
switch (serviceDaemonMode)
381386
{
382387
case 'r':

src/modules/Bots/ahbot/AhBotConfig.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ bool AhBotConfig::Initialize()
3131
{
3232
if (!config.SetSource(AUCTIONHOUSEBOT_CONFIG_NAME))
3333
{
34-
sLog.outString("AhBot is Disabled. Unable to open configuration file ahbot.conf");
35-
return false;
34+
// Try current folder as fallback
35+
if (!config.SetSource("ahbot.conf"))
36+
{
37+
sLog.outString("AhBot is Disabled. Unable to open configuration file ahbot.conf");
38+
return false;
39+
}
3640
}
3741

3842
enabled = config.GetBoolDefault("AhBot.Enabled", false);

src/modules/Bots/playerbot/PlayerbotAIConfig.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ bool PlayerbotAIConfig::Initialize()
103103

104104
if (!config.SetSource(SYSCONFDIR"aiplayerbot.conf"))
105105
{
106-
sLog.outString("AI Playerbot is Disabled. Unable to open configuration file aiplayerbot.conf");
107-
return false;
106+
// Try current folder as fallback
107+
if (!config.SetSource("aiplayerbot.conf"))
108+
{
109+
sLog.outString("AI Playerbot is Disabled. Unable to open configuration file aiplayerbot.conf");
110+
return false;
111+
}
108112
}
109113

110114
enabled = config.GetBoolDefault("AiPlayerbot.Enabled", true);

src/realmd

Submodule realmd updated 1 file

0 commit comments

Comments
 (0)