Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/s1lentq/ReGameDLL_CS
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-up committed Oct 19, 2024
2 parents 4a41ef6 + 9b626b1 commit 16b24f9
Show file tree
Hide file tree
Showing 70 changed files with 944 additions and 441 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ jobs:
move msvc\${{ env.buildRelease }}\mp.pdb publish\debug\mp.pdb
- name: Deploy artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3.1.1
with:
name: win32
path: publish/*

testdemos:
if: false # TODO: FIXME!!
name: 'Test demos (FIXME)'
name: 'Test demos'
runs-on: ubuntu-20.04
container: s1lentq/testdemos:latest
needs: [windows]

env:
WINEDEBUG: -all
WINEDLLOVERRIDES: mshtml=
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

defaults:
run:
Expand All @@ -81,7 +81,7 @@ jobs:

steps:
- name: Deploying windows artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: win32

Expand Down Expand Up @@ -146,12 +146,11 @@ jobs:
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y clang
sudo apt-get install -y gcc-multilib g++-multilib
- name: Build and Run unittests
run: |
rm -rf build && CC=clang CXX=clang++ 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 @@ -172,9 +171,9 @@ jobs:
fi
shell: bash

- name: Build using Clang C++ Compiler
- name: Build
run: |
rm -rf build && CC=clang CXX=clang++ cmake -B build && cmake --build build -j8
rm -rf build && CC=gcc CXX=g++ cmake -B build && cmake --build build -j8
- name: Prepare CSSDK
run: |
Expand All @@ -200,7 +199,7 @@ jobs:
shell: bash

- name: Deploy artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3.1.1
id: upload-job
with:
name: linux32
Expand All @@ -219,12 +218,12 @@ jobs:

steps:
- name: Deploying linux artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v3
with:
name: linux32

- name: Deploying windows artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v3
with:
name: win32

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| swapteams | Swap the teams and restart the game (1 sec delay to restart by default).<br/> Args: <br/>`0` - swap teams without restart. <br/> `>0.001` - time delay in seconds to restart the round after swap. |
| give | Give weapon command.<br/> Args:<br/><weapon_name><br/>Usage:<br/>`give weapon_ak47`<br/>`give weapon_usp`<br/><br/>NOTE: `sv_cheats 1` required. |
| impulse 255 | Give all weapons.<br/><br/>NOTE: `sv_cheats 1` required. |
| impulse 200 | Noclip with air acceleration.<br/><br/>NOTE: `sv_cheats 1` required. |

## Configuration (cvars)
<details>
Expand Down Expand Up @@ -120,6 +121,8 @@ This means that plugins that do binary code analysis (Orpheu for example) probab
| 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. |
| mp_scoreboard_fix | 0 | 0 | 1 | Enable ReGameDLL scoreboard bug fix(Dead players could see the bomb or defuse kit).<br/> `0` disabled<br/>`1` enabled<br/>`NOTE`: Absolutely cannot fix it in "CNCS😂" |
</details>

Expand Down
15 changes: 15 additions & 0 deletions dist/game.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,21 @@ mp_weapon_respawn_time "20"
// 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"
// Enable ReGameDLL scoreboard bug fix(Dead players could see the bomb or defuse kit)
// 0 - disable
// 1 - enabled
Expand Down
1 change: 1 addition & 0 deletions regamedll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ target_compile_definitions(regamedll PRIVATE
_strnicmp=strncasecmp
_strdup=strdup
_unlink=unlink
_snprintf=snprintf
_vsnprintf=vsnprintf
_write=write
_close=close
Expand Down
2 changes: 1 addition & 1 deletion regamedll/dlls/bot/cs_bot_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,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
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
21 changes: 15 additions & 6 deletions regamedll/dlls/bot/cs_bot_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,14 +578,16 @@ void CCSBotManager::ServerCommand(const char *pcmd)
}
else if (FStrEq(pcmd, "bot_nav_save"))
{
GET_GAME_DIR(buffer);
Q_strcat(buffer, "\\");
Q_strcat(buffer, CBotManager::GetNavMapFilename());
char gd[64]{};
GET_GAME_DIR(gd);

if (SaveNavigationMap(buffer))
CONSOLE_ECHO("Navigation map '%s' saved.\n", buffer);
char filename[MAX_OSPATH];
Q_snprintf(filename, sizeof(filename), "%s\\%s", gd, CBotManager::GetNavMapFilename());

if (SaveNavigationMap(filename))
CONSOLE_ECHO("Navigation map '%s' saved.\n", filename);
else
CONSOLE_ECHO("ERROR: Cannot save navigation map '%s'.\n", buffer);
CONSOLE_ECHO("ERROR: Cannot save navigation map '%s'.\n", filename);
}
else if (FStrEq(pcmd, "bot_nav_load"))
{
Expand Down Expand Up @@ -1211,6 +1213,13 @@ void CCSBotManager::ValidateMapData()
found = true;
isLegacy = false;
}
else if (FClassnameIs(pEntity->pev, "func_escapezone"))
{
m_gameScenario = SCENARIO_ESCAPE;
found = true;
isLegacy = false;
}


if (found)
{
Expand Down
3 changes: 2 additions & 1 deletion regamedll/dlls/bot/cs_bot_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class CCSBotManager: public CBotManager
SCENARIO_DEATHMATCH,
SCENARIO_DEFUSE_BOMB,
SCENARIO_RESCUE_HOSTAGES,
SCENARIO_ESCORT_VIP
SCENARIO_ESCORT_VIP,
SCENARIO_ESCAPE
};

GameScenarioType GetScenario() const
Expand Down
87 changes: 87 additions & 0 deletions regamedll/dlls/bot/states/cs_bot_idle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,93 @@ void IdleState::OnUpdate(CCSBot *me)
}
break;
}
case CCSBotManager::SCENARIO_ESCAPE:
{
if (me->m_iTeam == TERRORIST)
{
// if early in round, pick a random zone, otherwise pick closest zone
const float earlyTime = 20.0f;
const CCSBotManager::Zone *zone = nullptr;

if (TheCSBots()->GetElapsedRoundTime() < earlyTime)
{
// pick random zone
zone = TheCSBots()->GetRandomZone();
}
else
{
// pick closest zone
zone = TheCSBots()->GetClosestZone(me->GetLastKnownArea(), PathCost(me));
}

if (zone)
{
// pick a random spot within the escape zone
const Vector *pos = TheCSBots()->GetRandomPositionInZone(zone);
if (pos)
{
// move to escape zone
// me->SetTask(CCSBot::VIP_ESCAPE);
me->Run();
me->MoveTo(pos);
return;
}
}
}
// CT
else
{
if (me->IsSniper())
{
if (RANDOM_FLOAT(0, 100) <= defenseSniperCampChance)
{
// snipe escape zone(s)
const CCSBotManager::Zone *zone = TheCSBots()->GetRandomZone();
if (zone)
{
CNavArea *area = TheCSBots()->GetRandomAreaInZone(zone);
if (area)
{
me->SetTask(CCSBot::MOVE_TO_SNIPER_SPOT);
me->Hide(area, -1.0, sniperHideRange);
me->SetDisposition(CCSBot::OPPORTUNITY_FIRE);
me->PrintIfWatched("Sniping near escape zone\n");
return;
}
}
}
}

// rogues just hunt, unless they want to snipe
// if the whole team has decided to rush, hunt
if (me->IsRogue() || TheCSBots()->IsDefenseRushing())
break;

// the lower our morale gets, the more we want to camp the escape zone(s)
float guardEscapeZoneChance = -34.0f * me->GetMorale();

if (RANDOM_FLOAT(0.0f, 100.0f) < guardEscapeZoneChance)
{
// guard escape zone(s)
const CCSBotManager::Zone *zone = TheCSBots()->GetRandomZone();
if (zone)
{
CNavArea *area = TheCSBots()->GetRandomAreaInZone(zone);
if (area)
{
// guard the escape zone - stay closer if our morale is low
//me->SetTask(CCSBot::GUARD_VIP_ESCAPE_ZONE);
me->PrintIfWatched("I'm guarding an escape zone\n");

float escapeGuardRange = 750.0f + 250.0f * (me->GetMorale() + 3);
me->Hide(area, -1.0, escapeGuardRange);
me->SetDisposition(CCSBot::OPPORTUNITY_FIRE);
return;
}
}
}
}
}
// deathmatch
default:
{
Expand Down
24 changes: 24 additions & 0 deletions regamedll/dlls/cbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,30 @@ void OnFreeEntPrivateData(edict_t *pEnt)
if (!pEntity)
return;

#ifdef REGAMEDLL_FIXES
// FIXED: Ensure this item will be removed from the owner player's inventory 'm_rgpPlayerItems[]'
// to avoid dangling pointers
CBasePlayerItem *pItem = dynamic_cast<CBasePlayerItem *>(pEntity);
if (pItem)
{
CBasePlayer *pOwner = GET_PRIVATE<CBasePlayer>(pItem->pev->owner);
if (pOwner && pOwner->IsPlayer())
{
if (pOwner->m_pActiveItem == pItem && pItem->IsWeapon())
((CBasePlayerWeapon *)pItem)->RetireWeapon();

if (pOwner->RemovePlayerItem(pItem))
{
// Ammo must be dropped, otherwise grenades cannot be buy or picked up
if (IsGrenadeWeapon(pItem->m_iId) || pItem->m_iId == WEAPON_C4)
pOwner->m_rgAmmo[pItem->PrimaryAmmoIndex()] = 0;

pOwner->pev->weapons &= ~(1 << pItem->m_iId);
}
}
}
#endif

#ifdef REGAMEDLL_API
pEntity->OnDestroy();
#endif
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/cdll_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const int DEFAULT_FOV = 90; // the default field of view
#define PLAYER_PREVENT_DUCK BIT(4)
#define PLAYER_PREVENT_CLIMB BIT(5) // The player can't climb ladder
#define PLAYER_PREVENT_JUMP BIT(6)
#define PLAYER_PREVENT_DDUCK BIT(7)

#define MENU_KEY_1 BIT(0)
#define MENU_KEY_2 BIT(1)
Expand Down
Loading

0 comments on commit 16b24f9

Please sign in to comment.