From 7f276185bd3db5e436b7473d0f81ae13bfda82ce Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sat, 24 May 2014 02:07:54 +0300 Subject: [PATCH] Moving files: - new config for objects (config/objects/generic.json) - renamed lib/CDefObjectHandler to lib/CObjectClassesHandler --- AI/VCAI/VCAI.h | 2 +- CCallback.cpp | 2 +- client/CMT.cpp | 2 +- client/CPlayerInterface.cpp | 2 +- client/CPreGame.cpp | 2 +- client/Client.cpp | 2 +- client/Graphics.cpp | 2 +- client/NetPacksClient.cpp | 2 +- client/mapHandler.cpp | 2 +- config/objects/generic.json | 168 ++++++++++++++++++ lib/CGameState.cpp | 2 +- lib/CMakeLists.txt | 2 +- lib/CModHandler.cpp | 2 +- ...oHandler.cpp => CObjectClassesHandler.cpp} | 10 +- ...jInfoHandler.h => CObjectClassesHandler.h} | 2 +- lib/CObjectConstructor.h | 2 +- lib/CObjectHandler.cpp | 4 +- lib/CObjectHandler.h | 2 +- lib/CTownHandler.cpp | 2 +- lib/GameConstants.cpp | 2 +- lib/IGameCallback.cpp | 2 +- lib/NetPacksLib.cpp | 2 +- lib/VCMI_Lib.cpp | 2 +- lib/mapping/CMap.cpp | 128 ++++++------- lib/mapping/CMapEditManager.cpp | 2 +- lib/mapping/MapFormatH3M.cpp | 4 +- lib/mapping/MapFormatH3M.h | 2 +- lib/registerTypes/RegisterTypes.cpp | 2 +- lib/registerTypes/TypesClientPacks1.cpp | 2 +- lib/registerTypes/TypesClientPacks2.cpp | 2 +- lib/registerTypes/TypesMapObjects1.cpp | 2 +- lib/registerTypes/TypesMapObjects2.cpp | 2 +- lib/registerTypes/TypesPregamePacks.cpp | 2 +- lib/registerTypes/TypesServerPacks.cpp | 2 +- lib/rmg/CMapGenerator.cpp | 2 +- server/CGameHandler.cpp | 2 +- server/CVCMIServer.cpp | 2 +- 37 files changed, 274 insertions(+), 104 deletions(-) create mode 100644 config/objects/generic.json rename lib/{CDefObjInfoHandler.cpp => CObjectClassesHandler.cpp} (95%) rename lib/{CDefObjInfoHandler.h => CObjectClassesHandler.h} (96%) diff --git a/AI/VCAI/VCAI.h b/AI/VCAI/VCAI.h index 1faedb19d..eaefd1234 100644 --- a/AI/VCAI/VCAI.h +++ b/AI/VCAI/VCAI.h @@ -4,7 +4,7 @@ #include "Goals.h" #include "../../lib/AI_Base.h" #include "../../CCallback.h" -#include "../../lib/CDefObjInfoHandler.h" +#include "../../lib/CObjectClassesHandler.h" #include "../../lib/CThreadHelper.h" diff --git a/CCallback.cpp b/CCallback.cpp index fb5e807d2..ccf876ff8 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -9,7 +9,7 @@ #include "client/Client.h" #include "lib/mapping/CMap.h" #include "lib/CBuildingHandler.h" -#include "lib/CDefObjInfoHandler.h" +#include "lib/CObjectClassesHandler.h" #include "lib/CGeneralTextHandler.h" #include "lib/CHeroHandler.h" #include "lib/CObjectHandler.h" diff --git a/client/CMT.cpp b/client/CMT.cpp index aa6ce1ae8..816557786 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -44,7 +44,7 @@ #ifdef _WIN32 #include "SDL_syswm.h" #endif -#include "../lib/CDefObjInfoHandler.h" +#include "../lib/CObjectClassesHandler.h" #include "../lib/UnlockGuard.h" #include "CMT.h" diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 789c49a1e..997a14813 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1,5 +1,5 @@ #include "StdInc.h" -#include "../lib/CDefObjInfoHandler.h" +#include "../lib/CObjectClassesHandler.h" #include "CAdvmapInterface.h" #include "battle/CBattleInterface.h" #include "battle/CBattleInterfaceClasses.h" diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 04f2aed07..8b4f2b743 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -11,7 +11,7 @@ #include "gui/CCursorHandler.h" #include "CAnimation.h" #include "CDefHandler.h" -#include "../lib/CDefObjInfoHandler.h" +#include "../lib/CObjectClassesHandler.h" #include "../lib/CGeneralTextHandler.h" #include "../lib/CTownHandler.h" #include "../lib/CHeroHandler.h" diff --git a/client/Client.cpp b/client/Client.cpp index d0e9bba1b..1d1153179 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -11,7 +11,7 @@ #include "../lib/BattleState.h" #include "../lib/CModHandler.h" #include "../lib/CArtHandler.h" -#include "../lib/CDefObjInfoHandler.h" +#include "../lib/CObjectClassesHandler.h" #include "../lib/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/CTownHandler.h" diff --git a/client/Graphics.cpp b/client/Graphics.cpp index f9bebafb1..b758cc523 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -18,7 +18,7 @@ #include "CBitmapHandler.h" #include "../lib/CObjectHandler.h" #include "../lib/CSpellHandler.h" -#include "../lib/CDefObjInfoHandler.h" +#include "../lib/CObjectClassesHandler.h" #include "../lib/CGameState.h" #include "../lib/JsonNode.h" #include "../lib/vcmi_endian.h" diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 48a27020c..c41170dc7 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -9,7 +9,7 @@ #include "CGameInfo.h" #include "../lib/Connection.h" #include "../lib/CGeneralTextHandler.h" -#include "../lib/CDefObjInfoHandler.h" +#include "../lib/CObjectClassesHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/CObjectHandler.h" #include "../lib/VCMI_Lib.h" diff --git a/client/mapHandler.cpp b/client/mapHandler.cpp index efb2cfc01..1301f5082 100644 --- a/client/mapHandler.cpp +++ b/client/mapHandler.cpp @@ -4,7 +4,7 @@ #include "CBitmapHandler.h" #include "gui/SDL_Extensions.h" #include "CGameInfo.h" -#include "../lib/CDefObjInfoHandler.h" +#include "../lib/CObjectClassesHandler.h" #include "../lib/CGameState.h" #include "../lib/CHeroHandler.h" #include "../lib/CTownHandler.h" diff --git a/config/objects/generic.json b/config/objects/generic.json new file mode 100644 index 000000000..03258aca1 --- /dev/null +++ b/config/objects/generic.json @@ -0,0 +1,168 @@ +{ + "altarOfSacrifice" : { "id" :2, "handler": "market" }, + "arena" : { "id" :4, "handler": "oncePerHero" }, + "artifact" : { "id" :5, "handler": "artifact" }, + "pandoraBox" : { "id" :6, "handler": "pandora" }, + "blackMarket" : { "id" :7, "handler": "blackMarket" }, + "boat" : { "id" :8, "handler": "boat" }, + "borderGuard" : { "id" :9, "handler": "borderGuard" }, + "keymasterTent" : { "id" :10, "handler": "keymaster" }, + "buoy" : { "id" :11, "handler": "bonusingObject" }, + "campfire" : { "id" :12, "handler": "pickable" }, + "cartographer" : { "id" :13, "handler": "cartographer" }, + "swanPond" : { "id" :14, "handler": "bonusingObject" }, + "coverOfDarkness" : { "id" :15, "handler": "observatory" }, + "creatureBank" : { "id" :16, "handler": "bank" }, + "creatureGeneratorCommon" : { "id" :17, "handler": "dwelling" }, + "creatureGeneratorSpecial" : { "id" :20, "handler": "dwelling" }, + "cursedGround" : { "id" :21, "handler": "generic" }, + "corpse" : { "id" :22, "handler": "onceVisitable" }, + "marlettoTower" : { "id" :23, "handler": "oncePerHero" }, + "derelictShip" : { "id" :24, "handler": "bank" }, + "dragonUtopia" : { "id" :25, "handler": "bank" }, + "event" : { "id" :26, "handler": "event" }, + "eyeOfTheMagi" : { "id" :27, "handler": "magi" }, + "faerieRing" : { "id" :28, "handler": "bonusingObject" }, + "flotsam" : { "id" :29, "handler": "pickable" }, + "fountainOfFortune" : { "id" :30, "handler": "bonusingObject" }, + "fountainOfYouth" : { "id" :31, "handler": "bonusingObject" }, + "gardenOfRevelation" : { "id" :32, "handler": "oncePerHero" }, + "garrison" : { "id" :33, "handler": "garrison" }, + "hero" : { "id" :34, "handler": "hero" }, + "hillFort" : { "id" :35, "handler": "generic" }, + "grail" : { "id" :36, "handler": "generic" }, + "hutOfTheMagi" : { "id" :37, "handler": "magi" }, + "idolOfFortune" : { "id" :38, "handler": "bonusingObject" }, + "leanTo" : { "id" :39, "handler": "onceVisitable" }, + "libraryOfEnlightenment" : { "id" :41, "handler": "oncePerHero" }, + "lighthouse" : { "id" :42, "handler": "lighthouse" }, + "monolithOneWayEntrance" : { "id" :43, "handler": "teleport" }, + "monolithOneWayExit" : { "id" :44, "handler": "teleport" }, + "monolithTwoWay" : { "id" :45, "handler": "teleport" }, + "magicPlains" : { "id" :46, "handler": "generic" }, + "schoolOfMagic" : { "id" :47, "handler": "oncePerHero" }, + "magicSpring" : { "id" :48, "handler": "magicSpring" }, + "magicWell" : { "id" :49, "handler": "magicWell" }, + "mercenaryCamp" : { "id" :51, "handler": "oncePerHero" }, + "mermaids" : { "id" :52, "handler": "bonusingObject" }, + "mine" : { "id" :53, "handler": "mine" }, + "monster" : { "id" :54, "handler": "monster" }, + "mysticalGarden" : { "id" :55, "handler": "oncePerWeek" }, + "oasis" : { "id" :56, "handler": "bonusingObject" }, + "obelisk" : { "id" :57, "handler": "obelisk" }, + "redwoodObservatory" : { "id" :58, "handler": "observatory" }, + "oceanBottle" : { "id" :59, "handler": "sign" }, + "pillarOfFire" : { "id" :60, "handler": "observatory" }, + "starAxis" : { "id" :61, "handler": "oncePerHero" }, + "prison" : { "id" :62, "handler": "hero" }, + "pyramid" : { "id" :63, "handler": "pyramid" }, + "rallyFlag" : { "id" :64, "handler": "bonusingObject" }, + "randomArtifact" : { "id" :65, "handler": "artifact" }, + "randomArtifactTreasure" : { "id" :66, "handler": "artifact" }, + "randomArtifactMinor" : { "id" :67, "handler": "artifact" }, + "randomArtifactMajor" : { "id" :68, "handler": "artifact" }, + "randomArtifactRelic" : { "id" :69, "handler": "artifact" }, + "randomHero" : { "id" :70, "handler": "hero" }, + "randomMonster" : { "id" :71, "handler": "monster" }, + "randomMonsterLevel1" : { "id" :72, "handler": "monster" }, + "randomMonsterLevel2" : { "id" :73, "handler": "monster" }, + "randomMonsterLevel3" : { "id" :74, "handler": "monster" }, + "randomMonsterLevel4" : { "id" :75, "handler": "monster" }, + "randomResource" : { "id" :76, "handler": "resource" }, + "randomTown" : { "id" :77, "handler": "town" }, + "refugeeCamp" : { "id" :78, "handler": "dwelling" }, + "resource" : { "id" :79, "handler": "resource" }, + "sanctuary" : { "id" :80, "handler": "generic" }, + "scholar" : { "id" :81, "handler": "scholar" }, + "seaChest" : { "id" :82, "handler": "pickable" }, + "seerHut" : { "id" :83, "handler": "seerHut" }, + "crypt" : { "id" :84, "handler": "bank" }, + "shipwreck" : { "id" :85, "handler": "bank" }, + "shipwreckSurvivor" : { "id" :86, "handler": "pickable" }, + "shipyard" : { "id" :87, "handler": "shipyard" }, + "shrineOfMagicLevel1" : { "id" :88, "handler": "shrine" }, + "shrineOfMagicLevel2" : { "id" :89, "handler": "shrine" }, + "shrineOfMagicLevel3" : { "id" :90, "handler": "shrine" }, + "sign" : { "id" :91, "handler": "sign" }, + "sirens" : { "id" :92, "handler": "siren" }, + "spellScroll" : { "id" :93, "handler": "artifact" }, + "stables" : { "id" :94, "handler": "bonusingObject" }, + "tavern" : { "id" :95, "handler": "generic" }, + "temple" : { "id" :96, "handler": "bonusingObject" }, + "denOfThieves" : { "id" :97, "handler": "denOfThieves" }, + "town" : { "id" :98, "handler": "town" }, + "tradingPost" : { "id" :99, "handler": "market" }, + "learningStone" : { "id" :100, "handler": "oncePerHero" }, + "treasureChest" : { "id" :101, "handler": "pickable" }, + "treeOfKnowledge" : { "id" :102, "handler": "oncePerHero" }, + "subterraneanGate" : { "id" :103, "handler": "teleport" }, + "university" : { "id" :104, "handler": "university" }, + "wagon" : { "id" :105, "handler": "onceVisitable" }, + "warMachineFactory" : { "id" :106, "handler": "dwelling" }, + "schoolOfWar" : { "id" :107, "handler": "oncePerHero" }, + "warriorTomb" : { "id" :108, "handler": "onceVisitable" }, + "waterWheel" : { "id" :109, "handler": "oncePerWeek" }, + "wateringHole" : { "id" :110, "handler": "bonusingObject" }, + "whirlpool" : { "id" :111, "handler": "teleport" }, + "windmill" : { "id" :112, "handler": "oncePerWeek" }, + "witchHut" : { "id" :113, "handler": "witch" }, + "cactus" : { "id" :116, "handler": "generic" }, + "canyon" : { "id" :117, "handler": "generic" }, + "crater" : { "id" :118, "handler": "generic" }, + "deadVegetation" : { "id" :119, "handler": "generic" }, + "flowers" : { "id" :120, "handler": "generic" }, + "frozenLake" : { "id" :121, "handler": "generic" }, + "hole" : { "id" :124, "handler": "generic" }, + "kelp" : { "id" :125, "handler": "generic" }, + "lake" : { "id" :126, "handler": "generic" }, + "lavaFlow" : { "id" :127, "handler": "generic" }, + "lavaLake" : { "id" :128, "handler": "generic" }, + "mushrooms" : { "id" :129, "handler": "generic" }, + "log" : { "id" :130, "handler": "generic" }, + "mandrake" : { "id" :131, "handler": "generic" }, + "moss" : { "id" :132, "handler": "generic" }, + "mound" : { "id" :133, "handler": "generic" }, + "mountain" : { "id" :134, "handler": "generic" }, + "oakTrees" : { "id" :135, "handler": "generic" }, + "outcropping" : { "id" :136, "handler": "generic" }, + "pineTrees" : { "id" :137, "handler": "generic" }, + "riverDelta" : { "id" :143, "handler": "generic" }, + "rock" : { "id" :147, "handler": "generic" }, + "sandDune" : { "id" :148, "handler": "generic" }, + "sandPit" : { "id" :149, "handler": "generic" }, + "shrub" : { "id" :150, "handler": "generic" }, + "skull" : { "id" :151, "handler": "generic" }, + "stump" : { "id" :153, "handler": "generic" }, + "trees" : { "id" :155, "handler": "generic" }, + "volcano" : { "id" :158, "handler": "generic" }, + "reef" : { "id" :161, "handler": "generic" }, + "randomMonsterLevel5" : { "id" :162, "handler": "monster" }, + "randomMonsterLevel6" : { "id" :163, "handler": "monster" }, + "randomMonsterLevel7" : { "id" :164, "handler": "monster" }, + "lake" : { "id" :177, "handler": "generic" }, + "trees" : { "id" :199, "handler": "generic" }, + "desertHills" : { "id" :206, "handler": "generic" }, + "dirtHills" : { "id" :207, "handler": "generic" }, + "grassHills" : { "id" :208, "handler": "generic" }, + "roughHills" : { "id" :209, "handler": "generic" }, + "subterraneanRocks" : { "id" :210, "handler": "generic" }, + "swampFoliage" : { "id" :211, "handler": "generic" }, + "borderGate" : { "id" :212, "handler": "borderGate" }, + "freelancer'SGuild" : { "id" :213, "handler": "market" }, + "heroPlaceholder" : { "id" :214, "handler": "heroPlaceholder" }, + "questGuard" : { "id" :215, "handler": "questGuard" }, + "randomDwelling" : { "id" :216, "handler": "dwelling" }, + "garrison" : { "id" :219, "handler": "garrison" }, + "mine" : { "id" :220, "handler": "mine" }, + "tradingPost" : { "id" :221, "handler": "market" }, + "cloverField" : { "id" :222, "handler": "generic" }, + "cursedGround" : { "id" :223, "handler": "generic" }, + "evilFog" : { "id" :224, "handler": "generic" }, + "favorableWinds" : { "id" :225, "handler": "generic" }, + "fieryFields" : { "id" :226, "handler": "generic" }, + "holyGround" : { "id" :227, "handler": "generic" }, + "lucidPools" : { "id" :228, "handler": "generic" }, + "magicClouds" : { "id" :229, "handler": "generic" }, + "magicPlains" : { "id" :230, "handler": "generic" }, + "rocklands" : { "id" :231, "handler": "generic" } +} diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index fa83a1bf9..5649705c1 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -2,7 +2,7 @@ #include "CGameState.h" #include "mapping/CCampaignHandler.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "CArtHandler.h" #include "CBuildingHandler.h" #include "CGeneralTextHandler.h" diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a4010b48b..f612854b9 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -62,7 +62,7 @@ set(lib_SRCS CConsoleHandler.cpp CCreatureHandler.cpp CCreatureSet.cpp - CDefObjInfoHandler.cpp + CObjectClassesHandler.cpp CGameInterface.cpp CGeneralTextHandler.cpp CHeroHandler.cpp diff --git a/lib/CModHandler.cpp b/lib/CModHandler.cpp index bfb529db7..b1685df8b 100644 --- a/lib/CModHandler.cpp +++ b/lib/CModHandler.cpp @@ -1,6 +1,6 @@ #include "StdInc.h" #include "CModHandler.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "JsonNode.h" #include "filesystem/Filesystem.h" #include "filesystem/AdapterLoaders.h" diff --git a/lib/CDefObjInfoHandler.cpp b/lib/CObjectClassesHandler.cpp similarity index 95% rename from lib/CDefObjInfoHandler.cpp rename to lib/CObjectClassesHandler.cpp index a100a6456..0d2302cf4 100644 --- a/lib/CDefObjInfoHandler.cpp +++ b/lib/CObjectClassesHandler.cpp @@ -1,5 +1,5 @@ #include "StdInc.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "filesystem/Filesystem.h" #include "filesystem/CBinaryReader.h" @@ -14,7 +14,7 @@ #include "CObjectConstructor.h" /* - * CDefObjInfoHandler.cpp, part of VCMI engine + * CObjectClassesHandler.cpp, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * @@ -331,7 +331,7 @@ bool ObjectTemplate::canBePlacedAt(ETerrainType terrain) const return allowedTerrains.count(terrain) != 0; } /* -void CDefObjInfoHandler::readTextFile(std::string path) +void CObjectClassesHandler::readTextFile(std::string path) { CLegacyConfigParser parser(path); size_t totalNumber = parser.readNumber(); // first line contains number of objects to read and nothing else @@ -346,7 +346,7 @@ void CDefObjInfoHandler::readTextFile(std::string path) } } -CDefObjInfoHandler::CDefObjInfoHandler() +CObjectClassesHandler::CObjectClassesHandler() { readTextFile("Data/Objects.txt"); readTextFile("Data/Heroes.txt"); @@ -464,10 +464,12 @@ CObjectClassesHandler::ObjectContainter * CObjectClassesHandler::loadFromJson(co void CObjectClassesHandler::loadObject(std::string scope, std::string name, const JsonNode & data) { + } void CObjectClassesHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) { + } std::vector CObjectClassesHandler::getDefaultAllowed() const diff --git a/lib/CDefObjInfoHandler.h b/lib/CObjectClassesHandler.h similarity index 96% rename from lib/CDefObjInfoHandler.h rename to lib/CObjectClassesHandler.h index 6911eaed5..1632c2f04 100644 --- a/lib/CDefObjInfoHandler.h +++ b/lib/CObjectClassesHandler.h @@ -5,7 +5,7 @@ #include "IHandlerBase.h" /* - * CDefObjInfoHandler.h, part of VCMI engine + * CObjectClassesHandler.h, part of VCMI engine * * Authors: listed in file AUTHORS in main folder * diff --git a/lib/CObjectConstructor.h b/lib/CObjectConstructor.h index 8c080b44b..31dcf76b1 100644 --- a/lib/CObjectConstructor.h +++ b/lib/CObjectConstructor.h @@ -1,7 +1,7 @@ #pragma once #include "CObjectWithReward.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "JsonNode.h" /* diff --git a/lib/CObjectHandler.cpp b/lib/CObjectHandler.cpp index 885d5c28e..60c3adba6 100644 --- a/lib/CObjectHandler.cpp +++ b/lib/CObjectHandler.cpp @@ -11,9 +11,9 @@ #include "StdInc.h" #include "CObjectHandler.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "CGeneralTextHandler.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "CHeroHandler.h" #include "CSpellHandler.h" #include "CModHandler.h" diff --git a/lib/CObjectHandler.h b/lib/CObjectHandler.h index 102b46f28..a5d21b0cd 100644 --- a/lib/CObjectHandler.h +++ b/lib/CObjectHandler.h @@ -2,7 +2,7 @@ #include "../lib/CCreatureSet.h" #include "../lib/CTownHandler.h" -#include "../lib/CDefObjInfoHandler.h" +#include "../lib/CObjectClassesHandler.h" #include "CArtHandler.h" #include "../lib/ConstTransitivePtr.h" #include "int3.h" diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 0846efdd4..0735b7d83 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -11,7 +11,7 @@ #include "CArtHandler.h" #include "CSpellHandler.h" #include "filesystem/Filesystem.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "CObjectHandler.h" /* diff --git a/lib/GameConstants.cpp b/lib/GameConstants.cpp index 82bb431a1..4d9b9239d 100644 --- a/lib/GameConstants.cpp +++ b/lib/GameConstants.cpp @@ -13,7 +13,7 @@ #include "StdInc.h" #include "VCMI_Lib.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "CArtHandler.h" #include "CCreatureHandler.h" #include "CSpellHandler.h" diff --git a/lib/IGameCallback.cpp b/lib/IGameCallback.cpp index cd47cc630..79e643b4b 100644 --- a/lib/IGameCallback.cpp +++ b/lib/IGameCallback.cpp @@ -25,7 +25,7 @@ #include "CBuildingHandler.h" #include "GameConstants.h" #include "CModHandler.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "CBonusTypeHandler.h" #include "Connection.h" diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 9afc62ecb..f715b06ad 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -2,7 +2,7 @@ #include "NetPacks.h" #include "CGeneralTextHandler.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "CArtHandler.h" #include "CHeroHandler.h" #include "CObjectHandler.h" diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp index ab644757a..c8e277332 100644 --- a/lib/VCMI_Lib.cpp +++ b/lib/VCMI_Lib.cpp @@ -14,7 +14,7 @@ #include "CArtHandler.h" #include "CBonusTypeHandler.h" #include "CCreatureHandler.h" -#include "CDefObjInfoHandler.h" +#include "CObjectClassesHandler.h" #include "CHeroHandler.h" #include "CObjectHandler.h" #include "CTownHandler.h" diff --git a/lib/mapping/CMap.cpp b/lib/mapping/CMap.cpp index c6b190fce..2000e2451 100644 --- a/lib/mapping/CMap.cpp +++ b/lib/mapping/CMap.cpp @@ -6,7 +6,7 @@ #include "../CCreatureHandler.h" #include "../CTownHandler.h" #include "../CHeroHandler.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" #include "../CGeneralTextHandler.h" #include "../CSpellHandler.h" #include "CMapEditManager.h" @@ -336,72 +336,72 @@ bool CMap::isWaterTile(const int3 &pos) const return isInTheMap(pos) && getTile(pos).terType == ETerrainType::WATER; } -bool CMap::checkForVisitableDir(const int3 & src, const TerrainTile *pom, const int3 & dst ) const -{ - for(ui32 b=0; bvisitableObjects.size(); ++b) //checking destination tile - { - if(!vstd::contains(pom->blockingObjects, pom->visitableObjects[b])) //this visitable object is not blocking, ignore - continue; - - const CGObjectInstance * obj = pom->visitableObjects[b]; - - if (!obj->appearance.isVisitableFrom(src.x - dst.x, src.y - dst.y)) - return false; - } - return true; +bool CMap::checkForVisitableDir(const int3 & src, const TerrainTile *pom, const int3 & dst ) const +{ + for(ui32 b=0; bvisitableObjects.size(); ++b) //checking destination tile + { + if(!vstd::contains(pom->blockingObjects, pom->visitableObjects[b])) //this visitable object is not blocking, ignore + continue; + + const CGObjectInstance * obj = pom->visitableObjects[b]; + + if (!obj->appearance.isVisitableFrom(src.x - dst.x, src.y - dst.y)) + return false; + } + return true; } int3 CMap::guardingCreaturePosition (int3 pos) const -{ - - const int3 originalPos = pos; - // Give monster at position priority. - if (!isInTheMap(pos)) - return int3(-1, -1, -1); - const TerrainTile &posTile = getTile(pos); - if (posTile.visitable) - { - for (CGObjectInstance* obj : posTile.visitableObjects) - { - if(obj->blockVisit) - { - if (obj->ID == Obj::MONSTER) // Monster - return pos; - else - return int3(-1, -1, -1); //blockvis objects are not guarded by neighbouring creatures - } - } - } - - // See if there are any monsters adjacent. - bool water = posTile.isWater(); - - pos -= int3(1, 1, 0); // Start with top left. - for (int dx = 0; dx < 3; dx++) - { - for (int dy = 0; dy < 3; dy++) - { - if (isInTheMap(pos)) - { - const auto & tile = getTile(pos); - if (tile.visitable && (tile.isWater() == water)) - { - for (CGObjectInstance* obj : tile.visitableObjects) - { - if (obj->ID == Obj::MONSTER && checkForVisitableDir(pos, &posTile, originalPos)) // Monster being able to attack investigated tile - { - return pos; - } - } - } - } - - pos.y++; - } - pos.y -= 3; - pos.x++; - } - +{ + + const int3 originalPos = pos; + // Give monster at position priority. + if (!isInTheMap(pos)) + return int3(-1, -1, -1); + const TerrainTile &posTile = getTile(pos); + if (posTile.visitable) + { + for (CGObjectInstance* obj : posTile.visitableObjects) + { + if(obj->blockVisit) + { + if (obj->ID == Obj::MONSTER) // Monster + return pos; + else + return int3(-1, -1, -1); //blockvis objects are not guarded by neighbouring creatures + } + } + } + + // See if there are any monsters adjacent. + bool water = posTile.isWater(); + + pos -= int3(1, 1, 0); // Start with top left. + for (int dx = 0; dx < 3; dx++) + { + for (int dy = 0; dy < 3; dy++) + { + if (isInTheMap(pos)) + { + const auto & tile = getTile(pos); + if (tile.visitable && (tile.isWater() == water)) + { + for (CGObjectInstance* obj : tile.visitableObjects) + { + if (obj->ID == Obj::MONSTER && checkForVisitableDir(pos, &posTile, originalPos)) // Monster being able to attack investigated tile + { + return pos; + } + } + } + } + + pos.y++; + } + pos.y -= 3; + pos.x++; + } + return int3(-1, -1, -1); } diff --git a/lib/mapping/CMapEditManager.cpp b/lib/mapping/CMapEditManager.cpp index ef24689cd..9413b938c 100644 --- a/lib/mapping/CMapEditManager.cpp +++ b/lib/mapping/CMapEditManager.cpp @@ -3,7 +3,7 @@ #include "../JsonNode.h" #include "../filesystem/Filesystem.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" #include "../VCMI_Lib.h" MapRect::MapRect() : x(0), y(0), z(0), width(0), height(0) diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index 99bb4046f..80e4085cd 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/lib/mapping/MapFormatH3M.cpp @@ -21,8 +21,8 @@ #include "../CGeneralTextHandler.h" #include "../CHeroHandler.h" #include "../CObjectHandler.h" -#include "../CObjectWithReward.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectWithReward.h" +#include "../CObjectClassesHandler.h" #include "../VCMI_Lib.h" #include "../NetPacksBase.h" diff --git a/lib/mapping/MapFormatH3M.h b/lib/mapping/MapFormatH3M.h index 6a44449e0..0c61400a2 100644 --- a/lib/mapping/MapFormatH3M.h +++ b/lib/mapping/MapFormatH3M.h @@ -14,7 +14,7 @@ #include "CMapService.h" #include "../GameConstants.h" #include "../ResourceSet.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" #include "../int3.h" diff --git a/lib/registerTypes/RegisterTypes.cpp b/lib/registerTypes/RegisterTypes.cpp index 390fc320d..e3ffbdfd3 100644 --- a/lib/registerTypes/RegisterTypes.cpp +++ b/lib/registerTypes/RegisterTypes.cpp @@ -17,7 +17,7 @@ #include "../CTownHandler.h" #include "../mapping/CCampaignHandler.h" #include "../NetPacks.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" // For reference: peak memory usage by gcc during compilation of register type templates // registerTypesMapObjects: 1.9 Gb diff --git a/lib/registerTypes/TypesClientPacks1.cpp b/lib/registerTypes/TypesClientPacks1.cpp index 97e461493..44101ad82 100644 --- a/lib/registerTypes/TypesClientPacks1.cpp +++ b/lib/registerTypes/TypesClientPacks1.cpp @@ -16,7 +16,7 @@ #include "../CTownHandler.h" #include "../mapping/CCampaignHandler.h" #include "../NetPacks.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" template void registerTypesClientPacks1>(CISer& s); diff --git a/lib/registerTypes/TypesClientPacks2.cpp b/lib/registerTypes/TypesClientPacks2.cpp index be4b656b5..37e137992 100644 --- a/lib/registerTypes/TypesClientPacks2.cpp +++ b/lib/registerTypes/TypesClientPacks2.cpp @@ -16,7 +16,7 @@ #include "../CTownHandler.h" #include "../mapping/CCampaignHandler.h" #include "../NetPacks.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" template void registerTypesClientPacks2>(CISer& s); diff --git a/lib/registerTypes/TypesMapObjects1.cpp b/lib/registerTypes/TypesMapObjects1.cpp index 726ce6092..c0952f6ff 100644 --- a/lib/registerTypes/TypesMapObjects1.cpp +++ b/lib/registerTypes/TypesMapObjects1.cpp @@ -16,7 +16,7 @@ #include "../CTownHandler.h" #include "../mapping/CCampaignHandler.h" #include "../NetPacks.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" template void registerTypesMapObjects1>(CISer& s); diff --git a/lib/registerTypes/TypesMapObjects2.cpp b/lib/registerTypes/TypesMapObjects2.cpp index d77ed5822..197e2f5fe 100644 --- a/lib/registerTypes/TypesMapObjects2.cpp +++ b/lib/registerTypes/TypesMapObjects2.cpp @@ -16,7 +16,7 @@ #include "../CTownHandler.h" #include "../mapping/CCampaignHandler.h" #include "../NetPacks.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" template void registerTypesMapObjects2>(CISer& s); diff --git a/lib/registerTypes/TypesPregamePacks.cpp b/lib/registerTypes/TypesPregamePacks.cpp index 1fd97e76b..b4d73bf4f 100644 --- a/lib/registerTypes/TypesPregamePacks.cpp +++ b/lib/registerTypes/TypesPregamePacks.cpp @@ -16,7 +16,7 @@ #include "../CTownHandler.h" #include "../mapping/CCampaignHandler.h" #include "../NetPacks.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" template void registerTypesPregamePacks>(CISer& s); template void registerTypesPregamePacks>(COSer& s); diff --git a/lib/registerTypes/TypesServerPacks.cpp b/lib/registerTypes/TypesServerPacks.cpp index caabdcd1e..eff72a34e 100644 --- a/lib/registerTypes/TypesServerPacks.cpp +++ b/lib/registerTypes/TypesServerPacks.cpp @@ -16,7 +16,7 @@ #include "../CTownHandler.h" #include "../mapping/CCampaignHandler.h" #include "../NetPacks.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" template void registerTypesServerPacks>(CISer& s); template void registerTypesServerPacks>(COSer& s); diff --git a/lib/rmg/CMapGenerator.cpp b/lib/rmg/CMapGenerator.cpp index d0c9308b0..fa45e4d78 100644 --- a/lib/rmg/CMapGenerator.cpp +++ b/lib/rmg/CMapGenerator.cpp @@ -17,7 +17,7 @@ #include "../CGeneralTextHandler.h" #include "../mapping/CMapEditManager.h" #include "../CObjectHandler.h" -#include "../CDefObjInfoHandler.h" +#include "../CObjectClassesHandler.h" #include "../CTownHandler.h" #include "../StringConstants.h" #include "CRmgTemplate.h" diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 34db00278..c257a02ed 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -8,7 +8,7 @@ #include "../lib/CModHandler.h" #include "../lib/CArtHandler.h" #include "../lib/CBuildingHandler.h" -#include "../lib/CDefObjInfoHandler.h" +#include "../lib/CObjectClassesHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/CObjectHandler.h" #include "../lib/CSpellHandler.h" diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index e1e47c6f4..f5851ea45 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -8,7 +8,7 @@ #include "../lib/Connection.h" #include "../lib/CModHandler.h" #include "../lib/CArtHandler.h" -#include "../lib/CDefObjInfoHandler.h" +#include "../lib/CObjectClassesHandler.h" #include "../lib/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/CTownHandler.h"