diff --git a/README.md b/README.md index 72772ba1..3269f069 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Regamedll_CS is a result of reverse engineering of original library mods HLDS (b At the moment, the work of reverse engineering continues ## Goals of the project -* Provide more stable (than official) version of Half-Life dedicated server with extended API for mods and plugins +* Provide more stable (than official) version of Counter-Strike game with extended API for mods and plugins ## How can use it? Regamedll_CS is fully compatible with official mod CS 1.6 by Valve. All you have to do is to download binaries and replace original mo.dll/cs.so diff --git a/build.gradle b/build.gradle index 08694329..2242eda6 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,8 @@ if (gitInfo.tag && gitInfo.tag[0] == 'v') { countCommit: gitInfo.countCommit, lastCommitDate: gitInfo.lastCommitDate, commitID: gitInfo.commitID, - authorCommit: gitInfo.authorCommit + authorCommit: gitInfo.authorCommit, + urlCommits: gitInfo.urlCommits ) } else { versionInfo = new RegamedllVersionInfo( @@ -42,7 +43,8 @@ if (gitInfo.tag && gitInfo.tag[0] == 'v') { countCommit: gitInfo.countCommit, lastCommitDate: gitInfo.lastCommitDate, commitID: gitInfo.commitID, - authorCommit: gitInfo.authorCommit + authorCommit: gitInfo.authorCommit, + urlCommits: gitInfo.urlCommits ) } diff --git a/buildSrc/src/main/groovy/versioning/GitInfo.groovy b/buildSrc/src/main/groovy/versioning/GitInfo.groovy index 9d89fce5..1bfbce7b 100644 --- a/buildSrc/src/main/groovy/versioning/GitInfo.groovy +++ b/buildSrc/src/main/groovy/versioning/GitInfo.groovy @@ -12,4 +12,5 @@ class GitInfo { Integer countCommit String commitID String authorCommit + String urlCommits } diff --git a/buildSrc/src/main/groovy/versioning/GitVersioner.groovy b/buildSrc/src/main/groovy/versioning/GitVersioner.groovy index 56a41f16..04fef278 100644 --- a/buildSrc/src/main/groovy/versioning/GitVersioner.groovy +++ b/buildSrc/src/main/groovy/versioning/GitVersioner.groovy @@ -5,6 +5,7 @@ import groovy.transform.TypeChecked import org.eclipse.jgit.api.Git 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 @@ -38,6 +39,20 @@ class GitVersioner { return null; } + static String prepareUrlToCommits(String url) { + 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 { + childPath = url.substring(0, url.lastIndexOf('.git')); + } + + sb.append(childPath).append('/commit/'); + return sb.toString(); + } static GitInfo versionForDir(File dir) { FileRepositoryBuilder builder = new FileRepositoryBuilder() Repository repo = builder.setWorkTree(dir) @@ -49,6 +64,7 @@ class GitVersioner { return null } + final StoredConfig cfg = repo.getConfig(); def commit = new RevWalk(repo).parseCommit(head) def commitLast = parseCommitLast(repo) int commitCount = getCountCommit(repo) @@ -56,6 +72,11 @@ class GitVersioner { def branch = repo.getBranch() def commitDate = new DateTime(1000L * commit.commitTime, DateTimeZone.UTC) + String remote_name = cfg.getString("branch", branch, "remote"); + + String url = cfg.getString("remote", remote_name, "url"); + String urlCommits = prepareUrlToCommits(url); + if (!commit) { throw new RuntimeException("Can't find last commit.") } @@ -70,7 +91,8 @@ class GitVersioner { tag: tag, countCommit: commitCount, commitID: headCommitId, - authorCommit: authorCommit + authorCommit: authorCommit, + urlCommits: urlCommits ) } } diff --git a/buildSrc/src/main/groovy/versioning/RegamedllVersionInfo.groovy b/buildSrc/src/main/groovy/versioning/RegamedllVersionInfo.groovy index a3ba26fd..dae88523 100644 --- a/buildSrc/src/main/groovy/versioning/RegamedllVersionInfo.groovy +++ b/buildSrc/src/main/groovy/versioning/RegamedllVersionInfo.groovy @@ -16,6 +16,7 @@ class RegamedllVersionInfo { DateTime lastCommitDate String commitID String authorCommit + String urlCommits String format(String versionSeparator, String suffixSeparator, boolean includeSuffix) { StringBuilder sb = new StringBuilder() diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 3932b924..e84ac2c4 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -107,7 +107,7 @@ void GameDLL_Version_f() // print version CONSOLE_ECHO("ReGameDLL build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")\n"); CONSOLE_ECHO("ReGameDLL API version %i.%i\n", REGAMEDLL_API_VERSION_MAJOR, REGAMEDLL_API_VERSION_MINOR); - CONSOLE_ECHO("Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/" APP_COMMIT_ID " (" APP_COMMIT_AUTHOR ")\n"); + CONSOLE_ECHO("Build from: " APP_COMMITS_URL APP_COMMIT_ID " " APP_COMMIT_AUTHOR "\n"); } void GameDLL_EndRound_f() diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index e995f84f..db6913fa 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -586,7 +586,7 @@ void CBasePlayer::Radio(const char *msg_id, const char *msg_verbose, short pitch { // search the place name where is located the player const char *placeName = NULL; - if (TheBotPhrases != NULL) + if (g_bIsCzeroGame && TheBotPhrases != NULL) { Place playerPlace = TheNavAreaGrid.GetPlace(&pev->origin); const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); diff --git a/regamedll/dlls/util.cpp b/regamedll/dlls/util.cpp index 4ead2b2b..eac2b286 100644 --- a/regamedll/dlls/util.cpp +++ b/regamedll/dlls/util.cpp @@ -2337,6 +2337,9 @@ int UTIL_ReadFlags(const char *c) // Determine whether bots can be used or not bool UTIL_AreBotsAllowed() { + if (g_engfuncs.pfnEngCheckParm == NULL) + return false; + if (g_bIsCzeroGame) { // If they pass in -nobots, don't allow bots. This is for people who host servers, to diff --git a/regamedll/msvc/PreBuild.bat b/regamedll/msvc/PreBuild.bat index a1c6205c..65a35ef5 100644 --- a/regamedll/msvc/PreBuild.bat +++ b/regamedll/msvc/PreBuild.bat @@ -1,21 +1,27 @@ -@echo OFF +@setlocal enableextensions enabledelayedexpansion +@echo off :: :: Pre-build auto-versioning script :: -SET srcdir=%~1 -SET repodir=%~2 +set srcdir=%~1 +set repodir=%~2 -SET old_version= +set old_version= set old_specialbuild="" -SET version_revision=0 +set version_revision=0 set version_specialbuild= -SET version_pdate_1=%date:~-4%-%date:~3,2%-%date:~0,2% -SET version_pdate=%version_pdate_1% %time:~0,2%:%time:~3,2%:%time:~6,2% -SET version_date=%version_pdate_1%__%time:~0,2%-%time:~3,2%-%time:~6,2% -SET version_major=0 -SET version_minor=0 -SET version_specialversion= +set version_id_commit= +set version_author_commit= +set version_pdate_1=%date:~-4%-%date:~3,2%-%date:~0,2% +set version_pdate=%version_pdate_1%%time:~0,2%:%time:~3,2%:%time:~6,2% +set version_pdate_2=%time:~0,2%-%time:~3,2%-%time:~6,2% +set version_pdate_2=%version_pdate_2: =% +set version_date=%version_pdate_1%__%version_pdate_2% +set version_major=0 +set version_minor=0 +set version_specialversion= +set url_commit= :: :: Check for git.exe presence @@ -29,8 +35,8 @@ set errlvl="%ERRORLEVEL%" IF EXIST "%srcdir%\appversion.h" ( FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\appversion.h") do ( IF %%i==#define ( - IF %%j==APP_VERSION_C SET old_version=%%k - IF %%j==APP_VERSION_SPECIALBUILD SET old_specialbuild=%%k + IF %%j==APP_VERSION_C set old_version=%%k + IF %%j==APP_VERSION_SPECIALBUILD set old_specialbuild=%%k ) ) ) @@ -40,27 +46,27 @@ IF %errlvl% == "1" ( :: if we haven't appversion.h, we need to create it IF NOT "%old_version%" == "" ( - SET version_revision=0 + set version_revision=0 ) ) :: :: Read major, minor and maintenance version components from Version.h :: -IF EXIST "%srcdir%\version.h" ( +IF EXIST "%srcdir%\version.h" ( FOR /F "usebackq tokens=1,2,3" %%i in ("%srcdir%\version.h") do ( IF %%i==#define ( - IF %%j==VERSION_MAJOR SET version_major=%%k - IF %%j==VERSION_MINOR SET version_minor=%%k - IF %%j==VERSION_SPECIALVERSION SET version_specialversion=%%k + IF %%j==VERSION_MAJOR set version_major=%%k + IF %%j==VERSION_MINOR set version_minor=%%k + IF %%j==VERSION_SPECIALVERSION set version_specialversion=%%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==specialVersion SET version_specialversion=%%j + IF %%i==majorVersion set version_major=%%j + IF %%i==minorVersion set version_minor=%%j + IF %%i==specialVersion set version_specialversion=%%j ) ) ) @@ -82,13 +88,66 @@ IF NOT %errlvl% == "1" ( set new_version=%version_major%,%version_minor%,0,%version_revision% +:: +:: Get remote url repository +:: +IF NOT %errlvl% == "1" ( + + set branch_name=master + set branch_remote=origin + :: Get current branch + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --abbrev-ref HEAD"') DO ( + set branch_name=%%i + ) + :: Get remote name by current branch + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." config branch.!branch_name!.remote"') DO ( + set branch_remote=%%i + ) + :: Get remote url + FOR /F "tokens=2 delims=@" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO ( + set url_commit=%%i + ) + :: Get author last no-merge commit + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." log -1 --no-merges --pretty=format:%%an"') DO ( + set version_author_commit=%%i + ) + :: Get commit id + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --verify HEAD"') DO ( + set var=%%i + set version_id_commit=!var:~0,+7! + ) + + IF [!url_commit!] == [] ( + + FOR /F "tokens=1" %%i IN ('"git -C "%repodir%\." config remote.!branch_remote!.url"') DO ( + set url_commit=%%i + ) + + :: strip .git + if "x!url_commit:~-4!"=="x.git" ( + set url_commit=!url_commit:~0,-4! + ) + :: append extra string + set url_commit=!url_commit!/commit/ + ) ELSE ( + :: strip .git + if "x!url_commit:~-4!"=="x.git" ( + set url_commit=!url_commit:~0,-4! + ) + :: replace : to / + set url_commit=!url_commit::=/! + :: append extra string + set url_commit=https://!url_commit!/commit/ + ) +) + :: :: Detect local modifications :: -SET localChanged=0 +set localChanged=0 IF NOT %errlvl% == "1" ( FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." ls-files -m"') DO ( - SET localChanged=1 + set localChanged=1 ) ) @@ -128,23 +187,25 @@ IF "%version_specialversion%" == "" ( echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%version_revision%">>"%srcdir%\appversion.h" echo #define APP_VERSION_STRD_RC "%version_major%.%version_minor%.%version_revision%">>"%srcdir%\appversion.h" echo #define APP_VERSION_C %version_major%,%version_minor%,0,%version_revision% >>"%srcdir%\appversion.h" - echo #define APP_VERSION_STRCS "%version_major%, %version_minor%, 0, %version_revision%">>"%srcdir%\appversion.h" + echo #define APP_VERSION_STRCS "%version_major%,%version_minor%,0,%version_revision%">>"%srcdir%\appversion.h" ) ELSE ( echo #define APP_VERSION_D %version_major%.%version_minor%.%version_maintenance%.%version_revision% >>"%srcdir%\appversion.h" echo #define APP_VERSION_STRD "%version_major%.%version_minor%.%version_maintenance%.%version_revision%">>"%srcdir%\appversion.h" echo #define APP_VERSION_STRD_RC "%version_major%.%version_minor%.%version_maintenance%.%version_revision%">>"%srcdir%\appversion.h" echo #define APP_VERSION_C %version_major%,%version_minor%,%version_maintenance%,%version_revision% >>"%srcdir%\appversion.h" - echo #define APP_VERSION_STRCS "%version_major%, %version_minor%, %version_maintenance%, %version_revision%">>"%srcdir%\appversion.h" + echo #define APP_VERSION_STRCS "%version_major%,%version_minor%,%version_maintenance%,%version_revision%">>"%srcdir%\appversion.h" ) echo.>>"%srcdir%\appversion.h" echo #define APP_VERSION_DATE %version_date%>>"%srcdir%\appversion.h" echo #define APP_VERSION_DATE_STR "%version_date%">>"%srcdir%\appversion.h" -echo.>>"%srcdir%\appversion.h" echo #define APP_VERSION_PDATE_STR "%version_pdate%">>"%srcdir%\appversion.h" -echo.>>"%srcdir%\appversion.h" echo #define APP_VERSION_YMD_STR "%version_pdate_1%">>"%srcdir%\appversion.h" echo.>>"%srcdir%\appversion.h" +echo #define APP_COMMIT_AUTHOR "(%version_author_commit%)">>"%srcdir%\appversion.h" +echo #define APP_COMMIT_ID "%version_id_commit%">>"%srcdir%\appversion.h" +echo #define APP_COMMITS_URL "%url_commit%">>"%srcdir%\appversion.h" +echo.>>"%srcdir%\appversion.h" IF NOT "%version_specialbuild%" == "" ( echo #define APP_VERSION_FLAGS VS_FF_SPECIALBUILD>>"%srcdir%\appversion.h" @@ -163,6 +224,7 @@ 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 \ No newline at end of file diff --git a/regamedll/version/appversion.vm b/regamedll/version/appversion.vm index 21384417..bc844205 100644 --- a/regamedll/version/appversion.vm +++ b/regamedll/version/appversion.vm @@ -10,8 +10,9 @@ \#define VERSION_MAJOR ${verInfo.majorVersion} \#define VERSION_MINOR ${verInfo.minorVersion} -\#define APP_COMMIT_AUTHOR "${verInfo.authorCommit}" +\#define APP_COMMIT_AUTHOR "(${verInfo.authorCommit})" \#define APP_COMMIT_ID "${verInfo.commitID}" +\#define APP_COMMITS_URL "${verInfo.urlCommits}" \#define APP_VERSION_D ${verInfo.format('.', '-', true)} \#define APP_VERSION_C ${verInfo.majorVersion},${verInfo.minorVersion},0,${verInfo.countCommit}