Skip to content

Commit

Permalink
Updated files
Browse files Browse the repository at this point in the history
  • Loading branch information
eezstreet committed Aug 22, 2017
1 parent 6dd465e commit 87e6573
Show file tree
Hide file tree
Showing 21 changed files with 920 additions and 51 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@

# Projects
Build/*
Win32/*
game.dir/*
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(BUILD_GAME)
source_group("Game" FILES ${GAME_SRC})
set(GAME_SRC ${GAME_SRC} ${SHARED_SRC})

link_directories("../Shared")

add_executable(game WIN32 ${GAME_SRC})
set_target_properties(game PROPERTIES OUTPUT_NAME game)
set_target_properties(game PROPERTIES LINKER_LANGUAGE CXX)
Expand Down
57 changes: 57 additions & 0 deletions Game/Diablo2.hpp
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[];
6 changes: 0 additions & 6 deletions Game/FogInterface.cpp

This file was deleted.

17 changes: 0 additions & 17 deletions Game/FogInterface.hpp

This file was deleted.

Empty file removed Game/Fog_Interface.cpp
Empty file.
2 changes: 0 additions & 2 deletions Game/LibraryInterface.cpp

This file was deleted.

9 changes: 0 additions & 9 deletions Game/LibraryInterface.hpp

This file was deleted.

94 changes: 94 additions & 0 deletions Game/Platform_Windows.cpp
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);
}
Loading

0 comments on commit 87e6573

Please sign in to comment.