Merge commit 'origin/master' into 310

Conflicts:
	src/game/Player.cpp
This commit is contained in:
tomrus88 2009-04-28 19:08:53 +04:00
commit 950a4bf13f
52 changed files with 623 additions and 474 deletions

View file

@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` ( CREATE TABLE `db_version` (
`version` varchar(120) default NULL, `version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL,
`required_7706_01_mangos_command` bit(1) default NULL `required_7720_01_mangos_mangos_string` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
-- --
@ -285,6 +285,7 @@ INSERT INTO `command` VALUES
('cast target',3,'Syntax: .cast target #spellid [triggered]\r\n Selected target will cast #spellid to his victim. If \'trigered\' or part provided then spell casted with triggered flag.'), ('cast target',3,'Syntax: .cast target #spellid [triggered]\r\n Selected target will cast #spellid to his victim. If \'trigered\' or part provided then spell casted with triggered flag.'),
('character customize',2,'Syntax: .character customize [$name]\r\n\r\nMark selected in game or by $name in command character for customize at next login.'), ('character customize',2,'Syntax: .character customize [$name]\r\n\r\nMark selected in game or by $name in command character for customize at next login.'),
('character delete',4,'Syntax: .character delete $name\r\n\r\nDelete character $name.'), ('character delete',4,'Syntax: .character delete $name\r\n\r\nDelete character $name.'),
('character level',3,'Syntax: .character level [$playername] [#level]\r\n\r\nSet the level of character with $playername (or the selected if not name provided) by #numberoflevels Or +1 if no #numberoflevels provided). If #numberoflevels is omitted, the level will be increase by 1. If #numberoflevels is 0, the same level will be restarted. If no character is selected and name not provided, increase your level. Command can be used for offline character. All stats and dependent values recalculated. At level decrease talents can be reset if need. Also at level decrease equipped items with greater level requirement can be lost.'),
('character rename',2,'Syntax: .character rename [$name]\r\n\r\nMark selected in game or by $name in command character for rename at next login.'), ('character rename',2,'Syntax: .character rename [$name]\r\n\r\nMark selected in game or by $name in command character for rename at next login.'),
('combatstop',2,'Syntax: .combatstop [$playername]\r\nStop combat for selected character. If selected non-player then command applied to self. If $playername provided then attempt applied to online player $playername.'), ('combatstop',2,'Syntax: .combatstop [$playername]\r\nStop combat for selected character. If selected non-player then command applied to self. If $playername provided then attempt applied to online player $playername.'),
('commands',0,'Syntax: .commands\r\n\r\nDisplay a list of available commands for your account level.'), ('commands',0,'Syntax: .commands\r\n\r\nDisplay a list of available commands for your account level.'),
@ -2843,9 +2844,9 @@ INSERT INTO `mangos_string` VALUES
(554,'%s has hidden all zones from you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (554,'%s has hidden all zones from you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(555,'Hover enabled',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (555,'Hover enabled',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(556,'Hover disabled',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (556,'Hover disabled',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(557,'You have been leveled up (%i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (557,'%s level up you to (%i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(558,'You have been leveled down (%i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (558,'%s level down you to (%i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(559,'Your level progress has been reset.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (559,'%s reset your level progress.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(560,'The area has been set as explored.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (560,'The area has been set as explored.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(561,'The area has been set as not explored.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (561,'The area has been set as not explored.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(562,'GUID=%i \'s updateIndex: %i, value: %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (562,'GUID=%i \'s updateIndex: %i, value: %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),

View file

@ -0,0 +1,6 @@
ALTER TABLE db_version CHANGE COLUMN required_7706_01_mangos_command required_7714_01_mangos_command bit;
DELETE FROM `command` WHERE `name` IN ('character level');
INSERT INTO `command` VALUES
('character level',3,'Syntax: .character level [$playername] [#level]\r\n\r\nSet the level of character with $playername (or the selected if not name provided) by #numberoflevels Or +1 if no #numberoflevels provided). If #numberoflevels is omitted, the level will be increase by 1. If #numberoflevels is 0, the same level will be restarted. If no character is selected and name not provided, increase your level. Command can be used for offline character. All stats and dependent values recalculated. At level decrease talents can be reset if need. Also at level decrease equipped items with greater level requirement can be lost.');

View file

@ -0,0 +1,7 @@
ALTER TABLE db_version CHANGE COLUMN required_7714_01_mangos_command required_7720_01_mangos_mangos_string bit;
DELETE FROM mangos_string WHERE entry IN(557,558,559);
INSERT INTO mangos_string VALUES
(557,'%s level up you to (%i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(558,'%s level down you to (%i)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(559,'%s reset your level progress.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);

View file

@ -175,6 +175,8 @@ pkgdata_DATA = \
7662_02_mangos_spell_bonus_data.sql \ 7662_02_mangos_spell_bonus_data.sql \
7705_01_mangos_command.sql \ 7705_01_mangos_command.sql \
7706_01_mangos_command.sql \ 7706_01_mangos_command.sql \
7714_01_mangos_command.sql \
7720_01_mangos_mangos_string.sql \
README README
## Additional files to include when running 'make dist' ## Additional files to include when running 'make dist'
@ -330,4 +332,6 @@ EXTRA_DIST = \
7662_02_mangos_spell_bonus_data.sql \ 7662_02_mangos_spell_bonus_data.sql \
7705_01_mangos_command.sql \ 7705_01_mangos_command.sql \
7706_01_mangos_command.sql \ 7706_01_mangos_command.sql \
7714_01_mangos_command.sql \
7720_01_mangos_mangos_string.sql \
README README

View file

@ -720,12 +720,12 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
continue; continue;
// skip wrong arena achievements, if not achievIdByArenaSlot then normal total death counter // skip wrong arena achievements, if not achievIdByArenaSlot then normal total death counter
bool notfit = false; bool notfit = false;
for(int i = 0; i < MAX_ARENA_SLOT; ++i) for(int j = 0; j < MAX_ARENA_SLOT; ++j)
{ {
if(achievIdByArenaSlot[i] == achievement->ID) if(achievIdByArenaSlot[j] == achievement->ID)
{ {
BattleGround* bg = GetPlayer()->GetBattleGround(); BattleGround* bg = GetPlayer()->GetBattleGround();
if(!bg || !bg->isArena() || ArenaTeam::GetSlotByType(bg->GetArenaType()) != i) if(!bg || !bg->isArena() || ArenaTeam::GetSlotByType(bg->GetArenaType()) != j)
notfit = true; notfit = true;
break; break;
@ -749,26 +749,26 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
// search case // search case
bool found = false; bool found = false;
for(int i = 0; achievIdForDangeon[i][0]; ++i) for(int j = 0; achievIdForDangeon[j][0]; ++j)
{ {
if(achievIdForDangeon[i][0] == achievement->ID) if(achievIdForDangeon[j][0] == achievement->ID)
{ {
if(map->IsRaid()) if(map->IsRaid())
{ {
// if raid accepted (ignore difficulty) // if raid accepted (ignore difficulty)
if(!achievIdForDangeon[i][2]) if(!achievIdForDangeon[j][2])
break; // for break; // for
} }
else if(GetPlayer()->GetDifficulty()==DIFFICULTY_NORMAL) else if(GetPlayer()->GetDifficulty()==DIFFICULTY_NORMAL)
{ {
// dungeon in normal mode accepted // dungeon in normal mode accepted
if(!achievIdForDangeon[i][1]) if(!achievIdForDangeon[j][1])
break; // for break; // for
} }
else else
{ {
// dungeon in heroic mode accepted // dungeon in heroic mode accepted
if(!achievIdForDangeon[i][3]) if(!achievIdForDangeon[j][3])
break; // for break; // for
} }
@ -890,12 +890,16 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
break; break;
bool matchFound = false; bool matchFound = false;
for (int i = 0; i < 3; ++i) for (int j = 0; j < MAX_WORLD_MAP_OVERLAY_AREA_IDX; ++j)
{ {
int32 exploreFlag = GetAreaFlagByAreaID(worldOverlayEntry->areatableID[i]); uint32 area_id = worldOverlayEntry->areatableID[j];
if(exploreFlag < 0) if(!area_id) // array have 0 only in empty tail
break; break;
int32 exploreFlag = GetAreaFlagByAreaID(area_id);
if(exploreFlag < 0)
continue;
uint32 playerIndexOffset = uint32(exploreFlag) / 32; uint32 playerIndexOffset = uint32(exploreFlag) / 32;
uint32 mask = 1<< (uint32(exploreFlag) % 32); uint32 mask = 1<< (uint32(exploreFlag) % 32);
@ -1392,7 +1396,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* entry,
{ {
progress = &iter->second; progress = &iter->second;
uint32 newValue; uint32 newValue = 0;
switch(ptype) switch(ptype)
{ {
case PROGRESS_SET: case PROGRESS_SET:

View file

@ -60,8 +60,8 @@ AggressorAI::MoveInLineOfSight(Unit *u)
} }
else if(sMapStore.LookupEntry(m_creature->GetMapId())->IsDungeon()) else if(sMapStore.LookupEntry(m_creature->GetMapId())->IsDungeon())
{ {
u->SetInCombatWith(m_creature);
m_creature->AddThreat(u, 0.0f); m_creature->AddThreat(u, 0.0f);
u->SetInCombatWith(m_creature);
} }
} }
} }
@ -152,13 +152,13 @@ AggressorAI::AttackStart(Unit *u)
if(m_creature->Attack(u,true)) if(m_creature->Attack(u,true))
{ {
m_creature->SetInCombatWith(u);
u->SetInCombatWith(m_creature);
m_creature->AddThreat(u, 0.0f);
// DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", m_creature->GetName(), u->GetGUIDLow()); // DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", m_creature->GetName(), u->GetGUIDLow());
i_victimGuid = u->GetGUID(); i_victimGuid = u->GetGUID();
m_creature->AddThreat(u, 0.0f);
m_creature->SetInCombatWith(u);
u->SetInCombatWith(m_creature);
m_creature->GetMotionMaster()->MoveChase(u); m_creature->GetMotionMaster()->MoveChase(u);
} }
} }

View file

@ -1324,7 +1324,7 @@ bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float
// so we must create it specific for this instance // so we must create it specific for this instance
GameObject * go = new GameObject; GameObject * go = new GameObject;
if(!go->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT),entry, map, if(!go->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT),entry, map,
PHASEMASK_NORMAL, x,y,z,o,rotation0,rotation1,rotation2,rotation3,100,1)) PHASEMASK_NORMAL, x,y,z,o,rotation0,rotation1,rotation2,rotation3,100,GO_STATE_READY))
{ {
sLog.outErrorDb("Gameobject template %u not found in database! BattleGround not created!", entry); sLog.outErrorDb("Gameobject template %u not found in database! BattleGround not created!", entry);
sLog.outError("Cannot create gameobject template %u! BattleGround not created!", entry); sLog.outError("Cannot create gameobject template %u! BattleGround not created!", entry);
@ -1367,7 +1367,7 @@ void BattleGround::DoorClose(uint32 type)
if (obj) if (obj)
{ {
//if doors are open, close it //if doors are open, close it
if (obj->getLootState() == GO_ACTIVATED && !obj->GetGoState()) if (obj->getLootState() == GO_ACTIVATED && obj->GetGoState() != GO_STATE_READY)
{ {
//change state to allow door to be closed //change state to allow door to be closed
obj->SetLootState(GO_READY); obj->SetLootState(GO_READY);

View file

@ -105,7 +105,7 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
// get bg instance or bg template if instance not found // get bg instance or bg template if instance not found
BattleGround *bg = NULL; BattleGround *bg = NULL;
if (instanceId) if (instanceId)
BattleGround *bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId)); bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));
if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId))) if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)))
{ {
@ -353,7 +353,7 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
else else
{ {
// get the bg we're invited to // get the bg we're invited to
BattleGround * bg = sBattleGroundMgr.GetBattleGround(itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID, bgTypeId); bg = sBattleGroundMgr.GetBattleGround(itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID, bgTypeId);
status = STATUS_WAIT_JOIN; status = STATUS_WAIT_JOIN;
} }
@ -567,7 +567,7 @@ void WorldSession::HandleBattlefieldStatusOpcode( WorldPacket & /*recv_data*/ )
} }
else else
{ {
BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
if (!bg) if (!bg)
continue; continue;
uint32 avgTime = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetAverageQueueWaitTime(itrPlayerStatus->second.GroupInfo, _player->GetBattleGroundQueueIdFromLevel(bgTypeId)); uint32 avgTime = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].GetAverageQueueWaitTime(itrPlayerStatus->second.GroupInfo, _player->GetBattleGroundQueueIdFromLevel(bgTypeId));

View file

@ -761,10 +761,10 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
FillPlayersToBG(bg, queue_id); FillPlayersToBG(bg, queue_id);
// now everything is set, invite players // now everything is set, invite players
for(GroupsQueueType::const_iterator itr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); itr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++itr) for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++citr)
InviteGroupToBG((*itr), bg, (*itr)->Team); InviteGroupToBG((*citr), bg, (*citr)->Team);
for(GroupsQueueType::const_iterator itr = m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.begin(); itr != m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.end(); ++itr) for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.end(); ++citr)
InviteGroupToBG((*itr), bg, (*itr)->Team); InviteGroupToBG((*citr), bg, (*citr)->Team);
if (!bg->HasFreeSlots()) if (!bg->HasFreeSlots())
{ {
@ -834,8 +834,8 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
} }
//invite those selection pools //invite those selection pools
for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) for(uint32 i = 0; i < BG_TEAMS_COUNT; i++)
for(GroupsQueueType::const_iterator itr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); itr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++itr) for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr)
InviteGroupToBG((*itr), bg2, (*itr)->Team); InviteGroupToBG((*citr), bg2, (*citr)->Team);
//start bg //start bg
bg2->StartBattleGround(); bg2->StartBattleGround();
//clear structures //clear structures
@ -861,8 +861,8 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLeve
// invite those selection pools // invite those selection pools
for(uint32 i = 0; i < BG_TEAMS_COUNT; i++) for(uint32 i = 0; i < BG_TEAMS_COUNT; i++)
for(GroupsQueueType::const_iterator itr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); itr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++itr) for(GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr)
InviteGroupToBG((*itr), bg2, (*itr)->Team); InviteGroupToBG((*citr), bg2, (*citr)->Team);
// start bg // start bg
bg2->StartBattleGround(); bg2->StartBattleGround();
} }
@ -1825,9 +1825,10 @@ void BattleGroundMgr::DistributeArenaPoints()
void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint64& guid, Player* plr, BattleGroundTypeId bgTypeId, uint8 fromWhere) void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint64& guid, Player* plr, BattleGroundTypeId bgTypeId, uint8 fromWhere)
{ {
uint32 PlayerLevel = 10; if (!plr)
return;
if (plr) uint32 PlayerLevel = 10;
PlayerLevel = plr->getLevel(); PlayerLevel = plr->getLevel();
data->Initialize(SMSG_BATTLEFIELD_LIST); data->Initialize(SMSG_BATTLEFIELD_LIST);

View file

@ -298,10 +298,11 @@ void Channel::Password(uint64 p, const char *pass)
void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set) void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
{ {
uint32 sec = 0;
Player *plr = objmgr.GetPlayer(p); Player *plr = objmgr.GetPlayer(p);
if(plr) if (!plr)
sec = plr->GetSession()->GetSecurity(); return;
uint32 sec = plr->GetSession()->GetSecurity();
if(!IsOn(p)) if(!IsOn(p))
{ {
@ -366,10 +367,11 @@ void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
void Channel::SetOwner(uint64 p, const char *newname) void Channel::SetOwner(uint64 p, const char *newname)
{ {
uint32 sec = 0;
Player *plr = objmgr.GetPlayer(p); Player *plr = objmgr.GetPlayer(p);
if(plr) if (!plr)
sec = plr->GetSession()->GetSecurity(); return;
uint32 sec = plr->GetSession()->GetSecurity();
if(!IsOn(p)) if(!IsOn(p))
{ {

View file

@ -109,9 +109,10 @@ ChatCommand * ChatHandler::getCommandTable()
static ChatCommand characterCommandTable[] = static ChatCommand characterCommandTable[] =
{ {
{ "rename", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterRenameCommand, "", NULL },
{ "customize", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterCustomizeCommand, "", NULL }, { "customize", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterCustomizeCommand, "", NULL },
{ "delete", SEC_CONSOLE, true, &ChatHandler::HandleCharacterDeleteCommand, "", NULL }, { "delete", SEC_CONSOLE, true, &ChatHandler::HandleCharacterDeleteCommand, "", NULL },
{ "level", SEC_ADMINISTRATOR, true, &ChatHandler::HandleCharacterLevelCommand, "", NULL },
{ "rename", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterRenameCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL } { NULL, 0, false, NULL, "", NULL }
}; };

View file

@ -116,6 +116,7 @@ class ChatHandler
bool HandleCharacterCustomizeCommand(const char * args); bool HandleCharacterCustomizeCommand(const char * args);
bool HandleCharacterDeleteCommand(const char* args); bool HandleCharacterDeleteCommand(const char* args);
bool HandleCharacterRenameCommand(const char * args); bool HandleCharacterRenameCommand(const char * args);
bool HandleCharacterLevelCommand(const char* args);
bool HandleDebugAnimCommand(const char* args); bool HandleDebugAnimCommand(const char* args);
bool HandleDebugArenaCommand(const char * args); bool HandleDebugArenaCommand(const char * args);
@ -498,6 +499,7 @@ class ChatHandler
bool HandleBanHelper(BanMode mode,char const* args); bool HandleBanHelper(BanMode mode,char const* args);
bool HandleBanInfoHelper(uint32 accountid, char const* accountname); bool HandleBanInfoHelper(uint32 accountid, char const* accountname);
bool HandleUnBanHelper(BanMode mode,char const* args); bool HandleUnBanHelper(BanMode mode,char const* args);
void HandleCharacterLevel(Player* player, uint64 player_guid, uint32 oldlevel, uint32 newlevel);
void SetSentErrorMessage(bool val){ sentErrorMessage = val;}; void SetSentErrorMessage(bool val){ sentErrorMessage = val;};
private: private:

View file

@ -46,6 +46,9 @@ class MANGOS_DLL_SPEC CreatureAI
// Called if IsVisible(Unit *who) is true at each *who move, reaction at visibility zone enter // Called if IsVisible(Unit *who) is true at each *who move, reaction at visibility zone enter
virtual void MoveInLineOfSight(Unit *) {} virtual void MoveInLineOfSight(Unit *) {}
// Called for reaction at enter to combat if not in combat yet (enemy can be NULL)
virtual void EnterCombat(Unit* /*enemy*/) {}
// Called for reaction at stopping attack at no attackers or targets // Called for reaction at stopping attack at no attackers or targets
virtual void EnterEvadeMode() {} virtual void EnterEvadeMode() {}

View file

@ -39,10 +39,10 @@ int CreatureEventAI::Permissible(const Creature *creature)
CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c) CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c)
{ {
CreatureEventAI_Event_Map::iterator CreatureEvents = CreatureEAI_Mgr.GetCreatureEventAIMap().find(m_creature->GetEntry()); CreatureEventAI_Event_Map::const_iterator CreatureEvents = CreatureEAI_Mgr.GetCreatureEventAIMap().find(m_creature->GetEntry());
if (CreatureEvents != CreatureEAI_Mgr.GetCreatureEventAIMap().end()) if (CreatureEvents != CreatureEAI_Mgr.GetCreatureEventAIMap().end())
{ {
std::vector<CreatureEventAI_Event>::iterator i; std::vector<CreatureEventAI_Event>::const_iterator i;
for (i = (*CreatureEvents).second.begin(); i != (*CreatureEvents).second.end(); ++i) for (i = (*CreatureEvents).second.begin(); i != (*CreatureEvents).second.end(); ++i)
{ {
@ -622,7 +622,7 @@ void CreatureEventAI::ProcessAction(uint16 type, uint32 param1, uint32 param2, u
} }
//Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered //Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered
bool canCast = !(caster->IsNonMeleeSpellCasted(false) && (param3 & CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS)); bool canCast = !caster->IsNonMeleeSpellCasted(false) || (param3 & (CAST_TRIGGERED | CAST_INTURRUPT_PREVIOUS));
// If cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them // If cast flag CAST_AURA_NOT_PRESENT is active, check if target already has aura on them
if(param3 & CAST_AURA_NOT_PRESENT) if(param3 & CAST_AURA_NOT_PRESENT)
@ -678,9 +678,9 @@ void CreatureEventAI::ProcessAction(uint16 type, uint32 param1, uint32 param2, u
Creature* pCreature = NULL; Creature* pCreature = NULL;
if (param3) if (param3)
pCreature = m_creature->SummonCreature(param1, 0, 0, 0, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, param3); pCreature = m_creature->SummonCreature(param1, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, param3);
else else
pCreature = m_creature->SummonCreature(param1, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); pCreature = m_creature->SummonCreature(param1, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0);
if (!pCreature) if (!pCreature)
{ {
@ -912,8 +912,8 @@ void CreatureEventAI::ProcessAction(uint16 type, uint32 param1, uint32 param2, u
//if not available, use pActionInvoker //if not available, use pActionInvoker
if (Unit* pTarget = GetTargetByType(param2, pActionInvoker)) if (Unit* pTarget = GetTargetByType(param2, pActionInvoker))
{ {
if (Player* pPlayer = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself()) if (Player* pPlayer2 = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself())
pPlayer->RewardPlayerAndGroupAtEvent(param1, m_creature); pPlayer2->RewardPlayerAndGroupAtEvent(param1, m_creature);
} }
} }
} }
@ -1118,7 +1118,7 @@ void CreatureEventAI::JustSummoned(Creature* pUnit)
} }
} }
void CreatureEventAI::Aggro(Unit *who) void CreatureEventAI::EnterCombat(Unit *enemy)
{ {
//Check for on combat start events //Check for on combat start events
if (!bEmptyList) if (!bEmptyList)
@ -1129,7 +1129,7 @@ void CreatureEventAI::Aggro(Unit *who)
{ {
case EVENT_T_AGGRO: case EVENT_T_AGGRO:
(*i).Enabled = true; (*i).Enabled = true;
ProcessEvent(*i, who); ProcessEvent(*i, enemy);
break; break;
//Reset all in combat timers //Reset all in combat timers
case EVENT_T_TIMER: case EVENT_T_TIMER:
@ -1164,17 +1164,12 @@ void CreatureEventAI::AttackStart(Unit *who)
if (!who) if (!who)
return; return;
bool inCombat = m_creature->isInCombat();
if (m_creature->Attack(who, MeleeEnabled)) if (m_creature->Attack(who, MeleeEnabled))
{ {
m_creature->AddThreat(who, 0.0f); m_creature->AddThreat(who, 0.0f);
m_creature->SetInCombatWith(who); m_creature->SetInCombatWith(who);
who->SetInCombatWith(m_creature); who->SetInCombatWith(m_creature);
if (!inCombat)
Aggro(who);
if (CombatMovementEnabled) if (CombatMovementEnabled)
{ {
m_creature->GetMotionMaster()->MoveChase(who, AttackDistance, AttackAngle); m_creature->GetMotionMaster()->MoveChase(who, AttackDistance, AttackAngle);
@ -1233,8 +1228,8 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who)
} }
else if (m_creature->GetMap()->IsDungeon()) else if (m_creature->GetMap()->IsDungeon())
{ {
who->SetInCombatWith(m_creature);
m_creature->AddThreat(who, 0.0f); m_creature->AddThreat(who, 0.0f);
who->SetInCombatWith(m_creature);
} }
} }
} }

View file

@ -257,11 +257,11 @@ class MANGOS_DLL_SPEC CreatureEventAI : public CreatureAI
void JustRespawned(); void JustRespawned();
void Reset(); void Reset();
void JustReachedHome(); void JustReachedHome();
void EnterCombat(Unit *enemy);
void EnterEvadeMode(); void EnterEvadeMode();
void JustDied(Unit* killer); void JustDied(Unit* killer);
void KilledUnit(Unit* victim); void KilledUnit(Unit* victim);
void JustSummoned(Creature* pUnit); void JustSummoned(Creature* pUnit);
void Aggro(Unit *who);
void AttackStart(Unit *who); void AttackStart(Unit *who);
void MoveInLineOfSight(Unit *who); void MoveInLineOfSight(Unit *who);
void SpellHit(Unit* pUnit, const SpellEntry* pSpell); void SpellHit(Unit* pUnit, const SpellEntry* pSpell);

View file

@ -457,22 +457,16 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
sLog.outErrorDb("CreatureEventAI: Event %u Action %u param3 uses non-existant SoundID %u.", i, j+1, temp.action[j].param3); sLog.outErrorDb("CreatureEventAI: Event %u Action %u param3 uses non-existant SoundID %u.", i, j+1, temp.action[j].param3);
break; break;
case ACTION_T_EMOTE: case ACTION_T_EMOTE:
//TODO: load emotes and check it's store for existing
/*
if (!sEmotesStore.LookupEntry(temp.action[j].param1)) if (!sEmotesStore.LookupEntry(temp.action[j].param1))
sLog.outErrorDb("CreatureEventAI: Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param1); sLog.outErrorDb("CreatureEventAI: Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param1);
*/
break; break;
case ACTION_T_RANDOM_EMOTE: case ACTION_T_RANDOM_EMOTE:
//TODO: load emotes and check it's store for existing
/*
if (!sEmotesStore.LookupEntry(temp.action[j].param1)) if (!sEmotesStore.LookupEntry(temp.action[j].param1))
sLog.outErrorDb("CreatureEventAI: Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param1); sLog.outErrorDb("CreatureEventAI: Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param1);
if (temp.action[j].param2_s >= 0 && !sEmotesStore.LookupEntry(temp.action[j].param2)) if (temp.action[j].param2_s >= 0 && !sEmotesStore.LookupEntry(temp.action[j].param2))
sLog.outErrorDb("CreatureEventAI: Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param2); sLog.outErrorDb("CreatureEventAI: Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param2);
if (temp.action[j].param3_s >= 0 && !sEmotesStore.LookupEntry(temp.action[j].param3)) if (temp.action[j].param3_s >= 0 && !sEmotesStore.LookupEntry(temp.action[j].param3))
sLog.outErrorDb("CreatureEventAI: Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param3); sLog.outErrorDb("CreatureEventAI: Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j+1, temp.action[j].param3);
*/
break; break;
case ACTION_T_CAST: case ACTION_T_CAST:
{ {

View file

@ -32,9 +32,9 @@ class CreatureEventAIMgr
void LoadCreatureEventAI_Summons(); void LoadCreatureEventAI_Summons();
void LoadCreatureEventAI_Scripts(); void LoadCreatureEventAI_Scripts();
CreatureEventAI_Event_Map& GetCreatureEventAIMap() { return m_CreatureEventAI_Event_Map; } CreatureEventAI_Event_Map const& GetCreatureEventAIMap() const { return m_CreatureEventAI_Event_Map; }
CreatureEventAI_Summon_Map& GetCreatureEventAISummonMap() { return m_CreatureEventAI_Summon_Map; } CreatureEventAI_Summon_Map const& GetCreatureEventAISummonMap() const { return m_CreatureEventAI_Summon_Map; }
CreatureEventAI_TextMap& GetCreatureEventAITextMap() { return m_CreatureEventAI_TextMap; } CreatureEventAI_TextMap const& GetCreatureEventAITextMap() const { return m_CreatureEventAI_TextMap; }
private: private:
CreatureEventAI_Event_Map m_CreatureEventAI_Event_Map; CreatureEventAI_Event_Map m_CreatureEventAI_Event_Map;

View file

@ -146,8 +146,8 @@ DBCStorage <TotemCategoryEntry> sTotemCategoryStore(TotemCategoryEntryfmt);
DBCStorage <VehicleEntry> sVehicleStore(VehicleEntryfmt); DBCStorage <VehicleEntry> sVehicleStore(VehicleEntryfmt);
DBCStorage <VehicleSeatEntry> sVehicleSeatStore(VehicleSeatEntryfmt); DBCStorage <VehicleSeatEntry> sVehicleSeatStore(VehicleSeatEntryfmt);
DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore(WorldMapAreaEntryfmt); DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore(WorldMapAreaEntryfmt);
DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt);
DBCStorage <WorldMapOverlayEntry> sWorldMapOverlayStore(WorldMapOverlayEntryfmt); DBCStorage <WorldMapOverlayEntry> sWorldMapOverlayStore(WorldMapOverlayEntryfmt);
DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt);
typedef std::list<std::string> StoreProblemList; typedef std::list<std::string> StoreProblemList;
@ -461,8 +461,8 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleStore, dbcPath,"Vehicle.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleStore, dbcPath,"Vehicle.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleSeatStore, dbcPath,"VehicleSeat.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleSeatStore, dbcPath,"VehicleSeat.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapAreaStore, dbcPath,"WorldMapArea.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapAreaStore, dbcPath,"WorldMapArea.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldSafeLocsStore, dbcPath,"WorldSafeLocs.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapOverlayStore, dbcPath,"WorldMapOverlay.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapOverlayStore, dbcPath,"WorldMapOverlay.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldSafeLocsStore, dbcPath,"WorldSafeLocs.dbc");
// error checks // error checks
if(bad_dbc_files.size() >= DBCFilesCount ) if(bad_dbc_files.size() >= DBCFilesCount )

View file

@ -142,8 +142,8 @@ extern DBCStorage <TotemCategoryEntry> sTotemCategoryStore;
extern DBCStorage <VehicleEntry> sVehicleStore; extern DBCStorage <VehicleEntry> sVehicleStore;
extern DBCStorage <VehicleSeatEntry> sVehicleSeatStore; extern DBCStorage <VehicleSeatEntry> sVehicleSeatStore;
//extern DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore; -- use Zone2MapCoordinates and Map2ZoneCoordinates //extern DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore; -- use Zone2MapCoordinates and Map2ZoneCoordinates
extern DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore;
extern DBCStorage <WorldMapOverlayEntry> sWorldMapOverlayStore; extern DBCStorage <WorldMapOverlayEntry> sWorldMapOverlayStore;
extern DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore;
void LoadDBCStores(const std::string& dataPath); void LoadDBCStores(const std::string& dataPath);

View file

@ -1650,6 +1650,18 @@ struct WorldMapAreaEntry
// int32 dungeonMap_id; // 9 pointer to DungeonMap.dbc (owerride x1,x2,y1,y2 coordinates) // int32 dungeonMap_id; // 9 pointer to DungeonMap.dbc (owerride x1,x2,y1,y2 coordinates)
}; };
#define MAX_WORLD_MAP_OVERLAY_AREA_IDX 4
struct WorldMapOverlayEntry
{
uint32 ID; // 0
//uint32 worldMapAreaId; // 1 idx in WorldMapArea.dbc
uint32 areatableID[MAX_WORLD_MAP_OVERLAY_AREA_IDX]; // 2-5
// 6-7 always 0, possible part of areatableID[]
//char* internal_name // 8
// 9-16 some ints
};
struct WorldSafeLocsEntry struct WorldSafeLocsEntry
{ {
uint32 ID; // 0 uint32 ID; // 0
@ -1661,12 +1673,6 @@ struct WorldSafeLocsEntry
// 21 name flags, unused // 21 name flags, unused
}; };
struct WorldMapOverlayEntry
{
uint32 ID; // 0
uint32 areatableID[4]; // 2-5
};
// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
#if defined( __GNUC__ ) #if defined( __GNUC__ )
#pragma pack() #pragma pack()

View file

@ -101,7 +101,7 @@ const char TotemCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii";
const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifixxx"; const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifixxx";
const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx"; const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx";
const char WorldMapAreaEntryfmt[]="xinxffffix"; const char WorldMapAreaEntryfmt[]="xinxffffix";
const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx";
const char WorldMapOverlayEntryfmt[]="nxiiiixxxxxxxxxxx"; const char WorldMapOverlayEntryfmt[]="nxiiiixxxxxxxxxxx";
const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx";
#endif #endif

View file

@ -683,17 +683,17 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
} }
else // If not spawned else // If not spawned
{ {
CreatureData const* data = objmgr.GetCreatureData(itr->first); CreatureData const* data2 = objmgr.GetCreatureData(itr->first);
if (data && activate) if (data2 && activate)
{ {
CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(data->id); CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(data2->id);
uint32 display_id = objmgr.ChooseDisplayId(0,cinfo,data); uint32 display_id = objmgr.ChooseDisplayId(0,cinfo,data2);
CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id); CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id);
if (minfo) if (minfo)
display_id = minfo->modelid; display_id = minfo->modelid;
if (data->equipmentId == 0) if (data2->equipmentId == 0)
itr->second.equipement_id_prev = cinfo->equipmentId; itr->second.equipement_id_prev = cinfo->equipmentId;
else if (data->equipmentId != -1) else if (data2->equipmentId != -1)
itr->second.equipement_id_prev = data->equipmentId; itr->second.equipement_id_prev = data->equipmentId;
itr->second.modelid_prev = display_id; itr->second.modelid_prev = display_id;
} }
@ -751,7 +751,7 @@ MANGOS_DLL_SPEC bool IsHolidayActive( HolidayIds id )
GameEventMgr::ActiveEvents const& ae = gameeventmgr.GetActiveEventList(); GameEventMgr::ActiveEvents const& ae = gameeventmgr.GetActiveEventList();
for(GameEventMgr::ActiveEvents::const_iterator itr = ae.begin(); itr != ae.end(); ++itr) for(GameEventMgr::ActiveEvents::const_iterator itr = ae.begin(); itr != ae.end(); ++itr)
if(events[id].holiday_id==id) if(events[*itr].holiday_id==id)
return true; return true;
return false; return false;

View file

@ -89,7 +89,7 @@ void GameObject::RemoveFromWorld()
Object::RemoveFromWorld(); Object::RemoveFromWorld();
} }
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, uint32 go_state) bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state)
{ {
Relocate(x,y,z,ang); Relocate(x,y,z,ang);
SetMapId(map->GetId()); SetMapId(map->GetId());
@ -185,7 +185,7 @@ void GameObject::Update(uint32 /*p_time*/)
Unit* caster = GetOwner(); Unit* caster = GetOwner();
if(caster && caster->GetTypeId()==TYPEID_PLAYER) if(caster && caster->GetTypeId()==TYPEID_PLAYER)
{ {
SetGoState(0); SetGoState(GO_STATE_ACTIVE);
SetUInt32Value(GAMEOBJECT_FLAGS, GO_FLAG_NODESPAWN); SetUInt32Value(GAMEOBJECT_FLAGS, GO_FLAG_NODESPAWN);
UpdateData udata; UpdateData udata;
@ -243,8 +243,8 @@ void GameObject::Update(uint32 /*p_time*/)
case GAMEOBJECT_TYPE_DOOR: case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON: case GAMEOBJECT_TYPE_BUTTON:
//we need to open doors if they are closed (add there another condition if this code breaks some usage, but it need to be here for battlegrounds) //we need to open doors if they are closed (add there another condition if this code breaks some usage, but it need to be here for battlegrounds)
if( !GetGoState() ) if (GetGoState() != GO_STATE_READY)
SwitchDoorOrButton(false); ResetDoorOrButton();
//flags in AB are type_button and we need to add them here so no break! //flags in AB are type_button and we need to add them here so no break!
default: default:
if (!m_spawnedByDefault) // despawn timer if (!m_spawnedByDefault) // despawn timer
@ -366,10 +366,7 @@ void GameObject::Update(uint32 /*p_time*/)
case GAMEOBJECT_TYPE_DOOR: case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON: case GAMEOBJECT_TYPE_BUTTON:
if (GetAutoCloseTime() && (m_cooldownTime < time(NULL))) if (GetAutoCloseTime() && (m_cooldownTime < time(NULL)))
{ ResetDoorOrButton();
SwitchDoorOrButton(false);
SetLootState(GO_JUST_DEACTIVATED);
}
break; break;
} }
break; break;
@ -457,7 +454,7 @@ void GameObject::Delete()
{ {
SendObjectDeSpawnAnim(GetGUID()); SendObjectDeSpawnAnim(GetGUID());
SetGoState(1); SetGoState(GO_STATE_READY);
SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags); SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags);
uint16 poolid = poolhandler.IsPartOfAPool(GetGUIDLow(), TYPEID_GAMEOBJECT); uint16 poolid = poolhandler.IsPartOfAPool(GetGUIDLow(), TYPEID_GAMEOBJECT);
@ -542,8 +539,8 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+2) << ", " << GetFloatValue(GAMEOBJECT_PARENTROTATION+2) << ", "
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+3) << ", " << GetFloatValue(GAMEOBJECT_PARENTROTATION+3) << ", "
<< m_respawnDelayTime << ", " << m_respawnDelayTime << ", "
<< (uint32)GetGoAnimProgress() << ", " << uint32(GetGoAnimProgress()) << ", "
<< (uint32)GetGoState() << ")"; << uint32(GetGoState()) << ")";
WorldDatabase.BeginTransaction(); WorldDatabase.BeginTransaction();
WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid); WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
@ -575,7 +572,7 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
float rotation3 = data->rotation3; float rotation3 = data->rotation3;
uint32 animprogress = data->animprogress; uint32 animprogress = data->animprogress;
uint32 go_state = data->go_state; GOState go_state = data->go_state;
m_DBTableGuid = guid; m_DBTableGuid = guid;
if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
@ -810,7 +807,17 @@ GameObject* GameObject::LookupFishingHoleAround(float range)
return ok; return ok;
} }
void GameObject::UseDoorOrButton(uint32 time_to_restore) void GameObject::ResetDoorOrButton()
{
if (m_lootState == GO_READY || m_lootState == GO_JUST_DEACTIVATED)
return;
SwitchDoorOrButton(false);
SetLootState(GO_JUST_DEACTIVATED);
m_cooldownTime = 0;
}
void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */)
{ {
if(m_lootState != GO_READY) if(m_lootState != GO_READY)
return; return;
@ -818,24 +825,23 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore)
if(!time_to_restore) if(!time_to_restore)
time_to_restore = GetAutoCloseTime(); time_to_restore = GetAutoCloseTime();
SwitchDoorOrButton(true); SwitchDoorOrButton(true,alternative);
SetLootState(GO_ACTIVATED); SetLootState(GO_ACTIVATED);
m_cooldownTime = time(NULL) + time_to_restore; m_cooldownTime = time(NULL) + time_to_restore;
} }
void GameObject::SwitchDoorOrButton(bool activate) void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false */)
{ {
if(activate) if(activate)
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
else else
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
if(GetGoState()) //if closed -> open if(GetGoState() == GO_STATE_READY) //if closed -> open
SetGoState(0); SetGoState(alternative ? GO_STATE_ACTIVE_ALTERNATIVE : GO_STATE_ACTIVE);
else //if open -> close else //if open -> close
SetGoState(1); SetGoState(GO_STATE_READY);
} }
void GameObject::Use(Unit* user) void GameObject::Use(Unit* user)

View file

@ -366,12 +366,29 @@ struct GameObjectInfo
uint32 ScriptId; uint32 ScriptId;
}; };
// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
#if defined( __GNUC__ )
#pragma pack()
#else
#pragma pack(pop)
#endif
struct GameObjectLocale struct GameObjectLocale
{ {
std::vector<std::string> Name; std::vector<std::string> Name;
std::vector<std::string> CastBarCaption; std::vector<std::string> CastBarCaption;
}; };
// client side GO show states
enum GOState
{
GO_STATE_ACTIVE = 0, // show in world as used and not reset (closed door open)
GO_STATE_READY = 1, // show in world as ready (closed door close)
GO_STATE_ACTIVE_ALTERNATIVE = 2 // show in world as used in alt way and not reset (closed door open by cannon fire)
};
#define MAX_GO_STATE 3
// from `gameobject` // from `gameobject`
struct GameObjectData struct GameObjectData
{ {
@ -388,17 +405,10 @@ struct GameObjectData
float rotation3; float rotation3;
int32 spawntimesecs; int32 spawntimesecs;
uint32 animprogress; uint32 animprogress;
uint32 go_state; GOState go_state;
uint8 spawnMask; uint8 spawnMask;
}; };
// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
#if defined( __GNUC__ )
#pragma pack()
#else
#pragma pack(pop)
#endif
// For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ... // For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ...
// For bobber: GO_NOT_READY ->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-><deleted> // For bobber: GO_NOT_READY ->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-><deleted>
// For door(closed):[GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY(close) -> ... // For door(closed):[GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY(close) -> ...
@ -425,7 +435,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
void AddToWorld(); void AddToWorld();
void RemoveFromWorld(); void RemoveFromWorld();
bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, uint32 go_state); bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state);
void Update(uint32 p_time); void Update(uint32 p_time);
GameObjectInfo const* GetGOInfo() const; GameObjectInfo const* GetGOInfo() const;
@ -456,7 +466,6 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask); void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
bool LoadFromDB(uint32 guid, Map *map); bool LoadFromDB(uint32 guid, Map *map);
void DeleteFromDB(); void DeleteFromDB();
void SetLootState(LootState s) { m_lootState = s; }
static uint32 GetLootId(GameObjectInfo const* info); static uint32 GetLootId(GameObjectInfo const* info);
uint32 GetLootId() const { return GetLootId(GetGOInfo()); } uint32 GetLootId() const { return GetLootId(GetGOInfo()); }
uint32 GetLockId() const uint32 GetLockId() const
@ -523,8 +532,8 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
void getFishLoot(Loot *loot, Player* loot_owner); void getFishLoot(Loot *loot, Player* loot_owner);
GameobjectTypes GetGoType() const { return GameobjectTypes(GetByteValue(GAMEOBJECT_BYTES_1, 1)); } GameobjectTypes GetGoType() const { return GameobjectTypes(GetByteValue(GAMEOBJECT_BYTES_1, 1)); }
void SetGoType(GameobjectTypes type) { SetByteValue(GAMEOBJECT_BYTES_1, 1, type); } void SetGoType(GameobjectTypes type) { SetByteValue(GAMEOBJECT_BYTES_1, 1, type); }
uint8 GetGoState() const { return GetByteValue(GAMEOBJECT_BYTES_1, 0); } GOState GetGoState() const { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
void SetGoState(uint8 state) { SetByteValue(GAMEOBJECT_BYTES_1, 0, state); } void SetGoState(GOState state) { SetByteValue(GAMEOBJECT_BYTES_1, 0, state); }
uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); } uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
void SetGoArtKit(uint8 artkit) { SetByteValue(GAMEOBJECT_BYTES_1, 2, artkit); } void SetGoArtKit(uint8 artkit) { SetByteValue(GAMEOBJECT_BYTES_1, 2, artkit); }
uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); } uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
@ -533,6 +542,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
void Use(Unit* user); void Use(Unit* user);
LootState getLootState() const { return m_lootState; } LootState getLootState() const { return m_lootState; }
void SetLootState(LootState s) { m_lootState = s; }
void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); } void AddToSkillupList(uint32 PlayerGuidLow) { m_SkillupList.push_back(PlayerGuidLow); }
bool IsInSkillupList(uint32 PlayerGuidLow) const bool IsInSkillupList(uint32 PlayerGuidLow) const
@ -556,7 +566,10 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
bool hasQuest(uint32 quest_id) const; bool hasQuest(uint32 quest_id) const;
bool hasInvolvedQuest(uint32 quest_id) const; bool hasInvolvedQuest(uint32 quest_id) const;
bool ActivateToQuest(Player *pTarget) const; bool ActivateToQuest(Player *pTarget) const;
void UseDoorOrButton(uint32 time_to_restore = 0); // 0 = use `gameobject`.`spawntimesecs` void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false);
// 0 = use `gameobject`.`spawntimesecs`
void ResetDoorOrButton();
// 0 = use `gameobject`.`spawntimesecs`
uint32 GetLinkedGameObjectEntry() const uint32 GetLinkedGameObjectEntry() const
{ {
@ -613,7 +626,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
GameObjectInfo const* m_goInfo; GameObjectInfo const* m_goInfo;
uint64 m_rotation; uint64 m_rotation;
private: private:
void SwitchDoorOrButton(bool activate); void SwitchDoorOrButton(bool activate, bool alternative = false);
GridReference<GameObject> m_gridRef; GridReference<GameObject> m_gridRef;
}; };

View file

@ -70,8 +70,8 @@ Group::~Group()
// will be unloaded first so we must be prepared for both cases // will be unloaded first so we must be prepared for both cases
// this may unload some instance saves // this may unload some instance saves
for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) for(uint8 i = 0; i < TOTAL_DIFFICULTIES; i++)
for(BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) for(BoundInstancesMap::iterator itr2 = m_boundInstances[i].begin(); itr2 != m_boundInstances[i].end(); ++itr2)
itr->second.save->RemoveGroup(this); itr2->second.save->RemoveGroup(this);
// Sub group counters clean up // Sub group counters clean up
if (m_subGroupsCounts) if (m_subGroupsCounts)

View file

@ -137,11 +137,11 @@ void GuardAI::AttackStart(Unit *u)
// DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow()); // DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow());
if(m_creature->Attack(u,true)) if(m_creature->Attack(u,true))
{ {
i_victimGuid = u->GetGUID();
m_creature->AddThreat(u, 0.0f);
m_creature->SetInCombatWith(u); m_creature->SetInCombatWith(u);
u->SetInCombatWith(m_creature); u->SetInCombatWith(m_creature);
m_creature->AddThreat(u, 0.0f);
i_victimGuid = u->GetGUID();
m_creature->GetMotionMaster()->MoveChase(u); m_creature->GetMotionMaster()->MoveChase(u);
} }
} }

View file

@ -1193,7 +1193,7 @@ void WorldSession::HandleGuildBankDepositItem( WorldPacket & recv_data )
else // swap else // swap
{ {
gDest.clear(); gDest.clear();
uint8 msg = pGuild->CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(),pItemSrc,true); msg = pGuild->CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(),pItemSrc,true);
if( msg != EQUIP_ERR_OK ) if( msg != EQUIP_ERR_OK )
{ {
pl->SendEquipError( msg, pItemSrc, NULL ); pl->SendEquipError( msg, pItemSrc, NULL );

View file

@ -52,16 +52,16 @@ InstanceSaveManager::~InstanceSaveManager()
for (InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(); itr != m_instanceSaveById.end(); ++itr) for (InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(); itr != m_instanceSaveById.end(); ++itr)
{ {
InstanceSave *save = itr->second; InstanceSave *save = itr->second;
for(InstanceSave::PlayerListType::iterator itr = save->m_playerList.begin(), next = itr; itr != save->m_playerList.end(); itr = next) for(InstanceSave::PlayerListType::iterator itr2 = save->m_playerList.begin(), next = itr2; itr2 != save->m_playerList.end(); itr2 = next)
{ {
++next; ++next;
(*itr)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true); (*itr2)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true);
} }
save->m_playerList.clear(); save->m_playerList.clear();
for(InstanceSave::GroupListType::iterator itr = save->m_groupList.begin(), next = itr; itr != save->m_groupList.end(); itr = next) for(InstanceSave::GroupListType::iterator itr2 = save->m_groupList.begin(), next = itr2; itr2 != save->m_groupList.end(); itr2 = next)
{ {
++next; ++next;
(*itr)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true); (*itr2)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true);
} }
save->m_groupList.clear(); save->m_groupList.clear();
delete save; delete save;
@ -550,6 +550,7 @@ void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator &itr)
Group *group = *(gList.begin()); Group *group = *(gList.begin());
group->UnbindInstance(itr->second->GetMapId(), itr->second->GetDifficulty(), true); group->UnbindInstance(itr->second->GetMapId(), itr->second->GetDifficulty(), true);
} }
delete itr->second;
m_instanceSaveById.erase(itr++); m_instanceSaveById.erase(itr++);
lock_instLists = false; lock_instLists = false;
} }
@ -617,10 +618,10 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLe
MapInstanced::InstancedMaps::iterator mitr; MapInstanced::InstancedMaps::iterator mitr;
for(mitr = instMaps.begin(); mitr != instMaps.end(); ++mitr) for(mitr = instMaps.begin(); mitr != instMaps.end(); ++mitr)
{ {
Map *map = mitr->second; Map *map2 = mitr->second;
if(!map->IsDungeon()) continue; if(!map2->IsDungeon()) continue;
if(warn) ((InstanceMap*)map)->SendResetWarnings(timeLeft); if(warn) ((InstanceMap*)map2)->SendResetWarnings(timeLeft);
else ((InstanceMap*)map)->Reset(INSTANCE_RESET_GLOBAL); else ((InstanceMap*)map2)->Reset(INSTANCE_RESET_GLOBAL);
} }
// TODO: delete creature/gameobject respawn times even if the maps are not loaded // TODO: delete creature/gameobject respawn times even if the maps are not loaded

View file

@ -199,7 +199,7 @@ void WorldSession::HandleAutoEquipItemOpcode( WorldPacket & recv_data )
// check dest->src move possibility // check dest->src move possibility
ItemPosCountVec sSrc; ItemPosCountVec sSrc;
uint16 eSrc; uint16 eSrc = 0;
if( _player->IsInventoryPos( src ) ) if( _player->IsInventoryPos( src ) )
{ {
msg = _player->CanStoreItem( srcbag, srcslot, sSrc, pDstItem, true ); msg = _player->CanStoreItem( srcbag, srcslot, sSrc, pDstItem, true );

View file

@ -553,7 +553,7 @@ bool ChatHandler::HandleGameObjectDeleteCommand(const char* args)
if(owner_guid) if(owner_guid)
{ {
Unit* owner = ObjectAccessor::GetUnit(*m_session->GetPlayer(),owner_guid); Unit* owner = ObjectAccessor::GetUnit(*m_session->GetPlayer(),owner_guid);
if(!owner && !IS_PLAYER_GUID(owner_guid)) if(!owner || !IS_PLAYER_GUID(owner_guid))
{ {
PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow()); PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow());
SetSentErrorMessage(true); SetSentErrorMessage(true);
@ -734,7 +734,7 @@ bool ChatHandler::HandleGameObjectAddCommand(const char* args)
GameObject* pGameObj = new GameObject; GameObject* pGameObj = new GameObject;
uint32 db_lowGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); uint32 db_lowGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
if(!pGameObj->Create(db_lowGUID, goI->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, 1)) if(!pGameObj->Create(db_lowGUID, goI->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{ {
delete pGameObj; delete pGameObj;
return false; return false;
@ -1369,7 +1369,7 @@ bool ChatHandler::HandleNpcMoveCommand(const char* args)
if(!cId) if(!cId)
return false; return false;
uint32 lowguid = atoi(cId); lowguid = atoi(cId);
/* FIXME: impossibel without entry /* FIXME: impossibel without entry
if(lowguid) if(lowguid)

View file

@ -3896,6 +3896,124 @@ bool ChatHandler::HandleHoverCommand(const char* args)
return true; return true;
} }
void ChatHandler::HandleCharacterLevel(Player* player, uint64 player_guid, uint32 oldlevel, uint32 newlevel)
{
if(player)
{
player->GiveLevel(newlevel);
player->InitTalentForLevel();
player->SetUInt32Value(PLAYER_XP,0);
if(needReportToTarget(player))
{
if(oldlevel == newlevel)
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET,GetNameLink().c_str());
else if(oldlevel < newlevel)
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_UP,GetNameLink().c_str(),newlevel);
else // if(oldlevel > newlevel)
ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_DOWN,GetNameLink().c_str(),newlevel);
}
}
else
{
// update level and XP at level, all other will be updated at loading
Tokens values;
Player::LoadValuesArrayFromDB(values,player_guid);
Player::SetUInt32ValueInArray(values,UNIT_FIELD_LEVEL,newlevel);
Player::SetUInt32ValueInArray(values,PLAYER_XP,0);
Player::SaveValuesArrayInDB(values,player_guid);
}
}
bool ChatHandler::HandleCharacterLevelCommand(const char* args)
{
char* px = strtok((char*)args, " ");
char* py = strtok((char*)NULL, " ");
// command format parsing
char* pname = (char*)NULL;
int32 newlevel = 0;
if(px && py) // .character level $name #level
{
newlevel = atoi(py);
pname = px;
}
else if(px && !py) // .character level $name OR .character level #level
{
if(isalpha(px[0])) // .character level $name
pname = px;
else // .character level #level
newlevel = atoi(px);
}
// // .character level - progress reset
if(newlevel < 1)
return false; // invalid level
if(newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level
newlevel = STRONG_MAX_LEVEL;
// player
Player *chr = NULL;
uint64 chr_guid = 0;
std::string name;
if(pname) // player by name
{
name = extractPlayerNameFromLink(pname);
if(name.empty())
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
chr = objmgr.GetPlayer(name.c_str());
if(!chr) // not in game
{
chr_guid = objmgr.GetPlayerGUIDByName(name);
if (chr_guid == 0)
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
}
}
else // player by selection
{
chr = getSelectedPlayer();
if (chr == NULL)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true);
return false;
}
name = chr->GetName();
}
assert(chr || chr_guid);
int32 oldlevel = chr ? chr->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL,chr_guid);
if(!px && !py) // .character level - progress reset
newlevel = oldlevel;
HandleCharacterLevel(chr,chr_guid,oldlevel,newlevel);
if(m_session && m_session->GetPlayer() != chr) // including player==NULL
{
std::string nameLink = playerLink(name);
PSendSysMessage(LANG_YOU_CHANGE_LVL,nameLink.c_str(),newlevel);
}
return true;
}
bool ChatHandler::HandleLevelUpCommand(const char* args) bool ChatHandler::HandleLevelUpCommand(const char* args)
{ {
char* px = strtok((char*)args, " "); char* px = strtok((char*)args, " ");
@ -3970,36 +4088,14 @@ bool ChatHandler::HandleLevelUpCommand(const char* args)
if(newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level if(newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level
newlevel = STRONG_MAX_LEVEL; newlevel = STRONG_MAX_LEVEL;
if(chr) HandleCharacterLevel(chr,chr_guid,oldlevel,newlevel);
{
chr->GiveLevel(newlevel);
chr->InitTalentForLevel();
chr->SetUInt32Value(PLAYER_XP,0);
if(oldlevel == newlevel) if(m_session && m_session->GetPlayer() != chr) // including chr==NULL
ChatHandler(chr).SendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET);
else
if(oldlevel < newlevel)
ChatHandler(chr).PSendSysMessage(LANG_YOURS_LEVEL_UP,newlevel-oldlevel);
else
if(oldlevel > newlevel)
ChatHandler(chr).PSendSysMessage(LANG_YOURS_LEVEL_DOWN,newlevel-oldlevel);
}
else
{
// update level and XP at level, all other will be updated at loading
Tokens values;
Player::LoadValuesArrayFromDB(values,chr_guid);
Player::SetUInt32ValueInArray(values,UNIT_FIELD_LEVEL,newlevel);
Player::SetUInt32ValueInArray(values,PLAYER_XP,0);
Player::SaveValuesArrayInDB(values,chr_guid);
}
if(m_session->GetPlayer() != chr) // including chr==NULL
{ {
std::string nameLink = playerLink(name); std::string nameLink = playerLink(name);
PSendSysMessage(LANG_YOU_CHANGE_LVL,nameLink.c_str(),newlevel); PSendSysMessage(LANG_YOU_CHANGE_LVL,nameLink.c_str(),newlevel);
} }
return true; return true;
} }

View file

@ -208,7 +208,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave *save,
} }
// some instances only have one difficulty // some instances only have one difficulty
if(!entry->SupportsHeroicMode()) difficulty = DIFFICULTY_NORMAL; if (entry && !entry->SupportsHeroicMode()) difficulty = DIFFICULTY_NORMAL;
sLog.outDebug("MapInstanced::CreateInstance: %smap instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal"); sLog.outDebug("MapInstanced::CreateInstance: %smap instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");

View file

@ -1330,7 +1330,10 @@ void WorldSession::HandleReportSpamOpcode( WorldPacket & recv_data )
uint8 spam_type; // 0 - mail, 1 - chat uint8 spam_type; // 0 - mail, 1 - chat
uint64 spammer_guid; uint64 spammer_guid;
uint32 unk1, unk2, unk3, unk4 = 0; uint32 unk1 = 0;
uint32 unk2 = 0;
uint32 unk3 = 0;
uint32 unk4 = 0;
std::string description = ""; std::string description = "";
recv_data >> spam_type; // unk 0x01 const, may be spam type (mail/chat) recv_data >> spam_type; // unk 0x01 const, may be spam type (mail/chat)
recv_data >> spammer_guid; // player guid recv_data >> spammer_guid; // player guid

View file

@ -601,12 +601,12 @@ void ObjectMgr::LoadCreatureTemplates()
sLog.outErrorDb("Creature (Entry: %u) has non-existing PetSpellDataId (%u)", cInfo->Entry, cInfo->PetSpellDataId); sLog.outErrorDb("Creature (Entry: %u) has non-existing PetSpellDataId (%u)", cInfo->Entry, cInfo->PetSpellDataId);
} }
for(int i = 0; i < CREATURE_MAX_SPELLS; ++i) for(int j = 0; j < CREATURE_MAX_SPELLS; ++j)
{ {
if(cInfo->spells[i] && !sSpellStore.LookupEntry(cInfo->spells[i])) if(cInfo->spells[j] && !sSpellStore.LookupEntry(cInfo->spells[j]))
{ {
sLog.outErrorDb("Creature (Entry: %u) has non-existing Spell%d (%u), set to 0", cInfo->Entry, i+1,cInfo->spells[i]); sLog.outErrorDb("Creature (Entry: %u) has non-existing Spell%d (%u), set to 0", cInfo->Entry, j+1,cInfo->spells[j]);
const_cast<CreatureInfo*>(cInfo)->spells[i] = 0; const_cast<CreatureInfo*>(cInfo)->spells[j] = 0;
} }
} }
@ -1082,7 +1082,15 @@ void ObjectMgr::LoadGameobjects()
data.rotation3 = fields[10].GetFloat(); data.rotation3 = fields[10].GetFloat();
data.spawntimesecs = fields[11].GetInt32(); data.spawntimesecs = fields[11].GetInt32();
data.animprogress = fields[12].GetUInt32(); data.animprogress = fields[12].GetUInt32();
data.go_state = fields[13].GetUInt32();
uint32 go_state = fields[13].GetUInt32();
if (go_state >= MAX_GO_STATE)
{
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid `state` (%u) value, skip",guid,data.id,go_state);
continue;
}
data.go_state = GOState(go_state);
data.spawnMask = fields[14].GetUInt8(); data.spawnMask = fields[14].GetUInt8();
data.phaseMask = fields[15].GetUInt16(); data.phaseMask = fields[15].GetUInt16();
int16 gameEvent = fields[16].GetInt16(); int16 gameEvent = fields[16].GetInt16();
@ -2687,15 +2695,15 @@ void ObjectMgr::LoadGroups()
result = CharacterDatabase.Query("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid"); result = CharacterDatabase.Query("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid");
if(!result) if(!result)
{ {
barGoLink bar( 1 ); barGoLink bar2( 1 );
bar.step(); bar2.step();
} }
else else
{ {
barGoLink bar( result->GetRowCount() ); barGoLink bar2( result->GetRowCount() );
do do
{ {
bar.step(); bar2.step();
Field *fields = result->Fetch(); Field *fields = result->Fetch();
count++; count++;
leaderGuid = MAKE_NEW_GUID(fields[3].GetUInt32(), 0, HIGHGUID_PLAYER); leaderGuid = MAKE_NEW_GUID(fields[3].GetUInt32(), 0, HIGHGUID_PLAYER);
@ -2747,15 +2755,15 @@ void ObjectMgr::LoadGroups()
if(!result) if(!result)
{ {
barGoLink bar( 1 ); barGoLink bar2( 1 );
bar.step(); bar2.step();
} }
else else
{ {
barGoLink bar( result->GetRowCount() ); barGoLink bar2( result->GetRowCount() );
do do
{ {
bar.step(); bar2.step();
Field *fields = result->Fetch(); Field *fields = result->Fetch();
count++; count++;
leaderGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); leaderGuid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
@ -3142,7 +3150,7 @@ void ObjectMgr::LoadQuests()
{ {
sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u but spell %u does not exist, quest can't be done.", sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u but spell %u does not exist, quest can't be done.",
qinfo->GetQuestId(),j+1,id,id); qinfo->GetQuestId(),j+1,id,id);
// no changes, quest can't be done for this requirement continue;
} }
if(!qinfo->ReqCreatureOrGOId[j]) if(!qinfo->ReqCreatureOrGOId[j])

View file

@ -339,10 +339,10 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
delete m_declinedname; delete m_declinedname;
m_declinedname = new DeclinedName; m_declinedname = new DeclinedName;
Field *fields = result->Fetch(); Field *fields2 = result->Fetch();
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{ {
m_declinedname->name[i] = fields[i].GetCppString(); m_declinedname->name[i] = fields2[i].GetCppString();
} }
} }
} }
@ -1321,19 +1321,19 @@ bool Pet::addSpell(uint32 spell_id, uint16 active, PetSpellState state, PetSpell
} }
else if(uint32 chainstart = spellmgr.GetFirstSpellInChain(spell_id)) else if(uint32 chainstart = spellmgr.GetFirstSpellInChain(spell_id))
{ {
for (PetSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) for (PetSpellMap::iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2)
{ {
if(itr->second->state == PETSPELL_REMOVED) continue; if(itr2->second->state == PETSPELL_REMOVED) continue;
if(spellmgr.GetFirstSpellInChain(itr->first) == chainstart) if(spellmgr.GetFirstSpellInChain(itr2->first) == chainstart)
{ {
newspell->active = itr->second->active; newspell->active = itr2->second->active;
if(newspell->active == ACT_ENABLED) if(newspell->active == ACT_ENABLED)
ToggleAutocast(itr->first, false); ToggleAutocast(itr2->first, false);
oldspell_id = itr->first; oldspell_id = itr2->first;
unlearnSpell(itr->first); unlearnSpell(itr2->first);
break; break;
} }
} }

View file

@ -193,10 +193,19 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
//auto turn to target unless possessed //auto turn to target unless possessed
if(result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) if(result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS))
{
if(unit_target)
{ {
pet->SetInFront(unit_target); pet->SetInFront(unit_target);
if (unit_target->GetTypeId() == TYPEID_PLAYER) if (unit_target->GetTypeId() == TYPEID_PLAYER)
pet->SendUpdateToPlayer( (Player*)unit_target ); pet->SendUpdateToPlayer( (Player*)unit_target );
}
else if(Unit *unit_target2 = spell->m_targets.getUnitTarget())
{
pet->SetInFront(unit_target2);
if (unit_target2->GetTypeId() == TYPEID_PLAYER)
pet->SendUpdateToPlayer( (Player*)unit_target2 );
}
if (Unit* powner = pet->GetCharmerOrOwner()) if (Unit* powner = pet->GetCharmerOrOwner())
if(powner->GetTypeId() == TYPEID_PLAYER) if(powner->GetTypeId() == TYPEID_PLAYER)
pet->SendUpdateToPlayer((Player*)powner); pet->SendUpdateToPlayer((Player*)powner);

View file

@ -279,8 +279,8 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)
for(uint8 i = 1; i <= signs; i++) for(uint8 i = 1; i <= signs; i++)
{ {
Field *fields = result->Fetch(); Field *fields2 = result->Fetch();
uint64 plguid = fields[0].GetUInt64(); uint64 plguid = fields2[0].GetUInt64();
data << plguid; // Player GUID data << plguid; // Player GUID
data << (uint32)0; // there 0 ... data << (uint32)0; // there 0 ...
@ -690,8 +690,8 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
for(uint8 i = 1; i <= signs; i++) for(uint8 i = 1; i <= signs; i++)
{ {
Field *fields = result->Fetch(); Field *fields2 = result->Fetch();
uint64 plguid = fields[0].GetUInt64(); plguid = fields2[0].GetUInt64();
data << plguid; // Player GUID data << plguid; // Player GUID
data << (uint32)0; // there 0 ... data << (uint32)0; // there 0 ...

View file

@ -755,7 +755,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
} }
// if this is ammo then use it // if this is ammo then use it
uint8 msg = CanUseAmmo( pItem->GetEntry() ); msg = CanUseAmmo( pItem->GetEntry() );
if( msg == EQUIP_ERR_OK ) if( msg == EQUIP_ERR_OK )
SetAmmo( pItem->GetEntry() ); SetAmmo( pItem->GetEntry() );
} }
@ -859,8 +859,8 @@ void Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
DEBUG_LOG("We are fall to death, loosing 10 percents durability"); DEBUG_LOG("We are fall to death, loosing 10 percents durability");
DurabilityLossAll(0.10f,false); DurabilityLossAll(0.10f,false);
// durability lost message // durability lost message
WorldPacket data(SMSG_DURABILITY_DAMAGE_DEATH, 0); WorldPacket data2(SMSG_DURABILITY_DAMAGE_DEATH, 0);
GetSession()->SendPacket(&data); GetSession()->SendPacket(&data2);
} }
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM, 1, type); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM, 1, type);
@ -1130,7 +1130,7 @@ void Player::Update( uint32 p_time )
if (hasUnitState(UNIT_STAT_MELEE_ATTACKING)) if (hasUnitState(UNIT_STAT_MELEE_ATTACKING))
{ {
Unit *pVictim = getVictim(); Unit *pVictim = getVictim();
if( !IsNonMeleeSpellCasted(false) && pVictim) if (pVictim && !IsNonMeleeSpellCasted(false))
{ {
// default combat reach 10 // default combat reach 10
// TODO add weapon,skill check // TODO add weapon,skill check
@ -2798,39 +2798,39 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
// replace spells in action bars and spellbook to bigger rank if only one spell rank must be accessible // replace spells in action bars and spellbook to bigger rank if only one spell rank must be accessible
if(newspell->active && !newspell->disabled && !SpellMgr::canStackSpellRanks(spellInfo) && spellmgr.GetSpellRank(spellInfo->Id) != 0) if(newspell->active && !newspell->disabled && !SpellMgr::canStackSpellRanks(spellInfo) && spellmgr.GetSpellRank(spellInfo->Id) != 0)
{ {
for( PlayerSpellMap::iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr ) for( PlayerSpellMap::iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2 )
{ {
if(itr->second->state == PLAYERSPELL_REMOVED) continue; if(itr2->second->state == PLAYERSPELL_REMOVED) continue;
SpellEntry const *i_spellInfo = sSpellStore.LookupEntry(itr->first); SpellEntry const *i_spellInfo = sSpellStore.LookupEntry(itr2->first);
if(!i_spellInfo) continue; if(!i_spellInfo) continue;
if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr->first) ) if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr2->first) )
{ {
if(itr->second->active) if(itr2->second->active)
{ {
if(spellmgr.IsHighRankOfSpell(spell_id,itr->first)) if(spellmgr.IsHighRankOfSpell(spell_id,itr2->first))
{ {
if(IsInWorld()) // not send spell (re-/over-)learn packets at loading if(IsInWorld()) // not send spell (re-/over-)learn packets at loading
{ {
WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); WorldPacket data(SMSG_SUPERCEDED_SPELL, (4));
data << uint32(itr->first); data << uint32(itr2->first);
data << uint32(spell_id); data << uint32(spell_id);
GetSession()->SendPacket( &data ); GetSession()->SendPacket( &data );
} }
// mark old spell as disable (SMSG_SUPERCEDED_SPELL replace it in client by new) // mark old spell as disable (SMSG_SUPERCEDED_SPELL replace it in client by new)
itr->second->active = false; itr2->second->active = false;
if(itr->second->state != PLAYERSPELL_NEW) if(itr2->second->state != PLAYERSPELL_NEW)
itr->second->state = PLAYERSPELL_CHANGED; itr2->second->state = PLAYERSPELL_CHANGED;
superceded_old = true; // new spell replace old in action bars and spell book. superceded_old = true; // new spell replace old in action bars and spell book.
} }
else if(spellmgr.IsHighRankOfSpell(itr->first,spell_id)) else if(spellmgr.IsHighRankOfSpell(itr2->first,spell_id))
{ {
if(IsInWorld()) // not send spell (re-/over-)learn packets at loading if(IsInWorld()) // not send spell (re-/over-)learn packets at loading
{ {
WorldPacket data(SMSG_SUPERCEDED_SPELL, (4)); WorldPacket data(SMSG_SUPERCEDED_SPELL, (4));
data << uint32(spell_id); data << uint32(spell_id);
data << uint32(itr->first); data << uint32(itr2->first);
GetSession()->SendPacket( &data ); GetSession()->SendPacket( &data );
} }
@ -2943,14 +2943,14 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
SpellLearnSpellMap::const_iterator spell_begin = spellmgr.GetBeginSpellLearnSpell(spell_id); SpellLearnSpellMap::const_iterator spell_begin = spellmgr.GetBeginSpellLearnSpell(spell_id);
SpellLearnSpellMap::const_iterator spell_end = spellmgr.GetEndSpellLearnSpell(spell_id); SpellLearnSpellMap::const_iterator spell_end = spellmgr.GetEndSpellLearnSpell(spell_id);
for(SpellLearnSpellMap::const_iterator itr = spell_begin; itr != spell_end; ++itr) for(SpellLearnSpellMap::const_iterator itr2 = spell_begin; itr2 != spell_end; ++itr2)
{ {
if(!itr->second.autoLearned) if(!itr2->second.autoLearned)
{ {
if(!IsInWorld() || !itr->second.active) // at spells loading, no output, but allow save if(!IsInWorld() || !itr2->second.active) // at spells loading, no output, but allow save
addSpell(itr->second.spell,itr->second.active,true,true,false); addSpell(itr2->second.spell,itr2->second.active,true,true,false);
else // at normal learning else // at normal learning
learnSpell(itr->second.spell,true); learnSpell(itr2->second.spell,true);
} }
} }
@ -5212,15 +5212,15 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal)
// temporary bonuses // temporary bonuses
AuraList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL); AuraList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL);
for(AuraList::const_iterator i = mModSkill.begin(); i != mModSkill.end(); ++i) for(AuraList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j)
if ((*i)->GetModifier()->m_miscvalue == int32(id)) if ((*j)->GetModifier()->m_miscvalue == int32(id))
(*i)->ApplyModifier(true); (*j)->ApplyModifier(true);
// permanent bonuses // permanent bonuses
AuraList const& mModSkillTalent = GetAurasByType(SPELL_AURA_MOD_SKILL_TALENT); AuraList const& mModSkillTalent = GetAurasByType(SPELL_AURA_MOD_SKILL_TALENT);
for(AuraList::const_iterator i = mModSkillTalent.begin(); i != mModSkillTalent.end(); ++i) for(AuraList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j)
if ((*i)->GetModifier()->m_miscvalue == int32(id)) if ((*j)->GetModifier()->m_miscvalue == int32(id))
(*i)->ApplyModifier(true); (*j)->ApplyModifier(true);
// Learn all spells for skill // Learn all spells for skill
learnSkillRewardedSpells(id, currVal); learnSkillRewardedSpells(id, currVal);
@ -5676,7 +5676,7 @@ void Player::RewardReputation(Unit *pVictim, float rate)
GetReputationMgr().ModifyReputation(factionEntry1, donerep1); GetReputationMgr().ModifyReputation(factionEntry1, donerep1);
// Wiki: Team factions value divided by 2 // Wiki: Team factions value divided by 2
if(Rep->is_teamaward1) if (factionEntry1 && Rep->is_teamaward1)
{ {
FactionEntry const *team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team); FactionEntry const *team1_factionEntry = sFactionStore.LookupEntry(factionEntry1->team);
if(team1_factionEntry) if(team1_factionEntry)
@ -5694,7 +5694,7 @@ void Player::RewardReputation(Unit *pVictim, float rate)
GetReputationMgr().ModifyReputation(factionEntry2, donerep2); GetReputationMgr().ModifyReputation(factionEntry2, donerep2);
// Wiki: Team factions value divided by 2 // Wiki: Team factions value divided by 2
if(Rep->is_teamaward2) if (factionEntry2 && Rep->is_teamaward2)
{ {
FactionEntry const *team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team); FactionEntry const *team2_factionEntry = sFactionStore.LookupEntry(factionEntry2->team);
if(team2_factionEntry) if(team2_factionEntry)
@ -7070,12 +7070,6 @@ void Player::RemovedInsignia(Player* looterPlr)
looterPlr->SendLoot(bones->GetGUID(), LOOT_INSIGNIA); looterPlr->SendLoot(bones->GetGUID(), LOOT_INSIGNIA);
} }
/*Loot type MUST be
1-corpse, go
2-skinning
3-Fishing
*/
void Player::SendLootRelease( uint64 guid ) void Player::SendLootRelease( uint64 guid )
{ {
WorldPacket data( SMSG_LOOT_RELEASE_RESPONSE, (8+1) ); WorldPacket data( SMSG_LOOT_RELEASE_RESPONSE, (8+1) );
@ -7134,50 +7128,28 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
return; return;
} }
if(loot_type == LOOT_DISENCHANTING)
{
loot = &item->loot; loot = &item->loot;
if (!item->m_lootGenerated) if (!item->m_lootGenerated)
{ {
item->m_lootGenerated = true; item->m_lootGenerated = true;
loot->clear(); loot->clear();
switch(loot_type)
{
case LOOT_DISENCHANTING:
loot->FillLoot(item->GetProto()->DisenchantID, LootTemplates_Disenchant, this,true); loot->FillLoot(item->GetProto()->DisenchantID, LootTemplates_Disenchant, this,true);
} break;
} case LOOT_PROSPECTING:
else if(loot_type == LOOT_PROSPECTING)
{
loot = &item->loot;
if(!item->m_lootGenerated)
{
item->m_lootGenerated = true;
loot->clear();
loot->FillLoot(item->GetEntry(), LootTemplates_Prospecting, this,true); loot->FillLoot(item->GetEntry(), LootTemplates_Prospecting, this,true);
} break;
} case LOOT_MILLING:
else if(loot_type == LOOT_MILLING)
{
loot = &item->loot;
if(!item->m_lootGenerated)
{
item->m_lootGenerated = true;
loot->clear();
loot->FillLoot(item->GetEntry(), LootTemplates_Milling, this,true); loot->FillLoot(item->GetEntry(), LootTemplates_Milling, this,true);
} break;
} default:
else
{
loot = &item->loot;
if(!item->m_lootGenerated)
{
item->m_lootGenerated = true;
loot->clear();
loot->FillLoot(item->GetEntry(), LootTemplates_Item, this,true); loot->FillLoot(item->GetEntry(), LootTemplates_Item, this,true);
loot->generateMoneyLoot(item->GetProto()->MinMoneyLoot,item->GetProto()->MaxMoneyLoot); loot->generateMoneyLoot(item->GetProto()->MinMoneyLoot,item->GetProto()->MaxMoneyLoot);
break;
} }
} }
} }
@ -7327,12 +7299,13 @@ void Player::SendLoot(uint64 guid, LootType loot_type)
SetLootGUID(guid); SetLootGUID(guid);
// LOOT_PICKPOCKETING, LOOT_PROSPECTING, LOOT_DISENCHANTING, LOOT_INSIGNIA and LOOT_MILLING unsupported by client, sending LOOT_SKINNING instead // LOOT_INSIGNIA and LOOT_FISHINGHOLE unsupported by client
if(loot_type == LOOT_PICKPOCKETING || loot_type == LOOT_DISENCHANTING || loot_type == LOOT_PROSPECTING || loot_type == LOOT_INSIGNIA || loot_type == LOOT_MILLING) switch(loot_type)
loot_type = LOOT_SKINNING; {
case LOOT_INSIGNIA: loot_type = LOOT_SKINNING; break;
if(loot_type == LOOT_FISHINGHOLE) case LOOT_FISHINGHOLE: loot_type = LOOT_FISHING; break;
loot_type = LOOT_FISHING; default: break;
}
WorldPacket data(SMSG_LOOT_RESPONSE, (9+50)); // we guess size WorldPacket data(SMSG_LOOT_RESPONSE, (9+50)); // we guess size
@ -9535,8 +9508,8 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
return EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE; return EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE;
// if swap ignore item (equipped also) // if swap ignore item (equipped also)
if(uint8 res = CanEquipUniqueItem(pItem, swap ? eslot : NULL_SLOT)) if(uint8 res2 = CanEquipUniqueItem(pItem, swap ? eslot : NULL_SLOT))
return res; return res2;
// check unique-equipped special item classes // check unique-equipped special item classes
if (pProto->Class == ITEM_CLASS_QUIVER) if (pProto->Class == ITEM_CLASS_QUIVER)
@ -10127,8 +10100,7 @@ Item* Player::EquipNewItem( uint16 pos, uint32 item, bool update )
Item* Player::EquipItem( uint16 pos, Item *pItem, bool update ) Item* Player::EquipItem( uint16 pos, Item *pItem, bool update )
{ {
if( pItem )
{
AddEnchantmentDurations(pItem); AddEnchantmentDurations(pItem);
AddItemDurations(pItem); AddItemDurations(pItem);
@ -10214,10 +10186,10 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update )
return pItem2; return pItem2;
} }
}
// only for full equip instead adding to stack // only for full equip instead adding to stack
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry());
return pItem; return pItem;
} }
@ -10968,7 +10940,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
// check src->dest move possibility // check src->dest move possibility
ItemPosCountVec sDest; ItemPosCountVec sDest;
uint16 eDest; uint16 eDest = 0;
if( IsInventoryPos( dst ) ) if( IsInventoryPos( dst ) )
msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, true ); msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, true );
else if( IsBankPos( dst ) ) else if( IsBankPos( dst ) )
@ -10988,7 +10960,7 @@ void Player::SwapItem( uint16 src, uint16 dst )
// check dest->src move possibility // check dest->src move possibility
ItemPosCountVec sDest2; ItemPosCountVec sDest2;
uint16 eDest2; uint16 eDest2 = 0;
if( IsInventoryPos( src ) ) if( IsInventoryPos( src ) )
msg = CanStoreItem( srcbag, srcslot, sDest2, pDstItem, true ); msg = CanStoreItem( srcbag, srcslot, sDest2, pDstItem, true );
else if( IsBankPos( src ) ) else if( IsBankPos( src ) )
@ -12015,14 +11987,14 @@ bool Player::CanAddQuest( Quest const *pQuest, bool msg )
{ {
uint32 count = pQuest->GetSrcItemCount(); uint32 count = pQuest->GetSrcItemCount();
ItemPosCountVec dest; ItemPosCountVec dest;
uint8 msg = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count ); uint8 msg2 = CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, srcitem, count );
// player already have max number (in most case 1) source item, no additional item needed and quest can be added. // player already have max number (in most case 1) source item, no additional item needed and quest can be added.
if( msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS ) if( msg2 == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS )
return true; return true;
else if( msg != EQUIP_ERR_OK ) else if( msg2 != EQUIP_ERR_OK )
{ {
SendEquipError( msg, NULL, NULL ); SendEquipError( msg2, NULL, NULL );
return false; return false;
} }
} }
@ -12623,14 +12595,14 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg )
// each-from-all exclusive group ( < 0) // each-from-all exclusive group ( < 0)
// can be start if only all quests in prev quest exclusive group completed and rewarded // can be start if only all quests in prev quest exclusive group completed and rewarded
ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup()); ObjectMgr::ExclusiveQuestGroups::iterator iter2 = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup());
ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup()); ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup());
assert(iter!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0 assert(iter2!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0
for(; iter != end; ++iter) for(; iter2 != end; ++iter2)
{ {
uint32 exclude_Id = iter->second; uint32 exclude_Id = iter2->second;
// skip checked quest id, only state of other quests in group is interesting // skip checked quest id, only state of other quests in group is interesting
if(exclude_Id == prevId) if(exclude_Id == prevId)
@ -12658,14 +12630,14 @@ bool Player::SatisfyQuestPreviousQuest( Quest const* qInfo, bool msg )
// each-from-all exclusive group ( < 0) // each-from-all exclusive group ( < 0)
// can be start if only all quests in prev quest exclusive group active // can be start if only all quests in prev quest exclusive group active
ObjectMgr::ExclusiveQuestGroups::iterator iter = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup()); ObjectMgr::ExclusiveQuestGroups::iterator iter2 = objmgr.mExclusiveQuestGroups.lower_bound(qPrevInfo->GetExclusiveGroup());
ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup()); ObjectMgr::ExclusiveQuestGroups::iterator end = objmgr.mExclusiveQuestGroups.upper_bound(qPrevInfo->GetExclusiveGroup());
assert(iter!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0 assert(iter2!=end); // always must be found if qPrevInfo->ExclusiveGroup != 0
for(; iter != end; ++iter) for(; iter2 != end; ++iter2)
{ {
uint32 exclude_Id = iter->second; uint32 exclude_Id = iter2->second;
// skip checked quest id, only state of other quests in group is interesting // skip checked quest id, only state of other quests in group is interesting
if(exclude_Id == prevId) if(exclude_Id == prevId)
@ -17729,8 +17701,8 @@ void Player::AddComboPoints(Unit* target, int8 count)
else else
{ {
if(m_comboTarget) if(m_comboTarget)
if(Unit* target = ObjectAccessor::GetUnit(*this,m_comboTarget)) if(Unit* target2 = ObjectAccessor::GetUnit(*this,m_comboTarget))
target->RemoveComboPointHolder(GetGUIDLow()); target2->RemoveComboPointHolder(GetGUIDLow());
m_comboTarget = target->GetGUID(); m_comboTarget = target->GetGUID();
m_comboPoints = count; m_comboPoints = count;
@ -17853,10 +17825,10 @@ void Player::SendInitialPacketsAfterAddToMap()
// manual send package (have code in ApplyModifier(true,true); that don't must be re-applied. // manual send package (have code in ApplyModifier(true,true); that don't must be re-applied.
if(HasAuraType(SPELL_AURA_MOD_ROOT)) if(HasAuraType(SPELL_AURA_MOD_ROOT))
{ {
WorldPacket data(SMSG_FORCE_MOVE_ROOT, 10); WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10);
data.append(GetPackGUID()); data2.append(GetPackGUID());
data << (uint32)2; data2 << (uint32)2;
SendMessageToSet(&data,true); SendMessageToSet(&data2,true);
} }
SendAurasForTarget(this); SendAurasForTarget(this);

View file

@ -462,14 +462,16 @@ enum ActivateTaxiReplies
enum LootType enum LootType
{ {
LOOT_CORPSE = 1, LOOT_CORPSE = 1,
LOOT_SKINNING = 2, LOOT_PICKPOCKETING = 2,
LOOT_FISHING = 3, LOOT_FISHING = 3,
LOOT_PICKPOCKETING = 4, // unsupported by client, sending LOOT_SKINNING instead LOOT_DISENCHANTING = 4,
LOOT_DISENCHANTING = 5, // unsupported by client, sending LOOT_SKINNING instead // ignored always by client
LOOT_PROSPECTING = 6, // unsupported by client, sending LOOT_SKINNING instead LOOT_SKINNING = 6,
LOOT_INSIGNIA = 7, // unsupported by client, sending LOOT_SKINNING instead LOOT_PROSPECTING = 7,
LOOT_FISHINGHOLE = 8, // unsupported by client, sending LOOT_FISHING instead LOOT_MILLING = 8,
LOOT_MILLING = 9 // unsupported by client, sending LOOT_SKINNING instead
LOOT_FISHINGHOLE = 20, // unsupported by client, sending LOOT_FISHING instead
LOOT_INSIGNIA = 21 // unsupported by client, sending LOOT_CORPSE instead
}; };
enum MirrorTimerType enum MirrorTimerType

View file

@ -356,6 +356,8 @@ std::string PlayerDumpWriter::GetDump(uint32 guid)
} }
else else
sLog.outError("Table 'character_db_version' not have revision guard field, revision guard query not added to pdump."); sLog.outError("Table 'character_db_version' not have revision guard field, revision guard query not added to pdump.");
delete result;
} }
else else
sLog.outError("Character DB not have 'character_db_version' table, revision guard query not added to pdump."); sLog.outError("Character DB not have 'character_db_version' table, revision guard query not added to pdump.");

View file

@ -48,11 +48,12 @@ ReactorAI::AttackStart(Unit *p)
if(m_creature->Attack(p,true)) if(m_creature->Attack(p,true))
{ {
DEBUG_LOG("Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId()); DEBUG_LOG("Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId());
i_victimGuid = p->GetGUID();
m_creature->AddThreat(p, 0.0f);
m_creature->SetInCombatWith(p); m_creature->SetInCombatWith(p);
p->SetInCombatWith(m_creature); p->SetInCombatWith(m_creature);
m_creature->AddThreat(p, 0.0f);
i_victimGuid = p->GetGUID();
m_creature->GetMotionMaster()->MoveChase(p); m_creature->GetMotionMaster()->MoveChase(p);
} }
} }

View file

@ -1158,6 +1158,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
if(!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI()) if(!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI())
((Creature*)unit)->AI()->AttackedBy(m_caster); ((Creature*)unit)->AI()->AttackedBy(m_caster);
unit->AddThreat(m_caster, 0.0f);
unit->SetInCombatWith(m_caster); unit->SetInCombatWith(m_caster);
m_caster->SetInCombatWith(unit); m_caster->SetInCombatWith(unit);
@ -1165,7 +1166,6 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
{ {
m_caster->SetContestedPvP(attackedPlayer); m_caster->SetContestedPvP(attackedPlayer);
} }
unit->AddThreat(m_caster, 0.0f);
} }
} }
else else

View file

@ -2185,11 +2185,12 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
if( GetId()==24658 ) if( GetId()==24658 )
{ {
uint32 spellId = 24659; uint32 spellId = 24659;
if (apply) if (apply && caster)
{ {
const SpellEntry *spell = sSpellStore.LookupEntry(spellId); const SpellEntry *spell = sSpellStore.LookupEntry(spellId);
if (!spell) if (!spell)
return; return;
for (int i=0; i < spell->StackAmount; ++i) for (int i=0; i < spell->StackAmount; ++i)
caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID()); caster->CastSpell(m_target, spell->Id, true, NULL, NULL, GetCasterGUID());
return; return;
@ -2201,7 +2202,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
if( GetId()==24661 ) if( GetId()==24661 )
{ {
uint32 spellId = 24662; uint32 spellId = 24662;
if (apply) if (apply && caster)
{ {
const SpellEntry *spell = sSpellStore.LookupEntry(spellId); const SpellEntry *spell = sSpellStore.LookupEntry(spellId);
if (!spell) if (!spell)
@ -3411,7 +3412,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real)
{ {
GameObject* pObj = new GameObject; GameObject* pObj = new GameObject;
if(pObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 185584, m_target->GetMap(), m_target->GetPhaseMask(), if(pObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 185584, m_target->GetMap(), m_target->GetPhaseMask(),
m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1)) m_target->GetPositionX(), m_target->GetPositionY(), m_target->GetPositionZ(), m_target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
{ {
pObj->SetRespawnTime(GetAuraDuration()/IN_MILISECONDS); pObj->SetRespawnTime(GetAuraDuration()/IN_MILISECONDS);
pObj->SetSpellId(GetId()); pObj->SetSpellId(GetId());
@ -3539,7 +3540,7 @@ void Aura::HandleModStealth(bool apply, bool Real)
else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & 0x0000000000400000LL) else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & 0x0000000000400000LL)
{ {
pTarget->RemoveAurasDueToSpell(58428); pTarget->RemoveAurasDueToSpell(58428);
pTarget->CastSpell(m_target, 58427, true); pTarget->CastSpell(pTarget, 58427, true);
} }
} }
} }
@ -3577,7 +3578,7 @@ void Aura::HandleModStealth(bool apply, bool Real)
pTarget->CastSpell(pTarget,31666,true); pTarget->CastSpell(pTarget,31666,true);
// Overkill // Overkill
else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & 0x0000000000400000LL) else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & 0x0000000000400000LL)
pTarget->CastSpell(m_target, 58428, true); pTarget->CastSpell(pTarget, 58428, true);
} }
} }
} }

View file

@ -796,7 +796,7 @@ void Spell::EffectDummy(uint32 i)
// create before death for get proper coordinates // create before death for get proper coordinates
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 179644, map, m_caster->GetPhaseMask(), if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), 179644, map, m_caster->GetPhaseMask(),
creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(), creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(),
creatureTarget->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1) ) creatureTarget->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY) )
{ {
delete pGameObj; delete pGameObj;
return; return;
@ -888,7 +888,7 @@ void Spell::EffectDummy(uint32 i)
// return; -- implemented at client side // return; -- implemented at client side
case 28006: // Arcane Cloaking case 28006: // Arcane Cloaking
{ {
if( unitTarget->GetTypeId() == TYPEID_PLAYER ) if (unitTarget && unitTarget->GetTypeId() == TYPEID_PLAYER )
m_caster->CastSpell(unitTarget,29294,true); m_caster->CastSpell(unitTarget,29294,true);
return; return;
} }
@ -1292,7 +1292,7 @@ void Spell::EffectDummy(uint32 i)
} }
// Think its not need (also need remove Life Tap from SpellDamageBonus or add new value) // Think its not need (also need remove Life Tap from SpellDamageBonus or add new value)
// damage = m_caster->SpellDamageBonus(m_caster, m_spellInfo,uint32(damage > 0 ? damage : 0), SPELL_DIRECT_DAMAGE); // damage = m_caster->SpellDamageBonus(m_caster, m_spellInfo,uint32(damage > 0 ? damage : 0), SPELL_DIRECT_DAMAGE);
if(int32(unitTarget->GetHealth()) > damage) if(unitTarget && (int32(unitTarget->GetHealth()) > damage))
{ {
// Shouldn't Appear in Combat Log // Shouldn't Appear in Combat Log
unitTarget->ModifyHealth(-damage); unitTarget->ModifyHealth(-damage);
@ -1681,9 +1681,9 @@ void Spell::EffectDummy(uint32 i)
if(m_caster->GetTypeId() != TYPEID_PLAYER) if(m_caster->GetTypeId() != TYPEID_PLAYER)
return; return;
for(int i = BASE_ATTACK; i <= OFF_ATTACK; ++i) for(int j = BASE_ATTACK; j <= OFF_ATTACK; ++j)
{ {
if(Item* item = ((Player*)m_caster)->GetWeaponForAttack(WeaponAttackType(i))) if(Item* item = ((Player*)m_caster)->GetWeaponForAttack(WeaponAttackType(j)))
{ {
if(item->IsFitToSpellRequirements(m_spellInfo)) if(item->IsFitToSpellRequirements(m_spellInfo))
{ {
@ -1912,7 +1912,7 @@ void Spell::EffectTriggerSpell(uint32 i)
if (!spell) if (!spell)
return; return;
for (int i=0; i < spell->StackAmount; ++i) for (int j=0; j < spell->StackAmount; ++j)
m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID);
return; return;
} }
@ -1923,7 +1923,7 @@ void Spell::EffectTriggerSpell(uint32 i)
if (!spell) if (!spell)
return; return;
for (int i=0; i < spell->StackAmount; ++i) for (int j=0; j < spell->StackAmount; ++j)
m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID); m_caster->CastSpell(unitTarget,spell->Id, true, m_CastItem, NULL, m_originalCasterGUID);
return; return;
} }
@ -3044,10 +3044,10 @@ void Spell::EffectSummonChangeItem(uint32 i)
if( !pNewItem ) if( !pNewItem )
return; return;
for(uint8 i= PERM_ENCHANTMENT_SLOT; i<=TEMP_ENCHANTMENT_SLOT; ++i) for(uint8 j= PERM_ENCHANTMENT_SLOT; j<=TEMP_ENCHANTMENT_SLOT; ++j)
{ {
if(m_CastItem->GetEnchantmentId(EnchantmentSlot(i))) if(m_CastItem->GetEnchantmentId(EnchantmentSlot(j)))
pNewItem->SetEnchantment(EnchantmentSlot(i), m_CastItem->GetEnchantmentId(EnchantmentSlot(i)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(i)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(i))); pNewItem->SetEnchantment(EnchantmentSlot(j), m_CastItem->GetEnchantmentId(EnchantmentSlot(j)), m_CastItem->GetEnchantmentDuration(EnchantmentSlot(j)), m_CastItem->GetEnchantmentCharges(EnchantmentSlot(j)));
} }
if(m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) < m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) if(m_CastItem->GetUInt32Value(ITEM_FIELD_DURABILITY) < m_CastItem->GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
@ -4251,9 +4251,12 @@ void Spell::EffectLearnPetSpell(uint32 i)
void Spell::EffectTaunt(uint32 /*i*/) void Spell::EffectTaunt(uint32 /*i*/)
{ {
if (!unitTarget)
return;
// this effect use before aura Taunt apply for prevent taunt already attacking target // this effect use before aura Taunt apply for prevent taunt already attacking target
// for spell as marked "non effective at already attacking target" // for spell as marked "non effective at already attacking target"
if(unitTarget && unitTarget->GetTypeId() != TYPEID_PLAYER) if (unitTarget->GetTypeId() != TYPEID_PLAYER)
{ {
if (unitTarget->getVictim()==m_caster) if (unitTarget->getVictim()==m_caster)
{ {
@ -4377,12 +4380,12 @@ void Spell::EffectWeaponDmg(uint32 i)
if(m_spellInfo->SpellFamilyFlags & 0x001000000000LL) if(m_spellInfo->SpellFamilyFlags & 0x001000000000LL)
{ {
Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); Unit::AuraList const& m_OverrideClassScript = m_caster->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for(Unit::AuraList::const_iterator i = m_OverrideClassScript.begin(); i != m_OverrideClassScript.end(); ++i) for(Unit::AuraList::const_iterator citr = m_OverrideClassScript.begin(); citr != m_OverrideClassScript.end(); ++citr)
{ {
// Stormstrike AP Buff // Stormstrike AP Buff
if ( (*i)->GetModifier()->m_miscvalue == 5634 ) if ( (*citr)->GetModifier()->m_miscvalue == 5634 )
{ {
m_caster->CastSpell(m_caster,38430,true,NULL,*i); m_caster->CastSpell(m_caster,38430,true,NULL,*citr);
break; break;
} }
} }
@ -4561,7 +4564,7 @@ void Spell::EffectSummonObjectWild(uint32 i)
Map *map = target->GetMap(); Map *map = target->GetMap();
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map, if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), gameobject_id, map,
m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1)) m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
{ {
delete pGameObj; delete pGameObj;
return; return;
@ -4609,7 +4612,7 @@ void Spell::EffectSummonObjectWild(uint32 i)
{ {
GameObject* linkedGO = new GameObject; GameObject* linkedGO = new GameObject;
if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, map, if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, map,
m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1)) m_caster->GetPhaseMask(), x, y, z, target->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
{ {
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0); linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0);
linkedGO->SetSpellId(m_spellInfo->Id); linkedGO->SetSpellId(m_spellInfo->Id);
@ -4832,7 +4835,7 @@ void Spell::EffectScriptEffect(uint32 effIndex)
if(!unitTarget) if(!unitTarget)
return; return;
uint32 spellId; uint32 spellId = 0;
switch(rand()%4) switch(rand()%4)
{ {
case 0: spellId = 46740; break; case 0: spellId = 46740; break;
@ -5263,7 +5266,7 @@ void Spell::EffectDuel(uint32 i)
m_caster->GetPositionX()+(unitTarget->GetPositionX()-m_caster->GetPositionX())/2 , m_caster->GetPositionX()+(unitTarget->GetPositionX()-m_caster->GetPositionX())/2 ,
m_caster->GetPositionY()+(unitTarget->GetPositionY()-m_caster->GetPositionY())/2 , m_caster->GetPositionY()+(unitTarget->GetPositionY()-m_caster->GetPositionY())/2 ,
m_caster->GetPositionZ(), m_caster->GetPositionZ(),
m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, 1)) m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{ {
delete pGameObj; delete pGameObj;
return; return;
@ -5653,7 +5656,7 @@ void Spell::EffectSummonObject(uint32 i)
Map *map = m_caster->GetMap(); Map *map = m_caster->GetMap();
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), go_id, map, if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), go_id, map,
m_caster->GetPhaseMask(), x, y, z, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, 1)) m_caster->GetPhaseMask(), x, y, z, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
{ {
delete pGameObj; delete pGameObj;
return; return;
@ -6243,7 +6246,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
GameObject* pGameObj = new GameObject; GameObject* pGameObj = new GameObject;
if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), name_id, cMap, if(!pGameObj->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), name_id, cMap,
m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1)) m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
{ {
delete pGameObj; delete pGameObj;
return; return;
@ -6260,7 +6263,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo)) // end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
// start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME) // start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME)
int32 lastSec; int32 lastSec = 0;
switch(urand(0, 3)) switch(urand(0, 3))
{ {
case 0: lastSec = 3; break; case 0: lastSec = 3; break;
@ -6310,7 +6313,7 @@ void Spell::EffectTransmitted(uint32 effIndex)
{ {
GameObject* linkedGO = new GameObject; GameObject* linkedGO = new GameObject;
if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, cMap, if(linkedGO->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, cMap,
m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, 1)) m_caster->GetPhaseMask(), fx, fy, fz, m_caster->GetOrientation(), 0.0f, 0.0f, 0.0f, 0.0f, 100, GO_STATE_READY))
{ {
linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0); linkedGO->SetRespawnTime(duration > 0 ? duration/IN_MILISECONDS : 0);
linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() ); linkedGO->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() );

View file

@ -470,9 +470,9 @@ class PetAura
return itr->second; return itr->second;
else else
{ {
std::map<uint16, uint16>::const_iterator itr = auras.find(0); std::map<uint16, uint16>::const_iterator itr2 = auras.find(0);
if(itr != auras.end()) if(itr2 != auras.end())
return itr->second; return itr2->second;
else else
return 0; return 0;
} }
@ -649,9 +649,9 @@ class SpellMgr
// Not found, try lookup for 1 spell rank if exist // Not found, try lookup for 1 spell rank if exist
if (uint32 rank_1 = GetFirstSpellInChain(spellId)) if (uint32 rank_1 = GetFirstSpellInChain(spellId))
{ {
SpellBonusMap::const_iterator itr = mSpellBonusMap.find(rank_1); SpellBonusMap::const_iterator itr2 = mSpellBonusMap.find(rank_1);
if( itr != mSpellBonusMap.end( ) ) if( itr2 != mSpellBonusMap.end( ) )
return &itr->second; return &itr2->second;
} }
return NULL; return NULL;
} }

View file

@ -172,7 +172,7 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z,
SetUInt32Value(GAMEOBJECT_DISPLAYID, goinfo->displayId); SetUInt32Value(GAMEOBJECT_DISPLAYID, goinfo->displayId);
SetGoState(1); SetGoState(GO_STATE_READY);
SetGoType(GameobjectTypes(goinfo->type)); SetGoType(GameobjectTypes(goinfo->type));
SetGoAnimProgress(animprogress); SetGoAnimProgress(animprogress);

View file

@ -2104,12 +2104,12 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack
if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY) ) if(pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY) )
{ {
int32 tmp = int32(parry_chance); int32 tmp2 = int32(parry_chance);
if ( (tmp > 0) // check if unit _can_ parry if ( (tmp2 > 0) // check if unit _can_ parry
&& ((tmp -= skillBonus) > 0) && ((tmp2 -= skillBonus) > 0)
&& (roll < (sum += tmp))) && (roll < (sum += tmp2)))
{ {
DEBUG_LOG ("RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp, sum); DEBUG_LOG ("RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp2, sum);
return MELEE_HIT_PARRY; return MELEE_HIT_PARRY;
} }
} }
@ -2990,7 +2990,7 @@ void Unit::SetCurrentCastedSpell( Spell * pSpell )
{ {
assert(pSpell); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells assert(pSpell); // NULL may be never passed here, use InterruptSpell or InterruptNonMeleeSpells
uint32 CSpellType = pSpell->GetCurrentContainer(); CurrentSpellTypes CSpellType = pSpell->GetCurrentContainer();
if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self
@ -8679,7 +8679,7 @@ void Unit::SetInCombatWith(Unit* enemy)
Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf(); Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf();
if(eOwner->IsPvP()) if(eOwner->IsPvP())
{ {
SetInCombatState(true); SetInCombatState(true,enemy);
return; return;
} }
@ -8689,14 +8689,14 @@ void Unit::SetInCombatWith(Unit* enemy)
Unit const* myOwner = GetCharmerOrOwnerOrSelf(); Unit const* myOwner = GetCharmerOrOwnerOrSelf();
if(((Player const*)eOwner)->duel->opponent == myOwner) if(((Player const*)eOwner)->duel->opponent == myOwner)
{ {
SetInCombatState(true); SetInCombatState(true,enemy);
return; return;
} }
} }
SetInCombatState(false); SetInCombatState(false,enemy);
} }
void Unit::SetInCombatState(bool PvP) void Unit::SetInCombatState(bool PvP, Unit* enemy)
{ {
// only alive units can be in combat // only alive units can be in combat
if(!isAlive()) if(!isAlive())
@ -8704,10 +8704,16 @@ void Unit::SetInCombatState(bool PvP)
if(PvP) if(PvP)
m_CombatTimer = 5000; m_CombatTimer = 5000;
bool creatureNotInCombat = GetTypeId()==TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
if(isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet())) if(isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->isPet()))
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
if(creatureNotInCombat && ((Creature*)this)->AI())
((Creature*)this)->AI()->EnterCombat(enemy);
} }
void Unit::ClearInCombat() void Unit::ClearInCombat()

View file

@ -1018,7 +1018,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
bool isInFlight() const { return hasUnitState(UNIT_STAT_IN_FLIGHT); } bool isInFlight() const { return hasUnitState(UNIT_STAT_IN_FLIGHT); }
bool isInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); } bool isInCombat() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); }
void SetInCombatState(bool PvP); void SetInCombatState(bool PvP, Unit* enemy = NULL);
void SetInCombatWith(Unit* enemy); void SetInCombatWith(Unit* enemy);
void ClearInCombat(); void ClearInCombat();
uint32 GetCombatTimer() const { return m_CombatTimer; } uint32 GetCombatTimer() const { return m_CombatTimer; }

View file

@ -2013,7 +2013,7 @@ void World::ScriptsProcess()
break; break;
} }
if( !door->GetGoState() ) if (door->GetGoState() != GO_STATE_READY)
break; //door already open break; //door already open
door->UseDoorOrButton(time_to_close); door->UseDoorOrButton(time_to_close);
@ -2069,7 +2069,7 @@ void World::ScriptsProcess()
break; break;
} }
if( door->GetGoState() ) if( door->GetGoState() == GO_STATE_READY )
break; //door already closed break; //door already closed
door->UseDoorOrButton(time_to_open); door->UseDoorOrButton(time_to_open);

View file

@ -395,9 +395,9 @@ bool ChatHandler::HandleDebugGetItemState(const char* args)
Bag *bag = (Bag*)item; Bag *bag = (Bag*)item;
for (uint8 j = 0; j < bag->GetBagSize(); ++j) for (uint8 j = 0; j < bag->GetBagSize(); ++j)
{ {
Item* item = bag->GetItemByPos(j); Item* item2 = bag->GetItemByPos(j);
if (item && item->GetState() == state) if (item2 && item2->GetState() == state)
PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID())); PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()));
} }
} }
} }
@ -491,58 +491,58 @@ bool ChatHandler::HandleDebugGetItemState(const char* args)
Bag *bag = (Bag*)item; Bag *bag = (Bag*)item;
for (uint8 j = 0; j < bag->GetBagSize(); ++j) for (uint8 j = 0; j < bag->GetBagSize(); ++j)
{ {
Item* item = bag->GetItemByPos(j); Item* item2 = bag->GetItemByPos(j);
if (!item) continue; if (!item2) continue;
if (item->GetSlot() != j) if (item2->GetSlot() != j)
{ {
PSendSysMessage("the item in bag %d slot %d, guid %d has an incorrect slot value: %d", bag->GetSlot(), j, item->GetGUIDLow(), item->GetSlot()); PSendSysMessage("the item in bag %d slot %d, guid %d has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUIDLow(), item2->GetSlot());
error = true; continue; error = true; continue;
} }
if (item->GetOwnerGUID() != player->GetGUID()) if (item2->GetOwnerGUID() != player->GetGUID())
{ {
PSendSysMessage("for the item in bag %d at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); PSendSysMessage("for the item in bag %d at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID()), player->GetGUIDLow());
error = true; continue; error = true; continue;
} }
Bag *container = item->GetContainer(); Bag *container = item2->GetContainer();
if (!container) if (!container)
{ {
PSendSysMessage("the item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow()); PSendSysMessage("the item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow());
error = true; continue; error = true; continue;
} }
if (container != bag) if (container != bag)
{ {
PSendSysMessage("the item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); PSendSysMessage("the item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow());
error = true; continue; error = true; continue;
} }
if (item->IsInUpdateQueue()) if (item2->IsInUpdateQueue())
{ {
uint16 qp = item->GetQueuePos(); uint16 qp = item2->GetQueuePos();
if (qp > updateQueue.size()) if (qp > updateQueue.size())
{ {
PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), qp); PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp);
error = true; continue; error = true; continue;
} }
if (updateQueue[qp] == NULL) if (updateQueue[qp] == NULL)
{ {
PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), qp); PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp);
error = true; continue; error = true; continue;
} }
if (updateQueue[qp] != item) if (updateQueue[qp] != item2)
{ {
PSendSysMessage("item in bag: %d at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); PSendSysMessage("item in bag: %d at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow());
error = true; continue; error = true; continue;
} }
} }
else if (item->GetState() != ITEM_UNCHANGED) else if (item2->GetState() != ITEM_UNCHANGED)
{ {
PSendSysMessage("item in bag: %d at slot: %d guid: %d is not in queue but should be (state: %d)!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), item->GetState()); PSendSysMessage("item in bag: %d at slot: %d guid: %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUIDLow(), item2->GetState());
error = true; continue; error = true; continue;
} }
} }

View file

@ -129,10 +129,10 @@ bool WinServiceUninstall()
serviceName, SERVICE_QUERY_STATUS | DELETE); serviceName, SERVICE_QUERY_STATUS | DELETE);
if (service) if (service)
{ {
SERVICE_STATUS serviceStatus; SERVICE_STATUS serviceStatus2;
if (QueryServiceStatus(service, &serviceStatus)) if (QueryServiceStatus(service, &serviceStatus2))
{ {
if (serviceStatus.dwCurrentState == SERVICE_STOPPED) if (serviceStatus2.dwCurrentState == SERVICE_STOPPED)
DeleteService(service); DeleteService(service);
} }
CloseServiceHandle(service); CloseServiceHandle(service);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7713" #define REVISION_NR "7728"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__