Address review
This commit is contained in:
parent
2d139ac435
commit
6b9e36b3b7
@ -17,7 +17,7 @@ namespace Components
|
||||
|
||||
struct BotAction
|
||||
{
|
||||
const char* action;
|
||||
std::string action;
|
||||
int key;
|
||||
};
|
||||
|
||||
@ -38,26 +38,18 @@ namespace Components
|
||||
{ "holdbreath", Game::usercmdButtonBits::CMD_BUTTON_BREATH },
|
||||
{ "usereload", Game::usercmdButtonBits::CMD_BUTTON_USE_RELOAD },
|
||||
{ "activate", Game::usercmdButtonBits::CMD_BUTTON_ACTIVATE },
|
||||
{ "0", Bots::NUM_0 },
|
||||
{ "1", Bots::NUM_1 },
|
||||
{ "2", Bots::NUM_2 },
|
||||
{ "3", Bots::NUM_3 },
|
||||
{ "4", Bots::NUM_4},
|
||||
{ "5", Bots::NUM_5 },
|
||||
{ "6", Bots::NUM_6 },
|
||||
{ "7", Bots::NUM_7 },
|
||||
{ "8", Bots::NUM_8 },
|
||||
{ "9", Bots::NUM_9 }
|
||||
};
|
||||
|
||||
int Bots::BuildConnectString(char* buffer, const char* connectString, int num, int, int protocol, int checksum, int statVer, int statStuff, int port)
|
||||
{
|
||||
static size_t botId = 0;
|
||||
static bool loadedNames = false; // Load file only once
|
||||
const char* botName;
|
||||
|
||||
if (Bots::BotNames.empty())
|
||||
if (Bots::BotNames.empty() && !loadedNames)
|
||||
{
|
||||
FileSystem::File bots("bots.txt");
|
||||
loadedNames = true;
|
||||
|
||||
if (bots.exists())
|
||||
{
|
||||
@ -211,13 +203,13 @@ namespace Components
|
||||
|
||||
for (auto i = 0u; i < std::extent_v<decltype(BotActions)>; ++i)
|
||||
{
|
||||
if (strcmp(&action[1], BotActions[i].action) != 0)
|
||||
if (Utils::String::ToLower(&action[1]) != BotActions[i].action)
|
||||
continue;
|
||||
|
||||
if (action[0] == '+')
|
||||
g_botai[entref.entnum].buttons |= BotActions[i].key;
|
||||
else
|
||||
g_botai[entref.entnum].buttons &= ~(BotActions[i].key);
|
||||
g_botai[entref.entnum].buttons &= ~BotActions[i].key;
|
||||
|
||||
g_botai[entref.entnum].active = true;
|
||||
return;
|
||||
@ -362,6 +354,7 @@ namespace Components
|
||||
Logger::Print("Warning: %s is not a valid input\n"
|
||||
"Usage: %s optional <number of bots> or optional <\"all\">\n",
|
||||
input, params->get(0));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -383,5 +376,14 @@ namespace Components
|
||||
});
|
||||
|
||||
Bots::AddMethods();
|
||||
|
||||
// Reset activate so test clients can be used after unloading bot warfare
|
||||
Script::OnVMShutdown([]
|
||||
{
|
||||
for (auto i = 0u; i < std::extent_v<decltype(g_botai)>; i++)
|
||||
{
|
||||
g_botai[i].active = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -7,20 +7,6 @@ namespace Components
|
||||
public:
|
||||
Bots();
|
||||
|
||||
enum testClientKeyFlag
|
||||
{
|
||||
NUM_0 = 0x8,
|
||||
NUM_1 = 0x20,
|
||||
NUM_2 = 0x10000,
|
||||
NUM_3 = 0x20000,
|
||||
NUM_4 = 0x100000,
|
||||
NUM_5 = 0x200000,
|
||||
NUM_6 = 0x400000,
|
||||
NUM_7 = 0x800000,
|
||||
NUM_8 = 0x1000000,
|
||||
NUM_9 = 0x2000000
|
||||
};
|
||||
|
||||
private:
|
||||
static std::vector<std::string> BotNames;
|
||||
|
||||
|
@ -67,14 +67,13 @@ namespace Components
|
||||
}
|
||||
|
||||
// Let's not throw error unless we have to
|
||||
if (!Game::scrVmPub->abort_on_error)
|
||||
return;
|
||||
if (Game::scrVmPub->terminal_error)
|
||||
{
|
||||
if (dialogMessage == nullptr)
|
||||
dialogMessage = "";
|
||||
|
||||
if (dialogMessage == nullptr)
|
||||
dialogMessage = "";
|
||||
|
||||
const auto errorLevel = (Game::scrVmPub->terminal_error) ? Game::ERR_SCRIPT_DROP : Game::ERR_SCRIPT;
|
||||
Logger::Error(errorLevel, "\x15script runtime error\n(see console for details)\n%s\n%s", msg, dialogMessage);
|
||||
Logger::Error(Game::ERR_SCRIPT_DROP, "\x15script runtime error\n(see console for details)\n%s\n%s", msg, dialogMessage);
|
||||
}
|
||||
}
|
||||
|
||||
void Script::StoreScriptName(const char* name)
|
||||
@ -408,12 +407,12 @@ namespace Components
|
||||
Script::VMShutdownSignal.connect(std::move(callback));
|
||||
}
|
||||
|
||||
void Script::ScrShutdownSystemStub(int num)
|
||||
void Script::ScrShutdownSystemStub(unsigned char sys)
|
||||
{
|
||||
Script::VMShutdownSignal();
|
||||
|
||||
// Scr_ShutdownSystem
|
||||
Utils::Hook::Call<void(int)>(0x421EE0)(num);
|
||||
Utils::Hook::Call<void(unsigned char)>(0x421EE0)(sys);
|
||||
}
|
||||
|
||||
unsigned int Script::SetExpFogStub()
|
||||
@ -713,8 +712,8 @@ namespace Components
|
||||
Utils::Hook(0x61E92E, Script::VMExecuteInternalStub, HOOK_JUMP).install()->quick();
|
||||
Utils::Hook::Nop(0x61E933, 1);
|
||||
|
||||
Utils::Hook(0x47548B, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x4D06BA, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x47548B, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick(); // G_LoadGame
|
||||
Utils::Hook(0x4D06BA, Script::ScrShutdownSystemStub, HOOK_CALL).install()->quick(); // G_ShutdownGame
|
||||
|
||||
Scheduler::OnFrame([]()
|
||||
{
|
||||
@ -735,6 +734,7 @@ namespace Components
|
||||
Script::LastFrameTime = nowMs;
|
||||
});
|
||||
|
||||
#ifdef _DEBUG
|
||||
Script::AddFunction("DebugBox", [](Game::scr_entref_t)
|
||||
{
|
||||
const auto* message = Game::Scr_GetString(0);
|
||||
@ -746,6 +746,7 @@ namespace Components
|
||||
|
||||
MessageBoxA(nullptr, message, "DEBUG", MB_OK);
|
||||
}, true);
|
||||
#endif
|
||||
|
||||
Script::AddFunctions();
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace Components
|
||||
static Game::scr_function_t GetFunction(void* caller, const char** name, int* isDev);
|
||||
static void GetFunctionStub();
|
||||
|
||||
static void ScrShutdownSystemStub(int);
|
||||
static void ScrShutdownSystemStub(unsigned char sys);
|
||||
static void StoreScriptBaseProgramNumStub();
|
||||
static void StoreScriptBaseProgramNum();
|
||||
static void Scr_PrintPrevCodePosStub();
|
||||
|
@ -260,6 +260,7 @@ namespace Game
|
||||
Scr_GetFunctionHandle_t Scr_GetFunctionHandle = Scr_GetFunctionHandle_t(0x4234F0);
|
||||
|
||||
Scr_GetString_t Scr_GetString = Scr_GetString_t(0x425900);
|
||||
Scr_GetConstString_t Scr_GetConstString = Scr_GetConstString_t(0x494830);
|
||||
Scr_GetDebugString_t Scr_GetDebugString = Scr_GetDebugString_t(0x4EBF50);
|
||||
Scr_GetFloat_t Scr_GetFloat = Scr_GetFloat_t(0x443140);
|
||||
Scr_GetInt_t Scr_GetInt = Scr_GetInt_t(0x4F31D0);
|
||||
|
@ -648,10 +648,10 @@ namespace Game
|
||||
typedef void(__cdecl * Scr_AddIString_t)(const char* value);
|
||||
extern Scr_AddIString_t Scr_AddIString;
|
||||
|
||||
typedef void(__cdecl * Scr_AddInt_t)(int num);
|
||||
typedef void(__cdecl * Scr_AddInt_t)(int value);
|
||||
extern Scr_AddInt_t Scr_AddInt;
|
||||
|
||||
typedef void(__cdecl * Scr_AddFloat_t)(float);
|
||||
typedef void(__cdecl * Scr_AddFloat_t)(float value);
|
||||
extern Scr_AddFloat_t Scr_AddFloat;
|
||||
|
||||
typedef void(__cdecl * Scr_AddObject_t)(unsigned int id);
|
||||
@ -666,19 +666,22 @@ namespace Game
|
||||
typedef int(__cdecl * Scr_LoadScript_t)(const char*);
|
||||
extern Scr_LoadScript_t Scr_LoadScript;
|
||||
|
||||
typedef const char*(__cdecl * Scr_GetString_t)(unsigned int);
|
||||
typedef const char*(__cdecl * Scr_GetString_t)(unsigned int index);
|
||||
extern Scr_GetString_t Scr_GetString;
|
||||
|
||||
typedef unsigned int(__cdecl * Scr_GetConstString_t)(unsigned int index);
|
||||
extern Scr_GetConstString_t Scr_GetConstString;
|
||||
|
||||
typedef const char*(__cdecl * Scr_GetDebugString_t)(unsigned int index);
|
||||
extern Scr_GetDebugString_t Scr_GetDebugString;
|
||||
|
||||
typedef float(__cdecl * Scr_GetFloat_t)(unsigned int);
|
||||
typedef float(__cdecl * Scr_GetFloat_t)(unsigned int index);
|
||||
extern Scr_GetFloat_t Scr_GetFloat;
|
||||
|
||||
typedef int(__cdecl * Scr_GetInt_t)(unsigned int);
|
||||
typedef int(__cdecl * Scr_GetInt_t)(unsigned int index);
|
||||
extern Scr_GetInt_t Scr_GetInt;
|
||||
|
||||
typedef unsigned int(__cdecl * Scr_GetObject_t)(unsigned int);
|
||||
typedef unsigned int(__cdecl * Scr_GetObject_t)(unsigned int index);
|
||||
extern Scr_GetObject_t Scr_GetObject;
|
||||
|
||||
typedef unsigned int(__cdecl * Scr_GetNumParam_t)();
|
||||
|
Loading…
Reference in New Issue
Block a user