forked from serpi90/fakew3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because the previous version did not wait for the process to finish, it was not possible to host games.
- Loading branch information
Showing
3 changed files
with
67 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <windows.h> | ||
#include <stdio.h> | ||
|
||
#define MAX_COMMAND_SIZE 1024 | ||
|
||
int launchGame( char commandLine[] ) { | ||
STARTUPINFO startupInfo; | ||
PROCESS_INFORMATION processInformation; | ||
ZeroMemory( &startupInfo, sizeof( startupInfo ) ); | ||
startupInfo.cb = sizeof( startupInfo ); | ||
ZeroMemory( &processInformation, sizeof( processInformation ) ); | ||
|
||
/* Start the child process. */ | ||
if( CreateProcess( NULL, commandLine, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation ) ) { | ||
printf( "Waiting for the process to finish ...\r\n" ); | ||
/* Wait until child process exits. */ | ||
WaitForSingleObject( processInformation.hProcess, INFINITE ); | ||
/* Close process and thread handles. */ | ||
CloseHandle( processInformation.hProcess ); | ||
CloseHandle( processInformation.hThread ); | ||
return EXIT_SUCCESS; | ||
} else { | ||
printf( "Failed to start the process (%d).\n", GetLastError() ); | ||
return EXIT_FAILURE; | ||
} | ||
} | ||
|
||
int main( ) { | ||
const char configFileName[] = "fakew3.txt"; | ||
char defaultCommandLine[] = "\"C:\\Program Files (x86)\\Warcraft III\\Frozen Throne.exe\" -window"; | ||
char commandLine[MAX_COMMAND_SIZE]; | ||
FILE * configFile = fopen( configFileName, "r" ); | ||
|
||
if( configFile == NULL ) { | ||
return launchGame( defaultCommandLine ); | ||
} else if( fgets( commandLine, MAX_COMMAND_SIZE, configFile ) == NULL ) { | ||
printf( "Error reading configuration file %s, using default %s\r\n", configFileName, defaultCommandLine ); | ||
fclose( configFile ); | ||
return launchGame( defaultCommandLine ); | ||
} else { | ||
printf( "Starting %s\r\n", commandLine ); | ||
fclose( configFile ); | ||
return launchGame( commandLine ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# FakeW3 | ||
|
||
Used to bypass around *GameRanger* limitation of not being able to launch *Warcraft III* in windowed mode. | ||
|
||
To run *Warcraft III* in windowed mode you must pass the `-window` argument to the game, but *GameRanger* does not have an option for that. The solution was to take a program that requires no arguments, but launches the game in windowed mode. | ||
|
||
This program attempts to read the command line to execute from a configuration file. If file is missing or there is an error reading it, then it will tttempt to use default *Warcraft III* location: `C:\Program Files (x86)\Warcraft III\Frozen Throne.exe`. | ||
|
||
## Configuration | ||
|
||
The configuration file **fakew3.txt** only has the command line to execute, using the full path to the game (and passing the required `-window` argument). Example: | ||
|
||
``` | ||
"C:\Program Files (x86)\Warcraft III\Frozen Throne.exe" -window``` | ||
|
||
Please remember to wrap the path (but not the `-window` argument) with double quotes `"`, as shown in the example. | ||
|
||
## Additional Files | ||
|
||
Currently *GameRanger* requres an executable file named **Frozen Throne.exe** and a file named **War3x.mpq** to be present in the same folder to allow it to be selected as *Warcraft III: Frozen Throne*. An empty file with that name currently does the trick. | ||
|
||
I have not tested it but my guess is that for *Warcraft III: Reign of Chaos* you need an empty file named **War3.mpq**, and rename this program to **Warcraft III.exe** |