mirror of
https://github.com/Ragora/T2-CPP.git
synced 2026-03-12 00:40:31 +00:00
Restructured project structure to use a singular SLN; made the T2API common to all projects; adjusted watchdog timer to 8 seconds
This commit is contained in:
parent
e1c5d1dead
commit
527474ff24
79 changed files with 469 additions and 626 deletions
47
CommonAPI/Common/include/DXAPI/DXAPI.h
Normal file
47
CommonAPI/Common/include/DXAPI/DXAPI.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
* @file DXAPI.h
|
||||
* @brief The DXAPI is an API that allows you to manipulate various game objects
|
||||
* in Tribes 2 from raw C++ code. It dynamically resolves the addresses of member
|
||||
* variables as you can't really trust the compiler to produce binary compatible classes,
|
||||
* especially with all the inheritance involved in the original Tribes 2 codebase.
|
||||
*
|
||||
* This code wouldn't be possible without Linker's original gift on the-construct.net forums,
|
||||
* whose files are appropriately labelled in this codebase. These files have been edited where
|
||||
* appropriate in order to make that code play better with the DXAPI.
|
||||
*
|
||||
* @copyright (c) 2014 Robert MacGregor
|
||||
*/
|
||||
|
||||
//#pragma once
|
||||
|
||||
#include "LinkerAPI.h"
|
||||
|
||||
#include <DXAPI/Point3F.h>
|
||||
#include <DXAPI/GameBase.h>
|
||||
#include <DXAPI/NetObject.h>
|
||||
#include <DXAPI/Player.h>
|
||||
#include <DXAPI/Projectile.h>
|
||||
#include <DXAPI/SceneObject.h>
|
||||
#include <DXAPI/ShapeBase.h>
|
||||
#include <DXAPI/SimObject.h>
|
||||
#include <DXAPI/StaticShape.h>
|
||||
#include <DXAPI/GrenadeProjectile.h>
|
||||
#include <DXAPI/FlyingVehicle.h>
|
||||
#include <DXAPI/GameConnection.h>
|
||||
#include <DXAPI/NetConnection.h>
|
||||
#include <DXAPI/TCPObject.h>
|
||||
#include <DXAPI/ScriptObject.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
//! A typedef referring to some type of unresolved object in the game.
|
||||
typedef void* UnresolvedObject;
|
||||
|
||||
const char *GetModPaths(void);
|
||||
bool IsFile(const char *filename);
|
||||
|
||||
bool GetRelativePath(const char *filename, char *ret, int buffer_length);
|
||||
bool GetRunningMod(char *ret, int buffer_length);
|
||||
|
||||
bool SanitizeFileName(char *ret, int buffer_length);
|
||||
} // End NameSpace DX
|
||||
13
CommonAPI/Common/include/DXAPI/FlyingVehicle.h
Normal file
13
CommonAPI/Common/include/DXAPI/FlyingVehicle.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/Vehicle.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
//! Class representing a FlyingVehicle in the game.
|
||||
class FlyingVehicle : public Vehicle
|
||||
{
|
||||
public:
|
||||
FlyingVehicle(unsigned int obj);
|
||||
};
|
||||
} // End NameSpace DX
|
||||
19
CommonAPI/Common/include/DXAPI/GameBase.h
Normal file
19
CommonAPI/Common/include/DXAPI/GameBase.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/SceneObject.h>
|
||||
enum GameBaseMasks {
|
||||
InitialUpdateMask = 1 << 0,
|
||||
DataBlockMask = 1 << 1,
|
||||
ExtendedInfoMask = 1 << 2,
|
||||
NextFreeMask = ExtendedInfoMask << 1
|
||||
};
|
||||
namespace DX
|
||||
{
|
||||
class GameBase : public SceneObject
|
||||
{
|
||||
|
||||
public:
|
||||
GameBase(unsigned int obj);
|
||||
void setProcessTicks(bool proc);
|
||||
};
|
||||
} // End NameSpace DX
|
||||
18
CommonAPI/Common/include/DXAPI/GameConnection.h
Normal file
18
CommonAPI/Common/include/DXAPI/GameConnection.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/Point3F.h>
|
||||
#include <DXAPI/NetConnection.h>
|
||||
#include <LinkerAPI.h>
|
||||
#include <DXAPI/ShapeBase.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
class GameConnection : public NetConnection
|
||||
{
|
||||
public:
|
||||
GameConnection(unsigned int obj);
|
||||
|
||||
ShapeBase getControlObject(void);
|
||||
|
||||
};
|
||||
} // End NameSpace DX
|
||||
13
CommonAPI/Common/include/DXAPI/GrenadeProjectile.h
Normal file
13
CommonAPI/Common/include/DXAPI/GrenadeProjectile.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/Point3F.h>
|
||||
#include <DXAPI/Projectile.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
class GrenadeProjectile : public Projectile
|
||||
{
|
||||
public:
|
||||
GrenadeProjectile(unsigned int obj);
|
||||
};
|
||||
} // End NameSpace DX
|
||||
69
CommonAPI/Common/include/DXAPI/NetConnection.h
Normal file
69
CommonAPI/Common/include/DXAPI/NetConnection.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/Point3F.h>
|
||||
#include <DXAPI/SimObject.h>
|
||||
#include <DXAPI/NetObject.h>
|
||||
#include <LinkerAPI.h>
|
||||
struct GhostInfo;
|
||||
namespace DX
|
||||
{
|
||||
class NetConnection : public SimObject
|
||||
{
|
||||
public:
|
||||
NetConnection(unsigned int obj);
|
||||
S32 getGhostIndex(NetObject obj);
|
||||
unsigned char getGhostFrom();
|
||||
unsigned char getGhostTo();
|
||||
NetObject resolveGhostParent(S32 id);
|
||||
NetObject resolveGhost(S32 id);
|
||||
unsigned int actualbaseptr;
|
||||
GhostInfo * mGhostRefs;
|
||||
NetObject **mLocalGhosts;
|
||||
};
|
||||
} // End NameSpace DX
|
||||
struct GhostRef;
|
||||
struct GhostInfo
|
||||
{
|
||||
// public: // required for MSVC
|
||||
|
||||
// NOTE:
|
||||
// if the size of this structure changes, the
|
||||
// NetConnection::getGhostIndex function MUST be changed
|
||||
// to reflect.
|
||||
|
||||
U32 *obj; // the real object
|
||||
U32 updateMask; // 32 bits of object info
|
||||
GhostRef *updateChain; // chain of updates for this object in packets
|
||||
GhostInfo *nextObjectRef; // next ghost ref for this object (another connection)
|
||||
|
||||
GhostInfo *prevObjectRef; // prev ghost ref for this object
|
||||
U32 *connection;
|
||||
GhostInfo *nextLookupInfo;
|
||||
U32 updateSkipCount;
|
||||
|
||||
U32 flags;
|
||||
F32 priority;
|
||||
U32 index;
|
||||
U32 arrayIndex;
|
||||
|
||||
enum Flags
|
||||
{
|
||||
Valid = BIT(0),
|
||||
InScope = BIT(1),
|
||||
ScopeAlways = BIT(2),
|
||||
NotYetGhosted = BIT(3),
|
||||
Ghosting = BIT(4),
|
||||
KillGhost = BIT(5),
|
||||
KillingGhost = BIT(6),
|
||||
ScopedEvent = BIT(7),
|
||||
ScopeLocalAlways = BIT(8),
|
||||
};
|
||||
};
|
||||
struct GhostRef
|
||||
{
|
||||
U32 mask;
|
||||
U32 ghostInfoFlags;
|
||||
GhostInfo *ghost;
|
||||
GhostRef *nextRef;
|
||||
GhostRef *nextUpdateChain;
|
||||
};
|
||||
22
CommonAPI/Common/include/DXAPI/NetObject.h
Normal file
22
CommonAPI/Common/include/DXAPI/NetObject.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/SimObject.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
enum NetFlags
|
||||
{
|
||||
IsGhost = 1,
|
||||
ScopeAlways = 1 << 6,
|
||||
ScopeLocal = 1 << 7,
|
||||
Ghostable = 1 << 8
|
||||
};
|
||||
|
||||
class NetObject : public SimObject
|
||||
{
|
||||
public:
|
||||
NetObject(unsigned int obj);
|
||||
|
||||
unsigned int &net_flags;
|
||||
};
|
||||
} // End NameSpace DX
|
||||
29
CommonAPI/Common/include/DXAPI/Player.h
Normal file
29
CommonAPI/Common/include/DXAPI/Player.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/Point3F.h>
|
||||
#include <DXAPI/ShapeBase.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
//! Class representing a player object in the game.
|
||||
class Player : public ShapeBase
|
||||
{
|
||||
public:
|
||||
Player(unsigned int obj);
|
||||
|
||||
//! Object Name
|
||||
const char *name;
|
||||
//! Object ID
|
||||
const unsigned int &id;
|
||||
|
||||
//! Player Object Jetting State (readonly, writing it doesn't do anything)
|
||||
const bool &is_jetting;
|
||||
//! Player Object Jumping State (readonly, writing it doesn't do anything)
|
||||
const bool &is_jumping;
|
||||
//! Player Object Using Toggable Pack
|
||||
bool &is_using_toggledpack;
|
||||
|
||||
//! Player Velocity.
|
||||
Point3F velocity;
|
||||
};
|
||||
} // End NameSpace DX
|
||||
17
CommonAPI/Common/include/DXAPI/Point3F.h
Normal file
17
CommonAPI/Common/include/DXAPI/Point3F.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
namespace DX
|
||||
{
|
||||
/**
|
||||
* @brief A class representing a referenced 3D vector of floats in Tribes 2.
|
||||
*/
|
||||
class Point3F
|
||||
{
|
||||
public:
|
||||
Point3F(float &X, float &Y, float &Z);
|
||||
|
||||
float &x;
|
||||
float &y;
|
||||
float &z;
|
||||
};
|
||||
} // End NameSpace DX
|
||||
22
CommonAPI/Common/include/DXAPI/Projectile.h
Normal file
22
CommonAPI/Common/include/DXAPI/Projectile.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/Point3F.h>
|
||||
#include <DXAPI/GameBase.h>
|
||||
|
||||
#include <LinkerAPI.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
class Projectile : public GameBase
|
||||
{
|
||||
public:
|
||||
Projectile(unsigned int obj);
|
||||
|
||||
void explode(const Linker::Point3F &position, const Linker::Point3F &normal, const unsigned int collideType);
|
||||
|
||||
//! Velocity. It is constant because modifying it directly breaks the sim.
|
||||
const Point3F velocity;
|
||||
|
||||
bool &hidden;
|
||||
};
|
||||
} // End NameSpace DX
|
||||
16
CommonAPI/Common/include/DXAPI/SceneObject.h
Normal file
16
CommonAPI/Common/include/DXAPI/SceneObject.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/Point3F.h>
|
||||
#include <DXAPI/NetObject.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
class SceneObject : public NetObject
|
||||
{
|
||||
public:
|
||||
SceneObject(unsigned int obj);
|
||||
|
||||
Point3F position;
|
||||
Point3F scale;
|
||||
};
|
||||
} // End NameSpace DX
|
||||
12
CommonAPI/Common/include/DXAPI/ScriptObject.h
Normal file
12
CommonAPI/Common/include/DXAPI/ScriptObject.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/SimObject.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
class ScriptObject : public SimObject
|
||||
{
|
||||
public:
|
||||
ScriptObject(unsigned int obj);
|
||||
};
|
||||
} // End NameSpace DX
|
||||
17
CommonAPI/Common/include/DXAPI/ShapeBase.h
Normal file
17
CommonAPI/Common/include/DXAPI/ShapeBase.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/GameBase.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
class ShapeBase : public GameBase
|
||||
{
|
||||
public:
|
||||
ShapeBase(unsigned int obj);
|
||||
float &cloak_level;
|
||||
bool &cloaked;
|
||||
//! Heat Level
|
||||
float &heat_level;
|
||||
void setMaskBits(int value);
|
||||
};
|
||||
} // End NameSpace DX
|
||||
16
CommonAPI/Common/include/DXAPI/SimObject.h
Normal file
16
CommonAPI/Common/include/DXAPI/SimObject.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
namespace DX
|
||||
{
|
||||
class SimObject
|
||||
{
|
||||
public:
|
||||
SimObject(unsigned int obj);
|
||||
|
||||
void deleteObject(void);
|
||||
const char *CallMethod(const char *name, unsigned int argc, ...);
|
||||
|
||||
const unsigned int &identifier;
|
||||
const unsigned int base_pointer_value;
|
||||
};
|
||||
} // End NameSpace DX
|
||||
19
CommonAPI/Common/include/DXAPI/StaticShape.h
Normal file
19
CommonAPI/Common/include/DXAPI/StaticShape.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/Point3F.h>
|
||||
#include <DXAPI/ShapeBase.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
//! Class representing a StaticShape in the game.
|
||||
class StaticShape : public ShapeBase
|
||||
{
|
||||
public:
|
||||
StaticShape(unsigned int obj);
|
||||
|
||||
//! Object Name
|
||||
//const char *name;
|
||||
//! Position
|
||||
//const Point3F position;
|
||||
};
|
||||
} // End NameSpace DX
|
||||
14
CommonAPI/Common/include/DXAPI/TCPObject.h
Normal file
14
CommonAPI/Common/include/DXAPI/TCPObject.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/SimObject.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
class TCPObject : public SimObject
|
||||
{
|
||||
public:
|
||||
TCPObject(unsigned int obj);
|
||||
|
||||
unsigned int &state;
|
||||
};
|
||||
} // End NameSpace DX
|
||||
13
CommonAPI/Common/include/DXAPI/Vehicle.h
Normal file
13
CommonAPI/Common/include/DXAPI/Vehicle.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <DXAPI/ShapeBase.h>
|
||||
|
||||
namespace DX
|
||||
{
|
||||
//! Class representing a FlyingVehicle in the game.
|
||||
class Vehicle : public ShapeBase
|
||||
{
|
||||
public:
|
||||
Vehicle(unsigned int obj);
|
||||
};
|
||||
} // End NameSpace DX
|
||||
124
CommonAPI/Common/include/LinkerAPI.h
Normal file
124
CommonAPI/Common/include/LinkerAPI.h
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
// Linker's Tribes 2 API
|
||||
|
||||
#pragma once
|
||||
|
||||
//api stuff
|
||||
|
||||
typedef unsigned int U32;
|
||||
typedef int S32;
|
||||
typedef float F32;
|
||||
|
||||
typedef unsigned int dsize_t;
|
||||
#include <string>
|
||||
|
||||
//for addvariable
|
||||
#define TypeS32 1
|
||||
#define TypeBool 3
|
||||
#define TypeF32 5
|
||||
|
||||
//dshit
|
||||
inline dsize_t dStrlen(const char *str)
|
||||
{
|
||||
return (dsize_t)strlen(str);
|
||||
}
|
||||
|
||||
//class Namespace
|
||||
//{
|
||||
// const char* mName;
|
||||
//};
|
||||
|
||||
//class SimIdDictionary
|
||||
//{
|
||||
//enum
|
||||
//{
|
||||
// DefaultTableSize = 4096,
|
||||
// TableBitMask = 4095
|
||||
// };
|
||||
// Linker::SimObject *table[DefaultTableSize];
|
||||
//};
|
||||
//extern SimIdDictionary* gIdDictionary;
|
||||
|
||||
namespace Linker
|
||||
{
|
||||
class Point3F
|
||||
{
|
||||
public:
|
||||
Point3F(F32 *x, F32 *y, F32 *z)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->z = z;
|
||||
}
|
||||
|
||||
Point3F(void)
|
||||
{
|
||||
this->x = 0;
|
||||
this->y = 0;
|
||||
this->z = 0;
|
||||
}
|
||||
|
||||
F32 *x;
|
||||
F32 *y;
|
||||
F32 *z;
|
||||
};
|
||||
|
||||
struct SimObject
|
||||
{
|
||||
SimObject* group;
|
||||
const char* objectName; //04h: objectName
|
||||
SimObject* nextNameObject; //8
|
||||
SimObject* nextManagerNameObject; //c
|
||||
SimObject* nextIdObject; //10h: nextIdObject
|
||||
U32 stuff; //14
|
||||
U32 mFlags; //18h
|
||||
U32 mNotifyList; //actually a pointer
|
||||
U32 mId; //20h: mId
|
||||
//more stuff
|
||||
};
|
||||
}
|
||||
|
||||
//GuiTSCtrl
|
||||
class GuiTSCtrl {};
|
||||
void GuiTSCtrl_project(GuiTSCtrl *obj, const Linker::Point3F &pt, Linker::Point3F *dest); //fake
|
||||
|
||||
namespace Sim {
|
||||
extern Linker::SimObject* (*findObject)(U32 id);
|
||||
extern Linker::SimObject* (*findObjectc)(const char* name);
|
||||
}
|
||||
|
||||
//console
|
||||
#define BIT(x) (1 << (x))
|
||||
|
||||
|
||||
typedef const char * (*StringCallback)(Linker::SimObject *obj, S32 argc, const char *argv[]);
|
||||
typedef S32 (*IntCallback)(Linker::SimObject *obj, S32 argc, const char *argv[]);
|
||||
typedef F32 (*FloatCallback)(Linker::SimObject *obj, S32 argc, const char *argv[]);
|
||||
typedef void (*VoidCallback)(Linker::SimObject *obj, S32 argc, const char *argv[]);
|
||||
typedef bool (*BoolCallback)(Linker::SimObject *obj, S32 argc, const char *argv[]);
|
||||
|
||||
|
||||
//functions
|
||||
namespace Con
|
||||
{
|
||||
|
||||
extern char * (*getReturnBuffer)(U32 bufferSize);
|
||||
|
||||
extern void (*addMethodB)(const char *nsName, const char *name, BoolCallback cb, const char *usage, S32 minArgs, S32 maxArgs);
|
||||
extern void (*addMethodS)(const char *nsName, const char *name, StringCallback cb, const char *usage, S32 minArgs, S32 maxArgs);
|
||||
extern void (*addMethodI)(const char *nsName, const char *name, IntCallback cb, const char *usage, S32 minArgs, S32 maxArgs);
|
||||
extern bool (*addVariable)(const char *name, S32 t, void *dp);
|
||||
|
||||
extern void (*printf)(const char* fmt,...);
|
||||
extern void (*errorf)(U32 type, const char* fmt,...);
|
||||
|
||||
extern const char * (*getVariable)(const char *name);
|
||||
extern const char * (*execute)(S32 argc, const char *argv[]);
|
||||
extern const char * (*executef)(S32 argc, ...);
|
||||
extern const char * (*executem)(Linker::SimObject *object, S32 argc, const char *argv[]);
|
||||
extern const char * (*evaluate)(const char* string, bool echo, const char *fileName, bool cf);
|
||||
}
|
||||
|
||||
//d-util
|
||||
extern int (*dSscanf)(const char *buffer, const char *format, ...);
|
||||
extern int (*dSprintf)(char *buffer, dsize_t bufferSize, const char *format, ...);
|
||||
extern bool (*dAtob)(const char *str);
|
||||
Loading…
Add table
Add a link
Reference in a new issue