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-14 16:07:16 +01:00
|
|
|
#include "game/effects.h"
|
2021-02-13 14:58:42 +01:00
|
|
|
#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-14 16:07:16 +01:00
|
|
|
#include "game/text.h"
|
2021-02-17 23:59:55 +01:00
|
|
|
#include "specific/file.h"
|
|
|
|
#include "specific/game.h"
|
|
|
|
#include "specific/init.h"
|
|
|
|
#include "specific/input.h"
|
|
|
|
#include "specific/output.h"
|
2021-02-13 14:58:42 +01:00
|
|
|
|
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-17 23:59:55 +01:00
|
|
|
TR1MInjectGameControl();
|
|
|
|
TR1MInjectGameDraw();
|
|
|
|
TR1MInjectGameEffects();
|
|
|
|
TR1MInjectGameHealth();
|
|
|
|
TR1MInjectGameItems();
|
|
|
|
TR1MInjectGameLOT();
|
|
|
|
TR1MInjectGameLara();
|
|
|
|
TR1MInjectGameLaraMisc();
|
2021-02-18 16:02:36 +01:00
|
|
|
TR1MInjectGameLaraSurf();
|
2021-02-17 23:59:55 +01:00
|
|
|
TR1MInjectGameLaraSwim();
|
|
|
|
TR1MInjectGameSetup();
|
|
|
|
TR1MInjectGameText();
|
|
|
|
TR1MInjectSpecificFile();
|
|
|
|
TR1MInjectSpecificGame();
|
|
|
|
TR1MInjectSpecificInit();
|
|
|
|
TR1MInjectSpecificInput();
|
|
|
|
TR1MInjectSpecificOutput();
|
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-13 21:32:42 +01:00
|
|
|
TR1MData.medipack_cooldown = 0;
|
|
|
|
|
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-14 14:41:41 +01:00
|
|
|
TR1MConfig.enable_enhanced_look =
|
|
|
|
tr1m_json_get_boolean_value(json, "enable_enhanced_look");
|
2021-02-14 20:20:53 +01:00
|
|
|
TR1MConfig.enable_enhanced_ui =
|
|
|
|
tr1m_json_get_boolean_value(json, "enable_enhanced_ui");
|
2021-02-15 01:58:41 +01:00
|
|
|
|
|
|
|
const char* healthbar_showing_mode =
|
|
|
|
tr1m_json_get_string_value(json, "healthbar_showing_mode");
|
|
|
|
TR1MConfig.healthbar_showing_mode = TR1M_BSM_DEFAULT;
|
|
|
|
if (healthbar_showing_mode) {
|
|
|
|
if (!strcmp(healthbar_showing_mode, "flashing")) {
|
|
|
|
TR1MConfig.healthbar_showing_mode = TR1M_BSM_FLASHING;
|
|
|
|
} else if (!strcmp(healthbar_showing_mode, "always")) {
|
|
|
|
TR1MConfig.healthbar_showing_mode = TR1M_BSM_ALWAYS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-13 21:32:42 +01:00
|
|
|
TR1MConfig.enable_numeric_keys =
|
|
|
|
tr1m_json_get_boolean_value(json, "enable_numeric_keys");
|
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-13 19:39:56 +01:00
|
|
|
TR1MConfig.fix_tihocan_secret_sound =
|
|
|
|
tr1m_json_get_boolean_value(json, "fix_tihocan_secret_sound");
|
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;
|
|
|
|
}
|