From dba14e2dc1a01fe154d4bbea9507c562fdb02951 Mon Sep 17 00:00:00 2001 From: tupoy-ya Date: Mon, 30 Dec 2024 20:40:24 +0500 Subject: [PATCH] fix(CI): replace `--64bits` with `--32bits` fix(Build): Add missing mapbase functions. --- .github/workflows/build.yml | 10 +-- .github/workflows/tests.yml | 6 +- game/server/baseentity.cpp | 129 ++++++++++++++++++++++++++++++++++++ game/server/baseentity.h | 12 ++++ 4 files changed, 149 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f55a00ba..0e71ffd6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - bits: ['', '--64bits'] + bits: ['', '--32bits'] android: [''] flags: ['', '-d'] include: @@ -82,20 +82,20 @@ jobs: run: brew install sdl2 - name: Configure - run: ./waf configure --64bits ${{ matrix.flags }} $WAF_FLAGS + run: ./waf configure ${{ matrix.flags }} $WAF_FLAGS - name: Build macos-amd64 run: ./waf install --strip-to-file - name: Upload build uses: actions/upload-artifact@v3 with: - name: macOS--64bits${{matrix.flags}}${{matrix.android}} + name: macOS${{matrix.flags}}${{matrix.android}} path: | build_hl2 !build_hl2/**/*.dSYM - name: Upload debug symbols uses: actions/upload-artifact@v3 with: - name: debug-macOS--64bits${{matrix.flags}}${{matrix.android}} + name: debug-macOS${{matrix.flags}}${{matrix.android}} path: | build_hl2/**/*.dSYM @@ -104,7 +104,7 @@ jobs: fail-fast: false matrix: os: [windows-2019] - bits: ['', '--64bits'] + bits: ['', '--32bits'] flags: ['', '-d'] runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f027216a..59d0e368 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, ubuntu-20.04] - bits: ['', '--64bits'] + bits: ['', '--32bits'] android: [''] runs-on: ${{ matrix.os }} env: @@ -51,7 +51,7 @@ jobs: submodules: recursive - name: Configure - run: ./waf configure --64bits $WAF_FLAGS + run: ./waf configure $WAF_FLAGS - name: Build macos-amd64 run: ./waf install - name: Run tests @@ -63,7 +63,7 @@ jobs: strategy: matrix: os: [windows-2019] - bits: ['', '--64bits'] + bits: ['', '--32bits'] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 diff --git a/game/server/baseentity.cpp b/game/server/baseentity.cpp index e66879e4..de162fdf 100644 --- a/game/server/baseentity.cpp +++ b/game/server/baseentity.cpp @@ -64,6 +64,10 @@ #include "tier1/mapbase_con_groups.h" #include "utlhashtable.h" +#ifdef MAPBASE_VSCRIPT +#include "mapbase/matchers.h" +#endif + #if defined( TF_DLL ) #include "tf_gamerules.h" #endif @@ -7112,6 +7116,131 @@ int CBaseEntity::FindContextByName( const char *name ) const return -1; } +#ifdef MAPBASE_VSCRIPT +//----------------------------------------------------------------------------- +// Purpose: Searches entity for named context string and/or value. +// Intended to be called by entities rather than the conventional response system. +// Input : *name - Context name. +// *value - Context value. (optional) +// Output : bool +//----------------------------------------------------------------------------- +bool CBaseEntity::HasContext( const char *name, const char *value ) const +{ + int c = m_ResponseContexts.Count(); + for ( int i = 0; i < c; i++ ) + { + if ( Matcher_NamesMatch( name, STRING(m_ResponseContexts[i].m_iszName) ) ) + { + if (value == NULL) + return true; + else + return Matcher_Match(STRING(m_ResponseContexts[i].m_iszValue), value); + } + } + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: Searches entity for named context string and/or value. +// Intended to be called by entities rather than the conventional response system. +// Input : *name - Context name. +// *value - Context value. (optional) +// Output : bool +//----------------------------------------------------------------------------- +bool CBaseEntity::HasContext( string_t name, string_t value ) const +{ + int c = m_ResponseContexts.Count(); + for ( int i = 0; i < c; i++ ) + { + if ( name == m_ResponseContexts[i].m_iszName ) + { + if (value == NULL_STRING) + return true; + else + return value == m_ResponseContexts[i].m_iszValue; + } + } + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: Searches entity for named context string and/or value. +// Intended to be called by entities rather than the conventional response system. +// Input : *nameandvalue - Context name and value. +// Output : bool +//----------------------------------------------------------------------------- +bool CBaseEntity::HasContext( const char *nameandvalue ) const +{ + char key[ 128 ]; + char value[ 128 ]; + + const char *p = nameandvalue; + while ( p ) + { + p = SplitContext( p, key, sizeof( key ), value, sizeof( value ), NULL ); + + return HasContext( key, value ); + } + + return false; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : index - +// Output : const char +//----------------------------------------------------------------------------- +const char *CBaseEntity::GetContextValue( const char *contextName ) const +{ + int idx = FindContextByName( contextName ); + if ( idx == -1 ) + return ""; + + return m_ResponseContexts[ idx ].m_iszValue.ToCStr(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +float CBaseEntity::GetContextExpireTime( const char *name ) +{ + int idx = FindContextByName( name ); + if ( idx == -1 ) + return 0.0f; + + return m_ResponseContexts[ idx ].m_fExpirationTime; +} + +//----------------------------------------------------------------------------- +// Purpose: Internal method or removing contexts and can remove multiple contexts in one call +// Input : *contextName - +//----------------------------------------------------------------------------- +void CBaseEntity::RemoveContext( const char *contextName ) +{ + char key[ 128 ]; + char value[ 128 ]; + float duration; + + const char *p = contextName; + while ( p ) + { + duration = 0.0f; + p = SplitContext( p, key, sizeof( key ), value, sizeof( value ), &duration ); + if ( duration ) + { + duration += gpGlobals->curtime; + } + + int iIndex = FindContextByName( key ); + if ( iIndex != -1 ) + { + m_ResponseContexts.Remove( iIndex ); + } + } +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Input : inputdata - diff --git a/game/server/baseentity.h b/game/server/baseentity.h index e899195d..374ada08 100644 --- a/game/server/baseentity.h +++ b/game/server/baseentity.h @@ -909,6 +909,18 @@ protected: const char *GetContextValue( int index ) const; // note: context may be expired bool ContextExpired( int index ) const; int FindContextByName( const char *name ) const; + +#ifdef MAPBASE_VSCRIPT +public: + + bool HasContext( const char *name, const char *value ) const; + bool HasContext( string_t name, string_t value ) const; // NOTE: string_t version only compares pointers! + bool HasContext( const char *nameandvalue ) const; + const char *GetContextValue( const char *contextName ) const; + float GetContextExpireTime( const char *name ); + void RemoveContext( const char *nameandvalue ); +#endif + public: void AddContext( const char *nameandvalue ); void AddContext( const char *name, const char *value, float duration = 0.0f );