diff options
Diffstat (limited to 'src/char')
-rw-r--r-- | src/char/char.c | 1045 | ||||
-rw-r--r-- | src/char/geoip.c | 2 | ||||
-rw-r--r-- | src/char/int_auction.c | 32 | ||||
-rw-r--r-- | src/char/int_auction.h | 20 | ||||
-rw-r--r-- | src/char/int_elemental.c | 26 | ||||
-rw-r--r-- | src/char/int_elemental.h | 6 | ||||
-rw-r--r-- | src/char/int_guild.c | 41 | ||||
-rw-r--r-- | src/char/int_guild.h | 52 | ||||
-rw-r--r-- | src/char/int_homun.c | 8 | ||||
-rw-r--r-- | src/char/int_homun.h | 6 | ||||
-rw-r--r-- | src/char/int_mail.c | 4 | ||||
-rw-r--r-- | src/char/int_mail.h | 16 | ||||
-rw-r--r-- | src/char/int_mercenary.c | 2 | ||||
-rw-r--r-- | src/char/int_mercenary.h | 12 | ||||
-rw-r--r-- | src/char/int_party.c | 23 | ||||
-rw-r--r-- | src/char/int_party.h | 30 | ||||
-rw-r--r-- | src/char/int_pet.c | 2 | ||||
-rw-r--r-- | src/char/int_pet.h | 14 | ||||
-rw-r--r-- | src/char/int_quest.c | 2 | ||||
-rw-r--r-- | src/char/int_quest.h | 2 | ||||
-rw-r--r-- | src/char/int_storage.c | 14 | ||||
-rw-r--r-- | src/char/int_storage.h | 18 | ||||
-rw-r--r-- | src/char/inter.c | 80 | ||||
-rw-r--r-- | src/char/inter.h | 38 | ||||
-rw-r--r-- | src/char/pincode.c | 25 |
25 files changed, 755 insertions, 765 deletions
diff --git a/src/char/char.c b/src/char/char.c index d5adaa251..72ca563c3 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -46,9 +46,9 @@ #include "../common/utils.h" // private declarations -#define CHAR_CONF_NAME "conf/char-server.conf" -#define LAN_CONF_NAME "conf/subnet.conf" -#define SQL_CONF_NAME "conf/inter-server.conf" +#define CHAR_CONF_NAME "conf/char-server.conf" +#define LAN_CONF_NAME "conf/subnet.conf" +#define SQL_CONF_NAME "conf/inter-server.conf" char char_db[256] = "char"; char scdata_db[256] = "sc_data"; @@ -117,8 +117,8 @@ char char_name_letters[1024] = ""; // list of letters/symbols allowed (or not) i int char_del_level = 0; //From which level u can delete character [Lupus] int char_del_delay = 86400; -int log_char = 1; // logging char or not [devil] -int log_inter = 1; // logging inter or not [devil] +int log_char = 1; // logging char or not [devil] +int log_inter = 1; // logging inter or not [devil] int char_aegis_delete = 0; // Verify if char is in guild/party or char and reacts as Aegis does (doesn't allow deletion), see chr->delete2_req for more information @@ -284,8 +284,8 @@ void char_set_char_offline(int char_id, int account_id) Sql_ShowDebug(inter->sql_handle); } - if ((character = (struct online_char_data*)idb_get(chr->online_char_db, account_id)) != NULL) - { //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex] + if ((character = (struct online_char_data*)idb_get(chr->online_char_db, account_id)) != NULL) { + //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex] if( character->server > -1 ) if( chr->server[character->server].users > 0 ) // Prevent this value from going negative. chr->server[character->server].users--; @@ -434,7 +434,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) else errors++; } - + if ( (p->base_exp != cp->base_exp) || (p->base_level != cp->base_level) || (p->job_level != cp->job_level) || (p->job_exp != cp->job_exp) || @@ -454,14 +454,15 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) || (p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) || (p->uniqueitem_counter != cp->uniqueitem_counter ) - ) { //Save status + ) { + //Save status unsigned int opt = 0; - + if( p->allow_party ) opt |= OPT_ALLOW_PARTY; if( p->show_equip ) opt |= OPT_SHOW_EQUIP; - + if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d'," "`base_exp`='%u', `job_exp`='%u', `zeny`='%d'," "`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d'," @@ -488,7 +489,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) } else strcat(save_status, " status"); } - + if( p->bank_vault != cp->bank_vault || p->mod_exp != cp->mod_exp || p->mod_drop != cp->mod_drop || p->mod_death != cp->mod_death ) { if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`account_id`,`bank_vault`,`base_exp`,`base_drop`,`base_death`) VALUES ('%d','%d','%d','%d','%d')",account_data_db,p->account_id,p->bank_vault,p->mod_exp,p->mod_drop,p->mod_death) ) { Sql_ShowDebug(inter->sql_handle); @@ -503,7 +504,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->class_ != cp->class_) || (p->partner_id != cp->partner_id) || (p->father != cp->father) || (p->mother != cp->mother) || (p->child != cp->child) || - (p->karma != cp->karma) || (p->manner != cp->manner) || + (p->karma != cp->karma) || (p->manner != cp->manner) || (p->fame != cp->fame) ) { @@ -586,7 +587,6 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) //insert here. for( i = 0, count = 0; i < MAX_SKILL; ++i ) { if( p->skill[i].id != 0 && p->skill[i].flag != SKILL_FLAG_TEMPORARY ) { - if( p->skill[i].lv == 0 && ( p->skill[i].flag == SKILL_FLAG_PERM_GRANTED || p->skill[i].flag == SKILL_FLAG_PERMANENT ) ) continue; if( p->skill[i].flag != SKILL_FLAG_PERMANENT && p->skill[i].flag != SKILL_FLAG_PERM_GRANTED && (p->skill[i].flag - SKILL_FLAG_REPLACED_LV_0) == 0 ) @@ -620,8 +620,8 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) } } - if(diff == 1) - { //Save friends + if(diff == 1) { + //Save friends if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d'", friend_db, char_id) ) { Sql_ShowDebug(inter->sql_handle); @@ -674,7 +674,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) strcat(save_status, " hotkeys"); } #endif - + StrBuf->Destroy(&buf); if (save_status[0]!='\0' && save_log) ShowInfo("Saved char %d - %s:%s.\n", char_id, p->name, save_status); @@ -715,7 +715,7 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, int tabl StrBuf->Init(&buf); StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `bound`"); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) StrBuf->Printf(&buf, ", `card%d`", j); StrBuf->Printf(&buf, " FROM `%s` WHERE `%s`='%d'", tablename, selectoption, id); @@ -739,7 +739,7 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, int tabl SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &item.attribute, 0, NULL, NULL); SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &item.expire_time, 0, NULL, NULL); SQL->StmtBindColumn(stmt, 8, SQLDT_UCHAR, &item.bound, 0, NULL, NULL); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) SQL->StmtBindColumn(stmt, 9+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL); // bit array indicating which inventory items have already been matched @@ -756,29 +756,30 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, int tabl continue; if( items[i].nameid == item.nameid - && items[i].card[0] == item.card[0] - && items[i].card[2] == item.card[2] - && items[i].card[3] == item.card[3] - ) { //They are the same item. + && items[i].card[0] == item.card[0] + && items[i].card[2] == item.card[2] + && items[i].card[3] == item.card[3] + ) { + //They are the same item. ARR_FIND( 0, MAX_SLOTS, j, items[i].card[j] != item.card[j] ); - if( j == MAX_SLOTS && - items[i].amount == item.amount && - items[i].equip == item.equip && - items[i].identify == item.identify && - items[i].refine == item.refine && - items[i].attribute == item.attribute && - items[i].expire_time == item.expire_time && - items[i].bound == item.bound ) - ; //Do nothing. - else - { + if( j == MAX_SLOTS + && items[i].amount == item.amount + && items[i].equip == item.equip + && items[i].identify == item.identify + && items[i].refine == item.refine + && items[i].attribute == item.attribute + && items[i].expire_time == item.expire_time + && items[i].bound == item.bound + ) { + ; //Do nothing. + } else { // update all fields. StrBuf->Clear(&buf); StrBuf->Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u', `bound`='%d'", tablename, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].bound); - for( j = 0; j < MAX_SLOTS; ++j )for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j )for( j = 0; j < MAX_SLOTS; ++j ) StrBuf->Printf(&buf, ", `card%d`=%d", j, items[i].card[j]); - StrBuf->Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id); + StrBuf->Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id); if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) ) { @@ -804,7 +805,7 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, int tabl StrBuf->Clear(&buf); StrBuf->Printf(&buf, "INSERT INTO `%s`(`%s`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `bound`, `unique_id`", tablename, selectoption); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) StrBuf->Printf(&buf, ", `card%d`", j); StrBuf->AppendStr(&buf, ") VALUES "); @@ -823,7 +824,7 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, int tabl StrBuf->Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u', '%d', '%"PRIu64"'", id, items[i].nameid, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].bound, items[i].unique_id); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) StrBuf->Printf(&buf, ", '%d'", items[i].card[j]); StrBuf->AppendStr(&buf, ")"); } @@ -859,7 +860,7 @@ int char_inventory_to_sql(const struct item items[], int max, int id) { StrBuf->Init(&buf); StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `bound`"); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) StrBuf->Printf(&buf, ", `card%d`", j); StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`='%d'", inventory_db, id); @@ -884,7 +885,7 @@ int char_inventory_to_sql(const struct item items[], int max, int id) { SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &item.expire_time, 0, NULL, NULL); SQL->StmtBindColumn(stmt, 8, SQLDT_CHAR, &item.favorite, 0, NULL, NULL); SQL->StmtBindColumn(stmt, 9, SQLDT_UCHAR, &item.bound, 0, NULL, NULL); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) SQL->StmtBindColumn(stmt, 10+j, SQLDT_SHORT, &item.card[j], 0, NULL, NULL); // bit array indicating which inventory items have already been matched @@ -899,28 +900,30 @@ int char_inventory_to_sql(const struct item items[], int max, int id) { continue; if( items[i].nameid == item.nameid - && items[i].card[0] == item.card[0] - && items[i].card[2] == item.card[2] - && items[i].card[3] == item.card[3] - ) { //They are the same item. + && items[i].card[0] == item.card[0] + && items[i].card[2] == item.card[2] + && items[i].card[3] == item.card[3] + ) { + //They are the same item. ARR_FIND( 0, MAX_SLOTS, j, items[i].card[j] != item.card[j] ); - if( j == MAX_SLOTS && - items[i].amount == item.amount && - items[i].equip == item.equip && - items[i].identify == item.identify && - items[i].refine == item.refine && - items[i].attribute == item.attribute && - items[i].expire_time == item.expire_time && - items[i].favorite == item.favorite && - items[i].bound == item.bound ) - ; //Do nothing. - else { + if( j == MAX_SLOTS + && items[i].amount == item.amount + && items[i].equip == item.equip + && items[i].identify == item.identify + && items[i].refine == item.refine + && items[i].attribute == item.attribute + && items[i].expire_time == item.expire_time + && items[i].favorite == item.favorite + && items[i].bound == item.bound + ) { + ; //Do nothing. + } else { // update all fields. StrBuf->Clear(&buf); StrBuf->Printf(&buf, "UPDATE `%s` SET `amount`='%d', `equip`='%d', `identify`='%d', `refine`='%d',`attribute`='%d', `expire_time`='%u', `favorite`='%d', `bound`='%d'", - inventory_db, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].favorite, items[i].bound); - for( j = 0; j < MAX_SLOTS; ++j ) - StrBuf->Printf(&buf, ", `card%d`=%d", j, items[i].card[j]); + inventory_db, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].favorite, items[i].bound); + for( j = 0; j < MAX_SLOTS; ++j ) + StrBuf->Printf(&buf, ", `card%d`=%d", j, items[i].card[j]); StrBuf->Printf(&buf, " WHERE `id`='%d' LIMIT 1", item.id); if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, StrBuf->Value(&buf)) ) { @@ -944,7 +947,7 @@ int char_inventory_to_sql(const struct item items[], int max, int id) { StrBuf->Clear(&buf); StrBuf->Printf(&buf, "INSERT INTO `%s` (`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `bound`, `unique_id`", inventory_db); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) StrBuf->Printf(&buf, ", `card%d`", j); StrBuf->AppendStr(&buf, ") VALUES "); @@ -962,7 +965,7 @@ int char_inventory_to_sql(const struct item items[], int max, int id) { StrBuf->Printf(&buf, "('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%u', '%d', '%d', '%"PRIu64"'", id, items[i].nameid, items[i].amount, items[i].equip, items[i].identify, items[i].refine, items[i].attribute, items[i].expire_time, items[i].favorite, items[i].bound, items[i].unique_id); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) StrBuf->Printf(&buf, ", '%d'", items[i].card[j]); StrBuf->AppendStr(&buf, ")"); } @@ -1000,62 +1003,61 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) sd->found_char[i] = -1; sd->unban_time[i] = 0; } - + // read char data - if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT " + if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT " "`char_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`," "`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`," "`status_point`,`skill_point`,`option`,`karma`,`manner`,`hair`,`hair_color`," "`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom`,`last_map`,`rename`,`delete_date`," "`robe`,`slotchange`,`unban_time`,`sex`" " FROM `%s` WHERE `account_id`='%d' AND `char_num` < '%d'", char_db, sd->account_id, MAX_CHARS) - || SQL_ERROR == SQL->StmtExecute(stmt) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p.char_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &p.slot, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_SHORT, &p.class_, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_UINT, &p.base_level, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p.job_level, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_SHORT, &p.str, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p.agi, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p.vit, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_SHORT, &p.int_, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_SHORT, &p.dex, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_SHORT, &p.luk, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 15, SQLDT_INT, &p.max_hp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_UINT, &p.status_point, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p.skill_point, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p.hair, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.weapon, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.shield, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.head_top, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_USHORT, &p.rename, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p.robe, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_USHORT, &p.slotchange, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_LONG, &unban_time, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_ENUM, &sex, sizeof(sex), NULL, NULL) - ) - { + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p.char_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &p.slot, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_SHORT, &p.class_, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_UINT, &p.base_level, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p.job_level, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p.base_exp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p.job_exp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_INT, &p.zeny, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_SHORT, &p.str, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p.agi, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p.vit, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_SHORT, &p.int_, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_SHORT, &p.dex, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_SHORT, &p.luk, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 15, SQLDT_INT, &p.max_hp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_UINT, &p.status_point, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p.skill_point, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p.hair, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.weapon, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.shield, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.head_top, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_USHORT, &p.rename, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p.robe, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_USHORT, &p.slotchange, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_LONG, &unban_time, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_ENUM, &sex, sizeof(sex), NULL, NULL) + ) { SqlStmt_ShowDebug(stmt); SQL->StmtFree(stmt); return 0; } - + for( i = 0; i < MAX_CHARS && SQL_SUCCESS == SQL->StmtNextRow(stmt); i++ ) { p.last_point.map = mapindex->name2id(last_map); sd->found_char[p.slot] = p.char_id; @@ -1074,7 +1076,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) } j += chr->mmo_char_tobuf(WBUFP(buf, j), &p); } - + memset(sd->new_name,0,sizeof(sd->new_name)); SQL->StmtFree(stmt); @@ -1116,7 +1118,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every } // read char data - if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT " + if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT " "`char_id`,`account_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`," "`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`," "`status_point`,`skill_point`,`option`,`karma`,`manner`,`party_id`,`guild_id`,`pet_id`,`homun_id`,`elemental_id`,`hair`," @@ -1124,67 +1126,66 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every "`save_map`,`save_x`,`save_y`,`partner_id`,`father`,`mother`,`child`,`fame`,`rename`,`delete_date`,`robe`,`slotchange`," "`char_opt`,`font`,`uniqueitem_counter`,`sex`" " FROM `%s` WHERE `char_id`=? LIMIT 1", char_db) - || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SQL->StmtExecute(stmt) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->char_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &p->account_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR, &p->slot, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_SHORT, &p->class_, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p->base_level, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p->job_level, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p->base_exp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UINT, &p->job_exp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_INT, &p->zeny, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p->str, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p->agi, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_SHORT, &p->vit, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_SHORT, &p->int_, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_SHORT, &p->dex, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 15, SQLDT_SHORT, &p->luk, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p->max_hp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p->hp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p->max_sp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_INT, &p->sp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p->status_point, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p->skill_point, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UINT, &p->option, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_UCHAR, &p->karma, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p->manner, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_INT, &p->party_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_INT, &p->guild_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_INT, &p->pet_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_INT, &p->hom_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_INT, &p->ele_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p->hair, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->weapon, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->shield, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->head_top, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 39, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 40, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 41, SQLDT_STRING, &save_map, sizeof(save_map), NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 42, SQLDT_SHORT, &p->save_point.x, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 43, SQLDT_SHORT, &p->save_point.y, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 44, SQLDT_INT, &p->partner_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 45, SQLDT_INT, &p->father, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 46, SQLDT_INT, &p->mother, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 47, SQLDT_INT, &p->child, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 48, SQLDT_INT, &p->fame, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 49, SQLDT_USHORT, &p->rename, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 50, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 51, SQLDT_SHORT, &p->robe, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_USHORT, &p->slotchange, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 53, SQLDT_UINT, &opt, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 54, SQLDT_UCHAR, &p->font, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 55, SQLDT_UINT, &p->uniqueitem_counter, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 56, SQLDT_ENUM, &sex, sizeof(sex), NULL, NULL) - ) - { + || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->char_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &p->account_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR, &p->slot, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_SHORT, &p->class_, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_UINT, &p->base_level, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_UINT, &p->job_level, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &p->base_exp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UINT, &p->job_exp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_INT, &p->zeny, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_SHORT, &p->str, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 11, SQLDT_SHORT, &p->agi, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 12, SQLDT_SHORT, &p->vit, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 13, SQLDT_SHORT, &p->int_, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 14, SQLDT_SHORT, &p->dex, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 15, SQLDT_SHORT, &p->luk, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p->max_hp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p->hp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p->max_sp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_INT, &p->sp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p->status_point, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p->skill_point, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UINT, &p->option, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_UCHAR, &p->karma, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p->manner, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_INT, &p->party_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_INT, &p->guild_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_INT, &p->pet_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_INT, &p->hom_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_INT, &p->ele_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p->hair, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->weapon, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->shield, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->head_top, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 39, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 40, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 41, SQLDT_STRING, &save_map, sizeof(save_map), NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 42, SQLDT_SHORT, &p->save_point.x, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 43, SQLDT_SHORT, &p->save_point.y, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 44, SQLDT_INT, &p->partner_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 45, SQLDT_INT, &p->father, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 46, SQLDT_INT, &p->mother, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 47, SQLDT_INT, &p->child, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 48, SQLDT_INT, &p->fame, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 49, SQLDT_USHORT, &p->rename, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 50, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 51, SQLDT_SHORT, &p->robe, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_USHORT, &p->slotchange, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 53, SQLDT_UINT, &opt, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 54, SQLDT_UCHAR, &p->font, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 55, SQLDT_UINT, &p->uniqueitem_counter, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 56, SQLDT_ENUM, &sex, sizeof(sex), NULL, NULL) + ) { SqlStmt_ShowDebug(stmt); SQL->StmtFree(stmt); return 0; @@ -1195,7 +1196,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every SQL->StmtFree(stmt); return 0; } - + switch( sex[0] ) { case 'M': p->sex = 1; @@ -1208,9 +1209,9 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every p->sex = 99; break; } - + account_id = p->account_id; - + p->last_point.map = mapindex->name2id(last_map); p->save_point.map = mapindex->name2id(save_map); @@ -1219,13 +1220,13 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every p->last_point.x = MAP_DEFAULT_X; p->last_point.y = MAP_DEFAULT_Y; } - + if( p->save_point.map == 0 ) { p->save_point.map = (unsigned short)strdb_iget(mapindex->db, MAP_DEFAULT); p->save_point.x = MAP_DEFAULT_X; p->save_point.y = MAP_DEFAULT_Y; } - + strcat(t_msg, " status"); if (!load_everything) // For quick selection of data when displaying the char menu @@ -1237,12 +1238,13 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every //read memo data //`memo` (`memo_id`,`char_id`,`map`,`x`,`y`) memset(&tmp_point, 0, sizeof(tmp_point)); - if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`=? ORDER by `memo_id` LIMIT %d", memo_db, MAX_MEMOPOINTS) - || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SQL->StmtExecute(stmt) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_STRING, &point_map, sizeof(point_map), NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_point.x, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_point.y, 0, NULL, NULL) ) + if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`=? ORDER by `memo_id` LIMIT %d", memo_db, MAX_MEMOPOINTS) + || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_STRING, &point_map, sizeof(point_map), NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_point.x, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_point.y, 0, NULL, NULL) + ) SqlStmt_ShowDebug(stmt); for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i ) { @@ -1253,28 +1255,29 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every //read inventory //`inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, `expire_time`, `favorite`, `bound`, `unique_id`) - StrBuf->Init(&buf); + StrBuf->Init(&buf); StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `favorite`, `bound`, `unique_id`"); - for( i = 0; i < MAX_SLOTS; ++i ) + for( i = 0; i < MAX_SLOTS; ++i ) StrBuf->Printf(&buf, ", `card%d`", i); StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", inventory_db, MAX_INVENTORY); memset(&tmp_item, 0, sizeof(tmp_item)); - if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf)) - || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SQL->StmtExecute(stmt) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_UINT, &tmp_item.equip, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_CHAR, &tmp_item.favorite, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_UCHAR, &tmp_item.bound, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_UINT64, &tmp_item.unique_id, 0, NULL, NULL) ) - SqlStmt_ShowDebug(stmt); + if (SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf)) + || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_UINT, &tmp_item.equip, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_CHAR, &tmp_item.favorite, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_UCHAR, &tmp_item.bound, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 10, SQLDT_UINT64, &tmp_item.unique_id, 0, NULL, NULL) + ) + SqlStmt_ShowDebug(stmt); for( i = 0; i < MAX_SLOTS; ++i ) if( SQL_ERROR == SQL->StmtBindColumn(stmt, 11+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) ) SqlStmt_ShowDebug(stmt); @@ -1286,27 +1289,28 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every //read cart //`cart_inventory` (`id`,`char_id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `card0`, `card1`, `card2`, `card3`, expire_time`, `bound`, `unique_id`) - StrBuf->Clear(&buf); + StrBuf->Clear(&buf); StrBuf->AppendStr(&buf, "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`, `bound`, `unique_id`"); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) StrBuf->Printf(&buf, ", `card%d`", j); StrBuf->Printf(&buf, " FROM `%s` WHERE `char_id`=? LIMIT %d", cart_db, MAX_CART); memset(&tmp_item, 0, sizeof(tmp_item)); - if( SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf)) - || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SQL->StmtExecute(stmt) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_UINT, &tmp_item.equip, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UCHAR, &tmp_item.bound, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_UINT64, &tmp_item.unique_id, 0, NULL, NULL) ) - SqlStmt_ShowDebug(stmt); + if (SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf)) + || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_item.id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_SHORT, &tmp_item.nameid, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_SHORT, &tmp_item.amount, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_UINT, &tmp_item.equip, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 4, SQLDT_CHAR, &tmp_item.identify, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_CHAR, &tmp_item.refine, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_CHAR, &tmp_item.attribute, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 7, SQLDT_UINT, &tmp_item.expire_time, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 8, SQLDT_UCHAR, &tmp_item.bound, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 9, SQLDT_UINT64, &tmp_item.unique_id, 0, NULL, NULL) + ) + SqlStmt_ShowDebug(stmt); for( i = 0; i < MAX_SLOTS; ++i ) if( SQL_ERROR == SQL->StmtBindColumn(stmt, 10+i, SQLDT_SHORT, &tmp_item.card[i], 0, NULL, NULL) ) SqlStmt_ShowDebug(stmt); @@ -1322,14 +1326,15 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every //read skill //`skill` (`char_id`, `id`, `lv`) memset(&tmp_skill, 0, sizeof(tmp_skill)); - if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `id`, `lv`,`flag` FROM `%s` WHERE `char_id`=? LIMIT %d", skill_db, MAX_SKILL) - || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SQL->StmtExecute(stmt) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_USHORT, &tmp_skill.id , 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR , &tmp_skill.lv , 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR , &tmp_skill.flag, 0, NULL, NULL) ) + if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `id`, `lv`,`flag` FROM `%s` WHERE `char_id`=? LIMIT %d", skill_db, MAX_SKILL) + || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_USHORT, &tmp_skill.id , 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR , &tmp_skill.lv , 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UCHAR , &tmp_skill.flag, 0, NULL, NULL) + ) SqlStmt_ShowDebug(stmt); - + if( tmp_skill.flag != SKILL_FLAG_PERM_GRANTED ) tmp_skill.flag = SKILL_FLAG_PERMANENT; @@ -1344,12 +1349,12 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every //read friends //`friends` (`char_id`, `friend_account`, `friend_id`) memset(&tmp_friend, 0, sizeof(tmp_friend)); - if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_account` = c.`account_id` AND f.`friend_id` = c.`char_id` WHERE f.`char_id`=? LIMIT %d", char_db, friend_db, MAX_FRIENDS) - || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SQL->StmtExecute(stmt) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_friend.account_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &tmp_friend.char_id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &tmp_friend.name, sizeof(tmp_friend.name), NULL, NULL) ) + if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_account` = c.`account_id` AND f.`friend_id` = c.`char_id` WHERE f.`char_id`=? LIMIT %d", char_db, friend_db, MAX_FRIENDS) + || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_friend.account_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &tmp_friend.char_id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_STRING, &tmp_friend.name, sizeof(tmp_friend.name), NULL, NULL) ) SqlStmt_ShowDebug(stmt); for( i = 0; i < MAX_FRIENDS && SQL_SUCCESS == SQL->StmtNextRow(stmt); ++i ) @@ -1360,13 +1365,13 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every //read hotkeys //`hotkey` (`char_id`, `hotkey`, `type`, `itemskill_id`, `skill_lvl` memset(&tmp_hotkey, 0, sizeof(tmp_hotkey)); - if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`=?", hotkey_db) - || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) - || SQL_ERROR == SQL->StmtExecute(stmt) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &hotkey_num, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &tmp_hotkey.type, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UINT, &tmp_hotkey.id, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &tmp_hotkey.lv, 0, NULL, NULL) ) + if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`=?", hotkey_db) + || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &hotkey_num, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_UCHAR, &tmp_hotkey.type, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UINT, &tmp_hotkey.id, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &tmp_hotkey.lv, 0, NULL, NULL) ) SqlStmt_ShowDebug(stmt); while( SQL_SUCCESS == SQL->StmtNextRow(stmt) ) @@ -1385,21 +1390,21 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every /* default */ p->mod_exp = p->mod_drop = p->mod_death = 100; - + //`account_data` (`account_id`,`bank_vault`,`base_exp`,`base_drop`,`base_death`) - if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `bank_vault`,`base_exp`,`base_drop`,`base_death` FROM `%s` WHERE `account_id`=? LIMIT 1", account_data_db) - || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &account_id, 0) - || SQL_ERROR == SQL->StmtExecute(stmt) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->bank_vault, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_USHORT, &p->mod_exp, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_USHORT, &p->mod_drop, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &p->mod_death, 0, NULL, NULL) ) + if (SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `bank_vault`,`base_exp`,`base_drop`,`base_death` FROM `%s` WHERE `account_id`=? LIMIT 1", account_data_db) + || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &account_id, 0) + || SQL_ERROR == SQL->StmtExecute(stmt) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->bank_vault, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_USHORT, &p->mod_exp, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_USHORT, &p->mod_drop, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 3, SQLDT_USHORT, &p->mod_death, 0, NULL, NULL) ) SqlStmt_ShowDebug(stmt); - + if( SQL_SUCCESS == SQL->StmtNextRow(stmt) ) strcat(t_msg, " accdata"); - if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfully! + if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfully! SQL->StmtFree(stmt); StrBuf->Destroy(&buf); @@ -1408,7 +1413,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every p->allow_party = true; if( opt & OPT_SHOW_EQUIP ) p->show_equip = true; - + cp = idb_ensure(chr->char_db_, char_id, chr->create_charstatus); memcpy(cp, p, sizeof(struct mmo_charstatus)); return 1; @@ -1446,7 +1451,7 @@ bool char_char_slotchange(struct char_session_data *sd, int fd, unsigned short f return false; from_id = sd->found_char[from]; - + if( sd->found_char[to] > 0 ) {/* moving char to occupied slot */ bool result = false; /* update both at once */ @@ -1456,27 +1461,26 @@ bool char_char_slotchange(struct char_session_data *sd, int fd, unsigned short f Sql_ShowDebug(inter->sql_handle); else result = true; - + if( SQL_ERROR == SQL->QueryStr(inter->sql_handle, (result == true) ? "COMMIT" : "ROLLBACK") ) { Sql_ShowDebug(inter->sql_handle); result = false; } if( !result ) return false; - } else {/* slot is free. */ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `char_num`='%d' WHERE `char_id`='%d' LIMIT 1", char_db, to, sd->found_char[from] ) ) { Sql_ShowDebug(inter->sql_handle); return false; } } - + /* update count */ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `slotchange`=`slotchange`-1 WHERE `char_id`='%d' LIMIT 1", char_db, from_id ) ) { Sql_ShowDebug(inter->sql_handle); return false; } - + return true; } @@ -1605,7 +1609,7 @@ int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, i flag = chr->check_char_name(name,esc_name); if( flag < 0 ) return flag; - + //check other inputs #if PACKETVER >= 20120307 if(slot < 0 || slot >= sd->char_slots) @@ -1943,7 +1947,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { //When the weapon is sent and your option is riding, the client crashes on login!? WBUFW(buf,56) = p->option&(0x20|0x80000|0x100000|0x200000|0x400000|0x800000|0x1000000|0x2000000|0x4000000|0x8000000) ? 0 : p->weapon; #endif - + WBUFW(buf,58) = p->base_level; WBUFW(buf,60) = min(p->skill_point, INT16_MAX); WBUFW(buf,62) = p->head_bottom; @@ -1993,7 +1997,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { return 106+offset; } - + /* Made Possible by Yommy~! <3 */ void char_mmo_char_send099d(int fd, struct char_session_data *sd) { WFIFOHEAD(fd,4 + (MAX_CHARS*MAX_CHAR_BUF)); @@ -2007,16 +2011,15 @@ void char_mmo_char_send099d(int fd, struct char_session_data *sd) { void char_mmo_char_send_ban_list(int fd, struct char_session_data *sd) { int i; time_t now = time(NULL); - + ARR_FIND(0, MAX_CHARS, i, sd->unban_time[i]); - if( i != MAX_CHARS ) { int c; - + WFIFOHEAD(fd, 4 + (MAX_CHARS*24)); WFIFOW(fd, 0) = 0x20d; - + for(i = 0, c = 0; i < MAX_CHARS; i++) { if( sd->unban_time[i] ) { timestamp2string((char*)WFIFOP(fd,8 + (28*c)), 20, sd->unban_time[i], "%Y-%m-%d %H:%M:%S"); @@ -2034,9 +2037,9 @@ void char_mmo_char_send_ban_list(int fd, struct char_session_data *sd) { c++; } } - + WFIFOW(fd, 2) = 4 + (24*c); - + WFIFOSET(fd, WFIFOW(fd, 2)); } } @@ -2045,7 +2048,6 @@ void char_mmo_char_send_ban_list(int fd, struct char_session_data *sd) { // [Ind/Hercules] notify client about charselect window data //---------------------------------------- void char_mmo_char_send_slots_info(int fd, struct char_session_data* sd) { - WFIFOHEAD(fd,29); WFIFOW(fd,0) = 0x82d; WFIFOW(fd,2) = 29; @@ -2068,7 +2070,7 @@ int char_mmo_char_send_characters(int fd, struct char_session_data* sd) #endif if (save_log) ShowInfo("Loading Char Data ("CL_BOLD"%d"CL_RESET")\n",sd->account_id); - + j = 24 + offset; // offset WFIFOHEAD(fd,j + MAX_CHARS*MAX_CHAR_BUF); WFIFOW(fd,0) = 0x6b; @@ -2184,10 +2186,10 @@ static void char_auth_ok(int fd, struct char_session_data *sd) { struct online_char_data* character; - if( (character = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id)) != NULL ) - { // check if character is not online already. [Skotlex] - if (character->server > -1) - { //Character already online. KICK KICK KICK + if( (character = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id)) != NULL ) { + // check if character is not online already. [Skotlex] + if (character->server > -1) { + //Character already online. KICK KICK KICK mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 2); if (character->waiting_disconnect == INVALID_TIMER) character->waiting_disconnect = timer->add(timer->gettick()+20000, chr->waiting_disconnect, character->account_id, 0); @@ -2196,8 +2198,8 @@ static void char_auth_ok(int fd, struct char_session_data *sd) chr->authfail_fd(fd, 8); return; } - if (character->fd >= 0 && character->fd != fd) - { //There's already a connection from this account that hasn't picked a char yet. + if (character->fd >= 0 && character->fd != fd) { + //There's already a connection from this account that hasn't picked a char yet. chr->authfail_fd(fd, 8); return; } @@ -2457,7 +2459,7 @@ void mapif_ban(int id, unsigned int flag, int status) void char_parse_fromlogin_ban(int fd) { - mapif->ban(RFIFOL(fd,2), RFIFOB(fd,6), RFIFOL(fd,7)); + mapif->ban(RFIFOL(fd,2), RFIFOB(fd,6), RFIFOL(fd,7)); // disconnect player if online on char-server chr->disconnect_player(RFIFOL(fd,2)); RFIFOSKIP(fd,11); @@ -2470,8 +2472,8 @@ void char_parse_fromlogin_kick(int fd) RFIFOSKIP(fd,6); if( character != NULL ) {// account is already marked as online! - if( character->server > -1 ) - { //Kick it from the map server it is on. + if( character->server > -1 ) { + //Kick it from the map server it is on. mapif->disconnectplayer(chr->server[character->server].fd, character->account_id, character->char_id, 2); if (character->waiting_disconnect == INVALID_TIMER) character->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, chr->waiting_disconnect, character->account_id, 0); @@ -2514,8 +2516,8 @@ void char_parse_fromlogin_update_ip(int fd) login_ip = new_ip; //Update login ip, too. new_ip = host2ip(char_ip_str); - if (new_ip && new_ip != chr->ip) - { //Update ip. + if (new_ip && new_ip != chr->ip) { + //Update ip. chr->ip = new_ip; ShowInfo("Updating IP for [%s].\n", char_ip_str); // notify login server about the change @@ -2565,15 +2567,14 @@ int char_parse_fromlogin(int fd) { while(RFIFOREST(fd) >= 2) { uint16 command = RFIFOW(fd,0); - + if( HPM->packetsc[hpParse_FromLogin] ) { int success = HPM->parse_packets(fd,hpParse_FromLogin); if( success == 1 ) continue; else if( success == 2 ) return 0; } - - switch( command ) { + switch (command) { // acknowledgment of connect-to-loginserver request case 0x2711: if (RFIFOREST(fd) < 3) @@ -2708,47 +2709,43 @@ void char_global_accreg_to_login_send (void) { **/ void char_global_accreg_to_login_add (const char *key, unsigned int index, intptr_t val, bool is_string) { int nlen = WFIFOW(chr->login_fd, 2); - size_t len; - - len = strlen(key)+1; - + size_t len = strlen(key)+1; + WFIFOB(chr->login_fd, nlen) = (unsigned char)len;/* won't be higher; the column size is 32 */ nlen += 1; - + safestrncpy((char*)WFIFOP(chr->login_fd,nlen), key, len); nlen += len; - + WFIFOL(chr->login_fd, nlen) = index; nlen += 4; - + if( is_string ) { WFIFOB(chr->login_fd, nlen) = val ? 2 : 3; nlen += 1; - + if( val ) { char *sval = (char*)val; len = strlen(sval)+1; - + WFIFOB(chr->login_fd, nlen) = (unsigned char)len;/* won't be higher; the column size is 254 */ nlen += 1; - + safestrncpy((char*)WFIFOP(chr->login_fd,nlen), sval, len); nlen += len; } - } else { WFIFOB(chr->login_fd, nlen) = val ? 0 : 1; nlen += 1; - + if( val ) { WFIFOL(chr->login_fd, nlen) = (int)val; nlen += 4; } - } - + WFIFOW(chr->login_fd,12) += 1; - + WFIFOW(chr->login_fd, 2) = nlen; if( WFIFOW(chr->login_fd, 2) > 60000 ) { int account_id = WFIFOL(chr->login_fd,4), char_id = WFIFOL(chr->login_fd,8); @@ -3153,20 +3150,21 @@ void char_parse_frommap_save_character(int fd, int id) return; } //Check account only if this ain't final save. Final-save goes through because of the char-map reconnect - if (RFIFOB(fd,12) || ( - (character = (struct online_char_data*)idb_get(chr->online_char_db, aid)) != NULL && - character->char_id == cid)) - { + if (RFIFOB(fd,12) + || ( (character = (struct online_char_data*)idb_get(chr->online_char_db, aid)) != NULL + && character->char_id == cid) + ) { struct mmo_charstatus char_dat; memcpy(&char_dat, RFIFOP(fd,13), sizeof(struct mmo_charstatus)); chr->mmo_char_tosql(cid, &char_dat); - } else { //This may be valid on char-server reconnection, when re-sending characters that already logged off. + } else { + //This may be valid on char-server reconnection, when re-sending characters that already logged off. ShowError("parse_from_map (save-char): Received data for non-existing/offline character (%d:%d).\n", aid, cid); chr->set_char_online(id, cid, aid); } - if (RFIFOB(fd,12)) - { //Flag, set character offline after saving. [Skotlex] + if (RFIFOB(fd,12)) { + //Flag, set character offline after saving. [Skotlex] chr->set_char_offline(cid, aid); chr->save_character_ack(fd, aid, cid); } @@ -3241,16 +3239,15 @@ void char_parse_frommap_change_map_server(int fd) map_fd = chr->server[map_id].fd; //Char should just had been saved before this packet, so this should be safe. [Skotlex] char_data = (struct mmo_charstatus*)uidb_get(chr->char_db_,RFIFOL(fd,14)); - if (char_data == NULL) { //Really shouldn't happen. + if (char_data == NULL) { + //Really shouldn't happen. struct mmo_charstatus char_dat; chr->mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true); char_data = (struct mmo_charstatus*)uidb_get(chr->char_db_,RFIFOL(fd,14)); } - if( runflag == CHARSERVER_ST_RUNNING && - session_isActive(map_fd) && - char_data ) - { //Send the map server the auth of this player. + if (runflag == CHARSERVER_ST_RUNNING && session_isActive(map_fd) && char_data) { + //Send the map server the auth of this player. struct online_char_data* data; struct char_auth_node* node; @@ -3427,13 +3424,13 @@ void char_parse_frommap_change_account(int fd) SQL->GetData(inter->sql_handle, 1, &data, NULL); char_id = atoi(data); SQL->GetData(inter->sql_handle, 2, &data, NULL); unban_time = atol(data); - if( chr->login_fd <= 0 ) + if( chr->login_fd <= 0 ) { result = 3; // 3-login-server offline - //FIXME: need to move this check to login server [ultramage] - // else - // if( acc != -1 && isGM(acc) < isGM(account_id) ) - // result = 2; // 2-gm level too low - else { +#if 0 //FIXME: need to move this check to login server [ultramage] + } else if( acc != -1 && isGM(acc) < isGM(account_id) ) { + result = 2; // 2-gm level too low +#endif // 0 + } else { switch( type ) { case 1: // block loginif->block_account(account_id, 5); @@ -3791,16 +3788,14 @@ int char_parse_frommap(int fd) } while(RFIFOREST(fd) >= 2) { - if( HPM->packetsc[hpParse_FromMap] ) { if( (i = HPM->parse_packets(fd,hpParse_FromMap)) ) { if( i == 1 ) continue; if( i == 2 ) return 0; } } - - switch(RFIFOW(fd,0)) { + switch(RFIFOW(fd,0)) { case 0x2b0a: if( RFIFOREST(fd) < RFIFOW(fd, 2) ) return 0; @@ -3973,7 +3968,7 @@ int char_parse_frommap(int fd) chr->parse_frommap_request_stats_report(fd); } break; - + /* individual sc data insertion/update */ case 0x2740: if( RFIFOREST(fd) < 28 ) @@ -3992,13 +3987,12 @@ int char_parse_frommap(int fd) } break; - default: { // inter server - packet int r = inter->parse_frommap(fd); - if (r == 1) break; // processed - if (r == 2) return 0; // need more packet + if (r == 1) break; // processed + if (r == 2) return 0; // need more packet // no inter server packet. no char server packet -> disconnect ShowError("Unknown packet 0x%04x from map server, disconnecting.\n", RFIFOW(fd,0)); @@ -4111,7 +4105,6 @@ void char_delete2_accept_actual_ack(int fd, int char_id, uint32 result) /// Any (0x718): An unknown error has occurred. void char_delete2_accept_ack(int fd, int char_id, uint32 result) {// HC: <082a>.W <char id>.L <Msg:0-5>.L - #if PACKETVER >= 20130000 /* not sure the exact date -- must refresh or client gets stuck */ if( result == 1 ) { struct char_session_data* sd = (struct char_session_data*)session[fd]->session_data; @@ -4272,7 +4265,7 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) // refresh character list cache sd->found_char[i] = -1; - + chr->delete2_accept_ack(fd, char_id, 1); } @@ -4455,10 +4448,11 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl) return; } - if ( SQL_SUCCESS != SQL->Query(inter->sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d'", char_db, sd->account_id, slot) - || SQL_SUCCESS != SQL->NextRow(inter->sql_handle) - || SQL_SUCCESS != SQL->GetData(inter->sql_handle, 0, &data, NULL) ) - { //Not found?? May be forged packet. + if (SQL_SUCCESS != SQL->Query(inter->sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d'", char_db, sd->account_id, slot) + || SQL_SUCCESS != SQL->NextRow(inter->sql_handle) + || SQL_SUCCESS != SQL->GetData(inter->sql_handle, 0, &data, NULL) + ) { + //Not found?? May be forged packet. Sql_ShowDebug(inter->sql_handle); SQL->FreeResult(inter->sql_handle); chr->auth_error(fd, 0); @@ -4652,11 +4646,11 @@ void char_parse_char_delete_char(int fd, struct char_session_data* sd, unsigned RFIFOSKIP(fd,( cmd == 0x68) ? 46 : 56); // Check if e-mail is correct - if(strcmpi(email, sd->email) && //email does not matches and - ( - strcmp("a@a.com", sd->email) || //it is not default email, or - (strcmp("a@a.com", email) && strcmp("", email)) //email sent does not matches default - )) { //Fail + if (strcmpi(email, sd->email) != 0 /* emails don't match */ + && ( strcmp("a@a.com", sd->email) != 0 /* it's not the default email */ + || (strcmp("a@a.com", email) != 0 && strcmp("", email) != 0) /* sent email isn't the default */ + )) { + //Fail chr->delete_char_failed(fd, 0); return; } @@ -4933,8 +4927,8 @@ int char_parse_char(int fd) if(session[fd]->flag.eof) { - if( sd != NULL && sd->auth ) - { // already authed client + if( sd != NULL && sd->auth ) { + // already authed client struct online_char_data* data = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id); if( data != NULL && data->fd == fd) data->fd = -1; @@ -4954,11 +4948,10 @@ int char_parse_char(int fd) if( success == 1 ) continue; else if( success == 2 ) return 0; } - + cmd = RFIFOW(fd,0); switch( cmd ) { - // request to connect // 0065 <account id>.L <login id1>.L <login id2>.L <???>.W <sex>.B case 0x65: @@ -5082,36 +5075,36 @@ int char_parse_char(int fd) chr->parse_char_login_map_server(fd); } return 0; // avoid processing of follow-up packets here - + // checks the entered pin case 0x8b8: FIFOSD_CHECK(10); chr->parse_char_pincode_check(fd, sd); break; - + // request for PIN window case 0x8c5: FIFOSD_CHECK(6); chr->parse_char_pincode_window(fd, sd); break; - + // pincode change request case 0x8be: FIFOSD_CHECK(14); chr->parse_char_pincode_change(fd, sd); break; - + // activate PIN system and set first PIN case 0x8ba: FIFOSD_CHECK(10); chr->parse_char_pincode_first_pin(fd, sd); break; - + case 0x9a1: FIFOSD_CHECK(2); chr->parse_char_request_chars(fd, sd); break; - + /* 0x8d4 <from>.W <to>.W <unused>.W (2+2+2+2) */ case 0x8d4: FIFOSD_CHECK(8); @@ -5119,7 +5112,7 @@ int char_parse_char(int fd) chr->parse_char_move_character(fd, sd); } break; - + // unknown packet received default: if (chr->parse_char_unknown_packet(fd, ipl)) @@ -5257,7 +5250,7 @@ int char_check_connect_login_server(int tid, int64 tick, int id, intptr_t data) chr->login_fd = 0; return 0; } - + session[chr->login_fd]->func_parse = chr->parse_fromlogin; session[chr->login_fd]->flag.server = 1; realloc_fifo(chr->login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); @@ -5273,8 +5266,8 @@ int char_check_connect_login_server(int tid, int64 tick, int id, intptr_t data) //------------------------------------------------ static int char_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) { struct online_char_data* character; - if ((character = (struct online_char_data*)idb_get(chr->online_char_db, id)) != NULL && character->waiting_disconnect == tid) - { //Mark it offline due to timeout. + if ((character = (struct online_char_data*)idb_get(chr->online_char_db, id)) != NULL && character->waiting_disconnect == tid) { + //Mark it offline due to timeout. character->waiting_disconnect = INVALID_TIMER; chr->set_char_offline(character->char_id, character->account_id); } @@ -5590,8 +5583,8 @@ int char_config_read(const char* cfgName) start_zeny = atoi(w2); if (start_zeny < 0) start_zeny = 0; - } else if(strcmpi(w1,"log_char")==0) { //log char or not [devil] - log_char = atoi(w2); + } else if(strcmpi(w1,"log_char")==0) { + log_char = atoi(w2); //log char or not [devil] } else if (strcmpi(w1, "unknown_char_name") == 0) { safestrncpy(unknown_char_name, w2, sizeof(unknown_char_name)); unknown_char_name[NAME_LENGTH-1] = '\0'; @@ -5644,11 +5637,11 @@ int char_config_read(const char* cfgName) int do_final(void) { int i; - + ShowStatus("Terminating...\n"); HPM->event(HPET_FINAL); - + chr->set_all_offline(-1); chr->set_all_offline_sql(); @@ -5679,7 +5672,7 @@ int do_final(void) { for(i = 0; i < MAX_MAP_SERVERS; i++ ) if( chr->server[i].map ) aFree(chr->server[i].map); - + HPM->event(HPET_POST_FINAL); ShowStatus("Finished.\n"); @@ -5766,11 +5759,11 @@ int do_init(int argc, char **argv) { #endif HPM->config_read(NULL, 0); HPM->event(HPET_PRE_INIT); - + //Read map indexes mapindex->init(); start_point.map = mapindex->name2id("new_zone01"); - + chr->config_read((argc < 2) ? CHAR_CONF_NAME : argv[1]); chr->lan_config_read((argc > 3) ? argv[3] : LAN_CONF_NAME); chr->sql_config_read(SQL_CONF_NAME); @@ -5780,14 +5773,14 @@ int do_init(int argc, char **argv) { ShowNotice("Please edit your 'login' table to create a proper inter-server user/password (gender 'S')\n"); ShowNotice("And then change the user/password to use in conf/char-server.conf (or conf/import/char_conf.txt)\n"); } - + inter->init_sql((argc > 2) ? argv[2] : inter_cfgName); // inter server configuration auth_db = idb_alloc(DB_OPT_RELEASE_DATA); chr->online_char_db = idb_alloc(DB_OPT_RELEASE_DATA); HPM->event(HPET_INIT); - + chr->mmo_char_sql_init(); chr->read_fame_list(); //Read fame lists. @@ -5837,18 +5830,18 @@ int do_init(int argc, char **argv) { Sql_ShowDebug(inter->sql_handle); set_defaultparse(chr->parse_char); - + if( (chr->char_fd = make_listen_bind(bind_ip,chr->port)) == -1 ) { ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",chr->port); exit(EXIT_FAILURE); } - + Sql_HerculesUpdateCheck(inter->sql_handle); #ifdef CONSOLE_INPUT console->input->setSQL(inter->sql_handle); #endif ShowStatus("The char-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %d).\n\n", chr->port); - + if( runflag != CORE_ST_STOP ) { shutdown_callback = do_shutdown; @@ -5856,7 +5849,7 @@ int do_init(int argc, char **argv) { } HPM->event(HPET_READY); - + return 0; } @@ -5883,179 +5876,179 @@ void char_load_defaults(void) void char_defaults(void) { - chr = &char_s; - - memset(chr->server, 0, sizeof(chr->server)); - - chr->login_fd = 0; - chr->char_fd = -1; - chr->online_char_db = NULL; - chr->char_db_ = NULL; - - memset(chr->userid, 0, sizeof(chr->userid)); - memset(chr->passwd, 0, sizeof(chr->passwd)); - - chr->ip = 0; - chr->port = 6121; - chr->server_type = 0; - chr->new_display = 0; - - chr->waiting_disconnect = char_waiting_disconnect; - chr->delete_char_sql = char_delete_char_sql; - chr->create_online_char_data = char_create_online_char_data; - chr->set_account_online = char_set_account_online; - chr->set_account_offline = char_set_account_offline; - chr->set_char_charselect = char_set_char_charselect; - chr->set_char_online = char_set_char_online; - chr->set_char_offline = char_set_char_offline; - chr->db_setoffline = char_db_setoffline; - chr->db_kickoffline = char_db_kickoffline; - chr->set_login_all_offline = char_set_login_all_offline; - chr->set_all_offline = char_set_all_offline; - chr->set_all_offline_sql = char_set_all_offline_sql; - chr->create_charstatus = char_create_charstatus; - chr->mmo_char_tosql = char_mmo_char_tosql; - chr->memitemdata_to_sql = char_memitemdata_to_sql; - chr->inventory_to_sql = char_inventory_to_sql; - chr->mmo_chars_fromsql = char_mmo_chars_fromsql; - chr->mmo_char_fromsql = char_mmo_char_fromsql; - chr->mmo_char_sql_init = char_mmo_char_sql_init; - chr->char_slotchange = char_char_slotchange; - chr->rename_char_sql = char_rename_char_sql; - chr->check_char_name = char_check_char_name; - chr->make_new_char_sql = char_make_new_char_sql; - chr->divorce_char_sql = char_divorce_char_sql; - chr->count_users = char_count_users; - chr->mmo_char_tobuf = char_mmo_char_tobuf; - chr->mmo_char_send099d = char_mmo_char_send099d; - chr->mmo_char_send_ban_list = char_mmo_char_send_ban_list; - chr->mmo_char_send_slots_info = char_mmo_char_send_slots_info; - chr->mmo_char_send_characters = char_mmo_char_send_characters; - chr->char_married = char_char_married; - chr->char_child = char_char_child; - chr->char_family = char_char_family; - chr->disconnect_player = char_disconnect_player; - chr->authfail_fd = char_authfail_fd; - chr->request_account_data = char_request_account_data; - chr->auth_ok = char_auth_ok; - chr->ping_login_server = char_ping_login_server; - chr->parse_fromlogin_connection_state = char_parse_fromlogin_connection_state; - chr->auth_error = char_auth_error; - chr->parse_fromlogin_auth_state = char_parse_fromlogin_auth_state; - chr->parse_fromlogin_account_data = char_parse_fromlogin_account_data; - chr->parse_fromlogin_login_pong = char_parse_fromlogin_login_pong; - chr->changesex = char_changesex; - chr->parse_fromlogin_changesex_reply = char_parse_fromlogin_changesex_reply; - chr->parse_fromlogin_account_reg2 = char_parse_fromlogin_account_reg2; - chr->parse_fromlogin_ban = char_parse_fromlogin_ban; - chr->parse_fromlogin_kick = char_parse_fromlogin_kick; - chr->update_ip = char_update_ip; - chr->parse_fromlogin_update_ip = char_parse_fromlogin_update_ip; - chr->parse_fromlogin_accinfo2_failed = char_parse_fromlogin_accinfo2_failed; - chr->parse_fromlogin_accinfo2_ok = char_parse_fromlogin_accinfo2_ok; - chr->parse_fromlogin = char_parse_fromlogin; - chr->request_accreg2 = char_request_accreg2; - chr->global_accreg_to_login_start = char_global_accreg_to_login_start; - chr->global_accreg_to_login_send = char_global_accreg_to_login_send; - chr->global_accreg_to_login_add = char_global_accreg_to_login_add; - chr->read_fame_list = char_read_fame_list; - chr->send_fame_list = char_send_fame_list; - chr->update_fame_list = char_update_fame_list; - chr->loadName = char_loadName; - chr->parse_frommap_datasync = char_parse_frommap_datasync; - chr->parse_frommap_skillid2idx = char_parse_frommap_skillid2idx; - chr->map_received_ok = char_map_received_ok; - chr->send_maps = char_send_maps; - chr->parse_frommap_map_names = char_parse_frommap_map_names; - chr->send_scdata = char_send_scdata; - chr->parse_frommap_request_scdata = char_parse_frommap_request_scdata; - chr->parse_frommap_set_users_count = char_parse_frommap_set_users_count; - chr->parse_frommap_set_users = char_parse_frommap_set_users; - chr->save_character_ack = char_save_character_ack; - chr->parse_frommap_save_character = char_parse_frommap_save_character; - chr->select_ack = char_select_ack; - chr->parse_frommap_char_select_req = char_parse_frommap_char_select_req; - chr->change_map_server_ack = char_change_map_server_ack; - chr->parse_frommap_change_map_server = char_parse_frommap_change_map_server; - chr->parse_frommap_remove_friend = char_parse_frommap_remove_friend; - chr->char_name_ack = char_char_name_ack; - chr->parse_frommap_char_name_request = char_parse_frommap_char_name_request; - chr->parse_frommap_change_email = char_parse_frommap_change_email; - chr->ban = char_ban; - chr->unban = char_unban; - chr->ask_name_ack = char_ask_name_ack; - chr->parse_frommap_change_account = char_parse_frommap_change_account; - chr->parse_frommap_fame_list = char_parse_frommap_fame_list; - chr->parse_frommap_divorce_char = char_parse_frommap_divorce_char; - chr->parse_frommap_ragsrvinfo = char_parse_frommap_ragsrvinfo; - chr->parse_frommap_set_char_offline = char_parse_frommap_set_char_offline; - chr->parse_frommap_set_all_offline = char_parse_frommap_set_all_offline; - chr->parse_frommap_set_char_online = char_parse_frommap_set_char_online; - chr->parse_frommap_build_fame_list = char_parse_frommap_build_fame_list; - chr->parse_frommap_save_status_change_data = char_parse_frommap_save_status_change_data; - chr->send_pong = char_send_pong; - chr->parse_frommap_ping = char_parse_frommap_ping; - chr->map_auth_ok = char_map_auth_ok; - chr->map_auth_failed = char_map_auth_failed; - chr->parse_frommap_auth_request = char_parse_frommap_auth_request; - chr->parse_frommap_update_ip = char_parse_frommap_update_ip; - chr->parse_frommap_request_stats_report = char_parse_frommap_request_stats_report; - chr->parse_frommap_scdata_update = char_parse_frommap_scdata_update; - chr->parse_frommap_scdata_delete = char_parse_frommap_scdata_delete; - chr->parse_frommap = char_parse_frommap; - chr->search_mapserver = char_search_mapserver; - chr->mapif_init = char_mapif_init; - chr->lan_subnetcheck = char_lan_subnetcheck; - chr->delete2_ack = char_delete2_ack; - chr->delete2_accept_actual_ack = char_delete2_accept_actual_ack; - chr->delete2_accept_ack = char_delete2_accept_ack; - chr->delete2_cancel_ack = char_delete2_cancel_ack; - chr->delete2_req = char_delete2_req; - chr->delete2_accept = char_delete2_accept; - chr->delete2_cancel = char_delete2_cancel; - chr->send_account_id = char_send_account_id; - chr->parse_char_connect = char_parse_char_connect; - chr->send_map_info = char_send_map_info; - chr->send_wait_char_server = char_send_wait_char_server; - chr->search_default_maps_mapserver = char_search_default_maps_mapserver; - chr->parse_char_select = char_parse_char_select; - chr->creation_failed = char_creation_failed; - chr->creation_ok = char_creation_ok; - chr->parse_char_create_new_char = char_parse_char_create_new_char; - chr->delete_char_failed = char_delete_char_failed; - chr->delete_char_ok = char_delete_char_ok; - chr->parse_char_delete_char = char_parse_char_delete_char; - chr->parse_char_ping = char_parse_char_ping; - chr->allow_rename = char_allow_rename; - chr->parse_char_rename_char = char_parse_char_rename_char; - chr->parse_char_rename_char2 = char_parse_char_rename_char2; - chr->rename_char_ack = char_rename_char_ack; - chr->parse_char_rename_char_confirm = char_parse_char_rename_char_confirm; - chr->captcha_notsupported = char_captcha_notsupported; - chr->parse_char_request_captcha = char_parse_char_request_captcha; - chr->parse_char_check_captcha = char_parse_char_check_captcha; - chr->parse_char_delete2_req = char_parse_char_delete2_req; - chr->parse_char_delete2_accept = char_parse_char_delete2_accept; - chr->parse_char_delete2_cancel = char_parse_char_delete2_cancel; - chr->login_map_server_ack = char_login_map_server_ack; - chr->parse_char_login_map_server = char_parse_char_login_map_server; - chr->parse_char_pincode_check = char_parse_char_pincode_check; - chr->parse_char_pincode_window = char_parse_char_pincode_window; - chr->parse_char_pincode_change = char_parse_char_pincode_change; - chr->parse_char_pincode_first_pin = char_parse_char_pincode_first_pin; - chr->parse_char_request_chars = char_parse_char_request_chars; - chr->change_character_slot_ack = char_change_character_slot_ack; - chr->parse_char_move_character = char_parse_char_move_character; - chr->parse_char_unknown_packet = char_parse_char_unknown_packet; - chr->parse_char = char_parse_char; - chr->broadcast_user_count = char_broadcast_user_count; - chr->send_accounts_tologin_sub = char_send_accounts_tologin_sub; - chr->send_accounts_tologin = char_send_accounts_tologin; - chr->check_connect_login_server = char_check_connect_login_server; - chr->online_data_cleanup_sub = char_online_data_cleanup_sub; - chr->online_data_cleanup = char_online_data_cleanup; - chr->lan_config_read = char_lan_config_read; - chr->sql_config_read = char_sql_config_read; - chr->config_dispatch = char_config_dispatch; - chr->config_read = char_config_read; + chr = &char_s; + + memset(chr->server, 0, sizeof(chr->server)); + + chr->login_fd = 0; + chr->char_fd = -1; + chr->online_char_db = NULL; + chr->char_db_ = NULL; + + memset(chr->userid, 0, sizeof(chr->userid)); + memset(chr->passwd, 0, sizeof(chr->passwd)); + + chr->ip = 0; + chr->port = 6121; + chr->server_type = 0; + chr->new_display = 0; + + chr->waiting_disconnect = char_waiting_disconnect; + chr->delete_char_sql = char_delete_char_sql; + chr->create_online_char_data = char_create_online_char_data; + chr->set_account_online = char_set_account_online; + chr->set_account_offline = char_set_account_offline; + chr->set_char_charselect = char_set_char_charselect; + chr->set_char_online = char_set_char_online; + chr->set_char_offline = char_set_char_offline; + chr->db_setoffline = char_db_setoffline; + chr->db_kickoffline = char_db_kickoffline; + chr->set_login_all_offline = char_set_login_all_offline; + chr->set_all_offline = char_set_all_offline; + chr->set_all_offline_sql = char_set_all_offline_sql; + chr->create_charstatus = char_create_charstatus; + chr->mmo_char_tosql = char_mmo_char_tosql; + chr->memitemdata_to_sql = char_memitemdata_to_sql; + chr->inventory_to_sql = char_inventory_to_sql; + chr->mmo_chars_fromsql = char_mmo_chars_fromsql; + chr->mmo_char_fromsql = char_mmo_char_fromsql; + chr->mmo_char_sql_init = char_mmo_char_sql_init; + chr->char_slotchange = char_char_slotchange; + chr->rename_char_sql = char_rename_char_sql; + chr->check_char_name = char_check_char_name; + chr->make_new_char_sql = char_make_new_char_sql; + chr->divorce_char_sql = char_divorce_char_sql; + chr->count_users = char_count_users; + chr->mmo_char_tobuf = char_mmo_char_tobuf; + chr->mmo_char_send099d = char_mmo_char_send099d; + chr->mmo_char_send_ban_list = char_mmo_char_send_ban_list; + chr->mmo_char_send_slots_info = char_mmo_char_send_slots_info; + chr->mmo_char_send_characters = char_mmo_char_send_characters; + chr->char_married = char_char_married; + chr->char_child = char_char_child; + chr->char_family = char_char_family; + chr->disconnect_player = char_disconnect_player; + chr->authfail_fd = char_authfail_fd; + chr->request_account_data = char_request_account_data; + chr->auth_ok = char_auth_ok; + chr->ping_login_server = char_ping_login_server; + chr->parse_fromlogin_connection_state = char_parse_fromlogin_connection_state; + chr->auth_error = char_auth_error; + chr->parse_fromlogin_auth_state = char_parse_fromlogin_auth_state; + chr->parse_fromlogin_account_data = char_parse_fromlogin_account_data; + chr->parse_fromlogin_login_pong = char_parse_fromlogin_login_pong; + chr->changesex = char_changesex; + chr->parse_fromlogin_changesex_reply = char_parse_fromlogin_changesex_reply; + chr->parse_fromlogin_account_reg2 = char_parse_fromlogin_account_reg2; + chr->parse_fromlogin_ban = char_parse_fromlogin_ban; + chr->parse_fromlogin_kick = char_parse_fromlogin_kick; + chr->update_ip = char_update_ip; + chr->parse_fromlogin_update_ip = char_parse_fromlogin_update_ip; + chr->parse_fromlogin_accinfo2_failed = char_parse_fromlogin_accinfo2_failed; + chr->parse_fromlogin_accinfo2_ok = char_parse_fromlogin_accinfo2_ok; + chr->parse_fromlogin = char_parse_fromlogin; + chr->request_accreg2 = char_request_accreg2; + chr->global_accreg_to_login_start = char_global_accreg_to_login_start; + chr->global_accreg_to_login_send = char_global_accreg_to_login_send; + chr->global_accreg_to_login_add = char_global_accreg_to_login_add; + chr->read_fame_list = char_read_fame_list; + chr->send_fame_list = char_send_fame_list; + chr->update_fame_list = char_update_fame_list; + chr->loadName = char_loadName; + chr->parse_frommap_datasync = char_parse_frommap_datasync; + chr->parse_frommap_skillid2idx = char_parse_frommap_skillid2idx; + chr->map_received_ok = char_map_received_ok; + chr->send_maps = char_send_maps; + chr->parse_frommap_map_names = char_parse_frommap_map_names; + chr->send_scdata = char_send_scdata; + chr->parse_frommap_request_scdata = char_parse_frommap_request_scdata; + chr->parse_frommap_set_users_count = char_parse_frommap_set_users_count; + chr->parse_frommap_set_users = char_parse_frommap_set_users; + chr->save_character_ack = char_save_character_ack; + chr->parse_frommap_save_character = char_parse_frommap_save_character; + chr->select_ack = char_select_ack; + chr->parse_frommap_char_select_req = char_parse_frommap_char_select_req; + chr->change_map_server_ack = char_change_map_server_ack; + chr->parse_frommap_change_map_server = char_parse_frommap_change_map_server; + chr->parse_frommap_remove_friend = char_parse_frommap_remove_friend; + chr->char_name_ack = char_char_name_ack; + chr->parse_frommap_char_name_request = char_parse_frommap_char_name_request; + chr->parse_frommap_change_email = char_parse_frommap_change_email; + chr->ban = char_ban; + chr->unban = char_unban; + chr->ask_name_ack = char_ask_name_ack; + chr->parse_frommap_change_account = char_parse_frommap_change_account; + chr->parse_frommap_fame_list = char_parse_frommap_fame_list; + chr->parse_frommap_divorce_char = char_parse_frommap_divorce_char; + chr->parse_frommap_ragsrvinfo = char_parse_frommap_ragsrvinfo; + chr->parse_frommap_set_char_offline = char_parse_frommap_set_char_offline; + chr->parse_frommap_set_all_offline = char_parse_frommap_set_all_offline; + chr->parse_frommap_set_char_online = char_parse_frommap_set_char_online; + chr->parse_frommap_build_fame_list = char_parse_frommap_build_fame_list; + chr->parse_frommap_save_status_change_data = char_parse_frommap_save_status_change_data; + chr->send_pong = char_send_pong; + chr->parse_frommap_ping = char_parse_frommap_ping; + chr->map_auth_ok = char_map_auth_ok; + chr->map_auth_failed = char_map_auth_failed; + chr->parse_frommap_auth_request = char_parse_frommap_auth_request; + chr->parse_frommap_update_ip = char_parse_frommap_update_ip; + chr->parse_frommap_request_stats_report = char_parse_frommap_request_stats_report; + chr->parse_frommap_scdata_update = char_parse_frommap_scdata_update; + chr->parse_frommap_scdata_delete = char_parse_frommap_scdata_delete; + chr->parse_frommap = char_parse_frommap; + chr->search_mapserver = char_search_mapserver; + chr->mapif_init = char_mapif_init; + chr->lan_subnetcheck = char_lan_subnetcheck; + chr->delete2_ack = char_delete2_ack; + chr->delete2_accept_actual_ack = char_delete2_accept_actual_ack; + chr->delete2_accept_ack = char_delete2_accept_ack; + chr->delete2_cancel_ack = char_delete2_cancel_ack; + chr->delete2_req = char_delete2_req; + chr->delete2_accept = char_delete2_accept; + chr->delete2_cancel = char_delete2_cancel; + chr->send_account_id = char_send_account_id; + chr->parse_char_connect = char_parse_char_connect; + chr->send_map_info = char_send_map_info; + chr->send_wait_char_server = char_send_wait_char_server; + chr->search_default_maps_mapserver = char_search_default_maps_mapserver; + chr->parse_char_select = char_parse_char_select; + chr->creation_failed = char_creation_failed; + chr->creation_ok = char_creation_ok; + chr->parse_char_create_new_char = char_parse_char_create_new_char; + chr->delete_char_failed = char_delete_char_failed; + chr->delete_char_ok = char_delete_char_ok; + chr->parse_char_delete_char = char_parse_char_delete_char; + chr->parse_char_ping = char_parse_char_ping; + chr->allow_rename = char_allow_rename; + chr->parse_char_rename_char = char_parse_char_rename_char; + chr->parse_char_rename_char2 = char_parse_char_rename_char2; + chr->rename_char_ack = char_rename_char_ack; + chr->parse_char_rename_char_confirm = char_parse_char_rename_char_confirm; + chr->captcha_notsupported = char_captcha_notsupported; + chr->parse_char_request_captcha = char_parse_char_request_captcha; + chr->parse_char_check_captcha = char_parse_char_check_captcha; + chr->parse_char_delete2_req = char_parse_char_delete2_req; + chr->parse_char_delete2_accept = char_parse_char_delete2_accept; + chr->parse_char_delete2_cancel = char_parse_char_delete2_cancel; + chr->login_map_server_ack = char_login_map_server_ack; + chr->parse_char_login_map_server = char_parse_char_login_map_server; + chr->parse_char_pincode_check = char_parse_char_pincode_check; + chr->parse_char_pincode_window = char_parse_char_pincode_window; + chr->parse_char_pincode_change = char_parse_char_pincode_change; + chr->parse_char_pincode_first_pin = char_parse_char_pincode_first_pin; + chr->parse_char_request_chars = char_parse_char_request_chars; + chr->change_character_slot_ack = char_change_character_slot_ack; + chr->parse_char_move_character = char_parse_char_move_character; + chr->parse_char_unknown_packet = char_parse_char_unknown_packet; + chr->parse_char = char_parse_char; + chr->broadcast_user_count = char_broadcast_user_count; + chr->send_accounts_tologin_sub = char_send_accounts_tologin_sub; + chr->send_accounts_tologin = char_send_accounts_tologin; + chr->check_connect_login_server = char_check_connect_login_server; + chr->online_data_cleanup_sub = char_online_data_cleanup_sub; + chr->online_data_cleanup = char_online_data_cleanup; + chr->lan_config_read = char_lan_config_read; + chr->sql_config_read = char_sql_config_read; + chr->config_dispatch = char_config_dispatch; + chr->config_read = char_config_read; } diff --git a/src/char/geoip.c b/src/char/geoip.c index 34b731af8..4fe03ab07 100644 --- a/src/char/geoip.c +++ b/src/char/geoip.c @@ -160,7 +160,7 @@ void geoip_init(void) fseek(db, -4l, SEEK_CUR); } } - + fclose(db); if (db_type != 1) { diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 684faa46b..e28240ca6 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -129,7 +129,7 @@ unsigned int inter_auction_create(struct auction_data *auction) void mapif_auction_message(int char_id, unsigned char result) { unsigned char buf[74]; - + WBUFW(buf,0) = 0x3854; WBUFL(buf,2) = char_id; WBUFL(buf,6) = result; @@ -148,7 +148,7 @@ static int inter_auction_end_timer(int tid, int64 tick, int id, intptr_t data) { } else inter_mail->sendmail(0, "Auction Manager", auction->seller_id, auction->seller_name, "Auction", "No buyers have been found for your auction.", 0, &auction->item); - + ShowInfo("Auction End: id %u.\n", auction->auction_id); auction->auction_end_timer = INVALID_TIMER; @@ -201,7 +201,7 @@ void inter_auctions_fromsql(void) SQL->GetData(inter->sql_handle, 2, &data, NULL); safestrncpy(auction->seller_name, data, NAME_LENGTH); SQL->GetData(inter->sql_handle, 3, &data, NULL); auction->buyer_id = atoi(data); SQL->GetData(inter->sql_handle, 4, &data, NULL); safestrncpy(auction->buyer_name, data, NAME_LENGTH); - SQL->GetData(inter->sql_handle, 5, &data, NULL); auction->price = atoi(data); + SQL->GetData(inter->sql_handle, 5, &data, NULL); auction->price = atoi(data); SQL->GetData(inter->sql_handle, 6, &data, NULL); auction->buynow = atoi(data); SQL->GetData(inter->sql_handle, 7, &data, NULL); auction->hours = atoi(data); SQL->GetData(inter->sql_handle, 8, &data, NULL); auction->timestamp = atoi(data); @@ -493,17 +493,17 @@ void inter_auction_sql_final(void) void inter_auction_defaults(void) { - inter_auction = &inter_auction_s; - - inter_auction->db = NULL; // int auction_id -> struct auction_data* - - inter_auction->count = inter_auction_count; - inter_auction->save = inter_auction_save; - inter_auction->create = inter_auction_create; - inter_auction->end_timer = inter_auction_end_timer; - inter_auction->delete_ = inter_auction_delete; - inter_auction->fromsql = inter_auctions_fromsql; - inter_auction->parse_frommap = inter_auction_parse_frommap; - inter_auction->sql_init = inter_auction_sql_init; - inter_auction->sql_final = inter_auction_sql_final; + inter_auction = &inter_auction_s; + + inter_auction->db = NULL; // int auction_id -> struct auction_data* + + inter_auction->count = inter_auction_count; + inter_auction->save = inter_auction_save; + inter_auction->create = inter_auction_create; + inter_auction->end_timer = inter_auction_end_timer; + inter_auction->delete_ = inter_auction_delete; + inter_auction->fromsql = inter_auctions_fromsql; + inter_auction->parse_frommap = inter_auction_parse_frommap; + inter_auction->sql_init = inter_auction_sql_init; + inter_auction->sql_final = inter_auction_sql_final; } diff --git a/src/char/int_auction.h b/src/char/int_auction.h index 03efcdc51..ad8ac7b67 100644 --- a/src/char/int_auction.h +++ b/src/char/int_auction.h @@ -12,16 +12,16 @@ void inter_auction_defaults(void); * inter_auction_interface interface **/ struct inter_auction_interface { - DBMap* db; // int auction_id -> struct auction_data* - int (*count) (int char_id, bool buy); - void (*save) (struct auction_data *auction); - unsigned int (*create) (struct auction_data *auction); - int (*end_timer) (int tid, int64 tick, int id, intptr_t data); - void (*delete_) (struct auction_data *auction); - void (*fromsql) (void); - int (*parse_frommap) (int fd); - int (*sql_init) (void); - void (*sql_final) (void); + DBMap* db; // int auction_id -> struct auction_data* + int (*count) (int char_id, bool buy); + void (*save) (struct auction_data *auction); + unsigned int (*create) (struct auction_data *auction); + int (*end_timer) (int tid, int64 tick, int id, intptr_t data); + void (*delete_) (struct auction_data *auction); + void (*fromsql) (void); + int (*parse_frommap) (int fd); + int (*sql_init) (void); + void (*sql_final) (void); }; struct inter_auction_interface *inter_auction; diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index 3f8e7b190..d14d1e1e0 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -25,7 +25,7 @@ struct inter_elemental_interface inter_elemental_s; bool mapif_elemental_save(struct s_elemental* ele) { bool flag = true; - + if( ele->elemental_id == 0 ) { // Create new DB entry if( SQL_ERROR == SQL->Query(inter->sql_handle, "INSERT INTO `%s` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`atk1`,`atk2`,`matk`,`aspd`,`def`,`mdef`,`flee`,`hit`,`life_time`)" @@ -52,11 +52,11 @@ bool mapif_elemental_save(struct s_elemental* ele) { bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) { char* data; - + memset(ele, 0, sizeof(struct s_elemental)); ele->elemental_id = ele_id; ele->char_id = char_id; - + if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `atk1`, `atk2`, `matk`, `aspd`," "`def`, `mdef`, `flee`, `hit`, `life_time` FROM `%s` WHERE `ele_id` = '%d' AND `char_id` = '%d'", @@ -65,12 +65,12 @@ bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) { Sql_ShowDebug(inter->sql_handle); return false; } - + if( SQL_SUCCESS != SQL->NextRow(inter->sql_handle) ) { SQL->FreeResult(inter->sql_handle); return false; } - + SQL->GetData(inter->sql_handle, 0, &data, NULL); ele->class_ = atoi(data); SQL->GetData(inter->sql_handle, 1, &data, NULL); ele->mode = atoi(data); SQL->GetData(inter->sql_handle, 2, &data, NULL); ele->hp = atoi(data); @@ -89,7 +89,7 @@ bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) { SQL->FreeResult(inter->sql_handle); if( save_log ) ShowInfo("Elemental loaded (%d - %d).\n", ele->elemental_id, ele->char_id); - + return true; } @@ -98,13 +98,13 @@ bool mapif_elemental_delete(int ele_id) { Sql_ShowDebug(inter->sql_handle); return false; } - + return true; } void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) { int size = sizeof(struct s_elemental) + 5; - + WFIFOHEAD(fd,size); WFIFOW(fd,0) = 0x387c; WFIFOW(fd,2) = size; @@ -161,7 +161,7 @@ void inter_elemental_sql_final(void) { *------------------------------------------*/ int inter_elemental_parse_frommap(int fd) { unsigned short cmd = RFIFOW(fd,0); - + switch( cmd ) { case 0x307c: mapif->parse_elemental_create(fd, (struct s_elemental*)RFIFOP(fd,4)); break; case 0x307d: mapif->parse_elemental_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break; @@ -175,9 +175,9 @@ int inter_elemental_parse_frommap(int fd) { void inter_elemental_defaults(void) { - inter_elemental = &inter_elemental_s; + inter_elemental = &inter_elemental_s; - inter_elemental->sql_init = inter_elemental_sql_init; - inter_elemental->sql_final = inter_elemental_sql_final; - inter_elemental->parse_frommap = inter_elemental_parse_frommap; + inter_elemental->sql_init = inter_elemental_sql_init; + inter_elemental->sql_final = inter_elemental_sql_final; + inter_elemental->parse_frommap = inter_elemental_parse_frommap; } diff --git a/src/char/int_elemental.h b/src/char/int_elemental.h index 995dfbfab..611d97550 100644 --- a/src/char/int_elemental.h +++ b/src/char/int_elemental.h @@ -12,9 +12,9 @@ void inter_elemental_defaults(void); * inter_elemental_interface interface **/ struct inter_elemental_interface { - void (*sql_init) (void); - void (*sql_final) (void); - int (*parse_frommap) (int fd); + void (*sql_init) (void); + void (*sql_final) (void); + int (*parse_frommap) (int fd); }; struct inter_elemental_interface *inter_elemental; diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 9817f912d..a5623f83d 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -208,8 +208,10 @@ int inter_guild_tosql(struct guild *g,int flag) strcat(t_info, " level"); if( add_comma ) StrBuf->AppendStr(&buf, ", "); - //else //last condition using add_coma setting - // add_comma = true; +#if 0 + else //last condition using add_coma setting + add_comma = true; +#endif // 0 StrBuf->Printf(&buf, "`guild_lv`=%d, `skill_point`=%d, `exp`=%"PRIu64", `next_exp`=%u, `max_member`=%d", g->guild_lv, g->skill_point, g->exp, g->next_exp, g->max_member); } StrBuf->Printf(&buf, " WHERE `guild_id`=%d", g->guild_id); @@ -364,8 +366,8 @@ struct guild * inter_guild_fromsql(int guild_id) SQL->GetData(inter->sql_handle, 2, &data, NULL); g->guild_lv = atoi(data); SQL->GetData(inter->sql_handle, 3, &data, NULL); g->connect_member = atoi(data); SQL->GetData(inter->sql_handle, 4, &data, NULL); g->max_member = atoi(data); - if( g->max_member > MAX_GUILD ) - { // Fix reduction of MAX_GUILD [PoW] + if (g->max_member > MAX_GUILD) { + // Fix reduction of MAX_GUILD [PoW] ShowWarning("Guild %d:%s specifies higher capacity (%d) than MAX_GUILD (%d)\n", guild_id, g->name, g->max_member, MAX_GUILD); g->max_member = MAX_GUILD; } @@ -491,8 +493,8 @@ struct guild * inter_guild_fromsql(int guild_id) return NULL; } - for(i = 0; i < MAX_GUILDSKILL; i++) - { //Skill IDs must always be initialized. [Skotlex] + for (i = 0; i < MAX_GUILDSKILL; i++) { + //Skill IDs must always be initialized. [Skotlex] g->skill[i].id = i + GD_SKILLBASE; } @@ -858,8 +860,7 @@ int inter_guild_calcinfo(struct guild *g) g->average_lv /= c; // Check if guild stats has change - if(g->max_member != before.max_member || g->guild_lv != before.guild_lv || g->skill_point != before.skill_point ) - { + if (g->max_member != before.max_member || g->guild_lv != before.guild_lv || g->skill_point != before.skill_point) { g->save_flag |= GS_LEVEL; mapif->guild_info(-1,g); return 1; @@ -1271,8 +1272,8 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in return 0; } - if( flag ) - { // Write expulsion reason + if (flag) { + // Write expulsion reason // Find an empty slot int j; ARR_FIND( 0, MAX_GUILDEXPULSION, j, g->expulsion[j].account_id == 0 ); @@ -1484,10 +1485,10 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int return 0; // Search the member - for(i=0;i<g->max_member;i++) - if( g->member[i].account_id==account_id && - g->member[i].char_id==char_id ) - break; + for (i = 0; i < g->max_member; i++) { + if (g->member[i].account_id == account_id && g->member[i].char_id==char_id) + break; + } // Not Found if(i==g->max_member){ @@ -1507,7 +1508,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int break; } case GMI_EXP: - { // EXP + { uint64 exp, old_exp=g->member[i].exp; g->member[i].exp=*((uint64 *)data); g->member[i].modified = GS_MEMBER_MODIFIED; @@ -1688,7 +1689,7 @@ int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_ g[1] = inter_guild->fromsql(guild_id2); if(g[0] && g[1]==NULL && (flag & GUILD_ALLIANCE_REMOVE)) //Requested to remove an alliance with a not found guild. - return mapif->parse_GuildDeleteAlliance(g[0], guild_id2, account_id1, account_id2, flag); //Try to do a manual removal of said guild. + return mapif->parse_GuildDeleteAlliance(g[0], guild_id2, account_id1, account_id2, flag); //Try to do a manual removal of said guild. if(g[0]==NULL || g[1]==NULL) return 0; @@ -1734,7 +1735,7 @@ int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char * memcpy(g->mes1,mes1,MAX_GUILDMES1); memcpy(g->mes2,mes2,MAX_GUILDMES2); - g->save_flag |= GS_MES; //Change mes of guild + g->save_flag |= GS_MES; //Change mes of guild return mapif->guild_notice(g); } @@ -1752,7 +1753,7 @@ int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char memcpy(g->emblem_data,data,len); g->emblem_len=len; g->emblem_id++; - g->save_flag |= GS_EMBLEM; //Change guild + g->save_flag |= GS_EMBLEM; //Change guild return mapif->guild_emblem(g); } @@ -1842,8 +1843,8 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le // Data packet length that you set to inter.c //- Shouldn't do checking and packet length, RFIFOSKIP is done by the caller // Must Return -// 1 : ok -// 0 : error +// 1 : ok +// 0 : error int inter_guild_parse_frommap(int fd) { RFIFOHEAD(fd); diff --git a/src/char/int_guild.h b/src/char/int_guild.h index c72856709..960150f4f 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -28,32 +28,32 @@ void inter_guild_defaults(void); * inter_guild interface **/ struct inter_guild_interface { - DBMap* guild_db; // int guild_id -> struct guild* - DBMap* castle_db; - unsigned int exp[MAX_GUILDLEVEL]; - - int (*save_timer) (int tid, int64 tick, int id, intptr_t data); - int (*removemember_tosql) (int account_id, int char_id); - int (*tosql) (struct guild *g, int flag); - struct guild* (*fromsql) (int guild_id); - int (*castle_tosql) (struct guild_castle *gc); - struct guild_castle* (*castle_fromsql) (int castle_id); - bool (*exp_parse_row) (char* split[], int column, int current); - int (*CharOnline) (int char_id, int guild_id); - int (*CharOffline) (int char_id, int guild_id); - int (*sql_init) (void); - int (*db_final) (DBKey key, DBData *data, va_list ap); - void (*sql_final) (void); - int (*search_guildname) (char *str); - bool (*check_empty) (struct guild *g); - unsigned int (*nextexp) (int level); - int (*checkskill) (struct guild *g, int id); - int (*calcinfo) (struct guild *g); - int (*sex_changed) (int guild_id, int account_id, int char_id, short gender); - int (*charname_changed) (int guild_id, int account_id, int char_id, char *name); - int (*parse_frommap) (int fd); - int (*leave) (int guild_id, int account_id, int char_id); - int (*broken) (int guild_id); + DBMap* guild_db; // int guild_id -> struct guild* + DBMap* castle_db; + unsigned int exp[MAX_GUILDLEVEL]; + + int (*save_timer) (int tid, int64 tick, int id, intptr_t data); + int (*removemember_tosql) (int account_id, int char_id); + int (*tosql) (struct guild *g, int flag); + struct guild* (*fromsql) (int guild_id); + int (*castle_tosql) (struct guild_castle *gc); + struct guild_castle* (*castle_fromsql) (int castle_id); + bool (*exp_parse_row) (char* split[], int column, int current); + int (*CharOnline) (int char_id, int guild_id); + int (*CharOffline) (int char_id, int guild_id); + int (*sql_init) (void); + int (*db_final) (DBKey key, DBData *data, va_list ap); + void (*sql_final) (void); + int (*search_guildname) (char *str); + bool (*check_empty) (struct guild *g); + unsigned int (*nextexp) (int level); + int (*checkskill) (struct guild *g, int id); + int (*calcinfo) (struct guild *g); + int (*sex_changed) (int guild_id, int account_id, int char_id, short gender); + int (*charname_changed) (int guild_id, int account_id, int char_id, char *name); + int (*parse_frommap) (int fd); + int (*leave) (int guild_id, int account_id, int char_id); + int (*broken) (int guild_id); }; struct inter_guild_interface *inter_guild; diff --git a/src/char/int_homun.c b/src/char/int_homun.c index d3cc1c46c..7f9323bdd 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -167,8 +167,8 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) return false; } - if( !SQL->NumRows(inter->sql_handle) ) - { //No homunculus found. + if (!SQL->NumRows(inter->sql_handle)) { + //No homunculus found. SQL->FreeResult(inter->sql_handle); return false; } @@ -236,8 +236,8 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd) bool mapif_homunculus_delete(int homun_id) { - if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", homunculus_db, homun_id) - || SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", skill_homunculus_db, homun_id) + if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", homunculus_db, homun_id) + || SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%u'", skill_homunculus_db, homun_id) ) { Sql_ShowDebug(inter->sql_handle); return false; diff --git a/src/char/int_homun.h b/src/char/int_homun.h index 69b30b781..5bfa355d4 100644 --- a/src/char/int_homun.h +++ b/src/char/int_homun.h @@ -14,9 +14,9 @@ void inter_homunculus_defaults(void); * inter_homunculus interface **/ struct inter_homunculus_interface { - int (*sql_init) (void); - void (*sql_final) (void); - int (*parse_frommap) (int fd); + int (*sql_init) (void); + void (*sql_final) (void); + int (*parse_frommap) (int fd); }; struct inter_homunculus_interface *inter_homunculus; diff --git a/src/char/int_mail.c b/src/char/int_mail.c index c400ea01f..2c0a85f33 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -336,7 +336,7 @@ void mapif_parse_mail_delete(int fd) void mapif_mail_new(struct mail_message *msg) { unsigned char buf[74]; - + if( !msg || !msg->id ) return; @@ -405,7 +405,7 @@ void mapif_parse_mail_return(int fd) void mapif_mail_send(int fd, struct mail_message* msg) { int len = sizeof(struct mail_message) + 4; - + WFIFOHEAD(fd,len); WFIFOW(fd,0) = 0x384d; WFIFOW(fd,2) = len; diff --git a/src/char/int_mail.h b/src/char/int_mail.h index b69b27079..5ce7bafa2 100644 --- a/src/char/int_mail.h +++ b/src/char/int_mail.h @@ -16,14 +16,14 @@ void inter_mail_defaults(void); * inter_mail interface **/ struct inter_mail_interface { - int (*sql_init) (void); - void (*sql_final) (void); - int (*parse_frommap) (int fd); - int (*fromsql) (int char_id, struct mail_data* md); - int (*savemessage) (struct mail_message* msg); - bool (*loadmessage) (int mail_id, struct mail_message* msg); - bool (*DeleteAttach) (int mail_id); - void (*sendmail) (int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); + int (*sql_init) (void); + void (*sql_final) (void); + int (*parse_frommap) (int fd); + int (*fromsql) (int char_id, struct mail_data* md); + int (*savemessage) (struct mail_message* msg); + bool (*loadmessage) (int mail_id, struct mail_message* msg); + bool (*DeleteAttach) (int mail_id); + void (*sendmail) (int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item); }; struct inter_mail_interface *inter_mail; diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index 0e91b6785..2bd94b97e 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -129,7 +129,7 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc) SQL->FreeResult(inter->sql_handle); if( save_log ) ShowInfo("Mercenary loaded (%d - %d).\n", merc->mercenary_id, merc->char_id); - + return true; } diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index 900065cb7..b22ea61b2 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -14,12 +14,12 @@ void inter_mercenary_defaults(void); * inter_mercenary interface **/ struct inter_mercenary_interface { - bool (*owner_fromsql) (int char_id, struct mmo_charstatus *status); - bool (*owner_tosql) (int char_id, struct mmo_charstatus *status); - bool (*owner_delete) (int char_id); - int (*sql_init) (void); - void (*sql_final) (void); - int (*parse_frommap) (int fd); + bool (*owner_fromsql) (int char_id, struct mmo_charstatus *status); + bool (*owner_tosql) (int char_id, struct mmo_charstatus *status); + bool (*owner_delete) (int char_id); + int (*sql_init) (void); + void (*sql_final) (void); + int (*parse_frommap) (int fd); }; struct inter_mercenary_interface *inter_mercenary; diff --git a/src/char/int_party.c b/src/char/int_party.c index 49873feff..b16f106be 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -156,7 +156,7 @@ int inter_party_tosql(struct party *p, int flag, int index) party_db, p->member[index].account_id, p->member[index].char_id, party_id) ) Sql_ShowDebug(inter->sql_handle); } - + if( flag & PS_ADDMEMBER ) {// Add one party member. if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'", @@ -192,7 +192,7 @@ struct party_data *inter_party_fromsql(int party_id) #endif if( party_id <= 0 ) return NULL; - + //Load from memory p = (struct party_data*)idb_get(inter_party->db, party_id); if( p != NULL ) @@ -483,7 +483,7 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part } p = (struct party_data*)aCalloc(1, sizeof(struct party_data)); - + memcpy(p->party.name,name,NAME_LENGTH); p->party.exp=0; p->party.item=(item?1:0)|(item2?2:0); @@ -624,7 +624,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) inter_party->check_lv(p); } } - + if (inter_party->check_empty(p) == 0) mapif->party_info(-1, &p->party, 0); return 0; @@ -716,13 +716,10 @@ int mapif_parse_PartyLeaderChange(int fd, int party_id, int account_id, int char if(!p) return 0; - for (i = 0; i < MAX_PARTY; i++) - { + for (i = 0; i < MAX_PARTY; i++) { if(p->party.member[i].leader) p->party.member[i].leader = 0; - if(p->party.member[i].account_id == account_id && - p->party.member[i].char_id == char_id) - { + if(p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id) { p->party.member[i].leader = 1; inter_party->tosql(&p->party,PS_LEADER, i); } @@ -736,8 +733,8 @@ int mapif_parse_PartyLeaderChange(int fd, int party_id, int account_id, int char // Data packet length is set to inter.c that you // Do NOT go and check the packet length, RFIFOSKIP is done by the caller // Return : -// 0 : error -// 1 : ok +// 0 : error +// 1 : ok int inter_party_parse_frommap(int fd) { RFIFOHEAD(fd); @@ -787,7 +784,7 @@ int inter_party_CharOnline(int char_id, int party_id) } if (party_id == 0) return 0; //No party... - + p = inter_party->fromsql(party_id); if(!p) { ShowError("Character %d's party %d not found!\n", char_id, party_id); @@ -833,7 +830,7 @@ int inter_party_CharOffline(int char_id, int party_id) { } if (party_id == 0) return 0; //No party... - + //Character has a party, set character offline and check if they were the only member online if ((p = inter_party->fromsql(party_id)) == NULL) return 0; diff --git a/src/char/int_party.h b/src/char/int_party.h index 68fae32a8..0c70a5300 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -29,21 +29,21 @@ void inter_party_defaults(void); * inter_party interface **/ struct inter_party_interface { - struct party_data *pt; - DBMap* db; // int party_id -> struct party_data* - int (*check_lv) (struct party_data *p); - void (*calc_state) (struct party_data *p); - int (*tosql) (struct party *p, int flag, int index); - struct party_data* (*fromsql) (int party_id); - int (*sql_init) (void); - void (*sql_final) (void); - struct party_data* (*search_partyname) (const char *str); - int (*check_exp_share) (struct party_data *p); - int (*check_empty) (struct party_data *p); - int (*parse_frommap) (int fd); - int (*leave) (int party_id,int account_id, int char_id); - int (*CharOnline) (int char_id, int party_id); - int (*CharOffline) (int char_id, int party_id); + struct party_data *pt; + DBMap* db; // int party_id -> struct party_data* + int (*check_lv) (struct party_data *p); + void (*calc_state) (struct party_data *p); + int (*tosql) (struct party *p, int flag, int index); + struct party_data* (*fromsql) (int party_id); + int (*sql_init) (void); + void (*sql_final) (void); + struct party_data* (*search_partyname) (const char *str); + int (*check_exp_share) (struct party_data *p); + int (*check_empty) (struct party_data *p); + int (*parse_frommap) (int fd); + int (*leave) (int party_id,int account_id, int char_id); + int (*CharOnline) (int char_id, int party_id); + int (*CharOffline) (int char_id, int party_id); }; struct inter_party_interface *inter_party; diff --git a/src/char/int_pet.c b/src/char/int_pet.c index c68fe6476..b37037844 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -222,7 +222,7 @@ int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short inter_pet->pt->pet_id = -1; //Signal NEW pet. if (inter_pet->tosql(inter_pet->pt->pet_id,inter_pet->pt)) mapif->pet_created(fd, account_id, inter_pet->pt); - else //Failed... + else //Failed... mapif->pet_created(fd, account_id, NULL); return 0; diff --git a/src/char/int_pet.h b/src/char/int_pet.h index fcb052f34..873613307 100644 --- a/src/char/int_pet.h +++ b/src/char/int_pet.h @@ -12,13 +12,13 @@ void inter_pet_defaults(void); * inter_pet interface **/ struct inter_pet_interface { - struct s_pet *pt; - int (*tosql) (int pet_id, struct s_pet* p); - int (*fromsql) (int pet_id, struct s_pet* p); - int (*sql_init) (void); - void (*sql_final) (void); - int (*delete_) (int pet_id); - int (*parse_frommap) (int fd); + struct s_pet *pt; + int (*tosql) (int pet_id, struct s_pet* p); + int (*fromsql) (int pet_id, struct s_pet* p); + int (*sql_init) (void); + void (*sql_final) (void); + int (*delete_) (int pet_id); + int (*parse_frommap) (int fd); }; struct inter_pet_interface *inter_pet; diff --git a/src/char/int_quest.c b/src/char/int_quest.c index a5721c430..b993cbc14 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -299,5 +299,5 @@ void inter_quest_defaults(void) { inter_quest = &inter_quest_s; - inter_quest->parse_frommap = inter_quest_parse_frommap; + inter_quest->parse_frommap = inter_quest_parse_frommap; } diff --git a/src/char/int_quest.h b/src/char/int_quest.h index 17740341b..265a3f97a 100644 --- a/src/char/int_quest.h +++ b/src/char/int_quest.h @@ -10,7 +10,7 @@ void inter_quest_defaults(void); * inter_quest interface **/ struct inter_quest_interface { - int (*parse_frommap) (int fd); + int (*parse_frommap) (int fd); }; struct inter_quest_interface *inter_quest; diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 7cef7e6f0..d64e11b89 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -21,7 +21,7 @@ #include "../common/sql.h" #include "../common/strlib.h" // StringBuf -#define STORAGE_MEMINC 16 +#define STORAGE_MEMINC 16 struct inter_storage_interface inter_storage_s; @@ -47,7 +47,7 @@ int inter_storage_fromsql(int account_id, struct storage_data* p) // storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} StrBuf->Init(&buf); StrBuf->AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`expire_time`,`bound`,`unique_id`"); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) StrBuf->Printf(&buf, ",`card%d`", j); StrBuf->Printf(&buf, " FROM `%s` WHERE `account_id`='%d' ORDER BY `nameid`", storage_db, account_id); @@ -69,7 +69,7 @@ int inter_storage_fromsql(int account_id, struct storage_data* p) SQL->GetData(inter->sql_handle, 7, &data, NULL); item->expire_time = (unsigned int)atoi(data); SQL->GetData(inter->sql_handle, 8, &data, NULL); item->bound = atoi(data); SQL->GetData(inter->sql_handle, 9, &data, NULL); item->unique_id = strtoull(data, NULL, 10); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) { SQL->GetData(inter->sql_handle, 10+j, &data, NULL); item->card[j] = atoi(data); } @@ -105,7 +105,7 @@ int inter_storage_guild_storage_fromsql(int guild_id, struct guild_storage* p) // storage {`guild_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`} StrBuf->Init(&buf); StrBuf->AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`bound`,`unique_id`"); - for( j = 0; j < MAX_SLOTS; ++j ) + for( j = 0; j < MAX_SLOTS; ++j ) StrBuf->Printf(&buf, ",`card%d`", j); StrBuf->Printf(&buf, " FROM `%s` WHERE `guild_id`='%d' ORDER BY `nameid`", guild_storage_db, guild_id); @@ -125,7 +125,7 @@ int inter_storage_guild_storage_fromsql(int guild_id, struct guild_storage* p) SQL->GetData(inter->sql_handle, 6, &data, NULL); item->attribute = atoi(data); SQL->GetData(inter->sql_handle, 7, &data, NULL); item->bound = atoi(data); SQL->GetData(inter->sql_handle, 8, &data, NULL); item->unique_id = strtoull(data, NULL, 10); - item->expire_time = 0; + item->expire_time = 0; for( j = 0; j < MAX_SLOTS; ++j ) { SQL->GetData(inter->sql_handle, 9+j, &data, NULL); item->card[j] = atoi(data); @@ -180,7 +180,7 @@ int mapif_load_guild_storage(int fd, int account_id, int guild_id, char flag) WFIFOL(fd,8) = guild_id; WFIFOB(fd,12) = flag; //1 open storage, 0 don't open inter_storage->guild_storage_fromsql(guild_id, (struct guild_storage*)WFIFOP(fd,13)); - WFIFOSET(fd, WFIFOW(fd,2)); + WFIFOSET(fd, WFIFOW(fd,2)); return 0; } // guild does not exist @@ -305,7 +305,7 @@ int mapif_parse_ItemBoundRetrieve_sub(int fd) i++; } SQL->FreeResult(inter->sql_handle); - + if(!i) { //No items found - No need to continue StrBuf->Destroy(&buf); SQL->StmtFree(stmt); diff --git a/src/char/int_storage.h b/src/char/int_storage.h index dcf8f07c1..6c380f29b 100644 --- a/src/char/int_storage.h +++ b/src/char/int_storage.h @@ -13,15 +13,15 @@ void inter_storage_defaults(void); * inter_storage interface **/ struct inter_storage_interface { - int (*tosql) (int account_id, struct storage_data* p); - int (*fromsql) (int account_id, struct storage_data* p); - int (*guild_storage_tosql) (int guild_id, struct guild_storage* p); - int (*guild_storage_fromsql) (int guild_id, struct guild_storage* p); - int (*sql_init) (void); - void (*sql_final) (void); - int (*delete_) (int account_id); - int (*guild_storage_delete) (int guild_id); - int (*parse_frommap) (int fd); + int (*tosql) (int account_id, struct storage_data* p); + int (*fromsql) (int account_id, struct storage_data* p); + int (*guild_storage_tosql) (int guild_id, struct guild_storage* p); + int (*guild_storage_fromsql) (int guild_id, struct guild_storage* p); + int (*sql_init) (void); + void (*sql_final) (void); + int (*delete_) (int account_id); + int (*guild_storage_delete) (int guild_id); + int (*parse_frommap) (int fd); }; struct inter_storage_interface *inter_storage; diff --git a/src/char/inter.c b/src/char/inter.c index 1efe103c0..ab91e25b9 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -32,8 +32,8 @@ #include "../common/strlib.h" #include "../common/timer.h" -#define WISDATA_TTL (60*1000) //Wis data Time To Live (60 seconds) -#define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis +#define WISDATA_TTL (60*1000) // Wis data Time To Live (60 seconds) +#define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis struct inter_interface inter_s; @@ -48,7 +48,7 @@ unsigned int party_share_level = 10; // recv. packet list int inter_recv_packet_length[] = { - -1,-1, 7,-1, -1,13,36, (2 + 4 + 4 + 4 + NAME_LENGTH), 0, 0, 0, 0, 0, 0, 0, 0, // 3000- + -1,-1, 7,-1, -1,13,36, (2 + 4 + 4 + 4 + NAME_LENGTH), 0, 0, 0, 0, 0, 0, 0, 0, // 3000- 6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010- -1,10,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020- Party -1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 18,19,186,-1, // 3030- @@ -433,7 +433,8 @@ void mapif_parse_accinfo(int fd) account_id = atoi(query); - if (account_id < START_ACCOUNT_NUM) { // is string + if (account_id < START_ACCOUNT_NUM) { + // is string if ( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq) || SQL->NumRows(inter->sql_handle) == 0 ) { if( SQL->NumRows(inter->sql_handle) == 0 ) { @@ -480,7 +481,8 @@ void mapif_parse_accinfo(int fd) return; } void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, - const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state) + const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, + int group_id, int logincount, int state) { if (map_fd <= 0 || !session_isActive(map_fd)) return; // check if we have a valid fd @@ -588,7 +590,6 @@ void inter_savereg(int account_id, int char_id, const char *key, unsigned int in } } } - } // Load account_reg from sql (type=2) @@ -614,7 +615,7 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type) ShowError("inter->accreg_fromsql: Invalid type %d\n", type); return 0; } - + WFIFOHEAD(fd, 60000 + 300); WFIFOW(fd, 0) = 0x3804; /* 0x2 = length, set prior to being sent */ @@ -624,7 +625,7 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type) WFIFOB(fd, 13) = 1;/* is string type */ WFIFOW(fd, 14) = 0;/* count */ plen = 16; - + /** * Vessel! * @@ -632,16 +633,15 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type) * { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) } **/ while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) { - SQL->GetData(inter->sql_handle, 0, &data, NULL); len = strlen(data)+1; - + WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */ plen += 1; - + safestrncpy((char*)WFIFOP(fd,plen), data, len); plen += len; - + SQL->GetData(inter->sql_handle, 1, &data, NULL); WFIFOL(fd, plen) = (unsigned int)atol(data); @@ -652,16 +652,16 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type) WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 254 */ plen += 1; - + safestrncpy((char*)WFIFOP(fd,plen), data, len); 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) = 0x3804; @@ -674,13 +674,13 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type) plen = 16; } } - + /* mark & go. */ WFIFOW(fd, 2) = plen; WFIFOSET(fd, plen); SQL->FreeResult(inter->sql_handle); - + switch( type ) { case 3: //char reg if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `char_id`='%d'", char_reg_num_db, char_id) ) @@ -704,7 +704,7 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type) WFIFOB(fd, 13) = 0;/* is int type */ WFIFOW(fd, 14) = 0;/* count */ plen = 16; - + /** * Vessel! * @@ -712,32 +712,31 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type) * { keyLength(B), key(<keyLength>), index(L), value(L) } **/ while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) { - SQL->GetData(inter->sql_handle, 0, &data, NULL); len = strlen(data)+1; - + WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */ plen += 1; - + safestrncpy((char*)WFIFOP(fd,plen), data, len); plen += len; - + SQL->GetData(inter->sql_handle, 1, &data, NULL); - + WFIFOL(fd, plen) = (unsigned int)atol(data); plen += 4; - + SQL->GetData(inter->sql_handle, 2, &data, NULL); - + WFIFOL(fd, plen) = atoi(data); plen += 4; - + WFIFOW(fd, 14) += 1; - + if( plen > 60000 ) { WFIFOW(fd, 2) = plen; WFIFOSET(fd, plen); - + /* prepare follow up */ WFIFOHEAD(fd, 60000 + 300); WFIFOW(fd, 0) = 0x3804; @@ -750,12 +749,12 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type) plen = 16; } } - + /* mark as complete & go. */ WFIFOB(fd, 12) = type; WFIFOW(fd, 2) = plen; WFIFOSET(fd, plen); - + SQL->FreeResult(inter->sql_handle); return 1; } @@ -970,12 +969,14 @@ int mapif_wis_end(struct WisData *wd, int flag) return 0; } +#if 0 // Account registry transfer to map-server -//static void mapif_account_reg(int fd, unsigned char *src) -//{ -// WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO -// mapif->sendallwos(fd, src, WBUFW(src,2)); -//} +static void mapif_account_reg(int fd, unsigned char *src) +{ + WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO + mapif->sendallwos(fd, src, WBUFW(src,2)); +} +#endif // 0 // Send the requested account_reg int mapif_account_reg_reply(int fd,int account_id,int char_id, int type) @@ -1124,7 +1125,7 @@ int mapif_parse_WisReply(int fd) flag = RFIFOB(fd,6); wd = (struct WisData*)idb_get(wis_db, id); if (wd == NULL) - return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server + return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server if ((--wd->count) <= 0 || flag != 1) { mapif->wis_end(wd, flag); // flag: 0: success to send whisper, 1: target character is not logged in?, 2: ignored by target @@ -1150,7 +1151,7 @@ int mapif_parse_WisToGM(int fd) int mapif_parse_Registry(int fd) { int account_id = RFIFOL(fd, 4), char_id = RFIFOL(fd, 8), count = RFIFOW(fd, 12); - + if( count ) { int cursor = 14, i; char key[32], sval[254]; @@ -1159,7 +1160,7 @@ int mapif_parse_Registry(int fd) if( isLoginActive ) chr->global_accreg_to_login_start(account_id,char_id); - + for(i = 0; i < count; i++) { safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor)); cursor += RFIFOB(fd, cursor) + 1; @@ -1185,7 +1186,6 @@ int mapif_parse_Registry(int fd) case 3: inter->savereg(account_id,char_id,key,index,0,true); break; - default: ShowError("mapif->parse_Registry: unknown type %d\n",RFIFOB(fd, cursor - 1)); return 1; @@ -1193,7 +1193,7 @@ int mapif_parse_Registry(int fd) } - if( isLoginActive ) + if (isLoginActive) chr->global_accreg_to_login_send(); } return 0; diff --git a/src/char/inter.h b/src/char/inter.h index f15c8b0f7..c4bb43c1d 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -21,25 +21,25 @@ void inter_defaults(void); * inter interface **/ struct inter_interface { - Sql* sql_handle; - const char* (*msg_txt) (int msg_number); - bool (*msg_config_read) (const char *cfg_name, bool allow_override); - void (*do_final_msg) (void); - const char* (*job_name) (int class_); - void (*vmsg_to_fd) (int fd, int u_fd, int aid, char* msg, va_list ap); - void (*msg_to_fd) (int fd, int u_fd, int aid, char *msg, ...); - void (*savereg) (int account_id, int char_id, const char *key, unsigned int index, intptr_t val, bool is_string); - int (*accreg_fromsql) (int account_id,int char_id, int fd, int type); - int (*config_read) (const char* cfgName); - int (*vlog) (char* fmt, va_list ap); - int (*log) (char* fmt, ...); - int (*init_sql) (const char *file); - int (*mapif_init) (int fd); - int (*check_ttl_wisdata_sub) (DBKey key, DBData *data, va_list ap); - int (*check_ttl_wisdata) (void); - int (*check_length) (int fd, int length); - int (*parse_frommap) (int fd); - void (*final) (void); + Sql* sql_handle; + const char* (*msg_txt) (int msg_number); + bool (*msg_config_read) (const char *cfg_name, bool allow_override); + void (*do_final_msg) (void); + const char* (*job_name) (int class_); + void (*vmsg_to_fd) (int fd, int u_fd, int aid, char* msg, va_list ap); + void (*msg_to_fd) (int fd, int u_fd, int aid, char *msg, ...); + void (*savereg) (int account_id, int char_id, const char *key, unsigned int index, intptr_t val, bool is_string); + int (*accreg_fromsql) (int account_id,int char_id, int fd, int type); + int (*config_read) (const char* cfgName); + int (*vlog) (char* fmt, va_list ap); + int (*log) (char* fmt, ...); + int (*init_sql) (const char *file); + int (*mapif_init) (int fd); + int (*check_ttl_wisdata_sub) (DBKey key, DBData *data, va_list ap); + int (*check_ttl_wisdata) (void); + int (*check_length) (int fd, int length); + int (*parse_frommap) (int fd); + void (*final) (void); }; struct inter_interface *inter; diff --git a/src/char/pincode.c b/src/char/pincode.c index a4ec89484..299079358 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -20,14 +20,14 @@ struct pincode_interface pincode_s; void pincode_handle ( int fd, struct char_session_data* sd ) { struct online_char_data* character = (struct online_char_data*)idb_get(chr->online_char_db, sd->account_id); - + if( character && character->pincode_enable > pincode->charselect ){ character->pincode_enable = pincode->charselect * 2; }else{ pincode->sendstate( fd, sd, PINCODE_OK ); return; } - + if( strlen(sd->pincode) == 4 ){ if( pincode->changetime && time(NULL) > (sd->pincode_change+pincode->changetime) ){ // User hasn't changed his PIN code for a long time pincode->sendstate( fd, sd, PINCODE_EXPIRED ); @@ -43,7 +43,7 @@ void pincode_handle ( int fd, struct char_session_data* sd ) { void pincode_check(int fd, struct char_session_data* sd) { char pin[5] = "\0\0\0\0"; - + strncpy(pin, (char*)RFIFOP(fd, 6), 4+1); pincode->decrypt(sd->pincode_seed, pin); if( pincode->compare( fd, sd, pin ) ){ @@ -74,7 +74,7 @@ void pincode_change(int fd, struct char_session_data* sd) { pincode->decrypt(sd->pincode_seed,oldpin); if( !pincode->compare( fd, sd, oldpin ) ) return; - + strncpy(newpin, (char*)RFIFOP(fd,10), sizeof(newpin)); pincode->decrypt(sd->pincode_seed,newpin); pincode->update( sd->account_id, newpin ); @@ -128,7 +128,7 @@ void pincode_notifyLoginPinError(int account_id) { void pincode_decrypt(unsigned int userSeed, char* pin) { int i, pos; char tab[10] = {0,1,2,3,4,5,6,7,8,9}; - + for( i = 1; i < 10; i++ ){ userSeed = pincode->baseSeed + userSeed * pincode->multiplier; pos = userSeed % (i + 1); @@ -138,18 +138,17 @@ void pincode_decrypt(unsigned int userSeed, char* pin) { tab[i] ^= tab[pos]; } } - + for( i = 0; i < 4; i++ ){ pin[i] = tab[pin[i] - '0']; } - + sprintf(pin, "%d%d%d%d", pin[0], pin[1], pin[2], pin[3]); } bool pincode_config_read(char *w1, char *w2) { - + while ( true ) { - if ( strcmpi(w1, "pincode_enabled") == 0 ) { pincode->enabled = atoi(w2); #if PACKETVER < 20110309 @@ -168,18 +167,18 @@ bool pincode_config_read(char *w1, char *w2) { } } else if ( strcmpi(w1, "pincode_charselect") == 0 ) { pincode->charselect = atoi(w2); - } else + } else { return false; - + } break; } - + return true; } void pincode_defaults(void) { pincode = &pincode_s; - + pincode->enabled = PINCODE_OK; pincode->changetime = 0; pincode->maxtry = 3; |