77#include " Chat.h"
88#include " Message.h"
99
10- void AutoBalance_AllMapScript::OnCreateMap (Map* map)
11- {
12- LOG_DEBUG (" module.AutoBalance" , " AutoBalance_AllMapScript::OnCreateMap(): Map {} ({}{})" ,
13- map->GetMapName (),
14- map->GetId (),
15- map->GetInstanceId () ? " -" + std::to_string (map->GetInstanceId ()) : " "
16- );
17-
18- // clear out any previously-recorded data
19- map->CustomData .Erase (" AutoBalanceMapInfo" );
20-
21- AutoBalanceMapInfo* mapABInfo = map->CustomData .GetDefault <AutoBalanceMapInfo>(" AutoBalanceMapInfo" );
22-
23- if (map->IsDungeon ())
24- {
25- // get the map's LFG stats even if not enabled
26- LFGDungeonEntry const * dungeon = GetLFGDungeon (map->GetId (), map->GetDifficulty ());
27- if (dungeon) {
28- mapABInfo->lfgMinLevel = dungeon->MinLevel ;
29- mapABInfo->lfgMaxLevel = dungeon->MaxLevel ;
30- mapABInfo->lfgTargetLevel = dungeon->TargetLevel ;
31- }
32- // if this is a heroic dungeon that isn't in LFG, get the stats from the non-heroic version
33- else if (map->IsHeroic ())
34- {
35- LFGDungeonEntry const * nonHeroicDungeon = nullptr ;
36- if (map->GetDifficulty () == DUNGEON_DIFFICULTY_HEROIC)
37- nonHeroicDungeon = GetLFGDungeon (map->GetId (), DUNGEON_DIFFICULTY_NORMAL);
38- else if (map->GetDifficulty () == RAID_DIFFICULTY_10MAN_HEROIC)
39- nonHeroicDungeon = GetLFGDungeon (map->GetId (), RAID_DIFFICULTY_10MAN_NORMAL);
40- else if (map->GetDifficulty () == RAID_DIFFICULTY_25MAN_HEROIC)
41- nonHeroicDungeon = GetLFGDungeon (map->GetId (), RAID_DIFFICULTY_25MAN_NORMAL);
42-
43- LOG_DEBUG (" module.AutoBalance" , " AutoBalance_AllMapScript::OnCreateMap(): Map {} ({}{}) | is a Heroic dungeon that is not in LFG. Using non-heroic LFG levels." ,
44- map->GetMapName (),
45- map->GetId (),
46- map->GetInstanceId () ? " -" + std::to_string (map->GetInstanceId ()) : " "
47- );
48-
49- if (nonHeroicDungeon)
50- {
51- mapABInfo->lfgMinLevel = nonHeroicDungeon->MinLevel ;
52- mapABInfo->lfgMaxLevel = nonHeroicDungeon->MaxLevel ;
53- mapABInfo->lfgTargetLevel = nonHeroicDungeon->TargetLevel ;
54- }
55- else
56- {
57- LOG_ERROR (" module.AutoBalance" , " AutoBalance_AllMapScript::OnCreateMap(): Map {} ({}{}) | Could not determine LFG level ranges for this map. Level will bet set to 0." ,
58- map->GetMapName (),
59- map->GetId (),
60- map->GetInstanceId () ? " -" + std::to_string (map->GetInstanceId ()) : " "
61- );
62- }
63- }
64-
65- if (map->GetInstanceId ())
66- {
67- LOG_DEBUG (" module.AutoBalance" , " AutoBalance_AllMapScript::OnCreateMap(): Map {} ({}{}) | is an instance of a map. Loading initial map data." ,
68- map->GetMapName (),
69- map->GetId (),
70- map->GetInstanceId () ? " -" + std::to_string (map->GetInstanceId ()) : " "
71- );
72- UpdateMapDataIfNeeded (map);
73-
74- // provide a concise summary of the map data we collected
75- LOG_DEBUG (" module.AutoBalance" , " AutoBalance_AllMapScript::OnCreateMap(): Map {} ({}{}) | LFG levels ({}-{}) (target {}). {} for AutoBalancing." ,
76- map->GetMapName (),
77- map->GetId (),
78- map->GetInstanceId () ? " -" + std::to_string (map->GetInstanceId ()) : " " ,
79- mapABInfo->lfgMinLevel ? std::to_string (mapABInfo->lfgMinLevel ) : " ?" ,
80- mapABInfo->lfgMaxLevel ? std::to_string (mapABInfo->lfgMaxLevel ) : " ?" ,
81- mapABInfo->lfgTargetLevel ? std::to_string (mapABInfo->lfgTargetLevel ) : " ?" ,
82- mapABInfo->enabled ? " Enabled" : " Disabled"
83- );
84- }
85- else
86- {
87- LOG_DEBUG (
88- " module.AutoBalance" , " AutoBalance_AllMapScript::OnCreateMap(): Map {} ({}) | is an instance base map." ,
89- map->GetMapName (),
90- map->GetId ()
91- );
92- }
93- }
94- }
9510
9611void AutoBalance_AllMapScript::OnPlayerEnterAll (Map* map, Player* player)
9712{
@@ -112,7 +27,7 @@ void AutoBalance_AllMapScript::OnPlayerEnterAll(Map* map, Player* player)
11227 );
11328
11429 // get the map's info
115- AutoBalanceMapInfo* mapABInfo = map-> CustomData . GetDefault <AutoBalanceMapInfo>( " AutoBalanceMapInfo " );
30+ AutoBalanceMapInfo* mapABInfo = GetMapInfo (map );
11631
11732 // store the previous difficulty for comparison later
11833 int prevAdjustedPlayerCount = mapABInfo->adjustedPlayerCount ;
@@ -218,7 +133,7 @@ void AutoBalance_AllMapScript::OnPlayerLeaveAll(Map* map, Player* player)
218133 );
219134
220135 // get the map's info
221- AutoBalanceMapInfo* mapABInfo = map-> CustomData . GetDefault <AutoBalanceMapInfo>( " AutoBalanceMapInfo " );
136+ AutoBalanceMapInfo* mapABInfo = GetMapInfo (map );
222137
223138 // store the previous difficulty for comparison later
224139 int prevAdjustedPlayerCount = mapABInfo->adjustedPlayerCount ;
0 commit comments