MCPcopy Create free account
hub / github.com/bwapi/bwapi / reloadConfig

Method reloadConfig

bwapi/BWAPI/Source/BWAPI/AutoMenuManager.cpp:32–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32void AutoMenuManager::reloadConfig()
33{
34 InitPrimaryConfig();
35
36 // Reset menu activation variables
37 this->actRaceSel = false;
38 this->actStartedGame = false;
39 this->autoMapTryCount = 0;
40
41 //this function is called when starcraft loads and at the end of each match.
42 //the function loads the parameters for the auto-menu feature such as auto_menu, map, race, enemy_race, enemy_count, and game_type
43 this->autoMenuMode = LoadConfigStringUCase("auto_menu", "auto_menu", "OFF");
44#ifdef _DEBUG
45 this->autoMenuPause = LoadConfigStringUCase("auto_menu", "pause_dbg", "OFF");
46#endif
47 this->autoMenuRestartGame = LoadConfigStringUCase("auto_menu", "auto_restart", "OFF");
48 this->autoMenuGameName = LoadConfigString("auto_menu", "game");
49 this->autoMenuCharacterName = LoadConfigString("auto_menu", "character_name", "FIRST").substr(0, 24);
50
51 // Load map string
52 std::string cfgMap = LoadConfigString("auto_menu", "map", "");
53 std::replace(cfgMap.begin(), cfgMap.end(), '/', '\\');
54
55 // Used to check if map string was changed.
56 static std::string lastAutoMapString;
57 bool mapChanged = false;
58
59 // If the auto-menu map field was changed
60
61 if (lastAutoMapString != cfgMap)
62 {
63 lastAutoMapString = cfgMap;
64 this->lastAutoMapEntry = 0;
65 this->lastMapGen.clear();
66 this->autoMapPool.clear();
67
68 // Get just the directory
69 this->autoMenuMapPath.clear();
70 size_t tmp = cfgMap.find_last_of("\\/\n");
71 if (tmp != std::string::npos)
72 this->autoMenuMapPath = cfgMap.substr(0, tmp);
73 this->autoMenuMapPath += "\\";
74
75 // Iterate files in directory
76 WIN32_FIND_DATAA finder = { 0 };
77 HANDLE hFind = FindFirstFileA(cfgMap.c_str(), &finder);
78
79 if (hFind != INVALID_HANDLE_VALUE)
80 {
81 do
82 {
83 if (!(finder.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) // Check if found is not a directory
84 {
85 // Convert to string and add to autoMapPool if the type is valid
86 std::string finderStr = std::string(finder.cFileName);
87 if (getFileType(this->autoMenuMapPath + finderStr))
88 {
89 this->autoMapPool.push_back(finderStr);

Callers 2

AutoMenuManagerMethod · 0.95
loadAutoMenuDataMethod · 0.80

Calls 11

chooseNewRandomMapMethod · 0.95
InitPrimaryConfigFunction · 0.85
LoadConfigStringUCaseFunction · 0.85
LoadConfigStringFunction · 0.85
getFileTypeFunction · 0.85
trimFunction · 0.85
LoadConfigIntFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
c_strMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected