├── .github └── workflows │ └── msbuild.yml ├── .gitignore ├── Deploy-SS2.cmd ├── Deploy-T1.cmd ├── Deploy-T2.cmd ├── NVDebug.vcproj ├── NVDebug.vcxproj ├── NVDebug.vcxproj.filters ├── NVScript ToDo.txt ├── NVScript.sln ├── NVScript.vcproj ├── NVScript.vcxproj ├── NVScript.vcxproj.filters ├── NVScript ├── Citadel.cpp ├── Citadel.h ├── Citadel.rc ├── CitadelChangeLog.txt ├── Make-Citadel.cmd ├── Make-DEBUG.cmd ├── Make-NVDebug.cmd ├── Make-SS2.cmd ├── Make-T1.cmd ├── Make.cmd ├── MakeCitadel.ccd ├── MakeNVDebug.ccd ├── MakeNVScript.ccd ├── MakeNVScriptDebug.ccd ├── MakeNVScriptSS2.ccd ├── MakeNVScriptT1.ccd ├── MakeNone.ccd ├── Makefile ├── NVChangelog.txt ├── NVDebug.cpp ├── NVDebug.h ├── NVDebug.rc ├── NVGenericScript.cpp ├── NVGenericScript.h ├── NVGenericTrigger.cpp ├── NVGenericTrigger.h ├── NVMaths.h ├── NVScript-CoSaS.cpp ├── NVScript-CoSaS.h ├── NVScript-Defunct.cpp ├── NVScript-Defunct.h ├── NVScript-Flames.cpp ├── NVScript-Flames.h ├── NVScript-SS2.cpp ├── NVScript-SS2.h ├── NVScript-ThiefShock.cpp ├── NVScript-ThiefShock.h ├── NVScript.cpp ├── NVScript.h ├── NVScript.html ├── NVScript.rc ├── NVScriptLib.cpp ├── NVScriptLib.h ├── ParamCache.h ├── ScrInstance.cpp ├── ScrInstance.h ├── Script.cpp ├── Script.h ├── ScriptLib.h ├── ScriptLib │ ├── AddMetaProperty.cpp │ ├── AddSingleMetaProperty.cpp │ ├── CDSend.cpp │ ├── CalcTextTime.cpp │ ├── DebugPrintf.cpp │ ├── DeleteAllLinks.cpp │ ├── DeleteAllLinksByData.cpp │ ├── DisplayPrintf.cpp │ ├── FixupPlayerLinks.cpp │ ├── GetAnyLink.cpp │ ├── GetAnyLinkByData.cpp │ ├── GetAnyLinkByDataDest.cpp │ ├── GetAnyLinkByDataInheritedSrc.cpp │ ├── GetAnyLinkDest.cpp │ ├── GetAnyLinkInheritedSrc.cpp │ ├── GetObjectParamBool.cpp │ ├── GetObjectParamFloat.cpp │ ├── GetObjectParamInt.cpp │ ├── GetObjectParamObject.cpp │ ├── GetObjectParamString.cpp │ ├── GetObjectParamTime.cpp │ ├── GetObjectParams.cpp │ ├── GetObjectParamsNoInherit.cpp │ ├── GetOneLink.cpp │ ├── GetOneLinkByData.cpp │ ├── GetOneLinkByDataDest.cpp │ ├── GetOneLinkByDataInheritedSrc.cpp │ ├── GetOneLinkDest.cpp │ ├── GetOneLinkInheritedSrc.cpp │ ├── GetParamBool.cpp │ ├── GetParamFloat.cpp │ ├── GetParamInt.cpp │ ├── GetParamObject.cpp │ ├── GetParamString.cpp │ ├── GetParamTime.cpp │ ├── GlobalParamCache.cpp │ ├── HexTable.cpp │ ├── IterateLinks.cpp │ ├── IterateLinksByData.cpp │ ├── MultiParmAssignFloat.cpp │ ├── MultiParmAssignInt.cpp │ ├── MultiParmAssignString.cpp │ ├── MultiParmAssignVector.cpp │ ├── ParamCache.cpp │ ├── ParamExists.cpp │ ├── ParamExistsDirect.cpp │ ├── ParamGetBool.cpp │ ├── ParamGetFloat.cpp │ ├── ParamGetInt.cpp │ ├── ParamGetObject.cpp │ ├── ParamGetString.cpp │ ├── ParamGetTime.cpp │ ├── ParamRemove.cpp │ ├── ParamSetBool.cpp │ ├── ParamSetFloat.cpp │ ├── ParamSetInt.cpp │ ├── ParamSetString.cpp │ ├── RemoveMetaProperty.cpp │ ├── RemoveObjectParam.cpp │ ├── RemoveSingleMetaProperty.cpp │ ├── ScriptLib.cpp │ ├── SetObjectParamBool.cpp │ ├── SetObjectParamFloat.cpp │ ├── SetObjectParamInt.cpp │ ├── SetObjectParamString.cpp │ ├── SetObjectParams.cpp │ ├── SetParamBool.cpp │ ├── SetParamFloat.cpp │ ├── SetParamInt.cpp │ ├── SetParamString.cpp │ ├── ShowBook.cpp │ ├── ShowString.cpp │ ├── SimplePost.cpp │ ├── SimpleSend.cpp │ ├── StrToObject.cpp │ ├── strqsep.cpp │ ├── strsep.cpp │ ├── strtocolor.cpp │ └── strtotime.cpp ├── ScriptModule.cpp ├── ScriptModule.h ├── ScriptNV.cpp ├── ScriptNV.h ├── copyright.txt ├── genosm.pl ├── script.def ├── scriptvars.cpp ├── scriptvars.h ├── strless_nocase.h └── version.rc ├── PackageSource.cmd ├── README.md ├── ScriptLib.vcproj ├── ScriptLib.vcxproj ├── ScriptLib.vcxproj.filters ├── buildconfig.h ├── building.txt ├── lg.vcproj ├── lg.vcxproj ├── lg.vcxproj.filters └── lg ├── Makefile ├── Makefile-b32 ├── Makefile-vc ├── iids.cpp ├── lg.cpp ├── lg ├── actreact.h ├── ai.h ├── config.h ├── convict.h ├── defs.h ├── dlgs.h ├── dynarray.h ├── dynarray.hpp ├── editor.h ├── gen.h ├── graphics.h ├── iiddef.h ├── iids.h ├── input.h ├── interface.h ├── links.h ├── malloc.h ├── miss16.h ├── objects.h ├── objstd.h ├── propdefs.h ├── properties.h ├── quest.h ├── res.h ├── script.h ├── scrmanagers.h ├── scrmsgs.h ├── scrservices.h ├── sound.h ├── stamp-20090113 ├── tools.h ├── types.h └── win.h ├── lg2007-changes.txt ├── scrmsgs.cpp └── timestamp.sh /.github/workflows/msbuild.yml: -------------------------------------------------------------------------------- 1 | name: MSBuild 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | env: 10 | # Path to the solution file relative to the root of the project. 11 | SOLUTION_FILE_PATH: NVScript.sln 12 | 13 | permissions: 14 | contents: write 15 | 16 | jobs: 17 | check_version: 18 | runs-on: windows-latest 19 | 20 | steps: 21 | - name: Checkout (with tags) 22 | uses: actions/checkout@v4 23 | with: 24 | fetch-depth: 0 25 | 26 | - name: Generate version number for release 27 | if: ${{ github.ref == 'refs/heads/master' }} 28 | run: | 29 | $CurrentVersion = git describe --tags --abbrev=0 30 | $NewVersion = ($CurrentVersion -replace "(v[0-9]+\.[0-9]+\.)([0-9])+", "`${1}") + (1 + ($CurrentVersion -replace "(v[0-9]+\.[0-9]+\.)([0-9])+", "`${2}")) 31 | echo "Old version was $CurrentVersion" 32 | echo "New version is $NewVersion" 33 | $NewVersion | Out-File -FilePath github.version 34 | 35 | - name: Generate version number for non-release build (with datestamp) 36 | if: ${{ github.ref != 'refs/heads/master' }} 37 | run: | 38 | $CurrentVersion = git describe --tags --abbrev=0 39 | $NewVersion = $(date "+v%Y.%m.%d") 40 | echo "Old version was $CurrentVersion" 41 | echo "New version is $NewVersion" 42 | $NewVersion | Out-File -FilePath github.version 43 | 44 | - name: Upload version number as artefact 45 | uses: actions/upload-artifact@v4 46 | with: 47 | name: github.version 48 | path: | 49 | github.version 50 | 51 | build: 52 | runs-on: windows-2019 53 | needs: check_version 54 | 55 | strategy: 56 | matrix: 57 | include: 58 | - BUILD_NAME: NVScript-T2 59 | BUILD_CONFIGURATION: Release 60 | - BUILD_NAME: NVScript-T1 61 | BUILD_CONFIGURATION: ReleaseT1 62 | - BUILD_NAME: NVScript-SS2 63 | BUILD_CONFIGURATION: ReleaseSS2 64 | 65 | steps: 66 | - name: Checkout code 67 | uses: actions/checkout@v4 68 | 69 | # - name: Install Windows XP-compatible toolset 70 | # uses: thepwrtank18/install-vs-components@v1.0.0 71 | # with: 72 | # components: Microsoft.VisualStudio.Component.WinXP 73 | 74 | - name: Add MSBuild to PATH 75 | uses: microsoft/setup-msbuild@v2 76 | 77 | - name: Restore NuGet packages 78 | working-directory: ${{env.GITHUB_WORKSPACE}} 79 | run: nuget restore ${{env.SOLUTION_FILE_PATH}} 80 | 81 | - name: Fetch version number artefact 82 | uses: actions/download-artifact@v4 83 | with: 84 | name: github.version 85 | 86 | - name: Generate version number 87 | run: | 88 | $VersionNumber=$(cat .\github.version) 89 | echo "Version number is $VersionNumber" 90 | $VersionMajor = ($VersionNumber -replace "v([0-9]+).([0-9]+).([0-9]+)", '${1}') 91 | $VersionMinor = ($VersionNumber -replace "v([0-9]+).([0-9]+).([0-9]+)", '${2}') 92 | $VersionBuild = ($VersionNumber -replace "v([0-9]+).([0-9]+).([0-9]+)", '${3}') 93 | (Get-Content .\buildconfig.h) -replace '(#define\W+NVSCRIPT_VERSION_MAJOR\W+)[0-9]+', "`${1}$VersionMajor" | Set-Content .\buildconfig.h 94 | (Get-Content .\buildconfig.h) -replace '(#define\W+NVSCRIPT_VERSION_MINOR\W+)[0-9]+', "`${1}$VersionMinor" | Set-Content .\buildconfig.h 95 | (Get-Content .\buildconfig.h) -replace '(#define\W+NVSCRIPT_VERSION_BUILD\W+)[0-9]+', "`${1}$VersionBuild" | Set-Content .\buildconfig.h 96 | 97 | - name: Read build config 98 | run: echo "$(Get-Content .\buildconfig.h)" 99 | 100 | - name: Build 101 | working-directory: ${{env.GITHUB_WORKSPACE}} 102 | # Add additional options to the MSBuild command line here (like platform or verbosity level). 103 | # See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference 104 | run: msbuild /m /p:Configuration=${{matrix.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} 105 | 106 | - uses: actions/upload-artifact@v4 107 | with: 108 | name: ${{matrix.BUILD_NAME}} 109 | path: | 110 | D:\a\NVScript\NVScript\${{matrix.BUILD_CONFIGURATION}}\NVScript\NVScript.osm 111 | D:\a\NVScript\NVScript\${{matrix.BUILD_CONFIGURATION}}\NVScript\NVScript.html 112 | 113 | release: 114 | runs-on: windows-latest 115 | needs: build 116 | if: ${{ github.ref == 'refs/heads/master' }} 117 | 118 | steps: 119 | - name: Download artefacts 120 | uses: dawidd6/action-download-artifact@v6 121 | with: 122 | run_id: ${{ github.run_id }} 123 | path: outputs/ 124 | skip_unpack: true 125 | 126 | - name: Fetch version number artefact 127 | uses: actions/download-artifact@v4 128 | with: 129 | name: github.version 130 | 131 | - name: Generate release tag 132 | id: tag 133 | run: | 134 | echo "release_tag=$(cat .\github.version)" >> $env:GITHUB_OUTPUT 135 | 136 | - name: File listing 137 | run: ls -r 138 | 139 | - name: Create release 140 | uses: softprops/action-gh-release@v2 141 | with: 142 | Name: NVScript-${{ steps.tag.outputs.release_tag }} 143 | tag_name: ${{ steps.tag.outputs.release_tag }} 144 | body: Automatic build on ${{ steps.tag.outputs.release_tag }} 145 | files: outputs/NVScript*.zip -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | #Ignore thumbnails created by Windows 3 | Thumbs.db 4 | #Ignore files built by Visual Studio 5 | *.obj 6 | *.exe 7 | *.pdb 8 | *.user 9 | *.aps 10 | *.pch 11 | *.vspscc 12 | *_i.c 13 | *_p.c 14 | *.ncb 15 | *.suo 16 | *.tlb 17 | *.tlh 18 | *.bak 19 | *.cache 20 | *.ilk 21 | *.log 22 | [Bb]in 23 | [Dd]ebug*/ 24 | *.lib 25 | *.sbr 26 | *.VC.db 27 | obj/ 28 | [Rr]elease*/ 29 | _ReSharper*/ 30 | [Tt]est[Rr]esult* 31 | .vs/ 32 | #Nuget packages folder 33 | packages/ 34 | /output/ 35 | /NVScript-source 36 | /NVScript-source.zip 37 | 38 | *.o 39 | *.a 40 | *.osm -------------------------------------------------------------------------------- /Deploy-SS2.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM This script packages the source code and builds a zip locally, moving OSM files into place as needed 3 | REM Note that you need 7-zip installed and in the path to build the archive, and git-bash with rsync to package the source 4 | REM (see comments in PackageSource.cmd for more details) 5 | 6 | REM Set EnableDeploy to true to enable 7 | set EnableDeploy=false 8 | 9 | rem The path to output build artefacts (osm/html/zip) 10 | set OutPath=output\shock2 11 | 12 | 13 | REM Script follows 14 | REM ======================== 15 | set release=ReleaseSS2\NVScript 16 | 17 | if "%EnableDeploy%" == "false" exit 18 | 19 | call PackageSource.cmd 20 | 21 | echo Creating archive 22 | "7z.exe" a "output\NVScript.zip" ".\%release%\NVScript.osm" ".\%release%\NVScript.html" ".\output\source" -tzip -mx9 >NUL 23 | 24 | REM Copy build output to output path 25 | mkdir %OutPath% 26 | if exist %release%\NVScript.osm copy %release%\NVScript.osm "%OutPath%" 27 | if exist %release%\NVScript.html copy %release%\NVScript.html "%OutPath%" 28 | if exist output\NVScript.zip copy output\NVScript.zip "%OutPath%\NVScript-SS2.zip" 29 | 30 | REM Copy .osm to game dirs 31 | if exist %release%\NVScript.osm copy %release%\NVScript.osm "X:\Games\ShockEd" 32 | -------------------------------------------------------------------------------- /Deploy-T1.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM This script packages the source code and builds a zip locally, moving OSM files into place as needed 3 | REM Note that you need 7-zip installed and in the path to build the archive, and git-bash with rsync to package the source 4 | REM (see comments in PackageSource.cmd for more details) 5 | 6 | REM Note that deployment is disabled by default. 7 | 8 | REM Set EnableDeploy to true to enable 9 | set EnableDeploy=false 10 | 11 | rem The path to output build artefacts (osm/html/zip) 12 | set OutPath=output\thief1 13 | 14 | 15 | REM Script follows 16 | REM ======================== 17 | set release=ReleaseT1\NVScript 18 | 19 | if "%EnableDeploy%" == "false" exit 20 | 21 | call PackageSource.cmd 22 | 23 | echo Creating archive 24 | "7z.exe" a "output\NVScript.zip" ".\%release%\NVScript.osm" ".\%release%\NVScript.html" ".\output\source" -tzip -mx9 >NUL 25 | 26 | REM Copy build output to output path 27 | mkdir %OutPath% 28 | if exist %release%\NVScript.osm copy %release%\NVScript.osm "%OutPath%" 29 | if exist %release%\NVScript.html copy %release%\NVScript.html "%OutPath%" 30 | if exist output\NVScript.zip copy output\NVScript.zip "%OutPath%\NVScript-T1.zip" 31 | 32 | REM Copy .osm to game dirs 33 | if exist %release%\NVScript.osm copy %release%\NVScript.osm X:\Games\DromEd1 -------------------------------------------------------------------------------- /Deploy-T2.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM This script packages the source code and builds a zip locally, moving OSM files into place as needed 3 | REM Note that you need 7-zip installed and in the path to build the archive, and git-bash with rsync to package the source 4 | REM (see comments in PackageSource.cmd for more details) 5 | 6 | REM Set EnableDeploy to true to enable 7 | set EnableDeploy=false 8 | 9 | rem The path to output build artefacts (osm/html/zip) 10 | set OutPath=output\thief2 11 | 12 | 13 | REM Script follows 14 | REM ======================== 15 | set release=Release\NVScript 16 | 17 | if "%EnableDeploy%" == "false" exit 18 | 19 | call PackageSource.cmd 20 | 21 | echo Creating archive 22 | "7z.exe" a "output\NVScript.zip" ".\%release%\NVScript.osm" ".\%release%\NVScript.html" ".\output\source" -tzip -mx9 >NUL 23 | 24 | REM Copy build output to output path 25 | mkdir %OutPath% 26 | if exist %release%\NVScript.osm copy %release%\NVScript.osm "%OutPath%" 27 | if exist %release%\NVScript.html copy %release%\NVScript.html "%OutPath%" 28 | if exist output\NVScript.zip copy output\NVScript.zip "%OutPath%" 29 | 30 | REM Copy .osm to game dirs 31 | if exist %release%\NVScript.osm copy %release%\NVScript.osm X:\Games\DromEd 32 | if exist %release%\NVScript.osm copy %release%\NVScript.osm X:\Games\DromEd\Mayan.osm -------------------------------------------------------------------------------- /NVDebug.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | 67 | 68 | Resource Files 69 | 70 | 71 | -------------------------------------------------------------------------------- /NVScript ToDo.txt: -------------------------------------------------------------------------------- 1 | Sort multiplayer support 2 | check source for Tos' T2MP, ScriptHooks.cpp, line 69 3 | 4 | "Send Stim" message for NVConvEnhancer 5 | 6 | Built-in revert timer (for NVTrap scripts) -------------------------------------------------------------------------------- /NVScript.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.438 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NVScript", "NVScript.vcxproj", "{8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NVDebug", "NVDebug.vcxproj", "{8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lg", "lg.vcxproj", "{7326FEF0-652C-4C37-98A1-B8BBE4E7C443}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScriptLib", "ScriptLib.vcxproj", "{81F440D8-57C3-4DE6-8CD0-81432E7D4A80}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Win32 = Debug|Win32 17 | DebugSS2|Win32 = DebugSS2|Win32 18 | DebugT1|Win32 = DebugT1|Win32 19 | Release|Win32 = Release|Win32 20 | ReleaseSS2|Win32 = ReleaseSS2|Win32 21 | ReleaseT1|Win32 = ReleaseT1|Win32 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.Debug|Win32.Build.0 = Debug|Win32 26 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.DebugSS2|Win32.ActiveCfg = DebugSS2|Win32 27 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.DebugSS2|Win32.Build.0 = DebugSS2|Win32 28 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.DebugT1|Win32.ActiveCfg = DebugT1|Win32 29 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.DebugT1|Win32.Build.0 = DebugT1|Win32 30 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.Release|Win32.ActiveCfg = Release|Win32 31 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.Release|Win32.Build.0 = Release|Win32 32 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.ReleaseSS2|Win32.ActiveCfg = ReleaseSS2|Win32 33 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.ReleaseSS2|Win32.Build.0 = ReleaseSS2|Win32 34 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.ReleaseT1|Win32.ActiveCfg = ReleaseT1|Win32 35 | {8DA3AF8E-7C62-41D4-99C3-BF2ED005E187}.ReleaseT1|Win32.Build.0 = ReleaseT1|Win32 36 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.Debug|Win32.ActiveCfg = Debug|Win32 37 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.Debug|Win32.Build.0 = Debug|Win32 38 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.DebugSS2|Win32.ActiveCfg = DebugSS2|Win32 39 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.DebugSS2|Win32.Build.0 = DebugSS2|Win32 40 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.DebugT1|Win32.ActiveCfg = DebugT1|Win32 41 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.DebugT1|Win32.Build.0 = DebugT1|Win32 42 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.Release|Win32.ActiveCfg = Release|Win32 43 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.Release|Win32.Build.0 = Release|Win32 44 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.ReleaseSS2|Win32.ActiveCfg = ReleaseSS2|Win32 45 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.ReleaseSS2|Win32.Build.0 = ReleaseSS2|Win32 46 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.ReleaseT1|Win32.ActiveCfg = ReleaseT1|Win32 47 | {8DA3AF8E-7C62-41D4-99C4-BF2ED005E187}.ReleaseT1|Win32.Build.0 = ReleaseT1|Win32 48 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.Debug|Win32.ActiveCfg = Debug|Win32 49 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.Debug|Win32.Build.0 = Debug|Win32 50 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.DebugSS2|Win32.ActiveCfg = DebugSS2|Win32 51 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.DebugSS2|Win32.Build.0 = DebugSS2|Win32 52 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.DebugT1|Win32.ActiveCfg = DebugT1|Win32 53 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.DebugT1|Win32.Build.0 = DebugT1|Win32 54 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.Release|Win32.ActiveCfg = Release|Win32 55 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.Release|Win32.Build.0 = Release|Win32 56 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.ReleaseSS2|Win32.ActiveCfg = ReleaseSS2|Win32 57 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.ReleaseSS2|Win32.Build.0 = ReleaseSS2|Win32 58 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.ReleaseT1|Win32.ActiveCfg = ReleaseT1|Win32 59 | {7326FEF0-652C-4C37-98A1-B8BBE4E7C443}.ReleaseT1|Win32.Build.0 = ReleaseT1|Win32 60 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.Debug|Win32.ActiveCfg = Debug|Win32 61 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.Debug|Win32.Build.0 = Debug|Win32 62 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.DebugSS2|Win32.ActiveCfg = DebugSS2|Win32 63 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.DebugSS2|Win32.Build.0 = DebugSS2|Win32 64 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.DebugT1|Win32.ActiveCfg = DebugT1|Win32 65 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.DebugT1|Win32.Build.0 = DebugT1|Win32 66 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.Release|Win32.ActiveCfg = Release|Win32 67 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.Release|Win32.Build.0 = Release|Win32 68 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.ReleaseSS2|Win32.ActiveCfg = ReleaseSS2|Win32 69 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.ReleaseSS2|Win32.Build.0 = ReleaseSS2|Win32 70 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.ReleaseT1|Win32.ActiveCfg = ReleaseT1|Win32 71 | {81F440D8-57C3-4DE6-8CD0-81432E7D4A80}.ReleaseT1|Win32.Build.0 = ReleaseT1|Win32 72 | EndGlobalSection 73 | GlobalSection(SolutionProperties) = preSolution 74 | HideSolutionNode = FALSE 75 | EndGlobalSection 76 | GlobalSection(ExtensibilityGlobals) = postSolution 77 | SolutionGuid = {1C4DE9E1-9AE6-4A75-B66B-8523B9361CE5} 78 | EndGlobalSection 79 | EndGlobal 80 | -------------------------------------------------------------------------------- /NVScript.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | 106 | 107 | Resource Files 108 | 109 | 110 | -------------------------------------------------------------------------------- /NVScript/Citadel.rc: -------------------------------------------------------------------------------- 1 | // The major version number will be incremented for each release that may break 2 | // compatibility with older releases. If I feel confident that there won't 3 | // be any problems, I'll only increment the minor version. 4 | // 5 | // If you make your own modifications, please increase the revision or 6 | // sub-revision levels. But leave the major and minor version numbers alone. 7 | // You should also change the description to something else. Official releases 8 | // are labelled "NVScript Thief2 OSM" 9 | // 10 | #define SCRIPT_VERSION 1,0,0,0 11 | #define SCRIPT_VERSTRING "1.0.0" 12 | #define SCRIPT_NAME "Citadel Script Module" 13 | #define SCRIPT_LONGNAME "Citadel System Shock 2 OSM" 14 | 15 | #include "version.rc" 16 | 17 | -------------------------------------------------------------------------------- /NVScript/CitadelChangeLog.txt: -------------------------------------------------------------------------------- 1 | ----- 2005/06/29 2 | * Increased the number of dynamic lights for Night Vision effect from 9 to 17. 3 | * Right-clicking now properly adjusts the 'Active/Inactive' text in the Settings window. 4 | * Hardware is no longer turned off then on unless the settings are actually changed. 5 | * Batteries are no longer used when power is already at maximum. -------------------------------------------------------------------------------- /NVScript/Make-Citadel.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | set OutPath=output 3 | 4 | if exist Citadel_osm.cpp del Citadel_osm.cpp 5 | if exist Citadel_osm.o del Citadel_osm.o 6 | if exist Citadel.o del Citadel.o 7 | if not exist MakeShock del *.o 8 | if not exist MakeShock echo . >MakeShock 9 | D:\CygWin\bin\bash --login -i MakeCitadel.ccd 10 | 11 | echo. 12 | 13 | if not exist Citadel.osm echo ERROR compiling Citadel.osm (SS2) 14 | if exist Citadel.osm echo Citadel.osm (SS2) compiled successfully. 15 | 16 | if exist Citadel.osm copy Citadel.osm "%OutPath%" 17 | -------------------------------------------------------------------------------- /NVScript/Make-DEBUG.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | if exist NVScript_osm.cpp del NVScript_osm.cpp 3 | if exist NVScript_osm.o del NVScript_osm.o 4 | if exist NVScript.o del NVScript.o 5 | if exist MakeShock del *.o 6 | if exist MakeShock del MakeShock 7 | D:\CygWin\bin\bash --login -i MakeNVScriptDebug.ccd 8 | 9 | echo. 10 | if not exist NVScript.osm echo ERROR compiling NVScript.osm 11 | if exist NVScript.osm echo NVScript.osm compiled successfully. 12 | -------------------------------------------------------------------------------- /NVScript/Make-NVDebug.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | if exist NVScript_osm.cpp del NVScript_osm.cpp 3 | if exist NVScript_osm.o del NVScript_osm.o 4 | if exist NVScript.o del NVScript.o 5 | if exist MakeShock del *.o 6 | if exist MakeShock del MakeShock 7 | if exist MakeT1 del *.o 8 | if exist MakeT1 del MakeShock 9 | D:\CygWin\bin\bash --login -i MakeNVDebug.ccd 10 | 11 | echo. 12 | if not exist NVDebug.osm echo ERROR compiling NVDebug.osm 13 | if exist NVDebug.osm echo NVDebug.osm compiled successfully. 14 | -------------------------------------------------------------------------------- /NVScript/Make-SS2.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | set OutPath=output 3 | 4 | if exist NVScript_osm.cpp del NVScript_osm.cpp 5 | if exist NVScript_osm.o del NVScript_osm.o 6 | if exist NVScript.o del NVScript.o 7 | if exist NVScript-SS2.o del NVScript-SS2.o 8 | if exist NVScript-ThiefShock.o del NVScript-ThiefShock.o 9 | if not exist MakeShock del *.o 10 | if not exist MakeShock echo . >MakeShock 11 | D:\CygWin\bin\bash --login -i ~/NVScript/NVScript/MakeNVScriptSS2.ccd 12 | 13 | echo. 14 | if not exist NVScript.osm echo ERROR compiling NVScript.osm (SS2) 15 | if exist NVScript.osm echo NVScript.osm (SS2) compiled successfully. 16 | 17 | if exist NVScript.osm copy NVScript.osm "%OutPath%" 18 | 19 | if not exist NVDebug.osm echo ERROR compiling NVDebug.osm 20 | if exist NVDebug.osm echo NVDebug.osm compiled successfully. 21 | 22 | if exist NVDebug.osm copy NVDebug.osm "%OutPath%" 23 | 24 | 25 | 26 | if not exist Citadel.osm echo ERROR compiling Citadel.osm (SS2) 27 | if exist Citadel.osm echo Citadel.osm (SS2) compiled successfully. 28 | 29 | if exist Citadel.osm copy Citadel.osm "%OutPath%" 30 | 31 | if exist NVScript.html copy NVScript.html NVScript-SS2.html 32 | 33 | ..\replace.exe "NVScript-SS2.html" "/*T2Version-Start*/" "/*T2Version-Start" 34 | ..\replace.exe "NVScript-SS2.html" "/*T2Version-End*/" "T2Version-Start*/" 35 | ..\replace.exe "NVScript-SS2.html" "/*SS2Version-Start" "/*SS2Version-Start*/" 36 | ..\replace.exe "NVScript-SS2.html" "SS2Version-End*/" "/*SS2Version-End*/" 37 | 38 | if exist NVScript-SS2.html move NVScript-SS2.html "%OutPath%\NVScript.html" 39 | 40 | if exist "%OutPath%\NVScript-SS2.zip" del "%OutPath%\NVScript-SS2.zip" 41 | if exist %OutPath%\NVScript.osm 7z.exe a "%OutPath%\NVScript-SS2.zip" "%OutPath%\NVScript.osm" "%OutPath%\NVScript.html" -tzip -mx9 >NUL -------------------------------------------------------------------------------- /NVScript/Make-T1.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | set OutPath=output 3 | 4 | if exist NVScript_osm.cpp del NVScript_osm.cpp 5 | if exist NVScript_osm.o del NVScript_osm.o 6 | if exist NVScript.o del NVScript.o 7 | if not exist MakeT1 del *.o 8 | if not exist MakeT1 echo . >MakeT1 9 | D:\CygWin\bin\bash --login -i ~/NVScript/NVScript/MakeNVScriptT1.ccd 10 | 11 | echo. 12 | if not exist NVScript.osm echo ERROR compiling NVScript.osm (T1) 13 | if exist NVScript.osm echo NVScript.osm (T1) compiled successfully. 14 | 15 | if exist NVScript.osm copy NVScript.osm "%OutPath%" 16 | if exist NVScript.osm move NVScript.osm "C:\Games\DromEd1" 17 | 18 | echo Copying documentation to output 19 | if exist NVScript.html copy NVScript.html "%OutPath%" 20 | 21 | if exist "%OutPath%\NVScript-T1.zip" del "%OutPath%\NVScript-T1.zip" 22 | if exist %OutPath%\NVScript.osm 7z.exe a "%OutPath%\NVScript-T1.zip" "%OutPath%\NVScript.osm" "%OutPath%\NVScript.html" -tzip -mx9 >NUL -------------------------------------------------------------------------------- /NVScript/Make.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | set OutPath=output 3 | 4 | if exist NVScript_osm.cpp del NVScript_osm.cpp 5 | if exist NVScript_osm.o del NVScript_osm.o 6 | if exist NVScript.o del NVScript.o 7 | if exist NVScriptLib.o del NVScriptLib.o 8 | if exist MakeShock del *.o 9 | if exist MakeShock del MakeShock 10 | 11 | if exist MakeT1 del *.o 12 | if exist MakeT1 del MakeT1 13 | D:\CygWin\bin\bash --login -i ~/NVScript/NVScript/MakeNVScript.ccd 14 | 15 | echo. 16 | if not exist NVScript.osm echo ERROR compiling NVScript.osm 17 | if exist NVScript.osm echo NVScript.osm compiled successfully. 18 | 19 | 20 | if exist NVScript.osm move NVScript.osm "%OutPath%" 21 | 22 | echo Readying documentation 23 | if exist NVScript.html copy NVScript.html "%OutPath%" 24 | 25 | cd "%OutPath%" 26 | if exist "NVScript.zip" del "NVScript.zip" 27 | if exist NVScript.osm "7z.exe" a "NVScript.zip" "NVScript.osm" "NVScript.html" -tzip -mx9 >NUL 28 | 29 | cd .. -------------------------------------------------------------------------------- /NVScript/MakeCitadel.ccd: -------------------------------------------------------------------------------- 1 | make -C ~/NVScript/NVScript Citadel.osm GAMESUFFIX="-SS2" GAME=3 2 | -------------------------------------------------------------------------------- /NVScript/MakeNVDebug.ccd: -------------------------------------------------------------------------------- 1 | make -C ~/NVScript/NVScript NVDebug.osm -------------------------------------------------------------------------------- /NVScript/MakeNVScript.ccd: -------------------------------------------------------------------------------- 1 | make -C ~/NVScript/NVScript NVDebug.osm 2 | make -C ~/NVScript/NVScript NVScript.osm -------------------------------------------------------------------------------- /NVScript/MakeNVScriptDebug.ccd: -------------------------------------------------------------------------------- 1 | make -C ~/NVScript/NVScript NVScript.osm DEBUG=1 2 | -------------------------------------------------------------------------------- /NVScript/MakeNVScriptSS2.ccd: -------------------------------------------------------------------------------- 1 | make -C ~/NVScript/NVScript NVDebug.osm GAMESUFFIX="-SS2" SSINCLUDEH="NVScript-SS2.h NVScript-ThiefShock.h" SSINCLUDEO="NVScript-SS2.o NVScript-ThiefShock.o" SSINCLUDEC="NVScript-SS2.cpp NVScript-ThiefShock.cpp" GAME=3 2 | make -C ~/NVScript/NVScript Citadel.osm GAMESUFFIX="-SS2" SSINCLUDEH="NVScript-SS2.h NVScript-ThiefShock.h" SSINCLUDEO="NVScript-SS2.o NVScript-ThiefShock.o" SSINCLUDEC="NVScript-SS2.cpp NVScript-ThiefShock.cpp" GAME=3 3 | make -C ~/NVScript/NVScript NVScript.osm GAMESUFFIX="-SS2" SSINCLUDEH="NVScript-SS2.h NVScript-ThiefShock.h" SSINCLUDEO="NVScript-SS2.o NVScript-ThiefShock.o" SSINCLUDEC="NVScript-SS2.cpp NVScript-ThiefShock.cpp" GAME=3 -------------------------------------------------------------------------------- /NVScript/MakeNVScriptT1.ccd: -------------------------------------------------------------------------------- 1 | make -C ~/NVScript/NVScript NVDebug.osm GAMESUFFIX="-T1" GAME=1 2 | make -C ~/NVScript/NVScript Citadel.osm GAMESUFFIX="-T1" GAME=1 3 | make -C ~/NVScript/NVScript NVScript.osm GAMESUFFIX="-T1" GAME=1 -------------------------------------------------------------------------------- /NVScript/MakeNone.ccd: -------------------------------------------------------------------------------- 1 | cd NVScript 2 | cd NVScript 3 | echo make NVScript.osm {GAME=2} {BUILD=1} {DEBUG=} -------------------------------------------------------------------------------- /NVScript/NVDebug.cpp: -------------------------------------------------------------------------------- 1 | //#if _DARKGAME != 2 2 | //#error NVDebug is written for Thief2. You can try, but I doubt it. 3 | //#else 4 | 5 | // #include 6 | //#include 7 | 8 | //#include "lg/interface.h" 9 | #include "lg/scrservices.h" 10 | //#include "lg/scrmanagers.h" 11 | #include "lg/scrmsgs.h" 12 | #include "ScriptLib.h" 13 | 14 | #define INITOSM 15 | #include "NVDebug.h" 16 | 17 | #include "lg/iids.h" 18 | 19 | 20 | /*********************** 21 | * NVDifficultyDebug 22 | */ 23 | 24 | MSGHANDLER cScr_NVDifficultyDebug::OnSim(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace) 25 | { 26 | if (static_cast(pMsg)->fStarting) 27 | { 28 | SService pQSrv(g_pScriptManager); 29 | int iCurrent = -1; // Default value (if QVar doesn't exist) 30 | if (!pQSrv->Exists("Difficulty")) 31 | { 32 | if (pQSrv->Exists("DebugDifficulty")) 33 | { 34 | iCurrent = pQSrv->Get("DebugDifficulty"); // Get QVar value 35 | pQSrv->Set("difficulty", iCurrent, 0); 36 | 37 | // Process Difficulty: 38 | SService pDebugSrv(g_pScriptManager); 39 | pDebugSrv->Command("process_difficulty", "", "", "", "", "", "", ""); 40 | } 41 | } 42 | 43 | // Display warning/info (to remind people to delete the object before packing the FM). 44 | #if (_DARKGAME != 3) 45 | switch ( iCurrent ) 46 | { 47 | case -1: 48 | DisplayPrintf("Object %i is being used as Difficulty Debug\nNo difficulty defined.", m_iObjId); 49 | break; 50 | case 0: 51 | DisplayPrintf("Object %i is being used as Difficulty Debug\nDifficulty processed as 'Normal' (%i)", m_iObjId, iCurrent); 52 | break; 53 | case 1: 54 | DisplayPrintf("Object %i is being used as Difficulty Debug\nDifficulty processed as 'Hard' (%i)", m_iObjId, iCurrent); 55 | break; 56 | case 2: 57 | DisplayPrintf("Object %i is being used as Difficulty Debug\nDifficulty processed as 'Expert' (%i)", m_iObjId, iCurrent); 58 | break; 59 | default: 60 | DisplayPrintf("Object %i is being used as Difficulty Debug\nInvalid difficulty specified (%i)", m_iObjId, iCurrent); 61 | } 62 | #else 63 | switch ( iCurrent ) 64 | { 65 | case -1: 66 | DisplayPrintf("Object %i is being used as Difficulty Debug\nNo difficulty defined.", m_iObjId); 67 | break; 68 | case 0: 69 | DisplayPrintf("Object %i is being used as Difficulty Debug\nDifficulty processed as 'Easy' (%i)", m_iObjId, iCurrent); 70 | break; 71 | case 1: 72 | DisplayPrintf("Object %i is being used as Difficulty Debug\nDifficulty processed as 'Normal' (%i)", m_iObjId, iCurrent); 73 | break; 74 | case 2: 75 | DisplayPrintf("Object %i is being used as Difficulty Debug\nDifficulty processed as 'Hard' (%i)", m_iObjId, iCurrent); 76 | break; 77 | case 3: 78 | DisplayPrintf("Object %i is being used as Difficulty Debug\nDifficulty processed as 'Impossible' (%i)", m_iObjId, iCurrent); 79 | break; 80 | default: 81 | DisplayPrintf("Object %i is being used as Difficulty Debug\nInvalid difficulty specified (%i)", m_iObjId, iCurrent); 82 | } 83 | #endif 84 | } 85 | 86 | 87 | return 0; 88 | } 89 | 90 | /*********************** 91 | * NVObjDumper 92 | */ 93 | 94 | MSGHANDLER cScr_NVObjDumper::OnBeginScript(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace) 95 | { 96 | SService pOS(g_pScriptManager); 97 | cScrVec vPosition; 98 | pOS->Position(vPosition, m_iObjId); 99 | 100 | SInterface pTraits(g_pScriptManager); 101 | int iArchetype = pTraits->GetArchetype(m_iObjId); // Make a note of object's archetype. 102 | 103 | cScrStr strName; 104 | pOS->GetName(strName, iArchetype); 105 | 106 | DebugPrintf("%s (%i) at (%f, %f, %f)", static_cast(strName), m_iObjId, vPosition.x, vPosition.y, vPosition.z); 107 | 108 | return 0; 109 | } 110 | //#endif // _DARKGAME == 2 111 | -------------------------------------------------------------------------------- /NVScript/NVDebug.h: -------------------------------------------------------------------------------- 1 | /**************************************** 2 | * Scripts by Nameless Voice 3 | * 4 | */ 5 | 6 | #ifndef NVDEBUGSCRIPT_H 7 | #define NVDEBUGSCRIPT_H 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif 12 | 13 | #include "lg/scrservices.h" 14 | #include "lg/properties.h" 15 | 16 | #include "scriptvars.h" 17 | //#include "Script.h" 18 | #include "ScriptNV.h" 19 | 20 | 21 | DECLARE_MODULE(NVDebug) 22 | 23 | /*************************************************** 24 | * Debug / playtesting scripts. 25 | * Maybe these should be moved to a new module? 26 | **************************************************/ 27 | 28 | 29 | 30 | /************************** 31 | * NVDifficultyDebug 32 | * 33 | * A script designed solely for use in DromEd game mode!? 34 | * 35 | * Messages: Sim 36 | * Parameters: None 37 | * Links: None 38 | */ 39 | DECLARE_SCRIPT(cScr_NVDifficultyDebug,cScriptNV) 40 | { 41 | public: 42 | DECLARE_FACTORY(NVDifficultyDebug,CustomScript); 43 | cScr_NVDifficultyDebug(const char* pszName, int iHostObjId) 44 | : cScriptNV(pszName,iHostObjId) 45 | { } 46 | 47 | private: 48 | DECLARE_MSGHANDLER(OnSim); 49 | 50 | protected: 51 | 52 | virtual void InitScriptData() 53 | { 54 | cScriptNV::InitScriptData(); 55 | REGISTER_MSGHANDLER("Sim", cScr_NVDifficultyDebug::OnSim); 56 | } 57 | }; 58 | 59 | /************************** 60 | * NVObjDumper 61 | * 62 | * Dumps information about its object on BeginScript 63 | * 64 | * Messages: BeginScript 65 | * Parameters: None 66 | * Links: None 67 | */ 68 | DECLARE_SCRIPT(cScr_NVObjDumper,cScriptNV) 69 | { 70 | public: 71 | DECLARE_FACTORY(NVObjDumper,CustomScript); 72 | cScr_NVObjDumper(const char* pszName, int iHostObjId) 73 | : cScriptNV(pszName,iHostObjId) 74 | { } 75 | 76 | private: 77 | // nothing 78 | 79 | protected: 80 | virtual void InitScriptData() 81 | { 82 | cScriptNV::InitScriptData(); 83 | } 84 | 85 | virtual MSGHANDLER OnBeginScript(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace); 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /NVScript/NVDebug.rc: -------------------------------------------------------------------------------- 1 | // This is the version resource file for the makefile build. 2 | // Not really used any more, versions are just pulled from buildconfig.h 3 | // 4 | #define MODULE_NVDEBUG 5 | #include "../buildconfig.h" 6 | #undef MODULE_NVDEBUG 7 | 8 | #include "version.rc" 9 | 10 | -------------------------------------------------------------------------------- /NVScript/NVGenericScript.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef NVGENERICSCRIPT_H 3 | #define NVGENERICSCRIPT_H 4 | 5 | #include "scriptvars.h" 6 | #include "ScriptNV.h" 7 | 8 | 9 | /***************** 10 | * Generic Script 11 | * 12 | */ 13 | class cScrNVGeneric : public cScriptNV 14 | { 15 | public: 16 | cScrNVGeneric(const char* pszName, int iHostObjId) 17 | : cScriptNV(pszName, iHostObjId), 18 | SCRIPT_VAROBJ(m_iUseCount), 19 | SCRIPT_VAROBJ(m_iOnCapacitor), 20 | SCRIPT_VAROBJ(m_iOffCapacitor), 21 | SCRIPT_VAROBJ(m_iOnCapacitorTime), 22 | SCRIPT_VAROBJ(m_iOffCapacitorTime) 23 | { } 24 | 25 | STDMETHOD_(long,ReceiveMessage)(sScrMsg*,sMultiParm*,eScrTraceAction); 26 | 27 | private: 28 | // Nothing private 29 | 30 | protected: 31 | script_int m_iUseCount; 32 | script_int m_iOnCapacitor; 33 | script_int m_iOffCapacitor; 34 | script_int m_iOnCapacitorTime; 35 | script_int m_iOffCapacitorTime; 36 | 37 | virtual void InitGenericVars(void) 38 | { 39 | m_iUseCount.Init(); 40 | m_iOnCapacitor.Init(); 41 | m_iOffCapacitor.Init(); 42 | m_iOnCapacitorTime.Init(); 43 | m_iOffCapacitorTime.Init(); 44 | return; 45 | } 46 | 47 | virtual bool AnyUsesLeft(bool bOn); 48 | virtual bool CheckCapacitor(bool bOn, int iTime); 49 | virtual MSGHANDLER OnPreActivate(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace); 50 | virtual MSGHANDLER OnPreDeactivate(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace); 51 | virtual MSGHANDLER OnActivate(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace) = 0; 52 | virtual MSGHANDLER OnDeactivate(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace) = 0; 53 | 54 | public: 55 | // Nothing public 56 | }; 57 | 58 | #endif // NVGENERICSCRIPT_H 59 | -------------------------------------------------------------------------------- /NVScript/NVGenericTrigger.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef NVGENERICTRIGGER_H 3 | #define NVGENERICTRIGGER_H 4 | 5 | #include "scriptvars.h" 6 | #include "ScriptNV.h" 7 | 8 | /* 9 | * Generic Script 10 | * 11 | */ 12 | class cScrNVTrigger 13 | { 14 | public: 15 | cScrNVTrigger() 16 | : m_iTrigObjId(0) 17 | { 18 | m_szTriggerName = new char[1]; 19 | m_szTriggerName[0] = '\0'; 20 | } 21 | cScrNVTrigger(const char* pszName,int iHostObjId) 22 | : m_iTrigObjId(iHostObjId) 23 | { 24 | m_szTriggerName = new char[strlen(pszName) + 1]; 25 | strcpy(m_szTriggerName, pszName); 26 | } 27 | 28 | virtual ~cScrNVTrigger() 29 | { 30 | if (m_szTriggerName) 31 | { 32 | delete[] m_szTriggerName; 33 | m_szTriggerName = NULL; 34 | } 35 | } 36 | 37 | private: 38 | int m_iTrigObjId; 39 | char* m_szTriggerName; 40 | static int StimIterFunc(ILinkSrv* pLS, ILinkQuery* pLQ, IScript* pScript, void* pData); 41 | long TriggerSingleObject(object oDest, const char* pszMessage, int iMsgTime); 42 | long StimSingleObject(object oDest, object oStim, float fIntensity); 43 | long StimSingleObject(IActReactSrv* pARSrv, object oDest, object oStim, float fIntensity); 44 | // Nothing private 45 | 46 | protected: 47 | virtual void InitScriptData() 48 | { 49 | 50 | // Message handler registration function has not been inherited from cScript. 51 | // I think I'll just add this code to all decendants of this script instead. 52 | // RegisterMessageHandler("ResetTriggerCount", static_cast(&cScrNVTrigger::OnResetTriggerCount)); 53 | 54 | return; 55 | } 56 | 57 | virtual long Trigger(bool bOn, sScrMsg* pMsg, int iDefaultDest = 0, const char* szDefaultOnMessage = "TurnOn", const char* szDefaultOffMessage = "TurnOff"); 58 | 59 | void ResetTriggerCount(); 60 | 61 | public: 62 | // Nothing public 63 | }; 64 | 65 | #endif // NVGENERICTRIGGER_H 66 | -------------------------------------------------------------------------------- /NVScript/NVScript-Defunct.h: -------------------------------------------------------------------------------- 1 | /************************** 2 | * NVSongTrap 3 | * (NVTrap) 4 | * 5 | * 6 | * Messages: TurnOn, TurnOff (Specifiable) 7 | * Parameters: NVVOQVar, NVPoliteVO 8 | * Links: None 9 | */ 10 | /* 11 | DECLARE_SCRIPT(cScr_NVSongTrap, cScrNVGeneric) 12 | { 13 | public: 14 | DECLARE_FACTORY(NVSongTrap,NVGenericTrap); 15 | cScr_NVSongTrap(const char* pszName, int iHostObjId) 16 | : cScrNVGeneric(pszName,iHostObjId) 17 | { } 18 | 19 | private: 20 | virtual long OnActivate(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace); 21 | virtual long OnDeactivate(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace); 22 | 23 | protected: 24 | virtual void InitScriptData() 25 | { 26 | cScrNVGeneric::InitScriptData(); 27 | } 28 | 29 | }; 30 | */ 31 | 32 | /************************** 33 | * NVInfinityStair 34 | * 35 | * Infinite stairs 36 | * 37 | * 38 | * Messages: Descend, Ascend 39 | * Parameters: None 40 | * Links: None 41 | */ 42 | /* 43 | DECLARE_SCRIPT(cScr_NVInfinityStair,cScriptNV) 44 | { 45 | public: 46 | DECLARE_FACTORY(NVInfinityStair,CustomScript); 47 | cScr_NVInfinityStair(const char* pszName, int iHostObjId) 48 | : cScriptNV(pszName,iHostObjId), 49 | SCRIPT_VAROBJ(m_iLevel) 50 | { } 51 | 52 | private: 53 | DECLARE_MSGHANDLER(OnAscend); 54 | DECLARE_MSGHANDLER(OnDescend); 55 | DECLARE_MSGHANDLER(OnAddToLevel); 56 | DECLARE_MSGHANDLER(OnRemoveFromLevel); 57 | void Process(int iDirection); 58 | 59 | protected: 60 | 61 | virtual void InitScriptData() 62 | { 63 | cScriptNV::InitScriptData(); 64 | REGISTER_MSGHANDLER("Ascend", cScr_NVInfinityStair::OnAscend); 65 | REGISTER_MSGHANDLER("Descend", cScr_NVInfinityStair::OnDescend); 66 | REGISTER_MSGHANDLER("AddToLevel", cScr_NVInfinityStair::OnAddToLevel); 67 | REGISTER_MSGHANDLER("RemoveFromLevel", cScr_NVInfinityStair::OnRemoveFromLevel); 68 | } 69 | 70 | script_int m_iLevel; 71 | 72 | virtual void InitVars(void) 73 | { 74 | m_iLevel.Init(); 75 | return; 76 | } 77 | 78 | 79 | }; 80 | 81 | */ 82 | /************************** 83 | * NVInfinityStairCacheRoom 84 | * 85 | * Infinite stairs 86 | * 87 | * 88 | * Messages: Descend, Ascend 89 | * Parameters: None 90 | * Links: None 91 | */ 92 | /* 93 | DECLARE_SCRIPT(cScr_NVInfinityStairCacheRoom,cScriptNV) 94 | { 95 | public: 96 | DECLARE_FACTORY(NVInfinityStairCacheRoom,CustomScript); 97 | cScr_NVInfinityStairCacheRoom(const char* pszName, int iHostObjId) 98 | : cScriptNV(pszName,iHostObjId) 99 | { } 100 | 101 | private: 102 | DECLARE_MSGHANDLER(OnIn); 103 | DECLARE_MSGHANDLER(OnOut); 104 | 105 | protected: 106 | 107 | virtual void InitScriptData() 108 | { 109 | cScriptNV::InitScriptData(); 110 | REGISTER_MSGHANDLER("PlayerRoomEnter", cScr_NVInfinityStairCacheRoom::OnIn); 111 | REGISTER_MSGHANDLER("ObjectRoomEnter", cScr_NVInfinityStairCacheRoom::OnIn); 112 | REGISTER_MSGHANDLER("PlayerRoomExit", cScr_NVInfinityStairCacheRoom::OnOut); 113 | REGISTER_MSGHANDLER("ObjectRoomExit", cScr_NVInfinityStairCacheRoom::OnOut); 114 | } 115 | }; 116 | 117 | */ -------------------------------------------------------------------------------- /NVScript/NVScript-Flames.cpp: -------------------------------------------------------------------------------- 1 | //#if _DARKGAME != 2 2 | //#error NVScript is written for Thief2. You can try, but I doubt it. 3 | //#else 4 | 5 | // #include 6 | #include 7 | 8 | #include "lg/interface.h" 9 | #include "lg/scrservices.h" 10 | #include "lg/scrmanagers.h" 11 | #include "lg/scrmsgs.h" 12 | #include "lg/objects.h" 13 | #include "ScriptLib.h" 14 | #include "NVScriptLib.h" 15 | #include "NVScript-Flames.h" 16 | 17 | #include "lg/iids.h" 18 | 19 | 20 | 21 | /*********************** 22 | * NVInflammable 23 | */ 24 | 25 | MSGHANDLER cScr_NVInflammable::OnBurn(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace) 26 | { 27 | DisplayPrintf("I was hit with some fire..."); 28 | if ( !m_iBurning ) 29 | { 30 | DisplayPrintf("Starting to smoulder..."); 31 | m_iBurning = 1; 32 | 33 | SService pOS(g_pScriptManager); 34 | object oMeta = ParamGetObject(m_iObjId, "NVFlameMeta", 0); 35 | if ( oMeta ) 36 | { 37 | AddSingleMetaProperty(oMeta, m_iObjId); 38 | } 39 | 40 | const char* pszAttach; 41 | int iArc, iJoint; 42 | link lLink, lSPLink; 43 | object oCreated; 44 | char szParam[16]; 45 | 46 | SService pLS(g_pScriptManager); 47 | SService pLTS(g_pScriptManager); 48 | 49 | for ( int i = 1; i < 11; i++ ) 50 | { 51 | DebugPrintf("Considering whether to attach flame %i...", i); 52 | DisplayPrintf("Considering whether to attach flame %i...", i); 53 | oCreated = 0; 54 | sprintf(szParam, "NVFlame%i", i); 55 | pszAttach = ParamGetString(m_iObjId, szParam, NULL); 56 | if ( !pszAttach ) 57 | { 58 | DebugPrintf("No such thing as flame %i", i); 59 | return 0; 60 | } 61 | sprintf(szParam, "NVFlameJoint%i", i); 62 | iJoint = ParamGetInt(m_iObjId, szParam, 0); 63 | iArc = StrToObject(pszAttach); 64 | if ( iArc ) 65 | { 66 | DebugPrintf("Attaching flame %i...", i); 67 | DisplayPrintf("Attaching flame %i...", i); 68 | pOS->Create(oCreated, iArc); 69 | if ( oCreated ) 70 | { 71 | DebugPrintf("Object successfully created for %i...", i); 72 | lLink = 0; 73 | pLS->Create(lLink, pLTS->LinkKindNamed("~ParticleAttachement"), m_iObjId, oCreated); 74 | if (lLink) 75 | { 76 | DebugPrintf("Link created for %i.", i); 77 | if ( iJoint ) 78 | { 79 | DebugPrintf("Joint setup for %i.", i); 80 | pLTS->LinkSetData(lLink, "Type", 2); 81 | pLTS->LinkSetData(lLink, "Joint", iJoint); 82 | } 83 | pLS->Create(lSPLink, pLTS->LinkKindNamed("ScriptParams"), m_iObjId, oCreated); 84 | if ( lSPLink ) 85 | { 86 | DebugPrintf("SP Link created for %i.", i); 87 | pLTS->LinkSetData(lSPLink, NULL, "NVFlameObject"); 88 | } 89 | } 90 | } 91 | } 92 | } 93 | } 94 | return 0; 95 | } 96 | 97 | MSGHANDLER cScr_NVInflammable::OnDouse(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace) 98 | { 99 | IterateLinksByData("ScriptParams", m_iObjId, 0, "NVFlameObject", -1, DestroyAttachedIterFunc, NULL, NULL); 100 | m_iBurning = 0; 101 | object oMeta = ParamGetObject(m_iObjId, "NVFlameMeta", 0); 102 | if ( oMeta ) 103 | { 104 | RemoveSingleMetaProperty(oMeta, m_iObjId); 105 | } 106 | return 0; 107 | } 108 | 109 | int cScr_NVInflammable::DestroyAttachedIterFunc(ILinkSrv* pLS, ILinkQuery* pLQ, IScript* pScript, void* pData) 110 | { 111 | sLink sl; 112 | pLQ->Link(&sl); 113 | 114 | SInterface pOS(g_pScriptManager); 115 | pOS->Destroy(sl.dest); 116 | return 1; 117 | } 118 | 119 | //#endif // _DARKGAME == 2 120 | -------------------------------------------------------------------------------- /NVScript/NVScript-Flames.h: -------------------------------------------------------------------------------- 1 | /**************************************** 2 | * Scripts by Nameless Voice 3 | * 4 | * 5 | * For use with The Circle of Flames 6 | */ 7 | 8 | #ifndef NVSCRIPTFLAMES_H 9 | #define NVSCRIPTFLAMES_H 10 | 11 | #if _MSC_VER > 1000 12 | #pragma once 13 | #endif 14 | 15 | #include "lg/scrservices.h" 16 | #include "lg/properties.h" 17 | 18 | #include "scriptvars.h" 19 | #include "ScriptNV.h" 20 | 21 | /************************** 22 | * NVInflammable 23 | * 24 | * This script allows things to be set on fire. 25 | * 26 | * Messages: FlameStimStimulus 27 | * Parameters: None 28 | * Links: Firer 29 | */ 30 | DECLARE_SCRIPT(cScr_NVInflammable,cScriptNV) 31 | { 32 | public: 33 | DECLARE_FACTORY(NVInflammable,CustomScript); 34 | cScr_NVInflammable(const char* pszName, int iHostObjId) 35 | : cScriptNV(pszName,iHostObjId), 36 | SCRIPT_VAROBJ(m_iBurning) 37 | { } 38 | 39 | private: 40 | DECLARE_MSGHANDLER(OnBurn); 41 | DECLARE_MSGHANDLER(OnDouse); 42 | static int DestroyAttachedIterFunc(ILinkSrv* pLS, ILinkQuery* pLQ, IScript* pScript, void* pData); 43 | script_int m_iBurning; 44 | 45 | protected: 46 | virtual void InitScriptData() 47 | { 48 | cScriptNV::InitScriptData(); 49 | REGISTER_MSGHANDLER("FireStimStimulus", cScr_NVInflammable::OnBurn); 50 | REGISTER_MSGHANDLER("FlameStimStimulus", cScr_NVInflammable::OnBurn); 51 | REGISTER_MSGHANDLER("WaterStimStimulus", cScr_NVInflammable::OnDouse); 52 | } 53 | 54 | virtual void InitVars(void) 55 | { 56 | m_iBurning.Init(); 57 | return; 58 | } 59 | } 60 | END_DECLARE_SCRIPT(cScr_NVInflammable); 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /NVScript/NVScript.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NamelessVoice/NVScript/72866513b1f42a91e1620aa50c9e6bcd7ff68b90/NVScript/NVScript.cpp -------------------------------------------------------------------------------- /NVScript/NVScript.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NamelessVoice/NVScript/72866513b1f42a91e1620aa50c9e6bcd7ff68b90/NVScript/NVScript.h -------------------------------------------------------------------------------- /NVScript/NVScript.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NamelessVoice/NVScript/72866513b1f42a91e1620aa50c9e6bcd7ff68b90/NVScript/NVScript.html -------------------------------------------------------------------------------- /NVScript/NVScript.rc: -------------------------------------------------------------------------------- 1 | // This is the version resource file for the makefile build. 2 | // Not really used any more, versions are just pulled from buildconfig.h 3 | // 4 | #define MODULE_NVSCRIPT 5 | #include "../buildconfig.h" 6 | #undef MODULE_NVSCRIPT 7 | 8 | #include "version.rc" 9 | 10 | -------------------------------------------------------------------------------- /NVScript/NVScriptLib.h: -------------------------------------------------------------------------------- 1 | /************************************************ 2 | * General-purpose Utilities for script modules 3 | */ 4 | 5 | #ifndef NVSCRIPTLIB_H 6 | #define NVSCRIPTLIB_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | 14 | #if (_DARKGAME == 3) 15 | #define QVARPROP "QBName" 16 | #else 17 | #define QVARPROP "TrapQVar" 18 | #endif 19 | 20 | 21 | /************* 22 | * Objects 23 | */ 24 | 25 | // Convert a string to an object reference. Understands [Me], [Source], and ^ (closest) 26 | int NVStrToObject(const char* pszName, sScrMsg* pMsg); 27 | int NVStrToObject(const char* pszName, int iSource, int iMe); 28 | 29 | std::vector GetObjects(const char* pszDest, int iObj, sScrMsg* pMsg); 30 | 31 | // Get the distance between two points, using the Theorem of Pythagoras. 32 | float GetDistance(const mxs_vector* vSource, const mxs_vector* vDest); 33 | // Get the distance between two points on the X and Y axes only. The Z axis is ignored, using the Theorem of Pythagoras. 34 | float GetDistanceXY(const mxs_vector* vSource, const mxs_vector* vDest); 35 | 36 | // Returns the first object contained by iContainer that inherits from iType. 37 | int GetSinglePossession(int iContainer, int iType); 38 | 39 | // Gets a random ScriptParams link, treating data as a 'weight'. 40 | long GetAnyWeightedLink(int iSource, int iDest, sLink* pResult); 41 | 42 | int ParamGetNVObject(int iObject, const char* pszParam, int iDefault = 0); 43 | 44 | int NVParamGetInt(int iObject, const char* pszScriptName, const char* pszParam, int iDefault); 45 | void NVParamSetInt(int iObject, const char* pszScriptName, const char* pszParam, int iValue); 46 | float NVParamGetFloat(int iObject, const char* pszScriptName, const char* pszParam, float fDefault); 47 | const char* NVParamGetString(int iObject, const char* pszScriptName, const char* pszParam, const char* sDefault); 48 | int NVParamGetNVObject(int iObject, const char* pszScriptName, const char* pszParam, int iDefault); 49 | 50 | // Get the descriptive name (either its name, or the name of its archetype) of an object 51 | cScrStr GetObjectDescriptiveName(int objId); 52 | 53 | void ErrorPrintf(const char* pszMessage, const char* pszFormat, ...); 54 | 55 | bool GetQVarInfo(int iQVarObjId, char* cOperand, int* iValue, char** pszQVar, int* iValueLength); 56 | bool GetQVarInfo(char* pszQVarString, char* cOperand, int* iValue, char** pszQVar, int* iValueLength); 57 | 58 | #endif // NVSCRIPTLIB_H 59 | -------------------------------------------------------------------------------- /NVScript/ParamCache.h: -------------------------------------------------------------------------------- 1 | #ifndef PARAMCACHE_H 2 | #define PARAMCACHE_H 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include "strless_nocase.h" 17 | 18 | 19 | class cParamCache 20 | { 21 | public: 22 | cParamCache(IScriptMan *pInterface); 23 | ~cParamCache(); 24 | 25 | private: 26 | typedef std::map tParamEntryMap; 27 | typedef std::map tParamCacheMap; 28 | 29 | #ifdef DEBUG_PARAMCACHE 30 | struct tParamDebugCounter { 31 | unsigned long hit; 32 | unsigned long miss; 33 | unsigned long reparse; 34 | tParamDebugCounter() : 35 | hit(0), 36 | miss(0), 37 | reparse(0) 38 | { }; 39 | }; 40 | struct tParamDebug { 41 | std::map counter; 42 | unsigned long read; 43 | unsigned long touch; 44 | tParamDebug() : 45 | read(0), 46 | touch(0) 47 | { }; 48 | }; 49 | std::map m_mapParamDebug; 50 | int (__cdecl *m_Printf)(const char*,...); 51 | public: 52 | void SetDebug(int (__cdecl *pfnMPrintf)(const char*,...)); 53 | void PrintDebug(void); 54 | #endif 55 | private: 56 | 57 | tParamCacheMap m_mapParamCache; 58 | 59 | IStringProperty *m_pDNProp; 60 | ITraitManager *m_pTraitMan; 61 | 62 | PropListenerHandle m_hListenerHandle; 63 | int m_iUpdatingObj; 64 | 65 | static void __stdcall PropertyListener(sPropertyListenMsg* pPropMsg, PropListenerData pData); 66 | static int __cdecl SimListener(const sDispatchMsg* pSimMsg, const sDispatchListenerDesc* pData); 67 | static const GUID sm_iid; 68 | 69 | void Parse(tParamEntryMap& cache, const char* pszDN); 70 | std::string Unparse(tParamEntryMap& cache); 71 | tParamEntryMap* Read(int iObj); 72 | void Write(int iObj); 73 | 74 | public: 75 | const std::string* Retrieve(int iObj, const std::string& sParamName); 76 | const std::string* RetrieveSingle(int iObj, const std::string& sParamName); 77 | void Update(int iObj, const std::string& sParamName, const std::string* sParamValue); 78 | void Remove(int iObj, const std::string& sParamName); 79 | void Touch(int iObj); 80 | void Reset(void); 81 | }; 82 | 83 | #endif // PARAMCACHE_H 84 | -------------------------------------------------------------------------------- /NVScript/ScrInstance.cpp: -------------------------------------------------------------------------------- 1 | #include "ScrInstance.h" 2 | #include 3 | 4 | inline char* _alloc(size_t __n) 5 | { 6 | size_t* __r = reinterpret_cast(::operator new(__n + sizeof(size_t))); 7 | *__r = 1; 8 | return reinterpret_cast(__r + 1); 9 | } 10 | 11 | inline const char* _copy(const char* __s) 12 | { 13 | char* __x = _alloc(::strlen(__s)+1); 14 | ::strcpy(__x, __s); 15 | return __x; 16 | } 17 | 18 | inline size_t* _ref(const char* __s) 19 | { 20 | return reinterpret_cast(const_cast(__s)) - 1; 21 | } 22 | 23 | ScrInstance::~ScrInstance() 24 | { 25 | if (first) 26 | { 27 | size_t* __r = _ref(first); 28 | if (--*__r == 0) 29 | ::operator delete(__r); 30 | } 31 | } 32 | 33 | ScrInstance::ScrInstance(const char* __a, int __b) 34 | : std::pair(NULL,__b) 35 | { 36 | if (__a) 37 | { 38 | first = _copy(__a); 39 | } 40 | } 41 | 42 | ScrInstance::ScrInstance(const ScrInstance& __p) 43 | : std::pair(__p.first,__p.second) 44 | { 45 | if (__p.first) 46 | { 47 | size_t* __r = _ref(__p.first); 48 | *__r += 1; 49 | } 50 | } 51 | 52 | ScrInstance::ScrInstance(const std::pair& __p) 53 | : std::pair(NULL,__p.second) 54 | { 55 | if (__p.first) 56 | { 57 | first = _copy(__p.first); 58 | } 59 | } 60 | 61 | int ScrInstance::compare(const std::pair& __x) const 62 | { 63 | if (first == __x.first) 64 | return second - __x.second; 65 | int __c = ::stricmp(first, __x.first); 66 | return (__c != 0) ? __c : second - __x.second; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /NVScript/ScrInstance.h: -------------------------------------------------------------------------------- 1 | #ifndef SCRINSTANCE_H 2 | #define SCRINSTANCE_H 1 3 | 4 | #include 5 | #include 6 | 7 | struct ScrInstance : public std::pair 8 | { 9 | ~ScrInstance(); 10 | ScrInstance() : std::pair(NULL,0) { } 11 | ScrInstance(const char* __a, int __b); 12 | ScrInstance(const ScrInstance& __p); 13 | ScrInstance(const std::pair& __p); 14 | 15 | bool operator==(const ScrInstance& __x) const 16 | { return compare(__x) == 0; } 17 | bool operator==(const std::pair& __x) const 18 | { return compare(__x) == 0; } 19 | bool operator!=(const ScrInstance& __x) const 20 | { return compare(__x) != 0; } 21 | bool operator!=(const std::pair& __x) const 22 | { return compare(__x) != 0; } 23 | bool operator<(const ScrInstance& __x) const 24 | { return compare(__x) < 0; } 25 | bool operator<(const std::pair& __x) const 26 | { return compare(__x) < 0; } 27 | bool operator>(const ScrInstance& __x) const 28 | { return compare(__x) > 0; } 29 | bool operator>(const std::pair& __x) const 30 | { return compare(__x) > 0; } 31 | bool operator<=(const ScrInstance& __x) const 32 | { return compare(__x) <= 0; } 33 | bool operator<=(const std::pair& __x) const 34 | { return compare(__x) <= 0; } 35 | bool operator>=(const ScrInstance& __x) const 36 | { return compare(__x) >= 0; } 37 | bool operator>=(const std::pair& __x) const 38 | { return compare(__x) >= 0; } 39 | 40 | int compare(const std::pair& __x) const; 41 | }; 42 | 43 | #endif //SCRINSTANCE_H 44 | -------------------------------------------------------------------------------- /NVScript/Script.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef SCRIPT_H 3 | #define SCRIPT_H 4 | 5 | #include 6 | #include 7 | #include "strless_nocase.h" 8 | 9 | #include "lg/objstd.h" 10 | #include "lg/script.h" 11 | #include "ScriptModule.h" 12 | 13 | #undef DispatchMessage 14 | 15 | #ifdef GENOSM 16 | # define DECLARE_MODULE(osmName) DECLARE_MODULE(osmName) 17 | # define DECLARE_SCRIPT(clName,clBase) DECLARE_SCRIPT(clName,clBase) 18 | # define DECLARE_FACTORY(scrName,scrBase) DECLARE_FACTORY(scrName,scrBase) 19 | # define DECLARE_MSGHANDLER(fnName) DECLARE_MSGHANDLER(fnName) 20 | # define END_DECLARE_SCRIPT(clName) END_DECLARE_SCRIPT(clName) 21 | # define REGISTER_MSGHANDLER(msgName,fnHandler) REGISTER_MSGHANDLER(msgName,fnHandler) 22 | #else 23 | # define DECLARE_MODULE(osmName) 24 | # define DECLARE_SCRIPT(clName,clBase) class clName : public clBase 25 | # define DECLARE_FACTORY(scrName,scrBase) \ 26 | private: \ 27 | static IScript* __cdecl Make(const char* pszName, int iHostObjId) \ 28 | { \ 29 | cScr_##scrName* pscrRet = new(std::nothrow) cScr_##scrName(pszName, iHostObjId); \ 30 | if (pscrRet) \ 31 | { \ 32 | pscrRet->AddRef(); \ 33 | pscrRet->InitScriptData(); \ 34 | } \ 35 | return static_cast(pscrRet); \ 36 | } \ 37 | public: \ 38 | static void InitScriptDesc(sNewClassDesc * pDesc) \ 39 | { \ 40 | pDesc->pszModule = NULL; \ 41 | pDesc->pszClass = #scrName; \ 42 | pDesc->pszBaseClass = #scrBase; \ 43 | pDesc->pfnFactory = cScriptModule::ScriptFactory; \ 44 | pDesc->pfnRealFactory = Make; \ 45 | } 46 | 47 | #ifdef INITOSM 48 | #define END_DECLARE_SCRIPT(clName) ; \ 49 | struct _ScriptAutoRegister##clName \ 50 | { \ 51 | _ScriptAutoRegister##clName() { RegisterScriptClass(clName::InitScriptDesc); } \ 52 | } __ScriptAutoRegister##clName 53 | #else 54 | #define END_DECLARE_SCRIPT(clName) 55 | #endif 56 | 57 | # define MSGHANDLER long __cdecl 58 | # define DECLARE_MSGHANDLER(fnName) MSGHANDLER fnName(sScrMsg*, sMultiParm*, eScrTraceAction) 59 | # define REGISTER_MSGHANDLER(msgName,fnHandler) \ 60 | RegisterMessageHandler(msgName, static_cast(&fnHandler)) 61 | #endif 62 | 63 | 64 | struct sNewClassDesc : public sScrClassDesc 65 | { 66 | ScriptFactoryProc pfnRealFactory; 67 | }; 68 | 69 | 70 | class cScript : public IScript 71 | { 72 | protected: 73 | typedef long (__cdecl cScript::*MessageHandlerFunc)(sScrMsg*, sMultiParm*, eScrTraceAction); 74 | 75 | private: 76 | typedef std::map, strless_nocase> tDispatchMap; 77 | 78 | public: 79 | // IUnknown 80 | STDMETHOD(QueryInterface)(REFIID,void**); 81 | STDMETHOD_(ULONG,AddRef)(void); 82 | STDMETHOD_(ULONG,Release)(void); 83 | // IScript 84 | STDMETHOD_(const char*,GetClassName)(void); 85 | STDMETHOD_(long,ReceiveMessage)(sScrMsg*,sMultiParm*,eScrTraceAction); 86 | 87 | private: 88 | long int m_iRef; 89 | 90 | public: 91 | virtual ~cScript(); 92 | cScript(const char* pszName, int iHostObjId); 93 | 94 | STDMETHOD_(void*,GetThisPointer)() 95 | { 96 | return reinterpret_cast(this); 97 | } 98 | void DebugString(const char* pszMsg1, const char* pszMsg2 = ""); 99 | 100 | protected: 101 | char* m_szName; 102 | int m_iObjId; 103 | bool m_bSim; 104 | 105 | tDispatchMap m_mapHandlers; 106 | 107 | bool RegisterMessageHandler(const char* pszMsgName, MessageHandlerFunc pmfMsgHandler); 108 | bool UnregisterMessageHandler(const char* pszMsgName, MessageHandlerFunc pmfMsgHandler); 109 | long DispatchMessage(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace); 110 | virtual void InitScriptData(); 111 | 112 | private: 113 | 114 | MSGHANDLER ScriptPtrQuery(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace); 115 | 116 | }; 117 | 118 | 119 | #ifdef INITOSM 120 | void RegisterScriptClass(void (*)(sNewClassDesc*)); 121 | #endif 122 | 123 | 124 | #endif // SCRIPT_H 125 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/AddMetaProperty.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | int AddMetaProperty(const char* pszMetaProp, int iObjId) 4 | { 5 | SService pOS(g_pScriptManager); 6 | object oMetaProp; 7 | pOS->Named(oMetaProp, pszMetaProp); 8 | if (oMetaProp != 0) 9 | return pOS->AddMetaProperty(iObjId, oMetaProp); 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/AddSingleMetaProperty.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | static int DoAddMetaProperty(IObjectSrv* pOS, object oMetaProp, object oObject) 4 | { 5 | int iRet = 0; 6 | true_bool has_mp; 7 | pOS->HasMetaProperty(has_mp, oObject, oMetaProp); 8 | if (!has_mp) 9 | { 10 | iRet = pOS->AddMetaProperty(oObject, oMetaProp); 11 | } 12 | return iRet; 13 | } 14 | 15 | int AddSingleMetaProperty(const char* pszMetaProp, int iObjId) 16 | { 17 | SService pOS(g_pScriptManager); 18 | object oMetaProp; 19 | pOS->Named(oMetaProp, pszMetaProp); 20 | if (oMetaProp != 0) 21 | return DoAddMetaProperty(pOS, oMetaProp, iObjId); 22 | return 0; 23 | } 24 | 25 | int AddSingleMetaProperty(int iMetaProp, int iObjId) 26 | { 27 | SService pOS(g_pScriptManager); 28 | return DoAddMetaProperty(pOS, iMetaProp, iObjId); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/CDSend.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | long CDSend(const char* pszMessage, int iSource, const cMultiParm& mp) 4 | { 5 | SService pLS(g_pScriptManager); 6 | SService pLTS(g_pScriptManager); 7 | return pLS->BroadcastOnAllLinksData(iSource, pszMessage, pLTS->LinkKindNamed(g_pszCDLinkFlavor), mp); 8 | } 9 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/CalcTextTime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int CalcTextTime(const char* pszText, int iWordTime) 6 | { 7 | register const char *p = pszText; 8 | register const char *q = p; 9 | register int c = 0, e = 0; 10 | while (*p) 11 | { 12 | if (isspace((int)(unsigned int)(unsigned char)*p)) 13 | { 14 | if ((p - q) + e > 3) 15 | { 16 | ++c; 17 | e = 0; 18 | } 19 | else 20 | ++e; 21 | while (isspace((int)(unsigned int)(unsigned char)*++p)) ; 22 | q = p; 23 | continue; 24 | } 25 | ++p; 26 | } 27 | if ((p - q) + e > 3) 28 | ++c; 29 | //if (c < ((p-pszText)/8)) 30 | // c = (p-pszText)/8; 31 | return iWordTime * ((c < 10) ? 10 : c); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/DebugPrintf.cpp: -------------------------------------------------------------------------------- 1 | #define _SHOCKINTERFACES 1 2 | #include "ScriptLib.h" 3 | 4 | extern int (__cdecl *g_pfnMPrintf)(const char*, ...); 5 | 6 | #include 7 | #include 8 | 9 | using namespace std; 10 | 11 | // vs[n]printf is pre-C99 in msvcrt6, 12 | // so we can't dynamically allocating a buffer. 13 | // 1000 is a limit imposed by Dromed's mprint 14 | void DebugPrintf(const char* pszFormat, ...) 15 | { 16 | va_list va; 17 | char psz[1000]; 18 | va_start(va, pszFormat); 19 | int iLen = _vsnprintf(psz, 999, pszFormat, va); 20 | va_end(va); 21 | 22 | if (g_pfnMPrintf) 23 | { 24 | g_pfnMPrintf("%s\n", psz); 25 | } 26 | else 27 | { 28 | IDebugScrSrv* pDSS = static_cast(g_pScriptManager->GetService(IID_IDebugScriptService)); 29 | if (!pDSS) 30 | { 31 | return; 32 | } 33 | cScrStr nil; 34 | pDSS->MPrint(psz, nil, nil, nil, nil, nil, nil, nil); 35 | pDSS->Release(); 36 | } 37 | #ifdef DEBUG 38 | //ShowString(psz, 1000 + (iLen * 50)); 39 | try 40 | { 41 | // ShockAI should fail in Thief. 42 | SService pShockAI(g_pScriptManager); 43 | // TDP retains a non-functional copy of ShockGame, 44 | // so we can't use it alone to test the game type. 45 | SService pShock(g_pScriptManager); 46 | pShock->AddText(psz, 0, 1000 + (iLen * 50)); 47 | } 48 | catch (no_interface&) 49 | { 50 | SService pUI(g_pScriptManager); 51 | pUI->TextMessage(psz, 0, 1000 + (iLen * 50)); 52 | } 53 | #else 54 | iLen = iLen; 55 | #endif 56 | } 57 | 58 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/DeleteAllLinks.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | void DeleteAllLinks(const char* pszFlavor, int iSource, int iDest) 4 | { 5 | SService pLS(g_pScriptManager); 6 | SService pLTS(g_pScriptManager); 7 | 8 | linkset lsLinks; 9 | linkkind lkFlavor = (pszFlavor) ? pLTS->LinkKindNamed(pszFlavor) : 0; 10 | pLS->GetAll(lsLinks, lkFlavor, iSource, iDest); 11 | for (; lsLinks.AnyLinksLeft(); lsLinks.NextLink()) 12 | { 13 | pLS->Destroy(lsLinks.Link()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/DeleteAllLinksByData.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | void DeleteAllLinksByData(const char* pszFlavor, int iSource, int iDest, const void* pvFilter, int iFilterLen) 8 | { 9 | SService pLS(g_pScriptManager); 10 | SService pLTS(g_pScriptManager); 11 | 12 | int (__cdecl *cmp)(const void*, const void*, size_t) = memcmp; 13 | if (pvFilter && iFilterLen == -1) 14 | { 15 | iFilterLen = strlen(reinterpret_cast(pvFilter)) + 1; 16 | cmp = reinterpret_cast(strnicmp); 17 | } 18 | 19 | linkset lsLinks; 20 | linkkind lkFlavor = (pszFlavor) ? pLTS->LinkKindNamed(pszFlavor) : 0; 21 | pLS->GetAll(lsLinks, lkFlavor, iSource, iDest); 22 | for (; lsLinks.AnyLinksLeft(); lsLinks.NextLink()) 23 | { 24 | void* pLinkData = lsLinks.Data(); 25 | if (pvFilter) 26 | { 27 | if (!pLinkData) 28 | continue; 29 | if ((*cmp)(pvFilter, pLinkData, iFilterLen)) 30 | continue; 31 | } 32 | else 33 | { 34 | if (pLinkData && *reinterpret_cast(pLinkData)) 35 | continue; 36 | } 37 | pLS->Destroy(lsLinks.Link()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/DisplayPrintf.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | void DisplayPrintf(const char* pszFormat, ...) 9 | { 10 | va_list va; 11 | char psz[1000]; 12 | va_start(va, pszFormat); 13 | _vsnprintf(psz, 1000, pszFormat, va); 14 | va_end(va); 15 | 16 | ShowString(psz, CalcTextTime(psz, 500)); 17 | } 18 | 19 | void DisplayPrintf(COLORREF iColour, const char* pszFormat, ...) 20 | { 21 | va_list va; 22 | char psz[1000]; 23 | va_start(va, pszFormat); 24 | _vsnprintf(psz, 1000, pszFormat, va); 25 | va_end(va); 26 | 27 | ShowString(psz, CalcTextTime(psz, 500), iColour); 28 | } 29 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/FixupPlayerLinks.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | static int FixupPlayerLinksFunc(ILinkSrv* pLS, ILinkQuery* pLQ, IScript* pScript, void* pData) 4 | { 5 | // Move the destination of the link to the object specified in pData 6 | SInterface pLM(g_pScriptManager); 7 | int iPlayer = reinterpret_cast(pData); 8 | sLink slInfo; 9 | pLQ->Link(&slInfo); 10 | pLM->AddFull(slInfo.source, iPlayer, slInfo.flavor, pLQ->Data()); 11 | pLM->Remove(pLQ->ID()); 12 | return 1; 13 | } 14 | 15 | void FixupPlayerLinks(int iSource, int iPlayer) 16 | { 17 | SService pLS(g_pScriptManager); 18 | SService pLTS(g_pScriptManager); 19 | // Get the PlayerFactory link. There should only ever be one of these. 20 | link lPFLink; 21 | pLS->GetOne(lPFLink, pLTS->LinkKindNamed("PlayerFactory"), 0, 0); 22 | if (lPFLink == 0) 23 | return; 24 | // Iterate through all links from here to the source of the PF link. 25 | sLink lPFInfo; 26 | pLTS->LinkGet(lPFLink, lPFInfo); 27 | IterateLinks(NULL, iSource, lPFInfo.source, FixupPlayerLinksFunc, NULL, reinterpret_cast(iPlayer)); 28 | } 29 | 30 | 31 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetAnyLink.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | long GetAnyLink(const char* pszFlavor, int iSource, int iDest, sLink* pResult) 8 | { 9 | SService pLS(g_pScriptManager); 10 | SService pLTS(g_pScriptManager); 11 | 12 | vector vLinks; 13 | linkset lsLinks; 14 | linkkind lkFlavor = (pszFlavor) ? pLTS->LinkKindNamed(pszFlavor) : 0; 15 | pLS->GetAll(lsLinks, lkFlavor, iSource, iDest); 16 | for (; lsLinks.AnyLinksLeft(); lsLinks.NextLink()) 17 | { 18 | vLinks.insert(vLinks.begin(), lsLinks.Link()); 19 | } 20 | 21 | long iLinkID = 0; 22 | if (!vLinks.empty()) 23 | { 24 | SService pDS(g_pScriptManager); 25 | iLinkID = vLinks.at(pDS->RandInt(0, vLinks.size() - 1)); 26 | if (iLinkID && pResult) 27 | pLTS->LinkGet(iLinkID, *pResult); 28 | } 29 | return iLinkID; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetAnyLinkByData.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | 6 | #ifdef __BORLANDC__ 7 | #define strnicmp std::strnicmp 8 | #endif 9 | 10 | using namespace std; 11 | 12 | long GetAnyLinkByData(const char* pszFlavor, int iSource, int iDest, sLink* pResult, const void* pvData, int iDataLen) 13 | { 14 | SService pLS(g_pScriptManager); 15 | SService pLTS(g_pScriptManager); 16 | 17 | int (__cdecl *cmp)(const void*, const void*, size_t) = memcmp; 18 | if (pvData && iDataLen == -1) 19 | { 20 | iDataLen = strlen(reinterpret_cast(pvData)) + 1; 21 | cmp = reinterpret_cast(strnicmp); 22 | } 23 | 24 | vector vLinks; 25 | linkset lsLinks; 26 | linkkind lkFlavor = (pszFlavor) ? pLTS->LinkKindNamed(pszFlavor) : 0; 27 | pLS->GetAll(lsLinks, lkFlavor, iSource, iDest); 28 | for (; lsLinks.AnyLinksLeft(); lsLinks.NextLink()) 29 | { 30 | void* pLinkData = lsLinks.Data(); 31 | if (pvData) 32 | { 33 | if (!pLinkData) 34 | continue; 35 | if ((*cmp)(pvData, pLinkData, iDataLen)) 36 | continue; 37 | } 38 | else 39 | { 40 | if (pLinkData && *reinterpret_cast(pLinkData)) 41 | continue; 42 | } 43 | vLinks.insert(vLinks.begin(), lsLinks.Link()); 44 | } 45 | 46 | long iLinkID = 0; 47 | if (!vLinks.empty()) 48 | { 49 | SService pDS(g_pScriptManager); 50 | iLinkID = vLinks.at(pDS->RandInt(0, vLinks.size() - 1)); 51 | if (iLinkID && pResult) 52 | pLTS->LinkGet(iLinkID, *pResult); 53 | } 54 | return iLinkID; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetAnyLinkByDataDest.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | int GetAnyLinkByDataDest(const char* pszFlavor, int iSource, const void* pvData, int iDataLen) 4 | { 5 | sLink sl; 6 | if (GetAnyLinkByData(pszFlavor, iSource, 0, &sl, pvData, iDataLen)) 7 | return sl.dest; 8 | return 0; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetAnyLinkByDataInheritedSrc.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __BORLANDC__ 8 | #define strnicmp std::strnicmp 9 | #endif 10 | 11 | using namespace std; 12 | 13 | long GetAnyLinkByDataInheritedSrc(const char* pszFlavor, int iSource, int iDest, sLink* pResult, const void* pvData, int iDataLen) 14 | { 15 | SInterface pTM(g_pScriptManager); 16 | SInterface pLM(g_pScriptManager); 17 | SInterface pRel; 18 | pRel = pLM->GetRelationNamed(pszFlavor); 19 | if (!pRel) 20 | return 0; 21 | SInterface pTree; 22 | pTree = pTM->Query(iSource, kTraitQueryMetaProps | kTraitQueryFull); 23 | if (!pTree) 24 | return 0; 25 | 26 | int (__cdecl *cmp)(const void*, const void*, size_t) = memcmp; 27 | if (pvData && iDataLen == -1) 28 | { 29 | iDataLen = strlen(reinterpret_cast(pvData)) + 1; 30 | cmp = reinterpret_cast(strnicmp); 31 | } 32 | 33 | vector vLinks; 34 | for (; ! pTree->Done(); pTree->Next()) 35 | { 36 | if (pRel->AnyLinks(pTree->Object(), iDest)) 37 | { 38 | ILinkQuery* pLQ = pRel->Query(pTree->Object(), iDest); 39 | for (; ! pLQ->Done(); pLQ->Next()) 40 | { 41 | void* pLinkData = pLQ->Data(); 42 | if (pvData) 43 | { 44 | if (pLinkData && !(*cmp)(pvData, pLinkData, iDataLen)) 45 | { 46 | vLinks.insert(vLinks.begin(), pLQ->ID()); 47 | } 48 | } 49 | else 50 | { 51 | if (!pLinkData || !*reinterpret_cast(pLinkData)) 52 | { 53 | vLinks.insert(vLinks.begin(), pLQ->ID()); 54 | } 55 | } 56 | } 57 | pLQ->Release(); 58 | if (!vLinks.empty()) 59 | break; 60 | } 61 | } 62 | 63 | long iLinkID = 0; 64 | if (!vLinks.empty()) 65 | { 66 | SService pDS(g_pScriptManager); 67 | iLinkID = vLinks.at(pDS->RandInt(0, vLinks.size() - 1)); 68 | if (iLinkID && pResult) 69 | pLM->Get(iLinkID, pResult); 70 | } 71 | return iLinkID; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetAnyLinkDest.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | int GetAnyLinkDest(const char* pszFlavor, int iSource) 4 | { 5 | sLink sl; 6 | if (GetAnyLink(pszFlavor, iSource, 0, &sl)) 7 | return sl.dest; 8 | return 0; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetAnyLinkInheritedSrc.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | #include 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | long GetAnyLinkInheritedSrc(const char* pszFlavor, int iSource, int iDest, sLink* pResult) 9 | { 10 | SInterface pTM(g_pScriptManager); 11 | SInterface pLM(g_pScriptManager); 12 | SInterface pRel; 13 | pRel = pLM->GetRelationNamed(pszFlavor); 14 | if (!pRel) 15 | return 0; 16 | SInterface pTree; 17 | pTree = pTM->Query(iSource, kTraitQueryMetaProps | kTraitQueryFull); 18 | if (!pTree) 19 | return 0; 20 | 21 | vector vLinks; 22 | for (; ! pTree->Done(); pTree->Next()) 23 | { 24 | if (pRel->AnyLinks(pTree->Object(), iDest)) 25 | { 26 | ILinkQuery* pLQ = pRel->Query(pTree->Object(), iDest); 27 | for (; ! pLQ->Done(); pLQ->Next()) 28 | { 29 | vLinks.insert(vLinks.begin(), pLQ->ID()); 30 | } 31 | pLQ->Release(); 32 | } 33 | } 34 | 35 | long iLinkID = 0; 36 | if (!vLinks.empty()) 37 | { 38 | SService pDS(g_pScriptManager); 39 | iLinkID = vLinks.at(pDS->RandInt(0, vLinks.size() - 1)); 40 | if (iLinkID && pResult) 41 | pLM->Get(iLinkID, pResult); 42 | } 43 | return iLinkID; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetObjectParamBool.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | bool GetObjectParamBool(int iObject, const char* pszParam) 4 | { 5 | char* params = GetObjectParams(iObject); 6 | if (!params) 7 | return 0; 8 | bool bRet = GetParamBool(params, pszParam); 9 | g_pMalloc->Free(params); 10 | return bRet; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetObjectParamFloat.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | float GetObjectParamFloat(int iObject, const char* pszParam) 4 | { 5 | char* params = GetObjectParams(iObject); 6 | if (!params) 7 | return 0; 8 | float fRet = GetParamFloat(params, pszParam); 9 | g_pMalloc->Free(params); 10 | return fRet; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetObjectParamInt.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | int GetObjectParamInt(int iObject, const char* pszParam) 4 | { 5 | char* params = GetObjectParams(iObject); 6 | if (!params) 7 | return 0; 8 | int iRet = GetParamInt(params, pszParam); 9 | g_pMalloc->Free(params); 10 | return iRet; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetObjectParamObject.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | int GetObjectParamObject(int iObject, const char* pszParam) 4 | { 5 | char* params = GetObjectParams(iObject); 6 | if (!params) 7 | return 0; 8 | int iRet = GetParamObject(params, pszParam); 9 | g_pMalloc->Free(params); 10 | return iRet; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetObjectParamString.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | char* GetObjectParamString(int iObject, const char* pszParam) 4 | { 5 | char* pszString = GetObjectParams(iObject); 6 | char* pszRet = GetParamString(pszString, pszParam); 7 | g_pMalloc->Free(pszString); 8 | return pszRet; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetObjectParamTime.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | int GetObjectParamTime(int iObject, const char* pszParam) 4 | { 5 | char* params = GetObjectParams(iObject); 6 | if (!params) 7 | return 0; 8 | int iRet = GetParamTime(params, pszParam); 9 | g_pMalloc->Free(params); 10 | return iRet; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetObjectParams.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | extern const char* g_pszDesignNote; 4 | 5 | char* GetObjectParams(int iObject) 6 | { 7 | SService pPS(g_pScriptManager); 8 | cMultiParm mpDesignNote; 9 | if (!pPS->Possessed(iObject, g_pszDesignNote)) 10 | return NULL; 11 | pPS->Get(mpDesignNote, iObject, g_pszDesignNote, NULL); 12 | // naughty little shortcut to avoid alloc+copy 13 | mpDesignNote.type = kMT_Undef; 14 | return (mpDesignNote.psz); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetObjectParamsNoInherit.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | #include 3 | 4 | extern const char* g_pszDesignNote; 5 | 6 | char* GetObjectParamsNoInherit(int iObject) 7 | { 8 | SInterface pPM(g_pScriptManager); 9 | IProperty* pProp = pPM->GetPropertyNamed(g_pszDesignNote); 10 | if (!pProp) 11 | throw null_pointer(); 12 | if (!pProp->IsSimplyRelevant(iObject)) 13 | { 14 | pProp->Release(); 15 | return NULL; 16 | } 17 | IStringProperty *pDNProp; 18 | const char* pszDesignNote; 19 | char* pszRet; 20 | if (E_NOINTERFACE == pProp->QueryInterface(IID_IStringProperty, reinterpret_cast(&pDNProp))) 21 | throw no_interface("IStringProperty"); 22 | pProp->Release(); 23 | pDNProp->GetSimple(iObject, &pszDesignNote); 24 | if ( pszDesignNote == NULL ) 25 | return NULL; 26 | 27 | pszRet = reinterpret_cast(g_pMalloc->Alloc(strlen(pszDesignNote) + 1)); 28 | if (pszRet) 29 | strcpy(pszRet, pszDesignNote); 30 | pDNProp->Release(); 31 | return pszRet; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetOneLink.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | long GetOneLink(const char* pszFlavor, int iSource, int iDest, sLink* pResult) 4 | { 5 | SService pLS(g_pScriptManager); 6 | SService pLTS(g_pScriptManager); 7 | link l; 8 | linkkind lkFlavor = (pszFlavor) ? pLTS->LinkKindNamed(pszFlavor) : 0; 9 | pLS->GetOne(l,lkFlavor, iSource, iDest); 10 | if (l == 0) 11 | return 0; 12 | if (l && pResult) 13 | pLTS->LinkGet(l, *pResult); 14 | return l; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetOneLinkByData.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | #ifdef __BORLANDC__ 6 | #define strnicmp std::strnicmp 7 | #endif 8 | 9 | using namespace std; 10 | 11 | long GetOneLinkByData(const char* pszFlavor, int iSource, int iDest, sLink* pResult, const void* pvData, int iDataLen) 12 | { 13 | SService pLS(g_pScriptManager); 14 | SService pLTS(g_pScriptManager); 15 | 16 | int (__cdecl *cmp)(const void*, const void*, size_t) = memcmp; 17 | if (pvData && iDataLen == -1) 18 | { 19 | iDataLen = strlen(reinterpret_cast(pvData)) + 1; 20 | cmp = reinterpret_cast(strnicmp); 21 | } 22 | 23 | linkset lsLinks; 24 | linkkind lkFlavor = (pszFlavor) ? pLTS->LinkKindNamed(pszFlavor) : 0; 25 | pLS->GetAll(lsLinks, lkFlavor, iSource, iDest); 26 | long iLinkID = 0; 27 | for (; lsLinks.AnyLinksLeft(); lsLinks.NextLink()) 28 | { 29 | void* pLinkData = lsLinks.Data(); 30 | if (pvData) 31 | { 32 | if (!pLinkData) 33 | continue; 34 | if ((*cmp)(pvData, pLinkData, iDataLen)) 35 | continue; 36 | } 37 | else 38 | { 39 | if (pLinkData && *reinterpret_cast(pLinkData)) 40 | continue; 41 | } 42 | iLinkID = lsLinks.Link(); 43 | if (pResult) 44 | lsLinks.query->Link(pResult); 45 | } 46 | return iLinkID; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetOneLinkByDataDest.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | int GetOneLinkByDataDest(const char* pszFlavor, int iSource, const void* pvData, int iDataLen) 4 | { 5 | sLink sl; 6 | if (GetOneLinkByData(pszFlavor, iSource, 0, &sl, pvData, iDataLen)) 7 | return sl.dest; 8 | return 0; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetOneLinkByDataInheritedSrc.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | #include 3 | 4 | #include 5 | 6 | #ifdef __BORLANDC__ 7 | #define strnicmp std::strnicmp 8 | #endif 9 | 10 | using namespace std; 11 | 12 | long GetOneLinkByDataInheritedSrc(const char* pszFlavor, int iSource, int iDest, sLink* pResult, const void* pvData, int iDataLen) 13 | { 14 | SInterface pTM(g_pScriptManager); 15 | SInterface pLM(g_pScriptManager); 16 | SInterface pRel; 17 | pRel = pLM->GetRelationNamed(pszFlavor); 18 | if (!pRel) 19 | return 0; 20 | SInterface pTree; 21 | pTree = pTM->Query(iSource, kTraitQueryMetaProps | kTraitQueryFull); 22 | if (!pTree) 23 | return 0; 24 | 25 | int (__cdecl *cmp)(const void*, const void*, size_t) = memcmp; 26 | if (pvData && iDataLen == -1) 27 | { 28 | iDataLen = strlen(reinterpret_cast(pvData)) + 1; 29 | cmp = reinterpret_cast(strnicmp); 30 | } 31 | 32 | long iLinkID = 0; 33 | for (; ! pTree->Done(); pTree->Next()) 34 | { 35 | if (pRel->AnyLinks(pTree->Object(), iDest)) 36 | { 37 | ILinkQuery* pLQ = pRel->Query(pTree->Object(), iDest); 38 | for (; ! pLQ->Done(); pLQ->Next()) 39 | { 40 | void* pLinkData = pLQ->Data(); 41 | if (pvData) 42 | { 43 | if (pLinkData && !(*cmp)(pvData, pLinkData, iDataLen)) 44 | { 45 | iLinkID = pLQ->ID(); 46 | if (pResult) 47 | pLQ->Link(pResult); 48 | break; 49 | } 50 | } 51 | else 52 | { 53 | if (!pLinkData || !*reinterpret_cast(pLinkData)) 54 | { 55 | iLinkID = pLQ->ID(); 56 | if (pResult) 57 | pLQ->Link(pResult); 58 | break; 59 | } 60 | } 61 | } 62 | pLQ->Release(); 63 | if (iLinkID != 0) 64 | break; 65 | } 66 | } 67 | return iLinkID; 68 | } 69 | 70 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetOneLinkDest.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | int GetOneLinkDest(const char* pszFlavor, int iSource) 4 | { 5 | SService pLS(g_pScriptManager); 6 | SService pLTS(g_pScriptManager); 7 | link l; 8 | linkkind lkFlavor = (pszFlavor) ? pLTS->LinkKindNamed(pszFlavor) : 0; 9 | pLS->GetOne(l,lkFlavor, iSource, 0); 10 | if (l == 0) 11 | return 0; 12 | sLink sl; 13 | pLTS->LinkGet(l, sl); 14 | return sl.dest; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetOneLinkInheritedSrc.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | #include 3 | 4 | long GetOneLinkInheritedSrc(const char* pszFlavor, int iSource, int iDest, sLink* pResult) 5 | { 6 | SInterface pTM(g_pScriptManager); 7 | SInterface pLM(g_pScriptManager); 8 | SInterface pRel; 9 | pRel = pLM->GetRelationNamed(pszFlavor); 10 | if (!pRel) 11 | return 0; 12 | 13 | long iLinkID = 0; 14 | SInterface pTree; 15 | pTree = pTM->Query(iSource, kTraitQueryMetaProps | kTraitQueryFull); 16 | if (!pTree) 17 | return 0; 18 | 19 | for (; ! pTree->Done(); pTree->Next()) 20 | { 21 | if (pRel->AnyLinks(pTree->Object(), iDest)) 22 | { 23 | ILinkQuery* pLQ = pRel->Query(pTree->Object(), iDest); 24 | iLinkID = pLQ->ID(); 25 | pLQ->Release(); 26 | break; 27 | } 28 | } 29 | 30 | if (iLinkID && pResult) 31 | pLM->Get(iLinkID, pResult); 32 | return iLinkID; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetParamBool.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | extern const char* g_pszParamDelim; 10 | extern const char* g_pszQuotes; 11 | 12 | bool GetParamBool(const char* pszString, const char* pszParam) 13 | { 14 | if (!pszString || !pszParam) 15 | return 0; 16 | bool bRet = false; 17 | #ifndef _MSC_VER 18 | char szTemp[strlen(pszString) + 1]; 19 | #else 20 | char *szTemp = (char*)alloca(strlen(pszString) + 1); 21 | #endif 22 | strcpy(szTemp, pszString); 23 | char* pszSep, *pszToken; 24 | for (pszSep = szTemp, pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes); 25 | pszToken; pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes)) 26 | { 27 | while (isspace(*pszToken)) ++pszToken; 28 | char* pszStart = strchr(pszToken, '='); 29 | if (pszStart) 30 | *pszStart++ = '\0'; 31 | if (!stricmp(pszToken, pszParam)) 32 | { 33 | if (!pszStart) 34 | break; 35 | while (isspace(*pszStart)) ++pszStart; 36 | char* pszEnd = pszStart + strlen(pszStart); 37 | if (*pszStart == '\"' || *pszStart == '\'') 38 | { 39 | if (*(pszEnd-1) == *pszStart) 40 | *(--pszEnd) = '\0'; 41 | ++pszStart; 42 | } 43 | switch (*pszStart) 44 | { 45 | case '1': case 't': case 'T': case 'y': case 'Y': 46 | bRet = true; 47 | break; 48 | case '$': 49 | { 50 | ++pszStart; 51 | if (pszEnd > pszStart) 52 | { 53 | SService pQS(g_pScriptManager); 54 | if (pQS->Exists(pszStart)) 55 | bRet = pQS->Get(pszStart); 56 | } 57 | break; 58 | } 59 | default: 60 | bRet = strtol(pszStart, NULL, 0); 61 | break; 62 | } 63 | break; 64 | } 65 | } 66 | return bRet; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetParamFloat.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | extern const char* g_pszParamDelim; 10 | extern const char* g_pszQuotes; 11 | 12 | float GetParamFloat(const char* pszString, const char* pszParam) 13 | { 14 | if (!pszString || !pszParam) 15 | return 0; 16 | float fRet = 0; 17 | #ifndef _MSC_VER 18 | char szTemp[strlen(pszString) + 1]; 19 | #else 20 | char *szTemp = (char*)alloca(strlen(pszString) + 1); 21 | #endif 22 | strcpy(szTemp, pszString); 23 | char* pszSep, *pszToken; 24 | for (pszSep = szTemp, pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes); 25 | pszToken; pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes)) 26 | { 27 | while (isspace(*pszToken)) ++pszToken; 28 | char* pszStart = strchr(pszToken, '='); 29 | if (pszStart) 30 | *pszStart++ = '\0'; 31 | if (!stricmp(pszToken, pszParam)) 32 | { 33 | if (!pszStart) 34 | break; 35 | while (isspace(*pszStart)) ++pszStart; 36 | if (*pszStart == '\"' || *pszStart == '\'') 37 | ++pszStart; 38 | fRet = strtod(pszStart, NULL); 39 | break; 40 | } 41 | } 42 | return fRet; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetParamInt.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | extern const char* g_pszParamDelim; 10 | extern const char* g_pszQuotes; 11 | 12 | int GetParamInt(const char* pszString, const char* pszParam) 13 | { 14 | if (!pszString || !pszParam) 15 | return 0; 16 | int iRet = 0; 17 | #ifndef _MSC_VER 18 | char szTemp[strlen(pszString) + 1]; 19 | #else 20 | char *szTemp = (char*)alloca(strlen(pszString) + 1); 21 | #endif 22 | strcpy(szTemp, pszString); 23 | char* pszSep, *pszToken; 24 | for (pszSep = szTemp, pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes); 25 | pszToken; pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes)) 26 | { 27 | while (isspace(*pszToken)) ++pszToken; 28 | char* pszStart = strchr(pszToken, '='); 29 | if (pszStart) 30 | *pszStart++ = '\0'; 31 | if (!stricmp(pszToken, pszParam)) 32 | { 33 | if (!pszStart) 34 | break; 35 | while (isspace(*pszStart)) ++pszStart; 36 | char* pszEnd = pszStart + strlen(pszStart); 37 | if (*pszStart == '\"' || *pszStart == '\'') 38 | { 39 | if (*(pszEnd-1) == *pszStart) 40 | *(--pszEnd) = '\0'; 41 | ++pszStart; 42 | } 43 | if (*pszStart == '$') 44 | { 45 | ++pszStart; 46 | if (pszEnd > pszStart) 47 | { 48 | SService pQS(g_pScriptManager); 49 | if (pQS->Exists(pszStart)) 50 | iRet = pQS->Get(pszStart); 51 | } 52 | } 53 | else 54 | { 55 | iRet = strtol(pszStart, NULL, 0); 56 | } 57 | break; 58 | } 59 | } 60 | return iRet; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetParamObject.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | extern const char* g_pszParamDelim; 8 | extern const char* g_pszQuotes; 9 | 10 | int GetParamObject(const char* pszString, const char* pszParam) 11 | { 12 | if (!pszString || !pszParam) 13 | return 0; 14 | char* pszRet = NULL; 15 | #ifndef _MSC_VER 16 | char szTemp[strlen(pszString) + 1]; 17 | #else 18 | char *szTemp = (char*)alloca(strlen(pszString) + 1); 19 | #endif 20 | strcpy(szTemp, pszString); 21 | char* pszSep, *pszToken; 22 | for (pszSep = szTemp, pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes); 23 | pszToken; pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes)) 24 | { 25 | while (isspace(*pszToken)) ++pszToken; 26 | char* pszStart = strchr(pszToken, '='); 27 | if (pszStart) 28 | *pszStart++ = '\0'; 29 | if (!stricmp(pszToken, pszParam)) 30 | { 31 | if (!pszStart) 32 | break; 33 | while (isspace(*pszStart)) ++pszStart; 34 | char* pszEnd; 35 | if (*pszStart == '\"') 36 | { 37 | ++pszStart; 38 | pszEnd = strrchr(pszStart, '\"'); 39 | if (!pszEnd) 40 | pszEnd = pszStart + strlen(pszStart); 41 | } 42 | else if (*pszStart == '\'') 43 | { 44 | ++pszStart; 45 | pszEnd = strrchr(pszStart, '\''); 46 | if (!pszEnd) 47 | pszEnd = pszStart + strlen(pszStart); 48 | } 49 | else 50 | pszEnd = pszStart + strlen(pszStart); 51 | int iLen = pszEnd - pszStart; 52 | pszRet = pszStart; 53 | pszRet[iLen] = '\0'; 54 | break; 55 | } 56 | } 57 | int iRet = StrToObject(pszRet); 58 | return iRet; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetParamString.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | extern const char* g_pszParamDelim; 9 | extern const char* g_pszQuotes; 10 | 11 | char* GetParamString(const char* pszString, const char* pszParam) 12 | { 13 | if (!pszString || !pszParam) 14 | return NULL; 15 | char* pszRet = NULL; 16 | #ifndef _MSC_VER 17 | char szTemp[strlen(pszString) + 1]; 18 | #else 19 | char *szTemp = (char*)alloca(strlen(pszString) + 1); 20 | #endif 21 | strcpy(szTemp, pszString); 22 | char* pszSep, *pszToken; 23 | for (pszSep = szTemp, pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes); 24 | pszToken; pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes)) 25 | { 26 | while (isspace(*pszToken)) ++pszToken; 27 | char* pszStart = strchr(pszToken, '='); 28 | if (pszStart) 29 | *pszStart++ = '\0'; 30 | if (!stricmp(pszToken, pszParam)) 31 | { 32 | if (!pszStart) 33 | break; 34 | while (isspace(*pszStart)) ++pszStart; 35 | char* pszEnd; 36 | if (*pszStart == '\"') 37 | { 38 | ++pszStart; 39 | pszEnd = strrchr(pszStart, '\"'); 40 | if (!pszEnd) 41 | pszEnd = pszStart + strlen(pszStart); 42 | } 43 | else if (*pszStart == '\'') 44 | { 45 | ++pszStart; 46 | pszEnd = strrchr(pszStart, '\''); 47 | if (!pszEnd) 48 | pszEnd = pszStart + strlen(pszStart); 49 | } 50 | else 51 | pszEnd = pszStart + strlen(pszStart); 52 | int iLen = pszEnd - pszStart; 53 | pszRet = reinterpret_cast(g_pMalloc->Alloc(iLen + 1)); 54 | if (pszRet) 55 | { 56 | strncpy(pszRet, pszStart, iLen); 57 | pszRet[iLen] = '\0'; 58 | } 59 | break; 60 | } 61 | } 62 | return pszRet; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GetParamTime.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | extern const char* g_pszParamDelim; 9 | extern const char* g_pszQuotes; 10 | 11 | int GetParamTime(const char* pszString, const char* pszParam) 12 | { 13 | if (!pszString || !pszParam) 14 | return 0; 15 | int iRet = 0; 16 | #ifndef _MSC_VER 17 | char szTemp[strlen(pszString) + 1]; 18 | #else 19 | char *szTemp = (char*)alloca(strlen(pszString) + 1); 20 | #endif 21 | strcpy(szTemp, pszString); 22 | char* pszSep, *pszToken; 23 | for (pszSep = szTemp, pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes); 24 | pszToken; pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes)) 25 | { 26 | while (isspace(*pszToken)) ++pszToken; 27 | char* pszStart = strchr(pszToken, '='); 28 | if (pszStart) 29 | *pszStart++ = '\0'; 30 | if (!stricmp(pszToken, pszParam)) 31 | { 32 | if (!pszStart) 33 | break; 34 | while (isspace(*pszStart)) ++pszStart; 35 | char* pszEnd = pszStart + strlen(pszStart); 36 | if (*pszStart == '\"' || *pszStart == '\'') 37 | { 38 | if (*(pszEnd-1) == *pszStart) 39 | *(--pszEnd) = '\0'; 40 | ++pszStart; 41 | } 42 | if (*pszStart == '$') 43 | { 44 | ++pszStart; 45 | if (pszEnd > pszStart) 46 | { 47 | SService pQS(g_pScriptManager); 48 | if (pQS->Exists(pszStart)) 49 | iRet = pQS->Get(pszStart); 50 | } 51 | } 52 | else 53 | { 54 | iRet = strtotime(pszStart); 55 | } 56 | break; 57 | } 58 | } 59 | return iRet; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/GlobalParamCache.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | #include "ParamCache.h" 3 | 4 | #ifdef DEBUG_PARAMCACHE 5 | extern int (__cdecl *g_pfnMPrintf)(const char*,...); 6 | #endif 7 | 8 | cParamCache* g_pGlobalParamCache = NULL; 9 | 10 | void InitParamCache(void) 11 | { 12 | delete g_pGlobalParamCache; 13 | g_pGlobalParamCache = new cParamCache(g_pScriptManager); 14 | #ifdef DEBUG_PARAMCACHE 15 | g_pGlobalParamCache->SetDebug(g_pfnMPrintf); 16 | #endif 17 | } 18 | 19 | void ReleaseParamCache(void) 20 | { 21 | delete g_pGlobalParamCache; 22 | g_pGlobalParamCache = NULL; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/HexTable.cpp: -------------------------------------------------------------------------------- 1 | extern const char g_cHexTable[256] = { 2 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 4 | 0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 5 | 0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 6 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 7 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 8 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 9 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 10 | }; 11 | 12 | extern const char g_cHexChars[16] = { 13 | '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' 14 | }; 15 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/IterateLinks.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | long IterateLinks(const char* pszFlavor, int iSource, int iDest, 4 | LinkIterCallbackFunc pfnLinkIterCallback, IScript* pScript, void* pData) 5 | { 6 | SService pLS(g_pScriptManager); 7 | SService pLTS(g_pScriptManager); 8 | 9 | linkset lsLinks; 10 | linkkind lkFlavor = (pszFlavor) ? pLTS->LinkKindNamed(pszFlavor) : 0; 11 | pLS->GetAll(lsLinks, lkFlavor, iSource, iDest); 12 | long iCount = 0; 13 | for (; lsLinks.AnyLinksLeft(); lsLinks.NextLink()) 14 | { 15 | ++iCount; 16 | if (pfnLinkIterCallback && !pfnLinkIterCallback(pLS, lsLinks.query, pScript, pData)) 17 | break; 18 | } 19 | return iCount; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/IterateLinksByData.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | #ifdef __BORLANDC__ 6 | #define strnicmp std::strnicmp 7 | #endif 8 | 9 | using namespace std; 10 | 11 | long IterateLinksByData(const char* pszFlavor, int iSource, int iDest, 12 | const void* pvFilter, int iFilterLen, 13 | LinkIterCallbackFunc pfnLinkIterCallback, IScript* pScript, void* pData) 14 | { 15 | SService pLS(g_pScriptManager); 16 | SService pLTS(g_pScriptManager); 17 | 18 | int (__cdecl *cmp)(const void*, const void*, size_t) = memcmp; 19 | if (pvFilter && iFilterLen == -1) 20 | { 21 | iFilterLen = strlen(reinterpret_cast(pvFilter)) + 1; 22 | cmp = reinterpret_cast(strnicmp); 23 | } 24 | 25 | linkset lsLinks; 26 | linkkind lkFlavor = (pszFlavor) ? pLTS->LinkKindNamed(pszFlavor) : 0; 27 | pLS->GetAll(lsLinks, lkFlavor, iSource, iDest); 28 | long iCount = 0; 29 | for (; lsLinks.AnyLinksLeft(); lsLinks.NextLink()) 30 | { 31 | void* pLinkData = lsLinks.Data(); 32 | if (pvFilter) 33 | { 34 | if (!pLinkData) 35 | continue; 36 | if ((*cmp)(pvFilter, pLinkData, iFilterLen)) 37 | continue; 38 | } 39 | else 40 | { 41 | if (pLinkData && *reinterpret_cast(pLinkData)) 42 | continue; 43 | } 44 | ++iCount; 45 | if (pfnLinkIterCallback && !pfnLinkIterCallback(pLS, lsLinks.query, pScript, pData)) 46 | break; 47 | } 48 | return iCount; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/MultiParmAssignFloat.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | void MultiParmAssignFloat(sMultiParm* pParm, float fValue) 4 | { 5 | if (pParm->type == kMT_String || pParm->type == kMT_Vector) 6 | { 7 | g_pMalloc->Free(pParm->psz); 8 | } 9 | pParm->type = kMT_Float; 10 | pParm->f = fValue; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/MultiParmAssignInt.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | void MultiParmAssignInt(sMultiParm* pParm, int iValue) 4 | { 5 | if (pParm->type == kMT_String || pParm->type == kMT_Vector) 6 | { 7 | g_pMalloc->Free(pParm->psz); 8 | } 9 | pParm->type = kMT_Int; 10 | pParm->i = iValue; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/MultiParmAssignString.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | void MultiParmAssignString(sMultiParm* pParm, const char* pszValue) 8 | { 9 | if (pParm->type == kMT_String || pParm->type == kMT_Vector) 10 | { 11 | g_pMalloc->Free(pParm->psz); 12 | pParm->type = kMT_Undef; 13 | } 14 | pParm->psz = reinterpret_cast(g_pMalloc->Alloc(strlen(pszValue) + 1)); 15 | if (pParm->psz) 16 | { 17 | strcpy(pParm->psz, pszValue); 18 | pParm->type = kMT_String; 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/MultiParmAssignVector.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | void MultiParmAssignVector(sMultiParm* pParm, const mxs_vector* pvValue) 8 | { 9 | if (pParm->type == kMT_String || pParm->type == kMT_Vector) 10 | { 11 | g_pMalloc->Free(pParm->psz); 12 | pParm->type = kMT_Undef; 13 | } 14 | pParm->pVector = reinterpret_cast(g_pMalloc->Alloc(sizeof(mxs_vector))); 15 | if (pParm->pVector) 16 | { 17 | memcpy(pParm->pVector, pvValue, sizeof(mxs_vector)); 18 | pParm->type = kMT_Vector; 19 | } 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamExists.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | 3 | extern cParamCache* g_pGlobalParamCache; 4 | 5 | bool ParamExists(int iObject, const char* pszParam) 6 | { 7 | if (!g_pGlobalParamCache) 8 | return false; 9 | return (g_pGlobalParamCache->Retrieve(iObject, pszParam) != NULL); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamExistsDirect.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | 3 | extern cParamCache* g_pGlobalParamCache; 4 | 5 | bool ParamExistsDirect(int iObject, const char* pszParam) 6 | { 7 | if (!g_pGlobalParamCache) 8 | return false; 9 | return (g_pGlobalParamCache->RetrieveSingle(iObject, pszParam) != NULL); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamGetBool.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | #include "ScriptLib.h" 3 | #include 4 | 5 | #include 6 | 7 | using namespace std; 8 | 9 | extern cParamCache* g_pGlobalParamCache; 10 | 11 | bool ParamGetBool(int iObject, const char* pszParam, bool bDefault) 12 | { 13 | if (!g_pGlobalParamCache) 14 | return bDefault; 15 | const string* psParam = g_pGlobalParamCache->Retrieve(iObject, pszParam); 16 | if (!psParam) 17 | return bDefault; 18 | if (psParam->size() == 0) 19 | return false; 20 | switch (psParam->at(0)) 21 | { 22 | case '1': case 't': case 'T': case 'y': case 'Y': 23 | return true; 24 | case '$': 25 | { 26 | const char* psz = psParam->c_str()+1; 27 | SService pQS(g_pScriptManager); 28 | if (pQS->Exists(psz)) 29 | return pQS->Get(psz); 30 | break; 31 | } 32 | default: 33 | return strtol(psParam->c_str(), NULL, 0); 34 | } 35 | return bDefault; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamGetFloat.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | #include "ScriptLib.h" 3 | #include 4 | 5 | #include 6 | 7 | using namespace std; 8 | 9 | extern cParamCache* g_pGlobalParamCache; 10 | 11 | float ParamGetFloat(int iObject, const char* pszParam, float fDefault) 12 | { 13 | if (!g_pGlobalParamCache) 14 | return fDefault; 15 | const string* psParam = g_pGlobalParamCache->Retrieve(iObject, pszParam); 16 | if (!psParam) 17 | return fDefault; 18 | if (psParam->size() == 0) 19 | return 0.0f; 20 | if (psParam->at(0) == '$') 21 | { 22 | const char* psz = psParam->c_str()+1; 23 | SService pQS(g_pScriptManager); 24 | if (pQS->Exists(psz)) 25 | return (float)(pQS->Get(psz)); 26 | } 27 | else 28 | { 29 | return strtof(psParam->c_str(), NULL); 30 | } 31 | return fDefault; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamGetInt.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | #include "ScriptLib.h" 3 | #include 4 | 5 | #include 6 | 7 | using namespace std; 8 | 9 | extern cParamCache* g_pGlobalParamCache; 10 | 11 | int ParamGetInt(int iObject, const char* pszParam, int iDefault) 12 | { 13 | if (!g_pGlobalParamCache) 14 | return iDefault; 15 | const string* psParam = g_pGlobalParamCache->Retrieve(iObject, pszParam); 16 | if (!psParam) 17 | return iDefault; 18 | if (psParam->size() == 0) 19 | return 0; 20 | if (psParam->at(0) == '$') 21 | { 22 | const char* psz = psParam->c_str()+1; 23 | SService pQS(g_pScriptManager); 24 | if (pQS->Exists(psz)) 25 | return pQS->Get(psz); 26 | } 27 | else 28 | { 29 | return strtol(psParam->c_str(), NULL, 0); 30 | } 31 | return iDefault; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamGetObject.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | #include "ScriptLib.h" 3 | 4 | using namespace std; 5 | 6 | extern cParamCache* g_pGlobalParamCache; 7 | 8 | int ParamGetObject(int iObject, const char* pszParam, int iDefault) 9 | { 10 | if (!g_pGlobalParamCache) 11 | return iDefault; 12 | const string* psParam = g_pGlobalParamCache->Retrieve(iObject, pszParam); 13 | if (!psParam) 14 | return iDefault; 15 | return StrToObject(psParam->c_str()); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamGetString.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | 3 | using namespace std; 4 | 5 | extern cParamCache* g_pGlobalParamCache; 6 | 7 | const char* ParamGetString(int iObject, const char* pszParam, const char* pszDefault) 8 | { 9 | if (!g_pGlobalParamCache) 10 | return pszDefault; 11 | const string* psParam = g_pGlobalParamCache->Retrieve(iObject, pszParam); 12 | if (!psParam) 13 | return pszDefault; 14 | return psParam->c_str(); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamGetTime.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | #include "ScriptLib.h" 3 | #include 4 | 5 | using namespace std; 6 | 7 | extern cParamCache* g_pGlobalParamCache; 8 | 9 | int ParamGetTime(int iObject, const char* pszParam, int iDefault) 10 | { 11 | if (!g_pGlobalParamCache) 12 | return iDefault; 13 | const string* psParam = g_pGlobalParamCache->Retrieve(iObject, pszParam); 14 | if (!psParam) 15 | return iDefault; 16 | if (psParam->size() == 0) 17 | return 0; 18 | if (psParam->at(0) == '$') 19 | { 20 | const char* psz = psParam->c_str()+1; 21 | SService pQS(g_pScriptManager); 22 | if (pQS->Exists(psz)) 23 | return pQS->Get(psz); 24 | } 25 | else 26 | { 27 | return strtotime(psParam->c_str()); 28 | } 29 | return iDefault; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamRemove.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | 3 | extern cParamCache* g_pGlobalParamCache; 4 | 5 | void ParamRemove(int iObject, const char* pszParam, bool bNoInherit) 6 | { 7 | if (!g_pGlobalParamCache) 8 | return; 9 | if (bNoInherit) 10 | g_pGlobalParamCache->Update(iObject, pszParam, NULL); 11 | else 12 | g_pGlobalParamCache->Remove(iObject, pszParam); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamSetBool.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | 3 | extern cParamCache* g_pGlobalParamCache; 4 | 5 | void ParamSetBool(int iObject, const char* pszParam, bool bValue) 6 | { 7 | if (!g_pGlobalParamCache) 8 | return; 9 | std::string sVal(bValue ? "true" : "false"); 10 | g_pGlobalParamCache->Update(iObject, pszParam, &sVal); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamSetFloat.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | 3 | #include 4 | 5 | extern cParamCache* g_pGlobalParamCache; 6 | 7 | void ParamSetFloat(int iObject, const char* pszParam, float fValue) 8 | { 9 | if (!g_pGlobalParamCache) 10 | return; 11 | char psz[44]; 12 | std::string sVal(psz, sprintf(psz, "%0.2f", fValue)); 13 | g_pGlobalParamCache->Update(iObject, pszParam, &sVal); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamSetInt.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | 3 | #include 4 | 5 | extern cParamCache* g_pGlobalParamCache; 6 | 7 | void ParamSetInt(int iObject, const char* pszParam, int iValue) 8 | { 9 | if (!g_pGlobalParamCache) 10 | return; 11 | char psz[12]; 12 | std::string sVal(psz, sprintf(psz, "%d", iValue)); 13 | g_pGlobalParamCache->Update(iObject, pszParam, &sVal); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ParamSetString.cpp: -------------------------------------------------------------------------------- 1 | #include "ParamCache.h" 2 | 3 | extern cParamCache* g_pGlobalParamCache; 4 | 5 | void ParamSetString(int iObject, const char* pszParam, const char* pszValue) 6 | { 7 | if (!g_pGlobalParamCache) 8 | return; 9 | std::string sVal; 10 | if (pszValue) 11 | sVal = pszValue; 12 | g_pGlobalParamCache->Update(iObject, pszParam, &sVal); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/RemoveMetaProperty.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | int RemoveMetaProperty(const char* pszMetaProp, int iObjId) 4 | { 5 | SService pOS(g_pScriptManager); 6 | object oMetaProp; 7 | pOS->Named(oMetaProp, pszMetaProp); 8 | if (oMetaProp != 0) 9 | return pOS->RemoveMetaProperty(iObjId, oMetaProp); 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/RemoveObjectParam.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | extern const char* g_pszParamDelim; 9 | extern const char* g_pszQuotes; 10 | 11 | int RemoveObjectParam(int iObject, const char* pszParam) 12 | { 13 | char* pszString = GetObjectParams(iObject); 14 | if (!pszString) 15 | return 0; 16 | #ifndef _MSC_VER 17 | char szNew[strlen(pszString) + 1]; 18 | #else 19 | char *szNew = (char*)alloca(strlen(pszString) + 1); 20 | #endif 21 | *szNew = '\0'; 22 | char* pszSep, *pszToken; 23 | for (pszSep = pszString, pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes); 24 | pszToken; pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes)) 25 | { 26 | while (isspace(*pszToken)) ++pszToken; 27 | if (!*pszToken) 28 | continue; 29 | char* pszStart = strchr(pszToken, '='); 30 | if (pszStart) 31 | *pszStart++ = '\0'; 32 | if (stricmp(pszToken, pszParam)) 33 | { 34 | strcat(szNew, pszToken); 35 | if (pszStart) 36 | { 37 | strcat(szNew, "="); 38 | strcat(szNew, pszStart); 39 | } 40 | strcat(szNew, g_pszParamDelim); 41 | } 42 | } 43 | SetObjectParams(iObject, szNew); 44 | g_pMalloc->Free(pszString); 45 | return 0; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/RemoveSingleMetaProperty.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | static int DoRemoveMetaProperty(IObjectSrv* pOS, object oMetaProp, object oObject) 4 | { 5 | int iRet = 0; 6 | true_bool has_mp; 7 | pOS->HasMetaProperty(has_mp, oObject, oMetaProp); 8 | if (has_mp) 9 | { 10 | iRet = pOS->RemoveMetaProperty(oObject, oMetaProp); 11 | //pOS->HasMetaProperty(has_mp, oObject, oMetaProp); 12 | } 13 | return iRet; 14 | } 15 | 16 | int RemoveSingleMetaProperty(const char* pszMetaProp, int iObjId) 17 | { 18 | SService pOS(g_pScriptManager); 19 | object oMetaProp; 20 | pOS->Named(oMetaProp, pszMetaProp); 21 | if (oMetaProp != 0) 22 | return DoRemoveMetaProperty(pOS, oMetaProp, iObjId); 23 | return 0; 24 | } 25 | 26 | int RemoveSingleMetaProperty(int iMetaProp, int iObjId) 27 | { 28 | SService pOS(g_pScriptManager); 29 | return DoRemoveMetaProperty(pOS, iMetaProp, iObjId); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ScriptLib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | IMalloc* g_pMalloc; 6 | IScriptMan* g_pScriptManager; 7 | 8 | cMultiParm g_mpUndef; 9 | 10 | const char* g_pszDesignNote = 11 | #if (_DARKGAME == 3) 12 | "ObjList"; 13 | #else 14 | "DesignNote"; 15 | #endif 16 | 17 | const char* g_pszParamDelim = ";"; 18 | const char* g_pszQuotes = "\"'"; 19 | 20 | const char* g_pszCDLinkFlavor = 21 | #if (_DARKGAME == 3) 22 | "SwitchLink"; 23 | #else 24 | "ControlDevice"; 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SetObjectParamBool.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | int SetObjectParamBool(int iObject, const char* pszParam, bool bVal) 8 | { 9 | return SetObjectParamString(iObject, pszParam, (bVal) ? "true" : "false"); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SetObjectParamFloat.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | int SetObjectParamFloat(int iObject, const char* pszParam, float fVal) 8 | { 9 | char psz[44]; 10 | sprintf(psz, "%0.2f", fVal); 11 | return SetObjectParamString(iObject, pszParam, psz); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SetObjectParamInt.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | int SetObjectParamInt(int iObject, const char* pszParam, int iVal) 8 | { 9 | char psz[12]; 10 | sprintf(psz, "%d", iVal); 11 | return SetObjectParamString(iObject, pszParam, psz); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SetObjectParamString.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int SetObjectParamString(int iObject, const char* pszParam, const char* pszVal) 9 | { 10 | if (!pszParam || !pszVal) 11 | return 1; 12 | char* params = GetObjectParamsNoInherit(iObject); 13 | if (!params) 14 | { 15 | int iLen = 4 + strlen(pszParam) + strlen(pszVal); 16 | params = reinterpret_cast(g_pMalloc->Alloc(iLen + 1)); 17 | if (!params) 18 | return 1; 19 | sprintf(params, "%s=\"%s\"", pszParam, pszVal); 20 | } 21 | else 22 | { 23 | char* newparams = SetParamString(params, pszParam, pszVal); 24 | g_pMalloc->Free(params); 25 | params = newparams; 26 | } 27 | int iRet = 1; 28 | if (params) 29 | { 30 | iRet = SetObjectParams(iObject, params); 31 | g_pMalloc->Free(params); 32 | } 33 | return iRet; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SetObjectParams.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | int SetObjectParams(int iObject, const char* pszParams) 4 | { 5 | SService pPS(g_pScriptManager); 6 | cMultiParm mpDesignNote; 7 | mpDesignNote.Set(const_cast(pszParams)); 8 | pPS->Add(iObject, g_pszDesignNote); 9 | register int iRet = pPS->SetSimple(iObject, g_pszDesignNote, mpDesignNote); 10 | mpDesignNote.type = kMT_Undef; 11 | return iRet; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SetParamBool.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | char* SetParamBool(char* pszString, const char* pszParam, bool bVal) 8 | { 9 | return SetParamString(pszString, pszParam, (bVal) ? "true" : "false"); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SetParamFloat.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | char* SetParamFloat(char* pszString, const char* pszParam, float fVal) 8 | { 9 | char psz[44]; 10 | sprintf(psz, "%0.2f", fVal); 11 | return SetParamString(pszString, pszParam, psz); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SetParamInt.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | char* SetParamInt(char* pszString, const char* pszParam, int iVal) 8 | { 9 | char psz[12]; 10 | sprintf(psz, "%d", iVal); 11 | return SetParamString(pszString, pszParam, psz); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SetParamString.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | extern const char* g_pszParamDelim; 10 | extern const char* g_pszQuotes; 11 | 12 | char* SetParamString(char* pszString, const char* pszParam, const char* pszVal) 13 | { 14 | if (!pszString || !pszParam || !pszVal) 15 | return NULL; 16 | int iLen = 4 + strlen(pszString) + strlen(pszParam) + strlen(pszVal); 17 | char* pszNew = reinterpret_cast(g_pMalloc->Alloc(iLen + 1)); 18 | if (!pszNew) 19 | return NULL; 20 | sprintf(pszNew, "%s=\"%s\";", pszParam, pszVal); 21 | char* pszSep, *pszToken; 22 | for (pszSep = pszString, pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes); 23 | pszToken; pszToken = strqsep(&pszSep, g_pszParamDelim, g_pszQuotes)) 24 | { 25 | while (isspace(*pszToken)) ++pszToken; 26 | if (!*pszToken) 27 | continue; 28 | char* pszStart = strchr(pszToken, '='); 29 | if (pszStart) 30 | *pszStart++ = '\0'; 31 | if (stricmp(pszToken, pszParam)) 32 | { 33 | strcat(pszNew, pszToken); 34 | if (pszStart) 35 | { 36 | strcat(pszNew, "="); 37 | strcat(pszNew, pszStart); 38 | } 39 | strcat(pszNew, g_pszParamDelim); 40 | } 41 | } 42 | return pszNew; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ShowBook.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | int ShowBook(int iObject, bool bArt, int iTime) 8 | { 9 | SService pPS(g_pScriptManager); 10 | if (!pPS->Possessed(iObject, "Book")) 11 | return 1; 12 | cMultiParm mpBook, mpBookArt; 13 | pPS->Get(mpBook, iObject, "Book", NULL); 14 | if (!*mpBook.psz) 15 | { 16 | return 1; 17 | } 18 | SService pUI(g_pScriptManager); 19 | if (bArt && pPS->Possessed(iObject, "BookArt")) 20 | { 21 | pPS->Get(mpBookArt, iObject, "BookArt", NULL); 22 | pUI->ReadBook(mpBook, mpBookArt); 23 | } 24 | else 25 | { 26 | SService pDS(g_pScriptManager); 27 | #ifndef _MSC_VER 28 | char szBookFile[strlen(mpBook) + 10]; 29 | #else 30 | char *szBookFile = (char*)alloca(strlen(mpBook) + 10); 31 | #endif 32 | strcpy(szBookFile, "..\\books\\"); 33 | strcat(szBookFile, mpBook); 34 | cScrStr str; 35 | pDS->GetString(str, szBookFile, "page_0", "", "strings"); 36 | if (*static_cast(str)) 37 | { 38 | if (iTime == 0) 39 | iTime = CalcTextTime(str, 500); 40 | pUI->TextMessage(str, 0, iTime); 41 | } 42 | str.Free(); 43 | } 44 | return 0; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/ShowString.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | void ShowString(const char* pszStr, int iTime, COLORREF color) 4 | { 5 | #if (_DARKGAME == 3) 6 | SService pShock(g_pScriptManager); 7 | pShock->AddText(pszStr, 0, iTime); 8 | color = color; 9 | #else 10 | SService pUI(g_pScriptManager); 11 | pUI->TextMessage(pszStr, color, iTime); 12 | #endif 13 | return; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SimplePost.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | void SimplePost(int iSource, int iDest, const char* pszMessage, const cMultiParm& mpData1, const cMultiParm& mpData2, const cMultiParm& mpData3) 4 | { 5 | #if (_DARKGAME != 1) 6 | g_pScriptManager->PostMessage2(iSource, iDest, pszMessage, mpData1, mpData2, mpData3, 0L); 7 | #else 8 | g_pScriptManager->PostMessage2(iSource, iDest, pszMessage, mpData1, mpData2, mpData3); 9 | #endif 10 | } 11 | 12 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/SimpleSend.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | void SimpleSend(int iSource, int iDest, const char* pszMessage, const cMultiParm& mpData1, const cMultiParm& mpData2, const cMultiParm& mpData3) 4 | { 5 | cMultiParm mpReply; 6 | g_pScriptManager->SendMessage2(mpReply, iSource, iDest, pszMessage, mpData1, mpData2, mpData3); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/StrToObject.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | 5 | using namespace std; 6 | 7 | int StrToObject(const char* pszName) 8 | { 9 | if (!pszName || !*pszName) 10 | return 0; 11 | SService pOS(g_pScriptManager); 12 | object obj = 0; 13 | pOS->Named(obj, pszName); 14 | if (obj == 0) 15 | { 16 | char *p = NULL; 17 | obj = strtol(pszName, &p, 10); 18 | //if (*p != '\0') 19 | // return 0; 20 | true_bool _p; 21 | if (! *pOS->Exists(_p, obj)) 22 | return 0; 23 | } 24 | return obj; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/strqsep.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | /* Seperate a string on any of delim characters while preserving 6 | * substrings surrounded by an equal pair of any of quotes characters. 7 | * str is the address of a pointer to the string to be seperated. 8 | * The pointer to the next token in the string, or NULL, is copied to 9 | * the address and the the value that was passed in *str is returned. 10 | * delim and quotes cannot be NULL. 11 | * Empty tokens will be returned. 12 | * Like strtok and strsep, the string data will be modified. 13 | * str, of course, must be an lvalue. 14 | */ 15 | char* strqsep(char** str, const char* delim, const char* quotes) 16 | { 17 | char dtable[256]; 18 | char qtable[256]; 19 | register char* p = *str; 20 | if (!p) return NULL; 21 | memset(dtable,0,sizeof(dtable)); 22 | memset(qtable,0,sizeof(dtable)); 23 | { 24 | register const unsigned char* d = reinterpret_cast(delim); 25 | while (*d) 26 | dtable[*d++] = 0xFF; 27 | } 28 | { 29 | register const unsigned char* q = reinterpret_cast(quotes); 30 | while (*q) 31 | qtable[*q++] = 0xFF; 32 | } 33 | while (*p) 34 | { 35 | if (qtable[*reinterpret_cast(p)]) 36 | { 37 | register char* t = p; 38 | do 39 | { 40 | t = strchr(t+1, *p); 41 | if (!t) 42 | { 43 | p = *str; 44 | *str = NULL; 45 | return p; 46 | } 47 | } 48 | while (*(t-1) == '\\'); 49 | p = t; 50 | } 51 | else if (dtable[*reinterpret_cast(p)]) 52 | { 53 | register char* t = *str; 54 | *p++ = '\0'; 55 | *str = p; 56 | return t; 57 | } 58 | ++p; 59 | } 60 | p = *str; 61 | *str = NULL; 62 | return p; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/strsep.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | char* strsep(char** str, const char* delim) 6 | { 7 | char dtable[256]; 8 | register char* p = *str; 9 | if (!p) return NULL; 10 | memset(dtable,0,sizeof(dtable)); 11 | { 12 | register const unsigned char* d = reinterpret_cast(delim); 13 | while (*d) 14 | dtable[*d++] = 0xFF; 15 | } 16 | while (*p) 17 | { 18 | if (dtable[*reinterpret_cast(p)]) 19 | { 20 | register char* t = *str; 21 | *p++ = '\0'; 22 | *str = p; 23 | return t; 24 | } 25 | ++p; 26 | } 27 | p = *str; 28 | *str = NULL; 29 | return p; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/strtocolor.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptLib.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | typedef struct colorname_ 9 | { 10 | const char* n; 11 | unsigned long c; 12 | } colorname; 13 | static const colorname g_sColorNames[] = { 14 | { "black", 0x000000 }, 15 | { "silver", 0xC0C0C0 }, 16 | { "gray", 0x808080 }, 17 | { "grey", 0x808080 }, 18 | { "white", 0xFFFFFF }, 19 | { "maroon", 0x000080 }, 20 | { "red", 0x0000FF }, 21 | { "purple", 0x800080 }, 22 | { "fuchsia", 0xFF00FF }, 23 | { "green", 0x008000 }, 24 | { "lime", 0x00FF00 }, 25 | { "olive", 0x008080 }, 26 | { "yellow", 0x00FFFF }, 27 | { "navy", 0x800000 }, 28 | { "blue", 0xFF0000 }, 29 | { "teal", 0x808000 }, 30 | { "aqua", 0xFFFF00 } 31 | }; 32 | 33 | int strtocolor(const char* str) 34 | { 35 | register char* c = const_cast(str); 36 | if (*c == '#') 37 | { 38 | if (strlen(++c) < 6) 39 | return 0; 40 | unsigned char r,g,b; 41 | r = hexbyte(c); 42 | c += 2; 43 | g = hexbyte(c); 44 | c += 2; 45 | b = hexbyte(c); 46 | return (r|(g<<8)|(b<<16)); 47 | } 48 | if (strchr(str, ',')) 49 | { 50 | unsigned int r,g,b; 51 | if (3 == sscanf(str, "%u , %u , %u", &r, &g, &b)) 52 | { 53 | return ((r&0xFF)|((g&0xFF)<<8)|((b&0xFF)<<16)); 54 | } 55 | } 56 | else 57 | { 58 | for (unsigned int n=0; n < sizeof(g_sColorNames)/sizeof(g_sColorNames[0]); ++n) 59 | { 60 | if (!stricmp(str,g_sColorNames[n].n)) 61 | return g_sColorNames[n].c; 62 | } 63 | } 64 | return 0; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /NVScript/ScriptLib/strtotime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int strtotime(const char* str) 6 | { 7 | char* end = NULL; 8 | int t = strtoul(str, &end, 10); 9 | if (t > 0 && end) 10 | { 11 | if ((*end | 0x20) == 'm') 12 | t *= 60000; 13 | else if ((*end | 0x20) == 's') 14 | t *= 1000; 15 | } 16 | return t; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /NVScript/ScriptModule.h: -------------------------------------------------------------------------------- 1 | #ifndef SCRIPTMODULE_H 2 | #define SCRIPTMODULE_H 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include "lg/script.h" 9 | #include "lg/scrmanagers.h" 10 | 11 | #include "ScrInstance.h" 12 | 13 | #define SCRIPTMODULE2 1 14 | 15 | 16 | class cScriptModule : public IScriptModule 17 | { 18 | private: 19 | typedef std::map InstanceList; 20 | 21 | public: 22 | // IUnknown 23 | STDMETHOD(QueryInterface)(REFIID,void**); 24 | STDMETHOD_(ULONG,AddRef)(void); 25 | STDMETHOD_(ULONG,Release)(void); 26 | // IScriptModule 27 | STDMETHOD_(const char*,GetName)(void); 28 | STDMETHOD_(const sScrClassDesc*,GetFirstClass)(tScrIter*); 29 | STDMETHOD_(const sScrClassDesc*,GetNextClass)(tScrIter*); 30 | STDMETHOD_(void,EndClassIter)(tScrIter*); 31 | 32 | private: 33 | long int m_iRef; 34 | 35 | public: 36 | virtual ~cScriptModule(); 37 | cScriptModule(); 38 | cScriptModule(const char* pszName); 39 | 40 | void SetName(const char* pszName); 41 | 42 | static IScript* __cdecl ScriptFactory(const char* pszName, int iHostObjId); 43 | 44 | void InitScriptDescs(); 45 | void DestroyScriptDescs(); 46 | 47 | protected: 48 | static void DeleteScriptInstance(const char* pszName, int iHostObjId, IScript* pScript); 49 | 50 | friend class cScript; 51 | 52 | private: 53 | const sScrClassDesc* GetScript(unsigned int i); 54 | 55 | char* m_pszName; 56 | 57 | static InstanceList m_InstanceList; 58 | }; 59 | 60 | extern cScriptModule g_ScriptModule; 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /NVScript/ScriptNV.cpp: -------------------------------------------------------------------------------- 1 | #include "ScriptNV.h" 2 | #include "ScriptLib.h" 3 | 4 | MSGHANDLER cScriptNV::cScriptNVInit(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace) 5 | { 6 | InitVars(); 7 | OnBeginScript(pMsg, pReply, eTrace); 8 | return 0; 9 | } 10 | 11 | long __stdcall cScriptNV::ReceiveMessage(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace) 12 | { 13 | 14 | long iRet = 1; 15 | try 16 | { 17 | iRet = cScript::ReceiveMessage(pMsg, pReply, eTrace); 18 | } 19 | catch (std::exception& err) 20 | { 21 | DebugString("Exception caught: \n", err.what()); 22 | } 23 | return iRet; 24 | } 25 | -------------------------------------------------------------------------------- /NVScript/ScriptNV.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef NVSCRIPTNV_H 3 | #define NVSCRIPTNV_H 4 | 5 | #include "Script.h" 6 | 7 | 8 | /* 9 | * Generic Script 10 | * 11 | */ 12 | class cScriptNV : public cScript 13 | { 14 | public: 15 | cScriptNV(const char* pszName, int iHostObjId) 16 | : cScript(pszName, iHostObjId) 17 | { } 18 | 19 | STDMETHOD_(long,ReceiveMessage)(sScrMsg*,sMultiParm*,eScrTraceAction); 20 | 21 | private: 22 | DECLARE_MSGHANDLER(cScriptNVInit); 23 | 24 | protected: 25 | virtual void InitScriptData() 26 | { 27 | cScript::InitScriptData(); 28 | REGISTER_MSGHANDLER("BeginScript",cScriptNV::cScriptNVInit); 29 | } 30 | 31 | virtual MSGHANDLER OnBeginScript(sScrMsg* pMsg, sMultiParm* pReply, eScrTraceAction eTrace) 32 | { 33 | return 0; 34 | } 35 | virtual void InitVars(void) 36 | { 37 | return; 38 | } 39 | }; 40 | 41 | #endif // NVSCRIPTNV_H 42 | -------------------------------------------------------------------------------- /NVScript/copyright.txt: -------------------------------------------------------------------------------- 1 | NVScript Copyright (c) 2024 Nameless Voice 2 | 3 | Based upon code from: 4 | tnhScript Copyright (c) 2003-2005 Tom N Harris 5 | All Rights Reserved. 6 | 7 | THIS SOFTWARE IS PRIVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED. NAMELESS VOICE WILL NOT BE LIABLE FOR ANY INCIDENTAL, SPECIAL, CONSEQUENTIAL OR ANY OTHER DAMAGES THAT MAY RESULT FROM THE USE OR INABILITY TO USE THIS SOFTWARE. 8 | YOU MAY NOT COMMERCIALLY EXPLOIT IT OR ITS OUTPUT IN ANY WAY UNDER ANY CIRCUMSTANCED. 9 | 10 | The script module "NVScript.osm" may be distributed with your fan missions as 11 | long as you do not charge for the mission, other than the cost of materials 12 | alone. You must include the above copyright notice and disclaimer in the 13 | description of your fan mission. You should replace the words 'THIS SOFTWARE' 14 | with 'NVSCRIPT.OSM'. 15 | 16 | I've included the source for my scripts for informational purposes. Most of the 17 | underlying architecture of the scripts was built by Telliamed, and much of the 18 | stuff in the lg directory was worked out by GayleSaver and Totality. Telliamed 19 | has also made quite a few contributions to improve the interfaces, all of which 20 | he offers unconditionally. But it's actually LGS's code there, we've just been 21 | reverse-engineering it. So there really isn't anyone claiming ownership of it, 22 | although it technically should belong to Eidos. But we don't think they're going 23 | to put up a fuss about it, so long as we play fair. Consider everything in that 24 | directory to be covered by the DromEd copyright agreement. 25 | 26 | Telliamed's Script and ScriptModule are based on well-known code that is common 27 | to all script modules, and he says you may use them in your own script modules. 28 | 29 | You may use any or all of NVScriptLib, NVGenericScript, or NVGenericTrigger 30 | in your own scripts. 31 | 32 | You may use the ideas and small pieces of code from NVScript, but don't just 33 | copy whole scripts and call them your own. 34 | 35 | Please do not distribute NVDebug.osm with a fan mission, unless you have a 36 | very good reason to do so. -------------------------------------------------------------------------------- /NVScript/genosm.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use strict; 4 | 5 | my $OSMName; 6 | my @Scripts; 7 | my %ScrCache; 8 | my %History; 9 | 10 | my $CC = 'g++-3'; 11 | my $CFlags = '-x c++ -P -w -mno-cygwin'; 12 | my $CDefines = '-DGENOSM'; 13 | 14 | sub process_file 15 | { 16 | my ($file,$fh,$ifile,$script); 17 | $file = shift or return; 18 | return if ($History{$file}); 19 | $History{$file} = 1; 20 | #open($fh,'<',$file) or die "blegh"; 21 | print STDERR "$CC $CFlags $CDefines -E $file \n"; 22 | open($fh, "$CC $CFlags $CDefines -E $file |") or die "blegh"; 23 | my $skip = 0; 24 | while (<$fh>) { 25 | my ($osm,$class,$name,$base); 26 | if ($skip) { 27 | if (s|^.*\*/||) { 28 | $skip = 0; 29 | } 30 | else { 31 | next; 32 | } 33 | # This is way too simplistic. Do write simple comments. 34 | } 35 | s|//.*$||; 36 | s|/\*.*\*/||; 37 | if (s|/\*.*$||) { 38 | $skip = 1; 39 | next; 40 | } 41 | if (($osm) = m|^\s*DECLARE_MODULE\(\s*(\w+)\s*\)|) { 42 | $OSMName = $osm if not $OSMName; 43 | } 44 | elsif (($class,$base) = m|^\s*DECLARE_SCRIPT\(\s*(\w+)\s*,\s*(\w+)\s*\)|) { 45 | if (not $ScrCache{$class}) { 46 | $script = { 'ClassName' => $class }; 47 | $script->{'ClassBase'} = $base; 48 | } 49 | } 50 | elsif (($name,undef,$base) = m|^\s*DECLARE_FACTORY\(\s*(\w+)\s*,\s*((\w+)\s*)?\)|) { 51 | if ($script) { 52 | $script->{'ScriptName'} = $name; 53 | $script->{'BaseName'} = $base || ""; 54 | #$Scripts{$script->{'ClassName'}} = $script; 55 | push(@Scripts,$script); 56 | $ScrCache{$script->{'ClassName'}} = 1; 57 | undef $script; 58 | } 59 | } 60 | elsif (($ifile) = m|^#include \"([-\.\w]+)\"|) { 61 | &process_file($ifile); 62 | } 63 | } 64 | close($fh); 65 | 66 | #@Scripts = sort {$a->{'ScriptName'} cmp $b->{'ScriptName'}} @Scripts; 67 | 68 | } 69 | 70 | sub output_header { 71 | my (@files,$includes,$ofile,$fh,$ofh); 72 | $ofile = shift or return; 73 | @files = @_; 74 | if ($ofile ne '--') { 75 | open($fh,">",$ofile) or die "damn"; 76 | binmode($fh); 77 | $ofh = select $fh; 78 | } 79 | 80 | $includes = ""; 81 | foreach my $f (@files) { 82 | $includes .= "#include \"$f\"\n"; 83 | } 84 | 85 | print <{'ClassName'},"::InitScriptDesc(sm_ScriptsArray+",$n,");\n"; 96 | print "\tsm_ScriptsArray[",$n,"].pszModule = m_pszName;\n" 97 | } 98 | print "\tsm_ScriptsArraySize = ",scalar(@Scripts),";\n}\n\n"; 99 | 100 | foreach my $s (@Scripts) { 101 | print <{'ClassName'}::Make$s->{'ScriptName'}(const char* pszName, int iHostObjId) 104 | { 105 | $s->{'ClassName'}* pscrRet = new(std::nothrow) $s->{'ClassName'}(pszName, iHostObjId); 106 | if (pscrRet) 107 | { 108 | pscrRet->AddRef(); 109 | pscrRet->InitScriptData(); 110 | } 111 | return static_cast(pscrRet); 112 | } 113 | void $s->{'ClassName'}::InitScriptDesc(sNewClassDesc * pDesc) 114 | { 115 | pDesc->pszModule = "$OSMName"; 116 | pDesc->pszClass = "$s->{'ScriptName'}"; 117 | pDesc->pszBaseClass = "$s->{'BaseName'}"; 118 | pDesc->pfnFactory = cScriptModule::ScriptFactory; 119 | pDesc->pfnRealFactory = $s->{'ClassName'}::Make$s->{'ScriptName'}; 120 | } 121 | L_FCN 122 | } 123 | if ($ofile ne '--') { 124 | select $ofh; 125 | close($fh); 126 | } 127 | } 128 | 129 | { 130 | my ($fin,$fout); 131 | my $stdout = 0; 132 | while ($_ = $ARGV[0], /^-/) { 133 | shift; 134 | last if /^--$/; 135 | if (/^-c/) { $stdout = 1; } 136 | if (/^-o/) { $fout = shift; } 137 | if (/^-D/ or /^-I/) { $CDefines .= " $_"; } 138 | } 139 | foreach my $f (@ARGV) { 140 | &process_file($f); 141 | $fin = $f; 142 | } 143 | if ($stdout) { $fout = '--'; } 144 | if (!defined $fout) { ($fout = $fin) =~ s|\.h$|_osm.cpp|; } 145 | &output_header($fout,@ARGV); 146 | } 147 | -------------------------------------------------------------------------------- /NVScript/script.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | ScriptModuleInit@20 3 | -------------------------------------------------------------------------------- /NVScript/scriptvars.cpp: -------------------------------------------------------------------------------- 1 | #include "scriptvars.h" 2 | #include 3 | 4 | extern IScriptMan* g_pScriptManager; 5 | extern IMalloc* g_pMalloc; 6 | 7 | void script_var::SetDynTag(const char* pszDynName) 8 | { 9 | char* pszNew = new char[strlen(pszDynName)+1]; 10 | if (pszNew) 11 | { 12 | strcpy(pszNew, pszDynName); 13 | if (m_bDynName) 14 | delete[] m_tag.pszName; 15 | m_tag.pszName = pszNew; 16 | m_bDynName = true; 17 | } 18 | } 19 | void script_var::Clear() 20 | { 21 | cMultiParm param; 22 | g_pScriptManager->ClearScriptData(&m_tag, ¶m); 23 | } 24 | 25 | void script_int::_ReSynch() 26 | { 27 | cMultiParm param; 28 | g_pScriptManager->GetScriptData(&m_tag, ¶m); 29 | m_iVal = param; 30 | } 31 | void script_int::_Synch() 32 | { 33 | cMultiParm param(m_iVal); 34 | g_pScriptManager->SetScriptData(&m_tag, ¶m); 35 | } 36 | 37 | void script_float::_ReSynch() 38 | { 39 | cMultiParm param; 40 | g_pScriptManager->GetScriptData(&m_tag, ¶m); 41 | m_fVal = param; 42 | } 43 | void script_float::_Synch() 44 | { 45 | cMultiParm param(m_fVal); 46 | g_pScriptManager->SetScriptData(&m_tag, ¶m); 47 | } 48 | 49 | void script_str::_ReSynch() 50 | { 51 | sMultiParm param; 52 | param.type = kMT_Undef; 53 | g_pScriptManager->GetScriptData(&m_tag, ¶m); 54 | m_szVal.Free(); 55 | m_szVal = (param.type == kMT_String) ? param.psz : NULL; 56 | } 57 | void script_str::_Synch(const char* pszVal) 58 | { 59 | cMultiParm param(pszVal); 60 | g_pScriptManager->SetScriptData(&m_tag, ¶m); 61 | } 62 | 63 | void script_vec::_ReSynch() 64 | { 65 | cMultiParm param; 66 | g_pScriptManager->GetScriptData(&m_tag, ¶m); 67 | m_vVal = *static_cast(param); 68 | } 69 | void script_vec::_Synch() 70 | { 71 | cMultiParm param(m_vVal); 72 | g_pScriptManager->SetScriptData(&m_tag, ¶m); 73 | } 74 | -------------------------------------------------------------------------------- /NVScript/strless_nocase.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct stringless_nocase : public std::binary_function 6 | { 7 | bool operator()(const std::string& __x, const std::string& __y) const 8 | { return ::stricmp(__x.c_str(),__y.c_str()) < 0; } 9 | }; 10 | 11 | struct strless_nocase : public std::binary_function 12 | { 13 | bool operator()(const char* __x, const char* __y) const 14 | { return ::stricmp(__x,__y) < 0; } 15 | }; 16 | -------------------------------------------------------------------------------- /NVScript/version.rc: -------------------------------------------------------------------------------- 1 | #include "windows.h" 2 | #ifdef _MSC_VER 3 | #include "..\buildconfig.h" 4 | #else 5 | #ifndef SCRIPT_COPYRIGHT 6 | #define SCRIPT_COPYRIGHT "Copyright (C) 2024 Nameless Voice" 7 | #endif 8 | #endif 9 | 10 | VS_VERSION_INFO VERSIONINFO 11 | FILEVERSION SCRIPT_VERSION 12 | PRODUCTVERSION SCRIPT_VERSION 13 | #if DEBUG 14 | FILEFLAGS VS_FF_DEBUG 15 | #else 16 | FILEFLAGS 0 17 | #endif 18 | FILEOS VOS_NT_WINDOWS32 19 | FILETYPE VFT_DLL 20 | BEGIN 21 | BLOCK "StringFileInfo" 22 | BEGIN 23 | BLOCK "040904e4" 24 | BEGIN 25 | // VALUE "CompanyName", "\0" 26 | VALUE "FileDescription", SCRIPT_LONGNAME "\0" 27 | VALUE "FileVersion", SCRIPT_VERSTRING "\0" 28 | VALUE "InternalName", SCRIPT_NAME "\0" 29 | VALUE "LegalCopyright", SCRIPT_COPYRIGHT "\0" 30 | VALUE "OriginalFilename", SCRIPT_NAME ".osm" "\0" 31 | // VALUE "ProductName", "\0" 32 | // VALUE "ProductVersion", "1.0" "\0" 33 | END 34 | END 35 | BLOCK "VarFileInfo" 36 | BEGIN 37 | VALUE "Translation", 1033, 1252 38 | END 39 | END 40 | 41 | -------------------------------------------------------------------------------- /PackageSource.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | REM Packages up the source code into the source directory. 3 | REM Requires: 4 | REM - Git Bash with Rsync installed (see: https://prasaz.medium.com/add-rsync-to-windows-git-bash-f42736bae1b3 ) 5 | REM - 7-ZIP in the path (used to zip the source) 6 | 7 | echo Copying source code 8 | if exist output/source rm -rf output/source 9 | if exist output/NVScript-source.zip rm -rf output/source.zip 10 | 11 | rsync -t -r --exclude-from=.gitignore --exclude=output/source --exclude=.git . output/source 12 | 13 | rem echo Zipping source code (disabled, as the deploy scripts should put it into the main script zip) 14 | rem "7z.exe" a "output/NVScript-source.zip" "./output/source/*" -tzip -mx9 > NUL 15 | 16 | echo Source code packaging completed -------------------------------------------------------------------------------- /buildconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef BUILDCONFIG_H 2 | #define BUILDCONFIG_H 3 | 4 | #pragma once 5 | 6 | 7 | #if GAME == 1 8 | // T1 9 | #define _DARKGAME 1 10 | #define GAMENAME "Thief1" 11 | #elif GAME == 3 12 | // SS2 13 | #define _DARKGAME 3 14 | #define GAMENAME "Shock2" 15 | #else 16 | // T2 17 | #define _DARKGAME 2 18 | #define GAMENAME "Thief2" 19 | #endif 20 | 21 | #define NVSCRIPT_VERSION_MAJOR 0 22 | #define NVSCRIPT_VERSION_MINOR 0 23 | #define NVSCRIPT_VERSION_BUILD 0 24 | 25 | 26 | #ifdef MODULE_NVSCRIPT 27 | // NVScript version defines 28 | #define SCRIPT_VERSION NVSCRIPT_VERSION_MAJOR,NVSCRIPT_VERSION_MINOR,NVSCRIPT_VERSION_BUILD,0 29 | #define SCRIPT_VERSTRING NVSCRIPT_VERSION_MAJOR "." NVSCRIPT_VERSION_MINOR "." NVSCRIPT_VERSION_BUILD 30 | #define SCRIPT_NAME "NVScript Script Module" 31 | #define SCRIPT_LONGNAME "NVScript " GAMENAME " OSM" 32 | #define SCRIPT_COPYRIGHT "Copyright (C) 2024 Nameless Voice" 33 | #elif defined(MODULE_NVDEBUG) 34 | // NVDebug version defines 35 | #define SCRIPT_VERSION 1,0,0,0 36 | #define SCRIPT_VERSTRING "1.0.0" 37 | #define SCRIPT_NAME "NVDebug Script Module" 38 | #define SCRIPT_LONGNAME "NVDebug " GAMENAME " OSM" 39 | #define SCRIPT_COPYRIGHT "Copyright (C) 2024 Nameless Voice" 40 | #else 41 | #ifdef RC_INVOKED 42 | #error buildconfig.h not updated for current module. 43 | #endif 44 | #endif 45 | 46 | 47 | #define _CRT_SECURE_NO_WARNINGS 48 | // disable "POSIX name for this item is deprecated" warnings 49 | #pragma warning(disable : 4996) 50 | 51 | // enable access to M_PI etc. 52 | #define _USE_MATH_DEFINES 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /building.txt: -------------------------------------------------------------------------------- 1 | Building requires either: 2 | a) Visual Studio 2017 or later 3 | b) Another C++ IDE, such as Rider, with appropriate MSBuild tools installed. 4 | 5 | By default, NVScript is built using Windows Build tools 141 with Windows XP support. 6 | You will need to install these to build script modules that work on Windows XP. 7 | Under Visual Studio installer, Modify, Individual components: 8 | - C++ Windows XP support for VS 2017 (v141) tools 9 | - MSVC v141 - VS 2017 C++ - x64/x86 build tools (v14.16) 10 | 11 | Alternatively, change the build tool version in all of the project files to a more recent version (you will lose XP support.) 12 | 13 | 14 | 15 | To build using Visual Studio (2017 or later): 16 | 17 | 1) Open NVScript.sln 18 | 19 | 2) Change the configuration in the toolbar to one of: 20 | Release - Build for Thief 2 21 | ReleaseSS2 - Build for System Shock 2 22 | ReleaseT1 - Build for Thief: The Dark Project 23 | 24 | (Debug builds likely won't work, as the file size tends to be larger than Dark will load) 25 | 26 | 3) Click "Build" 27 | 28 | 4) The script module will be built into the relevant Release folder. 29 | NVDebug will also be built - find it in the relevant "Release" folder. 30 | 31 | 5) The relevant Deploy script will be run after the build has completed (Deploy-T2.cmd, Deploy-SS2.cmd, Deploy-T1); 32 | these can be set up to automatically copy the created files to wherever they are needed, edit as needed. 33 | 34 | There are also old makefiles and batch scripts for building using G++ with a CygWin / MingW environment. 35 | I wouldn't recommend using them, as I have no idea if they still work. They are provided purely for academic interest. 36 | 37 | 38 | 39 | The project can also be built automatically on GitHub. 40 | Script modules will automatically be created for any commit to either a PR branch or master. -------------------------------------------------------------------------------- /lg.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files 118 | 119 | 120 | Header Files 121 | 122 | 123 | Header Files 124 | 125 | 126 | -------------------------------------------------------------------------------- /lg/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for lg library 2 | # GCC in Cygwin/Mingw32 3 | 4 | .SUFFIXES: 5 | .SUFFIXES: .o .cpp 6 | 7 | srcdir = . 8 | 9 | 10 | SH = sh 11 | 12 | CC = g++-3 13 | AR = ar 14 | DLLWRAP = dllwrap 15 | 16 | # _DARKGAME is not used here. The implementation of lgLib is universal 17 | DEFINES = -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -DWIN32_LEAN_AND_MEAN 18 | 19 | ARFLAGS = rc 20 | LDFLAGS = -mno-cygwin -mwindows -L. 21 | LIBS = -lstdc++ -luuid 22 | INCLUDEDIRS = -I. -I$(srcdir) 23 | # If you care for this... # -Wno-unused-variable 24 | # A lot of the callbacks have unused parameters, so I turn that off. 25 | CXXFLAGS = -W -Wall -Wno-unused-parameter -Wno-pmf-conversions \ 26 | $(INCLUDEDIRS) -mno-cygwin -masm=att \ 27 | -fno-pcc-struct-return -mms-bitfields 28 | LDFLAGS = -mno-cygwin -mwindows -L. -llg 29 | DLLFLAGS = --def script.def --add-underscore --target i386-mingw32 30 | 31 | ifdef DEBUG 32 | CXXDEBUG = -g -DDEBUG 33 | LDDEBUG = -g 34 | else 35 | CXXDEBUG = -O2 -DNDEBUG 36 | LDDEBUG = 37 | endif 38 | 39 | LG_HEADERS = lg/actreact.h \ 40 | lg/ai.h \ 41 | lg/config.h \ 42 | lg/convict.h \ 43 | lg/defs.h \ 44 | lg/dynarray.h \ 45 | lg/dynarray.hpp \ 46 | lg/editor.h \ 47 | lg/gen.h \ 48 | lg/graphics.h \ 49 | lg/iiddef.h \ 50 | lg/iids.h \ 51 | lg/input.h \ 52 | lg/interface.h \ 53 | lg/links.h \ 54 | lg/malloc.h \ 55 | lg/miss16.h \ 56 | lg/objects.h \ 57 | lg/objstd.h \ 58 | lg/propdefs.h \ 59 | lg/properties.h \ 60 | lg/quest.h \ 61 | lg/res.h \ 62 | lg/script.h \ 63 | lg/scrmanagers.h \ 64 | lg/scrmsgs.h \ 65 | lg/scrservices.h \ 66 | lg/sound.h \ 67 | lg/tools.h \ 68 | lg/types.h \ 69 | lg/win.h 70 | 71 | LG_LIB = liblg.a 72 | LG_SRCS = lg.cpp scrmsgs.cpp iids.cpp 73 | LG_OBJS = lg.o scrmsgs.o iids.o 74 | 75 | LG_LIBD = liblg-d.a 76 | LG_OBJSD = lg-d.o scrmsgs-d.o iids.o 77 | 78 | %.o: %.cpp 79 | $(CC) $(CXXFLAGS) $(CXXDEBUG) $(DEFINES) -o $@ -c $< 80 | 81 | %-d.o: %.cpp 82 | $(CC) $(CXXFLAGS) $(CXXDEBUG) $(DEFINES) -o $@ -c $< 83 | 84 | 85 | ALL: stamp $(LG_LIB) $(LG_LIBD) 86 | 87 | clean: 88 | $(RM) $(LG_OBJS) 89 | 90 | stamp: $(LG_SRCS) $(LG_HEADERS) 91 | $(RM) lg/stamp-* 92 | $(SH) timestamp.sh lg lg $(LG_SRCS) 93 | 94 | $(LG_LIB): $(LG_OBJS) 95 | $(AR) $(ARFLAGS) $@ $? 96 | 97 | $(LG_LIBD): CXXDEBUG = -g -DDEBUG 98 | $(LG_LIBD): LDDEBUG = -g 99 | $(LG_LIBD): $(LG_OBJSD) 100 | $(AR) $(ARFLAGS) $@ $? 101 | 102 | iids.o: iids.cpp 103 | lg.o: lg.cpp lg/types.h lg/dynarray.h lg/dynarray.hpp 104 | scrmsgs.o: scrmsgs.cpp lg/scrmsgs.h 105 | lg-d.o: lg.cpp lg/types.h lg/dynarray.h lg/dynarray.hpp 106 | scrmsgs-d.o: scrmsgs.cpp lg/scrmsgs.h 107 | -------------------------------------------------------------------------------- /lg/Makefile-b32: -------------------------------------------------------------------------------- 1 | # Makefile for lg library 2 | # Borland/Inprise C++ 5.x 3 | 4 | .autodepend 5 | .cacheautodepend 6 | 7 | BCCROOT = D:\BCC 8 | 9 | IMPLIB = $(BCCROOT)\bin\Implib 10 | ILINK32 = $(BCCROOT)\bin\ILink32 11 | TLIB = $(BCCROOT)\bin\TLib 12 | BRC32 = $(BCCROOT)\bin\Brc32 13 | TASM32 = $(BCCROOT)\bin\Tasm32 14 | CC = $(BCCROOT)\bin\BCC32 15 | 16 | srcdir = . 17 | 18 | DEFINES = -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -DWIN32_LEAN_AND_MEAN 19 | 20 | LDFLAGS = -q -Tpd -c 21 | LIBDIRS = -L.;$(BCCROOT)\lib;$(BCCROOT)\lib\psdk 22 | LIBS = ole32.lib oleaut32.lib uuid.lib 23 | INCLUDES = -I. -I$(srcdir) 24 | CXXFLAGS = -q -P -VM -VF -Vd -tWD -tWM 25 | RCFLAGS = -r 26 | 27 | !ifdef DEBUG 28 | CXXDEBUG = -v -y -O0 -DDEBUG 29 | LDDEBUG = -v 30 | !else 31 | CXXDEBUG = -O2 -5 -OS -v- -DNDEBUG 32 | LDDEBUG = -v- 33 | !endif 34 | 35 | LG_HEADERS = lg/actreact.h \ 36 | lg/ai.h \ 37 | lg/config.h \ 38 | lg/convict.h \ 39 | lg/defs.h \ 40 | lg/dynarray.h \ 41 | lg/dynarray.hpp \ 42 | lg/editor.h \ 43 | lg/gen.h \ 44 | lg/graphics.h \ 45 | lg/iiddef.h \ 46 | lg/iids.h \ 47 | lg/input.h \ 48 | lg/interface.h \ 49 | lg/links.h \ 50 | lg/malloc.h \ 51 | lg/miss16.h \ 52 | lg/objects.h \ 53 | lg/objstd.h \ 54 | lg/propdefs.h \ 55 | lg/properties.h \ 56 | lg/quest.h \ 57 | lg/res.h \ 58 | lg/script.h \ 59 | lg/scrmanagers.h \ 60 | lg/scrmsgs.h \ 61 | lg/scrservices.h \ 62 | lg/sound.h \ 63 | lg/tools.h \ 64 | lg/types.h \ 65 | lg/win.h 66 | 67 | LG_LIB = lg.lib 68 | LG_SRCS = lg.cpp scrmsgs.cpp iids.cpp 69 | LG_OBJS = lg.obj scrmsgs.obj iids.obj 70 | 71 | .cpp.obj: 72 | $(CC) $(CXXFLAGS) $(CXXDEBUG) $(DEFINES) -c $< 73 | 74 | ALL: $(LG_LIB) 75 | 76 | clean: 77 | del /q $(LG_OBJS) 78 | 79 | $(LG_LIB): $(LG_OBJS) 80 | del /q $(LG_LIB) 81 | $(TLIB) /a $@ $? 82 | 83 | 84 | -------------------------------------------------------------------------------- /lg/Makefile-vc: -------------------------------------------------------------------------------- 1 | # Makefile for lg library 2 | # MSVC++ 3 | 4 | CPU=i386 5 | APPVER=4.0 6 | !include 7 | 8 | srcdir = . 9 | 10 | DEFINES = -D_MT -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -DWIN32_LEAN_AND_MEAN 11 | 12 | LDFLAGS = -nologo $(dlllflags) 13 | LIBDIRS = 14 | LIBS = ole32.lib oleaut32.lib uuid.lib $(baselibs) 15 | INCLUDES = -I. -I$(srcdir) 16 | CXXFLAGS = $(cflags) -nologo -W3 -wd4800 -TP -EHsc 17 | LIBFLAGS = -nologo 18 | 19 | !ifdef DEBUG 20 | CXXDEBUG = -MTd -Od -DDEBUG 21 | LDDEBUG = -DEBUG 22 | !else 23 | CXXDEBUG = -MT -Ox -G5 -DNDEBUG 24 | LDDEBUG = -RELEASE 25 | !endif 26 | 27 | LG_HEADERS = lg/actreact.h \ 28 | lg/ai.h \ 29 | lg/config.h \ 30 | lg/convict.h \ 31 | lg/defs.h \ 32 | lg/dynarray.h \ 33 | lg/dynarray.hpp \ 34 | lg/editor.h \ 35 | lg/gen.h \ 36 | lg/graphics.h \ 37 | lg/iiddef.h \ 38 | lg/iids.h \ 39 | lg/input.h \ 40 | lg/interface.h \ 41 | lg/links.h \ 42 | lg/malloc.h \ 43 | lg/miss16.h \ 44 | lg/objects.h \ 45 | lg/objstd.h \ 46 | lg/propdefs.h \ 47 | lg/properties.h \ 48 | lg/quest.h \ 49 | lg/res.h \ 50 | lg/script.h \ 51 | lg/scrmanagers.h \ 52 | lg/scrmsgs.h \ 53 | lg/scrservices.h \ 54 | lg/sound.h \ 55 | lg/tools.h \ 56 | lg/types.h \ 57 | lg/win.h 58 | 59 | LG_LIB = lg.lib 60 | LG_SRCS = lg.cpp scrmsgs.cpp iids.cpp 61 | LG_OBJS = lg.obj scrmsgs.obj iids.obj 62 | 63 | .cpp.obj: 64 | $(cc) $(CXXFLAGS) $(CXXDEBUG) $(DEFINES) $(INCLUDES) -c $< 65 | 66 | ALL: $(LG_LIB) 67 | 68 | clean: 69 | del /q $(LG_OBJS) 70 | 71 | $(LG_LIB): $(LG_OBJS) 72 | $(implib) $(libflags) -out:$@ $(LG_OBJS) 73 | 74 | -------------------------------------------------------------------------------- /lg/lg/actreact.h: -------------------------------------------------------------------------------- 1 | /********************** 2 | * LGS Act/React 3 | */ 4 | 5 | #ifndef _LG_ACTREACT_H 6 | #define _LG_ACTREACT_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | 14 | struct sPropagatorDesc 15 | { 16 | }; 17 | 18 | struct sStimSourceDesc 19 | { 20 | }; 21 | 22 | struct sStimSensorEvent 23 | { 24 | }; 25 | 26 | struct sStimSourceEvent 27 | { 28 | }; 29 | 30 | struct sReactionEvent 31 | { 32 | }; 33 | 34 | struct sReactionParam 35 | { 36 | }; 37 | 38 | extern const GUID IID_IPropagator; 39 | interface IPropagator : IUnknown 40 | { 41 | STDMETHOD_(const sPropagatorDesc *,Describe)(void) const PURE; 42 | STDMETHOD_(unsigned long,GetID)(void) PURE; 43 | STDMETHOD_(long,AddStimulus)(int) PURE; 44 | STDMETHOD_(long,RemoveStimulus)(int) PURE; 45 | STDMETHOD_(int,SupportsStimulus)(int) PURE; 46 | STDMETHOD_(long,InitSource)(sStimSourceDesc*) PURE; 47 | STDMETHOD_(const sStructDesc *,DescribeShapes)(void) PURE; 48 | STDMETHOD_(const sStructDesc *,DescribeLifeCycles)(void) PURE; 49 | STDMETHOD_(long,SourceEvent)(sStimSourceEvent *) PURE; 50 | STDMETHOD_(float,GetSourceLevel)(unsigned long) PURE; 51 | STDMETHOD_(long,DescribeSource)(unsigned long,sStimSourceDesc *) PURE; 52 | STDMETHOD_(int,f11)(void) PURE; 53 | STDMETHOD_(long,Connect)(IUnknown *) PURE; 54 | STDMETHOD_(long,Propagate)(unsigned long,unsigned long) PURE; 55 | STDMETHOD_(long,Reset)(void) PURE; 56 | STDMETHOD_(long,Start)(void) PURE; 57 | STDMETHOD_(long,Stop)(void) PURE; 58 | }; 59 | 60 | extern const GUID IID_IPropagatorQuery; 61 | interface IPropagatorQuery : IUnknown 62 | { 63 | STDMETHOD_(long,Start)(void) PURE; 64 | STDMETHOD_(int,Done)(void) PURE; 65 | STDMETHOD_(long,Next)(void) PURE; 66 | STDMETHOD_(unsigned long,ID)(void) PURE; 67 | STDMETHOD_(IPropagator*,Propagator)(void) PURE; 68 | }; 69 | 70 | extern const GUID IID_IReactionQuery; 71 | interface IReactionQuery : IUnknown 72 | { 73 | STDMETHOD_(long,Start)(void) PURE; 74 | STDMETHOD_(int,Done)(void) PURE; 75 | STDMETHOD_(long,Next)(void) PURE; 76 | STDMETHOD_(unsigned long,ID)(void) PURE; 77 | }; 78 | 79 | extern const GUID IID_IStimSensorQuery ; 80 | extern const GUID IID_IStimSourceQuery ; 81 | 82 | struct sReactionDesc 83 | { 84 | char szName[32]; 85 | char szLongName[64]; 86 | char szParamType[32]; 87 | int unknown; 88 | }; 89 | 90 | extern const GUID IID_IReactions; 91 | interface IReactions : IUnknown 92 | { 93 | STDMETHOD_(unsigned long,Add)(sReactionDesc*,unsigned long (__stdcall *)(sReactionEvent*,const sReactionParam*,void*),void*) PURE; 94 | STDMETHOD_(unsigned long,GetReactionNamed)(const char*) PURE; 95 | STDMETHOD_(const sReactionDesc*,DescribeReaction)(unsigned long) PURE; 96 | STDMETHOD_(IReactionQuery*,QueryAll)(void) PURE; 97 | STDMETHOD_(unsigned long,React)(unsigned long,sReactionEvent*,const sReactionParam) PURE; 98 | }; 99 | DEFINE_IIDSTRUCT(IReactions,IID_IReactions) 100 | 101 | extern const GUID IID_IStimSensors ; 102 | extern const GUID IID_IStimSources ; 103 | extern const GUID IID_IStimulator ; 104 | extern const GUID IID_IStimuli ; 105 | extern const GUID IID_IPeriodicPropagator ; 106 | 107 | extern const GUID IID_IPropagation ; 108 | interface IPropagation : IUnknown 109 | { 110 | STDMETHOD_(unsigned long,AddPropagator)(IPropagator*) PURE; 111 | STDMETHOD_(long,AddPropagatorStimulus)(unsigned long,int) PURE; 112 | STDMETHOD_(long,RemovePropagatorStimulus)(unsigned long,int) PURE; 113 | STDMETHOD_(int,SupportsStimulus)(unsigned long,int) PURE; 114 | STDMETHOD_(IPropagator*,GetPropagator)(unsigned long) PURE; 115 | STDMETHOD_(IPropagator*,GetPropagatorNamed)(const char*) PURE; 116 | STDMETHOD_(IPropagatorQuery*,GetPropagators)(int) PURE; 117 | STDMETHOD_(long,SensorEvent)(sStimSensorEvent*) PURE; 118 | STDMETHOD_(long,SimpleSensorEvent)(unsigned long,unsigned long) PURE; 119 | STDMETHOD_(long,SourceEvent)(sStimSourceEvent*) PURE; 120 | STDMETHOD_(long,SimpleSourceEvent)(unsigned long,unsigned long) PURE; 121 | STDMETHOD_(long,Propagate)(unsigned long,unsigned long) PURE; 122 | STDMETHOD_(long,Reset)(void) PURE; 123 | STDMETHOD_(long,AddStimulus)(int) PURE; 124 | }; 125 | 126 | #endif // _LG_ACTREACT_H 127 | -------------------------------------------------------------------------------- /lg/lg/config.h: -------------------------------------------------------------------------------- 1 | /************************** 2 | * portability macros 3 | */ 4 | 5 | #ifndef _LG_CONFIG_H 6 | #define _LG_CONFIG_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #ifdef _MSC_VER 13 | 14 | // "__thiscall" is not, as I was led to believe, valid syntax. 15 | // Just have to rely on it being the default. 16 | #define __thiscall 17 | 18 | // MSVC doesn't know what the hell a 'throw' function spec is 19 | 20 | #define SPEC_THROW(x) throw(...) 21 | #define NO_THROW throw() 22 | 23 | #else // !_MSC_VER 24 | 25 | #define __thiscall 26 | 27 | #define SPEC_THROW(x) throw(x) 28 | #define NO_THROW throw() 29 | 30 | #endif // _MSC_VER 31 | 32 | #ifdef __GNUC__ 33 | 34 | #define IF_NOT(a,b) ((a)?:(b)) 35 | 36 | #else // !__GNUC__ 37 | 38 | #ifndef __attribute__ 39 | #define __attribute__(x) 40 | #endif 41 | 42 | #define IF_NOT(a,b) ((a)?(a):(b)) 43 | 44 | #endif // !__GNUC__ 45 | 46 | #ifdef __BORLANDC__ 47 | 48 | #endif 49 | 50 | #endif // _LG_CONFIG_H 51 | -------------------------------------------------------------------------------- /lg/lg/dlgs.h: -------------------------------------------------------------------------------- 1 | /********************** 2 | * LGS Dialog Interfaces 3 | */ 4 | 5 | #ifndef _LG_DLGS_H 6 | #define _LG_DLGS_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | struct sObjEditorDesc 18 | { 19 | char title[32]; 20 | unsigned long flags; 21 | }; 22 | 23 | struct sLinkEditorDesc 24 | { 25 | char title[64]; 26 | unsigned long flags; 27 | }; 28 | 29 | struct sActReactEditorDesc 30 | { 31 | int objid; 32 | int stimulus; 33 | }; 34 | 35 | enum eHierarchyRootFlag 36 | { 37 | kHierarchyRootShowConcrete = 1, 38 | kHierarchyRootNoCreate = 8 39 | }; 40 | 41 | struct sHierarchyRootDesc 42 | { 43 | char label[32]; 44 | char name[16]; 45 | unsigned long flags; 46 | // Any of these callbacks can be NULL. In which case, 47 | // the dialog should handle the event itself (if it can) 48 | int (*CreateCallback)(int,const char*); // retuns 10 or 1 49 | int (*DeleteCallback)(int); // returns 1 or 8 50 | int (*BrushCallback)(int); // returns 5 51 | }; 52 | 53 | struct sHierarchyEditorDesc 54 | { 55 | char title[36]; 56 | sHierarchyRootDesc* root; 57 | }; 58 | 59 | // You could use a union to read the embedded structs, 60 | // but why not take advantage or IStructDescTools 61 | struct sStimSource 62 | { 63 | int type; 64 | float intensity; 65 | unsigned long flags; 66 | char shape[32]; 67 | char lifecycle[32]; 68 | }; 69 | 70 | struct sStimSensor 71 | { 72 | int ordinal; 73 | float minintensity; 74 | float maxintensity; 75 | unsigned long flags; 76 | int effect; 77 | int target; 78 | int agent; 79 | char data[32]; 80 | }; 81 | 82 | extern const GUID IID_IStructEditor; 83 | interface IStructEditor : IUnknown 84 | { 85 | STDMETHOD_(BOOL,Show)(BOOL) PURE; 86 | // Set...something or other 87 | STDMETHOD(f01)(int,void*) PURE; 88 | STDMETHOD_(char const*,GetTitle)(VOID) PURE; 89 | STDMETHOD_(char const* const*,GetStructDesc)(VOID) PURE; 90 | STDMETHOD_(void const*,GetData)(VOID) PURE; 91 | }; 92 | DEFINE_IIDSTRUCT(IStructEditor,IID_IStructEditor) 93 | 94 | extern const GUID IID_IObjEditor; 95 | interface IObjEditor : IUnknown 96 | { 97 | STDMETHOD_(BOOL,Show)(BOOL) PURE; 98 | // Set...something or other 99 | STDMETHOD(f01)(int,void*) PURE; 100 | STDMETHOD_(sObjEditorDesc*,GetDesc)(VOID) PURE; 101 | STDMETHOD_(int,GetID)(VOID) PURE; 102 | }; 103 | DEFINE_IIDSTRUCT(IObjEditor,IID_IObjEditor) 104 | 105 | // plural? 106 | extern const GUID IID_IActReactEditors; 107 | interface IActReactEditor : IUnknown 108 | { 109 | STDMETHOD(EditSource)(int,sActReactEditorDesc*,sStimSource*) PURE; 110 | STDMETHOD(EditReceptron)(int,sActReactEditorDesc*,sStimSensor*) PURE; 111 | STDMETHOD(ListReceptrons)(int,sActReactEditorDesc*) PURE; 112 | STDMETHOD(ListSources)(int,sActReactEditorDesc*) PURE; 113 | }; 114 | DEFINE_IIDSTRUCT(IActReactEditor,IID_IActReactEditors) 115 | 116 | #endif // _LG_DLGS_H 117 | -------------------------------------------------------------------------------- /lg/lg/dynarray.h: -------------------------------------------------------------------------------- 1 | #ifndef LG_DYNARRAY_H 2 | #define LG_DYNARRAY_H 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #ifdef __BORLANDC__ 14 | #pragma warn -inl 15 | #endif 16 | 17 | class cDynArrayBase 18 | { 19 | protected: 20 | void * m_data; 21 | unsigned long m_size; 22 | unsigned long m_allocsize; 23 | 24 | static void _resize(void **p, unsigned int sz, unsigned int c) SPEC_THROW(std::bad_alloc); 25 | 26 | ~cDynArrayBase(); 27 | cDynArrayBase() 28 | : m_data(NULL), m_size(0), m_allocsize(0) { } 29 | 30 | public: 31 | void resynch() 32 | { m_allocsize = m_size; } 33 | }; 34 | 35 | /* LGS code uses an allocation scheme that I can't (don't want to) replicate. 36 | * This can cause problems if you've allocated less space than the internal 37 | * code will be expecting. 38 | * To be safe, when passing an array to the engine that will be written to, 39 | * set m_size to 0. Then when getting it back, call ``resynch();''. 40 | */ 41 | 42 | template 43 | class cDynArray : protected cDynArrayBase 44 | { 45 | private: 46 | typedef _T type; 47 | typedef _T* ptr; 48 | typedef _T& ref; 49 | typedef const _T* c_ptr; 50 | typedef const _T& c_ref; 51 | 52 | public: 53 | cDynArray() 54 | : cDynArrayBase() { } 55 | cDynArray(unsigned int _i); 56 | 57 | cDynArray(const cDynArray<_T>& _cpy); 58 | cDynArray<_T>& operator=(const cDynArray<_T>& _cpy); 59 | 60 | unsigned long size() const 61 | { return m_size; } 62 | ref operator[](unsigned int _n) SPEC_THROW(std::out_of_range); 63 | c_ref operator[](unsigned int _n) const SPEC_THROW(std::out_of_range); 64 | 65 | ptr begin() NO_THROW 66 | { return reinterpret_cast(m_data); } 67 | c_ptr begin() const NO_THROW 68 | { return reinterpret_cast(m_data); } 69 | ptr end() NO_THROW 70 | { return reinterpret_cast(m_data) + m_size; } 71 | c_ptr end() const NO_THROW 72 | { return reinterpret_cast(m_data) + m_size; } 73 | 74 | void resize(unsigned int _i); 75 | void clear() 76 | { resize(0); } 77 | 78 | unsigned int append(c_ref _e); 79 | unsigned int insert(c_ref _e, unsigned int _n); 80 | void erase(unsigned int _n) SPEC_THROW(std::out_of_range); 81 | }; 82 | 83 | #include 84 | 85 | #ifdef __BORLANDC__ 86 | #pragma warn .inl 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /lg/lg/dynarray.hpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | template 5 | cDynArray<_T>::cDynArray(unsigned int _i) 6 | : cDynArrayBase() 7 | { 8 | if (_i != 0) 9 | { 10 | _resize(&m_data, sizeof(type), _i); 11 | m_allocsize = _i; 12 | } 13 | } 14 | 15 | template 16 | cDynArray<_T>::cDynArray(const cDynArray<_T>& _cpy) 17 | : cDynArrayBase() 18 | { 19 | if (_cpy.m_size != 0) 20 | { 21 | _resize(&m_data, sizeof(type), _cpy.m_size); 22 | ::memcpy(m_data, _cpy.m_data, sizeof(type) * _cpy.m_size); 23 | m_allocsize = m_size = _cpy.m_size; 24 | } 25 | } 26 | 27 | template 28 | cDynArray<_T>& cDynArray<_T>::operator=(const cDynArray<_T>& _cpy) 29 | { 30 | _resize(&m_data, sizeof(type), _cpy.m_size); 31 | if (_cpy.m_size) 32 | ::memcpy(m_data, _cpy.m_data, sizeof(type) * _cpy.m_size); 33 | m_allocsize = m_size = _cpy.m_size; 34 | } 35 | 36 | template 37 | _T& cDynArray<_T>::operator[](unsigned int _n) SPEC_THROW(std::out_of_range) 38 | { 39 | if (_n >= m_size) 40 | throw std::out_of_range("cDynArray::operator[]"); 41 | return reinterpret_cast(m_data)[_n]; 42 | } 43 | 44 | template 45 | const _T& cDynArray<_T>::operator[](unsigned int _n) const SPEC_THROW(std::out_of_range) 46 | { 47 | if (_n >= m_size) 48 | throw std::out_of_range("cDynArray::operator[]"); 49 | return reinterpret_cast(m_data)[_n]; 50 | } 51 | 52 | template 53 | void cDynArray<_T>::resize(unsigned int _i) 54 | { 55 | if (_i > m_allocsize) 56 | { 57 | _resize(&m_data, sizeof(type), _i); 58 | m_allocsize = _i; 59 | } 60 | else 61 | { 62 | if (_i < m_size) 63 | m_size = _i; 64 | if ((m_allocsize - m_size)*sizeof(type) > 4096) 65 | { 66 | _resize(&m_data, sizeof(type), m_size); 67 | m_allocsize = m_size; 68 | } 69 | } 70 | } 71 | 72 | template 73 | unsigned int cDynArray<_T>::append(const _T& _e) 74 | { 75 | register unsigned int _i = m_size + 1; 76 | if (_i > m_allocsize) 77 | { 78 | _resize(&m_data, sizeof(type), _i); 79 | m_allocsize = _i; 80 | } 81 | m_size = _i--; 82 | reinterpret_cast(m_data)[_i] = _e; 83 | return _i; 84 | } 85 | 86 | template 87 | unsigned int cDynArray<_T>::insert(const _T& _e, unsigned int _n) 88 | { 89 | register unsigned int _i = m_size + 1; 90 | if (_i > m_allocsize) 91 | { 92 | _resize(&m_data, sizeof(type), _i); 93 | m_allocsize = _i; 94 | } 95 | if (_n >= m_size) 96 | { 97 | m_size = _i--; 98 | reinterpret_cast(m_data)[_i] = _e; 99 | return _i; 100 | } 101 | register _T* _p = reinterpret_cast(m_data) + _n; 102 | ::memmove(_p+1, _p, (m_size - _n)*sizeof(type)); 103 | *_p = _e; 104 | m_size = _i; 105 | return _n; 106 | } 107 | 108 | template 109 | void cDynArray<_T>::erase(unsigned int _n) SPEC_THROW(std::out_of_range) 110 | { 111 | if (_n >= m_size) 112 | throw std::out_of_range("cDynArray::erase"); 113 | --m_size; 114 | register _T* _p = reinterpret_cast(m_data) + _n; 115 | ::memmove(_p, _p+1, (m_size - _n)*sizeof(type)); 116 | if ((m_allocsize - m_size)*sizeof(type) > 4096) 117 | { 118 | _resize(&m_data, sizeof(type), m_size); 119 | m_allocsize = m_size; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /lg/lg/editor.h: -------------------------------------------------------------------------------- 1 | /*********************** 2 | * LGS Editor Interface 3 | */ 4 | 5 | #ifndef _LG_EDITOR_H 6 | #define _LG_EDITOR_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | 16 | extern const GUID IID_IEditTools; 17 | interface IEditTools : IUnknown 18 | { 19 | STDMETHOD_(const char*,ObjName)(int) PURE; 20 | STDMETHOD_(int,GetObjNamed)(const char*) PURE; 21 | STDMETHOD_(long,EditTypedData)(const char*, const char*, void*) PURE; 22 | }; 23 | DEFINE_IIDSTRUCT(IEditTools,IID_IEditTools) 24 | 25 | #endif // _LG_EDITOR_H 26 | -------------------------------------------------------------------------------- /lg/lg/graphics.h: -------------------------------------------------------------------------------- 1 | /********************** 2 | * LGS Graphics interface 3 | */ 4 | 5 | #ifndef _LG_GRAPHICS_H 6 | #define _LG_GRAPHICS_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | 14 | enum eDisplayDeviceKind 15 | { 16 | kUnknownDisplayDeviceKind = -1 17 | }; 18 | 19 | struct grs_sys_info 20 | { 21 | }; 22 | 23 | struct grs_mode_info 24 | { 25 | short mode_num; 26 | short unknown1; 27 | unsigned short width; 28 | unsigned short height; 29 | unsigned char depth; 30 | unsigned char unknown2; 31 | unsigned short unknown3; 32 | }; 33 | 34 | struct sGrModeInfoEx 35 | { 36 | }; 37 | 38 | struct grs_bitmap 39 | { 40 | char *data; 41 | short unknown1; 42 | short unknown2; 43 | unsigned short width, height, row_size; 44 | unsigned short unknown3; 45 | }; 46 | 47 | extern const GUID IID_IDisplayDevice; 48 | interface IDisplayDevice : IUnknown 49 | { 50 | STDMETHOD_(eDisplayDeviceKind,GetKind)(void) PURE; 51 | STDMETHOD_(void,SetKind)(eDisplayDeviceKind,int) PURE; 52 | STDMETHOD_(void,GetInfo)(grs_sys_info*,grs_mode_info*) PURE; 53 | STDMETHOD_(long,Close)(void) PURE; 54 | STDMETHOD_(long,SetMode)(int,int) PURE; 55 | STDMETHOD_(int,GetMode)(sGrModeInfoEx*) PURE; 56 | STDMETHOD_(int,StatHTrace)(void) PURE; 57 | STDMETHOD_(int,StatVTrace)(void) PURE; 58 | STDMETHOD_(int,SetPalette)(unsigned int,unsigned int,const unsigned char*) PURE; 59 | STDMETHOD_(int,GetPalette)(unsigned int,unsigned int,unsigned char*) PURE; 60 | STDMETHOD_(long,PageFlip)(void) PURE; 61 | STDMETHOD_(int,Lock)(void) PURE; 62 | STDMETHOD_(int,Unlock)(void) PURE; 63 | STDMETHOD_(void,Flush)(void) PURE; 64 | STDMETHOD_(void,PauseFlush)(int) PURE; 65 | }; 66 | DEFINE_IIDSTRUCT(IDisplayDevice,IID_IDisplayDevice) 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /lg/lg/iiddef.h: -------------------------------------------------------------------------------- 1 | /*********************** 2 | * LGS IID Helper class 3 | */ 4 | 5 | #ifndef _LG_IIDDEF_H 6 | #define _LG_IIDDEF_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | 16 | #define DEFINE_IIDSTRUCT(_iface,_iid) \ 17 | template<> struct IID_Def<_iface> \ 18 | { \ 19 | static const GUID iid() { return _iid; } \ 20 | static const char* name() { return #_iface; } \ 21 | }; 22 | 23 | template 24 | struct IID_Def 25 | { 26 | static const IID* iid(); 27 | static const char* name(); 28 | }; 29 | 30 | #endif // _LG_IIDDEF_H 31 | -------------------------------------------------------------------------------- /lg/lg/input.h: -------------------------------------------------------------------------------- 1 | /********************** 2 | * LGS Input 3 | */ 4 | 5 | #ifndef _LG_INPUT_H 6 | #define _LG_INPUT_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | 16 | extern const GUID IID_IInputDevice; 17 | 18 | extern const GUID IID_IInputBinder; 19 | 20 | struct _ui_event 21 | { 22 | }; 23 | 24 | struct _intrnl_var_channel 25 | { 26 | }; 27 | 28 | struct _Region 29 | { 30 | }; 31 | 32 | typedef int (__cdecl *InputVarHandlerFunc)(const char*,const char*); 33 | typedef int (__cdecl *InputVarAddActiveAgg)(void*,int,char*); 34 | 35 | struct _IB_var 36 | { 37 | char szName[32]; 38 | char szValue[64]; 39 | int iType; // 2 - alias 40 | InputVarHandlerFunc pfnHandler; 41 | InputVarAddActiveAgg pfnActiveAgg; 42 | char zero[32]; 43 | }; 44 | 45 | struct _sBindContext 46 | { 47 | }; 48 | 49 | struct sInputDeviceInfo 50 | { 51 | }; 52 | 53 | struct sJoyState 54 | { 55 | }; 56 | 57 | typedef unsigned char (__cdecl *InputHandlerFunc)(_ui_event*,_Region*,void*); 58 | typedef int (__cdecl *InputBindFilter)(char*,char*,void*); 59 | typedef void (__cdecl *InputPostBind)(int); 60 | typedef int (__cdecl *MasterAggregationFunc)(_intrnl_var_channel**,long,char*); 61 | typedef char* (__cdecl *MasterProcessCallbackFunc)(char*,char*,int); 62 | 63 | interface IInputBinder : IUnknown 64 | { 65 | STDMETHOD_(char*,Init)(_IB_var*,char*) PURE; 66 | STDMETHOD_(char*,Term)(void) PURE; 67 | STDMETHOD_(void,GetHandler)(InputHandlerFunc*) PURE; 68 | STDMETHOD_(void,SetValidEvents)(unsigned long) PURE; 69 | #if (_DARKGAME == 2) || (_DARKGAME == 3) 70 | STDMETHOD_(unsigned long,GetValidEvents)(void) PURE; 71 | STDMETHOD_(int,Bind)(char*,char*) PURE; 72 | /*** Bind - Binds a command to a key 73 | * = int - 74 | * : char* - the key to bind 75 | * : char* - the command to bind to the key 76 | */ 77 | STDMETHOD_(int,Unbind)(char*) PURE; 78 | /*** Unbind - Unbinds all commands from a key 79 | * = int - 80 | * : char* - the key to unbind 81 | */ 82 | STDMETHOD_(void,QueryBind)(char*,char*,long) PURE; 83 | STDMETHOD_(void,GetVarValue)(char*,char*,long) PURE; 84 | #endif 85 | STDMETHOD_(char*,ProcessCmd)(char*) PURE; 86 | STDMETHOD_(void,TrapBind)(char*,InputBindFilter,InputPostBind,void*) PURE; 87 | STDMETHOD_(char*,Update)(void) PURE; 88 | STDMETHOD_(void,PollAllKeys)(void) PURE; 89 | STDMETHOD_(void,RegisterJoyProcObj)(void*) PURE; 90 | #if (_DARKGAME == 2) 91 | STDMETHOD_(void,LoadBndContexted)(char*) PURE; 92 | STDMETHOD_(void,ContextAssociate)(_sBindContext*) PURE; 93 | #endif 94 | STDMETHOD_(char*,LoadBndFile)(char*,unsigned long,char*) PURE; 95 | STDMETHOD_(char*,SaveBndFile)(char*,char*) PURE; 96 | STDMETHOD_(int,VarSet)(_IB_var*) PURE; 97 | STDMETHOD_(int,VarSetn)(_IB_var*,long) PURE; 98 | STDMETHOD_(char*,VarUnset)(char**,int) PURE; 99 | STDMETHOD_(char*,VarUnsetn)(char**,long,int) PURE; 100 | STDMETHOD_(char*,VarUnsetAll)(void) PURE; 101 | STDMETHOD_(int,SetContext)(unsigned long,int) PURE; 102 | STDMETHOD_(void,GetContext)(unsigned long*) PURE; 103 | STDMETHOD_(void,SetMasterAggregation)(MasterAggregationFunc) PURE; 104 | STDMETHOD_(void,SetMasterProcessCallback)(MasterProcessCallbackFunc) PURE; 105 | STDMETHOD_(char*,GetControlFromCmdStart)(char*,char*) PURE; 106 | STDMETHOD_(char*,GetControlFromCmdNext)(char*) PURE; 107 | STDMETHOD_(void,SetResPath)(char*) PURE; 108 | STDMETHOD_(char*,DecomposeControl)(char*,char*[32],long*) PURE; 109 | #if (_DARKGAME == 2) || (_DARKGAME == 3) 110 | STDMETHOD_(void,Reset)(void) PURE; 111 | #endif 112 | }; 113 | DEFINE_IIDSTRUCT(IInputBinder,IID_IInputBinder) 114 | 115 | interface IJoystick : IUnknown 116 | { 117 | STDMETHOD_(long,GetInfo)(sInputDeviceInfo*) PURE; 118 | STDMETHOD_(long,GetState)(sJoyState*) PURE; 119 | STDMETHOD_(long,SetAxisRange)(int,long,long) PURE; 120 | STDMETHOD_(long,GetAxisRange)(int,long*,long*) PURE; 121 | STDMETHOD_(long,SetAxisDeadZone)(int,unsigned long) PURE; 122 | STDMETHOD_(long,SetCooperativeLevel)(int,int) PURE; 123 | }; 124 | 125 | #endif // _LG_INPUT_H 126 | -------------------------------------------------------------------------------- /lg/lg/links.h: -------------------------------------------------------------------------------- 1 | /************* 2 | * LGS Links 3 | */ 4 | 5 | #ifndef _LG_LINKS_H 6 | #define _LG_LINKS_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | extern const GUID IID_ILinkQuery; 19 | interface ILinkQuery : IUnknown 20 | { 21 | STDMETHOD_(int,Done)(void) const PURE; 22 | STDMETHOD_(long,Link)(sLink *) const PURE; 23 | STDMETHOD_(long,ID)(void) const PURE; 24 | // The pointer should not be freed. 25 | STDMETHOD_(void*,Data)(void) const PURE; 26 | STDMETHOD_(long,Next)(void) PURE; 27 | STDMETHOD_(ILinkQuery*,Inverse)(void) PURE; 28 | }; 29 | DEFINE_IIDSTRUCT(ILinkQuery,IID_ILinkQuery) 30 | 31 | enum eRelationEvent 32 | { 33 | kRelationChange = 1, 34 | kRelationAdd = 2, 35 | // not sure what 4 is, related to Delete somehow 36 | kRelationDelete = 8, 37 | 38 | kRelationFull = 15 39 | }; 40 | struct sRelationListenMsg 41 | { 42 | eRelationEvent event; 43 | long lLink; 44 | int source; 45 | int dest; 46 | short flavor; 47 | }; 48 | typedef void (__stdcall *RelListenFunc)(sRelationListenMsg*,void*); 49 | 50 | struct sRelationDesc 51 | { 52 | char szName[45]; 53 | }; 54 | 55 | struct sRelationDataDesc 56 | { 57 | char szTypeName[32]; 58 | unsigned int uiTypeSize; 59 | }; 60 | 61 | extern const GUID IID_IRelation; 62 | interface IRelation : IUnknown 63 | { 64 | // This function returns information about the relation 65 | STDMETHOD_(const sRelationDesc*,Describe)(void) const PURE; 66 | // The functions below get (and set?) the ID of the relation 67 | STDMETHOD_(short,GetID)(void) const PURE; 68 | STDMETHOD_(long,SetID)(short) PURE; 69 | // This function returns the data of the relation 70 | STDMETHOD_(const sRelationDataDesc*,DescribeData)(void) const PURE; 71 | // This function returns the corresponding inverse relation (~Name) 72 | STDMETHOD_(IRelation*,Inverse)(void) PURE; 73 | // Add relations? 74 | STDMETHOD_(long,Add)(int,int) PURE; 75 | // The contents of the data pointer are copied. (Be sure the memory it points to is large enough to be read.) 76 | // Wasn't originally const, I changed it to allow the use of string literals. 77 | STDMETHOD_(long,AddFull)(int,int,const void*) PURE; 78 | STDMETHOD_(long,Remove)(long) PURE; 79 | // The function below retrieves link information, given the link's (not the relation's!) ID. 80 | STDMETHOD_(int,Get)(long,sLink *) const PURE; 81 | STDMETHOD_(long,SetData)(long,void *) PURE; 82 | // The pointer should not be freed 83 | STDMETHOD_(void*,GetData)(long) PURE; 84 | STDMETHOD_(ILinkQuery*,Query)(int,int) const PURE; 85 | STDMETHOD_(long,Notify)(unsigned long,void *) PURE; 86 | STDMETHOD_(long,Listen)(unsigned long,RelListenFunc,void*) PURE; 87 | STDMETHOD_(long,GetSingleLink)(int,int) PURE; 88 | STDMETHOD_(int,AnyLinks)(int,int) PURE; 89 | }; 90 | DEFINE_IIDSTRUCT(IRelation,IID_IRelation) 91 | 92 | 93 | /***LG3 -- Return values have changed for these methods. ***/ 94 | /////////// 95 | // linkset 96 | /////////// 97 | inline linkset& linkset::operator=(ILinkQuery* __q) 98 | { 99 | if (query) query->Release(); 100 | query = __q; 101 | return *this; 102 | } 103 | inline linkset::~linkset() 104 | { 105 | if (query) query->Release(); 106 | } 107 | inline link linkset::Link() const 108 | { 109 | link __l; 110 | if (query) 111 | __l = query->ID(); 112 | return __l; 113 | } 114 | inline void linkset::NextLink() 115 | { 116 | if (query) query->Next(); 117 | } 118 | inline bool linkset::AnyLinksLeft() const 119 | { 120 | return (query && !query->Done()); 121 | } 122 | inline void* linkset::Data() const 123 | { 124 | return (query) ? query->Data() : NULL; 125 | } 126 | inline sLink linkset::Get() const 127 | { 128 | sLink __sl; 129 | if (query) 130 | query->Link(&__sl); 131 | else 132 | __sl.flavor = __sl.dest = __sl.source = 0; 133 | return __sl; 134 | } 135 | 136 | 137 | #endif // _LG_LINKS_H 138 | -------------------------------------------------------------------------------- /lg/lg/malloc.h: -------------------------------------------------------------------------------- 1 | /***************************** 2 | * LGS Malloc Implementation 3 | */ 4 | 5 | #ifndef _LG_MALLOC_H 6 | #define _LG_MALLOC_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | 16 | /* 17 | interface IMalloc : IUnknown 18 | { 19 | STDMETHOD_(void*,Alloc)(ULONG) PURE; 20 | STDMETHOD_(void*,ReAlloc)(void*,ULONG) PURE; 21 | STDMETHOD_(void,Free)(void*) PURE; 22 | STDMETHOD_(ULONG,GetSize)(void*) PURE; 23 | STDMETHOD_(int,DidAlloc)(void*) PURE; 24 | STDMETHOD_(void,HeapMinimize)(void) PURE; 25 | }; 26 | DEFINE_IIDSTRUCT(IMalloc,IID_IMalloc) 27 | */ 28 | 29 | extern const GUID IID_IDebugMalloc; 30 | interface IDebugMalloc : IMalloc 31 | { 32 | STDMETHOD_(void*,AllocEx)(unsigned long,const char*,int) PURE; 33 | STDMETHOD_(void*,Reallocex)(void*,unsigned long,const char*,int) PURE; 34 | STDMETHOD_(void,FreeEx)(void*,const char*,int) PURE; 35 | STDMETHOD_(long,VerifyAlloc)(void*) PURE; 36 | STDMETHOD_(long,VerifyHeap)(void) PURE; 37 | STDMETHOD_(void,DumpHeapInfo)(void) PURE; 38 | STDMETHOD_(void,DumpStats)(void) PURE; 39 | STDMETHOD_(void,DumpBlocks)(void) PURE; 40 | STDMETHOD_(void,DumpModules)(void) PURE; 41 | STDMETHOD_(void,PushCredit)(const char*,int) PURE; 42 | STDMETHOD_(void,PopCredit)(void) PURE; 43 | }; 44 | DEFINE_IIDSTRUCT(IDebugMalloc,IID_IDebugMalloc) 45 | 46 | /* 47 | extern const GUID IID_IScriptModuleAlloc; 48 | interface IScriptModuleAlloc : IMalloc 49 | { 50 | STDMETHOD_(void*,AllocEx)(unsigned long,const char*,int) PURE; 51 | STDMETHOD_(void*,Reallocex)(void*,unsigned long,const char*,int) PURE; 52 | STDMETHOD_(void,FreeEx)(void*,const char*,int) PURE; 53 | STDMETHOD_(long,VerifyAlloc)(void*) PURE; 54 | STDMETHOD_(long,VerifyHeap)(void) PURE; 55 | STDMETHOD_(void,DumpHeapInfo)(void) PURE; 56 | STDMETHOD_(void,DumpStats)(void) PURE; 57 | STDMETHOD_(void,DumpBlocks)(void) PURE; 58 | STDMETHOD_(void,DumpModules)(void) PURE; 59 | STDMETHOD_(void,PushCredit)(const char*,int) PURE; 60 | STDMETHOD_(void,PopCredit)(void) PURE; 61 | virtual void Attach(IMalloc **) PURE; 62 | void Remove(void); 63 | int HaveRecord(void*); 64 | sScriptAllocRecord* VoidToRecord(void*); 65 | void* RealAddress(void*); 66 | void GrowBlocks(void); 67 | }; 68 | DEFINE_IIDSTRUCT(IScriptModuleAlloc,IID_IScriptModuleAlloc) 69 | */ 70 | 71 | 72 | #endif // _LG_MALLOC_H 73 | -------------------------------------------------------------------------------- /lg/lg/miss16.h: -------------------------------------------------------------------------------- 1 | /* 2 | [100050F0] = SetTimedMessage 3 | [10005350] = SetScriptVar 4 | [10005140] = GetScriptVar 5 | [100051E0] = GetScriptVar 6 | 7 | [10029220] = IScriptManager 8 | [10029228] = ILinkSrv 9 | [10029234] = IObjectSrv 10 | [10029238] = IPhysSrv 11 | [10029240] = IDarkGameSrv 12 | [10029274] = 13 | [10029280] = IPropertySrv 14 | [10029290] = IQuestSrv 15 | [10029294] = IDamageSrv 16 | [10029414] = IDataSrv 17 | [100294A0] = ISoundScrSrv 18 | [100294AC] = IDarkUISrv 19 | 20 | [1001ef60] = str GoalStateVarName(int i) 21 | [1001efa0] = str GoalVisibleVarName(int i) 22 | [1001efe0] = str GoalMinDiffVarName(int i) 23 | [1001f020] = str GoalMaxDiffVarName(int i) 24 | 25 | */ 26 | 27 | interface cScr_VictoryChecker : public IScr_Room 28 | { 29 | // IScr_RootScript 30 | // Responds to CheckVictory and ReSubscribe 31 | //virtual void OnMessage_(sScrMsg&,cMultiParm*) = 0; // 0x100072C0 32 | //virtual void OnBeginScript_(sScrMsg&,cMultiParm*) = 0; // 0x10006a70 33 | //virtual void OnEndScript_(sScrMsg&,cMultiParm*) = 0; // 0x10006d30 34 | //virtual void OnTimer_(sScrTimerMsg&,cMultiParm*) = 0; // 0x10007110 35 | //virtual void OnQuestChange_(sQuestMsg&,cMultiParm*) = 0; // 0x10006d60 36 | //virtual void OnContainer_(sContainerScrMsg&,cMultiParm*) = 0; // 0x10006f10 37 | //virtual void OnSlain_(sSlayMsg&,cMultiParm*) = 0; // 0x10006de0 38 | // IScr_Room 39 | // cScr_VictoryChecker 40 | // Set the timer EndMission for 4.5 seconds, or from the qvar EndMission 41 | // If the svar DoFadeToBlack is set, set the timer FadeToBlack for 1 second and set the svar FadeTime. 42 | // If qvar MISSION_COMPLETE is 0 and svar IDied is 0, display FailedObj from PlayHint.str. 43 | virtual void __thiscall EndMission(void) = 0; // 0x10004c30 44 | // Subscribes to GOAL_STATE_n and GOAL_VISIBLE_n qvars. 45 | // Stops at the first non-existent GOAL_STATE_n 46 | virtual void __thiscall SubscribeToGoalChanges(true_bool subscribe) = 0; // 0x100053b0 47 | virtual void __thiscall ObjectiveSet(int objective, int value) = 0; // 0x100055b0 48 | virtual void __thiscall ObjectiveShow(int objective, true_bool ShowElseHide) = 0; // 0x10005600 49 | // Sets the M-GarrettDiffSettings metaprops and adds a HitPointBonus 50 | virtual void __thiscall ObjectiveInit(int objective) = 0; // 0x10005660 51 | virtual int __thiscall ObjectiveGet(int objective) = 0; // 0x100056b0 52 | // Takes into account difficulty 53 | virtual true_bool __thiscall ObjectiveVisible(int objective) = 0; // 0x10005700 54 | virtual true_bool __thiscall ObjectiveExists(int objective) = 0; // 0x10005870 55 | // Return true if GOAL_REVERSE_n or GOAL_OPTIONAL_n 56 | virtual true_bool __thiscall ObjectiveNotBreach(int objective) = 0; // 0x100058d0 57 | // Returns 0, 1, or 3 58 | virtual int __thiscall ObjectivesMet(void) = 0; // 0x10005aa0 59 | // Returns true if mission is completed or failed. 60 | // Sets REVERSE and OPTIONAL qvars to final values. 61 | // Sets MISSION_COMPLETE and calls EndMission. 62 | virtual true_bool __thiscall CheckComplete(void) = 0; // 0x10005b80 63 | // Will send a Popup message 64 | virtual void __thiscall CheckNewGoal(void) = 0; // 0x10005d60 65 | virtual int __thiscall GoalVisibleMask(void) = 0; // 0x10006290 66 | virtual void __thiscall ObjectiveScore(int objective, true_bool DoneElseUndone) = 0; // 0x100063d0 67 | virtual void __thiscall ObjToGoal(object obj, true_bool got) = 0; // 0x10006a30 68 | virtual void __thiscall LootToGoal(int loot_total, int goldval, int gemsval, int goodsval, int lootbits) = 0; // 0x10006a50 69 | }; 70 | 71 | interface cScr_HealingWaterFont : public IScr_RootScript 72 | { 73 | virtual void __thiscall Heal(object Target) = 0; // 0x100074a0 74 | virtual int __thiscall GetHealAmount(void) = 0; // 0x100076b0 75 | virtual float __thiscall GetRechargeTime(void) = 0; // 0x100076d0 76 | }; 77 | 78 | interface cScr_TransmogrifyMachine : public IScr_RootScript 79 | { 80 | virtual void __thiscall OnTurnOn(void) = 0; // 0x1000c7d0 81 | virtual void __thiscall OnEnter(int,object) = 0; // 0x1000c7f0 82 | virtual void __thiscall OnExit(int,object) = 0; // 0x1000c810 83 | }; 84 | 85 | -------------------------------------------------------------------------------- /lg/lg/objstd.h: -------------------------------------------------------------------------------- 1 | #ifndef _LG_OBJSTD_H 2 | #define _LG_OBJSTD_H 3 | 4 | #ifndef NOMINMAX 5 | #define NOMINMAX 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #undef SendMessage 12 | #undef PostMessage 13 | #undef DispatchMessage 14 | #undef GetClassName 15 | #undef GetCommandLine 16 | #undef UnlockResource 17 | #undef FindResource 18 | 19 | #endif // _LG_OBJSTD_H 20 | -------------------------------------------------------------------------------- /lg/lg/propdefs.h: -------------------------------------------------------------------------------- 1 | /*************************** 2 | * LGS Property Definitions 3 | */ 4 | 5 | #ifndef _LG_PROPDEFS_H 6 | #define _LG_PROPDEFS_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #define AITEAM_GOOD 0 16 | #define AITEAM_NEUTRAL 1 17 | 18 | #define AIAWARE_SEEN 0x00000001 19 | #define AIAWARE_HEARD 0x00000002 20 | #define AIAWARE_CANRAYCAST 0x00000004 21 | #define AIAWARE_HAVELOS 0x00000008 22 | #define AIAWARE_BLIND 0x00000010 23 | #define AIAWARE_DEAF 0x00000020 24 | #define AIAWARE_HIGHEST 0x00000040 25 | #define AIAWARE_FIRSTHAND 0x00000080 26 | 27 | // This should really be in linkdefs.h 28 | struct sAIAwareness { 29 | int i; 30 | int flags; 31 | int level; 32 | int PeakLevel; 33 | int LevelEnterTime; 34 | int TimeLastContact; 35 | mxs_vector PosLastContact; 36 | int i2; 37 | int VisCone; 38 | int TimeLastUpdate; 39 | int TimeLastUpdateLOS; 40 | int i3; 41 | int TimeLastFirstHand; 42 | int Freshness; 43 | #if (_DARKGAME == 2) 44 | int i4; 45 | #endif 46 | }; 47 | 48 | struct sAIAlertCap { 49 | int iMax, iMin, iMinRelaxAfterPeak; 50 | }; 51 | 52 | 53 | struct sLoot { 54 | int iGold; 55 | int iGems; 56 | int iArt; 57 | int iSpecial; 58 | }; 59 | 60 | struct sMovingTerrain 61 | { 62 | unsigned long unknown; 63 | unsigned long active; 64 | }; 65 | 66 | 67 | #define PHYS_CONTROL_AXISVELS 1 68 | #define PHYS_CONTROL_VELS 2 69 | #define PHYS_CONTROL_ROTVELS 4 70 | 71 | struct sPhysControl { 72 | int uiActive; 73 | mxs_vector axis_vels; 74 | mxs_vector vels; 75 | mxs_vector rot_vels; 76 | }; 77 | 78 | struct sPhysState { 79 | mxs_vector loc; 80 | mxs_vector facing; 81 | mxs_vector vels; 82 | mxs_vector rot_vels; 83 | }; 84 | 85 | #pragma pack(push,1) 86 | struct sRenderFlash 87 | { 88 | unsigned char red; 89 | unsigned char green; 90 | unsigned char blue; 91 | unsigned char active; 92 | unsigned long worldduration; 93 | unsigned long screenduration; 94 | unsigned long effectduration; 95 | float time; 96 | float range; 97 | unsigned long starttime; 98 | }; 99 | #pragma pack(pop) 100 | 101 | enum eAIPsdScrAct 102 | { 103 | kPS_Nothing, 104 | kPS_ScrMsg, 105 | kPS_Alert, 106 | kPS_GoHostile, 107 | kPS_Investigate, 108 | kPS_GotoObject, 109 | kPS_FrobObject, 110 | kPS_Wait, 111 | kPS_MPrint, 112 | kPS_AddRemMetaProp, 113 | kPS_AddLink, 114 | kPS_RemLink, 115 | kPS_Face, 116 | kPS_DestScrMsg 117 | }; 118 | 119 | struct sAIPsdScr 120 | { 121 | eAIPsdScrAct action; 122 | char argument1[64]; 123 | char argument2[64]; 124 | char argument3[64]; 125 | char pad[64]; 126 | }; 127 | 128 | enum eAIWatchKind 129 | { 130 | kAIWatchPlayerIntrustion, 131 | kAIWatchSelfEntry 132 | }; 133 | 134 | enum eAIVisibility 135 | { 136 | kNoVisibility, 137 | kLineOfSight, 138 | kRaycast 139 | }; 140 | 141 | struct sAIWatchPoint 142 | { 143 | char pad1[60]; 144 | eAIWatchKind WatchKind; 145 | eAIAwareLevel ReqAwareness; 146 | eAIVisibility ReqVisibility; 147 | int pad2; 148 | unsigned long LinkKill; 149 | unsigned long KillLikeLinks; 150 | unsigned long NoTestOnceTriggered; 151 | int ReuseTime; 152 | int ResetTime; 153 | eAIScriptAlertLevel MinAlertness; 154 | eAIScriptAlertLevel MaxAlertness; 155 | eAIResponsePriority Priority; 156 | int TriggerRadius; 157 | int TriggerHeight; 158 | sAIPsdScr Response[8]; 159 | #if (_DARKGAME == 2) 160 | sAIPsdScr Response2[8]; 161 | #endif 162 | }; 163 | 164 | struct sFlinders 165 | { 166 | int Count; 167 | float Impulse; 168 | unsigned long Scatter; 169 | mxs_vector Offset; 170 | }; 171 | 172 | #pragma pack(push,1) 173 | struct sKeyProp 174 | { 175 | unsigned char bMasterBit; 176 | #if (_DARKGAME == 2) 177 | unsigned long iRegionMask; 178 | #else 179 | unsigned short iRegionMask; 180 | #endif 181 | unsigned char iLockID; 182 | }; 183 | #pragma pack(pop) 184 | 185 | #define ANIMLIGHT_FLIPMINMAX 0 186 | #define ANIMLIGHT_SLIDESMOOTHLY 1 187 | #define ANIMLIGHT_RANDOM 2 188 | #define ANIMLIGHT_MINBRIGHTNESS 3 189 | #define ANIMLIGHT_MAXBRIGHTNESS 4 190 | #define ANIMLIGHT_ZEROBRIGHTNESS 5 191 | #define ANIMLIGHT_SMOOTHLYBRIGHTEN 6 192 | #define ANIMLIGHT_SMOOTHLYDIM 7 193 | #define ANIMLIGHT_RANDOMBUTCOHERENT 8 194 | #define ANIMLIGHT_FLICKERMINMAX 9 195 | 196 | struct sAnimLight 197 | { 198 | int pad1; 199 | mxs_vector Offset; 200 | int pad2; 201 | unsigned short CellIndex; 202 | unsigned short CellCount; 203 | short LightID; 204 | unsigned short Mode; 205 | int TimeToBrighten; 206 | int TimeToDim; 207 | float MinBrightness; 208 | float MaxBrightness; 209 | float CurrentBrightness; 210 | unsigned long IsRising; 211 | int Countdown; 212 | unsigned long IsDisabled; 213 | float Radius; 214 | int pad3; 215 | unsigned long QuadLit; 216 | float InnerRadius; 217 | }; 218 | 219 | #endif // _LG_PROPS_H 220 | -------------------------------------------------------------------------------- /lg/lg/properties.h: -------------------------------------------------------------------------------- 1 | /************************** 2 | * LGS Property Interfaces 3 | */ 4 | 5 | #ifndef _LG_PROPERTIES_H 6 | #define _LG_PROPERTIES_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | 16 | struct sPropertyDesc 17 | { 18 | char szName[32]; 19 | char* pszParentMenu; 20 | char* pszMenuLabel; 21 | char unk1[8]; 22 | }; 23 | 24 | struct sPropertyTypeDesc 25 | { 26 | char szTypeName[32]; 27 | int iTypeSize; 28 | }; 29 | 30 | struct sPropertyObjIter 31 | { 32 | void* _a; 33 | unsigned long _b; 34 | void* _c; // cObjPropDatumHashTable 35 | }; 36 | 37 | // Alse the bitmask when registering a listener. 38 | enum ePropertyEvent 39 | { 40 | kPropertyChange = 1, 41 | kPropertyAdd = 2, 42 | kPropertyDelete = 4, 43 | // Don't know what 8 does, 44 | // sometimes shows up as event 11 which might be when a tagfile is loaded 45 | 46 | // These are only for registering 47 | kPropertyFull = 15, 48 | kPropertyRebuild = 0x30 // not sure how to use this 49 | }; 50 | struct sPropertyListenMsg 51 | { 52 | ePropertyEvent event; 53 | long lFlags; 54 | int iObjId; 55 | void* pData; // not necessarily a pointer 56 | //int ??? 57 | }; 58 | 59 | DECLARE_HANDLE(PropListenerHandle); 60 | DECLARE_HANDLE(PropListenerData); 61 | 62 | typedef void (__stdcall *PropListenFunc)(sPropertyListenMsg*,PropListenerData); 63 | 64 | extern const GUID IID_IProperty; 65 | interface IProperty : IUnknown 66 | { 67 | STDMETHOD_(const sPropertyDesc*,Describe)(void) const PURE; 68 | STDMETHOD_(int,GetID)(void) const PURE; 69 | STDMETHOD_(const sPropertyTypeDesc*,DescribeType)(void) const PURE; 70 | STDMETHOD_(long,Create)(int) PURE; 71 | STDMETHOD_(long,Copy)(int,int) PURE; 72 | STDMETHOD_(long,Delete)(int) PURE; 73 | STDMETHOD_(int,IsRelevant)(int) const PURE; 74 | STDMETHOD_(int,IsSimplyRelevant)(int) const PURE; 75 | STDMETHOD_(int,Touch)(int) PURE; 76 | STDMETHOD_(void,Notify)(unsigned long,void*) PURE; 77 | STDMETHOD_(PropListenerHandle,Listen)(unsigned long,PropListenFunc,PropListenerData) PURE; 78 | STDMETHOD_(long,Unlisten)(PropListenerHandle) PURE; 79 | STDMETHOD_(void,IterStart)(sPropertyObjIter*) const PURE; 80 | STDMETHOD_(int,IterNext)(sPropertyObjIter*,int*) const PURE; 81 | STDMETHOD_(void,IterStop)(sPropertyObjIter*) const PURE; 82 | }; 83 | DEFINE_IIDSTRUCT(IProperty,IID_IProperty) 84 | 85 | interface IGenericProperty : IProperty 86 | { 87 | STDMETHOD_(int,Set)(int,void*) PURE; 88 | STDMETHOD_(int,TouchValue)(int,void*) PURE; 89 | STDMETHOD_(int,Get)(int,void**) const PURE; 90 | STDMETHOD_(int,GetSimple)(int,void**) const PURE; 91 | STDMETHOD_(int,IterNextValue)(sPropertyObjIter*,int*,void**) const PURE; 92 | }; 93 | 94 | extern const GUID IID_IIntProperty; 95 | interface IIntProperty : IProperty 96 | { 97 | STDMETHOD_(int,Set)(int,int) PURE; 98 | STDMETHOD_(int,TouchValue)(int,int) PURE; 99 | STDMETHOD_(int,Get)(int,int*) PURE; 100 | STDMETHOD_(int,GetSimple)(int,int*) PURE; 101 | STDMETHOD_(int,IterNextValue)(sPropertyObjIter*,int*,int*) const PURE; 102 | }; 103 | 104 | extern const GUID IID_IBoolProperty; 105 | #define IBoolProperty IIntProperty 106 | 107 | extern const GUID IID_IFloatProperty; 108 | interface IFloatProperty : IProperty 109 | { 110 | STDMETHOD_(int,Set)(int,float) PURE; 111 | STDMETHOD_(int,TouchValue)(int,float) PURE; 112 | STDMETHOD_(int,Get)(int,float*) PURE; 113 | STDMETHOD_(int,GetSimple)(int,float*) PURE; 114 | STDMETHOD_(int,IterNextValue)(sPropertyObjIter*,int*,float*) const PURE; 115 | }; 116 | 117 | extern const GUID IID_IStringProperty; 118 | interface IStringProperty : IProperty 119 | { 120 | STDMETHOD_(int,Set)(int,const char*) PURE; 121 | STDMETHOD_(int,TouchValue)(int,const char*) PURE; 122 | STDMETHOD_(int,Get)(int,const char* *) PURE; 123 | STDMETHOD_(int,GetSimple)(int,const char**) PURE; 124 | STDMETHOD_(int,IterNextValue)(sPropertyObjIter*,int*,const char* *) const PURE; 125 | }; 126 | 127 | extern const GUID IID_IVectorProperty; 128 | interface IVectorProperty : IProperty 129 | { 130 | STDMETHOD_(int,Set)(int,const mxs_vector*) PURE; 131 | STDMETHOD_(int,TouchValue)(int,const mxs_vector*) PURE; 132 | STDMETHOD_(int,Get)(int,mxs_vector**) PURE; 133 | STDMETHOD_(int,GetSimple)(int,mxs_vector**) PURE; 134 | STDMETHOD_(int,IterNextValue)(sPropertyObjIter*,int*,mxs_vector**) const PURE; 135 | }; 136 | 137 | extern const GUID IID_ILabelProperty; 138 | 139 | extern const GUID IID_IInvRenderProperty; 140 | 141 | extern const GUID IID_IInvStringProperty; 142 | 143 | extern const GUID IID_IBrushProperty; 144 | 145 | extern const GUID IID_IGlobalIDProperty; 146 | 147 | extern const GUID IID_ITweqSimpleProperty; 148 | 149 | extern const GUID IID_ITweqSimpleStateProperty; 150 | 151 | extern const GUID IID_ITweqVectorProperty; 152 | 153 | extern const GUID IID_ITweqVectorStateProperty; 154 | 155 | // Specific properties. 156 | 157 | extern const GUID IID_IMovingTerrainProperty; 158 | 159 | extern const GUID IID_IPhysStateProperty; 160 | 161 | extern const GUID IID_IRendFlashProperty; 162 | 163 | extern const GUID IID_IScriptProperty; 164 | 165 | 166 | #endif // _LG_PROPERTIES_H 167 | -------------------------------------------------------------------------------- /lg/lg/quest.h: -------------------------------------------------------------------------------- 1 | #ifndef _LG_QUEST_H 2 | #define _LG_QUEST_H 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif 7 | 8 | extern const GUID IID_IQuestDataIter; 9 | interface IQuestDataIter : IUnknown 10 | { 11 | STDMETHOD_(int,Done)(void) PURE; 12 | STDMETHOD_(long,Next)(void) PURE; 13 | STDMETHOD_(const char*,Name)(void) PURE; 14 | STDMETHOD_(int,Value)(void) PURE; 15 | }; 16 | 17 | extern const GUID IID_IQuestData; 18 | interface IQuestData : IUnknown 19 | { 20 | STDMETHOD_(long,Create)(const char *,int) PURE; 21 | STDMETHOD_(long,Set)(const char *,int) PURE; 22 | STDMETHOD_(int,Get)(const char *) PURE; 23 | STDMETHOD_(int,Exists)(const char *) PURE; 24 | STDMETHOD_(long,Delete)(const char *) PURE; 25 | STDMETHOD_(IQuestDataIter*,Iter)(int) PURE; 26 | STDMETHOD_(long,DeleteAll)(void) PURE; 27 | STDMETHOD_(long,DeleteAllType)(int) PURE; 28 | STDMETHOD_(int,Save)(long (__cdecl *)(void *,unsigned int,unsigned int),int) PURE; 29 | STDMETHOD_(int,Load)(long (__cdecl *)(void *,unsigned int,unsigned int),int) PURE; 30 | STDMETHOD_(long,SubscribeMsg)(int,const char *,int) PURE; 31 | STDMETHOD_(long,UnsubscribeMsg)(int,const char *) PURE; 32 | STDMETHOD_(long,ObjDeleteListener)(int) PURE; 33 | STDMETHOD_(long,UnsubscribeAll)(void) PURE; 34 | STDMETHOD_(long,ObjSpewListen)(int) PURE; 35 | STDMETHOD_(long,Filter)(int (__cdecl *)(const char *,int,int),void *) PURE; 36 | }; 37 | DEFINE_IIDSTRUCT(IQuestData,IID_IQuestData) 38 | 39 | extern const GUID IID_ICampaign ; 40 | 41 | #endif // _LG_QUEST_H 42 | -------------------------------------------------------------------------------- /lg/lg/res.h: -------------------------------------------------------------------------------- 1 | 2 | extern const GUID IID_IRes; 3 | interface IRes : IUnknown 4 | { 5 | virtual void* Lock(void) = 0; 6 | virtual void Unlock(void) = 0; 7 | }; 8 | /* 9 | int ExtractPartial(long,long,void*) 10 | int HasSetData(void) 11 | unsigned int GetLockCount(void) 12 | unsigned long GetManData(void) 13 | IStore* GetStore(void) 14 | void* LoadData(unsigned long*, unsigned long*, IResMemOverride*) 15 | void* Extract(void*) 16 | void* LoadTranslation(void*, long,const char*,int*,unsigned long*,IResMemOverride*) 17 | void* DataPeek(void) 18 | void* PreLoad(void) 19 | const char* GetName(void) 20 | void GetVariant(char**) 21 | void SetCanonStore(IStore*) 22 | void SetName(const char*) 23 | void Unlock(void) 24 | int AsyncLock(int) 25 | int AsyncExtract(int, void*, long) 26 | int SetStore(IStore*) 27 | int FreeData(void*,long,IResMemOverride*) 28 | int AsyncPreload(void) 29 | int Drop(void) 30 | int IsAsyncFulfilled(void) 31 | long GetAsyncResult(void**) 32 | long GetSize(void) 33 | long AsyncKill(void) 34 | unsigned long GetAppData(void) 35 | char** GetTranslatableTypes(int*) 36 | IResType* GetType(void) 37 | IStore* GetcanonStore(void) 38 | IStoreStream* OpenStream(void) 39 | void* Lock(void) 40 | void AllowStorageReset(int) 41 | void GetStreamName(int,char**) 42 | void SetAppData(unsigned long) 43 | void SetManData(unsigned long) 44 | void GetCanonPathName(char**) 45 | void GetCanonPath(char**) 46 | void SetData(void*) 47 | void ExtractBlocks(void*, long, long (*)(IRes*,void*,long,long,void*),void*) 48 | */ 49 | extern const GUID IID_IResControl; 50 | extern const GUID IID_IResHack; 51 | extern const GUID IID_IResMem; 52 | extern const GUID IID_IResMemOverride; 53 | extern const GUID IID_IResStats; 54 | extern const GUID IID_IResType; 55 | interface IResType : IUnknown 56 | { 57 | virtual char const * GetName(void) = 0; 58 | virtual void EnumerateExts(void (__cdecl *)(char const *, IResType *, void *), void *) = 0; 59 | virtual int IsLegalExt(char const *) = 0; 60 | virtual IRes * CreateRes(IStore *, char const *, char const *, IResMemOverride **) = 0; 61 | }; 62 | 63 | extern const GUID IID_ISearchPath; 64 | interface ISearchPath : IUnknown 65 | { 66 | STDMETHOD_(void,Clear)(void) PURE; 67 | STDMETHOD_(ISearchPath*,Copy)(void) PURE; 68 | STDMETHOD_(void,AddPath)(const char *) PURE; 69 | STDMETHOD_(void,AddPathTrees)(const char *,int) PURE; 70 | STDMETHOD_(void,Ready)(void) PURE; 71 | }; 72 | /* 73 | STDMETHOD_(int,Next)(void*,IStore**,char*,char*) PURE; 74 | STDMETHOD_(IStore*,Find)(const char*,unsigned int,IStore**,const char*) PURE; 75 | STDMETHOD_(void*,BeginContents)(const char*,unsigned int,const char*) PURE; 76 | STDMETHOD_(void,Iterate)(void (__cdecl *)(ISearchPath*,const char*,int,void*)int,void*) PURE; 77 | STDMETHOD_(void,SetContext)(ISearchPath*) PURE; 78 | STDMETHOD_(void,SetVariants)(ISearchPath*) PURE; 79 | STDMETHOD_(void,EndContents)(void*) PURE; 80 | */ 81 | 82 | extern const GUID IID_IStringRes ; 83 | -------------------------------------------------------------------------------- /lg/lg/script.h: -------------------------------------------------------------------------------- 1 | /******************************* 2 | * LGS Script and Script Module 3 | */ 4 | 5 | #ifndef _LG_SCRIPT_H 6 | #define _LG_SCRIPT_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | 19 | extern const GUID IID_IScriptModule; 20 | interface IScriptModule : IUnknown 21 | { 22 | STDMETHOD_(const char*,GetName)(void) PURE; 23 | STDMETHOD_(const sScrClassDesc*,GetFirstClass)(tScrIter*) PURE; 24 | STDMETHOD_(const sScrClassDesc*,GetNextClass)(tScrIter*) PURE; 25 | STDMETHOD_(void,EndClassIter)(tScrIter*) PURE; 26 | }; 27 | DEFINE_IIDSTRUCT(IScriptModule,IID_IScriptModule) 28 | 29 | 30 | extern const GUID IID_IScript; 31 | interface IScript : IUnknown 32 | { 33 | STDMETHOD_(const char*,GetClassName)(void) PURE; 34 | STDMETHOD_(long,ReceiveMessage)(sScrMsg *,sMultiParm *,eScrTraceAction) PURE; 35 | }; 36 | DEFINE_IIDSTRUCT(IScript,IID_IScript) 37 | 38 | #endif // _LG_SCRIPT_H 39 | -------------------------------------------------------------------------------- /lg/lg/sound.h: -------------------------------------------------------------------------------- 1 | /********************** 2 | * LGS Sound 3 | */ 4 | 5 | #ifndef _LG_SOUND_H 6 | #define _LG_SOUND_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | extern const GUID IID_ICDPlayer; 16 | interface ICDPlayer : IUnknown 17 | { 18 | STDMETHOD_(long,Init)(void) PURE; 19 | STDMETHOD_(long,CDPlayTrack)(int) PURE; 20 | STDMETHOD_(long,CDStopPlay)(void) PURE; 21 | STDMETHOD_(long,CDSetBGMTrack)(int) PURE; 22 | STDMETHOD_(long,CDPlayTransition)(int,unsigned int) PURE; 23 | STDMETHOD_(long,Update)(void) PURE; 24 | virtual void * __thiscall d0(unsigned int) = 0; 25 | STDMETHOD_(long,CDOpen)(LPMCI_OPEN_PARMS) PURE; 26 | STDMETHOD_(long,CheckBGM)(void) PURE; 27 | }; 28 | DEFINE_IIDSTRUCT(ICDPlayer,IID_ICDPlayer) 29 | 30 | interface ISong; 31 | 32 | extern const GUID IID_ISongPlayer; 33 | interface ISongPlayer : IUnknown 34 | { 35 | STDMETHOD_(int,SetSong)(ISong*) PURE; 36 | STDMETHOD_(void,GetSong)(ISong**) PURE; 37 | STDMETHOD_(void,UnloadSong)(void) PURE; 38 | STDMETHOD_(int,StartPlaying)(void) PURE; 39 | STDMETHOD_(int,StopPlaying)(void) PURE; 40 | STDMETHOD_(int,PausePlaying)(void) PURE; 41 | STDMETHOD_(int,ResumePlaying)(void) PURE; 42 | STDMETHOD_(void,SetVolume)(int) PURE; 43 | STDMETHOD_(int,GetVolume)(void) PURE; 44 | STDMETHOD_(int,SendEvent)(char const*, int) PURE; 45 | STDMETHOD_(void,SetThemed)(int) PURE; 46 | STDMETHOD_(int,IsThemed)(void) PURE; 47 | STDMETHOD_(int,SetTheme)(char const*) PURE; 48 | STDMETHOD_(void,GetMemento)(void**, int*) PURE; 49 | STDMETHOD_(int,RestoreMemento)(void*, int) PURE; 50 | }; 51 | DEFINE_IIDSTRUCT(ISongPlayer,IID_ISongPlayer) 52 | 53 | extern const GUID IID_IVoiceOverSys; 54 | interface IVoiceOverSys : IUnknown 55 | { 56 | STDMETHOD_(int,Play)(int) PURE; 57 | STDMETHOD_(int,AlreadyPlayed)(int) PURE; 58 | STDMETHOD_(long,SetAlreadyPlayed)(int,int) PURE; 59 | STDMETHOD_(long,SetCombatTest)(int (__stdcall *)(void)) PURE; 60 | }; 61 | 62 | #endif // _LG_SOUND_H 63 | -------------------------------------------------------------------------------- /lg/lg/stamp-20090113: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NamelessVoice/NVScript/72866513b1f42a91e1620aa50c9e6bcd7ff68b90/lg/lg/stamp-20090113 -------------------------------------------------------------------------------- /lg/lg/tools.h: -------------------------------------------------------------------------------- 1 | /********************** 2 | * LGS Script Tools 3 | */ 4 | 5 | #ifndef _LG_TOOLS_H 6 | #define _LG_TOOLS_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | interface IStringProperty; 18 | 19 | 20 | extern const GUID IID_IGameStrings; 21 | interface IGameStrings : IUnknown 22 | { 23 | // filename, stringname, ???, resname 24 | STDMETHOD_(cAnsiStr*,FetchString)(cAnsiStr&,const char*,const char*,const char*,const char*) PURE; 25 | // Bind a resname to a property 26 | STDMETHOD_(long,RegisterProp)(const char*,IStringProperty*) PURE; 27 | // object id, resname (as used in RegisterProp) 28 | STDMETHOD_(cAnsiStr*,FetchObjString)(cAnsiStr&,int,const char*) PURE; 29 | STDMETHOD_(long,DumpProp)(const char*) PURE; 30 | STDMETHOD_(long,LoadProp)(const char*) PURE; 31 | STDMETHOD_(long,StripProp)(const char*) PURE; 32 | STDMETHOD_(long,ModernizeProp)(const char*) PURE; 33 | }; 34 | DEFINE_IIDSTRUCT(IGameStrings,IID_IGameStrings) 35 | 36 | extern const GUID IID_IGameTools; 37 | typedef int (__cdecl *IsToGameModeGUIDCallbackFunc)(const _GUID&); 38 | interface IGameTools : IUnknown 39 | { 40 | STDMETHOD_(int,IsToGameModeGUID)(const _GUID&) PURE; 41 | STDMETHOD_(long,SetIsToGameModeGUIDCallback)(IsToGameModeGUIDCallbackFunc) PURE; 42 | STDMETHOD_(long,TeleportObject)(int,const mxs_vector*,const mxs_angvec*,int) PURE; 43 | }; 44 | DEFINE_IIDSTRUCT(IGameTools,IID_IGameTools) 45 | 46 | extern const GUID IID_IStructDescTools; 47 | interface IStructDescTools : IUnknown 48 | { 49 | STDMETHOD_(const sFieldDesc*,GetFieldNamed)(const sStructDesc*,const char*) PURE; 50 | STDMETHOD_(long,ParseField)(const sFieldDesc*,const char*,void*) PURE; 51 | STDMETHOD_(long,UnparseField)(const sFieldDesc*,const void*,char*,int) PURE; 52 | STDMETHOD_(int,IsSimple)(const sStructDesc*) PURE; 53 | STDMETHOD_(int,ParseSimple)(const sStructDesc*,const char*,void*) PURE; 54 | STDMETHOD_(int,UnparseSimple)(const sStructDesc*,const void*,char*,int) PURE; 55 | STDMETHOD_(int,ParseFull)(const sStructDesc*,const char*,void*) PURE; 56 | STDMETHOD_(int,UnparseFull)(const sStructDesc*,const void*,char*,int) PURE; 57 | STDMETHOD_(long,Dump)(const sStructDesc*,const void*) PURE; 58 | STDMETHOD_(long,SetIntegral)(const sFieldDesc*,long,void*) PURE; 59 | STDMETHOD_(long,GetIntegral)(const sFieldDesc*,const void*,long*) PURE; 60 | STDMETHOD_(const sStructDesc*,Lookup)(const char*) PURE; 61 | STDMETHOD_(long,Register)(const sStructDesc*) PURE; 62 | STDMETHOD_(long,ClearRegistry)(void) PURE; 63 | }; 64 | DEFINE_IIDSTRUCT(IStructDescTools,IID_IStructDescTools) 65 | 66 | #endif // _LG_TOOLS_H 67 | -------------------------------------------------------------------------------- /lg/lg/win.h: -------------------------------------------------------------------------------- 1 | /********************** 2 | * LGS Windows Host 3 | */ 4 | 5 | #ifndef _LG_WIN_H 6 | #define _LG_WIN_H 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif 11 | 12 | #include "lg/objstd.h" 13 | #include 14 | #include "lg/graphics.h" 15 | 16 | 17 | interface IApplication : IUnknown 18 | { 19 | }; 20 | /* 21 | int IWindowsApplication::CriticalMessageBox(const char*,const char*,int); 22 | int IWindowsApplication::MessageBoxA(const char*,const char*,int); 23 | long IWindowsApplication::Unadvise(unsigned long); 24 | long IWindowsApplication::QueryQuit(void); 25 | const char* IWindowsApplication::GetCaption(void); 26 | const char* IWindowsApplication::GetDefaultFilePath(void); 27 | const char* IWindowsApplication::GetPath(void); 28 | const char* IWindowsApplication::GetFullName(void); 29 | void IWindowsApplication::AppCommand(unsigned int); 30 | void IWindowsApplication::Abort(const char*); 31 | void IWindowsApplication::SetCaption(const char*); 32 | void IWindowsApplication::SetDefaultFilePath(const char*); 33 | void IWindowsApplication::Quit(void); 34 | */ 35 | 36 | extern const GUID IID_IWinApp; 37 | 38 | enum eWinPumpResult 39 | { 40 | kWinPumpResult0 41 | }; 42 | enum eWinPumpDuration 43 | { 44 | kWinPumpDuration0 45 | }; 46 | 47 | interface IWinApp : IUnknown 48 | { 49 | STDMETHOD_(HWND,GetMainWnd)(void) PURE; 50 | STDMETHOD_(HWND,SetMainWnd)(HWND) PURE; 51 | STDMETHOD_(HINSTANCE,GetResourceInstance)(void) PURE; 52 | virtual int f1() = 0; 53 | STDMETHOD_(const char*,GetCommandLine)(void) PURE; 54 | STDMETHOD_(int,GetCommandShow)(void) PURE; 55 | STDMETHOD_(void,SetRegistryKey)(const char*) PURE; 56 | STDMETHOD_(const char*,GetRegistryKey)(void) PURE; 57 | STDMETHOD_(void,SetProfileName)(const char*) PURE; 58 | STDMETHOD_(const char*,GetProfileName)(void) PURE; 59 | STDMETHOD_(void,SetDialogBkColor)(unsigned long,unsigned long) PURE; 60 | STDMETHOD_(eWinPumpResult,PumpEvents)(int,eWinPumpDuration) PURE; 61 | STDMETHOD_(long,ModalDialogBox)(const char*,DLGPROC) PURE; 62 | virtual int f2() = 0; 63 | virtual int f3() = 0; 64 | }; 65 | DEFINE_IIDSTRUCT(IWinApp,IID_IWinApp) 66 | 67 | /* 68 | STDMETHOD_(int,BreakLock)(void) PURE; 69 | STDMETHOD_(void,GetKind2)(eDisplayDeviceKind*,int*,_GUID**) PURE; 70 | STDMETHOD_(int,SetGamma)(double) PURE; 71 | STDMETHOD_(long,Open)(grs_drvcap*,int) PURE; 72 | STDMETHOD_(int,SetMonitor)(void**,eDisplayDeviceMonitorFlag) PURE; 73 | STDMETHOD_(void,SetKind2)(eDisplayDeviceKind,_GUID*) PURE; 74 | STDMETHOD_(long,GetRenderTargets)(sGrRenderTargets*) PURE; 75 | STDMETHOD_(int,SetFlip)(int) PURE; 76 | STDMETHOD_(void,RestoreLock)(int) PURE; 77 | STDMETHOD_(int,IsLocked)(void) PURE; 78 | STDMETHOD_(void,FlushRect)(int,int,int,int) PURE; 79 | */ 80 | extern const GUID IID_IWinDisplayDevice; 81 | struct sWinDispDevCallbackInfo 82 | { 83 | }; 84 | typedef void (__cdecl *TaskSwitchCallbackFunc)(sWinDispDevCallbackInfo*); 85 | interface IWinDispDevice : IUnknown 86 | { 87 | STDMETHOD_(int,ProcessMessage)(unsigned int,unsigned int,long,long*) PURE; 88 | STDMETHOD_(void,GetWidthHeight)(unsigned int*,unsigned int*) PURE; 89 | STDMETHOD_(void,OnTaskSwitch)(int) PURE; 90 | STDMETHOD_(int,GetDirectDraw)(IDirectDraw4**) PURE; 91 | STDMETHOD_(void,WaitForMutex)(void) PURE; 92 | STDMETHOD_(void,ReleaseMutex)(void) PURE; 93 | STDMETHOD_(void,CursorBltFromGDIScreen)(grs_bitmap*,int,int) PURE; 94 | STDMETHOD_(void,CursorBltToGDIScreen)(grs_bitmap*,int,int) PURE; 95 | STDMETHOD_(int,GetBitmapSurface)(grs_bitmap*,IDirectDrawSurface4**) PURE; 96 | STDMETHOD_(void,AddTaskSwitchCallback)(TaskSwitchCallbackFunc) PURE; 97 | STDMETHOD_(void,RemoveTaskSwitchCallback)(int) PURE; 98 | }; 99 | DEFINE_IIDSTRUCT(IWinDispDevice,IID_IWinDisplayDevice) 100 | 101 | extern const GUID IID_IGameShell; 102 | interface IWinGameShell : IUnknown 103 | { 104 | STDMETHOD_(void,BeginFrame)(void) PURE; 105 | STDMETHOD_(void,EndFrame)(void) PURE; 106 | STDMETHOD_(long,BringToFront)(void) PURE; 107 | }; 108 | 109 | #endif // _LG_WIN_H 110 | -------------------------------------------------------------------------------- /lg/lg2007-changes.txt: -------------------------------------------------------------------------------- 1 | IAIScrSrv::MakeFrobObjWith(true_bool &,int,const object &,const object &,eAIActionPriority,const cMultiParm &) 2 | IAIScrSrv::MakeFrobObj(true_bool &,int,const object &,eAIActionPriority,const cMultiParm &) 3 | ILinkSrv::BroadcastOnAllLinks(const object &,const char *,linkkind) 4 | ILinkSrv::BroadcastOnAllLinksData(const object &,const char *,linkkind,const cMultiParm &) 5 | IPropertySrv::Set(object,const char *,const char *,const cMultiParm &) 6 | IPropertySrv::SetSimple(object,const char *,const cMultiParm &) 7 | IShockGameSrv::CreatePlayerPuppet(const cScrStr &) 8 | IShockGameSrv::CreatePlayerPuppetDefault(void) 9 | ISoundScrSrv::PlayAtLocation(true_bool&,object,const cScrStr &,const cScrVec &,eSoundSpecial SOUND_NET) 10 | ISoundScrSrv::PlayAtObject(true_bool&,object,const cScrStr &,object,eSoundSpecial SOUND_NET) 11 | ISoundScrSrv::Play(true_bool&,object,const cScrStr &,eSoundSpecial SOUND_NET) 12 | ISoundScrSrv::PlayAmbient(true_bool&,object,const cScrStr &,eSoundSpecial SOUND_NET) 13 | ISoundScrSrv::PlaySchemaAtLocation(true_bool &,object,object,const cScrVec & SOUND_NET) 14 | ISoundScrSrv::PlaySchemaAtObject(true_bool &,object,object,object SOUND_NET) 15 | ISoundScrSrv::PlaySchema(true_bool &,object,object SOUND_NET) 16 | ISoundScrSrv::PlaySchemaAmbient(true_bool &,object,object SOUND_NET) 17 | 18 | -------------------------------------------------------------------------------- /lg/scrmsgs.cpp: -------------------------------------------------------------------------------- 1 | #include "lg/objstd.h" 2 | #include "lg/interface.h" 3 | #include "lg/types.h" 4 | #include "lg/scrmsgs.h" 5 | 6 | extern IMalloc* g_pMalloc; 7 | 8 | 9 | /* 10 | * So just what does sPersistent do anyway, and why do we need it? 11 | * 12 | * The sPersistent class (not related to the OLE IPersist class) allows 13 | * class data to be streamed out to a file (or some file-like object) 14 | * and later streamed back in. A class that needs to be streamed implements 15 | * sPersist::Persistence. When called, it is supposed to call a 16 | * static function pointer (gm_pfnIO) with a static context pointer (gm_pContextIO) 17 | * and the address and size of the data that will be read or written. 18 | * Another static flag (gm_fReading) tells which way the data is going, 19 | * though for simple structures it's not necessary differentiate. 20 | * 21 | * Those static members are what makes it impossible (or, at least, very-very difficult) 22 | * to implement sPersistent from a script. 23 | * 24 | * But where does Thief/SShock use sPersist? I can't actually find where script 25 | * messages are streamed to, if at all. Which makes me wonder if the persistence 26 | * of sScrMsg is a feature that was never actually used. If this is indeed the case, 27 | * then it doesn't matter that our sPersist implementation is a no-op. 28 | * 29 | * If the persistence is being used, then the most obvious places are when a SAV 30 | * database is being written (but, as I said, I've never seen message data in a SAV), 31 | * or when the sim is interrupted, such as a missloop state change (i.e. book mode). 32 | * 33 | * The most telling thing I can think of is that when I create my own script messages, 34 | * they appear to work just fine. 35 | */ 36 | 37 | #ifndef _MSC_VER 38 | //////////////////// 39 | // sPersistent hack 40 | //////////////////// 41 | 42 | /* Thankfully, none of these have arguments. 43 | * Otherwise, it'd be a hell of a lot more complicated 44 | * to deal with the stack. 45 | */ 46 | static int hackPersistent_Persistence() 47 | { 48 | register sScrMsg* msg; 49 | #ifdef __GNUC__ 50 | asm ("movl %%ecx,%0\n\tsubl $0x8,%0" : "=r" (msg) : : "ecx" ); 51 | #else 52 | /* I need TASM32 53 | asm { 54 | mov msg,ecx 55 | sub msg,8 56 | } 57 | */ 58 | return 0; 59 | #endif 60 | return msg->Persistence(); 61 | } 62 | 63 | static const char* hackPersistent_GetName() 64 | { 65 | register sScrMsg* msg; 66 | #ifdef __GNUC__ 67 | asm ("movl %%ecx,%0\n\tsubl $0x8,%0" : "=r" (msg) : : "ecx" ); 68 | #else 69 | /* 70 | asm { 71 | mov msg,ecx 72 | sub msg,8 73 | } 74 | */ 75 | return NULL; 76 | #endif 77 | return msg->GetName(); 78 | } 79 | 80 | static void hackPersistent_dtor(void*) 81 | { 82 | // Hopefully, this will never actually be called. 83 | } 84 | 85 | static sPersistent_vtable hackPersistent_vtable = { 86 | hackPersistent_dtor, 87 | hackPersistent_Persistence, 88 | hackPersistent_GetName 89 | }; 90 | #endif 91 | 92 | 93 | /////////////// 94 | // sScrMsgBase 95 | /////////////// 96 | HRESULT __stdcall sScrMsgBase::QueryInterface(REFIID riid, void** ppv) 97 | { 98 | if (riid == IID_IUnknown) 99 | *ppv = (IUnknown*)this; 100 | else { 101 | *ppv = NULL; 102 | return E_NOINTERFACE; 103 | } 104 | return S_OK; 105 | } 106 | ULONG __stdcall sScrMsgBase::AddRef() 107 | { 108 | return InterlockedIncrement((LONG*)&m_iRef); 109 | } 110 | ULONG __stdcall sScrMsgBase::Release() 111 | { 112 | ULONG uRefCnt = InterlockedDecrement((LONG*)&m_iRef); 113 | if (uRefCnt == 0) 114 | delete this; 115 | return uRefCnt; 116 | } 117 | 118 | 119 | /////////// 120 | // sScrMsg 121 | /////////// 122 | 123 | sScrMsg::~sScrMsg() 124 | { 125 | } 126 | 127 | sScrMsg::sScrMsg() { 128 | m_iRef = 1; 129 | // Make sure everything is initialized 130 | #ifndef _MSC_VER 131 | persistent_hack = &hackPersistent_vtable; 132 | #endif 133 | from = 0; 134 | to = 0; 135 | message = NULL; 136 | time = 0; 137 | flags = 0; 138 | data.type = kMT_Undef; 139 | data2.type = kMT_Undef; 140 | data3.type = kMT_Undef; 141 | } 142 | 143 | #ifndef _MSC_VER 144 | int sScrMsg::Persistent_Persistence(void) 145 | { 146 | register int retval; 147 | #ifdef __GNUC__ 148 | asm ( 149 | "\txor %0,%0\n" 150 | "\tmovl %1,%%ecx\n" 151 | "\taddl $0x8,%%ecx\n" 152 | "\tmovl (%%ecx),%%edx\n" 153 | "\ttest %%edx,%%edx\n" 154 | "\tje l1\n" 155 | "\tcmp $0xCCCCCCCC,%%edx\n" 156 | "\tje l1\n" 157 | "\tcall *0x4(%%edx)\n" 158 | "l1:\t\n" 159 | : "=a" (retval) : "g" (this) : "ecx","edx" ); 160 | #else 161 | /* 162 | asm { 163 | xor eax,eax 164 | mov ecx,this 165 | add ecx,8 166 | mov edx,dword ptr [ecx] 167 | test edx,edx 168 | je l1 169 | cmp edx,0xCCCCCCCC 170 | je l1 171 | call dword ptr [edx+4] 172 | move retval,eax 173 | l1: 174 | } 175 | */ 176 | return 0; 177 | #endif 178 | return retval; 179 | } 180 | 181 | const char* sScrMsg::Persistent_GetName(void) const 182 | { 183 | register const char* retval; 184 | #ifdef __GNUC__ 185 | // bleh... GCC is tossing the retval initialization 186 | asm ( 187 | "\tmovl %2,%0\n" 188 | "\tmovl %1,%%ecx\n" 189 | "\taddl $0x8,%%ecx\n" 190 | "\tmovl (%%ecx),%%edx\n" 191 | "\ttest %%edx,%%edx\n" 192 | "\tje l2\n" 193 | "\tcmp $0xCCCCCCCC,%%edx\n" 194 | "\tje l2\n" 195 | "\tcall *0x8(%%edx)\n" 196 | "l2:\t\n" 197 | : "=a" (retval) : "g" (this) , "g" ("") : "ecx","edx" ); 198 | #else 199 | /* 200 | retval = ""; 201 | asm { 202 | mov ecx,this 203 | add ecx,8 204 | mov edx,dword ptr [ecx] 205 | test edx,edx 206 | je l2 207 | cmp edx,0xCCCCCCCC 208 | je l2 209 | call dword ptr [edx+8] 210 | move retval,eax 211 | l2: 212 | } 213 | */ 214 | return NULL; 215 | #endif 216 | return retval; 217 | } 218 | #endif 219 | 220 | -------------------------------------------------------------------------------- /lg/timestamp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | s=$1 4 | shift 5 | 6 | t="00000000" 7 | 8 | checktime() 9 | { 10 | m=`date -r $1 +%Y%m%d` 11 | if [ $m -gt $t ]; then 12 | t=$m 13 | fi 14 | } 15 | 16 | while [ $# -gt 0 ]; do 17 | if [ -d $1 ]; then 18 | for f in $1/* ; do 19 | case $f in 20 | $1/stamp-*) 21 | ;; 22 | *) 23 | checktime $f 24 | ;; 25 | esac 26 | done 27 | else 28 | checktime $1 29 | fi 30 | shift 31 | done 32 | 33 | echo -n > $s/stamp-$t 34 | --------------------------------------------------------------------------------