aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bindings/interface/ScriptMgr.cpp644
-rw-r--r--src/bindings/scripts/scripts/zone/borean_tundra/borean_tundra.cpp210
-rw-r--r--src/game/Debugcmds.cpp (renamed from src/game/debugcmds.cpp)0
-rw-r--r--src/game/GameObject.cpp29
-rw-r--r--src/game/GameObject.h1
-rw-r--r--src/game/Player.cpp327
-rw-r--r--src/game/SpellAuras.cpp2
-rw-r--r--src/game/TicketHandler.cpp380
-rw-r--r--src/game/Tools.cpp (renamed from src/game/tools.cpp)0
-rw-r--r--src/shared/Database/DatabaseMysql.h158
-rw-r--r--src/shared/revision_nr.h2
11 files changed, 921 insertions, 832 deletions
diff --git a/src/bindings/interface/ScriptMgr.cpp b/src/bindings/interface/ScriptMgr.cpp
index bb621f7da68..d4a0ddbc6f1 100644
--- a/src/bindings/interface/ScriptMgr.cpp
+++ b/src/bindings/interface/ScriptMgr.cpp
@@ -1,322 +1,322 @@
-/*
- * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
- *
- * Thanks to the original authors: MaNGOS <http://getmangos.com/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "config.h"
-#include "ScriptMgr.h"
-#include "../../game/GossipDef.h"
-#include "../../game/GameObject.h"
-#include "../../game/Player.h"
-#include "../../game/Map.h"
-#include "../../game/ObjectMgr.h"
-
-//uint8 loglevel = 0;
-int nrscripts;
-Script *m_scripts[MAX_SCRIPTS];
-InstanceDataScript* m_instance_scripts[MAX_INSTANCE_SCRIPTS];
-int num_inst_scripts;
-
-// -- Scripts to be added --
-extern void AddSC_default();
-// -------------------
-
-TRINITY_DLL_EXPORT
-void ScriptsFree()
-{ // Free resources before library unload
- for(int i=0;i<nrscripts;i++)
- delete m_scripts[i];
-
- for(int i=0;i<num_inst_scripts;i++)
- delete m_instance_scripts[i];
-
- nrscripts = 0;
- num_inst_scripts = 0;
-}
-
-TRINITY_DLL_EXPORT
-void ScriptsInit()
-{
- nrscripts = 0;
- num_inst_scripts = 0;
- for(int i=0;i<MAX_SCRIPTS;i++)
- {
- m_scripts[i]=NULL;
- m_instance_scripts[i]=NULL;
- }
-
- // -- Inicialize the Scripts to be Added --
- AddSC_default();
- // ----------------------------------------
-
-}
-
-Script* GetScriptByName(std::string Name)
-{
- if(Name.empty())
- return NULL;
- for(int i=0;i<MAX_SCRIPTS;i++)
- {
- if( m_scripts[i] && m_scripts[i]->Name == Name )
- return m_scripts[i];
- }
- return NULL;
-}
-
-//********************************
-//*** Functions to be Exported ***
-
-TRINITY_DLL_EXPORT
-char const* ScriptsVersion()
-{
- return "Default Trinity scripting library";
-}
-TRINITY_DLL_EXPORT
-bool GossipHello ( Player * player, Creature *_Creature )
-{
- Script *tmpscript = m_scripts[_Creature->GetScriptId()];
- if (!tmpscript || !tmpscript->pGossipHello) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pGossipHello(player,_Creature);
-}
-
-TRINITY_DLL_EXPORT
-bool GossipSelect( Player *player, Creature *_Creature, uint32 sender, uint32 action )
-{
- debug_log("TSCR: Gossip selection, sender: %d, action: %d",sender, action);
-
- Script *tmpscript = m_scripts[_Creature->GetScriptId()];
- if (!tmpscript || !tmpscript->pGossipSelect) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pGossipSelect(player,_Creature,sender,action);
-}
-
-TRINITY_DLL_EXPORT
-bool GossipSelectWithCode( Player *player, Creature *_Creature, uint32 sender, uint32 action, const char* sCode )
-{
- debug_log("TSCR: Gossip selection with code, sender: %d, action: %d",sender, action);
-
- Script *tmpscript = m_scripts[_Creature->GetScriptId()];
- if (!tmpscript || !tmpscript->pGossipSelectWithCode) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pGossipSelectWithCode(player,_Creature,sender,action,sCode);
-}
-
-TRINITY_DLL_EXPORT
-bool QuestAccept( Player *player, Creature *_Creature, Quest const *_Quest )
-{
- Script *tmpscript = m_scripts[_Creature->GetScriptId()];
- if (!tmpscript || !tmpscript->pQuestAccept) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pQuestAccept(player,_Creature,_Quest);
-}
-
-TRINITY_DLL_EXPORT
-bool QuestSelect( Player *player, Creature *_Creature, Quest const *_Quest )
-{
- Script *tmpscript = m_scripts[_Creature->GetScriptId()];
- if (!tmpscript || !tmpscript->pQuestSelect) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pQuestSelect(player,_Creature,_Quest);
-}
-
-TRINITY_DLL_EXPORT
-bool QuestComplete( Player *player, Creature *_Creature, Quest const *_Quest )
-{
- Script *tmpscript = m_scripts[_Creature->GetScriptId()];
- if (!tmpscript || !tmpscript->pQuestComplete) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pQuestComplete(player,_Creature,_Quest);
-}
-
-TRINITY_DLL_EXPORT
-bool ChooseReward( Player *player, Creature *_Creature, Quest const *_Quest, uint32 opt )
-{
- Script *tmpscript = m_scripts[_Creature->GetScriptId()];
- if (!tmpscript || !tmpscript->pChooseReward) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pChooseReward(player,_Creature,_Quest,opt);
-}
-
-TRINITY_DLL_EXPORT
-uint32 NPCDialogStatus( Player *player, Creature *_Creature )
-{
- Script *tmpscript = m_scripts[_Creature->GetScriptId()];
- if (!tmpscript || !tmpscript->pNPCDialogStatus) return 100;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pNPCDialogStatus(player,_Creature);
-}
-
-TRINITY_DLL_EXPORT
-uint32 GODialogStatus( Player *player, GameObject *_GO )
-{
- Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
- if (!tmpscript || !tmpscript->pGODialogStatus) return 100;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pGODialogStatus(player,_GO);
-}
-
-TRINITY_DLL_EXPORT
-bool ItemHello( Player *player, Item *_Item, Quest const *_Quest )
-{
- Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
- if (!tmpscript || !tmpscript->pItemHello) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pItemHello(player,_Item,_Quest);
-}
-
-TRINITY_DLL_EXPORT
-bool ItemQuestAccept( Player *player, Item *_Item, Quest const *_Quest )
-{
- Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
- if (!tmpscript || !tmpscript->pItemQuestAccept) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pItemQuestAccept(player,_Item,_Quest);
-}
-
-TRINITY_DLL_EXPORT
-bool GOHello( Player *player, GameObject *_GO )
-{
- Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
- if (!tmpscript || !tmpscript->pGOHello) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pGOHello(player,_GO);
-}
-
-TRINITY_DLL_EXPORT
-bool GOQuestAccept( Player *player, GameObject *_GO, Quest const *_Quest )
-{
- Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
- if (!tmpscript || !tmpscript->pGOQuestAccept) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pGOQuestAccept(player,_GO,_Quest);
-}
-
-TRINITY_DLL_EXPORT
-bool GOChooseReward( Player *player, GameObject *_GO, Quest const *_Quest, uint32 opt )
-{
- Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
- if (!tmpscript || !tmpscript->pGOChooseReward) return false;
-
- player->PlayerTalkClass->ClearMenus();
- return tmpscript->pGOChooseReward(player,_GO,_Quest,opt);
-}
-
-TRINITY_DLL_EXPORT
-bool AreaTrigger( Player *player, AreaTriggerEntry * atEntry)
-{
- Script *tmpscript = m_scripts[GetAreaTriggerScriptId(atEntry->id)];
- if (!tmpscript || !tmpscript->pAreaTrigger) return false;
-
- return tmpscript->pAreaTrigger(player, atEntry);
-}
-
-TRINITY_DLL_EXPORT
-CreatureAI* GetAI(Creature *_Creature)
-{
- Script *tmpscript = m_scripts[_Creature->GetScriptId()];
- if (!tmpscript || !tmpscript->GetAI) return NULL;
-
- return tmpscript->GetAI(_Creature);
-}
-
-TRINITY_DLL_EXPORT
-bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& targets)
-{
- Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
- if (!tmpscript || !tmpscript->pItemUse) return false;
-
- return tmpscript->pItemUse(player,_Item,targets);
-}
-
-TRINITY_DLL_EXPORT
-bool ReceiveEmote( Player *player, Creature *_Creature, uint32 emote )
-{
- Script *tmpscript = m_scripts[_Creature->GetScriptId()];
- if (!tmpscript || !tmpscript->pReceiveEmote) return false;
-
- return tmpscript->pReceiveEmote(player, _Creature, emote);
-}
-
-/*TRINITY_DLL_EXPORT
-InstanceData* CreateInstanceData(Map *map)
-{
- if (!map->IsDungeon()) return NULL;
-
- Script *tmpscript = m_scripts[((InstanceMap*)map)->GetScriptId()];
- if (!tmpscript || !tmpscript->GetInstanceData) return NULL;
-
- return tmpscript->GetInstanceData(map);
-}
-
-void ScriptedAI::UpdateAI(const uint32)
-{
- //Check if we have a current target
- if( m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim())
- {
- //If we are within range melee the target
- if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
- {
- if( m_creature->isAttackReady() )
- {
- m_creature->AttackerStateUpdate(m_creature->getVictim());
- m_creature->resetAttackTimer();
- }
- }
- }
-}
-
-void ScriptedAI::EnterEvadeMode()
-{
- if( m_creature->isAlive() )
- DoGoHome();
-}
-
-void ScriptedAI::DoStartAttack(Unit* victim)
-{
- if( m_creature->Attack(victim, true) )
- m_creature->GetMotionMaster()->MoveChase(victim);
-}
-
-void ScriptedAI::DoStopAttack()
-{
- if( m_creature->getVictim() != NULL )
- {
- m_creature->AttackStop();
- }
-}
-
-void ScriptedAI::DoGoHome()
-{
- if( !m_creature->getVictim() && m_creature->isAlive() )
- m_creature->GetMotionMaster()->MoveTargetedHome();
-}
-*/
+/*
+ * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
+ *
+ * Thanks to the original authors: MaNGOS <http://getmangos.com/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "config.h"
+#include "ScriptMgr.h"
+#include "../../game/GossipDef.h"
+#include "../../game/GameObject.h"
+#include "../../game/Player.h"
+#include "../../game/Map.h"
+#include "../../game/ObjectMgr.h"
+
+//uint8 loglevel = 0;
+int nrscripts;
+Script *m_scripts[MAX_SCRIPTS];
+InstanceDataScript* m_instance_scripts[MAX_INSTANCE_SCRIPTS];
+int num_inst_scripts;
+
+// -- Scripts to be added --
+extern void AddSC_default();
+// -------------------
+
+TRINITY_DLL_EXPORT
+void ScriptsFree()
+{ // Free resources before library unload
+ for(int i=0;i<nrscripts;i++)
+ delete m_scripts[i];
+
+ for(int i=0;i<num_inst_scripts;i++)
+ delete m_instance_scripts[i];
+
+ nrscripts = 0;
+ num_inst_scripts = 0;
+}
+
+TRINITY_DLL_EXPORT
+void ScriptsInit()
+{
+ nrscripts = 0;
+ num_inst_scripts = 0;
+ for(int i=0;i<MAX_SCRIPTS;i++)
+ {
+ m_scripts[i]=NULL;
+ m_instance_scripts[i]=NULL;
+ }
+
+ // -- Inicialize the Scripts to be Added --
+ AddSC_default();
+ // ----------------------------------------
+
+}
+
+Script* GetScriptByName(std::string Name)
+{
+ if(Name.empty())
+ return NULL;
+ for(int i=0;i<MAX_SCRIPTS;i++)
+ {
+ if( m_scripts[i] && m_scripts[i]->Name == Name )
+ return m_scripts[i];
+ }
+ return NULL;
+}
+
+//********************************
+//*** Functions to be Exported ***
+
+TRINITY_DLL_EXPORT
+char const* ScriptsVersion()
+{
+ return "Default Trinity scripting library";
+}
+TRINITY_DLL_EXPORT
+bool GossipHello ( Player * player, Creature *_Creature )
+{
+ Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+ if (!tmpscript || !tmpscript->pGossipHello) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pGossipHello(player,_Creature);
+}
+
+TRINITY_DLL_EXPORT
+bool GossipSelect( Player *player, Creature *_Creature, uint32 sender, uint32 action )
+{
+ debug_log("TSCR: Gossip selection, sender: %d, action: %d",sender, action);
+
+ Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+ if (!tmpscript || !tmpscript->pGossipSelect) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pGossipSelect(player,_Creature,sender,action);
+}
+
+TRINITY_DLL_EXPORT
+bool GossipSelectWithCode( Player *player, Creature *_Creature, uint32 sender, uint32 action, const char* sCode )
+{
+ debug_log("TSCR: Gossip selection with code, sender: %d, action: %d",sender, action);
+
+ Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+ if (!tmpscript || !tmpscript->pGossipSelectWithCode) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pGossipSelectWithCode(player,_Creature,sender,action,sCode);
+}
+
+TRINITY_DLL_EXPORT
+bool QuestAccept( Player *player, Creature *_Creature, Quest const *_Quest )
+{
+ Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+ if (!tmpscript || !tmpscript->pQuestAccept) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pQuestAccept(player,_Creature,_Quest);
+}
+
+TRINITY_DLL_EXPORT
+bool QuestSelect( Player *player, Creature *_Creature, Quest const *_Quest )
+{
+ Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+ if (!tmpscript || !tmpscript->pQuestSelect) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pQuestSelect(player,_Creature,_Quest);
+}
+
+TRINITY_DLL_EXPORT
+bool QuestComplete( Player *player, Creature *_Creature, Quest const *_Quest )
+{
+ Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+ if (!tmpscript || !tmpscript->pQuestComplete) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pQuestComplete(player,_Creature,_Quest);
+}
+
+TRINITY_DLL_EXPORT
+bool ChooseReward( Player *player, Creature *_Creature, Quest const *_Quest, uint32 opt )
+{
+ Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+ if (!tmpscript || !tmpscript->pChooseReward) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pChooseReward(player,_Creature,_Quest,opt);
+}
+
+TRINITY_DLL_EXPORT
+uint32 NPCDialogStatus( Player *player, Creature *_Creature )
+{
+ Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+ if (!tmpscript || !tmpscript->pNPCDialogStatus) return 100;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pNPCDialogStatus(player,_Creature);
+}
+
+TRINITY_DLL_EXPORT
+uint32 GODialogStatus( Player *player, GameObject *_GO )
+{
+ Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
+ if (!tmpscript || !tmpscript->pGODialogStatus) return 100;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pGODialogStatus(player,_GO);
+}
+
+TRINITY_DLL_EXPORT
+bool ItemHello( Player *player, Item *_Item, Quest const *_Quest )
+{
+ Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
+ if (!tmpscript || !tmpscript->pItemHello) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pItemHello(player,_Item,_Quest);
+}
+
+TRINITY_DLL_EXPORT
+bool ItemQuestAccept( Player *player, Item *_Item, Quest const *_Quest )
+{
+ Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
+ if (!tmpscript || !tmpscript->pItemQuestAccept) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pItemQuestAccept(player,_Item,_Quest);
+}
+
+TRINITY_DLL_EXPORT
+bool GOHello( Player *player, GameObject *_GO )
+{
+ Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
+ if (!tmpscript || !tmpscript->pGOHello) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pGOHello(player,_GO);
+}
+
+TRINITY_DLL_EXPORT
+bool GOQuestAccept( Player *player, GameObject *_GO, Quest const *_Quest )
+{
+ Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
+ if (!tmpscript || !tmpscript->pGOQuestAccept) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pGOQuestAccept(player,_GO,_Quest);
+}
+
+TRINITY_DLL_EXPORT
+bool GOChooseReward( Player *player, GameObject *_GO, Quest const *_Quest, uint32 opt )
+{
+ Script *tmpscript = m_scripts[_GO->GetGOInfo()->ScriptId];
+ if (!tmpscript || !tmpscript->pGOChooseReward) return false;
+
+ player->PlayerTalkClass->ClearMenus();
+ return tmpscript->pGOChooseReward(player,_GO,_Quest,opt);
+}
+
+TRINITY_DLL_EXPORT
+bool AreaTrigger( Player *player, AreaTriggerEntry * atEntry)
+{
+ Script *tmpscript = m_scripts[GetAreaTriggerScriptId(atEntry->id)];
+ if (!tmpscript || !tmpscript->pAreaTrigger) return false;
+
+ return tmpscript->pAreaTrigger(player, atEntry);
+}
+
+TRINITY_DLL_EXPORT
+CreatureAI* GetAI(Creature *_Creature)
+{
+ Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+ if (!tmpscript || !tmpscript->GetAI) return NULL;
+
+ return tmpscript->GetAI(_Creature);
+}
+
+TRINITY_DLL_EXPORT
+bool ItemUse( Player *player, Item* _Item, SpellCastTargets const& targets)
+{
+ Script *tmpscript = m_scripts[_Item->GetProto()->ScriptId];
+ if (!tmpscript || !tmpscript->pItemUse) return false;
+
+ return tmpscript->pItemUse(player,_Item,targets);
+}
+
+TRINITY_DLL_EXPORT
+bool ReceiveEmote( Player *player, Creature *_Creature, uint32 emote )
+{
+ Script *tmpscript = m_scripts[_Creature->GetScriptId()];
+ if (!tmpscript || !tmpscript->pReceiveEmote) return false;
+
+ return tmpscript->pReceiveEmote(player, _Creature, emote);
+}
+
+/*TRINITY_DLL_EXPORT
+InstanceData* CreateInstanceData(Map *map)
+{
+ if (!map->IsDungeon()) return NULL;
+
+ Script *tmpscript = m_scripts[((InstanceMap*)map)->GetScriptId()];
+ if (!tmpscript || !tmpscript->GetInstanceData) return NULL;
+
+ return tmpscript->GetInstanceData(map);
+}
+
+void ScriptedAI::UpdateAI(const uint32)
+{
+ //Check if we have a current target
+ if( m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim())
+ {
+ //If we are within range melee the target
+ if( m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
+ {
+ if( m_creature->isAttackReady() )
+ {
+ m_creature->AttackerStateUpdate(m_creature->getVictim());
+ m_creature->resetAttackTimer();
+ }
+ }
+ }
+}
+
+void ScriptedAI::EnterEvadeMode()
+{
+ if( m_creature->isAlive() )
+ DoGoHome();
+}
+
+void ScriptedAI::DoStartAttack(Unit* victim)
+{
+ if( m_creature->Attack(victim, true) )
+ m_creature->GetMotionMaster()->MoveChase(victim);
+}
+
+void ScriptedAI::DoStopAttack()
+{
+ if( m_creature->getVictim() != NULL )
+ {
+ m_creature->AttackStop();
+ }
+}
+
+void ScriptedAI::DoGoHome()
+{
+ if( !m_creature->getVictim() && m_creature->isAlive() )
+ m_creature->GetMotionMaster()->MoveTargetedHome();
+}
+*/
diff --git a/src/bindings/scripts/scripts/zone/borean_tundra/borean_tundra.cpp b/src/bindings/scripts/scripts/zone/borean_tundra/borean_tundra.cpp
index c06fdf77d1d..c776c1f9271 100644
--- a/src/bindings/scripts/scripts/zone/borean_tundra/borean_tundra.cpp
+++ b/src/bindings/scripts/scripts/zone/borean_tundra/borean_tundra.cpp
@@ -1,105 +1,105 @@
-/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* ScriptData
-SDName: Borean_Tundra
-SD%Complete: 100
-SDComment:
-SDCategory: Borean Tundra
-EndScriptData */
-
-/* ContentData
-npc_tiare
-npc_surristrasz
-EndContentData */
-
-#include "precompiled.h"
-
-/*######
-## npc_tiare
-######*/
-
-#define GOSSIP_ITEM_TELEPORT "Teleport me to Amber Ledge, please."
-
-bool GossipHello_npc_tiare(Player *player, Creature *_Creature)
-{
- player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_TELEPORT, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_GOSSIP);
- player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID());
- return true;
-}
-
-bool GossipSelect_npc_tiare(Player *player, Creature *_Creature, uint32 sender, uint32 action)
-{
- if (action == GOSSIP_OPTION_GOSSIP)
- {
- player->CLOSE_GOSSIP_MENU();
- player->CastSpell(player,50135,true);
- }
- return true;
-}
-
-/*######
-## npc_surristrasz
-######*/
-
-#define GOSSIP_ITEM_FREE_FLIGHT "I'd like passage to the Transitus Shield."
-#define GOSSIP_ITEM_FLIGHT "May I use a drake to fly elsewhere?"
-
-bool GossipHello_npc_surristrasz(Player *player, Creature *_Creature)
-{
- if (_Creature->isQuestGiver())
- player->PrepareQuestMenu(_Creature->GetGUID());
-
- if (_Creature->isTaxi())
- {
- player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_FREE_FLIGHT, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_GOSSIP);
- player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM_FLIGHT, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_TAXIVENDOR);
- }
-
- player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID());
- return true;
-}
-
-bool GossipSelect_npc_surristrasz(Player *player, Creature *_Creature, uint32 sender, uint32 action)
-{
- if (action == GOSSIP_OPTION_GOSSIP)
- {
- player->CLOSE_GOSSIP_MENU();
- player->CastSpell(player,46064,true); //TaxiPath 795 (amber to coldarra)
- }
- if (action == GOSSIP_OPTION_TAXIVENDOR)
- {
- player->GetSession()->SendTaxiMenu(_Creature);
- }
- return true;
-}
-
-void AddSC_borean_tundra()
-{
- Script *newscript;
-
- newscript = new Script;
- newscript->Name = "npc_tiare";
- newscript->pGossipHello = &GossipHello_npc_tiare;
- newscript->pGossipSelect = &GossipSelect_npc_tiare;
- newscript->RegisterSelf();
-
- newscript = new Script;
- newscript->Name = "npc_surristrasz";
- newscript->pGossipHello = &GossipHello_npc_surristrasz;
- newscript->pGossipSelect = &GossipSelect_npc_surristrasz;
- newscript->RegisterSelf();
-}
+/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/>
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* ScriptData
+SDName: Borean_Tundra
+SD%Complete: 100
+SDComment:
+SDCategory: Borean Tundra
+EndScriptData */
+
+/* ContentData
+npc_tiare
+npc_surristrasz
+EndContentData */
+
+#include "precompiled.h"
+
+/*######
+## npc_tiare
+######*/
+
+#define GOSSIP_ITEM_TELEPORT "Teleport me to Amber Ledge, please."
+
+bool GossipHello_npc_tiare(Player *player, Creature *_Creature)
+{
+ player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_TELEPORT, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_GOSSIP);
+ player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID());
+ return true;
+}
+
+bool GossipSelect_npc_tiare(Player *player, Creature *_Creature, uint32 sender, uint32 action)
+{
+ if (action == GOSSIP_OPTION_GOSSIP)
+ {
+ player->CLOSE_GOSSIP_MENU();
+ player->CastSpell(player,50135,true);
+ }
+ return true;
+}
+
+/*######
+## npc_surristrasz
+######*/
+
+#define GOSSIP_ITEM_FREE_FLIGHT "I'd like passage to the Transitus Shield."
+#define GOSSIP_ITEM_FLIGHT "May I use a drake to fly elsewhere?"
+
+bool GossipHello_npc_surristrasz(Player *player, Creature *_Creature)
+{
+ if (_Creature->isQuestGiver())
+ player->PrepareQuestMenu(_Creature->GetGUID());
+
+ if (_Creature->isTaxi())
+ {
+ player->ADD_GOSSIP_ITEM(0, GOSSIP_ITEM_FREE_FLIGHT, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_GOSSIP);
+ player->ADD_GOSSIP_ITEM(2, GOSSIP_ITEM_FLIGHT, GOSSIP_SENDER_MAIN, GOSSIP_OPTION_TAXIVENDOR);
+ }
+
+ player->SEND_GOSSIP_MENU(_Creature->GetNpcTextId(), _Creature->GetGUID());
+ return true;
+}
+
+bool GossipSelect_npc_surristrasz(Player *player, Creature *_Creature, uint32 sender, uint32 action)
+{
+ if (action == GOSSIP_OPTION_GOSSIP)
+ {
+ player->CLOSE_GOSSIP_MENU();
+ player->CastSpell(player,46064,true); //TaxiPath 795 (amber to coldarra)
+ }
+ if (action == GOSSIP_OPTION_TAXIVENDOR)
+ {
+ player->GetSession()->SendTaxiMenu(_Creature);
+ }
+ return true;
+}
+
+void AddSC_borean_tundra()
+{
+ Script *newscript;
+
+ newscript = new Script;
+ newscript->Name = "npc_tiare";
+ newscript->pGossipHello = &GossipHello_npc_tiare;
+ newscript->pGossipSelect = &GossipSelect_npc_tiare;
+ newscript->RegisterSelf();
+
+ newscript = new Script;
+ newscript->Name = "npc_surristrasz";
+ newscript->pGossipHello = &GossipHello_npc_surristrasz;
+ newscript->pGossipSelect = &GossipSelect_npc_surristrasz;
+ newscript->RegisterSelf();
+}
diff --git a/src/game/debugcmds.cpp b/src/game/Debugcmds.cpp
index 22b7fb389fb..22b7fb389fb 100644
--- a/src/game/debugcmds.cpp
+++ b/src/game/Debugcmds.cpp
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index df694fdd735..0b2dd179cdf 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -738,12 +738,12 @@ bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const
return false;
// special invisibility cases
- /* TODO: implement trap stealth, take look at spell 2836
- if(GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && GetGOInfo()->trap.stealthed && u->IsHostileTo(GetOwner()))
+ if(GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && GetGOInfo()->trap.stealthed)
{
- if(check stuff here)
+ Unit *owner = GetOwner();
+ if(owner && u->IsHostileTo(owner) && !canDetectTrap(u, GetDistance(u)))
return false;
- }*/
+ }
}
// check distance
@@ -751,6 +751,27 @@ bool GameObject::isVisibleForInState(Player const* u, bool inVisibleList) const
(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
}
+bool GameObject::canDetectTrap(Player const* u, float distance) const
+{
+ if(u->hasUnitState(UNIT_STAT_STUNNED))
+ return false;
+ if(distance < GetGOInfo()->size) //collision
+ return true;
+ if(!u->HasInArc(M_PI, this)) //behind
+ return false;
+ if(u->HasAuraType(SPELL_AURA_DETECT_STEALTH))
+ return true;
+
+ //Visible distance is modified by -Level Diff (every level diff = 0.25f in visible distance)
+ float visibleDistance = (int32(u->getLevel()) - int32(GetOwner()->getLevel()))* 0.25f;
+ //GetModifier for trap (miscvalue 1)
+ //35y for aura 2836
+ //WARNING: these values are guessed, may be not blizzlike
+ visibleDistance += u->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DETECT, 1)* 0.5f;
+
+ return distance < visibleDistance;
+}
+
void GameObject::Respawn()
{
if(m_spawnedByDefault && m_respawnTime > 0)
diff --git a/src/game/GameObject.h b/src/game/GameObject.h
index 3c8cc768f37..64cf1b9b159 100644
--- a/src/game/GameObject.h
+++ b/src/game/GameObject.h
@@ -579,6 +579,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
void TriggeringLinkedGameObject( uint32 trapEntry, Unit* target);
bool isVisibleForInState(Player const* u, bool inVisibleList) const;
+ bool canDetectTrap(Player const* u, float distance) const;
GameObject* LookupFishingHoleAround(float range);
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index ee4cf8cc165..57ab42128da 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -10396,29 +10396,17 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p
// in specific slot
if( bag != NULL_BAG && slot != NULL_SLOT )
{
- if( pProto->InventoryType == INVTYPE_BAG )
+ if( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END )
{
- Bag *pBag = (Bag*)pItem;
- if( pBag )
- {
- if( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END )
- {
- if( !HasBankBagSlot( slot ) )
- return EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT;
- if( uint8 cantuse = CanUseItem( pItem, not_loading ) != EQUIP_ERR_OK )
- return cantuse;
- }
- else
- {
- if( !pBag->IsEmpty() )
- return EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG;
- }
- }
- }
- else
- {
- if( slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END )
+ if (!pItem->IsBag())
return EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT;
+
+ Bag *pBag = (Bag*)pItem;
+ if( !HasBankBagSlot( slot ) )
+ return EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT;
+
+ if( uint8 cantuse = CanUseItem( pItem, not_loading ) != EQUIP_ERR_OK )
+ return cantuse;
}
res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem);
@@ -11575,6 +11563,8 @@ void Player::SwapItem( uint16 src, uint16 dst )
return;
}
+ // SRC checks
+
if(pSrcItem->m_lootGenerated) // prevent swap looting item
{
//best error message found for attempting to swap while looting
@@ -11585,8 +11575,8 @@ void Player::SwapItem( uint16 src, uint16 dst )
// check unequip potability for equipped items and bank bags
if(IsEquipmentPos ( src ) || IsBagPos ( src ))
{
- // bags can be swapped with empty bag slots
- uint8 msg = CanUnequipItem( src, !IsBagPos ( src ) || IsBagPos ( dst ));
+ // bags can be swapped with empty bag slots, or with empty bag (items move possibility checked later)
+ uint8 msg = CanUnequipItem( src, !IsBagPos ( src ) || IsBagPos ( dst ) || pDstItem && pDstItem->IsBag() && ((Bag*)pDstItem)->IsEmpty());
if(msg != EQUIP_ERR_OK)
{
SendEquipError( msg, pSrcItem, pDstItem );
@@ -11601,6 +11591,34 @@ void Player::SwapItem( uint16 src, uint16 dst )
return;
}
+ // DST checks
+
+ if (pDstItem)
+ {
+ if(pDstItem->m_lootGenerated) // prevent swap looting item
+ {
+ //best error message found for attempting to swap while looting
+ SendEquipError( EQUIP_ERR_CANT_DO_RIGHT_NOW, pDstItem, NULL );
+ return;
+ }
+
+ // check unequip potability for equipped items and bank bags
+ if(IsEquipmentPos ( dst ) || IsBagPos ( dst ))
+ {
+ // bags can be swapped with empty bag slots, or with empty bag (items move possibility checked later)
+ uint8 msg = CanUnequipItem( dst, !IsBagPos ( dst ) || IsBagPos ( src ) || pSrcItem->IsBag() && ((Bag*)pSrcItem)->IsEmpty());
+ if(msg != EQUIP_ERR_OK)
+ {
+ SendEquipError( msg, pSrcItem, pDstItem );
+ return;
+ }
+ }
+ }
+
+ // NOW this is or item move (swap with empty), or swap with another item (including bags in bag possitions)
+ // or swap empty bag with another empty or not empty bag (with items exchange)
+
+ // Move case
if( !pDstItem )
{
if( IsInventoryPos( dst ) )
@@ -11643,140 +11661,187 @@ void Player::SwapItem( uint16 src, uint16 dst )
EquipItem( dest, pSrcItem, true);
AutoUnequipOffhandIfNeed();
}
+
+ return;
}
- else // if (!pDstItem)
+
+ // attempt merge to / fill target item
+ if(!pSrcItem->IsBag() && !pDstItem->IsBag())
{
- if(pDstItem->m_lootGenerated) // prevent swap looting item
- {
- //best error message found for attempting to swap while looting
- SendEquipError( EQUIP_ERR_CANT_DO_RIGHT_NOW, pDstItem, NULL );
+ uint8 msg;
+ ItemPosCountVec sDest;
+ uint16 eDest;
+ if( IsInventoryPos( dst ) )
+ msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, false );
+ else if( IsBankPos ( dst ) )
+ msg = CanBankItem( dstbag, dstslot, sDest, pSrcItem, false );
+ else if( IsEquipmentPos ( dst ) )
+ msg = CanEquipItem( dstslot, eDest, pSrcItem, false );
+ else
return;
- }
- // check unequip potability for equipped items and bank bags
- if(IsEquipmentPos ( dst ) || IsBagPos ( dst ))
+ // can be merge/fill
+ if(msg == EQUIP_ERR_OK)
{
- // bags can be swapped with empty bag slots
- uint8 msg = CanUnequipItem( dst, !IsBagPos ( dst ) || IsBagPos ( src ) );
- if(msg != EQUIP_ERR_OK)
+ if( pSrcItem->GetCount() + pDstItem->GetCount() <= pSrcItem->GetProto()->GetMaxStackSize())
{
- SendEquipError( msg, pSrcItem, pDstItem );
- return;
- }
- }
+ RemoveItem(srcbag, srcslot, true);
- // attempt merge to / fill target item
- {
- uint8 msg;
- ItemPosCountVec sDest;
- uint16 eDest;
- if( IsInventoryPos( dst ) )
- msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, false );
- else if( IsBankPos ( dst ) )
- msg = CanBankItem( dstbag, dstslot, sDest, pSrcItem, false );
- else if( IsEquipmentPos ( dst ) )
- msg = CanEquipItem( dstslot, eDest, pSrcItem, false );
- else
- return;
-
- // can be merge/fill
- if(msg == EQUIP_ERR_OK)
- {
- if( pSrcItem->GetCount() + pDstItem->GetCount() <= pSrcItem->GetProto()->GetMaxStackSize())
+ if( IsInventoryPos( dst ) )
+ StoreItem( sDest, pSrcItem, true);
+ else if( IsBankPos ( dst ) )
+ BankItem( sDest, pSrcItem, true);
+ else if( IsEquipmentPos ( dst ) )
{
- RemoveItem(srcbag, srcslot, true);
-
- if( IsInventoryPos( dst ) )
- StoreItem( sDest, pSrcItem, true);
- else if( IsBankPos ( dst ) )
- BankItem( sDest, pSrcItem, true);
- else if( IsEquipmentPos ( dst ) )
- {
- EquipItem( eDest, pSrcItem, true);
- AutoUnequipOffhandIfNeed();
- }
+ EquipItem( eDest, pSrcItem, true);
+ AutoUnequipOffhandIfNeed();
}
- else
+ }
+ else
+ {
+ pSrcItem->SetCount( pSrcItem->GetCount() + pDstItem->GetCount() - pSrcItem->GetProto()->GetMaxStackSize());
+ pDstItem->SetCount( pSrcItem->GetProto()->GetMaxStackSize());
+ pSrcItem->SetState(ITEM_CHANGED, this);
+ pDstItem->SetState(ITEM_CHANGED, this);
+ if( IsInWorld() )
{
- pSrcItem->SetCount( pSrcItem->GetCount() + pDstItem->GetCount() - pSrcItem->GetProto()->GetMaxStackSize());
- pDstItem->SetCount( pSrcItem->GetProto()->GetMaxStackSize());
- pSrcItem->SetState(ITEM_CHANGED, this);
- pDstItem->SetState(ITEM_CHANGED, this);
- if( IsInWorld() )
- {
- pSrcItem->SendUpdateToPlayer( this );
- pDstItem->SendUpdateToPlayer( this );
- }
+ pSrcItem->SendUpdateToPlayer( this );
+ pDstItem->SendUpdateToPlayer( this );
}
- return;
}
+ return;
}
+ }
- // impossible merge/fill, do real swap
- uint8 msg;
+ // impossible merge/fill, do real swap
+ uint8 msg;
- // check src->dest move possibility
- ItemPosCountVec sDest;
- uint16 eDest;
- if( IsInventoryPos( dst ) )
- msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, true );
- else if( IsBankPos( dst ) )
- msg = CanBankItem( dstbag, dstslot, sDest, pSrcItem, true );
- else if( IsEquipmentPos( dst ) )
- {
- msg = CanEquipItem( dstslot, eDest, pSrcItem, true );
- if( msg == EQUIP_ERR_OK )
- msg = CanUnequipItem( eDest, true );
- }
+ // check src->dest move possibility
+ ItemPosCountVec sDest;
+ uint16 eDest;
+ if( IsInventoryPos( dst ) )
+ msg = CanStoreItem( dstbag, dstslot, sDest, pSrcItem, true );
+ else if( IsBankPos( dst ) )
+ msg = CanBankItem( dstbag, dstslot, sDest, pSrcItem, true );
+ else if( IsEquipmentPos( dst ) )
+ {
+ msg = CanEquipItem( dstslot, eDest, pSrcItem, true );
+ if( msg == EQUIP_ERR_OK )
+ msg = CanUnequipItem( eDest, true );
+ }
- if( msg != EQUIP_ERR_OK )
+ if( msg != EQUIP_ERR_OK )
+ {
+ SendEquipError( msg, pSrcItem, pDstItem );
+ return;
+ }
+
+ // check dest->src move possibility
+ ItemPosCountVec sDest2;
+ uint16 eDest2;
+ if( IsInventoryPos( src ) )
+ msg = CanStoreItem( srcbag, srcslot, sDest2, pDstItem, true );
+ else if( IsBankPos( src ) )
+ msg = CanBankItem( srcbag, srcslot, sDest2, pDstItem, true );
+ else if( IsEquipmentPos( src ) )
+ {
+ msg = CanEquipItem( srcslot, eDest2, pDstItem, true);
+ if( msg == EQUIP_ERR_OK )
+ msg = CanUnequipItem( eDest2, true);
+ }
+
+ if( msg != EQUIP_ERR_OK )
+ {
+ SendEquipError( msg, pDstItem, pSrcItem );
+ return;
+ }
+
+ // Check bag swap with item exchange (one from empty in not bag possition (equipped (not possible in fact) or store)
+ if(pSrcItem->IsBag() && pDstItem->IsBag())
+ {
+ Bag* emptyBag = NULL;
+ Bag* fullBag = NULL;
+ if(((Bag*)pSrcItem)->IsEmpty() && !IsBagPos(src))
{
- SendEquipError( msg, pSrcItem, pDstItem );
- return;
+ emptyBag = (Bag*)pSrcItem;
+ fullBag = (Bag*)pDstItem;
}
-
- // check dest->src move possibility
- ItemPosCountVec sDest2;
- uint16 eDest2;
- if( IsInventoryPos( src ) )
- msg = CanStoreItem( srcbag, srcslot, sDest2, pDstItem, true );
- else if( IsBankPos( src ) )
- msg = CanBankItem( srcbag, srcslot, sDest2, pDstItem, true );
- else if( IsEquipmentPos( src ) )
+ else if(((Bag*)pDstItem)->IsEmpty() && !IsBagPos(dst))
{
- msg = CanEquipItem( srcslot, eDest2, pDstItem, true);
- if( msg == EQUIP_ERR_OK )
- msg = CanUnequipItem( eDest2, true);
+ emptyBag = (Bag*)pDstItem;
+ fullBag = (Bag*)pSrcItem;
}
- if( msg != EQUIP_ERR_OK )
+ // bag swap (with items exchange) case
+ if(emptyBag && fullBag)
{
- SendEquipError( msg, pDstItem, pSrcItem );
- return;
- }
+ ItemPrototype const* emotyProto = emptyBag->GetProto();
- // now do moves, remove...
- RemoveItem(dstbag, dstslot, false);
- RemoveItem(srcbag, srcslot, false);
+ uint32 count = 0;
- // add to dest
- if( IsInventoryPos( dst ) )
- StoreItem(sDest, pSrcItem, true);
- else if( IsBankPos( dst ) )
- BankItem(sDest, pSrcItem, true);
- else if( IsEquipmentPos( dst ) )
- EquipItem(eDest, pSrcItem, true);
-
- // add to src
- if( IsInventoryPos( src ) )
- StoreItem(sDest2, pDstItem, true);
- else if( IsBankPos( src ) )
- BankItem(sDest2, pDstItem, true);
- else if( IsEquipmentPos( src ) )
- EquipItem(eDest2, pDstItem, true);
+ for(int i=0; i < fullBag->GetBagSize(); ++i)
+ {
+ Item *bagItem = fullBag->GetItemByPos(i);
+ if (!bagItem)
+ continue;
- AutoUnequipOffhandIfNeed();
+ ItemPrototype const* bagItemProto = bagItem->GetProto();
+ if (!bagItemProto || !ItemCanGoIntoBag(bagItemProto, emotyProto))
+ {
+ // one from items not go to empry target bag
+ SendEquipError( EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG, pSrcItem, pDstItem );
+ return;
+ }
+
+ ++count;
+ }
+
+
+ if (count > emptyBag->GetBagSize())
+ {
+ // too small targeted bag
+ SendEquipError( EQUIP_ERR_ITEMS_CANT_BE_SWAPPED, pSrcItem, pDstItem );
+ return;
+ }
+
+ // Items swap
+ count = 0; // will pos in new bag
+ for(int i=0; i< fullBag->GetBagSize(); ++i)
+ {
+ Item *bagItem = fullBag->GetItemByPos(i);
+ if (!bagItem)
+ continue;
+
+ fullBag->RemoveItem(i, true);
+ emptyBag->StoreItem(count, bagItem, true);
+ bagItem->SetState(ITEM_CHANGED, this);
+
+ ++count;
+ }
+ }
}
+
+ // now do moves, remove...
+ RemoveItem(dstbag, dstslot, false);
+ RemoveItem(srcbag, srcslot, false);
+
+ // add to dest
+ if( IsInventoryPos( dst ) )
+ StoreItem(sDest, pSrcItem, true);
+ else if( IsBankPos( dst ) )
+ BankItem(sDest, pSrcItem, true);
+ else if( IsEquipmentPos( dst ) )
+ EquipItem(eDest, pSrcItem, true);
+
+ // add to src
+ if( IsInventoryPos( src ) )
+ StoreItem(sDest2, pDstItem, true);
+ else if( IsBankPos( src ) )
+ BankItem(sDest2, pDstItem, true);
+ else if( IsEquipmentPos( src ) )
+ EquipItem(eDest2, pDstItem, true);
+
+ AutoUnequipOffhandIfNeed();
}
void Player::AddItemToBuyBackSlot( Item *pItem )
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index ef9b9847ba0..a2155e6df72 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -1078,6 +1078,8 @@ void Aura::RefreshAura()
bool Aura::isAffectedOnSpell(SpellEntry const *spell) const
{
+ if (!spell)
+ return false;
// Check family name
if (spell->SpellFamilyName != m_spellProto->SpellFamilyName)
return false;
diff --git a/src/game/TicketHandler.cpp b/src/game/TicketHandler.cpp
index d00ebb813b8..1ce07e80bc2 100644
--- a/src/game/TicketHandler.cpp
+++ b/src/game/TicketHandler.cpp
@@ -1,190 +1,190 @@
-/*
- * Copyright (C) 2005-2009 MaNGOS
- *
- * Copyright (C) 2008-2009 Trinity
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "Language.h"
-#include "ObjectAccessor.h"
-#include "WorldPacket.h"
-#include "Common.h"
-#include "Log.h"
-#include "ObjectAccessor.h"
-#include "Player.h"
-#include "Chat.h"
-#include "TicketMgr.h"
-#include "World.h"
-#include "Chat.h"
-
-
-void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
-{
- // always do a packet check
- CHECK_PACKET_SIZE(recv_data, 4*4+1+2*4);
-
- uint32 map;
- float x, y, z;
- std::string ticketText = "";
- std::string ticketText2 = "";
- GM_Ticket *ticket = new GM_Ticket;
-
- WorldPacket data(SMSG_GMTICKET_CREATE, 4);
-
- // recv Data
- //TODO: Add map coordinates to tickets.
- recv_data >> map;
- recv_data >> x;
- recv_data >> y;
- recv_data >> z;
- recv_data >> ticketText;
-
- // get additional data, rarely used
- recv_data >> ticketText2;
-
- // assign values
- ticket->name = GetPlayer()->GetName();
- ticket->guid = ticketmgr.GenerateTicketID();
- ticket->playerGuid = GetPlayer()->GetGUID();
- ticket->message = ticketText;
- ticket->timestamp = time(NULL);
- ticket->closed = 0;
- ticket->assignedToGM = 0;
- ticket->comment = "";
-
- // remove ticket by player, shouldn't happen
- ticketmgr.RemoveGMTicketByPlayer(GetPlayer()->GetGUID(), GetPlayer()->GetGUID());
-
- // add ticket
- ticketmgr.AddGMTicket(ticket, false);
-
- // Response - no errors
- data << uint32(2);
-
- // Send ticket creation
- SendPacket(&data);
-
- sWorld.SendGMText(LANG_COMMAND_TICKETNEW, ticket->name.c_str(), ticket->guid);
-
-}
-
-void WorldSession::HandleGMTicketUpdateOpcode( WorldPacket & recv_data)
-{
- // always do a packet check
- CHECK_PACKET_SIZE(recv_data,1);
-
- std::string message = "";
- time_t t = time(NULL);
-
- WorldPacket data(SMSG_GMTICKET_UPDATETEXT, 4);
-
- // recv Data
- recv_data >> message;
-
- // Update Ticket
- GM_Ticket *ticket = ticketmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID());
-
- // Check if player has a GM Ticket yet
- if(!ticket)
- {
- // Response - error couldnt find existing Ticket
- data << uint32(1);
-
- // Send packet
- SendPacket(&data);
- return;
- }
-
- ticket->message = message;
- ticket->timestamp = (uint32)t;
-
- ticketmgr.UpdateGMTicket(ticket);
-
- // Response - no errors
- data << uint32(2);
-
- // Send packet
- SendPacket(&data);
-
- sWorld.SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName(), ticket->guid);
-
-}
-
-void WorldSession::HandleGMTicketDeleteOpcode( WorldPacket & /*recv_data*/)
-{
- // NO recv_data, NO packet check size
-
- GM_Ticket* ticket = ticketmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID());
-
- // CHeck for Ticket
- if(ticket)
- {
- // Remove Tickets from Player
-
- // Response - no errors
- WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4);
- data << uint32(9);
- // Send Packet
- SendPacket(&data);
-
- sWorld.SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName(), ticket->guid );
- ticketmgr.RemoveGMTicketByPlayer(GetPlayer()->GetGUID(), GetPlayer()->GetGUID());
- }
-}
-
-void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/)
-{
- // NO recv_data NO packet size check
-
- WorldPacket data(SMSG_GMTICKET_GETTICKET, 400);
-
- // get Current Ticket
- GM_Ticket *ticket = ticketmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID());
-
- // check for existing ticket
- if(!ticket)
- {
- data << uint32(10);
- // send packet
- SendPacket(&data);
- return;
- }
-
- // Send current Ticket
- data << uint32(6); // unk ?
- data << ticket->message.c_str();
-
- SendPacket(&data);
-
-}
-
-void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket & /*recv_data*/)
-{
- // NO recv_data NO packet size check
-
- WorldPacket data(SMSG_GMTICKET_SYSTEMSTATUS, 4);
-
- // Response - System is working Fine
-
- // No need for checks, ticket system is active
- // in case of disactivity, this should be set to (0)
-
- data << uint32(1);
-
-
- // Send Packet
- SendPacket(&data);
-}
+/*
+ * Copyright (C) 2005-2009 MaNGOS
+ *
+ * Copyright (C) 2008-2009 Trinity
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "Language.h"
+#include "ObjectAccessor.h"
+#include "WorldPacket.h"
+#include "Common.h"
+#include "Log.h"
+#include "ObjectAccessor.h"
+#include "Player.h"
+#include "Chat.h"
+#include "TicketMgr.h"
+#include "World.h"
+#include "Chat.h"
+
+
+void WorldSession::HandleGMTicketCreateOpcode( WorldPacket & recv_data )
+{
+ // always do a packet check
+ CHECK_PACKET_SIZE(recv_data, 4*4+1+2*4);
+
+ uint32 map;
+ float x, y, z;
+ std::string ticketText = "";
+ std::string ticketText2 = "";
+ GM_Ticket *ticket = new GM_Ticket;
+
+ WorldPacket data(SMSG_GMTICKET_CREATE, 4);
+
+ // recv Data
+ //TODO: Add map coordinates to tickets.
+ recv_data >> map;
+ recv_data >> x;
+ recv_data >> y;
+ recv_data >> z;
+ recv_data >> ticketText;
+
+ // get additional data, rarely used
+ recv_data >> ticketText2;
+
+ // assign values
+ ticket->name = GetPlayer()->GetName();
+ ticket->guid = ticketmgr.GenerateTicketID();
+ ticket->playerGuid = GetPlayer()->GetGUID();
+ ticket->message = ticketText;
+ ticket->timestamp = time(NULL);
+ ticket->closed = 0;
+ ticket->assignedToGM = 0;
+ ticket->comment = "";
+
+ // remove ticket by player, shouldn't happen
+ ticketmgr.RemoveGMTicketByPlayer(GetPlayer()->GetGUID(), GetPlayer()->GetGUID());
+
+ // add ticket
+ ticketmgr.AddGMTicket(ticket, false);
+
+ // Response - no errors
+ data << uint32(2);
+
+ // Send ticket creation
+ SendPacket(&data);
+
+ sWorld.SendGMText(LANG_COMMAND_TICKETNEW, ticket->name.c_str(), ticket->guid);
+
+}
+
+void WorldSession::HandleGMTicketUpdateOpcode( WorldPacket & recv_data)
+{
+ // always do a packet check
+ CHECK_PACKET_SIZE(recv_data,1);
+
+ std::string message = "";
+ time_t t = time(NULL);
+
+ WorldPacket data(SMSG_GMTICKET_UPDATETEXT, 4);
+
+ // recv Data
+ recv_data >> message;
+
+ // Update Ticket
+ GM_Ticket *ticket = ticketmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID());
+
+ // Check if player has a GM Ticket yet
+ if(!ticket)
+ {
+ // Response - error couldnt find existing Ticket
+ data << uint32(1);
+
+ // Send packet
+ SendPacket(&data);
+ return;
+ }
+
+ ticket->message = message;
+ ticket->timestamp = (uint32)t;
+
+ ticketmgr.UpdateGMTicket(ticket);
+
+ // Response - no errors
+ data << uint32(2);
+
+ // Send packet
+ SendPacket(&data);
+
+ sWorld.SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName(), ticket->guid);
+
+}
+
+void WorldSession::HandleGMTicketDeleteOpcode( WorldPacket & /*recv_data*/)
+{
+ // NO recv_data, NO packet check size
+
+ GM_Ticket* ticket = ticketmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID());
+
+ // CHeck for Ticket
+ if(ticket)
+ {
+ // Remove Tickets from Player
+
+ // Response - no errors
+ WorldPacket data(SMSG_GMTICKET_DELETETICKET, 4);
+ data << uint32(9);
+ // Send Packet
+ SendPacket(&data);
+
+ sWorld.SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName(), ticket->guid );
+ ticketmgr.RemoveGMTicketByPlayer(GetPlayer()->GetGUID(), GetPlayer()->GetGUID());
+ }
+}
+
+void WorldSession::HandleGMTicketGetTicketOpcode( WorldPacket & /*recv_data*/)
+{
+ // NO recv_data NO packet size check
+
+ WorldPacket data(SMSG_GMTICKET_GETTICKET, 400);
+
+ // get Current Ticket
+ GM_Ticket *ticket = ticketmgr.GetGMTicketByPlayer(GetPlayer()->GetGUID());
+
+ // check for existing ticket
+ if(!ticket)
+ {
+ data << uint32(10);
+ // send packet
+ SendPacket(&data);
+ return;
+ }
+
+ // Send current Ticket
+ data << uint32(6); // unk ?
+ data << ticket->message.c_str();
+
+ SendPacket(&data);
+
+}
+
+void WorldSession::HandleGMTicketSystemStatusOpcode( WorldPacket & /*recv_data*/)
+{
+ // NO recv_data NO packet size check
+
+ WorldPacket data(SMSG_GMTICKET_SYSTEMSTATUS, 4);
+
+ // Response - System is working Fine
+
+ // No need for checks, ticket system is active
+ // in case of disactivity, this should be set to (0)
+
+ data << uint32(1);
+
+
+ // Send Packet
+ SendPacket(&data);
+}
diff --git a/src/game/tools.cpp b/src/game/Tools.cpp
index f8663a4b4e4..f8663a4b4e4 100644
--- a/src/game/tools.cpp
+++ b/src/game/Tools.cpp
diff --git a/src/shared/Database/DatabaseMysql.h b/src/shared/Database/DatabaseMysql.h
index 0ef046541b5..6dbaf4a59ab 100644
--- a/src/shared/Database/DatabaseMysql.h
+++ b/src/shared/Database/DatabaseMysql.h
@@ -1,79 +1,79 @@
-/*
- * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
- *
- * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef DO_POSTGRESQL
-
-#ifndef _DATABASEMYSQL_H
-#define _DATABASEMYSQL_H
-
-#include "Database.h"
-#include "Policies/Singleton.h"
-#include "zthread/FastMutex.h"
-
-#ifdef WIN32
-#define FD_SETSIZE 1024
-#include <winsock2.h>
-#include <mysql/mysql.h>
-#else
-#include <mysql.h>
-#endif
-
-class TRINITY_DLL_SPEC DatabaseMysql : public Database
-{
- friend class Trinity::OperatorNew<DatabaseMysql>;
-
- public:
- DatabaseMysql();
- ~DatabaseMysql();
-
- //! Initializes Mysql and connects to a server.
- /*! infoString should be formated like hostname;username;password;database. */
- bool Initialize(const char *infoString);
- void InitDelayThread();
- void HaltDelayThread();
- QueryResult* Query(const char *sql);
- bool Execute(const char *sql);
- bool DirectExecute(const char* sql);
- bool BeginTransaction();
- bool CommitTransaction();
- bool RollbackTransaction();
-
- operator bool () const { return mMysql != NULL; }
-
- unsigned long escape_string(char *to, const char *from, unsigned long length);
- using Database::escape_string;
-
- // must be call before first query in thread
- void ThreadStart();
- // must be call before finish thread run
- void ThreadEnd();
- private:
- ZThread::FastMutex mMutex;
-
- ZThread::ThreadImpl* tranThread;
-
- MYSQL *mMysql;
-
- static size_t db_count;
-
- bool _TransactionCmd(const char *sql);
-};
-#endif
-#endif
+/*
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+ *
+ * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef DO_POSTGRESQL
+
+#ifndef _DATABASEMYSQL_H
+#define _DATABASEMYSQL_H
+
+#include "Database.h"
+#include "Policies/Singleton.h"
+#include "zthread/FastMutex.h"
+
+#ifdef WIN32
+#define FD_SETSIZE 1024
+#include <winsock2.h>
+#include <mysql/mysql.h>
+#else
+#include <mysql.h>
+#endif
+
+class TRINITY_DLL_SPEC DatabaseMysql : public Database
+{
+ friend class Trinity::OperatorNew<DatabaseMysql>;
+
+ public:
+ DatabaseMysql();
+ ~DatabaseMysql();
+
+ //! Initializes Mysql and connects to a server.
+ /*! infoString should be formated like hostname;username;password;database. */
+ bool Initialize(const char *infoString);
+ void InitDelayThread();
+ void HaltDelayThread();
+ QueryResult* Query(const char *sql);
+ bool Execute(const char *sql);
+ bool DirectExecute(const char* sql);
+ bool BeginTransaction();
+ bool CommitTransaction();
+ bool RollbackTransaction();
+
+ operator bool () const { return mMysql != NULL; }
+
+ unsigned long escape_string(char *to, const char *from, unsigned long length);
+ using Database::escape_string;
+
+ // must be call before first query in thread
+ void ThreadStart();
+ // must be call before finish thread run
+ void ThreadEnd();
+ private:
+ ZThread::FastMutex mMutex;
+
+ ZThread::ThreadImpl* tranThread;
+
+ MYSQL *mMysql;
+
+ static size_t db_count;
+
+ bool _TransactionCmd(const char *sql);
+};
+#endif
+#endif
diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h
index a257b588318..813eb27444c 100644
--- a/src/shared/revision_nr.h
+++ b/src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "7227"
+ #define REVISION_NR "7228"
#endif // __REVISION_NR_H__