Initial + Added skill db read + converter skill_id > readable
parent
432af617a1
commit
b23c9c45f0
@ -0,0 +1,11 @@
|
||||
--
|
||||
-- Table structure for table `bot_accounts`
|
||||
-- Creator id = 0 -> Created by Brokk via Auto-Generate from Configs
|
||||
--
|
||||
CREATE TABLE IF NOT EXISTS `bot_accounts` (
|
||||
`account_id` int(11) unsigned NOT NULL,
|
||||
`is_bot` tinyint(2) NOT NULL default '1',
|
||||
`creator_id` int(11) unsigned NOT NULL default '0',
|
||||
`creator_name` varchar(23) NOT NULL default 'Brokk',
|
||||
PRIMARY KEY (`account_id`)
|
||||
) ENGINE=MyISAM;
|
@ -0,0 +1,954 @@
|
||||
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "account.hpp"
|
||||
|
||||
#include <algorithm> //min / max
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <common/malloc.hpp>
|
||||
#include <common/mmo.hpp>
|
||||
#include <common/showmsg.hpp>
|
||||
#include <common/socket.hpp>
|
||||
#include <common/sql.hpp>
|
||||
#include <common/strlib.hpp>
|
||||
|
||||
#include "brokk.hpp" // brokk_config
|
||||
|
||||
/// global defines
|
||||
|
||||
/// internal structure
|
||||
typedef struct AccountDB_SQL {
|
||||
AccountDB vtable; // public interface
|
||||
Sql* accounts; // SQL handle accounts storage
|
||||
std::string db_hostname = "127.0.0.1";
|
||||
uint16 db_port = 3306;
|
||||
std::string db_username = "ragnarok";
|
||||
std::string db_password = "";
|
||||
std::string db_database = "ragnarok";
|
||||
std::string codepage = "";
|
||||
// other settings
|
||||
bool case_sensitive;
|
||||
//table name
|
||||
char account_db[32];
|
||||
char global_acc_reg_num_table[32];
|
||||
char global_acc_reg_str_table[32];
|
||||
|
||||
} AccountDB_SQL;
|
||||
|
||||
/// internal structure
|
||||
typedef struct AccountDBIterator_SQL {
|
||||
AccountDBIterator vtable; // public interface
|
||||
AccountDB_SQL* db;
|
||||
int last_account_id;
|
||||
} AccountDBIterator_SQL;
|
||||
|
||||
/// internal functions
|
||||
static bool account_db_sql_init(AccountDB* self);
|
||||
static void account_db_sql_destroy(AccountDB* self);
|
||||
static bool account_db_sql_get_property(AccountDB* self, const char* key, char* buf, size_t buflen);
|
||||
static bool account_db_sql_set_property(AccountDB* self, const char* option, const char* value);
|
||||
static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc);
|
||||
static bool account_db_sql_remove(AccountDB* self, const uint32 account_id);
|
||||
static bool account_db_sql_enable_webtoken( AccountDB* self, const uint32 account_id );
|
||||
static bool account_db_sql_disable_webtoken( AccountDB* self, const uint32 account_id );
|
||||
static bool account_db_sql_remove_webtokens( AccountDB* self );
|
||||
static bool account_db_sql_save(AccountDB* self, const struct mmo_account* acc, bool refresh_token);
|
||||
static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const uint32 account_id);
|
||||
static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, const char* userid);
|
||||
static AccountDBIterator* account_db_sql_iterator(AccountDB* self);
|
||||
static void account_db_sql_iter_destroy(AccountDBIterator* self);
|
||||
static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account* acc);
|
||||
|
||||
static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, uint32 account_id);
|
||||
static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new, bool refresh_token);
|
||||
|
||||
/// public constructor
|
||||
AccountDB* account_db_sql(void) {
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)aCalloc(1, sizeof(AccountDB_SQL));
|
||||
new(db) AccountDB_SQL();
|
||||
|
||||
// set up the vtable
|
||||
db->vtable.init = &account_db_sql_init;
|
||||
db->vtable.destroy = &account_db_sql_destroy;
|
||||
db->vtable.get_property = &account_db_sql_get_property;
|
||||
db->vtable.set_property = &account_db_sql_set_property;
|
||||
db->vtable.save = &account_db_sql_save;
|
||||
db->vtable.create = &account_db_sql_create;
|
||||
db->vtable.remove = &account_db_sql_remove;
|
||||
db->vtable.enable_webtoken = &account_db_sql_enable_webtoken;
|
||||
db->vtable.disable_webtoken = &account_db_sql_disable_webtoken;
|
||||
db->vtable.remove_webtokens = &account_db_sql_remove_webtokens;
|
||||
db->vtable.load_num = &account_db_sql_load_num;
|
||||
db->vtable.load_str = &account_db_sql_load_str;
|
||||
db->vtable.iterator = &account_db_sql_iterator;
|
||||
|
||||
// initialize to default values
|
||||
db->accounts = nullptr;
|
||||
// other settings
|
||||
db->case_sensitive = false;
|
||||
safestrncpy(db->account_db, "login", sizeof(db->account_db));
|
||||
safestrncpy(db->global_acc_reg_num_table, "global_acc_reg_num", sizeof(db->global_acc_reg_num_table));
|
||||
safestrncpy(db->global_acc_reg_str_table, "global_acc_reg_str", sizeof(db->global_acc_reg_str_table));
|
||||
|
||||
return &db->vtable;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/**
|
||||
* Establish the database connection.
|
||||
* @param self: pointer to db
|
||||
*/
|
||||
static bool account_db_sql_init(AccountDB* self) {
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
Sql* sql_handle;
|
||||
|
||||
db->accounts = Sql_Malloc();
|
||||
sql_handle = db->accounts;
|
||||
|
||||
if( SQL_ERROR == Sql_Connect(sql_handle, db->db_username.c_str(), db->db_password.c_str(), db->db_hostname.c_str(), db->db_port, db->db_database.c_str()) )
|
||||
{
|
||||
ShowError("Couldn't connect with uname='%s',host='%s',port='%hu',database='%s'\n",
|
||||
db->db_username.c_str(), db->db_hostname.c_str(), db->db_port, db->db_database.c_str());
|
||||
Sql_ShowDebug(sql_handle);
|
||||
Sql_Free(db->accounts);
|
||||
db->accounts = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !db->codepage.empty() && SQL_ERROR == Sql_SetEncoding(sql_handle, db->codepage.c_str()) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
self->remove_webtokens( self );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the database and close the connection to it.
|
||||
* @param self: pointer to db
|
||||
*/
|
||||
static void account_db_sql_destroy(AccountDB* self){
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
|
||||
if( SQL_ERROR == Sql_Query( db->accounts, "UPDATE `%s` SET `web_auth_token` = NULL", db->account_db ) ){
|
||||
Sql_ShowDebug( db->accounts );
|
||||
}
|
||||
|
||||
Sql_Free(db->accounts);
|
||||
db->accounts = nullptr;
|
||||
|
||||
db->~AccountDB_SQL();
|
||||
aFree(db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get configuration information into buf.
|
||||
* If the option is supported, adjust the internal state.
|
||||
* @param self: pointer to db
|
||||
* @param key: config keyword
|
||||
* @param buf: value set of the keyword
|
||||
* @param buflen: size of buffer to avoid out of bound
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool account_db_sql_get_property(AccountDB* self, const char* key, char* buf, size_t buflen)
|
||||
{
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
const char* signature;
|
||||
|
||||
signature = "login_server_";
|
||||
if( strncmpi(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "ip") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_hostname.c_str());
|
||||
else
|
||||
if( strcmpi(key, "port") == 0 )
|
||||
safesnprintf(buf, buflen, "%hu", db->db_port);
|
||||
else
|
||||
if( strcmpi(key, "id") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_username.c_str());
|
||||
else
|
||||
if( strcmpi(key, "pw") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_password.c_str());
|
||||
else
|
||||
if( strcmpi(key, "db") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_database.c_str());
|
||||
else
|
||||
if( strcmpi(key, "account_db") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->account_db);
|
||||
else
|
||||
if( strcmpi(key, "global_acc_reg_str_table") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->global_acc_reg_str_table);
|
||||
else
|
||||
if( strcmpi(key, "global_acc_reg_num_table") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->global_acc_reg_num_table);
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
signature = "login_";
|
||||
if( strncmpi(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "codepage") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->codepage.c_str());
|
||||
else
|
||||
if( strcmpi(key, "case_sensitive") == 0 )
|
||||
safesnprintf(buf, buflen, "%d", (db->case_sensitive ? 1 : 0));
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;// not found
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and set configuration.
|
||||
* If the option is supported, adjust the internal state.
|
||||
* @param self: pointer to db
|
||||
* @param key: config keyword
|
||||
* @param value: config value for keyword
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool account_db_sql_set_property(AccountDB* self, const char* key, const char* value) {
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
const char* signature;
|
||||
|
||||
signature = "login_server_";
|
||||
if( strncmp(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "ip") == 0 )
|
||||
db->db_hostname = value;
|
||||
else
|
||||
if( strcmpi(key, "port") == 0 )
|
||||
db->db_port = (uint16)strtoul( value, nullptr, 10 );
|
||||
else
|
||||
if( strcmpi(key, "id") == 0 )
|
||||
db->db_username = value;
|
||||
else
|
||||
if( strcmpi(key, "pw") == 0 )
|
||||
db->db_password = value;
|
||||
else
|
||||
if( strcmpi(key, "db") == 0 )
|
||||
db->db_database = value;
|
||||
else
|
||||
if( strcmpi(key, "account_db") == 0 )
|
||||
safestrncpy(db->account_db, value, sizeof(db->account_db));
|
||||
else
|
||||
if( strcmpi(key, "global_acc_reg_str_table") == 0 )
|
||||
safestrncpy(db->global_acc_reg_str_table, value, sizeof(db->global_acc_reg_str_table));
|
||||
else
|
||||
if( strcmpi(key, "global_acc_reg_num_table") == 0 )
|
||||
safestrncpy(db->global_acc_reg_num_table, value, sizeof(db->global_acc_reg_num_table));
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
signature = "login_";
|
||||
if( strncmpi(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "codepage") == 0 )
|
||||
db->codepage = value;
|
||||
else
|
||||
if( strcmpi(key, "case_sensitive") == 0 )
|
||||
db->case_sensitive = (config_switch(value)==1);
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;// not found
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new account entry.
|
||||
* If acc->account_id is -1, the account id will be auto-generated,
|
||||
* and its value will be written to acc->account_id if everything succeeds.
|
||||
* @param self: pointer to db
|
||||
* @param acc: pointer of mmo_account to save
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc) {
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
Sql* sql_handle = db->accounts;
|
||||
|
||||
// decide on the account id to assign
|
||||
uint32 account_id;
|
||||
if( acc->account_id != -1 )
|
||||
{// caller specifies it manually
|
||||
account_id = acc->account_id;
|
||||
}
|
||||
else
|
||||
{// ask the database
|
||||
char* data;
|
||||
size_t len;
|
||||
|
||||
if( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT MAX(`account_id`)+1 FROM `%s`", db->account_db) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
Sql_GetData(sql_handle, 0, &data, &len);
|
||||
account_id = ( data != nullptr ) ? atoi(data) : 0;
|
||||
Sql_FreeResult(sql_handle);
|
||||
account_id = max((uint32_t) START_ACCOUNT_NUM, account_id);
|
||||
}
|
||||
|
||||
// zero value is prohibited
|
||||
if( account_id == 0 )
|
||||
return false;
|
||||
|
||||
// absolute maximum
|
||||
if( account_id > END_ACCOUNT_NUM )
|
||||
return false;
|
||||
|
||||
// insert the data into the database
|
||||
acc->account_id = account_id;
|
||||
return mmo_auth_tosql(db, acc, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing account entry and its regs.
|
||||
* @param self: pointer to db
|
||||
* @param account_id: id of user account
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool account_db_sql_remove(AccountDB* self, const uint32 account_id) {
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
Sql* sql_handle = db->accounts;
|
||||
bool result = false;
|
||||
|
||||
if( SQL_SUCCESS != Sql_QueryStr(sql_handle, "START TRANSACTION")
|
||||
|| SQL_SUCCESS != Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = %d", db->account_db, account_id)
|
||||
|| SQL_SUCCESS != Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = %d", db->global_acc_reg_num_table, account_id)
|
||||
|| SQL_SUCCESS != Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = %d", db->global_acc_reg_str_table, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else
|
||||
result = true;
|
||||
|
||||
result &= ( SQL_SUCCESS == Sql_QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing account with the new data provided (both account and regs).
|
||||
* @param self: pointer to db
|
||||
* @param acc: pointer of mmo_account to save
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool account_db_sql_save(AccountDB* self, const struct mmo_account* acc, bool refresh_token) {
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
return mmo_auth_tosql(db, acc, false, refresh_token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve data from db and store it in the provided data structure.
|
||||
* Filled data structure is done by delegation to mmo_auth_fromsql.
|
||||
* @param self: pointer to db
|
||||
* @param acc: pointer of mmo_account to fill
|
||||
* @param account_id: id of user account
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const uint32 account_id) {
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
return mmo_auth_fromsql(db, acc, account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve data from db and store it in the provided data structure.
|
||||
* Doesn't actually retrieve data yet: escapes and checks userid, then transforms it to accid for fetching.
|
||||
* Filled data structure is done by delegation to account_db_sql_load_num.
|
||||
* @param self: pointer to db
|
||||
* @param acc: pointer of mmo_account to fill
|
||||
* @param userid: name of user account
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, const char* userid) {
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
Sql* sql_handle = db->accounts;
|
||||
char esc_userid[2*NAME_LENGTH+1];
|
||||
uint32 account_id;
|
||||
char* data;
|
||||
|
||||
Sql_EscapeString(sql_handle, esc_userid, userid);
|
||||
|
||||
// get the list of account IDs for this user ID
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `userid`= %s '%s'",
|
||||
db->account_db, (db->case_sensitive ? "BINARY" : ""), esc_userid) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( Sql_NumRows(sql_handle) > 1 )
|
||||
{// serious problem - duplicit account
|
||||
ShowError("account_db_sql_load_str: multiple accounts found when retrieving data for account '%s'!\n", userid);
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
{// no such entry
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr);
|
||||
account_id = atoi(data);
|
||||
|
||||
return account_db_sql_load_num(self, acc, account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new forward iterator.
|
||||
* @param self: pointer to db iterator
|
||||
* @return a new db iterator
|
||||
*/
|
||||
static AccountDBIterator* account_db_sql_iterator(AccountDB* self) {
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)aCalloc(1, sizeof(AccountDBIterator_SQL));
|
||||
|
||||
// set up the vtable
|
||||
iter->vtable.destroy = &account_db_sql_iter_destroy;
|
||||
iter->vtable.next = &account_db_sql_iter_next;
|
||||
|
||||
// fill data
|
||||
iter->db = db;
|
||||
iter->last_account_id = -1;
|
||||
|
||||
return &iter->vtable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys this iterator, releasing all allocated memory (including itself).
|
||||
* @param self: pointer to db iterator
|
||||
*/
|
||||
static void account_db_sql_iter_destroy(AccountDBIterator* self) {
|
||||
AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self;
|
||||
aFree(iter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the next account in the database.
|
||||
* @param self: pointer to db iterator
|
||||
* @param acc: pointer of mmo_account to fill
|
||||
* @return true if next account found and filled, false if something has failed
|
||||
*/
|
||||
static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account* acc) {
|
||||
AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self;
|
||||
AccountDB_SQL* db = iter->db;
|
||||
Sql* sql_handle = db->accounts;
|
||||
char* data;
|
||||
|
||||
// get next account ID
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `account_id` > '%d' ORDER BY `account_id` ASC LIMIT 1",
|
||||
db->account_db, iter->last_account_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS == Sql_NextRow(sql_handle) &&
|
||||
SQL_SUCCESS == Sql_GetData(sql_handle, 0, &data, nullptr) &&
|
||||
data != nullptr )
|
||||
{// get account data
|
||||
uint32 account_id;
|
||||
account_id = atoi(data);
|
||||
if( mmo_auth_fromsql(db, acc, account_id) )
|
||||
{
|
||||
iter->last_account_id = account_id;
|
||||
Sql_FreeResult(sql_handle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a struct mmo_account from sql, excluding web_auth_token.
|
||||
* @param db: pointer to db
|
||||
* @param acc: pointer of mmo_account to fill
|
||||
* @param account_id: id of user account to take data from
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, uint32 account_id) {
|
||||
Sql* sql_handle = db->accounts;
|
||||
char* data;
|
||||
|
||||
// retrieve login entry for the specified account
|
||||
if( SQL_ERROR == Sql_Query(sql_handle,
|
||||
#ifdef VIP_ENABLE
|
||||
"SELECT `account_id`,`userid`,`user_pass`,`sex`,`email`,`group_id`,`state`,`unban_time`,`expiration_time`,`logincount`,`lastlogin`,`last_ip`,`birthdate`,`character_slots`,`pincode`, `pincode_change`, `vip_time`, `old_group` FROM `%s` WHERE `account_id` = %d",
|
||||
#else
|
||||
"SELECT `account_id`,`userid`,`user_pass`,`sex`,`email`,`group_id`,`state`,`unban_time`,`expiration_time`,`logincount`,`lastlogin`,`last_ip`,`birthdate`,`character_slots`,`pincode`, `pincode_change` FROM `%s` WHERE `account_id` = %d",
|
||||
#endif
|
||||
db->account_db, account_id )
|
||||
) {
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
{// no such entry
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr); acc->account_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 1, &data, nullptr); safestrncpy(acc->userid, data, sizeof(acc->userid));
|
||||
Sql_GetData(sql_handle, 2, &data, nullptr); safestrncpy(acc->pass, data, sizeof(acc->pass));
|
||||
Sql_GetData(sql_handle, 3, &data, nullptr); acc->sex = data[0];
|
||||
Sql_GetData(sql_handle, 4, &data, nullptr); safestrncpy(acc->email, data, sizeof(acc->email));
|
||||
Sql_GetData(sql_handle, 5, &data, nullptr); acc->group_id = (unsigned int) atoi(data);
|
||||
Sql_GetData(sql_handle, 6, &data, nullptr); acc->state = (unsigned int) strtoul(data, nullptr, 10);
|
||||
Sql_GetData(sql_handle, 7, &data, nullptr); acc->unban_time = atol(data);
|
||||
Sql_GetData(sql_handle, 8, &data, nullptr); acc->expiration_time = atol(data);
|
||||
Sql_GetData(sql_handle, 9, &data, nullptr); acc->logincount = (unsigned int) strtoul(data, nullptr, 10);
|
||||
Sql_GetData(sql_handle, 10, &data, nullptr); safestrncpy(acc->lastlogin, data==nullptr?"":data, sizeof(acc->lastlogin));
|
||||
Sql_GetData(sql_handle, 11, &data, nullptr); safestrncpy(acc->last_ip, data, sizeof(acc->last_ip));
|
||||
Sql_GetData(sql_handle, 12, &data, nullptr); safestrncpy(acc->birthdate, data==nullptr?"":data, sizeof(acc->birthdate));
|
||||
Sql_GetData(sql_handle, 13, &data, nullptr); acc->char_slots = (uint8) atoi(data);
|
||||
Sql_GetData(sql_handle, 14, &data, nullptr); safestrncpy(acc->pincode, data, sizeof(acc->pincode));
|
||||
Sql_GetData(sql_handle, 15, &data, nullptr); acc->pincode_change = atol(data);
|
||||
#ifdef VIP_ENABLE
|
||||
Sql_GetData(sql_handle, 16, &data, nullptr); acc->vip_time = atol(data);
|
||||
Sql_GetData(sql_handle, 17, &data, nullptr); acc->old_group = atoi(data);
|
||||
#endif
|
||||
Sql_FreeResult(sql_handle);
|
||||
acc->web_auth_token[0] = '\0';
|
||||
|
||||
if( acc->char_slots > MAX_CHARS ){
|
||||
ShowError( "Account %s (AID=%u) exceeds MAX_CHARS. Capping...\n", acc->userid, acc->account_id );
|
||||
acc->char_slots = MAX_CHARS;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a struct mmo_account in sql.
|
||||
* @param db: pointer to db
|
||||
* @param acc: pointer of mmo_account to save
|
||||
* @param is_new: if it's a new entry or should we update
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new, bool refresh_token) {
|
||||
Sql* sql_handle = db->accounts;
|
||||
SqlStmt* stmt = SqlStmt_Malloc(sql_handle);
|
||||
bool result = false;
|
||||
|
||||
// try
|
||||
do
|
||||
{
|
||||
|
||||
if( SQL_SUCCESS != Sql_QueryStr(sql_handle, "START TRANSACTION") )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
}
|
||||
|
||||
if( is_new )
|
||||
{// insert into account table
|
||||
if( SQL_SUCCESS != SqlStmt_Prepare(stmt,
|
||||
#ifdef VIP_ENABLE
|
||||
"INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `group_id`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`, `birthdate`, `character_slots`, `pincode`, `pincode_change`, `vip_time`, `old_group` ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
#else
|
||||
"INSERT INTO `%s` (`account_id`, `userid`, `user_pass`, `sex`, `email`, `group_id`, `state`, `unban_time`, `expiration_time`, `logincount`, `lastlogin`, `last_ip`, `birthdate`, `character_slots`, `pincode`, `pincode_change`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
#endif
|
||||
db->account_db)
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_INT, (void*)&acc->account_id, sizeof(acc->account_id))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_STRING, (void*)&acc->email, strlen(acc->email))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 6, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 7, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 8, SQLDT_INT, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 9, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 10, acc->lastlogin[0]?SQLDT_STRING:SQLDT_NULL, (void*)&acc->lastlogin, strlen(acc->lastlogin))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 11, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 12, acc->birthdate[0]?SQLDT_STRING:SQLDT_NULL, (void*)&acc->birthdate, strlen(acc->birthdate))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 13, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 14, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 15, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
|
||||
#ifdef VIP_ENABLE
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 16, SQLDT_LONG, (void*)&acc->vip_time, sizeof(acc->vip_time))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 17, SQLDT_INT, (void*)&acc->old_group, sizeof(acc->old_group))
|
||||
#endif
|
||||
|| SQL_SUCCESS != SqlStmt_Execute(stmt)
|
||||
) {
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{// update account table
|
||||
if( SQL_SUCCESS != SqlStmt_Prepare(stmt,
|
||||
#ifdef VIP_ENABLE
|
||||
"UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=?,`character_slots`=?,`pincode`=?, `pincode_change`=?, `vip_time`=?, `old_group`=? WHERE `account_id` = '%d'",
|
||||
#else
|
||||
"UPDATE `%s` SET `userid`=?,`user_pass`=?,`sex`=?,`email`=?,`group_id`=?,`state`=?,`unban_time`=?,`expiration_time`=?,`logincount`=?,`lastlogin`=?,`last_ip`=?,`birthdate`=?,`character_slots`=?,`pincode`=?, `pincode_change`=? WHERE `account_id` = '%d'",
|
||||
#endif
|
||||
db->account_db, acc->account_id)
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (void*)acc->userid, strlen(acc->userid))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_STRING, (void*)acc->pass, strlen(acc->pass))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_ENUM, (void*)&acc->sex, sizeof(acc->sex))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, (void*)acc->email, strlen(acc->email))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 4, SQLDT_INT, (void*)&acc->group_id, sizeof(acc->group_id))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 5, SQLDT_UINT, (void*)&acc->state, sizeof(acc->state))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 6, SQLDT_LONG, (void*)&acc->unban_time, sizeof(acc->unban_time))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 7, SQLDT_LONG, (void*)&acc->expiration_time, sizeof(acc->expiration_time))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 8, SQLDT_UINT, (void*)&acc->logincount, sizeof(acc->logincount))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 9, acc->lastlogin[0]?SQLDT_STRING:SQLDT_NULL, (void*)&acc->lastlogin, strlen(acc->lastlogin))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 10, SQLDT_STRING, (void*)&acc->last_ip, strlen(acc->last_ip))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 11, acc->birthdate[0]?SQLDT_STRING:SQLDT_NULL, (void*)&acc->birthdate, strlen(acc->birthdate))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 12, SQLDT_UCHAR, (void*)&acc->char_slots, sizeof(acc->char_slots))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 13, SQLDT_STRING, (void*)&acc->pincode, strlen(acc->pincode))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 14, SQLDT_LONG, (void*)&acc->pincode_change, sizeof(acc->pincode_change))
|
||||
#ifdef VIP_ENABLE
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 15, SQLDT_LONG, (void*)&acc->vip_time, sizeof(acc->vip_time))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 16, SQLDT_INT, (void*)&acc->old_group, sizeof(acc->old_group))
|
||||
#endif
|
||||
|| SQL_SUCCESS != SqlStmt_Execute(stmt)
|
||||
) {
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( acc->sex != 'S' && brokk_config.use_web_auth_token && refresh_token ){
|
||||
static bool initialized = false;
|
||||
static const char* query;
|
||||
|
||||
// Pseudo Scope to break out
|
||||
while( !initialized ){
|
||||
if( SQL_SUCCESS == Sql_Query( sql_handle, "SELECT SHA2( 'test', 256 )" ) ){
|
||||
query = "UPDATE `%s` SET `web_auth_token` = LEFT( SHA2( CONCAT( UUID(), RAND() ), 256 ), %d ), `web_auth_token_enabled` = '1' WHERE `account_id` = '%d'";
|
||||
initialized = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS == Sql_Query( sql_handle, "SELECT MD5( 'test' )" ) ){
|
||||
query = "UPDATE `%s` SET `web_auth_token` = LEFT( MD5( CONCAT( UUID(), RAND() ) ), %d ), `web_auth_token_enabled` = '1' WHERE `account_id` = '%d'";
|
||||
initialized = true;
|
||||
break;
|
||||
}
|
||||
|
||||
ShowWarning( "Your MySQL does not support SHA2 and MD5 - no hashing will be used for login token creation.\n" );
|
||||
ShowWarning( "If you are using an old version of MySQL consider upgrading to a newer release.\n" );
|
||||
query = "UPDATE `%s` SET `web_auth_token` = LEFT( CONCAT( UUID(), RAND() ), %d ), `web_auth_token_enabled` = '1' WHERE `account_id` = '%d'";
|
||||
initialized = true;
|
||||
break;
|
||||
}
|
||||
|
||||
const int MAX_RETRIES = 20;
|
||||
int i = 0;
|
||||
bool success = false;
|
||||
|
||||
// Retry it for a maximum number of retries
|
||||
do{
|
||||
if( SQL_SUCCESS == Sql_Query( sql_handle, query, db->account_db, WEB_AUTH_TOKEN_LENGTH - 1, acc->account_id ) ){
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}while( i < MAX_RETRIES && Sql_GetError( sql_handle ) == 1062 );
|
||||
|
||||
if( !success ){
|
||||
if( i == MAX_RETRIES ){
|
||||
ShowError( "Failed to generate a unique web_auth_token with %d retries...\n", i );
|
||||
}else{
|
||||
Sql_ShowDebug( sql_handle );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
char* data;
|
||||
size_t len;
|
||||
|
||||
if( SQL_SUCCESS != Sql_Query( sql_handle, "SELECT `web_auth_token` from `%s` WHERE `account_id` = '%d'", db->account_db, acc->account_id ) ||
|
||||
SQL_SUCCESS != Sql_NextRow( sql_handle ) ||
|
||||
SQL_SUCCESS != Sql_GetData( sql_handle, 0, &data, &len )
|
||||
){
|
||||
Sql_ShowDebug( sql_handle );
|
||||
break;
|
||||
}
|
||||
|
||||
safestrncpy( (char *)&acc->web_auth_token, data, sizeof( acc->web_auth_token ) );
|
||||
|
||||
Sql_FreeResult( sql_handle );
|
||||
}
|
||||
|
||||
// if we got this far, everything was successful
|
||||
result = true;
|
||||
|
||||
} while(0);
|
||||
// finally
|
||||
|
||||
result &= ( SQL_SUCCESS == Sql_QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") );
|
||||
SqlStmt_Free(stmt);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void mmo_save_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id) {
|
||||
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
uint16 count = RFIFOW(fd, 12);
|
||||
|
||||
if (count) {
|
||||
int cursor = 14, i;
|
||||
char key[32], sval[254], esc_key[32*2+1], esc_sval[254*2+1];
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
uint32 index;
|
||||
safestrncpy(key, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
|
||||
Sql_EscapeString(sql_handle, esc_key, key);
|
||||
cursor += RFIFOB(fd, cursor) + 1;
|
||||
|
||||
index = RFIFOL(fd, cursor);
|
||||
cursor += 4;
|
||||
|
||||
switch (RFIFOB(fd, cursor++)) {
|
||||
// int
|
||||
case 0:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%" PRId64 "')", db->global_acc_reg_num_table, account_id, esc_key, index, RFIFOQ(fd, cursor)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
cursor += 8;
|
||||
break;
|
||||
case 1:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", db->global_acc_reg_num_table, account_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
// str
|
||||
case 2:
|
||||
safestrncpy(sval, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
|
||||
cursor += RFIFOB(fd, cursor) + 1;
|
||||
Sql_EscapeString(sql_handle, esc_sval, sval);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%s')", db->global_acc_reg_str_table, account_id, esc_key, index, esc_sval) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 3:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", db->global_acc_reg_str_table, account_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
default:
|
||||
ShowError("mmo_save_global_accreg: unknown type %d\n",RFIFOB(fd, cursor - 1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mmo_send_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id) {
|
||||
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
char* data;
|
||||
int16 plen = 0;
|
||||
size_t len;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%" PRIu32 "'", db->global_acc_reg_str_table, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 1; // is string type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
plen = 16;
|
||||
|
||||
/**
|
||||
* Vessel!
|
||||
*
|
||||
* str type
|
||||
* { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
|
||||
**/
|
||||
while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr);
|
||||
len = strlen(data)+1;
|
||||
|
||||
WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 32
|
||||
plen += 1;
|
||||
|
||||
safestrncpy(WFIFOCP(fd,plen), data, len);
|
||||
plen += static_cast<decltype(plen)>( len );
|
||||
|
||||
Sql_GetData(sql_handle, 1, &data, nullptr);
|
||||
|
||||
WFIFOL(fd, plen) = (uint32)atol(data);
|
||||
plen += 4;
|
||||
|
||||
Sql_GetData(sql_handle, 2, &data, nullptr);
|
||||
len = strlen(data)+1;
|
||||
|
||||
WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 254
|
||||
plen += 1;
|
||||
|
||||
safestrncpy(WFIFOCP(fd,plen), data, len);
|
||||
plen += static_cast<decltype(plen)>( len );
|
||||
|
||||
WFIFOW(fd, 14) += 1;
|
||||
|
||||
if( plen > 60000 ) {
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
// prepare follow up
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 1; // is string type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
plen = 16;
|
||||
}
|
||||
}
|
||||
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%" PRIu32 "'", db->global_acc_reg_num_table, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 0; // is int type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
plen = 16;
|
||||
|
||||
/**
|
||||
* Vessel!
|
||||
*
|
||||
* int type
|
||||
* { keyLength(B), key(<keyLength>), index(L), value(L) }
|
||||
**/
|
||||
while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr);
|
||||
len = strlen(data)+1;
|
||||
|
||||
WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 32
|
||||
plen += 1;
|
||||
|
||||
safestrncpy(WFIFOCP(fd,plen), data, len);
|
||||
plen += static_cast<decltype(plen)>( len );
|
||||
|
||||
Sql_GetData(sql_handle, 1, &data, nullptr);
|
||||
|
||||
WFIFOL(fd, plen) = (uint32)atol(data);
|
||||
plen += 4;
|
||||
|
||||
Sql_GetData(sql_handle, 2, &data, nullptr);
|
||||
|
||||
WFIFOQ(fd, plen) = strtoll(data,nullptr,10);
|
||||
plen += 8;
|
||||
|
||||
WFIFOW(fd, 14) += 1;
|
||||
|
||||
if( plen > 60000 ) {
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
// prepare follow up
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 0; // is int type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
|
||||
plen = 16;
|
||||
}
|
||||
}
|
||||
|
||||
WFIFOB(fd, 12) = 1;
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
Sql_FreeResult(sql_handle);
|
||||
}
|
||||
|
||||
bool account_db_sql_enable_webtoken( AccountDB* self, const uint32 account_id ){
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
|
||||
if( SQL_ERROR == Sql_Query( db->accounts, "UPDATE `%s` SET `web_auth_token_enabled` = '1' WHERE `account_id` = '%u'", db->account_db, account_id ) ){
|
||||
Sql_ShowDebug( db->accounts );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timered function to disable webtoken for user
|
||||
* If the user is online, then they must have logged since we started the timer.
|
||||
* In that case, do nothing. The new authtoken must be valid.
|
||||
* @param tid: timer id
|
||||
* @param tick: tick of execution
|
||||
* @param id: user account id
|
||||
* @param data: AccountDB // because we don't use singleton???
|
||||
* @return :0
|
||||
|
||||
TIMER_FUNC(account_disable_webtoken_timer){
|
||||
const struct online_login_data* p = login_get_online_user(id);
|
||||
AccountDB_SQL* db = reinterpret_cast<AccountDB_SQL*>(data);
|
||||
|
||||
if (p == nullptr) {
|
||||
ShowInfo("Web Auth Token for account %d was disabled\n", id);
|
||||
if( SQL_ERROR == Sql_Query( db->accounts, "UPDATE `%s` SET `web_auth_token_enabled` = '0' WHERE `account_id` = '%u'", db->account_db, id ) ){
|
||||
Sql_ShowDebug( db->accounts );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
bool account_db_sql_disable_webtoken( AccountDB* self, const uint32 account_id ){
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
|
||||
//add_timer(gettick() + brokk_config.disable_webtoken_delay, account_disable_webtoken_timer, account_id, reinterpret_cast<intptr_t>(db));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool account_db_sql_remove_webtokens( AccountDB* self ){
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
|
||||
if( SQL_ERROR == Sql_Query( db->accounts, "UPDATE `%s` SET `web_auth_token` = NULL, `web_auth_token_enabled` = '0'", db->account_db ) ){
|
||||
Sql_ShowDebug( db->accounts );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef ACCOUNT_HPP
|
||||
#define ACCOUNT_HPP
|
||||
|
||||
#include <common/cbasetypes.hpp>
|
||||
#include <common/mmo.hpp> // ACCOUNT_REG2_NUM, WEB_AUTH_TOKEN_LENGTH
|
||||
#include <config/core.hpp>
|
||||
|
||||
typedef struct AccountDB AccountDB;
|
||||
typedef struct AccountDBIterator AccountDBIterator;
|
||||
|
||||
|
||||
// standard engines
|
||||
AccountDB* account_db_sql(void);
|
||||
|
||||
struct mmo_account {
|
||||
uint32 account_id;
|
||||
char userid[NAME_LENGTH];
|
||||
char pass[32+1]; // 23+1 for plaintext, 32+1 for md5-ed passwords
|
||||
char sex; // gender (M/F/S)
|
||||
char email[40]; // e-mail (by default: a@a.com)
|
||||
unsigned int group_id; // player group id
|
||||
uint8 char_slots; // this accounts maximum character slots (maximum is limited to MAX_CHARS define in char server)
|
||||
unsigned int state; // packet 0x006a value + 1 (0: compte OK)
|
||||
time_t unban_time; // (timestamp): ban time limit of the account (0 = no ban)
|
||||
time_t expiration_time; // (timestamp): validity limit of the account (0 = unlimited)
|
||||
unsigned int logincount;// number of successful auth attempts
|
||||
char lastlogin[24]; // date+time of last successful login
|
||||
char last_ip[16]; // save of last IP of connection
|
||||
char birthdate[10+1]; // assigned birth date (format: YYYY-MM-DD)
|
||||
char pincode[PINCODE_LENGTH+1]; // pincode system
|
||||
time_t pincode_change; // (timestamp): last time of pincode change
|
||||
char web_auth_token[WEB_AUTH_TOKEN_LENGTH]; // web authentication token (randomized on each login)
|
||||
#ifdef VIP_ENABLE
|
||||
int old_group;
|
||||
time_t vip_time;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct AccountDBIterator {
|
||||
/// Destroys this iterator, releasing all allocated memory (including itself).
|
||||
///
|
||||
/// @param self Iterator
|
||||
void (*destroy)(AccountDBIterator* self);
|
||||
|
||||
/// Fetches the next account in the database.
|
||||
/// Fills acc with the account data.
|
||||
/// @param self Iterator
|
||||
/// @param acc Account data
|
||||
/// @return true if successful
|
||||
bool (*next)(AccountDBIterator* self, struct mmo_account* acc);
|
||||
};
|
||||
|
||||
|
||||
struct AccountDB {
|
||||
/// Initializes this database, making it ready for use.
|
||||
/// Call this after setting the properties.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @return true if successful
|
||||
bool (*init)(AccountDB* self);
|
||||
|
||||
/// Destroys this database, releasing all allocated memory (including itself).
|
||||
///
|
||||
/// @param self Database
|
||||
void (*destroy)(AccountDB* self);
|
||||
|
||||
/// Gets a property from this database.
|
||||
/// These read-only properties must be implemented:
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param key Property name
|
||||
/// @param buf Buffer for the value
|
||||
/// @param buflen Buffer length
|
||||
/// @return true if successful
|
||||
bool (*get_property)(AccountDB* self, const char* key, char* buf, size_t buflen);
|
||||
|
||||
/// Sets a property in this database.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param key Property name
|
||||
/// @param value Property value
|
||||
/// @return true if successful
|
||||
bool (*set_property)(AccountDB* self, const char* key, const char* value);
|
||||
|
||||
/// Creates a new account in this database.
|
||||
/// If acc->account_id is not -1, the provided value will be used.
|
||||
/// Otherwise the account_id will be auto-generated and written to acc->account_id.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param acc Account data
|
||||
/// @return true if successful
|
||||
bool (*create)(AccountDB* self, struct mmo_account* acc);
|
||||
|
||||
/// Removes an account from this database.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param account_id Account id
|
||||
/// @return true if successful
|
||||
bool (*remove)(AccountDB* self, const uint32 account_id);
|
||||
|
||||
/// Enables the web auth token for the given account id
|
||||
bool (*enable_webtoken)(AccountDB* self, const uint32 account_id);
|
||||
|
||||
/// Disables the web auth token for the given account id
|
||||
bool (*disable_webtoken)(AccountDB* self, const uint32 account_id);
|
||||
|
||||
/// Removes the web auth token for all accounts
|
||||
bool (*remove_webtokens)(AccountDB* self);
|
||||
|
||||
/// Modifies the data of an existing account.
|
||||
/// Uses acc->account_id to identify the account.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param acc Account data
|
||||
/// @param refresh_token Whether or not to refresh the web auth token
|
||||
/// @return true if successful
|
||||
bool (*save)(AccountDB* self, const struct mmo_account* acc, bool refresh_token);
|
||||
|
||||
/// Finds an account with account_id and copies it to acc.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param acc Pointer that receives the account data
|
||||
/// @param account_id Target account id
|
||||
/// @return true if successful
|
||||
bool (*load_num)(AccountDB* self, struct mmo_account* acc, const uint32 account_id);
|
||||
|
||||
/// Finds an account with userid and copies it to acc.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param acc Pointer that receives the account data
|
||||
/// @param userid Target username
|
||||
/// @return true if successful
|
||||
bool (*load_str)(AccountDB* self, struct mmo_account* acc, const char* userid);
|
||||
|
||||
/// Returns a new forward iterator.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @return Iterator
|
||||
AccountDBIterator* (*iterator)(AccountDB* self);
|
||||
};
|
||||
|
||||
void mmo_send_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id);
|
||||
void mmo_save_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id);
|
||||
|
||||
#endif /* ACCOUNT_HPP */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,787 @@
|
||||
// Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef BATTLE_HPP
|
||||
#define BATTLE_HPP
|
||||
|
||||
#include <bitset>
|
||||
|
||||
#include <common/cbasetypes.hpp>
|
||||
#include <common/mmo.hpp>
|
||||
#include <config/core.hpp>
|
||||
|
||||
#include "map.hpp" //ELE_MAX
|
||||
#include "skill.hpp"
|
||||
|
||||
//fwd declaration
|
||||
class map_session_data;
|
||||
struct mob_data;
|
||||
struct block_list;
|
||||
enum e_damage_type : uint8;
|
||||
|
||||
|
||||
/// State of a single attack attempt; used in flee/def penalty calculations when mobbed
|
||||
enum damage_lv : uint8 {
|
||||
ATK_NONE, /// Not an attack
|
||||
ATK_LUCKY, /// Attack was lucky-dodged
|
||||
ATK_FLEE, /// Attack was dodged
|
||||
ATK_MISS, /// Attack missed because of element/race modifier.
|
||||
ATK_BLOCK, /// Attack was blocked by some skills.
|
||||
ATK_DEF /// Attack connected
|
||||
};
|
||||
|
||||
/// Flag for base damage calculation
|
||||
enum e_base_damage_flag : uint16 {
|
||||
BDMG_NONE = 0x0000, /// None
|
||||
BDMG_CRIT = 0x0001, /// Critical hit damage
|
||||
BDMG_ARROW = 0x0002, /// Add arrow attack and use ranged damage formula
|
||||
BDMG_MAGIC = 0x0004, /// Use MATK for base damage (e.g. Magic Crasher)
|
||||
BDMG_NOSIZE = 0x0008, /// Skip target size adjustment (e.g. Weapon Perfection)
|
||||
};
|
||||
|
||||
/// Flag of the final calculation
|
||||
enum e_battle_flag : uint16 {
|
||||
BF_NONE = 0x0000, /// None
|
||||
BF_WEAPON = 0x0001, /// Weapon attack
|
||||
BF_MAGIC = 0x0002, /// Magic attack
|
||||
BF_MISC = 0x0004, /// Misc attack
|
||||
|
||||
BF_SHORT = 0x0010, /// Short attack
|
||||
BF_LONG = 0x0040, /// Long attack
|
||||
|
||||
BF_SKILL = 0x0100, /// Skill attack
|
||||
BF_NORMAL = 0x0200, /// Normal attack
|
||||
|
||||
BF_WEAPONMASK = BF_WEAPON|BF_MAGIC|BF_MISC, /// Weapon attack mask
|
||||
BF_RANGEMASK = BF_SHORT|BF_LONG, /// Range attack mask
|
||||
BF_SKILLMASK = BF_SKILL|BF_NORMAL, /// Skill attack mask
|
||||
};
|
||||
|
||||
/// Battle check target [Skotlex]
|
||||
enum e_battle_check_target : uint32 {
|
||||
BCT_NOONE = 0x000000, ///< No one
|
||||
BCT_SELF = 0x010000, ///< Self
|
||||
BCT_ENEMY = 0x020000, ///< Enemy
|
||||
BCT_PARTY = 0x040000, ///< Party members
|
||||
BCT_GUILDALLY = 0x080000, ///< Only allies, NOT guildmates
|
||||
BCT_NEUTRAL = 0x100000, ///< Neutral target
|
||||
BCT_SAMEGUILD = 0x200000, ///< Guildmates, No Guild Allies
|
||||
|
||||
BCT_ALL = 0x3F0000, ///< All targets
|
||||
|
||||
BCT_WOS = 0x400000, ///< Except self (currently used for skipping if src == bl in skill_area_sub)
|
||||
BCT_GUILD = BCT_SAMEGUILD|BCT_GUILDALLY, ///< Guild AND Allies (BCT_SAMEGUILD|BCT_GUILDALLY)
|
||||
BCT_NOGUILD = BCT_ALL&~BCT_GUILD, ///< Except guildmates
|
||||
BCT_NOPARTY = BCT_ALL&~BCT_PARTY, ///< Except party members
|
||||
BCT_NOENEMY = BCT_ALL&~BCT_ENEMY, ///< Except enemy
|
||||
BCT_ALLY = BCT_PARTY|BCT_GUILD,
|
||||
BCT_FRIEND = BCT_NOENEMY,
|
||||
};
|
||||
|
||||
/// Check flag for common damage bonuses such as: ATKpercent, Refine, Passive Mastery, Spirit Spheres and Star Crumbs
|
||||
enum e_bonus_chk_flag : uint8 {
|
||||
BCHK_ALL, /// Check if all of the common damage bonuses apply to this skill
|
||||
BCHK_REFINE, /// Check if refine bonus is applied (pre-renewal only currently)
|
||||
BCHK_STAR, /// Check if Star Crumb bonus is applied (pre-renewal only currently)
|
||||
};
|
||||
|
||||
/// Damage structure
|
||||
struct Damage {
|
||||
#ifdef RENEWAL
|
||||
int64 statusAtk, statusAtk2, weaponAtk, weaponAtk2, equipAtk, equipAtk2, masteryAtk, masteryAtk2, percentAtk, percentAtk2;
|
||||
#else
|
||||
int64 basedamage; /// Right hand damage that a normal attack would deal
|
||||
#endif
|
||||
int64 damage, /// Right hand damage
|
||||
damage2; /// Left hand damage
|
||||
enum e_damage_type type; /// Check clif_damage for type
|
||||
short div_; /// Number of hit
|
||||
int amotion,
|
||||
dmotion;
|
||||
int blewcount; /// Number of knockback
|
||||
int flag; /// chk e_battle_flag
|
||||
int miscflag;
|
||||
enum damage_lv dmg_lv; /// ATK_LUCKY,ATK_FLEE,ATK_DEF
|
||||
bool isspdamage; /// Display blue damage numbers in clif_damage
|
||||
};
|
||||
|
||||
// Damage Calculation
|
||||
|
||||
struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct block_list *target,uint16 skill_id,uint16 skill_lv,int flag);
|
||||
|
||||
int64 battle_calc_return_damage(struct block_list *bl, struct block_list *src, int64 *, int flag, uint16 skill_id, bool status_reflect);
|
||||
|
||||
void battle_drain(map_session_data *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int class_);
|
||||
|
||||
int64 battle_attr_fix(struct block_list* src, struct block_list* target, int64 damage, int atk_elem, int def_type, int def_lv, int flag = 0);
|
||||
int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_list *target, std::bitset<NK_MAX> nk, int s_ele, int s_ele_, int64 damage, int left, int flag);
|
||||
|
||||
// Final calculation Damage
|
||||
int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv);
|
||||
int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 damage,uint16 skill_id,int flag);
|
||||
int64 battle_calc_bg_damage(struct block_list *src,struct block_list *bl,int64 damage,uint16 skill_id,int flag);
|
||||
int64 battle_calc_pk_damage(block_list &src, block_list &bl, int64 damage, uint16 skill_id, int flag);
|
||||
|
||||
int battle_damage(struct block_list *src, struct block_list *target, int64 damage, t_tick delay, uint16 skill_lv, uint16 skill_id, enum damage_lv dmg_lv, unsigned short attack_type, bool additional_effects, t_tick tick, bool spdamage);
|
||||
int battle_delay_damage (t_tick tick, int amotion, struct block_list *src, struct block_list *target, int attack_type, uint16 skill_id, uint16 skill_lv, int64 damage, enum damage_lv dmg_lv, t_tick ddelay, bool additional_effects, bool spdamage);
|
||||
int battle_fix_damage(struct block_list* src, struct block_list* target, int64 damage, t_tick walkdelay, uint16 skill_id);
|
||||
|
||||
int battle_calc_chorusbonus(map_session_data *sd);
|
||||
|
||||
// Summary normal attack treatment (basic attack)
|
||||
enum damage_lv battle_weapon_attack( struct block_list *bl,struct block_list *target,t_tick tick,int flag);
|
||||
|
||||
// Accessors
|
||||
struct block_list* battle_get_master(struct block_list *src);
|
||||
struct block_list* battle_gettargeted(struct block_list *target);
|
||||
struct block_list* battle_getenemy(struct block_list *target, int type, int range);
|
||||
int battle_gettarget(struct block_list *bl);
|
||||
uint16 battle_getcurrentskill(struct block_list *bl);
|
||||
|
||||
int battle_check_undead(int race,int element);
|
||||
int battle_check_target(struct block_list *src, struct block_list *target,int flag);
|
||||
bool battle_check_range(struct block_list *src,struct block_list *bl,int range);
|
||||
bool battle_check_coma(map_session_data& sd, struct block_list& target, e_battle_flag attack_type);
|
||||
|
||||
void battle_consume_ammo(map_session_data* sd, int skill, int lv);
|
||||
|
||||
bool is_infinite_defense(struct block_list *target, int flag);
|
||||
|
||||
// Settings
|
||||
|
||||
#define MIN_HAIR_STYLE battle_config.min_hair_style
|
||||
#define MAX_HAIR_STYLE battle_config.max_hair_style
|
||||
#define MIN_HAIR_COLOR battle_config.min_hair_color
|
||||
#define MAX_HAIR_COLOR battle_config.max_hair_color
|
||||
#define MIN_CLOTH_COLOR battle_config.min_cloth_color
|
||||
#define MAX_CLOTH_COLOR battle_config.max_cloth_color
|
||||
#define MIN_BODY_STYLE battle_config.min_body_style
|
||||
#define MAX_BODY_STYLE battle_config.max_body_style
|
||||
|
||||
struct Battle_Config
|
||||
{
|
||||
int warp_point_debug;
|
||||
int enable_critical;
|
||||
int mob_critical_rate;
|
||||
int critical_rate;
|
||||
int enable_baseatk, enable_baseatk_renewal;
|
||||
int enable_perfect_flee;
|
||||
int cast_rate, delay_rate;
|
||||
int delay_dependon_dex, delay_dependon_agi;
|
||||
int sdelay_attack_enable;
|
||||
int left_cardfix_to_right;
|
||||
int cardfix_monster_physical;
|
||||
int skill_add_range;
|
||||
int skill_out_range_consume;
|
||||
int skill_amotion_leniency;
|
||||
int skillrange_by_distance; //[Skotlex]
|
||||
int use_weapon_skill_range; //[Skotlex]
|
||||
int pc_damage_delay_rate;
|
||||
int defnotenemy;
|
||||
int vs_traps_bctall;
|
||||
int traps_setting;
|
||||
int summon_flora; //[Skotlex]
|
||||
int clear_unit_ondeath; //[Skotlex]
|
||||
int clear_unit_onwarp; //[Skotlex]
|
||||
int random_monster_checklv;
|
||||
int attr_recover;
|
||||
int item_auto_get;
|
||||
int flooritem_lifetime;
|
||||
int item_first_get_time;
|
||||
int item_second_get_time;
|
||||
int item_third_get_time;
|
||||
int mvp_item_first_get_time;
|
||||
int mvp_item_second_get_time;
|
||||
int mvp_item_third_get_time;
|
||||
int base_exp_rate,job_exp_rate;
|
||||
int drop_rate0item;
|
||||
int death_penalty_type;
|
||||
int death_penalty_base,death_penalty_job;
|
||||
int pvp_exp; // [MouseJstr]
|
||||
int gtb_sc_immunity;
|
||||
int zeny_penalty;
|
||||
int restart_hp_rate;
|
||||
int restart_sp_rate;
|
||||
int mvp_exp_rate;
|
||||
int mvp_hp_rate;
|
||||
int monster_hp_rate;
|
||||
int monster_max_aspd;
|
||||
int view_range_rate;
|
||||
int chase_range_rate;
|
||||
int atc_spawn_quantity_limit;
|
||||
int atc_slave_clone_limit;
|
||||
int partial_name_scan;
|
||||
int skillfree;
|
||||
int skillup_limit;
|
||||
int wp_rate;
|
||||
int pp_rate;
|
||||
int monster_active_enable;
|
||||
int monster_damage_delay_rate;
|
||||
int monster_loot_type;
|
||||
int mob_skill_rate; //[Skotlex]
|
||||
int mob_skill_delay; //[Skotlex]
|
||||
int mob_count_rate;
|
||||
int no_spawn_on_player; //[Skotlex]
|
||||
int force_random_spawn; //[Skotlex]
|
||||
int mob_spawn_delay, plant_spawn_delay, boss_spawn_delay; // [Skotlex]
|
||||
int slaves_inherit_mode;
|
||||
int slaves_inherit_speed;
|
||||
int summons_trigger_autospells;
|
||||
int pc_walk_delay_rate; //Adjusts can't walk delay after being hit for players. [Skotlex]
|
||||
int walk_delay_rate; //Adjusts can't walk delay after being hit. [Skotlex]
|
||||
int multihit_delay; //Adjusts can't walk delay per hit on multi-hitting skills. [Skotlex]
|
||||
int quest_skill_learn;
|
||||
int quest_skill_reset;
|
||||
int basic_skill_check;
|
||||
int guild_emperium_check;
|
||||
int guild_exp_limit;
|
||||
int guild_max_castles;
|
||||
int guild_skill_relog_delay;
|
||||
int guild_skill_relog_type;
|
||||
int emergency_call;
|
||||
int guild_aura;
|
||||
int pc_invincible_time;
|
||||
|
||||
int pet_catch_rate;
|
||||
int pet_rename;
|
||||
int pet_friendly_rate;
|
||||
int pet_hungry_delay_rate;
|
||||
int pet_hungry_friendly_decrease;
|
||||
int pet_status_support;
|
||||
int pet_attack_support;
|
||||
int pet_damage_support;
|
||||
int pet_support_min_friendly; //[Skotlex]
|
||||
int pet_support_rate;
|
||||
int pet_attack_exp_to_master;
|
||||
int pet_attack_exp_rate;
|
||||
int pet_lv_rate; //[Skotlex]
|
||||
int pet_max_stats; //[Skotlex]
|
||||
int pet_max_atk1; //[Skotlex]
|
||||
int pet_max_atk2; //[Skotlex]
|
||||
int pet_no_gvg; //Disables pets in gvg. [Skotlex]
|
||||
int pet_equip_required;
|
||||
int pet_unequip_destroy;
|
||||
int pet_master_dead;
|
||||
|
||||
int skill_min_damage;
|
||||
int finger_offensive_type;
|
||||
int heal_exp;
|
||||
int max_heal_lv;
|
||||
int max_heal; //Mitternacht
|
||||
int resurrection_exp;
|
||||
int shop_exp;
|
||||
int combo_delay_rate;
|
||||
int item_check;
|
||||
int item_use_interval; //[Skotlex]
|
||||
int cashfood_use_interval;
|
||||
int wedding_modifydisplay;
|
||||
int wedding_ignorepalette; //[Skotlex]
|
||||
int xmas_ignorepalette; // [Valaris]
|
||||
int summer_ignorepalette; // [Zephyrus]
|
||||
int hanbok_ignorepalette;
|
||||
int oktoberfest_ignorepalette;
|
||||
int natural_healhp_interval;
|
||||
int natural_healsp_interval;
|
||||
int natural_heal_skill_interval;
|
||||
int natural_heal_weight_rate;
|
||||
int natural_heal_weight_rate_renewal;
|
||||
int arrow_decrement;
|
||||
int ammo_unequip;
|
||||
int ammo_check_weapon;
|
||||
int max_aspd;
|
||||
int max_walk_speed; //Maximum walking speed after buffs [Skotlex]
|
||||
int max_hp_lv99;
|
||||
int max_hp_lv150;
|
||||
int max_hp;
|
||||
int max_sp;
|
||||
int max_lv, aura_lv;
|
||||
int max_parameter, max_baby_parameter;
|
||||
int max_cart_weight;
|
||||
int skill_log;
|
||||
int battle_log;
|
||||
int etc_log;
|
||||
int save_clothcolor;
|
||||
int undead_detect_type;
|
||||
int auto_counter_type;
|
||||
int min_hitrate; //[Skotlex]
|
||||
int max_hitrate; //[Skotlex]
|
||||
int agi_penalty_target;
|
||||
int agi_penalty_type;
|
||||
int agi_penalty_count;
|
||||
int agi_penalty_num;
|
||||
int vit_penalty_target;
|
||||
int vit_penalty_type;
|
||||
int vit_penalty_count;
|
||||
int vit_penalty_num;
|
||||
int weapon_defense_type;
|
||||
int magic_defense_type;
|
||||
int skill_reiteration;
|
||||
int skill_nofootset;
|
||||
int pc_cloak_check_type;
|
||||
int monster_cloak_check_type;
|
||||
int estimation_type;
|
||||
int gvg_short_damage_rate;
|
||||
int gvg_long_damage_rate;
|
||||
int gvg_weapon_damage_rate;
|
||||
int gvg_magic_damage_rate;
|
||||
int gvg_misc_damage_rate;
|
||||
int gvg_flee_penalty;
|
||||
int pk_short_damage_rate;
|
||||
int pk_long_damage_rate;
|
||||
int pk_weapon_damage_rate;
|
||||
int pk_magic_damage_rate;
|
||||
int pk_misc_damage_rate;
|
||||
int mob_changetarget_byskill;
|
||||
int attack_direction_change;
|
||||
int land_skill_limit;
|
||||
int monster_class_change_recover;
|
||||
int produce_item_name_input;
|
||||
int display_skill_fail;
|
||||
int chat_warpportal;
|
||||
int mob_warp;
|
||||
int dead_branch_active;
|
||||
int vending_max_value;
|
||||
int vending_over_max;
|
||||
int vending_tax;
|
||||
int vending_tax_min;
|
||||
int show_steal_in_same_party;
|
||||
int party_share_type;
|
||||
int party_hp_mode;
|
||||
int party_show_share_picker;
|
||||
int show_picker_item_type;
|
||||
int attack_attr_none;
|
||||
int item_rate_mvp, item_rate_common, item_rate_common_boss, item_rate_card, item_rate_card_boss,
|
||||
item_rate_equip, item_rate_equip_boss, item_rate_heal, item_rate_heal_boss, item_rate_use,
|
||||
item_rate_use_boss, item_rate_treasure, item_rate_adddrop;
|
||||
int item_rate_common_mvp, item_rate_heal_mvp, item_rate_use_mvp, item_rate_equip_mvp, item_rate_card_mvp;
|
||||
|
||||
int logarithmic_drops;
|
||||
int item_drop_common_min,item_drop_common_max; // Added by TyrNemesis^
|
||||
int item_drop_card_min,item_drop_card_max;
|
||||
int item_drop_equip_min,item_drop_equip_max;
|
||||
int item_drop_mvp_min,item_drop_mvp_max; // End Addition
|
||||
int item_drop_mvp_mode; //rAthena addition [Playtester]
|
||||
int item_drop_heal_min,item_drop_heal_max; // Added by Valatris
|
||||
int item_drop_use_min,item_drop_use_max; //End
|
||||
int item_drop_treasure_min,item_drop_treasure_max; //by [Skotlex]
|
||||
int item_drop_adddrop_min,item_drop_adddrop_max; //[Skotlex]
|
||||
|
||||
int prevent_logout; // Added by RoVeRT
|
||||
int prevent_logout_trigger;
|
||||
int land_protector_behavior;
|
||||
int npc_emotion_behavior;
|
||||
|
||||
int alchemist_summon_reward; // [Valaris]
|
||||
int drops_by_luk;
|
||||
int drops_by_luk2;
|
||||
int equip_natural_break_rate; //Base Natural break rate for attacks.
|
||||
int equip_self_break_rate; //Natural & Penalty skills break rate
|
||||
int equip_skill_break_rate; //Offensive skills break rate
|
||||
int multi_level_up;
|
||||
int multi_level_up_base;
|
||||
int multi_level_up_job;
|
||||
int max_exp_gain_rate; //Max amount of exp bar % you can get in one go.
|
||||
int pk_mode;
|
||||
int pk_mode_mes;
|
||||
int pk_level_range;
|
||||
|
||||
int manner_system; // end additions [Valaris]
|
||||
int show_mob_info;
|
||||
|
||||
int gx_allhit;
|
||||
int gx_disptype;
|
||||
int devotion_level_difference;
|
||||
int player_skill_partner_check;
|
||||
int invite_request_check;
|
||||
int skill_removetrap_type;
|
||||
int disp_experience;
|
||||
int disp_zeny;
|
||||
int backstab_bow_penalty;
|
||||
int hp_rate;
|
||||
int sp_rate;
|
||||
int bone_drop;
|
||||
int buyer_name;
|
||||
int dancing_weaponswitch_fix;
|
||||
|
||||
// eAthena additions
|
||||
int night_at_start; // added by [Yor]
|
||||
int day_duration; // added by [Yor]
|
||||
int night_duration; // added by [Yor]
|
||||
int ban_hack_trade; // added by [Yor]
|
||||
|
||||
int min_hair_style; // added by [MouseJstr]
|
||||
int max_hair_style; // added by [MouseJstr]
|
||||
int min_hair_color; // added by [MouseJstr]
|
||||
int max_hair_color; // added by [MouseJstr]
|
||||
int min_cloth_color; // added by [MouseJstr]
|
||||
int max_cloth_color; // added by [MouseJstr]
|
||||
int pet_hair_style; // added by [Skotlex]
|
||||
|
||||
int castrate_dex_scale; // added by [MouseJstr]
|
||||
int area_size; // added by [MouseJstr]
|
||||
|
||||
int max_def, over_def_bonus; //added by [Skotlex]
|
||||
|
||||
int zeny_from_mobs; // [Valaris]
|
||||
int mobs_level_up; // [Valaris]
|
||||
int mobs_level_up_exp_rate; // [Valaris]
|
||||
int pk_min_level; // [celest]
|
||||
int skill_steal_max_tries; //max steal skill tries on a mob. if 0, then w/o limit [Lupus]
|
||||
int skill_steal_random_options;
|
||||
int motd_type; // [celest]
|
||||
int finding_ore_rate; // orn
|
||||
int exp_calc_type;
|
||||
int exp_bonus_attacker;
|
||||
int exp_bonus_max_attacker;
|
||||
int min_skill_delay_limit;
|
||||
int default_walk_delay;
|
||||
int no_skill_delay;
|
||||
int attack_walk_delay;
|
||||
int require_glory_guild;
|
||||
int idle_no_share;
|
||||
int party_update_interval;
|
||||
int party_even_share_bonus;
|
||||
int delay_battle_damage;
|
||||
int hide_woe_damage;
|
||||
int display_version;
|
||||
|
||||
int display_hallucination; // [Skotlex]
|
||||
int use_statpoint_table; // [Skotlex]
|
||||
|
||||
int debuff_on_logout; // Removes a few "official" negative Scs on logout. [Skotlex]
|
||||
int mob_ai; //Configures various mob_ai settings to make them smarter or dumber(official). [Skotlex]
|
||||
int hom_setting; //Configures various homunc settings which make them behave unlike normal characters.. [Skotlex]
|
||||
int dynamic_mobs; // Dynamic Mobs [Wizputer] - battle_athena flag implemented by [random]
|
||||
int mob_remove_damaged; // Dynamic Mobs - Remove mobs even if damaged [Wizputer]
|
||||
int mob_remove_delay; // Dynamic Mobs - delay before removing mobs from a map [Skotlex]
|
||||
int mob_active_time; //Duration through which mobs execute their Hard AI after players leave their area of sight.
|
||||
int boss_active_time;
|
||||
|
||||
int show_hp_sp_drain, show_hp_sp_gain; //[Skotlex]
|
||||
|
||||
int mob_npc_event_type; //Determines on who the npc_event is executed. [Skotlex]
|
||||
|
||||
int character_size; // if riders have size=2, and baby class riders size=1 [Lupus]
|
||||
int mob_max_skilllvl; // Max possible skill level [Lupus]
|
||||
int rare_drop_announce; // chance <= to show rare drops global announces
|
||||
int drop_rate_cap; // Drop rate can't be raised above this amount by drop bonus items
|
||||
int drop_rate_cap_vip;
|
||||
|
||||
int retaliate_to_master; //Whether when a mob is attacked by another mob, it will retaliate versus the mob or the mob's master. [Skotlex]
|
||||
|
||||
int duel_allow_pvp; // [LuzZza]
|
||||
int duel_allow_gvg; // [LuzZza]
|
||||
int duel_allow_teleport; // [LuzZza]
|
||||
int duel_autoleave_when_die; // [LuzZza]
|
||||
int duel_time_interval; // [LuzZza]
|
||||
int duel_only_on_same_map; // [Toms]
|
||||
|
||||
int skip_teleport_lv1_menu; // possibility to disable (skip) Teleport Lv1 menu, that have only two lines `Random` and `Cancel` [LuzZza]
|
||||
|
||||
int allow_skill_without_day; // [Komurka]
|
||||
int allow_es_magic_pc; // [Skotlex]
|
||||
int skill_wall_check; // [Skotlex]
|
||||
int official_cell_stack_limit; // [Playtester]
|
||||
int custom_cell_stack_limit; // [Skotlex]
|
||||
int skill_caster_check; // [Skotlex]
|
||||
int sc_castcancel; // [Skotlex]
|
||||
int pc_sc_def_rate; // [Skotlex]
|
||||
int mob_sc_def_rate;
|
||||
int pc_max_sc_def;
|
||||
int mob_max_sc_def;
|
||||
|
||||
int sg_angel_skill_ratio;
|
||||
int sg_miracle_skill_ratio;
|
||||
int sg_miracle_skill_duration;
|
||||
int autospell_stacking; //Enables autospell cards to stack. [Skotlex]
|
||||
int override_mob_names; //Enables overriding spawn mob names with the mob_db names. [Skotlex]
|
||||
int min_chat_delay; //Minimum time between client messages. [Skotlex]
|
||||
int friend_auto_add; //When accepting friends, both get friended. [Skotlex]
|
||||
int hvan_explosion_intimate; // fix [albator]
|
||||
int hom_rename;
|
||||
int homunculus_show_growth ; //[orn]
|
||||
int homunculus_friendly_rate;
|
||||
int quest_exp_rate;
|
||||
int autotrade_mapflag;
|
||||
int at_timeout;
|
||||
int homunculus_autoloot;
|
||||
int idle_no_autoloot;
|
||||
int max_guild_alliance;
|
||||
int ksprotection;
|
||||
int auction_feeperhour;
|
||||
int auction_maximumprice;
|
||||
int homunculus_auto_vapor; //Keep Homunculus from Vaporizing when master dies. [L0ne_W0lf]
|
||||
int display_status_timers; //Show or hide skill buff/delay timers in recent clients [Sara]
|
||||
int skill_add_heal_rate; //skills that bHealPower has effect on [Inkfish]
|
||||
int eq_single_target_reflectable;
|
||||
int invincible_nodamage;
|
||||
int mob_slave_keep_target;
|
||||
int autospell_check_range; //Enable range check for autospell bonus. [L0ne_W0lf]
|
||||
int knockback_left;
|
||||
int client_reshuffle_dice; // Reshuffle /dice
|
||||
int client_sort_storage;
|
||||
int feature_buying_store;
|
||||
int feature_search_stores;
|
||||
int searchstore_querydelay;
|
||||
int searchstore_maxresults;
|
||||
int display_party_name;
|
||||
int cashshop_show_points;
|
||||
int mail_show_status;
|
||||
int client_limit_unit_lv;
|
||||
int hom_max_level;
|
||||
int hom_S_max_level;
|
||||
int hom_S_growth_level;
|
||||
|
||||
// [BattleGround Settings]
|
||||
int bg_update_interval;
|
||||
int bg_short_damage_rate;
|
||||
int bg_long_damage_rate;
|
||||
int bg_weapon_damage_rate;
|
||||
int bg_magic_damage_rate;
|
||||
int bg_misc_damage_rate;
|
||||
int bg_flee_penalty;
|
||||
|
||||
// rAthena
|
||||
int max_third_parameter;
|
||||
int max_baby_third_parameter;
|
||||
int max_trans_parameter;
|
||||
int max_third_trans_parameter;
|
||||
int max_extended_parameter;
|
||||
int max_summoner_parameter;
|
||||
int max_fourth_parameter;
|
||||
int max_third_aspd;
|
||||
int max_summoner_aspd;
|
||||
int vcast_stat_scale;
|
||||
|
||||
int mvp_tomb_enabled;
|
||||
int mvp_tomb_delay;
|
||||
|
||||
int atcommand_suggestions_enabled;
|
||||
int min_npc_vendchat_distance;
|
||||
int atcommand_mobinfo_type;
|
||||
|
||||
int mob_size_influence; // Enable modifications on earned experience, drop rates and monster status depending on monster size. [mkbu95]
|
||||
int skill_trap_type;
|
||||
int allow_consume_restricted_item;
|
||||
int allow_equip_restricted_item;
|
||||
int max_walk_path;
|
||||
int item_enabled_npc;
|
||||
int item_onfloor; // Whether to drop an undroppable item on the map or destroy it if inventory is full.
|
||||
int bowling_bash_area;
|
||||
int drop_rateincrease;
|
||||
int feature_auction;
|
||||
int feature_banking;
|
||||
int vip_storage_increase;
|
||||
int vip_base_exp_increase;
|
||||
int vip_job_exp_increase;
|
||||
int vip_zeny_penalty;
|
||||
int vip_bm_increase;
|
||||
int vip_drop_increase;
|
||||
int vip_gemstone;
|
||||
int vip_exp_penalty_base;
|
||||
int vip_exp_penalty_job;
|
||||
int vip_disp_rate;
|
||||
int mon_trans_disable_in_gvg;
|
||||
int discount_item_point_shop;
|
||||
int update_enemy_position;
|
||||
int devotion_rdamage;
|
||||
int feature_itemlink;
|
||||
int feature_mesitemlink;
|
||||
int feature_mesitemlink_brackets;
|
||||
int feature_mesitemlink_dbname;
|
||||
|
||||
// autotrade persistency
|
||||
int feature_autotrade;
|
||||
int feature_autotrade_direction;
|
||||
int feature_autotrade_head_direction;
|
||||
int feature_autotrade_sit;
|
||||
int feature_autotrade_open_delay;
|
||||
|
||||
// Fame points
|
||||
int fame_taekwon_mission;
|
||||
int fame_refine_lv1;
|
||||
int fame_refine_lv2;
|
||||
int fame_refine_lv3;
|
||||
int fame_forge;
|
||||
int fame_pharmacy_3;
|
||||
int fame_pharmacy_5;
|
||||
int fame_pharmacy_7;
|
||||
int fame_pharmacy_10;
|
||||
|
||||
int disp_servervip_msg;
|
||||
int warg_can_falcon;
|
||||
int path_blown_halt;
|
||||
int rental_mount_speed_boost;
|
||||
int warp_suggestions_enabled;
|
||||
int taekwon_mission_mobname;
|
||||
int teleport_on_portal;
|
||||
int cart_revo_knockback;
|
||||
int guild_notice_changemap;
|
||||
int transcendent_status_points;
|
||||
int taekwon_ranker_min_lv;
|
||||
int revive_onwarp;
|
||||
int mail_delay;
|
||||
int autotrade_monsterignore;
|
||||
int idletime_option;
|
||||
int spawn_direction;
|
||||
int arrow_shower_knockback;
|
||||
int devotion_rdamage_skill_only;
|
||||
int max_extended_aspd;
|
||||
int mob_chase_refresh; //How often a monster should refresh its chase [Playtester]
|
||||
int mob_icewall_walk_block; //How a normal monster should be trapped in icewall [Playtester]
|
||||
int boss_icewall_walk_block; //How a boss monster should be trapped in icewall [Playtester]
|
||||
int snap_dodge; // Enable or disable dodging damage snapping away [csnv]
|
||||
int stormgust_knockback;
|
||||
int default_fixed_castrate;
|
||||
int default_bind_on_equip;
|
||||
int pet_ignore_infinite_def; // Makes fixed damage of petskillattack2 ignores infinite defense
|
||||
int homunculus_evo_intimacy_need;
|
||||
int homunculus_evo_intimacy_reset;
|
||||
int monster_loot_search_type;
|
||||
int feature_roulette;
|
||||
int feature_roulette_bonus_reward;
|
||||
int monster_hp_bars_info;
|
||||
int min_body_style;
|
||||
int max_body_style;
|
||||
int save_body_style;
|
||||
int mob_eye_range_bonus; //Vulture's Eye and Snake's Eye range bonus
|
||||
int mob_stuck_warning; //Show warning if a monster is stuck too long
|
||||
int skill_eightpath_algorithm; //Official path algorithm
|
||||
int skill_eightpath_same_cell;
|
||||
int death_penalty_maxlv;
|
||||
int exp_cost_redemptio;
|
||||
int exp_cost_redemptio_limit;
|
||||
int mvp_exp_reward_message;
|
||||
int can_damage_skill; //Which BL types can damage traps
|
||||
int atcommand_levelup_events;
|
||||
int atcommand_disable_npc;
|
||||
int block_account_in_same_party;
|
||||
int tarotcard_equal_chance; //Official or equal chance for each card
|
||||
int change_party_leader_samemap;
|
||||
int dispel_song; //Can songs be dispelled?
|
||||
int guild_maprespawn_clones; // Should clones be killed by maprespawnguildid?
|
||||
int hide_fav_sell;
|
||||
int mail_daily_count;
|
||||
int mail_zeny_fee;
|
||||
int mail_attachment_price;
|
||||
int mail_attachment_weight;
|
||||
int banana_bomb_duration;
|
||||
int guild_leaderchange_delay;
|
||||
int guild_leaderchange_woe;
|
||||
int guild_alliance_onlygm;
|
||||
int feature_achievement;
|
||||
int allow_bound_sell;
|
||||
int autoloot_adjust;
|
||||
int feature_petevolution;
|
||||
int feature_pet_autofeed;
|
||||
int feature_pet_autofeed_rate;
|
||||
int pet_autofeed_always;
|
||||
int broadcast_hide_name;
|
||||
int skill_drop_items_full;
|
||||
int switch_remove_edp;
|
||||
int feature_homunculus_autofeed;
|
||||
int feature_homunculus_autofeed_rate;
|
||||
int summoner_race;
|
||||
int summoner_size;
|
||||
int homunculus_autofeed_always;
|
||||
int feature_attendance;
|
||||
int feature_privateairship;
|
||||
int rental_transaction;
|
||||
int min_shop_buy;
|
||||
int min_shop_sell;
|
||||
int feature_equipswitch;
|
||||
int pet_walk_speed;
|
||||
int blacksmith_fame_refine_threshold;
|
||||
int mob_nopc_idleskill_rate;
|
||||
int mob_nopc_move_rate;
|
||||
int boss_nopc_idleskill_rate;
|
||||
int boss_nopc_move_rate;
|
||||
int hom_idle_no_share;
|
||||
int idletime_hom_option;
|
||||
int devotion_standup_fix;
|
||||
int feature_bgqueue;
|
||||
int bgqueue_nowarp_mapflag;
|
||||
int homunculus_exp_gain;
|
||||
int rental_item_novalue;
|
||||
int ping_timer_interval;
|
||||
int ping_time;
|
||||
int show_skill_scale;
|
||||
int achievement_mob_share;
|
||||
int slave_stick_with_master;
|
||||
int at_logout_event;
|
||||
int homunculus_starving_rate;
|
||||
int homunculus_starving_delay;
|
||||
int drop_connection_on_quit;
|
||||
int mob_spawn_variance;
|
||||
int mercenary_autoloot;
|
||||
int mer_idle_no_share;
|
||||
int idletime_mer_option;
|
||||
int feature_refineui;
|
||||
int rndopt_drop_pillar;
|
||||
int pet_legacy_formula;
|
||||
int pet_distance_check;
|
||||
int pet_hide_check;
|
||||
|
||||
int instance_block_leave;
|
||||
int instance_block_leaderchange;
|
||||
int instance_block_invite;
|
||||
int instance_block_expulsion;
|
||||
// 4th Jobs Stuff
|
||||
int trait_points_job_change;
|
||||
int use_traitpoint_table;
|
||||
int max_trait_parameter;
|
||||
int max_res_mres_ignored;
|
||||
int max_ap;
|
||||
int ap_rate;
|
||||
int restart_ap_rate;
|
||||
int loose_ap_on_death;
|
||||
int loose_ap_on_map;
|
||||
int keep_ap_on_logout;
|
||||
int attack_machine_level_difference;
|
||||
|
||||
int feature_barter;
|
||||
int feature_barter_extended;
|
||||
int break_mob_equip;
|
||||
int macro_detection_retry;
|
||||
int macro_detection_timeout;
|
||||
int macro_detection_punishment;
|
||||
int macro_detection_punishment_time;
|
||||
|
||||
int feature_dynamicnpc_timeout;
|
||||
int feature_dynamicnpc_rangex;
|
||||
int feature_dynamicnpc_rangey;
|
||||
int feature_dynamicnpc_direction;
|
||||
|
||||
int mob_respawn_time;
|
||||
int mob_unlock_time;
|
||||
int map_edge_size;
|
||||
int randomize_center_cell;
|
||||
|
||||
int feature_stylist;
|
||||
int feature_banking_state_enforce;
|
||||
int instance_allow_reconnect;
|
||||
int synchronize_damage;
|
||||
int item_stacking;
|
||||
int hom_delay_reset_vaporize;
|
||||
int hom_delay_reset_warp;
|
||||
|
||||
#include <custom/battle_config_struct.inc>
|
||||
};
|
||||
|
||||
extern struct Battle_Config battle_config;
|
||||
|
||||
void do_init_battle(void);
|
||||
void do_final_battle(void);
|
||||
extern int battle_config_read(const char *cfgName);
|
||||
extern void battle_set_defaults(void);
|
||||
int battle_set_value(const char* w1, const char* w2);
|
||||
int battle_get_value(const char* w1);
|
||||
|
||||
//
|
||||
struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int range, int type, int ignore_id);
|
||||
/**
|
||||
* Royal Guard
|
||||
**/
|
||||
int battle_damage_area( struct block_list *bl, va_list ap);
|
||||
|
||||
#endif /* BATTLE_HPP */
|
@ -0,0 +1,825 @@
|
||||
// Copyright (c) 4lexKidd
|
||||
// This software is licensed under the GPL v3 as to be fitting with the rathena project with the additional requirement
|
||||
// that any distributed versions must include an attribution to the original author (4lexKidd) in all copies
|
||||
// or substantial portions of the software.
|
||||
|
||||
|
||||
#include "bot_account.hpp"
|
||||
|
||||
#include <algorithm> //min / max
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <common/malloc.hpp>
|
||||
#include <common/mmo.hpp>
|
||||
#include <common/showmsg.hpp>
|
||||
#include <common/socket.hpp>
|
||||
#include <common/sql.hpp>
|
||||
#include <common/strlib.hpp>
|
||||
|
||||
#include "brokk.hpp" // brokk_config
|
||||
|
||||
/// global defines
|
||||
|
||||
/// internal structure
|
||||
typedef struct BotAccountDB_SQL {
|
||||
BotAccountDB vtable; // public interface
|
||||
Sql* bot_accounts; // SQL handle bot accounts storage
|
||||
std::string db_hostname = "127.0.0.1";
|
||||
uint16 db_port = 3306;
|
||||
std::string db_username = "ragnarok";
|
||||
std::string db_password = "ragnarok";
|
||||
std::string db_database = "ragnarok";
|
||||
std::string codepage = "";
|
||||
// other settings
|
||||
bool case_sensitive;
|
||||
//table name
|
||||
char bot_account_db[32];
|
||||
char login_account_db[32];
|
||||
char global_acc_reg_num_table[32];
|
||||
char global_acc_reg_str_table[32];
|
||||
|
||||
} BotAccountDB_SQL;
|
||||
|
||||
/// internal structure
|
||||
typedef struct BotAccountDBIterator_SQL {
|
||||
BotAccountDBIterator vtable; // public interface
|
||||
BotAccountDB_SQL* db;
|
||||
int last_bot_account_id;
|
||||
} BotAccountDBIterator_SQL;
|
||||
|
||||
/// internal functions
|
||||
static bool bot_account_db_sql_init(BotAccountDB* self);
|
||||
static void bot_account_db_sql_destroy(BotAccountDB* self);
|
||||
static bool bot_account_db_sql_get_property(BotAccountDB* self, const char* key, char* buf, size_t buflen);
|
||||
static bool bot_account_db_sql_set_property(BotAccountDB* self, const char* option, const char* value);
|
||||
static bool bot_account_db_sql_create(BotAccountDB* self, struct mmo_bot_account* bot_acc);
|
||||
static bool bot_account_db_sql_remove(BotAccountDB* self, const uint32 account_id);
|
||||
static bool bot_account_db_sql_save(BotAccountDB* self, const struct mmo_bot_account* bot_acc, bool refresh_token);
|
||||
static bool bot_account_db_sql_load_num(BotAccountDB* self, struct mmo_bot_account* bot_acc, const uint32 account_id);
|
||||
static bool bot_account_db_sql_load_str(BotAccountDB* self, struct mmo_bot_account* bot_acc, const char* creator_name);
|
||||
static BotAccountDBIterator* bot_account_db_sql_iterator(BotAccountDB* self);
|
||||
static void bot_account_db_sql_iter_destroy(BotAccountDBIterator* self);
|
||||
static bool bot_account_db_sql_iter_next(BotAccountDBIterator* self, struct mmo_bot_account* bot_acc);
|
||||
static bool mmo_bot_auth_fromsql(BotAccountDB_SQL* db, struct mmo_bot_account* bot_acc, uint32 account_id);
|
||||
static bool mmo_bot_auth_tosql(BotAccountDB_SQL* db, const struct mmo_bot_account* bot_acc, bool is_new, bool refresh_token);
|
||||
|
||||
/// public constructor
|
||||
BotAccountDB* bot_account_db_sql(void) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)aCalloc(1, sizeof(BotAccountDB_SQL));
|
||||
new(db) BotAccountDB_SQL();
|
||||
|
||||
// set up the vtable
|
||||
db->vtable.init = &bot_account_db_sql_init;
|
||||
db->vtable.destroy = &bot_account_db_sql_destroy;
|
||||
db->vtable.get_property = &bot_account_db_sql_get_property;
|
||||
db->vtable.set_property = &bot_account_db_sql_set_property;
|
||||
db->vtable.save = &bot_account_db_sql_save;
|
||||
db->vtable.create = &bot_account_db_sql_create;
|
||||
db->vtable.remove = &bot_account_db_sql_remove;
|
||||
db->vtable.load_num = &bot_account_db_sql_load_num;
|
||||
db->vtable.load_str = &bot_account_db_sql_load_str;
|
||||
db->vtable.iterator = &bot_account_db_sql_iterator;
|
||||
|
||||
// initialize to default values
|
||||
db->bot_accounts = nullptr;
|
||||
|
||||
// other settings
|
||||
db->case_sensitive = false;
|
||||
safestrncpy(db->bot_account_db, "bot_accounts", sizeof(db->bot_account_db));
|
||||
safestrncpy(db->login_account_db, "login", sizeof(db->login_account_db));
|
||||
//safestrncpy(db->global_acc_reg_num_table, "global_acc_reg_num", sizeof(db->global_acc_reg_num_table));
|
||||
//safestrncpy(db->global_acc_reg_str_table, "global_acc_reg_str", sizeof(db->global_acc_reg_str_table));
|
||||
|
||||
return &db->vtable;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/**
|
||||
* Establish the database connection.
|
||||
* @param self: pointer to db
|
||||
*/
|
||||
static bool bot_account_db_sql_init(BotAccountDB* self) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
Sql* sql_handle;
|
||||
|
||||
db->bot_accounts = Sql_Malloc();
|
||||
sql_handle = db->bot_accounts;
|
||||
|
||||
if (SQL_ERROR == Sql_Connect(sql_handle, db->db_username.c_str(), db->db_password.c_str(), db->db_hostname.c_str(), db->db_port, db->db_database.c_str()))
|
||||
{
|
||||
ShowError("Couldn't connect with uname='%s',host='%s',port='%hu',database='%s'\n",
|
||||
db->db_username.c_str(), db->db_hostname.c_str(), db->db_port, db->db_database.c_str());
|
||||
Sql_ShowDebug(sql_handle);
|
||||
Sql_Free(db->bot_accounts);
|
||||
db->bot_accounts = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!db->codepage.empty() && SQL_ERROR == Sql_SetEncoding(sql_handle, db->codepage.c_str()))
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
//self->remove_webtokens( self );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the database and close the connection to it.
|
||||
* @param self: pointer to db
|
||||
*/
|
||||
static void bot_account_db_sql_destroy(BotAccountDB* self){
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
|
||||
//if( SQL_ERROR == Sql_Query( db->bot_accounts, "UPDATE `%s` SET `web_auth_token` = NULL", db->bot_account_db ) ){
|
||||
// Sql_ShowDebug( db->accounts );
|
||||
//}
|
||||
|
||||
Sql_Free(db->bot_accounts);
|
||||
db->bot_accounts = nullptr;
|
||||
|
||||
db->~BotAccountDB_SQL();
|
||||
aFree(db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get configuration information into buf.
|
||||
* If the option is supported, adjust the internal state.
|
||||
* @param self: pointer to db
|
||||
* @param key: config keyword
|
||||
* @param buf: value set of the keyword
|
||||
* @param buflen: size of buffer to avoid out of bound
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_get_property(BotAccountDB* self, const char* key, char* buf, size_t buflen)
|
||||
{
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
const char* signature;
|
||||
|
||||
signature = "brokk_server_";
|
||||
if( strncmpi(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "ip") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_hostname.c_str());
|
||||
else
|
||||
if( strcmpi(key, "port") == 0 )
|
||||
safesnprintf(buf, buflen, "%hu", db->db_port);
|
||||
else
|
||||
if( strcmpi(key, "id") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_username.c_str());
|
||||
else
|
||||
if( strcmpi(key, "pw") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_password.c_str());
|
||||
else
|
||||
if( strcmpi(key, "db") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_database.c_str());
|
||||
else
|
||||
if( strcmpi(key, "bot_account_db") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->bot_account_db);
|
||||
//else
|
||||
//if( strcmpi(key, "global_acc_reg_str_table") == 0 )
|
||||
// safesnprintf(buf, buflen, "%s", db->global_acc_reg_str_table);
|
||||
//else
|
||||
//if( strcmpi(key, "global_acc_reg_num_table") == 0 )
|
||||
// safesnprintf(buf, buflen, "%s", db->global_acc_reg_num_table);
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
signature = "brokk_";
|
||||
if( strncmpi(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "codepage") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->codepage.c_str());
|
||||
else
|
||||
if( strcmpi(key, "case_sensitive") == 0 )
|
||||
safesnprintf(buf, buflen, "%d", (db->case_sensitive ? 1 : 0));
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;// not found
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and set configuration.
|
||||
* If the option is supported, adjust the internal state.
|
||||
* @param self: pointer to db
|
||||
* @param key: config keyword
|
||||
* @param value: config value for keyword
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_set_property(BotAccountDB* self, const char* key, const char* value) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
const char* signature;
|
||||
|
||||
signature = "brokk_server_";
|
||||
if( strncmp(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "ip") == 0 )
|
||||
db->db_hostname = value;
|
||||
else
|
||||
if( strcmpi(key, "port") == 0 )
|
||||
db->db_port = (uint16)strtoul( value, nullptr, 10 );
|
||||
else
|
||||
if( strcmpi(key, "id") == 0 )
|
||||
db->db_username = value;
|
||||
else
|
||||
if( strcmpi(key, "pw") == 0 )
|
||||
db->db_password = value;
|
||||
else
|
||||
if( strcmpi(key, "db") == 0 )
|
||||
db->db_database = value;
|
||||
else
|
||||
if( strcmpi(key, "bot_account_db") == 0 )
|
||||
safestrncpy(db->bot_account_db, value, sizeof(db->bot_account_db));
|
||||
else
|
||||
if (strcmpi(key, "login_account_db") == 0)
|
||||
safestrncpy(db->login_account_db, value, sizeof(db->login_account_db));
|
||||
//else
|
||||
//if( strcmpi(key, "global_acc_reg_str_table") == 0 )
|
||||
// safestrncpy(db->global_acc_reg_str_table, value, sizeof(db->global_acc_reg_str_table));
|
||||
//else
|
||||
//if( strcmpi(key, "global_acc_reg_num_table") == 0 )
|
||||
// safestrncpy(db->global_acc_reg_num_table, value, sizeof(db->global_acc_reg_num_table));
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
signature = "brokk_";
|
||||
if( strncmpi(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "codepage") == 0 )
|
||||
db->codepage = value;
|
||||
else
|
||||
if( strcmpi(key, "case_sensitive") == 0 )
|
||||
db->case_sensitive = (config_switch(value)==1);
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;// not found
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new account entry.
|
||||
* acc->account_id = -1 means auto_decidet by server
|
||||
* bot_acc->account_id is always matching its login table counter part,
|
||||
* and its value will be written to bot_acc->account_id if everything succeeds.
|
||||
* @param self: pointer to db
|
||||
* @param acc: pointer of mmo_bot_account to save
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_create(BotAccountDB* self, struct mmo_bot_account* bot_acc) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
Sql* sql_handle_bot = db->bot_accounts;
|
||||
|
||||
// validate account id to assign
|
||||
uint32 account_id;
|
||||
account_id = bot_acc->account_id;
|
||||
|
||||
// zero value is prohibited
|
||||
if( account_id == 0 )
|
||||
return false;
|
||||
|
||||
// absolute maximum
|
||||
if( account_id > END_ACCOUNT_NUM )
|
||||
return false;
|
||||
|
||||
// insert the data into the database
|
||||
bot_acc->account_id = account_id;
|
||||
return mmo_bot_auth_tosql(db, bot_acc, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing bot account entry and its regs.
|
||||
* @param self: pointer to db
|
||||
* @param account_id: id of user account
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_remove(BotAccountDB* self, const uint32 account_id) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
Sql* sql_handle = db->bot_accounts;
|
||||
bool result = false;
|
||||
|
||||
if( SQL_SUCCESS != Sql_QueryStr(sql_handle, "START TRANSACTION")
|
||||
|| SQL_SUCCESS != Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = %d", db->bot_account_db, account_id)
|
||||
)
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else
|
||||
result = true;
|
||||
|
||||
result &= ( SQL_SUCCESS == Sql_QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing bot_account with the new data provided.
|
||||
* @param self: pointer to db
|
||||
* @param bot_acc: pointer of mmo_bot_account to save
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_save(BotAccountDB* self, const struct mmo_bot_account* bot_acc, bool refresh_token) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
return mmo_bot_auth_tosql(db, bot_acc, false, refresh_token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve data from db and store it in the provided data structure.
|
||||
* Filled data structure is done by delegation to mmo_bot_auth_fromsql.
|
||||
* @param self: pointer to db
|
||||
* @param bot_acc: pointer of mmo_bot_account to fill
|
||||
* @param account_id: id of user account
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_load_num(BotAccountDB* self, struct mmo_bot_account* bot_acc, const uint32 account_id) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
return mmo_bot_auth_fromsql(db, bot_acc, account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve data from db and store it in the provided data structure.
|
||||
* Doesn't actually retrieve data yet: escapes and checks userid, then transforms it to accid for fetching.
|
||||
* Filled data structure is done by delegation to bot_account_db_sql_load_num.
|
||||
* This function basicly fetches account_ids of all bots of an account
|
||||
* @param self: pointer to db
|
||||
* @param bot_acc: pointer of mmo_bot_account to fill
|
||||
* @param userid: name of user account
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_load_str(BotAccountDB* self, struct mmo_bot_account* bot_acc, const char* userid) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
Sql* sql_handle = db->bot_accounts;
|
||||
char esc_userid[2*NAME_LENGTH+1];
|
||||
uint32 account_id;
|
||||
char* data;
|
||||
|
||||
Sql_EscapeString(sql_handle, esc_userid, userid);
|
||||
|
||||
// get the list of account IDs for this userid
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `userid`= %s '%s'",
|
||||
db->login_account_db, (db->case_sensitive ? "BINARY" : ""), esc_userid) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( Sql_NumRows(sql_handle) > 1 )
|
||||
{// serious problem - duplicit account
|
||||
ShowError("bot_account_db_sql_load_str: multiple accounts found when retrieving data for account '%s'!\n", userid);
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
{// no such entry
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO FIXME this will only get the first found bot to a creator (Currently not a problem, because only one bot per account)
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr);
|
||||
account_id = atoi(data);
|
||||
|
||||
return bot_account_db_sql_load_num(self, bot_acc, account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new forward iterator.
|
||||
* @param self: pointer to db iterator
|
||||
* @return a new db iterator
|
||||
*/
|
||||
static BotAccountDBIterator* bot_account_db_sql_iterator(BotAccountDB* self) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
BotAccountDBIterator_SQL* iter = (BotAccountDBIterator_SQL*)aCalloc(1, sizeof(BotAccountDBIterator_SQL));
|
||||
|
||||
// set up the vtable
|
||||
iter->vtable.destroy = &bot_account_db_sql_iter_destroy;
|
||||
iter->vtable.next = &bot_account_db_sql_iter_next;
|
||||
|
||||
// fill data
|
||||
iter->db = db;
|
||||
iter->last_bot_account_id = -1;
|
||||
|
||||
return &iter->vtable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys this iterator, releasing all allocated memory (including itself).
|
||||
* @param self: pointer to db iterator
|
||||
*/
|
||||
static void bot_account_db_sql_iter_destroy(BotAccountDBIterator* self) {
|
||||
BotAccountDBIterator_SQL* iter = (BotAccountDBIterator_SQL*)self;
|
||||
aFree(iter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the next account in the database.
|
||||
* @param self: pointer to db iterator
|
||||
* @param bot_acc: pointer of mmo_bot_account to fill
|
||||
* @return true if next account found and filled, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_iter_next(BotAccountDBIterator* self, struct mmo_bot_account* bot_acc) {
|
||||
BotAccountDBIterator_SQL* iter = (BotAccountDBIterator_SQL*)self;
|
||||
BotAccountDB_SQL* db = iter->db;
|
||||
Sql* sql_handle = db->bot_accounts;
|
||||
char* data;
|
||||
|
||||
// get next account ID
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `account_id` > '%d' ORDER BY `account_id` ASC LIMIT 1",
|
||||
db->bot_account_db, iter->last_bot_account_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS == Sql_NextRow(sql_handle) &&
|
||||
SQL_SUCCESS == Sql_GetData(sql_handle, 0, &data, nullptr) &&
|
||||
data != nullptr )
|
||||
{// get account data
|
||||
uint32 account_id;
|
||||
account_id = atoi(data);
|
||||
if( mmo_bot_auth_fromsql(db, bot_acc, account_id) )
|
||||
{
|
||||
iter->last_bot_account_id = account_id;
|
||||
Sql_FreeResult(sql_handle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a struct mmo_bot_account from sql.
|
||||
* @param db: pointer to db
|
||||
* @param acc: pointer of mmo_bot_account to fill
|
||||
* @param account_id: id of user account to take data from
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool mmo_bot_auth_fromsql(BotAccountDB_SQL* db, struct mmo_bot_account* bot_acc, uint32 account_id) {
|
||||
Sql* sql_handle = db->bot_accounts;
|
||||
char* data;
|
||||
|
||||
// retrieve login entry for the specified account
|
||||
if( SQL_ERROR == Sql_Query(sql_handle,
|
||||
#ifdef VIP_ENABLE
|
||||
"SELECT `account_id`,`is_bot`,`creator_id`,`creator_name` FROM `%s` WHERE `account_id` = %d",
|
||||
#else
|
||||
"SELECT `account_id`,`is_bot`,`creator_id`,`creator_name` FROM `%s` WHERE `account_id` = %d",
|
||||
#endif
|
||||
db->bot_account_db, account_id )
|
||||
) {
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
{// no such entry
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr); bot_acc->account_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 1, &data, nullptr); bot_acc->is_bot = (uint8)atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, nullptr); bot_acc->creator_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 3, &data, nullptr); safestrncpy(bot_acc->creator_name, data, sizeof(bot_acc->creator_name));
|
||||
//ifdef VIP_ENABLE
|
||||
|
||||
//endif
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a struct mmo_bot_account in sql.
|
||||
* @param db: pointer to db
|
||||
* @param bot_acc: pointer of mmo_account to save
|
||||
* @param is_new: if it's a new entry or should we update
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool mmo_bot_auth_tosql(BotAccountDB_SQL* db, const struct mmo_bot_account* bot_acc, bool is_new, bool refresh_token) {
|
||||
Sql* sql_handle = db->bot_accounts;
|
||||
SqlStmt* stmt = SqlStmt_Malloc(sql_handle);
|
||||
bool result = false;
|
||||
|
||||
// try
|
||||
do
|
||||
{
|
||||
|
||||
if( SQL_SUCCESS != Sql_QueryStr(sql_handle, "START TRANSACTION") )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
}
|
||||
|
||||
if( is_new )
|
||||
{// insert into account table
|
||||
if( SQL_SUCCESS != SqlStmt_Prepare(stmt,
|
||||
#ifdef VIP_ENABLE
|
||||
"INSERT INTO `%s` (`account_id`, `is_bot`, `creator_id`, `creator_name`) VALUES (?, ?, ?, ?)",
|
||||
#else
|
||||
"INSERT INTO `%s` (`account_id`, `is_bot`, `creator_id`, `creator_name`) VALUES (?, ?, ?, ?)",
|
||||
#endif
|
||||
db->bot_account_db)
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_INT, (void*)&bot_acc->account_id, sizeof(bot_acc->account_id))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_SHORT, (void*)&bot_acc->is_bot, sizeof(bot_acc->is_bot))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_INT, (void*)&bot_acc->creator_id, sizeof(bot_acc->creator_id))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, (void*)&bot_acc->creator_name, strlen(bot_acc->creator_name))
|
||||
//ifdef VIP_ENABLE
|
||||
//endif
|
||||
|| SQL_SUCCESS != SqlStmt_Execute(stmt)
|
||||
) {
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{// update is bot state (meaning if controlled by sindri or by other means)
|
||||
if( SQL_SUCCESS != SqlStmt_Prepare(stmt,
|
||||
#ifdef VIP_ENABLE
|
||||
"UPDATE `%s` SET `is_bot`=? WHERE `account_id` = '%d'",
|
||||
#else
|
||||
"UPDATE `%s` SET `is_bot`=? WHERE `account_id` = '%d'",
|
||||
#endif
|
||||
db->bot_account_db, bot_acc->account_id)
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (void*)bot_acc->is_bot, sizeof(bot_acc->is_bot))
|
||||
#ifdef VIP_ENABLE
|
||||
#endif
|
||||
|| SQL_SUCCESS != SqlStmt_Execute(stmt)
|
||||
) {
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we got this far, everything was successful
|
||||
result = true;
|
||||
|
||||
} while(0);
|
||||
// finally
|
||||
|
||||
result &= ( SQL_SUCCESS == Sql_QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") );
|
||||
SqlStmt_Free(stmt);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
void mmo_save_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id) {
|
||||
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
uint16 count = RFIFOW(fd, 12);
|
||||
|
||||
if (count) {
|
||||
int cursor = 14, i;
|
||||
char key[32], sval[254], esc_key[32*2+1], esc_sval[254*2+1];
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
uint32 index;
|
||||
safestrncpy(key, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
|
||||
Sql_EscapeString(sql_handle, esc_key, key);
|
||||
cursor += RFIFOB(fd, cursor) + 1;
|
||||
|
||||
index = RFIFOL(fd, cursor);
|
||||
cursor += 4;
|
||||
|
||||
switch (RFIFOB(fd, cursor++)) {
|
||||
// int
|
||||
case 0:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%" PRId64 "')", db->global_acc_reg_num_table, account_id, esc_key, index, RFIFOQ(fd, cursor)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
cursor += 8;
|
||||
break;
|
||||
case 1:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", db->global_acc_reg_num_table, account_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
// str
|
||||
case 2:
|
||||
safestrncpy(sval, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
|
||||
cursor += RFIFOB(fd, cursor) + 1;
|
||||
Sql_EscapeString(sql_handle, esc_sval, sval);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%s')", db->global_acc_reg_str_table, account_id, esc_key, index, esc_sval) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 3:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", db->global_acc_reg_str_table, account_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
default:
|
||||
ShowError("mmo_save_global_accreg: unknown type %d\n",RFIFOB(fd, cursor - 1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
void mmo_send_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id) {
|
||||
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
char* data;
|
||||
int16 plen = 0;
|
||||
size_t len;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%" PRIu32 "'", db->global_acc_reg_str_table, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 1; // is string type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
plen = 16;
|
||||
|
||||
//
|
||||
// * Vessel!
|
||||
// *
|
||||
// * str type
|
||||
// * { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
|
||||
//
|
||||
while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr);
|
||||
len = strlen(data)+1;
|
||||
|
||||
WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 32
|
||||
plen += 1;
|
||||
|
||||
safestrncpy(WFIFOCP(fd,plen), data, len);
|
||||
plen += static_cast<decltype(plen)>( len );
|
||||
|
||||
Sql_GetData(sql_handle, 1, &data, nullptr);
|
||||
|
||||
WFIFOL(fd, plen) = (uint32)atol(data);
|
||||
plen += 4;
|
||||
|
||||
Sql_GetData(sql_handle, 2, &data, nullptr);
|
||||
len = strlen(data)+1;
|
||||
|
||||
WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 254
|
||||
plen += 1;
|
||||
|
||||
safestrncpy(WFIFOCP(fd,plen), data, len);
|
||||
plen += static_cast<decltype(plen)>( len );
|
||||
|
||||
WFIFOW(fd, 14) += 1;
|
||||
|
||||
if( plen > 60000 ) {
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
// prepare follow up
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 1; // is string type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
plen = 16;
|
||||
}
|
||||
}
|
||||
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%" PRIu32 "'", db->global_acc_reg_num_table, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 0; // is int type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
plen = 16;
|
||||
|
||||
//
|
||||
// * Vessel!
|
||||
// *
|
||||
// * int type
|
||||
// * { keyLength(B), key(<keyLength>), index(L), value(L) }
|
||||
//
|
||||
while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr);
|
||||
len = strlen(data)+1;
|
||||
|
||||
WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 32
|
||||
plen += 1;
|
||||
|
||||
safestrncpy(WFIFOCP(fd,plen), data, len);
|
||||
plen += static_cast<decltype(plen)>( len );
|
||||
|
||||
Sql_GetData(sql_handle, 1, &data, nullptr);
|
||||
|
||||
WFIFOL(fd, plen) = (uint32)atol(data);
|
||||
plen += 4;
|
||||
|
||||
Sql_GetData(sql_handle, 2, &data, nullptr);
|
||||
|
||||
WFIFOQ(fd, plen) = strtoll(data,nullptr,10);
|
||||
plen += 8;
|
||||
|
||||
WFIFOW(fd, 14) += 1;
|
||||
|
||||
if( plen > 60000 ) {
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
// prepare follow up
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 0; // is int type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
|
||||
plen = 16;
|
||||
}
|
||||
}
|
||||
|
||||
WFIFOB(fd, 12) = 1;
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
Sql_FreeResult(sql_handle);
|
||||
}*/
|
||||
|
||||
/*
|
||||
bool account_db_sql_enable_webtoken( AccountDB* self, const uint32 account_id ){
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
|
||||
if( SQL_ERROR == Sql_Query( db->accounts, "UPDATE `%s` SET `web_auth_token_enabled` = '1' WHERE `account_id` = '%u'", db->account_db, account_id ) ){
|
||||
Sql_ShowDebug( db->accounts );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Timered function to disable webtoken for user
|
||||
* If the user is online, then they must have logged since we started the timer.
|
||||
* In that case, do nothing. The new authtoken must be valid.
|
||||
* @param tid: timer id
|
||||
* @param tick: tick of execution
|
||||
* @param id: user account id
|
||||
* @param data: BotAccountDB // because we don't use singleton???
|
||||
* @return :0
|
||||
|
||||
TIMER_FUNC(account_disable_webtoken_timer){
|
||||
const struct online_login_data* p = login_get_online_user(id);
|
||||
AccountDB_SQL* db = reinterpret_cast<AccountDB_SQL*>(data);
|
||||
|
||||
if (p == nullptr) {
|
||||
ShowInfo("Web Auth Token for account %d was disabled\n", id);
|
||||
if( SQL_ERROR == Sql_Query( db->accounts, "UPDATE `%s` SET `web_auth_token_enabled` = '0' WHERE `account_id` = '%u'", db->account_db, id ) ){
|
||||
Sql_ShowDebug( db->accounts );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
bool account_db_sql_disable_webtoken( AccountDB* self, const uint32 account_id ){
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
|
||||
//add_timer(gettick() + brokk_config.disable_webtoken_delay, account_disable_webtoken_timer, account_id, reinterpret_cast<intptr_t>(db));
|
||||
|
||||
return true;
|
||||
}*/
|
||||
/*
|
||||
bool account_db_sql_remove_webtokens( AccountDB* self ){
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
|
||||
if( SQL_ERROR == Sql_Query( db->accounts, "UPDATE `%s` SET `web_auth_token` = NULL, `web_auth_token_enabled` = '0'", db->account_db ) ){
|
||||
Sql_ShowDebug( db->accounts );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
@ -0,0 +1,133 @@
|
||||
// Copyright (c) 4lexKidd
|
||||
// This software is licensed under the GPL v3 as to be fitting with the rathena project with the additional requirement
|
||||
// that any distributed versions must include an attribution to the original author (4lexKidd) in all copies
|
||||
// or substantial portions of the software.
|
||||
|
||||
#ifndef BOT_ACCOUNT_HPP
|
||||
#define BOT_ACCOUNT_HPP
|
||||
|
||||
#include <common/cbasetypes.hpp>
|
||||
#include <common/mmo.hpp> // ACCOUNT_REG2_NUM, WEB_AUTH_TOKEN_LENGTH
|
||||
#include <config/core.hpp>
|
||||
|
||||
typedef struct BotAccountDB BotAccountDB;
|
||||
typedef struct BotAccountDBIterator BotAccountDBIterator;
|
||||
|
||||
|
||||
// standard engines
|
||||
BotAccountDB* bot_account_db_sql(void);
|
||||
|
||||
struct mmo_bot_account {
|
||||
uint32 account_id; // ID of corresponding login account
|
||||
int is_bot; // Flag for if account is declared bot (will be controllable by sindri)
|
||||
uint32 creator_id; // ID of login account of creating/summoning player [Default: 0 for config generated bots)
|
||||
char creator_name[NAME_LENGTH]; // Name of the player character that spawned/summoned the bot [Default: Brokk for generated bots)
|
||||
};
|
||||
|
||||
|
||||
struct BotAccountDBIterator {
|
||||
/// Destroys this iterator, releasing all allocated memory (including itself).
|
||||
///
|
||||
/// @param self Iterator
|
||||
void (*destroy)(BotAccountDBIterator* self);
|
||||
|
||||
/// Fetches the next account in the database.
|
||||
/// Fills acc with the account data.
|
||||
/// @param self Iterator
|
||||
/// @param acc Account data
|
||||
/// @return true if successful
|
||||
bool (*next)(BotAccountDBIterator* self, struct mmo_bot_account* bot_acc);
|
||||
};
|
||||
|
||||
|
||||
struct BotAccountDB {
|
||||
/// Initializes this database, making it ready for use.
|
||||
/// Call this after setting the properties.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @return true if successful
|
||||
bool (*init)(BotAccountDB* self);
|
||||
|
||||
/// Destroys this database, releasing all allocated memory (including itself).
|
||||
///
|
||||
/// @param self Database
|
||||
void (*destroy)(BotAccountDB* self);
|
||||
|
||||
/// Gets a property from this database.
|
||||
/// These read-only properties must be implemented:
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param key Property name
|
||||
/// @param buf Buffer for the value
|
||||
/// @param buflen Buffer length
|
||||
/// @return true if successful
|
||||
bool (*get_property)(BotAccountDB* self, const char* key, char* buf, size_t buflen);
|
||||
|
||||
/// Sets a property in this database.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param key Property name
|
||||
/// @param value Property value
|
||||
/// @return true if successful
|
||||
bool (*set_property)(BotAccountDB* self, const char* key, const char* value);
|
||||
|
||||
/// Creates a new account in this database.
|
||||
/// bot_acc->account_id must always be set, because there will never be a valid bot_account without login-table account
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param acc Account data
|
||||
/// @return true if successful
|
||||
bool (*create)(BotAccountDB* self, struct mmo_bot_account* bot_acc);
|
||||
|
||||
/// Removes an account from this database.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param account_id Account id
|
||||
/// @return true if successful
|
||||
bool (*remove)(BotAccountDB* self, const uint32 account_id);
|
||||
|
||||
/// Enables the web auth token for the given account id
|
||||
//bool (*enable_webtoken)(BotAccountDB* self, const uint32 account_id);
|
||||
|
||||
/// Disables the web auth token for the given account id
|
||||
//bool (*disable_webtoken)(BotAccountDB* self, const uint32 account_id);
|
||||
|
||||
/// Removes the web auth token for all accounts
|
||||
//bool (*remove_webtokens)(BotAccountDB* self);
|
||||
|
||||
/// Modifies the data of an existing account.
|
||||
/// Uses bot_acc->account_id to identify the account.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param bot_acc Account data
|
||||
/// @param refresh_token Whether or not to refresh the web auth token
|
||||
/// @return true if successful
|
||||
bool (*save)(BotAccountDB* self, const struct mmo_bot_account* bot_acc, bool refresh_token);
|
||||
|
||||
/// Finds an bot_account with account_id and copies it to bot_acc.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param bot_acc Pointer that receives the account data
|
||||
/// @param account_id Target account id
|
||||
/// @return true if successful
|
||||
bool (*load_num)(BotAccountDB* self, struct mmo_bot_account* bot_acc, const uint32 account_id);
|
||||
|
||||
/// Finds an bot_account with creator_name and copies it to bot_acc.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param bot_acc Pointer that receives the account data
|
||||
/// @param userid Target username
|
||||
/// @return true if successful
|
||||
bool (*load_str)(BotAccountDB* self, struct mmo_bot_account* bot_acc, const char* userid);
|
||||
|
||||
/// Returns a new forward iterator.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @return Iterator
|
||||
BotAccountDBIterator* (*iterator)(BotAccountDB* self);
|
||||
};
|
||||
|
||||
//void mmo_send_global_accreg(BotAccountDB* self, int fd, uint32 account_id, uint32 char_id);
|
||||
//void mmo_save_global_accreg(BotAccountDB* self, int fd, uint32 account_id, uint32 char_id);
|
||||
|
||||
#endif /* BOT_ACCOUNT_HPP */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,369 @@
|
||||
// Copyright (c) 4lexKidd
|
||||
// This software is licensed under the GPL v3 as to be fitting with the rathena project with the additional requirement
|
||||
// that any distributed versions must include an attribution to the original author (4lexKidd) in all copies
|
||||
// or substantial portions of the software.
|
||||
|
||||
#ifndef CHAR_CREATION_HELPERS_HPP
|
||||
#define CHAR_CREATION_HELPERS_HPP
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <common/cbasetypes.hpp>
|
||||
#include <common/database.hpp>
|
||||
#include <common/mmo.hpp> // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus
|
||||
#include "charakters.hpp"
|
||||
/*
|
||||
* Constants for yaml dbs
|
||||
*/
|
||||
#define MAX_LEVEL 275
|
||||
|
||||
/// Enum of Player's Parameter
|
||||
enum bot_params {
|
||||
BOT_PARAM_STR = 0,
|
||||
BOT_PARAM_AGI,
|
||||
BOT_PARAM_VIT,
|
||||
BOT_PARAM_INT,
|
||||
BOT_PARAM_DEX,
|
||||
BOT_PARAM_LUK,
|
||||
BOT_PARAM_POW,
|
||||
BOT_PARAM_STA,
|
||||
BOT_PARAM_WIS,
|
||||
BOT_PARAM_SPL,
|
||||
BOT_PARAM_CON,
|
||||
BOT_PARAM_CRT,
|
||||
BOT_PARAM_MAX
|
||||
};
|
||||
|
||||
static const char* bot_parameter_names[BOT_PARAM_MAX] = {
|
||||
"Str",
|
||||
"Agi",
|
||||
"Vit",
|
||||
"Int",
|
||||
"Dex",
|
||||
"Luk",
|
||||
"Pow",
|
||||
"Sta",
|
||||
"Wis",
|
||||
"Spl",
|
||||
"Con",
|
||||
"Crt"
|
||||
};
|
||||
|
||||
//Total number of classes (for data storage)
|
||||
#define CLASS_COUNT (JOB_MAX - JOB_NOVICE_HIGH + JOB_MAX_BASIC)
|
||||
|
||||
enum bot_weapon_type : uint8 {
|
||||
BOT_W_FIST, //Bare hands
|
||||
BOT_W_DAGGER, //1
|
||||
BOT_W_1HSWORD, //2
|
||||
BOT_W_2HSWORD, //3
|
||||
BOT_W_1HSPEAR, //4
|
||||
BOT_W_2HSPEAR, //5
|
||||
BOT_W_1HAXE, //6
|
||||
BOT_W_2HAXE, //7
|
||||
BOT_W_MACE, //8
|
||||
BOT_W_2HMACE, //9 (unused)
|
||||
BOT_W_STAFF, //10
|
||||
BOT_W_BOW, //11
|
||||
BOT_W_KNUCKLE, //12
|
||||
BOT_W_MUSICAL, //13
|
||||
BOT_W_WHIP, //14
|
||||
BOT_W_BOOK, //15
|
||||
BOT_W_KATAR, //16
|
||||
BOT_W_REVOLVER, //17
|
||||
BOT_W_RIFLE, //18
|
||||
BOT_W_GATLING, //19
|
||||
BOT_W_SHOTGUN, //20
|
||||
BOT_W_GRENADE, //21
|
||||
BOT_W_HUUMA, //22
|
||||
BOT_W_2HSTAFF, //23
|
||||
BOT_MAX_WEAPON_TYPE,
|
||||
// dual-wield constants
|
||||
BOT_W_DOUBLE_DD, // 2 daggers
|
||||
BOT_W_DOUBLE_SS, // 2 swords
|
||||
BOT_W_DOUBLE_AA, // 2 axes
|
||||
BOT_W_DOUBLE_DS, // dagger + sword
|
||||
BOT_W_DOUBLE_DA, // dagger + axe
|
||||
BOT_W_DOUBLE_SA, // sword + axe
|
||||
BOT_MAX_WEAPON_TYPE_ALL,
|
||||
BOT_W_SHIELD = BOT_MAX_WEAPON_TYPE,
|
||||
};
|
||||
|
||||
#define WEAPON_TYPE_ALL ((1<<MAX_WEAPON_TYPE)-1)
|
||||
|
||||
//Checks if the given class value corresponds to a player class. [Skotlex]
|
||||
//JOB_NOVICE isn't checked for class_ is supposed to be unsigned
|
||||
#define pcdb_checkid_sub(class_) ( \
|
||||
( (class_) < JOB_MAX_BASIC ) || \
|
||||
( (class_) >= JOB_NOVICE_HIGH && (class_) <= JOB_DARK_COLLECTOR ) || \
|
||||
( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) || \
|
||||
( (class_) >= JOB_BABY_RUNE_KNIGHT && (class_) <= JOB_BABY_MECHANIC2 ) || \
|
||||
( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) || \
|
||||
( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) || \
|
||||
(class_) == JOB_REBELLION || (class_) == JOB_SUMMONER || \
|
||||
(class_) == JOB_BABY_SUMMONER || \
|
||||
( (class_) >= JOB_BABY_NINJA && (class_) <= JOB_BABY_REBELLION ) || \
|
||||
( (class_) >= JOB_BABY_STAR_GLADIATOR2 && (class_) <= JOB_BABY_STAR_EMPEROR2 ) || \
|
||||
( (class_) >= JOB_DRAGON_KNIGHT && (class_) <= JOB_TROUVERE ) || \
|
||||
( (class_) >= JOB_WINDHAWK2 && (class_) <= JOB_IMPERIAL_GUARD2 ) || \
|
||||
( (class_) >= JOB_SKY_EMPEROR && (class_) <= JOB_SPIRIT_HANDLER ) || \
|
||||
(class_) == JOB_SKY_EMPEROR2 \
|
||||
)
|
||||
#define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)class_)
|
||||
|
||||
|
||||
//These marks the "level" of the job.
|
||||
#define JOBL_2_1 0x100 //256
|
||||
#define JOBL_2_2 0x200 //512
|
||||
#define JOBL_2 0x300 //768
|
||||
|
||||
#define JOBL_UPPER 0x1000 //4096
|
||||
#define JOBL_BABY 0x2000 //8192
|
||||
#define JOBL_THIRD 0x4000 //16384
|
||||
#define JOBL_FOURTH 0x8000 //32768
|
||||
|
||||
//First Jobs
|
||||
//Note the oddity of the novice:
|
||||
|
||||
enum bot_mapid : uint64{
|
||||
//Novice And 1-1 Jobs
|
||||
BOT_MAPID_NOVICE = 0x0,
|
||||
BOT_MAPID_SWORDMAN,
|
||||
BOT_MAPID_MAGE,
|
||||
BOT_MAPID_ARCHER,
|
||||
BOT_MAPID_ACOLYTE,
|
||||
BOT_MAPID_MERCHANT,
|
||||
BOT_MAPID_THIEF,
|
||||
BOT_MAPID_TAEKWON,
|
||||
BOT_MAPID_WEDDING,
|
||||
BOT_MAPID_GUNSLINGER,
|
||||
BOT_MAPID_NINJA,
|
||||
BOT_MAPID_XMAS,
|
||||
BOT_MAPID_SUMMER,
|
||||
BOT_MAPID_HANBOK,
|
||||
BOT_MAPID_GANGSI,
|
||||
BOT_MAPID_OKTOBERFEST,
|
||||
BOT_MAPID_SUMMONER,
|
||||
BOT_MAPID_SUMMER2,
|
||||
//2-1 Jobs
|
||||
BOT_MAPID_SUPER_NOVICE = JOBL_2_1|BOT_MAPID_NOVICE,
|
||||
BOT_MAPID_KNIGHT,
|
||||
BOT_MAPID_WIZARD,
|
||||
BOT_MAPID_HUNTER,
|
||||
BOT_MAPID_PRIEST,
|
||||
BOT_MAPID_BLACKSMITH,
|
||||
BOT_MAPID_ASSASSIN,
|
||||
BOT_MAPID_STAR_GLADIATOR,
|
||||
BOT_MAPID_REBELLION = JOBL_2_1| BOT_MAPID_GUNSLINGER,
|
||||
BOT_MAPID_KAGEROUOBORO,
|
||||
BOT_MAPID_DEATH_KNIGHT = JOBL_2_1|BOT_MAPID_GANGSI,
|
||||
//2-2 Jobs
|
||||
BOT_MAPID_CRUSADER = JOBL_2_2|BOT_MAPID_SWORDMAN,
|
||||
BOT_MAPID_SAGE,
|
||||
BOT_MAPID_BARDDANCER,
|
||||
BOT_MAPID_MONK,
|
||||
BOT_MAPID_ALCHEMIST,
|
||||
BOT_MAPID_ROGUE,
|
||||
BOT_MAPID_SOUL_LINKER,
|
||||
BOT_MAPID_DARK_COLLECTOR = JOBL_2_2|BOT_MAPID_GANGSI,
|
||||
//Trans Novice And Trans 1-1 Jobs
|
||||
BOT_MAPID_NOVICE_HIGH = JOBL_UPPER|BOT_MAPID_NOVICE,
|
||||
BOT_MAPID_SWORDMAN_HIGH,
|
||||
BOT_MAPID_MAGE_HIGH,
|
||||
BOT_MAPID_ARCHER_HIGH,
|
||||
BOT_MAPID_ACOLYTE_HIGH,
|
||||
BOT_MAPID_MERCHANT_HIGH,
|
||||
BOT_MAPID_THIEF_HIGH,
|
||||
//Trans 2-1 Jobs
|
||||
BOT_MAPID_LORD_KNIGHT = JOBL_UPPER|BOT_MAPID_KNIGHT,
|
||||
BOT_MAPID_HIGH_WIZARD,
|
||||
BOT_MAPID_SNIPER,
|
||||
BOT_MAPID_HIGH_PRIEST,
|
||||
BOT_MAPID_WHITESMITH,
|
||||
BOT_MAPID_ASSASSIN_CROSS,
|
||||
//Trans 2-2 Jobs
|
||||
BOT_MAPID_PALADIN = JOBL_UPPER|BOT_MAPID_CRUSADER,
|
||||
BOT_MAPID_PROFESSOR,
|
||||
BOT_MAPID_CLOWNGYPSY,
|
||||
BOT_MAPID_CHAMPION,
|
||||
BOT_MAPID_CREATOR,
|
||||
BOT_MAPID_STALKER,
|
||||
//Baby Novice And Baby 1-1 Jobs
|
||||
BOT_MAPID_BABY = JOBL_BABY|BOT_MAPID_NOVICE,
|
||||
BOT_MAPID_BABY_SWORDMAN,
|
||||
BOT_MAPID_BABY_MAGE,
|
||||
BOT_MAPID_BABY_ARCHER,
|
||||
BOT_MAPID_BABY_ACOLYTE,
|
||||
BOT_MAPID_BABY_MERCHANT,
|
||||
BOT_MAPID_BABY_THIEF,
|
||||
BOT_MAPID_BABY_TAEKWON,
|
||||
BOT_MAPID_BABY_GUNSLINGER = JOBL_BABY|BOT_MAPID_GUNSLINGER,
|
||||
BOT_MAPID_BABY_NINJA,
|
||||
BOT_MAPID_BABY_SUMMONER = JOBL_BABY|BOT_MAPID_SUMMONER,
|
||||
//Baby 2-1 Jobs
|
||||
BOT_MAPID_SUPER_BABY = JOBL_BABY|BOT_MAPID_SUPER_NOVICE,
|
||||
BOT_MAPID_BABY_KNIGHT,
|
||||
BOT_MAPID_BABY_WIZARD,
|
||||
BOT_MAPID_BABY_HUNTER,
|
||||
BOT_MAPID_BABY_PRIEST,
|
||||
BOT_MAPID_BABY_BLACKSMITH,
|
||||
BOT_MAPID_BABY_ASSASSIN,
|
||||
BOT_MAPID_BABY_STAR_GLADIATOR,
|
||||
BOT_MAPID_BABY_REBELLION = JOBL_BABY|BOT_MAPID_REBELLION,
|
||||
BOT_MAPID_BABY_KAGEROUOBORO,
|
||||
//Baby 2-2 Jobs
|
||||
BOT_MAPID_BABY_CRUSADER = JOBL_BABY|BOT_MAPID_CRUSADER,
|
||||
BOT_MAPID_BABY_SAGE,
|
||||
BOT_MAPID_BABY_BARDDANCER,
|
||||
BOT_MAPID_BABY_MONK,
|
||||
BOT_MAPID_BABY_ALCHEMIST,
|
||||
BOT_MAPID_BABY_ROGUE,
|
||||
BOT_MAPID_BABY_SOUL_LINKER,
|
||||
//3-1 Jobs
|
||||
BOT_MAPID_SUPER_NOVICE_E = JOBL_THIRD|BOT_MAPID_SUPER_NOVICE,
|
||||
BOT_MAPID_RUNE_KNIGHT,
|
||||
BOT_MAPID_WARLOCK,
|
||||
BOT_MAPID_RANGER,
|
||||
BOT_MAPID_ARCH_BISHOP,
|
||||
BOT_MAPID_MECHANIC,
|
||||
BOT_MAPID_GUILLOTINE_CROSS,
|
||||
BOT_MAPID_STAR_EMPEROR,
|
||||
//3-2 Jobs
|
||||
BOT_MAPID_ROYAL_GUARD = JOBL_THIRD|BOT_MAPID_CRUSADER,
|
||||
BOT_MAPID_SORCERER,
|
||||
BOT_MAPID_MINSTRELWANDERER,
|
||||
BOT_MAPID_SURA,
|
||||
BOT_MAPID_GENETIC,
|
||||
BOT_MAPID_SHADOW_CHASER,
|
||||
BOT_MAPID_SOUL_REAPER,
|
||||
//Trans 3-1 Jobs
|
||||
BOT_MAPID_RUNE_KNIGHT_T = JOBL_THIRD|BOT_MAPID_LORD_KNIGHT,
|
||||
BOT_MAPID_WARLOCK_T,
|
||||
BOT_MAPID_RANGER_T,
|
||||
BOT_MAPID_ARCH_BISHOP_T,
|
||||
BOT_MAPID_MECHANIC_T,
|
||||
BOT_MAPID_GUILLOTINE_CROSS_T,
|
||||
//Trans 3-2 Jobs
|
||||
BOT_MAPID_ROYAL_GUARD_T = JOBL_THIRD|BOT_MAPID_PALADIN,
|
||||
BOT_MAPID_SORCERER_T,
|
||||
BOT_MAPID_MINSTRELWANDERER_T,
|
||||
BOT_MAPID_SURA_T,
|
||||
BOT_MAPID_GENETIC_T,
|
||||
BOT_MAPID_SHADOW_CHASER_T,
|
||||
//Baby 3-1 Jobs
|
||||
BOT_MAPID_SUPER_BABY_E = JOBL_THIRD|BOT_MAPID_SUPER_BABY,
|
||||
BOT_MAPID_BABY_RUNE_KNIGHT,
|
||||
BOT_MAPID_BABY_WARLOCK,
|
||||
BOT_MAPID_BABY_RANGER,
|
||||
BOT_MAPID_BABY_ARCH_BISHOP,
|
||||
BOT_MAPID_BABY_MECHANIC,
|
||||
BOT_MAPID_BABY_GUILLOTINE_CROSS,
|
||||
BOT_MAPID_BABY_STAR_EMPEROR,
|
||||
//Baby 3-2 Jobs
|
||||
BOT_MAPID_BABY_ROYAL_GUARD = JOBL_THIRD|BOT_MAPID_BABY_CRUSADER,
|
||||
BOT_MAPID_BABY_SORCERER,
|
||||
BOT_MAPID_BABY_MINSTRELWANDERER,
|
||||
BOT_MAPID_BABY_SURA,
|
||||
BOT_MAPID_BABY_GENETIC,
|
||||
BOT_MAPID_BABY_SHADOW_CHASER,
|
||||
BOT_MAPID_BABY_SOUL_REAPER,
|
||||
//4-1 Jobs
|
||||
BOT_MAPID_HYPER_NOVICE = JOBL_FOURTH|JOBL_THIRD|JOBL_UPPER|BOT_MAPID_SUPER_NOVICE,
|
||||
BOT_MAPID_DRAGON_KNIGHT,
|
||||
BOT_MAPID_ARCH_MAGE,
|
||||
BOT_MAPID_WINDHAWK,
|
||||
BOT_MAPID_CARDINAL,
|
||||
BOT_MAPID_MEISTER,
|
||||
BOT_MAPID_SHADOW_CROSS,
|
||||
BOT_MAPID_SKY_EMPEROR,
|
||||
BOT_MAPID_NIGHT_WATCH = JOBL_FOURTH|JOBL_THIRD|JOBL_UPPER|BOT_MAPID_REBELLION,
|
||||
BOT_MAPID_SHINKIRO_SHIRANUI,
|
||||
BOT_MAPID_SPIRIT_HANDLER = JOBL_FOURTH|JOBL_THIRD|JOBL_UPPER|JOBL_2_1|BOT_MAPID_SUMMONER,
|
||||
//4-2 Jobs
|
||||
BOT_MAPID_IMPERIAL_GUARD = JOBL_FOURTH|JOBL_THIRD|JOBL_UPPER|BOT_MAPID_CRUSADER,
|
||||
BOT_MAPID_ELEMENTAL_MASTER,
|
||||
BOT_MAPID_TROUBADOURTROUVERE,
|
||||
BOT_MAPID_INQUISITOR,
|
||||
BOT_MAPID_BIOLO,
|
||||
BOT_MAPID_ABYSS_CHASER,
|
||||
BOT_MAPID_SOUL_ASCETIC,
|
||||
// Additional constants
|
||||
BOT_MAPID_ALL = UINT64_MAX
|
||||
};
|
||||
|
||||
|
||||
//for filtering and quick checking.
|
||||
#define MAPID_BASEMASK 0x00ff
|
||||
#define MAPID_UPPERMASK 0x0fff
|
||||
#define MAPID_THIRDMASK (JOBL_THIRD|MAPID_UPPERMASK)
|
||||
#define MAPID_FOURTHMASK (JOBL_FOURTH|MAPID_THIRDMASK|JOBL_UPPER)
|
||||
|
||||
/*
|
||||
* Yaml DBs and their containers
|
||||
*/
|
||||
struct bot_statpoint_entry {
|
||||
uint16 level;
|
||||
uint32 statpoints;
|
||||
uint32 traitpoints;
|
||||
};
|
||||
|
||||
class BotStatPointDatabase : public TypesafeCachedYamlDatabase<uint16, bot_statpoint_entry> {
|
||||
public:
|
||||
BotStatPointDatabase() : TypesafeCachedYamlDatabase("STATPOINT_DB", 2, 1) {
|
||||
|
||||
}
|
||||
|
||||
const std::string getDefaultLocation() override;
|
||||
uint64 parseBodyNode(const ryml::NodeRef& node) override;
|
||||
void loadingFinished() override;
|
||||
|
||||
// Additional
|
||||
uint32 load_max_status_points_of_level(uint16 level);
|
||||
uint32 get_table_point(uint16 level);
|
||||
uint32 load_max_trait_points_of_level(uint16 level);
|
||||
uint32 get_trait_table_point(uint16 level);
|
||||
};
|
||||
|
||||
extern BotStatPointDatabase bot_statpoint_db;
|
||||
|
||||
struct bot_job_info {
|
||||
std::vector<uint32> base_hp, base_sp, base_ap; //Storage for the first calculation with hp/sp/ap factor and multiplicator
|
||||
uint32 hp_factor, hp_increase, sp_increase, max_weight_base;
|
||||
std::vector<std::array<uint16, BOT_PARAM_MAX>> job_bonus;
|
||||
std::vector<int16> aspd_base;
|
||||
t_exp base_exp[MAX_LEVEL], job_exp[MAX_LEVEL];
|
||||
uint16 max_base_level, max_job_level;
|
||||
uint16 max_param[BOT_PARAM_MAX];
|
||||
struct s_job_noenter_map {
|
||||
uint32 zone;
|
||||
uint8 group_lv;
|
||||
} noenter_map;
|
||||
};
|
||||
|
||||
class BotJobDatabase : public TypesafeCachedYamlDatabase<uint16, bot_job_info> {
|
||||
public:
|
||||
BotJobDatabase() : TypesafeCachedYamlDatabase("JOB_STATS", 2) {
|
||||
|
||||
}
|
||||
|
||||
const std::string getDefaultLocation() override;
|
||||
uint64 parseBodyNode(const ryml::NodeRef& node) override;
|
||||
void loadingFinished() override;
|
||||
|
||||
// Additional
|
||||
uint32 get_maxBaseLv(uint16 job_id);
|
||||
uint32 get_maxJobLv(uint16 job_id);
|
||||
t_exp get_baseExp(uint16 job_id, uint32 level);
|
||||
t_exp get_jobExp(uint16 job_id, uint32 level);
|
||||
int32 get_maxWeight(uint16 job_id);
|
||||
};
|
||||
|
||||
extern BotJobDatabase bot_job_db;
|
||||
|
||||
/*
|
||||
* Tool Functions
|
||||
*/
|
||||
|
||||
void bot_read_yaml_dbs(void);
|
||||
|
||||
#endif /* CHAR_CREATION_HELPERS_HPP */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,216 @@
|
||||
// Copyright (c) 4lexKidd
|
||||
// This software is licensed under the GPL v3 as to be fitting with the rathena project with the additional requirement
|
||||
// that any distributed versions must include an attribution to the original author (4lexKidd) in all copies
|
||||
// or substantial portions of the software.
|
||||
|
||||
#ifndef CHARAKTERS_HPP
|
||||
#define CHARAKTERS_HPP
|
||||
|
||||
#include <common/cbasetypes.hpp>
|
||||
#include <common/mmo.hpp> // ACCOUNT_REG2_NUM, WEB_AUTH_TOKEN_LENGTH
|
||||
#include <config/core.hpp>
|
||||
|
||||
typedef struct CharDB CharDB;
|
||||
typedef struct CharakterDBIterator CharakterDBIterator;
|
||||
|
||||
|
||||
// standard engines
|
||||
CharDB* char_db_sql(void);
|
||||
|
||||
struct mmo_charakter {
|
||||
uint32 char_id; // Primary key
|
||||
uint32 account_id; // ID of corresponding login account
|
||||
uint8 char_num; // Slot number of the character
|
||||
char name[NAME_LENGTH]; // Name of the character, limited to 30 chars
|
||||
|
||||
uint16 class_; // Class ID of the character
|
||||
uint16 base_level; // Base level of the character
|
||||
uint16 job_level; // Job level of the character
|
||||
|
||||
uint64 base_exp; // Base experience points
|
||||
uint64 job_exp; // Job experience points
|
||||
uint32 zeny; // Amount of zeny
|
||||
|
||||
uint16 str; // Strength stat
|
||||
uint16 agi; // Agility stat
|
||||
uint16 vit; // Vitality stat
|
||||
uint16 int_; // Intelligence stat
|
||||
uint16 dex; // Dexterity stat
|
||||
uint16 luk; // Luck stat
|
||||
|
||||
// Additional stats
|
||||
uint16 pow; // Power stat
|
||||
uint16 sta; // Stamina stat
|
||||
uint16 wis; // Wisdom stat
|
||||
uint16 spl; // Spirit stat
|
||||
uint16 con; // Concentration stat
|
||||
uint16 crt; // Critical stat
|
||||
|
||||
uint32 max_hp; // Maximum HP
|
||||
uint32 hp; // Current HP
|
||||
uint32 max_sp; // Maximum SP
|
||||
uint32 sp; // Current SP
|
||||
uint32 max_ap; // Maximum AP (if applicable)
|
||||
uint32 ap; // Current AP (if applicable)
|
||||
|
||||
uint32 status_point; // Available status points
|
||||
uint32 skill_point; // Available skill points
|
||||
uint32 trait_point; // Available trait points
|
||||
|
||||
int32 option; // Character options
|
||||
int8 karma; // Karma points (signed, -128 to 127)
|
||||
int16 manner; // Manner points (could be negative, small int)
|
||||
|
||||
uint32 party_id; // ID of the party the character is in
|
||||
uint32 guild_id; // ID of the guild the character is in
|
||||
uint32 pet_id; // ID of the pet (if any)
|
||||
uint32 homun_id; // ID of the homunculus (if any)
|
||||
uint32 elemental_id; // ID of the elemental (if any)
|
||||
|
||||
uint8 hair; // Hair style
|
||||
uint16 hair_color; // Hair color
|
||||
uint16 clothes_color; // Clothes color
|
||||
uint16 body; // Body ID
|
||||
uint16 weapon; // Weapon ID
|
||||
uint16 shield; // Shield ID
|
||||
uint16 head_top; // Head top item
|
||||
uint16 head_mid; // Head middle item
|
||||
uint16 head_bottom; // Head bottom item
|
||||
uint16 robe; // Robe item
|
||||
|
||||
char last_map[MAP_NAME_LENGTH]; // Last known map the character was on
|
||||
uint16 last_x; // Last X position on the map
|
||||
uint16 last_y; // Last Y position on the map
|
||||
uint32 last_instanceid; // ID of the last instance the character was in
|
||||
|
||||
char save_map[MAP_NAME_LENGTH]; // Save map (respawn location)
|
||||
uint16 save_x; // Save X position
|
||||
uint16 save_y; // Save Y position
|
||||
|
||||
uint32 partner_id; // ID of the partner (e.g., for marriage)
|
||||
uint8 online; // Is the character online or not?
|
||||
uint32 father; // Father character ID
|
||||
uint32 mother; // Mother character ID
|
||||
uint32 child; // Child character ID
|
||||
|
||||
uint32 fame; // Fame points
|
||||
uint16 rename; // Rename status
|
||||
uint32 delete_date; // Scheduled deletion time (timestamp)
|
||||
uint32 moves; // Character moves (could represent migration)
|
||||
uint32 unban_time; // Time until unbanned (timestamp)
|
||||
int8 font; // Font used by the character
|
||||
uint32 uniqueitem_counter; // Counter for unique items
|
||||
|
||||
char sex; // 'M' or 'F' for gender
|
||||
int8 hotkey_rowshift; // Hotkey row shift setting
|
||||
int8 hotkey_rowshift2; // Additional hotkey row shift setting
|
||||
uint32 clan_id; // Clan ID
|
||||
char last_login[24]; // date+time of last successful login
|
||||
uint32 title_id; // Character title ID
|
||||
uint8 show_equip; // Show equipment flag
|
||||
uint16 inventory_slots; // Available inventory slots
|
||||
uint8 body_direction; // Direction the body is facing
|
||||
uint8 disable_call; // Disable call flag (e.g., for party/guild recall)
|
||||
|
||||
// Add other custom fields here if needed for future expansions
|
||||
};
|
||||
|
||||
|
||||
struct CharakterDBIterator {
|
||||
/// Destroys this iterator, releasing all allocated memory (including itself).
|
||||
///
|
||||
/// @param self Iterator
|
||||
void (*destroy)(CharakterDBIterator* self);
|
||||
|
||||
/// Fetches the next charakter in the database.
|
||||
/// Fills charakter with the charakter data.
|
||||
/// @param self Iterator
|
||||
/// @param character data
|
||||
/// @return true if successful
|
||||
bool (*next)(CharakterDBIterator* self, struct mmo_charakter* charakter);
|
||||
};
|
||||
|
||||
|
||||
struct CharDB {
|
||||
/// Initializes this database, making it ready for use.
|
||||
/// Call this after setting the properties.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @return true if successful
|
||||
bool (*init)(CharDB* self);
|
||||
|
||||
/// Destroys this database, releasing all allocated memory (including itself).
|
||||
///
|
||||
/// @param self Database
|
||||
void (*destroy)(CharDB* self);
|
||||
|
||||
/// Gets a property from this database.
|
||||
/// These read-only properties must be implemented:
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param key Property name
|
||||
/// @param buf Buffer for the value
|
||||
/// @param buflen Buffer length
|
||||
/// @return true if successful
|
||||
bool (*get_property)(CharDB* self, const char* key, char* buf, size_t buflen);
|
||||
|
||||
/// Sets a property in this database.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param key Property name
|
||||
/// @param value Property value
|
||||
/// @return true if successful
|
||||
bool (*set_property)(CharDB* self, const char* key, const char* value);
|
||||
|
||||
/// Creates a new charakter in this database.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param charakter Charakter data
|
||||
/// @return true if successful
|
||||
bool (*create)(CharDB* self, struct mmo_charakter* charakter);
|
||||
|
||||
/// Removes an charakter from this database.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param char_id Charakter id
|
||||
/// @return true if successful
|
||||
bool (*remove)(CharDB* self, const uint32 char_id);
|
||||
|
||||
/// Modifies the data of an existing charakter.
|
||||
/// Uses charakter->char_id to identify the charakter.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param charakter Char data
|
||||
/// @return true if successful
|
||||
bool (*save)(CharDB* self, const struct mmo_charakter* charakter);
|
||||
|
||||
/// Finds an charakter with char_id and copies it to charakter.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param charakter Pointer that receives the char data
|
||||
/// @param char_id Target charakter id
|
||||
/// @return true if successful
|
||||
bool (*load_num)(CharDB* self, struct mmo_charakter* charakter, const uint32 char_id);
|
||||
|
||||
/// Finds an charakter with charakter_name and copies it to charakter.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @param charakter Pointer that receives the charakter data
|
||||
/// @param char_name Target Charakter Name
|
||||
/// @return true if successful
|
||||
bool (*load_str)(CharDB* self, struct mmo_charakter* charakter, const char* id);
|
||||
|
||||
/// Returns a new forward iterator.
|
||||
///
|
||||
/// @param self Database
|
||||
/// @return Iterator
|
||||
CharakterDBIterator* (*iterator)(CharDB* self);
|
||||
};
|
||||
|
||||
//void mmo_send_global_accreg(BotAccountDB* self, int fd, uint32 account_id, uint32 char_id);
|
||||
//void mmo_save_global_accreg(BotAccountDB* self, int fd, uint32 account_id, uint32 char_id);
|
||||
|
||||
int convert_jobid_to_number(const char* job_id);
|
||||
int convert_weaponid_to_number(const char* weapon_id);
|
||||
|
||||
#endif /* CHARAKTERS_HPP */
|
@ -0,0 +1,825 @@
|
||||
// Copyright (c) 4lexKidd
|
||||
// This software is licensed under the GPL v3 as to be fitting with the rathena project with the additional requirement
|
||||
// that any distributed versions must include an attribution to the original author (4lexKidd) in all copies
|
||||
// or substantial portions of the software.
|
||||
|
||||
|
||||
#include "bot_account.hpp"
|
||||
|
||||
#include <algorithm> //min / max
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <common/malloc.hpp>
|
||||
#include <common/mmo.hpp>
|
||||
#include <common/showmsg.hpp>
|
||||
#include <common/socket.hpp>
|
||||
#include <common/sql.hpp>
|
||||
#include <common/strlib.hpp>
|
||||
|
||||
#include "brokk.hpp" // brokk_config
|
||||
|
||||
/// global defines
|
||||
|
||||
/// internal structure
|
||||
typedef struct BotAccountDB_SQL {
|
||||
BotAccountDB vtable; // public interface
|
||||
Sql* bot_accounts; // SQL handle bot accounts storage
|
||||
std::string db_hostname = "127.0.0.1";
|
||||
uint16 db_port = 3306;
|
||||
std::string db_username = "ragnarok";
|
||||
std::string db_password = "ragnarok";
|
||||
std::string db_database = "ragnarok";
|
||||
std::string codepage = "";
|
||||
// other settings
|
||||
bool case_sensitive;
|
||||
//table name
|
||||
char bot_account_db[32];
|
||||
char login_account_db[32];
|
||||
char global_acc_reg_num_table[32];
|
||||
char global_acc_reg_str_table[32];
|
||||
|
||||
} BotAccountDB_SQL;
|
||||
|
||||
/// internal structure
|
||||
typedef struct BotAccountDBIterator_SQL {
|
||||
BotAccountDBIterator vtable; // public interface
|
||||
BotAccountDB_SQL* db;
|
||||
int last_bot_account_id;
|
||||
} BotAccountDBIterator_SQL;
|
||||
|
||||
/// internal functions
|
||||
static bool bot_account_db_sql_init(BotAccountDB* self);
|
||||
static void bot_account_db_sql_destroy(BotAccountDB* self);
|
||||
static bool bot_account_db_sql_get_property(BotAccountDB* self, const char* key, char* buf, size_t buflen);
|
||||
static bool bot_account_db_sql_set_property(BotAccountDB* self, const char* option, const char* value);
|
||||
static bool bot_account_db_sql_create(BotAccountDB* self, struct mmo_bot_account* bot_acc);
|
||||
static bool bot_account_db_sql_remove(BotAccountDB* self, const uint32 account_id);
|
||||
static bool bot_account_db_sql_save(BotAccountDB* self, const struct mmo_bot_account* bot_acc, bool refresh_token);
|
||||
static bool bot_account_db_sql_load_num(BotAccountDB* self, struct mmo_bot_account* bot_acc, const uint32 account_id);
|
||||
static bool bot_account_db_sql_load_str(BotAccountDB* self, struct mmo_bot_account* bot_acc, const char* creator_name);
|
||||
static BotAccountDBIterator* bot_account_db_sql_iterator(BotAccountDB* self);
|
||||
static void bot_account_db_sql_iter_destroy(BotAccountDBIterator* self);
|
||||
static bool bot_account_db_sql_iter_next(BotAccountDBIterator* self, struct mmo_bot_account* bot_acc);
|
||||
static bool mmo_bot_auth_fromsql(BotAccountDB_SQL* db, struct mmo_bot_account* bot_acc, uint32 account_id);
|
||||
static bool mmo_bot_auth_tosql(BotAccountDB_SQL* db, const struct mmo_bot_account* bot_acc, bool is_new, bool refresh_token);
|
||||
|
||||
/// public constructor
|
||||
BotAccountDB* bot_account_db_sql(void) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)aCalloc(1, sizeof(BotAccountDB_SQL));
|
||||
new(db) BotAccountDB_SQL();
|
||||
|
||||
// set up the vtable
|
||||
db->vtable.init = &bot_account_db_sql_init;
|
||||
db->vtable.destroy = &bot_account_db_sql_destroy;
|
||||
db->vtable.get_property = &bot_account_db_sql_get_property;
|
||||
db->vtable.set_property = &bot_account_db_sql_set_property;
|
||||
db->vtable.save = &bot_account_db_sql_save;
|
||||
db->vtable.create = &bot_account_db_sql_create;
|
||||
db->vtable.remove = &bot_account_db_sql_remove;
|
||||
db->vtable.load_num = &bot_account_db_sql_load_num;
|
||||
db->vtable.load_str = &bot_account_db_sql_load_str;
|
||||
db->vtable.iterator = &bot_account_db_sql_iterator;
|
||||
|
||||
// initialize to default values
|
||||
db->bot_accounts = nullptr;
|
||||
|
||||
// other settings
|
||||
db->case_sensitive = false;
|
||||
safestrncpy(db->bot_account_db, "bot_accounts", sizeof(db->bot_account_db));
|
||||
safestrncpy(db->login_account_db, "login", sizeof(db->login_account_db));
|
||||
//safestrncpy(db->global_acc_reg_num_table, "global_acc_reg_num", sizeof(db->global_acc_reg_num_table));
|
||||
//safestrncpy(db->global_acc_reg_str_table, "global_acc_reg_str", sizeof(db->global_acc_reg_str_table));
|
||||
|
||||
return &db->vtable;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/**
|
||||
* Establish the database connection.
|
||||
* @param self: pointer to db
|
||||
*/
|
||||
static bool bot_account_db_sql_init(BotAccountDB* self) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
Sql* sql_handle;
|
||||
|
||||
db->bot_accounts = Sql_Malloc();
|
||||
sql_handle = db->bot_accounts;
|
||||
|
||||
if (SQL_ERROR == Sql_Connect(sql_handle, db->db_username.c_str(), db->db_password.c_str(), db->db_hostname.c_str(), db->db_port, db->db_database.c_str()))
|
||||
{
|
||||
ShowError("Couldn't connect with uname='%s',host='%s',port='%hu',database='%s'\n",
|
||||
db->db_username.c_str(), db->db_hostname.c_str(), db->db_port, db->db_database.c_str());
|
||||
Sql_ShowDebug(sql_handle);
|
||||
Sql_Free(db->bot_accounts);
|
||||
db->bot_accounts = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!db->codepage.empty() && SQL_ERROR == Sql_SetEncoding(sql_handle, db->codepage.c_str()))
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
//self->remove_webtokens( self );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the database and close the connection to it.
|
||||
* @param self: pointer to db
|
||||
*/
|
||||
static void bot_account_db_sql_destroy(BotAccountDB* self){
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
|
||||
//if( SQL_ERROR == Sql_Query( db->bot_accounts, "UPDATE `%s` SET `web_auth_token` = NULL", db->bot_account_db ) ){
|
||||
// Sql_ShowDebug( db->accounts );
|
||||
//}
|
||||
|
||||
Sql_Free(db->bot_accounts);
|
||||
db->bot_accounts = nullptr;
|
||||
|
||||
db->~BotAccountDB_SQL();
|
||||
aFree(db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get configuration information into buf.
|
||||
* If the option is supported, adjust the internal state.
|
||||
* @param self: pointer to db
|
||||
* @param key: config keyword
|
||||
* @param buf: value set of the keyword
|
||||
* @param buflen: size of buffer to avoid out of bound
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_get_property(BotAccountDB* self, const char* key, char* buf, size_t buflen)
|
||||
{
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
const char* signature;
|
||||
|
||||
signature = "brokk_server_";
|
||||
if( strncmpi(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "ip") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_hostname.c_str());
|
||||
else
|
||||
if( strcmpi(key, "port") == 0 )
|
||||
safesnprintf(buf, buflen, "%hu", db->db_port);
|
||||
else
|
||||
if( strcmpi(key, "id") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_username.c_str());
|
||||
else
|
||||
if( strcmpi(key, "pw") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_password.c_str());
|
||||
else
|
||||
if( strcmpi(key, "db") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->db_database.c_str());
|
||||
else
|
||||
if( strcmpi(key, "bot_account_db") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->bot_account_db);
|
||||
//else
|
||||
//if( strcmpi(key, "global_acc_reg_str_table") == 0 )
|
||||
// safesnprintf(buf, buflen, "%s", db->global_acc_reg_str_table);
|
||||
//else
|
||||
//if( strcmpi(key, "global_acc_reg_num_table") == 0 )
|
||||
// safesnprintf(buf, buflen, "%s", db->global_acc_reg_num_table);
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
signature = "brokk_";
|
||||
if( strncmpi(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "codepage") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->codepage.c_str());
|
||||
else
|
||||
if( strcmpi(key, "case_sensitive") == 0 )
|
||||
safesnprintf(buf, buflen, "%d", (db->case_sensitive ? 1 : 0));
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;// not found
|
||||
}
|
||||
|
||||
/**
|
||||
* Read and set configuration.
|
||||
* If the option is supported, adjust the internal state.
|
||||
* @param self: pointer to db
|
||||
* @param key: config keyword
|
||||
* @param value: config value for keyword
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_set_property(BotAccountDB* self, const char* key, const char* value) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
const char* signature;
|
||||
|
||||
signature = "brokk_server_";
|
||||
if( strncmp(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "ip") == 0 )
|
||||
db->db_hostname = value;
|
||||
else
|
||||
if( strcmpi(key, "port") == 0 )
|
||||
db->db_port = (uint16)strtoul( value, nullptr, 10 );
|
||||
else
|
||||
if( strcmpi(key, "id") == 0 )
|
||||
db->db_username = value;
|
||||
else
|
||||
if( strcmpi(key, "pw") == 0 )
|
||||
db->db_password = value;
|
||||
else
|
||||
if( strcmpi(key, "db") == 0 )
|
||||
db->db_database = value;
|
||||
else
|
||||
if( strcmpi(key, "bot_account_db") == 0 )
|
||||
safestrncpy(db->bot_account_db, value, sizeof(db->bot_account_db));
|
||||
else
|
||||
if (strcmpi(key, "login_account_db") == 0)
|
||||
safestrncpy(db->login_account_db, value, sizeof(db->login_account_db));
|
||||
//else
|
||||
//if( strcmpi(key, "global_acc_reg_str_table") == 0 )
|
||||
// safestrncpy(db->global_acc_reg_str_table, value, sizeof(db->global_acc_reg_str_table));
|
||||
//else
|
||||
//if( strcmpi(key, "global_acc_reg_num_table") == 0 )
|
||||
// safestrncpy(db->global_acc_reg_num_table, value, sizeof(db->global_acc_reg_num_table));
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
signature = "brokk_";
|
||||
if( strncmpi(key, signature, strlen(signature)) == 0 ) {
|
||||
key += strlen(signature);
|
||||
if( strcmpi(key, "codepage") == 0 )
|
||||
db->codepage = value;
|
||||
else
|
||||
if( strcmpi(key, "case_sensitive") == 0 )
|
||||
db->case_sensitive = (config_switch(value)==1);
|
||||
else
|
||||
return false;// not found
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;// not found
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new account entry.
|
||||
* acc->account_id = -1 means auto_decidet by server
|
||||
* bot_acc->account_id is always matching its login table counter part,
|
||||
* and its value will be written to bot_acc->account_id if everything succeeds.
|
||||
* @param self: pointer to db
|
||||
* @param acc: pointer of mmo_bot_account to save
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_create(BotAccountDB* self, struct mmo_bot_account* bot_acc) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
Sql* sql_handle_bot = db->bot_accounts;
|
||||
|
||||
// validate account id to assign
|
||||
uint32 account_id;
|
||||
account_id = bot_acc->account_id;
|
||||
|
||||
// zero value is prohibited
|
||||
if( account_id == 0 )
|
||||
return false;
|
||||
|
||||
// absolute maximum
|
||||
if( account_id > END_ACCOUNT_NUM )
|
||||
return false;
|
||||
|
||||
// insert the data into the database
|
||||
bot_acc->account_id = account_id;
|
||||
return mmo_bot_auth_tosql(db, bot_acc, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing bot account entry and its regs.
|
||||
* @param self: pointer to db
|
||||
* @param account_id: id of user account
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_remove(BotAccountDB* self, const uint32 account_id) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
Sql* sql_handle = db->bot_accounts;
|
||||
bool result = false;
|
||||
|
||||
if( SQL_SUCCESS != Sql_QueryStr(sql_handle, "START TRANSACTION")
|
||||
|| SQL_SUCCESS != Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = %d", db->bot_account_db, account_id)
|
||||
)
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else
|
||||
result = true;
|
||||
|
||||
result &= ( SQL_SUCCESS == Sql_QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing bot_account with the new data provided.
|
||||
* @param self: pointer to db
|
||||
* @param bot_acc: pointer of mmo_bot_account to save
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_save(BotAccountDB* self, const struct mmo_bot_account* bot_acc, bool refresh_token) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
return mmo_bot_auth_tosql(db, bot_acc, false, refresh_token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve data from db and store it in the provided data structure.
|
||||
* Filled data structure is done by delegation to mmo_bot_auth_fromsql.
|
||||
* @param self: pointer to db
|
||||
* @param bot_acc: pointer of mmo_bot_account to fill
|
||||
* @param account_id: id of user account
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_load_num(BotAccountDB* self, struct mmo_bot_account* bot_acc, const uint32 account_id) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
return mmo_bot_auth_fromsql(db, bot_acc, account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve data from db and store it in the provided data structure.
|
||||
* Doesn't actually retrieve data yet: escapes and checks userid, then transforms it to accid for fetching.
|
||||
* Filled data structure is done by delegation to bot_account_db_sql_load_num.
|
||||
* This function basicly fetches account_ids of all bots of an account
|
||||
* @param self: pointer to db
|
||||
* @param bot_acc: pointer of mmo_bot_account to fill
|
||||
* @param userid: name of user account
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_load_str(BotAccountDB* self, struct mmo_bot_account* bot_acc, const char* userid) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
Sql* sql_handle = db->bot_accounts;
|
||||
char esc_userid[2*NAME_LENGTH+1];
|
||||
uint32 account_id;
|
||||
char* data;
|
||||
|
||||
Sql_EscapeString(sql_handle, esc_userid, userid);
|
||||
|
||||
// get the list of account IDs for this userid
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `userid`= %s '%s'",
|
||||
db->login_account_db, (db->case_sensitive ? "BINARY" : ""), esc_userid) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( Sql_NumRows(sql_handle) > 1 )
|
||||
{// serious problem - duplicit account
|
||||
ShowError("bot_account_db_sql_load_str: multiple accounts found when retrieving data for account '%s'!\n", userid);
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
{// no such entry
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
//TODO FIXME this will only get the first found bot to a creator (Currently not a problem, because only one bot per account)
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr);
|
||||
account_id = atoi(data);
|
||||
|
||||
return bot_account_db_sql_load_num(self, bot_acc, account_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new forward iterator.
|
||||
* @param self: pointer to db iterator
|
||||
* @return a new db iterator
|
||||
*/
|
||||
static BotAccountDBIterator* bot_account_db_sql_iterator(BotAccountDB* self) {
|
||||
BotAccountDB_SQL* db = (BotAccountDB_SQL*)self;
|
||||
BotAccountDBIterator_SQL* iter = (BotAccountDBIterator_SQL*)aCalloc(1, sizeof(BotAccountDBIterator_SQL));
|
||||
|
||||
// set up the vtable
|
||||
iter->vtable.destroy = &bot_account_db_sql_iter_destroy;
|
||||
iter->vtable.next = &bot_account_db_sql_iter_next;
|
||||
|
||||
// fill data
|
||||
iter->db = db;
|
||||
iter->last_bot_account_id = -1;
|
||||
|
||||
return &iter->vtable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys this iterator, releasing all allocated memory (including itself).
|
||||
* @param self: pointer to db iterator
|
||||
*/
|
||||
static void bot_account_db_sql_iter_destroy(BotAccountDBIterator* self) {
|
||||
BotAccountDBIterator_SQL* iter = (BotAccountDBIterator_SQL*)self;
|
||||
aFree(iter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the next account in the database.
|
||||
* @param self: pointer to db iterator
|
||||
* @param bot_acc: pointer of mmo_bot_account to fill
|
||||
* @return true if next account found and filled, false if something has failed
|
||||
*/
|
||||
static bool bot_account_db_sql_iter_next(BotAccountDBIterator* self, struct mmo_bot_account* bot_acc) {
|
||||
BotAccountDBIterator_SQL* iter = (BotAccountDBIterator_SQL*)self;
|
||||
BotAccountDB_SQL* db = iter->db;
|
||||
Sql* sql_handle = db->bot_accounts;
|
||||
char* data;
|
||||
|
||||
// get next account ID
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id` FROM `%s` WHERE `account_id` > '%d' ORDER BY `account_id` ASC LIMIT 1",
|
||||
db->bot_account_db, iter->last_bot_account_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS == Sql_NextRow(sql_handle) &&
|
||||
SQL_SUCCESS == Sql_GetData(sql_handle, 0, &data, nullptr) &&
|
||||
data != nullptr )
|
||||
{// get account data
|
||||
uint32 account_id;
|
||||
account_id = atoi(data);
|
||||
if( mmo_bot_auth_fromsql(db, bot_acc, account_id) )
|
||||
{
|
||||
iter->last_bot_account_id = account_id;
|
||||
Sql_FreeResult(sql_handle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a struct mmo_bot_account from sql.
|
||||
* @param db: pointer to db
|
||||
* @param acc: pointer of mmo_bot_account to fill
|
||||
* @param account_id: id of user account to take data from
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool mmo_bot_auth_fromsql(BotAccountDB_SQL* db, struct mmo_bot_account* bot_acc, uint32 account_id) {
|
||||
Sql* sql_handle = db->bot_accounts;
|
||||
char* data;
|
||||
|
||||
// retrieve login entry for the specified account
|
||||
if( SQL_ERROR == Sql_Query(sql_handle,
|
||||
#ifdef VIP_ENABLE
|
||||
"SELECT `account_id`,`is_bot`,`creator_id`,`creator_name` FROM `%s` WHERE `account_id` = %d",
|
||||
#else
|
||||
"SELECT `account_id`,`is_bot`,`creator_id`,`creator_name` FROM `%s` WHERE `account_id` = %d",
|
||||
#endif
|
||||
db->bot_account_db, account_id )
|
||||
) {
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
{// no such entry
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr); bot_acc->account_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 1, &data, nullptr); bot_acc->is_bot = (uint8)atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, nullptr); bot_acc->creator_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 3, &data, nullptr); safestrncpy(bot_acc->creator_name, data, sizeof(bot_acc->creator_name));
|
||||
//ifdef VIP_ENABLE
|
||||
|
||||
//endif
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a struct mmo_bot_account in sql.
|
||||
* @param db: pointer to db
|
||||
* @param bot_acc: pointer of mmo_account to save
|
||||
* @param is_new: if it's a new entry or should we update
|
||||
* @return true if successful, false if something has failed
|
||||
*/
|
||||
static bool mmo_bot_auth_tosql(BotAccountDB_SQL* db, const struct mmo_bot_account* bot_acc, bool is_new, bool refresh_token) {
|
||||
Sql* sql_handle = db->bot_accounts;
|
||||
SqlStmt* stmt = SqlStmt_Malloc(sql_handle);
|
||||
bool result = false;
|
||||
|
||||
// try
|
||||
do
|
||||
{
|
||||
|
||||
if( SQL_SUCCESS != Sql_QueryStr(sql_handle, "START TRANSACTION") )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
}
|
||||
|
||||
if( is_new )
|
||||
{// insert into account table
|
||||
if( SQL_SUCCESS != SqlStmt_Prepare(stmt,
|
||||
#ifdef VIP_ENABLE
|
||||
"INSERT INTO `%s` (`account_id`, `is_bot`, `creator_id`, `creator_name`) VALUES (?, ?, ?, ?)",
|
||||
#else
|
||||
"INSERT INTO `%s` (`account_id`, `is_bot`, `creator_id`, `creator_name`) VALUES (?, ?, ?, ?)",
|
||||
#endif
|
||||
db->bot_account_db)
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_INT, (void*)&bot_acc->account_id, sizeof(bot_acc->account_id))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 1, SQLDT_SHORT, (void*)&bot_acc->is_bot, sizeof(bot_acc->is_bot))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 2, SQLDT_INT, (void*)&bot_acc->creator_id, sizeof(bot_acc->creator_id))
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 3, SQLDT_STRING, (void*)&bot_acc->creator_name, strlen(bot_acc->creator_name))
|
||||
//ifdef VIP_ENABLE
|
||||
//endif
|
||||
|| SQL_SUCCESS != SqlStmt_Execute(stmt)
|
||||
) {
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{// update is bot state (meaning if controlled by sindri or by other means)
|
||||
if( SQL_SUCCESS != SqlStmt_Prepare(stmt,
|
||||
#ifdef VIP_ENABLE
|
||||
"UPDATE `%s` SET `is_bot`=? WHERE `account_id` = '%d'",
|
||||
#else
|
||||
"UPDATE `%s` SET `is_bot`=? WHERE `account_id` = '%d'",
|
||||
#endif
|
||||
db->bot_account_db, bot_acc->account_id)
|
||||
|| SQL_SUCCESS != SqlStmt_BindParam(stmt, 0, SQLDT_STRING, (void*)bot_acc->is_bot, sizeof(bot_acc->is_bot))
|
||||
#ifdef VIP_ENABLE
|
||||
#endif
|
||||
|| SQL_SUCCESS != SqlStmt_Execute(stmt)
|
||||
) {
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we got this far, everything was successful
|
||||
result = true;
|
||||
|
||||
} while(0);
|
||||
// finally
|
||||
|
||||
result &= ( SQL_SUCCESS == Sql_QueryStr(sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") );
|
||||
SqlStmt_Free(stmt);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
void mmo_save_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id) {
|
||||
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
uint16 count = RFIFOW(fd, 12);
|
||||
|
||||
if (count) {
|
||||
int cursor = 14, i;
|
||||
char key[32], sval[254], esc_key[32*2+1], esc_sval[254*2+1];
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
uint32 index;
|
||||
safestrncpy(key, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
|
||||
Sql_EscapeString(sql_handle, esc_key, key);
|
||||
cursor += RFIFOB(fd, cursor) + 1;
|
||||
|
||||
index = RFIFOL(fd, cursor);
|
||||
cursor += 4;
|
||||
|
||||
switch (RFIFOB(fd, cursor++)) {
|
||||
// int
|
||||
case 0:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%" PRId64 "')", db->global_acc_reg_num_table, account_id, esc_key, index, RFIFOQ(fd, cursor)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
cursor += 8;
|
||||
break;
|
||||
case 1:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", db->global_acc_reg_num_table, account_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
// str
|
||||
case 2:
|
||||
safestrncpy(sval, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
|
||||
cursor += RFIFOB(fd, cursor) + 1;
|
||||
Sql_EscapeString(sql_handle, esc_sval, sval);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`key`,`index`,`value`) VALUES ('%" PRIu32 "','%s','%" PRIu32 "','%s')", db->global_acc_reg_str_table, account_id, esc_key, index, esc_sval) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 3:
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%" PRIu32 "' AND `key` = '%s' AND `index` = '%" PRIu32 "' LIMIT 1", db->global_acc_reg_str_table, account_id, esc_key, index) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
default:
|
||||
ShowError("mmo_save_global_accreg: unknown type %d\n",RFIFOB(fd, cursor - 1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
void mmo_send_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 char_id) {
|
||||
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
char* data;
|
||||
int16 plen = 0;
|
||||
size_t len;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%" PRIu32 "'", db->global_acc_reg_str_table, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 1; // is string type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
plen = 16;
|
||||
|
||||
//
|
||||
// * Vessel!
|
||||
// *
|
||||
// * str type
|
||||
// * { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
|
||||
//
|
||||
while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr);
|
||||
len = strlen(data)+1;
|
||||
|
||||
WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 32
|
||||
plen += 1;
|
||||
|
||||
safestrncpy(WFIFOCP(fd,plen), data, len);
|
||||
plen += static_cast<decltype(plen)>( len );
|
||||
|
||||
Sql_GetData(sql_handle, 1, &data, nullptr);
|
||||
|
||||
WFIFOL(fd, plen) = (uint32)atol(data);
|
||||
plen += 4;
|
||||
|
||||
Sql_GetData(sql_handle, 2, &data, nullptr);
|
||||
len = strlen(data)+1;
|
||||
|
||||
WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 254
|
||||
plen += 1;
|
||||
|
||||
safestrncpy(WFIFOCP(fd,plen), data, len);
|
||||
plen += static_cast<decltype(plen)>( len );
|
||||
|
||||
WFIFOW(fd, 14) += 1;
|
||||
|
||||
if( plen > 60000 ) {
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
// prepare follow up
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 1; // is string type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
plen = 16;
|
||||
}
|
||||
}
|
||||
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%" PRIu32 "'", db->global_acc_reg_num_table, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 0; // is int type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
plen = 16;
|
||||
|
||||
//
|
||||
// * Vessel!
|
||||
// *
|
||||
// * int type
|
||||
// * { keyLength(B), key(<keyLength>), index(L), value(L) }
|
||||
//
|
||||
while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
|
||||
Sql_GetData(sql_handle, 0, &data, nullptr);
|
||||
len = strlen(data)+1;
|
||||
|
||||
WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 32
|
||||
plen += 1;
|
||||
|
||||
safestrncpy(WFIFOCP(fd,plen), data, len);
|
||||
plen += static_cast<decltype(plen)>( len );
|
||||
|
||||
Sql_GetData(sql_handle, 1, &data, nullptr);
|
||||
|
||||
WFIFOL(fd, plen) = (uint32)atol(data);
|
||||
plen += 4;
|
||||
|
||||
Sql_GetData(sql_handle, 2, &data, nullptr);
|
||||
|
||||
WFIFOQ(fd, plen) = strtoll(data,nullptr,10);
|
||||
plen += 8;
|
||||
|
||||
WFIFOW(fd, 14) += 1;
|
||||
|
||||
if( plen > 60000 ) {
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
// prepare follow up
|
||||
WFIFOHEAD(fd, 60000 + 300);
|
||||
WFIFOW(fd, 0) = 0x2726;
|
||||
// 0x2 = length, set prior to being sent
|
||||
WFIFOL(fd, 4) = account_id;
|
||||
WFIFOL(fd, 8) = char_id;
|
||||
WFIFOB(fd, 12) = 0; // var type (only set when all vars have been sent, regardless of type)
|
||||
WFIFOB(fd, 13) = 0; // is int type
|
||||
WFIFOW(fd, 14) = 0; // count
|
||||
|
||||
plen = 16;
|
||||
}
|
||||
}
|
||||
|
||||
WFIFOB(fd, 12) = 1;
|
||||
WFIFOW(fd, 2) = plen;
|
||||
WFIFOSET(fd, plen);
|
||||
|
||||
Sql_FreeResult(sql_handle);
|
||||
}*/
|
||||
|
||||
/*
|
||||
bool account_db_sql_enable_webtoken( AccountDB* self, const uint32 account_id ){
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
|
||||
if( SQL_ERROR == Sql_Query( db->accounts, "UPDATE `%s` SET `web_auth_token_enabled` = '1' WHERE `account_id` = '%u'", db->account_db, account_id ) ){
|
||||
Sql_ShowDebug( db->accounts );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Timered function to disable webtoken for user
|
||||
* If the user is online, then they must have logged since we started the timer.
|
||||
* In that case, do nothing. The new authtoken must be valid.
|
||||
* @param tid: timer id
|
||||
* @param tick: tick of execution
|
||||
* @param id: user account id
|
||||
* @param data: BotAccountDB // because we don't use singleton???
|
||||
* @return :0
|
||||
|
||||
TIMER_FUNC(account_disable_webtoken_timer){
|
||||
const struct online_login_data* p = login_get_online_user(id);
|
||||
AccountDB_SQL* db = reinterpret_cast<AccountDB_SQL*>(data);
|
||||
|
||||
if (p == nullptr) {
|
||||
ShowInfo("Web Auth Token for account %d was disabled\n", id);
|
||||
if( SQL_ERROR == Sql_Query( db->accounts, "UPDATE `%s` SET `web_auth_token_enabled` = '0' WHERE `account_id` = '%u'", db->account_db, id ) ){
|
||||
Sql_ShowDebug( db->accounts );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
bool account_db_sql_disable_webtoken( AccountDB* self, const uint32 account_id ){
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
|
||||
//add_timer(gettick() + brokk_config.disable_webtoken_delay, account_disable_webtoken_timer, account_id, reinterpret_cast<intptr_t>(db));
|
||||
|
||||
return true;
|
||||
}*/
|
||||
/*
|
||||
bool account_db_sql_remove_webtokens( AccountDB* self ){
|
||||
AccountDB_SQL* db = (AccountDB_SQL*)self;
|
||||
|
||||
if( SQL_ERROR == Sql_Query( db->accounts, "UPDATE `%s` SET `web_auth_token` = NULL, `web_auth_token_enabled` = '0'", db->account_db ) ){
|
||||
Sql_ShowDebug( db->accounts );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
@ -0,0 +1,676 @@
|
||||
// Copyright (c) 4lexKidd
|
||||
// This software is licensed under the GPL v3 as to be fitting with the rathena project with the additional requirement
|
||||
// that any distributed versions must include an attribution to the original author (4lexKidd) in all copies
|
||||
// or substantial portions of the software.
|
||||
|
||||
#ifndef CONFIG_HELPERS_HPP
|
||||
#define CONFIG_HELPERS_HPP
|
||||
/*
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <common/cbasetypes.hpp>
|
||||
#include <common/database.hpp>
|
||||
*/
|
||||
/*Inter Configs
|
||||
struct inter_conf {
|
||||
uint32 start_status_points;
|
||||
bool emblem_woe_change;
|
||||
uint32 emblem_transparency_limit;
|
||||
};
|
||||
extern struct inter_conf inter_config;
|
||||
*/
|
||||
|
||||
//Brokk Configs
|
||||
/*
|
||||
struct Brokk_Config {
|
||||
uint32 brokk_ip; /// the address to bind to
|
||||
uint16 brokk_port; /// the port to bind to
|
||||
bool log_brokk; /// whether to log brokk server actions or not
|
||||
char date_format[32]; /// date format used in messages
|
||||
bool console; /// console input system enabled?
|
||||
|
||||
char brokkconf_name[256]; /// name of main config file
|
||||
char msgconf_name[256]; /// name of msg_conf config file
|
||||
bool destroy_all_on_shutdown; /// cleanup all bots on shutdown?
|
||||
uint32 allowed_bot_creations; /// number of allowed bot creations in quick succession
|
||||
uint8 acc_name_min_length; /// minimum account name length
|
||||
uint8 password_min_length; /// minimum password length
|
||||
int time_allowed; /// registration interval in seconds
|
||||
|
||||
bool use_web_auth_token; /// Enable web authentication token system
|
||||
int disable_webtoken_delay; /// delay disabling web token after char logs off in milliseconds
|
||||
|
||||
#ifdef VIP_ENABLE
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
extern struct Brokk_Config brokk_config;
|
||||
*/
|
||||
|
||||
bool config_read(const char* cfgName, bool normal);
|
||||
void set_defaults();
|
||||
|
||||
//Battle Configs
|
||||
#define MIN_HAIR_STYLE battle_config.min_hair_style
|
||||
#define MAX_HAIR_STYLE battle_config.max_hair_style
|
||||
#define MIN_HAIR_COLOR battle_config.min_hair_color
|
||||
#define MAX_HAIR_COLOR battle_config.max_hair_color
|
||||
#define MIN_CLOTH_COLOR battle_config.min_cloth_color
|
||||
#define MAX_CLOTH_COLOR battle_config.max_cloth_color
|
||||
#define MIN_BODY_STYLE battle_config.min_body_style
|
||||
#define MAX_BODY_STYLE battle_config.max_body_style
|
||||
/*
|
||||
struct Battle_Config
|
||||
{
|
||||
int warp_point_debug;
|
||||
int enable_critical;
|
||||
int mob_critical_rate;
|
||||
int critical_rate;
|
||||
int enable_baseatk, enable_baseatk_renewal;
|
||||
int enable_perfect_flee;
|
||||
int cast_rate, delay_rate;
|
||||
int delay_dependon_dex, delay_dependon_agi;
|
||||
int sdelay_attack_enable;
|
||||
int left_cardfix_to_right;
|
||||
int cardfix_monster_physical;
|
||||
int skill_add_range;
|
||||
int skill_out_range_consume;
|
||||
int skill_amotion_leniency;
|
||||
int skillrange_by_distance; //[Skotlex]
|
||||
int use_weapon_skill_range; //[Skotlex]
|
||||
int pc_damage_delay_rate;
|
||||
int defnotenemy;
|
||||
int vs_traps_bctall;
|
||||
int traps_setting;
|
||||
int summon_flora; //[Skotlex]
|
||||
int clear_unit_ondeath; //[Skotlex]
|
||||
int clear_unit_onwarp; //[Skotlex]
|
||||
int random_monster_checklv;
|
||||
int attr_recover;
|
||||
int item_auto_get;
|
||||
int flooritem_lifetime;
|
||||
int item_first_get_time;
|
||||
int item_second_get_time;
|
||||
int item_third_get_time;
|
||||
int mvp_item_first_get_time;
|
||||
int mvp_item_second_get_time;
|
||||
int mvp_item_third_get_time;
|
||||
int base_exp_rate, job_exp_rate;
|
||||
int drop_rate0item;
|
||||
int death_penalty_type;
|
||||
int death_penalty_base, death_penalty_job;
|
||||
int pvp_exp; // [MouseJstr]
|
||||
int gtb_sc_immunity;
|
||||
int zeny_penalty;
|
||||
int restart_hp_rate;
|
||||
int restart_sp_rate;
|
||||
int mvp_exp_rate;
|
||||
int mvp_hp_rate;
|
||||
int monster_hp_rate;
|
||||
int monster_max_aspd;
|
||||
int view_range_rate;
|
||||
int chase_range_rate;
|
||||
int atc_spawn_quantity_limit;
|
||||
int atc_slave_clone_limit;
|
||||
int partial_name_scan;
|
||||
int skillfree;
|
||||
int skillup_limit;
|
||||
int wp_rate;
|
||||
int pp_rate;
|
||||
int monster_active_enable;
|
||||
int monster_damage_delay_rate;
|
||||
int monster_loot_type;
|
||||
int mob_skill_rate; //[Skotlex]
|
||||
int mob_skill_delay; //[Skotlex]
|
||||
int mob_count_rate;
|
||||
int no_spawn_on_player; //[Skotlex]
|
||||
int force_random_spawn; //[Skotlex]
|
||||
int mob_spawn_delay, plant_spawn_delay, boss_spawn_delay; // [Skotlex]
|
||||
int slaves_inherit_mode;
|
||||
int slaves_inherit_speed;
|
||||
int summons_trigger_autospells;
|
||||
int pc_walk_delay_rate; //Adjusts can't walk delay after being hit for players. [Skotlex]
|
||||
int walk_delay_rate; //Adjusts can't walk delay after being hit. [Skotlex]
|
||||
int multihit_delay; //Adjusts can't walk delay per hit on multi-hitting skills. [Skotlex]
|
||||
int quest_skill_learn;
|
||||
int quest_skill_reset;
|
||||
int basic_skill_check;
|
||||
int guild_emperium_check;
|
||||
int guild_exp_limit;
|
||||
int guild_max_castles;
|
||||
int guild_skill_relog_delay;
|
||||
int guild_skill_relog_type;
|
||||
int emergency_call;
|
||||
int guild_aura;
|
||||
int pc_invincible_time;
|
||||
|
||||
int pet_catch_rate;
|
||||
int pet_rename;
|
||||
int pet_friendly_rate;
|
||||
int pet_hungry_delay_rate;
|
||||
int pet_hungry_friendly_decrease;
|
||||
int pet_status_support;
|
||||
int pet_attack_support;
|
||||
int pet_damage_support;
|
||||
int pet_support_min_friendly; //[Skotlex]
|
||||
int pet_support_rate;
|
||||
int pet_attack_exp_to_master;
|
||||
int pet_attack_exp_rate;
|
||||
int pet_lv_rate; //[Skotlex]
|
||||
int pet_max_stats; //[Skotlex]
|
||||
int pet_max_atk1; //[Skotlex]
|
||||
int pet_max_atk2; //[Skotlex]
|
||||
int pet_no_gvg; //Disables pets in gvg. [Skotlex]
|
||||
int pet_equip_required;
|
||||
int pet_unequip_destroy;
|
||||
int pet_master_dead;
|
||||
|
||||
int skill_min_damage;
|
||||
int finger_offensive_type;
|
||||
int heal_exp;
|
||||
int max_heal_lv;
|
||||
int max_heal; //Mitternacht
|
||||
int resurrection_exp;
|
||||
int shop_exp;
|
||||
int combo_delay_rate;
|
||||
int item_check;
|
||||
int item_use_interval; //[Skotlex]
|
||||
int cashfood_use_interval;
|
||||
int wedding_modifydisplay;
|
||||
int wedding_ignorepalette; //[Skotlex]
|
||||
int xmas_ignorepalette; // [Valaris]
|
||||
int summer_ignorepalette; // [Zephyrus]
|
||||
int hanbok_ignorepalette;
|
||||
int oktoberfest_ignorepalette;
|
||||
int natural_healhp_interval;
|
||||
int natural_healsp_interval;
|
||||
int natural_heal_skill_interval;
|
||||
int natural_heal_weight_rate;
|
||||
int natural_heal_weight_rate_renewal;
|
||||
int arrow_decrement;
|
||||
int ammo_unequip;
|
||||
int ammo_check_weapon;
|
||||
int max_aspd;
|
||||
int max_walk_speed; //Maximum walking speed after buffs [Skotlex]
|
||||
int max_hp_lv99;
|
||||
int max_hp_lv150;
|
||||
int max_hp;
|
||||
int max_sp;
|
||||
int max_lv, aura_lv;
|
||||
int max_parameter, max_baby_parameter;
|
||||
int max_cart_weight;
|
||||
int skill_log;
|
||||
int battle_log;
|
||||
int etc_log;
|
||||
int save_clothcolor;
|
||||
int undead_detect_type;
|
||||
int auto_counter_type;
|
||||
int min_hitrate; //[Skotlex]
|
||||
int max_hitrate; //[Skotlex]
|
||||
int agi_penalty_target;
|
||||
int agi_penalty_type;
|
||||
int agi_penalty_count;
|
||||
int agi_penalty_num;
|
||||
int vit_penalty_target;
|
||||
int vit_penalty_type;
|
||||
int vit_penalty_count;
|
||||
int vit_penalty_num;
|
||||
int weapon_defense_type;
|
||||
int magic_defense_type;
|
||||
int skill_reiteration;
|
||||
int skill_nofootset;
|
||||
int pc_cloak_check_type;
|
||||
int monster_cloak_check_type;
|
||||
int estimation_type;
|
||||
int gvg_short_damage_rate;
|
||||
int gvg_long_damage_rate;
|
||||
int gvg_weapon_damage_rate;
|
||||
int gvg_magic_damage_rate;
|
||||
int gvg_misc_damage_rate;
|
||||
int gvg_flee_penalty;
|
||||
int pk_short_damage_rate;
|
||||
int pk_long_damage_rate;
|
||||
int pk_weapon_damage_rate;
|
||||
int pk_magic_damage_rate;
|
||||
int pk_misc_damage_rate;
|
||||
int mob_changetarget_byskill;
|
||||
int attack_direction_change;
|
||||
int land_skill_limit;
|
||||
int monster_class_change_recover;
|
||||
int produce_item_name_input;
|
||||
int display_skill_fail;
|
||||
int chat_warpportal;
|
||||
int mob_warp;
|
||||
int dead_branch_active;
|
||||
int vending_max_value;
|
||||
int vending_over_max;
|
||||
int vending_tax;
|
||||
int vending_tax_min;
|
||||
int show_steal_in_same_party;
|
||||
int party_share_type;
|
||||
int party_hp_mode;
|
||||
int party_show_share_picker;
|
||||
int show_picker_item_type;
|
||||
int attack_attr_none;
|
||||
int item_rate_mvp, item_rate_common, item_rate_common_boss, item_rate_card, item_rate_card_boss,
|
||||
item_rate_equip, item_rate_equip_boss, item_rate_heal, item_rate_heal_boss, item_rate_use,
|
||||
item_rate_use_boss, item_rate_treasure, item_rate_adddrop;
|
||||
int item_rate_common_mvp, item_rate_heal_mvp, item_rate_use_mvp, item_rate_equip_mvp, item_rate_card_mvp;
|
||||
|
||||
int logarithmic_drops;
|
||||
int item_drop_common_min, item_drop_common_max; // Added by TyrNemesis^
|
||||
int item_drop_card_min, item_drop_card_max;
|
||||
int item_drop_equip_min, item_drop_equip_max;
|
||||
int item_drop_mvp_min, item_drop_mvp_max; // End Addition
|
||||
int item_drop_mvp_mode; //rAthena addition [Playtester]
|
||||
int item_drop_heal_min, item_drop_heal_max; // Added by Valatris
|
||||
int item_drop_use_min, item_drop_use_max; //End
|
||||
int item_drop_treasure_min, item_drop_treasure_max; //by [Skotlex]
|
||||
int item_drop_adddrop_min, item_drop_adddrop_max; //[Skotlex]
|
||||
|
||||
int prevent_logout; // Added by RoVeRT
|
||||
int prevent_logout_trigger;
|
||||
int land_protector_behavior;
|
||||
int npc_emotion_behavior;
|
||||
|
||||
int alchemist_summon_reward; // [Valaris]
|
||||
int drops_by_luk;
|
||||
int drops_by_luk2;
|
||||
int equip_natural_break_rate; //Base Natural break rate for attacks.
|
||||
int equip_self_break_rate; //Natural & Penalty skills break rate
|
||||
int equip_skill_break_rate; //Offensive skills break rate
|
||||
int multi_level_up;
|
||||
int multi_level_up_base;
|
||||
int multi_level_up_job;
|
||||
int max_exp_gain_rate; //Max amount of exp bar % you can get in one go.
|
||||
int pk_mode;
|
||||
int pk_mode_mes;
|
||||
int pk_level_range;
|
||||
|
||||
int manner_system; // end additions [Valaris]
|
||||
int show_mob_info;
|
||||
|
||||
int gx_allhit;
|
||||
int gx_disptype;
|
||||
int devotion_level_difference;
|
||||
int player_skill_partner_check;
|
||||
int invite_request_check;
|
||||
int skill_removetrap_type;
|
||||
int disp_experience;
|
||||
int disp_zeny;
|
||||
int backstab_bow_penalty;
|
||||
int hp_rate;
|
||||
int sp_rate;
|
||||
int bone_drop;
|
||||
int buyer_name;
|
||||
int dancing_weaponswitch_fix;
|
||||
|
||||
// eAthena additions
|
||||
int night_at_start; // added by [Yor]
|
||||
int day_duration; // added by [Yor]
|
||||
int night_duration; // added by [Yor]
|
||||
int ban_hack_trade; // added by [Yor]
|
||||
|
||||
int min_hair_style; // added by [MouseJstr]
|
||||
int max_hair_style; // added by [MouseJstr]
|
||||
int min_hair_color; // added by [MouseJstr]
|
||||
int max_hair_color; // added by [MouseJstr]
|
||||
int min_cloth_color; // added by [MouseJstr]
|
||||
int max_cloth_color; // added by [MouseJstr]
|
||||
int pet_hair_style; // added by [Skotlex]
|
||||
|
||||
int castrate_dex_scale; // added by [MouseJstr]
|
||||
int area_size; // added by [MouseJstr]
|
||||
|
||||
int max_def, over_def_bonus; //added by [Skotlex]
|
||||
|
||||
int zeny_from_mobs; // [Valaris]
|
||||
int mobs_level_up; // [Valaris]
|
||||
int mobs_level_up_exp_rate; // [Valaris]
|
||||
int pk_min_level; // [celest]
|
||||
int skill_steal_max_tries; //max steal skill tries on a mob. if 0, then w/o limit [Lupus]
|
||||
int skill_steal_random_options;
|
||||
int motd_type; // [celest]
|
||||
int finding_ore_rate; // orn
|
||||
int exp_calc_type;
|
||||
int exp_bonus_attacker;
|
||||
int exp_bonus_max_attacker;
|
||||
int min_skill_delay_limit;
|
||||
int default_walk_delay;
|
||||
int no_skill_delay;
|
||||
int attack_walk_delay;
|
||||
int require_glory_guild;
|
||||
int idle_no_share;
|
||||
int party_update_interval;
|
||||
int party_even_share_bonus;
|
||||
int delay_battle_damage;
|
||||
int hide_woe_damage;
|
||||
int display_version;
|
||||
|
||||
int display_hallucination; // [Skotlex]
|
||||
int use_statpoint_table; // [Skotlex]
|
||||
|
||||
int debuff_on_logout; // Removes a few "official" negative Scs on logout. [Skotlex]
|
||||
int mob_ai; //Configures various mob_ai settings to make them smarter or dumber(official). [Skotlex]
|
||||
int hom_setting; //Configures various homunc settings which make them behave unlike normal characters.. [Skotlex]
|
||||
int dynamic_mobs; // Dynamic Mobs [Wizputer] - battle_athena flag implemented by [random]
|
||||
int mob_remove_damaged; // Dynamic Mobs - Remove mobs even if damaged [Wizputer]
|
||||
int mob_remove_delay; // Dynamic Mobs - delay before removing mobs from a map [Skotlex]
|
||||
int mob_active_time; //Duration through which mobs execute their Hard AI after players leave their area of sight.
|
||||
int boss_active_time;
|
||||
|
||||
int show_hp_sp_drain, show_hp_sp_gain; //[Skotlex]
|
||||
|
||||
int mob_npc_event_type; //Determines on who the npc_event is executed. [Skotlex]
|
||||
|
||||
int character_size; // if riders have size=2, and baby class riders size=1 [Lupus]
|
||||
int mob_max_skilllvl; // Max possible skill level [Lupus]
|
||||
int rare_drop_announce; // chance <= to show rare drops global announces
|
||||
int drop_rate_cap; // Drop rate can't be raised above this amount by drop bonus items
|
||||
int drop_rate_cap_vip;
|
||||
|
||||
int retaliate_to_master; //Whether when a mob is attacked by another mob, it will retaliate versus the mob or the mob's master. [Skotlex]
|
||||
|
||||
int duel_allow_pvp; // [LuzZza]
|
||||
int duel_allow_gvg; // [LuzZza]
|
||||
int duel_allow_teleport; // [LuzZza]
|
||||
int duel_autoleave_when_die; // [LuzZza]
|
||||
int duel_time_interval; // [LuzZza]
|
||||
int duel_only_on_same_map; // [Toms]
|
||||
|
||||
int skip_teleport_lv1_menu; // possibility to disable (skip) Teleport Lv1 menu, that have only two lines `Random` and `Cancel` [LuzZza]
|
||||
|
||||
int allow_skill_without_day; // [Komurka]
|
||||
int allow_es_magic_pc; // [Skotlex]
|
||||
int skill_wall_check; // [Skotlex]
|
||||
int official_cell_stack_limit; // [Playtester]
|
||||
int custom_cell_stack_limit; // [Skotlex]
|
||||
int skill_caster_check; // [Skotlex]
|
||||
int sc_castcancel; // [Skotlex]
|
||||
int pc_sc_def_rate; // [Skotlex]
|
||||
int mob_sc_def_rate;
|
||||
int pc_max_sc_def;
|
||||
int mob_max_sc_def;
|
||||
|
||||
int sg_angel_skill_ratio;
|
||||
int sg_miracle_skill_ratio;
|
||||
int sg_miracle_skill_duration;
|
||||
int autospell_stacking; //Enables autospell cards to stack. [Skotlex]
|
||||
int override_mob_names; //Enables overriding spawn mob names with the mob_db names. [Skotlex]
|
||||
int min_chat_delay; //Minimum time between client messages. [Skotlex]
|
||||
int friend_auto_add; //When accepting friends, both get friended. [Skotlex]
|
||||
int hvan_explosion_intimate; // fix [albator]
|
||||
int hom_rename;
|
||||
int homunculus_show_growth; //[orn]
|
||||
int homunculus_friendly_rate;
|
||||
int quest_exp_rate;
|
||||
int autotrade_mapflag;
|
||||
int at_timeout;
|
||||
int homunculus_autoloot;
|
||||
int idle_no_autoloot;
|
||||
int max_guild_alliance;
|
||||
int ksprotection;
|
||||
int auction_feeperhour;
|
||||
int auction_maximumprice;
|
||||
int homunculus_auto_vapor; //Keep Homunculus from Vaporizing when master dies. [L0ne_W0lf]
|
||||
int display_status_timers; //Show or hide skill buff/delay timers in recent clients [Sara]
|
||||
int skill_add_heal_rate; //skills that bHealPower has effect on [Inkfish]
|
||||
int eq_single_target_reflectable;
|
||||
int invincible_nodamage;
|
||||
int mob_slave_keep_target;
|
||||
int autospell_check_range; //Enable range check for autospell bonus. [L0ne_W0lf]
|
||||
int knockback_left;
|
||||
int client_reshuffle_dice; // Reshuffle /dice
|
||||
int client_sort_storage;
|
||||
int feature_buying_store;
|
||||
int feature_search_stores;
|
||||
int searchstore_querydelay;
|
||||
int searchstore_maxresults;
|
||||
int display_party_name;
|
||||
int cashshop_show_points;
|
||||
int mail_show_status;
|
||||
int client_limit_unit_lv;
|
||||
int hom_max_level;
|
||||
int hom_S_max_level;
|
||||
int hom_S_growth_level;
|
||||
|
||||
// [BattleGround Settings]
|
||||
int bg_update_interval;
|
||||
int bg_short_damage_rate;
|
||||
int bg_long_damage_rate;
|
||||
int bg_weapon_damage_rate;
|
||||
int bg_magic_damage_rate;
|
||||
int bg_misc_damage_rate;
|
||||
int bg_flee_penalty;
|
||||
|
||||
// rAthena
|
||||
int max_third_parameter;
|
||||
int max_baby_third_parameter;
|
||||
int max_trans_parameter;
|
||||
int max_third_trans_parameter;
|
||||
int max_extended_parameter;
|
||||
int max_summoner_parameter;
|
||||
int max_fourth_parameter;
|
||||
int max_third_aspd;
|
||||
int max_summoner_aspd;
|
||||
int vcast_stat_scale;
|
||||
|
||||
int mvp_tomb_enabled;
|
||||
int mvp_tomb_delay;
|
||||
|
||||
int atcommand_suggestions_enabled;
|
||||
int min_npc_vendchat_distance;
|
||||
int atcommand_mobinfo_type;
|
||||
|
||||
int mob_size_influence; // Enable modifications on earned experience, drop rates and monster status depending on monster size. [mkbu95]
|
||||
int skill_trap_type;
|
||||
int allow_consume_restricted_item;
|
||||
int allow_equip_restricted_item;
|
||||
int max_walk_path;
|
||||
int item_enabled_npc;
|
||||
int item_onfloor; // Whether to drop an undroppable item on the map or destroy it if inventory is full.
|
||||
int bowling_bash_area;
|
||||
int drop_rateincrease;
|
||||
int feature_auction;
|
||||
int feature_banking;
|
||||
int vip_storage_increase;
|
||||
int vip_base_exp_increase;
|
||||
int vip_job_exp_increase;
|
||||
int vip_zeny_penalty;
|
||||
int vip_bm_increase;
|
||||
int vip_drop_increase;
|
||||
int vip_gemstone;
|
||||
int vip_exp_penalty_base;
|
||||
int vip_exp_penalty_job;
|
||||
int vip_disp_rate;
|
||||
int mon_trans_disable_in_gvg;
|
||||
int discount_item_point_shop;
|
||||
int update_enemy_position;
|
||||
int devotion_rdamage;
|
||||
int feature_itemlink;
|
||||
int feature_mesitemlink;
|
||||
int feature_mesitemlink_brackets;
|
||||
int feature_mesitemlink_dbname;
|
||||
|
||||
// autotrade persistency
|
||||
int feature_autotrade;
|
||||
int feature_autotrade_direction;
|
||||
int feature_autotrade_head_direction;
|
||||
int feature_autotrade_sit;
|
||||
int feature_autotrade_open_delay;
|
||||
|
||||
// Fame points
|
||||
int fame_taekwon_mission;
|
||||
int fame_refine_lv1;
|
||||
int fame_refine_lv2;
|
||||
int fame_refine_lv3;
|
||||
int fame_forge;
|
||||
int fame_pharmacy_3;
|
||||
int fame_pharmacy_5;
|
||||
int fame_pharmacy_7;
|
||||
int fame_pharmacy_10;
|
||||
|
||||
int disp_servervip_msg;
|
||||
int warg_can_falcon;
|
||||
int path_blown_halt;
|
||||
int rental_mount_speed_boost;
|
||||
int warp_suggestions_enabled;
|
||||
int taekwon_mission_mobname;
|
||||
int teleport_on_portal;
|
||||
int cart_revo_knockback;
|
||||
int guild_notice_changemap;
|
||||
int transcendent_status_points;
|
||||
int taekwon_ranker_min_lv;
|
||||
int revive_onwarp;
|
||||
int mail_delay;
|
||||
int autotrade_monsterignore;
|
||||
int idletime_option;
|
||||
int spawn_direction;
|
||||
int arrow_shower_knockback;
|
||||
int devotion_rdamage_skill_only;
|
||||
int max_extended_aspd;
|
||||
int mob_chase_refresh; //How often a monster should refresh its chase [Playtester]
|
||||
int mob_icewall_walk_block; //How a normal monster should be trapped in icewall [Playtester]
|
||||
int boss_icewall_walk_block; //How a boss monster should be trapped in icewall [Playtester]
|
||||
int snap_dodge; // Enable or disable dodging damage snapping away [csnv]
|
||||
int stormgust_knockback;
|
||||
int default_fixed_castrate;
|
||||
int default_bind_on_equip;
|
||||
int pet_ignore_infinite_def; // Makes fixed damage of petskillattack2 ignores infinite defense
|
||||
int homunculus_evo_intimacy_need;
|
||||
int homunculus_evo_intimacy_reset;
|
||||
int monster_loot_search_type;
|
||||
int feature_roulette;
|
||||
int feature_roulette_bonus_reward;
|
||||
int monster_hp_bars_info;
|
||||
int min_body_style;
|
||||
int max_body_style;
|
||||
int save_body_style;
|
||||
int mob_eye_range_bonus; //Vulture's Eye and Snake's Eye range bonus
|
||||
int mob_stuck_warning; //Show warning if a monster is stuck too long
|
||||
int skill_eightpath_algorithm; //Official path algorithm
|
||||
int skill_eightpath_same_cell;
|
||||
int death_penalty_maxlv;
|
||||
int exp_cost_redemptio;
|
||||
int exp_cost_redemptio_limit;
|
||||
int mvp_exp_reward_message;
|
||||
int can_damage_skill; //Which BL types can damage traps
|
||||
int atcommand_levelup_events;
|
||||
int atcommand_disable_npc;
|
||||
int block_account_in_same_party;
|
||||
int tarotcard_equal_chance; //Official or equal chance for each card
|
||||
int change_party_leader_samemap;
|
||||
int dispel_song; //Can songs be dispelled?
|
||||
int guild_maprespawn_clones; // Should clones be killed by maprespawnguildid?
|
||||
int hide_fav_sell;
|
||||
int mail_daily_count;
|
||||
int mail_zeny_fee;
|
||||
int mail_attachment_price;
|
||||
int mail_attachment_weight;
|
||||
int banana_bomb_duration;
|
||||
int guild_leaderchange_delay;
|
||||
int guild_leaderchange_woe;
|
||||
int guild_alliance_onlygm;
|
||||
int feature_achievement;
|
||||
int allow_bound_sell;
|
||||
int autoloot_adjust;
|
||||
int feature_petevolution;
|
||||
int feature_pet_autofeed;
|
||||
int feature_pet_autofeed_rate;
|
||||
int pet_autofeed_always;
|
||||
int broadcast_hide_name;
|
||||
int skill_drop_items_full;
|
||||
int switch_remove_edp;
|
||||
int feature_homunculus_autofeed;
|
||||
int feature_homunculus_autofeed_rate;
|
||||
int summoner_race;
|
||||
int summoner_size;
|
||||
int homunculus_autofeed_always;
|
||||
int feature_attendance;
|
||||
int feature_privateairship;
|
||||
int rental_transaction;
|
||||
int min_shop_buy;
|
||||
int min_shop_sell;
|
||||
int feature_equipswitch;
|
||||
int pet_walk_speed;
|
||||
int blacksmith_fame_refine_threshold;
|
||||
int mob_nopc_idleskill_rate;
|
||||
int mob_nopc_move_rate;
|
||||
int boss_nopc_idleskill_rate;
|
||||
int boss_nopc_move_rate;
|
||||
int hom_idle_no_share;
|
||||
int idletime_hom_option;
|
||||
int devotion_standup_fix;
|
||||
int feature_bgqueue;
|
||||
int bgqueue_nowarp_mapflag;
|
||||
int homunculus_exp_gain;
|
||||
int rental_item_novalue;
|
||||
int ping_timer_interval;
|
||||
int ping_time;
|
||||
int show_skill_scale;
|
||||
int achievement_mob_share;
|
||||
int slave_stick_with_master;
|
||||
int at_logout_event;
|
||||
int homunculus_starving_rate;
|
||||
int homunculus_starving_delay;
|
||||
int drop_connection_on_quit;
|
||||
int mob_spawn_variance;
|
||||
int mercenary_autoloot;
|
||||
int mer_idle_no_share;
|
||||
int idletime_mer_option;
|
||||
int feature_refineui;
|
||||
int rndopt_drop_pillar;
|
||||
int pet_legacy_formula;
|
||||
int pet_distance_check;
|
||||
int pet_hide_check;
|
||||
|
||||
int instance_block_leave;
|
||||
int instance_block_leaderchange;
|
||||
int instance_block_invite;
|
||||
int instance_block_expulsion;
|
||||
// 4th Jobs Stuff
|
||||
int trait_points_job_change;
|
||||
int use_traitpoint_table;
|
||||
int max_trait_parameter;
|
||||
int max_res_mres_ignored;
|
||||
int max_ap;
|
||||
int ap_rate;
|
||||
int restart_ap_rate;
|
||||
int loose_ap_on_death;
|
||||
int loose_ap_on_map;
|
||||
int keep_ap_on_logout;
|
||||
int attack_machine_level_difference;
|
||||
|
||||
int feature_barter;
|
||||
int feature_barter_extended;
|
||||
int break_mob_equip;
|
||||
int macro_detection_retry;
|
||||
int macro_detection_timeout;
|
||||
int macro_detection_punishment;
|
||||
int macro_detection_punishment_time;
|
||||
|
||||
int feature_dynamicnpc_timeout;
|
||||
int feature_dynamicnpc_rangex;
|
||||
int feature_dynamicnpc_rangey;
|
||||
int feature_dynamicnpc_direction;
|
||||
|
||||
int mob_respawn_time;
|
||||
int mob_unlock_time;
|
||||
int map_edge_size;
|
||||
int randomize_center_cell;
|
||||
|
||||
int feature_stylist;
|
||||
int feature_banking_state_enforce;
|
||||
int instance_allow_reconnect;
|
||||
int synchronize_damage;
|
||||
int item_stacking;
|
||||
int hom_delay_reset_vaporize;
|
||||
int hom_delay_reset_warp;
|
||||
|
||||
#include <custom/battle_config_struct.inc>
|
||||
};
|
||||
|
||||
extern struct Battle_Config battle_config;
|
||||
*/
|
||||
#endif /* CONFIG_HELPERS_HPP */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,44 @@
|
||||
[
|
||||
{
|
||||
"userid": "BrokkBot1",
|
||||
"pass": "password",
|
||||
"sex": "M",
|
||||
"last_ip": "127.0.0.1",
|
||||
"characters": [
|
||||
{
|
||||
"name": "BrokkKnight",
|
||||
"str": 9,
|
||||
"agi": 9,
|
||||
"vit": 9,
|
||||
"int": 1,
|
||||
"dex": 1,
|
||||
"luk": 1,
|
||||
"slot": 0,
|
||||
"hair_style": 1,
|
||||
"hair_color": 0,
|
||||
"start_job": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"userid": "BrokkBot2",
|
||||
"pass": "password",
|
||||
"sex": "F",
|
||||
"last_ip": "127.0.0.1",
|
||||
"characters": [
|
||||
{
|
||||
"name": "BrokkDancer",
|
||||
"str": 1,
|
||||
"agi": 9,
|
||||
"vit": 1,
|
||||
"int": 9,
|
||||
"dex": 9,
|
||||
"luk": 1,
|
||||
"slot": 0,
|
||||
"hair_style": 2,
|
||||
"hair_color": 1,
|
||||
"start_job": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue