diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..e1893939 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: cpp + +matrix: + include: + - os: linux + compiler: gcc + script: cd main/source/linux && make + env: OPJ_CI_ARCH=i386 + addons: + apt: + packages: + - gcc-multilib + - g++-multilib + - libc6-i386 + - libcurl4-openssl-dev:i386 + - libpng12-dev:i386 + + - os: osx + compiler: clang + before_script: + - export CC=clang + - export CPLUS=clang++ + script: cd main/source/linux && make \ No newline at end of file diff --git a/README.md b/README.md index d9b2a6d4..038991ef 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,12 @@ LD_LIBRARY_PATH=".:$LD_LIBRARY_PATH" gdb ./hl_linux r -game ns -dev -steam ``` Due to the new engine and the nature of Linux I had to make a lot of changes! You can find them with grep -Ril `@Linux`. +For MacOS & lldb: +``` +DYLD_LIBRARY_PATH=".:$DYLD_LIBRARY_PATH" /Applications/Xcode.app/Contents/Developer/usr/bin/lldb -- ./hl_osx r -game ns -dev -steam -windowed +``` +Have to use XCode's lldb to get around https://stackoverflow.com/a/33589760 (Lack of environment variables). `-windowed` as windowed mode makes it easier to deal with crashes on MacOS. + ### Hosting a server Since servers are really rare at this point in time here is a tutorial how to set up an [Natural Selection] server with [hlds]. diff --git a/main/source/cl_dll/vgui_TeamFortressViewport.h b/main/source/cl_dll/vgui_TeamFortressViewport.h index 3ae9be5d..a9a9b324 100644 --- a/main/source/cl_dll/vgui_TeamFortressViewport.h +++ b/main/source/cl_dll/vgui_TeamFortressViewport.h @@ -35,7 +35,6 @@ using namespace vgui; -class Cursor; class ScorePanel; class SpectatorPanel; class CCommandMenu; diff --git a/main/source/dlls/player.h b/main/source/dlls/player.h index c1689439..5b6255f9 100644 --- a/main/source/dlls/player.h +++ b/main/source/dlls/player.h @@ -334,7 +334,7 @@ public: void SetCustomDecalFrames( int nFrames ); int GetCustomDecalFrames( void ); - void CBasePlayer::TabulateAmmo( void ); + void TabulateAmmo( void ); float m_flStartCharge; float m_flAmmoStartCharge; diff --git a/main/source/dlls/teamplay_gamerules.cpp b/main/source/dlls/teamplay_gamerules.cpp index 875523d9..77d2e2ef 100644 --- a/main/source/dlls/teamplay_gamerules.cpp +++ b/main/source/dlls/teamplay_gamerules.cpp @@ -183,7 +183,7 @@ const char *CHalfLifeTeamplay::SetDefaultPlayerTeam( CBasePlayer *pPlayer ) // update the current player of the team he is joining const char* theTeamName = pPlayer->TeamID(); - if ( theTeamName == '\0' || !IsValidTeam( theTeamName ) || defaultteam.value ) + if ( theTeamName[0] == '\0' || !IsValidTeam( theTeamName ) || defaultteam.value ) { const char *pTeamName = NULL; diff --git a/main/source/includes/lpng1251/configure b/main/source/includes/lpng1251/configure old mode 100644 new mode 100755 diff --git a/main/source/linux/Makefile b/main/source/linux/Makefile index 143ff2cf..fd3bf4e3 100644 --- a/main/source/linux/Makefile +++ b/main/source/linux/Makefile @@ -60,10 +60,10 @@ ifeq ($(OS),Darwin) ifeq ($(origin CC), default) CC ="$(COMPILER_BIN_DIR)/clang -Qunused-arguments -isysroot $(SDKROOT) -mmacosx-version-min=10.5 -fasm-blocks -I$(SDKROOT)/usr/include/malloc $(ARCH_FLAGS)" endif - ifeq ($(origin CXX), default) + ifeq ($(origin CPLUS), default) CPLUS ="$(COMPILER_BIN_DIR)/clang++ -Qunused-arguments -isysroot $(SDKROOT) -mmacosx-version-min=10.5 -fasm-blocks -I$(SDKROOT)/usr/include/malloc $(ARCH_FLAGS)" endif - LINK ?= $(CXX) + LINK ?= $(CPLUS) endif CLINK=$(CC) @@ -88,9 +88,9 @@ endif ifeq ($(OS),Darwin) # force 387 for FP math so the precision between win32 and linux and osx match -ARCH_CFLAGS_I486+=-march=pentium-m -mfpmath=387 -ARCH_CFLAGS_I686+=-march=pentium-m -mfpmath=387 -ARCH_CFLAGS_AMD+=-mfpmath=387 +ARCH_CFLAGS_I486+=-mno-sse -mfpmath=387 -target i386-apple-darwin -DCMAKE_OSX_ARCHITECTURES=i386 +ARCH_CFLAGS_I686+=-mno-sse -mfpmath=387 -target i386-apple-darwin -DCMAKE_OSX_ARCHITECTURES=i386 +ARCH_CFLAGS_AMD+=-mno-sse -mfpmath=387 -target i386-apple-darwin -DCMAKE_OSX_ARCHITECTURES=i386 endif @@ -100,7 +100,7 @@ BASE_CFLAGS=-fpermissive -fno-strict-aliasing -DNDEBUG -DPOSIX -D_POSIX -DLINUX BASE_CFLAGS+=-w ifeq ($(OS),Darwin) - BASE_CFLAGS += -DOSX -D_OSX -fvisibility=hidden + BASE_CFLAGS += -DOSX -D_OSX -fvisibility=hidden -target i386-apple-darwin -DCMAKE_OSX_ARCHITECTURES=i386 else BASE_CFLAGS+= -DLINUX -D_LINUX endif @@ -109,7 +109,7 @@ DEDICATED_CFLAGS="-DDEDICATED -DSWDS" ifeq ($(OS),Darwin) SHLIBEXT=dylib SHLIBCFLAGS= -SHLIBLDFLAGS="-shared -gdwarf-2 -g2" +SHLIBLDFLAGS="-shared -gdwarf-2 -g2 -DCMAKE_OSX_ARCHITECTURES=i386 -target i386-apple-darwin" else SHLIBEXT=so SHLIBCFLAGS= @@ -131,7 +131,8 @@ all: build_dir targets TARGETS= TARGETS+= \ - ns \ + particles \ + ns \ hl_cdll \ build_dir: @@ -140,6 +141,8 @@ build_dir: targets: $(TARGETS) +particles: + cd ../particles && make && cd ../linux && cp ../particles/libpart* . hl_cdll: build_dir $(MAKE_hl_cdll) ARCH=i686 CC=$(CC) CPLUS=$(CPLUS) CPP_LIB="$(CPP_LIB)" BUILD_DIR=$(BUILD_DIR) BUILD_OBJ_DIR=$(BUILD_OBJ_DIR) SOURCE_DIR=$(SOURCE_DIR) ENGINE_SRC_DIR=$(ENGINE_SRC_DIR) MOD_SRC_DIR=$(MOD_SRC_DIR) COMMON_SRC_DIR=$(COMMON_SRC_DIR) BASE_CFLAGS="$(BASE_CFLAGS)" PUBLIC_SRC_DIR=$(PUBLIC_SRC_DIR) DBG_SRC_DIR=$(DBG_SRC_DIR) ARCH_CFLAGS="$(ARCH_CFLAGS_I686)" GAME_SHARED_SRC_DIR=$(GAME_SHARED_SRC_DIR) CLINK=$(CLINK) PM_SRC_DIR=$(PM_SRC_DIR) SHLIBEXT=$(SHLIBEXT) SHLIBCFLAGS=$(SHLIBCFLAGS) SHLIBLDFLAGS=$(SHLIBLDFLAGS) CFG=$(CFG) OS=$(OS) @@ -148,4 +151,5 @@ ns: build_dir $(MAKE_HL_LIB) CC=$(CC) ARCH=$(ARCH) CPP_LIB="$(CPP_LIB)" BUILD_DIR=$(BUILD_DIR) BUILD_OBJ_DIR=$(BUILD_OBJ_DIR) SOURCE_DIR=$(SOURCE_DIR) ENGINE_SRC_DIR=$(ENGINE_SRC_DIR) COMMON_SRC_DIR=$(COMMON_SRC_DIR) PM_SRC_DIR=$(PM_SRC_DIR) GAME_SHARED_SRC_DIR=$(GAME_SHARED_SRC_DIR) GAMEDB_SRC_DIR=$(GAMEDB_SRC_DIR) BASE_CFLAGS="$(BASE_CFLAGS)" SHLIBEXT=$(SHLIBEXT) SHLIBCFLAGS=$(SHLIBCFLAGS) SHLIBLDFLAGS=$(SHLIBLDFLAGS) PUBLIC_SRC_DIR=$(PUBLIC_SRC_DIR) CFG=$(CFG) OS=$(OS) ARCH_CFLAGS="$(ARCH_CFLAGS_I686)" clean: + make -f ../particles/Makefile clean -rm -rf $(BUILD_OBJ_DIR) diff --git a/main/source/linux/Makefile.hl_cdll b/main/source/linux/Makefile.hl_cdll index bf1bc65b..c4418764 100644 --- a/main/source/linux/Makefile.hl_cdll +++ b/main/source/linux/Makefile.hl_cdll @@ -13,6 +13,7 @@ HL_SERVER_SRC_DIR=$(SOURCE_DIR)/dlls GAME_SHARED_SRC_DIR=$(SOURCE_DIR)/game_shared PM_SHARED_SRC_DIR=$(SOURCE_DIR)/pm_shared TEXTREP_SRC_DIR=$(SOURCE_DIR)/textrep +PARTICLES_SRC_DIR=$(SOURCE_DIR)/particles TEXTREP_OBJ_DIR=$(HL1_OBJ_DIR)/textrep UTIL_OBJ_DIR=$(HL1_OBJ_DIR)/util @@ -30,7 +31,7 @@ CFLAGS=$(BASE_CFLAGS) $(ARCH_CFLAGS) -DCLIENT_DLL -I/usr/include/malloc -D_snwpr INCLUDEDIRS= -I$(HL_SRC_DIR) -I$(NS_MOD_SRC_DIR) -I$(COMMON_SRC_DIR) -I$(PUBLIC_SRC_DIR) -I$(PM_SHARED_SRC_DIR) -I../engine -I$(GAME_SHARED_SRC_DIR) -I../external/ -I../particles -I../includes/fmodapi375linux/api/inc -I$(HL_SERVER_SRC_DIR) -I$(HL_SRC_DIR)/cl_dll -I$(VGUI_INCLUDE_DIR) -I$(UI_INCLUDE_DIR) -I$(UTIL_SRC_DIR) -I../ -I../includes/fmodapi375linux/api -I../includes/lpng1251 ifeq ($(OS),Darwin) -LDFLAGS=$(SHLIBLDFLAGS) $(CPP_LIB) -framework Carbon $(CFG)/vgui.dylib -L. -lSDL2-2.0.0 +LDFLAGS=$(SHLIBLDFLAGS) $(CPP_LIB) -L. libpng12.dylib -lz -framework Carbon vgui.dylib -L. -lSDL2-2.0.0 -L. libparticleMP.a else LDFLAGS=$(SHLIBLDFLAGS) $(CPP_LIB) -lpng -lz -lfmod-3.75 -L$(CFG) vgui.so -L. libSDL2-2.0.so.0 -L. libparticleMP.a endif diff --git a/main/source/linux/Makefile.nsdll b/main/source/linux/Makefile.nsdll index 4de4b522..a9febad9 100644 --- a/main/source/linux/Makefile.nsdll +++ b/main/source/linux/Makefile.nsdll @@ -30,7 +30,12 @@ MOD_INCLUDEDIRS=-I$(UTIL_SRC_DIR) -I$(GAME_SHARED_SRC_DIR) -I$(HLDLL_SRC_DIR) -I UTIL_INCLUDEDIRS = -I../ -I../util TEXTREP_INCLUDEDIRS=.. +ifeq ($(OS),Darwin) LDFLAGS=-lm -lcurl -lstdc++ -L. libparticleMP.a +else +LDFLAGS=-lm -lcurl -lstdc++ -L. libparticleMP.a +endif + DO_HLDLL_CC=$(CC) $(HLDLL_INCLUDEDIRS) $(CFLAGS) -o $@ -c $< DO_PM_CC=$(CC) $(PM_INCLUDEDIRS) $(CFLAGS) -o $@ -c $< DO_GAME_SHARED_CC=$(CC) $(GAME_SHARED_INCLUDEDIRS) $(CFLAGS) -o $@ -c $< diff --git a/main/source/linux/libparticleMP.a b/main/source/linux/libparticleMP.a deleted file mode 100644 index 39516034..00000000 Binary files a/main/source/linux/libparticleMP.a and /dev/null differ diff --git a/main/source/linux/libpng12.dylib b/main/source/linux/libpng12.dylib new file mode 100755 index 00000000..96500be9 Binary files /dev/null and b/main/source/linux/libpng12.dylib differ diff --git a/main/source/linux/vgui.dylib b/main/source/linux/vgui.dylib new file mode 100644 index 00000000..5f4bd616 Binary files /dev/null and b/main/source/linux/vgui.dylib differ diff --git a/main/source/mod/AvHHud.cpp b/main/source/mod/AvHHud.cpp index 42232699..5c37596b 100644 --- a/main/source/mod/AvHHud.cpp +++ b/main/source/mod/AvHHud.cpp @@ -5659,7 +5659,7 @@ string AvHHud::GetRankTitle(bool inShowUnspentLevels) const { string theText; - char* theTeamName = this->GetIsMarine() ? "Marine" : "Alien"; + char const* theTeamName = this->GetIsMarine() ? "Marine" : "Alien"; int theCurrentLevel = this->GetHUDExperienceLevel(); char theCharArray[512]; diff --git a/main/source/mod/CollisionChecker.cpp b/main/source/mod/CollisionChecker.cpp index 72599647..cd21cffa 100644 --- a/main/source/mod/CollisionChecker.cpp +++ b/main/source/mod/CollisionChecker.cpp @@ -454,7 +454,8 @@ void CollisionChecker::SetIgnoreEntityClass(int ignore_entity_class) int CollisionChecker::GetContentsAtPoint(const nspoint_t& point) const { - return GetContents(&PointCollisionTest(point)); + PointCollisionTest tmp = PointCollisionTest(point); + return GetContents(&tmp); } //------------------------------------------------------------------- @@ -468,14 +469,16 @@ int CollisionChecker::GetWorldContentsAtPoint(const nspoint_t& point) const int CollisionChecker::GetAllEntityContentsAtPoint(const nspoint_t& point) const { - return GetAllEntityContents(&PointCollisionTest(point)); + PointCollisionTest tmp = PointCollisionTest(point); + return GetAllEntityContents(&tmp); } //------------------------------------------------------------------- int CollisionChecker::GetSingleEntityContentsAtPoint(const nspoint_t& point, int entity_index) const { - return GetSingleEntityContents(&PointCollisionTest(point),entity_index); + PointCollisionTest tmp = PointCollisionTest(point); + return GetSingleEntityContents(&tmp, entity_index); } //------------------------------------------------------------------- @@ -486,28 +489,32 @@ const static nspoint_t CYLINDER_UP_DEFAULT = {0,0,1.0f}; int CollisionChecker::GetContentsInCylinder(const nspoint_t& base, float radius, float height) const { - return GetContents(&CylinderCollisionTest(CYLINDER_UP_DEFAULT,base,radius,height)); + CylinderCollisionTest tmp = CylinderCollisionTest(CYLINDER_UP_DEFAULT,base,radius,height); + return GetContents(&tmp); } //------------------------------------------------------------------- int CollisionChecker::GetWorldContentsInCylinder(const nspoint_t& base, float radius, float height) const { - return GetSingleEntityContents(&CylinderCollisionTest(CYLINDER_UP_DEFAULT,base,radius,height),WORLD_ENTITY); + CylinderCollisionTest tmp = CylinderCollisionTest(CYLINDER_UP_DEFAULT,base,radius,height); + return GetSingleEntityContents(&tmp, WORLD_ENTITY); } //------------------------------------------------------------------- int CollisionChecker::GetAllEntityContentsInCylinder(const nspoint_t& base, float radius, float height) const { - return GetAllEntityContents(&CylinderCollisionTest(CYLINDER_UP_DEFAULT,base,radius,height)); + CylinderCollisionTest tmp = CylinderCollisionTest(CYLINDER_UP_DEFAULT,base,radius,height); + return GetAllEntityContents(&tmp); } //------------------------------------------------------------------- int CollisionChecker::GetSingleEntityContentsInCylinder(const nspoint_t& base, float radius, float height, int entity_index) const { - return GetSingleEntityContents(&CylinderCollisionTest(CYLINDER_UP_DEFAULT,base,radius,height),entity_index); + CylinderCollisionTest tmp = CylinderCollisionTest(CYLINDER_UP_DEFAULT,base,radius,height); + return GetSingleEntityContents(&tmp,entity_index); } //------------------------------------------------------------------- @@ -516,28 +523,32 @@ int CollisionChecker::GetSingleEntityContentsInCylinder(const nspoint_t& base, f int CollisionChecker::GetContentsInAABB(const nspoint_t& mins, const nspoint_t& maxs) const { - return GetContents(&AABBCollisionTest(mins,maxs)); + AABBCollisionTest tmp = AABBCollisionTest(mins,maxs); + return GetContents(&tmp); } //------------------------------------------------------------------- int CollisionChecker::GetWorldContentsInAABB(const nspoint_t& mins, const nspoint_t& maxs) const { - return GetSingleEntityContents(&AABBCollisionTest(mins,maxs),WORLD_ENTITY); + AABBCollisionTest tmp = AABBCollisionTest(mins,maxs); + return GetSingleEntityContents(&tmp, WORLD_ENTITY); } //------------------------------------------------------------------- int CollisionChecker::GetAllEntityContentsInAABB(const nspoint_t& mins, const nspoint_t& maxs) const { - return GetAllEntityContents(&AABBCollisionTest(mins,maxs)); + AABBCollisionTest tmp = AABBCollisionTest(mins,maxs); + return GetAllEntityContents(&tmp); } //------------------------------------------------------------------- int CollisionChecker::GetSingleEntityContentsInAABB(const nspoint_t& mins, const nspoint_t& maxs, int entity_index) const { - return GetSingleEntityContents(&AABBCollisionTest(mins,maxs),entity_index); + AABBCollisionTest tmp = AABBCollisionTest(mins,maxs); + return GetSingleEntityContents(&tmp,entity_index); } //------------------------------------------------------------------- diff --git a/main/source/particles/Makefile b/main/source/particles/Makefile index b4ebad78..4ff94947 100644 --- a/main/source/particles/Makefile +++ b/main/source/particles/Makefile @@ -11,12 +11,21 @@ GLUT_HOME =/usr/local/contrib/unmoderated MP = #-mp -DPARTICLE_MP +OS:=$(shell uname) + # Make it real fast on an Origin 2000. #LNO =-LNO:opt=1:fusion=2:fission=2:fusion_peeling_limit=2048:cs1=32K:cs2=8M COPT = $(MP) -O3 $(LNO) -fPIC CFLAGS = $(COPT) $(COMPFLAGS) -I. -I.. -I$(GLUT_HOME)/include -I/usr/include/c++/4.8/ -I../common -I../public -I../pm_shared -I../engine +ifeq ($(OS),Darwin) +SLIBB = libtool -static *.o -o libparticleMP.a +CFLAGS += -target i386-apple-darwin -DCMAKE_OSX_ARCHITECTURES=i386 +else +SLIBB = ar clq $@ $(POBJS) +endif + POBJS =action_api.o actions.o HLRender.o opengl.o system.o ALL = libparticleMP.a @@ -31,7 +40,7 @@ all: $(ALL) libparticleMP.a: $(POBJS) rm -f $@ - ar clq $@ $(POBJS) + $(SLIBB) SPDir: (make) diff --git a/main/source/particles/libparticleMP.a b/main/source/particles/libparticleMP.a deleted file mode 100644 index 39516034..00000000 Binary files a/main/source/particles/libparticleMP.a and /dev/null differ diff --git a/main/source/particles/opengl.cpp b/main/source/particles/opengl.cpp index 2f48a566..564ff577 100644 --- a/main/source/particles/opengl.cpp +++ b/main/source/particles/opengl.cpp @@ -9,9 +9,16 @@ #ifdef WIN32 // This is for something in gl.h. #include +#else +#define NULL 0 #endif +#ifdef __APPLE__ +#include +#else #include +#endif + // XXX #include // Emit OpenGL calls to draw the particles. These are drawn with diff --git a/main/source/ui/ScoreboardIcon.cpp b/main/source/ui/ScoreboardIcon.cpp index 62640133..d1333db5 100644 --- a/main/source/ui/ScoreboardIcon.cpp +++ b/main/source/ui/ScoreboardIcon.cpp @@ -133,7 +133,14 @@ void loadImages( const int icon_number, std::vector& images ) std::string extension = ".tga"; std::string icon_name; - unsigned char icon_bytes[2] = { (icon_number >> 8) & 0xFF, icon_number & 0xFF }; + unsigned char icon_bytes[2] = { + static_cast( + (icon_number >> 8) & 0xFF + ), + static_cast( + icon_number & 0xFF + ) + }; MakeHexPairsFromBytes(icon_bytes,icon_name,2); icon_name = "0x" + icon_name; diff --git a/main/source/util/CString.h b/main/source/util/CString.h index fcea4b1a..578c280f 100644 --- a/main/source/util/CString.h +++ b/main/source/util/CString.h @@ -34,12 +34,12 @@ public: void operator =(const string& inString) { - sprintf_s(this->mString, "%s", inString.c_str()); + sprintf_s(this->mString, sizeof(this->mString), "%s", inString.c_str()); } void operator =(const CString& inString) { - sprintf_s(this->mString, "%s", inString.mString); + sprintf_s(this->mString, sizeof(this->mString), "%s", inString.mString); } bool operator ==(const CString& inString) const