From fcde03a03670caa76b0933dbf3e7a1e95bb2b3be Mon Sep 17 00:00:00 2001 From: KingPin Date: Sun, 19 Oct 2008 21:08:34 -0500 Subject: [svn] * Fixed compile from r78 * Fixed: not apply healling bonus to spell 40972 heal amount. - Source Mangos * Item 30627 hidden cooldown - Source Mangos * Fixed Trinityrealm autopatching system - Source Arrai * Add support for autoconf 2.6.2 and newer - Source Derex Some decent sized changes, please test before deploying - KP --HG-- branch : trunk --- src/game/CharacterHandler.cpp | 2 +- src/game/Player.cpp | 14 +-- src/game/SpellAuras.cpp | 2 +- src/game/Unit.cpp | 4 +- src/game/WorldSocketMgr.cpp | 1 - src/trinityrealm/AuthSocket.cpp | 267 ++++++++++++++++++++-------------------- src/trinityrealm/AuthSocket.h | 9 +- 7 files changed, 156 insertions(+), 143 deletions(-) (limited to 'src') diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index d86bf7734a0..36e0720a08d 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -61,7 +61,7 @@ bool LoginQueryHolder::Initialize() // NOTE: all fields in `characters` must be read to prevent lost character data at next save in case wrong DB structure. // !!! NOTE: including unused `zone`,`online` - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, gmstate, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid)); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 32413aba503..5aa67b645fd 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -13664,7 +13664,7 @@ float Player::GetFloatValueFromDB(uint16 index, uint64 guid) bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) { //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [28] [29] 30 31 32 - //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, gmstate, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty FROM characters WHERE guid = '%u'", guid); + //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extraflags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty FROM characters WHERE guid = '%u'", guid); QueryResult *result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM); if(!result) @@ -13899,7 +13899,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) m_taxi.LoadTaxiMask( fields[11].GetString() ); // must be before InitTaxiNodesForLevel - uint32 gmstate = fields[25].GetUInt32(); + uint32 extraflags = fields[25].GetUInt32(); m_stableSlots = fields[26].GetUInt32(); if(m_stableSlots > 2) @@ -14089,7 +14089,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) case 0: break; // disable case 1: SetGameMaster(true); break; // enable case 2: // save state - if(gmstate & PLAYER_EXTRA_GM_ON) + if(extraflags & PLAYER_EXTRA_GM_ON) SetGameMaster(true); break; } @@ -14100,7 +14100,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) case 0: break; // disable case 1: SetAcceptTicket(true); break; // enable case 2: // save state - if(gmstate & PLAYER_EXTRA_GM_ACCEPT_TICKETS) + if(extraflags & PLAYER_EXTRA_GM_ACCEPT_TICKETS) SetAcceptTicket(true); break; } @@ -14111,7 +14111,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) case 0: break; // disable case 1: SetGMChat(true); break; // enable case 2: // save state - if(gmstate & PLAYER_EXTRA_GM_CHAT) + if(extraflags & PLAYER_EXTRA_GM_CHAT) SetGMChat(true); break; } @@ -14122,7 +14122,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) case 0: break; // disable case 1: SetAcceptWhispers(true); break; // enable case 2: // save state - if(gmstate & PLAYER_EXTRA_ACCEPT_WHISPERS) + if(extraflags & PLAYER_EXTRA_ACCEPT_WHISPERS) SetAcceptWhispers(true); break; } @@ -15109,7 +15109,7 @@ void Player::SaveToDB() "map, dungeon_difficulty, position_x, position_y, position_z, orientation, data, " "taximask, online, cinematic, " "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, " - "trans_x, trans_y, trans_z, trans_o, transguid, gmstate, stable_slots, at_login, zone, " + "trans_x, trans_y, trans_z, trans_o, transguid, extraflags, stable_slots, at_login, zone, " "death_expire_time, taxi_path) VALUES (" << GetGUIDLow() << ", " << GetSession()->GetAccountId() << ", '" diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 600d9a27cf1..f0c67b66918 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -1953,7 +1953,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 43873: // Headless Horseman Laugh if(caster->GetTypeId() == TYPEID_PLAYER) { - ((Player*)caster)->PlaySound(11965, false); + ((Player*)caster)->SendPlaySound(11965, false); } return; case 46354: // Blood Elf Illusion diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 51991c01d2d..24acc4c18f8 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -7764,7 +7764,9 @@ uint32 Unit::SpellHealingBonus(SpellEntry const *spellProto, uint32 healamount, // Healing Done // These Spells are doing fixed amount of healing (TODO found less hack-like check) - if(spellProto->Id == 15290 || spellProto->Id == 39373 || spellProto->Id == 33778 || spellProto->Id == 379 || spellProto->Id == 38395) + if (spellProto->Id == 15290 || spellProto->Id == 39373 || + spellProto->Id == 33778 || spellProto->Id == 379 || + spellProto->Id == 38395 || spellProto->Id == 40972) return healamount; diff --git a/src/game/WorldSocketMgr.cpp b/src/game/WorldSocketMgr.cpp index c431bf21b73..7d4a7e84078 100644 --- a/src/game/WorldSocketMgr.cpp +++ b/src/game/WorldSocketMgr.cpp @@ -362,7 +362,6 @@ WorldSocketMgr::OnSocketOpen (WorldSocket* sock) return m_NetThreads[min].AddSocket (sock); - return 0; } WorldSocketMgr* diff --git a/src/trinityrealm/AuthSocket.cpp b/src/trinityrealm/AuthSocket.cpp index b06ac605e4f..4be14a52d30 100644 --- a/src/trinityrealm/AuthSocket.cpp +++ b/src/trinityrealm/AuthSocket.cpp @@ -137,7 +137,7 @@ typedef struct XFER_INIT { uint8 cmd; // XFER_INITIATE uint8 fileNameLen; // strlen(fileName); - uint8 fileName[1]; // fileName[fileNameLen] + uint8 fileName[5]; // fileName[fileNameLen] uint64 file_size; // file size (bytes) uint8 md5[MD5_DIGEST_LENGTH]; // MD5 }XFER_INIT; @@ -217,7 +217,7 @@ AuthSocket::AuthSocket(ISocketHandler &h) : TcpSocket(h) N.SetHexStr("894B645E89E1535BBDAD5B8B290650530801B18EBFBF5E8FAB3C82872A3E9BB7"); g.SetDword(7); _authed = false; - pPatch=NULL; + pPatch = NULL; _accountSecurityLevel = SEC_PLAYER; } @@ -225,6 +225,7 @@ AuthSocket::AuthSocket(ISocketHandler &h) : TcpSocket(h) /// Close patch file descriptor before leaving AuthSocket::~AuthSocket() { + ZThread::Guard g(patcherLock); if(pPatch) fclose(pPatch); } @@ -360,6 +361,7 @@ bool AuthSocket::_HandleLogonChallenge() ByteBuffer pkt; _login = (const char*)ch->I; + _build = ch->build; ///- Normalize account name //utf8ToUpperOnlyLatin(_login); -- client already send account in expected form @@ -369,154 +371,169 @@ bool AuthSocket::_HandleLogonChallenge() _safelogin=_login; dbRealmServer.escape_string(_safelogin); - ///- Check if the client has one of the expected version numbers - bool valid_version=false; - int accepted_versions[]=EXPECTED_TRINITY_CLIENT_BUILD; - for(int i=0;accepted_versions[i];i++) - if(ch->build==accepted_versions[i]) + pkt << (uint8) AUTH_LOGON_CHALLENGE; + pkt << (uint8) 0x00; + + ///- Verify that this IP is not in the ip_banned table + // No SQL injection possible (paste the IP address as passed by the socket) + dbRealmServer.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + + std::string address = GetRemoteAddress(); + dbRealmServer.escape_string(address); + QueryResult *result = dbRealmServer.PQuery( "SELECT * FROM ip_banned WHERE ip = '%s'",address.c_str()); + if(result) { - valid_version=true; - break; + pkt << (uint8)REALM_AUTH_ACCOUNT_BANNED; + sLog.outBasic("[AuthChallenge] Banned ip %s tries to login!",GetRemoteAddress().c_str ()); + delete result; } - - ///