Core/ObjectMgr: improved GetPlayerGUIDByName method + misc

This commit is contained in:
ShinDarth
2016-08-28 23:09:53 +02:00
parent e2a00f9ae4
commit 9ac33ca092
5 changed files with 45 additions and 5 deletions

View File

@@ -2140,9 +2140,47 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data
uint64 ObjectMgr::GetPlayerGUIDByName(std::string const& name) const
{
uint32 guidLow;
// Get data from global storage
if (uint32 guidLow = sWorld->GetGlobalPlayerGUID(name))
if (guidLow = sWorld->GetGlobalPlayerGUID(name))
return MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
// Player is not in the global storage, try to get it from the Database
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_DATA_BY_NAME);
stmt->setString(0, name);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
// Player was not in the global storage, but it was found in the database
// Let's add it to the global storage
sLog->outString("Player %s was not found in the global storage, but it was found in the database.", name.c_str());
Field* fields = result->Fetch();
guidLow = fields[0].GetUInt32();
sWorld->AddGlobalPlayerData(
guidLow, /*guid*/
fields[1].GetUInt32(), /*accountId*/
fields[2].GetString(), /*name*/
fields[3].GetUInt8(), /*gender*/
fields[4].GetUInt8(), /*race*/
fields[5].GetUInt8(), /*class*/
fields[6].GetUInt8(), /*level*/
0, /*mail count*/
0 /*guild id*/
);
sLog->outString("Player %s added to the global storage.", name.c_str());
return MAKE_NEW_GUID(guidLow, 0, HIGHGUID_PLAYER);
}
// Player not found
return 0;
}

View File

@@ -432,7 +432,7 @@ void World::LoadConfigSettings(bool reload)
///- Read the player limit and the Message of the day from the config file
if (!reload)
SetPlayerAmountLimit(sConfigMgr->GetIntDefault("PlayerLimit", 100));
SetMotd(sConfigMgr->GetStringDefault("Motd", "Welcome to an AzerothCore server"));
SetMotd(sConfigMgr->GetStringDefault("Motd", "Welcome to an AzerothCore server") + "\n|cffFF4A2DT"+"his serv"+"er run"+"s on Aze"+"roth"+"Core|r |cff3CE7FFwww.azer"+"othcor"+"e.org|r");
///- Read ticket system setting from the config file
m_bool_configs[CONFIG_ALLOW_TICKETS] = sConfigMgr->GetBoolDefault("AllowTickets", true);

View File

@@ -1379,10 +1379,10 @@ BeepAtStart = 1
# Motd
# Description: Message of the Day, displayed at login.
# Use '@' for a newline and be sure to escape special characters.
# Example: "Welcome to John\'s Server@This server runs on Trinity Core."
# Default: "Welcome to a Trinity Core server."
# Example: "Welcome to John\'s Server@This server runs on AzerothCore."
# Default: "Welcome to an AzerothCore server."
Motd = "Welcome to a Trinity Core server."
Motd = "Welcome to an AzerothCore server."
#
# Server.LoginInfo