Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Include/GameLogic/AIPathfind.h
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ class Pathfinder : PathfindServicesInterface, public Snapshot
const Object *obj, Int attackDistance);

Path *buildActualPath( const Object *obj, LocomotorSurfaceTypeMask acceptableSurfaces,
const Coord3D *fromPos, PathfindCell *goalCell, Bool center, Bool blocked ); ///< Work backwards from goal cell to construct final path
const Coord3D *fromPos, PathfindCell *goalCell, Bool center, Bool blocked, Int requireWaterLevel ); ///< Work backwards from goal cell to construct final path
Path *buildGroundPath( Bool isCrusher,const Coord3D *fromPos, PathfindCell *goalCell,
Bool center, Int pathDiameter ); ///< Work backwards from goal cell to construct final path
Path *buildHierachicalPath( const Coord3D *fromPos, PathfindCell *goalCell); ///< Work backwards from goal cell to construct final path
Expand Down
3 changes: 2 additions & 1 deletion GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class GlobalData : public SubsystemInterface
Real m_MinDistFromEdgeOfMapForBuild;
Real m_SupplyBuildBorder;
Real m_allowedHeightVariationForBuilding; ///< how "flat" is still flat enough to build on
Real m_allowedHeightVariationForBuildingShipyard; ///< how "flat" is still flat enough to build on
Real m_MinLowEnergyProductionSpeed;
Real m_MaxLowEnergyProductionSpeed;
Real m_LowEnergyPenaltyModifier;
Expand Down Expand Up @@ -586,7 +587,7 @@ class GlobalData : public SubsystemInterface
//AudioEventRTS m_chronoDisableSoundLoop;

DeathTypeFlags m_defaultExcludedDeathTypes;

Bool m_heightAboveTerrainIncludesWater;

// the trailing '\' is included!
const AsciiString &getPath_UserData() const { return m_userDataDir; }
Expand Down
1 change: 1 addition & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/KindOf.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ enum KindOfType CPP_11(: Int)
KINDOF_SUPERHEAVY_VEHICLE,

KINDOF_TELEPORTER,
KINDOF_SHIPYARD,

KINDOF_EXTRA1,
KINDOF_EXTRA2,
Expand Down
15 changes: 10 additions & 5 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/AIPathfind.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Path : public MemoryPoolObject, public Snapshot
void appendNode( const Coord3D *pos, PathfindLayerEnum layer ); ///< Create a new node at the end of the path
void setBlockedByAlly(Bool blocked) {m_blockedByAlly = blocked;}
Bool getBlockedByAlly(void) {return m_blockedByAlly;}
void optimize( const Object *obj, LocomotorSurfaceTypeMask acceptableSurfaces, Bool blocked ); ///< Optimize the path to discard redundant nodes
void optimize( const Object *obj, LocomotorSurfaceTypeMask acceptableSurfaces, Bool blocked, Int requiredWaterLevel); ///< Optimize the path to discard redundant nodes

void optimizeGroundPath( Bool crusher, Int diameter ); ///< Optimize the ground path to discard redundant nodes

Expand Down Expand Up @@ -343,6 +343,9 @@ class PathfindCell
Bool getPinched(void) const {return m_pinched;}
void setPinched(Bool pinch) {m_pinched = pinch; }

Short getWaterLevel(void) const { return m_waterLevel; }
void setWaterLevel(Short level) { m_waterLevel = level; }

Bool allocateInfo(const ICoord2D &pos);
void releaseInfo(void);
Bool hasInfo(void) const {return m_info!=NULL;}
Expand Down Expand Up @@ -373,6 +376,8 @@ class PathfindCell
UnsignedByte m_flags:4; ///< what type of units are in or moving through this cell.
UnsignedByte m_connectsToLayer:4; ///< This cell can pathfind onto this layer, if > LAYER_TOP.
UnsignedByte m_layer:4; ///< Layer of this cell.
//This is added for ship pathing
Short m_waterLevel:8; ///< how far away is this cell from land (distance transform), capped at 15
};

typedef PathfindCell *PathfindCellP;
Expand Down Expand Up @@ -673,7 +678,7 @@ class Pathfinder : PathfindServicesInterface, public Snapshot

void setIgnoreObstacleID( ObjectID objID ); ///< if non-zero, the pathfinder will ignore the given obstacle

Bool validMovementPosition( Bool isCrusher, LocomotorSurfaceTypeMask acceptableSurfaces, PathfindCell *toCell, PathfindCell *fromCell = NULL ); ///< Return true if given position is a valid movement location
Bool validMovementPosition( Bool isCrusher, LocomotorSurfaceTypeMask acceptableSurfaces, Int requiredWaterLevel, PathfindCell *toCell, PathfindCell *fromCell = NULL ); ///< Return true if given position is a valid movement location
Bool validMovementPosition( Bool isCrusher, PathfindLayerEnum layer, const LocomotorSet& locomotorSet, Int x, Int y ); ///< Return true if given position is a valid movement location
Bool validMovementPosition( Bool isCrusher, PathfindLayerEnum layer, const LocomotorSet& locomotorSet, const Coord3D *pos ); ///< Return true if given position is a valid movement location
Bool validMovementTerrain( PathfindLayerEnum layer, const Locomotor* locomotor, const Coord3D *pos ); ///< Return true if given position is a valid movement location
Expand All @@ -686,7 +691,7 @@ class Pathfinder : PathfindServicesInterface, public Snapshot

Bool isLinePassable( const Object *obj, LocomotorSurfaceTypeMask acceptableSurfaces,
PathfindLayerEnum layer, const Coord3D& startWorld, const Coord3D& endWorld,
Bool blocked, Bool allowPinched ); ///< Return true if the straight line between the given points is passable
Bool blocked, Bool allowPinched, Int requiredWaterDepth); ///< Return true if the straight line between the given points is passable

void moveAlliesAwayFromDestination( Object *obj,const Coord3D& destination);

Expand Down Expand Up @@ -817,7 +822,7 @@ class Pathfinder : PathfindServicesInterface, public Snapshot
const Object *obj, Int attackDistance);

Path *buildActualPath( const Object *obj, LocomotorSurfaceTypeMask acceptableSurfaces,
const Coord3D *fromPos, PathfindCell *goalCell, Bool center, Bool blocked ); ///< Work backwards from goal cell to construct final path
const Coord3D *fromPos, PathfindCell *goalCell, Bool center, Bool blocked, Int requiredWaterLevel ); ///< Work backwards from goal cell to construct final path
Path *buildGroundPath( Bool isCrusher,const Coord3D *fromPos, PathfindCell *goalCell,
Bool center, Int pathDiameter ); ///< Work backwards from goal cell to construct final path
Path *buildHierachicalPath( const Coord3D *fromPos, PathfindCell *goalCell); ///< Work backwards from goal cell to construct final path
Expand Down Expand Up @@ -888,7 +893,7 @@ inline void Pathfinder::worldToGrid( const Coord3D *pos, ICoord2D *cellIndex )

inline Bool Pathfinder::validMovementPosition( Bool isCrusher, PathfindLayerEnum layer, const LocomotorSet& locomotorSet, Int x, Int y )
{
return validMovementPosition( isCrusher, locomotorSet.getValidSurfaces(), getCell( layer, x, y ) );
return validMovementPosition( isCrusher, locomotorSet.getValidSurfaces(), locomotorSet.getRequiredWaterLevel(), getCell(layer, x, y));
}

inline Bool Pathfinder::validMovementPosition( Bool isCrusher, PathfindLayerEnum layer, const LocomotorSet& locomotorSet, const Coord3D *pos )
Expand Down
9 changes: 7 additions & 2 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ enum LocomotorAppearance CPP_11(: Int)
LOCO_CLIMBER, // human climber - backs down cliffs.
LOCO_OTHER,
LOCO_MOTORCYCLE,

LOCO_SHIP,
LOCOMOTOR_APPEARANCE_COUNT
};

Expand All @@ -84,7 +84,7 @@ static const char *const TheLocomotorAppearanceNames[] =
"CLIMBER",
"OTHER",
"MOTORCYCLE",

"SHIP",
NULL
};
static_assert(ARRAY_SIZE(TheLocomotorAppearanceNames) == LOCOMOTOR_APPEARANCE_COUNT + 1, "Array size");
Expand Down Expand Up @@ -218,6 +218,8 @@ class LocomotorTemplate : public Overridable
Real m_rudderCorrectionRate;
Real m_elevatorCorrectionDegree;
Real m_elevatorCorrectionRate;

Int m_requiredWaterLevel; ///< for LOCO_SHIP, how deep the water must be
};

typedef OVERRIDE<LocomotorTemplate> LocomotorTemplateOverride;
Expand Down Expand Up @@ -321,6 +323,9 @@ class Locomotor : public MemoryPoolObject, public Snapshot

void setPreferredHeight( Real height ) { m_preferredHeight = height; }

//Returns 0 for non SHIP locomotors
inline Int getRequireWaterLevel() const { return m_template->m_appearance == LOCO_SHIP ? m_template->m_requiredWaterLevel : 0; };

#ifdef CIRCLE_FOR_LANDING
/**
if we are climbing/diving more than this, circle as needed rather
Expand Down
2 changes: 2 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/LocomotorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class LocomotorSet : public Snapshot
LocomotorVector m_locomotors;
LocomotorSurfaceTypeMask m_validLocomotorSurfaces;
Bool m_downhillOnly;
Int m_requiredWaterLevel; // for ships, if there are multiple water locomotors the lowest allowed value is used

LocomotorSet(const LocomotorSet& that);
LocomotorSet& operator=(const LocomotorSet& that);
Expand All @@ -105,5 +106,6 @@ class LocomotorSet : public Snapshot

LocomotorSurfaceTypeMask getValidSurfaces() const { return m_validLocomotorSurfaces; }
Bool isDownhillOnly( void ) const { return m_downhillOnly; };
Int getRequiredWaterLevel() const { return m_requiredWaterLevel; };

};
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class DumbProjectileBehavior : public UpdateModule, public ProjectileUpdateInter
virtual void projectileNowJammed() {}
virtual Object* getTargetObject();
virtual const Coord3D* getTargetPosition();
virtual Bool projectileShouldCollideWithWater() const override;

protected:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class FreeFallProjectileBehavior : public UpdateModule, public ProjectileUpdateI
virtual void projectileNowJammed() {}
virtual Object* getTargetObject();
virtual const Coord3D* getTargetPosition();
virtual bool projectileShouldCollideWithWater() const override;

protected:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class MissileAIUpdate : public AIUpdateInterface, public ProjectileUpdateInterfa
virtual void projectileNowJammed();///< We lose our Object target and scatter to the ground
virtual Object* getTargetObject();
virtual const Coord3D* getTargetPosition();
virtual bool projectileShouldCollideWithWater() const override;

virtual Bool processCollision(PhysicsBehavior *physics, Object *other); ///< Returns true if the physics collide should apply the force. Normally not. jba.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class ProjectileUpdateInterface
virtual Bool projectileHandleCollision(Object *other) = 0;
virtual void setFramesTillCountermeasureDiversionOccurs( UnsignedInt frames ) = 0; ///< Number of frames till missile diverts to countermeasures.
virtual void projectileNowJammed() = 0;
virtual Bool projectileShouldCollideWithWater() const { return false; };

virtual Object* getTargetObject() = 0;
virtual const Coord3D* getTargetPosition() = 0;
Expand Down
35 changes: 20 additions & 15 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ enum WeaponCollideMaskType CPP_11(: Int)
WEAPON_COLLIDE_WALLS = 0x0020,
WEAPON_COLLIDE_SMALL_MISSILES = 0x0040, //All missiles are also projectiles!
WEAPON_COLLIDE_BALLISTIC_MISSILES = 0x0080, //All missiles are also projectiles!
WEAPON_COLLIDE_CONTROLLED_STRUCTURES = 0x0100 //this is "ONLY structures belonging to the projectile's controller".
WEAPON_COLLIDE_CONTROLLED_STRUCTURES = 0x0100, //this is "ONLY structures belonging to the projectile's controller".
WEAPON_COLLIDE_WATER = 0x0200
};

#ifdef DEFINE_WEAPONCOLLIDEMASK_NAMES
Expand All @@ -161,6 +162,7 @@ static const char *const TheWeaponCollideMaskNames[] =
"SMALL_MISSILES", //All missiles are also projectiles!
"BALLISTIC_MISSILES", //All missiles are also projectiles!
"CONTROLLED_STRUCTURES",
"WATER",
NULL
};
#endif
Expand Down Expand Up @@ -399,21 +401,21 @@ class WeaponTemplate : public MemoryPoolObject
{
friend class WeaponStore;

MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( WeaponTemplate, "WeaponTemplate" )
MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(WeaponTemplate, "WeaponTemplate")

public:

WeaponTemplate();
// virtual destructor declared by memory pool

void reset( void );
void reset(void);

void friend_setNextTemplate(WeaponTemplate *nextTemplate) { m_nextTemplate = nextTemplate; }
WeaponTemplate *friend_clearNextTemplate( void ) { WeaponTemplate *ret = m_nextTemplate; m_nextTemplate = NULL; return ret; }
Bool isOverride( void ) { return m_nextTemplate != NULL; }
void friend_setNextTemplate(WeaponTemplate* nextTemplate) { m_nextTemplate = nextTemplate; }
WeaponTemplate* friend_clearNextTemplate(void) { WeaponTemplate* ret = m_nextTemplate; m_nextTemplate = NULL; return ret; }
Bool isOverride(void) { return m_nextTemplate != NULL; }

/// field table for loading the values from an INI
const FieldParse *getFieldParse() const { return TheWeaponTemplateFieldParseTable; }
const FieldParse* getFieldParse() const { return TheWeaponTemplateFieldParseTable; }

/**
fire the weapon. return the logic-frame in which the damage will be dealt.
Expand All @@ -425,15 +427,15 @@ class WeaponTemplate : public MemoryPoolObject
*/
UnsignedInt fireWeaponTemplate
(
const Object *sourceObj,
const Object* sourceObj,
WeaponSlotType wslot,
Int specificBarrelToUse,
Object *victimObj,
Object* victimObj,
const Coord3D* victimPos,
const WeaponBonus& bonus,
Bool isProjectileDetonation,
Bool ignoreRanges,
Weapon *firingWeapon,
Weapon* firingWeapon,
ObjectID* projectileID,
Bool inflictDamage
) const;
Expand All @@ -445,8 +447,8 @@ class WeaponTemplate : public MemoryPoolObject
take weapon range into account -- it ASSUMES that the victim is within range!
*/
Real estimateWeaponTemplateDamage(
const Object *sourceObj,
const Object *victimObj,
const Object* sourceObj,
const Object* victimObj,
const Coord3D* victimPos,
const WeaponBonus& bonus
) const;
Expand All @@ -467,7 +469,7 @@ class WeaponTemplate : public MemoryPoolObject
Real getShockWaveRadius() const { return m_shockWaveRadius; }
Real getShockWaveTaperOff() const { return m_shockWaveTaperOff; }

Real getRequestAssistRange() const {return m_requestAssistRange;}
Real getRequestAssistRange() const { return m_requestAssistRange; }
AsciiString getName() const { return m_name; }
AsciiString getProjectileStreamName() const { return m_projectileStreamName; }
AsciiString getLaserName() const { return m_laserName; }
Expand Down Expand Up @@ -499,7 +501,7 @@ class WeaponTemplate : public MemoryPoolObject
Int getContinuousFireOneShotsNeeded() const { return m_continuousFireOneShotsNeeded; }
Int getContinuousFireTwoShotsNeeded() const { return m_continuousFireTwoShotsNeeded; }
UnsignedInt getContinuousFireCoastFrames() const { return m_continuousFireCoastFrames; }
UnsignedInt getAutoReloadWhenIdleFrames() const { return m_autoReloadWhenIdleFrames; }
UnsignedInt getAutoReloadWhenIdleFrames() const { return m_autoReloadWhenIdleFrames; }
UnsignedInt getSuspendFXDelay() const { return m_suspendFXDelay; }

const FXList* getFireFX(VeterancyLevel v) const { return m_fireFXs[v]; }
Expand Down Expand Up @@ -530,8 +532,9 @@ class WeaponTemplate : public MemoryPoolObject
Bool isScatterTargetAligned() const { return m_scatterTargetAligned; }
Bool isScatterTargetRandom() const { return m_scatterTargetRandom; }
Bool isScatterTargetRandomAngle() const { return m_scatterTargetRandomAngle; }
Real getScatterTargetMinScalar () const { return m_scatterTargetMinScalar; }
Real getScatterTargetMinScalar() const { return m_scatterTargetMinScalar; }
Bool isScatterTargetCenteredAtShooter() const { return m_scatterTargetCenteredAtShooter; }
Bool isScatterOnWaterSurface() const { return m_scatterOnWaterSurface; }

Bool shouldProjectileCollideWith(
const Object* projectileLauncher,
Expand Down Expand Up @@ -659,6 +662,8 @@ class WeaponTemplate : public MemoryPoolObject
UnsignedInt m_scatterTargetResetTime; ///< if this much time between shots has passed, we reset the scatter targets
Bool m_scatterTargetResetRecenter; ///< when resetting scatter targets, use indices in the "middle" of the list, to keep the target centered for Line based attacks

Bool m_scatterOnWaterSurface; ///< Scatter radius and targets include the water surface instead of just the terrain height

mutable HistoricWeaponDamageList m_historicDamage;
mutable UnsignedInt m_historicDamageTriggerId;
};
Expand Down
6 changes: 5 additions & 1 deletion GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ GlobalData* GlobalData::m_theOriginal = NULL;
{ "MinDistFromEdgeOfMapForBuild", INI::parseReal, NULL, offsetof( GlobalData, m_MinDistFromEdgeOfMapForBuild ) },
{ "SupplyBuildBorder", INI::parseReal, NULL, offsetof( GlobalData, m_SupplyBuildBorder ) },
{ "AllowedHeightVariationForBuilding", INI::parseReal,NULL, offsetof( GlobalData, m_allowedHeightVariationForBuilding ) },
{ "AllowedHeightVariationForBuildingShipyard", INI::parseReal,NULL, offsetof(GlobalData, m_allowedHeightVariationForBuildingShipyard) },
{ "MinLowEnergyProductionSpeed",INI::parseReal, NULL, offsetof( GlobalData, m_MinLowEnergyProductionSpeed ) },
{ "MaxLowEnergyProductionSpeed",INI::parseReal, NULL, offsetof( GlobalData, m_MaxLowEnergyProductionSpeed ) },
{ "LowEnergyPenaltyModifier", INI::parseReal, NULL, offsetof( GlobalData, m_LowEnergyPenaltyModifier ) },
Expand Down Expand Up @@ -572,7 +573,7 @@ GlobalData* GlobalData::m_theOriginal = NULL;
{"ChronoDamageParticleSystemSmall", INI::parseAsciiString, NULL, offsetof(GlobalData, m_chronoDisableParticleSystemSmall) },

{"DefaultExcludedDeathTypes", INI::parseDeathTypeFlagsList, NULL, offsetof(GlobalData, m_defaultExcludedDeathTypes) },

{"HeightAboveTerrainIncludesWater", INI::parseBool, NULL, offsetof(GlobalData, m_heightAboveTerrainIncludesWater) },
{ NULL, NULL, NULL, 0 } // keep this last

};
Expand Down Expand Up @@ -915,6 +916,7 @@ GlobalData::GlobalData()
m_MinDistFromEdgeOfMapForBuild = 0.0f;
m_SupplyBuildBorder = 0.0f;
m_allowedHeightVariationForBuilding = 0.0f;
m_allowedHeightVariationForBuildingShipyard = 0.0f;
m_MinLowEnergyProductionSpeed = 0.0f;
m_MaxLowEnergyProductionSpeed = 0.0f;
m_LowEnergyPenaltyModifier = 0.0f;
Expand Down Expand Up @@ -1158,6 +1160,8 @@ GlobalData::GlobalData()
m_chronoDisableParticleSystemSmall.clear();
// m_chronoTintStatusType = TINT_STATUS_INVALID;

m_heightAboveTerrainIncludesWater = false;

} // end GlobalData


Expand Down
Loading