1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Prepare transport enum

This commit is contained in:
nordsoft 2023-04-18 13:04:49 +04:00
parent 2babb5add5
commit ed798b06da
27 changed files with 78 additions and 63 deletions

View File

@ -228,7 +228,7 @@ bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater)
} }
else if(!fromWater) // do not try to board when in water sector 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 true;
} }
return false; 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); return ai->cb->getHeroesInfo().size() < VLC->settings()->getInteger(EGameSettings::HEROES_PER_PLAYER_ON_MAP_CAP);
case Obj::TAVERN: case Obj::TAVERN:
case Obj::EYE_OF_MAGI: case Obj::EYE_OF_MAGI:
case Obj::BOAT: case Obj::TRANSPORT:
case Obj::SIGN: case Obj::SIGN:
return false; return false;
} }

View File

@ -193,7 +193,7 @@ void ObjectClusterizer::clusterize()
blockedObjects.clear(); blockedObjects.clear();
Obj ignoreObjects[] = { Obj ignoreObjects[] = {
Obj::BOAT, Obj::TRANSPORT,
Obj::EYE_OF_MAGI, Obj::EYE_OF_MAGI,
Obj::MONOLITH_ONE_WAY_ENTRANCE, Obj::MONOLITH_ONE_WAY_ENTRANCE,
Obj::MONOLITH_ONE_WAY_EXIT, Obj::MONOLITH_ONE_WAY_EXIT,

View File

@ -198,7 +198,7 @@ bool canBeEmbarkmentPoint(const TerrainTile * t, bool fromWater)
} }
else if(!fromWater) // do not try to board when in water sector 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 true;
} }
return false; return false;

View File

@ -2868,7 +2868,7 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
return false; return false;
break; break;
} }
case Obj::BOAT: case Obj::TRANSPORT:
return false; return false;
//Boats are handled by pathfinder //Boats are handled by pathfinder
case Obj::EYE_OF_MAGI: case Obj::EYE_OF_MAGI:

View File

@ -1490,14 +1490,14 @@ void CPlayerInterface::showShipyardDialog(const IShipyard *obj)
auto state = obj->shipyardStatus(); auto state = obj->shipyardStatus();
TResources cost; TResources cost;
obj->getBoatCost(cost); obj->getBoatCost(cost);
GH.pushIntT<CShipyardWindow>(cost, state, obj->getBoatType(), [=](){ cb->buildBoat(obj); }); GH.pushIntT<CShipyardWindow>(cost, state, obj->getTransportType(), [=](){ cb->buildBoat(obj); });
} }
void CPlayerInterface::newObject( const CGObjectInstance * obj ) void CPlayerInterface::newObject( const CGObjectInstance * obj )
{ {
EVENT_HANDLER_CALLED_BY_CLIENT; EVENT_HANDLER_CALLED_BY_CLIENT;
//we might have built a boat in shipyard in opened town screen //we might have built a boat in shipyard in opened town screen
if (obj->ID == Obj::BOAT if (obj->ID == Obj::TRANSPORT
&& LOCPLINT->castleInt && LOCPLINT->castleInt
&& obj->visitablePos() == LOCPLINT->castleInt->town->bestLocation()) && obj->visitablePos() == LOCPLINT->castleInt->town->bestLocation())
{ {

View File

@ -1083,7 +1083,7 @@ void CAdvMapInt::onTileLeftClicked(const int3 &mapPos)
switch(spellBeingCasted->id) switch(spellBeingCasted->id)
{ {
case SpellID::SCUTTLE_BOAT: //Scuttle Boat case SpellID::SCUTTLE_BOAT: //Scuttle Boat
if(topBlocking && topBlocking->ID == Obj::BOAT) if(topBlocking && topBlocking->ID == Obj::TRANSPORT)
leaveCastingMode(true, mapPos); leaveCastingMode(true, mapPos);
break; break;
case SpellID::DIMENSION_DOOR: case SpellID::DIMENSION_DOOR:
@ -1179,7 +1179,7 @@ void CAdvMapInt::onTileHovered(const int3 &mapPos)
switch(spellBeingCasted->id) switch(spellBeingCasted->id)
{ {
case SpellID::SCUTTLE_BOAT: case SpellID::SCUTTLE_BOAT:
if(objAtTile && objAtTile->ID == Obj::BOAT) if(objAtTile && objAtTile->ID == Obj::TRANSPORT)
CCS->curh->set(Cursor::Map::SCUTTLE_BOAT); CCS->curh->set(Cursor::Map::SCUTTLE_BOAT);
else else
CCS->curh->set(Cursor::Map::POINTER); CCS->curh->set(Cursor::Map::POINTER);

View File

@ -392,7 +392,7 @@ std::shared_ptr<CAnimation> MapRendererObjects::getBaseAnimation(const CGObjectI
return std::shared_ptr<CAnimation>(); return std::shared_ptr<CAnimation>();
} }
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? //TODO: relocate to config file?
// Boat appearance files only contain single, unanimated image // Boat appearance files only contain single, unanimated image
@ -401,7 +401,7 @@ std::shared_ptr<CAnimation> MapRendererObjects::getBaseAnimation(const CGObjectI
"AB01_.def", "AB02_.def", "AB03_.def" "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(boatAnimations[info->subid], generateMovementGroups);
return getAnimation(info->animationFile, generateMovementGroups); return getAnimation(info->animationFile, generateMovementGroups);
@ -452,11 +452,10 @@ std::shared_ptr<CAnimation> MapRendererObjects::getFlagAnimation(const CGObjectI
return getAnimation(heroFlags[obj->tempOwner.getNum()], true); return getAnimation(heroFlags[obj->tempOwner.getNum()], true);
} }
if(obj->ID == Obj::BOAT) if(obj->ID == Obj::TRANSPORT)
{ {
const auto * boat = dynamic_cast<const CGBoat *>(obj); const auto * boat = dynamic_cast<const CGBoat *>(obj);
assert(boat->subID < boatFlags.size()); if(boat->hero && boat->subID < boatFlags.size())
if (boat->hero)
{ {
assert(boat->hero->tempOwner.isValidPlayer()); assert(boat->hero->tempOwner.isValidPlayer());
return getAnimation(boatFlags[boat->subID][boat->hero->tempOwner.getNum()], true); return getAnimation(boatFlags[boat->subID][boat->hero->tempOwner.getNum()], true);
@ -468,7 +467,7 @@ std::shared_ptr<CAnimation> MapRendererObjects::getFlagAnimation(const CGObjectI
std::shared_ptr<CAnimation> MapRendererObjects::getOverlayAnimation(const CGObjectInstance * obj) std::shared_ptr<CAnimation> MapRendererObjects::getOverlayAnimation(const CGObjectInstance * obj)
{ {
if(obj->ID == Obj::BOAT) if(obj->ID == Obj::TRANSPORT)
{ {
//TODO: relocate to config file? //TODO: relocate to config file?
// Boats have additional animation with waves around boat // Boats have additional animation with waves around boat

View File

@ -39,7 +39,7 @@ uint32_t MapRendererBaseContext::getObjectRotation(ObjectInstanceID objectID) co
return hero->moveDir; return hero->moveDir;
} }
if(obj->ID == Obj::BOAT) if(obj->ID == Obj::TRANSPORT)
{ {
const auto * boat = dynamic_cast<const CGBoat *>(obj); const auto * boat = dynamic_cast<const CGBoat *>(obj);

View File

@ -276,7 +276,7 @@ void MapViewController::fadeInObject(const CGObjectInstance * obj)
void MapViewController::removeObject(const CGObjectInstance * obj) void MapViewController::removeObject(const CGObjectInstance * obj)
{ {
if (obj->ID == Obj::BOAT) if (obj->ID == Obj::TRANSPORT)
{ {
auto * boat = dynamic_cast<const CGBoat*>(obj); auto * boat = dynamic_cast<const CGBoat*>(obj);
if (boat->hero) if (boat->hero)

View File

@ -595,7 +595,7 @@ void CCastleBuildings::recreate()
logGlobal->warn("Shipyard in non-coastal town!"); logGlobal->warn("Shipyard in non-coastal town!");
std::vector <const CGObjectInstance *> vobjs = LOCPLINT->cb->getVisitableObjs(bayPos, false); std::vector <const CGObjectInstance *> vobjs = LOCPLINT->cb->getVisitableObjs(bayPos, false);
//there is visitable obj at shipyard output tile and it's a boat or hero (on boat) //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); buildingsCopy.insert(BuildingID::SHIP);
} }

View File

@ -1079,7 +1079,7 @@ void CExchangeWindow::updateWidgets()
} }
} }
CShipyardWindow::CShipyardWindow(const TResources & cost, int state, int boatType, const std::function<void()> & onBuy) CShipyardWindow::CShipyardWindow(const TResources & cost, int state, TransportId boatType, const std::function<void()> & onBuy)
: CStatusbarWindow(PLAYER_COLORED, "TPSHIP") : CStatusbarWindow(PLAYER_COLORED, "TPSHIP")
{ {
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE); 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_"}; std::string boatFilenames[3] = {"AB01_", "AB02_", "AB03_"};
Point waterCenter = Point(bgWater->pos.x+bgWater->pos.w/2, bgWater->pos.y+bgWater->pos.h/2); Point waterCenter = Point(bgWater->pos.x+bgWater->pos.w/2, bgWater->pos.y+bgWater->pos.h/2);
bgShip = std::make_shared<CAnimImage>(boatFilenames[boatType], 0, 7, 120, 96, 0); bgShip = std::make_shared<CAnimImage>(boatFilenames[boatType.getNum()], 0, 7, 120, 96, 0);
bgShip->center(waterCenter); bgShip->center(waterCenter);
// Create resource icons and costs. // Create resource icons and costs.

View File

@ -358,7 +358,7 @@ class CShipyardWindow : public CStatusbarWindow
std::shared_ptr<CButton> quit; std::shared_ptr<CButton> quit;
public: public:
CShipyardWindow(const TResources & cost, int state, int boatType, const std::function<void()> & onBuy); CShipyardWindow(const TResources & cost, int state, TransportId boatType, const std::function<void()> & onBuy);
}; };
/// Creature transformer window /// Creature transformer window

View File

@ -668,10 +668,10 @@ PathfinderBlockingRule::BlockingReason MovementToDestinationRule::getBlockingRea
if(!destination.isNodeObjectVisitable()) if(!destination.isNodeObjectVisitable())
return BlockingReason::DESTINATION_BLOCKED; return BlockingReason::DESTINATION_BLOCKED;
if(destination.nodeObject->ID != Obj::BOAT && !destination.nodeHero) if(destination.nodeObject->ID != Obj::TRANSPORT && !destination.nodeHero)
return BlockingReason::DESTINATION_BLOCKED; 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 /// Hero in boat can't visit empty boats
return BlockingReason::DESTINATION_BLOCKED; return BlockingReason::DESTINATION_BLOCKED;
@ -810,7 +810,7 @@ void DestinationActionRule::process(
{ {
auto objRel = destination.objectRelations; auto objRel = destination.objectRelations;
if(destination.nodeObject->ID == Obj::BOAT) if(destination.nodeObject->ID == Obj::TRANSPORT)
action = CGPathNode::EMBARK; action = CGPathNode::EMBARK;
else if(destination.nodeHero) else if(destination.nodeHero)
{ {

View File

@ -756,7 +756,7 @@ public:
ARTIFACT = 5, ARTIFACT = 5,
PANDORAS_BOX = 6, PANDORAS_BOX = 6,
BLACK_MARKET = 7, BLACK_MARKET = 7,
BOAT = 8, TRANSPORT = 8,
BORDERGUARD = 9, BORDERGUARD = 9,
KEYMASTER = 10, KEYMASTER = 10,
BUOY = 11, BUOY = 11,
@ -1241,6 +1241,27 @@ class BattleField : public BaseForID<BattleField, si32>
DLL_LINKAGE static BattleField fromString(const std::string & identifier); 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 { enum class ETerrainId {
NATIVE_TERRAIN = -4, NATIVE_TERRAIN = -4,
ANY_TERRAIN = -3, ANY_TERRAIN = -3,

View File

@ -1285,7 +1285,7 @@ void TryMoveHero::applyGs(CGameState *gs)
if(result == EMBARK) //hero enters boat at destination tile if(result == EMBARK) //hero enters boat at destination tile
{ {
const TerrainTile &tt = gs->map->getTile(h->convertToVisitablePos(end)); 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<CGBoat *>(tt.visitableObjects.back()); auto * boat = dynamic_cast<CGBoat *>(tt.visitableObjects.back());
assert(boat); assert(boat);
@ -1457,7 +1457,7 @@ void NewObject::applyGs(CGameState *gs)
{ {
TerrainId terrainType = ETerrainId::NONE; 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(); CGObjectInstance testObject = CGObjectInstance();
testObject.pos = pos; testObject.pos = pos;
@ -1475,7 +1475,7 @@ void NewObject::applyGs(CGameState *gs)
CGObjectInstance *o = nullptr; CGObjectInstance *o = nullptr;
switch(ID) switch(ID)
{ {
case Obj::BOAT: case Obj::TRANSPORT:
o = new CGBoat(); o = new CGBoat();
terrainType = ETerrainId::WATER; //TODO: either boat should only spawn on water, or all water objects should be handled this way terrainType = ETerrainId::WATER; //TODO: either boat should only spawn on water, or all water objects should be handled this way
break; break;

View File

@ -935,18 +935,14 @@ si32 CGHeroInstance::getManaNewTurn() const
// ai->putAt(this, ai->firstAvailableSlot(this)); // ai->putAt(this, ai->firstAvailableSlot(this));
// } // }
int CGHeroInstance::getBoatType() const TransportId CGHeroInstance::getTransportType() const
{ {
switch(type->heroClass->getAlignment()) switch(type->heroClass->getAlignment())
{ {
case EAlignment::GOOD: case EAlignment::EVIL : return TransportId::ETransportId::BOAT_EVIL;
return 1; case EAlignment::GOOD : return TransportId::ETransportId::BOAT_GOOD;
case EAlignment::EVIL: case EAlignment::NEUTRAL : return TransportId::ETransportId::BOAT_NEUTRAL;
return 0; default: return TransportId::ETransportId::NONE;
case EAlignment::NEUTRAL:
return 2;
default:
throw std::runtime_error("Wrong alignment!");
} }
} }

View File

@ -133,7 +133,7 @@ public:
int getSightRadius() const override; //sight distance (should be used if player-owned structure) 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<int3> &offsets) const override; //offsets to obj pos when we boat can be placed void getOutOffsets(std::vector<int3> &offsets) const override; //offsets to obj pos when we boat can be placed
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -1085,16 +1085,15 @@ void CGTownInstance::clearArmy() const
} }
} }
int CGTownInstance::getBoatType() const TransportId CGTownInstance::getTransportType() const
{ {
switch (town->faction->alignment) switch (town->faction->alignment)
{ {
case EAlignment::EVIL : return 0; case EAlignment::EVIL : return TransportId::ETransportId::BOAT_EVIL;
case EAlignment::GOOD : return 1; case EAlignment::GOOD : return TransportId::ETransportId::BOAT_GOOD;
case EAlignment::NEUTRAL : return 2; case EAlignment::NEUTRAL : return TransportId::ETransportId::BOAT_NEUTRAL;
default: return TransportId::ETransportId::NONE;
} }
assert(0);
return -1;
} }
int CGTownInstance::getMarketEfficiency() const int CGTownInstance::getMarketEfficiency() const

View File

@ -293,7 +293,7 @@ public:
bool passableFor(PlayerColor color) const override; bool passableFor(PlayerColor color) const override;
//int3 getSightCenter() const override; //"center" tile from which the sight distance is calculated //int3 getSightCenter() const override; //"center" tile from which the sight distance is calculated
int getSightRadius() const override; //returns sight distance 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<int3> &offsets) const override; //offsets to obj pos when we boat can be placed. Parameter will be cleared void getOutOffsets(std::vector<int3> &offsets) const override; //offsets to obj pos when we boat can be placed. Parameter will be cleared
int getMarketEfficiency() const override; //=market count int getMarketEfficiency() const override; //=market count
bool allowsTrade(EMarketMode::EMarketMode mode) const override; bool allowsTrade(EMarketMode::EMarketMode mode) const override;

View File

@ -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(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; return o->pos + offset;
} }
} }
@ -457,16 +457,16 @@ IBoatGenerator::EGeneratorState IBoatGenerator::shipyardStatus() const
return TILE_BLOCKED; //no available water return TILE_BLOCKED; //no available water
else if(t->blockingObjects.empty()) else if(t->blockingObjects.empty())
return GOOD; //OK 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 return BOAT_ALREADY_BUILT; //blocked with boat
else else
return TILE_BLOCKED; //blocked return TILE_BLOCKED; //blocked
} }
int IBoatGenerator::getBoatType() const TransportId IBoatGenerator::getTransportType() const
{ {
//We make good ships by default //We make good ships by default
return 1; return TransportId::ETransportId::BOAT_GOOD;
} }

View File

@ -86,7 +86,7 @@ public:
IBoatGenerator(const CGObjectInstance *O); IBoatGenerator(const CGObjectInstance *O);
virtual ~IBoatGenerator() = default; 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<int3> &offsets) const =0; //offsets to obj pos when we boat can be placed virtual void getOutOffsets(std::vector<int3> &offsets) const =0; //offsets to obj pos when we boat can be placed
int3 bestLocation() const; //returns location when the boat should be placed int3 bestLocation() const; //returns location when the boat should be placed

View File

@ -36,7 +36,7 @@ static bool isOnVisitableFromTopList(int identifier, int type)
Obj::SHIPWRECK_SURVIVOR, Obj::SHIPWRECK_SURVIVOR,
Obj::BUOY, Obj::BUOY,
Obj::OCEAN_BOTTLE, Obj::OCEAN_BOTTLE,
Obj::BOAT, Obj::TRANSPORT,
Obj::WHIRLPOOL, Obj::WHIRLPOOL,
Obj::GARRISON, Obj::GARRISON,
Obj::GARRISON2, Obj::GARRISON2,

View File

@ -209,8 +209,8 @@ bool WaterProxy::placeBoat(Zone & land, const Lake & lake, RouteInfo & info)
if(!manager) if(!manager)
return false; return false;
auto subObjects = VLC->objtypeh->knownSubObjects(Obj::BOAT); auto subObjects = VLC->objtypeh->knownSubObjects(Obj::TRANSPORT);
auto * boat = dynamic_cast<CGBoat *>(VLC->objtypeh->getHandlerFor(Obj::BOAT, *RandomGeneratorUtil::nextItem(subObjects, generator.rand))->create()); auto * boat = dynamic_cast<CGBoat *>(VLC->objtypeh->getHandlerFor(Obj::TRANSPORT, *RandomGeneratorUtil::nextItem(subObjects, generator.rand))->create());
rmg::Object rmgObject(*boat); rmg::Object rmgObject(*boat);
rmgObject.setTemplate(zone.getTerrainType()); rmgObject.setTemplate(zone.getTerrainType());

View File

@ -182,7 +182,7 @@ ESpellCastResult SummonBoatMechanics::applyAdventureEffects(SpellCastEnvironment
double dist = 0; double dist = 0;
for(const CGObjectInstance * obj : env->getMap()->objects) for(const CGObjectInstance * obj : env->getMap()->objects)
{ {
if(obj && obj->ID == Obj::BOAT) if(obj && obj->ID == Obj::TRANSPORT)
{ {
const auto * b = dynamic_cast<const CGBoat *>(obj); const auto * b = dynamic_cast<const CGBoat *>(obj);
if(b->hero) if(b->hero)
@ -214,8 +214,8 @@ ESpellCastResult SummonBoatMechanics::applyAdventureEffects(SpellCastEnvironment
else //create boat else //create boat
{ {
NewObject no; NewObject no;
no.ID = Obj::BOAT; no.ID = Obj::TRANSPORT;
no.subID = parameters.caster->getHeroCaster()->getBoatType(); no.subID = parameters.caster->getHeroCaster()->getTransportType().getNum();
no.pos = summonPos + int3(1,0,0); no.pos = summonPos + int3(1,0,0);
env->apply(&no); env->apply(&no);
} }
@ -250,7 +250,7 @@ ESpellCastResult ScuttleBoatMechanics::applyAdventureEffects(SpellCastEnvironmen
//TODO: test range, visibility //TODO: test range, visibility
const TerrainTile *t = &env->getMap()->getTile(parameters.pos); 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!"); env->complain("There is no boat to scuttle!");
return ESpellCastResult::ERROR; return ESpellCastResult::ERROR;

View File

@ -663,7 +663,7 @@ void MainWindow::loadObjectsTree()
addGroupIntoCatalog("HEROES", false, false, Obj::HERO); addGroupIntoCatalog("HEROES", false, false, Obj::HERO);
addGroupIntoCatalog("HEROES", false, false, Obj::RANDOM_HERO); addGroupIntoCatalog("HEROES", false, false, Obj::RANDOM_HERO);
addGroupIntoCatalog("HEROES", false, false, Obj::HERO_PLACEHOLDER); 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", true, false, Obj::ARTIFACT);
addGroupIntoCatalog("ARTIFACTS", false, false, Obj::RANDOM_ART); addGroupIntoCatalog("ARTIFACTS", false, false, Obj::RANDOM_ART);
addGroupIntoCatalog("ARTIFACTS", false, false, Obj::RANDOM_TREASURE_ART); addGroupIntoCatalog("ARTIFACTS", false, false, Obj::RANDOM_TREASURE_ART);

View File

@ -187,7 +187,7 @@ void MapHandler::initObjectRects()
CGObjectInstance *obj = const_cast<CGObjectInstance *>(elem); CGObjectInstance *obj = const_cast<CGObjectInstance *>(elem);
if( !obj if( !obj
|| (obj->ID==Obj::HERO && static_cast<const CGHeroInstance*>(obj)->inTownGarrison) //garrisoned hero || (obj->ID==Obj::HERO && static_cast<const CGHeroInstance*>(obj)->inTownGarrison) //garrisoned hero
|| (obj->ID==Obj::BOAT && static_cast<const CGBoat*>(obj)->hero)) //boat with hero (hero graphics is used) || (obj->ID==Obj::TRANSPORT && static_cast<const CGBoat*>(obj)->hero)) //boat with hero (hero graphics is used)
{ {
continue; continue;
} }

View File

@ -2263,7 +2263,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
const TerrainTile t = *getTile(hmpos); const TerrainTile t = *getTile(hmpos);
const int3 guardPos = gs->guardingCreaturePosition(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; const bool disembarking = h->boat && t.terType->isLand() && !t.blocked;
//result structure for start - movement failed, no move points used //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) //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)) if (((!t.terType->isPassable() || (t.blocked && !t.visitable && !canFly))
&& complain("Cannot move hero, destination tile is blocked!")) && 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!")) && complain("Cannot move hero, destination tile is on water!"))
|| ((h->boat && t.terType->isLand() && t.blocked) || ((h->boat && t.terType->isLand() && t.blocked)
&& complain("Cannot disembark hero, tile is blocked!")) && complain("Cannot disembark hero, tile is blocked!"))
@ -5624,8 +5624,8 @@ bool CGameHandler::buildBoat(ObjectInstanceID objid, PlayerColor playerID)
//create boat //create boat
NewObject no; NewObject no;
no.ID = Obj::BOAT; no.ID = Obj::TRANSPORT;
no.subID = obj->getBoatType(); no.subID = obj->getTransportType().getNum();
no.pos = tile + int3(1,0,0); no.pos = tile + int3(1,0,0);
sendAndApply(&no); sendAndApply(&no);