Skip to content

Commit

Permalink
Merge branch 'master' of github.com:diasurgical/devilutionX into swit…
Browse files Browse the repository at this point in the history
…ch-next
  • Loading branch information
AJenbo committed Sep 26, 2019
2 parents 1eb0a21 + e88e574 commit b89050d
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 605 deletions.
5 changes: 4 additions & 1 deletion 3rdParty/Storm/Source/storm.h
Expand Up @@ -825,7 +825,10 @@ SMemReAlloc(
#define SLOG_FILE -4
#define SLOG_EXCEPTION -5


void GetBasePath(char *buffer, size_t size);
void GetPrefPath(char *buffer, size_t size);
bool getIniValue(const char *sectionName, const char *keyName, char *string, int stringSize, int *dataSize = NULL);
void setIniValue(const char *sectionName, const char *keyName, char *value, int len = 0);
BOOL STORMAPI SRegLoadData(const char *keyname, const char *valuename, int size, LPBYTE lpData, BYTE flags, LPDWORD lpcbData);
BOOL STORMAPI SRegLoadString(const char *keyname, const char *valuename, BYTE flags, char *buffer, unsigned int buffersize);
BOOL STORMAPI SRegLoadValue(const char *keyname, const char *valuename, BYTE flags, int *value);
Expand Down
11 changes: 5 additions & 6 deletions CMakeLists.txt
Expand Up @@ -2,13 +2,11 @@ cmake_minimum_required(VERSION 3.7)

include(CMake/out_of_tree.cmake)

set(PROJECT_VERSION 0.5.0)

project(devilutionX
VERSION ${PROJECT_VERSION}
project(DevilutionX
VERSION 0.5.0
LANGUAGES C CXX)

list(APPEND CMAKE_MODULE_PATH "${devilutionX_SOURCE_DIR}/CMake")
list(APPEND CMAKE_MODULE_PATH "${DevilutionX_SOURCE_DIR}/CMake")

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
Expand Down Expand Up @@ -218,7 +216,8 @@ endif()

add_executable(devilutionx MACOSX_BUNDLE ${devilutionx_SRCS})

target_include_directories(devilution PUBLIC Source SourceS)
configure_file(SourceS/config.h.in config.h @ONLY)
target_include_directories(devilution PUBLIC Source SourceS ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(devilutionx PRIVATE
SourceX
3rdParty/asio/include
Expand Down
10 changes: 0 additions & 10 deletions Source/appfat.cpp
Expand Up @@ -289,16 +289,6 @@ void FileErrDlg(const char *error)
app_fatal(NULL);
}

void DiskFreeDlg(char *error)
{
FreeDlg();

if (DialogBoxParam(ghInst, MAKEINTRESOURCE(IDD_DIALOG7), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)error) == -1)
app_fatal("DiskFreeDlg");

app_fatal(NULL);
}

BOOL InsertCDDlg()
{
int nResult;
Expand Down
7 changes: 5 additions & 2 deletions Source/capture.cpp
@@ -1,4 +1,5 @@
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"

DEVILUTION_BEGIN_NAMESPACE

Expand Down Expand Up @@ -126,10 +127,12 @@ BYTE *CaptureEnc(BYTE *src, BYTE *dst, int width)

HANDLE CaptureFile(char *dst_path)
{
int len = GetModuleFileNameA(ghInst, dst_path, MAX_PATH);
char path[MAX_PATH];

GetPrefPath(dst_path, MAX_PATH);

for (int i = 0; i <= 99; i++) {
sprintf(&dst_path[len], "screen%02d.PCX", i);
snprintf(dst_path, MAX_PATH, "%sscreen%02d.PCX", path, i);
FILE *file = fopen(dst_path, "r");

if (file == NULL) {
Expand Down
22 changes: 6 additions & 16 deletions Source/diablo.cpp
Expand Up @@ -235,16 +235,13 @@ void free_game()

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HINSTANCE hInst;
int nData;
char szFileName[MAX_PATH];

hInst = hInstance;
ghInst = hInst;
ghInst = hInstance;

if (ReadOnlyTest()) {
if (!GetModuleFileName(ghInst, szFileName, sizeof(szFileName)))
szFileName[0] = '\0';
GetPrefPath(szFileName, sizeof(szFileName));
DirErrorDlg(szFileName);
}

Expand Down Expand Up @@ -877,25 +874,18 @@ BOOL PressSysKey(int wParam)

void diablo_hotkey_msg(DWORD dwMsg)
{
char *s;
char szFileName[MAX_PATH];
char szMsg[MAX_SEND_STR_LEN];

if (gbMaxPlayers == 1) {
return;
}
if (GetModuleFileName(ghInst, szFileName, sizeof(szFileName)) == 0) {
app_fatal("Can't get program name");
}

s = strrchr(szFileName, '\\');
if (s != NULL) {
*s = '\0';
/// ASSERT: assert(dwMsg < sizeof(spszMsgTbl) / sizeof(spszMsgTbl[0]));
if (!getIniValue("NetMsg", spszMsgHotKeyTbl[dwMsg], szMsg, MAX_SEND_STR_LEN)) {
snprintf(szMsg, MAX_SEND_STR_LEN, "%s", spszMsgTbl[dwMsg]);
setIniValue("NetMsg", spszMsgHotKeyTbl[dwMsg], szMsg);
}

strcat(szFileName, "\\Diablo.ini");
/// ASSERT: assert(dwMsg < sizeof(spszMsgTbl) / sizeof(spszMsgTbl[0]));
GetPrivateProfileString("NetMsg", spszMsgHotKeyTbl[dwMsg], spszMsgTbl[dwMsg], szMsg, sizeof(szMsg), szFileName);
NetSendCmdString(-1, szMsg);
}

Expand Down
40 changes: 11 additions & 29 deletions Source/init.cpp
Expand Up @@ -3,6 +3,9 @@
#include "../3rdParty/Storm/Source/storm.h"
#include "../DiabloUI/diabloui.h"
#include <SDL.h>
#ifndef SWITCH
#include <config.h>
#endif

DEVILUTION_BEGIN_NAMESPACE

Expand Down Expand Up @@ -54,8 +57,6 @@ void init_create_window(int nCmdShow)
int nWidth, nHeight;
HWND hWnd;

pfile_init_save_directory();

if (GetSystemMetrics(SM_CXSCREEN) < SCREEN_WIDTH)
nWidth = SCREEN_WIDTH;
else
Expand Down Expand Up @@ -111,14 +112,14 @@ void init_archives()
HANDLE init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags, int fs)
{
char Buffer[2][MAX_PATH];
char *sdlPath;
HANDLE archive;

GetCurrentDirectory(MAX_PATH, Buffer[0]); // Package
GetModuleFileName(NULL, Buffer[1], MAX_PATH); // Preferences
GetBasePath(Buffer[0], MAX_PATH);
GetPrefPath(Buffer[1], MAX_PATH);

for (int i = 0; i < 2; i++) {
strcpy(mpq_path, Buffer[i]);
strcat(mpq_path, mpq_name);
snprintf(mpq_path, MAX_PATH, "%s%s", Buffer[i], mpq_name);
if (SFileOpenArchive(mpq_path, 0, flags, &archive)) {
SFileSetBasePath(Buffer[i]);
return archive;
Expand All @@ -130,29 +131,10 @@ HANDLE init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags

void init_get_file_info()
{
DWORD dwLen;
void *pBlock;
unsigned int uBytes;
DWORD dwHandle;
VS_FIXEDFILEINFO *lpBuffer;

if (GetModuleFileName(ghInst, diablo_exe_path, sizeof(diablo_exe_path))) {
dwLen = GetFileVersionInfoSize(diablo_exe_path, &dwHandle);
if (dwLen) {
pBlock = DiabloAllocPtr(dwLen);
if (GetFileVersionInfo(diablo_exe_path, 0, dwLen, pBlock)) {
if (VerQueryValue(pBlock, "\\", (LPVOID *)&lpBuffer, &uBytes))
sprintf(
gszVersionNumber,
"version %d.%d.%d.%d",
lpBuffer->dwProductVersionMS >> 16,
lpBuffer->dwProductVersionMS & 0xFFFF,
lpBuffer->dwProductVersionLS >> 16,
lpBuffer->dwProductVersionLS & 0xFFFF);
}
mem_free_dbg(pBlock);
}
}
#ifndef SWITCH
snprintf(gszProductName, MAX_PATH, "%s v%s", PROJECT_NAME, PROJECT_VERSION);
snprintf(gszVersionNumber, MAX_PATH, "version %s", PROJECT_VERSION);
#endif
}

LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Expand Down
7 changes: 4 additions & 3 deletions Source/multi.cpp
Expand Up @@ -47,9 +47,10 @@ void __cdecl dumphist(const char *pszFmt, ...)

va_start(va, pszFmt);

char dumpHistPath[MAX_PATH] = {};
if (sgpHistFile == NULL && GetWindowsDirectory(dumpHistPath, sizeof(dumpHistPath))) {
strcat(dumpHistPath, "\\dumphist.txt");
char path[MAX_PATH], dumpHistPath[MAX_PATH];
if (sgpHistFile == NULL) {
GetPrefPath(path, MAX_PATH);
snprintf(dumpHistPath, MAX_PATH, "%sdumphist.txt", path);
sgpHistFile = fopen(dumpHistPath, "wb");
if (sgpHistFile == NULL) {
return;
Expand Down

0 comments on commit b89050d

Please sign in to comment.