aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRochet2 <rochet2@post.com>2017-07-22 10:22:17 +0300
committerAokromes <Aokromes@users.noreply.github.com>2017-07-22 09:22:17 +0200
commit211b564894b0142c86d86482caf2a8f8158da39a (patch)
tree4cf0aef3356039ebbf90e787ec977eaf8a61f781 /src
parent0feb56e2c75e5cf3a8388ff6d9b9441d2b5d0c59 (diff)
Scripts/Commands: Fix trinity_string usage and enhance commands
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/Commands/cs_account.cpp6
-rw-r--r--src/server/scripts/Commands/cs_arena.cpp6
-rw-r--r--src/server/scripts/Commands/cs_character.cpp7
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp48
-rw-r--r--src/server/scripts/Commands/cs_disable.cpp2
-rw-r--r--src/server/scripts/Commands/cs_go.cpp2
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp24
-rw-r--r--src/server/scripts/Commands/cs_group.cpp2
-rw-r--r--src/server/scripts/Commands/cs_guild.cpp4
-rw-r--r--src/server/scripts/Commands/cs_honor.cpp2
-rw-r--r--src/server/scripts/Commands/cs_instance.cpp10
-rw-r--r--src/server/scripts/Commands/cs_list.cpp16
-rw-r--r--src/server/scripts/Commands/cs_lookup.cpp15
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp24
-rw-r--r--src/server/scripts/Commands/cs_modify.cpp31
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp46
-rw-r--r--src/server/scripts/Commands/cs_reload.cpp2
-rw-r--r--src/server/scripts/Commands/cs_send.cpp2
-rw-r--r--src/server/scripts/Commands/cs_ticket.cpp2
-rw-r--r--src/server/scripts/Commands/cs_titles.cpp28
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp28
21 files changed, 145 insertions, 162 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 5db80a148b2..d2977a7cdd7 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -545,7 +545,7 @@ public:
{
// GM Level
AccountTypes gmLevel = handler->GetSession()->GetSecurity();
- handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmLevel));
+ handler->PSendSysMessage(LANG_ACCOUNT_LEVEL, int32(gmLevel));
// Security level required
bool hasRBAC = (handler->HasPermission(rbac::RBAC_PERM_EMAIL_CONFIRM_FOR_PASS_CHANGE) ? true : false);
@@ -629,8 +629,8 @@ public:
handler->HasLowerSecurityAccount(NULL, accountId, true))
return false;
- int expansion = atoi(exp); //get int anyway (0 if error)
- if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
+ uint8 expansion = static_cast<uint8>(atoul(exp));
+ if (expansion > sWorld->getIntConfig(CONFIG_EXPANSION))
return false;
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION);
diff --git a/src/server/scripts/Commands/cs_arena.cpp b/src/server/scripts/Commands/cs_arena.cpp
index 6dacd58d2c5..88573fbd859 100644
--- a/src/server/scripts/Commands/cs_arena.cpp
+++ b/src/server/scripts/Commands/cs_arena.cpp
@@ -121,7 +121,7 @@ public:
if (!*args)
return false;
- uint32 teamId = atoi((char*)args);
+ uint32 teamId = atoul(args);
if (!teamId)
return false;
@@ -228,7 +228,7 @@ public:
if (!idStr)
return false;
- uint32 teamId = atoi(idStr);
+ uint32 teamId = atoul(idStr);
if (!teamId)
return false;
@@ -300,7 +300,7 @@ public:
if (!*args)
return false;
- uint32 teamId = atoi((char*)args);
+ uint32 teamId = atoul(args);
if (!teamId)
return false;
diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp
index 7d6e4725040..d6c20e42229 100644
--- a/src/server/scripts/Commands/cs_character.cpp
+++ b/src/server/scripts/Commands/cs_character.cpp
@@ -284,12 +284,11 @@ public:
? handler->GetTrinityString(LANG_ACTIVE)
: "";
- char titleNameStr[80];
- snprintf(titleNameStr, 80, name.c_str(), targetName);
+ std::string titleNameStr = Trinity::StringFormat(name.c_str(), targetName);
// send title in "id (idx:idx) - [namedlink locale]" format
if (handler->GetSession())
- handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->MaskID, id, titleNameStr, localeNames[loc], knownStr, activeStr);
+ handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->MaskID, id, titleNameStr.c_str(), localeNames[loc], knownStr, activeStr);
else
handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->MaskID, name.c_str(), localeNames[loc], knownStr, activeStr);
}
@@ -922,7 +921,7 @@ public:
if (ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid::Create<HighGuid::Player>(guid)))
{
- handler->PSendSysMessage(LANG_CHARACTER_GUID_IN_USE, guid);
+ handler->PSendSysMessage(LANG_CHARACTER_GUID_IN_USE, std::to_string(guid).c_str());
handler->SetSentErrorMessage(true);
return false;
}
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index bd9d68761b6..b349e1574b0 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -126,7 +126,7 @@ public:
return false;
}
- uint32 id = atoi((char*)args);
+ uint32 id = atoul(args);
CinematicSequencesEntry const* cineSeq = sCinematicSequencesStore.LookupEntry(id);
if (!cineSeq)
@@ -164,7 +164,7 @@ public:
return false;
}
- uint32 id = atoi((char*)args);
+ uint32 id = atoul(args);
if (!sMovieStore.LookupEntry(id))
{
@@ -189,7 +189,7 @@ public:
return false;
}
- uint32 soundId = atoi((char*)args);
+ uint32 soundId = atoul(args);
if (!sSoundKitStore.LookupEntry(soundId))
{
@@ -386,7 +386,7 @@ public:
GameObject* obj = handler->GetNearbyGameObject();
if (!obj)
{
- handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, UI64LIT(0));
+ handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, "0");
handler->SetSentErrorMessage(true);
ifs.close();
return false;
@@ -434,8 +434,8 @@ public:
if (!w || !s)
return false;
- uint32 world = (uint32)atoi(w);
- uint32 state = (uint32)atoi(s);
+ uint32 world = atoul(w);
+ uint32 state = atoul(s);
handler->GetSession()->GetPlayer()->SendUpdateWorldState(world, state);
return true;
}
@@ -501,8 +501,8 @@ public:
if (!target)
return false;
- handler->PSendSysMessage("Loot recipient for creature %s (%s, DB GUID " UI64FMTD ") is %s",
- target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetSpawnId(),
+ handler->PSendSysMessage("Loot recipient for creature %s (%s, DB GUID %s) is %s",
+ target->GetName().c_str(), target->GetGUID().ToString().c_str(), std::to_string(target->GetSpawnId()).c_str(),
target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient");
return true;
}
@@ -832,7 +832,7 @@ public:
if (Unit* unit = ref->GetSource()->GetOwner())
{
++count;
- handler->PSendSysMessage(" %u. %s (%s, SpawnId: %u) - threat %f", count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0, ref->getThreat());
+ handler->PSendSysMessage(" %u. %s (%s, SpawnId: %s) - threat %f", count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), unit->GetTypeId() == TYPEID_UNIT ? std::to_string(unit->ToCreature()->GetSpawnId()).c_str() : "0", ref->getThreat());
}
ref = ref->next();
}
@@ -853,7 +853,7 @@ public:
if (!i)
return false;
- uint32 id = (uint32)atoi(i);
+ uint32 id = atoul(i);
//target->SetVehicleId(id);
handler->PSendSysMessage("Vehicle id set to %u", id);
return true;
@@ -874,7 +874,7 @@ public:
char* j = strtok(NULL, " ");
- uint32 entry = (uint32)atoi(i);
+ uint32 entry = atoul(i);
int8 seatId = j ? (int8)atoi(j) : -1;
if (!entry)
@@ -905,7 +905,7 @@ public:
if (!e)
return false;
- uint32 entry = (uint32)atoi(e);
+ uint32 entry = atoul(e);
float x, y, z, o = handler->GetSession()->GetPlayer()->GetOrientation();
handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, handler->GetSession()->GetPlayer()->GetObjectSize());
@@ -913,7 +913,7 @@ public:
if (!i)
return handler->GetSession()->GetPlayer()->SummonCreature(entry, x, y, z, o) != nullptr;
- uint32 id = (uint32)atoi(i);
+ uint32 id = atoul(i);
CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(entry);
@@ -995,7 +995,7 @@ public:
return false;
ObjectGuid::LowType guid = strtoull(e, nullptr, 10);
- uint32 index = (uint32)atoi(f);
+ uint32 index = atoul(f);
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
@@ -1025,8 +1025,8 @@ public:
return false;
ObjectGuid::LowType guid = strtoull(e, nullptr, 10);
- uint32 index = (uint32)atoi(f);
- uint32 value = (uint32)atoi(g);
+ uint32 index = atoul(f);
+ uint32 value = atoul(g);
Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
@@ -1134,7 +1134,7 @@ public:
ObjectGuid guid = target->GetGUID();
- uint32 field = (uint32)atoi(x);
+ uint32 field = atoul(x);
if (field >= target->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, field, guid.ToString().c_str(), target->GetValuesCount());
@@ -1147,7 +1147,7 @@ public:
if (isInt32)
{
- uint32 value = (uint32)atoi(y);
+ uint32 value = atoul(y);
target->SetUInt32Value(field, value);
handler->PSendSysMessage(LANG_SET_UINT_FIELD, guid.ToString().c_str(), field, value);
}
@@ -1182,7 +1182,7 @@ public:
ObjectGuid guid = target->GetGUID();
- uint32 opcode = (uint32)atoi(x);
+ uint32 opcode = atoul(x);
if (opcode >= target->GetValuesCount())
{
handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, guid.ToString().c_str(), target->GetValuesCount());
@@ -1218,7 +1218,7 @@ public:
if (!x || !y)
return false;
- uint32 opcode = (uint32)atoi(x);
+ uint32 opcode = atoul(x);
int value = atoi(y);
if (opcode >= handler->GetSession()->GetPlayer()->GetValuesCount())
@@ -1227,10 +1227,10 @@ public:
return false;
}
- int currentValue = (int)handler->GetSession()->GetPlayer()->GetUInt32Value(opcode);
+ uint32 currentValue = handler->GetSession()->GetPlayer()->GetUInt32Value(opcode);
currentValue += value;
- handler->GetSession()->GetPlayer()->SetUInt32Value(opcode, (uint32)currentValue);
+ handler->GetSession()->GetPlayer()->SetUInt32Value(opcode, currentValue);
handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, opcode, currentValue);
@@ -1305,8 +1305,8 @@ public:
if (!x || !y)
return false;
- uint32 opcode = (uint32)atoi(x);
- uint32 val = (uint32)atoi(y);
+ uint32 opcode = atoul(x);
+ uint32 val = atoul(y);
if (val > 32) //uint32 = 32 bits
return false;
diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp
index 55c92db5a82..b96e40cbbfe 100644
--- a/src/server/scripts/Commands/cs_disable.cpp
+++ b/src/server/scripts/Commands/cs_disable.cpp
@@ -90,7 +90,7 @@ public:
return false;
std::string disableComment = commentStr;
- uint32 entry = uint32(atoi(entryStr));
+ uint32 entry = atoul(entryStr);
char const* disableTypeStr = "";
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp
index deadd9c25b3..9e767f4b1df 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -321,7 +321,7 @@ public:
if (!id)
return false;
- uint32 questID = atoi(id);
+ uint32 questID = atoul(id);
if (!questID)
return false;
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index 7c9f5b224dc..46fa3542503 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -91,7 +91,7 @@ public:
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
- handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
+ handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(guidLow).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -177,7 +177,7 @@ public:
/// @todo is it really necessary to add both the real and DB table guid here ?
sObjectMgr->AddGameobjectToGrid(spawnId, ASSERT_NOTNULL(sObjectMgr->GetGOData(spawnId)));
- handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, objectId, objectInfo->name.c_str(), spawnId, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
+ handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, objectId, objectInfo->name.c_str(), std::to_string(spawnId).c_str(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
return true;
}
@@ -316,7 +316,7 @@ public:
GameObject* target = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
- handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name.c_str(), guidLow, id, x, y, z, mapId, o, phaseId, phaseGroup);
+ handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, std::to_string(guidLow).c_str(), objectInfo->name.c_str(), std::to_string(guidLow).c_str(), id, x, y, z, mapId, o, phaseId, phaseGroup);
if (target)
{
@@ -347,7 +347,7 @@ public:
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
- handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
+ handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(guidLow).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -370,7 +370,7 @@ public:
object->Delete();
object->DeleteFromDB();
- handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetGUID().ToString().c_str());
+ handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, std::to_string(guidLow).c_str());
return true;
}
@@ -390,7 +390,7 @@ public:
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
- handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
+ handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(guidLow).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -425,7 +425,7 @@ public:
object->SaveToDB();
- handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetGUID().ToString().c_str(), object->GetOrientation());
+ handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, std::to_string(object->GetSpawnId()).c_str(), object->GetGOInfo()->name.c_str(), object->GetGUID().ToString().c_str(), object->GetOrientation());
return true;
}
@@ -445,7 +445,7 @@ public:
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
- handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
+ handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(guidLow).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -483,7 +483,7 @@ public:
object->SaveToDB();
- handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetGUID().ToString().c_str());
+ handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, std::to_string(object->GetSpawnId()).c_str(), object->GetGOInfo()->name.c_str(), object->GetGUID().ToString().c_str());
return true;
}
@@ -503,7 +503,7 @@ public:
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
- handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
+ handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(guidLow).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -557,7 +557,7 @@ public:
if (!gameObjectInfo)
continue;
- handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gameObjectInfo->name.c_str(), x, y, z, mapId);
+ handler->PSendSysMessage(LANG_GO_LIST_CHAT, std::to_string(guid).c_str(), entry, std::to_string(guid).c_str(), gameObjectInfo->name.c_str(), x, y, z, mapId);
++count;
} while (result->NextRow());
@@ -640,7 +640,7 @@ public:
GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!object)
{
- handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
+ handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(guidLow).c_str());
handler->SetSentErrorMessage(true);
return false;
}
diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp
index ea6bd7fa3e1..a05efd61678 100644
--- a/src/server/scripts/Commands/cs_group.cpp
+++ b/src/server/scripts/Commands/cs_group.cpp
@@ -315,7 +315,7 @@ public:
Group::MemberSlotList const& members = groupTarget->GetMemberSlots();
// To avoid a cluster fuck, namely trying multiple queries to simply get a group member count...
- handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "raid" : "party"), members.size());
+ handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "raid" : "party"), std::to_string(members.size()).c_str());
// ... we simply move the group type and member count print after retrieving the slots and simply output it's size.
// While rather dirty codestyle-wise, it saves space (if only a little). For each member, we look several informations up.
diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp
index e02101aa010..a5839200568 100644
--- a/src/server/scripts/Commands/cs_guild.cpp
+++ b/src/server/scripts/Commands/cs_guild.cpp
@@ -266,7 +266,7 @@ public:
return false;
// Display Guild Information
- handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), guild->GetId()); // Guild Id + Name
+ handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), std::to_string(guild->GetId()).c_str()); // Guild Id + Name
std::string guildMasterName;
if (ObjectMgr::GetPlayerNameByGUID(guild->GetLeaderGUID(), guildMasterName))
@@ -280,7 +280,7 @@ public:
handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, createdDateStr); // Creation Date
handler->PSendSysMessage(LANG_GUILD_INFO_MEMBER_COUNT, guild->GetMembersCount()); // Number of Members
- handler->PSendSysMessage(LANG_GUILD_INFO_BANK_GOLD, guild->GetBankMoney() / 100 / 100); // Bank Gold (in gold coins)
+ handler->PSendSysMessage(LANG_GUILD_INFO_BANK_GOLD, std::to_string(guild->GetBankMoney() / 100 / 100).c_str()); // Bank Gold (in gold coins)
handler->PSendSysMessage(LANG_GUILD_INFO_LEVEL, guild->GetLevel()); // Level
handler->PSendSysMessage(LANG_GUILD_INFO_MOTD, guild->GetMOTD().c_str()); // Message of the Day
handler->PSendSysMessage(LANG_GUILD_INFO_EXTRA_INFO, guild->GetInfo().c_str()); // Extra Information
diff --git a/src/server/scripts/Commands/cs_honor.cpp b/src/server/scripts/Commands/cs_honor.cpp
index c187df7ede2..eff3b6241dd 100644
--- a/src/server/scripts/Commands/cs_honor.cpp
+++ b/src/server/scripts/Commands/cs_honor.cpp
@@ -73,7 +73,7 @@ public:
if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
return false;
- uint32 amount = (uint32)atoi(args);
+ int32 amount = atoi(args);
target->RewardHonor(NULL, 1, amount);
return true;
}
diff --git a/src/server/scripts/Commands/cs_instance.cpp b/src/server/scripts/Commands/cs_instance.cpp
index b1e9390db24..f9a2b83219a 100644
--- a/src/server/scripts/Commands/cs_instance.cpp
+++ b/src/server/scripts/Commands/cs_instance.cpp
@@ -244,7 +244,7 @@ public:
return false;
}
- encounterId = atoi(param1);
+ encounterId = atoul(param1);
state = atoi(param2);
// Reject improper values.
@@ -257,7 +257,7 @@ public:
map->GetInstanceScript()->SetBossState(encounterId, EncounterState(state));
std::string stateName = InstanceScript::GetBossStateName(state);
- handler->PSendSysMessage(LANG_COMMAND_INST_SET_BOSS_STATE, encounterId, state, stateName);
+ handler->PSendSysMessage(LANG_COMMAND_INST_SET_BOSS_STATE, encounterId, state, stateName.c_str());
return true;
}
@@ -311,7 +311,7 @@ public:
return false;
}
- encounterId = atoi(param1);
+ encounterId = atoul(param1);
if (encounterId > map->GetInstanceScript()->GetEncounterCount())
{
@@ -320,9 +320,9 @@ public:
return false;
}
- uint32 state = map->GetInstanceScript()->GetBossState(encounterId);
+ int32 state = map->GetInstanceScript()->GetBossState(encounterId);
std::string stateName = InstanceScript::GetBossStateName(state);
- handler->PSendSysMessage(LANG_COMMAND_INST_GET_BOSS_STATE, encounterId, state, stateName);
+ handler->PSendSysMessage(LANG_COMMAND_INST_GET_BOSS_STATE, encounterId, state, stateName.c_str());
return true;
}
};
diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp
index eb58710a647..53faf7f84f4 100644
--- a/src/server/scripts/Commands/cs_list.cpp
+++ b/src/server/scripts/Commands/cs_list.cpp
@@ -117,9 +117,9 @@ public:
uint16 mapId = fields[4].GetUInt16();
if (handler->GetSession())
- handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name.c_str(), x, y, z, mapId);
+ handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, std::to_string(guid).c_str(), std::to_string(guid).c_str(), cInfo->Name.c_str(), x, y, z, mapId);
else
- handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name.c_str(), x, y, z, mapId);
+ handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, std::to_string(guid).c_str(), cInfo->Name.c_str(), x, y, z, mapId);
}
while (result->NextRow());
}
@@ -246,7 +246,7 @@ public:
char const* itemPos = "[in mail]";
- handler->PSendSysMessage(LANG_ITEMLIST_MAIL, itemGuid, itemSenderName.c_str(), itemSender, itemSenderAccountId, itemReceiverName.c_str(), itemReceiver, itemReceiverAccount, itemPos);
+ handler->PSendSysMessage(LANG_ITEMLIST_MAIL, std::to_string(itemGuid).c_str(), itemSenderName.c_str(), std::to_string(itemSender).c_str(), itemSenderAccountId, itemReceiverName.c_str(), std::to_string(itemReceiver).c_str(), itemReceiverAccount, itemPos);
}
while (result->NextRow());
@@ -407,9 +407,9 @@ public:
uint32 entry = fields[5].GetUInt32();
if (handler->GetSession())
- handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapId);
+ handler->PSendSysMessage(LANG_GO_LIST_CHAT, std::to_string(guid).c_str(), entry, std::to_string(guid).c_str(), gInfo->name.c_str(), x, y, z, mapId);
else
- handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name.c_str(), x, y, z, mapId);
+ handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, std::to_string(guid).c_str(), gInfo->name.c_str(), x, y, z, mapId);
}
while (result->NextRow());
}
@@ -433,7 +433,7 @@ public:
char const* passiveStr = handler->GetTrinityString(LANG_PASSIVE);
Unit::AuraApplicationMap const& auras = unit->GetAppliedAuras();
- handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, auras.size());
+ handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, std::to_string(auras.size()).c_str());
for (Unit::AuraApplicationMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
@@ -458,7 +458,7 @@ public:
if (auraList.empty())
continue;
- handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, auraList.size(), i);
+ handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE, std::to_string(auraList.size()).c_str(), i);
for (Unit::AuraEffectList::const_iterator itr = auraList.begin(); itr != auraList.end(); ++itr)
handler->PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), (*itr)->GetAmount());
@@ -524,7 +524,7 @@ public:
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_2, senderStr.c_str(), senderId, receiverStr.c_str(), receiverId);
+ handler->PSendSysMessage(LANG_LIST_MAIL_INFO_2, senderStr.c_str(), std::to_string(senderId).c_str(), receiverStr.c_str(), std::to_string(receiverId).c_str());
handler->PSendSysMessage(LANG_LIST_MAIL_INFO_3, TimeToTimestampStr(deliverTime).c_str(), TimeToTimestampStr(expireTime).c_str());
if (hasItem == 1)
diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp
index dc07c0b9f49..10a8d91d4c9 100644
--- a/src/server/scripts/Commands/cs_lookup.cpp
+++ b/src/server/scripts/Commands/cs_lookup.cpp
@@ -778,7 +778,7 @@ public:
return true;
}
- char valStr[50] = "";
+ std::string valStr = "";
char const* knownStr = "";
if (target && target->HasSkill(id))
{
@@ -789,14 +789,14 @@ public:
uint32 tempValue = target->GetSkillTempBonusValue(id);
char const* valFormat = handler->GetTrinityString(LANG_SKILL_VALUES);
- snprintf(valStr, 50, valFormat, curValue, maxValue, permValue, tempValue);
+ valStr = Trinity::StringFormat(valFormat, curValue, maxValue, permValue, tempValue);
}
// send skill in "id - [namedlink locale]" format
if (handler->GetSession())
- handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, id, id, name.c_str(), "", knownStr, valStr);
+ handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, id, id, name.c_str(), "", knownStr, valStr.c_str());
else
- handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, id, name.c_str(), "", knownStr, valStr);
+ handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, id, name.c_str(), "", knownStr, valStr.c_str());
if (!found)
found = true;
@@ -1170,14 +1170,13 @@ public:
? handler->GetTrinityString(LANG_ACTIVE)
: "";
- char titleNameStr[80];
- snprintf(titleNameStr, 80, name.c_str(), targetName);
+ std::string titleNameStr = Trinity::StringFormat(name.c_str(), targetName);
// send title in "id (idx:idx) - [namedlink locale]" format
if (handler->GetSession())
- handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->MaskID, id, titleNameStr, "", knownStr, activeStr);
+ handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->MaskID, id, titleNameStr.c_str(), "", knownStr, activeStr);
else
- handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->MaskID, titleNameStr, "", knownStr, activeStr);
+ handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->MaskID, titleNameStr.c_str(), "", knownStr, activeStr);
++counter;
}
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 87d521f67f8..f948869e838 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -1071,7 +1071,7 @@ public:
if (!px)
return false;
- uint32 graveyardId = uint32(atoi(px));
+ uint32 graveyardId = atoul(px);
uint32 team;
@@ -1541,15 +1541,15 @@ public:
char const* maxPureSkill = strtok(NULL, " ");
- int32 skill = atoi(skillStr);
- if (skill <= 0)
+ uint32 skill = atoul(skillStr);
+ if (skill == 0)
{
handler->PSendSysMessage(LANG_INVALID_SKILL_ID, skill);
handler->SetSentErrorMessage(true);
return false;
}
- int32 level = atol(levelStr);
+ uint32 level = atoul(levelStr);
Player* target = handler->getSelectedPlayerOrSelf();
if (!target)
@@ -1573,7 +1573,7 @@ public:
// the max level of the new profession.
uint16 max = maxPureSkill ? atoul(maxPureSkill) : targetHasSkill ? target->GetPureMaxSkillValue(skill) : uint16(level);
- if (level <= 0 || level > max || max <= 0)
+ if (level == 0 || level > max || max <= 0)
return false;
// If the player has the skill, we get the current skill step. If they don't have the skill, we
@@ -1642,8 +1642,8 @@ public:
* * Phases: %s - XIII. LANG_PINFO_CHR_PHASE (if not GM)
* * Money: %ug%us%uc - XIV. LANG_PINFO_CHR_MONEY
* * Map: %s, Area: %s - XV. LANG_PINFO_CHR_MAP
- * * Guild: %s (Id: %u) - XVI. LANG_PINFO_CHR_GUILD (if in guild)
- * ** Rank: %s - XVII. LANG_PINFO_CHR_GUILD_RANK (if in guild)
+ * * Guild: %s (Id: %s) - XVI. LANG_PINFO_CHR_GUILD (if in guild)
+ * ** Rank: %s, ID: %u - XVII. LANG_PINFO_CHR_GUILD_RANK (if in guild)
* ** Note: %s - XVIII.LANG_PINFO_CHR_GUILD_NOTE (if in guild and has note)
* ** O. Note: %s - XVIX. LANG_PINFO_CHR_GUILD_ONOTE (if in guild and has officer note)
* * Played time: %s - XX. LANG_PINFO_CHR_PLAYEDTIME
@@ -1942,7 +1942,7 @@ public:
// Output XVII. - XVIX. if they are not empty
if (!guildName.empty())
{
- handler->PSendSysMessage(LANG_PINFO_CHR_GUILD, guildName.c_str(), guildId);
+ handler->PSendSysMessage(LANG_PINFO_CHR_GUILD, guildName.c_str(), std::to_string(guildId).c_str());
handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_RANK, guildRank.c_str(), uint32(guildRankId));
if (!note.empty())
handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_NOTE, note.c_str());
@@ -2358,7 +2358,7 @@ public:
GameObject* go = handler->GetObjectFromPlayerMapByDbGuid(guidLow);
if (!go)
{
- handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow);
+ handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(guidLow).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -2371,7 +2371,7 @@ public:
}
go->ModifyHealth(-damage, player);
- handler->PSendSysMessage(LANG_GAMEOBJECT_DAMAGED, go->GetName().c_str(), guidLow, -damage, go->GetGOValue()->Building.Health);
+ handler->PSendSysMessage(LANG_GAMEOBJECT_DAMAGED, go->GetName().c_str(), std::to_string(guidLow).c_str(), -damage, go->GetGOValue()->Building.Health);
}
return true;
@@ -2706,7 +2706,7 @@ public:
if (!*args)
return false;
- uint32 soundId = atoi((char*)args);
+ uint32 soundId = atoul(args);
if (!sSoundKitStore.LookupEntry(soundId))
{
@@ -2783,7 +2783,7 @@ public:
}
Unit::AuraApplicationMap const& uAuras = target->GetAppliedAuras();
- handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, uAuras.size());
+ handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, std::to_string(uAuras.size()).c_str());
for (Unit::AuraApplicationMap::const_iterator itr = uAuras.begin(); itr != uAuras.end(); ++itr)
{
AuraApplication const* aurApp = itr->second;
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp
index e8d9d20f9a6..83733f2eef6 100644
--- a/src/server/scripts/Commands/cs_modify.cpp
+++ b/src/server/scripts/Commands/cs_modify.cpp
@@ -206,9 +206,6 @@ public:
//Edit Player Faction
static bool HandleModifyFactionCommand(ChatHandler* handler, const char* args)
{
- if (!*args)
- return false;
-
char* pfactionid = handler->extractKeyFromLink((char*)args, "Hfaction");
Creature* target = handler->getSelectedCreature();
@@ -225,18 +222,18 @@ public:
uint32 flag = target->GetUInt32Value(UNIT_FIELD_FLAGS);
uint64 npcflag = target->GetUInt64Value(UNIT_NPC_FLAGS);
uint32 dyflag = target->GetUInt32Value(OBJECT_DYNAMIC_FLAGS);
- handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUID().ToString().c_str(), factionid, flag, npcflag, dyflag);
+ handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUID().ToString().c_str(), factionid, flag, std::to_string(npcflag).c_str(), dyflag);
return true;
}
- uint32 factionid = atoi(pfactionid);
+ uint32 factionid = atoul(pfactionid);
uint32 flag;
char *pflag = strtok(NULL, " ");
if (!pflag)
flag = target->GetUInt32Value(UNIT_FIELD_FLAGS);
else
- flag = atoi(pflag);
+ flag = atoul(pflag);
char* pnpcflag = strtok(NULL, " ");
@@ -244,7 +241,7 @@ public:
if (!pnpcflag)
npcflag = target->GetUInt64Value(UNIT_NPC_FLAGS);
else
- npcflag = std::strtoull(pnpcflag, nullptr, 10);
+ npcflag = atoull(pnpcflag);
char* pdyflag = strtok(NULL, " ");
@@ -252,7 +249,7 @@ public:
if (!pdyflag)
dyflag = target->GetUInt32Value(OBJECT_DYNAMIC_FLAGS);
else
- dyflag = atoi(pdyflag);
+ dyflag = atoul(pdyflag);
if (!sFactionTemplateStore.LookupEntry(factionid))
{
@@ -261,7 +258,7 @@ public:
return false;
}
- handler->PSendSysMessage(LANG_YOU_CHANGE_FACTION, target->GetGUID().ToString().c_str(), factionid, flag, npcflag, dyflag);
+ handler->PSendSysMessage(LANG_YOU_CHANGE_FACTION, target->GetGUID().ToString().c_str(), factionid, flag, std::to_string(npcflag).c_str(), dyflag);
target->setFaction(factionid);
target->SetUInt32Value(UNIT_FIELD_FLAGS, flag);
@@ -790,7 +787,7 @@ public:
{
int64 newmoney = int64(targetMoney) + moneyToAdd;
- TC_LOG_DEBUG("misc", handler->GetTrinityString(LANG_CURRENT_MONEY), uint32(targetMoney), int32(moneyToAdd), uint32(newmoney));
+ TC_LOG_DEBUG("misc", handler->GetTrinityString(LANG_CURRENT_MONEY), std::to_string(targetMoney).c_str(), std::to_string(moneyToAdd).c_str(), std::to_string(newmoney).c_str());
if (newmoney <= 0)
{
NotifyModification(handler, target, LANG_YOU_TAKE_ALL_MONEY, LANG_YOURS_ALL_MONEY_GONE);
@@ -802,17 +799,17 @@ public:
if (newmoney > static_cast<int64>(MAX_MONEY_AMOUNT))
newmoney = MAX_MONEY_AMOUNT;
- handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, moneyToAddMsg, handler->GetNameLink(target).c_str());
+ handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, std::to_string(moneyToAddMsg).c_str(), handler->GetNameLink(target).c_str());
if (handler->needReportToTarget(target))
- ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), moneyToAddMsg);
+ ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), std::to_string(moneyToAddMsg).c_str());
target->SetMoney(newmoney);
}
}
else
{
- handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, uint32(moneyToAdd), handler->GetNameLink(target).c_str());
+ handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, std::to_string(moneyToAdd).c_str(), handler->GetNameLink(target).c_str());
if (handler->needReportToTarget(target))
- ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), uint32(moneyToAdd));
+ ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), std::to_string(moneyToAdd).c_str());
if (moneyToAdd >= int64(MAX_MONEY_AMOUNT))
moneyToAdd = MAX_MONEY_AMOUNT;
@@ -823,7 +820,7 @@ public:
target->ModifyMoney(moneyToAdd);
}
- TC_LOG_DEBUG("misc", handler->GetTrinityString(LANG_NEW_MONEY), uint32(targetMoney), int32(moneyToAdd), uint32(target->GetMoney()));
+ TC_LOG_DEBUG("misc", handler->GetTrinityString(LANG_NEW_MONEY), std::to_string(targetMoney).c_str(), std::to_string(moneyToAdd).c_str(), std::to_string(target->GetMoney()).c_str());
return true;
}
@@ -900,7 +897,7 @@ public:
if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
return false;
- int32 amount = (uint32)atoi(args);
+ int32 amount = atoi(args);
handler->PSendSysMessage("NOT IMPLEMENTED: %d honor NOT added.", amount);
@@ -1030,7 +1027,7 @@ public:
if (!*args)
return false;
- uint32 display_id = (uint32)atoi((char*)args);
+ uint32 display_id = atoul(args);
Unit* target = handler->getSelectedUnit();
if (!target)
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index a5238df6651..09b04004108 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -352,12 +352,10 @@ public:
return false;
}
- int32 item_int = atol(pitem);
- if (item_int <= 0)
+ uint32 itemId = atoull(pitem);
+ if (!itemId)
return false;
- uint32 itemId = item_int;
-
char* fmaxcount = strtok(nullptr, " "); //add maxcount, default: 0
uint32 maxcount = 0;
if (fmaxcount)
@@ -409,7 +407,7 @@ public:
CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid);
if (!data)
{
- handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowGuid);
+ handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, std::to_string(lowGuid).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -728,10 +726,10 @@ public:
std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);
- handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().ToString().c_str(), faction, npcflags, Entry, displayid, nativeid);
+ handler->PSendSysMessage(LANG_NPCINFO_CHAR, std::to_string(target->GetSpawnId()).c_str(), target->GetGUID().ToString().c_str(), faction, std::to_string(npcflags).c_str(), Entry, displayid, nativeid);
handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel());
handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, target->GetCurrentEquipmentId(), target->GetOriginalEquipmentId());
- handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
+ handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), std::to_string(target->GetMaxHealth()).c_str(), std::to_string(target->GetHealth()).c_str());
handler->PSendSysMessage(LANG_NPCINFO_INHABIT_TYPE, cInfo->InhabitType);
handler->PSendSysMessage(LANG_NPCINFO_UNIT_FIELD_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS));
@@ -825,7 +823,7 @@ public:
if (!creatureTemplate)
continue;
- handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, creatureTemplate->Name.c_str(), x, y, z, mapId);
+ handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, std::to_string(guid).c_str(), std::to_string(guid).c_str(), creatureTemplate->Name.c_str(), x, y, z, mapId);
++count;
}
@@ -857,7 +855,7 @@ public:
CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
if (!data)
{
- handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid);
+ handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, std::to_string(lowguid).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -866,7 +864,7 @@ public:
if (handler->GetSession()->GetPlayer()->GetMapId() != map_id)
{
- handler->PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, lowguid);
+ handler->PSendSysMessage(LANG_COMMAND_CREATUREATSAMEMAP, std::to_string(lowguid).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -1042,7 +1040,7 @@ public:
CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
if (!data)
{
- handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid);
+ handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, std::to_string(lowguid).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -1107,7 +1105,7 @@ public:
if (!*args)
return false;
- uint32 phaseGroupId = (uint32)atoi((char*)args);
+ int32 phaseGroupId = atoi(args);
Creature* creature = handler->getSelectedCreature();
if (!creature || creature->IsPet())
@@ -1123,7 +1121,7 @@ public:
creature->SetInPhase(id, false, true); // don't send update here for multiple phases, only send it once after adding all phases
creature->UpdateObjectVisibility();
- creature->SetDBPhase(-int(phaseGroupId));
+ creature->SetDBPhase(-phaseGroupId);
creature->SaveToDB();
@@ -1219,31 +1217,21 @@ public:
if (!stime)
return false;
- int spawnTime = atoi(stime);
-
- if (spawnTime < 0)
- {
- handler->SendSysMessage(LANG_BAD_VALUE);
- handler->SetSentErrorMessage(true);
- return false;
- }
+ uint32 spawnTime = atoul(stime);
Creature* creature = handler->getSelectedCreature();
- ObjectGuid::LowType guidLow = UI64LIT(0);
-
- if (creature)
- guidLow = creature->GetSpawnId();
- else
+ if (!creature)
return false;
- PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_SPAWN_TIME_SECS);
+ ObjectGuid::LowType guidLow = creature->GetSpawnId();
- stmt->setUInt32(0, uint32(spawnTime));
+ PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_SPAWN_TIME_SECS);
+ stmt->setUInt32(0, spawnTime);
stmt->setUInt64(1, guidLow);
WorldDatabase.Execute(stmt);
- creature->SetRespawnDelay((uint32)spawnTime);
+ creature->SetRespawnDelay(spawnTime);
handler->PSendSysMessage(LANG_COMMAND_SPAWNTIME, spawnTime);
return true;
diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp
index 7ebb01c8581..48a7106fc2d 100644
--- a/src/server/scripts/Commands/cs_reload.cpp
+++ b/src/server/scripts/Commands/cs_reload.cpp
@@ -432,7 +432,7 @@ public:
for (Tokenizer::const_iterator itr = entries.begin(); itr != entries.end(); ++itr)
{
- uint32 entry = uint32(atoi(*itr));
+ uint32 entry = atoul(*itr);
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_TEMPLATE);
stmt->setUInt32(0, entry);
diff --git a/src/server/scripts/Commands/cs_send.cpp b/src/server/scripts/Commands/cs_send.cpp
index 39d937dd003..2c36e856772 100644
--- a/src/server/scripts/Commands/cs_send.cpp
+++ b/src/server/scripts/Commands/cs_send.cpp
@@ -142,7 +142,7 @@ public:
char const* itemIdStr = strtok(itemStr, ":");
char const* itemCountStr = strtok(NULL, " ");
- uint32 itemId = atoi(itemIdStr);
+ uint32 itemId = atoul(itemIdStr);
if (!itemId)
return false;
diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp
index 5f794c59335..4ffc38b8b12 100644
--- a/src/server/scripts/Commands/cs_ticket.cpp
+++ b/src/server/scripts/Commands/cs_ticket.cpp
@@ -146,7 +146,7 @@ bool ticket_commandscript::HandleTicketAssignToCommand(ChatHandler* handler, cha
Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
if (player && ticket->IsAssignedNotTo(player->GetGUID()))
{
- handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId(), target.c_str());
+ handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId());
return true;
}
diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp
index 7f412569393..fb554b2f3f7 100644
--- a/src/server/scripts/Commands/cs_titles.cpp
+++ b/src/server/scripts/Commands/cs_titles.cpp
@@ -62,8 +62,8 @@ public:
if (!id_p)
return false;
- int32 id = atoi(id_p);
- if (id <= 0)
+ uint32 id = atoul(id_p);
+ if (id == 0)
{
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
handler->SetSentErrorMessage(true);
@@ -108,8 +108,8 @@ public:
if (!id_p)
return false;
- int32 id = atoi(id_p);
- if (id <= 0)
+ uint32 id = atoul(id_p);
+ if (id == 0)
{
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
handler->SetSentErrorMessage(true);
@@ -138,13 +138,13 @@ public:
std::string tNameLink = handler->GetNameLink(target);
- char titleNameStr[80];
- snprintf(titleNameStr, 80,
+ std::string titleNameStr = Trinity::StringFormat(
(target->getGender() == GENDER_MALE ? titleInfo->NameMale : titleInfo->NameFemale)->Str[handler->GetSessionDbcLocale()],
- target->GetName().c_str());
+ target->GetName().c_str()
+ );
target->SetTitle(titleInfo);
- handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str());
+ handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr.c_str(), tNameLink.c_str());
return true;
}
@@ -156,8 +156,8 @@ public:
if (!id_p)
return false;
- int32 id = atoi(id_p);
- if (id <= 0)
+ uint32 id = atoul(id_p);
+ if (id == 0)
{
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
handler->SetSentErrorMessage(true);
@@ -188,12 +188,12 @@ public:
std::string tNameLink = handler->GetNameLink(target);
- char titleNameStr[80];
- snprintf(titleNameStr, 80,
+ std::string titleNameStr = Trinity::StringFormat(
(target->getGender() == GENDER_MALE ? titleInfo->NameMale : titleInfo->NameFemale)->Str[handler->GetSessionDbcLocale()],
- target->GetName().c_str());
+ target->GetName().c_str()
+ );
- handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str());
+ handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr.c_str(), tNameLink.c_str());
if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
{
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index e64713b32b1..ff775189495 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -302,7 +302,7 @@ public:
if (show == "add")
{
if (arg_id)
- id = atoi(arg_id);
+ id = atoul(arg_id);
if (id)
{
@@ -344,7 +344,7 @@ public:
return true;
}
- id = atoi(arg_id);
+ id = atoul(arg_id);
uint32 a2, a3, a4, a5, a6;
float a8, a9, a10, a11;
@@ -389,7 +389,7 @@ public:
return true;
}
- id = atoi(arg_id);
+ id = atoul(arg_id);
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
stmt->setUInt32(0, id);
@@ -417,11 +417,11 @@ public:
return true;
}
- id = atoi(arg_id);
+ id = atoul(arg_id);
if (!id)
{
- handler->SendSysMessage("|cffff33ffERROR: No vallid waypoint script id not present.|r");
+ handler->SendSysMessage("|cffff33ffERROR: No valid waypoint script id not present.|r");
return true;
}
@@ -455,8 +455,8 @@ public:
if (arg_str_2 == "setid")
{
- uint32 newid = atoi(arg_3);
- handler->PSendSysMessage("%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r", "|cff00ff00", "Wp Event: Wypoint scipt guid: ", newid, " id changed: ", id);
+ uint32 newid = atoul(arg_3);
+ handler->PSendSysMessage("%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r", "|cff00ff00", "Wp Event: Waypoint script guid: ", newid, " id changed: ", id);
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_ID);
stmt->setUInt32(0, newid);
@@ -523,7 +523,7 @@ public:
}
else if (arg_str_2 == "dataint")
{
- WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", arg_2, atoi(arg_3), id); // Query can't be a prepared statement
+ WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", arg_2, atoul(arg_3), id); // Query can't be a prepared statement
handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id);
return true;
@@ -587,7 +587,7 @@ public:
if (!result)
{
- handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUID().ToString().c_str());
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, std::to_string(target->GetSpawnId()).c_str());
// Select waypoint number from database
// Since we compare float values, we have to deal with
// some difficulties.
@@ -607,7 +607,7 @@ public:
if (!result)
{
- handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetGUID().ToString().c_str());
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, std::to_string(target->GetSpawnId()).c_str());
return true;
}
}
@@ -780,7 +780,7 @@ public:
if (!result)
{
- handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetSpawnId());
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, std::to_string(target->GetSpawnId()).c_str());
return true;
}
@@ -839,7 +839,7 @@ public:
if (!creature)
{
- handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid);
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, std::to_string(wpguid).c_str());
hasError = true;
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
@@ -919,7 +919,7 @@ public:
if (show == "first")
{
- handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid);
+ handler->PSendSysMessage("|cff00ff00DEBUG: wp first, pathid: %u|r", pathid);
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID);
stmt->setUInt32(0, pathid);
@@ -1041,7 +1041,7 @@ public:
Creature* creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid);
if (!creature)
{
- handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, lowguid);
+ handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, std::to_string(lowguid).c_str());
hasError = true;
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);