Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.

Commit d2453cb

Browse files
committed
Update sdk and update crash
1 parent 467a0b5 commit d2453cb

File tree

7 files changed

+70
-58
lines changed

7 files changed

+70
-58
lines changed

sdk

Submodule sdk updated 74 files

src/cs2_sdk/schema.cpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* =============================================================================
33
* CS2Fixes
4-
* Copyright (C) 2023 Source2ZE
4+
* Copyright (C) 2023-2024 Source2ZE
55
* =============================================================================
66
*
77
* This program is free software; you can redistribute it and/or modify it under
@@ -20,13 +20,12 @@
2020
#include "schema.h"
2121

2222
#include "../common.h"
23-
#include "cschemasystem.h"
23+
#include "schemasystem/schemasystem.h"
2424
#include "tier1/utlmap.h"
2525
#include "tier0/memdbgon.h"
2626
#include "plat.h"
2727
#include "entity/cbaseentity.h"
2828

29-
extern CSchemaSystem *g_pSchemaSystem2;
3029
extern CGlobalVars *gpGlobals;
3130

3231
using SchemaKeyValueMap_t = CUtlMap<uint32_t, SchemaKey>;
@@ -35,10 +34,10 @@ using SchemaTableMap_t = CUtlMap<uint32_t, SchemaKeyValueMap_t*>;
3534

3635
static bool IsFieldNetworked(SchemaClassFieldData_t& field)
3736
{
38-
for (int i = 0; i < field.m_metadata_size; i++)
37+
for (int i = 0; i < field.m_nStaticMetadataCount; i++)
3938
{
4039
static auto networkEnabled = hash_32_fnv1a_const("MNetworkEnable");
41-
if (networkEnabled == hash_32_fnv1a_const(field.m_metadata[i].m_name))
40+
if (networkEnabled == hash_32_fnv1a_const(field.m_pStaticMetadata[i].m_pszName))
4241
return true;
4342
}
4443

@@ -47,12 +46,12 @@ static bool IsFieldNetworked(SchemaClassFieldData_t& field)
4746

4847
static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* className, uint32_t classKey)
4948
{
50-
CSchemaSystemTypeScope* pType = g_pSchemaSystem2->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
49+
CSchemaSystemTypeScope* pType = g_pSchemaSystem->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
5150

5251
if (!pType)
5352
return false;
5453

55-
SchemaClassInfoData_t *pClassInfo = pType->FindDeclaredClass(className);
54+
SchemaClassInfoData_t *pClassInfo = pType->FindDeclaredClass(className).Get();
5655

5756
if (!pClassInfo)
5857
{
@@ -63,8 +62,8 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* cla
6362
return false;
6463
}
6564

66-
short fieldsSize = pClassInfo->GetFieldsSize();
67-
SchemaClassFieldData_t* pFields = pClassInfo->GetFields();
65+
short fieldsSize = pClassInfo->m_nFieldCount;
66+
SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;
6867

6968
SchemaKeyValueMap_t *keyValueMap = new SchemaKeyValueMap_t(0, 0, DefLessFunc(uint32_t));
7069
keyValueMap->EnsureCapacity(fieldsSize);
@@ -75,38 +74,38 @@ static bool InitSchemaFieldsForClass(SchemaTableMap_t *tableMap, const char* cla
7574
SchemaClassFieldData_t& field = pFields[i];
7675

7776
#ifdef _DEBUG
78-
Message("%s::%s found at -> 0x%X - %llx\n", className, field.m_name, field.m_single_inheritance_offset, &field);
77+
Message("%s::%s found at -> 0x%X - %llx\n", className, field.m_pszName, field.m_nSingleInheritanceOffset, &field);
7978
#endif
8079

81-
keyValueMap->Insert(hash_32_fnv1a_const(field.m_name), {field.m_single_inheritance_offset, IsFieldNetworked(field)});
80+
keyValueMap->Insert(hash_32_fnv1a_const(field.m_pszName), {field.m_nSingleInheritanceOffset, IsFieldNetworked(field)});
8281
}
8382

8483
return true;
8584
}
8685

8786
int16_t schema::FindChainOffset(const char* className)
8887
{
89-
CSchemaSystemTypeScope* pType = g_pSchemaSystem2->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
88+
CSchemaSystemTypeScope* pType = g_pSchemaSystem->FindTypeScopeForModule(MODULE_PREFIX "server" MODULE_EXT);
9089

9190
if (!pType)
9291
return false;
9392

94-
SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass(className);
93+
SchemaClassInfoData_t* pClassInfo = pType->FindDeclaredClass(className).Get();
9594

9695
do
9796
{
98-
SchemaClassFieldData_t* pFields = pClassInfo->GetFields();
99-
short fieldsSize = pClassInfo->GetFieldsSize();
97+
SchemaClassFieldData_t* pFields = pClassInfo->m_pFields;
98+
short fieldsSize = pClassInfo->m_nFieldCount;
10099
for (int i = 0; i < fieldsSize; ++i)
101100
{
102101
SchemaClassFieldData_t& field = pFields[i];
103102

104-
if (V_strcmp(field.m_name, "__m_pChainEntity") == 0)
103+
if (V_strcmp(field.m_pszName, "__m_pChainEntity") == 0)
105104
{
106-
return field.m_single_inheritance_offset;
105+
return field.m_nSingleInheritanceOffset;
107106
}
108107
}
109-
} while ((pClassInfo = pClassInfo->GetParent()) != nullptr);
108+
} while ((pClassInfo = pClassInfo->m_pBaseClasses ? pClassInfo->m_pBaseClasses->m_pClass : nullptr) != nullptr);
110109

111110
return 0;
112111
}
@@ -140,4 +139,4 @@ void SetStateChanged(Z_CBaseEntity* pEntity, int offset)
140139

141140
pEntity->m_lastNetworkChange = gpGlobals->curtime;
142141
pEntity->m_isSteadyState().ClearAll();
143-
};
142+
};

src/cs2_sdk/schema.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* =============================================================================
33
* CS2Fixes
4-
* Copyright (C) 2023 Source2ZE
4+
* Copyright (C) 2023-2024 Source2ZE
55
* =============================================================================
66
*
77
* This program is free software; you can redistribute it and/or modify it under
@@ -19,8 +19,6 @@
1919

2020
#pragma once
2121

22-
#include "stdint.h"
23-
2422
#ifdef _WIN32
2523
#pragma warning(push)
2624
#pragma warning(disable : 4005)

src/cs2fixes.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "icvar.h"
3434
#include "interface.h"
3535
#include "tier0/dbg.h"
36-
#include "cschemasystem.h"
36+
#include "schemasystem/schemasystem.h"
3737
#include "plat.h"
3838
#include "entitysystem.h"
3939
#include "engine/igameeventsystem.h"
@@ -53,9 +53,6 @@
5353
#include "entity/ccsplayercontroller.h"
5454
#include "entitylistener.h"
5555

56-
#define VPROF_ENABLED
57-
#include "tier0/vprof.h"
58-
5956
#include "tier0/memdbgon.h"
6057

6158
extern CUtlVector <CCSPlayerController*> coaches;
@@ -120,7 +117,6 @@ IGameEventManager2 *g_gameEventManager = nullptr;
120117
INetworkGameServer *g_pNetworkGameServer = nullptr;
121118
CGameEntitySystem *g_pEntitySystem = nullptr;
122119
CEntityListener *g_pEntityListener = nullptr;
123-
CSchemaSystem *g_pSchemaSystem2 = nullptr;
124120
CGlobalVars *gpGlobals = nullptr;
125121
CPlayerManager *g_playerManager = nullptr;
126122
IVEngineServer2 *g_pEngineServer2 = nullptr;
@@ -141,9 +137,9 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool
141137
PLUGIN_SAVEVARS();
142138

143139
GET_V_IFACE_CURRENT(GetEngineFactory, g_pEngineServer2, IVEngineServer2, SOURCE2ENGINETOSERVER_INTERFACE_VERSION);
144-
GET_V_IFACE_CURRENT(GetEngineFactory, g_pGameResourceServiceServer, IGameResourceServiceServer, GAMERESOURCESERVICESERVER_INTERFACE_VERSION);
140+
GET_V_IFACE_CURRENT(GetEngineFactory, g_pGameResourceServiceServer, IGameResourceService, GAMERESOURCESERVICESERVER_INTERFACE_VERSION);
145141
GET_V_IFACE_CURRENT(GetEngineFactory, g_pCVar, ICvar, CVAR_INTERFACE_VERSION);
146-
GET_V_IFACE_CURRENT(GetEngineFactory, g_pSchemaSystem2, CSchemaSystem, SCHEMASYSTEM_INTERFACE_VERSION);
142+
GET_V_IFACE_CURRENT(GetEngineFactory, g_pSchemaSystem, ISchemaSystem, SCHEMASYSTEM_INTERFACE_VERSION);
147143
GET_V_IFACE_ANY(GetServerFactory, g_pSource2Server, ISource2Server, SOURCE2SERVER_INTERFACE_VERSION);
148144
GET_V_IFACE_ANY(GetServerFactory, g_pSource2ServerConfig, ISource2ServerConfig, SOURCE2SERVERCONFIG_INTERFACE_VERSION);
149145
GET_V_IFACE_ANY(GetServerFactory, g_pSource2GameEntities, ISource2GameEntities, SOURCE2GAMEENTITIES_INTERFACE_VERSION);
@@ -404,7 +400,7 @@ void CS2Fixes::Hook_StartupServer(const GameSessionConfiguration_t& config, ISou
404400

405401
// Run map cfg (if present)
406402
/*char cmd[MAX_PATH];
407-
V_snprintf(cmd, sizeof(cmd), "exec cs2fixes/maps/%s", gpGlobals->mapname);
403+
V_snprintf(cmd, sizeof(cmd), "exec cs2fixes/maps/%s", gpGlobals->mapname.ToCStr());
408404
g_pEngineServer2->ServerCommand(cmd);
409405
*/
410406

@@ -536,7 +532,7 @@ void CS2Fixes::Hook_ClientDisconnect( CPlayerSlot slot, ENetworkDisconnectionRea
536532

537533
void CS2Fixes::Hook_GameFrame( bool simulating, bool bFirstTick, bool bLastTick )
538534
{
539-
VPROF_ENTER_SCOPE(__FUNCTION__);
535+
540536
/**
541537
* simulating:
542538
* ***********
@@ -577,7 +573,6 @@ void CS2Fixes::Hook_GameFrame( bool simulating, bool bFirstTick, bool bLastTick
577573
}
578574
}
579575

580-
VPROF_EXIT_SCOPE();
581576
}
582577

583578
// Potentially might not work

src/detours.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
#include "gameconfig.h"
3939

4040

41-
#define VPROF_ENABLED
42-
#include "tier0/vprof.h"
43-
4441
#include "tier0/memdbgon.h"
4542

4643
extern CGlobalVars *gpGlobals;

src/playermanager.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
#include "ctimer.h"
2828
#include "ctime"
2929

30-
#define VPROF_ENABLED
31-
#include "tier0/vprof.h"
32-
3330
#include "tier0/memdbgon.h"
3431

3532

src/recipientfilters.h

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* =============================================================================
33
* CS2Fixes
4-
* Copyright (C) 2023 Source2ZE
4+
* Copyright (C) 2023-2024 Source2ZE
55
* =============================================================================
66
*
77
* This program is free software; you can redistribute it and/or modify it under
@@ -19,35 +19,41 @@
1919

2020
#pragma once
2121
#include "irecipientfilter.h"
22+
#include "playermanager.h"
2223

24+
// Simple filter for when only 1 recipient is needed
2325
class CSingleRecipientFilter : public IRecipientFilter
2426
{
2527
public:
26-
CSingleRecipientFilter(int iRecipient, bool bReliable = true, bool bInitMessage = false) :
27-
m_iRecipient(iRecipient), m_bReliable(bReliable), m_bInitMessage(bInitMessage) {}
28+
CSingleRecipientFilter(CPlayerSlot iRecipient, NetChannelBufType_t nBufType = BUF_RELIABLE, bool bInitMessage = false) :
29+
m_iRecipient(iRecipient), m_nBufType(nBufType), m_bInitMessage(bInitMessage) {}
2830

2931
~CSingleRecipientFilter() override {}
3032

31-
bool IsReliable(void) const override { return m_bReliable; }
32-
33+
NetChannelBufType_t GetNetworkBufType(void) const override { return m_nBufType; }
3334
bool IsInitMessage(void) const override { return m_bInitMessage; }
34-
3535
int GetRecipientCount(void) const override { return 1; }
36-
37-
CPlayerSlot GetRecipientIndex(int slot) const override { return CPlayerSlot(m_iRecipient); }
36+
CPlayerSlot GetRecipientIndex(int slot) const override { return m_iRecipient; }
3837

3938
private:
40-
bool m_bReliable;
39+
CPlayerSlot m_iRecipient;
40+
NetChannelBufType_t m_nBufType;
4141
bool m_bInitMessage;
42-
int m_iRecipient;
4342
};
4443

45-
class CCopyRecipientFilter : public IRecipientFilter
44+
45+
class CRecipientFilter : public IRecipientFilter
4646
{
4747
public:
48-
CCopyRecipientFilter(IRecipientFilter *source, int iExcept)
48+
CRecipientFilter()
4949
{
50-
m_bReliable = source->IsReliable();
50+
m_nBufType = BUF_RELIABLE;
51+
m_bInitMessage = false;
52+
}
53+
54+
CRecipientFilter(IRecipientFilter *source, int iExcept = -1)
55+
{
56+
m_nBufType = source->GetNetworkBufType();
5157
m_bInitMessage = source->IsInitMessage();
5258
m_Recipients.RemoveAll();
5359

@@ -58,12 +64,10 @@ class CCopyRecipientFilter : public IRecipientFilter
5864
}
5965
}
6066

61-
~CCopyRecipientFilter() override {}
62-
63-
bool IsReliable(void) const override { return m_bReliable; }
67+
~CRecipientFilter() override {}
6468

69+
NetChannelBufType_t GetNetworkBufType(void) const override { return m_nBufType; }
6570
bool IsInitMessage(void) const override { return m_bInitMessage; }
66-
6771
int GetRecipientCount(void) const override { return m_Recipients.Count(); }
6872

6973
CPlayerSlot GetRecipientIndex(int slot) const override
@@ -74,8 +78,30 @@ class CCopyRecipientFilter : public IRecipientFilter
7478
return m_Recipients[slot];
7579
}
7680

81+
void AddAllPlayers(void)
82+
{
83+
m_Recipients.RemoveAll();
84+
85+
for (int i = 0; i < MAXPLAYERS; i++)
86+
{
87+
if (!g_playerManager->GetPlayer(i))
88+
continue;
89+
90+
AddRecipient(i);
91+
}
92+
}
93+
94+
void AddRecipient(CPlayerSlot slot)
95+
{
96+
// Don't add if it already exists
97+
if (m_Recipients.Find(slot) != m_Recipients.InvalidIndex())
98+
return;
99+
100+
m_Recipients.AddToTail(slot);
101+
}
102+
77103
private:
78-
bool m_bReliable;
104+
NetChannelBufType_t m_nBufType;
79105
bool m_bInitMessage;
80-
CUtlVectorFixed<CPlayerSlot, 64> m_Recipients;
106+
CUtlVectorFixed<CPlayerSlot, MAXPLAYERS> m_Recipients;
81107
};

0 commit comments

Comments
 (0)