Skip to content

Commit

Permalink
[9324] Fix some gcc warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDereka committed Feb 7, 2010
1 parent defd3a9 commit f17929c
Show file tree
Hide file tree
Showing 27 changed files with 100 additions and 101 deletions.
6 changes: 3 additions & 3 deletions src/game/AccountMgr.cpp
Expand Up @@ -156,17 +156,17 @@ uint32 AccountMgr::GetId(std::string username)
}
}

uint32 AccountMgr::GetSecurity(uint32 acc_id)
AccountTypes AccountMgr::GetSecurity(uint32 acc_id)
{
QueryResult *result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE id = '%u'", acc_id);
if(result)
{
uint32 sec = (*result)[0].GetUInt32();
AccountTypes sec = AccountTypes((*result)[0].GetInt32());
delete result;
return sec;
}

return 0;
return SEC_PLAYER;
}

bool AccountMgr::GetName(uint32 acc_id, std::string &name)
Expand Down
2 changes: 1 addition & 1 deletion src/game/AccountMgr.h
Expand Up @@ -48,7 +48,7 @@ class AccountMgr
bool CheckPassword(uint32 accid, std::string passwd);

uint32 GetId(std::string username);
uint32 GetSecurity(uint32 acc_id);
AccountTypes GetSecurity(uint32 acc_id);
bool GetName(uint32 acc_id, std::string &name);
std::string CalculateShaPassHash(std::string& name, std::string& password);

Expand Down
4 changes: 2 additions & 2 deletions src/game/Chat.cpp
Expand Up @@ -729,7 +729,7 @@ bool ChatHandler::HasLowerSecurity(Player* target, uint64 guid, bool strong)

bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_account, bool strong)
{
uint32 target_sec;
AccountTypes target_sec;

// allow everything from console and RA console
if (!m_session)
Expand All @@ -746,7 +746,7 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac
else
return true; // caller must report error for (target==NULL && target_account==0)

if (m_session->GetSecurity() < target_sec || (strong && (uint32)m_session->GetSecurity() <= target_sec))
if (m_session->GetSecurity() < target_sec || (strong && m_session->GetSecurity() <= target_sec))
{
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
SetSentErrorMessage(true);
Expand Down
37 changes: 21 additions & 16 deletions src/game/GossipDef.cpp
Expand Up @@ -391,32 +391,37 @@ void PlayerMenu::SendQuestGiverQuestList( QEmote eEmote, const std::string& Titl
data << Title;
data << uint32(eEmote._Delay ); // player emote
data << uint32(eEmote._Emote ); // NPC emote
data << uint8 ( mQuestMenu.MenuItemCount() );

for (uint32 iI = 0; iI < mQuestMenu.MenuItemCount(); ++iI )
size_t count_pos = data.wpos();
data << uint8 ( mQuestMenu.MenuItemCount() );
uint32 count = 0;
for (; count < mQuestMenu.MenuItemCount(); ++count )
{
QuestMenuItem const& qmi = mQuestMenu.GetItem(iI);
QuestMenuItem const& qmi = mQuestMenu.GetItem(count);

uint32 questID = qmi.m_qId;
Quest const *pQuest = sObjectMgr.GetQuestTemplate(questID);

std::string title = pQuest ? pQuest->GetTitle() : "";

int loc_idx = pSession->GetSessionDbLocaleIndex();
if (loc_idx >= 0)
if(pQuest)
{
if(QuestLocale const *ql = sObjectMgr.GetQuestLocale(questID))
std::string title = pQuest->GetTitle();

int loc_idx = pSession->GetSessionDbLocaleIndex();
if (loc_idx >= 0)
{
if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty())
title=ql->Title[loc_idx];
if(QuestLocale const *ql = sObjectMgr.GetQuestLocale(questID))
{
if (ql->Title.size() > (size_t)loc_idx && !ql->Title[loc_idx].empty())
title=ql->Title[loc_idx];
}
}
}

data << uint32(questID);
data << uint32(qmi.m_qIcon);
data << int32(pQuest->GetQuestLevel());
data << title;
data << uint32(questID);
data << uint32(qmi.m_qIcon);
data << int32(pQuest->GetQuestLevel());
data << title;
}
}
data.put<uint8>(count_pos,count);
pSession->SendPacket( &data );
sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID));
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/GridNotifiers.h
Expand Up @@ -595,7 +595,7 @@ namespace MaNGOS
if(go->GetGOInfo()->spellFocus.focusId != i_focusId)
return false;

float dist = go->GetGOInfo()->spellFocus.dist;
float dist = (float)go->GetGOInfo()->spellFocus.dist;

return go->IsWithinDistInMap(i_unit, dist);
}
Expand All @@ -611,7 +611,7 @@ namespace MaNGOS
NearestGameObjectFishingHole(WorldObject const& obj, float range) : i_obj(obj), i_range(range) {}
bool operator()(GameObject* go)
{
if(go->GetGOInfo()->type == GAMEOBJECT_TYPE_FISHINGHOLE && go->isSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, go->GetGOInfo()->fishinghole.radius))
if(go->GetGOInfo()->type == GAMEOBJECT_TYPE_FISHINGHOLE && go->isSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, (float)go->GetGOInfo()->fishinghole.radius))
{
i_range = i_obj.GetDistance(go);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/game/Group.cpp
Expand Up @@ -843,7 +843,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, uint32 NumberOfPlayers)
uint8 maxresul = 0;
uint64 maxguid = (*roll->playerVote.begin()).first;
Player *player;
RollVote rollvote;
RollVote rollvote = PASS; //Fixed: Using uninitialized memory 'rollvote'

Roll::PlayerVote::iterator itr;
for (itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Level0.cpp
Expand Up @@ -158,7 +158,7 @@ bool ChatHandler::HandleGMListIngameCommand(const char* /*args*/)
for(; itr != m.end(); ++itr)
{
AccountTypes itr_sec = itr->second->GetSession()->GetSecurity();
if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= sWorld.getConfig(CONFIG_GM_LEVEL_IN_GM_LIST))) &&
if ((itr->second->isGameMaster() || (itr_sec > SEC_PLAYER && itr_sec <= (AccountTypes)sWorld.getConfig(CONFIG_GM_LEVEL_IN_GM_LIST))) &&
(!m_session || itr->second->IsVisibleGloballyFor(m_session->GetPlayer())))
{
if(first)
Expand Down
6 changes: 3 additions & 3 deletions src/game/Level2.cpp
Expand Up @@ -2159,15 +2159,15 @@ bool ChatHandler::HandlePInfoCommand(const char* args)

std::string username = GetMangosString(LANG_ERROR);
std::string last_ip = GetMangosString(LANG_ERROR);
uint32 security = 0;
AccountTypes security = SEC_PLAYER;
std::string last_login = GetMangosString(LANG_ERROR);

QueryResult* result = loginDatabase.PQuery("SELECT username,gmlevel,last_ip,last_login FROM account WHERE id = '%u'",accId);
if(result)
{
Field* fields = result->Fetch();
username = fields[0].GetCppString();
security = fields[1].GetUInt32();
security = (AccountTypes)fields[1].GetUInt32();

if(!m_session || m_session->GetSecurity() >= security)
{
Expand Down Expand Up @@ -3681,7 +3681,7 @@ bool ChatHandler::HandleHonorAddCommand(const char* args)
if (HasLowerSecurity(target, 0))
return false;

uint32 amount = (uint32)atoi(args);
float amount = (float)atof(args);
target->RewardHonor(NULL, 1, amount);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/Level3.cpp
Expand Up @@ -5550,7 +5550,7 @@ bool ChatHandler::HandlePDumpWriteCommand(const char *args)
return false;
}

guid = sObjectMgr.GetPlayerGUIDByName(name);
guid = GUID_LOPART(sObjectMgr.GetPlayerGUIDByName(name));
}

if(!sObjectMgr.GetPlayerAccountIdByGUID(guid))
Expand Down
2 changes: 1 addition & 1 deletion src/game/LootHandler.cpp
Expand Up @@ -350,7 +350,7 @@ void WorldSession::DoLootRelease( uint64 lguid )
else if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE)
{ // The fishing hole used once more
go->AddUse(); // if the max usage is reached, will be despawned in next tick
if (go->GetUseCount() >= irand(go->GetGOInfo()->fishinghole.minSuccessOpens,go->GetGOInfo()->fishinghole.maxSuccessOpens))
if (go->GetUseCount() >= urand(go->GetGOInfo()->fishinghole.minSuccessOpens,go->GetGOInfo()->fishinghole.maxSuccessOpens))
{
go->SetLootState(GO_JUST_DEACTIVATED);
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/Map.cpp
Expand Up @@ -1584,7 +1584,7 @@ float GridMap::getLiquidLevel(float x, float y)
uint8 GridMap::getTerrainType(float x, float y)
{
if (!m_liquid_type)
return m_liquidType;
return (uint8)m_liquidType;

x = 16 * (32 - x/SIZE_OF_GRIDS);
y = 16 * (32 - y/SIZE_OF_GRIDS);
Expand Down
4 changes: 2 additions & 2 deletions src/game/MiscHandler.cpp
Expand Up @@ -280,7 +280,7 @@ void WorldSession::HandleLogoutRequestOpcode( WorldPacket & /*recv_data*/ )

//instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in mangosd.conf
if (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || GetPlayer()->isInFlight() ||
GetSecurity() >= sWorld.getConfig(CONFIG_INSTANT_LOGOUT))
GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_INSTANT_LOGOUT))
{
LogoutPlayer(true);
return;
Expand Down Expand Up @@ -588,7 +588,7 @@ void WorldSession::HandleSetContactNotesOpcode( WorldPacket & recv_data )
uint64 guid;
std::string note;
recv_data >> guid >> note;
_player->GetSocial()->SetFriendNote(guid, note);
_player->GetSocial()->SetFriendNote(GUID_LOPART(guid), note);
}

void WorldSession::HandleBugOpcode( WorldPacket & recv_data )
Expand Down
3 changes: 2 additions & 1 deletion src/game/NPCHandler.cpp
Expand Up @@ -743,7 +743,6 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);

WorldPacket data(SMSG_STABLE_RESULT, 200); // guess size

Pet* pet = _player->GetPet();

Expand Down Expand Up @@ -782,6 +781,8 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
// move alive pet to slot or delete dead pet
_player->RemovePet(pet,pet->isAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED);

WorldPacket data(SMSG_STABLE_RESULT, 1); // guess size

// summon unstabled pet
Pet *newpet = new Pet;
if(!newpet->LoadPetFromDB(_player,creature_id,pet_number))
Expand Down
2 changes: 1 addition & 1 deletion src/game/ObjectAccessor.cpp
Expand Up @@ -189,7 +189,7 @@ ObjectAccessor::RemoveCorpse(Corpse *corpse)
CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;

sObjectMgr.DeleteCorpseCellData(corpse->GetMapId(), cell_id, corpse->GetOwnerGUID());
sObjectMgr.DeleteCorpseCellData(corpse->GetMapId(), cell_id, GUID_LOPART(corpse->GetOwnerGUID()));
corpse->RemoveFromWorld();

i_player2corpse.erase(iter);
Expand Down
8 changes: 4 additions & 4 deletions src/game/Pet.cpp
Expand Up @@ -519,8 +519,8 @@ void Pet::Update(uint32 diff)

if(m_duration > 0)
{
if(m_duration > diff)
m_duration -= diff;
if(m_duration > (int32)diff)
m_duration -= (int32)diff;
else
{
Remove(getPetType() != SUMMON_PET ? PET_SAVE_AS_DELETED:PET_SAVE_NOT_IN_SLOT);
Expand Down Expand Up @@ -1184,7 +1184,7 @@ void Pet::_LoadAuras(uint32 timediff)
// prevent wrong values of remaincharges
if(spellproto->procCharges)
{
if(remaincharges <= 0 || remaincharges > spellproto->procCharges)
if(remaincharges <= 0 || remaincharges > (int32)spellproto->procCharges)
remaincharges = spellproto->procCharges;
}
else
Expand Down Expand Up @@ -1774,7 +1774,7 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)

PetSpellMap::iterator itr = m_spells.find(spellid);

int i;
uint32 i;

if(apply)
{
Expand Down
6 changes: 3 additions & 3 deletions src/game/PetitionsHandler.cpp
Expand Up @@ -265,7 +265,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)

// result==NULL also correct in case no sign yet
if(result)
signs = result->GetRowCount();
signs = (uint8)result->GetRowCount();

sLog.outDebug("CMSG_PETITION_SHOW_SIGNATURES petition entry: '%u'", petitionguid_low);

Expand Down Expand Up @@ -674,7 +674,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
// result==NULL also correct charter without signs
if(result)
signs = result->GetRowCount();
signs = (uint8)result->GetRowCount();

WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8+8+4+signs+signs*12));
data << petitionguid; // petition guid
Expand Down Expand Up @@ -762,7 +762,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
uint8 signs;
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
if(result)
signs = result->GetRowCount();
signs = (uint8)result->GetRowCount();
else
signs = 0;

Expand Down

0 comments on commit f17929c

Please sign in to comment.