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:
hendricks266 2012-11-15 06:42:37 +00:00
parent c6bbb0547b
commit a418bec8c2
8 changed files with 340 additions and 198 deletions

View file

@ -5,7 +5,8 @@
include Makefile.common include Makefile.common
# SDK locations - adjust to match your setup # SDK locations for Windows - adjust to match your setup
#
ifneq ($(DXROOT_OVERRIDE),) ifneq ($(DXROOT_OVERRIDE),)
DXROOT=$(DXROOT_OVERRIDE) DXROOT=$(DXROOT_OVERRIDE)
else else
@ -14,6 +15,7 @@ else
endif endif
# Build locations # Build locations
#
SRC=source SRC=source
RSRC=rsrc RSRC=rsrc
ESRC=$(EROOT)/src ESRC=$(EROOT)/src
@ -70,8 +72,6 @@ endif
EDUKE32 ?= eduke32$(EXESUFFIX) EDUKE32 ?= eduke32$(EXESUFFIX)
MAPSTER32 ?= mapster32$(EXESUFFIX) MAPSTER32 ?= mapster32$(EXESUFFIX)
IVFRATE ?= samples/ivfrate$(EXESUFFIX)
EDUKE32_TARGET:=$(EDUKE32) EDUKE32_TARGET:=$(EDUKE32)
ifneq ($(PLATFORM),WII) ifneq ($(PLATFORM),WII)
MAPSTER32_TARGET:=$(MAPSTER32) MAPSTER32_TARGET:=$(MAPSTER32)
@ -80,8 +80,6 @@ endif
EBACKTRACEDLL ?= ebacktrace1.dll EBACKTRACEDLL ?= ebacktrace1.dll
EBACKTRACEDLL_TARGET:= EBACKTRACEDLL_TARGET:=
IVFRATE_TARGET:=$(IVFRATE)
ifeq ($(PLATFORM),WINDOWS) ifeq ($(PLATFORM),WINDOWS)
OBJ=obj_win OBJ=obj_win
EOBJ=eobj_win EOBJ=eobj_win
@ -321,20 +319,29 @@ endif
# TARGETS # TARGETS
all: notice $(EDUKE32_TARGET) $(MAPSTER32_TARGET) $(EBACKTRACEDLL_TARGET) $(IVFRATE_TARGET) UTILOBJS=$(OBJ)/ivfrate.$o
UTILS=ivfrate$(EXESUFFIX)
all: all: start $(EDUKE32_TARGET) $(MAPSTER32_TARGET) $(EBACKTRACEDLL_TARGET) finish
$(BUILD_FINISHED)
ifneq (,$(EDUKE32_TARGET)) ifneq (,$(EDUKE32_TARGET))
@ls -l $(EDUKE32) @ls -l $(EDUKE32)
endif endif
ifneq (,$(MAPSTER32_TARGET)) ifneq (,$(MAPSTER32_TARGET))
@ls -l $(MAPSTER32) @ls -l $(MAPSTER32)
endif endif
ifneq (,$(EBACKTRACEDLL_TARGET))
@ls -l $(EBACKTRACEDLL)
endif
notice: utils: start $(UTILS) finish
@ls -l $(UTILS)
start:
$(BUILD_STARTED) $(BUILD_STARTED)
finish:
$(BUILD_FINISHED)
$(EDUKE32): $(GAMEOBJS) $(EOBJ)/$(ENGINELIB) $(JAUDIOLIBDIR)/$(JAUDIOLIB) $(ENETDIR)/$(ENETLIB) $(MISCGAMEDEPS) $(EDUKE32): $(GAMEOBJS) $(EOBJ)/$(ENGINELIB) $(JAUDIOLIBDIR)/$(JAUDIOLIB) $(ENETDIR)/$(ENETLIB) $(MISCGAMEDEPS)
$(LINK_STATUS) $(LINK_STATUS)
@ -405,6 +412,7 @@ endif
# RULES # RULES
$(EBACKTRACEDLL): Windows/src/backtrace.c $(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 if $(CC) $(OURCONLYFLAGS) -O2 -shared -Wall -Wextra -I$(EINC) -o $@ $^ -lbfd -liberty -limagehlp; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
$(OBJ)/%.$o: $(SRC)/%.nasm $(OBJ)/%.$o: $(SRC)/%.nasm
@ -417,8 +425,13 @@ $(OBJ)/%.$o: $(SRC)/%.c
#### Utilities #### Utilities
$(IVFRATE): $(SRC)/ivfrate.c $(SRC)/animvpx.h $(OBJ)/%.$o: $(SRC)/util/%.c
if $(COMPILER) -Wall -Wextra $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi $(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 #### Lunatic
@ -463,15 +476,15 @@ $(OBJ)/%.$o: Apple/%.m
$(OBJ)/%.$o: $(SRC)/%.cc $(OBJ)/%.$o: $(SRC)/%.cc
$(COMPILE_STATUS) $(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 $(OBJ)/%.$o: $(SRC)/%.cpp
$(COMPILE_STATUS) $(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 $(OBJ)/%.$o: $(SRC)/%.cxx
$(COMPILE_STATUS) $(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 $(OBJ)/%.$o: $(SRC)/jmact/%.c
$(COMPILE_STATUS) $(COMPILE_STATUS)
@ -502,15 +515,21 @@ $(RSRC)/editor_banner.c: $(RSRC)/build.bmp
echo "extern const GdkPixdata startbanner_pixdata;" >> $@ echo "extern const GdkPixdata startbanner_pixdata;" >> $@
gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@ gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed 's/load_inc//' >> $@
# PHONIES # PHONIES
clean: 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) ifeq ($(PLATFORM),DARWIN)
-rm -rf EDuke32.app Mapster32.app -rm -rf EDuke32.app Mapster32.app
endif endif
echo -n "" > $(OBJ)/keep.me echo -n "" > $(OBJ)/keep.me
veryclean: clean cleanutils:
-rm -f $(UTILS) $(UTILOBJS) $(addsuffix .memmap, $(UTILS))
veryclean: clean cleanutils
-rm -f $(EOBJ)/* $(RSRC)/*banner* $(EBACKTRACEDLL) -rm -f $(EOBJ)/* $(RSRC)/*banner* $(EBACKTRACEDLL)
echo -n "" > $(EOBJ)/keep.me echo -n "" > $(EOBJ)/keep.me
printutils:
echo "$(UTILS)"

View file

@ -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)/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)/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

View file

@ -2,12 +2,6 @@
# Build Makefile for GNU Make # 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 include ../Makefile.common
@ -19,7 +13,6 @@ else
DXROOT=../../sdk/dx DXROOT=../../sdk/dx
#DXROOT=c:/sdks/directx/dx8 #DXROOT=c:/sdks/directx/dx8
endif endif
FMODROOTWIN=c:/sdks/fmodapi374win/api
# Build locations - OBJ gets overridden to the game-specific objects dir # Build locations - OBJ gets overridden to the game-specific objects dir
# #
@ -125,7 +118,7 @@ ifeq ($(PLATFORM),BSD)
OURCOMMONFLAGS+= -I/usr/X11R6/include OURCOMMONFLAGS+= -I/usr/X11R6/include
endif endif
ifeq ($(PLATFORM),WINDOWS) 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 OURASFLAGS+= -DUNDERSCORES -f win32
endif endif
ifeq ($(PLATFORM),BEOS) ifeq ($(PLATFORM),BEOS)
@ -188,7 +181,7 @@ ifneq ($(CPLUSPLUS),0)
endif endif
.SILENT: .SILENT:
.PHONY: clean cleanutils veryclean all utils enginelib editorlib .PHONY: clean cleanutils veryclean all utils dxutils sdlutils printutils printsdlutils printdxutils enginelib editorlib
# TARGETS # TARGETS
@ -209,9 +202,14 @@ SDLUTILOBJS=$(OBJ)/makesdlkeytrans.$o
SDLUTILS=makesdlkeytrans$(EXESUFFIX) SDLUTILS=makesdlkeytrans$(EXESUFFIX)
# all: $(OBJ)/$(ENGINELIB) $(OBJ)/$(EDITORLIB) # all: $(OBJ)/$(ENGINELIB) $(OBJ)/$(EDITORLIB)
utils: start $(UTILS) finish utilfinish utils: start $(UTILS) finish
dxutils: start $(DXUTILS) finish dxutilfinish @ls -l $(UTILS)
sdlutils: start $(SDLUTILS) finish sdlutilfinish
dxutils: start $(DXUTILS) finish
@ls -l $(DXUTILS)
sdlutils: start $(SDLUTILS) finish
@ls -l $(SDLUTILS)
start: start:
$(BUILD_STARTED) $(BUILD_STARTED)
@ -219,15 +217,6 @@ start:
finish: finish:
$(BUILD_FINISHED) $(BUILD_FINISHED)
utilfinish:
@ls -l $(UTILS)
dxutilfinish:
@ls -l $(DXUTILS)
sdlutilfinish:
@ls -l $(SDLUTILS)
enginelib: $(OBJ)/$(ENGINELIB) enginelib: $(OBJ)/$(ENGINELIB)
$(OBJ)/$(ENGINELIB): $(ENGINEOBJS) $(OBJ)/$(ENGINELIB): $(ENGINEOBJS)
$(BUILD_ECHOFLAGS) $(BUILD_ECHOFLAGS)
@ -247,56 +236,56 @@ $(OBJ)/$(EDITORLIB): $(EDITOROBJS)
kextract$(EXESUFFIX): $(OBJ)/kextract.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS) kextract$(EXESUFFIX): $(OBJ)/kextract.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) kgroup$(EXESUFFIX): $(OBJ)/kgroup.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) transpal$(EXESUFFIX): $(OBJ)/transpal.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) wad2art$(EXESUFFIX): $(OBJ)/wad2art.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) wad2map$(EXESUFFIX): $(OBJ)/wad2map.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) kmd2tool$(EXESUFFIX): $(OBJ)/kmd2tool.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) md2tool$(EXESUFFIX): $(OBJ)/md2tool.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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 \ generateicon$(EXESUFFIX): $(OBJ)/generateicon.$o $(OBJ)/compat.$o $(OBJ)/pragmas.$o $(OBJ)/kplib.$o \
$(OBJ)/cache1d.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS) $(OBJ)/cache1d.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) cacheinfo$(EXESUFFIX): $(OBJ)/cacheinfo.$o $(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) enumdisplay$(EXESUFFIX): $(OBJ)/enumdisplay.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) getdxdidf$(EXESUFFIX): $(OBJ)/getdxdidf.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) makesdlkeytrans$(EXESUFFIX): $(OBJ)/makesdlkeytrans.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) arttool$(EXESUFFIX): $(OBJ)/arttool.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) givedepth$(EXESUFFIX): $(OBJ)/givedepth.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) mkpalette$(EXESUFFIX): $(OBJ)/mkpalette.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) unpackssi$(EXESUFFIX): $(OBJ)/unpackssi.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(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) bsuite$(EXESUFFIX): $(OBJ)/bsuite.$o $(UTILADDOBJS)
$(ONESTEP_STATUS) $(ONESTEP_STATUS)
if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); fi if $(LINKER) -o $@ $^ $(OURLDFLAGS) $(UTILLIBS); then $(ONESTEP_OK); else $(ONESTEP_FAILED); fi
# DEPENDENCIES # DEPENDENCIES
include Makefile.deps include Makefile.deps
@ -321,15 +310,15 @@ $(OBJ)/%.$o: $(SRC)/%.m
$(OBJ)/%.$o: $(SRC)/%.cc $(OBJ)/%.$o: $(SRC)/%.cc
$(COMPILE_STATUS) $(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 $(OBJ)/%.$o: $(SRC)/%.cpp
$(COMPILE_STATUS) $(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 $(OBJ)/%.$o: $(SRC)/%.cxx
$(COMPILE_STATUS) $(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 $(OBJ)/%.$o: $(SRC)/misc/%.c
$(COMPILE_STATUS) $(COMPILE_STATUS)
@ -345,15 +334,15 @@ $(OBJ)/%.$o: $(SRC)/util/%.c
$(OBJ)/%.$o: $(SRC)/util/%.cc $(OBJ)/%.$o: $(SRC)/util/%.cc
$(COMPILE_STATUS) $(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 $(OBJ)/%.$o: $(SRC)/util/%.cpp
$(COMPILE_STATUS) $(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 $(OBJ)/%.$o: $(SRC)/util/%.cxx
$(COMPILE_STATUS) $(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 $(OBJ)/%.$o: $(RSRC)/%.c
$(COMPILE_STATUS) $(COMPILE_STATUS)
@ -381,6 +370,9 @@ clean:
cleanutils: cleanutils:
-rm -f $(UTILS) $(UTILOBJS) $(DXUTILS) $(DXUTILOBJS) $(SDLUTILS) $(SDLUTILOBJS) $(UTILADDOBJS) -rm -f $(UTILS) $(UTILOBJS) $(DXUTILS) $(DXUTILOBJS) $(SDLUTILS) $(SDLUTILOBJS) $(UTILADDOBJS)
veryclean: clean cleanutils
-rm -f $(ENGINELIB) $(EDITORLIB)
printutils: printutils:
echo "$(UTILS)" echo "$(UTILS)"
@ -390,9 +382,6 @@ printdxutils:
printsdlutils: printsdlutils:
echo "$(SDLUTILS)" echo "$(SDLUTILS)"
veryclean: clean cleanutils
-rm -f $(ENGINELIB) $(EDITORLIB)
.PHONY: fixlineends .PHONY: fixlineends
fixlineends: fixlineends:
for a in `find . -type f \( -name '*.c' -o -name '*.h' -o -name 'Makefile*' \) \! -path '*/.svn/*'`; do \ for a in `find . -type f \( -name '*.c' -o -name '*.h' -o -name 'Makefile*' \) \! -path '*/.svn/*'`; do \

View file

@ -34,10 +34,10 @@ endif
BUILDCOMMONFLAGS=$(ARCH) BUILDCOMMONFLAGS=$(ARCH)
ifeq ($(PLATFORM),LINUX) ifeq ($(PLATFORM),LINUX)
STDCPPLIB= STDCPPLIB:=
else else
# Overridden for OSes that don't have the cutdown stdc++ that is supc++ # Overridden for OSes that don't have the cutdown stdc++ that is supc++
STDCPPLIB= -lsupc++ STDCPPLIB:=-lsupc++
endif endif
ifeq ($(PLATFORM),LINUX) ifeq ($(PLATFORM),LINUX)
@ -59,7 +59,7 @@ ifeq ($(PLATFORM),LINUX)
endif endif
ifeq ($(PLATFORM),DARWIN) ifeq ($(PLATFORM),DARWIN)
RENDERTYPE = SDL RENDERTYPE = SDL
STDCPPLIB = -lstdc++ STDCPPLIB:=-lstdc++
BUILDCOMMONFLAGS += -DHAVE_INTTYPES BUILDCOMMONFLAGS += -DHAVE_INTTYPES
GTKCOMPAT32 = 0 GTKCOMPAT32 = 0
SDL_FRAMEWORK = 1 SDL_FRAMEWORK = 1
@ -81,7 +81,7 @@ ifeq ($(PLATFORM),WINDOWS)
EXESUFFIX=.exe EXESUFFIX=.exe
LIBS+= -lmingwex -lwinmm -L$(DXROOT)/lib -lwsock32 -lcomctl32 LIBS+= -lmingwex -lwinmm -L$(DXROOT)/lib -lwsock32 -lcomctl32
#-lshfolder #-lshfolder
# STDCPPLIB=-lstdc++ #STDCPPLIB:=-lstdc++
endif endif
ifeq ($(PLATFORM),BSD) ifeq ($(PLATFORM),BSD)
RENDERTYPE=SDL RENDERTYPE=SDL
@ -89,11 +89,11 @@ ifeq ($(PLATFORM),BSD)
ifneq ($(findstring i386, $(SYSARCH)), i386) ifneq ($(findstring i386, $(SYSARCH)), i386)
override NOASM=1 override NOASM=1
endif endif
STDCPPLIB=-lstdc++ STDCPPLIB:=-lstdc++
endif endif
ifeq ($(PLATFORM),BEOS) ifeq ($(PLATFORM),BEOS)
RENDERTYPE=SDL RENDERTYPE=SDL
STDCPPLIB=-lstdc++ STDCPPLIB:=-lstdc++
endif endif
ifeq ($(PLATFORM),SKYOS) ifeq ($(PLATFORM),SKYOS)
RENDERTYPE=SDL RENDERTYPE=SDL
@ -130,14 +130,14 @@ ifeq ($(PLATFORM),QNX)
RENDERTYPE=SDL RENDERTYPE=SDL
override USE_OPENGL=0 override USE_OPENGL=0
override NOASM=1 override NOASM=1
STDCPPLIB=-lstdc++ STDCPPLIB:=-lstdc++
LIBS+= -lsocket LIBS+= -lsocket
endif endif
ifeq ($(PLATFORM),SUNOS) ifeq ($(PLATFORM),SUNOS)
RENDERTYPE=SDL RENDERTYPE=SDL
override USE_OPENGL=0 override USE_OPENGL=0
override NOASM=1 override NOASM=1
STDCPPLIB=-lstdc++ STDCPPLIB:=-lstdc++
LIBS+= -lsocket -lnsl LIBS+= -lsocket -lnsl
endif endif
ifeq ($(PLATFORM),SYLLABLE) ifeq ($(PLATFORM),SYLLABLE)
@ -146,6 +146,12 @@ ifeq ($(PLATFORM),SYLLABLE)
override NOASM=1 override NOASM=1
endif endif
ifneq (0,$(CLANG))
ifneq (,$(STDCPPLIB))
STDCPPLIB:=-Xlinker $(STDCPPLIB)
endif
endif
ifeq ($(RENDERTYPE),SDL) ifeq ($(RENDERTYPE),SDL)
ifeq ($(SDL_FRAMEWORK),1) ifeq ($(SDL_FRAMEWORK),1)
LIBS += -Wl,-framework,SDL 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" 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" 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 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_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_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 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 COMPILE_OK = true
ONESTEP_OK = true ONESTEP_OK = true
COMPILE_FAILED = false; exit 1 COMPILE_FAILED = false; exit 1
ONESTEP_FAILED = false; exit 1
ARCHIVE_STATUS = ARCHIVE_STATUS =
ARCHIVE_OK = true ARCHIVE_OK = true
ARCHIVE_FAILED = false; exit 1 ARCHIVE_FAILED = false; exit 1

View file

@ -515,6 +515,8 @@ static inline uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7ff
# define Bstat stat # define Bstat stat
# define Bfstat fstat # define Bfstat fstat
# endif # endif
# define Bfileno fileno
# define Bferror ferror
# define Bfopen fopen # define Bfopen fopen
# define Bfclose fclose # define Bfclose fclose
# define Bfflush fflush # define Bfflush fflush

View file

@ -3,15 +3,130 @@
* @author Jonathon Fowler * @author Jonathon Fowler
* @license Artistic License 2.0 (http://www.perlfoundation.org/artistic_license_2_0) * @license Artistic License 2.0 (http://www.perlfoundation.org/artistic_license_2_0)
*/ */
// Bstring and C++ STL --> C conversion by Hendricks266
#include <cstdio> #include <stdio.h>
#include <fstream> #include <string.h>
#include <cstring>
#include <string>
#include "compat.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() void usage()
{ {
@ -39,7 +154,7 @@ void usage()
Bprintf(" arttool tileprop [options] <tilenum>\n"); Bprintf(" arttool tileprop [options] <tilenum>\n");
Bprintf(" -x <pixels> X-centre\n"); Bprintf(" -x <pixels> X-centre\n");
Bprintf(" -y <pixels> Y-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(" -ant <type> Animation type (0=none, 1=oscillate, 2=forward, 3=reverse)\n");
Bprintf(" -ans <speed> Animation speed\n"); Bprintf(" -ans <speed> Animation speed\n");
Bprintf(" Changes tile properties\n"); Bprintf(" Changes tile properties\n");
@ -48,7 +163,7 @@ void usage()
class ARTFile { class ARTFile {
private: private:
string filename_; Bstring filename_;
long localtilestart_; long localtilestart_;
long localtileend_; long localtileend_;
short * tilesizx_; short * tilesizx_;
@ -60,33 +175,37 @@ private:
char * insert_; char * insert_;
int insertlen_; 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) }; 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) }; 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 char d[2];
unsigned short s; 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[0];
s |= (unsigned short)d[1] << 8; s |= (unsigned short)d[1] << 8;
return (short)s; return (short)s;
} }
long readLong(ifstream &ifs) long readLong(BFILE *ifs)
{ {
Bassert(ifs);
unsigned char d[4]; unsigned char d[4];
unsigned long l; 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[0];
l |= (unsigned long)d[1] << 8; l |= (unsigned long)d[1] << 8;
l |= (unsigned long)d[2] << 16; l |= (unsigned long)d[2] << 16;
@ -107,43 +226,36 @@ private:
void load() void load()
{ {
ifstream infile(filename_.c_str(), ios::in | ios::binary); BFILE *infile = Bfopen(filename_(),"rb");
int i, ntiles; int i, ntiles;
if (infile.is_open()) { if (infile != NULL && readLong(infile) == 1)
do { {
if (readLong(infile) != 1) { readLong(infile); // skip the numtiles
break; dispose();
}
readLong(infile); // skip the numtiles
dispose();
localtilestart_ = readLong(infile); localtilestart_ = readLong(infile);
localtileend_ = readLong(infile); localtileend_ = readLong(infile);
ntiles = localtileend_ - localtilestart_ + 1; ntiles = localtileend_ - localtilestart_ + 1;
tilesizx_ = new short[ntiles]; tilesizx_ = new short[ntiles];
tilesizy_ = new short[ntiles]; tilesizy_ = new short[ntiles];
picanm_ = new long[ntiles]; picanm_ = new long[ntiles];
for (i = 0; i < ntiles; i++) { for (i = 0; i < ntiles; ++i) {
tilesizx_[i] = readShort(infile); tilesizx_[i] = readShort(infile);
} }
for (i = 0; i < ntiles; i++) { for (i = 0; i < ntiles; ++i) {
tilesizy_[i] = readShort(infile); tilesizy_[i] = readShort(infile);
} }
for (i = 0; i < ntiles; i++) { for (i = 0; i < ntiles; ++i) {
picanm_[i] = readLong(infile); picanm_[i] = readLong(infile);
} }
} while (0);
infile.close();
} }
} }
public: public:
ARTFile(string filename) ARTFile(Bstring filename)
: filename_(filename), localtilestart_(0), localtileend_(-1), : filename_(filename), localtilestart_(0), localtileend_(-1),
tilesizx_(0), tilesizy_(0), picanm_(0), tilesizx_(0), tilesizy_(0), picanm_(0),
markprelength_(0), markskiplength_(0), markpostlength_(0), markprelength_(0), markskiplength_(0), markpostlength_(0),
@ -215,11 +327,11 @@ public:
markprelength_ = markpostlength_ = 0; markprelength_ = markpostlength_ = 0;
for (i = 0; i < tile; i++) { for (i = 0; i < tile; ++i) {
markprelength_ += tilesizx_[i] * tilesizy_[i]; markprelength_ += tilesizx_[i] * tilesizy_[i];
} }
markskiplength_ = tilesizx_[tile] * tilesizy_[tile]; markskiplength_ = tilesizx_[tile] * tilesizy_[tile];
for (i = tile + 1; i <= end; i++) { for (i = tile + 1; i <= end; ++i) {
markpostlength_ += tilesizx_[i] * tilesizy_[i]; markpostlength_ += tilesizx_[i] * tilesizy_[i];
} }
@ -306,18 +418,19 @@ public:
int write() int write()
{ {
string tmpfilename(filename_ + ".arttooltmp"); BFILE *outfile = tmpfile();
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];
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 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 // skip to the start of the existing ART data
int ofs = 4+4+4+4+(2+2+4)*(localtileend_-localtilestart_+1); 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 // write a header to the temporary file
@ -325,58 +438,64 @@ public:
writeLong(outfile, 0); // numtiles writeLong(outfile, 0); // numtiles
writeLong(outfile, localtilestart_); writeLong(outfile, localtilestart_);
writeLong(outfile, localtileend_); 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]); 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]); 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]); writeLong(outfile, picanm_[i]);
} }
// copy the existing leading tile data to be kept // copy the existing leading tile data to be kept
left = markprelength_; left = markprelength_;
while (left > 0) { while (left > 0) {
i = left; tmp = left;
if ((unsigned int)i > sizeof(blk)) { if ((unsigned int)tmp > blksize) {
i = sizeof(blk); tmp = blksize;
} }
infile.read(blk, i); Bfread(blk, 1, tmp, infile);
outfile.write(blk, i); Bfwrite(blk, 1, tmp, outfile);
left -= i; left -= tmp;
} }
// insert the replacement data // insert the replacement data
if (insertlen_ > 0) { if (insertlen_ > 0) {
outfile.write(insert_, insertlen_); Bfwrite(insert_, 1, insertlen_, outfile);
} }
if (markskiplength_ > 0) { if (markskiplength_ > 0) {
infile.seekg(markskiplength_, ios::cur); Bfseek(infile, markskiplength_, SEEK_CUR);
} }
// copy the existing trailing tile data to be kept // copy the existing trailing tile data to be kept
left = markpostlength_; left = markpostlength_;
while (left > 0) { while (left > 0) {
i = left; tmp = left;
if ((unsigned int)i > sizeof(blk)) { if ((unsigned int)tmp > blksize) {
i = sizeof(blk); tmp = blksize;
} }
infile.read(blk, i); Bfread(blk, 1, tmp, infile);
outfile.write(blk, i); Bfwrite(blk, 1, tmp, outfile);
left -= i; left -= tmp;
} }
// close our files // clean up
if (infile.is_open()) { const long int tempsize = Bftell(outfile);
infile.close(); Brewind(outfile);
}
outfile.close();
// replace it with the new one Bfclose(infile);
unlink(filename_.c_str());
rename(tmpfilename.c_str(), filename_.c_str()); 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; return 0;
} }
@ -445,23 +564,24 @@ int loadimage_pcx(unsigned char * data, int datalen ATTRIBUTE((unused)), char **
* @param imgdatah receives the decoded image height * @param imgdatah receives the decoded image height
* @return 0 on success * @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; unsigned char * data = 0;
int datalen = 0, err = 0; int datalen = 0, err = 0;
if (!infile.is_open()) { if (infile == NULL)
return 1; return 1;
}
infile.seekg(0, ios::end); struct Bstat stbuf;
datalen = infile.tellg(); if (Bfstat(Bfileno(infile), &stbuf) == -1)
infile.seekg(0, ios::beg); return 1;
datalen = stbuf.st_size;
data = new unsigned char [datalen]; data = new unsigned char [datalen];
infile.read((char *) data, datalen); Bfread(data, 1, datalen, infile);
infile.close(); Bfclose(infile);
err = loadimage_pcx(data, datalen, imgdata, imgdataw, imgdatah); err = loadimage_pcx(data, datalen, imgdata, imgdataw, imgdatah);
@ -472,9 +592,9 @@ int loadimage(string filename, char ** imgdata, int& imgdataw, int& imgdatah)
class Operation { class Operation {
protected: protected:
string makefilename(int n) Bstring makefilename(int n)
{ {
string filename("tilesXXX.art"); Bstring filename("tilesXXX.art");
filename[5] = '0' + (n / 100) % 10; filename[5] = '0' + (n / 100) % 10;
filename[6] = '0' + (n / 10) % 10; filename[6] = '0' + (n / 10) % 10;
filename[7] = '0' + (n / 1) % 10; filename[7] = '0' + (n / 1) % 10;
@ -499,7 +619,7 @@ public:
case ERR_BAD_VALUE: return "bad value"; case ERR_BAD_VALUE: return "bad value";
case ERR_TOO_MANY_PARAMS: return "too many parameters given"; case ERR_TOO_MANY_PARAMS: return "too many parameters given";
case ERR_NO_ART_FILE: return "no ART file was found"; 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"; default: return "unknown error";
} }
} }
@ -514,7 +634,7 @@ public:
* @param value the option value * @param value the option value
* @return a value from the Result enum * @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 * Sets a parameter from the unnamed sequence
@ -522,7 +642,7 @@ public:
* @param value the parameter value * @param value the parameter value
* @return a value from the Result enum * @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 * Do the operation
@ -537,20 +657,20 @@ private:
public: public:
CreateOp() : filen_(0), offset_(0), ntiles_(256) { } 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") { if (opt == "f") {
filen_ = atoi(value.c_str()); filen_ = atoi(value());
if (filen_ < 0 || filen_ > 999) { if (filen_ < 0 || filen_ > 999) {
return ERR_BAD_VALUE; return ERR_BAD_VALUE;
} }
} else if (opt == "o") { } else if (opt == "o") {
offset_ = atoi(value.c_str()); offset_ = atoi(value());
if (offset_ < 0) { if (offset_ < 0) {
return ERR_BAD_VALUE; return ERR_BAD_VALUE;
} }
} else if (opt == "n") { } else if (opt == "n") {
ntiles_ = atoi(value.c_str()); ntiles_ = atoi(value());
if (ntiles_ < 1) { if (ntiles_ < 1) {
return ERR_BAD_VALUE; return ERR_BAD_VALUE;
} }
@ -560,7 +680,7 @@ public:
return ERR_NO_ERROR; 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; return ERR_TOO_MANY_PARAMS;
} }
@ -581,7 +701,7 @@ private:
int xofs_, yofs_; int xofs_, yofs_;
int animframes_, animtype_, animspeed_; int animframes_, animtype_, animspeed_;
int tilenum_; int tilenum_;
string filename_; Bstring filename_;
public: public:
AddTileOp() AddTileOp()
: xofs_(0), yofs_(0), : xofs_(0), yofs_(0),
@ -589,24 +709,24 @@ public:
tilenum_(-1), filename_("") tilenum_(-1), filename_("")
{ } { }
virtual Result setOption(string opt, string value) virtual Result setOption(const Bstring &opt, const Bstring &value)
{ {
if (opt == "x") { if (opt == "x") {
xofs_ = atoi(value.c_str()); xofs_ = atoi(value());
} else if (opt == "y") { } else if (opt == "y") {
yofs_ = atoi(value.c_str()); yofs_ = atoi(value());
} else if (opt == "ann") { } else if (opt == "ann") {
animframes_ = atoi(value.c_str()); animframes_ = atoi(value());
if (animframes_ < 0 || animframes_ > 63) { if (animframes_ < 0 || animframes_ > 63) {
return ERR_BAD_VALUE; return ERR_BAD_VALUE;
} }
} else if (opt == "ant") { } else if (opt == "ant") {
animtype_ = atoi(value.c_str()); animtype_ = atoi(value());
if (animtype_ < 0 || animtype_ > 3) { if (animtype_ < 0 || animtype_ > 3) {
return ERR_BAD_VALUE; return ERR_BAD_VALUE;
} }
} else if (opt == "ans") { } else if (opt == "ans") {
animspeed_ = atoi(value.c_str()); animspeed_ = atoi(value());
if (animspeed_ < 0 || animspeed_ > 15) { if (animspeed_ < 0 || animspeed_ > 15) {
return ERR_BAD_VALUE; return ERR_BAD_VALUE;
} }
@ -616,11 +736,11 @@ public:
return ERR_NO_ERROR; return ERR_NO_ERROR;
} }
virtual Result setParameter(int number, string value) virtual Result setParameter(const int &number, const Bstring &value)
{ {
switch (number) { switch (number) {
case 0: case 0:
tilenum_ = atoi(value.c_str()); tilenum_ = atoi(value());
return ERR_NO_ERROR; return ERR_NO_ERROR;
case 1: case 1:
filename_ = value; filename_ = value;
@ -702,16 +822,16 @@ private:
public: public:
RmTileOp() : tilenum_(-1) { } 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; return ERR_BAD_OPTION;
} }
virtual Result setParameter(int number, string value) virtual Result setParameter(const int &number, const Bstring &value)
{ {
switch (number) { switch (number) {
case 0: case 0:
tilenum_ = atoi(value.c_str()); tilenum_ = atoi(value());
return ERR_NO_ERROR; return ERR_NO_ERROR;
default: default:
return ERR_TOO_MANY_PARAMS; return ERR_TOO_MANY_PARAMS;
@ -765,28 +885,28 @@ public:
tilenum_(-1), settings_(0) tilenum_(-1), settings_(0)
{ } { }
virtual Result setOption(string opt, string value) virtual Result setOption(const Bstring &opt, const Bstring &value)
{ {
if (opt == "x") { if (opt == "x") {
xofs_ = atoi(value.c_str()); xofs_ = atoi(value());
settings_ |= SET_XOFS; settings_ |= SET_XOFS;
} else if (opt == "y") { } else if (opt == "y") {
yofs_ = atoi(value.c_str()); yofs_ = atoi(value());
settings_ |= SET_YOFS; settings_ |= SET_YOFS;
} else if (opt == "ann") { } else if (opt == "ann") {
animframes_ = atoi(value.c_str()); animframes_ = atoi(value());
settings_ |= SET_ANIMFRAMES; settings_ |= SET_ANIMFRAMES;
if (animframes_ < 0 || animframes_ > 63) { if (animframes_ < 0 || animframes_ > 63) {
return ERR_BAD_VALUE; return ERR_BAD_VALUE;
} }
} else if (opt == "ant") { } else if (opt == "ant") {
animtype_ = atoi(value.c_str()); animtype_ = atoi(value());
settings_ |= SET_ANIMTYPE; settings_ |= SET_ANIMTYPE;
if (animtype_ < 0 || animtype_ > 3) { if (animtype_ < 0 || animtype_ > 3) {
return ERR_BAD_VALUE; return ERR_BAD_VALUE;
} }
} else if (opt == "ans") { } else if (opt == "ans") {
animspeed_ = atoi(value.c_str()); animspeed_ = atoi(value());
settings_ |= SET_ANIMSPEED; settings_ |= SET_ANIMSPEED;
if (animspeed_ < 0 || animspeed_ > 15) { if (animspeed_ < 0 || animspeed_ > 15) {
return ERR_BAD_VALUE; return ERR_BAD_VALUE;
@ -797,11 +917,11 @@ public:
return ERR_NO_ERROR; return ERR_NO_ERROR;
} }
virtual Result setParameter(int number, string value) virtual Result setParameter(const int &number, const Bstring &value)
{ {
switch (number) { switch (number) {
case 0: case 0:
tilenum_ = atoi(value.c_str()); tilenum_ = atoi(value());
return ERR_NO_ERROR; return ERR_NO_ERROR;
default: default:
return ERR_TOO_MANY_PARAMS; return ERR_TOO_MANY_PARAMS;
@ -860,8 +980,8 @@ int main(int argc, char ** argv)
if (argc < 2) { if (argc < 2) {
showusage = 1; showusage = 1;
} else { } else {
string opt(argv[1]); Bstring opt(argv[1]);
string value; Bstring value;
// create the option handler object according to the first param // create the option handler object according to the first param
if (opt == "create") { if (opt == "create") {
@ -879,15 +999,15 @@ int main(int argc, char ** argv)
// apply the command line options given // apply the command line options given
if (oper) { if (oper) {
int unnamedParm = 0; int unnamedParm = 0;
for (int i = 2; i < argc && !showusage; i++) { for (int i = 2; i < argc && !showusage; ++i) {
if (argv[i][0] == '-') { if (argv[i][0] == '-') {
opt = string(argv[i]).substr(1); opt = argv[i] + 1;
if (i+1 >= argc) { if (i+1 >= argc) {
showusage = 2; showusage = 2;
break; break;
} }
value = string(argv[i+1]); value = argv[i+1];
i++; ++i;
switch (err = oper->setOption(opt, value)) { switch (err = oper->setOption(opt, value)) {
case Operation::ERR_NO_ERROR: break; case Operation::ERR_NO_ERROR: break;
@ -897,7 +1017,7 @@ int main(int argc, char ** argv)
break; break;
} }
} else { } else {
value = string(argv[i]); value = argv[i];
switch (oper->setParameter(unnamedParm, value)) { switch (oper->setParameter(unnamedParm, value)) {
case Operation::ERR_NO_ERROR: break; case Operation::ERR_NO_ERROR: break;
default: default:
@ -905,7 +1025,7 @@ int main(int argc, char ** argv)
showusage = 2; showusage = 2;
break; break;
} }
unnamedParm++; ++unnamedParm;
} }
} }
} }

View file

@ -17,6 +17,7 @@
/* /*
NOTE: This program does not fall under BUILDLIC. NOTE: This program does not fall under BUILDLIC.
*/ */
// DOS 16-bit real mode UI --> portable command line conversion by Hendricks266
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

View file

@ -9,7 +9,9 @@
#include <stdint.h> #include <stdint.h>
#define Bmemcmp memcmp #define Bmemcmp memcmp
#define USE_OPENGL #ifndef USE_OPENGL
# define USE_OPENGL
#endif
#define ANIMVPX_STANDALONE #define ANIMVPX_STANDALONE
#include "animvpx.h" #include "animvpx.h"