From 07e861eb3022a751e9d664519b17cd68e6ceac21 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Wed, 27 Jul 2016 21:08:42 +0700 Subject: [PATCH] Added cvar mp_team_maxkills Changed enum AmmoType --- README.md | 1 + .../groovy/versioning/GitVersioner.groovy | 10 +++- dist/game.cfg | 7 +++ regamedll/dlls/cdll_dll.h | 1 - regamedll/dlls/client.cpp | 2 +- regamedll/dlls/game.cpp | 2 + regamedll/dlls/game.h | 1 + regamedll/dlls/multiplay_gamerules.cpp | 6 ++- regamedll/dlls/player.cpp | 2 +- regamedll/dlls/weapons.cpp | 46 ++++++++++++++++--- regamedll/dlls/weapontype.cpp | 8 ++-- regamedll/dlls/weapontype.h | 23 ++++++---- regamedll/extra/cssdk/dlls/cdll_dll.h | 1 - regamedll/extra/cssdk/dlls/weapontype.h | 23 ++++++---- regamedll/msvc/PreBuild.bat | 28 +++++++---- 15 files changed, 118 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 12112e26..bafc5033 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure' | mp_refill_bpammo_weapons | 0 | 0 | 2 | Refill amount of backpack ammo up to the max
`0` disabled
`1` refill backpack ammo on player spawn
`2` refill backpack ammo on each weapon reload | | bot_deathmatch | 0 | 0 | 1 | Set's the mode for the zBot
`0` disabled
`1` enable mode Deathmatch and not allow to do the scenario | | mp_auto_join_team | 0 | 0 | 1 | Automatically joins the team
`0` disabled
`1` enable (Use in conjunction with the cvar humans_join_team any/CT/T) | +| mp_max_teamkills | 3 | 0 | - | Maximum number of allowed teamkills before autokick. Used when enabled mp_autokick. | ## How to install zBot for CS 1.6? * Extract all the files from an [archive](regamedll/extra/zBot/bot_profiles.zip?raw=true) diff --git a/buildSrc/src/main/groovy/versioning/GitVersioner.groovy b/buildSrc/src/main/groovy/versioning/GitVersioner.groovy index 4a5aac29..862d6a79 100644 --- a/buildSrc/src/main/groovy/versioning/GitVersioner.groovy +++ b/buildSrc/src/main/groovy/versioning/GitVersioner.groovy @@ -52,10 +52,16 @@ class GitVersioner { childPath = url.substring(pos + 1, url.lastIndexOf('.git')).replace(':', '/'); sb.append('https://'); } else { - childPath = url.substring(0, url.lastIndexOf('.git')); + pos = url.lastIndexOf('.git'); + childPath = (pos == -1) ? url : url.substring(0, pos); } - sb.append(childPath).append('/commit/'); + // 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(); } static GitInfo versionForDir(File dir) { diff --git a/dist/game.cfg b/dist/game.cfg index 8ef1d87e..c1be303b 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -77,3 +77,10 @@ bot_deathmatch 0 // // Default value: "0" mp_auto_join_team 0 + +// Maximum number of allowed teamkills before autokick. +// Used when enabled mp_autokick. +// 0 - disabled +// +// Default value: "3" +mp_max_teamkills 3 diff --git a/regamedll/dlls/cdll_dll.h b/regamedll/dlls/cdll_dll.h index 342bcdfe..678b056d 100644 --- a/regamedll/dlls/cdll_dll.h +++ b/regamedll/dlls/cdll_dll.h @@ -89,7 +89,6 @@ #define MENU_KEY_9 (1<<8) #define MENU_KEY_0 (1<<9) -#define MAX_AMMO_TYPES 32 // ??? #define MAX_AMMO_SLOTS 32 // not really slots #define HUD_PRINTNOTIFY 1 diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 0a202030..c313e4cb 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -4517,7 +4517,7 @@ void EXT_FUNC UpdateClientData(const struct edict_s *ent, int sendweapons, struc { cd->m_iId = II.iId; - if ((unsigned int)weapon->m_iPrimaryAmmoType < MAX_AMMO_TYPES) + if ((unsigned int)weapon->m_iPrimaryAmmoType < MAX_AMMO_SLOTS) { cd->vuser4.x = weapon->m_iPrimaryAmmoType; cd->vuser4.y = pPlayer->m_rgAmmo[ weapon->m_iPrimaryAmmoType ]; diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index ffb1cebe..2459feac 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -105,6 +105,7 @@ cvar_t auto_reload_weapons = { "mp_auto_reload_weapons", "0", 0, 0.0f, nullptr } cvar_t refill_bpammo_weapons = { "mp_refill_bpammo_weapons", "0", 0, 0.0f, nullptr }; // Useful for mods like DeathMatch, GunGame, ZombieMod etc cvar_t freeforall = { "mp_freeforall", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t auto_join_team = { "mp_auto_join_team", "0", 0, 0.0f, nullptr }; +cvar_t max_teamkills = { "mp_max_teamkills", "3", 0, 3.0f, nullptr }; void GameDLL_Version_f() { @@ -236,6 +237,7 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&refill_bpammo_weapons); CVAR_REGISTER(&freeforall); CVAR_REGISTER(&auto_join_team); + CVAR_REGISTER(&max_teamkills); // print version CONSOLE_ECHO("ReGameDLL build: " __TIME__ " " __DATE__ " (" APP_VERSION_STRD ")\n"); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 1a352136..e83e0be9 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -142,6 +142,7 @@ extern cvar_t auto_reload_weapons; extern cvar_t refill_bpammo_weapons; extern cvar_t freeforall; extern cvar_t auto_join_team; +extern cvar_t max_teamkills; #endif diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 4ff01f24..fce824ab 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -3604,7 +3604,11 @@ void CHalfLifeMultiplay::__API_VHOOK(PlayerKilled)(CBasePlayer *pVictim, entvars ClientPrint(killer->pev, HUD_PRINTCENTER, "#Killed_Teammate"); ClientPrint(killer->pev, HUD_PRINTCONSOLE, "#Game_teammate_kills", UTIL_dtos1(killer->m_iTeamKills)); - if (killer->m_iTeamKills == 3 && autokick.value != 0.0f) +#ifdef REGAMEDLL_ADD + if (autokick.value && max_teamkills.value && killer->m_iTeamKills >= (int)max_teamkills.value) +#else + if (autokick.value && killer->m_iTeamKills == 3) +#endif { ClientPrint(killer->pev, HUD_PRINTCONSOLE, "#Banned_For_Killing_Teamates"); diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 39a12b00..e83f95e1 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -4290,7 +4290,7 @@ void EXT_FUNC CBasePlayer::__API_VHOOK(PreThink)() //check if this player has been inactive for 2 rounds straight if (flLastMove > CSGameRules()->m_fMaxIdlePeriod) { - if (!IsBot() && CVAR_GET_FLOAT("mp_autokick") != 0.0f) + if (!IsBot() && autokick.value) { // Log the kick UTIL_LogPrintf("\"%s<%i><%s><%s>\" triggered \"Game_idle_kick\" (auto)\n", STRING(pev->netname), GETPLAYERUSERID(edict()), GETPLAYERAUTHID(edict()), GetTeam(m_iTeam)); diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index a30cf27c..a0935f4a 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -204,6 +204,29 @@ NOXREF void EjectBrass2(const Vector &vecOrigin, const Vector &vecVelocity, floa MESSAGE_END(); } +#ifdef REGAMEDLL_ADD +struct { + AmmoType type; + const char *name; +} ammoIndex[] = +{ + { AMMO_338MAGNUM, "338Magnum" }, + { AMMO_762NATO, "762Nato" }, + { AMMO_556NATOBOX, "556NatoBox" }, + { AMMO_556NATO, "556Nato" }, + { AMMO_BUCKSHOT, "buckshot" }, + { AMMO_45ACP, "45acp" }, + { AMMO_57MM, "57mm" }, + { AMMO_50AE, "50AE" }, + { AMMO_357SIG, "357SIG" }, + { AMMO_9MM, "9mm" }, + { AMMO_FLASHBANG, "Flashbang" }, + { AMMO_HEGRENADE, "HEGrenade" }, + { AMMO_SMOKEGRENADE, "SmokeGrenade" }, + { AMMO_C4, "C4" }, +}; +#endif + // Precaches the ammo and queues the ammo info for sending to clients void AddAmmoNameToAmmoRegistry(const char *szAmmoname) { @@ -224,9 +247,20 @@ void AddAmmoNameToAmmoRegistry(const char *szAmmoname) assert(giAmmoIndex < MAX_AMMO_SLOTS); if (giAmmoIndex >= MAX_AMMO_SLOTS) - { giAmmoIndex = 0; + +#ifdef REGAMEDLL_ADD + for (auto& ammo : ammoIndex) + { + if (Q_stricmp(ammo.name, szAmmoname)) + continue; + + if (ammo.type != giAmmoIndex) { + CONSOLE_ECHO("Warning: ammo '%s' index mismatch; expected %i, real %i\n", szAmmoname, ammo.type, giAmmoIndex); + } + break; } +#endif IMPL_CLASS(CBasePlayerItem, AmmoInfoArray)[ giAmmoIndex ].pszName = szAmmoname; @@ -246,8 +280,7 @@ void UTIL_PrecacheOtherWeapon(const char *szClassname) } CBaseEntity *pEntity = CBaseEntity::Instance(VARS(pent)); - - if (pEntity != NULL) + if (pEntity) { ItemInfo II; Q_memset(&II, 0, sizeof(II)); @@ -1794,7 +1827,6 @@ void CWeaponBox::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) // unlink this weapon from the box m_rgpPlayerItems[i] = pItem = pNext; - continue; } #else @@ -1822,13 +1854,16 @@ void CWeaponBox::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) { // CRITICAL BUG: since gives a new entity using GiveNamedItem, // but the entity is packaged in a weaponbox still exists and will never used or removed. It's leak! + // How reproduced: Drop your grenade on the ground, check output of command `entity_dump`, + // there we will see only get one grenade. Next step - pick it up, do check again `entity_dump`, + // but this time we'll see them x2. + bEmitSound = true; pPlayer->GiveNamedItem(grenadeName); // unlink this weapon from the box pItem = m_rgpPlayerItems[i]->m_pNext; m_rgpPlayerItems[i] = pItem; - continue; } #endif @@ -1850,7 +1885,6 @@ void CWeaponBox::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) // unlink this weapon from the box m_rgpPlayerItems[i] = pItem = pNext; - continue; } diff --git a/regamedll/dlls/weapontype.cpp b/regamedll/dlls/weapontype.cpp index a2fc0dcf..0de91eb2 100644 --- a/regamedll/dlls/weapontype.cpp +++ b/regamedll/dlls/weapontype.cpp @@ -254,11 +254,11 @@ WeaponInfoStruct weaponInfo_default[] = { WEAPON_P90, P90_PRICE, AMMO_57MM_PRICE, AMMO_57MM_BUY, P90_MAX_CLIP, MAX_AMMO_57MM, AMMO_57MM, "weapon_p90", "ammo_57mm" }, #ifdef REGAMEDLL_ADD - { WEAPON_C4, 0, 0, 0, 0, 0, AMMO_NONE, "weapon_c4", nullptr }, + { WEAPON_C4, 0, 0, 0, 0, 0, AMMO_C4, "weapon_c4", nullptr }, { WEAPON_KNIFE, 0, 0, 0, 0, 0, AMMO_NONE, "weapon_knife", nullptr }, - { WEAPON_HEGRENADE, (WeaponCostType)HEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_HEGRENADE, AMMO_NONE, "weapon_hegrenade", nullptr }, - { WEAPON_SMOKEGRENADE, (WeaponCostType)SMOKEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_SMOKEGRENADE, AMMO_NONE, "weapon_smokegrenade", nullptr }, - { WEAPON_FLASHBANG, (WeaponCostType)FLASHBANG_PRICE, 0, 0, 0, MAX_AMMO_FLASHBANG, AMMO_NONE, "weapon_flashbang", nullptr }, + { WEAPON_HEGRENADE, (WeaponCostType)HEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_HEGRENADE, AMMO_HEGRENADE, "weapon_hegrenade", nullptr }, + { WEAPON_SMOKEGRENADE, (WeaponCostType)SMOKEGRENADE_PRICE, 0, 0, 0, MAX_AMMO_SMOKEGRENADE, AMMO_SMOKEGRENADE, "weapon_smokegrenade", nullptr }, + { WEAPON_FLASHBANG, (WeaponCostType)FLASHBANG_PRICE, 0, 0, 0, MAX_AMMO_FLASHBANG, AMMO_FLASHBANG, "weapon_flashbang", nullptr }, #endif { WEAPON_SHIELDGUN, SHIELDGUN_PRICE, 0, 0, 0, 0, AMMO_NONE, "weapon_shield", nullptr }, diff --git a/regamedll/dlls/weapontype.h b/regamedll/dlls/weapontype.h index 86060699..4c0f847a 100644 --- a/regamedll/dlls/weapontype.h +++ b/regamedll/dlls/weapontype.h @@ -256,18 +256,23 @@ enum MaxAmmoType enum AmmoType { - AMMO_NONE = -1, - AMMO_BUCKSHOT, - AMMO_9MM, - AMMO_556NATO, - AMMO_556NATOBOX, - AMMO_762NATO, - AMMO_45ACP, - AMMO_50AE, + AMMO_NONE, AMMO_338MAGNUM, + AMMO_762NATO, + AMMO_556NATOBOX, + AMMO_556NATO, + AMMO_BUCKSHOT, + AMMO_45ACP, AMMO_57MM, + AMMO_50AE, AMMO_357SIG, - AMMO_MAX_TYPES, + AMMO_9MM, + AMMO_FLASHBANG, + AMMO_HEGRENADE, + AMMO_SMOKEGRENADE, + AMMO_C4, + + AMMO_MAX_TYPES }; enum WeaponClassType diff --git a/regamedll/extra/cssdk/dlls/cdll_dll.h b/regamedll/extra/cssdk/dlls/cdll_dll.h index e69f6fce..0a033cc1 100644 --- a/regamedll/extra/cssdk/dlls/cdll_dll.h +++ b/regamedll/extra/cssdk/dlls/cdll_dll.h @@ -84,7 +84,6 @@ #define MENU_KEY_9 (1<<8) #define MENU_KEY_0 (1<<9) -#define MAX_AMMO_TYPES 32 // ??? #define MAX_AMMO_SLOTS 32 // not really slots #define HUD_PRINTNOTIFY 1 diff --git a/regamedll/extra/cssdk/dlls/weapontype.h b/regamedll/extra/cssdk/dlls/weapontype.h index 10e5b670..784f8049 100644 --- a/regamedll/extra/cssdk/dlls/weapontype.h +++ b/regamedll/extra/cssdk/dlls/weapontype.h @@ -251,18 +251,23 @@ enum MaxAmmoType enum AmmoType { - AMMO_NONE = -1, - AMMO_BUCKSHOT, - AMMO_9MM, - AMMO_556NATO, - AMMO_556NATOBOX, - AMMO_762NATO, - AMMO_45ACP, - AMMO_50AE, + AMMO_NONE, AMMO_338MAGNUM, + AMMO_762NATO, + AMMO_556NATOBOX, + AMMO_556NATO, + AMMO_BUCKSHOT, + AMMO_45ACP, AMMO_57MM, + AMMO_50AE, AMMO_357SIG, - AMMO_MAX_TYPES, + AMMO_9MM, + AMMO_FLASHBANG, + AMMO_HEGRENADE, + AMMO_SMOKEGRENADE, + AMMO_C4, + + AMMO_MAX_TYPES }; enum WeaponClassType diff --git a/regamedll/msvc/PreBuild.bat b/regamedll/msvc/PreBuild.bat index 65a35ef5..7b994817 100644 --- a/regamedll/msvc/PreBuild.bat +++ b/regamedll/msvc/PreBuild.bat @@ -22,6 +22,7 @@ set version_major=0 set version_minor=0 set version_specialversion= set url_commit= +set branch_name=master :: :: Check for git.exe presence @@ -75,7 +76,12 @@ IF EXIST "%srcdir%\version.h" ( :: Read revision and release date from it :: IF NOT %errlvl% == "1" ( - FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --all | wc -l"') DO ( + :: Get current branch + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-parse --abbrev-ref HEAD"') DO ( + set branch_name=%%i + ) + + FOR /F "tokens=*" %%i IN ('"git -C "%repodir%\." rev-list --count !branch_name!"') DO ( IF NOT [%%i] == [] ( set version_revision=%%i ) @@ -93,12 +99,7 @@ set new_version=%version_major%,%version_minor%,0,%version_revision% :: 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 @@ -127,8 +128,14 @@ IF NOT %errlvl% == "1" ( if "x!url_commit:~-4!"=="x.git" ( set url_commit=!url_commit:~0,-4! ) + :: append extra string - set url_commit=!url_commit!/commit/ + If NOT "%url_commit%"=="%url_commit:bitbucket.org=%" ( + set url_commit=!url_commit!/commits/ + ) ELSE ( + set url_commit=!url_commit!/commit/ + ) + ) ELSE ( :: strip .git if "x!url_commit:~-4!"=="x.git" ( @@ -136,8 +143,13 @@ IF NOT %errlvl% == "1" ( ) :: replace : to / set url_commit=!url_commit::=/! + :: append extra string - set url_commit=https://!url_commit!/commit/ + If NOT "%url_commit%"=="%url_commit:bitbucket.org=%" ( + set url_commit=https://!url_commit!/commits/ + ) ELSE ( + set url_commit=https://!url_commit!/commit/ + ) ) )