2021-01-01 19:50:16 +01:00
|
|
|
#include <stdio.h>
|
2021-02-10 16:03:02 +01:00
|
|
|
#include <windows.h>
|
2021-01-01 19:50:16 +01:00
|
|
|
|
2021-02-08 11:30:21 +01:00
|
|
|
#include "json_utils.h"
|
2021-02-10 16:03:02 +01:00
|
|
|
#include "mod.h"
|
2021-02-08 01:18:57 +01:00
|
|
|
#include "util.h"
|
2021-01-01 19:50:16 +01:00
|
|
|
|
2021-02-13 14:58:42 +01:00
|
|
|
#include "game/control.h"
|
2021-02-13 17:23:14 +01:00
|
|
|
#include "game/draw.h"
|
2021-02-13 14:58:42 +01:00
|
|
|
#include "game/game.h"
|
|
|
|
#include "game/health.h"
|
|
|
|
#include "game/items.h"
|
|
|
|
#include "game/lara.h"
|
|
|
|
#include "game/lot.h"
|
2021-02-13 18:46:57 +01:00
|
|
|
#include "game/setup.h"
|
2021-02-13 14:58:42 +01:00
|
|
|
#include "game/shell.h"
|
|
|
|
|
2021-01-01 19:50:16 +01:00
|
|
|
HINSTANCE hInstance = NULL;
|
|
|
|
|
2021-02-13 14:58:42 +01:00
|
|
|
static void TR1MInject()
|
2021-02-10 16:03:02 +01:00
|
|
|
{
|
2021-02-13 14:58:42 +01:00
|
|
|
TR1MInjectControl();
|
2021-02-13 17:23:14 +01:00
|
|
|
TR1MInjectDraw();
|
2021-02-13 14:58:42 +01:00
|
|
|
TR1MInjectGame();
|
|
|
|
TR1MInjectHealth();
|
|
|
|
TR1MInjectItems();
|
2021-02-13 17:23:14 +01:00
|
|
|
TR1MInjectLOT();
|
2021-02-13 14:58:42 +01:00
|
|
|
TR1MInjectLara();
|
|
|
|
TR1MInjectLaraMisc();
|
2021-02-13 18:46:57 +01:00
|
|
|
TR1MInjectSetup();
|
2021-02-13 14:58:42 +01:00
|
|
|
TR1MInjectShell();
|
2021-01-01 19:50:16 +01:00
|
|
|
}
|
|
|
|
|
2021-02-13 14:58:42 +01:00
|
|
|
static int TR1MReadConfig()
|
2021-02-10 16:03:02 +01:00
|
|
|
{
|
|
|
|
FILE* fp = fopen("TR1Main.json", "rb");
|
2021-02-08 11:30:21 +01:00
|
|
|
if (!fp) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fseek(fp, 0, SEEK_END);
|
|
|
|
int cfg_size = ftell(fp);
|
|
|
|
fseek(fp, 0, SEEK_SET);
|
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
char* cfg_data = malloc(cfg_size);
|
2021-02-08 11:50:39 +01:00
|
|
|
if (!cfg_data) {
|
|
|
|
fclose(fp);
|
|
|
|
return 0;
|
|
|
|
}
|
2021-02-08 11:30:21 +01:00
|
|
|
fread(cfg_data, 1, cfg_size, fp);
|
2021-02-08 11:50:39 +01:00
|
|
|
fclose(fp);
|
2021-02-08 11:30:21 +01:00
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
json_value* json = json_parse((const json_char*)cfg_data, cfg_size);
|
2021-02-08 11:30:21 +01:00
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
TR1MConfig.disable_healing_between_levels =
|
|
|
|
tr1m_json_get_boolean_value(json, "disable_healing_between_levels");
|
|
|
|
TR1MConfig.disable_medpacks =
|
|
|
|
tr1m_json_get_boolean_value(json, "disable_medpacks");
|
2021-02-13 19:00:58 +01:00
|
|
|
TR1MConfig.disable_magnums =
|
|
|
|
tr1m_json_get_boolean_value(json, "disable_magnums");
|
|
|
|
TR1MConfig.disable_uzis = tr1m_json_get_boolean_value(json, "disable_uzis");
|
|
|
|
TR1MConfig.disable_shotgun =
|
|
|
|
tr1m_json_get_boolean_value(json, "disable_shotgun");
|
2021-02-10 23:59:11 +01:00
|
|
|
TR1MConfig.enable_red_healthbar =
|
|
|
|
tr1m_json_get_boolean_value(json, "enable_red_healthbar");
|
2021-02-10 22:31:06 +01:00
|
|
|
TR1MConfig.enable_enemy_healthbar =
|
|
|
|
tr1m_json_get_boolean_value(json, "enable_enemy_healthbar");
|
2021-02-13 16:47:38 +01:00
|
|
|
TR1MConfig.enable_look_while_running =
|
|
|
|
tr1m_json_get_boolean_value(json, "enable_look_while_running");
|
2021-02-10 16:03:02 +01:00
|
|
|
TR1MConfig.fix_end_of_level_freeze =
|
|
|
|
tr1m_json_get_boolean_value(json, "fix_end_of_level_freeze");
|
2021-02-08 11:30:21 +01:00
|
|
|
|
|
|
|
json_value_free(json);
|
|
|
|
free(cfg_data);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
2021-01-01 19:50:16 +01:00
|
|
|
switch (fdwReason) {
|
2021-02-10 16:03:02 +01:00
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
freopen("./TR1Main.log", "w", stdout);
|
2021-02-13 14:58:42 +01:00
|
|
|
TR1MReadConfig();
|
2021-02-10 16:03:02 +01:00
|
|
|
TRACE("Attached");
|
|
|
|
hInstance = hinstDLL;
|
2021-02-13 14:58:42 +01:00
|
|
|
TR1MInject();
|
2021-02-10 16:03:02 +01:00
|
|
|
break;
|
2021-01-01 19:50:16 +01:00
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
TRACE("Detached");
|
|
|
|
break;
|
2021-01-01 19:50:16 +01:00
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
case DLL_THREAD_ATTACH:
|
|
|
|
break;
|
2021-01-01 19:50:16 +01:00
|
|
|
|
2021-02-10 16:03:02 +01:00
|
|
|
case DLL_THREAD_DETACH:
|
|
|
|
break;
|
2021-01-01 19:50:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|