Skip to content

Commit

Permalink
Merge branch 's1lentq:master' into botescape
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaqtincha authored Sep 15, 2024
2 parents 8c8e8ed + 19714af commit b76fbfc
Show file tree
Hide file tree
Showing 92 changed files with 1,860 additions and 821 deletions.
44 changes: 16 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Nuget
uses: nuget/setup-nuget@v1
with:
nuget-api-key: ${{ secrets.NuGetAPIKey }}
nuget-version: '5.x'

- run: nuget restore '${{ env.solution }}'

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.1.3
uses: microsoft/setup-msbuild@v2
with:
vs-version: '16.8'

Expand Down Expand Up @@ -80,6 +72,7 @@ jobs:
env:
WINEDEBUG: -all
WINEDLLOVERRIDES: mshtml=
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

defaults:
run:
Expand Down Expand Up @@ -141,18 +134,23 @@ jobs:
linux:
name: 'Linux'
runs-on: ubuntu-20.04
container: s1lentq/linux86buildtools:latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- name: Check dependencies
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y gcc-multilib g++-multilib
- name: Build and Run unittests
run: |
rm -rf build && CC=icc CXX=icpc cmake -DCMAKE_BUILD_TYPE=Unittests -B build && cmake --build build -j8
rm -rf build && CC=gcc CXX=g++ cmake -DCMAKE_BUILD_TYPE=Unittests -B build && cmake --build build -j8
retVal=0
./build/regamedll/cs 2> /dev/null > result.log || retVal=$?
while read line; do
Expand All @@ -173,17 +171,9 @@ jobs:
fi
shell: bash

- name: Build using Intel C++ Compiler 19.0 (only for release)
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
run: |
rm -rf build-icc && CC=icc CXX=icpc cmake -B build-icc && cmake --build build-icc -j8
- name: Build using GCC Compiler 9.3
- name: Build
run: |
rm -rf build-gcc && CC=gcc CXX=g++ cmake -B build-gcc && cmake --build build-gcc -j8
rm -rf build && CC=gcc CXX=g++ cmake -B build && cmake --build build -j8
- name: Prepare CSSDK
run: |
Expand All @@ -193,16 +183,14 @@ jobs:
- name: Move files
run: |
mkdir -p publish/bin/linux32/cstrike/dlls
mv build-icc/regamedll/cs.so publish/bin/linux32/cstrike/dlls/cs.so 2>/dev/null || true
mv build-gcc/regamedll/cs.so publish/cs-gcc.so
mv build/regamedll/cs.so publish/bin/linux32/cstrike/dlls/cs.so 2>/dev/null || true
mv regamedll/version/appversion.h publish/appversion.h
mv dist/ publish/
- name: Run GLIBC/ABI version compat test
run: |
binaries=(
"publish/bin/linux32/cstrike/dlls/cs.so"
"publish/cs-gcc.so"
)
bash ./regamedll/version/glibc_test.sh ${binaries[@]}
if [[ $? -ne 0 ]]; then
Expand All @@ -225,7 +213,7 @@ jobs:
publish:
name: 'Publish'
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: [windows, testdemos, linux]

steps:
Expand Down Expand Up @@ -265,7 +253,7 @@ jobs:
7z a -tzip regamedll-bin-${{ env.APP_VERSION }}.zip bin/ cssdk/
- name: Publish artifacts
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
id: publish-job
if: |
startsWith(github.ref, 'refs/tags/') &&
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| mp_freezetime_duck | 1 | 0 | 1 | Allow players to duck during freezetime.<br/> `0` disabled<br/>`1` enabled |
| mp_freezetime_jump | 1 | 0 | 1 | Allow players to jump during freezetime.<br/> `0` disabled<br/>`1` enabled |
| mp_defuser_allocation | 0 | 0 | 2 | Give defuser on player spawn.<br/> `0` disabled<br/>`1` Random players. <br/>`2` All players. |
| mp_location_area_info | 0 | 0 | 3 | Enable location area info.<br/> `0` disabled<br/>`1` show location below HUD radar.<br/>`2` show location in HUD chat. `NOT RECOMMENDED!` [:speech_balloon:](## "Not all client builds are compatible")<br/>`3` both displayed. `NOT RECOMMENDED!` [:speech_balloon:](## "Not all client builds are compatible")<br/><br/>`NOTE`: Navigation `maps/.nav` file required and should contain place names<br/>`NOTE`: If option `2` or `3` is enabled, be sure to enable `mp_chat_loc_fallback 1` |
| mp_item_respawn_time | 30 | 0.0 | - | The respawn time for items (such as health packs, armor, etc.). |
| mp_weapon_respawn_time | 20 | 0.0 | - | The respawn time for weapons. |
| mp_ammo_respawn_time | 20 | 0.0 | - | The respawn time for ammunition. |
| mp_vote_flags | km | 0 | - | Vote systems enabled in server.<br/>`0` voting disabled<br/>`k` votekick enabled via `vote` command<br/>`m` votemap enabled via `votemap` command |
| mp_votemap_min_time | 180 | 0.0 | - | Minimum seconds that must elapse on map before `votemap` command can be used. |

</details>

## How to install zBot for CS 1.6?
Expand Down
45 changes: 45 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,48 @@ mp_freezetime_jump "1"
//
// Default value: "0"
mp_defuser_allocation "0"

// Enable location area info
// 0 - disabled (default behavior)
// 1 - show location below HUD radar
// 2 - show location in HUD chat (NOT RECOMMENDED! Not all client builds are compatible)
// 3 - both displayed (NOT RECOMMENDED! Not all client builds are compatible)
//
// NOTE: Navigation maps/.nav file required and should contain place names
// NOTE: If option 2 or 3 is enabled, be sure to enable mp_chat_loc_fallback 1
//
// Default value: "0"
mp_location_area_info "0"

// The respawn time for items (such as health packs, armor, etc.).
// 0 - disable delay
//
// Default value: "30"
mp_item_respawn_time "30"

// The respawn time for weapons.
// 0 - disable delay
//
// Default value: "20"
mp_weapon_respawn_time "20"

// The respawn time for ammunition.
// 0 - disable delay
//
// Default value: "20"
mp_ammo_respawn_time "20"

// Vote systems enabled in server
//
// k - votekick enabled via vote command
// m - votemap enabled via votemap command
//
// Set to "0" to disable voting systems
//
// Default value: "km"
mp_vote_flags "km"

// Minimum seconds that must elapse on map before votemap command can be used
//
// Default value: "180"
mp_votemap_min_time "180"
14 changes: 9 additions & 5 deletions regamedll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ project(regamedll CXX)

option(DEBUG "Build with debug information." OFF)
option(USE_STATIC_LIBSTDC "Enables static linking libstdc++." OFF)
option(USE_LEGACY_LIBC "Enables linking against legacy libc (<= 2.15) for compat with older distros (Debian 8/Ubuntu 16.04/Centos 7)." OFF)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -32,6 +33,7 @@ set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")

set(COMPILE_FLAGS "-m32 -U_FORTIFY_SOURCE")
set(LINK_FLAGS "-m32 -s")
set(LINK_LIBS dl aelf32)

set(COMPILE_FLAGS "${COMPILE_FLAGS} -Wall -fno-exceptions -fno-builtin -Wno-unknown-pragmas")

Expand Down Expand Up @@ -346,6 +348,7 @@ target_compile_definitions(regamedll PRIVATE
_strnicmp=strncasecmp
_strdup=strdup
_unlink=unlink
_snprintf=snprintf
_vsnprintf=vsnprintf
_write=write
_close=close
Expand All @@ -362,12 +365,13 @@ target_sources(regamedll PRIVATE
${UNITTESTS_SRCS}>
)

target_link_libraries(regamedll PRIVATE
dl
aelf32
if (CMAKE_BUILD_TYPE MATCHES Unittests)
list(APPEND LINK_LIBS cppunitlite)
elseif (USE_LEGACY_LIBC)
list(APPEND LINK_LIBS libc-2.15.so)
endif()

$<$<CONFIG:Unittests>:cppunitlite>
)
target_link_libraries(regamedll PRIVATE ${LINK_LIBS})

if (USE_STATIC_LIBSTDC)
target_compile_definitions(regamedll PRIVATE BUILD_STATIC_LIBSTDC)
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/API/CAPI_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ GAMEHOOK_REGISTRY(CSGameRules_SendDeathMessage);

GAMEHOOK_REGISTRY(CBasePlayer_PlayerDeathThink);
GAMEHOOK_REGISTRY(CBasePlayer_Observer_Think);
GAMEHOOK_REGISTRY(CBasePlayer_RemoveAllItems);

int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR;
Expand Down
6 changes: 6 additions & 0 deletions regamedll/dlls/API/CAPI_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,10 @@ typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBase
typedef IHookChainClassImpl<void, CBasePlayer> CReGameHook_CBasePlayer_Observer_Think;
typedef IHookChainRegistryClassImpl<void, CBasePlayer> CReGameHookRegistry_CBasePlayer_Observer_Think;

// CBasePlayer::RemoveAllItems hook
typedef IHookChainClassImpl<void, CBasePlayer, BOOL> CReGameHook_CBasePlayer_RemoveAllItems;
typedef IHookChainRegistryClassImpl<void, CBasePlayer, BOOL> CReGameHookRegistry_CBasePlayer_RemoveAllItems;

class CReGameHookchains: public IReGameHookchains {
public:
// CBasePlayer virtual
Expand Down Expand Up @@ -905,6 +909,7 @@ class CReGameHookchains: public IReGameHookchains {

CReGameHookRegistry_CBasePlayer_PlayerDeathThink m_CBasePlayer_PlayerDeathThink;
CReGameHookRegistry_CBasePlayer_Observer_Think m_CBasePlayer_Observer_Think;
CReGameHookRegistry_CBasePlayer_RemoveAllItems m_CBasePlayer_RemoveAllItems;

public:
virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn();
Expand Down Expand Up @@ -1064,6 +1069,7 @@ class CReGameHookchains: public IReGameHookchains {

virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink();
virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think();
virtual IReGameHookRegistry_CBasePlayer_RemoveAllItems *CBasePlayer_RemoveAllItems();
};

extern CReGameHookchains g_ReGameHookchains;
Expand Down
6 changes: 5 additions & 1 deletion regamedll/dlls/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ void CBasePlayerAmmo::Spawn()

SetTouch(&CBasePlayerAmmo::DefaultTouch);

if (g_pGameRules->IsMultiplayer())
if (g_pGameRules->IsMultiplayer()
#ifdef REGAMEDLL_FIXES
&& g_pGameRules->AmmoShouldRespawn(this) == GR_AMMO_RESPAWN_NO
#endif
)
{
SetThink(&CBaseEntity::SUB_Remove);
pev->nextthink = gpGlobals->time + 2.0f;
Expand Down
10 changes: 2 additions & 8 deletions regamedll/dlls/bot/cs_bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ int GetBotFollowCount(CBasePlayer *pLeader)
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);

if (!pPlayer)
continue;

if (FNullEnt(pPlayer->pev))
if (!UTIL_IsValidPlayer(pPlayer))
continue;

if (FStrEq(STRING(pPlayer->pev->netname), ""))
Expand Down Expand Up @@ -685,10 +682,7 @@ CBasePlayer *CCSBot::GetImportantEnemy(bool checkVisibility) const
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);

if (!pPlayer)
continue;

if (FNullEnt(pPlayer->pev))
if (!UTIL_IsValidPlayer(pPlayer))
continue;

if (FStrEq(STRING(pPlayer->pev->netname), ""))
Expand Down
15 changes: 7 additions & 8 deletions regamedll/dlls/bot/cs_bot_chatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ void BotMeme::Transmit(CCSBot *pSender) const
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);

if (!pPlayer)
continue;

if (FNullEnt(pPlayer->pev))
if (!UTIL_IsValidPlayer(pPlayer))
continue;

if (FStrEq(STRING(pPlayer->pev->netname), ""))
Expand Down Expand Up @@ -540,8 +537,13 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex)
else if (!Q_stricmp("UNDEFINED", token))
placeCriteria = UNDEFINED_PLACE;
else
{
placeCriteria = TheBotPhrases->NameToID(token);

if (!TheBotPhrases->IsValid() && placeCriteria == UNDEFINED_PLACE)
placeCriteria = TheNavAreaGrid.NameToID(token);
}

continue;
}

Expand Down Expand Up @@ -1520,10 +1522,7 @@ BotStatement *BotChatterInterface::GetActiveStatement()
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);

if (!pPlayer)
continue;

if (FNullEnt(pPlayer->pev))
if (!UTIL_IsValidPlayer(pPlayer))
continue;

if (FStrEq(STRING(pPlayer->pev->netname), ""))
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/bot/cs_bot_chatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ class BotPhraseManager
Place NameToID(const char *name) const;
const char *IDToName(Place id) const;

bool IsValid() const { return !m_placeList.empty(); }

// given a name, return the associated phrase collection
const BotPhrase *GetPhrase(const char *name) const;

Expand Down
6 changes: 5 additions & 1 deletion regamedll/dlls/bot/cs_bot_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ cvar_t cv_bot_deathmatch = { "bot_deathmatch", "0", FCVAR_SERVER, 0.
cvar_t cv_bot_quota_mode = { "bot_quota_mode", "normal", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_join_delay = { "bot_join_delay", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_freeze = { "bot_freeze", "0", 0, 0.0f, nullptr };
cvar_t cv_bot_mimic = { "bot_mimic", "0", 0, 0.0f, nullptr };
cvar_t cv_bot_mimic_yaw_offset = { "bot_mimic_yaw_offset", "0", 0, 0.0f, nullptr };
#else
// Migrated to bot_quota_mode, use "match"
cvar_t cv_bot_quota_match = { "bot_quota_match", "0", FCVAR_SERVER, 0.0f, nullptr };
Expand Down Expand Up @@ -131,6 +133,8 @@ void Bot_RegisterCVars()
CVAR_REGISTER(&cv_bot_quota_mode);
CVAR_REGISTER(&cv_bot_join_delay);
CVAR_REGISTER(&cv_bot_freeze);
CVAR_REGISTER(&cv_bot_mimic);
CVAR_REGISTER(&cv_bot_mimic_yaw_offset);
#endif

}
Expand Down Expand Up @@ -328,7 +332,7 @@ void CCSBot::SpawnBot()
TheCSBots()->ValidateMapData();
ResetValues();

Q_strcpy(m_name, STRING(pev->netname));
Q_strlcpy(m_name, STRING(pev->netname));

SetState(&m_buyState);
SetTouch(&CCSBot::BotTouch);
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/bot/cs_bot_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ extern cvar_t cv_bot_deathmatch;
extern cvar_t cv_bot_quota_mode;
extern cvar_t cv_bot_join_delay;
extern cvar_t cv_bot_freeze;
extern cvar_t cv_bot_mimic;
extern cvar_t cv_bot_mimic_yaw_offset;
#else
extern cvar_t cv_bot_quota_match;
#endif
8 changes: 4 additions & 4 deletions regamedll/dlls/bot/cs_bot_learn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,14 @@ void CCSBot::StartSaveProcess()

void CCSBot::UpdateSaveProcess()
{
char filename[256];
char msg[256];
char cmd[128];

GET_GAME_DIR(filename);
char gd[64]{};
GET_GAME_DIR(gd);

Q_strcat(filename, "\\");
Q_strcat(filename, TheBots->GetNavMapFilename());
char filename[MAX_OSPATH];
Q_snprintf(filename, sizeof(filename), "%s\\%s", gd, TheBots->GetNavMapFilename());

HintMessageToAllPlayers("Saving...");
SaveNavigationMap(filename);
Expand Down
Loading

0 comments on commit b76fbfc

Please sign in to comment.