From 2a88c1f329ee360664ecc5be0edc0a1eaab2aac5 Mon Sep 17 00:00:00 2001 From: Er2 Date: Mon, 24 Apr 2023 18:27:03 +0300 Subject: [PATCH] Port to musl libc Closes #72 and uses some patches from #193 for better portability between UNIXes. Also this patch replaces so many NULLs with 0 or '\0' because musl headers redefines it and anyway it is better practice. Moreover, due to very "cool" code from Valve, some modules comes with disabled fortify which distributes with build-base in Alpine (fortify is something like compile-time checking for memory bounds) --- appframework/sdlmgr.cpp | 4 +- appframework/wscript | 1 + common/freetype/config/ftconfig.h | 2 - common/vgui_surfacelib/FontManager.h | 2 +- engine/audio/snd_mix.cpp | 2 +- engine/bugreporter.cpp | 4 +- engine/disp_interface.cpp | 2 +- engine/disp_mapload.cpp | 2 +- engine/downloadthread.cpp | 4 +- engine/saverestore_filesystem.cpp | 2 +- engine/sys_dll.cpp | 8 +-- engine/sys_dll2.cpp | 2 +- engine/sys_mainwind.cpp | 6 +-- game/client/wscript | 1 + game/server/ai_basenpc.cpp | 2 +- game/server/ai_hint.cpp | 2 +- game/server/ai_pathfinder.cpp | 4 +- game/server/genericactor.cpp | 2 +- game/server/genericmonster.cpp | 2 +- game/server/hl2/npc_breen.cpp | 2 +- game/server/hl2/npc_eli.cpp | 2 +- game/server/hl2/npc_gman.cpp | 2 +- game/server/hl2/npc_kleiner.cpp | 2 +- game/server/hl2/npc_mossman.cpp | 2 +- game/server/player.cpp | 2 +- game/server/sceneentity.cpp | 2 +- game/server/wscript | 1 + game/shared/particle_parse.cpp | 2 +- game/shared/soundenvelope.cpp | 8 +-- gameui/BasePanel.cpp | 22 ++++---- gameui/CommentaryDialog.cpp | 8 +-- gameui/CreateMultiplayerGameServerPage.cpp | 2 +- gameui/LoadGameDialog_Xbox.cpp | 2 +- gameui/LoadingDialog.cpp | 6 +-- gameui/NewGameDialog.cpp | 2 +- gameui/OptionsDialog_Xbox.cpp | 2 +- gameui/SaveGameDialog_Xbox.cpp | 3 +- gameui/VGuiSystemModuleLoader.cpp | 6 +-- ivp | 2 +- launcher/launcher.cpp | 8 +-- materialsystem/cmatrendercontext.cpp | 4 +- materialsystem/shaderapidx9/wscript | 1 + materialsystem/stdshaders/wscript | 1 + materialsystem/wscript | 1 + mathlib/3dnow.cpp | 2 +- mathlib/mathlib_base.cpp | 2 +- public/appframework/AppFramework.h | 2 +- public/appframework/ilaunchermgr.h | 2 +- public/datamap.h | 54 ++++++++++---------- public/filesystem_init.cpp | 2 +- public/tier0/platform.h | 19 ++++--- public/tier0/threadtools.h | 4 +- public/vgui/VGUI.h | 3 +- public/vgui_controls/FocusNavGroup.h | 4 +- public/vgui_controls/Panel.h | 4 +- public/vgui_controls/PropertySheet.h | 4 +- scenefilecache/SceneFileCache.cpp | 2 +- serverbrowser/ServerBrowserDialog.cpp | 2 +- tier0/assert_dialog.cpp | 4 +- tier0/cpu_posix.cpp | 4 +- tier0/platform_posix.cpp | 22 +++++--- tier0/stacktools.cpp | 4 +- tier0/threadtools.cpp | 7 +-- tier0/wscript | 4 ++ tier1/KeyValues.cpp | 2 +- tier1/interface.cpp | 2 +- tier1/strtools.cpp | 12 ++--- tier1/wscript | 3 +- togl/linuxwin/dxabstract.cpp | 2 +- togl/linuxwin/glentrypoints.cpp | 2 +- togl/linuxwin/glmgr.cpp | 2 +- togl/linuxwin/glmgrbasics.cpp | 41 --------------- togl/wscript | 1 + togles/linuxwin/glmgr.cpp | 2 +- togles/wscript | 2 + vgui2/src/InputWin32.cpp | 48 ++++++++--------- vgui2/src/system_posix.cpp | 3 +- vgui2/src/vgui.cpp | 8 +-- vgui2/src/vgui_internal.h | 2 +- vgui2/src/vgui_key_translation.cpp | 4 +- vgui2/src/wscript | 3 +- vgui2/vgui_controls/EditablePanel.cpp | 6 +-- vgui2/vgui_controls/FocusNavGroup.cpp | 30 +++++------ vgui2/vgui_controls/KeyBoardEditorDialog.cpp | 6 +-- vgui2/vgui_controls/ListPanel.cpp | 2 +- vgui2/vgui_controls/MenuButton.cpp | 4 +- vgui2/vgui_controls/MenuItem.cpp | 4 +- vgui2/vgui_controls/PropertyPage.cpp | 2 +- vgui2/vgui_controls/PropertySheet.cpp | 2 +- vgui2/vgui_controls/ScrollBar.cpp | 2 +- vgui2/vgui_controls/SectionedListPanel.cpp | 2 +- vgui2/vgui_controls/Splitter.cpp | 2 +- vgui2/vgui_controls/TreeView.cpp | 2 +- vgui2/vgui_controls/TreeViewListControl.cpp | 2 +- vgui2/vgui_controls/wscript | 2 + vgui2/vgui_surfacelib/BitmapFont.cpp | 4 +- vgui2/vgui_surfacelib/FontAmalgam.cpp | 2 +- vgui2/vgui_surfacelib/FontManager.cpp | 22 ++++---- vgui2/vgui_surfacelib/Win32Font.cpp | 2 +- vgui2/vgui_surfacelib/linuxfont.cpp | 4 +- vgui2/vgui_surfacelib/wscript | 2 +- vguimatsurface/FontTextureCache.cpp | 4 +- vguimatsurface/FontTextureCache.h | 2 +- vguimatsurface/MatSystemSurface.cpp | 13 +++-- vguimatsurface/MatSystemSurface.h | 6 +-- vguimatsurface/asanstubs.cpp | 2 +- vguimatsurface/wscript | 2 +- video/videoservices.cpp | 6 +-- vpklib/packedstore.cpp | 12 ++--- vstdlib/coroutine.cpp | 2 +- waf | 2 +- wscript | 14 ++--- 112 files changed, 294 insertions(+), 314 deletions(-) diff --git a/appframework/sdlmgr.cpp b/appframework/sdlmgr.cpp index dd5ee2c23..eeae8d7c9 100644 --- a/appframework/sdlmgr.cpp +++ b/appframework/sdlmgr.cpp @@ -270,7 +270,7 @@ class CSDLMgr : public ILauncherMgr // Get the next N events. The function returns the number of events that were filled into your array. virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ); -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) && !defined(OSX) virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvent = false ); #endif @@ -1004,7 +1004,7 @@ int CSDLMgr::GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debug return nToWrite; } -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) && !defined(OSX) int CSDLMgr::PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvent ) { diff --git a/appframework/wscript b/appframework/wscript index f8ded3183..e48d026bb 100755 --- a/appframework/wscript +++ b/appframework/wscript @@ -41,6 +41,7 @@ def build(bld): includes = [ '.', + '../common', '../public', '../public/tier0', '../public/tier1' diff --git a/common/freetype/config/ftconfig.h b/common/freetype/config/ftconfig.h index b56a4d44f..5e19c414c 100644 --- a/common/freetype/config/ftconfig.h +++ b/common/freetype/config/ftconfig.h @@ -3,8 +3,6 @@ #ifdef ANDROID #include -#elif defined(OSX) || defined(PLATFORM_BSD) -#include #else #include #endif diff --git a/common/vgui_surfacelib/FontManager.h b/common/vgui_surfacelib/FontManager.h index b6b10b814..60b941d07 100644 --- a/common/vgui_surfacelib/FontManager.h +++ b/common/vgui_surfacelib/FontManager.h @@ -12,7 +12,7 @@ #endif #include -#include "vgui_surfacelib/FontAmalgam.h" +#include "common/vgui_surfacelib/FontAmalgam.h" #include "materialsystem/imaterialsystem.h" #include "filesystem.h" #include "vguifont.h" diff --git a/engine/audio/snd_mix.cpp b/engine/audio/snd_mix.cpp index 26437e0fa..310aaa1d5 100644 --- a/engine/audio/snd_mix.cpp +++ b/engine/audio/snd_mix.cpp @@ -1999,7 +1999,7 @@ void CChannelCullList::Initialize( CChannelList &list ) else { m_channelInfo[i].m_vol = -1; - m_channelInfo[i].m_nameHash = NULL; // doesn't matter + m_channelInfo[i].m_nameHash = 0; // doesn't matter } } diff --git a/engine/bugreporter.cpp b/engine/bugreporter.cpp index a0fbb4b8a..4ee5ad723 100644 --- a/engine/bugreporter.cpp +++ b/engine/bugreporter.cpp @@ -110,7 +110,7 @@ #define BUG_REPOSITORY_URL "\\\\fileserver\\bugs" #elif defined(OSX) #define BUG_REPOSITORY_URL "/Volumes/bugs" -#elif defined(LINUX) || defined(PLATFORM_BSD) +#elif defined(POSIX) #define BUG_REPOSITORY_URL "\\\\fileserver\\bugs" #else //#error @@ -2257,7 +2257,7 @@ void NonFileSystem_CreatePath (const char *path) } } -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) && !defined(OSX) #define COPYFILE_ALL 0 #define BSIZE 65535 int copyfile( const char *local, const char *remote, void *ignored, int ignoredFlags ) diff --git a/engine/disp_interface.cpp b/engine/disp_interface.cpp index 6bf015cae..782db13a5 100644 --- a/engine/disp_interface.cpp +++ b/engine/disp_interface.cpp @@ -1298,7 +1298,7 @@ int DispInfo_ComputeIndex( HDISPINFOARRAY hArray, IDispInfo* pInfo ) { CDispArray *pArray = static_cast( hArray ); if( !pArray ) - return NULL; + return 0; intp iElement = ((intp)pInfo - (intp)(pArray->m_pDispInfos)) / sizeof(CDispInfo); diff --git a/engine/disp_mapload.cpp b/engine/disp_mapload.cpp index 11b75e965..2fd46663c 100644 --- a/engine/disp_mapload.cpp +++ b/engine/disp_mapload.cpp @@ -801,7 +801,7 @@ CDispInfo::CDispInfo() m_pMesh = NULL; - m_Tag = NULL; + m_Tag = 0; m_pDispArray = NULL; m_FirstDecal = DISP_DECAL_HANDLE_INVALID; diff --git a/engine/downloadthread.cpp b/engine/downloadthread.cpp index 882609f70..e7b4972b8 100644 --- a/engine/downloadthread.cpp +++ b/engine/downloadthread.cpp @@ -587,12 +587,12 @@ static size_t curlHeaderFn( void *ptr, size_t size, size_t nmemb, void *stream) char *pszValue = NULL; RequestContext_t *pRC = (RequestContext_t *) stream; - pszHeader[ ( size * nmemb - 1 ) ] = NULL; + pszHeader[ ( size * nmemb - 1 ) ] = '\0'; pszValue = Q_strstr( pszHeader, ":" ); if ( pszValue ) { // null terminate the header name, and point pszValue at it's value - *pszValue = NULL; + *pszValue = '\0'; pszValue++; Q_StrTrim( pszValue ); } diff --git a/engine/saverestore_filesystem.cpp b/engine/saverestore_filesystem.cpp index a58bab50f..916dac1de 100644 --- a/engine/saverestore_filesystem.cpp +++ b/engine/saverestore_filesystem.cpp @@ -79,7 +79,7 @@ class CSaveDirectory pBuffer = NULL; pCompressedBuffer = NULL; nSize = 0; - nCompressedSize = NULL; + nCompressedSize = 0; } diff --git a/engine/sys_dll.cpp b/engine/sys_dll.cpp index c30e01228..65df39cfa 100644 --- a/engine/sys_dll.cpp +++ b/engine/sys_dll.cpp @@ -1578,7 +1578,7 @@ CON_COMMAND( star_memory, "Dump memory stats" ) { // get a current stat of available memory // 32 MB is reserved and fixed by OS, so not reporting to allow memory loggers sync -#ifdef LINUX +#ifdef PLATFORM_GLIBC struct mallinfo memstats = mallinfo( ); Msg( "sbrk size: %.2f MB, Used: %.2f MB, #mallocs = %d\n", memstats.arena / ( 1024.0 * 1024.0), memstats.uordblks / ( 1024.0 * 1024.0 ), memstats.hblks ); @@ -1586,14 +1586,14 @@ CON_COMMAND( star_memory, "Dump memory stats" ) struct mstats memstats = mstats( ); Msg( "Available %.2f MB, Used: %.2f MB, #mallocs = %lu\n", memstats.bytes_free / ( 1024.0 * 1024.0), memstats.bytes_used / ( 1024.0 * 1024.0 ), memstats.chunks_used ); -#elif PLATFORM_BSD -# warning TODO: Implement memory stats (peace of sheet of course) -#else // Win32 +#elif _WIN32 MEMORYSTATUS stat; GlobalMemoryStatus( &stat ); Msg( "Available: %.2f MB, Used: %.2f MB, Free: %.2f MB\n", stat.dwTotalPhys/( 1024.0f*1024.0f ) - 32.0f, ( stat.dwTotalPhys - stat.dwAvailPhys )/( 1024.0f*1024.0f ) - 32.0f, stat.dwAvailPhys/( 1024.0f*1024.0f ) ); +#else +# warning TODO: Implement memory stats (peace of sheet of course) #endif } diff --git a/engine/sys_dll2.cpp b/engine/sys_dll2.cpp index 10d0c0d50..f260abc1d 100644 --- a/engine/sys_dll2.cpp +++ b/engine/sys_dll2.cpp @@ -279,7 +279,7 @@ static void posix_signal_handler( int i ) #define DO_TRY if ( sigsetjmp( g_mark, 1 ) == 0 ) #define DO_CATCH else -#if defined( OSX ) || defined(PLATFORM_BSD) +#if !defined(PLATFORM_GLIBC) #define __sighandler_t sig_t #endif diff --git a/engine/sys_mainwind.cpp b/engine/sys_mainwind.cpp index 6003bf7cb..3eea1a1cc 100644 --- a/engine/sys_mainwind.cpp +++ b/engine/sys_mainwind.cpp @@ -25,9 +25,7 @@ #elif defined(_X360) // nothing to include for 360 #elif defined(OSX) -#elif defined(LINUX) || defined(PLATFORM_BSD) - #include "tier0/dynfunction.h" -#elif defined(_WIN32) +#elif defined(POSIX) || defined(_WIN32) #include "tier0/dynfunction.h" #else #error @@ -833,7 +831,7 @@ LRESULT CGame::WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) // return 0 if handled message, 1 if not return lRet; } -#elif defined(OSX) || defined(LINUX) || defined(_WIN32) || defined(PLATFORM_BSD) +#elif defined(POSIX) || defined(_WIN32) #else #error diff --git a/game/client/wscript b/game/client/wscript index c454d535c..274a287d8 100755 --- a/game/client/wscript +++ b/game/client/wscript @@ -77,6 +77,7 @@ def build(bld): includes += game["includes"] defines = game["defines"] + defines.append('_FORTIFY_SOURCE=0') defines.remove('PROTECTED_THINGS_ENABLE') bld.shlib( diff --git a/game/server/ai_basenpc.cpp b/game/server/ai_basenpc.cpp index 0acc458f0..4b0e11a4a 100644 --- a/game/server/ai_basenpc.cpp +++ b/game/server/ai_basenpc.cpp @@ -8803,7 +8803,7 @@ void CAI_BaseNPC::DrawDebugGeometryOverlays(void) { float r,g,b; char debugText[255]; - debugText[0] = NULL; + debugText[0] = '\0'; if (npcEnemy == GetEnemy()) { diff --git a/game/server/ai_hint.cpp b/game/server/ai_hint.cpp index 04b8dca84..50d67f272 100644 --- a/game/server/ai_hint.cpp +++ b/game/server/ai_hint.cpp @@ -311,7 +311,7 @@ int CAI_HintManager::FindAllHints( CAI_BaseNPC *pNPC, const Vector &position, co // If we have no hints, bail int c = CAI_HintManager::gm_AllHints.Count(); if ( !c ) - return NULL; + return 0; // Remove the nearest flag. It makes now sense with random. bool hadNearest = hintCriteria.HasFlag( bits_HINT_NODE_NEAREST ); diff --git a/game/server/ai_pathfinder.cpp b/game/server/ai_pathfinder.cpp index 5099925e9..2d44283b0 100644 --- a/game/server/ai_pathfinder.cpp +++ b/game/server/ai_pathfinder.cpp @@ -1514,7 +1514,7 @@ AI_Waypoint_t *CAI_Pathfinder::BuildRadialRoute( const Vector &vStartPos, const vNextPos.y += flRadius * sin( flCurAngle ); // Build a route from the last position to the current one - pNextRoute = BuildLocalRoute( vLastPos, vNextPos, NULL, NULL, NO_NODE, fRouteBits, goalTolerance); + pNextRoute = BuildLocalRoute( vLastPos, vNextPos, 0, 0, NO_NODE, fRouteBits, goalTolerance); // If we can't find a route, we failed if ( pNextRoute == NULL ) @@ -1547,7 +1547,7 @@ AI_Waypoint_t *CAI_Pathfinder::BuildRadialRoute( const Vector &vStartPos, const return NULL; // Append a path to the final position - pLastRoute = BuildLocalRoute( vLastPos, vGoalPos, NULL, NULL, NO_NODE, bAirRoute ? bits_BUILD_FLY : bits_BUILD_GROUND, goalTolerance ); + pLastRoute = BuildLocalRoute( vLastPos, vGoalPos, 0, 0, NO_NODE, bAirRoute ? bits_BUILD_FLY : bits_BUILD_GROUND, goalTolerance ); if ( pLastRoute == NULL ) return NULL; diff --git a/game/server/genericactor.cpp b/game/server/genericactor.cpp index 6f104887d..b872f81a7 100644 --- a/game/server/genericactor.cpp +++ b/game/server/genericactor.cpp @@ -92,7 +92,7 @@ void CGenericActor::HandleAnimEvent( animevent_t *pEvent ) //========================================================= int CGenericActor::GetSoundInterests ( void ) { - return NULL; + return 0; } //========================================================= diff --git a/game/server/genericmonster.cpp b/game/server/genericmonster.cpp index ed1be8191..3322f9adb 100644 --- a/game/server/genericmonster.cpp +++ b/game/server/genericmonster.cpp @@ -127,7 +127,7 @@ void CGenericNPC::HandleAnimEvent( animevent_t *pEvent ) //========================================================= int CGenericNPC::GetSoundInterests ( void ) { - return NULL; + return 0; } //========================================================= diff --git a/game/server/hl2/npc_breen.cpp b/game/server/hl2/npc_breen.cpp index e12bab0c2..cfad85faa 100644 --- a/game/server/hl2/npc_breen.cpp +++ b/game/server/hl2/npc_breen.cpp @@ -69,7 +69,7 @@ void CNPC_Breen::HandleAnimEvent( animevent_t *pEvent ) //----------------------------------------------------------------------------- int CNPC_Breen::GetSoundInterests ( void ) { - return NULL; + return 0; } //----------------------------------------------------------------------------- diff --git a/game/server/hl2/npc_eli.cpp b/game/server/hl2/npc_eli.cpp index 4b42c6c0a..52544aa1a 100644 --- a/game/server/hl2/npc_eli.cpp +++ b/game/server/hl2/npc_eli.cpp @@ -72,7 +72,7 @@ void CNPC_Eli::HandleAnimEvent( animevent_t *pEvent ) //----------------------------------------------------------------------------- int CNPC_Eli::GetSoundInterests ( void ) { - return NULL; + return 0; } //----------------------------------------------------------------------------- diff --git a/game/server/hl2/npc_gman.cpp b/game/server/hl2/npc_gman.cpp index a13fd083b..5b31bdefc 100644 --- a/game/server/hl2/npc_gman.cpp +++ b/game/server/hl2/npc_gman.cpp @@ -84,7 +84,7 @@ void CNPC_GMan::HandleAnimEvent( animevent_t *pEvent ) //----------------------------------------------------------------------------- int CNPC_GMan::GetSoundInterests ( void ) { - return NULL; + return 0; } diff --git a/game/server/hl2/npc_kleiner.cpp b/game/server/hl2/npc_kleiner.cpp index e80817620..3d630d795 100644 --- a/game/server/hl2/npc_kleiner.cpp +++ b/game/server/hl2/npc_kleiner.cpp @@ -70,7 +70,7 @@ void CNPC_Kleiner::HandleAnimEvent( animevent_t *pEvent ) //----------------------------------------------------------------------------- int CNPC_Kleiner::GetSoundInterests ( void ) { - return NULL; + return 0; } //----------------------------------------------------------------------------- diff --git a/game/server/hl2/npc_mossman.cpp b/game/server/hl2/npc_mossman.cpp index ff924cd25..f0b7f02bc 100644 --- a/game/server/hl2/npc_mossman.cpp +++ b/game/server/hl2/npc_mossman.cpp @@ -82,7 +82,7 @@ void CNPC_Mossman::HandleAnimEvent( animevent_t *pEvent ) //----------------------------------------------------------------------------- int CNPC_Mossman::GetSoundInterests ( void ) { - return NULL; + return 0; } //----------------------------------------------------------------------------- diff --git a/game/server/player.cpp b/game/server/player.cpp index 18aededa7..efa394c78 100644 --- a/game/server/player.cpp +++ b/game/server/player.cpp @@ -1459,7 +1459,7 @@ void CBasePlayer::PackDeadPlayerItems( void ) int iPW = 0;// index into packweapons array int iPA = 0;// index into packammo array - memset(rgpPackWeapons, NULL, sizeof(rgpPackWeapons) ); + memset(rgpPackWeapons, 0, sizeof(rgpPackWeapons) ); memset(iPackAmmo, -1, sizeof(iPackAmmo) ); // get the game rules diff --git a/game/server/sceneentity.cpp b/game/server/sceneentity.cpp index 495aa0044..c9f8d1fda 100644 --- a/game/server/sceneentity.cpp +++ b/game/server/sceneentity.cpp @@ -147,7 +147,7 @@ class CSceneManager : public CBaseEntity CRestoreSceneSound() { actor = NULL; - soundname[ 0 ] = NULL; + soundname[ 0 ] = '\0'; soundlevel = SNDLVL_NORM; time_in_past = 0.0f; } diff --git a/game/server/wscript b/game/server/wscript index 1b6d834d0..3da25d6a7 100755 --- a/game/server/wscript +++ b/game/server/wscript @@ -67,6 +67,7 @@ def build(bld): includes += game["includes"] defines = game["defines"] + defines.append('_FORTIFY_SOURCE=0') defines.remove('PROTECTED_THINGS_ENABLE') bld.shlib( diff --git a/game/shared/particle_parse.cpp b/game/shared/particle_parse.cpp index db15685d0..f4ea54ddc 100644 --- a/game/shared/particle_parse.cpp +++ b/game/shared/particle_parse.cpp @@ -172,7 +172,7 @@ void ParseParticleEffectsMap( const char *pMapName, bool bLoadSheets, IFileList CUtlVector files; char szMapManifestFilename[MAX_PATH]; - szMapManifestFilename[0] = NULL; + szMapManifestFilename[0] = '\0'; if ( pMapName && *pMapName ) { diff --git a/game/shared/soundenvelope.cpp b/game/shared/soundenvelope.cpp index e262aa269..7f50a589c 100644 --- a/game/shared/soundenvelope.cpp +++ b/game/shared/soundenvelope.cpp @@ -1056,7 +1056,7 @@ CSoundPatch *CSoundControllerImp::SoundCreate( IRecipientFilter& filter, int nEn CSoundPatch *pSound = new CSoundPatch; // FIXME: This is done so we don't have to futz with the public interface - EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : NULL; + EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : 0; pSound->Init( &filter, hEnt.Get(), CHAN_AUTO, pSoundName, SNDLVL_NORM ); return pSound; @@ -1073,7 +1073,7 @@ CSoundPatch *CSoundControllerImp::SoundCreate( IRecipientFilter& filter, int nEn #endif CSoundPatch *pSound = new CSoundPatch; - EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : NULL; + EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : 0; pSound->Init( &filter, hEnt.Get(), channel, pSoundName, ATTN_TO_SNDLVL( attenuation ) ); return pSound; @@ -1090,7 +1090,7 @@ CSoundPatch *CSoundControllerImp::SoundCreate( IRecipientFilter& filter, int nEn #endif CSoundPatch *pSound = new CSoundPatch; - EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : NULL; + EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : 0; pSound->Init( &filter, hEnt.Get(), channel, pSoundName, soundlevel ); return pSound; @@ -1101,7 +1101,7 @@ CSoundPatch *CSoundControllerImp::SoundCreate( IRecipientFilter& filter, int nEn CSoundPatch *pSound = new CSoundPatch; // FIXME: This is done so we don't have to futz with the public interface - EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : NULL; + EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : 0; pSound->Init( &filter, hEnt.Get(), es.m_nChannel, es.m_pSoundName, es.m_SoundLevel ); pSound->ChangeVolume( es.m_flVolume, 0 ); pSound->ChangePitch( es.m_nPitch, 0 ); diff --git a/gameui/BasePanel.cpp b/gameui/BasePanel.cpp index b9f0bb07c..e7c525f73 100644 --- a/gameui/BasePanel.cpp +++ b/gameui/BasePanel.cpp @@ -245,7 +245,7 @@ class ImageButton : public vgui::Panel if( m_szUrl ) SDL_OpenURL( m_szUrl ); #endif - input()->SetMouseCapture(NULL); + input()->SetMouseCapture(0); } void SetUrl( const char *url ) @@ -332,7 +332,7 @@ class CGameMenu : public vgui::Menu m_pConsoleFooter = NULL; } - m_hMainMenuOverridePanel = NULL; + m_hMainMenuOverridePanel = 0; } virtual void ApplySchemeSettings(IScheme *pScheme) @@ -844,7 +844,7 @@ CBasePanel::CBasePanel() : Panel(NULL, "BaseGameUIPanel") m_pGameMenu = NULL; m_pGameLogo = NULL; - m_hMainMenuOverridePanel = NULL; + m_hMainMenuOverridePanel = 0; if ( SteamClient() ) { @@ -1019,7 +1019,7 @@ static void CC_GameMenuCommand( const CCommand &args ) return; } - vgui::ivgui()->PostMessage( g_pBasePanel->GetVPanel(), new KeyValues("Command", "command", args[1] ), NULL); + vgui::ivgui()->PostMessage( g_pBasePanel->GetVPanel(), new KeyValues("Command", "command", args[1] ), 0); } static int CC_GameMenuCompletionFunc( char const *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] ) @@ -1584,7 +1584,7 @@ void CBasePanel::UpdateGameMenus() if ( m_hMainMenuOverridePanel ) { - vgui::ivgui()->PostMessage( m_hMainMenuOverridePanel, new KeyValues( "UpdateMenu" ), NULL ); + vgui::ivgui()->PostMessage( m_hMainMenuOverridePanel, new KeyValues( "UpdateMenu" ), 0 ); } // position the menu @@ -2263,7 +2263,7 @@ void CBasePanel::RunMenuCommand(const char *command) } else if ( !Q_stricmp( command, "ReleaseModalWindow" ) ) { - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); } else if ( Q_stristr( command, "engine " ) ) { @@ -2343,7 +2343,7 @@ void CBasePanel::RunMenuCommand(const char *command) RegCloseKey(hKey); } -#elif defined( OSX ) || defined( LINUX ) || defined(PLATFORM_BSD) +#elif defined( POSIX ) FILE *fp = fopen( "/tmp/hl2_relaunch", "w+" ); if ( fp ) { @@ -3002,7 +3002,7 @@ class CSaveBeforeQuitQueryDialog : public vgui::Frame virtual void OnClose() { BaseClass::OnClose(); - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); GameUI().AllowEngineHideGameUI(); } }; @@ -3054,7 +3054,7 @@ class CQuitQueryBox : public vgui::QueryBox virtual void OnClose() { BaseClass::OnClose(); - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); GameUI().AllowEngineHideGameUI(); } }; @@ -4733,7 +4733,7 @@ void CMessageDialogHandler::CloseAllMessageDialogs() CMessageDialog *pDlg = m_hMessageDialogs[i]; if ( pDlg ) { - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); if ( vgui_message_dialog_modal.GetBool() ) { vgui::input()->ReleaseAppModalSurface(); @@ -4760,7 +4760,7 @@ void CMessageDialogHandler::CloseMessageDialog( const uint nType ) CMessageDialog *pDlg = m_hMessageDialogs[nStackIdx]; if ( pDlg ) { - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); if ( vgui_message_dialog_modal.GetBool() ) { vgui::input()->ReleaseAppModalSurface(); diff --git a/gameui/CommentaryDialog.cpp b/gameui/CommentaryDialog.cpp index 6f3479c1f..16bc97e06 100644 --- a/gameui/CommentaryDialog.cpp +++ b/gameui/CommentaryDialog.cpp @@ -73,7 +73,7 @@ void CCommentaryDialog::OnClose( void ) { BaseClass::OnClose(); - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); GameUI().AllowEngineHideGameUI(); // Bring up the post dialog @@ -217,7 +217,7 @@ void CPostCommentaryDialog::OnFinishedClose( void ) if ( !m_bResetPaintRestrict ) { m_bResetPaintRestrict = true; - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); GameUI().HideGameUI(); } } @@ -227,7 +227,7 @@ void CPostCommentaryDialog::OnKeyCodeTyped(KeyCode code) if ( code == KEY_ESCAPE ) { Close(); - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); m_bResetPaintRestrict = true; } else @@ -245,7 +245,7 @@ void CPostCommentaryDialog::OnKeyCodePressed(KeyCode code) if ( code == KEY_XBUTTON_A || code == KEY_XBUTTON_B || code == STEAMCONTROLLER_B ) { Close(); - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); m_bResetPaintRestrict = true; } else diff --git a/gameui/CreateMultiplayerGameServerPage.cpp b/gameui/CreateMultiplayerGameServerPage.cpp index 58f2ad54b..ec37c6c5f 100644 --- a/gameui/CreateMultiplayerGameServerPage.cpp +++ b/gameui/CreateMultiplayerGameServerPage.cpp @@ -165,7 +165,7 @@ void CCreateMultiplayerGameServerPage::OnApplyChanges() //----------------------------------------------------------------------------- void CCreateMultiplayerGameServerPage::LoadMaps( const char *pszPathID ) { - FileFindHandle_t findHandle = NULL; + FileFindHandle_t findHandle = 0; KeyValues *hiddenMaps = ModInfo().GetHiddenMaps(); diff --git a/gameui/LoadGameDialog_Xbox.cpp b/gameui/LoadGameDialog_Xbox.cpp index 742a0ea5c..cdae416b4 100644 --- a/gameui/LoadGameDialog_Xbox.cpp +++ b/gameui/LoadGameDialog_Xbox.cpp @@ -164,7 +164,7 @@ void CLoadGameDialogXbox::OnCommand( const char *command ) } else if ( !Q_stricmp( command, "ReleaseModalWindow" ) ) { - vgui::surface()->RestrictPaintToSinglePanel( NULL ); + vgui::surface()->RestrictPaintToSinglePanel(0); } else if ( !Q_stricmp( command, "DeleteGameCancelled" ) ) { diff --git a/gameui/LoadingDialog.cpp b/gameui/LoadingDialog.cpp index b0d6be665..280c461f5 100644 --- a/gameui/LoadingDialog.cpp +++ b/gameui/LoadingDialog.cpp @@ -110,7 +110,7 @@ CLoadingDialog::~CLoadingDialog() { if ( input()->GetAppModalSurface() == GetVPanel() ) { - vgui::surface()->RestrictPaintToSinglePanel( NULL ); + vgui::surface()->RestrictPaintToSinglePanel(0); } } @@ -265,12 +265,12 @@ void CLoadingDialog::HideOtherDialogs( bool bHide ) if ( GameUI().HasLoadingBackgroundDialog() ) { GameUI().HideLoadingBackgroundDialog(); - vgui::input()->SetAppModalSurface( NULL ); + vgui::input()->SetAppModalSurface(0); } else { // remove any rendering restrictions - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); } } } diff --git a/gameui/NewGameDialog.cpp b/gameui/NewGameDialog.cpp index 36325e3ca..86a38003c 100644 --- a/gameui/NewGameDialog.cpp +++ b/gameui/NewGameDialog.cpp @@ -1597,7 +1597,7 @@ void CNewGameDialog::OnCommand( const char *command ) } else if ( !Q_stricmp( command, "ReleaseModalWindow" ) ) { - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); } else { diff --git a/gameui/OptionsDialog_Xbox.cpp b/gameui/OptionsDialog_Xbox.cpp index 9db9d0ad9..f936d939d 100644 --- a/gameui/OptionsDialog_Xbox.cpp +++ b/gameui/OptionsDialog_Xbox.cpp @@ -541,7 +541,7 @@ void COptionsDialogXbox::OnCommand(const char *command) } else if ( !Q_stricmp( command, "ReleaseModalWindow" ) ) { - vgui::surface()->RestrictPaintToSinglePanel(NULL); + vgui::surface()->RestrictPaintToSinglePanel(0); } else { diff --git a/gameui/SaveGameDialog_Xbox.cpp b/gameui/SaveGameDialog_Xbox.cpp index 610c0a03a..7d09e5a8c 100644 --- a/gameui/SaveGameDialog_Xbox.cpp +++ b/gameui/SaveGameDialog_Xbox.cpp @@ -122,7 +122,6 @@ CAsyncCtxSaveGame::CAsyncCtxSaveGame( CSaveGameDialogXbox *pDlg ) : CBasePanel::CAsyncJobContext( 3.0f ), // Storage device info for at least 3 seconds m_pSaveGameDlg( pDlg ) { - NULL; } void CAsyncCtxSaveGame::ExecuteAsync() @@ -260,7 +259,7 @@ void CSaveGameDialogXbox::OnCommand( const char *command ) } else if ( !Q_stricmp( command, "ReleaseModalWindow" ) ) { - vgui::surface()->RestrictPaintToSinglePanel( NULL ); + vgui::surface()->RestrictPaintToSinglePanel(0); } else if ( !m_bGameSaving ) { diff --git a/gameui/VGuiSystemModuleLoader.cpp b/gameui/VGuiSystemModuleLoader.cpp index 003cdbd71..d554469c8 100644 --- a/gameui/VGuiSystemModuleLoader.cpp +++ b/gameui/VGuiSystemModuleLoader.cpp @@ -161,7 +161,7 @@ bool CVGuiSystemModuleLoader::LoadPlatformModules(CreateInterfaceFn *factorylist { dllPath = it->GetString("dll_osx"); } - else if ( IsLinux() || IsBSD() ) + else if ( IsPosix() ) { dllPath = it->GetString("dll_linux"); } @@ -225,7 +225,7 @@ void CVGuiSystemModuleLoader::ShutdownPlatformModules() int i; for ( i = 0; i < m_Modules.Count(); i++ ) { - vgui::ivgui()->PostMessage(m_Modules[i].moduleInterface->GetPanel(), new KeyValues("Command", "command", "Quit"), NULL); + vgui::ivgui()->PostMessage(m_Modules[i].moduleInterface->GetPanel(), new KeyValues("Command", "command", "Quit"), 0); } for ( i = 0; i < m_Modules.Count(); i++ ) @@ -362,7 +362,7 @@ void CVGuiSystemModuleLoader::PostMessageToAllModules(KeyValues *message) { for (int i = 0; i < m_Modules.Count(); i++) { - vgui::ivgui()->PostMessage(m_Modules[i].moduleInterface->GetPanel(), message->MakeCopy(), NULL); + vgui::ivgui()->PostMessage(m_Modules[i].moduleInterface->GetPanel(), message->MakeCopy(), 0); } message->deleteThis(); } diff --git a/ivp b/ivp index bceb2c427..a583786b4 160000 --- a/ivp +++ b/ivp @@ -1 +1 @@ -Subproject commit bceb2c427255f181a2538ca43369989aa0d983d7 +Subproject commit a583786b4ed92e108327fd5280b7ed97d199aa64 diff --git a/launcher/launcher.cpp b/launcher/launcher.cpp index 0b27da73e..5623c8ced 100644 --- a/launcher/launcher.cpp +++ b/launcher/launcher.cpp @@ -954,7 +954,7 @@ bool GrabSourceMutex() #ifdef ANDROID return true; -#elif defined (LINUX) || defined(PLATFORM_BSD) +#elif defined (POSIX) && !defined(OSX) /* * Linux */ @@ -1205,7 +1205,7 @@ DLL_EXPORT int LauncherMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR DLL_EXPORT int LauncherMain( int argc, char **argv ) #endif { -#if (defined(LINUX) || defined(PLATFORM_BSD)) && !defined ANDROID +#if (defined(POSIX)) && !defined ANDROID // Temporary fix to stop us from crashing in printf/sscanf functions that don't expect // localization to mess with your "." and "," float seperators. Mac OSX also sets LANG // to en_US.UTF-8 before starting up (in info.plist I believe). @@ -1232,7 +1232,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv ) Msg("SDL version: %d.%d.%d rev: %s\n", (int)ver.major, (int)ver.minor, (int)ver.patch, SDL_GetRevision()); #endif -#if (defined LINUX || defined PLATFORM_BSD) && defined USE_SDL && defined TOGLES && !defined ANDROID +#if defined POSIX && defined USE_SDL && defined TOGLES && !defined ANDROID SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1"); #endif @@ -1560,7 +1560,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv ) RegCloseKey(hKey); } -#elif defined( OSX ) || defined( LINUX ) || defined(PLATFORM_BSD) +#elif defined( POSIX ) struct stat st; if ( stat( RELAUNCH_FILE, &st ) == 0 ) { diff --git a/materialsystem/cmatrendercontext.cpp b/materialsystem/cmatrendercontext.cpp index 0e3721278..d3f5cebe8 100644 --- a/materialsystem/cmatrendercontext.cpp +++ b/materialsystem/cmatrendercontext.cpp @@ -2346,7 +2346,7 @@ void CMatRenderContext::CopyRenderTargetToTextureEx( ITexture *pTexture, int nRe void CMatRenderContext::CopyRenderTargetToTexture( ITexture *pTexture ) { - CopyRenderTargetToTextureEx( pTexture, NULL, NULL ); + CopyRenderTargetToTextureEx( pTexture, 0, NULL ); } @@ -3039,7 +3039,7 @@ void CMatRenderContext::AsyncMap( ITextureInternal* pTexToMap, IAsyncTextureOper } void* pMemory = NULL; - int nPitch = NULL; + int nPitch = 0; pTexToMap->Map( &pMemory, &nPitch ); diff --git a/materialsystem/shaderapidx9/wscript b/materialsystem/shaderapidx9/wscript index dba874698..017bccc11 100755 --- a/materialsystem/shaderapidx9/wscript +++ b/materialsystem/shaderapidx9/wscript @@ -66,6 +66,7 @@ def build(bld): ] + bld.env.INCLUDES_SDL2 defines = [] + defines.append('_FORTIFY_SOURCE=0') libs = ['tier0','tier1','tier2','vstdlib','togl','bitmap','mathlib'] diff --git a/materialsystem/stdshaders/wscript b/materialsystem/stdshaders/wscript index 4d82e5153..73f9744d3 100644 --- a/materialsystem/stdshaders/wscript +++ b/materialsystem/stdshaders/wscript @@ -141,6 +141,7 @@ def build(bld): includes = [ '.', + '../../common', '../../public', '../../public/tier0', '../../public/tier1', diff --git a/materialsystem/wscript b/materialsystem/wscript index 7a758c590..f3d1dbbb4 100755 --- a/materialsystem/wscript +++ b/materialsystem/wscript @@ -58,6 +58,7 @@ def build(bld): ] + bld.env.INCLUDES_SDL2 defines = [] + defines.append('_FORTIFY_SOURCE=0') libs = ['tier0','tier1','tier2','vstdlib','mathlib','bitmap','shaderlib','vtf'] diff --git a/mathlib/3dnow.cpp b/mathlib/3dnow.cpp index 88e4ead7c..599a22e87 100644 --- a/mathlib/3dnow.cpp +++ b/mathlib/3dnow.cpp @@ -16,7 +16,7 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -#if !defined(COMPILER_MSVC64) && !defined(LINUX) && !defined(COMPILER_CLANG) +#if !defined(COMPILER_MSVC64) && !defined(POSIX) && !defined(COMPILER_CLANG) // Implement for 64-bit Windows if needed. // Clang hits "fatal error: error in backend:" and other errors when trying // to compile the inline assembly below. 3DNow support is highly unlikely to diff --git a/mathlib/mathlib_base.cpp b/mathlib/mathlib_base.cpp index 3b8fbe2fa..50904802d 100644 --- a/mathlib/mathlib_base.cpp +++ b/mathlib/mathlib_base.cpp @@ -3343,7 +3343,7 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright // SSE Generally performs better than 3DNow when present, so this is placed // first to allow SSE to override these settings. -#if !defined( OSX ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined(LINUX) && !defined(PLATFORM_BSD) +#if !defined( OSX ) && !defined( PLATFORM_WINDOWS_PC64 ) && !defined(POSIX) if ( bAllow3DNow && pi.m_b3DNow ) { s_b3DNowEnabled = true; diff --git a/public/appframework/AppFramework.h b/public/appframework/AppFramework.h index 4df8a2b85..ad4c5f3e6 100644 --- a/public/appframework/AppFramework.h +++ b/public/appframework/AppFramework.h @@ -61,7 +61,7 @@ void AppShutdown( CAppSystemGroup *pAppSystemGroup ); extern int ValveCocoaMain( int argc, char **argv, CAppSystemGroup *pAppSystemGroup ); \ return ValveCocoaMain( argc, argv, &_globalVarName ); \ } -#elif defined( LINUX ) || defined(PLATFORM_BSD) +#elif defined(POSIX) #define DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( _globalVarName ) \ int main( int argc, char **argv ) \ { \ diff --git a/public/appframework/ilaunchermgr.h b/public/appframework/ilaunchermgr.h index b7011ca12..4a3e79154 100644 --- a/public/appframework/ilaunchermgr.h +++ b/public/appframework/ilaunchermgr.h @@ -52,7 +52,7 @@ class ILauncherMgr : public IAppSystem // Get the next N events. The function returns the number of events that were filled into your array. virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ) = 0; -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) && !defined(OSX) virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvents = false ) = 0; #endif diff --git a/public/datamap.h b/public/datamap.h index 2f4edbf57..123e23b50 100644 --- a/public/datamap.h +++ b/public/datamap.h @@ -134,47 +134,47 @@ DECLARE_FIELD_SIZE( FIELD_MATERIALINDEX, sizeof(int) ) #define _offsetof(s,m) ((int)(intp)&(((s *)0)->m)) -#define _FIELD(name,fieldtype,count,flags,mapname,tolerance) { fieldtype, #name, { _offsetof(classNameTypedef, name), 0 }, count, flags, mapname, NULL, NULL, NULL, sizeof( ((classNameTypedef *)0)->name ), NULL, 0, tolerance } +#define _FIELD(name,fieldtype,count,flags,mapname,tolerance) { fieldtype, #name, { _offsetof(classNameTypedef, name), 0 }, count, flags, mapname, 0, 0, 0, sizeof( ((classNameTypedef *)0)->name ), 0, 0, tolerance } #define DEFINE_FIELD_NULL { FIELD_VOID,0, {0,0},0,0,0,0,0,0} -#define DEFINE_FIELD(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_SAVE, NULL, 0 ) +#define DEFINE_FIELD(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_SAVE, 0, 0 ) #define DEFINE_KEYFIELD(name,fieldtype, mapname) _FIELD(name, fieldtype, 1, FTYPEDESC_KEY | FTYPEDESC_SAVE, mapname, 0 ) #define DEFINE_KEYFIELD_NOT_SAVED(name,fieldtype, mapname)_FIELD(name, fieldtype, 1, FTYPEDESC_KEY, mapname, 0 ) -#define DEFINE_AUTO_ARRAY(name,fieldtype) _FIELD(name, fieldtype, SIZE_OF_ARRAY(((classNameTypedef *)0)->name), FTYPEDESC_SAVE, NULL, 0 ) +#define DEFINE_AUTO_ARRAY(name,fieldtype) _FIELD(name, fieldtype, SIZE_OF_ARRAY(((classNameTypedef *)0)->name), FTYPEDESC_SAVE, 0, 0 ) #define DEFINE_AUTO_ARRAY_KEYFIELD(name,fieldtype,mapname) _FIELD(name, fieldtype, SIZE_OF_ARRAY(((classNameTypedef *)0)->name), FTYPEDESC_SAVE, mapname, 0 ) -#define DEFINE_ARRAY(name,fieldtype, count) _FIELD(name, fieldtype, count, FTYPEDESC_SAVE, NULL, 0 ) +#define DEFINE_ARRAY(name,fieldtype, count) _FIELD(name, fieldtype, count, FTYPEDESC_SAVE, 0, 0 ) #define DEFINE_ENTITY_FIELD(name,fieldtype) _FIELD(edict_t, name, fieldtype, 1, FTYPEDESC_KEY | FTYPEDESC_SAVE, #name, 0 ) #define DEFINE_ENTITY_GLOBAL_FIELD(name,fieldtype) _FIELD(edict_t, name, fieldtype, 1, FTYPEDESC_KEY | FTYPEDESC_SAVE | FTYPEDESC_GLOBAL, #name, 0 ) -#define DEFINE_GLOBAL_FIELD(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_GLOBAL | FTYPEDESC_SAVE, NULL, 0 ) +#define DEFINE_GLOBAL_FIELD(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_GLOBAL | FTYPEDESC_SAVE, 0, 0 ) #define DEFINE_GLOBAL_KEYFIELD(name,fieldtype, mapname) _FIELD(name, fieldtype, 1, FTYPEDESC_GLOBAL | FTYPEDESC_KEY | FTYPEDESC_SAVE, mapname, 0 ) -#define DEFINE_CUSTOM_FIELD(name,datafuncs) { FIELD_CUSTOM, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, datafuncs, NULL } -#define DEFINE_CUSTOM_KEYFIELD(name,datafuncs,mapname) { FIELD_CUSTOM, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_KEY, mapname, datafuncs, NULL } -#define DEFINE_AUTO_ARRAY2D(name,fieldtype) _FIELD(name, fieldtype, ARRAYSIZE2D(((classNameTypedef *)0)->name), FTYPEDESC_SAVE, NULL, 0 ) +#define DEFINE_CUSTOM_FIELD(name,datafuncs) { FIELD_CUSTOM, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, 0, datafuncs, 0 } +#define DEFINE_CUSTOM_KEYFIELD(name,datafuncs,mapname) { FIELD_CUSTOM, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_KEY, mapname, datafuncs, 0 } +#define DEFINE_AUTO_ARRAY2D(name,fieldtype) _FIELD(name, fieldtype, ARRAYSIZE2D(((classNameTypedef *)0)->name), FTYPEDESC_SAVE, 0, 0 ) // Used by byteswap datadescs #define DEFINE_BITFIELD(name,fieldtype,bitcount) DEFINE_ARRAY(name,fieldtype,((bitcount+FIELD_BITS(fieldtype)-1)&~(FIELD_BITS(fieldtype)-1)) / FIELD_BITS(fieldtype) ) -#define DEFINE_INDEX(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_INDEX, NULL, 0 ) +#define DEFINE_INDEX(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_INDEX, 0, 0 ) #define DEFINE_EMBEDDED( name ) \ - { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name.m_DataMap), sizeof( ((classNameTypedef *)0)->name ), NULL, 0, 0.0f } + { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, 0, 0, 0, &(((classNameTypedef *)0)->name.m_DataMap), sizeof( ((classNameTypedef *)0)->name ), 0, 0, 0.0f } #define DEFINE_EMBEDDED_OVERRIDE( name, overridetype ) \ - { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &((overridetype *)0)->m_DataMap, sizeof( ((classNameTypedef *)0)->name ), NULL, 0, 0.0f } + { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, 0, 0, 0, &((overridetype *)0)->m_DataMap, sizeof( ((classNameTypedef *)0)->name ), 0, 0, 0.0f } #define DEFINE_EMBEDDEDBYREF( name ) \ - { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_PTR, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( *(((classNameTypedef *)0)->name) ), NULL, 0, 0.0f } + { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_PTR, 0, 0, 0, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( *(((classNameTypedef *)0)->name) ), 0, 0, 0.0f } #define DEFINE_EMBEDDED_ARRAY( name, count ) \ - { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, count, FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( ((classNameTypedef *)0)->name[0] ), NULL, 0, 0.0f } + { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, count, FTYPEDESC_SAVE, 0, 0, 0, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( ((classNameTypedef *)0)->name[0] ), 0, 0, 0.0f } #define DEFINE_EMBEDDED_AUTO_ARRAY( name ) \ - { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, SIZE_OF_ARRAY( ((classNameTypedef *)0)->name ), FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( ((classNameTypedef *)0)->name[0] ), NULL, 0, 0.0f } + { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, SIZE_OF_ARRAY( ((classNameTypedef *)0)->name ), FTYPEDESC_SAVE, 0, 0, 0, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( ((classNameTypedef *)0)->name[0] ), 0, 0, 0.0f } #ifndef NO_ENTITY_PREDICTION #define DEFINE_PRED_TYPEDESCRIPTION( name, fieldtype ) \ - { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &fieldtype::m_PredMap } + { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, 0, 0, 0, &fieldtype::m_PredMap } #define DEFINE_PRED_TYPEDESCRIPTION_PTR( name, fieldtype ) \ - { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_PTR, NULL, NULL, NULL, &fieldtype::m_PredMap } + { FIELD_EMBEDDED, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_PTR, 0, 0, 0, &fieldtype::m_PredMap } #else @@ -184,19 +184,19 @@ DECLARE_FIELD_SIZE( FIELD_MATERIALINDEX, sizeof(int) ) #endif // Extensions to datamap.h macros for predicted entities only -#define DEFINE_PRED_FIELD(name,fieldtype, flags) _FIELD(name, fieldtype, 1, flags, NULL, 0.0f ) -#define DEFINE_PRED_ARRAY(name,fieldtype, count,flags) _FIELD(name, fieldtype, count, flags, NULL, 0.0f ) +#define DEFINE_PRED_FIELD(name,fieldtype, flags) _FIELD(name, fieldtype, 1, flags, 0, 0.0f ) +#define DEFINE_PRED_ARRAY(name,fieldtype, count,flags) _FIELD(name, fieldtype, count, flags, 0, 0.0f ) #define DEFINE_FIELD_NAME(localname,netname,fieldtype) _FIELD(localname, fieldtype, 1, 0, #netname, 0.0f ) // Predictable macros, which include a tolerance for floating point values... -#define DEFINE_PRED_FIELD_TOL(name,fieldtype, flags,tolerance) _FIELD(name, fieldtype, 1, flags, NULL, tolerance ) -#define DEFINE_PRED_ARRAY_TOL(name,fieldtype, count,flags,tolerance) _FIELD(name, fieldtype, count, flags, NULL, tolerance) +#define DEFINE_PRED_FIELD_TOL(name,fieldtype, flags,tolerance) _FIELD(name, fieldtype, 1, flags, 0, tolerance ) +#define DEFINE_PRED_ARRAY_TOL(name,fieldtype, count,flags,tolerance) _FIELD(name, fieldtype, count, flags, 0, tolerance) #define DEFINE_FIELD_NAME_TOL(localname,netname,fieldtolerance) _FIELD(localname, fieldtype, 1, 0, #netname, tolerance ) //#define DEFINE_DATA( name, fieldextname, flags ) _FIELD(name, fieldtype, 1, flags, extname ) // INPUTS -#define DEFINE_INPUT( name, fieldtype, inputname ) { fieldtype, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_INPUT | FTYPEDESC_SAVE | FTYPEDESC_KEY, inputname, NULL, NULL, NULL, sizeof( ((classNameTypedef *)0)->name ) } -#define DEFINE_INPUTFUNC( fieldtype, inputname, inputfunc ) { fieldtype, #inputfunc, { NULL, NULL }, 1, FTYPEDESC_INPUT, inputname, NULL, static_cast (&classNameTypedef::inputfunc) } +#define DEFINE_INPUT( name, fieldtype, inputname ) { fieldtype, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_INPUT | FTYPEDESC_SAVE | FTYPEDESC_KEY, inputname, 0, 0, 0, sizeof( ((classNameTypedef *)0)->name ) } +#define DEFINE_INPUTFUNC( fieldtype, inputname, inputfunc ) { fieldtype, #inputfunc, { 0, 0 }, 1, FTYPEDESC_INPUT, inputname, 0, static_cast (&classNameTypedef::inputfunc) } // OUTPUTS // the variable 'name' MUST BE derived from CBaseOutput @@ -206,7 +206,7 @@ extern ISaveRestoreOps *eventFuncs; #define DEFINE_OUTPUT( name, outputname ) { FIELD_CUSTOM, #name, { _offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_OUTPUT | FTYPEDESC_SAVE | FTYPEDESC_KEY, outputname, eventFuncs } // replaces EXPORT table for portability and non-DLL based systems (xbox) -#define DEFINE_FUNCTION_RAW( function, func_type ) { FIELD_VOID, nameHolder.GenerateName(#function), { NULL, NULL }, 1, FTYPEDESC_FUNCTIONTABLE, NULL, NULL, (inputfunc_t)((func_type)(&classNameTypedef::function)) } +#define DEFINE_FUNCTION_RAW( function, func_type ) { FIELD_VOID, nameHolder.GenerateName(#function), { 0, 0 }, 1, FTYPEDESC_FUNCTIONTABLE, 0, 0, (inputfunc_t)((func_type)(&classNameTypedef::function)) } #define DEFINE_FUNCTION( function ) DEFINE_FUNCTION_RAW( function, inputfunc_t ) @@ -325,24 +325,24 @@ struct datamap_t virtual datamap_t *GetDataDescMap( void ); #define BEGIN_DATADESC( className ) \ - datamap_t className::m_DataMap = { 0, 0, #className, NULL }; \ + datamap_t className::m_DataMap = { 0, 0, #className, 0 }; \ datamap_t *className::GetDataDescMap( void ) { return &m_DataMap; } \ datamap_t *className::GetBaseMap() { datamap_t *pResult; DataMapAccess((BaseClass *)NULL, &pResult); return pResult; } \ BEGIN_DATADESC_GUTS( className ) #define BEGIN_DATADESC_NO_BASE( className ) \ - datamap_t className::m_DataMap = { 0, 0, #className, NULL }; \ + datamap_t className::m_DataMap = { 0, 0, #className, 0 }; \ datamap_t *className::GetDataDescMap( void ) { return &m_DataMap; } \ datamap_t *className::GetBaseMap() { return NULL; } \ BEGIN_DATADESC_GUTS( className ) #define BEGIN_SIMPLE_DATADESC( className ) \ - datamap_t className::m_DataMap = { 0, 0, #className, NULL }; \ + datamap_t className::m_DataMap = { 0, 0, #className, 0 }; \ datamap_t *className::GetBaseMap() { return NULL; } \ BEGIN_DATADESC_GUTS( className ) #define BEGIN_SIMPLE_DATADESC_( className, BaseClass ) \ - datamap_t className::m_DataMap = { 0, 0, #className, NULL }; \ + datamap_t className::m_DataMap = { 0, 0, #className, 0 }; \ datamap_t *className::GetBaseMap() { datamap_t *pResult; DataMapAccess((BaseClass *)NULL, &pResult); return pResult; } \ BEGIN_DATADESC_GUTS( className ) diff --git a/public/filesystem_init.cpp b/public/filesystem_init.cpp index d309efcd3..87dc82d4b 100644 --- a/public/filesystem_init.cpp +++ b/public/filesystem_init.cpp @@ -639,7 +639,7 @@ FSReturnCode_t FileSystem_LoadSearchPaths( CFSSearchPathsInit &initInfo ) } else { - FileFindHandle_t findHandle = NULL; + FileFindHandle_t findHandle = 0; const char *pszFoundShortName = initInfo.m_pFileSystem->FindFirst( szAbsSearchPath, &findHandle ); if ( pszFoundShortName ) { diff --git a/public/tier0/platform.h b/public/tier0/platform.h index 99ac5b3b3..eebf9d01d 100644 --- a/public/tier0/platform.h +++ b/public/tier0/platform.h @@ -63,15 +63,22 @@ #define NEW_SOFTWARE_LIGHTING #ifdef POSIX -// need this for _alloca # ifdef PLATFORM_BSD # define va_list __va_list # else +// need this for _alloca # include # endif -#include -#include -#include +# include +# include +# include +#endif + +#ifdef LINUX +# include +# ifdef __GLIBC__ +# define PLATFORM_GLIBC 1 +# endif #endif #ifdef OSX @@ -1404,11 +1411,11 @@ PLATFORM_INTERFACE void* Plat_SimpleLog( const tchar* file, int line ); //----------------------------------------------------------------------------- // Returns true if debugger attached, false otherwise //----------------------------------------------------------------------------- -#if defined(_WIN32) || defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#if defined(_WIN32) || defined(POSIX) PLATFORM_INTERFACE bool Plat_IsInDebugSession(); PLATFORM_INTERFACE void Plat_DebugString( const char * ); #else -#warning "Plat_IsInDebugSession isn't working properly" +#error "Plat_IsInDebugSession isn't working properly" inline bool Plat_IsInDebugSession( bool bForceRecheck = false ) { return false; } #define Plat_DebugString(s) ((void)0) #endif diff --git a/public/tier0/threadtools.h b/public/tier0/threadtools.h index b72161937..1077c2d8e 100644 --- a/public/tier0/threadtools.h +++ b/public/tier0/threadtools.h @@ -319,7 +319,7 @@ PLATFORM_INTERFACE void ThreadSetAffinity( ThreadHandle_t hThread, int nAffinity #error Every platform needs to define ThreadMemoryBarrier to at least prevent compiler reordering #endif -#if defined( _LINUX ) || defined( _OSX ) || defined(PLATFORM_BSD) +#if defined(POSIX) #define USE_INTRINSIC_INTERLOCKED // linux implementation inline int32 ThreadInterlockedIncrement( int32 volatile *p ) @@ -520,7 +520,7 @@ PLATFORM_INTERFACE void ThreadNotifySyncReleasing(void *p); #ifndef NO_THREAD_LOCAL -#if defined(WIN32) || defined(OSX) || defined( _PS3 ) || ( defined (_LINUX) ) || defined(PLATFORM_BSD) +#if defined(WIN32) || defined(POSIX) || defined( _PS3 ) #ifndef __AFXTLS_H__ // not compatible with some Windows headers #if defined(_PS3) diff --git a/public/vgui/VGUI.h b/public/vgui/VGUI.h index f72630c8c..fa71f960a 100644 --- a/public/vgui/VGUI.h +++ b/public/vgui/VGUI.h @@ -16,7 +16,8 @@ #define NeedProportional() (IsAndroid() || CommandLine()->CheckParm("-gameuiproportionality")) -#ifndef NULL +#if !defined(NULL) || !defined(PLATFORM_GLIBC) +#undef NULL #ifdef __cplusplus #define NULL 0 #else diff --git a/public/vgui_controls/FocusNavGroup.h b/public/vgui_controls/FocusNavGroup.h index 2d7435123..28a65912c 100644 --- a/public/vgui_controls/FocusNavGroup.h +++ b/public/vgui_controls/FocusNavGroup.h @@ -34,8 +34,8 @@ class FocusNavGroup virtual VPANEL GetDefaultButton(); // panel which receives default input when ENTER is hit, if current focused item cannot accept ENTER virtual VPANEL GetCurrentDefaultButton(); // panel which receives input when ENTER is hit virtual Panel *FindPanelByHotkey(wchar_t key); // finds the panel which is activated by the specified key - virtual bool RequestFocusPrev(VPANEL panel = NULL); // if panel is NULL, then the tab increment is based last known panel that had key focus - virtual bool RequestFocusNext(VPANEL panel = NULL); + virtual bool RequestFocusPrev(VPANEL panel = 0); // if panel is NULL, then the tab increment is based last known panel that had key focus + virtual bool RequestFocusNext(VPANEL panel = 0); virtual Panel *GetCurrentFocus(); virtual VPANEL SetCurrentFocus(VPANEL panel, VPANEL defaultPanel); // returns the Default panel diff --git a/public/vgui_controls/Panel.h b/public/vgui_controls/Panel.h index 0a3aa41a2..d9279c790 100644 --- a/public/vgui_controls/Panel.h +++ b/public/vgui_controls/Panel.h @@ -318,8 +318,8 @@ class Panel : public IClientPanel, virtual public IForceVirtualInheritancePanel virtual void RequestFocus(int direction = 0); virtual bool HasFocus(); virtual void InvalidateLayout(bool layoutNow = false, bool reloadScheme = false); - virtual bool RequestFocusPrev(VPANEL panel = NULL); - virtual bool RequestFocusNext(VPANEL panel = NULL); + virtual bool RequestFocusPrev(VPANEL panel = 0); + virtual bool RequestFocusNext(VPANEL panel = 0); // tab positioning virtual void SetTabPosition(int position); virtual int GetTabPosition(); diff --git a/public/vgui_controls/PropertySheet.h b/public/vgui_controls/PropertySheet.h index d6fdf88dd..b8888617c 100644 --- a/public/vgui_controls/PropertySheet.h +++ b/public/vgui_controls/PropertySheet.h @@ -64,8 +64,8 @@ class PropertySheet : public EditablePanel // focus handling - passed on to current active page virtual void RequestFocus(int direction = 0); - virtual bool RequestFocusPrev(VPANEL panel = NULL); - virtual bool RequestFocusNext(VPANEL panel = NULL); + virtual bool RequestFocusPrev(VPANEL panel = 0); + virtual bool RequestFocusNext(VPANEL panel = 0); // returns the ith panel virtual Panel *GetPage(int i); diff --git a/scenefilecache/SceneFileCache.cpp b/scenefilecache/SceneFileCache.cpp index 18f673155..ec5fbad6f 100644 --- a/scenefilecache/SceneFileCache.cpp +++ b/scenefilecache/SceneFileCache.cpp @@ -280,7 +280,7 @@ bool CSceneFileCache::GetSceneDataFromImage( const char *pFileName, int iScene, { if ( pSceneData ) { - *pSceneData = NULL; + *pSceneData = 0; } if ( pSceneLength ) { diff --git a/serverbrowser/ServerBrowserDialog.cpp b/serverbrowser/ServerBrowserDialog.cpp index 2ba47348c..7c177a639 100644 --- a/serverbrowser/ServerBrowserDialog.cpp +++ b/serverbrowser/ServerBrowserDialog.cpp @@ -25,7 +25,7 @@ #define WIN32_LEAN_AND_MEAN #include #endif -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) #include #endif diff --git a/tier0/assert_dialog.cpp b/tier0/assert_dialog.cpp index e13b47e0b..985720ee8 100644 --- a/tier0/assert_dialog.cpp +++ b/tier0/assert_dialog.cpp @@ -386,7 +386,7 @@ DBG_INTERFACE bool ShouldUseNewAssertDialog() #endif // DBGFLAG_ASSERTDLG } -#if defined( POSIX ) && !defined ( ANDROID ) +#if defined( POSIX ) && defined ( PLATFORM_GCC ) #include @@ -441,7 +441,7 @@ DBG_INTERFACE bool DoNewAssertDialog( const tchar *pFilename, int line, const tc pFilename, line, pExpression); if ( getenv( "POSIX_ASSERT_BACKTRACE" ) ) { -#if !defined ( ANDROID ) +#if defined ( PLATFORM_GCC ) SpewBacktrace(); #endif } diff --git a/tier0/cpu_posix.cpp b/tier0/cpu_posix.cpp index a86f40a77..9b979fd1c 100644 --- a/tier0/cpu_posix.cpp +++ b/tier0/cpu_posix.cpp @@ -10,7 +10,7 @@ #ifdef LINUX #include #else -#include +# include # ifdef __APPLE__ # define CPUFREQ_SYSCTL "hw.cpufrequency_max" # else @@ -101,7 +101,7 @@ uint64 GetCPUFreqFromPROC() uint64 CalculateCPUFreq() { -#if defined(__APPLE__) || defined(PLATFORM_BSD) +#if !defined(LINUX) return GetCPUFreqFromPROC(); #else // Try to open cpuinfo_max_freq. If the kernel was built with cpu scaling support disabled, this will fail. diff --git a/tier0/platform_posix.cpp b/tier0/platform_posix.cpp index 425f8cff5..ca0e776f8 100644 --- a/tier0/platform_posix.cpp +++ b/tier0/platform_posix.cpp @@ -16,7 +16,7 @@ #include #include -#if defined(OSX) || defined(PLATFORM_BSD) +#if defined(OSX) || defined(PLATFORM_FBSD) # ifdef PLATFORM_BSD # include # include @@ -446,6 +446,9 @@ PLATFORM_INTERFACE void Plat_SetAllocErrorFn( Plat_AllocErrorFn fn ) // From the Apple tech note: http://developer.apple.com/library/mac/#qa/qa1361/_index.html bool Plat_IsInDebugSession() { +#if defined(PLATFORM_BSD) && !defined(PLATFORM_FBSD) + return false; // TODO: OpenBSD and NetBSD support +#else static int s_IsInDebugSession; int junk; struct kinfo_proc info; @@ -466,6 +469,7 @@ bool Plat_IsInDebugSession() #endif return !!s_IsInDebugSession; +#endif } #elif defined( LINUX ) @@ -502,6 +506,14 @@ bool Plat_IsInDebugSession() return ( tracerpid > 0 ); } +#else +# warning "TODO: Plat_IsInDebugSession()" + +bool Plat_IsInDebugSession() +{ + return false; +} + #endif // defined( LINUX ) void Plat_DebugString( const char * psz ) @@ -559,11 +571,7 @@ PLATFORM_INTERFACE const char *Plat_GetCommandLineA() PLATFORM_INTERFACE bool GetMemoryInformation( MemoryInformation *pOutMemoryInfo ) { - #if defined( LINUX ) || defined( OSX ) || defined(PLATFORM_BSD) - return false; - #else - #error "Need to fill out GetMemoryInformation or at least return false for this platform" - #endif + return false; } @@ -571,7 +579,7 @@ PLATFORM_INTERFACE bool Is64BitOS() { #if defined OSX return true; -#elif defined(LINUX) || defined(PLATFORM_BSD) +#elif defined(POSIX) FILE *pp = popen( "uname -m", "r" ); if ( pp != NULL ) { diff --git a/tier0/stacktools.cpp b/tier0/stacktools.cpp index f32dc4d52..fc33c5824 100644 --- a/tier0/stacktools.cpp +++ b/tier0/stacktools.cpp @@ -27,7 +27,7 @@ #include #endif -#if defined( LINUX ) && !defined( ANDROID ) +#if defined( LINUX ) && defined(PLATFORM_GLIBC) #include #endif @@ -38,7 +38,7 @@ #if !defined( ENABLE_RUNTIME_STACK_TRANSLATION ) //disable the whole toolset -#if defined( LINUX ) && !defined( ANDROID ) +#if defined( LINUX ) && defined(PLATFORM_GLIBC) int GetCallStack( void **pReturnAddressesOut, int iArrayCount, int iSkipCount ) { diff --git a/tier0/threadtools.cpp b/tier0/threadtools.cpp index 06c8296f5..9ec774cfd 100644 --- a/tier0/threadtools.cpp +++ b/tier0/threadtools.cpp @@ -27,13 +27,8 @@ #define GetLastError() errno typedef void *LPVOID; #if !defined(OSX) -#if defined(ANDROID) #include #include -#else - #include - #include -#endif #define sem_unlink( arg ) #define OS_TO_PTHREAD(x) (x) #else @@ -1632,7 +1627,7 @@ bool CThreadFullMutex::Release() // //----------------------------------------------------------------------------- -#if defined( WIN32 ) || defined( _PS3 ) || defined( _OSX ) || defined (_LINUX) || defined(PLATFORM_BSD) +#if defined( WIN32 ) || defined( _PS3 ) || defined(POSIX) #if !defined(_PS3) namespace GenericThreadLocals { diff --git a/tier0/wscript b/tier0/wscript index b02c60bf8..83b14787b 100755 --- a/tier0/wscript +++ b/tier0/wscript @@ -17,6 +17,9 @@ def configure(conf): conf.define('TIER0_DLL_EXPORT',1) # conf.define('NO_HOOK_MALLOC',1) + if conf.env.DEST_OS == 'freebsd': + conf.check_cc(lib='execinfo') + def build(bld): source = [ 'assert_dialog.cpp', @@ -82,6 +85,7 @@ def build(bld): libs = ['ADVAPI32', 'WS2_32'] else: libs = ['DL', 'M', 'LOG'] + if bld.env.DEST_OS == 'freebsd': libs += ['EXECINFO'] install_path = bld.env.LIBDIR diff --git a/tier1/KeyValues.cpp b/tier1/KeyValues.cpp index 75664e435..45823e2f2 100644 --- a/tier1/KeyValues.cpp +++ b/tier1/KeyValues.cpp @@ -2239,7 +2239,7 @@ bool EvaluateConditional( const char *str ) return bNot; if ( Q_stristr( str, "$LINUX" ) ) - return ( IsLinux() || IsBSD() || IsOSX() ) ^ bNot; + return ( IsPosix() ) ^ bNot; if ( Q_stristr( str, "$POSIX" ) ) return IsPosix() ^ bNot; diff --git a/tier1/interface.cpp b/tier1/interface.cpp index 47fda8f94..b72cb734c 100644 --- a/tier1/interface.cpp +++ b/tier1/interface.cpp @@ -323,7 +323,7 @@ CSysModule *Sys_LoadModule( const char *pModuleName, Sys_Flags flags /* = SYS_NO #ifdef POSIX char szModuleName[1024] = { 0 }; #endif - HMODULE hDLL = NULL; + HMODULE hDLL = 0; if ( !Q_IsAbsolutePath( pModuleName ) ) { diff --git a/tier1/strtools.cpp b/tier1/strtools.cpp index ce1adb0ca..610717d3b 100644 --- a/tier1/strtools.cpp +++ b/tier1/strtools.cpp @@ -82,7 +82,7 @@ #ifdef ANDROID #include "common/iconv.h" #elif POSIX -#include +# include #endif static int FastToLower( char c ) @@ -2090,7 +2090,7 @@ bool V_ExtractFilePath (const char *path, char *dest, int destSize ) //----------------------------------------------------------------------------- void V_ExtractFileExtension( const char *path, char *dest, int destSize ) { - *dest = NULL; + *dest = '\0'; const char * extension = V_GetFileExtension( path ); if ( NULL != extension ) V_strncpy( dest, extension, destSize ); @@ -2953,11 +2953,11 @@ extern "C" void qsort_s( void *base, size_t num, size_t width, int (*compare )(v void V_qsort_s( void *base, size_t num, size_t width, int ( __cdecl *compare )(void *, const void *, const void *), void * context ) { -#if defined(OSX) || defined(PLATFORM_BSD) - // the arguments are swapped 'round on the mac - awesome, huh? - return qsort_r( base, num, width, context, compare ); -#else +#if defined(_WIN32) || defined(LINUX) + // the arguments are swapped 'round on the win32 - awesome, huh? return qsort_s( base, num, width, compare, context ); +#else + return qsort_r( base, num, width, context, compare ); #endif } diff --git a/tier1/wscript b/tier1/wscript index 0a5f684b5..5fa514b80 100755 --- a/tier1/wscript +++ b/tier1/wscript @@ -75,8 +75,7 @@ def build(bld): '../', '../public', '../public/tier1', - '../public/tier0', - '../common' + '../public/tier0' ] defines = [] diff --git a/togl/linuxwin/dxabstract.cpp b/togl/linuxwin/dxabstract.cpp index 45100948d..e0f6e6c0d 100644 --- a/togl/linuxwin/dxabstract.cpp +++ b/togl/linuxwin/dxabstract.cpp @@ -38,7 +38,7 @@ #include "glmgr_flush.inl" -#if defined(OSX) || defined(LINUX) || (defined (WIN32) && defined( DX_TO_GL_ABSTRACTION )) || defined(PLATFORM_BSD) +#if defined(POSIX) || (defined (WIN32) && defined( DX_TO_GL_ABSTRACTION )) #include "appframework/ilaunchermgr.h" extern ILauncherMgr *g_pLauncherMgr; #endif diff --git a/togl/linuxwin/glentrypoints.cpp b/togl/linuxwin/glentrypoints.cpp index 621ab394f..0d0005b53 100644 --- a/togl/linuxwin/glentrypoints.cpp +++ b/togl/linuxwin/glentrypoints.cpp @@ -54,7 +54,7 @@ #error #endif -#if defined(OSX) || defined(LINUX) || (defined (WIN32) && defined( DX_TO_GL_ABSTRACTION )) || defined(PLATFORM_BSD) +#if defined(POSIX) || (defined (WIN32) && defined( DX_TO_GL_ABSTRACTION )) #include "appframework/ilaunchermgr.h" ILauncherMgr *g_pLauncherMgr = NULL; #endif diff --git a/togl/linuxwin/glmgr.cpp b/togl/linuxwin/glmgr.cpp index 745862b1b..e2fb33fa4 100644 --- a/togl/linuxwin/glmgr.cpp +++ b/togl/linuxwin/glmgr.cpp @@ -1975,7 +1975,7 @@ void GLMContext::DelBuffer( CGLMBuffer *buff ) } } - BindGLBufferToCtx( buff->m_buffGLTarget, NULL, false ); + BindGLBufferToCtx( buff->m_buffGLTarget, 0, false ); delete buff; } diff --git a/togl/linuxwin/glmgrbasics.cpp b/togl/linuxwin/glmgrbasics.cpp index 7a02f7f3b..cd9c7cd71 100644 --- a/togl/linuxwin/glmgrbasics.cpp +++ b/togl/linuxwin/glmgrbasics.cpp @@ -2628,11 +2628,6 @@ bool GLMDetectOGLP( void ) #include #ifndef _WIN32 #include -#ifdef LINUX -#include -#else -#include -#endif #endif // From Technical Q&A QA1361 @@ -2643,43 +2638,7 @@ bool GLMDetectOGLP( void ) bool GLMDetectGDB( void ) // aka AmIBeingDebugged() { -#ifdef OSX - bool result; - int junk; - int mib[4]; - struct kinfo_proc info; - size_t size; - - // Initialize the flags so that, - // if sysctl fails for some bizarre - // reason, we get a predictable result. - - info.kp_proc.p_flag = 0; - - // Initialize mib, which tells sysctl the info - // we want, in this case we're looking for - // information about a specific process ID. - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); - - // Call sysctl. - - size = sizeof(info); - junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); - - assert(junk == 0); - - // We're being debugged if the P_TRACED - // flag is set. - - result = ( (info.kp_proc.p_flag & P_TRACED) != 0 ); - return result; -#else return Sys_IsDebuggerPresent(); -#endif } diff --git a/togl/wscript b/togl/wscript index 9d55d56db..f41ead694 100755 --- a/togl/wscript +++ b/togl/wscript @@ -43,6 +43,7 @@ def build(bld): ] + bld.env.INCLUDES_SDL2 defines = [] + defines.append('_FORTIFY_SOURCE=0') libs = ['tier0','tier1','tier2','vstdlib','mathlib'] diff --git a/togles/linuxwin/glmgr.cpp b/togles/linuxwin/glmgr.cpp index 302090cf6..177b8881e 100644 --- a/togles/linuxwin/glmgr.cpp +++ b/togles/linuxwin/glmgr.cpp @@ -1914,7 +1914,7 @@ void GLMContext::DelBuffer( CGLMBuffer *buff ) } } - BindGLBufferToCtx( buff->m_buffGLTarget, NULL, false ); + BindGLBufferToCtx( buff->m_buffGLTarget, 0, false ); delete buff; } diff --git a/togles/wscript b/togles/wscript index 0fedceaad..d7947186a 100755 --- a/togles/wscript +++ b/togles/wscript @@ -39,12 +39,14 @@ def build(bld): includes = [ '.', + '../common', '../public', '../public/tier0', '../public/tier1' ] + bld.env.INCLUDES_SDL2 defines = [] + defines.append('_FORTIFY_SOURCE=0') libs = ['tier0','tier1','tier2','vstdlib','mathlib'] diff --git a/vgui2/src/InputWin32.cpp b/vgui2/src/InputWin32.cpp index a9a037f95..fc39b7974 100644 --- a/vgui2/src/InputWin32.cpp +++ b/vgui2/src/InputWin32.cpp @@ -450,7 +450,7 @@ CInputSystem::~CInputSystem() //----------------------------------------------------------------------------- void CInputSystem::InitInputContext( InputContext_t *pContext ) { - pContext->_rootPanel = NULL; + pContext->_rootPanel = 0; pContext->_keyFocus = NULL; pContext->_oldMouseFocus = NULL; pContext->_mouseFocus = NULL; @@ -568,7 +568,7 @@ void CInputSystem::RunFrame() // when modal dialogs are up messages only get sent to the dialogs children. if (IsChildOfModalPanel((VPANEL)pContext->_keyFocus)) { - g_pIVgui->PostMessage((VPANEL)pContext->_keyFocus, new KeyValues("KeyFocusTicked"), NULL); + g_pIVgui->PostMessage((VPANEL)pContext->_keyFocus, new KeyValues("KeyFocusTicked"), 0); } } @@ -578,7 +578,7 @@ void CInputSystem::RunFrame() // when modal dialogs are up messages only get sent to the dialogs children. if (IsChildOfModalPanel((VPANEL)pContext->_mouseFocus)) { - g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseFocusTicked"), NULL); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseFocusTicked"), 0); } } // Mouse has wandered "off" the modal panel, just force a regular arrow cursor until it wanders back within the proper bounds @@ -809,7 +809,7 @@ void CInputSystem::PanelDeleted(VPANEL vfocus, InputContext_t &context) // NOTE: These two will only ever happen for the default context at the moment if (context._mouseCapture == focus) { - SetMouseCapture(NULL); + SetMouseCapture(0); context._mouseCapture = NULL; } if (context._appModalPanel == focus) @@ -894,7 +894,7 @@ void CInputSystem::SetMouseFocus(VPANEL newMouseFocus) // only notify of entry if the mouse is not captured or we're the captured panel if ( !pContext->_mouseCapture || pContext->_oldMouseFocus == pContext->_mouseCapture ) { - g_pIVgui->PostMessage( (VPANEL)pContext->_oldMouseFocus, new KeyValues( "CursorExited" ), NULL ); + g_pIVgui->PostMessage( (VPANEL)pContext->_oldMouseFocus, new KeyValues( "CursorExited" ), 0 ); } } @@ -904,7 +904,7 @@ void CInputSystem::SetMouseFocus(VPANEL newMouseFocus) // only notify of entry if the mouse is not captured or we're the captured panel if ( !pContext->_mouseCapture || pContext->_mouseOver == pContext->_mouseCapture ) { - g_pIVgui->PostMessage( (VPANEL)pContext->_mouseOver, new KeyValues( "CursorEntered" ), NULL ); + g_pIVgui->PostMessage( (VPANEL)pContext->_mouseOver, new KeyValues( "CursorEntered" ), 0 ); } } @@ -1120,10 +1120,10 @@ void CInputSystem::SetMouseCapture(VPANEL panel) // send a message if the panel is losing mouse capture if (pContext->_mouseCapture && panel != (VPANEL)pContext->_mouseCapture) { - g_pIVgui->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MouseCaptureLost"), NULL); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MouseCaptureLost"), 0); } - if (panel == NULL) + if (panel == 0) { if (pContext->_mouseCapture != NULL) { @@ -1431,7 +1431,7 @@ HCursor CInputSystem::GetCursorOveride() //----------------------------------------------------------------------------- bool CInputSystem::InternalCursorMoved(int x, int y) { - g_pIVgui->PostMessage((VPANEL) MESSAGE_CURSOR_POS, new KeyValues("SetCursorPosInternal", "xpos", x, "ypos", y), NULL); + g_pIVgui->PostMessage((VPANEL) MESSAGE_CURSOR_POS, new KeyValues("SetCursorPosInternal", "xpos", x, "ypos", y), 0); return true; } @@ -1484,13 +1484,13 @@ void CInputSystem::PostCursorMessage( ) return; // the panel with mouse capture gets all messages - g_pIVgui->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("CursorMoved", "xpos", pContext->m_nCursorX, "ypos", pContext->m_nCursorY), NULL); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("CursorMoved", "xpos", pContext->m_nCursorX, "ypos", pContext->m_nCursorY), 0); } else if (pContext->_mouseFocus != NULL) { // mouse focus is current from UpdateMouse focus // so the appmodal check has already been made. - g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("CursorMoved", "xpos", pContext->m_nCursorX, "ypos", pContext->m_nCursorY), NULL); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("CursorMoved", "xpos", pContext->m_nCursorX, "ypos", pContext->m_nCursorY), 0); } } @@ -1512,13 +1512,13 @@ bool CInputSystem::InternalMousePressed(MouseCode code) bool captureLost = code == pContext->m_MouseCaptureStartCode || pContext->m_MouseCaptureStartCode == (MouseCode)-1; // the panel with mouse capture gets all messages - g_pIVgui->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MousePressed", "code", code), NULL); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MousePressed", "code", code), 0); pTargetPanel = pContext->_mouseCapture; if ( captureLost ) { // this has to happen after MousePressed so the panel doesn't Think it got a mouse press after it lost capture - SetMouseCapture(NULL); + SetMouseCapture(0); } } else if ( (pContext->_mouseFocus != NULL) && IsChildOfModalPanel((VPANEL)pContext->_mouseFocus) ) @@ -1530,7 +1530,7 @@ bool CInputSystem::InternalMousePressed(MouseCode code) bFilter = true; // tell the panel with the mouseFocus that the mouse was presssed - g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MousePressed", "code", code), NULL); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MousePressed", "code", code), 0); // g_pIVgui->DPrintf2("MousePressed: (%s, %s)\n", _mouseFocus->GetName(), _mouseFocus->GetClassName()); pTargetPanel = pContext->_mouseFocus; } @@ -1548,7 +1548,7 @@ bool CInputSystem::InternalMousePressed(MouseCode code) if ( code == MOUSE_WHEEL_DOWN || code == MOUSE_WHEEL_UP ) return true; - g_pIVgui->PostMessage( ( VPANEL )pContext->m_pUnhandledMouseClickListener, new KeyValues( "UnhandledMouseClick", "code", code ), NULL ); + g_pIVgui->PostMessage( ( VPANEL )pContext->m_pUnhandledMouseClickListener, new KeyValues( "UnhandledMouseClick", "code", code ), 0 ); pTargetPanel = pContext->m_pUnhandledMouseClickListener; bFilter = true; } @@ -1580,7 +1580,7 @@ bool CInputSystem::InternalMouseDoublePressed(MouseCode code) return true; // the panel with mouse capture gets all messages - g_pIVgui->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MouseDoublePressed", "code", code), NULL); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MouseDoublePressed", "code", code), 0); pTargetPanel = pContext->_mouseCapture; bFilter = true; } @@ -1591,7 +1591,7 @@ bool CInputSystem::InternalMouseDoublePressed(MouseCode code) return true; // tell the panel with the mouseFocus that the mouse was double presssed - g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseDoublePressed", "code", code), NULL); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseDoublePressed", "code", code), 0); pTargetPanel = pContext->_mouseFocus; bFilter = true; } @@ -1619,7 +1619,7 @@ bool CInputSystem::InternalMouseReleased( MouseCode code ) return true; // the panel with mouse capture gets all messages - g_pIVgui->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MouseReleased", "code", code), NULL ); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MouseReleased", "code", code), 0 ); bFilter = true; } else if ((pContext->_mouseFocus != NULL) && IsChildOfModalPanel((VPANEL)pContext->_mouseFocus)) @@ -1629,7 +1629,7 @@ bool CInputSystem::InternalMouseReleased( MouseCode code ) return true; //tell the panel with the mouseFocus that the mouse was release - g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseReleased", "code", code), NULL ); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseReleased", "code", code), 0 ); bFilter = true; } @@ -1645,7 +1645,7 @@ bool CInputSystem::InternalMouseWheeled(int delta) if ((pContext->_mouseFocus != NULL) && IsChildOfModalPanel((VPANEL)pContext->_mouseFocus)) { // the mouseWheel works with the mouseFocus, not the keyFocus - g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseWheeled", "delta", delta), NULL); + g_pIVgui->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseWheeled", "delta", delta), 0); bFilter = true; } return bFilter; @@ -1798,10 +1798,10 @@ bool CInputSystem::PostKeyMessage(KeyValues *message) if( (pContext->_keyFocus!= NULL) && IsChildOfModalPanel((VPANEL)pContext->_keyFocus)) { #ifdef _X360 - g_pIVgui->PostMessage((VPANEL) MESSAGE_CURRENT_KEYFOCUS, message, NULL ); + g_pIVgui->PostMessage((VPANEL) MESSAGE_CURRENT_KEYFOCUS, message, 0 ); #else //tell the current focused panel that a key was released - g_pIVgui->PostMessage((VPANEL)pContext->_keyFocus, message, NULL ); + g_pIVgui->PostMessage((VPANEL)pContext->_keyFocus, message, 0 ); #endif return true; } @@ -3103,7 +3103,7 @@ void CInputSystem::OnKeyCodeUnhandled( int keyCode ) for ( int i = 0; i < c; ++i ) { VPanel *listener = pContext->m_KeyCodeUnhandledListeners[ i ]; - g_pIVgui->PostMessage((VPANEL)listener, new KeyValues( "KeyCodeUnhandled", "code", keyCode ), NULL ); + g_pIVgui->PostMessage((VPANEL)listener, new KeyValues( "KeyCodeUnhandled", "code", keyCode ), 0 ); } } @@ -3115,7 +3115,7 @@ void CInputSystem::PostModalSubTreeMessage( VPanel *subTree, bool state ) //tell the current focused panel that a key was released KeyValues *kv = new KeyValues( "ModalSubTree", "state", state ? 1 : 0 ); - g_pIVgui->PostMessage( (VPANEL)pContext->m_pModalSubTree, kv, NULL ); + g_pIVgui->PostMessage( (VPANEL)pContext->m_pModalSubTree, kv, 0 ); } // Assumes subTree is a child panel of the root panel for the vgui contect diff --git a/vgui2/src/system_posix.cpp b/vgui2/src/system_posix.cpp index 9473d416d..796dc95da 100644 --- a/vgui2/src/system_posix.cpp +++ b/vgui2/src/system_posix.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include @@ -292,7 +291,7 @@ void CSystem::ShellExecute(const char *command, const char *file) if ( pid == 0 ) { // Child -#if defined(LINUX) || defined(PLATFORM_BSD) +#if defined(POSIX) && !defined(OSX) // Escape steam runtime if necessary const char *szSteamRuntime = getenv( "STEAM_RUNTIME" ); if ( szSteamRuntime ) diff --git a/vgui2/src/vgui.cpp b/vgui2/src/vgui.cpp index b3de84e56..a61b938f3 100644 --- a/vgui2/src/vgui.cpp +++ b/vgui2/src/vgui.cpp @@ -573,7 +573,7 @@ VPANEL CVGui::HandleToPanel(HPanel index) { if ( !m_HandleTable.IsHandleValid( index ) ) { - return NULL; + return 0; } return (VPANEL)m_HandleTable.GetHandle( (UtlHandle_t)index ); } @@ -913,7 +913,7 @@ bool CVGui::DispatchMessages() //----------------------------------------------------------------------------- void CVGui::MarkPanelForDeletion(VPANEL panel) { - PostMessage(panel, new KeyValues("Delete"), NULL); + PostMessage(panel, new KeyValues("Delete"), 0); } //----------------------------------------------------------------------------- @@ -994,11 +994,11 @@ void CVGui::ShutdownMessage(unsigned int shutdownID) VPANEL panel = g_pSurface->GetEmbeddedPanel(); for (int i = 0; i < ((VPanel *)panel)->GetChildCount(); i++) { - g_pIVgui->PostMessage((VPANEL)((VPanel *)panel)->GetChild(i), new KeyValues("ShutdownRequest", "id", shutdownID), NULL); + g_pIVgui->PostMessage((VPANEL)((VPanel *)panel)->GetChild(i), new KeyValues("ShutdownRequest", "id", shutdownID), 0); } // post to the top level window as well - g_pIVgui->PostMessage(panel, new KeyValues("ShutdownRequest", "id", shutdownID), NULL); + g_pIVgui->PostMessage(panel, new KeyValues("ShutdownRequest", "id", shutdownID), 0); } //----------------------------------------------------------------------------- diff --git a/vgui2/src/vgui_internal.h b/vgui2/src/vgui_internal.h index 65d2bfb52..5e17ce62d 100644 --- a/vgui2/src/vgui_internal.h +++ b/vgui2/src/vgui_internal.h @@ -15,7 +15,7 @@ #include #include "interface.h" #include "tier3/tier3.h" -#include "xbox/xboxstubs.h" +#include "common/xbox/xboxstubs.h" namespace vgui { diff --git a/vgui2/src/vgui_key_translation.cpp b/vgui2/src/vgui_key_translation.cpp index 0377a5d87..5cd44bef7 100644 --- a/vgui2/src/vgui_key_translation.cpp +++ b/vgui2/src/vgui_key_translation.cpp @@ -7,12 +7,12 @@ #if defined( WIN32 ) && !defined( _X360 ) #include #include -#include "xbox/xboxstubs.h" +#include "common/xbox/xboxstubs.h" #endif #include "tier0/dbg.h" #include "vgui_key_translation.h" #if defined( _X360 ) -#include "xbox/xbox_win32stubs.h" +#include "common/xbox/xbox_win32stubs.h" #endif #ifdef POSIX #define VK_RETURN -1 diff --git a/vgui2/src/wscript b/vgui2/src/wscript index b4063e144..8a14391ef 100644 --- a/vgui2/src/wscript +++ b/vgui2/src/wscript @@ -50,10 +50,11 @@ def build(bld): includes = [ '.', + '../..', '../../public', '../../public/tier0', '../../public/tier1', - '../../common' + '../../common', ] + bld.env.INCLUDES_SDL2 defines = [] diff --git a/vgui2/vgui_controls/EditablePanel.cpp b/vgui2/vgui_controls/EditablePanel.cpp index 670d4dbc4..06f30ed41 100644 --- a/vgui2/vgui_controls/EditablePanel.cpp +++ b/vgui2/vgui_controls/EditablePanel.cpp @@ -761,11 +761,11 @@ void EditablePanel::RequestFocus(int direction) // delegate focus if (direction == 1) { - RequestFocusNext(NULL); + RequestFocusNext(0); } else if (direction == -1) { - RequestFocusPrev(NULL); + RequestFocusPrev(0); } else { @@ -829,7 +829,7 @@ VPANEL EditablePanel::GetCurrentKeyFocus() { Panel *focus = m_NavGroup.GetCurrentFocus(); if (focus == this) - return NULL; + return 0; if (focus) { diff --git a/vgui2/vgui_controls/FocusNavGroup.cpp b/vgui2/vgui_controls/FocusNavGroup.cpp index 8bfb807d9..67f81374b 100644 --- a/vgui2/vgui_controls/FocusNavGroup.cpp +++ b/vgui2/vgui_controls/FocusNavGroup.cpp @@ -29,10 +29,10 @@ using namespace vgui; //----------------------------------------------------------------------------- FocusNavGroup::FocusNavGroup(Panel *panel) : _mainPanel(panel) { - _currentFocus = NULL; + _currentFocus = 0; _topLevelFocus = false; - _defaultButton = NULL; - _currentDefaultButton = NULL; + _defaultButton = 0; + _currentDefaultButton = 0; } //----------------------------------------------------------------------------- @@ -51,7 +51,7 @@ bool FocusNavGroup::RequestFocusPrev(VPANEL panel) if(panel==0) return false; - _currentFocus = NULL; + _currentFocus = 0; int newPosition = 9999999; if (panel) { @@ -116,7 +116,7 @@ bool FocusNavGroup::RequestFocusPrev(VPANEL panel) if (ipanel()->RequestFocusPrev(_mainPanel->GetVParent(), _mainPanel->GetVPanel())) { bFound = true; - SetCurrentDefaultButton(NULL); + SetCurrentDefaultButton(0); break; } } @@ -141,12 +141,12 @@ bool FocusNavGroup::RequestFocusPrev(VPANEL panel) } else { - SetCurrentDefaultButton(NULL); + SetCurrentDefaultButton(0); // we need to ask the parent to set its default button if (_mainPanel->GetVParent()) { - ivgui()->PostMessage(_mainPanel->GetVParent(), new KeyValues("FindDefaultButton"), NULL); + ivgui()->PostMessage(_mainPanel->GetVParent(), new KeyValues("FindDefaultButton"), 0); } } } @@ -168,7 +168,7 @@ bool FocusNavGroup::RequestFocusNext(VPANEL panel) static int stack_depth = 0; stack_depth++; - _currentFocus = NULL; + _currentFocus = 0; int newPosition = 0; if (panel) { @@ -230,7 +230,7 @@ bool FocusNavGroup::RequestFocusNext(VPANEL panel) if (ipanel()->RequestFocusNext(_mainPanel->GetVParent(), _mainPanel->GetVPanel())) { bFound = true; - SetCurrentDefaultButton(NULL); + SetCurrentDefaultButton(0); break; } @@ -258,12 +258,12 @@ bool FocusNavGroup::RequestFocusNext(VPANEL panel) } else { - SetCurrentDefaultButton(NULL); + SetCurrentDefaultButton(0); // we need to ask the parent to set its default button if (_mainPanel->GetVParent()) { - ivgui()->PostMessage(_mainPanel->GetVParent(), new KeyValues("FindDefaultButton"), NULL); + ivgui()->PostMessage(_mainPanel->GetVParent(), new KeyValues("FindDefaultButton"), 0); } } } @@ -290,7 +290,7 @@ void FocusNavGroup::SetFocusTopLevel(bool state) //----------------------------------------------------------------------------- void FocusNavGroup::SetDefaultButton(Panel *panel) { - VPANEL vpanel = panel ? panel->GetVPanel() : NULL; + VPANEL vpanel = panel ? panel->GetVPanel() : 0; if ( vpanel == _defaultButton.Get() ) return; @@ -310,14 +310,14 @@ void FocusNavGroup::SetCurrentDefaultButton(VPANEL panel, bool sendCurrentDefaul if ( sendCurrentDefaultButtonMessage && _currentDefaultButton.Get() != 0) { - ivgui()->PostMessage(_currentDefaultButton, new KeyValues("SetAsCurrentDefaultButton", "state", 0), NULL); + ivgui()->PostMessage(_currentDefaultButton, new KeyValues("SetAsCurrentDefaultButton", "state", 0), 0); } _currentDefaultButton = panel; if ( sendCurrentDefaultButtonMessage && _currentDefaultButton.Get() != 0) { - ivgui()->PostMessage(_currentDefaultButton, new KeyValues("SetAsCurrentDefaultButton", "state", 1), NULL); + ivgui()->PostMessage(_currentDefaultButton, new KeyValues("SetAsCurrentDefaultButton", "state", 1), 0); } } @@ -430,4 +430,4 @@ bool FocusNavGroup::CanButtonBeDefault(VPANEL panel) } data->deleteThis(); return bResult; -} \ No newline at end of file +} diff --git a/vgui2/vgui_controls/KeyBoardEditorDialog.cpp b/vgui2/vgui_controls/KeyBoardEditorDialog.cpp index c177ffaff..86b1bd9ee 100644 --- a/vgui2/vgui_controls/KeyBoardEditorDialog.cpp +++ b/vgui2/vgui_controls/KeyBoardEditorDialog.cpp @@ -58,8 +58,8 @@ class VControlsListPanel : public ListPanel virtual ~VControlsListPanel(); // Start/end capturing - virtual void StartCaptureMode(vgui::HCursor hCursor = NULL); - virtual void EndCaptureMode(vgui::HCursor hCursor = NULL); + virtual void StartCaptureMode(vgui::HCursor hCursor = 0); + virtual void EndCaptureMode(vgui::HCursor hCursor = 0); virtual bool IsCapturing(); // Set which item should be associated with the prompt @@ -199,7 +199,7 @@ void VControlsListPanel::OnClearBinding() void VControlsListPanel::EndCaptureMode( HCursor hCursor ) { m_bCaptureMode = false; - input()->SetMouseCapture(NULL); + input()->SetMouseCapture(0); LeaveEditMode(); RequestFocus(); input()->SetMouseFocus(GetVPanel()); diff --git a/vgui2/vgui_controls/ListPanel.cpp b/vgui2/vgui_controls/ListPanel.cpp index 8a5139fca..7bcf514ec 100644 --- a/vgui2/vgui_controls/ListPanel.cpp +++ b/vgui2/vgui_controls/ListPanel.cpp @@ -183,7 +183,7 @@ void Dragger::OnMouseReleased(MouseCode code) { if (m_bMovable) { - input()->SetMouseCapture(NULL); + input()->SetMouseCapture(0); m_bDragging = false; } } diff --git a/vgui2/vgui_controls/MenuButton.cpp b/vgui2/vgui_controls/MenuButton.cpp index 19b35ae67..0ea6b8eac 100644 --- a/vgui2/vgui_controls/MenuButton.cpp +++ b/vgui2/vgui_controls/MenuButton.cpp @@ -239,7 +239,7 @@ void MenuButton::OnCursorEntered() KeyValues *msg = new KeyValues ("CursorEnteredMenuButton"); // tell the parent this menuitem is the one that was entered so it can open the menu if it wants msg->SetInt("VPanel", GetVPanel()); - ivgui()->PostMessage(GetVParent(), msg, NULL); + ivgui()->PostMessage(GetVParent(), msg, 0); } // This style is like the IE "back" button where the left side acts like a regular button, the the right side has a little @@ -348,4 +348,4 @@ Menu *MenuButton::GetMenu() { Assert( m_pMenu ); return m_pMenu; -} \ No newline at end of file +} diff --git a/vgui2/vgui_controls/MenuItem.cpp b/vgui2/vgui_controls/MenuItem.cpp index 5db442766..7d75ded6e 100644 --- a/vgui2/vgui_controls/MenuItem.cpp +++ b/vgui2/vgui_controls/MenuItem.cpp @@ -224,7 +224,7 @@ void MenuItem::OnCursorEntered() // tell the parent this menuitem is the one that was entered so it can highlight it msg->SetInt("menuItem", ToHandle() ); - ivgui()->PostMessage(GetVParent(), msg, NULL); + ivgui()->PostMessage(GetVParent(), msg, 0); } //----------------------------------------------------------------------------- @@ -238,7 +238,7 @@ void MenuItem::OnCursorExited() // tell the parent this menuitem is the one that was entered so it can unhighlight it msg->SetInt("menuItem", ToHandle() ); - ivgui()->PostMessage(GetVParent(), msg, NULL); + ivgui()->PostMessage(GetVParent(), msg, 0); } //----------------------------------------------------------------------------- diff --git a/vgui2/vgui_controls/PropertyPage.cpp b/vgui2/vgui_controls/PropertyPage.cpp index 36aa102d5..089ec79cf 100644 --- a/vgui2/vgui_controls/PropertyPage.cpp +++ b/vgui2/vgui_controls/PropertyPage.cpp @@ -105,7 +105,7 @@ void PropertyPage::SetVisible(bool state) // if we're going away and we have a current button, get rid of it if (GetFocusNavGroup().GetCurrentDefaultButton()) { - GetFocusNavGroup().SetCurrentDefaultButton(NULL); + GetFocusNavGroup().SetCurrentDefaultButton(0); } } diff --git a/vgui2/vgui_controls/PropertySheet.cpp b/vgui2/vgui_controls/PropertySheet.cpp index cb5b9d95b..34a59495e 100644 --- a/vgui2/vgui_controls/PropertySheet.cpp +++ b/vgui2/vgui_controls/PropertySheet.cpp @@ -446,7 +446,7 @@ class PageTab : public Button // ensure mouse capture gets released if (IsUseCaptureMouseEnabled()) { - input()->SetMouseCapture(NULL); + input()->SetMouseCapture(0); } // make sure the button gets unselected diff --git a/vgui2/vgui_controls/ScrollBar.cpp b/vgui2/vgui_controls/ScrollBar.cpp index 79ccb0d3f..ef6cd792a 100644 --- a/vgui2/vgui_controls/ScrollBar.cpp +++ b/vgui2/vgui_controls/ScrollBar.cpp @@ -103,7 +103,7 @@ class ScrollBarButton : public Button } // lock mouse input to going to this button - input()->SetMouseCapture(NULL); + input()->SetMouseCapture(0); } if( input()->GetMouseOver() == GetVPanel() ) diff --git a/vgui2/vgui_controls/SectionedListPanel.cpp b/vgui2/vgui_controls/SectionedListPanel.cpp index d3939e600..23b64e4f9 100644 --- a/vgui2/vgui_controls/SectionedListPanel.cpp +++ b/vgui2/vgui_controls/SectionedListPanel.cpp @@ -1452,7 +1452,7 @@ int SectionedListPanel::GetColumnCountBySection(int sectionID) { int index = FindSectionIndexByID(sectionID); if (index < 0) - return NULL; + return 0; return m_Sections[index].m_Columns.Size(); } diff --git a/vgui2/vgui_controls/Splitter.cpp b/vgui2/vgui_controls/Splitter.cpp index 96bde986c..96a1931ba 100644 --- a/vgui2/vgui_controls/Splitter.cpp +++ b/vgui2/vgui_controls/Splitter.cpp @@ -122,7 +122,7 @@ void SplitterHandle::OnMouseReleased(MouseCode code) { if ( m_bDragging ) { - input()->SetMouseCapture(NULL); + input()->SetMouseCapture(0); m_bDragging = false; } } diff --git a/vgui2/vgui_controls/TreeView.cpp b/vgui2/vgui_controls/TreeView.cpp index b7ad4d3b8..122a89ac5 100644 --- a/vgui2/vgui_controls/TreeView.cpp +++ b/vgui2/vgui_controls/TreeView.cpp @@ -1422,7 +1422,7 @@ void TreeNode::OnMouseReleased(MouseCode code) if ( input()->GetMouseCapture() == GetVPanel() ) { - input()->SetMouseCapture( NULL ); + input()->SetMouseCapture(0); return; } int x, y; diff --git a/vgui2/vgui_controls/TreeViewListControl.cpp b/vgui2/vgui_controls/TreeViewListControl.cpp index 30cb3b753..4e425f5b1 100644 --- a/vgui2/vgui_controls/TreeViewListControl.cpp +++ b/vgui2/vgui_controls/TreeViewListControl.cpp @@ -41,7 +41,7 @@ CTreeViewListControl::CTreeViewListControl( vgui::Panel *pParent, const char *pN { m_pTree = NULL; m_BorderColor.SetColor( 255, 255, 255, 255 ); - m_TitleBarFont = NULL; + m_TitleBarFont = 0; m_TitleBarHeight = 20; SetPostChildPaintEnabled( true ); } diff --git a/vgui2/vgui_controls/wscript b/vgui2/vgui_controls/wscript index 68644dc06..5d464800e 100644 --- a/vgui2/vgui_controls/wscript +++ b/vgui2/vgui_controls/wscript @@ -97,6 +97,7 @@ def build(bld): includes = [ '.', + '../..', '../../public', '../../public/tier0', '../../public/tier1' @@ -108,6 +109,7 @@ def build(bld): if bld.env.DEST_OS == 'win32': libs += ['SHELL32'] + includes += ['../../common'] bld.stlib( source = source, diff --git a/vgui2/vgui_surfacelib/BitmapFont.cpp b/vgui2/vgui_surfacelib/BitmapFont.cpp index b597ac479..0c2f49cda 100644 --- a/vgui2/vgui_surfacelib/BitmapFont.cpp +++ b/vgui2/vgui_surfacelib/BitmapFont.cpp @@ -15,8 +15,8 @@ #else #include #endif -#include "vgui_surfacelib/BitmapFont.h" -#include "vgui_surfacelib/FontManager.h" +#include "common/vgui_surfacelib/BitmapFont.h" +#include "common/vgui_surfacelib/FontManager.h" #include #include #include diff --git a/vgui2/vgui_surfacelib/FontAmalgam.cpp b/vgui2/vgui_surfacelib/FontAmalgam.cpp index 34010144d..b9eab6cfb 100644 --- a/vgui2/vgui_surfacelib/FontAmalgam.cpp +++ b/vgui2/vgui_surfacelib/FontAmalgam.cpp @@ -5,7 +5,7 @@ // $NoKeywords: $ //=============================================================================// -#include "vgui_surfacelib/FontAmalgam.h" +#include "common/vgui_surfacelib/FontAmalgam.h" #include #include #include diff --git a/vgui2/vgui_surfacelib/FontManager.cpp b/vgui2/vgui_surfacelib/FontManager.cpp index 870113aa6..ab6a50d8a 100644 --- a/vgui2/vgui_surfacelib/FontManager.cpp +++ b/vgui2/vgui_surfacelib/FontManager.cpp @@ -5,8 +5,8 @@ //=====================================================================================// #include -#include "vgui_surfacelib/BitmapFont.h" -#include "vgui_surfacelib/FontManager.h" +#include "common/vgui_surfacelib/BitmapFont.h" +#include "common/vgui_surfacelib/FontManager.h" #include #include @@ -584,20 +584,20 @@ FallbackFont_t g_FallbackFonts[] = { NULL, "Monaco" } // every other font falls back to this }; -#elif defined(LINUX) || defined(PLATFORM_BSD) -static const char *g_szValidAsianFonts[] = { "Marlett", "WenQuanYi Zen Hei", "unifont", NULL }; - +#elif defined(_PS3) // list of how fonts fallback FallbackFont_t g_FallbackFonts[] = { - { "DejaVu Sans", NULL }, - { NULL, "DejaVu Sans" }, // every other font falls back to this + { NULL, "Tahoma" }, // every other font falls back to this }; -#elif defined(_PS3) +#elif defined(POSIX) +static const char *g_szValidAsianFonts[] = { "Marlett", "WenQuanYi Zen Hei", "unifont", NULL }; + // list of how fonts fallback FallbackFont_t g_FallbackFonts[] = { - { NULL, "Tahoma" }, // every other font falls back to this + { "DejaVu Sans", NULL }, + { NULL, "DejaVu Sans" }, // every other font falls back to this }; #else #error @@ -649,10 +649,10 @@ const char *CFontManager::GetForeignFallbackFontName() return "Tahoma"; #elif defined(OSX) return "Helvetica"; -#elif defined(LINUX) || defined(PLATFORM_BSD) - return "WenQuanYi Zen Hei"; #elif defined(_PS3) return "Tahoma"; +#elif defined(POSIX) + return "WenQuanYi Zen Hei"; #else #error #endif diff --git a/vgui2/vgui_surfacelib/Win32Font.cpp b/vgui2/vgui_surfacelib/Win32Font.cpp index 5ec02ac69..5bb551804 100644 --- a/vgui2/vgui_surfacelib/Win32Font.cpp +++ b/vgui2/vgui_surfacelib/Win32Font.cpp @@ -11,7 +11,7 @@ #include #include #include -#include "vgui_surfacelib/Win32Font.h" +#include "common/vgui_surfacelib/Win32Font.h" #include #include #include diff --git a/vgui2/vgui_surfacelib/linuxfont.cpp b/vgui2/vgui_surfacelib/linuxfont.cpp index aada7b4ad..c5152315e 100644 --- a/vgui2/vgui_surfacelib/linuxfont.cpp +++ b/vgui2/vgui_surfacelib/linuxfont.cpp @@ -6,7 +6,7 @@ //=============================================================================// -#include "vgui_surfacelib/linuxfont.h" +#include "common/vgui_surfacelib/linuxfont.h" #include #include @@ -24,7 +24,7 @@ #include #include "materialsystem/imaterialsystem.h" -#include "vgui_surfacelib/FontManager.h" +#include "common/vgui_surfacelib/FontManager.h" #include "FontEffects.h" // memdbgon must be the last include file in a .cpp file!!! diff --git a/vgui2/vgui_surfacelib/wscript b/vgui2/vgui_surfacelib/wscript index c469a336b..a809e23a5 100644 --- a/vgui2/vgui_surfacelib/wscript +++ b/vgui2/vgui_surfacelib/wscript @@ -35,10 +35,10 @@ def build(bld): includes = [ '.', + '../..', '../../public', '../../public/tier0', '../../public/tier1', - '../../common', ] + bld.env.INCLUDES_FC + bld.env.INCLUDES_FT2 defines = [] diff --git a/vguimatsurface/FontTextureCache.cpp b/vguimatsurface/FontTextureCache.cpp index 7703be73f..11f58e5eb 100644 --- a/vguimatsurface/FontTextureCache.cpp +++ b/vguimatsurface/FontTextureCache.cpp @@ -10,7 +10,7 @@ #include #elif defined( OSX ) #include -#elif defined( LINUX ) || defined(PLATFORM_BSD) +#elif defined(POSIX) //#error #elif defined( _X360 ) #else @@ -18,7 +18,7 @@ #endif #include "FontTextureCache.h" #include "MatSystemSurface.h" -#include +#include "common/vgui_surfacelib/BitmapFont.h" #include #include #include "bitmap/imageformat.h" diff --git a/vguimatsurface/FontTextureCache.h b/vguimatsurface/FontTextureCache.h index 1f12e3ce2..5ca2724df 100644 --- a/vguimatsurface/FontTextureCache.h +++ b/vguimatsurface/FontTextureCache.h @@ -11,7 +11,7 @@ #pragma once #endif -#include "vgui_surfacelib/FontManager.h" +#include "common/vgui_surfacelib/FontManager.h" #include "utlrbtree.h" #include #include "utlmap.h" diff --git a/vguimatsurface/MatSystemSurface.cpp b/vguimatsurface/MatSystemSurface.cpp index 02f11001a..4563fac0e 100644 --- a/vguimatsurface/MatSystemSurface.cpp +++ b/vguimatsurface/MatSystemSurface.cpp @@ -36,7 +36,6 @@ ILauncherMgr *g_pLauncherMgr = NULL; #include "Input.h" #include #include -#include "vgui_surfacelib/FontManager.h" #include "FontTextureCache.h" #include "MatSystemSurface.h" #include "inputsystem/iinputsystem.h" @@ -56,9 +55,9 @@ ILauncherMgr *g_pLauncherMgr = NULL; #include "../vgui2/src/VPanel.h" #include #if defined( _X360 ) -#include "xbox/xbox_win32stubs.h" +#include "common/xbox/xbox_win32stubs.h" #endif -#include "xbox/xboxstubs.h" +#include "common/xbox/xboxstubs.h" #include "../vgui2/src/Memorybitmap.h" #pragma warning( disable : 4706 ) @@ -146,7 +145,7 @@ CMatSystemSurface g_MatSystemSurface; EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CMatSystemSurface, ISurface, VGUI_SURFACE_INTERFACE_VERSION, g_MatSystemSurface ); -#if defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#if defined(POSIX) CUtlDict< CMatSystemSurface::font_entry, unsigned short > CMatSystemSurface::m_FontData; #endif @@ -407,7 +406,7 @@ InitReturnVal_t CMatSystemSurface::Init( void ) FontManager().SetLanguage( "english" ); } -#if defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#if defined(POSIX) FontManager().SetFontDataHelper( &CMatSystemSurface::FontDataHelper ); #endif @@ -1907,7 +1906,7 @@ bool CMatSystemSurface::AddCustomFontFile( const char *fontName, const char *fon } Assert( success ); return success; -#elif defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#elif defined(POSIX) int size; if ( CMatSystemSurface::FontDataHelper( fontName, size, fontFileName ) ) @@ -1921,7 +1920,7 @@ bool CMatSystemSurface::AddCustomFontFile( const char *fontName, const char *fon #endif } -#if defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#if defined(POSIX) static void RemoveSpaces( CUtlString &str ) { diff --git a/vguimatsurface/MatSystemSurface.h b/vguimatsurface/MatSystemSurface.h index bc46b1fd1..20801ef9e 100644 --- a/vguimatsurface/MatSystemSurface.h +++ b/vguimatsurface/MatSystemSurface.h @@ -517,8 +517,8 @@ class CMatSystemSurface : public CTier3AppSystem< IMatSystemSurface > public: TitleEntry() { - panel = NULL; - title[0] = 0; + panel = 0; + title[0] = '\0'; } vgui::VPANEL panel; @@ -556,7 +556,7 @@ class CMatSystemSurface : public CTier3AppSystem< IMatSystemSurface > int m_nFullscreenViewportHeight; ITexture *m_pFullscreenRenderTarget; -#if defined(LINUX) || defined(OSX) || defined(PLATFORM_BSD) +#if defined(POSIX) struct font_entry { void *data; diff --git a/vguimatsurface/asanstubs.cpp b/vguimatsurface/asanstubs.cpp index 63f7dc4fd..630ac3ebb 100644 --- a/vguimatsurface/asanstubs.cpp +++ b/vguimatsurface/asanstubs.cpp @@ -190,7 +190,7 @@ const char *VPanel::GetClassName() HScheme VPanel::GetScheme() { - return NULL; + return 0; } diff --git a/vguimatsurface/wscript b/vguimatsurface/wscript index a76de0b29..4a4dd3633 100644 --- a/vguimatsurface/wscript +++ b/vguimatsurface/wscript @@ -40,10 +40,10 @@ def build(bld): includes = [ '.', + '..', '../public', '../public/tier0', '../public/tier1', - '../common', ] defines = [] diff --git a/video/videoservices.cpp b/video/videoservices.cpp index 58f1e8c61..e38bc78cc 100644 --- a/video/videoservices.cpp +++ b/video/videoservices.cpp @@ -58,14 +58,14 @@ DEFINE_ENUM_BITWISE_OPERATORS( EPlatform_t ); const EPlatform_t thisPlatform = PLATFORM_XBOX_360; #elif defined( _PS3 ) const EPlatform_t thisPlatform = PLATFORM_PS3; -#elif defined ( _LINUX ) || defined(PLATFORM_BSD) +#elif defined(POSIX) const EPlatform_t thisPlatform = PLATFORM_LINUX; #else #error "UNABLE TO DETERMINE PLATFORM" #endif -#if defined( OSX ) || defined( LINUX ) || defined(PLATFORM_BSD) +#if defined(POSIX) ILauncherMgr *g_pLauncherMgr = NULL; #endif @@ -1382,7 +1382,7 @@ bool CVideoCommonServices::ProcessFullScreenInput( bool &bAbortEvent, bool &bPau bool bEscPressed = ( m_bScanEsc ) ? CGEventSourceKeyState( kCGEventSourceStateCombinedSessionState, kVK_Escape ) : false; bool bReturnPressed = ( m_bScanReturn ) ? CGEventSourceKeyState( kCGEventSourceStateCombinedSessionState, kVK_Return ) : false; bool bSpacePressed = ( m_bScanSpace ) ? CGEventSourceKeyState( kCGEventSourceStateCombinedSessionState, kVK_Space ) : false; -#elif defined(LINUX) || defined(PLATFORM_BSD) +#elif defined(POSIX) g_pLauncherMgr->PumpWindowsMessageLoop(); // Escape, return, or space stops or pauses the playback diff --git a/vpklib/packedstore.cpp b/vpklib/packedstore.cpp index 1c1234768..1ae2727ac 100644 --- a/vpklib/packedstore.cpp +++ b/vpklib/packedstore.cpp @@ -1710,7 +1710,7 @@ int CPackedStore::GetFileList( const char *pWildCard, CUtlStringList &outFilenam bool bNoBaseWildcard = false; bool bNoExtWildcard = false; - szWildCardPath[0] = szWildCardExt[0] = szWildCardBase[0] = NULL; + szWildCardPath[0] = szWildCardExt[0] = szWildCardBase[0] = '\0'; // Parse the wildcard string into a base and extension used for string comparisons if ( pWildCard ) @@ -1723,9 +1723,9 @@ int CPackedStore::GetFileList( const char *pWildCard, CUtlStringList &outFilenam // Remove '*' from the base and extension strings so that the string comparison calls will match char *pcStar = strchr( szWildCardBase, '*' ); - pcStar ? *pcStar = NULL : bNoBaseWildcard = true; + pcStar ? *pcStar = '\0' : bNoBaseWildcard = true; pcStar = strchr( szWildCardExt, '*' ); - pcStar ? *pcStar = NULL : bNoExtWildcard = true; + pcStar ? *pcStar = '\0' : bNoExtWildcard = true; } char const *pData = reinterpret_cast< char const *>( DirectoryData() ); @@ -1928,10 +1928,10 @@ int CPackedStore::GetFileAndDirLists( const char *pWildCard, CUtlStringList &out // Remove '*' from the base and extension strings so that the string comparison calls will match char *pcStar = strchr( szWildCardBase, '*' ); - pcStar ? *pcStar = NULL : bBaseWildcard = false; + pcStar ? *pcStar = '\0' : bBaseWildcard = false; pcStar = strchr( szWildCardExt, '*' ); - pcStar ? *pcStar = NULL : bExtWildcard = false; + pcStar ? *pcStar = '\0' : bExtWildcard = false; nLenWildcardPath = V_strlen( szWildCardPath ); nLenWildcardBase = V_strlen( szWildCardBase ); @@ -1960,7 +1960,7 @@ int CPackedStore::GetFileAndDirLists( const char *pWildCard, CUtlStringList &out // Set the next / to NULL and we have our subdirectory char *pSlash = strchr( szSubDir, '/' ); - pSlash ? *pSlash = NULL : NULL; + pSlash ? *pSlash = '\0' : 0; szSubDirExtension = strchr( szSubDir, '.' ); if ( szSubDirExtension ) diff --git a/vstdlib/coroutine.cpp b/vstdlib/coroutine.cpp index dc148a8c2..9ede53309 100644 --- a/vstdlib/coroutine.cpp +++ b/vstdlib/coroutine.cpp @@ -1076,7 +1076,7 @@ bool Coroutine_Test() while ( vecCoroutineL2.Count() ) { if ( hCoroutine && !Coroutine_Continue( hCoroutine, NULL ) ) - hCoroutine = NULL; + hCoroutine = 0; FOR_EACH_VEC_BACK( vecCoroutineL2, i ) { diff --git a/waf b/waf index b2f4c6f49..f754d112d 100755 --- a/waf +++ b/waf @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # encoding: latin-1 # Thomas Nagy, 2005-2018 # diff --git a/wscript b/wscript index ada484c56..0201dd783 100644 --- a/wscript +++ b/wscript @@ -1,4 +1,5 @@ #! /usr/bin/env python +# vim: noexpandtab # encoding: utf-8 # nillerusr @@ -88,6 +89,7 @@ projects={ 'tier3', 'unitlib', 'mathlib', + 'vstdlib', 'filesystem', 'vpklib', @@ -228,10 +230,13 @@ def define_platform(conf): '_DLL_EXT=.dylib' ]) - elif conf.env.DEST_OS in ['freebsd', 'openbsd', 'netbsd', 'dragonflybsd']: # Tested only in freebsd + elif conf.env.DEST_OS in ['freebsd', 'openbsd', 'netbsd']: # Tested only in freebsd + if conf.env.DEST_OS == 'freebsd': + conf.env.append_unique('DEFINES', ['PLATFORM_FBSD=1']) conf.env.append_unique('DEFINES', [ 'POSIX=1', '_POSIX=1', 'PLATFORM_POSIX=1', 'GNUC', # but uses clang + 'NO_HOOK_MALLOC', 'PLATFORM_BSD=1', '_DLL_EXT=.so' ]) @@ -328,7 +333,7 @@ def check_deps(conf): for i in a: conf.check_cc(lib = i) - if conf.env.DEST_OS == "darwin": + if conf.env.DEST_OS == 'darwin': conf.check(lib='iconv', uselib_store='ICONV') conf.env.FRAMEWORK_APPKIT = "AppKit" conf.env.FRAMEWORK_IOKIT = "IOKit" @@ -492,9 +497,6 @@ def configure(conf): if conf.env.DEST_CPU == 'arm': flags += ['-mfpu=neon-vfpv4'] - if conf.env.DEST_OS == 'freebsd': - linkflags += ['-lexecinfo'] - if conf.env.DEST_OS != 'win32': cflags += flags linkflags += flags @@ -562,7 +564,6 @@ def configure(conf): conf.env.append_unique('CFLAGS', cflags) conf.env.append_unique('CXXFLAGS', cxxflags) conf.env.append_unique('LINKFLAGS', linkflags) - conf.env.append_unique('INCLUDES', [os.path.abspath('common/')]) check_deps( conf ) @@ -606,3 +607,4 @@ def build(bld): projects['game'] += ['togl'] bld.add_subproject(projects['game']) +