diff --git a/.editorconfig b/.editorconfig
index dd89059..27e3ede 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -8,4 +8,5 @@ root = true
[*]
indent_style = tab
indent_size = 4
+trim_trailing_whitespace = true
insert_final_newline = true
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000..060cce7
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,164 @@
+name: C/C++ CI
+
+on:
+ push:
+ branches: [master]
+ paths-ignore:
+ - '**.md'
+
+ pull_request:
+ types: [opened, reopened, synchronize]
+ release:
+ types: [published]
+
+jobs:
+ windows:
+ name: 'Windows'
+ runs-on: windows-2019
+
+ env:
+ solution: 'msvc/metamod.sln'
+ buildPlatform: 'Win32'
+ buildRelease: 'Release'
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - name: Setup MSBuild
+ uses: microsoft/setup-msbuild@v1.0.2
+
+ - name: Build
+ run: |
+ msbuild ${{ env.solution }} -p:Configuration="${{ env.buildRelease }}" /t:Clean,Build /p:Platform=${{ env.buildPlatform }} /p:PlatformToolset=v142
+
+ - name: Move files
+ run: |
+ mkdir publish\debug
+ mkdir publish\addons\metamod
+
+ move msvc\${{ env.buildRelease }}\metamod.dll publish\addons\metamod\metamod.dll
+ move msvc\${{ env.buildRelease }}\metamod.pdb publish\debug\metamod.pdb
+
+ - name: Deploy artifacts
+ uses: actions/upload-artifact@v2
+ with:
+ name: win32
+ path: publish/*
+
+ linux:
+ name: 'Linux'
+ runs-on: ubuntu-latest
+ container: s1lentq/linux86buildtools:latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+
+ - name: Build using Intel C++ Compiler 19.0
+ run: |
+ rm -rf build && CC=icc CXX=icpc cmake -DCMAKE_BUILD_TYPE=COMPAT_GLIBC -B build && cmake --build build -j8
+
+ - name: Prepare SDK
+ run: |
+ mkdir -p publish/sdk
+ mkdir -p publish/addons/metamod
+ rsync -a \
+ --include=dllapi.h \
+ --include=engine_api.h \
+ --include=enginecallbacks.h \
+ --include=h_export.h \
+ --include=meta_api.h \
+ --include=mutil.h \
+ --include=plinfo.h \
+ --exclude='*' metamod/src/ publish/sdk
+ rsync metamod/extra/config.ini publish/addons/metamod
+ rsync -a metamod/extra/example/ publish/example_plugin
+ rsync -a publish/sdk/ publish/example_plugin/include/metamod
+
+ - name: Move files
+ run: |
+ mv build/metamod/metamod_i386.so publish/addons/metamod/metamod_i386.so
+ mv metamod/version/appversion.h publish/appversion.h
+
+ - name: Run GLIBC/ABI version compat test
+ run: |
+ binaries=(
+ "publish/addons/metamod/metamod_i386.so"
+ )
+ bash ./metamod/version/glibc_test.sh ${binaries[@]}
+ if [[ $? -ne 0 ]]; then
+ exit 1 # Assertion failed
+ fi
+ shell: bash
+
+ - name: Deploy artifacts
+ uses: actions/upload-artifact@v2
+ id: upload-job
+ with:
+ name: linux32
+ path: publish/*
+
+ - name: Cleanup temporary artifacts
+ if: success() && steps.upload-job.outcome == 'success'
+ run: |
+ rm -f appversion.h
+
+ publish:
+ name: 'Publish'
+ runs-on: ubuntu-latest
+ needs: [windows, linux]
+
+ steps:
+ - name: Deploying linux artifacts
+ uses: actions/download-artifact@v2
+ with:
+ name: linux32
+
+ - name: Deploying windows artifacts
+ uses: actions/download-artifact@v2
+ with:
+ name: win32
+
+ - name: Reading appversion.h
+ run: |
+ if [ -e appversion.h ]; then
+ APP_VERSION=$(cat appversion.h | grep -wi '#define APP_VERSION_STRD' | sed -e 's/#define APP_VERSION_STRD[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g')
+ if [ $? -ne 0 ]; then
+ APP_VERSION=""
+ else
+ # Remove quotes
+ APP_VERSION=$(echo $APP_VERSION | xargs)
+ echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV
+ fi
+ fi
+ rm -f appversion.h
+
+ - name: Packaging binaries
+ id: packaging-job
+ if: |
+ github.event_name == 'release' &&
+ github.event.action == 'published' &&
+ startsWith(github.ref, 'refs/tags/')
+ run: |
+ 7z a -tzip metamod-bin-${{ env.APP_VERSION }}.zip addons/ example_plugin/ sdk/
+
+ - name: Publish artifacts
+ uses: softprops/action-gh-release@v1
+ id: publish-job
+ if: |
+ startsWith(github.ref, 'refs/tags/') &&
+ steps.packaging-job.outcome == 'success'
+ with:
+ files: |
+ *.zip
+
+ - name: Cleanup temporary artifacts
+ if: success() && steps.publish-job.outcome == 'success'
+ run: |
+ rm -rf addons debug example_plugin sdk
+ rm -f *.zip appversion.h
diff --git a/.gitignore b/.gitignore
index d351090..b5613a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,4 @@
**/build
-**/.gradle
-.idea
-*.iml
*.bat
**/msvc/Debug*
**/msvc/Release*
@@ -19,5 +16,5 @@
**/PublishPath*.txt
**/*.log
+metamod/version/appversion.h
publish
-**/appversion.h
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..ebd5f6e
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.1)
+project(metamod CXX)
+
+if (WIN32)
+ message(FATAL_ERROR "CMakeLists.txt Windows platform isn't supported yet. Use msvc/metamod.sln instead it!")
+endif()
+
+add_custom_target(appversion DEPENDS
+ COMMAND "${PROJECT_SOURCE_DIR}/metamod/version/appversion.sh" "${PROJECT_SOURCE_DIR}"
+)
+
+add_subdirectory(metamod)
diff --git a/README.md b/README.md
index f85e6c2..2e98fc9 100644
--- a/README.md
+++ b/README.md
@@ -1,34 +1,94 @@
-# metamod-r
-
-
-**Metamod-r** is based on the original version of [Metamod](http://metamod.org/) written by _Will Day_ for Half-Life 1 with some improvements from [Jussi Kivilinna](https://github.com/jkivilin) ([Metamod-p](https://github.com/jkivilin/metamod-p)). This product contains a large number of performance optimizations and more pure code. The core was written using JIT compiler.
+# Metamod-r [](https://github.com/theAsmodai/metamod-r/releases/latest) []() [](http://isitmaintained.com/project/theAsmodai/metamod-r "Percentage of issues still open") [](https://www.gnu.org/licenses/gpl-3.0)
+**Metamod-r** is based on the original version of [Metamod](http://metamod.org/) written by _Will Day_ for Half-Life 1 with some improvements from [Jussi Kivilinna](https://github.com/jkivilin) ([Metamod-p](https://github.com/jkivilin/metamod-p)). This product contains a large number of performance optimizations and more pure code. The core was written using JIT compiler.
**Metamod-r is incompatible with original `HLDS`. It's necessary to have installed [ReHLDS](https://github.com/dreamstalker/ReHLDS) (`API 3.1+`). There is no guarantee that the product will work in a different environment.**
-|HLDS | [ReHLDS](https://github.com/dreamstalker/ReHLDS) | OS | Download |
-|---------| -------| --- | --- |
-| :x: | `API 3.1+` |  | [](http://teamcity.rehlds.org/guestAuth/downloadArtifacts.html?buildTypeId=Metamod_Publish&buildId=lastSuccessful)
+|HLDS | [ReHLDS](https://github.com/dreamstalker/ReHLDS) | OS | Download |
+|---------| -------| --- | --- |
+| :x: | `API 3.1+` |  | [](https://github.com/theAsmodai/metamod-r/releases/latest)
[](https://metamod-r.org/)
[](https://github.com/theAsmodai/metamod-r/)
-[](http://teamcity.rehlds.org/viewType.html?buildTypeId=Metamod_Publish&guest=1)
-[](https://github.com/theAsmodai/metamod-r/issues)
-[](https://github.com/theAsmodai/metamod-r/network)
-[](https://github.com/theAsmodai/metamod-r/stargazers)
+[](https://github.com/theAsmodai/metamod-r/issues)
+[](https://github.com/theAsmodai/metamod-r/network)
+[](https://github.com/theAsmodai/metamod-r/stargazers)
-Distributed under
+Distributed under
[](https://github.com/theAsmodai/metamod-r/blob/master/LICENSE).
## Documentation
-* All actual documentation in  **English** and  **Russian** languages is placed at [this link](https://github.com/theAsmodai/metamod-r/wiki).
+* All actual documentation in  **English** and  **Russian** languages is placed at [this link](https://github.com/theAsmodai/metamod-r/wiki).
### Supported games
*  Actual [list of supported games](https://github.com/theAsmodai/metamod-r/wiki/Supported-games).
*  Актуальный [список поддерживаемых игр](https://github.com/theAsmodai/metamod-r/wiki/Поддерживаемые-игры).
+## Build instructions
+### Checking requirements
+There are several software requirements for building Metamod-r:
-### Build instructions
-*  [Build instructions](https://github.com/theAsmodai/metamod-r/wiki/Compilling-metamod-r).
-*  [Инструкция по сборке](https://github.com/theAsmodai/metamod-r/wiki/Компиляция-metamod-r).
+#### Windows
+
+Visual Studio 2015 (C++14 standard) and later
+
+
+#### Linux
+
+git >= 1.8.5
+cmake >= 3.10
+GCC >= 4.9.2 (Optional)
+ICC >= 15.0.1 20141023 (Optional)
+LLVM (Clang) >= 6.0 (Optional)
+
+
+### Building
+
+#### Windows
+Use `Visual Studio` to build, open `msvc/metamod.sln` and just select from the solution configurations list `Release` or `Debug`
+
+#### Linux
+
+* Optional options using `build.sh --compiler=[gcc] --jobs=[N] -D[option]=[ON or OFF]` (without square brackets)
+
+
+-c=|--compiler=[icc|gcc|clang] - Select preferred C/C++ compiler to build
+-j=|--jobs=[N] - Specifies the number of jobs (commands) to run simultaneously (For faster building)
+
+Definitions (-D)
+DEBUG - Enables debugging mode
+USE_STATIC_LIBSTDC - Enables static linking library libstdc++
+
+
+* ICC ./build.sh --compiler=intel
+* LLVM (Clang) ./build.sh --compiler=clang
+* GCC ./build.sh --compiler=gcc
+
+##### Checking build environment (Debian / Ubuntu)
+
+
+Click to expand
+
+
+
+Installing required packages
+
+sudo dpkg --add-architecture i386
+sudo apt-get update
+sudo apt-get install -y gcc-multilib g++-multilib
+sudo apt-get install -y build-essential
+sudo apt-get install -y libc6-dev libc6-dev-i386
+
+
+
+
+Select the preferred C/C++ Compiler installation
+
+1) sudo apt-get install -y gcc g++
+2) sudo apt-get install -y clang
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index b6f2efa..0000000
--- a/build.gradle
+++ /dev/null
@@ -1,54 +0,0 @@
-import versioning.GitVersioner
-import versioning.MetamodVersionInfo
-import org.joda.time.DateTime
-
-apply from: 'shared.gradle'
-group = 'metamod'
-
-apply plugin: 'idea'
-
-idea {
- project {
- languageLevel = 'JDK_1_7'
- }
-}
-
-def gitInfo = GitVersioner.versionForDir(project.rootDir)
-MetamodVersionInfo versionInfo
-if (gitInfo && gitInfo.tag && gitInfo.tag[0] == 'v') {
- def m = gitInfo.tag =~ /^v(\d+)\.(\d+)(\.(\d+))?$/
- if (!m.find()) {
- throw new RuntimeException("Invalid git version tag name ${gitInfo.tag}")
- }
-
- versionInfo = new MetamodVersionInfo(
- majorVersion: m.group(1) as int,
- minorVersion: m.group(2) as int,
- maintenanceVersion: m.group(4) ? (m.group(4) as int) : null,
- localChanges: gitInfo.localChanges,
- commitDate: gitInfo.commitDate,
- commitSHA: gitInfo.commitSHA,
- commitURL: gitInfo.commitURL
- )
-} else {
- versionInfo = new MetamodVersionInfo(
- majorVersion: project.majorVersion as int,
- minorVersion: project.minorVersion as int,
- maintenanceVersion: project.maintenanceVersion as int,
- suffix: '',
- localChanges: gitInfo ? gitInfo.localChanges : true,
- commitDate: gitInfo ? gitInfo.commitDate : new DateTime(),
- commitSHA: gitInfo ? gitInfo.commitSHA : "",
- commitURL: gitInfo ? gitInfo.commitURL : "",
- commitCount: gitInfo ? (gitInfo.commitCount as int) : null
- )
-}
-
-project.ext.metamodVersionInfo = versionInfo
-project.version = versionInfo.asMavenVersion()
-
-apply from: 'publish.gradle'
-
-task wrapper(type: Wrapper) {
- gradleVersion = '2.4'
-}
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..5f474d9
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+main()
+{
+ CC=gcc
+ CXX=g++
+
+ if [[ "$*" =~ "--help" ]]; then
+ help
+ exit 0;
+ fi
+
+ n=0
+ args=()
+ for i in "$@"
+ do
+ case $i in
+ -j=*|--jobs=*)
+ jobs="-j${i#*=}"
+ shift
+ ;;
+ -c=*|--compiler=*)
+ C="${i#*=}"
+ shift
+ ;;
+ *)
+ args[$n]="$i"
+ ((++n))
+ ;;
+ esac
+ done
+
+ case "$C" in
+ ("intel"|"icc") CC=icc CXX=icpc ;;
+ ("gcc"|"g++") CC=gcc CXX=g++ ;;
+ ("clang"|"llvm") CC=clang CXX=clang++ ;;
+ *)
+ ;;
+ esac
+
+ rm -rf build
+ mkdir build
+ pushd build &> /dev/null
+ CC=$CC CXX=$CXX cmake ${args[@]} ..
+ make ${jobs}
+ popd > /dev/null
+}
+
+help()
+{
+ printf "Usage: ./build.sh \n\n"
+ printf " -c= | --compiler= - Select preferred C/C++ compiler to build\n"
+ printf " -j= | --jobs= - Specifies the number of jobs (commands) to run simultaneously (For faster building)\n\n"
+}
+
+# Initialize
+main $*
+
+# Exit normally
+exit 0
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
deleted file mode 100644
index 0d93aa3..0000000
--- a/buildSrc/build.gradle
+++ /dev/null
@@ -1,23 +0,0 @@
-apply plugin: 'groovy'
-
-repositories {
- //mavenLocal()
- mavenCentral()
- maven {
- url 'http://nexus.rehlds.org/nexus/content/repositories/rehlds-releases/'
- }
- maven {
- url 'http://nexus.rehlds.org/nexus/content/repositories/rehlds-snapshots/'
- }
-}
-
-dependencies {
- compile gradleApi()
- compile localGroovy()
- compile 'commons-io:commons-io:2.4'
- compile 'commons-lang:commons-lang:2.6'
- compile 'joda-time:joda-time:2.7'
- compile 'org.doomedsociety.gradlecpp:gradle-cpp-plugin:1.2'
- compile 'org.eclipse.jgit:org.eclipse.jgit:3.7.0.201502260915-r'
- compile 'org.apache.velocity:velocity:1.7'
-}
diff --git a/buildSrc/src/main/groovy/gradlecpp/VelocityUtils.groovy b/buildSrc/src/main/groovy/gradlecpp/VelocityUtils.groovy
deleted file mode 100644
index 2dc0fb2..0000000
--- a/buildSrc/src/main/groovy/gradlecpp/VelocityUtils.groovy
+++ /dev/null
@@ -1,37 +0,0 @@
-package gradlecpp
-
-import org.apache.velocity.Template
-import org.apache.velocity.VelocityContext
-import org.apache.velocity.app.Velocity
-import org.joda.time.format.DateTimeFormat
-
-class VelocityUtils {
-
- static {
- Properties p = new Properties();
-
- p.setProperty("resource.loader", "class");
- p.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
- p.setProperty("class.resource.loader.path", "");
-
- p.setProperty("input.encoding", "UTF-8");
- p.setProperty("output.encoding", "UTF-8");
-
- Velocity.init(p);
- }
-
- static String renderTemplate(File tplFile, Map ctx) {
- Template tpl = Velocity.getTemplate(tplFile.absolutePath)
- if (!tpl) {
- throw new RuntimeException("Failed to load velocity template ${tplFile.absolutePath}: not found")
- }
-
- def velocityContext = new VelocityContext(ctx)
- velocityContext.put("_DateTimeFormat", DateTimeFormat)
-
- def sw = new StringWriter()
- tpl.merge(velocityContext, sw)
-
- return sw.toString()
- }
-}
diff --git a/buildSrc/src/main/groovy/versioning/GitInfo.groovy b/buildSrc/src/main/groovy/versioning/GitInfo.groovy
deleted file mode 100644
index e0ad38f..0000000
--- a/buildSrc/src/main/groovy/versioning/GitInfo.groovy
+++ /dev/null
@@ -1,16 +0,0 @@
-package versioning
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeChecked
-import org.joda.time.DateTime
-
-@CompileStatic @TypeChecked
-class GitInfo {
- boolean localChanges
- DateTime commitDate
- String branch
- String tag
- String commitSHA
- String commitURL
- Integer commitCount
-}
diff --git a/buildSrc/src/main/groovy/versioning/GitVersioner.groovy b/buildSrc/src/main/groovy/versioning/GitVersioner.groovy
deleted file mode 100644
index 840ff66..0000000
--- a/buildSrc/src/main/groovy/versioning/GitVersioner.groovy
+++ /dev/null
@@ -1,125 +0,0 @@
-package versioning
-
-import java.util.Set;
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeChecked
-import org.eclipse.jgit.api.Git
-import org.eclipse.jgit.api.Status;
-import org.eclipse.jgit.lib.ObjectId
-import org.eclipse.jgit.lib.Repository
-import org.eclipse.jgit.lib.StoredConfig
-import org.eclipse.jgit.revwalk.RevCommit
-import org.eclipse.jgit.revwalk.RevWalk
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder
-import org.joda.time.DateTime
-import org.joda.time.DateTimeZone
-
-@CompileStatic @TypeChecked
-class GitVersioner {
-
- static GitInfo versionForDir(String dir) {
- versionForDir(new File(dir))
- }
- static int getCountCommit(Repository repo) {
- Iterable commits = Git.wrap(repo).log().call()
- int count = 0;
- commits.each {
- count++;
- }
-
- return count;
- }
- static String prepareUrlToCommits(String url) {
- if (url == null) {
- // default remote url
- return "https://github.com/theAsmodai/metamod-r/commits/";
- }
-
- StringBuilder sb = new StringBuilder();
- String childPath;
- int pos = url.indexOf('@');
- if (pos != -1) {
- childPath = url.substring(pos + 1, url.lastIndexOf('.git')).replace(':', '/');
- sb.append('https://');
- } else {
- pos = url.lastIndexOf('.git');
- childPath = (pos == -1) ? url : url.substring(0, pos);
- }
-
- // support for different links to history of commits
- if (url.indexOf('bitbucket.org') != -1) {
- sb.append(childPath).append('/commits/');
- } else {
- sb.append(childPath).append('/commit/');
- }
- return sb.toString();
- }
- // check uncommited changes
- static boolean getUncommittedChanges(Repository repo) {
- Git git = new Git(repo);
- Status status = git.status().call();
-
- Set uncommittedChanges = status.getUncommittedChanges();
- for(String uncommitted : uncommittedChanges) {
- return true;
- }
-
- return false;
- }
- static GitInfo versionForDir(File dir) {
- FileRepositoryBuilder builder = new FileRepositoryBuilder();
- Repository repo = builder.setWorkTree(dir)
- .findGitDir()
- .build()
-
- ObjectId head = repo.resolve('HEAD');
- if (!head) {
- return null
- }
-
- final StoredConfig cfg = repo.getConfig();
- def commit = new RevWalk(repo).parseCommit(head);
- if (!commit) {
- throw new RuntimeException("Can't find last commit.");
- }
-
- def localChanges = getUncommittedChanges(repo);
- def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC);
- if (localChanges) {
- commitDate = new DateTime();
- }
-
- def branch = repo.getBranch();
-
- String url = null;
- String remote_name = cfg.getString("branch", branch, "remote");
-
- if (remote_name == null) {
- for (String remotes : cfg.getSubsections("remote")) {
- if (url != null) {
- println 'Found a second remote: (' + remotes + '), url: (' + cfg.getString("remote", remotes, "url") + ')'
- continue;
- }
-
- url = cfg.getString("remote", remotes, "url");
- }
- } else {
- url = cfg.getString("remote", remote_name, "url");
- }
-
- String commitURL = prepareUrlToCommits(url);
- String tag = repo.tags.find { kv -> kv.value.objectId == commit.id }?.key
- String commitSHA = commit.getId().abbreviate(7).name();
-
- return new GitInfo(
- localChanges: localChanges,
- commitDate: commitDate,
- branch: branch,
- tag: tag,
- commitSHA: commitSHA,
- commitURL: commitURL,
- commitCount: getCountCommit(repo)
- )
- }
-}
diff --git a/buildSrc/src/main/groovy/versioning/MetamodVersionInfo.groovy b/buildSrc/src/main/groovy/versioning/MetamodVersionInfo.groovy
deleted file mode 100644
index 1c3fea6..0000000
--- a/buildSrc/src/main/groovy/versioning/MetamodVersionInfo.groovy
+++ /dev/null
@@ -1,58 +0,0 @@
-package versioning
-
-import groovy.transform.CompileStatic
-import groovy.transform.ToString
-import groovy.transform.TypeChecked
-import org.joda.time.format.DateTimeFormat
-import org.joda.time.DateTime
-
-@CompileStatic @TypeChecked
-@ToString(includeNames = true)
-class MetamodVersionInfo {
- Integer majorVersion
- Integer minorVersion
- Integer maintenanceVersion
- String suffix
-
- boolean localChanges
- DateTime commitDate
- String commitSHA
- String commitURL
- Integer commitCount
-
- String asMavenVersion(boolean extra = true, String separator = ".") {
- StringBuilder sb = new StringBuilder()
- sb.append(majorVersion).append(separator).append(minorVersion);
- if (maintenanceVersion != null) {
- sb.append(separator).append(maintenanceVersion);
- }
-
- if (commitCount != null) {
- sb.append(separator).append(commitCount)
- }
-
- if (extra && suffix) {
- sb.append('-' + suffix)
- }
-
- // do mark for this build like a modified version
- if (extra && localChanges) {
- sb.append('+m');
- }
-
- return sb.toString()
- }
- String asCommitDate(String pattern = null) {
- if (pattern == null) {
- pattern = "MMM d yyyy";
- if (commitDate.getDayOfMonth() >= 10) {
- pattern = "MMM d yyyy";
- }
- }
-
- return DateTimeFormat.forPattern(pattern).withLocale(Locale.ENGLISH).print(commitDate);
- }
- String asCommitTime() {
- return DateTimeFormat.forPattern('HH:mm:ss').withLocale(Locale.ENGLISH).print(commitDate);
- }
-}
diff --git a/getucrtinfo.bat b/getucrtinfo.bat
deleted file mode 100644
index 29f5bb1..0000000
--- a/getucrtinfo.bat
+++ /dev/null
@@ -1,19 +0,0 @@
-@echo off
-
-if defined VS150COMNTOOLS (
- if not exist "%VS150COMNTOOLS%vcvarsqueryregistry.bat" goto NoVS
- call "%VS150COMNTOOLS%vcvarsqueryregistry.bat"
- goto :run
-) else if defined VS140COMNTOOLS (
- if not exist "%VS140COMNTOOLS%vcvarsqueryregistry.bat" goto NoVS
- call "%VS140COMNTOOLS%vcvarsqueryregistry.bat"
- goto :run
-)
-
-:NoVS
-echo Error: Visual Studio 2015 or 2017 required.
-exit /b 1
-
-:run
-echo %UniversalCRTSdkDir%
-echo %UCRTVersion%
diff --git a/gradle.properties b/gradle.properties
deleted file mode 100644
index ea3ef06..0000000
--- a/gradle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-majorVersion=1
-minorVersion=3
-maintenanceVersion=0
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 175c642..0000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index c6638f3..0000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Sat Jun 06 16:31:05 BRT 2015
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
diff --git a/gradlew b/gradlew
deleted file mode 100644
index 91a7e26..0000000
--- a/gradlew
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
deleted file mode 100644
index 8a0b282..0000000
--- a/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/metamod/CMakeLists.txt b/metamod/CMakeLists.txt
new file mode 100644
index 0000000..8709a12
--- /dev/null
+++ b/metamod/CMakeLists.txt
@@ -0,0 +1,197 @@
+#----------------------------------------
+# 1. Preparing build:
+# rm -rf build
+# mkdir build && cd build
+#
+# 2. Select compiler and build it
+# - Compile with Clang:
+# CC="clang" CXX="clang++" cmake ..
+# make
+#
+# - Compile with Intel C++ Compiler:
+# CC="icc" CXX="icpc" cmake ..
+# make
+#
+# - Compile with GCC Compiler:
+# cmake ..
+# make
+#
+# Use -DCMAKE_BUILD_TYPE=COMPAT_GLIBC
+# to backward compatibility with oldest version of glibc 2.11
+#
+#----------------------------------------
+
+cmake_minimum_required(VERSION 3.1)
+project(metamod CXX)
+
+option(DEBUG "Build with debug information." OFF)
+option(USE_STATIC_LIBSTDC "Enables static linking libstdc++." OFF)
+
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
+# Avoid -rdynamic -fPIC options
+set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
+set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
+
+set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE")
+set(LINK_FLAGS "-m32 -s")
+
+set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions -fno-builtin -Wno-unknown-pragmas")
+
+# Remove noxref code and data
+set(COMPILE_FLAGS "${COMPILE_FLAGS} -ffunction-sections -fdata-sections")
+
+if (DEBUG)
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} -g3 -O3 -ggdb")
+else()
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector")
+endif()
+
+# Check Intel C++ compiler
+if ("$ENV{CXX}" MATCHES "icpc")
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} \
+ -fasm-blocks -Qoption,cpp,--treat_func_as_string_literal_cpp\
+ -inline-forceinline -no-ansi-alias")
+
+ set(LINK_FLAGS "${LINK_FLAGS} -static-intel -no-intel-extensions")
+
+ if (NOT DEBUG)
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} -ipo")
+ set(LINK_FLAGS "${LINK_FLAGS} -ipo -diag-disable=11003")
+ endif()
+else()
+ # Produce code optimized for the most common IA32/AMD64/EM64T processors.
+ # As new processors are deployed in the marketplace, the behavior of this option will change.
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} \
+ -mtune=generic -msse3\
+ -fno-sized-deallocation -Wno-invalid-offsetof -Wno-ignored-attributes\
+ -Wno-write-strings -Wno-strict-aliasing -fno-plt")
+
+ # Check Clang compiler
+ if (NOT "$ENV{CXX}" MATCHES "clang")
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-maybe-uninitialized -Wno-unused-but-set-variable")
+
+ # GCC >= 8.3
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wno-stringop-truncation -Wno-format-truncation -Wno-class-memaccess")
+ endif()
+ endif()
+endif()
+
+# GCC >= 8.3
+if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} -fcf-protection=none")
+endif()
+
+if (NOT DEBUG)
+ set(LINK_FLAGS "${LINK_FLAGS} \
+ -Wl,-gc-sections -Wl,--version-script=\"${PROJECT_SOURCE_DIR}/../version_script.lds\"")
+endif()
+
+if (CMAKE_BUILD_TYPE MATCHES COMPAT_GLIBC)
+ set(LINK_FLAGS "${LINK_FLAGS} -Wl,--wrap=stat64")
+endif()
+
+set(PROJECT_SRC_DIR
+ "${PROJECT_SOURCE_DIR}"
+ "${PROJECT_SOURCE_DIR}/src"
+ "${PROJECT_SOURCE_DIR}/include/engine"
+ "${PROJECT_SOURCE_DIR}/include/common"
+ "${PROJECT_SOURCE_DIR}/include/dlls"
+ "${PROJECT_SOURCE_DIR}/include/game_shared"
+ "${PROJECT_SOURCE_DIR}/include/pm_shared"
+ "${PROJECT_SOURCE_DIR}/include/public"
+)
+
+set(PROJECT_PUBLIC_DIR
+ "${PROJECT_SOURCE_DIR}/include/public"
+ "${PROJECT_SOURCE_DIR}/include/public/metamod"
+)
+
+add_library(metamod SHARED ${appversion.sh})
+
+if (NOT TARGET appversion)
+ add_custom_target(appversion DEPENDS COMMAND "${PROJECT_SOURCE_DIR}/version/appversion.sh" "${PROJECT_SOURCE_DIR}/..")
+endif()
+
+add_dependencies(metamod appversion)
+
+target_include_directories(metamod PRIVATE
+ ${PROJECT_SRC_DIR}
+ ${PROJECT_PUBLIC_DIR}
+)
+
+target_compile_definitions(metamod PRIVATE
+ _LINUX
+ LINUX
+ NDEBUG
+ METAMOD_CORE
+ _GLIBCXX_USE_CXX11_ABI=0
+ _stricmp=strcasecmp
+ _strnicmp=strncasecmp
+ _strdup=strdup
+ _unlink=unlink
+ _write=write
+ _close=close
+ _getcwd=getcwd
+ _vsnprintf=vsnprintf
+ _vsnwprintf=vswprintf
+ _snprintf=snprintf
+)
+
+target_sources(metamod PRIVATE
+ "src/api_info.cpp"
+ "src/callback_jit.cpp"
+ "src/commands_meta.cpp"
+ "src/conf_meta.cpp"
+ "src/dllapi.cpp"
+ "src/engine_api.cpp"
+ "src/game_support.cpp"
+ "src/h_export.cpp"
+ "src/linkent.cpp"
+ "src/linkgame.cpp"
+ "src/log_meta.cpp"
+ "src/mdebug.cpp"
+ "src/mem_utils.cpp"
+ "src/meta_rehlds_api.cpp"
+ "src/metamod.cpp"
+ "src/mextdll.cpp"
+ "src/mlist.cpp"
+ "src/mplayer.cpp"
+ "src/mplugin.cpp"
+ "src/mreg.cpp"
+ "src/mutil.cpp"
+ "src/precompiled.cpp"
+ "src/public_amalgamation.cpp"
+ "src/reg_support.cpp"
+ "src/sdk_util.cpp"
+ "src/studioapi.cpp"
+ "src/sys_module.cpp"
+ "src/utils.cpp"
+ "src/glibc_compat.cpp"
+)
+
+target_link_libraries(metamod PRIVATE
+ dl
+ $<$:libc-2.11.1.so>
+)
+
+if (USE_STATIC_LIBSTDC)
+ target_compile_definitions(metamod PRIVATE BUILD_STATIC_LIBSTDC)
+ set(LINK_FLAGS "${LINK_FLAGS} -static-libgcc -static-libstdc++")
+endif()
+
+if (CMAKE_BUILD_TYPE MATCHES COMPAT_GLIBC)
+ set(LINK_FLAGS "${LINK_FLAGS} \
+ -Wl,-rpath,'$ORIGIN/.' \
+ -L${PROJECT_SOURCE_DIR}/lib/linux32")
+endif()
+
+set_target_properties(metamod PROPERTIES
+ OUTPUT_NAME metamod_i386
+ PREFIX ""
+ COMPILE_FLAGS ${COMPILE_FLAGS}
+ LINK_FLAGS ${LINK_FLAGS}
+ POSITION_INDEPENDENT_CODE ON
+)
diff --git a/metamod/build.gradle b/metamod/build.gradle
deleted file mode 100644
index 86fac29..0000000
--- a/metamod/build.gradle
+++ /dev/null
@@ -1,210 +0,0 @@
-import org.doomedsociety.gradlecpp.GradleCppUtils
-import org.doomedsociety.gradlecpp.toolchain.icc.IccCompilerPlugin
-import org.doomedsociety.gradlecpp.toolchain.icc.Icc
-import org.doomedsociety.gradlecpp.cfg.ToolchainConfig
-import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig
-import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
-import org.doomedsociety.gradlecpp.cfg.ToolchainConfigUtils
-import org.gradle.language.cpp.CppSourceSet
-import org.gradle.language.rc.tasks.WindowsResourceCompile
-import org.gradle.nativeplatform.NativeBinarySpec
-import versioning.MetamodVersionInfo
-import gradlecpp.VelocityUtils
-
-apply plugin: 'cpp'
-apply plugin: 'windows-resources'
-apply plugin: IccCompilerPlugin
-
-List getRcCompileTasks(NativeBinarySpec binary) {
- def linkTask = GradleCppUtils.getLinkTask(binary)
-
- def res = linkTask.taskDependencies.getDependencies(linkTask).findAll { Task t -> t instanceof WindowsResourceCompile }
- return res as List
-}
-
-void postEvaluate(NativeBinarySpec b) {
- if (GradleCppUtils.windows) {
- getRcCompileTasks(b).each { Task t ->
- t.dependsOn project.generateAppVersion
- }
- } else {
- // attach generateAppVersion task to all 'compile source' tasks
- GradleCppUtils.getCompileTasks(b).each { Task t ->
- t.dependsOn project.generateAppVersion
- }
- }
-}
-
-void setupToolchain(NativeBinarySpec b)
-{
- ToolchainConfig cfg = rootProject.createToolchainConfig(b)
- cfg.projectInclude(project, '', '/src', '/include/common', '/include/dlls', '/include/engine', '/include/game_shared', '/include/pm_shared', '/include/public')
- cfg.singleDefines 'METAMOD_CORE';
-
- if (cfg instanceof MsvcToolchainConfig) {
- cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig(
- enabled: true,
- pchHeader: 'precompiled.h',
- pchSourceSet: 'rmod_pch'
- )
-
- cfg.extraLibs 'psapi.lib', 'user32.lib'
- cfg.singleDefines('_CRT_SECURE_NO_WARNINGS')
- } else if (cfg instanceof GccToolchainConfig) {
- cfg.compilerOptions.pchConfig = new GccToolchainConfig.PrecompilerHeaderOptions(
- enabled: true,
- pchSourceSet: 'rmod_pch'
- )
- cfg.compilerOptions.languageStandard = 'c++0x'
- cfg.defines([
- '_stricmp': 'strcasecmp',
- '_strnicmp': 'strncasecmp',
- '_strdup': 'strdup',
- '_unlink': 'unlink',
- '_write' : 'write',
- '_close' : 'close',
- '_getcwd' : 'getcwd',
- '_vsnprintf': 'vsnprintf',
- '_vsnwprintf': 'vswprintf',
- '_snprintf': 'snprintf'
- ])
-
- cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-msse2', '-fomit-frame-pointer', '-inline-forceinline', '-fvisibility=default', '-fvisibility-inlines-hidden', '-fno-rtti', '-g0', '-s', '-fno-exceptions'
- }
-
- ToolchainConfigUtils.apply(project, cfg, b)
-
- GradleCppUtils.onTasksCreated(project, 'postEvaluate', {
- postEvaluate(b)
- })
-}
-
-model {
- buildTypes {
- debug
- release
- }
-
- platforms {
- x86 {
- architecture "x86"
- }
- }
-
- toolChains {
- visualCpp(VisualCpp) {
- }
- icc(Icc) {
- }
- }
-
- components {
- metamod(NativeLibrarySpec) {
- targetPlatform 'x86'
- baseName GradleCppUtils.windows ? 'metamod' : 'metamod_i386'
-
- sources {
- rmod_pch(CppSourceSet) {
- source {
- srcDirs "src"
- include "precompiled.cpp"
- }
-
- exportedHeaders {
- srcDirs "include"
- }
- }
- rmod_src(CppSourceSet) {
- source {
- srcDir "src"
- srcDir "version"
- include "**/*.cpp"
-
- exclude "precompiled.cpp"
- }
-
- exportedHeaders {
- srcDirs "include"
- }
- }
- rc {
- source {
- srcDirs "msvc"
- include "metamod.rc"
- }
- exportedHeaders {
- srcDirs "msvc"
- }
- }
- }
- binaries.all {
- NativeBinarySpec b -> project.setupToolchain(b)
- }
- }
- }
-}
-
-afterEvaluate {
- project.binaries.all {
- NativeBinarySpec binary ->
- Tool linker = binary.linker
-
- if (GradleCppUtils.windows) {
- linker.args "/DEF:${projectDir}\\msvc\\metamod.def"
- }
- }
-}
-
-task buildFinalize << {
- if (GradleCppUtils.windows) {
- return;
- }
-
- binaries.withType(SharedLibraryBinarySpec) {
- def sharedBinary = it.getSharedLibraryFile();
- if (sharedBinary.exists()) {
- sharedBinary.renameTo(new File(sharedBinary.getParent() + "/" + sharedBinary.getName().replaceFirst("^lib", "")));
- }
- }
-}
-
-task buildRelease {
- dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib ->
- blib.buildable && blib.buildType.name == 'release'
- }
- finalizedBy buildFinalize
-}
-
-tasks.clean.doLast {
- project.file('version/appversion.h').delete()
-}
-
-task generateAppVersion {
-
- MetamodVersionInfo verInfo = (MetamodVersionInfo)rootProject.metamodVersionInfo
- def tplFile = project.file('version/appversion.vm')
- def renderedFile = project.file('version/appversion.h')
-
- // check to up-to-date
- inputs.file tplFile
- inputs.file project.file('gradle.properties')
- outputs.file renderedFile
-
- // this will ensure that this task is redone when the versions change
- inputs.property('version', rootProject.version)
- inputs.property('commitDate', verInfo.asCommitDate())
-
- println "##teamcity[buildNumber '" + verInfo.asMavenVersion(false) + "']";
-
- doLast {
- def templateCtx = [
- verInfo: verInfo
- ]
-
- def content = VelocityUtils.renderTemplate(tplFile, templateCtx)
- renderedFile.delete()
- renderedFile.write(content, 'utf-8')
-
- println 'The current Metamod maven version is ' + rootProject.version + ', url: (' + verInfo.commitURL + '' + verInfo.commitSHA + ')';
- }
-}
diff --git a/metamod/extra/example/msvc/example_plugin.vcxproj b/metamod/extra/example/msvc/example_plugin.vcxproj
index d39804d..83978e9 100644
--- a/metamod/extra/example/msvc/example_plugin.vcxproj
+++ b/metamod/extra/example/msvc/example_plugin.vcxproj
@@ -13,22 +13,25 @@
{1B03767B-CB83-4A1B-8480-EF08D557838B}
example_plugin
+ 12.0
DynamicLibrary
true
- v120_xp
- v140_xp
- v141_xp
+ v120
+ v140
+ v141
+ v142
MultiByte
DynamicLibrary
false
- v120_xp
- v140_xp
- v141_xp
+ v120
+ v140
+ v141
+ v142
true
MultiByte
@@ -47,8 +50,6 @@
Level3
Disabled
-
-
$(ProjectDir)\..\;$(ProjectDir)\..\include;$(ProjectDir)\..\include\metamod;$(ProjectDir)\..\include\hlsdk\common;$(ProjectDir)\..\include\hlsdk\dlls;$(ProjectDir)\..\include\hlsdk\engine;$(ProjectDir)\..\include\hlsdk\pm_shared;$(ProjectDir)\..\include\hlsdk\public;%(AdditionalIncludeDirectories)
_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
@@ -64,8 +65,6 @@
Full
true
true
-
-
$(ProjectDir)..\;$(ProjectDir)..\include;$(ProjectDir)..\include\metamod;$(ProjectDir)..\include\hlsdk\common;$(ProjectDir)..\include\hlsdk\dlls;$(ProjectDir)..\include\hlsdk\engine;$(ProjectDir)..\include\hlsdk\pm_shared;$(ProjectDir)..\include\hlsdk\public;%(AdditionalIncludeDirectories)
AnySuitable
true
@@ -77,10 +76,7 @@
true
- true
- true
example_plugin.def
- Console
diff --git a/metamod/extra/example/public_amalgamation.cpp b/metamod/extra/example/public_amalgamation.cpp
index 13a3e02..9a30ddb 100644
--- a/metamod/extra/example/public_amalgamation.cpp
+++ b/metamod/extra/example/public_amalgamation.cpp
@@ -1,5 +1,4 @@
#include
#include
-#include "sys_shared.cpp"
#include "interface.cpp"
diff --git a/metamod/include/common/stdc++compat.cpp b/metamod/include/common/stdc++compat.cpp
index 6177fee..1937b9b 100644
--- a/metamod/include/common/stdc++compat.cpp
+++ b/metamod/include/common/stdc++compat.cpp
@@ -1,15 +1,23 @@
#include
+#include
-#if !defined(_WIN32)
-void NORETURN Sys_Error(const char *error, ...);
+#if !defined(_WIN32) && !defined(BUILD_STATIC_LIBSTDC) // if build with static libstdc++ then ignore
// This file adds the necessary compatibility tricks to avoid symbols with
// version GLIBCXX_3.4.16 and bigger, keeping binary compatibility with libstdc++ 4.6.1.
namespace std
{
+
+#if __cpp_exceptions
+ logic_error::logic_error(const char *__arg) : exception(), _M_msg(__arg) {}
+ out_of_range::out_of_range(const char *__arg) : logic_error(__arg) {}
+ out_of_range::~out_of_range() _GLIBCXX_USE_NOEXCEPT {}
+#endif // #if __cpp_exceptions
+
// We shouldn't be throwing exceptions at all, but it sadly turns out we call STL (inline) functions that do.
void __throw_out_of_range_fmt(const char *fmt, ...)
{
+ #if __cpp_exceptions
va_list ap;
char buf[1024]; // That should be big enough.
@@ -18,16 +26,43 @@ namespace std
buf[sizeof(buf) - 1] = '\0';
va_end(ap);
- Sys_Error(buf);
+ throw std::out_of_range(buf);
+ #else
+ abort();
+ #endif
}
}; // namespace std
-// Technically, this symbol is not in GLIBCXX_3.4.20, but in CXXABI_1.3.8,
-// but that's equivalent, version-wise. Those calls are added by the compiler
+// Was added in GCC 4.9
+// Technically, this symbol is not in GLIBCXX_3.4.20, but in CXXABI_1.3.8, but that's equivalent, version-wise.
+// Those calls are added by the compiler
// itself on `new Class[n]` calls.
extern "C"
void __cxa_throw_bad_array_new_length()
{
- Sys_Error("Bad array new length.");
+#if __cpp_exceptions
+ throw std::bad_array_new_length();
+#else
+ abort();
+#endif
}
+
+#if defined(__INTEL_COMPILER) && __cplusplus >= 201402L
+// This operator delete sized deallocations was added in c++14
+// and required at least not less than CXXABI_1.3.9
+// we should to keep CXXABI_1.3.8 for binary compatibility with oldest libstdc++.
+// GCC and Clang allow to compile C++14 code with -fno-sized-deallocation to disable the new feature, but ICC isn't allow
+// so that our C++14 library code would never call that version of operator delete,
+// for ICC compiler we must override those operators for static linking to the library.
+void operator delete[](void *ptr, std::size_t size) noexcept
+{
+ ::operator delete(ptr);
+}
+
+void operator delete(void *ptr, std::size_t size) noexcept
+{
+ ::operator delete(ptr);
+}
+#endif
+
#endif // !defined(_WIN32)
diff --git a/metamod/lib/linux32/libc-2.11.1.so b/metamod/lib/linux32/libc-2.11.1.so
new file mode 100644
index 0000000..5d65f04
Binary files /dev/null and b/metamod/lib/linux32/libc-2.11.1.so differ
diff --git a/metamod/lib/linux32/libm.so b/metamod/lib/linux32/libm.so
new file mode 100644
index 0000000..b0430eb
Binary files /dev/null and b/metamod/lib/linux32/libm.so differ
diff --git a/metamod/lib/linux32/librt.so b/metamod/lib/linux32/librt.so
new file mode 100644
index 0000000..4b39fa4
Binary files /dev/null and b/metamod/lib/linux32/librt.so differ
diff --git a/metamod/msvc/PreBuild.bat b/metamod/msvc/PreBuild.bat
index 8147e2f..19ead2a 100644
--- a/metamod/msvc/PreBuild.bat
+++ b/metamod/msvc/PreBuild.bat
@@ -4,6 +4,8 @@
:: Pre-build auto-versioning script
::
+chcp 65001
+
set srcdir=%~1
set repodir=%~2
@@ -26,6 +28,14 @@ set "hour=%dt:~8,2%"
set "min=%dt:~10,2%"
set "sec=%dt:~12,2%"
+::
+:: Remove leading zero from MM (e.g 09 > 9)
+::
+for /f "tokens=* delims=0" %%I in ("%MM%") do set MM=%%I
+
+::
+:: Index into array to get month name
+::
for /f "tokens=%MM%" %%I in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "month=%%I"
::
@@ -69,14 +79,6 @@ IF EXIST "%srcdir%\version.h" (
IF %%j==VERSION_MAINTENANCE set version_maintenance=%%k
)
)
-) ELSE (
- FOR /F "usebackq tokens=1,2,3,* delims==" %%i in ("%repodir%..\gradle.properties") do (
- IF NOT [%%j] == [] (
- IF %%i==majorVersion set version_major=%%j
- IF %%i==minorVersion set version_minor=%%j
- IF %%i==maintenanceVersion set version_maintenance=%%j
- )
- )
)
::
@@ -90,7 +92,7 @@ IF NOT %errlvl% == "1" (
FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --count !branch_name!"') DO (
IF NOT [%%i] == [] (
- set /a commitCount=%%i
+ set commitCount=%%i
)
)
)
@@ -143,9 +145,9 @@ IF NOT %errlvl% == "1" (
:: append extra string
If NOT "!commitURL!"=="!commitURL:bitbucket.org=!" (
- set commitURL=https://!commitURL!/commits/
- ) ELSE (
set commitURL=https://!commitURL!/commit/
+ ) ELSE (
+ set commitURL=https://!commitURL!/commits/
)
)
)
@@ -173,9 +175,7 @@ set new_version=%version_major%.%version_minor%.%version_maintenance%.%commitCou
::
:: Update appversion.h if version has changed or modifications/mixed revisions detected
::
-IF NOT "%new_version%"=="%old_version%" (
- goto _update
-)
+IF NOT "%new_version%"=="%old_version%" goto _update
goto _exit
@@ -189,10 +189,10 @@ echo Updating appversion.h, new version is "%new_version%", the old one was %old
echo #ifndef __APPVERSION_H__>"%srcdir%\appversion.h"
echo #define __APPVERSION_H__>>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h"
-echo // >>"%srcdir%\appversion.h"
+echo //>>"%srcdir%\appversion.h"
echo // This file is generated automatically.>>"%srcdir%\appversion.h"
echo // Don't edit it.>>"%srcdir%\appversion.h"
-echo // >>"%srcdir%\appversion.h"
+echo //>>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h"
echo // Version defines>>"%srcdir%\appversion.h"
echo #define APP_VERSION "%new_version%">>"%srcdir%\appversion.h"
@@ -202,7 +202,7 @@ echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%version_maintena
echo #define APP_VERSION_FLAGS 0x0L>>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h"
-echo #define APP_COMMIT_DATE "%YYYY%-%DD%-%MM%">>"%srcdir%\appversion.h"
+echo #define APP_COMMIT_DATE "%month% %DD% %YYYY%">>"%srcdir%\appversion.h"
echo #define APP_COMMIT_TIME "%hour%:%min%:%sec%">>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h"
@@ -213,11 +213,5 @@ echo.>>"%srcdir%\appversion.h"
echo #endif //__APPVERSION_H__>>"%srcdir%\appversion.h"
echo.>>"%srcdir%\appversion.h"
-::
-:: Do update of version.cpp file last modify time to force it recompile
-::
-copy /b "%srcdir%\version.cpp"+,, "%srcdir%\version.cpp"
-endlocal
-
:_exit
exit /B 0
diff --git a/metamod/msvc/metamod.vcxproj b/metamod/msvc/metamod.vcxproj
index 07f6db0..40c66b2 100644
--- a/metamod/msvc/metamod.vcxproj
+++ b/metamod/msvc/metamod.vcxproj
@@ -12,23 +12,23 @@
{02832A39-E902-46B7-8D47-911C37CF41B0}
-
-
- 8.1
+ 12.0
DynamicLibrary
- v120_xp
- v140_xp
- v141_xp
+ v120
+ v140
+ v141
+ v142
true
DynamicLibrary
- v120_xp
- v140_xp
- v141_xp
+ v120
+ v140
+ v141
+ v142
@@ -42,7 +42,6 @@
<_ProjectFileVersion>10.0.40219.1
- false
AllRules.ruleset
@@ -50,50 +49,25 @@
-
- $(ProjectName)
-
-
- $(ProjectName)
-
+
+
- Disabled
$(ProjectDir)\..\;$(ProjectDir)\..\src;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\common;$(ProjectDir)\..\include\dlls;$(ProjectDir)\..\include\engine;$(ProjectDir)\..\include\game_shared;$(ProjectDir)\..\include\pm_shared;$(ProjectDir)\..\include\public;%(AdditionalIncludeDirectories)
METAMOD_CORE;WIN32;_DEBUG;_WINDOWS;_USRDLL;METAMOD_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
MultiThreadedDebug
Use
- $(IntDir)$(TargetName).pch
- $(IntDir)
- $(IntDir)
- .\debug/inf/
- Level3
- true
- true
- EditAndContinue
- Default
precompiled.h
+ EditAndContinue
+ Level3
- true
metamod.def
- true
- $(OutDir)$(TargetName).pdb
- $(OutDir)$(TargetName).lib
- MachineX86
- false
psapi.lib;%(AdditionalDependencies)
- Console
+ true
+ Windows
+ false
-
- _DEBUG;%(PreprocessorDefinitions)
- true
- true
- Win32
- .\debug/metamod.tlb
-
-
-
_DEBUG;%(PreprocessorDefinitions)
0x0409
@@ -121,53 +95,28 @@
- Full
- AnySuitable
$(ProjectDir)\..\;$(ProjectDir)\..\src;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\common;$(ProjectDir)\..\include\dlls;$(ProjectDir)\..\include\engine;$(ProjectDir)\..\include\game_shared;$(ProjectDir)\..\include\pm_shared;$(ProjectDir)\..\include\public;%(AdditionalIncludeDirectories)
METAMOD_CORE;WIN32;NDEBUG;_WINDOWS;_USRDLL;METAMOD_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- true
MultiThreaded
- true
Use
- $(IntDir)$(TargetName).pch
- $(IntDir)
- $(IntDir)
- .\release/inf/
Level3
- true
- true
- Default
precompiled.h
- false
- true
- true
- false
StreamingSIMDExtensions2
-
-
+ true
+ true
+ AnySuitable
+ true
+ false
+ true
- $(OutDir)$(TargetName)$(TargetExt)
- true
- .\metamod.def
- $(OutDir)$(TargetName).pdb
- $(OutDir)$(TargetName).lib
- MachineX86
+ metamod.def
false
psapi.lib;%(AdditionalDependencies)
- Console
+ Windows
true
true
-
- NDEBUG;%(PreprocessorDefinitions)
- true
- true
- Win32
- .\release/metamod.tlb
-
-
-
NDEBUG;%(PreprocessorDefinitions)
0x0409
diff --git a/metamod/src/callback_jit.h b/metamod/src/callback_jit.h
index 24a7c75..28cd508 100644
--- a/metamod/src/callback_jit.h
+++ b/metamod/src/callback_jit.h
@@ -1,6 +1,6 @@
#pragma once
-#define CDATA_ENTRY(s, x, p, h) {#x, offsetof(s, x), (uint8)getArgsCount(decltype(s##::##x)()), getRetType(decltype(s##::##x)()), is_varargs(decltype(s##::##x)()), p, h}
+#define CDATA_ENTRY(s, x, p, h) {#x, offsetof(s, x), (uint8)getArgsCount(decltype(s::x)()), getRetType(decltype(s::x)()), is_varargs(decltype(s::x)()), p, h}
enum rettype_t : uint8_t
{
diff --git a/metamod/src/conf_meta.cpp b/metamod/src/conf_meta.cpp
index 5b293bd..e9b1541 100644
--- a/metamod/src/conf_meta.cpp
+++ b/metamod/src/conf_meta.cpp
@@ -1,6 +1,6 @@
#include "precompiled.h"
-MConfig::MConfig() : m_debuglevel(0), m_gamedll(nullptr), m_exec_cfg(nullptr), m_list(nullptr), m_filename(nullptr), m_clientmeta(FALSE), m_dynalign_list(FALSE)
+MConfig::MConfig() : m_debuglevel(0), m_gamedll(nullptr), m_exec_cfg(nullptr), m_clientmeta(FALSE), m_dynalign_list(FALSE), m_list(nullptr), m_filename(nullptr)
{
set_directory();
}
diff --git a/metamod/src/glibc_compat.cpp b/metamod/src/glibc_compat.cpp
new file mode 100644
index 0000000..aadf819
--- /dev/null
+++ b/metamod/src/glibc_compat.cpp
@@ -0,0 +1,23 @@
+#include "precompiled.h"
+
+// Compatibility with legacy glibc
+#if !defined(_WIN32)
+
+// i386 versions of the `stat' interface
+#define _STAT_VER_LINUX 3
+#define _STAT_VER _STAT_VER_LINUX
+
+struct stat;
+struct stat64;
+
+extern "C" {
+ __asm__(".symver __xstat64,__xstat64@GLIBC_2.2");
+
+ int __xstat64(int ver, const char *path, struct stat64 *stat_buf);
+ int __wrap_stat64(const char *file, struct stat64 *buf)
+ {
+ return __xstat64(_STAT_VER, file, buf);
+ }
+}
+
+#endif // #if !defined(_WIN32)
diff --git a/metamod/src/jitasm.h b/metamod/src/jitasm.h
index 6562d91..aceeb11 100644
--- a/metamod/src/jitasm.h
+++ b/metamod/src/jitasm.h
@@ -886,7 +886,8 @@ struct Backend
Backend(void* pbuff = nullptr, size_t buffsize = 0) : pbuff_((uint8*) pbuff), buffsize_(buffsize), size_(0)
{
- memset(pbuff, 0xCC, buffsize); // INT3
+ if (pbuff)
+ memset(pbuff, 0xCC, buffsize); // INT3
}
size_t GetSize() const
diff --git a/metamod/src/log_meta.h b/metamod/src/log_meta.h
index 67401e8..4dabd37 100644
--- a/metamod/src/log_meta.h
+++ b/metamod/src/log_meta.h
@@ -8,6 +8,15 @@ enum
extern cvar_t g_meta_debug;
+void META_CONS(const char* fmt, ...);
+void META_DEV(const char* fmt, ...);
+void META_INFO(const char* fmt, ...);
+void META_WARNING(const char* fmt, ...);
+void META_ERROR(const char* fmt, ...);
+void META_LOG(const char* fmt, ...);
+void META_CLIENT(edict_t* pEntity, const char* fmt, ...);
+void META_DEBUG_(int level, const char* fmt, ...);
+
template
void META_DEBUG(int level, const char* fmt, t_args ... args)
{
@@ -15,13 +24,4 @@ void META_DEBUG(int level, const char* fmt, t_args ... args)
META_DEBUG_(level, fmt, args...);
}
-void META_CONS(const char* fmt, ...);
-void META_DEV(const char* fmt, ...);
-void META_INFO(const char* fmt, ...);
-void META_WARNING(const char* fmt, ...);
-void META_ERROR(const char* fmt, ...);
-void META_LOG(const char* fmt, ...);
-void META_DEBUG_(int level, const char* fmt, ...);
-void META_CLIENT(edict_t* pEntity, const char* fmt, ...);
-
void flush_ALERT_buffer();
diff --git a/metamod/src/metamod.cpp b/metamod/src/metamod.cpp
index 4135b08..5c05b5c 100644
--- a/metamod/src/metamod.cpp
+++ b/metamod/src/metamod.cpp
@@ -449,7 +449,7 @@ static void meta_collect_fix_data(uint32* const esp, std::vector& dat
char* raddr = (char *)*pret;
size_t args_count = 0;
- if ((raddr[0] == 0x83 && raddr[1] == 0xC4)) // add esp, XX
+ if ((unsigned char)raddr[0] == 0x83 && (unsigned char)raddr[1] == 0xC4) // add esp, XX
args_count = raddr[2] / 4;
// 8B 0D 4E 61 BC 00 mov ecx, ds:0BC614Eh
diff --git a/metamod/src/mextdll.cpp b/metamod/src/mextdll.cpp
index bd6bad3..6331cbd 100644
--- a/metamod/src/mextdll.cpp
+++ b/metamod/src/mextdll.cpp
@@ -3,7 +3,7 @@
CExtDll g_meta_extdll;
CExtDll::CExtDll()
- : m_dlls(nullptr), m_count(nullptr), m_hGameDLL(CSysModule::INVALID_HANDLE)
+ : m_hGameDLL(CSysModule::INVALID_HANDLE), m_dlls(nullptr), m_count(nullptr)
{
}
diff --git a/metamod/src/mlist.cpp b/metamod/src/mlist.cpp
index be3b2b2..b69b44e 100644
--- a/metamod/src/mlist.cpp
+++ b/metamod/src/mlist.cpp
@@ -108,10 +108,10 @@ MPlugin* MPluginList::find_match(const char* prefix, bool& unique)
if (p->m_status < PL_VALID)
continue;
- if (p->info() && !Q_strnicmp(p->info()->name, prefix, len)
+ if ((p->info() && !Q_strnicmp(p->info()->name, prefix, len))
|| !Q_strnicmp(p->m_desc, prefix, len)
|| !Q_strnicmp(p->m_file, prefix, len)
- || p->info() && !Q_strnicmp(p->info()->logtag, prefix, len)) {
+ || (p->info() && !Q_strnicmp(p->info()->logtag, prefix, len))) {
if (pfound) {
unique = false;
break;
diff --git a/metamod/src/mplayer.h b/metamod/src/mplayer.h
index 8e3f4da..ea1610e 100644
--- a/metamod/src/mplayer.h
+++ b/metamod/src/mplayer.h
@@ -26,6 +26,5 @@ public:
const char* is_querying_cvar(const edict_t* pEntity) const;
private:
- int m_maxplayers = 32;
MPlayer m_players[MAX_CLIENTS + 1]; // array of players
};
diff --git a/metamod/src/mutil.cpp b/metamod/src/mutil.cpp
index a19592b..000edeb 100644
--- a/metamod/src/mutil.cpp
+++ b/metamod/src/mutil.cpp
@@ -202,7 +202,7 @@ int EXT_FUNC mutil_GetUserMsgID(plid_t plid, const char* msgname, int* size)
return umsg->getid();
}
- for (int n = 1; n < arraysize(g_engine_msg_names); n++) {
+ for (unsigned int n = 1; n < arraysize(g_engine_msg_names); n++) {
if (!Q_strcmp(msgname, g_engine_msg_names[n])) {
if (size) *size = -1;
return n;
@@ -221,7 +221,7 @@ const char* EXT_FUNC mutil_GetUserMsgName(plid_t plid, int msgid, int* size)
// Guess names for any built-in g_engine messages mentioned in the SDK;
// from dlls/util.h.
- if (msgid < arraysize(g_engine_msg_names)) {
+ if ((unsigned)msgid < arraysize(g_engine_msg_names)) {
if (size) *size = -1;
return g_engine_msg_names[msgid];
}
diff --git a/metamod/src/public_amalgamation.cpp b/metamod/src/public_amalgamation.cpp
index d6efe09..07211c8 100644
--- a/metamod/src/public_amalgamation.cpp
+++ b/metamod/src/public_amalgamation.cpp
@@ -1,6 +1,4 @@
#include "precompiled.h"
#include "stdc++compat.cpp"
-#include "sys_shared.cpp"
#include "interface.cpp"
-#include "crc32c.cpp"
diff --git a/metamod/src/reg_support.cpp b/metamod/src/reg_support.cpp
index 422a476..99e63cb 100644
--- a/metamod/src/reg_support.cpp
+++ b/metamod/src/reg_support.cpp
@@ -26,7 +26,7 @@ void EXT_FUNC meta_command_handler()
// to a generic command-handler function (see above).
void EXT_FUNC meta_AddServerCommand(const char* cmd_name, void (*function)())
{
- MPlugin* plug = g_plugins->find_memloc(function);
+ MPlugin* plug = g_plugins->find_memloc((void *)function);
META_DEBUG(4, "called: meta_AddServerCommand; cmd_name=%s, function=%d, plugin=%s", cmd_name, function, plug ? plug->file() : "unknown");
diff --git a/metamod/src/utils.h b/metamod/src/utils.h
index 98c5428..a0d538d 100644
--- a/metamod/src/utils.h
+++ b/metamod/src/utils.h
@@ -4,7 +4,7 @@
// stripping off the leading "len" characters. Useful for things like
// turning 'pfnClientCommand' into "ClientCommand" so we don't have to
// specify strings used for all the debugging/log messages.
-#define STRINGIZE(name, len) #name+len
+#define STRINGIZE(name, len) &(#name[len])
// Max description length for plugins.ini and other places.
#define MAX_DESC_LEN 256
diff --git a/metamod/version/appversion.sh b/metamod/version/appversion.sh
new file mode 100755
index 0000000..0719d5e
--- /dev/null
+++ b/metamod/version/appversion.sh
@@ -0,0 +1,158 @@
+#!/bin/bash
+
+init()
+{
+ SOURCE_DIR="$@"
+ GIT_DIR=$SOURCE_DIR
+ VERSION_FILE=$SOURCE_DIR/metamod/version/version.h
+ APPVERSION_FILE=$SOURCE_DIR/metamod/version/appversion.h
+
+ if test -z "`git --version`"; then
+ echo "Please install git client"
+ echo "sudo apt-get install git"
+ exit -1
+ fi
+
+ # Read old version
+ if [ -e "$APPVERSION_FILE" ]; then
+ OLD_VERSION=$(cat "$APPVERSION_FILE" | grep -wi '#define APP_VERSION' | sed -e 's/#define APP_VERSION[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g')
+ if [ $? -ne 0 ]; then
+ OLD_VERSION=""
+ else
+ # Remove quotes
+ OLD_VERSION=$(echo $OLD_VERSION | xargs)
+ fi
+ fi
+
+ # Get major, minor and maintenance information from gradle.properties
+ MAJOR=$(cat "$VERSION_FILE" | grep -wi 'VERSION_MAJOR' | sed -e 's/.*VERSION_MAJOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
+ if [ $? -ne 0 -o "$MAJOR" = "" ]; then
+ MAJOR=0
+ fi
+
+ MINOR=$(cat "$VERSION_FILE" | grep -wi 'VERSION_MINOR' | sed -e 's/.*VERSION_MINOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
+ if [ $? -ne 0 -o "$MINOR" = "" ]; then
+ MINOR=0
+ fi
+
+ MAINTENANCE=$(cat "$VERSION_FILE" | grep -i 'VERSION_MAINTENANCE' | sed -e 's/.*VERSION_MAINTENANCE.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
+ if [ $? -ne 0 -o "$MAINTENANCE" = "" ]; then
+ MAINTENANCE=0
+ fi
+
+ BRANCH_NAME=$(git -C "$GIT_DIR/" rev-parse --abbrev-ref HEAD)
+ if [ $? -ne 0 -o "$BRANCH_NAME" = "" ]; then
+ BRANCH_NAME=master
+ fi
+
+ COMMIT_COUNT=$(git -C "$GIT_DIR/" rev-list --count $BRANCH_NAME)
+ if [ $? -ne 0 -o "$COMMIT_COUNT" = "" ]; then
+ COMMIT_COUNT=0
+ fi
+
+ #
+ # Configure remote url repository
+ #
+ # Get remote name by current branch
+ BRANCH_REMOTE=$(git -C "$GIT_DIR/" config branch.$BRANCH_NAME.remote)
+ if [ $? -ne 0 -o "$BRANCH_REMOTE" = "" ]; then
+ BRANCH_REMOTE=origin
+ fi
+
+ # Get commit id
+ COMMIT_SHA=$(git -C "$GIT_DIR/" rev-parse --verify HEAD)
+ COMMIT_SHA=${COMMIT_SHA:0:7}
+
+ # Get remote url
+ COMMIT_URL=$(git -C "$GIT_DIR/" config remote.$BRANCH_REMOTE.url)
+
+ URL_CONSTRUCT=0
+
+ if [[ "$COMMIT_URL" == *"git@"* ]]; then
+ URL_CONSTRUCT=1
+
+ # Strip prefix 'git@'
+ COMMIT_URL=${COMMIT_URL#git@}
+
+ # Strip postfix '.git'
+ COMMIT_URL=${COMMIT_URL%.git}
+
+ # Replace ':' to '/'
+ COMMIT_URL=${COMMIT_URL/:/\/}
+
+ elif [[ "$COMMIT_URL" == *"https://"* ]]; then
+ URL_CONSTRUCT=1
+
+ # Strip prefix 'https://'
+ COMMIT_URL=${COMMIT_URL#https://}
+
+ # Strip postfix '.git'
+ COMMIT_URL=${COMMIT_URL%.git}
+ fi
+
+ if test "$URL_CONSTRUCT" -eq 1; then
+ # Append extra string
+ if [[ "$COMMIT_URL" == *"bitbucket.org"* ]]; then
+ COMMIT_URL=$(echo https://$COMMIT_URL/commits/)
+ else
+ COMMIT_URL=$(echo https://$COMMIT_URL/commit/)
+ fi
+ fi
+
+ #
+ # Detect local modifications
+ #
+ if [ `git -C "$GIT_DIR/" ls-files -m | wc -l` = 0 ]; then
+ MODIFIED=
+ else
+ MODIFIED=+m
+ fi
+
+ NEW_VERSION="$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT-dev$MODIFIED"
+
+ # Update appversion.h if version has changed or modifications/mixed revisions detected
+ if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
+ update_appversion
+ fi
+}
+
+update_appversion()
+{
+ day=$(date +%d)
+ year=$(date +%Y)
+ hours=$(date +%H:%M:%S)
+ month=$(LANG=en_us_88591; date +"%b")
+
+ # Write appversion.h
+ echo Updating appversion.h, new version is '"'$NEW_VERSION'"', the old one was $OLD_VERSION
+
+ echo -e "#ifndef __APPVERSION_H__\r">"$APPVERSION_FILE"
+ echo -e "#define __APPVERSION_H__\r">>"$APPVERSION_FILE"
+ echo -e "\r">>"$APPVERSION_FILE"
+ echo -e "//\r">>"$APPVERSION_FILE"
+ echo -e "// This file is generated automatically.\r">>"$APPVERSION_FILE"
+ echo -e "// Don't edit it.\r">>"$APPVERSION_FILE"
+ echo -e "//\r">>"$APPVERSION_FILE"
+ echo -e "\r">>"$APPVERSION_FILE"
+ echo -e "// Version defines\r">>"$APPVERSION_FILE"
+ echo -e '#define APP_VERSION "'$NEW_VERSION'"\r'>>"$APPVERSION_FILE"
+
+ echo -e "#define APP_VERSION_C $MAJOR,$MINOR,$MAINTENANCE,$COMMIT_COUNT\r">>"$APPVERSION_FILE"
+ echo -e '#define APP_VERSION_STRD "'$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT'"\r'>>"$APPVERSION_FILE"
+ echo -e "#define APP_VERSION_FLAGS 0x0L\r">>"$APPVERSION_FILE"
+ echo -e "\r">>"$APPVERSION_FILE"
+ echo -e '#define APP_COMMIT_DATE "'$month $day $year'"\r'>>"$APPVERSION_FILE"
+ echo -e '#define APP_COMMIT_TIME "'$hours'"\r'>>"$APPVERSION_FILE"
+ echo -e "\r">>"$APPVERSION_FILE"
+
+ echo -e '#define APP_COMMIT_SHA "'$COMMIT_SHA'"\r'>>"$APPVERSION_FILE"
+ echo -e '#define APP_COMMIT_URL "'$COMMIT_URL'"\r'>>"$APPVERSION_FILE"
+ echo -e "\r">>"$APPVERSION_FILE"
+ echo -e "#endif //__APPVERSION_H__\r">>"$APPVERSION_FILE"
+}
+
+# Initialise
+init $*
+
+# Exit normally
+exit 0
diff --git a/metamod/version/appversion.vm b/metamod/version/appversion.vm
deleted file mode 100644
index 1b8fbf6..0000000
--- a/metamod/version/appversion.vm
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __APPVERSION_H__
-\#define __APPVERSION_H__
-
-//
-// This file is generated automatically.
-// Don't edit it.
-//
-
-// Version defines
-\#define APP_VERSION "$verInfo.asMavenVersion()"
-\#define APP_VERSION_C $verInfo.asMavenVersion(false, ",")
-\#define APP_VERSION_STRD "$verInfo.asMavenVersion(false)"
-\#define APP_VERSION_FLAGS 0x0L
-
-\#define APP_COMMIT_DATE "$verInfo.asCommitDate("yyyy-MM-dd")"
-\#define APP_COMMIT_TIME "$verInfo.asCommitTime()"
-
-\#define APP_COMMIT_SHA "$verInfo.commitSHA"
-\#define APP_COMMIT_URL "$verInfo.commitURL"
-
-#endif //__APPVERSION_H__
diff --git a/metamod/version/glibc_test.sh b/metamod/version/glibc_test.sh
new file mode 100755
index 0000000..74d41d2
--- /dev/null
+++ b/metamod/version/glibc_test.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+main()
+{
+ files=($@)
+
+ declare -A threshold_version
+ threshold_version[CXXABI]="1.3.5"
+ threshold_version[GLIBCXX]="3.4.15"
+ threshold_version[GLIBC]="2.11"
+
+ for k in "${!threshold_version[@]}"; do
+ for f in "${files[@]}"
+ do
+ :
+ version=$(readelf -sV $f | sed -n 's/.*@'$k'_//p' | sort -u -V | tail -1 | cut -d ' ' -f 1)
+
+ # version no present - skipped
+ if [[ -z "$version" ]]; then
+ version="UND"
+ # version is private - skipped
+ elif [ "$version" = "PRIVATE" ]; then
+ version="PRV"
+ # ensure numeric
+ elif [[ $version =~ ^([0-9]+\.){0,2}(\*|[0-9]+)$ ]]; then
+ check_version_greater $version ${threshold_version[$k]}
+ if [[ $? -eq 1 ]]; then
+ echo -e "\033[0;31mAssertion failed:\033[0m Binary \033[0;32m${f}\033[0m has ${k}_\033[0;33m$version\033[0m greater than max version ${k}_\033[0;33m${threshold_version[$k]}\033[0m"
+ exit -1
+ fi
+ fi
+ done
+
+ if [[ "$version" = "PRV" || "$version" = "UND" ]]; then
+ echo -e "[\033[0;90mSKIP\033[0m] \033[0;33m${version}\033[0m < ${k}_\033[0;33m${threshold_version[$k]}\033[0m"
+ else
+ echo -e "[\033[0;32mOK\033[0m] \033[0;33m${version}\033[0m < ${k}_\033[0;33m${threshold_version[$k]}\033[0m"
+ fi
+ done
+}
+
+check_version_greater()
+{
+ if [[ -z "$1" || $1 == $2 ]]; then
+ return 0
+ fi
+
+ local IFS=.
+ local i ver1=($1) ver2=($2)
+
+ # fill empty fields in ver1 with zeros
+ for ((i = ${#ver1[@]}; i < ${#ver2[@]}; i++))
+ do
+ ver1[i]=0
+ done
+
+ for ((i = 0; i < ${#ver1[@]}; i++))
+ do
+ if [[ -z ${ver2[i]} ]]
+ then
+ # fill empty fields in ver2 with zeros
+ ver2[i]=0
+ fi
+
+ if ((10#${ver1[i]} > 10#${ver2[i]}))
+ then
+ return 1
+ fi
+
+ if ((10#${ver1[i]} < 10#${ver2[i]}))
+ then
+ break
+ fi
+ done
+
+ return 0
+}
+
+# Initialize
+main $*
+
+# Exit normally
+exit 0
diff --git a/metamod/version/version.cpp b/metamod/version/version.cpp
deleted file mode 100644
index 5089a5f..0000000
--- a/metamod/version/version.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
-* Version declaration dependency file
-*
-*/
-
-//
-// This file needed just to add the dependency and appversion.h
-//
-#include "precompiled.h"
-
diff --git a/metamod/version/version.h b/metamod/version/version.h
new file mode 100644
index 0000000..90a1e66
--- /dev/null
+++ b/metamod/version/version.h
@@ -0,0 +1,10 @@
+/*
+* Version declaration dependency file
+*
+*/
+
+#pragma once
+
+#define VERSION_MAJOR 1
+#define VERSION_MINOR 3
+#define VERSION_MAINTENANCE 0
diff --git a/publish.gradle b/publish.gradle
deleted file mode 100644
index f98d015..0000000
--- a/publish.gradle
+++ /dev/null
@@ -1,93 +0,0 @@
-import org.doomedsociety.gradlecpp.GradleCppUtils
-import org.apache.commons.io.FilenameUtils
-
-void _copyFileToDir(String from, String to) {
- if (!project.file(from).exists()) {
- println 'WARNING: Could not find: ' + from;
- return;
- }
-
- if (!project.file(to).exists()) {
- project.file(to).mkdirs();
- }
-
- def dst = new File(project.file(to), FilenameUtils.getName(from))
- GradleCppUtils.copyFile(project.file(from), dst, false)
-}
-
-void _copyFile(String from, String to) {
- if (!project.file(from).exists()) {
- println 'WARNING: Could not find: ' + from;
- return;
- }
-
- GradleCppUtils.copyFile(project.file(from), project.file(to), false)
-}
-
-task publishPrepareFiles << {
- def pubRootDir = project.file('publish/publishRoot')
- if (pubRootDir.exists()) {
- if (!pubRootDir.deleteDir()) {
- throw new RuntimeException("Failed to delete ${pubRootDir}")
- }
- }
-
- pubRootDir.mkdirs()
- project.file('publish/publishRoot/metamod/addons/metamod').mkdirs()
-
- _copyFileToDir('publish/metamod.dll', 'publish/publishRoot/metamod/addons/metamod/')
- //_copyFileToDir('publish/metamod.pdb', 'publish/publishRoot/metamod/addons/metamod/')
- _copyFile('publish/metamod_i386.so', 'publish/publishRoot/metamod/addons/metamod/metamod_i386.so')
-
- project.file('publish/publishRoot/metamod/sdk').mkdirs()
- copy {
- from 'metamod/src/dllapi.h'
- into 'publish/publishRoot/metamod/sdk'
- }
- copy {
- from 'metamod/src/engine_api.h'
- into 'publish/publishRoot/metamod/sdk'
- }
- copy {
- from 'metamod/src/enginecallbacks.h'
- into 'publish/publishRoot/metamod/sdk'
- }
- copy {
- from 'metamod/src/h_export.h'
- into 'publish/publishRoot/metamod/sdk'
- }
- copy {
- from 'metamod/src/meta_api.h'
- into 'publish/publishRoot/metamod/sdk'
- }
- copy {
- from 'metamod/src/mutil.h'
- into 'publish/publishRoot/metamod/sdk'
- }
- copy {
- from 'metamod/src/plinfo.h'
- into 'publish/publishRoot/metamod/sdk'
- }
- copy {
- from 'metamod/extra/config.ini'
- into 'publish/publishRoot/metamod/addons/metamod/'
- }
- copy {
- from 'metamod/extra/example'
- into 'publish/publishRoot/metamod/example_plugin'
- }
- copy {
- from 'publish/publishRoot/metamod/sdk'
- into 'publish/publishRoot/metamod/example_plugin/include/metamod'
- }
-}
-
-task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') {
- baseName = "metamod_${project.version}"
- destinationDir file('publish')
- from 'publish/publishRoot/metamod'
-}
-
-task doPackage {
- dependsOn 'publishPackage'
-}
diff --git a/settings.gradle b/settings.gradle
deleted file mode 100644
index 3969a27..0000000
--- a/settings.gradle
+++ /dev/null
@@ -1,2 +0,0 @@
-rootProject.name = 'metamod'
-include 'metamod'
diff --git a/shared.gradle b/shared.gradle
deleted file mode 100644
index cc61691..0000000
--- a/shared.gradle
+++ /dev/null
@@ -1,33 +0,0 @@
-import org.doomedsociety.gradlecpp.cfg.BinaryKind
-import org.doomedsociety.gradlecpp.toolchain.icc.Icc
-import org.gradle.nativeplatform.NativeBinarySpec
-import org.gradle.nativeplatform.NativeExecutableBinarySpec
-import org.gradle.nativeplatform.SharedLibraryBinarySpec
-import org.gradle.nativeplatform.StaticLibraryBinarySpec
-import org.gradle.nativeplatform.toolchain.VisualCpp
-
-apply from: 'shared_msvc.gradle'
-apply from: 'shared_icc.gradle'
-
-rootProject.ext.createToolchainConfig = { NativeBinarySpec bin ->
- BinaryKind binaryKind
- if (bin instanceof NativeExecutableBinarySpec) {
- binaryKind = BinaryKind.EXECUTABLE
- } else if (bin instanceof SharedLibraryBinarySpec) {
- binaryKind = BinaryKind.SHARED_LIBRARY
- } else if (bin instanceof StaticLibraryBinarySpec) {
- binaryKind = BinaryKind.STATIC_LIBRARY
- } else {
- throw new RuntimeException("Unknown executable kind ${bin.class.name}")
- }
-
- boolean releaseBuild = bin.buildType.name.toLowerCase() == 'release'
-
- if (bin.toolChain instanceof VisualCpp) {
- return rootProject.createMsvcConfig(releaseBuild, binaryKind)
- } else if (bin.toolChain instanceof Icc) {
- return rootProject.createIccConfig(releaseBuild, binaryKind)
- } else {
- throw new RuntimeException("Unknown native toolchain: ${bin.toolChain.class.name}")
- }
-}
diff --git a/shared_icc.gradle b/shared_icc.gradle
deleted file mode 100644
index d20a9cc..0000000
--- a/shared_icc.gradle
+++ /dev/null
@@ -1,70 +0,0 @@
-import org.doomedsociety.gradlecpp.cfg.BinaryKind
-import org.doomedsociety.gradlecpp.gcc.GccToolchainConfig
-import org.doomedsociety.gradlecpp.gcc.OptimizationLevel
-
-rootProject.ext.createIccConfig = { boolean release, BinaryKind binKind ->
- GccToolchainConfig cfg
- if (release) {
- cfg = new GccToolchainConfig(
- compilerOptions: new GccToolchainConfig.CompilerOptions(
- optimizationLevel: OptimizationLevel.LEVEL_3,
- stackProtector: false,
- interProceduralOptimizations: true,
- noBuiltIn: true,
- intelExtensions: false,
- asmBlocks: true,
- positionIndependentCode: false,
-
- extraDefines: [
- 'linux': null,
- '__linux__': null,
- 'NDEBUG': null,
- '_GLIBCXX_USE_CXX11_ABI': 0
- ]
- ),
-
- linkerOptions: new GccToolchainConfig.LinkerOptions(
- interProceduralOptimizations: true,
- stripSymbolTable: true,
- staticLibGcc: false,
- staticIntel: true,
- staticLibStdCpp: false,
- ),
-
- librarianOptions: new GccToolchainConfig.LibrarianOptions(
- )
- )
- } else {
- //debug
- cfg = new GccToolchainConfig(
- compilerOptions: new GccToolchainConfig.CompilerOptions(
- optimizationLevel: OptimizationLevel.DISABLE,
- stackProtector: true,
- interProceduralOptimizations: false,
- noBuiltIn: true,
- intelExtensions: false,
- asmBlocks: true,
-
- extraDefines: [
- 'linux': null,
- '__linux__': null,
- 'NDEBUG': null,
- '_GLIBCXX_USE_CXX11_ABI': 0
- ]
- ),
-
- linkerOptions: new GccToolchainConfig.LinkerOptions(
- interProceduralOptimizations: false,
- stripSymbolTable: false,
- staticLibGcc: false,
- staticIntel: true,
- staticLibStdCpp: false,
- ),
-
- librarianOptions: new GccToolchainConfig.LibrarianOptions(
- )
- )
- }
-
- return cfg;
-}
diff --git a/shared_msvc.gradle b/shared_msvc.gradle
deleted file mode 100644
index 129fc06..0000000
--- a/shared_msvc.gradle
+++ /dev/null
@@ -1,141 +0,0 @@
-import org.doomedsociety.gradlecpp.cfg.BinaryKind
-import org.doomedsociety.gradlecpp.msvc.CallingConvention
-import org.doomedsociety.gradlecpp.msvc.CodeGenerationKind
-import org.doomedsociety.gradlecpp.msvc.CppExceptions
-import org.doomedsociety.gradlecpp.msvc.DebugInfoFormat
-import org.doomedsociety.gradlecpp.msvc.EnhancedInstructionsSet
-import org.doomedsociety.gradlecpp.msvc.ErrorReporting
-import org.doomedsociety.gradlecpp.msvc.FloatingPointModel
-import org.doomedsociety.gradlecpp.msvc.LinkTimeCodeGenKind
-import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig
-import org.doomedsociety.gradlecpp.msvc.OptimizationLevel
-import org.doomedsociety.gradlecpp.msvc.RuntimeChecks
-import org.doomedsociety.gradlecpp.msvc.WarningLevel
-
-rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind ->
- MsvcToolchainConfig cfg
- if (release) {
- cfg = new MsvcToolchainConfig(
- compilerOptions: new MsvcToolchainConfig.CompilerOptions(
- codeGeneration: CodeGenerationKind.MULTITHREADED,
- optimizationLevel: OptimizationLevel.FULL_OPTIMIZATION,
- debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE,
- runtimeChecks: RuntimeChecks.DEFAULT,
- cppExceptions: CppExceptions.DISABLED,
- warningLevel: WarningLevel.LEVEL_3,
- callingConvention: CallingConvention.CDECL,
- enhancedInstructionsSet: EnhancedInstructionsSet.SSE2,
- floatingPointModel: FloatingPointModel.FAST,
-
- enableMinimalRebuild: false,
- omitFramePointers: true,
- wholeProgramOptimization: true,
- enabledFunctionLevelLinking: true,
- enableSecurityCheck: false,
- analyzeCode: false,
- sdlChecks: false,
- treatWarningsAsErrors: false,
- treatWchartAsBuiltin: true,
- forceConformanceInForLoopScope: true,
-
- extraDefines: [
- 'WIN32': null,
- '_MBCS': null,
- 'NDEBUG': null,
- 'NOMINMAX': null
- ]
- ),
-
- linkerOptions: new MsvcToolchainConfig.LinkerOptions(
- linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG,
- errorReportingMode: ErrorReporting.NO_ERROR_REPORT,
-
- enableIncrementalLinking: false,
- eliminateUnusedRefs: true,
- enableCOMDATFolding: true,
- generateDebugInfo: true,
- dataExecutionPrevention: true,
- randomizedBaseAddress: true
- ),
-
- librarianOptions: new MsvcToolchainConfig.LibrarianOptions(
- linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG
- ),
-
- generatePdb: true
- )
- } else {
- //debug
- cfg = new MsvcToolchainConfig(
- compilerOptions: new MsvcToolchainConfig.CompilerOptions(
- codeGeneration: CodeGenerationKind.MULTITHREADED_DEBUG,
- optimizationLevel: OptimizationLevel.DISABLED,
- debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE,
- runtimeChecks: RuntimeChecks.DEFAULT,
- cppExceptions: CppExceptions.ENABLED_WITH_SEH,
- warningLevel: WarningLevel.LEVEL_3,
- callingConvention: CallingConvention.CDECL,
- enhancedInstructionsSet: EnhancedInstructionsSet.SSE2,
- floatingPointModel: FloatingPointModel.FAST,
-
- enableMinimalRebuild: true,
- omitFramePointers: false,
- wholeProgramOptimization: false,
- enabledFunctionLevelLinking: true,
- enableSecurityCheck: true,
- analyzeCode: false,
- sdlChecks: false,
- treatWarningsAsErrors: false,
- treatWchartAsBuiltin: true,
- forceConformanceInForLoopScope: true,
-
- extraDefines: [
- 'WIN32': null,
- '_MBCS': null,
- '_DEBUG': null,
- 'NOMINMAX': null,
- ]
- ),
-
- linkerOptions: new MsvcToolchainConfig.LinkerOptions(
- linkTimeCodeGenKind: LinkTimeCodeGenKind.DEFAULT,
- errorReportingMode: ErrorReporting.NO_ERROR_REPORT,
-
- enableIncrementalLinking: true,
- eliminateUnusedRefs: false,
- enableCOMDATFolding: false,
- generateDebugInfo: true,
- dataExecutionPrevention: true,
- randomizedBaseAddress: true
- ),
-
- librarianOptions: new MsvcToolchainConfig.LibrarianOptions(
- linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG
- ),
-
- generatePdb: true
- )
-
- if (binKind == BinaryKind.STATIC_LIBRARY) {
- cfg.compilerConfig.extraDefines['_LIB'] = null
- }
- }
-
- // Detect and setup UCRT paths
- def ucrtInfo = "getucrtinfo.bat".execute().text
- def m = ucrtInfo =~ /^(.*)\r\n(.*)?$/
- if (!m.find()) {
- return cfg
- }
- def kitPath = m.group(1)
- def ucrtVersion = m.group(2)
- def ucrtCheckFile = new File("${kitPath}Include/${ucrtVersion}/ucrt/stdio.h");
- if (!ucrtCheckFile.exists()) {
- return cfg
- }
-
- cfg.compilerOptions.args "/FS", "/I${kitPath}Include/${ucrtVersion}/ucrt";
- cfg.linkerOptions.args("/LIBPATH:${kitPath}Lib/${ucrtVersion}/ucrt/x86");
-
- return cfg
-}
diff --git a/version_script.lds b/version_script.lds
new file mode 100644
index 0000000..2b8e4ad
--- /dev/null
+++ b/version_script.lds
@@ -0,0 +1,30 @@
+METAMOD_ABI_1.0 {
+ global:
+ GiveFnptrsToDll;
+ GetEntityAPI;
+ GetEntityAPI2;
+ GetNewDLLFunctions;
+ Server_GetBlendingInterface;
+ worldspawn;
+ extern "C++" {
+ mutil_*;
+ mm_*;
+ metamod_*;
+ meta_*;
+ META_*;
+ get_function_table*;
+ do_link_ent*;
+ cmd_*;
+ compile_*;
+ client_meta*;
+ MReg*::*;
+ MPlugin*::*;
+ MPlayer*::*;
+ MConfig::*;
+ CJit::*;
+ CForwardCallbackJIT::*;
+ CExtDll::*;
+ };
+ local:
+ *;
+};