diff options
| author | ShinDarth <borzifrancesco@gmail.com> | 2016-08-28 23:09:53 +0200 |
|---|---|---|
| committer | ShinDarth <borzifrancesco@gmail.com> | 2016-08-28 23:09:53 +0200 |
| commit | 9ac33ca0928086a1c052e4734f65fc443803f6b5 (patch) | |
| tree | bed6f9be67e749f64bdf556c8a9cf720640c458a /src | |
| parent | e2a00f9ae48349bd6f409b1e5df6cbb7307f60b5 (diff) | |
Core/ObjectMgr: improved GetPlayerGUIDByName method + misc
Diffstat (limited to 'src')
| -rw-r--r-- | src/game/Globals/ObjectMgr.cpp | 40 | ||||
| -rw-r--r-- | src/game/World/World.cpp | 2 | ||||
| -rw-r--r-- | src/worldserver/worldserver.conf.dist | 6 |
3 files changed, 43 insertions, 5 deletions
diff --git a/src/game/Globals/ObjectMgr.cpp b/src/game/Globals/ObjectMgr.cpp index ea85c214d0..6ee38e5a36 100644 --- a/src/game/Globals/ObjectMgr.cpp +++ b/src/game/Globals/ObjectMgr.cpp @@ -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; } diff --git a/src/game/World/World.cpp b/src/game/World/World.cpp index 8272744436..82ff52f5f4 100644 --- a/src/game/World/World.cpp +++ b/src/game/World/World.cpp @@ -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); diff --git a/src/worldserver/worldserver.conf.dist b/src/worldserver/worldserver.conf.dist index 317cbd0530..5c1d1a88bd 100644 --- a/src/worldserver/worldserver.conf.dist +++ b/src/worldserver/worldserver.conf.dist @@ -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 |
