diff options
| author | Alexander <alex@cogarr.net> | 2019-07-10 14:23:51 -0400 |
|---|---|---|
| committer | Alexander <alex@cogarr.net> | 2019-07-10 14:23:51 -0400 |
| commit | c9db55cdc2f69c3dc7aefabe0cc828a64e377024 (patch) | |
| tree | b6735e6b43660ea77f59654f8dd4ad1339b6f9e3 | |
| parent | 456ee9baefb343e98dc94678e05335a547786c2a (diff) | |
| parent | 6539fbff3d4ecd686676f7c0de6672de38023764 (diff) | |
| download | brokengine-c9db55cdc2f69c3dc7aefabe0cc828a64e377024.tar.gz brokengine-c9db55cdc2f69c3dc7aefabe0cc828a64e377024.tar.bz2 brokengine-c9db55cdc2f69c3dc7aefabe0cc828a64e377024.zip | |
Started work on cross-platform refactor
Started refactoring the code to work on windows and linux
| -rw-r--r-- | Makefile | 352 | ||||
| -rw-r--r-- | Makefile.nix | 53 | ||||
| -rw-r--r-- | Makefile.shared | 70 | ||||
| -rw-r--r-- | Makefile.win | 394 | ||||
| -rw-r--r-- | build/.gitignore | 1 | ||||
| -rw-r--r-- | build/client/.gitignore | 1 | ||||
| -rw-r--r-- | build/client/lua_api/io/.gitignore | 1 | ||||
| -rw-r--r-- | build/server/.gitignore | 1 | ||||
| -rw-r--r-- | build/shared/.gitignore (renamed from build/client/phys/.gitignore) | 0 | ||||
| -rw-r--r-- | build/shared/lua_api/.gitignore (renamed from build/client/util/.gitignore) | 0 | ||||
| -rw-r--r-- | build/shared/lua_api/phys/.gitignore (renamed from build/server/lua_api/phys/.gitignore) | 0 | ||||
| -rw-r--r-- | build/shared/phys/.gitignore (renamed from build/server/phys/.gitignore) | 0 | ||||
| -rw-r--r-- | build/shared/util/.gitignore (renamed from build/server/util/.gitignore) | 0 | ||||
| -rw-r--r-- | spec/test1_spec.lua | 11 | ||||
| -rw-r--r-- | spec/test3_spec.lua | 15 | ||||
| -rw-r--r-- | src/client/lua_api/gui/simple.cpp | 55 | ||||
| -rw-r--r-- | src/client/main.hpp | 2 | ||||
| -rw-r--r-- | src/server/main.hpp (renamed from src/client/lua_api/gui/simple.hpp) | 0 | ||||
| -rw-r--r-- | src/shared/lua_api/irr/cubenode.cpp | 6 | ||||
| -rw-r--r-- | src/shared/lua_api/irr/cubenode.hpp | 6 | ||||
| -rw-r--r-- | src/shared/lua_api/phys/bphysbuffer.cpp | 215 | ||||
| -rw-r--r-- | src/shared/lua_api/phys/bphysmodel.cpp | 4 |
22 files changed, 652 insertions, 535 deletions
@@ -6,357 +6,9 @@ else UNAME:=$(shell uname -s) endif -CP=cp -CXX?=g++ -MKDIR?=mkdir -RM?=rm -f -ECHO?=echo - ifeq ($(UNAME), Windows) - EXE_EXT=.exe - STA_LIB_EXT=.a - DYN_LIB_EXT=.dll - CMAKE_TYPE="MinGW Makefiles" - CMAKE_FLAGS=-G $(CMAKE_TYPE) -DCMAKE_SH="CMAKE_SH-NOTFOUND" +include Makefile.win endif - ifeq ($(UNAME), Linux) - EXE_EXT= - STA_LIB_EXT=.a - DYN_LIB_EXT=.so - CMAKE_TYPE="Unix Makefiles" - CMAKE_FLAGS= -G $(CMAKE_TYPE) +include Makefile.nix endif - -BIN_DIR=bin -BUILD_DIR=build -SRC_DIR=src -LIB_DIR=lib -DOC_DIR=doc - -CLIENTNAME=client -SERVERNAME=server -MASTERNAME=#masterserver -BINS= - -EX_PRE = brokengine_ -EX_PARTS = $(CLIENTNAME) $(SERVERNAME) $(MASTERNAME) - -NAMES = $(EX_PARTS:%=$(EX_PRE)%) -BINS+= $(foreach part,$(EX_PARTS),$(BIN_DIR)/$(part)/bin/$(EX_PRE)$(part)$(EXE_EXT)) -BUILDS = $(EX_PARTS:%=$(BUILD_DIR)/%) -SRC_DIRS = $(EX_PARTS:%=$(SRC_DIR)/%) - - -LLUADIR=$(LIB_DIR)/luajit -LIRRDIR=$(LIB_DIR)/irrlicht -LBULDIR=$(LIB_DIR)/bullet -LNNGDIR=$(LIB_DIR)/nng -LOBJDIR=$(LIB_DIR)/tinyobjloader-c - -#Include directories -ILUADIR=$(LLUADIR)/src -IIRRDIR=$(LIRRDIR)/include -IBULDIR=$(LBULDIR)/src -INNGDIR=$(LNNGDIR)/include -IOBJDIR=$(LOBJDIR)/ -ISHADIR=src -INCLUDE_PATHS=-I$(ILUADIR) -I$(IIRRDIR) -I$(IBULDIR) -I$(INNGDIR) -I$(ISHADIR) -I$(IOBJDIR) -#library directories - -CXXFLAGS+=$(INCLUDE_PATHS) - -CXXFLAGS+=-Llib - -#Libraries -#static libs -LIB_S_LUA=lib/libluajit.a -LIB_S_IRR=lib/libIrrlicht.a -LIB_S_BCO=lib/libBulletCollision.a -LIB_S_BDY=lib/libBulletDynamics.a -LIB_S_BLM=lib/libLinearMath.a -LIB_S_NNG=lib/libnng.a - -#dynamic libraries -LIB_D_LUA=lib/lua51$(DYN_LIB_EXT) -LIB_D_IRR=lib/Irrlicht$(DYN_LIB_EXT) -# Bullet cannot be built dynamically -LIB_D_BCO=$(LIB_S_BCO) -LIB_D_BDY=$(LIB_S_BDY) -LIB_D_BLM=$(LIB_S_BLM) -LIB_D_NNG=lib/libnng$(DYN_LIB_EXT) - -CLIENT_DLLS=Irrlicht libnng lua51 -SERVER_DLLS=libnng lua51 -ifeq ($(DEBUG),true) - LIB_OBJS = $(LIB_D_LUA) $(LIB_D_IRR) $(LIB_D_BCO) $(LIB_D_BDY) $(LIB_D_BLM) $(LIB_D_NNG) - BINS+=$(CLIENT_DLLS:%=$(BIN_DIR)/$(CLIENTNAME)/bin/%$(DYN_LIB_EXT)) $(SERVER_DLLS:%=$(BIN_DIR)/$(SERVERNAME)/bin/%$(DYN_LIB_EXT)) -else - LIB_OBJS = $(LIB_S_LUA) $(LIB_S_IRR) $(LIB_S_BCO) $(LIB_S_BDY) $(LIB_S_BLM) $(LIB_S_NNG) -endif - -# Libraries -#order matters! -CLIENT_LIBS=-lBulletDynamics -lBulletCollision -lLinearMath -lIrrlicht -lnng -SERVER_LIBS=-lBulletDynamics -lBulletCollision -lLinearMath -lnng -#LIBS=-lBulletDynamics -lBulletCollision -lLinearMath -lIrrlicht -lnng -ifeq ($(UNAME),Windows) - CLIENT_LIBS+=-lOpenGL32 -else - CLIENT_LIBS+=-lGL -endif -ifeq ($(DEBUG),true) - CLIENT_LIBS+=-llua51 - SERVER_LIBS+=-llua51 -else - CLIENT_LIBS+=-lluajit - SERVER_LIBS+=-lluajit -endif - -#can't compile with -std=c++11 because irrlicht will complain -#LDFLAGS+=$(LIBS) -ifeq ($(DEBUG), true) - -else - CXXFLAGS += -static $(INCLUDE_PATHS) -D_IRR_STATIC_LIB_ -DNNG_STATIC_LIB -endif -S_LDFLAGS= $(SERVER_LIBS) -C_LDFLAGS= $(CLIENT_LIBS) -ifeq ($(UNAME),Windows) - C_LDFLAGS += -mwindows -lwinmm -lstdc++ - ifeq ($(DEBUG),true) - - else - C_LDFLAGS += -lws2_32 -lmswsock -ladvapi32 - S_LDFLAGS += -lws2_32 -lmswsock -ladvapi32 - endif -endif - -ifeq ($(DEBUG),true) - ifeq ($(UNAME),Windows) - C_LDFLAGS+=-Wl,-subsystem,console - endif -endif - -ifeq ($(DEBUG),true) - CXXFLAGS+=-O0 -g -Wall -Werror -else - CXXFLAGS+=-O3 -endif - -FSYSTEM_FOLDERS = lua_api phys util lua_api/irr lua_api/phys lua_api/gui lua_api/scene lua_api/video -CLIENT_BUILD_FOLDERS = $(FSYSTEM_FOLDERS:%=$(BUILD_DIR)/$(CLIENTNAME)/%) - -all : $(BINS) - @echo "Done" - -# The shared stuff -LAPI_S_PHYS = bhingeconstraint bphysbox bphysmodel bphysgeneric bcharactercontroller bghostobject bcollider -LAPI_S_LOAD = load_phys load_net common stream load_common -LAPI_PATHS_T = $(LAPI_S_PHYS:%=lua_api/phys/%) $(LAPI_S_LOAD:%=lua_api/%) -SHARED_CLIENT_FILES = $(LAPI_PATHS_T) phys/physcommon util/hashmap util/tinyobj -SHARED_CLIENT_OBJS = $(SHARED_CLIENT_FILES:%=$(BUILD_DIR)/$(CLIENTNAME)/%.o) - -# The client-side only stuff -LAPI_C_GUI = iguibutton iguicheckbox iguielement iguiimage iguilabel iguiwindow iguieditbox iguicolorselector iguifiledialog iguispinbox iguitreeview iguicombobox -LAPI_C_PHYS = cbphysbox cbphysmodel cbcharactercontroller -LAPI_C_SCENE = icamera igeneric ilight imesh -LAPI_C_VIDEO = iimage itexture smaterial -LAPI_C_IO = ifilesystem -LAPI_LOAD = load_gui load_scene load_game load_cphys load_video load_io -LAPI_OBJS_T = $(LAPI_C_GUI:%=gui/%.o) $(LAPI_C_PHYS:%=phys/%.o) $(LAPI_C_SCENE:%=scene/%.o) $(LAPI_C_VIDEO:%=video/%.o) $(LAPI_C_IO:%=io/%.o) -LAPI_OBJS = $(LAPI_OBJS_T:%=$(BUILD_DIR)/$(CLIENTNAME)/lua_api/%) $(LAPI_LOAD:%=$(BUILD_DIR)/$(CLIENTNAME)/lua_api/%.o) -CLIENT_FILES = initdevice menuhandeler callbackhandeler -CLIENT_SRCS = $(CLIENT_FILES:%=$(BUILD_DIR)/$(CLIENTNAME)/%.o) $(LAPI_OBJS) -CLIENT_OBJS = $(BUILD_DIR)/$(CLIENTNAME)/main.o $(CLIENT_SRCS) $(SHARED_CLIENT_OBJS) - -#Compile the client -$(BIN_DIR)/$(CLIENTNAME)/bin/$(EX_PRE)$(CLIENTNAME)$(EXE_EXT) : $(CLIENT_OBJS) $(LIB_OBJS) - @echo "[CLIENT] Building binary $@" - @$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(C_LDFLAGS) $(LIB_OBJS) # -Wl,--verbose - -# does not have .hpp associated -$(BUILD_DIR)/$(CLIENTNAME)/main.o : $(SRC_DIR)/client/main.cpp - @$(CXX) $(CXXFLAGS) -c -o $@ $^ - -# does have the .hpp associated in src/client -$(CLIENT_SRCS) : $(BUILD_DIR)/$(CLIENTNAME)/%.o : src/client/%.cpp $(SRC_DIR)/client/%.hpp $(LIB_OBJS) - @echo "[CLIENT] CXX $<" - @$(CXX) $(CXXFLAGS) -c -o $@ $< - -# does have the .hpp associated in src/shared -$(SHARED_CLIENT_OBJS) : $(BUILD_DIR)/$(CLIENTNAME)/%.o : src/shared/%.cpp $(SRC_DIR)/shared/%.hpp - @echo "[CLIENT] CXX $<" - @$(CXX) $(CXXFLAGS) -c -o $@ $< - -#compile server -SERVER_FILES = lua_api/load_game lua_api/load_io -SERVER_OBJ=$(SERVER_FILES:%=$(BUILD_DIR)/$(SERVERNAME)/%.o) -SHARED_SERVER_FILES= $(LAPI_PATHS_T) util/hashmap phys/physcommon util/tinyobj -SHARED_SERVER_OBJS=$(SHARED_SERVER_FILES:%=$(BUILD_DIR)/$(SERVERNAME)/%.o) -SERVER_OBJS = $(SERVER_OBJ) $(SHARED_SERVER_OBJS) $(BUILD_DIR)/$(SERVERNAME)/main.o - -$(BIN_DIR)/$(SERVERNAME)/bin/$(EX_PRE)$(SERVERNAME)$(EXE_EXT) : $(SERVER_OBJS) $(LIB_OBJS) - @echo "[SERVER] Building binary $@" - @$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(S_LDFLAGS) - -# Special, main does not have a .hpp associated with it -$(BUILD_DIR)/$(SERVERNAME)/main.o : $(SRC_DIR)/server/main.cpp - @echo "[SERVER] CXX $<" - @$(CXX) $(CXXFLAGS) -c -o $@ $^ - -$(SHARED_SERVER_OBJS) : $(BUILD_DIR)/$(SERVERNAME)/%.o : $(SRC_DIR)/shared/%.cpp $(SRC_DIR)/shared/%.hpp - @echo "[SERVER] CXX $<" - @$(CXX) $(CXXFLAGS) -c -o $@ $< - -$(SERVER_OBJ) : $(BUILD_DIR)/$(SERVERNAME)/%.o : $(SRC_DIR)/server/%.cpp $(SRC_DIR)/server/%.hpp - @echo "[SERVER] CXX $<" - @$(CXX) $(CXXFLAGS) -c -o $@ $< - -#compile libraries -$(LIBLUA) : $(ILUADIR)/Makefile - @echo "Could not find $(LIBLUA), rebuilding" - cd $(ILUADIR) && $(MAKE) "BUILDMODE= static" - $(CP) $(ILUADIR)/libluajit.a lib - -IRRMAKEFLAGS= -IRRMADELIB= -ifeq ($(UNAME), Windows) - ifeq ($(DEBUG),true) - IRRMAKEFLAGS=sharedlib_win32 - IRRMADELIB=$(LIRRDIR)/bin/Win32-gcc - else - IRRMAKEFLAGS=staticlib_win32 - IRRMADELIB=$(LIRRDIR)/lib/Win32-gcc - endif -else - IRRMADELIB=$(LIRRDIR)/lib/Linux -endif - -ifeq ($(DEBUG),true) -else - IRRMAKEFLAGS+=NDEBUG=1 -endif - -# Library - Irrlicht -$(LIB_S_IRR) : $(IRRMADELIB)/libIrrlicht.a - $(CP) $^ $@ - -$(IRRMADELIB)/libIrrlicht.a : $(LIRRDIR)/source/Irrlicht/Makefile - sed --in-place=OLD 's/ -ld3dx9d//' lib/irrlicht/source/Irrlicht/Makefile - cd $(LIRRDIR)/source/Irrlicht && $(MAKE) $(IRRMAKEFLAGS) - -$(LIB_D_IRR) : $(IRRMADELIB)/Irrlicht$(DYN_LIB_EXT) - @echo "Could not find $@, remaking..." - $(CP) $^ $@ - -$(BIN_DIR)/$(CLIENTNAME)/bin/Irrlicht$(DYN_LIB_EXT) : $(IRRMADELIB)/Irrlicht$(DYN_LIB_EXT) - $(CP) $^ $@ - -$(IRRMADELIB)/Irrlicht$(DYN_LIB_EXT) : $(LIRRDIR)/source/Irrlicht/Makefile - sed --in-place=OLD 's/ -ld3dx9d//' lib/irrlicht/source/Irrlicht/Makefile - cd $(LIRRDIR)/source/Irrlicht && $(MAKE) $(IRRMAKEFLAGS) - -ifeq ($(UNAME),Windows) - LUAJIT_ARGS:= TARGET_SYS=Windows -else - LUAJIT_ARGS:= -endif - -# Library - Lua -# Client -$(BIN_DIR)/$(CLIENTNAME)/bin/lua51$(DYN_LIB_EXT) : $(LIB_D_LUA) - $(CP) $^ $@ - -# Server -$(BIN_DIR)/$(SERVERNAME)/bin/lua51$(DYN_LIB_EXT) : $(LIB_D_LUA) - $(CP) $^ $@ - -$(LLUADIR)/src/libluajit$(STA_LIB_EXT) : $(LLUADIR)/src/Makefile - cd $(LLUADIR)/src && $(MAKE) $(LUAJIT_ARGS) "BUILDMODE= static" - -$(LIB_S_LUA) : $(LLUADIR)/src/libluajit$(STA_LIB_EXT) - $(CP) $^ $@ - -$(LLUADIR)/src/lua51$(DYN_LIB_EXT) : $(LLUADIR)/src/Makefile - cd $(LLUADIR)/src && $(MAKE) $(LUAJIT_ARGS) "BUILDMODE= dynamic" - -$(LIB_D_LUA) : $(LLUADIR)/src/lua51$(DYN_LIB_EXT) - $(CP) $^ $@ - -# Library - Bullet -$(LBULDIR)/lib/libBulletCollision.a : $(LBULDIR)/Makefile - cd $(LBULDIR) && $(MAKE) BulletCollision - -$(LBULDIR)/lib/libBulletDynamics.a : $(LBULDIR)/Makefile - cd $(LBULDIR) && $(MAKE) BulletDynamics - -$(LBULDIR)/lib/libLinearMath.a : $(LBULDIR)/Makefile - cd $(LBULDIR) && $(MAKE) LinearMath - -$(LIB_D_BCO) : $(LBULDIR)/lib/libBulletCollision.a - $(CP) $^ $@ - -$(LIB_D_BDY) : $(LBULDIR)/lib/libBulletDynamics.a - $(CP) $^ $@ - -$(LIB_D_BLM) : $(LBULDIR)/lib/libLinearMath.a - $(CP) $^ $@ - -$(LBULDIR)/Makefile : $(LBULDIR)/CMakeLists.txt - cd $(LBULDIR) && cmake $(CMAKE_FLAGS) -DBUILD_EXTRAS=off -DBUILD_DEMOS=off - -# Library - NNG -NNGFLAGS= -$(BIN_DIR)/$(CLIENTNAME)/bin/libnng$(DYN_LIB_EXT) : $(LIB_D_NNG) - $(CP) $^ $@ - -$(BIN_DIR)/$(SERVERNAME)/bin/libnng$(DYN_LIB_EXT) : $(LIB_D_NNG) - $(CP) $^ $@ - -$(LNNGDIR)/dynamic/Makefile : $(LNNGDIR)/CMakeLists.txt - cd $(LNNGDIR)/dynamic && cmake $(CMAKE_FLAGS) -DBUILD_SHARED_LIBS="TRUE" ../ - -$(LIB_S_NNG) : $(LNNGDIR)/static/libnng$(STA_LIB_EXT) - $(CP) $< $@ - -$(LIB_D_NNG) : $(LNNGDIR)/dynamic/libnng$(DYN_LIB_EXT) - $(CP) $< $@ - -$(LNNGDIR)/static/libnng$(STA_LIB_EXT) : $(LNNGDIR)/static/Makefile - cd $(LNNGDIR)/static && $(MAKE) nng - ln -s $(LNNGDIR)/src $(LNNGDIR)/include/nng - -$(LNNGDIR)/dynamic/libnng$(DYN_LIB_EXT) : $(LNNGDIR)/dynamic/Makefile - cd $(LNNGDIR)/dynamic && $(MAKE) nng - ln -s $(LNNGDIR)/src $(LNNGDIR)/include/nng - -$(LNNGDIR)/Makefile : $(LNNGDIR)/CMakeLists.txt - @echo "LIB_OBJS were $(LIB_OBJS)" - cd $(LNNGDIR) && cmake $(CMAKE_FLAGS) $(NNGCMAKEFLAGS) - -TEST_BIN_NAMES=brokengine_client.exe Irrlicht.dll libnanomsg.dll libnng.dll lua51.dll -TEST_BINS=$(TEST_BIN_NAMES:%=test/bin/%) - -#compile & run tests -test: $(TEST_BINS) - @$(ECHO) "Running busted tests" - @./busted busted.spec - -$(TEST_BINS) : test/bin/% : bin/client/bin/% - $(CP) $^ $@ - -$(TEST_PATH)test_stream : $(TEST_SRC)test_streams.cpp $(SHARED_SRC)/lua_api/stream.cpp $(SHARED_SRC)/lua_api/stream.hpp - @$(CC) $(CFLAGS) -o $(TEST_PATH)test_stream $(TEST_SRC)test_streams.cpp $(SHARED_SRC)/lua_api/stream.cpp $(SHARED_SRC)/lua_api/stream.hpp - -$(TEST_PATH)test_phys : $(TEST_SRC)test_phys.cpp - $(CC) $(CFLAGS) -o $(TEST_PATH)test_phys $(TEST_SRC)test_phys.cpp $(SLIBS) -#end tests - -cleantest : - echo $(BUILDS:%=%/*.o) - -clean : - $(RM) $(CLIENT_OBJS) - $(RM) $(SERVER_OBJS) - $(RM) $(BINS) diff --git a/Makefile.nix b/Makefile.nix new file mode 100644 index 0000000..e70286d --- /dev/null +++ b/Makefile.nix @@ -0,0 +1,53 @@ + + +include Makefile.shared + +shared_objs=$(SHARED_SRC:src/shared/%=build/shared/%.o) +client_objs=$(CLIENT_SRC:src/client/%=build/client/%.o) +server_objs=$(SERVER_SRC:src/server/%=build/server/%.o) +client_bins=bin/client/bin/brokengine_client +server_bins=bin/server/bin/brokengine_server +bins=$(client_bins) $(server_bins) + +all: $(bins) + echo "Done" + +clean: + $(RM) $(client_objs) + $(RM) $(server_objs) + $(RM) $(shared_objs) + $(RM) $(bins) + +CLIENT_LIB_DIRS=\ + -Llib/luajit/src\ + -Llib/irrlicht/lib/Linux\ + -Llib/bullet/src/BulletCollision\ + -Llib/bullet/src/BulletDynamics\ + -Llib/bullet/src/LinearMath\ + -Llib/nng/static + +CLIENT_LIBS=\ + -lluajit\ + -lIrrlicht\ + -lGL\ + -lX11\ + -lXxf86vm\ + -lBulletDynamics\ + -lBulletCollision\ + -lLinearMath\ + -lnng\ + +bin/client/bin/brokengine_client : $(client_objs) $(shared_objs) + $(CXX) $(LDFLAGS) -o $@ $^ $(CLIENT_LIB_DIRS) $(CLIENT_LIBS) + +bin/server/bin/brokengine_server : $(server_objs) $(shared_objs) + $(CXX) $(LDFLAGS) -o $@ $^ $(CLIENT_LIB_DIRS) $(CLIENT_LIBS) + +$(shared_objs) : build/shared/%.o : src/shared/%.cpp src/shared/%.hpp + $(CXX) $(CFLAGS) -c -o $@ $< + +$(client_objs) : build/client/%.o : src/client/%.cpp src/client/%.hpp + $(CXX) $(CFLAGS) -c -o $@ $< + +$(server_objs) : build/server/%.o : src/server/%.cpp src/server/%.hpp + $(CXX) $(CFLAGS) -c -o $@ $< diff --git a/Makefile.shared b/Makefile.shared new file mode 100644 index 0000000..f2192b9 --- /dev/null +++ b/Makefile.shared @@ -0,0 +1,70 @@ + +SHARED_SRC=\ + src/shared/lua_api/common\ + src/shared/lua_api/load_common\ + src/shared/lua_api/load_net\ + src/shared/lua_api/load_phys\ + src/shared/lua_api/load_scene\ + src/shared/lua_api/stream\ + src/shared/lua_api/phys/bcharactercontroller\ + src/shared/lua_api/phys/bcollider\ + src/shared/lua_api/phys/bghostobject\ + src/shared/lua_api/phys/bhingeconstraint\ + src/shared/lua_api/phys/bphysbox\ + src/shared/lua_api/phys/bphysbuffer\ + src/shared/lua_api/phys/bphysgeneric\ + src/shared/lua_api/phys/bphysmodel\ + src/shared/phys/physcommon\ + src/shared/util/hashmap\ + src/shared/util/tinyobj + +CLIENT_SRC=\ + src/client/main\ + src/client/callbackhandeler\ + src/client/initdevice\ + src/client/menuhandeler\ + src/client/lua_api/load_cphys\ + src/client/lua_api/load_game\ + src/client/lua_api/load_gui\ + src/client/lua_api/load_io\ + src/client/lua_api/load_scene\ + src/client/lua_api/load_video\ + src/client/lua_api/gui/iguibutton\ + src/client/lua_api/gui/iguicheckbox\ + src/client/lua_api/gui/iguicolorselector\ + src/client/lua_api/gui/iguicombobox\ + src/client/lua_api/gui/iguieditbox\ + src/client/lua_api/gui/iguielement\ + src/client/lua_api/gui/iguifiledialog\ + src/client/lua_api/gui/iguiimage\ + src/client/lua_api/gui/iguilabel\ + src/client/lua_api/gui/iguispinbox\ + src/client/lua_api/gui/iguitreeview\ + src/client/lua_api/gui/iguiwindow\ + src/client/lua_api/io/ifilesystem\ + src/client/lua_api/phys/cbcharactercontroller\ + src/client/lua_api/phys/cbphysbox\ + src/client/lua_api/phys/cbphysmodel\ + src/client/lua_api/scene/icamera\ + src/client/lua_api/scene/igeneric\ + src/client/lua_api/scene/ilight\ + src/client/lua_api/scene/imesh\ + src/client/lua_api/video/iimage\ + src/client/lua_api/video/itexture\ + src/client/lua_api/video/smaterial + +SERVER_SRC=\ + src/server/main\ + src/server/lua_api/load_game\ + src/server/lua_api/load_io\ + +# Include paths +CFLAGS += -Ilib/luajit/src -Ilib/irrlicht/include -Isrc -Ilib/bullet/src -Ilib/tinyobjloader-c -Ilib/nng/include + +ifeq ($(DEBUG), true) + CFLAGS += -g -shared -Wall -Werror -fPIC + LDFLAGS += -shared +else + CFLAGS += -static + #LDFLAGS += -static +endif diff --git a/Makefile.win b/Makefile.win new file mode 100644 index 0000000..b4e8162 --- /dev/null +++ b/Makefile.win @@ -0,0 +1,394 @@ + +#Detect what kind of system we're on +ifeq ($(OS), Windows_NT) + UNAME:=Windows +else + UNAME:=$(shell uname -s) +endif + +CP=cp +CXX?=g++ +MKDIR?=mkdir +RM?=rm -f +ECHO?=echo + +ifeq ($(UNAME), Windows) + EXE_EXT=.exe + STA_LIB_EXT=.a + DYN_LIB_EXT=.dll + CMAKE_TYPE="MinGW Makefiles" + CMAKE_FLAGS=-G $(CMAKE_TYPE) -DCMAKE_SH="CMAKE_SH-NOTFOUND" +endif + +ifeq ($(UNAME), Linux) + EXE_EXT= + STA_LIB_EXT=.a + DYN_LIB_EXT=.so + CMAKE_TYPE="Unix Makefiles" + CMAKE_FLAGS= -G $(CMAKE_TYPE) +endif + +BIN_DIR=bin +BUILD_DIR=build +SRC_DIR=src +LIB_DIR=lib +DOC_DIR=doc + +CLIENTNAME=client +SERVERNAME=server +MASTERNAME=#masterserver +BINS= + +EX_PRE = brokengine_ +EX_PARTS = $(CLIENTNAME) $(SERVERNAME) $(MASTERNAME) + +NAMES = $(EX_PARTS:%=$(EX_PRE)%) +BINS+= $(foreach part,$(EX_PARTS),$(BIN_DIR)/$(part)/bin/$(EX_PRE)$(part)$(EXE_EXT)) +BUILDS = $(EX_PARTS:%=$(BUILD_DIR)/%) +SRC_DIRS = $(EX_PARTS:%=$(SRC_DIR)/%) + + +LLUADIR=$(LIB_DIR)/luajit +LIRRDIR=$(LIB_DIR)/irrlicht +LBULDIR=$(LIB_DIR)/bullet +LNNGDIR=$(LIB_DIR)/nng +LOBJDIR=$(LIB_DIR)/tinyobjloader-c + +#Include directories +ILUADIR=$(LLUADIR)/src +IIRRDIR=$(LIRRDIR)/include +IBULDIR=$(LBULDIR)/src +INNGDIR=$(LNNGDIR)/include +IOBJDIR=$(LOBJDIR)/ +ISHADIR=src +INCLUDE_PATHS=-I$(ILUADIR) -I$(IIRRDIR) -I$(IBULDIR) -I$(INNGDIR) -I$(ISHADIR) -I$(IOBJDIR) +#library directories + +CXXFLAGS+=$(INCLUDE_PATHS) + +CXXFLAGS+=-Llib + +#Library binary names +ifeq ($(UNAME),Windows) + LIB_N_LUA=lua51 + LIB_N_IRR=Irrlicht$(DYN_LIB_EXT) +endif +ifeq ($(UNAME),Linux) + LIB_N_LUA=libluajit + LIB_N_IRR=libIrrlicht$(DYN_LIB_EXT).1.8.4 #TODO: Automatically detect version +endif + +#Libraries +#static libs +LIB_S_LUA=$(LIB_DIR)/libluajit.a +LIB_S_IRR=$(LIB_DIR)/libIrrlicht.a +LIB_S_BCO=$(LIB_DIR)/libBulletCollision.a +LIB_S_BDY=$(LIB_DIR)/libBulletDynamics.a +LIB_S_BLM=$(LIB_DIR)/libLinearMath.a +LIB_S_NNG=$(LIB_DIR)/libnng.a + +#dynamic libraries +LIB_D_LUA=$(LIB_DIR)/$(LIB_N_LUA)$(DYN_LIB_EXT) +LIB_D_IRR=lib/$(LIB_N_IRR) +# Bullet cannot be built dynamically +LIB_D_BCO=$(LIB_S_BCO) +LIB_D_BDY=$(LIB_S_BDY) +LIB_D_BLM=$(LIB_S_BLM) +LIB_D_NNG=lib/libnng$(DYN_LIB_EXT) + +ifeq ($(UNAME),Windows) + CLIENT_DLLS=Irrlicht libnng lua51 + SERVER_DLLS=libnng lua51 +endif +ifeq ($(UNAME),Linux) + CLIENT_DLLS=Irrlicht libnng luajit + SERVER_DLLS=libnng luajit +endif +ifeq ($(DEBUG),true) + LIB_OBJS = $(LIB_D_LUA) $(LIB_D_IRR) $(LIB_D_BCO) $(LIB_D_BDY) $(LIB_D_BLM) $(LIB_D_NNG) + BINS+=$(CLIENT_DLLS:%=$(BIN_DIR)/$(CLIENTNAME)/bin/%$(DYN_LIB_EXT)) $(SERVER_DLLS:%=$(BIN_DIR)/$(SERVERNAME)/bin/%$(DYN_LIB_EXT)) +else + LIB_OBJS = $(LIB_S_LUA) $(LIB_S_IRR) $(LIB_S_BCO) $(LIB_S_BDY) $(LIB_S_BLM) $(LIB_S_NNG) +endif + +# Libraries +#order matters! +CLIENT_LIBS=-lBulletDynamics -lBulletCollision -lLinearMath -lIrrlicht -lnng +SERVER_LIBS=-lBulletDynamics -lBulletCollision -lLinearMath -lnng +#LIBS=-lBulletDynamics -lBulletCollision -lLinearMath -lIrrlicht -lnng +ifeq ($(UNAME),Windows) + CLIENT_LIBS+=-lOpenGL32 +else + CLIENT_LIBS+=-lGL +endif +ifeq ($(DEBUG),true) +ifeq ($(UNAME),Windows) + CLIENT_LIBS+=-llua51 + SERVER_LIBS+=-llua51 +endif +ifeq ($(UNAME),Linux) + CLIENT_LIBS+=-lluajit + SERVER_LIBS+=-lluajit +endif +else + CLIENT_LIBS+=-lluajit + SERVER_LIBS+=-lluajit +endif + +#can't compile with -std=c++11 because irrlicht will complain +#LDFLAGS+=$(LIBS) +ifeq ($(DEBUG), true) + +else + CXXFLAGS += -static $(INCLUDE_PATHS) -D_IRR_STATIC_LIB_ -DNNG_STATIC_LIB +endif +S_LDFLAGS= $(SERVER_LIBS) +C_LDFLAGS= $(CLIENT_LIBS) +ifeq ($(UNAME),Windows) + C_LDFLAGS += -mwindows -lwinmm -lstdc++ + ifeq ($(DEBUG),true) + + else + C_LDFLAGS += -lws2_32 -lmswsock -ladvapi32 + S_LDFLAGS += -lws2_32 -lmswsock -ladvapi32 + endif +endif + +ifeq ($(DEBUG),true) + ifeq ($(UNAME),Windows) + C_LDFLAGS+=-Wl,-subsystem,console + endif +endif + +ifeq ($(DEBUG),true) + CXXFLAGS+=-O0 -g -Wall -Werror +else + CXXFLAGS+=-O3 +endif + +FSYSTEM_FOLDERS = lua_api phys util lua_api/irr lua_api/phys lua_api/gui lua_api/scene lua_api/video +CLIENT_BUILD_FOLDERS = $(FSYSTEM_FOLDERS:%=$(BUILD_DIR)/$(CLIENTNAME)/%) + +all : $(BINS) + @echo "Done" + +# The shared stuff +LAPI_S_PHYS = bhingeconstraint bphysbox bphysmodel bphysgeneric bcharactercontroller bghostobject bcollider +LAPI_S_LOAD = load_phys load_net common stream load_common +LAPI_PATHS_T = $(LAPI_S_PHYS:%=lua_api/phys/%) $(LAPI_S_LOAD:%=lua_api/%) +SHARED_CLIENT_FILES = $(LAPI_PATHS_T) phys/physcommon util/hashmap util/tinyobj +SHARED_CLIENT_OBJS = $(SHARED_CLIENT_FILES:%=$(BUILD_DIR)/$(CLIENTNAME)/%.o) + +# The client-side only stuff +LAPI_C_GUI = iguibutton iguicheckbox iguielement iguiimage iguilabel iguiwindow iguieditbox iguicolorselector iguifiledialog iguispinbox iguitreeview iguicombobox +LAPI_C_PHYS = cbphysbox cbphysmodel cbcharactercontroller +LAPI_C_SCENE = icamera igeneric ilight imesh +LAPI_C_VIDEO = iimage itexture smaterial +LAPI_C_IO = ifilesystem +LAPI_LOAD = load_gui load_scene load_game load_cphys load_video load_io +LAPI_OBJS_T = $(LAPI_C_GUI:%=gui/%.o) $(LAPI_C_PHYS:%=phys/%.o) $(LAPI_C_SCENE:%=scene/%.o) $(LAPI_C_VIDEO:%=video/%.o) $(LAPI_C_IO:%=io/%.o) +LAPI_OBJS = $(LAPI_OBJS_T:%=$(BUILD_DIR)/$(CLIENTNAME)/lua_api/%) $(LAPI_LOAD:%=$(BUILD_DIR)/$(CLIENTNAME)/lua_api/%.o) +CLIENT_FILES = initdevice menuhandeler callbackhandeler +CLIENT_SRCS = $(CLIENT_FILES:%=$(BUILD_DIR)/$(CLIENTNAME)/%.o) $(LAPI_OBJS) +CLIENT_OBJS = $(BUILD_DIR)/$(CLIENTNAME)/main.o $(CLIENT_SRCS) $(SHARED_CLIENT_OBJS) + +#Compile the client +$(BIN_DIR)/$(CLIENTNAME)/bin/$(EX_PRE)$(CLIENTNAME)$(EXE_EXT) : $(CLIENT_OBJS) $(LIB_OBJS) + @echo "[CLIENT] Building binary $@" + $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(C_LDFLAGS) $(LIB_OBJS) # -Wl,--verbose + +# does not have .hpp associated +$(BUILD_DIR)/$(CLIENTNAME)/main.o : $(SRC_DIR)/client/main.cpp + @$(CXX) $(CXXFLAGS) -c -o $@ $^ + +# does have the .hpp associated in src/client +$(CLIENT_SRCS) : $(BUILD_DIR)/$(CLIENTNAME)/%.o : src/client/%.cpp $(SRC_DIR)/client/%.hpp $(LIB_OBJS) + @echo "[CLIENT] CXX $<" + @$(CXX) $(CXXFLAGS) -c -o $@ $< + +# does have the .hpp associated in src/shared +$(SHARED_CLIENT_OBJS) : $(BUILD_DIR)/$(CLIENTNAME)/%.o : src/shared/%.cpp $(SRC_DIR)/shared/%.hpp + @echo "[CLIENT] CXX $<" + @$(CXX) $(CXXFLAGS) -c -o $@ $< + +#compile server +SERVER_FILES = lua_api/load_game lua_api/load_io +SERVER_OBJ=$(SERVER_FILES:%=$(BUILD_DIR)/$(SERVERNAME)/%.o) +SHARED_SERVER_FILES= $(LAPI_PATHS_T) util/hashmap phys/physcommon util/tinyobj +SHARED_SERVER_OBJS=$(SHARED_SERVER_FILES:%=$(BUILD_DIR)/$(SERVERNAME)/%.o) +SERVER_OBJS = $(SERVER_OBJ) $(SHARED_SERVER_OBJS) $(BUILD_DIR)/$(SERVERNAME)/main.o + +$(BIN_DIR)/$(SERVERNAME)/bin/$(EX_PRE)$(SERVERNAME)$(EXE_EXT) : $(SERVER_OBJS) $(LIB_OBJS) + @echo "[SERVER] Building binary $@" + @$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(S_LDFLAGS) + +# Special, main does not have a .hpp associated with it +$(BUILD_DIR)/$(SERVERNAME)/main.o : $(SRC_DIR)/server/main.cpp + @echo "[SERVER] CXX $<" + @$(CXX) $(CXXFLAGS) -c -o $@ $^ + +$(SHARED_SERVER_OBJS) : $(BUILD_DIR)/$(SERVERNAME)/%.o : $(SRC_DIR)/shared/%.cpp $(SRC_DIR)/shared/%.hpp + @echo "[SERVER] CXX $<" + @$(CXX) $(CXXFLAGS) -c -o $@ $< + +$(SERVER_OBJ) : $(BUILD_DIR)/$(SERVERNAME)/%.o : $(SRC_DIR)/server/%.cpp $(SRC_DIR)/server/%.hpp + @echo "[SERVER] CXX $<" + @$(CXX) $(CXXFLAGS) -c -o $@ $< + +#compile libraries +$(LIBLUA) : $(ILUADIR)/Makefile + @echo "Could not find $(LIBLUA), rebuilding" + cd $(ILUADIR) && $(MAKE) "BUILDMODE= static" + $(CP) $(ILUADIR)/libluajit.a lib + +IRRMAKEFLAGS= +IRRMADELIB= +ifeq ($(UNAME), Windows) + ifeq ($(DEBUG),true) + IRRMAKEFLAGS=sharedlib_win32 + IRRMADELIB=$(LIRRDIR)/bin/Win32-gcc + else + IRRMAKEFLAGS=staticlib_win32 + IRRMADELIB=$(LIRRDIR)/lib/Win32-gcc + endif +else + IRRMADELIB=$(LIRRDIR)/lib/Linux +endif + +ifeq ($(DEBUG),true) +else + IRRMAKEFLAGS+=NDEBUG=1 +endif + +# Library - Irrlicht +$(LIB_S_IRR) : $(IRRMADELIB)/libIrrlicht.a + $(CP) $^ $@ + +$(IRRMADELIB)/libIrrlicht.a : $(LIRRDIR)/source/Irrlicht/Makefile + sed --in-place=OLD 's/ -ld3dx9d//' lib/irrlicht/source/Irrlicht/Makefile + cd $(LIRRDIR)/source/Irrlicht && $(MAKE) $(IRRMAKEFLAGS) + +$(LIB_D_IRR) : $(IRRMADELIB)/$(LIB_N_IRR) + @echo "Could not find $@, remaking..." + $(CP) $^ $@ + +$(BIN_DIR)/$(CLIENTNAME)/bin/Irrlicht$(DYN_LIB_EXT) : $(IRRMADELIB)/$(LIB_N_IRR) + $(CP) $^ $@* + +$(IRRMADELIB)/$(LIB_N_IRR) : $(LIRRDIR)/source/Irrlicht/Makefile + sed --in-place=OLD 's/ -ld3dx9d//' lib/irrlicht/source/Irrlicht/Makefile + cd $(LIRRDIR)/source/Irrlicht && $(MAKE) $(IRRMAKEFLAGS) + +ifeq ($(UNAME),Windows) + LUAJIT_ARGS:= TARGET_SYS=Windows +else + #LUAJIT_ARGS= +endif + +# Library - Lua +$(BIN_DIR)/$(CLIENTNAME)/bin/$(LIB_N_LUA)$(DYN_LIB_EXT) : $(LIB_D_LUA) + $(CP) $^ $@ + +$(BIN_DIR)/$(SERVERNAME)/bin/$(LIB_N_LUA)$(DYN_LIB_EXT) : $(LIB_D_LUA) + $(CP) $^ $@ + +$(LLUADIR)/src/libluajit$(STA_LIB_EXT) : $(LLUADIR)/src/Makefile + cd $(LLUADIR)/src && $(MAKE) $(LUAJIT_ARGS) "BUILDMODE= static" + +$(LIB_S_LUA) : $(LLUADIR)/src/libluajit$(STA_LIB_EXT) + $(CP) $^ $@ + +$(LLUADIR)/src/lua51$(DYN_LIB_EXT) : $(LLUADIR)/src/Makefile + cd $(LLUADIR)/src && $(MAKE) $(LUAJIT_ARGS) "BUILDMODE= dynamic" + +$(LIB_D_LUA) : $(LLUADIR)/src/$(LIB_N_LUA)$(DYN_LIB_EXT) + $(CP) $^ $@ + +# Library - Bullet +$(LBULDIR)/lib/libBulletCollision.a : $(LBULDIR)/Makefile + cd $(LBULDIR) && $(MAKE) BulletCollision + +$(LBULDIR)/lib/libBulletDynamics.a : $(LBULDIR)/Makefile + cd $(LBULDIR) && $(MAKE) BulletDynamics + +$(LBULDIR)/lib/libLinearMath.a : $(LBULDIR)/Makefile + cd $(LBULDIR) && $(MAKE) LinearMath + +ifeq ($(UNAME),Windows) +$(LIB_D_BCO) : $(LBULDIR)/lib/libBulletCollision.a + $(CP) $^ $@ + +$(LIB_D_BDY) : $(LBULDIR)/lib/libBulletDynamics.a + $(CP) $^ $@ + +$(LIB_D_BLM) : $(LBULDIR)/lib/libLinearMath.a + $(CP) $^ $@ +endif +ifeq ($(UNAME),Linux) +$(LIB_D_BCO) : $(LBULDIR)/src/BulletCollision/libBulletCollision.a + $(CP) $^ $@ + +$(LIB_D_BDY) : $(LBULDIR)/src/BulletDynamics/libBulletDynamics.a + $(CP) $^ $@ + +$(LIB_D_BLM) : $(LBULDIR)/src/LinearMath/libLinearMath.a + $(CP) $^ $@ +endif + +$(LBULDIR)/Makefile : $(LBULDIR)/CMakeLists.txt + cd $(LBULDIR) && cmake $(CMAKE_FLAGS) -DBUILD_EXTRAS=off -DBUILD_DEMOS=off + +# Library - NNG +NNGFLAGS= +$(BIN_DIR)/$(CLIENTNAME)/bin/libnng$(DYN_LIB_EXT) : $(LIB_D_NNG) + $(CP) $^ $@ + +$(BIN_DIR)/$(SERVERNAME)/bin/libnng$(DYN_LIB_EXT) : $(LIB_D_NNG) + $(CP) $^ $@ + +$(LNNGDIR)/dynamic/Makefile : $(LNNGDIR)/CMakeLists.txt + cd $(LNNGDIR)/dynamic && cmake $(CMAKE_FLAGS) -DBUILD_SHARED_LIBS="TRUE" ../ + +$(LIB_S_NNG) : $(LNNGDIR)/static/libnng$(STA_LIB_EXT) + $(CP) $< $@ + +$(LIB_D_NNG) : $(LNNGDIR)/dynamic/libnng$(DYN_LIB_EXT) + $(CP) $< $@ + +$(LNNGDIR)/static/libnng$(STA_LIB_EXT) : $(LNNGDIR)/static/Makefile + cd $(LNNGDIR)/static && $(MAKE) nng + ln -s $(LNNGDIR)/src $(LNNGDIR)/include/nng + +$(LNNGDIR)/dynamic/libnng$(DYN_LIB_EXT) : $(LNNGDIR)/dynamic/Makefile + cd $(LNNGDIR)/dynamic && $(MAKE) nng + ln -s $(LNNGDIR)/src $(LNNGDIR)/include/nng + +$(LNNGDIR)/Makefile : $(LNNGDIR)/CMakeLists.txt + @echo "LIB_OBJS were $(LIB_OBJS)" + cd $(LNNGDIR) && cmake $(CMAKE_FLAGS) $(NNGCMAKEFLAGS) + +TEST_BIN_NAMES=brokengine_client.exe Irrlicht.dll libnanomsg.dll libnng.dll lua51.dll +TEST_BINS=$(TEST_BIN_NAMES:%=test/bin/%) + +#compile & run tests +test: $(TEST_BINS) + @$(ECHO) "Running busted tests" + @./busted busted.spec + +$(TEST_BINS) : test/bin/% : bin/client/bin/% + $(CP) $^ $@ + +$(TEST_PATH)test_stream : $(TEST_SRC)test_streams.cpp $(SHARED_SRC)/lua_api/stream.cpp $(SHARED_SRC)/lua_api/stream.hpp + @$(CC) $(CFLAGS) -o $(TEST_PATH)test_stream $(TEST_SRC)test_streams.cpp $(SHARED_SRC)/lua_api/stream.cpp $(SHARED_SRC)/lua_api/stream.hpp + +$(TEST_PATH)test_phys : $(TEST_SRC)test_phys.cpp + $(CC) $(CFLAGS) -o $(TEST_PATH)test_phys $(TEST_SRC)test_phys.cpp $(SLIBS) +#end tests + +cleantest : + echo $(BUILDS:%=%/*.o) + +clean : + $(RM) $(CLIENT_OBJS) + $(RM) $(SERVER_OBJS) + $(RM) $(BINS) diff --git a/build/.gitignore b/build/.gitignore index e69de29..5761abc 100644 --- a/build/.gitignore +++ b/build/.gitignore @@ -0,0 +1 @@ +*.o diff --git a/build/client/.gitignore b/build/client/.gitignore index 5761abc..e69de29 100644 --- a/build/client/.gitignore +++ b/build/client/.gitignore @@ -1 +0,0 @@ -*.o diff --git a/build/client/lua_api/io/.gitignore b/build/client/lua_api/io/.gitignore index 5761abc..e69de29 100644 --- a/build/client/lua_api/io/.gitignore +++ b/build/client/lua_api/io/.gitignore @@ -1 +0,0 @@ -*.o diff --git a/build/server/.gitignore b/build/server/.gitignore index 5761abc..e69de29 100644 --- a/build/server/.gitignore +++ b/build/server/.gitignore @@ -1 +0,0 @@ -*.o diff --git a/build/client/phys/.gitignore b/build/shared/.gitignore index e69de29..e69de29 100644 --- a/build/client/phys/.gitignore +++ b/build/shared/.gitignore diff --git a/build/client/util/.gitignore b/build/shared/lua_api/.gitignore index e69de29..e69de29 100644 --- a/build/client/util/.gitignore +++ b/build/shared/lua_api/.gitignore diff --git a/build/server/lua_api/phys/.gitignore b/build/shared/lua_api/phys/.gitignore index e69de29..e69de29 100644 --- a/build/server/lua_api/phys/.gitignore +++ b/build/shared/lua_api/phys/.gitignore diff --git a/build/server/phys/.gitignore b/build/shared/phys/.gitignore index e69de29..e69de29 100644 --- a/build/server/phys/.gitignore +++ b/build/shared/phys/.gitignore diff --git a/build/server/util/.gitignore b/build/shared/util/.gitignore index e69de29..e69de29 100644 --- a/build/server/util/.gitignore +++ b/build/shared/util/.gitignore diff --git a/spec/test1_spec.lua b/spec/test1_spec.lua index 81df8f0..147abbd 100644 --- a/spec/test1_spec.lua +++ b/spec/test1_spec.lua @@ -21,15 +21,22 @@ return { ]=]) f:close() +local game_bin = nil +if package.config:sub(1,1) == "/" then -- linux or osx + game_bin = "bin/client/bin/brokengine_client" +else + game_bin = "bin\\client\\bin\\brokengine_client.exe" +end + function rungame() - f = io.popen("bin\\client\\bin\\brokengine_client.exe spec/headless","r") + f = io.popen(game_bin .. " spec/headless","r") d = f:read("*all") f:close() return d end function writegame(...) - f = io.open("spec/headless/init.lua","w") + f = assert(io.open("spec/headless/init.lua","w")) data = {"GAME.crashy()"} for _,v in pairs({...}) do data[#data + 1] = v diff --git a/spec/test3_spec.lua b/spec/test3_spec.lua index e19741d..8861b0c 100644 --- a/spec/test3_spec.lua +++ b/spec/test3_spec.lua @@ -1,6 +1,15 @@ +local game_bin = nil +if package.config:sub(1,1) == "/" then -- linux or osx + game_bin = "bin/client/bin/brokengine_client" + server_bin = "bin/server/bin/brokengine_server" +else + game_bin = "bin\\client\\bin\\brokengine_client.exe" + server_bin = "bin\\server\\bin\\brokengine_server.exe" +end + function rungame() - f = io.popen("bin\\client\\bin\\brokengine_client.exe spec/headless","r") + f = io.popen(game_bin .. " spec/headless","r") d = f:read("*all") f:close() return d @@ -10,8 +19,8 @@ function runboth() --print("Running both") --Do we have a race condition here? (Can client start and send it's message --before the server is ready to accept? - f1 = io.popen("bin\\server\\bin\\brokengine_server.exe spec/server","r") - f2 = io.popen("bin\\client\\bin\\brokengine_client.exe spec/headless","r") + f1 = io.popen(server_bin .. " spec/server","r") + f2 = io.popen(game_bin .. " spec/headless","r") --print("Both ran...") d1 = f1:read("*all") d2 = f2:read("*all") diff --git a/src/client/lua_api/gui/simple.cpp b/src/client/lua_api/gui/simple.cpp deleted file mode 100644 index 130240c..0000000 --- a/src/client/lua_api/gui/simple.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include <irrlicht.h>
-extern "C" {
- #include <lua.h>
- #include <lauxlib.h>
- #include <lualib.h>
-}
-
-// {{startx, starty},{endx,endy}}
-lua_torecti(lua_State* L, int number, int* sx, int* sy, int* ex, int* ey){
- lua_pushnumber(L,1);// ...,{},...,1
- lua_gettable(L,number);// ...,{{sx,sy},{ex,ey}},...,{sx,sy}
-
- lua_pushnumber(L,1);// ...,{{sx,sy},{ex,ey}},...,{sx,sy},1
- lua_gettable(L,-2);// ...,{{sx,sy},{ex,ey}},...,{sx,sy},sx
- *sx = lua_tonumber(L,-1);// ...,{{sx,sy},{ex,ey}},...,{sx,sy},sx
-
- lua_pop(1);// ...,{{sx,sy},{ex,ey}},...,{sx,sy}
-
- lua_pushnumber(L,2);// ...,{{sx,sy},{ex,ey}},...,{sx,sy},2
- lua_gettable(L,-2);// ...,{{sx,sy},{ex,ey}},...,{sx,sy},sy
- *sy = lua_tonumber(L,-1);
-
- lua_pop(2);// ...,{{sx,sy},{ex,ey}},...
-
-
- lua_pushnumber(L,2);// ...,{{sx,sy},{ex,ey}},...,2
- lua_gettable(L,number);// ...,{{sx,sy},{ex,ey}},...,{ex,ey}
- lua_pushnumber(L,1);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},1
-
- lua_gettable(L,-2);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},ex
- *ex = lua_tonumber(L,-1);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},ex
- lua_pop(L,1);// ...,{{sx,sy},{ex,ey}},...,{ex,ey}
-
- lua_pushnumber(L,2);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},2
- lua_gettable(L,-2);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},ey
- *ey = lua_tonumber(L,-1);// ...,{{sx,sy},{ex,ey}},...,{ex,ey},ey
-
- lua_pop(L,2);// ...,{{sx,sy},{ex,ey}},...
-}
-
-int addIGUIButton(lua_State* L){
- IGUIEnvironment env = lua_touserdata(L,1);
- IGUIElement parent = lua_touserdata(L,2);
- s32 id = lua_tonumber(L,3);
- s32 sx,sy,ex,ey;
- lua_torecti(L,4,&sx,&sy,&ex,&ey);
- core::rect<s32> rect = core::rect<s32>(sx,sy,ex,ey);
- IGUIElement* button = env->addButton(rect,parent,id,
-
-}
-
-void add_gui(lua_State* L){
-
-}
-blah
diff --git a/src/client/main.hpp b/src/client/main.hpp new file mode 100644 index 0000000..c94fc6e --- /dev/null +++ b/src/client/main.hpp @@ -0,0 +1,2 @@ + +int main(int argc, char *argv[]); diff --git a/src/client/lua_api/gui/simple.hpp b/src/server/main.hpp index e69de29..e69de29 100644 --- a/src/client/lua_api/gui/simple.hpp +++ b/src/server/main.hpp diff --git a/src/shared/lua_api/irr/cubenode.cpp b/src/shared/lua_api/irr/cubenode.cpp deleted file mode 100644 index d7e87bb..0000000 --- a/src/shared/lua_api/irr/cubenode.cpp +++ /dev/null @@ -1,6 +0,0 @@ - -extern "C" { - #include <lua.h> - #include <lauxlib.h> - #include <lualib.h> -} diff --git a/src/shared/lua_api/irr/cubenode.hpp b/src/shared/lua_api/irr/cubenode.hpp deleted file mode 100644 index d7e87bb..0000000 --- a/src/shared/lua_api/irr/cubenode.hpp +++ /dev/null @@ -1,6 +0,0 @@ - -extern "C" { - #include <lua.h> - #include <lauxlib.h> - #include <lualib.h> -} diff --git a/src/shared/lua_api/phys/bphysbuffer.cpp b/src/shared/lua_api/phys/bphysbuffer.cpp index f1f20c0..111b159 100644 --- a/src/shared/lua_api/phys/bphysbuffer.cpp +++ b/src/shared/lua_api/phys/bphysbuffer.cpp @@ -15,7 +15,6 @@ extern "C" { #include <client/lua_api/gameparts.hpp> #include <shared/lua_api/phys/bphysbox.hpp> #include "bphysmodel.hpp" -#include "../scene/igeneric.hpp" #include <shared/lua_api/common.hpp> using namespace irr; @@ -23,7 +22,7 @@ using namespace scene; using namespace core; using namespace video; -extern IrrlichtDevice* device; +//extern IrrlichtDevice* device; extern btDiscreteDynamicsWorld* World; extern core::list<btRigidBody*> Objects; @@ -36,137 +35,137 @@ static LBPhysNode* checkisbphysmodel(lua_State* L, int index){ //iscenecamera.new(Vector position, Vector lookat, parrent) // {} {} 0 1 -static int newbphysmodel(lua_State* L){ - printf("Createing bphysbox!\n"); - int nargs = lua_gettop(L); - if(nargs != 3){ - printf("Incorrect # of args to create a physmodel!"); - } - //The model for the mesh - //const char* modelpath = luaL_optstring(L,1,"error"); - - double x,y,z; - popvector3d(L,&x,&y,&z); - printf("Found position for phys model: %f %f %f\n",x,y,z); +//static int newbphysmodel(lua_State* L){ + //printf("Createing bphysbox!\n"); + //int nargs = lua_gettop(L); + //if(nargs != 3){ + //printf("Incorrect # of args to create a physmodel!"); + //} + ////The model for the mesh + ////const char* modelpath = luaL_optstring(L,1,"error"); + + //double x,y,z; + //popvector3d(L,&x,&y,&z); + //printf("Found position for phys model: %f %f %f\n",x,y,z); - //Find the vector scale - double sx,sy,sz; - popvector3d(L,&sx,&sy,&sz); - printf("Found scale for phys model: %f %f %f\n",sx,sy,sz); + ////Find the vector scale + //double sx,sy,sz; + //popvector3d(L,&sx,&sy,&sz); + //printf("Found scale for phys model: %f %f %f\n",sx,sy,sz); - //find the model path - const char* mpath = luaL_optstring(L,3,"error.obj"); + ////find the model path + //const char* mpath = luaL_optstring(L,3,"error.obj"); - printf("I want to use model %s\n", mpath); + //printf("I want to use model %s\n", mpath); - ISceneManager* smgr = device->getSceneManager(); - IMesh* amesh = smgr->getMesh(mpath); - IMeshBuffer* bf = amesh->getMeshBuffer(0); - u32 ni = bf->getIndexCount(); - - btTriangleMesh* trimesh = new btTriangleMesh(); - for(u32 i = 0; i < ni; i+=3){ - vector3df p1 = bf->getPosition(i + 0); - vector3df p2 = bf->getPosition(i + 1); - vector3df p3 = bf->getPosition(i + 2); - btVector3 b1 = btVector3(p1.X,p1.Y,p1.Z); - btVector3 b2 = btVector3(p2.X,p2.Y,p2.Z); - btVector3 b3 = btVector3(p3.X,p3.Y,p3.Z); - trimesh->addTriangle(b1,b2,b3); - } - btCollisionShape* shape = new btConvexTriangleMeshShape(trimesh,true); - core::vector3df scale = core::vector3df(sx,sy,sz); - btVector3 pos = btVector3(x,y,z); - core::vector3df ipos = core::vector3df(x,y,z); - shape->setLocalScaling(btVector3(sx,sy,sz)); - //Find the mass - float mass = luaL_optint(L,4,0); - printf("Found mass for physbox:%f\n",mass); + //ISceneManager* smgr = device->getSceneManager(); + //IMesh* amesh = smgr->getMesh(mpath); + //IMeshBuffer* bf = amesh->getMeshBuffer(0); + //u32 ni = bf->getIndexCount(); + + //btTriangleMesh* trimesh = new btTriangleMesh(); + //for(u32 i = 0; i < ni; i+=3){ + //vector3df p1 = bf->getPosition(i + 0); + //vector3df p2 = bf->getPosition(i + 1); + //vector3df p3 = bf->getPosition(i + 2); + //btVector3 b1 = btVector3(p1.X,p1.Y,p1.Z); + //btVector3 b2 = btVector3(p2.X,p2.Y,p2.Z); + //btVector3 b3 = btVector3(p3.X,p3.Y,p3.Z); + //trimesh->addTriangle(b1,b2,b3); + //} + //btCollisionShape* shape = new btConvexTriangleMeshShape(trimesh,true); + //core::vector3df scale = core::vector3df(sx,sy,sz); + //btVector3 pos = btVector3(x,y,z); + //core::vector3df ipos = core::vector3df(x,y,z); + //shape->setLocalScaling(btVector3(sx,sy,sz)); + ////Find the mass + //float mass = luaL_optint(L,4,0); + //printf("Found mass for physbox:%f\n",mass); - // Create an Irrlicht cube - scene::ISceneNode* Node = smgr->addMeshSceneNode( - amesh, - (ISceneNode*)0, - (s32)-1, - ipos, - vector3df(0,0,0), - scale - ); - //Node->setScale(scale); + //// Create an Irrlicht cube + //scene::ISceneNode* Node = smgr->addMeshSceneNode( + //amesh, + //(ISceneNode*)0, + //(s32)-1, + //ipos, + //vector3df(0,0,0), + //scale + //); + ////Node->setScale(scale); - printf("Added cube scene node and set it's scale\n"); + //printf("Added cube scene node and set it's scale\n"); - //Node->setMaterialFlag(video::EMF_WIREFRAME,true) - //Node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true); - Node->setMaterialFlag(video::EMF_LIGHTING,true); - //Node->setMaterialTexture(0, device->getVideoDriver()->getTexture("../data/wall.jpg")); + ////Node->setMaterialFlag(video::EMF_WIREFRAME,true) + ////Node->setMaterialFlag(video::EMF_NORMALIZE_NORMALS, true); + //Node->setMaterialFlag(video::EMF_LIGHTING,true); + ////Node->setMaterialTexture(0, device->getVideoDriver()->getTexture("../data/wall.jpg")); - printf("Set node's lighting stuff...\n"); + //printf("Set node's lighting stuff...\n"); - // Set the initial position of the object - btTransform Transform; - Transform.setIdentity(); - Transform.setOrigin(pos); + //// Set the initial position of the object + //btTransform Transform; + //Transform.setIdentity(); + //Transform.setOrigin(pos); - printf("Created transform at pos...\n"); + //printf("Created transform at pos...\n"); - // Give it a default MotionState - btDefaultMotionState *MotionState = new btDefaultMotionState(Transform); + //// Give it a default MotionState + //btDefaultMotionState *MotionState = new btDefaultMotionState(Transform); - // Create the shape - // btVector3 HalfExtents(sx * 0.5f, sy * 0.5f, sz * 0.5f); - // btCollisionShape *Shape = new btBoxShape(HalfExtents); + //// Create the shape + //// btVector3 HalfExtents(sx * 0.5f, sy * 0.5f, sz * 0.5f); + //// btCollisionShape *Shape = new btBoxShape(HalfExtents); - printf("Created collision shape..."); + //printf("Created collision shape..."); - // Add mass - btVector3 LocalInertia; - shape->calculateLocalInertia(mass, LocalInertia); + //// Add mass + //btVector3 LocalInertia; + //shape->calculateLocalInertia(mass, LocalInertia); - // Create the rigid body object - btRigidBody *RigidBody = new btRigidBody(mass, MotionState, shape, LocalInertia); + //// Create the rigid body object + //btRigidBody *RigidBody = new btRigidBody(mass, MotionState, shape, LocalInertia); - printf("Created rigidboxy..."); + //printf("Created rigidboxy..."); - // Store a pointer to the irrlicht node so we can update it later - RigidBody->setUserPointer((void *)(Node)); + //// Store a pointer to the irrlicht node so we can update it later + //RigidBody->setUserPointer((void *)(Node)); - printf("Set user pointer"); + //printf("Set user pointer"); - // Add it to the world - World->addRigidBody(RigidBody); - printf("Added to world"); - Objects.push_back(RigidBody); + //// Add it to the world + //World->addRigidBody(RigidBody); + //printf("Added to world"); + //Objects.push_back(RigidBody); - //Register it's callback - printf("Everything created, makeing the lua representation\n"); + ////Register it's callback + //printf("Everything created, makeing the lua representation\n"); - //Create it's lua representation - LBPhysNode* pnode = (LBPhysNode*)lua_newuserdata(L, sizeof(LBPhysNode)); - int tref = luaL_ref(L,LUA_REGISTRYINDEX); - //iguielements[lcam] = tref; - lua_rawgeti(L,LUA_REGISTRYINDEX,tref);//Put it back on the stack since luaL_ref pops the object. + ////Create it's lua representation + //LBPhysNode* pnode = (LBPhysNode*)lua_newuserdata(L, sizeof(LBPhysNode)); + //int tref = luaL_ref(L,LUA_REGISTRYINDEX); + ////iguielements[lcam] = tref; + //lua_rawgeti(L,LUA_REGISTRYINDEX,tref);//Put it back on the stack since luaL_ref pops the object. - //Set it's metatable - luaL_getmetatable(L, "phys.physmodel"); - lua_setmetatable(L, -2); + ////Set it's metatable + //luaL_getmetatable(L, "phys.physmodel"); + //lua_setmetatable(L, -2); - //Create the struct - pnode->n = Node; - pnode->r = RigidBody; - pnode->funcmap = hashmap_new(); - pnode->type = "bphysbox"; + ////Create the struct + //pnode->n = Node; + //pnode->r = RigidBody; + //pnode->funcmap = hashmap_new(); + //pnode->type = "bphysbox"; - printf("Done createing lua representation!\n"); - //Free up anything made in this function - //free(label); + //printf("Done createing lua representation!\n"); + ////Free up anything made in this function + ////free(label); - //Put it on top and return it - lua_rawgeti(L,LUA_REGISTRYINDEX,tref); - return 1; -} + ////Put it on top and return it + //lua_rawgeti(L,LUA_REGISTRYINDEX,tref); + //return 1; +//} static const luaL_reg bphysbuffer_f[] = { @@ -185,9 +184,9 @@ static const luaL_reg bphysbuffer_m[] = { {0, 0}, }; -void bphysbuffer_register(lua_State* L, IrrlichtDevice* d){ +void bphysbuffer_register(lua_State* L){ - device = d; + //device = d; luaL_newmetatable(L, "phys.physbuffer");//{m_physbuffer} lua_newtable(L);//{m_physbuffer},{} diff --git a/src/shared/lua_api/phys/bphysmodel.cpp b/src/shared/lua_api/phys/bphysmodel.cpp index a89a28f..0cff0ed 100644 --- a/src/shared/lua_api/phys/bphysmodel.cpp +++ b/src/shared/lua_api/phys/bphysmodel.cpp @@ -66,8 +66,8 @@ void makebphysmodel(lua_State *L){ printf("Tinyobj failed to load model:%s\n",ppath); } //u32 meshcount = pmesh->getMeshBufferCount(); - __mingw_printf("attrib.num_vertices: %u\n",attrib.num_vertices); - __mingw_printf("attrib.num_faces: %u\n",attrib.num_faces); + //__mingw_printf("attrib.num_vertices: %u\n",attrib.num_vertices); + //__mingw_printf("attrib.num_faces: %u\n",attrib.num_faces); btTriangleMesh* trimesh = new btTriangleMesh(); for(size_t i = 0; i < attrib.num_vertices; i++){ //0 - x, so num_vertices - 1 //__mingw_printf("Looking at vertice %llu/%u\n",i,attrib.num_vertices); |
