aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_account.cpp2
-rw-r--r--src/server/scripts/Commands/cs_character.cpp4
-rw-r--r--src/server/scripts/Commands/cs_deserter.cpp6
-rw-r--r--src/server/scripts/Commands/cs_list.cpp4
-rw-r--r--src/server/scripts/Commands/cs_lookup.cpp22
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp76
-rw-r--r--src/server/scripts/Commands/cs_mmaps.cpp12
-rw-r--r--src/server/scripts/Commands/cs_modify.cpp24
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp2
-rw-r--r--src/server/scripts/Commands/cs_rbac.cpp42
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp2
11 files changed, 111 insertions, 85 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 9aa68e0892c..c347648abab 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -482,7 +482,7 @@ public:
char* arg3 = strtok(NULL, " ");
bool isAccountNameGiven = true;
- if (arg1 && !arg3)
+ if (!arg3)
{
if (!handler->getSelectedPlayer())
return false;
diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp
index 727aa55597f..2b316803029 100644
--- a/src/server/scripts/Commands/cs_character.cpp
+++ b/src/server/scripts/Commands/cs_character.cpp
@@ -320,7 +320,7 @@ public:
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
-
+
playerOldName = target->GetName();
}
else
@@ -345,7 +345,7 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (WorldSession* session = handler->GetSession())
{
if (!session->HasPermission(RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME) && sObjectMgr->IsReservedName(newName))
diff --git a/src/server/scripts/Commands/cs_deserter.cpp b/src/server/scripts/Commands/cs_deserter.cpp
index 3850456fcb3..ef2cd7b45b9 100644
--- a/src/server/scripts/Commands/cs_deserter.cpp
+++ b/src/server/scripts/Commands/cs_deserter.cpp
@@ -45,20 +45,20 @@ public:
ChatCommand* GetCommands() const
{
- static ChatCommand deserterInstanceCommandTable[] =
+ static ChatCommand deserterInstanceCommandTable[] =
{
{ "add", SEC_ADMINISTRATOR, false, &HandleDeserterInstanceAdd, "", NULL },
{ "remove", SEC_ADMINISTRATOR, false, &HandleDeserterInstanceRemove, "", NULL },
{ NULL, SEC_PLAYER, false, NULL, "", NULL }
};
- static ChatCommand deserterBGCommandTable[] =
+ static ChatCommand deserterBGCommandTable[] =
{
{ "add", SEC_ADMINISTRATOR, false, &HandleDeserterBGAdd, "", NULL },
{ "remove", SEC_ADMINISTRATOR, false, &HandleDeserterBGRemove, "", NULL },
{ NULL, SEC_PLAYER, false, NULL, "", NULL }
};
- static ChatCommand deserterCommandTable[] =
+ static ChatCommand deserterCommandTable[] =
{
{ "instance", SEC_ADMINISTRATOR, false, NULL, "", deserterInstanceCommandTable },
{ "bg", SEC_ADMINISTRATOR, false, NULL, "", deserterBGCommandTable },
diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp
index bbff716253e..364746adae9 100644
--- a/src/server/scripts/Commands/cs_list.cpp
+++ b/src/server/scripts/Commands/cs_list.cpp
@@ -518,7 +518,7 @@ public:
uint32 copp = (money % GOLD) % SILVER;
std::string receiverStr = handler->playerLink(receiver);
std::string senderStr = handler->playerLink(sender);
- handler->PSendSysMessage(LANG_LIST_MAIL_INFO_1 , messageId, subject.c_str(),gold, silv, copp);
+ handler->PSendSysMessage(LANG_LIST_MAIL_INFO_1, messageId, subject.c_str(), gold, silv, copp);
handler->PSendSysMessage(LANG_LIST_MAIL_INFO_2, senderStr.c_str(), senderId, receiverStr.c_str(), receiverId);
handler->PSendSysMessage(LANG_LIST_MAIL_INFO_3, TimeToTimestampStr(deliverTime).c_str(), TimeToTimestampStr(expireTime).c_str());
if (hasItem == 1)
@@ -541,7 +541,7 @@ public:
uint32 item_entry = fields[0].GetUInt32();
uint32 item_count = fields[1].GetUInt32();
QueryResult result4;
- result4 = WorldDatabase.PQuery("SELECT name,quality FROM item_template WHERE entry = '%u'", item_entry);
+ result4 = WorldDatabase.PQuery("SELECT name, quality FROM item_template WHERE entry = '%u'", item_entry);
Field* fields1 = result4->Fetch();
std::string item_name = fields1[0].GetString();
int item_quality = fields1[1].GetUInt8();
diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp
index e28251bebb4..ff5ece84272 100644
--- a/src/server/scripts/Commands/cs_lookup.cpp
+++ b/src/server/scripts/Commands/cs_lookup.cpp
@@ -869,12 +869,7 @@ public:
uint32 id = atoi((char*)args);
- bool found = false;
- uint32 count = 0;
- uint32 maxResults = 1;
-
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id);
- if (spellInfo)
+ if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id))
{
int locale = handler->GetSessionDbcLocale();
std::string name = spellInfo->SpellName;
@@ -884,14 +879,6 @@ public:
return true;
}
- if (locale < TOTAL_LOCALES)
- {
- if (maxResults && count++ == maxResults)
- {
- handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
- return true;
- }
-
bool known = target && target->HasSpell(id);
bool learn = (spellInfo->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
@@ -935,13 +922,8 @@ public:
ss << handler->GetTrinityString(LANG_ACTIVE);
handler->SendSysMessage(ss.str().c_str());
-
- if (!found)
- found = true;
- }
}
-
- if (!found)
+ else
handler->SendSysMessage(LANG_COMMAND_NOSPELLFOUND);
return true;
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index c5182f7cf4c..489c11e0f94 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -1070,9 +1070,7 @@ public:
Player* player = handler->GetSession()->GetPlayer();
uint32 zone_id = player->GetZoneId();
- WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveYard(
- player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), team);
-
+ WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), team);
if (graveyard)
{
uint32 graveyardId = graveyard->ID;
@@ -1102,14 +1100,12 @@ public:
{
std::string team_name;
- if (team == 0)
- team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY);
- else if (team == HORDE)
+ if (team == HORDE)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE);
else if (team == ALLIANCE)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE);
- if (team == ~uint32(0))
+ if (!team)
handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, zone_id);
else
handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str());
@@ -2046,6 +2042,70 @@ public:
if (!*args)
return false;
+ char* str = strtok((char*)args, " ");
+
+ if (strcmp(str, "go") == 0)
+ {
+ char* guidStr = strtok(NULL, " ");
+ if (!guidStr)
+ {
+ handler->SendSysMessage(LANG_BAD_VALUE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ int32 guid = atoi(guidStr);
+ if (!guid)
+ {
+ handler->SendSysMessage(LANG_BAD_VALUE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ char* damageStr = strtok(NULL, " ");
+ if (!damageStr)
+ {
+ handler->SendSysMessage(LANG_BAD_VALUE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ int32 damage = atoi(damageStr);
+ if (!damage)
+ {
+ handler->SendSysMessage(LANG_BAD_VALUE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ if (Player* player = handler->GetSession()->GetPlayer())
+ {
+ GameObject* go = NULL;
+
+ if (GameObjectData const* goData = sObjectMgr->GetGOData(guid))
+ go = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guid, goData->id);
+
+ if (!go)
+ {
+ handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guid);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ if (!go->IsDestructibleBuilding())
+ {
+ handler->SendSysMessage(LANG_INVALID_GAMEOBJECT_TYPE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ go->ModifyHealth(-damage, player);
+ handler->PSendSysMessage(LANG_GAMEOBJECT_DAMAGED, go->GetName().c_str(), guid, -damage, go->GetGOValue()->Building.Health);
+ }
+
+ return true;
+ }
+
Unit* target = handler->getSelectedUnit();
if (!target || !handler->GetSession()->GetPlayer()->GetSelection())
{
@@ -2084,7 +2144,7 @@ public:
return true;
}
- uint32 school = schoolStr ? atoi((char*)schoolStr) : SPELL_SCHOOL_NORMAL;
+ uint32 school = atoi((char*)schoolStr);
if (school >= MAX_SPELL_SCHOOL)
return false;
diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp
index 55b6edbadbe..300b39fc389 100644
--- a/src/server/scripts/Commands/cs_mmaps.cpp
+++ b/src/server/scripts/Commands/cs_mmaps.cpp
@@ -128,7 +128,7 @@ public:
int32 gy = 32 - player->GetPositionY() / SIZE_OF_GRIDS;
handler->PSendSysMessage("%03u%02i%02i.mmtile", player->GetMapId(), gy, gx);
- handler->PSendSysMessage("gridloc [%i,%i]", gx, gy);
+ handler->PSendSysMessage("gridloc [%i, %i]", gx, gy);
// calculate navmesh tile location
dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId());
@@ -148,7 +148,7 @@ public:
int32 tilex = int32((y - min[0]) / SIZE_OF_GRIDS);
int32 tiley = int32((x - min[2]) / SIZE_OF_GRIDS);
- handler->PSendSysMessage("Calc [%02i,%02i]", tilex, tiley);
+ handler->PSendSysMessage("Calc [%02i, %02i]", tilex, tiley);
// navmesh poly -> navmesh tile location
dtQueryFilter filter = dtQueryFilter();
@@ -156,16 +156,16 @@ public:
navmeshquery->findNearestPoly(location, extents, &filter, &polyRef, NULL);
if (polyRef == INVALID_POLYREF)
- handler->PSendSysMessage("Dt [??,??] (invalid poly, probably no tile loaded)");
+ handler->PSendSysMessage("Dt [??, ??] (invalid poly, probably no tile loaded)");
else
{
dtMeshTile const* tile;
dtPoly const* poly;
navmesh->getTileAndPolyByRef(polyRef, &tile, &poly);
if (tile)
- handler->PSendSysMessage("Dt [%02i,%02i]", tile->header->x, tile->header->y);
+ handler->PSendSysMessage("Dt [%02i, %02i]", tile->header->x, tile->header->y);
else
- handler->PSendSysMessage("Dt [??,??] (no tile loaded)");
+ handler->PSendSysMessage("Dt [??, ??] (no tile loaded)");
}
return true;
@@ -190,7 +190,7 @@ public:
if (!tile || !tile->header)
continue;
- handler->PSendSysMessage("[%02i,%02i]", tile->header->x, tile->header->y);
+ handler->PSendSysMessage("[%02i, %02i]", tile->header->x, tile->header->y);
}
return true;
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp
index be111c9356b..ed933ffd5bc 100644
--- a/src/server/scripts/Commands/cs_modify.cpp
+++ b/src/server/scripts/Commands/cs_modify.cpp
@@ -310,24 +310,14 @@ public:
if (!pfactionid)
{
- if (target)
- {
- uint32 factionid = target->getFaction();
- uint32 flag = target->GetUInt32Value(UNIT_FIELD_FLAGS);
- uint32 npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS);
- uint32 dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
- handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUIDLow(), factionid, flag, npcflag, dyflag);
- }
+ uint32 factionid = target->getFaction();
+ uint32 flag = target->GetUInt32Value(UNIT_FIELD_FLAGS);
+ uint32 npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS);
+ uint32 dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
+ handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUIDLow(), factionid, flag, npcflag, dyflag);
return true;
}
- if (!target)
- {
- handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
uint32 factionid = atoi(pfactionid);
uint32 flag;
@@ -341,7 +331,7 @@ public:
uint32 npcflag;
if (!pnpcflag)
- npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS);
+ npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS);
else
npcflag = atoi(pnpcflag);
@@ -349,7 +339,7 @@ public:
uint32 dyflag;
if (!pdyflag)
- dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
+ dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
else
dyflag = atoi(pdyflag);
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index a398ac9004b..eadfd3b8da0 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -254,7 +254,7 @@ public:
return false;
}
- uint32 vendor_entry = vendor ? vendor->GetEntry() : 0;
+ uint32 vendor_entry = vendor->GetEntry();
if (!sObjectMgr->IsVendorItemValid(vendor_entry, itemId, maxcount, incrtime, extendedcost, type, handler->GetSession()->GetPlayer()))
{
diff --git a/src/server/scripts/Commands/cs_rbac.cpp b/src/server/scripts/Commands/cs_rbac.cpp
index 604218c2e68..667815ce16c 100644
--- a/src/server/scripts/Commands/cs_rbac.cpp
+++ b/src/server/scripts/Commands/cs_rbac.cpp
@@ -32,6 +32,12 @@ EndScriptData */
struct RBACCommandData
{
RBACCommandData(): id(0), realmId(0), rbac(NULL), needDelete(false) { }
+ ~RBACCommandData()
+ {
+ if (needDelete)
+ delete rbac;
+ }
+
uint32 id;
int32 realmId;
RBACData* rbac;
@@ -230,8 +236,7 @@ public:
break;
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -266,8 +271,7 @@ public:
break;
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -295,8 +299,7 @@ public:
}
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -335,8 +338,7 @@ public:
break;
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -375,8 +377,7 @@ public:
break;
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -411,8 +412,7 @@ public:
break;
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -453,8 +453,7 @@ public:
}
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -493,8 +492,7 @@ public:
break;
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -533,8 +531,7 @@ public:
break;
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -569,8 +566,7 @@ public:
break;
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -613,8 +609,7 @@ public:
}
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
@@ -643,8 +638,7 @@ public:
}
}
- if (command->needDelete)
- delete command;
+ delete command;
return true;
}
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index b162e0c51a4..745cc80ab41 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -800,7 +800,7 @@ public:
if (show == "info")
{
// Check if the user did specify a visual waypoint
- if (target->GetEntry() != VISUAL_WAYPOINT)
+ if (target && target->GetEntry() != VISUAL_WAYPOINT)
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_SELECT);
handler->SetSentErrorMessage(true);