1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

rct2.c: port check_mutex().

This commit is contained in:
Patrick Wijnings
2014-06-19 13:51:54 +02:00
parent f8f70d8d08
commit bf8bc151b9
2 changed files with 25 additions and 1 deletions

View File

@@ -230,7 +230,12 @@ void subsitute_path(char *dest, const char *path, const char *filename)
// rct2: 0x00674B42
void rct2_startup_checks()
{
// check if game is already running
// Check if game is already running
if (check_mutex())
{
RCT2_ERROR("Game is already running");
RCT2_CALLPROC_X(0x006E3838, 0x343, 0xB2B, 0, 0, 0, 0, 0); // exit_with_error
}
RCT2_CALLPROC_EBPSAFE(0x00674C0B);
}
@@ -303,6 +308,24 @@ void check_cmdline_arg()
}
}
// rct2: 0x00407DB0
int check_mutex()
{
const char * const mutex_name = "RollerCoaster Tycoon 2_GSKMUTEX"; // rct2 @ 0x009AAC3D + 0x009A8B50
HANDLE mutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, mutex_name);
if (mutex != NULL)
{
// Already running
CloseHandle(mutex);
return 1;
}
HANDLE status = CreateMutex(NULL, FALSE, mutex_name);
return 0;
}
void rct2_update_2()
{
int tick, tick2;

View File

@@ -228,6 +228,7 @@ static const char * const file_paths[] =
void rct2_endupdate();
void subsitute_path(char *dest, const char *path, const char *filename);
int check_mutex();
const char *get_file_path(int pathId);
void get_system_info();
void get_system_time();