* remove extra fields from Lua account objects to exclude additional sql query.
* verious changes
This commit is contained in:
parent
5008da5b3d
commit
434ec4758a
6 changed files with 11 additions and 13 deletions
|
@ -45,8 +45,8 @@ function handle_command(account, text)
|
||||||
for cmd,func in pairs(cmdlist) do
|
for cmd,func in pairs(cmdlist) do
|
||||||
if string.starts(text, cmd) then
|
if string.starts(text, cmd) then
|
||||||
|
|
||||||
-- check if command group is in account.commandgroups
|
-- check if command group is in account commandgroups
|
||||||
if math_and(account.commandgroups, cg) == 0 then
|
if math_and(account_get_auth_command_groups(account.name), cg) == 0 then
|
||||||
api.message_send_text(account.name, message_type_error, account.name, localize(account.name, "This command is reserved for admins."))
|
api.message_send_text(account.name, message_type_error, account.name, localize(account.name, "This command is reserved for admins."))
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
|
@ -607,8 +607,6 @@ namespace pvpgn
|
||||||
// log command
|
// log command
|
||||||
if (t_account * account = conn_get_account(c))
|
if (t_account * account = conn_get_account(c))
|
||||||
userlog_append(account, text);
|
userlog_append(account, text);
|
||||||
|
|
||||||
// TODO: modify all commands to return "0" only if success, and "-1" if not
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@ namespace pvpgn
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
ERROR2("Can't format translation string \"%s\" (%s)", fmt, e.what());
|
WARN2("Can't format translation string \"%s\" (%s)", fmt, e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|
|
@ -220,7 +220,8 @@ namespace pvpgn
|
||||||
switch ((t_attr_type)attrtype)
|
switch ((t_attr_type)attrtype)
|
||||||
{
|
{
|
||||||
case attr_type_str:
|
case attr_type_str:
|
||||||
attrvalue = account_get_strattr(account, attrkey);
|
if (const char * val = account_get_strattr(account, attrkey))
|
||||||
|
attrvalue = val;
|
||||||
break;
|
break;
|
||||||
case attr_type_num:
|
case attr_type_num:
|
||||||
attrvalue = std_to_string(account_get_numattr(account, attrkey));
|
attrvalue = std_to_string(account_get_numattr(account, attrkey));
|
||||||
|
@ -229,7 +230,8 @@ namespace pvpgn
|
||||||
attrvalue = account_get_boolattr(account, attrkey) == 0 ? "false" : "true";
|
attrvalue = account_get_boolattr(account, attrkey) == 0 ? "false" : "true";
|
||||||
break;
|
break;
|
||||||
case attr_type_raw:
|
case attr_type_raw:
|
||||||
attrvalue = account_get_rawattr(account, attrkey);
|
if (const char * val = account_get_rawattr(account, attrkey))
|
||||||
|
attrvalue = val;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,7 +522,7 @@ namespace pvpgn
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get usernames online. If allaccounts = true then return all server users */
|
/* Get usernames online. If allaccounts = true then return all accounts that were used by the server since start */
|
||||||
extern int __server_get_users(lua_State* L)
|
extern int __server_get_users(lua_State* L)
|
||||||
{
|
{
|
||||||
bool allaccounts = false;
|
bool allaccounts = false;
|
||||||
|
|
|
@ -220,6 +220,7 @@ namespace pvpgn
|
||||||
config.update("version_exeinfo_maxdiff", prefs_get_version_exeinfo_maxdiff());
|
config.update("version_exeinfo_maxdiff", prefs_get_version_exeinfo_maxdiff());
|
||||||
config.update("usersync", prefs_get_user_sync_timer());
|
config.update("usersync", prefs_get_user_sync_timer());
|
||||||
config.update("userflush", prefs_get_user_flush_timer());
|
config.update("userflush", prefs_get_user_flush_timer());
|
||||||
|
config.update("userflush_connected", prefs_get_user_flush_connected());
|
||||||
config.update("userstep", prefs_get_user_step());
|
config.update("userstep", prefs_get_user_step());
|
||||||
config.update("latency", prefs_get_latency());
|
config.update("latency", prefs_get_latency());
|
||||||
config.update("nullmsg", prefs_get_nullmsg());
|
config.update("nullmsg", prefs_get_nullmsg());
|
||||||
|
|
|
@ -95,13 +95,10 @@ namespace pvpgn
|
||||||
if (!account)
|
if (!account)
|
||||||
return o_account;
|
return o_account;
|
||||||
|
|
||||||
|
// DO NOT ADD FIELDS FROM A DATABASE HERE - IT WILL CAUSE WASTE SQL QUERIES WHEN ITERATE ALL CONNECTIONS
|
||||||
|
|
||||||
o_account["id"] = std_to_string(account_get_uid(account));
|
o_account["id"] = std_to_string(account_get_uid(account));
|
||||||
o_account["name"] = account_get_name(account);
|
o_account["name"] = account_get_name(account);
|
||||||
if (const char * email = account_get_email(account)) // email can be empty
|
|
||||||
o_account["email"] = email;
|
|
||||||
o_account["commandgroups"] = std_to_string(account_get_command_groups(account));
|
|
||||||
o_account["locked"] = account_get_auth_lock(account) ? "true" : "false";
|
|
||||||
o_account["muted"] = account_get_auth_mute(account) ? "true" : "false";
|
|
||||||
|
|
||||||
o_account["online"] = "false"; // set init as offline
|
o_account["online"] = "false"; // set init as offline
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue