And here are the async mysql helper functions:
PHP Code:
init_async_mysql()
{
host = getcvar("mysql_host");
user = getcvar("mysql_user");
port = getcvarint("mysql_port");
pass = getcvar("mysql_password");
db = getcvar("mysql_database");
mysql_async_initializer(host, user, pass, db, port, 4);
level.mysql_async = [];
while(true)
{
list = mysql_async_getdone_list();
for(i = 0; i < list.size; i++)
{
result = mysql_async_getresult_and_free(list[i]);
if(!isdefined(result))
continue;
if(result == 0)
result = undefined;
f = level.mysql_async["" + list[i]];
if(isdefined(f))
{
if(isdefined(f.function))
thread [[f.function]](result, f.args);
else if(isdefined(result))
mysql_free_result(result);
f = undefined;
}
level.mysql_async["" + list[i]] = undefined;
}
wait .05;
}
}
add_async_query_nosave(q, function, args)
{
if(getcvarint("show_mysql") == 1)
printf("mysql_query async nosave:" + q + "\n");
id = mysql_async_create_query_nosave(q);
f = spawnstruct();
f.query = q;
f.function = function;
f.args = args;
level.mysql_async["" + id] = f;
}
add_async_query(q, function, args)
{
if(getcvarint("show_mysql") == 1)
printf("mysql_query async:" + q + "\n");
id = mysql_async_create_query(q);
f = spawnstruct();
f.query = q;
f.function = function;
f.args = args;
level.mysql_async["" + id] = f;
}
Yes, it is stored as a string-indexed array as i had trouble with high-int indexed arrays in cod2 in the past.