diff options
| author | Rochet2 <rochet2@post.com> | 2017-01-08 05:55:22 +0200 |
|---|---|---|
| committer | tkrokli <tkrokli@users.noreply.github.com> | 2017-01-08 04:55:22 +0100 |
| commit | 117d1c31c99b00269fa73d50d1a5ccf7c49a8450 (patch) | |
| tree | 59c0ffa808fd374603017143bb99835ebcbba129 /src/server/scripts | |
| parent | 3d245fb2dc40d89ecfbe9f924ef9d3d16bc02cda (diff) | |
Scripts/Commands: Fix guid usage and enhance commands (#18278)
- Fix targeting gameobjects and creatures for .dist and .gps. The old code used DB guid to search from core generated guid lists.
- Fix some error messages saying 'no player found' even if creatures and gameobjects and players were searched
- Change atoi to atoul when receiving lowguids as string or other uint32 values
- Use ObjectGuid::LowType instead of uint32 for lowguid type
- Allow .gob info to take in gameobject guid link as well as entry link in addition to gameobject entry and update the documentation of the command
- Change .gob delete to post the spawnid (dbguid) instead of the ingame generated guid (which is basically never seen or used by the player in any other commands that I see)
- Allow spawntimesecs to be negative when spawning a gameobject
- Disable searching by ingame spawn id in commands. (it makes little sense for a user to provide a number which is then attempted to be used as DB guid and non DB guid when both could have a match)
- Update .gob turn documentation to tell about possibility to provide orientation in command
- Correct the types in .gob add command result trinity_string
- Correct the creature search for .npc del
- Change .event to .event info
- Add .go offset command
- Remove the .go command for empty string (no subcommand given) because it just used .go xyz
- Extend .gob info to show size, faction, flags and model dimensions
- Remove some unnecessary casts
- Document .wp show better (first and last were not documented)
- Insert spawnid to .wp show info error message
- Fix spawntime printing for .gobject target
- Fix guid targetting for .npc set movetype
- Fix query by spawnid for .wp show info
- Fix deleting of existing waypoints when twice doing the command .wp show on
- Fix deleting of existing waypoints when doing the command .wp show off
- Change wpguid column in DB and in core to uint32, which is what the spawnid type is in core and db.
Diffstat (limited to 'src/server/scripts')
| -rw-r--r-- | src/server/scripts/Commands/cs_achievement.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_event.cpp | 8 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_go.cpp | 74 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_gobject.cpp | 101 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 121 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_npc.cpp | 38 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_wp.cpp | 19 |
7 files changed, 226 insertions, 137 deletions
diff --git a/src/server/scripts/Commands/cs_achievement.cpp b/src/server/scripts/Commands/cs_achievement.cpp index 6e7499972ec..ddfd35e17e4 100644 --- a/src/server/scripts/Commands/cs_achievement.cpp +++ b/src/server/scripts/Commands/cs_achievement.cpp @@ -55,7 +55,7 @@ public: if (!achievementId) { if (char* id = handler->extractKeyFromLink((char*)args, "Hachievement")) - achievementId = atoi(id); + achievementId = atoul(id); if (!achievementId) return false; } diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index c24f6ccadf0..05b49f9b4e7 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -40,7 +40,7 @@ public: { "activelist", rbac::RBAC_PERM_COMMAND_EVENT_ACTIVELIST, true, &HandleEventActiveListCommand, "" }, { "start", rbac::RBAC_PERM_COMMAND_EVENT_START, true, &HandleEventStartCommand, "" }, { "stop", rbac::RBAC_PERM_COMMAND_EVENT_STOP, true, &HandleEventStopCommand, "" }, - { "", rbac::RBAC_PERM_COMMAND_EVENT, true, &HandleEventInfoCommand, "" }, + { "info", rbac::RBAC_PERM_COMMAND_EVENT, true, &HandleEventInfoCommand, "" }, }; static std::vector<ChatCommand> commandTable = { @@ -88,7 +88,7 @@ public: if (!id) return false; - uint32 eventId = atoi(id); + uint32 eventId = atoul(id); GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); @@ -137,7 +137,7 @@ public: if (!id) return false; - int32 eventId = atoi(id); + uint32 eventId = atoul(id); GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); @@ -178,7 +178,7 @@ public: if (!id) return false; - int32 eventId = atoi(id); + uint32 eventId = atoul(id); GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index 3d5b4d4ff03..cdeb07ee844 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -49,7 +49,7 @@ public: { "zonexy", rbac::RBAC_PERM_COMMAND_GO_ZONEXY, false, &HandleGoZoneXYCommand, "" }, { "xyz", rbac::RBAC_PERM_COMMAND_GO_XYZ, false, &HandleGoXYZCommand, "" }, { "ticket", rbac::RBAC_PERM_COMMAND_GO_TICKET, false, &HandleGoTicketCommand, "" }, - { "", rbac::RBAC_PERM_COMMAND_GO, false, &HandleGoXYZCommand, "" }, + { "offset", rbac::RBAC_PERM_COMMAND_GO_OFFSET, false, &HandleGoOffsetCommand, "" }, }; static std::vector<ChatCommand> commandTable = @@ -96,7 +96,7 @@ public: if (!id) return false; - int32 entry = atoi(id); + uint32 entry = atoul(id); if (!entry) return false; @@ -104,17 +104,17 @@ public: } else { - int32 guid = atoi(param1); + ObjectGuid::LowType guidLow = atoul(param1); // Number is invalid - maybe the user specified the mob's name - if (!guid) + if (!guidLow) { std::string name = param1; WorldDatabase.EscapeString(name); whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name " _LIKE_" '" << name << '\''; } else - whereClause << "WHERE guid = '" << guid << '\''; + whereClause << "WHERE guid = '" << guidLow << '\''; } QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map, guid, id FROM creature %s", whereClause.str().c_str()); @@ -172,7 +172,7 @@ public: if (!gyId) return false; - int32 graveyardId = atoi(gyId); + uint32 graveyardId = atoul(gyId); if (!graveyardId) return false; @@ -221,7 +221,7 @@ public: if (!gridX || !gridY) return false; - uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId(); + uint32 mapId = id ? atoul(id) : player->GetMapId(); // center of grid float x = ((float)atof(gridX) - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS; @@ -264,15 +264,15 @@ public: if (!id) return false; - int32 guid = atoi(id); - if (!guid) + ObjectGuid::LowType guidLow = atoul(id); + if (!guidLow) return false; float x, y, z, o; uint32 mapId; // by DB guid - if (GameObjectData const* goData = sObjectMgr->GetGOData(guid)) + if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow)) { x = goData->posX; y = goData->posY; @@ -319,7 +319,7 @@ public: if (!id) return false; - int32 nodeId = atoi(id); + uint32 nodeId = atoul(id); if (!nodeId) return false; @@ -364,7 +364,7 @@ public: if (!id) return false; - int32 areaTriggerId = atoi(id); + uint32 areaTriggerId = atoul(id); if (!areaTriggerId) return false; @@ -422,7 +422,7 @@ public: if ((x == 0.0f && *zoneX != '0') || (y == 0.0f && *zoneY != '0')) return false; - uint32 areaId = id ? (uint32)atoi(id) : player->GetZoneId(); + uint32 areaId = id ? atoul(id) : player->GetZoneId(); AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId); @@ -492,7 +492,7 @@ public: float y = (float)atof(goY); float z; float ort = port ? (float)atof(port) : player->GetOrientation(); - uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId(); + uint32 mapId = id ? atoul(id) : player->GetMapId(); if (goZ) { @@ -539,7 +539,7 @@ public: if (!id) return false; - uint32 ticketId = atoi(id); + uint32 ticketId = atoul(id); if (!ticketId) return false; @@ -562,6 +562,50 @@ public: ticket->TeleportTo(player); return true; } + + static bool HandleGoOffsetCommand(ChatHandler* handler, char const* args) + { + if (!*args) + return false; + + Player* player = handler->GetSession()->GetPlayer(); + + char* goX = strtok((char*)args, " "); + char* goY = strtok(NULL, " "); + char* goZ = strtok(NULL, " "); + char* port = strtok(NULL, " "); + + float x, y, z, o; + player->GetPosition(x, y, z, o); + if (goX) + x += atof(goX); + if (goY) + y += atof(goY); + if (goZ) + z += atof(goZ); + if (port) + o += atof(port); + + if (!Trinity::IsValidMapCoord(x, y, z, o)) + { + handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, player->GetMapId()); + handler->SetSentErrorMessage(true); + return false; + } + + // stop flight if need + if (player->IsInFlight()) + { + player->GetMotionMaster()->MovementExpired(); + player->CleanupAfterTaxiFlight(); + } + // save only in non-flight case + else + player->SaveRecallPosition(); + + player->TeleportTo(player->GetMapId(), x, y, z, o); + return true; + } }; void AddSC_go_commandscript() diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 91d677a5859..617bf39dbde 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -77,16 +77,11 @@ public: if (!id) return false; - ObjectGuid::LowType guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoul(id); if (!guidLow) return false; - GameObject* object = NULL; - - // by DB guid - if (GameObjectData const* goData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, goData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); @@ -152,7 +147,7 @@ public: if (spawntimeSecs) { - uint32 value = atoi((char*)spawntimeSecs); + int32 value = atoi((char*)spawntimeSecs); object->SetRespawnTime(value); } @@ -195,10 +190,10 @@ public: uint32 spawntm = 300; if (spawntime) - spawntm = atoi((char*)spawntime); + spawntm = atoul(spawntime); G3D::Quat rotation = G3D::Matrix3::fromEulerAnglesZYX(player->GetOrientation(), 0.f, 0.f); - uint32 objectId = atoi(id); + uint32 objectId = atoul(id); if (!sObjectMgr->GetGameObjectTemplate(objectId)) { @@ -312,7 +307,7 @@ public: return false; } - GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(ObjectGuid(HighGuid::GameObject, id, guidLow)); + GameObject* target = handler->GetObjectFromPlayerMapByDbGuid(guidLow); handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name.c_str(), guidLow, id, x, y, z, mapId, o, phase); @@ -338,16 +333,11 @@ public: if (!id) return false; - ObjectGuid::LowType guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoul(id); if (!guidLow) return false; - GameObject* object = NULL; - - // by DB guid - if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); @@ -361,7 +351,7 @@ public: Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(), ownerGuid); if (!owner || !ownerGuid.IsPlayer()) { - handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), object->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, ownerGuid.GetCounter(), guidLow); handler->SetSentErrorMessage(true); return false; } @@ -373,7 +363,7 @@ public: object->Delete(); object->DeleteFromDB(); - handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, object->GetSpawnId()); return true; } @@ -386,16 +376,11 @@ public: if (!id) return false; - ObjectGuid::LowType guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoul(id); if (!guidLow) return false; - GameObject* object = NULL; - - // by DB guid - if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); @@ -455,16 +440,11 @@ public: if (!id) return false; - ObjectGuid::LowType guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoul(id); if (!guidLow) return false; - GameObject* object = NULL; - - // by DB guid - if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); @@ -529,16 +509,11 @@ public: if (!id) return false; - ObjectGuid::LowType guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoul(id); if (!guidLow) return false; - GameObject* object = NULL; - - // by DB guid - if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); @@ -547,7 +522,7 @@ public: } char* phase = strtok (NULL, " "); - uint32 phaseMask = phase ? atoi(phase) : 0; + uint32 phaseMask = phase ? atoul(phase) : 0; if (phaseMask == 0) { handler->SendSysMessage(LANG_BAD_VALUE); @@ -615,13 +590,28 @@ public: uint32 lootId = 0; if (!*args) + return false; + + char* param1 = handler->extractKeyFromLink((char*)args, "Hgameobject_entry"); + if (!param1) + return false; + + if (strcmp(param1, "guid") == 0) { - if (WorldObject* object = handler->getSelectedObject()) - entry = object->GetEntry(); - else - entry = atoi((char*)args); - } else - entry = atoi((char*)args); + char* tail = strtok(nullptr, ""); + char* cValue = handler->extractKeyFromLink(tail, "Hgameobject"); + if (!cValue) + return false; + ObjectGuid::LowType guidLow = atoul(cValue); + const GameObjectData* data = sObjectMgr->GetGOData(guidLow); + if (!data) + return false; + entry = data->id; + } + else + { + entry = atoul(param1); + } GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry); @@ -641,6 +631,13 @@ public: handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId); handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId); handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str()); + handler->PSendSysMessage(LANG_GOINFO_SIZE, gameObjectInfo->size); + + if (GameObjectTemplateAddon const* addon = sObjectMgr->GetGameObjectTemplateAddon(entry)) + handler->PSendSysMessage(LANG_GOINFO_ADDON, addon->faction, addon->flags); + + if (GameObjectDisplayInfoEntry const* modelInfo = sGameObjectDisplayInfoStore.LookupEntry(displayId)) + handler->PSendSysMessage(LANG_GOINFO_MODEL, modelInfo->maxX, modelInfo->maxY, modelInfo->maxZ, modelInfo->minX, modelInfo->minY, modelInfo->minZ); return true; } @@ -652,15 +649,11 @@ public: if (!id) return false; - ObjectGuid::LowType guidLow = atoi(id); + ObjectGuid::LowType guidLow = atoul(id); if (!guidLow) return false; - GameObject* object = NULL; - - if (GameObjectData const* gameObjectData = sObjectMgr->GetGOData(guidLow)) - object = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guidLow, gameObjectData->id); - + GameObject* object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!object) { handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index d4c39099182..9c5e30c340e 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -165,24 +165,54 @@ public: static bool HandleGPSCommand(ChatHandler* handler, char const* args) { - WorldObject* object = NULL; + WorldObject* object = nullptr; if (*args) { - ObjectGuid guid = handler->extractGuidFromLink((char*)args); - if (guid) - object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT); - - if (!object) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); + HighGuid guidHigh; + ObjectGuid::LowType guidLow = handler->extractLowGuidFromLink((char*)args, guidHigh); + if (!guidLow) return false; + switch (guidHigh) + { + case HighGuid::Player: + { + object = sObjectMgr->GetPlayerByLowGUID(guidLow); + if (!object) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + } + break; + } + case HighGuid::Unit: + { + object = handler->GetCreatureFromPlayerMapByDbGuid(guidLow); + if (!object) + { + handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); + handler->SetSentErrorMessage(true); + } + break; + } + case HighGuid::GameObject: + { + object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); + if (!object) + { + handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); + handler->SetSentErrorMessage(true); + } + break; + } + default: + return false; } + if (!object) + return false; } else { object = handler->getSelectedUnit(); - if (!object) { handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); @@ -748,26 +778,55 @@ public: static bool HandleGetDistanceCommand(ChatHandler* handler, char const* args) { - WorldObject* obj = NULL; - + WorldObject* object = nullptr; if (*args) { - ObjectGuid guid = handler->extractGuidFromLink((char*)args); - if (guid) - obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT); - - if (!obj) - { - handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); - handler->SetSentErrorMessage(true); + HighGuid guidHigh; + ObjectGuid::LowType guidLow = handler->extractLowGuidFromLink((char*)args, guidHigh); + if (!guidLow) return false; + switch (guidHigh) + { + case HighGuid::Player: + { + object = sObjectMgr->GetPlayerByLowGUID(guidLow); + if (!object) + { + handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); + handler->SetSentErrorMessage(true); + } + break; + } + case HighGuid::Unit: + { + object = handler->GetCreatureFromPlayerMapByDbGuid(guidLow); + if (!object) + { + handler->SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); + handler->SetSentErrorMessage(true); + } + break; + } + case HighGuid::GameObject: + { + object = handler->GetObjectFromPlayerMapByDbGuid(guidLow); + if (!object) + { + handler->SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); + handler->SetSentErrorMessage(true); + } + break; + } + default: + return false; } + if (!object) + return false; } else { - obj = handler->getSelectedUnit(); - - if (!obj) + object = handler->getSelectedUnit(); + if (!object) { handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); handler->SetSentErrorMessage(true); @@ -775,7 +834,7 @@ public: } } - handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(obj), handler->GetSession()->GetPlayer()->GetDistance2d(obj), handler->GetSession()->GetPlayer()->GetExactDist(obj), handler->GetSession()->GetPlayer()->GetExactDist2d(obj)); + handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(object), handler->GetSession()->GetPlayer()->GetDistance2d(object), handler->GetSession()->GetPlayer()->GetExactDist(object), handler->GetSession()->GetPlayer()->GetExactDist2d(object)); return true; } // Teleport player to last position @@ -2166,8 +2225,8 @@ public: return false; } - int32 guid = atoi(guidStr); - if (!guid) + ObjectGuid::LowType guidLow = atoul(guidStr); + if (!guidLow) { handler->SendSysMessage(LANG_BAD_VALUE); handler->SetSentErrorMessage(true); @@ -2192,14 +2251,10 @@ public: if (Player* player = handler->GetSession()->GetPlayer()) { - GameObject* go = NULL; - - if (GameObjectData const* goData = sObjectMgr->GetGOData(guid)) - go = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(guid, goData->id); - + GameObject* go = handler->GetObjectFromPlayerMapByDbGuid(guidLow); if (!go) { - handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guid); + handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, guidLow); handler->SetSentErrorMessage(true); return false; } @@ -2212,7 +2267,7 @@ public: } go->ModifyHealth(-damage, player); - handler->PSendSysMessage(LANG_GAMEOBJECT_DAMAGED, go->GetName().c_str(), guid, -damage, go->GetGOValue()->Building.Health); + handler->PSendSysMessage(LANG_GAMEOBJECT_DAMAGED, go->GetName().c_str(), guidLow, -damage, go->GetGOValue()->Building.Health); } return true; diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index fe6d0f55a38..7b4d648eca9 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -243,7 +243,7 @@ public: if (!charID) return false; - uint32 id = atoi(charID); + uint32 id = atoul(charID); if (!sObjectMgr->GetCreatureTemplate(id)) return false; @@ -364,7 +364,7 @@ public: char* guidStr = strtok((char*)args, " "); char* waitStr = strtok((char*)nullptr, " "); - ObjectGuid::LowType lowGuid = atoi((char*)guidStr); + ObjectGuid::LowType lowGuid = atoul(guidStr); // attempt check creature existence by DB data CreatureData const* data = sObjectMgr->GetCreatureData(lowGuid); @@ -413,7 +413,7 @@ public: if (!*args) return false; - uint32 newEntryNum = atoi(args); + uint32 newEntryNum = atoul(args); if (!newEntryNum) return false; @@ -438,7 +438,7 @@ public: if (!*args) return false; - uint8 lvl = (uint8) atoi((char*)args); + uint8 lvl = (uint8) atoi(args); if (lvl < 1 || lvl > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) + 3) { handler->SendSysMessage(LANG_BAD_VALUE); @@ -473,12 +473,10 @@ public: if (!cId) return false; - ObjectGuid::LowType lowguid = atoi(cId); + ObjectGuid::LowType lowguid = atoul(cId); if (!lowguid) return false; - - if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid)) - unit = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, cr_data->id, lowguid)); + unit = handler->GetCreatureFromPlayerMapByDbGuid(lowguid); } else unit = handler->getSelectedCreature(); @@ -542,7 +540,7 @@ public: if (!*args) return false; - uint32 factionId = (uint32) atoi((char*)args); + uint32 factionId = atoul(args); if (!sFactionTemplateStore.LookupEntry(factionId)) { @@ -585,7 +583,7 @@ public: if (!*args) return false; - uint32 npcFlags = (uint32) atoi((char*)args); + uint32 npcFlags = (uint32) atoi(args); Creature* creature = handler->getSelectedCreature(); @@ -785,7 +783,7 @@ public: if (!cId) return false; - lowguid = atoi(cId); + lowguid = atoul(cId); // Attempting creature load from DB data CreatureData const* data = sObjectMgr->GetCreatureData(lowguid); @@ -871,7 +869,7 @@ public: if (!*args) return false; - uint32 displayId = (uint32) atoi((char*)args); + uint32 displayId = atoul(args); Creature* creature = handler->getSelectedCreature(); @@ -965,12 +963,10 @@ public: } else // case .setmovetype #creature_guid $move_type (with selected creature) { - lowguid = atoi((char*)guid_str); + lowguid = atoul(guid_str); - /* impossible without entry if (lowguid) - creature = ObjectAccessor::GetCreature(*handler->GetSession()->GetPlayer(), MAKE_GUID(lowguid, HighGuid::Unit)); - */ + creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid); // attempt check creature existence by DB data if (!creature) @@ -1043,7 +1039,7 @@ public: if (!*args) return false; - uint32 phasemask = (uint32) atoi((char*)args); + uint32 phasemask = atoul(args); if (phasemask == 0) { handler->SendSysMessage(LANG_BAD_VALUE); @@ -1124,7 +1120,7 @@ public: if (!stime) return false; - int spawnTime = atoi((char*)stime); + int spawnTime = atoi(stime); if (spawnTime < 0) { @@ -1323,7 +1319,7 @@ public: Player* chr = handler->GetSession()->GetPlayer(); - uint32 id = atoi(charID); + uint32 id = atoul(charID); if (!id) return false; @@ -1452,7 +1448,7 @@ public: if (!*args) return false; - ObjectGuid::LowType leaderGUID = (uint32) atoi((char*)args); + ObjectGuid::LowType leaderGUID = atoul(args); Creature* creature = handler->getSelectedCreature(); if (!creature || !creature->GetSpawnId()) @@ -1504,7 +1500,7 @@ public: if (!*args) return false; - ObjectGuid::LowType linkguid = (uint32) atoi((char*)args); + ObjectGuid::LowType linkguid = atoul(args); Creature* creature = handler->getSelectedCreature(); diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index af6a5189487..ffbc4da5d57 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -746,7 +746,7 @@ public: if (target) handler->SendSysMessage(LANG_WAYPOINT_CREATSELECTED); - pathid = atoi((char*)guid_str); + pathid = atoul(guid_str); } std::string show = show_str; @@ -765,12 +765,12 @@ public: } stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID); - stmt->setUInt32(0, target->GetGUID().GetCounter()); + stmt->setUInt32(0, target->GetSpawnId()); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) { - handler->SendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM); + handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, target->GetSpawnId()); return true; } @@ -825,7 +825,7 @@ public: { Field* fields = result2->Fetch(); uint32 wpguid = fields[0].GetUInt32(); - Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, VISUAL_WAYPOINT, wpguid)); + Creature* creature = handler->GetCreatureFromPlayerMapByDbGuid(wpguid); if (!creature) { @@ -880,7 +880,7 @@ public: // Set "wpguid" column to the visual waypoint stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID); - stmt->setInt32(0, int32(wpCreature->GetSpawnId())); + stmt->setUInt32(0, wpCreature->GetSpawnId()); stmt->setUInt32(1, pathid); stmt->setUInt32(2, point); WorldDatabase.Execute(stmt); @@ -1021,15 +1021,16 @@ public: do { Field* fields = result->Fetch(); - ObjectGuid::LowType guid = fields[0].GetUInt32(); - Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid(HighGuid::Unit, VISUAL_WAYPOINT, guid)); + ObjectGuid::LowType lowguid = fields[0].GetUInt32(); + + Creature* creature = handler->GetCreatureFromPlayerMapByDbGuid(lowguid); if (!creature) { - handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid); + handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, lowguid); hasError = true; stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE); - stmt->setUInt32(0, guid); + stmt->setUInt32(0, lowguid); WorldDatabase.Execute(stmt); } else |
