aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2019-06-03 20:40:34 +0200
committerShauren <shauren.trinity@gmail.com>2019-06-08 17:06:57 +0200
commit455959c6064af6f7863a6b4b57cb0ef1646bd8ef (patch)
tree7d7a7cdd3a44643ee5fc7d19521ced1c8b815c66 /src/server/scripts/Commands
parent31fda79556e55375962a3c9e46f6dbdbf6e90d18 (diff)
Core/PacketIO: Rewrite updatefield handling
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_character.cpp4
-rw-r--r--src/server/scripts/Commands/cs_cheat.cpp4
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp270
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp35
-rw-r--r--src/server/scripts/Commands/cs_lookup.cpp2
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp22
-rw-r--r--src/server/scripts/Commands/cs_modify.cpp84
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp28
-rw-r--r--src/server/scripts/Commands/cs_pet.cpp8
-rw-r--r--src/server/scripts/Commands/cs_reset.cpp13
-rw-r--r--src/server/scripts/Commands/cs_titles.cpp12
11 files changed, 87 insertions, 395 deletions
diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp
index 2c9bde87d2c..9e3c199a638 100644
--- a/src/server/scripts/Commands/cs_character.cpp
+++ b/src/server/scripts/Commands/cs_character.cpp
@@ -235,7 +235,7 @@ public:
{
player->GiveLevel(newLevel);
player->InitTalentForLevel();
- player->SetUInt32Value(ACTIVE_PLAYER_FIELD_XP, 0);
+ player->SetXP(0);
if (handler->needReportToTarget(player))
{
@@ -281,7 +281,7 @@ public:
if (name.empty())
continue;
- char const* activeStr = target->GetInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->MaskID
+ char const* activeStr = *target->m_playerData->PlayerTitle == titleInfo->MaskID
? handler->GetTrinityString(LANG_ACTIVE)
: "";
diff --git a/src/server/scripts/Commands/cs_cheat.cpp b/src/server/scripts/Commands/cs_cheat.cpp
index 2c67db493c6..ae41ca54537 100644
--- a/src/server/scripts/Commands/cs_cheat.cpp
+++ b/src/server/scripts/Commands/cs_cheat.cpp
@@ -276,9 +276,9 @@ public:
for (uint16 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
{
if (flag != 0)
- handler->GetSession()->GetPlayer()->SetFlag(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES + i, 0xFFFFFFFF);
+ handler->GetSession()->GetPlayer()->AddExploredZones(i, 0xFFFFFFFFFFFFFFFF);
else
- handler->GetSession()->GetPlayer()->SetFlag(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES + i, 0);
+ handler->GetSession()->GetPlayer()->RemoveExploredZones(i, 0xFFFFFFFFFFFFFFFF);
}
return true;
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 60cf7bda4e7..edd69688e0e 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -77,7 +77,6 @@ public:
};
static std::vector<ChatCommand> debugCommandTable =
{
- { "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "" },
{ "threat", rbac::RBAC_PERM_COMMAND_DEBUG_THREAT, false, &HandleDebugThreatListCommand, "" },
{ "hostil", rbac::RBAC_PERM_COMMAND_DEBUG_HOSTIL, false, &HandleDebugHostileRefListCommand, "" },
{ "anim", rbac::RBAC_PERM_COMMAND_DEBUG_ANIM, false, &HandleDebugAnimCommand, "" },
@@ -85,19 +84,13 @@ public:
{ "bg", rbac::RBAC_PERM_COMMAND_DEBUG_BG, true, &HandleDebugBattlegroundCommand, "" },
{ "getitemstate", rbac::RBAC_PERM_COMMAND_DEBUG_GETITEMSTATE, false, &HandleDebugGetItemStateCommand, "" },
{ "lootrecipient", rbac::RBAC_PERM_COMMAND_DEBUG_LOOTRECIPIENT, false, &HandleDebugGetLootRecipientCommand, "" },
- { "getvalue", rbac::RBAC_PERM_COMMAND_DEBUG_GETVALUE, false, &HandleDebugGetValueCommand, "" },
- { "getitemvalue", rbac::RBAC_PERM_COMMAND_DEBUG_GETITEMVALUE, false, &HandleDebugGetItemValueCommand, "" },
- { "Mod32Value", rbac::RBAC_PERM_COMMAND_DEBUG_MOD32VALUE, false, &HandleDebugMod32ValueCommand, "" },
{ "play", rbac::RBAC_PERM_COMMAND_DEBUG_PLAY, false, nullptr, "", debugPlayCommandTable },
{ "send", rbac::RBAC_PERM_COMMAND_DEBUG_SEND, false, nullptr, "", debugSendCommandTable },
{ "setaurastate", rbac::RBAC_PERM_COMMAND_DEBUG_SETAURASTATE, false, &HandleDebugSetAuraStateCommand, "" },
- { "setitemvalue", rbac::RBAC_PERM_COMMAND_DEBUG_SETITEMVALUE, false, &HandleDebugSetItemValueCommand, "" },
- { "setvalue", rbac::RBAC_PERM_COMMAND_DEBUG_SETVALUE, false, &HandleDebugSetValueCommand, "" },
{ "spawnvehicle", rbac::RBAC_PERM_COMMAND_DEBUG_SPAWNVEHICLE, false, &HandleDebugSpawnVehicleCommand, "" },
{ "setvid", rbac::RBAC_PERM_COMMAND_DEBUG_SETVID, false, &HandleDebugSetVehicleIdCommand, "" },
{ "entervehicle", rbac::RBAC_PERM_COMMAND_DEBUG_ENTERVEHICLE, false, &HandleDebugEnterVehicleCommand, "" },
{ "uws", rbac::RBAC_PERM_COMMAND_DEBUG_UWS, false, &HandleDebugUpdateWorldStateCommand, "" },
- { "update", rbac::RBAC_PERM_COMMAND_DEBUG_UPDATE, false, &HandleDebugUpdateCommand, "" },
{ "itemexpire", rbac::RBAC_PERM_COMMAND_DEBUG_ITEMEXPIRE, false, &HandleDebugItemExpireCommand, "" },
{ "areatriggers", rbac::RBAC_PERM_COMMAND_DEBUG_AREATRIGGERS, false, &HandleDebugAreaTriggersCommand, "" },
{ "los", rbac::RBAC_PERM_COMMAND_DEBUG_LOS, false, &HandleDebugLoSCommand, "" },
@@ -991,64 +984,6 @@ public:
return true;
}
- static bool HandleDebugGetItemValueCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- char* e = strtok((char*)args, " ");
- char* f = strtok(NULL, " ");
-
- if (!e || !f)
- return false;
-
- ObjectGuid::LowType guid = strtoull(e, nullptr, 10);
- uint32 index = atoul(f);
-
- Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
-
- if (!i)
- return false;
-
- if (index >= i->GetValuesCount())
- return false;
-
- uint32 value = i->GetUInt32Value(index);
-
- handler->PSendSysMessage("Item " UI64FMTD ": value at %u is %u", guid, index, value);
-
- return true;
- }
-
- static bool HandleDebugSetItemValueCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- char* e = strtok((char*)args, " ");
- char* f = strtok(NULL, " ");
- char* g = strtok(NULL, " ");
-
- if (!e || !f || !g)
- return false;
-
- ObjectGuid::LowType guid = strtoull(e, nullptr, 10);
- uint32 index = atoul(f);
- uint32 value = atoul(g);
-
- Item* i = handler->GetSession()->GetPlayer()->GetItemByGuid(ObjectGuid::Create<HighGuid::Item>(guid));
-
- if (!i)
- return false;
-
- if (index >= i->GetValuesCount())
- return false;
-
- i->SetUInt32Value(index, value);
-
- return true;
- }
-
static bool HandleDebugItemExpireCommand(ChatHandler* handler, char const* args)
{
if (!*args)
@@ -1120,211 +1055,6 @@ public:
return true;
}
- static bool HandleDebugSetValueCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- char* x = strtok((char*)args, " ");
- char* y = strtok(NULL, " ");
- char* z = strtok(NULL, " ");
-
- if (!x || !y)
- return false;
-
- WorldObject* target = handler->getSelectedObject();
- if (!target)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- ObjectGuid guid = target->GetGUID();
-
- uint32 field = atoul(x);
- if (field >= target->GetValuesCount())
- {
- handler->PSendSysMessage(LANG_TOO_BIG_INDEX, field, guid.ToString().c_str(), target->GetValuesCount());
- return false;
- }
-
- bool isInt32 = true;
- if (z)
- isInt32 = atoi(z) != 0;
-
- if (isInt32)
- {
- uint32 value = atoul(y);
- target->SetUInt32Value(field, value);
- handler->PSendSysMessage(LANG_SET_UINT_FIELD, guid.ToString().c_str(), field, value);
- }
- else
- {
- float value = (float)atof(y);
- target->SetFloatValue(field, value);
- handler->PSendSysMessage(LANG_SET_FLOAT_FIELD, guid.ToString().c_str(), field, value);
- }
-
- return true;
- }
-
- static bool HandleDebugGetValueCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- char* x = strtok((char*)args, " ");
- char* z = strtok(NULL, " ");
-
- if (!x)
- return false;
-
- Unit* target = handler->getSelectedUnit();
- if (!target)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- ObjectGuid guid = target->GetGUID();
-
- uint32 opcode = atoul(x);
- if (opcode >= target->GetValuesCount())
- {
- handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, guid.ToString().c_str(), target->GetValuesCount());
- return false;
- }
-
- bool isInt32 = true;
- if (z)
- isInt32 = atoi(z) != 0;
-
- if (isInt32)
- {
- uint32 value = target->GetUInt32Value(opcode);
- handler->PSendSysMessage(LANG_GET_UINT_FIELD, guid.ToString().c_str(), opcode, value);
- }
- else
- {
- float value = target->GetFloatValue(opcode);
- handler->PSendSysMessage(LANG_GET_FLOAT_FIELD, guid.ToString().c_str(), opcode, value);
- }
-
- return true;
- }
-
- static bool HandleDebugMod32ValueCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- char* x = strtok((char*)args, " ");
- char* y = strtok(NULL, " ");
-
- if (!x || !y)
- return false;
-
- uint32 opcode = atoul(x);
- int value = atoi(y);
-
- if (opcode >= handler->GetSession()->GetPlayer()->GetValuesCount())
- {
- handler->PSendSysMessage(LANG_TOO_BIG_INDEX, opcode, handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str(), handler->GetSession()->GetPlayer()->GetValuesCount());
- return false;
- }
-
- uint32 currentValue = handler->GetSession()->GetPlayer()->GetUInt32Value(opcode);
-
- currentValue += value;
- handler->GetSession()->GetPlayer()->SetUInt32Value(opcode, currentValue);
-
- handler->PSendSysMessage(LANG_CHANGE_32BIT_FIELD, opcode, currentValue);
-
- return true;
- }
-
- static bool HandleDebugUpdateCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- uint32 updateIndex;
- uint32 value;
-
- char* index = strtok((char*)args, " ");
-
- Unit* unit = handler->getSelectedUnit();
- if (!unit)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (!index)
- return true;
-
- updateIndex = atoi(index);
- //check updateIndex
- if (unit->GetTypeId() == TYPEID_PLAYER)
- {
- if (updateIndex >= PLAYER_END)
- return true;
- }
- else if (updateIndex >= UNIT_END)
- return true;
-
- char* val = strtok(NULL, " ");
- if (!val)
- {
- value = unit->GetUInt32Value(updateIndex);
-
- handler->PSendSysMessage(LANG_UPDATE, unit->GetGUID().ToString().c_str(), updateIndex, value);
- return true;
- }
-
- value = atoi(val);
-
- handler->PSendSysMessage(LANG_UPDATE_CHANGE, unit->GetGUID().ToString().c_str(), updateIndex, value);
-
- unit->SetUInt32Value(updateIndex, value);
-
- return true;
- }
-
- static bool HandleDebugSet32BitCommand(ChatHandler* handler, char const* args)
- {
- if (!*args)
- return false;
-
- WorldObject* target = handler->getSelectedObject();
- if (!target)
- {
- handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- char* x = strtok((char*)args, " ");
- char* y = strtok(NULL, " ");
-
- if (!x || !y)
- return false;
-
- uint32 opcode = atoul(x);
- uint32 val = atoul(y);
- if (val > 32) //uint32 = 32 bits
- return false;
-
- uint32 value = val ? 1 << (val - 1) : 0;
- target->SetUInt32Value(opcode, value);
-
- handler->PSendSysMessage(LANG_SET_32BIT_FIELD, opcode, value);
- return true;
- }
-
static bool HandleDebugMoveflagsCommand(ChatHandler* handler, char const* args)
{
Unit* target = handler->getSelectedUnit();
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index b60b957cc17..3293c6cb9d7 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -674,16 +674,31 @@ public:
int32 objectState = atoi(state);
- if (objectType < 4)
- object->SetByteValue(GAMEOBJECT_BYTES_1, uint8(objectType), uint8(objectState));
- else if (objectType == 4)
- object->SendCustomAnim(objectState);
- else if (objectType == 5)
- {
- if (objectState < 0 || objectState > GO_DESTRUCTIBLE_REBUILDING)
- return false;
-
- object->SetDestructibleState(GameObjectDestructibleState(objectState));
+ switch (objectType)
+ {
+ case 0:
+ object->SetGoState(GOState(objectState));
+ break;
+ case 1:
+ object->SetGoType(GameobjectTypes(objectState));
+ break;
+ case 2:
+ object->SetGoArtKit(objectState);
+ break;
+ case 3:
+ object->SetGoAnimProgress(objectState);
+ break;
+ case 4:
+ object->SendCustomAnim(objectState);
+ break;
+ case 5:
+ if (objectState < 0 || objectState > GO_DESTRUCTIBLE_REBUILDING)
+ return false;
+
+ object->SetDestructibleState(GameObjectDestructibleState(objectState));
+ break;
+ default:
+ break;
}
handler->PSendSysMessage("Set gobject type %d state %d", objectType, objectState);
diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp
index 0f89fa23ded..c9a8a70127b 100644
--- a/src/server/scripts/Commands/cs_lookup.cpp
+++ b/src/server/scripts/Commands/cs_lookup.cpp
@@ -1174,7 +1174,7 @@ public:
char const* knownStr = target && target->HasTitle(titleInfo) ? handler->GetTrinityString(LANG_KNOWN) : "";
- char const* activeStr = target && target->GetInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->MaskID
+ char const* activeStr = target && *target->m_playerData->PlayerTitle == titleInfo->MaskID
? handler->GetTrinityString(LANG_ACTIVE)
: "";
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 56b7071a8a8..3a87ac318a0 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -156,7 +156,7 @@ public:
{
if (!*args)
{
- if (handler->GetSession()->GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER))
+ if (handler->GetSession()->GetPlayer()->HasPlayerFlag(PLAYER_FLAGS_DEVELOPER))
handler->GetSession()->SendNotification(LANG_DEV_ON);
else
handler->GetSession()->SendNotification(LANG_DEV_OFF);
@@ -167,14 +167,14 @@ public:
if (argstr == "on")
{
- handler->GetSession()->GetPlayer()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
+ handler->GetSession()->GetPlayer()->AddPlayerFlag(PLAYER_FLAGS_DEVELOPER);
handler->GetSession()->SendNotification(LANG_DEV_ON);
return true;
}
if (argstr == "off")
{
- handler->GetSession()->GetPlayer()->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
+ handler->GetSession()->GetPlayer()->RemovePlayerFlag(PLAYER_FLAGS_DEVELOPER);
handler->GetSession()->SendNotification(LANG_DEV_OFF);
return true;
}
@@ -1195,7 +1195,7 @@ public:
return false;
}
- int32 offset = area->AreaBit / 32;
+ uint32 offset = area->AreaBit / 64;
if (offset >= PLAYER_EXPLORED_ZONES_SIZE)
{
handler->SendSysMessage(LANG_BAD_VALUE);
@@ -1203,9 +1203,8 @@ public:
return false;
}
- uint32 val = uint32((1 << (area->AreaBit % 32)));
- uint32 currFields = playerTarget->GetUInt32Value(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES + offset);
- playerTarget->SetUInt32Value(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES + offset, uint32((currFields | val)));
+ uint64 val = UI64LIT(1) << (area->AreaBit % 64);
+ playerTarget->AddExploredZones(offset, val);
handler->SendSysMessage(LANG_EXPLORE_AREA);
return true;
@@ -1239,7 +1238,7 @@ public:
return false;
}
- int32 offset = area->AreaBit / 32;
+ uint32 offset = area->AreaBit / 64;
if (offset >= PLAYER_EXPLORED_ZONES_SIZE)
{
handler->SendSysMessage(LANG_BAD_VALUE);
@@ -1247,9 +1246,8 @@ public:
return false;
}
- uint32 val = uint32((1 << (area->AreaBit % 32)));
- uint32 currFields = playerTarget->GetUInt32Value(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES + offset);
- playerTarget->SetUInt32Value(ACTIVE_PLAYER_FIELD_EXPLORED_ZONES + offset, uint32((currFields ^ val)));
+ uint64 val = UI64LIT(1) << (area->AreaBit % 64);
+ playerTarget->RemoveExploredZones(offset, val);
handler->SendSysMessage(LANG_UNEXPLORE_AREA);
return true;
@@ -1712,7 +1710,7 @@ public:
mapId = target->GetMapId();
areaId = target->GetAreaId();
alive = target->IsAlive() ? handler->GetTrinityString(LANG_YES) : handler->GetTrinityString(LANG_NO);
- gender = target->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER);
+ gender = target->m_playerData->NativeSex;
}
// get additional information from DB
else
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp
index b444c806f2f..0b113206f48 100644
--- a/src/server/scripts/Commands/cs_modify.cpp
+++ b/src/server/scripts/Commands/cs_modify.cpp
@@ -54,7 +54,6 @@ public:
};
static std::vector<ChatCommand> modifyCommandTable =
{
- { "bit", rbac::RBAC_PERM_COMMAND_MODIFY_BIT, false, &HandleModifyBitCommand, "" },
{ "currency", rbac::RBAC_PERM_COMMAND_MODIFY_CURRENCY, false, &HandleModifyCurrencyCommand, "" },
{ "drunk", rbac::RBAC_PERM_COMMAND_MODIFY_DRUNK, false, &HandleModifyDrunkCommand, "" },
{ "energy", rbac::RBAC_PERM_COMMAND_MODIFY_ENERGY, false, &HandleModifyEnergyCommand, "" },
@@ -220,9 +219,10 @@ public:
if (!pfactionid)
{
uint32 factionid = target->getFaction();
- uint32 flag = target->GetUInt32Value(UNIT_FIELD_FLAGS);
- uint64 npcflag = target->GetUInt64Value(UNIT_NPC_FLAGS);
- uint32 dyflag = target->GetUInt32Value(OBJECT_DYNAMIC_FLAGS);
+ uint32 flag = target->m_unitData->Flags;
+ uint64 npcflag;
+ memcpy(&npcflag, target->m_unitData->NpcFlags.begin(), sizeof(uint64));
+ uint32 dyflag = target->m_objectData->DynamicFlags;
handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUID().ToString().c_str(), factionid, flag, std::to_string(npcflag).c_str(), dyflag);
return true;
}
@@ -232,7 +232,7 @@ public:
char *pflag = strtok(NULL, " ");
if (!pflag)
- flag = target->GetUInt32Value(UNIT_FIELD_FLAGS);
+ flag = target->m_unitData->Flags;
else
flag = atoul(pflag);
@@ -240,7 +240,7 @@ public:
uint64 npcflag;
if (!pnpcflag)
- npcflag = target->GetUInt64Value(UNIT_NPC_FLAGS);
+ memcpy(&npcflag, target->m_unitData->NpcFlags.begin(), sizeof(uint64));
else
npcflag = atoull(pnpcflag);
@@ -248,7 +248,7 @@ public:
uint32 dyflag;
if (!pdyflag)
- dyflag = target->GetUInt32Value(OBJECT_DYNAMIC_FLAGS);
+ dyflag = target->m_objectData->DynamicFlags;
else
dyflag = atoul(pdyflag);
@@ -262,9 +262,10 @@ public:
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);
- target->SetUInt64Value(UNIT_NPC_FLAGS, npcflag);
- target->SetUInt32Value(OBJECT_DYNAMIC_FLAGS, dyflag);
+ target->SetUnitFlags(UnitFlags(flag));
+ target->SetNpcFlags(NPCFlags(npcflag & 0xFFFFFFFF));
+ target->SetNpcFlags2(NPCFlags2(npcflag >> 32));
+ target->SetDynamicFlags(dyflag);
return true;
}
@@ -494,7 +495,7 @@ public:
{
NotifyModification(handler, target, LANG_YOU_CHANGE_SIZE, LANG_YOURS_SIZE_CHANGED, Scale);
if (Creature* creatureTarget = target->ToCreature())
- creatureTarget->SetFloatValue(UNIT_FIELD_DISPLAY_SCALE, Scale);
+ creatureTarget->SetDisplayId(creatureTarget->GetDisplayId(), Scale);
else
target->SetObjectScale(Scale);
return true;
@@ -612,61 +613,6 @@ public:
return true;
}
- //Edit Unit field
- static bool HandleModifyBitCommand(ChatHandler* handler, const char* args)
- {
- if (!*args)
- return false;
-
- Unit* target = handler->getSelectedUnit();
- if (!target)
- {
- handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- // check online security
- if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity(target->ToPlayer(), ObjectGuid::Empty))
- return false;
-
- char* pField = strtok((char*)args, " ");
- if (!pField)
- return false;
-
- char* pBit = strtok(NULL, " ");
- if (!pBit)
- return false;
-
- uint16 field = atoi(pField);
- uint32 bit = atoi(pBit);
-
- if (field < OBJECT_END || field >= target->GetValuesCount())
- {
- handler->SendSysMessage(LANG_BAD_VALUE);
- handler->SetSentErrorMessage(true);
- return false;
- }
- if (bit < 1 || bit > 32)
- {
- handler->SendSysMessage(LANG_BAD_VALUE);
- handler->SetSentErrorMessage(true);
- return false;
- }
-
- if (target->HasFlag(field, (1<<(bit-1))))
- {
- target->RemoveFlag(field, (1<<(bit-1)));
- handler->PSendSysMessage(LANG_REMOVE_BIT, bit, field);
- }
- else
- {
- target->SetFlag(field, (1<<(bit-1)));
- handler->PSendSysMessage(LANG_SET_BIT, bit, field);
- }
- return true;
- }
-
static bool HandleModifyHonorCommand(ChatHandler* handler, const char* args)
{
if (!*args)
@@ -889,7 +835,7 @@ public:
return false;
uint32 anim_id = atoi((char*)args);
- handler->GetSession()->GetPlayer()->SetUInt32Value(UNIT_NPC_EMOTESTATE, anim_id);
+ handler->GetSession()->GetPlayer()->SetEmoteState(Emote(anim_id));
return true;
}
@@ -939,8 +885,8 @@ public:
}
// Set gender
- target->SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, gender);
- target->SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER, gender);
+ target->SetGender(gender);
+ target->SetNativeSex(gender);
// Change display ID
target->InitDisplayIds();
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index 49d7b18b393..129053e2f88 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -642,7 +642,10 @@ public:
return false;
}
- creature->SetUInt64Value(UNIT_NPC_FLAGS, npcFlags);
+ uint32 raw[2];
+ memcpy(raw, &npcFlags, sizeof(raw));
+ creature->SetNpcFlags(NPCFlags(raw[0]));
+ creature->SetNpcFlags2(NPCFlags2(raw[1]));
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_NPCFLAG);
@@ -723,7 +726,8 @@ public:
CreatureTemplate const* cInfo = target->GetCreatureTemplate();
uint32 faction = target->getFaction();
- uint64 npcflags = target->GetUInt64Value(UNIT_NPC_FLAGS);
+ uint64 npcflags;
+ memcpy(&npcflags, target->m_unitData->NpcFlags.begin(), sizeof(npcflags));
uint32 mechanicImmuneMask = cInfo->MechanicImmuneMask;
uint32 displayid = target->GetDisplayId();
uint32 nativeid = target->GetNativeDisplayId();
@@ -741,22 +745,22 @@ public:
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));
+ handler->PSendSysMessage(LANG_NPCINFO_UNIT_FIELD_FLAGS, *target->m_unitData->Flags);
for (uint8 i = 0; i < MAX_UNIT_FLAGS; ++i)
- if (target->GetUInt32Value(UNIT_FIELD_FLAGS) & unitFlags[i].Value)
+ if (target->HasUnitFlag(unitFlags[i].Value))
handler->PSendSysMessage("%s (0x%X)", unitFlags[i].Name, unitFlags[i].Value);
- handler->PSendSysMessage(LANG_NPCINFO_UNIT_FIELD_FLAGS_2, target->GetUInt32Value(UNIT_FIELD_FLAGS_2));
+ handler->PSendSysMessage(LANG_NPCINFO_UNIT_FIELD_FLAGS_2, *target->m_unitData->Flags2);
for (uint8 i = 0; i < MAX_UNIT_FLAGS_2; ++i)
- if (target->GetUInt32Value(UNIT_FIELD_FLAGS_2) & unitFlags2[i].Value)
+ if (target->HasUnitFlag2(unitFlags2[i].Value))
handler->PSendSysMessage("%s (0x%X)", unitFlags2[i].Name, unitFlags2[i].Value);
- handler->PSendSysMessage(LANG_NPCINFO_UNIT_FIELD_FLAGS_3, target->GetUInt32Value(UNIT_FIELD_FLAGS_3));
+ handler->PSendSysMessage(LANG_NPCINFO_UNIT_FIELD_FLAGS_3, *target->m_unitData->Flags3);
for (uint8 i = 0; i < MAX_UNIT_FLAGS_3; ++i)
- if (target->GetUInt32Value(UNIT_FIELD_FLAGS_3) & unitFlags3[i].Value)
+ if (target->HasUnitFlag3(unitFlags3[i].Value))
handler->PSendSysMessage("%s (0x%X)", unitFlags3[i].Name, unitFlags3[i].Value);
- handler->PSendSysMessage(LANG_NPCINFO_DYNAMIC_FLAGS, target->GetUInt32Value(OBJECT_DYNAMIC_FLAGS));
+ handler->PSendSysMessage(LANG_NPCINFO_DYNAMIC_FLAGS, target->GetDynamicFlags());
handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str());
handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId);
handler->PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId());
@@ -923,7 +927,7 @@ public:
return false;
}
- target->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote);
+ target->SetEmoteState(Emote(emote));
return true;
}
@@ -1463,13 +1467,13 @@ public:
uint8 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel();
// prepare visual effect for levelup
- pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1);
+ pet->SetLevel(level - 1);
// add to world
pet->GetMap()->AddToMap(pet->ToCreature());
// visual effect for levelup
- pet->SetUInt32Value(UNIT_FIELD_LEVEL, level);
+ pet->SetLevel(level);
// caster have pet now
player->SetMinion(pet, true);
diff --git a/src/server/scripts/Commands/cs_pet.cpp b/src/server/scripts/Commands/cs_pet.cpp
index 565998c4fac..37484bba405 100644
--- a/src/server/scripts/Commands/cs_pet.cpp
+++ b/src/server/scripts/Commands/cs_pet.cpp
@@ -102,8 +102,8 @@ public:
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
- pet->SetGuidValue(UNIT_FIELD_CREATEDBY, player->GetGUID());
- pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
+ pet->SetCreatorGUID(player->GetGUID());
+ pet->setFaction(player->getFaction());
if (!pet->InitStatsForLevel(creatureTarget->getLevel()))
{
@@ -114,7 +114,7 @@ public:
}
// prepare visual effect for levelup
- pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()-1);
+ pet->SetLevel(creatureTarget->getLevel() - 1);
pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
// this enables pet details window (Shift+P)
@@ -124,7 +124,7 @@ public:
pet->GetMap()->AddToMap(pet->ToCreature());
// visual effect for levelup
- pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel());
+ pet->SetLevel(creatureTarget->getLevel());
player->SetMinion(pet, true);
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp
index 5162a186add..f8ae4589612 100644
--- a/src/server/scripts/Commands/cs_reset.cpp
+++ b/src/server/scripts/Commands/cs_reset.cpp
@@ -83,8 +83,7 @@ public:
if (!handler->extractPlayerTarget((char*)args, &target))
return false;
- target->SetUInt32Value(ACTIVE_PLAYER_FIELD_KILLS, 0);
- target->SetUInt32Value(ACTIVE_PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, 0);
+ target->ResetHonorStats();
target->UpdateCriteria(CRITERIA_TYPE_EARN_HONORABLE_KILL);
return true;
@@ -106,18 +105,18 @@ public:
player->SetShapeshiftForm(FORM_NONE);
player->setFactionForRace(player->getRace());
- player->SetUInt32Value(UNIT_FIELD_DISPLAY_POWER, powerType);
+ player->SetPowerType(Powers(powerType));
// reset only if player not in some form;
if (player->GetShapeshiftForm() == FORM_NONE)
player->InitDisplayIds();
- player->SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_PVP_FLAG, UNIT_BYTE2_FLAG_PVP);
+ player->SetPvpFlags(UNIT_BYTE2_FLAG_PVP);
- player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
+ player->SetUnitFlags(UNIT_FLAG_PVP_ATTACKABLE);
//-1 is default value
- player->SetUInt32Value(ACTIVE_PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1));
+ player->SetWatchedFactionIndex(-1);
return true;
}
@@ -143,7 +142,7 @@ public:
target->InitStatsForLevel(true);
target->InitTaxiNodesForLevel();
target->InitTalentForLevel();
- target->SetUInt32Value(ACTIVE_PLAYER_FIELD_XP, 0);
+ target->SetXP(0);
target->_ApplyAllLevelScaleItemMods(true);
diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp
index 1b315cc4bf1..197c31bd51c 100644
--- a/src/server/scripts/Commands/cs_titles.cpp
+++ b/src/server/scripts/Commands/cs_titles.cpp
@@ -93,7 +93,7 @@ public:
std::string tNameLink = handler->GetNameLink(target);
target->SetTitle(titleInfo); // to be sure that title now known
- target->SetUInt32Value(PLAYER_CHOSEN_TITLE, titleInfo->MaskID);
+ target->SetChosenTitle(titleInfo->MaskID);
handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, id,
(target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[handler->GetSessionDbcLocale()],
@@ -195,9 +195,9 @@ public:
handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr.c_str(), tNameLink.c_str());
- if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
+ if (!target->HasTitle(target->m_playerData->PlayerTitle))
{
- target->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
+ target->SetChosenTitle(0);
handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str());
}
@@ -234,12 +234,12 @@ public:
titles &= ~titles2; // remove non-existing titles
- target->SetUInt64Value(ACTIVE_PLAYER_FIELD_KNOWN_TITLES, titles);
+ target->SetKnownTitles(0, titles);
handler->SendSysMessage(LANG_DONE);
- if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
+ if (!target->HasTitle(target->m_playerData->PlayerTitle))
{
- target->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
+ target->SetChosenTitle(0);
handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, handler->GetNameLink(target).c_str());
}