Skip to content

Commit

Permalink
Implement some of TerrainLogic
Browse files Browse the repository at this point in the history
  • Loading branch information
jonwil committed Apr 17, 2023
1 parent 95e08f8 commit dffc784
Show file tree
Hide file tree
Showing 22 changed files with 1,703 additions and 24 deletions.
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ set(GAMEENGINE_SRC
game/logic/object/armortemplateset.cpp
game/logic/object/experiencetracker.cpp
game/logic/object/firingtracker.cpp
game/logic/object/ghostobject.cpp
game/logic/object/locomotor.cpp
game/logic/object/object.cpp
game/logic/object/objectcreationlist.cpp
Expand All @@ -284,6 +285,8 @@ set(GAMEENGINE_SRC
game/logic/object/weaponset.cpp
game/logic/object/weapontemplateset.cpp
game/logic/object/behavior/autohealbehavior.cpp
game/logic/object/behavior/bridgebehavior.cpp
game/logic/object/behavior/bridgetowerbehavior.cpp
game/logic/object/behavior/overchargebehavior.cpp
game/logic/object/behavior/rebuildholebehavior.cpp
game/logic/object/collide/collidemodule.cpp
Expand Down
3 changes: 2 additions & 1 deletion src/game/client/terrainroads.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class TerrainRoadType : public MemoryPoolObject
Utf8String Get_Bridge_Model_Name_Really_Damaged() { return m_bridgeModelNameReallyDamaged; }
Utf8String Get_Texture_Broken() { return m_textureBroken; }
Utf8String Get_Bridge_Model_Name_Broken() { return m_bridgeModelNameBroken; }
Utf8String Get_Tower_Object_Name(BridgeTowerType type) { return m_towerObjectName[type]; }

void Set_Name(Utf8String name) { m_name = name; }
void Set_Damaged_OCL(int dmg, int effect, Utf8String name) { m_damagedTransitionOCL[dmg][effect] = name; }
Expand Down Expand Up @@ -137,4 +138,4 @@ class TerrainRoadCollection : public SubsystemInterface
extern TerrainRoadCollection *&g_theTerrainRoads;
#else
extern TerrainRoadCollection *g_theTerrainRoads;
#endif
#endif
7 changes: 3 additions & 4 deletions src/game/common/mapobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "rendobj.h"
#include "sideslist.h"
#include "staticnamekey.h"
#include "terrainroads.h"
#include "thingtemplate.h"
#include <deque>
#ifndef GAME_DLL
Expand Down Expand Up @@ -260,17 +259,17 @@ void MapObject::Set_Name(Utf8String name)
m_objectName = name;
}

int MapObject::Get_Waypoint_ID()
WaypointID MapObject::Get_Waypoint_ID()
{
return Get_Properties()->Get_Int(g_waypointIDKey);
return static_cast<WaypointID>(Get_Properties()->Get_Int(g_waypointIDKey));
}

Utf8String MapObject::Get_Waypoint_Name()
{
return Get_Properties()->Get_AsciiString(g_waypointNameKey);
}

void MapObject::Set_Waypoint_ID(int i)
void MapObject::Set_Waypoint_ID(WaypointID i)
{
Get_Properties()->Set_Int(g_waypointIDKey, i);
}
Expand Down
5 changes: 3 additions & 2 deletions src/game/common/mapobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "asciistring.h"
#include "coord.h"
#include "dict.h"
#include "terrainlogic.h"
#include "terrainroads.h"

class ThingTemplate;
Expand Down Expand Up @@ -89,9 +90,9 @@ class MapObject : public MemoryPoolObject
static void Fast_Assign_All_Unique_IDs();
void Set_Thing_Template(const ThingTemplate *thing);
void Set_Name(Utf8String name);
int Get_Waypoint_ID();
WaypointID Get_Waypoint_ID();
Utf8String Get_Waypoint_Name();
void Set_Waypoint_ID(int i);
void Set_Waypoint_ID(WaypointID i);
void Set_Waypoint_Name(Utf8String n);
static int Count_Map_Objects_With_Owner(const Utf8String &n);
const ThingTemplate *Get_Thing_Template();
Expand Down
4 changes: 4 additions & 0 deletions src/game/common/staticnamekey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ StaticNameKey g_objectSoundAmbientVolume("objectSoundAmbientVolume");
StaticNameKey g_objectSoundAmbientMinRange("objectSoundAmbientMinRange");
StaticNameKey g_objectSoundAmbientMaxRange("objectSoundAmbientMaxRange");
StaticNameKey g_objectSoundAmbientPriority("objectSoundAmbientPriority");
StaticNameKey g_waypointPathLabel1("waypointPathLabel1");
StaticNameKey g_waypointPathLabel2("waypointPathLabel2");
StaticNameKey g_waypointPathLabel3("waypointPathLabel3");
StaticNameKey g_waypointPathBiDirectional("waypointPathBiDirectional");

NameKeyType StaticNameKey::Key()
{
Expand Down
4 changes: 4 additions & 0 deletions src/game/common/staticnamekey.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,7 @@ extern StaticNameKey g_objectSoundAmbientVolume;
extern StaticNameKey g_objectSoundAmbientMinRange;
extern StaticNameKey g_objectSoundAmbientMaxRange;
extern StaticNameKey g_objectSoundAmbientPriority;
extern StaticNameKey g_waypointPathLabel1;
extern StaticNameKey g_waypointPathLabel2;
extern StaticNameKey g_waypointPathLabel3;
extern StaticNameKey g_waypointPathBiDirectional;
1 change: 1 addition & 0 deletions src/game/common/system/geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class GeometryInfo : public SnapShot
float Get_Bounding_Circle_Radius() const { return m_boundingCircleRadius; }
float Get_Bounding_Sphere_Radius() const { return m_boundingSphereRadius; }
GeometryType Get_Type() const { return m_type; }
bool Is_Small() const { return m_isSmall; }

private:
GeometryType m_type;
Expand Down
32 changes: 32 additions & 0 deletions src/game/logic/ai/aipathfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,35 @@ void Pathfinder::Remove_Pos(Object *obj)
Call_Method<void, Pathfinder, Object *>(PICK_ADDRESS(0x0056DA30, 0x0089E389), this, obj);
#endif
}

void Pathfinder::Change_Bridge_State(PathfindLayerEnum layer, bool b)
{
#ifdef GAME_DLL
Call_Method<void, Pathfinder, PathfindLayerEnum, bool>(PICK_ADDRESS(0x0056C970, 0x0089D713), this, layer, b);
#endif
}

PathfindLayerEnum Pathfinder::Add_Bridge(Bridge *bridge)
{
#ifdef GAME_DLL
return Call_Method<PathfindLayerEnum, Pathfinder, Bridge *>(PICK_ADDRESS(0x0055F580, 0x008908BE), this, bridge);
#else
return LAYER_INVALID;
#endif
}

bool Pathfinder::Is_Point_On_Wall(const Coord3D *point)
{
#ifdef GAME_DLL
return Call_Method<bool, Pathfinder, const Coord3D *>(PICK_ADDRESS(0x0055F450, 0x00890845), this, point);
#else
return false;
#endif
}

void Pathfinder::Force_Map_Recalculation()
{
#ifdef GAME_DLL
Call_Method<void, Pathfinder>(PICK_ADDRESS(0x00560E90, 0x00892519), this);
#endif
}
5 changes: 5 additions & 0 deletions src/game/logic/ai/aipathfind.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,14 @@ class Pathfinder : public PathfindServicesInterface, public SnapShot
void Classify_Object_Footprint(Object *obj, bool insert);
void Update_Pos(Object *obj, const Coord3D *pos);
void Remove_Pos(Object *obj);
void Change_Bridge_State(PathfindLayerEnum layer, bool b);
PathfindLayerEnum Add_Bridge(Bridge *bridge);
bool Is_Point_On_Wall(const Coord3D *point);
void Force_Map_Recalculation();

void Remove_Object_From_Pathfind_Map(Object *obj) { Classify_Object_Footprint(obj, false); }
void Add_Object_To_Pathfind_Map(Object *obj) { Classify_Object_Footprint(obj, true); }
float Get_Wall_Height() const { return m_wallHeight; }

private:
PathfindCell *m_mapPointer; // not 100% confirmed
Expand Down
Loading

0 comments on commit dffc784

Please sign in to comment.