mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[6892] Some small code clean ups and optimisations.
Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
parent
9f8e51ff41
commit
2e2055c469
5 changed files with 19 additions and 70 deletions
|
|
@ -209,7 +209,7 @@ void Channel::KickOrBan(uint64 good, const char *badname, bool ban)
|
||||||
|
|
||||||
if(ban && !IsBanned(bad->GetGUID()))
|
if(ban && !IsBanned(bad->GetGUID()))
|
||||||
{
|
{
|
||||||
banned.push_back(bad->GetGUID());
|
banned.insert(bad->GetGUID());
|
||||||
MakePlayerBanned(&data, bad->GetGUID(), good);
|
MakePlayerBanned(&data, bad->GetGUID(), good);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -258,7 +258,7 @@ void Channel::UnBan(uint64 good, const char *badname)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
banned.remove(bad->GetGUID());
|
banned.erase(bad->GetGUID());
|
||||||
|
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
MakePlayerUnbanned(&data, bad->GetGUID(), good);
|
MakePlayerUnbanned(&data, bad->GetGUID(), good);
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ class Channel
|
||||||
|
|
||||||
typedef std::map<uint64, PlayerInfo> PlayerList;
|
typedef std::map<uint64, PlayerInfo> PlayerList;
|
||||||
PlayerList players;
|
PlayerList players;
|
||||||
typedef std::list<uint64> BannedList;
|
typedef std::set<uint64> BannedList;
|
||||||
BannedList banned;
|
BannedList banned;
|
||||||
bool m_announce;
|
bool m_announce;
|
||||||
bool m_moderate;
|
bool m_moderate;
|
||||||
|
|
@ -202,15 +202,9 @@ class Channel
|
||||||
void SendToAllButOne(WorldPacket *data, uint64 who);
|
void SendToAllButOne(WorldPacket *data, uint64 who);
|
||||||
void SendToOne(WorldPacket *data, uint64 who);
|
void SendToOne(WorldPacket *data, uint64 who);
|
||||||
|
|
||||||
bool IsOn(uint64 who) const { return players.count(who) > 0; }
|
bool IsOn(uint64 who) const { return players.count(who) != 0; }
|
||||||
|
|
||||||
bool IsBanned(const uint64 guid) const
|
bool IsBanned(const uint64 guid) const {return banned.count(guid) != 0; }
|
||||||
{
|
|
||||||
for(BannedList::const_iterator i = banned.begin(); i != banned.end(); ++i)
|
|
||||||
if(*i == guid)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsFirst() const { return !(players.size() > 1); }
|
bool IsFirst() const { return !(players.size() > 1); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -904,12 +904,19 @@ void WorldSession::HandleChangePlayerNameOpcode(WorldPacket& recv_data)
|
||||||
recv_data >> guid;
|
recv_data >> guid;
|
||||||
recv_data >> newname;
|
recv_data >> newname;
|
||||||
|
|
||||||
QueryResult *result = CharacterDatabase.PQuery("SELECT at_login FROM characters WHERE guid ='%u'", GUID_LOPART(guid));
|
QueryResult *result = CharacterDatabase.PQuery("SELECT at_login, name FROM characters WHERE guid ='%u'", GUID_LOPART(guid));
|
||||||
if (result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
WorldPacket data(SMSG_CHAR_RENAME, 1);
|
||||||
|
data << (uint8)CHAR_CREATE_ERROR;
|
||||||
|
SendPacket( &data );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 at_loginFlags;
|
uint32 at_loginFlags;
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
at_loginFlags = fields[0].GetUInt32();
|
at_loginFlags = fields[0].GetUInt32();
|
||||||
|
oldname = fields[1].GetCppString();
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
if (!(at_loginFlags & AT_LOGIN_RENAME))
|
if (!(at_loginFlags & AT_LOGIN_RENAME))
|
||||||
|
|
@ -919,22 +926,6 @@ void WorldSession::HandleChangePlayerNameOpcode(WorldPacket& recv_data)
|
||||||
SendPacket( &data );
|
SendPacket( &data );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WorldPacket data(SMSG_CHAR_RENAME, 1);
|
|
||||||
data << (uint8)CHAR_CREATE_ERROR;
|
|
||||||
SendPacket( &data );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!objmgr.GetPlayerNameByGUID(guid, oldname)) // character not exist, because we have no name for this guid
|
|
||||||
{
|
|
||||||
WorldPacket data(SMSG_CHAR_RENAME, 1);
|
|
||||||
data << (uint8)CHAR_LOGIN_NO_CHARACTER;
|
|
||||||
SendPacket( &data );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// prevent character rename to invalid name
|
// prevent character rename to invalid name
|
||||||
if(!normalizePlayerName(newname))
|
if(!normalizePlayerName(newname))
|
||||||
|
|
|
||||||
|
|
@ -926,44 +926,7 @@ void Creature::OnPoiSelect(Player* player, GossipOption const *gossip)
|
||||||
{
|
{
|
||||||
if(gossip->GossipId==GOSSIP_GUARD_SPELLTRAINER || gossip->GossipId==GOSSIP_GUARD_SKILLTRAINER)
|
if(gossip->GossipId==GOSSIP_GUARD_SPELLTRAINER || gossip->GossipId==GOSSIP_GUARD_SKILLTRAINER)
|
||||||
{
|
{
|
||||||
//float x,y;
|
|
||||||
//bool findnpc=false;
|
|
||||||
Poi_Icon icon = ICON_POI_0;
|
Poi_Icon icon = ICON_POI_0;
|
||||||
//QueryResult *result;
|
|
||||||
//Field *fields;
|
|
||||||
uint32 mapid=GetMapId();
|
|
||||||
Map const* map=MapManager::Instance().GetBaseMap( mapid );
|
|
||||||
uint16 areaflag=map->GetAreaFlag(GetPositionX(),GetPositionY());
|
|
||||||
uint32 zoneid=Map::GetZoneId(areaflag,mapid);
|
|
||||||
std::string areaname= gossip->OptionText;
|
|
||||||
/*
|
|
||||||
uint16 pflag;
|
|
||||||
|
|
||||||
// use the action relate to creaturetemplate.trainer_type ?
|
|
||||||
result= WorldDatabase.PQuery("SELECT creature.position_x,creature.position_y FROM creature,creature_template WHERE creature.map = '%u' AND creature.id = creature_template.entry AND creature_template.trainer_type = '%u'", mapid, gossip->Action );
|
|
||||||
if(!result)
|
|
||||||
return;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
fields = result->Fetch();
|
|
||||||
x=fields[0].GetFloat();
|
|
||||||
y=fields[1].GetFloat();
|
|
||||||
pflag=map->GetAreaFlag(GetPositionX(),GetPositionY());
|
|
||||||
if(pflag==areaflag)
|
|
||||||
{
|
|
||||||
findnpc=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}while(result->NextRow());
|
|
||||||
|
|
||||||
delete result;
|
|
||||||
|
|
||||||
if(!findnpc)
|
|
||||||
{
|
|
||||||
player->PlayerTalkClass->SendTalking( "$NSorry", "Here no this person.");
|
|
||||||
return;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//need add more case.
|
//need add more case.
|
||||||
switch(gossip->Action)
|
switch(gossip->Action)
|
||||||
{
|
{
|
||||||
|
|
@ -980,8 +943,9 @@ void Creature::OnPoiSelect(Player* player, GossipOption const *gossip)
|
||||||
icon=ICON_POI_TOWER;
|
icon=ICON_POI_TOWER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint32 textid=GetGossipTextId( gossip->Action, zoneid );
|
uint32 textid = GetGossipTextId( gossip->Action, GetZoneId() );
|
||||||
player->PlayerTalkClass->SendTalking(textid);
|
player->PlayerTalkClass->SendTalking(textid);
|
||||||
|
// std::string areaname= gossip->OptionText;
|
||||||
// how this could worked player->PlayerTalkClass->SendPointOfInterest( x, y, icon, 2, 15, areaname.c_str() );
|
// how this could worked player->PlayerTalkClass->SendPointOfInterest( x, y, icon, 2, 15, areaname.c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "6891"
|
#define REVISION_NR "6892"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue