Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
id: version
with:
release_branch: master
increment: minor
increment: patch
use_api: true

extensions_build:
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@

Over here will be noted all the update change logs.

## v1.6.1 - [Release](https://github.com/swiftly-solution/swiftly/releases/tag/v1.6.1)

### VGUI

- [+] Fix Memory Leak
- [+] Fix Entity Spawn

### Exports

- [+] Fix Return Value

### Weapon

- [+] Fix CBasePlayerWeapon
- [+] Fix CCSWeaponBase
- [+] Fix CBasePlayerWeaponVData
- [+] Fix CCSWeaponBaseVData

### Core Commands

- [+] sw status
- [+] sw list

### Player

- [+] Fix Buttons

## v1.6.0 - [Release](https://github.com/swiftly-solution/swiftly/releases/tag/v1.6.0)

### Memory
Expand Down
3 changes: 3 additions & 0 deletions src/core/entrypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,11 @@ void SwiftlyS2::AllPluginsLoaded()

std::string currentMap = "None";

void EraseScheduledCEntKeyVals();

void SwiftlyS2::OnLevelInit(char const* pMapName, char const* pMapEntities, char const* pOldLevel, char const* pLandmarkName, bool loadGame, bool background)
{
EraseScheduledCEntKeyVals();
currentMap = pMapName;
g_pluginManager.ExecuteEvent("core", "OnMapLoad", { currentMap }, nullptr);
}
Expand Down
47 changes: 29 additions & 18 deletions src/engine/vgui/screentext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <server/configuration/configuration.h>
#include <sdk/schema.h>
#include <entities/system.h>
#include <public/entity2/entitykeyvalues.h>

std::vector<CEntityKeyValues*> scheduleForDelete;

ScreenText::~ScreenText()
{
Expand All @@ -28,6 +29,8 @@ void ScreenText::Create(Color color, std::string font, int size, bool drawBackgr

CEntityKeyValues* pMenuKV = new CEntityKeyValues();

scheduleForDelete.push_back(pMenuKV);

pMenuKV->SetBool("enabled", true);
pMenuKV->SetFloat("world_units_per_pixel", (0.25 / 1050) * size);
pMenuKV->SetInt("justify_horizontal", 0);
Expand All @@ -38,13 +41,14 @@ void ScreenText::Create(Color color, std::string font, int size, bool drawBackgr
pMenuKV->SetString("font_name", font.c_str());
pMenuKV->SetColor("color", color);

if(drawBackground) {
if (drawBackground) {
pMenuKV->SetBool("draw_background", true);

if(isMenu) {
if (isMenu) {
pMenuKV->SetFloat("background_border_width", 0.2);
pMenuKV->SetFloat("background_border_height", 0.15);
} else {
}
else {
pMenuKV->SetFloat("background_border_width", g_Config.FetchValue<float>("core.vgui.textBackground.paddingX"));
pMenuKV->SetFloat("background_border_height", g_Config.FetchValue<float>("core.vgui.textBackground.paddingY"));
}
Expand All @@ -68,7 +72,7 @@ void ScreenText::SetupViewForPlayer(Player* player)
if (!pViewModel) return;

g_entSystem.AcceptInput(pScreenEntity, "SetParent", pViewModel, nullptr, "!activator", 0);
schema::SetProp<CHandle<CEntityInstance>>(pScreenEntity, "CBaseEntity", "m_hOwnerEntity", ((CEntityInstance*)pViewModel)->GetRefEHandle());
schema::SetProp<CHandle<CEntityInstance>>(pScreenEntity, "CBaseEntity", "m_hOwnerEntity", ((CEntityInstance*)(pViewModel))->GetRefEHandle());
}

void ScreenText::SetText(std::string text)
Expand All @@ -88,31 +92,31 @@ void ScreenText::SetPosition(float posX, float posY)

if (!m_player) return;
if (m_player->IsFakeClient()) return;
if(!pScreenEntity) return;
if (!pScreenEntity) return;

auto pawn = m_player->GetPlayerPawn();
if(!pawn) return;
if (!pawn) return;

if(schema::GetProp<uint32_t>(pawn, "CBaseEntity", "m_lifeState") == 2) {
if (schema::GetProp<uint32_t>(pawn, "CBaseEntity", "m_lifeState") == 2) {
auto controller = m_player->GetController();
if(!controller) return;
if(schema::GetProp<bool>(controller, "CCSPlayerController", "m_bControllingBot")) return;
if (!controller) return;
if (schema::GetProp<bool>(controller, "CCSPlayerController", "m_bControllingBot")) return;

auto observerServices = schema::GetProp<void*>(pawn, "CBasePlayerPawn", "m_pObserverServices");
if(!observerServices) return;
if (!observerServices) return;

CHandle<CEntityInstance> observerTarget = schema::GetProp<CHandle<CEntityInstance>>(observerServices, "CPlayer_ObserverServices", "m_hObserverTarget");
if(!observerTarget) return;
if (!observerTarget) return;

auto observerController = schema::GetProp<CHandle<CEntityInstance>>(observerTarget.Get(), "CCSPlayerPawnBase", "m_hOriginalController");
if(!observerController) return;
if (!observerController) return;

CHandle<CEntityInstance> pawnHandle = schema::GetProp<CHandle<CEntityInstance>>(observerController, "CCSPlayerController", "m_hPlayerPawn");
if(!pawnHandle) return;
if (!pawnHandle) return;
pawn = (void*)(pawnHandle.Get());
}

if(!pawn) return;
if (!pawn) return;

QAngle eyeAngles = schema::GetProp<QAngle>(pawn, "CCSPlayerPawnBase", "m_angEyeAngles");
Vector fwd, right, up;
Expand All @@ -126,13 +130,13 @@ void ScreenText::SetPosition(float posX, float posY)
QAngle ang(0, eyeAngles.y + 270, 90 - eyeAngles.x);

void* bodyComponent = schema::GetProp<void*>(pawn, "CBaseEntity", "m_CBodyComponent");
if(bodyComponent) return;
if (!bodyComponent) return;

void* sceneNode = schema::GetProp<void*>(bodyComponent, "CBodyComponent", "m_pSceneNode");
if(!sceneNode) return;
if (!sceneNode) return;

void* camServices = schema::GetProp<void*>(pawn, "CBasePlayerPawn", "m_pCameraServices");
if(!camServices) return;
if (!camServices) return;

float oldZ = schema::GetProp<float>(camServices, "CPlayer_CameraServices", "m_flOldPlayerViewOffsetZ");

Expand Down Expand Up @@ -190,4 +194,11 @@ bool ScreenText::IsRenderingTo(CHandle<CEntityInstance> renderingTo)
void ScreenText::SetRenderingTo(CEntityInstance* ent)
{
pRenderingTo.Set(ent);
}

void EraseScheduledCEntKeyVals() {
for (auto e : scheduleForDelete) {
delete e;
}
scheduleForDelete.clear();
}
1 change: 1 addition & 0 deletions src/engine/vgui/screentext.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>
#include <server/player/player.h>
#include "ehandle.h"
#include <public/entity2/entitykeyvalues.h>

class ScreenText
{
Expand Down
6 changes: 0 additions & 6 deletions src/entities/listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <public/entity2/entitykeyvalues.h>

CEntityListener g_entityListener;
std::map<void*, void*> entKeyVal;

void CEntityListener::OnEntitySpawned(CEntityInstance* pEntity)
{
Expand Down Expand Up @@ -42,9 +41,4 @@ void CEntityListener::OnEntityDeleted(CEntityInstance* pEntity)
{
ClassData* entity = new ClassData({ { "should_mark_freeable", true }, { "class_name", std::string("CEntityInstance") }, { "class_ptr", (void*)pEntity } }, "SDKClass", nullptr);
g_pluginManager.ExecuteEvent("core", "OnEntityDeleted", { entity }, {});

if (entKeyVal.find(pEntity) != entKeyVal.end()) {
delete (CEntityKeyValues*)entKeyVal[pEntity];
entKeyVal.erase(pEntity);
}
}
4 changes: 0 additions & 4 deletions src/entities/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ typedef void (*UTIL_Remove)(void*);
typedef void* (*UTIL_CreateEntityByName)(const char*, int);
typedef void (*CEntityInstance_AcceptInput)(void*, const char*, void*, void*, variant_t*, int);

extern std::map<void*, void*> entKeyVal;
void* gameRules = nullptr;

CGameEntitySystem* GameEntitySystem()
Expand Down Expand Up @@ -49,9 +48,6 @@ void EntitySystem::StartupServer(const GameSessionConfiguration_t& config, ISour
void EntitySystem::Spawn(void* entity, void* keyvalues)
{
g_GameData.FetchSignature<CBaseEntity_DispatchSpawn>("CBaseEntity_DispatchSpawn")(entity, keyvalues);

if (entKeyVal.find(entity) != entKeyVal.end()) delete (CEntityKeyValues*)entKeyVal[entity];
entKeyVal[entity] = keyvalues;
}

void EntitySystem::Despawn(void* entity)
Expand Down
11 changes: 7 additions & 4 deletions src/scripting/engine/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <sdk/game.h>

extern std::map<std::string, std::string> gameEventsRegister;
EValue SerializeData(std::any data, EContext* state);

typedef IGameEventListener2* (*GetLegacyGameEventListener)(CPlayerSlot slot);

Expand Down Expand Up @@ -59,8 +60,7 @@ LoadScriptingComponent(events, [](PluginObject plugin, EContext* ctx) -> void {
auto event_name = context->GetArgumentOr<std::string>(0, "");
auto event_data = context->GetArgumentOr<std::string>(1, "[]");

auto evObject = MAKE_CLASS_INSTANCE("Event", { { "plugin_name", FetchPluginName(context->GetPluginContext()) } }).cast<ClassData*>();

ClassData* evObject = new ClassData({ { "plugin_name", FetchPluginName(context->GetPluginContext()) }, { "should_mark_freeable", true } }, "Event", nullptr);
std::vector<std::any> returnValues;

returnValues.push_back((int)g_pluginManager.ExecuteEventJSON(FetchPluginName(context->GetPluginContext()), event_name, event_data, evObject));
Expand Down Expand Up @@ -183,11 +183,14 @@ LoadScriptingComponent(events, [](PluginObject plugin, EContext* ctx) -> void {
ADD_CLASS_FUNCTION("Event", "SetReturn", [](FunctionContext* context, ClassData* data) -> void {
if (context->GetArgumentsCount() < 1) return;

data->SetData("event_return", context->GetArgument<std::any>(0));
std::any val = context->GetArgument<std::any>(0);
data->SetData("event_return", val);
});

ADD_CLASS_FUNCTION("Event", "GetReturn", [](FunctionContext* context, ClassData* data) -> void {
if (data->HasData("event_return")) context->SetReturn(data->GetData<std::any>("event_return"));
if (data->HasData("event_return")) {
context->SetReturn(data->GetAnyData("event_return"));
}
});

ADD_CLASS_FUNCTION("Event", "SetNoBroadcast", [](FunctionContext* context, ClassData* data) -> void {
Expand Down
Loading