diff options
5 files changed, 45 insertions, 5 deletions
diff --git a/modules/worldengine/nucleus/src/Database/Implementation/CharacterDatabase.cpp b/modules/worldengine/nucleus/src/Database/Implementation/CharacterDatabase.cpp index 7d61d96fee..6f18d3feb2 100644 --- a/modules/worldengine/nucleus/src/Database/Implementation/CharacterDatabase.cpp +++ b/modules/worldengine/nucleus/src/Database/Implementation/CharacterDatabase.cpp @@ -16,6 +16,7 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_INS_QUEST_POOL_SAVE, "INSERT INTO pool_quest_save (pool_id, quest_id) VALUES (?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_ITEM, "DELETE FROM guild_bank_item WHERE guildid = ? AND TabId = ? AND SlotId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_EXPIRED_BANS, "UPDATE character_banned SET active = 0 WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate <> bandate", CONNECTION_ASYNC); + PrepareStatement(CHAR_SEL_DATA_BY_NAME, "SELECT guid, account, name, gender, race, class, level FROM characters WHERE deleteDate IS NULL AND name = ?", CONNECTION_BOTH); PrepareStatement(CHAR_SEL_CHECK_NAME, "SELECT 1 FROM characters WHERE name = ?", CONNECTION_BOTH); PrepareStatement(CHAR_SEL_CHECK_GUID, "SELECT 1 FROM characters WHERE guid = ?", CONNECTION_SYNCH); PrepareStatement(CHAR_SEL_SUM_CHARS, "SELECT COUNT(guid) FROM characters WHERE account = ?", CONNECTION_BOTH); diff --git a/modules/worldengine/nucleus/src/Database/Implementation/CharacterDatabase.h b/modules/worldengine/nucleus/src/Database/Implementation/CharacterDatabase.h index 8f0243665a..82ace73b15 100644 --- a/modules/worldengine/nucleus/src/Database/Implementation/CharacterDatabase.h +++ b/modules/worldengine/nucleus/src/Database/Implementation/CharacterDatabase.h @@ -36,6 +36,7 @@ enum CharacterDatabaseStatements CHAR_INS_QUEST_POOL_SAVE, CHAR_DEL_NONEXISTENT_GUILD_BANK_ITEM, CHAR_DEL_EXPIRED_BANS, + CHAR_SEL_DATA_BY_NAME, CHAR_SEL_CHECK_NAME, CHAR_SEL_CHECK_GUID, CHAR_SEL_SUM_CHARS, 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 |
