diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/interface/ScriptMgr.cpp | 644 | ||||
-rw-r--r-- | src/game/TicketHandler.cpp | 380 | ||||
-rw-r--r-- | src/shared/Database/DatabaseMysql.h | 158 |
3 files changed, 591 insertions, 591 deletions
diff --git a/src/bindings/interface/ScriptMgr.cpp b/src/bindings/interface/ScriptMgr.cpp index d4a0ddbc6f1..bb621f7da68 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/game/TicketHandler.cpp b/src/game/TicketHandler.cpp index 1ce07e80bc2..d00ebb813b8 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/shared/Database/DatabaseMysql.h b/src/shared/Database/DatabaseMysql.h index 6dbaf4a59ab..0ef046541b5 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
|