mirror of
https://github.com/rehlds/metamod-r.git
synced 2025-05-12 14:49:29 +03:00
Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
273618c684 | |||
0424bed00e | |||
ae86a6f41e | |||
d24c1994b7 | |||
616d208a25 | |||
1027ed0515 | |||
98879bdaac | |||
d8ddb05638 | |||
22c0ec665b | |||
8e4b8af1c4 | |||
|
011e8234e2 | ||
8dcdd6833c | |||
720a63eacd | |||
29b24fb9ea | |||
a2cc1fb8bd | |||
31c8b41738 | |||
|
cedda15813 | ||
|
603a2574e9 | ||
|
096f4383b0 | ||
265a818856 | |||
cd11920267 | |||
d7125e99e9 | |||
3d783bdb9b | |||
0e0d84013e | |||
385a2229da | |||
a05af41a82 | |||
6d3a663c33 | |||
d672d76bbd | |||
|
5179c25986 | ||
|
24e086ae2f | ||
|
0c99300d8d | ||
|
3af38129f4 | ||
|
83c9d6e177 | ||
|
0118e05280 | ||
|
ec926a611f | ||
|
adc94141a4 | ||
|
b838abda59 | ||
|
80145abcb7 |
@ -8,4 +8,5 @@ root = true
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
165
.github/workflows/build.yml
vendored
Normal file
165
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,165 @@
|
||||
name: C/C++ CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '.github/**'
|
||||
|
||||
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@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v2
|
||||
|
||||
- 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@v4
|
||||
with:
|
||||
name: win32
|
||||
path: publish/*
|
||||
|
||||
linux:
|
||||
name: 'Linux'
|
||||
runs-on: ubuntu-latest
|
||||
container: debian:11-slim
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
dpkg --add-architecture i386
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
gcc-multilib g++-multilib \
|
||||
build-essential \
|
||||
libc6-dev libc6-dev-i386 \
|
||||
git cmake rsync \
|
||||
g++ gcc
|
||||
|
||||
- name: Build using Intel GCC Compiler
|
||||
run: |
|
||||
rm -rf build && 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@v4
|
||||
id: upload-job
|
||||
with:
|
||||
name: linux32
|
||||
path: publish/*
|
||||
|
||||
publish:
|
||||
name: 'Publish'
|
||||
runs-on: ubuntu-latest
|
||||
needs: [windows, linux]
|
||||
|
||||
steps:
|
||||
- name: Deploying linux artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux32
|
||||
|
||||
- name: Deploying windows artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
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@v2
|
||||
id: publish-job
|
||||
if: |
|
||||
startsWith(github.ref, 'refs/tags/') &&
|
||||
steps.packaging-job.outcome == 'success'
|
||||
with:
|
||||
files: |
|
||||
*.zip
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -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
|
103
CHANGELOG.md
Normal file
103
CHANGELOG.md
Normal file
@ -0,0 +1,103 @@
|
||||
# [Metamod-r](https://github.com/rehlds/metamod-r) Changelog
|
||||
|
||||
**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 numerous performance optimizations and cleaner code. The core was rewritten with a JIT compiler.
|
||||
|
||||
`*` Original changelog [here](https://github.com/Bots-United/metamod-p/blob/master/doc/Changelog).
|
||||
|
||||
---
|
||||
|
||||
## [`1.3.0.149`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.149) - 2024-04-23
|
||||
|
||||
### Fixed
|
||||
- Fixed shutdown issue
|
||||
|
||||
**Full Changelog**: [1.3.0.138...1.3.0.149](https://github.com/rehlds/metamod-r/compare/1.3.0.138...1.3.0.149)
|
||||
|
||||
## [`1.3.0.138`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.138) - 2023-11-28
|
||||
|
||||
### Changed
|
||||
- Improved ReHLDS API initialization.
|
||||
|
||||
### Fixed
|
||||
- HLDS compatibility
|
||||
- [Fixed](https://github.com/rehlds/metamod-r/commit/ec926a611f4d225bb433609bf827269ad8482618) gracefully shuts down Metamod and plugins when the game is closing (now the _restart command works properly).
|
||||
|
||||
**Full Changelog**: [1.3.0.131...1.3.0.138](https://github.com/rehlds/metamod-r/compare/1.3.0.131...1.3.0.138)
|
||||
|
||||
## [`1.3.0.131`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.131) - 2018-08-24
|
||||
|
||||
### Changed
|
||||
- Updated `C++ Intel Compiler` version `17.0` > `19.0`.
|
||||
|
||||
**Full Changelog**: [1.3.0.128...1.3.0.131](https://github.com/rehlds/metamod-r/compare/1.3.0.128...1.3.0.131)
|
||||
|
||||
## [`1.3.0.128`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.128) - 2018-08-24
|
||||
|
||||
### Fixed
|
||||
- [Fixed](https://github.com/rehlds/metamod-r/commit/0cf2f709dbeae18ca84d2fafd4481ffbba06ad0c) two bugs in `jit`.
|
||||
|
||||
**Full Changelog**: [1.3.0.126...1.3.0.128](https://github.com/rehlds/metamod-r/compare/1.3.0.126...1.3.0.128)
|
||||
|
||||
## [`1.3.0.126`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.126) - 2018-05-10
|
||||
|
||||
### Fixed
|
||||
- [Fixed](https://github.com/rehlds/metamod-r/commit/93b5bd45e279aad6a91e71504dd8deaf9896ab42) crashes in `pfnAlertMessage`.
|
||||
|
||||
**Full Changelog**: [1.3.0.125...1.3.0.126](https://github.com/rehlds/metamod-r/compare/1.3.0.125...1.3.0.126)
|
||||
|
||||
## [`1.3.0.125`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.125) - 2018-04-30
|
||||
|
||||
### Fixed
|
||||
- [Fixed](https://github.com/rehlds/metamod-r/commit/6456c5f7ec872cd98d9be964440cf96780899558#diff-f15b77cc15bf608d761260093dfe8e0d) binary names to correctly auto-detect games.
|
||||
|
||||
**Full Changelog**: [1.3.0.119...1.3.0.125](https://github.com/rehlds/metamod-r/compare/1.3.0.119...1.3.0.125)
|
||||
|
||||
## [`1.3.0.119`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.119) - 2018-03-12
|
||||
|
||||
### Added
|
||||
- Added support for various gamedll binaries for mods.
|
||||
- Added `mm_pluginsfile` option.
|
||||
|
||||
**Full Changelog**: [1.3.0.107...1.3.0.119](https://github.com/rehlds/metamod-r/compare/1.3.0.107...1.3.0.119)
|
||||
|
||||
## [`1.3.0.107`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.107) - 2018-01-29
|
||||
|
||||
### Fixed
|
||||
- Fixed problems with API functions returning float.
|
||||
|
||||
### Added
|
||||
- [Added](https://github.com/rehlds/metamod-r/commit/132cbad0099c9903123d7ff7c3e1c13344efb3c9) support for more games.
|
||||
|
||||
### Changed
|
||||
- Refactored code.
|
||||
|
||||
**Full Changelog**: [1.3.0.86...1.3.0.107](https://github.com/rehlds/metamod-r/compare/1.3.0.86...1.3.0.107)
|
||||
|
||||
## [`1.3.0.86`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.86) - 2017-11-15
|
||||
|
||||
### Fixed
|
||||
- [Fixed crash](https://github.com/rehlds/metamod-r/commit/5b7fe147231df9354a8fe29c3852bd1db8119e81) and reworked `find_memloc`.
|
||||
|
||||
**Full Changelog**: [1.3.0.85...1.3.0.86](https://github.com/rehlds/metamod-r/compare/1.3.0.85...1.3.0.86)
|
||||
|
||||
## [`1.3.0.85`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.85) - 2017-11-15
|
||||
|
||||
### Fixed
|
||||
- Fixed parse plugins.ini (loads the plugins for an appropriate platform only).
|
||||
- Fixed crash for meta-plugins using UPX.
|
||||
|
||||
**Full Changelog**: [1.3.0.84...1.3.0.85](https://github.com/rehlds/metamod-r/compare/1.3.0.84...1.3.0.85)
|
||||
|
||||
## [`1.3.0.84`](https://github.com/rehlds/metamod-r/releases/tag/1.3.0.84) - 2017-10-27
|
||||
|
||||
### Added
|
||||
- First public release.
|
||||
|
||||
### Changed
|
||||
- Minor refactoring.
|
||||
|
||||
## `0.0.0.0` (based on `1.20p35`) - 2016-07-04
|
||||
|
||||
### Added
|
||||
- Started `metamod-r` project by forking from `metamod-p`. Based on version `1.20p35`.
|
||||
- The official changelog of the original version is missing.
|
12
CMakeLists.txt
Normal file
12
CMakeLists.txt
Normal file
@ -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)
|
103
README.md
103
README.md
@ -1,34 +1,91 @@
|
||||
# metamod-r
|
||||
|
||||
|
||||
# [Metamod-r](https://github.com/rehlds/metamod-r) [](http://isitmaintained.com/project/rehlds/metamod-r "Percentage of issues still open") [](https://github.com/rehlds/metamod-r/blob/master/LICENSE)
|
||||
|
||||
**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 recommended to be run with [ReHLDS](https://github.com/rehlds/ReHLDS) (`API 3.1+`).
|
||||
There is compatible with original `HLDS`**
|
||||
|
||||
**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/rehlds/ReHLDS) | OS | Download |
|
||||
|---------| -------| --- | --- |
|
||||
| :heavy_check_mark: | :heavy_check_mark: `API 3.1+` |  | [](https://github.com/rehlds/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)
|
||||
|
||||
|
||||
Distributed under
|
||||
[](https://github.com/theAsmodai/metamod-r/blob/master/LICENSE).
|
||||
[](https://github.com/rehlds/metamod-r/)
|
||||
[](https://github.com/rehlds/metamod-r/issues)
|
||||
[](https://github.com/rehlds/metamod-r/network)
|
||||
[](https://github.com/rehlds/metamod-r/stargazers)
|
||||
|
||||
## 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/rehlds/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/Поддерживаемые-игры).
|
||||
*  Actual [list of supported games](https://github.com/rehlds/metamod-r/wiki/Supported-games).
|
||||
*  Актуальный [список поддерживаемых игр](https://github.com/rehlds/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
|
||||
<pre>
|
||||
Visual Studio 2015 (C++14 standard) and later
|
||||
</pre>
|
||||
|
||||
#### Linux
|
||||
<pre>
|
||||
git >= 1.8.5
|
||||
cmake >= 3.10
|
||||
GCC >= 4.9.2 (Optional)
|
||||
ICC >= 15.0.1 20141023 (Optional)
|
||||
LLVM (Clang) >= 6.0 (Optional)
|
||||
</pre>
|
||||
|
||||
### 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)
|
||||
|
||||
<pre>
|
||||
-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)
|
||||
|
||||
<sub>Definitions (-D)</sub>
|
||||
DEBUG - Enables debugging mode
|
||||
USE_STATIC_LIBSTDC - Enables static linking library libstdc++
|
||||
</pre>
|
||||
|
||||
* ICC <pre>./build.sh --compiler=intel</pre>
|
||||
* LLVM (Clang) <pre>./build.sh --compiler=clang</pre>
|
||||
* GCC <pre>./build.sh --compiler=gcc</pre>
|
||||
|
||||
##### Checking build environment (Debian / Ubuntu)
|
||||
|
||||
<details>
|
||||
<summary>Click to expand</summary>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Installing required packages
|
||||
<pre>
|
||||
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
|
||||
</pre>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Select the preferred C/C++ Compiler installation
|
||||
<pre>
|
||||
1) sudo apt-get install -y gcc g++
|
||||
2) sudo apt-get install -y clang
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</details>
|
||||
|
54
build.gradle
54
build.gradle
@ -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'
|
||||
}
|
60
build.sh
Executable file
60
build.sh
Executable file
@ -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 <options>\n\n"
|
||||
printf " -c= | --compiler=<icc|gcc|clang> - Select preferred C/C++ compiler to build\n"
|
||||
printf " -j= | --jobs=<N> - Specifies the number of jobs (commands) to run simultaneously (For faster building)\n\n"
|
||||
}
|
||||
|
||||
# Initialize
|
||||
main $*
|
||||
|
||||
# Exit normally
|
||||
exit 0
|
@ -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'
|
||||
}
|
@ -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<String, ? extends Object> 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()
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
@ -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<RevCommit> 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<String> 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)
|
||||
)
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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%
|
@ -1,3 +0,0 @@
|
||||
majorVersion=1
|
||||
minorVersion=3
|
||||
maintenanceVersion=0
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
6
gradle/wrapper/gradle-wrapper.properties
vendored
@ -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
|
164
gradlew
vendored
164
gradlew
vendored
@ -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 "$@"
|
90
gradlew.bat
vendored
90
gradlew.bat
vendored
@ -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
|
198
metamod/CMakeLists.txt
Normal file
198
metamod/CMakeLists.txt
Normal file
@ -0,0 +1,198 @@
|
||||
#----------------------------------------
|
||||
# 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")
|
||||
|
||||
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 -O0 -ggdb")
|
||||
else()
|
||||
set(COMPILE_FLAGS "${COMPILE_FLAGS} -g0 -O3 -fno-stack-protector")
|
||||
set(LINK_FLAGS "${LINK_FLAGS} -s")
|
||||
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/osdep_linkent_linux.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
|
||||
pthread
|
||||
$<$<CONFIG:COMPAT_GLIBC>: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
|
||||
)
|
@ -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<Task> 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 + ')';
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ COMPILER = g++
|
||||
|
||||
OBJECTS = *.cpp
|
||||
|
||||
LINK =
|
||||
LINK = -ldl
|
||||
|
||||
OPT_FLAGS = -O3 -msse3 -flto -funroll-loops -fomit-frame-pointer -fno-stack-protector -fPIC
|
||||
|
||||
@ -15,9 +15,9 @@ INCLUDE = -I. -I$(HLSDK)/common -I$(HLSDK)/dlls -I$(HLSDK)/engine \
|
||||
-I$(HLSDK)/game_shared -I$(HLSDK)/pm_shared -I$(HLSDK)/public -I$(METAMOD)
|
||||
|
||||
BIN_DIR = Release
|
||||
CFLAGS = $(OPT_FLAGS)
|
||||
CFLAGS = $(OPT_FLAGS) -Wno-unused-result
|
||||
|
||||
CFLAGS += -g -DNDEBUG -Dlinux -D__linux__ -D__USE_GNU -std=gnu++11 -shared
|
||||
CFLAGS += -g -DNDEBUG -Dlinux -D__linux__ -D__USE_GNU -std=gnu++11 -shared -m32
|
||||
|
||||
OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o)
|
||||
|
||||
|
@ -7,7 +7,7 @@ const RehldsFuncs_t* g_RehldsFuncs;
|
||||
IRehldsHookchains* g_RehldsHookchains;
|
||||
IRehldsServerStatic* g_RehldsSvs;
|
||||
|
||||
bool rehlds_api_try_init(CSysModule* engineModule, char* failureReason)
|
||||
bool rehlds_api_init(CSysModule* engineModule)
|
||||
{
|
||||
if (!engineModule) {
|
||||
gpMetaUtilFuncs->pfnLogConsole(PLID, "Failed to locate engine module\n");
|
||||
@ -16,14 +16,13 @@ bool rehlds_api_try_init(CSysModule* engineModule, char* failureReason)
|
||||
|
||||
CreateInterfaceFn ifaceFactory = Sys_GetFactory(engineModule);
|
||||
if (!ifaceFactory) {
|
||||
sprintf(failureReason, "Failed to locate interface factory in engine module\n");
|
||||
gpMetaUtilFuncs->pfnLogConsole(PLID, "Failed to locate interface factory in engine module\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
int retCode = 0;
|
||||
g_RehldsApi = (IRehldsApi*)ifaceFactory(VREHLDS_HLDS_API_VERSION, &retCode);
|
||||
if (!g_RehldsApi) {
|
||||
sprintf(failureReason, "Failed to locate retrieve rehlds api interface from engine module, return code is %d\n", retCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -31,12 +30,12 @@ bool rehlds_api_try_init(CSysModule* engineModule, char* failureReason)
|
||||
int minorVersion = g_RehldsApi->GetMinorVersion();
|
||||
|
||||
if (majorVersion != REHLDS_API_VERSION_MAJOR) {
|
||||
sprintf(failureReason, "REHLDS Api major version mismatch; expected %d, real %d\n", REHLDS_API_VERSION_MAJOR, majorVersion);
|
||||
gpMetaUtilFuncs->pfnLogConsole(PLID, "REHLDS Api major version mismatch; expected %d, real %d\n", REHLDS_API_VERSION_MAJOR, majorVersion);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (minorVersion < REHLDS_API_VERSION_MINOR) {
|
||||
sprintf(failureReason, "REHLDS Api minor version mismatch; expected at least %d, real %d\n", REHLDS_API_VERSION_MINOR, minorVersion);
|
||||
gpMetaUtilFuncs->pfnLogConsole(PLID, "REHLDS Api minor version mismatch; expected at least %d, real %d\n", REHLDS_API_VERSION_MINOR, minorVersion);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -47,25 +46,31 @@ bool rehlds_api_try_init(CSysModule* engineModule, char* failureReason)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool meta_init_rehlds_api() {
|
||||
char failReason[2048];
|
||||
|
||||
#ifdef WIN32
|
||||
CSysModule* engineModule = Sys_LoadModule("swds.dll");
|
||||
if (!rehlds_api_try_init(engineModule, failReason)) {
|
||||
engineModule = Sys_LoadModule("filesystem_stdio.dll");
|
||||
if (!rehlds_api_try_init(engineModule, failReason)) {
|
||||
gpMetaUtilFuncs->pfnLogConsole(PLID, "%s", failReason);
|
||||
return false;
|
||||
}
|
||||
bool meta_init_rehlds_api()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Find the most appropriate module handle from a list of DLL candidates
|
||||
// Notes:
|
||||
// - "swds.dll" is the library Dedicated Server
|
||||
//
|
||||
// Let's also attempt to locate the ReHLDS API in the client's library
|
||||
// - "sw.dll" is the client library for Software render, with a built-in listenserver
|
||||
// - "hw.dll" is the client library for Hardware render, with a built-in listenserver
|
||||
const char *dllNames[] = { "swds.dll", "hw.dll", "sw.dll" }; // List of DLL candidates to lookup for the ReHLDS API
|
||||
CSysModule *engineModule = NULL; // The module handle of the selected DLL
|
||||
for (const char *dllName : dllNames)
|
||||
{
|
||||
if (engineModule = Sys_GetModuleHandle(dllName))
|
||||
break; // gotcha
|
||||
}
|
||||
|
||||
#else
|
||||
CSysModule* engineModule = Sys_LoadModule("engine_i486.so");
|
||||
if (!rehlds_api_try_init(engineModule, failReason)) {
|
||||
gpMetaUtilFuncs->pfnLogConsole(PLID, "%s", failReason);
|
||||
CSysModule *engineModule = Sys_GetModuleHandle("engine_i486.so");
|
||||
#endif
|
||||
|
||||
if (!rehlds_api_init(engineModule)) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -121,6 +121,14 @@ void *Sys_GetProcAddress(void *pModuleHandle, const char *pName)
|
||||
return GetProcAddress((HMODULE)pModuleHandle, pName);
|
||||
}
|
||||
|
||||
// Purpose: Returns a module handle by its name.
|
||||
// Input : pModuleName - module name
|
||||
// Output : the module handle or NULL in case of an error
|
||||
CSysModule *Sys_GetModuleHandle(const char *pModuleName)
|
||||
{
|
||||
return reinterpret_cast<CSysModule *>(GetModuleHandle(pModuleName));
|
||||
}
|
||||
|
||||
// Purpose: Loads a DLL/component from disk and returns a handle to it
|
||||
// Input : *pModuleName - filename of the component
|
||||
// Output : opaque handle to the module (hides system dependency)
|
||||
|
@ -114,6 +114,8 @@ extern CreateInterfaceFn Sys_GetFactory(const char *pModuleName);
|
||||
// load/unload components
|
||||
class CSysModule;
|
||||
|
||||
extern CSysModule *Sys_GetModuleHandle(const char *pModuleName);
|
||||
|
||||
// Load & Unload should be called in exactly one place for each module
|
||||
// The factory for that module should be passed on to dependent components for
|
||||
// proper versioning.
|
||||
|
@ -13,22 +13,25 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{1B03767B-CB83-4A1B-8480-EF08D557838B}</ProjectGuid>
|
||||
<RootNamespace>example_plugin</RootNamespace>
|
||||
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@ -47,8 +50,6 @@
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
@ -64,8 +65,6 @@
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
@ -77,10 +76,7 @@
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<ModuleDefinitionFile>example_plugin.def</ModuleDefinitionFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "sys_shared.cpp"
|
||||
#include "interface.cpp"
|
||||
|
||||
|
@ -1,15 +1,23 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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)
|
||||
|
173
metamod/include/engine/physint.h
Normal file
173
metamod/include/engine/physint.h
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
physint.h - Server Physics Interface
|
||||
Copyright (C) 2011 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef PHYSINT_H
|
||||
#define PHYSINT_H
|
||||
|
||||
#include "eiface.h" // offsetof
|
||||
|
||||
#define SV_PHYSICS_INTERFACE_VERSION 6
|
||||
|
||||
#define STRUCT_FROM_LINK( l, t, m ) ((t *)((byte *)l - offsetof(t, m)))
|
||||
#define EDICT_FROM_AREA( l ) STRUCT_FROM_LINK( l, edict_t, area )
|
||||
|
||||
// values that can be returned with pfnServerState
|
||||
#define SERVER_DEAD 0
|
||||
#define SERVER_LOADING 1
|
||||
#define SERVER_ACTIVE 2
|
||||
|
||||
// LUMP reading errors
|
||||
#define LUMP_LOAD_OK 0
|
||||
#define LUMP_LOAD_COULDNT_OPEN 1
|
||||
#define LUMP_LOAD_BAD_HEADER 2
|
||||
#define LUMP_LOAD_BAD_VERSION 3
|
||||
#define LUMP_LOAD_NO_EXTRADATA 4
|
||||
#define LUMP_LOAD_INVALID_NUM 5
|
||||
#define LUMP_LOAD_NOT_EXIST 6
|
||||
#define LUMP_LOAD_MEM_FAILED 7
|
||||
#define LUMP_LOAD_CORRUPTED 8
|
||||
|
||||
// LUMP saving errors
|
||||
#define LUMP_SAVE_OK 0
|
||||
#define LUMP_SAVE_COULDNT_OPEN 1
|
||||
#define LUMP_SAVE_BAD_HEADER 2
|
||||
#define LUMP_SAVE_BAD_VERSION 3
|
||||
#define LUMP_SAVE_NO_EXTRADATA 4
|
||||
#define LUMP_SAVE_INVALID_NUM 5
|
||||
#define LUMP_SAVE_ALREADY_EXIST 6
|
||||
#define LUMP_SAVE_NO_DATA 7
|
||||
#define LUMP_SAVE_CORRUPTED 8
|
||||
|
||||
#ifndef ALLOC_CHECK
|
||||
#define ALLOC_CHECK( x )
|
||||
#endif
|
||||
|
||||
typedef struct areanode_s
|
||||
{
|
||||
int axis; // -1 = leaf node
|
||||
float dist;
|
||||
struct areanode_s *children[2];
|
||||
link_t trigger_edicts;
|
||||
link_t solid_edicts;
|
||||
link_t portal_edicts;
|
||||
} areanode_t;
|
||||
|
||||
typedef struct server_physics_api_s
|
||||
{
|
||||
// unlink edict from old position and link onto new
|
||||
void ( *pfnLinkEdict) ( edict_t *ent, qboolean touch_triggers );
|
||||
double ( *pfnGetServerTime )( void ); // unclamped
|
||||
double ( *pfnGetFrameTime )( void ); // unclamped
|
||||
void* ( *pfnGetModel )( int modelindex );
|
||||
areanode_t* ( *pfnGetHeadnode )( void ); // AABB tree for all physic entities
|
||||
int ( *pfnServerState )( void );
|
||||
void ( *pfnHost_Error )( const char *error, ... ); // cause Host Error
|
||||
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 6
|
||||
struct triangleapi_s *pTriAPI; // draw coliisions etc. Only for local system
|
||||
|
||||
// draw debug messages (must be called from DrawOrthoTriangles). Only for local system
|
||||
int ( *pfnDrawConsoleString )( int x, int y, char *string );
|
||||
void ( *pfnDrawSetTextColor )( float r, float g, float b );
|
||||
void ( *pfnDrawConsoleStringLen )( const char *string, int *length, int *height );
|
||||
void ( *Con_NPrintf )( int pos, const char *fmt, ... );
|
||||
void ( *Con_NXPrintf )( struct con_nprint_s *info, const char *fmt, ... );
|
||||
const char *( *pfnGetLightStyle )( int style ); // read custom appreance for selected lightstyle
|
||||
void ( *pfnUpdateFogSettings )( unsigned int packed_fog );
|
||||
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly );
|
||||
struct msurface_s *(*pfnTraceSurface)( edict_t *pTextureEntity, const float *v1, const float *v2 );
|
||||
const byte *(*pfnGetTextureData)( unsigned int texnum );
|
||||
|
||||
// static allocations
|
||||
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline ) ALLOC_CHECK( 1 );
|
||||
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
|
||||
|
||||
// trace & contents
|
||||
int (*pfnMaskPointContents)( const float *pos, int groupmask );
|
||||
trace_t (*pfnTrace)( const float *p0, float *mins, float *maxs, const float *p1, int type, edict_t *e );
|
||||
trace_t (*pfnTraceNoEnts)( const float *p0, float *mins, float *maxs, const float *p1, int type, edict_t *e );
|
||||
int (*pfnBoxInPVS)( const float *org, const float *boxmins, const float *boxmaxs );
|
||||
|
||||
// message handler (missed function to write raw bytes)
|
||||
void (*pfnWriteBytes)( const byte *bytes, int count );
|
||||
|
||||
// BSP lump management
|
||||
int (*pfnCheckLump)( const char *filename, const int lump, int *lumpsize );
|
||||
int (*pfnReadLump)( const char *filename, const int lump, void **lumpdata, int *lumpsize );
|
||||
int (*pfnSaveLump)( const char *filename, const int lump, void *lumpdata, int lumpsize );
|
||||
|
||||
// FS tools
|
||||
int (*pfnSaveFile)( const char *filename, const void *data, int len );
|
||||
const byte *(*pfnLoadImagePixels)( const char *filename, int *width, int *height );
|
||||
|
||||
const char *(*pfnGetModelName)( int modelindex );
|
||||
|
||||
// FWGS extension
|
||||
void *(*pfnGetNativeObject)( const char *object );
|
||||
} server_physics_api_t;
|
||||
|
||||
// physic callbacks
|
||||
typedef struct physics_interface_s
|
||||
{
|
||||
int version;
|
||||
// passed through pfnCreate (0 is attempt to create, -1 is reject)
|
||||
int ( *SV_CreateEntity )( edict_t *pent, const char *szName );
|
||||
// run custom physics for each entity (return 0 to use built-in engine physic)
|
||||
int ( *SV_PhysicsEntity )( edict_t *pEntity );
|
||||
// spawn entities with internal mod function e.g. for re-arrange spawn order (0 - use engine parser, 1 - use mod parser)
|
||||
int ( *SV_LoadEntities )( const char *mapname, char *entities );
|
||||
// update conveyor belt for clients
|
||||
void ( *SV_UpdatePlayerBaseVelocity )( edict_t *ent );
|
||||
// The game .dll should return 1 if save game should be allowed
|
||||
int ( *SV_AllowSaveGame )( void );
|
||||
// ONLY ADD NEW FUNCTIONS TO THE END OF THIS STRUCT. INTERFACE VERSION IS FROZEN AT 6
|
||||
// override trigger area checking and touching
|
||||
int ( *SV_TriggerTouch )( edict_t *pent, edict_t *trigger );
|
||||
// some engine features can be enabled only through this function
|
||||
unsigned int ( *SV_CheckFeatures )( void );
|
||||
// used for draw debug collisions for custom physic engine etc
|
||||
void ( *DrawDebugTriangles )( void );
|
||||
// used for draw debug overlay (textured)
|
||||
void ( *DrawNormalTriangles )( void );
|
||||
// used for draw debug messages (2d mode)
|
||||
void ( *DrawOrthoTriangles )( void );
|
||||
// tracing entities with SOLID_CUSTOM mode on a server (not used by pmove code)
|
||||
void ( *ClipMoveToEntity)( edict_t *ent, const float *start, float *mins, float *maxs, const float *end, trace_t *trace );
|
||||
// tracing entities with SOLID_CUSTOM mode on a server (only used by pmove code)
|
||||
void ( *ClipPMoveToEntity)( struct physent_s *pe, const float *start, float *mins, float *maxs, const float *end, struct pmtrace_s *tr );
|
||||
// called at end the frame of SV_Physics call
|
||||
void ( *SV_EndFrame )( void );
|
||||
// obsolete
|
||||
void (*pfnPrepWorldFrame)( void );
|
||||
// called through save\restore process
|
||||
void (*pfnCreateEntitiesInRestoreList)( SAVERESTOREDATA *pSaveData, int levelMask, qboolean create_world );
|
||||
// allocate custom string (e.g. using user implementation of stringtable, not engine strings)
|
||||
string_t (*pfnAllocString)( const char *szValue );
|
||||
// make custom string (e.g. using user implementation of stringtable, not engine strings)
|
||||
string_t (*pfnMakeString)( const char *szValue );
|
||||
// read custom string (e.g. using user implementation of stringtable, not engine strings)
|
||||
const char* (*pfnGetString)( string_t iString );
|
||||
// helper for restore custom decals that have custom message (e.g. Paranoia)
|
||||
int (*pfnRestoreDecal)( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent );
|
||||
// handle custom trigger touching for player
|
||||
void (*PM_PlayerTouch)( struct playermove_s *ppmove, edict_t *client );
|
||||
// alloc or destroy model custom data (called only for dedicated servers, otherwise using an client version)
|
||||
void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer );
|
||||
// select BSP-hull for trace with specified mins\maxs
|
||||
void *(*SV_HullForBsp)( edict_t *ent, const float *mins, const float *maxs, float *offset );
|
||||
// handle player custom think function
|
||||
int (*SV_PlayerThink)( edict_t *ent, float frametime, double time );
|
||||
} physics_interface_t;
|
||||
|
||||
#endif//PHYSINT_H
|
@ -121,6 +121,14 @@ void *Sys_GetProcAddress(void *pModuleHandle, const char *pName)
|
||||
return GetProcAddress((HMODULE)pModuleHandle, pName);
|
||||
}
|
||||
|
||||
// Purpose: Returns a module handle by its name.
|
||||
// Input : pModuleName - module name
|
||||
// Output : the module handle or NULL in case of an error
|
||||
CSysModule *Sys_GetModuleHandle(const char *pModuleName)
|
||||
{
|
||||
return reinterpret_cast<CSysModule *>(GetModuleHandle(pModuleName));
|
||||
}
|
||||
|
||||
// Purpose: Loads a DLL/component from disk and returns a handle to it
|
||||
// Input : *pModuleName - filename of the component
|
||||
// Output : opaque handle to the module (hides system dependency)
|
||||
|
@ -114,6 +114,8 @@ extern CreateInterfaceFn Sys_GetFactory(const char *pModuleName);
|
||||
// load/unload components
|
||||
class CSysModule;
|
||||
|
||||
extern CSysModule *Sys_GetModuleHandle(const char *pModuleName);
|
||||
|
||||
// Load & Unload should be called in exactly one place for each module
|
||||
// The factory for that module should be passed on to dependent components for
|
||||
// proper versioning.
|
||||
|
BIN
metamod/lib/linux32/libc-2.11.1.so
Normal file
BIN
metamod/lib/linux32/libc-2.11.1.so
Normal file
Binary file not shown.
BIN
metamod/lib/linux32/libm.so
Normal file
BIN
metamod/lib/linux32/libm.so
Normal file
Binary file not shown.
BIN
metamod/lib/linux32/librt.so
Normal file
BIN
metamod/lib/linux32/librt.so
Normal file
Binary file not shown.
@ -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
|
||||
|
@ -12,23 +12,23 @@
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{02832A39-E902-46B7-8D47-911C37CF41B0}</ProjectGuid>
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141_xp</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
|
||||
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@ -42,7 +42,6 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
@ -50,50 +49,25 @@
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>METAMOD_CORE;WIN32;_DEBUG;_WINDOWS;_USRDLL;METAMOD_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\debug/inf/</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<ModuleDefinitionFile>metamod.def</ModuleDefinitionFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<AdditionalDependencies>psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
<Midl>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<TargetEnvironment>Win32</TargetEnvironment>
|
||||
<TypeLibraryName>.\debug/metamod.tlb</TypeLibraryName>
|
||||
<HeaderFileName>
|
||||
</HeaderFileName>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0409</Culture>
|
||||
@ -121,53 +95,28 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Full</Optimization>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>METAMOD_CORE;WIN32;NDEBUG;_WINDOWS;_USRDLL;METAMOD_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
|
||||
<ObjectFileName>$(IntDir)</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\release/inf/</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<SDLCheck>
|
||||
</SDLCheck>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<ModuleDefinitionFile>.\metamod.def</ModuleDefinitionFile>
|
||||
<ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
|
||||
<ImportLibrary>$(OutDir)$(TargetName).lib</ImportLibrary>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<ModuleDefinitionFile>metamod.def</ModuleDefinitionFile>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<AdditionalDependencies>psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
<Midl>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MkTypLibCompatible>true</MkTypLibCompatible>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<TargetEnvironment>Win32</TargetEnvironment>
|
||||
<TypeLibraryName>.\release/metamod.tlb</TypeLibraryName>
|
||||
<HeaderFileName>
|
||||
</HeaderFileName>
|
||||
</Midl>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0409</Culture>
|
||||
@ -202,8 +151,6 @@
|
||||
<ClCompile Include="..\src\engine_api.cpp" />
|
||||
<ClCompile Include="..\src\game_support.cpp" />
|
||||
<ClCompile Include="..\src\h_export.cpp" />
|
||||
<ClCompile Include="..\src\linkent.cpp" />
|
||||
<ClCompile Include="..\src\linkgame.cpp" />
|
||||
<ClCompile Include="..\src\log_meta.cpp" />
|
||||
<ClCompile Include="..\src\mdebug.cpp" />
|
||||
<ClCompile Include="..\src\mem_utils.cpp" />
|
||||
@ -215,6 +162,11 @@
|
||||
<ClCompile Include="..\src\mplugin.cpp" />
|
||||
<ClCompile Include="..\src\mreg.cpp" />
|
||||
<ClCompile Include="..\src\mutil.cpp" />
|
||||
<ClCompile Include="..\src\osdep_linkent_linux.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\osdep_linkent_win32.cpp" />
|
||||
<ClCompile Include="..\src\precompiled.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
|
@ -35,12 +35,6 @@
|
||||
<ClCompile Include="..\src\h_export.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\linkent.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\linkgame.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\log_meta.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
@ -98,6 +92,12 @@
|
||||
<ClCompile Include="..\src\meta_rehlds_api.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\osdep_linkent_win32.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\osdep_linkent_linux.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\src\api_info.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
|
||||
{
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -12,8 +12,12 @@ NEW_DLL_FUNCTIONS sNewFunctionTable;
|
||||
NEW_DLL_FUNCTIONS sNewFunctionTable_jit;
|
||||
NEW_DLL_FUNCTIONS *pHookedNewDllFunctions = &sNewFunctionTable;
|
||||
|
||||
void MM_PRE_HOOK EXT_FUNC mm_GameShutdown()
|
||||
// Unload game DLL and meta plugins
|
||||
void MM_POST_HOOK EXT_FUNC mm_GameShutdown()
|
||||
{
|
||||
g_metamod_active = false;
|
||||
if (g_plugins && !g_dedicated_server) g_plugins->unload_all();
|
||||
|
||||
g_meta_extdll.unload();
|
||||
g_GameDLL.sys_module.unload();
|
||||
g_engine.sys_module.unload();
|
||||
@ -130,7 +134,7 @@ compile_data_t g_dllfunc_cdata[] =
|
||||
compile_data_t g_newdllfunc_cdata[] =
|
||||
{
|
||||
CDATA_NEWDLL(pfnOnFreeEntPrivateData), // Called right before the object's memory is freed. Calls its destructor.
|
||||
CDATA_NEWDLL_H(pfnGameShutdown, P_PRE, mm_GameShutdown), //
|
||||
CDATA_NEWDLL_H(pfnGameShutdown, P_POST, mm_GameShutdown), //
|
||||
CDATA_NEWDLL(pfnShouldCollide), //
|
||||
|
||||
CDATA_NEWDLL(pfnCvarValue), // (fz) Use mm_CvarValue2 instead
|
||||
@ -217,6 +221,33 @@ C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *in
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
C_DLLEXPORT int Server_GetPhysicsInterface(int iVersion, server_physics_api_t *pfuncsFromEngine, physics_interface_t *pFunctionTable)
|
||||
{
|
||||
// TODO: provide physint to plugins
|
||||
if (iVersion != SV_PHYSICS_INTERFACE_VERSION || pfuncsFromEngine == nullptr || pFunctionTable == nullptr)
|
||||
return FALSE;
|
||||
|
||||
|
||||
// we have linkent alternative, shutdown linkent replacement
|
||||
meta_shutdown_linkent_replacement();
|
||||
|
||||
// engine always require for nullptr, only replace single function needed for linkent alternative
|
||||
Q_memset(pFunctionTable, 0, sizeof(*pFunctionTable));
|
||||
pFunctionTable->SV_CreateEntity = [](edict_t *pent, const char *szName)
|
||||
{
|
||||
// check if gamedll implements this entity
|
||||
ENTITY_FN SpawnEdict = reinterpret_cast<ENTITY_FN>(g_GameDLL.sys_module.getsym(szName));
|
||||
|
||||
// should we check metamod module itself? engine will do GPA on metamod module before failing back to this call anyway
|
||||
if( !SpawnEdict )
|
||||
return -1; // failed
|
||||
|
||||
SpawnEdict( &pent->v );
|
||||
return 0; // handled
|
||||
};
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void compile_dllfunc_callbacks()
|
||||
{
|
||||
jitdata_t jitdata;
|
||||
|
23
metamod/src/glibc_compat.cpp
Normal file
23
metamod/src/glibc_compat.cpp
Normal file
@ -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)
|
@ -16,6 +16,7 @@ void WINAPI GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t* pG
|
||||
g_engine.funcs = &g_engfuncs;
|
||||
g_engine.globals = pGlobals;
|
||||
g_engfuncs = *pengfuncsFromEngine;
|
||||
g_metamod_module.load(&g_engfuncs);
|
||||
g_engine.sys_module.load(pengfuncsFromEngine);
|
||||
|
||||
g_engfuncs = *pengfuncsFromEngine;
|
||||
|
@ -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
|
||||
|
@ -1,26 +0,0 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
// Function to perform common code of LINK_ENTITY_TO_GAME, rather than
|
||||
// duplicating the code in ~2000 expanded macros. Based on code from Jussi
|
||||
// Kivilinna <kijuhe00@students.oamk.fi>.
|
||||
void NOINLINE do_link_ent(ENTITY_FN* pfnEntity, int* missing, const char* entStr, entvars_t* pev)
|
||||
{
|
||||
if (*missing) {
|
||||
META_DEBUG(9, "Skipping entity '%s'; was previously found missing", entStr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!*pfnEntity) {
|
||||
META_DEBUG(9, "Looking up game entity '%s'", entStr);
|
||||
*pfnEntity = (ENTITY_FN)g_GameDLL.sys_module.getsym(entStr);
|
||||
}
|
||||
|
||||
if (!*pfnEntity) {
|
||||
META_ERROR("Couldn't find game entity '%s' in game DLL '%s': %s", entStr, g_GameDLL.name, CSysModule::getloaderror());
|
||||
*missing = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
META_DEBUG(8, "Linking game entity '%s'", entStr);
|
||||
(*pfnEntity)(pev);
|
||||
}
|
@ -1,19 +1,52 @@
|
||||
// vi: set ts=4 sw=4 :
|
||||
// vim: set tw=75 :
|
||||
|
||||
// linkent.h - export entities from mod "games" back to the HL engine
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2006 Will Day <willday@hpgx.net>
|
||||
*
|
||||
* This file is part of Metamod.
|
||||
*
|
||||
* Metamod is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Metamod is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Metamod; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// Initializes replacement code
|
||||
bool meta_init_linkent_replacement(CSysModule *moduleMetamod, CSysModule *moduleGame);
|
||||
|
||||
// Remove replacement code if new linkent mechanism was found
|
||||
void meta_shutdown_linkent_replacement();
|
||||
|
||||
// Comments from SDK dlls/util.h:
|
||||
//! This is the glue that hooks .MAP entity class names to our CPP classes.
|
||||
//! The _declspec forces them to be exported by name so we can do a lookup with GetProcAddress().
|
||||
//! The function is used to intialize / allocate the object for the entity.
|
||||
|
||||
// Adapted from LINK_ENTITY_TO_FUNC in adminmod linkfunc.cpp.
|
||||
typedef void (*ENTITY_FN)(entvars_t *);
|
||||
|
||||
// Function to perform common code of LINK_ENTITY_TO_GAME.
|
||||
void do_link_ent(ENTITY_FN* pfnEntity, int* missing, const char* entStr, entvars_t* pev);
|
||||
|
||||
#define LINK_ENTITY_TO_GAME(entityName) \
|
||||
C_DLLEXPORT void entityName(entvars_t *pev) { \
|
||||
static ENTITY_FN pfnEntity = nullptr; \
|
||||
static int missing = 0; \
|
||||
do_link_ent(&pfnEntity, &missing, STRINGIZE(entityName, 0), pev); \
|
||||
}
|
||||
typedef void (*ENTITY_FN) (entvars_t *);
|
||||
|
@ -1,9 +0,0 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
// Entity list for gamedlls adapted from adminmod linkfunc.cpp.
|
||||
|
||||
// NOTE: This list of entities is automatically generated via the script
|
||||
// "mklinkgame.sh". See the files in the directory "ents" for the actual
|
||||
// list of entities.
|
||||
|
||||
LINK_ENTITY_TO_GAME(worldspawn);
|
@ -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 <typename ...t_args>
|
||||
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();
|
||||
|
@ -46,7 +46,26 @@ bool rehlds_api_init(CSysModule* engineModule)
|
||||
|
||||
bool meta_init_rehlds_api()
|
||||
{
|
||||
CSysModule* engineModule = Sys_LoadModule(ENGINE_LIB);
|
||||
#ifdef _WIN32
|
||||
// Find the most appropriate module handle from a list of DLL candidates
|
||||
// Notes:
|
||||
// - "swds.dll" is the library Dedicated Server
|
||||
//
|
||||
// Let's also attempt to locate the ReHLDS API in the client's library
|
||||
// - "sw.dll" is the client library for Software render, with a built-in listenserver
|
||||
// - "hw.dll" is the client library for Hardware render, with a built-in listenserver
|
||||
const char *dllNames[] = { "swds.dll", "hw.dll", "sw.dll" }; // List of DLL candidates to lookup for the ReHLDS API
|
||||
CSysModule *engineModule = NULL; // The module handle of the selected DLL
|
||||
for (const char *dllName : dllNames)
|
||||
{
|
||||
if (engineModule = Sys_GetModuleHandle(dllName))
|
||||
break; // gotcha
|
||||
}
|
||||
|
||||
#else
|
||||
CSysModule *engineModule = Sys_GetModuleHandle("engine_i486.so");
|
||||
#endif
|
||||
|
||||
if (!rehlds_api_init(engineModule)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ option_t g_global_options[] =
|
||||
|
||||
gamedll_t g_GameDLL;
|
||||
|
||||
CSysModule g_metamod_module;
|
||||
|
||||
ALIGN16
|
||||
meta_globals_t g_metaGlobals;
|
||||
|
||||
@ -32,6 +34,9 @@ unsigned int g_CALL_API_count = 0;
|
||||
|
||||
int g_requestid_counter = 0;
|
||||
|
||||
bool g_metamod_active = false;
|
||||
bool g_dedicated_server = false;
|
||||
|
||||
// Very first metamod function that's run.
|
||||
// Do startup operations...
|
||||
void metamod_startup()
|
||||
@ -61,6 +66,8 @@ void metamod_startup()
|
||||
Sys_Error("Failure to init game DLL; exiting...");
|
||||
}
|
||||
|
||||
g_metamod_active = true;
|
||||
|
||||
// Register various console commands and cvars.
|
||||
// Can I do these here, rather than waiting for GameDLLInit() ?
|
||||
// Looks like it works okay..
|
||||
@ -160,6 +167,7 @@ void metamod_startup()
|
||||
g_engine.pl_funcs.pfnCVarRegister = meta_CVarRegister;
|
||||
g_engine.pl_funcs.pfnCvar_RegisterVariable = meta_CVarRegister;
|
||||
g_engine.pl_funcs.pfnRegUserMsg = meta_RegUserMsg;
|
||||
g_dedicated_server = g_engine.pl_funcs.pfnIsDedicatedServer() ? true : false;
|
||||
|
||||
if (g_engine.pl_funcs.pfnQueryClientCvarValue)
|
||||
g_engine.pl_funcs.pfnQueryClientCvarValue = meta_QueryClientCvarValue;
|
||||
@ -225,10 +233,17 @@ void metamod_startup()
|
||||
// Exit on failure here? Dunno...
|
||||
}
|
||||
|
||||
meta_init_rehlds_api();
|
||||
|
||||
if (!g_meta_extdll.init(&g_engine.sys_module)) {
|
||||
Sys_Error("Failure to init extension DLL; exiting...");
|
||||
if (meta_init_rehlds_api()) {
|
||||
if (!g_meta_extdll.init(&g_engine.sys_module)) {
|
||||
Sys_Error("Failure to init extension DLL; exiting...");
|
||||
}
|
||||
} else {
|
||||
// activate linkent-replacement after give_engfuncs so that if game dll is
|
||||
// plugin too and uses same method we get combined export table of plugin
|
||||
// and game dll
|
||||
if (!meta_init_linkent_replacement(&g_metamod_module, &g_GameDLL.sys_module)) {
|
||||
Sys_Error("dll: Couldn't load linkent replacement for game DLL");
|
||||
}
|
||||
}
|
||||
|
||||
// Allow for commands to metamod plugins at startup. Autoexec.cfg is
|
||||
@ -449,7 +464,7 @@ static void meta_collect_fix_data(uint32* const esp, std::vector<fixdata_t>& 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
|
||||
@ -509,6 +524,8 @@ static void meta_apply_fix_data(std::vector<fixdata_t>& data)
|
||||
|
||||
void meta_rebuild_callbacks()
|
||||
{
|
||||
if (!g_metamod_active) return;
|
||||
|
||||
std::vector<fixdata_t> fixdata;
|
||||
if (g_metaGlobals.esp_save) {
|
||||
META_LOG("dll: Begin scan to collect callback fix data...");
|
||||
|
@ -15,6 +15,9 @@
|
||||
// cvar to contain version
|
||||
extern cvar_t g_meta_version;
|
||||
|
||||
// metamod module handle
|
||||
extern CSysModule g_metamod_module;
|
||||
|
||||
// Info about the game dll/mod.
|
||||
struct gamedll_t
|
||||
{
|
||||
@ -74,6 +77,9 @@ extern unsigned int g_CALL_API_count;
|
||||
// stores previous requestid counter
|
||||
extern int g_requestid_counter;
|
||||
|
||||
extern bool g_metamod_active;
|
||||
extern bool g_dedicated_server;
|
||||
|
||||
// (patch by BAILOPAN)
|
||||
// Holds cached player info, right now only things for querying cvars
|
||||
// Max players is always 32, small enough that we can use a static array
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
@ -17,10 +17,6 @@ void CExtDll::load()
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
auto extdll = &m_dlls[(*m_count)++];
|
||||
Q_memset(extdll, 0, sizeof(*extdll));
|
||||
extdll->lDLLHandle = m_hGameDLL;
|
||||
}
|
||||
|
||||
void CExtDll::unload()
|
||||
@ -29,68 +25,13 @@ void CExtDll::unload()
|
||||
g_RehldsFuncs->RemoveExtDll(m_hGameDLL);
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto i = 0u; i < *m_count; i++)
|
||||
{
|
||||
if (m_dlls[i].lDLLHandle == m_hGameDLL)
|
||||
{
|
||||
--(*m_count);
|
||||
if (*m_count != i)
|
||||
{
|
||||
Q_memmove(&m_dlls[i], &m_dlls[i + 1], (*m_count - i) * sizeof(m_dlls[0]));
|
||||
i = *m_count;
|
||||
}
|
||||
|
||||
Q_memset(&m_dlls[i], 0, sizeof(m_dlls[0]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CExtDll::init(CSysModule *module)
|
||||
{
|
||||
m_hGameDLL = g_GameDLL.sys_module.gethandle();
|
||||
|
||||
if (g_RehldsFuncs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
m_dlls = (extensiondll_t *)module->getsym("g_rgextdll");
|
||||
m_count = (size_t *)module->getsym("g_iextdllMac");
|
||||
|
||||
if (m_dlls && m_count) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// HACK HACK MORE HACK
|
||||
// HLDS SHIT
|
||||
auto pos = module->find_string_push("SV_SaveGameComment");
|
||||
if (!pos) {
|
||||
if (!m_hGameDLL)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char patterns[2][2][14] = {
|
||||
{ "\x56\x33\xF6\x39\x2A\x2A\x2A\x2A\x2A\x7E\x2A\x53\x8B", "\x5B\xC3\x90\x90\xA1\x2A\x2A\x2A\x2A\x53\x56\x57\x33" },
|
||||
{ "\x53\x8B\x2A\x2A\x2A\x2A\x2A\x57\xBF\x2A\x2A\x2A\x2A", "\x7E\x2A\x8B\x2A\x2A\x2A\x2A\x2A\xBE\x2A\x2A\x2A\x2A" },
|
||||
};
|
||||
|
||||
for (auto i = 0u; i < ARRAYSIZE(patterns); i++)
|
||||
{
|
||||
auto addr = mem_find_pattern(pos - 33, 20, patterns[0][i], sizeof(patterns[0][i]) - 1);
|
||||
if (!addr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
m_count = *(size_t **)(addr + 5);
|
||||
|
||||
addr = mem_find_pattern(addr, 30, patterns[1][i], sizeof(patterns[1][i]) - 1);
|
||||
if (!addr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dlls = *(extensiondll_t **)(addr + 9);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -12,8 +12,6 @@ public:
|
||||
|
||||
private:
|
||||
module_handle_t m_hGameDLL;
|
||||
extensiondll_t *m_dlls;
|
||||
size_t *m_count;
|
||||
};
|
||||
|
||||
extern CExtDll g_meta_extdll;
|
||||
|
@ -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;
|
||||
@ -573,6 +573,15 @@ void MPluginList::unpause_all()
|
||||
}
|
||||
}
|
||||
|
||||
// Unload all plugins currently loaded
|
||||
void MPluginList::unload_all()
|
||||
{
|
||||
bool delayed;
|
||||
for (auto p : m_plugins) {
|
||||
p->unload(PT_ANYTIME, PNL_CMD_FORCED, delayed);
|
||||
}
|
||||
}
|
||||
|
||||
// Retry any pending actions on plugins, for instance load/unload delayed
|
||||
// until changelevel.
|
||||
void MPluginList::retry_all(PLUG_LOADTIME now)
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
bool load(); // load the list, at startup
|
||||
bool refresh(PLUG_LOADTIME now); // update from re-read inifile
|
||||
void unpause_all(); // unpause any paused plugins
|
||||
void unload_all(); // unload all plugins
|
||||
void retry_all(PLUG_LOADTIME now); // retry any pending plugin actions
|
||||
void show(int source_index = 0); // list plugins to console use dynamic alignment
|
||||
void show_static(int source_index = 0); // list plugins to console use static alignment
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -471,7 +471,7 @@ bool MPlugin::unload(PLUG_LOADTIME now, PL_UNLOAD_REASON reason, bool& delayed)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (m_action != PA_UNLOAD && m_action != PA_RELOAD) {
|
||||
if (m_action != PA_UNLOAD && m_action != PA_RELOAD && reason != PNL_CMD_FORCED) {
|
||||
META_WARNING("dll: Not unloading plugin '%s'; not marked for unload (action=%s)", m_desc, str_action());
|
||||
return false;
|
||||
}
|
||||
|
@ -64,17 +64,21 @@ MRegCmd* MRegCmdList::add(const char* addname, REG_CMD_FN cmd_handler, MPlugin*
|
||||
|
||||
void MRegCmdList::remove(char* cmd_name)
|
||||
{
|
||||
for (auto it = m_list.begin(), end = m_list.end(); it != end; ++it) {
|
||||
for (auto it = m_list.begin(); it != m_list.end(); ) {
|
||||
auto reg = *it;
|
||||
|
||||
if (!Q_stricmp(reg->m_name, cmd_name)) {
|
||||
if (g_RehldsFuncs) {
|
||||
g_RehldsFuncs->Cmd_RemoveCmd(cmd_name);
|
||||
m_list.erase(it);
|
||||
delete reg;
|
||||
it = m_list.erase(it);
|
||||
}
|
||||
else {
|
||||
reg->disable();
|
||||
it++;
|
||||
}
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,17 +86,22 @@ void MRegCmdList::remove(char* cmd_name)
|
||||
// Disable any functions belonging to the given plugin (by index id).
|
||||
void MRegCmdList::remove(int owner_plugin_id)
|
||||
{
|
||||
for (auto it = m_list.begin(), end = m_list.end(); it != end; ++it) {
|
||||
for (auto it = m_list.begin(); it != m_list.end(); ) {
|
||||
auto reg = *it;
|
||||
|
||||
if (reg->m_plugid == owner_plugin_id) {
|
||||
if (g_RehldsFuncs) {
|
||||
g_RehldsFuncs->Cmd_RemoveCmd(reg->m_name);
|
||||
m_list.erase(it);
|
||||
}
|
||||
else {
|
||||
reg->disable();
|
||||
}
|
||||
if (reg->m_plugid != owner_plugin_id) {
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (g_RehldsFuncs) {
|
||||
g_RehldsFuncs->Cmd_RemoveCmd(reg->m_name);
|
||||
delete reg;
|
||||
it = m_list.erase(it);
|
||||
}
|
||||
else {
|
||||
reg->disable();
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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];
|
||||
}
|
||||
|
233
metamod/src/osdep_linkent_linux.cpp
Normal file
233
metamod/src/osdep_linkent_linux.cpp
Normal file
@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2006 Jussi Kivilinna
|
||||
*
|
||||
* This file is part of "Metamod All-Mod-Support"-patch for Metamod.
|
||||
*
|
||||
* Metamod is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Metamod is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Metamod; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#define PAGE_SIZE 4096UL
|
||||
#define PAGE_MASK (~(PAGE_SIZE - 1))
|
||||
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
|
||||
|
||||
//
|
||||
// Linux code for dynamic linkents
|
||||
// -- by Jussi Kivilinna
|
||||
//
|
||||
|
||||
// opcode, e9, + sizeof pointer
|
||||
#define BYTES_SIZE (1 + sizeof(void*))
|
||||
|
||||
typedef void *(*dlsym_func)(void *module, const char *funcname);
|
||||
|
||||
static void *gamedll_module_handle = 0;
|
||||
static void *metamod_module_handle = 0;
|
||||
|
||||
// pointer to original dlsym
|
||||
static dlsym_func dlsym_original;
|
||||
|
||||
// contains jmp to replacement_dlsym @dlsym_original
|
||||
static unsigned char dlsym_new_bytes[BYTES_SIZE];
|
||||
|
||||
// contains original bytes of dlsym
|
||||
static unsigned char dlsym_old_bytes[BYTES_SIZE];
|
||||
|
||||
// Mutex for our protection
|
||||
static pthread_mutex_t mutex_replacement_dlsym = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
||||
|
||||
static int is_original_restored;
|
||||
|
||||
// constructs new jmp forwarder
|
||||
inline void construct_jmp_instruction(void *x, void *place, void *target)
|
||||
{
|
||||
((unsigned char *)x)[0] = 0xe9;
|
||||
*(unsigned long *)((char *)x + 1) = (unsigned long)target - ((unsigned long)place + 5);
|
||||
}
|
||||
|
||||
// checks if pointer x points to jump forwarder
|
||||
inline bool is_code_trampoline_jmp_opcode(void *x)
|
||||
{
|
||||
return (((unsigned char *)x)[0] == 0xff || ((unsigned char *)x)[1] == 0x25);
|
||||
}
|
||||
|
||||
// extracts pointer from "jmp dword ptr[pointer]"
|
||||
inline void *extract_function_pointer_from_trampoline_jmp(void *x)
|
||||
{
|
||||
return (**(void ***)((char *)(x) + 2));
|
||||
}
|
||||
|
||||
//
|
||||
// restores old dlsym
|
||||
//
|
||||
inline void restore_original_dlsym()
|
||||
{
|
||||
//Copy old dlsym bytes back
|
||||
memcpy((void *)dlsym_original, dlsym_old_bytes, BYTES_SIZE);
|
||||
}
|
||||
|
||||
//
|
||||
// resets new dlsym
|
||||
//
|
||||
inline void reset_dlsym_hook()
|
||||
{
|
||||
//Copy new dlsym bytes back
|
||||
memcpy((void *)dlsym_original, dlsym_new_bytes, BYTES_SIZE);
|
||||
}
|
||||
|
||||
//
|
||||
// Replacement dlsym function
|
||||
//
|
||||
static void *__replacement_dlsym(void *module, const char *funcname)
|
||||
{
|
||||
// these are needed in case dlsym calls dlsym, default one doesn't do
|
||||
// it but some LD_PRELOADed library that hooks dlsym might actually
|
||||
// do so.
|
||||
int was_original_restored = is_original_restored;
|
||||
|
||||
// Lock before modifing original dlsym
|
||||
pthread_mutex_lock(&mutex_replacement_dlsym);
|
||||
|
||||
// restore old dlsym
|
||||
if (!is_original_restored)
|
||||
{
|
||||
restore_original_dlsym();
|
||||
is_original_restored = 1;
|
||||
}
|
||||
|
||||
// check if we should hook this call
|
||||
if (module != metamod_module_handle || !metamod_module_handle || !gamedll_module_handle)
|
||||
{
|
||||
//no metamod/gamedll module? should we remove hook now?
|
||||
void *retval = dlsym_original(module, funcname);
|
||||
if (metamod_module_handle && gamedll_module_handle)
|
||||
{
|
||||
if (!was_original_restored)
|
||||
{
|
||||
// reset dlsym hook
|
||||
reset_dlsym_hook();
|
||||
is_original_restored = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no metamod/gamedll module? should we remove hook now by not reseting it back?
|
||||
}
|
||||
|
||||
// unlock
|
||||
pthread_mutex_unlock(&mutex_replacement_dlsym);
|
||||
return retval;
|
||||
}
|
||||
|
||||
// dlsym on metamod module
|
||||
void *func = dlsym_original(module, funcname);
|
||||
|
||||
if (!func)
|
||||
{
|
||||
// function not in metamod module, try gamedll
|
||||
func = dlsym_original(gamedll_module_handle, funcname);
|
||||
}
|
||||
|
||||
if (!was_original_restored)
|
||||
{
|
||||
// reset dlsym hook
|
||||
reset_dlsym_hook();
|
||||
|
||||
is_original_restored = 0;
|
||||
}
|
||||
|
||||
// unlock
|
||||
pthread_mutex_unlock(&mutex_replacement_dlsym);
|
||||
return func;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize
|
||||
//
|
||||
bool meta_init_linkent_replacement(CSysModule *moduleMetamod, CSysModule *moduleGame)
|
||||
{
|
||||
metamod_module_handle = moduleMetamod->gethandle();
|
||||
gamedll_module_handle = moduleGame->gethandle();
|
||||
|
||||
// dlsym is already known to be pointing to valid function, we loaded gamedll using it earlier!
|
||||
void *sym_ptr = (void *)&dlsym;
|
||||
while (is_code_trampoline_jmp_opcode(sym_ptr))
|
||||
{
|
||||
sym_ptr = extract_function_pointer_from_trampoline_jmp(sym_ptr);
|
||||
}
|
||||
|
||||
dlsym_original = (dlsym_func)sym_ptr;
|
||||
|
||||
// Backup old bytes of "dlsym" function
|
||||
memcpy(dlsym_old_bytes, (void *)dlsym_original, BYTES_SIZE);
|
||||
|
||||
// Construct new bytes: "jmp offset[replacement_sendto] @ sendto_original"
|
||||
construct_jmp_instruction((void *)&dlsym_new_bytes[0], (void *)dlsym_original, (void *)&__replacement_dlsym);
|
||||
|
||||
// Check if bytes overlap page border.
|
||||
unsigned long start_of_page = PAGE_ALIGN((long)dlsym_original) - PAGE_SIZE;
|
||||
unsigned long size_of_pages = 0;
|
||||
|
||||
if ((unsigned long)dlsym_original + BYTES_SIZE > PAGE_ALIGN((unsigned long)dlsym_original))
|
||||
{
|
||||
// bytes are located on two pages
|
||||
size_of_pages = PAGE_SIZE * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// bytes are located entirely on one page.
|
||||
size_of_pages = PAGE_SIZE;
|
||||
}
|
||||
|
||||
// Remove PROT_READ restriction
|
||||
if (mprotect((void *)start_of_page, size_of_pages, PROT_READ | PROT_WRITE | PROT_EXEC))
|
||||
{
|
||||
META_ERROR("Couldn't initialize dynamic linkents, mprotect failed: %i. Exiting...", errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write our own jmp-forwarder on "dlsym"
|
||||
reset_dlsym_hook();
|
||||
|
||||
// done
|
||||
return true;
|
||||
}
|
||||
|
||||
void meta_shutdown_linkent_replacement()
|
||||
{
|
||||
// Lock before modifing original dlsym
|
||||
pthread_mutex_lock(&mutex_replacement_dlsym);
|
||||
|
||||
// restore old dlsym
|
||||
if (!is_original_restored)
|
||||
{
|
||||
restore_original_dlsym();
|
||||
is_original_restored = 1;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&mutex_replacement_dlsym);
|
||||
}
|
251
metamod/src/osdep_linkent_win32.cpp
Normal file
251
metamod/src/osdep_linkent_win32.cpp
Normal file
@ -0,0 +1,251 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2006 Jussi Kivilinna
|
||||
*
|
||||
* This file is part of "Metamod All-Mod-Support"-patch for Metamod.
|
||||
*
|
||||
* Metamod is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Metamod is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Metamod; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* In addition, as a special exception, the author gives permission to
|
||||
* link the code of this program with the Half-Life Game Engine ("HL
|
||||
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
|
||||
* L.L.C ("Valve"). You must obey the GNU General Public License in all
|
||||
* respects for all of the code used other than the HL Engine and MODs
|
||||
* from Valve. If you modify this file, you may extend this exception
|
||||
* to your version of the file, but you are not obligated to do so. If
|
||||
* you do not wish to do so, delete this exception statement from your
|
||||
* version.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
//
|
||||
// Win32 code for dynamic linkents
|
||||
// -- by Jussi Kivilinna
|
||||
//
|
||||
|
||||
//
|
||||
// Reads metamod.dll and game.dll function export tables and combines theim to
|
||||
// single table that replaces metamod.dll's original table.
|
||||
//
|
||||
|
||||
typedef struct sort_names_s {
|
||||
unsigned long name;
|
||||
unsigned short nameOrdinal;
|
||||
} sort_names_t;
|
||||
|
||||
// relative virtual address to virtual address
|
||||
#define rva_to_va(base, rva) ((unsigned long)base + (unsigned long)rva)
|
||||
|
||||
// virtual address to relative virtual address
|
||||
#define va_to_rva(base, va) ((unsigned long)va - (unsigned long)base)
|
||||
|
||||
//
|
||||
// Checks module signatures and return ntheaders pointer for valid module
|
||||
//
|
||||
static IMAGE_NT_HEADERS *get_ntheaders(HMODULE module)
|
||||
{
|
||||
union {
|
||||
unsigned long mem;
|
||||
IMAGE_DOS_HEADER * dos;
|
||||
IMAGE_NT_HEADERS * pe;
|
||||
} mem;
|
||||
|
||||
//Check if valid dos header
|
||||
mem.mem = (unsigned long)module;
|
||||
if (IsBadReadPtr(mem.dos, sizeof(*mem.dos)) || mem.dos->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
return NULL;
|
||||
|
||||
//Get and check pe header
|
||||
mem.mem = rva_to_va(module, mem.dos->e_lfanew);
|
||||
if (IsBadReadPtr(mem.pe, sizeof(*mem.pe)) || mem.pe->Signature != IMAGE_NT_SIGNATURE)
|
||||
return NULL;
|
||||
|
||||
return mem.pe;
|
||||
}
|
||||
|
||||
//
|
||||
// Returns export table for valid module
|
||||
//
|
||||
static IMAGE_EXPORT_DIRECTORY *get_export_table(HMODULE module)
|
||||
{
|
||||
union {
|
||||
unsigned long mem;
|
||||
void * pvoid;
|
||||
IMAGE_DOS_HEADER * dos;
|
||||
IMAGE_NT_HEADERS * pe;
|
||||
IMAGE_EXPORT_DIRECTORY * export_dir;
|
||||
} mem;
|
||||
|
||||
// Check module
|
||||
mem.pe = get_ntheaders(module);
|
||||
if (!mem.pe)
|
||||
return NULL;
|
||||
|
||||
// Check for exports
|
||||
if (!mem.pe->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress)
|
||||
return NULL;
|
||||
|
||||
mem.mem = rva_to_va(module, mem.pe->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
|
||||
if (IsBadReadPtr(mem.export_dir, sizeof(*mem.export_dir)))
|
||||
return NULL;
|
||||
|
||||
return mem.export_dir;
|
||||
}
|
||||
|
||||
//
|
||||
// Sort function for qsort
|
||||
//
|
||||
static int sort_names_list(const sort_names_t * A, const sort_names_t * B)
|
||||
{
|
||||
const char *str_A = (const char *)A->name;
|
||||
const char *str_B = (const char *)B->name;
|
||||
|
||||
return Q_strcmp(str_A, str_B);
|
||||
}
|
||||
|
||||
//
|
||||
// Combines meta_module and game_module export tables and replaces meta_module table with new one
|
||||
//
|
||||
static bool combine_module_export_tables(CSysModule *meta_module, CSysModule *game_module)
|
||||
{
|
||||
IMAGE_EXPORT_DIRECTORY * exportMM;
|
||||
IMAGE_EXPORT_DIRECTORY * exportGame;
|
||||
|
||||
unsigned long newNumberOfFunctions;
|
||||
unsigned long newNumberOfNames;
|
||||
unsigned long * newFunctions;
|
||||
unsigned long * newNames;
|
||||
unsigned short * newNameOrdinals;
|
||||
sort_names_t * newSort;
|
||||
|
||||
unsigned long i;
|
||||
unsigned long u;
|
||||
unsigned long funcCount;
|
||||
unsigned long nameCount;
|
||||
unsigned long listFix;
|
||||
|
||||
HMODULE moduleMeta = meta_module->gethandle();
|
||||
HMODULE moduleGame = game_module->gethandle();
|
||||
|
||||
// Get export tables
|
||||
exportMM = get_export_table(moduleMeta);
|
||||
exportGame = get_export_table(moduleGame);
|
||||
if (!exportMM || !exportGame)
|
||||
{
|
||||
META_ERROR("Couldn't initialize dynamic linkents, exportMM: %i, exportGame: %i. Exiting...", exportMM, exportGame);
|
||||
return false;
|
||||
}
|
||||
|
||||
// setup new export table
|
||||
newNumberOfFunctions = exportMM->NumberOfFunctions + exportGame->NumberOfFunctions;
|
||||
newNumberOfNames = exportMM->NumberOfNames + exportGame->NumberOfNames;
|
||||
|
||||
// alloc lists
|
||||
*(void**)&newFunctions = calloc(1, newNumberOfFunctions * sizeof(*newFunctions));
|
||||
*(void**)&newSort = calloc(1, newNumberOfNames * sizeof(*newSort));
|
||||
|
||||
// copy moduleMeta to new export
|
||||
for (funcCount = 0; funcCount < exportMM->NumberOfFunctions; funcCount++)
|
||||
newFunctions[funcCount] = rva_to_va(moduleMeta, ((unsigned long *)rva_to_va(moduleMeta, exportMM->AddressOfFunctions))[funcCount]);
|
||||
|
||||
for (nameCount = 0; nameCount < exportMM->NumberOfNames; nameCount++)
|
||||
{
|
||||
// fix name address
|
||||
newSort[nameCount].name = rva_to_va(moduleMeta, ((unsigned long *)rva_to_va(moduleMeta, exportMM->AddressOfNames))[nameCount]);
|
||||
|
||||
// ordinal is index to function list
|
||||
newSort[nameCount].nameOrdinal = ((unsigned short *)rva_to_va(moduleMeta, exportMM->AddressOfNameOrdinals))[nameCount];
|
||||
}
|
||||
|
||||
// copy moduleGame to new export
|
||||
for (i = 0; i < exportGame->NumberOfFunctions; i++)
|
||||
newFunctions[funcCount + i] = rva_to_va(moduleGame, ((unsigned long *)rva_to_va(moduleGame, exportGame->AddressOfFunctions))[i]);
|
||||
|
||||
for (i = 0, listFix = 0; i < exportGame->NumberOfNames; i++)
|
||||
{
|
||||
const char *name = (const char *)rva_to_va(moduleGame, ((unsigned long *)rva_to_va(moduleGame, exportGame->AddressOfNames))[i]);
|
||||
//Check if name already in the list
|
||||
for (u = 0; u < nameCount; u++)
|
||||
{
|
||||
if (!Q_stricmp(name, (const char *)newSort[u].name))
|
||||
{
|
||||
listFix -= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (u < nameCount) //already in the list.. skip
|
||||
continue;
|
||||
|
||||
newSort[nameCount + i + listFix].name = (unsigned long)name;
|
||||
newSort[nameCount + i + listFix].nameOrdinal = (unsigned short)funcCount + ((unsigned short *)rva_to_va(moduleGame, exportGame->AddressOfNameOrdinals))[i];
|
||||
}
|
||||
|
||||
//set new number
|
||||
newNumberOfNames = nameCount + i + listFix;
|
||||
|
||||
//sort names list
|
||||
qsort(newSort, newNumberOfNames, sizeof(*newSort), (int(*)(const void*, const void*))&sort_names_list);
|
||||
|
||||
//make newNames and newNameOrdinals lists (VirtualAlloc so we dont waste heap memory to stuff that isn't freed)
|
||||
*(void**)&newNames = VirtualAlloc(0, newNumberOfNames * sizeof(*newNames), MEM_COMMIT, PAGE_READWRITE);
|
||||
*(void**)&newNameOrdinals = VirtualAlloc(0, newNumberOfNames * sizeof(*newNameOrdinals), MEM_COMMIT, PAGE_READWRITE);
|
||||
|
||||
for (i = 0; i < newNumberOfNames; i++)
|
||||
{
|
||||
newNames[i] = newSort[i].name;
|
||||
newNameOrdinals[i] = newSort[i].nameOrdinal;
|
||||
}
|
||||
|
||||
free(newSort);
|
||||
|
||||
// translate VAs to RVAs
|
||||
for (i = 0; i < newNumberOfFunctions; i++)
|
||||
newFunctions[i] = va_to_rva(moduleMeta, newFunctions[i]);
|
||||
|
||||
for (i = 0; i < newNumberOfNames; i++)
|
||||
{
|
||||
newNames[i] = va_to_rva(moduleMeta, newNames[i]);
|
||||
newNameOrdinals[i] = (unsigned short)va_to_rva(moduleMeta, newNameOrdinals[i]);
|
||||
}
|
||||
|
||||
DWORD OldProtect;
|
||||
if (!VirtualProtect(exportMM, sizeof(*exportMM), PAGE_READWRITE, &OldProtect))
|
||||
{
|
||||
META_ERROR("Couldn't initialize dynamic linkents, VirtualProtect failed: %i. Exiting...", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
exportMM->Base = 1;
|
||||
exportMM->NumberOfFunctions = newNumberOfFunctions;
|
||||
exportMM->NumberOfNames = newNumberOfNames;
|
||||
*(unsigned long*)&(exportMM->AddressOfFunctions) = va_to_rva(moduleMeta, newFunctions);
|
||||
*(unsigned long*)&(exportMM->AddressOfNames) = va_to_rva(moduleMeta, newNames);
|
||||
*(unsigned long*)&(exportMM->AddressOfNameOrdinals) = va_to_rva(moduleMeta, newNameOrdinals);
|
||||
|
||||
VirtualProtect(exportMM, sizeof(*exportMM), OldProtect, &OldProtect);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool meta_init_linkent_replacement(CSysModule *moduleMetamod, CSysModule *moduleGame)
|
||||
{
|
||||
return combine_module_export_tables(moduleMetamod, moduleGame);
|
||||
}
|
||||
|
||||
void meta_shutdown_linkent_replacement()
|
||||
{
|
||||
// no-op
|
||||
}
|
@ -53,6 +53,7 @@
|
||||
#include "mem_utils.h"
|
||||
#include "callback_jit.h"
|
||||
#include "meta_rehlds_api.h"
|
||||
#include "physint.h"
|
||||
|
||||
#undef CreateInterface
|
||||
#include "linkent.h"
|
||||
|
@ -1,6 +1,4 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "stdc++compat.cpp"
|
||||
#include "sys_shared.cpp"
|
||||
#include "interface.cpp"
|
||||
#include "crc32c.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");
|
||||
|
||||
|
@ -68,6 +68,7 @@ module_handle_t CSysModule::load(const char *filepath)
|
||||
{
|
||||
if (!m_handle) {
|
||||
m_handle = LoadLibrary(filepath);
|
||||
if (m_handle) m_free = true;
|
||||
|
||||
MODULEINFO module_info;
|
||||
if (GetModuleInformation(GetCurrentProcess(), m_handle, &module_info, sizeof(module_info))) {
|
||||
@ -142,7 +143,7 @@ module_handle_t CSysModule::find(void *addr)
|
||||
{
|
||||
Dl_info dlinfo;
|
||||
if ((!dladdr(addr, &dlinfo) && !dlinfo.dli_fbase) || !dlinfo.dli_fname) {
|
||||
return false;
|
||||
return INVALID_HANDLE;
|
||||
}
|
||||
|
||||
module_handle_t hHandle = INVALID_HANDLE;
|
||||
@ -157,6 +158,7 @@ module_handle_t CSysModule::load(const char *filepath)
|
||||
{
|
||||
if (!m_handle) {
|
||||
m_handle = dlopen(filepath, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
|
||||
if (m_handle) m_free = true;
|
||||
|
||||
char buf[1024], dummy[1024], path[260];
|
||||
Q_sprintf(buf, "/proc/%i/maps", getpid());
|
||||
@ -192,7 +194,7 @@ bool CSysModule::unload()
|
||||
|
||||
bool ret = true;
|
||||
if (m_free) {
|
||||
ret = dlclose(m_handle) != 0;
|
||||
ret = dlclose(m_handle) == 0;
|
||||
}
|
||||
|
||||
m_handle = INVALID_HANDLE;
|
||||
|
@ -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
|
||||
|
158
metamod/version/appversion.sh
Executable file
158
metamod/version/appversion.sh
Executable file
@ -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$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
|
@ -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__
|
83
metamod/version/glibc_test.sh
Executable file
83
metamod/version/glibc_test.sh
Executable file
@ -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
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Version declaration dependency file
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// This file needed just to add the dependency and appversion.h
|
||||
//
|
||||
#include "precompiled.h"
|
||||
|
10
metamod/version/version.h
Normal file
10
metamod/version/version.h
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Version declaration dependency file
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_MAINTENANCE 0
|
@ -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'
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
rootProject.name = 'metamod'
|
||||
include 'metamod'
|
@ -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}")
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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
|
||||
}
|
30
version_script.lds
Normal file
30
version_script.lds
Normal file
@ -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:
|
||||
*;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user