From 10237a66c7aa5718702af3026e3c7ea378a4bccd Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Wed, 25 Jun 2008 23:01:13 +0000 Subject: [PATCH] GCC/Linux build fixes This was SVN commit r6107. --- source/gui/MiniMap.cpp | 6 ++-- source/lib/sysdep/linux/lcpu.cpp | 2 +- source/lib/sysdep/unix/unix.cpp | 2 +- source/network/NMTCreator.h | 6 ++-- source/network/NetClient.cpp | 48 ++++++++++++++-------------- source/network/NetServer.cpp | 40 +++++++++++------------ source/scripting/DOMEvent.cpp | 2 +- source/scripting/DOMEvent.h | 2 +- source/scripting/JSConversions.cpp | 3 +- source/scripting/JSConversions.h | 3 ++ source/simulation/AStarEngine.cpp | 1 + source/simulation/PathfindEngine.cpp | 1 + 12 files changed, 62 insertions(+), 54 deletions(-) diff --git a/source/gui/MiniMap.cpp b/source/gui/MiniMap.cpp index dde84e1049..184767309f 100644 --- a/source/gui/MiniMap.cpp +++ b/source/gui/MiniMap.cpp @@ -42,9 +42,9 @@ static float m_scaleX, m_scaleY; static unsigned int ScaleColor(unsigned int color, float x) { - unsigned int r = unsigned int(float(color & 0xff) * x); - unsigned int g = unsigned int(float((color>>8) & 0xff) * x); - unsigned int b = unsigned int(float((color>>16) & 0xff) * x); + unsigned int r = unsigned(float(color & 0xff) * x); + unsigned int g = unsigned(float((color>>8) & 0xff) * x); + unsigned int b = unsigned(float((color>>16) & 0xff) * x); return (0xff000000 | r | g<<8 | b<<16); } diff --git a/source/lib/sysdep/linux/lcpu.cpp b/source/lib/sysdep/linux/lcpu.cpp index c1ea02a76a..66ab84d545 100644 --- a/source/lib/sysdep/linux/lcpu.cpp +++ b/source/lib/sysdep/linux/lcpu.cpp @@ -120,7 +120,7 @@ uintptr_t os_cpu_SetThreadAffinityMask(uintptr_t processorMask) } -LibError cpu_CallByEachCPU(OsCpuCallback cb, uintptr_t cbData) +LibError os_cpu_CallByEachCPU(OsCpuCallback cb, uintptr_t cbData) { for(size_t processor = 0; processor < os_cpu_NumProcessors(); processor++) { diff --git a/source/lib/sysdep/unix/unix.cpp b/source/lib/sysdep/unix/unix.cpp index cfb5f1298d..622f719798 100644 --- a/source/lib/sysdep/unix/unix.cpp +++ b/source/lib/sysdep/unix/unix.cpp @@ -26,7 +26,7 @@ void sys_display_msgw(const wchar_t* caption, const wchar_t* msg) fwprintf(stderr, L"%ls: %ls\n", caption, msg); } -ErrorReaction sys_display_error(const wchar_t* text, size_t flags) +ErrorReaction sys_display_error(const wchar_t* text, int flags) { printf("%ls\n\n", text); diff --git a/source/network/NMTCreator.h b/source/network/NMTCreator.h index a18e528d57..2cd544db59 100644 --- a/source/network/NMTCreator.h +++ b/source/network/NMTCreator.h @@ -255,8 +255,10 @@ const u8 *_nm::Deserialize(const u8 *pos, const u8 *end) \ #define START_NMT_CLASS(_nm, _tp) \ START_NMT_CLASS_DERIVED(CNetMessage, _nm, _tp) -//#define START_NMT_CLASS_DERIVED(_base, _nm, _tp) \ -// { _tp, Deserialize##_nm }, +/* +#define START_NMT_CLASS_DERIVED(_base, _nm, _tp) \ + { _tp, Deserialize##_nm }, +*/ #define START_NMT_CLASS_DERIVED(_base, _nm, _tp) diff --git a/source/network/NetClient.cpp b/source/network/NetClient.cpp index 13594cb7e1..e0089e3d75 100644 --- a/source/network/NetClient.cpp +++ b/source/network/NetClient.cpp @@ -10,7 +10,7 @@ #include "precompiled.h" #include "NetClient.h" #include "NetJsEvents.h" -#include "network.h" +#include "Network.h" #include "NetServer.h" #include "scripting/DOMEvent.h" #include "scripting/JSConversions.h" @@ -160,33 +160,33 @@ bool CNetClient::SetupSession( CNetSession* pSession ) pContext->pSession = pSession; // Setup transitions for session - pSession->AddTransition( NCS_CONNECT, ( uint )NMT_SERVER_HANDSHAKE, NCS_HANDSHAKE, &OnHandshake, pContext ); + pSession->AddTransition( NCS_CONNECT, ( uint )NMT_SERVER_HANDSHAKE, NCS_HANDSHAKE, (void*)&OnHandshake, pContext ); - pSession->AddTransition( NCS_HANDSHAKE, ( uint )NMT_ERROR, NCS_CONNECT, &OnError, pContext ); - pSession->AddTransition( NCS_HANDSHAKE, ( uint )NMT_SERVER_HANDSHAKE_RESPONSE, NCS_AUTHENTICATE, &OnHandshake, pContext ); + pSession->AddTransition( NCS_HANDSHAKE, ( uint )NMT_ERROR, NCS_CONNECT, (void*)&OnError, pContext ); + pSession->AddTransition( NCS_HANDSHAKE, ( uint )NMT_SERVER_HANDSHAKE_RESPONSE, NCS_AUTHENTICATE, (void*)&OnHandshake, pContext ); - pSession->AddTransition( NCS_AUTHENTICATE, ( uint )NMT_ERROR, NCS_CONNECT, &OnError, pContext ); - pSession->AddTransition( NCS_AUTHENTICATE, ( uint )NMT_AUTHENTICATE_RESULT, NCS_PREGAME, &OnAuthenticate, pContext ); + pSession->AddTransition( NCS_AUTHENTICATE, ( uint )NMT_ERROR, NCS_CONNECT, (void*)&OnError, pContext ); + pSession->AddTransition( NCS_AUTHENTICATE, ( uint )NMT_AUTHENTICATE_RESULT, NCS_PREGAME, (void*)&OnAuthenticate, pContext ); - pSession->AddTransition( NCS_PREGAME, ( uint )NMT_ERROR, NCS_CONNECT, &OnError, pContext ); - pSession->AddTransition( NCS_PREGAME, ( uint )NMT_GAME_SETUP, NCS_PREGAME, &OnPreGame, pContext ); - pSession->AddTransition( NCS_PREGAME, ( uint )NMT_ASSIGN_PLAYER_SLOT, NCS_PREGAME, &OnPreGame, pContext ); - pSession->AddTransition( NCS_PREGAME, ( uint )NMT_PLAYER_CONFIG, NCS_PREGAME, &OnPreGame, pContext ); - pSession->AddTransition( NCS_PREGAME, ( uint )NMT_PLAYER_JOIN, NCS_PREGAME, &OnPlayerJoin, pContext ); - pSession->AddTransition( NCS_PREGAME, ( uint )NMT_GAME_START, NCS_INGAME, &OnStartGame, pContext ); + pSession->AddTransition( NCS_PREGAME, ( uint )NMT_ERROR, NCS_CONNECT, (void*)&OnError, pContext ); + pSession->AddTransition( NCS_PREGAME, ( uint )NMT_GAME_SETUP, NCS_PREGAME, (void*)&OnPreGame, pContext ); + pSession->AddTransition( NCS_PREGAME, ( uint )NMT_ASSIGN_PLAYER_SLOT, NCS_PREGAME, (void*)&OnPreGame, pContext ); + pSession->AddTransition( NCS_PREGAME, ( uint )NMT_PLAYER_CONFIG, NCS_PREGAME, (void*)&OnPreGame, pContext ); + pSession->AddTransition( NCS_PREGAME, ( uint )NMT_PLAYER_JOIN, NCS_PREGAME, (void*)&OnPlayerJoin, pContext ); + pSession->AddTransition( NCS_PREGAME, ( uint )NMT_GAME_START, NCS_INGAME, (void*)&OnStartGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_CHAT, NCS_INGAME, &OnChat, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_GOTO, NCS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_PATROL, NCS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_ADD_WAYPOINT, NCS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_GENERIC, NCS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_PRODUCE, NCS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_PLACE_OBJECT, NCS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_RUN, NCS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_NOTIFY_REQUEST, NCS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_FORMATION_GOTO, NCS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_FORMATION_GENERIC, NCS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NCS_INGAME, ( uint )NMT_END_COMMAND_BATCH, NCS_INGAME, &OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_CHAT, NCS_INGAME, (void*)&OnChat, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_GOTO, NCS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_PATROL, NCS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_ADD_WAYPOINT, NCS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_GENERIC, NCS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_PRODUCE, NCS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_PLACE_OBJECT, NCS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_RUN, NCS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_NOTIFY_REQUEST, NCS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_FORMATION_GOTO, NCS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_FORMATION_GENERIC, NCS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NCS_INGAME, ( uint )NMT_END_COMMAND_BATCH, NCS_INGAME, (void*)&OnInGame, pContext ); // Set first state pSession->SetFirstState( NCS_CONNECT ); diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index e493ec0528..c4b8d2115b 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -125,26 +125,26 @@ bool CNetServer::SetupSession( CNetSession* pSession ) pContext->pSession = pSession; // Setup transitions for session - pSession->AddTransition( NSS_HANDSHAKE, ( uint )NMT_ERROR, NSS_HANDSHAKE, &OnError, pContext ); - pSession->AddTransition( NSS_HANDSHAKE, ( uint )NMT_CLIENT_HANDSHAKE, NSS_AUTHENTICATE, &OnHandshake, pContext ); - pSession->AddTransition( NSS_AUTHENTICATE, ( uint )NMT_ERROR, NSS_AUTHENTICATE, &OnError, pContext ); - pSession->AddTransition( NSS_AUTHENTICATE, ( uint )NMT_AUTHENTICATE, NSS_PREGAME, &OnAuthenticate, pContext ); - pSession->AddTransition( NSS_AUTHENTICATE, ( uint )NMT_APP_PREGAME, NSS_PREGAME, &OnPreGame, pContext ); - pSession->AddTransition( NSS_AUTHENTICATE, ( uint )NMT_APP_OBSERVER, NSS_INGAME, &OnChat, pContext ); - pSession->AddTransition( NSS_PREGAME, ( uint )NMT_CHAT, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_ERROR, NSS_INGAME, &OnError, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_CHAT, NSS_INGAME, &OnChat, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_GOTO, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_PATROL, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_ADD_WAYPOINT, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_GENERIC, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_PRODUCE, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_PLACE_OBJECT, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_RUN, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_NOTIFY_REQUEST, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_FORMATION_GOTO, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_FORMATION_GENERIC, NSS_INGAME, &OnInGame, pContext ); - pSession->AddTransition( NSS_INGAME, ( uint )NMT_END_COMMAND_BATCH, NSS_INGAME, &OnInGame, pContext ); + pSession->AddTransition( NSS_HANDSHAKE, ( uint )NMT_ERROR, NSS_HANDSHAKE, (void*)&OnError, pContext ); + pSession->AddTransition( NSS_HANDSHAKE, ( uint )NMT_CLIENT_HANDSHAKE, NSS_AUTHENTICATE, (void*)&OnHandshake, pContext ); + pSession->AddTransition( NSS_AUTHENTICATE, ( uint )NMT_ERROR, NSS_AUTHENTICATE, (void*)&OnError, pContext ); + pSession->AddTransition( NSS_AUTHENTICATE, ( uint )NMT_AUTHENTICATE, NSS_PREGAME, (void*)&OnAuthenticate, pContext ); + pSession->AddTransition( NSS_AUTHENTICATE, ( uint )NMT_APP_PREGAME, NSS_PREGAME, (void*)&OnPreGame, pContext ); + pSession->AddTransition( NSS_AUTHENTICATE, ( uint )NMT_APP_OBSERVER, NSS_INGAME, (void*)&OnChat, pContext ); + pSession->AddTransition( NSS_PREGAME, ( uint )NMT_CHAT, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_ERROR, NSS_INGAME, (void*)&OnError, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_CHAT, NSS_INGAME, (void*)&OnChat, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_GOTO, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_PATROL, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_ADD_WAYPOINT, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_GENERIC, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_PRODUCE, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_PLACE_OBJECT, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_RUN, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_NOTIFY_REQUEST, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_FORMATION_GOTO, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_FORMATION_GENERIC, NSS_INGAME, (void*)&OnInGame, pContext ); + pSession->AddTransition( NSS_INGAME, ( uint )NMT_END_COMMAND_BATCH, NSS_INGAME, (void*)&OnInGame, pContext ); // Set first state pSession->SetFirstState( NSS_HANDSHAKE ); diff --git a/source/scripting/DOMEvent.cpp b/source/scripting/DOMEvent.cpp index cd4aa8850f..01fc04b010 100644 --- a/source/scripting/DOMEvent.cpp +++ b/source/scripting/DOMEvent.cpp @@ -158,7 +158,7 @@ CScriptEvent::CScriptEvent( const CStrW& Type, size_t TypeCode, bool Cancelable, m_Type = Type; m_TypeCode = TypeCode; m_Cancelable = Cancelable; m_Cancelled = false; m_Blockable = Blockable; m_Blocked = false; - m_Timestamp = (long)( timer_Time() * 1000.0 ); + m_Timestamp = (size_t)( timer_Time() * 1000.0 ); } void CScriptEvent::ScriptingInit() diff --git a/source/scripting/DOMEvent.h b/source/scripting/DOMEvent.h index f360da5ad2..a741d50b04 100644 --- a/source/scripting/DOMEvent.h +++ b/source/scripting/DOMEvent.h @@ -105,7 +105,7 @@ public: bool m_Blockable; // Timestamp (milliseconds since epoch (start of game?)) - long m_Timestamp; + size_t m_Timestamp; // Event type string CStrW m_Type; diff --git a/source/scripting/JSConversions.cpp b/source/scripting/JSConversions.cpp index 0f434813c8..2aadaa03e5 100644 --- a/source/scripting/JSConversions.cpp +++ b/source/scripting/JSConversions.cpp @@ -130,8 +130,8 @@ template<> bool ToPrimitive( JSContext* cx, jsval v, unsigned& Storage ) return true; } +/* (See comment in JSConversions.h) // ssize_t - template<> jsval ToJSVal( const ssize_t& Native ) { return( INT_TO_JSVAL( (int)Native ) ); @@ -149,6 +149,7 @@ template<> bool ToPrimitive( JSContext* cx, jsval v, ssize_t& Storage ) Storage = (ssize_t)tmp; return ok == JS_TRUE; } +*/ #if ARCH_AMD64 diff --git a/source/scripting/JSConversions.h b/source/scripting/JSConversions.h index 0042c276f3..c0874902db 100644 --- a/source/scripting/JSConversions.h +++ b/source/scripting/JSConversions.h @@ -125,9 +125,12 @@ template<> jsval ToJSVal( const unsigned& Native ); template<> jsval ToJSVal( unsigned& Native ); // ssize_t +/* PT: Disabled this since it breaks the GCC build (conflicting with int) - this + might break the build on Windows instead. TODO: find out and clean this up. template<> bool ToPrimitive( JSContext* cx, jsval v, ssize_t& Storage ); template<> jsval ToJSVal( const ssize_t& Native ); template<> jsval ToJSVal( ssize_t& Native ); +*/ // size_t template<> bool ToPrimitive( JSContext* cx, jsval v, size_t& Storage ); diff --git a/source/simulation/AStarEngine.cpp b/source/simulation/AStarEngine.cpp index d596219b9c..bf8f1a0732 100644 --- a/source/simulation/AStarEngine.cpp +++ b/source/simulation/AStarEngine.cpp @@ -6,6 +6,7 @@ #include "Collision.h" #include "Entity.h" +#include "ps/Overlay.h" #include "ps/Game.h" #include "ps/World.h" #include "graphics/TextureEntry.h" diff --git a/source/simulation/PathfindEngine.cpp b/source/simulation/PathfindEngine.cpp index f1f1979a5a..7446a57bf5 100644 --- a/source/simulation/PathfindEngine.cpp +++ b/source/simulation/PathfindEngine.cpp @@ -12,6 +12,7 @@ #include "ps/GameSetup/Config.h" +#include "lib/ogl.h"