22#include < mariadb++/result_set.hpp>
33
44using namespace intercept ::client;
5-
5+ extern auto_array<ref<GameDataDBAsyncResult>> asyncWork;
66
77game_data* createGameDataDBResult (param_archive* ar) {
88 auto x = new GameDataDBResult ();
@@ -75,6 +75,24 @@ game_value Result::cmd_bindCallback(uintptr_t, game_value_parameter left, game_v
7575 return {};
7676}
7777
78+ game_value Result::cmd_waitForResult (uintptr_t , game_value_parameter right) {
79+ auto & res = right.get_as <GameDataDBAsyncResult>();
80+
81+ res->data ->res .wait ();
82+
83+ for (int i = 0 ; i < asyncWork.size (); ++i) {
84+ if (asyncWork[i] == res) {
85+ asyncWork.erase (i);
86+ break ;
87+ }
88+ }
89+
90+ auto gd_res = new GameDataDBResult ();
91+ gd_res->res = res->data ->res .get ();
92+ sqf::call (res->data ->callback , { gd_res, res->data ->callbackArgs });
93+ return gd_res;
94+ }
95+
7896void ::Result::initCommands () {
7997
8098 auto dbType = host::register_sqf_type (" DBRES" sv, " databaseResult" sv, " TODO" sv, " databaseResult" sv, createGameDataDBResult);
@@ -89,6 +107,7 @@ void ::Result::initCommands() {
89107 handle_cmd_lastInsertId = client::host::register_sqf_command (" db_resultLastInsertId" , " TODO" , Result::cmd_lastInsertId, game_data_type::SCALAR, GameDataDBResult_typeE);
90108 handle_cmd_toArray = client::host::register_sqf_command (" db_resultToArray" , " TODO" , Result::cmd_toArray, game_data_type::ARRAY, GameDataDBResult_typeE);
91109 handle_cmd_bindCallback = client::host::register_sqf_command (" db_bindCallback" , " TODO" , Result::cmd_bindCallback, game_data_type::NOTHING, GameDataDBAsyncResult_typeE, game_data_type::ARRAY);
110+ handle_cmd_waitForResult = client::host::register_sqf_command (" db_waitForResult" , " TODO" , Result::cmd_waitForResult, GameDataDBResult_typeE, GameDataDBAsyncResult_typeE);
92111
93112
94113}
0 commit comments