Skip to content

Commit 028f0b6

Browse files
committed
fix(database): Data reading error
1 parent 409f8ba commit 028f0b6

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/plugins/core/scripting/database.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@ void DatabaseQueryThread()
4444
if (queue.plugin->GetKind() == PluginKind_t::Lua)
4545
{
4646
lua_State* state = ((LuaPlugin*)queue.plugin)->GetState();
47-
std::vector<std::map<std::string, luabridge::LuaRef>> tbl;
48-
49-
for (uint32_t i = 0; i < queryResult.size(); i++)
50-
{
51-
std::map<std::string, luabridge::LuaRef> rowTbl;
52-
53-
for (std::map<const char*, std::any>::iterator it = queryResult[i].begin(); it != queryResult[i].end(); ++it)
54-
rowTbl.insert({ it->first, LuaSerializeData(it->second, state) });
55-
56-
tbl.push_back(rowTbl);
57-
}
5847

5948
std::string error = queue.db->GetError();
6049
if (error == "MySQL server has gone away") {
@@ -68,7 +57,19 @@ void DatabaseQueryThread()
6857
}
6958

7059
luabridge::LuaRef* ref = (luabridge::LuaRef*)queue.callback;
71-
auto ExecuteCallback = [error, ref, state, tbl]() -> void {
60+
auto ExecuteCallback = [&]() -> void {
61+
std::vector<std::map<std::string, luabridge::LuaRef>> tbl;
62+
63+
for (uint32_t i = 0; i < queryResult.size(); i++)
64+
{
65+
std::map<std::string, luabridge::LuaRef> rowTbl;
66+
67+
for (std::map<const char*, std::any>::iterator it = queryResult[i].begin(); it != queryResult[i].end(); ++it)
68+
rowTbl.insert({ it->first, LuaSerializeData(it->second, state) });
69+
70+
tbl.push_back(rowTbl);
71+
}
72+
7273
try
7374
{
7475
if (ref != nullptr) {

src/signatures/Signatures.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ typedef void (*CCSPlayerController_SwitchTeam)(CCSPlayerController* pController,
2626
typedef void* (*UTIL_CreateEntityByName)(const char*, int);
2727
typedef void (*CBaseModelEntity_SetModel)(CBaseModelEntity*, const char*);
2828
typedef void (*CBaseEntity_DispatchSpawn)(CBaseEntity*, void*);
29-
typedef void (*PrecacheResource)(const char*, int64_t);
3029
typedef void (*UTIL_Remove)(CEntityInstance*);
3130
typedef void (*CEntityInstance_AcceptInput)(CEntityInstance*, const char*, CEntityInstance*, CEntityInstance*, variant_t*, int);
3231
typedef void (*CAttributeList_SetOrAddAttributeValueByName)(void*, const char*, float);
3332
typedef void (*CBaseModelEntity_SetBodygroup)(void*, const char*, ...);
3433
typedef void (*GiveNamedItem_t)(CCSPlayer_ItemServices*, const char*, int, int, int, int);
3534
typedef void (*CBasePlayerController_SetPawn)(CBasePlayerController*, CCSPlayerPawn*, bool, bool);
3635
typedef void (*CCSPlayerPawnBase_PostThink)(CCSPlayerPawnBase*);
37-
typedef void (*CBaseEntity_TakeDamageOld)(CBaseEntity*, CTakeDamageInfo*);
3836
typedef void (*CCSPlayer_MovementServices_CheckJumpPre)(CCSPlayer_MovementServices*, void*);
3937
typedef SndOpEventGuid_t(*CBaseEntity_EmitSoundFilter)(IRecipientFilter& filter, CEntityIndex ent, const EmitSound_t& params);
4038

0 commit comments

Comments
 (0)