TRX/src/main.c

139 lines
3.9 KiB
C
Raw Normal View History

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-18 16:40:32 +01:00
static void Tomb1MInject()
2021-02-10 16:03:02 +01:00
{
2021-02-18 16:40:32 +01:00
Tomb1MInjectGameControl();
Tomb1MInjectGameDraw();
Tomb1MInjectGameEffects();
Tomb1MInjectGameHealth();
Tomb1MInjectGameItems();
Tomb1MInjectGameLOT();
Tomb1MInjectGameLara();
2021-02-20 01:09:31 +01:00
Tomb1MInjectGameLaraGun1();
2021-02-20 11:33:32 +01:00
Tomb1MInjectGameLaraGun2();
2021-02-18 16:40:32 +01:00
Tomb1MInjectGameLaraMisc();
Tomb1MInjectGameLaraSurf();
Tomb1MInjectGameLaraSwim();
Tomb1MInjectGameSetup();
Tomb1MInjectGameText();
Tomb1MInjectSpecificFile();
Tomb1MInjectSpecificGame();
Tomb1MInjectSpecificInit();
Tomb1MInjectSpecificInput();
Tomb1MInjectSpecificOutput();
2021-01-01 19:50:16 +01:00
}
2021-02-18 16:40:32 +01:00
static int Tomb1MReadConfig()
2021-02-10 16:03:02 +01:00
{
2021-02-18 16:40:32 +01:00
FILE* fp = fopen("Tomb1Main.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-18 16:40:32 +01:00
Tomb1MData.medipack_cooldown = 0;
2021-02-13 21:32:42 +01:00
2021-02-18 16:40:32 +01:00
Tomb1MConfig.disable_healing_between_levels =
2021-02-10 16:03:02 +01:00
tr1m_json_get_boolean_value(json, "disable_healing_between_levels");
2021-02-18 16:40:32 +01:00
Tomb1MConfig.disable_medpacks =
2021-02-10 16:03:02 +01:00
tr1m_json_get_boolean_value(json, "disable_medpacks");
2021-02-18 16:40:32 +01:00
Tomb1MConfig.disable_magnums =
2021-02-13 19:00:58 +01:00
tr1m_json_get_boolean_value(json, "disable_magnums");
2021-02-18 16:40:32 +01:00
Tomb1MConfig.disable_uzis =
tr1m_json_get_boolean_value(json, "disable_uzis");
Tomb1MConfig.disable_shotgun =
2021-02-13 19:00:58 +01:00
tr1m_json_get_boolean_value(json, "disable_shotgun");
2021-02-18 16:40:32 +01:00
Tomb1MConfig.enable_red_healthbar =
2021-02-10 23:59:11 +01:00
tr1m_json_get_boolean_value(json, "enable_red_healthbar");
2021-02-18 16:40:32 +01:00
Tomb1MConfig.enable_enemy_healthbar =
2021-02-10 22:31:06 +01:00
tr1m_json_get_boolean_value(json, "enable_enemy_healthbar");
2021-02-18 16:40:32 +01:00
Tomb1MConfig.enable_enhanced_look =
tr1m_json_get_boolean_value(json, "enable_enhanced_look");
2021-02-18 16:40:32 +01:00
Tomb1MConfig.enable_enhanced_ui =
2021-02-14 20:20:53 +01:00
tr1m_json_get_boolean_value(json, "enable_enhanced_ui");
2021-02-20 01:22:23 +01:00
Tomb1MConfig.enable_shotgun_flash =
tr1m_json_get_boolean_value(json, "enable_shotgun_flash");
const char* healthbar_showing_mode =
tr1m_json_get_string_value(json, "healthbar_showing_mode");
2021-02-18 16:40:32 +01:00
Tomb1MConfig.healthbar_showing_mode = Tomb1M_BSM_DEFAULT;
if (healthbar_showing_mode) {
if (!strcmp(healthbar_showing_mode, "flashing")) {
2021-02-18 16:40:32 +01:00
Tomb1MConfig.healthbar_showing_mode = Tomb1M_BSM_FLASHING;
} else if (!strcmp(healthbar_showing_mode, "always")) {
2021-02-18 16:40:32 +01:00
Tomb1MConfig.healthbar_showing_mode = Tomb1M_BSM_ALWAYS;
}
}
2021-02-18 16:40:32 +01:00
Tomb1MConfig.enable_numeric_keys =
2021-02-13 21:32:42 +01:00
tr1m_json_get_boolean_value(json, "enable_numeric_keys");
2021-02-18 16:40:32 +01:00
Tomb1MConfig.fix_end_of_level_freeze =
2021-02-10 16:03:02 +01:00
tr1m_json_get_boolean_value(json, "fix_end_of_level_freeze");
2021-02-18 16:40:32 +01:00
Tomb1MConfig.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:
2021-02-18 16:40:32 +01:00
freopen("./Tomb1Main.log", "w", stdout);
Tomb1MReadConfig();
2021-02-10 16:03:02 +01:00
TRACE("Attached");
hInstance = hinstDLL;
2021-02-18 16:40:32 +01:00
Tomb1MInject();
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;
}