Skip to content

Commit

Permalink
Add Diablo Version 1.08-Specific Behavior with Preprocessor Directives (
Browse files Browse the repository at this point in the history
diasurgical#2292)

* add preprocessor directive for version 1.08

* Update MakefileVC

* Missed "endif"

* revise handling of diablo version
  • Loading branch information
kphoenix137 committed Aug 19, 2024
1 parent f5e73a1 commit 1888f6b
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
117 changes: 117 additions & 0 deletions MakefileVC
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# The $(VC5_DIR)/.. and $(VS6_DIR) directories are copies "Microsoft Visual Studio".
#
# To get a working setup on Linux or other "portable" copies of VS,
# the following DLLs have to be copied to the
# $(VS6_DIR)/VC98/Bin directory.
#
# - $(VS6_DIR)/Common/MSDev98/Bin/MSPDB60.DLL
#
# And to the $(VC5_DIR)/bin directory.
#
# - $(VC5_DIR)/SharedIDE/bin/MSDIS100.DLL
# - $(VC5_DIR)/SharedIDE/bin/MSPDB50.DLL
VS6_DIR ?= $(HOME)/VS6

VC6_DIR = $(VS6_DIR)/VC98

VC6_BIN_DIR = $(VC6_DIR)/Bin
VC6_INC_DIR = $(VC6_DIR)/Include
VC6_LIB_DIR = $(VC6_DIR)/Lib

VC5_DIR ?= $(HOME)/DevStudio_5.10/VC

VC5_BIN_DIR = $(VC5_DIR)/bin
VC5_INC_DIR = $(VC5_DIR)/include
VC5_LIB_DIR = $(VC5_DIR)/lib

IDE_DIR ?= $(VS6_DIR)/Common/MSDev98
IDE_BIN_DIR = $(IDE_DIR)/bin
ifeq ($(OS),Windows_NT)
CL5 = $(VC5_BIN_DIR)/CL.EXE
CL6 = $(VC6_BIN_DIR)/CL.EXE
RC = $(IDE_BIN_DIR)/RC.EXE
VC5_LINK = $(VC5_BIN_DIR)/link.exe
VC6_LINK = $(VC6_BIN_DIR)/link.exe
else
CL5 = wine $(VC5_BIN_DIR)/CL.EXE
CL6 = wine $(VC6_BIN_DIR)/CL.EXE
RC = wine $(IDE_BIN_DIR)/RC.EXE
VC5_LINK = wine $(VC5_BIN_DIR)/link.exe
VC6_LINK = wine $(VC6_BIN_DIR)/link.exe
endif

ifeq ($(HELLFIRE),1)
CL = $(CL5)
VC_INC_DIR = $(VC5_INC_DIR)
else
CL = $(CL6)
VC_INC_DIR = $(VC6_INC_DIR)
endif

CFLAGS=/nologo /c /GX /W3 /O1 /I $(VC_INC_DIR) /FD /Gr /MT /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fp"Diablo.pch" /YX /G5 /Zi /FAs
LINKFLAGS=/nologo /subsystem:windows /machine:I386 /incremental:no

VERSION := 109

CFLAGS += /D "VERSION=$(VERSION)"

ifeq ($(HELLFIRE),1)
CFLAGS += /D "HELLFIRE"
endif

ifeq ($(SPAWN),1)
CFLAGS += /D "SPAWN"
endif

ifeq ($(MAKE_BUILD),pdb)
ifeq ($(HELLFIRE),1)
VC_LINK = $(VC5_LINK)
LINKFLAGS += /pdb:"hellfire.pdb" /LIBPATH:$(VC5_LIB_DIR) /debug
else
VC_LINK = $(VC6_LINK)
LINKFLAGS += /pdb:"Diablo.pdb" /LIBPATH:$(VC6_LIB_DIR) /debug
endif
else
VC_LINK = $(VC5_LINK)
LINKFLAGS += /LIBPATH:$(VC5_LIB_DIR)
endif

all: Diablo.exe

debug: CFLAGS += /D "_DEBUG"
debug: Diablo.exe

# fix compilation order to match the VC6 workspace files and exclude local assembly functions
DIABLO_SRC=$(sort $(filter-out Source/_asm.cpp Source/_render.cpp Source/render.cpp, $(wildcard Source/*.cpp)))
DIABLO_SRC += Source/render.cpp
OBJS=$(DIABLO_SRC:.cpp=.obj)

Diablo.exe: main_files diablo.res DiabloUI/diabloui.lib 3rdParty/Storm/storm.lib 3rdParty/PKWare/pkware.lib
$(VC_LINK) /OUT:$@ $(LINKFLAGS) $(OBJS) diablo.res DiabloUI/diabloui.lib 3rdParty/Storm/storm.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib version.lib 3rdParty/PKWare/pkware.lib

DiabloUI/diabloui.lib:
make -C DiabloUI

3rdParty/Storm/storm.lib:
make -C 3rdParty/Storm

3rdParty/PKWare/pkware.lib:
make -C 3rdParty/PKWare

# compiles all main source files with once compiler call
main_files:
$(CL) $(CFLAGS) /FoSource/ $(DIABLO_SRC)

%.obj: %.cpp
$(CL) $(CFLAGS) /Fo$@ $<

diablo.res: Diablo.rc
$(RC) /i $(VC_INC_DIR) /l 0x409 /fo $@ $<

clean:
@$(RM) -v $(OBJS) vc60.idb vc60.pdb Diablo.pdb Diablo.pch vc50.idb vc50.pdb hellfire.pdb
make -C DiabloUI clean
make -C 3rdParty/Storm clean
make -C 3rdParty/PKWare clean

.PHONY: clean all
4 changes: 4 additions & 0 deletions Source/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ int path_get_h_cost(int sx, int sy, int dx, int dy)
int max = delta_x > delta_y ? delta_x : delta_y;

// see path_check_equal for why this is times 2
#if VERSION == 108
return min + (2 * max);
#else
return 2 * (min + max);
#endif
}

/**
Expand Down

0 comments on commit 1888f6b

Please sign in to comment.