From 0f00949058fe1397404fb10de7d1108374fac750 Mon Sep 17 00:00:00 2001 From: JCash Date: Wed, 2 Nov 2022 14:16:30 +0100 Subject: [PATCH] Updated to use dmScript::LuaToJson() --- gpgs/src/gpgs_callback.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/gpgs/src/gpgs_callback.cpp b/gpgs/src/gpgs_callback.cpp index 59f8a62..459bb54 100644 --- a/gpgs/src/gpgs_callback.cpp +++ b/gpgs/src/gpgs_callback.cpp @@ -60,26 +60,7 @@ static void gpgs_invoke_callback(MESSAGE_ID type, const char* json) } else { lua_pushnumber(L, type); - int count_table_elements = 1; - bool is_fail = false; - dmJson::Document doc; - dmJson::Result r = dmJson::Parse(json, &doc); - if (r == dmJson::RESULT_OK && doc.m_NodeCount > 0) { - char error_str_out[128]; - if (dmScript::JsonToLua(L, &doc, 0, error_str_out, sizeof(error_str_out)) < 0) { - dmLogError("Failed converting object JSON to Lua; %s", error_str_out); - is_fail = true; - } - } else { - dmLogError("Failed to parse JSON object(%d): (%s)", r, json); - is_fail = true; - } - dmJson::Free(&doc); - if (is_fail) { - lua_pop(L, 2); - assert(top == lua_gettop(L)); - return; - } + dmScript::JsonToLua(L, json, strlen(json)); // throws lua error if it fails int number_of_arguments = 3; int ret = lua_pcall(L, number_of_arguments, 0, 0);