From 105bc12d64f04f721c6c0cc6dca24fa69b511048 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 30 Mar 2016 13:41:30 -0400 Subject: [PATCH] Bunch more work on getting this to compile. Down to Stream and Gfx_OpenGL now. --- Sources/Engine/Base/Stream.h | 42 +++++++++++----------- Sources/Engine/Base/Types.h | 1 + Sources/Engine/GameAgent/GameAgent.cpp | 50 +++++++++++++++----------- Sources/Engine/Math/Quaternion.h | 1 + Sources/Engine/Ska/smcPars.y | 1 + Sources/Engine/Templates/BSP.cpp | 6 ++-- Sources/Engine/Templates/Selection.cpp | 2 +- Sources/Makefile | 4 +-- 8 files changed, 60 insertions(+), 47 deletions(-) diff --git a/Sources/Engine/Base/Stream.h b/Sources/Engine/Base/Stream.h index ee8cd42..f9114c7 100644 --- a/Sources/Engine/Base/Stream.h +++ b/Sources/Engine/Base/Stream.h @@ -155,27 +155,29 @@ public: inline CTString &GetDescription(void) { return strm_strStreamDescription; }; /* Read an object from stream. */ - inline CTStream &operator>>(float &f) { Read_t( &f, sizeof( f)); return *this; } // throw char * - inline CTStream &operator>>(double &d) { Read_t( &d, sizeof( d)); return *this; } // throw char * - inline CTStream &operator>>(ULONG &ul) { Read_t(&ul, sizeof(ul)); return *this; } // throw char * - inline CTStream &operator>>(UWORD &uw) { Read_t(&uw, sizeof(uw)); return *this; } // throw char * - inline CTStream &operator>>(UBYTE &ub) { Read_t(&ub, sizeof(ub)); return *this; } // throw char * - inline CTStream &operator>>(SLONG &sl) { Read_t(&sl, sizeof(sl)); return *this; } // throw char * - inline CTStream &operator>>(SWORD &sw) { Read_t(&sw, sizeof(sw)); return *this; } // throw char * - inline CTStream &operator>>(SBYTE &sb) { Read_t(&sb, sizeof(sb)); return *this; } // throw char * - inline CTStream &operator>>(BOOL &b) { Read_t( &b, sizeof( b)); return *this; } // throw char * - inline CTStream &operator>>(__int64 &i64) { Read_t( &i64, sizeof(i64)); return *this; } // throw char * + inline CTStream &operator>>(UBYTE &ub) { Read_t(&ub, sizeof(ub)); return *this; } // throw char * + inline CTStream &operator>>(SBYTE &sb) { Read_t(&sb, sizeof(sb)); return *this; } // throw char * + inline CTStream &operator>>(float &f) { Read_t( &f, sizeof( f)); BYTESWAP( f); return *this; } // throw char * + inline CTStream &operator>>(double &d) { Read_t( &d, sizeof( d)); BYTESWAP( d); return *this; } // throw char * + inline CTStream &operator>>(ULONG &ul) { Read_t(&ul, sizeof(ul)); BYTESWAP(ul); return *this; } // throw char * + inline CTStream &operator>>(SLONG &sl) { Read_t(&sl, sizeof(sl)); BYTESWAP(sl); return *this; } // throw char * + inline CTStream &operator>>(UWORD &uw) { Read_t(&uw, sizeof(uw)); BYTESWAP(uw); return *this; } // throw char * + inline CTStream &operator>>(SWORD &sw) { Read_t(&sw, sizeof(sw)); BYTESWAP(sw); return *this; } // throw char * + inline CTStream &operator>>(BOOL &b) { Read_t( &b, sizeof( b)); BYTESWAP( b); return *this; } // throw char * + inline CTStream &operator>>(__int64 i) { Read_t( &i, sizeof( i)); BYTESWAP( i); return *this; } // throw char * + inline CTStream &operator>>(__uint64 i) { Read_t( &i, sizeof( i)); BYTESWAP( i); return *this; } // throw char * /* Write an object into stream. */ - inline CTStream &operator<<(const float &f) { Write_t( &f, sizeof( f)); return *this; } // throw char * - inline CTStream &operator<<(const double &d) { Write_t( &d, sizeof( d)); return *this; } // throw char * - inline CTStream &operator<<(const ULONG &ul) { Write_t(&ul, sizeof(ul)); return *this; } // throw char * - inline CTStream &operator<<(const UWORD &uw) { Write_t(&uw, sizeof(uw)); return *this; } // throw char * - inline CTStream &operator<<(const UBYTE &ub) { Write_t(&ub, sizeof(ub)); return *this; } // throw char * - inline CTStream &operator<<(const SLONG &sl) { Write_t(&sl, sizeof(sl)); return *this; } // throw char * - inline CTStream &operator<<(const SWORD &sw) { Write_t(&sw, sizeof(sw)); return *this; } // throw char * - inline CTStream &operator<<(const SBYTE &sb) { Write_t(&sb, sizeof(sb)); return *this; } // throw char * - inline CTStream &operator<<(const BOOL &b) { Write_t( &b, sizeof( b)); return *this; } // throw char * - inline CTStream &operator<<(const __int64 &i64) { Write_t( &i64, sizeof(i64)); return *this; } // throw char * + inline CTStream &operator<<(UBYTE ub) { Write_t(&ub, sizeof(ub)); return *this; } // throw char * + inline CTStream &operator<<(SBYTE sb) { Write_t(&sb, sizeof(sb)); return *this; } // throw char * + inline CTStream &operator<<(float f) { BYTESWAP( f); Write_t( &f, sizeof( f)); return *this; } // throw char * + inline CTStream &operator<<(double d) { BYTESWAP( d); Write_t( &d, sizeof( d)); return *this; } // throw char * + inline CTStream &operator<<(ULONG ul) { BYTESWAP(ul); Write_t(&ul, sizeof(ul)); return *this; } // throw char * + inline CTStream &operator<<(SLONG sl) { BYTESWAP(sl); Write_t(&sl, sizeof(sl)); return *this; } // throw char * + inline CTStream &operator<<(UWORD uw) { BYTESWAP(uw); Write_t(&uw, sizeof(uw)); return *this; } // throw char * + inline CTStream &operator<<(SWORD sw) { BYTESWAP(sw); Write_t(&sw, sizeof(sw)); return *this; } // throw char * + inline CTStream &operator<<(BOOL b) { BYTESWAP( b); Write_t( &b, sizeof( b)); return *this; } // throw char * + inline CTStream &operator<<(__int64 i) { BYTESWAP( i); Write_t( &i, sizeof( i)); return *this; } // throw char * + inline CTStream &operator<<(__uint64 i) { BYTESWAP( i); Write_t( &i, sizeof( i)); return *this; } // throw char * // CTFileName reading/writing ENGINE_API friend CTStream &operator>>(CTStream &strmStream, CTFileName &fnmFileName); diff --git a/Sources/Engine/Base/Types.h b/Sources/Engine/Base/Types.h index a014d51..24e5cad 100644 --- a/Sources/Engine/Base/Types.h +++ b/Sources/Engine/Base/Types.h @@ -191,6 +191,7 @@ typedef unsigned int UINT; typedef long long __int64; #endif + typedef char CHAR; typedef UBYTE BYTE; typedef unsigned short WORD; typedef unsigned long int DWORD; diff --git a/Sources/Engine/GameAgent/GameAgent.cpp b/Sources/Engine/GameAgent/GameAgent.cpp index b6d9e8c..35c313c 100644 --- a/Sources/Engine/GameAgent/GameAgent.cpp +++ b/Sources/Engine/GameAgent/GameAgent.cpp @@ -1,6 +1,6 @@ /* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ -#include "StdH.h" +#include #include #include @@ -39,9 +39,10 @@ typedef struct sockaddr SOCKADDR; #ifdef PLATFORM_WIN32 #pragma comment(lib, "wsock32.lib") WSADATA* _wsaData = NULL; +typedef int socklen_t; #endif -SOCKET _socket = NULL; +SOCKET _socket = INVALID_SOCKET; sockaddr_in* _sin = NULL; sockaddr_in* _sinLocal = NULL; @@ -56,18 +57,18 @@ TIME _tmLastHeartbeat = 0; CDynamicStackArray ga_asrRequests; -extern CTString ga_strServer = "master1.croteam.org"; +CTString ga_strServer = "master1.croteam.org"; void _uninitWinsock(); void _initializeWinsock(void) { #ifdef PLATFORM_WIN32 - if(_wsaData != NULL && _socket != NULL) { + if(_wsaData != NULL && _socket != INVALID_SOCKET) { return; } _wsaData = new WSADATA; - _socket = NULL; + _socket = INVALID_SOCKET; // make the buffer that we'll use for packet reading if(_szBuffer != NULL) { @@ -89,7 +90,7 @@ void _initializeWinsock(void) // if we couldn't resolve the hostname if(phe == NULL) { // report and stop - CPrintF("Couldn't resolve GameAgent server %s.\n", ga_strServer); + CPrintF("Couldn't resolve GameAgent server %s.\n", (const char *) ga_strServer); _uninitWinsock(); return; } @@ -102,6 +103,11 @@ void _initializeWinsock(void) // create the socket _socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (_socket == INVALID_SOCKET) { + CPrintF("Error creating GameAgent socket!\n"); + _uninitWinsock(); + return; + } // if we're a server if(_bServer) { @@ -141,14 +147,16 @@ void _initializeWinsock(void) void _uninitWinsock() { - if(_wsaData != NULL) { + if (_socket != INVALID_SOCKET) { closesocket(_socket); - #ifdef PLATFORM_WIN32 + _socket = INVALID_SOCKET; + } + #ifdef PLATFORM_WIN32 + if(_wsaData != NULL) { delete _wsaData; _wsaData = NULL; - #endif } - _socket = NULL; + #endif } void _sendPacketTo(const char* pubBuffer, INDEX iLen, sockaddr_in* sin) @@ -173,7 +181,7 @@ void _sendPacket(const char* szBuffer) int _recvPacket() { - int fromLength = sizeof(_sinFrom); + socklen_t fromLength = sizeof(_sinFrom); return recvfrom(_socket, _szBuffer, 1024, 0, (sockaddr*)&_sinFrom, &fromLength); } @@ -202,10 +210,10 @@ void _sendHeartbeat(INDEX iChallenge) iChallenge, _pNetwork->ga_srvServer.GetPlayersCount(), _pNetwork->ga_sesSessionState.ses_ctMaxPlayers, - _pNetwork->ga_World.wo_strName, - _getGameModeName(_getSP()->sp_gmGameMode), + (const char *) _pNetwork->ga_World.wo_strName, + (const char *) _getGameModeName(_getSP()->sp_gmGameMode), _SE_VER_STRING, - _pShell->GetString("sam_strGameName")); + (const char *) _pShell->GetString("sam_strGameName")); _sendPacket(strPacket); _tmLastHeartbeat = _pTimer->GetRealTimeTick(); } @@ -250,7 +258,7 @@ extern void GameAgent_ServerEnd(void) /// GameAgent server update call which responds to enumeration pings and sends pings to masterserver. extern void GameAgent_ServerUpdate(void) { - if((_socket == NULL) || (!_bInitialized)) { + if((_socket == INVALID_SOCKET) || (!_bInitialized)) { return; } @@ -273,11 +281,11 @@ extern void GameAgent_ServerUpdate(void) strPacket.PrintF("0;players;%d;maxplayers;%d;level;%s;gametype;%s;version;%s;gamename;%s;sessionname;%s", _pNetwork->ga_srvServer.GetPlayersCount(), _pNetwork->ga_sesSessionState.ses_ctMaxPlayers, - _pNetwork->ga_World.wo_strName, - _getGameModeName(_getSP()->sp_gmGameMode), + (const char *) _pNetwork->ga_World.wo_strName, + (const char *) _getGameModeName(_getSP()->sp_gmGameMode), _SE_VER_STRING, - _pShell->GetString("sam_strGameName"), - _pShell->GetString("gam_strSessionName")); + (const char *) _pShell->GetString("sam_strGameName"), + (const char *) _pShell->GetString("gam_strSessionName")); _sendPacketTo(strPacket, &_sinFrom); break; } @@ -355,7 +363,7 @@ extern void GameAgent_EnumTrigger(BOOL bInternet) /// GameAgent client update for enumerations. extern void GameAgent_EnumUpdate(void) { - if((_socket == NULL) || (!_bInitialized)) { + if((_socket == INVALID_SOCKET) || (!_bInitialized)) { return; } @@ -439,7 +447,7 @@ extern void GameAgent_EnumUpdate(void) } else if(strKey == "gamename") { strGameName = strValue; } else { - CPrintF("Unknown GameAgent parameter key '%s'!", strKey); + CPrintF("Unknown GameAgent parameter key '%s'!", (const char *) strKey); } // reset temporary holders diff --git a/Sources/Engine/Math/Quaternion.h b/Sources/Engine/Math/Quaternion.h index ee9280c..c2f94ca 100644 --- a/Sources/Engine/Math/Quaternion.h +++ b/Sources/Engine/Math/Quaternion.h @@ -7,6 +7,7 @@ #endif #include +#include /* * Template class for quaternion of arbitrary precision. diff --git a/Sources/Engine/Ska/smcPars.y b/Sources/Engine/Ska/smcPars.y index f0110bf..f918c2e 100644 --- a/Sources/Engine/Ska/smcPars.y +++ b/Sources/Engine/Ska/smcPars.y @@ -4,6 +4,7 @@ #include #include #include +#include #include // for static linking mojo... diff --git a/Sources/Engine/Templates/BSP.cpp b/Sources/Engine/Templates/BSP.cpp index 5d13d9c..d1b3672 100644 --- a/Sources/Engine/Templates/BSP.cpp +++ b/Sources/Engine/Templates/BSP.cpp @@ -455,7 +455,7 @@ FLOAT BSPNode::TestSphere(const Vector &vS } else { ASSERT(bn_bnlLocation == BNL_BRANCH); // test the sphere against the split plane - Type tCenterDistance = PointDistance(vSphereCenter); + Type tCenterDistance = this->PointDistance(vSphereCenter); // if the sphere is in front of the plane if (tCenterDistance > +tSphereRadius) { // recurse down the front node @@ -564,8 +564,8 @@ void BSPNode::FindLineMinMax( } else { ASSERT(bn_bnlLocation == BNL_BRANCH); // test the points against the split plane - Type tD0 = PointDistance(v0); - Type tD1 = PointDistance(v1); + Type tD0 = this->PointDistance(v0); + Type tD1 = this->PointDistance(v1); // if both are front if (tD0>=0 && tD1>=0) { // recurse down the front node diff --git a/Sources/Engine/Templates/Selection.cpp b/Sources/Engine/Templates/Selection.cpp index 56d910c..ce257ff 100644 --- a/Sources/Engine/Templates/Selection.cpp +++ b/Sources/Engine/Templates/Selection.cpp @@ -39,7 +39,7 @@ void CSelection::Deselect(cType &tToSelect) // deselect it tToSelect.Deselect(ulFlag); // remove it from this container - Remove(&tToSelect); + this->Remove(&tToSelect); // if the object is not selected } else { diff --git a/Sources/Makefile b/Sources/Makefile index ddb58a6..10f2e45 100644 --- a/Sources/Makefile +++ b/Sources/Makefile @@ -664,7 +664,7 @@ endif #DYNAMIC_SDL_LDFLAGS := $(shell sdl-config --libs) DYNAMIC_SDL_LDFLAGS := ifeq ($(strip $(macosx)),true) - DYNAMIC_SDL_LDFLAGS := lib/macosx_x86/libSDL-1.2.0.dylib bin/libSDLmain.a + DYNAMIC_SDL_LDFLAGS := lib/macosx/libSDL-1.2.0.dylib lib/macosx/libSDLmain.a else DYNAMIC_SDL_LDFLAGS := lib/linux_x86/libSDL-1.2.so.0 endif @@ -743,7 +743,7 @@ endif ifeq ($(strip $(macosx)),true) SDLMAINLIB := bin/libSDLmain.a -$(SDLMAINLIB) : lib/macosx_x86/libSDLmain.a $(BINDIR) +$(SDLMAINLIB) : lib/macosx/libSDLmain.a $(BINDIR) cp $< $@ ranlib $@ endif