From ed798b06da81961dc152c073c3e02990c9d26e8a Mon Sep 17 00:00:00 2001 From: nordsoft Date: Tue, 18 Apr 2023 13:04:49 +0400 Subject: [PATCH] Prepare transport enum --- AI/Nullkiller/AIUtility.cpp | 4 ++-- AI/Nullkiller/Analyzers/ObjectClusterizer.cpp | 2 +- AI/VCAI/AIUtility.cpp | 2 +- AI/VCAI/VCAI.cpp | 2 +- client/CPlayerInterface.cpp | 4 ++-- client/adventureMap/CAdvMapInt.cpp | 4 ++-- client/mapView/MapRenderer.cpp | 11 ++++----- client/mapView/MapRendererContext.cpp | 2 +- client/mapView/MapViewController.cpp | 2 +- client/windows/CCastleInterface.cpp | 2 +- client/windows/GUIClasses.cpp | 4 ++-- client/windows/GUIClasses.h | 2 +- lib/CPathfinder.cpp | 6 ++--- lib/GameConstants.h | 23 ++++++++++++++++++- lib/NetPacksLib.cpp | 6 ++--- lib/mapObjects/CGHeroInstance.cpp | 14 ++++------- lib/mapObjects/CGHeroInstance.h | 2 +- lib/mapObjects/CGTownInstance.cpp | 11 ++++----- lib/mapObjects/CGTownInstance.h | 2 +- lib/mapObjects/CObjectHandler.cpp | 8 +++---- lib/mapObjects/CObjectHandler.h | 2 +- lib/mapObjects/ObjectTemplate.cpp | 2 +- lib/rmg/WaterProxy.cpp | 4 ++-- lib/spells/AdventureSpellMechanics.cpp | 8 +++---- mapeditor/mainwindow.cpp | 2 +- mapeditor/maphandler.cpp | 2 +- server/CGameHandler.cpp | 8 +++---- 27 files changed, 78 insertions(+), 63 deletions(-) diff --git a/AI/Nullkiller/AIUtility.cpp b/AI/Nullkiller/AIUtility.cpp index e3f683a09..4adb89f68 100644 --- a/AI/Nullkiller/AIUtility.cpp +++ b/AI/Nullkiller/AIUtility.cpp @@ -228,7 +228,7 @@ bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater) } else if(!fromWater) // do not try to board when in water sector { - if(t->visitableObjects.size() == 1 && t->topVisitableId() == Obj::BOAT) + if(t->visitableObjects.size() == 1 && t->topVisitableId() == Obj::TRANSPORT) return true; } return false; @@ -450,7 +450,7 @@ bool shouldVisit(const Nullkiller * ai, const CGHeroInstance * h, const CGObject return ai->cb->getHeroesInfo().size() < VLC->settings()->getInteger(EGameSettings::HEROES_PER_PLAYER_ON_MAP_CAP); case Obj::TAVERN: case Obj::EYE_OF_MAGI: - case Obj::BOAT: + case Obj::TRANSPORT: case Obj::SIGN: return false; } diff --git a/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp b/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp index 88db0921a..18c80d58f 100644 --- a/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp +++ b/AI/Nullkiller/Analyzers/ObjectClusterizer.cpp @@ -193,7 +193,7 @@ void ObjectClusterizer::clusterize() blockedObjects.clear(); Obj ignoreObjects[] = { - Obj::BOAT, + Obj::TRANSPORT, Obj::EYE_OF_MAGI, Obj::MONOLITH_ONE_WAY_ENTRANCE, Obj::MONOLITH_ONE_WAY_EXIT, diff --git a/AI/VCAI/AIUtility.cpp b/AI/VCAI/AIUtility.cpp index c90b878c0..500fa7b0e 100644 --- a/AI/VCAI/AIUtility.cpp +++ b/AI/VCAI/AIUtility.cpp @@ -198,7 +198,7 @@ bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater) } else if(!fromWater) // do not try to board when in water sector { - if(t->visitableObjects.size() == 1 && t->topVisitableId() == Obj::BOAT) + if(t->visitableObjects.size() == 1 && t->topVisitableId() == Obj::TRANSPORT) return true; } return false; diff --git a/AI/VCAI/VCAI.cpp b/AI/VCAI/VCAI.cpp index db4bd6b65..7079fc0f8 100644 --- a/AI/VCAI/VCAI.cpp +++ b/AI/VCAI/VCAI.cpp @@ -2868,7 +2868,7 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj) return false; break; } - case Obj::BOAT: + case Obj::TRANSPORT: return false; //Boats are handled by pathfinder case Obj::EYE_OF_MAGI: diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 5aa6801bf..fa9993ca3 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1490,14 +1490,14 @@ void CPlayerInterface::showShipyardDialog(const IShipyard *obj) auto state = obj->shipyardStatus(); TResources cost; obj->getBoatCost(cost); - GH.pushIntT(cost, state, obj->getBoatType(), [=](){ cb->buildBoat(obj); }); + GH.pushIntT(cost, state, obj->getTransportType(), [=](){ cb->buildBoat(obj); }); } void CPlayerInterface::newObject( const CGObjectInstance * obj ) { EVENT_HANDLER_CALLED_BY_CLIENT; //we might have built a boat in shipyard in opened town screen - if (obj->ID == Obj::BOAT + if (obj->ID == Obj::TRANSPORT && LOCPLINT->castleInt && obj->visitablePos() == LOCPLINT->castleInt->town->bestLocation()) { diff --git a/client/adventureMap/CAdvMapInt.cpp b/client/adventureMap/CAdvMapInt.cpp index e9f1d7b4a..39ffcb90d 100644 --- a/client/adventureMap/CAdvMapInt.cpp +++ b/client/adventureMap/CAdvMapInt.cpp @@ -1083,7 +1083,7 @@ void CAdvMapInt::onTileLeftClicked(const int3 &mapPos) switch(spellBeingCasted->id) { case SpellID::SCUTTLE_BOAT: //Scuttle Boat - if(topBlocking && topBlocking->ID == Obj::BOAT) + if(topBlocking && topBlocking->ID == Obj::TRANSPORT) leaveCastingMode(true, mapPos); break; case SpellID::DIMENSION_DOOR: @@ -1179,7 +1179,7 @@ void CAdvMapInt::onTileHovered(const int3 &mapPos) switch(spellBeingCasted->id) { case SpellID::SCUTTLE_BOAT: - if(objAtTile && objAtTile->ID == Obj::BOAT) + if(objAtTile && objAtTile->ID == Obj::TRANSPORT) CCS->curh->set(Cursor::Map::SCUTTLE_BOAT); else CCS->curh->set(Cursor::Map::POINTER); diff --git a/client/mapView/MapRenderer.cpp b/client/mapView/MapRenderer.cpp index 0e1c69020..c6b4a6925 100644 --- a/client/mapView/MapRenderer.cpp +++ b/client/mapView/MapRenderer.cpp @@ -392,7 +392,7 @@ std::shared_ptr MapRendererObjects::getBaseAnimation(const CGObjectI return std::shared_ptr(); } - bool generateMovementGroups = (info->id == Obj::BOAT) || (info->id == Obj::HERO); + bool generateMovementGroups = (info->id == Obj::TRANSPORT) || (info->id == Obj::HERO); //TODO: relocate to config file? // Boat appearance files only contain single, unanimated image @@ -401,7 +401,7 @@ std::shared_ptr MapRendererObjects::getBaseAnimation(const CGObjectI "AB01_.def", "AB02_.def", "AB03_.def" }; - if (info->id == Obj::BOAT) + if (info->id == Obj::TRANSPORT && info->subid < boatAnimations.size()) return getAnimation(boatAnimations[info->subid], generateMovementGroups); return getAnimation(info->animationFile, generateMovementGroups); @@ -452,11 +452,10 @@ std::shared_ptr MapRendererObjects::getFlagAnimation(const CGObjectI return getAnimation(heroFlags[obj->tempOwner.getNum()], true); } - if(obj->ID == Obj::BOAT) + if(obj->ID == Obj::TRANSPORT) { const auto * boat = dynamic_cast(obj); - assert(boat->subID < boatFlags.size()); - if (boat->hero) + if(boat->hero && boat->subID < boatFlags.size()) { assert(boat->hero->tempOwner.isValidPlayer()); return getAnimation(boatFlags[boat->subID][boat->hero->tempOwner.getNum()], true); @@ -468,7 +467,7 @@ std::shared_ptr MapRendererObjects::getFlagAnimation(const CGObjectI std::shared_ptr MapRendererObjects::getOverlayAnimation(const CGObjectInstance * obj) { - if(obj->ID == Obj::BOAT) + if(obj->ID == Obj::TRANSPORT) { //TODO: relocate to config file? // Boats have additional animation with waves around boat diff --git a/client/mapView/MapRendererContext.cpp b/client/mapView/MapRendererContext.cpp index 4e3c95d5b..c94d104d3 100644 --- a/client/mapView/MapRendererContext.cpp +++ b/client/mapView/MapRendererContext.cpp @@ -39,7 +39,7 @@ uint32_t MapRendererBaseContext::getObjectRotation(ObjectInstanceID objectID) co return hero->moveDir; } - if(obj->ID == Obj::BOAT) + if(obj->ID == Obj::TRANSPORT) { const auto * boat = dynamic_cast(obj); diff --git a/client/mapView/MapViewController.cpp b/client/mapView/MapViewController.cpp index 3e547a396..9c3902cf7 100644 --- a/client/mapView/MapViewController.cpp +++ b/client/mapView/MapViewController.cpp @@ -276,7 +276,7 @@ void MapViewController::fadeInObject(const CGObjectInstance * obj) void MapViewController::removeObject(const CGObjectInstance * obj) { - if (obj->ID == Obj::BOAT) + if (obj->ID == Obj::TRANSPORT) { auto * boat = dynamic_cast(obj); if (boat->hero) diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 81c719d25..6be350dfb 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -595,7 +595,7 @@ void CCastleBuildings::recreate() logGlobal->warn("Shipyard in non-coastal town!"); std::vector vobjs = LOCPLINT->cb->getVisitableObjs(bayPos, false); //there is visitable obj at shipyard output tile and it's a boat or hero (on boat) - if(!vobjs.empty() && (vobjs.front()->ID == Obj::BOAT || vobjs.front()->ID == Obj::HERO)) + if(!vobjs.empty() && (vobjs.front()->ID == Obj::TRANSPORT || vobjs.front()->ID == Obj::HERO)) { buildingsCopy.insert(BuildingID::SHIP); } diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index c46bda223..18254d85e 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -1079,7 +1079,7 @@ void CExchangeWindow::updateWidgets() } } -CShipyardWindow::CShipyardWindow(const TResources & cost, int state, int boatType, const std::function & onBuy) +CShipyardWindow::CShipyardWindow(const TResources & cost, int state, TransportId boatType, const std::function & onBuy) : CStatusbarWindow(PLAYER_COLORED, "TPSHIP") { OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); @@ -1089,7 +1089,7 @@ CShipyardWindow::CShipyardWindow(const TResources & cost, int state, int boatTyp std::string boatFilenames[3] = {"AB01_", "AB02_", "AB03_"}; Point waterCenter = Point(bgWater->pos.x+bgWater->pos.w/2, bgWater->pos.y+bgWater->pos.h/2); - bgShip = std::make_shared(boatFilenames[boatType], 0, 7, 120, 96, 0); + bgShip = std::make_shared(boatFilenames[boatType.getNum()], 0, 7, 120, 96, 0); bgShip->center(waterCenter); // Create resource icons and costs. diff --git a/client/windows/GUIClasses.h b/client/windows/GUIClasses.h index a6c2a6a11..98ed912d9 100644 --- a/client/windows/GUIClasses.h +++ b/client/windows/GUIClasses.h @@ -358,7 +358,7 @@ class CShipyardWindow : public CStatusbarWindow std::shared_ptr quit; public: - CShipyardWindow(const TResources & cost, int state, int boatType, const std::function & onBuy); + CShipyardWindow(const TResources & cost, int state, TransportId boatType, const std::function & onBuy); }; /// Creature transformer window diff --git a/lib/CPathfinder.cpp b/lib/CPathfinder.cpp index 28d742002..e6613bf4e 100644 --- a/lib/CPathfinder.cpp +++ b/lib/CPathfinder.cpp @@ -668,10 +668,10 @@ PathfinderBlockingRule::BlockingReason MovementToDestinationRule::getBlockingRea if(!destination.isNodeObjectVisitable()) return BlockingReason::DESTINATION_BLOCKED; - if(destination.nodeObject->ID != Obj::BOAT && !destination.nodeHero) + if(destination.nodeObject->ID != Obj::TRANSPORT && !destination.nodeHero) return BlockingReason::DESTINATION_BLOCKED; } - else if(destination.isNodeObjectVisitable() && destination.nodeObject->ID == Obj::BOAT) + else if(destination.isNodeObjectVisitable() && destination.nodeObject->ID == Obj::TRANSPORT) { /// Hero in boat can't visit empty boats return BlockingReason::DESTINATION_BLOCKED; @@ -810,7 +810,7 @@ void DestinationActionRule::process( { auto objRel = destination.objectRelations; - if(destination.nodeObject->ID == Obj::BOAT) + if(destination.nodeObject->ID == Obj::TRANSPORT) action = CGPathNode::EMBARK; else if(destination.nodeHero) { diff --git a/lib/GameConstants.h b/lib/GameConstants.h index 025f3777c..09d41a93e 100644 --- a/lib/GameConstants.h +++ b/lib/GameConstants.h @@ -756,7 +756,7 @@ public: ARTIFACT = 5, PANDORAS_BOX = 6, BLACK_MARKET = 7, - BOAT = 8, + TRANSPORT = 8, BORDERGUARD = 9, KEYMASTER = 10, BUOY = 11, @@ -1241,6 +1241,27 @@ class BattleField : public BaseForID DLL_LINKAGE static BattleField fromString(const std::string & identifier); }; +class TransportId +{ +public: + enum ETransportId + { + NONE = -1, + BOAT_EVIL = 0, + BOAT_GOOD, + BOAT_NEUTRAL + }; + + TransportId(ETransportId _num = NONE) : num(_num) + {} + + ID_LIKE_CLASS_COMMON(TransportId, ETransportId) + + ETransportId num; +}; + +ID_LIKE_OPERATORS(TransportId, TransportId::ETransportId) + enum class ETerrainId { NATIVE_TERRAIN = -4, ANY_TERRAIN = -3, diff --git a/lib/NetPacksLib.cpp b/lib/NetPacksLib.cpp index 260abd6d8..65817f923 100644 --- a/lib/NetPacksLib.cpp +++ b/lib/NetPacksLib.cpp @@ -1285,7 +1285,7 @@ void TryMoveHero::applyGs(CGameState *gs) if(result == EMBARK) //hero enters boat at destination tile { const TerrainTile &tt = gs->map->getTile(h->convertToVisitablePos(end)); - assert(tt.visitableObjects.size() >= 1 && tt.visitableObjects.back()->ID == Obj::BOAT); //the only visitable object at destination is Boat + assert(tt.visitableObjects.size() >= 1 && tt.visitableObjects.back()->ID == Obj::TRANSPORT); //the only visitable object at destination is Boat auto * boat = dynamic_cast(tt.visitableObjects.back()); assert(boat); @@ -1457,7 +1457,7 @@ void NewObject::applyGs(CGameState *gs) { TerrainId terrainType = ETerrainId::NONE; - if(ID == Obj::BOAT && !gs->isInTheMap(pos)) //special handling for bug #3060 - pos outside map but visitablePos is not + if(ID == Obj::TRANSPORT && !gs->isInTheMap(pos)) //special handling for bug #3060 - pos outside map but visitablePos is not { CGObjectInstance testObject = CGObjectInstance(); testObject.pos = pos; @@ -1475,7 +1475,7 @@ void NewObject::applyGs(CGameState *gs) CGObjectInstance *o = nullptr; switch(ID) { - case Obj::BOAT: + case Obj::TRANSPORT: o = new CGBoat(); terrainType = ETerrainId::WATER; //TODO: either boat should only spawn on water, or all water objects should be handled this way break; diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 5826f19b2..42e6c9f07 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -935,18 +935,14 @@ si32 CGHeroInstance::getManaNewTurn() const // ai->putAt(this, ai->firstAvailableSlot(this)); // } -int CGHeroInstance::getBoatType() const +TransportId CGHeroInstance::getTransportType() const { switch(type->heroClass->getAlignment()) { - case EAlignment::GOOD: - return 1; - case EAlignment::EVIL: - return 0; - case EAlignment::NEUTRAL: - return 2; - default: - throw std::runtime_error("Wrong alignment!"); + case EAlignment::EVIL : return TransportId::ETransportId::BOAT_EVIL; + case EAlignment::GOOD : return TransportId::ETransportId::BOAT_GOOD; + case EAlignment::NEUTRAL : return TransportId::ETransportId::BOAT_NEUTRAL; + default: return TransportId::ETransportId::NONE; } } diff --git a/lib/mapObjects/CGHeroInstance.h b/lib/mapObjects/CGHeroInstance.h index 28b2dae4b..28f183604 100644 --- a/lib/mapObjects/CGHeroInstance.h +++ b/lib/mapObjects/CGHeroInstance.h @@ -133,7 +133,7 @@ public: int getSightRadius() const override; //sight distance (should be used if player-owned structure) ////////////////////////////////////////////////////////////////////////// - int getBoatType() const override; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral + TransportId getTransportType() const override; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral void getOutOffsets(std::vector &offsets) const override; //offsets to obj pos when we boat can be placed ////////////////////////////////////////////////////////////////////////// diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 10f2fbb2b..ba4e12380 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -1085,16 +1085,15 @@ void CGTownInstance::clearArmy() const } } -int CGTownInstance::getBoatType() const +TransportId CGTownInstance::getTransportType() const { switch (town->faction->alignment) { - case EAlignment::EVIL : return 0; - case EAlignment::GOOD : return 1; - case EAlignment::NEUTRAL : return 2; + case EAlignment::EVIL : return TransportId::ETransportId::BOAT_EVIL; + case EAlignment::GOOD : return TransportId::ETransportId::BOAT_GOOD; + case EAlignment::NEUTRAL : return TransportId::ETransportId::BOAT_NEUTRAL; + default: return TransportId::ETransportId::NONE; } - assert(0); - return -1; } int CGTownInstance::getMarketEfficiency() const diff --git a/lib/mapObjects/CGTownInstance.h b/lib/mapObjects/CGTownInstance.h index 0f5730679..01b8feea4 100644 --- a/lib/mapObjects/CGTownInstance.h +++ b/lib/mapObjects/CGTownInstance.h @@ -293,7 +293,7 @@ public: bool passableFor(PlayerColor color) const override; //int3 getSightCenter() const override; //"center" tile from which the sight distance is calculated int getSightRadius() const override; //returns sight distance - int getBoatType() const override; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral + TransportId getTransportType() const override; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral void getOutOffsets(std::vector &offsets) const override; //offsets to obj pos when we boat can be placed. Parameter will be cleared int getMarketEfficiency() const override; //=market count bool allowsTrade(EMarketMode::EMarketMode mode) const override; diff --git a/lib/mapObjects/CObjectHandler.cpp b/lib/mapObjects/CObjectHandler.cpp index 17e94634c..419c2dded 100644 --- a/lib/mapObjects/CObjectHandler.cpp +++ b/lib/mapObjects/CObjectHandler.cpp @@ -442,7 +442,7 @@ int3 IBoatGenerator::bestLocation() const { if(const TerrainTile *tile = IObjectInterface::cb->getTile(o->pos + offset, false)) //tile is in the map { - if(tile->terType->isWater() && (!tile->blocked || tile->blockingObjects.front()->ID == Obj::BOAT)) //and is water and is not blocked or is blocked by boat + if(tile->terType->isWater() && (!tile->blocked || tile->blockingObjects.front()->ID == Obj::TRANSPORT)) //and is water and is not blocked or is blocked by boat return o->pos + offset; } } @@ -457,16 +457,16 @@ IBoatGenerator::EGeneratorState IBoatGenerator::shipyardStatus() const return TILE_BLOCKED; //no available water else if(t->blockingObjects.empty()) return GOOD; //OK - else if(t->blockingObjects.front()->ID == Obj::BOAT) + else if(t->blockingObjects.front()->ID == Obj::TRANSPORT) return BOAT_ALREADY_BUILT; //blocked with boat else return TILE_BLOCKED; //blocked } -int IBoatGenerator::getBoatType() const +TransportId IBoatGenerator::getTransportType() const { //We make good ships by default - return 1; + return TransportId::ETransportId::BOAT_GOOD; } diff --git a/lib/mapObjects/CObjectHandler.h b/lib/mapObjects/CObjectHandler.h index 983050a9e..4112d4c70 100644 --- a/lib/mapObjects/CObjectHandler.h +++ b/lib/mapObjects/CObjectHandler.h @@ -86,7 +86,7 @@ public: IBoatGenerator(const CGObjectInstance *O); virtual ~IBoatGenerator() = default; - virtual int getBoatType() const; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral + virtual TransportId getTransportType() const; //0 - evil (if a ship can be evil...?), 1 - good, 2 - neutral virtual void getOutOffsets(std::vector &offsets) const =0; //offsets to obj pos when we boat can be placed int3 bestLocation() const; //returns location when the boat should be placed diff --git a/lib/mapObjects/ObjectTemplate.cpp b/lib/mapObjects/ObjectTemplate.cpp index cf36e66a6..8fbb18cf2 100644 --- a/lib/mapObjects/ObjectTemplate.cpp +++ b/lib/mapObjects/ObjectTemplate.cpp @@ -36,7 +36,7 @@ static bool isOnVisitableFromTopList(int identifier, int type) Obj::SHIPWRECK_SURVIVOR, Obj::BUOY, Obj::OCEAN_BOTTLE, - Obj::BOAT, + Obj::TRANSPORT, Obj::WHIRLPOOL, Obj::GARRISON, Obj::GARRISON2, diff --git a/lib/rmg/WaterProxy.cpp b/lib/rmg/WaterProxy.cpp index d8d133fff..0956d7cf3 100644 --- a/lib/rmg/WaterProxy.cpp +++ b/lib/rmg/WaterProxy.cpp @@ -209,8 +209,8 @@ bool WaterProxy::placeBoat(Zone & land, const Lake & lake, RouteInfo & info) if(!manager) return false; - auto subObjects = VLC->objtypeh->knownSubObjects(Obj::BOAT); - auto * boat = dynamic_cast(VLC->objtypeh->getHandlerFor(Obj::BOAT, *RandomGeneratorUtil::nextItem(subObjects, generator.rand))->create()); + auto subObjects = VLC->objtypeh->knownSubObjects(Obj::TRANSPORT); + auto * boat = dynamic_cast(VLC->objtypeh->getHandlerFor(Obj::TRANSPORT, *RandomGeneratorUtil::nextItem(subObjects, generator.rand))->create()); rmg::Object rmgObject(*boat); rmgObject.setTemplate(zone.getTerrainType()); diff --git a/lib/spells/AdventureSpellMechanics.cpp b/lib/spells/AdventureSpellMechanics.cpp index d7c0b7043..eeceb1521 100644 --- a/lib/spells/AdventureSpellMechanics.cpp +++ b/lib/spells/AdventureSpellMechanics.cpp @@ -182,7 +182,7 @@ ESpellCastResult SummonBoatMechanics::applyAdventureEffects(SpellCastEnvironment double dist = 0; for(const CGObjectInstance * obj : env->getMap()->objects) { - if(obj && obj->ID == Obj::BOAT) + if(obj && obj->ID == Obj::TRANSPORT) { const auto * b = dynamic_cast(obj); if(b->hero) @@ -214,8 +214,8 @@ ESpellCastResult SummonBoatMechanics::applyAdventureEffects(SpellCastEnvironment else //create boat { NewObject no; - no.ID = Obj::BOAT; - no.subID = parameters.caster->getHeroCaster()->getBoatType(); + no.ID = Obj::TRANSPORT; + no.subID = parameters.caster->getHeroCaster()->getTransportType().getNum(); no.pos = summonPos + int3(1,0,0); env->apply(&no); } @@ -250,7 +250,7 @@ ESpellCastResult ScuttleBoatMechanics::applyAdventureEffects(SpellCastEnvironmen //TODO: test range, visibility const TerrainTile *t = &env->getMap()->getTile(parameters.pos); - if(t->visitableObjects.empty() || t->visitableObjects.back()->ID != Obj::BOAT) + if(t->visitableObjects.empty() || t->visitableObjects.back()->ID != Obj::TRANSPORT) { env->complain("There is no boat to scuttle!"); return ESpellCastResult::ERROR; diff --git a/mapeditor/mainwindow.cpp b/mapeditor/mainwindow.cpp index 329cb9176..86ca6a775 100644 --- a/mapeditor/mainwindow.cpp +++ b/mapeditor/mainwindow.cpp @@ -663,7 +663,7 @@ void MainWindow::loadObjectsTree() addGroupIntoCatalog("HEROES", false, false, Obj::HERO); addGroupIntoCatalog("HEROES", false, false, Obj::RANDOM_HERO); addGroupIntoCatalog("HEROES", false, false, Obj::HERO_PLACEHOLDER); - addGroupIntoCatalog("HEROES", false, false, Obj::BOAT); + addGroupIntoCatalog("HEROES", false, false, Obj::TRANSPORT); addGroupIntoCatalog("ARTIFACTS", true, false, Obj::ARTIFACT); addGroupIntoCatalog("ARTIFACTS", false, false, Obj::RANDOM_ART); addGroupIntoCatalog("ARTIFACTS", false, false, Obj::RANDOM_TREASURE_ART); diff --git a/mapeditor/maphandler.cpp b/mapeditor/maphandler.cpp index 9ee5f86d7..f73f24f42 100644 --- a/mapeditor/maphandler.cpp +++ b/mapeditor/maphandler.cpp @@ -187,7 +187,7 @@ void MapHandler::initObjectRects() CGObjectInstance *obj = const_cast(elem); if( !obj || (obj->ID==Obj::HERO && static_cast(obj)->inTownGarrison) //garrisoned hero - || (obj->ID==Obj::BOAT && static_cast(obj)->hero)) //boat with hero (hero graphics is used) + || (obj->ID==Obj::TRANSPORT && static_cast(obj)->hero)) //boat with hero (hero graphics is used) { continue; } diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 3f3856e6f..a483e262f 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2263,7 +2263,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo const TerrainTile t = *getTile(hmpos); const int3 guardPos = gs->guardingCreaturePosition(hmpos); - const bool embarking = !h->boat && !t.visitableObjects.empty() && t.visitableObjects.back()->ID == Obj::BOAT; + const bool embarking = !h->boat && !t.visitableObjects.empty() && t.visitableObjects.back()->ID == Obj::TRANSPORT; const bool disembarking = h->boat && t.terType->isLand() && !t.blocked; //result structure for start - movement failed, no move points used @@ -2286,7 +2286,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo //OR hero is on land and dest is water and (there is not present only one object - boat) if (((!t.terType->isPassable() || (t.blocked && !t.visitable && !canFly)) && complain("Cannot move hero, destination tile is blocked!")) - || ((!h->boat && !canWalkOnSea && !canFly && t.terType->isWater() && (t.visitableObjects.size() < 1 || (t.visitableObjects.back()->ID != Obj::BOAT && t.visitableObjects.back()->ID != Obj::HERO))) //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276) + || ((!h->boat && !canWalkOnSea && !canFly && t.terType->isWater() && (t.visitableObjects.size() < 1 || (t.visitableObjects.back()->ID != Obj::TRANSPORT && t.visitableObjects.back()->ID != Obj::HERO))) //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276) && complain("Cannot move hero, destination tile is on water!")) || ((h->boat && t.terType->isLand() && t.blocked) && complain("Cannot disembark hero, tile is blocked!")) @@ -5624,8 +5624,8 @@ bool CGameHandler::buildBoat(ObjectInstanceID objid, PlayerColor playerID) //create boat NewObject no; - no.ID = Obj::BOAT; - no.subID = obj->getBoatType(); + no.ID = Obj::TRANSPORT; + no.subID = obj->getTransportType().getNum(); no.pos = tile + int3(1,0,0); sendAndApply(&no);