예제 #1
0
extern unsigned int account_get_normal_disconnects(t_account * account, char const * clienttag)
{
    char key[256];
    
    if (!clienttag || strlen(clienttag)!=4)
    {
	eventlog(eventlog_level_error,"account_get_normal_disconnects","got bad clienttag");
	return 0;
    }
    sprintf(key,"Record\\%s\\0\\disconnects",clienttag);
    return account_get_numattr(account,key);
}
예제 #2
0
extern unsigned int account_get_ladder_high_rank(t_account * account, char const * clienttag, t_ladder_id id)
{
    char key[256];
    
    if (!clienttag || strlen(clienttag)!=4)
    {
	eventlog(eventlog_level_error,"account_get_ladder_high_rank","got bad clienttag");
	return 0;
    }
    sprintf(key,"Record\\%s\\%d\\high_rank",clienttag,(int)id);
    return account_get_numattr(account,key);
}
예제 #3
0
		/* Get account attribute value */
		extern int __account_get_attr(lua_State* L)
		{
			const char *username, *attrkey;
			int attrtype;
			std::string attrvalue;
			std::map<std::string, std::string> o_account;

			try
			{
				lua::stack st(L);
				// get args
				st.at(1, username);
				st.at(2, attrkey);
				st.at(3, attrtype);

				if (t_account *account = accountlist_find_account(username))
				{
					switch ((t_attr_type)attrtype)
					{
					case attr_type_str:
						attrvalue = account_get_strattr(account, attrkey);
						break;
					case attr_type_num:
						attrvalue = std_to_string(account_get_numattr(account, attrkey));
						break;
					case attr_type_bool:
						attrvalue = account_get_boolattr(account, attrkey) == 0 ? "false" : "true";
						break;
					case attr_type_raw:
						attrvalue = account_get_rawattr(account, attrkey);
						break;
					}
				}

				st.push(attrvalue);
			}
			catch (const std::exception& e)
			{
				eventlog(eventlog_level_error, __FUNCTION__, e.what());
			}
			catch (...)
			{
				eventlog(eventlog_level_error, __FUNCTION__, "lua exception\n");
			}

			return 1;
		}
예제 #4
0
/* Get account attribute value */
extern int __account_get_attr(lua_State* L)
{
    const char *username, *attrkey;
    int attrtype;

    try
    {
        lua::stack st(L);
        // get args
        st.at(1, username);
        st.at(2, attrkey);
        st.at(3, attrtype);

        if (t_account *account = accountlist_find_account(username))
        {
            switch ((t_attr_type)attrtype)
            {
            case attr_type_str:
                if (const char * val = account_get_strattr(account, attrkey))
                    st.push(val);
                break;
            case attr_type_num:
                st.push(account_get_numattr(account, attrkey));
                break;
            case attr_type_bool:
                st.push(account_get_boolattr(account, attrkey));
                break;
            case attr_type_raw:
                if (const char * val = account_get_rawattr(account, attrkey))
                    st.push(val);
                break;
            }
        }
    }
    catch (const std::exception& e)
    {
        eventlog(eventlog_level_error, __FUNCTION__, e.what());
    }
    catch (...)
    {
        eventlog(eventlog_level_error, __FUNCTION__, "lua exception\n");
    }
    return 1;
}
예제 #5
0
extern unsigned int account_get_ll_connection(t_account * account)
{
    return account_get_numattr(account,"BNET\\acct\\lastlogin_connection");
}
예제 #6
0
extern unsigned int account_get_ll_time(t_account * account)
{
    return account_get_numattr(account,"BNET\\acct\\lastlogin_time");
}