Skip to content

Commit

Permalink
Core/World: Change worldstate storage to uint32 to fix compile warnin…
Browse files Browse the repository at this point in the history
…gs (its also saved/loaded as uint32 from database)
  • Loading branch information
Shauren committed Aug 19, 2016
1 parent 650ab69 commit 3ab2f69
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 38 deletions.
36 changes: 18 additions & 18 deletions src/server/game/Battlefield/Zones/BattlefieldTB.cpp
Expand Up @@ -79,14 +79,14 @@ bool BattlefieldTB::SetupBattlefield()

// Set timer
m_Timer = sWorld->getWorldState(TB_WS_TIME_NEXT_BATTLE);

// Defending team isn't set yet? Choose randomly.
if (sWorld->getWorldState(TB_WS_FACTION_CONTROLLING) == 0)
sWorld->setWorldState(TB_WS_FACTION_CONTROLLING, uint64(urand(1, 2)));
sWorld->setWorldState(TB_WS_FACTION_CONTROLLING, uint32(urand(1, 2)));

// Set defender team
SetDefenderTeam(TeamId(sWorld->getWorldState(TB_WS_FACTION_CONTROLLING) - 1));

// Just to save world states
SendInitWorldStatesToAll();

Expand All @@ -103,7 +103,7 @@ bool BattlefieldTB::SetupBattlefield()
}
AddCapturePoint(capturePoint);
}

// Spawn towers
for (uint8 i = 0; i < TB_TOWERS_COUNT; i++)
if (GameObject* go = SpawnGameObject(TBTowers[i].entry, TBTowers[i].x, TBTowers[i].y, TBTowers[i].z, TBTowers[i].o))
Expand Down Expand Up @@ -132,7 +132,7 @@ bool BattlefieldTB::SetupBattlefield()
warnedFiveMinutes = false;
warnedTwoMinutes = false;
warnedOneMinute = false;

UpdateNPCsAndGameObjects();

return true;
Expand Down Expand Up @@ -163,7 +163,7 @@ bool BattlefieldTB::Update(uint32 diff)
SendWarning(TB_TEXT_PREPARATIONS_IN_1_MIN);
}
}

if (!updatedNPCAndObjects)
{
if (m_updateObjectsTimer <= diff)
Expand Down Expand Up @@ -299,7 +299,7 @@ void BattlefieldTB::FillInitialWorldStates(WorldPackets::WorldState::InitWorldSt
packet.Worldstates.emplace_back(uint32(TB_WS_BUILDINGS_CAPTURED_SHOW), int32(IsWarTime() ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TB_WS_BUILDINGS_CAPTURED), int32(GetData(BATTLEFIELD_TB_DATA_BUILDINGS_CAPTURED)));
packet.Worldstates.emplace_back(uint32(TB_WS_TOWERS_DESTROYED), int32(0));

packet.Worldstates.emplace_back(uint32(TB_WS_TIME_BATTLE_END_SHOW), int32(IsWarTime() ? 1 : 0));

packet.Worldstates.emplace_back(uint32(TB_WS_STATE_BATTLE), int32(IsWarTime() ? 1 : 0));
Expand Down Expand Up @@ -340,7 +340,7 @@ void BattlefieldTB::FillInitialWorldStates(WorldPackets::WorldState::InitWorldSt
}

packet.Worldstates.emplace_back(uint32(TB_WS_TIME_NEXT_BATTLE_SHOW), int32(!IsWarTime() ? 1 : 0));

packet.Worldstates.emplace_back(uint32(TB_WS_ALLIANCE_CONTROLS_SHOW), int32(!IsWarTime() && GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TB_WS_HORDE_CONTROLS_SHOW), int32(!IsWarTime() && GetDefenderTeam() == TEAM_HORDE ? 1 : 0));

Expand All @@ -352,7 +352,7 @@ void BattlefieldTB::FillInitialWorldStates(WorldPackets::WorldState::InitWorldSt
//packet.Worldstates.emplace_back(uint32(TB_WS_66_UNKNOWN), int32(0));

packet.Worldstates.emplace_back(uint32(TB_WS_KEEP_ALLIANCE), int32(GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TB_WS_KEEP_HORDE), int32(GetDefenderTeam() == TEAM_HORDE ? 1 : 0));
packet.Worldstates.emplace_back(uint32(TB_WS_KEEP_HORDE), int32(GetDefenderTeam() == TEAM_HORDE ? 1 : 0));
}

void BattlefieldTB::SendInitWorldStatesTo(Player* player)
Expand All @@ -370,13 +370,13 @@ void BattlefieldTB::SendInitWorldStatesTo(Player* player)
void BattlefieldTB::SendInitWorldStatesToAll()
{
// Save
sWorld->setWorldState(TB_WS_STATE_BATTLE, uint64(IsWarTime() ? 1 : 0));
sWorld->setWorldState(TB_WS_ALLIANCE_CONTROLS_SHOW, uint64(!IsWarTime() && GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0));
sWorld->setWorldState(TB_WS_HORDE_CONTROLS_SHOW, uint64(!IsWarTime() && GetDefenderTeam() == TEAM_HORDE ? 1 : 0));
sWorld->setWorldState(TB_WS_ALLIANCE_ATTACKING_SHOW, uint64(IsWarTime() && GetAttackerTeam() == TEAM_ALLIANCE ? 1 : 0));
sWorld->setWorldState(TB_WS_HORDE_ATTACKING_SHOW, uint64(IsWarTime() && GetAttackerTeam() == TEAM_HORDE ? 1 : 0));
sWorld->setWorldState(TB_WS_TIME_NEXT_BATTLE, uint64(!IsWarTime() ? m_Timer : 0));
sWorld->setWorldState(TB_WS_TIME_NEXT_BATTLE_SHOW, uint64(!IsWarTime() ? 1 : 0));
sWorld->setWorldState(TB_WS_STATE_BATTLE, uint32(IsWarTime() ? 1 : 0));
sWorld->setWorldState(TB_WS_ALLIANCE_CONTROLS_SHOW, uint32(!IsWarTime() && GetDefenderTeam() == TEAM_ALLIANCE ? 1 : 0));
sWorld->setWorldState(TB_WS_HORDE_CONTROLS_SHOW, uint32(!IsWarTime() && GetDefenderTeam() == TEAM_HORDE ? 1 : 0));
sWorld->setWorldState(TB_WS_ALLIANCE_ATTACKING_SHOW, uint32(IsWarTime() && GetAttackerTeam() == TEAM_ALLIANCE ? 1 : 0));
sWorld->setWorldState(TB_WS_HORDE_ATTACKING_SHOW, uint32(IsWarTime() && GetAttackerTeam() == TEAM_HORDE ? 1 : 0));
sWorld->setWorldState(TB_WS_TIME_NEXT_BATTLE, uint32(!IsWarTime() ? m_Timer : 0));
sWorld->setWorldState(TB_WS_TIME_NEXT_BATTLE_SHOW, uint32(!IsWarTime() ? 1 : 0));

// Tol Barad
for (uint8 team = 0; team < 2; team++)
Expand Down Expand Up @@ -473,7 +473,7 @@ void BattlefieldTB::UpdateNPCsAndGameObjects()
if (GameObject* gameobject = GetGameObject(guid))
gameobject->Delete();
TemporaryGOs.clear();

// Tol Barad gates - closed during warmup
if (GameObject* gates = GetGameObject(TBGatesGUID))
gates->SetGoState(GetState() == BATTLEFIELD_WARMUP ? GO_STATE_READY : GO_STATE_ACTIVE);
Expand Down Expand Up @@ -533,7 +533,7 @@ void BattlefieldTB::UpdateNPCsAndGameObjects()
if (Creature* creature = SpawnCreature(entry, TBQuestInfantrySpawnData[i], GetDefenderTeam()))
TemporaryNPCs.insert(creature->GetGUID());
}

for (uint8 i = 0; i < TB_GUARDS_MAX; i++)
if (Creature* creature = SpawnCreature(GetDefenderTeam() == TEAM_ALLIANCE ? NPC_BARADIN_GUARD : NPC_HELLSCREAMS_SENTRY, GuardNPCSpawns[i], GetDefenderTeam()))
TemporaryNPCs.insert(creature->GetGUID());
Expand Down
4 changes: 2 additions & 2 deletions src/server/game/Battlefield/Zones/BattlefieldWG.cpp
Expand Up @@ -80,8 +80,8 @@ bool BattlefieldWG::SetupBattlefield()
if ((sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) == 0) && (sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER) == 0)
&& (sWorld->getWorldState(ClockWorldState[0]) == 0))
{
sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, uint64(false));
sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER, uint64(urand(0, 1)));
sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, 0);
sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER, urand(0, 1));
sWorld->setWorldState(ClockWorldState[0], uint64(m_NoWarBattleTime));
}

Expand Down
10 changes: 5 additions & 5 deletions src/server/game/Entities/Player/Player.cpp
Expand Up @@ -9120,11 +9120,11 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid)
case 5389:
if (sWorld->getBoolConfig(CONFIG_TOLBARAD_ENABLE))
{
packet.Worldstates.emplace_back(5385, sWorld->getWorldState(5385)); // TB_WS_ALLIANCE_CONTROLS_SHOW
packet.Worldstates.emplace_back(5384, sWorld->getWorldState(5384)); // TB_WS_HORDE_CONTROLS_SHOW
packet.Worldstates.emplace_back(5387, sWorld->getWorldState(5387)); // TB_WS_TIME_NEXT_BATTLE_SHOW
packet.Worldstates.emplace_back(5546, sWorld->getWorldState(5546)); // TB_WS_ALLIANCE_ATTACKING_SHOW
packet.Worldstates.emplace_back(5547, sWorld->getWorldState(5547)); // TB_WS_HORDE_ATTACKING_SHOW
packet.Worldstates.emplace_back(5385u, sWorld->getWorldState(5385)); // TB_WS_ALLIANCE_CONTROLS_SHOW
packet.Worldstates.emplace_back(5384u, sWorld->getWorldState(5384)); // TB_WS_HORDE_CONTROLS_SHOW
packet.Worldstates.emplace_back(5387u, sWorld->getWorldState(5387)); // TB_WS_TIME_NEXT_BATTLE_SHOW
packet.Worldstates.emplace_back(5546u, sWorld->getWorldState(5546)); // TB_WS_ALLIANCE_ATTACKING_SHOW
packet.Worldstates.emplace_back(5547u, sWorld->getWorldState(5547)); // TB_WS_HORDE_ATTACKING_SHOW
}
break;
// Tol Barad
Expand Down
20 changes: 10 additions & 10 deletions src/server/game/World/World.cpp
Expand Up @@ -3167,7 +3167,7 @@ void World::InitRandomBGResetTime()
m_NextRandomBGReset = bgtime < curTime ? nextDayResetTime - DAY : nextDayResetTime;

if (!bgtime)
sWorld->setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset));
sWorld->setWorldState(WS_BG_DAILY_RESET_TIME, uint32(m_NextRandomBGReset));
}

void World::InitGuildResetTime()
Expand Down Expand Up @@ -3195,7 +3195,7 @@ void World::InitGuildResetTime()
m_NextGuildReset = gtime < curTime ? nextDayResetTime - DAY : nextDayResetTime;

if (!gtime)
sWorld->setWorldState(WS_GUILD_DAILY_RESET_TIME, uint64(m_NextGuildReset));
sWorld->setWorldState(WS_GUILD_DAILY_RESET_TIME, uint32(m_NextGuildReset));
}

void World::InitCurrencyResetTime()
Expand Down Expand Up @@ -3225,7 +3225,7 @@ void World::InitCurrencyResetTime()
m_NextCurrencyReset = currencytime < curTime ? nextWeekResetTime - getIntConfig(CONFIG_CURRENCY_RESET_INTERVAL) * DAY : nextWeekResetTime;

if (!currencytime)
sWorld->setWorldState(WS_CURRENCY_RESET_TIME, uint64(m_NextCurrencyReset));
sWorld->setWorldState(WS_CURRENCY_RESET_TIME, uint32(m_NextCurrencyReset));
}

void World::DailyReset()
Expand Down Expand Up @@ -3256,7 +3256,7 @@ void World::ResetCurrencyWeekCap()
itr->second->GetPlayer()->ResetCurrencyWeekCap();

m_NextCurrencyReset = time_t(m_NextCurrencyReset + DAY * getIntConfig(CONFIG_CURRENCY_RESET_INTERVAL));
sWorld->setWorldState(WS_CURRENCY_RESET_TIME, uint64(m_NextCurrencyReset));
sWorld->setWorldState(WS_CURRENCY_RESET_TIME, uint32(m_NextCurrencyReset));
}

void World::LoadDBAllowedSecurityLevel()
Expand Down Expand Up @@ -3290,7 +3290,7 @@ void World::ResetWeeklyQuests()
itr->second->GetPlayer()->ResetWeeklyQuestStatus();

m_NextWeeklyQuestReset = time_t(m_NextWeeklyQuestReset + WEEK);
sWorld->setWorldState(WS_WEEKLY_QUEST_RESET_TIME, uint64(m_NextWeeklyQuestReset));
sWorld->setWorldState(WS_WEEKLY_QUEST_RESET_TIME, uint32(m_NextWeeklyQuestReset));

// change available weeklies
sPoolMgr->ChangeWeeklyQuests();
Expand Down Expand Up @@ -3337,7 +3337,7 @@ void World::ResetMonthlyQuests()
// plan next reset time
m_NextMonthlyQuestReset = (curTime >= nextMonthResetTime) ? nextMonthResetTime + MONTH : nextMonthResetTime;

sWorld->setWorldState(WS_MONTHLY_QUEST_RESET_TIME, uint64(m_NextMonthlyQuestReset));
sWorld->setWorldState(WS_MONTHLY_QUEST_RESET_TIME, uint32(m_NextMonthlyQuestReset));
}

void World::ResetEventSeasonalQuests(uint16 event_id)
Expand Down Expand Up @@ -3365,13 +3365,13 @@ void World::ResetRandomBG()
itr->second->GetPlayer()->SetRandomWinner(false);

m_NextRandomBGReset = time_t(m_NextRandomBGReset + DAY);
sWorld->setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset));
sWorld->setWorldState(WS_BG_DAILY_RESET_TIME, uint32(m_NextRandomBGReset));
}

void World::ResetGuildCap()
{
m_NextGuildReset = time_t(m_NextGuildReset + DAY);
sWorld->setWorldState(WS_GUILD_DAILY_RESET_TIME, uint64(m_NextGuildReset));
sWorld->setWorldState(WS_GUILD_DAILY_RESET_TIME, uint32(m_NextGuildReset));
uint32 week = getWorldState(WS_GUILD_WEEKLY_RESET_TIME);
week = week < 7 ? week + 1 : 1;

Expand Down Expand Up @@ -3441,7 +3441,7 @@ void World::LoadWorldStates()
}

// Setting a worldstate will save it to DB
void World::setWorldState(uint32 index, uint64 value)
void World::setWorldState(uint32 index, uint32 value)
{
WorldStatesMap::const_iterator it = m_worldstates.find(index);
if (it != m_worldstates.end())
Expand All @@ -3465,7 +3465,7 @@ void World::setWorldState(uint32 index, uint64 value)
m_worldstates[index] = value;
}

uint64 World::getWorldState(uint32 index) const
uint32 World::getWorldState(uint32 index) const
{
WorldStatesMap::const_iterator it = m_worldstates.find(index);
return it != m_worldstates.end() ? it->second : 0;
Expand Down
6 changes: 3 additions & 3 deletions src/server/game/World/World.h
Expand Up @@ -736,8 +736,8 @@ class TC_GAME_API World
return index < INT_CONFIG_VALUE_COUNT ? m_int_configs[index] : 0;
}

void setWorldState(uint32 index, uint64 value);
uint64 getWorldState(uint32 index) const;
void setWorldState(uint32 index, uint32 value);
uint32 getWorldState(uint32 index) const;
void LoadWorldStates();

/// Are we on a "Player versus Player" server?
Expand Down Expand Up @@ -851,7 +851,7 @@ class TC_GAME_API World
uint32 m_int_configs[INT_CONFIG_VALUE_COUNT];
bool m_bool_configs[BOOL_CONFIG_VALUE_COUNT];
float m_float_configs[FLOAT_CONFIG_VALUE_COUNT];
typedef std::map<uint32, uint64> WorldStatesMap;
typedef std::map<uint32, uint32> WorldStatesMap;
WorldStatesMap m_worldstates;
uint32 m_playerLimit;
AccountTypes m_allowedSecurityLevel;
Expand Down

0 comments on commit 3ab2f69

Please sign in to comment.