-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
920 additions
and
51 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 |
---|---|---|
|
@@ -33,3 +33,5 @@ | |
|
||
# Projects | ||
Build/* | ||
Win32/* | ||
game.dir/* |
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
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,57 @@ | ||
#pragma once | ||
#include "../Shared/D2Shared.hpp" | ||
|
||
|
||
///////////////////////////////////////////////////////// | ||
// | ||
// Types | ||
|
||
enum D2InterfaceModules | ||
{ | ||
D2I_NONE, | ||
D2I_CLIENT, | ||
D2I_SERVER, | ||
D2I_MULTI, | ||
D2I_LAUNCH, | ||
D2I_MAX, | ||
}; | ||
|
||
typedef D2InterfaceModules(__fastcall *run_t)(D2GameConfigStrc*); | ||
typedef run_t*(__fastcall *interface_t)(); | ||
|
||
|
||
///////////////////////////////////////////////////////// | ||
// | ||
// Structures | ||
|
||
/* | ||
* The structure containing information about parsing commandline arguments | ||
* @author Necrolis | ||
*/ | ||
struct D2CmdArgStrc | ||
{ | ||
char szSection[16]; // +00 | ||
char szKeyName[16]; // +10 | ||
char szCmdName[16]; // +20 | ||
DWORD dwType; // +30 ( 0 use GetProfInt - write bool, 1 DWORD , 2 string, 3 BYTE, 4 WORD) | ||
int nOffset; // +34 | ||
DWORD dwDefault; // +38 | ||
}; // +3C | ||
|
||
|
||
///////////////////////////////////////////////////////// | ||
// | ||
// Functions | ||
|
||
// Diablo2.cpp | ||
int InitGame(int argc, char** argv, DWORD pid); | ||
|
||
// Platform_*.cpp | ||
void Sys_InitModules(); | ||
|
||
|
||
///////////////////////////////////////////////////////// | ||
// | ||
// Variables | ||
|
||
extern run_t gpfModules[]; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,94 @@ | ||
#define WIN32_LEAN_AND_MEAN | ||
#include "Diablo2.hpp" | ||
#include <Windows.h> | ||
#include <stdlib.h> | ||
|
||
#define D2REGISTRY_BETA_KEY "SOFTWARE\\Blizzard Entertainment\\Diablo II Beta" | ||
#define D2REGISTRY_KEY "SOFTWARE\\Blizzard Entertainment\\Diablo II" | ||
|
||
#define REGISTRY_KEY_SIZE 16384 | ||
|
||
/* | ||
* Global variables | ||
*/ | ||
|
||
static const char* gszInterfaces[D2I_MAX] = { | ||
nullptr, | ||
"D2Client.dll", | ||
"D2Server.dll", | ||
"D2Multi.dll", | ||
"D2Launch.dll", | ||
}; | ||
|
||
run_t gpfModules[D2I_MAX] = { nullptr, nullptr, nullptr, nullptr, nullptr }; | ||
|
||
/* | ||
* Copy registry keys (and delete them) from the Diablo II beta to the retail game. | ||
* This step is done before anything else. | ||
* Never really gets used anymore, but since we're in the business of replicating base game behavior... | ||
*/ | ||
void Sys_CopyBetaRegistryKeys() | ||
{ | ||
HKEY betakey; | ||
HKEY key; | ||
int i; | ||
DWORD type; | ||
BYTE data; | ||
DWORD cbdata; | ||
LSTATUS status; | ||
char keybuffer[REGISTRY_KEY_SIZE]{ 0 }; | ||
DWORD keybufferSize = REGISTRY_KEY_SIZE; | ||
|
||
if (!RegOpenKeyA(HKEY_LOCAL_MACHINE, D2REGISTRY_BETA_KEY, &betakey)) | ||
{ // We had the Diablo II beta installed. Copy the keys and delete the old ones. | ||
RegCreateKeyA(HKEY_LOCAL_MACHINE, D2REGISTRY_KEY, &key); | ||
|
||
do | ||
{ | ||
status = RegEnumValueA(betakey, i, keybuffer, &keybufferSize, 0, &type, &data, &cbdata); | ||
} while (status == 0 && RegSetValueExA(key, keybuffer, 0, type, &data, cbdata)); | ||
|
||
RegCloseKey(betakey); | ||
RegCloseKey(key); | ||
RegDeleteKeyA(HKEY_LOCAL_MACHINE, D2REGISTRY_BETA_KEY); | ||
} | ||
} | ||
|
||
/* | ||
* Copy registry keys from the retail game and make them available in D2.ini | ||
* This step has to be done after we've initialized the file system | ||
*/ | ||
void Sys_CopySettings() | ||
{ | ||
|
||
} | ||
|
||
/* | ||
* Load all of the modules | ||
* @author Necrolis (modified by eezstreet) | ||
*/ | ||
void Sys_InitModules() | ||
{ | ||
for (int i = 1; i < 5; i++) | ||
{ | ||
HMODULE hLib = LoadLibrary(gszInterfaces[i]); | ||
if (hLib) | ||
{ | ||
interface_t pfInterface = (interface_t)GetProcAddress(hLib, "QueryInterface"); | ||
if (pfInterface != nullptr) | ||
{ | ||
gpfModules[i] = *pfInterface(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/* | ||
* The main entrypoint of the program (on Windows) | ||
*/ | ||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char* szCmdLine, int nShowCmd) | ||
{ | ||
Sys_CopyBetaRegistryKeys(); | ||
|
||
return InitGame(__argc, __argv, (DWORD)hInstance); | ||
} |
Oops, something went wrong.