Begin transition to the new ModLoader paradigm. Begin cleaning up code.

This commit is contained in:
Robert MacGregor 2017-07-21 04:30:15 -04:00
parent 015a9f4dc8
commit cb9895a38e
39 changed files with 1429 additions and 967 deletions

View file

@ -0,0 +1,24 @@
#pragma once
#include <DXAPI/Move.h>
#include <DXAPI/GameConnection.h>
namespace DX
{
class AIConnection : public GameConnection
{
public:
AIConnection(unsigned int obj);
//! Whether or not this bot should use custom moves.
bool mUseCustomMoves;
//! The custom move for this bot.
Move mCustomMove;
/**
* @brief Computes the current move for this bot.
*/
void generateMove(void);
};
} // End NameSpace DX

View file

@ -38,13 +38,25 @@ namespace DX
typedef void* UnresolvedObject;
const char *GetModPaths(void);
bool IsFile(const char *filename);
const char * StringTableInsert(const char * str,bool casesensitive) ;
const char * StringTableInsert(const char * str,bool casesensitive);
bool GetRelativePath(const char *filename, char *ret, int buffer_length);
bool GetRunningMod(char *ret, int buffer_length);
bool memPatch(unsigned int addr, unsigned char * data, unsigned int size);
bool memToHex(unsigned int addr, char * dst, int size, bool spaces);
unsigned int memToUInt(unsigned int addr);
float memToFloat(unsigned int addr);
bool SanitizeFileName(char *ret, int buffer_length);
//! Initializes all hooks for the engine.
void initializeHooks(void);
} // End NameSpace DX

View file

@ -7,12 +7,18 @@
namespace DX
{
/**
* @brief A class representing an incoming connection to the Tribes 2 server.
*/
class GameConnection : public NetConnection
{
public:
GameConnection(unsigned int obj);
public:
GameConnection(unsigned int obj);
ShapeBase getControlObject(void);
/**
* @brief Gets the control object this game connection is controlling.
* @return The shapebase instance being controlled.
*/
ShapeBase getControlObject(void);
};
} // End NameSpace DX

View file

@ -6,7 +6,9 @@
#include <LinkerAPI.h>
namespace DX
{
/**
* @brief Move structure.
*/
struct Move {
int px;
int py;
@ -26,13 +28,14 @@ namespace DX
bool triggers[6];
};
struct AIMove {
unsigned int id;
Move move;
bool used;
};
float clampFloat(float in);
float clampMove(float in);
void generateNullMove(Move * ret);
};

View file

@ -15,5 +15,7 @@ namespace DX
const unsigned int &identifier;
const unsigned int base_pointer_value;
const unsigned int &dataBlock;
char& mName;
};
} // End NameSpace DX

View file

@ -0,0 +1,39 @@
/**
* @brief ModLoader main include file.
*/
namespace ModLoader
{
//! A pointer type for a server process function.
typedef void (*ServerProcessPointer)(unsigned int);
typedef void (*InitializeModPointer)();
typedef void (*DeinitializeModPointer)();
typedef const char* (*GetManagementNamePointer)();
//! A pointer type for reading the supported mod loader version for this mod.
typedef unsigned int (*GetModLoaderVersionPointer)();
class ModLoaderCallables
{
public:
//! Hook function that is called when the mod is loaded.
InitializeModPointer mInitializeModPointer;
//! Hook function that is called when the mod is unloaded.
DeinitializeModPointer mDeinitializeModPointer;
//! Hook function for the server update loop.
ServerProcessPointer mServerProcessPointer;
//! Function called to get the name of the script object to use for registering mod management functions.
GetManagementNamePointer mGetManagementName;
};
/**
* @brief Returns the hook information from the loaded mod.
*/
typedef ModLoaderCallables* (*GetModCallablesPointer)();
}