diff options
author | megamage <none@none> | 2009-09-02 15:42:40 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-09-02 15:42:40 -0500 |
commit | 0c0a7b6b0ee55aa1c58a82b2afdc48614f3342bc (patch) | |
tree | 38b20ab7a9ef0dd38dd7f572c8f4dee165ad1f7f | |
parent | f49754447b51f6b25b61e3067a2b40508dd60116 (diff) |
[8444] Prevent spawn gameobjects with invalid displayid by command. Author: VladimirMangos
Also fix mangos string for not existed gameobejct entry.
--HG--
branch : trunk
-rw-r--r-- | sql/FULL/world_trinity_string_full.sql | 3 | ||||
-rw-r--r-- | sql/updates/5552_8444_world_trinity_string.sql | 6 | ||||
-rw-r--r-- | src/game/Language.h | 3 | ||||
-rw-r--r-- | src/game/Level2.cpp | 19 | ||||
-rw-r--r-- | src/game/ObjectMgr.cpp | 12 |
5 files changed, 30 insertions, 13 deletions
diff --git a/sql/FULL/world_trinity_string_full.sql b/sql/FULL/world_trinity_string_full.sql index 4f4f4d2df53..50cf30b27f0 100644 --- a/sql/FULL/world_trinity_string_full.sql +++ b/sql/FULL/world_trinity_string_full.sql @@ -284,6 +284,7 @@ INSERT INTO `trinity_string` (`entry`, `content_default`, `content_loc1`, `conte (345, 'Forced customize for player %s will be requested at next login.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (346, 'Forced customize for player %s (GUID #%u) will be requested at next login.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (347, 'TaxiNode ID %u not found!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), +(348,'Game Object (Entry: %u) have invalid data and can\'t be spawned',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (400, '|cffff0000[System Message]:|rScripts reloaded', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (401, 'You change security level of account %s to %i.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (402, '%s changed your security level to %i.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), @@ -405,7 +406,7 @@ INSERT INTO `trinity_string` (`entry`, `content_default`, `content_loc1`, `conte (519, '|cffffffff|Htele:%s|h[%s]|h|r ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (520, '%d - |cffffffff|Hspell:%d|h[%s]|h|r ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (521, '%d - |cffffffff|Hskill:%d|h[%s %s]|h|r %s %s', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), -(522, 'Game Object (GUID: %u) not found', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), +(522, 'Game Object (Entry: %u) not found', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (523, '>> Game Object %s (GUID: %u) at %f %f %f. Orientation %f.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (524, 'Selected object:\n|cffffffff|Hgameobject:%d|h[%s]|h|r GUID: %u ID: %u\nX: %f Y: %f Z: %f MapId: %u\nOrientation: %f', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), (525, '>> Add Game Object ''%i'' (%s) (GUID: %i) added at ''%f %f %f''.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL), diff --git a/sql/updates/5552_8444_world_trinity_string.sql b/sql/updates/5552_8444_world_trinity_string.sql new file mode 100644 index 00000000000..0d41fadfbae --- /dev/null +++ b/sql/updates/5552_8444_world_trinity_string.sql @@ -0,0 +1,6 @@ +-- ALTER TABLE db_version CHANGE COLUMN required_8416_01_mangos_spell_learn_spell required_8444_01_mangos_mangos_string bit; + +DELETE FROM trinity_string WHERE entry IN(348,522); +INSERT INTO trinity_string VALUES +(348,'Game Object (Entry: %u) have invalid data and can\'t be spawned',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(522,'Game Object (Entry: %u) not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); diff --git a/src/game/Language.h b/src/game/Language.h index bd74333c45a..048ba69bb43 100644 --- a/src/game/Language.h +++ b/src/game/Language.h @@ -328,7 +328,8 @@ enum TrinityStrings LANG_CUSTOMIZE_PLAYER = 345, LANG_CUSTOMIZE_PLAYER_GUID = 346, LANG_COMMAND_GOTAXINODENOTFOUND = 347, - // Room for more level 2 348-399 not used + LANG_GAMEOBJECT_HAVE_INVALID_DATA = 348, + // Room for more level 2 349-399 not used // level 3 chat LANG_SCRIPTS_RELOADED = 400, diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 9e613de3acc..842fba4f10c 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -733,15 +733,24 @@ bool ChatHandler::HandleGameObjectAddCommand(const char* args) char* spawntimeSecs = strtok(NULL, " "); - const GameObjectInfo *goI = objmgr.GetGameObjectInfo(id); + const GameObjectInfo *gInfo = objmgr.GetGameObjectInfo(id); - if (!goI) + if (!gInfo) { PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); SetSentErrorMessage(true); return false; } + if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId)) + { + // report to DB errors log as in loading case + sLog.outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.",id, gInfo->type, gInfo->displayId); + PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA,id); + SetSentErrorMessage(true); + return false; + } + Player *chr = m_session->GetPlayer(); float x = float(chr->GetPositionX()); float y = float(chr->GetPositionY()); @@ -752,7 +761,7 @@ bool ChatHandler::HandleGameObjectAddCommand(const char* args) GameObject* pGameObj = new GameObject; uint32 db_lowGUID = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT); - if(!pGameObj->Create(db_lowGUID, goI->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) + if(!pGameObj->Create(db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY)) { delete pGameObj; return false; @@ -775,14 +784,14 @@ bool ChatHandler::HandleGameObjectAddCommand(const char* args) return false; } - sLog.outDebug(GetMangosString(LANG_GAMEOBJECT_CURRENT), goI->name, db_lowGUID, x, y, z, o); + sLog.outDebug(GetMangosString(LANG_GAMEOBJECT_CURRENT), gInfo->name, db_lowGUID, x, y, z, o); map->Add(pGameObj); // TODO: is it really necessary to add both the real and DB table guid here ? objmgr.AddGameobjectToGrid(db_lowGUID, objmgr.GetGOData(db_lowGUID)); - PSendSysMessage(LANG_GAMEOBJECT_ADD,id,goI->name,db_lowGUID,x,y,z); + PSendSysMessage(LANG_GAMEOBJECT_ADD,id,gInfo->name,db_lowGUID,x,y,z); return true; } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 885a8c843f7..3204e8f0145 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1565,13 +1565,13 @@ void ObjectMgr::LoadGameobjects() uint32 entry = fields[ 1].GetUInt32(); GameObjectInfo const* gInfo = GetGameObjectInfo(entry); - if(!gInfo) + if (!gInfo) { sLog.outErrorDb("Table `gameobject` has gameobject (GUID: %u) with non existing gameobject entry %u, skipped.", guid, entry); continue; } - if(gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId)) + if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId)) { sLog.outErrorDb("Gameobject (GUID: %u Entry %u GoType: %u) have invalid displayId (%u), not loaded.",guid, entry, gInfo->type, gInfo->displayId); continue; @@ -1612,25 +1612,25 @@ void ObjectMgr::LoadGameobjects() int16 gameEvent = fields[16].GetInt16(); int16 PoolId = fields[17].GetInt16(); - if(data.rotation2 < -1.0f || data.rotation2 > 1.0f) + if (data.rotation2 < -1.0f || data.rotation2 > 1.0f) { sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid rotation2 (%f) value, skip",guid,data.id,data.rotation2 ); continue; } - if(data.rotation3 < -1.0f || data.rotation3 > 1.0f) + if (data.rotation3 < -1.0f || data.rotation3 > 1.0f) { sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid rotation3 (%f) value, skip",guid,data.id,data.rotation3 ); continue; } - if(!MapManager::IsValidMapCoord(data.mapid,data.posX,data.posY,data.posZ,data.orientation)) + if (!MapManager::IsValidMapCoord(data.mapid,data.posX,data.posY,data.posZ,data.orientation)) { sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid coordinates, skip",guid,data.id ); continue; } - if(data.phaseMask==0) + if (data.phaseMask==0) { sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.",guid,data.id ); data.phaseMask = 1; |