Merge branch 'mapbase-source:develop' into develop

This commit is contained in:
arbabf 2022-10-22 12:30:51 +11:00 committed by GitHub
commit 0c9883f5e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 985 additions and 63 deletions

View File

@ -23,12 +23,12 @@ All contributions must follow the following rules:
is usually not fit for Mapbase.
* All content in a contribution must be either already legally open-source or done with the
full permission of the content's original creator(s). If licensing is involved, the contribution
must ensure Mapbase follows said licensing.
full permission of the content's original creator(s). If a license is involved, the contributor
should ensure Mapbase conforms to its terms.
* **NOTE:** Due to concerns with mods which do not wish to be open-source, content using GPL licenses (or any
license with similar open-source requirements) are currently not allowed to be distributed with Mapbase.
Contributions which can draw from them without actually distributing the licensed content may theoretically
be excepted from this rule.
Contributions which can draw from them without actually distributing the licensed content may be excepted
from this rule.
* Contributions must not break existing maps/content or interfere with them in a negative or non-objective way.
@ -41,13 +41,19 @@ All contributions must follow the following rules:
* Do not modify the README to add attribution for your contribution. That is handled by Mapbase's maintainers.
Contributions which do not follow these guidelines cannot be accepted into Mapbase.
Attempting to contribute content which seriously violates the rules above can lead to being blocked from contributing,
especially if done repeatedly.
Contributions which do not follow these guidelines cannot be accepted into Mapbase. Attempting to contribute content
which seriously violates the rules above can lead to being blocked from contributing, especially if done repeatedly.
---
Mapbase uses GitHub Actions to help manage issues and pull requests. Some of these workflows build the code of incoming
contributions to make sure they compile properly. The code is compiled separately for Visual Studio 2022 and GCC/G++ 9 (Linux)
and on both Debug and Release configurations.
If these workflows fail, don't freak out! Accidents can happen frequently due to compiler syntax differences and conflicts
from other contributions. You can look at a failed workflow's log by clicking "Details", which will include the build's output.
Any errors must be resolved by you and/or by code reviewers before a pull request can be merged.
If your contribution is accepted, you may be listed in Mapbase's credits and the README's external content list:
https://github.com/mapbase-source/source-sdk-2013/wiki/Mapbase-Credits#Contributors
https://github.com/mapbase-source/source-sdk-2013/blob/master/README

27
.github/labeler.yml vendored Normal file
View File

@ -0,0 +1,27 @@
#
# MAPBASE REPO AUTOMATION
#
# Automatically labels pull requests according to changed file paths.
# See mapbase_pr.yml for more information.
#
Repo:
- '*'
- '.github/**'
Project Generation:
- '**/src/vpc_scripts/**'
- '**/src/devtools/**'
- '**/src/create*'
Entities:
- '**/src/game/**/**logic**'
- '**/src/game/**/**point**'
Shaders:
- '**/src/materialsystem/**'
VScript:
- '**vscript**'
Tools:
- '**utils**'

View File

@ -0,0 +1,68 @@
#
# MAPBASE SOURCE 2013 CI
#
# This can be used to manually build the codebase.
#
# See mapbase_build-base.yml for more information on how this works.
name: Build Projects (Manual)
on:
workflow_dispatch:
inputs:
configuration:
description: 'Which configuration to build with'
default: 'Release'
required: true
type: choice
options:
- Release
- Debug
branch:
description: 'Which Source 2013 engine branch to compile for'
default: 'sp'
required: true
type: choice
options:
- sp
- mp
game:
description: 'Name of the game to build (if relevant)'
default: 'episodic'
required: false
type: choice
options:
- episodic
- hl2
project-group:
description: 'Which group of projects to compile'
required: true
type: choice
options:
- all
- game
- shaders
- maptools
solution-name:
description: 'Name of the solution/makefile'
required: true
type: choice
options:
- everything
- games
- shaders
- maptools
build-on-linux:
description: 'Build on Ubuntu/Linux?'
default: true
required: false
type: boolean
jobs:
build_manual:
uses: mapbase-source/source-sdk-2013/.github/workflows/mapbase_build-base.yml@feature/github-workflows
with:
configuration: '${{ github.event.inputs.configuration }}'
branch: '${{ github.event.inputs.branch }}'
project-group: '${{ github.event.inputs.project-group }}'
solution-name: '${{ github.event.inputs.solution-name }}'

265
.github/workflows/mapbase_build-base.yml vendored Normal file
View File

@ -0,0 +1,265 @@
#
# MAPBASE SOURCE 2013 CI
#
# This workflow script automatically builds the Source SDK 2013 codebase on Windows and Linux using GitHub Actions.
#
# This is useful in a number of ways:
#
# 1. It ensures pull requests compile correctly on multiple platforms and provides binaries that can be used to test them.
# 2. It can be used to compile code for releases without having to pull and prepare a local development environment.
# 3. It opens potential for scripts that can employ more principles of CI/CD. (e.g. automatically publishing a release)
#
# This is based on a workflow originally created by z33ky.
name: Build Projects
on:
workflow_call:
inputs:
configuration:
description: 'Which configuration to build with'
default: 'Release'
required: true
type: string
branch:
description: 'Which Source 2013 engine branch to compile for'
default: 'sp'
required: true
type: string
game:
description: 'The name of the game to build (if relevant)'
default: 'episodic'
required: false
type: string
project-group:
description: 'Which group of projects to compile'
required: true
type: string
solution-name:
description: 'The name of the solution/makefile'
required: true
type: string
build-on-linux:
description: 'Build on Ubuntu/Linux?'
default: true
required: false
type: boolean
jobs:
build_windows:
name: Windows (VS2022)
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: Enable VS2022
working-directory: '${{inputs.branch}}/src/vpc_scripts'
shell: bash
run: sed -i 's/^\($Conditional[ ]\+VS2022[ ]\+\).*/\1"1"/' newer_vs_toolsets.vpc
- name: Pick game
if: inputs.project-group == 'game' || inputs.project-group == 'shaders'
working-directory: '${{inputs.branch}}/src'
shell: bash
run: sed -i 's/\/hl2 \/episodic/\/${{inputs.game}}/' create${{inputs.project-group}}projects.bat
- name: Create project files
working-directory: '${{inputs.branch}}/src'
shell: cmd
# https://github.com/ValveSoftware/source-sdk-2013/issues/72
run: |
reg add "HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\10.0\Projects\{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" /v DefaultProjectExtension /t REG_SZ /d vcproj /f
create${{inputs.project-group}}projects.bat
# --------------------------------------------------------------------
# "I'm invoking msbuild for each project individually, which looks a bit odd considering there is a solution file which should be able to invoke the builds in their proper order automatically, but passing the solution to msbuild doesn't seem to work."
# https://github.com/mapbase-source/source-sdk-2013/pull/162
- name: Build mathlib
#if: steps.filter.outputs.game == 'true'
working-directory: '${{inputs.branch}}/src'
shell: cmd
run: |
msbuild -m -p:Configuration=${{inputs.configuration}} mathlib\mathlib.vcxproj
- name: Build Base Libraries
if: inputs.project-group == 'all' || inputs.project-group == 'game' || inputs.project-group == 'maptools'
working-directory: '${{inputs.branch}}/src'
shell: cmd
run: |
msbuild -m -p:Configuration=${{inputs.configuration}} raytrace\raytrace.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} tier1\tier1.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} vgui2\vgui_controls\vgui_controls.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} vscript\vscript.vcxproj
- name: Build Map Tools
if: inputs.project-group == 'all' || inputs.project-group == 'maptools'
working-directory: '${{inputs.branch}}/src'
shell: cmd
run: |
msbuild -m -p:Configuration=${{inputs.configuration}} fgdlib\fgdlib.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} utils\vbsp\vbsp.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} utils\vvis\vvis_dll.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} utils\vvis_launcher\vvis_launcher.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} utils\vrad\vrad_dll.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} utils\vrad_launcher\vrad_launcher.vcxproj
- name: Build Shaders
if: inputs.project-group == 'shaders'
working-directory: '${{inputs.branch}}/src'
shell: cmd
run: |
msbuild -m -p:Configuration=${{inputs.configuration}} materialsystem\stdshaders\game_shader_dx9_${{inputs.game}}.vcxproj
- name: Build Game
if: inputs.project-group == 'game'
working-directory: '${{inputs.branch}}/src'
shell: cmd
run: |
msbuild -m -p:Configuration=${{inputs.configuration}} responserules\runtime\responserules.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} game\client\client_${{inputs.game}}.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} game\server\server_${{inputs.game}}.vcxproj
# TODO: Hook to game naming?
- name: Build everything
if: inputs.project-group == 'all'
working-directory: '${{inputs.branch}}/src'
shell: cmd
run: |
msbuild -m -p:Configuration=${{inputs.configuration}} responserules\runtime\responserules.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} materialsystem\stdshaders\game_shader_dx9_episodic.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} materialsystem\stdshaders\game_shader_dx9_hl2.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} game\client\client_episodic.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} game\client\client_hl2.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} game\server\server_episodic.vcxproj
msbuild -m -p:Configuration=${{inputs.configuration}} game\server\server_hl2.vcxproj
# --------------------------------------------------------------------
- name: Publish Windows game DLLs
if: inputs.project-group == 'all' || inputs.project-group == 'game'
uses: actions/upload-artifact@v3
with:
name: 'Windows Game DLLs (server & client.dll) [${{ inputs.configuration }}]'
path: |
${{inputs.branch}}/game/mod_${{inputs.game}}/bin/client.dll
${{inputs.branch}}/game/mod_${{inputs.game}}/bin/server.dll
if-no-files-found: error
- name: Publish Windows shader DLL
if: inputs.project-group == 'shaders'
uses: actions/upload-artifact@v3
with:
name: 'Windows Shader DLL (game_shader_dx9.dll) [${{ inputs.configuration }}]'
path: |
${{inputs.branch}}/game/mod_${{inputs.game}}/bin/game_shader_dx9.dll
if-no-files-found: error
- name: Publish Windows map tools
if: inputs.project-group == 'maptools'
uses: actions/upload-artifact@v3
with:
name: 'Windows Map Tools [${{ inputs.configuration }}]'
path: |
${{inputs.branch}}/game/bin/vbsp.exe
${{inputs.branch}}/game/bin/vvis.exe
${{inputs.branch}}/game/bin/vvis_dll.dll
${{inputs.branch}}/game/bin/vrad.exe
${{inputs.branch}}/game/bin/vrad_dll.dll
if-no-files-found: error
- name: Publish everything (Windows)
if: inputs.project-group == 'all'
uses: actions/upload-artifact@v3
with:
name: 'Everything (Windows) [${{ inputs.configuration }}]'
path: |
${{inputs.branch}}/game/bin
${{inputs.branch}}/game/mod_*/bin
if-no-files-found: error
build_ubuntu:
if: inputs.build-on-linux == true && inputs.project-group != 'maptools' # No Linux map tools for now
name: Ubuntu (GCC/G++)
runs-on: ubuntu-latest
env:
config: ${{ inputs.configuration }}
steps:
- uses: actions/checkout@v3
- name: Install GCC/G++ multilib
run: sudo apt-get install gcc-multilib g++-multilib
- name: Pick game
if: inputs.project-group == 'game' || inputs.project-group == 'shaders'
working-directory: '${{inputs.branch}}/src'
shell: bash
run: sed -i 's/\/hl2 \/episodic/\/${{inputs.game}}/' create${{inputs.project-group}}projects
- name: Set configuration
working-directory: '${{inputs.branch}}/src'
shell: bash
run: |
config=${{inputs.configuration}}
export CFG=${config,,}
echo "config=${CFG}" >> $GITHUB_ENV
- name: Create project files
working-directory: '${{inputs.branch}}/src'
run: sudo ./create${{inputs.project-group}}projects
# --------------------------------------------------------------------
- name: Build
working-directory: '${{inputs.branch}}/src'
run: make CFG=${{env.config}} -f ${{inputs.solution-name}}.mak
# --------------------------------------------------------------------
- name: Publish Linux game SOs
if: inputs.project-group == 'game'
uses: actions/upload-artifact@v3
with:
name: 'Linux Game SOs (server & client.so) [${{ inputs.configuration }}]'
path: |
${{inputs.branch}}/game/mod_${{inputs.game}}/bin/client.so
${{inputs.branch}}/game/mod_${{inputs.game}}/bin/server.so
if-no-files-found: error
- name: Publish Linux shader SO
if: inputs.project-group == 'shaders'
uses: actions/upload-artifact@v3
with:
name: 'Linux Shader SO (game_shader_dx9.so) [${{ inputs.configuration }}]'
path: |
${{inputs.branch}}/game/mod_${{inputs.game}}/bin/game_shader_dx9.so
if-no-files-found: error
#- name: Publish Linux map tools
# if: inputs.project-group == 'maptools'
# uses: actions/upload-artifact@v3
# with:
# name: 'Linux Map Tools [${{ inputs.configuration }}]'
# path: |
# ${{inputs.branch}}/game/bin/vbsp
# ${{inputs.branch}}/game/bin/vvis
# ${{inputs.branch}}/game/bin/vvis_dll.so
# ${{inputs.branch}}/game/bin/vrad
# ${{inputs.branch}}/game/bin/vrad_dll.so
# if-no-files-found: error
- name: Publish everything (Linux)
if: inputs.project-group == 'all'
uses: actions/upload-artifact@v3
with:
name: 'Everything (Linux) [${{ inputs.configuration }}]'
path: |
${{inputs.branch}}/game/bin
${{inputs.branch}}/game/mod_*/bin
if-no-files-found: error

View File

@ -0,0 +1,37 @@
#
# MAPBASE SOURCE 2013 CI
#
# Builds game projects every time a pull request which modifies the game code is opened.
# If you're using a fork of Mapbase, feel free to configure this to meet your repository's needs.
#
# See mapbase_build-base.yml for more information on how this works.
name: Build Game Projects #(SP Release)
on:
pull_request:
branches:
- develop
paths:
- '.github/workflows/mapbase_build-sp-rel-games.yml'
- 'sp/src/vpc_scripts/**'
- 'sp/src/game/**'
- 'sp/src/mathlib/**'
- 'sp/src/responserules/runtime/**'
- 'sp/src/tier1/**'
- 'sp/src/vgui2/vgui_controls/**'
- 'sp/src/vscript/**'
jobs:
games:
strategy:
matrix:
configuration: [Release, Debug]
uses: ./.github/workflows/mapbase_build-base.yml
with:
configuration: ${{ matrix.configuration }}
branch: 'sp'
game: 'episodic' # Change this if your mod is not using HL2/Episodic game projects
project-group: 'game'
solution-name: 'games'
build-on-linux: true # Disable this if you don't want to compile for Linux

View File

@ -0,0 +1,38 @@
#
# MAPBASE SOURCE 2013 CI
#
# Builds map tool projects every time a pull request which modifies the map tool code is opened.
# If you're using a fork of Mapbase, feel free to configure this to meet your repository's needs.
#
# See mapbase_build-base.yml for more information on how this works.
name: Build Map Tool Projects #(SP Release)
on:
pull_request:
branches:
- develop
paths:
- '.github/workflows/mapbase_build-sp-rel-maptools.yml'
- 'sp/src/vpc_scripts/**'
- 'sp/src/utils/vbsp/**'
- 'sp/src/utils/vvis/**'
- 'sp/src/utils/vvis_launcher/**'
- 'sp/src/utils/vrad/**'
- 'sp/src/utils/vrad_launcher/**'
- 'sp/src/mathlib/**'
- 'sp/src/tier1/**'
- 'sp/src/vgui2/vgui_controls/**'
- 'sp/src/vscript/**'
jobs:
maptools:
strategy:
matrix:
configuration: [Release, Debug]
uses: ./.github/workflows/mapbase_build-base.yml
with:
configuration: ${{ matrix.configuration }}
branch: 'sp'
project-group: 'maptools'
solution-name: 'maptools'

View File

@ -0,0 +1,33 @@
#
# MAPBASE SOURCE 2013 CI
#
# Builds shader projects every time a pull request which modifies the shader code is opened.
# If you're using a fork of Mapbase, feel free to configure this to meet your repository's needs.
#
# See mapbase_build-base.yml for more information on how this works.
name: Build Shader Projects #(SP Release)
on:
pull_request:
branches:
- develop
paths:
- '.github/workflows/mapbase_build-sp-rel-shaders.yml'
- 'sp/src/vpc_scripts/**'
- 'sp/src/materialsystem/**'
- 'sp/src/mathlib/**'
jobs:
shaders:
strategy:
matrix:
configuration: [Release, Debug]
uses: ./.github/workflows/mapbase_build-base.yml
with:
configuration: ${{ matrix.configuration }}
branch: 'sp'
game: 'episodic' # Change this if your mod is not using HL2/Episodic game projects
project-group: 'shaders'
solution-name: 'shaders'
build-on-linux: true # Disable this if you don't want to compile for Linux

23
.github/workflows/mapbase_pr.yml vendored Normal file
View File

@ -0,0 +1,23 @@
#
# MAPBASE REPO AUTOMATION
#
# Automatically labels pull requests according to changed file paths.
# See mapbase_triage-pr.yml for more information.
#
# https://github.com/actions/labeler
name: Pull Request Automation
on: [pull_request]
jobs:
label:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

12
README
View File

@ -1,6 +1,6 @@
//===================================================================================================================================================
Mapbase v7.0 - Source 2013
Mapbase v7.1 - Source 2013
https://github.com/mapbase-source/source-sdk-2013
https://www.moddb.com/mods/mapbase
@ -101,16 +101,18 @@ interchangeable arms; this may change in the future)
Direct contributions:
- https://github.com/mapbase-source/source-sdk-2013/pull/3 ("playvideo" command playback fix from Avanate)
- https://github.com/mapbase-source/source-sdk-2013/pull/5 (Custom VScript implementation by ReDucTor; was placed into feature branch before being merged in a subsequent PR)
- https://github.com/mapbase-source/source-sdk-2013/pull/3 ("playvideo" command playback fix from Avantate)
- https://github.com/mapbase-source/source-sdk-2013/pull/60 (Adjustment by RoyaleNoir to one of Saul's VDC changes)
- https://github.com/mapbase-source/source-sdk-2013/pull/84 (CS:S viewmodel chirality from 1upD)
- https://github.com/mapbase-source/source-sdk-2013/pull/116 (vgui_movie_display mute keyvalue from Alivebyte/rzkid)
- https://github.com/mapbase-source/source-sdk-2013/pull/140 (logic_substring entity and icon created by moofemp)
- https://github.com/mapbase-source/source-sdk-2013/pull/143 (Propper features for VBSP from Matty-64)
- https://github.com/mapbase-source/source-sdk-2013/pull/174 (Fix for multiply defined symbols in later toolsets from und)
- https://github.com/mapbase-source/source-sdk-2013/issues/201 (env_projectedtexture shadow filter keyvalue from celisej567)
- Demo autorecord code provided by Klems
- cc_emit crash fix provided by 1upD
- Custom HL2 ammo crate models created by Rara (Textures created by Blixibon; This is asset-based and, aside from the SLAM crate, not reflected in the code)
- Custom HL2 ammo crate models created by Rykah (Textures created by Blixibon; This is asset-based and, aside from the SLAM crate, not reflected in the code)
- Combine lock hardware on door01_left.mdl created by Kralich (This is asset-based and not reflected in the code)
- npc_vehicledriver fixes provided by CrAzY
- npc_combine cover behavior patches provided by iohnnyboy
@ -180,6 +182,10 @@ Other relevant articles:
* https://github.com/mapbase-source/source-sdk-2013/wiki/Mapbase-Disclaimers
* https://github.com/mapbase-source/source-sdk-2013/wiki/Frequently-Asked-Questions-(FAQ)
//---------------------------------------------------------------------------------------------------------------------------------------------------
In memory of Holly Liberatore (moofemp)
//===================================================================================================================================================
Please see the Source SDK 2013 license below:

5
sp/src/createmaptoolsprojects Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
pushd `dirname $0`
devtools/bin/vpc /hl2 /episodic +maptools /mksln maptools
popd

View File

@ -0,0 +1 @@
devtools\bin\vpc.exe +maptools /mksln maptools.sln

5
sp/src/createshadersprojects Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
pushd `dirname $0`
devtools/bin/vpc /hl2 /episodic +shaders /mksln shaders
popd

View File

@ -0,0 +1 @@
devtools\bin\vpc.exe /hl2 /episodic +shaders /mksln shaders.sln

View File

@ -11,6 +11,6 @@ $(MAKEFILE_LINK): $(shell which $(CXX)) $(THISFILE) $(SRCROOT)/devtools/gcc9+sup
@ if [ "$(shell printf "$(shell $(CXX) -dumpversion)\n8" | sort -Vr | head -1)" = 8 ]; then \
ln -sf $(MAKEFILE_BASE).default $@ ;\
else \
$(COMPILE.cpp) -o $(SRCROOT)/devtools/gcc9+support.o $(SRCROOT)/devtools/gcc9+support.cpp &&\
$(COMPILE.cpp) -m32 -o $(SRCROOT)/devtools/gcc9+support.o $(SRCROOT)/devtools/gcc9+support.cpp &&\
ln -sf $(MAKEFILE_BASE).gcc8 $@ ;\
fi

View File

@ -92,6 +92,7 @@ private:
float m_flLinearAtten;
float m_flQuadraticAtten;
float m_flShadowAtten;
float m_flShadowFilter;
bool m_bAlwaysDraw;
//bool m_bProjectedTextureVersion;

View File

@ -60,6 +60,7 @@ IMPLEMENT_CLIENTCLASS_DT( C_EnvProjectedTexture, DT_EnvProjectedTexture, CEnvPro
RecvPropFloat( RECVINFO( m_flLinearAtten ) ),
RecvPropFloat( RECVINFO( m_flQuadraticAtten ) ),
RecvPropFloat( RECVINFO( m_flShadowAtten ) ),
RecvPropFloat( RECVINFO( m_flShadowFilter ) ),
RecvPropBool( RECVINFO( m_bAlwaysDraw ) ),
// Not needed on the client right now, change when it actually is needed
@ -97,6 +98,7 @@ C_EnvProjectedTexture *C_EnvProjectedTexture::Create( )
pEnt->m_flLinearAtten = 100.0f;
pEnt->m_flQuadraticAtten = 0.0f;
pEnt->m_flShadowAtten = 0.0f;
pEnt->m_flShadowFilter = 0.5f;
//pEnt->m_bProjectedTextureVersion = 1;
#endif
@ -403,6 +405,7 @@ void C_EnvProjectedTexture::UpdateLight( void )
state.m_flShadowSlopeScaleDepthBias = mat_slopescaledepthbias_shadowmap.GetFloat();
state.m_flShadowDepthBias = mat_depthbias_shadowmap.GetFloat();
state.m_flShadowAtten = m_flShadowAtten;
state.m_flShadowFilterSize = m_flShadowFilter;
#else
state.m_fQuadraticAtten = 0.0;
state.m_fLinearAtten = 100;

View File

@ -120,6 +120,7 @@ private:
// HACKHACK: Needed as a failsafe to prevent desync
int m_iCCDefaultY;
float m_flCCAnimTime;
bool m_bShouldRepositionSubtitles;
#endif
@ -248,7 +249,7 @@ public:
#ifdef MAPBASE
// Special commentary localization file (useful for things like text nodes or print names)
g_pVGuiLocalize->AddFile( "resource/commentary_%language%.txt" );
g_pVGuiLocalize->AddFile( "resource/commentary_%language%.txt", "MOD", true );
#endif
}
@ -910,6 +911,7 @@ CHudCommentary::CHudCommentary( const char *name ) : vgui::Panel( NULL, "HudComm
m_pFootnoteLabel = new vgui::Label( this, "HudCommentaryFootnoteLabel", L"Commentary footnote" );
m_iCCDefaultY = 0;
m_flCCAnimTime = 0.0f;
#endif
}
@ -1415,6 +1417,9 @@ void CHudCommentary::StartCommentary( C_PointCommentaryNode *pNode, char *pszSpe
{
m_bShouldPaint = true;
m_bShouldRepositionSubtitles = true;
// Ensure we perform layout later
InvalidateLayout();
}
else
m_bShouldRepositionSubtitles = false;
@ -1634,6 +1639,9 @@ void CHudCommentary::StartSceneCommentary( C_PointCommentaryNode *pNode, char *p
{
m_bShouldPaint = true;
m_bShouldRepositionSubtitles = true;
// Ensure we perform layout later
InvalidateLayout();
}
else
m_bShouldRepositionSubtitles = false;
@ -1697,13 +1705,16 @@ void CHudCommentary::FixupCommentaryLabels( const char *pszPrintName, const char
}
else
{
static wchar_t iszPrintNameLocalized[MAX_SPEAKER_NAME];
static wchar_t iszSpeakersLocalized[MAX_SPEAKER_NAME] = { 0 };
static wchar_t iszPrintNameLocalized[MAX_SPEAKER_NAME] = { 0 };
wcsncpy( iszSpeakersLocalized, m_szSpeakers, sizeof( iszSpeakersLocalized ) / sizeof( wchar_t ) );
if (m_szSpeakers[0] == '#')
{
wchar_t *pwszSpeakers = g_pVGuiLocalize->Find( pszSpeakers );
if (pwszSpeakers)
wcsncpy( m_szSpeakers, pwszSpeakers, sizeof( m_szSpeakers ) / sizeof( wchar_t ) );
wcsncpy( iszSpeakersLocalized, pwszSpeakers, sizeof( iszSpeakersLocalized ) / sizeof( wchar_t ) );
}
if (pszPrintName[0] == '#' && pszLocal)
@ -1711,7 +1722,7 @@ void CHudCommentary::FixupCommentaryLabels( const char *pszPrintName, const char
else
g_pVGuiLocalize->ConvertANSIToUnicode( pszPrintName, iszPrintNameLocalized, sizeof( iszPrintNameLocalized ) );
V_snwprintf( m_szSpeakers, sizeof( m_szSpeakers ), L"%ls ~ %ls", m_szSpeakers, iszPrintNameLocalized );
V_snwprintf( m_szSpeakers, sizeof( m_szSpeakers ), L"%ls ~ %ls", iszSpeakersLocalized, iszPrintNameLocalized );
}
}
@ -1781,9 +1792,17 @@ void CHudCommentary::RepositionAndFollowCloseCaption( int yOffset )
// Run this animation command instead of setting the position directly
g_pClientMode->GetViewportAnimationController()->RunAnimationCommand( pHudCloseCaption, "YPos", ccY - yOffset, 0.0f, 0.2f, vgui::AnimationController::INTERPOLATOR_DEACCEL );
//pHudCloseCaption->SetPos( ccX, ccY );
m_flCCAnimTime = gpGlobals->curtime + 0.2f;
pHudCloseCaption->SetUsingCommentaryDimensions( true );
}
else if (gpGlobals->curtime > m_flCCAnimTime && ccY != m_iCCDefaultY - m_iTypeAudioT - yOffset)
{
DevMsg( "CHudCommentary had to correct misaligned CC element offset (%i != %i)\n", m_iCCDefaultY - ccY, yOffset );
g_pClientMode->GetViewportAnimationController()->RunAnimationCommand( pHudCloseCaption, "YPos", m_iCCDefaultY - m_iTypeAudioT - yOffset, 0.0f, 0.2f, vgui::AnimationController::INTERPOLATOR_DEACCEL );
m_flCCAnimTime = gpGlobals->curtime + 0.2f;
}
SetPos( ccX, ccY + pHudCloseCaption->GetTall() + commentary_audio_element_below_cc_margin.GetInt() );

View File

@ -71,7 +71,6 @@ $Configuration
$SystemFrameworks "Carbon" [$OSXALL]
$SystemLibraries "rt" [$LINUXALL]
$IgnoreImportLibrary "TRUE"
$AdditionalOptions "$BASE /force:multiple" [($VS2015||$VS2017||$VS2019||$VS2022)] // Required to fix _hypot in particles.lib (this may be a temporary solution)
$AdditionalDependencies "$BASE winmm.lib" [$WIN32]
$AdditionalDependencies "$BASE wsock32.lib Ws2_32.lib" [$BUILD_REPLAY]
}
@ -1261,6 +1260,9 @@ $Project
$Lib vtf
$ImpLib steam_api
// Discord integration
$Lib "$LIBPUBLIC\discord-rpc" [$MAPBASE_RPC]
$Lib $LIBCOMMON/libcrypto [$POSIX]
$ImpLib "$LIBCOMMON\curl" [$OSXALL]

View File

@ -644,6 +644,15 @@ void CHudWeaponSelection::Paint()
// This is a bit of a misnomer... we really are asking "Is this the selected slot"?
selectedWeapon = true;
}
#ifdef MAPBASE
else if (!hud_showemptyweaponslots.GetBool() && !pWeapon)
{
// Revert the offset
xPos -= ( m_flMediumBoxWide + 5 ) * xModifiers[ i ];
yPos -= ( m_flMediumBoxTall + 5 ) * yModifiers[ i ];
continue;
}
#endif
// Draw the box with the appropriate icon
DrawLargeWeaponBox( pWeapon,
@ -1375,6 +1384,23 @@ void CHudWeaponSelection::PlusTypeFastWeaponSwitch( int iWeaponSlot )
// Changing vertical/horizontal direction. Reset the selected box position to zero.
m_iSelectedBoxPosition = 0;
m_iSelectedSlot = iWeaponSlot;
#ifdef MAPBASE
if (!hud_showemptyweaponslots.GetBool())
{
// Skip empty slots
int i = 0;
while ( i < MAX_WEAPON_POSITIONS )
{
C_BaseCombatWeapon *pWeapon = GetWeaponInSlot( iWeaponSlot, i );
if ( pWeapon )
break;
i++;
}
m_iSelectedBoxPosition = i;
}
#endif
}
else
{
@ -1385,6 +1411,27 @@ void CHudWeaponSelection::PlusTypeFastWeaponSwitch( int iWeaponSlot )
// Decrementing within the slot. If we're at the zero position in this slot,
// jump to the zero position of the opposite slot. This also counts as our increment.
increment = -1;
#ifdef MAPBASE
if (!hud_showemptyweaponslots.GetBool())
{
// Skip empty slots
int iZeroPos = 0;
while ( iZeroPos < MAX_WEAPON_POSITIONS )
{
C_BaseCombatWeapon *pWeapon = GetWeaponInSlot( m_iSelectedSlot, iZeroPos );
if ( pWeapon )
break;
iZeroPos++;
}
if ( iZeroPos == m_iSelectedBoxPosition )
{
newSlot = ( m_iSelectedSlot + 2 ) % 4;
m_iSelectedBoxPosition = increment = 0;
}
}
else
#endif
if ( 0 == m_iSelectedBoxPosition )
{
newSlot = ( m_iSelectedSlot + 2 ) % 4;
@ -1402,6 +1449,35 @@ void CHudWeaponSelection::PlusTypeFastWeaponSwitch( int iWeaponSlot )
lastSlotPos = slotPos;
}
}
#ifdef MAPBASE
if (!hud_showemptyweaponslots.GetBool())
{
// Skip empty slots
int i = m_iSelectedBoxPosition + increment;
while ( i >= 0 && i < lastSlotPos )
{
C_BaseCombatWeapon *pWeapon = GetWeaponInSlot( newSlot, i );
if ( !pWeapon )
{
if (increment < 0)
{
increment--;
i--;
}
else
{
increment++;
i++;
}
}
else
{
break;
}
}
}
#endif
// Increment/Decrement the selected box position
if ( m_iSelectedBoxPosition + increment <= lastSlotPos )

View File

@ -707,6 +707,10 @@ bool VScriptClientInit()
VScriptRunScript( "vscript_client", true );
VScriptRunScript( "mapspawn", false );
#ifdef MAPBASE_VSCRIPT
RunAddonScripts();
#endif
VMPROF_SHOW( pszScriptLanguage, "virtual machine startup" );
return true;

View File

@ -2025,7 +2025,8 @@ void CResponseSystem::ParseInclude( CStringPool &includedFiles )
if (len+1 != strlen(scriptfile))
{
Q_snprintf(includefile, sizeof(includefile), "%s/%s", includefile, token);
Q_strncat( includefile, "/", sizeof( includefile ) );
Q_strncat( includefile, token, sizeof( includefile ) );
}
else
includefile[0] = '\0';

View File

@ -1149,8 +1149,14 @@ void CAI_BaseActor::UpdateHeadControl( const Vector &vHeadTarget, float flHeadIn
Warning( "================================================================================\n"
"!!!!! %s tried to set a NaN head angle (can happen when look targets have >1 importance) !!!!!\n"
"================================================================================\n", GetDebugName() );
vTargetAngles.x = 0;
vTargetAngles.y = 0;
m_goalHeadCorrection.Init();
Set( m_FlexweightHeadRightLeft, 0.0f );
Set( m_FlexweightHeadUpDown, 0.0f );
Set( m_FlexweightHeadTilt, 0.0f );
Set( m_ParameterHeadYaw, 0.0f );
Set( m_ParameterHeadPitch, 0.0f );
Set( m_ParameterHeadRoll, 0.0f );
return;
}
#endif

View File

@ -2598,11 +2598,7 @@ bool CAI_BaseNPC::FValidateHintType ( CAI_Hint *pHint )
Activity CAI_BaseNPC::GetHintActivity( short sHintType, Activity HintsActivity )
{
if ( HintsActivity != ACT_INVALID )
#ifdef MAPBASE
return TranslateActivity( HintsActivity ); // Always translate the activity
#else
return HintsActivity;
#endif
return ACT_IDLE;
}

View File

@ -2930,9 +2930,9 @@ void CBaseAnimating::InvalidateBoneCache( void )
bool CBaseAnimating::TestCollision( const Ray_t &ray, unsigned int fContentsMask, trace_t& tr )
{
// Return a special case for scaled physics objects
if ( GetModelScale() != 1.0f )
IPhysicsObject *pPhysObject = VPhysicsGetObject();
if ( GetModelScale() != 1.0f && pPhysObject )
{
IPhysicsObject *pPhysObject = VPhysicsGetObject();
Vector vecPosition;
QAngle vecAngles;
pPhysObject->GetPosition( &vecPosition, &vecAngles );

View File

@ -50,6 +50,7 @@ BEGIN_DATADESC( CEnvProjectedTexture )
DEFINE_FIELD( m_flLinearAtten, FIELD_FLOAT ),
DEFINE_FIELD( m_flQuadraticAtten, FIELD_FLOAT ),
DEFINE_KEYFIELD( m_flShadowAtten, FIELD_FLOAT, "shadowatten" ),
DEFINE_KEYFIELD( m_flShadowFilter, FIELD_FLOAT, "shadowfilter" ),
#endif
DEFINE_INPUTFUNC( FIELD_VOID, "TurnOn", InputTurnOn ),
@ -77,6 +78,7 @@ BEGIN_DATADESC( CEnvProjectedTexture )
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetLinear", InputSetLinear ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetConstant", InputSetConstant ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetShadowAtten", InputSetShadowAtten ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFilter", InputSetFilter ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetNearZ", InputSetNearZ ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFarZ", InputSetFarZ ),
DEFINE_INPUTFUNC( FIELD_VOID, "AlwaysDrawOn", InputAlwaysDrawOn ),
@ -116,6 +118,7 @@ IMPLEMENT_SERVERCLASS_ST( CEnvProjectedTexture, DT_EnvProjectedTexture )
SendPropFloat( SENDINFO( m_flLinearAtten ) ),
SendPropFloat( SENDINFO( m_flQuadraticAtten ) ),
SendPropFloat( SENDINFO( m_flShadowAtten ) ),
SendPropFloat( SENDINFO( m_flShadowFilter ) ),
SendPropBool( SENDINFO( m_bAlwaysDraw ) ),
// Not needed on the client right now, change when it actually is needed
@ -158,6 +161,7 @@ CEnvProjectedTexture::CEnvProjectedTexture( void )
m_flLinearAtten = 100.0f;
m_flConstantAtten = 0.0f;
m_flShadowAtten = 0.0f;
m_flShadowFilter = 0.5f;
#endif
}
@ -316,6 +320,11 @@ void CEnvProjectedTexture::InputSetHorFOV( inputdata_t &inputdata )
{
m_flLightHorFOV = inputdata.value.Float();
}
void CEnvProjectedTexture::InputSetFilter( inputdata_t &inputdata )
{
m_flShadowFilter = inputdata.value.Float();
}
#endif
void CEnvProjectedTexture::InputSetTarget( inputdata_t &inputdata )

View File

@ -64,6 +64,7 @@ public:
void InputAlwaysDrawOff( inputdata_t &inputdata ) { m_bAlwaysDraw = false; }
void InputStopFollowingTarget( inputdata_t &inputdata ) { m_bDontFollowTarget = true; }
void InputStartFollowingTarget( inputdata_t &inputdata ) { m_bDontFollowTarget = false; }
void InputSetFilter( inputdata_t &inputdata );
// Corrects keyvalue/input attenuation for internal FlashlightEffect_t attenuation.
float CorrectConstantAtten( float fl ) { return fl * 0.5f; }
@ -105,6 +106,8 @@ private:
CNetworkVar( float, m_flQuadraticAtten );
CNetworkVar( float, m_flShadowAtten );
CNetworkVar( float, m_flShadowFilter );
CNetworkVar( bool, m_bAlwaysDraw );
// 1 = New projected texture

View File

@ -134,6 +134,12 @@ void CBaseFilter::InputTestActivator( inputdata_t &inputdata )
//-----------------------------------------------------------------------------
void CBaseFilter::InputTestEntity( inputdata_t &inputdata )
{
if ( !inputdata.value.Entity() )
{
// HACKHACK: Not firing OnFail in this case is intentional for the time being (activator shouldn't be null)
return;
}
if ( PassesFilter( inputdata.pCaller, inputdata.value.Entity() ) )
{
m_OnPass.FireOutput( inputdata.value.Entity(), m_bPassCallerWhenTested ? inputdata.pCaller : this );

View File

@ -131,6 +131,9 @@ public:
entity.name = m_nameList.AddString( pGlobalname );
entity.levelName = m_nameList.AddString( pMapName );
entity.state = state;
#ifdef MAPBASE
entity.counter = 0;
#endif
int index = GetIndex( m_nameList.String( entity.name ) );
if ( index >= 0 )

View File

@ -940,6 +940,14 @@ void CProtoSniper::OnScheduleChange( void )
{
LaserOff();
#ifdef MAPBASE
if ( m_bKilledPlayer && HasCondition( COND_SEE_PLAYER ) )
{
// IMPOSSIBLE! (possible when SP respawn is enabled)
m_bKilledPlayer = false;
}
#endif
BaseClass::OnScheduleChange();
}
@ -3439,6 +3447,18 @@ AI_BEGIN_CUSTOM_NPC( proto_sniper, CProtoSniper )
//=========================================================
//=========================================================
#ifdef MAPBASE
DEFINE_SCHEDULE
(
SCHED_PSNIPER_PLAYER_DEAD,
" Tasks"
" TASK_SNIPER_PLAYER_DEAD 0"
" "
" Interrupts"
" COND_SEE_PLAYER"
)
#else
DEFINE_SCHEDULE
(
SCHED_PSNIPER_PLAYER_DEAD,
@ -3448,6 +3468,7 @@ AI_BEGIN_CUSTOM_NPC( proto_sniper, CProtoSniper )
" "
" Interrupts"
)
#endif
AI_END_CUSTOM_NPC()

View File

@ -1405,9 +1405,16 @@ acttable_t CWeaponRPG::m_acttable[] =
{ ACT_GESTURE_RANGE_ATTACK1, ACT_GESTURE_RANGE_ATTACK_RPG, false },
#endif
#ifdef MAPBASE
// Readiness activities should not be required
{ ACT_IDLE_RELAXED, ACT_IDLE_RPG_RELAXED, false },
{ ACT_IDLE_STIMULATED, ACT_IDLE_ANGRY_RPG, false },
{ ACT_IDLE_AGITATED, ACT_IDLE_ANGRY_RPG, false },
#else
{ ACT_IDLE_RELAXED, ACT_IDLE_RPG_RELAXED, true },
{ ACT_IDLE_STIMULATED, ACT_IDLE_ANGRY_RPG, true },
{ ACT_IDLE_AGITATED, ACT_IDLE_ANGRY_RPG, true },
#endif
{ ACT_IDLE, ACT_IDLE_RPG, true },
{ ACT_IDLE_ANGRY, ACT_IDLE_ANGRY_RPG, true },

View File

@ -2283,11 +2283,7 @@ bool CDynamicProp::TestCollision( const Ray_t &ray, unsigned int mask, trace_t&
}
}
}
#ifdef MAPBASE // From Alien Swarm SDK
return BaseClass::TestCollision( ray, mask, trace );
#else
return false;
#endif
}
@ -4486,6 +4482,13 @@ void CBasePropDoor::CalcDoorSounds()
#endif
}
#ifdef MAPBASE
// This would still be -1 if the hardware wasn't valid
if (m_flNPCOpenDistance == -1)
m_flNPCOpenDistance = ai_door_enable_acts.GetBool() ? 32.0 : 64.0;
#endif
// If any sounds were missing, try the "defaults" block.
if ( ( strSoundOpen == NULL_STRING ) || ( strSoundClose == NULL_STRING ) || ( strSoundMoving == NULL_STRING ) ||
( strSoundLocked == NULL_STRING ) || ( strSoundUnlocked == NULL_STRING ) )

View File

@ -672,6 +672,8 @@ bool VScriptServerInit()
VScriptRunScript( "mapspawn", false );
#ifdef MAPBASE_VSCRIPT
RunAddonScripts();
// Since the world entity spawns before VScript is initted, RunVScripts() is called before the VM has started, so no scripts are run.
// This gets around that by calling the same function right after the VM is initted.
GetWorldEntity()->RunVScripts();

View File

@ -93,7 +93,7 @@ function __ReplaceClosures( script, scope )
local tempParent = { getroottable = function() { return null; } };
local temp = { runscript = script };
temp.set_delegate(tempParent);
temp.setdelegate(tempParent);
temp.runscript()
foreach( key,val in temp )

View File

@ -473,7 +473,7 @@ public:
void LoadFromValue( const char *value, int type, bool bDontWarn )
{
if (!filesystem->FileExists(value, "MOD"))
if (type != MANIFEST_VSCRIPT && !filesystem->FileExists(value, "MOD"))
{
if (!bDontWarn)
{

View File

@ -938,6 +938,26 @@ bool ScriptIsClient()
#endif
}
bool ScriptIsWindows()
{
return IsWindows();
}
bool ScriptIsLinux()
{
return IsLinux();
}
bool ScriptIsOSX()
{
return IsOSX();
}
bool ScriptIsPosix()
{
return IsPosix();
}
// Notification printing on the right edge of the screen
void NPrint( int pos, const char* fmt )
{
@ -1077,5 +1097,10 @@ void RegisterSharedScriptFunctions()
ScriptRegisterFunction( g_pScriptVM, GetFrameCount, "Absolute frame counter" );
//ScriptRegisterFunction( g_pScriptVM, GetTickCount, "Simulation ticks" );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptIsWindows, "IsWindows", "Returns true if the game is being run on a Windows machine." );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptIsLinux, "IsLinux", "Returns true if the game is being run on a Linux machine." );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptIsOSX, "IsOSX", "Returns true if the game is being run on an OSX machine." );
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptIsPosix, "IsPosix", "Returns true if the game is being run on a Posix machine." );
RegisterScriptSingletons();
}

View File

@ -1424,7 +1424,7 @@ void CNetMsgScriptHelper::ReceiveMessage( bf_read &msg )
m_MsgIn.StartReading( msg.m_pData, msg.m_nDataBytes );
#endif
DebugNetMsg( 2, DLL_LOC_STR " " __FUNCTION__ "()\n" );
DebugNetMsg( 2, DLL_LOC_STR " %s()", __FUNCTION__ );
// Don't do anything if there's no VM here. This can happen if a message from the server goes to a VM-less client, or vice versa.
if ( !g_pScriptVM )
@ -1483,7 +1483,7 @@ void CNetMsgScriptHelper::Start( const char *msg )
return;
}
DebugNetMsg( 1, DLL_LOC_STR " " __FUNCTION__ "() [%d]%s\n", Hash( msg ), msg );
DebugNetMsg( 1, DLL_LOC_STR " %s() [%d]%s\n", __FUNCTION__, Hash( msg ), msg );
#ifdef CLIENT_DLL
// Client can write multiple messages in a frame before the usercmd is sent,
@ -1519,7 +1519,7 @@ void CNetMsgScriptHelper::Start( const char *msg )
//-----------------------------------------------------------------------------
void CNetMsgScriptHelper::Send( HSCRIPT player, bool bReliable )
{
DebugNetMsg( 1, DLL_LOC_STR " " __FUNCTION__ "() size(%d)\n", GetNumBitsWritten() );
DebugNetMsg( 1, DLL_LOC_STR " %s() size(%d)\n", __FUNCTION__, GetNumBitsWritten() );
CBaseEntity *pPlayer = ToEnt(player);
if ( pPlayer )
@ -1544,7 +1544,7 @@ void CNetMsgScriptHelper::Send( HSCRIPT player, bool bReliable )
//-----------------------------------------------------------------------------
void CNetMsgScriptHelper::Send()
{
DebugNetMsg( 1, DLL_LOC_STR " " __FUNCTION__ "() size(%d)\n", m_bWriteIgnore ? 0 : GetNumBitsWritten() );
DebugNetMsg( 1, DLL_LOC_STR " %s() size(%d)\n", __FUNCTION__, m_bWriteIgnore ? 0 : GetNumBitsWritten() );
m_bWriteReady = true;
}

View File

@ -40,6 +40,15 @@ extern int vscript_token;
int vscript_token_hack = vscript_token;
#endif
static const char *pszExtensions[] =
{
"", // SL_NONE
".gm", // SL_GAMEMONKEY
".nut", // SL_SQUIRREL
".lua", // SL_LUA
".py", // SL_PYTHON
};
HSCRIPT VScriptCompileScript( const char *pszScriptName, bool bWarnMissing )
@ -49,15 +58,6 @@ HSCRIPT VScriptCompileScript( const char *pszScriptName, bool bWarnMissing )
return NULL;
}
static const char *pszExtensions[] =
{
"", // SL_NONE
".gm", // SL_GAMEMONKEY
".nut", // SL_SQUIRREL
".lua", // SL_LUA
".py", // SL_PYTHON
};
const char *pszVMExtension = pszExtensions[g_pScriptVM->GetLanguage()];
const char *pszIncomingExtension = V_strrchr( pszScriptName , '.' );
if ( pszIncomingExtension && V_strcmp( pszIncomingExtension, pszVMExtension ) != 0 )
@ -171,6 +171,113 @@ bool VScriptRunScript( const char *pszScriptName, HSCRIPT hScope, bool bWarnMiss
}
#ifdef MAPBASE_VSCRIPT
//
// These functions are currently only used for "mapspawn_addon" scripts.
//
HSCRIPT VScriptCompileScriptAbsolute( const char *pszScriptName, bool bWarnMissing, const char *pszRootFolderName )
{
if ( !g_pScriptVM )
{
return NULL;
}
const char *pszVMExtension = pszExtensions[g_pScriptVM->GetLanguage()];
const char *pszIncomingExtension = V_strrchr( pszScriptName , '.' );
if ( pszIncomingExtension && V_strcmp( pszIncomingExtension, pszVMExtension ) != 0 )
{
CGWarning( 0, CON_GROUP_VSCRIPT, "Script file type does not match VM type\n" );
return NULL;
}
CFmtStr scriptPath;
if ( pszIncomingExtension )
{
scriptPath = pszScriptName;
}
else
{
scriptPath.sprintf( "%s%s", pszScriptName, pszVMExtension );
}
const char *pBase;
CUtlBuffer bufferScript;
if ( g_pScriptVM->GetLanguage() == SL_PYTHON )
{
// python auto-loads raw or precompiled modules - don't load data here
pBase = NULL;
}
else
{
bool bResult = filesystem->ReadFile( scriptPath, NULL, bufferScript );
if ( !bResult && bWarnMissing )
{
CGWarning( 0, CON_GROUP_VSCRIPT, "Script not found (%s) \n", scriptPath.operator const char *() );
Assert( "Error running script" );
}
pBase = (const char *) bufferScript.Base();
if ( !pBase || !*pBase )
{
return NULL;
}
}
// Attach the folder to the script ID
const char *pszFilename = V_strrchr( scriptPath, '/' );
scriptPath.sprintf( "%s%s", pszRootFolderName, pszFilename );
HSCRIPT hScript = g_pScriptVM->CompileScript( pBase, scriptPath );
if ( !hScript )
{
CGWarning( 0, CON_GROUP_VSCRIPT, "FAILED to compile and execute script file named %s\n", scriptPath.operator const char *() );
Assert( "Error running script" );
}
return hScript;
}
bool VScriptRunScriptAbsolute( const char *pszScriptName, HSCRIPT hScope, bool bWarnMissing, const char *pszRootFolderName )
{
if ( !g_pScriptVM )
{
return false;
}
if ( !pszScriptName || !*pszScriptName )
{
CGWarning( 0, CON_GROUP_VSCRIPT, "Cannot run script: NULL script name\n" );
return false;
}
// Prevent infinite recursion in VM
if ( g_ScriptServerRunScriptDepth > 16 )
{
CGWarning( 0, CON_GROUP_VSCRIPT, "IncludeScript stack overflow\n" );
return false;
}
g_ScriptServerRunScriptDepth++;
HSCRIPT hScript = VScriptCompileScriptAbsolute( pszScriptName, bWarnMissing, pszRootFolderName );
bool bSuccess = false;
if ( hScript )
{
bSuccess = ( g_pScriptVM->Run( hScript, hScope ) != SCRIPT_ERROR );
if ( !bSuccess )
{
Warning( "Error running script named %s\n", pszScriptName );
Assert( "Error running script" );
}
}
g_ScriptServerRunScriptDepth--;
return bSuccess;
}
#endif
#ifdef GAME_DLL
#define IsCommandIssuedByServerAdmin() UTIL_IsCommandIssuedByServerAdmin()
#else
@ -321,6 +428,74 @@ CON_COMMAND_F( script_dump_all, "Dump the state of the VM to the console", FCVAR
//-----------------------------------------------------------------------------
#ifdef MAPBASE_VSCRIPT
void RunAddonScripts()
{
char searchPaths[4096];
filesystem->GetSearchPath( "ADDON", true, searchPaths, sizeof( searchPaths ) );
for ( char *path = strtok( searchPaths, ";" ); path; path = strtok( NULL, ";" ) )
{
char folderName[MAX_PATH];
Q_FileBase( path, folderName, sizeof( folderName ) );
// mapspawn_addon
char fullpath[MAX_PATH];
Q_snprintf( fullpath, sizeof( fullpath ), "%sscripts/vscripts/mapspawn_addon", path );
Q_FixSlashes( fullpath );
VScriptRunScriptAbsolute( fullpath, NULL, false, folderName );
}
}
// UNDONE: "autorun" folder
/*
void RunAutorunScripts()
{
FileFindHandle_t fileHandle;
char szDirectory[MAX_PATH];
char szFileName[MAX_PATH];
char szPartialScriptPath[MAX_PATH];
// TODO: Scanning for VM extension would make this more efficient
Q_strncpy( szDirectory, "scripts/vscripts/autorun/*", sizeof( szDirectory ) );
const char *pszScriptFile = filesystem->FindFirst( szDirectory, &fileHandle );
while (pszScriptFile && fileHandle != FILESYSTEM_INVALID_FIND_HANDLE)
{
Q_FileBase( pszScriptFile, szFileName, sizeof( szFileName ) );
Q_snprintf( szPartialScriptPath, sizeof( szPartialScriptPath ), "autorun/%s", szFileName );
VScriptRunScript( szPartialScriptPath );
pszScriptFile = filesystem->FindNext( fileHandle );
}
// Non-shared scripts
#ifdef CLIENT_DLL
Q_strncpy( szDirectory, "scripts/vscripts/autorun/client/*", sizeof( szDirectory ) );
#else
Q_strncpy( szDirectory, "scripts/vscripts/autorun/server/*", sizeof( szDirectory ) );
#endif
pszScriptFile = filesystem->FindFirst( szDirectory, &fileHandle );
while (pszScriptFile && fileHandle != FILESYSTEM_INVALID_FIND_HANDLE)
{
Q_FileBase( pszScriptFile, szFileName, sizeof( szFileName ) );
#ifdef CLIENT_DLL
Q_snprintf( szPartialScriptPath, sizeof( szPartialScriptPath ), "autorun/client/%s", szFileName );
#else
Q_snprintf( szPartialScriptPath, sizeof( szPartialScriptPath ), "autorun/server/%s", szFileName );
#endif
VScriptRunScript( szPartialScriptPath );
pszScriptFile = filesystem->FindNext( fileHandle );
}
}
*/
#endif
//-----------------------------------------------------------------------------
static short VSCRIPT_SERVER_SAVE_RESTORE_VERSION = 2;
//-----------------------------------------------------------------------------

View File

@ -45,6 +45,8 @@ extern CBaseEntityScriptInstanceHelper g_BaseEntityScriptInstanceHelper;
#ifdef MAPBASE_VSCRIPT
void RegisterSharedScriptConstants();
void RegisterSharedScriptFunctions();
void RunAddonScripts();
#endif
#endif // VSCRIPT_SHARED_H

Binary file not shown.

View File

@ -225,7 +225,7 @@ BEGIN_VS_SHADER( SDK_DecalModulate_dx9,
SetFlashLightColorFromState( state, pShaderAPI, 28 );
Assert( state.m_pSpotlightTexture >= 0 && state.m_nSpotlightTextureFrame >= 0 );
Assert( state.m_pSpotlightTexture && state.m_nSpotlightTextureFrame >= 0 );
BindTexture( SHADER_SAMPLER7, state.m_pSpotlightTexture, state.m_nSpotlightTextureFrame );
float atten_pos[8];

View File

@ -1281,8 +1281,8 @@ PLATFORM_INTERFACE bool Is64BitOS();
//-----------------------------------------------------------------------------
// General Mapbase version constants compiled into projects for versioning purposes
//-----------------------------------------------------------------------------
#define MAPBASE_VERSION "7.0"
#define MAPBASE_VER_INT 7000 // For use in #if in a similar fashion to macros like _MSC_VER
#define MAPBASE_VERSION "7.1"
#define MAPBASE_VER_INT 7100 // For use in #if in a similar fashion to macros like _MSC_VER
#endif

View File

@ -1605,6 +1605,10 @@ typedef CScriptScopeT<> CScriptScope;
#define FOR_EACH_VEC_PTR( vecName, iteratorName ) \
for ( int iteratorName = 0; iteratorName < (vecName)->Count(); iteratorName++ )
//-----------------------------------------------------------------------------
static void __UpdateScriptHooks( HSCRIPT hooksList );
//-----------------------------------------------------------------------------
//
// Keeps track of which events and scopes are hooked without polling this from the script VM on each request.
@ -1654,12 +1658,6 @@ public:
return scopeMap->Find( g_pScriptVM->HScriptToRaw( hScope ) ) != scopeMap->InvalidIndex();
}
static void __UpdateScriptHooks( HSCRIPT hooksList )
{
extern CScriptHookManager &GetScriptHookManager();
GetScriptHookManager().Update( hooksList );
}
//
// On VM init, registers script func and caches the hook func.
//
@ -1843,7 +1841,7 @@ public:
scopemap_t *scopeMap = m_HookList.Element(i);
char *szEvent = m_HookList.Key(i);
Msg( "%s [%x]\n", szEvent, (void*)scopeMap );
Msg( "%s [%p]\n", szEvent, (void*)scopeMap );
Msg( "{\n" );
FOR_EACH_MAP_PTR( scopeMap, j )
@ -1851,7 +1849,7 @@ public:
HScriptRaw hScope = scopeMap->Key(j);
contextmap_t *contextMap = scopeMap->Element(j);
Msg( "\t(0x%X) [%x]\n", hScope, (void*)contextMap );
Msg( "\t(0x%X) [%p]\n", hScope, (void*)contextMap );
Msg( "\t{\n" );
FOR_EACH_VEC_PTR( contextMap, k )
@ -1876,6 +1874,11 @@ inline CScriptHookManager &GetScriptHookManager()
return g_ScriptHookManager;
}
static void __UpdateScriptHooks( HSCRIPT hooksList )
{
GetScriptHookManager().Update( hooksList );
}
//-----------------------------------------------------------------------------
// Function bindings allow script functions to run C++ functions.

View File

@ -1509,7 +1509,8 @@ void CResponseSystem::ParseInclude()
if (len+1 != strlen(scriptfile))
{
Q_snprintf(includefile, sizeof(includefile), "%s/%s", includefile, token);
Q_strncat( includefile, "/", sizeof( includefile ) );
Q_strncat( includefile, token, sizeof( includefile ) );
}
else
includefile[0] = '\0';

View File

@ -28,6 +28,9 @@
#include "utlhash.h"
#include "UtlSortVector.h"
#include "convar.h"
#ifdef MAPBASE
#include "icommandline.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
@ -2081,6 +2084,28 @@ bool EvaluateConditional( const char *str )
if ( Q_stristr( str, "$POSIX" ) )
return IsPosix() ^ bNot;
#ifdef MAPBASE
// Custom conditional
switch( str[bNot ? 1 : 0] )
{
case '%':
{
// Look for a cvar
ConVarRef cvar( str + (bNot ? 2 : 1), true );
if (cvar.IsValid())
{
return cvar.GetBool() ^ bNot;
}
} break;
case '-':
{
// Look for a command line param
return (CommandLine()->CheckParm( bNot ? str+1 : str ) != 0) ^ bNot;
} break;
}
#endif
return false;
}

View File

@ -357,7 +357,12 @@ bool AnimationController::ParseScriptFile(char *pMem, int length)
// get the open brace or a conditional
pMem = ParseFile(pMem, token, NULL);
#ifdef MAPBASE
// Fixes ! conditionals
if ( Q_stristr( token, "[$" ) || Q_stristr( token, "[!$" ) )
#else
if ( Q_stristr( token, "[$" ) )
#endif
{
bAccepted = EvaluateConditional( token );
@ -622,7 +627,12 @@ bool AnimationController::ParseScriptFile(char *pMem, int length)
// Look ahead one token for a conditional
char *peek = ParseFile(pMem, token, NULL);
#ifdef MAPBASE
// Fixes ! conditionals
if ( Q_stristr( token, "[$" ) || Q_stristr( token, "[!$" ) )
#else
if ( Q_stristr( token, "[$" ) )
#endif
{
if ( !EvaluateConditional( token ) )
{

View File

@ -26,9 +26,15 @@ $Group "game"
"responserules"
}
$Group "shaderdlls"
{
"game_shader_dx9"
}
$Group "shaders"
{
"game_shader_dx9"
"mathlib"
}
$Group "everything"

View File

@ -19,7 +19,7 @@
// Mapbase functionality conditionals
$Conditional MAPBASE "1" // Equivalent to (and required for) our MAPBASE preprocessor defined below
$Conditional MAPBASE_RPC "1" // Toggles Mapbase's Rich Presence Client implementations
$Conditional MAPBASE_RPC "0" // Toggles Mapbase's Rich Presence Client implementations (requires discord-rpc.dll in game bin)
$Conditional MAPBASE_VSCRIPT "1" // Toggles VScript implementation (note: interfaces still exist, just the provided implementation is not present)
$Conditional NEW_RESPONSE_SYSTEM "1" // Toggles the new Response System library based on the Alien Swarm SDK

View File

@ -141,9 +141,6 @@ $Project
$Implib "$LIBPUBLIC\tier0"
$Lib "$LIBPUBLIC\tier1"
$Implib "$LIBPUBLIC\vstdlib"
// Discord integration
$Lib "$LIBPUBLIC\discord-rpc" [$MAPBASE_RPC]
}
}

View File

@ -67,8 +67,9 @@ $Configuration
$PostBuildEvent [!$ANALYZE]
{
$CommandLine "if not exist $QUOTE$OUTBINDIR$QUOTE mkdir $QUOTE$OUTBINDIR$QUOTE" "\n" [($VS2015||$VS2017||$VS2019||$VS2022)]
$CommandLine "$BASE" "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$(TargetFileName) $SRCDIR" "\n" [!$SOURCESDK && ($VS2015||$VS2017||$VS2019||$VS2022)]
$CommandLine "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$(TargetFileName) $SRCDIR" "\n" [!$SOURCESDK && !($VS2015||$VS2017||$VS2019||$VS2022)]
$CommandLine "if not exist $QUOTE$OUTBINDIR$QUOTE mkdir $QUOTE$OUTBINDIR$QUOTE" "\n" [!$SOURCESDK && ($VS2015||$VS2017||$VS2019||$VS2022)]
$CommandLine "$BASE" "copy $QUOTE$(TargetDir)$QUOTE$(TargetFileName) $OUTBINDIR\$(TargetFileName) >nul" "\n" \
"if ERRORLEVEL 1 goto BuildEventFailed" "\n" \
"if exist $QUOTE$(TargetDir)$QUOTE$(TargetName).map copy $QUOTE$(TargetDir)$QUOTE$(TargetName).map $OUTBINDIR\$(TargetName).map >nul" "\n"