From 3cc8afc0467d62fb4acadf29fe2904ac6a585440 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Sun, 4 Sep 2022 15:47:58 +0400 Subject: [PATCH] Revert "Game runs without crash" This reverts commit 9bb8f2a9718a0fcbe6c8ab5921926ed61a5043d1. --- client/CGameInfo.cpp | 6 - client/CGameInfo.h | 3 - config/obstacles.json | 633 +++++++++++++------------------ lib/CModHandler.cpp | 2 - lib/GameConstants.cpp | 7 +- lib/GameConstants.h | 4 +- lib/ObstacleHandler.cpp | 63 ++- lib/ObstacleHandler.h | 25 +- lib/VCMI_Lib.cpp | 2 - lib/battle/BattleInfo.cpp | 8 +- lib/battle/CObstacleInstance.cpp | 4 +- 11 files changed, 297 insertions(+), 460 deletions(-) diff --git a/client/CGameInfo.cpp b/client/CGameInfo.cpp index d8c58296a..3c8eb86fb 100644 --- a/client/CGameInfo.cpp +++ b/client/CGameInfo.cpp @@ -38,7 +38,6 @@ void CGameInfo::setFromLib() skillh = VLC->skillh; objtypeh = VLC->objtypeh; battleFieldHandler = VLC->battlefieldsHandler; - obstacleHandler = VLC->obstacleHandler; } const ArtifactService * CGameInfo::artifacts() const @@ -86,11 +85,6 @@ const SkillService * CGameInfo::skills() const return globalServices->skills(); } -const ObstacleService * CGameInfo::obstacles() const -{ - return globalServices->obstacles(); -} - void CGameInfo::updateEntity(Metatype metatype, int32_t index, const JsonNode & data) { logGlobal->error("CGameInfo::updateEntity call is not expected."); diff --git a/client/CGameInfo.h b/client/CGameInfo.h index 70b56905c..b93924873 100644 --- a/client/CGameInfo.h +++ b/client/CGameInfo.h @@ -32,7 +32,6 @@ class CGameState; class IMainVideoPlayer; class CServerHandler; class BattleFieldHandler; -class ObstacleHandler; class CMap; @@ -63,7 +62,6 @@ public: const spells::Service * spells() const override; const SkillService * skills() const override; const BattleFieldService * battlefields() const override; - const ObstacleService * obstacles() const override; void updateEntity(Metatype metatype, int32_t index, const JsonNode & data) override; @@ -79,7 +77,6 @@ public: ConstTransitivePtr skillh; ConstTransitivePtr objh; ConstTransitivePtr objtypeh; - ConstTransitivePtr obstacleHandler; CGeneralTextHandler * generaltexth; CMapHandler * mh; CTownHandler * townh; diff --git a/config/obstacles.json b/config/obstacles.json index d2a7116c6..22a944f3c 100644 --- a/config/obstacles.json +++ b/config/obstacles.json @@ -11,1346 +11,1225 @@ // * "defname" is name of the graphics. It's def file for usual obstacles and bitmap for the absolute ones. { - "0": +"obstacles" : [ { + "id" : 0, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObDino1.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "1": { + "id" : 1, "allowedTerrain" : ["dirt", "sand", "rough", "subterra"], "specialBattlefields" : ["sand_shore"], "width" : 3, "height" : 2, "blockedTiles" : [0, 1, 2], "defname" : "ObDino2.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "2": { + "id" : 2, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 4, "height" : 2, "blockedTiles" : [0, 1, -14, -15, -16], "defname" : "ObDino3.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "3": { + "id" : 3, "allowedTerrain" : ["dirt", "rough"], "specialBattlefields" : ["cursed_ground"], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObSkel1.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "4": { + "id" : 4, "allowedTerrain" : ["dirt", "rough", "subterra"], "specialBattlefields" : ["sand_shore", "cursed_ground"], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObSkel2.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "5": { + "id" : 5, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 4, "height" : 2, "blockedTiles" : [1, 2, 3], "defname" : "ObBDT01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "6": { + "id" : 6, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 3, "height" : 2, "blockedTiles" : [-15, -16], "defname" : "ObDRk01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "7": { + "id" : 7, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 2, "height" : 2, "blockedTiles" : [0, 1], "defname" : "ObDRk02.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "8": { + "id" : 8, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 2, "height" : 2, "blockedTiles" : [-16], "defname" : "ObDRk03.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "9": { + "id" : 9, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 2, "height" : 2, "blockedTiles" : [0, 1], "defname" : "ObDRk04.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "10": { + "id" : 10, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 2, "height" : 2, "blockedTiles" : [0, 1], "defname" : "ObDSh01.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "11": { + "id" : 11, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObDTF03.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "12": { + "id" : 12, "allowedTerrain" : ["dirt", "rough"], "specialBattlefields" : ["cursed_ground"], "width" : 3, "height" : 3, "blockedTiles" : [0, 1, 2, 3], "defname" : "ObDtS03.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "13": { + "id" : 13, "allowedTerrain" : ["dirt", "rough"], "specialBattlefields" : ["cursed_ground"], "width" : 3, "height" : 2, "blockedTiles" : [1, 2, -15], "defname" : "ObDtS04.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "14": { + "id" : 14, "allowedTerrain" : ["dirt", "rough"], "specialBattlefields" : ["cursed_ground"], "width" : 3, "height" : 2, "blockedTiles" : [2, -15, -16], "defname" : "ObDtS14.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "15": { + "id" : 15, "allowedTerrain" : ["dirt", "rough"], "specialBattlefields" : ["cursed_ground"], "width" : 3, "height" : 3, "blockedTiles" : [1, -16, -33], "defname" : "ObDtS15.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "16": { + "id" : 16, "allowedTerrain" : ["sand"], "specialBattlefields" : [], "width" : 4, "height" : 4, "blockedTiles" : [-15, -16, -32, -33, -48, -49], "defname" : "ObDsM01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "17": { + "id" : 17, "allowedTerrain" : ["sand"], "specialBattlefields" : [], "width" : 3, "height" : 2, "blockedTiles" : [1, -15, -16], "defname" : "ObDsS02.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "18": { + "id" : 18, "allowedTerrain" : ["sand"], "specialBattlefields" : [], "width" : 4, "height" : 2, "blockedTiles" : [1, 2, 3, -15, -16], "defname" : "ObDsS17.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "19": { + "id" : 19, "allowedTerrain" : ["grass", "swamp"], "specialBattlefields" : [], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObGLg01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "20": { + "id" : 20, "allowedTerrain" : ["grass", "swamp"], "specialBattlefields" : ["magic_plains"], "width" : 2, "height" : 2, "blockedTiles" : [0, 1], "defname" : "ObGRk01.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "21": { + "id" : 21, "allowedTerrain" : ["grass", "swamp"], "specialBattlefields" : [], "width" : 1, "height" : 1, "blockedTiles" : [0], "defname" : "ObGSt01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "22": { + "id" : 22, "allowedTerrain" : ["grass"], "specialBattlefields" : ["magic_plains"], "width" : 6, "height" : 2, "blockedTiles" : [1, 2, 3, 4, -13, -14, -15, -16], "defname" : "ObGrS01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "23": { + "id" : 23, "allowedTerrain" : ["grass"], "specialBattlefields" : [], "width" : 7, "height" : 1, "blockedTiles" : [1, 2], "defname" : "OBGrS02.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "24": { + "id" : 24, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 3, "height" : 1, "blockedTiles" : [0, 1, 2], "defname" : "ObSnS01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "25": { + "id" : 25, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 5, "height" : 1, "blockedTiles" : [1, 2, 3, 4], "defname" : "ObSnS02.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "26": { + "id" : 26, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 3, "height" : 3, "blockedTiles" : [0, -16, -33], "defname" : "ObSnS03.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "27": { + "id" : 27, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 3, "height" : 1, "blockedTiles" : [0, 1, 2], "defname" : "ObSnS04.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "28": { + "id" : 28, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 3, "height" : 1, "blockedTiles" : [1], "defname" : "ObSnS05.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "29": { + "id" : 29, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 3, "height" : 2, "blockedTiles" : [1, 2], "defname" : "ObSnS06.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "30": { + "id" : 30, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObSnS07.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "31": { + "id" : 31, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 3, "height" : 2, "blockedTiles" : [0, 1, 2], "defname" : "ObSnS08.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "32": { + "id" : 32, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 7, "height" : 2, "blockedTiles" : [2, 3, 4, 5, -13, -14, -15, -16], "defname" : "ObSnS09.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "33": { + "id" : 33, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 5, "height" : 5, "blockedTiles" : [3, -13, -14, -15, -33, -49, -66], "defname" : "ObSnS10.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "34": { + "id" : 34, "allowedTerrain" : ["swamp"], "specialBattlefields" : [], "width" : 2, "height" : 2, "blockedTiles" : [0], "defname" : "ObSwS01.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "35": { + "id" : 35, "allowedTerrain" : ["swamp"], "specialBattlefields" : [], "width" : 8, "height" : 3, "blockedTiles" : [-10, -11, -12, -13, -14, -15, -16], "defname" : "ObSwS02.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "36": { + "id" : 36, "allowedTerrain" : ["swamp"], "specialBattlefields" : [], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObSwS03.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "37": { + "id" : 37, "allowedTerrain" : ["swamp"], "specialBattlefields" : [], "width" : 3, "height" : 1, "blockedTiles" : [0, 1, 2], "defname" : "ObSwS04.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "38": { + "id" : 38, "allowedTerrain" : ["swamp"], "specialBattlefields" : [], "width" : 5, "height" : 4, "blockedTiles" : [-13, -14, -15, -16, -30, -31, -32, -33], "defname" : "ObSwS11b.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "39": { + "id" : 39, "allowedTerrain" : ["swamp"], "specialBattlefields" : [], "width" : 4, "height" : 3, "blockedTiles" : [-16, -17, -31, -32, -33, -34], "defname" : "ObSwS13a.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "40": { + "id" : 40, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 2, "height" : 2, "blockedTiles" : [0, 1, -16], "defname" : "ObRgS01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "41": { + "id" : 41, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 4, "height" : 3, "blockedTiles" : [-14, -15, -16, -32, -33], "defname" : "ObRgS02.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "42": { + "id" : 42, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 3, "height" : 2, "blockedTiles" : [1, 2, -15, -16], "defname" : "ObRgS03.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "43": { + "id" : 43, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 3, "height" : 3, "blockedTiles" : [-16, -32, -33], "defname" : "ObRgS04.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "44": { + "id" : 44, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 3, "height" : 3, "blockedTiles" : [-15, -16, -32], "defname" : "ObRgS05.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "45": { + "id" : 45, "allowedTerrain" : ["subterra"], "specialBattlefields" : [], "width" : 3, "height" : 3, "blockedTiles" : [0, 1, 2, -15, -16], "defname" : "ObSuS01.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "46": { + "id" : 46, "allowedTerrain" : ["subterra"], "specialBattlefields" : [], "width" : 3, "height" : 2, "blockedTiles" : [0, 1, 2], "defname" : "ObSuS02.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "47": { + "id" : 47, "allowedTerrain" : ["subterra"], "specialBattlefields" : [], "width" : 4, "height" : 3, "blockedTiles" : [0, 1, 2, 3, -14, -15, -16], "defname" : "ObSuS11b.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "48": { + "id" : 48, "allowedTerrain" : ["lava"], "specialBattlefields" : [], "width" : 4, "height" : 3, "blockedTiles" : [-14, -32, -33], "defname" : "ObLvS01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "49": { + "id" : 49, "allowedTerrain" : ["lava"], "specialBattlefields" : [], "width" : 4, "height" : 2, "blockedTiles" : [0, 1, 2, -14, -15, -16], "defname" : "ObLvS02.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "50": { + "id" : 50, "allowedTerrain" : ["lava"], "specialBattlefields" : [], "width" : 5, "height" : 3, "blockedTiles" : [-13, -14, -15, -30, -31, -32, -33], "defname" : "ObLvS03.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "51": { + "id" : 51, "allowedTerrain" : ["lava"], "specialBattlefields" : [], "width" : 3, "height" : 2, "blockedTiles" : [0, 1, 2], "defname" : "ObLvS04.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "52": { + "id" : 52, "allowedTerrain" : ["lava"], "specialBattlefields" : [], "width" : 4, "height" : 4, "blockedTiles" : [-14, -15, -32, -33, -49, -50], "defname" : "ObLvS09.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "53": { + "id" : 53, "allowedTerrain" : ["lava"], "specialBattlefields" : [], "width" : 5, "height" : 3, "blockedTiles" : [-13, -14, -15, -16, -30, -31], "defname" : "ObLvS17.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "54": { + "id" : 54, "allowedTerrain" : ["lava"], "specialBattlefields" : [], "width" : 5, "height" : 3, "blockedTiles" : [-13, -14, -15, -16, -31, -32, -33], "defname" : "ObLvS22.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "55": { + "id" : 55, "allowedTerrain" : ["water"], "specialBattlefields" : [], "width" : 3, "height" : 3, "blockedTiles" : [-15, -16, -33], "defname" : "ObBtS04.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "56": { + "id" : 56, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 3, "height" : 2, "blockedTiles" : [1, -15, -16], "defname" : "ObBhS02.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "57": { + "id" : 57, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 3, "height" : 2, "blockedTiles" : [0, 1, 2], "defname" : "ObBhS03.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "58": { + "id" : 58, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 5, "height" : 2, "blockedTiles" : [1, 2, 3, -14, -15, -16], "defname" : "ObBhS11a.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "59": { + "id" : 59, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 4, "height" : 2, "blockedTiles" : [1, 2, -14, -15], "defname" : "ObBhS12b.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "60": { + "id" : 60, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 2, "height" : 2, "blockedTiles" : [0, 1, -16], "defname" : "ObBhS14b.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "61": { + "id" : 61, "allowedTerrain" : [], "specialBattlefields" : ["holy_ground"], "width" : 1, "height" : 1, "blockedTiles" : [0], "defname" : "ObHGs00.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "62": { + "id" : 62, "allowedTerrain" : [], "specialBattlefields" : ["holy_ground"], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObHGs01.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "63": { + "id" : 63, "allowedTerrain" : [], "specialBattlefields" : ["holy_ground"], "width" : 3, "height" : 3, "blockedTiles" : [1], "defname" : "ObHGs02.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "64": { + "id" : 64, "allowedTerrain" : [], "specialBattlefields" : ["holy_ground"], "width" : 3, "height" : 2, "blockedTiles" : [0, 1, 2], "defname" : "ObHGs03.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "65": { + "id" : 65, "allowedTerrain" : [], "specialBattlefields" : ["holy_ground"], "width" : 4, "height" : 3, "blockedTiles" : [0, 1, 2, 3], "defname" : "ObHGs04.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "66": { + "id" : 66, "allowedTerrain" : [], "specialBattlefields" : ["evil_fog"], "width" : 1, "height" : 1, "blockedTiles" : [0], "defname" : "ObEFs00.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "67": { + "id" : 67, "allowedTerrain" : [], "specialBattlefields" : ["evil_fog"], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObEFs01.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "68": { + "id" : 68, "allowedTerrain" : [], "specialBattlefields" : ["evil_fog"], "width" : 3, "height" : 2, "blockedTiles" : [0, 1, 2], "defname" : "ObEFs02.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "69": { + "id" : 69, "allowedTerrain" : [], "specialBattlefields" : ["evil_fog"], "width" : 4, "height" : 2, "blockedTiles" : [1, 2], "defname" : "ObEFs03.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "70": { + "id" : 70, "allowedTerrain" : [], "specialBattlefields" : ["evil_fog"], "width" : 6, "height" : 2, "blockedTiles" : [1, 2, 3, -12, -13], "defname" : "ObEFs04.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "71": { + "id" : 71, "allowedTerrain" : [], "specialBattlefields" : ["clover_field"], "width" : 1, "height" : 1, "blockedTiles" : [0], "defname" : "ObCFs00.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "72": { + "id" : 72, "allowedTerrain" : [], "specialBattlefields" : ["clover_field"], "width" : 3, "height" : 1, "blockedTiles" : [0, 1, 2], "defname" : "ObCFs01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "73": { + "id" : 73, "allowedTerrain" : [], "specialBattlefields" : ["clover_field"], "width" : 3, "height" : 2, "blockedTiles" : [1, 2, -15, -16], "defname" : "ObCFs02.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "74": { + "id" : 74, "allowedTerrain" : [], "specialBattlefields" : ["clover_field"], "width" : 4, "height" : 2, "blockedTiles" : [0, 1, 2, -14, -15, -16], "defname" : "ObCFs03.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "75": { + "id" : 75, "allowedTerrain" : [], "specialBattlefields" : ["lucid_pools"], "width" : 1, "height" : 1, "blockedTiles" : [0], "defname" : "ObLPs00.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "76": { + "id" : 76, "allowedTerrain" : [], "specialBattlefields" : ["lucid_pools"], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObLPs01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "77": { + "id" : 77, "allowedTerrain" : [], "specialBattlefields" : ["lucid_pools"], "width" : 3, "height" : 2, "blockedTiles" : [0, -15, -16], "defname" : "ObLPs02.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "78": { + "id" : 78, "allowedTerrain" : [], "specialBattlefields" : ["lucid_pools"], "width" : 5, "height" : 2, "blockedTiles" : [1, 2, 3, -13, -14, -15, -16], "defname" : "ObLPs03.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "79": { + "id" : 79, "allowedTerrain" : [], "specialBattlefields" : ["fiery_fields"], "width" : 1, "height" : 1, "blockedTiles" : [0], "defname" : "ObFFs00.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "80": { + "id" : 80, "allowedTerrain" : [], "specialBattlefields" : ["fiery_fields"], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObFFs01.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "81": { + "id" : 81, "allowedTerrain" : [], "specialBattlefields" : ["fiery_fields"], "width" : 3, "height" : 2, "blockedTiles" : [0, 1, 2, -15], "defname" : "ObFFs02.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "82": { + "id" : 82, "allowedTerrain" : [], "specialBattlefields" : ["fiery_fields"], "width" : 4, "height" : 2, "blockedTiles" : [1, 2, 3, -15, -16], "defname" : "ObFFs03.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "83": { + "id" : 83, "allowedTerrain" : [], "specialBattlefields" : ["fiery_fields"], "width" : 3, "height" : 3, "blockedTiles" : [0, 1, 2, 3, -14, -15, -16], "defname" : "ObFFs04.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "84": { + "id" : 84, "allowedTerrain" : [], "specialBattlefields" : ["rocklands"], "width" : 1, "height" : 1, "blockedTiles" : [0], "defname" : "ObRLs00.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "85": { + "id" : 85, "allowedTerrain" : [], "specialBattlefields" : ["rocklands"], "width" : 2, "height" : 1, "blockedTiles" : [0, 1], "defname" : "ObRLs01.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "86": { + "id" : 86, "allowedTerrain" : [], "specialBattlefields" : ["rocklands"], "width" : 3, "height" : 1, "blockedTiles" : [0, 1, 2], "defname" : "ObRLs02.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "87": { + "id" : 87, "allowedTerrain" : [], "specialBattlefields" : ["rocklands"], "width" : 4, "height" : 2, "blockedTiles" : [1, 2, 3, -15, -16], "defname" : "ObRLs03.def", - "unknown" : 0, - "absolute" : false + "unknown" : 0 }, - "88": { + "id" : 88, "allowedTerrain" : [], "specialBattlefields" : ["magic_clouds"], "width" : 1, "height" : 1, "blockedTiles" : [0], "defname" : "ObMCs00.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "89": { + "id" : 89, "allowedTerrain" : [], "specialBattlefields" : ["magic_clouds"], "width" : 2, "height" : 2, "blockedTiles" : [1, -16], "defname" : "ObMCs01.def", - "unknown" : 1, - "absolute" : false + "unknown" : 1 }, - "90": { + "id" : 90, "allowedTerrain" : [], "specialBattlefields" : ["magic_clouds"], "width" : 4, "height" : 2, "blockedTiles" : [0, 1, -14, -15], "defname" : "ObMCs02.def", - "unknown" : 1, - "absolute" : false - }, - - "100": + "unknown" : 1 + } +], +"absoluteObstacles" : [ { + "id" : 0, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 124, "height" : 254, "blockedTiles" : [80, 94, 95, 96, 97, 105, 106, 107, 108, 109, 110], - "defname" : "ObDtL04.pcx", - "absolute" : true + "defname" : "ObDtL04.pcx" }, - "101": { + "id" : 1, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 256, "height" : 254, "blockedTiles" : [73, 91, 108, 109, 110, 111, 112, 113], - "defname" : "ObDtL06.pcx", - "absolute" : true + "defname" : "ObDtL06.pcx" }, - "102": { + "id" : 2, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 168, "height" : 212, "blockedTiles" : [60, 61, 62, 63, 64, 72, 73, 74, 75, 76, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149], - "defname" : "ObDtL10.pcx", - "absolute" : true + "defname" : "ObDtL10.pcx" }, - "103": { + "id" : 3, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 124, "height" : 254, "blockedTiles" : [88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98], - "defname" : "ObDtL02.pcx", - "absolute" : true + "defname" : "ObDtL02.pcx" }, - "104": { + "id" : 4, "allowedTerrain" : ["dirt"], "specialBattlefields" : [], "width" : 146, "height" : 254, "blockedTiles" : [76, 77, 78, 79, 80, 89, 90, 91, 92, 93], - "defname" : "ObDtL03.pcx", - "absolute" : true + "defname" : "ObDtL03.pcx" }, - "105": { + "id" : 5, "allowedTerrain" : ["grass"], "specialBattlefields" : [], "width" : 173, "height" : 221, "blockedTiles" : [55, 56, 57, 58, 75, 76, 77, 95, 112, 113, 131], - "defname" : "ObGrL01.pcx", - "absolute" : true + "defname" : "ObGrL01.pcx" }, - "106": { + "id" : 6, "allowedTerrain" : ["grass"], "specialBattlefields" : [], "width" : 180, "height" : 264, "blockedTiles" : [81, 91, 92, 93, 94, 95, 96, 97, 98, 106, 107, 123], - "defname" : "ObGrL02.pcx", - "absolute" : true + "defname" : "ObGrL02.pcx" }, - "107": { + "id" : 7, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 166, "height" : 255, "blockedTiles" : [76, 77, 78, 79, 91, 92, 93, 97, 98, 106, 107, 108], - "defname" : "ObSnL01.pcx", - "absolute" : true + "defname" : "ObSnL01.pcx" }, - "108": { + "id" : 8, "allowedTerrain" : ["snow"], "specialBattlefields" : [], "width" : 302, "height" : 172, "blockedTiles" : [41, 42, 43, 58, 75, 92, 108, 126, 143], - "defname" : "ObSnL14.pcx", - "absolute" : true + "defname" : "ObSnL14.pcx" }, - "109": { + "id" : 9, "allowedTerrain" : ["swamp"], "specialBattlefields" : [], "width" : 300, "height" : 170, "blockedTiles" : [40, 41, 58, 59, 74, 75, 92, 93, 109, 110, 111, 127, 128, 129, 130], - "defname" : "ObSwL15.pcx", - "absolute" : true + "defname" : "ObSwL15.pcx" }, - "110": { + "id" : 10, "allowedTerrain" : ["swamp"], "specialBattlefields" : [], "width" : 278, "height" : 171, "blockedTiles" : [43, 60, 61, 77, 93, 94, 95, 109, 110, 126, 127], - "defname" : "ObSwL14.pcx", - "absolute" : true + "defname" : "ObSwL14.pcx" }, - "111": { + "id" : 11, "allowedTerrain" : ["swamp"], "specialBattlefields" : [], "width" : 256, "height" : 254, "blockedTiles" : [74, 75, 76, 77, 91, 92, 93, 94, 95, 109, 110, 111, 112], - "defname" : "ObSwL22.pcx", - "absolute" : true + "defname" : "ObSwL22.pcx" }, - "112": { + "id" : 12, "allowedTerrain" : ["lava"], "specialBattlefields" : [], "width" : 124, "height" : 254, "blockedTiles" : [77, 78, 79, 80, 81, 91, 92, 93, 94, 105, 106, 107], - "defname" : "ObLvL01.pcx", - "absolute" : true + "defname" : "ObLvL01.pcx" }, - "113": { + "id" : 13, "allowedTerrain" : ["lava"], "specialBattlefields" : [], "width" : 256, "height" : 128, "blockedTiles" : [43, 60, 61, 76, 77, 93, 109, 126, 127, 142, 143], - "defname" : "OBLvL02.pcx", - "absolute" : true + "defname" : "OBLvL02.pcx" }, - "114": { + "id" : 14, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 186, "height" : 212, "blockedTiles" : [55, 72, 90, 107, 125, 126, 127, 128, 129, 130, 131, 132], - "defname" : "ObRgL01.pcx", - "absolute" : true + "defname" : "ObRgL01.pcx" }, - "115": { + "id" : 15, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 347, "height" : 174, "blockedTiles" : [41, 59, 76, 94, 111, 129, 143, 144, 145], - "defname" : "ObRgL02.pcx", - "absolute" : true + "defname" : "ObRgL02.pcx" }, - "116": { + "id" : 16, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 294, "height" : 169, "blockedTiles" : [40, 41, 42, 43, 58, 75, 93, 110, 128, 145], - "defname" : "ObRgL03.pcx", - "absolute" : true + "defname" : "ObRgL03.pcx" }, - "117": { + "id" : 17, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 165, "height" : 257, "blockedTiles" : [72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 89, 105], - "defname" : "ObRgL04.pcx", - "absolute" : true + "defname" : "ObRgL04.pcx" }, - "118": { + "id" : 18, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 208, "height" : 268, "blockedTiles" : [72, 73, 74, 75, 76, 77, 78, 79, 80, 90, 91, 92, 93, 94, 95, 96, 97], - "defname" : "ObRgL05.pcx", - "absolute" : true + "defname" : "ObRgL05.pcx" }, - "119": { + "id" : 19, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 252, "height" : 254, "blockedTiles" : [73, 74, 75, 76, 77, 78, 91, 92, 93, 94], - "defname" : "ObRgL06.pcx", - "absolute" : true + "defname" : "ObRgL06.pcx" }, - "120": { + "id" : 20, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 278, "height" : 128, "blockedTiles" : [23, 40, 58, 75, 93, 110, 128, 145, 163], - "defname" : "ObRgL15.pcx", - "absolute" : true + "defname" : "ObRgL15.pcx" }, - "121": { + "id" : 21, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 208, "height" : 268, "blockedTiles" : [72, 73, 74, 75, 76, 77, 78, 79, 80, 90, 91, 92, 93, 94, 95, 96, 97], - "defname" : "ObRgL05.pcx", - "absolute" : true + "defname" : "ObRgL05.pcx" }, - "122": { + "id" : 22, "allowedTerrain" : ["rough"], "specialBattlefields" : ["cursed_ground"], "width" : 168, "height" : 212, "blockedTiles" : [73, 74, 75, 76, 77, 78, 79, 90, 91, 92, 93, 94, 95, 96, 97, 106, 107, 108, 109, 110, 111, 112], - "defname" : "ObRgL22.pcx", - "absolute" : true + "defname" : "ObRgL22.pcx" }, - "123": { + "id" : 23, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 147, "height" : 264, "blockedTiles" : [72, 73, 74, 75, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98], - "defname" : "ObBhL02.pcx", - "absolute" : true + "defname" : "ObBhL02.pcx" }, - "124": { + "id" : 24, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 178, "height" : 262, "blockedTiles" : [71, 72, 73, 74, 75, 76, 77, 78, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98], - "defname" : "ObBhL03.pcx", - "absolute" : true + "defname" : "ObBhL03.pcx" }, - "125": { + "id" : 25, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 173, "height" : 257, "blockedTiles" : [72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 89, 90, 105, 106], - "defname" : "ObBhL05.pcx", - "absolute" : true + "defname" : "ObBhL05.pcx" }, - "126": { + "id" : 26, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 241, "height" : 272, "blockedTiles" : [73, 91, 108, 109, 110, 111, 112, 113], - "defname" : "ObBhL06.pcx", - "absolute" : true + "defname" : "ObBhL06.pcx" }, - "127": { + "id" : 27, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 261, "height" : 129, "blockedTiles" : [27, 28, 43, 44, 60, 61, 76, 77, 93, 94, 109, 110, 126, 127, 142, 143, 159], - "defname" : "ObBhL14.pcx", - "absolute" : true + "defname" : "ObBhL14.pcx" }, - "128": { + "id" : 28, "allowedTerrain" : [], "specialBattlefields" : ["sand_shore"], "width" : 180, "height" : 154, "blockedTiles" : [22, 38, 39, 40, 44, 45, 46, 55, 56, 57, 62, 63, 123, 124, 125, 130, 131, 140, 141, 146, 147, 148], - "defname" : "ObBhL16.pcx", - "absolute" : true + "defname" : "ObBhL16.pcx" }, - "129": { + "id" : 29, "allowedTerrain" : [], "specialBattlefields" : ["clover_field"], "width" : 304, "height" : 264, "blockedTiles" : [76, 77, 92, 93, 94, 95, 109, 110, 111], - "defname" : "ObCFL00.pcx", - "absolute" : true + "defname" : "ObCFL00.pcx" }, - "130": { + "id" : 30, "allowedTerrain" : [], "specialBattlefields" : ["lucid_pools"], "width" : 256, "height" : 257, "blockedTiles" : [76, 77, 78, 92, 93, 94, 107, 108, 109], - "defname" : "ObLPL00.pcx", - "absolute" : true + "defname" : "ObLPL00.pcx" }, - "131": { + "id" : 31, "allowedTerrain" : [], "specialBattlefields" : ["fiery_fields"], "width" : 257, "height" : 255, "blockedTiles" : [76, 77, 91, 92, 93, 94, 95, 108, 109, 110, 111], - "defname" : "ObFFL00.pcx", - "absolute" : true + "defname" : "ObFFL00.pcx" }, - "132": { + "id" : 32, "allowedTerrain" : [], "specialBattlefields" : ["rocklands"], "width" : 277, "height" : 218, "blockedTiles" : [60, 61, 75, 76, 77, 91, 92, 93, 94, 95], - "defname" : "ObRLL00.pcx", - "absolute" : true + "defname" : "ObRLL00.pcx" }, - "133": { + "id" : 33, "allowedTerrain" : [], "specialBattlefields" : ["magic_clouds"], "width" : 300, "height" : 214, "blockedTiles" : [59, 60, 74, 75, 76, 93, 94, 95, 111, 112], - "defname" : "ObMCL00.pcx", - "absolute" : true + "defname" : "ObMCL00.pcx" } +] + } diff --git a/lib/CModHandler.cpp b/lib/CModHandler.cpp index 1c30b1208..a7b2ace73 100644 --- a/lib/CModHandler.cpp +++ b/lib/CModHandler.cpp @@ -26,7 +26,6 @@ #include "CSkillHandler.h" #include "ScriptHandler.h" #include "BattleFieldHandler.h" -#include "ObstacleHandler.h" #include @@ -436,7 +435,6 @@ void CContentHandler::init() handlers.insert(std::make_pair("templates", ContentTypeHandler((IHandlerBase *)VLC->tplh, "template"))); handlers.insert(std::make_pair("scripts", ContentTypeHandler(VLC->scriptHandler, "script"))); handlers.insert(std::make_pair("battlefields", ContentTypeHandler(VLC->battlefieldsHandler, "battlefield"))); - handlers.insert(std::make_pair("obstacles", ContentTypeHandler(VLC->obstacleHandler, "obstacle"))); //TODO: any other types of moddables? } diff --git a/lib/GameConstants.cpp b/lib/GameConstants.cpp index e7137de75..609df9b88 100644 --- a/lib/GameConstants.cpp +++ b/lib/GameConstants.cpp @@ -294,15 +294,10 @@ BattleField BattleField::fromString(std::string identifier) else return BattleField::NONE; } - -const ObstacleInfo * Obstacle::getInfo() const -{ - return VLC->obstacles()->getById(*this); -} Obstacle::operator std::string() const { - return getInfo()->identifier; + return VLC->obstacles()->getById(*this)->identifier; } Obstacle Obstacle::fromString(std::string identifier) diff --git a/lib/GameConstants.h b/lib/GameConstants.h index d86c760ce..18fb48ba4 100644 --- a/lib/GameConstants.h +++ b/lib/GameConstants.h @@ -1126,13 +1126,13 @@ class BattleField : public BaseForID DLL_LINKAGE static BattleField fromString(std::string identifier); }; -class ObstacleInfo; class Obstacle : public BaseForID { INSTID_LIKE_CLASS_COMMON(Obstacle, si32) - DLL_LINKAGE const ObstacleInfo * getInfo() const; + ///json serialization helpers DLL_LINKAGE operator std::string() const; + DLL_LINKAGE static Obstacle fromString(std::string identifier); }; diff --git a/lib/ObstacleHandler.cpp b/lib/ObstacleHandler.cpp index 38b2b283b..2490f3134 100644 --- a/lib/ObstacleHandler.cpp +++ b/lib/ObstacleHandler.cpp @@ -76,40 +76,35 @@ bool ObstacleInfo::isAppropriate(const Terrain & terrainType, const BattleField return vstd::contains(allowedTerrains, terrainType); } -ObstacleInfo * ObstacleHandler::loadFromJson(const std::string & scope, const JsonNode & json, const std::string & identifier, size_t index) +void ObstacleHandler::loadObstacles() { - auto * info = new ObstacleInfo(Obstacle(index), identifier); + auto loadObstacles = [](const JsonNode & node, bool absolute, std::vector & out) + { + for(const JsonNode &obs : node.Vector()) + { + out.emplace_back(); + ObstacleInfo & obi = out.back(); + obi.defName = obs["defname"].String(); + obi.width = static_cast(obs["width"].Float()); + obi.height = static_cast(obs["height"].Float()); + for(auto & t : obs["allowedTerrain"].Vector()) + obi.allowedTerrains.emplace_back(t.String()); + for(auto & t : obs["specialBattlefields"].Vector()) + obi.allowedSpecialBfields.emplace_back(t.String()); + obi.blockedTiles = obs["blockedTiles"].convertTo >(); + obi.isAbsoluteObstacle = absolute; + } + }; - info->defName = json["defname"].String(); - info->width = static_cast(json["width"].Float()); - info->height = static_cast(json["height"].Float()); - for(auto & t : json["allowedTerrain"].Vector()) - info->allowedTerrains.emplace_back(t.String()); - for(auto & t : json["specialBattlefields"].Vector()) - info->allowedSpecialBfields.emplace_back(t.String()); - info->blockedTiles = json["blockedTiles"].convertTo>(); - info->isAbsoluteObstacle = json["absolute"].Bool(); - if(info->isAbsoluteObstacle) - absoluteObstacles.push_back(info->getId()); - else - obstacles.push_back(info->getId()); - - return info; -} - -std::vector ObstacleHandler::loadLegacyData(size_t dataSize) -{ - return std::vector(); -} - -std::vector ObstacleHandler::getDefaultAllowed() const -{ - return std::vector(); -} - -const std::vector & ObstacleHandler::getTypeNames() const -{ - static const std::vector types = std::vector { "obstacle" }; - - return types; + //auto allConfigs = VLC->modh->getActiveMods(); + //allConfigs.insert(allConfigs.begin(), "core"); + /*for(auto & mod : allConfigs) + { + if(!CResourceHandler::get(mod)->existsResource(ResourceID("config/obstacles.json"))) + continue; + + const JsonNode config(mod, ResourceID("config/obstacles.json")); + loadObstacles(config["obstacles"], false, obstacles); + loadObstacles(config["absoluteObstacles"], true, absoluteObstacles); + }*/ } diff --git a/lib/ObstacleHandler.h b/lib/ObstacleHandler.h index e4b6fc5f4..04fb119eb 100644 --- a/lib/ObstacleHandler.h +++ b/lib/ObstacleHandler.h @@ -18,14 +18,6 @@ struct DLL_LINKAGE ObstacleInfo : public EntityT { - ObstacleInfo(): obstacle(-1), width(0), height(0), isAbsoluteObstacle(false), iconIndex(0) - {} - - ObstacleInfo(Obstacle obstacle, std::string identifier) - : obstacle(obstacle), identifier(identifier), iconIndex(obstacle.getNum()), name(identifier), width(0), height(0), isAbsoluteObstacle(false) - { - } - Obstacle obstacle; si32 iconIndex; std::string name; @@ -51,10 +43,6 @@ struct DLL_LINKAGE ObstacleInfo : public EntityT template void serialize(Handler &h, const int version) { - h & obstacle; - h & iconIndex; - h & name; - h & identifier; h & defName; h & allowedTerrains; h & allowedSpecialBfields; @@ -73,17 +61,10 @@ public: class ObstacleHandler: public CHandlerBase { public: - std::vector absoluteObstacles; - std::vector obstacles; + void loadObstacles(); - ObstacleInfo * loadFromJson(const std::string & scope, - const JsonNode & json, - const std::string & identifier, - size_t index) override; - - const std::vector & getTypeNames() const override; - std::vector loadLegacyData(size_t dataSize) override; - std::vector getDefaultAllowed() const override; + std::vector obstacles; //info about obstacles that may be placed on battlefield + std::vector absoluteObstacles; //info about obstacles that may be placed on battlefield template void serialize(Handler & h, const int version) { diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp index 81fd2bd99..1ebb22783 100644 --- a/lib/VCMI_Lib.cpp +++ b/lib/VCMI_Lib.cpp @@ -218,8 +218,6 @@ void LibClasses::init(bool onlyEssential) createHandler(scriptHandler, "Script", pomtime); createHandler(battlefieldsHandler, "Battlefields", pomtime); - - createHandler(obstacleHandler, "Obstacles", pomtime); logGlobal->info("\tInitializing handlers: %d ms", totalTime.getDiff()); diff --git a/lib/battle/BattleInfo.cpp b/lib/battle/BattleInfo.cpp index 43157bd65..d8930762e 100644 --- a/lib/battle/BattleInfo.cpp +++ b/lib/battle/BattleInfo.cpp @@ -254,11 +254,11 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, const Terrain & terrain, auto appropriateAbsoluteObstacle = [&](int id) { - return VLC->obstacleHandler->absoluteObstacles[id].getInfo()->isAppropriate(curB->terrainType, battlefieldType); + return VLC->obstacleHandler->absoluteObstacles[id].isAppropriate(curB->terrainType, battlefieldType); }; auto appropriateUsualObstacle = [&](int id) -> bool { - return VLC->obstacleHandler->obstacles[id].getInfo()->isAppropriate(curB->terrainType, battlefieldType); + return VLC->obstacleHandler->obstacles[id].isAppropriate(curB->terrainType, battlefieldType); }; if(r.rand(1,100) <= 40) //put cliff-like obstacle @@ -275,7 +275,7 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, const Terrain & terrain, for(BattleHex blocked : obstPtr->getBlockedTiles()) blockedTiles.push_back(blocked); - tilesToBlock -= (int)VLC->obstacleHandler->absoluteObstacles[obstPtr->ID].getInfo()->blockedTiles.size() / 2; + tilesToBlock -= (int)VLC->obstacleHandler->absoluteObstacles[obstPtr->ID].blockedTiles.size() / 2; } catch(RangeGenerator::ExhaustedPossibilities &) { @@ -291,7 +291,7 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, const Terrain & terrain, { auto tileAccessibility = curB->getAccesibility(); const int obid = obidgen.getSuchNumber(appropriateUsualObstacle); - const ObstacleInfo &obi = *VLC->obstacleHandler->obstacles[obid].getInfo(); + const ObstacleInfo &obi = VLC->obstacleHandler->obstacles[obid]; auto validPosition = [&](BattleHex pos) -> bool { diff --git a/lib/battle/CObstacleInstance.cpp b/lib/battle/CObstacleInstance.cpp index 4cc0f4b3b..d70a3e78e 100644 --- a/lib/battle/CObstacleInstance.cpp +++ b/lib/battle/CObstacleInstance.cpp @@ -35,9 +35,9 @@ const ObstacleInfo & CObstacleInstance::getInfo() const switch(obstacleType) { case ABSOLUTE_OBSTACLE: - return *VLC->obstacleHandler->absoluteObstacles[ID].getInfo(); + return VLC->obstacleHandler->absoluteObstacles[ID]; case USUAL: - return *VLC->obstacleHandler->obstacles[ID].getInfo(); + return VLC->obstacleHandler->obstacles[ID]; default: throw std::runtime_error("Unknown obstacle type in CObstacleInstance::getInfo()"); }