From eff77f0a0abbe39be5c85b018ece9195ad95f7b5 Mon Sep 17 00:00:00 2001 From: nillerusr Date: Fri, 16 Dec 2022 19:20:56 +0300 Subject: [PATCH 1/6] windows: fix 64bit build( #149 ) --- game/client/client_thinklist.cpp | 4 ++-- game/client/client_thinklist.h | 2 +- game/client/clientleafsystem.cpp | 2 +- ivp | 2 +- public/tier1/memhelpers.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/game/client/client_thinklist.cpp b/game/client/client_thinklist.cpp index eae2d880..bbb70a7b 100644 --- a/game/client/client_thinklist.cpp +++ b/game/client/client_thinklist.cpp @@ -158,7 +158,7 @@ void CClientThinkList::RemoveThinkable( ClientThinkHandle_t hThink ) { pThink->SetThinkHandle( INVALID_THINK_HANDLE ); } - m_ThinkEntries.Remove( (unsigned long)hThink ); + m_ThinkEntries.Remove( (uintp)hThink ); } @@ -304,7 +304,7 @@ void CClientThinkList::PerformThinkFunctions() if ( hThink != INVALID_THINK_HANDLE ) { // This can happen if the same think handle was removed twice - if ( !m_ThinkEntries.IsInList( (unsigned long)hThink ) ) + if ( !m_ThinkEntries.IsInList( (uintp)hThink ) ) continue; // NOTE: This is necessary for the case where the client entity handle diff --git a/game/client/client_thinklist.h b/game/client/client_thinklist.h index 3d3e1744..9d3b3b54 100644 --- a/game/client/client_thinklist.h +++ b/game/client/client_thinklist.h @@ -121,7 +121,7 @@ inline ClientThinkHandle_t CClientThinkList::GetInvalidThinkHandle() inline CClientThinkList::ThinkEntry_t* CClientThinkList::GetThinkEntry( ClientThinkHandle_t hThink ) { - return &m_ThinkEntries[ (unsigned long)hThink ]; + return &m_ThinkEntries[ (uintp)hThink ]; } diff --git a/game/client/clientleafsystem.cpp b/game/client/clientleafsystem.cpp index f8e46d88..c00481fd 100644 --- a/game/client/clientleafsystem.cpp +++ b/game/client/clientleafsystem.cpp @@ -1337,7 +1337,7 @@ void CClientLeafSystem::ComputeTranslucentRenderLeaf( int count, const LeafIndex static CUtlVector orderedList; // @MULTICORE (toml 8/30/2006): will need to make non-static if thread this function static CUtlVector renderablesToUpdate; - int leaf = 0; + intp leaf = 0; for ( i = 0; i < count; ++i ) { leaf = pLeafList[i]; diff --git a/ivp b/ivp index dfa42eb5..960c7228 160000 --- a/ivp +++ b/ivp @@ -1 +1 @@ -Subproject commit dfa42eb575618661a9c41c2ed635c1b9a0a51858 +Subproject commit 960c7228f8e8d710625891991e88b1ec3aa92e45 diff --git a/public/tier1/memhelpers.h b/public/tier1/memhelpers.h index 898cafb2..296a566b 100644 --- a/public/tier1/memhelpers.h +++ b/public/tier1/memhelpers.h @@ -19,7 +19,7 @@ namespace memutils } template - inline void set( T *dest, T value, size_t n ) + inline void set( T *dest, const T &value, size_t n ) { do { From 8404418202a099dd3db64435ae7d1ecf4c9249e8 Mon Sep 17 00:00:00 2001 From: nillerusr Date: Fri, 16 Dec 2022 19:23:23 +0300 Subject: [PATCH 2/6] windows: add workflows for amd64 target architecture --- .github/workflows/build.yml | 22 ++++++++++++++++++++++ .github/workflows/tests.yml | 14 ++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6977112b..d4e2a14c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,6 +47,17 @@ jobs: ./waf.bat configure -T debug ./waf.bat build + build-windows-amd64: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v2 + - name: Build windows-i386 + run: | + git submodule init && git submodule update + ./waf.bat configure -T debug -8 + ./waf.bat build + build-dedicated-windows-i386: runs-on: windows-2019 @@ -58,6 +69,17 @@ jobs: ./waf.bat configure -T debug -d ./waf.bat build + build-dedicated-windows-amd64: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v2 + - name: Build dedicated windows-amd64 + run: | + git submodule init && git submodule update + ./waf.bat configure -T debug -d -8 + ./waf.bat build + build-dedicated-linux-i386: runs-on: ubuntu-18.04 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a0742c16..3a99a7f2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,3 +40,17 @@ jobs: cd out $env:Path = "bin"; ./unittest.exe + + tests-windows-amd64: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v2 + - name: Run tests windows-amd64 + run: | + git submodule init && git submodule update + ./waf.bat configure -T release --tests --prefix=out/ -8 + ./waf.bat install + cd out + $env:Path = "bin"; + ./unittest.exe From af8c358ce974270c06ec908ef742935ba0a03364 Mon Sep 17 00:00:00 2001 From: nillerusr Date: Fri, 16 Dec 2022 19:47:53 +0300 Subject: [PATCH 3/6] windows: fix dedicated build --- .github/workflows/build.yml | 8 +------- .github/workflows/tests.yml | 8 +------- dedicated/sys_ded.cpp | 2 +- wscript | 3 ++- 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d4e2a14c..c51b0f8d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,6 @@ name: Build -on: - push: - branches: - - "*" - pull_request: - branches: - - "*" +on: [push, pull_request] jobs: build-linux-i386: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3a99a7f2..4974855e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,12 +1,6 @@ name: Tests -on: - push: - branches: - - "*" - pull_request: - branches: - - "*" +on: [push, pull_request] jobs: tests-linux-i386: diff --git a/dedicated/sys_ded.cpp b/dedicated/sys_ded.cpp index c7a9be92..f1ff4449 100644 --- a/dedicated/sys_ded.cpp +++ b/dedicated/sys_ded.cpp @@ -470,7 +470,7 @@ bool CDedicatedSteamApplication::Create( ) //----------------------------------------------------------------------------- int main(int argc, char **argv) { -#ifndef POSIX +#if !defined( POSIX ) && !defined( PLATFORM_64BITS ) _asm { fninit diff --git a/wscript b/wscript index 5c12bf40..c2f86949 100644 --- a/wscript +++ b/wscript @@ -394,7 +394,8 @@ def configure(conf): '/Zc:forScope', '/Zc:wchar_t', '/GR', - '/TP' + '/TP', + '/EHsc' ] if conf.options.BUILD_TYPE == 'debug': From ff2211f0ad243c02d1c02c07ddb9848abd89b598 Mon Sep 17 00:00:00 2001 From: nillerusr Date: Sat, 17 Dec 2022 10:14:49 +0300 Subject: [PATCH 4/6] windows: fix(workaround) illegal instruction in release build --- .github/workflows/build.yml | 2 +- engine/tmessage.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c51b0f8d..779ebc77 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Build windows-i386 + - name: Build windows-amd64 run: | git submodule init && git submodule update ./waf.bat configure -T debug -8 diff --git a/engine/tmessage.cpp b/engine/tmessage.cpp index 72c65f22..c5e00116 100644 --- a/engine/tmessage.cpp +++ b/engine/tmessage.cpp @@ -322,10 +322,17 @@ int ParseDirective( const char *pText ) { if ( ParseFloats( pText, tempFloat, 4 ) ) { - for ( int i = 0; i < 4; ++i ) + // that's original code, msvc2015 generates illegal instruction on amd64 architecture + /*for ( int i = 0; i < 4; ++i ) { gMessageParms.boxcolor[ i ] = (byte)(int)tempFloat[ i ]; - } + }*/ + + // workaround + gMessageParms.boxcolor[0] = (int)tempFloat[0]; + gMessageParms.boxcolor[1] = (int)tempFloat[1]; + gMessageParms.boxcolor[2] = (int)tempFloat[2]; + gMessageParms.boxcolor[3] = (int)tempFloat[3]; } } else if ( IsToken( pText, "clearmessage" ) ) From bc909e9f969bf0eb5aaa10434e3d3096933ce19f Mon Sep 17 00:00:00 2001 From: nillerusr Date: Sat, 17 Dec 2022 11:48:41 +0300 Subject: [PATCH 5/6] windows(amd64): fix EHANDLE size( fixes saverestore ) --- public/basehandle.h | 8 ++++---- public/saverestoretypes.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/basehandle.h b/public/basehandle.h index 91eb02d0..0e35ddb3 100644 --- a/public/basehandle.h +++ b/public/basehandle.h @@ -30,7 +30,7 @@ public: CBaseHandle(); CBaseHandle( const CBaseHandle &other ); - CBaseHandle( unsigned long value ); + CBaseHandle( uintp value ); CBaseHandle( int iEntry, int iSerialNumber ); void Init( int iEntry, int iSerialNumber ); @@ -63,7 +63,7 @@ public: protected: // The low NUM_SERIAL_BITS hold the index. If this value is less than MAX_EDICTS, then the entity is networkable. // The high NUM_SERIAL_NUM_BITS bits are the serial number. - unsigned long m_Index; + uintp m_Index; }; @@ -80,7 +80,7 @@ inline CBaseHandle::CBaseHandle( const CBaseHandle &other ) m_Index = other.m_Index; } -inline CBaseHandle::CBaseHandle( unsigned long value ) +inline CBaseHandle::CBaseHandle( uintp value ) { m_Index = value; } @@ -150,7 +150,7 @@ inline bool CBaseHandle::operator <( const CBaseHandle &other ) const inline bool CBaseHandle::operator <( const IHandleEntity *pEntity ) const { - unsigned long otherIndex = (pEntity) ? pEntity->GetRefEHandle().m_Index : INVALID_EHANDLE_INDEX; + uintp otherIndex = (pEntity) ? pEntity->GetRefEHandle().m_Index : INVALID_EHANDLE_INDEX; return m_Index < otherIndex; } diff --git a/public/saverestoretypes.h b/public/saverestoretypes.h index 4bfb25b4..e470f662 100644 --- a/public/saverestoretypes.h +++ b/public/saverestoretypes.h @@ -102,7 +102,7 @@ struct levellist_t struct EHandlePlaceholder_t // Engine does some of the game writing (alas, probably shouldn't), but can't see ehandle.h { - unsigned long i; + uintp i; }; //------------------------------------- From bfb5b44d38846b6a54a2269173b70bd09d1d1e00 Mon Sep 17 00:00:00 2001 From: HappyDOGE <28511119+HappyDOGE@users.noreply.github.com> Date: Mon, 16 Jan 2023 11:56:05 +0300 Subject: [PATCH 6/6] win64: misc pointer truncation fixes --- engine/downloadthread.cpp | 2 +- filesystem/filesystem_stdio.cpp | 2 +- game/server/ai_navigator.cpp | 2 +- materialsystem/CColorCorrection.cpp | 2 +- studiorender/r_studiodraw.cpp | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/engine/downloadthread.cpp b/engine/downloadthread.cpp index a79ebff5..882609f7 100644 --- a/engine/downloadthread.cpp +++ b/engine/downloadthread.cpp @@ -425,7 +425,7 @@ DWORD __stdcall DownloadThread( void *voidPtr ) //Thread_DPrintf( "Requesting full download\n%s", headers ); } - rc.hDataResource = InternetOpenUrl(rc.hOpenResource, fullURL, headerPtr, headerLen, flags,(DWORD)(&rc) ); + rc.hDataResource = InternetOpenUrl(rc.hOpenResource, fullURL, headerPtr, headerLen, flags, (DWORD_PTR)(&rc) ); // send the request off if ( !rc.hDataResource ) diff --git a/filesystem/filesystem_stdio.cpp b/filesystem/filesystem_stdio.cpp index f80d4e4a..29caa925 100644 --- a/filesystem/filesystem_stdio.cpp +++ b/filesystem/filesystem_stdio.cpp @@ -1413,7 +1413,7 @@ size_t CWin32ReadOnlyFile::FS_fread( void *dest, size_t destSize, size_t size ) if ( m_hFileUnbuffered != INVALID_HANDLE_VALUE ) { const int destBaseAlign = ( IsX360() ) ? 4 : m_SectorSize; - bool bDestBaseIsAligned = ( (DWORD)dest % destBaseAlign == 0 ); + bool bDestBaseIsAligned = ( (DWORD_PTR)dest % destBaseAlign == 0 ); bool bCanReadUnbufferedDirect = ( bDestBaseIsAligned && ( destSize % m_SectorSize == 0 ) && ( m_ReadPos % m_SectorSize == 0 ) ); if ( bCanReadUnbufferedDirect ) diff --git a/game/server/ai_navigator.cpp b/game/server/ai_navigator.cpp index 2825744c..c304bcdc 100644 --- a/game/server/ai_navigator.cpp +++ b/game/server/ai_navigator.cpp @@ -1222,7 +1222,7 @@ float CAI_Navigator::GetPathTimeToGoal() AI_PathNode_t CAI_Navigator::GetNearestNode() { #ifdef WIN32 - COMPILE_TIME_ASSERT( (int)AIN_NO_NODE == NO_NODE ); + COMPILE_TIME_ASSERT( (intp)AIN_NO_NODE == NO_NODE ); #endif return (AI_PathNode_t)(intp)( GetPathfinder()->NearestNodeToNPC() ); } diff --git a/materialsystem/CColorCorrection.cpp b/materialsystem/CColorCorrection.cpp index 5483d18e..46246658 100644 --- a/materialsystem/CColorCorrection.cpp +++ b/materialsystem/CColorCorrection.cpp @@ -79,7 +79,7 @@ ColorCorrectionLookup_t::~ColorCorrectionLookup_t( ) void ColorCorrectionLookup_t::AllocTexture() { char name[64]; - sprintf( name, "ColorCorrection - %d", m_Handle ); + sprintf( name, "ColorCorrection - %p", m_Handle ); m_pColorCorrectionTexture = ITextureInternal::CreateProceduralTexture( name, TEXTURE_GROUP_OTHER, COLOR_CORRECTION_TEXTURE_SIZE, COLOR_CORRECTION_TEXTURE_SIZE, COLOR_CORRECTION_TEXTURE_SIZE, IMAGE_FORMAT_BGRX8888, diff --git a/studiorender/r_studiodraw.cpp b/studiorender/r_studiodraw.cpp index da6905fd..c2aee1fb 100644 --- a/studiorender/r_studiodraw.cpp +++ b/studiorender/r_studiodraw.cpp @@ -1138,7 +1138,7 @@ public: if ( nHasSIMD ) { // Precaches the data - _mm_prefetch( (char*)((int)pGroupToMesh & (~0x1F)), _MM_HINT_NTA ); + _mm_prefetch( (char*)((intp)pGroupToMesh & (~0x1F)), _MM_HINT_NTA ); } #endif for ( int i = 0; i < PREFETCH_VERT_COUNT; ++i ) @@ -1165,7 +1165,7 @@ public: if ( nHasSIMD ) { char *pMem = (char*)&pGroupToMesh[j + PREFETCH_VERT_COUNT + 1]; - _mm_prefetch( (char*)((int)pMem & (~0x1F)), _MM_HINT_NTA ); + _mm_prefetch( (char*)((intp)pMem & (~0x1F)), _MM_HINT_NTA ); } #endif idx = j & (PREFETCH_VERT_COUNT-1);