Skip to content

Commit e94ca6d

Browse files
authored
Merge pull request #35 from swiftly-solution/rewrite
Linux Depots & GetCCSGameRules Fix
2 parents e6ffcd5 + ab277a9 commit e94ca6d

File tree

9 files changed

+338
-295
lines changed

9 files changed

+338
-295
lines changed

.github/workflows/builder.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,23 @@ jobs:
6565
uses: actions/upload-artifact@v4
6666
with:
6767
name: Swiftly Plugin Windows
68+
path: ${{ github.workspace }}/swiftly/build/package
69+
70+
- name: Creating Swiftly Depot - Linux
71+
if: matrix.os == 'Linux'
72+
working-directory: swiftly
73+
run: |
74+
cd build
75+
curl https://api.github.com/repos/swiftly-solution/swiftly/releases/latest | grep "Swiftly.Plugin.Linux.zip" | cut -d : -f 2,3 | tr -d \" | tail -1 | wget -qi -
76+
unzip Swiftly.Plugin.Linux.zip
77+
mkdir release
78+
mv addons release
79+
fdupes -r --delete --noprompt package release
80+
find package -empty -type d -delete
81+
82+
- name: Upload Swiftly Depot - Linux
83+
if: matrix.os == 'Linux'
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: Swiftly Plugin Depot Linux
6887
path: ${{ github.workspace }}/swiftly/build/package

plugin_files/bin/scripting/utils.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,4 @@ string.split = function(str, split)
121121
table.insert(splitted, split)
122122
end
123123
return splitted
124-
end
125-
126-
function CCSGameRules()
127-
local entities = FindEntitiesByClassname("cs_gamerules")
128-
if #entities <= 0 then return nil end
129-
local rulesProxy = entities[1]
130-
return CCSGameRulesProxy(rulesProxy:ToPtr()).GameRules
131124
end

src/plugins/core/scripting.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class GCBasePlayerWeapon;
2828
class GCCSWeaponBase;
2929
class GCBasePlayerWeaponVData;
3030
class GCCSWeaponBaseVData;
31+
class GCCSGameRules;
3132

3233
//////////////////////////////////////////////////////////////
3334
///////////////// Entity IO //////////////
@@ -689,5 +690,6 @@ GCEntityInstance *CreateEntityByName(const char *name);
689690
bool scripting_IsWindows();
690691
bool scripting_IsLinux();
691692
std::string scripting_GetOS();
693+
GCCSGameRules *scripting_GetCCSGameRules();
692694

693695
#endif

src/plugins/core/scripting/generated/GClasses1.cpp

Lines changed: 151 additions & 151 deletions
Large diffs are not rendered by default.

src/plugins/core/scripting/generated/GClasses2.cpp

Lines changed: 121 additions & 121 deletions
Large diffs are not rendered by default.

src/plugins/core/scripting/generated/GClasses3.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4189,7 +4189,7 @@ void GVPhysXAggregateData_t::SetJoints(std::vector<GVPhysXJoint_t> value) {
41894189
SetSchemaValueCUtlVector<GVPhysXJoint_t>(m_ptr, "VPhysXAggregateData_t", "m_joints", true, value);
41904190
}
41914191
GPhysFeModelDesc_t GVPhysXAggregateData_t::GetFeModel() const {
4192-
GPhysFeModelDesc_t value(*GetSchemaValuePtr<void*>(m_ptr, "VPhysXAggregateData_t", "m_pFeModel"));
4192+
GPhysFeModelDesc_t value(GetSchemaPtr(m_ptr, "VPhysXAggregateData_t", "m_pFeModel"));
41934193
return value;
41944194
}
41954195
void GVPhysXAggregateData_t::SetFeModel(GPhysFeModelDesc_t value) {
@@ -18051,7 +18051,7 @@ void GCEntityComponentHelper::SetFlags(uint32_t value) {
1805118051
SetSchemaValue(m_ptr, "CEntityComponentHelper", "m_flags", false, value);
1805218052
}
1805318053
GEntComponentInfo_t GCEntityComponentHelper::GetInfo() const {
18054-
GEntComponentInfo_t value(*GetSchemaValuePtr<void*>(m_ptr, "CEntityComponentHelper", "m_pInfo"));
18054+
GEntComponentInfo_t value(GetSchemaPtr(m_ptr, "CEntityComponentHelper", "m_pInfo"));
1805518055
return value;
1805618056
}
1805718057
void GCEntityComponentHelper::SetInfo(GEntComponentInfo_t value) {
@@ -18064,7 +18064,7 @@ void GCEntityComponentHelper::SetPriority(int32_t value) {
1806418064
SetSchemaValue(m_ptr, "CEntityComponentHelper", "m_nPriority", false, value);
1806518065
}
1806618066
GCEntityComponentHelper GCEntityComponentHelper::GetNext() const {
18067-
GCEntityComponentHelper value(*GetSchemaValuePtr<void*>(m_ptr, "CEntityComponentHelper", "m_pNext"));
18067+
GCEntityComponentHelper value(GetSchemaPtr(m_ptr, "CEntityComponentHelper", "m_pNext"));
1806818068
return value;
1806918069
}
1807018070
void GCEntityComponentHelper::SetNext(GCEntityComponentHelper value) {
@@ -19026,7 +19026,7 @@ void GPermModelData_t::SetBoneFlexDrivers(std::vector<GModelBoneFlexDriver_t> va
1902619026
SetSchemaValueCUtlVector<GModelBoneFlexDriver_t>(m_ptr, "PermModelData_t", "m_boneFlexDrivers", true, value);
1902719027
}
1902819028
GCModelConfigList GPermModelData_t::GetModelConfigList() const {
19029-
GCModelConfigList value(*GetSchemaValuePtr<void*>(m_ptr, "PermModelData_t", "m_pModelConfigList"));
19029+
GCModelConfigList value(GetSchemaPtr(m_ptr, "PermModelData_t", "m_pModelConfigList"));
1903019030
return value;
1903119031
}
1903219032
void GPermModelData_t::SetModelConfigList(GCModelConfigList value) {

src/plugins/core/scripting/generated/GClasses4.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ void GRnHull_t::SetFlags(uint32_t value) {
11961196
SetSchemaValue(m_ptr, "RnHull_t", "m_nFlags", true, value);
11971197
}
11981198
GCRegionSVM GRnHull_t::GetRegionSVM() const {
1199-
GCRegionSVM value(*GetSchemaValuePtr<void*>(m_ptr, "RnHull_t", "m_pRegionSVM"));
1199+
GCRegionSVM value(GetSchemaPtr(m_ptr, "RnHull_t", "m_pRegionSVM"));
12001200
return value;
12011201
}
12021202
void GRnHull_t::SetRegionSVM(GCRegionSVM value) {
@@ -10694,14 +10694,14 @@ void GCDecalInfo::SetBoundingRadiusSqr(float value) {
1069410694
SetSchemaValue(m_ptr, "CDecalInfo", "m_flBoundingRadiusSqr", false, value);
1069510695
}
1069610696
GCDecalInfo GCDecalInfo::GetNext() const {
10697-
GCDecalInfo value(*GetSchemaValuePtr<void*>(m_ptr, "CDecalInfo", "m_pNext"));
10697+
GCDecalInfo value(GetSchemaPtr(m_ptr, "CDecalInfo", "m_pNext"));
1069810698
return value;
1069910699
}
1070010700
void GCDecalInfo::SetNext(GCDecalInfo value) {
1070110701
SetSchemaValue(m_ptr, "CDecalInfo","m_pNext", false, (char*)value.GetPtr());
1070210702
}
1070310703
GCDecalInfo GCDecalInfo::GetPrev() const {
10704-
GCDecalInfo value(*GetSchemaValuePtr<void*>(m_ptr, "CDecalInfo", "m_pPrev"));
10704+
GCDecalInfo value(GetSchemaPtr(m_ptr, "CDecalInfo", "m_pPrev"));
1070510705
return value;
1070610706
}
1070710707
void GCDecalInfo::SetPrev(GCDecalInfo value) {
@@ -12224,21 +12224,21 @@ GCNewParticleEffect::GCNewParticleEffect(void *ptr) {
1222412224
m_ptr = ptr;
1222512225
}
1222612226
GCNewParticleEffect GCNewParticleEffect::GetNext() const {
12227-
GCNewParticleEffect value(*GetSchemaValuePtr<void*>(m_ptr, "CNewParticleEffect", "m_pNext"));
12227+
GCNewParticleEffect value(GetSchemaPtr(m_ptr, "CNewParticleEffect", "m_pNext"));
1222812228
return value;
1222912229
}
1223012230
void GCNewParticleEffect::SetNext(GCNewParticleEffect value) {
1223112231
SetSchemaValue(m_ptr, "CNewParticleEffect","m_pNext", false, (char*)value.GetPtr());
1223212232
}
1223312233
GCNewParticleEffect GCNewParticleEffect::GetPrev() const {
12234-
GCNewParticleEffect value(*GetSchemaValuePtr<void*>(m_ptr, "CNewParticleEffect", "m_pPrev"));
12234+
GCNewParticleEffect value(GetSchemaPtr(m_ptr, "CNewParticleEffect", "m_pPrev"));
1223512235
return value;
1223612236
}
1223712237
void GCNewParticleEffect::SetPrev(GCNewParticleEffect value) {
1223812238
SetSchemaValue(m_ptr, "CNewParticleEffect","m_pPrev", false, (char*)value.GetPtr());
1223912239
}
1224012240
GIParticleCollection GCNewParticleEffect::GetParticles() const {
12241-
GIParticleCollection value(*GetSchemaValuePtr<void*>(m_ptr, "CNewParticleEffect", "m_pParticles"));
12241+
GIParticleCollection value(GetSchemaPtr(m_ptr, "CNewParticleEffect", "m_pParticles"));
1224212242
return value;
1224312243
}
1224412244
void GCNewParticleEffect::SetParticles(GIParticleCollection value) {
@@ -12263,14 +12263,14 @@ void GCNewParticleEffect::SetScale(float value) {
1226312263
SetSchemaValue(m_ptr, "CNewParticleEffect", "m_flScale", false, value);
1226412264
}
1226512265
GPARTICLE_EHANDLE__ GCNewParticleEffect::GetOwner() const {
12266-
GPARTICLE_EHANDLE__ value(*GetSchemaValuePtr<void*>(m_ptr, "CNewParticleEffect", "m_hOwner"));
12266+
GPARTICLE_EHANDLE__ value(GetSchemaPtr(m_ptr, "CNewParticleEffect", "m_hOwner"));
1226712267
return value;
1226812268
}
1226912269
void GCNewParticleEffect::SetOwner(GPARTICLE_EHANDLE__ value) {
1227012270
SetSchemaValue(m_ptr, "CNewParticleEffect","m_hOwner", false, (char*)value.GetPtr());
1227112271
}
1227212272
GCParticleProperty GCNewParticleEffect::GetOwningParticleProperty() const {
12273-
GCParticleProperty value(*GetSchemaValuePtr<void*>(m_ptr, "CNewParticleEffect", "m_pOwningParticleProperty"));
12273+
GCParticleProperty value(GetSchemaPtr(m_ptr, "CNewParticleEffect", "m_pOwningParticleProperty"));
1227412274
return value;
1227512275
}
1227612276
void GCNewParticleEffect::SetOwningParticleProperty(GCParticleProperty value) {
@@ -12837,7 +12837,7 @@ void GCastSphereSATParams_t::SetScale(float value) {
1283712837
SetSchemaValue(m_ptr, "CastSphereSATParams_t", "m_flScale", true, value);
1283812838
}
1283912839
GRnHull_t GCastSphereSATParams_t::GetHull() const {
12840-
GRnHull_t value(*GetSchemaValuePtr<void*>(m_ptr, "CastSphereSATParams_t", "m_pHull"));
12840+
GRnHull_t value(GetSchemaPtr(m_ptr, "CastSphereSATParams_t", "m_pHull"));
1284112841
return value;
1284212842
}
1284312843
void GCastSphereSATParams_t::SetHull(GRnHull_t value) {
@@ -14809,7 +14809,7 @@ void GEntComponentInfo_t::SetFlags(uint32_t value) {
1480914809
SetSchemaValue(m_ptr, "EntComponentInfo_t", "m_nFlags", true, value);
1481014810
}
1481114811
GCEntityComponentHelper GEntComponentInfo_t::GetBaseClassComponentHelper() const {
14812-
GCEntityComponentHelper value(*GetSchemaValuePtr<void*>(m_ptr, "EntComponentInfo_t", "m_pBaseClassComponentHelper"));
14812+
GCEntityComponentHelper value(GetSchemaPtr(m_ptr, "EntComponentInfo_t", "m_pBaseClassComponentHelper"));
1481314813
return value;
1481414814
}
1481514815
void GEntComponentInfo_t::SetBaseClassComponentHelper(GCEntityComponentHelper value) {
@@ -15011,7 +15011,7 @@ void GCRenderMesh::SetMeshDeformParams(GDynamicMeshDeformParams_t value) {
1501115011
PLUGIN_PRINT("Schema SDK", "Setting a value for 'MeshDeformParams' is not possible.\n");
1501215012
}
1501315013
GCRenderGroom GCRenderMesh::GetGroomData() const {
15014-
GCRenderGroom value(*GetSchemaValuePtr<void*>(m_ptr, "CRenderMesh", "m_pGroomData"));
15014+
GCRenderGroom value(GetSchemaPtr(m_ptr, "CRenderMesh", "m_pGroomData"));
1501515015
return value;
1501615016
}
1501715017
void GCRenderMesh::SetGroomData(GCRenderGroom value) {

src/plugins/core/scripting/utils.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
#include "../scripting.h"
2+
#include "../../../sdk/entity/CGameRules.h"
3+
#include "../../../hooks/FuncHook.h"
4+
#include "generated/classes.h"
5+
6+
void Hook_CGameRules_Constructor(CGameRules *pThis);
7+
CCSGameRules *gameRules = nullptr;
8+
GCCSGameRules *gameRulesPtr = nullptr;
9+
10+
FuncHook<decltype(Hook_CGameRules_Constructor)> CGameRules_ConstructorT(Hook_CGameRules_Constructor, "CGameRules_Constructor");
11+
12+
void Hook_CGameRules_Constructor(CGameRules *pThis)
13+
{
14+
gameRules = (CCSGameRules *)pThis;
15+
CGameRules_ConstructorT(pThis);
16+
}
217

318
bool scripting_IsWindows()
419
{
@@ -13,4 +28,17 @@ bool scripting_IsLinux()
1328
std::string scripting_GetOS()
1429
{
1530
return WIN_LINUX("Windows", "Linux");
31+
}
32+
33+
GCCSGameRules *scripting_GetCCSGameRules()
34+
{
35+
if (!gameRulesPtr)
36+
gameRulesPtr = new GCCSGameRules((void *)gameRules);
37+
else if (gameRulesPtr->GetPtr() != (void *)gameRules)
38+
{
39+
delete gameRulesPtr;
40+
gameRulesPtr = new GCCSGameRules((void *)gameRules);
41+
}
42+
43+
return gameRulesPtr;
1644
}

src/plugins/lua/scripting/utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ void SetupLuaUtils(LuaPlugin *plugin, lua_State *state)
1313
Plugin* plugin = g_pluginManager->FetchPlugin(plugin_name);
1414
if(!plugin) return (int)PluginState_t::Stopped;
1515

16-
return (int)plugin->GetPluginState(); });
16+
return (int)plugin->GetPluginState(); })
17+
.addFunction("GetCCSGameRules", scripting_GetCCSGameRules);
1718
}

0 commit comments

Comments
 (0)