mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Tools updates:
- Eliminate use of the C++ standard library from arttool. I improved some of the program's workings but it continues to corrupt my art files in certain circumstances. (Note: Not a regression; it happens with previous revisions.) - Construct "make utils" for the game side following the pattern of the engine. - Move ivfrate to this new distinction. - Minor Makefile cleanup and tweaks, mainly to facilitate CLANG=1 and to formalize text output in special cases. git-svn-id: https://svn.eduke32.com/eduke32@3163 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
c6bbb0547b
commit
a418bec8c2
8 changed files with 340 additions and 198 deletions
|
@ -5,7 +5,8 @@
|
|||
include Makefile.common
|
||||
|
||||
|
||||
# SDK locations - adjust to match your setup
|
||||
# SDK locations for Windows - adjust to match your setup
|
||||
#
|
||||
ifneq ($(DXROOT_OVERRIDE),)
|
||||
DXROOT=$(DXROOT_OVERRIDE)
|
||||
else
|
||||
|
@ -14,6 +15,7 @@ else
|
|||
endif
|
||||
|
||||
# Build locations
|
||||
#
|
||||
SRC=source
|
||||
RSRC=rsrc
|
||||
ESRC=$(EROOT)/src
|
||||
|
@ -70,8 +72,6 @@ endif
|
|||
EDUKE32 ?= eduke32$(EXESUFFIX)
|
||||
MAPSTER32 ?= mapster32$(EXESUFFIX)
|
||||
|
||||
IVFRATE ?= samples/ivfrate$(EXESUFFIX)
|
||||
|
||||
EDUKE32_TARGET:=$(EDUKE32)
|
||||
ifneq ($(PLATFORM),WII)
|
||||
MAPSTER32_TARGET:=$(MAPSTER32)
|
||||
|
@ -80,8 +80,6 @@ endif
|
|||
EBACKTRACEDLL ?= ebacktrace1.dll
|
||||
EBACKTRACEDLL_TARGET:=
|
||||
|
||||
IVFRATE_TARGET:=$(IVFRATE)
|
||||
|
||||
ifeq ($(PLATFORM),WINDOWS)
|
||||
OBJ=obj_win
|
||||
EOBJ=eobj_win
|
||||
|
@ -321,20 +319,29 @@ endif
|
|||
|
||||
# TARGETS
|
||||
|
||||
all: notice $(EDUKE32_TARGET) $(MAPSTER32_TARGET) $(EBACKTRACEDLL_TARGET) $(IVFRATE_TARGET)
|
||||
UTILOBJS=$(OBJ)/ivfrate.$o
|
||||
UTILS=ivfrate$(EXESUFFIX)
|
||||
|
||||
all:
|
||||
$(BUILD_FINISHED)
|
||||
all: start $(EDUKE32_TARGET) $(MAPSTER32_TARGET) $(EBACKTRACEDLL_TARGET) finish
|
||||
ifneq (,$(EDUKE32_TARGET))
|
||||
@ls -l $(EDUKE32)
|
||||
endif
|
||||
ifneq (,$(MAPSTER32_TARGET))
|
||||
@ls -l $(MAPSTER32)
|
||||
endif
|
||||
ifneq (,$(EBACKTRACEDLL_TARGET))
|
||||
@ls -l $(EBACKTRACEDLL)
|
||||
endif
|
||||
|
||||
notice:
|
||||
utils: start $(UTILS) finish
|
||||
@ls -l $(UTILS)
|
||||
|
||||
start:
|
||||
$(BUILD_STARTED)
|
||||
|
||||
finish:
|
||||
$(BUILD_FINISHED)
|
||||
|
||||
|
||||
$(EDUKE32): $(GAMEOBJS) $(EOBJ)/$(ENGINELIB) $(JAUDIOLIBDIR)/$(JAUDIOLIB) $(ENETDIR)/$(ENETLIB) $(MISCGAMEDEPS)
|
||||
$(LINK_STATUS)
|
||||
|
@ -405,6 +412,7 @@ endif
|
|||
# RULES
|
||||
|
||||
$(EBACKTRACEDLL): Windows/src/backtrace.c
|
||||
$(COMPILE_STATUS)
|
||||
if $(CC) $(OURCONLYFLAGS) -O2 -shared -Wall -Wextra -I$(EINC) -o $@ $^ -lbfd -liberty -limagehlp; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
$(OBJ)/%.$o: $(SRC)/%.nasm
|
||||
|
@ -417,8 +425,13 @@ $(OBJ)/%.$o: $(SRC)/%.c
|
|||
|
||||
#### Utilities
|
||||
|
||||
$(IVFRATE): $(SRC)/ivfrate.c $(SRC)/animvpx.h
|
||||
if $(COMPILER) -Wall -Wextra $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
$(OBJ)/%.$o: $(SRC)/util/%.c
|
||||
$(COMPILE_STATUS)
|
||||
if $(COMPILER) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
ivfrate$(EXESUFFIX): $(OBJ)/ivfrate.$o
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(LIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
|
||||
#### Lunatic
|
||||
|
||||
|
@ -463,15 +476,15 @@ $(OBJ)/%.$o: Apple/%.m
|
|||
|
||||
$(OBJ)/%.$o: $(SRC)/%.cc
|
||||
$(COMPILE_STATUS)
|
||||
if $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
if $(CXX) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
$(OBJ)/%.$o: $(SRC)/%.cpp
|
||||
$(COMPILE_STATUS)
|
||||
if $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
if $(CXX) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
$(OBJ)/%.$o: $(SRC)/%.cxx
|
||||
$(COMPILE_STATUS)
|
||||
if $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
if $(CXX) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
$(OBJ)/%.$o: $(SRC)/jmact/%.c
|
||||
$(COMPILE_STATUS)
|
||||
|
@ -505,12 +518,18 @@ $(RSRC)/editor_banner.c: $(RSRC)/build.bmp
|
|||
# PHONIES
|
||||
|
||||
clean:
|
||||
-rm -f $(OBJ)/* $(EDUKE32) $(EDUKE32).memmap $(MAPSTER32) $(MAPSTER32).memmap $(IVFRATE) core* duke3d_w32$(EXESUFFIX) && $(MAKE) -C $(JAUDIOLIBDIR) clean && $(MAKE) -C $(ENETDIR) clean
|
||||
-rm -f $(OBJ)/* $(EDUKE32) $(EDUKE32).memmap $(MAPSTER32) $(MAPSTER32).memmap core* duke3d_w32$(EXESUFFIX) && $(MAKE) -C $(JAUDIOLIBDIR) clean && $(MAKE) -C $(ENETDIR) clean
|
||||
ifeq ($(PLATFORM),DARWIN)
|
||||
-rm -rf EDuke32.app Mapster32.app
|
||||
endif
|
||||
echo -n "" > $(OBJ)/keep.me
|
||||
|
||||
veryclean: clean
|
||||
cleanutils:
|
||||
-rm -f $(UTILS) $(UTILOBJS) $(addsuffix .memmap, $(UTILS))
|
||||
|
||||
veryclean: clean cleanutils
|
||||
-rm -f $(EOBJ)/* $(RSRC)/*banner* $(EBACKTRACEDLL)
|
||||
echo -n "" > $(EOBJ)/keep.me
|
||||
|
||||
printutils:
|
||||
echo "$(UTILS)"
|
||||
|
|
|
@ -122,3 +122,4 @@ $(OBJ)/midi.$o: $(SRC)/midi.c $(SRC)/_midi.h $(SRC)/midi.h $(JAUDIOLIBDIR)/inclu
|
|||
$(OBJ)/mpu401.$o: $(SRC)/mpu401.c $(SRC)/mpu401.h $(JAUDIOLIBDIR)/include/music.h
|
||||
$(OBJ)/music.$o: $(SRC)/music.c $(SRC)/midi.h $(SRC)/mpu401.h $(JAUDIOLIBDIR)/include/music.h
|
||||
|
||||
$(OBJ)/ivfrate.$o: $(SRC)/util/ivfrate.c $(SRC)/animvpx.h
|
||||
|
|
|
@ -2,12 +2,6 @@
|
|||
# Build Makefile for GNU Make
|
||||
#
|
||||
|
||||
# Notes:
|
||||
# As of 6 July 2005, the engine should handle optimisations being enabled.
|
||||
# If things seem to be going wrong, lower or disable optimisations, then
|
||||
# try again. If things are still going wrong, call me.
|
||||
#
|
||||
|
||||
include ../Makefile.common
|
||||
|
||||
|
||||
|
@ -19,7 +13,6 @@ else
|
|||
DXROOT=../../sdk/dx
|
||||
#DXROOT=c:/sdks/directx/dx8
|
||||
endif
|
||||
FMODROOTWIN=c:/sdks/fmodapi374win/api
|
||||
|
||||
# Build locations - OBJ gets overridden to the game-specific objects dir
|
||||
#
|
||||
|
@ -125,7 +118,7 @@ ifeq ($(PLATFORM),BSD)
|
|||
OURCOMMONFLAGS+= -I/usr/X11R6/include
|
||||
endif
|
||||
ifeq ($(PLATFORM),WINDOWS)
|
||||
OURCOMMONFLAGS+= -DUNDERSCORES -I$(DXROOT)/include -I$(FMODROOTWIN)/inc # -I$(ENETROOT)/include
|
||||
OURCOMMONFLAGS+= -DUNDERSCORES -I$(DXROOT)/include # -I$(ENETROOT)/include
|
||||
OURASFLAGS+= -DUNDERSCORES -f win32
|
||||
endif
|
||||
ifeq ($(PLATFORM),BEOS)
|
||||
|
@ -188,7 +181,7 @@ ifneq ($(CPLUSPLUS),0)
|
|||
endif
|
||||
|
||||
.SILENT:
|
||||
.PHONY: clean cleanutils veryclean all utils enginelib editorlib
|
||||
.PHONY: clean cleanutils veryclean all utils dxutils sdlutils printutils printsdlutils printdxutils enginelib editorlib
|
||||
|
||||
# TARGETS
|
||||
|
||||
|
@ -209,9 +202,14 @@ SDLUTILOBJS=$(OBJ)/makesdlkeytrans.$o
|
|||
SDLUTILS=makesdlkeytrans$(EXESUFFIX)
|
||||
|
||||
# all: $(OBJ)/$(ENGINELIB) $(OBJ)/$(EDITORLIB)
|
||||
utils: start $(UTILS) finish utilfinish
|
||||
dxutils: start $(DXUTILS) finish dxutilfinish
|
||||
sdlutils: start $(SDLUTILS) finish sdlutilfinish
|
||||
utils: start $(UTILS) finish
|
||||
@ls -l $(UTILS)
|
||||
|
||||
dxutils: start $(DXUTILS) finish
|
||||
@ls -l $(DXUTILS)
|
||||
|
||||
sdlutils: start $(SDLUTILS) finish
|
||||
@ls -l $(SDLUTILS)
|
||||
|
||||
start:
|
||||
$(BUILD_STARTED)
|
||||
|
@ -219,15 +217,6 @@ start:
|
|||
finish:
|
||||
$(BUILD_FINISHED)
|
||||
|
||||
utilfinish:
|
||||
@ls -l $(UTILS)
|
||||
|
||||
dxutilfinish:
|
||||
@ls -l $(DXUTILS)
|
||||
|
||||
sdlutilfinish:
|
||||
@ls -l $(SDLUTILS)
|
||||
|
||||
enginelib: $(OBJ)/$(ENGINELIB)
|
||||
$(OBJ)/$(ENGINELIB): $(ENGINEOBJS)
|
||||
$(BUILD_ECHOFLAGS)
|
||||
|
@ -247,56 +236,56 @@ $(OBJ)/$(EDITORLIB): $(EDITOROBJS)
|
|||
|
||||
kextract$(EXESUFFIX): $(OBJ)/kextract.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
kgroup$(EXESUFFIX): $(OBJ)/kgroup.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
transpal$(EXESUFFIX): $(OBJ)/transpal.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
wad2art$(EXESUFFIX): $(OBJ)/wad2art.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
wad2map$(EXESUFFIX): $(OBJ)/wad2map.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
kmd2tool$(EXESUFFIX): $(OBJ)/kmd2tool.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
md2tool$(EXESUFFIX): $(OBJ)/md2tool.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
generateicon$(EXESUFFIX): $(OBJ)/generateicon.$o $(OBJ)/compat.$o $(OBJ)/pragmas.$o $(OBJ)/kplib.$o \
|
||||
$(OBJ)/cache1d.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
cacheinfo$(EXESUFFIX): $(OBJ)/cacheinfo.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
enumdisplay$(EXESUFFIX): $(OBJ)/enumdisplay.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS) -I$(DXROOT)/include -lgdi32; then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS) -I$(DXROOT)/include -lgdi32; then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
getdxdidf$(EXESUFFIX): $(OBJ)/getdxdidf.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS) -I$(DXROOT)/include -ldinput; then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS) -I$(DXROOT)/include -ldinput; then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
makesdlkeytrans$(EXESUFFIX): $(OBJ)/makesdlkeytrans.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
arttool$(EXESUFFIX): $(OBJ)/arttool.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(L_CXX) -o $@ $^ $(OURLDFLAGS) $(STATICSTDCPP) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(L_CXX) -o $@ $^ $(OURLDFLAGS) $(STATICSTDCPP) $(STDCPPLIB) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
givedepth$(EXESUFFIX): $(OBJ)/givedepth.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
mkpalette$(EXESUFFIX): $(OBJ)/mkpalette.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
unpackssi$(EXESUFFIX): $(OBJ)/unpackssi.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
bsuite$(EXESUFFIX): $(OBJ)/bsuite.$o $(UTILADDOBJS)
|
||||
$(ONESTEP_STATUS)
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi
|
||||
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
|
||||
|
||||
# DEPENDENCIES
|
||||
include Makefile.deps
|
||||
|
@ -321,15 +310,15 @@ $(OBJ)/%.$o: $(SRC)/%.m
|
|||
|
||||
$(OBJ)/%.$o: $(SRC)/%.cc
|
||||
$(COMPILE_STATUS)
|
||||
if $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
if $(CXX) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
$(OBJ)/%.$o: $(SRC)/%.cpp
|
||||
$(COMPILE_STATUS)
|
||||
if $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
if $(CXX) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
$(OBJ)/%.$o: $(SRC)/%.cxx
|
||||
$(COMPILE_STATUS)
|
||||
if $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
if $(CXX) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
$(OBJ)/%.$o: $(SRC)/misc/%.c
|
||||
$(COMPILE_STATUS)
|
||||
|
@ -345,15 +334,15 @@ $(OBJ)/%.$o: $(SRC)/util/%.c
|
|||
|
||||
$(OBJ)/%.$o: $(SRC)/util/%.cc
|
||||
$(COMPILE_STATUS)
|
||||
if $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
if $(CXX) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
$(OBJ)/%.$o: $(SRC)/util/%.cpp
|
||||
$(COMPILE_STATUS)
|
||||
if $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
if $(CXX) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
$(OBJ)/%.$o: $(SRC)/util/%.cxx
|
||||
$(COMPILE_STATUS)
|
||||
if $(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
if $(CXX) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
|
||||
|
||||
$(OBJ)/%.$o: $(RSRC)/%.c
|
||||
$(COMPILE_STATUS)
|
||||
|
@ -381,6 +370,9 @@ clean:
|
|||
cleanutils:
|
||||
-rm -f $(UTILS) $(UTILOBJS) $(DXUTILS) $(DXUTILOBJS) $(SDLUTILS) $(SDLUTILOBJS) $(UTILADDOBJS)
|
||||
|
||||
veryclean: clean cleanutils
|
||||
-rm -f $(ENGINELIB) $(EDITORLIB)
|
||||
|
||||
printutils:
|
||||
echo "$(UTILS)"
|
||||
|
||||
|
@ -390,9 +382,6 @@ printdxutils:
|
|||
printsdlutils:
|
||||
echo "$(SDLUTILS)"
|
||||
|
||||
veryclean: clean cleanutils
|
||||
-rm -f $(ENGINELIB) $(EDITORLIB)
|
||||
|
||||
.PHONY: fixlineends
|
||||
fixlineends:
|
||||
for a in `find . -type f \( -name '*.c' -o -name '*.h' -o -name 'Makefile*' \) \! -path '*/.svn/*'`; do \
|
||||
|
|
|
@ -34,10 +34,10 @@ endif
|
|||
BUILDCOMMONFLAGS=$(ARCH)
|
||||
|
||||
ifeq ($(PLATFORM),LINUX)
|
||||
STDCPPLIB=
|
||||
STDCPPLIB:=
|
||||
else
|
||||
# Overridden for OSes that don't have the cutdown stdc++ that is supc++
|
||||
STDCPPLIB= -lsupc++
|
||||
STDCPPLIB:=-lsupc++
|
||||
endif
|
||||
|
||||
ifeq ($(PLATFORM),LINUX)
|
||||
|
@ -59,7 +59,7 @@ ifeq ($(PLATFORM),LINUX)
|
|||
endif
|
||||
ifeq ($(PLATFORM),DARWIN)
|
||||
RENDERTYPE = SDL
|
||||
STDCPPLIB = -lstdc++
|
||||
STDCPPLIB:=-lstdc++
|
||||
BUILDCOMMONFLAGS += -DHAVE_INTTYPES
|
||||
GTKCOMPAT32 = 0
|
||||
SDL_FRAMEWORK = 1
|
||||
|
@ -81,7 +81,7 @@ ifeq ($(PLATFORM),WINDOWS)
|
|||
EXESUFFIX=.exe
|
||||
LIBS+= -lmingwex -lwinmm -L$(DXROOT)/lib -lwsock32 -lcomctl32
|
||||
#-lshfolder
|
||||
# STDCPPLIB=-lstdc++
|
||||
#STDCPPLIB:=-lstdc++
|
||||
endif
|
||||
ifeq ($(PLATFORM),BSD)
|
||||
RENDERTYPE=SDL
|
||||
|
@ -89,11 +89,11 @@ ifeq ($(PLATFORM),BSD)
|
|||
ifneq ($(findstring i386, $(SYSARCH)), i386)
|
||||
override NOASM=1
|
||||
endif
|
||||
STDCPPLIB=-lstdc++
|
||||
STDCPPLIB:=-lstdc++
|
||||
endif
|
||||
ifeq ($(PLATFORM),BEOS)
|
||||
RENDERTYPE=SDL
|
||||
STDCPPLIB=-lstdc++
|
||||
STDCPPLIB:=-lstdc++
|
||||
endif
|
||||
ifeq ($(PLATFORM),SKYOS)
|
||||
RENDERTYPE=SDL
|
||||
|
@ -130,14 +130,14 @@ ifeq ($(PLATFORM),QNX)
|
|||
RENDERTYPE=SDL
|
||||
override USE_OPENGL=0
|
||||
override NOASM=1
|
||||
STDCPPLIB=-lstdc++
|
||||
STDCPPLIB:=-lstdc++
|
||||
LIBS+= -lsocket
|
||||
endif
|
||||
ifeq ($(PLATFORM),SUNOS)
|
||||
RENDERTYPE=SDL
|
||||
override USE_OPENGL=0
|
||||
override NOASM=1
|
||||
STDCPPLIB=-lstdc++
|
||||
STDCPPLIB:=-lstdc++
|
||||
LIBS+= -lsocket -lnsl
|
||||
endif
|
||||
ifeq ($(PLATFORM),SYLLABLE)
|
||||
|
@ -146,6 +146,12 @@ ifeq ($(PLATFORM),SYLLABLE)
|
|||
override NOASM=1
|
||||
endif
|
||||
|
||||
ifneq (0,$(CLANG))
|
||||
ifneq (,$(STDCPPLIB))
|
||||
STDCPPLIB:=-Xlinker $(STDCPPLIB)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(RENDERTYPE),SDL)
|
||||
ifeq ($(SDL_FRAMEWORK),1)
|
||||
LIBS += -Wl,-framework,SDL
|
||||
|
@ -264,6 +270,7 @@ ONESTEP_STATUS = printf "\033[K\033[0mBuilding executable \033[1m$@\033[0m...\03
|
|||
COMPILE_OK = printf "\033[K\033[0;32mBuilt object \033[1;32m$@\033[0;32m \033[0m\n"
|
||||
ONESTEP_OK = printf "\033[K\033[0;32mBuilt executable \033[1;32m$@\033[0;32m \033[0m\n"
|
||||
COMPILE_FAILED = printf "\033[K\033[0;31mFailed building \033[1;31m$@\033[0;31m from\033[0m \033[1;31m$<\033[0;31m!\033[0m\n"; exit 1
|
||||
ONESTEP_FAILED = printf "\033[K\033[0;31mFailed building executable \033[1;31m$@\033[0;31m!\033[0m\n"; exit 1
|
||||
ARCHIVE_STATUS = printf "\033[K\033[0mCreating library archive \033[1m$@\033[0m...\033[0m\r"
|
||||
ARCHIVE_OK = printf "\033[K\033[0;32mCreated library archive \033[1;32m$@\033[0;32m \033[0m\n"
|
||||
ARCHIVE_FAILED = printf "\033[K\033[0;31mFailed creating library archive \033[1;31m$@\033[0;31m from\033[0m \033[1;31m$<\033[0;31m!\033[0m\n"; exit 1
|
||||
|
@ -279,6 +286,7 @@ ONESTEP_STATUS =
|
|||
COMPILE_OK = true
|
||||
ONESTEP_OK = true
|
||||
COMPILE_FAILED = false; exit 1
|
||||
ONESTEP_FAILED = false; exit 1
|
||||
ARCHIVE_STATUS =
|
||||
ARCHIVE_OK = true
|
||||
ARCHIVE_FAILED = false; exit 1
|
||||
|
|
|
@ -515,6 +515,8 @@ static inline uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7ff
|
|||
# define Bstat stat
|
||||
# define Bfstat fstat
|
||||
# endif
|
||||
# define Bfileno fileno
|
||||
# define Bferror ferror
|
||||
# define Bfopen fopen
|
||||
# define Bfclose fclose
|
||||
# define Bfflush fflush
|
||||
|
|
|
@ -3,15 +3,130 @@
|
|||
* @author Jonathon Fowler
|
||||
* @license Artistic License 2.0 (http://www.perlfoundation.org/artistic_license_2_0)
|
||||
*/
|
||||
// Bstring and C++ STL --> C conversion by Hendricks266
|
||||
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
using namespace std;
|
||||
////////// Bstring //////////
|
||||
|
||||
class Bstring {
|
||||
public:
|
||||
Bstring(void);
|
||||
Bstring(const char*);
|
||||
Bstring(const Bstring&);
|
||||
~Bstring(void);
|
||||
|
||||
operator const char*() const;
|
||||
const char* operator()(void) const;
|
||||
char& operator[](int);
|
||||
|
||||
Bstring& operator=(const char*);
|
||||
Bstring& operator=(const Bstring&);
|
||||
|
||||
Bstring& operator+=(const char*);
|
||||
Bstring& operator+=(const Bstring&);
|
||||
|
||||
bool operator==(const Bstring&) const;
|
||||
bool operator!=(const Bstring&) const;
|
||||
bool operator< (const Bstring&) const;
|
||||
bool operator<=(const Bstring&) const;
|
||||
bool operator> (const Bstring&) const;
|
||||
bool operator>=(const Bstring&) const;
|
||||
|
||||
bool operator==(const char*) const;
|
||||
bool operator!=(const char*) const;
|
||||
bool operator< (const char*) const;
|
||||
bool operator<=(const char*) const;
|
||||
bool operator> (const char*) const;
|
||||
bool operator>=(const char*) const;
|
||||
|
||||
int compare(const char*) const;
|
||||
int compare(const Bstring&) const;
|
||||
|
||||
unsigned length(void) const;
|
||||
|
||||
void clear(void);
|
||||
|
||||
protected:
|
||||
char* data;
|
||||
};
|
||||
|
||||
Bstring::Bstring(void) { data = NULL; }
|
||||
Bstring::Bstring(const Bstring &value) {
|
||||
if (&value != this)
|
||||
(*this)=value();
|
||||
}
|
||||
Bstring::Bstring(const char *str) {
|
||||
data = NULL;
|
||||
(*this)=str;
|
||||
}
|
||||
|
||||
Bstring::~Bstring(void) { clear(); }
|
||||
|
||||
Bstring::operator const char*() const { return data; }
|
||||
const char* Bstring::operator()(void) const { return data; }
|
||||
char& Bstring::operator[](int index) { return data[index]; }
|
||||
|
||||
Bstring& Bstring::operator=(const Bstring &value)
|
||||
{
|
||||
if (&value != this)
|
||||
(*this)=value();
|
||||
|
||||
return *this;
|
||||
}
|
||||
Bstring& Bstring::operator=(const char *str)
|
||||
{
|
||||
clear();
|
||||
data = Bstrdup(str);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Bstring& Bstring::operator+=(const Bstring &value)
|
||||
{
|
||||
(*this)+=value();
|
||||
|
||||
return *this;
|
||||
}
|
||||
Bstring& Bstring::operator+=(const char *str)
|
||||
{
|
||||
data = (char*) Brealloc(data, (Bstrlen(data) + Bstrlen(str) + 1) * sizeof(char));
|
||||
Bstrcat(data, str);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool Bstring::operator==(const Bstring &value) const { return Bstrcmp(data, value()) == 0; }
|
||||
bool Bstring::operator!=(const Bstring &value) const { return Bstrcmp(data, value()) != 0; }
|
||||
bool Bstring::operator< (const Bstring &value) const { return Bstrcmp(data, value()) < 0; }
|
||||
bool Bstring::operator<=(const Bstring &value) const { return Bstrcmp(data, value()) <= 0; }
|
||||
bool Bstring::operator> (const Bstring &value) const { return Bstrcmp(data, value()) > 0; }
|
||||
bool Bstring::operator>=(const Bstring &value) const { return Bstrcmp(data, value()) >= 0; }
|
||||
|
||||
bool Bstring::operator==(const char *str) const { return Bstrcmp(data, str) == 0; }
|
||||
bool Bstring::operator!=(const char *str) const { return Bstrcmp(data, str) != 0; }
|
||||
bool Bstring::operator< (const char *str) const { return Bstrcmp(data, str) < 0; }
|
||||
bool Bstring::operator<=(const char *str) const { return Bstrcmp(data, str) <= 0; }
|
||||
bool Bstring::operator> (const char *str) const { return Bstrcmp(data, str) > 0; }
|
||||
bool Bstring::operator>=(const char *str) const { return Bstrcmp(data, str) >= 0; }
|
||||
|
||||
int Bstring::compare(const Bstring &value) const { return Bstrcmp(data,value()); }
|
||||
int Bstring::compare(const char *str) const { return Bstrcmp(data,str); }
|
||||
|
||||
unsigned Bstring::length(void) const { return Bstrlen(data); }
|
||||
|
||||
void Bstring::clear(void)
|
||||
{
|
||||
if (data != NULL)
|
||||
Bfree(data);
|
||||
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
////////// arttool //////////
|
||||
|
||||
void usage()
|
||||
{
|
||||
|
@ -39,7 +154,7 @@ void usage()
|
|||
Bprintf(" arttool tileprop [options] <tilenum>\n");
|
||||
Bprintf(" -x <pixels> X-centre\n");
|
||||
Bprintf(" -y <pixels> Y-centre\n");
|
||||
Bprintf(" -ann <frames> Animation frame span, may be -ve\n");
|
||||
Bprintf(" -ann <frames> Animation frame span, may be negative\n");
|
||||
Bprintf(" -ant <type> Animation type (0=none, 1=oscillate, 2=forward, 3=reverse)\n");
|
||||
Bprintf(" -ans <speed> Animation speed\n");
|
||||
Bprintf(" Changes tile properties\n");
|
||||
|
@ -48,7 +163,7 @@ void usage()
|
|||
|
||||
class ARTFile {
|
||||
private:
|
||||
string filename_;
|
||||
Bstring filename_;
|
||||
long localtilestart_;
|
||||
long localtileend_;
|
||||
short * tilesizx_;
|
||||
|
@ -60,33 +175,37 @@ private:
|
|||
char * insert_;
|
||||
int insertlen_;
|
||||
|
||||
void writeShort(ofstream &ofs, short s)
|
||||
void writeShort(BFILE *ofs, short s)
|
||||
{
|
||||
Bassert(ofs);
|
||||
char d[2] = { static_cast<char>(s&255), static_cast<char>((s>>8)&255) };
|
||||
ofs.write(d, 2);
|
||||
Bfwrite(d,1,2,ofs); // 2 == sizeof(d)
|
||||
}
|
||||
|
||||
void writeLong(ofstream &ofs, long l)
|
||||
void writeLong(BFILE *ofs, long l)
|
||||
{
|
||||
Bassert(ofs);
|
||||
char d[4] = { static_cast<char>(l&255), static_cast<char>((l>>8)&255), static_cast<char>((l>>16)&255), static_cast<char>((l>>24)&255) };
|
||||
ofs.write(d, 4);
|
||||
Bfwrite(d,1,4,ofs); // 4 == sizeof(d)
|
||||
}
|
||||
|
||||
short readShort(ifstream &ifs)
|
||||
short readShort(BFILE *ifs)
|
||||
{
|
||||
Bassert(ifs);
|
||||
unsigned char d[2];
|
||||
unsigned short s;
|
||||
ifs.read((char *) d, 2);
|
||||
Bfread(d,1,2,ifs); // 2 == sizeof(d)
|
||||
s = (unsigned short)d[0];
|
||||
s |= (unsigned short)d[1] << 8;
|
||||
return (short)s;
|
||||
}
|
||||
|
||||
long readLong(ifstream &ifs)
|
||||
long readLong(BFILE *ifs)
|
||||
{
|
||||
Bassert(ifs);
|
||||
unsigned char d[4];
|
||||
unsigned long l;
|
||||
ifs.read((char *) d, 4);
|
||||
Bfread(d,1,4,ifs); // 4 == sizeof(d)
|
||||
l = (unsigned long)d[0];
|
||||
l |= (unsigned long)d[1] << 8;
|
||||
l |= (unsigned long)d[2] << 16;
|
||||
|
@ -107,14 +226,11 @@ private:
|
|||
|
||||
void load()
|
||||
{
|
||||
ifstream infile(filename_.c_str(), ios::in | ios::binary);
|
||||
BFILE *infile = Bfopen(filename_(),"rb");
|
||||
int i, ntiles;
|
||||
|
||||
if (infile.is_open()) {
|
||||
do {
|
||||
if (readLong(infile) != 1) {
|
||||
break;
|
||||
}
|
||||
if (infile != NULL && readLong(infile) == 1)
|
||||
{
|
||||
readLong(infile); // skip the numtiles
|
||||
dispose();
|
||||
|
||||
|
@ -126,24 +242,20 @@ private:
|
|||
tilesizy_ = new short[ntiles];
|
||||
picanm_ = new long[ntiles];
|
||||
|
||||
for (i = 0; i < ntiles; i++) {
|
||||
for (i = 0; i < ntiles; ++i) {
|
||||
tilesizx_[i] = readShort(infile);
|
||||
}
|
||||
for (i = 0; i < ntiles; i++) {
|
||||
for (i = 0; i < ntiles; ++i) {
|
||||
tilesizy_[i] = readShort(infile);
|
||||
}
|
||||
for (i = 0; i < ntiles; i++) {
|
||||
for (i = 0; i < ntiles; ++i) {
|
||||
picanm_[i] = readLong(infile);
|
||||
}
|
||||
|
||||
} while (0);
|
||||
|
||||
infile.close();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
ARTFile(string filename)
|
||||
ARTFile(Bstring filename)
|
||||
: filename_(filename), localtilestart_(0), localtileend_(-1),
|
||||
tilesizx_(0), tilesizy_(0), picanm_(0),
|
||||
markprelength_(0), markskiplength_(0), markpostlength_(0),
|
||||
|
@ -215,11 +327,11 @@ public:
|
|||
|
||||
markprelength_ = markpostlength_ = 0;
|
||||
|
||||
for (i = 0; i < tile; i++) {
|
||||
for (i = 0; i < tile; ++i) {
|
||||
markprelength_ += tilesizx_[i] * tilesizy_[i];
|
||||
}
|
||||
markskiplength_ = tilesizx_[tile] * tilesizy_[tile];
|
||||
for (i = tile + 1; i <= end; i++) {
|
||||
for (i = tile + 1; i <= end; ++i) {
|
||||
markpostlength_ += tilesizx_[i] * tilesizy_[i];
|
||||
}
|
||||
|
||||
|
@ -306,18 +418,19 @@ public:
|
|||
|
||||
int write()
|
||||
{
|
||||
string tmpfilename(filename_ + ".arttooltmp");
|
||||
ofstream outfile(tmpfilename.c_str(), ios::out | ios::trunc | ios::binary);
|
||||
ifstream infile(filename_.c_str(), ios::in | ios::binary);
|
||||
int i, left;
|
||||
char blk[4096];
|
||||
BFILE *outfile = tmpfile();
|
||||
|
||||
if (!infile.is_open() && (markprelength_ > 0 || markskiplength_ > 0 || markpostlength_ > 0)) {
|
||||
BFILE *infile = Bfopen(filename_(),"rb");
|
||||
int tmp, left;
|
||||
static const unsigned int blksize = 4096;
|
||||
char blk[blksize];
|
||||
|
||||
if (infile == NULL && (markprelength_ > 0 || markskiplength_ > 0 || markpostlength_ > 0)) {
|
||||
return -1; // couldn't open the original file for copying
|
||||
} else if (infile.is_open()) {
|
||||
} else if (infile != NULL) {
|
||||
// skip to the start of the existing ART data
|
||||
int ofs = 4+4+4+4+(2+2+4)*(localtileend_-localtilestart_+1);
|
||||
infile.seekg(ofs, ios::cur);
|
||||
Bfseek(infile, ofs, SEEK_CUR);
|
||||
}
|
||||
|
||||
// write a header to the temporary file
|
||||
|
@ -325,58 +438,64 @@ public:
|
|||
writeLong(outfile, 0); // numtiles
|
||||
writeLong(outfile, localtilestart_);
|
||||
writeLong(outfile, localtileend_);
|
||||
for (int i = 0; i < localtileend_ - localtilestart_ + 1; i++) {
|
||||
for (int i = 0; i < localtileend_ - localtilestart_ + 1; ++i) {
|
||||
writeShort(outfile, tilesizx_[i]);
|
||||
}
|
||||
for (int i = 0; i < localtileend_ - localtilestart_ + 1; i++) {
|
||||
for (int i = 0; i < localtileend_ - localtilestart_ + 1; ++i) {
|
||||
writeShort(outfile, tilesizy_[i]);
|
||||
}
|
||||
for (int i = 0; i < localtileend_ - localtilestart_ + 1; i++) {
|
||||
for (int i = 0; i < localtileend_ - localtilestart_ + 1; ++i) {
|
||||
writeLong(outfile, picanm_[i]);
|
||||
}
|
||||
|
||||
// copy the existing leading tile data to be kept
|
||||
left = markprelength_;
|
||||
while (left > 0) {
|
||||
i = left;
|
||||
if ((unsigned int)i > sizeof(blk)) {
|
||||
i = sizeof(blk);
|
||||
tmp = left;
|
||||
if ((unsigned int)tmp > blksize) {
|
||||
tmp = blksize;
|
||||
}
|
||||
infile.read(blk, i);
|
||||
outfile.write(blk, i);
|
||||
left -= i;
|
||||
Bfread(blk, 1, tmp, infile);
|
||||
Bfwrite(blk, 1, tmp, outfile);
|
||||
left -= tmp;
|
||||
}
|
||||
|
||||
// insert the replacement data
|
||||
if (insertlen_ > 0) {
|
||||
outfile.write(insert_, insertlen_);
|
||||
Bfwrite(insert_, 1, insertlen_, outfile);
|
||||
}
|
||||
|
||||
if (markskiplength_ > 0) {
|
||||
infile.seekg(markskiplength_, ios::cur);
|
||||
Bfseek(infile, markskiplength_, SEEK_CUR);
|
||||
}
|
||||
|
||||
// copy the existing trailing tile data to be kept
|
||||
left = markpostlength_;
|
||||
while (left > 0) {
|
||||
i = left;
|
||||
if ((unsigned int)i > sizeof(blk)) {
|
||||
i = sizeof(blk);
|
||||
tmp = left;
|
||||
if ((unsigned int)tmp > blksize) {
|
||||
tmp = blksize;
|
||||
}
|
||||
infile.read(blk, i);
|
||||
outfile.write(blk, i);
|
||||
left -= i;
|
||||
Bfread(blk, 1, tmp, infile);
|
||||
Bfwrite(blk, 1, tmp, outfile);
|
||||
left -= tmp;
|
||||
}
|
||||
|
||||
// close our files
|
||||
if (infile.is_open()) {
|
||||
infile.close();
|
||||
}
|
||||
outfile.close();
|
||||
// clean up
|
||||
const long int tempsize = Bftell(outfile);
|
||||
Brewind(outfile);
|
||||
|
||||
// replace it with the new one
|
||||
unlink(filename_.c_str());
|
||||
rename(tmpfilename.c_str(), filename_.c_str());
|
||||
Bfclose(infile);
|
||||
|
||||
infile = Bfopen(filename_(),"wb");
|
||||
|
||||
char * buffer = (char*)Bmalloc(tempsize * sizeof(char));
|
||||
|
||||
Bfread(buffer, 1, tempsize, outfile);
|
||||
Bfwrite(buffer, 1, tempsize, infile);
|
||||
|
||||
Bfclose(infile);
|
||||
Bfclose(outfile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -445,23 +564,24 @@ int loadimage_pcx(unsigned char * data, int datalen ATTRIBUTE((unused)), char **
|
|||
* @param imgdatah receives the decoded image height
|
||||
* @return 0 on success
|
||||
*/
|
||||
int loadimage(string filename, char ** imgdata, int& imgdataw, int& imgdatah)
|
||||
int loadimage(Bstring filename, char ** imgdata, int& imgdataw, int& imgdatah)
|
||||
{
|
||||
ifstream infile(filename.c_str(), ios::in | ios::binary);
|
||||
BFILE *infile = Bfopen(filename(),"rb");
|
||||
unsigned char * data = 0;
|
||||
int datalen = 0, err = 0;
|
||||
|
||||
if (!infile.is_open()) {
|
||||
if (infile == NULL)
|
||||
return 1;
|
||||
}
|
||||
|
||||
infile.seekg(0, ios::end);
|
||||
datalen = infile.tellg();
|
||||
infile.seekg(0, ios::beg);
|
||||
struct Bstat stbuf;
|
||||
if (Bfstat(Bfileno(infile), &stbuf) == -1)
|
||||
return 1;
|
||||
|
||||
datalen = stbuf.st_size;
|
||||
|
||||
data = new unsigned char [datalen];
|
||||
infile.read((char *) data, datalen);
|
||||
infile.close();
|
||||
Bfread(data, 1, datalen, infile);
|
||||
Bfclose(infile);
|
||||
|
||||
err = loadimage_pcx(data, datalen, imgdata, imgdataw, imgdatah);
|
||||
|
||||
|
@ -472,9 +592,9 @@ int loadimage(string filename, char ** imgdata, int& imgdataw, int& imgdatah)
|
|||
|
||||
class Operation {
|
||||
protected:
|
||||
string makefilename(int n)
|
||||
Bstring makefilename(int n)
|
||||
{
|
||||
string filename("tilesXXX.art");
|
||||
Bstring filename("tilesXXX.art");
|
||||
filename[5] = '0' + (n / 100) % 10;
|
||||
filename[6] = '0' + (n / 10) % 10;
|
||||
filename[7] = '0' + (n / 1) % 10;
|
||||
|
@ -499,7 +619,7 @@ public:
|
|||
case ERR_BAD_VALUE: return "bad value";
|
||||
case ERR_TOO_MANY_PARAMS: return "too many parameters given";
|
||||
case ERR_NO_ART_FILE: return "no ART file was found";
|
||||
case ERR_INVALID_IMAGE: return "a corrupt or unrecognised image was given";
|
||||
case ERR_INVALID_IMAGE: return "a nonexistent, corrupt, or unrecognised image was given";
|
||||
default: return "unknown error";
|
||||
}
|
||||
}
|
||||
|
@ -514,7 +634,7 @@ public:
|
|||
* @param value the option value
|
||||
* @return a value from the Result enum
|
||||
*/
|
||||
virtual Result setOption(string opt, string value) = 0;
|
||||
virtual Result setOption(const Bstring &opt, const Bstring &value) = 0;
|
||||
|
||||
/**
|
||||
* Sets a parameter from the unnamed sequence
|
||||
|
@ -522,7 +642,7 @@ public:
|
|||
* @param value the parameter value
|
||||
* @return a value from the Result enum
|
||||
*/
|
||||
virtual Result setParameter(int number, string value) = 0;
|
||||
virtual Result setParameter(const int &number, const Bstring &value) = 0;
|
||||
|
||||
/**
|
||||
* Do the operation
|
||||
|
@ -537,20 +657,20 @@ private:
|
|||
public:
|
||||
CreateOp() : filen_(0), offset_(0), ntiles_(256) { }
|
||||
|
||||
virtual Result setOption(string opt, string value)
|
||||
virtual Result setOption(const Bstring &opt, const Bstring &value)
|
||||
{
|
||||
if (opt == "f") {
|
||||
filen_ = atoi(value.c_str());
|
||||
filen_ = atoi(value());
|
||||
if (filen_ < 0 || filen_ > 999) {
|
||||
return ERR_BAD_VALUE;
|
||||
}
|
||||
} else if (opt == "o") {
|
||||
offset_ = atoi(value.c_str());
|
||||
offset_ = atoi(value());
|
||||
if (offset_ < 0) {
|
||||
return ERR_BAD_VALUE;
|
||||
}
|
||||
} else if (opt == "n") {
|
||||
ntiles_ = atoi(value.c_str());
|
||||
ntiles_ = atoi(value());
|
||||
if (ntiles_ < 1) {
|
||||
return ERR_BAD_VALUE;
|
||||
}
|
||||
|
@ -560,7 +680,7 @@ public:
|
|||
return ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
virtual Result setParameter(int number ATTRIBUTE((unused)), string value ATTRIBUTE((unused)))
|
||||
virtual Result setParameter(const int &number ATTRIBUTE((unused)), const Bstring &value ATTRIBUTE((unused)))
|
||||
{
|
||||
return ERR_TOO_MANY_PARAMS;
|
||||
}
|
||||
|
@ -581,7 +701,7 @@ private:
|
|||
int xofs_, yofs_;
|
||||
int animframes_, animtype_, animspeed_;
|
||||
int tilenum_;
|
||||
string filename_;
|
||||
Bstring filename_;
|
||||
public:
|
||||
AddTileOp()
|
||||
: xofs_(0), yofs_(0),
|
||||
|
@ -589,24 +709,24 @@ public:
|
|||
tilenum_(-1), filename_("")
|
||||
{ }
|
||||
|
||||
virtual Result setOption(string opt, string value)
|
||||
virtual Result setOption(const Bstring &opt, const Bstring &value)
|
||||
{
|
||||
if (opt == "x") {
|
||||
xofs_ = atoi(value.c_str());
|
||||
xofs_ = atoi(value());
|
||||
} else if (opt == "y") {
|
||||
yofs_ = atoi(value.c_str());
|
||||
yofs_ = atoi(value());
|
||||
} else if (opt == "ann") {
|
||||
animframes_ = atoi(value.c_str());
|
||||
animframes_ = atoi(value());
|
||||
if (animframes_ < 0 || animframes_ > 63) {
|
||||
return ERR_BAD_VALUE;
|
||||
}
|
||||
} else if (opt == "ant") {
|
||||
animtype_ = atoi(value.c_str());
|
||||
animtype_ = atoi(value());
|
||||
if (animtype_ < 0 || animtype_ > 3) {
|
||||
return ERR_BAD_VALUE;
|
||||
}
|
||||
} else if (opt == "ans") {
|
||||
animspeed_ = atoi(value.c_str());
|
||||
animspeed_ = atoi(value());
|
||||
if (animspeed_ < 0 || animspeed_ > 15) {
|
||||
return ERR_BAD_VALUE;
|
||||
}
|
||||
|
@ -616,11 +736,11 @@ public:
|
|||
return ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
virtual Result setParameter(int number, string value)
|
||||
virtual Result setParameter(const int &number, const Bstring &value)
|
||||
{
|
||||
switch (number) {
|
||||
case 0:
|
||||
tilenum_ = atoi(value.c_str());
|
||||
tilenum_ = atoi(value());
|
||||
return ERR_NO_ERROR;
|
||||
case 1:
|
||||
filename_ = value;
|
||||
|
@ -702,16 +822,16 @@ private:
|
|||
public:
|
||||
RmTileOp() : tilenum_(-1) { }
|
||||
|
||||
virtual Result setOption(string opt ATTRIBUTE((unused)), string value ATTRIBUTE((unused)))
|
||||
virtual Result setOption(const Bstring &opt ATTRIBUTE((unused)), const Bstring &value ATTRIBUTE((unused)))
|
||||
{
|
||||
return ERR_BAD_OPTION;
|
||||
}
|
||||
|
||||
virtual Result setParameter(int number, string value)
|
||||
virtual Result setParameter(const int &number, const Bstring &value)
|
||||
{
|
||||
switch (number) {
|
||||
case 0:
|
||||
tilenum_ = atoi(value.c_str());
|
||||
tilenum_ = atoi(value());
|
||||
return ERR_NO_ERROR;
|
||||
default:
|
||||
return ERR_TOO_MANY_PARAMS;
|
||||
|
@ -765,28 +885,28 @@ public:
|
|||
tilenum_(-1), settings_(0)
|
||||
{ }
|
||||
|
||||
virtual Result setOption(string opt, string value)
|
||||
virtual Result setOption(const Bstring &opt, const Bstring &value)
|
||||
{
|
||||
if (opt == "x") {
|
||||
xofs_ = atoi(value.c_str());
|
||||
xofs_ = atoi(value());
|
||||
settings_ |= SET_XOFS;
|
||||
} else if (opt == "y") {
|
||||
yofs_ = atoi(value.c_str());
|
||||
yofs_ = atoi(value());
|
||||
settings_ |= SET_YOFS;
|
||||
} else if (opt == "ann") {
|
||||
animframes_ = atoi(value.c_str());
|
||||
animframes_ = atoi(value());
|
||||
settings_ |= SET_ANIMFRAMES;
|
||||
if (animframes_ < 0 || animframes_ > 63) {
|
||||
return ERR_BAD_VALUE;
|
||||
}
|
||||
} else if (opt == "ant") {
|
||||
animtype_ = atoi(value.c_str());
|
||||
animtype_ = atoi(value());
|
||||
settings_ |= SET_ANIMTYPE;
|
||||
if (animtype_ < 0 || animtype_ > 3) {
|
||||
return ERR_BAD_VALUE;
|
||||
}
|
||||
} else if (opt == "ans") {
|
||||
animspeed_ = atoi(value.c_str());
|
||||
animspeed_ = atoi(value());
|
||||
settings_ |= SET_ANIMSPEED;
|
||||
if (animspeed_ < 0 || animspeed_ > 15) {
|
||||
return ERR_BAD_VALUE;
|
||||
|
@ -797,11 +917,11 @@ public:
|
|||
return ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
virtual Result setParameter(int number, string value)
|
||||
virtual Result setParameter(const int &number, const Bstring &value)
|
||||
{
|
||||
switch (number) {
|
||||
case 0:
|
||||
tilenum_ = atoi(value.c_str());
|
||||
tilenum_ = atoi(value());
|
||||
return ERR_NO_ERROR;
|
||||
default:
|
||||
return ERR_TOO_MANY_PARAMS;
|
||||
|
@ -860,8 +980,8 @@ int main(int argc, char ** argv)
|
|||
if (argc < 2) {
|
||||
showusage = 1;
|
||||
} else {
|
||||
string opt(argv[1]);
|
||||
string value;
|
||||
Bstring opt(argv[1]);
|
||||
Bstring value;
|
||||
|
||||
// create the option handler object according to the first param
|
||||
if (opt == "create") {
|
||||
|
@ -879,15 +999,15 @@ int main(int argc, char ** argv)
|
|||
// apply the command line options given
|
||||
if (oper) {
|
||||
int unnamedParm = 0;
|
||||
for (int i = 2; i < argc && !showusage; i++) {
|
||||
for (int i = 2; i < argc && !showusage; ++i) {
|
||||
if (argv[i][0] == '-') {
|
||||
opt = string(argv[i]).substr(1);
|
||||
opt = argv[i] + 1;
|
||||
if (i+1 >= argc) {
|
||||
showusage = 2;
|
||||
break;
|
||||
}
|
||||
value = string(argv[i+1]);
|
||||
i++;
|
||||
value = argv[i+1];
|
||||
++i;
|
||||
|
||||
switch (err = oper->setOption(opt, value)) {
|
||||
case Operation::ERR_NO_ERROR: break;
|
||||
|
@ -897,7 +1017,7 @@ int main(int argc, char ** argv)
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
value = string(argv[i]);
|
||||
value = argv[i];
|
||||
switch (oper->setParameter(unnamedParm, value)) {
|
||||
case Operation::ERR_NO_ERROR: break;
|
||||
default:
|
||||
|
@ -905,7 +1025,7 @@ int main(int argc, char ** argv)
|
|||
showusage = 2;
|
||||
break;
|
||||
}
|
||||
unnamedParm++;
|
||||
++unnamedParm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
/*
|
||||
NOTE: This program does not fall under BUILDLIC.
|
||||
*/
|
||||
// DOS 16-bit real mode UI --> portable command line conversion by Hendricks266
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -9,7 +9,9 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#define Bmemcmp memcmp
|
||||
#define USE_OPENGL
|
||||
#ifndef USE_OPENGL
|
||||
# define USE_OPENGL
|
||||
#endif
|
||||
#define ANIMVPX_STANDALONE
|
||||
#include "animvpx.h"
|
||||
|
Loading…
Reference in a new issue