[bot] Add CGameMode::Load(...)

This commit is contained in:
RD42 2024-02-21 19:44:43 +08:00
parent 089ff5df25
commit 1bdaff6125
2 changed files with 27 additions and 0 deletions

View File

@ -1,6 +1,7 @@
#include "main.h"
int AMXAPI aux_LoadProgram(AMX* amx, char* filename);
void AMXPrintError(CGameMode* pGameMode, AMX *amx, int error);
char szGameModeFileName[256];
@ -22,6 +23,31 @@ CGameMode::~CGameMode()
//----------------------------------------------------------------------------------
bool CGameMode::Load(char* pFileName)
{
if (m_bInitialised)
Unload();
FILE* f = fopen(pFileName, "rb");
if (!f) return false;
fclose(f);
memset((void*)&m_amx, 0, sizeof(AMX));
m_fSleepTime = 0.0f;
strcpy(szGameModeFileName, pFileName);
int err = aux_LoadProgram(&m_amx, szGameModeFileName);
if (err != AMX_ERR_NONE)
{
AMXPrintError(this, &m_amx, err);
return false;
}
return false;
}
//----------------------------------------------------------------------------------
void CGameMode::Unload()
{
// TODO: CGameMode::Unload

View File

@ -20,6 +20,7 @@ public:
char* GetFileName() { return &szGameModeFileName[0]; };
bool Load(char* pFileName);
void Unload();
void Frame(float fElapsedTime);