aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/server/game/Chat/Chat.cpp58
-rwxr-xr-xsrc/server/game/Chat/Chat.h11
-rwxr-xr-xsrc/server/game/Chat/Commands/Level1.cpp165
-rwxr-xr-xsrc/server/game/Chat/Commands/Level2.cpp160
-rwxr-xr-xsrc/server/game/Chat/Commands/Level3.cpp104
-rwxr-xr-xsrc/server/game/Scripting/ScriptLoader.cpp8
-rw-r--r--src/server/scripts/Commands/CMakeLists.txt4
-rw-r--r--src/server/scripts/Commands/cs_account.cpp3
-rw-r--r--src/server/scripts/Commands/cs_achievement.cpp2
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp9
-rw-r--r--src/server/scripts/Commands/cs_event.cpp217
-rw-r--r--src/server/scripts/Commands/cs_gm.cpp4
-rw-r--r--src/server/scripts/Commands/cs_go.cpp4
-rw-r--r--src/server/scripts/Commands/cs_learn.cpp5
-rw-r--r--src/server/scripts/Commands/cs_modify.cpp4
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp4
-rw-r--r--src/server/scripts/Commands/cs_tele.cpp317
17 files changed, 586 insertions, 493 deletions
diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
index 0aaecd233f5..2aaa3992572 100755
--- a/src/server/game/Chat/Chat.cpp
+++ b/src/server/game/Chat/Chat.cpp
@@ -160,15 +160,6 @@ ChatCommand * ChatHandler::getCommandTable()
{ NULL, 0, false, NULL, "", NULL }
};
- static ChatCommand eventCommandTable[] =
- {
- { "activelist", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleEventActiveListCommand>, "", NULL },
- { "start", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleEventStartCommand>, "", NULL },
- { "stop", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleEventStopCommand>, "", NULL },
- { "", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleEventInfoCommand>, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
- };
-
static ChatCommand gobjectCommandTable[] =
{
{ "activate", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleActivateObjectCommand>, "", NULL },
@@ -465,16 +456,6 @@ ChatCommand * ChatHandler::getCommandTable()
{ NULL, 0, false, NULL, "", NULL }
};
- static ChatCommand teleCommandTable[] =
- {
- { "add", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleTeleAddCommand>, "", NULL },
- { "del", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleTeleDelCommand>, "", NULL },
- { "name", SEC_MODERATOR, true, OldHandler<&ChatHandler::HandleTeleNameCommand>, "", NULL },
- { "group", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleTeleGroupCommand>, "", NULL },
- { "", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleTeleCommand>, "", NULL },
- { NULL, 0, false, NULL, "", NULL }
- };
-
static ChatCommand titlesCommandTable[] =
{
{ "add", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTitlesAddCommand>, "", NULL },
@@ -533,9 +514,7 @@ ChatCommand * ChatHandler::getCommandTable()
static ChatCommand commandTable[] =
{
- { "tele", SEC_MODERATOR, true, NULL, "", teleCommandTable },
{ "character", SEC_GAMEMASTER, true, NULL, "", characterCommandTable},
- { "event", SEC_GAMEMASTER, false, NULL, "", eventCommandTable },
{ "gobject", SEC_GAMEMASTER, false, NULL, "", gobjectCommandTable },
{ "honor", SEC_GAMEMASTER, false, NULL, "", honorCommandTable },
{ "wp", SEC_GAMEMASTER, false, NULL, "", wpCommandTable },
@@ -854,6 +833,26 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co
if (!hasStringAbbr(table[i].Name, cmd.c_str()))
continue;
+ bool match = false;
+ if (strlen(table[i].Name) > strlen(cmd.c_str()))
+ {
+ for (uint32 j = 0; table[j].Name != NULL; ++j)
+ {
+ if (!hasStringAbbr(table[j].Name, cmd.c_str()))
+ continue;
+
+ if (strcmp(table[j].Name,cmd.c_str()) != 0)
+ continue;
+ else
+ {
+ match = true;
+ break;
+ }
+ }
+ }
+ if (match)
+ continue;
+
// select subcommand from child commands list
if (table[i].ChildCommands != NULL)
{
@@ -874,23 +873,6 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co
if (!table[i].Handler || !isAvailable(table[i]))
continue;
- bool match = false;
- if (strlen(table[i].Name) > strlen(cmd.c_str()))
- {
- for (uint32 j = 0; table[j].Name != NULL; ++j)
- {
- if (strcmp(table[j].Name,cmd.c_str()) != 0)
- continue;
- else
- {
- match = true;
- break;
- }
- }
- }
- if (match)
- continue;
-
SetSentErrorMessage(false);
// table[i].Name == "" is special case: send original command to handler
if ((table[i].Handler)(this, strlen(table[i].Name) != 0 ? text : oldtext))
diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h
index 6a90ae9c9a4..5918e79237a 100755
--- a/src/server/game/Chat/Chat.h
+++ b/src/server/game/Chat/Chat.h
@@ -171,11 +171,6 @@ class ChatHandler
bool HandleBindSightCommand(const char* args);
bool HandleUnbindSightCommand(const char* args);
- bool HandleEventActiveListCommand(const char* args);
- bool HandleEventStartCommand(const char* args);
- bool HandleEventStopCommand(const char* args);
- bool HandleEventInfoCommand(const char* args);
-
bool HandleGameObjectAddCommand(const char* args);
bool HandleGameObjectDeleteCommand(const char* args);
bool HandleGameObjectInfoCommand(const char* args);
@@ -366,12 +361,6 @@ class ChatHandler
bool HandleServerSetLogFileLevelCommand(const char* args);
bool HandleServerSetDiffTimeCommand(const char* args);
- bool HandleTeleCommand(const char * args);
- bool HandleTeleAddCommand(const char * args);
- bool HandleTeleDelCommand(const char * args);
- bool HandleTeleGroupCommand(const char* args);
- bool HandleTeleNameCommand(const char* args);
-
bool HandleTitlesAddCommand(const char* args);
bool HandleTitlesCurrentCommand(const char* args);
bool HandleTitlesRemoveCommand(const char* args);
diff --git a/src/server/game/Chat/Commands/Level1.cpp b/src/server/game/Chat/Commands/Level1.cpp
index 0cd416275f3..23793abf946 100755
--- a/src/server/game/Chat/Commands/Level1.cpp
+++ b/src/server/game/Chat/Commands/Level1.cpp
@@ -759,171 +759,6 @@ bool ChatHandler::HandleSendMailCommand(const char* args)
return true;
}
-// teleport player to given game_tele.entry
-bool ChatHandler::HandleTeleNameCommand(const char * args)
-{
- char* nameStr;
- char* teleStr;
- extractOptFirstArg((char*)args,&nameStr,&teleStr);
- if (!teleStr)
- return false;
-
- Player* target;
- uint64 target_guid;
- std::string target_name;
- if (!extractPlayerTarget(nameStr,&target,&target_guid,&target_name))
- return false;
-
- // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
- GameTele const* tele = extractGameTeleFromLink(teleStr);
- if (!tele)
- {
- SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
- SetSentErrorMessage(true);
- return false;
- }
-
-/* MapEntry const * me = sMapStore.LookupEntry(tele->mapId);
- if (!me || me->IsBattlegroundOrArena())
- {
- SendSysMessage(LANG_CANNOT_TELE_TO_BG);
- SetSentErrorMessage(true);
- return false;
- }
-
- Player *chr = sObjectMgr.GetPlayer(name.c_str());*/
-
- if (target)
- {
- // check online security
- if (HasLowerSecurity(target, 0))
- return false;
-
- std::string chrNameLink = playerLink(target_name);
-
- if (target->IsBeingTeleported() == true)
- {
- PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
- SetSentErrorMessage(true);
- return false;
- }
-
- PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(),"", tele->name.c_str());
- if (needReportToTarget(target))
- ChatHandler(target).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetNameLink().c_str());
-
- // stop flight if need
- if (target->isInFlight())
- {
- target->GetMotionMaster()->MovementExpired();
- target->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
- else
- target->SaveRecallPosition();
-
- target->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation);
- }
- else
- {
- // check offline security
- if (HasLowerSecurity(NULL, target_guid))
- return false;
-
- std::string nameLink = playerLink(target_name);
-
- PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), GetTrinityString(LANG_OFFLINE), tele->name.c_str());
- Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,
- sMapMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),target_guid);
- }
-
- return true;
-}
-
-//Teleport group to given game_tele.entry
-bool ChatHandler::HandleTeleGroupCommand(const char * args)
-{
- if (!*args)
- return false;
-
- Player *player = getSelectedPlayer();
- if (!player)
- {
- SendSysMessage(LANG_NO_CHAR_SELECTED);
- SetSentErrorMessage(true);
- return false;
- }
-
- // check online security
- if (HasLowerSecurity(player, 0))
- return false;
-
- // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
- GameTele const* tele = extractGameTeleFromLink((char*)args);
- if (!tele)
- {
- SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
- SetSentErrorMessage(true);
- return false;
- }
-
- MapEntry const * me = sMapStore.LookupEntry(tele->mapId);
- if (!me || me->IsBattlegroundOrArena())
- {
- SendSysMessage(LANG_CANNOT_TELE_TO_BG);
- SetSentErrorMessage(true);
- return false;
- }
-
- std::string nameLink = GetNameLink(player);
-
- Group *grp = player->GetGroup();
- if (!grp)
- {
- PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str());
- SetSentErrorMessage(true);
- return false;
- }
-
- for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
- {
- Player *pl = itr->getSource();
-
- if (!pl || !pl->GetSession())
- continue;
-
- // check online security
- if (HasLowerSecurity(pl, 0))
- return false;
-
- std::string plNameLink = GetNameLink(pl);
-
- if (pl->IsBeingTeleported())
- {
- PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
- continue;
- }
-
- PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(),"", tele->name.c_str());
- if (needReportToTarget(pl))
- ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());
-
- // stop flight if need
- if (pl->isInFlight())
- {
- pl->GetMotionMaster()->MovementExpired();
- pl->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
- else
- pl->SaveRecallPosition();
-
- pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
- }
-
- return true;
-}
-
//Summon group of player
bool ChatHandler::HandleGroupSummonCommand(const char* args)
{
diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp
index ae86c290b7b..e291957cd13 100755
--- a/src/server/game/Chat/Commands/Level2.cpp
+++ b/src/server/game/Chat/Commands/Level2.cpp
@@ -2113,166 +2113,6 @@ bool ChatHandler::HandleLookupEventCommand(const char* args)
return true;
}
-bool ChatHandler::HandleEventActiveListCommand(const char* /*args*/)
-{
- uint32 counter = 0;
-
- GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
- GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
-
- char const* active = GetTrinityString(LANG_ACTIVE);
-
- for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr)
- {
- uint32 event_id = *itr;
- GameEventData const& eventData = events[event_id];
-
- if (m_session)
- PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,event_id,event_id,eventData.description.c_str(),active);
- else
- PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,event_id,eventData.description.c_str(),active);
-
- ++counter;
- }
-
- if (counter == 0)
- SendSysMessage(LANG_NOEVENTFOUND);
-
- return true;
-}
-
-bool ChatHandler::HandleEventInfoCommand(const char* args)
-{
- if (!*args)
- return false;
-
- // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
- char* cId = extractKeyFromLink((char*)args,"Hgameevent");
- if (!cId)
- return false;
-
- uint32 event_id = atoi(cId);
-
- GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
-
- if (event_id >=events.size())
- {
- SendSysMessage(LANG_EVENT_NOT_EXIST);
- SetSentErrorMessage(true);
- return false;
- }
-
- GameEventData const& eventData = events[event_id];
- if (!eventData.isValid())
- {
- SendSysMessage(LANG_EVENT_NOT_EXIST);
- SetSentErrorMessage(true);
- return false;
- }
-
- GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
- bool active = activeEvents.find(event_id) != activeEvents.end();
- char const* activeStr = active ? GetTrinityString(LANG_ACTIVE) : "";
-
- std::string startTimeStr = TimeToTimestampStr(eventData.start);
- std::string endTimeStr = TimeToTimestampStr(eventData.end);
-
- uint32 delay = sGameEventMgr.NextCheck(event_id);
- time_t nextTime = time(NULL)+delay;
- std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL)+delay) : "-";
-
- std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE);
- std::string lengthStr = secsToTimeString(eventData.length * MINUTE);
-
- PSendSysMessage(LANG_EVENT_INFO,event_id,eventData.description.c_str(),activeStr,
- startTimeStr.c_str(),endTimeStr.c_str(),occurenceStr.c_str(),lengthStr.c_str(),
- nextStr.c_str());
- return true;
-}
-
-bool ChatHandler::HandleEventStartCommand(const char* args)
-{
- if (!*args)
- return false;
-
- // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
- char* cId = extractKeyFromLink((char*)args,"Hgameevent");
- if (!cId)
- return false;
-
- int32 event_id = atoi(cId);
-
- GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
-
- if (event_id < 1 || uint32(event_id) >= events.size())
- {
- SendSysMessage(LANG_EVENT_NOT_EXIST);
- SetSentErrorMessage(true);
- return false;
- }
-
- GameEventData const& eventData = events[event_id];
- if (!eventData.isValid())
- {
- SendSysMessage(LANG_EVENT_NOT_EXIST);
- SetSentErrorMessage(true);
- return false;
- }
-
- GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
- if (activeEvents.find(event_id) != activeEvents.end())
- {
- PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE,event_id);
- SetSentErrorMessage(true);
- return false;
- }
-
- sGameEventMgr.StartEvent(event_id,true);
- return true;
-}
-
-bool ChatHandler::HandleEventStopCommand(const char* args)
-{
- if (!*args)
- return false;
-
- // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
- char* cId = extractKeyFromLink((char*)args,"Hgameevent");
- if (!cId)
- return false;
-
- int32 event_id = atoi(cId);
-
- GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
-
- if (event_id < 1 || uint32(event_id) >= events.size())
- {
- SendSysMessage(LANG_EVENT_NOT_EXIST);
- SetSentErrorMessage(true);
- return false;
- }
-
- GameEventData const& eventData = events[event_id];
- if (!eventData.isValid())
- {
- SendSysMessage(LANG_EVENT_NOT_EXIST);
- SetSentErrorMessage(true);
- return false;
- }
-
- GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
-
- if (activeEvents.find(event_id) == activeEvents.end())
- {
- PSendSysMessage(LANG_EVENT_NOT_ACTIVE,event_id);
- SetSentErrorMessage(true);
- return false;
- }
-
- sGameEventMgr.StopEvent(event_id,true);
- return true;
-}
-
bool ChatHandler::HandleCombatStopCommand(const char* args)
{
Player* target;
diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp
index fcb29b623fe..521d8e287cd 100755
--- a/src/server/game/Chat/Commands/Level3.cpp
+++ b/src/server/game/Chat/Commands/Level3.cpp
@@ -3577,110 +3577,6 @@ bool ChatHandler::HandleChangeWeather(const char *args)
return true;
}
-bool ChatHandler::HandleTeleCommand(const char* args)
-{
- if (!*args)
- return false;
-
- Player* me = GetSession()->GetPlayer();
-
- // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
- GameTele const* tele = extractGameTeleFromLink((char*)args);
-
- if (!tele)
- {
- SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
- SetSentErrorMessage(true);
- return false;
- }
-
- if (me->isInCombat())
- {
- SendSysMessage(LANG_YOU_IN_COMBAT);
- SetSentErrorMessage(true);
- return false;
- }
-
- MapEntry const * map = sMapStore.LookupEntry(tele->mapId);
- if (!map || map->IsBattlegroundOrArena())
- {
- SendSysMessage(LANG_CANNOT_TELE_TO_BG);
- SetSentErrorMessage(true);
- return false;
- }
-
- // stop flight if need
- if (me->isInFlight())
- {
- me->GetMotionMaster()->MovementExpired();
- me->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
- else
- me->SaveRecallPosition();
-
- me->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
- return true;
-}
-
-bool ChatHandler::HandleTeleAddCommand(const char * args)
-{
- if (!*args)
- return false;
-
- Player *player=m_session->GetPlayer();
- if (!player)
- return false;
-
- std::string name = args;
-
- if (sObjectMgr.GetGameTele(name))
- {
- SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST);
- SetSentErrorMessage(true);
- return false;
- }
-
- GameTele tele;
- tele.position_x = player->GetPositionX();
- tele.position_y = player->GetPositionY();
- tele.position_z = player->GetPositionZ();
- tele.orientation = player->GetOrientation();
- tele.mapId = player->GetMapId();
- tele.name = name;
-
- if (sObjectMgr.AddGameTele(tele))
- {
- SendSysMessage(LANG_COMMAND_TP_ADDED);
- }
- else
- {
- SendSysMessage(LANG_COMMAND_TP_ADDEDERR);
- SetSentErrorMessage(true);
- return false;
- }
-
- return true;
-}
-
-bool ChatHandler::HandleTeleDelCommand(const char * args)
-{
- if (!*args)
- return false;
-
- std::string name = args;
-
- if (!sObjectMgr.DeleteGameTele(name))
- {
- SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
- SetSentErrorMessage(true);
- return false;
- }
-
- SendSysMessage(LANG_COMMAND_TP_DELETED);
- return true;
-}
-
bool ChatHandler::HandleListAurasCommand (const char * /*args*/)
{
Unit *unit = getSelectedUnit();
diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
index d904e171290..5b9e458a6b3 100755
--- a/src/server/game/Scripting/ScriptLoader.cpp
+++ b/src/server/game/Scripting/ScriptLoader.cpp
@@ -47,12 +47,12 @@ void AddSC_SmartSCripts();
//Commands
void AddSC_account_commandscript();
void AddSC_achievement_commandscript();
+void AddSC_debug_commandscript();
void AddSC_gm_commandscript();
-void AddSC_npc_commandscript();
void AddSC_go_commandscript();
void AddSC_learn_commandscript();
void AddSC_modify_commandscript();
-void AddSC_debug_commandscript();
+void AddSC_npc_commandscript();
#ifdef SCRIPTS
//world
@@ -623,12 +623,12 @@ void AddCommandScripts()
{
AddSC_account_commandscript();
AddSC_achievement_commandscript();
+ AddSC_debug_commandscript();
AddSC_gm_commandscript();
- AddSC_npc_commandscript();
AddSC_go_commandscript();
AddSC_learn_commandscript();
AddSC_modify_commandscript();
- AddSC_debug_commandscript();
+ AddSC_npc_commandscript();
}
void AddWorldScripts()
diff --git a/src/server/scripts/Commands/CMakeLists.txt b/src/server/scripts/Commands/CMakeLists.txt
index b16cb182169..1eac1322b0e 100644
--- a/src/server/scripts/Commands/CMakeLists.txt
+++ b/src/server/scripts/Commands/CMakeLists.txt
@@ -8,9 +8,9 @@ set(scripts_STAT_SRCS
Commands/cs_learn.cpp
Commands/cs_modify.cpp
Commands/cs_debug.cpp
-# Commands/cs_tele.cpp
+ Commands/cs_tele.cpp
# Commands/cs_character.cpp
-# Commands/cs_event.cpp
+ Commands/cs_event.cpp
# Commands/cs_gobject.cpp
# Commands/cs_honor.cpp
# Commands/cs_wp.cpp
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 1c6bd03f8a4..b9cd6367816 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -22,8 +22,9 @@ Comment: All account related commands
Category: commandscripts
EndScriptData */
-#include "ScriptPCH.h"
+#include "ScriptMgr.h"
#include "AccountMgr.h"
+#include "Chat.h"
class account_commandscript : public CommandScript
{
diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp
index f3bf0381ecf..06bf2563000 100644
--- a/src/server/scripts/Commands/cs_achievement.cpp
+++ b/src/server/scripts/Commands/cs_achievement.cpp
@@ -22,7 +22,7 @@ Comment: All achievement related commands
Category: commandscripts
EndScriptData */
-#include "ScriptPCH.h"
+#include "ScriptMgr.h"
#include "Chat.h"
class achievement_commandscript : public CommandScript
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 027f9d91aab..30f1582acff 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -22,9 +22,14 @@ Comment: All debug related commands
Category: commandscripts
EndScriptData */
-#include "ScriptPCH.h"
-#include <fstream>
+#include "ScriptMgr.h"
+#include "ObjectMgr.h"
+#include "GossipDef.h"
+#include "GridNotifiers.h"
#include "BattlegroundMgr.h"
+#include "Chat.h"
+
+#include <fstream>
class debug_commandscript : public CommandScript
{
diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp
new file mode 100644
index 00000000000..ed445fdccce
--- /dev/null
+++ b/src/server/scripts/Commands/cs_event.cpp
@@ -0,0 +1,217 @@
+/*
+ * Copyright (C) 2008-2010 TrinityCore <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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* ScriptData
+Name: event_commandscript
+%Complete: 100
+Comment: All event related commands
+Category: commandscripts
+EndScriptData */
+
+#include "ScriptMgr.h"
+#include "GameEventMgr.h"
+#include "Chat.h"
+
+class event_commandscript : public CommandScript
+{
+ public:
+ event_commandscript() : CommandScript("event_commandscript") { }
+
+ ChatCommand* GetCommands() const
+ {
+ static ChatCommand eventCommandTable[] =
+ {
+ { "activelist", SEC_GAMEMASTER, true, &HandleEventActiveListCommand, "", NULL },
+ { "start", SEC_GAMEMASTER, true, &HandleEventStartCommand, "", NULL },
+ { "stop", SEC_GAMEMASTER, true, &HandleEventStopCommand, "", NULL },
+ { "", SEC_GAMEMASTER, true, &HandleEventInfoCommand, "", NULL },
+ { NULL, 0, false, NULL, "", NULL }
+ };
+ static ChatCommand commandTable[] =
+ {
+ { "event", SEC_GAMEMASTER, false, NULL, "", eventCommandTable },
+ { NULL, 0, false, NULL, "", NULL }
+ };
+ return commandTable;
+ }
+
+ static bool HandleEventActiveListCommand(ChatHandler* handler, const char* /*args*/)
+ {
+ uint32 counter = 0;
+
+ GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
+ GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
+
+ char const* active = handler->GetTrinityString(LANG_ACTIVE);
+
+ for (GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr)
+ {
+ uint32 event_id = *itr;
+ GameEventData const& eventData = events[event_id];
+
+ if (handler->GetSession())
+ handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,event_id,event_id,eventData.description.c_str(),active);
+ else
+ handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,event_id,eventData.description.c_str(),active);
+
+ ++counter;
+ }
+
+ if (counter == 0)
+ handler->SendSysMessage(LANG_NOEVENTFOUND);
+ handler->SetSentErrorMessage(true);
+
+ return true;
+ }
+
+ static bool HandleEventInfoCommand(ChatHandler* handler, const char* args)
+ {
+ if (!*args)
+ return false;
+
+ // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
+ char* cId = handler->extractKeyFromLink((char*)args,"Hgameevent");
+ if (!cId)
+ return false;
+
+ uint32 event_id = atoi(cId);
+
+ GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
+
+ if (event_id >=events.size())
+ {
+ handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ GameEventData const& eventData = events[event_id];
+ if (!eventData.isValid())
+ {
+ handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
+ bool active = activeEvents.find(event_id) != activeEvents.end();
+ char const* activeStr = active ? handler->GetTrinityString(LANG_ACTIVE) : "";
+
+ std::string startTimeStr = TimeToTimestampStr(eventData.start);
+ std::string endTimeStr = TimeToTimestampStr(eventData.end);
+
+ uint32 delay = sGameEventMgr.NextCheck(event_id);
+ time_t nextTime = time(NULL)+delay;
+ std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL)+delay) : "-";
+
+ std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE);
+ std::string lengthStr = secsToTimeString(eventData.length * MINUTE);
+
+ handler->PSendSysMessage(LANG_EVENT_INFO,event_id,eventData.description.c_str(),activeStr,
+ startTimeStr.c_str(),endTimeStr.c_str(),occurenceStr.c_str(),lengthStr.c_str(),
+ nextStr.c_str());
+ return true;
+ }
+
+ static bool HandleEventStartCommand(ChatHandler* handler, const char* args)
+ {
+ if (!*args)
+ return false;
+
+ // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
+ char* cId = handler->extractKeyFromLink((char*)args,"Hgameevent");
+ if (!cId)
+ return false;
+
+ int32 event_id = atoi(cId);
+
+ GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
+
+ if (event_id < 1 || uint32(event_id) >= events.size())
+ {
+ handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ GameEventData const& eventData = events[event_id];
+ if (!eventData.isValid())
+ {
+ handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
+ if (activeEvents.find(event_id) != activeEvents.end())
+ {
+ handler->PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE,event_id);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ sGameEventMgr.StartEvent(event_id,true);
+ return true;
+ }
+
+ static bool HandleEventStopCommand(ChatHandler* handler, const char* args)
+ {
+ if (!*args)
+ return false;
+
+ // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r
+ char* cId = handler->extractKeyFromLink((char*)args,"Hgameevent");
+ if (!cId)
+ return false;
+
+ int32 event_id = atoi(cId);
+
+ GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap();
+
+ if (event_id < 1 || uint32(event_id) >= events.size())
+ {
+ handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ GameEventData const& eventData = events[event_id];
+ if (!eventData.isValid())
+ {
+ handler->SendSysMessage(LANG_EVENT_NOT_EXIST);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr.GetActiveEventList();
+
+ if (activeEvents.find(event_id) == activeEvents.end())
+ {
+ handler->PSendSysMessage(LANG_EVENT_NOT_ACTIVE,event_id);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ sGameEventMgr.StopEvent(event_id,true);
+ return true;
+ }
+};
+
+void AddSC_event_commandscript()
+{
+ new event_commandscript();
+}
diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp
index c9a36ca2f5b..07846c3cb43 100644
--- a/src/server/scripts/Commands/cs_gm.cpp
+++ b/src/server/scripts/Commands/cs_gm.cpp
@@ -22,7 +22,9 @@ Comment: All gm related commands
Category: commandscripts
EndScriptData */
-#include "ScriptPCH.h"
+#include "ScriptMgr.h"
+#include "ObjectMgr.h"
+#include "Chat.h"
class gm_commandscript : public CommandScript
{
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp
index 27cfc5c3268..08a7e992f8c 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -22,9 +22,11 @@ Comment: All go related commands
Category: commandscripts
EndScriptData */
-#include "ScriptPCH.h"
+#include "ScriptMgr.h"
+#include "ObjectMgr.h"
#include "MapManager.h"
#include "TicketMgr.h"
+#include "Chat.h"
class go_commandscript : public CommandScript
{
diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp
index 4ac6c98564b..e68800e85fa 100644
--- a/src/server/scripts/Commands/cs_learn.cpp
+++ b/src/server/scripts/Commands/cs_learn.cpp
@@ -22,7 +22,10 @@ Comment: All learn related commands
Category: commandscripts
EndScriptData */
-#include "ScriptPCH.h"
+#include "ScriptMgr.h"
+#include "ObjectMgr.h"
+#include "SpellMgr.h"
+#include "Chat.h"
class learn_commandscript : public CommandScript
{
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp
index ecca547910f..41017573680 100644
--- a/src/server/scripts/Commands/cs_modify.cpp
+++ b/src/server/scripts/Commands/cs_modify.cpp
@@ -22,7 +22,9 @@ Comment: All modify related commands
Category: commandscripts
EndScriptData */
-#include "ScriptPCH.h"
+#include "ScriptMgr.h"
+#include "ObjectMgr.h"
+#include "Chat.h"
class modify_commandscript : public CommandScript
{
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index a0c81ae608f..d155eb44377 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -22,7 +22,9 @@ Comment: All npc related commands
Category: commandscripts
EndScriptData */
-#include "ScriptPCH.h"
+#include "ScriptMgr.h"
+#include "ObjectMgr.h"
+#include "Chat.h"
#include "Transport.h"
#include "CreatureGroups.h"
#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp
new file mode 100644
index 00000000000..aa096bb698e
--- /dev/null
+++ b/src/server/scripts/Commands/cs_tele.cpp
@@ -0,0 +1,317 @@
+/*
+ * Copyright (C) 2008-2010 TrinityCore <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, see <http://www.gnu.org/licenses/>.
+ */
+
+/* ScriptData
+Name: tele_commandscript
+%Complete: 100
+Comment: All tele related commands
+Category: commandscripts
+EndScriptData */
+
+#include "ScriptMgr.h"
+#include "ObjectMgr.h"
+#include "MapManager.h"
+#include "Chat.h"
+
+class tele_commandscript : public CommandScript
+{
+ public:
+ tele_commandscript() : CommandScript("tele_commandscript") { }
+
+ ChatCommand* GetCommands() const
+ {
+ static ChatCommand teleCommandTable[] =
+ {
+ { "add", SEC_ADMINISTRATOR, false, &HandleTeleAddCommand, "", NULL },
+ { "del", SEC_ADMINISTRATOR, true, &HandleTeleDelCommand, "", NULL },
+ { "name", SEC_MODERATOR, true, &HandleTeleNameCommand, "", NULL },
+ { "group", SEC_MODERATOR, false, &HandleTeleGroupCommand, "", NULL },
+ { "", SEC_MODERATOR, false, &HandleTeleCommand, "", NULL },
+ { NULL, 0, false, NULL, "", NULL }
+ };
+ static ChatCommand commandTable[] =
+ {
+ { "tele", SEC_MODERATOR, false, NULL, "", teleCommandTable },
+ { NULL, 0, false, NULL, "", NULL }
+ };
+ return commandTable;
+ }
+
+ static bool HandleTeleAddCommand(ChatHandler* handler, const char* args)
+ {
+ if (!*args)
+ return false;
+
+ Player *player = handler->GetSession()->GetPlayer();
+ if (!player)
+ return false;
+
+ std::string name = args;
+
+ if (sObjectMgr.GetGameTele(name))
+ {
+ handler->SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ GameTele tele;
+ tele.position_x = player->GetPositionX();
+ tele.position_y = player->GetPositionY();
+ tele.position_z = player->GetPositionZ();
+ tele.orientation = player->GetOrientation();
+ tele.mapId = player->GetMapId();
+ tele.name = name;
+
+ if (sObjectMgr.AddGameTele(tele))
+ {
+ handler->SendSysMessage(LANG_COMMAND_TP_ADDED);
+ }
+ else
+ {
+ handler->SendSysMessage(LANG_COMMAND_TP_ADDEDERR);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ return true;
+ }
+
+ static bool HandleTeleDelCommand(ChatHandler* handler, const char* args)
+ {
+ if (!*args)
+ return false;
+
+ std::string name = args;
+
+ if (!sObjectMgr.DeleteGameTele(name))
+ {
+ handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ handler->SendSysMessage(LANG_COMMAND_TP_DELETED);
+ return true;
+ }
+
+ // teleport player to given game_tele.entry
+ static bool HandleTeleNameCommand(ChatHandler* handler, const char* args)
+ {
+ char* nameStr;
+ char* teleStr;
+ handler->extractOptFirstArg((char*)args,&nameStr,&teleStr);
+ if (!teleStr)
+ return false;
+
+ Player* target;
+ uint64 target_guid;
+ std::string target_name;
+ if (!handler->extractPlayerTarget(nameStr,&target,&target_guid,&target_name))
+ return false;
+
+ // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
+ GameTele const* tele = handler->extractGameTeleFromLink(teleStr);
+ if (!tele)
+ {
+ handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ if (target)
+ {
+ // check online security
+ if (handler->HasLowerSecurity(target, 0))
+ return false;
+
+ std::string chrNameLink = handler->playerLink(target_name);
+
+ if (target->IsBeingTeleported() == true)
+ {
+ handler->PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ handler->PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(),"", tele->name.c_str());
+ if (handler->needReportToTarget(target))
+ (ChatHandler(target)).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink().c_str());
+
+ // stop flight if need
+ if (target->isInFlight())
+ {
+ target->GetMotionMaster()->MovementExpired();
+ target->CleanupAfterTaxiFlight();
+ }
+ // save only in non-flight case
+ else
+ target->SaveRecallPosition();
+
+ target->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation);
+ }
+ else
+ {
+ // check offline security
+ if (handler->HasLowerSecurity(NULL, target_guid))
+ return false;
+
+ std::string nameLink = handler->playerLink(target_name);
+
+ handler->PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), handler->GetTrinityString(LANG_OFFLINE), tele->name.c_str());
+ Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,
+ sMapMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),target_guid);
+ }
+
+ return true;
+ }
+
+ //Teleport group to given game_tele.entry
+ static bool HandleTeleGroupCommand(ChatHandler* handler, const char* args)
+ {
+ if (!*args)
+ return false;
+
+ Player *player = handler->getSelectedPlayer();
+ if (!player)
+ {
+ handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ // check online security
+ if (handler->HasLowerSecurity(player, 0))
+ return false;
+
+ // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
+ GameTele const* tele = handler->extractGameTeleFromLink((char*)args);
+ if (!tele)
+ {
+ handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ MapEntry const * map = sMapStore.LookupEntry(tele->mapId);
+ if (!map || map->IsBattlegroundOrArena())
+ {
+ handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ std::string nameLink = handler->GetNameLink(player);
+
+ Group *grp = player->GetGroup();
+ if (!grp)
+ {
+ handler->PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str());
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
+ {
+ Player *pl = itr->getSource();
+
+ if (!pl || !pl->GetSession())
+ continue;
+
+ // check online security
+ if (handler->HasLowerSecurity(pl, 0))
+ return false;
+
+ std::string plNameLink = handler->GetNameLink(pl);
+
+ if (pl->IsBeingTeleported())
+ {
+ handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
+ continue;
+ }
+
+ handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(),"", tele->name.c_str());
+ if (handler->needReportToTarget(pl))
+ (ChatHandler(pl)).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());
+
+ // stop flight if need
+ if (pl->isInFlight())
+ {
+ pl->GetMotionMaster()->MovementExpired();
+ pl->CleanupAfterTaxiFlight();
+ }
+ // save only in non-flight case
+ else
+ pl->SaveRecallPosition();
+
+ pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
+ }
+
+ return true;
+ }
+
+ static bool HandleTeleCommand(ChatHandler* handler, const char* args)
+ {
+ if (!*args)
+ return false;
+
+ Player* me = handler->GetSession()->GetPlayer();
+
+ // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
+ GameTele const* tele = handler->extractGameTeleFromLink((char*)args);
+
+ if (!tele)
+ {
+ handler->SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ if (me->isInCombat())
+ {
+ handler->SendSysMessage(LANG_YOU_IN_COMBAT);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ MapEntry const * map = sMapStore.LookupEntry(tele->mapId);
+ if (!map || map->IsBattlegroundOrArena())
+ {
+ handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ // stop flight if need
+ if (me->isInFlight())
+ {
+ me->GetMotionMaster()->MovementExpired();
+ me->CleanupAfterTaxiFlight();
+ }
+ // save only in non-flight case
+ else
+ me->SaveRecallPosition();
+
+ me->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
+ return true;
+ }
+};
+
+void AddSC_tele_commandscript()
+{
+ new tele_commandscript();
+}