* use databases instead of hardcoded values for language,map,zone,race,class names
This commit is contained in:
parent
1ea085ae7b
commit
96610d36c6
@ -64,7 +64,7 @@ name=Emerald Forest
|
||||
name=Scarlet Monastery Instance
|
||||
|
||||
[209]
|
||||
name=Zul\'Farrak Instance
|
||||
name=Zul'Farrak Instance
|
||||
|
||||
[229]
|
||||
name=Blackrock Spire Instance
|
||||
@ -73,7 +73,7 @@ name=Blackrock Spire Instance
|
||||
name=Blackrock Depths Instance
|
||||
|
||||
[249]
|
||||
name=Onyxia\'s Lair Instance
|
||||
name=Onyxia's Lair Instance
|
||||
|
||||
[269]
|
||||
name=Caverns of Time
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
#include "common.h"
|
||||
#include "SCPDatabase.h"
|
||||
|
||||
// for helper functions
|
||||
#include "NameTables.h"
|
||||
|
||||
uint32 SCPDatabase::LoadFromFile(char *fn)
|
||||
{
|
||||
@ -94,3 +96,44 @@ SCPDatabase& SCPDatabaseMgr::GetDB(std::string n)
|
||||
{
|
||||
return _map[n];
|
||||
}
|
||||
|
||||
// -- helper functions -- //
|
||||
|
||||
std::string SCPDatabaseMgr::GetZoneName(uint32 id)
|
||||
{
|
||||
return GetDB("zone").GetField(id).GetString("name");
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetRaceName(uint32 id)
|
||||
{
|
||||
std::string r = GetDB("race").GetField(id).GetString("name");
|
||||
if(r.empty())
|
||||
r = raceName[id];
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetMapName(uint32 id)
|
||||
{
|
||||
return GetDB("map").GetField(id).GetString("name");
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetClassName_(uint32 id)
|
||||
{
|
||||
std::string r = GetDB("class").GetField(id).GetString("name");
|
||||
if(r.empty())
|
||||
r = className[id];
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetGenderName(uint32 id)
|
||||
{
|
||||
return GetDB("gender").GetField(id).GetString("name");
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetLangName(uint32 id)
|
||||
{
|
||||
std::string r = GetDB("language").GetField(id).GetString("name");
|
||||
if(r.empty())
|
||||
r = LookupName(id,langNames);
|
||||
return r;
|
||||
}
|
||||
@ -48,8 +48,21 @@ public:
|
||||
bool HasDB(std::string);
|
||||
SCPDatabase& GetDB(std::string);
|
||||
|
||||
//////////////////////
|
||||
// helper functions //
|
||||
//////////////////////
|
||||
std::string GetZoneName(uint32 id);
|
||||
std::string GetRaceName(uint32 id);
|
||||
std::string GetClassName_(uint32 id);
|
||||
std::string GetGenderName(uint32 id);
|
||||
std::string GetMapName(uint32 id);
|
||||
std::string GetLangName(uint32 id);
|
||||
|
||||
private:
|
||||
SCPDatabaseMap _map;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -196,10 +196,10 @@ OpcodeHandler *WorldSession::_GetOpcodeHandlerTable() const
|
||||
|
||||
void WorldSession::SetTarget(uint64 guid)
|
||||
{
|
||||
_targetGUID=guid;
|
||||
// TODO: update the UpdateFields once implemented
|
||||
SendSetSelection(guid);
|
||||
}
|
||||
|
||||
// redundant for now
|
||||
void WorldSession::SetFollowTarget(uint64 guid)
|
||||
{
|
||||
_followGUID=guid;
|
||||
@ -344,8 +344,13 @@ void WorldSession::_HandleCharEnumOpcode(WorldPacket& recvPacket)
|
||||
int playerNum = 0;
|
||||
|
||||
for(unsigned int i=0;i<num;i++){
|
||||
logcustom(0,LGREEN,"## %s (%u) [%s/%s]",
|
||||
plr[i]._name.c_str(),plr[i]._level,raceName[plr[i]._race],className[plr[i]._class]);
|
||||
logcustom(0,LGREEN,"## %s (%u) [%s/%s] Map: %s; Zone: %s",
|
||||
plr[i]._name.c_str(),
|
||||
plr[i]._level,
|
||||
GetDBMgr().GetRaceName(plr[i]._race).c_str(),
|
||||
GetDBMgr().GetClassName_(plr[i]._class).c_str(),
|
||||
GetDBMgr().GetMapName(plr[i]._mapId).c_str(),
|
||||
GetDBMgr().GetZoneName(plr[i]._zoneId).c_str());
|
||||
logdetail("-> coords: map=%u zone=%u x=%f y=%f z=%f",
|
||||
plr[i]._mapId,plr[i]._zoneId,plr[i]._x,plr[i]._y,plr[i]._z);
|
||||
for(unsigned int inv=0;inv<20;inv++)
|
||||
@ -402,6 +407,10 @@ void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket)
|
||||
|
||||
recvPacket >> type >> lang;
|
||||
|
||||
std::string langname = GetDBMgr().GetLangName(lang);
|
||||
const char* ln = langname.c_str();
|
||||
|
||||
|
||||
if (type == CHAT_MSG_CHANNEL)
|
||||
{
|
||||
recvPacket >> channel; // extract channel name
|
||||
@ -432,35 +441,35 @@ void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket)
|
||||
}
|
||||
else if (type==CHAT_MSG_WHISPER )
|
||||
{
|
||||
logcustom(0,WHITE,"WHISP: %s [%s]: %s",plrname.c_str(),LookupName(lang,langNames),msg.c_str());
|
||||
logcustom(0,WHITE,"WHISP: %s [%s]: %s",plrname.c_str(),ln,msg.c_str());
|
||||
}
|
||||
else if (type==CHAT_MSG_CHANNEL )
|
||||
{
|
||||
logcustom(0,WHITE,"CHANNEL: [%s]: %s [%s]: %s",channel.c_str(),plrname.c_str(),LookupName(lang,langNames),msg.c_str());
|
||||
logcustom(0,WHITE,"CHANNEL: [%s]: %s [%s]: %s",channel.c_str(),plrname.c_str(),ln,msg.c_str());
|
||||
}
|
||||
else if (type==CHAT_MSG_SAY )
|
||||
{
|
||||
logcustom(0,WHITE,"CHAT: %s [%s]: %s",plrname.c_str(),LookupName(lang,langNames),msg.c_str());
|
||||
logcustom(0,WHITE,"CHAT: %s [%s]: %s",plrname.c_str(),ln,msg.c_str());
|
||||
}
|
||||
else if (type==CHAT_MSG_YELL )
|
||||
{
|
||||
logcustom(0,WHITE,"CHAT: %s yells [%s]: %s ",plrname.c_str(),LookupName(lang,langNames),msg.c_str());
|
||||
logcustom(0,WHITE,"CHAT: %s yells [%s]: %s ",plrname.c_str(),ln,msg.c_str());
|
||||
}
|
||||
else if (type==CHAT_MSG_WHISPER_INFORM )
|
||||
{
|
||||
logcustom(0,WHITE,"TO %s [%s]: %s",plrname.c_str(),LookupName(lang,langNames),msg.c_str());
|
||||
logcustom(0,WHITE,"TO %s [%s]: %s",plrname.c_str(),ln,msg.c_str());
|
||||
}
|
||||
else if (type==CHAT_MSG_GUILD )
|
||||
{
|
||||
logcustom(0,WHITE,"GUILD: %s [%s]: %s",plrname.c_str(),LookupName(lang,langNames),msg.c_str());
|
||||
logcustom(0,WHITE,"GUILD: %s [%s]: %s",plrname.c_str(),ln,msg.c_str());
|
||||
}
|
||||
else if (type==CHAT_MSG_PARTY )
|
||||
{
|
||||
logcustom(0,WHITE,"PARTY: %s [%s]: %s",plrname.c_str(),LookupName(lang,langNames),msg.c_str());
|
||||
logcustom(0,WHITE,"PARTY: %s [%s]: %s",plrname.c_str(),ln,msg.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
logcustom(0,WHITE,"UNK CHAT TYPE (%u): %s [%s]: %s",type,plrname.c_str(),LookupName(lang,langNames),msg.c_str());
|
||||
logcustom(0,WHITE,"UNK CHAT TYPE (%u): %s [%s]: %s",type,plrname.c_str(),ln,msg.c_str());
|
||||
}
|
||||
|
||||
if(target_guid!=GetGuid() && msg.length()>1 && msg.at(0)=='-' && GetInstance()->GetConf()->allowgamecmd)
|
||||
|
||||
@ -31,6 +31,7 @@ public:
|
||||
void Init(void);
|
||||
|
||||
PseuInstance *GetInstance(void) { return _instance; }
|
||||
SCPDatabaseMgr& GetDBMgr(void) { return GetInstance()->dbmgr; }
|
||||
|
||||
OpcodeHandler *_GetOpcodeHandlerTable(void) const;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user