From 959e7640e28249556278634a4bd08fdff6f2d068 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 4 Nov 2009 11:03:39 +0300 Subject: [PATCH 1/9] [8771] Fixed *nix build and small code cleanup. Thanks to balrok for reporting, and help in resolve/test. --- src/game/Mail.h | 23 +++++++++++++++++++++++ src/game/SharedDefines.h | 21 --------------------- src/shared/revision_nr.h | 2 +- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/game/Mail.h b/src/game/Mail.h index b46370e63..c704d406a 100644 --- a/src/game/Mail.h +++ b/src/game/Mail.h @@ -23,6 +23,8 @@ struct AuctionEntry; class Item; +class Object; +class Player; #define MAIL_BODY_ITEM_TEMPLATE 8383 // - plain letter, A Dusty Unsent Letter: 889 #define MAX_MAIL_ITEMS 12 @@ -36,6 +38,27 @@ enum MailMessageType MAIL_ITEM = 5, // client send CMSG_ITEM_QUERY on this mailmessagetype }; +enum MailCheckMask +{ + MAIL_CHECK_MASK_NONE = 0x00, + MAIL_CHECK_MASK_READ = 0x01, + MAIL_CHECK_MASK_AUCTION = 0x04, + MAIL_CHECK_MASK_COD_PAYMENT = 0x08, + MAIL_CHECK_MASK_RETURNED = 0x10 +}; + +// gathered from Stationery.dbc +enum MailStationery +{ + MAIL_STATIONERY_UNKNOWN = 1, + MAIL_STATIONERY_NORMAL = 41, + MAIL_STATIONERY_GM = 61, + MAIL_STATIONERY_AUCTION = 62, + MAIL_STATIONERY_VAL = 64, + MAIL_STATIONERY_CHR = 65, + MAIL_STATIONERY_ORP = 67, // new in 3.2.2 +}; + enum MailState { MAIL_STATE_UNCHANGED = 1, diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 279391595..c6ce091f5 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -2620,27 +2620,6 @@ enum BattleGroundTypeId }; #define MAX_BATTLEGROUND_TYPE_ID 33 -enum MailCheckMask -{ - MAIL_CHECK_MASK_NONE = 0x00, - MAIL_CHECK_MASK_READ = 0x01, - MAIL_CHECK_MASK_AUCTION = 0x04, - MAIL_CHECK_MASK_COD_PAYMENT = 0x08, - MAIL_CHECK_MASK_RETURNED = 0x10 -}; - -// gathered from Stationery.dbc -enum MailStationery -{ - MAIL_STATIONERY_UNKNOWN = 1, - MAIL_STATIONERY_NORMAL = 41, - MAIL_STATIONERY_GM = 61, - MAIL_STATIONERY_AUCTION = 62, - MAIL_STATIONERY_VAL = 64, - MAIL_STATIONERY_CHR = 65, - MAIL_STATIONERY_ORP = 67, // new in 3.2.2 -}; - enum MailResponseType { MAIL_SEND = 0, diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 24ab70cac..e336ad1d1 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 "8770" + #define REVISION_NR "8771" #endif // __REVISION_NR_H__ From 44fb72aeff516a26610a07827ec10420b9e8a988 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 4 Nov 2009 11:57:37 +0300 Subject: [PATCH 2/9] [8772] Prevent incomplete packer read spam at reject by another reason mail packet. --- src/game/Mail.cpp | 6 +++--- src/shared/revision_nr.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 24463acf8..282189636 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -270,11 +270,11 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket & recv_data ) uint64 mailbox; uint32 mailId; recv_data >> mailbox; + recv_data >> mailId; if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; - recv_data >> mailId; Player *pl = _player; Mail *m = pl->GetMail(mailId); if (m) @@ -381,12 +381,12 @@ void WorldSession::HandleMailTakeItem(WorldPacket & recv_data ) uint32 mailId; uint32 itemId; recv_data >> mailbox; + recv_data >> mailId; + recv_data >> itemId; // item guid low if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX)) return; - recv_data >> mailId; - recv_data >> itemId; // item guid low? Player* pl = _player; Mail* m = pl->GetMail(mailId); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e336ad1d1..7693cc68b 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 "8771" + #define REVISION_NR "8772" #endif // __REVISION_NR_H__ From 6b1e76a150c44a96473ffb7730988ee6c753116d Mon Sep 17 00:00:00 2001 From: unik Date: Wed, 4 Nov 2009 16:22:23 +0300 Subject: [PATCH 3/9] [8773] Prevent counter overflow in mail list oacket sent to client. Signed-off-by: VladimirMangos --- src/game/Mail.cpp | 7 +++++++ src/shared/revision_nr.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 282189636..c2bd28d4a 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -529,6 +529,13 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data ) for(PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr) { + // packet send mail count as uint8, prevent overflow + if(mailsCount >= 254) + { + realCount += 1; + continue; + } + // skip deleted or not delivered (deliver delay not expired) mails if ((*itr)->state == MAIL_STATE_DELETED || cur_time < (*itr)->deliver_time) continue; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7693cc68b..33236e307 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 "8772" + #define REVISION_NR "8773" #endif // __REVISION_NR_H__ From adde82b73c38a5f8ae913f2903c10eef1f8d5edd Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Wed, 4 Nov 2009 17:44:32 +0100 Subject: [PATCH 4/9] [8774] Implement SCRIPT_COMMAND_KILL_CREDIT (8). Signed-off-by: NoFantasy --- src/game/Map.cpp | 30 ++++++++++++++++++++++++++++++ src/game/ObjectMgr.cpp | 10 ++++++++++ src/game/World.h | 1 + src/shared/revision_nr.h | 2 +- 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 83a367cfd..8915069ff 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -2988,6 +2988,36 @@ void Map::ScriptsProcess() break; } + case SCRIPT_COMMAND_KILL_CREDIT: + { + // accept player in any one from target/source arg + if (!target && !source) + { + sLog.outError("SCRIPT_COMMAND_KILL_CREDIT call for NULL object."); + break; + } + + // must be only Player + if((!target || target->GetTypeId() != TYPEID_PLAYER) && (!source || source->GetTypeId() != TYPEID_PLAYER)) + { + sLog.outError("SCRIPT_COMMAND_KILL_CREDIT call for non-player (TypeIdSource: %u)(TypeIdTarget: %u), skipping.", source ? source->GetTypeId() : 0, target ? target->GetTypeId() : 0); + break; + } + + Player* pSource = target && target->GetTypeId() == TYPEID_PLAYER ? (Player*)target : (Player*)source; + + if (step.script->datalong2) + { + pSource->RewardPlayerAndGroupAtEvent(step.script->datalong, pSource); + } + else + { + pSource->KilledMonsterCredit(step.script->datalong, 0); + } + + break; + } + case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE: { if(!step.script->datalong) // creature not specified diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index f8f087ab1..d330bffb6 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -4100,6 +4100,16 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename) break; } + case SCRIPT_COMMAND_KILL_CREDIT: + { + if (!GetCreatureTemplate(tmp.datalong)) + { + sLog.outErrorDb("Table `%s` has invalid creature (Entry: %u) in SCRIPT_COMMAND_KILL_CREDIT for script id %u",tablename,tmp.datalong,tmp.id); + continue; + } + break; + } + case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE: { if(!MaNGOS::IsValidMapCoord(tmp.x,tmp.y,tmp.z,tmp.o)) diff --git a/src/game/World.h b/src/game/World.h index fd8fa61b0..74c897ad6 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -343,6 +343,7 @@ enum RealmZone #define SCRIPT_COMMAND_FLAG_REMOVE 5 // source = any, datalong = field_id, datalog2 = bitmask #define SCRIPT_COMMAND_TELEPORT_TO 6 // source or target with Player, datalong = map_id, x/y/z #define SCRIPT_COMMAND_QUEST_EXPLORED 7 // one from source or target must be Player, another GO/Creature, datalong=quest_id, datalong2=distance or 0 +#define SCRIPT_COMMAND_KILL_CREDIT 8 // source or target with Player, datalong = creature entry, datalong2 = bool (0=personal credit, 1=group credit) #define SCRIPT_COMMAND_RESPAWN_GAMEOBJECT 9 // source = any (summoner), datalong=db_guid, datalong2=despawn_delay #define SCRIPT_COMMAND_TEMP_SUMMON_CREATURE 10 // source = any (summoner), datalong=creature entry, datalong2=despawn_delay #define SCRIPT_COMMAND_OPEN_DOOR 11 // source = unit, datalong=db_guid, datalong2=reset_delay diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 33236e307..fe3e6b733 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 "8773" + #define REVISION_NR "8774" #endif // __REVISION_NR_H__ From c50df41b3ce3b270b5c6ff2424562ee1beb626a6 Mon Sep 17 00:00:00 2001 From: balrok Date: Thu, 5 Nov 2009 10:22:10 +0100 Subject: [PATCH 5/9] [8775] implement all creature difficulties + support bgs with this former know as heroic_entry we now have 3 of those which let us chose different creature_templates for different map-types normal maps will need a bit more support to use correct spawnmodes but for battlegrounds it works already good: they are divided by levelrange: 0-59 == normal spawn -> spiritguides level 60 60-69 == difficulty=1 -> spritiguides level 70 70-79 == difficulty=2 -> spiritguides level 80 80 == difficulty=3 -> spiritguides level 80 this is needed mostly for alterac valley to get right creature-templates spawned and with that all creature->SetLevel hacks could get removed from alterac valley code --- sql/mangos.sql | 4 +- .../8775_01_mangos_creature_template.sql | 6 ++ sql/updates/8775_02_mangos_creature.sql | 10 ++ sql/updates/8775_03_mangos_gameobject.sql | 6 ++ sql/updates/Makefile.am | 6 ++ src/game/BattleGround.h | 8 +- src/game/BattleGroundAV.cpp | 17 ---- src/game/BattleGroundAV.h | 2 - src/game/Creature.cpp | 23 ++--- src/game/Creature.h | 2 +- src/game/Map.cpp | 4 +- src/game/Map.h | 2 +- src/game/MapInstanced.cpp | 6 +- src/game/MapManager.cpp | 2 +- src/game/ObjectMgr.cpp | 97 ++++++++++++------- src/shared/Database/SQLStorage.cpp | 4 +- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 18 files changed, 121 insertions(+), 82 deletions(-) create mode 100644 sql/updates/8775_01_mangos_creature_template.sql create mode 100644 sql/updates/8775_02_mangos_creature.sql create mode 100644 sql/updates/8775_03_mangos_gameobject.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 96c8df0b6..0852b744b 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_8770_01_mangos_quest_template` bit(1) default NULL + `required_8775_03_mangos_gameobject` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -1062,6 +1062,8 @@ DROP TABLE IF EXISTS `creature_template`; CREATE TABLE `creature_template` ( `entry` mediumint(8) unsigned NOT NULL default '0', `difficulty_entry_1` mediumint(8) unsigned NOT NULL default '0', + `difficulty_entry_2` mediumint(8) unsigned NOT NULL default '0', + `difficulty_entry_3` mediumint(8) unsigned NOT NULL default '0', `KillCredit1` int(11) unsigned NOT NULL default '0', `KillCredit2` int(11) unsigned NOT NULL default '0', `modelid_A` mediumint(8) unsigned NOT NULL default '0', diff --git a/sql/updates/8775_01_mangos_creature_template.sql b/sql/updates/8775_01_mangos_creature_template.sql new file mode 100644 index 000000000..abd6ec546 --- /dev/null +++ b/sql/updates/8775_01_mangos_creature_template.sql @@ -0,0 +1,6 @@ +ALTER TABLE db_version CHANGE COLUMN required_8770_01_mangos_quest_template required_8775_01_mangos_creature_template bit; + +ALTER TABLE `creature_template` ADD `difficulty_entry_2` MEDIUMINT(8) unsigned + NOT NULL default 0 AFTER `difficulty_entry_1`; +ALTER TABLE `creature_template` ADD `difficulty_entry_3` MEDIUMINT(8) unsigned + NOT NULL default 0 AFTER `difficulty_entry_2`; diff --git a/sql/updates/8775_02_mangos_creature.sql b/sql/updates/8775_02_mangos_creature.sql new file mode 100644 index 000000000..0f6d5a00a --- /dev/null +++ b/sql/updates/8775_02_mangos_creature.sql @@ -0,0 +1,10 @@ +ALTER TABLE db_version CHANGE COLUMN required_8775_01_mangos_creature_template required_8775_02_mangos_creature bit; + +-- cause bgs now have different spawnmodes all creatures on those maps must go +-- to all spwanmodes.. maybe this isn't valid for all creatures - but i won't +-- destroy again all bgs :p +-- 0x1 = 2^0 - normal +-- 0x2 = 2^1 - difficulty_1 +-- 0x4 = 2^2 - difficulty_2 +-- 0x8 = 2^3 - difficulty_3 +UPDATE creature SET spawnMask = (0x1 | 0x2 | 0x4 | 0x8) WHERE map IN (30, 489, 529, 566); diff --git a/sql/updates/8775_03_mangos_gameobject.sql b/sql/updates/8775_03_mangos_gameobject.sql new file mode 100644 index 000000000..3b7ea4e9e --- /dev/null +++ b/sql/updates/8775_03_mangos_gameobject.sql @@ -0,0 +1,6 @@ +ALTER TABLE db_version CHANGE COLUMN required_8775_02_mangos_creature required_8775_03_mangos_gameobject bit; + +-- cause bgs now have different spawnmodes all gameobjects on those maps must go +-- to all spwanmodes.. maybe this isn't valid for all gameobjects - but i won't +-- destroy again all bgs :p +UPDATE gameobject SET spawnMask = (0x1 | 0x2 | 0x4 | 0x8) WHERE map IN (30, 489, 529, 566); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index a023a3bc4..f0c9cec0e 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -148,6 +148,9 @@ pkgdata_DATA = \ 8749_01_mangos_mail_loot_template.sql \ 8769_01_mangos_mail_level_reward.sql \ 8770_01_mangos_quest_template.sql \ + 8775_01_mangos_creature_template.sql \ + 8775_02_mangos_creature.sql \ + 8775_03_mangos_gameobject.sql \ README ## Additional files to include when running 'make dist' @@ -276,4 +279,7 @@ EXTRA_DIST = \ 8749_01_mangos_mail_loot_template.sql \ 8769_01_mangos_mail_level_reward.sql \ 8770_01_mangos_quest_template.sql \ + 8775_01_mangos_creature_template.sql \ + 8775_02_mangos_creature.sql \ + 8775_03_mangos_gameobject.sql \ README diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index 31eab6392..d35e11400 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -492,11 +492,10 @@ class BattleGround // can be extended in in BG subclass /* event related */ - // generic implementation in BattleGround-class // called when a creature gets added to map (NOTE: only triggered if // a player activates the cell of the creature) - virtual void OnObjectDBLoad(Creature* /*creature*/); - virtual void OnObjectDBLoad(GameObject* /*obj*/); + void OnObjectDBLoad(Creature* /*creature*/); + void OnObjectDBLoad(GameObject* /*obj*/); // (de-)spawns creatures and gameobjects from an event void SpawnEvent(uint8 event1, uint8 event2, bool spawn); bool IsActiveEvent(uint8 event1, uint8 event2) @@ -510,9 +509,6 @@ class BattleGround void OpenDoorEvent(uint8 event1, uint8 event2 = 0); bool IsDoor(uint8 event1, uint8 event2); - /* other things */ - virtual void OnCreatureRespawn(Creature* /*creature*/) {} - void HandleTriggerBuff(uint64 const& go_guid); // TODO: make this protected: diff --git a/src/game/BattleGroundAV.cpp b/src/game/BattleGroundAV.cpp index e0e7f7198..dc4b3e5a9 100644 --- a/src/game/BattleGroundAV.cpp +++ b/src/game/BattleGroundAV.cpp @@ -232,23 +232,6 @@ void BattleGroundAV::UpdateScore(BattleGroundTeamId team, int32 points ) UpdateWorldState(((team == BG_TEAM_HORDE) ? BG_AV_Horde_Score : BG_AV_Alliance_Score), m_TeamScores[team]); } -void BattleGroundAV::OnObjectDBLoad(Creature* creature) -{ - uint32 level = creature->getLevel(); - if (level != 0) - level += GetMaxLevel() - 60; // maybe we can do this more generic for custom level - range.. actually it's ok - creature->SetLevel(level); - BattleGround::OnObjectDBLoad(creature); -} - -void BattleGroundAV::OnCreatureRespawn(Creature* creature) -{ - uint32 level = creature->getLevel(); - if (level != 0) - level += GetMaxLevel() - 60; // maybe we can do this more generic for custom level - range.. actually it's ok - creature->SetLevel(level); -} - void BattleGroundAV::Update(uint32 diff) { BattleGround::Update(diff); diff --git a/src/game/BattleGroundAV.h b/src/game/BattleGroundAV.h index 353318344..c62060cd8 100644 --- a/src/game/BattleGroundAV.h +++ b/src/game/BattleGroundAV.h @@ -308,8 +308,6 @@ class BattleGroundAV : public BattleGround /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); - virtual void OnObjectDBLoad(Creature* creature); - virtual void OnCreatureRespawn(Creature* creature); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index d2d2e9357..48215ef84 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -191,17 +191,21 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data ) // get difficulty 1 mode entry uint32 actualEntry = Entry; CreatureInfo const *cinfo = normalInfo; - if(normalInfo->DifficultyEntry1) + // TODO correctly implement spawnmodes for non-bg maps + for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1; ++diff) { - //we already have valid Map pointer for current creature! - //FIXME: spawn modes 2-3 must have own case DifficultyEntryN - if(GetMap()->GetSpawnMode() > 0) + if (normalInfo->DifficultyEntry[diff]) { - cinfo = objmgr.GetCreatureTemplate(normalInfo->DifficultyEntry1); - if(!cinfo) + // we already have valid Map pointer for current creature! + if (GetMap()->GetSpawnMode() > diff) { - sLog.outErrorDb("Creature::UpdateEntry creature difficulty 1 entry %u does not exist.", actualEntry); - return false; + cinfo = objmgr.GetCreatureTemplate(normalInfo->DifficultyEntry[diff]); + if (!cinfo) + { + // maybe check such things already at startup + sLog.outErrorDb("Creature::UpdateEntry creature difficulty %u entry %u does not exist.", diff + 1, actualEntry); + return false; + } } } } @@ -362,9 +366,6 @@ void Creature::Update(uint32 diff) else setDeathState( JUST_ALIVED ); - if (GetMap()->IsBattleGround() && ((BattleGroundMap*)GetMap())->GetBG()) - ((BattleGroundMap*)GetMap())->GetBG()->OnCreatureRespawn(this); // for alterac valley needed to adjust the correct level again - //Call AI respawn virtual function i_AI->JustRespawned(); diff --git a/src/game/Creature.h b/src/game/Creature.h index cea73e59f..6ec94ec29 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -158,7 +158,7 @@ enum CreatureFlagsExtra struct CreatureInfo { uint32 Entry; - uint32 DifficultyEntry1; + uint32 DifficultyEntry[MAX_DIFFICULTY - 1]; uint32 KillCredit[MAX_KILL_CREDIT]; uint32 DisplayID_A[2]; uint32 DisplayID_H[2]; diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 8915069ff..d6b21f7c0 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -2628,8 +2628,8 @@ uint32 InstanceMap::GetMaxPlayers() const /* ******* Battleground Instance Maps ******* */ -BattleGroundMap::BattleGroundMap(uint32 id, time_t expiry, uint32 InstanceId, Map* _parent) - : Map(id, expiry, InstanceId, DUNGEON_DIFFICULTY_NORMAL, _parent) +BattleGroundMap::BattleGroundMap(uint32 id, time_t expiry, uint32 InstanceId, Map* _parent, uint8 spawnMode) + : Map(id, expiry, InstanceId, spawnMode, _parent) { //lets initialize visibility distance for BG/Arenas BattleGroundMap::InitVisibilityDistance(); diff --git a/src/game/Map.h b/src/game/Map.h index 569231368..849efcb8b 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -612,7 +612,7 @@ class MANGOS_DLL_SPEC InstanceMap : public Map class MANGOS_DLL_SPEC BattleGroundMap : public Map { public: - BattleGroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent); + BattleGroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent, uint8 spawnMode); ~BattleGroundMap(); bool Add(Player *); diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp index 852486ddf..b308e63a8 100644 --- a/src/game/MapInstanced.cpp +++ b/src/game/MapInstanced.cpp @@ -24,7 +24,7 @@ #include "InstanceSaveMgr.h" #include "World.h" -MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, 0) +MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, DUNGEON_DIFFICULTY_NORMAL) { // initialize instanced maps list m_InstancedMaps.clear(); @@ -216,7 +216,9 @@ BattleGroundMap* MapInstanced::CreateBattleGroundMap(uint32 InstanceId, BattleGr sLog.outDebug("MapInstanced::CreateBattleGroundMap: instance:%d for map:%d and bgType:%d created.", InstanceId, GetId(), bg->GetTypeID()); - BattleGroundMap *map = new BattleGroundMap(GetId(), GetGridExpiry(), InstanceId, this); + // 0-59 normal spawn 60-69 difficulty_1, 70-79 difficulty_2, 80 dufficulty_3 + uint8 spawnMode = (bg->GetQueueId() > QUEUE_ID_MAX_LEVEL_59) ? (bg->GetQueueId() - QUEUE_ID_MAX_LEVEL_59) : 0; + BattleGroundMap *map = new BattleGroundMap(GetId(), GetGridExpiry(), InstanceId, this, spawnMode); ASSERT(map->IsBattleGroundOrArena()); map->SetBG(bg); bg->SetBgMap(map); diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index 7e83ee061..00924cad9 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -118,7 +118,7 @@ MapManager::_createBaseMap(uint32 id) } else { - m = new Map(id, i_gridCleanUpDelay, 0, 0); + m = new Map(id, i_gridCleanUpDelay, 0, DUNGEON_DIFFICULTY_NORMAL); } i_maps[id] = m; } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index d330bffb6..cc1e07962 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -473,8 +473,8 @@ void ObjectMgr::LoadCreatureTemplates() sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount ); sLog.outString(); - std::set difficultyEntries1; // already loaded difficulty 1 value in creatures - std::set hasDifficultyEntries1; // already loaded creatures with difficulty 1 values + std::set difficultyEntries[MAX_DIFFICULTY - 1]; // already loaded difficulty 1 value in creatures + std::set hasDifficultyEntries[MAX_DIFFICULTY - 1]; // already loaded creatures with difficulty 1 values // check data correctness for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) @@ -483,84 +483,105 @@ void ObjectMgr::LoadCreatureTemplates() if (!cInfo) continue; - if (cInfo->DifficultyEntry1) + bool ok = true; // bool to allow continue outside this loop + for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff) { - CreatureInfo const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry1); + if (!cInfo->DifficultyEntry[diff]) + continue; + ok = false; // will be set to true at the end of this loop again + + CreatureInfo const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry[diff]); if (!difficultyInfo) { - sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_1`=%u but creature entry %u not exist.", i, cInfo->DifficultyEntry1, cInfo->DifficultyEntry1); + sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_%u`=%u but creature entry %u not exist.", + i, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff]); continue; } - if (difficultyEntries1.find(i)!=difficultyEntries1.end()) + if (difficultyEntries[diff].find(i) != difficultyEntries[diff].end()) { - sLog.outErrorDb("Creature (Entry: %u) listed as difficulty 1 but have value in `difficulty_entry_1`.",i); + sLog.outErrorDb("Creature (Entry: %u) listed as difficulty %u but have value in `difficulty_entry_1`.", i, diff + 1); continue; } - if (difficultyEntries1.find(cInfo->DifficultyEntry1)!=difficultyEntries1.end()) + bool ok2 = true; + for (uint32 diff2 = 0; diff2 < MAX_DIFFICULTY - 1 && ok2; ++diff2) { - sLog.outErrorDb("Creature (Entry: %u) already listed as difficulty 1 for another entry.",cInfo->DifficultyEntry1); - continue; - } + ok2 = false; + if (difficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != difficultyEntries[diff2].end()) + { + sLog.outErrorDb("Creature (Entry: %u) already listed as difficulty %u for another entry.", cInfo->DifficultyEntry[diff], diff2 + 1); + continue; + } - if (hasDifficultyEntries1.find(cInfo->DifficultyEntry1)!=hasDifficultyEntries1.end()) - { - sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_1`=%u but creature entry %u have difficulty 1 entry also.",i,cInfo->DifficultyEntry1,cInfo->DifficultyEntry1); - continue; + if (hasDifficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != hasDifficultyEntries[diff2].end()) + { + sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_%u`=%u but creature entry %u have difficulty %u entry also.", + i, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff], diff2 + 1); + continue; + } + ok2 = true; } + if (!ok2) + continue; if (cInfo->unit_class != difficultyInfo->unit_class) { - sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in difficulty 1 mode (Entry: %u, class %u).",i, cInfo->unit_class, cInfo->DifficultyEntry1, difficultyInfo->unit_class); + sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in difficulty %u mode (Entry: %u, class %u).", + i, cInfo->unit_class, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->unit_class); continue; } if (cInfo->npcflag != difficultyInfo->npcflag) { - sLog.outErrorDb("Creature (Entry: %u) has different `npcflag` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1); + sLog.outErrorDb("Creature (Entry: %u) has different `npcflag` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]); continue; } if (cInfo->trainer_class != difficultyInfo->trainer_class) { - sLog.outErrorDb("Creature (Entry: %u) has different `trainer_class` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1); + sLog.outErrorDb("Creature (Entry: %u) has different `trainer_class` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]); continue; } if (cInfo->trainer_race != difficultyInfo->trainer_race) { - sLog.outErrorDb("Creature (Entry: %u) has different `trainer_race` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1); + sLog.outErrorDb("Creature (Entry: %u) has different `trainer_race` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]); continue; } if (cInfo->trainer_type != difficultyInfo->trainer_type) { - sLog.outErrorDb("Creature (Entry: %u) has different `trainer_type` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1); + sLog.outErrorDb("Creature (Entry: %u) has different `trainer_type` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]); continue; } if (cInfo->trainer_spell != difficultyInfo->trainer_spell) { - sLog.outErrorDb("Creature (Entry: %u) has different `trainer_spell` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1); + sLog.outErrorDb("Creature (Entry: %u) has different `trainer_spell` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]); continue; } if (difficultyInfo->AIName && *difficultyInfo->AIName) { - sLog.outErrorDb("Difficulty 1 mode creature (Entry: %u) has `AIName`, but in any case will used difficulty 0 mode creature (Entry: %u) AIName.",cInfo->DifficultyEntry1,i); + sLog.outErrorDb("Difficulty %u mode creature (Entry: %u) has `AIName`, but in any case will used difficulty 0 mode creature (Entry: %u) AIName.", + diff, cInfo->DifficultyEntry[diff], i); continue; } if (difficultyInfo->ScriptID) { - sLog.outErrorDb("Difficulty 1 mode creature (Entry: %u) has `ScriptName`, but in any case will used difficulty 0 mode creature (Entry: %u) ScriptName.",cInfo->DifficultyEntry1,i); + sLog.outErrorDb("Difficulty %u mode creature (Entry: %u) has `ScriptName`, but in any case will used difficulty 0 mode creature (Entry: %u) ScriptName.", + diff, cInfo->DifficultyEntry[diff], i); continue; } - hasDifficultyEntries1.insert(i); - difficultyEntries1.insert(cInfo->DifficultyEntry1); + hasDifficultyEntries[diff].insert(i); + difficultyEntries[diff].insert(cInfo->DifficultyEntry[diff]); + ok = true; } + if (!ok) + continue; FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_A); if (!factionTemplate) @@ -1032,11 +1053,12 @@ void ObjectMgr::LoadCreatures() } // build single time for check creature data - std::set difficultyCreatures1; - for(uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i) - if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) - if(cInfo->DifficultyEntry1) - difficultyCreatures1.insert(cInfo->DifficultyEntry1); + std::set difficultyCreatures[MAX_DIFFICULTY - 1]; + for (uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i) + if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) + for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1; ++diff) + if (cInfo->DifficultyEntry[diff]) + difficultyCreatures[diff].insert(cInfo->DifficultyEntry[diff]); // build single time for check spawnmask std::map spawnMasks; @@ -1095,11 +1117,18 @@ void ObjectMgr::LoadCreatures() if (data.spawnMask & ~spawnMasks[data.mapid]) sLog.outErrorDb("Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).",guid, data.spawnMask, data.mapid ); - if(difficultyCreatures1.find(data.id)!=difficultyCreatures1.end()) + bool ok = true; + for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as difficulty 1 template (entry: %u) in `creature_template`, skipped.",guid, data.id ); - continue; + if (difficultyCreatures[diff].find(data.id) != difficultyCreatures[diff].end()) + { + sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as difficulty %u template (entry: %u) in `creature_template`, skipped.", + guid, diff + 1, data.id ); + ok = false; + } } + if (!ok) + continue; if(data.equipmentId > 0) // -1 no equipment, 0 use default { @@ -3191,7 +3220,7 @@ void ObjectMgr::LoadGroups() uint32 diff = fields[4].GetUInt8(); if(diff >= (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)) { - sLog.outErrorDb("Wrong dungeon difficulty use in group_instance table: %d", diff); + sLog.outErrorDb("Wrong dungeon difficulty use in group_instance table: %d", diff + 1); diff = 0; // default for both difficaly types } diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index 2cf69db0f..e48f45cf9 100644 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -25,8 +25,8 @@ extern DatabasePostgre WorldDatabase; extern DatabaseMysql WorldDatabase; #endif -const char CreatureInfosrcfmt[]="iiiiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiis"; -const char CreatureInfodstfmt[]="iiiiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiii"; +const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiis"; +const char CreatureInfodstfmt[]="iiiiiiiiiisssiiiiiiiiiiffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiii"; const char CreatureDataAddonInfofmt[]="iiiiiis"; const char CreatureModelfmt[]="iffbi"; const char CreatureInfoAddonInfofmt[]="iiiiiis"; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index fe3e6b733..a5f76519a 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 "8774" + #define REVISION_NR "8775" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index b658c51c9..9259b292d 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_8721_01_characters_guild" - #define REVISION_DB_MANGOS "required_8770_01_mangos_quest_template" + #define REVISION_DB_MANGOS "required_8775_03_mangos_gameobject" #define REVISION_DB_REALMD "required_8728_01_realmd_account" #endif // __REVISION_SQL_H__ From 63951591fddc692c20c473971078abaa344c1c63 Mon Sep 17 00:00:00 2001 From: danielich Date: Thu, 5 Nov 2009 10:59:32 +0100 Subject: [PATCH 6/9] [8776] proper arena rating calculation the elo-formula has K=48 for rating<1000 an K=32 for rating>1000 also set the rating of new members to 0 if they join a team with rating <1000 --- src/game/ArenaTeam.cpp | 28 ++++++++++++++++++---------- src/shared/revision_nr.h | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index 891ce63c3..4fe4fcb2c 100644 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -136,7 +136,7 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid) if (sWorld.getConfig(CONFIG_ARENA_SEASON_ID) >= 6) { if (m_stats.rating < 1000) - newmember.personal_rating = m_stats.rating; + newmember.personal_rating = 0; else newmember.personal_rating = 1000; } @@ -513,8 +513,8 @@ float ArenaTeam::GetChanceAgainst(uint32 own_rating, uint32 enemy_rating) // ELO system if (sWorld.getConfig(CONFIG_ARENA_SEASON_ID) >= 6) - if (enemy_rating < 1500) - enemy_rating = 1500; + if (enemy_rating < 1000) + enemy_rating = 1000; return 1.0f/(1.0f+exp(log(10.0f)*(float)((float)enemy_rating - (float)own_rating)/400.0f)); } @@ -542,8 +542,9 @@ int32 ArenaTeam::WonAgainst(uint32 againstRating) // called when the team has won // 'chance' calculation - to beat the opponent float chance = GetChanceAgainst(m_stats.rating, againstRating); - // calculate the rating modification (ELO system with k=32) - int32 mod = (int32)floor(32.0f * (1.0f - chance)); + float K = (m_stats.rating < 1000) ? 48.0f : 32.0f; + // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000) + int32 mod = (int32)floor(K* (1.0f - chance)); // modify the team stats accordingly FinishGame(mod); m_stats.wins_week += 1; @@ -558,8 +559,9 @@ int32 ArenaTeam::LostAgainst(uint32 againstRating) // called when the team has lost //'chance' calculation - to loose to the opponent float chance = GetChanceAgainst(m_stats.rating, againstRating); - // calculate the rating modification (ELO system with k=32) - int32 mod = (int32)ceil(32.0f * (0.0f - chance)); + float K = (m_stats.rating < 1000) ? 48.0f : 32.0f; + // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000) + int32 mod = (int32)floor(K* (1.0f - chance)); // modify the team stats accordingly FinishGame(mod); @@ -576,7 +578,9 @@ void ArenaTeam::MemberLost(Player * plr, uint32 againstRating) { // update personal rating float chance = GetChanceAgainst(itr->personal_rating, againstRating); - int32 mod = (int32)ceil(32.0f * (0.0f - chance)); + float K = (m_stats.rating < 1000) ? 48.0f : 32.0f; + // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000) + int32 mod = (int32)floor(K* (1.0f - chance)); itr->ModifyPersonalRating(plr, mod, GetSlot()); // update personal played stats itr->games_week += 1; @@ -598,7 +602,9 @@ void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstRating) { // update personal rating float chance = GetChanceAgainst(itr->personal_rating, againstRating); - int32 mod = (int32)ceil(32.0f * (0.0f - chance)); + float K = (m_stats.rating < 1000) ? 48.0f : 32.0f; + // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000) + int32 mod = (int32)floor(K* (1.0f - chance)); if (int32(itr->personal_rating) + mod < 0) itr->personal_rating = 0; else @@ -620,7 +626,9 @@ void ArenaTeam::MemberWon(Player * plr, uint32 againstRating) { // update personal rating float chance = GetChanceAgainst(itr->personal_rating, againstRating); - int32 mod = (int32)floor(32.0f * (1.0f - chance)); + float K = (m_stats.rating < 1000) ? 48.0f : 32.0f; + // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000) + int32 mod = (int32)floor(K* (1.0f - chance)); itr->ModifyPersonalRating(plr, mod, GetSlot()); // update personal stats itr->games_week += 1; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a5f76519a..28b964037 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 "8775" + #define REVISION_NR "8776" #endif // __REVISION_NR_H__ From 500858b7897676de3b6dcecadffb1fd01987e2b5 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 5 Nov 2009 14:11:30 +0300 Subject: [PATCH 7/9] [8777] Fixed spawn mask to correct after recent commits for BG maps. --- sql/mangos.sql | 2 +- sql/updates/8777_01_mangos_creature.sql | 4 ++++ sql/updates/8777_02_mangos_gameobject.sql | 4 ++++ sql/updates/Makefile.am | 4 ++++ src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 6 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 sql/updates/8777_01_mangos_creature.sql create mode 100644 sql/updates/8777_02_mangos_gameobject.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 0852b744b..519f93e6f 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_8775_03_mangos_gameobject` bit(1) default NULL + `required_8777_02_mangos_gameobject` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- diff --git a/sql/updates/8777_01_mangos_creature.sql b/sql/updates/8777_01_mangos_creature.sql new file mode 100644 index 000000000..10d0500cf --- /dev/null +++ b/sql/updates/8777_01_mangos_creature.sql @@ -0,0 +1,4 @@ +ALTER TABLE db_version CHANGE COLUMN required_8775_03_mangos_gameobject required_8777_01_mangos_creature bit; + +UPDATE creature SET spawnMask = 0x1 WHERE map IN (489, 529, 566); +UPDATE creature SET spawnMask = (0x1 | 0x2 | 0x4) WHERE map IN (30); diff --git a/sql/updates/8777_02_mangos_gameobject.sql b/sql/updates/8777_02_mangos_gameobject.sql new file mode 100644 index 000000000..7b0fc0ba3 --- /dev/null +++ b/sql/updates/8777_02_mangos_gameobject.sql @@ -0,0 +1,4 @@ +ALTER TABLE db_version CHANGE COLUMN required_8777_01_mangos_creature required_8777_02_mangos_gameobject bit; + +UPDATE gameobject SET spawnMask = 0x1 WHERE map IN (489, 529, 566); +UPDATE gameobject SET spawnMask = (0x1 | 0x2 | 0x4) WHERE map IN (30); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index f0c9cec0e..cbb47eae8 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -151,6 +151,8 @@ pkgdata_DATA = \ 8775_01_mangos_creature_template.sql \ 8775_02_mangos_creature.sql \ 8775_03_mangos_gameobject.sql \ + 8777_01_mangos_creature.sql \ + 8777_02_mangos_gameobject.sql \ README ## Additional files to include when running 'make dist' @@ -282,4 +284,6 @@ EXTRA_DIST = \ 8775_01_mangos_creature_template.sql \ 8775_02_mangos_creature.sql \ 8775_03_mangos_gameobject.sql \ + 8777_01_mangos_creature.sql \ + 8777_02_mangos_gameobject.sql \ README diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 28b964037..20591613f 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 "8776" + #define REVISION_NR "8777" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 9259b292d..f748d660a 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_8721_01_characters_guild" - #define REVISION_DB_MANGOS "required_8775_03_mangos_gameobject" + #define REVISION_DB_MANGOS "required_8777_02_mangos_gameobject" #define REVISION_DB_REALMD "required_8728_01_realmd_account" #endif // __REVISION_SQL_H__ From a6d245058d8b3af5692ea8d5b7fd9c951a66eeef Mon Sep 17 00:00:00 2001 From: balrok Date: Thu, 5 Nov 2009 13:24:44 +0100 Subject: [PATCH 8/9] [8778] corrected bg-spawnmodes based on dbc-data so it seems, that the difficulty-level isn't implemented for all battlegrounds (in fact only for alterac valley) we now set the difficulty level based on queue-id and then go down to the highest difficulty-level possible for this map big thx to vladimir for information and help with code :) --- src/game/MapInstanced.cpp | 3 +++ src/shared/revision_nr.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp index b308e63a8..d59a0b3cc 100644 --- a/src/game/MapInstanced.cpp +++ b/src/game/MapInstanced.cpp @@ -218,6 +218,9 @@ BattleGroundMap* MapInstanced::CreateBattleGroundMap(uint32 InstanceId, BattleGr // 0-59 normal spawn 60-69 difficulty_1, 70-79 difficulty_2, 80 dufficulty_3 uint8 spawnMode = (bg->GetQueueId() > QUEUE_ID_MAX_LEVEL_59) ? (bg->GetQueueId() - QUEUE_ID_MAX_LEVEL_59) : 0; + // some bgs don't have different spawnmodes, with this we can stay close to dbc-data + while (!GetMapDifficultyData(GetId(), Difficulty(spawnMode))) + spawnMode--; BattleGroundMap *map = new BattleGroundMap(GetId(), GetGridExpiry(), InstanceId, this, spawnMode); ASSERT(map->IsBattleGroundOrArena()); map->SetBG(bg); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 20591613f..c3180d79d 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 "8777" + #define REVISION_NR "8778" #endif // __REVISION_NR_H__ From d594a29af193c49ca5ee76cc6a5d6f49841494d3 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 6 Nov 2009 02:34:49 +0300 Subject: [PATCH 9/9] [8779] Not output error at empty item loot for mail template at mail creating. --- src/game/Creature.cpp | 14 +++++++------- src/game/GameObject.cpp | 6 ++---- src/game/LootMgr.cpp | 11 +++++++---- src/game/LootMgr.h | 2 +- src/game/Mail.cpp | 3 ++- src/shared/revision_nr.h | 2 +- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 48215ef84..7ef4f89ae 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1526,29 +1526,29 @@ float Creature::GetAttackDistance(Unit const* pl) const void Creature::setDeathState(DeathState s) { - if((s == JUST_DIED && !m_isDeadByDefault)||(s == JUST_ALIVED && m_isDeadByDefault)) + if ((s == JUST_DIED && !m_isDeadByDefault)||(s == JUST_ALIVED && m_isDeadByDefault)) { m_deathTimer = m_corpseDelay*IN_MILISECONDS; // always save boss respawn time at death to prevent crash cheating - if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss()) + if (sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss()) SaveRespawnTime(); if (canFly() && FallGround()) return; - if(!IsStopped()) + if (!IsStopped()) StopMoving(); } Unit::setDeathState(s); - if(s == JUST_DIED) + if (s == JUST_DIED) { SetTargetGUID(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState) SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); - if(!isPet() && GetCreatureInfo()->SkinLootId) - if ( LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId) ) + if (!isPet() && GetCreatureInfo()->SkinLootId) + if (LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId)) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); if (canFly() && FallGround()) @@ -1557,7 +1557,7 @@ void Creature::setDeathState(DeathState s) SetNoSearchAssistance(false); Unit::setDeathState(CORPSE); } - if(s == JUST_ALIVED) + if (s == JUST_ALIVED) { SetHealth(GetMaxHealth()); SetLootRecipient(NULL); diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 78d9f3dbe..b5fe2cf0a 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -488,10 +488,8 @@ void GameObject::getFishLoot(Loot *fishloot, Player* loot_owner) GetZoneAndAreaId(zone,subzone); // if subzone loot exist use it - if(LootTemplates_Fishing.HaveLootFor(subzone)) - fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner,true); - // else use zone loot - else + if (!fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner, true, true)) + // else use zone loot (must exist in like case) fishloot->FillLoot(zone, LootTemplates_Fishing, loot_owner,true); } diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index 203bc24df..504b55112 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -386,18 +386,19 @@ void Loot::AddItem(LootStoreItem const & item) } // Calls processor of corresponding LootTemplate (which handles everything including references) -void Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal) +bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError) { // Must be provided if(!loot_owner) - return; + return false; LootTemplate const* tab = store.GetLootFor(loot_id); if (!tab) { - sLog.outErrorDb("Table '%s' loot id #%u used but it doesn't have records.",store.GetName(),loot_id); - return; + if (!noEmptyError) + sLog.outErrorDb("Table '%s' loot id #%u used but it doesn't have records.",store.GetName(),loot_id); + return false; } items.reserve(MAX_NR_LOOT_ITEMS); @@ -416,6 +417,8 @@ void Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, // ... for personal loot else FillNotNormalLootFor(loot_owner); + + return true; } void Loot::FillNotNormalLootFor(Player* pl) diff --git a/src/game/LootMgr.h b/src/game/LootMgr.h index 88c7280b5..9263e323b 100644 --- a/src/game/LootMgr.h +++ b/src/game/LootMgr.h @@ -284,7 +284,7 @@ struct Loot void RemoveLooter(uint64 GUID) { PlayersLooting.erase(GUID); } void generateMoneyLoot(uint32 minAmount, uint32 maxAmount); - void FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal); + bool FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, bool personal, bool noEmptyError = false); // Inserts the item into the loot (called by LootTemplate processors) void AddItem(LootStoreItem const & item); diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index c2bd28d4a..67aabcd06 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -837,7 +837,8 @@ void MailDraft::prepareItems(Player* receiver) Loot mailLoot; - mailLoot.FillLoot(m_mailTemplateId, LootTemplates_Mail, receiver,true); + // can be empty + mailLoot.FillLoot(m_mailTemplateId, LootTemplates_Mail, receiver, true, true); uint32 max_slot = mailLoot.GetMaxSlotInLootFor(receiver); for(uint32 i = 0; m_items.size() < MAX_MAIL_ITEMS && i < max_slot; ++i) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c3180d79d..da5c412c2 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 "8778" + #define REVISION_NR "8779" #endif // __REVISION_NR_H__