aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-08-15 20:13:34 +0200
committerShauren <shauren.trinity@gmail.com>2014-08-15 20:13:34 +0200
commitd0176f985d20604a23396c326af303327ef989be (patch)
tree3b3e2ecbeb55531cb4863f0ad063f45699429ace /src/server/scripts/Commands
parent4a741258f145af59a224760651e735297ad92101 (diff)
parentaab4ab166de351e2c6e1c26a9d4001328e253ea9 (diff)
Merge branch 'master' of https://github.com/TrinityCore/TrinityCore into 4.3.4
Conflicts: src/server/game/Globals/ObjectMgr.cpp src/server/scripts/Commands/cs_reload.cpp src/server/shared/Database/Implementation/WorldDatabase.cpp
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_ban.cpp16
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp46
-rw-r--r--src/server/scripts/Commands/cs_reload.cpp83
3 files changed, 26 insertions, 119 deletions
diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp
index 2f74132fe21..121da6489a3 100644
--- a/src/server/scripts/Commands/cs_ban.cpp
+++ b/src/server/scripts/Commands/cs_ban.cpp
@@ -109,21 +109,23 @@ public:
return false;
}
- switch (sWorld->BanCharacter(name, durationStr, reasonStr, handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : ""))
+ std::string author = handler->GetSession() ? handler->GetSession()->GetPlayerName() : "Server";
+
+ switch (sWorld->BanCharacter(name, durationStr, reasonStr, author))
{
case BAN_SUCCESS:
{
if (atoi(durationStr) > 0)
{
if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD))
- sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr);
+ sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD, author.c_str(), name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr);
else
handler->PSendSysMessage(LANG_BAN_YOUBANNED, name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr);
}
else
{
if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD))
- sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), name.c_str(), reasonStr);
+ sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD, author.c_str(), name.c_str(), reasonStr);
else
handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, name.c_str(), reasonStr);
}
@@ -195,20 +197,22 @@ public:
break;
}
- switch (sWorld->BanAccount(mode, nameOrIP, durationStr, reasonStr, handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : ""))
+ std::string author = handler->GetSession() ? handler->GetSession()->GetPlayerName() : "Server";
+
+ switch (sWorld->BanAccount(mode, nameOrIP, durationStr, reasonStr, author))
{
case BAN_SUCCESS:
if (atoi(durationStr) > 0)
{
if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD))
- sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr);
+ sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, author.c_str(), nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr);
else
handler->PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr);
}
else
{
if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD))
- sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), nameOrIP.c_str(), reasonStr);
+ sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, author.c_str(), nameOrIP.c_str(), reasonStr);
else
handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reasonStr);
}
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 9d763cb8d71..2afdff94a0b 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -1610,16 +1610,7 @@ public:
banReason = fields[3].GetString();
}
- // Can be used to query data from World database
- stmt2 = WorldDatabase.GetPreparedStatement(WORLD_SEL_REQ_XP);
- stmt2->setUInt8(0, level);
- PreparedQueryResult result3 = WorldDatabase.Query(stmt2);
- if (result3)
- {
- Field* fields = result3->Fetch();
- xptotal = fields[0].GetUInt32();
- }
// Can be used to query data from Characters database
stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_XP);
@@ -1631,6 +1622,7 @@ public:
Field* fields = result4->Fetch();
xp = fields[0].GetUInt32(); // Used for "current xp" output and "%u XP Left" calculation
uint32 gguid = fields[1].GetUInt32(); // We check if have a guild for the person, so we might not require to query it at all
+ xptotal = sObjectMgr->GetXPForLevel(level);
if (gguid != 0)
{
@@ -1767,10 +1759,10 @@ public:
Player* player = handler->GetSession()->GetPlayer();
// accept only explicitly selected target (not implicitly self targeting case)
- Unit* target = handler->getSelectedUnit();
- if (player->GetTarget() && target)
+ Creature* target = player->GetTarget() ? handler->getSelectedCreature() : nullptr;
+ if (target)
{
- if (target->GetTypeId() != TYPEID_UNIT || target->IsPet())
+ if (target->IsPet())
{
handler->SendSysMessage(LANG_SELECT_CREATURE);
handler->SetSentErrorMessage(true);
@@ -1778,19 +1770,13 @@ public:
}
if (target->isDead())
- target->ToCreature()->Respawn();
+ target->Respawn();
return true;
}
- CellCoord p(Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()));
- Cell cell(p);
- cell.SetNoCreate();
-
Trinity::RespawnDo u_do;
Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do);
-
- TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
- cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange());
+ player->VisitNearbyGridObject(player->GetGridActivationRange(), worker);
return true;
}
@@ -1844,14 +1830,9 @@ public:
std::string nameLink = handler->playerLink(targetName);
if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD))
- {
- sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
- ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str());
- }
- else
- {
- ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str());
- }
+ sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
+
+ ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str());
}
else
{
@@ -1866,10 +1847,11 @@ public:
LoginDatabase.Execute(stmt);
std::string nameLink = handler->playerLink(targetName);
- if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD) && !target)
- sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, handler->GetSession()->GetPlayerName().c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
- else
- handler->PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
+ if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD) && !target)
+ sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
+ else
+ handler->PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
+
return true;
}
diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp
index 2988c2c50c9..4b78ab880d4 100644
--- a/src/server/scripts/Commands/cs_reload.cpp
+++ b/src/server/scripts/Commands/cs_reload.cpp
@@ -438,7 +438,7 @@ public:
continue;
}
- CreatureTemplate* cInfo = const_cast<CreatureTemplate*>(sObjectMgr->GetCreatureTemplate(entry));
+ CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(entry);
if (!cInfo)
{
handler->PSendSysMessage(LANG_COMMAND_CREATURESTORAGE_NOTFOUND, entry);
@@ -448,86 +448,7 @@ public:
TC_LOG_INFO("misc", "Reloading creature template entry %u", entry);
Field* fields = result->Fetch();
-
- for (uint8 i = 0; i < MAX_DIFFICULTY - 1; ++i)
- cInfo->DifficultyEntry[i] = fields[0 + i].GetUInt32();
-
- for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
- cInfo->KillCredit[i] = fields[3 + i].GetUInt32();
-
- cInfo->Modelid1 = fields[5].GetUInt32();
- cInfo->Modelid2 = fields[6].GetUInt32();
- cInfo->Modelid3 = fields[7].GetUInt32();
- cInfo->Modelid4 = fields[8].GetUInt32();
- cInfo->Name = fields[9].GetString();
- cInfo->SubName = fields[10].GetString();
- cInfo->FemaleName = fields[11].GetString();
- cInfo->IconName = fields[12].GetString();
- cInfo->GossipMenuId = fields[13].GetUInt32();
- cInfo->minlevel = fields[14].GetUInt8();
- cInfo->maxlevel = fields[15].GetUInt8();
- cInfo->expansion = fields[16].GetUInt16();
- cInfo->expansionUnknown = fields[17].GetUInt16();
- cInfo->faction = fields[18].GetUInt16();
- cInfo->npcflag = fields[19].GetUInt32();
- cInfo->speed_walk = fields[20].GetFloat();
- cInfo->speed_run = fields[21].GetFloat();
- cInfo->scale = fields[22].GetFloat();
- cInfo->rank = fields[23].GetUInt8();
- cInfo->mindmg = fields[24].GetFloat();
- cInfo->maxdmg = fields[25].GetFloat();
- cInfo->dmgschool = fields[26].GetUInt8();
- cInfo->attackpower = fields[27].GetUInt32();
- cInfo->dmg_multiplier = fields[28].GetFloat();
- cInfo->baseattacktime = fields[29].GetUInt32();
- cInfo->rangeattacktime = fields[30].GetUInt32();
- cInfo->unit_class = fields[31].GetUInt8();
- cInfo->unit_flags = fields[32].GetUInt32();
- cInfo->unit_flags2 = fields[33].GetUInt32();
- cInfo->dynamicflags = fields[34].GetUInt32();
- cInfo->family = fields[35].GetUInt8();
- cInfo->trainer_type = fields[36].GetUInt8();
- cInfo->trainer_class = fields[37].GetUInt8();
- cInfo->trainer_race = fields[38].GetUInt8();
- cInfo->minrangedmg = fields[39].GetFloat();
- cInfo->maxrangedmg = fields[40].GetFloat();
- cInfo->rangedattackpower = fields[41].GetUInt16();
- cInfo->type = fields[42].GetUInt8();
- cInfo->type_flags = fields[43].GetUInt32();
- cInfo->type_flags2 = fields[44].GetUInt32();
- cInfo->lootid = fields[45].GetUInt32();
- cInfo->pickpocketLootId = fields[46].GetUInt32();
- cInfo->SkinLootId = fields[47].GetUInt32();
-
- for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
- cInfo->resistance[i] = fields[48 + i -1].GetUInt16();
-
- for (uint8 i = 0; i < CREATURE_MAX_SPELLS; ++i)
- cInfo->spells[i] = fields[54 + i].GetUInt32();
-
- cInfo->PetSpellDataId = fields[62].GetUInt32();
- cInfo->VehicleId = fields[63].GetUInt32();
- cInfo->mingold = fields[64].GetUInt32();
- cInfo->maxgold = fields[65].GetUInt32();
- cInfo->AIName = fields[66].GetString();
- cInfo->MovementType = fields[67].GetUInt8();
- cInfo->InhabitType = fields[68].GetUInt8();
- cInfo->HoverHeight = fields[69].GetFloat();
- cInfo->ModHealth = fields[70].GetFloat();
- cInfo->ModMana = fields[71].GetFloat();
- cInfo->ModManaExtra = fields[72].GetFloat();
- cInfo->ModArmor = fields[73].GetFloat();
- cInfo->RacialLeader = fields[74].GetBool();
-
- for (uint8 i = 0; i < MAX_CREATURE_QUEST_ITEMS; ++i)
- cInfo->questItems[i] = fields[75 + i].GetUInt32();
-
- cInfo->movementId = fields[81].GetUInt32();
- cInfo->RegenHealth = fields[82].GetBool();
- cInfo->MechanicImmuneMask = fields[83].GetUInt32();
- cInfo->flags_extra = fields[84].GetUInt32();
- cInfo->ScriptID = sObjectMgr->GetScriptId(fields[85].GetCString());
-
+ sObjectMgr->LoadCreatureTemplate(fields);
sObjectMgr->CheckCreatureTemplate(cInfo);
}