Skip to content

Commit d0691b8

Browse files
committed
update(src): v1.6.6 back
1 parent 4915afe commit d0691b8

File tree

12 files changed

+482
-399
lines changed

12 files changed

+482
-399
lines changed

CHANGELOG.md

+30
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,36 @@
22

33
Over here will be noted all the update change logs.
44

5+
## v1.6.6 - [Release](https://github.com/swiftly-solution/swiftly/releases/tag/v1.6.6)
6+
7+
### Database
8+
9+
- Add optional argument to skip connecting to `default_connection`
10+
11+
### Crash Reporter
12+
13+
- Add file location of the function from Call Stack
14+
15+
### Utils
16+
17+
- Added: GetPluginsList
18+
19+
### Menus
20+
21+
- Remove screen menus on windows as they crash without a dump
22+
23+
### CCheckTransmitInfo
24+
25+
- Fix self casting
26+
27+
### Events
28+
29+
- Fix event return values
30+
31+
### SDK
32+
33+
- Fix FollowServerRules check not working
34+
535
## v1.6.5 - [Release](https://github.com/swiftly-solution/swiftly/releases/tag/v1.6.5)
636

737
### HTTP

src/core/entrypoint.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ bool OnClientCommand(int playerid, std::string command)
243243
bool response = true;
244244
try
245245
{
246-
response = std::any_cast<bool>(data.GetData<std::any>("event_return"));
246+
response = std::any_cast<bool>(data.GetAnyData("event_return"));
247247
}
248248
catch (std::bad_any_cast& e)
249249
{

src/plugins/manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ EXT_API int swiftly_TriggerEvent(const char* ext_name, const char* evName, void*
214214
{
215215
ClassData data({ { "plugin_name", std::string(ext_name) } }, "Event", nullptr);
216216
auto result = g_pluginManager.ExecuteEvent(ext_name, evName, *(std::vector<std::any>*)args, &data);
217-
*reinterpret_cast<std::any*>(eventReturn) = data.GetData<std::any>("event_return");
217+
*reinterpret_cast<std::any*>(eventReturn) = data.GetAnyData("event_return");
218218

219219
return (int)result;
220220
}

src/scripting/core.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ void SetupScriptingEnvironment(PluginObject plugin, EContext* ctx)
7777
arguments.push_back(context->GetArgumentAsString(i));
7878
function_call += "(" + implode(arguments, ", ") + ")";
7979

80+
if (context->GetPluginContext()->GetKind() == ContextKinds::Lua) {
81+
lua_Debug ar;
82+
lua_State* L = context->GetPluginContext()->GetLuaState();
83+
84+
if (lua_getstack(L, 1, &ar)) {
85+
if (lua_getinfo(L, "Sl", &ar)) {
86+
function_call += string_format(" -> %s:%d", ar.short_src, ar.currentline);
87+
}
88+
}
89+
}
90+
8091
context->temporaryData.push_back(g_callStack.RegisterPluginCallstack(FetchPluginName(context->GetPluginContext()), function_call));
8192
g_ResourceMonitor.StartTime("core", replace(context->GetFunctionKey(), " ", "::"));
8293
});

src/scripting/engine/gameevents.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bool OnClientChat(int playerid, std::string text, bool teamonly)
3232
bool response = true;
3333
try
3434
{
35-
response = std::any_cast<bool>(data.GetData<std::any>("event_return"));
35+
response = std::any_cast<bool>(data.GetAnyData("event_return"));
3636
}
3737
catch (std::bad_any_cast& e)
3838
{
@@ -55,7 +55,7 @@ dyno::ReturnAction Hook_CGameRules_TerminateRound(dyno::CallbackType type, dyno:
5555
bool response = true;
5656
try
5757
{
58-
response = std::any_cast<bool>(data.GetData<std::any>("event_return"));
58+
response = std::any_cast<bool>(data.GetAnyData("event_return"));
5959
}
6060
catch (std::bad_any_cast& e)
6161
{
@@ -81,7 +81,7 @@ dyno::ReturnAction Hook_CEntityIdentity_AcceptInput(dyno::CallbackType type, dyn
8181
bool response = true;
8282
try
8383
{
84-
response = std::any_cast<bool>(data.GetData<std::any>("event_return"));
84+
response = std::any_cast<bool>(data.GetAnyData("event_return"));
8585
}
8686
catch (std::bad_any_cast& e)
8787
{
@@ -123,7 +123,7 @@ dyno::ReturnAction Hook_CBaseEntity_TakeDamage(dyno::CallbackType type, dyno::IH
123123
bool response = true;
124124
try
125125
{
126-
response = std::any_cast<bool>(data.GetData<std::any>("event_return"));
126+
response = std::any_cast<bool>(data.GetAnyData("event_return"));
127127
}
128128
catch (std::bad_any_cast& e)
129129
{

src/scripting/network/database.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@ LoadScriptingComponent(database, [](PluginObject plugin, EContext* ctx) -> void
3636

3737
ADD_CLASS_FUNCTION("Database", "Database", [](FunctionContext* context, ClassData* data) -> void {
3838
std::string connection_name = context->GetArgumentOr<std::string>(0, "default_connection");
39+
bool shouldSkipDefaultConnection = context->GetArgumentOr<bool>(1, false);
40+
3941
auto db = g_dbManager.GetDatabase(connection_name);
4042
if (!db && connection_name != "default_connection") {
4143
PRINTF("Database connection \"%s\" doesn't exists inside the database configurations. Automatically falling back to \"default_connection\".\n", connection_name.c_str());
42-
db = g_dbManager.GetDatabase("default_connection");
44+
if (!shouldSkipDefaultConnection) db = g_dbManager.GetDatabase("default_connection");
4345
}
4446

45-
if (!db->Connect()) {
47+
if (!db) {
48+
PRINTF("An error has occured while trying to connect to database \"%s\":\nError: Invalid connection inside `addons/swiftly/configs/databases.json`\n", connection_name.c_str());
49+
}
50+
else if (!db->Connect()) {
4651
PRINTF("An error has occured while trying to connect to database \"%s\":\nError: %s\n", connection_name.c_str(), db->GetError().c_str());
4752
}
4853

49-
data->SetData("connection_name", connection_name);
5054
data->SetData("db", db);
5155
});
5256

src/scripting/sdk/checktransmit.cpp

+19-12
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,24 @@ LoadScriptingComponent(checktransmit, [](PluginObject plugin, EContext* ctx) ->
1313

1414
ADD_CLASS_FUNCTION("CCheckTransmitInfo", "CCheckTransmitInfo", [](FunctionContext* context, ClassData* data) -> void {
1515
auto classData = context->GetArgumentOr<ClassData*>(0, nullptr);
16-
if(classData) {
17-
if(classData->HasData("transmit_ptr")) {
16+
if (classData) {
17+
if (classData->HasData("class_ptr")) {
1818
data->SetData("transmit_ptr", classData->GetData<void*>("class_ptr"));
19-
} else if(classData->HasData("ptr")) {
19+
}
20+
else if (classData->HasData("ptr")) {
2021
data->SetData("transmit_ptr", classData->GetData<void*>("ptr"));
21-
} else data->SetData("transmit_ptr", (void*)nullptr);
22-
} else {
22+
}
23+
else if (classData->HasData("transmit_ptr")) {
24+
data->SetData("transmit_ptr", classData->GetData<void*>("transmit_ptr"));
25+
}
26+
else data->SetData("transmit_ptr", (void*)nullptr);
27+
}
28+
else {
2329
auto strptr = context->GetArgumentOr<std::string>(0, "");
24-
if(starts_with(strptr, "0x")) {
30+
if (starts_with(strptr, "0x")) {
2531
data->SetData("transmit_ptr", (void*)StringToPtr(strptr));
26-
} else data->SetData("transmit_ptr", (void*)nullptr);
32+
}
33+
else data->SetData("transmit_ptr", (void*)nullptr);
2734
}
2835
});
2936

@@ -32,11 +39,11 @@ LoadScriptingComponent(checktransmit, [](PluginObject plugin, EContext* ctx) ->
3239

3340
for (int i = 0; i < GetMaxGameClients(); i++) {
3441
CEntityInstance* controller = g_pEntitySystem->GetEntityInstance(CEntityIndex(i + 1));
35-
if(!controller) continue;
42+
if (!controller) continue;
3643

3744
CHandle<CEntityInstance> pawnHandle = schema::GetProp<CHandle<CEntityInstance>>(controller, "CCSPlayerController", "m_hPlayerPawn");
3845
if (!pawnHandle) continue;
39-
46+
4047
player_entindex.insert({ i, pawnHandle->m_pEntity->m_EHandle.GetEntryIndex() });
4148
}
4249

@@ -50,7 +57,7 @@ LoadScriptingComponent(checktransmit, [](PluginObject plugin, EContext* ctx) ->
5057
for (int i = 0; i < MAX_EDICTS; i++)
5158
if (m_ptr->m_pTransmitEntity->IsBitSet(i))
5259
entities_list.push_back(i);
53-
60+
5461
context->SetReturn(entities_list);
5562
});
5663

@@ -67,15 +74,15 @@ LoadScriptingComponent(checktransmit, [](PluginObject plugin, EContext* ctx) ->
6774
int entindex = context->GetArgumentOr<int>(0, 0);
6875
CCheckTransmitInfo* m_ptr = (CCheckTransmitInfo*)data->GetData<void*>("transmit_ptr");
6976

70-
if(!m_ptr->m_pTransmitEntity->IsBitSet(entindex))
77+
if (!m_ptr->m_pTransmitEntity->IsBitSet(entindex))
7178
m_ptr->m_pTransmitEntity->Set(entindex);
7279
});
7380

7481
ADD_CLASS_FUNCTION("CCheckTransmitInfo", "RemoveEntityIndex", [](FunctionContext* context, ClassData* data) -> void {
7582
int entindex = context->GetArgumentOr<int>(0, 0);
7683
CCheckTransmitInfo* m_ptr = (CCheckTransmitInfo*)data->GetData<void*>("transmit_ptr");
7784

78-
if(m_ptr->m_pTransmitEntity->IsBitSet(entindex))
85+
if (m_ptr->m_pTransmitEntity->IsBitSet(entindex))
7986
m_ptr->m_pTransmitEntity->Clear(entindex);
8087
});
8188

0 commit comments

Comments
 (0)