From 34ee1cffa2abcc7b691d0a9d2c6425e36de90a59 Mon Sep 17 00:00:00 2001 From: freghar Date: Thu, 21 May 2009 18:09:00 +0200 Subject: [PATCH 01/11] [7867] Change default IP in account and banned_ip tables As IP of 0.0.0.0 is, unlike 127.0.0.1, more clearly recognized as invalid. Signed-off-by: freghar --- sql/realmd.sql | 4 ++-- sql/updates/7867_01_realmd_account.sql | 2 ++ src/shared/revision_nr.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 sql/updates/7867_01_realmd_account.sql diff --git a/sql/realmd.sql b/sql/realmd.sql index ee8e023f1..c7d66ce2a 100644 --- a/sql/realmd.sql +++ b/sql/realmd.sql @@ -50,7 +50,7 @@ CREATE TABLE `account` ( `s` longtext, `email` text, `joindate` timestamp NOT NULL default CURRENT_TIMESTAMP, - `last_ip` varchar(30) NOT NULL default '127.0.0.1', + `last_ip` varchar(30) NOT NULL default '0.0.0.0', `failed_logins` int(11) unsigned NOT NULL default '0', `locked` tinyint(3) unsigned NOT NULL default '0', `last_login` timestamp NOT NULL default '0000-00-00 00:00:00', @@ -107,7 +107,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `ip_banned`; CREATE TABLE `ip_banned` ( - `ip` varchar(32) NOT NULL default '127.0.0.1', + `ip` varchar(32) NOT NULL default '0.0.0.0', `bandate` bigint(40) NOT NULL, `unbandate` bigint(40) NOT NULL, `bannedby` varchar(50) NOT NULL default '[Console]', diff --git a/sql/updates/7867_01_realmd_account.sql b/sql/updates/7867_01_realmd_account.sql new file mode 100644 index 000000000..577382979 --- /dev/null +++ b/sql/updates/7867_01_realmd_account.sql @@ -0,0 +1,2 @@ +ALTER TABLE `account` CHANGE COLUMN `last_ip` `last_ip` varchar(30) NOT NULL default '0.0.0.0'; +ALTER TABLE `ip_banned` CHANGE COLUMN `ip` `ip` varchar(32) NOT NULL default '0.0.0.0'; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 3f8609005..f414ef119 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7866" + #define REVISION_NR "7867" #endif // __REVISION_NR_H__ From fd074a71fbc7610dd17ffbc08999dfb39ea467e6 Mon Sep 17 00:00:00 2001 From: freghar Date: Thu, 21 May 2009 19:09:58 +0200 Subject: [PATCH 02/11] [7868] Added guard sql queries and 7867_01_realmd_account.sql to Makefile "the stuff I forgot in previous commit", sorry Signed-off-by: freghar --- sql/realmd.sql | 2 +- sql/updates/7867_01_realmd_account.sql | 2 ++ sql/updates/Makefile.am | 2 ++ src/shared/revision_nr.h | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sql/realmd.sql b/sql/realmd.sql index c7d66ce2a..dfc329fd0 100644 --- a/sql/realmd.sql +++ b/sql/realmd.sql @@ -21,7 +21,7 @@ DROP TABLE IF EXISTS `realmd_db_version`; CREATE TABLE `realmd_db_version` ( - `required_7546_02_realmd_uptime` bit(1) default NULL + `required_7867_01_realmd_account` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; -- diff --git a/sql/updates/7867_01_realmd_account.sql b/sql/updates/7867_01_realmd_account.sql index 577382979..4dad2bfe3 100644 --- a/sql/updates/7867_01_realmd_account.sql +++ b/sql/updates/7867_01_realmd_account.sql @@ -1,2 +1,4 @@ +ALTER TABLE realmd_db_version CHANGE COLUMN required_7546_02_realmd_uptime required_7867_01_realmd_account bit; + ALTER TABLE `account` CHANGE COLUMN `last_ip` `last_ip` varchar(30) NOT NULL default '0.0.0.0'; ALTER TABLE `ip_banned` CHANGE COLUMN `ip` `ip` varchar(32) NOT NULL default '0.0.0.0'; diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index decb87867..d3aab66e3 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -190,6 +190,7 @@ pkgdata_DATA = \ 7839_02_mangos_command.sql \ 7850_01_mangos_command.sql \ 7855_01_mangos_pools.sql \ + 7867_01_realmd_account.sql \ README ## Additional files to include when running 'make dist' @@ -360,4 +361,5 @@ EXTRA_DIST = \ 7839_02_mangos_command.sql \ 7850_01_mangos_command.sql \ 7855_01_mangos_pools.sql \ + 7867_01_realmd_account.sql \ README diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index f414ef119..46c1d8692 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7867" + #define REVISION_NR "7868" #endif // __REVISION_NR_H__ From b708cc87a34df9e7d2c652fed54b22605d3faf69 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 21 May 2009 21:49:15 +0400 Subject: [PATCH 03/11] [7869] Add note about VS 2003 drop to NEWS --- NEWS | 1 + src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ddba38e79..7e269c753 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ Version 0.13 * Under discussion. * OpenSSL lib upgrade to OpenSSL 0.9.8k * ZThread replaced by similar ACE framework functionality. ZThread use dropped. + * Visual Studio 2003 (VC71) support dropped * Upgrade to client version 3.0.9 (build 9551). Version 0.12 diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 46c1d8692..d6da2c606 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7868" + #define REVISION_NR "7869" #endif // __REVISION_NR_H__ From 3b11d833c8f0f701277481deb968ea9c9ddd2137 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 22 May 2009 06:06:20 +0400 Subject: [PATCH 04/11] [7870] Implement creature ranged ammo show at ranged weapon use. * Use BDC data (creature weapon not alwas listed in item_template) --- src/game/DBCStructure.h | 2 +- src/game/DBCfmt.h | 2 +- src/game/ObjectMgr.cpp | 4 ++-- src/game/Spell.cpp | 35 ++++++++++++++++++++++++++++++++++- src/shared/revision_nr.h | 2 +- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index 2948f8621..c63b94a58 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -943,7 +943,7 @@ struct ItemEntry { uint32 ID; // 0 uint32 Class; // 1 - //uint32 SubClass; // 2 some items have strnage subclasses + uint32 SubClass; // 2 some items have strnage subclasses int32 Unk0; // 3 int32 Material; // 4 uint32 DisplayId; // 5 diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h index 75a795906..0966e2e2e 100644 --- a/src/game/DBCfmt.h +++ b/src/game/DBCfmt.h @@ -60,7 +60,7 @@ const char GtOCTRegenHPfmt[]="f"; const char GtRegenHPPerSptfmt[]="f"; const char GtRegenMPPerSptfmt[]="f"; const char Holidaysfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; -const char Itemfmt[]="nixiiiii"; +const char Itemfmt[]="niiiiiii"; const char ItemBagFamilyfmt[]="nxxxxxxxxxxxxxxxxx"; //const char ItemDisplayTemplateEntryfmt[]="nxxxxxxxxxxixxxxxxxxxxx"; //const char ItemCondExtCostsEntryfmt[]="xiii"; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index f6518193f..9955db4c9 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -787,8 +787,8 @@ void ObjectMgr::LoadEquipmentTemplates() sLog.outString( ">> Loaded %u equipment template", sEquipmentStorage.RecordCount ); sLog.outString(); - // This DBC is currently only used for item templates and creature equipments checks. - sItemStore.Clear(); + // Creature items can be not listed in item_template + //sItemStore.Clear(); -- so used in spell casting } CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelid) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index da6f652b2..9f47254e4 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -3048,7 +3048,40 @@ void Spell::WriteAmmoToPacket( WorldPacket * data ) } } } - // TODO: implement selection ammo data based at ranged weapon stored in equipmodel/equipinfo/equipslot fields + else + { + for (uint8 i = 0; i < 3; ++i) + { + if(uint32 item_id = m_caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i)) + { + if(ItemEntry const * itemEntry = sItemStore.LookupEntry(item_id)) + { + if(itemEntry->Class==ITEM_CLASS_WEAPON) + { + switch(itemEntry->SubClass) + { + case ITEM_SUBCLASS_WEAPON_THROWN: + ammoDisplayID = itemEntry->DisplayId; + ammoInventoryType = itemEntry->InventoryType; + break; + case ITEM_SUBCLASS_WEAPON_BOW: + case ITEM_SUBCLASS_WEAPON_CROSSBOW: + ammoDisplayID = 5996; // is this need fixing? + ammoInventoryType = INVTYPE_AMMO; + break; + case ITEM_SUBCLASS_WEAPON_GUN: + ammoDisplayID = 5998; // is this need fixing? + ammoInventoryType = INVTYPE_AMMO; + break; + } + + if(ammoDisplayID) + break; + } + } + } + } + } *data << uint32(ammoDisplayID); *data << uint32(ammoInventoryType); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d6da2c606..5b0ccd2da 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7869" + #define REVISION_NR "7870" #endif // __REVISION_NR_H__ From 8b5fa130117633a427b58a6115cac4fa99e12d4d Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Fri, 22 May 2009 06:31:51 +0400 Subject: [PATCH 05/11] [7871] Drop unused second arg in InstanceData::OnCreatureCreate. Signed-off-by: VladimirMangos --- src/game/Creature.cpp | 2 +- src/game/InstanceData.h | 2 +- src/shared/revision_nr.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index fe79838e0..6b941271a 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1297,7 +1297,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const Map *map = MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); if(map && map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) { - ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this, Entry); + ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this); } return true; diff --git a/src/game/InstanceData.h b/src/game/InstanceData.h index cd416653e..4099e7aa3 100644 --- a/src/game/InstanceData.h +++ b/src/game/InstanceData.h @@ -61,7 +61,7 @@ class MANGOS_DLL_SPEC InstanceData virtual void OnObjectCreate(GameObject *) {} //called on creature creation - virtual void OnCreatureCreate(Creature * /*creature*/, uint32 /*creature_entry*/) {} + virtual void OnCreatureCreate(Creature * /*creature*/) {} //All-purpose data storage 64 bit virtual uint64 GetData64(uint32 /*Data*/) { return 0; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 5b0ccd2da..90d4c9a1e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7870" + #define REVISION_NR "7871" #endif // __REVISION_NR_H__ From 0bd7177b11b22f191e5ae03ee1ea97d4921262b4 Mon Sep 17 00:00:00 2001 From: Astellar Date: Fri, 22 May 2009 14:46:12 +0400 Subject: [PATCH 06/11] [7872] Restore work one shaman totem Signed-off-by: DiSlord --- src/game/SpellEffects.cpp | 6 ++++++ src/shared/revision_nr.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index c1cfd684d..06ebd13e9 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1687,6 +1687,12 @@ void Spell::EffectDummy(uint32 i) } return; } + // Cleansing Totem + if(m_spellInfo->SpellFamilyFlags & 0x0000000004000000LL && m_spellInfo->SpellIconID==1673) + { + m_caster->CastSpell(unitTarget, 52025, true); + return; + } // Healing Stream Totem if(m_spellInfo->SpellFamilyFlags & 0x0000000000002000LL) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 90d4c9a1e..c95aabe5d 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7871" + #define REVISION_NR "7872" #endif // __REVISION_NR_H__ From 3beec18f4eff4bbbb0db170315c0401ff18afb12 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 22 May 2009 16:08:36 +0400 Subject: [PATCH 07/11] [7873] Use same name for realmd DB connection in realmd code as used in mangosd/game. --- src/realmd/AuthSocket.cpp | 36 ++++++++++++++++++------------------ src/realmd/Main.cpp | 8 ++++---- src/realmd/RealmList.cpp | 4 ++-- src/shared/revision_nr.h | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/realmd/AuthSocket.cpp b/src/realmd/AuthSocket.cpp index a20f660e8..70448390a 100644 --- a/src/realmd/AuthSocket.cpp +++ b/src/realmd/AuthSocket.cpp @@ -34,7 +34,7 @@ extern RealmList m_realmList; -extern DatabaseType dbRealmServer; +extern DatabaseType loginDatabase; #define ChunkSize 2048 @@ -323,7 +323,7 @@ void AuthSocket::_SetVSFields(const std::string& rI) const char *v_hex, *s_hex; v_hex = v.AsHexStr(); s_hex = s.AsHexStr(); - dbRealmServer.PExecute("UPDATE account SET v = '%s', s = '%s' WHERE username = '%s'",v_hex,s_hex, _safelogin.c_str() ); + loginDatabase.PExecute("UPDATE account SET v = '%s', s = '%s' WHERE username = '%s'",v_hex,s_hex, _safelogin.c_str() ); OPENSSL_free((void*)v_hex); OPENSSL_free((void*)s_hex); } @@ -379,18 +379,18 @@ bool AuthSocket::_HandleLogonChallenge() //Escape the user login to avoid further SQL injection //Memory will be freed on AuthSocket object destruction _safelogin=_login; - dbRealmServer.escape_string(_safelogin); + loginDatabase.escape_string(_safelogin); 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"); + loginDatabase.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()); + loginDatabase.escape_string(address); + QueryResult *result = loginDatabase.PQuery( "SELECT * FROM ip_banned WHERE ip = '%s'",address.c_str()); if(result) { pkt << (uint8)REALM_AUTH_ACCOUNT_BANNED; @@ -402,7 +402,7 @@ bool AuthSocket::_HandleLogonChallenge() ///- Get the account details from the account table // No SQL injection (escaped user name) - result = dbRealmServer.PQuery("SELECT sha_pass_hash,id,locked,last_ip,gmlevel FROM account WHERE username = '%s'",_safelogin.c_str ()); + result = loginDatabase.PQuery("SELECT sha_pass_hash,id,locked,last_ip,gmlevel FROM account WHERE username = '%s'",_safelogin.c_str ()); if( result ) { ///- If the IP is 'locked', check that the player comes indeed from the correct IP address @@ -430,9 +430,9 @@ bool AuthSocket::_HandleLogonChallenge() if (!locked) { //set expired bans to inactive - dbRealmServer.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + loginDatabase.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); ///- If the account is banned, reject the logon attempt - QueryResult *banresult = dbRealmServer.PQuery("SELECT bandate,unbandate FROM account_banned WHERE id = %u AND active = 1", (*result)[1].GetUInt32()); + QueryResult *banresult = loginDatabase.PQuery("SELECT bandate,unbandate FROM account_banned WHERE id = %u AND active = 1", (*result)[1].GetUInt32()); if(banresult) { if((*banresult)[0].GetUInt64() == (*banresult)[1].GetUInt64()) @@ -651,7 +651,7 @@ bool AuthSocket::_HandleLogonProof() ///- Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account // No SQL injection (escaped user name) and IP address as received by socket const char* K_hex = K.AsHexStr(); - dbRealmServer.PExecute("UPDATE account SET sessionkey = '%s', last_ip = '%s', last_login = NOW(), locale = '%u', failed_logins = 0 WHERE username = '%s'", K_hex, GetRemoteAddress().c_str(), GetLocaleByName(_localizationName), _safelogin.c_str() ); + loginDatabase.PExecute("UPDATE account SET sessionkey = '%s', last_ip = '%s', last_login = NOW(), locale = '%u', failed_logins = 0 WHERE username = '%s'", K_hex, GetRemoteAddress().c_str(), GetLocaleByName(_localizationName), _safelogin.c_str() ); OPENSSL_free((void*)K_hex); ///- Finish SRP6 and send the final result to the client @@ -682,9 +682,9 @@ bool AuthSocket::_HandleLogonProof() if(MaxWrongPassCount > 0) { //Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP - dbRealmServer.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'",_safelogin.c_str()); + loginDatabase.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'",_safelogin.c_str()); - if(QueryResult *loginfail = dbRealmServer.PQuery("SELECT id, failed_logins FROM account WHERE username = '%s'", _safelogin.c_str())) + if(QueryResult *loginfail = loginDatabase.PQuery("SELECT id, failed_logins FROM account WHERE username = '%s'", _safelogin.c_str())) { Field* fields = loginfail->Fetch(); uint32 failed_logins = fields[1].GetUInt32(); @@ -697,7 +697,7 @@ bool AuthSocket::_HandleLogonProof() if(WrongPassBanType) { uint32 acc_id = fields[0].GetUInt32(); - dbRealmServer.PExecute("INSERT INTO account_banned VALUES ('%u',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','MaNGOS realmd','Failed login autoban',1)", + loginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','MaNGOS realmd','Failed login autoban',1)", acc_id, WrongPassBanTime); sLog.outBasic("[AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times", _login.c_str(), WrongPassBanTime, failed_logins); @@ -705,8 +705,8 @@ bool AuthSocket::_HandleLogonProof() else { std::string current_ip = GetRemoteAddress(); - dbRealmServer.escape_string(current_ip); - dbRealmServer.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','MaNGOS realmd','Failed login autoban')", + loginDatabase.escape_string(current_ip); + loginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','MaNGOS realmd','Failed login autoban')", current_ip.c_str(), WrongPassBanTime); sLog.outBasic("[AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times", current_ip.c_str(), WrongPassBanTime, _login.c_str(), failed_logins); @@ -752,7 +752,7 @@ bool AuthSocket::_HandleReconnectChallenge() _login = (const char*)ch->I; _safelogin = _login; - QueryResult *result = dbRealmServer.PQuery ("SELECT sessionkey FROM account WHERE username = '%s'", _safelogin.c_str ()); + QueryResult *result = loginDatabase.PQuery ("SELECT sessionkey FROM account WHERE username = '%s'", _safelogin.c_str ()); // Stop if the account is not found if (!result) @@ -832,7 +832,7 @@ bool AuthSocket::_HandleRealmList() ///- Get the user id (else close the connection) // No SQL injection (escaped user name) - QueryResult *result = dbRealmServer.PQuery("SELECT id,sha_pass_hash FROM account WHERE username = '%s'",_safelogin.c_str()); + QueryResult *result = loginDatabase.PQuery("SELECT id,sha_pass_hash FROM account WHERE username = '%s'",_safelogin.c_str()); if(!result) { sLog.outError("[ERROR] user %s tried to login and we cannot find him in the database.",_login.c_str()); @@ -857,7 +857,7 @@ bool AuthSocket::_HandleRealmList() uint8 AmountOfCharacters; // No SQL injection. id of realm is controlled by the database. - result = dbRealmServer.PQuery( "SELECT numchars FROM realmcharacters WHERE realmid = '%d' AND acctid='%u'",i->second.m_ID,id); + result = loginDatabase.PQuery( "SELECT numchars FROM realmcharacters WHERE realmid = '%d' AND acctid='%u'",i->second.m_ID,id); if( result ) { Field *fields = result->Fetch(); diff --git a/src/realmd/Main.cpp b/src/realmd/Main.cpp index 59b6081ef..08611268e 100644 --- a/src/realmd/Main.cpp +++ b/src/realmd/Main.cpp @@ -54,7 +54,7 @@ void HookSignals(); bool stopEvent = false; ///< Setting it to true stops the server RealmList m_realmList; ///< Holds the list of realms for this server -DatabaseType dbRealmServer; ///< Accessor to the realm server database +DatabaseType loginDatabase; ///< Accessor to the realm server database /// Print out the usage string for this program on the console. void usage(const char *prog) @@ -262,7 +262,7 @@ extern int main(int argc, char **argv) { loopCounter = 0; sLog.outDetail("Ping MySQL to keep connection alive"); - delete dbRealmServer.Query("SELECT 1 FROM realmlist LIMIT 1"); + delete loginDatabase.Query("SELECT 1 FROM realmlist LIMIT 1"); } #ifdef WIN32 if (m_ServiceStatus == 0) stopEvent = true; @@ -271,7 +271,7 @@ extern int main(int argc, char **argv) } ///- Wait for the delay thread to exit - dbRealmServer.HaltDelayThread(); + loginDatabase.HaltDelayThread(); ///- Remove signal handling before leaving UnhookSignals(); @@ -310,7 +310,7 @@ bool StartDB(std::string &dbstring) } sLog.outString("Database: %s", dbstring.c_str() ); - if(!dbRealmServer.Initialize(dbstring.c_str())) + if(!loginDatabase.Initialize(dbstring.c_str())) { sLog.outError("Cannot connect to database"); return false; diff --git a/src/realmd/RealmList.cpp b/src/realmd/RealmList.cpp index a5352d0d9..1bb0a977d 100644 --- a/src/realmd/RealmList.cpp +++ b/src/realmd/RealmList.cpp @@ -27,7 +27,7 @@ INSTANTIATE_SINGLETON_1( RealmList ); -extern DatabaseType dbRealmServer; +extern DatabaseType loginDatabase; RealmList::RealmList( ) : m_UpdateInterval(0), m_NextUpdateTime(time(NULL)) { @@ -79,7 +79,7 @@ void RealmList::UpdateRealms(bool init) { sLog.outDetail("Updating Realm List..."); - QueryResult *result = dbRealmServer.Query( "SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population FROM realmlist WHERE color <> 3 ORDER BY name" ); + QueryResult *result = loginDatabase.Query( "SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population FROM realmlist WHERE color <> 3 ORDER BY name" ); ///- Circle through results and add them to the realm map if(result) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c95aabe5d..5c1823bf9 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7872" + #define REVISION_NR "7873" #endif // __REVISION_NR_H__ From 5c80c62f9b668f3cb29863e2a92d776f31966572 Mon Sep 17 00:00:00 2001 From: ApoC Date: Fri, 22 May 2009 18:20:33 +0200 Subject: [PATCH 08/11] [7874] Fix: possible runtime crash. Signed-off-by: ApoC --- src/game/Level3.cpp | 2 +- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 61469006f..e7dd57d00 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -4599,7 +4599,7 @@ bool ChatHandler::HandleResetSpellsCommand(const char * args) else { CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_SPELLS), GUID_LOPART(target_guid)); - PSendSysMessage(LANG_RESET_SPELLS_OFFLINE,target_name); + PSendSysMessage(LANG_RESET_SPELLS_OFFLINE,target_name.c_str()); } return true; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 5c1823bf9..e4955593c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7873" + #define REVISION_NR "7874" #endif // __REVISION_NR_H__ From dad833fd3e75fc2587c6c7fffcc13483252ab037 Mon Sep 17 00:00:00 2001 From: ApoC Date: Fri, 22 May 2009 19:05:28 +0200 Subject: [PATCH 09/11] [7875] Calculate mechanic immune mask for aura remove only if really needed. Signed-off-by: ApoC --- src/game/SpellAuras.cpp | 12 ++++++------ src/shared/revision_nr.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 2dd62f901..431753a18 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3965,12 +3965,6 @@ void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real) void Aura::HandleModMechanicImmunity(bool apply, bool /*Real*/) { - uint32 mechanic = 1 << m_modifier.m_miscvalue; - - //immune movement impairment and loss of control - if(GetId()==42292 || GetId()==59752) - mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; - // cache values in local vars for prevent access to possible deleted aura data SpellEntry const* spellInfo = GetSpellProto(); uint32 misc = m_modifier.m_miscvalue; @@ -3978,6 +3972,12 @@ void Aura::HandleModMechanicImmunity(bool apply, bool /*Real*/) if(apply && spellInfo->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) { + uint32 mechanic = 1 << m_modifier.m_miscvalue; + + //immune movement impairment and loss of control + if(GetId()==42292 || GetId()==59752) + mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; + Unit::AuraMap& Auras = target->GetAuras(); for(Unit::AuraMap::iterator iter = Auras.begin(), next; iter != Auras.end(); iter = next) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e4955593c..d762c9584 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7874" + #define REVISION_NR "7875" #endif // __REVISION_NR_H__ From e0e5ed7bd803bc31b21e6ba908c6c92cb4fd8346 Mon Sep 17 00:00:00 2001 From: ApoC Date: Fri, 22 May 2009 20:30:48 +0200 Subject: [PATCH 10/11] [7876] Implemented dummy effect and special target selection for 52759. Signed-off-by: ApoC --- src/game/Spell.cpp | 27 +++++++++++++++++++++++++++ src/game/SpellEffects.cpp | 5 +++++ src/game/Unit.cpp | 1 - src/shared/revision_nr.h | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 9f47254e4..648552d36 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1737,6 +1737,33 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,UnitList& TagUnitMap) TagUnitMap.push_back(pet); } } + if (m_spellInfo->Id==52759) //Ancestral Awakening (special target selection) + { + float lowestPerc = (float)m_caster->GetHealth() / (float)m_caster->GetMaxHealth(); + Unit* lowestTarget = m_caster; + + if (pGroup) + { + Group::MemberSlotList const& members = pGroup->GetMemberSlots(); + Group::MemberSlotList::const_iterator itr = members.begin(); + for(; itr != members.end(); ++itr) + { + if (Unit* member = ObjectAccessor::GetPlayer(*m_caster, (*itr).guid)) + { + if (member == m_caster || member->isDead() || m_caster->IsHostileTo(member) || !m_caster->IsWithinDistInMap(member, radius)) + continue; + + float perc = (float)member->GetHealth() / (float)member->GetMaxHealth(); + if (perc <= lowestPerc) + { + lowestPerc = perc; + lowestTarget = member; + } + } + } + } + TagUnitMap.push_back(lowestTarget); + } else { if(pGroup) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 06ebd13e9..2b5846e00 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1138,6 +1138,11 @@ void Spell::EffectDummy(uint32 i) } return; } + case 52759: // Ancestral Awakening + if (!unitTarget) + return; + m_caster->CastCustomSpell(unitTarget, 52752, &damage, NULL, NULL, true); + return; case 53341: case 53343: { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 70a76429e..1e4adbab1 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -5812,7 +5812,6 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu // Ancestral Awakening if (dummySpell->SpellIconID == 3065) { - // TODO: frite dummy fot triggered spell triggered_spell_id = 52759; basepoints0 = triggerAmount * damage / 100; target = this; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d762c9584..52a8002a7 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7875" + #define REVISION_NR "7876" #endif // __REVISION_NR_H__ From bc4611e8c0d0c5cbfca31dc1cf624b7874edd230 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Sat, 23 May 2009 00:30:18 +0400 Subject: [PATCH 11/11] [7877] Correctly set totem PvP state at loading and owner PvP state change, including GM totem case. * Also set PvP state in proper way at pet loading if owner in PvP state. --- src/game/Pet.cpp | 3 +++ src/game/Player.cpp | 22 ++++++++++------------ src/game/SpellEffects.cpp | 6 ++++++ src/game/Unit.cpp | 21 +++++++++++++++++++++ src/game/Unit.h | 8 +------- src/shared/revision_nr.h | 2 +- 6 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index df1efee88..20cd43335 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -211,6 +211,9 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool sLog.outError("Pet have incorrect type (%u) for pet loading.", getPetType()); } + if(owner->IsPvP()) + SetPvP(true); + InitStatsForLevel(petlevel); SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL)); SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, fields[5].GetUInt32()); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index bc1778a85..dd2282e74 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -2079,6 +2079,11 @@ void Player::SetGameMaster(bool on) pet->getHostilRefManager().setOnlineOfflineState(false); } + for (int8 i = 0; i < MAX_TOTEM; ++i) + if(m_TotemSlot[i]) + if(Creature *totem = GetMap()->GetCreature(m_TotemSlot[i])) + totem->setFaction(35); + RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); ResetContestedPvP(); @@ -2103,6 +2108,11 @@ void Player::SetGameMaster(bool on) pet->getHostilRefManager().setOnlineOfflineState(true); } + for (int8 i = 0; i < MAX_TOTEM; ++i) + if(m_TotemSlot[i]) + if(Creature *totem = GetMap()->GetCreature(m_TotemSlot[i])) + totem->setFaction(getFaction()); + // restore FFA PvP Server state if(sWorld.IsFFAPvPRealm()) SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); @@ -17371,11 +17381,6 @@ void Player::UpdatePvP(bool state, bool ovrride) if(!state || ovrride) { SetPvP(state); - if(Pet* pet = GetPet()) - pet->SetPvP(state); - if(Unit* charmed = GetCharm()) - charmed->SetPvP(state); - pvpInfo.endTimer = 0; } else @@ -17383,14 +17388,7 @@ void Player::UpdatePvP(bool state, bool ovrride) if(pvpInfo.endTimer != 0) pvpInfo.endTimer = time(NULL); else - { SetPvP(state); - - if(Pet* pet = GetPet()) - pet->SetPvP(state); - if(Unit* charmed = GetCharm()) - charmed->SetPvP(state); - } } } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 2b5846e00..6bf1a5330 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4181,6 +4181,9 @@ void Spell::EffectSummonPet(uint32 i) if(m_caster->GetTypeId() == TYPEID_PLAYER) NewSummon->SetUInt32Value(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); + if(m_caster->IsPvP()) + NewSummon->SetPvP(true); + NewSummon->InitStatsForLevel(petlevel); NewSummon->InitPetCreateSpells(); NewSummon->InitLevelupSpellsForLevel(); @@ -5515,6 +5518,9 @@ void Spell::EffectSummonTotem(uint32 i) if(m_caster->GetTypeId() == TYPEID_PLAYER) pTotem->SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_PVP_ATTACKABLE); + if(m_caster->IsPvP()) + pTotem->SetPvP(true); + pTotem->Summon(m_caster); if(slot < MAX_TOTEM && m_caster->GetTypeId() == TYPEID_PLAYER) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 1e4adbab1..685ca2e8d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -11398,6 +11398,9 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) if(GetTypeId()==TYPEID_PLAYER) pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); + if(IsPvP()) + pet->SetPvP(true); + uint32 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel(); if(!pet->InitStatsForLevel(level)) @@ -11602,3 +11605,21 @@ void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool ca SendMessageToSet(&data, false); } } + +void Unit::SetPvP( bool state ) +{ + if(state) + SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); + else + RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); + + if(Pet* pet = GetPet()) + pet->SetPvP(state); + if(Unit* charmed = GetCharm()) + charmed->SetPvP(state); + + for (int8 i = 0; i < MAX_TOTEM; ++i) + if(m_TotemSlot[i]) + if(Creature *totem = GetMap()->GetCreature(m_TotemSlot[i])) + totem->SetPvP(state); +} \ No newline at end of file diff --git a/src/game/Unit.h b/src/game/Unit.h index 4636c52ba..95507d23b 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -924,13 +924,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject return false; } bool IsPvP() const { return HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); } - void SetPvP(bool state) - { - if(state) - SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); - else - RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); - } + void SetPvP(bool state); uint32 GetCreatureType() const; uint32 GetCreatureTypeMask() const { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 52a8002a7..9b676ab15 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7876" + #define REVISION_NR "7877" #endif // __REVISION_NR_H__