Skip to content

Commit 87e6573

Browse files
committed
Updated files
1 parent 6dd465e commit 87e6573

21 files changed

+920
-51
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@
3333

3434
# Projects
3535
Build/*
36+
Win32/*
37+
game.dir/*

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ if(BUILD_GAME)
2323
source_group("Game" FILES ${GAME_SRC})
2424
set(GAME_SRC ${GAME_SRC} ${SHARED_SRC})
2525

26+
link_directories("../Shared")
27+
2628
add_executable(game WIN32 ${GAME_SRC})
2729
set_target_properties(game PROPERTIES OUTPUT_NAME game)
2830
set_target_properties(game PROPERTIES LINKER_LANGUAGE CXX)

Game/Diablo2.hpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#pragma once
2+
#include "../Shared/D2Shared.hpp"
3+
4+
5+
/////////////////////////////////////////////////////////
6+
//
7+
// Types
8+
9+
enum D2InterfaceModules
10+
{
11+
D2I_NONE,
12+
D2I_CLIENT,
13+
D2I_SERVER,
14+
D2I_MULTI,
15+
D2I_LAUNCH,
16+
D2I_MAX,
17+
};
18+
19+
typedef D2InterfaceModules(__fastcall *run_t)(D2GameConfigStrc*);
20+
typedef run_t*(__fastcall *interface_t)();
21+
22+
23+
/////////////////////////////////////////////////////////
24+
//
25+
// Structures
26+
27+
/*
28+
* The structure containing information about parsing commandline arguments
29+
* @author Necrolis
30+
*/
31+
struct D2CmdArgStrc
32+
{
33+
char szSection[16]; // +00
34+
char szKeyName[16]; // +10
35+
char szCmdName[16]; // +20
36+
DWORD dwType; // +30 ( 0 use GetProfInt - write bool, 1 DWORD , 2 string, 3 BYTE, 4 WORD)
37+
int nOffset; // +34
38+
DWORD dwDefault; // +38
39+
}; // +3C
40+
41+
42+
/////////////////////////////////////////////////////////
43+
//
44+
// Functions
45+
46+
// Diablo2.cpp
47+
int InitGame(int argc, char** argv, DWORD pid);
48+
49+
// Platform_*.cpp
50+
void Sys_InitModules();
51+
52+
53+
/////////////////////////////////////////////////////////
54+
//
55+
// Variables
56+
57+
extern run_t gpfModules[];

Game/FogInterface.cpp

Lines changed: 0 additions & 6 deletions
This file was deleted.

Game/FogInterface.hpp

Lines changed: 0 additions & 17 deletions
This file was deleted.

Game/Fog_Interface.cpp

Whitespace-only changes.

Game/LibraryInterface.cpp

Lines changed: 0 additions & 2 deletions
This file was deleted.

Game/LibraryInterface.hpp

Lines changed: 0 additions & 9 deletions
This file was deleted.

Game/Platform_Windows.cpp

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#define WIN32_LEAN_AND_MEAN
2+
#include "Diablo2.hpp"
3+
#include <Windows.h>
4+
#include <stdlib.h>
5+
6+
#define D2REGISTRY_BETA_KEY "SOFTWARE\\Blizzard Entertainment\\Diablo II Beta"
7+
#define D2REGISTRY_KEY "SOFTWARE\\Blizzard Entertainment\\Diablo II"
8+
9+
#define REGISTRY_KEY_SIZE 16384
10+
11+
/*
12+
* Global variables
13+
*/
14+
15+
static const char* gszInterfaces[D2I_MAX] = {
16+
nullptr,
17+
"D2Client.dll",
18+
"D2Server.dll",
19+
"D2Multi.dll",
20+
"D2Launch.dll",
21+
};
22+
23+
run_t gpfModules[D2I_MAX] = { nullptr, nullptr, nullptr, nullptr, nullptr };
24+
25+
/*
26+
* Copy registry keys (and delete them) from the Diablo II beta to the retail game.
27+
* This step is done before anything else.
28+
* Never really gets used anymore, but since we're in the business of replicating base game behavior...
29+
*/
30+
void Sys_CopyBetaRegistryKeys()
31+
{
32+
HKEY betakey;
33+
HKEY key;
34+
int i;
35+
DWORD type;
36+
BYTE data;
37+
DWORD cbdata;
38+
LSTATUS status;
39+
char keybuffer[REGISTRY_KEY_SIZE]{ 0 };
40+
DWORD keybufferSize = REGISTRY_KEY_SIZE;
41+
42+
if (!RegOpenKeyA(HKEY_LOCAL_MACHINE, D2REGISTRY_BETA_KEY, &betakey))
43+
{ // We had the Diablo II beta installed. Copy the keys and delete the old ones.
44+
RegCreateKeyA(HKEY_LOCAL_MACHINE, D2REGISTRY_KEY, &key);
45+
46+
do
47+
{
48+
status = RegEnumValueA(betakey, i, keybuffer, &keybufferSize, 0, &type, &data, &cbdata);
49+
} while (status == 0 && RegSetValueExA(key, keybuffer, 0, type, &data, cbdata));
50+
51+
RegCloseKey(betakey);
52+
RegCloseKey(key);
53+
RegDeleteKeyA(HKEY_LOCAL_MACHINE, D2REGISTRY_BETA_KEY);
54+
}
55+
}
56+
57+
/*
58+
* Copy registry keys from the retail game and make them available in D2.ini
59+
* This step has to be done after we've initialized the file system
60+
*/
61+
void Sys_CopySettings()
62+
{
63+
64+
}
65+
66+
/*
67+
* Load all of the modules
68+
* @author Necrolis (modified by eezstreet)
69+
*/
70+
void Sys_InitModules()
71+
{
72+
for (int i = 1; i < 5; i++)
73+
{
74+
HMODULE hLib = LoadLibrary(gszInterfaces[i]);
75+
if (hLib)
76+
{
77+
interface_t pfInterface = (interface_t)GetProcAddress(hLib, "QueryInterface");
78+
if (pfInterface != nullptr)
79+
{
80+
gpfModules[i] = *pfInterface();
81+
}
82+
}
83+
}
84+
}
85+
86+
/*
87+
* The main entrypoint of the program (on Windows)
88+
*/
89+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char* szCmdLine, int nShowCmd)
90+
{
91+
Sys_CopyBetaRegistryKeys();
92+
93+
return InitGame(__argc, __argv, (DWORD)hInstance);
94+
}

0 commit comments

Comments
 (0)