diff options
author | Haru <haru@dotalux.com> | 2014-11-16 06:35:51 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2014-11-16 07:16:23 +0100 |
commit | 02fcaed6bd32b0ffbc4f03b8f9de6f0720e6253f (patch) | |
tree | 3161fd5786bb563c32059068eb3b4876d2ae11ca /src | |
parent | 31bff051ee3c353fb7ee5e544d68feeaefd4941f (diff) | |
download | hercules-02fcaed6bd32b0ffbc4f03b8f9de6f0720e6253f.tar.gz hercules-02fcaed6bd32b0ffbc4f03b8f9de6f0720e6253f.tar.bz2 hercules-02fcaed6bd32b0ffbc4f03b8f9de6f0720e6253f.tar.xz hercules-02fcaed6bd32b0ffbc4f03b8f9de6f0720e6253f.zip |
Whitespace cleanup (no code changes)
This includes, and is not limited to: mixed or wrong indentation, excess
whitespace (horizontal and vertical), misalignment, trailing spaces.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
118 files changed, 5599 insertions, 5570 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; diff --git a/src/common/HPM.c b/src/common/HPM.c index 003f2d935..e38451161 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -56,22 +56,22 @@ void hplugin_export_symbol(void *var, char *name) { void *hplugin_import_symbol(char *name, unsigned int pID) { unsigned int i; - + for( i = 0; i < HPM->symbol_count; i++ ) { if( strcmp(HPM->symbols[i]->name,name) == 0 ) return HPM->symbols[i]->ptr; } - + ShowError("HPM:get_symbol:%s: '"CL_WHITE"%s"CL_RESET"' not found!\n",HPM->pid2name(pID),name); return NULL; } bool hplugin_iscompatible(char* version) { unsigned int req_major = 0, req_minor = 0; - + if( version == NULL ) return false; - + sscanf(version, "%u.%u", &req_major, &req_minor); return ( req_major == HPM->version[0] && req_minor <= HPM->version[1] ) ? true : false; @@ -110,7 +110,7 @@ bool hplugin_populate(struct hplugin *plugin, const char *filename) { HPM_POP(ShowFatalError), }; int i, length = ARRAYLENGTH(ToLink); - + for(i = 0; i < length; i++) { if( !( Link = plugin_import(plugin->dll, ToLink[i].name,void **) ) ) { ShowWarning("HPM:plugin_load: failed to retrieve '%s' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", ToLink[i].name, filename); @@ -119,7 +119,7 @@ bool hplugin_populate(struct hplugin *plugin, const char *filename) { } *Link = ToLink[i].Ref; } - + return true; } #undef HPM_POP @@ -133,54 +133,54 @@ struct hplugin *hplugin_load(const char* filename) { int *HPMDataCheckVer; unsigned int *HPMDataCheckLen; struct s_HPMDataCheck *HPMDataCheck; - + if( HPM->exists(filename) ) { ShowWarning("HPM:plugin_load: attempting to load duplicate '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename); return NULL; } - + plugin = HPM->create(); - + if( !( plugin->dll = plugin_open(filename) ) ){ ShowWarning("HPM:plugin_load: failed to load '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename); HPM->unload(plugin); return NULL; } - + if( !( info = plugin_import(plugin->dll, "pinfo",struct hplugin_info*) ) ) { ShowDebug("HPM:plugin_load: failed to retrieve 'plugin_info' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename); HPM->unload(plugin); return NULL; } - + if( !(info->type & SERVER_TYPE) ) { HPM->unload(plugin); return NULL; } - + if( !HPM->iscompatible(info->req_version) ) { ShowWarning("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' incompatible version '%s' -> '%s', skipping...\n", filename, info->req_version, HPM_VERSION); HPM->unload(plugin); return NULL; } - + plugin->info = info; plugin->filename = aStrdup(filename); - + if( !( import_symbol_ref = plugin_import(plugin->dll, "import_symbol",void **) ) ) { ShowWarning("HPM:plugin_load: failed to retrieve 'import_symbol' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename); HPM->unload(plugin); return NULL; } - + *import_symbol_ref = HPM->import_symbol; - + if( !( sql_handle = plugin_import(plugin->dll, "mysql_handle",Sql **) ) ) { ShowWarning("HPM:plugin_load: failed to retrieve 'mysql_handle' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename); HPM->unload(plugin); return NULL; } - + *sql_handle = HPM->import_symbol("sql_handle",plugin->idx); if( !( HPMi = plugin_import(plugin->dll, "HPMi",struct HPMi_interface **) ) ) { @@ -188,44 +188,44 @@ struct hplugin *hplugin_load(const char* filename) { HPM->unload(plugin); return NULL; } - + if( !( *HPMi = plugin_import(plugin->dll, "HPMi_s",struct HPMi_interface *) ) ) { ShowWarning("HPM:plugin_load: failed to retrieve 'HPMi_s' for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename); HPM->unload(plugin); return NULL; } plugin->hpi = *HPMi; - + if( ( plugin->hpi->event[HPET_INIT] = plugin_import(plugin->dll, "plugin_init",void (*)(void)) ) ) anyEvent = true; - + if( ( plugin->hpi->event[HPET_FINAL] = plugin_import(plugin->dll, "plugin_final",void (*)(void)) ) ) anyEvent = true; - + if( ( plugin->hpi->event[HPET_READY] = plugin_import(plugin->dll, "server_online",void (*)(void)) ) ) anyEvent = true; - + if( ( plugin->hpi->event[HPET_POST_FINAL] = plugin_import(plugin->dll, "server_post_final",void (*)(void)) ) ) anyEvent = true; - + if( ( plugin->hpi->event[HPET_PRE_INIT] = plugin_import(plugin->dll, "server_preinit",void (*)(void)) ) ) anyEvent = true; - + if( !anyEvent ) { ShowWarning("HPM:plugin_load: no events found for '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename); HPM->unload(plugin); return NULL; } - + if( !HPM->populate(plugin,filename) ) return NULL; - + if( !( HPMDataCheckLen = plugin_import(plugin->dll, "HPMDataCheckLen", unsigned int *) ) ) { ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheckLen' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h, skipping...\n", filename); HPM->unload(plugin); return NULL; } - + if( !( HPMDataCheckVer = plugin_import(plugin->dll, "HPMDataCheckVer", int *) ) ) { ShowWarning("HPM:plugin_load: failed to retrieve 'HPMDataCheckVer' for '"CL_WHITE"%s"CL_RESET"', most likely an outdated plugin, skipping...\n", filename); HPM->unload(plugin); @@ -237,14 +237,14 @@ struct hplugin *hplugin_load(const char* filename) { HPM->unload(plugin); return NULL; } - + // TODO: Remove the HPM->DataCheck != NULL check once login and char support is complete if (HPM->DataCheck != NULL && !HPM->DataCheck(HPMDataCheck,*HPMDataCheckLen,*HPMDataCheckVer,plugin->info->name)) { ShowWarning("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' failed DataCheck, out of sync from the core (recompile plugin), skipping...\n", filename); HPM->unload(plugin); return NULL; } - + /* id */ plugin->hpi->pid = plugin->idx; /* core */ @@ -261,13 +261,13 @@ struct hplugin *hplugin_load(const char* filename) { /* server specific */ if( HPM->load_sub ) HPM->load_sub(plugin); - + return plugin; } void hplugin_unload(struct hplugin* plugin) { unsigned int i = plugin->idx, cursor = 0; - + if( plugin->filename ) aFree(plugin->filename); if( plugin->dll ) @@ -297,25 +297,25 @@ void hplugins_config_read(const char * const *extra_plugins, int extra_plugins_c const char *config_filename = "conf/plugins.conf"; // FIXME hardcoded name FILE *fp; int i; - + /* yes its ugly, its temporary and will be gone as soon as the new inter-server.conf is set */ if( (fp = fopen("conf/import/plugins.conf","r")) ) { config_filename = "conf/import/plugins.conf"; fclose(fp); } - + if (libconfig->read_file(&plugins_conf, config_filename)) return; if( HPM->symbol_defaults_sub ) HPM->symbol_defaults_sub(); - + plist = libconfig->lookup(&plugins_conf, "plugins_list"); for (i = 0; i < extra_plugins_count; i++) { config_setting_t *entry = libconfig->setting_add(plist, NULL, CONFIG_TYPE_STRING); config_setting_set_string(entry, extra_plugins[i]); } - + if (plist != NULL) { int length = libconfig->setting_length(plist); char filename[60]; @@ -356,7 +356,7 @@ void hplugins_config_read(const char * const *extra_plugins, int extra_plugins_c } libconfig->destroy(&plugins_conf); } - + if( HPM->plugin_count ) ShowStatus("HPM: There are '"CL_WHITE"%d"CL_RESET"' plugins loaded, type '"CL_WHITE"plugins"CL_RESET"' to list them\n", HPM->plugin_count); } @@ -365,9 +365,9 @@ CPCMD(plugins) { ShowInfo("HPC: there are no plugins loaded\n"); } else { unsigned int i; - + ShowInfo("HPC: There are '"CL_WHITE"%d"CL_RESET"' plugins loaded\n",HPM->plugin_count); - + for(i = 0; i < HPM->plugin_count; i++) { ShowInfo("HPC: - '"CL_WHITE"%s"CL_RESET"' (%s)\n",HPM->plugins[i]->info->name,HPM->plugins[i]->filename); } @@ -400,18 +400,18 @@ void hplugins_addToHPData(enum HPluginDataTypes type, unsigned int pluginID, voi struct HPluginData *HPData, **HPDataSRC; struct HPDataOperationStorage action; unsigned int i, max; - + HPM->grabHPData(&action,type,ptr); if( action.hdatac == NULL ) { /* woo it failed! */ ShowError("HPM:addToHPData:%s: failed, type %d (%u|%u)\n",HPM->pid2name(pluginID),type,pluginID,index); return; } - + /* flag */ HPDataSRC = *(action.HPDataSRCPtr); max = *(action.hdatac); - + /* duplicate check */ for(i = 0; i < max; i++) { if( HPDataSRC[i]->pluginID == pluginID && HPDataSRC[i]->type == index ) { @@ -419,20 +419,20 @@ void hplugins_addToHPData(enum HPluginDataTypes type, unsigned int pluginID, voi return; } } - + /* HPluginData is always same size, probably better to use the ERS (with reasonable chunk size e.g. 10/25/50) */ CREATE(HPData, struct HPluginData, 1); - + /* input */ HPData->pluginID = pluginID; HPData->type = index; HPData->flag.free = autofree ? 1 : 0; HPData->data = data; - + /* resize */ *(action.hdatac) += 1; RECREATE(*(action.HPDataSRCPtr),struct HPluginData *,*(action.hdatac)); - + /* RECREATE modified the address */ HPDataSRC = *(action.HPDataSRCPtr); HPDataSRC[*(action.hdatac) - 1] = HPData; @@ -442,23 +442,23 @@ void *hplugins_getFromHPData(enum HPluginDataTypes type, unsigned int pluginID, struct HPDataOperationStorage action; struct HPluginData **HPDataSRC; unsigned int i, max; - + HPM->grabHPData(&action,type,ptr); - + if( action.hdatac == NULL ) { /* woo it failed! */ ShowError("HPM:getFromHPData:%s: failed, type %d (%u|%u)\n",HPM->pid2name(pluginID),type,pluginID,index); return NULL; } - + /* flag */ HPDataSRC = *(action.HPDataSRCPtr); max = *(action.hdatac); - + for(i = 0; i < max; i++) { if( HPDataSRC[i]->pluginID == pluginID && HPDataSRC[i]->type == index ) return HPDataSRC[i]->data; } - + return NULL; } @@ -466,30 +466,30 @@ void hplugins_removeFromHPData(enum HPluginDataTypes type, unsigned int pluginID struct HPDataOperationStorage action; struct HPluginData **HPDataSRC; unsigned int i, max; - + HPM->grabHPData(&action,type,ptr); - + if( action.hdatac == NULL ) { /* woo it failed! */ ShowError("HPM:removeFromHPData:%s: failed, type %d (%u|%u)\n",HPM->pid2name(pluginID),type,pluginID,index); return; } - + /* flag */ HPDataSRC = *(action.HPDataSRCPtr); max = *(action.hdatac); - + for(i = 0; i < max; i++) { if( HPDataSRC[i]->pluginID == pluginID && HPDataSRC[i]->type == index ) break; } - + if( i != max ) { unsigned int cursor; - + aFree(HPDataSRC[i]->data);/* when its removed we delete it regardless of autofree */ aFree(HPDataSRC[i]); HPDataSRC[i] = NULL; - + for(i = 0, cursor = 0; i < max; i++) { if( HPDataSRC[i] == NULL ) continue; @@ -499,13 +499,12 @@ void hplugins_removeFromHPData(enum HPluginDataTypes type, unsigned int pluginID } *(action.hdatac) = cursor; } - } bool hplugins_addpacket(unsigned short cmd, short length,void (*receive) (int fd),unsigned int point,unsigned int pluginID) { struct HPluginPacket *packet; unsigned int i; - + if( point >= hpPHP_MAX ) { ShowError("HPM->addPacket:%s: unknown point '%u' specified for packet 0x%04x (len %d)\n",HPM->pid2name(pluginID),point,cmd,length); return false; @@ -517,15 +516,15 @@ bool hplugins_addpacket(unsigned short cmd, short length,void (*receive) (int fd return false; } } - + RECREATE(HPM->packets[point], struct HPluginPacket, ++HPM->packetsc[point]); packet = &HPM->packets[point][HPM->packetsc[point] - 1]; - + packet->pluginID = pluginID; packet->cmd = cmd; packet->len = length; packet->receive = receive; - + return true; } /* @@ -535,52 +534,52 @@ bool hplugins_addpacket(unsigned short cmd, short length,void (*receive) (int fd */ unsigned char hplugins_parse_packets(int fd, enum HPluginPacketHookingPoints point) { unsigned int i; - + for(i = 0; i < HPM->packetsc[point]; i++) { if( HPM->packets[point][i].cmd == RFIFOW(fd,0) ) break; } - + if( i != HPM->packetsc[point] ) { struct HPluginPacket *packet = &HPM->packets[point][i]; short length; - + if( (length = packet->len) == -1 ) { if( (length = RFIFOW(fd, 2)) > (int)RFIFOREST(fd) ) - return 2; + return 2; } - + packet->receive(fd); RFIFOSKIP(fd, length); return 1; } - + return 0; } char *hplugins_id2name (unsigned int pid) { unsigned int i; - + for( i = 0; i < HPM->plugin_count; i++ ) { if( HPM->plugins[i]->idx == pid ) return HPM->plugins[i]->info->name; } - + return "UnknownPlugin"; } char* HPM_file2ptr(const char *file) { unsigned int i; - + for(i = 0; i < HPM->fnamec; i++) { if( HPM->fnames[i].addr == file ) return HPM->fnames[i].name; } - + i = HPM->fnamec; - + /* we handle this memory outside of the server's memory manager because we need it to exist after the memory manager goes down */ HPM->fnames = realloc(HPM->fnames,(++HPM->fnamec)*sizeof(struct HPMFileNameCache)); - + HPM->fnames[i].addr = file; HPM->fnames[i].name = strdup(file); @@ -611,9 +610,9 @@ bool HPM_AddHook(enum HPluginHookType type, const char *target, void *hook, unsi /* if not check if a sub-hooking list is available (from the server) and run it by */ if( HPM->addhook_sub && HPM->addhook_sub(type,target,hook,pID) ) return true; - + ShowError("HPM:AddHook: unknown Hooking Point '%s'!\n",target); - + return false; } void HPM_HookStop (const char *func, unsigned int pID) { @@ -632,82 +631,82 @@ bool hpm_parse_arg(const char *arg, int *index, char *argv[], bool param) { if( data->has_param && param ) *index += 1; return true; } - + return false; } void hpm_arg_help(void) { DBIterator *iter = db_iterator(HPM->arg_db); struct HPMArgData *data = NULL; - + for( data = dbi_first(iter); dbi_exists(iter); data = dbi_next(iter) ) { if( data->help != NULL ) data->help(); else ShowInfo(" %s (%s)\t\t<no description provided>\n",data->name,HPM->pid2name(data->pluginID)); } - + dbi_destroy(iter); } bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, void (*func) (char *param),void (*help) (void)) { struct HPMArgData *data = NULL; - + if( strdb_exists(HPM->arg_db, name) ) { ShowError("HPM:add_arg:%s duplicate! (from %s)\n",name,HPM->pid2name(pluginID)); return false; } - + CREATE(data, struct HPMArgData, 1); - + data->pluginID = pluginID; data->name = aStrdup(name); data->func = func; data->help = help; data->has_param = has_param; - + strdb_put(HPM->arg_db, data->name, data); - + return true; } bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *name, void (*func) (const char *val)) { struct HPConfListenStorage *conf; unsigned int i; - + if( type >= HPCT_MAX ) { ShowError("HPM->addConf:%s: unknown point '%u' specified for config '%s'\n",HPM->pid2name(pluginID),type,name); return false; } - + for(i = 0; i < HPM->confsc[type]; i++) { if( !strcmpi(name,HPM->confs[type][i].key) ) { ShowError("HPM->addConf:%s: duplicate '%s', already in use by '%s'!",HPM->pid2name(pluginID),name,HPM->pid2name(HPM->confs[type][i].pluginID)); return false; } } - + RECREATE(HPM->confs[type], struct HPConfListenStorage, ++HPM->confsc[type]); conf = &HPM->confs[type][HPM->confsc[type] - 1]; - + conf->pluginID = pluginID; safestrncpy(conf->key, name, HPM_ADDCONF_LENGTH); conf->func = func; - + return true; } bool hplugins_parse_conf(const char *w1, const char *w2, enum HPluginConfType point) { unsigned int i; - + /* exists? */ for(i = 0; i < HPM->confsc[point]; i++) { if( !strcmpi(w1,HPM->confs[point][i].key) ) break; } - + /* trigger and we're set! */ if( i != HPM->confsc[point] ) { HPM->confs[point][i].func(w2); return true; } - + return false; } @@ -721,7 +720,7 @@ bool HPM_DataCheck(struct s_HPMDataCheck *src, unsigned int size, int version, c ShowError("HPMDataCheck:%s: DataCheck API version mismatch %d != %d\n", name, datacheck_version, version); return false; } - + for (i = 0; i < size; i++) { if (!(src[i].type|SERVER_TYPE)) continue; @@ -737,7 +736,7 @@ bool HPM_DataCheck(struct s_HPMDataCheck *src, unsigned int size, int version, c } } } - + return true; } @@ -746,12 +745,12 @@ void HPM_datacheck_init(const struct s_HPMDataCheck *src, unsigned int length, i datacheck_version = version; datacheck_data = src; - + /** * Populates datacheck_db for easy lookup later on **/ datacheck_db = strdb_alloc(DB_OPT_BASE,0); - + for(i = 0; i < length; i++) { strdb_uiput(datacheck_db, src[i].name, i); } @@ -805,12 +804,12 @@ void hpm_init(void) { datacheck_db = NULL; datacheck_data = NULL; datacheck_version = 0; - + HPM->symbols = NULL; HPM->plugins = NULL; HPM->plugin_count = HPM->symbol_count = 0; HPM->off = false; - + memcpy(&iMalloc_HPM, iMalloc, sizeof(struct malloc_interface)); HPMiMalloc = &iMalloc_HPM; HPMiMalloc->malloc = HPM_mmalloc; @@ -820,21 +819,21 @@ void hpm_init(void) { HPMiMalloc->astrdup = HPM_astrdup; sscanf(HPM_VERSION, "%u.%u", &HPM->version[0], &HPM->version[1]); - + if( HPM->version[0] == 0 && HPM->version[1] == 0 ) { ShowError("HPM:init:failed to retrieve HPM version!!\n"); return; } - + for(i = 0; i < hpPHP_MAX; i++) { HPM->packets[i] = NULL; HPM->packetsc[i] = 0; } - + HPM->arg_db = strdb_alloc(DB_OPT_RELEASE_DATA, 0); - + HPM->symbol_defaults(); - + #ifdef CONSOLE_INPUT console->input->addCommand("plugins",CPCMD_A(plugins)); #endif @@ -842,64 +841,63 @@ void hpm_init(void) { } void hpm_memdown(void) { unsigned int i; - + /* this memory is handled outside of the server's memory manager and thus cleared after memory manager goes down */ - + for( i = 0; i < HPM->fnamec; i++ ) { free(HPM->fnames[i].name); } - + if( HPM->fnames ) free(HPM->fnames); - } int hpm_arg_db_clear_sub(DBKey key, DBData *data, va_list args) { struct HPMArgData *a = DB->data2ptr(data); - + aFree(a->name); - + return 0; } void hpm_final(void) { unsigned int i; - + HPM->off = true; - + for( i = 0; i < HPM->plugin_count; i++ ) { HPM->unload(HPM->plugins[i]); } - + if( HPM->plugins ) aFree(HPM->plugins); - + for( i = 0; i < HPM->symbol_count; i++ ) { aFree(HPM->symbols[i]); } - + if( HPM->symbols ) aFree(HPM->symbols); - + for( i = 0; i < hpPHP_MAX; i++ ) { if( HPM->packets[i] ) aFree(HPM->packets[i]); } - + for( i = 0; i < HPCT_MAX; i++ ) { if( HPM->confsc[i] ) aFree(HPM->confs[i]); } - + HPM->arg_db->destroy(HPM->arg_db,HPM->arg_db_clear_sub); - + /* HPM->fnames is cleared after the memory manager goes down */ iMalloc->post_shutdown = hpm_memdown; - + return; } void hpm_defaults(void) { unsigned int i; HPM = &HPM_s; - + HPM->fnames = NULL; HPM->fnamec = 0; HPM->force_return = false; @@ -919,7 +917,7 @@ void hpm_defaults(void) { /* */ HPM->init = hpm_init; HPM->final = hpm_final; - + HPM->create = hplugin_create; HPM->load = hplugin_load; HPM->unload = hplugin_unload; diff --git a/src/common/atomic.h b/src/common/atomic.h index e73b1c464..a42dfad1c 100644 --- a/src/common/atomic.h +++ b/src/common/atomic.h @@ -8,9 +8,9 @@ // (Interlocked CompareExchange, Add .. and so on ..) // // Implementation varies / depends on: -// - Architecture -// - Compiler -// - Operating System +// - Architecture +// - Compiler +// - Operating System // // our Abstraction is fully API-Compatible to Microsoft's implementation @ NT5.0+ // @@ -29,13 +29,13 @@ forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, _asm{ lea esi,_cmp; lea edi,exch; - + mov eax,[esi]; mov edx,4[esi]; mov ebx,[edi]; mov ecx,4[edi]; mov esi,dest; - + lock CMPXCHG8B [esi]; } } @@ -109,7 +109,7 @@ static forceinline int64 InterlockedIncrement64(volatile int64 *addend){ static forceinline int32 InterlockedIncrement(volatile int32 *addend){ - return __sync_add_and_fetch(addend, 1); + return __sync_add_and_fetch(addend, 1); }//end: InterlockedIncrement() @@ -139,7 +139,7 @@ static forceinline int64 InterlockedExchange64(volatile int64 *target, int64 val static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){ - return __sync_lock_test_and_set(target, val); + return __sync_lock_test_and_set(target, val); }//end: InterlockedExchange() diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 18bc0b8cb..df1d364d4 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -117,56 +117,56 @@ // Integers with guaranteed _exact_ size. ////////////////////////////////////////////////////////////////////////// -typedef int8_t int8; -typedef int16_t int16; -typedef int32_t int32; -typedef int64_t int64; +typedef int8_t int8; +typedef int16_t int16; +typedef int32_t int32; +typedef int64_t int64; -typedef int8_t sint8; -typedef int16_t sint16; -typedef int32_t sint32; -typedef int64_t sint64; +typedef int8_t sint8; +typedef int16_t sint16; +typedef int32_t sint32; +typedef int64_t sint64; -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; -typedef uint64_t uint64; +typedef uint8_t uint8; +typedef uint16_t uint16; +typedef uint32_t uint32; +typedef uint64_t uint64; #undef UINT8_MIN #undef UINT16_MIN #undef UINT32_MIN #undef UINT64_MIN -#define UINT8_MIN ((uint8) UINT8_C(0x00)) -#define UINT16_MIN ((uint16)UINT16_C(0x0000)) -#define UINT32_MIN ((uint32)UINT32_C(0x00000000)) -#define UINT64_MIN ((uint64)UINT64_C(0x0000000000000000)) +#define UINT8_MIN ((uint8) UINT8_C(0x00)) +#define UINT16_MIN ((uint16)UINT16_C(0x0000)) +#define UINT32_MIN ((uint32)UINT32_C(0x00000000)) +#define UINT64_MIN ((uint64)UINT64_C(0x0000000000000000)) #undef UINT8_MAX #undef UINT16_MAX #undef UINT32_MAX #undef UINT64_MAX -#define UINT8_MAX ((uint8) UINT8_C(0xFF)) -#define UINT16_MAX ((uint16)UINT16_C(0xFFFF)) -#define UINT32_MAX ((uint32)UINT32_C(0xFFFFFFFF)) -#define UINT64_MAX ((uint64)UINT64_C(0xFFFFFFFFFFFFFFFF)) +#define UINT8_MAX ((uint8) UINT8_C(0xFF)) +#define UINT16_MAX ((uint16)UINT16_C(0xFFFF)) +#define UINT32_MAX ((uint32)UINT32_C(0xFFFFFFFF)) +#define UINT64_MAX ((uint64)UINT64_C(0xFFFFFFFFFFFFFFFF)) #undef SINT8_MIN #undef SINT16_MIN #undef SINT32_MIN #undef SINT64_MIN -#define SINT8_MIN ((sint8) INT8_C(0x80)) -#define SINT16_MIN ((sint16)INT16_C(0x8000)) -#define SINT32_MIN ((sint32)INT32_C(0x80000000)) -#define SINT64_MIN ((sint32)INT64_C(0x8000000000000000)) +#define SINT8_MIN ((sint8) INT8_C(0x80)) +#define SINT16_MIN ((sint16)INT16_C(0x8000)) +#define SINT32_MIN ((sint32)INT32_C(0x80000000)) +#define SINT64_MIN ((sint32)INT64_C(0x8000000000000000)) #undef SINT8_MAX #undef SINT16_MAX #undef SINT32_MAX #undef SINT64_MAX -#define SINT8_MAX ((sint8) INT8_C(0x7F)) -#define SINT16_MAX ((sint16)INT16_C(0x7FFF)) -#define SINT32_MAX ((sint32)INT32_C(0x7FFFFFFF)) -#define SINT64_MAX ((sint64)INT64_C(0x7FFFFFFFFFFFFFFF)) +#define SINT8_MAX ((sint8) INT8_C(0x7F)) +#define SINT16_MAX ((sint16)INT16_C(0x7FFF)) +#define SINT32_MAX ((sint32)INT32_C(0x7FFFFFFF)) +#define SINT64_MAX ((sint64)INT64_C(0x7FFFFFFFFFFFFFFF)) ////////////////////////////////////////////////////////////////////////// // Integers with guaranteed _minimum_ size. @@ -191,10 +191,10 @@ typedef unsigned long int ppuint32; #if defined(WIN32) && !defined(MINGW) // does not have a signed size_t ////////////////////////////// -#if defined(_WIN64) // native 64bit windows platform -typedef __int64 ssize_t; +#if defined(_WIN64) // native 64bit windows platform +typedef __int64 ssize_t; #else -typedef int ssize_t; +typedef int ssize_t; #endif ////////////////////////////// #endif @@ -236,22 +236,22 @@ typedef uintptr_t uintptr; // some redefine of function redefines for some Compilers ////////////////////////////////////////////////////////////////////////// #if defined(_MSC_VER) || defined(__BORLANDC__) -#define strcasecmp stricmp -#define strncasecmp strnicmp -#define strncmpi strnicmp -#define snprintf _snprintf +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define strncmpi strnicmp +#define snprintf _snprintf #if defined(_MSC_VER) && _MSC_VER < 1400 -#define vsnprintf _vsnprintf +#define vsnprintf _vsnprintf #endif #else -#define strcmpi strcasecmp -#define stricmp strcasecmp -#define strncmpi strncasecmp -#define strnicmp strncasecmp +#define strcmpi strcasecmp +#define stricmp strcasecmp +#define strncmpi strncasecmp +#define strnicmp strncasecmp #endif #if defined(_MSC_VER) && _MSC_VER > 1200 -#define strtoull _strtoui64 -#define strtoll _strtoi64 +#define strtoull _strtoui64 +#define strtoll _strtoi64 #endif // keyword replacement @@ -286,8 +286,8 @@ typedef uintptr_t uintptr; #ifndef __bool_true_false_are_defined // If stdbool.h is not available or does not define this typedef char bool; -#define false (1==0) -#define true (1==1) +#define false (1==0) +#define true (1==1) #define __bool_true_false_are_defined #endif // __bool_true_false_are_defined @@ -308,18 +308,17 @@ typedef char bool; #if 0 //to be activated soon, more tests needed on how VS works with the macro above #ifdef WIN32 #undef swap -#define swap(a,b)__asm \ -{ \ - __asm mov eax, dword ptr [a] \ - __asm cmp eax, dword ptr [b] \ - __asm je _ret \ - __asm xor eax, dword ptr [b] \ - __asm mov dword ptr [a], eax \ - __asm xor eax, dword ptr [b] \ - __asm mov dword ptr [b], eax \ - __asm xor eax, dword ptr [a] \ - __asm mov dword ptr [a], eax \ - __asm _ret: \ +#define swap(a,b)__asm { \ + __asm mov eax, dword ptr [a] \ + __asm cmp eax, dword ptr [b] \ + __asm je _ret \ + __asm xor eax, dword ptr [b] \ + __asm mov dword ptr [a], eax \ + __asm xor eax, dword ptr [b] \ + __asm mov dword ptr [b], eax \ + __asm xor eax, dword ptr [a] \ + __asm mov dword ptr [a], eax \ + __asm _ret: \ } #endif #endif @@ -343,7 +342,7 @@ typedef char bool; ////////////////////////////////////////////////////////////////////////// // number of bits in a byte #ifndef NBBY -#define NBBY 8 +#define NBBY 8 #endif ////////////////////////////////////////////////////////////////////////// diff --git a/src/common/conf.c b/src/common/conf.c index 34d1cacbf..c974decf9 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -34,10 +34,10 @@ void config_setting_copy_simple(config_setting_t *parent, const config_setting_t } else { config_setting_t *set; - + if( libconfig->setting_get_member(parent, config_setting_name(src)) != NULL ) return; - + if ((set = libconfig->setting_add(parent, config_setting_name(src), config_setting_type(src))) == NULL) return; @@ -83,14 +83,14 @@ void config_setting_copy_aggregate(config_setting_t *parent, const config_settin if( libconfig->setting_get_member(parent, config_setting_name(src)) != NULL ) return; - + newAgg = libconfig->setting_add(parent, config_setting_name(src), config_setting_type(src)); if (newAgg == NULL) return; n = config_setting_length(src); - + for (i = 0; i < n; i++) { if (config_setting_is_group(src)) { libconfig->setting_copy_simple(newAgg, libconfig->setting_get_elem(src, i)); @@ -101,7 +101,6 @@ void config_setting_copy_aggregate(config_setting_t *parent, const config_settin } int config_setting_copy(config_setting_t *parent, const config_setting_t *src) { - if (!config_setting_is_group(parent) && !config_setting_is_list(parent)) return CONFIG_FALSE; @@ -115,7 +114,7 @@ int config_setting_copy(config_setting_t *parent, const config_setting_t *src) { void libconfig_defaults(void) { libconfig = &libconfig_s; - + libconfig->read = config_read; libconfig->write = config_write; /* */ diff --git a/src/common/conf.h b/src/common/conf.h index c232a035c..9ea5f5b72 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -22,21 +22,21 @@ struct libconfig_interface { int (*read_string) (config_t *config, const char *str); int (*read_file_src) (config_t *config, const char *filename); int (*write_file) (config_t *config, const char *filename); - + void (*set_destructor) (config_t *config, void (*destructor)(void *)); void (*set_include_dir) (config_t *config, const char *include_dir); - + void (*init) (config_t *config); void (*destroy) (config_t *config); - + int (*setting_get_int) (const config_setting_t *setting); long long (*setting_get_int64) (const config_setting_t *setting); double (*setting_get_float) (const config_setting_t *setting); - + int (*setting_get_bool) (const config_setting_t *setting); - + const char * (*setting_get_string) (const config_setting_t *setting); - + int (*setting_lookup_int) (const config_setting_t *setting, const char *name, int *value); int (*setting_lookup_int64) (const config_setting_t *setting, const char *name, long long *value); int (*setting_lookup_float) (const config_setting_t *setting, const char *name, double *value); @@ -47,10 +47,10 @@ struct libconfig_interface { int (*setting_set_float) (config_setting_t *setting, double value); int (*setting_set_bool) (config_setting_t *setting, int value); int (*setting_set_string) (config_setting_t *setting, const char *value); - + int (*setting_set_format) (config_setting_t *setting, short format); short (*setting_get_format) (const config_setting_t *setting); - + int (*setting_get_int_elem) (const config_setting_t *setting, int idx); long long (*setting_get_int64_elem) (const config_setting_t *setting, int idx); double (*setting_get_float_elem) (const config_setting_t *setting, int idx); @@ -61,19 +61,19 @@ struct libconfig_interface { config_setting_t * (*setting_set_float_elem) (config_setting_t *setting, int idx, double value); config_setting_t * (*setting_set_bool_elem) (config_setting_t *setting, int idx, int value); config_setting_t * (*setting_set_string_elem) (config_setting_t *setting, int idx, const char *value); - + int (*setting_index) (const config_setting_t *setting); int (*setting_length) (const config_setting_t *setting); - + config_setting_t * (*setting_get_elem) (const config_setting_t *setting, unsigned int idx); config_setting_t * (*setting_get_member) (const config_setting_t *setting, const char *name); - + config_setting_t * (*setting_add) (config_setting_t *parent, const char *name, int type); int (*setting_remove) (config_setting_t *parent, const char *name); - + int (*setting_remove_elem) (config_setting_t *parent, unsigned int idx); void (*setting_set_hook) (config_setting_t *setting, void *hook); - + config_setting_t * (*lookup) (const config_t *config, const char *path); config_setting_t * (*lookup_from) (config_setting_t *setting, const char *path); int (*lookup_int) (const config_t *config, const char *path, int *value); @@ -81,7 +81,7 @@ struct libconfig_interface { int (*lookup_float) (const config_t *config, const char *path, double *value); int (*lookup_bool) (const config_t *config, const char *path, int *value); int (*lookup_string) (const config_t *config, const char *path, const char **value); - + /* those are custom and are from src/common/conf.c */ /* Functions to copy settings from libconfig/contrib */ int (*read_file) (config_t *config, const char *config_filename); diff --git a/src/common/console.c b/src/common/console.c index 6a82db555..577d1a3f0 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -43,7 +43,7 @@ struct console_input_interface console_input_s; #endif /*====================================== - * CORE : Display title + * CORE : Display title *--------------------------------------*/ void display_title(void) { const char *vcstype = sysinfo->vcstype(); @@ -80,18 +80,18 @@ int console_parse_key_pressed(void) { fd_set fds; tv.tv_sec = 0; tv.tv_usec = 0; - + FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); - + select(STDIN_FILENO+1, &fds, NULL, NULL, &tv); - + return FD_ISSET(STDIN_FILENO, &fds); } #endif /* _WIN32 */ /*====================================== - * CORE: Console commands + * CORE: Console commands *--------------------------------------*/ /** @@ -152,20 +152,22 @@ CPCMD_C(skip,update) { } /** - * Defines a main category - * Categories can't be used as commands! + * Defines a main category. + * + * Categories can't be used as commands! * E.G. - * sql update skip - * 'sql' is the main category + * - sql update skip + * 'sql' is the main category * CP_DEF_C(category) **/ #define CP_DEF_C(x) { #x , NULL , NULL, NULL } /** - * Defines a sub-category - * Sub-categories can't be used as commands! + * Defines a sub-category. + * + * Sub-categories can't be used as commands! * E.G. - * sql update skip - * 'update' is a sub-category + * - sql update skip + * 'update' is a sub-category * CP_DEF_C2(command, category) **/ #define CP_DEF_C2(x,y) { #x , NULL , #y, NULL } @@ -209,21 +211,21 @@ void console_load_defaults(void) { }; unsigned int i, len = ARRAYLENGTH(default_list); struct CParseEntry *cmd; - + RECREATE(console->input->cmds,struct CParseEntry *, len); - + for(i = 0; i < len; i++) { CREATE(cmd, struct CParseEntry, 1); - + safestrncpy(cmd->cmd, default_list[i].name, CP_CMD_LENGTH); - + if( default_list[i].func ) cmd->u.func = default_list[i].func; else cmd->u.next = NULL; - + cmd->next_count = 0; - + console->input->cmd_count++; console->input->cmds[i] = cmd; default_list[i].self = cmd; @@ -232,7 +234,7 @@ void console_load_defaults(void) { console->input->cmd_list[console->input->cmd_list_count - 1] = cmd; } } - + for(i = 0; i < len; i++) { unsigned int k; if( !default_list[i].connect ) @@ -256,10 +258,10 @@ void console_parse_create(char *name, CParseFunc func) { char *tok; char sublist[CP_CMD_LENGTH * 5]; struct CParseEntry *cmd; - + safestrncpy(sublist, name, CP_CMD_LENGTH * 5); tok = strtok(sublist,":"); - + for ( i = 0; i < console->input->cmd_list_count; i++ ) { if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) break; @@ -278,12 +280,11 @@ void console_parse_create(char *name, CParseFunc func) { cmd = console->input->cmd_list[i]; while( ( tok = strtok(NULL, ":") ) != NULL ) { - for(i = 0; i < cmd->next_count; i++) { if( strcmpi(cmd->u.next[i]->cmd,tok) == 0 ) break; } - + if ( i == cmd->next_count ) { RECREATE(console->input->cmds,struct CParseEntry *, ++console->input->cmd_count); CREATE(console->input->cmds[console->input->cmd_count-1], struct CParseEntry, 1); @@ -294,7 +295,6 @@ void console_parse_create(char *name, CParseFunc func) { cmd = console->input->cmds[console->input->cmd_count-1]; continue; } - } cmd->u.func = func; } @@ -320,24 +320,24 @@ void console_parse_sub(char *line) { char *tok; char sublist[CP_CMD_LENGTH * 5]; unsigned int i, len = 0; - + memcpy(bline, line, 200); tok = strtok(line, " "); - + for ( i = 0; i < console->input->cmd_list_count; i++ ) { if( strcmpi(tok,console->input->cmd_list[i]->cmd) == 0 ) break; } - + if( i == console->input->cmd_list_count ) { ShowError("'"CL_WHITE"%s"CL_RESET"' is not a known command, type '"CL_WHITE"help"CL_RESET"' to list all commands\n",line); return; } - + cmd = console->input->cmd_list[i]; - + len += snprintf(sublist,CP_CMD_LENGTH * 5,"%s", cmd->cmd) + 1; - + if( cmd->next_count == 0 && console->input->cmd_list[i]->u.func ) { char *r = NULL; if( (tok = strtok(NULL, " ")) ) { @@ -381,8 +381,8 @@ void console_parse_sub(char *line) { } } void console_parse(char* line) { - int c, i = 0, len = MAX_CONSOLE_INPUT - 1;/* we leave room for the \0 :P */ - + int c, i = 0, len = MAX_CONSOLE_INPUT - 1;/* we leave room for the \0 :P */ + while( (c = fgetc(stdin)) != EOF ) { if( --len == 0 ) break; @@ -391,33 +391,32 @@ void console_parse(char* line) { break;/* new line~! we leave it for the next cycle */ } } - + line[i++] = '\0'; } void *cThread_main(void *x) { - while( console->input->ptstate ) {/* loopx */ if( console->input->key_pressed() ) { char input[MAX_CONSOLE_INPUT]; - + console->input->parse(input); if( input[0] != '\0' ) {/* did we get something? */ EnterSpinLock(&console->input->ptlock); - + if( cinput.count == CONSOLE_PARSE_SIZE ) { LeaveSpinLock(&console->input->ptlock); continue;/* drop */ } - + safestrncpy(cinput.queue[cinput.count++],input,MAX_CONSOLE_INPUT); LeaveSpinLock(&console->input->ptlock); } } ramutex_lock( console->input->ptmutex ); - racond_wait( console->input->ptcond, console->input->ptmutex, -1 ); + racond_wait( console->input->ptcond, console->input->ptmutex, -1 ); ramutex_unlock( console->input->ptmutex ); } - + return NULL; } int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { @@ -435,7 +434,7 @@ void console_parse_final(void) { if( console->input->ptstate ) { InterlockedDecrement(&console->input->ptstate); racond_signal(console->input->ptcond); - + /* wait for thread to close */ rathread_wait(console->input->pthread, NULL); @@ -445,22 +444,21 @@ void console_parse_final(void) { } void console_parse_init(void) { cinput.count = 0; - + console->input->ptstate = 1; InitializeSpinLock(&console->input->ptlock); - + console->input->ptmutex = ramutex_create(); console->input->ptcond = racond_create(); - + if( (console->input->pthread = rathread_create(console->input->pthread_main, NULL)) == NULL ){ ShowFatalError("console_parse_init: failed to spawn console_parse thread.\n"); exit(EXIT_FAILURE); } - + timer->add_func_list(console->input->parse_timer, "console_parse_timer"); timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ - } void console_setSQL(Sql *SQL_handle) { console->input->SQL = SQL_handle; diff --git a/src/common/core.c b/src/common/core.c index 99dbc36ec..04434a5dd 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -48,14 +48,14 @@ char **arg_v = NULL; char *SERVER_NAME = NULL; -#ifndef MINICORE // minimalist Core +#ifndef MINICORE // minimalist Core // Added by Gabuzomeu // // This is an implementation of signal() using sigaction() for portability. // (sigaction() is POSIX; signal() is not.) Taken from Stevens' _Advanced // Programming in the UNIX Environment_. // -#ifdef WIN32 // windows don't have SIGPIPE +#ifdef WIN32 // windows don't have SIGPIPE #define SIGPIPE SIGINT #endif @@ -69,7 +69,7 @@ sigfunc *compat_signal(int signo, sigfunc *func) { sigemptyset(&sact.sa_mask); sact.sa_flags = 0; #ifdef SA_INTERRUPT - sact.sa_flags |= SA_INTERRUPT; /* SunOS */ + sact.sa_flags |= SA_INTERRUPT; /* SunOS */ #endif if (sigaction(signo, &sact, &oact) < 0) @@ -80,7 +80,7 @@ sigfunc *compat_signal(int signo, sigfunc *func) { #endif /*====================================== - * CORE : Console events for Windows + * CORE : Console events for Windows *--------------------------------------*/ #ifdef _WIN32 static BOOL WINAPI console_handler(DWORD c_event) { @@ -106,7 +106,7 @@ static void cevents_init(void) { #endif /*====================================== - * CORE : Signal Sub Function + * CORE : Signal Sub Function *--------------------------------------*/ static void sig_proc(int sn) { static int is_called = 0; @@ -132,11 +132,11 @@ static void sig_proc(int sn) { case SIGXFSZ: // ignore and allow it to set errno to EFBIG ShowWarning ("Max file size reached!\n"); - //run_flag = 0; // should we quit? + //run_flag = 0; // should we quit? break; case SIGPIPE: - //ShowInfo ("Broken pipe found... closing socket\n"); // set to eof in socket.c - break; // does nothing here + //ShowInfo ("Broken pipe found... closing socket\n"); // set to eof in socket.c + break; // does nothing here #endif } } @@ -185,7 +185,7 @@ void core_defaults(void) { #endif } /*====================================== - * CORE : MAINROUTINE + * CORE : MAINROUTINE *--------------------------------------*/ int main (int argc, char **argv) { int retval = EXIT_SUCCESS; @@ -209,7 +209,7 @@ int main (int argc, char **argv) { } } } - + iMalloc->init();// needed for Show* in display_title() [FlavioJS] sysinfo->init(); @@ -229,7 +229,7 @@ int main (int argc, char **argv) { rathread_init(); DB->init(); signals_init(); - + #ifdef _WIN32 cevents_init(); #endif @@ -239,11 +239,11 @@ int main (int argc, char **argv) { /* timer first */ rnd_init(); srand((unsigned int)timer->gettick()); - + console->init(); - + HCache->init(); - + HPM->init(); sockt->init(); @@ -258,7 +258,7 @@ int main (int argc, char **argv) { } console->final(); - + retval = do_final(); HPM->final(); timer->final(); diff --git a/src/common/db.c b/src/common/db.c index b227d66bc..044df19aa 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -579,7 +579,7 @@ static void db_rebalance_erase(DBNode *node, DBNode **root) x = x_parent; x_parent = x_parent->parent; } else { - if (w->right == NULL || w->right->color == BLACK) { + if (w->right == NULL || w->right->color == BLACK) { if (w->left) w->left->color = BLACK; w->color = RED; db_rotate_right(w, root); @@ -1231,7 +1231,7 @@ static void db_release_both(DBKey key, DBData data, DBRelease which) DBData* dbit_obj_first(DBIterator* self, DBKey* out_key) { DBIterator_impl* it = (DBIterator_impl*)self; - + DB_COUNTSTAT(dbit_first); // position before the first entry it->ht_index = -1; @@ -1253,7 +1253,7 @@ DBData* dbit_obj_first(DBIterator* self, DBKey* out_key) DBData* dbit_obj_last(DBIterator* self, DBKey* out_key) { DBIterator_impl* it = (DBIterator_impl*)self; - + DB_COUNTSTAT(dbit_last); // position after the last entry it->ht_index = HASH_SIZE; @@ -1375,7 +1375,6 @@ DBData* dbit_obj_prev(DBIterator* self, DBKey* out_key) node = &fake; } - while( node ) {// next node if( node->left ) @@ -1662,17 +1661,17 @@ static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max, } va_end(argscopy); } - + if (node->left) { node = node->left; continue; } - + if (node->right) { node = node->right; continue; } - + while (node) { parent = node->parent; if (parent && parent->right && parent->left == node) { @@ -1859,7 +1858,7 @@ static DBData* db_obj_ensure(DBMap* self, DBKey key, DBCreateData create, ...) * @see #db_malloc_dbn(void) * @see DBMap#put * FIXME: If this method fails shouldn't it return another value? - * Other functions rely on this to know if they were able to put something [Panikon] + * Other functions rely on this to know if they were able to put something [Panikon] */ static int db_obj_put(DBMap* self, DBKey key, DBData data, DBData *out_data) { @@ -1981,7 +1980,7 @@ static int db_obj_remove(DBMap* self, DBKey key, DBData *out_data) db->alloc_file, db->alloc_line); return 0; // nullpo candidate } - if (!(db->options&DB_OPT_ALLOW_NULL_KEY) && db_is_key_null(db->type, key)) { + if (!(db->options&DB_OPT_ALLOW_NULL_KEY) && db_is_key_null(db->type, key)) { ShowError("db_remove: Attempted to use non-allowed NULL key for db allocated at %s:%d\n",db->alloc_file, db->alloc_line); return 0; // nullpo candidate } @@ -2645,7 +2644,7 @@ DBKey db_str2key(const char *key) DBKey db_i642key(int64 key) { DBKey ret; - + DB_COUNTSTAT(db_i642key); ret.i64 = key; return ret; @@ -2660,7 +2659,7 @@ DBKey db_i642key(int64 key) DBKey db_ui642key(uint64 key) { DBKey ret; - + DB_COUNTSTAT(db_ui642key); ret.ui64 = key; return ret; diff --git a/src/common/db.h b/src/common/db.h index f500520a9..88265c3e8 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -848,7 +848,7 @@ DBKey (*i642key) (int64 key); * @public */ DBKey (*ui642key) (uint64 key); - + /** * Manual cast from 'int' to the struct DBData. * @param data Data to be casted @@ -1500,7 +1500,7 @@ void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...); VECTOR_INDEX(__heap,0) = VECTOR_POP(__heap); /* put last at index */ \ if( !VECTOR_LENGTH(__heap) ) /* removed last, nothing to do */ \ break; \ - BHEAP_SIFTUP(__heap,0,__topcmp,__swp); \ + BHEAP_SIFTUP(__heap,0,__topcmp,__swp); \ }while(0) @@ -1562,7 +1562,7 @@ void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...); /// @param __idx Index of an inserted element /// @param __topcmp Comparator /// @param __swp Swapper -#define BHEAP_SIFTDOWN(__heap,__startidx,__idx,__topcmp,__swp) \ +#define BHEAP_SIFTDOWN(__heap,__startidx,__idx,__topcmp,__swp) \ do{ \ size_t _i2_ = __idx; \ while( _i2_ > __startidx ) \ diff --git a/src/common/des.c b/src/common/des.c index 7f952be76..89a920bc9 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -103,14 +103,14 @@ static void E(BIT64* src) } #endif // optimized - tmp.b[0] = ((src->b[7]<<5) | (src->b[4]>>3)) & 0x3f; // ..0 vutsr - tmp.b[1] = ((src->b[4]<<1) | (src->b[5]>>7)) & 0x3f; // ..srqpo n - tmp.b[2] = ((src->b[4]<<5) | (src->b[5]>>3)) & 0x3f; // ..o nmlkj - tmp.b[3] = ((src->b[5]<<1) | (src->b[6]>>7)) & 0x3f; // ..kjihg f - tmp.b[4] = ((src->b[5]<<5) | (src->b[6]>>3)) & 0x3f; // ..g fedcb - tmp.b[5] = ((src->b[6]<<1) | (src->b[7]>>7)) & 0x3f; // ..cba98 7 - tmp.b[6] = ((src->b[6]<<5) | (src->b[7]>>3)) & 0x3f; // ..8 76543 - tmp.b[7] = ((src->b[7]<<1) | (src->b[4]>>7)) & 0x3f; // ..43210 v + tmp.b[0] = ((src->b[7]<<5) | (src->b[4]>>3)) & 0x3f; // ..0 vutsr + tmp.b[1] = ((src->b[4]<<1) | (src->b[5]>>7)) & 0x3f; // ..srqpo n + tmp.b[2] = ((src->b[4]<<5) | (src->b[5]>>3)) & 0x3f; // ..o nmlkj + tmp.b[3] = ((src->b[5]<<1) | (src->b[6]>>7)) & 0x3f; // ..kjihg f + tmp.b[4] = ((src->b[5]<<5) | (src->b[6]>>3)) & 0x3f; // ..g fedcb + tmp.b[5] = ((src->b[6]<<1) | (src->b[7]>>7)) & 0x3f; // ..cba98 7 + tmp.b[6] = ((src->b[6]<<5) | (src->b[7]>>3)) & 0x3f; // ..8 76543 + tmp.b[7] = ((src->b[7]<<1) | (src->b[4]>>7)) & 0x3f; // ..43210 v *src = tmp; } diff --git a/src/common/ers.c b/src/common/ers.c index c8a11d2a9..489d8f7ae 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -83,19 +83,19 @@ typedef struct ers_cache // Free objects count unsigned int Free; - + // Used blocks count unsigned int Used; - + // Objects in-use count unsigned int UsedObjs; - + // Default = ERS_BLOCK_ENTRIES, can be adjusted for performance for individual cache sizes. unsigned int ChunkSize; - + // Misc options, some options are shared from the instance enum ERSOptions Options; - + // Linked list struct ers_cache *Next, *Prev; } ers_cache_t; @@ -103,10 +103,10 @@ typedef struct ers_cache struct ers_instance_t { // Interface to ERS struct eri VTable; - + // Name, used for debugging purposes char *Name; - + // Misc options enum ERSOptions Options; @@ -115,7 +115,7 @@ struct ers_instance_t { // Count of objects in use, used for detecting memory leaks unsigned int Count; - + #ifdef DEBUG /* for data analysis [Ind/Hercules] */ unsigned int Peak; @@ -149,7 +149,7 @@ static ers_cache_t *ers_find_cache(unsigned int size, enum ERSOptions Options) { cache->Max = 0; cache->ChunkSize = ERS_BLOCK_ENTRIES; cache->Options = (Options & ERS_CACHE_OPTIONS); - + if (CacheList == NULL) { CacheList = cache; @@ -181,7 +181,7 @@ static void ers_free_cache(ers_cache_t *cache, bool remove) CacheList = cache->Next; aFree(cache->Blocks); - + aFree(cache); } @@ -216,7 +216,7 @@ static void *ers_obj_alloc_entry(ERS *self) instance->Count++; instance->Cache->UsedObjs++; - + #ifdef DEBUG if( instance->Count > instance->Peak ) instance->Peak = instance->Count; @@ -240,7 +240,7 @@ static void ers_obj_free_entry(ERS *self, void *entry) if( instance->Cache->Options & ERS_OPT_CLEAN ) memset((unsigned char*)reuse + sizeof(struct ers_list), 0, instance->Cache->ObjectSize - sizeof(struct ers_list)); - + reuse->Next = instance->Cache->ReuseList; instance->Cache->ReuseList = reuse; instance->Count--; @@ -277,27 +277,27 @@ static void ers_obj_destroy(ERS *self) if (instance->Next) instance->Next->Prev = instance->Prev; - + if (instance->Prev) instance->Prev->Next = instance->Next; else InstanceList = instance->Next; - + if( instance->Options & ERS_OPT_FREE_NAME ) aFree(instance->Name); - + aFree(instance); } void ers_cache_size(ERS *self, unsigned int new_size) { struct ers_instance_t *instance = (struct ers_instance_t *)self; - + nullpo_retv(instance); - + if( !(instance->Cache->Options&ERS_OPT_FLEX_CHUNK) ) { ShowWarning("ers_cache_size: '%s' has adjusted its chunk size to '%d', however ERS_OPT_FLEX_CHUNK is missing!\n",instance->Name,new_size); } - + instance->Cache->ChunkSize = new_size; } @@ -321,7 +321,7 @@ ERS *ers_new(uint32 size, char *name, enum ERSOptions options) instance->Options = options; instance->Cache = ers_find_cache(size,instance->Options); - + instance->Cache->ReferenceCount++; if (InstanceList == NULL) { @@ -384,7 +384,7 @@ void ers_report(void) { **/ void ers_final(void) { struct ers_instance_t *instance = InstanceList, *next; - + while( instance ) { next = instance->Next; ers_obj_destroy((ERS*)instance); diff --git a/src/common/ers.h b/src/common/ers.h index 904f7fb81..8c56118ae 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -77,7 +77,7 @@ enum ERSOptions { ERS_OPT_FREE_NAME = 0x4,/* name is dynamic memory, and should be freed */ ERS_OPT_CLEAN = 0x8,/* clears used memory upon ers_free so that its all new to be reused on the next alloc */ ERS_OPT_FLEX_CHUNK = 0x10,/* signs that it should look for its own cache given it'll have a dynamic chunk size, so that it doesn't affect the other ERS it'd otherwise be sharing */ - + /* Compound, is used to determine whether it should be looking for a cache of matching options */ ERS_CACHE_OPTIONS = ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK, }; diff --git a/src/common/grfio.c b/src/common/grfio.c index 5be0c8237..eeda7e4b5 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -21,7 +21,7 @@ #include "../common/utils.h" //---------------------------- -// file entry table struct +// file entry table struct //---------------------------- typedef struct FILELIST { int srclen; ///< compressed size @@ -50,14 +50,14 @@ typedef struct FILELIST { // stores info about every loaded file -FILELIST* filelist = NULL; -int filelist_entrys = 0; -int filelist_maxentry = 0; +FILELIST* filelist = NULL; +int filelist_entrys = 0; +int filelist_maxentry = 0; // stores grf file names -char** gentry_table = NULL; -int gentry_entrys = 0; -int gentry_maxentry = 0; +char** gentry_table = NULL; +int gentry_entrys = 0; +int gentry_maxentry = 0; // the path to the data directory char data_dir[1024] = ""; @@ -109,22 +109,23 @@ static uint8_t grf_substitution(uint8_t in) return out; } -/* this is not used anywhere, is it ok to delete? */ -//static void grf_shuffle_enc(BIT64* src) { -// BIT64 out; -// -// out.b[0] = src->b[3]; -// out.b[1] = src->b[4]; -// out.b[2] = src->b[5]; -// out.b[3] = src->b[0]; -// out.b[4] = src->b[1]; -// out.b[5] = src->b[6]; -// out.b[6] = src->b[2]; -// out.b[7] = grf_substitution(src->b[7]); -// -// *src = out; -//} +#if 0 /* this is not used anywhere, is it ok to delete? */ +static void grf_shuffle_enc(BIT64* src) +{ + BIT64 out; + out.b[0] = src->b[3]; + out.b[1] = src->b[4]; + out.b[2] = src->b[5]; + out.b[3] = src->b[0]; + out.b[4] = src->b[1]; + out.b[5] = src->b[6]; + out.b[6] = src->b[2]; + out.b[7] = grf_substitution(src->b[7]); + + *src = out; +} +#endif // 0 static void grf_shuffle_dec(BIT64* src) { @@ -425,7 +426,7 @@ void* grfio_reads(const char* fname, int* size) *size = declen; } else { if (entry != NULL && entry->gentry < 0) { - entry->gentry = -entry->gentry; // local file checked + entry->gentry = -entry->gentry; // local file checked } else { ShowError("grfio_reads: %s not found (local file: %s)\n", fname, lfname); return NULL; @@ -515,7 +516,7 @@ static int grfio_entryread(const char* grfname, int gentry) FILE* fp = fopen(grfname, "rb"); if( fp == NULL ) { ShowWarning("GRF data file not found: '%s'\n",grfname); - return 1; // 1:not found error + return 1; // 1:not found error } else ShowInfo("GRF data file found: '%s'\n",grfname); @@ -527,7 +528,7 @@ static int grfio_entryread(const char* grfname, int gentry) if( strcmp((const char*)grf_header,"Master of Magic") != 0 || fseek(fp,getlong(grf_header+0x1e),SEEK_CUR) != 0 ) { fclose(fp); ShowError("GRF %s read error\n", grfname); - return 2; // 2:file format error + return 2; // 2:file format error } grf_version = getlong(grf_header+0x2a) >> 8; @@ -565,11 +566,11 @@ static int grfio_entryread(const char* grfname, int gentry) aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e; aentry.type = type; safestrncpy(aentry.fn, fname, sizeof(aentry.fn)); - aentry.fnd = NULL; -#ifdef GRFIO_LOCAL - aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck + aentry.fnd = NULL; +#ifdef GRFIO_LOCAL + aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck #else - aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck + aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck #endif filelist_modify(&aentry); } @@ -584,8 +585,8 @@ static int grfio_entryread(const char* grfname, int gentry) uLongf rSize, eSize; if(fread(eheader,1,8,fp) != 8) ShowError("An error occurred in fread while reading header buffer\n"); - rSize = getlong(eheader); // Read Size - eSize = getlong(eheader+4); // Extend Size + rSize = getlong(eheader); // Read Size + eSize = getlong(eheader+4); // Extend Size if( (long)rSize > grf_size-ftell(fp) ) { fclose(fp); @@ -593,11 +594,11 @@ static int grfio_entryread(const char* grfname, int gentry) return 4; } - rBuf = (unsigned char *)aMalloc(rSize); // Get a Read Size - grf_filelist = (unsigned char *)aMalloc(eSize); // Get a Extend Size + rBuf = (unsigned char *)aMalloc(rSize); // Get a Read Size + grf_filelist = (unsigned char *)aMalloc(eSize); // Get a Extend Size if(fread(rBuf,1,rSize,fp) != rSize) ShowError("An error occurred in fread \n"); fclose(fp); - decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function + decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function aFree(rBuf); entrys = getlong(grf_header+0x26) - 7; @@ -623,11 +624,11 @@ static int grfio_entryread(const char* grfname, int gentry) aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e; aentry.type = (char)type; safestrncpy(aentry.fn, fname, sizeof(aentry.fn)); - aentry.fnd = NULL; -#ifdef GRFIO_LOCAL - aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck + aentry.fnd = NULL; +#ifdef GRFIO_LOCAL + aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck #else - aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck + aentry.gentry = (char)(gentry+1); // With no first time LocalFileCheck #endif filelist_modify(&aentry); } @@ -642,9 +643,9 @@ static int grfio_entryread(const char* grfname, int gentry) return 4; } - filelist_compact(); // Unnecessary area release of filelist + filelist_compact(); // Unnecessary area release of filelist - return 0; // 0:no error + return 0; // 0:no error } @@ -714,7 +715,7 @@ static void grfio_resourcecheck(void) fclose(fp); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, "resnametable.txt"); - return; // we're done here! + return; // we're done here! } // read resnametable from loaded GRF's, only if it cannot be loaded from the data directory @@ -745,12 +746,12 @@ static void grfio_resourcecheck(void) /// Reads a grf file and adds it to the list. static int grfio_add(const char* fname) { - if( gentry_entrys >= gentry_maxentry ) - { - #define GENTRY_ADDS 4 // The number increment of gentry_table entries + if (gentry_entrys >= gentry_maxentry) { +#define GENTRY_ADDS 4 // The number increment of gentry_table entries gentry_maxentry += GENTRY_ADDS; gentry_table = (char**)aRealloc(gentry_table, gentry_maxentry * sizeof(char*)); memset(gentry_table + (gentry_maxentry - GENTRY_ADDS), 0, sizeof(char*) * GENTRY_ADDS); +#undef GENTRY_ADDS } gentry_table[gentry_entrys++] = aStrdup(fname); @@ -792,7 +793,7 @@ void grfio_init(const char* fname) FILE* data_conf; int grf_num = 0; - hashinit(); // hash table initialization + hashinit(); // hash table initialization data_conf = fopen(fname, "r"); if( data_conf != NULL ) diff --git a/src/common/malloc.c b/src/common/malloc.c index eae9ad423..625875b76 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -143,7 +143,7 @@ void aFree_(void *p, const char *file, int line, const char *func) * Since the complex processing, I might be slightly heavier. * * (I'm sorry for the poor description ^ ^;) such as data structures -* Divided into "blocks" of a plurality of memory, "unit" of a plurality of blocks further +* Divided into "blocks" of a plurality of memory, "unit" of a plurality of blocks further * I have to divide. Size of the unit, a plurality of distribution equal to the capacity of one block * That's what you have. For example, if one unit of 32KB, one block 1 Yu 32Byte * Knit, or are able to gather 1024, gathered 512 units 64Byte @@ -155,33 +155,33 @@ void aFree_(void *p, const char *file, int line, const char *func) */ /* Alignment of the block */ -#define BLOCK_ALIGNMENT1 16 -#define BLOCK_ALIGNMENT2 64 +#define BLOCK_ALIGNMENT1 16 +#define BLOCK_ALIGNMENT2 64 /* Amount of data entering a block */ -#define BLOCK_DATA_COUNT1 128 -#define BLOCK_DATA_COUNT2 608 +#define BLOCK_DATA_COUNT1 128 +#define BLOCK_DATA_COUNT2 608 /* The size of the block: 16*128 + 64*576 = 40KB */ -#define BLOCK_DATA_SIZE1 ( BLOCK_ALIGNMENT1 * BLOCK_DATA_COUNT1 ) -#define BLOCK_DATA_SIZE2 ( BLOCK_ALIGNMENT2 * BLOCK_DATA_COUNT2 ) -#define BLOCK_DATA_SIZE ( BLOCK_DATA_SIZE1 + BLOCK_DATA_SIZE2 ) +#define BLOCK_DATA_SIZE1 ( BLOCK_ALIGNMENT1 * BLOCK_DATA_COUNT1 ) +#define BLOCK_DATA_SIZE2 ( BLOCK_ALIGNMENT2 * BLOCK_DATA_COUNT2 ) +#define BLOCK_DATA_SIZE ( BLOCK_DATA_SIZE1 + BLOCK_DATA_SIZE2 ) /* The number of blocks to be allocated at a time. */ -#define BLOCK_ALLOC 104 +#define BLOCK_ALLOC 104 /* block */ struct block { - struct block* block_next; /* Then the allocated area */ - struct block* unfill_prev; /* The previous area not filled */ - struct block* unfill_next; /* The next area not filled */ - unsigned short unit_size; /* The size of the unit */ - unsigned short unit_hash; /* The hash of the unit */ - unsigned short unit_count; /* The number of units */ - unsigned short unit_used; /* The number of used units */ - unsigned short unit_unfill; /* The number of unused units */ - unsigned short unit_maxused; /* The maximum value of units used */ - char data[ BLOCK_DATA_SIZE ]; + struct block *block_next; ///< Then the allocated area + struct block *unfill_prev; ///< The previous area not filled + struct block *unfill_next; ///< The next area not filled + unsigned short unit_size; ///< The size of the unit + unsigned short unit_hash; ///< The hash of the unit + unsigned short unit_count; ///< The number of units + unsigned short unit_used; ///< The number of used units + unsigned short unit_unfill; ///< The number of unused units + unsigned short unit_maxused; ///< The maximum value of units used + char data[BLOCK_DATA_SIZE]; }; struct unit_head { @@ -222,7 +222,7 @@ static unsigned short size2hash( size_t size ) return (unsigned short)(size - BLOCK_DATA_SIZE1 + BLOCK_ALIGNMENT2 - 1) / BLOCK_ALIGNMENT2 + BLOCK_DATA_COUNT1; } else { - return 0xffff; // If it exceeds the block length hash I do not + return 0xffff; // If it exceeds the block length hash I do not } } @@ -375,13 +375,13 @@ void *mrealloc_(void *memblock, size_t size, const char *file, int line, const c void *mreallocz_(void *memblock, size_t size, const char *file, int line, const char *func) { size_t old_size; void *p = NULL; - + if(memblock == NULL) { p = iMalloc->malloc(size,file,line,func); memset(p,0,size); return p; } - + old_size = ((struct unit_head *)((char *)memblock - sizeof(struct unit_head) + sizeof(long)))->size; if( old_size == 0 ) { old_size = ((struct unit_head_large *)((char *)memblock - sizeof(struct unit_head_large) + sizeof(long)))->size; @@ -702,7 +702,7 @@ void memmgr_report (int extra) { unsigned int count; } data[100]; memset(&data, 0, sizeof(data)); - + if( extra != 0 ) msize = extra; @@ -732,7 +732,7 @@ void memmgr_report (int extra) { } block = block->block_next; } - + while(large) { if( large->size > msize ) { for( j = 0; j < 100; j++ ) { @@ -760,7 +760,7 @@ void memmgr_report (int extra) { } ShowMessage("[malloc] : reporting %u instances | %.2f MB\n",count,(double)((size)/1024)/1024); ShowMessage("[malloc] : internal usage %.2f MB | %.2f MB\n",(double)((memmgr_usage_bytes_t-memmgr_usage_bytes)/1024)/1024,(double)((memmgr_usage_bytes_t)/1024)/1024); - + if (extra) { ShowMessage("[malloc] : unit_head_large: %"PRIuS" bytes\n", sizeof(struct unit_head_large)); ShowMessage("[malloc] : unit_head: %"PRIuS" bytes\n", sizeof(struct unit_head)); @@ -848,19 +848,19 @@ void malloc_defaults(void) { // Athena's built-in Memory Manager #ifdef USE_MEMMGR - iMalloc->malloc = mmalloc_; - iMalloc->calloc = mcalloc_; - iMalloc->realloc = mrealloc_; - iMalloc->reallocz= mreallocz_; - iMalloc->astrdup = mstrdup_; - iMalloc->free = mfree_; + iMalloc->malloc = mmalloc_; + iMalloc->calloc = mcalloc_; + iMalloc->realloc = mrealloc_; + iMalloc->reallocz = mreallocz_; + iMalloc->astrdup = mstrdup_; + iMalloc->free = mfree_; #else - iMalloc->malloc = aMalloc_; - iMalloc->calloc = aCalloc_; - iMalloc->realloc = aRealloc_; - iMalloc->reallocz= aRealloc_;/* not using memory manager huhum o.o perhaps we could still do something about */ - iMalloc->astrdup = aStrdup_; - iMalloc->free = aFree_; + iMalloc->malloc = aMalloc_; + iMalloc->calloc = aCalloc_; + iMalloc->realloc = aRealloc_; + iMalloc->reallocz = aRealloc_;/* not using memory manager huhum o.o perhaps we could still do something about */ + iMalloc->astrdup = aStrdup_; + iMalloc->free = aFree_; #endif iMalloc->post_shutdown = NULL; } diff --git a/src/common/malloc.h b/src/common/malloc.h index 8dace2d68..53d2ebdd2 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -68,19 +68,19 @@ void malloc_defaults(void); struct malloc_interface { - void (*init) (void); - void (*final) (void); + void (*init) (void); + void (*final) (void); /* */ - void* (*malloc )(size_t size, const char *file, int line, const char *func); - void* (*calloc )(size_t num, size_t size, const char *file, int line, const char *func); - void* (*realloc )(void *p, size_t size, const char *file, int line, const char *func); + void* (*malloc)(size_t size, const char *file, int line, const char *func); + void* (*calloc)(size_t num, size_t size, const char *file, int line, const char *func); + void* (*realloc)(void *p, size_t size, const char *file, int line, const char *func); void* (*reallocz)(void *p, size_t size, const char *file, int line, const char *func); - char* (*astrdup )(const char *p, const char *file, int line, const char *func); - void (*free )(void *p, const char *file, int line, const char *func); + char* (*astrdup)(const char *p, const char *file, int line, const char *func); + void (*free)(void *p, const char *file, int line, const char *func); /* */ - void (*memory_check)(void); - bool (*verify_ptr)(void* ptr); - size_t (*usage) (void); + void (*memory_check)(void); + bool (*verify_ptr)(void* ptr); + size_t (*usage) (void); /* */ void (*post_shutdown) (void); }; diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 0873b3e59..ec829ee56 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -24,7 +24,7 @@ struct mapindex_interface mapindex_s; const char* mapindex_getmapname(const char* string, char* output) { static char buf[MAP_NAME_LENGTH]; char* dest = (output != NULL) ? output : buf; - + size_t len = strnlen(string, MAP_NAME_LENGTH_EXT); if (len == MAP_NAME_LENGTH_EXT) { ShowWarning("(mapindex_normalize_name) Map name '%*s' is too long!\n", 2*MAP_NAME_LENGTH_EXT, string); @@ -32,11 +32,11 @@ const char* mapindex_getmapname(const char* string, char* output) { } if (len >= 4 && stricmp(&string[len-4], ".gat") == 0) len -= 4; // strip .gat extension - + len = min(len, MAP_NAME_LENGTH-1); safestrncpy(dest, string, len+1); memset(&dest[len], '\0', MAP_NAME_LENGTH-len); - + return dest; } @@ -65,7 +65,7 @@ const char* mapindex_getmapname_ext(const char* string, char* output) { } memset(&dest[len], '\0', MAP_NAME_LENGTH_EXT-len); - + return dest; } @@ -105,7 +105,7 @@ int mapindex_addmap(int index, const char* name) { safestrncpy(mapindex->list[index].name, map_name, MAP_NAME_LENGTH); strdb_iput(mapindex->db, map_name, index); - + if (mapindex->num <= index) mapindex->num = index+1; @@ -115,12 +115,12 @@ int mapindex_addmap(int index, const char* name) { unsigned short mapindex_name2id(const char* name) { int i; char map_name[MAP_NAME_LENGTH]; - + mapindex->getmapname(name, map_name); if( (i = strdb_iget(mapindex->db, map_name)) ) return i; - + ShowDebug("mapindex_name2id: Map \"%s\" not found in index list!\n", map_name); return 0; } @@ -139,14 +139,14 @@ int mapindex_init(void) { int last_index = -1; int index, total = 0; char map_name[13]; - + if( ( fp = fopen(mapindex->config_file,"r") ) == NULL ){ ShowFatalError("Unable to read mapindex config file %s!\n", mapindex->config_file); exit(EXIT_FAILURE); //Server can't really run without this file. } mapindex->db = strdb_alloc(DB_OPT_DUP_KEY, MAP_NAME_LENGTH); - + while(fgets(line, sizeof(line), fp)) { if(line[0] == '/' && line[1] == '/') continue; @@ -168,7 +168,7 @@ int mapindex_init(void) { if( !strdb_iget(mapindex->db, MAP_DEFAULT) ) { ShowError("mapindex_init: MAP_DEFAULT '%s' not found in cache! update mapindex.h MAP_DEFAULT var!!!\n",MAP_DEFAULT); } - + return total; } @@ -183,14 +183,14 @@ void mapindex_final(void) { void mapindex_defaults(void) { mapindex = &mapindex_s; - + /* TODO: place it in inter-server.conf? */ snprintf(mapindex->config_file, 80, "%s","db/map_index.txt"); /* */ mapindex->db = NULL; mapindex->num = 0; memset (&mapindex->list, 0, sizeof (mapindex->list)); - + /* */ mapindex->init = mapindex_init; mapindex->final = mapindex_final; diff --git a/src/common/md5calc.c b/src/common/md5calc.c index e7b506e27..18e502da2 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -25,22 +25,22 @@ static unsigned int *pX; // String Table static const unsigned int T[] = { - 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0 - 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4 - 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, //8 - 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, //12 - 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, //16 - 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8, //20 - 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, //24 - 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, //28 - 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, //32 - 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, //36 - 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, //40 - 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, //44 - 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, //48 - 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, //52 - 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, //56 - 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 //60 + 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0 + 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4 + 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, //8 + 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, //12 + 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, //16 + 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8, //20 + 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, //24 + 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, //28 + 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, //32 + 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, //36 + 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, //40 + 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, //44 + 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, //48 + 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, //52 + 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, //56 + 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391 //60 }; // ROTATE_LEFT The left is made to rotate x [ n-bit ]. This is diverted as it is from RFC. @@ -49,25 +49,25 @@ static const unsigned int T[] = { // The function used for other calculation static unsigned int F(unsigned int X, unsigned int Y, unsigned int Z) { - return (X & Y) | (~X & Z); + return (X & Y) | (~X & Z); } static unsigned int G(unsigned int X, unsigned int Y, unsigned int Z) { - return (X & Z) | (Y & ~Z); + return (X & Z) | (Y & ~Z); } static unsigned int H(unsigned int X, unsigned int Y, unsigned int Z) { - return X ^ Y ^ Z; + return X ^ Y ^ Z; } static unsigned int I(unsigned int X, unsigned int Y, unsigned int Z) { - return Y ^ (X | ~Z); + return Y ^ (X | ~Z); } static unsigned int Round(unsigned int a, unsigned int b, unsigned int FGHI, - unsigned int k, unsigned int s, unsigned int i) + unsigned int k, unsigned int s, unsigned int i) { - return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s); + return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s); } static void Round1(unsigned int *a, unsigned int b, unsigned int c, @@ -113,103 +113,103 @@ static void MD5_Round_Calculate(const unsigned char *block, | ( ((unsigned int )block[j+3]) << 24 ); - //Round 1 - Round1(&A,B,C,D, 0, 7, 0); Round1(&D,A,B,C, 1, 12, 1); Round1(&C,D,A,B, 2, 17, 2); Round1(&B,C,D,A, 3, 22, 3); - Round1(&A,B,C,D, 4, 7, 4); Round1(&D,A,B,C, 5, 12, 5); Round1(&C,D,A,B, 6, 17, 6); Round1(&B,C,D,A, 7, 22, 7); - Round1(&A,B,C,D, 8, 7, 8); Round1(&D,A,B,C, 9, 12, 9); Round1(&C,D,A,B, 10, 17, 10); Round1(&B,C,D,A, 11, 22, 11); - Round1(&A,B,C,D, 12, 7, 12); Round1(&D,A,B,C, 13, 12, 13); Round1(&C,D,A,B, 14, 17, 14); Round1(&B,C,D,A, 15, 22, 15); - - //Round 2 - Round2(&A,B,C,D, 1, 5, 16); Round2(&D,A,B,C, 6, 9, 17); Round2(&C,D,A,B, 11, 14, 18); Round2(&B,C,D,A, 0, 20, 19); - Round2(&A,B,C,D, 5, 5, 20); Round2(&D,A,B,C, 10, 9, 21); Round2(&C,D,A,B, 15, 14, 22); Round2(&B,C,D,A, 4, 20, 23); - Round2(&A,B,C,D, 9, 5, 24); Round2(&D,A,B,C, 14, 9, 25); Round2(&C,D,A,B, 3, 14, 26); Round2(&B,C,D,A, 8, 20, 27); - Round2(&A,B,C,D, 13, 5, 28); Round2(&D,A,B,C, 2, 9, 29); Round2(&C,D,A,B, 7, 14, 30); Round2(&B,C,D,A, 12, 20, 31); - - //Round 3 - Round3(&A,B,C,D, 5, 4, 32); Round3(&D,A,B,C, 8, 11, 33); Round3(&C,D,A,B, 11, 16, 34); Round3(&B,C,D,A, 14, 23, 35); - Round3(&A,B,C,D, 1, 4, 36); Round3(&D,A,B,C, 4, 11, 37); Round3(&C,D,A,B, 7, 16, 38); Round3(&B,C,D,A, 10, 23, 39); - Round3(&A,B,C,D, 13, 4, 40); Round3(&D,A,B,C, 0, 11, 41); Round3(&C,D,A,B, 3, 16, 42); Round3(&B,C,D,A, 6, 23, 43); - Round3(&A,B,C,D, 9, 4, 44); Round3(&D,A,B,C, 12, 11, 45); Round3(&C,D,A,B, 15, 16, 46); Round3(&B,C,D,A, 2, 23, 47); - - //Round 4 - Round4(&A,B,C,D, 0, 6, 48); Round4(&D,A,B,C, 7, 10, 49); Round4(&C,D,A,B, 14, 15, 50); Round4(&B,C,D,A, 5, 21, 51); - Round4(&A,B,C,D, 12, 6, 52); Round4(&D,A,B,C, 3, 10, 53); Round4(&C,D,A,B, 10, 15, 54); Round4(&B,C,D,A, 1, 21, 55); - Round4(&A,B,C,D, 8, 6, 56); Round4(&D,A,B,C, 15, 10, 57); Round4(&C,D,A,B, 6, 15, 58); Round4(&B,C,D,A, 13, 21, 59); - Round4(&A,B,C,D, 4, 6, 60); Round4(&D,A,B,C, 11, 10, 61); Round4(&C,D,A,B, 2, 15, 62); Round4(&B,C,D,A, 9, 21, 63); - - // Then perform the following additions. (let's add) - *A2 = A + AA; - *B2 = B + BB; - *C2 = C + CC; - *D2 = D + DD; - - //The clearance of confidential information - memset(pX, 0, sizeof(X)); + //Round 1 + Round1(&A,B,C,D, 0, 7, 0); Round1(&D,A,B,C, 1, 12, 1); Round1(&C,D,A,B, 2, 17, 2); Round1(&B,C,D,A, 3, 22, 3); + Round1(&A,B,C,D, 4, 7, 4); Round1(&D,A,B,C, 5, 12, 5); Round1(&C,D,A,B, 6, 17, 6); Round1(&B,C,D,A, 7, 22, 7); + Round1(&A,B,C,D, 8, 7, 8); Round1(&D,A,B,C, 9, 12, 9); Round1(&C,D,A,B, 10, 17, 10); Round1(&B,C,D,A, 11, 22, 11); + Round1(&A,B,C,D, 12, 7, 12); Round1(&D,A,B,C, 13, 12, 13); Round1(&C,D,A,B, 14, 17, 14); Round1(&B,C,D,A, 15, 22, 15); + + //Round 2 + Round2(&A,B,C,D, 1, 5, 16); Round2(&D,A,B,C, 6, 9, 17); Round2(&C,D,A,B, 11, 14, 18); Round2(&B,C,D,A, 0, 20, 19); + Round2(&A,B,C,D, 5, 5, 20); Round2(&D,A,B,C, 10, 9, 21); Round2(&C,D,A,B, 15, 14, 22); Round2(&B,C,D,A, 4, 20, 23); + Round2(&A,B,C,D, 9, 5, 24); Round2(&D,A,B,C, 14, 9, 25); Round2(&C,D,A,B, 3, 14, 26); Round2(&B,C,D,A, 8, 20, 27); + Round2(&A,B,C,D, 13, 5, 28); Round2(&D,A,B,C, 2, 9, 29); Round2(&C,D,A,B, 7, 14, 30); Round2(&B,C,D,A, 12, 20, 31); + + //Round 3 + Round3(&A,B,C,D, 5, 4, 32); Round3(&D,A,B,C, 8, 11, 33); Round3(&C,D,A,B, 11, 16, 34); Round3(&B,C,D,A, 14, 23, 35); + Round3(&A,B,C,D, 1, 4, 36); Round3(&D,A,B,C, 4, 11, 37); Round3(&C,D,A,B, 7, 16, 38); Round3(&B,C,D,A, 10, 23, 39); + Round3(&A,B,C,D, 13, 4, 40); Round3(&D,A,B,C, 0, 11, 41); Round3(&C,D,A,B, 3, 16, 42); Round3(&B,C,D,A, 6, 23, 43); + Round3(&A,B,C,D, 9, 4, 44); Round3(&D,A,B,C, 12, 11, 45); Round3(&C,D,A,B, 15, 16, 46); Round3(&B,C,D,A, 2, 23, 47); + + //Round 4 + Round4(&A,B,C,D, 0, 6, 48); Round4(&D,A,B,C, 7, 10, 49); Round4(&C,D,A,B, 14, 15, 50); Round4(&B,C,D,A, 5, 21, 51); + Round4(&A,B,C,D, 12, 6, 52); Round4(&D,A,B,C, 3, 10, 53); Round4(&C,D,A,B, 10, 15, 54); Round4(&B,C,D,A, 1, 21, 55); + Round4(&A,B,C,D, 8, 6, 56); Round4(&D,A,B,C, 15, 10, 57); Round4(&C,D,A,B, 6, 15, 58); Round4(&B,C,D,A, 13, 21, 59); + Round4(&A,B,C,D, 4, 6, 60); Round4(&D,A,B,C, 11, 10, 61); Round4(&C,D,A,B, 2, 15, 62); Round4(&B,C,D,A, 9, 21, 63); + + // Then perform the following additions. (let's add) + *A2 = A + AA; + *B2 = B + BB; + *C2 = C + CC; + *D2 = D + DD; + + //The clearance of confidential information + memset(pX, 0, sizeof(X)); } static void MD5_String2binary(const char * string, unsigned char * output) { //var - /*8bit*/ - unsigned char padding_message[64]; //Extended message 512bit 64byte - unsigned char *pstring; //The position of string in the present scanning notes is held. - - /*32bit*/ - unsigned int string_byte_len, //The byte chief of string is held. - string_bit_len, //The bit length of string is held. - copy_len, //The number of bytes which is used by 1-3 and which remained - msg_digest[4]; //Message digest 128bit 4byte - unsigned int *A = &msg_digest[0], //The message digest in accordance with RFC (reference) - *B = &msg_digest[1], - *C = &msg_digest[2], - *D = &msg_digest[3]; + /*8bit*/ + unsigned char padding_message[64]; //Extended message 512bit 64byte + unsigned char *pstring; //The position of string in the present scanning notes is held. + + /*32bit*/ + unsigned int string_byte_len, //The byte chief of string is held. + string_bit_len, //The bit length of string is held. + copy_len, //The number of bytes which is used by 1-3 and which remained + msg_digest[4]; //Message digest 128bit 4byte + unsigned int *A = &msg_digest[0], //The message digest in accordance with RFC (reference) + *B = &msg_digest[1], + *C = &msg_digest[2], + *D = &msg_digest[3]; int i; //prog - //Step 3.Initialize MD Buffer (although it is the initialization; step 3 of A, B, C, and D -- unavoidable -- a head) - *A = 0x67452301; - *B = 0xefcdab89; - *C = 0x98badcfe; - *D = 0x10325476; - - //Step 1.Append Padding Bits (extension of a mark bit) - //1-1 - string_byte_len = (unsigned int)strlen(string); //The byte chief of a character sequence is acquired. - pstring = (unsigned char *)string; //The position of the present character sequence is set. - - //1-2 Repeat calculation until length becomes less than 64 bytes. - for (i=string_byte_len; 64<=i; i-=64,pstring+=64) - MD5_Round_Calculate(pstring, A,B,C,D); - - //1-3 - copy_len = string_byte_len % 64; //The number of bytes which remained is computed. - strncpy((char *)padding_message, (char *)pstring, copy_len); //A message is copied to an extended bit sequence. - memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length. - padding_message[copy_len] |= 0x80; //The next of a message is 1. - - //1-4 - //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes. - if (56 <= copy_len) { - MD5_Round_Calculate(padding_message, A,B,C,D); - memset(padding_message, 0, 56); //56 bytes is newly fill uped with 0. - } - - //Step 2.Append Length (the information on length is added) - string_bit_len = string_byte_len * 8; //From the byte chief to bit length (32 bytes of low rank) - memcpy(&padding_message[56], &string_bit_len, 4); //32 bytes of low rank is set. - - //When bit length cannot be expressed in 32 bytes of low rank, it is a beam raising to a higher rank. - if (UINT_MAX / 8 < string_byte_len) { - unsigned int high = (string_byte_len - UINT_MAX / 8) * 8; - memcpy(&padding_message[60], &high, 4); - } else - memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0. - - //Step 4.Process Message in 16-Word Blocks (calculation of MD5) - MD5_Round_Calculate(padding_message, A,B,C,D); - - //Step 5.Output (output) - memcpy(output,msg_digest,16); + //Step 3.Initialize MD Buffer (although it is the initialization; step 3 of A, B, C, and D -- unavoidable -- a head) + *A = 0x67452301; + *B = 0xefcdab89; + *C = 0x98badcfe; + *D = 0x10325476; + + //Step 1.Append Padding Bits (extension of a mark bit) + //1-1 + string_byte_len = (unsigned int)strlen(string); //The byte chief of a character sequence is acquired. + pstring = (unsigned char *)string; //The position of the present character sequence is set. + + //1-2 Repeat calculation until length becomes less than 64 bytes. + for (i=string_byte_len; 64<=i; i-=64,pstring+=64) + MD5_Round_Calculate(pstring, A,B,C,D); + + //1-3 + copy_len = string_byte_len % 64; //The number of bytes which remained is computed. + strncpy((char *)padding_message, (char *)pstring, copy_len); //A message is copied to an extended bit sequence. + memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length. + padding_message[copy_len] |= 0x80; //The next of a message is 1. + + //1-4 + //If 56 bytes or more (less than 64 bytes) of remainder becomes, it will calculate by extending to 64 bytes. + if (56 <= copy_len) { + MD5_Round_Calculate(padding_message, A,B,C,D); + memset(padding_message, 0, 56); //56 bytes is newly fill uped with 0. + } + + //Step 2.Append Length (the information on length is added) + string_bit_len = string_byte_len * 8; //From the byte chief to bit length (32 bytes of low rank) + memcpy(&padding_message[56], &string_bit_len, 4); //32 bytes of low rank is set. + + //When bit length cannot be expressed in 32 bytes of low rank, it is a beam raising to a higher rank. + if (UINT_MAX / 8 < string_byte_len) { + unsigned int high = (string_byte_len - UINT_MAX / 8) * 8; + memcpy(&padding_message[60], &high, 4); + } else + memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0. + + //Step 4.Process Message in 16-Word Blocks (calculation of MD5) + MD5_Round_Calculate(padding_message, A,B,C,D); + + //Step 5.Output (output) + memcpy(output,msg_digest,16); } //------------------------------------------------------------------- @@ -227,7 +227,7 @@ void MD5_String(const char * string, char * output) unsigned char digest[16]; MD5_String2binary(string,digest); - sprintf(output, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + sprintf(output, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", digest[ 0], digest[ 1], digest[ 2], digest[ 3], digest[ 4], digest[ 5], digest[ 6], digest[ 7], digest[ 8], digest[ 9], digest[10], digest[11], diff --git a/src/common/mmo.h b/src/common/mmo.h index 597b25126..fd054ba91 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -73,14 +73,14 @@ #define HOTKEY_SAVING #if PACKETVER < 20090603 - // (27 = 9 skills x 3 bars) (0x02b9,191) - #define MAX_HOTKEYS 27 + // (27 = 9 skills x 3 bars) (0x02b9,191) + #define MAX_HOTKEYS 27 #elif PACKETVER < 20090617 - // (36 = 9 skills x 4 bars) (0x07d9,254) - #define MAX_HOTKEYS 36 + // (36 = 9 skills x 4 bars) (0x07d9,254) + #define MAX_HOTKEYS 36 #else // >= 20090617 - // (38 = 9 skills x 4 bars & 2 Quickslots)(0x07d9,268) - #define MAX_HOTKEYS 38 + // (38 = 9 skills x 4 bars & 2 Quickslots)(0x07d9,268) + #define MAX_HOTKEYS 38 #endif // 20090603 #endif // 20070227 @@ -469,7 +469,7 @@ struct mmo_charstatus { /* `account_data` modifiers */ unsigned short mod_exp,mod_drop,mod_death; - + unsigned char font; uint32 uniqueitem_counter; @@ -593,15 +593,15 @@ struct guild { struct guild_alliance alliance[MAX_GUILDALLIANCE]; struct guild_expulsion expulsion[MAX_GUILDEXPULSION]; struct guild_skill skill[MAX_GUILDSKILL]; - + /* used on char.c to state what kind of data is being saved/processed */ unsigned short save_flag; - + short *instance; unsigned short instances; - + struct hChSysCh *channel; - + /* HPM Custom Struct */ struct HPluginData **hdata; unsigned int hdatac; diff --git a/src/common/mutex.c b/src/common/mutex.c index f046febf6..31202d440 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -52,19 +52,19 @@ struct racond{ ramutex *ramutex_create(void) { struct ramutex *m; - + m = (struct ramutex*)aMalloc( sizeof(struct ramutex) ); if (m == NULL) { ShowFatalError("ramutex_create: OOM while allocating %"PRIuS" bytes.\n", sizeof(struct ramutex)); return NULL; } - + #ifdef WIN32 InitializeCriticalSection(&m->hMutex); #else pthread_mutex_init(&m->hMutex, NULL); #endif - + return m; }//end: ramutex_create() @@ -101,7 +101,7 @@ bool ramutex_trylock(ramutex *m) { #else if(pthread_mutex_trylock(&m->hMutex) == 0) return true; - + return false; #endif }//end: ramutex_trylock() @@ -126,7 +126,7 @@ void ramutex_unlock(ramutex *m) { racond *racond_create(void) { struct racond *c; - + c = (struct racond*)aMalloc( sizeof(struct racond) ); if (c == NULL) { ShowFatalError("racond_create: OOM while allocating %"PRIuS" bytes\n", sizeof(struct racond)); @@ -135,13 +135,13 @@ racond *racond_create(void) { #ifdef WIN32 c->nWaiters = 0; - c->events[ EVENT_COND_SIGNAL ] = CreateEvent( NULL, FALSE, FALSE, NULL ); - c->events[ EVENT_COND_BROADCAST ] = CreateEvent( NULL, TRUE, FALSE, NULL ); + c->events[EVENT_COND_SIGNAL] = CreateEvent(NULL, FALSE, FALSE, NULL); + c->events[EVENT_COND_BROADCAST] = CreateEvent(NULL, TRUE, FALSE, NULL); InitializeCriticalSection( &c->waiters_lock ); #else pthread_cond_init(&c->hCond, NULL); #endif - + return c; }//end: racond_create() @@ -174,24 +174,20 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) { ms = INFINITE; else ms = (timeout_ticks > MAXDWORD) ? (MAXDWORD - 1) : (DWORD)timeout_ticks; - - + // we can release the mutex (m) here, cause win's // manual reset events maintain state when used with // SetEvent() ramutex_unlock(m); result = WaitForMultipleObjects(2, c->events, FALSE, ms); - - + EnterCriticalSection(&c->waiters_lock); c->nWaiters--; if( (result == WAIT_OBJECT_0 + EVENT_COND_BROADCAST) && (c->nWaiters == 0) ) is_last = true; // Broadcast called! LeaveCriticalSection(&c->waiters_lock); - - // we are the last waiter that has to be notified, or to stop waiting // so we have to do a manual reset if(is_last == true) @@ -206,10 +202,10 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) { }else{ struct timespec wtime; int64 exact_timeout = timer->gettick() + timeout_ticks; - + wtime.tv_sec = exact_timeout/1000; wtime.tv_nsec = (exact_timeout%1000)*1000000; - + pthread_cond_timedwait( &c->hCond, &m->hMutex, &wtime); } @@ -219,13 +215,15 @@ void racond_wait(racond *c, ramutex *m, sysint timeout_ticks) { void racond_signal(racond *c) { #ifdef WIN32 -// bool has_waiters = false; -// EnterCriticalSection(&c->waiters_lock); -// if(c->nWaiters > 0) -// has_waiters = true; -// LeaveCriticalSection(&c->waiters_lock); - -// if(has_waiters == true) +# if 0 + bool has_waiters = false; + EnterCriticalSection(&c->waiters_lock); + if(c->nWaiters > 0) + has_waiters = true; + LeaveCriticalSection(&c->waiters_lock); + + if(has_waiters == true) +# endif // 0 SetEvent( c->events[ EVENT_COND_SIGNAL ] ); #else pthread_cond_signal(&c->hCond); @@ -235,13 +233,15 @@ void racond_signal(racond *c) { void racond_broadcast(racond *c) { #ifdef WIN32 -// bool has_waiters = false; -// EnterCriticalSection(&c->waiters_lock); -// if(c->nWaiters > 0) -// has_waiters = true; -// LeaveCriticalSection(&c->waiters_lock); - -// if(has_waiters == true) +# if 0 + bool has_waiters = false; + EnterCriticalSection(&c->waiters_lock); + if(c->nWaiters > 0) + has_waiters = true; + LeaveCriticalSection(&c->waiters_lock); + + if(has_waiters == true) +# endif // 0 SetEvent( c->events[ EVENT_COND_BROADCAST ] ); #else pthread_cond_broadcast(&c->hCond); diff --git a/src/common/nullpo.c b/src/common/nullpo.c index a3471b00d..0333c02ef 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -24,10 +24,10 @@ void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) { if (file == NULL) file = "??"; - + if (func == NULL || *func == '\0') func = "unknown"; - + ShowError("--- %s --------------------------------------------\n", title); ShowError("%s:%d: '%s' in function `%s'\n", file, line, targetname, func); ShowError("--- end %s ----------------------------------------\n", title); diff --git a/src/common/showmsg.c b/src/common/showmsg.c index f3982d364..0dd645eeb 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -93,20 +93,20 @@ int console_msg_log = 0;//[Ind] msg error logging // // \033[#;...;#m - Set Graphics Rendition (SGR) // -// printf("\x1b[1;31;40m"); // Bright red on black -// printf("\x1b[3;33;45m"); // Blinking yellow on magenta (blink not implemented) -// printf("\x1b[1;30;47m"); // Bright black (grey) on dim white +// printf("\x1b[1;31;40m"); // Bright red on black +// printf("\x1b[3;33;45m"); // Blinking yellow on magenta (blink not implemented) +// printf("\x1b[1;30;47m"); // Bright black (grey) on dim white // // Style Foreground Background -// 1st Digit 2nd Digit 3rd Digit RGB -// 0 - Reset 30 - Black 40 - Black 000 -// 1 - FG Bright 31 - Red 41 - Red 100 -// 2 - Unknown 32 - Green 42 - Green 010 -// 3 - Blink 33 - Yellow 43 - Yellow 110 -// 4 - Underline 34 - Blue 44 - Blue 001 -// 5 - BG Bright 35 - Magenta 45 - Magenta 101 -// 6 - Unknown 36 - Cyan 46 - Cyan 011 -// 7 - Reverse 37 - White 47 - White 111 +// 1st Digit 2nd Digit 3rd Digit RGB +// 0 - Reset 30 - Black 40 - Black 000 +// 1 - FG Bright 31 - Red 41 - Red 100 +// 2 - Unknown 32 - Green 42 - Green 010 +// 3 - Blink 33 - Yellow 43 - Yellow 110 +// 4 - Underline 34 - Blue 44 - Blue 001 +// 5 - BG Bright 35 - Magenta 45 - Magenta 101 +// 6 - Unknown 36 - Cyan 46 - Cyan 011 +// 7 - Reverse 37 - White 47 - White 111 // 8 - Concealed (invisible) // // \033[#A - Cursor Up (CUU) @@ -181,7 +181,7 @@ Escape sequences for Select Character Set #define is_console(handle) (FILE_TYPE_CHAR==GetFileType(handle)) /////////////////////////////////////////////////////////////////////////////// -int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) +int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) { ///////////////////////////////////////////////////////////////// /* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs] @@ -207,19 +207,18 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) // start with processing p = BUFVAL(tempbuf); - while ((q = strchr(p, 0x1b)) != NULL) - { // find the escape character + while ((q = strchr(p, 0x1b)) != NULL) { + // find the escape character if( 0==WriteConsole(handle, p, (DWORD)(q-p), &written, 0) ) // write up to the escape WriteFile(handle, p, (DWORD)(q-p), &written, 0); - if( q[1]!='[' ) - { // write the escape char (whatever purpose it has) + if (q[1]!='[') { + // write the escape char (whatever purpose it has) if(0==WriteConsole(handle, q, 1, &written, 0) ) WriteFile(handle,q, 1, &written, 0); - p=q+1; //and start searching again - } - else - { // from here, we will skip the '\033[' + p=q+1; //and start searching again + } else { + // from here, we will skip the '\033[' // we break at the first unprocessible position // assuming regular text is starting there uint8 numbers[16], numpoint=0; @@ -231,84 +230,72 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) // skip escape and bracket q=q+2; - for(;;) - { - if( ISDIGIT(*q) ) - { // add number to number array, only accept 2digits, shift out the rest + for (;;) { + if (ISDIGIT(*q)) { + // add number to number array, only accept 2digits, shift out the rest // so // \033[123456789m will become \033[89m numbers[numpoint] = (numbers[numpoint]<<4) | (*q-'0'); ++q; // and next character continue; - } - else if( *q == ';' ) - { // delimiter - if(numpoint<sizeof(numbers)/sizeof(*numbers)) - { // go to next array position + } else if (*q == ';') { + // delimiter + if (numpoint < sizeof(numbers)/sizeof(*numbers)) { + // go to next array position numpoint++; - } - else - { // array is full, so we 'forget' the first value + } else { + // array is full, so we 'forget' the first value memmove(numbers,numbers+1,sizeof(numbers)/sizeof(*numbers)-1); numbers[sizeof(numbers)/sizeof(*numbers)-1]=0; } ++q; // and next number continue; - } - else if( *q == 'm' ) - { // \033[#;...;#m - Set Graphics Rendition (SGR) + } else if (*q == 'm') { + // \033[#;...;#m - Set Graphics Rendition (SGR) uint8 i; - for(i=0; i<= numpoint; ++i) - { - if( 0x00 == (0xF0 & numbers[i]) ) - { // upper nibble 0 - if( 0 == numbers[i] ) - { // reset + for (i=0; i<= numpoint; ++i) { + if (0x00 == (0xF0 & numbers[i])) { + // upper nibble 0 + if (0 == numbers[i]) { + // reset info.wAttributes = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; - } - else if( 1==numbers[i] ) - { // set foreground intensity + } else if (1 == numbers[i]) { + // set foreground intensity info.wAttributes |= FOREGROUND_INTENSITY; - } - else if( 5==numbers[i] ) - { // set background intensity + } else if (5 == numbers[i]) { + // set background intensity info.wAttributes |= BACKGROUND_INTENSITY; - } - else if( 7==numbers[i] ) - { // reverse colors (just xor them) + } else if (7 == numbers[i]) { + // reverse colors (just xor them) info.wAttributes ^= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | - BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE; + BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE; } //case '2': // not existing - //case '3': // blinking (not implemented) - //case '4': // underline (not implemented) + //case '3': // blinking (not implemented) + //case '4': // underline (not implemented) //case '6': // not existing //case '8': // concealed (not implemented) //case '9': // not existing - } - else if( 0x20 == (0xF0 & numbers[i]) ) - { // off + } else if (0x20 == (0xF0 & numbers[i])) { + // off - if( 1==numbers[i] ) - { // set foreground intensity off + if (1 == numbers[i]) { + // set foreground intensity off info.wAttributes &= ~FOREGROUND_INTENSITY; - } - else if( 5==numbers[i] ) - { // set background intensity off + } else if (5 == numbers[i]) { + // set background intensity off info.wAttributes &= ~BACKGROUND_INTENSITY; - } - else if( 7==numbers[i] ) - { // reverse colors (just xor them) + } else if (7 == numbers[i]) { + // reverse colors (just xor them) info.wAttributes ^= FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | - BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE; + BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE; } - } - else if( 0x30 == (0xF0 & numbers[i]) ) - { // foreground + } else if (0x30 == (0xF0 & numbers[i])) { + // foreground uint8 num = numbers[i]&0x0F; if(num==9) info.wAttributes |= FOREGROUND_INTENSITY; - if(num>7) num=7; // set white for 37, 38 and 39 + if(num>7) num=7; // set white for 37, 38 and 39 info.wAttributes &= ~(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); if( (num & 0x01)>0 ) // lowest bit set = red info.wAttributes |= FOREGROUND_RED; @@ -316,12 +303,11 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) info.wAttributes |= FOREGROUND_GREEN; if( (num & 0x04)>0 ) // third bit set = blue info.wAttributes |= FOREGROUND_BLUE; - } - else if( 0x40 == (0xF0 & numbers[i]) ) - { // background + } else if (0x40 == (0xF0 & numbers[i])) { + // background uint8 num = numbers[i]&0x0F; if(num==9) info.wAttributes |= BACKGROUND_INTENSITY; - if(num>7) num=7; // set white for 47, 48 and 49 + if(num>7) num=7; // set white for 47, 48 and 49 info.wAttributes &= ~(BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE); if( (num & 0x01)>0 ) // lowest bit set = red info.wAttributes |= BACKGROUND_RED; @@ -333,61 +319,51 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) } // set the attributes SetConsoleTextAttribute(handle, info.wAttributes); - } - else if( *q=='J' ) - { // \033[#J - Erase Display (ED) - // \033[0J - Clears the screen from cursor to end of display. The cursor position is unchanged. - // \033[1J - Clears the screen from start to cursor. The cursor position is unchanged. - // \033[2J - Clears the screen and moves the cursor to the home position (line 1, column 1). + } else if (*q=='J') { + // \033[#J - Erase Display (ED) + // \033[0J - Clears the screen from cursor to end of display. The cursor position is unchanged. + // \033[1J - Clears the screen from start to cursor. The cursor position is unchanged. + // \033[2J - Clears the screen and moves the cursor to the home position (line 1, column 1). uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F); int cnt; DWORD tmp; COORD origin = {0,0}; - if(num==1) - { // chars from start up to and including cursor + if (num == 1) { + // chars from start up to and including cursor cnt = info.dwSize.X * info.dwCursorPosition.Y + info.dwCursorPosition.X + 1; - } - else if(num==2) - { // Number of chars on screen. + } else if (num == 2) { + // Number of chars on screen. cnt = info.dwSize.X * info.dwSize.Y; SetConsoleCursorPosition(handle, origin); - } - else// 0 and default - { // number of chars from cursor to end + } else { /* 0 and default */ + // number of chars from cursor to end origin = info.dwCursorPosition; cnt = info.dwSize.X * (info.dwSize.Y - info.dwCursorPosition.Y) - info.dwCursorPosition.X; } FillConsoleOutputAttribute(handle, info.wAttributes, cnt, origin, &tmp); FillConsoleOutputCharacter(handle, ' ', cnt, origin, &tmp); - } - else if( *q=='K' ) - { // \033[K : clear line from actual position to end of the line - // \033[0K - Clears all characters from the cursor position to the end of the line. - // \033[1K - Clears all characters from start of line to the cursor position. - // \033[2K - Clears all characters of the whole line. + } else if (*q=='K') { + // \033[K : clear line from actual position to end of the line + // \033[0K - Clears all characters from the cursor position to the end of the line. + // \033[1K - Clears all characters from start of line to the cursor position. + // \033[2K - Clears all characters of the whole line. uint8 num = (numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F); COORD origin = {0,info.dwCursorPosition.Y}; //warning C4204 SHORT cnt; DWORD tmp; - if(num==1) - { + if (num == 1) { cnt = info.dwCursorPosition.X + 1; - } - else if(num==2) - { + } else if (num == 2) { cnt = info.dwSize.X; - } - else// 0 and default - { + } else { /* 0 and default */ origin = info.dwCursorPosition; cnt = info.dwSize.X - info.dwCursorPosition.X; // how many spaces until line is full } FillConsoleOutputAttribute(handle, info.wAttributes, cnt, origin, &tmp); FillConsoleOutputCharacter(handle, ' ', cnt, origin, &tmp); - } - else if( *q == 'H' || *q == 'f' ) - { // \033[#;#H - Cursor Position (CUP) + } else if (*q == 'H' || *q == 'f') { + // \033[#;#H - Cursor Position (CUP) // \033[#;#f - Horizontal & Vertical Position // The first # specifies the line number, the second # specifies the column. // The default for both is 1 @@ -397,59 +373,52 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) if( info.dwCursorPosition.X >= info.dwSize.X ) info.dwCursorPosition.Y = info.dwSize.X-1; if( info.dwCursorPosition.Y >= info.dwSize.Y ) info.dwCursorPosition.Y = info.dwSize.Y-1; SetConsoleCursorPosition(handle, info.dwCursorPosition); - } - else if( *q=='s' ) - { // \033[s - Save Cursor Position (SCP) + } else if (*q=='s') { + // \033[s - Save Cursor Position (SCP) /* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs] CONSOLE_SCREEN_BUFFER_INFO info; GetConsoleScreenBufferInfo(handle, &info); saveposition = info.dwCursorPosition; */ - } - else if( *q=='u' ) - { // \033[u - Restore cursor position (RCP) + } else if (*q=='u') { + // \033[u - Restore cursor position (RCP) /* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs] SetConsoleCursorPosition(handle, saveposition); */ - } - else if( *q == 'A' ) - { // \033[#A - Cursor Up (CUU) + } else if (*q == 'A') { + // \033[#A - Cursor Up (CUU) // Moves the cursor UP # number of lines info.dwCursorPosition.Y -= (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1; if( info.dwCursorPosition.Y < 0 ) info.dwCursorPosition.Y = 0; SetConsoleCursorPosition(handle, info.dwCursorPosition); - } - else if( *q == 'B' ) - { // \033[#B - Cursor Down (CUD) + } else if (*q == 'B') { + // \033[#B - Cursor Down (CUD) // Moves the cursor DOWN # number of lines info.dwCursorPosition.Y += (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1; if( info.dwCursorPosition.Y >= info.dwSize.Y ) info.dwCursorPosition.Y = info.dwSize.Y-1; SetConsoleCursorPosition(handle, info.dwCursorPosition); - } - else if( *q == 'C' ) - { // \033[#C - Cursor Forward (CUF) + } else if (*q == 'C') { + // \033[#C - Cursor Forward (CUF) // Moves the cursor RIGHT # number of columns info.dwCursorPosition.X += (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1; if( info.dwCursorPosition.X >= info.dwSize.X ) info.dwCursorPosition.X = info.dwSize.X-1; SetConsoleCursorPosition(handle, info.dwCursorPosition); - } - else if( *q == 'D' ) - { // \033[#D - Cursor Backward (CUB) + } else if (*q == 'D') { + // \033[#D - Cursor Backward (CUB) // Moves the cursor LEFT # number of columns info.dwCursorPosition.X -= (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1; if( info.dwCursorPosition.X < 0 ) info.dwCursorPosition.X = 0; SetConsoleCursorPosition(handle, info.dwCursorPosition); - } - else if( *q == 'E' ) - { // \033[#E - Cursor Next Line (CNL) + } else if (*q == 'E') { + // \033[#E - Cursor Next Line (CNL) // Moves the cursor down the indicated # of rows, to column 1 info.dwCursorPosition.Y += (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1; info.dwCursorPosition.X = 0; @@ -457,9 +426,8 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) if( info.dwCursorPosition.Y >= info.dwSize.Y ) info.dwCursorPosition.Y = info.dwSize.Y-1; SetConsoleCursorPosition(handle, info.dwCursorPosition); - } - else if( *q == 'F' ) - { // \033[#F - Cursor Preceding Line (CPL) + } else if (*q == 'F') { + // \033[#F - Cursor Preceding Line (CPL) // Moves the cursor up the indicated # of rows, to column 1. info.dwCursorPosition.Y -= (numbers[numpoint])?(numbers[numpoint]>>4)*10+(numbers[numpoint]&0x0F):1; info.dwCursorPosition.X = 0; @@ -467,21 +435,18 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) if( info.dwCursorPosition.Y < 0 ) info.dwCursorPosition.Y = 0; SetConsoleCursorPosition(handle, info.dwCursorPosition); - } - else if( *q == 'G' ) - { // \033[#G - Cursor Horizontal Absolute (CHA) + } else if (*q == 'G') { + // \033[#G - Cursor Horizontal Absolute (CHA) // Moves the cursor to indicated column in current row. info.dwCursorPosition.X = (numbers[numpoint])?(numbers[numpoint]>>4)*10+((numbers[numpoint]&0x0F)-1):0; if( info.dwCursorPosition.X >= info.dwSize.X ) info.dwCursorPosition.X = info.dwSize.X-1; SetConsoleCursorPosition(handle, info.dwCursorPosition); - } - else if( *q == 'L' || *q == 'M' || *q == '@' || *q == 'P') - { // not implemented, just skip - } - else - { // no number nor valid sequencer + } else if (*q == 'L' || *q == 'M' || *q == '@' || *q == 'P') { + // not implemented, just skip + } else { + // no number nor valid sequencer // something is fishy, we break and give the current char free --q; } @@ -491,7 +456,7 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) }// end while } } - if (*p) // write the rest of the buffer + if (*p) // write the rest of the buffer if( 0==WriteConsole(handle, p, (DWORD)strlen(p), &written, 0) ) WriteFile(handle, p, (DWORD)strlen(p), &written, 0); FREEBUF(tempbuf); @@ -519,7 +484,7 @@ int FPRINTF(HANDLE handle, const char *fmt, ...) { #define is_console(file) (0!=isatty(fileno(file))) //vprintf_without_ansiformats -int VFPRINTF(FILE *file, const char *fmt, va_list argptr) +int VFPRINTF(FILE *file, const char *fmt, va_list argptr) { char *p, *q; NEWBUF(tempbuf); // temporary buffer @@ -538,88 +503,70 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) // start with processing p = BUFVAL(tempbuf); - while ((q = strchr(p, 0x1b)) != NULL) - { // find the escape character + while ((q = strchr(p, 0x1b)) != NULL) { + // find the escape character fprintf(file, "%.*s", (int)(q-p), p); // write up to the escape - if( q[1]!='[' ) - { // write the escape char (whatever purpose it has) + if (q[1]!='[') { + // write the escape char (whatever purpose it has) fprintf(file, "%.*s", 1, q); - p=q+1; //and start searching again - } - else - { // from here, we will skip the '\033[' + p=q+1; //and start searching again + } else { + // from here, we will skip the '\033[' // we break at the first unprocessible position // assuming regular text is starting there // skip escape and bracket q=q+2; - while(1) - { - if( ISDIGIT(*q) ) - { + while(1) { + if (ISDIGIT(*q)) { ++q; // and next character continue; - } - else if( *q == ';' ) - { // delimiter + } else if (*q == ';') { + // delimiter ++q; // and next number continue; - } - else if( *q == 'm' ) - { // \033[#;...;#m - Set Graphics Rendition (SGR) + } else if (*q == 'm') { + // \033[#;...;#m - Set Graphics Rendition (SGR) // set the attributes + } else if (*q=='J') { + // \033[#J - Erase Display (ED) } - else if( *q=='J' ) - { // \033[#J - Erase Display (ED) - } - else if( *q=='K' ) - { // \033[K : clear line from actual position to end of the line - } - else if( *q == 'H' || *q == 'f' ) - { // \033[#;#H - Cursor Position (CUP) + else if (*q=='K') { + // \033[K : clear line from actual position to end of the line + } else if (*q == 'H' || *q == 'f') { + // \033[#;#H - Cursor Position (CUP) // \033[#;#f - Horizontal & Vertical Position - } - else if( *q=='s' ) - { // \033[s - Save Cursor Position (SCP) - } - else if( *q=='u' ) - { // \033[u - Restore cursor position (RCP) - } - else if( *q == 'A' ) - { // \033[#A - Cursor Up (CUU) + } else if (*q=='s') { + // \033[s - Save Cursor Position (SCP) + } else if (*q=='u') { + // \033[u - Restore cursor position (RCP) + } else if (*q == 'A') { + // \033[#A - Cursor Up (CUU) // Moves the cursor UP # number of lines - } - else if( *q == 'B' ) - { // \033[#B - Cursor Down (CUD) + } else if (*q == 'B') { + // \033[#B - Cursor Down (CUD) // Moves the cursor DOWN # number of lines - } - else if( *q == 'C' ) - { // \033[#C - Cursor Forward (CUF) + } else if (*q == 'C') { + // \033[#C - Cursor Forward (CUF) // Moves the cursor RIGHT # number of columns - } - else if( *q == 'D' ) - { // \033[#D - Cursor Backward (CUB) + } else if (*q == 'D') { + // \033[#D - Cursor Backward (CUB) // Moves the cursor LEFT # number of columns - } - else if( *q == 'E' ) - { // \033[#E - Cursor Next Line (CNL) + } else if (*q == 'E') { + // \033[#E - Cursor Next Line (CNL) // Moves the cursor down the indicated # of rows, to column 1 - } - else if( *q == 'F' ) - { // \033[#F - Cursor Preceding Line (CPL) + } else if (*q == 'F') { + // \033[#F - Cursor Preceding Line (CPL) // Moves the cursor up the indicated # of rows, to column 1. - } - else if( *q == 'G' ) - { // \033[#G - Cursor Horizontal Absolute (CHA) + } else if (*q == 'G') { + // \033[#G - Cursor Horizontal Absolute (CHA) // Moves the cursor to indicated column in current row. - } - else if( *q == 'L' || *q == 'M' || *q == '@' || *q == 'P') - { // not implemented, just skip - } - else - { // no number nor valid sequencer + } else if (*q == 'L' || *q == 'M' || *q == '@' || *q == 'P') { + // not implemented, just skip + } else { + // no number nor valid sequencer // something is fishy, we break and give the current char free --q; } @@ -629,7 +576,7 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) }// end while } } - if (*p) // write the rest of the buffer + if (*p) // write the rest of the buffer fprintf(file, "%s", p); FREEBUF(tempbuf); return 0; @@ -661,7 +608,7 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) #if defined(DEBUGLOGMAP) || defined(DEBUGLOGCHAR) || defined(DEBUGLOGLOGIN) FILE *fp; #endif - + if (!string || *string == '\0') { ShowError("Empty string passed to vShowMessage_().\n"); return 1; @@ -700,8 +647,8 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) ) return 0; //Do not print it. - if (timestamp_format[0] && flag != MSG_NONE) - { //Display time format. [Skotlex] + if (timestamp_format[0] && flag != MSG_NONE) { + //Display time format. [Skotlex] time_t t = time(NULL); strftime(prefix, 80, timestamp_format, localtime(&t)); } else prefix[0]='\0'; @@ -738,8 +685,8 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) return 1; } - if (flag == MSG_ERROR || flag == MSG_FATALERROR || flag == MSG_SQL) - { //Send Errors to StdErr [Skotlex] + if (flag == MSG_ERROR || flag == MSG_FATALERROR || flag == MSG_SQL) { + //Send Errors to StdErr [Skotlex] FPRINTF(STDERR, "%s ", prefix); va_copy(apcopy, ap); VFPRINTF(STDERR, string, apcopy); @@ -757,7 +704,7 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) #if defined(DEBUGLOGMAP) || defined(DEBUGLOGCHAR) || defined(DEBUGLOGLOGIN) if(strlen(DEBUGLOGPATH) > 0) { fp=fopen(DEBUGLOGPATH,"a"); - if (fp == NULL) { + if (fp == NULL) { FPRINTF(STDERR, CL_RED"[ERROR]"CL_RESET": Could not open '"CL_WHITE"%s"CL_RESET"', access denied.\n", DEBUGLOGPATH); FFLUSH(STDERR); } else { @@ -779,7 +726,7 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) void ClearScreen(void) { #ifndef _WIN32 - ShowMessage(CL_CLS); // to prevent empty string passed messages + ShowMessage(CL_CLS); // to prevent empty string passed messages #endif } int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3))); diff --git a/src/common/socket.c b/src/common/socket.c index c57cba32d..f307dc4a9 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -274,7 +274,7 @@ const char* error_msg(void) } /*====================================== - * CORE : Default processing functions + * CORE : Default processing functions *--------------------------------------*/ int null_recv(int fd) { return 0; } int null_send(int fd) { return 0; } @@ -289,7 +289,7 @@ void set_defaultparse(ParseFunc defaultparse) /*====================================== - * CORE : Socket options + * CORE : Socket options *--------------------------------------*/ void set_nonblocking(int fd, unsigned long yes) { @@ -302,7 +302,7 @@ void set_nonblocking(int fd, unsigned long yes) void setsocketopts(int fd, struct hSockOpt *opt) { int yes = 1; // reuse fix struct linger lopt; - + #if !defined(WIN32) // set SO_REAUSEADDR to true, unix only. on windows this option causes // the previous owner of the socket to give up, which is not desirable @@ -319,14 +319,14 @@ void setsocketopts(int fd, struct hSockOpt *opt) { if( opt && opt->setTimeo ) { struct timeval timeout; - + timeout.tv_sec = 5; timeout.tv_usec = 0; - + sSetsockopt(fd,SOL_SOCKET,SO_RCVTIMEO,(char *)&timeout,sizeof(timeout)); sSetsockopt(fd,SOL_SOCKET,SO_SNDTIMEO,(char *)&timeout,sizeof(timeout)); } - + // force the socket into no-wait, graceful-close mode (should be the default, but better make sure) //(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/closesocket_2.asp) lopt.l_onoff = 0; // SO_DONTLINGER @@ -336,7 +336,7 @@ void setsocketopts(int fd, struct hSockOpt *opt) { } /*====================================== - * CORE : Socket Sub Function + * CORE : Socket Sub Function *--------------------------------------*/ void set_eof(int fd) { @@ -448,7 +448,7 @@ void flush_fifos(void) } /*====================================== - * CORE : Connection functions + * CORE : Connection functions *--------------------------------------*/ int connect_client(int listen_fd) { int fd; @@ -659,19 +659,19 @@ int realloc_writefifo(int fd, size_t addition) if( !sockt->session_isValid(fd) ) // might not happen return 0; - if( session[fd]->wdata_size + addition > session[fd]->max_wdata ) - { // grow rule; grow in multiples of WFIFO_SIZE + if (session[fd]->wdata_size + addition > session[fd]->max_wdata) { + // grow rule; grow in multiples of WFIFO_SIZE newsize = WFIFO_SIZE; while( session[fd]->wdata_size + addition > newsize ) newsize += WFIFO_SIZE; - } - else - if( session[fd]->max_wdata >= (size_t)2*(session[fd]->flag.server?FIFOSIZE_SERVERLINK:WFIFO_SIZE) - && (session[fd]->wdata_size+addition)*4 < session[fd]->max_wdata ) - { // shrink rule, shrink by 2 when only a quarter of the fifo is used, don't shrink below nominal size. + } else if (session[fd]->max_wdata >= (size_t)2*(session[fd]->flag.server?FIFOSIZE_SERVERLINK:WFIFO_SIZE) + && (session[fd]->wdata_size+addition)*4 < session[fd]->max_wdata + ) { + // shrink rule, shrink by 2 when only a quarter of the fifo is used, don't shrink below nominal size. newsize = session[fd]->max_wdata / 2; - } - else // no change + } else { + // no change return 0; + } RECREATE(session[fd]->wdata, unsigned char, newsize); session[fd]->max_wdata = newsize; @@ -682,7 +682,7 @@ int realloc_writefifo(int fd, size_t addition) /// advance the RFIFO cursor (marking 'len' bytes as processed) int RFIFOSKIP(int fd, size_t len) { - struct socket_data *s; + struct socket_data *s; if ( !sockt->session_isActive(fd) ) return 0; @@ -711,8 +711,8 @@ int WFIFOSET(int fd, size_t len) return 0; // we have written len bytes to the buffer already before calling WFIFOSET - if(s->wdata_size+len > s->max_wdata) - { // actually there was a buffer overflow already + if (s->wdata_size+len > s->max_wdata) { + // actually there was a buffer overflow already uint32 ip = s->client_addr; ShowFatalError("WFIFOSET: Write Buffer Overflow. Connection %d (%d.%d.%d.%d) has written %u bytes on a %u/%u bytes buffer.\n", fd, CONVIP(ip), (unsigned int)len, (unsigned int)s->wdata_size, (unsigned int)s->max_wdata); ShowDebug("Likely command that caused it: 0x%x\n", (*(uint16*)(s->wdata + s->wdata_size))); @@ -839,8 +839,8 @@ int do_sockets(int next) if(session[i]->wdata_size) session[i]->func_send(i); - if(session[i]->flag.eof) //func_send can't free a session, this is safe. - { //Finally, even if there is no data to parse, connections signaled eof should be closed, so we call parse_func [Skotlex] + if (session[i]->flag.eof) { //func_send can't free a session, this is safe. + //Finally, even if there is no data to parse, connections signaled eof should be closed, so we call parse_func [Skotlex] session[i]->func_parse(i); //This should close the session immediately. } } @@ -870,7 +870,7 @@ int do_sockets(int next) if(!session[i]) continue; - + RFIFOFLUSH(i); // after parse, check client's RFIFO size to know if there is an invalid packet (too big and not parsed) if (session[i]->rdata_size == session[i]->max_rdata) { @@ -883,7 +883,7 @@ int do_sockets(int next) if (sockt->last_tick != socket_data_last_tick) { char buf[1024]; - + sprintf(buf, "In: %.03f kB/s (%.03f kB/s, Q: %.03f kB) | Out: %.03f kB/s (%.03f kB/s, Q: %.03f kB) | RAM: %.03f MB", socket_data_i/1024., socket_data_ci/1024., socket_data_qi/1024., socket_data_o/1024., socket_data_co/1024., socket_data_qo/1024., iMalloc->usage()/1024.); #ifdef _WIN32 SetConsoleTitle(buf); @@ -1232,7 +1232,7 @@ void socket_final(void) aFree(session[0]->rdata); aFree(session[0]->wdata); aFree(session[0]); - + aFree(session); } @@ -1396,7 +1396,7 @@ void socket_init(void) #endif CREATE(session, struct socket_data *, FD_SETSIZE); - + socket_config_read(SOCKET_CONF_FILENAME); // initialize last send-receive tick @@ -1414,7 +1414,7 @@ void socket_init(void) #endif ShowInfo("Server supports up to '"CL_WHITE"%"PRId64""CL_RESET"' concurrent connections.\n", rlim_cur); - + /* Hercules Plugin Manager */ HPM->share(session,"session"); } @@ -1498,11 +1498,11 @@ void socket_datasync(int fd, bool send) { WFIFOW(fd, 0) = 0x2b0a; WFIFOW(fd, 2) = p_len; - + for( i = 0; i < alen; i++ ) { WFIFOL(fd, 4 + ( i * 4 ) ) = data_list[i].length; } - + WFIFOSET(fd, p_len); } else { for( i = 0; i < alen; i++ ) { @@ -1602,7 +1602,7 @@ void send_shortlist_do_sends() void socket_defaults(void) { sockt = &sockt_s; - + sockt->fd_max = 0; /* */ sockt->stall_time = 60; diff --git a/src/common/socket.h b/src/common/socket.h index 42b0efe3b..b9c562a29 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -97,7 +97,7 @@ struct socket_data { ParseFunc func_parse; void* session_data; // stores application-specific data related to the session - + struct HPluginData **hdata; unsigned int hdatac; }; diff --git a/src/common/spinlock.h b/src/common/spinlock.h index bde36b8e5..85a78ed33 100644 --- a/src/common/spinlock.h +++ b/src/common/spinlock.h @@ -13,7 +13,7 @@ // For more information, see LICENCE in the main folder // // - + #include "../common/atomic.h" #include "../common/cbasetypes.h" #include "../common/thread.h" @@ -33,7 +33,7 @@ typedef struct __declspec( align(64) ) SPIN_LOCK{ typedef struct SPIN_LOCK{ volatile int32 lock; volatile int32 nest; // nesting level. - + volatile int32 sync_lock; } __attribute__((aligned(64))) SPIN_LOCK; #endif @@ -56,7 +56,7 @@ static forceinline void FinalizeSpinLock(SPIN_LOCK *lck){ static forceinline void EnterSpinLock(SPIN_LOCK *lck){ int tid = rathread_get_tid(); - + // Get Sync Lock && Check if the requester thread already owns the lock. // if it owns, increase nesting level getsynclock(&lck->sync_lock); @@ -67,18 +67,14 @@ static forceinline void EnterSpinLock(SPIN_LOCK *lck){ } // drop sync lock dropsynclock(&lck->sync_lock); - - + // Spin until we've got it ! while(1){ - - if(InterlockedCompareExchange(&lck->lock, tid, 0) == 0){ - - InterlockedIncrement(&lck->nest); - return; // Got Lock - } - - rathread_yield(); // Force ctxswitch to another thread. + if(InterlockedCompareExchange(&lck->lock, tid, 0) == 0){ + InterlockedIncrement(&lck->nest); + return; // Got Lock + } + rathread_yield(); // Force ctxswitch to another thread. } } @@ -88,12 +84,12 @@ static forceinline void LeaveSpinLock(SPIN_LOCK *lck){ int tid = rathread_get_tid(); getsynclock(&lck->sync_lock); - + if(InterlockedCompareExchange(&lck->lock, tid, tid) == tid){ // this thread owns the lock. if(InterlockedDecrement(&lck->nest) == 0) InterlockedExchange(&lck->lock, 0); // Unlock! } - + dropsynclock(&lck->sync_lock); } diff --git a/src/common/sql.c b/src/common/sql.c index c75b90cec..7f89e9828 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -1004,10 +1004,10 @@ void Sql_HerculesUpdateCheck(Sql* self) { FILE* ifp;/* index fp */ unsigned int performed = 0; StringBuf buf; - + if( self == NULL ) return;/* return silently, build has no mysql connection */ - + if( !( ifp = fopen("sql-files/upgrades/index.txt", "r") ) ) { ShowError("SQL upgrade index was not found!\n"); return; @@ -1055,7 +1055,7 @@ void Sql_HerculesUpdateCheck(Sql* self) { ShowMessage("%s",StrBuf->Value(&buf)); ShowSQL("To manually skip, type: 'sql update skip <file name>'\n"); } - + StrBuf->Destroy(&buf); } @@ -1063,21 +1063,21 @@ void Sql_HerculesUpdateSkip(Sql* self,const char *filename) { char path[41];// "sql-files/upgrades/" (19) + "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1 char timestamp[11];// "1360186680" (10) + 1 FILE* ifp;/* index fp */ - + if( !self ) { ShowError("SQL not hooked!\n"); return; } - + snprintf(path,41,"sql-files/upgrades/%s",filename); - + if( !( ifp = fopen(path, "r") ) ) { ShowError("Upgrade file '%s' was not found!\n",filename); return; } - + fseek (ifp,1,SEEK_SET);/* woo. skip the # */ - + if( fgets(timestamp,sizeof(timestamp),ifp) ) { unsigned int timestampui = (unsigned int)atol(timestamp); if( SQL_ERROR == SQL->Query(self, "SELECT 1 FROM `sql_updates` WHERE `timestamp` = '%u' LIMIT 1", timestampui) ) diff --git a/src/common/strlib.c b/src/common/strlib.c index 35e0c63b0..8b63b4161 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -62,11 +62,12 @@ char* jstrescapecpy (char* pt, const char* spt) //a escape character is found, the target's final length increases! [Skotlex] int i =0, j=0; - if (!spt) { //Return an empty string [Skotlex] + if (!spt) { + //Return an empty string [Skotlex] pt[0] = '\0'; return &pt[0]; } - + while (spt[i] != '\0') { switch (spt[i]) { case '\'': @@ -252,7 +253,8 @@ char* strtok_r_(char *s1, const char *s2, char **lasts) { // for NetBSD 5.x and possibly some Solaris versions. #if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) /* Find the length of STRING, but scan at most MAXLEN characters. - If no '\0' terminator is found in that many characters, return MAXLEN. */ + * If no '\0' terminator is found in that many characters, return MAXLEN. + */ size_t strnlen(const char* string, size_t maxlen) { const char* end = (const char*)memchr(string, '\0', maxlen); return end ? (size_t) (end - string) : maxlen; @@ -1136,13 +1138,13 @@ void strlib_defaults(void) { strlib->trim = trim; strlib->normalize_name = normalize_name; strlib->stristr = stristr; - + #if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN) strlib->strnlen = strnlen; #else strlib->strnlen = NULL; #endif - + #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200 strlib->strtoull = strtoull; #else @@ -1155,7 +1157,7 @@ void strlib_defaults(void) { strlib->safesnprintf = safesnprintf; strlib->strline = strline; strlib->bin2hex = bin2hex; - + StrBuf->Malloc = StringBuf_Malloc; StrBuf->Init = StringBuf_Init; StrBuf->Printf = StringBuf_Printf; @@ -1167,7 +1169,7 @@ void strlib_defaults(void) { StrBuf->Clear = StringBuf_Clear; StrBuf->Destroy = StringBuf_Destroy; StrBuf->Free = StringBuf_Free; - + sv->parse_next = sv_parse_next; sv->parse = sv_parse; sv->split = sv_split; diff --git a/src/common/strlib.h b/src/common/strlib.h index 8f61470cf..0c596cb8f 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -63,31 +63,31 @@ struct strlib_interface { char *(*trim) (char* str); char *(*normalize_name) (char* str,const char* delims); const char *(*stristr) (const char *haystack, const char *needle); - + /* only used when '!(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN)', needs to be defined at all times however */ size_t (*strnlen) (const char* string, size_t maxlen); /* only used when 'defined(WIN32) && defined(_MSC_VER) && _MSC_VER <= 1200', needs to be defined at all times however */ uint64 (*strtoull) (const char* str, char** endptr, int base); - + int (*e_mail_check) (char* email); int (*config_switch) (const char* str); - + /// strncpy that always null-terminates the string char *(*safestrncpy) (char* dst, const char* src, size_t n); - + /// doesn't crash on null pointer size_t (*safestrnlen) (const char* string, size_t maxlen); - + /// Works like snprintf, but always null-terminates the buffer. /// Returns the size of the string (without null-terminator) /// or -1 if the buffer is too small. int (*safesnprintf) (char *buf, size_t sz, const char *fmt, ...) __attribute__((format(printf, 3, 4))); - + /// Returns the line of the target position in the string. /// Lines start at 1. int (*strline) (const char* str, size_t pos); - + /// Produces the hexadecimal representation of the given input. /// The output buffer must be at least count*2+1 in size. /// Returns true on success, false on failure. @@ -119,14 +119,14 @@ struct sv_interface { /// @param svstate Parse state /// @return 1 if a field was parsed, 0 if done, -1 on error. int (*parse_next) (struct s_svstate* svstate); - + /// Parses a delim-separated string. /// Starts parsing at startoff and fills the pos array with position pairs. /// out_pos[0] and out_pos[1] are the start and end of line. /// Other position pairs are the start and end of fields. /// Returns the number of fields found or -1 if an error occurs. int (*parse) (const char* str, int len, int startoff, char delim, int* out_pos, int npos, enum e_svopt opt); - + /// Splits a delim-separated string. /// WARNING: this function modifies the input string /// Starts splitting at startoff and fills the out_fields array. @@ -134,20 +134,20 @@ struct sv_interface { /// Other entries are the start of fields (null-terminated). /// Returns the number of fields found or -1 if an error occurs. int (*split) (char* str, int len, int startoff, char delim, char** out_fields, int nfields, enum e_svopt opt); - + /// Escapes src to out_dest according to the format of the C compiler. /// Returns the length of the escaped string. /// out_dest should be len*4+1 in size. size_t (*escape_c) (char* out_dest, const char* src, size_t len, const char* escapes); - + /// Unescapes src to out_dest according to the format of the C compiler. /// Returns the length of the unescaped string. /// out_dest should be len+1 in size and can be the same buffer as src. size_t (*unescape_c) (char* out_dest, const char* src, size_t len); - + /// Skips a C escape sequence (starting with '\\'). const char* (*skip_escaped_c) (const char* p); - + /// Opens and parses a file containing delim-separated columns, feeding them to the specified callback function row by row. /// Tracks the progress of the operation (current line number, number of successfully processed rows). /// Returns 'true' if it was able to process the specified file, or 'false' if it could not be read. diff --git a/src/common/thread.c b/src/common/thread.c index 1d0285302..a00bd6333 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -36,7 +36,7 @@ struct rAthread { unsigned int myID; - + RATHREAD_PRIO prio; rAthreadProc proc; void *param; @@ -62,7 +62,7 @@ static struct rAthread l_threads[RA_THREADS_MAX]; void rathread_init(void) { register unsigned int i; memset(&l_threads, 0x00, RA_THREADS_MAX * sizeof(struct rAthread) ); - + for(i = 0; i < RA_THREADS_MAX; i++){ l_threads[i].myID = i; } @@ -80,7 +80,7 @@ void rathread_init(void) { void rathread_final(void) { register unsigned int i; - + // Unterminated Threads Left? // Shouldn't happen .. // Kill 'em all! @@ -91,8 +91,7 @@ void rathread_final(void) { rathread_destroy(&l_threads[i]); } } - - + }//end: rathread_final() @@ -112,7 +111,7 @@ static void *raThreadMainRedirector( void *p ){ sigset_t set; // on Posix Thread platforms #endif void *ret; - + // Update myID @ TLS to right id. #ifdef HAS_TLS g_rathread_ID = ((rAthread*)p)->myID; @@ -129,7 +128,7 @@ static void *raThreadMainRedirector( void *p ){ sigaddset(&set, SIGPIPE); pthread_sigmask(SIG_BLOCK, &set, NULL); - + #endif @@ -181,14 +180,12 @@ rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack break; } } - + if(handle == NULL){ ShowError("rAthread: cannot create new thread (entryPoint: %p) - no free thread slot found!", entryPoint); return NULL; } - - - + handle->proc = entryPoint; handle->param = param; @@ -197,7 +194,7 @@ rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack #else pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, szStack); - + if(pthread_create(&handle->hThread, &attr, raThreadMainRedirector, (void*)handle) != 0){ handle->proc = NULL; handle->param = NULL; @@ -207,7 +204,7 @@ rAthread *rathread_createEx(rAthreadProc entryPoint, void *param, size_t szStack #endif rathread_prio_set( handle, prio ); - + return handle; }//end: rathread_createEx @@ -220,10 +217,9 @@ void rathread_destroy(rAthread *handle) { } #else if( pthread_cancel( handle->hThread ) == 0){ - // We have to join it, otherwise pthread wont re-cycle its internal resources assoc. with this thread. pthread_join( handle->hThread, NULL ); - + // Tell our manager to release resources ;) rat_thread_terminated(handle); } @@ -233,7 +229,7 @@ void rathread_destroy(rAthread *handle) { rAthread *rathread_self(void) { #ifdef HAS_TLS rAthread *handle = &l_threads[g_rathread_ID]; - + if(handle->proc != NULL) // entry point set, so its used! return handle; #else @@ -247,14 +243,13 @@ rAthread *rathread_self(void) { pthread_t hSelf; hSelf = pthread_self(); #endif - + for(i = 0; i < RA_THREADS_MAX; i++){ if(l_threads[i].hThread == hSelf && l_threads[i].proc != NULL) return &l_threads[i]; } - #endif - + return NULL; }//end: rathread_self() @@ -270,14 +265,12 @@ int rathread_get_tid(void) { #else return (intptr_t)pthread_self(); #endif - #endif - + }//end: rathread_get_tid() bool rathread_wait(rAthread *handle, void **out_exitCode) { - // Hint: // no thread data cleanup routine call here! // its managed by the callProxy itself.. diff --git a/src/common/thread.h b/src/common/thread.h index c7582366d..f00e7290d 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -104,8 +104,8 @@ RATHREAD_PRIO rathread_prio_get(rAthread *handle); * Tells the OS scheduler to yield the execution of the calling thread * * @note: this will not "pause" the thread, - * it just allows the OS to spent the remaining time - * of the slice to another thread. + * it just allows the OS to spend the remaining time + * of the slice to another thread. */ void rathread_yield(void); diff --git a/src/common/timer.c b/src/common/timer.c index 5d0a45b99..f2bfa98b3 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -59,7 +59,7 @@ time_t start_time; /*---------------------------- - * Timer debugging + * Timer debugging *----------------------------*/ struct timer_func_list { struct timer_func_list* next; @@ -101,31 +101,31 @@ char* search_timer_func_list(TimerFunc func) } /*---------------------------- - * Get tick time + * Get tick time *----------------------------*/ #if defined(ENABLE_RDTSC) static uint64 RDTSC_BEGINTICK = 0, RDTSC_CLOCK = 0; static __inline uint64 rdtsc_(void) { - register union{ - uint64 qw; - uint32 dw[2]; + register union { + uint64 qw; + uint32 dw[2]; } t; asm volatile("rdtsc":"=a"(t.dw[0]), "=d"(t.dw[1]) ); - + return t.qw; } static void rdtsc_calibrate(void){ uint64 t1, t2; int32 i; - + ShowStatus("Calibrating Timer Source, please wait... "); - + RDTSC_CLOCK = 0; - + for(i = 0; i < 5; i++){ t1 = rdtsc_(); usleep(1000000); //1000 MS @@ -133,9 +133,9 @@ static void rdtsc_calibrate(void){ RDTSC_CLOCK += (t2 - t1) / 1000; } RDTSC_CLOCK /= 5; - + RDTSC_BEGINTICK = rdtsc_(); - + ShowMessage(" done. (Frequency: %u Mhz)\n", (uint32)(RDTSC_CLOCK/1000) ); } @@ -233,7 +233,7 @@ int64 timer_gettick(void) { ////////////////////////////////////////////////////////////////////////// /*====================================== - * CORE : Timer Heap + * CORE : Timer Heap *--------------------------------------*/ /// Adds a timer to the timer_heap @@ -243,7 +243,7 @@ static void push_timer_heap(int tid) { } /*========================== - * Timer Management + * Timer Management *--------------------------*/ /// Returns a free timer id. @@ -281,7 +281,7 @@ static int acquire_timer(void) { /// Returns the timer's id. int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) { int tid; - + tid = acquire_timer(); timer_data[tid].tick = tick; timer_data[tid].func = func; @@ -304,7 +304,7 @@ int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int in tick, func, search_timer_func_list(func), id, data, DIFF_TICK(tick, timer->gettick())); return INVALID_TIMER; } - + tid = acquire_timer(); timer_data[tid].tick = tick; timer_data[tid].func = func; @@ -351,7 +351,7 @@ int64 timer_addtick(int tid, int64 tick) { /// Returns the new tick value, or -1 if it fails. int64 timer_settick(int tid, int64 tick) { size_t i; - + // search timer position ARR_FIND(0, BHEAP_LENGTH(timer_heap), i, BHEAP_DATA(timer_heap)[i] == tid); if( i == BHEAP_LENGTH(timer_heap) ) { @@ -444,8 +444,8 @@ void timer_final(void) { struct timer_func_list *next; for( tfl=tfl_root; tfl != NULL; tfl = next ) { - next = tfl->next; // copy next pointer - aFree(tfl->name); // free structures + next = tfl->next; // copy next pointer + aFree(tfl->name); // free structures aFree(tfl); } diff --git a/src/common/utils.c b/src/common/utils.c index 79232b25c..d73aab066 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -92,7 +92,8 @@ void ShowDump(const void *buffer, size_t length) { #ifdef WIN32 static char* checkpath(char *path, const char *srcpath) -{ // just make sure the char*path is not const +{ + // just make sure the char*path is not const char *p=path; if(NULL!=path && NULL!=srcpath) while(*srcpath) { @@ -112,16 +113,15 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) WIN32_FIND_DATAA FindFileData; HANDLE hFind; char tmppath[MAX_PATH+1]; - const char *path = (p ==NULL)? "." : p; const char *pattern = (pat==NULL)? "" : pat; - + checkpath(tmppath,path); if( PATHSEP != tmppath[strlen(tmppath)-1]) strcat(tmppath, "\\*"); else strcat(tmppath, "*"); - + hFind = FindFirstFileA(tmppath, &FindFileData); if (hFind != INVALID_HANDLE_VALUE) { @@ -153,7 +153,8 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) #define MAX_DIR_PATH 2048 static char* checkpath(char *path, const char*srcpath) -{ // just make sure the char*path is not const +{ + // just make sure the char*path is not const char *p=path; if(NULL!=path && NULL!=srcpath) while(*srcpath) { @@ -170,9 +171,9 @@ static char* checkpath(char *path, const char*srcpath) void findfile(const char *p, const char *pat, void (func)(const char*)) { - DIR* dir; // pointer to the scanned directory. - struct dirent* entry; // pointer to one directory entry. - struct stat dir_stat; // used by stat(). + DIR* dir; ///< pointer to the scanned directory. + struct dirent* entry; ///< pointer to one directory entry. + struct stat dir_stat; ///< used by stat(). char tmppath[MAX_DIR_PATH+1]; char path[MAX_DIR_PATH+1]= "."; const char *pattern = (pat==NULL)? "" : pat; @@ -289,17 +290,17 @@ int32 MakeLongLE(int32 val) // Reads an uint16 in little-endian from the buffer uint16 GetUShort(const unsigned char* buf) { - return ( ((uint16)(buf[0])) ) - |( ((uint16)(buf[1])) << 0x08 ); + return ( ((uint16)(buf[0])) ) + | ( ((uint16)(buf[1])) << 0x08 ); } // Reads an uint32 in little-endian from the buffer uint32 GetULong(const unsigned char* buf) { - return ( ((uint32)(buf[0])) ) - |( ((uint32)(buf[1])) << 0x08 ) - |( ((uint32)(buf[2])) << 0x10 ) - |( ((uint32)(buf[3])) << 0x18 ); + return ( ((uint32)(buf[0])) ) + | ( ((uint32)(buf[1])) << 0x08 ) + | ( ((uint32)(buf[2])) << 0x10 ) + | ( ((uint32)(buf[3])) << 0x18 ); } // Reads an int32 in little-endian from the buffer @@ -356,15 +357,15 @@ bool HCache_check(const char *file) { time_t rtime; if( !(first = fopen(file,"rb")) ) - return false; + return false; if( file[0] == '.' && file[1] == '/' ) - file += 2; + file += 2; else if( file[0] == '.' ) - file++; - + file++; + snprintf(s_path, 255, "./cache/%s", file); - + if( !(second = fopen(s_path,"rb")) ) { fclose(first); return false; @@ -375,34 +376,34 @@ bool HCache_check(const char *file) { fclose(second); return false; } - + fstat(fileno(first), &bufa); fstat(fileno(second), &bufb); - + fclose(first); fclose(second); - + if( bufa.st_mtime > bufb.st_mtime ) return false; - + return true; } FILE *HCache_open(const char *file, const char *opt) { FILE *first; char s_path[255]; - + if( file[0] == '.' && file[1] == '/' ) file += 2; else if( file[0] == '.' ) file++; - + snprintf(s_path, 255, "./cache/%s", file); - + if( !(first = fopen(s_path,opt)) ) { return NULL; } - + if( opt[0] != 'r' ) { char dT[1];/* 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */ dT[0] = HCACHE_KEY; @@ -410,19 +411,19 @@ FILE *HCache_open(const char *file, const char *opt) { hwrite(&HCache->recompile_time,sizeof(HCache->recompile_time),1,first); } fseek(first, 20, SEEK_SET);/* skip first 20, might wanna store something else later */ - + return first; } void HCache_init(void) { FILE *server; - + if( (server = fopen(SERVER_NAME,"rb")) ) { struct stat buf; - + fstat(fileno(server), &buf); HCache->recompile_time = buf.st_mtime; fclose(server); - + HCache->enabled = true; } else ShowWarning("Unable to open '%s', caching capabilities have been disabled!\n",SERVER_NAME); @@ -437,11 +438,10 @@ size_t hwrite(const void * ptr, size_t size, size_t count, FILE * stream) { } void HCache_defaults(void) { - HCache = &HCache_s; HCache->init = HCache_init; - + HCache->check = HCache_check; HCache->open = HCache_open; HCache->recompile_time = 0; diff --git a/src/common/winapi.h b/src/common/winapi.h index a8a38f30e..f53d9cbbd 100644 --- a/src/common/winapi.h +++ b/src/common/winapi.h @@ -2,10 +2,10 @@ #define STRICT -#define NTDDI_VERSION NTDDI_WIN2K +#define NTDDI_VERSION NTDDI_WIN2K #define _WIN32_WINNT 0x0500 -#define WINVER 0x0500 -#define _WIN32_IE 0x0600 +#define WINVER 0x0500 +#define _WIN32_IE 0x0600 #define WIN32_LEAN_AND_MEAN #define NOCOMM #define NOKANJI diff --git a/src/login/account_sql.c b/src/login/account_sql.c index 5f9357c81..adbb7914d 100644 --- a/src/login/account_sql.c +++ b/src/login/account_sql.c @@ -222,7 +222,7 @@ static bool account_db_sql_get_property(AccountDB* self, const char* key, char* if( strcmpi(key, "db_username") == 0 ) safesnprintf(buf, buflen, "%s", db->global_db_username); else - if( strcmpi(key, "db_password") == 0 ) + if( strcmpi(key, "db_password") == 0 ) safesnprintf(buf, buflen, "%s", db->global_db_password); else if( strcmpi(key, "db_database") == 0 ) @@ -248,7 +248,7 @@ static bool account_db_sql_get_property(AccountDB* self, const char* key, char* if( strcmpi(key, "db_username") == 0 ) safesnprintf(buf, buflen, "%s", db->db_username); else - if( strcmpi(key, "db_password") == 0 ) + if( strcmpi(key, "db_password") == 0 ) safesnprintf(buf, buflen, "%s", db->db_password); else if( strcmpi(key, "db_database") == 0 ) @@ -573,7 +573,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8)atoi(data); SQL->GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode)); SQL->GetData(sql_handle, 15, &data, NULL); acc->pincode_change = (unsigned int)atol(data); - + SQL->FreeResult(sql_handle); return true; @@ -665,19 +665,19 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) { Sql* sql_handle = ((AccountDB_SQL*)self)->accounts; AccountDB_SQL* db = (AccountDB_SQL*)self; int count = RFIFOW(fd, 12); - + if( count ) { int cursor = 14, i; char key[32], sval[254]; unsigned int index; - + for(i = 0; i < count; i++) { safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor)); cursor += RFIFOB(fd, cursor) + 1; - + index = RFIFOL(fd, cursor); cursor += 4; - + switch (RFIFOB(fd, cursor++)) { /* int */ case 0: @@ -700,24 +700,21 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) { if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", db->global_acc_reg_str_db, account_id, key, index) ) Sql_ShowDebug(sql_handle); break; - default: ShowError("mmo_save_accreg2: DA HOO UNKNOWN TYPE %d\n",RFIFOB(fd, cursor - 1)); return; } - } - } - } + void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { Sql* sql_handle = ((AccountDB_SQL*)self)->accounts; AccountDB_SQL* db = (AccountDB_SQL*)self; char* data; int plen = 0; size_t len; - + if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", db->global_acc_reg_str_db, account_id) ) Sql_ShowDebug(sql_handle); @@ -730,7 +727,7 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { WFIFOB(fd, 13) = 1;/* is string type */ WFIFOW(fd, 14) = 0;/* count */ plen = 16; - + /** * Vessel! * @@ -738,36 +735,35 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { * { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) } **/ while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) { - SQL->GetData(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(sql_handle, 1, &data, NULL); - + WFIFOL(fd, plen) = (unsigned int)atol(data); plen += 4; - + SQL->GetData(sql_handle, 2, &data, NULL); len = strlen(data)+1; - + 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; @@ -780,16 +776,16 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { plen = 16; } } - + /* mark & go. */ WFIFOW(fd, 2) = plen; WFIFOSET(fd, plen); - + SQL->FreeResult(sql_handle); - + if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", db->global_acc_reg_num_db, account_id) ) Sql_ShowDebug(sql_handle); - + WFIFOHEAD(fd, 60000 + 300); WFIFOW(fd, 0) = 0x3804; /* 0x2 = length, set prior to being sent */ @@ -799,7 +795,7 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { WFIFOB(fd, 13) = 0;/* is int type */ WFIFOW(fd, 14) = 0;/* count */ plen = 16; - + /** * Vessel! * @@ -807,32 +803,31 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { * { keyLength(B), key(<keyLength>), index(L), value(L) } **/ while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) { - SQL->GetData(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(sql_handle, 1, &data, NULL); - + WFIFOL(fd, plen) = (unsigned int)atol(data); plen += 4; - + SQL->GetData(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; @@ -842,15 +837,15 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) { WFIFOB(fd, 12) = 0;/* var type (only set when all vars have been sent, regardless of type) */ WFIFOB(fd, 13) = 0;/* is int type */ WFIFOW(fd, 14) = 0;/* count */ - + plen = 16; } } - + /* mark as complete & go. */ WFIFOB(fd, 12) = 1; WFIFOW(fd, 2) = plen; WFIFOSET(fd, plen); - + SQL->FreeResult(sql_handle); } diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index 82512b0f0..bfc90ad11 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -105,7 +105,7 @@ void ipban_final(void) if( login_config.ipban_cleanup_interval > 0 ) // release data timer->delete(cleanup_timer_id, ipban_cleanup); - + ipban_cleanup(0,0,0,0); // always clean up on login-server stop // close connections diff --git a/src/login/login.c b/src/login/login.c index 2a322ba40..c006d9c45 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -223,7 +223,7 @@ bool login_check_password(const char* md5key, int passwdenc, const char* passwd, { // password mode set to 1 -> md5(md5key, refpass) enable with <passwordencrypt></passwordencrypt> // password mode set to 2 -> md5(refpass, md5key) enable with <passwordencrypt2></passwordencrypt2> - + return ((passwdenc&0x01) && login->check_encrypted(md5key, refpass, passwd)) || ((passwdenc&0x02) && login->check_encrypted(refpass, md5key, passwd)); } @@ -767,7 +767,7 @@ void login_fromchar_accinfo(int fd, int account_id, int u_fd, int u_aid, int u_g safestrncpy((char*)WFIFOP(fd,119), acc->lastlogin, 24); WFIFOL(fd,143) = acc->logincount; WFIFOL(fd,147) = acc->state; - if (u_group >= acc->group_id) + if (u_group >= acc->group_id) safestrncpy((char*)WFIFOP(fd,151), acc->pincode, 5); else memset(WFIFOP(fd,151), '\0', 5); @@ -840,7 +840,7 @@ int login_parse_fromchar(int fd) if( j == 2 ) return 0; } } - + switch( command ) { case 0x2712: // request from char-server to authenticate an account @@ -880,7 +880,7 @@ int login_parse_fromchar(int fd) break; // Map server send information to change an email of an account via char-server - case 0x2722: // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B + case 0x2722: // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B if (RFIFOREST(fd) < 86) return 0; { @@ -912,7 +912,7 @@ int login_parse_fromchar(int fd) } break; - case 0x2728: // We receive account_reg2 from a char-server, and we send them to other map-servers. + case 0x2728: // We receive account_reg2 from a char-server, and we send them to other map-servers. if( RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2) ) return 0; { @@ -920,7 +920,7 @@ int login_parse_fromchar(int fd) } break; - case 0x272a: // Receiving of map-server via char-server an unban request + case 0x272a: // Receiving of map-server via char-server an unban request if( RFIFOREST(fd) < 6 ) return 0; { @@ -940,7 +940,7 @@ int login_parse_fromchar(int fd) login->fromchar_parse_account_offline(fd); break; - case 0x272d: // Receive list of all online accounts. [Skotlex] + case 0x272d: // Receive list of all online accounts. [Skotlex] if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; { @@ -974,7 +974,7 @@ int login_parse_fromchar(int fd) login->fromchar_parse_change_pincode(fd); } break; - + case 0x2739: // PIN Code was entered wrong too often if( RFIFOREST(fd) < 6 ) return 0; @@ -983,7 +983,7 @@ int login_parse_fromchar(int fd) return 0; } break; - + case 0x2740: // Accinfo request forwarded by charserver on mapserver's account if( RFIFOREST(fd) < 22 ) return 0; @@ -1045,7 +1045,7 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con safestrncpy(acc.pincode, "\0", sizeof(acc.pincode)); acc.pincode_change = 0; acc.char_slots = 0; - + if( !accounts->create(accounts, &acc) ) return 0; @@ -1117,7 +1117,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { ShowNotice("Empty userid (received pass: '%s', ip: %s)\n", sd->passwd, ip); return 0; // 0 = Unregistered ID } - + if( !accounts->load_str(accounts, &acc, sd->userid) ) { ShowNotice("Unknown account (account: %s, received pass: %s, ip: %s)\n", sd->userid, sd->passwd, ip); return 0; // 0 = Unregistered ID @@ -1139,7 +1139,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { ShowNotice("Connection refused (account: %s, pass: %s, state: %d, ip: %s)\n", sd->userid, sd->passwd, acc.state, ip); return acc.state - 1; } - + if( login_config.client_hash_check && !isServer ) { struct client_hash_node *node = NULL; bool match = false; @@ -1302,12 +1302,12 @@ void login_auth_ok(struct login_session_data* sd) WFIFOW(fd,47+n*32+4) = ntows(htons(server[i].port)); // [!] LE byte order here [!] memcpy(WFIFOP(fd,47+n*32+6), server[i].name, 20); WFIFOW(fd,47+n*32+26) = server[i].users; - + if( server[i].type == CST_PAYING && sd->expiration_time > time(NULL) ) WFIFOW(fd,47+n*32+28) = CST_NORMAL; else WFIFOW(fd,47+n*32+28) = server[i].type; - + WFIFOW(fd,47+n*32+30) = server[i].new_; n++; } @@ -1634,10 +1634,10 @@ int login_parse_login(int fd) if( result == 2 ) return 0; } } - + switch( command ) { - case 0x0200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive. + case 0x0200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive. if (RFIFOREST(fd) < 26) return 0; login->parse_ping(fd, sd); @@ -1678,14 +1678,14 @@ int login_parse_login(int fd) } break; - case 0x01db: // Sending request of the coding key + case 0x01db: // Sending request of the coding key RFIFOSKIP(fd,2); { login->parse_request_coding_key(fd, sd); } break; - case 0x2710: // Connection request of a char-server + case 0x2710: // Connection request of a char-server if (RFIFOREST(fd) < 86) return 0; { @@ -1863,9 +1863,9 @@ int do_final(void) { struct client_hash_node *hn = login_config.client_hash_nodes; ShowStatus("Terminating...\n"); - + HPM->event(HPET_FINAL); - + while (hn) { struct client_hash_node *tmp = hn; hn = hn->next; @@ -1887,7 +1887,7 @@ int do_final(void) { accounts = NULL; // destroyed in account_engine login->online_db->destroy(login->online_db, NULL); login->auth_db->destroy(login->auth_db, NULL); - + for( i = 0; i < ARRAYLENGTH(server); ++i ) chrif_server_destroy(i); @@ -1984,7 +1984,7 @@ int do_init(int argc, char** argv) login_config_read((argc > 1) ? argv[1] : LOGIN_CONF_NAME); login->lan_config_read((argc > 2) ? argv[2] : LAN_CONF_NAME); - + for( i = 0; i < ARRAYLENGTH(server); ++i ) chrif_server_init(i); @@ -1994,7 +1994,7 @@ int do_init(int argc, char** argv) // initialize static and dynamic ipban system ipban_init(); - + // Online user database init login->online_db = idb_alloc(DB_OPT_RELEASE_DATA); timer->add_func_list(login->waiting_disconnect_timer, "login->waiting_disconnect_timer"); @@ -2022,23 +2022,23 @@ int do_init(int argc, char** argv) } HPM->event(HPET_INIT); - + // server port open & binding if( (login->fd = make_listen_bind(login_config.login_ip,login_config.login_port)) == -1 ) { ShowFatalError("Failed to bind to port '"CL_WHITE"%d"CL_RESET"'\n",login_config.login_port); exit(EXIT_FAILURE); } - + if( runflag != CORE_ST_STOP ) { shutdown_callback = do_shutdown_login; runflag = LOGINSERVER_ST_RUNNING; } - + ShowStatus("The login-server is "CL_GREEN"ready"CL_RESET" (Server is listening on the port %u).\n\n", login_config.login_port); login_log(0, "login server", 100, "login server started"); - + HPM->event(HPET_READY); - + return 0; } diff --git a/src/login/login.h b/src/login/login.h index f86abaf4b..4c9bbd8b7 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -46,7 +46,7 @@ struct login_session_data { int has_client_hash; int fd; - + time_t expiration_time; }; @@ -69,34 +69,34 @@ struct client_hash_node { struct Login_Config { - uint32 login_ip; // the address to bind to - uint16 login_port; // the port to bind to - unsigned int ipban_cleanup_interval; // interval (in seconds) to clean up expired IP bans - unsigned int ip_sync_interval; // interval (in minutes) to execute a DNS/IP update (for dynamic IPs) - bool log_login; // whether to log login server actions or not - char date_format[32]; // date format used in messages - bool new_account_flag,new_acc_length_limit; // auto-registration via _M/_F ? / if yes minimum length is 4? - int start_limited_time; // new account expiration time (-1: unlimited) - bool use_md5_passwds; // work with password hashes instead of plaintext passwords? - int group_id_to_connect; // required group id to connect - int min_group_id_to_connect; // minimum group id to connect - bool check_client_version; // check the clientversion set in the clientinfo ? - uint32 client_version_to_connect; // the client version needed to connect (if checking is enabled) - int allowed_regs; // account registration flood protection [Kevin] - int time_allowed; // time in seconds - - bool ipban; // perform IP blocking (via contents of `ipbanlist`) ? - bool dynamic_pass_failure_ban; // automatic IP blocking due to failed login attemps ? - unsigned int dynamic_pass_failure_ban_interval; // how far to scan the loginlog for password failures - unsigned int dynamic_pass_failure_ban_limit; // number of failures needed to trigger the ipban - unsigned int dynamic_pass_failure_ban_duration; // duration of the ipban - bool use_dnsbl; // dns blacklist blocking ? - char dnsbl_servs[1024]; // comma-separated list of dnsbl servers - - int client_hash_check; // flags for checking client md5 - struct client_hash_node *client_hash_nodes; // linked list containg md5 hash for each gm group - - // Advanced subnet check [LuzZza] + uint32 login_ip; ///< the address to bind to + uint16 login_port; ///< the port to bind to + unsigned int ipban_cleanup_interval; ///< interval (in seconds) to clean up expired IP bans + unsigned int ip_sync_interval; ///< interval (in minutes) to execute a DNS/IP update (for dynamic IPs) + bool log_login; ///< whether to log login server actions or not + char date_format[32]; ///< date format used in messages + bool new_account_flag,new_acc_length_limit; ///< auto-registration via _M/_F ? / if yes minimum length is 4? + int start_limited_time; ///< new account expiration time (-1: unlimited) + bool use_md5_passwds; ///< work with password hashes instead of plaintext passwords? + int group_id_to_connect; ///< required group id to connect + int min_group_id_to_connect; ///< minimum group id to connect + bool check_client_version; ///< check the clientversion set in the clientinfo ? + uint32 client_version_to_connect; ///< the client version needed to connect (if checking is enabled) + int allowed_regs; ///< account registration flood protection [Kevin] + int time_allowed; ///< time in seconds + + bool ipban; ///< perform IP blocking (via contents of `ipbanlist`) ? + bool dynamic_pass_failure_ban; ///< automatic IP blocking due to failed login attemps ? + unsigned int dynamic_pass_failure_ban_interval; ///< how far to scan the loginlog for password failures + unsigned int dynamic_pass_failure_ban_limit; ///< number of failures needed to trigger the ipban + unsigned int dynamic_pass_failure_ban_duration; ///< duration of the ipban + bool use_dnsbl; ///< dns blacklist blocking ? + char dnsbl_servs[1024]; ///< comma-separated list of dnsbl servers + + int client_hash_check; ///< flags for checking client md5 + struct client_hash_node *client_hash_nodes; ///< linked list containg md5 hash for each gm group + + /// Advanced subnet check [LuzZza] struct s_subnet { uint32 mask; uint32 char_ip; diff --git a/src/map/atcommand.c b/src/map/atcommand.c index dac51d153..254da5c5b 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -162,15 +162,15 @@ ACMD(send) { int len=0,off,end,type; long num; - + // read message type as hex number (without the 0x) if(!message || !*message || !((sscanf(message, "len %x", &type)==1 && (len=1)) || sscanf(message, "%x", &type)==1) ) { clif->message(fd, msg_txt(900)); // Usage: - clif->message(fd, msg_txt(901)); // @send len <packet hex number> - clif->message(fd, msg_txt(902)); // @send <packet hex number> {<value>}* - clif->message(fd, msg_txt(903)); // Value: <type=B(default),W,L><number> or S<length>"<string>" + clif->message(fd, msg_txt(901)); // @send len <packet hex number> + clif->message(fd, msg_txt(902)); // @send <packet hex number> {<value>}* + clif->message(fd, msg_txt(903)); // Value: <type=B(default),W,L><number> or S<length>"<string>" return false; } @@ -200,14 +200,13 @@ ACMD(send) } while(0) //define GET_VALUE if (type > 0 && type < MAX_PACKET_DB) { - if(len) {// show packet length sprintf(atcmd_output, msg_txt(904), type, packet_db[type].len); // Packet 0x%x length: %d clif->message(fd, atcmd_output); return true; } - + len=packet_db[type].len; off=2; if(len == 0) @@ -222,7 +221,7 @@ ACMD(send) } WFIFOHEAD(sd->fd, len); WFIFOW(sd->fd,0)=TOW(type); - + // parse packet contents SKIP_VALUE(message); while(*message != 0 && off < len){ @@ -266,7 +265,7 @@ ACMD(send) ++message; } } - + // parse string ++message; CHECK_EOS(message); @@ -344,7 +343,7 @@ ACMD(send) ++message; CHECK_EOS(message); } - + // terminate the string if(off < end) {// fill the rest with 0's @@ -358,7 +357,7 @@ ACMD(send) } SKIP_VALUE(message); } - + if(packet_db[type].len == -1) {// send dynamic packet WFIFOW(sd->fd,2)=TOW(off); WFIFOSET(sd->fd,off); @@ -388,21 +387,20 @@ ACMD(mapmove) { unsigned short map_index; short x = 0, y = 0; int16 m = -1; - + memset(map_name, '\0', sizeof(map_name)); - + if (!message || !*message || (sscanf(message, "%15s %hd %hd", map_name, &x, &y) < 3 && sscanf(message, "%15[^,],%hd,%hd", map_name, &x, &y) < 1)) { - clif->message(fd, msg_txt(909)); // Please enter a map (usage: @warp/@rura/@mapmove <mapname> <x> <y>). return false; } - + map_index = mapindex->name2id(map_name); if (map_index) m = map->mapindex2mapid(map_index); - + if (!map_index || m < 0) { // m < 0 means on different server or that map is disabled! [Kevin] clif->message(fd, msg_txt(1)); // Map not found. return false; @@ -412,7 +410,7 @@ ACMD(mapmove) { clif->message(fd, msg_txt(253)); // You already are at your destination! return false; } - + if ((x || y) && map->getcell(m, x, y, CELL_CHKNOPASS) && pc_get_group_level(sd) < battle_config.gm_ignore_warpable_area) { //This is to prevent the pc->setpos call from printing an error. clif->message(fd, msg_txt(2)); @@ -431,7 +429,7 @@ ACMD(mapmove) { clif->message(fd, msg_txt(1)); // Map not found. return false; } - + clif->message(fd, msg_txt(0)); // Warped. return true; } @@ -441,14 +439,14 @@ ACMD(mapmove) { *------------------------------------------*/ ACMD(where) { struct map_session_data* pl_sd; - + memset(atcmd_player_name, '\0', sizeof atcmd_player_name); - + if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif->message(fd, msg_txt(910)); // Please enter a player name (usage: @where <char name>). return false; } - + pl_sd = map->nick2sd(atcmd_player_name); if (pl_sd == NULL || strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 || @@ -457,10 +455,10 @@ ACMD(where) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); clif->message(fd, atcmd_output); - + return true; } @@ -489,7 +487,7 @@ ACMD(jumpto) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); // You are not authorized to warp to this map. return false; @@ -513,21 +511,21 @@ ACMD(jumpto) { ACMD(jump) { short x = 0, y = 0; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + sscanf(message, "%hd %hd", &x, &y); - + if (map->list[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } - + if( pc_isdead(sd) ) { clif->message(fd, msg_txt(864)); // "You cannot use this command when dead." return false; } - + if ((x || y) && map->getcell(sd->bl.m, x, y, CELL_CHKNOPASS)) { //This is to prevent the pc->setpos call from printing an error. clif->message(fd, msg_txt(2)); @@ -539,7 +537,7 @@ ACMD(jump) clif->message(fd, msg_txt(253)); // You already are at your destination! return false; } - + pc->setpos(sd, sd->mapindex, x, y, CLR_TELEPORT); sprintf(atcmd_output, msg_txt(5), sd->bl.x, sd->bl.y); // Jumped to %d %d clif->message(fd, atcmd_output); @@ -565,24 +563,24 @@ ACMD(who) { */ int display_type = 1; int map_id = -1; - + if (stristr(info->command, "map") != NULL) { if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map->mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } else { sscanf(message, "%23s", player_name); } - + if (stristr(info->command, "2") != NULL) display_type = 2; else if (stristr(info->command, "3") != NULL) display_type = 3; - + level = pc_get_group_level(sd); StrBuf->Init(&buf); - + iter = mapit_getallusers(); - for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) { + for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) { if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || pc_isinvisible(pl_sd)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive || (map_id >= 0 && pl_sd->bl.m != map_id)) @@ -598,7 +596,7 @@ ACMD(who) { } case 3: { if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) - StrBuf->Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) " + StrBuf->Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) " StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists StrBuf->Printf(&buf, msg_txt(344), pcg->get_name(pl_sd->group)); // "(%s) " @@ -608,7 +606,7 @@ ACMD(who) { default: { struct party_data *p = party->search(pl_sd->status.party_id); struct guild *g = pl_sd->guild; - + StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists StrBuf->Printf(&buf, msg_txt(344), pcg->get_name(pl_sd->group)); // "(%s) " @@ -625,7 +623,7 @@ ACMD(who) { } } mapit->free(iter); - + if (map_id < 0) { if (count == 0) StrBuf->Printf(&buf, msg_txt(28)); // No player found. @@ -659,32 +657,32 @@ ACMD(whogm) char player_name[NAME_LENGTH]; struct guild *g; struct party_data *p; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(match_text, '\0', sizeof(match_text)); memset(player_name, '\0', sizeof(player_name)); - + if (sscanf(message, "%199[^\n]", match_text) < 1) strcpy(match_text, ""); for (j = 0; match_text[j]; j++) match_text[j] = TOLOWER(match_text[j]); - + count = 0; level = pc_get_group_level(sd); - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { pl_level = pc_get_group_level(pl_sd); if (!pl_level) continue; - + if (match_text[0]) { memcpy(player_name, pl_sd->status.name, NAME_LENGTH); for (j = 0; player_name[j]; j++) player_name[j] = TOLOWER(player_name[j]); - // search with no case sensitive + // search with no case sensitive if (strstr(player_name, match_text) == NULL) continue; } @@ -696,28 +694,28 @@ ACMD(whogm) count++; continue; } - + sprintf(atcmd_output, msg_txt(914), // Name: %s (GM:%d) | Location: %s %d %d pl_sd->status.name, pl_level, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); clif->message(fd, atcmd_output); - + sprintf(atcmd_output, msg_txt(915), // BLvl: %d | Job: %s (Lvl: %d) pl_sd->status.base_level, pc->job_name(pl_sd->status.class_), pl_sd->status.job_level); clif->message(fd, atcmd_output); - + p = party->search(pl_sd->status.party_id); g = pl_sd->guild; - - sprintf(atcmd_output,msg_txt(916), // Party: '%s' | Guild: '%s' - p?p->party.name:msg_txt(917), g?g->name:msg_txt(917)); // None. - + + sprintf(atcmd_output,msg_txt(916), // Party: '%s' | Guild: '%s' + p?p->party.name:msg_txt(917), g?g->name:msg_txt(917)); // None. + clif->message(fd, atcmd_output); count++; } mapit->free(iter); - + if (count == 0) clif->message(fd, msg_txt(150)); // No GM found. else if (count == 1) @@ -726,23 +724,23 @@ ACMD(whogm) sprintf(atcmd_output, msg_txt(152), count); // %d GMs found. clif->message(fd, atcmd_output); } - + return true; } /*========================================== * *------------------------------------------*/ -ACMD(save) { - +ACMD(save) +{ pc->setsavepoint(sd, sd->mapindex, sd->bl.x, sd->bl.y); if (sd->status.pet_id > 0 && sd->pd) intif->save_petdata(sd->status.account_id, &sd->pd->pet); - + chrif->save(sd,0); - + clif->message(fd, msg_txt(6)); // Your save point has been changed. - + return true; } @@ -751,7 +749,7 @@ ACMD(save) { *------------------------------------------*/ ACMD(load) { int16 m; - + m = map->mapindex2mapid(sd->status.save_point.map); if (m >= 0 && map->list[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(249)); // You are not authorized to warp to your save map. @@ -761,10 +759,10 @@ ACMD(load) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } - + pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_OUTSIGHT); clif->message(fd, msg_txt(7)); // Warping to save point.. - + return true; } @@ -774,30 +772,30 @@ ACMD(load) { ACMD(speed) { int speed; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%d", &speed) < 1) { sprintf(atcmd_output, msg_txt(918), MIN_WALK_SPEED, MAX_WALK_SPEED); // Please enter a speed value (usage: @speed <%d-%d>). clif->message(fd, atcmd_output); return false; } - + sd->state.permanent_speed = 0; - + if (speed < 0) sd->base_status.speed = DEFAULT_WALK_SPEED; else sd->base_status.speed = cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED); - + if( sd->base_status.speed != DEFAULT_WALK_SPEED ) { sd->state.permanent_speed = 1; // Set lock when set to non-default speed. clif->message(fd, msg_txt(8)); // Speed changed. } else clif->message(fd, msg_txt(172)); //Speed returned to normal. - + status_calc_bl(&sd->bl, SCB_SPEED); - + return true; } @@ -808,14 +806,14 @@ ACMD(storage) { if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag) return false; - + if (storage->open(sd) == 1) { //Already open. clif->message(fd, msg_txt(250)); return false; } - + clif->message(fd, msg_txt(919)); // Storage opened. - + return true; } @@ -829,20 +827,20 @@ ACMD(guildstorage) clif->message(fd, msg_txt(252)); return false; } - + if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading) return false; - + if (sd->state.storage_flag == 1) { clif->message(fd, msg_txt(250)); return false; } - + if (sd->state.storage_flag == 2) { clif->message(fd, msg_txt(251)); return false; } - + if( gstorage->open(sd) ) { clif->message(fd, msg_txt(1201)); // Your guild's storage has already been opened by another member, try again later. return false; @@ -858,30 +856,30 @@ ACMD(guildstorage) ACMD(option) { int param1 = 0, param2 = 0, param3 = 0; - + if (!message || !*message || sscanf(message, "%d %d %d", ¶m1, ¶m2, ¶m3) < 1 || param1 < 0 || param2 < 0 || param3 < 0) {// failed to match the parameters so inform the user of the options const char* text; - + // attempt to find the setting information for this command text = atcommand_help_string( info ); - + // notify the user of the requirement to enter an option clif->message(fd, msg_txt(921)); // Please enter at least one option. - + if( text ) {// send the help text associated with this command clif->messageln( fd, text ); } - + return false; } - + sd->sc.opt1 = param1; sd->sc.opt2 = param2; pc->setoption(sd, param3); - + clif->message(fd, msg_txt(9)); // Options changed. - + return true; } @@ -896,10 +894,10 @@ ACMD(hide) { else status->set_viewdata(&sd->bl, sd->status.class_); clif->message(fd, msg_txt(10)); // Invisible: Off - + // increment the number of pvp players on the map map->list[sd->bl.m].users_pvp++; - + if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank ) { // register the player for ranking calculations sd->pvp_timer = timer->add( timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0 ); @@ -910,10 +908,10 @@ ACMD(hide) { sd->sc.option |= OPTION_INVISIBLE; sd->vd.class_ = INVISIBLE_CLASS; clif->message(fd, msg_txt(11)); // Invisible: On - + // decrement the number of pvp players on the map map->list[sd->bl.m].users_pvp--; - + if( map->list[sd->bl.m].flag.pvp && !map->list[sd->bl.m].flag.pvp_nocalcrank && sd->pvp_timer != INVALID_TIMER ) { // unregister the player for ranking timer->delete( sd->pvp_timer, pc->calc_pvprank_timer ); @@ -921,7 +919,7 @@ ACMD(hide) { } } clif->changeoption(&sd->bl); - + return true; } @@ -931,11 +929,11 @@ ACMD(hide) { ACMD(jobchange) { int job = 0, upper = 0; const char* text; - + if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) { upper = 0; - - if( message ) { + + if( message ) { int i; bool found = false; @@ -946,7 +944,7 @@ ACMD(jobchange) { found = true; } } - + // High Jobs, Babies and Third for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){ if (strncmpi(message, pc->job_name(i), 16) == 0) { @@ -954,7 +952,7 @@ ACMD(jobchange) { found = true; } } - + if (!found) { text = atcommand_help_string(info); if (text) @@ -965,14 +963,14 @@ ACMD(jobchange) { } /* WHY DO WE LIST THEM THEN? */ // Deny direct transformation into dummy jobs - if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER - || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2 - || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2) - ) { + if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER + || job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2 + || (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2) + ) { clif->message(fd, msg_txt(923)); //"You can not change to this job by command." return true; } - + if (pcdb_checkid(job)) { if (pc->jobchange(sd, job, upper) == 0) clif->message(fd, msg_txt(12)); // Your job has been changed. @@ -982,11 +980,11 @@ ACMD(jobchange) { } } else { text = atcommand_help_string(info); - if (text) - clif->messageln(fd, text); + if (text) + clif->messageln(fd, text); return false; } - + return true; } @@ -1022,15 +1020,15 @@ ACMD(alive) ACMD(kami) { unsigned int color=0; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if(*(info->command + 4) != 'c' && *(info->command + 4) != 'C') { if (!message || !*message) { clif->message(fd, msg_txt(980)); // Please enter a message (usage: @kami <message>). return false; } - + sscanf(message, "%199[^\n]", atcmd_output); if (stristr(info->command, "l") != NULL) clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); @@ -1041,7 +1039,7 @@ ACMD(kami) clif->message(fd, msg_txt(981)); // Please enter color and message (usage: @kamic <color> <message>). return false; } - + if(color > 0xFFFFFF) { clif->message(fd, msg_txt(982)); // Invalid color. return false; @@ -1057,13 +1055,13 @@ ACMD(kami) ACMD(heal) { int hp = 0, sp = 0; // [Valaris] thanks to fov - + sscanf(message, "%d %d", &hp, &sp); - + // some overflow checks if( hp == INT_MIN ) hp++; if( sp == INT_MIN ) sp++; - + if ( hp == 0 && sp == 0 ) { if (!status_percent_heal(&sd->bl, 100, 100)) clif->message(fd, msg_txt(157)); // HP and SP have already been recovered. @@ -1071,7 +1069,7 @@ ACMD(heal) clif->message(fd, msg_txt(17)); // HP, SP recovered. return true; } - + if ( hp > 0 && sp >= 0 ) { if(!status->heal(&sd->bl, hp, sp, 0)) clif->message(fd, msg_txt(157)); // HP and SP are already with the good value. @@ -1079,14 +1077,14 @@ ACMD(heal) clif->message(fd, msg_txt(17)); // HP, SP recovered. return true; } - + if ( hp < 0 && sp <= 0 ) { status->damage(NULL, &sd->bl, -hp, -sp, 0, 0); clif->damage(&sd->bl,&sd->bl, 0, 0, -hp, 0, 4, 0); clif->message(fd, msg_txt(156)); // HP or/and SP modified. return true; } - + //Opposing signs. if ( hp ) { if (hp > 0) @@ -1096,14 +1094,14 @@ ACMD(heal) clif->damage(&sd->bl,&sd->bl, 0, 0, -hp, 0, 4, 0); } } - + if ( sp ) { if (sp > 0) status->heal(&sd->bl, 0, sp, 0); else status->damage(NULL, &sd->bl, 0, -sp, 0, 0); } - + clif->message(fd, msg_txt(156)); // HP or/and SP modified. return true; } @@ -1119,7 +1117,7 @@ ACMD(item) struct item item_tmp; struct item_data *item_data; int get_count, i; - + memset(item_name, '\0', sizeof(item_name)); if (!strcmpi(info->command,"itembound") && (!message || !*message || ( @@ -1128,24 +1126,24 @@ ACMD(item) ))) { clif->message(fd, msg_txt(295)); // Please enter an item name or ID (usage: @itembound <item name/ID> <quantity> <bound_type>). return false; - } else if (!message || !*message || ( - sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 && - sscanf(message, "%99s %d", item_name, &number) < 1 )) - { - clif->message(fd, msg_txt(983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>). + } else if (!message || !*message + || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &number) < 1 + && sscanf(message, "%99s %d", item_name, &number) < 1 + )) { + clif->message(fd, msg_txt(983)); // Please enter an item name or ID (usage: @item <item name/ID> <quantity>). return false; } - + if (number <= 0) number = 1; - + if ((item_data = itemdb->search_name(item_name)) == NULL && (item_data = itemdb->exists(atoi(item_name))) == NULL) { clif->message(fd, msg_txt(19)); // Invalid item ID or name. return false; } - + if(!strcmpi(info->command,"itembound") ) { if( !(bound >= IBT_MIN && bound <= IBT_MAX) ) { clif->message(fd, msg_txt(298)); // Invalid bound type @@ -1178,9 +1176,9 @@ ACMD(item) clif->message(fd, msg_txt(498)); // Cannot create bounded pet eggs or pet armors. return false; } - get_count = 1; + get_count = 1; } - + for (i = 0; i < number; i += get_count) { // if not pet egg if (!pet->create_egg(sd, item_id)) { @@ -1188,12 +1186,12 @@ ACMD(item) item_tmp.nameid = item_id; item_tmp.identify = 1; item_tmp.bound = (unsigned char)bound; - + if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND))) clif->additem(sd, 0, 0, flag); } } - + if (flag == 0) clif->message(fd, msg_txt(18)); // Item created. return true; @@ -1210,24 +1208,24 @@ ACMD(item2) int item_id, number = 0, bound = 0; int identify = 0, refine = 0, attr = 0; int c1 = 0, c2 = 0, c3 = 0, c4 = 0; - + memset(item_name, '\0', sizeof(item_name)); - + if (!strcmpi(info->command,"itembound2") && (!message || !*message || ( sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 && sscanf(message, "%99s %d %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4, &bound) < 10 ))) { clif->message(fd, msg_txt(296)); // Please enter all parameters (usage: @itembound2 <item name/ID> <quantity> clif->message(fd, msg_txt(297)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4> <bound_type>). return false; - } else if ( !message || !*message || ( - sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 && - sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 - )) { + } else if ( !message || !*message + || ( sscanf(message, "\"%99[^\"]\" %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 + && sscanf(message, "%99s %d %d %d %d %d %d %d %d", item_name, &number, &identify, &refine, &attr, &c1, &c2, &c3, &c4) < 9 + )) { clif->message(fd, msg_txt(984)); // Please enter all parameters (usage: @item2 <item name/ID> <quantity> clif->message(fd, msg_txt(985)); // <identify_flag> <refine> <attribute> <card1> <card2> <card3> <card4>). return false; } - + if (number <= 0) number = 1; @@ -1240,7 +1238,7 @@ ACMD(item2) if ((item_data = itemdb->search_name(item_name)) != NULL || (item_data = itemdb->exists(atoi(item_name))) != NULL) item_id = item_data->nameid; - + if (item_id > 500) { int flag = 0; int loop, get_count, i; @@ -1253,7 +1251,7 @@ ACMD(item2) clif->message(fd, msg_txt(498)); // Cannot create bounded pet eggs or pet armors. return false; } - loop = number; + loop = number; get_count = 1; if (item_data->type == IT_PETEGG) { identify = 1; @@ -1278,18 +1276,18 @@ ACMD(item2) item_tmp.card[1] = c2; item_tmp.card[2] = c3; item_tmp.card[3] = c4; - + if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_COMMAND))) clif->additem(sd, 0, 0, flag); } - + if (flag == 0) clif->message(fd, msg_txt(18)); // Item created. } else { clif->message(fd, msg_txt(19)); // Invalid item ID or name. return false; } - + return true; } @@ -1299,14 +1297,14 @@ ACMD(item2) ACMD(itemreset) { int i; - + for (i = 0; i < MAX_INVENTORY; i++) { if (sd->status.inventory[i].amount && sd->status.inventory[i].equip == 0) { pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_COMMAND); } } clif->message(fd, msg_txt(20)); // All of your items have been removed. - + return true; } @@ -1318,12 +1316,12 @@ ACMD(baselevelup) int level=0, i=0, status_point=0; level = atoi(message); - + if (!message || !*message || !level) { clif->message(fd, msg_txt(986)); // Please enter a level adjustment (usage: @lvup/@blevel/@baselvlup <number of levels>). return false; } - + if (level > 0) { if (sd->status.base_level >= pc->maxbaselv(sd)) { // check for max level by Valaris clif->message(fd, msg_txt(47)); // Base level can't go any higher. @@ -1333,7 +1331,7 @@ ACMD(baselevelup) level = pc->maxbaselv(sd) - sd->status.base_level; for (i = 0; i < level; i++) status_point += pc->gets_status_point(sd->status.base_level + i); - + sd->status.status_point += status_point; sd->status.base_level += (unsigned int)level; status_calc_pc(sd, SCO_FORCE); @@ -1377,9 +1375,9 @@ ACMD(baselevelup) ACMD(joblevelup) { int level=0; - + level = atoi(message); - + if (!message || !*message || !level) { clif->message(fd, msg_txt(987)); // Please enter a level adjustment (usage: @joblvup/@jlevel/@joblvlup <number of levels>). return false; @@ -1405,7 +1403,7 @@ ACMD(joblevelup) level = sd->status.job_level-1; sd->status.job_level -= (unsigned int)level; if (sd->status.skill_point < level) - pc->resetskill(sd,0); //Reset skills since we need to subtract more points. + pc->resetskill(sd,0); //Reset skills since we need to subtract more points. if (sd->status.skill_point < level) sd->status.skill_point = 0; else @@ -1418,7 +1416,7 @@ ACMD(joblevelup) clif->updatestatus(sd, SP_NEXTJOBEXP); clif->updatestatus(sd, SP_SKILLPOINT); status_calc_pc(sd, SCO_FORCE); - + return true; } @@ -1429,7 +1427,7 @@ ACMD(help) { const char *command_name = NULL; char *default_command = "help"; AtCommandInfo *tinfo = NULL; - + if (!message || !*message) { command_name = default_command; // If no command_name specified, display help for @help. } else { @@ -1437,33 +1435,33 @@ ACMD(help) { ++message; command_name = atcommand->check_alias(message); } - + if (!atcommand->can_use2(sd, command_name, COMMAND_ATCOMMAND)) { sprintf(atcmd_output, msg_txt(153), message); // "%s is Unknown Command" clif->message(fd, atcmd_output); atcommand->get_suggestions(sd, command_name, true); return false; } - + tinfo = atcommand->get_info_byname(atcommand->check_alias(command_name)); - + if ( !tinfo || tinfo->help == NULL ) { sprintf(atcmd_output, msg_txt(988), atcommand->at_symbol, command_name); // There is no help for %c%s. clif->message(fd, atcmd_output); atcommand->get_suggestions(sd, command_name, true); return false; } - + sprintf(atcmd_output, msg_txt(989), atcommand->at_symbol, command_name); // Help for command %c%s: clif->message(fd, atcmd_output); - + { // Display aliases DBIterator* iter; AtCommandInfo *command_info; AliasInfo *alias_info = NULL; StringBuf buf; bool has_aliases = false; - + StrBuf->Init(&buf); StrBuf->AppendStr(&buf, msg_txt(990)); // Available aliases: command_info = atcommand->get_info_byname(command_name); @@ -1479,7 +1477,7 @@ ACMD(help) { clif->message(fd, StrBuf->Value(&buf)); StrBuf->Destroy(&buf); } - + // Display help contents clif->message(fd, tinfo->help); return true; @@ -1512,16 +1510,16 @@ int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) return 0; } -ACMD(pvpoff) { - +ACMD(pvpoff) +{ if (!map->list[sd->bl.m].flag.pvp) { clif->message(fd, msg_txt(160)); // PvP is already Off. return false; } - + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); map->list[sd->bl.m].flag.pvp = 0; - + if (!battle_config.pk_mode) { clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); @@ -1549,24 +1547,24 @@ int atcommand_pvpon_sub(struct block_list *bl,va_list ap) return 0; } -ACMD(pvpon) { - +ACMD(pvpon) +{ if (map->list[sd->bl.m].flag.pvp) { clif->message(fd, msg_txt(161)); // PvP is already On. return false; } - + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)); map->list[sd->bl.m].flag.pvp = 1; - + if (!battle_config.pk_mode) {// display pvp circle and rank clif->map_property_mapall(sd->bl.m, MAPPROPERTY_FREEPVPZONE); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); map->foreachinmap(atcommand->pvpon_sub,sd->bl.m, BL_PC); } - + clif->message(fd, msg_txt(32)); // PvP: On. - + return true; } @@ -1574,38 +1572,38 @@ ACMD(pvpon) { * *------------------------------------------*/ ACMD(gvgoff) { - + if (!map->list[sd->bl.m].flag.gvg) { clif->message(fd, msg_txt(162)); // GvG is already Off. return false; } - + map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); map->list[sd->bl.m].flag.gvg = 0; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_NOTHING); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); map->foreachinmap(atcommand->stopattack,sd->bl.m, BL_CHAR, 0); clif->message(fd, msg_txt(33)); // GvG: Off. - + return true; } /*========================================== * *------------------------------------------*/ -ACMD(gvgon) { - +ACMD(gvgon) +{ if (map->list[sd->bl.m].flag.gvg) { clif->message(fd, msg_txt(163)); // GvG is already On. return false; } - + map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); map->list[sd->bl.m].flag.gvg = 1; clif->map_property_mapall(sd->bl.m, MAPPROPERTY_AGITZONE); clif->maptypeproperty2(&sd->bl,ALL_SAMEMAP); clif->message(fd, msg_txt(34)); // GvG: On. - + return true; } @@ -1615,16 +1613,16 @@ ACMD(gvgon) { ACMD(model) { int hair_style = 0, hair_color = 0, cloth_color = 0; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%d %d %d", &hair_style, &hair_color, &cloth_color) < 1) { sprintf(atcmd_output, msg_txt(991), // Please enter at least one value (usage: @model <hair ID: %d-%d> <hair color: %d-%d> <clothes color: %d-%d>). MIN_HAIR_STYLE, MAX_HAIR_STYLE, MIN_HAIR_COLOR, MAX_HAIR_COLOR, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); clif->message(fd, atcmd_output); return false; } - + if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE && hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR && cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) { @@ -1636,7 +1634,7 @@ ACMD(model) clif->message(fd, msg_txt(37)); // An invalid number was specified. return false; } - + return true; } @@ -1646,15 +1644,15 @@ ACMD(model) ACMD(dye) { int cloth_color = 0; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%d", &cloth_color) < 1) { sprintf(atcmd_output, msg_txt(992), MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); // Please enter a clothes color (usage: @dye/@ccolor <clothes color: %d-%d>). clif->message(fd, atcmd_output); return false; } - + if (cloth_color >= MIN_CLOTH_COLOR && cloth_color <= MAX_CLOTH_COLOR) { pc->changelook(sd, LOOK_CLOTHES_COLOR, cloth_color); clif->message(fd, msg_txt(36)); // Appearance changed. @@ -1662,7 +1660,7 @@ ACMD(dye) clif->message(fd, msg_txt(37)); // An invalid number was specified. return false; } - + return true; } @@ -1672,15 +1670,15 @@ ACMD(dye) ACMD(hair_style) { int hair_style = 0; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%d", &hair_style) < 1) { sprintf(atcmd_output, msg_txt(993), MIN_HAIR_STYLE, MAX_HAIR_STYLE); // Please enter a hair style (usage: @hairstyle/@hstyle <hair ID: %d-%d>). clif->message(fd, atcmd_output); return false; } - + if (hair_style >= MIN_HAIR_STYLE && hair_style <= MAX_HAIR_STYLE) { pc->changelook(sd, LOOK_HAIR, hair_style); clif->message(fd, msg_txt(36)); // Appearance changed. @@ -1688,7 +1686,7 @@ ACMD(hair_style) clif->message(fd, msg_txt(37)); // An invalid number was specified. return false; } - + return true; } @@ -1698,15 +1696,15 @@ ACMD(hair_style) ACMD(hair_color) { int hair_color = 0; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%d", &hair_color) < 1) { sprintf(atcmd_output, msg_txt(994), MIN_HAIR_COLOR, MAX_HAIR_COLOR); // Please enter a hair color (usage: @haircolor/@hcolor <hair color: %d-%d>). clif->message(fd, atcmd_output); return false; } - + if (hair_color >= MIN_HAIR_COLOR && hair_color <= MAX_HAIR_COLOR) { pc->changelook(sd, LOOK_HAIR_COLOR, hair_color); clif->message(fd, msg_txt(36)); // Appearance changed. @@ -1714,7 +1712,7 @@ ACMD(hair_color) clif->message(fd, msg_txt(37)); // An invalid number was specified. return false; } - + return true; } @@ -1725,7 +1723,7 @@ ACMD(go) { int i; int town = INT_MAX; // Initialized to INT_MAX instead of -1 to avoid conflicts with those who map [-3:-1] to @memo locations. char map_name[MAP_NAME_LENGTH]; - + const struct { char map[MAP_NAME_LENGTH]; int x, y; @@ -1772,23 +1770,23 @@ ACMD(go) { { MAP_MALAYA, 242, 211, 5 }, // 34 = Malaya Port { MAP_ECLAGE, 110, 39, 3 }, // 35 = Eclage }; - + memset(map_name, '\0', sizeof(map_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%11s", map_name) < 1) { // no value matched so send the list of locations const char* text; - + // attempt to find the text help string text = atcommand_help_string( info ); - + clif->message(fd, msg_txt(38)); // Invalid location number, or name. - + if( text ) {// send the text to the client clif->messageln( fd, text ); } - + return false; } @@ -1852,7 +1850,7 @@ ACMD(go) { clif->message(fd, msg_txt(38)); // Invalid location number or name. return false; } - + return true; } @@ -1870,11 +1868,11 @@ ACMD(monster) int i, k, range; short mx, my; unsigned int size; - + memset(name, '\0', sizeof(name)); memset(monster, '\0', sizeof(monster)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message) { clif->message(fd, msg_txt(80)); // Please specify a display name or monster name/id. return false; @@ -1895,35 +1893,35 @@ ACMD(monster) clif->message(fd, msg_txt(80)); // Give a display name and monster name/id please. return false; } - + if ((mob_id = mob->db_searchname(monster)) == 0) // check name first (to avoid possible name beginning by a number) mob_id = mob->db_checkid(atoi(monster)); - + if (mob_id == 0) { clif->message(fd, msg_txt(40)); // Invalid monster ID or name. return false; } - + if (number <= 0) number = 1; - + if( !name[0] ) strcpy(name, "--ja--"); - + // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit) number = battle_config.atc_spawn_quantity_limit; - + if (strcmpi(info->command, "monstersmall") == 0) size = SZ_MEDIUM; else if (strcmpi(info->command, "monsterbig") == 0) size = SZ_BIG; else size = SZ_SMALL; - + if (battle_config.etc_log) ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y); - + count = 0; range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { @@ -1931,7 +1929,7 @@ ACMD(monster) k = mob->once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE|(mob_id == MOBID_EMPERIUM?0x200:0x0)); count += (k != 0) ? 1 : 0; } - + if (count != 0) if (number == count) clif->message(fd, msg_txt(39)); // All monster summoned! @@ -1943,7 +1941,7 @@ ACMD(monster) clif->message(fd, msg_txt(40)); // Invalid monster ID or name. return false; } - + return true; } @@ -1954,13 +1952,13 @@ int atkillmonster_sub(struct block_list *bl, va_list ap) { struct mob_data *md; int flag; - + nullpo_ret(md=(struct mob_data *)bl); flag = va_arg(ap, int); - + if (md->guardian_data) return 0; //Do not touch WoE mobs! - + if (flag) status_zap(bl,md->status.hp, 0); else @@ -1971,22 +1969,22 @@ int atkillmonster_sub(struct block_list *bl, va_list ap) ACMD(killmonster) { int map_id, drop_flag; char map_name[MAP_NAME_LENGTH_EXT]; - + memset(map_name, '\0', sizeof(map_name)); - + if (!message || !*message || sscanf(message, "%15s", map_name) < 1) map_id = sd->bl.m; else { if ((map_id = map->mapname2mapid(map_name)) < 0) map_id = sd->bl.m; } - + drop_flag = strcmpi(info->command, "killmonster2"); - + map->foreachinmap(atcommand->atkillmonster_sub, map_id, BL_MOB, -drop_flag); - + clif->message(fd, msg_txt(165)); // All monsters killed! - + return true; } @@ -1997,9 +1995,9 @@ ACMD(refine) { int i,j, position = 0, refine = 0, current_position, final_refine; int count; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%d %d", &position, &refine) < 2) { clif->message(fd, msg_txt(996)); // Please enter a position and an amount (usage: @refine <equip position> <+/- amount>). sprintf(atcmd_output, msg_txt(997), EQP_HEAD_LOW); // %d: Lower Headgear @@ -2024,9 +2022,9 @@ ACMD(refine) clif->message(fd, atcmd_output); return false; } - + refine = cap_value(refine, -MAX_REFINE, MAX_REFINE); - + count = 0; for (j = 0; j < EQI_MAX; j++) { if ((i = sd->equip_index[j]) < 0) @@ -2038,10 +2036,10 @@ ACMD(refine) continue; if(j == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == i || sd->equip_index[EQI_HEAD_LOW] == i)) continue; - + if(position && !(sd->status.inventory[i].equip & position)) continue; - + final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE); if (sd->status.inventory[i].refine != final_refine) { sd->status.inventory[i].refine = final_refine; @@ -2055,7 +2053,7 @@ ACMD(refine) count++; } } - + if (count == 0) clif->message(fd, msg_txt(166)); // No item has been refined. else if (count == 1) @@ -2064,7 +2062,7 @@ ACMD(refine) sprintf(atcmd_output, msg_txt(168), count); // %d items have been refined. clif->message(fd, atcmd_output); } - + return true; } @@ -2077,10 +2075,10 @@ ACMD(produce) int item_id, attribute = 0, star = 0; struct item_data *item_data; struct item tmp_item; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(item_name, '\0', sizeof(item_name)); - + if (!message || !*message || ( sscanf(message, "\"%99[^\"]\" %d %d", item_name, &attribute, &star) < 1 && sscanf(message, "%99s %d %d", item_name, &attribute, &star) < 1 @@ -2088,15 +2086,15 @@ ACMD(produce) clif->message(fd, msg_txt(1007)); // Please enter at least one item name/ID (usage: @produce <equip name/ID> <element> <# of very's>). return false; } - + if ( (item_data = itemdb->search_name(item_name)) == NULL && (item_data = itemdb->exists(atoi(item_name))) == NULL ) { clif->message(fd, msg_txt(170)); //This item is not an equipment. return false; } - + item_id = item_data->nameid; - + if (itemdb->isequip2(item_data)) { int flag = 0; if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE) @@ -2114,7 +2112,7 @@ ACMD(produce) tmp_item.card[3] = GetWord(sd->status.char_id, 1); clif->produce_effect(sd, 0, item_id); clif->misceffect(&sd->bl, 3); - + if ((flag = pc->additem(sd, &tmp_item, 1, LOG_TYPE_COMMAND))) clif->additem(sd, 0, 0, flag); } else { @@ -2122,7 +2120,7 @@ ACMD(produce) clif->message(fd, atcmd_output); return false; } - + return true; } @@ -2132,9 +2130,9 @@ ACMD(produce) ACMD(memo) { int position = 0; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if( !message || !*message || sscanf(message, "%d", &position) < 1 ) { int i; @@ -2146,17 +2144,17 @@ ACMD(memo) else sprintf(atcmd_output, msg_txt(171), i); // %d - void clif->message(sd->fd, atcmd_output); - } + } return true; - } - + } + if( position < 0 || position >= MAX_MEMOPOINTS ) { sprintf(atcmd_output, msg_txt(1008), 0, MAX_MEMOPOINTS-1); // Please enter a valid position (usage: @memo <memo_position:%d-%d>). clif->message(fd, atcmd_output); return false; } - + pc->memo(sd, position); return true; } @@ -2166,9 +2164,9 @@ ACMD(memo) *------------------------------------------*/ ACMD(gat) { int y; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + for (y = 2; y >= -2; y--) { sprintf(atcmd_output, "%s (x= %d, y= %d) %02X %02X %02X %02X %02X", map->list[sd->bl.m].name, sd->bl.x - 2, sd->bl.y + y, @@ -2177,10 +2175,10 @@ ACMD(gat) { map->getcell(sd->bl.m, sd->bl.x, sd->bl.y + y, CELL_GETTYPE), map->getcell(sd->bl.m, sd->bl.x + 1, sd->bl.y + y, CELL_GETTYPE), map->getcell(sd->bl.m, sd->bl.x + 2, sd->bl.y + y, CELL_GETTYPE)); - + clif->message(fd, atcmd_output); } - + return true; } @@ -2190,19 +2188,19 @@ ACMD(gat) { ACMD(displaystatus) { int i, type, flag, tick, val1 = 0, val2 = 0, val3 = 0; - + if (!message || !*message || (i = sscanf(message, "%d %d %d %d %d %d", &type, &flag, &tick, &val1, &val2, &val3)) < 1) { clif->message(fd, msg_txt(1009)); // Please enter a status type/flag (usage: @displaystatus <status type> <flag> <tick> {<val1> {<val2> {<val3>}}}). return false; } if (i < 2) flag = 1; if (i < 3) tick = 0; - + if( flag == 0 ) clif->sc_end(&sd->bl,sd->bl.id,AREA,type); else clif->status_change(&sd->bl, type, flag, tick, val1, val2, val3); - + return true; } @@ -2213,12 +2211,12 @@ ACMD(statuspoint) { int point; unsigned int new_status_point; - + if (!message || !*message || (point = atoi(message)) == 0) { clif->message(fd, msg_txt(1010)); // Please enter a number (usage: @stpoint <number of points>). return false; } - + if(point < 0) { if(sd->status.status_point < (unsigned int)(-point)) @@ -2238,7 +2236,7 @@ ACMD(statuspoint) { new_status_point = sd->status.status_point + point; } - + if (new_status_point != sd->status.status_point) { sd->status.status_point = new_status_point; clif->updatestatus(sd, SP_STATUSPOINT); @@ -2250,7 +2248,7 @@ ACMD(statuspoint) clif->message(fd, msg_txt(149)); // Unable to increase the number/value. return false; } - + return true; } @@ -2261,12 +2259,12 @@ ACMD(skillpoint) { int point; unsigned int new_skill_point; - + if (!message || !*message || (point = atoi(message)) == 0) { clif->message(fd, msg_txt(1011)); // Please enter a number (usage: @skpoint <number of points>). return false; } - + if(point < 0) { if(sd->status.skill_point < (unsigned int)(-point)) @@ -2286,7 +2284,7 @@ ACMD(skillpoint) { new_skill_point = sd->status.skill_point + point; } - + if (new_skill_point != sd->status.skill_point) { sd->status.skill_point = new_skill_point; clif->updatestatus(sd, SP_SKILLPOINT); @@ -2298,7 +2296,7 @@ ACMD(skillpoint) clif->message(fd, msg_txt(149)); // Unable to increase the number/value. return false; } - + return true; } @@ -2308,12 +2306,12 @@ ACMD(skillpoint) ACMD(zeny) { int zeny=0, ret=-1; - + if (!message || !*message || (zeny = atoi(message)) == 0) { clif->message(fd, msg_txt(1012)); // Please enter an amount (usage: @zeny <amount>). return false; } - + if(zeny > 0){ if((ret=pc->getzeny(sd,zeny,LOG_TYPE_COMMAND,NULL)) == 1) clif->message(fd, msg_txt(149)); // Unable to increase the number/value. @@ -2338,34 +2336,34 @@ ACMD(param) { int i, value = 0, new_value, max; const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" }; short* stats[6]; - //we don't use direct initialization because it isn't part of the c standard. - + //we don't use direct initialization because it isn't part of the c standard. + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) { clif->message(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>). return false; } - + ARR_FIND( 0, ARRAYLENGTH(param), i, strcmpi(info->command, param[i]) == 0 ); - + if( i == ARRAYLENGTH(param) || i > MAX_STATUS_TYPE) { // normally impossible... clif->message(fd, msg_txt(1013)); // Please enter a valid value (usage: @str/@agi/@vit/@int/@dex/@luk <+/-adjustment>). return false; } - + stats[0] = &sd->status.str; stats[1] = &sd->status.agi; stats[2] = &sd->status.vit; stats[3] = &sd->status.int_; stats[4] = &sd->status.dex; stats[5] = &sd->status.luk; - + if( battle_config.atcommand_max_stat_bypass ) max = SHRT_MAX; else max = pc_maxparameter(sd); - + if(value < 0 && *stats[i] <= -value) { new_value = 1; } else if(max - *stats[i] < value) { @@ -2373,7 +2371,7 @@ ACMD(param) { } else { new_value = *stats[i] + value; } - + if (new_value != *stats[i]) { *stats[i] = new_value; clif->updatestatus(sd, SP_STR + i); @@ -2387,7 +2385,7 @@ ACMD(param) { clif->message(fd, msg_txt(149)); // Unable to increase the number/value. return false; } - + return true; } @@ -2397,15 +2395,15 @@ ACMD(param) { ACMD(stat_all) { int index, count, value, max, new_value; short* stats[6]; - //we don't use direct initialization because it isn't part of the c standard. - + //we don't use direct initialization because it isn't part of the c standard. + stats[0] = &sd->status.str; stats[1] = &sd->status.agi; stats[2] = &sd->status.vit; stats[3] = &sd->status.int_; stats[4] = &sd->status.dex; stats[5] = &sd->status.luk; - + if (!message || !*message || sscanf(message, "%d", &value) < 1 || value == 0) { value = pc_maxparameter(sd); max = pc_maxparameter(sd); @@ -2415,17 +2413,16 @@ ACMD(stat_all) { else max = pc_maxparameter(sd); } - + count = 0; for (index = 0; index < ARRAYLENGTH(stats); index++) { - if (value > 0 && *stats[index] > max - value) new_value = max; else if (value < 0 && *stats[index] <= -value) new_value = 1; else new_value = *stats[index] +value; - + if (new_value != (int)*stats[index]) { *stats[index] = new_value; clif->updatestatus(sd, SP_STR + index); @@ -2433,7 +2430,7 @@ ACMD(stat_all) { count++; } } - + if (count > 0) { // if at least 1 stat modified status_calc_pc(sd, SCO_FORCE); clif->message(fd, msg_txt(84)); // All stats changed! @@ -2444,7 +2441,7 @@ ACMD(stat_all) { clif->message(fd, msg_txt(178)); // You cannot increase that stat anymore. return false; } - + return true; } @@ -2455,12 +2452,12 @@ ACMD(guildlevelup) { int level = 0; int16 added_level; struct guild *guild_info; - + if (!message || !*message || sscanf(message, "%d", &level) < 1 || level == 0) { clif->message(fd, msg_txt(1014)); // Please enter a valid level (usage: @guildlvup/@guildlvlup <# of levels>). return false; } - + if (sd->status.guild_id <= 0 || (guild_info = sd->guild) == NULL) { clif->message(fd, msg_txt(43)); // You're not in a guild. return false; @@ -2471,13 +2468,13 @@ ACMD(guildlevelup) { return false; } #endif // 0 - + if (level > INT16_MAX || (level > 0 && level > MAX_GUILDLEVEL - guild_info->guild_lv)) // fix positive overflow level = MAX_GUILDLEVEL - guild_info->guild_lv; else if (level < INT16_MIN || (level < 0 && level < 1 - guild_info->guild_lv)) // fix negative overflow level = 1 - guild_info->guild_lv; added_level = (int16)level; - + if (added_level != 0) { intif->guild_change_basicinfo(guild_info->guild_id, GBI_GUILDLV, &added_level, sizeof(added_level)); clif->message(fd, msg_txt(179)); // Guild level changed. @@ -2485,7 +2482,7 @@ ACMD(guildlevelup) { clif->message(fd, msg_txt(45)); // Guild level change failed. return false; } - + return true; } @@ -2496,12 +2493,12 @@ ACMD(makeegg) { struct item_data *item_data; int id, pet_id; - + if (!message || !*message) { clif->message(fd, msg_txt(1015)); // Please enter a monster/egg name/ID (usage: @makeegg <pet>). return false; } - + if ((item_data = itemdb->search_name(message)) != NULL) // for egg name id = item_data->nameid; else @@ -2509,7 +2506,7 @@ ACMD(makeegg) ; else id = atoi(message); - + pet_id = pet->search_petDB_index(id, PET_CLASS); if (pet_id < 0) pet_id = pet->search_petDB_index(id, PET_EGG); @@ -2524,7 +2521,7 @@ ACMD(makeegg) clif->message(fd, msg_txt(180)); // The monster/egg name/id doesn't exist. return false; } - + return true; } @@ -2539,7 +2536,7 @@ ACMD(hatch) clif->message(fd, msg_txt(181)); // You already have a pet. return false; } - + return true; } @@ -2550,29 +2547,29 @@ ACMD(petfriendly) { int friendly; struct pet_data *pd; - + if (!message || !*message || (friendly = atoi(message)) < 0) { clif->message(fd, msg_txt(1016)); // Please enter a valid value (usage: @petfriendly <0-1000>). return false; } - + pd = sd->pd; if (!pd) { clif->message(fd, msg_txt(184)); // Sorry, but you have no pet. return false; } - + if (friendly < 0 || friendly > 1000) { clif->message(fd, msg_txt(37)); // An invalid number was specified. return false; } - + if (friendly == pd->pet.intimate) { clif->message(fd, msg_txt(183)); // Pet intimacy is already at maximum. return false; } - + pet->set_intimate(pd, friendly); clif->send_petstatus(sd); clif->message(fd, msg_txt(182)); // Pet intimacy changed. @@ -2586,12 +2583,12 @@ ACMD(pethungry) { int hungry; struct pet_data *pd; - + if (!message || !*message || (hungry = atoi(message)) < 0) { clif->message(fd, msg_txt(1017)); // Please enter a valid number (usage: @pethungry <0-100>). return false; } - + pd = sd->pd; if (!sd->status.pet_id || !pd) { clif->message(fd, msg_txt(184)); // Sorry, but you have no pet. @@ -2605,11 +2602,11 @@ ACMD(pethungry) clif->message(fd, msg_txt(186)); // Pet hunger is already at maximum. return false; } - + pd->pet.hungry = hungry; clif->send_petstatus(sd); clif->message(fd, msg_txt(185)); // Pet hunger changed. - + return true; } @@ -2628,12 +2625,12 @@ ACMD(petrename) clif->message(fd, msg_txt(188)); // You can already rename your pet. return false; } - + pd->pet.rename_flag = 0; intif->save_petdata(sd->status.account_id, &pd->pet); clif->send_petstatus(sd); clif->message(fd, msg_txt(187)); // You can now rename your pet. - + return true; } @@ -2642,24 +2639,23 @@ ACMD(petrename) *------------------------------------------*/ ACMD(recall) { struct map_session_data *pl_sd = NULL; - - + if (!message || !*message) { clif->message(fd, msg_txt(1018)); // Please enter a player name (usage: @recall <char name/ID>). return false; } - + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { clif->message(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player. return false; } - + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1019)); // You are not authorized to warp someone to this map. return false; @@ -2674,7 +2670,7 @@ ACMD(recall) { pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); sprintf(atcmd_output, msg_txt(46), pl_sd->status.name); // %s recalled! clif->message(fd, atcmd_output); - + return true; } @@ -2684,17 +2680,17 @@ ACMD(recall) { *------------------------------------------*/ ACMD(char_block) { - + memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - + if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif->message(fd, msg_txt(1021)); // Please enter a player name (usage: @block <char name>). return false; } - + chrif->char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it. - + return true; } @@ -2719,17 +2715,17 @@ ACMD(char_ban) int year, month, day, hour, minute, second, value; time_t timestamp; struct tm *tmtime; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - + if (!message || !*message || sscanf(message, "%255s %23[^\n]", atcmd_output, atcmd_player_name) < 2) { clif->message(fd, msg_txt(1022)); // Please enter ban time and a player name (usage: @ban <time> <char name>). return false; } - + atcmd_output[sizeof(atcmd_output)-1] = '\0'; - + modif_p = atcmd_output; year = month = day = hour = minute = second = 0; while (modif_p[0] != '\0') { @@ -2787,10 +2783,10 @@ ACMD(char_ban) clif->message(fd,msg_txt(1023)); // You are not allowed to reduce the length of a ban. return false; } - + chrif->char_ask_name(sd->status.account_id, atcmd_player_name, !strcmpi(info->command,"charban") ? 6 : 2, year, month, day, hour, minute, second); // type: 2 - ban; 6 - charban clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it. - + return true; } @@ -2799,18 +2795,17 @@ ACMD(char_ban) *------------------------------------------*/ ACMD(char_unblock) { - memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - + if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif->message(fd, msg_txt(1024)); // Please enter a player name (usage: @unblock <char name>). return false; } - + // send answer to login server via char-server chrif->char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it. - + return true; } @@ -2819,48 +2814,47 @@ ACMD(char_unblock) *------------------------------------------*/ ACMD(char_unban) { - memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - + if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif->message(fd, msg_txt(1025)); // Please enter a player name (usage: @unban <char name>). return false; } - + // send answer to login server via char-server chrif->char_ask_name(sd->status.account_id, atcmd_player_name, !strcmpi(info->command,"charunban") ? 7 : 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban account; type 7 - unban character clif->message(fd, msg_txt(88)); // Character name sent to char-server to ask it. - + return true; } /*========================================== * *------------------------------------------*/ -ACMD(night) { - +ACMD(night) +{ if (map->night_flag != 1) { pc->map_night_timer(pc->night_timer_tid, 0, 0, 1); } else { clif->message(fd, msg_txt(89)); // Night mode is already enabled. return false; } - + return true; } /*========================================== * *------------------------------------------*/ -ACMD(day) { - +ACMD(day) +{ if (map->night_flag != 0) { pc->map_day_timer(pc->day_timer_tid, 0, 0, 1); } else { clif->message(fd, msg_txt(90)); // Day mode is already enabled. return false; } - + return true; } @@ -2871,7 +2865,7 @@ ACMD(doom) { struct map_session_data* pl_sd; struct s_mapiterator* iter; - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { @@ -2883,9 +2877,9 @@ ACMD(doom) } } mapit->free(iter); - + clif->message(fd, msg_txt(62)); // Judgment was made. - + return true; } @@ -2896,7 +2890,7 @@ ACMD(doommap) { struct map_session_data* pl_sd; struct s_mapiterator* iter; - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { @@ -2908,19 +2902,19 @@ ACMD(doommap) } } mapit->free(iter); - + clif->message(fd, msg_txt(62)); // Judgment was made. - + return true; } /*========================================== * *------------------------------------------*/ -void atcommand_raise_sub(struct map_session_data* sd) { - +void atcommand_raise_sub(struct map_session_data* sd) +{ status->revive(&sd->bl, 100, 100); - + clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1); clif->message(sd->fd, msg_txt(63)); // Mercy has been shown. } @@ -2932,15 +2926,15 @@ ACMD(raise) { struct map_session_data* pl_sd; struct s_mapiterator* iter; - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) if( pc_isdead(pl_sd) ) atcommand->raise_sub(pl_sd); mapit->free(iter); - + clif->message(fd, msg_txt(64)); // Mercy has been granted. - + return true; } @@ -2951,15 +2945,15 @@ ACMD(raisemap) { struct map_session_data* pl_sd; struct s_mapiterator* iter; - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) ) atcommand->raise_sub(pl_sd); mapit->free(iter); - + clif->message(fd, msg_txt(64)); // Mercy has been granted. - + return true; } @@ -2969,27 +2963,27 @@ ACMD(raisemap) ACMD(kick) { struct map_session_data *pl_sd; - + memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - + if (!message || !*message) { clif->message(fd, msg_txt(1026)); // Please enter a player name (usage: @kick <char name/ID>). return false; } - + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } - + clif->GM_kick(sd, pl_sd); - + return true; } @@ -3000,7 +2994,7 @@ ACMD(kickall) { struct map_session_data* pl_sd; struct s_mapiterator* iter; - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { @@ -3010,9 +3004,9 @@ ACMD(kickall) } } mapit->free(iter); - + clif->message(fd, msg_txt(195)); // All players have been kicked! - + return true; } @@ -3025,7 +3019,7 @@ ACMD(allskill) sd->status.skill_point = 0; // 0 skill points clif->updatestatus(sd, SP_SKILLPOINT); // update clif->message(fd, msg_txt(76)); // All skills have been added to your skill tree. - + return true; } @@ -3035,21 +3029,21 @@ ACMD(allskill) ACMD(questskill) { uint16 skill_id, index; - + if (!message || !*message || (skill_id = atoi(message)) <= 0) {// also send a list of skills applicable to this command const char* text; - + // attempt to find the text corresponding to this command text = atcommand_help_string( info ); - + // send the error message as always clif->message(fd, msg_txt(1027)); // Please enter a quest skill number. - + if( text ) {// send the skill ID list associated with this command clif->messageln( fd, text ); } - + return false; } if( !(index = skill->get_index(skill_id)) ) { @@ -3064,10 +3058,10 @@ ACMD(questskill) clif->message(fd, msg_txt(196)); // You already have this quest skill. return false; } - + pc->skill(sd, skill_id, 1, 0); clif->message(fd, msg_txt(70)); // You have learned the skill. - + return true; } @@ -3077,21 +3071,21 @@ ACMD(questskill) ACMD(lostskill) { uint16 skill_id, index; - + if (!message || !*message || (skill_id = atoi(message)) <= 0) {// also send a list of skills applicable to this command const char* text; - + // attempt to find the text corresponding to this command text = atcommand_help_string( info ); - + // send the error message as always clif->message(fd, msg_txt(1027)); // Please enter a quest skill number. - + if( text ) {// send the skill ID list associated with this command clif->messageln( fd, text ); } - + return false; } if ( !( index = skill->get_index(skill_id) ) ) { @@ -3106,12 +3100,12 @@ ACMD(lostskill) clif->message(fd, msg_txt(201)); // You don't have this quest skill. return false; } - + sd->status.skill[index].lv = 0; sd->status.skill[index].flag = 0; clif->deleteskill(sd,skill_id); clif->message(fd, msg_txt(71)); // You have forgotten the skill. - + return true; } @@ -3122,9 +3116,9 @@ ACMD(spiritball) { int max_spiritballs; int number; - + max_spiritballs = min(ARRAYLENGTH(sd->spirit_timer), 0x7FFF); - + if( !message || !*message || (number = atoi(message)) < 0 || number > max_spiritballs ) { char msg[CHAT_SIZE_MAX]; @@ -3132,13 +3126,13 @@ ACMD(spiritball) clif->message(fd, msg); return false; } - + if( sd->spiritball > 0 ) pc->delspiritball(sd, sd->spiritball, 1); sd->spiritball = number; clif->spiritball(&sd->bl); // no message, player can look the difference - + return true; } @@ -3148,16 +3142,16 @@ ACMD(spiritball) ACMD(party) { char party_name[NAME_LENGTH]; - + memset(party_name, '\0', sizeof(party_name)); - + if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) { clif->message(fd, msg_txt(1029)); // Please enter a party name (usage: @party <party_name>). return false; } - + party->create(sd, party_name, 0, 0); - + return true; } @@ -3168,25 +3162,24 @@ ACMD(guild) { char guild_name[NAME_LENGTH]; int prev; - + memset(guild_name, '\0', sizeof(guild_name)); - + if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) { clif->message(fd, msg_txt(1030)); // Please enter a guild name (usage: @guild <guild_name>). return false; } - + prev = battle_config.guild_emperium_check; battle_config.guild_emperium_check = 0; guild->create(sd, guild_name); battle_config.guild_emperium_check = prev; - + return true; } ACMD(breakguild) { - if (sd->status.guild_id) { // Check if the player has a guild struct guild *g; g = sd->guild; // Search the guild @@ -3222,11 +3215,11 @@ ACMD(agitstart) { clif->message(fd, msg_txt(73)); // War of Emperium is currently in progress. return false; } - + map->agit_flag = 1; guild->agit_start(); clif->message(fd, msg_txt(72)); // War of Emperium has been initiated. - + return true; } @@ -3238,11 +3231,11 @@ ACMD(agitstart2) { clif->message(fd, msg_txt(404)); // "War of Emperium SE is currently in progress." return false; } - + map->agit2_flag = 1; guild->agit2_start(); clif->message(fd, msg_txt(403)); // "War of Emperium SE has been initiated." - + return true; } @@ -3254,11 +3247,11 @@ ACMD(agitend) { clif->message(fd, msg_txt(75)); // War of Emperium is currently not in progress. return false; } - + map->agit_flag = 0; guild->agit_end(); clif->message(fd, msg_txt(74)); // War of Emperium has been ended. - + return true; } @@ -3270,11 +3263,11 @@ ACMD(agitend2) { clif->message(fd, msg_txt(406)); // "War of Emperium SE is currently not in progress." return false; } - + map->agit2_flag = 0; guild->agit2_end(); clif->message(fd, msg_txt(405)); // "War of Emperium SE has been ended." - + return true; } @@ -3294,15 +3287,15 @@ ACMD(idsearch) char item_name[100]; unsigned int i, match; struct item_data *item_array[MAX_SEARCH]; - + memset(item_name, '\0', sizeof(item_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%99s", item_name) < 0) { clif->message(fd, msg_txt(1031)); // Please enter part of an item name (usage: @idsearch <part_of_item_name>). return false; } - + sprintf(atcmd_output, msg_txt(77), item_name); // Search results for '%s' (name: id): clif->message(fd, atcmd_output); match = itemdb->search_name_array(item_array, MAX_SEARCH, item_name, 0); @@ -3317,7 +3310,7 @@ ACMD(idsearch) } sprintf(atcmd_output, msg_txt(79), match); // %d results found. clif->message(fd, atcmd_output); - + return true; } @@ -3329,14 +3322,14 @@ ACMD(recallall) struct map_session_data* pl_sd; struct s_mapiterator* iter; int count; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp someone to your current map. return false; } - + count = 0; iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { @@ -3355,13 +3348,13 @@ ACMD(recallall) } } mapit->free(iter); - + clif->message(fd, msg_txt(92)); // All characters recalled! if (count) { sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled. clif->message(fd, atcmd_output); } - + return true; } @@ -3375,29 +3368,29 @@ ACMD(guildrecall) int count; char guild_name[NAME_LENGTH]; struct guild *g; - + memset(guild_name, '\0', sizeof(guild_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) { clif->message(fd, msg_txt(1034)); // Please enter a guild name/ID (usage: @guildrecall <guild_name/ID>). return false; } - + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp someone to your current map. return false; } - + if ((g = guild->searchname(guild_name)) == NULL && // name first to avoid error when name begin with a number (g = guild->search(atoi(message))) == NULL) { clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online. return false; } - + count = 0; - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { @@ -3411,14 +3404,14 @@ ACMD(guildrecall) } } mapit->free(iter); - + sprintf(atcmd_output, msg_txt(93), g->name); // All online characters of the %s guild have been recalled to your position. clif->message(fd, atcmd_output); if (count) { sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled. clif->message(fd, atcmd_output); } - + return true; } @@ -3432,29 +3425,29 @@ ACMD(partyrecall) char party_name[NAME_LENGTH]; struct party_data *p; int count; - + memset(party_name, '\0', sizeof(party_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) { clif->message(fd, msg_txt(1035)); // Please enter a party name/ID (usage: @partyrecall <party_name/ID>). return false; } - + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp someone to your current map. return false; } - + if ((p = party->searchname(party_name)) == NULL && // name first to avoid error when name begin with a number (p = party->search(atoi(message))) == NULL) { clif->message(fd, msg_txt(96)); // Incorrect name or ID, or no one from the party is online. return false; } - + count = 0; - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) { @@ -3467,14 +3460,14 @@ ACMD(partyrecall) } } mapit->free(iter); - + sprintf(atcmd_output, msg_txt(95), p->party.name); // All online characters of the %s party have been recalled to your position. clif->message(fd, atcmd_output); if (count) { sprintf(atcmd_output, msg_txt(1033), count); // Because you are not authorized to warp from some maps, %d player(s) have not been recalled. clif->message(fd, atcmd_output); } - + return true; } @@ -3485,7 +3478,7 @@ ACMD(reloaditemdb) { itemdb->reload(); clif->message(fd, msg_txt(97)); // Item database has been reloaded. - + return true; } @@ -3500,7 +3493,7 @@ ACMD(reloadmobdb) { mercenary->read_skilldb(); elemental->reload_db(); clif->message(fd, msg_txt(98)); // Monster database has been reloaded. - + return true; } @@ -3514,7 +3507,7 @@ ACMD(reloadskilldb) elemental->reload_skilldb(); mercenary->read_skilldb(); clif->message(fd, msg_txt(99)); // Skill database has been reloaded. - + return true; } @@ -3523,21 +3516,21 @@ ACMD(reloadskilldb) *------------------------------------------*/ ACMD(reloadatcommand) { config_t run_test; - + if (libconfig->read_file(&run_test, "conf/groups.conf")) { clif->message(fd, msg_txt(1036)); // Error reading groups.conf, reload failed. return false; } - + libconfig->destroy(&run_test); - + if (libconfig->read_file(&run_test, map->ATCOMMAND_CONF_FILENAME)) { clif->message(fd, msg_txt(1037)); // Error reading atcommand.conf, reload failed. return false; } - + libconfig->destroy(&run_test); - + atcommand->doload(); pcg->reload(); clif->message(fd, msg_txt(254)); @@ -3550,9 +3543,9 @@ ACMD(reloadbattleconf) { struct Battle_Config prev_config; memcpy(&prev_config, &battle_config, sizeof(prev_config)); - + battle->config_read(map->BATTLE_CONF_FILENAME); - + if( prev_config.item_rate_mvp != battle_config.item_rate_mvp || prev_config.item_rate_common != battle_config.item_rate_common || prev_config.item_rate_common_boss != battle_config.item_rate_common_boss @@ -3583,8 +3576,7 @@ ACMD(reloadbattleconf) || prev_config.item_drop_treasure_max != battle_config.item_drop_treasure_max || prev_config.base_exp_rate != battle_config.base_exp_rate || prev_config.job_exp_rate != battle_config.job_exp_rate - ) - { // Exp or Drop rates changed. + ) { // Exp or Drop rates changed. mob->reload(); //Needed as well so rate changes take effect. chrif->ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common); } @@ -3618,7 +3610,7 @@ ACMD(reloadscript) { //atcommand_broadcast( fd, sd, "@broadcast", "Server is reloading scripts..." ); //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" ); - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (pl_sd->npc_id || pl_sd->npc_shopid) { @@ -3638,14 +3630,14 @@ ACMD(reloadscript) { } } mapit->free(iter); - + flush_fifos(); map->reloadnpc(true, NULL, 0); // reload config files seeking for npcs script->reload(); npc->reload(); - + clif->message(fd, msg_txt(100)); // Scripts have been reloaded. - + return true; } @@ -3667,33 +3659,33 @@ ACMD(mapinfo) { int i, m_id, chat_num = 0, list = 0, vend_num = 0; unsigned short m_index; char mapname[24]; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(mapname, '\0', sizeof(mapname)); memset(direction, '\0', sizeof(direction)); - + sscanf(message, "%d %23[^\n]", &list, mapname); - + if (list < 0 || list > 3) { clif->message(fd, msg_txt(1038)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>). return false; } - + if (mapname[0] == '\0') { safestrncpy(mapname, mapindex_id2name(sd->mapindex), MAP_NAME_LENGTH); m_id = map->mapindex2mapid(sd->mapindex); } else { m_id = map->mapname2mapid(mapname); } - + if (m_id < 0) { clif->message(fd, msg_txt(1)); // Map not found. return false; } m_index = mapindex->name2id(mapname); //This one shouldn't fail since the previous seek did not. - + clif->message(fd, msg_txt(1039)); // ------ Map Info ------ - + // count chats (for initial message) chat_num = 0; iter = mapit_getallusers(); @@ -3706,21 +3698,21 @@ ACMD(mapinfo) { } } mapit->free(iter); - + sprintf(atcmd_output, msg_txt(1040), mapname, map->list[m_id].zone->name, map->list[m_id].users, map->list[m_id].npc_num, chat_num, vend_num); // Map: %s (Zone:%s) | Players: %d | NPCs: %d | Chats: %d | Vendings: %d clif->message(fd, atcmd_output); clif->message(fd, msg_txt(1041)); // ------ Map Flags ------ if (map->list[m_id].flag.town) clif->message(fd, msg_txt(1042)); // Town Map - + if (battle_config.autotrade_mapflag == map->list[m_id].flag.autotrade) clif->message(fd, msg_txt(1043)); // Autotrade Enabled else clif->message(fd, msg_txt(1044)); // Autotrade Disabled - + if (map->list[m_id].flag.battleground) clif->message(fd, msg_txt(1045)); // Battlegrounds ON - + strcpy(atcmd_output,msg_txt(1046)); // PvP Flags: if (map->list[m_id].flag.pvp) strcat(atcmd_output, msg_txt(1047)); // Pvp ON | @@ -3733,7 +3725,7 @@ ACMD(mapinfo) { if (map->list[m_id].flag.pvp_nocalcrank) strcat(atcmd_output, msg_txt(1051)); // NoCalcRank | clif->message(fd, atcmd_output); - + strcpy(atcmd_output,msg_txt(1052)); // GvG Flags: if (map->list[m_id].flag.gvg) strcat(atcmd_output, msg_txt(1053)); // GvG ON | @@ -3744,7 +3736,7 @@ ACMD(mapinfo) { if (map->list[m_id].flag.gvg_noparty) strcat(atcmd_output, msg_txt(1056)); // NoParty | clif->message(fd, atcmd_output); - + strcpy(atcmd_output,msg_txt(1057)); // Teleport Flags: if (map->list[m_id].flag.noteleport) strcat(atcmd_output, msg_txt(1058)); // NoTeleport | @@ -3759,12 +3751,12 @@ ACMD(mapinfo) { if (map->list[m_id].flag.nomemo) strcat(atcmd_output, msg_txt(1064)); // NoMemo | clif->message(fd, atcmd_output); - + sprintf(atcmd_output, msg_txt(1065), // No Exp Penalty: %s | No Zeny Penalty: %s (map->list[m_id].flag.noexppenalty) ? msg_txt(1066) : msg_txt(1067), (map->list[m_id].flag.nozenypenalty) ? msg_txt(1066) : msg_txt(1067)); // On / Off clif->message(fd, atcmd_output); - + if (map->list[m_id].flag.nosave) { if (!map->list[m_id].save.map) clif->message(fd, msg_txt(1068)); // No Save (Return to last Save Point) @@ -3777,7 +3769,7 @@ ACMD(mapinfo) { clif->message(fd, atcmd_output); } } - + strcpy(atcmd_output,msg_txt(1071)); // Weather Flags: if (map->list[m_id].flag.snow) strcat(atcmd_output, msg_txt(1072)); // Snow | @@ -3796,7 +3788,7 @@ ACMD(mapinfo) { if (map->list[m_id].flag.nightenabled) strcat(atcmd_output, msg_txt(1080)); // Displays Night | clif->message(fd, atcmd_output); - + strcpy(atcmd_output,msg_txt(1081)); // Other Flags: if (map->list[m_id].flag.nobranch) strcat(atcmd_output, msg_txt(1082)); // NoBranch | @@ -3815,7 +3807,7 @@ ACMD(mapinfo) { if (map->list[m_id].flag.reset) strcat(atcmd_output, msg_txt(1089)); // Reset | clif->message(fd, atcmd_output); - + strcpy(atcmd_output,msg_txt(1090)); // Other Flags: if (map->list[m_id].nocommand) strcat(atcmd_output, msg_txt(1091)); // NoCommand | @@ -3832,7 +3824,7 @@ ACMD(mapinfo) { if (map->list[m_id].flag.guildlock) strcat(atcmd_output, msg_txt(1097)); // GuildLock | clif->message(fd, atcmd_output); - + switch (list) { case 0: // Do nothing. It's list 0, no additional display. @@ -3881,8 +3873,8 @@ ACMD(mapinfo) { for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if ((cd = (struct chat_data*)map->id2bl(pl_sd->chatID)) != NULL && - pl_sd->mapindex == m_index && - cd->usersd[0] == pl_sd) + pl_sd->mapindex == m_index && + cd->usersd[0] == pl_sd) { sprintf(atcmd_output, msg_txt(1114), // Chat: %s | Player: %s | Location: %d %d cd->title, pl_sd->status.name, cd->bl.x, cd->bl.y); @@ -3898,7 +3890,7 @@ ACMD(mapinfo) { clif->message(fd, msg_txt(1118)); // Please enter at least one valid list number (usage: @mapinfo <0-3> <map>). return false; } - + return true; } @@ -3911,12 +3903,12 @@ ACMD(mount_peco) clif->message(fd, msg_txt(212)); // Cannot mount while in disguise. return false; } - + if( sd->sc.data[SC_ALL_RIDING] ) { clif->message(fd, msg_txt(1476)); // You are already mounting something else return false; } - + if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT ) { if( !pc->checkskill(sd,RK_DRAGONTRAINING) ) { sprintf(atcmd_output, msg_txt(213), skill->get_desc(RK_DRAGONTRAINING)); // You need %s to mount! @@ -3982,10 +3974,10 @@ ACMD(mount_peco) ACMD(guildspy) { char guild_name[NAME_LENGTH]; struct guild *g; - + memset(guild_name, '\0', sizeof(guild_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!map->enable_spy) { clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled. @@ -3995,7 +3987,7 @@ ACMD(guildspy) { clif->message(fd, msg_txt(1126)); // Please enter a guild name/ID (usage: @guildspy <guild_name/ID>). return false; } - + if ((g = guild->searchname(guild_name)) != NULL || // name first to avoid error when name begin with a number (g = guild->search(atoi(message))) != NULL) { if (sd->guildspy == g->guild_id) { @@ -4011,7 +4003,7 @@ ACMD(guildspy) { clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the specified guild is online. return false; } - + return true; } @@ -4021,21 +4013,21 @@ ACMD(guildspy) { ACMD(partyspy) { char party_name[NAME_LENGTH]; struct party_data *p; - + memset(party_name, '\0', sizeof(party_name)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!map->enable_spy) { clif->message(fd, msg_txt(1125)); // The mapserver has spy command support disabled. return false; } - + if (!message || !*message || sscanf(message, "%23[^\n]", party_name) < 1) { clif->message(fd, msg_txt(1127)); // Please enter a party name/ID (usage: @partyspy <party_name/ID>). return false; } - + if ((p = party->searchname(party_name)) != NULL || // name first to avoid error when name begin with a number (p = party->search(atoi(message))) != NULL) { if (sd->partyspy == p->party.party_id) { @@ -4051,7 +4043,7 @@ ACMD(partyspy) { clif->message(fd, msg_txt(96)); // Incorrect name/ID, or no one from the specified party is online. return false; } - + return true; } @@ -4061,7 +4053,7 @@ ACMD(partyspy) { ACMD(repairall) { int count, i; - + count = 0; for (i = 0; i < MAX_INVENTORY; i++) { if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) { @@ -4070,7 +4062,7 @@ ACMD(repairall) count++; } } - + if (count > 0) { clif->misceffect(&sd->bl, 3); clif->equiplist(sd); @@ -4079,7 +4071,7 @@ ACMD(repairall) clif->message(fd, msg_txt(108)); // No item need to be repaired. return false; } - + return true; } @@ -4088,14 +4080,14 @@ ACMD(repairall) *------------------------------------------*/ ACMD(nuke) { struct map_session_data *pl_sd; - + memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - + if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif->message(fd, msg_txt(1128)); // Please enter a player name (usage: @nuke <char name>). return false; } - + if ((pl_sd = map->nick2sd(atcmd_player_name)) != NULL) { if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, timer->gettick(), 0); @@ -4108,7 +4100,7 @@ ACMD(nuke) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + return true; } @@ -4118,14 +4110,14 @@ ACMD(nuke) { ACMD(tonpc) { char npcname[NAME_LENGTH+1]; struct npc_data *nd; - + memset(npcname, 0, sizeof(npcname)); - + if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) { clif->message(fd, msg_txt(1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>). return false; } - + if ((nd = npc->name2id(npcname)) != NULL) { if (nd->bl.m != -1 && pc->setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0) clif->message(fd, msg_txt(0)); // Warped. @@ -4135,7 +4127,7 @@ ACMD(tonpc) { clif->message(fd, msg_txt(111)); // This NPC doesn't exist. return false; } - + return true; } @@ -4145,14 +4137,14 @@ ACMD(tonpc) { ACMD(shownpc) { char NPCname[NAME_LENGTH+1]; - + memset(NPCname, '\0', sizeof(NPCname)); - + if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) { clif->message(fd, msg_txt(1130)); // Please enter a NPC name (usage: @enablenpc <NPC_name>). return false; } - + if (npc->name2id(NPCname) != NULL) { npc->enable(NPCname, 1); clif->message(fd, msg_txt(110)); // Npc Enabled. @@ -4160,7 +4152,7 @@ ACMD(shownpc) clif->message(fd, msg_txt(111)); // This NPC doesn't exist. return false; } - + return true; } @@ -4170,19 +4162,19 @@ ACMD(shownpc) ACMD(hidenpc) { char NPCname[NAME_LENGTH+1]; - + memset(NPCname, '\0', sizeof(NPCname)); - + if (!message || !*message || sscanf(message, "%23[^\n]", NPCname) < 1) { clif->message(fd, msg_txt(1131)); // Please enter a NPC name (usage: @hidenpc <NPC_name>). return false; } - + if (npc->name2id(NPCname) == NULL) { clif->message(fd, msg_txt(111)); // This NPC doesn't exist. return false; } - + npc->enable(NPCname, 0); clif->message(fd, msg_txt(112)); // Npc Disabled. return true; @@ -4191,26 +4183,26 @@ ACMD(hidenpc) ACMD(loadnpc) { FILE *fp; - + if (!message || !*message) { clif->message(fd, msg_txt(1132)); // Please enter a script file name (usage: @loadnpc <file name>). return false; } - + // check if script file exists if ((fp = fopen(message, "r")) == NULL) { clif->message(fd, msg_txt(261)); return false; } fclose(fp); - + // add to list of script sources and run it npc->addsrcfile(message); npc->parsesrcfile(message,true); npc->read_event_script(); - + clif->message(fd, msg_txt(262)); - + return true; } @@ -4218,19 +4210,19 @@ ACMD(unloadnpc) { struct npc_data *nd; char NPCname[NAME_LENGTH+1]; - + memset(NPCname, '\0', sizeof(NPCname)); - + if (!message || !*message || sscanf(message, "%24[^\n]", NPCname) < 1) { clif->message(fd, msg_txt(1133)); // Please enter a NPC name (usage: @npcoff <NPC_name>). return false; } - + if ((nd = npc->name2id(NPCname)) == NULL) { clif->message(fd, msg_txt(111)); // This NPC doesn't exist. return false; } - + npc->unload_duplicates(nd); npc->unload(nd,true); npc->read_event_script(); @@ -4246,16 +4238,16 @@ char* txt_time(unsigned int duration) int days, hours, minutes, seconds; static char temp1[CHAT_SIZE_MAX]; int tlen = 0; - + memset(temp1, '\0', sizeof(temp1)); - + days = duration / (60 * 60 * 24); duration = duration - (60 * 60 * 24 * days); hours = duration / (60 * 60); duration = duration - (60 * 60 * hours); minutes = duration / 60; seconds = duration - (60 * minutes); - + if (days == 1) tlen += sprintf(tlen + temp1, msg_txt(219), days); // %d day else if (days > 1) @@ -4272,7 +4264,7 @@ char* txt_time(unsigned int duration) sprintf(tlen + temp1, msg_txt(225), seconds); // and %d second else if (seconds > 1) sprintf(tlen + temp1, msg_txt(226), seconds); // and %d seconds - + return temp1; } @@ -4284,19 +4276,19 @@ ACMD(servertime) { time_t time_server; // variable for number of seconds (used with time() function) struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ... char temp[CHAT_SIZE_MAX]; - + memset(temp, '\0', sizeof(temp)); - + time(&time_server); // get time in seconds since 1/1/1970 datetime = localtime(&time_server); // convert seconds in structure // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52) strftime(temp, sizeof(temp)-1, msg_txt(230), datetime); // Server time (normal time): %A, %B %d %Y %X. clif->message(fd, temp); - + if (pc->day_timer_tid != INVALID_TIMER && pc->night_timer_tid != INVALID_TIMER) { const struct TimerData * timer_data = timer->get(pc->night_timer_tid); const struct TimerData * timer_data2 = timer->get(pc->day_timer_tid); - + if (map->night_flag == 0) { sprintf(temp, msg_txt(235), // Game time: The game is actually in daylight for %s. txt_time((unsigned int)(DIFF_TICK(timer_data->tick,timer->gettick())/1000))); @@ -4328,7 +4320,7 @@ ACMD(servertime) { else clif->message(fd, msg_txt(232)); // Game time: The game is in permanent night. } - + return true; } @@ -4341,7 +4333,7 @@ void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int const int factor_month = 43200; //30*24*60 = 43200 const int factor_day = 1440; //24*60 = 1440 const int factor_hour = 60; - + *year = jailtime/factor_year; jailtime -= *year*factor_year; *month = jailtime/factor_month; @@ -4351,7 +4343,7 @@ void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int *hour = jailtime/factor_hour; jailtime -= *hour*factor_hour; *minute = jailtime; - + *year = *year > 0? *year : 0; *month = *month > 0? *month : 0; *day = *day > 0? *day : 0; @@ -4368,31 +4360,31 @@ ACMD(jail) { struct map_session_data *pl_sd; int x, y; unsigned short m_index; - + memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - + if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif->message(fd, msg_txt(1134)); // Please enter a player name (usage: @jail <char_name>). return false; } - + if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - - if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) - { // you can jail only lower or same GM + + if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { + // you can jail only lower or same GM clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } - + if (pl_sd->sc.data[SC_JAILED]) { clif->message(fd, msg_txt(118)); // Player warped in jails. return false; } - + switch(rnd() % 2) { //Jail Locations case 0: m_index = mapindex->name2id(MAP_JAIL); @@ -4405,7 +4397,7 @@ ACMD(jail) { y = 75; break; } - + //Duration of INT_MAX to specify infinity. sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,INT_MAX,m_index,x,y,1000); clif->message(pl_sd->fd, msg_txt(117)); // You have been jailed by a GM. @@ -4419,31 +4411,31 @@ ACMD(jail) { *------------------------------------------*/ ACMD(unjail) { struct map_session_data *pl_sd; - + memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); - + if (!message || !*message || sscanf(message, "%23[^\n]", atcmd_player_name) < 1) { clif->message(fd, msg_txt(1135)); // Please enter a player name (usage: @unjail/@discharge <char_name>). return false; } - + if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM - + clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } - + if (!pl_sd->sc.data[SC_JAILED]) { clif->message(fd, msg_txt(119)); // This player is not in jails. return false; } - + //Reset jail time to 1 sec. sc_start(NULL,&pl_sd->bl,SC_JAILED,100,1,1000); clif->message(pl_sd->fd, msg_txt(120)); // A GM has discharged you from jail. @@ -4457,14 +4449,14 @@ ACMD(jailfor) { char * modif_p; int jailtime = 0,x,y; short m_index = 0; - + if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) { - clif->message(fd, msg_txt(400)); //Usage: @jailfor <time> <character name> + clif->message(fd, msg_txt(400)); //Usage: @jailfor <time> <character name> return false; } - + atcmd_output[sizeof(atcmd_output)-1] = '\0'; - + modif_p = atcmd_output; year = month = day = hour = minute = 0; while (modif_p[0] != '\0') { @@ -4499,33 +4491,32 @@ ACMD(jailfor) { } } } - + if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0) { clif->message(fd, msg_txt(1136)); // Invalid time for jail command. return false; } - + if ((pl_sd = map->nick2sd(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) { clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } - - jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes - + + jailtime = year*12*30*24*60 + month*30*24*60 + day*24*60 + hour*60 + minute; //In minutes + if(jailtime==0) { clif->message(fd, msg_txt(1136)); // Invalid time for jail command. return false; } - + //Added by Coltaro - if(pl_sd->sc.data[SC_JAILED] && - pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) - { //Update the player's jail time + if (pl_sd->sc.data[SC_JAILED] && pl_sd->sc.data[SC_JAILED]->val1 != INT_MAX) { + //Update the player's jail time jailtime += pl_sd->sc.data[SC_JAILED]->val1; if (jailtime <= 0) { jailtime = 0; @@ -4534,15 +4525,15 @@ ACMD(jailfor) { } else { atcommand->get_jail_time(jailtime,&year,&month,&day,&hour,&minute); sprintf(atcmd_output,msg_txt(402),msg_txt(1137),year,month,day,hour,minute); //%s in jail for %d years, %d months, %d days, %d hours and %d minutes - clif->message(pl_sd->fd, atcmd_output); + clif->message(pl_sd->fd, atcmd_output); sprintf(atcmd_output,msg_txt(402),msg_txt(1138),year,month,day,hour,minute); //This player is now in jail for %d years, %d months, %d days, %d hours and %d minutes - clif->message(fd, atcmd_output); + clif->message(fd, atcmd_output); } } else if (jailtime < 0) { clif->message(fd, msg_txt(1136)); return false; } - + //Jail locations, add more as you wish. switch(rnd()%2) { @@ -4555,7 +4546,7 @@ ACMD(jailfor) { x = 24; y = 75; break; } - + sc_start4(NULL,&pl_sd->bl,SC_JAILED,100,jailtime,m_index,x,y,jailtime?60000:1000); //jailtime = 0: Time was reset to 0. Wait 1 second to warp player out (since it's done in status->change_timer). return true; } @@ -4565,28 +4556,28 @@ ACMD(jailfor) { ACMD(jailtime) { int year, month, day, hour, minute; - + if (!sd->sc.data[SC_JAILED]) { clif->message(fd, msg_txt(1139)); // You are not in jail. return false; } - + if (sd->sc.data[SC_JAILED]->val1 == INT_MAX) { clif->message(fd, msg_txt(1140)); // You have been jailed indefinitely. return true; } - + if (sd->sc.data[SC_JAILED]->val1 <= 0) { // Was not jailed with @jailfor (maybe @jail? or warped there? or got recalled?) clif->message(fd, msg_txt(1141)); // You have been jailed for an unknown amount of time. return false; } - + //Get remaining jail time atcommand->get_jail_time(sd->sc.data[SC_JAILED]->val1,&year,&month,&day,&hour,&minute); sprintf(atcmd_output,msg_txt(402),msg_txt(1142),year,month,day,hour,minute); // You will remain in jail for %d years, %d months, %d days, %d hours and %d minutes - + clif->message(fd, atcmd_output); - + return true; } @@ -4596,17 +4587,18 @@ ACMD(jailtime) ACMD(disguise) { int id = 0; - + if (!message || !*message) { clif->message(fd, msg_txt(1143)); // Please enter a Monster/NPC name/ID (usage: @disguise <name/ID>). return false; } - - if ((id = atoi(message)) > 0) - { //Acquired an ID + + if ((id = atoi(message)) > 0) { + //Acquired an ID if (!mob->db_checkid(id) && !npcdb_checkid(id)) id = 0; //Invalid id for either mobs or npcs. - } else { //Acquired a Name + } else { + //Acquired a Name if ((id = mob->db_searchname(message)) == 0) { struct npc_data* nd = npc->name2id(message); @@ -4614,18 +4606,18 @@ ACMD(disguise) id = nd->class_; } } - + if (id == 0) { - clif->message(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified. + clif->message(fd, msg_txt(123)); // Invalid Monster/NPC name/ID specified. return false; } - + if (pc_hasmount(sd)) { clif->message(fd, msg_txt(1144)); // Character cannot be disguised while mounted. return false; } - + if(sd->sc.data[SC_MONSTER_TRANSFORM]) { clif->message(fd, msg_txt(1487)); // Character cannot be disguised while in monster form. @@ -4634,7 +4626,7 @@ ACMD(disguise) pc->disguise(sd, id); clif->message(fd, msg_txt(122)); // Disguise applied. - + return true; } @@ -4646,25 +4638,25 @@ ACMD(disguiseall) int mob_id=0; struct map_session_data *pl_sd; struct s_mapiterator* iter; - + if (!message || !*message) { clif->message(fd, msg_txt(1145)); // Please enter a Monster/NPC name/ID (usage: @disguiseall <name/ID>). return false; } - + if ((mob_id = mob->db_searchname(message)) == 0) // check name first (to avoid possible name begining by a number) mob_id = atoi(message); - + if (!mob->db_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc... clif->message(fd, msg_txt(123)); // Monster/NPC name/id not found. return false; } - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) pc->disguise(pl_sd, mob_id); mapit->free(iter); - + clif->message(fd, msg_txt(122)); // Disguise applied. return true; } @@ -4678,15 +4670,15 @@ ACMD(disguiseguild) char monster[NAME_LENGTH], guild_name[NAME_LENGTH]; struct map_session_data *pl_sd; struct guild *g; - + memset(monster, '\0', sizeof(monster)); memset(guild_name, '\0', sizeof(guild_name)); - + if( !message || !*message || sscanf(message, "%23[^,], %23[^\r\n]", monster, guild_name) < 2 ) { clif->message(fd, msg_txt(1146)); // Please enter a mob name/ID and guild name/ID (usage: @disguiseguild <mob name/ID>, <guild name/ID>). return false; } - + if( (id = atoi(monster)) > 0 ) { if( !mob->db_checkid(id) && !npcdb_checkid(id) ) id = 0; @@ -4697,21 +4689,21 @@ ACMD(disguiseguild) id = nd->class_; } } - + if( id == 0 ) { - clif->message(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found. + clif->message(fd, msg_txt(123)); // Monster/NPC name/id hasn't been found. return false; } - + if( (g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(guild_name))) == NULL ) { clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online. return false; } - + for (i = 0; i < g->max_member; i++) if ((pl_sd = g->member[i].sd) && !pc_hasmount(pl_sd)) pc->disguise(pl_sd, id); - + clif->message(fd, msg_txt(122)); // Disguise applied. return true; } @@ -4729,7 +4721,7 @@ ACMD(undisguise) clif->message(fd, msg_txt(125)); // You're not disguised. return false; } - + return true; } @@ -4739,15 +4731,15 @@ ACMD(undisguise) ACMD(undisguiseall) { struct map_session_data *pl_sd; struct s_mapiterator* iter; - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) if( pl_sd->disguise != -1 ) pc->disguise(pl_sd, -1); mapit->free(iter); - + clif->message(fd, msg_txt(124)); // Disguise removed. - + return true; } @@ -4760,25 +4752,25 @@ ACMD(undisguiseguild) struct map_session_data *pl_sd; struct guild *g; int i; - + memset(guild_name, '\0', sizeof(guild_name)); - + if(!message || !*message || sscanf(message, "%23[^\n]", guild_name) < 1) { clif->message(fd, msg_txt(1147)); // Please enter guild name/ID (usage: @undisguiseguild <guild name/ID>). return false; } - + if( (g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(message))) == NULL ) { clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online. return false; } - + for(i = 0; i < g->max_member; i++) if( (pl_sd = g->member[i].sd) && pl_sd->disguise != -1 ) pc->disguise(pl_sd, -1); - + clif->message(fd, msg_txt(124)); // Disguise removed. - + return true; } @@ -4791,15 +4783,15 @@ ACMD(exp) double nextb, nextj; memset(output, '\0', sizeof(output)); - + nextb = pc->nextbaseexp(sd); if (nextb) nextb = sd->status.base_exp*100.0/nextb; - + nextj = pc->nextjobexp(sd); if (nextj) nextj = sd->status.job_exp*100.0/nextj; - + sprintf(output, msg_txt(1148), sd->status.base_level, nextb, sd->status.job_level, nextj); // Base Level: %d (%.3f%%) | Job Level: %d (%.3f%%) clif->message(fd, output); return true; @@ -4811,17 +4803,16 @@ ACMD(exp) *------------------------------------------*/ ACMD(broadcast) { - memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message) { clif->message(fd, msg_txt(1149)); // Please enter a message (usage: @broadcast <message>). return false; } - + sprintf(atcmd_output, "%s: %s", sd->status.name, message); intif->broadcast(atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT); - + return true; } @@ -4831,16 +4822,16 @@ ACMD(broadcast) ACMD(localbroadcast) { memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (!message || !*message) { clif->message(fd, msg_txt(1150)); // Please enter a message (usage: @localbroadcast <message>). return false; } - + sprintf(atcmd_output, "%s: %s", sd->status.name, message); - + clif->broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP); - + return true; } @@ -4851,15 +4842,15 @@ ACMD(email) { char actual_email[100]; char new_email[100]; - + memset(actual_email, '\0', sizeof(actual_email)); memset(new_email, '\0', sizeof(new_email)); - + if (!message || !*message || sscanf(message, "%99s %99s", actual_email, new_email) < 2) { clif->message(fd, msg_txt(1151)); // Please enter two e-mail addresses (usage: @email <current@email> <new@email>). return false; } - + if (e_mail_check(actual_email) == 0) { clif->message(fd, msg_txt(144)); // Invalid e-mail. If your email hasn't been set, use a@a.com. return false; @@ -4873,7 +4864,7 @@ ACMD(email) clif->message(fd, msg_txt(147)); // New e-mail must be different from the current e-mail address. return false; } - + chrif->changeemail(sd->status.account_id, actual_email, new_email); clif->message(fd, msg_txt(148)); // Information sended to login-server via char-server. return true; @@ -4885,12 +4876,12 @@ ACMD(email) ACMD(effect) { int type = 0, flag = 0; - + if (!message || !*message || sscanf(message, "%d", &type) < 1) { clif->message(fd, msg_txt(1152)); // Please enter an effect number (usage: @effect <effect number>). return false; } - + clif->specialeffect(&sd->bl, type, (send_target)flag); clif->message(fd, msg_txt(229)); // Your effect has changed. return true; @@ -4903,7 +4894,7 @@ ACMD(effect) ACMD(killer) { sd->state.killer = !sd->state.killer; - + if(sd->state.killer) clif->message(fd, msg_txt(241)); else { @@ -4919,7 +4910,7 @@ ACMD(killer) *------------------------------------------*/ ACMD(killable) { sd->state.killable = !sd->state.killable; - + if(sd->state.killable) clif->message(fd, msg_txt(242)); else { @@ -4958,29 +4949,29 @@ ACMD(npcmove) { struct npc_data *nd = 0; memset(atcmd_player_name, '\0', sizeof atcmd_player_name); - + if (!message || !*message || sscanf(message, "%d %d %23[^\n]", &x, &y, atcmd_player_name) < 3) { clif->message(fd, msg_txt(1153)); // Usage: @npcmove <X> <Y> <npc_name> return false; } - + if ((nd = npc->name2id(atcmd_player_name)) == NULL) { clif->message(fd, msg_txt(111)); // This NPC doesn't exist. return false; } - + if ((m=nd->bl.m) < 0 || nd->bl.prev == NULL) { clif->message(fd, msg_txt(1154)); // NPC is not in this map. - return false; //Not on a map. + return false; //Not on a map. } - + x = cap_value(x, 0, map->list[m].xs-1); y = cap_value(y, 0, map->list[m].ys-1); map->foreachinrange(clif->outsight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); map->moveblock(&nd->bl, x, y, timer->gettick()); map->foreachinrange(clif->insight, &nd->bl, AREA_SIZE, BL_PC, &nd->bl); clif->message(fd, msg_txt(1155)); // NPC moved. - + return true; } @@ -4994,14 +4985,14 @@ ACMD(addwarp) int x,y; unsigned short m; struct npc_data* nd; - + memset(warpname, '\0', sizeof(warpname)); - + if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 4) { clif->message(fd, msg_txt(1156)); // Usage: @addwarp <mapname> <X> <Y> <npc name> return false; } - + m = mapindex->name2id(mapname); if( m == 0 ) { @@ -5009,11 +5000,11 @@ ACMD(addwarp) clif->message(fd, atcmd_output); return false; } - + nd = npc->add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y); if( nd == NULL ) return false; - + sprintf(atcmd_output, msg_txt(1158), nd->exname); // New warp NPC '%s' created. clif->message(fd, atcmd_output); return true; @@ -5025,22 +5016,21 @@ ACMD(addwarp) *------------------------------------------*/ ACMD(follow) { struct map_session_data *pl_sd = NULL; - + if (!message || !*message) { if (sd->followtarget == -1) return false; - pc->stop_following (sd); clif->message(fd, msg_txt(1159)); // Follow mode OFF. return true; } - + if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + if (sd->followtarget == pl_sd->bl.id) { pc->stop_following (sd); clif->message(fd, msg_txt(1159)); // Follow mode OFF. @@ -5048,7 +5038,7 @@ ACMD(follow) { pc->follow(sd, pl_sd->bl.id); clif->message(fd, msg_txt(1160)); // Follow mode ON. } - + return true; } @@ -5078,15 +5068,15 @@ ACMD(dropall) ACMD(storeall) { int i; - - if (sd->state.storage_flag != 1) - { //Open storage. + + if (sd->state.storage_flag != 1) { + //Open storage. if( storage->open(sd) == 1 ) { clif->message(fd, msg_txt(1161)); // You currently cannot open your storage. return false; } } - + for (i = 0; i < MAX_INVENTORY; i++) { if (sd->status.inventory[i].amount) { if(sd->status.inventory[i].equip != 0) @@ -5095,7 +5085,7 @@ ACMD(storeall) } } storage->close(sd); - + clif->message(fd, msg_txt(1162)); // All items stored. return true; } @@ -5103,18 +5093,18 @@ ACMD(storeall) ACMD(clearstorage) { int i, j; - + if (sd->state.storage_flag == 1) { clif->message(fd, msg_txt(250)); return false; } - + j = sd->status.storage.storage_amount; for (i = 0; i < j; ++i) { storage->delitem(sd, i, sd->status.storage.items[i].amount); } storage->close(sd); - + clif->message(fd, msg_txt(1394)); // Your storage was cleaned. return true; } @@ -5124,29 +5114,29 @@ ACMD(cleargstorage) int i, j; struct guild *g; struct guild_storage *guild_storage; - + g = sd->guild; - + if (g == NULL) { clif->message(fd, msg_txt(43)); return false; } - + if (sd->state.storage_flag == 1) { clif->message(fd, msg_txt(250)); return false; } - + if (sd->state.storage_flag == 2) { clif->message(fd, msg_txt(251)); return false; } - + guild_storage = idb_get(gstorage->db,sd->status.guild_id); if (guild_storage == NULL) {// Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there. return false; } - + j = guild_storage->storage_amount; guild_storage->lock = 1; // Lock @gstorage: do not allow any item to be retrieved or stored from any guild member for (i = 0; i < j; ++i) { @@ -5154,7 +5144,7 @@ ACMD(cleargstorage) } gstorage->close(sd); guild_storage->lock = 0; // Cleaning done, release lock - + clif->message(fd, msg_txt(1395)); // Your guild storage was cleaned. return true; } @@ -5162,24 +5152,24 @@ ACMD(cleargstorage) ACMD(clearcart) { int i; - + if (pc_iscarton(sd) == 0) { clif->message(fd, msg_txt(1396)); // You do not have a cart to be cleaned. return false; } - + if( sd->state.vending == 1 ) { clif->message(fd, msg_txt(548)); // You can't clean a cart while vending! - return false; - } - + return false; + } + for( i = 0; i < MAX_CART; i++ ) if(sd->status.cart[i].nameid > 0) pc->cart_delitem(sd, i, sd->status.cart[i].amount, 1, LOG_TYPE_OTHER); - + clif->clearcart(fd); clif->updatestatus(sd,SP_CARTINFO); - + clif->message(fd, msg_txt(1397)); // Your cart was cleaned. return true; } @@ -5197,16 +5187,16 @@ ACMD(skillid) { DBKey key; DBData *data; char partials[MAX_SKILLID_PARTIAL_RESULTS][MAX_SKILLID_PARTIAL_RESULTS_LEN]; - + if (!message || !*message) { clif->message(fd, msg_txt(1163)); // Please enter a skill name to look up (usage: @skillid <skill name>). return false; } - + skillen = strlen(message); - + iter = db_iterator(skill->name2id_db); - + for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) { idx = skill->get_index(DB->data2i(data)); if (strnicmp(key.str, message, skillen) == 0 || strnicmp(skill->db[idx].desc, message, skillen) == 0) { @@ -5216,18 +5206,18 @@ ACMD(skillid) { snprintf(partials[found++], MAX_SKILLID_PARTIAL_RESULTS_LEN, msg_txt(1164), DB->data2i(data), skill->db[idx].desc, key.str); } } - + dbi_destroy(iter); - + if( found ) { sprintf(atcmd_output, msg_txt(1398), found); // -- Displaying first %d partial matches clif->message(fd, atcmd_output); } - + for(i = 0; i < found; i++) { /* partials */ clif->message(fd, partials[i]); } - + return true; } @@ -5241,38 +5231,38 @@ ACMD(useskill) { uint16 skill_id; uint16 skill_lv; char target[100]; - + if(!message || !*message || sscanf(message, "%hu %hu %23[^\n]", &skill_id, &skill_lv, target) != 3) { clif->message(fd, msg_txt(1165)); // Usage: @useskill <skill ID> <skill level> <target> return false; } - + if(!strcmp(target,"self")) pl_sd = sd; //quick keyword else if ( (pl_sd = map->nick2sd(target)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { clif->message(fd, msg_txt(81)); // Your GM level don't authorized you to do this action on this player. return false; } - + if (skill_id >= HM_SKILLBASE && skill_id < HM_SKILLBASE+MAX_HOMUNSKILL && sd->hd && homun_alive(sd->hd)) // (If used with @useskill, put the homunc as dest) bl = &sd->hd->bl; else bl = &sd->bl; - + pc->delinvincibletimer(sd); - + if (skill->get_inf(skill_id)&INF_GROUND_SKILL) unit->skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv); else unit->skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv); - + return true; } @@ -5286,7 +5276,7 @@ ACMD(displayskill) { int64 tick; uint16 skill_id; uint16 skill_lv = 1; - + if (!message || !*message || sscanf(message, "%hu %hu", &skill_id, &skill_lv) < 1) { clif->message(fd, msg_txt(1166)); // Usage: @displayskill <skill ID> {<skill level>} return false; @@ -5309,32 +5299,32 @@ ACMD(skilltree) { int meets, j, c=0; char target[NAME_LENGTH]; struct skill_tree_entry *ent; - + if(!message || !*message || sscanf(message, "%hu %23[^\r\n]", &skill_id, target) != 2) { clif->message(fd, msg_txt(1167)); // Usage: @skilltree <skill ID> <target> return false; } - + if ( (pl_sd = map->nick2sd(target)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + c = pc->calc_skilltree_normalize_job(pl_sd); c = pc->mapid2jobid(c, pl_sd->status.sex); - + sprintf(atcmd_output, msg_txt(1168), pc->job_name(c), pc->checkskill(pl_sd, NV_BASIC)); // Player is using %s skill tree (%d basic points). clif->message(fd, atcmd_output); - + ARR_FIND( 0, MAX_SKILL_TREE, j, pc->skill_tree[c][j].id == 0 || pc->skill_tree[c][j].id == skill_id ); if( j == MAX_SKILL_TREE || pc->skill_tree[c][j].id == 0 ) { clif->message(fd, msg_txt(1169)); // The player cannot use that skill. return false; } - + ent = &pc->skill_tree[c][j]; - + meets = 1; for(j=0;j<MAX_PC_SKILL_REQUIRE;j++) { @@ -5348,7 +5338,7 @@ ACMD(skilltree) { if (meets == 1) { clif->message(fd, msg_txt(1171)); // The player meets all the requirements for that skill. } - + return true; } @@ -5357,14 +5347,14 @@ void getring(struct map_session_data* sd) { int flag, item_id; struct item item_tmp; item_id = (sd->status.sex) ? WEDDING_RING_M : WEDDING_RING_F; - + memset(&item_tmp, 0, sizeof(item_tmp)); item_tmp.nameid = item_id; item_tmp.identify = 1; item_tmp.card[0] = 255; item_tmp.card[2] = sd->status.partner_id; item_tmp.card[3] = sd->status.partner_id >> 16; - + if((flag = pc->additem(sd,&item_tmp,1,LOG_TYPE_COMMAND))) { clif->additem(sd,0,0,flag); map->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); @@ -5378,17 +5368,17 @@ void getring(struct map_session_data* sd) { ACMD(marry) { struct map_session_data *pl_sd = NULL; char player_name[NAME_LENGTH] = ""; - + if (!message || !*message || sscanf(message, "%23s", player_name) != 1) { clif->message(fd, msg_txt(1172)); // Usage: @marry <char name> return false; } - + if ((pl_sd = map->nick2sd(player_name)) == NULL) { clif->message(fd, msg_txt(3)); return false; } - + if (pc->marriage(sd, pl_sd) == 0) { clif->message(fd, msg_txt(1173)); // They are married... wish them well. clif->wedding_effect(&pl_sd->bl); //wedding effect and music [Lupus] @@ -5396,7 +5386,7 @@ ACMD(marry) { getring(pl_sd); return true; } - + clif->message(fd, msg_txt(1174)); // The two cannot wed because one is either a baby or already married. return false; } @@ -5412,7 +5402,7 @@ ACMD(divorce) clif->message(fd, atcmd_output); return false; } - + sprintf(atcmd_output, msg_txt(1176), sd->status.name); // '%s' and his/her partner are now divorced. clif->message(fd, atcmd_output); return true; @@ -5425,7 +5415,7 @@ ACMD(changelook) { int i, j = 0, k = 0; int pos[7] = { LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HEAD_BOTTOM,LOOK_WEAPON,LOOK_SHIELD,LOOK_SHOES,LOOK_ROBE }; - + if((i = sscanf(message, "%d %d", &j, &k)) < 1) { clif->message(fd, msg_txt(1177)); // Usage: @changelook {<position>} <view id> clif->message(fd, msg_txt(1178)); // Position: 1-Top 2-Middle 3-Bottom 4-Weapon 5-Shield 6-Shoes 7-Robe @@ -5434,13 +5424,13 @@ ACMD(changelook) if (j < 1 || j > 7) j = 1; j = pos[j - 1]; - } else if( i == 1 ) { // position not defined, use HEAD_TOP as default - k = j; // swap + } else if( i == 1 ) { // position not defined, use HEAD_TOP as default + k = j; // swap j = LOOK_HEAD_TOP; } - + clif->changelook(&sd->bl,j,k); - + return true; } @@ -5448,23 +5438,23 @@ ACMD(changelook) * @autotrade by durf [Lupus] [Paradox924X] * Turns on/off Autotrade for a specific player *------------------------------------------*/ -ACMD(autotrade) { - +ACMD(autotrade) +{ if( map->list[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) { clif->message(fd, msg_txt(1179)); // Autotrade is not allowed in this map. return false; } - + if( pc_isdead(sd) ) { clif->message(fd, msg_txt(1180)); // You cannot autotrade when dead. return false; } - + if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying clif->message(fd, msg_txt(549)); // "You should have a shop open in order to use @autotrade." return false; } - + sd->state.autotrade = 1; if( battle_config.at_timeout ) { int timeout = atoi(message); @@ -5473,17 +5463,17 @@ ACMD(autotrade) { } clif->chsys_quit(sd); - + clif->authfail_fd(sd->fd, 15); /* currently standalone is not supporting buyingstores, so we rely on the previous method */ if( sd->state.buyingstore ) return true; - + #ifdef AUTOTRADE_PERSISTENCY sd->state.autotrade = 2;/** state will enter pre-save, we use it to rule out some criterias **/ pc->autotrade_prepare(sd); - + return false;/* we fail to not cause it to proceed on is_atcommand */ #else return true; @@ -5497,27 +5487,27 @@ ACMD(autotrade) { ACMD(changegm) { struct guild *g; struct map_session_data *pl_sd; - + if (sd->status.guild_id == 0 || (g = sd->guild) == NULL || strcmp(g->master,sd->status.name)) { clif->message(fd, msg_txt(1181)); // You need to be a Guild Master to use this command. return false; } - + if( map->list[sd->bl.m].flag.guildlock || map->list[sd->bl.m].flag.gvg_castle ) { clif->message(fd, msg_txt(1182)); // You cannot change guild leaders in this map. return false; } - + if( !message[0] ) { clif->message(fd, msg_txt(1183)); // Usage: @changegm <guild_member_name> return false; } - + if((pl_sd=map->nick2sd((char *) message)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) { clif->message(fd, msg_txt(1184)); // Target character must be online and be a guild member. return false; } - + guild->gm_change(sd->status.guild_id, pl_sd); return true; } @@ -5527,12 +5517,12 @@ ACMD(changegm) { * Changes the leader of a party. *------------------------------------------*/ ACMD(changeleader) { - + if( !message[0] ) { clif->message(fd, msg_txt(1185)); // Usage: @changeleader <party_member_name> return false; } - + if (party->changeleader(sd, map->nick2sd((char *) message))) return true; return false; @@ -5547,37 +5537,37 @@ ACMD(partyoption) struct party_data *p; int mi, option; char w1[16], w2[16]; - + if (sd->status.party_id == 0 || (p = party->search(sd->status.party_id)) == NULL) { clif->message(fd, msg_txt(282)); return false; } - + ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd ); if (mi == MAX_PARTY) return false; //Shouldn't happen - + if (!p->party.member[mi].leader) { clif->message(fd, msg_txt(282)); return false; } - + if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2) { clif->message(fd, msg_txt(1186)); // Usage: @partyoption <pickup share: yes/no> <item distribution: yes/no> return false; } - + option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0); - + //Change item share type. if (option != p->party.item) party->changeoption(sd, p->party.exp, option); else clif->message(fd, msg_txt(286)); - + return true; } @@ -5603,14 +5593,14 @@ ACMD(autoloot) } if (rate < 0) rate = 0; if (rate > 10000) rate = 10000; - + sd->state.autoloot = rate; if (sd->state.autoloot) { snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1187),((double)sd->state.autoloot)/100.); // Autolooting items with drop rates of %0.02f%% and below. clif->message(fd, atcmd_output); }else clif->message(fd, msg_txt(1188)); // Autoloot is now off. - + return true; } @@ -5622,7 +5612,7 @@ ACMD(autolootitem) struct item_data *item_data = NULL; int i; int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset - + if (message && *message) { if (message[0] == '+') { message++; @@ -5646,7 +5636,7 @@ ACMD(autolootitem) } } } - + switch(action) { case 1: ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid); @@ -5810,8 +5800,8 @@ ACMD(autoloottype) { /*========================================== * It is made to snow. *------------------------------------------*/ -ACMD(snow) { - +ACMD(snow) +{ if (map->list[sd->bl.m].flag.snow) { map->list[sd->bl.m].flag.snow=0; clif->weather(sd->bl.m); @@ -5821,7 +5811,7 @@ ACMD(snow) { clif->weather(sd->bl.m); clif->message(fd, msg_txt(1204)); // It has started to snow. } - + return true; } @@ -5856,7 +5846,7 @@ ACMD(clouds) { clif->weather(sd->bl.m); clif->message(fd, msg_txt(1208)); // Clouds appear. } - + return true; } @@ -5874,7 +5864,7 @@ ACMD(clouds2) { clif->weather(sd->bl.m); clif->message(fd, msg_txt(1210)); // Alternative clouds appear. } - + return true; } @@ -5909,7 +5899,7 @@ ACMD(leaves) { clif->weather(sd->bl.m); clif->message(fd, msg_txt(1214)); // Fallen leaves fall. } - + return true; } @@ -5927,15 +5917,15 @@ ACMD(fireworks) { clif->weather(sd->bl.m); clif->message(fd, msg_txt(1216)); // Fireworks have launched. } - + return true; } /*========================================== * Clearing Weather Effects by Dexity *------------------------------------------*/ -ACMD(clearweather) { - +ACMD(clearweather) +{ map->list[sd->bl.m].flag.snow=0; map->list[sd->bl.m].flag.sakura=0; map->list[sd->bl.m].flag.clouds=0; @@ -5945,7 +5935,7 @@ ACMD(clearweather) { map->list[sd->bl.m].flag.leaves=0; clif->weather(sd->bl.m); clif->message(fd, msg_txt(291)); // "Weather effects will disappear after teleporting or refreshing." - + return true; } @@ -5955,24 +5945,24 @@ ACMD(clearweather) { ACMD(sound) { char sound_file[100]; - + memset(sound_file, '\0', sizeof(sound_file)); - + if(!message || !*message || sscanf(message, "%99[^\n]", sound_file) < 1) { clif->message(fd, msg_txt(1217)); // Please enter a sound filename (usage: @sound <filename>). return false; } - + if(strstr(sound_file, ".wav") == NULL) strcat(sound_file, ".wav"); - + clif->soundeffectall(&sd->bl, sound_file, 0, AREA); - + return true; } /*========================================== - * MOB Search + * MOB Search *------------------------------------------*/ ACMD(mobsearch) { @@ -5980,12 +5970,12 @@ ACMD(mobsearch) int mob_id; int number = 0; struct s_mapiterator* it; - + if (!message || !*message || sscanf(message, "%99[^\n]", mob_name) < 1) { clif->message(fd, msg_txt(1218)); // Please enter a monster name (usage: @mobsearch <monster name>). return false; } - + if ((mob_id = atoi(mob_name)) == 0) mob_id = mob->db_searchname(mob_name); if(mob_id > 0 && mob->db_checkid(mob_id) == 0){ @@ -5994,24 +5984,24 @@ ACMD(mobsearch) return false; } if(mob_id == atoi(mob_name) && mob->db(mob_id)->jname) - strcpy(mob_name,mob->db(mob_id)->jname); // --ja-- - // strcpy(mob_name,mob_db(mob_id)->name); // --en-- - + strcpy(mob_name,mob->db(mob_id)->jname); // --ja-- + //strcpy(mob_name,mob_db(mob_id)->name); // --en-- + snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s clif->message(fd, atcmd_output); - + it = mapit_geteachmob(); for(;;) { TBL_MOB* md = (TBL_MOB*)mapit->next(it); if( md == NULL ) break;// no more mobs - + if( md->bl.m != sd->bl.m ) continue; if( mob_id != -1 && md->class_ != mob_id ) continue; - + ++number; if( md->spawn_timer == INVALID_TIMER ) snprintf(atcmd_output, sizeof(atcmd_output), "%2d[%3d:%3d] %s", number, md->bl.x, md->bl.y, md->name); @@ -6020,7 +6010,7 @@ ACMD(mobsearch) clif->message(fd, atcmd_output); } mapit->free(it); - + return true; } @@ -6031,7 +6021,7 @@ ACMD(mobsearch) int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) { nullpo_ret(bl); map->clearflooritem(bl); - + return 0; } @@ -6043,7 +6033,7 @@ ACMD(cleanmap) { ACMD(cleanarea) { int x0 = 0, y0 = 0, x1 = 0, y1 = 0; - + if (!message || !*message || sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) < 1) { map->foreachinrange(atcommand->cleanfloor_sub, &sd->bl, AREA_SIZE * 2, BL_ITEM); } else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 1) { @@ -6051,7 +6041,7 @@ ACMD(cleanarea) { } else if (sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1) == 4) { map->foreachinarea(atcommand->cleanfloor_sub, sd->bl.m, x0, y0, x1, y1, BL_ITEM); } - + clif->message(fd, msg_txt(1221)); // All dropped items have been cleaned up. return true; } @@ -6066,12 +6056,12 @@ ACMD(npctalk) struct npc_data *nd; bool ifcolor=(*(info->command + 7) != 'c' && *(info->command + 7) != 'C')?0:1; unsigned int color = 0; - + if (sd->sc.count && //no "chatting" while muted. (sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT))) return false; - + if(!ifcolor) { if (!message || !*message || sscanf(message, "%23[^,], %99[^\n]", name, mes) < 2) { clif->message(fd, msg_txt(1222)); // Please enter the correct parameters (usage: @npctalk <npc name>, <message>). @@ -6084,18 +6074,18 @@ ACMD(npctalk) return false; } } - + if (!(nd = npc->name2id(name))) { clif->message(fd, msg_txt(111)); // This NPC doesn't exist return false; } - + strtok(name, "#"); // discard extra name identifier if present snprintf(temp, sizeof(temp), "%s : %s", name, mes); - + if(ifcolor) clif->messagecolor(&nd->bl,color,temp); else clif->disp_overhead(&nd->bl, temp); - + return true; } @@ -6103,29 +6093,29 @@ ACMD(pettalk) { char mes[100],temp[100]; struct pet_data *pd; - + if ( battle_config.min_chat_delay ) { if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 ) return true; sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } - + if(!sd->status.pet_id || !(pd=sd->pd)) { clif->message(fd, msg_txt(184)); return false; } - + if (sd->sc.count && //no "chatting" while muted. (sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT))) return false; - + if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) { clif->message(fd, msg_txt(1224)); // Please enter a message (usage: @pettalk <message>). return false; } - + if (message[0] == '/') {// pet emotion processing const char* emo[] = { @@ -6149,15 +6139,15 @@ ACMD(pettalk) return true; } sd->emotionlasttime = time(NULL); - + clif->emotion(&pd->bl, i); return true; } } - + snprintf(temp, sizeof temp ,"%s : %s", pd->pet.name, mes); clif->disp_overhead(&pd->bl, temp); - + return true; } @@ -6170,10 +6160,10 @@ ACMD(users) int users[MAX_MAPINDEX]; int users_all; struct s_mapiterator* iter; - + memset(users, 0, sizeof(users)); users_all = 0; - + // count users on each map iter = mapit_getallusers(); for(;;) @@ -6181,29 +6171,29 @@ ACMD(users) struct map_session_data* sd2 = (struct map_session_data*)mapit->next(iter); if( sd2 == NULL ) break;// no more users - + if( sd2->mapindex >= MAX_MAPINDEX ) continue;// invalid mapindex - + if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex]; if( users_all < INT_MAX ) ++users_all; } mapit->free(iter); - + // display results for each map for( i = 0; i < MAX_MAPINDEX; ++i ) { if( users[i] == 0 ) continue;// empty - + safesnprintf(buf, sizeof(buf), "%s: %d (%.2f%%)", mapindex_id2name(i), users[i], (float)(100.0f*users[i]/users_all)); clif->message(sd->fd, buf); } - + // display overall count safesnprintf(buf, sizeof(buf), "all: %d", users_all); clif->message(sd->fd, buf); - + return true; } @@ -6229,31 +6219,31 @@ ACMD(summon) int duration = 0; struct mob_data *md; int64 tick=timer->gettick(); - + if (!message || !*message || sscanf(message, "%23s %d", name, &duration) < 1) { clif->message(fd, msg_txt(1225)); // Please enter a monster name (usage: @summon <monster name> {duration}). return false; } - + if (duration < 1) duration =1; else if (duration > 60) duration =60; - + if ((mob_id = atoi(name)) == 0) mob_id = mob->db_searchname(name); if(mob_id == 0 || mob->db_checkid(mob_id) == 0) { - clif->message(fd, msg_txt(40)); // Invalid monster ID or name. + clif->message(fd, msg_txt(40)); // Invalid monster ID or name. return false; } - + md = mob->once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE); - + if(!md) return false; - + md->master_id=sd->bl.id; md->special_state.ai=1; md->deletetimer=timer->add(tick+(duration*60000),mob->timer_delete,md->bl.id,0); @@ -6261,8 +6251,8 @@ ACMD(summon) mob->spawn(md); sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000); clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick); - clif->message(fd, msg_txt(39)); // All monster summoned! - + clif->message(fd, msg_txt(39)); // All monster summoned! + return true; } @@ -6274,12 +6264,12 @@ ACMD(summon) ACMD(adjgroup) { int new_group = 0; - + if (!message || !*message || sscanf(message, "%d", &new_group) != 1) { clif->message(fd, msg_txt(1226)); // Usage: @adjgroup <group_id> return false; } - + if (pc->set_group(sd, new_group) != 0) { clif->message(fd, msg_txt(1227)); // Specified group does not exist. return false; @@ -6295,18 +6285,18 @@ ACMD(adjgroup) * Open a trade window with a remote player *------------------------------------------*/ ACMD(trade) { - struct map_session_data *pl_sd = NULL; - + struct map_session_data *pl_sd = NULL; + if (!message || !*message) { clif->message(fd, msg_txt(1230)); // Please enter a player name (usage: @trade <char name>). return false; } - + if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + trade->request(sd, pl_sd); return true; } @@ -6318,19 +6308,19 @@ ACMD(trade) { ACMD(setbattleflag) { char flag[128], value[128]; - + if (!message || !*message || sscanf(message, "%127s %127s", flag, value) != 2) { clif->message(fd, msg_txt(1231)); // Usage: @setbattleflag <flag> <value> return false; } - + if (battle->config_set_value(flag, value) == 0) { clif->message(fd, msg_txt(1232)); // Unknown battle_config flag. return false; } - + clif->message(fd, msg_txt(1233)); // Set battle_config as requested. - + return true; } @@ -6339,27 +6329,27 @@ ACMD(setbattleflag) *------------------------------------------*/ ACMD(unmute) { struct map_session_data *pl_sd = NULL; - + if (!message || !*message) { clif->message(fd, msg_txt(1234)); // Please enter a player name (usage: @unmute <char name>). return false; } - + if ( (pl_sd = map->nick2sd((char *)message)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + if(!pl_sd->sc.data[SC_NOCHAT]) { clif->message(sd->fd,msg_txt(1235)); // Player is not muted. return false; } - + pl_sd->status.manner = 0; status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER); clif->message(sd->fd,msg_txt(1236)); // Player unmuted. - + return true; } @@ -6370,7 +6360,7 @@ ACMD(uptime) { unsigned long seconds = 0, day = 24*60*60, hour = 60*60, minute = 60, days = 0, hours = 0, minutes = 0; - + seconds = timer->get_uptime(); days = seconds/day; seconds -= (seconds/day>0)?(seconds/day)*day:0; @@ -6378,10 +6368,10 @@ ACMD(uptime) seconds -= (seconds/hour>0)?(seconds/hour)*hour:0; minutes = seconds/minute; seconds -= (seconds/minute>0)?(seconds/minute)*minute:0; - + snprintf(atcmd_output, sizeof(atcmd_output), msg_txt(245), days, hours, minutes, seconds); clif->message(fd, atcmd_output); - + return true; } @@ -6407,26 +6397,26 @@ ACMD(changesex) ACMD(mute) { struct map_session_data *pl_sd = NULL; int manner; - + if (!message || !*message || sscanf(message, "%d %23[^\n]", &manner, atcmd_player_name) < 1) { clif->message(fd, msg_txt(1237)); // Usage: @mute <time> <char name> return false; } - + if ( (pl_sd = map->nick2sd(atcmd_player_name)) == NULL ) { clif->message(fd, msg_txt(3)); // Character not found. return false; } - + if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { clif->message(fd, msg_txt(81)); // Your GM level don't authorize you to do this action on this player. return false; } - + clif->manner_message(sd, 0); clif->manner_message(pl_sd, 5); - + if( pl_sd->status.manner < manner ) { pl_sd->status.manner -= manner; sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0); @@ -6434,9 +6424,9 @@ ACMD(mute) { pl_sd->status.manner = 0; status_change_end(&pl_sd->bl, SC_NOCHAT, INVALID_TIMER); } - + clif->GM_silence(sd, pl_sd, (manner > 0 ? 1 : 0)); - + return true; } @@ -6453,7 +6443,7 @@ ACMD(refreshall) { struct map_session_data* iter_sd; struct s_mapiterator* iter; - + iter = mapit_getallusers(); for (iter_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); iter_sd = (TBL_PC*)mapit->next(iter)) clif->refresh(iter_sd); @@ -6468,7 +6458,7 @@ ACMD(refreshall) ACMD(identify) { int i,num; - + for(i=num=0;i<MAX_INVENTORY;i++){ if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].identify!=1){ num++; @@ -6490,7 +6480,7 @@ ACMD(misceffect) { if (sscanf(message, "%d", &effect) < 1) return false; clif->misceffect(&sd->bl,effect); - + return true; } @@ -6517,103 +6507,103 @@ ACMD(mobinfo) struct mob_db *monster, *mob_array[MAX_SEARCH]; int count; int i, j, k; - + memset(atcmd_output, '\0', sizeof(atcmd_output)); memset(atcmd_output2, '\0', sizeof(atcmd_output2)); - + if (!message || !*message) { clif->message(fd, msg_txt(1239)); // Please enter a monster name/ID (usage: @mobinfo <monster_name_or_monster_ID>). return false; } - + // If monster identifier/name argument is a name if ((i = mob->db_checkid(atoi(message)))) { mob_array[0] = mob->db(i); count = 1; } else count = mob->db_searchname_array(mob_array, MAX_SEARCH, message, 0); - + if (!count) { clif->message(fd, msg_txt(40)); // Invalid monster ID or name. return false; } - + if (count > MAX_SEARCH) { sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); clif->message(fd, atcmd_output); count = MAX_SEARCH; } - + for (k = 0; k < count; k++) { unsigned int job_exp, base_exp; - + monster = mob_array[k]; - + job_exp = monster->job_exp; base_exp = monster->base_exp; - + #ifdef RENEWAL_EXP if( battle_config.atcommand_mobinfo_type ) { base_exp = base_exp * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 1) / 100; job_exp = job_exp * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 1) / 100; } #endif - + // stats if (monster->mexp) sprintf(atcmd_output, msg_txt(1240), monster->name, monster->jname, monster->sprite, monster->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d) else sprintf(atcmd_output, msg_txt(1241), monster->name, monster->jname, monster->sprite, monster->vd.class_); // Monster: '%s'/'%s'/'%s' (%d) clif->message(fd, atcmd_output); - + sprintf(atcmd_output, msg_txt(1242), monster->lv, monster->status.max_hp, base_exp, job_exp, MOB_HIT(monster), MOB_FLEE(monster)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d clif->message(fd, atcmd_output); - + sprintf(atcmd_output, msg_txt(1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d monster->status.def, monster->status.mdef, monster->status.str, monster->status.agi, monster->status.vit, monster->status.int_, monster->status.dex, monster->status.luk); clif->message(fd, atcmd_output); - + sprintf(atcmd_output, msg_txt(1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d) monster->status.rhw.atk, monster->status.rhw.atk2, monster->status.rhw.range, monster->range2 , monster->range3, msize[monster->status.size], mrace[monster->status.race], melement[monster->status.def_ele], monster->status.ele_lv); clif->message(fd, atcmd_output); - + // drops clif->message(fd, msg_txt(1245)); // Drops: strcpy(atcmd_output, " "); j = 0; for (i = 0; i < MAX_MOB_DROP; i++) { int droprate; - + if (monster->dropitem[i].nameid <= 0 || monster->dropitem[i].p < 1 || (item_data = itemdb->exists(monster->dropitem[i].nameid)) == NULL) continue; - + droprate = monster->dropitem[i].p; #ifdef RENEWAL_DROP if( battle_config.atcommand_mobinfo_type ) { droprate = droprate * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 2) / 100; - + if (droprate <= 0 && !battle_config.drop_rate0item) droprate = 1; } #endif - + if (item_data->slot) sprintf(atcmd_output2, " - %s[%d] %02.02f%%", item_data->jname, item_data->slot, (float)droprate / 100); else sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)droprate / 100); - + strcat(atcmd_output, atcmd_output2); - + if (++j % 3 == 0) { clif->message(fd, atcmd_output); strcpy(atcmd_output, " "); } } - + if (j == 0) clif->message(fd, msg_txt(1246)); // This monster has no drops. else if (j % 3 != 0) @@ -6622,7 +6612,7 @@ ACMD(mobinfo) if (monster->mexp) { sprintf(atcmd_output, msg_txt(1247), monster->mexp); // MVP Bonus EXP:%u clif->message(fd, atcmd_output); - + strcpy(atcmd_output, msg_txt(1248)); // MVP Items: j = 0; for (i = 0; i < MAX_MVP_DROP; i++) { @@ -6656,7 +6646,7 @@ ACMD(showmobs) int mob_id; int number = 0; struct s_mapiterator* it; - + if( sscanf(message, "%99[^\n]", mob_name) < 0 ) { clif->message(fd, msg_txt(546)); // Please enter a mob name/id (usage: @showmobs <mob name/id>) return false; @@ -6676,27 +6666,28 @@ ACMD(showmobs) clif->message(fd, atcmd_output); return false; } - - if(mob->db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs. + + if (mob->db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)) { + // If player group does not have access to boss mobs. clif->message(fd, msg_txt(1251)); // Can't show boss mobs! return false; } - + if(mob_id == atoi(mob_name) && mob->db(mob_id)->jname) strcpy(mob_name,mob->db(mob_id)->jname); // --ja-- //strcpy(mob_name,mob_db(mob_id)->name); // --en-- - + snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1252), // Mob Search... %s %s mob_name, mapindex_id2name(sd->mapindex)); clif->message(fd, atcmd_output); - + it = mapit_geteachmob(); for(;;) { TBL_MOB* md = (TBL_MOB*)mapit->next(it); if( md == NULL ) break;// no more mobs - + if( md->bl.m != sd->bl.m ) continue; if( mob_id != -1 && md->class_ != mob_id ) @@ -6705,12 +6696,12 @@ ACMD(showmobs) continue; // hide slaves and player summoned mobs if( md->spawn_timer != INVALID_TIMER ) continue; // hide mobs waiting for respawn - + ++number; clif->viewpoint(sd, 1, 0, md->bl.x, md->bl.y, number, 0xFFFFFF); } mapit->free(it); - + return true; } @@ -6721,19 +6712,19 @@ ACMD(homlevel) { TBL_HOM * hd; int level = 0; enum homun_type htype; - + if( !message || !*message || ( level = atoi(message) ) < 1 ) { clif->message(fd, msg_txt(1253)); // Please enter a level adjustment (usage: @homlevel <number of levels>). return false; } - + if( !homun_alive(sd->hd) ) { clif->message(fd, msg_txt(1254)); // You do not have a homunculus. return false; } - + hd = sd->hd; - + if( (htype = homun->class2type(hd->homunculus.class_)) == HT_INVALID ) { ShowError("atcommand_homlevel: invalid homun class %d (player %s)\n", hd->homunculus.class_,sd->status.name); return false; @@ -6759,12 +6750,11 @@ ACMD(homlevel) { ShowError("atcommand_homlevel: unknown htype '%d'\n",htype); return false; } - - + do { hd->homunculus.exp += hd->exp_next; } while( hd->homunculus.level < level && homun->levelup(hd) ); - + status_calc_homunculus(hd,SCO_NONE); status_percent_heal(&hd->bl, 100, 100); clif->specialeffect(&hd->bl,568,AREA); @@ -6780,7 +6770,7 @@ ACMD(homevolution) clif->message(fd, msg_txt(1254)); // You do not have a homunculus. return false; } - + if ( !homun->evolve(sd->hd) ) { clif->message(fd, msg_txt(1255)); // Your homunculus doesn't evolve. return false; @@ -6792,21 +6782,21 @@ ACMD(homevolution) ACMD(hommutate) { int homun_id; enum homun_type m_class, m_id; - + if( !homun_alive(sd->hd) ) { clif->message(fd, msg_txt(1254)); // You do not have a homunculus. return false; } - + if( !message || !*message ) { homun_id = 6048 + (rnd() % 4); } else { homun_id = atoi(message); } - + m_class = homun->class2type(sd->hd->homunculus.class_); - m_id = homun->class2type(homun_id); - + m_id = homun->class2type(homun_id); + if( m_class != HT_INVALID && m_id != HT_INVALID && m_class == HT_EVO && m_id == HT_S && sd->hd->homunculus.level >= 99 ) { homun->mutate(sd->hd, homun_id); } else { @@ -6820,14 +6810,14 @@ ACMD(hommutate) { *------------------------------------------*/ ACMD(makehomun) { int homunid; - + if (!message || !*message) { clif->message(fd, msg_txt(1256)); // Please enter a homunculus ID (usage: @makehomun <homunculus id>). return false; } - + homunid = atoi(message); - + if( homunid == -1 && sd->status.hom_id && !(sd->hd && homun_alive(sd->hd)) ) { if( !sd->hd ) homun->call(sd); @@ -6837,18 +6827,18 @@ ACMD(makehomun) { homun->call(sd); return true; } - + if ( sd->status.hom_id ) { clif->message(fd, msg_txt(450)); return false; } - + if( homunid < HM_CLASS_BASE || homunid > HM_CLASS_BASE + MAX_HOMUNCULUS_CLASS - 1 ) { clif->message(fd, msg_txt(1257)); // Invalid Homunculus ID. return false; } - + homun->creation_request(sd,homunid); return true; } @@ -6859,20 +6849,20 @@ ACMD(makehomun) { ACMD(homfriendly) { int friendly = 0; - + if ( !homun_alive(sd->hd) ) { clif->message(fd, msg_txt(1254)); // You do not have a homunculus. return false; } - + if (!message || !*message) { clif->message(fd, msg_txt(1258)); // Please enter a friendly value (usage: @homfriendly <friendly value [0-1000]>). return false; } - + friendly = atoi(message); friendly = cap_value(friendly, 0, 1000); - + sd->hd->homunculus.intimacy = friendly * 100 ; clif->send_homdata(sd,SP_INTIMATE,friendly); return true; @@ -6884,20 +6874,20 @@ ACMD(homfriendly) ACMD(homhungry) { int hungry = 0; - + if ( !homun_alive(sd->hd) ) { clif->message(fd, msg_txt(1254)); // You do not have a homunculus. return false; } - + if (!message || !*message) { clif->message(fd, msg_txt(1259)); // Please enter a hunger value (usage: @homhungry <hunger value [0-100]>). return false; } - + hungry = atoi(message); hungry = cap_value(hungry, 0, 100); - + sd->hd->homunculus.hunger = hungry; clif->send_homdata(sd,SP_HUNGRY,hungry); return true; @@ -6909,31 +6899,31 @@ ACMD(homhungry) ACMD(homtalk) { char mes[100],temp[100]; - + if ( battle_config.min_chat_delay ) { if( DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0 ) return true; sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; } - + if (sd->sc.count && //no "chatting" while muted. (sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT))) return false; - + if ( !homun_alive(sd->hd) ) { clif->message(fd, msg_txt(1254)); // You do not have a homunculus. return false; } - + if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) { clif->message(fd, msg_txt(1260)); // Please enter a message (usage: @homtalk <message>). return false; } - + snprintf(temp, sizeof temp ,"%s : %s", sd->hd->homunculus.name, mes); clif->disp_overhead(&sd->hd->bl, temp); - + return true; } @@ -6943,34 +6933,34 @@ ACMD(homtalk) ACMD(hominfo) { struct homun_data *hd; struct status_data *st; - + if ( !homun_alive(sd->hd) ) { clif->message(fd, msg_txt(1254)); // You do not have a homunculus. return false; } - + hd = sd->hd; st = status->get_status_data(&hd->bl); clif->message(fd, msg_txt(1261)); // Homunculus stats: - + snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1262), // HP: %d/%d - SP: %d/%d st->hp, st->max_hp, st->sp, st->max_sp); clif->message(fd, atcmd_output); - + snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1263), // ATK: %d - MATK: %d~%d st->rhw.atk2 +st->batk, st->matk_min, st->matk_max); clif->message(fd, atcmd_output); - + snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1264), // Hungry: %d - Intimacy: %u hd->homunculus.hunger, hd->homunculus.intimacy/100); clif->message(fd, atcmd_output); - + snprintf(atcmd_output, sizeof(atcmd_output) , msg_txt(1265), // Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d st->str, st->agi, st->vit, st->int_, st->dex, st->luk); clif->message(fd, atcmd_output); - + return true; } @@ -6980,75 +6970,75 @@ ACMD(homstats) struct s_homunculus_db *db; struct s_homunculus *hom; int lv, min, max, evo; - + if ( !homun_alive(sd->hd) ) { clif->message(fd, msg_txt(1254)); // You do not have a homunculus. return false; } - + hd = sd->hd; - + hom = &hd->homunculus; db = hd->homunculusDB; lv = hom->level; - + snprintf(atcmd_output, sizeof(atcmd_output) , msg_txt(1266), lv, db->name); // Homunculus growth stats (Lv %d %s): clif->message(fd, atcmd_output); lv--; //Since the first increase is at level 2. - + evo = (hom->class_ == db->evo_class); min = db->base.HP +lv*db->gmin.HP +(evo?db->emin.HP:0); max = db->base.HP +lv*db->gmax.HP +(evo?db->emax.HP:0);; snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1267), hom->max_hp, min, max); // Max HP: %d (%d~%d) clif->message(fd, atcmd_output); - + min = db->base.SP +lv*db->gmin.SP +(evo?db->emin.SP:0); max = db->base.SP +lv*db->gmax.SP +(evo?db->emax.SP:0);; snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1268), hom->max_sp, min, max); // Max SP: %d (%d~%d) clif->message(fd, atcmd_output); - + min = db->base.str +lv*(db->gmin.str/10) +(evo?db->emin.str:0); max = db->base.str +lv*(db->gmax.str/10) +(evo?db->emax.str:0);; snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1269), hom->str/10, min, max); // Str: %d (%d~%d) clif->message(fd, atcmd_output); - + min = db->base.agi +lv*(db->gmin.agi/10) +(evo?db->emin.agi:0); max = db->base.agi +lv*(db->gmax.agi/10) +(evo?db->emax.agi:0);; snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1270), hom->agi/10, min, max); // Agi: %d (%d~%d) clif->message(fd, atcmd_output); - + min = db->base.vit +lv*(db->gmin.vit/10) +(evo?db->emin.vit:0); max = db->base.vit +lv*(db->gmax.vit/10) +(evo?db->emax.vit:0);; snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1271), hom->vit/10, min, max); // Vit: %d (%d~%d) clif->message(fd, atcmd_output); - + min = db->base.int_ +lv*(db->gmin.int_/10) +(evo?db->emin.int_:0); max = db->base.int_ +lv*(db->gmax.int_/10) +(evo?db->emax.int_:0);; snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1272), hom->int_/10, min, max); // Int: %d (%d~%d) clif->message(fd, atcmd_output); - + min = db->base.dex +lv*(db->gmin.dex/10) +(evo?db->emin.dex:0); max = db->base.dex +lv*(db->gmax.dex/10) +(evo?db->emax.dex:0);; snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1273), hom->dex/10, min, max); // Dex: %d (%d~%d) clif->message(fd, atcmd_output); - + min = db->base.luk +lv*(db->gmin.luk/10) +(evo?db->emin.luk:0); max = db->base.luk +lv*(db->gmax.luk/10) +(evo?db->emax.luk:0);; snprintf(atcmd_output, sizeof(atcmd_output) ,msg_txt(1274), hom->luk/10, min, max); // Luk: %d (%d~%d) clif->message(fd, atcmd_output); - + return true; } -ACMD(homshuffle) { - +ACMD(homshuffle) +{ if(!sd->hd) return false; // nothing to do - + if(!homun->shuffle(sd->hd)) return false; - + clif->message(sd->fd, msg_txt(1275)); // Homunculus stats altered. atcommand_homstats(fd, sd, command, message, info); //Print out the new stats return true; @@ -7062,19 +7052,19 @@ ACMD(iteminfo) { struct item_data *item_data, *item_array[MAX_SEARCH]; int i, count = 1; - + if (!message || !*message) { clif->message(fd, msg_txt(1276)); // Please enter an item name/ID (usage: @ii/@iteminfo <item name/ID>). return false; } if ((item_array[0] = itemdb->exists(atoi(message))) == NULL) count = itemdb->search_name_array(item_array, MAX_SEARCH, message, 0); - + if (!count) { - clif->message(fd, msg_txt(19)); // Invalid item ID or name. + clif->message(fd, msg_txt(19)); // Invalid item ID or name. return false; } - + if (count > MAX_SEARCH) { sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches clif->message(fd, atcmd_output); @@ -7088,10 +7078,10 @@ ACMD(iteminfo) (item_data->script==NULL)? msg_txt(1278) : msg_txt(1279) // None / With script ); clif->message(fd, atcmd_output); - + sprintf(atcmd_output, msg_txt(1280), item_data->value_buy, item_data->value_sell, item_data->weight/10. ); // NPC Buy:%dz, Sell:%dz | Weight: %.1f clif->message(fd, atcmd_output); - + if (item_data->maxchance == -1) strcpy(atcmd_output, msg_txt(1281)); // - Available in the shops only. else if ( !battle_config.atcommand_mobinfo_type ) { @@ -7101,7 +7091,7 @@ ACMD(iteminfo) strcpy(atcmd_output, msg_txt(1283)); // - Monsters don't drop this item. } clif->message(fd, atcmd_output); - + } return true; } @@ -7113,19 +7103,19 @@ ACMD(whodrops) { struct item_data *item_data, *item_array[MAX_SEARCH]; int i,j, count = 1; - + if (!message || !*message) { clif->message(fd, msg_txt(1284)); // Please enter item name/ID (usage: @whodrops <item name/ID>). return false; } if ((item_array[0] = itemdb->exists(atoi(message))) == NULL) count = itemdb->search_name_array(item_array, MAX_SEARCH, message, 0); - + if (!count) { - clif->message(fd, msg_txt(19)); // Invalid item ID or name. + clif->message(fd, msg_txt(19)); // Invalid item ID or name. return false; } - + if (count > MAX_SEARCH) { sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); // Displaying first %d out of %d matches clif->message(fd, atcmd_output); @@ -7135,14 +7125,14 @@ ACMD(whodrops) item_data = item_array[i]; sprintf(atcmd_output, msg_txt(1285), item_data->jname,item_data->slot); // Item: '%s'[%d] clif->message(fd, atcmd_output); - + if (item_data->mob[0].chance == 0) { strcpy(atcmd_output, msg_txt(1286)); // - Item is not dropped by mobs. clif->message(fd, atcmd_output); } else { sprintf(atcmd_output, msg_txt(1287), MAX_SEARCH); // - Common mobs with highest drop chance (only max %d are listed): clif->message(fd, atcmd_output); - + for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++) { sprintf(atcmd_output, "- %s (%02.02f%%)", mob->db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.); @@ -7158,12 +7148,12 @@ ACMD(whereis) struct mob_db *monster, *mob_array[MAX_SEARCH]; int count; int i, j, k; - + if (!message || !*message) { clif->message(fd, msg_txt(1288)); // Please enter a monster name/ID (usage: @whereis <monster_name_or_monster_ID>). return false; } - + // If monster identifier/name argument is a name if ((i = mob->db_checkid(atoi(message)))) { @@ -7171,12 +7161,12 @@ ACMD(whereis) count = 1; } else count = mob->db_searchname_array(mob_array, MAX_SEARCH, message, 0); - + if (!count) { clif->message(fd, msg_txt(40)); // Invalid monster ID or name. return false; } - + if (count > MAX_SEARCH) { sprintf(atcmd_output, msg_txt(269), MAX_SEARCH, count); clif->message(fd, atcmd_output); @@ -7186,7 +7176,7 @@ ACMD(whereis) monster = mob_array[k]; snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), monster->jname); // %s spawns in: clif->message(fd, atcmd_output); - + for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++) { j = map->mapindex2mapid(monster->spawn[i].mapindex); if (j < 0) continue; @@ -7196,7 +7186,7 @@ ACMD(whereis) if (i == 0) clif->message(fd, msg_txt(1290)); // This monster does not spawn normally. } - + return true; } @@ -7214,15 +7204,15 @@ ACMD(version) { *------------------------------------------*/ int atcommand_mutearea_sub(struct block_list *bl,va_list ap) { // As it is being used [ACMD(mutearea)] there's no need to be a bool, but if there's need to reuse it, it's better to be this way - + int time, id; struct map_session_data *pl_sd = (struct map_session_data *)bl; if (pl_sd == NULL) return 0; - + id = va_arg(ap, int); time = va_arg(ap, int); - + if (id != bl->id && !pc_get_group_level(pl_sd)) { pl_sd->status.manner -= time; if (pl_sd->status.manner < 0) @@ -7235,18 +7225,18 @@ int atcommand_mutearea_sub(struct block_list *bl,va_list ap) ACMD(mutearea) { int time; - + if (!message || !*message) { clif->message(fd, msg_txt(1297)); // Please enter a time in minutes (usage: @mutearea/@stfu <time in minutes>). return false; } - + time = atoi(message); - + map->foreachinarea(atcommand->mutearea_sub,sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd->bl.id, time); - + return true; } @@ -7254,9 +7244,9 @@ ACMD(mutearea) { ACMD(rates) { char buf[CHAT_SIZE_MAX]; - + memset(buf, '\0', sizeof(buf)); - + snprintf(buf, CHAT_SIZE_MAX, msg_txt(1298), // Experience rates: Base %.2fx / Job %.2fx battle_config.base_exp_rate/100., battle_config.job_exp_rate/100.); clif->message(fd, buf); @@ -7269,7 +7259,7 @@ ACMD(rates) snprintf(buf, CHAT_SIZE_MAX, msg_txt(1301), // Other Drop Rates: MvP %.2fx / Card-Based %.2fx / Treasure %.2fx battle_config.item_rate_mvp/100., battle_config.item_rate_adddrop/100., battle_config.item_rate_treasure/100.); clif->message(fd, buf); - + return true; } @@ -7280,25 +7270,24 @@ ACMD(rates) ACMD(me) { char tempmes[CHAT_SIZE_MAX]; - + memset(tempmes, '\0', sizeof(tempmes)); memset(atcmd_output, '\0', sizeof(atcmd_output)); - + if (sd->sc.count && //no "chatting" while muted. (sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT))) return false; - + if (!message || !*message || sscanf(message, "%199[^\n]", tempmes) < 0) { clif->message(fd, msg_txt(1302)); // Please enter a message (usage: @me <message>). return false; } - - sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s* + + sprintf(atcmd_output, msg_txt(270), sd->status.name, tempmes); // *%s %s* clif->disp_overhead(&sd->bl, atcmd_output); - + return true; - } /*========================================== @@ -7308,20 +7297,20 @@ ACMD(me) ACMD(size) { int size = 0; - + size = cap_value(atoi(message),SZ_SMALL,SZ_BIG); - + if(sd->state.size) { sd->state.size = SZ_SMALL; pc->setpos(sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_TELEPORT); } - + sd->state.size = size; if( size == SZ_MEDIUM ) clif->specialeffect(&sd->bl,420,AREA); else if( size == SZ_BIG ) clif->specialeffect(&sd->bl,422,AREA); - + clif->message(fd, msg_txt(1303)); // Size change applied. return true; } @@ -7331,10 +7320,10 @@ ACMD(sizeall) int size; struct map_session_data *pl_sd; struct s_mapiterator* iter; - + size = atoi(message); size = cap_value(size,0,2); - + iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if( pl_sd->state.size != size ) { @@ -7342,7 +7331,7 @@ ACMD(sizeall) pl_sd->state.size = SZ_SMALL; pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT); } - + pl_sd->state.size = size; if( size == SZ_MEDIUM ) clif->specialeffect(&pl_sd->bl,420,AREA); @@ -7351,7 +7340,7 @@ ACMD(sizeall) } } mapit->free(iter); - + clif->message(fd, msg_txt(1303)); // Size change applied. return true; } @@ -7362,28 +7351,28 @@ ACMD(sizeguild) char guild_name[NAME_LENGTH]; struct map_session_data *pl_sd; struct guild *g; - + memset(guild_name, '\0', sizeof(guild_name)); - + if( !message || !*message || sscanf(message, "%d %23[^\n]", &size, guild_name) < 2 ) { clif->message(fd, msg_txt(1304)); // Please enter guild name/ID (usage: @sizeguild <size> <guild name/ID>). return false; } - + if( (g = guild->searchname(guild_name)) == NULL && (g = guild->search(atoi(guild_name))) == NULL ) { clif->message(fd, msg_txt(94)); // Incorrect name/ID, or no one from the guild is online. return false; } - + size = cap_value(size,SZ_SMALL,SZ_BIG); - + for( i = 0; i < g->max_member; i++ ) { if( (pl_sd = g->member[i].sd) && pl_sd->state.size != size ) { if( pl_sd->state.size ) { pl_sd->state.size = SZ_SMALL; pc->setpos(pl_sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT); } - + pl_sd->state.size = size; if( size == SZ_MEDIUM ) clif->specialeffect(&pl_sd->bl,420,AREA); @@ -7391,7 +7380,7 @@ ACMD(sizeguild) clif->specialeffect(&pl_sd->bl,422,AREA); } } - + clif->message(fd, msg_txt(1303)); // Size change applied. return true; } @@ -7400,8 +7389,8 @@ ACMD(sizeguild) * @monsterignore * => Makes monsters ignore you. [Valaris] *------------------------------------------*/ -ACMD(monsterignore) { - +ACMD(monsterignore) +{ if (!sd->state.monster_ignore) { sd->state.monster_ignore = 1; clif->message(sd->fd, msg_txt(1305)); // You are now immune to attacks. @@ -7409,15 +7398,15 @@ ACMD(monsterignore) { sd->state.monster_ignore = 0; clif->message(sd->fd, msg_txt(1306)); // Returned to normal state. } - + return true; } /*========================================== * @fakename * => Gives your character a fake name. [Valaris] *------------------------------------------*/ -ACMD(fakename){ - +ACMD(fakename) +{ if( !message || !*message ) { if( sd->fakename[0] ) @@ -7429,23 +7418,23 @@ ACMD(fakename){ clif->message(sd->fd, msg_txt(1307)); // Returned to real name. return true; } - + clif->message(sd->fd, msg_txt(1308)); // You must enter a name. return false; } - + if( strlen(message) < 2 ) { clif->message(sd->fd, msg_txt(1309)); // Fake name must be at least two characters. return false; } - + safestrncpy(sd->fakename, message, sizeof(sd->fakename)); clif->charnameack(0, &sd->bl); if( sd->disguise ) // Another packet should be sent so the client updates the name for sd clif->charnameack(sd->fd, &sd->bl); clif->message(sd->fd, msg_txt(1310)); // Fake name enabled. - + return true; } @@ -7467,7 +7456,7 @@ ACMD(mapflag) { short flag=0,i; memset(flag_name, '\0', sizeof(flag_name)); - + if (!message || !*message || (sscanf(message, "%99s %hd", flag_name, &flag) < 1)) { clif->message(sd->fd,msg_txt(1311)); // Enabled Mapflags in this map: clif->message(sd->fd,"----------------------------------"); @@ -7490,7 +7479,7 @@ ACMD(mapflag) { return true; } for (i = 0; flag_name[i]; i++) flag_name[i] = TOLOWER(flag_name[i]); //lowercase - + if ( strcmp( flag_name , "gvg" ) == 0 ) { if( flag && !map->list[sd->bl.m].flag.gvg ) map->zone_change2(sd->bl.m,strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)); @@ -7507,7 +7496,7 @@ ACMD(mapflag) { else if ( !flag && map->list[sd->bl.m].flag.battleground ) map->zone_change2(sd->bl.m,map->list[sd->bl.m].prev_zone); } - + SETFLAG(autotrade); SETFLAG(allowks); SETFLAG(nomemo); SETFLAG(noteleport); SETFLAG(noreturn); SETFLAG(monster_noteleport); SETFLAG(nosave); SETFLAG(nobranch); SETFLAG(noexppenalty); SETFLAG(pvp); SETFLAG(pvp_noparty); SETFLAG(pvp_noguild); @@ -7521,7 +7510,7 @@ ACMD(mapflag) { SETFLAG(nodrop); SETFLAG(novending); SETFLAG(loadevent); SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); SETFLAG(src4instance); SETFLAG(notomb); SETFLAG(nocashshop); - + clif->message(sd->fd,msg_txt(1314)); // Invalid flag name or flag. clif->message(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On) clif->message(sd->fd,msg_txt(1315)); // Available Flags: @@ -7533,10 +7522,9 @@ ACMD(mapflag) { clif->message(sd->fd,"fog, fireworks, sakura, leaves, nobaseexp, nojobexp, nomobloot,"); clif->message(sd->fd,"nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,"); clif->message(sd->fd,"guildlock, src4instance, notomb, nocashshop"); - #undef CHECKFLAG #undef SETFLAG - + return true; } @@ -7550,7 +7538,7 @@ ACMD(showexp) clif->message(fd, msg_txt(1316)); // Gained exp will not be shown. return true; } - + sd->state.showexp = 1; clif->message(fd, msg_txt(1317)); // Gained exp is now shown. return true; @@ -7563,7 +7551,7 @@ ACMD(showzeny) clif->message(fd, msg_txt(1318)); // Gained zeny will not be shown. return true; } - + sd->state.showzeny = 1; clif->message(fd, msg_txt(1319)); // Gained zeny is now shown. return true; @@ -7576,7 +7564,7 @@ ACMD(showdelay) clif->message(fd, msg_txt(1320)); // Skill delay failures will not be shown. return true; } - + sd->state.showdelay = 1; clif->message(fd, msg_txt(1321)); // Skill delay failures are now shown. return true; @@ -7594,34 +7582,33 @@ ACMD(showdelay) ACMD(invite) { unsigned int did = sd->duel_group; struct map_session_data *target_sd = map->nick2sd((char *)message); - + if(did == 0) { // "Duel: @invite without @duel." clif->message(fd, msg_txt(350)); return false; } - + if(duel->list[did].max_players_limit > 0 && duel->list[did].members_count >= duel->list[did].max_players_limit) { - // "Duel: Limit of players is reached." clif->message(fd, msg_txt(351)); return false; } - + if(target_sd == NULL) { // "Duel: Player not found." clif->message(fd, msg_txt(352)); return false; } - + if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) { // "Duel: Player already in duel." clif->message(fd, msg_txt(353)); return false; } - + if(battle_config.duel_only_on_same_map && target_sd->bl.m != sd->bl.m) { // "Duel: You can't invite %s because he/she isn't in the same map." @@ -7629,7 +7616,7 @@ ACMD(invite) { clif->message(fd, atcmd_output); return false; } - + duel->invite(did, sd, target_sd); // "Duel: Invitation has been sent." clif->message(fd, msg_txt(354)); @@ -7638,18 +7625,18 @@ ACMD(invite) { ACMD(duel) { unsigned int maxpl = 0; - + if(sd->duel_group > 0) { duel->showinfo(sd->duel_group, sd); return true; } - + if(sd->duel_invite > 0) { // "Duel: @duel without @reject." clif->message(fd, msg_txt(355)); return false; } - + if(!duel->checktime(sd)) { char output[CHAT_SIZE_MAX]; // "Duel: You can take part in duel only one time per %d minutes." @@ -7657,7 +7644,7 @@ ACMD(duel) { clif->message(fd, output); return false; } - + if( message[0] ) { if(sscanf(message, "%d", &maxpl) >= 1) { if(maxpl < 2 || maxpl > 65535) { @@ -7671,7 +7658,7 @@ ACMD(duel) { if(target_sd != NULL) { unsigned int newduel; if((newduel = duel->create(sd, 2)) != -1) { - if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) { + if(target_sd->duel_group > 0 || target_sd->duel_invite > 0) { clif->message(fd, msg_txt(353)); // "Duel: Player already in duel." return false; } @@ -7686,7 +7673,7 @@ ACMD(duel) { } } else duel->create(sd, 0); - + return true; } @@ -7697,7 +7684,6 @@ ACMD(leave) { clif->message(fd, msg_txt(358)); return false; } - duel->leave(sd->duel_group, sd); clif->message(fd, msg_txt(359)); // "Duel: You left the duel." return true; @@ -7711,20 +7697,20 @@ ACMD(accept) { clif->message(fd, output); return false; } - + if(sd->duel_invite <= 0) { // "Duel: @accept without invitation." clif->message(fd, msg_txt(360)); return false; } - + if( duel->list[sd->duel_invite].max_players_limit > 0 && duel->list[sd->duel_invite].members_count >= duel->list[sd->duel_invite].max_players_limit ) { // "Duel: Limit of players is reached." clif->message(fd, msg_txt(351)); return false; } - + duel->accept(sd->duel_invite, sd); // "Duel: Invitation has been accepted." clif->message(fd, msg_txt(361)); @@ -7737,7 +7723,7 @@ ACMD(reject) { clif->message(fd, msg_txt(362)); return false; } - + duel->reject(sd->duel_invite, sd); // "Duel: Invitation has been rejected." clif->message(fd, msg_txt(363)); @@ -7752,12 +7738,12 @@ ACMD(cash) char output[128]; int value; int ret=0; - + if( !message || !*message || (value = atoi(message)) == 0 ) { clif->message(fd, msg_txt(1322)); // Please enter an amount. return false; } - + if( !strcmpi(info->command,"cash") ) { if( value > 0 ) { if( (ret=pc->getcash(sd, value, 0)) >= 0){ @@ -7793,7 +7779,7 @@ ACMD(cash) clif->message(fd, msg_txt(41)); // Unable to decrease the number/value. } } - + return true; } @@ -7801,22 +7787,22 @@ ACMD(cash) ACMD(clone) { int x=0,y=0,flag=0,master=0,i=0; struct map_session_data *pl_sd=NULL; - + if (!message || !*message) { clif->message(sd->fd,msg_txt(1323)); // You must enter a player name or ID. return false; } - + if((pl_sd=map->nick2sd((char *)message)) == NULL && (pl_sd=map->charid2sd(atoi(message))) == NULL) { - clif->message(fd, msg_txt(3)); // Character not found. + clif->message(fd, msg_txt(3)); // Character not found. return false; } - + if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) { - clif->message(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself. + clif->message(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself. return false; } - + if (strcmpi(info->command, "clone") == 0) flag = 1; else if (strcmpi(info->command, "slaveclone") == 0) { @@ -7829,26 +7815,26 @@ ACMD(clone) { master = sd->bl.id; if (battle_config.atc_slave_clone_limit && mob->countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) { - clif->message(fd, msg_txt(127)); // You've reached your slave clones limit. + clif->message(fd, msg_txt(127)); // You've reached your slave clones limit. return false; } } - + do { x = sd->bl.x + (rnd() % 10 - 5); y = sd->bl.y + (rnd() % 10 - 5); } while (map->getcell(sd->bl.m,x,y,CELL_CHKNOPASS) && i++ < 10); - + if (i >= 10) { x = sd->bl.x; y = sd->bl.y; } - + if((x = mob->clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) { - clif->message(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned. + clif->message(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned. return true; } - clif->message(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone. + clif->message(fd, msg_txt(129+flag*2)); // Unable to spawn evil clone. Unable to spawn clone. Unable to spawn slave clone. return false; } @@ -7865,7 +7851,7 @@ ACMD(noask) clif->message(fd, msg_txt(390)); // Autorejecting is activated. sd->state.noask = 1; } - + return true; } @@ -7876,14 +7862,14 @@ ACMD(noask) ACMD(request) { if (!message || !*message) { - clif->message(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>. + clif->message(sd->fd,msg_txt(277)); // Usage: @request <petition/message to online GMs>. return false; } - - sprintf(atcmd_output, msg_txt(278), message); // (@request): %s + + sprintf(atcmd_output, msg_txt(278), message); // (@request): %s intif->wis_message_to_gm(sd->status.name, PC_PERM_RECEIVE_REQUESTS, atcmd_output); clif_disp_onlyself(sd, atcmd_output, strlen(atcmd_output)); - clif->message(sd->fd,msg_txt(279)); // @request sent. + clif->message(sd->fd,msg_txt(279)); // @request sent. return true; } @@ -7894,7 +7880,7 @@ ACMD(feelreset) { pc->resetfeel(sd); clif->message(fd, msg_txt(1324)); // Reset 'Feeling' maps. - + return true; } @@ -7902,14 +7888,14 @@ ACMD(feelreset) * AUCTION SYSTEM *------------------------------------------*/ ACMD(auction) { - + if( !battle_config.feature_auction ) { clif->colormes(sd->fd,COLOR_RED,msg_txt(1484)); return false; } - + clif->auction_openwindow(sd); - + return true; } @@ -7947,8 +7933,8 @@ ACMD(ksprotection) /*========================================== * Map Kill Steal Protection Setting *------------------------------------------*/ -ACMD(allowks) { - +ACMD(allowks) +{ if( map->list[sd->bl.m].flag.allowks ) { map->list[sd->bl.m].flag.allowks = 0; clif->message(fd, msg_txt(1330)); // [ Map K.S Protection Active ] @@ -7959,16 +7945,16 @@ ACMD(allowks) { return true; } -ACMD(resetstat) { - +ACMD(resetstat) +{ pc->resetstate(sd); sprintf(atcmd_output, msg_txt(207), sd->status.name); clif->message(fd, atcmd_output); return true; } -ACMD(resetskill) { - +ACMD(resetskill) +{ pc->resetskill(sd,1); sprintf(atcmd_output, msg_txt(206), sd->status.name); clif->message(fd, atcmd_output); @@ -7987,7 +7973,7 @@ ACMD(itemlist) const struct item* items; int size; StringBuf buf; - + if( strcmpi(info->command, "storagelist") == 0 ) { location = "storage"; items = sd->status.storage.items; @@ -8002,34 +7988,34 @@ ACMD(itemlist) size = MAX_INVENTORY; } else return false; - + StrBuf->Init(&buf); - + count = 0; // total slots occupied counter = 0; // total items found for( i = 0; i < size; ++i ) { const struct item* it = &items[i]; struct item_data* itd; - + if( it->nameid == 0 || (itd = itemdb->exists(it->nameid)) == NULL ) continue; - + counter += it->amount; count++; - + if( count == 1 ) { StrBuf->Printf(&buf, msg_txt(1332), location, sd->status.name); // ------ %s items list of '%s' ------ clif->message(fd, StrBuf->Value(&buf)); StrBuf->Clear(&buf); } - + if( it->refine ) StrBuf->Printf(&buf, "%d %s %+d (%s, id: %d)", it->amount, itd->jname, it->refine, itd->name, it->nameid); else StrBuf->Printf(&buf, "%d %s (%s, id: %d)", it->amount, itd->jname, itd->name, it->nameid); - + if( it->equip ) { char equipstr[CHAT_SIZE_MAX]; strcpy(equipstr, msg_txt(1333)); // | equipped: @@ -8065,10 +8051,10 @@ ACMD(itemlist) equipstr[strlen(equipstr) - 2] = '\0'; StrBuf->AppendStr(&buf, equipstr); } - + clif->message(fd, StrBuf->Value(&buf)); StrBuf->Clear(&buf); - + if( it->card[0] == CARD0_PET ) { // pet egg if (it->card[3]) @@ -8105,22 +8091,21 @@ ACMD(itemlist) if( counter2 > 0 ) StrBuf->AppendStr(&buf, ")"); } - + if( StrBuf->Length(&buf) > 0 ) clif->message(fd, StrBuf->Value(&buf)); StrBuf->Clear(&buf); } - + if( count == 0 ) StrBuf->Printf(&buf, msg_txt(1353), location); // No item found in this player's %s. else StrBuf->Printf(&buf, msg_txt(1354), counter, count, location); // %d item(s) found in %d %s slots. - + clif->message(fd, StrBuf->Value(&buf)); - + StrBuf->Destroy(&buf); - return true; } @@ -8151,10 +8136,10 @@ ACMD(stats) { "JobChangeLvl (3rd) - %d", 0 }, { NULL, 0 } }; - + memset(job_jobname, '\0', sizeof(job_jobname)); memset(output, '\0', sizeof(output)); - + //direct array initialization with variables is not standard C compliant. output_table[0].value = sd->status.base_level; output_table[1].format = job_jobname; @@ -8173,17 +8158,16 @@ ACMD(stats) output_table[13].value = sd->status.skill_point; output_table[14].value = sd->change_level_2nd; output_table[15].value = sd->change_level_3rd; - + sprintf(job_jobname, "Job - %s %s", pc->job_name(sd->status.class_), "(level %d)"); sprintf(output, msg_txt(53), sd->status.name); // '%s' stats: - + clif->message(fd, output); - + for (i = 0; output_table[i].format != NULL; i++) { sprintf(output, output_table[i].format, output_table[i].value); clif->message(fd, output); } - return true; } @@ -8191,13 +8175,13 @@ ACMD(delitem) { char item_name[100]; int nameid, amount = 0, total, idx; struct item_data* id; - + if( !message || !*message || ( sscanf(message, "\"%99[^\"]\" %d", item_name, &amount) < 2 && sscanf(message, "%99s %d", item_name, &amount) < 2 ) || amount < 1 ) { clif->message(fd, msg_txt(1355)); // Please enter an item name/ID, a quantity, and a player name (usage: #delitem <player> <item_name_or_ID> <quantity>). return false; } - + if( ( id = itemdb->search_name(item_name) ) != NULL || ( id = itemdb->exists(atoi(item_name)) ) != NULL ) { nameid = id->nameid; @@ -8207,26 +8191,26 @@ ACMD(delitem) { clif->message(fd, msg_txt(19)); // Invalid item ID or name. return false; } - + total = amount; - + // delete items while (amount && (idx = pc->search_inventory(sd, nameid)) != INDEX_NOT_FOUND) { int delamount = ( amount < sd->status.inventory[idx].amount ) ? amount : sd->status.inventory[idx].amount; - + if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET ) {// delete pet intif->delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2])); } pc->delitem(sd, idx, delamount, 0, 0, LOG_TYPE_COMMAND); - + amount-= delamount; } - + // notify target sprintf(atcmd_output, msg_txt(113), total-amount); // %d item(s) removed by a GM. clif->message(sd->fd, atcmd_output); - + // notify source if( amount == total ) { @@ -8242,7 +8226,6 @@ ACMD(delitem) { sprintf(atcmd_output, msg_txt(114), total); // %d item(s) removed from the player. clif->message(fd, atcmd_output); } - return true; } @@ -8251,7 +8234,7 @@ ACMD(delitem) { *------------------------------------------*/ ACMD(font) { int font_id; - + font_id = atoi(message); if( font_id == 0 ) { @@ -8277,7 +8260,7 @@ ACMD(font) { } else clif->message(fd, msg_txt(1361)); // Already using this font. - + return true; } @@ -8291,15 +8274,15 @@ void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommand AtCommandInfo* cmd; DBIterator *iter = db_iterator(atcommand->db); int count = 0; - + memset(line_buff,' ',CHATBOX_SIZE); line_buff[CHATBOX_SIZE-1] = 0; - + clif->message(fd, msg_txt(273)); // "Available commands:" - + for (cmd = dbi_first(iter); dbi_exists(iter); cmd = dbi_next(iter)) { size_t slen; - + switch( type ) { case COMMAND_CHARCOMMAND: if( cmd->char_groups[pcg->get_idx(sd->group)] == 0 ) @@ -8312,10 +8295,9 @@ void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommand default: continue; } - - + slen = strlen(cmd->command); - + // flush the text buffer if this command won't fit into it if ( slen + cur - line_buff >= CHATBOX_SIZE ) { @@ -8324,18 +8306,18 @@ void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommand memset(line_buff,' ',CHATBOX_SIZE); line_buff[CHATBOX_SIZE-1] = 0; } - + memcpy(cur,cmd->command,slen); cur += slen+(10-slen%10); - + count++; } dbi_destroy(iter); clif->message(fd,line_buff); - + sprintf(atcmd_output, msg_txt(274), count); // "%d commands found." clif->message(fd, atcmd_output); - + return; } @@ -8359,12 +8341,11 @@ ACMD(charcommands) /* for new mounts */ ACMD(cashmount) { - if (pc_hasmount(sd)) { clif->message(fd, msg_txt(1476)); // You are already mounting something else return false; } - + clif->message(sd->fd,msg_txt(1362)); // NOTICE: If you crash with mount your LUA is outdated. if (!sd->sc.data[SC_ALL_RIDING]) { clif->message(sd->fd,msg_txt(1363)); // You have mounted. @@ -8378,18 +8359,17 @@ ACMD(cashmount) ACMD(accinfo) { char query[NAME_LENGTH]; - + if (!message || !*message || strlen(message) > NAME_LENGTH ) { clif->message(fd, msg_txt(1365)); // Usage: @accinfo/@accountinfo <account_id/char name> clif->message(fd, msg_txt(1366)); // You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario". return false; } - + //remove const type safestrncpy(query, message, NAME_LENGTH); - intif->request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query ); - + return true; } @@ -8400,7 +8380,7 @@ ACMD(set) { int toset = 0; bool is_str = false; size_t len; - + if( !message || !*message || (toset = sscanf(message, "%31s %128[^\n]s", reg, val)) < 1 ) { clif->message(fd, msg_txt(1367)); // Usage: @set <variable name> <value> clif->message(fd, msg_txt(1368)); // Usage: ex. "@set PoringCharVar 50" @@ -8408,7 +8388,7 @@ ACMD(set) { clif->message(fd, msg_txt(1370)); // Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String. return false; } - + /* disabled variable types (they require a proper script state to function, so allowing them would crash the server) */ if( reg[0] == '.' ) { clif->message(fd, msg_txt(1371)); // NPC variables may not be used with @set. @@ -8417,29 +8397,26 @@ ACMD(set) { clif->message(fd, msg_txt(1372)); // Instance variables may not be used with @set. return false; } - + is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false; - + if( ( len = strlen(val) ) > 1 ) { if( val[0] == '"' && val[len-1] == '"') { val[len-1] = '\0'; //Strip quotes. memmove(val, val+1, len-1); } } - + if( toset >= 2 ) {/* we only set the var if there is an val, otherwise we only output the value */ if( is_str ) script->set_var(sd, reg, (void*) val); else script->set_var(sd, reg, (void*)h64BPTRSIZE((atoi(val)))); - } - + CREATE(data, struct script_data,1); - - + if( is_str ) {// string variable - switch( reg[0] ) { case '@': data->u.str = pc->readregstr(sd, script->add_str(reg)); @@ -8457,7 +8434,6 @@ ACMD(set) { data->u.str = pc_readglobalreg_str(sd, script->add_str(reg)); break; } - if( data->u.str == NULL || data->u.str[0] == '\0' ) {// empty string data->type = C_CONSTSTR; data->u.str = ""; @@ -8465,9 +8441,7 @@ ACMD(set) { data->type = C_STR; data->u.str = aStrdup(data->u.str); } - } else {// integer variable - data->type = C_INT; switch( reg[0] ) { case '@': @@ -8486,10 +8460,8 @@ ACMD(set) { data->u.num = pc_readglobalreg(sd, script->add_str(reg)); break; } - } - - + switch( data->type ) { case C_INT: sprintf(atcmd_output,msg_txt(1373),reg,data->u.num); // %s value is now :%d @@ -8504,11 +8476,9 @@ ACMD(set) { sprintf(atcmd_output,msg_txt(1376),reg,data->type); // %s data type is not supported :%u break; } - clif->message(fd, atcmd_output); - + aFree(data); - return true; } ACMD(reloadquestdb) { @@ -8520,7 +8490,7 @@ ACMD(addperm) { int perm_size = pcg->permission_count; bool add = (strcmpi(info->command, "addperm") == 0) ? true : false; int i; - + if( !message || !*message ) { sprintf(atcmd_output, msg_txt(1378),command); // Usage: %s <permission_name> clif->message(fd, atcmd_output); @@ -8531,9 +8501,8 @@ ACMD(addperm) { } return false; } - + ARR_FIND(0, perm_size, i, strcmpi(pcg->permissions[i].name, message) == 0); - if( i == perm_size ) { sprintf(atcmd_output,msg_txt(1380),message); // '%s' is not a known permission. clif->message(fd, atcmd_output); @@ -8544,7 +8513,7 @@ ACMD(addperm) { } return false; } - + if( add && (sd->extra_temp_permissions&pcg->permissions[i].permission) ) { sprintf(atcmd_output, msg_txt(1381),sd->status.name,pcg->permissions[i].name); // User '%s' already possesses the '%s' permission. clif->message(fd, atcmd_output); @@ -8560,28 +8529,26 @@ ACMD(addperm) { clif->message(fd, atcmd_output); } } - return false; } - + if( add ) sd->extra_temp_permissions |= pcg->permissions[i].permission; else sd->extra_temp_permissions &=~ pcg->permissions[i].permission; - - + sprintf(atcmd_output, msg_txt(1384),sd->status.name); // User '%s' permissions updated successfully. The changes are temporary. clif->message(fd, atcmd_output); - + return true; } -ACMD(unloadnpcfile) { - +ACMD(unloadnpcfile) +{ if( !message || !*message ) { clif->message(fd, msg_txt(1385)); // Usage: @unloadnpcfile <file name> return false; } - + if( npc->unloadfile(message) ) clif->message(fd, msg_txt(1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed. else { @@ -8596,39 +8563,39 @@ ACMD(cart) { sd->status.skill[idx].lv = (x)?1:0; \ sd->status.skill[idx].flag = (x)?1:0; \ } while(0) - + int val = atoi(message); bool need_skill = pc->checkskill(sd, MC_PUSHCART) ? false : true; unsigned int index = skill->get_index(MC_PUSHCART); - + if( !message || !*message || val < 0 || val > MAX_CARTS ) { sprintf(atcmd_output, msg_txt(1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>). clif->message(fd, atcmd_output); return false; } - + if( val == 0 && !pc_iscarton(sd) ) { clif->message(fd, msg_txt(1391)); // You do not possess a cart to be removed return false; } - + if( need_skill ) { MC_CART_MDFY(1,index); } - + if( pc->setcart(sd, val) ) { if( need_skill ) { MC_CART_MDFY(0,index); } return false;/* @cart failed */ } - + if( need_skill ) { MC_CART_MDFY(0,index); } - + clif->message(fd, msg_txt(1392)); // Cart Added - + return true; #undef MC_CART_MDFY } @@ -8636,7 +8603,7 @@ ACMD(cart) { ACMD(join) { struct hChSysCh *channel = NULL; char name[HCHSYS_NAME_LENGTH], pass[HCHSYS_NAME_LENGTH]; - + if (!message || !*message || sscanf(message, "%19s %19s", name, pass) < 1) { sprintf(atcmd_output, msg_txt(1399),command); // Unknown Channel (usage: %s <#channel_name>) clif->message(fd, atcmd_output); @@ -8658,14 +8625,13 @@ ACMD(join) { clif->message(fd, atcmd_output); return false; } - + if( !channel ) { sprintf(atcmd_output, msg_txt(1400),name,command); // Unknown Channel '%s' (usage: %s <#channel_name>) clif->message(fd, atcmd_output); return false; } - - + if( idb_exists(channel->users, sd->status.char_id) ) { sprintf(atcmd_output, msg_txt(1436),name); // You're already in the '%s' channel clif->message(fd, atcmd_output); @@ -8680,13 +8646,13 @@ ACMD(join) { return false; } } - + if( channel->banned && idb_exists(channel->banned, sd->status.account_id) ) { sprintf(atcmd_output, msg_txt(1438),name); // You cannot join the '%s' channel because you've been banned from it clif->message(fd, atcmd_output); return false; } - + if( !( channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) { sprintf(atcmd_output, msg_txt(1403),name); // You're now in the '%s' channel clif->message(fd, atcmd_output); @@ -8703,7 +8669,7 @@ ACMD(join) { } } clif->chsys_join(channel,sd); - + return true; } /* [Ind/Hercules] */ @@ -8755,7 +8721,6 @@ static inline void atcmd_channel_help(int fd, const char *command, bool can_crea clif->message(fd, atcmd_output); clif->message(fd, msg_txt(1463));// - adds or removes <option name> with <option value> to <channel name> channel } - } /* [Ind/Hercules] */ ACMD(channel) { @@ -8763,12 +8728,12 @@ ACMD(channel) { char subcmd[HCHSYS_NAME_LENGTH], sub1[HCHSYS_NAME_LENGTH], sub2[HCHSYS_NAME_LENGTH], sub3[HCHSYS_NAME_LENGTH]; unsigned char k = 0; sub1[0] = sub2[0] = sub3[0] = '\0'; - + if (!message || !*message || sscanf(message, "%19s %19s %19s %19s", subcmd, sub1, sub2, sub3) < 1) { atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); return true; } - + if (strcmpi(subcmd,"create") == 0 && (hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN))) { // sub1 = channel name; sub2 = password; sub3 = unused if (sub1[0] != '#') { @@ -8787,19 +8752,18 @@ ACMD(channel) { clif->message(fd, atcmd_output); return false; } - + CREATE( channel, struct hChSysCh, 1 ); - clif->chsys_create(channel,sub1 + 1,sub2,0); - + channel->owner = sd->status.char_id; channel->type = hChSys_PRIVATE; - + if( !( channel->opt & hChSys_OPT_ANNOUNCE_JOIN ) ) { sprintf(atcmd_output, msg_txt(1403),sub1); // You're now in the '%s' channel clif->message(fd, atcmd_output); } - + clif->chsys_join(channel,sd); } else if (strcmpi(subcmd,"list") == 0) { // sub1 = list type; sub2 = unused; sub3 = unused @@ -8808,7 +8772,7 @@ ACMD(channel) { for (k = 0; k < hChSys.colors_count; k++) { unsigned short msg_len = 1; msg_len += sprintf(mout, "[ %s list colors ] : %s",command,hChSys.colors_name[k]); - + WFIFOHEAD(fd,msg_len + 12); WFIFOW(fd,0) = 0x2C1; WFIFOW(fd,2) = msg_len + 12; @@ -8845,19 +8809,19 @@ ACMD(channel) { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - + if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - + if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - + for (k = 0; k < hChSys.colors_count; k++) { if (strcmpi(sub2, hChSys.colors_name[k]) == 0) break; @@ -8905,7 +8869,7 @@ ACMD(channel) { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - + for (k = 0; k < sd->channel_count; k++) { if (strcmpi(sub1+1,sd->channels[k]->name) == 0) break; @@ -8915,7 +8879,7 @@ ACMD(channel) { clif->message(fd, atcmd_output); return false; } - + sd->gcbind = sd->channels[k]; sprintf(atcmd_output, msg_txt(1431),sub1); // Your global chat is now bound to the '%s' channel clif->message(fd, atcmd_output); @@ -8925,34 +8889,34 @@ ACMD(channel) { clif->message(fd, msg_txt(1432));// Your global chat is not bound to any channel return false; } - + sprintf(atcmd_output, msg_txt(1433),sd->gcbind->name); // Your global chat is no longer bound to the '#%s' channel clif->message(fd, atcmd_output); - + sd->gcbind = NULL; } else if (strcmpi(subcmd,"ban") == 0) { // sub1 = channel name; sub2 = unused; sub3 = unused struct map_session_data *pl_sd = NULL; struct hChSysBanEntry *entry = NULL; char sub4[NAME_LENGTH]; ///< player name - + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - + if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - + if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - + if (!message || !*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) { sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found clif->message(fd, atcmd_output); @@ -8964,59 +8928,53 @@ ACMD(channel) { clif->message(fd, atcmd_output); return false; } - + if (pc_has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN)) { clif->message(fd, msg_txt(1464)); // Ban failed, not possible to ban this user. return false; } - + if (channel->banned && idb_exists(channel->banned,pl_sd->status.account_id)) { sprintf(atcmd_output, msg_txt(1465), pl_sd->status.name);// Player '%s' is already banned from this channel clif->message(fd, atcmd_output); return false; } - + if (!channel->banned) channel->banned = idb_alloc(DB_OPT_BASE|DB_OPT_ALLOW_NULL_DATA|DB_OPT_RELEASE_DATA); - + CREATE(entry, struct hChSysBanEntry, 1); - safestrncpy(entry->name, pl_sd->status.name, NAME_LENGTH); - idb_put(channel->banned, pl_sd->status.account_id, entry); - + clif->chsys_left(channel,pl_sd); - + sprintf(atcmd_output, msg_txt(1437),pl_sd->status.name,sub1); // Player '%s' has now been banned from '%s' channel clif->message(fd, atcmd_output); } else if (strcmpi(subcmd,"unban") == 0) { // sub1 = channel name; sub2 = unused; sub3 = unused struct map_session_data *pl_sd = NULL; char sub4[NAME_LENGTH]; ///< player name - + if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - if (!channel->banned) { sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players clif->message(fd, atcmd_output); return false; } - if (!message || !*message || sscanf(message, "%19s %19s %23[^\n]", subcmd, sub1, sub4) < 3) { sprintf(atcmd_output, msg_txt(1434), sub4);// Player '%s' was not found clif->message(fd, atcmd_output); @@ -9028,20 +8986,18 @@ ACMD(channel) { clif->message(fd, atcmd_output); return false; } - if (!idb_exists(channel->banned,pl_sd->status.account_id)) { sprintf(atcmd_output, msg_txt(1440), pl_sd->status.name);// Player '%s' is not banned from this channel clif->message(fd, atcmd_output); return false; } - + idb_remove(channel->banned, pl_sd->status.account_id); - if (!db_size(channel->banned)) { db_destroy(channel->banned); channel->banned = NULL; } - + sprintf(atcmd_output, msg_txt(1441),pl_sd->status.name,sub1); // Player '%s' has now been unbanned from the '%s' channel clif->message(fd, atcmd_output); } else if (strcmpi(subcmd,"unbanall") == 0) { @@ -9050,28 +9006,24 @@ ACMD(channel) { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - if (!channel->banned) { sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players clif->message(fd, atcmd_output); return false; } - db_destroy(channel->banned); channel->banned = NULL; - + sprintf(atcmd_output, msg_txt(1442),sub1); // Removed all bans from '%s' channel clif->message(fd, atcmd_output); } else if (strcmpi(subcmd,"banlist") == 0) { @@ -9084,19 +9036,16 @@ ACMD(channel) { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - if (channel->owner != sd->status.char_id && !isA) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - if (!channel->banned) { sprintf(atcmd_output, msg_txt(1439), sub1);// Channel '%s' has no banned players clif->message(fd, atcmd_output); @@ -9104,22 +9053,19 @@ ACMD(channel) { } sprintf(atcmd_output, msg_txt(1443), channel->name);// -- '%s' ban list clif->message(fd, atcmd_output); - + iter = db_iterator(channel->banned); - for (data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key)) { struct hChSysBanEntry * entry = DB->data2ptr(data); - + if (!isA) sprintf(atcmd_output, msg_txt(1444), entry->name);// - %s %s else sprintf(atcmd_output, msg_txt(1445), entry->name, key.i);// - %s (%d) - + clif->message(fd, atcmd_output); } - dbi_destroy(iter); - } else if (strcmpi(subcmd,"setopt") == 0) { // sub1 = channel name; sub2 = option name; sub3 = value const char* opt_str[3] = { @@ -9127,34 +9073,28 @@ ACMD(channel) { "JoinAnnounce", "MessageDelay", }; - if (sub1[0] != '#') { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; } - if (!(channel = strdb_get(clif->channel_db, sub1 + 1))) { sprintf(atcmd_output, msg_txt(1407), sub1);// Channel '%s' is not available clif->message(fd, atcmd_output); return false; } - if (channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; } - if (sub2[0] == '\0') { clif->message(fd, msg_txt(1446));// You need to input a option return false; } - for (k = 1; k < 3; k++) { if (strcmpi(sub2,opt_str[k]) == 0) break; } - if (k == 3) { sprintf(atcmd_output, msg_txt(1447), sub2);// '%s' is not a known channel option clif->message(fd, atcmd_output); @@ -9165,7 +9105,6 @@ ACMD(channel) { } return false; } - if (sub3[0] == '\0') { if (k == hChSys_OPT_MSG_DELAY) { sprintf(atcmd_output, msg_txt(1466), opt_str[k]);// For '%s' you need the amount of seconds (from 0 to 10) @@ -9226,12 +9165,10 @@ ACMD(channel) { } } } - } } else { atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); } - return true; } /* debug only, delete after */ @@ -9243,7 +9180,7 @@ ACMD(fontcolor) { if( !message || !*message ) { for( k = 0; k < hChSys.colors_count; k++ ) { msg_len += sprintf(mout, "[ %s ] : %s",command,hChSys.colors_name[k]); - + WFIFOHEAD(fd,msg_len + 12); WFIFOW(fd,0) = 0x2C1; WFIFOW(fd,2) = msg_len + 12; @@ -9254,12 +9191,12 @@ ACMD(fontcolor) { } return false; } - + if( message[0] == '0' ) { sd->fontcolor = 0; return true; } - + for( k = 0; k < hChSys.colors_count; k++ ) { if( strcmpi(message,hChSys.colors_name[k]) == 0 ) break; @@ -9269,10 +9206,10 @@ ACMD(fontcolor) { clif->message(fd, atcmd_output); return false; } - + sd->fontcolor = k + 1; msg_len += sprintf(mout, "Color changed to '%s'",hChSys.colors_name[k]); - + WFIFOHEAD(fd,msg_len + 12); WFIFOW(fd,0) = 0x2C1; WFIFOW(fd,2) = msg_len + 12; @@ -9284,7 +9221,7 @@ ACMD(fontcolor) { } ACMD(searchstore){ int val = atoi(message); - + switch( val ) { case 0://EFFECTTYPE_NORMAL case 1://EFFECTTYPE_CASH @@ -9295,7 +9232,6 @@ ACMD(searchstore){ } searchstore->open(sd, 99, val); - return true; } ACMD(costume){ @@ -9318,7 +9254,7 @@ ACMD(costume){ #endif }; unsigned short k = 0, len = ARRAYLENGTH(names); - + if( !message || !*message ) { for( k = 0; k < len; k++ ) { if( sd->sc.data[name2id[k]] ) { @@ -9328,7 +9264,6 @@ ACMD(costume){ return true; } } - clif->message(sd->fd,msg_txt(1472)); for( k = 0; k < len; k++ ) { sprintf(atcmd_output,msg_txt(1471),names[k]);//-- %s @@ -9336,7 +9271,7 @@ ACMD(costume){ } return false; } - + for( k = 0; k < len; k++ ) { if( sd->sc.data[name2id[k]] ) { sprintf(atcmd_output,msg_txt(1470),names[k]);// You're already with a '%s' costume, type '@costume' to remove it. @@ -9344,7 +9279,7 @@ ACMD(costume){ return false; } } - + for( k = 0; k < len; k++ ) { if( strcmpi(message,names[k]) == 0 ) break; @@ -9354,9 +9289,9 @@ ACMD(costume){ clif->message(sd->fd,atcmd_output); return false; } - + sc_start(NULL,&sd->bl, name2id[k], 100, 0, -1); - + return true; } /* for debugging purposes (so users can easily provide us with debug info) */ @@ -9643,17 +9578,17 @@ void atcommand_basecommands(void) { ACMD_DEF(skdebug), }; int i; - + for( i = 0; i < ARRAYLENGTH(atcommand_base); i++ ) { if(!atcommand->add(atcommand_base[i].command,atcommand_base[i].func,false)) { // Should not happen if atcommand_base[] array is OK ShowDebug("atcommand_basecommands: duplicate ACMD_DEF for '%s'.\n", atcommand_base[i].command); continue; } } - + /* @commands from plugins */ HPM_map_atcommands(); - + return; } #undef ACMD_DEF @@ -9669,12 +9604,12 @@ bool atcommand_add(char *name,AtCommandFunc func, bool replace) { CREATE(cmd, AtCommandInfo, 1); strdb_put(atcommand->db, name, cmd); } - + safestrncpy(cmd->command, name, sizeof(cmd->command)); cmd->func = func; cmd->help = NULL; cmd->log = true; - + return true; } @@ -9868,7 +9803,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa if( battle_config.idletime_criteria & BCIDLE_ATCOMMAND ) sd->idletime = sockt->last_tick; - + //Clearing these to be used once more. memset(command, '\0', sizeof(command)); memset(params, '\0', sizeof(params)); @@ -9894,7 +9829,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa ) { // Check if self or character invoking; if self == character invoked, then self invoke. bool invokeFlag = ((*atcmd_msg == atcommand->at_symbol) ? 1 : 0); - + // Check if the command initiated is a character command if (*message == atcommand->char_symbol && (ssd = map->nick2sd(charname)) == NULL @@ -9904,10 +9839,10 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa clif->message(fd, output); return true; } - + if( binding->log ) /* log only if this command should be logged [Ind/Hercules] */ logs->atcommand(sd, atcmd_msg); - + npc->do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event); return true; } @@ -9945,7 +9880,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa } } } - + // Check if target is valid only if confirmed that player can use command. if (*message == atcommand->char_symbol && (ssd = map->nick2sd(charname)) == NULL @@ -10047,12 +9982,12 @@ void atcommand_config_read(const char* config_filename) { if (nolog != NULL) { int i = 0; int count = libconfig->setting_length(nolog); - + for (i = 0; i < count; ++i) { config_setting_t *command; const char *commandname = NULL; AtCommandInfo *commandinfo = NULL; - + command = libconfig->setting_get_elem(nolog, i); commandname = config_setting_name(command); if ( !( commandinfo = atcommand->exists(commandname) ) ) { @@ -10062,7 +9997,7 @@ void atcommand_config_read(const char* config_filename) { commandinfo->log = false; } } - + // Commands help // We only check if all commands exist help = libconfig->lookup(&atcommand_config, "help"); @@ -10091,7 +10026,7 @@ void atcommand_config_read(const char* config_filename) { } ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' command aliases in '"CL_WHITE"%s"CL_RESET"'.\n", num_aliases, config_filename); - + libconfig->destroy(&atcommand_config); return; } @@ -10124,7 +10059,7 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command config_setting_t *commands = commands_[i]; int result = 0; int idx = -1; - + if (group == NULL) { ShowError("atcommand_db_load_groups: group is NULL\n"); continue; @@ -10135,12 +10070,12 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command ShowError("atcommand_db_load_groups: index (%d) out of bounds [0,%"PRIuS"]\n", idx, sz - 1); continue; } - + if (pcg->has_permission(group, PC_PERM_USE_ALL_COMMANDS)) { atcmd->at_groups[idx] = atcmd->char_groups[idx] = 1; continue; } - + if (commands != NULL) { config_setting_t *cmd = NULL; @@ -10170,28 +10105,28 @@ void atcommand_db_load_groups(GroupSettings **groups, config_setting_t **command bool atcommand_can_use(struct map_session_data *sd, const char *command) { AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); - + if (info == NULL) return false; - + if ((*command == atcommand->at_symbol && info->at_groups[pcg->get_idx(sd->group)] != 0) || (*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] != 0) ) { return true; } - + return false; } bool atcommand_can_use2(struct map_session_data *sd, const char *command, AtCommandType type) { AtCommandInfo *info = atcommand->get_info_byname(atcommand->check_alias(command)); - + if (info == NULL) return false; - + if ((type == COMMAND_ATCOMMAND && info->at_groups[pcg->get_idx(sd->group)] != 0) || (type == COMMAND_CHARCOMMAND && info->char_groups[pcg->get_idx(sd->group)] != 0) ) { return true; } - + return false; } bool atcommand_hp_add(char *name, AtCommandFunc func) { @@ -10201,7 +10136,7 @@ bool atcommand_hp_add(char *name, AtCommandFunc func) { ShowDebug("atcommand_hp_add: Commands can't be added after server is ready, skipping '%s'...\n",name); return false; } - + return HPM_map_add_atcommand(name,func); } @@ -10246,7 +10181,7 @@ void do_init_atcommand(bool minimal) { atcommand->at_symbol = '@'; atcommand->char_symbol = '#'; atcommand->binding_count = 0; - + atcommand->doload(); } @@ -10256,15 +10191,15 @@ void do_final_atcommand(void) { void atcommand_defaults(void) { atcommand = &atcommand_s; - + atcommand->db = NULL; atcommand->alias_db = NULL; - + memset(atcommand->msg_table, 0, sizeof(atcommand->msg_table)); - + atcommand->init = do_init_atcommand; atcommand->final = do_final_atcommand; - + atcommand->exec = atcommand_exec; atcommand->create = atcommand_hp_add; atcommand->can_use = atcommand_can_use; diff --git a/src/map/battle.c b/src/map/battle.c index 73b563d4b..9ee4695f7 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -218,7 +218,7 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { } src = map->id2bl(dat->src_id); - + //Check to see if you haven't teleported. [Skotlex] if( src && (target->type != BL_PC || ((TBL_PC*)target)->invincible_timer == INVALID_TIMER) @@ -239,7 +239,7 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { status_fix_damage(target, target, dat->damage, dat->delay); map->freeblock_unlock(); } - + if( src && src->type == BL_PC && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { ((TBL_PC*)src)->state.hold_recalc = 0; status_calc_pc(((TBL_PC*)src),SCO_FORCE); @@ -292,7 +292,7 @@ int battle_delay_damage(int64 tick, int amotion, struct block_list *src, struct if( src->type == BL_PC ) { ((TBL_PC*)src)->delayed_damage++; } - + timer->add(tick+amotion, battle->delay_damage_sub, 0, (intptr_t)dat); return 0; @@ -437,13 +437,13 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u sd = BL_CAST(BL_PC, src); damage = status->get_weapon_atk(src, watk, flag); - + if( sd ){ if( type == EQI_HAND_R ) damage = battle->calc_sizefix(sd, damage, EQI_HAND_R, size, flag&8); else damage = battle->calc_sizefix(sd, damage, EQI_HAND_L, size, flag&8); - + if( flag&2 && sd->bonus.arrow_atk ) damage += sd->bonus.arrow_atk; @@ -479,7 +479,7 @@ int64 battle_calc_weapon_damage(struct block_list *src, struct block_list *bl, u // attacker side damage = battle->calc_cardfix(BF_WEAPON, src, bl, nk, s_ele, s_ele_, damage, 2|(type == EQI_HAND_L), flag2); - + // target side damage = battle->calc_cardfix(BF_WEAPON, src, bl, nk, s_ele, s_ele_, damage, 0, flag2); @@ -516,7 +516,7 @@ int64 battle_calc_base_damage(struct block_list *src, struct block_list *bl, uin damage = batk + 3 * battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &st->lhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2) / 4; else damage = (batk << 1) + battle->calc_weapon_damage(src, bl, skill_id, skill_lv, &st->rhw, nk, n_ele, s_ele, s_ele_, status_get_size(bl), type, flag, flag2); - + return damage; } int64 battle_calc_base_damage2(struct status_data *st, struct weapon_atk *wa, struct status_change *sc, unsigned short t_size, struct map_session_data *sd, int flag) { @@ -726,14 +726,14 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, nullpo_ret(src); nullpo_ret(target); - + sc = status->get_sc(src); sd = BL_CAST(BL_PC, src); tstatus = status->get_status_data(target); if ( !sd ) return damage; - + damage = battle->add_mastery(sd, target, damage, left); switch( skill_id ){ // specific skill masteries @@ -768,7 +768,7 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, damage += 40 * pc->checkskill(sd, RA_RESEARCHTRAP); break; } - + if( sc ){ // sc considered as masteries if(sc->data[SC_GN_CARTBOOST]) damage += 10 * sc->data[SC_GN_CARTBOOST]->val1; @@ -796,9 +796,11 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, else damage += sc->data[SC_GS_GATLINGFEVER]->val1; } - //if(sc->data[SC_SPECIALZONE]) - // damage += sc->data[SC_SPECIALZONE]->val2 >> 4; -#endif +#if 0 + if(sc->data[SC_SPECIALZONE]) + damage += sc->data[SC_SPECIALZONE]->val2 >> 4; +#endif // 0 +#endif // RENEWAL } // general skill masteries @@ -850,12 +852,12 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, *------------------------------------------*/ int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint16 skill_id, uint16 skill_lv, int64 damage, int nk, int n_ele, int s_ele, int s_ele_, bool left, int flag){ struct status_data *tstatus; - + nullpo_ret(src); nullpo_ret(target); tstatus = status->get_status_data(target); - + if( (nk&NK_NO_ELEFIX) || n_ele ) return damage; @@ -874,12 +876,12 @@ int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint damage += battle->attr_fix(src,target,50*skill_lv,ELE_NEUTRAL,tstatus->def_ele, tstatus->ele_lv); } } - + #ifndef RENEWAL { struct status_data *sstatus; struct status_change *sc; - + sstatus = status->get_status_data(src); sc = status->get_sc(src); @@ -898,8 +900,8 @@ int64 battle_calc_elefix(struct block_list *src, struct block_list *target, uint /*========================================== * Calculates card bonuses damage adjustments. * cflag(cardfix flag): - * &1 - calc for left hand. - * &2 - atker side cardfix(BF_WEAPON) otherwise target side(BF_WEAPON). + * &1 - calc for left hand. + * &2 - atker side cardfix(BF_WEAPON) otherwise target side(BF_WEAPON). *------------------------------------------*/ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_list *target, int nk, int s_ele, int s_ele_, int64 damage, int cflag, int wflag){ struct map_session_data *sd, *tsd; @@ -909,7 +911,7 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_ if( !damage ) return 0; - + nullpo_ret(src); nullpo_ret(target); @@ -920,7 +922,7 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_ sstatus = status->get_status_data(src); tstatus = status->get_status_data(target); s_race2 = status->get_race2(src); - + switch(attack_type){ case BF_MAGIC: if ( sd && !(nk&NK_NO_CARDFIX_ATK) ) { @@ -1133,7 +1135,7 @@ int64 battle_calc_cardfix(int attack_type, struct block_list *src, struct block_ } } cardfix = cardfix * (100-tsd->subsize[sstatus->size]) / 100; - cardfix = cardfix * (100-tsd->subrace2[s_race2]) / 100; + cardfix = cardfix * (100-tsd->subrace2[s_race2]) / 100; cardfix = cardfix * (100-tsd->subrace[sstatus->race]) / 100; cardfix = cardfix * (100-tsd->subrace[is_boss(src)?RC_BOSS:RC_NONBOSS]) / 100; if( sstatus->race != RC_DEMIHUMAN ) @@ -1211,13 +1213,13 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ struct map_session_data *sd, *tsd; struct status_change *sc, *tsc; int i; - + if( !damage ) return 0; - + nullpo_ret(src); nullpo_ret(target); - + sd = BL_CAST(BL_PC, src); tsd = BL_CAST(BL_PC, target); sstatus = status->get_status_data(src); @@ -1228,10 +1230,10 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ switch(attack_type){ case BF_WEAPON: { - /** Take note in RE - * def1 = equip def - * def2 = status def - **/ + /* Take note in RE + * def1 = equip def + * def2 = status def + */ defType def1 = status->get_def(target); //Don't use tstatus->def1 due to skill timer reductions. short def2 = tstatus->def2, vit_def; #ifdef RENEWAL @@ -1257,7 +1259,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ def1 -= def1 * i / 100; def2 -= def2 * i / 100; } - + if( battle_config.vit_penalty_type && battle_config.vit_penalty_target&target->type ) { unsigned char target_count; //256 max targets should be a sane max target_count = unit->counttargeted(target); @@ -1276,8 +1278,8 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ if(def2 < 1) def2 = 1; } //Vitality reduction from rodatazone: http://rodatazone.simgaming.net/mechanics/substats.php#def - if (tsd) //Sd vit-eq - { + if (tsd) { + //Sd vit-eq #ifndef RENEWAL //[VIT*0.5] + rnd([VIT*0.3], max([VIT*0.3],[VIT^2/150]-1)) vit_def = def2*(def2-15)/150; @@ -1301,7 +1303,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ vit_def = def2; #endif } - + if (battle_config.weapon_defense_type) { vit_def += def1*battle_config.weapon_defense_type; def1 = 0; @@ -1325,7 +1327,6 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ else damage = (int)((100.0f - def1 / (def1 + 400.0f) * 90.0f) / 100.0f * damage - vit_def); } - #else if( def1 > 100 ) def1 = 100; if( !(flag&1) ){ @@ -1341,7 +1342,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ break; case BF_MAGIC: - { + { defType mdef = tstatus->mdef; short mdef2= tstatus->mdef2; #ifdef RENEWAL @@ -1379,7 +1380,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_ else damage = damage * (100-mdef)/100 - mdef2; #endif - } + } break; } return damage; @@ -1515,16 +1516,16 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += 25; break; case WZ_VERMILION: - { - int interval = 0, per = interval, ratio = per; - while( (per++) < skill_lv ){ - ratio += interval; - if(per%3==0) interval += 20; - } - if( skill_lv > 9 ) - ratio -= 10; - skillratio += ratio; + { + int interval = 0, per = interval, ratio = per; + while( (per++) < skill_lv ){ + ratio += interval; + if(per%3==0) interval += 20; } + if( skill_lv > 9 ) + ratio -= 10; + skillratio += ratio; + } break; case NJ_HUUJIN: skillratio += 50; @@ -1913,7 +1914,8 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block break; #ifndef RENEWAL case MO_EXTREMITYFIST: - { //Overflow check. [Skotlex] + { + //Overflow check. [Skotlex] unsigned int ratio = skillratio + 100*(8 + st->sp/10); //You'd need something like 6K SP to reach this max, so should be fine for most purposes. if (ratio > 60000) ratio = 60000; //We leave some room here in case skillratio gets further increased. @@ -2082,10 +2084,10 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block case MO_BALKYOUNG: skillratio += 200; break; - case HFLI_MOON: //[orn] + case HFLI_MOON: //[orn] skillratio += 10 + 110 * skill_lv; break; - case HFLI_SBR44: //[orn] + case HFLI_SBR44: //[orn] skillratio += 100 * (skill_lv-1); break; case NPC_VAMPIRE_GIFT: @@ -2238,7 +2240,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block RE_LVL_DMOD(100); if( st->rhw.ele == ELE_WIND ) skillratio = skillratio * 125 / 100; - if ( distance_bl(src, target) > 2 ) // Will deal 75% damage outside of 5x5 area. + if ( distance_bl(src, target) > 2 ) // Will deal 75% damage outside of 5x5 area. skillratio = skillratio * 75 / 100; break; case SC_FATALMENACE: @@ -2354,7 +2356,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block case SR_FALLENEMPIRE:// ATK [(Skill Level x 150 + 100) x Caster Base Level / 150] % skillratio += 150 *skill_lv; RE_LVL_DMOD(150); - break; + break; case SR_TIGERCANNON:// ATK [((Caster consumed HP + SP) / 4) x Caster Base Level / 100] % { int hp = status_get_max_hp(src) * (10 + 2 * skill_lv) / 100, @@ -2723,7 +2725,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if (sce_d) { // If the target is too far away from the devotion caster, autoguard has no effect // Autoguard will be disabled later on - if ((d_bl = map->id2bl(sce_d->val1)) && check_distance_bl(bl, d_bl, sce_d->val3) + if ((d_bl = map->id2bl(sce_d->val1)) && check_distance_bl(bl, d_bl, sce_d->val3) && ((d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == bl->id) || (d_bl->type == BL_PC && ((TBL_PC*)d_bl)->devotion[sce_d->val2] == bl->id)) ) { @@ -2785,8 +2787,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if(sc->data[SC_NJ_TATAMIGAESHI] && (flag&(BF_MAGIC|BF_LONG)) == BF_LONG) return 0; - if((sce=sc->data[SC_KAUPE]) && rnd()%100 < sce->val2) - { //Kaupe blocks damage (skill or otherwise) from players, mobs, homuns, mercenaries. + if ((sce=sc->data[SC_KAUPE]) && rnd()%100 < sce->val2) { + //Kaupe blocks damage (skill or otherwise) from players, mobs, homuns, mercenaries. clif->specialeffect(bl, 462, AREA); //Shouldn't end until Breaker's non-weapon part connects. if (skill_id != ASC_BREAKER || !(flag&BF_WEAPON)) @@ -3082,10 +3084,10 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam status->change_spread(src, bl); if (sc->data[SC_SHIELDSPELL_REF] && sc->data[SC_SHIELDSPELL_REF]->val1 == 1 && damage > 0) skill->break_equip(bl,EQP_ARMOR,10000,BCT_ENEMY ); - if (sc->data[SC_STYLE_CHANGE] && rnd()%2) { - TBL_HOM *hd = BL_CAST(BL_HOM,bl); - if (hd) homun->addspiritball(hd, 10); - } + if (sc->data[SC_STYLE_CHANGE] && rnd()%2) { + TBL_HOM *hd = BL_CAST(BL_HOM,bl); + if (hd) homun->addspiritball(hd, 10); + } } /* no data claims these settings affect anything other than players */ if( damage && sd && bl->type == BL_PC ) { @@ -3162,7 +3164,7 @@ int64 battle_calc_bg_damage(struct block_list *src, struct block_list *bl, int64 if( bl->type == BL_MOB ) { struct mob_data* md = BL_CAST(BL_MOB, bl); - + if( flag&BF_SKILL && (md->class_ == MOBID_BLUE_CRYST || md->class_ == MOBID_PINK_CRYST) ) return 0; // Crystal cannot receive skill damage on battlegrounds } @@ -3220,7 +3222,6 @@ int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 */ break; } - return damage; } @@ -3286,11 +3287,10 @@ int battle_adjust_skill_damage(int m, unsigned short skill_id) { if( map->list[m].skill_count ) { int i; ARR_FIND(0, map->list[m].skill_count, i, map->list[m].skills[i]->skill_id == skill_id ); - + if( i < map->list[m].skill_count ) { return map->list[m].skills[i]->modifier; } - } return 0; @@ -3314,9 +3314,9 @@ int battle_blewcount_bonus(struct map_session_data *sd, uint16 skill_id) { struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int mflag) { int i, nk; short s_ele = 0; - unsigned int skillratio = 100; //Skill dmg modifiers. + unsigned int skillratio = 100; //Skill dmg modifiers. - TBL_PC *sd; + TBL_PC *sd; struct status_change *sc; struct Damage ad; struct status_data *sstatus = status->get_status_data(src); @@ -3324,7 +3324,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list struct { unsigned imdef : 1; unsigned infdef : 1; - } flag; + } flag; memset(&ad,0,sizeof(ad)); memset(&flag,0,sizeof(flag)); @@ -3424,8 +3424,8 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list //Adds an absolute value to damage. 100 = +100 damage #define MATK_ADD( a ) ( ad.damage+= (a) ) - switch (skill_id) - { //Calc base damage according to skill + switch (skill_id) { + //Calc base damage according to skill case AL_HEAL: case PR_BENEDICTIO: case PR_SANCTUARY: @@ -3444,7 +3444,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list case PR_TURNUNDEAD: //Undead check is on skill_castend_damageid code. i = 20*skill_lv + sstatus->luk + sstatus->int_ + status->get_lv(src) - + 200 - 200*tstatus->hp/tstatus->max_hp; // there is no changed in success chance in renewal. [malufett] + + 200 - 200*tstatus->hp/tstatus->max_hp; // there is no changed in success chance in renewal. [malufett] if(i > 700) i = 700; if(rnd()%1000 < i && !(tstatus->mode&MD_BOSS)) ad.damage = tstatus->hp; @@ -3468,7 +3468,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list break; default: { MATK_ADD( status->get_matk(src, 2) ); - + if (nk&NK_SPLASHSPLIT) { // Divide MATK in case of multiple targets skill if(mflag>0) ad.damage/= mflag; @@ -3565,11 +3565,11 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list )) flag.imdef = 1; } - + ad.damage = battle->calc_defense(BF_MAGIC, src, target, skill_id, skill_lv, ad.damage, (flag.imdef?1:0), 0); - - if (skill_id == NPC_EARTHQUAKE) - { //Adds atk2 to the damage, should be influenced by number of hits and skill-ratio, but not mdef reductions. [Skotlex] + + if (skill_id == NPC_EARTHQUAKE) { + //Adds atk2 to the damage, should be influenced by number of hits and skill-ratio, but not mdef reductions. [Skotlex] //Also divide the extra bonuses from atk2 based on the number in range [Kevin] if(mflag>0) ad.damage+= (sstatus->rhw.atk2*skillratio/100)/mflag; @@ -3613,7 +3613,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list } } #ifndef RENEWAL - ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag); + ad.damage = battle->calc_cardfix(BF_MAGIC, src, target, nk, s_ele, 0, ad.damage, 0, ad.flag); #endif } @@ -3660,7 +3660,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * #ifdef RENEWAL struct status_change *sc = status->get_sc(src); #endif - + memset(&md,0,sizeof(md)); nullpo_retr(md, src); @@ -3781,7 +3781,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * }*/ }else{ float vitfactor = 0.0f, ftemp; - + if( (vitfactor=(status_get_vit(target)-120.0f)) > 0) vitfactor = (vitfactor * (matk + atk) / 10) / status_get_vit(target); ftemp = max(0, vitfactor) + (targetVit * (matk + atk)) / 10; @@ -3807,8 +3807,8 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * if( md.damage < 0 ) md.damage = 0; if( md.damage > INT_MAX>>1 ) - //Overflow prevention, will anyone whine if I cap it to a few billion? - //Not capped to INT_MAX to give some room for further damage increase. + //Overflow prevention, will anyone whine if I cap it to a few billion? + //Not capped to INT_MAX to give some room for further damage increase. md.damage = INT_MAX>>1; break; @@ -3830,7 +3830,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * case GS_FLING: md.damage = sd?sd->status.job_level:status->get_lv(src); break; - case HVAN_EXPLOSION: //[orn] + case HVAN_EXPLOSION: //[orn] md.damage = sstatus->max_hp * (50 + 50 * skill_lv) / 100; break ; case ASC_BREAKER: @@ -3843,7 +3843,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * int64 matk = battle->calc_magic_attack(src, target, skill_id, skill_lv, mflag).damage; short totaldef = status->get_total_def(target) + status->get_total_mdef(target); int64 atk = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, false, s_ele, ELE_NEUTRAL, EQI_HAND_R, (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0), md.flag); - + if( sc && sc->data[SC_EDP] ) ratio >>= 1; md.damage = (matk + atk) * ratio / 100; @@ -3874,7 +3874,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * **/ case RA_CLUSTERBOMB: case RA_FIRINGTRAP: - case RA_ICEBOUNDTRAP: + case RA_ICEBOUNDTRAP: md.damage = skill_lv * sstatus->dex + sstatus->int_ * 5 ; RE_LVL_TMDMOD(); if(sd) @@ -3974,7 +3974,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * #endif if( skill_id == KO_MUCHANAGE ) hitrate = (int)((10 - ((float)1 / (status_get_dex(src) + status_get_luk(src))) * 500) * ((float)skill_lv / 2 + 5)); - + hitrate = cap_value(hitrate, battle_config.min_hitrate, battle_config.max_hitrate); if(rnd()%100 < hitrate) @@ -4004,7 +4004,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * } } #endif - md.damage = battle->calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag); + md.damage = battle->calc_cardfix(BF_MISC, src, target, nk, s_ele, 0, md.damage, 0, md.flag); if(skill_id){ uint16 rskill;/* redirect skill id */ switch(skill_id){ @@ -4048,7 +4048,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * switch( skill_id ) { case RA_FIRINGTRAP: - case RA_ICEBOUNDTRAP: + case RA_ICEBOUNDTRAP: if( md.damage == 1 ) break; case RA_CLUSTERBOMB: { @@ -4074,7 +4074,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list * *------------------------------------------*/ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list *target,uint16 skill_id,uint16 skill_lv,int wflag) { - unsigned int skillratio = 100; //Skill dmg modifiers. + unsigned int skillratio = 100; //Skill dmg modifiers. short temp=0; short s_ele, s_ele_; int i, nk; @@ -4087,21 +4087,21 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list struct status_data *sstatus = status->get_status_data(src); struct status_data *tstatus = status->get_status_data(target); struct { - unsigned hit : 1; //the attack Hit? (not a miss) - unsigned cri : 1; //Critical hit - unsigned idef : 1; //Ignore defense - unsigned idef2 : 1; //Ignore defense (left weapon) - unsigned pdef : 2; //Pierces defense (Investigate/Ice Pick) - unsigned pdef2 : 2; //1: Use def+def2/100, 2: Use def+def2/50 - unsigned infdef : 1; //Infinite defense (plants) - unsigned arrow : 1; //Attack is arrow-based - unsigned rh : 1; //Attack considers right hand (wd.damage) - unsigned lh : 1; //Attack considers left hand (wd.damage2) - unsigned weapon : 1; //It's a weapon attack (consider VVS, and all that) + unsigned hit : 1; ///< the attack Hit? (not a miss) + unsigned cri : 1; ///< Critical hit + unsigned idef : 1; ///< Ignore defense + unsigned idef2 : 1; ///< Ignore defense (left weapon) + unsigned pdef : 2; ///< Pierces defense (Investigate/Ice Pick) + unsigned pdef2 : 2; ///< 1: Use def+def2/100, 2: Use def+def2/50 + unsigned infdef : 1; ///< Infinite defense (plants) + unsigned arrow : 1; ///< Attack is arrow-based + unsigned rh : 1; ///< Attack considers right hand (wd.damage) + unsigned lh : 1; ///< Attack considers left hand (wd.damage2) + unsigned weapon : 1; ///< It's a weapon attack (consider VVS, and all that) #ifdef RENEWAL - unsigned tdef : 1; //Total defense reduction + unsigned tdef : 1; ///< Total defense reduction #endif - } flag; + } flag; memset(&wd,0,sizeof(wd)); memset(&flag,0,sizeof(flag)); @@ -4130,7 +4130,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list wd.blewcount=skill->get_blewcount(skill_id,skill_lv); wd.flag = BF_WEAPON; //Initial Flag wd.flag |= (skill_id||wflag)?BF_SKILL:BF_NORMAL; // Baphomet card's splash damage is counted as a skill. [Inkfish] - wd.dmg_lv=ATK_DEF; //This assumption simplifies the assignation later + wd.dmg_lv=ATK_DEF; //This assumption simplifies the assignation later nk = skill->get_nk(skill_id); if( !skill_id && wflag ) //If flag, this is splash damage from Baphomet Card and it always hits. nk |= NK_NO_CARDFIX_ATK|NK_IGNORE_FLEE; @@ -4218,11 +4218,11 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if( sc && sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 > 3 ) wd.div_ = sc->data[SC_BANDING]->val2; break; - + case MO_INVESTIGATE: flag.pdef = flag.pdef2 = 2; break; - + case RA_AIMEDBOLT: if( tsc && (tsc->data[SC_WUGBITE] || tsc->data[SC_ANKLESNARE] || tsc->data[SC_ELECTRICSHOCKER]) ) wd.div_ = tstatus->size + 2 + ( (rnd()%100 < 50-tstatus->size*10) ? 1 : 0 ); @@ -4235,8 +4235,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } } else //Range for normal attacks. wd.flag |= flag.arrow?BF_LONG:BF_SHORT; - if ( (!skill_id || skill_id == PA_SACRIFICE) && tstatus->flee2 && rnd()%1000 < tstatus->flee2 ) - { //Check for Lucky Dodge + if ((!skill_id || skill_id == PA_SACRIFICE) && tstatus->flee2 && rnd()%1000 < tstatus->flee2) { + //Check for Lucky Dodge wd.type=0x0b; wd.dmg_lv=ATK_LUCKY; if (wd.div_ < 0) wd.div_*=-1; @@ -4271,7 +4271,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list break; case LG_HESPERUSLIT: if ( sc && sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 == 5 ) - s_ele = ELE_HOLY; // Banding with 5 RGs: change atk element to Holy. + s_ele = ELE_HOLY; // Banding with 5 RGs: change atk element to Holy. break; } @@ -4283,8 +4283,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list n_ele = false; } - if(!skill_id) - { //Skills ALWAYS use ONLY your right-hand weapon (tested on Aegis 10.2) + if(!skill_id) { + //Skills ALWAYS use ONLY your right-hand weapon (tested on Aegis 10.2) if (sd && sd->weapontype1 == 0 && sd->weapontype2 > 0) { flag.rh=0; @@ -4294,11 +4294,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list flag.lh=1; } - if( sd && !skill_id ) { //Check for double attack. - if( ( ( skill_lv = pc->checkskill(sd,TF_DOUBLE) ) > 0 && sd->weapontype1 == W_DAGGER ) - || ( sd->bonus.double_rate > 0 && sd->weapontype1 != W_FIST ) //Will fail bare-handed - || ( sc && sc->data[SC_KAGEMUSYA] && sd->weapontype1 != W_FIST )) // Need confirmation - { //Success chance is not added, the higher one is used [Skotlex] + if (sd && !skill_id) { + //Check for double attack. + if (( (skill_lv=pc->checkskill(sd,TF_DOUBLE)) > 0 && sd->weapontype1 == W_DAGGER ) + || ( sd->bonus.double_rate > 0 && sd->weapontype1 != W_FIST ) //Will fail bare-handed + || ( sc && sc->data[SC_KAGEMUSYA] && sd->weapontype1 != W_FIST ) // Need confirmation + ) { + //Success chance is not added, the higher one is used [Skotlex] if( rnd()%100 < ( 5*skill_lv > sd->bonus.double_rate ? 5*skill_lv : sc && sc->data[SC_KAGEMUSYA]?sc->data[SC_KAGEMUSYA]->val1*3:sd->bonus.double_rate ) ) { wd.div_ = skill->get_num(TF_DOUBLE,skill_lv?skill_lv:1); @@ -4400,7 +4402,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list flag.idef = flag.idef2 = #endif flag.hit = 1; - } else { //Check for Perfect Hit + } else { + //Check for Perfect Hit if(sd && sd->bonus.perfect_hit > 0 && rnd()%100 < sd->bonus.perfect_hit) flag.hit = 1; if (sc && sc->data[SC_FUSION]) { @@ -4423,14 +4426,13 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list flag.hit = 1; } - if (!flag.hit) - { //Hit/Flee calculation - short - flee = tstatus->flee, + if (!flag.hit) { + //Hit/Flee calculation + short flee = tstatus->flee; #ifdef RENEWAL - hitrate = 0; //Default hitrate + short hitrate = 0; //Default hitrate #else - hitrate = 80; //Default hitrate + short hitrate = 80; //Default hitrate #endif if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) { @@ -4457,9 +4459,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if( sd ) //in Renewal hit bonus from Vultures Eye is not anymore shown in status window hitrate += pc->checkskill(sd,AC_VULTURE); #endif - if(skill_id) - switch(skill_id) - { //Hit skill modifiers + switch(skill_id) { + //Hit skill modifiers //It is proven that bonus is applied on final hitrate, not hit. case SM_BASH: case MS_BASH: @@ -4530,10 +4531,10 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } else flag.hit = 1; - } //End hit/miss calculation + } //End hit/miss calculation - if (flag.hit && !flag.infdef) //No need to do the math for plants - { //Hitting attack + if (flag.hit && !flag.infdef) { //No need to do the math for plants + //Hitting attack //Assuming that 99% of the cases we will not need to check for the flag.rh... we don't. //ATK_RATE scales the damage. 100 = no change. 50 is halved, 200 is doubled, etc @@ -4551,8 +4552,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list #define GET_NORMAL_ATTACK( f ) ( wd.damage = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_R, (f), wd.flag) ) #define GET_NORMAL_ATTACK2( f ) ( wd.damage2 = battle->calc_base_damage(src, target, skill_id, skill_lv, nk, n_ele, s_ele, s_ele_, EQI_HAND_L, (f), wd.flag) ) #endif - switch (skill_id) - { //Calc base damage according to skill + switch (skill_id) { + //Calc base damage according to skill case PA_SACRIFICE: wd.damage = sstatus->max_hp* 9/100; wd.damage2 = 0; @@ -4584,7 +4585,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0) ); wd.damage += battle->calc_masteryfix(src, target, skill_id, skill_lv, 4 * skill_lv + (sd ? sd->bonus.arrow_atk : 0), wd.div_, 0, flag.weapon) - status->get_total_def(target); break; - case MO_EXTREMITYFIST: // [malufett] + case MO_EXTREMITYFIST: // [malufett] { short totaldef = status->get_total_def(target); GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|8 ); @@ -4636,7 +4637,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } else ATK_ADD(sstatus->rhw.atk2); //Else use Atk2 break; - case HFLI_SBR44: //[orn] + case HFLI_SBR44: //[orn] if(src->type == BL_HOM) { wd.damage = ((TBL_HOM*)src)->homunculus.intimacy ; break; @@ -4702,7 +4703,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list #endif } break; - } //End default case + } //End default case } //End switch(skill_id) if( sc && skill_id != PA_SACRIFICE && sc->data[SC_UNLIMIT] && (wd.flag&(BF_LONG|BF_MAGIC)) == BF_LONG) { @@ -4745,12 +4746,12 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list GET_NORMAL_ATTACK( (sc && sc->data[SC_MAXIMIZEPOWER]?1:0)|(sc && sc->data[SC_WEAPONPERFECT]?8:0) ); wd.damage = wd.damage * 70 / 100; //n_ele = true; // FIXME: This is has no effect if it's after GET_NORMAL_ATTACK (was this intended, or was it supposed to be put above?) - + if (sd && index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_WEAPON) ATK_ADD(sd->inventory_data[index]->weight * 7 / 100); - + switch (tstatus->size) { case SZ_SMALL: //Small: 115% ATK_RATE(115); @@ -4862,7 +4863,6 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if( sc->data[SC_TRUESIGHT] ) ATK_ADDRATE(2*sc->data[SC_TRUESIGHT]->val1); #endif - #ifndef RENEWAL_EDP if( sc->data[SC_EDP] ){ switch(skill_id){ @@ -4967,8 +4967,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } } - if (skill_id != CR_GRANDCROSS && skill_id != NPC_GRANDDARKNESS) - { //Ignore Defense? + if (skill_id != CR_GRANDCROSS && skill_id != NPC_GRANDDARKNESS) { + //Ignore Defense? if (!flag.idef && ( sd->right_weapon.ignore_def_ele & (1<<tstatus->def_ele) || sd->right_weapon.ignore_def_race & (1<<tstatus->race) || @@ -5010,8 +5010,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list damage_div_fix(wd.damage, wd.div_); #endif //Post skill/vit reduction damage increases - if( sc ) - { //SC skill damages + if (sc) { + //SC skill damages if(sc->data[SC_AURABLADE] #ifndef RENEWAL && skill_id != LK_SPIRALPIERCE && skill_id != ML_SPIRALPIERCE @@ -5023,7 +5023,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list #endif ATK_ADD(20*lv); } - + if( !skill_id ) { if( sc->data[SC_ENCHANTBLADE] ) { //[( ( Skill Lv x 20 ) + 100 ) x ( casterBaseLevel / 150 )] + casterInt @@ -5035,7 +5035,6 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if( sc->data[SC_GIANTGROWTH] && rnd()%100 < 15 ) ATK_ADDRATE(200); // Triple Damage } - } #ifndef RENEWAL //Refine bonus @@ -5065,7 +5064,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list ATK_ADDRATE(40); #endif } //Here ends flag.hit section, the rest of the function applies to both hitting and missing attacks - else if(wd.div_ < 0) //Since the attack missed... + else if(wd.div_ < 0) //Since the attack missed... wd.div_ *= -1; #ifndef RENEWAL if(sd && (temp=pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0) @@ -5113,9 +5112,9 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } //Card Fix, sd side - wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 2, wd.flag); - if( flag.lh ) - wd.damage2 = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 3, wd.flag); + wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, 2, wd.flag); + if( flag.lh ) + wd.damage2 = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage2, 3, wd.flag); if( skill_id == CR_SHIELDBOOMERANG || skill_id == PA_SHIELDCHAIN ) { //Refine bonus applies after cards and elements. @@ -5125,8 +5124,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } } #endif - //Card Fix, tsd side - if(tsd){ //if player on player then it was already measured above + //Card Fix, tsd side + if(tsd){ //if player on player then it was already measured above wd.damage = battle->calc_cardfix(BF_WEAPON, src, target, nk, s_ele, s_ele_, wd.damage, (flag.lh?1:0), wd.flag); } if( flag.infdef ) { //Plants receive 1 damage when hit @@ -5152,12 +5151,14 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } if (sd) { - if (!flag.rh && flag.lh) { //Move lh damage to the rh + if (!flag.rh && flag.lh) { + //Move lh damage to the rh wd.damage = wd.damage2; wd.damage2 = 0; flag.rh=1; flag.lh=0; - } else if(flag.rh && flag.lh) { //Dual-wield + } else if(flag.rh && flag.lh) { + //Dual-wield if (wd.damage) { temp = pc->checkskill(sd,AS_RIGHT) * 10; if( (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO ) @@ -5237,7 +5238,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if( wd.damage + wd.damage2 ) { //There is a total damage value int64 damage = wd.damage + wd.damage2; - + if(!wd.damage2) { wd.damage = battle->calc_damage(src,target,&wd,wd.damage,skill_id,skill_lv); if( map_flag_gvg2(target->m) ) @@ -5284,9 +5285,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } else battle->reflect_damage(target, src, &wd, skill_id); - } - } //Reject Sword bugreport:4493 by Daegaladh if(wd.damage && tsc && tsc->data[SC_SWORDREJECT] && @@ -5304,7 +5303,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list status_change_end(target, SC_SWORDREJECT, INVALID_TIMER); } #ifndef RENEWAL - if(skill_id == ASC_BREAKER) { //Breaker's int-based damage (a misc attack?) + if(skill_id == ASC_BREAKER) { + //Breaker's int-based damage (a misc attack?) struct Damage md = battle->calc_misc_attack(src, target, skill_id, skill_lv, wflag); wd.damage += md.damage; } @@ -5329,7 +5329,7 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl memset(&d,0,sizeof(d)); break; } - + #ifdef HMAP_ZONE_DAMAGE_CAP_TYPE if( target && skill_id ) { int i; @@ -5350,7 +5350,7 @@ struct Damage battle_calc_attack(int attack_type,struct block_list *bl,struct bl } } #endif - + if( d.damage + d.damage2 < 1 ) { //Miss/Absorbed //Weapon attacks should go through to cause additional effects. if (d.dmg_lv == ATK_DEF /*&& attack_type&(BF_MAGIC|BF_MISC)*/) // Isn't it that additional effects don't apply if miss? @@ -5396,8 +5396,6 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st sc = NULL; if( sc ) { - - if (wd->flag & BF_SHORT && !(skill->get_inf(skill_id) & (INF_GROUND_SKILL | INF_SELF_SKILL))) { if( sc->data[SC_CRESCENTELBOW] && !is_boss(src) && rnd()%100 < sc->data[SC_CRESCENTELBOW]->val2 ){ //ATK [{(Target HP / 100) x Skill Level} x Caster Base Level / 125] % + [Received damage x {1 + (Skill Level x 0.2)}] @@ -5468,7 +5466,7 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st if (sce_d && sce_d->val1) d_bl = map->id2bl(sce_d->val1); - + if( sc->data[SC_REFLECTSHIELD] && skill_id != WS_CARTTERMINATION && skill_id != GS_DESPERADO && !(d_bl && !(wd->flag&BF_SKILL)) // It should not be a basic attack if the target is under devotion && !(d_bl && sce_d && !check_distance_bl(target, d_bl, sce_d->val3)) // It should not be out of range if the target is under devotion @@ -6096,7 +6094,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if (flag&BCT_ENEMY && ( map->getcell(m,src->x,src->y,CELL_CHKBASILICA) || map->getcell(m,target->x,target->y,CELL_CHKBASILICA) ) ) { return -1; } - + //t_bl/s_bl hold the 'master' of the attack, while src/target are the actual //objects involved. if( (t_bl = battle->get_master(target)) == NULL ) @@ -6135,7 +6133,8 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if(((((TBL_MOB*)target)->special_state.ai == 2 || //Marine Spheres (((TBL_MOB*)target)->special_state.ai == 3 && battle_config.summon_flora&1)) && //Floras s_bl->type == BL_PC && src->type != BL_MOB) || (((TBL_MOB*)target)->special_state.ai == 4 && t_bl->id != s_bl->id)) //Zanzoe - { //Targetable by players + { + //Targetable by players state |= BCT_ENEMY; strip_enemy = 0; } @@ -6192,8 +6191,10 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f su->group->skill_id == GN_WALLOFTHORN) { state |= BCT_ENEMY; strip_enemy = 0; - } else //Excepting traps and icewall, you should not be able to target skills. + } else { + //Excepting traps and icewall, you should not be able to target skills. return 0; + } } break; //Valid targets with no special checks here. @@ -6204,7 +6205,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f //All else not specified is an invalid target. default: return 0; - } //end switch actual target + } //end switch actual target switch( t_bl->type ) { //Checks on target master case BL_PC: @@ -6350,7 +6351,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if( flag&(BCT_PARTY|BCT_ENEMY) ) { int s_party = status->get_party_id(s_bl); int s_guild = status->get_guild_id(s_bl); - + if( s_party && s_party == status->get_party_id(t_bl) && !(map->list[m].flag.pvp && map->list[m].flag.pvp_noparty) && !(map_flag_gvg(m) && map->list[m].flag.gvg_noparty && !( s_guild && s_guild == status->get_guild_id(t_bl) )) @@ -6399,7 +6400,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if(s_guild && t_guild && (s_guild == t_guild || (!(flag&BCT_SAMEGUILD) && guild->isallied(s_guild, t_guild)))) state |= BCT_GUILD; } - } //end non pvp/gvg chk rivality + } //end non pvp/gvg chk rivality if( !state ) //If not an enemy, nor a guild, nor party, nor yourself, it's neutral. state = BCT_NEUTRAL; @@ -6513,7 +6514,7 @@ static const struct battle_data { { "monster_active_enable", &battle_config.monster_active_enable, 1, 0, 1, }, { "monster_damage_delay_rate", &battle_config.monster_damage_delay_rate, 100, 0, INT_MAX, }, { "monster_loot_type", &battle_config.monster_loot_type, 0, 0, 1, }, -// { "mob_skill_use", &battle_config.mob_skill_use, 1, 0, 1, }, //Deprecated + //{ "mob_skill_use", &battle_config.mob_skill_use, 1, 0, 1, }, //Deprecated { "mob_skill_rate", &battle_config.mob_skill_rate, 100, 0, INT_MAX, }, { "mob_skill_delay", &battle_config.mob_skill_delay, 100, 0, INT_MAX, }, { "mob_count_rate", &battle_config.mob_count_rate, 100, 0, INT_MAX, }, @@ -6783,7 +6784,7 @@ static const struct battle_data { { "invincible.nodamage", &battle_config.invincible_nodamage, 0, 0, 1, }, { "mob_slave_keep_target", &battle_config.mob_slave_keep_target, 0, 0, 1, }, { "autospell_check_range", &battle_config.autospell_check_range, 0, 0, 1, }, - { "knockback_left", &battle_config.knockback_left, 1, 0, 1, }, + { "knockback_left", &battle_config.knockback_left, 1, 0, 1, }, { "client_reshuffle_dice", &battle_config.client_reshuffle_dice, 0, 0, 1, }, { "client_sort_storage", &battle_config.client_sort_storage, 0, 0, 1, }, { "feature.buying_store", &battle_config.feature_buying_store, 1, 0, 1, }, @@ -6834,8 +6835,8 @@ static const struct battle_data { { "mon_trans_disable_in_gvg", &battle_config.mon_trans_disable_in_gvg, 0, 0, 1, }, { "case_sensitive_aegisnames", &battle_config.case_sensitive_aegisnames, 1, 0, 1, }, - { "guild_castle_invite", &battle_config.guild_castle_invite, 0, 0, 1, }, - { "guild_castle_expulsion", &battle_config.guild_castle_expulsion, 0, 0, 1, }, + { "guild_castle_invite", &battle_config.guild_castle_invite, 0, 0, 1, }, + { "guild_castle_expulsion", &battle_config.guild_castle_expulsion, 0, 0, 1, }, { "song_timer_reset", &battle_config.song_timer_reset, 0, 0, 1, }, { "snap_dodge", &battle_config.snap_dodge, 0, 0, 1, }, { "monster_chase_refresh", &battle_config.mob_chase_refresh, 1, 0, 30, }, @@ -6882,7 +6883,7 @@ void Hercules_report(char* date, char *time_c) { /* we get the current time */ time(&curtime); strftime(timestring, 24, "%Y-%m-%d %H:%M:%S", localtime(&curtime)); - + #ifdef CIRCULAR_AREA config |= C_CIRCULAR_AREA; #endif @@ -6894,7 +6895,7 @@ void Hercules_report(char* date, char *time_c) { #ifdef CONSOLE_INPUT config |= C_CONSOLE_INPUT; #endif - + #ifdef SCRIPT_CALLFUNC_CHECK config |= C_SCRIPT_CALLFUNC_CHECK; #endif @@ -6938,7 +6939,7 @@ void Hercules_report(char* date, char *time_c) { #ifdef PACKETVER_RE config |= C_PACKETVER_RE; #endif - + /* non-define part */ if( map->db_use_sql_item_db ) config |= C_SQL_DB_ITEM; @@ -7085,7 +7086,7 @@ void battle_adjust_conf(void) { battle_config.feature_search_stores = 0; } #endif - + #if PACKETVER < 20130724 if( battle_config.feature_banking ) { ShowWarning("conf/battle/feature.conf banking is enabled but it requires PACKETVER 2013-07-24 or newer, disabling...\n"); @@ -7099,7 +7100,7 @@ void battle_adjust_conf(void) { battle_config.feature_roulette = 0; } #endif - + #if PACKETVER > 20120000 && PACKETVER < 20130515 /* exact date (when it started) not known */ if( battle_config.feature_auction == 1 ) { ShowWarning("conf/battle/feature.conf:feature.auction is enabled but it is not stable on PACKETVER "EXPAND_AND_QUOTE(PACKETVER)", disabling...\n"); @@ -7178,15 +7179,15 @@ void do_final_battle(void) { /* initialize the interface */ void battle_defaults(void) { battle = &battle_s; - + battle->bc = &battle_config; - + memset(battle->attr_fix_table, 0, sizeof(battle->attr_fix_table)); battle->delay_damage_ers = NULL; - + battle->init = do_init_battle; battle->final = do_final_battle; - + battle->calc_attack = battle_calc_attack; battle->calc_damage = battle_calc_damage; battle->calc_gvg_damage = battle_calc_gvg_damage; diff --git a/src/map/battle.h b/src/map/battle.h index c44e3e19d..ad879bd1a 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -28,23 +28,24 @@ struct status_data; #define MIN_CLOTH_COLOR (battle->bc->min_cloth_color) #define MAX_CLOTH_COLOR (battle->bc->max_cloth_color) -#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru] +#define is_boss(bl) (status_get_mode(bl)&MD_BOSS) // Can refine later [Aru] /** * Enumerations **/ -enum { // Flag of the final calculation - BF_WEAPON = 0x0001, - BF_MAGIC = 0x0002, - BF_MISC = 0x0004, - BF_SHORT = 0x0010, - BF_LONG = 0x0040, - BF_SKILL = 0x0100, - BF_NORMAL = 0x0200, - BF_WEAPONMASK=0x000f, - BF_RANGEMASK= 0x00f0, - BF_SKILLMASK= 0x0f00, +enum { + // Flag of the final calculation + BF_WEAPON = 0x0001, + BF_MAGIC = 0x0002, + BF_MISC = 0x0004, + BF_SHORT = 0x0010, + BF_LONG = 0x0040, + BF_SKILL = 0x0100, + BF_NORMAL = 0x0200, + BF_WEAPONMASK = 0x000f, + BF_RANGEMASK = 0x00f0, + BF_SKILLMASK = 0x0f00, }; // state of a single attack attempt; used in flee/def penalty calculations when mobbed @@ -62,17 +63,17 @@ enum e_battle_check_target { //New definitions [Skotlex] BCT_SELF = 0x010000, BCT_ENEMY = 0x020000, BCT_PARTY = 0x040000, - BCT_GUILDALLY = 0x080000, // Only allies, NOT guildmates + BCT_GUILDALLY = 0x080000, ///< Only allies, NOT guildmates BCT_NEUTRAL = 0x100000, - BCT_SAMEGUILD = 0x200000, // No Guild Allies - - BCT_GUILD = 0x280000, // Guild AND allies (BCT_SAMEGUILD|BCT_GUILDALLY) - - BCT_NOGUILD = 0x170000, // This should be (~BCT_GUILD&BCT_ALL) - BCT_NOPARTY = 0x3b0000, // This should be (~BCT_PARTY&BCT_ALL) - BCT_NOENEMY = 0x3d0000, // This should be (~BCT_ENEMY&BCT_ALL) - - BCT_ALL = 0x3f0000, // Sum of BCT_NOONE to BCT_SAMEGUILD + BCT_SAMEGUILD = 0x200000, ///< No Guild Allies + + BCT_GUILD = 0x280000, ///< Guild AND allies (BCT_SAMEGUILD|BCT_GUILDALLY) + + BCT_NOGUILD = 0x170000, ///< This must be (~BCT_GUILD&BCT_ALL) + BCT_NOPARTY = 0x3b0000, ///< This must be (~BCT_PARTY&BCT_ALL) + BCT_NOENEMY = 0x3d0000, ///< This must be (~BCT_ENEMY&BCT_ALL) + + BCT_ALL = 0x3f0000, ///< Sum of BCT_NOONE to BCT_SAMEGUILD }; /** @@ -86,7 +87,7 @@ struct Damage { int amotion,dmotion; int blewcount; //nb of knockback int flag; //chk BF_* flag, (enum below) - enum damage_lv dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF + enum damage_lv dmg_lv; //ATK_LUCKY,ATK_FLEE,ATK_DEF }; struct Battle_Config { @@ -147,12 +148,12 @@ struct Battle_Config { int monster_active_enable; int monster_damage_delay_rate; int monster_loot_type; - int mob_skill_rate; //[Skotlex] - int mob_skill_delay; //[Skotlex] + int mob_skill_rate; //[Skotlex] + int mob_skill_delay; //[Skotlex] int mob_count_rate; int no_spawn_on_player; //[Skotlex] int force_random_spawn; //[Skotlex] - int mob_spawn_delay, plant_spawn_delay, boss_spawn_delay; // [Skotlex] + int mob_spawn_delay, plant_spawn_delay, boss_spawn_delay; // [Skotlex] int slaves_inherit_mode; int slaves_inherit_speed; int summons_trigger_autospells; @@ -169,7 +170,7 @@ struct Battle_Config { int emergency_call; int guild_aura; int pc_invincible_time; - + int pet_catch_rate; int pet_rename; int pet_friendly_rate; @@ -178,7 +179,7 @@ struct Battle_Config { int pet_status_support; int pet_attack_support; int pet_damage_support; - int pet_support_min_friendly; //[Skotlex] + int pet_support_min_friendly; //[Skotlex] int pet_equip_min_friendly; int pet_support_rate; int pet_attack_exp_to_master; @@ -189,7 +190,7 @@ struct Battle_Config { int pet_max_atk2; //[Skotlex] int pet_no_gvg; //Disables pets in gvg. [Skotlex] int pet_equip_required; - + int skill_min_damage; int finger_offensive_type; int heal_exp; @@ -199,11 +200,11 @@ struct Battle_Config { int shop_exp; int combo_delay_rate; int item_check; - int item_use_interval; //[Skotlex] + int item_use_interval; //[Skotlex] int cashfood_use_interval; int wedding_modifydisplay; - int wedding_ignorepalette; //[Skotlex] - int xmas_ignorepalette; // [Valaris] + int wedding_ignorepalette; //[Skotlex] + int xmas_ignorepalette; // [Valaris] int summer_ignorepalette; // [Zephyrus] int hanbok_ignorepalette; int natural_healhp_interval; @@ -212,7 +213,7 @@ struct Battle_Config { int natural_heal_weight_rate; int arrow_decrement; int max_aspd; - int max_walk_speed; //Maximum walking speed after buffs [Skotlex] + int max_walk_speed; //Maximum walking speed after buffs [Skotlex] int max_hp; int max_sp; int max_lv, aura_lv; @@ -224,8 +225,8 @@ struct Battle_Config { int save_clothcolor; int undead_detect_type; int auto_counter_type; - int min_hitrate; //[Skotlex] - int max_hitrate; //[Skotlex] + int min_hitrate; //[Skotlex] + int max_hitrate; //[Skotlex] int agi_penalty_target; int agi_penalty_type; int agi_penalty_count; @@ -263,33 +264,33 @@ struct Battle_Config { int item_rate_mvp, item_rate_common, item_rate_common_boss, item_rate_card, item_rate_card_boss, item_rate_equip, item_rate_equip_boss, item_rate_heal, item_rate_heal_boss, item_rate_use, item_rate_use_boss, item_rate_treasure, item_rate_adddrop; - + int logarithmic_drops; - int item_drop_common_min,item_drop_common_max; // Added by TyrNemesis^ + int item_drop_common_min,item_drop_common_max; // Added by TyrNemesis^ int item_drop_card_min,item_drop_card_max; int item_drop_equip_min,item_drop_equip_max; - int item_drop_mvp_min,item_drop_mvp_max; // End Addition - int item_drop_heal_min,item_drop_heal_max; // Added by Valatris - int item_drop_use_min,item_drop_use_max; //End + int item_drop_mvp_min,item_drop_mvp_max; // End Addition + int item_drop_heal_min,item_drop_heal_max; // Added by Valatris + int item_drop_use_min,item_drop_use_max; //End int item_drop_treasure_min,item_drop_treasure_max; //by [Skotlex] int item_drop_adddrop_min,item_drop_adddrop_max; //[Skotlex] - - int prevent_logout; // Added by RoVeRT - - int alchemist_summon_reward; // [Valaris] + + int prevent_logout; // Added by RoVeRT + + int alchemist_summon_reward; // [Valaris] int drops_by_luk; int drops_by_luk2; - int equip_natural_break_rate; //Base Natural break rate for attacks. + int equip_natural_break_rate; //Base Natural break rate for attacks. int equip_self_break_rate; //Natural & Penalty skills break rate int equip_skill_break_rate; //Offensive skills break rate int multi_level_up; int max_exp_gain_rate; //Max amount of exp bar % you can get in one go. int pk_mode; int pk_level_range; - + int manner_system; // end additions [Valaris] int show_mob_info; - + int gx_allhit; int gx_disptype; int devotion_level_difference; @@ -305,13 +306,13 @@ struct Battle_Config { int bone_drop; int buyer_name; int dancing_weaponswitch_fix; - + // eAthena additions int night_at_start; // added by [Yor] int day_duration; // added by [Yor] int night_duration; // added by [Yor] int ban_hack_trade; // added by [Yor] - + int min_hair_style; // added by [MouseJstr] int max_hair_style; // added by [MouseJstr] int min_hair_color; // added by [MouseJstr] @@ -319,12 +320,12 @@ struct Battle_Config { int min_cloth_color; // added by [MouseJstr] int max_cloth_color; // added by [MouseJstr] int pet_hair_style; // added by [Skotlex] - + int castrate_dex_scale; // added by [MouseJstr] int area_size; // added by [MouseJstr] - + int max_def, over_def_bonus; //added by [Skotlex] - + int zeny_from_mobs; // [Valaris] int mobs_level_up; // [Valaris] int mobs_level_up_exp_rate; // [Valaris] @@ -344,12 +345,12 @@ struct Battle_Config { int delay_battle_damage; int hide_woe_damage; int display_version; - - int display_hallucination; // [Skotlex] - int use_statpoint_table; // [Skotlex] - + + int display_hallucination; // [Skotlex] + int use_statpoint_table; // [Skotlex] + int ignore_items_gender; //[Lupus] - + int copyskill_restrict; // [Aru] int berserk_cancels_buffs; // [Aru] int mob_ai; //Configures various mob_ai settings to make them smarter or dumber(official). [Skotlex] @@ -359,23 +360,23 @@ struct Battle_Config { int mob_remove_delay; // Dynamic Mobs - delay before removing mobs from a map [Skotlex] int mob_active_time; //Duration through which mobs execute their Hard AI after players leave their area of sight. int boss_active_time; - - int show_hp_sp_drain, show_hp_sp_gain; //[Skotlex] - + + int show_hp_sp_drain, show_hp_sp_gain; //[Skotlex] + int mob_npc_event_type; //Determines on who the npc_event is executed. [Skotlex] - + int character_size; // if riders have size=2, and baby class riders size=1 [Lupus] int rare_drop_announce; // chance <= to show rare drops global announces - - int retaliate_to_master; //Whether when a mob is attacked by another mob, it will retaliate versus the mob or the mob's master. [Skotlex] - + + int retaliate_to_master; //Whether when a mob is attacked by another mob, it will retaliate versus the mob or the mob's master. [Skotlex] + int duel_allow_pvp; // [LuzZza] int duel_allow_gvg; // [LuzZza] int duel_allow_teleport; // [LuzZza] int duel_autoleave_when_die; // [LuzZza] int duel_time_interval; // [LuzZza] int duel_only_on_same_map; // [Toms] - + int skip_teleport_lv1_menu; // possibility to disable (skip) Teleport Lv1 menu, that have only two lines `Random` and `Cancel` [LuzZza] int mob_max_skilllvl; int allow_skill_without_day; // [Komurka] @@ -389,7 +390,7 @@ struct Battle_Config { int mob_sc_def_rate; int pc_max_sc_def; int mob_max_sc_def; - + int sg_angel_skill_ratio; int sg_miracle_skill_ratio; int sg_miracle_skill_duration; @@ -397,9 +398,9 @@ struct Battle_Config { int override_mob_names; //Enables overriding spawn mob names with the mob_db names. [Skotlex] int min_chat_delay; //Minimum time between client messages. [Skotlex] int friend_auto_add; //When accepting friends, both get friended. [Skotlex] - int hvan_explosion_intimate; // fix [albator] + int hvan_explosion_intimate; // fix [albator] int hom_rename; - int homunculus_show_growth ; //[orn] + int homunculus_show_growth; //[orn] int homunculus_friendly_rate; int quest_exp_rate; int autotrade_mapflag; @@ -410,13 +411,13 @@ struct Battle_Config { int ksprotection; int auction_feeperhour; int auction_maximumprice; - int homunculus_auto_vapor; //Keep Homunculus from Vaporizing when master dies. [L0ne_W0lf] - int display_status_timers; //Show or hide skill buff/delay timers in recent clients [Sara] - int skill_add_heal_rate; //skills that bHealPower has effect on [Inkfish] + int homunculus_auto_vapor; //Keep Homunculus from Vaporizing when master dies. [L0ne_W0lf] + int display_status_timers; //Show or hide skill buff/delay timers in recent clients [Sara] + int skill_add_heal_rate; //skills that bHealPower has effect on [Inkfish] int eq_single_target_reflectable; int invincible_nodamage; int mob_slave_keep_target; - int autospell_check_range; //Enable range check for autospell bonus. [L0ne_W0lf] + int autospell_check_range; //Enable range check for autospell bonus. [L0ne_W0lf] int knockback_left; int client_reshuffle_dice; // Reshuffle /dice int client_sort_storage; @@ -431,11 +432,11 @@ struct Battle_Config { int client_emblem_max_blank_percent; int hom_max_level; int hom_S_max_level; - + // [BattleGround Settings] int bg_update_interval; int bg_flee_penalty; - + // rAthena int max_third_parameter; int max_baby_third_parameter; @@ -443,13 +444,13 @@ struct Battle_Config { int atcommand_max_stat_bypass; int max_third_aspd; int vcast_stat_scale; - + int mvp_tomb_enabled; - + int atcommand_suggestions_enabled; int min_npc_vendchat_distance; int atcommand_mobinfo_type; - + int mob_size_influence; // Enable modifications on earned experience, drop rates and monster status depending on monster size. [mkbu95] int bowling_bash_area; int mob_chase_refresh; //How often a monster should refresh its chase [Playtester] @@ -465,11 +466,11 @@ struct Battle_Config { int packet_obfuscation; int idletime_criteria; int gm_ignore_warpable_area; - + int client_accept_chatdori; // [Ai4rei/Mirei] int snovice_call_type; int guild_notice_changemap; - + int feature_banking; int feature_auction; @@ -481,7 +482,7 @@ struct Battle_Config { int song_timer_reset; // [csnv] int snap_dodge; // Enable or disable dodging damage snapping away [csnv] - + int feature_roulette; }; diff --git a/src/map/battleground.c b/src/map/battleground.c index f7131513d..190f7886d 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -157,11 +157,11 @@ int bg_team_leave(struct map_session_data *sd, enum bg_team_leave_type flag) { if( bgd->logout_event[0] && flag ) npc->event(sd, bgd->logout_event, 0); - + if( sd->bg_queue.arena ) { bg->queue_pc_cleanup(sd); } - + return bgd->count; } @@ -267,11 +267,11 @@ int bg_send_xy_timer(int tid, int64 tick, int id, intptr_t data) { enum bg_queue_types bg_str2teamtype (const char *str) { char temp[200], *parse; enum bg_queue_types type = BGQT_INVALID; - + safestrncpy(temp, str, 200); - + parse = strtok(temp,"|"); - + while (parse != NULL) { normalize_name(parse," "); if( strcmpi(parse,"all") == 0 ) @@ -287,7 +287,7 @@ enum bg_queue_types bg_str2teamtype (const char *str) { } parse = strtok(NULL,"|"); } - + return type; } @@ -295,25 +295,24 @@ void bg_config_read(void) { config_t bg_conf; config_setting_t *data = NULL; const char *config_filename = "conf/battlegrounds.conf"; // FIXME hardcoded name - + if (libconfig->read_file(&bg_conf, config_filename)) return; - + data = libconfig->lookup(&bg_conf, "battlegrounds"); - + if (data != NULL) { config_setting_t *settings = libconfig->setting_get_elem(data, 0); config_setting_t *arenas; const char *delay_var; int i, arena_count = 0, offline = 0; - + if( !libconfig->setting_lookup_string(settings, "global_delay_var", &delay_var) ) delay_var = "BG_Delay_Tick"; - + safestrncpy(bg->gdelay_var, delay_var, BG_DELAY_VAR_LENGTH); - + libconfig->setting_lookup_int(settings, "maximum_afk_seconds", &bg->mafksec); - libconfig->setting_lookup_bool(settings, "feature_off", &offline); if( offline == 0 ) @@ -332,14 +331,14 @@ void bg_config_read(void) { int maxDuration; int fillup_duration = 0, pregame_duration = 0; enum bg_queue_types allowedTypes; - + bg->arena[i] = NULL; - + if( !libconfig->setting_lookup_string(arena, "name", &aName) ) { ShowError("bg_config_read: failed to find 'name' for arena #%d\n",i); continue; } - + if( !libconfig->setting_lookup_string(arena, "event", &aEvent) ) { ShowError("bg_config_read: failed to find 'event' for arena #%d\n",i); continue; @@ -347,7 +346,7 @@ void bg_config_read(void) { libconfig->setting_lookup_int(arena, "minLevel", &minLevel); libconfig->setting_lookup_int(arena, "maxLevel", &maxLevel); - + if( minLevel < 0 ) { ShowWarning("bg_config_read: invalid %d value for arena '%s' minLevel\n",minLevel,aName); minLevel = 0; @@ -356,16 +355,16 @@ void bg_config_read(void) { ShowWarning("bg_config_read: invalid %d value for arena '%s' maxLevel\n",maxLevel,aName); maxLevel = MAX_LEVEL; } - + if( !(reward = libconfig->setting_get_member(arena, "reward")) ) { ShowError("bg_config_read: failed to find 'reward' for arena '%s'/#%d\n",aName,i); continue; } - + libconfig->setting_lookup_int(reward, "win", &prizeWin); libconfig->setting_lookup_int(reward, "loss", &prizeLoss); libconfig->setting_lookup_int(reward, "draw", &prizeDraw); - + if( prizeWin < 0 ) { ShowWarning("bg_config_read: invalid %d value for arena '%s' reward:win\n",prizeWin,aName); prizeWin = 0; @@ -378,11 +377,11 @@ void bg_config_read(void) { ShowWarning("bg_config_read: invalid %d value for arena '%s' reward:draw\n",prizeDraw,aName); prizeDraw = 0; } - + libconfig->setting_lookup_int(arena, "minPlayers", &minPlayers); libconfig->setting_lookup_int(arena, "maxPlayers", &maxPlayers); libconfig->setting_lookup_int(arena, "minTeamPlayers", &minTeamPlayers); - + if( minPlayers < 0 ) { ShowWarning("bg_config_read: invalid %d value for arena '%s' minPlayers\n",minPlayers,aName); minPlayers = 0; @@ -400,20 +399,19 @@ void bg_config_read(void) { ShowError("bg_config_read: failed to find 'delay_var' for arena '%s'/#%d\n",aName,i); continue; } - - + if( !libconfig->setting_lookup_string(arena, "allowedTypes", &aTeamTypes) ) { ShowError("bg_config_read: failed to find 'allowedTypes' for arena '%s'/#%d\n",aName,i); continue; } - + libconfig->setting_lookup_int(arena, "maxDuration", &maxDuration); - + if( maxDuration < 0 ) { ShowWarning("bg_config_read: invalid %d value for arena '%s' maxDuration\n",maxDuration,aName); maxDuration = 30; } - + libconfig->setting_lookup_int(arena, "fillDuration", &fillup_duration); libconfig->setting_lookup_int(arena, "pGameDuration", &pregame_duration); @@ -428,9 +426,9 @@ void bg_config_read(void) { } allowedTypes = bg->str2teamtype(aTeamTypes); - + CREATE( bg->arena[i], struct bg_arena, 1 ); - + bg->arena[i]->id = i; safestrncpy(bg->arena[i]->name, aName, NAME_LENGTH); safestrncpy(bg->arena[i]->npc_event, aEvent, EVENT_NAME_LENGTH); @@ -455,7 +453,6 @@ void bg_config_read(void) { } bg->arenas = arena_count; } - libconfig->destroy(&bg_conf); } } @@ -493,7 +490,7 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo struct hQueue *queue = &script->hq[arena->queue_id]; int i, count = 0; sd->bg_queue.ready = 1; - + for( i = 0; i < queue->size; i++ ) { if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.ready == 1 ) @@ -506,10 +503,9 @@ void bg_queue_ready_ack (struct bg_arena *arena, struct map_session_data *sd, bo arena->begin_timer = INVALID_TIMER; bg->begin(arena); } - } - } + void bg_queue_player_cleanup(struct map_session_data *sd) { if ( sd->bg_queue.client_has_bg_data ) { if( sd->bg_queue.arena ) @@ -527,14 +523,14 @@ void bg_queue_player_cleanup(struct map_session_data *sd) { void bg_match_over(struct bg_arena *arena, bool canceled) { struct hQueue *queue = &script->hq[arena->queue_id]; int i; - + if( !arena->ongoing ) return; arena->ongoing = false; for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.arena ) { bg->team_leave(sd, 0); @@ -559,7 +555,7 @@ void bg_begin(struct bg_arena *arena) { for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.ready == 1 ) count++; @@ -575,23 +571,21 @@ void bg_begin(struct bg_arena *arena) { bg->match_over(arena,true); } else { arena->ongoing = true; - + if( bg->afk_timer_id == INVALID_TIMER && bg->mafksec > 0 ) bg->afk_timer_id = timer->add(timer->gettick()+10000,bg->afk_timer,0,0); - + /* TODO: make this a arena-independent var? or just .@? */ mapreg->setreg(script->add_str("$@bg_queue_id"),arena->queue_id); mapreg->setregstr(script->add_str("$@bg_delay_var$"),bg->gdelay_var); - + count = 0; for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { if( sd->bg_queue.ready == 1 ) { - mapreg->setreg(reference_uid(script->add_str("$@bg_member"), count), sd->status.account_id); - mapreg->setreg(reference_uid(script->add_str("$@bg_member_group"), count), sd->bg_queue.type == BGQT_GUILD ? sd->status.guild_id : sd->bg_queue.type == BGQT_PARTY ? sd->status.party_id : @@ -607,7 +601,7 @@ void bg_begin(struct bg_arena *arena) { } } mapreg->setreg(script->add_str("$@bg_member_size"),count); - + npc->event_do(arena->npc_event); } } @@ -631,7 +625,7 @@ int bg_afk_timer(int tid, int64 tick, int id, intptr_t data) { count++; } mapit->free(iter); - + if( count ) bg->afk_timer_id = timer->add(timer->gettick()+10000,bg->afk_timer,0,0); else @@ -642,10 +636,10 @@ int bg_afk_timer(int tid, int64 tick, int id, intptr_t data) { void bg_queue_pregame(struct bg_arena *arena) { struct hQueue *queue = &script->hq[arena->queue_id]; int i; - + for( i = 0; i < queue->size; i++ ) { struct map_session_data * sd = NULL; - + if( queue->item[i] > 0 && ( sd = map->id2sd(queue->item[i]) ) ) { clif->bgqueue_battlebegins(sd,arena->id,SELF); } @@ -674,17 +668,17 @@ void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_q enum BATTLEGROUNDS_QUEUE_ACK result = bg->can_queue(sd,arena,type); struct hQueue *queue; int i, count = 0; - + if( arena->begin_timer != INVALID_TIMER || arena->ongoing ) { clif->bgqueue_ack(sd,BGQA_FAIL_QUEUING_FINISHED,arena->id); return; } - + if( result != BGQA_SUCCESS ) { clif->bgqueue_ack(sd,result,arena->id); return; } - + switch( type ) { /* guild/party already validated in can_queue */ case BGQT_PARTY: { struct party_data *p = party->search(sd->status.party_id); @@ -705,7 +699,7 @@ void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_q count = 1; break; } - + if( !(queue = script->queue(arena->queue_id)) || (queue->items+count) > arena->max_players ) { clif->bgqueue_ack(sd,BGQA_FAIL_PPL_OVERAMOUNT,arena->id); return; @@ -746,26 +740,24 @@ void bg_queue_add(struct map_session_data *sd, struct bg_arena *arena, enum bg_q } break; } - clif->bgqueue_ack(sd,BGQA_SUCCESS,arena->id); - bg->queue_check(arena); } enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type) { int tick; unsigned int tsec; - + if( !(arena->allowed_types & type) ) return BGQA_FAIL_TYPE_INVALID; - + if ( sd->status.base_level > arena->max_level || sd->status.base_level < arena->min_level ) return BGQA_FAIL_LEVEL_INCORRECT; - + if ( !(sd->class_&JOBL_2) ) /* TODO: maybe make this a per-arena setting, so users may make custom arenas like baby-only,whatever. */ return BGQA_FAIL_CLASS_INVALID; - + tsec = (unsigned int)time(NULL); - + if ( ( tick = pc_readglobalreg(sd, script->add_str(bg->gdelay_var)) ) && tsec < tick ) { char response[100]; if( (tick-tsec) > 60 ) @@ -775,7 +767,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ clif->colormes(sd->fd,COLOR_RED,response); return BGQA_FAIL_DESERTER; } - + if ( ( tick = pc_readglobalreg(sd, script->add_str(arena->delay_var)) ) && tsec < tick ) { char response[100]; if( (tick-tsec) > 60 ) @@ -788,7 +780,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ if( sd->bg_queue.arena != NULL ) return BGQA_DUPLICATE_REQUEST; - + switch(type) { case BGQT_GUILD: if( !sd->guild || !sd->state.gmaster_flag ) @@ -831,7 +823,7 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ if( !is_leader ) return BGQA_NOT_PARTY_GUILD_LEADER; - + if( count < arena->min_team_players ) { char response[100]; if( count != p->party.count && p->party.count >= arena->min_team_players ) @@ -841,7 +833,6 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ clif->colormes(sd->fd,COLOR_RED,response); return BGQA_FAIL_TEAM_COUNT; } - } else return BGQA_NOT_PARTY_GUILD_LEADER; } @@ -852,7 +843,6 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_ ShowDebug("bg_canqueue: unknown/unsupported type %d\n",type); return BGQA_DUPLICATE_REQUEST; } - return BGQA_SUCCESS; } void do_init_battleground(bool minimal) { @@ -867,22 +857,22 @@ void do_init_battleground(bool minimal) { void do_final_battleground(void) { int i; - + db_destroy(bg->team_db); - + for( i = 0; i < bg->arenas; i++ ) { if( bg->arena[i] ) aFree(bg->arena[i]); } - + if( bg->arena ) aFree(bg->arena); } void battleground_defaults(void) { bg = &bg_s; - + bg->queue_on = false; - + bg->mafksec = 0; bg->afk_timer_id = INVALID_TIMER; bg->arena = NULL; diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 84b917cfc..8efffa342 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -294,8 +294,11 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int return; } - if( sd->status.inventory[index].expire_time || (sd->status.inventory[index].bound && !pc_can_give_bound_items(sd)) || !itemdb_cantrade(&sd->status.inventory[index], pc_get_group_level(sd), pc_get_group_level(pl_sd)) || memcmp(sd->status.inventory[index].card, buyingstore->blankslots, sizeof(buyingstore->blankslots)) ) - {// non-tradable item + if (sd->status.inventory[index].expire_time || (sd->status.inventory[index].bound && !pc_can_give_bound_items(sd)) + || !itemdb_cantrade(&sd->status.inventory[index], pc_get_group_level(sd), pc_get_group_level(pl_sd)) + || memcmp(sd->status.inventory[index].card, buyingstore->blankslots, sizeof(buyingstore->blankslots)) + ) { + // non-tradable item clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid); return; } @@ -367,7 +370,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int chrif->save(sd, 0); chrif->save(pl_sd, 0); } - + // check whether or not there is still something to buy ARR_FIND( 0, pl_sd->buyingstore.slots, i, pl_sd->buyingstore.items[i].amount != 0 ); if( i == pl_sd->buyingstore.slots ) @@ -459,7 +462,7 @@ bool buyingstore_searchall(struct map_session_data* sd, const struct s_search_st } void buyingstore_defaults(void) { buyingstore = &buyingstore_s; - + buyingstore->nextid = 0; memset(buyingstore->blankslots,0,sizeof(buyingstore->blankslots)); /* */ diff --git a/src/map/chat.c b/src/map/chat.c index cd7b5f811..9c67e0f44 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -61,10 +61,10 @@ struct chat_data* chat_createchat(struct block_list* bl, const char* title, cons } map->addiddb(&cd->bl); - + if( bl->type != BL_NPC ) cd->kick_list = idb_alloc(DB_OPT_BASE); - + return cd; } @@ -156,20 +156,20 @@ bool chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) { pc_setchatid(sd,cd->bl.id); - clif->joinchatok(sd, cd); //To the person who newly joined the list of all - clif->addchat(cd, sd); //Reports To the person who already in the chat - clif->dispchat(cd, 0); //Reported number of changes to the people around + clif->joinchatok(sd, cd); //To the person who newly joined the list of all + clif->addchat(cd, sd); //Reports To the person who already in the chat + clif->dispchat(cd, 0); //Reported number of changes to the people around - chat->trigger_event(cd); //Event + chat->trigger_event(cd); //Event - return true; + return true; } /*========================================== * Leave a chatroom * Return - * 0: User not found in chatroom/Missing data + * 0: User not found in chatroom/Missing data * 1: Success * 2: Chat room deleted (chat room empty) * 3: Owner changed (Owner left and a new one as assigned) @@ -188,8 +188,8 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) { } ARR_FIND( 0, cd->users, i, cd->usersd[i] == sd ); - if ( i == cd->users ) - { // Not found in the chatroom? + if (i == cd->users) { + // Not found in the chatroom? pc_setchatid(sd, 0); return 0; } @@ -213,7 +213,7 @@ int chat_leavechat(struct map_session_data* sd, bool kicked) { map->deliddb(&cd->bl); map->delblock(&cd->bl); map->freeblock(&cd->bl); - + su = map->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0); group = (su != NULL) ? su->group : NULL; if (group != NULL) @@ -326,7 +326,7 @@ bool chat_kickchat(struct map_session_data* sd, const char* kickusername) { nullpo_ret(sd); cd = (struct chat_data *)map->id2bl(sd->chatID); - + if( cd==NULL || (struct block_list *)sd != cd->owner ) return false; @@ -336,7 +336,7 @@ bool chat_kickchat(struct map_session_data* sd, const char* kickusername) { if (pc_has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK)) return false; //gm kick protection [Valaris] - + idb_iput(cd->kick_list,cd->usersd[i]->status.char_id,1); chat->leave(cd->usersd[i],1); @@ -385,14 +385,14 @@ bool chat_deletenpcchat(struct npc_data* nd) { cd = (struct chat_data*)map->id2bl(nd->chat_id); if( cd == NULL ) return false; - + chat->npc_kick_all(cd); clif->clearchat(cd, 0); map->deliddb(&cd->bl); map->delblock(&cd->bl); map->freeblock(&cd->bl); nd->chat_id = 0; - + return true; } @@ -452,7 +452,7 @@ bool chat_npckickall(struct chat_data* cd) *-------------------------------------*/ void chat_defaults(void) { chat = &chat_s; - + /* funcs */ chat->create_pc_chat = chat_createpcchat; chat->join = chat_joinchat; diff --git a/src/map/chat.h b/src/map/chat.h index e055c04ed..6fca018f4 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -16,21 +16,21 @@ struct npc_data; #define MAX_CHAT_USERS 20 struct chat_data { - struct block_list bl; // data for this map object - char title[CHATROOM_TITLE_SIZE]; // room title - char pass[CHATROOM_PASS_SIZE]; // password - bool pub; // private/public flag - uint8 users; // current user count - uint8 limit; // join limit - uint8 trigger; // number of users needed to trigger event - uint32 zeny; // required zeny to join - uint32 minLvl; // minimum base level to join - uint32 maxLvl; // maximum base level allowed to join + struct block_list bl; ///< data for this map object + char title[CHATROOM_TITLE_SIZE]; ///< room title + char pass[CHATROOM_PASS_SIZE]; ///< password + bool pub; ///< private/public flag + uint8 users; ///< current user count + uint8 limit; ///< join limit + uint8 trigger; ///< number of users needed to trigger event + uint32 zeny; ///< required zeny to join + uint32 minLvl; ///< minimum base level to join + uint32 maxLvl; ///< maximum base level allowed to join struct map_session_data* usersd[MAX_CHAT_USERS]; struct block_list* owner; char npc_event[EVENT_NAME_LENGTH]; /* isn't this a waste? there is a enormous overhead, wouldn't something like skill_blockpc_start be better here? [Ind] */ - DBMap* kick_list; //DBMap of users who were kicked from this chat + DBMap* kick_list; ///< DBMap of users who were kicked from this chat }; /*===================================== @@ -39,7 +39,6 @@ struct chat_data { * created by Susu *-------------------------------------*/ struct chat_interface { - /* funcs */ bool (*create_pc_chat) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub); bool (*join) (struct map_session_data* sd, int chatid, const char* pass); diff --git a/src/map/chrif.c b/src/map/chrif.c index c78b34309..a5003ab95 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -116,7 +116,6 @@ struct auth_node* chrif_search(int account_id) { struct auth_node* chrif_auth_check(int account_id, int char_id, enum sd_state state) { struct auth_node *node = chrif->search(account_id); - return ( node && node->char_id == char_id && node->state == state ) ? node : NULL; } @@ -125,24 +124,23 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) { if ( (node = chrif->auth_check(account_id, char_id, state) ) ) { int fd = node->sd ? node->sd->fd : node->fd; - + if ( session[fd] && session[fd]->session_data == node->sd ) session[fd]->session_data = NULL; - + if ( node->sd ) { - if( node->sd->regs.vars ) node->sd->regs.vars->destroy(node->sd->regs.vars, script->reg_destroy); - + if( node->sd->regs.arrays ) node->sd->regs.arrays->destroy(node->sd->regs.arrays, script->array_free_db); - + aFree(node->sd); } - + ers_free(chrif->auth_db_ers, node); idb_remove(chrif->auth_db,account_id); - + return true; } return false; @@ -151,52 +149,52 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) { //Moves the sd character to the auth_db structure. bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) { struct auth_node *node; - + if ( chrif->search(sd->status.account_id) ) return false; //Already exists? node = ers_alloc(chrif->auth_db_ers, struct auth_node); - + memset(node, 0, sizeof(struct auth_node)); - + node->account_id = sd->status.account_id; node->char_id = sd->status.char_id; node->login_id1 = sd->login_id1; node->login_id2 = sd->login_id2; node->sex = sd->status.sex; node->fd = sd->fd; - node->sd = sd; //Data from logged on char. + node->sd = sd; //Data from logged on char. node->node_created = timer->gettick(); //timestamp for node timeouts node->state = state; sd->state.active = 0; - + idb_put(chrif->auth_db, node->account_id, node); - + return true; } -bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) { - +bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) +{ if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex] //fd info must not be lost for ST_MAPCHANGE as a final packet needs to be sent to the player. if ( session[sd->fd] ) session[sd->fd]->session_data = NULL; sd->fd = 0; } - + return chrif->sd_to_auth(sd, state); } bool chrif_auth_finished(TBL_PC* sd) { struct auth_node *node= chrif->search(sd->status.account_id); - + if ( node && node->sd == sd && node->state == ST_LOGIN ) { node->sd = NULL; - + return chrif->auth_delete(node->account_id, node->char_id, ST_LOGIN); } - + return false; } // sets char-server's user id @@ -221,16 +219,16 @@ void chrif_checkdefaultlogin(void) { // sets char-server's ip address bool chrif_setip(const char* ip) { char ip_str[16]; - + if ( !( chrif->ip = host2ip(ip) ) ) { ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip); return false; } - + safestrncpy(chrif->ip_str, ip, sizeof(chrif->ip_str)); - + ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(chrif->ip, ip_str)); - + return true; } @@ -314,9 +312,9 @@ void chrif_connect(int fd) { // sends maps to char-server void chrif_sendmap(int fd) { int i; - + ShowStatus("Sending maps to char server...\n"); - + // Sending normal maps, not instances WFIFOHEAD(fd, 4 + instance->start_id * 4); WFIFOW(fd,0) = 0x2afa; @@ -335,7 +333,7 @@ void chrif_recvmap(int fd) { for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) { map->setipport(RFIFOW(fd,i), ip, port); } - + if (battle_config.etc_log) ShowStatus("Received maps from %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j); @@ -352,7 +350,7 @@ void chrif_removemap(int fd) { map->eraseipport(RFIFOW(fd, i), ip, port); chrif->other_mapserver_count--; - + if(battle_config.etc_log) ShowStatus("remove map of server %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j); } @@ -389,7 +387,7 @@ bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) WFIFOL(chrif->fd,31) = htonl(session[sd->fd]->client_addr); WFIFOL(chrif->fd,35) = sd->group_id; WFIFOSET(chrif->fd,39); - + return true; } @@ -397,7 +395,7 @@ bool chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) /// R 2b06 <account_id>.L <login_id1>.L <login_id2>.L <char_id>.L <map_index>.W <x>.W <y>.W <ip>.L <port>.W bool chrif_changemapserverack(int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port) { struct auth_node *node; - + if ( !( node = chrif->auth_check(account_id, char_id, ST_MAPCHANGE) ) ) return false; @@ -436,7 +434,7 @@ void chrif_connectack(int fd) { ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInitOnce")); guild->castle_map_init(); } - + sockt->datasync(fd, true); chrif->skillid2idx(fd); } @@ -446,7 +444,7 @@ void chrif_connectack(int fd) { */ int chrif_reconnect(DBKey key, DBData *data, va_list ap) { struct auth_node *node = DB->data2ptr(data); - + switch (node->state) { case ST_LOGIN: if ( node->sd ) {//Since there is no way to request the char auth, make it fail. @@ -463,7 +461,7 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) { struct map_session_data *sd = node->sd; uint32 ip; uint16 port; - + if( map->mapname2ipport(sd->mapindex,&ip,&port) == 0 ) chrif->changemapserver(sd, ip, port); else //too much lag/timeout is the closest explanation for this error. @@ -471,7 +469,6 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) { break; } } - return 0; } @@ -480,9 +477,9 @@ int chrif_reconnect(DBKey key, DBData *data, va_list ap) { void chrif_on_ready(void) { static bool once = false; ShowStatus("Map Server is now online.\n"); - + chrif->state = 2; - + chrif->check_shutdown(); //If there are players online, send them to the char-server. [Skotlex] @@ -496,7 +493,7 @@ void chrif_on_ready(void) { //Re-save any guild castles that were modified in the disconnection time. guild->castle_reconnect(-1, 0, 0); - + if( !once ) { #ifdef AUTOTRADE_PERSISTENCY pc->autotrade_load(); @@ -509,23 +506,23 @@ void chrif_on_ready(void) { /*========================================== * *------------------------------------------*/ -void chrif_sendmapack(int fd) { - +void chrif_sendmapack(int fd) +{ if (RFIFOB(fd,2)) { ShowFatalError("chrif : send map list to char server failed %d\n", RFIFOB(fd,2)); exit(EXIT_FAILURE); } memcpy(map->wisp_server_name, RFIFOP(fd,3), NAME_LENGTH); - + chrif->on_ready(); } /*========================================== * Request sc_data from charserver [Skotlex] *------------------------------------------*/ -bool chrif_scdata_request(int account_id, int char_id) { - +bool chrif_scdata_request(int account_id, int char_id) +{ #ifdef ENABLE_SC_SAVING chrif_check(false); @@ -535,7 +532,6 @@ bool chrif_scdata_request(int account_id, int char_id) { WFIFOL(chrif->fd,6) = char_id; WFIFOSET(chrif->fd,10); #endif - return true; } @@ -544,7 +540,7 @@ bool chrif_scdata_request(int account_id, int char_id) { *------------------------------------------*/ void chrif_authreq(struct map_session_data *sd, bool hstandalone) { struct auth_node *node= chrif->search(sd->bl.id); - + if( node != NULL || !chrif->isconnected() ) { set_eof(sd->fd); return; @@ -621,7 +617,7 @@ void chrif_authok(int fd) { } else { //Auth Failed pc->authfail(sd); } - + chrif_char_offline(sd); //Set him offline, the char server likely has it set as online already. chrif->auth_delete(account_id, char_id, ST_LOGIN); } @@ -639,7 +635,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used ( sex = RFIFOB(fd,14); node = chrif->search(account_id); - + if( node != NULL && node->account_id == account_id && node->char_id == char_id && @@ -660,7 +656,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used ( int auth_db_cleanup_sub(DBKey key, DBData *data, va_list ap) { struct auth_node *node = DB->data2ptr(data); const char* states[] = { "Login", "Logout", "Map change" }; - + if(DIFF_TICK(timer->gettick(),node->node_created)>60000) { switch (node->state) { case ST_LOGOUT: @@ -694,7 +690,7 @@ bool chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) { if( !sd->bl.id || !sd->login_id1 ) return false; - + chrif_check(false); WFIFOHEAD(chrif->fd,22); @@ -713,10 +709,10 @@ bool chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) { * Search Char trough id on char serv *------------------------------------------*/ bool chrif_searchcharid(int char_id) { - + if( !char_id ) return false; - + chrif_check(false); WFIFOHEAD(chrif->fd,6); @@ -731,7 +727,7 @@ bool chrif_searchcharid(int char_id) { * Change Email *------------------------------------------*/ bool chrif_changeemail(int id, const char *actual_email, const char *new_email) { - + if (battle_config.etc_log) ShowInfo("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n", id, actual_email, new_email); @@ -753,8 +749,8 @@ bool chrif_changeemail(int id, const char *actual_email, const char *new_email) * type of operation: * 1: block, 2: ban, 3: unblock, 4: unban, 5: changesex (use next function for 5), 6: charban *------------------------------------------*/ -bool chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second) { - +bool chrif_char_ask_name(int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second) +{ chrif_check(false); WFIFOHEAD(chrif->fd,44); @@ -762,7 +758,7 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope WFIFOL(chrif->fd,2) = acc; safestrncpy((char*)WFIFOP(chrif->fd,6), character_name, NAME_LENGTH); WFIFOW(chrif->fd,30) = operation_type; - + if ( operation_type == 2 || operation_type == 6 ) { WFIFOW(chrif->fd,32) = year; WFIFOW(chrif->fd,34) = month; @@ -771,14 +767,14 @@ bool chrif_char_ask_name(int acc, const char* character_name, unsigned short ope WFIFOW(chrif->fd,40) = minute; WFIFOW(chrif->fd,42) = second; } - + WFIFOSET(chrif->fd,44); return true; } bool chrif_changesex(struct map_session_data *sd) { chrif_check(false); - + WFIFOHEAD(chrif->fd,44); WFIFOW(chrif->fd,0) = 0x2b0e; WFIFOL(chrif->fd,2) = sd->status.account_id; @@ -811,9 +807,9 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u char action[25]; char output[256]; bool charsrv = ( type == 6 || type == 7 ) ? true : false; - + sd = map->id2sd(acc); - + if( acc < 0 || sd == NULL ) { ShowError("chrif_char_ask_name_answer failed - player not online.\n"); return false; @@ -822,7 +818,7 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u /* re-use previous msg_txt */ if( type == 6 ) type = 2; if( type == 7 ) type = 4; - + if( type > 0 && type <= 5 ) snprintf(action,25,"%s",msg_txt(427+type)); //block|ban|unblock|unban|change the sex of else @@ -835,7 +831,7 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u case 3 : sprintf(output, msg_txt(427), action, NAME_LENGTH, player_name); break; default: output[0] = '\0'; break; } - + clif->message(sd->fd, output); return true; } @@ -846,7 +842,7 @@ bool chrif_char_ask_name_answer(int acc, const char* player_name, uint16 type, u void chrif_changedsex(int fd) { int acc = RFIFOL(fd,2); //int sex = RFIFOL(fd,6); // Dead store. Uncomment if needed again. - + if ( battle_config.etc_log ) ShowNotice("chrif_changedsex %d.\n", acc); @@ -896,7 +892,7 @@ bool chrif_divorceack(int char_id, int partner_id) { if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F) pc->delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER); } - + return true; } /*========================================== @@ -932,10 +928,10 @@ void chrif_idbanned(int fd) { struct map_session_data *sd; id = RFIFOL(fd,2); - + if ( battle_config.etc_log ) ShowNotice("chrif_idbanned %d.\n", id); - + sd = ( RFIFOB(fd,6) == 2 ) ? map->charid2sd(id) : map->id2sd(id); if ( id < 0 || sd == NULL ) { @@ -981,10 +977,10 @@ int chrif_disconnectplayer(int fd) { sd = map->id2sd(account_id); if( sd == NULL ) { struct auth_node* auth = chrif->search(account_id); - + if( auth != NULL && chrif->auth_delete(account_id, auth->char_id, ST_LOGIN) ) return 0; - + return -1; } @@ -1011,7 +1007,7 @@ int chrif_disconnectplayer(int fd) { *------------------------------------------*/ int chrif_updatefamelist(struct map_session_data* sd) { char type; - + chrif_check(-1); switch(sd->class_ & MAPID_UPPERMASK) { @@ -1051,30 +1047,24 @@ void chrif_recvfamelist(int fd) { memset(pc->taekwon_fame_list, 0, sizeof(pc->taekwon_fame_list)); size = RFIFOW(fd, 6); //Blacksmith block size - for (num = 0; len < size && num < MAX_FAME_LIST; num++) { memcpy(&pc->smith_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list)); - len += sizeof(struct fame_list); + len += sizeof(struct fame_list); } - total += num; size = RFIFOW(fd, 4); //Alchemist block size - for (num = 0; len < size && num < MAX_FAME_LIST; num++) { memcpy(&pc->chemist_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list)); - len += sizeof(struct fame_list); + len += sizeof(struct fame_list); } - total += num; size = RFIFOW(fd, 2); //Total packet length - for (num = 0; len < size && num < MAX_FAME_LIST; num++) { memcpy(&pc->taekwon_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list)); - len += sizeof(struct fame_list); + len += sizeof(struct fame_list); } - total += num; ShowInfo("Received Fame List of '"CL_WHITE"%d"CL_RESET"' characters.\n", total); @@ -1085,21 +1075,20 @@ void chrif_recvfamelist(int fd) { int chrif_updatefamelist_ack(int fd) { struct fame_list* list; uint8 index; - + switch (RFIFOB(fd,2)) { case RANKTYPE_BLACKSMITH: list = pc->smith_fame_list; break; case RANKTYPE_ALCHEMIST: list = pc->chemist_fame_list; break; case RANKTYPE_TAEKWON: list = pc->taekwon_fame_list; break; default: return 0; } - + index = RFIFOB(fd, 3); - if (index >= MAX_FAME_LIST) return 0; - + list[index].fame = RFIFOL(fd,4); - + return 1; } @@ -1114,12 +1103,12 @@ bool chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of th chrif_check(false); tick = timer->gettick(); - + WFIFOHEAD(chrif->fd, 14 + SC_MAX*sizeof(struct status_change_data)); WFIFOW(chrif->fd,0) = 0x2b1c; WFIFOL(chrif->fd,4) = sd->status.account_id; WFIFOL(chrif->fd,8) = sd->status.char_id; - + for (i = 0; i < SC_MAX; i++) { if (!sc->data[i]) continue; @@ -1142,15 +1131,15 @@ bool chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of th &data, sizeof(struct status_change_data)); count++; } - + if (count == 0) return true; //Nothing to save. | Everything was as successful as if there was something to save. - + WFIFOW(chrif->fd,12) = count; WFIFOW(chrif->fd,2) = 14 +count*sizeof(struct status_change_data); //Total packet size WFIFOSET(chrif->fd,WFIFOW(chrif->fd,2)); #endif - + return true; } @@ -1164,30 +1153,29 @@ bool chrif_load_scdata(int fd) { aid = RFIFOL(fd,4); //Player Account ID cid = RFIFOL(fd,8); //Player Char ID - + sd = map->id2sd(aid); - + if ( !sd ) { ShowError("chrif_load_scdata: Player of AID %d not found!\n", aid); return false; } - + if ( sd->status.char_id != cid ) { ShowError("chrif_load_scdata: Receiving data for account %d, char id does not matches (%d != %d)!\n", aid, sd->status.char_id, cid); return false; } - + count = RFIFOW(fd,12); //sc_count - + for (i = 0; i < count; i++) { data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data)); status->change_start(NULL, &sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_LOADED|SCFLAG_FIXEDRATE); } - + pc->scdata_received(sd); #endif - return true; } @@ -1204,7 +1192,6 @@ bool chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate) { WFIFOL(chrif->fd,6) = job_rate; WFIFOL(chrif->fd,10) = drop_rate; WFIFOSET(chrif->fd,14); - return true; } @@ -1270,7 +1257,7 @@ void chrif_on_disconnect(void) { if( chrif->connected != 1 ) ShowWarning("Connection to Char Server lost.\n\n"); chrif->connected = 0; - + chrif->other_mapserver_count = 0; //Reset counter. We receive ALL maps from all map-servers on reconnect. map->eraseallipport(); @@ -1281,19 +1268,19 @@ void chrif_on_disconnect(void) { void chrif_update_ip(int fd) { uint32 new_ip; - + WFIFOHEAD(fd,6); - + new_ip = host2ip(chrif->ip_str); - + if (new_ip && new_ip != chrif->ip) chrif->ip = new_ip; //Update chrif->ip new_ip = clif->refresh_ip(); - + if (!new_ip) return; //No change - + WFIFOW(fd,0) = 0x2736; WFIFOL(fd,2) = htonl(new_ip); WFIFOSET(fd,6); @@ -1310,12 +1297,12 @@ void chrif_keepalive_ack(int fd) { } void chrif_skillid2idx(int fd) { int i, count = 0; - + if( fd == 0 ) fd = chrif->fd; - + if( !session_isValid(fd) ) return; - + WFIFOHEAD(fd,4 + (MAX_SKILL * 4)); WFIFOW(fd,0) = 0x2b0b; for(i = 0; i < MAX_SKILL; i++) { @@ -1367,12 +1354,12 @@ int chrif_parse(int fd) { } cmd = RFIFOW(fd,0); - + if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(chrif->packet_len_table) || chrif->packet_len_table[cmd-0x2af8] == 0) { r = intif->parse(fd); // Passed on to the intif - if (r == 1) continue; // Treated in intif - if (r == 2) return 0; // Didn't have enough data (len==-1) + if (r == 1) continue; // Treated in intif + if (r == 2) return 0; // Didn't have enough data (len==-1) ShowWarning("chrif_parse: session #%d, intif->parse failed (unrecognized command 0x%.4x).\n", fd, cmd); set_eof(fd); @@ -1448,20 +1435,18 @@ bool send_users_tochar(void) { chrif_check(false); users = map->usercount(); - + WFIFOHEAD(chrif->fd, 6+8*users); WFIFOW(chrif->fd,0) = 0x2aff; - + iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { WFIFOL(chrif->fd,6+8*i) = sd->status.account_id; WFIFOL(chrif->fd,6+8*i+4) = sd->status.char_id; i++; } - mapit->free(iter); - + WFIFOW(chrif->fd,2) = 6 + 8*users; WFIFOW(chrif->fd,4) = users; WFIFOSET(chrif->fd, 6+8*users); @@ -1471,7 +1456,7 @@ bool send_users_tochar(void) { /*========================================== * timerFunction - * Check the connection to char server, (if it down) + * Check the connection to char server, (if it down) *------------------------------------------*/ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) { static int displayed = 0; @@ -1482,7 +1467,7 @@ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) { } chrif->state = 0; - + if ( ( chrif->fd = make_connection(chrif->ip, chrif->port,NULL) ) == -1) //Attempt to connect later. [Skotlex] return 0; @@ -1507,8 +1492,8 @@ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) { /*========================================== * Asks char server to remove friend_id from the friend list of char_id *------------------------------------------*/ -bool chrif_removefriend(int char_id, int friend_id) { - +bool chrif_removefriend(int char_id, int friend_id) +{ chrif_check(false); WFIFOHEAD(chrif->fd,10); @@ -1516,7 +1501,6 @@ bool chrif_removefriend(int char_id, int friend_id) { WFIFOL(chrif->fd,2) = char_id; WFIFOL(chrif->fd,6) = friend_id; WFIFOSET(chrif->fd,10); - return true; } @@ -1524,13 +1508,12 @@ void chrif_send_report(char* buf, int len) { #ifndef STATS_OPT_OUT if( chrif->fd > 0 ) { WFIFOHEAD(chrif->fd,len + 2); - + WFIFOW(chrif->fd,0) = 0x3008; - memcpy(WFIFOP(chrif->fd,2), buf, len); - + WFIFOSET(chrif->fd,len + 2); - + flush_fifo(chrif->fd); /* ensure it's sent now. */ } #endif @@ -1539,13 +1522,13 @@ void chrif_send_report(char* buf, int len) { /** * Sends a single scdata for saving into char server, meant to ensure integrity of duration-less conditions **/ -void chrif_save_scdata_single(int account_id, int char_id, short type, struct status_change_entry *sce) { - +void chrif_save_scdata_single(int account_id, int char_id, short type, struct status_change_entry *sce) +{ if( !chrif->isconnected() ) return; - + WFIFOHEAD(chrif->fd, 28); - + WFIFOW(chrif->fd, 0) = 0x2740; WFIFOL(chrif->fd, 2) = account_id; WFIFOL(chrif->fd, 6) = char_id; @@ -1554,46 +1537,42 @@ void chrif_save_scdata_single(int account_id, int char_id, short type, struct st WFIFOL(chrif->fd, 16) = sce->val2; WFIFOL(chrif->fd, 20) = sce->val3; WFIFOL(chrif->fd, 24) = sce->val4; - + WFIFOSET(chrif->fd, 28); - } /** * Sends a single scdata deletion request into char server, meant to ensure integrity of duration-less conditions **/ -void chrif_del_scdata_single(int account_id, int char_id, short type) { - +void chrif_del_scdata_single(int account_id, int char_id, short type) +{ if( !chrif->isconnected() ) { ShowError("MAYDAY! failed to delete status %d from CID:%d/AID:%d\n",type,char_id,account_id); return; } - WFIFOHEAD(chrif->fd, 12); - + WFIFOW(chrif->fd, 0) = 0x2741; WFIFOL(chrif->fd, 2) = account_id; WFIFOL(chrif->fd, 6) = char_id; WFIFOW(chrif->fd, 10) = type; - - WFIFOSET(chrif->fd, 12); + WFIFOSET(chrif->fd, 12); } -/** ` +/** * @see DBApply */ int auth_db_final(DBKey key, DBData *data, va_list ap) { struct auth_node *node = DB->data2ptr(data); - + if (node->sd) { - if( node->sd->regs.vars ) node->sd->regs.vars->destroy(node->sd->regs.vars, script->reg_destroy); - + if( node->sd->regs.arrays ) node->sd->regs.arrays->destroy(node->sd->regs.arrays, script->array_free_db); - + aFree(node->sd); } ers_free(chrif->auth_db_ers, node); @@ -1604,15 +1583,15 @@ int auth_db_final(DBKey key, DBData *data, va_list ap) { /*========================================== * Destructor *------------------------------------------*/ -void do_final_chrif(void) { - +void do_final_chrif(void) +{ if( chrif->fd != -1 ) { do_close(chrif->fd); chrif->fd = -1; } chrif->auth_db->destroy(chrif->auth_db, chrif->auth_db_final); - + ers_destroy(chrif->auth_db_ers); } @@ -1648,12 +1627,12 @@ void do_init_chrif(bool minimal) { *-------------------------------------*/ void chrif_defaults(void) { const int packet_len_table[CHRIF_PACKET_LEN_TABLE_SIZE] = { // U - used, F - free - 60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff - 6,-1,18, 7,-1,39,30, 10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07 - 6,30, -1, 0,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, U->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f - 11,10,10, 0,11, 0,266,10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->2b15, U->2b16, U->2b17 - 2,10, 2,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f - -1,10, 8, 2, 2,14,19,19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27 + 60, 3, -1, 27, 10, -1, 6, -1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff + 6, -1, 18, 7, -1, 39, 30, 10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07 + 6, 30, -1, 0, 86, 7, 44, 34, // 2b08-2b0f: U->2b08, U->2b09, U->2b0a, F->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f + 11, 10, 10, 0, 11, 0,266, 10, // 2b10-2b17: U->2b10, U->2b11, U->2b12, F->2b13, U->2b14, F->2b15, U->2b16, U->2b17 + 2, 10, 2, -1, -1, -1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f + -1, 10, 8, 2, 2, 14, 19, 19, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, U->2b24, U->2b25, U->2b26, U->2b27 }; chrif = &chrif_s; @@ -1661,7 +1640,7 @@ void chrif_defaults(void) { /* vars */ chrif->connected = 0; chrif->other_mapserver_count = 0; - + memcpy(chrif->packet_len_table,&packet_len_table,sizeof(chrif->packet_len_table)); chrif->fd = -1; chrif->srvinfo = 0; @@ -1671,36 +1650,36 @@ void chrif_defaults(void) { memset(chrif->userid,0,sizeof(chrif->userid)); memset(chrif->passwd,0,sizeof(chrif->passwd)); chrif->state = 0; - + /* */ chrif->auth_db = NULL; chrif->auth_db_ers = NULL; /* */ chrif->init = do_init_chrif; chrif->final = do_final_chrif; - + /* funcs */ chrif->setuserid = chrif_setuserid; chrif->setpasswd = chrif_setpasswd; chrif->checkdefaultlogin = chrif_checkdefaultlogin; chrif->setip = chrif_setip; chrif->setport = chrif_setport; - + chrif->isconnected = chrif_isconnected; chrif->check_shutdown = chrif_check_shutdown; - + chrif->search = chrif_search; chrif->auth_check = chrif_auth_check; chrif->auth_delete = chrif_auth_delete; chrif->auth_finished = chrif_auth_finished; - + chrif->authreq = chrif_authreq; chrif->authok = chrif_authok; chrif->scdata_request = chrif_scdata_request; chrif->save = chrif_save; chrif->charselectreq = chrif_charselectreq; chrif->changemapserver = chrif_changemapserver; - + chrif->searchcharid = chrif_searchcharid; chrif->changeemail = chrif_changeemail; chrif->char_ask_name = chrif_char_ask_name; @@ -1715,13 +1694,13 @@ void chrif_defaults(void) { chrif->changesex = chrif_changesex; //chrif->chardisconnect = chrif_chardisconnect; chrif->divorce = chrif_divorce; - + chrif->removefriend = chrif_removefriend; chrif->send_report = chrif_send_report; - + chrif->flush = chrif_flush; chrif->skillid2idx = chrif_skillid2idx; - + chrif->sd_to_auth = chrif_sd_to_auth; chrif->check_connect_char_server = check_connect_char_server; chrif->auth_logout = chrif_auth_logout; @@ -1732,7 +1711,7 @@ void chrif_defaults(void) { chrif->auth_db_final = auth_db_final; chrif->send_usercount_tochar = send_usercount_tochar; chrif->auth_db_cleanup = auth_db_cleanup; - + chrif->connect = chrif_connect; chrif->connectack = chrif_connectack; chrif->sendmap = chrif_sendmap; diff --git a/src/map/chrif.h b/src/map/chrif.h index 11baaf5ff..2ef4d0eb5 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -48,7 +48,7 @@ struct auth_node { struct chrif_interface { /* vars */ - + int connected; int other_mapserver_count; //Holds count of how many other map servers are online (apart of this instance) [Skotlex] @@ -73,22 +73,22 @@ struct chrif_interface { void (*checkdefaultlogin) (void); bool (*setip) (const char* ip); void (*setport) (uint16 port); - + int (*isconnected) (void); void (*check_shutdown) (void); - + struct auth_node* (*search) (int account_id); struct auth_node* (*auth_check) (int account_id, int char_id, enum sd_state state); bool (*auth_delete) (int account_id, int char_id, enum sd_state state); bool (*auth_finished) (struct map_session_data* sd); - + void (*authreq) (struct map_session_data* sd, bool hstandalone); void (*authok) (int fd); bool (*scdata_request) (int account_id, int char_id); bool (*save) (struct map_session_data* sd, int flag); bool (*charselectreq) (struct map_session_data* sd, uint32 s_ip); bool (*changemapserver) (struct map_session_data* sd, uint32 ip, uint16 port); - + bool (*searchcharid) (int char_id); bool (*changeemail) (int id, const char *actual_email, const char *new_email); bool (*char_ask_name) (int acc, const char* character_name, unsigned short operation_type, int year, int month, int day, int hour, int minute, int second); @@ -104,13 +104,13 @@ struct chrif_interface { bool (*changesex) (struct map_session_data *sd); //int (*chardisconnect) (struct map_session_data *sd); // FIXME: Commented out in clif.c, function does not exist bool (*divorce) (int partner_id1, int partner_id2); - + bool (*removefriend) (int char_id, int friend_id); void (*send_report) (char* buf, int len); - + bool (*flush) (void); void (*skillid2idx) (int fd); - + bool (*sd_to_auth) (TBL_PC* sd, enum sd_state state); int (*check_connect_char_server) (int tid, int64 tick, int id, intptr_t data); bool (*auth_logout) (TBL_PC* sd, enum sd_state state); diff --git a/src/map/clif.c b/src/map/clif.c index 7ca37fa38..950898ba5 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -76,12 +76,15 @@ static struct packet_npc_market_open npcmarket_open; static inline int itemtype(int type) { switch( type ) { #if PACKETVER >= 20080827 - case IT_WEAPON: return IT_ARMOR; + case IT_WEAPON: + return IT_ARMOR; case IT_ARMOR: case IT_PETARMOR: #endif - case IT_PETEGG: return IT_WEAPON; - default: return type; + case IT_PETEGG: + return IT_WEAPON; + default: + return type; } } @@ -1467,7 +1470,7 @@ void clif_hominfo(struct map_session_data *sd, struct homun_data *hd, int flag) /// 3 = accessory? /// ? = ignored void clif_send_homdata(struct map_session_data *sd, int state, int param) -{ //[orn] +{ int fd = sd->fd; if ( (state == SP_INTIMATE) && (param >= 910) && (sd->hd->homunculus.class_ == sd->hd->homunculusDB->evo_class) ) @@ -1538,7 +1541,7 @@ void clif_homskillup(struct map_session_data *sd, uint16 skill_id) { //[orn] WFIFOSET(fd,packet_len(0x239)); } -void clif_hom_food(struct map_session_data *sd,int foodid,int fail) //[orn] +void clif_hom_food(struct map_session_data *sd,int foodid,int fail) { int fd; nullpo_retv(sd); @@ -1584,7 +1587,7 @@ void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *u case BL_PC: { TBL_PC *sd = ((TBL_PC*)bl); - // clif_movepc(sd); + //clif_movepc(sd); if(sd->state.size==SZ_BIG) // tiny/big players [Valaris] clif->specialeffect(&sd->bl,423,AREA); else if(sd->state.size==SZ_MEDIUM) @@ -2946,7 +2949,7 @@ void clif_updatestatus(struct map_session_data *sd,int type) case SP_WEIGHT: pc->updateweightstatus(sd); WFIFOHEAD(fd,14); - WFIFOW(fd,0)=0xb0; //Need to re-set as pc->updateweightstatus can alter the buffer. [Skotlex] + WFIFOW(fd,0)=0xb0; //Need to re-set as pc->updateweightstatus can alter the buffer. [Skotlex] WFIFOW(fd,2)=type; WFIFOL(fd,4)=sd->weight; break; @@ -4933,8 +4936,8 @@ void clif_deleteskill(struct map_session_data *sd, int id) /// 010e <skill id>.W <level>.W <sp cost>.W <attack range>.W <upgradable>.B /// Merged clif_skillup and clif_guild_skillup, same packet was used [panikon] /// flag: -/// 0: guild call -/// 1: player call +/// 0: guild call +/// 1: player call void clif_skillup(struct map_session_data *sd, uint16 skill_id, int skill_lv, int flag) { int fd; @@ -5065,7 +5068,8 @@ void clif_skill_fail(struct map_session_data *sd,uint16 skill_id,enum useskill_f { int fd; - if (!sd) { //Since this is the most common nullpo.... + if (!sd) { + //Since this is the most common nullpo.... ShowDebug("clif_skill_fail: Error, received NULL sd for skill %d\n", skill_id); return; } @@ -5376,7 +5380,7 @@ void clif_skill_memomessage(struct map_session_data* sd, int type) /// type: /// 0 = "Unable to Teleport in this area" in color 0xFFFF00 (cyan) /// 1 = "Saved point cannot be memorized." in color 0x0000FF (red) -/// 2 = "This skill cannot be used within this area." in color 0xFFFF00 (cyan) +/// 2 = "This skill cannot be used within this area." in color 0xFFFF00 (cyan) /// /// @param sd Who receives the message /// @param type What message @@ -5421,10 +5425,11 @@ void clif_skill_estimation(struct map_session_data *sd,struct block_list *dst) { WBUFW(buf,16) = (battle_config.estimation_type&1?dstatus->mdef:0) + (battle_config.estimation_type&2?dstatus->mdef2:0); WBUFW(buf,18) = dstatus->def_ele; - for(i=0;i<9;i++) + for(i=0;i<9;i++) { WBUFB(buf,20+i)= (unsigned char)battle->attr_ratio(i+1,dstatus->def_ele, dstatus->ele_lv); -// The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex] -// WBUFB(buf,20+i)= (unsigned char)((fix=battle->attr_ratio(i+1,dstatus->def_ele, dstatus->ele_lv))<0?0:fix); + // The following caps negative attributes to 0 since the client displays them as 255-fix. [Skotlex] + //WBUFB(buf,20+i)= (unsigned char)((fix=battle->attr_ratio(i+1,dstatus->def_ele, dstatus->ele_lv))<0?0:fix); + } clif->send(buf,packet_len(0x18c),&sd->bl,sd->status.party_id>0?PARTY_SAMEMAP:SELF); } @@ -5507,7 +5512,8 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id c++; } - if( skill_id == AM_PHARMACY ) { // Only send it while Cooking else check for c. + if( skill_id == AM_PHARMACY ) { + // Only send it while Cooking else check for c. WFIFOW(fd,2) = 6 + 2 * c; WFIFOSET(fd,WFIFOW(fd,2)); } @@ -5998,17 +6004,17 @@ void clif_use_card(struct map_session_data *sd,int idx) if(itemdb_isspecial(sd->status.inventory[i].card[0])) //Can't slot it continue; - if(sd->status.inventory[i].identify==0 ) //Not identified + if (sd->status.inventory[i].identify == 0) //Not identified continue; - if((sd->inventory_data[i]->equip&ep)==0) //Not equippable on this part. + if ((sd->inventory_data[i]->equip&ep) == 0) //Not equippable on this part. continue; if(sd->inventory_data[i]->type==IT_WEAPON && ep==EQP_SHIELD) //Shield card won't go on left weapon. continue; ARR_FIND( 0, sd->inventory_data[i]->slot, j, sd->status.inventory[i].card[j] == 0 ); - if( j == sd->inventory_data[i]->slot ) // No room + if (j == sd->inventory_data[i]->slot) // No room continue; if( sd->status.inventory[i].equip > 0 ) // Do not check items that are already equipped @@ -6764,7 +6770,7 @@ void clif_party_message(struct party_data* p, int account_id, const char* mes, i WBUFW(buf,0)=0x109; WBUFW(buf,2)=len+8; WBUFL(buf,4)=account_id; - safestrncpy((char *)WBUFP(buf,8), mes, len); + safestrncpy((char *)WBUFP(buf,8), mes, len); clif->send(buf,len+8,&sd->bl,PARTY); } } @@ -7167,20 +7173,20 @@ void clif_devotion(struct block_list *src, struct map_session_data *tsd) * 01e1 <id>.L <amount>.W (ZC_SPIRITS2) *------------------------------------------*/ void clif_spiritball(struct block_list *bl) { - unsigned char buf[16]; - TBL_PC *sd = BL_CAST(BL_PC,bl); - TBL_HOM *hd = BL_CAST(BL_HOM,bl); + unsigned char buf[16]; + TBL_PC *sd = BL_CAST(BL_PC,bl); + TBL_HOM *hd = BL_CAST(BL_HOM,bl); - nullpo_retv(bl); + nullpo_retv(bl); - WBUFW(buf, 0) = 0x1d0; - WBUFL(buf, 2) = bl->id; + WBUFW(buf, 0) = 0x1d0; + WBUFL(buf, 2) = bl->id; WBUFW(buf, 6) = 0; //init to 0 - switch(bl->type){ - case BL_PC: WBUFW(buf, 6) = sd->spiritball; break; - case BL_HOM: WBUFW(buf, 6) = hd->homunculus.spiritball; break; - } - clif->send(buf, packet_len(0x1d0), bl, AREA); + switch(bl->type){ + case BL_PC: WBUFW(buf, 6) = sd->spiritball; break; + case BL_HOM: WBUFW(buf, 6) = hd->homunculus.spiritball; break; + } + clif->send(buf, packet_len(0x1d0), bl, AREA); } @@ -7448,9 +7454,9 @@ void clif_guild_basicinfo(struct map_session_data *sd) { WFIFOL(fd,18)=g->average_lv; WFIFOL(fd,22)=(uint32)cap_value(g->exp,0,INT32_MAX); WFIFOL(fd,26)=g->next_exp; - WFIFOL(fd,30)=0; // Tax Points - WFIFOL(fd,34)=0; // Honor: (left) Vulgar [-100,100] Famed (right) - WFIFOL(fd,38)=0; // Virtue: (down) Wicked [-100,100] Righteous (up) + WFIFOL(fd,30)=0; // Tax Points + WFIFOL(fd,34)=0; // Honor: (left) Vulgar [-100,100] Famed (right) + WFIFOL(fd,38)=0; // Virtue: (down) Wicked [-100,100] Righteous (up) WFIFOL(fd,42)=g->emblem_id; memcpy(WFIFOP(fd,46),g->name, NAME_LENGTH); memcpy(WFIFOP(fd,70),g->master, NAME_LENGTH); @@ -7525,7 +7531,7 @@ void clif_guild_memberlist(struct map_session_data *sd) WFIFOL(fd,c*104+22)=(int)cap_value(m->exp,0,INT32_MAX); WFIFOL(fd,c*104+26)=m->online; WFIFOL(fd,c*104+30)=m->position; - memset(WFIFOP(fd,c*104+34),0,50); //[Ind] - This is displayed in the 'note' column but being you can't edit it it's sent empty. + memset(WFIFOP(fd,c*104+34),0,50); //[Ind] - This is displayed in the 'note' column but being you can't edit it it's sent empty. memcpy(WFIFOP(fd,c*104+84),m->name,NAME_LENGTH); c++; } @@ -8643,9 +8649,11 @@ void clif_charnameack (int fd, struct block_list *bl) } } break; - case BL_CHAT: //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex] - // memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH); - // break; + case BL_CHAT: +#if 0 //FIXME: Clients DO request this... what should be done about it? The chat's title may not fit... [Skotlex] + memcpy(WBUFP(buf,6), (struct chat*)->title, NAME_LENGTH); + break; +#endif return; case BL_ELEM: memcpy(WBUFP(buf,6), ((TBL_ELEM*)bl)->db->name, NAME_LENGTH); @@ -8954,7 +8962,7 @@ void clif_viewequip_ack(struct map_session_data* sd, struct map_session_data* ts for( i = 0; i < EQI_MAX; i++ ) { if( (k = tsd->equip_index[i]) >= 0 ) { - if (tsd->status.inventory[k].nameid <= 0 || tsd->inventory_data[k] == NULL) // Item doesn't exist + if (tsd->status.inventory[k].nameid <= 0 || tsd->inventory_data[k] == NULL) // Item doesn't exist continue; clif_item_equip(k+2,&viewequip_list.list[equip++],&tsd->status.inventory[k],tsd->inventory_data[k],pc->equippoint(tsd,k)); @@ -9045,8 +9053,8 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, packetlen = RFIFOW(fd,2); // basic structure checks - if( packetlen < 4 + 1 ) - { // 4-byte header and at least an empty string is expected + if (packetlen < 4 + 1) { + // 4-byte header and at least an empty string is expected ShowWarning("clif_process_message: Received malformed packet from player '%s' (no message data)!\n", sd->status.name); return false; } @@ -9085,8 +9093,8 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, name = text; namelen = strnlen(name, NAME_LENGTH-1); // name length (w/o zero byte) - if( name[namelen] != '\0' ) - { // only restriction is that the name must be zero-terminated + if (name[namelen] != '\0') { + // only restriction is that the name must be zero-terminated ShowWarning("clif_process_message: Player '%s' sent an unterminated name!\n", sd->status.name); return false; } @@ -9095,19 +9103,19 @@ bool clif_process_message(struct map_session_data *sd, int format, char **name_, messagelen = textlen - NAME_LENGTH; // this should be the message length (w/ zero byte included) } - if( messagelen != strnlen(message, messagelen)+1 ) - { // the declared length must match real length + if (messagelen != strnlen(message, messagelen)+1) { + // the declared length must match real length ShowWarning("clif_process_message: Received malformed packet from player '%s' (length is incorrect)!\n", sd->status.name); return false; } // verify <message> part of the packet - if( message[messagelen-1] != '\0' ) - { // message must be zero-terminated + if (message[messagelen-1] != '\0') { + // message must be zero-terminated ShowWarning("clif_process_message: Player '%s' sent an unterminated message string!\n", sd->status.name); return false; } - if( messagelen > CHAT_SIZE_MAX-1 ) - { // messages mustn't be too long + if (messagelen > CHAT_SIZE_MAX-1) { + // messages mustn't be too long // Normally you can only enter CHATBOX_SIZE-1 letters into the chat box, but Frost Joke / Dazzler's text can be longer. // Also, the physical size of strings that use multibyte encoding can go multiple times over the chatbox capacity. // Neither the official client nor server place any restriction on the length of the data in the packet, @@ -9407,7 +9415,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->spawn(&sd->pd->bl); clif->send_petdata(sd,sd->pd,0,0); clif->send_petstatus(sd); -// skill->unit_move(&sd->pd->bl,timer->gettick(),1); + //skill->unit_move(&sd->pd->bl,timer->gettick(),1); } } @@ -9800,7 +9808,7 @@ void clif_disconnect_ack(struct map_session_data* sd, short result) /// 0 = quit void clif_parse_QuitGame(int fd, struct map_session_data *sd) { - /* Rovert's prevent logout option fixed [Valaris] */ + /* Rovert's prevent logout option fixed [Valaris] */ if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && !sd->sc.data[SC__INVISIBILITY] && (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) { @@ -9827,7 +9835,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { bl = map->id2bl(id); if( bl == NULL ) - return; // Lagged clients could request names of already gone mobs/players. [Skotlex] + return; // Lagged clients could request names of already gone mobs/players. [Skotlex] if( sd->bl.m != bl->m || !check_distance_bl(&sd->bl, bl, AREA_SIZE) ) return; // Block namerequests past view range @@ -10361,10 +10369,12 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) { pc->respawn(sd,CLR_OUTSIGHT); break; case 0x01: - /* Rovert's Prevent logout option - Fixed [Valaris] */ - if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && !sd->sc.data[SC__INVISIBILITY] && - (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) - { //Send to char-server for character selection. + /* Rovert's Prevent logout option - Fixed [Valaris] */ + if (!sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] + && !sd->sc.data[SC_CLOAKINGEXCEED] && !sd->sc.data[SC__INVISIBILITY] + && (!battle_config.prevent_logout || DIFF_TICK(timer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) + ) { + //Send to char-server for character selection. chrif->charselectreq(sd, session[fd]->client_addr); } else { clif->disconnect_ack(sd, 1); @@ -11553,7 +11563,7 @@ void clif_parse_UseSkillToPos(int fd, struct map_session_data *sd) RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]), //skill num RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[2]), //pos x RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[3]), //pos y - -1 //Skill more info. + -1 //Skill more info. ); } @@ -12232,8 +12242,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) if( sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) ) return; - if( battle_config.min_chat_delay ) - { //[Skotlex] + if (battle_config.min_chat_delay) { if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) return; sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; @@ -12738,11 +12747,11 @@ void clif_parse_PartyBookingAckRecall(int fd, struct map_session_data *sd) /// 08f8 <caller AID>.L <reason>.B /// <reason>: -/// REASON_PROHIBITION = 0x0 -/// REASON_MASTER_IN_PROHIBITION_MAP = 0x1 -/// REASON_REFUSE = 0x2 -/// REASON_NOT_PARTY_MEMBER = 0x3 -/// REASON_ETC = 0x4 +/// REASON_PROHIBITION = 0x0 +/// REASON_MASTER_IN_PROHIBITION_MAP = 0x1 +/// REASON_REFUSE = 0x2 +/// REASON_NOT_PARTY_MEMBER = 0x3 +/// REASON_ETC = 0x4 void clif_PartyBookingFailedRecall(int fd, struct map_session_data *sd) { } @@ -12968,22 +12977,22 @@ void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd) return; switch( RFIFOL(fd,2) ) { - case 0: // Basic Information Guild, hostile alliance information + case 0: // Basic Information Guild, hostile alliance information clif->guild_basicinfo(sd); clif->guild_allianceinfo(sd); break; - case 1: // Members list, list job title + case 1: // Members list, list job title clif->guild_positionnamelist(sd); clif->guild_memberlist(sd); break; - case 2: // List job title, title information list + case 2: // List job title, title information list clif->guild_positionnamelist(sd); clif->guild_positioninfolist(sd); break; - case 3: // Skill list + case 3: // Skill list clif->guild_skillinfo(sd); break; - case 4: // Expulsion list + case 4: // Expulsion list clif->guild_expulsionlist(sd); break; default: @@ -13295,8 +13304,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd) if( sd->sc.data[SC_BERSERK] || (sd->sc.data[SC_DEEP_SLEEP] && sd->sc.data[SC_DEEP_SLEEP]->val2) || (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOCHAT) ) return; - if( battle_config.min_chat_delay ) - { //[Skotlex] + if (battle_config.min_chat_delay) { if (DIFF_TICK(sd->cantalk_tick, timer->gettick()) > 0) return; sd->cantalk_tick = timer->gettick() + battle_config.min_chat_delay; @@ -14276,8 +14284,8 @@ void clif_PVPInfo(struct map_session_data* sd) { WFIFOW(fd,0) = 0x210; WFIFOL(fd,2) = sd->status.char_id; WFIFOL(fd,6) = sd->status.account_id; - WFIFOL(fd,10) = sd->pvp_won; // times won - WFIFOL(fd,14) = sd->pvp_lost; // times lost + WFIFOL(fd,10) = sd->pvp_won; // times won + WFIFOL(fd,14) = sd->pvp_lost; // times lost WFIFOL(fd,18) = sd->pvp_point; WFIFOSET(fd, packet_len(0x210)); } @@ -14335,7 +14343,7 @@ void clif_ranklist(struct map_session_data *sd, enum fame_list_type type) { WFIFOW(fd, 0) = 0x97d; WFIFOW(fd, 2) = type; clif_ranklist_sub(WFIFOP(fd,4), type); - + if( (upperMask == MAPID_BLACKSMITH && type == RANKTYPE_BLACKSMITH) || (upperMask == MAPID_ALCHEMIST && type == RANKTYPE_ALCHEMIST) || (upperMask == MAPID_TAEKWON && type == RANKTYPE_TAEKWON) @@ -14510,9 +14518,10 @@ void clif_parse_FeelSaveOk(int fd,struct map_session_data *sd) sd->feel_map[i].m = sd->bl.m; pc_setglobalreg(sd,script->add_str(pc->sg_info[i].feel_var),sd->feel_map[i].index); -//Are these really needed? Shouldn't they show up automatically from the feel save packet? -// clif_misceffect2(&sd->bl, 0x1b0); -// clif_misceffect2(&sd->bl, 0x21f); +#if 0 // Are these really needed? Shouldn't they show up automatically from the feel save packet? + clif_misceffect2(&sd->bl, 0x1b0); + clif_misceffect2(&sd->bl, 0x21f); +#endif // 0 clif->feel_info(sd, i, 0); clif_menuskill_clear(sd); } @@ -15299,7 +15308,7 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd) !sd->status.inventory[idx].identify || !itemdb_canauction(&sd->status.inventory[idx],pc_get_group_level(sd)) || // Quest Item or something else (sd->status.inventory[idx].bound && !pc_can_give_bound_items(sd)) ) { - clif->auction_setitem(sd->fd, idx, true); + clif->auction_setitem(sd->fd, idx, true); return; } @@ -15410,7 +15419,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd) if( sd->status.inventory[sd->auction.index].bound && !pc_can_give_bound_items(sd) ) { clif->message(sd->fd, msg_txt(293)); clif->auction_message(fd, 2); // The auction has been canceled - return; + return; } safestrncpy(auction.item_name, item->jname, sizeof(auction.item_name)); @@ -15587,7 +15596,7 @@ void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd) { /// For error return codes see enum cashshop_error@clif.h void clif_cashshop_ack(struct map_session_data* sd, int error) { struct npc_data *nd; - int fd = sd->fd; + int fd = sd->fd; int currency[2] = { 0,0 }; if( (nd = map->id2nd(sd->npc_shopid)) && nd->subtype == SCRIPT ) { @@ -15618,34 +15627,33 @@ void clif_cashshop_ack(struct map_session_data* sd, int error) { /// 0288 <packet len>.W <kafra points>.L <count>.W { <amount>.W <name id>.W }.4B*count (PACKETVER >= 20100803) void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) { - int fail = 0; - nullpo_retv(sd); + int fail = 0; + nullpo_retv(sd); - if( sd->state.trading || !sd->npc_shopid || pc_has_permission(sd,PC_PERM_DISABLE_STORE) ) - fail = 1; - else { + if( sd->state.trading || !sd->npc_shopid || pc_has_permission(sd,PC_PERM_DISABLE_STORE) ) + fail = 1; + else { #if PACKETVER < 20101116 - short nameid = RFIFOW(fd,2); - short amount = RFIFOW(fd,4); - int points = RFIFOL(fd,6); + short nameid = RFIFOW(fd,2); + short amount = RFIFOW(fd,4); + int points = RFIFOL(fd,6); - fail = npc->cashshop_buy(sd, nameid, amount, points); + fail = npc->cashshop_buy(sd, nameid, amount, points); #else - int len = RFIFOW(fd,2); - int points = RFIFOL(fd,4); - int count = RFIFOW(fd,8); - unsigned short* item_list = (unsigned short*)RFIFOP(fd,10); - - if( len < 10 || len != 10 + count * 4) - { - ShowWarning("Player %u sent incorrect cash shop buy packet (len %u:%u)!\n", sd->status.char_id, len, 10 + count * 4); - return; - } - fail = npc->cashshop_buylist(sd,points,count,item_list); + int len = RFIFOW(fd,2); + int points = RFIFOL(fd,4); + int count = RFIFOW(fd,8); + unsigned short* item_list = (unsigned short*)RFIFOP(fd,10); + + if( len < 10 || len != 10 + count * 4) { + ShowWarning("Player %u sent incorrect cash shop buy packet (len %u:%u)!\n", sd->status.char_id, len, 10 + count * 4); + return; + } + fail = npc->cashshop_buylist(sd,points,count,item_list); #endif - } + } - clif->cashshop_ack(sd,fail); + clif->cashshop_ack(sd,fail); } @@ -15813,7 +15821,7 @@ void clif_parse_PartyTick(int fd, struct map_session_data* sd) /// 02b1 <packet len>.W <num>.L { <quest id>.L <active>.B }*num void clif_quest_send_list(struct map_session_data *sd) { int fd = sd->fd; - int i; + int i; #if PACKETVER >= 20141022 int info_len = 15; int len = sd->avail_quests*info_len+8; @@ -15822,8 +15830,8 @@ void clif_quest_send_list(struct map_session_data *sd) { #else int info_len = 5; int len = sd->avail_quests*info_len+8; - WFIFOHEAD(fd,len); - WFIFOW(fd, 0) = 0x2b1; + WFIFOHEAD(fd,len); + WFIFOW(fd, 0) = 0x2b1; #endif WFIFOW(fd, 2) = len; WFIFOL(fd, 4) = sd->avail_quests; @@ -16600,8 +16608,8 @@ void clif_parse_ItemListWindowSelected(int fd, struct map_session_data* sd) { case 0: // Change Material skill->changematerial(sd,n,item_list); break; - case 1: // Level 1: Pure to Rough - case 2: // Level 2: Rough to Pure + case 1: // Level 1: Pure to Rough + case 2: // Level 2: Rough to Pure skill->elementalanalysis(sd,n,type,item_list); break; } @@ -17451,8 +17459,8 @@ void clif_charm(struct map_session_data *sd,short type) /// /// R 0908 <index>.w <type>.b /// type: -/// 0 = move item to personal tab -/// 1 = move item to normal tab +/// 0 = move item to personal tab +/// 1 = move item to normal tab void clif_parse_MoveItem(int fd, struct map_session_data *sd) { #if PACKETVER >= 20111122 int index; @@ -17870,7 +17878,7 @@ void clif_bgqueue_update_info(struct map_session_data *sd, unsigned char arena_i safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name)); p.position = position; - sd->bg_queue.client_has_bg_data = true; // Client creates bg data when this packet arrives + sd->bg_queue.client_has_bg_data = true; // Client creates bg data when this packet arrives clif->send(&p,sizeof(p), &sd->bl, SELF); } diff --git a/src/map/clif.h b/src/map/clif.h index a56fbe458..ccaedabcb 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -86,14 +86,14 @@ typedef enum send_target { DUEL, DUEL_WOS, SELF, - + BG, // BattleGround System BG_WOS, BG_SAMEMAP, BG_SAMEMAP_WOS, BG_AREA, BG_AREA_WOS, - + BG_QUEUE, } send_target; @@ -352,16 +352,16 @@ enum clif_messages { * Used to answer CZ_PC_BUY_CASH_POINT_ITEM (clif_parse_cashshop_buy) **/ enum cashshop_error { - ERROR_TYPE_NONE = 0, // The deal has successfully completed. (ERROR_TYPE_NONE) - ERROR_TYPE_NPC, // The Purchase has failed because the NPC does not exist. (ERROR_TYPE_NPC) - ERROR_TYPE_SYSTEM, // The Purchase has failed because the Kafra Shop System is not working correctly. (ERROR_TYPE_SYSTEM) - ERROR_TYPE_INVENTORY_WEIGHT, // You are over your Weight Limit. (ERROR_TYPE_INVENTORY_WEIGHT) - ERROR_TYPE_EXCHANGE, // You cannot purchase items while you are in a trade. (ERROR_TYPE_EXCHANGE) - ERROR_TYPE_ITEM_ID, // The Purchase has failed because the Item Information was incorrect. (ERROR_TYPE_ITEM_ID) - ERROR_TYPE_MONEY, // You do not have enough Kafra Credit Points. (ERROR_TYPE_MONEY) + ERROR_TYPE_NONE = 0, ///< The deal has successfully completed. (ERROR_TYPE_NONE) + ERROR_TYPE_NPC = 1, ///< The Purchase has failed because the NPC does not exist. (ERROR_TYPE_NPC) + ERROR_TYPE_SYSTEM = 2, ///< The Purchase has failed because the Kafra Shop System is not working correctly. (ERROR_TYPE_SYSTEM) + ERROR_TYPE_INVENTORY_WEIGHT = 3, ///< You are over your Weight Limit. (ERROR_TYPE_INVENTORY_WEIGHT) + ERROR_TYPE_EXCHANGE = 4, ///< You cannot purchase items while you are in a trade. (ERROR_TYPE_EXCHANGE) + ERROR_TYPE_ITEM_ID = 5, ///< The Purchase has failed because the Item Information was incorrect. (ERROR_TYPE_ITEM_ID) + ERROR_TYPE_MONEY = 6, ///< You do not have enough Kafra Credit Points. (ERROR_TYPE_MONEY) // Unofficial type names - ERROR_TYPE_QUANTITY, // You can purchase up to 10 items. (ERROR_TYPE_QUANTITY) - ERROR_TYPE_NOT_ALL, // Some items could not be purchased. (ERROR_TYPE_NOT_ALL) + ERROR_TYPE_QUANTITY = 7, ///< You can purchase up to 10 items. (ERROR_TYPE_QUANTITY) + ERROR_TYPE_NOT_ALL = 8, ///< Some items could not be purchased. (ERROR_TYPE_NOT_ALL) }; /** @@ -375,40 +375,40 @@ enum clif_colors { }; enum hChSysChOpt { - hChSys_OPT_BASE = 0x0, - hChSys_OPT_ANNOUNCE_JOIN = 0x1, - hChSys_OPT_MSG_DELAY = 0x2, + hChSys_OPT_BASE = 0x0, + hChSys_OPT_ANNOUNCE_JOIN = 0x1, + hChSys_OPT_MSG_DELAY = 0x2, }; enum hChSysChType { - hChSys_PUBLIC = 0, - hChSys_PRIVATE = 1, - hChSys_MAP = 2, - hChSys_ALLY = 3, - hChSys_IRC = 4, + hChSys_PUBLIC = 0, + hChSys_PRIVATE = 1, + hChSys_MAP = 2, + hChSys_ALLY = 3, + hChSys_IRC = 4, }; enum CASH_SHOP_TABS { - CASHSHOP_TAB_NEW = 0, - CASHSHOP_TAB_POPULAR = 1, - CASHSHOP_TAB_LIMITED = 2, - CASHSHOP_TAB_RENTAL = 3, + CASHSHOP_TAB_NEW = 0, + CASHSHOP_TAB_POPULAR = 1, + CASHSHOP_TAB_LIMITED = 2, + CASHSHOP_TAB_RENTAL = 3, CASHSHOP_TAB_PERPETUITY = 4, - CASHSHOP_TAB_BUFF = 5, - CASHSHOP_TAB_RECOVERY = 6, - CASHSHOP_TAB_ETC = 7, + CASHSHOP_TAB_BUFF = 5, + CASHSHOP_TAB_RECOVERY = 6, + CASHSHOP_TAB_ETC = 7, CASHSHOP_TAB_MAX, }; enum CASH_SHOP_BUY_RESULT { - CSBR_SUCCESS = 0x0, - CSBR_SHORTTAGE_CASH = 0x2, - CSBR_UNKONWN_ITEM = 0x3, - CSBR_INVENTORY_WEIGHT = 0x4, - CSBR_INVENTORY_ITEMCNT = 0x5, - CSBR_RUNE_OVERCOUNT = 0x9, - CSBR_EACHITEM_OVERCOUNT = 0xa, - CSBR_UNKNOWN = 0xb, + CSBR_SUCCESS = 0x0, + CSBR_SHORTTAGE_CASH = 0x2, + CSBR_UNKONWN_ITEM = 0x3, + CSBR_INVENTORY_WEIGHT = 0x4, + CSBR_INVENTORY_ITEMCNT = 0x5, + CSBR_RUNE_OVERCOUNT = 0x9, + CSBR_EACHITEM_OVERCOUNT = 0xa, + CSBR_UNKNOWN = 0xb, }; enum BATTLEGROUNDS_QUEUE_ACK { @@ -587,7 +587,7 @@ struct clif_interface { struct { int *nameid[MAX_ROULETTE_LEVEL];//nameid int *qty[MAX_ROULETTE_LEVEL];//qty of nameid - int items[MAX_ROULETTE_LEVEL];//number of items in the list for each + int items[MAX_ROULETTE_LEVEL];//number of items in the list for each } rd; /* */ unsigned int cryptKey[3]; diff --git a/src/map/duel.h b/src/map/duel.h index e88f6ec4e..5466f3b43 100644 --- a/src/map/duel.h +++ b/src/map/duel.h @@ -37,7 +37,7 @@ struct duel_interface { void (*leave) (const unsigned int did, struct map_session_data* sd); void (*showinfo) (const unsigned int did, struct map_session_data* sd); int (*checktime) (struct map_session_data* sd); - + void (*init) (bool minimal); void (*final) (void); }; diff --git a/src/map/elemental.c b/src/map/elemental.c index b594c8899..50d6c34b3 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -246,7 +246,8 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { } db = &elemental->db[i]; - if( !sd->ed ) { // Initialize it after first summon. + if( !sd->ed ) { + // Initialize it after first summon. sd->ed = ed = (struct elemental_data*)aCalloc(1,sizeof(struct elemental_data)); ed->bl.type = BL_ELEM; ed->bl.id = npc->get_new_npc_id(); @@ -322,8 +323,8 @@ int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id) { case SC_UPHEAVAL_OPTION: case SC_CIRCLE_OF_FIRE_OPTION: case SC_TIDAL_WEAPON_OPTION: - if( bl ) status_change_end(bl,type,INVALID_TIMER); // Master - status_change_end(&ed->bl,type-1,INVALID_TIMER); // Elemental Spirit + if( bl ) status_change_end(bl,type,INVALID_TIMER); // Master + status_change_end(&ed->bl,type-1,INVALID_TIMER); // Elemental Spirit break; case SC_ZEPHYR: if( bl ) status_change_end(bl,type,INVALID_TIMER); @@ -409,7 +410,7 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, int64 tic return 0; if( ed->target_id ) - elemental->unlocktarget(ed); // Remove previous target. + elemental->unlocktarget(ed); // Remove previous target. ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&EL_SKILLMODE_AGGRESSIVE)); if( i == MAX_ELESKILLTREE ) @@ -426,7 +427,7 @@ int elemental_action(struct elemental_data *ed, struct block_list *bl, int64 tic else if( DIFF_TICK(tick, ed->ud.canact_tick) < 0 ) return 0; - ed->target_id = ed->ud.skilltarget = bl->id; // Set new target + ed->target_id = ed->ud.skilltarget = bl->id; // Set new target ed->last_thinktime = tick; // Not in skill range. @@ -504,7 +505,7 @@ int elemental_change_mode_ack(struct elemental_data *ed, int mode) { else if( DIFF_TICK(timer->gettick(), ed->ud.canact_tick) < 0 ) return 0; - ed->target_id = bl->id; // Set new target + ed->target_id = bl->id; // Set new target ed->last_thinktime = timer->gettick(); if( skill->get_inf(skill_id) & INF_GROUND_SKILL ) @@ -512,7 +513,7 @@ int elemental_change_mode_ack(struct elemental_data *ed, int mode) { else unit->skilluse_id(&ed->bl,bl->id,skill_id,skill_lv); - ed->target_id = 0; // Reset target after casting the skill to avoid continuous attack. + ed->target_id = 0; // Reset target after casting the skill to avoid continuous attack. return 1; } @@ -532,9 +533,9 @@ int elemental_change_mode(struct elemental_data *ed, int mode) { ed->battle_status.mode = ed->elemental.mode = mode; // Normalize elemental mode to elemental skill mode. - if( mode == EL_MODE_AGGRESSIVE ) mode = EL_SKILLMODE_AGGRESSIVE; // Aggressive spirit mode -> Aggressive spirit skill. - else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill. - else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill. + if( mode == EL_MODE_AGGRESSIVE ) mode = EL_SKILLMODE_AGGRESSIVE; // Aggressive spirit mode -> Aggressive spirit skill. + else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill. + else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill. // Use a skill immediately after every change mode. if( mode != EL_SKILLMODE_AGGRESSIVE ) @@ -580,7 +581,7 @@ struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 memset(&req,0,sizeof(req)); if( idx == 0 ) // invalid skill id - return req; + return req; if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL ) return req; @@ -660,12 +661,16 @@ int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *s int sp = 5; switch(ed->vd->class_){ - case 2115: case 2118: - case 2121: case 2124: + case 2115: + case 2118: + case 2121: + case 2124: sp = 8; break; - case 2116: case 2119: - case 2122: case 2125: + case 2116: + case 2119: + case 2122: + case 2125: sp = 11; break; } @@ -701,13 +706,15 @@ int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *s mode = status_get_mode(&ed->bl); master_dist = distance_bl(&sd->bl, &ed->bl); - if( master_dist > AREA_SIZE ) { // Master out of vision range. + if( master_dist > AREA_SIZE ) { + // Master out of vision range. elemental->unlocktarget(ed); unit->warp(&ed->bl,sd->bl.m,sd->bl.x,sd->bl.y,CLR_TELEPORT); clif->elemental_updatestatus(sd,SP_HP); clif->elemental_updatestatus(sd,SP_SP); return 0; - } else if( master_dist > MAX_ELEDISTANCE ) { // Master too far, chase. + } else if( master_dist > MAX_ELEDISTANCE ) { + // Master too far, chase. short x = sd->bl.x, y = sd->bl.y; if( ed->target_id ) elemental->unlocktarget(ed); diff --git a/src/map/elemental.h b/src/map/elemental.h index 0c8fff8b3..ca13c30b8 100644 --- a/src/map/elemental.h +++ b/src/map/elemental.h @@ -79,22 +79,22 @@ struct elemental_interface { /* funcs */ bool (*class) (int class_); struct view_data * (*get_viewdata) (int class_); - + int (*create) (struct map_session_data *sd, int class_, unsigned int lifetime); int (*data_received) (struct s_elemental *ele, bool flag); int (*save) (struct elemental_data *ed); - + int (*change_mode_ack) (struct elemental_data *ed, int mode); int (*change_mode) (struct elemental_data *ed, int mode); - + void (*heal) (struct elemental_data *ed, int hp, int sp); int (*dead) (struct elemental_data *ed); - + int (*delete) (struct elemental_data *ed, int reply); void (*summon_stop) (struct elemental_data *ed); - + int (*get_lifetime) (struct elemental_data *ed); - + int (*unlocktarget) (struct elemental_data *ed); int (*skillnotok) (uint16 skill_id, struct elemental_data *ed); int (*set_target) (struct map_session_data *sd, struct block_list *bl); @@ -102,11 +102,11 @@ struct elemental_interface { int (*clean_effect) (struct elemental_data *ed); int (*action) (struct elemental_data *ed, struct block_list *bl, int64 tick); struct skill_condition (*skill_get_requirements) (uint16 skill_id, uint16 skill_lv); - + int (*read_skilldb) (void); void (*reload_db) (void); void (*reload_skilldb) (void); - + int (*search_index) (int class_); void (*summon_init) (struct elemental_data *ed); int (*summon_end_timer) (int tid, int64 tick, int id, intptr_t data); diff --git a/src/map/guild.c b/src/map/guild.c index 1d9cf03a9..e43a5881e 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -63,10 +63,10 @@ int guild_skill_get_max (int id) { // Retrieve skill_lv learned by guild int guild_checkskill(struct guild *g, int id) { - int idx = id - GD_SKILLBASE; - if (idx < 0 || idx >= MAX_GUILDSKILL) - return 0; - return g->skill[idx].lv; + int idx = id - GD_SKILLBASE; + if (idx < 0 || idx >= MAX_GUILDSKILL) + return 0; + return g->skill[idx].lv; } /*========================================== @@ -236,17 +236,17 @@ void guild_makemember(struct guild_member *m,struct map_session_data *sd) nullpo_retv(sd); memset(m,0,sizeof(struct guild_member)); - m->account_id =sd->status.account_id; - m->char_id =sd->status.char_id; - m->hair =sd->status.hair; - m->hair_color =sd->status.hair_color; - m->gender =sd->status.sex; - m->class_ =sd->status.class_; - m->lv =sd->status.base_level; -// m->exp =0; -// m->exp_payper =0; - m->online =1; - m->position =MAX_GUILDPOSITION-1; + m->account_id = sd->status.account_id; + m->char_id = sd->status.char_id; + m->hair = sd->status.hair; + m->hair_color = sd->status.hair_color; + m->gender = sd->status.sex; + m->class_ = sd->status.class_; + m->lv = sd->status.base_level; + //m->exp = 0; + //m->exp_payper = 0; + m->online = 1; + m->position = MAX_GUILDPOSITION-1; memcpy(m->name,sd->status.name,NAME_LENGTH); return; } @@ -366,14 +366,14 @@ int guild_created(int account_id,int guild_id) { if(sd==NULL) return 0; if(!guild_id) { - clif->guild_created(sd, 2); // Creation failure (presence of the same name Guild) + clif->guild_created(sd, 2); // Creation failure (presence of the same name Guild) return 0; } //struct guild *g; sd->status.guild_id=guild_id; clif->guild_created(sd,0); if(battle_config.guild_emperium_check) - pc->delitem(sd,pc->search_inventory(sd,ITEMID_EMPERIUM),1,0,0,LOG_TYPE_CONSUME); //emperium consumption + pc->delitem(sd,pc->search_inventory(sd,ITEMID_EMPERIUM),1,0,0,LOG_TYPE_CONSUME); //emperium consumption return 0; } @@ -567,32 +567,32 @@ int guild_recv_info(struct guild *sg) { bm++; } - for (i = 0; i < g->max_member; i++) { //Transmission of information at all members + for (i = 0; i < g->max_member; i++) { //Transmission of information at all members sd = g->member[i].sd; if( sd==NULL ) continue; sd->guild = g; - if (before.guild_lv != g->guild_lv || bm != m || - before.max_member != g->max_member) { - clif->guild_basicinfo(sd); //Submit basic information - clif->guild_emblem(sd, g); //Submit emblem - } + if (before.guild_lv != g->guild_lv || bm != m + || before.max_member != g->max_member) { + clif->guild_basicinfo(sd); //Submit basic information + clif->guild_emblem(sd, g); //Submit emblem + } - if (bm != m) { //Send members information - clif->guild_memberlist(g->member[i].sd); - } + if (bm != m) { //Send members information + clif->guild_memberlist(g->member[i].sd); + } - if (before.skill_point != g->skill_point) - clif->guild_skillinfo(sd); //Submit information skills + if (before.skill_point != g->skill_point) + clif->guild_skillinfo(sd); //Submit information skills if (guild_new) { // Send information and affiliation if unsent - clif->guild_belonginfo(sd, g); - //clif->guild_notice(sd, g); Is already sent in clif_parse_LoadEndAck - sd->guild_emblem_id = g->emblem_id; - } - } + clif->guild_belonginfo(sd, g); + //clif->guild_notice(sd, g); Is already sent in clif_parse_LoadEndAck + sd->guild_emblem_id = g->emblem_id; + } + } - //Occurrence of an event + //Occurrence of an event if (guild->infoevent_db->remove(guild->infoevent_db, DB->i2key(sg->guild_id), &data)) { struct eventlist *ev = DB->data2ptr(&data), *ev2; while(ev) { @@ -610,8 +610,8 @@ int guild_recv_info(struct guild *sg) { * Player sd send a guild invatation to player tsd to join his guild *--------------------------------------------*/ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { - struct guild *g; - int i; + struct guild *g; + int i; nullpo_ret(sd); @@ -624,7 +624,7 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { return 0; //Invite permission. if(!battle_config.invite_request_check) { - if (tsd->party_invite > 0 || tsd->trade_partner || tsd->adopt_invite) { //checking if there no other invitation pending + if (tsd->party_invite > 0 || tsd->trade_partner || tsd->adopt_invite) { //checking if there no other invitation pending clif->guild_inviteack(sd,0); return 0; } @@ -635,8 +635,8 @@ int guild_invite(struct map_session_data *sd, struct map_session_data *tsd) { return 0; } - if( tsd->status.guild_id > 0 - || tsd->guild_invite > 0 + if( tsd->status.guild_id > 0 + || tsd->guild_invite > 0 || ( (map->agit_flag || map->agit2_flag) && map->list[tsd->bl.m].flag.gvg_castle && !battle_config.guild_castle_invite @@ -730,7 +730,8 @@ void guild_member_joined(struct map_session_data *sd) guild->request_info(sd->status.guild_id); return; } - if (strcmp(sd->status.name,g->master) == 0) { // set the Guild Master flag + if (strcmp(sd->status.name,g->master) == 0) { + // set the Guild Master flag sd->state.gmaster_flag = 1; // prevent Guild Skills from being used directly after relog if( battle_config.guild_skill_relog_delay ) @@ -823,8 +824,8 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c return 0; if( sd->status.account_id != account_id - || sd->status.char_id != char_id - || sd->status.guild_id != guild_id + || sd->status.char_id != char_id + || sd->status.guild_id != guild_id // Can't leave inside castles || ((map->agit_flag || map->agit2_flag) && map->list[sd->bl.m].flag.gvg_castle @@ -855,11 +856,11 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i return 0; if( (ps=guild->getposition(g,sd))<0 || !(g->position[ps].mode&0x0010) ) - return 0; //Expulsion permission + return 0; //Expulsion permission //Can't leave inside guild castles. - if ((tsd = map->id2sd(account_id)) - && tsd->status.char_id == char_id + if ((tsd = map->id2sd(account_id)) + && tsd->status.char_id == char_id && ((map->agit_flag || map->agit2_flag) && map->list[sd->bl.m].flag.gvg_castle && !battle_config.guild_castle_expulsion) @@ -976,8 +977,8 @@ int guild_send_memberinfoshort(struct map_session_data *sd,int online) return 0; } - if(sd->state.connect_new) - { //Note that this works because it is invoked in parse_LoadEndAck before connect_new is cleared. + if (sd->state.connect_new) { + //Note that this works because it is invoked in parse_LoadEndAck before connect_new is cleared. clif->guild_belonginfo(sd,g); sd->guild_emblem_id = g->emblem_id; } @@ -1392,8 +1393,8 @@ void guild_guildaura_refresh(struct map_session_data *sd, uint16 skill_id, uint1 /*==================================================== * Count number of relations the guild has. * Flag: - * 0 = allied - * 1 = enemy + * 0 = allied + * 1 = enemy *---------------------------------------------------*/ int guild_get_alliance_count(struct guild *g,int flag) { @@ -1401,9 +1402,8 @@ int guild_get_alliance_count(struct guild *g,int flag) nullpo_ret(g); - for(i=c=0;i<MAX_GUILDALLIANCE;i++){ - if( g->alliance[i].guild_id>0 && - g->alliance[i].opposition==flag ) + for(i=c=0;i<MAX_GUILDALLIANCE;i++) { + if(g->alliance[i].guild_id>0 && g->alliance[i].opposition==flag) c++; } return c; @@ -1421,8 +1421,8 @@ void guild_block_skill(struct map_session_data *sd, int time) /*==================================================== * Check relation between guild_id1 and guild_id2. * Flag: - * 0 = allied - * 1 = enemy + * 0 = allied + * 1 = enemy * Returns true if yes. *---------------------------------------------------*/ int guild_check_alliance(int guild_id1, int guild_id2, int flag) @@ -1467,7 +1467,7 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) if(sd->status.guild_id == tsd->status.guild_id) return 0; - if( guild->get_alliance_count(g[0],0) >= battle_config.max_guild_alliance ) { + if( guild->get_alliance_count(g[0],0) >= battle_config.max_guild_alliance ) { clif->guild_allianceack(sd,4); return 0; } @@ -1481,9 +1481,8 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) return 0; } - for (i = 0; i < MAX_GUILDALLIANCE; i++) { // check if already allied - if( g[0]->alliance[i].guild_id==tsd->status.guild_id && - g[0]->alliance[i].opposition==0){ + for (i = 0; i < MAX_GUILDALLIANCE; i++) { // check if already allied + if(g[0]->alliance[i].guild_id==tsd->status.guild_id && g[0]->alliance[i].opposition==0) { clif->guild_allianceack(sd,0); return 0; } @@ -1509,13 +1508,13 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) return 0; } - if (sd->guild_alliance != tsd->status.guild_id) // proposed guild_id alliance doesn't match tsd guildid + if (sd->guild_alliance != tsd->status.guild_id) // proposed guild_id alliance doesn't match tsd guildid return 0; - if (flag == 1) { // consent + if (flag == 1) { // consent int i; - struct guild *g, *tg; // Reconfirm the number of alliance + struct guild *g, *tg; // Reconfirm the number of alliance g=sd->guild; tg=tsd->guild; @@ -1543,11 +1542,11 @@ int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) tsd->status.account_id,sd->status.account_id,9 ); } - // inform other servers + // inform other servers intif->guild_alliance( sd->status.guild_id,tsd->status.guild_id, sd->status.account_id,tsd->status.account_id,0 ); return 0; - } else { // deny + } else { // deny sd->guild_alliance=0; sd->guild_alliance_account=0; if(tsd!=NULL) @@ -1590,7 +1589,7 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd) if(sd->status.guild_id == tsd->status.guild_id) return 0; - if( guild->get_alliance_count(g,1) >= battle_config.max_guild_alliance ) { + if( guild->get_alliance_count(g,1) >= battle_config.max_guild_alliance ) { clif->guild_oppositionack(sd,1); return 0; } @@ -1711,7 +1710,8 @@ int guild_broken_sub(DBKey key, DBData *data, va_list ap) nullpo_ret(g); - for(i=0;i<MAX_GUILDALLIANCE;i++){ // Destroy all relationships + for(i=0;i<MAX_GUILDALLIANCE;i++) { + // Destroy all relationships if(g->alliance[i].guild_id==guild_id){ for(j=0;j<g->max_member;j++) if( (sd=g->member[j].sd)!=NULL ) @@ -1757,7 +1757,8 @@ int guild_broken(int guild_id,int flag) if(flag!=0 || g==NULL) return 0; - for(i=0;i<g->max_member;i++){ // Destroy all relationships + for(i=0;i<g->max_member;i++){ + // Destroy all relationships if((sd=g->member[i].sd)!=NULL){ if(sd->state.storage_flag == 2) gstorage->pc_quit(sd,1); @@ -1886,11 +1887,13 @@ int guild_break(struct map_session_data *sd,char *name) { return 0; if(!sd->state.gmaster_flag) return 0; - for(i=0;i<g->max_member;i++){ - if( g->member[i].account_id>0 && ( - g->member[i].account_id!=sd->status.account_id || - g->member[i].char_id!=sd->status.char_id )) + for (i = 0; i < g->max_member; i++) { + if (g->member[i].account_id > 0 + && (g->member[i].account_id!=sd->status.account_id + || g->member[i].char_id!=sd->status.char_id + )) { break; + } } if(i<g->max_member){ clif->guild_broken(sd,2); @@ -2094,7 +2097,8 @@ int guild_castledataloadack(int len, struct guild_castle *gc) * Start normal woe and triggers all npc OnAgitStart *---------------------------------------------------*/ void guild_agit_start(void) -{ // Run All NPC_Event[OnAgitStart] +{ + // Run All NPC_Event[OnAgitStart] int c = npc->event_doall("OnAgitStart"); ShowStatus("NPC_Event:[OnAgitStart] Run (%d) Events by @AgitStart.\n",c); } @@ -2103,7 +2107,8 @@ void guild_agit_start(void) * End normal woe and triggers all npc OnAgitEnd *---------------------------------------------------*/ void guild_agit_end(void) -{ // Run All NPC_Event[OnAgitEnd] +{ + // Run All NPC_Event[OnAgitEnd] int c = npc->event_doall("OnAgitEnd"); ShowStatus("NPC_Event:[OnAgitEnd] Run (%d) Events by @AgitEnd.\n",c); } @@ -2112,7 +2117,8 @@ void guild_agit_end(void) * Start woe2 and triggers all npc OnAgitStart2 *---------------------------------------------------*/ void guild_agit2_start(void) -{ // Run All NPC_Event[OnAgitStart2] +{ + // Run All NPC_Event[OnAgitStart2] int c = npc->event_doall("OnAgitStart2"); ShowStatus("NPC_Event:[OnAgitStart2] Run (%d) Events by @AgitStart2.\n",c); } @@ -2121,7 +2127,8 @@ void guild_agit2_start(void) * End woe2 and triggers all npc OnAgitEnd2 *---------------------------------------------------*/ void guild_agit2_end(void) -{ // Run All NPC_Event[OnAgitEnd2] +{ + // Run All NPC_Event[OnAgitEnd2] int c = npc->event_doall("OnAgitEnd2"); ShowStatus("NPC_Event:[OnAgitEnd2] Run (%d) Events by @AgitEnd2.\n",c); } diff --git a/src/map/guild.h b/src/map/guild.h index 126325eef..eb6de7070 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -13,8 +13,8 @@ /** * Defines **/ -#define GUILD_SEND_XY_INVERVAL 5000 // Interval of sending coordinates and HP -#define GUILD_PAYEXP_INVERVAL 10000 //Interval (maximum survival time of the cache, in milliseconds) +#define GUILD_SEND_XY_INVERVAL 5000 // Interval of sending coordinates and HP +#define GUILD_PAYEXP_INVERVAL 10000 //Interval (maximum survival time of the cache, in milliseconds) #define MAX_GUILD_SKILL_REQUIRE 5 /** diff --git a/src/map/homunculus.c b/src/map/homunculus.c index f4ffc62a6..e45f654ff 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -78,39 +78,39 @@ enum homun_type homunculus_class2type(int class_) { } void homunculus_addspiritball(struct homun_data *hd, int max) { - nullpo_retv(hd); + nullpo_retv(hd); - if (max > MAX_SKILL_LEVEL) - max = MAX_SKILL_LEVEL; - if (hd->homunculus.spiritball < 0) - hd->homunculus.spiritball = 0; + if (max > MAX_SKILL_LEVEL) + max = MAX_SKILL_LEVEL; + if (hd->homunculus.spiritball < 0) + hd->homunculus.spiritball = 0; - if (hd->homunculus.spiritball && hd->homunculus.spiritball >= max) { - hd->homunculus.spiritball = max; - } - else - hd->homunculus.spiritball++; + if (hd->homunculus.spiritball && hd->homunculus.spiritball >= max) { + hd->homunculus.spiritball = max; + } + else + hd->homunculus.spiritball++; - clif->spiritball(&hd->bl); + clif->spiritball(&hd->bl); } void homunculus_delspiritball(struct homun_data *hd, int count, int type) { - nullpo_retv(hd); - - if (hd->homunculus.spiritball <= 0) { - hd->homunculus.spiritball = 0; - return; - } - if (count <= 0) - return; - if (count > MAX_SKILL_LEVEL) - count = MAX_SKILL_LEVEL; - if (count > hd->homunculus.spiritball) - count = hd->homunculus.spiritball; - - hd->homunculus.spiritball -= count; - if (!type) - clif->spiritball(&hd->bl); + nullpo_retv(hd); + + if (hd->homunculus.spiritball <= 0) { + hd->homunculus.spiritball = 0; + return; + } + if (count <= 0) + return; + if (count > MAX_SKILL_LEVEL) + count = MAX_SKILL_LEVEL; + if (count > hd->homunculus.spiritball) + count = hd->homunculus.spiritball; + + hd->homunculus.spiritball -= count; + if (!type) + clif->spiritball(&hd->bl); } void homunculus_damaged(struct homun_data *hd) { @@ -313,7 +313,7 @@ bool homunculus_levelup(struct homun_data *hd) { hom = &hd->homunculus; hom->level++ ; if (!(hom->level % 3)) - hom->skillpts++; //1 skillpoint each 3 base level + hom->skillpts++; //1 skillpoint each 3 base level hom->exp -= hd->exp_next; hd->exp_next = homun->exptable[hom->level - 1]; @@ -500,7 +500,7 @@ int homunculus_gainexp(struct homun_data *hd,unsigned int exp) { return 0; } - //levelup + //levelup while( hd->homunculus.exp > hd->exp_next && homun->levelup(hd) ); if( hd->exp_next == 0 ) @@ -601,7 +601,7 @@ bool homunculus_feed(struct map_session_data *sd, struct homun_data *hd) { emotion = E_HO; } - hd->homunculus.hunger += 10; //dunno increase value for each food + hd->homunculus.hunger += 10; //dunno increase value for each food if(hd->homunculus.hunger > 100) hd->homunculus.hunger = 100; @@ -912,7 +912,7 @@ bool homunculus_ressurect(struct map_session_data* sd, unsigned char per, short hd = sd->hd; - if (hd->homunculus.vaporize != HOM_ST_ACTIVE) + if (hd->homunculus.vaporize != HOM_ST_ACTIVE) return false; // vaporized homunculi need to be 'called' if (!status->isdead(&hd->bl)) @@ -1151,7 +1151,7 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) { int minJobLevelPresent = 0; if( columns == 15 ) - minJobLevelPresent = 1; // MinJobLvl has been added - FIXME: is this extra field even needed anymore? + minJobLevelPresent = 1; // MinJobLvl has been added - FIXME: is this extra field even needed anymore? // check for bounds [celest] classid = atoi(split[0]) - HM_CLASS_BASE; diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 25ccabf48..263922e4e 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -65,7 +65,7 @@ struct homun_data { int hungry_timer; //[orn] unsigned int exp_next; char blockskill[MAX_SKILL]; // [orn] - + int64 masterteleport_timer; }; diff --git a/src/map/instance.c b/src/map/instance.c index 5789d7dd6..4140973b1 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -273,7 +273,7 @@ int instance_add_map(const char *name, int instance_id, bool usebasename, const * type : result (0 = map id | 1 = instance id) *--------------------------------------*/ int instance_map2imap(int16 m, int instance_id) { - int i; + int i; if( !instance->valid(instance_id) ) { return -1; @@ -282,12 +282,12 @@ int instance_map2imap(int16 m, int instance_id) { for( i = 0; i < instance->list[instance_id].num_map; i++ ) { if( instance->list[instance_id].map[i] && map->list[instance->list[instance_id].map[i]].instance_src_map == m ) return instance->list[instance_id].map[i]; - } - return -1; + } + return -1; } int instance_mapname2imap(const char *map_name, int instance_id) { - int i; + int i; if( !instance->valid(instance_id) ) { return -1; @@ -296,8 +296,8 @@ int instance_mapname2imap(const char *map_name, int instance_id) { for( i = 0; i < instance->list[instance_id].num_map; i++ ) { if( instance->list[instance_id].map[i] && !strcmpi(map->list[map->list[instance->list[instance_id].map[i]].instance_src_map].name,map_name) ) return instance->list[instance_id].map[i]; - } - return -1; + } + return -1; } diff --git a/src/map/instance.h b/src/map/instance.h index 2ee77d3e3..4848c9c59 100644 --- a/src/map/instance.h +++ b/src/map/instance.h @@ -41,17 +41,17 @@ struct instance_data { unsigned short users; struct reg_db regs; ///< Instance variables for scripts - + int progress_timer; unsigned int progress_timeout; int idle_timer; unsigned int idle_timeout, idle_timeoutval; - + unsigned int original_progress_timeout; - + struct point respawn; ///< reload spawn - + /** HPM Custom Struct */ struct HPluginData **hdata; unsigned int hdatac; diff --git a/src/map/intif.c b/src/map/intif.c index c20905bcf..73fb648ae 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -210,8 +210,8 @@ int intif_wis_message(struct map_session_data *sd, char *nick, char *mes, size_t if (intif->CheckForCharServer()) return 0; - if (chrif->other_mapserver_count < 1) - { //Character not found. + if (chrif->other_mapserver_count < 1) { + //Character not found. clif->wis_end(sd->fd, 1); return 0; } @@ -924,8 +924,8 @@ void intif_parse_WisMessage(int fd) { strcmp(sd->ignore[i].name, wisp_source) != 0 ; i++); - if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0') - { //Ignored + if (i < MAX_IGNORE_LIST && sd->ignore[i].name[0] != '\0') { + //Ignored intif_wis_replay(id, 2); return; } @@ -1113,7 +1113,7 @@ void intif_parse_LoadGuildStorage(int fd) } if (RFIFOW(fd,2)-13 != sizeof(struct guild_storage)) { ShowError("intif_parse_LoadGuildStorage: data size mismatch %d != %"PRIuS"\n", RFIFOW(fd,2)-13, sizeof(struct guild_storage)); - gstor->storage_status = 0; + gstor->storage_status = 0; return; } @@ -2136,7 +2136,7 @@ void intif_request_accinfo( int u_fd, int aid, int group_lv, char* query ) { WFIFOL(inter_fd,2) = u_fd; WFIFOL(inter_fd,6) = aid; WFIFOL(inter_fd,10) = group_lv; - safestrncpy((char *)WFIFOP(inter_fd,14), query, NAME_LENGTH); + safestrncpy((char *)WFIFOP(inter_fd,14), query, NAME_LENGTH); WFIFOSET(inter_fd,2 + 4 + 4 + 4 + NAME_LENGTH); @@ -2196,12 +2196,13 @@ int intif_parse(int fd) { int packet_len, cmd; cmd = RFIFOW(fd,0); - // Verify ID of the packet - if(cmd<0x3800 || cmd>=0x3800+(sizeof(intif->packet_len_table)/sizeof(intif->packet_len_table[0])) || - intif->packet_len_table[cmd-0x3800]==0){ - return 0; + // Verify ID of the packet + if (cmd < 0x3800 || cmd >= 0x3800+(sizeof(intif->packet_len_table)/sizeof(intif->packet_len_table[0])) + || intif->packet_len_table[cmd-0x3800] == 0 + ) { + return 0; } - // Check the length of the packet + // Check the length of the packet packet_len = intif->packet_len_table[cmd-0x3800]; if(packet_len==-1){ if(RFIFOREST(fd)<4) @@ -2211,7 +2212,7 @@ int intif_parse(int fd) if((int)RFIFOREST(fd)<packet_len){ return 2; } - // Processing branch + // Processing branch switch(cmd){ case 0x3800: if (RFIFOL(fd,4) == 0xFF000000) //Normal announce. @@ -2219,57 +2220,57 @@ int intif_parse(int fd) else //Color announce. clif->broadcast2(NULL, (char *) RFIFOP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT); break; - case 0x3801: intif->pWisMessage(fd); break; - case 0x3802: intif->pWisEnd(fd); break; - case 0x3803: intif->pWisToGM(fd); break; - case 0x3804: intif->pRegisters(fd); break; - case 0x3806: intif->pChangeNameOk(fd); break; - case 0x3807: intif->pMessageToFD(fd); break; - case 0x3818: intif->pLoadGuildStorage(fd); break; - case 0x3819: intif->pSaveGuildStorage(fd); break; - case 0x3820: intif->pPartyCreated(fd); break; - case 0x3821: intif->pPartyInfo(fd); break; - case 0x3822: intif->pPartyMemberAdded(fd); break; - case 0x3823: intif->pPartyOptionChanged(fd); break; - case 0x3824: intif->pPartyMemberWithdraw(fd); break; - case 0x3825: intif->pPartyMove(fd); break; - case 0x3826: intif->pPartyBroken(fd); break; - case 0x3827: intif->pPartyMessage(fd); break; - case 0x3830: intif->pGuildCreated(fd); break; - case 0x3831: intif->pGuildInfo(fd); break; - case 0x3832: intif->pGuildMemberAdded(fd); break; - case 0x3834: intif->pGuildMemberWithdraw(fd); break; - case 0x3835: intif->pGuildMemberInfoShort(fd); break; - case 0x3836: intif->pGuildBroken(fd); break; - case 0x3837: intif->pGuildMessage(fd); break; - case 0x3839: intif->pGuildBasicInfoChanged(fd); break; - case 0x383a: intif->pGuildMemberInfoChanged(fd); break; - case 0x383b: intif->pGuildPosition(fd); break; - case 0x383c: intif->pGuildSkillUp(fd); break; - case 0x383d: intif->pGuildAlliance(fd); break; - case 0x383e: intif->pGuildNotice(fd); break; - case 0x383f: intif->pGuildEmblem(fd); break; - case 0x3840: intif->pGuildCastleDataLoad(fd); break; - case 0x3843: intif->pGuildMasterChanged(fd); break; + case 0x3801: intif->pWisMessage(fd); break; + case 0x3802: intif->pWisEnd(fd); break; + case 0x3803: intif->pWisToGM(fd); break; + case 0x3804: intif->pRegisters(fd); break; + case 0x3806: intif->pChangeNameOk(fd); break; + case 0x3807: intif->pMessageToFD(fd); break; + case 0x3818: intif->pLoadGuildStorage(fd); break; + case 0x3819: intif->pSaveGuildStorage(fd); break; + case 0x3820: intif->pPartyCreated(fd); break; + case 0x3821: intif->pPartyInfo(fd); break; + case 0x3822: intif->pPartyMemberAdded(fd); break; + case 0x3823: intif->pPartyOptionChanged(fd); break; + case 0x3824: intif->pPartyMemberWithdraw(fd); break; + case 0x3825: intif->pPartyMove(fd); break; + case 0x3826: intif->pPartyBroken(fd); break; + case 0x3827: intif->pPartyMessage(fd); break; + case 0x3830: intif->pGuildCreated(fd); break; + case 0x3831: intif->pGuildInfo(fd); break; + case 0x3832: intif->pGuildMemberAdded(fd); break; + case 0x3834: intif->pGuildMemberWithdraw(fd); break; + case 0x3835: intif->pGuildMemberInfoShort(fd); break; + case 0x3836: intif->pGuildBroken(fd); break; + case 0x3837: intif->pGuildMessage(fd); break; + case 0x3839: intif->pGuildBasicInfoChanged(fd); break; + case 0x383a: intif->pGuildMemberInfoChanged(fd); break; + case 0x383b: intif->pGuildPosition(fd); break; + case 0x383c: intif->pGuildSkillUp(fd); break; + case 0x383d: intif->pGuildAlliance(fd); break; + case 0x383e: intif->pGuildNotice(fd); break; + case 0x383f: intif->pGuildEmblem(fd); break; + case 0x3840: intif->pGuildCastleDataLoad(fd); break; + case 0x3843: intif->pGuildMasterChanged(fd); break; //Quest system - case 0x3860: intif->pQuestLog(fd); break; - case 0x3861: intif->pQuestSave(fd); break; + case 0x3860: intif->pQuestLog(fd); break; + case 0x3861: intif->pQuestSave(fd); break; // Mail System - case 0x3848: intif->pMailInboxReceived(fd); break; - case 0x3849: intif->pMailNew(fd); break; - case 0x384a: intif->pMailGetAttach(fd); break; - case 0x384b: intif->pMailDelete(fd); break; - case 0x384c: intif->pMailReturn(fd); break; - case 0x384d: intif->pMailSend(fd); break; + case 0x3848: intif->pMailInboxReceived(fd); break; + case 0x3849: intif->pMailNew(fd); break; + case 0x384a: intif->pMailGetAttach(fd); break; + case 0x384b: intif->pMailDelete(fd); break; + case 0x384c: intif->pMailReturn(fd); break; + case 0x384d: intif->pMailSend(fd); break; // Auction System - case 0x3850: intif->pAuctionResults(fd); break; - case 0x3851: intif->pAuctionRegister(fd); break; - case 0x3852: intif->pAuctionCancel(fd); break; - case 0x3853: intif->pAuctionClose(fd); break; - case 0x3854: intif->pAuctionMessage(fd); break; - case 0x3855: intif->pAuctionBid(fd); break; + case 0x3850: intif->pAuctionResults(fd); break; + case 0x3851: intif->pAuctionRegister(fd); break; + case 0x3852: intif->pAuctionCancel(fd); break; + case 0x3853: intif->pAuctionClose(fd); break; + case 0x3854: intif->pAuctionMessage(fd); break; + case 0x3855: intif->pAuctionBid(fd); break; //Bound items case 0x3856: #ifdef GP_BOUND_ITEMS @@ -2279,27 +2280,27 @@ int intif_parse(int fd) #endif break; // Mercenary System - case 0x3870: intif->pMercenaryReceived(fd); break; - case 0x3871: intif->pMercenaryDeleted(fd); break; - case 0x3872: intif->pMercenarySaved(fd); break; + case 0x3870: intif->pMercenaryReceived(fd); break; + case 0x3871: intif->pMercenaryDeleted(fd); break; + case 0x3872: intif->pMercenarySaved(fd); break; // Elemental System - case 0x387c: intif->pElementalReceived(fd); break; - case 0x387d: intif->pElementalDeleted(fd); break; - case 0x387e: intif->pElementalSaved(fd); break; + case 0x387c: intif->pElementalReceived(fd); break; + case 0x387d: intif->pElementalDeleted(fd); break; + case 0x387e: intif->pElementalSaved(fd); break; - case 0x3880: intif->pCreatePet(fd); break; - case 0x3881: intif->pRecvPetData(fd); break; - case 0x3882: intif->pSavePetOk(fd); break; - case 0x3883: intif->pDeletePetOk(fd); break; - case 0x3890: intif->pCreateHomunculus(fd); break; - case 0x3891: intif->pRecvHomunculusData(fd); break; - case 0x3892: intif->pSaveHomunculusOk(fd); break; - case 0x3893: intif->pDeleteHomunculusOk(fd); break; + case 0x3880: intif->pCreatePet(fd); break; + case 0x3881: intif->pRecvPetData(fd); break; + case 0x3882: intif->pSavePetOk(fd); break; + case 0x3883: intif->pDeletePetOk(fd); break; + case 0x3890: intif->pCreateHomunculus(fd); break; + case 0x3891: intif->pRecvHomunculusData(fd); break; + case 0x3892: intif->pSaveHomunculusOk(fd); break; + case 0x3893: intif->pDeleteHomunculusOk(fd); break; default: ShowError("intif_parse : unknown packet %d %x\n",fd,RFIFOW(fd,0)); return 0; } - // Skip packet + // Skip packet RFIFOSKIP(fd,packet_len); return 1; } diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c index 6f016697f..8a510b969 100644 --- a/src/map/irc-bot.c +++ b/src/map/irc-bot.c @@ -122,7 +122,7 @@ int irc_parse(int fd) { ircbot->fails = 0; ircbot->ip = host2ip(hChSys.irc_server); timer->add(timer->gettick() + 120000, ircbot->connect_timer, 0, 0); - return 0; + return 0; } if( !RFIFOREST(fd) ) diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 41e0a5348..67aab7a18 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -320,8 +320,8 @@ void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask) int i; bclass[0]= bclass[1]= bclass[2]= 0; //Base classes - if (jobmask & 1<<JOB_NOVICE) - { //Both Novice/Super-Novice are counted with the same ID + if (jobmask & 1<<JOB_NOVICE) { + //Both Novice/Super-Novice are counted with the same ID bclass[0] |= 1<<MAPID_NOVICE; bclass[1] |= 1<<MAPID_NOVICE; } @@ -354,9 +354,10 @@ void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask) bclass[2] |= 1<<MAPID_MERCHANT; if (jobmask & 1<<JOB_BARD) bclass[2] |= 1<<MAPID_ARCHER; -// Bard/Dancer share the same slot now. -// if (jobmask & 1<<JOB_DANCER) -// bclass[2] |= 1<<MAPID_ARCHER; +#if 0 // Bard/Dancer share the same slot now. + if (jobmask & 1<<JOB_DANCER) + bclass[2] |= 1<<MAPID_ARCHER; +#endif // 0 if (jobmask & 1<<JOB_ROGUE) bclass[2] |= 1<<MAPID_THIEF; //Special classes that don't fit above. @@ -487,16 +488,16 @@ int itemdb_isequip2(struct item_data *data) { *------------------------------------------*/ int itemdb_isstackable(int nameid) { - int type=itemdb_type(nameid); - switch(type) { - case IT_WEAPON: - case IT_ARMOR: - case IT_PETEGG: - case IT_PETARMOR: - return 0; - default: - return 1; - } + int type=itemdb_type(nameid); + switch(type) { + case IT_WEAPON: + case IT_ARMOR: + case IT_PETEGG: + case IT_PETARMOR: + return 0; + default: + return 1; + } } /*========================================== @@ -504,16 +505,16 @@ int itemdb_isstackable(int nameid) *------------------------------------------*/ int itemdb_isstackable2(struct item_data *data) { - nullpo_ret(data); - switch(data->type) { - case IT_WEAPON: - case IT_ARMOR: - case IT_PETEGG: - case IT_PETARMOR: - return 0; - default: - return 1; - } + nullpo_ret(data); + switch(data->type) { + case IT_WEAPON: + case IT_ARMOR: + case IT_PETEGG: + case IT_PETARMOR: + return 0; + default: + return 1; + } } @@ -576,7 +577,7 @@ int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(stru } /*========================================== - * Specifies if item-type should drop unidentified. + * Specifies if item-type should drop unidentified. *------------------------------------------*/ int itemdb_isidentified(int nameid) { int type=itemdb_type(nameid); diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 8d8cfd7c2..a1c4d1053 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -374,7 +374,7 @@ enum ItemNouseRestrictions { struct item_data { uint16 nameid; char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH]; - + //Do not add stuff between value_buy and view_id (see how getiteminfo works) int value_buy; int value_sell; @@ -396,21 +396,21 @@ struct item_data { int delay; //Lupus: I rearranged order of these fields due to compatibility with ITEMINFO script command -// some script commands should be revised as well... - unsigned int class_base[3]; //Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2) - unsigned class_upper : 6; //Specifies if the upper-type can equip it (bitfield, 0x01: normal, 0x02: upper, 0x04: baby normal, 0x08: third normal, 0x10: third upper, 0x20: third baby) +// some script commands should be revised as well... + unsigned int class_base[3]; ///< Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2) + unsigned class_upper : 6; ///< Specifies if the upper-type can equip it (bitfield, 0x01: normal, 0x02: upper, 0x04: baby normal, 0x08: third normal, 0x10: third upper, 0x20: third baby) struct { unsigned short chance; int id; - } mob[MAX_SEARCH]; //Holds the mobs that have the highest drop rate for this item. [Skotlex] - struct script_code *script; //Default script for everything. - struct script_code *equip_script; //Script executed once when equipping. - struct script_code *unequip_script;//Script executed once when unequipping. + } mob[MAX_SEARCH]; ///< Holds the mobs that have the highest drop rate for this item. [Skotlex] + struct script_code *script; ///< Default script for everything. + struct script_code *equip_script; ///< Script executed once when equipping. + struct script_code *unequip_script; ///< Script executed once when unequipping. struct { unsigned available : 1; - unsigned no_refine : 1; // [celest] - unsigned delay_consume : 1; // Signifies items that are not consumed immediately upon double-click [Skotlex] - unsigned trade_restriction : 9; ///< Item trade restrictions mask (@see enum ItemTradeRestrictions) + unsigned no_refine : 1; // [celest] + unsigned delay_consume : 1; ///< Signifies items that are not consumed immediately upon double-click [Skotlex] + unsigned trade_restriction : 9; ///< Item trade restrictions mask (@see enum ItemTradeRestrictions) unsigned autoequip: 1; unsigned buyingstore : 1; unsigned bindonequip : 1; @@ -426,7 +426,7 @@ struct item_data { unsigned int flag; ///< Item nouse restriction mask (@see enum ItemNouseRestrictions) unsigned short override; } item_usage; - short gm_lv_trade_override; //GM-level to override trade_restriction + short gm_lv_trade_override; ///< GM-level to override trade_restriction /* bugreport:309 */ struct item_combo **combos; unsigned char combos_count; diff --git a/src/map/log.c b/src/map/log.c index f0fd6795c..92956fa67 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -45,7 +45,7 @@ char log_picktype2char(e_log_pick_type type) { case LOG_TYPE_BUYING_STORE: return 'B'; // (B)uying Store case LOG_TYPE_LOOT: return 'L'; // (L)oot (consumed monster pick/drop) case LOG_TYPE_BANK: return 'K'; // Ban(K) Transactions - case LOG_TYPE_OTHER: return 'X'; // Other + case LOG_TYPE_OTHER: return 'X'; // Other } // should not get here, fallback diff --git a/src/map/log.h b/src/map/log.h index 40dbf6761..fb61b6e66 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -110,7 +110,7 @@ struct log_interface { void (*atcommand) (struct map_session_data* sd, const char* message); void (*branch) (struct map_session_data* sd); void (*mvpdrop) (struct map_session_data* sd, int monster_id, int* log_mvp); - + void (*pick_sub) (int id, int16 m, e_log_pick_type type, int amount, struct item* itm, struct item_data *data); void (*zeny_sub) (struct map_session_data* sd, e_log_pick_type type, struct map_session_data* src_sd, int amount); void (*npc_sub) (struct map_session_data* sd, const char *message); @@ -118,12 +118,12 @@ struct log_interface { void (*atcommand_sub) (struct map_session_data* sd, const char* message); void (*branch_sub) (struct map_session_data* sd); void (*mvpdrop_sub) (struct map_session_data* sd, int monster_id, int* log_mvp); - + int (*config_read) (const char* cfgName); void (*config_done) (void); void (*sql_init) (void); void (*sql_final) (void); - + char (*picktype2char) (e_log_pick_type type); char (*chattype2char) (e_log_chat_type type); bool (*should_log_item) (int nameid, int amount, int refine, struct item_data *id); diff --git a/src/map/map.c b/src/map/map.c index 9e2727b07..651c895ec 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -309,7 +309,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, int64 tick) { skill->unit_move(bl,tick,2); status_change_end(bl, SC_RG_CCONFINE_M, INVALID_TIMER); status_change_end(bl, SC_RG_CCONFINE_S, INVALID_TIMER); - // status_change_end(bl, SC_BLADESTOP, INVALID_TIMER); //Won't stop when you are knocked away, go figure... + //status_change_end(bl, SC_BLADESTOP, INVALID_TIMER); //Won't stop when you are knocked away, go figure... status_change_end(bl, SC_NJ_TATAMIGAESHI, INVALID_TIMER); status_change_end(bl, SC_MAGICROD, INVALID_TIMER); if (sc && sc->data[SC_PROPERTYWALK] && @@ -395,8 +395,8 @@ int map_moveblock(struct block_list *bl, int x1, int y1, int64 tick) { /*========================================== * Counts specified number of objects on given cell. - * flag: - * 0x1 - only count standing units + * flag: + * 0x1 - only count standing units * TODO: merge with bl_getall_area *------------------------------------------*/ int map_count_oncell(int16 m, int16 x, int16 y, int type, int flag) { @@ -1493,8 +1493,8 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1 * Returns true on success and sets x and y to cell found. * Otherwise returns false and x and y are not changed. * type: Types of block to count - * flag: - * 0x1 - only count standing units + * flag: + * 0x1 - only count standing units *------------------------------------------*/ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag) { @@ -1520,7 +1520,7 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag) *y = ty; return true; } - } + } //Full diagonal search else if(dir%2 == 1 && costrange%MOVE_DIAGONAL_COST == 0) { tx = *x+dx*(costrange/MOVE_DIAGONAL_COST); @@ -2507,35 +2507,31 @@ uint8 map_calc_dir(struct block_list* src, int16 x, int16 y) dx = x-src->x; dy = y-src->y; - if( dx == 0 && dy == 0 ) - { // both are standing on the same spot. + if (dx == 0 && dy == 0) { + // both are standing on the same spot. // aegis-style, makes knockback default to the left. // athena-style, makes knockback default to behind 'src'. dir = (battle_config.knockback_left ? 6 : unit->getdir(src)); - } - else if( dx >= 0 && dy >=0 ) - { // upper-right - if( dx*2 < dy || dx == 0 ) dir = 0; // up - else if( dx > dy*2+1 || dy == 0 ) dir = 6; // right - else dir = 7; // up-right - } - else if( dx >= 0 && dy <= 0 ) - { // lower-right - if( dx*2 < -dy || dx == 0 ) dir = 4; // down - else if( dx > -dy*2+1 || dy == 0 ) dir = 6; // right - else dir = 5; // down-right - } - else if( dx <= 0 && dy <= 0 ) - { // lower-left - if( dx*2 > dy || dx == 0 ) dir = 4; // down - else if( dx < dy*2-1 || dy == 0 ) dir = 2; // left - else dir = 3; // down-left - } - else - { // upper-left - if( -dx*2 < dy || dx == 0 ) dir = 0; // up - else if( -dx > dy*2+1 || dy == 0) dir = 2; // left - else dir = 1; // up-left + } else if (dx >= 0 && dy >=0) { + // upper-right + if( dx*2 < dy || dx == 0 ) dir = 0; // up + else if( dx > dy*2+1 || dy == 0 ) dir = 6; // right + else dir = 7; // up-right + } else if (dx >= 0 && dy <= 0) { + // lower-right + if( dx*2 < -dy || dx == 0 ) dir = 4; // down + else if( dx > -dy*2+1 || dy == 0 ) dir = 6; // right + else dir = 5; // down-right + } else if (dx <= 0 && dy <= 0) { + // lower-left + if( dx*2 > dy || dx == 0 ) dir = 4; // down + else if( dx < dy*2-1 || dy == 0 ) dir = 2; // left + else dir = 3; // down-left + } else { + // upper-left + if( -dx*2 < dy || dx == 0 ) dir = 0; // up + else if( -dx > dy*2+1 || dy == 0) dir = 2; // left + else dir = 1; // up-left } return dir; } @@ -3482,8 +3478,8 @@ int map_readallmaps (void) { map->list[i].m = i; map->addmap2db(&map->list[i]); - memset(map->list[i].moblist, 0, sizeof(map->list[i].moblist)); //Initialize moblist [Skotlex] - map->list[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] + memset(map->list[i].moblist, 0, sizeof(map->list[i].moblist)); //Initialize moblist [Skotlex] + map->list[i].mob_delete_timer = INVALID_TIMER; //Initialize timer [Skotlex] map->list[i].bxs = (map->list[i].xs + BLOCK_SIZE - 1) / BLOCK_SIZE; map->list[i].bys = (map->list[i].ys + BLOCK_SIZE - 1) / BLOCK_SIZE; @@ -5940,7 +5936,7 @@ int do_init(int argc, char *argv[]) exit(EXIT_SUCCESS); } - npc->event_do_oninit( false ); // Init npcs (OnInit) + npc->event_do_oninit( false ); // Init npcs (OnInit) npc->market_fromsql(); /* after OnInit */ if (battle_config.pk_mode) diff --git a/src/map/map.h b/src/map/map.h index 1766220af..bb6e43ac3 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -315,20 +315,20 @@ struct block_list { // Mob List Held in memory for Dynamic Mobs [Wizputer] // Expanded to specify all mob-related spawn data by [Skotlex] struct spawn_data { - short class_; //Class, used because a mob can change it's class - unsigned short m, x, y; //Spawn information (map, point, spawn-area around point) + short class_; ///< Class, used because a mob can change it's class + unsigned short m, x, y; ///< Spawn information (map, point, spawn-area around point) signed short xs, ys; - unsigned short num; //Number of mobs using this structure - unsigned short active;//Number of mobs that are already spawned (for mob_remove_damaged: no) - unsigned int delay1, delay2; //Spawn delay (fixed base + random variance) + unsigned short num; ///< Number of mobs using this structure + unsigned short active; ///< Number of mobs that are already spawned (for mob_remove_damaged: no) + unsigned int delay1, delay2; ///< Spawn delay (fixed base + random variance) unsigned int level; struct { - unsigned int size : 2; //Holds if mob has to be tiny/large - unsigned int ai : 4; //Special AI for summoned monsters. + unsigned int size : 2; ///< Holds if mob has to be tiny/large + unsigned int ai : 4; ///< Special AI for summoned monsters. //0: Normal mob | 1: Standard summon, attacks mobs //2: Alchemist Marine Sphere | 3: Alchemist Summon Flora | 4: Summon Zanzou - unsigned int dynamic : 1; //Whether this data is indexed by a map's dynamic mob list - unsigned int boss : 1; //0: Non-boss monster | 1: Boss monster + unsigned int dynamic : 1; ///< Whether this data is indexed by a map's dynamic mob list + unsigned int boss : 1; ///< 0: Non-boss monster | 1: Boss monster } state; char name[NAME_LENGTH], eventname[EVENT_NAME_LENGTH]; //Name/event }; @@ -343,18 +343,18 @@ struct flooritem_data { }; enum status_point_types { - SP_SPEED,SP_BASEEXP,SP_JOBEXP,SP_KARMA,SP_MANNER,SP_HP,SP_MAXHP,SP_SP, // 0-7 - SP_MAXSP,SP_STATUSPOINT,SP_0a,SP_BASELEVEL,SP_SKILLPOINT,SP_STR,SP_AGI,SP_VIT, // 8-15 - SP_INT,SP_DEX,SP_LUK,SP_CLASS,SP_ZENY,SP_SEX,SP_NEXTBASEEXP,SP_NEXTJOBEXP, // 16-23 - SP_WEIGHT,SP_MAXWEIGHT,SP_1a,SP_1b,SP_1c,SP_1d,SP_1e,SP_1f, // 24-31 - SP_USTR,SP_UAGI,SP_UVIT,SP_UINT,SP_UDEX,SP_ULUK,SP_26,SP_27, // 32-39 - SP_28,SP_ATK1,SP_ATK2,SP_MATK1,SP_MATK2,SP_DEF1,SP_DEF2,SP_MDEF1, // 40-47 - SP_MDEF2,SP_HIT,SP_FLEE1,SP_FLEE2,SP_CRITICAL,SP_ASPD,SP_36,SP_JOBLEVEL, // 48-55 - SP_UPPER,SP_PARTNER,SP_CART,SP_FAME,SP_UNBREAKABLE, //56-60 - SP_CARTINFO=99, // 99 - - SP_BASEJOB=119, // 100+19 - celest - SP_BASECLASS=120, //Hmm.. why 100+19? I just use the next one... [Skotlex] + SP_SPEED,SP_BASEEXP,SP_JOBEXP,SP_KARMA,SP_MANNER,SP_HP,SP_MAXHP,SP_SP, // 0-7 + SP_MAXSP,SP_STATUSPOINT,SP_0a,SP_BASELEVEL,SP_SKILLPOINT,SP_STR,SP_AGI,SP_VIT, // 8-15 + SP_INT,SP_DEX,SP_LUK,SP_CLASS,SP_ZENY,SP_SEX,SP_NEXTBASEEXP,SP_NEXTJOBEXP, // 16-23 + SP_WEIGHT,SP_MAXWEIGHT,SP_1a,SP_1b,SP_1c,SP_1d,SP_1e,SP_1f, // 24-31 + SP_USTR,SP_UAGI,SP_UVIT,SP_UINT,SP_UDEX,SP_ULUK,SP_26,SP_27, // 32-39 + SP_28,SP_ATK1,SP_ATK2,SP_MATK1,SP_MATK2,SP_DEF1,SP_DEF2,SP_MDEF1, // 40-47 + SP_MDEF2,SP_HIT,SP_FLEE1,SP_FLEE2,SP_CRITICAL,SP_ASPD,SP_36,SP_JOBLEVEL, // 48-55 + SP_UPPER,SP_PARTNER,SP_CART,SP_FAME,SP_UNBREAKABLE, //56-60 + SP_CARTINFO=99, // 99 + + SP_BASEJOB=119, // 100+19 - celest + SP_BASECLASS=120, //Hmm.. why 100+19? I just use the next one... [Skotlex] SP_KILLERRID=121, SP_KILLEDRID=122, SP_SLOTCHANGE=123, @@ -367,10 +367,10 @@ enum status_point_types { SP_MERCFLEE=165, SP_MERCKILLS=189, SP_MERCFAITH=190, // original 1000- - SP_ATTACKRANGE=1000, SP_ATKELE,SP_DEFELE, // 1000-1002 + SP_ATTACKRANGE=1000, SP_ATKELE,SP_DEFELE, // 1000-1002 SP_CASTRATE, SP_MAXHPRATE, SP_MAXSPRATE, SP_SPRATE, // 1003-1006 SP_ADDELE, SP_ADDRACE, SP_ADDSIZE, SP_SUBELE, SP_SUBRACE, // 1007-1011 - SP_ADDEFF, SP_RESEFF, // 1012-1013 + SP_ADDEFF, SP_RESEFF, // 1012-1013 SP_BASE_ATK,SP_ASPD_RATE,SP_HP_RECOV_RATE,SP_SP_RECOV_RATE,SP_SPEED_RATE, // 1014-1018 SP_CRITICAL_DEF,SP_NEAR_ATK_DEF,SP_LONG_ATK_DEF, // 1019-1021 SP_DOUBLE_RATE, SP_DOUBLE_ADD_RATE, SP_SKILL_HEAL, SP_MATK_RATE, // 1022-1025 @@ -401,8 +401,8 @@ enum status_point_types { SP_CRIT_ATK_RATE, SP_CRITICAL_ADDRACE, SP_NO_REGEN, SP_ADDEFF_WHENHIT, SP_AUTOSPELL_WHENHIT, // 2013-2017 SP_SKILL_ATK, SP_UNSTRIPABLE, SP_AUTOSPELL_ONSKILL, // 2018-2020 SP_SP_GAIN_VALUE, SP_HP_REGEN_RATE, SP_HP_LOSS_RATE, SP_ADDRACE2, SP_HP_GAIN_VALUE, // 2021-2025 - SP_SUBSIZE, SP_HP_DRAIN_VALUE_RACE, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_RACE, SP_EXP_ADDRACE, // 2026-2030 - SP_SP_GAIN_RACE, SP_SUBRACE2, SP_UNBREAKABLE_SHOES, // 2031-2033 + SP_SUBSIZE, SP_HP_DRAIN_VALUE_RACE, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_RACE, SP_EXP_ADDRACE, // 2026-2030 + SP_SP_GAIN_RACE, SP_SUBRACE2, SP_UNBREAKABLE_SHOES, // 2031-2033 SP_UNSTRIPABLE_WEAPON,SP_UNSTRIPABLE_ARMOR,SP_UNSTRIPABLE_HELM,SP_UNSTRIPABLE_SHIELD, // 2034-2037 SP_INTRAVISION, SP_ADD_MONSTER_DROP_CHAINITEM, SP_SP_LOSS_RATE, // 2038-2040 SP_ADD_SKILL_BLOW, SP_SP_VANISH_RATE, SP_MAGIC_SP_GAIN_VALUE, SP_MAGIC_HP_GAIN_VALUE, SP_ADD_CLASS_DROP_ITEM, //2041-2045 @@ -410,8 +410,7 @@ enum status_point_types { SP_SKILL_COOLDOWN,SP_SKILL_FIXEDCAST, SP_SKILL_VARIABLECAST, SP_FIXCASTRATE, SP_VARCASTRATE, //2050-2054 SP_SKILL_USE_SP,SP_MAGIC_ATK_ELE, SP_ADD_FIXEDCAST, SP_ADD_VARIABLECAST, //2055-2058 SP_SET_DEF_RACE,SP_SET_MDEF_RACE, //2059-2060 - - + /* must be the last, plugins add bonuses from this value onwards */ SP_LAST_KNOWN, }; @@ -450,17 +449,17 @@ typedef enum { // used by map->getcell() typedef enum { - CELL_GETTYPE, // retrieves a cell's 'gat' type + CELL_GETTYPE, ///< retrieves a cell's 'gat' type - CELL_CHKWALL, // wall (gat type 1) - CELL_CHKWATER, // water (gat type 3) - CELL_CHKCLIFF, // cliff/gap (gat type 5) + CELL_CHKWALL, ///< wall (gat type 1) + CELL_CHKWATER, ///< water (gat type 3) + CELL_CHKCLIFF, ///< cliff/gap (gat type 5) - CELL_CHKPASS, // passable cell (gat type non-1/5) - CELL_CHKREACH, // Same as PASS, but ignores the cell-stacking mod. - CELL_CHKNOPASS, // non-passable cell (gat types 1 and 5) - CELL_CHKNOREACH, // Same as NOPASS, but ignores the cell-stacking mod. - CELL_CHKSTACK, // whether cell is full (reached cell stacking limit) + CELL_CHKPASS, ///< passable cell (gat type non-1/5) + CELL_CHKREACH, ///< Same as PASS, but ignores the cell-stacking mod. + CELL_CHKNOPASS, ///< non-passable cell (gat types 1 and 5) + CELL_CHKNOREACH, ///< Same as NOPASS, but ignores the cell-stacking mod. + CELL_CHKSTACK, ///< whether cell is full (reached cell stacking limit) CELL_CHKNPC, CELL_CHKBASILICA, @@ -507,11 +506,11 @@ struct mapflag_skill_adjust { }; enum map_zone_skill_subtype { - MZS_NONE = 0x0, - MZS_CLONE = 0x01, - MZS_BOSS = 0x02, + MZS_NONE = 0x0, + MZS_CLONE = 0x01, + MZS_BOSS = 0x02, - MZS_ALL = 0xFFF, + MZS_ALL = 0xFFF }; struct map_zone_disabled_skill_entry { @@ -578,7 +577,7 @@ struct map_data { char name[MAP_NAME_LENGTH]; uint16 index; // The map index used by the mapindex* functions. struct mapcell* cell; // Holds the information of each map cell (NULL if the map is not on this map-server). - + /* 2D Orthogonal Range Search: Grid Implementation "Algorithms in Java, Parts 1-4" 3.18, Robert Sedgewick Map is divided into squares, called blocks (side length = BLOCK_SIZE). @@ -590,7 +589,7 @@ struct map_data { */ struct block_list **block; // Grid array of block_lists containing only non-BL_MOB objects struct block_list **block_mob; // Grid array of block_lists containing only BL_MOB objects - + int16 m; int16 xs,ys; // map dimensions (in cells) int16 bxs,bys; // map dimensions (in blocks) @@ -633,10 +632,10 @@ struct map_data { unsigned fireworks : 1; unsigned sakura : 1; // [Valaris] unsigned leaves : 1; // [Valaris] - unsigned nobaseexp : 1; // [Lorky] added by Lupus - unsigned nojobexp : 1; // [Lorky] - unsigned nomobloot : 1; // [Lorky] - unsigned nomvploot : 1; // [Lorky] + unsigned nobaseexp : 1; // [Lorky] added by Lupus + unsigned nojobexp : 1; // [Lorky] + unsigned nomobloot : 1; // [Lorky] + unsigned nomvploot : 1; // [Lorky] unsigned nightenabled :1; //For night display. [Skotlex] unsigned nodrop : 1; unsigned novending : 1; @@ -657,9 +656,9 @@ struct map_data { unsigned short drop_list_count; struct spawn_data *moblist[MAX_MOB_LIST_PER_MAP]; // [Wizputer] - int mob_delete_timer; // [Skotlex] - int jexp; // map experience multiplicator - int bexp; // map experience multiplicator + int mob_delete_timer; // [Skotlex] + int jexp; // map experience multiplicator + int bexp; // map experience multiplicator int nocommand; //Blocks @/# commands for non-gms. [Skotlex] // Instance Variables @@ -702,14 +701,14 @@ struct map_data { int (*getcellp)(struct map_data* m,int16 x,int16 y,cell_chk cellchk); void (*setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag); char *cellPos; - + /* ShowEvent Data Cache */ struct questinfo *qi_data; unsigned short qi_count; - + /* speeds up clif_updatestatus processing by causing hpmeter to run only when someone with the permission can view it */ unsigned short hpmeter_visible; - + /* HPM Custom Struct */ struct HPluginData **hdata; unsigned int hdatac; @@ -730,7 +729,7 @@ struct map_data_other_server { /// Bitfield of flags for the iterator. enum e_mapitflags { MAPIT_NORMAL = 0, - // MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold authed, active players. + //MAPIT_PCISPLAYING = 1,// Unneeded as pc_db/id_db will only hold authed, active players. }; struct s_mapiterator; @@ -764,7 +763,7 @@ typedef struct skill_unit TBL_SKILL; typedef struct pet_data TBL_PET; typedef struct homun_data TBL_HOM; typedef struct mercenary_data TBL_MER; -typedef struct elemental_data TBL_ELEM; +typedef struct elemental_data TBL_ELEM; #define BL_CAST(type_, bl) \ ( ((bl) == (struct block_list*)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) ) @@ -846,17 +845,17 @@ struct map_interface { char npc_market_data_db[32]; char default_codepage[32]; - + int server_port; char server_ip[32]; char server_id[32]; char server_pw[100]; char server_db[32]; Sql* mysql_handle; - + int port; int users; - int enable_grf; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89] + int enable_grf; //To enable/disable reading maps from GRF files, bypassing mapcache [blackhole89] bool ip_set; bool char_ip_set; @@ -1016,7 +1015,7 @@ struct map_interface { void (*clean) (int i); void (*do_shutdown) (void); - + int (*freeblock_timer) (int tid, int64 tick, int id, intptr_t data); int (*searchrandfreecell) (int16 m, int16 *x, int16 *y, int stack); int (*count_sub) (struct block_list *bl, va_list ap); diff --git a/src/map/mercenary.h b/src/map/mercenary.h index 270245e96..68f60b08b 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -42,7 +42,7 @@ struct mercenary_data { struct map_session_data *master; int contract_timer; - + unsigned devotion_flag : 1; int64 masterteleport_timer; }; @@ -55,26 +55,26 @@ struct mercenary_data { struct mercenary_interface { /* vars */ - + struct s_mercenary_db db[MAX_MERCENARY_CLASS]; /* funcs */ void (*init) (bool minimal); - + bool (*class) (int class_); struct view_data * (*get_viewdata) (int class_); - + int (*create) (struct map_session_data *sd, int class_, unsigned int lifetime); int (*data_received) (struct s_mercenary *merc, bool flag); int (*save) (struct mercenary_data *md); - + void (*heal) (struct mercenary_data *md, int hp, int sp); int (*dead) (struct mercenary_data *md); - + int (*delete) (struct mercenary_data *md, int reply); void (*contract_stop) (struct mercenary_data *md); - + int (*get_lifetime) (struct mercenary_data *md); int (*get_guild) (struct mercenary_data *md); int (*get_faith) (struct mercenary_data *md); @@ -82,14 +82,14 @@ struct mercenary_interface { int (*get_calls) (struct mercenary_data *md); int (*set_calls) (struct mercenary_data *md, int value); int (*kills) (struct mercenary_data *md); - + int (*checkskill) (struct mercenary_data *md, uint16 skill_id); int (*read_db) (void); int (*read_skilldb) (void); - + int (*killbonus) (struct mercenary_data *md); int (*search_index) (int class_); - + int (*contract_end_timer) (int tid, int64 tick, int id, intptr_t data); bool (*read_db_sub) (char* str[], int columns, int current); bool (*read_skill_db_sub) (char* str[], int columns, int current); diff --git a/src/map/mob.c b/src/map/mob.c index 5af3f99b4..28e70c5c0 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -48,9 +48,9 @@ struct mob_interface mob_s; -#define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode. +#define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode. -#define IDLE_SKILL_INTERVAL 10 //Active idle skills should be triggered every 1 second (1000/MIN_MOBTHINKTIME) +#define IDLE_SKILL_INTERVAL 10 //Active idle skills should be triggered every 1 second (1000/MIN_MOBTHINKTIME) // Probability for mobs far from players from doing their IDLE skill. (rate of 1000 minute) // in Aegis, this is 100% for mobs that have been activated by players and none otherwise. @@ -59,8 +59,8 @@ struct mob_interface mob_s; // in Aegis, this is 100% for mobs that have been activated by players and none otherwise. #define MOB_LAZYMOVEPERC(md) ((md)->state.spotted?1000:0) #define MOB_MAX_DELAY (24*3600*1000) -#define MAX_MINCHASE 30 //Max minimum chase value to use for mobs. -#define RUDE_ATTACKED_COUNT 2 //After how many rude-attacks should the skill be used? +#define MAX_MINCHASE 30 //Max minimum chase value to use for mobs. +#define RUDE_ATTACKED_COUNT 2 //After how many rude-attacks should the skill be used? //Dynamic item drop ratio database for per-item drop ratio modifiers overriding global drop ratios. #define MAX_ITEMRATIO_MOBS 10 @@ -502,7 +502,7 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const else if( gc->guild_id ) //Guild not yet available, retry in 5. timer->add(timer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,gc->guild_id); } - } // end addition [Valaris] + } // end addition [Valaris] mob->spawn(md); @@ -677,8 +677,8 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam else g = guild->search(gc->guild_id); - if( has_index && gc->guardian[guardian].id ) - { //Check if guardian already exists, refuse to spawn if so. + if( has_index && gc->guardian[guardian].id ) { + //Check if guardian already exists, refuse to spawn if so. struct mob_data *md2 = (TBL_MOB*)map->id2bl(gc->guardian[guardian].id); if (md2 && md2->bl.type == BL_MOB && md2->guardian_data @@ -805,7 +805,8 @@ int mob_linksearch(struct block_list *bl,va_list ap) { && !md->target_id) { md->last_linktime = tick; - if( mob->can_reach(md,target,md->db->range2, MSS_FOLLOW) ){ // Reachability judging + if (mob->can_reach(md,target,md->db->range2, MSS_FOLLOW)) { + // Reachability judging md->target_id = target->id; md->min_chase=md->db->range3; return 1; @@ -853,17 +854,20 @@ int mob_setdelayspawn(struct mob_data *md) //Apply the spawn delay fix [Skotlex] db = mob->db(md->spawn->class_); mode = db->status.mode; - if (mode & MD_BOSS) { //Bosses + if (mode & MD_BOSS) { + //Bosses if (battle_config.boss_spawn_delay != 100) { // Divide by 100 first to prevent overflows //(precision loss is minimal as duration is in ms already) spawntime = spawntime/100*battle_config.boss_spawn_delay; } - } else if (mode&MD_PLANT) { //Plants + } else if (mode&MD_PLANT) { + //Plants if (battle_config.plant_spawn_delay != 100) { spawntime = spawntime/100*battle_config.plant_spawn_delay; } - } else if (battle_config.mob_spawn_delay != 100) { //Normal mobs + } else if (battle_config.mob_spawn_delay != 100) { + //Normal mobs spawntime = spawntime/100*battle_config.mob_spawn_delay; } @@ -943,7 +947,7 @@ int mob_spawn (struct mob_data *md) md->spawn_timer = INVALID_TIMER; } -// md->master_id = 0; + //md->master_id = 0; md->master_dist = 0; md->state.aggressive = md->status.mode&MD_ANGRY?1:0; @@ -1027,7 +1031,7 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist) if(!status->check_skilluse(&md->bl, bl, 0, 0)) return 0; - md->target_id = bl->id; // Since there was no disturbance, it locks on to target. + md->target_id = bl->id; // Since there was no disturbance, it locks on to target. if (md->state.provoke_flag && bl->id != md->state.provoke_flag) md->state.provoke_flag = 0; md->min_chase=dist+md->db->range3; @@ -1197,8 +1201,8 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md, int64 tick) { if (bl->prev == NULL) return 0; //Master not on a map? Could be warping, do not process. - if(status_get_mode(&md->bl)&MD_CANMOVE) - { //If the mob can move, follow around. [Check by Skotlex] + if (status_get_mode(&md->bl)&MD_CANMOVE) { + //If the mob can move, follow around. [Check by Skotlex] int old_dist; // Distance with between slave and master is measured. @@ -1235,8 +1239,7 @@ int mob_ai_sub_hard_slavemob(struct mob_data *md, int64 tick) { } //Avoid attempting to lock the master's target too often to avoid unnecessary overload. [Skotlex] - if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id) - { + if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id) { struct unit_data *ud = unit->bl2ud(bl); md->last_linktime = tick; @@ -1327,7 +1330,8 @@ int mob_randomwalk(struct mob_data *md, int64 tick) { d =12-md->move_fail_count; if(d<5) d=5; if(d>7) d=7; - for(i=0;i<retrycount;i++){ // Search of a movable place + for (i = 0; i < retrycount; i++) { + // Search of a movable place int r=rnd(); x=r%(d*2+1)-d; y=r/(d*2+1)%(d*2+1)-d; @@ -1442,23 +1446,23 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { } // Check for target change. - if( md->attacked_id && mode&MD_CANATTACK ) - { - if( md->attacked_id == md->target_id ) - { //Rude attacked check. - if( !battle->check_range(&md->bl, tbl, md->status.rhw.range) - && ( //Can't attack back and can't reach back. - (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1) - || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP] - || md->sc.data[SC__MANHOLE] // Not yet confirmed if boss will teleport once it can't reach target. - || md->walktoxy_fail_count > 0) - ) - || !mob->can_reach(md, tbl, md->min_chase, MSS_RUSH) - ) - && md->state.attacked_count++ >= RUDE_ATTACKED_COUNT - && !mob->skill_use(md, tick, MSC_RUDEATTACKED) // If can't rude Attack - && can_move && unit->escape(&md->bl, tbl, rnd()%10 +1)) // Attempt escape - { //Escaped + if (md->attacked_id && mode&MD_CANATTACK) { + if (md->attacked_id == md->target_id) { + //Rude attacked check. + if (!battle->check_range(&md->bl, tbl, md->status.rhw.range) + && ( //Can't attack back and can't reach back. + (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1) + || md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP] + || md->sc.data[SC__MANHOLE] // Not yet confirmed if boss will teleport once it can't reach target. + || md->walktoxy_fail_count > 0) + ) + || !mob->can_reach(md, tbl, md->min_chase, MSS_RUSH) + ) + && md->state.attacked_count++ >= RUDE_ATTACKED_COUNT + && !mob->skill_use(md, tick, MSC_RUDEATTACKED) // If can't rude Attack + && can_move && unit->escape(&md->bl, tbl, rnd()%10 +1) // Attempt escape + ) { + //Escaped md->attacked_id = 0; return true; } @@ -1483,9 +1487,10 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { ) { // Rude attacked if (md->state.attacked_count++ >= RUDE_ATTACKED_COUNT - && !mob->skill_use(md, tick, MSC_RUDEATTACKED) && can_move - && !tbl && unit->escape(&md->bl, abl, rnd()%10 +1)) - { //Escaped. + && !mob->skill_use(md, tick, MSC_RUDEATTACKED) && can_move + && !tbl && unit->escape(&md->bl, abl, rnd()%10 +1) + ) { + //Escaped. //TODO: Maybe it shouldn't attempt to run if it has another, valid target? md->attacked_id = 0; return true; @@ -1496,9 +1501,11 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { //Can't attack back, but didn't invoke a rude attacked skill... } else { //Attackable - if (!tbl || dist < md->status.rhw.range || !check_distance_bl(&md->bl, tbl, dist) - || battle->get_target(tbl) != md->bl.id) - { //Change if the new target is closer than the actual one + if (!tbl || dist < md->status.rhw.range + || !check_distance_bl(&md->bl, tbl, dist) + || battle->get_target(tbl) != md->bl.id + ) { + //Change if the new target is closer than the actual one //or if the previous target is not attacking the mob. [Skotlex] md->target_id = md->attacked_id; // set target if (md->state.attacked_count) @@ -1556,20 +1563,20 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { } //Target exists, attack or loot as applicable. - if (tbl->type == BL_ITEM) - { //Loot time. + if (tbl->type == BL_ITEM) { + //Loot time. struct flooritem_data *fitem; if (md->ud.target == tbl->id && md->ud.walktimer != INVALID_TIMER) return true; //Already locked. - if (md->lootitem == NULL) - { //Can't loot... + if (md->lootitem == NULL) { + //Can't loot... mob->unlocktarget (md, tick); return true; } - if (!check_distance_bl(&md->bl, tbl, 1)) - { //Still not within loot range. - if (!(mode&MD_CANMOVE)) - { //A looter that can't move? Real smart. + if (!check_distance_bl(&md->bl, tbl, 1)) { + //Still not within loot range. + if (!(mode&MD_CANMOVE)) { + //A looter that can't move? Real smart. mob->unlocktarget(md,tick); return true; } @@ -1590,14 +1597,15 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { if (md->lootitem_count < LOOTITEM_SIZE) { memcpy (&md->lootitem[md->lootitem_count++], &fitem->item_data, sizeof(md->lootitem[0])); - } else { //Destroy first looted item... + } else { + //Destroy first looted item... if (md->lootitem[0].card[0] == CARD0_PET) intif->delete_petdata( MakeDWord(md->lootitem[0].card[1],md->lootitem[0].card[2]) ); memmove(&md->lootitem[0], &md->lootitem[1], (LOOTITEM_SIZE-1)*sizeof(md->lootitem[0])); memcpy (&md->lootitem[LOOTITEM_SIZE-1], &fitem->item_data, sizeof(md->lootitem[0])); } - if (pcdb_checkid(md->vd->class_)) - { //Give them walk act/delay to properly mimic players. [Skotlex] + if (pcdb_checkid(md->vd->class_)) { + //Give them walk act/delay to properly mimic players. [Skotlex] clif->takeitem(&md->bl,tbl); md->ud.canact_tick = tick + md->status.amotion; unit->set_walkdelay(&md->bl, tick, md->status.amotion, 1); @@ -1610,9 +1618,9 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { //Attempt to attack. //At this point we know the target is attackable, we just gotta check if the range matches. - if (battle->check_range(&md->bl, tbl, md->status.rhw.range) && !(md->sc.option&OPTION_HIDE)) - { //Target within range and able to use normal attack, engage - if (md->ud.target != tbl->id || md->ud.attacktimer == INVALID_TIMER) + if (battle->check_range(&md->bl, tbl, md->status.rhw.range) && !(md->sc.option&OPTION_HIDE)) { + //Target within range and able to use normal attack, engage + if (md->ud.target != tbl->id || md->ud.attacktimer == INVALID_TIMER) { //Only attack if no more attack delay left if(tbl->type == BL_PC) mob->log_damage(md, tbl, 0); //Log interaction (counts as 'attacker' for the exp bonus) @@ -1623,7 +1631,7 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { //Monsters in berserk state, unable to use normal attacks, will always attempt a skill if(md->ud.walktimer == INVALID_TIMER && (md->state.skillstate == MSS_BERSERK || md->state.skillstate == MSS_ANGRY)) { - if (DIFF_TICK(md->ud.canmove_tick, tick) <= MIN_MOBTHINKTIME && DIFF_TICK(md->ud.canact_tick, tick) < -MIN_MOBTHINKTIME*IDLE_SKILL_INTERVAL) + if (DIFF_TICK(md->ud.canmove_tick, tick) <= MIN_MOBTHINKTIME && DIFF_TICK(md->ud.canact_tick, tick) < -MIN_MOBTHINKTIME*IDLE_SKILL_INTERVAL) { //Only use skill if able to walk on next tick and not used a skill the last second mob->skill_use(md, tick, -1); } @@ -1638,15 +1646,15 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { return true; //Out of range... - if (!(mode&MD_CANMOVE) || (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0)) - { //Can't chase. Immobile and trapped mobs should unlock target and use an idle skill. + if (!(mode&MD_CANMOVE) || (!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0)) { + //Can't chase. Immobile and trapped mobs should unlock target and use an idle skill. if (md->ud.attacktimer == INVALID_TIMER) { //Only unlock target if no more attack delay left //This handles triggering idle/walk skill. mob->unlocktarget(md,tick); } return true; - } + } if (md->ud.walktimer != INVALID_TIMER && md->ud.target == tbl->id && ( @@ -1667,8 +1675,8 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { int mob_ai_sub_hard_timer(struct block_list *bl, va_list ap) { struct mob_data *md = (struct mob_data*)bl; int64 tick = va_arg(ap, int64); - if (mob->ai_sub_hard(md, tick)) - { //Hard AI triggered. + if (mob->ai_sub_hard(md, tick)) { + //Hard AI triggered. if(!md->state.spotted) md->state.spotted = 1; md->last_pcneartime = tick; @@ -1706,11 +1714,11 @@ int mob_ai_sub_lazy(struct mob_data *md, va_list args) { if (md->bl.prev==NULL || md->status.hp == 0) return 1; - if(battle_config.mob_active_time && - md->last_pcneartime && - !(md->status.mode&MD_BOSS) && - DIFF_TICK(tick,md->last_thinktime) > MIN_MOBTHINKTIME) - { + if (battle_config.mob_active_time + && md->last_pcneartime + && !(md->status.mode&MD_BOSS) + && DIFF_TICK(tick,md->last_thinktime) > MIN_MOBTHINKTIME + ) { if (DIFF_TICK(tick,md->last_pcneartime) < battle_config.mob_active_time) return (int)mob->ai_sub_hard(md, tick); md->last_pcneartime = 0; @@ -1840,7 +1848,8 @@ void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct ite && sd->bl.m == md->bl.m && check_distance_blxy(&sd->bl, dlist->x, dlist->y, AUTOLOOT_DISTANCE) #endif - ) { //Autoloot. + ) { + //Autoloot. if (party->share_loot(party->search(sd->status.party_id), sd, &ditem->item_data, sd->status.char_id) == 0 ) { @@ -1995,13 +2004,14 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage) if(md->dmglog[i].id==char_id && md->dmglog[i].flag==flag) break; - if(md->dmglog[i].id==0) { //Store data in first empty slot. + if(md->dmglog[i].id==0) { + //Store data in first empty slot. md->dmglog[i].id = char_id; md->dmglog[i].flag= flag; break; } - if(md->dmglog[i].dmg<mindmg && i) - { //Never overwrite first hit slot (he gets double exp bonus) + if (md->dmglog[i].dmg<mindmg && i) { + //Never overwrite first hit slot (he gets double exp bonus) minpos=i; mindmg=md->dmglog[i].dmg; } @@ -2145,8 +2155,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { // determines, if the monster was killed by homunculus' damage only homkillonly = (bool)( ( dmgbltypes&BL_HOM ) && !( dmgbltypes&~BL_HOM ) ); - if(!battle_config.exp_calc_type && count > 1) - { //Apply first-attacker 200% exp share bonus + if (!battle_config.exp_calc_type && count > 1) { + //Apply first-attacker 200% exp share bonus //TODO: Determine if this should go before calculating the MVP player instead of after. if (UINT_MAX - md->dmglog[0].dmg > md->tdmg) { md->tdmg += md->dmglog[0].dmg; @@ -2246,7 +2256,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { pnum++; flag=0; } - } else { //Add to total + } else { + //Add to total if (pt[j].base_exp > UINT_MAX - base_exp) pt[j].base_exp = UINT_MAX; else @@ -2445,7 +2456,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { timer->add(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist); else //No drops ers_free(item_drop_list_ers, dlist); - } else if (md->lootitem && md->lootitem_count) { //Loot MUST drop! + } else if (md->lootitem && md->lootitem_count) { + //Loot MUST drop! struct item_drop_list *dlist = ers_alloc(item_drop_list_ers, struct item_drop_list); dlist->m = md->bl.m; dlist->x = md->bl.x; @@ -2540,9 +2552,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { logs->mvpdrop(mvp_sd, md->class_, log_mvp); } - if (type&2 && !sd && md->class_ == MOBID_EMPERIUM && md->guardian_data) - //Emperium destroyed by script. Discard mvp character. [Skotlex] + if (type&2 && !sd && md->class_ == MOBID_EMPERIUM && md->guardian_data) { + //Emperium destroyed by script. Discard mvp character. [Skotlex] mvp_sd = NULL; + } rebirth = ( md->sc.data[SC_KAIZEL] || (md->sc.data[SC_REBIRTH] && !md->state.rebirth) ); if( !rebirth ) { // Only trigger event on final kill @@ -2643,7 +2656,7 @@ void mob_revive(struct mob_data *md, unsigned int hp) md->next_walktime = tick+rnd()%1000+MIN_RANDOMWALKTIME; md->last_linktime = tick; md->last_pcneartime = 0; - memset(md->dmglog, 0, sizeof(md->dmglog)); // Reset the damage done on the rebirthed monster, otherwise will grant full exp + damage done. [Valaris] + memset(md->dmglog, 0, sizeof(md->dmglog)); // Reset the damage done on the rebirthed monster, otherwise will grant full exp + damage done. [Valaris] md->tdmg = 0; if (!md->bl.prev) map->addblock(&md->bl); @@ -2662,8 +2675,8 @@ int mob_guardian_guildchange(struct mob_data *md) if (!md->guardian_data) return 0; - if( md->guardian_data->castle->guild_id == 0 ) - { //Castle with no owner? Delete the guardians. + if (md->guardian_data->castle->guild_id == 0) { + //Castle with no owner? Delete the guardians. if( md->class_ == MOBID_EMPERIUM ) //But don't delete the emperium, just clear it's guild-data md->guardian_data->g = NULL; else { @@ -2675,8 +2688,8 @@ int mob_guardian_guildchange(struct mob_data *md) } g = guild->search(md->guardian_data->castle->guild_id); - if( g == NULL ) - { //Properly remove guardian info from Castle data. + if (g == NULL) { + //Properly remove guardian info from Castle data. ShowError("mob_guardian_guildchange: New Guild (id %d) does not exists!\n", md->guardian_data->castle->guild_id); if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS) guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number, 0); @@ -2700,7 +2713,7 @@ int mob_random_class (int *value, size_t count) if (count < 1) { count = 0; while(count < 5 && mob->db_checkid(value[count])) count++; - if(count < 1) // nothing found + if(count < 1) // nothing found return 0; } else { // check if at least the first value is valid @@ -2925,8 +2938,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id) md->status.hp = md->status.max_hp*hp_rate/100; //Inherit the aggressive mode of the master. - if (battle_config.slaves_inherit_mode && md->master_id) - { + if (battle_config.slaves_inherit_mode && md->master_id) { switch (battle_config.slaves_inherit_mode) { case 1: //Always aggressive if (!(md->status.mode&MD_AGGRESSIVE)) @@ -3116,16 +3128,16 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) { { case MSC_ALWAYS: flag = 1; break; - case MSC_MYHPLTMAXRATE: // HP< maxhp% + case MSC_MYHPLTMAXRATE: // HP< maxhp% flag = get_percentage(md->status.hp, md->status.max_hp); flag = (flag <= c2); - break; + break; case MSC_MYHPINRATE: flag = get_percentage(md->status.hp, md->status.max_hp); flag = (flag >= c2 && flag <= ms[i].val[0]); break; - case MSC_MYSTATUSON: // status[num] on - case MSC_MYSTATUSOFF: // status[num] off + case MSC_MYSTATUSON: // status[num] on + case MSC_MYSTATUSOFF: // status[num] off if (!md->sc.count) { flag = 0; } else if (ms[i].cond2 == -1) { @@ -3136,26 +3148,26 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) { flag = (md->sc.data[ms[i].cond2]!=NULL); } flag ^= (ms[i].cond1 == MSC_MYSTATUSOFF); break; - case MSC_FRIENDHPLTMAXRATE: // friend HP < maxhp% + case MSC_FRIENDHPLTMAXRATE: // friend HP < maxhp% flag = ((fbl = mob->getfriendhprate(md, 0, ms[i].cond2)) != NULL); break; - case MSC_FRIENDHPINRATE : + case MSC_FRIENDHPINRATE: flag = ((fbl = mob->getfriendhprate(md, ms[i].cond2, ms[i].val[0])) != NULL); break; - case MSC_FRIENDSTATUSON: // friend status[num] on - case MSC_FRIENDSTATUSOFF: // friend status[num] off + case MSC_FRIENDSTATUSON: // friend status[num] on + case MSC_FRIENDSTATUSOFF: // friend status[num] off flag = ((fmd = mob->getfriendstatus(md, ms[i].cond1, ms[i].cond2)) != NULL); break; - case MSC_SLAVELT: // slave < num + case MSC_SLAVELT: // slave < num flag = (mob->countslave(&md->bl) < c2 ); break; - case MSC_ATTACKPCGT: // attack pc > num + case MSC_ATTACKPCGT: // attack pc > num flag = (unit->counttargeted(&md->bl) > c2); break; - case MSC_SLAVELE: // slave <= num + case MSC_SLAVELE: // slave <= num flag = (mob->countslave(&md->bl) <= c2 ); break; - case MSC_ATTACKPCGE: // attack pc >= num + case MSC_ATTACKPCGE: // attack pc >= num flag = (unit->counttargeted(&md->bl) >= c2); break; case MSC_AFTERSKILL: flag = (md->ud.skill_id == c2); break; case MSC_RUDEATTACKED: flag = (md->state.attacked_count >= RUDE_ATTACKED_COUNT); - if (flag) md->state.attacked_count = 0; //Rude attacked count should be reset after the skill condition is met. Thanks to Komurka [Skotlex] + if (flag) md->state.attacked_count = 0; //Rude attacked count should be reset after the skill condition is met. Thanks to Komurka [Skotlex] break; case MSC_MASTERHPLTMAXRATE: flag = ((fbl = mob->getmasterhpltmaxrate(md, ms[i].cond2)) != NULL); break; @@ -3201,7 +3213,7 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) { if (!bl) continue; x = bl->x; - y = bl->y; + y = bl->y; // Look for an area to cast the spell around... if (ms[i].target >= MST_AROUND1 || ms[i].target >= MST_AROUND5) { j = ms[i].target >= MST_AROUND1? @@ -3260,10 +3272,10 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) { if ( ms[ i ].msg_id ){ //Display color message [SnakeDrak] struct mob_chat *mc = mob->chat(ms[i].msg_id); char temp[CHAT_SIZE_MAX]; - char name[NAME_LENGTH]; - snprintf(name, sizeof name,"%s", md->name); - strtok(name, "#"); // discard extra name identifier if present [Daegaladh] - snprintf(temp, sizeof temp,"%s : %s", name, mc->msg); + char name[NAME_LENGTH]; + snprintf(name, sizeof name,"%s", md->name); + strtok(name, "#"); // discard extra name identifier if present [Daegaladh] + snprintf(temp, sizeof temp,"%s : %s", name, mc->msg); clif->messagecolor(&md->bl, mc->color, temp); } if(!(battle_config.mob_ai&0x200)) { //pass on delay to same skill. @@ -3555,8 +3567,8 @@ int mob_makedummymobdb(int class_) { if (mob->db(class_) == mob->dummy) return 1; //Using the mob->dummy data already. [Skotlex] - if (class_ > 0 && class_ <= MAX_MOB_DB) - { //Remove the mob data so that it uses the dummy data instead. + if (class_ > 0 && class_ <= MAX_MOB_DB) { + //Remove the mob data so that it uses the dummy data instead. aFree(mob->db_data[class_]); mob->db_data[class_] = NULL; } @@ -3708,7 +3720,7 @@ bool mob_parse_dbrow(char** str) { if (mstatus->luk < 1) mstatus->luk = 1; //Tests showed that chase range is effectively 2 cells larger than expected [Playtester] - if (db->range3 > 0) + if (db->range3 > 0) db->range3 += 2; db->range2 = atoi(str[20]); @@ -3819,8 +3831,8 @@ bool mob_parse_dbrow(char** str) { id = itemdb->search(db->dropitem[i].nameid); type = id->type; rate = atoi(str[k+1]); - if( (class_ >= 1324 && class_ <= 1363) || (class_ >= 1938 && class_ <= 1946) ) - { //Treasure box drop rates [Skotlex] + if( (class_ >= 1324 && class_ <= 1363) || (class_ >= 1938 && class_ <= 1946) ) { + //Treasure box drop rates [Skotlex] rate_adjust = battle_config.item_rate_treasure; ratemin = battle_config.item_drop_treasure_min; ratemax = battle_config.item_drop_treasure_max; @@ -3990,8 +4002,8 @@ bool mob_readdb_mobavail(char* str[], int columns, int current) class_=atoi(str[0]); - if(mob->db(class_) == mob->dummy) // invalid class (probably undefined in db) - { + if(mob->db(class_) == mob->dummy) { + // invalid class (probably undefined in db) ShowWarning("mob_readdb_mobavail: Unknown mob id %d.\n", class_); return false; } @@ -4042,7 +4054,7 @@ int mob_read_randommonster(void) for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ ) { unsigned int count = 0; - mob->db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one + mob->db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one sprintf(line, "%s/%s", map->db_path, mobfile[i]); fp=fopen(line,"r"); if(fp==NULL){ @@ -4209,16 +4221,16 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current) char str[32]; enum MobSkillState id; } state[] = { - { "any", MSS_ANY }, //All states except Dead - { "idle", MSS_IDLE }, - { "walk", MSS_WALK }, - { "loot", MSS_LOOT }, - { "dead", MSS_DEAD }, - { "attack", MSS_BERSERK }, //Retaliating attack - { "angry", MSS_ANGRY }, //Preemptive attack (aggressive mobs) - { "chase", MSS_RUSH }, //Chase escaping target - { "follow", MSS_FOLLOW }, //Preemptive chase (aggressive mobs) - { "anytarget",MSS_ANYTARGET }, //Berserk+Angry+Rush+Follow + { "any", MSS_ANY }, //All states except Dead + { "idle", MSS_IDLE }, + { "walk", MSS_WALK }, + { "loot", MSS_LOOT }, + { "dead", MSS_DEAD }, + { "attack", MSS_BERSERK }, //Retaliating attack + { "angry", MSS_ANGRY }, //Preemptive attack (aggressive mobs) + { "chase", MSS_RUSH }, //Chase escaping target + { "follow", MSS_FOLLOW }, //Preemptive chase (aggressive mobs) + { "anytarget", MSS_ANYTARGET }, //Berserk+Angry+Rush+Follow }; static const struct { char str[32]; @@ -4248,33 +4260,33 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current) { "alchemist", MSC_ALCHEMIST }, { "onspawn", MSC_SPAWN }, }, cond2[] ={ - { "anybad", -1 }, - { "stone", SC_STONE }, - { "freeze", SC_FREEZE }, - { "stun", SC_STUN }, - { "sleep", SC_SLEEP }, - { "poison", SC_POISON }, - { "curse", SC_CURSE }, - { "silence", SC_SILENCE }, - { "confusion", SC_CONFUSION }, - { "blind", SC_BLIND }, - { "hiding", SC_HIDING }, - { "sight", SC_SIGHT }, + { "anybad", -1 }, + { "stone", SC_STONE }, + { "freeze", SC_FREEZE }, + { "stun", SC_STUN }, + { "sleep", SC_SLEEP }, + { "poison", SC_POISON }, + { "curse", SC_CURSE }, + { "silence", SC_SILENCE }, + { "confusion", SC_CONFUSION }, + { "blind", SC_BLIND }, + { "hiding", SC_HIDING }, + { "sight", SC_SIGHT }, }, target[] = { - { "target", MST_TARGET }, - { "randomtarget", MST_RANDOM }, - { "self", MST_SELF }, - { "friend", MST_FRIEND }, - { "master", MST_MASTER }, - { "around5", MST_AROUND5 }, - { "around6", MST_AROUND6 }, - { "around7", MST_AROUND7 }, - { "around8", MST_AROUND8 }, - { "around1", MST_AROUND1 }, - { "around2", MST_AROUND2 }, - { "around3", MST_AROUND3 }, - { "around4", MST_AROUND4 }, - { "around", MST_AROUND }, + { "target", MST_TARGET }, + { "randomtarget", MST_RANDOM }, + { "self", MST_SELF }, + { "friend", MST_FRIEND }, + { "master", MST_MASTER }, + { "around5", MST_AROUND5 }, + { "around6", MST_AROUND6 }, + { "around7", MST_AROUND7 }, + { "around8", MST_AROUND8 }, + { "around1", MST_AROUND1 }, + { "around2", MST_AROUND2 }, + { "around3", MST_AROUND3 }, + { "around4", MST_AROUND4 }, + { "around", MST_AROUND }, }; static int last_mob_id = 0; // ensures that only one error message per mob id is printed @@ -4301,8 +4313,8 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current) return true; } - if (mob_id < 0) - { //Prepare global skill. [Skotlex] + if (mob_id < 0) { + //Prepare global skill. [Skotlex] memset(&gms, 0, sizeof (struct mob_skill)); ms = &gms; } else { @@ -4413,8 +4425,8 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current) ms->val[1] = 0; ms->val[4] = 1; //request to return mode to normal. } - if(ms->skill_id == NPC_EMOTION_ON && mob_id>0 && ms->val[1]) - { //Adds a mode to the mob. + if (ms->skill_id == NPC_EMOTION_ON && mob_id>0 && ms->val[1]) { + //Adds a mode to the mob. //Remove aggressive mode when the new mob type is passive. if (!(ms->val[1]&MD_AGGRESSIVE)) ms->val[3]|=MD_AGGRESSIVE; @@ -4432,8 +4444,8 @@ bool mob_parse_row_mobskilldb(char** str, int columns, int current) else ms->msg_id=0; - if (mob_id < 0) - { //Set this skill to ALL mobs. [Skotlex] + if (mob_id < 0) { + //Set this skill to ALL mobs. [Skotlex] mob_id *= -1; for (i = 1; i < MAX_MOB_DB; i++) { @@ -4638,8 +4650,11 @@ void mob_reload(void) { mob->load(false); } +/** + * Clears spawn related information for a script reload. + */ void mob_clear_spawninfo() -{ //Clears spawn related information for a script reload. +{ int i; for (i = 0; i < MAX_MOB_DB; i++) if (mob->db_data[i]) diff --git a/src/map/mob.h b/src/map/mob.h index f3937c0d1..c61d29103 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -106,7 +106,7 @@ struct mob_db { unsigned int base_exp,job_exp; unsigned int mexp; short range2,range3; - short race2; // celest + short race2; // celest unsigned short lv; struct { int nameid,p; } dropitem[MAX_MOB_DROP]; struct { int nameid,p; } mvpitem[MAX_MVP_DROP]; @@ -125,7 +125,7 @@ struct mob_data { struct view_data *vd; struct status_data status, *base_status; //Second one is in case of leveling up mobs, or tiny/large mobs. struct status_change sc; - struct mob_db *db; //For quick data access (saves doing mob_db(md->class_) all the time) [Skotlex] + struct mob_db *db; //For quick data access (saves doing mob_db(md->class_) all the time) [Skotlex] char name[NAME_LENGTH]; struct { unsigned int size : 2; //Small/Big monsters. @@ -193,8 +193,8 @@ struct mob_data { enum { - MST_TARGET = 0, - MST_RANDOM, //Random Target! + MST_TARGET = 0, + MST_RANDOM, //Random Target! MST_SELF, MST_FRIEND, MST_MASTER, @@ -206,9 +206,9 @@ enum { MST_AROUND2, MST_AROUND3, MST_AROUND4, - MST_AROUND = MST_AROUND4, + MST_AROUND = MST_AROUND4, - MSC_ALWAYS = 0x0000, + MSC_ALWAYS = 0x0000, MSC_MYHPLTMAXRATE, MSC_MYHPINRATE, MSC_FRIENDHPLTMAXRATE, diff --git a/src/map/npc.c b/src/map/npc.c index 7378ac470..ce668bfae 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -63,14 +63,16 @@ static struct view_data npc_viewdb2[MAX_NPC_CLASS2_END-MAX_NPC_CLASS2_START]; unsigned int npc_market_qty[MAX_INVENTORY]; static struct script_event_s -{ //Holds pointers to the commonly executed scripts for speedup. [Skotlex] +{ + //Holds pointers to the commonly executed scripts for speedup. [Skotlex] struct event_data *event[UCHAR_MAX]; const char *event_name[UCHAR_MAX]; uint8 event_count; } script_event[NPCE_MAX]; struct view_data* npc_get_viewdata(int class_) -{ //Returns the viewdata for normal npc classes. +{ + //Returns the viewdata for normal npc classes. if( class_ == INVISIBLE_CLASS ) return &npc_viewdb[0]; if (npcdb_checkid(class_) || class_ == WARP_CLASS){ @@ -103,12 +105,12 @@ int npc_get_new_npc_id(void) { } int npc_isnear_sub(struct block_list* bl, va_list args) { - struct npc_data *nd = (struct npc_data*)bl; - - if( nd->option & (OPTION_HIDE|OPTION_INVISIBLE) ) - return 0; + struct npc_data *nd = (struct npc_data*)bl; + + if( nd->option & (OPTION_HIDE|OPTION_INVISIBLE) ) + return 0; - return 1; + return 1; } bool npc_isnear(struct block_list * bl) { @@ -885,9 +887,10 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y) nullpo_retr(1, sd); - // Why not enqueue it? [Inkfish] - //if(sd->npc_id) - // return 1; +#if 0 // Why not enqueue it? [Inkfish] + if(sd->npc_id) + return 1; +#endif // 0 for(i=0;i<map->list[m].npc_num;i++) { if (map->list[m].npc[i]->option&OPTION_INVISIBLE) { @@ -1211,7 +1214,7 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing) { TBL_NPC* nd = BL_CAST(BL_NPC, target); ShowDebug("npc_scriptcont: %s (sd->npc_id=%d) is not %s (id=%d).\n", nd_sd?(char*)nd_sd->name:"'Unknown NPC'", (int)sd->npc_id, - nd?(char*)nd->name:"'Unknown NPC'", (int)id); + nd?(char*)nd->name:"'Unknown NPC'", (int)id); return 1; } @@ -1270,7 +1273,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type) { sd->npc_id = 0; return 1; } - + if (nd->option & OPTION_INVISIBLE) // can't buy if npc is not visible (hack?) return 1; @@ -1807,11 +1810,11 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list) { return npc->buylist_sub(sd,n,item_list,nd->master_nd); if( z > (double)sd->status.zeny ) - return 1; // Not enough Zeny + return 1; // Not enough Zeny if( w + sd->weight > sd->max_weight ) - return 2; // Too heavy + return 2; // Too heavy if( pc->inventoryblank(sd) < new_ ) - return 3; // Not enough space to store items + return 3; // Not enough space to store items pc->payzeny(sd,(int)z,LOG_TYPE_NPC, NULL); @@ -1920,13 +1923,13 @@ int npc_market_buylist(struct map_session_data* sd, unsigned short list_size, st } if( z > (double)sd->status.zeny ) /* TODO find official response for this */ - return 1; // Not enough Zeny + return 1; // Not enough Zeny if( w + sd->weight > sd->max_weight ) /* TODO find official response for this */ - return 1; // Too heavy + return 1; // Too heavy if( pc->inventoryblank(sd) < new_ ) /* TODO find official response for this */ - return 1; // Not enough space to store items + return 1; // Not enough space to store items pc->payzeny(sd,(int)z,LOG_TYPE_NPC, NULL); @@ -2449,7 +2452,7 @@ void npc_parsename(struct npc_data* nd, const char* name, const char* start, con // Support for using Constants in place of NPC View IDs. int npc_parseview(const char* w4, const char* start, const char* buffer, const char* filepath) { int val = -1, i = 0; - char viewid[1024]; // Max size of name from const.txt, see script->read_constdb. + char viewid[1024]; // Max size of name from const.txt, see script->read_constdb. // Extract view ID / constant while (w4[i] != '\0') { @@ -2489,7 +2492,7 @@ bool npc_viewisid(const char * viewid) } } - return true; + return true; } //Add then display an npc warp on map @@ -2839,7 +2842,7 @@ const char* npc_skip_script(const char* start, const char* buffer, const char* f /// <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,{<code>} /// <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>,{<code>} const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, int options, int *retval) { - int x, y, dir = 0, m, xs = 0, ys = 0; // [Valaris] thanks to fov + int x, y, dir = 0, m, xs = 0, ys = 0; // [Valaris] thanks to fov char mapname[32]; struct script_code *scriptroot; int i; @@ -3605,7 +3608,7 @@ const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* st } /*========================================== * Set or disable mapflag on map - * eg : bat_c01 mapflag battleground 2 + * eg : bat_c01<TAB>mapflag<TAB>battleground<TAB>2 * also chking if mapflag conflict with another *------------------------------------------*/ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, int *retval) { @@ -3629,7 +3632,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char } if (w4 && !strcmpi(w4, "off")) - state = 0; //Disable mapflag rather than enable it. [Skotlex] + state = 0; //Disable mapflag rather than enable it. [Skotlex] if (!strcmpi(w3, "nosave")) { char savemap[32]; diff --git a/src/map/npc.h b/src/map/npc.h index 4c904e1ac..9c497ffe9 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -61,7 +61,7 @@ struct npc_data { int touching_id; int64 next_walktime; uint8 dir; - + unsigned size : 2; struct status_data status; diff --git a/src/map/packets.h b/src/map/packets.h index 3240a97a1..bb5222e93 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -1654,128 +1654,128 @@ packet(0x020d,-1); packet(0x0802,18,clif->pPartyBookingRegisterReq,2,4,6); // Booking System packet(0x0803,4); packet(0x0804,8); // Booking System - packet(0x0805,-1); - packet(0x0806,4,clif->pPartyBookingDeleteReq,2);// Booking System - //packet(0x0807,2); - packet(0x0808,4); // Booking System - //packet(0x0809,14); - //packet(0x080A,50); - //packet(0x080B,18); - //packet(0x080C,6); -#endif - - //2009-12-29aRagexeRE + packet(0x0805,-1); + packet(0x0806,4,clif->pPartyBookingDeleteReq,2);// Booking System + //packet(0x0807,2); + packet(0x0808,4); // Booking System + //packet(0x0809,14); + //packet(0x080A,50); + //packet(0x080B,18); + //packet(0x080C,6); +#endif + + //2009-12-29aRagexeRE #if PACKETVER >= 20091229 - packet(0x0804,14,clif->pPartyBookingSearchReq,2,4,6,8,12);// Booking System - packet(0x0806,2,clif->pPartyBookingDeleteReq,0);// Booking System - packet(0x0807,4); - packet(0x0808,14,clif->pPartyBookingUpdateReq,2); // Booking System - packet(0x0809,50); - packet(0x080A,18); - packet(0x080B,6);// Booking System -#endif - - //2010-01-05aRagexeRE + packet(0x0804,14,clif->pPartyBookingSearchReq,2,4,6,8,12);// Booking System + packet(0x0806,2,clif->pPartyBookingDeleteReq,0);// Booking System + packet(0x0807,4); + packet(0x0808,14,clif->pPartyBookingUpdateReq,2); // Booking System + packet(0x0809,50); + packet(0x080A,18); + packet(0x080B,6);// Booking System +#endif + + //2010-01-05aRagexeRE #if PACKETVER >= 20100105 - packet(0x0801,-1,clif->pPurchaseReq2,2,4,8,12); + packet(0x0801,-1,clif->pPurchaseReq2,2,4,8,12); #endif - - //2010-01-26aRagexeRE + + //2010-01-26aRagexeRE #if PACKETVER >= 20100126 - //packet(0x080C,2); - //packet(0x080D,3); - packet(0x080E,14); + //packet(0x080C,2); + //packet(0x080D,3); + packet(0x080E,14); #endif - - //2010-02-09aRagexeRE + + //2010-02-09aRagexeRE #if PACKETVER >= 20100209 - //packet(0x07F0,6); + //packet(0x07F0,6); #endif - - //2010-02-23aRagexeRE + + //2010-02-23aRagexeRE #if PACKETVER >= 20100223 - packet(0x080F,20); + packet(0x080F,20); #endif - - //2010-03-03aRagexeRE + + //2010-03-03aRagexeRE #if PACKETVER >= 20100303 - packet(0x0810,3); - packet(0x0811,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); - //packet(0x0812,86); - //packet(0x0813,6); - //packet(0x0814,6); - //packet(0x0815,-1); - //packet(0x0817,-1); - //packet(0x0818,6); - //packet(0x0819,4); -#endif - - //2010-03-09aRagexeRE + packet(0x0810,3); + packet(0x0811,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); + //packet(0x0812,86); + //packet(0x0813,6); + //packet(0x0814,6); + //packet(0x0815,-1); + //packet(0x0817,-1); + //packet(0x0818,6); + //packet(0x0819,4); +#endif + + //2010-03-09aRagexeRE #if PACKETVER >= 20100309 - packet(0x0813,-1); - //packet(0x0814,2); - //packet(0x0815,6); - packet(0x0816,6); - packet(0x0818,-1); - //packet(0x0819,10); - //packet(0x081A,4); - //packet(0x081B,4); - //packet(0x081C,6); - packet(0x081d,22); - packet(0x081e,8); -#endif - - //2010-03-23aRagexeRE + packet(0x0813,-1); + //packet(0x0814,2); + //packet(0x0815,6); + packet(0x0816,6); + packet(0x0818,-1); + //packet(0x0819,10); + //packet(0x081A,4); + //packet(0x081B,4); + //packet(0x081C,6); + packet(0x081d,22); + packet(0x081e,8); +#endif + + //2010-03-23aRagexeRE #if PACKETVER >= 20100323 - //packet(0x081F,-1); + //packet(0x081F,-1); #endif - - //2010-04-06aRagexeRE + + //2010-04-06aRagexeRE #if PACKETVER >= 20100406 - //packet(0x081A,6); + //packet(0x081A,6); #endif - - //2010-04-13aRagexeRE + + //2010-04-13aRagexeRE #if PACKETVER >= 20100413 - //packet(0x081A,10); - packet(0x0820,11); - //packet(0x0821,2); - //packet(0x0822,9); - //packet(0x0823,-1); -#endif - - //2010-04-14dRagexeRE + //packet(0x081A,10); + packet(0x0820,11); + //packet(0x0821,2); + //packet(0x0822,9); + //packet(0x0823,-1); +#endif + + //2010-04-14dRagexeRE #if PACKETVER >= 20100414 - //packet(0x081B,8); + //packet(0x081B,8); #endif - - //2010-04-20aRagexeRE + + //2010-04-20aRagexeRE #if PACKETVER >= 20100420 - packet(0x0812,8); - packet(0x0814,86); - packet(0x0815,2,clif->pReqCloseBuyingStore,0); - packet(0x0817,6,clif->pReqClickBuyingStore,2); - packet(0x0819,-1,clif->pReqTradeBuyingStore,2,4,8,12); - packet(0x081a,4); - packet(0x081b,10); - packet(0x081c,10); - packet(0x0824,6); -#endif - - //2010-06-01aRagexeRE + packet(0x0812,8); + packet(0x0814,86); + packet(0x0815,2,clif->pReqCloseBuyingStore,0); + packet(0x0817,6,clif->pReqClickBuyingStore,2); + packet(0x0819,-1,clif->pReqTradeBuyingStore,2,4,8,12); + packet(0x081a,4); + packet(0x081b,10); + packet(0x081c,10); + packet(0x0824,6); +#endif + + //2010-06-01aRagexeRE #if PACKETVER >= 20100601 - //packet(0x0825,-1); - //packet(0x0826,4); - packet(0x0835,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); - packet(0x0836,-1); - packet(0x0837,3); - //packet(0x0838,3); -#endif - - //2010-06-08aRagexeRE + //packet(0x0825,-1); + //packet(0x0826,4); + packet(0x0835,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); + packet(0x0836,-1); + packet(0x0837,3); + //packet(0x0838,3); +#endif + + //2010-06-08aRagexeRE #if PACKETVER >= 20100608 - packet(0x0838,2,clif->pSearchStoreInfoNextPage,0); - packet(0x083A,4); // Search Stalls Feature + packet(0x0838,2,clif->pSearchStoreInfoNextPage,0); + packet(0x083A,4); // Search Stalls Feature packet(0x083B,2,clif->pCloseSearchStoreInfo,0); packet(0x083C,12,clif->pSearchStoreInfoListItemClick,2,6,10); packet(0x083D,6); @@ -2415,7 +2415,7 @@ packet(0x020d,-1); packet(0x0873,36,clif->pStoragePassword,0); packet(0x097C,4,clif->pRanklist); #endif - + //2013-08-07Ragexe (Shakto) #if PACKETVER >= 20130807 packet(0x0369,7,clif->pActionRequest,2,6); @@ -2700,7 +2700,7 @@ packet(0x020d,-1); #endif // 2014-04-02gRagexe - Themon -#if PACKETVER >= 20140402 +#if PACKETVER >= 20140402 packet(0x0946,7,clif->pActionRequest,2,6); packet(0x0868,10,clif->pUseSkillToId,2,4,6); packet(0x093F,5,clif->pWalkToXY,2); @@ -2734,7 +2734,7 @@ packet(0x020d,-1); #endif // 2014-04-16aRagexe - Themon -#if PACKETVER >= 20140416 +#if PACKETVER >= 20140416 packet(0x0369,7,clif->pActionRequest,2,6); packet(0x083C,10,clif->pUseSkillToId,2,4,6); packet(0x0437,5,clif->pWalkToXY,2); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 1c6deab96..71471e5c6 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -279,10 +279,10 @@ struct EQUIPITEM_INFO { int HireExpireDate; #endif #if PACKETVER >= 20080102 - unsigned short bindOnEquipType; + unsigned short bindOnEquipType; #endif #if PACKETVER >= 20100629 - unsigned short wItemSpriteNumber; + unsigned short wItemSpriteNumber; #endif #if PACKETVER >= 20120925 struct { @@ -672,7 +672,7 @@ struct packet_bgqueue_register { struct packet_bgqueue_update_info { short PacketType; char bg_name[NAME_LENGTH]; - int position; + int position; } __attribute__((packed)); struct packet_bgqueue_checkstate { diff --git a/src/map/party.c b/src/map/party.c index f4a5c870a..668251b5d 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -11,7 +11,7 @@ #include <stdlib.h> #include <string.h> -#include "atcommand.h" //msg_txt() +#include "atcommand.h" //msg_txt() #include "battle.h" #include "clif.h" #include "instance.h" @@ -41,7 +41,7 @@ struct party_interface party_s; * Used when creating/adding people to a party. [Skotlex] *------------------------------------------*/ void party_fill_member(struct party_member* member, struct map_session_data* sd, unsigned int leader) { - member->account_id = sd->status.account_id; + member->account_id = sd->status.account_id; member->char_id = sd->status.char_id; safestrncpy(member->name, sd->status.name, NAME_LENGTH); member->class_ = sd->status.class_; @@ -87,8 +87,8 @@ TBL_PC* party_sd_check(int party_id, int account_id, int char_id) { if( sd->status.party_id == 0 ) sd->status.party_id = party_id;// auto-join if not in a party - if (sd->status.party_id != party_id) - { //If player belongs to a different party, kick him out. + if (sd->status.party_id != party_id) { + //If player belongs to a different party, kick him out. intif->party_leave(party_id,account_id,char_id); return NULL; } @@ -674,8 +674,8 @@ bool party_changeleader(struct map_session_data *sd, struct map_session_data *ts if (mi == MAX_PARTY) return false; //Shouldn't happen - if (!p->party.member[mi].leader) - { //Need to be a party leader. + if (!p->party.member[mi].leader) { + //Need to be a party leader. clif->message(sd->fd, msg_txt(282)); return false; } @@ -979,14 +979,14 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i if (p && p->party.item&2 && (first_charid || !(battle_config.party_share_type&1))) { //item distribution to party members. - if (battle_config.party_share_type&2) - { //Round Robin + if (battle_config.party_share_type&2) { + //Round Robin TBL_PC* psd; i = p->itemc; do { i++; if (i >= MAX_PARTY) - i = 0; // reset counter to 1st person in party so it'll stop when it reaches "itemc" + i = 0; // reset counter to 1st person in party so it'll stop when it reaches "itemc" if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) || (battle_config.idle_no_share && pc_isidle(psd)) ) continue; @@ -999,9 +999,8 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i target = psd; break; } while (i != p->itemc); - } - else - { //Random pick + } else { + //Random pick TBL_PC* psd[MAX_PARTY]; int count = 0; //Collect pick candidates @@ -1013,11 +1012,12 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i } while (count > 0) { //Pick a random member. i = rnd()%count; - if (pc->additem(psd[i],item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER)) - { //Discard this receiver. + if (pc->additem(psd[i],item_data,item_data->amount,LOG_TYPE_PICKDROP_PLAYER)) { + //Discard this receiver. psd[i] = psd[count-1]; count--; - } else { //Successful pick. + } else { + //Successful pick. target = psd[i]; break; } @@ -1172,7 +1172,7 @@ void party_recruit_register(struct map_session_data *sd, short level, const char memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH); pb_ad->expiretime = (int)time(NULL); - pb_ad->p_detail.level = level; + pb_ad->p_detail.level = level; safestrncpy(pb_ad->p_detail.notice, notice, PB_NOTICE_LENGTH); clif->PartyRecruitRegisterAck(sd, 0); @@ -1185,7 +1185,7 @@ void party_recruit_register(struct map_session_data *sd, short level, const char void party_booking_register(struct map_session_data *sd, short level, short mapid, short* job) { #ifndef PARTY_RECRUIT struct party_booking_ad_info *pb_ad; - int i; + int i; pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id); @@ -1202,7 +1202,7 @@ void party_booking_register(struct map_session_data *sd, short level, short mapi memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH); pb_ad->expiretime = (int)time(NULL); - pb_ad->p_detail.level = level; + pb_ad->p_detail.level = level; pb_ad->p_detail.mapid = mapid; for(i=0;i<PARTY_BOOKING_JOBS;i++) diff --git a/src/map/party.h b/src/map/party.h index d62db23a7..f6cd448a6 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -30,12 +30,12 @@ struct party_data { short *instance; unsigned short instances; struct { - unsigned monk : 1; //There's at least one monk in party? - unsigned sg : 1; //There's at least one Star Gladiator in party? - unsigned snovice :1; //There's a Super Novice - unsigned tk : 1; //There's a taekwon + unsigned monk : 1; ///< There's at least one monk in party? + unsigned sg : 1; ///< There's at least one Star Gladiator in party? + unsigned snovice :1; ///< There's a Super Novice + unsigned tk : 1; ///< There's a taekwon } state; - + /* HPM Custom Struct */ struct HPluginData **hdata; unsigned int hdatac; @@ -46,8 +46,8 @@ struct party_data { #ifndef PARTY_RECRUIT struct party_booking_detail { short level; - short mapid; - short job[PARTY_BOOKING_JOBS]; + short mapid; + short job[PARTY_BOOKING_JOBS]; }; struct party_booking_ad_info { @@ -87,7 +87,7 @@ struct party_interface { struct party_data* (*searchname) (const char* str); int (*getmemberid) (struct party_data* p, struct map_session_data* sd); struct map_session_data* (*getavailablesd) (struct party_data *p); - + int (*create) (struct map_session_data *sd,char *name, int item, int item2); void (*created) (int account_id,int char_id,int fail,int party_id,char *name); int (*request_info) (int party_id, int char_id); diff --git a/src/map/path.c b/src/map/path.c index 9aeb108fa..a7315da3c 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -53,7 +53,7 @@ BHEAP_STRUCT_DECL(node_heap, struct path_node*); /// Estimates the cost from (x0,y0) to (x1,y1). /// This is inadmissible (overestimating) heuristic used by game client. -#define heuristic(x0, y0, x1, y1) (MOVE_COST * (abs((x1) - (x0)) + abs((y1) - (y0)))) // Manhattan distance +#define heuristic(x0, y0, x1, y1) (MOVE_COST * (abs((x1) - (x0)) + abs((y1) - (y0)))) // Manhattan distance /// @} // Translates dx,dy into walking direction @@ -435,7 +435,7 @@ unsigned int distance(int dx, int dy) min = dy; max = dx; } - // coefficients equivalent to ( 123/128 * max ) and ( 51/128 * min ) + // coefficients equivalent to ( 123/128 * max ) and ( 51/128 * min ) return ((( max << 8 ) + ( max << 3 ) - ( max << 4 ) - ( max << 1 ) + ( min << 7 ) - ( min << 5 ) + ( min << 3 ) - ( min << 1 )) >> 8 ); #else diff --git a/src/map/pc.c b/src/map/pc.c index 1e651b321..6ba06c82b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -388,7 +388,8 @@ int pc_setrestartvalue(struct map_session_data *sd,int type) { bst = &sd->base_status; st = &sd->battle_status; - if (type&1) { //Normal resurrection + if (type&1) { + //Normal resurrection st->hp = 1; //Otherwise status->heal may fail if dead. status->heal(&sd->bl, bst->hp, 0, 1); if( st->sp < bst->sp ) @@ -554,7 +555,7 @@ int pc_makesavestatus(struct map_session_data *sd) if(!battle_config.save_clothcolor) sd->status.clothes_color=0; - //Only copy the Cart/Peco/Falcon options, the rest are handled via + //Only copy the Cart/Peco/Falcon options, the rest are handled via //status change load/saving. [Skotlex] #ifdef NEW_CARTS sd->status.option = sd->sc.option&(OPTION_INVISIBLE|OPTION_FALCON|OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR); @@ -643,12 +644,15 @@ int pc_equippoint(struct map_session_data *sd,int n) return 0; //Not equippable by players. ep = sd->inventory_data[n]->equip; - if(sd->inventory_data[n]->look == W_DAGGER || - sd->inventory_data[n]->look == W_1HSWORD || - sd->inventory_data[n]->look == W_1HAXE) { - if( (pc->checkskill(sd,AS_LEFT) > 0 || - (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN || - (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO) ) { //Kagerou and Oboro can dual wield daggers. [Rytech] + if (sd->inventory_data[n]->look == W_DAGGER + || sd->inventory_data[n]->look == W_1HSWORD + || sd->inventory_data[n]->look == W_1HAXE + ) { + if (pc->checkskill(sd,AS_LEFT) > 0 + || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN + || (sd->class_&MAPID_UPPERMASK) == MAPID_KAGEROUOBORO + ) { + //Kagerou and Oboro can dual wield daggers. [Rytech] if( ep == EQP_HAND_R ) return EQP_ARMS; if( ep == EQP_SHADOW_WEAPON ) @@ -1201,8 +1205,8 @@ int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl) int class_; if (!sd || !bl || pos < 0 || pos > 2) return 0; - if (sd->hate_mob[pos] != -1) - { //Can't change hate targets. + if (sd->hate_mob[pos] != -1) { + //Can't change hate targets. clif->hate_info(sd, pos, sd->hate_mob[pos], 0); //Display current return 0; } @@ -1830,10 +1834,10 @@ int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_ski return 0; } - spell[i].flag = src_skill; - spell[i].id = id; - spell[i].lv = lv; - spell[i].rate = rate; + spell[i].flag = src_skill; + spell[i].id = id; + spell[i].lv = lv; + spell[i].rate = rate; spell[i].card_id = card_id; return 1; } @@ -1910,8 +1914,8 @@ int pc_bonus_item_drop(struct s_add_drop *drop, const short max, short id, short && race > 0 ) { drop[i].race |= race; - if(drop[i].rate > 0 && rate > 0) - { //Both are absolute rates. + if (drop[i].rate > 0 && rate > 0) { + //Both are absolute rates. if (drop[i].rate < rate) drop[i].rate = rate; } else @@ -2308,19 +2312,19 @@ int pc_bonus(struct map_session_data *sd,int type,int val) { break; } break; - case SP_SPEED_RATE: //Non stackable increase + case SP_SPEED_RATE: //Non stackable increase if(sd->state.lr_flag != 2) sd->bonus.speed_rate = min(sd->bonus.speed_rate, -val); break; - case SP_SPEED_ADDRATE: //Stackable increase + case SP_SPEED_ADDRATE: //Stackable increase if(sd->state.lr_flag != 2) sd->bonus.speed_add_rate -= val; break; - case SP_ASPD: //Raw increase + case SP_ASPD: //Raw increase if(sd->state.lr_flag != 2) sd->bonus.aspd_add -= 10*val; break; - case SP_ASPD_RATE: //Stackable increase - Made it linear as per rodatazone + case SP_ASPD_RATE: //Stackable increase - Made it linear as per rodatazone if(sd->state.lr_flag != 2) #ifndef RENEWAL_ASPD bst->aspd_rate -= 10*val; @@ -2533,7 +2537,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) { if(sd->state.lr_flag != 2) sd->bonus.magic_damage_return += val; break; - case SP_ALL_STATS: // [Valaris] + case SP_ALL_STATS: // [Valaris] if(sd->state.lr_flag!=2) { sd->param_bonus[SP_STR-SP_STR]+=val; sd->param_bonus[SP_AGI-SP_STR]+=val; @@ -2543,13 +2547,13 @@ int pc_bonus(struct map_session_data *sd,int type,int val) { sd->param_bonus[SP_LUK-SP_STR]+=val; } break; - case SP_AGI_VIT: // [Valaris] + case SP_AGI_VIT: // [Valaris] if(sd->state.lr_flag!=2) { sd->param_bonus[SP_AGI-SP_STR]+=val; sd->param_bonus[SP_VIT-SP_STR]+=val; } break; - case SP_AGI_DEX_STR: // [Valaris] + case SP_AGI_DEX_STR: // [Valaris] if(sd->state.lr_flag!=2) { sd->param_bonus[SP_AGI-SP_STR]+=val; sd->param_bonus[SP_DEX-SP_STR]+=val; @@ -2593,7 +2597,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) { sd->bonus.classchange=val; break; case SP_LONG_ATK_RATE: - if(sd->state.lr_flag != 2) //[Lupus] it should stack, too. As any other cards rate bonuses + if(sd->state.lr_flag != 2) //[Lupus] it should stack, too. As any other cards rate bonuses sd->bonus.long_attack_atk_rate+=val; break; case SP_BREAK_WEAPON_RATE: @@ -3920,10 +3924,10 @@ int pc_getzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type, /** * Searches for the specified item ID in inventory and return its inventory index. - * + * * If the item is found, the returned value is guaranteed to be a valid index * (non-negative, smaller than MAX_INVENTORY). - * + * * @param sd Character to search on. * @param item_id The item ID to search. * @return the inventory index of the first instance of the requested item. @@ -3940,14 +3944,14 @@ int pc_search_inventory(struct map_session_data *sd, int item_id) { /*========================================== * Attempt to add a new item to inventory. * Return: - 0 = success - 1 = invalid itemid not found or negative amount - 2 = overweight - 3 = ? - 4 = no free place found - 5 = max amount reached - 6 = ? - 7 = stack limitation + * 0 = success + * 1 = invalid itemid not found or negative amount + * 2 = overweight + * 3 = ? + * 4 = no free place found + * 5 = max amount reached + * 6 = ? + * 7 = stack limitation *------------------------------------------*/ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type) { @@ -4060,11 +4064,11 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l * Remove an item at index n from inventory by amount. * Parameters : * @type - * 1 : don't notify deletion - * 2 : don't notify weight change + * 1 : don't notify deletion + * 2 : don't notify weight change * Return: - * 0 = success - * 1 = invalid itemid or negative amount + * 0 = success + * 1 = invalid itemid or negative amount *------------------------------------------*/ int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason, e_log_pick_type log_type) { @@ -4094,8 +4098,8 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reas /*========================================== * Attempt to drop an item. * Return: - * 0 = fail - * 1 = success + * 0 = fail + * 1 = success *------------------------------------------*/ int pc_dropitem(struct map_session_data *sd,int n,int amount) { @@ -4137,8 +4141,8 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) /*========================================== * Attempt to pick up an item. * Return: - * 0 = fail - * 1 = success + * 0 = fail + * 1 = success *------------------------------------------*/ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) { @@ -4151,7 +4155,7 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) nullpo_ret(fitem); if(!check_distance_bl(&fitem->bl, &sd->bl, 2) && sd->ud.skill_id!=BS_GREED) - return 0; // Distance is too far + return 0; // Distance is too far if( pc_has_permission(sd,PC_PERM_DISABLE_PICK_UP) ) return 0; @@ -4208,8 +4212,8 @@ int pc_takeitem(struct map_session_data *sd,struct flooritem_data *fitem) /*========================================== * Check if item is usable. * Return: - * 0 = no - * 1 = yes + * 0 = no + * 1 = yes *------------------------------------------*/ int pc_isUseitem(struct map_session_data *sd,int n) { @@ -4392,8 +4396,8 @@ int pc_isUseitem(struct map_session_data *sd,int n) /*========================================== * Last checks to use an item. * Return: - * 0 = fail - * 1 = success + * 0 = fail + * 1 = success *------------------------------------------*/ int pc_useitem(struct map_session_data *sd,int n) { int64 tick = timer->gettick(); @@ -4547,8 +4551,8 @@ int pc_useitem(struct map_session_data *sd,int n) { /*========================================== * Add item on cart for given index. * Return: - * 0 = success - * 1 = fail + * 0 = success + * 1 = fail *------------------------------------------*/ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type) { @@ -4567,8 +4571,8 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun return 1; } - if( !itemdb_cancartstore(item_data, pc_get_group_level(sd)) || (item_data->bound > IBT_ACCOUNT && !pc_can_give_bound_items(sd))) - { // Check item trade restrictions [Skotlex] + if (!itemdb_cancartstore(item_data, pc_get_group_level(sd)) || (item_data->bound > IBT_ACCOUNT && !pc_can_give_bound_items(sd))) { + // Check item trade restrictions clif->message (sd->fd, msg_txt(264)); return 1;/* TODO: there is no official response to this? */ } @@ -4581,7 +4585,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun { ARR_FIND( 0, MAX_CART, i, sd->status.cart[i].nameid == item_data->nameid && sd->status.cart[i].bound == item_data->bound && - sd->status.cart[i].card[0] == item_data->card[0] && sd->status.cart[i].card[1] == item_data->card[1] && + sd->status.cart[i].card[0] == item_data->card[0] && sd->status.cart[i].card[1] == item_data->card[1] && sd->status.cart[i].card[2] == item_data->card[2] && sd->status.cart[i].card[3] == item_data->card[3] ); }; @@ -4616,8 +4620,8 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun /*========================================== * Delete item on cart for given index. * Return: - * 0 = success - * 1 = fail + * 0 = success + * 1 = fail *------------------------------------------*/ int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type) { struct item_data * data; @@ -4645,8 +4649,8 @@ int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_ /*========================================== * Transfer item from inventory to cart. * Return: - * 0 = fail - * 1 = succes + * 0 = fail + * 1 = succes *------------------------------------------*/ int pc_putitemtocart(struct map_session_data *sd,int idx,int amount) { @@ -4672,8 +4676,8 @@ int pc_putitemtocart(struct map_session_data *sd,int idx,int amount) /*========================================== * Get number of item in cart. * Return: - -1 = itemid not found or no amount found - x = remaining itemid on cart after get + * -1 = itemid not found or no amount found + * x = remaining itemid on cart after get *------------------------------------------*/ int pc_cartitem_amount(struct map_session_data* sd, int idx, int amount) { @@ -4691,8 +4695,8 @@ int pc_cartitem_amount(struct map_session_data* sd, int idx, int amount) /*========================================== * Retrieve an item at index idx from cart. * Return: - * 0 = player not found or (FIXME) succes (from pc->cart_delitem) - * 1 = failure + * 0 = player not found or (FIXME) succes (from pc->cart_delitem) + * 1 = failure *------------------------------------------*/ int pc_getitemfromcart(struct map_session_data *sd,int idx,int amount) { @@ -4772,8 +4776,8 @@ int pc_show_steal(struct block_list *bl,va_list ap) /*========================================== * Steal an item from bl (mob). * Return: - * 0 = fail - * 1 = succes + * 0 = fail + * 1 = succes *------------------------------------------*/ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skill_lv) { @@ -4799,7 +4803,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil map->list[bl->m].flag.nomobloot || // check noloot map flag [Lorky] (battle_config.skill_steal_max_tries && //Reached limit of steal attempts. [Lupus] md->state.steal_flag++ >= battle_config.skill_steal_max_tries) - ) { //Can't steal from + ) { //Can't steal from md->state.steal_flag = UCHAR_MAX; return 0; } @@ -5118,8 +5122,8 @@ int pc_setpos(struct map_session_data* sd, unsigned short map_index, int x, int * Warp player sd to random location on current map. * May fail if no walkable cell found (1000 attempts). * Return: - * 0 = fail or FIXME success (from pc->setpos) - * x(1|2) = fail + * 0 = fail or FIXME success (from pc->setpos) + * x(1|2) = fail *------------------------------------------*/ int pc_randomwarp(struct map_session_data *sd, clr_type type) { int x,y,i=0; @@ -5239,7 +5243,7 @@ int pc_checkskill2(struct map_session_data *sd,uint16 index) { * Chk if we still have the correct weapon to continue the skill (actually status) * If not ending it * Return - * 0 - No status found or all done + * 0 - No status found or all done *------------------------------------------*/ int pc_checkallowskill(struct map_session_data *sd) { @@ -5735,7 +5739,7 @@ const char* job_name(int class_) case JOB_ARCH_BISHOP_T: // 659 case JOB_MECHANIC_T: // 660 case JOB_GUILLOTINE_CROSS_T: // 661 - return msg_txt(656 - JOB_RUNE_KNIGHT_T+class_); + return msg_txt(656 - JOB_RUNE_KNIGHT_T+class_); case JOB_ROYAL_GUARD: // 631 case JOB_SORCERER: // 632 @@ -5753,7 +5757,7 @@ const char* job_name(int class_) case JOB_SURA_T: // 666 case JOB_GENETIC_T: // 667 case JOB_SHADOW_CHASER_T: // 668 - return msg_txt(662 - JOB_ROYAL_GUARD_T+class_); + return msg_txt(662 - JOB_ROYAL_GUARD_T+class_); case JOB_RUNE_KNIGHT2: return msg_txt(625); @@ -5855,7 +5859,7 @@ int pc_follow_timer(int tid, int64 tick, int id, intptr_t data) { pc->setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT); } sd->followtimer = timer->add( - tick + 1000, // increase time a bit to loosen up map's load + tick + 1000, // increase time a bit to loosen up map's load pc->follow_timer, sd->bl.id, 0); return 0; } @@ -5907,7 +5911,7 @@ int pc_checkbaselevelup(struct map_session_data *sd) { } while ((next=pc->nextbaseexp(sd)) > 0 && sd->status.base_exp >= next); - if (battle_config.pet_lv_rate && sd->pd) //<Skotlex> update pet's level + if (battle_config.pet_lv_rate && sd->pd) //<Skotlex> update pet's level status_calc_pet(sd->pd,SCO_NONE); clif->updatestatus(sd,SP_STATUSPOINT); @@ -6109,12 +6113,12 @@ bool pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned in *------------------------------------------*/ unsigned int pc_maxbaselv(struct map_session_data *sd) { - return pc->max_level[pc->class2idx(sd->status.class_)][0]; + return pc->max_level[pc->class2idx(sd->status.class_)][0]; } unsigned int pc_maxjoblv(struct map_session_data *sd) { - return pc->max_level[pc->class2idx(sd->status.class_)][1]; + return pc->max_level[pc->class2idx(sd->status.class_)][1]; } /*========================================== @@ -6145,8 +6149,8 @@ unsigned int pc_thisbaseexp(struct map_session_data *sd) /*========================================== * job level exp lookup * Return: - * 0 = not found - * x = exp for level + * 0 = not found + * x = exp for level *------------------------------------------*/ //Job exp needed for next level. @@ -6470,7 +6474,7 @@ int pc_allskillup(struct map_session_data *sd) continue; //Cannot be learned normally. sd->status.skill[idx].id = id; - sd->status.skill[idx].lv = skill->tree_get_max(id, sd->status.class_); // celest + sd->status.skill[idx].lv = skill->tree_get_max(id, sd->status.class_); // celest } } status_calc_pc(sd,SCO_NONE); @@ -6508,7 +6512,7 @@ int pc_resetlvl(struct map_session_data* sd,int type) sd->status.dex=1; sd->status.luk=1; if(sd->status.class_ == JOB_NOVICE_HIGH) { - sd->status.status_point=100; // not 88 [celest] + sd->status.status_point=100; // not 88 [celest] // give platinum skills upon changing pc->skill(sd,142,1,0); pc->skill(sd,143,1,0); @@ -6547,12 +6551,12 @@ int pc_resetlvl(struct map_session_data* sd,int type) clif->updatestatus(sd,SP_NEXTJOBEXP); clif->updatestatus(sd,SP_SKILLPOINT); - clif->updatestatus(sd,SP_USTR); // Updates needed stat points - Valaris + clif->updatestatus(sd,SP_USTR); // Updates needed stat points - Valaris clif->updatestatus(sd,SP_UAGI); clif->updatestatus(sd,SP_UVIT); clif->updatestatus(sd,SP_UINT); clif->updatestatus(sd,SP_UDEX); - clif->updatestatus(sd,SP_ULUK); // End Addition + clif->updatestatus(sd,SP_ULUK); // End Addition for(i=0;i<EQI_MAX;i++) { // unequip items that can't be equipped by base 1 [Valaris] if(sd->equip_index[i] >= 0) @@ -6575,10 +6579,10 @@ int pc_resetstate(struct map_session_data* sd) { nullpo_ret(sd); - if (battle_config.use_statpoint_table) - { // New statpoint table used here - Dexity - if (sd->status.base_level > MAX_LEVEL) - { //pc->statp[] goes out of bounds, can't reset! + if (battle_config.use_statpoint_table) { + // New statpoint table used here - Dexity + if (sd->status.base_level > MAX_LEVEL) { + //pc->statp[] goes out of bounds, can't reset! ShowError("pc_resetstate: Can't reset stats of %d:%d, the base level (%d) is greater than the max level supported (%d)\n", sd->status.account_id, sd->status.char_id, sd->status.base_level, MAX_LEVEL); return 0; @@ -6613,12 +6617,12 @@ int pc_resetstate(struct map_session_data* sd) clif->updatestatus(sd,SP_DEX); clif->updatestatus(sd,SP_LUK); - clif->updatestatus(sd,SP_USTR); // Updates needed stat points - Valaris + clif->updatestatus(sd,SP_USTR); // Updates needed stat points - Valaris clif->updatestatus(sd,SP_UAGI); clif->updatestatus(sd,SP_UVIT); clif->updatestatus(sd,SP_UINT); clif->updatestatus(sd,SP_UDEX); - clif->updatestatus(sd,SP_ULUK); // End Addition + clif->updatestatus(sd,SP_ULUK); // End Addition clif->updatestatus(sd,SP_STATUSPOINT); @@ -7001,12 +7005,13 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { case BL_MOB: { struct mob_data *md=(struct mob_data *)src; - if(md->target_id==sd->bl.id) + if (md->target_id==sd->bl.id) mob->unlocktarget(md,tick); - if(battle_config.mobs_level_up && md->status.hp && - (unsigned int)md->level < pc->maxbaselv(sd) && - !md->guardian_data && !md->special_state.ai// Guardians/summons should not level. [Skotlex] - ) { // monster level up [Valaris] + if (battle_config.mobs_level_up && md->status.hp + && (unsigned int)md->level < pc->maxbaselv(sd) + && !md->guardian_data && !md->special_state.ai// Guardians/summons should not level. [Skotlex] + ) { + // monster level up [Valaris] clif->misceffect(&md->bl,0); md->level++; status_calc_mob(md, SCO_NONE); @@ -7048,19 +7053,20 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { // karma going down = more 'good' / more honourable. // The Karma System way... - if (sd->status.karma > ssd->status.karma) { // If player killed was more evil + if (sd->status.karma > ssd->status.karma) { + // If player killed was more evil sd->status.karma--; ssd->status.karma--; } - else if (sd->status.karma < ssd->status.karma) // If player killed was more good + else if (sd->status.karma < ssd->status.karma) // If player killed was more good ssd->status.karma++; // or the PK System way... - if (sd->status.karma > 0) // player killed is dishonourable? + if (sd->status.karma > 0) // player killed is dishonourable? ssd->status.karma--; // honour points earned - sd->status.karma++; // honour points lost + sd->status.karma++; // honour points lost // To-do: Receive exp on certain occasions #endif @@ -7118,7 +7124,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } if(base_penalty) { - if (battle_config.pk_mode && src && src->type==BL_PC) + if (battle_config.pk_mode && src && src->type==BL_PC) base_penalty*=2; if( sd->status.mod_death != 100 ) base_penalty = base_penalty * sd->status.mod_death / 100; @@ -7140,7 +7146,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { } if(base_penalty) { - if (battle_config.pk_mode && src && src->type==BL_PC) + if (battle_config.pk_mode && src && src->type==BL_PC) base_penalty*=2; if( sd->status.mod_death != 100 ) base_penalty = base_penalty * sd->status.mod_death / 100; @@ -7309,32 +7315,32 @@ int pc_readparam(struct map_session_data* sd,int type) case SP_FAME: val = sd->status.fame; break; case SP_KILLERRID: val = sd->killerrid; break; case SP_KILLEDRID: val = sd->killedrid; break; - case SP_SLOTCHANGE: val = sd->status.slotchange; break; - case SP_CHARRENAME: val = sd->status.rename; break; + case SP_SLOTCHANGE: val = sd->status.slotchange; break; + case SP_CHARRENAME: val = sd->status.rename; break; case SP_MOD_EXP: val = sd->status.mod_exp; break; case SP_MOD_DROP: val = sd->status.mod_drop; break; case SP_MOD_DEATH: val = sd->status.mod_death; break; case SP_CRITICAL: val = sd->battle_status.cri/10; break; case SP_ASPD: val = (2000-sd->battle_status.amotion)/10; break; - case SP_BASE_ATK: val = sd->battle_status.batk; break; - case SP_DEF1: val = sd->battle_status.def; break; - case SP_DEF2: val = sd->battle_status.def2; break; - case SP_MDEF1: val = sd->battle_status.mdef; break; - case SP_MDEF2: val = sd->battle_status.mdef2; break; - case SP_HIT: val = sd->battle_status.hit; break; - case SP_FLEE1: val = sd->battle_status.flee; break; - case SP_FLEE2: val = sd->battle_status.flee2; break; - case SP_DEFELE: val = sd->battle_status.def_ele; break; + case SP_BASE_ATK: val = sd->battle_status.batk; break; + case SP_DEF1: val = sd->battle_status.def; break; + case SP_DEF2: val = sd->battle_status.def2; break; + case SP_MDEF1: val = sd->battle_status.mdef; break; + case SP_MDEF2: val = sd->battle_status.mdef2; break; + case SP_HIT: val = sd->battle_status.hit; break; + case SP_FLEE1: val = sd->battle_status.flee; break; + case SP_FLEE2: val = sd->battle_status.flee2; break; + case SP_DEFELE: val = sd->battle_status.def_ele; break; #ifndef RENEWAL_CAST case SP_VARCASTRATE: #endif case SP_CASTRATE: val = sd->castrate+=val; break; - case SP_MAXHPRATE: val = sd->hprate; break; - case SP_MAXSPRATE: val = sd->sprate; break; - case SP_SPRATE: val = sd->dsprate; break; - case SP_SPEED_RATE: val = sd->bonus.speed_rate; break; + case SP_MAXHPRATE: val = sd->hprate; break; + case SP_MAXSPRATE: val = sd->sprate; break; + case SP_SPRATE: val = sd->dsprate; break; + case SP_SPEED_RATE: val = sd->bonus.speed_rate; break; case SP_SPEED_ADDRATE: val = sd->bonus.speed_add_rate; break; case SP_ASPD_RATE: #ifndef RENEWAL_ASPD @@ -7847,7 +7853,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) for(i=0;i<EQI_MAX;i++) { if(sd->equip_index[i] >= 0) if(!pc->isequip(sd,sd->equip_index[i])) - pc->unequipitem(sd,sd->equip_index[i],2); // unequip invalid item for class + pc->unequipitem(sd,sd->equip_index[i],2); // unequip invalid item for class } //Change look, if disguised, you need to undisguise @@ -7911,7 +7917,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) chrif->buildfamelist(); } else if (sd->status.fame > 0) { //It may be that now they are famous? - switch (sd->class_&MAPID_UPPERMASK) { + switch (sd->class_&MAPID_UPPERMASK) { case MAPID_BLACKSMITH: case MAPID_ALCHEMIST: case MAPID_TAEKWON: @@ -7958,7 +7964,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) clif->skillinfoblock(sd); return 0; break; - case LOOK_HAIR: //Use the battle_config limits! [Skotlex] + case LOOK_HAIR: //Use the battle_config limits! [Skotlex] val = cap_value(val, MIN_HAIR_STYLE, MAX_HAIR_STYLE); if (sd->status.hair != val) { @@ -7980,7 +7986,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) case LOOK_HEAD_MID: sd->status.head_mid=val; break; - case LOOK_HAIR_COLOR: //Use the battle_config limits! [Skotlex] + case LOOK_HAIR_COLOR: //Use the battle_config limits! [Skotlex] val = cap_value(val, MIN_HAIR_COLOR, MAX_HAIR_COLOR); if (sd->status.hair_color != val) { @@ -7990,7 +7996,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) GMI_HAIR_COLOR,&sd->status.hair_color,sizeof(sd->status.hair_color)); } break; - case LOOK_CLOTHES_COLOR: //Use the battle_config limits! [Skotlex] + case LOOK_CLOTHES_COLOR: //Use the battle_config limits! [Skotlex] val = cap_value(val, MIN_CLOTH_COLOR, MAX_CLOTH_COLOR); sd->status.clothes_color=val; @@ -8154,7 +8160,7 @@ int pc_setcart(struct map_session_data *sd,int type) { } /* FIXME: These setter methods are inconsistent in their class/skill checks. - They should be changed so that they all either do or skip the checks.*/ + * They should be changed so that they all either do or skip the checks.*/ /** * Gives/removes a falcon. @@ -8310,7 +8316,7 @@ bool pc_can_talk( struct map_session_data *sd ) { int pc_candrop(struct map_session_data *sd, struct item *item) { if( item && (item->expire_time || (item->bound && !pc_can_give_bound_items(sd))) ) - return 0; + return 0; if( !pc_can_give_items(sd) ) //check if this GM level can drop items return 0; return (itemdb_isdropable(item, pc_get_group_level(sd))); @@ -8847,13 +8853,13 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) ShowInfo("equip %d(%d) %x:%x\n",sd->status.inventory[n].nameid,n,id?id->equip:0,req_pos); if(!pc->isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || sd->status.inventory[n].attribute==1 ) { // [Valaris] // FIXME: pc->isequip: equip level failure uses 2 instead of 0 - clif->equipitemack(sd,n,0,EIA_FAIL); // fail + clif->equipitemack(sd,n,0,EIA_FAIL); // fail return 0; } if (sd->sc.data[SC_BERSERK] || sd->sc.data[SC_NO_SWITCH_EQUIP]) { - clif->equipitemack(sd,n,0,EIA_FAIL); // fail + clif->equipitemack(sd,n,0,EIA_FAIL); // fail return 0; } @@ -8868,7 +8874,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) if (pos == EQP_ACC) //User specified both slots.. pos = sd->equip_index[EQI_ACC_R] >= 0 ? EQP_ACC_L : EQP_ACC_R; } else if(pos == EQP_ARMS && id->equip == EQP_HAND_R) { //Dual wield capable weapon. - pos = (req_pos&EQP_ARMS); + pos = (req_pos&EQP_ARMS); if (pos == EQP_ARMS) //User specified both slots, pick one for them. pos = sd->equip_index[EQI_HAND_R] >= 0 ? EQP_HAND_L : EQP_HAND_R; } else if(pos == EQP_SHADOW_ACC) { //Accesories should only go in one of the two, @@ -8876,13 +8882,13 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) if (pos == EQP_SHADOW_ACC) //User specified both slots.. pos = sd->equip_index[EQI_SHADOW_ACC_R] >= 0 ? EQP_SHADOW_ACC_L : EQP_SHADOW_ACC_R; } else if( pos == EQP_SHADOW_ARMS && id->equip == EQP_SHADOW_WEAPON) { //Dual wield capable weapon. - pos = (req_pos&EQP_SHADOW_ARMS); + pos = (req_pos&EQP_SHADOW_ARMS); if (pos == EQP_SHADOW_ARMS) //User specified both slots, pick one for them. pos = sd->equip_index[EQI_SHADOW_WEAPON] >= 0 ? EQP_SHADOW_SHIELD : EQP_SHADOW_WEAPON; } - if (pos&EQP_HAND_R && battle_config.use_weapon_skill_range&BL_PC) - { //Update skill-block range database when weapon range changes. [Skotlex] + if (pos&EQP_HAND_R && battle_config.use_weapon_skill_range&BL_PC) { + //Update skill-block range database when weapon range changes. [Skotlex] i = sd->equip_index[EQI_HAND_R]; if (i < 0 || !sd->inventory_data[i]) //No data, or no weapon equipped flag = 1; @@ -9414,8 +9420,8 @@ int pc_calc_pvprank_timer(int tid, int64 tick, int id, intptr_t data) { /*========================================== * Checking if sd is married * Return: - * partner_id = yes - * 0 = no + * partner_id = yes + * 0 = no *------------------------------------------*/ int pc_ismarried(struct map_session_data *sd) { @@ -9429,8 +9435,8 @@ int pc_ismarried(struct map_session_data *sd) /*========================================== * Marry player sd to player dstsd * Return: - * -1 = fail - * 0 = success + * -1 = fail + * 0 = success *------------------------------------------*/ int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd) { @@ -9446,8 +9452,8 @@ int pc_marriage(struct map_session_data *sd,struct map_session_data *dstsd) /*========================================== * Divorce sd from its partner * Return: - * -1 = fail - * 0 = success + * -1 = fail + * 0 = success *------------------------------------------*/ int pc_divorce(struct map_session_data *sd) { @@ -10199,11 +10205,11 @@ void pc_read_skill_tree(void) { libconfig->destroy(&skill_tree_conf); - /* lets update all players skill tree */ - iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) - clif->skillinfoblock(sd); - mapit->free(iter); + /* lets update all players skill tree */ + iter = mapit_getallusers(); + for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) + clif->skillinfoblock(sd); + mapit->free(iter); } bool pc_readdb_levelpenalty(char* fields[], int columns, int current) { #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP) @@ -10291,7 +10297,7 @@ int pc_readdb(void) { //Reverse check in case the array has a bunch of trailing zeros... [Skotlex] //The reasoning behind the -2 is this... if the max level is 5, then the array //should look like this: - //0: x, 1: x, 2: x: 3: x 4: 0 <- last valid value is at 3. + //0: x, 1: x, 2: x: 3: x 4: 0 <- last valid value is at 3. while ((ui = pc->max_level[job][type]) >= 2 && pc->exp_table[job][type][ui-2] <= 0) pc->max_level[job][type]--; if (pc->max_level[job][type] < maxlv) { @@ -10303,7 +10309,7 @@ int pc_readdb(void) { pc->exp_table[job][type][ui] = pc->exp_table[job][type][ui-1]; pc->max_level[job][type] = maxlv; } -// ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job_id, pc->max_level[job][type]); + //ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job_id, pc->max_level[job][type]); for (i = 1; i < job_count; i++) { job_id = jobs[i]; if (!pcdb_checkid(job_id)) { @@ -10313,7 +10319,7 @@ int pc_readdb(void) { job = pc->class2idx(job_id); memcpy(pc->exp_table[job][type], pc->exp_table[jobs[0]][type], sizeof(pc->exp_table[0][0])); pc->max_level[job][type] = maxlv; -// ShowDebug("%s - Class %d: %u\n", type?"Job":"Base", job_id, pc->max_level[job][type]); + //ShowDebug("%s - Class %d: %u\n", type?"Job":"Base", job_id, pc->max_level[job][type]); } } fclose(fp); diff --git a/src/map/pc.h b/src/map/pc.h index b7a0b099c..aa2bb0e74 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -29,7 +29,7 @@ #define MAX_PC_BONUS 10 #define MAX_PC_SKILL_REQUIRE 5 #define MAX_PC_FEELHATE 3 -#define PVP_CALCRANK_INTERVAL 1000 // PVP calculation interval +#define PVP_CALCRANK_INTERVAL 1000 // PVP calculation interval //Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index //where the arrows are equipped) @@ -80,7 +80,7 @@ struct weapon_data { } hp_drain[RC_MAX], sp_drain[RC_MAX]; struct { short class_, rate; - } add_dmg[MAX_PC_BONUS]; + } add_dmg[MAX_PC_BONUS]; struct { short flag, rate; unsigned char ele; @@ -145,7 +145,7 @@ struct map_session_data { unsigned int snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used. unsigned int abra_flag : 2; // Abracadabra bugfix by Aru unsigned int autocast : 1; // Autospell flag [Inkfish] - unsigned int autotrade : 2; //By Fantik + unsigned int autotrade : 2; //By Fantik unsigned int showdelay :1; unsigned int showexp :1; unsigned int showzeny :1; @@ -202,13 +202,13 @@ struct map_session_data { unsigned int bonus_coma : 1; } special_state; int login_id1, login_id2; - unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex] - + unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex] + /// Groups & permissions int group_id; GroupSettings *group; unsigned int extra_temp_permissions; /* permissions from @addperm */ - + struct mmo_charstatus status; struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups) short equip_index[EQI_MAX]; @@ -301,7 +301,7 @@ struct map_session_data { } hp_loss, sp_loss, hp_regen, sp_regen; struct { short class_, rate; - } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS]; + } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS]; struct s_add_drop add_drop[MAX_PC_BONUS]; struct { int nameid; @@ -349,7 +349,7 @@ struct map_session_data { short sp_gain_value, hp_gain_value, magic_sp_gain_value, magic_hp_gain_value; short sp_vanish_rate; short sp_vanish_per, sp_vanish_trigger; - unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest] + unsigned short unbreakable; // chance to prevent ANY equipment breaking [celest] unsigned short unbreakable_equip; //100% break resistance on certain equipment unsigned short unstripable_equip; int fixcastrate,varcastrate; @@ -362,7 +362,7 @@ struct map_session_data { int matk_rate; int critical_rate,hit_rate,flee_rate,flee2_rate,def_rate,def2_rate,mdef_rate,mdef2_rate; int itemid; - short itemindex; //Used item's index in sd->inventory [Skotlex] + short itemindex; //Used item's index in sd->inventory [Skotlex] short catch_target_class; // pet catching, stores a pet class to catch (short now) [zzo] short spiritball, spiritball_old; int spirit_timer[MAX_SPIRITBALL]; @@ -400,7 +400,7 @@ struct map_session_data { struct s_search_store_info searchstore; struct pet_data *pd; - struct homun_data *hd; // [blackhole89] + struct homun_data *hd; // [blackhole89] struct mercenary_data *md; struct elemental_data *ed; @@ -481,14 +481,14 @@ struct map_session_data { struct pc_combos *combos; unsigned char combo_count; - + /** * Guarantees your friend request is legit (for bugreport:4629) **/ int friend_req; int shadowform_id; - + /* [Ind/Hercules] */ struct hChSysCh **channels; unsigned char channel_count; @@ -497,14 +497,14 @@ struct map_session_data { unsigned char fontcolor; unsigned int fontcolor_tid; int64 hchsysch_tick; - + /* [Ind/Hercules] */ struct sc_display_entry **sc_display; unsigned char sc_display_count; - + short *instance; unsigned short instances; - + /* Possible Thanks to Yommy~! */ struct { unsigned int ready : 1;/* did he accept the 'match is about to start, enter' dialog? */ @@ -515,26 +515,26 @@ struct map_session_data { int *queues; unsigned int queues_count; - + /* Made Possible Thanks to Yommy~! */ unsigned int cryptKey; ///< Packet obfuscation key to be used for the next received packet unsigned short (*parse_cmd_func)(int fd, struct map_session_data *sd); ///< parse_cmd_func used by this player - + unsigned char delayed_damage;//ref. counter bugreport:7307 [Ind/Hercules] - + /* HPM Custom Struct */ struct HPluginData **hdata; unsigned int hdatac; - + /* expiration_time timer id */ int expiration_tid; time_t expiration_time; - + /* */ struct { unsigned int second,third; } sktree; - + /** * Account/Char variables & array control of those variables **/ @@ -542,14 +542,14 @@ struct map_session_data { unsigned char vars_received;/* char loading is only complete when you get it all. */ bool vars_ok; bool vars_dirty; - + struct { short stage; short prizeIdx; short prizeStage; bool claimPrize; } roulette; - + // temporary debugging of bug #3504 const char* delunit_prevfile; int delunit_prevline; @@ -622,13 +622,13 @@ struct map_session_data { //JOB_NOVICE isn't checked for class_ is supposed to be unsigned #define pcdb_checkid_sub(class_) \ ( \ - ( (class_) < JOB_MAX_BASIC ) \ -|| ( (class_) >= JOB_NOVICE_HIGH && (class_) <= JOB_DARK_COLLECTOR ) \ -|| ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) \ -|| ( (class_) >= JOB_BABY_RUNE && (class_) <= JOB_BABY_MECHANIC2 ) \ -|| ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) \ -|| ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) \ -|| ( (class_) >= JOB_REBELLION && (class_) < JOB_MAX ) \ + ( (class_) < JOB_MAX_BASIC ) \ + || ( (class_) >= JOB_NOVICE_HIGH && (class_) <= JOB_DARK_COLLECTOR ) \ + || ( (class_) >= JOB_RUNE_KNIGHT && (class_) <= JOB_MECHANIC_T2 ) \ + || ( (class_) >= JOB_BABY_RUNE && (class_) <= JOB_BABY_MECHANIC2 ) \ + || ( (class_) >= JOB_SUPER_NOVICE_E && (class_) <= JOB_SUPER_BABY_E ) \ + || ( (class_) >= JOB_KAGEROU && (class_) <= JOB_OBORO ) \ + || ( (class_) >= JOB_REBELLION && (class_) < JOB_MAX ) \ ) #define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)(class_)) @@ -649,18 +649,16 @@ struct map_session_data { #define pc_rightside_def(sd) ((sd)->battle_status.def2) #define pc_leftside_mdef(sd) ((sd)->battle_status.mdef) #define pc_rightside_mdef(sd) ( (sd)->battle_status.mdef2 - ((sd)->battle_status.vit>>1) ) -#define pc_leftside_matk(sd) \ - (\ - ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \ +#define pc_leftside_matk(sd) (\ + ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \ ?((sd)->battle_status.matk_min * 100 + 50) / ((sd)->sc.data[SC_MAGICPOWER]->val3+100) \ - :(sd)->battle_status.matk_min \ - ) -#define pc_rightside_matk(sd) \ - (\ - ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \ + :(sd)->battle_status.matk_min \ +) +#define pc_rightside_matk(sd) (\ + ((sd)->sc.data[SC_MAGICPOWER] && (sd)->sc.data[SC_MAGICPOWER]->val4) \ ?((sd)->battle_status.matk_max * 100 + 50) / ((sd)->sc.data[SC_MAGICPOWER]->val3+100) \ - :(sd)->battle_status.matk_max \ - ) + :(sd)->battle_status.matk_max \ +) #endif #define pc_get_group_id(sd) ( (sd)->group_id ) @@ -777,12 +775,12 @@ struct pc_interface { /* funcs */ void (*init) (bool minimal); void (*final) (void); - + struct map_session_data* (*get_dummy_sd) (void); int (*class2idx) (int class_); bool (*can_talk) (struct map_session_data *sd); bool (*can_attack) ( struct map_session_data *sd, int target_id ); - + bool (*can_use_command) (struct map_session_data *sd, const char *command); int (*set_group) (struct map_session_data *sd, int group_id); bool (*should_log_commands) (struct map_session_data *sd); @@ -794,25 +792,25 @@ struct pc_interface { bool (*authok) (struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers); void (*authfail) (struct map_session_data *sd); int (*reg_received) (struct map_session_data *sd); - + int (*isequip) (struct map_session_data *sd,int n); int (*equippoint) (struct map_session_data *sd,int n); int (*setinventorydata) (struct map_session_data *sd); - + int (*checkskill) (struct map_session_data *sd,uint16 skill_id); int (*checkskill2) (struct map_session_data *sd,uint16 index); int (*checkallowskill) (struct map_session_data *sd); int (*checkequip) (struct map_session_data *sd,int pos); - + int (*calc_skilltree) (struct map_session_data *sd); int (*calc_skilltree_normalize_job) (struct map_session_data *sd); int (*clean_skilltree) (struct map_session_data *sd); - + int (*setpos) (struct map_session_data* sd, unsigned short map_index, int x, int y, clr_type clrtype); int (*setsavepoint) (struct map_session_data *sd, short map_index, int x, int y); int (*randomwarp) (struct map_session_data *sd,clr_type type); int (*memo) (struct map_session_data* sd, int pos); - + int (*checkadditem) (struct map_session_data *sd,int nameid,int amount); int (*inventoryblank) (struct map_session_data *sd); int (*search_inventory) (struct map_session_data *sd,int item_id); @@ -824,45 +822,45 @@ struct pc_interface { // Special Shop System int (*paycash) (struct map_session_data *sd, int price, int points); int (*getcash) (struct map_session_data *sd, int cash, int points); - + int (*cart_additem) (struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type); int (*cart_delitem) (struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type); int (*putitemtocart) (struct map_session_data *sd,int idx,int amount); int (*getitemfromcart) (struct map_session_data *sd,int idx,int amount); int (*cartitem_amount) (struct map_session_data *sd,int idx,int amount); - + int (*takeitem) (struct map_session_data *sd,struct flooritem_data *fitem); int (*dropitem) (struct map_session_data *sd,int n,int amount); - + bool (*isequipped) (struct map_session_data *sd, int nameid); bool (*can_Adopt) (struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd); bool (*adoption) (struct map_session_data *p1_sd, struct map_session_data *p2_sd, struct map_session_data *b_sd); - + int (*updateweightstatus) (struct map_session_data *sd); - + int (*addautobonus) (struct s_autobonus *bonus,char max,const char *bonus_script,short rate,unsigned int dur,short atk_type,const char *o_script,unsigned short pos,bool onskill); int (*exeautobonus) (struct map_session_data* sd,struct s_autobonus *bonus); int (*endautobonus) (int tid, int64 tick, int id, intptr_t data); int (*delautobonus) (struct map_session_data* sd,struct s_autobonus *bonus,char max,bool restore); - + int (*bonus) (struct map_session_data *sd,int type,int val); int (*bonus2) (struct map_session_data *sd,int type,int type2,int val); int (*bonus3) (struct map_session_data *sd,int type,int type2,int type3,int val); int (*bonus4) (struct map_session_data *sd,int type,int type2,int type3,int type4,int val); int (*bonus5) (struct map_session_data *sd,int type,int type2,int type3,int type4,int type5,int val); int (*skill) (struct map_session_data *sd, int id, int level, int flag); - + int (*insert_card) (struct map_session_data *sd,int idx_card,int idx_equip); - + int (*steal_item) (struct map_session_data *sd,struct block_list *bl, uint16 skill_lv); int (*steal_coin) (struct map_session_data *sd,struct block_list *bl); - + int (*modifybuyvalue) (struct map_session_data *sd,int orig_value); int (*modifysellvalue) (struct map_session_data *sd,int orig_value); - + int (*follow) (struct map_session_data *sd, int target_id); // [MouseJstr] int (*stop_following) (struct map_session_data *sd); - + unsigned int (*maxbaselv) (struct map_session_data *sd); unsigned int (*maxjoblv) (struct map_session_data *sd); int (*checkbaselevelup) (struct map_session_data *sd); @@ -888,11 +886,11 @@ struct pc_interface { int (*unequipitem) (struct map_session_data *sd,int n,int flag); int (*checkitem) (struct map_session_data *sd); int (*useitem) (struct map_session_data *sd,int n); - + int (*skillatk_bonus) (struct map_session_data *sd, uint16 skill_id); int (*skillheal_bonus) (struct map_session_data *sd, uint16 skill_id); int (*skillheal2_bonus) (struct map_session_data *sd, uint16 skill_id); - + void (*damage) (struct map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp); int (*dead) (struct map_session_data *sd,struct block_list *src); void (*revive) (struct map_session_data *sd,unsigned int hp, unsigned int sp); @@ -909,7 +907,7 @@ struct pc_interface { void (*setridingwug) (struct map_session_data *sd, bool flag); int (*changelook) (struct map_session_data *sd,int type,int val); int (*equiplookall) (struct map_session_data *sd); - + int (*readparam) (struct map_session_data *sd,int type); int (*setparam) (struct map_session_data *sd,int type,int val); int (*readreg) (struct map_session_data *sd, int64 reg); @@ -920,15 +918,15 @@ struct pc_interface { int (*setregistry) (struct map_session_data *sd, int64 reg, int val); char * (*readregistry_str) (struct map_session_data *sd, int64 reg); int (*setregistry_str) (struct map_session_data *sd, int64 reg, const char *val); - + int (*addeventtimer) (struct map_session_data *sd,int tick,const char *name); int (*deleventtimer) (struct map_session_data *sd,const char *name); int (*cleareventtimer) (struct map_session_data *sd); int (*addeventtimercount) (struct map_session_data *sd,const char *name,int tick); - + int (*calc_pvprank) (struct map_session_data *sd); int (*calc_pvprank_timer) (int tid, int64 tick, int id, intptr_t data); - + int (*ismarried) (struct map_session_data *sd); int (*marriage) (struct map_session_data *sd,struct map_session_data *dstsd); int (*divorce) (struct map_session_data *sd); @@ -936,27 +934,27 @@ struct pc_interface { struct map_session_data * (*get_father) (struct map_session_data *sd); struct map_session_data * (*get_mother) (struct map_session_data *sd); struct map_session_data * (*get_child) (struct map_session_data *sd); - + void (*bleeding) (struct map_session_data *sd, unsigned int diff_tick); void (*regen) (struct map_session_data *sd, unsigned int diff_tick); - + void (*setstand) (struct map_session_data *sd); int (*candrop) (struct map_session_data *sd,struct item *item); - + int (*jobid2mapid) (unsigned short b_class); // Skotlex int (*mapid2jobid) (unsigned short class_, int sex); // Skotlex - + const char * (*job_name) (int class_); - + void (*setinvincibletimer) (struct map_session_data* sd, int val); void (*delinvincibletimer) (struct map_session_data* sd); - + int (*addspiritball) (struct map_session_data *sd,int interval,int max); int (*delspiritball) (struct map_session_data *sd,int count,int type); void (*addfame) (struct map_session_data *sd,int count); unsigned char (*famerank) (int char_id, int job); int (*set_hate_mob) (struct map_session_data *sd, int pos, struct block_list *bl); - + int (*readdb) (void); int (*map_day_timer) (int tid, int64 tick, int id, intptr_t data); // by [yor] int (*map_night_timer) (int tid, int64 tick, int id, intptr_t data); // by [yor] @@ -964,25 +962,25 @@ struct pc_interface { void (*inventory_rentals) (struct map_session_data *sd); int (*inventory_rental_clear) (struct map_session_data *sd); void (*inventory_rental_add) (struct map_session_data *sd, int seconds); - + int (*disguise) (struct map_session_data *sd, int class_); bool (*isautolooting) (struct map_session_data *sd, int nameid); - + void (*overheat) (struct map_session_data *sd, int val); - + int (*banding) (struct map_session_data *sd, uint16 skill_lv); - + void (*itemcd_do) (struct map_session_data *sd, bool load); - + int (*load_combo) (struct map_session_data *sd); - + int (*add_charm) (struct map_session_data *sd,int interval,int max,int type); int (*del_charm) (struct map_session_data *sd,int count,int type); - + void (*baselevelchanged) (struct map_session_data *sd); int (*level_penalty_mod) (int diff, unsigned char race, unsigned short mode, int type); int (*calc_skillpoint) (struct map_session_data* sd); - + int (*invincible_timer) (int tid, int64 tick, int id, intptr_t data); int (*spiritball_timer) (int tid, int64 tick, int id, intptr_t data); int (*check_banding) ( struct block_list *bl, va_list ap ); @@ -1010,19 +1008,19 @@ struct pc_interface { int (*checkcombo) (struct map_session_data *sd, struct item_data *data ); int (*calcweapontype) (struct map_session_data *sd); int (*removecombo) (struct map_session_data *sd, struct item_data *data ); - + void (*bank_deposit) (struct map_session_data *sd, int money); void (*bank_withdraw) (struct map_session_data *sd, int money); - + void (*rental_expire) (struct map_session_data *sd, int i); void (*scdata_received) (struct map_session_data *sd); - + void (*bound_clear) (struct map_session_data *sd, enum e_item_bound_type type); - + int (*expiration_timer) (int tid, int64 tick, int id, intptr_t data); int (*global_expiration_timer) (int tid, int64 tick, int id, intptr_t data); void (*expire_check) (struct map_session_data *sd); - + /** * Autotrade persistency [Ind/Hercules <3] **/ diff --git a/src/map/pet.c b/src/map/pet.c index d90727b97..0378ea0c3 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -510,7 +510,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) { if (sd->catch_target_class == 0 && !(md->status.mode&MD_BOSS)) sd->catch_target_class = md->class_; if(i < 0 || sd->catch_target_class != md->class_) { - clif->emotion(&md->bl, E_AG); //mob will do /ag if wrong lure is used on them. + clif->emotion(&md->bl, E_AG); //mob will do /ag if wrong lure is used on them. clif->pet_roulette(sd,0); sd->catch_target_class = -1; return 1; @@ -911,17 +911,18 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int64 tick if (target->type != BL_ITEM) { //enemy targetted - if(!battle->check_range(&pd->bl,target,pd->status.rhw.range)) - { //Chase + if(!battle->check_range(&pd->bl,target,pd->status.rhw.range)) { + //Chase if(!unit->walktobl(&pd->bl, target, pd->status.rhw.range, 2)) pet->unlocktarget(pd); //Unreachable target. return 0; } //Continuous attack. unit->attack(&pd->bl, pd->target_id, 1); - } else { //Item Targeted, attempt loot - if (!check_distance_bl(&pd->bl, target, 1)) - { //Out of range + } else { + //Item Targeted, attempt loot + if (!check_distance_bl(&pd->bl, target, 1)) { + //Out of range if(!unit->walktobl(&pd->bl, target, 1, 1)) //Unreachable target. pet->unlocktarget(pd); return 0; @@ -1036,7 +1037,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd) memset(pd->loot->item,0,pd->loot->max * sizeof(struct item)); pd->loot->count = 0; pd->loot->weight = 0; - pd->ud.canact_tick = timer->gettick()+10000; //prevent picked up during 10*1000ms + pd->ud.canact_tick = timer->gettick()+10000; //prevent picked up during 10*1000ms if (dlist->item) timer->add(timer->gettick()+540,pet->delay_item_drop,0,(intptr_t)dlist); @@ -1103,8 +1104,8 @@ int pet_recovery_timer(int tid, int64 tick, int id, intptr_t data) { return 0; } - if(sd->sc.data[pd->recovery->type]) - { //Display a heal animation? + if (sd->sc.data[pd->recovery->type]) { + //Display a heal animation? //Detoxify is chosen for now. clif->skill_nodamage(&pd->bl,&sd->bl,TF_DETOXIFY,1,1); status_change_end(&sd->bl, pd->recovery->type, INVALID_TIMER); @@ -1170,8 +1171,8 @@ int pet_skill_support_timer(int tid, int64 tick, int id, intptr_t data) { st = status->get_status_data(&sd->bl); - if (DIFF_TICK(pd->ud.canact_tick, tick) > 0) - { //Wait until the pet can act again. + if (DIFF_TICK(pd->ud.canact_tick, tick) > 0) { + //Wait until the pet can act again. pd->s_skill->timer=timer->add(pd->ud.canact_tick,pet->skill_support_timer,sd->bl.id,0); return 0; } diff --git a/src/map/pet.h b/src/map/pet.h index 5c890ef85..286109126 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -41,16 +41,16 @@ struct s_pet_db { enum { PET_CLASS,PET_CATCH,PET_EGG,PET_EQUIP,PET_FOOD }; struct pet_recovery { //Stat recovery - enum sc_type type; //Status Change id - unsigned short delay; //How long before curing (secs). + enum sc_type type; ///< Status Change id + unsigned short delay; ///< How long before curing (secs). int timer; }; struct pet_bonus { - unsigned short type; //bStr, bVit? - unsigned short val; //Qty + unsigned short type; //bStr, bVit? + unsigned short val; //Qty unsigned short duration; //in secs - unsigned short delay; //Time before RENEWAL_CAST (secs) + unsigned short delay; //Time before RENEWAL_CAST (secs) int timer; }; @@ -93,7 +93,7 @@ struct pet_data { } state; int move_fail_count; int64 next_walktime, last_thinktime; - short rate_fix; //Support rate as modified by intimacy (1000 = 100%) [Skotlex] + short rate_fix; //Support rate as modified by intimacy (1000 = 100%) [Skotlex] struct pet_recovery* recovery; struct pet_bonus* bonus; diff --git a/src/map/script.h b/src/map/script.h index 90804dd5b..e28abf970 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -187,7 +187,7 @@ typedef enum c_op { C_USERFUNC, // internal script function C_USERFUNC_POS, // internal script function label C_REF, // the next call to c_op2 should push back a ref to the left operand - + // operators C_OP3, // a ? b : c C_LOR, // a || b @@ -265,7 +265,7 @@ enum e_arglist { *------------------------------------------*/ enum { - MF_NOMEMO, //0 + MF_NOMEMO, //0 MF_NOTELEPORT, MF_NOSAVE, MF_NOBRANCH, @@ -275,7 +275,7 @@ enum { MF_PVP_NOPARTY, MF_PVP_NOGUILD, MF_GVG, - MF_GVG_NOPARTY, //10 + MF_GVG_NOPARTY, //10 MF_NOTRADE, MF_NOSKILL, MF_NOWARP, @@ -293,7 +293,7 @@ enum { MF_GVG_DUNGEON, MF_NIGHTENABLED, MF_NOBASEEXP, - MF_NOJOBEXP, //30 + MF_NOJOBEXP, //30 MF_NOMOBLOOT, MF_NOMVPLOOT, MF_NORETURN, @@ -303,7 +303,7 @@ enum { MF_NOCOMMAND, MF_NODROP, MF_JEXP, - MF_BEXP, //40 + MF_BEXP, //40 MF_NOVENDING, MF_LOADEVENT, MF_NOCHAT, @@ -313,7 +313,7 @@ enum { MF_AUTOTRADE, MF_ALLOWKS, MF_MONSTER_NOTELEPORT, - MF_PVP_NOCALCRANK, //50 + MF_PVP_NOCALCRANK, //50 MF_BATTLEGROUND, MF_RESET, MF_NOTOMB, @@ -460,9 +460,9 @@ struct script_syntax_data { int count; int flag; struct linkdb_node *case_label; - } curly[256]; // Information right parenthesis - int curly_count; // The number of right brackets - int index; // Number of the syntax used in the script + } curly[256]; // Information right parenthesis + int curly_count; // The number of right brackets + int index; // Number of the syntax used in the script }; struct casecheck_data { diff --git a/src/map/searchstore.c b/src/map/searchstore.c index 72b28aacd..782c14987 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -333,7 +333,7 @@ bool searchstore_result(struct map_session_data* sd, unsigned int store_id, int void searchstore_defaults (void) { searchstore = &searchstore_s; - + searchstore->open = searchstore_open; searchstore->query = searchstore_query; searchstore->querynext = searchstore_querynext; @@ -344,5 +344,5 @@ void searchstore_defaults (void) { searchstore->queryremote = searchstore_queryremote; searchstore->clearremote = searchstore_clearremote; searchstore->result = searchstore_result; - + } diff --git a/src/map/skill.c b/src/map/skill.c index c9e68531d..169f4bcb9 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -45,7 +45,7 @@ #include "../common/timer.h" #include "../common/utils.h" -#define SKILLUNITTIMER_INTERVAL 100 +#define SKILLUNITTIMER_INTERVAL 100 // ranges reserved for mapping skill ids to skilldb offsets #define HM_SKILLRANGEMIN 750 @@ -145,49 +145,49 @@ void skill_chk(uint16* skill_id) { } while(0) #define skill_glv(lv) min((lv),MAX_SKILL_LEVEL-1) // Skill DB -int skill_get_hit( uint16 skill_id ) { skill_get (skill->db[skill_id].hit, skill_id); } -int skill_get_inf( uint16 skill_id ) { skill_get (skill->db[skill_id].inf, skill_id); } -int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { skill_get (skill->db[skill_id].element[skill_glv(skill_lv-1)], skill_id); } -int skill_get_nk( uint16 skill_id ) { skill_get (skill->db[skill_id].nk, skill_id); } -int skill_get_max( uint16 skill_id ) { skill_get (skill->db[skill_id].max, skill_id); } -int skill_get_range( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill->db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { skill_get2 ( (skill->db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill->db[skill_id].splash[skill_glv(skill_lv-1)]:AREA_SIZE), skill_id, skill_lv); } -int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].hp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_state(uint16 skill_id) { skill_get (skill->db[skill_id].state, skill_id); } -int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { skill_get2 (skill->db[skill_id].spiritball[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_itemid(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].itemid[idx], skill_id); } -int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].amount[idx], skill_id); } -int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_castdef( uint16 skill_id ) { skill_get (skill->db[skill_id].cast_def_rate, skill_id); } -int skill_get_weapontype( uint16 skill_id ) { skill_get (skill->db[skill_id].weapon, skill_id); } -int skill_get_ammotype( uint16 skill_id ) { skill_get (skill->db[skill_id].ammo, skill_id); } -int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_inf2( uint16 skill_id ) { skill_get (skill->db[skill_id].inf2, skill_id); } -int skill_get_castcancel( uint16 skill_id ) { skill_get (skill->db[skill_id].castcancel, skill_id); } -int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_type( uint16 skill_id ) { skill_get (skill->db[skill_id].skill_type, skill_id); } -int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill->db[skill_id].unit_id[flag], skill_id); } -int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_interval, skill_id); } -int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].unit_range[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_unit_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BCT_ALL, skill_id); } -int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BL_ALL, skill_id); } -int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_flag, skill_id); } -int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].unit_layout_type[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].cooldown[skill_glv(skill_lv-1)], skill_id, skill_lv); } -int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ) { +int skill_get_hit( uint16 skill_id ) { skill_get (skill->db[skill_id].hit, skill_id); } +int skill_get_inf( uint16 skill_id ) { skill_get (skill->db[skill_id].inf, skill_id); } +int skill_get_ele( uint16 skill_id , uint16 skill_lv ) { skill_get (skill->db[skill_id].element[skill_glv(skill_lv-1)], skill_id); } +int skill_get_nk( uint16 skill_id ) { skill_get (skill->db[skill_id].nk, skill_id); } +int skill_get_max( uint16 skill_id ) { skill_get (skill->db[skill_id].max, skill_id); } +int skill_get_range( uint16 skill_id , uint16 skill_lv ) { skill_get2 (skill->db[skill_id].range[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_splash( uint16 skill_id , uint16 skill_lv ) { skill_get2 ( (skill->db[skill_id].splash[skill_glv(skill_lv-1)]>=0?skill->db[skill_id].splash[skill_glv(skill_lv-1)]:AREA_SIZE), skill_id, skill_lv); } +int skill_get_hp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].hp[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_sp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].sp[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_hp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].hp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_sp_rate(uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].sp_rate[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_state(uint16 skill_id) { skill_get (skill->db[skill_id].state, skill_id); } +int skill_get_spiritball(uint16 skill_id, uint16 skill_lv) { skill_get2 (skill->db[skill_id].spiritball[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_itemid(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].itemid[idx], skill_id); } +int skill_get_itemqty(uint16 skill_id, int idx) { skill_get (skill->db[skill_id].amount[idx], skill_id); } +int skill_get_zeny( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].zeny[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_num( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].num[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_cast( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].cast[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_delay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].delay[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_walkdelay( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].walkdelay[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_time( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].upkeep_time[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_time2( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].upkeep_time2[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_castdef( uint16 skill_id ) { skill_get (skill->db[skill_id].cast_def_rate, skill_id); } +int skill_get_weapontype( uint16 skill_id ) { skill_get (skill->db[skill_id].weapon, skill_id); } +int skill_get_ammotype( uint16 skill_id ) { skill_get (skill->db[skill_id].ammo, skill_id); } +int skill_get_ammo_qty( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].ammo_qty[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_inf2( uint16 skill_id ) { skill_get (skill->db[skill_id].inf2, skill_id); } +int skill_get_castcancel( uint16 skill_id ) { skill_get (skill->db[skill_id].castcancel, skill_id); } +int skill_get_maxcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].maxcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_blewcount( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].blewcount[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_mhp( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].mhp[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_castnodex( uint16 skill_id ,uint16 skill_lv ) { skill_get2 (skill->db[skill_id].castnodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_delaynodex( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].delaynodex[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_type( uint16 skill_id ) { skill_get (skill->db[skill_id].skill_type, skill_id); } +int skill_get_unit_id ( uint16 skill_id, int flag ){ skill_get (skill->db[skill_id].unit_id[flag], skill_id); } +int skill_get_unit_interval( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_interval, skill_id); } +int skill_get_unit_range( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].unit_range[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_unit_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BCT_ALL, skill_id); } +int skill_get_unit_bl_target( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_target&BL_ALL, skill_id); } +int skill_get_unit_flag( uint16 skill_id ) { skill_get (skill->db[skill_id].unit_flag, skill_id); } +int skill_get_unit_layout_type( uint16 skill_id ,uint16 skill_lv ){ skill_get2 (skill->db[skill_id].unit_layout_type[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_cooldown( uint16 skill_id, uint16 skill_lv ) { skill_get2 (skill->db[skill_id].cooldown[skill_glv(skill_lv-1)], skill_id, skill_lv); } +int skill_get_fixed_cast( uint16 skill_id ,uint16 skill_lv ) { #ifdef RENEWAL_CAST skill_get2 (skill->db[skill_id].fixed_cast[skill_glv(skill_lv-1)], skill_id, skill_lv); #else @@ -254,8 +254,10 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { //TODO: Find a way better than hardcoding the list of skills affected by AC_VULTURE switch( skill_id ) { - case AC_SHOWER: case MA_SHOWER: - case AC_DOUBLE: case MA_DOUBLE: + case AC_SHOWER: + case MA_SHOWER: + case AC_DOUBLE: + case MA_DOUBLE: case HT_BLITZBEAT: case AC_CHARGEARROW: case MA_CHARGEARROW: @@ -645,7 +647,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 nullpo_ret(src); nullpo_ret(bl); - if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! - celest + if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! - celest if( dmg_lv < ATK_BLOCK ) // Don't apply effect if miss. return 0; @@ -805,8 +807,8 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 skill_lv = pc->checkskill(sd, TF_POISON); case TF_POISON: case AS_SPLASHER: - if(!sc_start2(src,bl,SC_POISON,(4*skill_lv+10),skill_lv,src->id,skill->get_time2(skill_id,skill_lv)) - && sd && skill_id==TF_POISON + if (!sc_start2(src,bl,SC_POISON,(4*skill_lv+10),skill_lv,src->id,skill->get_time2(skill_id,skill_lv)) + && sd && skill_id==TF_POISON ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; @@ -823,8 +825,9 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 #ifndef RENEWAL case WZ_FROSTNOVA: #endif - if( !sc_start(src,bl,SC_FREEZE,skill_lv*3+35,skill_lv,skill->get_time2(skill_id,skill_lv)) - && sd && skill_id == MG_FROSTDIVER ) + if (!sc_start(src,bl,SC_FREEZE,skill_lv*3+35,skill_lv,skill->get_time2(skill_id,skill_lv)) + && sd && skill_id == MG_FROSTDIVER + ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; @@ -841,7 +844,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 #ifdef RENEWAL sc_start(src,bl,SC_FREEZE,65-(5*skill_lv),skill_lv,skill->get_time2(skill_id,skill_lv)); #else - //On third hit, there is a 150% to freeze the target + //On third hit, there is a 150% to freeze the target if(tsc->sg_counter >= 3 && sc_start(src,bl,SC_FREEZE,150,skill_lv,skill->get_time2(skill_id,skill_lv))) tsc->sg_counter = 0; @@ -983,7 +986,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 case NPC_MENTALBREAKER: { //Based on observations by [Tharis], Mental Breaker should do SP damage - //equal to Matk*skLevel. + //equal to Matk*skLevel. rate = status->get_matk(src, 2); rate*=skill_lv; status_zap(bl, 0, rate); @@ -1045,14 +1048,14 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 break; default: sc_start2(src,bl,SC_BLOODING,(5+skill_lv*5),skill_lv,src->id,skill->get_time2(skill_id,3)); - } + } break; case HW_NAPALMVULCAN: sc_start(src,bl,SC_CURSE,5*skill_lv,skill_lv,skill->get_time2(skill_id,skill_lv)); break; - case WS_CARTTERMINATION: // Cart termination + case WS_CARTTERMINATION: sc_start(src,bl,SC_STUN,5*skill_lv,skill_lv,skill->get_time2(skill_id,skill_lv)); break; @@ -1212,7 +1215,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 break; case LG_HESPERUSLIT: if ( sc && sc->data[SC_BANDING] ) { - if ( sc->data[SC_BANDING]->val2 == 4 ) // 4 banding RGs: Targets will be stunned at 100% chance for 4 ~ 8 seconds, irreducible by STAT. + if ( sc->data[SC_BANDING]->val2 == 4 ) // 4 banding RGs: Targets will be stunned at 100% chance for 4 ~ 8 seconds, irreducible by STAT. status->change_start(src, bl, SC_STUN, 10000, skill_lv, 0, 0, 0, 1000*(4+rand()%4), SCFLAG_FIXEDTICK); else if ( sc->data[SC_BANDING]->val2 == 6 ) // 6 banding RGs: activate Pinpoint Attack Lv1-5 skill->castend_damage_id(src,bl,LG_PINPOINTATTACK,1+rand()%5,tick,0); @@ -1245,7 +1248,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 else if( dstmd && !is_boss(bl) ) sc_start(src, bl,SC_STOP,100,skill_lv,skill->get_time(skill_id,skill_lv)); break; - case LG_RAYOFGENESIS: // 50% chance to cause Blind on Undead and Demon monsters. + case LG_RAYOFGENESIS: // 50% chance to cause Blind on Undead and Demon monsters. if ( battle->check_undead(tstatus->race, tstatus->def_ele) || tstatus->race == RC_DEMON ) sc_start(src, bl, SC_BLIND,50, skill_lv, skill->get_time(skill_id,skill_lv)); break; @@ -1275,7 +1278,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 sc_start(src, bl, SC_FEAR, 5 + 5 * skill_lv, skill_lv, skill->get_time(skill_id, skill_lv)); break; case SO_EARTHGRAVE: - sc_start2(src, bl, SC_BLOODING, 5 * skill_lv, skill_lv, src->id, skill->get_time2(skill_id, skill_lv)); // Need official rate. [LimitLine] + sc_start2(src, bl, SC_BLOODING, 5 * skill_lv, skill_lv, src->id, skill->get_time2(skill_id, skill_lv)); // Need official rate. [LimitLine] break; case SO_DIAMONDDUST: rate = 5 + 5 * skill_lv; @@ -1288,7 +1291,8 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 break; case GN_SLINGITEM_RANGEMELEEATK: if( sd ) { - switch( sd->itemid ) { // Starting SCs here instead of do it in skill->additional_effect to simplify the code. + switch( sd->itemid ) { + // Starting SCs here instead of do it in skill->additional_effect to simplify the code. case ITEMID_COCONUT_BOMB: sc_start(src, bl, SC_STUN, 100, skill_lv, 5000); // 5 seconds until I get official sc_start(src, bl, SC_BLOODING, 100, skill_lv, 10000); @@ -1308,7 +1312,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 sc_start(src, bl, SC_STUN, 20 + 10 * skill_lv, skill_lv, skill->get_time2(skill_id, skill_lv)); sc_start2(src, bl, SC_BLOODING, 5 + 5 * skill_lv, skill_lv, src->id,skill->get_time2(skill_id, skill_lv)); break; - case EL_WIND_SLASH: // Non confirmed rate. + case EL_WIND_SLASH: // Non confirmed rate. sc_start2(src, bl, SC_BLOODING, 25, skill_lv, src->id, skill->get_time(skill_id,skill_lv)); break; case EL_STONE_HAMMER: @@ -1361,8 +1365,8 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 if (rate) status->change_start(src, bl, SC_COMA, rate, 0, 0, src->id, 0, 0, SCFLAG_NONE); } - if( sd && battle_config.equip_self_break_rate ) - { // Self weapon breaking + if (sd && battle_config.equip_self_break_rate) { + // Self weapon breaking rate = battle_config.equip_natural_break_rate; if( sc ) { @@ -1376,8 +1380,8 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 if( rate ) skill->break_equip(src, EQP_WEAPON, rate, BCT_SELF); } - if( battle_config.equip_skill_break_rate && skill_id != WS_CARTTERMINATION && skill_id != ITM_TOMAHAWK ) - { // Cart Termination/Tomahawk won't trigger breaking data. Why? No idea, go ask Gravity. + if (battle_config.equip_skill_break_rate && skill_id != WS_CARTTERMINATION && skill_id != ITM_TOMAHAWK) { + // Cart Termination/Tomahawk won't trigger breaking data. Why? No idea, go ask Gravity. // Target weapon breaking rate = 0; if( sd ) @@ -1565,7 +1569,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 monster = mob->db(class_); } while ( (monster->status.mode&(MD_BOSS|MD_PLANT) || monster->summonper[0] <= rate) && - (temp++) < 2000); + (temp++) < 2000); if (temp < 2000) mob->class_change(dstmd,class_); } @@ -1680,7 +1684,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b nullpo_ret(src); nullpo_ret(bl); - if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! [celest] + if(skill_id > 0 && !skill_lv) return 0; // don't forget auto attacks! [celest] sd = BL_CAST(BL_PC, src); dstsd = BL_CAST(BL_PC, bl); @@ -1720,7 +1724,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b case GS_FULLBUSTER: sc_start(src,src,SC_BLIND,2*skill_lv,skill_lv,skill->get_time2(skill_id,skill_lv)); break; - case HFLI_SBR44: // [orn] + case HFLI_SBR44: // [orn] case HVAN_EXPLOSION: if(src->type == BL_HOM){ TBL_HOM *hd = (TBL_HOM*)src; @@ -1771,7 +1775,7 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b if( attack_type&BF_MAGIC ) { sp += sd->bonus.magic_sp_gain_value; hp += sd->bonus.magic_hp_gain_value; - if( skill_id == WZ_WATERBALL ) {// (bugreport:5303) + if( skill_id == WZ_WATERBALL ) {// (bugreport:5303) if( sc->data[SC_SOULLINK] && sc->data[SC_SOULLINK]->val2 == SL_WIZARD && sc->data[SC_SOULLINK]->val3 == WZ_WATERBALL @@ -1895,11 +1899,11 @@ int skill_counter_additional_effect(struct block_list* src, struct block_list *b return 0; } /*========================================================================= - Breaks equipment. On-non players causes the corresponding strip effect. - - rate goes from 0 to 10000 (100.00%) - - flag is a BCT_ flag to indicate which type of adjustment should be used - (BCT_ENEMY/BCT_PARTY/BCT_SELF) are the valid values. ---------------------------------------------------------------------------*/ + * Breaks equipment. On-non players causes the corresponding strip effect. + * - rate goes from 0 to 10000 (100.00%) + * - flag is a BCT_ flag to indicate which type of adjustment should be used + * (BCT_ENEMY/BCT_PARTY/BCT_SELF) are the valid values. + *------------------------------------------------------------------------*/ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, int flag) { const int where_list[4] = {EQP_WEAPON, EQP_ARMOR, EQP_SHIELD, EQP_HELM}; const enum sc_type scatk[4] = {SC_NOEQUIPWEAPON, SC_NOEQUIPARMOR, SC_NOEQUIPSHIELD, SC_NOEQUIPHELM}; @@ -1918,7 +1922,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in rate -= rate*sd->bonus.unbreakable/100; if (where&EQP_WEAPON) { switch (sd->status.weapon) { - case W_FIST: //Bare fists should not break :P + case W_FIST: //Bare fists should not break :P case W_1HAXE: case W_2HAXE: case W_MACE: // Axes and Maces can't be broken [DracoRPG] @@ -2061,13 +2065,13 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in if (dir == -1) // <optimized>: do the computation here instead of outside dir = map->calc_dir(target, src->x, src->y); // direction from src to target, reversed - if (dir >= 0 && dir < 8) - { // take the reversed 'direction' and reverse it + if (dir >= 0 && dir < 8) { + // take the reversed 'direction' and reverse it dx = -dirx[dir]; dy = -diry[dir]; } - return unit->blown(target, dx, dy, count, flag); // send over the proper flag + return unit->blown(target, dx, dy, count, flag); // send over the proper flag } @@ -2137,7 +2141,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr if(skill_id > 0 && !skill_lv) return 0; - nullpo_ret(src); // Source is the master behind the attack (player/mob/pet) + nullpo_ret(src); // Source is the master behind the attack (player/mob/pet) nullpo_ret(dsrc); // dsrc is the actual originator of the damage, can be the same as src, or a skill casted by src. nullpo_ret(bl); //Target to be attacked. @@ -2354,14 +2358,14 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr case AC_DOUBLE: // AC_DOUBLE can start the combo with other monster types, but the // monster that's going to be hit by HT_POWER should be RC_BRUTE or RC_INSECT [Panikon] - if( pc->checkskill(sd, HT_POWER) ) - { + if (pc->checkskill(sd, HT_POWER)) { sc_start4(NULL,src,SC_COMBOATTACK,100,HT_POWER,0,1,0,2000); clif->combo_delay(src,2000); } break; case TK_COUNTER: - { //bonus from SG_FRIEND [Komurka] + { + //bonus from SG_FRIEND [Komurka] int level; if(sd->status.party_id>0 && (level = pc->checkskill(sd,SG_FRIEND))) party->skill_check(sd, sd->status.party_id, TK_COUNTER,level); @@ -2388,7 +2392,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr if( pc->checkskill(sd, SR_TIGERCANNON) > 0 || pc->checkskill(sd, SR_GATEOFHELL) > 0 ) combo = 1; break; - } //Switch End + } //Switch End if (combo) { //Possible to chain if ( (combo = DIFF_TICK32(sd->ud.canact_tick, tick)) < 50 ) combo = 50;/* less is a waste. */ sc_start2(NULL,src,SC_COMBOATTACK,100,skill_id,bl->id,combo); @@ -2520,11 +2524,12 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr map->freeblock_lock(); - if(damage > 0 && dmg.flag&BF_SKILL && tsd - && pc->checkskill(tsd,RG_PLAGIARISM) - && (!sc || !sc->data[SC_PRESERVE]) - && damage < tsd->battle_status.hp) - { //Updated to not be able to copy skills if the blow will kill you. [Skotlex] + if (damage > 0 && dmg.flag&BF_SKILL && tsd + && pc->checkskill(tsd,RG_PLAGIARISM) + && (!sc || !sc->data[SC_PRESERVE]) + && damage < tsd->battle_status.hp + ) { + //Updated to not be able to copy skills if the blow will kill you. [Skotlex] int copy_skill = skill_id, cidx = 0; /** * Copy Referral: dummy skills should point to their source upon copying @@ -2560,7 +2565,7 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr } cidx = skill->get_index(copy_skill); if ((tsd->status.skill[cidx].id == 0 || tsd->status.skill[cidx].flag == SKILL_FLAG_PLAGIARIZED) && - can_copy(tsd,copy_skill,bl)) // Split all the check into their own function [Aru] + can_copy(tsd,copy_skill,bl)) // Split all the check into their own function [Aru] { int lv, idx = 0; if( sc && sc->data[SC__REPRODUCE] && (lv = sc->data[SC__REPRODUCE]->val1) ) { @@ -2935,7 +2940,8 @@ int skill_check_unit_range2_sub (struct block_list *bl, va_list ap) { int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_id, uint16 skill_lv) { int range, type; - switch (skill_id) { // to be expanded later + switch (skill_id) { + // to be expanded later case WZ_ICEWALL: range = 2; break; @@ -3403,7 +3409,7 @@ int skill_activate_reverberation(struct block_list *bl, va_list ap) { int skill_reveal_trap (struct block_list *bl, va_list ap) { TBL_SKILL *su = (TBL_SKILL*)bl; - if (su->alive && su->group && skill->get_inf2(su->group->skill_id)&INF2_TRAP) { //Reveal trap. + if (su->alive && su->group && skill->get_inf2(su->group->skill_id)&INF2_TRAP) { //Reveal trap. //Change look is not good enough, the client ignores it as an actual trap still. [Skotlex] //clif->changetraplook(bl, su->group->unit_id); clif->getareachar_skillunit(&su->bl,su,AREA); @@ -3516,9 +3522,9 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 case MO_TRIPLEATTACK: case CH_CHAINCRUSH: case CH_TIGERFIST: - case PA_SHIELDCHAIN: // Shield Chain + case PA_SHIELDCHAIN: case PA_SACRIFICE: - case WS_CARTTERMINATION: // Cart Termination + case WS_CARTTERMINATION: case AS_VENOMKNIFE: case HT_PHANTASMIC: case TK_DOWNKICK: @@ -3530,15 +3536,15 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 case GS_PIERCINGSHOT: case GS_RAPIDSHOWER: case GS_DUST: - case GS_DISARM: // Added disarm. [Reddozen] + case GS_DISARM: case GS_FULLBUSTER: case NJ_SYURIKEN: case NJ_KUNAI: #ifndef RENEWAL case ASC_BREAKER: #endif - case HFLI_MOON: //[orn] - case HFLI_SBR44: //[orn] + case HFLI_MOON: //[orn] + case HFLI_SBR44: //[orn] case NPC_BLEEDING: case NPC_CRITICALWOUND: case NPC_HELLPOWER: @@ -3980,8 +3986,8 @@ int skill_castend_damage_id(struct block_list* src, struct block_list *bl, uint1 skill->castend_nodamage_id); } break; - case CH_PALMSTRIKE: // Palm Strike takes effect 1sec after casting. [Skotlex] - // clif->skill_nodamage(src,bl,skill_id,skill_lv,0); //Can't make this one display the correct attack animation delay :/ + case CH_PALMSTRIKE: // Palm Strike takes effect 1sec after casting. [Skotlex] + //clif->skill_nodamage(src,bl,skill_id,skill_lv,0); //Can't make this one display the correct attack animation delay :/ clif->damage(src,bl,status_get_amotion(src),0,-1,1,4,0); //Display an absorbed damage attack. skill->addtimerskill(src, tick + (1000+status_get_amotion(src)), bl->id, 0, 0, skill_id, skill_lv, BF_WEAPON, flag); break; @@ -4860,7 +4866,7 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { break; } else if( ud->skill_id == RK_PHANTOMTHRUST && target->type != BL_MOB ) { if( !map_flag_vs(src->m) && battle->check_target(src,target,BCT_PARTY) <= 0 ) - break; // You can use Phantom Thurst on party members in normal maps too. [pakpil] + break; // You can use Phantom Thurst on party members in normal maps too. [pakpil] } if( inf&BCT_ENEMY @@ -4909,8 +4915,8 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { break; if (ud->state.running && ud->skill_id == TK_JUMPKICK) { - ud->state.running = 0; - status_change_end(src, SC_RUN, INVALID_TIMER); + ud->state.running = 0; + status_change_end(src, SC_RUN, INVALID_TIMER); flag = 1; } @@ -5004,8 +5010,8 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { skill->consume_requirement(sd,ud->skill_id, ud->skill_lv,1); status->set_sp(src, 0, 0); sc = &sd->sc; - if (sc->count) - { //End states + if (sc->count) { + //End states status_change_end(src, SC_EXPLOSIONSPIRITS, INVALID_TIMER); status_change_end(src, SC_BLADESTOP, INVALID_TIMER); #ifdef RENEWAL @@ -5022,8 +5028,8 @@ int skill_castend_id(int tid, int64 tick, int id, intptr_t data) { if( dir > 2 && dir < 6 ) y = -2; else if( dir == 7 || dir < 2 ) y = 2; else y = 0; - if (unit->movepos(src, src->x+x, src->y+y, 1, 1)) - { //Display movement + animation. + if (unit->movepos(src, src->x+x, src->y+y, 1, 1)) { + //Display movement + animation. clif->slide(src,src->x,src->y); clif->spiritball(src); } @@ -5059,7 +5065,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int element = 0; enum sc_type type; - if(skill_id > 0 && !skill_lv) return 0; // [Celest] + if(skill_id > 0 && !skill_lv) return 0; // [Celest] nullpo_retr(1, src); nullpo_retr(1, bl); @@ -5115,12 +5121,12 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin //Check for undead skills that convert a no-damage skill into a damage one. [Skotlex] switch (skill_id) { - case HLIF_HEAL: // [orn] + case HLIF_HEAL: // [orn] if (bl->type != BL_HOM) { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0) ; break ; } - case AL_HEAL: + case AL_HEAL: /** * Arch Bishop @@ -5133,7 +5139,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin //Apparently only player casted skills can be offensive like this. if (sd && battle->check_undead(tstatus->race,tstatus->def_ele) && skill_id != AL_INCAGI) { if (battle->check_target(src, bl, BCT_ENEMY) < 1) { - //Offensive heal does not works on non-enemies. [Skotlex] + //Offensive heal does not works on non-enemies. [Skotlex] clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -5225,7 +5231,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin map->freeblock_lock(); switch(skill_id) { - case HLIF_HEAL: // [orn] + case HLIF_HEAL: // [orn] case AL_HEAL: /** * Arch Bishop @@ -5414,7 +5420,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin bl = (struct block_list*)((TBL_PET*)src)->msd; if (!bl) bl = src; unit->skilluse_id(src, bl->id, abra_skill_id, abra_skill_lv); - } else { //Assume offensive skills + } else { //Assume offensive skills int target_id = 0; if (ud->target) target_id = ud->target; @@ -5574,14 +5580,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start4(src,bl,type,100,skill_lv,src->id,0,0,skill->get_time(skill_id,skill_lv))); break; - case SA_FLAMELAUNCHER: // added failure chance and chance to break weapon if turned on [Valaris] + case SA_FLAMELAUNCHER: // added failure chance and chance to break weapon if turned on [Valaris] case SA_FROSTWEAPON: case SA_LIGHTNINGLOADER: case SA_SEISMICWEAPON: if (dstsd) { if(dstsd->status.weapon == W_FIST || (dstsd->sc.count && !dstsd->sc.data[type] && - ( //Allow re-enchanting to lengthen time. [Skotlex] + ( //Allow re-enchanting to lengthen time. [Skotlex] dstsd->sc.data[SC_PROPERTYFIRE] || dstsd->sc.data[SC_PROPERTYWATER] || dstsd->sc.data[SC_PROPERTYWIND] || @@ -5846,7 +5852,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin dstsd->sc.data[SC_PROPERTYGROUND] || dstsd->sc.data[SC_PROPERTYDARK] || dstsd->sc.data[SC_PROPERTYTELEKINESIS] - // dstsd->sc.data[SC_ENCHANTPOISON] //People say you should be able to recast to lengthen the timer. [Skotlex] + //dstsd->sc.data[SC_ENCHANTPOISON] //People say you should be able to recast to lengthen the timer. [Skotlex] ) { clif->skill_nodamage(src,bl,skill_id,skill_lv,0); clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); @@ -6025,12 +6031,15 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case MO_ABSORBSPIRITS: { int sp = 0; - if (dstsd && dstsd->spiritball && (sd == dstsd || map_flag_vs(src->m) || (sd->duel_group && sd->duel_group == dstsd->duel_group)) && ((dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER || (dstsd->class_&MAPID_UPPERMASK)!=MAPID_REBELLION)) - { // split the if for readability, and included gunslingers in the check so that their coins cannot be removed [Reddozen] + if (dstsd && dstsd->spiritball + && (sd == dstsd || map_flag_vs(src->m) || (sd->duel_group && sd->duel_group == dstsd->duel_group)) + && ((dstsd->class_&MAPID_BASEMASK)!=MAPID_GUNSLINGER || (dstsd->class_&MAPID_UPPERMASK)!=MAPID_REBELLION) + ) { + // split the if for readability, and included gunslingers in the check so that their coins cannot be removed [Reddozen] sp = dstsd->spiritball * 7; pc->delspiritball(dstsd,dstsd->spiritball,0); - } else if (dstmd && !(tstatus->mode&MD_BOSS) && rnd() % 100 < 20) - { // check if target is a monster and not a Boss, for the 20% chance to absorb 2 SP per monster's level [Reddozen] + } else if (dstmd && !(tstatus->mode&MD_BOSS) && rnd() % 100 < 20) { + // check if target is a monster and not a Boss, for the 20% chance to absorb 2 SP per monster's level [Reddozen] sp = 2 * dstmd->level; mob->target(dstmd,src,0); } @@ -6137,7 +6146,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin BF_MAGIC, src, src, skill_id, skill_lv, tick, flag, BCT_ENEMY); break; - case HVAN_EXPLOSION: // [orn] + case HVAN_EXPLOSION: // [orn] case NPC_SELFDESTRUCTION: { //Self Destruction hits everyone in range (allies+enemies) @@ -6522,8 +6531,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; case MC_VENDING: - if(sd) - { //Prevent vending of GMs with unnecessary Level to trade/drop. [Skotlex] + if (sd) { + //Prevent vending of GMs with unnecessary Level to trade/drop. [Skotlex] if ( !pc_can_give_items(sd) ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); else { @@ -6747,14 +6756,14 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin sp += sp * i / 100; } } else { - //Maybe replace with potion_hp, but I'm unsure how that works [Playtester] - switch (skill_lv) { - case 1: hp = 45; break; - case 2: hp = 105; break; - case 3: hp = 175; break; - default: hp = 325; break; - } - hp = (hp + rnd()%(skill_lv*20+1)) * (150 + skill_lv*10) / 100; + //Maybe replace with potion_hp, but I'm unsure how that works [Playtester] + switch (skill_lv) { + case 1: hp = 45; break; + case 2: hp = 105; break; + case 3: hp = 175; break; + default: hp = 325; break; + } + hp = (hp + rnd()%(skill_lv*20+1)) * (150 + skill_lv*10) / 100; hp = hp * (100 + (tstatus->vit<<1)) / 100; if( dstsd ) hp = hp * (100 + pc->checkskill(dstsd,SM_RECOVERY)*10) / 100; @@ -6800,7 +6809,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; case AM_CP_SHIELD: { int i; - if(dstsd && (i=dstsd->equip_index[EQI_HAND_L])>=0 && dstsd->inventory_data[i] && + if(dstsd && (i=dstsd->equip_index[EQI_HAND_L])>=0 && dstsd->inventory_data[i] && dstsd->inventory_data[i]->type==IT_ARMOR) clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -6990,8 +6999,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin break; //Nothing to cancel. bl_skill_id = ud->skill_id; bl_skill_lv = ud->skill_lv; - if (tstatus->mode & MD_BOSS) - { //Only 10% success chance against bosses. [Skotlex] + if (tstatus->mode & MD_BOSS) { + //Only 10% success chance against bosses. [Skotlex] if (rnd()%100 < 90) { if (sd) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); @@ -7006,7 +7015,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin status_zap(bl, hp, sp); if (hp && skill_lv >= 5) - hp>>=1; //Recover half damaged HP at level 5 [Skotlex] + hp>>=1; //Recover half damaged HP at level 5 [Skotlex] else hp = 0; @@ -7032,9 +7041,11 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin static const int spellarray[3] = { MG_COLDBOLT,MG_FIREBOLT,MG_LIGHTNINGBOLT }; if(skill_lv >= 10) { spellid = MG_FROSTDIVER; - // if (tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SA_SAGE) - // maxlv = 10; - // else +#if 0 + if (tsc && tsc->data[SC_SOULLINK] && tsc->data[SC_SOULLINK]->val2 == SA_SAGE) + maxlv = 10; + else +#endif // 0 maxlv = skill_lv - 9; } else if(skill_lv >=8) { @@ -7110,7 +7121,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin struct unit_data *ud = unit->bl2ud(bl); if (clif->skill_nodamage(src,bl,skill_id,skill_lv, sc_start(src,bl,type,100,skill_lv,skill_time)) - && ud) { //Disable attacking/acting/moving for skill's duration. + && ud) { + //Disable attacking/acting/moving for skill's duration. ud->attackabletime = ud->canact_tick = ud->canmove_tick = tick + skill_time; @@ -7359,7 +7371,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin struct skill_unit *su=NULL; if((bl->type==BL_SKILL) && (su=(struct skill_unit *)bl) && (su->group) ){ switch(su->group->unit_id){ - case UNT_ANKLESNARE: // ankle snare + case UNT_ANKLESNARE: if (su->group->val2 != 0) // if it is already trapping something don't spring it, // remove trap should be used instead @@ -7514,7 +7526,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if(dstsd && dstsd->inventory_data[dstsd->equip_index[EQI_HAND_R]]) { iused=true; clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(src,bl,SC_PROTECTWEAPON,100,skill_lv,skill->get_time(skill_id,skill_lv))); - } if(dstsd && (i=dstsd->equip_index[EQI_HAND_L])>=0 && dstsd->inventory_data[i] && + } if(dstsd && (i=dstsd->equip_index[EQI_HAND_L])>=0 && dstsd->inventory_data[i] && dstsd->inventory_data[i]->type==IT_ARMOR) { iused=true; clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start(src,bl,SC_PROTECTSHIELD,100,skill_lv,skill->get_time(skill_id,skill_lv))); @@ -7533,7 +7545,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } break; - case RG_CLEANER: //AppleGirl + case RG_CLEANER: //AppleGirl clif->skill_nodamage(src,bl,skill_id,skill_lv,1); break; @@ -7571,16 +7583,16 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->specialeffect(bl, 523 + eff, AREA); switch (eff) { - case 0: // heals SP to 0 + case 0: // heals SP to 0 status_percent_damage(src, bl, 0, 100, false); break; - case 1: // matk halved + case 1: // matk halved sc_start(src,bl,SC_INCMATKRATE,100,-50,skill->get_time2(skill_id,skill_lv)); break; - case 2: // all buffs removed + case 2: // all buffs removed status->change_clear_buffs(bl,1); break; - case 3: // 1000 damage, random armor destroyed + case 3: // 1000 damage, random armor destroyed { status_fix_damage(src, bl, 1000, 0); clif->damage(src,bl,0,0,1000,0,0,0); @@ -7590,49 +7602,49 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } } break; - case 4: // atk halved + case 4: // atk halved sc_start(src,bl,SC_INCATKRATE,100,-50,skill->get_time2(skill_id,skill_lv)); break; - case 5: // 2000HP heal, random teleported + case 5: // 2000HP heal, random teleported status->heal(src, 2000, 0, 0); if( !map_flag_vs(bl->m) ) unit->warp(bl, -1,-1,-1, CLR_TELEPORT); break; - case 6: // random 2 other effects + case 6: // random 2 other effects if (count == -1) count = 3; else count++; //Should not re-trigger this one. break; - case 7: // stop freeze or stoned + case 7: // stop freeze or stoned { enum sc_type sc[] = { SC_STOP, SC_FREEZE, SC_STONE }; sc_start(src,bl,sc[rnd()%3],100,skill_lv,skill->get_time2(skill_id,skill_lv)); } break; - case 8: // curse coma and poison + case 8: // curse coma and poison sc_start(src,bl,SC_COMA,100,skill_lv,skill->get_time2(skill_id,skill_lv)); sc_start(src,bl,SC_CURSE,100,skill_lv,skill->get_time2(skill_id,skill_lv)); sc_start(src,bl,SC_POISON,100,skill_lv,skill->get_time2(skill_id,skill_lv)); break; - case 9: // confusion + case 9: // confusion sc_start(src,bl,SC_CONFUSION,100,skill_lv,skill->get_time2(skill_id,skill_lv)); break; - case 10: // 6666 damage, atk matk halved, cursed + case 10: // 6666 damage, atk matk halved, cursed status_fix_damage(src, bl, 6666, 0); clif->damage(src,bl,0,0,6666,0,0,0); sc_start(src,bl,SC_INCATKRATE,100,-50,skill->get_time2(skill_id,skill_lv)); sc_start(src,bl,SC_INCMATKRATE,100,-50,skill->get_time2(skill_id,skill_lv)); sc_start(src,bl,SC_CURSE,skill_lv,100,skill->get_time2(skill_id,skill_lv)); break; - case 11: // 4444 damage + case 11: // 4444 damage status_fix_damage(src, bl, 4444, 0); clif->damage(src,bl,0,0,4444,0,0,0); break; - case 12: // stun + case 12: // stun sc_start(src,bl,SC_STUN,100,skill_lv,5000); break; - case 13: // atk,matk,hit,flee,def reduced + case 13: // atk,matk,hit,flee,def reduced sc_start(src,bl,SC_INCATKRATE,100,-20,skill->get_time2(skill_id,skill_lv)); sc_start(src,bl,SC_INCMATKRATE,100,-20,skill->get_time2(skill_id,skill_lv)); sc_start(src,bl,SC_INCHITRATE,100,-20,skill->get_time2(skill_id,skill_lv)); @@ -7668,8 +7680,8 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; } - if (skill_id == SL_SUPERNOVICE && dstsd && dstsd->die_counter && !(rnd()%100)) - { //Erase death count 1% of the casts + if (skill_id == SL_SUPERNOVICE && dstsd && dstsd->die_counter && !(rnd()%100)) { + //Erase death count 1% of the casts dstsd->die_counter = 0; pc_setglobalreg(dstsd,script->add_str("PC_DIE_COUNTER"), 0); clif->specialeffect(bl, 0x152, AREA); @@ -7817,7 +7829,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } break; - case AM_CALLHOMUN: // [orn] + case AM_CALLHOMUN: // [orn] if( sd ) { if (homun->call(sd)) clif->skill_nodamage(src, bl, skill_id, skill_lv, 1); @@ -7835,7 +7847,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } break; - case HAMI_CASTLE: // [orn] + case HAMI_CASTLE: // [orn] if(rnd()%100 < 20*skill_lv && src != bl) { int x,y; @@ -7864,7 +7876,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin else if (sd) clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); break; - case HVAN_CHAOTIC: // [orn] + case HVAN_CHAOTIC: // [orn] { static const int per[5][2]={{20,50},{50,60},{25,75},{60,64},{34,67}}; int r = rnd()%100; @@ -8814,15 +8826,24 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin if (!tsc->data[i]) continue; switch(i){ - case SC_POISON: case SC_BLIND: - case SC_FREEZE: case SC_STONE: - case SC_STUN: case SC_SLEEP: - case SC_BLOODING: case SC_CURSE: - case SC_CONFUSION: case SC_ILLUSION: - case SC_SILENCE: case SC_BURNING: - case SC_COLD: case SC_FROSTMISTY: - case SC_DEEP_SLEEP: case SC_FEAR: - case SC_MANDRAGORA: case SC__CHAOS: + case SC_POISON: + case SC_BLIND: + case SC_FREEZE: + case SC_STONE: + case SC_STUN: + case SC_SLEEP: + case SC_BLOODING: + case SC_CURSE: + case SC_CONFUSION: + case SC_ILLUSION: + case SC_SILENCE: + case SC_BURNING: + case SC_COLD: + case SC_FROSTMISTY: + case SC_DEEP_SLEEP: + case SC_FEAR: + case SC_MANDRAGORA: + case SC__CHAOS: status_change_end(bl, (sc_type)i, INVALID_TIMER); } } @@ -8954,7 +8975,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin for( i = 0; i < ARRAYLENGTH(combo); i++ ) skill->addtimerskill(src, tick + 400 * i, bl->id, 0, 0, combo[i], skill_lv, BF_WEAPON, flag|SD_LEVEL); - break; + break; } case WA_SWING_DANCE: case WA_SYMPHONY_OF_LOVER: @@ -9198,9 +9219,9 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SO_EL_CONTROL: if( sd ) { - int mode = EL_MODE_PASSIVE; // Standard mode. + int mode = EL_MODE_PASSIVE; // Standard mode. - if( !sd->ed ) break; + if( !sd->ed ) break; if( skill_lv == 4 ) {// At level 4 delete elementals. elemental->delete(sd->ed, 0); @@ -9249,7 +9270,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin int s_hp = sd->battle_status.hp * 10 / 100, s_sp = sd->battle_status.sp * 10 / 100; int e_hp, e_sp; - if( !ed ) break; + if( !ed ) break; if( !status->charge(&sd->bl,s_hp,s_sp) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); break; @@ -9378,7 +9399,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin } else { clif->skill_nodamage(src,src,skill_id,skill_lv,1); clif->skill_damage(src, ( skill_id == EL_GUST || skill_id == EL_BLAST || skill_id == EL_WILD_STORM )?src:bl, tick, status_get_amotion(src), 0, -30000, 1, skill_id, skill_lv, 6); - if( skill_id == EL_WIND_STEP ) // There aren't teleport, just push the master away. + if( skill_id == EL_WIND_STEP ) // There aren't teleport, just push the master away. skill->blown(src,bl,(rnd()%skill->get_blewcount(skill_id,skill_lv))+1,rnd()%8,0); sc_start(src, src,type2,100,skill_lv,skill->get_time(skill_id,skill_lv)); sc_start(src, bl,type,100,skill_lv,skill->get_time(skill_id,skill_lv)); @@ -9767,7 +9788,7 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) { if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) ) ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); - if (sd) { //Cooldown application + if (sd) { //Cooldown application int i, cooldown = skill->get_cooldown(ud->skill_id, ud->skill_lv); for (i = 0; i < ARRAYLENGTH(sd->skillcooldown) && sd->skillcooldown[i].id; i++) { // Increases/Decreases cooldown of a skill by item/card bonuses. if (sd->skillcooldown[i].id == ud->skill_id){ @@ -9780,15 +9801,15 @@ int skill_castend_pos(int tid, int64 tick, int id, intptr_t data) { } if( battle_config.display_status_timers && sd ) clif->status_change(src, SI_POSTDELAY, 1, skill->delay_fix(src, ud->skill_id, ud->skill_lv), 0, 0, 0); -// if( sd ) -// { -// switch( ud->skill_id ) -// { -// case ????: -// sd->canequip_tick = tick + ????; -// break; -// } -// } +#if 0 + if (sd) { + switch (ud->skill_id) { + case ????: + sd->canequip_tick = tick + ????; + break; + } + } +#endif // 0 unit->set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1); status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);// only normal attack and auto cast skills benefit from its bonuses map->freeblock_lock(); @@ -9985,7 +10006,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui int r; //if(skill_lv <= 0) return 0; - if(skill_id > 0 && !skill_lv) return 0; // [Celest] + if(skill_id > 0 && !skill_lv) return 0; // [Celest] nullpo_ret(src); @@ -10111,7 +10132,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui case WE_CALLPARTNER: case WE_CALLPARENT: case WE_CALLBABY: - case AC_SHOWER: //Ground-placed skill implementation. + case AC_SHOWER: //Ground-placed skill implementation. case MA_SHOWER: case SA_LANDPROTECTOR: case BD_LULLABY: @@ -10194,7 +10215,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui if( skill->unitsetting(src,skill_id,skill_lv,x,y,0) ) map->list[src->m].setcell(src->m, x, y, CELL_NOICEWALL, true); break; - case RG_GRAFFITI: /* Graffiti [Valaris] */ + case RG_GRAFFITI: skill->clear_unitgroup(src); skill->unitsetting(src,skill_id,skill_lv,x,y,0); flag|=1; @@ -10438,7 +10459,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui sc_start(src,src,type,100,skill_lv,skill->get_time2(skill_id,skill_lv)); break; - case AM_RESURRECTHOMUN: // [orn] + case AM_RESURRECTHOMUN: // [orn] if (sd) { if (!homun->ressurect(sd, 20*skill_lv, x, y)) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); @@ -10764,7 +10785,8 @@ bool skill_dance_switch(struct skill_unit* su, int flag) { } prevflag = flag; - if( !flag ) { //Transform + if( !flag ) { + //Transform uint16 skill_id = su->val2&UF_SONG ? BA_DISSONANCE : DC_UGLYDANCE; // backup @@ -10782,7 +10804,8 @@ bool skill_dance_switch(struct skill_unit* su, int flag) { group->target_flag = skill->get_unit_target(skill_id); group->bl_flag = skill->get_unit_bl_target(skill_id); group->interval = skill->get_unit_interval(skill_id); - } else { //Restore + } else { + //Restore group->skill_id = backup.skill_id; group->skill_lv = backup.skill_lv; group->unit_id = backup.unit_id; @@ -10827,7 +10850,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ sd = BL_CAST(BL_PC, src); st = status->get_status_data(src); - sc = status->get_sc(src); // for traps, firewall and fogwall - celest + sc = status->get_sc(src); // for traps, firewall and fogwall - celest switch( skill_id ) { case SO_ELEMENTAL_SHIELD: @@ -10854,10 +10877,10 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ case AL_WARP: val1=skill_lv+6; - if(!(flag&1)) + if(!(flag&1)) { limit=2000; - else // previous implementation (not used anymore) - { //Warp Portal morphing to active mode, extract relevant data from src. [Skotlex] + } else { // previous implementation (not used anymore) + //Warp Portal morphing to active mode, extract relevant data from src. [Skotlex] if( src->type != BL_SKILL ) return NULL; group = ((TBL_SKILL*)src)->group; src = map->id2bl(group->src_id); @@ -10882,7 +10905,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ limit=1000; val1=skill_lv+2; break; - case WZ_QUAGMIRE: //The target changes to "all" if used in a gvg map. [Skotlex] + case WZ_QUAGMIRE: //The target changes to "all" if used in a gvg map. [Skotlex] case AM_DEMONSTRATION: case GN_HELLS_PLANT: if( skill_id == GN_HELLS_PLANT && map->getcell(src->m, x, y, CELL_CHKLANDPROTECTOR) ) @@ -10936,17 +10959,18 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ case SA_VIOLENTGALE: { struct skill_unit_group *old_sg; - if ((old_sg = skill->locate_element_field(src)) != NULL) - { //HelloKitty confirmed that these are interchangeable, + if ((old_sg = skill->locate_element_field(src)) != NULL) { + //HelloKitty confirmed that these are interchangeable, //so you can change element and not consume gemstones. - if (( - old_sg->skill_id == SA_VOLCANO || - old_sg->skill_id == SA_DELUGE || - old_sg->skill_id == SA_VIOLENTGALE - ) && old_sg->limit > 0) - { //Use the previous limit (minus the elapsed time) [Skotlex] + if (( old_sg->skill_id == SA_VOLCANO + || old_sg->skill_id == SA_DELUGE + || old_sg->skill_id == SA_VIOLENTGALE + ) + && old_sg->limit > 0 + ) { + //Use the previous limit (minus the elapsed time) [Skotlex] limit = old_sg->limit - DIFF_TICK32(timer->gettick(), old_sg->tick); - if (limit < 0) //This can happen... + if (limit < 0) //This can happen... limit = skill->get_time(skill_id,skill_lv); } skill->clear_group(src,1); @@ -11030,22 +11054,22 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ break; case BD_DRUMBATTLEFIELD: #ifdef RENEWAL - val1 = (skill_lv+5)*25; //Watk increase - val2 = skill_lv*10; //Def increase + val1 = (skill_lv+5)*25; //Watk increase + val2 = skill_lv*10; //Def increase #else - val1 = (skill_lv+1)*25; //Watk increase - val2 = (skill_lv+1)*2; //Def increase + val1 = (skill_lv+1)*25; //Watk increase + val2 = (skill_lv+1)*2; //Def increase #endif break; case BD_RINGNIBELUNGEN: - val1 = (skill_lv+2)*25; //Watk increase + val1 = (skill_lv+2)*25; //Watk increase break; case BD_RICHMANKIM: val1 = 25 + 11*skill_lv; //Exp increase bonus. break; case BD_SIEGFRIED: - val1 = 55 + skill_lv*5; //Elemental Resistance - val2 = skill_lv*10; //Status ailment resistance + val1 = 55 + skill_lv*5; //Elemental Resistance + val2 = skill_lv*10; //Status ailment resistance break; case WE_CALLPARTNER: if (sd) val1 = sd->status.partner_id; @@ -11168,7 +11192,7 @@ struct skill_unit_group* skill_unitsetting(struct block_list *src, uint16 skill_ group->state.song_dance = (unit_flag&(UF_DANCE|UF_SONG)?1:0)|(unit_flag&UF_ENSEMBLE?2:0); //Signals if this is a song/dance/duet group->state.guildaura = ( skill_id >= GD_LEADERSHIP && skill_id <= GD_HAWKEYES )?1:0; group->item_id = req_item; - //if tick is greater than current, do not invoke onplace function just yet. [Skotlex] + //if tick is greater than current, do not invoke onplace function just yet. [Skotlex] if (DIFF_TICK(group->tick, timer->gettick()) > SKILLUNITTIMER_INTERVAL) active_flag = 0; @@ -11479,12 +11503,13 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick sc_start4(ss,bl,type,100,sg->skill_lv,0,BCT_ENEMY,sg->group_id,sg->limit); break; - // officially, icewall has no problems existing on occupied cells [ultramage] - // case UNT_ICEWALL: //Destroy the cell. [Skotlex] - // src->val1 = 0; - // if(src->limit + sg->tick > tick + 700) - // src->limit = DIFF_TICK32(tick+700,sg->tick); - // break; +#if 0 // officially, icewall has no problems existing on occupied cells [ultramage] + case UNT_ICEWALL: //Destroy the cell. [Skotlex] + src->val1 = 0; + if(src->limit + sg->tick > tick + 700) + src->limit = DIFF_TICK32(tick+700,sg->tick); + break; +#endif // 0 case UNT_MOONLIT: //Knockback out of area if affected char isn't in Moonlit effect @@ -11497,7 +11522,7 @@ int skill_unit_onplace(struct skill_unit *src, struct block_list *bl, int64 tick case UNT_WALLOFTHORN: if( status_get_mode(bl)&MD_BOSS ) - break; // iRO Wiki says that this skill don't affect to Boss monsters. + break; // iRO Wiki says that this skill don't affect to Boss monsters. if( map_flag_vs(bl->m) || bl->id == src->bl.id || battle->check_target(&src->bl,bl, BCT_ENEMY) == 1 ) skill->attack(skill->get_type(sg->skill_id), ss, &src->bl, bl, sg->skill_id, sg->skill_lv, tick, 0); break; @@ -11563,9 +11588,20 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 if ( tsc && tsc->data[SC_HOVERING] ) { switch ( skill_id ) { - case HT_SKIDTRAP: case HT_LANDMINE: case HT_ANKLESNARE: case HT_FLASHER: case HT_SHOCKWAVE: - case HT_SANDMAN: case HT_FREEZINGTRAP: case HT_BLASTMINE: case HT_CLAYMORETRAP: case HW_GRAVITATION: - case SA_DELUGE: case SA_VOLCANO: case SA_VIOLENTGALE: case NJ_SUITON: + case HT_SKIDTRAP: + case HT_LANDMINE: + case HT_ANKLESNARE: + case HT_FLASHER: + case HT_SHOCKWAVE: + case HT_SANDMAN: + case HT_FREEZINGTRAP: + case HT_BLASTMINE: + case HT_CLAYMORETRAP: + case HW_GRAVITATION: + case SA_DELUGE: + case SA_VOLCANO: + case SA_VIOLENTGALE: + case NJ_SUITON: return 0; } } @@ -11827,7 +11863,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 skill->additional_effect(ss, bl, sg->skill_id, sg->skill_lv, BF_LONG|BF_SKILL|BF_MISC, ATK_DEF, tick); break; - case UNT_UGLYDANCE: //Ugly Dance [Skotlex] + case UNT_UGLYDANCE: if (ss->id != bl->id) skill->additional_effect(ss, bl, sg->skill_id, sg->skill_lv, BF_LONG|BF_SKILL|BF_MISC, ATK_DEF, tick); break; @@ -11854,7 +11890,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 status->heal(bl, heal, 0, 0); } break; - case UNT_TATAMIGAESHI: + case UNT_TATAMIGAESHI: case UNT_DEMONSTRATION: skill->attack(BF_WEAPON,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); break; @@ -12078,7 +12114,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 clif->fixpos(bl); sg->val2 = bl->id; } else - sec = 3000; // Couldn't trap it? + sec = 3000; // Couldn't trap it? sg->limit = DIFF_TICK32(tick, sg->tick) + sec; } else if( tsc->data[SC_THORNS_TRAP] && bl->id == sg->val2 ) skill->attack(skill->get_type(GN_THORNS_TRAP), ss, ss, bl, sg->skill_id, sg->skill_lv, tick, SD_LEVEL|SD_ANIMATION); @@ -12127,7 +12163,8 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 break; case UNT_WARMER: - { // It has effect on everything, including monsters, undead property and demon + { + // It has effect on everything, including monsters, undead property and demon int hp = 0; if( ssc && ssc->data[SC_HEATER_OPTION] ) hp = tstatus->max_hp * 3 * sg->skill_lv / 100; @@ -12267,7 +12304,8 @@ int skill_unit_onout(struct skill_unit *src, struct block_list *bl, int64 tick) if( sce && sce->val4 == src->bl.id ) status_change_end(bl, type, INVALID_TIMER); break; - case UNT_HERMODE: //Clear Hermode if the owner moved. + case UNT_HERMODE: + //Clear Hermode if the owner moved. if (sce && sce->val3 == BCT_SELF && sce->val4 == sg->group_id) status_change_end(bl, type, INVALID_TIMER); break; @@ -12328,8 +12366,8 @@ int skill_unit_onleft(uint16 skill_id, struct block_list *bl, int64 tick) { case BD_ROKISWEIL: case BD_INTOABYSS: case BD_SIEGFRIED: - if(sc && sc->data[SC_DANCING] && (sc->data[SC_DANCING]->val1&0xFFFF) == skill_id) - { //Check if you just stepped out of your ensemble skill to cancel dancing. [Skotlex] + if(sc && sc->data[SC_DANCING] && (sc->data[SC_DANCING]->val1&0xFFFF) == skill_id) { + //Check if you just stepped out of your ensemble skill to cancel dancing. [Skotlex] //We don't check for SC_LONGING because someone could always have knocked you back and out of the song/dance. //FIXME: This code is not perfect, it doesn't checks for the real ensemble's owner, //it only checks if you are doing the same ensemble. So if there's two chars doing an ensemble @@ -12437,7 +12475,7 @@ int skill_unit_effect(struct block_list* bl, va_list ap) { return 0; // Don't let a Bard/Dancer update their own song timer if( flag&4 ) - skill->unit_onleft(skill_id, bl, tick); + skill->unit_onleft(skill_id, bl, tick); } if( dissonance ) skill->dance_switch(su, 1); @@ -12487,7 +12525,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) { struct block_list *src; struct map_session_data *sd; struct map_session_data *tsd; - int *p_sd; //Contains the list of characters found. + int *p_sd; //Contains the list of characters found. nullpo_ret(bl); nullpo_ret(tsd=(struct map_session_data*)bl); @@ -12578,7 +12616,8 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16 if (!battle_config.player_skill_partner_check || pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL)) return is_chorus ? MAX_PARTY : 99; //As if there were infinite partners. - if (cast_flag) { //Execute the skill on the partners. + if (cast_flag) { + //Execute the skill on the partners. struct map_session_data* tsd; switch (skill_id) { case PR_BENEDICTIO: @@ -12651,7 +12690,7 @@ int skill_isammotype (struct map_session_data *sd, int skill_id) (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) && skill_id != HT_PHANTASMIC && skill->get_type(skill_id) == BF_WEAPON && - !(skill->get_nk(skill_id)&NK_NO_DAMAGE) && + !(skill->get_nk(skill_id)&NK_NO_DAMAGE) && !skill->get_spiritball(skill_id,1) //Assume spirit spheres are used as ammo instead. ); } @@ -12694,8 +12733,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if (sd->chatID) return 0; - if( pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id ) - { //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] + if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id) { + //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] sd->state.arrow_atk = skill->get_ammotype(skill_id)?1:0; //Need to do arrow state check. sd->spiritball_old = sd->spiritball; //Need to do Spiritball check. return 1; @@ -12737,8 +12776,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id sd->inventory_data[i] == NULL || !sd->inventory_data[i]->flag.delay_consume || sd->status.inventory[i].amount < 1 - ) - { //Something went wrong, item exploit? + ) { + //Something went wrong, item exploit? sd->itemid = sd->itemindex = -1; return 0; } @@ -12825,20 +12864,34 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id // Check the skills that can be used whiled using mado if( pc_ismadogear(sd) ) { switch ( skill_id ) { - case BS_GREED: case NC_BOOSTKNUCKLE: - case NC_PILEBUNKER: case NC_VULCANARM: - case NC_FLAMELAUNCHER: case NC_COLDSLOWER: - case NC_ARMSCANNON: case NC_ACCELERATION: - case NC_HOVERING: case NC_F_SIDESLIDE: - case NC_B_SIDESLIDE: case NC_SELFDESTRUCTION: - case NC_SHAPESHIFT: case NC_EMERGENCYCOOL: - case NC_INFRAREDSCAN: case NC_ANALYZE: - case NC_MAGNETICFIELD: case NC_NEUTRALBARRIER: - case NC_STEALTHFIELD: case NC_REPAIR: - case NC_AXEBOOMERANG: case NC_POWERSWING: - case NC_AXETORNADO: case NC_SILVERSNIPER: - case NC_MAGICDECOY: case NC_DISJOINT: - case NC_MAGMA_ERUPTION: case ALL_FULL_THROTTLE: + case BS_GREED: + case NC_BOOSTKNUCKLE: + case NC_PILEBUNKER: + case NC_VULCANARM: + case NC_FLAMELAUNCHER: + case NC_COLDSLOWER: + case NC_ARMSCANNON: + case NC_ACCELERATION: + case NC_HOVERING: + case NC_F_SIDESLIDE: + case NC_B_SIDESLIDE: + case NC_SELFDESTRUCTION: + case NC_SHAPESHIFT: + case NC_EMERGENCYCOOL: + case NC_INFRAREDSCAN: + case NC_ANALYZE: + case NC_MAGNETICFIELD: + case NC_NEUTRALBARRIER: + case NC_STEALTHFIELD: + case NC_REPAIR: + case NC_AXEBOOMERANG: + case NC_POWERSWING: + case NC_AXETORNADO: + case NC_SILVERSNIPER: + case NC_MAGICDECOY: + case NC_DISJOINT: + case NC_MAGMA_ERUPTION: + case ALL_FULL_THROTTLE: case NC_MAGMA_ERUPTION_DOTDAMAGE: break; default: @@ -12930,12 +12983,13 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id } return 0; case MO_EXTREMITYFIST: - // if(sc && sc->data[SC_EXTREMITYFIST]) //To disable Asura during the 5 min skill block uncomment this... - // return 0; - if( sc && (sc->data[SC_BLADESTOP] || sc->data[SC_CURSEDCIRCLE_ATKER]) ) +#if 0 //To disable Asura during the 5 min skill block uncomment this block... + if(sc && sc->data[SC_EXTREMITYFIST]) + return 0; +#endif // 0 + if (sc && (sc->data[SC_BLADESTOP] || sc->data[SC_CURSEDCIRCLE_ATKER])) break; - if( sc && sc->data[SC_COMBOATTACK] ) - { + if (sc && sc->data[SC_COMBOATTACK]) { switch(sc->data[SC_COMBOATTACK]->val1) { case MO_COMBOFINISH: case CH_TIGERFIST: @@ -12944,9 +12998,8 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id default: return 0; } - } - else if( !unit->can_move(&sd->bl) ) - { //Placed here as ST_MOVE_ENABLE should not apply if rooted or on a combo. [Skotlex] + } else if (!unit->can_move(&sd->bl)) { + //Placed here as ST_MOVE_ENABLE should not apply if rooted or on a combo. [Skotlex] clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } @@ -12981,14 +13034,15 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if(!(sc && sc->data[SC_COMBOATTACK]) || sc->data[SC_COMBOATTACK]->val1 == TK_JUMPKICK) return 0; //Combo needs to be ready - if (sc->data[SC_COMBOATTACK]->val3) { //Kick chain + if (sc->data[SC_COMBOATTACK]->val3) { //Kick chain //Do not repeat a kick. if (sc->data[SC_COMBOATTACK]->val3 != skill_id) break; status_change_end(&sd->bl, SC_COMBOATTACK, INVALID_TIMER); return 0; } - if(sc->data[SC_COMBOATTACK]->val1 != skill_id && !( sd && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )) { //Cancel combo wait. + if(sc->data[SC_COMBOATTACK]->val1 != skill_id && !( sd && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )) { + //Cancel combo wait. unit->cancel_combo(&sd->bl); return 0; } @@ -13295,11 +13349,11 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id case LG_RAYOFGENESIS: case LG_HESPERUSLIT: if( sc && sc->data[SC_INSPIRATION] ) - return 1; // Don't check for partner. + return 1; // Don't check for partner. if( !(sc && sc->data[SC_BANDING]) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL,0); return 0; - } + } if( sc->data[SC_BANDING] && sc->data[SC_BANDING]->val2 < (skill_id == LG_RAYOFGENESIS ? 2 : 3) ) return 0; // Just fails, no msg here. @@ -13370,7 +13424,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id } break; case SO_FIREWALK: - case SO_ELECTRICWALK: // Can't be casted until you've walked all cells. + case SO_ELECTRICWALK: // Can't be casted until you've walked all cells. if( sc && sc->data[SC_PROPERTYWALK] && sc->data[SC_PROPERTYWALK]->val3 < skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2) ) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); @@ -13589,12 +13643,14 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id return 0; } +#if 0 // There's no need to check if the skill is part of a combo if it's // already been checked before, see unit_skilluse_id2 [Panikon] // Note that if this check is read part of issue:8047 will reappear! - //if( sd->sc.data[SC_COMBOATTACK] && !skill->is_combo(skill_id ) ) - // return 0; - + if( sd->sc.data[SC_COMBOATTACK] && !skill->is_combo(skill_id ) ) + return 0; +#endif // 0 + return 1; } @@ -13919,7 +13975,7 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 idx = skill->get_index(skill_id); if( idx == 0 ) // invalid skill id - return req; + return req; if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL ) return req; @@ -14000,7 +14056,7 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 continue; break; case WZ_FIREPILLAR: // celest - if (skill_lv <= 5) // no gems required at level 1-5 + if (skill_lv <= 5) // no gems required at level 1-5 continue; break; case AB_ADORAMUS: @@ -14031,10 +14087,9 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 req.itemid[i] = skill->db[idx].itemid[i]; req.amount[i] = skill->db[idx].amount[i]; - if( itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN ) - { - if( sd->special_state.no_gemstone ) - { // All gem skills except Hocus Pocus and Ganbantein can cast for free with Mistress card [helvetica] + if (itemid_isgemstone(req.itemid[i]) && skill_id != HW_GANBANTEIN) { + if (sd->special_state.no_gemstone) { + // All gem skills except Hocus Pocus and Ganbantein can cast for free with Mistress card [helvetica] if( skill_id != SA_ABRACADABRA ) req.itemid[i] = req.amount[i] = 0; else if( --req.amount[i] < 1 ) @@ -14146,7 +14201,7 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16 case CH_TIGERFIST: req.spiritball = 3; break; - case CH_CHAINCRUSH: //It should consume whatever is left as long as it's at least 1. + case CH_CHAINCRUSH: //It should consume whatever is left as long as it's at least 1. req.spiritball = sd->spiritball?sd->spiritball:1; break; } @@ -14196,10 +14251,10 @@ int skill_castfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { // calculate base cast time (reduced by dex) if( !(skill->get_castnodex(skill_id, skill_lv)&1) ) { int scale = battle_config.castrate_dex_scale - status_get_dex(bl); - if( scale > 0 ) // not instant cast + if( scale > 0 ) // not instant cast time = time * scale / battle_config.castrate_dex_scale; else - return 0; // instant cast + return 0; // instant cast } // calculate cast time reduced by item/card bonuses @@ -14224,9 +14279,9 @@ int skill_castfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { if (battle_config.cast_rate != 100) time = time * battle_config.cast_rate / 100; // return final cast time - time = max(time, 0); + time = max(time, 0); -// ShowInfo("Castime castfix = %d\n",time); + //ShowInfo("Castime castfix = %d\n",time); return time; } @@ -14411,10 +14466,11 @@ int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { return battle_config.min_skill_delay_limit; if (time < 0) - time = -time + status_get_amotion(bl); // If set to <0, add to attack motion. + time = -time + status_get_amotion(bl); // If set to <0, add to attack motion. // Delay reductions - switch (skill_id) { //Monk combo skills have their delay reduced by agi/dex. + switch (skill_id) { + //Monk combo skills have their delay reduced by agi/dex. case MO_TRIPLEATTACK: case MO_CHAINCOMBO: case MO_COMBOFINISH: @@ -14429,16 +14485,16 @@ int skill_delay_fix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { time = 0; // There is no Delay on Basilica creation, only on cancel break; default: - if (battle_config.delay_dependon_dex && !(delaynodex&1)) - { // if skill delay is allowed to be reduced by dex + if (battle_config.delay_dependon_dex && !(delaynodex&1)) { + // if skill delay is allowed to be reduced by dex int scale = battle_config.castrate_dex_scale - status_get_dex(bl); if (scale > 0) time = time * scale / battle_config.castrate_dex_scale; else //To be capped later to minimum. time = 0; } - if (battle_config.delay_dependon_agi && !(delaynodex&1)) - { // if skill delay is allowed to be reduced by agi + if (battle_config.delay_dependon_agi && !(delaynodex&1)) { + // if skill delay is allowed to be reduced by agi int scale = battle_config.castrate_dex_scale - status_get_agi(bl); if (scale > 0) time = time * scale / battle_config.castrate_dex_scale; @@ -14749,7 +14805,8 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) if(item->nameid > 0 && ditem->type == IT_WEAPON) { - if( ditem->flag.no_refine ){ // if the item isn't refinable + if( ditem->flag.no_refine ) { + // if the item isn't refinable clif->skill_fail(sd,sd->menuskill_id,USESKILL_FAIL_LEVEL,0); return; } @@ -14830,7 +14887,7 @@ int skill_autospell (struct map_session_data *sd, uint16 skill_id) if(!skill_lv || !lv) return 0; // Player must learn the skill before doing auto-spell [Lance] - if(skill_id==MG_NAPALMBEAT) maxlv=3; + if(skill_id==MG_NAPALMBEAT) maxlv=3; else if(skill_id==MG_COLDBOLT || skill_id==MG_FIREBOLT || skill_id==MG_LIGHTNINGBOLT){ if (sd->sc.data[SC_SOULLINK] && sd->sc.data[SC_SOULLINK]->val2 == SL_SAGE) maxlv =10; //Soul Linker bonus. [Skotlex] @@ -15971,7 +16028,7 @@ int skill_unit_timer_sub(DBKey key, DBData *data, va_list ap) { struct skill_unit* su = DB->data2ptr(data); struct skill_unit_group* group = su->group; int64 tick = va_arg(ap,int64); - bool dissonance; + bool dissonance; struct block_list* bl = &su->bl; if( !su->alive ) @@ -16216,8 +16273,8 @@ int skill_unit_move_sub(struct block_list* bl, va_list ap) { //Necessary in case the group is deleted after calling on_place/on_out [Skotlex] skill_id = su->group->skill_id; - if( su->group->interval != -1 && !(skill->get_unit_flag(skill_id)&UF_DUALMODE) && skill_id != BD_LULLABY ) //Lullaby is the exception, bugreport:411 - { //Non-dualmode unit skills with a timer don't trigger when walking, so just return + if( su->group->interval != -1 && !(skill->get_unit_flag(skill_id)&UF_DUALMODE) && skill_id != BD_LULLABY ) { //Lullaby is the exception, bugreport:411 + //Non-dualmode unit skills with a timer don't trigger when walking, so just return if( dissonance ) skill->dance_switch(su, 1); return 0; } @@ -16331,11 +16388,11 @@ int skill_unit_move_unit_group(struct skill_unit_group *group, int16 m, int16 dx return 0; //Icewalls and Wall of Thorns don't get knocked back m_flag = (int *) aCalloc(group->unit_count, sizeof(int)); - // m_flag - // 0: Neither of the following (skill_unit_onplace & skill_unit_onout are needed) - // 1: Unit will move to a slot that had another unit of the same group (skill_unit_onplace not needed) - // 2: Another unit from same group will end up positioned on this unit (skill_unit_onout not needed) - // 3: Both 1+2. + // m_flag: + // 0: Neither of the following (skill_unit_onplace & skill_unit_onout are needed) + // 1: Unit will move to a slot that had another unit of the same group (skill_unit_onplace not needed) + // 2: Another unit from same group will end up positioned on this unit (skill_unit_onout not needed) + // 3: Both 1+2. for(i=0;i<group->unit_count;i++) { su1=&group->unit[i]; if (!su1->alive || su1->bl.m!=m) @@ -16787,9 +16844,8 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, } break; default: - if (sd->menuskill_id == AM_PHARMACY && - sd->menuskill_val > 10 && sd->menuskill_val <= 20) - { //Assume Cooking Dish + if (sd->menuskill_id == AM_PHARMACY && sd->menuskill_val > 10 && sd->menuskill_val <= 20) { + //Assume Cooking Dish if (sd->menuskill_val >= 15) //Legendary Cooking Set. make_per = 10000; //100% Success else @@ -16880,9 +16936,10 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, } } -// if(log_config.produce > 0) -// log_produce(sd,nameid,slot1,slot2,slot3,1); -//TODO update PICKLOG +#if 0 // TODO: update PICKLOG + if(log_config.produce > 0) + log_produce(sd,nameid,slot1,slot2,slot3,1); +#endif // 0 if(equip){ clif->produce_effect(sd,0,nameid); @@ -16893,7 +16950,8 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, int fame = 0; tmp_item.amount = 0; - for (i=0; i< qty; i++) { //Apply quantity modifiers. + for (i=0; i< qty; i++) { + //Apply quantity modifiers. if( (skill_id == GN_MIX_COOKING || skill_id == GN_MAKEBOMB || skill_id == GN_S_PHARMACY) && make_per > 1){ tmp_item.amount = qty; break; @@ -16991,9 +17049,10 @@ int skill_produce_mix(struct map_session_data *sd, uint16 skill_id, int nameid, } } //Failure -// if(log_config.produce) -// log_produce(sd,nameid,slot1,slot2,slot3,0); -//TODO update PICKLOG +#if 0 // TODO: update PICKLOG + if(log_config.produce) + log_produce(sd,nameid,slot1,slot2,slot3,0); +#endif // 0 if(equip){ clif->produce_effect(sd,1,nameid); @@ -17314,7 +17373,8 @@ int skill_elementalanalysis(struct map_session_data* sd, int n, uint16 skill_lv, return 1; } - if( skill_lv == 2 && rnd()%100 < 25 ) { // At level 2 have a fail chance. You loose your items if it fails. + if( skill_lv == 2 && rnd()%100 < 25 ) { + // At level 2 have a fail chance. You loose your items if it fails. clif->skill_fail(sd,SO_EL_ANALYSIS,USESKILL_FAIL_LEVEL,0); return 1; } @@ -17366,7 +17426,7 @@ int skill_changematerial(struct map_session_data *sd, int n, unsigned short *ite } } else - break; // No more items required + break; // No more items required } p++; } while(n == j && c == n); @@ -17645,7 +17705,8 @@ int skill_split_atoi (char *str, int *val) { } if(i==0) //No data found. return 0; - if(i==1) { //Single value, have the whole range have the same value. + if(i==1) { + //Single value, have the whole range have the same value. for (; i < MAX_SKILL_LEVEL; i++) val[i] = val[i-1]; return i; @@ -17960,44 +18021,132 @@ int skill_block_check(struct block_list *bl, sc_type type , uint16 skill_id) { if( inf == INF2_SONG_DANCE || skill->get_inf2(skill_id) == INF2_CHORUS_SKILL || inf == INF2_SPIRIT_SKILL ) return 1; // Can't do it. switch( skill_id ) { - case NV_FIRSTAID: case TF_HIDING: case AS_CLOAKING: case WZ_SIGHTRASHER: - case RG_STRIPWEAPON: case RG_STRIPSHIELD: case RG_STRIPARMOR: case WZ_METEOR: - case RG_STRIPHELM: case SC_STRIPACCESSARY: case ST_FULLSTRIP: case WZ_SIGHTBLASTER: - case ST_CHASEWALK: case SC_ENERVATION: case SC_GROOMY: case WZ_ICEWALL: - case SC_IGNORANCE: case SC_LAZINESS: case SC_UNLUCKY: case WZ_STORMGUST: - case SC_WEAKNESS: case AL_RUWACH: case AL_PNEUMA: case WZ_JUPITEL: - case AL_HEAL: case AL_BLESSING: case AL_INCAGI: case WZ_VERMILION: - case AL_TELEPORT: case AL_WARP: case AL_HOLYWATER: case WZ_EARTHSPIKE: - case AL_HOLYLIGHT: case PR_IMPOSITIO: case PR_ASPERSIO: case WZ_HEAVENDRIVE: - case PR_SANCTUARY: case PR_STRECOVERY: case PR_MAGNIFICAT: case WZ_QUAGMIRE: - case ALL_RESURRECTION: case PR_LEXDIVINA: case PR_LEXAETERNA: case HW_GRAVITATION: - case PR_MAGNUS: case PR_TURNUNDEAD: case MG_SRECOVERY: case HW_MAGICPOWER: - case MG_SIGHT: case MG_NAPALMBEAT: case MG_SAFETYWALL: case HW_GANBANTEIN: - case MG_SOULSTRIKE: case MG_COLDBOLT: case MG_FROSTDIVER: case WL_DRAINLIFE: - case MG_STONECURSE: case MG_FIREBALL: case MG_FIREWALL: case WL_SOULEXPANSION: - case MG_FIREBOLT: case MG_LIGHTNINGBOLT: case MG_THUNDERSTORM: case MG_ENERGYCOAT: - case WL_WHITEIMPRISON: case WL_SUMMONFB: case WL_SUMMONBL: case WL_SUMMONWB: - case WL_SUMMONSTONE: case WL_SIENNAEXECRATE: case WL_RELEASE: case WL_EARTHSTRAIN: - case WL_RECOGNIZEDSPELL: case WL_READING_SB: case SA_MAGICROD: case SA_SPELLBREAKER: - case SA_DISPELL: case SA_FLAMELAUNCHER: case SA_FROSTWEAPON: case SA_LIGHTNINGLOADER: - case SA_SEISMICWEAPON: case SA_VOLCANO: case SA_DELUGE: case SA_VIOLENTGALE: - case SA_LANDPROTECTOR: case PF_HPCONVERSION: case PF_SOULCHANGE: case PF_SPIDERWEB: - case PF_FOGWALL: case TK_RUN: case TK_HIGHJUMP: case TK_SEVENWIND: - case SL_KAAHI: case SL_KAUPE: case SL_KAITE: + case NV_FIRSTAID: + case TF_HIDING: + case AS_CLOAKING: + case WZ_SIGHTRASHER: + case RG_STRIPWEAPON: + case RG_STRIPSHIELD: + case RG_STRIPARMOR: + case WZ_METEOR: + case RG_STRIPHELM: + case SC_STRIPACCESSARY: + case ST_FULLSTRIP: + case WZ_SIGHTBLASTER: + case ST_CHASEWALK: + case SC_ENERVATION: + case SC_GROOMY: + case WZ_ICEWALL: + case SC_IGNORANCE: + case SC_LAZINESS: + case SC_UNLUCKY: + case WZ_STORMGUST: + case SC_WEAKNESS: + case AL_RUWACH: + case AL_PNEUMA: + case WZ_JUPITEL: + case AL_HEAL: + case AL_BLESSING: + case AL_INCAGI: + case WZ_VERMILION: + case AL_TELEPORT: + case AL_WARP: + case AL_HOLYWATER: + case WZ_EARTHSPIKE: + case AL_HOLYLIGHT: + case PR_IMPOSITIO: + case PR_ASPERSIO: + case WZ_HEAVENDRIVE: + case PR_SANCTUARY: + case PR_STRECOVERY: + case PR_MAGNIFICAT: + case WZ_QUAGMIRE: + case ALL_RESURRECTION: + case PR_LEXDIVINA: + case PR_LEXAETERNA: + case HW_GRAVITATION: + case PR_MAGNUS: + case PR_TURNUNDEAD: + case MG_SRECOVERY: + case HW_MAGICPOWER: + case MG_SIGHT: + case MG_NAPALMBEAT: + case MG_SAFETYWALL: + case HW_GANBANTEIN: + case MG_SOULSTRIKE: + case MG_COLDBOLT: + case MG_FROSTDIVER: + case WL_DRAINLIFE: + case MG_STONECURSE: + case MG_FIREBALL: + case MG_FIREWALL: + case WL_SOULEXPANSION: + case MG_FIREBOLT: + case MG_LIGHTNINGBOLT: + case MG_THUNDERSTORM: + case MG_ENERGYCOAT: + case WL_WHITEIMPRISON: + case WL_SUMMONFB: + case WL_SUMMONBL: + case WL_SUMMONWB: + case WL_SUMMONSTONE: + case WL_SIENNAEXECRATE: + case WL_RELEASE: + case WL_EARTHSTRAIN: + case WL_RECOGNIZEDSPELL: + case WL_READING_SB: + case SA_MAGICROD: + case SA_SPELLBREAKER: + case SA_DISPELL: + case SA_FLAMELAUNCHER: + case SA_FROSTWEAPON: + case SA_LIGHTNINGLOADER: + case SA_SEISMICWEAPON: + case SA_VOLCANO: + case SA_DELUGE: + case SA_VIOLENTGALE: + case SA_LANDPROTECTOR: + case PF_HPCONVERSION: + case PF_SOULCHANGE: + case PF_SPIDERWEB: + case PF_FOGWALL: + case TK_RUN: + case TK_HIGHJUMP: + case TK_SEVENWIND: + case SL_KAAHI: + case SL_KAUPE: + case SL_KAITE: // Skills that need to be confirmed. - case SO_FIREWALK: case SO_ELECTRICWALK: case SO_SPELLFIST: case SO_EARTHGRAVE: - case SO_DIAMONDDUST: case SO_POISON_BUSTER: case SO_PSYCHIC_WAVE: case SO_CLOUD_KILL: - case SO_STRIKING: case SO_WARMER: case SO_VACUUM_EXTREME: case SO_VARETYR_SPEAR: + case SO_FIREWALK: + case SO_ELECTRICWALK: + case SO_SPELLFIST: + case SO_EARTHGRAVE: + case SO_DIAMONDDUST: + case SO_POISON_BUSTER: + case SO_PSYCHIC_WAVE: + case SO_CLOUD_KILL: + case SO_STRIKING: + case SO_WARMER: + case SO_VACUUM_EXTREME: + case SO_VARETYR_SPEAR: case SO_ARRULLO: - return 1; // Can't do it. + return 1; // Can't do it. } break; case SC_KG_KAGEHUMI: switch(skill_id) { - case TF_HIDING: case AS_CLOAKING: case GC_CLOAKINGEXCEED: case SC_SHADOWFORM: - case MI_HARMONIZE: case CG_MARIONETTE: case AL_TELEPORT: case TF_BACKSLIDING: - case RA_CAMOUFLAGE: case ST_CHASEWALK: case GD_EMERGENCYCALL: + case TF_HIDING: + case AS_CLOAKING: + case GC_CLOAKINGEXCEED: + case SC_SHADOWFORM: + case MI_HARMONIZE: + case CG_MARIONETTE: + case AL_TELEPORT: + case TF_BACKSLIDING: + case RA_CAMOUFLAGE: + case ST_CHASEWALK: + case GD_EMERGENCYCALL: return 1; // needs more info } break; @@ -18010,10 +18159,10 @@ int skill_get_elemental_type( uint16 skill_id , uint16 skill_lv ) { int type = 0; switch( skill_id ) { - case SO_SUMMON_AGNI: type = 2114; break; - case SO_SUMMON_AQUA: type = 2117; break; - case SO_SUMMON_VENTUS: type = 2120; break; - case SO_SUMMON_TERA: type = 2123; break; + case SO_SUMMON_AGNI: type = 2114; break; + case SO_SUMMON_AQUA: type = 2117; break; + case SO_SUMMON_VENTUS: type = 2120; break; + case SO_SUMMON_TERA: type = 2123; break; } type += skill_lv - 1; @@ -18148,7 +18297,7 @@ bool skill_parse_row_requiredb(char* split[], int columns, int current) { skill->split_atoi(split[5],skill->db[idx].sp_rate); skill->split_atoi(split[6],skill->db[idx].zeny); - //Which weapon type are required, see doc/item_db for types + //Which weapon type are required, see doc/item_db for types p = split[7]; for( j = 0; j < 32; j++ ) { int l = atoi(p); diff --git a/src/map/skill.h b/src/map/skill.h index 4ec742bd0..f0a54b982 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -26,29 +26,29 @@ struct status_change_entry; /** * Defines **/ -#define MAX_SKILL_DB MAX_SKILL -#define MAX_SKILL_PRODUCE_DB 270 -#define MAX_PRODUCE_RESOURCE 10 -#define MAX_SKILL_ARROW_DB 140 -#define MAX_ARROW_RESOURCE 5 -#define MAX_SKILL_ABRA_DB 210 -#define MAX_SKILL_IMPROVISE_DB 30 -#define MAX_SKILL_LEVEL 10 -#define MAX_SKILL_UNIT_LAYOUT 45 -#define MAX_SQUARE_LAYOUT 5 // 11*11 Placement of a maximum unit -#define MAX_SKILL_UNIT_COUNT ((MAX_SQUARE_LAYOUT*2+1)*(MAX_SQUARE_LAYOUT*2+1)) -#define MAX_SKILLTIMERSKILL 15 -#define MAX_SKILLUNITGROUP 25 -#define MAX_SKILL_ITEM_REQUIRE 10 +#define MAX_SKILL_DB MAX_SKILL +#define MAX_SKILL_PRODUCE_DB 270 +#define MAX_PRODUCE_RESOURCE 10 +#define MAX_SKILL_ARROW_DB 140 +#define MAX_ARROW_RESOURCE 5 +#define MAX_SKILL_ABRA_DB 210 +#define MAX_SKILL_IMPROVISE_DB 30 +#define MAX_SKILL_LEVEL 10 +#define MAX_SKILL_UNIT_LAYOUT 45 +#define MAX_SQUARE_LAYOUT 5 // 11*11 Placement of a maximum unit +#define MAX_SKILL_UNIT_COUNT ((MAX_SQUARE_LAYOUT*2+1)*(MAX_SQUARE_LAYOUT*2+1)) +#define MAX_SKILLTIMERSKILL 15 +#define MAX_SKILLUNITGROUP 25 +#define MAX_SKILL_ITEM_REQUIRE 10 #define MAX_SKILLUNITGROUPTICKSET 25 -#define MAX_SKILL_NAME_LENGTH 30 +#define MAX_SKILL_NAME_LENGTH 30 // (Epoque:) To-do: replace this macro with some sort of skill tree check (rather than hard-coded skill names) #define skill_ischangesex(id) ( \ ((id) >= BD_ADAPTATION && (id) <= DC_SERVICEFORYOU) || ((id) >= CG_ARROWVULCAN && (id) <= CG_MARIONETTE) || \ ((id) >= CG_LONGINGFREEDOM && (id) <= CG_TAROTCARD) || ((id) >= WA_SWING_DANCE && (id) <= WM_UNLIMITED_HUMMING_VOICE)) -#define MAX_SKILL_SPELLBOOK_DB 17 +#define MAX_SKILL_SPELLBOOK_DB 17 #define MAX_SKILL_MAGICMUSHROOM_DB 23 //Walk intervals at which chase-skills are attempted to be triggered. @@ -99,7 +99,7 @@ enum e_skill_inf2 { INF2_GUILD_ONLY = 0x0800, INF2_NO_ENEMY = 0x1000, INF2_NOLP = 0x2000, // Spells that can ignore Land Protector - INF2_CHORUS_SKILL = 0x4000, // Chorus skill + INF2_CHORUS_SKILL = 0x4000, // Chorus skill }; @@ -112,19 +112,19 @@ enum e_skill_display { }; enum { - UF_DEFNOTENEMY = 0x0001, // If 'defunit_not_enemy' is set, the target is changed to 'friend' - UF_NOREITERATION = 0x0002, // Spell cannot be stacked - UF_NOFOOTSET = 0x0004, // Spell cannot be cast near/on targets - UF_NOOVERLAP = 0x0008, // Spell effects do not overlap - UF_PATHCHECK = 0x0010, // Only cells with a shootable path will be placed - UF_NOPC = 0x0020, // May not target players - UF_NOMOB = 0x0040, // May not target mobs - UF_SKILL = 0x0080, // May target skills - UF_DANCE = 0x0100, // Dance - UF_ENSEMBLE = 0x0200, // Duet - UF_SONG = 0x0400, // Song - UF_DUALMODE = 0x0800, // Spells should trigger both ontimer and onplace/onout/onleft effects. - UF_RANGEDSINGLEUNIT = 0x2000 // Hack for ranged layout, only display center + UF_DEFNOTENEMY = 0x0001, // If 'defunit_not_enemy' is set, the target is changed to 'friend' + UF_NOREITERATION = 0x0002, // Spell cannot be stacked + UF_NOFOOTSET = 0x0004, // Spell cannot be cast near/on targets + UF_NOOVERLAP = 0x0008, // Spell effects do not overlap + UF_PATHCHECK = 0x0010, // Only cells with a shootable path will be placed + UF_NOPC = 0x0020, // May not target players + UF_NOMOB = 0x0040, // May not target mobs + UF_SKILL = 0x0080, // May target skills + UF_DANCE = 0x0100, // Dance + UF_ENSEMBLE = 0x0200, // Duet + UF_SONG = 0x0400, // Song + UF_DUALMODE = 0x0800, // Spells should trigger both ontimer and onplace/onout/onleft effects. + UF_RANGEDSINGLEUNIT = 0x2000, // Hack for ranged layout, only display center }; //Returns the cast type of the skill: ground cast, castend damage, castend no damage @@ -1623,14 +1623,14 @@ enum { UNT_MAKIBISHI, UNT_VENOMFOG, UNT_ICEMINE, - UNT_FLAMECROSS, - UNT_HELLBURNING, - UNT_MAGMA_ERUPTION, + UNT_FLAMECROSS, + UNT_HELLBURNING, + UNT_MAGMA_ERUPTION, UNT_KINGS_GRACE, UNT_GLITTERING_GREED, UNT_B_TRAP, UNT_FIRE_RAIN, - + /** * Guild Auras **/ @@ -1638,7 +1638,7 @@ enum { UNT_GD_GLORYWOUNDS = 0xc2, UNT_GD_SOULCOLD = 0xc3, UNT_GD_HAWKEYES = 0xc4, - + UNT_MAX = 0x190 }; @@ -1703,10 +1703,10 @@ struct skill_unit_group { int bg_id; int map; int target_flag; //Holds BCT_* flag for battle_check_target - int bl_flag; //Holds BL_* flag for map_foreachin* functions + int bl_flag; //Holds BL_* flag for map_foreachin* functions int64 tick; int limit,interval; - + uint16 skill_id,skill_lv; int val1,val2,val3; char *valstr; @@ -1724,9 +1724,9 @@ struct skill_unit_group { struct skill_unit { struct block_list bl; - + struct skill_unit_group *group; - + int limit; int val1,val2; short alive,range; @@ -1852,49 +1852,49 @@ struct skill_interface { int unit_temp[20]; // temporary storage for tracking skill unit skill ids as players move in/out of them int unit_group_newid; /* accesssors */ - int (*get_index) ( uint16 skill_id ); - int (*get_type) ( uint16 skill_id ); - int (*get_hit) ( uint16 skill_id ); - int (*get_inf) ( uint16 skill_id ); - int (*get_ele) ( uint16 skill_id, uint16 skill_lv ); - int (*get_nk) ( uint16 skill_id ); - int (*get_max) ( uint16 skill_id ); - int (*get_range) ( uint16 skill_id, uint16 skill_lv ); - int (*get_range2) (struct block_list *bl, uint16 skill_id, uint16 skill_lv); - int (*get_splash) ( uint16 skill_id, uint16 skill_lv ); - int (*get_hp) ( uint16 skill_id, uint16 skill_lv ); - int (*get_mhp) ( uint16 skill_id, uint16 skill_lv ); - int (*get_sp) ( uint16 skill_id, uint16 skill_lv ); - int (*get_state) (uint16 skill_id); - int (*get_spiritball) (uint16 skill_id, uint16 skill_lv); - int (*get_zeny) ( uint16 skill_id, uint16 skill_lv ); - int (*get_num) ( uint16 skill_id, uint16 skill_lv ); - int (*get_cast) ( uint16 skill_id, uint16 skill_lv ); - int (*get_delay) ( uint16 skill_id, uint16 skill_lv ); - int (*get_walkdelay) ( uint16 skill_id, uint16 skill_lv ); - int (*get_time) ( uint16 skill_id, uint16 skill_lv ); - int (*get_time2) ( uint16 skill_id, uint16 skill_lv ); - int (*get_castnodex) ( uint16 skill_id, uint16 skill_lv ); - int (*get_delaynodex) ( uint16 skill_id ,uint16 skill_lv ); - int (*get_castdef) ( uint16 skill_id ); - int (*get_weapontype) ( uint16 skill_id ); - int (*get_ammotype) ( uint16 skill_id ); - int (*get_ammo_qty) ( uint16 skill_id, uint16 skill_lv ); - int (*get_unit_id) (uint16 skill_id,int flag); - int (*get_inf2) ( uint16 skill_id ); - int (*get_castcancel) ( uint16 skill_id ); - int (*get_maxcount) ( uint16 skill_id, uint16 skill_lv ); - int (*get_blewcount) ( uint16 skill_id, uint16 skill_lv ); - int (*get_unit_flag) ( uint16 skill_id ); - int (*get_unit_target) ( uint16 skill_id ); - int (*get_unit_interval) ( uint16 skill_id ); - int (*get_unit_bl_target) ( uint16 skill_id ); - int (*get_unit_layout_type) ( uint16 skill_id ,uint16 skill_lv ); - int (*get_unit_range) ( uint16 skill_id, uint16 skill_lv ); - int (*get_cooldown) ( uint16 skill_id, uint16 skill_lv ); - int (*tree_get_max) ( uint16 skill_id, int b_class ); - const char* (*get_name) ( uint16 skill_id ); - const char* (*get_desc) ( uint16 skill_id ); + int (*get_index) ( uint16 skill_id ); + int (*get_type) ( uint16 skill_id ); + int (*get_hit) ( uint16 skill_id ); + int (*get_inf) ( uint16 skill_id ); + int (*get_ele) ( uint16 skill_id, uint16 skill_lv ); + int (*get_nk) ( uint16 skill_id ); + int (*get_max) ( uint16 skill_id ); + int (*get_range) ( uint16 skill_id, uint16 skill_lv ); + int (*get_range2) (struct block_list *bl, uint16 skill_id, uint16 skill_lv); + int (*get_splash) ( uint16 skill_id, uint16 skill_lv ); + int (*get_hp) ( uint16 skill_id, uint16 skill_lv ); + int (*get_mhp) ( uint16 skill_id, uint16 skill_lv ); + int (*get_sp) ( uint16 skill_id, uint16 skill_lv ); + int (*get_state) (uint16 skill_id); + int (*get_spiritball) (uint16 skill_id, uint16 skill_lv); + int (*get_zeny) ( uint16 skill_id, uint16 skill_lv ); + int (*get_num) ( uint16 skill_id, uint16 skill_lv ); + int (*get_cast) ( uint16 skill_id, uint16 skill_lv ); + int (*get_delay) ( uint16 skill_id, uint16 skill_lv ); + int (*get_walkdelay) ( uint16 skill_id, uint16 skill_lv ); + int (*get_time) ( uint16 skill_id, uint16 skill_lv ); + int (*get_time2) ( uint16 skill_id, uint16 skill_lv ); + int (*get_castnodex) ( uint16 skill_id, uint16 skill_lv ); + int (*get_delaynodex) ( uint16 skill_id ,uint16 skill_lv ); + int (*get_castdef) ( uint16 skill_id ); + int (*get_weapontype) ( uint16 skill_id ); + int (*get_ammotype) ( uint16 skill_id ); + int (*get_ammo_qty) ( uint16 skill_id, uint16 skill_lv ); + int (*get_unit_id) (uint16 skill_id,int flag); + int (*get_inf2) ( uint16 skill_id ); + int (*get_castcancel) ( uint16 skill_id ); + int (*get_maxcount) ( uint16 skill_id, uint16 skill_lv ); + int (*get_blewcount) ( uint16 skill_id, uint16 skill_lv ); + int (*get_unit_flag) ( uint16 skill_id ); + int (*get_unit_target) ( uint16 skill_id ); + int (*get_unit_interval) ( uint16 skill_id ); + int (*get_unit_bl_target) ( uint16 skill_id ); + int (*get_unit_layout_type) ( uint16 skill_id ,uint16 skill_lv ); + int (*get_unit_range) ( uint16 skill_id, uint16 skill_lv ); + int (*get_cooldown) ( uint16 skill_id, uint16 skill_lv ); + int (*tree_get_max) ( uint16 skill_id, int b_class ); + const char *(*get_name) ( uint16 skill_id ); + const char *(*get_desc) ( uint16 skill_id ); /* check */ void (*chk) (uint16* skill_id); /* whether its CAST_GROUND, CAST_DAMAGE or CAST_NODAMAGE */ diff --git a/src/map/status.c b/src/map/status.c index 4b31b9486..e2eede490 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -245,7 +245,7 @@ void initChangeTables(void) { set_sc( NPC_BARRIER , SC_BARRIER , SI_BLANK , SCB_MDEF|SCB_DEF ); add_sc( NPC_DEFENDER , SC_ARMOR ); add_sc( NPC_LICK , SC_STUN ); - set_sc( NPC_HALLUCINATION , SC_ILLUSION , SI_ILLUSION , SCB_NONE ); + set_sc( NPC_HALLUCINATION , SC_ILLUSION , SI_ILLUSION , SCB_NONE ); add_sc( NPC_REBIRTH , SC_REBIRTH ); add_sc( RG_RAID , SC_STUN ); #ifdef RENEWAL @@ -469,8 +469,8 @@ void initChangeTables(void) { set_sc( HAMI_BLOODLUST , SC_HAMI_BLOODLUST , SI_BLANK , SCB_BATK|SCB_WATK ); // Homunculus S - set_sc( MH_LIGHT_OF_REGENE , SC_LIGHT_OF_REGENE , SI_LIGHT_OF_REGENE , SCB_NONE ); - set_sc( MH_OVERED_BOOST , SC_OVERED_BOOST , SI_OVERED_BOOST , SCB_FLEE|SCB_ASPD|SCB_DEF ); + set_sc( MH_LIGHT_OF_REGENE , SC_LIGHT_OF_REGENE , SI_LIGHT_OF_REGENE , SCB_NONE ); + set_sc( MH_OVERED_BOOST , SC_OVERED_BOOST , SI_OVERED_BOOST , SCB_FLEE|SCB_ASPD|SCB_DEF ); add_sc(MH_STAHL_HORN, SC_STUN); set_sc(MH_ANGRIFFS_MODUS, SC_ANGRIFFS_MODUS, SI_ANGRIFFS_MODUS, SCB_BATK | SCB_DEF | SCB_FLEE | SCB_MAXHP); @@ -529,14 +529,14 @@ void initChangeTables(void) { set_sc( RK_DEATHBOUND , SC_DEATHBOUND , SI_DEATHBOUND , SCB_NONE ); set_sc( RK_WINDCUTTER , SC_FEAR , SI_BLANK , SCB_FLEE|SCB_HIT ); add_sc( RK_DRAGONBREATH , SC_BURNING ); - set_sc( RK_MILLENNIUMSHIELD , SC_MILLENNIUMSHIELD , SI_BLANK , SCB_NONE ); + set_sc( RK_MILLENNIUMSHIELD , SC_MILLENNIUMSHIELD , SI_BLANK , SCB_NONE ); set_sc( RK_REFRESH , SC_REFRESH , SI_REFRESH , SCB_NONE ); set_sc( RK_GIANTGROWTH , SC_GIANTGROWTH , SI_GIANTGROWTH , SCB_STR ); set_sc( RK_STONEHARDSKIN , SC_STONEHARDSKIN , SI_STONEHARDSKIN , SCB_NONE ); set_sc( RK_VITALITYACTIVATION, SC_VITALITYACTIVATION, SI_VITALITYACTIVATION, SCB_REGEN ); set_sc( RK_FIGHTINGSPIRIT , SC_FIGHTINGSPIRIT , SI_FIGHTINGSPIRIT , SCB_WATK|SCB_ASPD ); set_sc( RK_ABUNDANCE , SC_ABUNDANCE , SI_ABUNDANCE , SCB_NONE ); - set_sc( RK_CRUSHSTRIKE , SC_CRUSHSTRIKE , SI_CRUSHSTRIKE , SCB_NONE ); + set_sc( RK_CRUSHSTRIKE , SC_CRUSHSTRIKE , SI_CRUSHSTRIKE , SCB_NONE ); add_sc( RK_DRAGONBREATH_WATER, SC_FROSTMISTY ); /** * GC Guillotine Cross @@ -724,25 +724,25 @@ void initChangeTables(void) { set_sc( EL_ROCK_CRUSHER , SC_ROCK_CRUSHER , SI_ROCK_CRUSHER , SCB_DEF ); set_sc( EL_ROCK_CRUSHER_ATK, SC_ROCK_CRUSHER_ATK , SI_ROCK_CRUSHER_ATK , SCB_SPEED ); - add_sc( KO_YAMIKUMO , SC_HIDING ); - set_sc_with_vfx( KO_JYUMONJIKIRI , SC_KO_JYUMONJIKIRI , SI_KO_JYUMONJIKIRI , SCB_NONE ); - add_sc( KO_MAKIBISHI , SC_STUN ); - set_sc( KO_MEIKYOUSISUI , SC_MEIKYOUSISUI , SI_MEIKYOUSISUI , SCB_NONE ); - set_sc( KO_KYOUGAKU , SC_KYOUGAKU , SI_KYOUGAKU , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); - add_sc( KO_JYUSATSU , SC_CURSE ); - set_sc( KO_ZENKAI , SC_ZENKAI , SI_ZENKAI , SCB_NONE ); - set_sc( KO_IZAYOI , SC_IZAYOI , SI_IZAYOI , SCB_MATK ); - set_sc( KG_KYOMU , SC_KYOMU , SI_KYOMU , SCB_NONE ); - set_sc( KG_KAGEMUSYA , SC_KAGEMUSYA , SI_KAGEMUSYA , SCB_NONE ); - set_sc( KG_KAGEHUMI , SC_KG_KAGEHUMI , SI_KG_KAGEHUMI , SCB_NONE ); - set_sc( OB_ZANGETSU , SC_ZANGETSU , SI_ZANGETSU , SCB_MATK|SCB_BATK ); - set_sc_with_vfx( OB_AKAITSUKI , SC_AKAITSUKI , SI_AKAITSUKI , SCB_NONE ); - set_sc( OB_OBOROGENSOU , SC_GENSOU , SI_GENSOU , SCB_NONE ); - - set_sc( ALL_FULL_THROTTLE , SC_FULL_THROTTLE , SI_FULL_THROTTLE , SCB_SPEED|SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); - - add_sc( ALL_REVERSEORCISH , SC_ORCISH ); - set_sc( ALL_ANGEL_PROTECT , SC_ANGEL_PROTECT , SI_ANGEL_PROTECT , SCB_REGEN ); + add_sc( KO_YAMIKUMO , SC_HIDING ); + set_sc_with_vfx( KO_JYUMONJIKIRI , SC_KO_JYUMONJIKIRI , SI_KO_JYUMONJIKIRI , SCB_NONE ); + add_sc( KO_MAKIBISHI , SC_STUN ); + set_sc( KO_MEIKYOUSISUI , SC_MEIKYOUSISUI , SI_MEIKYOUSISUI , SCB_NONE ); + set_sc( KO_KYOUGAKU , SC_KYOUGAKU , SI_KYOUGAKU , SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); + add_sc( KO_JYUSATSU , SC_CURSE ); + set_sc( KO_ZENKAI , SC_ZENKAI , SI_ZENKAI , SCB_NONE ); + set_sc( KO_IZAYOI , SC_IZAYOI , SI_IZAYOI , SCB_MATK ); + set_sc( KG_KYOMU , SC_KYOMU , SI_KYOMU , SCB_NONE ); + set_sc( KG_KAGEMUSYA , SC_KAGEMUSYA , SI_KAGEMUSYA , SCB_NONE ); + set_sc( KG_KAGEHUMI , SC_KG_KAGEHUMI , SI_KG_KAGEHUMI , SCB_NONE ); + set_sc( OB_ZANGETSU , SC_ZANGETSU , SI_ZANGETSU , SCB_MATK|SCB_BATK ); + set_sc_with_vfx( OB_AKAITSUKI, SC_AKAITSUKI , SI_AKAITSUKI , SCB_NONE ); + set_sc( OB_OBOROGENSOU , SC_GENSOU , SI_GENSOU , SCB_NONE ); + + set_sc( ALL_FULL_THROTTLE , SC_FULL_THROTTLE , SI_FULL_THROTTLE , SCB_SPEED|SCB_STR|SCB_AGI|SCB_VIT|SCB_INT|SCB_DEX|SCB_LUK ); + + add_sc( ALL_REVERSEORCISH , SC_ORCISH ); + set_sc( ALL_ANGEL_PROTECT , SC_ANGEL_PROTECT , SI_ANGEL_PROTECT , SCB_REGEN ); add_sc( NPC_WIDEHEALTHFEAR , SC_FEAR ); add_sc( NPC_WIDEBODYBURNNING , SC_BURNING ); @@ -750,7 +750,7 @@ void initChangeTables(void) { add_sc( NPC_WIDECOLD , SC_COLD ); add_sc( NPC_WIDE_DEEP_SLEEP , SC_DEEP_SLEEP ); add_sc( NPC_WIDESIREN , SC_SIREN ); - + set_sc_with_vfx( GN_ILLUSIONDOPING , SC_ILLUSIONDOPING , SI_ILLUSIONDOPING , SCB_HIT ); // Storing the target job rather than simply SC_SOULLINK simplifies code later on. @@ -1022,32 +1022,32 @@ void initChangeTables(void) { status->ChangeFlagTable[SC_DECORATION_OF_MUSIC] |= SCB_NONE; /* status->DisplayType Table [Ind/Hercules] */ - status->DisplayType[SC_ALL_RIDING] = true; - status->DisplayType[SC_PUSH_CART] = true; - status->DisplayType[SC_SUMMON1] = true; - status->DisplayType[SC_SUMMON2] = true; - status->DisplayType[SC_SUMMON3] = true; - status->DisplayType[SC_SUMMON4] = true; - status->DisplayType[SC_SUMMON5] = true; - status->DisplayType[SC_CAMOUFLAGE] = true; - status->DisplayType[SC_DUPLELIGHT] = true; - status->DisplayType[SC_ORATIO] = true; - status->DisplayType[SC_FROSTMISTY] = true; - status->DisplayType[SC_VENOMIMPRESS] = true; - status->DisplayType[SC_HALLUCINATIONWALK] = true; - status->DisplayType[SC_ROLLINGCUTTER] = true; - status->DisplayType[SC_BANDING] = true; - status->DisplayType[SC_COLD] = true; - status->DisplayType[SC_DEEP_SLEEP] = true; - status->DisplayType[SC_CURSEDCIRCLE_ATKER]= true; - status->DisplayType[SC_CURSEDCIRCLE_TARGET]= true; - status->DisplayType[SC_BLOOD_SUCKER] = true; - status->DisplayType[SC__SHADOWFORM] = true; - status->DisplayType[SC_MONSTER_TRANSFORM] = true; - status->DisplayType[SC_MOONSTAR] = true; - status->DisplayType[SC_SUPER_STAR] = true; - status->DisplayType[SC_STRANGELIGHTS] = true; - status->DisplayType[SC_DECORATION_OF_MUSIC] = true; + status->DisplayType[SC_ALL_RIDING] = true; + status->DisplayType[SC_PUSH_CART] = true; + status->DisplayType[SC_SUMMON1] = true; + status->DisplayType[SC_SUMMON2] = true; + status->DisplayType[SC_SUMMON3] = true; + status->DisplayType[SC_SUMMON4] = true; + status->DisplayType[SC_SUMMON5] = true; + status->DisplayType[SC_CAMOUFLAGE] = true; + status->DisplayType[SC_DUPLELIGHT] = true; + status->DisplayType[SC_ORATIO] = true; + status->DisplayType[SC_FROSTMISTY] = true; + status->DisplayType[SC_VENOMIMPRESS] = true; + status->DisplayType[SC_HALLUCINATIONWALK] = true; + status->DisplayType[SC_ROLLINGCUTTER] = true; + status->DisplayType[SC_BANDING] = true; + status->DisplayType[SC_COLD] = true; + status->DisplayType[SC_DEEP_SLEEP] = true; + status->DisplayType[SC_CURSEDCIRCLE_ATKER] = true; + status->DisplayType[SC_CURSEDCIRCLE_TARGET] = true; + status->DisplayType[SC_BLOOD_SUCKER] = true; + status->DisplayType[SC__SHADOWFORM] = true; + status->DisplayType[SC_MONSTER_TRANSFORM] = true; + status->DisplayType[SC_MOONSTAR] = true; + status->DisplayType[SC_SUPER_STAR] = true; + status->DisplayType[SC_STRANGELIGHTS] = true; + status->DisplayType[SC_DECORATION_OF_MUSIC] = true; #ifdef RENEWAL_EDP // renewal EDP increases your weapon atk @@ -1141,7 +1141,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, /* here onwards we consider it a 32-type, the client does not support higher and from here onwards the value doesn't get thru percentage modifiers */ hp = (int)cap_value(in_hp,INT_MIN,INT_MAX); sp = (int)cap_value(in_sp,INT_MIN,INT_MAX); - + if(sp && !(target->type&BL_CONSUME)) sp = 0; //Not a valid SP target. @@ -1178,10 +1178,12 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if( !st->hp ) flag |= 8; +#if 0 // Let through. battle.c/skill.c have the whole logic of when it's possible or // not to hurt someone (and this check breaks pet catching) [Skotlex] - // if (!target->prev && !(flag&2)) - // return 0; //Cannot damage a bl not on a map, except when "charging" hp/sp + if (!target->prev && !(flag&2)) + return 0; //Cannot damage a bl not on a map, except when "charging" hp/sp +#endif // 0 sc = status->get_sc(target); if( hp && battle_config.invincible_nodamage && src && sc && sc->data[SC_INVINCIBLE] && !sc->data[SC_INVINCIBLEOFF] ) @@ -1190,11 +1192,11 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if( hp && !(flag&1) ) { if( sc ) { struct status_change_entry *sce; - + #ifdef DEVOTION_REFLECT_DAMAGE if(src && (sce = sc->data[SC_DEVOTION])) { struct block_list *d_bl = map->id2bl(sce->val1); - + if(d_bl &&((d_bl->type == BL_MER && ((TBL_MER *)d_bl)->master && ((TBL_MER *)d_bl)->master->bl.id == target->id) || (d_bl->type == BL_PC && ((TBL_PC *)d_bl)->devotion[sce->val2] == target->id)) && check_distance_bl(target, d_bl, sce->val3)) { clif->damage(d_bl, d_bl, 0, 0, hp, 0, 0, 0); @@ -1204,7 +1206,6 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, status_change_end(target, SC_DEVOTION, INVALID_TIMER); } #endif - if (sc->data[SC_STONE] && sc->opt1 == OPT1_STONE) status_change_end(target, SC_STONE, INVALID_TIMER); status_change_end(target, SC_FREEZE, INVALID_TIMER); @@ -1268,8 +1269,8 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, unit->stop_walking( target, 1 ); } - if( st->hp || (flag&8) ) - { //Still lives or has been dead before this damage. + if (st->hp || (flag&8)) { + //Still lives or has been dead before this damage. if (walkdelay) unit->set_walkdelay(target, timer->gettick(), walkdelay, 0); return (int)(hp+sp); @@ -1287,7 +1288,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, case BL_HOM: flag = homun->dead((TBL_HOM*)target); break; case BL_MER: flag = mercenary->dead((TBL_MER*)target); break; case BL_ELEM: flag = elemental->dead((TBL_ELEM*)target); break; - default: //Unhandled case, do nothing to object. + default: //Unhandled case, do nothing to object. flag = 0; break; } @@ -1373,7 +1374,7 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) { /* here onwards we consider it a 32-type, the client does not support higher and from here onwards the value doesn't get thru percentage modifiers */ hp = (int)cap_value(in_hp,INT_MIN,INT_MAX); sp = (int)cap_value(in_sp,INT_MIN,INT_MAX); - + sc = status->get_sc(bl); if (sc && !sc->count) sc = NULL; @@ -1517,13 +1518,12 @@ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per if (bl->prev) //Animation only if character is already on a map. clif->resurrection(bl, 1); - + switch (bl->type) { case BL_PC: pc->revive((TBL_PC*)bl, hp, sp); break; case BL_MOB: mob->revive((TBL_MOB*)bl, hp); break; case BL_HOM: homun->revive((TBL_HOM*)bl, hp, sp); break; } - return 1; } @@ -1543,7 +1543,7 @@ int status_fixed_revive(struct block_list *bl, unsigned int per_hp, unsigned int hp = st->max_hp - st->hp; else if (per_hp && !hp) hp = 1; - + if(sp > st->max_sp - st->sp) sp = st->max_sp - st->sp; else if (per_sp && !sp) @@ -1566,9 +1566,9 @@ int status_fixed_revive(struct block_list *bl, unsigned int per_hp, unsigned int * Checks whether the src can use the skill on the target, * taking into account status/option of both source/target. [Skotlex] * flag: -* 0 - Trying to use skill on target. -* 1 - Cast bar is done. -* 2 - Skill already pulled off, check is due to ground-based skills or splash-damage ones. +* 0 - Trying to use skill on target. +* 1 - Cast bar is done. +* 2 - Skill already pulled off, check is due to ground-based skills or splash-damage ones. * src MAY be null to indicate we shouldn't check it, this is a ground-based skill attack. * target MAY Be null, in which case the checks are only to see * whether the source can cast or not the skill on the ground. @@ -1701,12 +1701,13 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin } } if ((sc->data[SC_DANCING]->val1&0xFFFF) == CG_HERMODE && skill_id == BD_ADAPTATION) - return 0; //Can't amp out of Wand of Hermode :/ [Skotlex] + return 0; //Can't amp out of Wand of Hermode :/ [Skotlex] } if (skill_id && //Do not block item-casted skills. (src->type != BL_PC || ((TBL_PC*)src)->skillitem != skill_id) - ) { //Skills blocked through status changes... + ) { + //Skills blocked through status changes... if (!flag && ( //Blocked only from using the skill (stuff like autospell may still go through sc->data[SC_SILENCE] || sc->data[SC_STEELBODY] || @@ -1822,7 +1823,8 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin } } break; - case BL_ITEM: //Allow targeting of items to pick'em up (or in the case of mobs, to loot them). + case BL_ITEM: + //Allow targeting of items to pick'em up (or in the case of mobs, to loot them). //TODO: Would be nice if this could be used to judge whether the player can or not pick up the item it targets. [Skotlex] if (st->mode&MD_LOOTER) return 1; @@ -1853,7 +1855,7 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin int status_check_visibility(struct block_list *src, struct block_list *target) { int view_range; struct status_change *tsc = NULL; - + switch (src->type) { case BL_MOB: view_range = ((TBL_MOB*)src)->min_chase; @@ -1870,7 +1872,7 @@ int status_check_visibility(struct block_list *src, struct block_list *target) { if( src->type == BL_NPC ) /* NPCs don't care for the rest */ return 1; - + if( ( tsc = status->get_sc(target) ) ) { struct status_data *st = status->get_status_data(src); @@ -1899,11 +1901,14 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) short mod = -1; switch( sd->weapontype2 ){ // adjustment for dual wielding - case W_DAGGER: mod = 0; break; // 0, 1, 1 + case W_DAGGER: + mod = 0; + break; // 0, 1, 1 case W_1HSWORD: - case W_1HAXE: mod = 1; + case W_1HAXE: + mod = 1; if( (sd->class_&MAPID_THIRDMASK) == MAPID_GUILLOTINE_CROSS ) // 0, 2, 3 - mod = sd->weapontype2 / W_1HSWORD + W_1HSWORD / sd->weapontype2 ; + mod = sd->weapontype2 / W_1HSWORD + W_1HSWORD / sd->weapontype2; } amotion = ( sd->status.weapon < MAX_WEAPON_TYPE && mod < 0 ) @@ -1926,14 +1931,13 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) // percentual delay reduction from stats amotion -= amotion * (4*st->agi + st->dex)/1000; #endif - // raw delay adjustment from bAspd bonus amotion += sd->bonus.aspd_add; /* angra manyu disregards aspd_base and similar */ if( sd->equip_index[EQI_HAND_R] >= 0 && sd->status.inventory[sd->equip_index[EQI_HAND_R]].nameid == ITEMID_ANGRA_MANYU ) return 0; - + return amotion; } @@ -2215,8 +2219,8 @@ int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) { status->calc_misc(&md->bl, mstatus, md->level); - if(flag&4) - { // Strengthen Guardians - custom value +10% / lv + if (flag&4) { + // Strengthen Guardians - custom value +10% / lv struct guild_castle *gc; gc=guild->mapname2gc(map->list[md->bl.m].name); if (!gc) @@ -2297,7 +2301,7 @@ int status_calc_pet_(struct pet_data *pd, enum e_status_calc_opt opt) status->calc_misc(&pd->bl, &pd->status, lv); - if (! (opt&SCO_FIRST) ) //Not done the first time because the pet is not visible yet + if (! (opt&SCO_FIRST) ) //Not done the first time because the pet is not visible yet clif->send_petstatus(sd); } } else if ( opt&SCO_FIRST ) { @@ -2396,7 +2400,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { b_max_weight = sd->max_weight; b_cart_weight_max = sd->cart_weight_max; - pc->calc_skilltree(sd); // SkillTree calculation + pc->calc_skilltree(sd); // SkillTree calculation sd->max_weight = status->max_weight_base[pc->class2idx(sd->status.class_)]+sd->status.str*300; @@ -2472,7 +2476,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { clif->sc_end(&sd->bl,sd->bl.id,SELF,SI_CLAIRVOYANCE); memset(&sd->special_state,0,sizeof(sd->special_state)); - + if (!sd->state.permanent_speed) { memset(&bstatus->max_hp, 0, sizeof(struct status_data)-(sizeof(bstatus->hp)+sizeof(bstatus->sp))); bstatus->speed = DEFAULT_WALK_SPEED; @@ -2481,7 +2485,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { memset(&bstatus->max_hp, 0, sizeof(struct status_data)-(sizeof(bstatus->hp)+sizeof(bstatus->sp))); bstatus->speed = pSpeed; } - + //FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex] //Give them all modes except these (useful for clones) bstatus->mode = MD_MASK&~(MD_BOSS|MD_PLANT|MD_DETECTOR|MD_ANGRY|MD_TARGETWEAK); @@ -2569,8 +2573,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { bstatus->def += sd->inventory_data[index]->def; - if(opt&SCO_FIRST && sd->inventory_data[index]->equip_script) - { //Execute equip-script on login + if (opt&SCO_FIRST && sd->inventory_data[index]->equip_script) { + //Execute equip-script on login script->run(sd->inventory_data[index]->equip_script,0,sd->bl.id,0); if (!calculating) return 1; @@ -2620,8 +2624,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { return 1; } - if(sd->status.inventory[index].card[0]==CARD0_FORGE) - { // Forged weapon + if (sd->status.inventory[index].card[0]==CARD0_FORGE) { + // Forged weapon wd->star += (sd->status.inventory[index].card[1]>>8); if(wd->star >= 15) wd->star = 40; // 3 Star Crumbs now give +40 dmg if(pc->famerank(MakeDWord(sd->status.inventory[index].card[2],sd->status.inventory[index].card[3]) ,MAPID_BLACKSMITH)) @@ -2649,7 +2653,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { if(sd->equip_index[EQI_AMMO] >= 0){ index = sd->equip_index[EQI_AMMO]; - if(sd->inventory_data[index]){ // Arrows + if (sd->inventory_data[index]) { + // Arrows sd->bonus.arrow_atk += sd->inventory_data[index]->atk; sd->state.lr_flag = 2; if( !itemdb_is_GNthrowable(sd->inventory_data[index]->nameid) ) //don't run scripts on throwable items @@ -2664,7 +2669,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { for( i = 0; i < sd->combo_count; i++ ) { struct item_combo *combo = itemdb->id2combo(sd->combos[i].id); unsigned char j; - + /** * ensure combo usage is allowed at this location **/ @@ -2677,10 +2682,10 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { if( k != map->list[sd->bl.m].zone->disabled_items_count ) break; } - + if( j != combo->count ) continue; - + script->run(sd->combos[i].bonus,0,sd->bl.id,0); if (!calculating) //Abort, script->run retriggered this. return 1; @@ -3191,7 +3196,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { sd->subele[ELE_HOLY] += sc->data[SC_PROVIDENCE]->val2; sd->subrace[RC_DEMON] += sc->data[SC_PROVIDENCE]->val2; } - if(sc->data[SC_ARMORPROPERTY]) { //This status change should grant card-type elemental resist. + if(sc->data[SC_ARMORPROPERTY]) { + //This status change should grant card-type elemental resist. sd->subele[ELE_WATER] += sc->data[SC_ARMORPROPERTY]->val1; sd->subele[ELE_EARTH] += sc->data[SC_ARMORPROPERTY]->val2; sd->subele[ELE_FIRE] += sc->data[SC_ARMORPROPERTY]->val3; @@ -3333,7 +3339,7 @@ int status_calc_homunculus_(struct homun_data *hd, enum e_status_calc_opt opt) { homun->calc_skilltree(hd, 0); if((skill_lv=homun->checkskill(hd,HAMI_SKIN)) > 0) - hstatus->def += skill_lv * 4; + hstatus->def += skill_lv * 4; if((skill_lv = homun->checkskill(hd,HVAN_INSTRUCT)) > 0) { hstatus->int_ += 1 +skill_lv/2 +skill_lv/4 +skill_lv/5; @@ -3578,8 +3584,8 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str || sc->data[SC_MAGICMUSHROOM] || sc->data[SC_RAISINGDRAGON] || sc->data[SC_SATURDAY_NIGHT_FEVER] - ) //No regen - regen->flag = 0; + ) + regen->flag = 0; //No regen if ( sc->data[SC_DANCING] || sc->data[SC_OBLIVIONCURSE] || sc->data[SC_MAXIMIZEPOWER] || sc->data[SC_REBOUND] || ( bl->type == BL_PC && (((TBL_PC*)bl)->class_&MAPID_UPPERMASK) == MAPID_MONK @@ -3868,9 +3874,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { } // No status changes alter these yet. - // if(flag&SCB_SIZE) - // if(flag&SCB_RACE) - // if(flag&SCB_RANGE) + //if(flag&SCB_SIZE) + //if(flag&SCB_RACE) + //if(flag&SCB_RANGE) if(flag&SCB_MAXHP) { if( bl->type&BL_PC ) { @@ -3944,7 +3950,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { amotion = (1000 - 2*st->agi - st->dex) * ((TBL_HOM*)bl)->homunculusDB->baseASPD/1000; #else amotion = (1000 - 4*st->agi - st->dex) * ((TBL_HOM*)bl)->homunculusDB->baseASPD/1000; -#endif +#endif st->aspd_rate = status->calc_aspd_rate(bl, sc, bst->aspd_rate); if(st->aspd_rate != 1000) @@ -4013,7 +4019,7 @@ void status_calc_bl_(struct block_list *bl, enum scb_flag flag, enum e_status_ca return; } } - + // remember previous values st = status->get_status_data(bl); memcpy(&bst, st, sizeof(struct status_data)); @@ -4270,7 +4276,7 @@ unsigned short status_calc_agi(struct block_list *bl, struct status_change *sc, if(sc->data[SC_INC_AGI]) agi += sc->data[SC_INC_AGI]->val2; if(sc->data[SC_GS_ACCURACY]) - agi += 4; // added based on skill updates [Reddozen] + agi += 4; // added based on skill updates [Reddozen] if(sc->data[SC_DEC_AGI]) agi -= sc->data[SC_DEC_AGI]->val2; if(sc->data[SC_QUAGMIRE]) @@ -4446,7 +4452,7 @@ unsigned short status_calc_dex(struct block_list *bl, struct status_change *sc, dex >>= 1; } if(sc->data[SC_GS_ACCURACY]) - dex += 4; // added based on skill updates [Reddozen] + dex += 4; // added based on skill updates [Reddozen] if(sc->data[SC_MARIONETTE_MASTER]) dex -= ((sc->data[SC_MARIONETTE_MASTER]->val4)>>8)&0xFF; if(sc->data[SC_MARIONETTE]) @@ -4578,9 +4584,10 @@ unsigned short status_calc_batk(struct block_list *bl, struct status_change *sc, batk -= batk * 25/100; if( sc->data[SC_ZANGETSU] ) batk += sc->data[SC_ZANGETSU]->val2; - //Curse shouldn't effect on this? <- Curse OR Bleeding?? - // if(sc->data[SC_BLOODING]) - // batk -= batk * 25/100; +#if 0 //Curse shouldn't effect on this? <- Curse OR Bleeding?? + if(sc->data[SC_BLOODING]) + batk -= batk * 25/100; +#endif // 0 if(sc->data[SC_HLIF_FLEET]) batk += batk * sc->data[SC_HLIF_FLEET]->val3/100; if(sc->data[SC__ENERVATION]) @@ -4838,7 +4845,7 @@ signed short status_calc_hit(struct block_list *bl, struct status_change *sc, in hit /= 2; if(sc->data[SC_ILLUSIONDOPING]) hit -= hit * (5 + sc->data[SC_ILLUSIONDOPING]->val1) / 100; //custom - + return (short)cap_value(hit,1,SHRT_MAX); } @@ -4923,7 +4930,7 @@ signed short status_calc_flee(struct block_list *bl, struct status_change *sc, i if(status_get_element(bl) == ELE_WATER) //water type flee /= 2; } - + if( sc->data[SC_OVERED_BOOST] ) // should be final and unmodifiable by any means flee = sc->data[SC_OVERED_BOOST]->val2; @@ -4981,7 +4988,7 @@ defType status_calc_def(struct block_list *bl, struct status_change *sc, int def if(sc->data[SC_STEELBODY]) return 90; #endif - + if(sc->data[SC_STONEHARDSKIN]) def += sc->data[SC_STONEHARDSKIN]->val1; if(sc->data[SC_DRUMBATTLE]) @@ -4989,7 +4996,7 @@ defType status_calc_def(struct block_list *bl, struct status_change *sc, int def if(sc->data[SC_STONESKIN]) def += sc->data[SC_STONESKIN]->val2; - if(sc->data[SC_HAMI_DEFENCE]) //[orn] + if(sc->data[SC_HAMI_DEFENCE]) //[orn] def += sc->data[SC_HAMI_DEFENCE]->val2; if(sc->data[SC_EARTH_INSIGNIA] && sc->data[SC_EARTH_INSIGNIA]->val1 == 2) @@ -5307,7 +5314,7 @@ unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc if( sc->data[SC__GROOMY] ) val = max( val, sc->data[SC__GROOMY]->val2); if( sc->data[SC_GLOOMYDAY] ) - val = max( val, sc->data[SC_GLOOMYDAY]->val3 ); // Should be 50 (-50% speed) + val = max( val, sc->data[SC_GLOOMYDAY]->val3 ); // Should be 50 (-50% speed) if( sc->data[SC_STEALTHFIELD_MASTER] ) val = max( val, 30 ); if( sc->data[SC_BANDING_DEFENCE] ) @@ -5517,7 +5524,7 @@ short status_calc_aspd(struct block_list *bl, struct status_change *sc, short fl skills2 += sc->data[SC_GS_GATLINGFEVER]->val1; if( sc->data[SC_STAR_COMFORT] ) skills2 += 3 * sc->data[SC_STAR_COMFORT]->val1; - + return ( flag&1? (skills1 + pots) : skills2 ); #else return 0; @@ -5899,8 +5906,8 @@ const char* status_get_name(struct block_list *bl) { /*========================================== * Get the class of the current bl * return -* 0 = fail -* class_id = success +* 0 = fail +* class_id = success *------------------------------------------*/ int status_get_class(struct block_list *bl) { nullpo_ret(bl); @@ -5918,8 +5925,8 @@ int status_get_class(struct block_list *bl) { /*========================================== * Get the base level of the current bl * return -* 1 = fail -* level = success +* 1 = fail +* level = success *------------------------------------------*/ int status_get_lv(struct block_list *bl) { nullpo_ret(bl); @@ -6093,7 +6100,7 @@ int status_get_emblem_id(struct block_list *bl) { case BL_MOB: { struct map_session_data *msd; struct mob_data *md = (struct mob_data *)bl; - if (md->guardian_data) //Guardian's guild [Skotlex] + if (md->guardian_data) //Guardian's guild [Skotlex] return (md->guardian_data->g) ? md->guardian_data->g->emblem_id:0; if (md->special_state.ai && (msd = map->id2sd(md->master_id)) != NULL) return msd->guild_emblem_id; //Alchemist's mobs [Skotlex] @@ -6195,7 +6202,8 @@ void status_set_viewdata(struct block_list *bl, int class_) TBL_PC* sd = (TBL_PC*)bl; if (pcdb_checkid(class_)) { if (pc_isridingpeco(sd)) { - switch (class_) { //Adapt class to a Mounted one. + switch (class_) { + //Adapt class to a Mounted one. case JOB_KNIGHT: class_ = JOB_KNIGHT2; break; @@ -6280,7 +6288,7 @@ void status_set_viewdata(struct block_list *bl, int class_) ShowError("status_set_viewdata (NPC): No view data for class %d\n", class_); } break; - case BL_HOM: //[blackhole89] + case BL_HOM: //[blackhole89] { struct homun_data *hd = (struct homun_data*)bl; if (vd) @@ -6350,7 +6358,7 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ struct map_session_data *sd; nullpo_ret(bl); - + if(!src) return tick ? tick : 1; // If no source, it can't be resisted (NPC given) @@ -6692,19 +6700,19 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ void status_display_add(struct map_session_data *sd, enum sc_type type, int dval1, int dval2, int dval3) { struct sc_display_entry *entry; int i; - + for( i = 0; i < sd->sc_display_count; i++ ) { if( sd->sc_display[i]->type == type ) break; } - + if( i != sd->sc_display_count ) { sd->sc_display[i]->val1 = dval1; sd->sc_display[i]->val2 = dval2; sd->sc_display[i]->val3 = dval3; return; } - + entry = ers_alloc(pc->sc_display_ers, struct sc_display_entry); entry->type = type; @@ -6791,8 +6799,10 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t struct mob_data *md = BL_CAST(BL_MOB,bl); if(md && (md->class_ == MOBID_EMPERIUM || mob_is_battleground(md)) && type != SC_SAFETYWALL && type != SC_PNEUMA) return 0; //Emperium/BG Monsters can't be afflicted by status changes - //if(md && mob_is_gvg(md) && status->sc2scb_flag(type)&SCB_MAXHP) - // return 0; //prevent status addinh hp to gvg mob (like bloodylust=hp*3 etc... +#if 0 + if(md && mob_is_gvg(md) && status->sc2scb_flag(type)&SCB_MAXHP) + return 0; //prevent status addinh hp to gvg mob (like bloodylust=hp*3 etc... +#endif // 0 } if( sc->data[SC_REFRESH] ) { @@ -7146,7 +7156,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t { // it doesn't stack or even renewed int i = SC_TOXIN; for(; i<= SC_LEECHESEND; i++) - if(sc->data[i]) return 0; + if(sc->data[i]) return 0; } break; case SC_MAGNETICFIELD: @@ -7296,8 +7306,8 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t status_change_end(bl, SC_ASSUMPTIO, INVALID_TIMER); break; case SC_CARTBOOST: - if(sc->data[SC_DEC_AGI] || sc->data[SC_ADORAMUS]) - { //Cancel Decrease Agi, but take no further effect [Skotlex] + if (sc->data[SC_DEC_AGI] || sc->data[SC_ADORAMUS]) { + //Cancel Decrease Agi, but take no further effect [Skotlex] status_change_end(bl, SC_DEC_AGI, INVALID_TIMER); status_change_end(bl, SC_ADORAMUS, INVALID_TIMER); return 0; @@ -7599,7 +7609,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t tick_time = val2 = tick>0?tick:60000; tick = -1; // duration sent to the client should be infinite break; - case SC_EDP: // [Celest] + case SC_EDP: // [Celest] val2 = val1 + 2; //Chance to Poison enemies. val3 = 50*(val1+1); //Damage increase (+50 +50*lv%) #ifdef RENEWAL_EDP @@ -7639,7 +7649,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t tick = -1; break; case SC_ENCHANTPOISON: - val2= 250+50*val1; //Poisoning Chance (2.5+0.5%) in 1/10000 rate + val2= 250+50*val1; //Poisoning Chance (2.5+0.5%) in 1/10000 rate case SC_ASPERSIO: case SC_PROPERTYFIRE: case SC_PROPERTYWATER: @@ -7888,12 +7898,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t //val4&1 signals the presence of a wall. //val4&2 makes cloak not end on normal attacks [Skotlex] //val4&4 makes cloak not end on using skills - if (bl->type == BL_PC || (bl->type == BL_MOB && ((TBL_MOB*)bl)->special_state.clone) ) //Standard cloaking. + if (bl->type == BL_PC || (bl->type == BL_MOB && ((TBL_MOB*)bl)->special_state.clone) ) //Standard cloaking. val4 |= battle_config.pc_cloak_check_type&7; else val4 |= battle_config.monster_cloak_check_type&7; break; - case SC_SIGHT: /* splash status */ + case SC_SIGHT: /* splash status */ case SC_RUWACH: case SC_WZ_SIGHTBLASTER: val3 = skill->get_splash(val2, val1); //Val2 should bring the skill-id. @@ -8167,7 +8177,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t case SC_KAAHI: val2 = 200*val1; //HP heal val3 = 5*val1; //SP cost - val4 = INVALID_TIMER; //Kaahi Timer. + val4 = INVALID_TIMER; //Kaahi Timer. break; case SC_BLESSING: if ((!undead_flag && st->race!=RC_DEMON) || bl->type == BL_PC) @@ -8303,7 +8313,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t //2. Set restore point (val3 -> return map, val4 return coords val3 = map_index; val4 = pos; - } else if (!val3 + } else if (!val3 || val3 == sd->mapindex || !sd->sc.data[SC_JAILED] // If player is being jailed and is already in jail (issue: 8206) ) { //Use save point. @@ -8357,11 +8367,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t break; case SC_STONESKIN: - if (val2 == NPC_ANTIMAGIC) - { //Boost mdef + if (val2 == NPC_ANTIMAGIC) { + //Boost mdef val2 =-20; val3 = 20; - } else { //Boost def + } else { + //Boost def val2 = 20; val3 =-20; } @@ -8825,7 +8836,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t case SC_HEATER_OPTION: val2 = 120; // Watk. TODO: Renewal (Atk2) val3 = (sd ? sd->status.job_level : 0); // % Increase damage. - val4 = 3; // Change into fire element. + val4 = 3; // Change into fire element. break; case SC_TROPIC_OPTION: val2 = 180; // Watk. TODO: Renewal (Atk2) @@ -8835,16 +8846,16 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t val2 = 40; break; case SC_COOLER_OPTION: - val2 = 80; // Bonus Matk + val2 = 80; // Bonus Matk val3 = (sd ? sd->status.job_level : 0); // % Freezing chance - val4 = 1; // Change into water elemet + val4 = 1; // Change into water elemet break; case SC_CHILLY_AIR_OPTION: val2 = 120; // Matk. TODO: Renewal (Matk1) val3 = MG_COLDBOLT; break; case SC_WIND_STEP_OPTION: - val2 = 50; // % Increase speed and flee. + val2 = 50; // % Increase speed and flee. break; case SC_BLAST_OPTION: val2 = (sd ? sd->status.job_level : 0); // % Increase damage @@ -8876,7 +8887,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t case SC_WATER_DROP_OPTION: case SC_WIND_CURTAIN_OPTION: case SC_STONE_SHIELD_OPTION: - val2 = 100; // Elemental modifier. + val2 = 100; // Elemental modifier. break; case SC_TROPIC: case SC_CHILLY_AIR: @@ -8908,10 +8919,10 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t tick_time = val3; break; case SC_WATER_BARRIER: - val3 = 20; // Reductions. Atk2, Flee1 + val3 = 20; // Reductions. Atk2, Flee1 break; case SC_ZEPHYR: - val2 = 25; // Flee. + val2 = 25; // Flee. break; case SC_TIDAL_WEAPON: val2 = 20; // Increase Elemental's attack. @@ -8926,7 +8937,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t val1 = 15; break; case SC_STOMACHACHE: - val2 = 8; // SP consume. + val2 = 8; // SP consume. val4 = tick / 10000; tick_time = 10000; // [GodLesZ] tick time break; @@ -9061,8 +9072,8 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t val2 = 20+(20*val1); break; default: - if( calc_flag == SCB_NONE && status->SkillChangeTable[type] == 0 && status->IconChangeTable[type] == 0 ) - { //Status change with no calc, no icon, and no skill associated...? + if (calc_flag == SCB_NONE && status->SkillChangeTable[type] == 0 && status->IconChangeTable[type] == 0) { + //Status change with no calc, no icon, and no skill associated...? ShowError("UnknownStatusChange [%d]\n", type); return 0; } @@ -9213,7 +9224,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t val_flag |= 1; break; } - + /* [Ind/Hercules] */ if( sd && status->DisplayType[type] ) { int dval1 = 0, dval2 = 0, dval3 = 0; @@ -9317,13 +9328,13 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t opt_flag = 1; switch(type) { //OPT1 - case SC_STONE: sc->opt1 = OPT1_STONEWAIT; break; - case SC_FREEZE: sc->opt1 = OPT1_FREEZE; break; - case SC_STUN: sc->opt1 = OPT1_STUN; break; - case SC_SLEEP: sc->opt1 = OPT1_SLEEP; break; - case SC_BURNING: sc->opt1 = OPT1_BURNING; break; // Burning need this to be showed correctly. [pakpil] - case SC_WHITEIMPRISON: sc->opt1 = OPT1_IMPRISON; break; - case SC_COLD: sc->opt1 = OPT1_CRYSTALIZE; break; + case SC_STONE: sc->opt1 = OPT1_STONEWAIT; break; + case SC_FREEZE: sc->opt1 = OPT1_FREEZE; break; + case SC_STUN: sc->opt1 = OPT1_STUN; break; + case SC_SLEEP: sc->opt1 = OPT1_SLEEP; break; + case SC_BURNING: sc->opt1 = OPT1_BURNING; break; // Burning need this to be showed correctly. [pakpil] + case SC_WHITEIMPRISON: sc->opt1 = OPT1_IMPRISON; break; + case SC_COLD: sc->opt1 = OPT1_CRYSTALIZE; break; //OPT2 case SC_POISON: sc->opt2 |= OPT2_POISON; break; case SC_CURSE: sc->opt2 |= OPT2_CURSE; break; @@ -9349,7 +9360,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t break; case SC_OVERTHRUSTMAX: case SC_OVERTHRUST: - case SC_SWOO: //Why does it shares the same opt as Overthrust? Perhaps we'll never know... + case SC_SWOO: //Why does it shares the same opt as Overthrust? Perhaps we'll never know... sc->opt3 |= OPT3_OVERTHRUST; opt_flag = 0; break; @@ -9385,10 +9396,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t opt_flag = 0; sc->opt3 |= OPT3_BERSERK; break; -// case ???: // doesn't seem to do anything -// sc->opt3 |= OPT3_LIGHTBLADE; -// opt_flag = 0; -// break; +#if 0 + case ???: // doesn't seem to do anything + sc->opt3 |= OPT3_LIGHTBLADE; + opt_flag = 0; + break; +#endif // 0 case SC_DANCING: if ((val1&0xFFFF) == CG_MOONLIT) sc->opt3 |= OPT3_MOONLIT; @@ -9423,10 +9436,12 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t sc->opt3 |= OPT3_UNDEAD; opt_flag = 0; break; -// case ???: // from DA_CONTRACT (looks like biolab mobs aura) -// sc->opt3 |= OPT3_CONTRACT; -// opt_flag = 0; -// break; +#if 0 + case ???: // from DA_CONTRACT (looks like biolab mobs aura) + sc->opt3 |= OPT3_CONTRACT; + opt_flag = 0; + break; +#endif // 0 //OPTION case SC_HIDING: sc->option |= OPTION_HIDE; @@ -9492,7 +9507,8 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t clif->changelook(bl,LOOK_CLOTHES_COLOR,vd->cloth_color); } } - if (calc_flag&SCB_DYE) { //Reset DYE color + if (calc_flag&SCB_DYE) { + //Reset DYE color if (vd && vd->cloth_color) { val4 = vd->cloth_color; clif->changelook(bl,LOOK_CLOTHES_COLOR,0); @@ -9694,7 +9710,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const #ifdef ANTI_MAYAP_CHEAT bool invisible = false; #endif - + nullpo_ret(bl); sc = status->get_sc(bl); @@ -9710,7 +9726,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const if( sd && sce->timer == INVALID_TIMER && !sd->state.loggingout ) chrif->del_scdata_single(sd->status.account_id,sd->status.char_id,type); - + if (tid == INVALID_TIMER) { if (type == SC_ENDURE && sce->val4) //Do not end infinite endure. @@ -10333,10 +10349,12 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const opt_flag = 0; sc->opt3 &= ~OPT3_BERSERK; break; - // case ???: // doesn't seem to do anything - // sc->opt3 &= ~OPT3_LIGHTBLADE; - // opt_flag = 0; - // break; +#if 0 + case ???: // doesn't seem to do anything + sc->opt3 &= ~OPT3_LIGHTBLADE; + opt_flag = 0; + break; +#endif // 0 case SC_DANCING: if ((sce->val1&0xFFFF) == CG_MOONLIT) sc->opt3 &= ~OPT3_MOONLIT; @@ -10371,10 +10389,12 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const sc->opt3 &= ~OPT3_UNDEAD; opt_flag = 0; break; - // case ???: // from DA_CONTRACT (looks like biolab mobs aura) - // sc->opt3 &= ~OPT3_CONTRACT; - // opt_flag = 0; - // break; +#if 0 + case ???: // from DA_CONTRACT (looks like biolab mobs aura) + sc->opt3 &= ~OPT3_CONTRACT; + opt_flag = 0; + break; +#endif // 0 default: opt_flag = 0; } @@ -10608,10 +10628,11 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { case SC_KNOWLEDGE: if (!sd) break; - if(bl->m == sd->feel_map[0].m || - bl->m == sd->feel_map[1].m || - bl->m == sd->feel_map[2].m) - { //Timeout will be handled by pc->setpos + if (bl->m == sd->feel_map[0].m + || bl->m == sd->feel_map[1].m + || bl->m == sd->feel_map[2].m + ) { + //Timeout will be handled by pc->setpos sce->timer = INVALID_TIMER; return 0; } @@ -10741,12 +10762,13 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { break; case SC_SPLASHER: - // custom Venom Splasher countdown timer - //if (sce->val4 % 1000 == 0) { - // char counter[10]; - // snprintf (counter, 10, "%d", sce->val4/1000); - // clif->message(bl, counter); - //} +#if 0 // custom Venom Splasher countdown timer + if (sce->val4 % 1000 == 0) { + char counter[10]; + snprintf (counter, 10, "%d", sce->val4/1000); + clif->message(bl, counter); + } +#endif // 0 if((sce->val4 -= 500) > 0) { sc_timer_next(500 + tick, status->change_timer, bl->id, data); return 0; @@ -11163,7 +11185,7 @@ int status_change_timer(int tid, int64 tick, int id, intptr_t data) { if(--(sce->val4) >= 0) { // 1% SP Upkeep Cost int sp = st->max_sp / 100; - + if( st->sp <= sp ) status_change_end(bl,SC_STEALTHFIELD_MASTER,INVALID_TIMER); @@ -11423,9 +11445,9 @@ unsigned short status_get_rand_matk( unsigned short matk_max, unsigned short mat /** * Get bl's matk_max and matk_min values depending on flag * @param flag - * 0 - Get MATK - * 1 - Get MATK w/o SC bonuses - * 3 - Get MATK w/o EATK & SC bonuses + * 0 - Get MATK + * 1 - Get MATK w/o SC bonuses + * 3 - Get MATK w/o EATK & SC bonuses **/ void status_get_matk_sub( struct block_list *bl, int flag, unsigned short *matk_max, unsigned short *matk_min ) { struct status_data *st; @@ -11496,9 +11518,9 @@ void status_get_matk_sub( struct block_list *bl, int flag, unsigned short *matk_ /** * Get bl's matk value depending on flag * @param flag [malufett] - * 1 - Get MATK w/o SC bonuses - * 2 - Get modified MATK - * 3 - Get MATK w/o eATK & SC bonuses + * 1 - Get MATK w/o SC bonuses + * 2 - Get modified MATK + * 3 - Get MATK w/o eATK & SC bonuses * @retval 1 failure * @retval MATK success * @@ -12231,7 +12253,7 @@ void status_defaults(void) { status->readdb = status_readdb; status->init = do_init_status; status->final = do_final_status; - + status->initChangeTables = initChangeTables; status->initDummyData = initDummyData; status->base_amotion_pc = status_base_amotion_pc; diff --git a/src/map/status.h b/src/map/status.h index aca26b1af..00c243543 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -102,7 +102,7 @@ typedef enum sc_type { SC_BURNING, SC_DEEP_SLEEP, SC_COMMON_MAX = 14, // end - + //Next up, we continue on 20, to leave enough room for additional "common" ailments in the future. SC_PROVOKE = 20, SC_ENDURE, @@ -267,7 +267,7 @@ typedef enum sc_type { SC_DONTFORGETME, //180 SC_FORTUNE, SC_SERVICEFORYOU, - SC_STOP, //Prevents inflicted chars from walking. [Skotlex] + SC_STOP, //Prevents inflicted chars from walking. [Skotlex] SC_STRUP, SC_SOULLINK, SC_COMA, //Not a real SC_, it makes a char's HP/SP hit 1. @@ -324,7 +324,7 @@ typedef enum sc_type { SC_NJ_SUITON, SC_NJ_NEN, SC_KNOWLEDGE, - SC_SMA_READY, //240 + SC_SMA_READY, //240 SC_FLING, SC_HLIF_AVOID, SC_HLIF_CHANGE, @@ -334,7 +334,7 @@ typedef enum sc_type { SC_HAMI_DEFENCE, SC_INCASPDRATE, SC_PLUSAVOIDVALUE, - SC_JAILED, //250 + SC_JAILED, //250 SC_ENCHANTARMS, SC_MAGICALATTACK, SC_STONESKIN, @@ -679,7 +679,7 @@ typedef enum sc_type { SC_ZANGETSU, SC_GENSOU, SC_AKAITSUKI, - + //homon S SC_STYLE_CHANGE, SC_GOLDENE_FERSE, // 540 @@ -705,13 +705,13 @@ typedef enum sc_type { SC_TELEKINESIS_INTENSE, SC_OFFERTORIUM, SC_FRIGG_SONG, // 560 - + SC_ALL_RIDING, SC_HANBOK, SC_MONSTER_TRANSFORM, SC_ANGEL_PROTECT, SC_ILLUSIONDOPING, - + SC_MTF_ASPD, SC_MTF_RANGEATK, SC_MTF_MATK, @@ -724,10 +724,10 @@ typedef enum sc_type { SC_OKTOBERFEST, SC_STRANGELIGHTS, SC_DECORATION_OF_MUSIC, - + SC__MAELSTROM, SC__CHAOS, - + SC__FEINTBOMB_MASTER, SC_FALLENEMPIRE, SC_FLASHCOMBO, // 580 @@ -1494,21 +1494,21 @@ enum si_type { //SI_ = 735, SI_CHILL = 736, SI_BURNT = 737, -// SI_PCCAFE_PLAY_TIME = 738, -// SI_TWISTED_TIME = 739, + //SI_PCCAFE_PLAY_TIME = 738, + //SI_TWISTED_TIME = 739, SI_FLASHCOMBO = 740, -// SI_JITTER_BUFF1 = 741, -// SI_JITTER_BUFF2 = 742, -// SI_JITTER_BUFF3 = 743, -// SI_JITTER_BUFF4 = 744, -// SI_JITTER_BUFF5 = 745, -// SI_JITTER_BUFF6 = 746, -// SI_JITTER_BUFF7 = 747, -// SI_JITTER_BUFF8 = 748, -// SI_JITTER_BUFF9 = 749, -// SI_JITTER_BUFF10 = 750, -// SI_CUP_OF_BOZA = 751, + //SI_JITTER_BUFF1 = 741, + //SI_JITTER_BUFF2 = 742, + //SI_JITTER_BUFF3 = 743, + //SI_JITTER_BUFF4 = 744, + //SI_JITTER_BUFF5 = 745, + //SI_JITTER_BUFF6 = 746, + //SI_JITTER_BUFF7 = 747, + //SI_JITTER_BUFF8 = 748, + //SI_JITTER_BUFF9 = 749, + //SI_JITTER_BUFF10 = 750, + //SI_CUP_OF_BOZA = 751, SI_B_TRAP = 752, SI_E_CHAIN = 753, SI_E_QD_SHOT_READY = 754, @@ -1534,38 +1534,38 @@ enum si_type { SI_PACKING_ENVELOPE9 = 774, SI_PACKING_ENVELOPE10 = 775, SI_GLASTHEIM_TRANS = 776, -// SI_ZONGZI_POUCH_TRANS = 777, + //SI_ZONGZI_POUCH_TRANS = 777, SI_HEAT_BARREL_AFTER = 778, SI_DECORATION_OF_MUSIC = 779, -// SI_OVERSEAEXPUP = 780, -// SI_CLOWN_N_GYPSY_CARD = 781, -// SI_OPEN_NPC_MARKET = 782, -// SI_BEEF_RIB_STEW = 783, -// SI_PORK_RIB_STEW = 784, -// SI_CHUSEOK_MONDAY = 785, -// SI_CHUSEOK_TUESDAY = 786, -// SI_CHUSEOK_WEDNESDAY = 787, -// SI_CHUSEOK_THURSDAY = 788, -// SI_CHUSEOK_FRIDAY = 789, -// SI_CHUSEOK_WEEKEND = 790, -// SI_ALL_LIGHTGUARD = 791, -// SI_ALL_LIGHTGUARD_COOL_TIME = 792, -// SI_MTF_MHP = 793, -// SI_MTF_MSP = 794, -// SI_MTF_PUMPKIN = 795, -// SI_MTF_HITFLEE = 796, -// SI_MTF_CRIDAMAGE2 = 797, -// SI_MTF_SPDRAIN = 798, -// SI_ACUO_MINT_GUM = 799, -// ... -// SI_GUILD_STORAGE = 810, -// ... -// SI_JUMPINGCLAN = 815, -// ... -// SI_MTF_RANGEATK2 = 818, -// SI_MTF_ASPD2 = 819, -// SI_MTF_MATK2 = 820, + //SI_OVERSEAEXPUP = 780, + //SI_CLOWN_N_GYPSY_CARD = 781, + //SI_OPEN_NPC_MARKET = 782, + //SI_BEEF_RIB_STEW = 783, + //SI_PORK_RIB_STEW = 784, + //SI_CHUSEOK_MONDAY = 785, + //SI_CHUSEOK_TUESDAY = 786, + //SI_CHUSEOK_WEDNESDAY = 787, + //SI_CHUSEOK_THURSDAY = 788, + //SI_CHUSEOK_FRIDAY = 789, + //SI_CHUSEOK_WEEKEND = 790, + //SI_ALL_LIGHTGUARD = 791, + //SI_ALL_LIGHTGUARD_COOL_TIME = 792, + //SI_MTF_MHP = 793, + //SI_MTF_MSP = 794, + //SI_MTF_PUMPKIN = 795, + //SI_MTF_HITFLEE = 796, + //SI_MTF_CRIDAMAGE2 = 797, + //SI_MTF_SPDRAIN = 798, + //SI_ACUO_MINT_GUM = 799, + // ... + //SI_GUILD_STORAGE = 810, + // ... + //SI_JUMPINGCLAN = 815, + // ... + //SI_MTF_RANGEATK2 = 818, + //SI_MTF_ASPD2 = 819, + //SI_MTF_MATK2 = 820, SI_MAX, }; @@ -1681,18 +1681,18 @@ enum { OPTION_DRAGON5 = 0x04000000, OPTION_HANBOK = 0x08000000, OPTION_OKTOBERFEST = 0x10000000, - + #ifndef NEW_CARTS OPTION_CART1 = 0x00000008, OPTION_CART2 = 0x00000080, OPTION_CART3 = 0x00000100, OPTION_CART4 = 0x00000200, OPTION_CART5 = 0x00000400, - + /* compound constant for older carts */ OPTION_CART = OPTION_CART1|OPTION_CART2|OPTION_CART3|OPTION_CART4|OPTION_CART5, #endif - + // compound constants OPTION_DRAGON = OPTION_DRAGON1|OPTION_DRAGON2|OPTION_DRAGON3|OPTION_DRAGON4|OPTION_DRAGON5, OPTION_COSTUME = OPTION_WEDDING|OPTION_XMAS|OPTION_SUMMER|OPTION_HANBOK|OPTION_OKTOBERFEST, @@ -1825,7 +1825,7 @@ struct regen_data_sub { struct { unsigned int hp,sp; } tick; - + //Regen rates (where every 1 means +100% regen) struct { unsigned char hp,sp; @@ -1842,18 +1842,18 @@ struct regen_data { struct { unsigned int hp,sp,shp,ssp; } tick; - + //Regen rates (where every 1 means +100% regen) struct { unsigned char hp,sp,shp,ssp; } rate; - + struct { - unsigned walk:1; //Can you regen even when walking? - unsigned gc:1; //Tags when you should have double regen due to GVG castle + unsigned walk:1; //Can you regen even when walking? + unsigned gc:1; //Tags when you should have double regen due to GVG castle unsigned overweight :2; //overweight state (1: 50%, 2: 90%) - unsigned block :2; //Block regen flag (1: Hp, 2: Sp) + unsigned block :2; //Block regen flag (1: Hp, 2: Sp) } state; //skill-regen, sitting-skill-regen (since not all chars with regen need it) @@ -2069,7 +2069,7 @@ struct status_interface { int (*get_matk) (struct block_list *src, int flag); void (*update_matk) ( struct block_list *bl ); int (*readdb) (void); - + void (*initChangeTables) (void); void (*initDummyData) (void); int (*base_amotion_pc) (struct map_session_data *sd, struct status_data *st); diff --git a/src/map/storage.c b/src/map/storage.c index 523f64cc8..755f50cb7 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -85,13 +85,13 @@ int storage_storageopen(struct map_session_data *sd) if(sd->state.storage_flag) return 1; //Already open? - - if( !pc_can_give_items(sd) ) - { //check is this GM level is allowed to put items to storage + + if( !pc_can_give_items(sd) ) { + //check is this GM level is allowed to put items to storage clif->message(sd->fd, msg_txt(246)); return 1; } - + sd->state.storage_flag = 1; storage->sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items)); clif->storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items)); @@ -128,7 +128,7 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo if( item_data->nameid <= 0 || amount <= 0 ) return 1; - + data = itemdb->search(item_data->nameid); if( data->stack.storage && amount > data->stack.amount ) @@ -136,12 +136,12 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo return 1; } - if( !itemdb_canstore(item_data, pc_get_group_level(sd)) ) - { //Check if item is storable. [Skotlex] + if (!itemdb_canstore(item_data, pc_get_group_level(sd))) { + //Check if item is storable. [Skotlex] clif->message (sd->fd, msg_txt(264)); return 1; } - + if( item_data->bound > IBT_ACCOUNT && !pc_can_give_bound_items(sd) ) { clif->message(sd->fd, msg_txt(294)); return 1; @@ -200,8 +200,8 @@ int storage_delitem(struct map_session_data* sd, int n, int amount) * Add an item to the storage from the inventory. * @index : inventory idx * return - * 0 : fail - * 1 : success + * 0 : fail + * 1 : success *------------------------------------------*/ int storage_storageadd(struct map_session_data* sd, int index, int amount) { nullpo_ret(sd); @@ -216,7 +216,7 @@ int storage_storageadd(struct map_session_data* sd, int index, int amount) { return 0; // No item on that spot if( amount < 1 || amount > sd->status.inventory[index].amount ) - return 0; + return 0; if( storage->additem(sd,&sd->status.inventory[index],amount) == 0 ) pc->delitem(sd,index,amount,0,4,LOG_TYPE_STORAGE); @@ -230,8 +230,8 @@ int storage_storageadd(struct map_session_data* sd, int index, int amount) { * Retrieve an item from the storage into inventory * @index : storage idx * return - * 0 : fail - * 1 : success + * 0 : fail + * 1 : success *------------------------------------------*/ int storage_storageget(struct map_session_data* sd, int index, int amount) { @@ -242,7 +242,7 @@ int storage_storageget(struct map_session_data* sd, int index, int amount) if( sd->status.storage.items[index].nameid <= 0 ) return 0; //Nothing there - + if( amount < 1 || amount > sd->status.storage.items[index].amount ) return 0; @@ -258,22 +258,22 @@ int storage_storageget(struct map_session_data* sd, int index, int amount) * Move an item from cart to storage. * @index : cart inventory index * return - * 0 : fail - * 1 : success + * 0 : fail + * 1 : success *------------------------------------------*/ int storage_storageaddfromcart(struct map_session_data* sd, int index, int amount) { nullpo_ret(sd); if( sd->status.storage.storage_amount > MAX_STORAGE ) - return 0; // storage full / storage closed + return 0; // storage full / storage closed if( index < 0 || index >= MAX_CART ) - return 0; + return 0; if( sd->status.cart[index].nameid <= 0 ) return 0; //No item there. - + if( amount < 1 || amount > sd->status.cart[index].amount ) return 0; @@ -287,8 +287,8 @@ int storage_storageaddfromcart(struct map_session_data* sd, int index, int amoun * Get from Storage to the Cart inventory * @index : storage index * return - * 0 : fail - * 1 : success + * 0 : fail + * 1 : success *------------------------------------------*/ int storage_storagegettocart(struct map_session_data* sd, int index, int amount) { int flag = 0; @@ -296,13 +296,13 @@ int storage_storagegettocart(struct map_session_data* sd, int index, int amount) if( index < 0 || index >= MAX_STORAGE ) return 0; - + if( sd->status.storage.items[index].nameid <= 0 ) return 0; //Nothing there. - + if( amount < 1 || amount > sd->status.storage.items[index].amount ) return 0; - + if( (flag = pc->cart_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE)) == 0 ) storage->delitem(sd,index,amount); else { @@ -333,7 +333,7 @@ void storage_storageclose(struct map_session_data* sd) { *------------------------------------------*/ void storage_storage_quit(struct map_session_data* sd, int flag) { nullpo_retv(sd); - + if (map->save_settings&4) chrif->save(sd, flag); //Invokes the storage saving as well. @@ -367,9 +367,9 @@ int guild_storage_delete(int guild_id) { /*========================================== * Attempt to open guild storage for sd * return -* 0 : success (open or req to create a new one) -* 1 : fail -* 2 : no guild for sd +* 0 : success (open or req to create a new one) +* 1 : fail +* 2 : no guild for sd *------------------------------------------*/ int storage_guild_storageopen(struct map_session_data* sd) { @@ -382,7 +382,7 @@ int storage_guild_storageopen(struct map_session_data* sd) if(sd->state.storage_flag) return 1; //Can't open both storages at a time. - + if( !pc_can_give_items(sd) ) { //check is this GM level can open guild storage and store items [Lupus] clif->message(sd->fd, msg_txt(246)); return 1; @@ -394,10 +394,10 @@ int storage_guild_storageopen(struct map_session_data* sd) } if(gstor->storage_status) return 1; - + if( gstor->lock ) return 1; - + gstor->storage_status = 1; sd->state.storage_flag = 2; storage->sortitem(gstor->items, ARRAYLENGTH(gstor->items)); @@ -409,8 +409,8 @@ int storage_guild_storageopen(struct map_session_data* sd) /*========================================== * Attempt to add an item in guild storage, then refresh it * return -* 0 : success -* 1 : fail +* 0 : success +* 1 : fail *------------------------------------------*/ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* stor, struct item* item_data, int amount) { @@ -431,8 +431,8 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto return 1; } - if( !itemdb_canguildstore(item_data, pc_get_group_level(sd)) || item_data->expire_time ) - { //Check if item is storable. [Skotlex] + if (!itemdb_canguildstore(item_data, pc_get_group_level(sd)) || item_data->expire_time) { + //Check if item is storable. [Skotlex] clif->message (sd->fd, msg_txt(264)); return 1; } @@ -441,7 +441,7 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto clif->message(sd->fd, msg_txt(294)); return 1; } - + if(itemdb->isstackable2(data)){ //Stackable for(i=0;i<MAX_GUILD_STORAGE;i++){ if(compare_item(&stor->items[i], item_data)) { @@ -456,10 +456,10 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto } //Add item for(i=0;i<MAX_GUILD_STORAGE && stor->items[i].nameid;i++); - + if(i>=MAX_GUILD_STORAGE) return 1; - + memcpy(&stor->items[i],item_data,sizeof(stor->items[0])); stor->items[i].amount=amount; stor->storage_amount++; @@ -472,8 +472,8 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto /*========================================== * Attempt to delete an item in guild storage, then refresh it * return -* 0 : success -* 1 : fail +* 0 : success +* 1 : fail *------------------------------------------*/ int guild_storage_delitem(struct map_session_data* sd, struct guild_storage* stor, int n, int amount) { @@ -498,8 +498,8 @@ int guild_storage_delitem(struct map_session_data* sd, struct guild_storage* sto * Attempt to add an item in guild storage from inventory, then refresh it * @index : inventory idx * return -* 0 : fail -* 1 : succes +* 0 : fail +* 1 : succes *------------------------------------------*/ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount) { @@ -507,19 +507,19 @@ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount) nullpo_ret(sd); nullpo_ret(stor=idb_get(gstorage->db,sd->status.guild_id)); - + if( !stor->storage_status || stor->storage_amount > MAX_GUILD_STORAGE ) return 0; - + if( index<0 || index>=MAX_INVENTORY ) return 0; if( sd->status.inventory[index].nameid <= 0 ) return 0; - + if( amount < 1 || amount > sd->status.inventory[index].amount ) return 0; - + if( stor->lock ) { gstorage->close(sd); return 0; @@ -537,8 +537,8 @@ int storage_guild_storageadd(struct map_session_data* sd, int index, int amount) * Attempt to retrieve an item from guild storage to inventory, then refresh it * @index : storage idx * return -* 0 : fail -* 1 : success +* 0 : fail +* 1 : success *------------------------------------------*/ int storage_guild_storageget(struct map_session_data* sd, int index, int amount) { @@ -549,17 +549,17 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount) nullpo_ret(stor=idb_get(gstorage->db,sd->status.guild_id)); if(!stor->storage_status) - return 0; - + return 0; + if(index<0 || index>=MAX_GUILD_STORAGE) return 0; if(stor->items[index].nameid <= 0) return 0; - + if(amount < 1 || amount > stor->items[index].amount) - return 0; - + return 0; + if( stor->lock ) { gstorage->close(sd); return 0; @@ -569,7 +569,7 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount) gstorage->delitem(sd,stor,index,amount); else //inform fail clif->additem(sd,0,0,flag); -// log_fromstorage(sd, index, 1); + //log_fromstorage(sd, index, 1); return 0; } @@ -578,8 +578,8 @@ int storage_guild_storageget(struct map_session_data* sd, int index, int amount) * Attempt to add an item in guild storage from cart, then refresh it * @index : cart inventory idx * return -* 0 : fail -* 1 : success +* 0 : fail +* 1 : success *------------------------------------------*/ int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int amount) { @@ -596,7 +596,7 @@ int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int if( sd->status.cart[index].nameid <= 0 ) return 0; - + if( amount < 1 || amount > sd->status.cart[index].amount ) return 0; @@ -610,8 +610,8 @@ int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int * Attempt to retrieve an item from guild storage to cart, then refresh it * @index : storage idx * return -* 0 : fail -* 1 : success +* 0 : fail +* 1 : success *------------------------------------------*/ int storage_guild_storagegettocart(struct map_session_data* sd, int index, int amount) { @@ -621,14 +621,14 @@ int storage_guild_storagegettocart(struct map_session_data* sd, int index, int a nullpo_ret(stor=idb_get(gstorage->db,sd->status.guild_id)); if(!stor->storage_status) - return 0; + return 0; if(index<0 || index>=MAX_GUILD_STORAGE) - return 0; - + return 0; + if(stor->items[index].nameid<=0) return 0; - + if(amount < 1 || amount > stor->items[index].amount) return 0; @@ -641,8 +641,8 @@ int storage_guild_storagegettocart(struct map_session_data* sd, int index, int a /*========================================== * Request to save guild storage * return -* 0 : fail (no storage) -* 1 : success +* 0 : fail (no storage) +* 1 : success *------------------------------------------*/ int storage_guild_storagesave(int account_id, int guild_id, int flag) { @@ -652,7 +652,7 @@ int storage_guild_storagesave(int account_id, int guild_id, int flag) { if (flag) //Char quitting, close it. stor->storage_status = 0; - if (stor->dirty) + if (stor->dirty) intif->send_guild_storage(account_id,stor); return 1; } @@ -662,16 +662,16 @@ int storage_guild_storagesave(int account_id, int guild_id, int flag) /*========================================== * ACK save of guild storage * return -* 0 : fail (no storage) -* 1 : success +* 0 : fail (no storage) +* 1 : success *------------------------------------------*/ int storage_guild_storagesaved(int guild_id) { struct guild_storage *stor; if((stor=idb_get(gstorage->db,guild_id)) != NULL) { - if (stor->dirty && stor->storage_status == 0) - { //Storage has been correctly saved. + if (stor->dirty && stor->storage_status == 0) { + //Storage has been correctly saved. stor->dirty = 0; } return 1; @@ -704,7 +704,7 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag) { nullpo_ret(sd); nullpo_ret(stor=idb_get(gstorage->db,sd->status.guild_id)); - + if(flag) { //Only during a guild break flag is 1 (don't save storage) sd->state.storage_flag = 0; @@ -755,7 +755,7 @@ void storage_defaults(void) { } void gstorage_defaults(void) { gstorage = &gstorage_s; - + /* */ gstorage->init = do_init_gstorage; gstorage->final = do_final_gstorage; diff --git a/src/map/trade.c b/src/map/trade.c index 3bbb73568..4d6909957 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -43,8 +43,8 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta return; } - if (target_sd->npc_id) - { //Trade fails if you are using an NPC. + if (target_sd->npc_id) { + //Trade fails if you are using an NPC. clif->tradestart(sd, 2); return; } @@ -145,9 +145,10 @@ void trade_tradeack(struct map_session_data *sd, int type) { } //Check if you can start trade. - if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.storage_flag || - tsd->npc_id || tsd->state.vending || tsd->state.buyingstore || tsd->state.storage_flag) - { //Fail + if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.storage_flag + || tsd->npc_id || tsd->state.vending || tsd->state.buyingstore || tsd->state.storage_flag + ) { + //Fail clif->tradestart(sd, 2); clif->tradestart(tsd, 2); sd->state.deal_locked = 0; @@ -335,8 +336,8 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount) return; } - if( amount == 0 ) - { //Why do this.. ~.~ just send an ack, the item won't display on the trade window. + if (amount == 0) { + //Why do this.. ~.~ just send an ack, the item won't display on the trade window. clif->tradeitemok(sd, index, TIO_SUCCESS); return; } @@ -375,7 +376,7 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount) clif->tradeitemok(sd, index+2, TIO_INDROCKS); return; } - + //Locate a trade position ARR_FIND( 0, 10, trade_i, sd->deal.item[trade_i].index == index || sd->deal.item[trade_i].amount == 0 ); if( trade_i == 10 ) //No space left @@ -385,23 +386,22 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount) } trade_weight = sd->inventory_data[index]->weight * amount; - if( target_sd->weight + sd->deal.weight + trade_weight > target_sd->max_weight ) - { //fail to add item -- the player was over weighted. + if (target_sd->weight + sd->deal.weight + trade_weight > target_sd->max_weight) { + //fail to add item -- the player was over weighted. clif->tradeitemok(sd, index+2, TIO_OVERWEIGHT); return; } - if( sd->deal.item[trade_i].index == index ) - { //The same item as before is being readjusted. - if( sd->deal.item[trade_i].amount + amount > sd->status.inventory[index].amount ) - { //packet deal exploit check + if (sd->deal.item[trade_i].index == index) { + //The same item as before is being readjusted. + if (sd->deal.item[trade_i].amount + amount > sd->status.inventory[index].amount) { + //packet deal exploit check amount = sd->status.inventory[index].amount - sd->deal.item[trade_i].amount; trade_weight = sd->inventory_data[index]->weight * amount; } sd->deal.item[trade_i].amount += amount; - } - else - { //New deal item + } else { + //New deal item sd->deal.item[trade_i].index = index; sd->deal.item[trade_i].amount = amount; } @@ -427,8 +427,8 @@ void trade_tradeaddzeny(struct map_session_data* sd, int amount) return; } - if( amount < 0 || amount > sd->status.zeny || amount > MAX_ZENY - target_sd->status.zeny ) - { // invalid values, no appropriate packet for it => abort + if (amount < 0 || amount > sd->status.zeny || amount > MAX_ZENY - target_sd->status.zeny) { + // invalid values, no appropriate packet for it => abort trade->cancel(sd); return; } @@ -606,8 +606,7 @@ void trade_tradecommit(struct map_session_data *sd) { clif->tradecompleted(tsd, 0); // save both player to avoid crash: they always have no advantage/disadvantage between the 2 players - if (map->save_settings&1) - { + if (map->save_settings&1) { chrif->save(sd,0); chrif->save(tsd,0); } @@ -616,7 +615,7 @@ void trade_tradecommit(struct map_session_data *sd) { void trade_defaults(void) { trade = &trade_s; - + trade->request = trade_traderequest; trade->ack = trade_tradeack; trade->check_impossible = impossible_trade_check; diff --git a/src/map/unit.c b/src/map/unit.c index 0eb6fdbd2..2ab13b121 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -187,7 +187,7 @@ int unit_step_timer(int tid, int64 tick, int id, intptr_t data) //Execute request now if target is in attack range if(ud->stepskill_id && skill->get_inf(ud->stepskill_id) & INF_GROUND_SKILL) { //Execute ground skill - struct map_data *md = &map->list[bl->m]; + struct map_data *md = &map->list[bl->m]; unit->skilluse_pos(bl, target_id%md->xs, target_id/md->xs, ud->stepskill_id, ud->stepskill_lv); } else { //If a player has target_id set and target is in range, attempt attack @@ -314,7 +314,6 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) { } } else // reset the tick, he is not far anymore sd->md->masterteleport_timer = 0; - } if( sd->hd ) { if( homun_alive(sd->hd) && !check_distance_bl(&sd->bl, &sd->hd->bl, MAX_MER_DISTANCE) ) { @@ -337,14 +336,15 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) { if (md->min_chase > md->db->range3) md->min_chase--; //Walk skills are triggered regardless of target due to the idle-walk mob state. //But avoid triggering on stop-walk calls. - if(tid != INVALID_TIMER && - !(ud->walk_count%WALK_SKILL_INTERVAL) && - map->list[bl->m].users > 0 && - mob->skill_use(md, tick, -1)) - { + if (tid != INVALID_TIMER + && !(ud->walk_count%WALK_SKILL_INTERVAL) + && map->list[bl->m].users > 0 + && mob->skill_use(md, tick, -1) + ) { if (!(ud->skill_id == NPC_SELFDESTRUCTION && ud->skilltimer != INVALID_TIMER) - && md->state.skillstate != MSS_WALK) //Walk skills are supposed to be used while walking - { //Skill used, abort walking + && md->state.skillstate != MSS_WALK //Walk skills are supposed to be used while walking + ) { + //Skill used, abort walking clif->fixpos(bl); //Fix position as walk has been canceled. return 0; } @@ -424,8 +424,8 @@ int unit_walktoxy_timer(int tid, int64 tick, int id, intptr_t data) { } if (tbl->m == bl->m && check_distance_bl(bl, tbl, ud->chaserange)) { //Reached destination. - if (ud->state.attack_continue) - { //Aegis uses one before every attack, we should + if (ud->state.attack_continue) { + //Aegis uses one before every attack, we should //only need this one for syncing purposes. [Skotlex] ud->target_to = 0; clif->fixpos(bl); @@ -555,8 +555,8 @@ int unit_walktobl_sub(int tid, int64 tick, int id, intptr_t data) { // if flag&2, start attacking upon arrival within range, otherwise just walk to that character. int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int flag) { - struct unit_data *ud = NULL; - struct status_change *sc = NULL; + struct unit_data *ud = NULL; + struct status_change *sc = NULL; nullpo_ret(bl); nullpo_ret(tbl); @@ -590,8 +590,8 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int return 1; } - if(DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0) - { //Can't move, wait a bit before invoking the movement. + if (DIFF_TICK(ud->canmove_tick, timer->gettick()) > 0) { + //Can't move, wait a bit before invoking the movement. timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target); return 1; } @@ -786,7 +786,7 @@ int unit_setdir(struct block_list *bl,unsigned char dir) uint8 unit_getdir(struct block_list *bl) { struct unit_data *ud; nullpo_ret(bl); - + if( bl->type == BL_NPC ) return ((TBL_NPC*)bl)->dir; ud = unit->bl2ud(bl); @@ -1076,7 +1076,6 @@ int unit_can_move(struct block_list *bl) { ) ) return 0; - if (sc->opt1 > 0 && sc->opt1 != OPT1_STONEWAIT && sc->opt1 != OPT1_BURNING && !(sc->opt1 == OPT1_CRYSTALIZE && bl->type == BL_MOB)) return 0; @@ -1143,10 +1142,10 @@ int unit_set_walkdelay(struct block_list *bl, int64 tick, int delay, int type) { return 0; } ud->canmove_tick = tick + delay; - if (ud->walktimer != INVALID_TIMER) - { //Stop walking, if chasing, readjust timers. - if (delay == 1) - { //Minimal delay (walk-delay) disabled. Just stop walking. + if (ud->walktimer != INVALID_TIMER) { + //Stop walking, if chasing, readjust timers. + if (delay == 1) { + //Minimal delay (walk-delay) disabled. Just stop walking. unit->stop_walking(bl,4); } else { //Resume running after can move again [Kevin] @@ -1214,7 +1213,8 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if(skill->not_ok(skill_id, sd)) // [MouseJstr] return 0; - switch(skill_id) { //Check for skills that auto-select target + switch (skill_id) { + //Check for skills that auto-select target case MO_CHAINCOMBO: if (sc && sc->data[SC_BLADESTOP]) { if ((target=map->id2bl(sc->data[SC_BLADESTOP]->val4)) == NULL) @@ -1276,7 +1276,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if(!status->check_skilluse(src, target, skill_id, 0)) return 0; - + if( src != target && status->isdead(target) ) { /** * Skills that may be cast on dead targets @@ -1300,7 +1300,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } - + switch(skill_id){ case SA_CASTCANCEL: if(ud->skill_id != skill_id){ @@ -1408,7 +1408,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui temp = 1; break; case CR_DEVOTION: - if (sd) { + if (sd) { int i = 0, count = min(skill_lv, 5); ARR_FIND(0, count, i, sd->devotion[i] == target_id); if (i == count) { @@ -1416,7 +1416,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if(i == count) { clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0); return 0; // Can't cast on other characters when limit is reached - } + } } } break; @@ -1462,7 +1462,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui case RA_WUGDASH: if (sc && sc->data[SC_WUGDASH]) casttime = -1; - break; + break; case EL_WIND_SLASH: case EL_HURRICANE: case EL_TYPOON_MIS: @@ -1505,7 +1505,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui /** * why the if else chain: these 3 status do not stack, so its efficient that way. **/ - if( sc->data[SC_CLOAKING] && !(sc->data[SC_CLOAKING]->val4&4) && skill_id != AS_CLOAKING ) { + if( sc->data[SC_CLOAKING] && !(sc->data[SC_CLOAKING]->val4&4) && skill_id != AS_CLOAKING ) { status_change_end(src, SC_CLOAKING, INVALID_TIMER); if (!src->prev) return 0; //Warped away! } else if( sc->data[SC_CLOAKINGEXCEED] && !(sc->data[SC_CLOAKINGEXCEED]->val4&4) && skill_id != GC_CLOAKINGEXCEED ) { @@ -1513,10 +1513,10 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui if (!src->prev) return 0; } } - + if(!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026 unit->stop_walking(src,1);// even though this is not how official works but this will do the trick. bugreport:6829 - + // in official this is triggered even if no cast time. clif->skillcasting(src, src->id, target_id, 0,0, skill_id, skill->get_ele(skill_id, skill_lv), casttime); if( casttime > 0 || temp ) @@ -1643,7 +1643,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui return 0; } - /* Check range and obstacle */ + /* Check range and obstacle */ bl.type = BL_NUL; bl.m = src->m; bl.x = skill_x; @@ -1691,14 +1691,14 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui ud->state.skillcastcancel = castcancel&&casttime>0?1:0; if( !sd || sd->skillitem != skill_id || skill->get_cast(skill_id,skill_lv) ) ud->canact_tick = tick + casttime + 100; -// if( sd ) -// { -// switch( skill_id ) -// { -// case ????: -// sd->canequip_tick = tick + casttime; -// } -// } +#if 0 + if (sd) { + switch (skill_id) { + case ????: + sd->canequip_tick = tick + casttime; + } + } +#endif // 0 ud->skill_id = skill_id; ud->skill_lv = skill_lv; ud->skillx = skill_x; @@ -1961,7 +1961,7 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, /*========================================== * Calculates position of Pet/Mercenary/Homunculus/Elemental *------------------------------------------*/ -int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) +int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir) { int dx, dy, x, y, i, k; struct unit_data *ud = unit->bl2ud(bl); @@ -2121,8 +2121,8 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) { md->state.skillstate = md->state.aggressive?MSS_ANGRY:MSS_BERSERK; } - if (sstatus->mode&MD_ASSIST && DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME) - { // Link monsters nearby [Skotlex] + if (sstatus->mode&MD_ASSIST && DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME) { + // Link monsters nearby [Skotlex] md->last_linktime = tick; map->foreachinrange(mob->linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick); } @@ -2144,7 +2144,7 @@ int unit_attack_timer_sub(struct block_list* src, int tid, int64 tick) { return 1; ud->attackabletime = tick + sstatus->adelay; -// You can't move if you can't attack neither. + // You can't move if you can't attack neither. if (src->type&battle_config.attack_walk_delay) unit->set_walkdelay(src, tick, sstatus->amotion, 1); } @@ -2189,8 +2189,8 @@ int unit_skillcastcancel(struct block_list *bl,int type) if (!ud->state.skillcastcancel) return 0; - if (sd && (sd->special_state.no_castcancel2 || - ( sd->special_state.no_castcancel && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89] + if (sd && (sd->special_state.no_castcancel2 + || (sd->special_state.no_castcancel && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground))) //fixed flags being read the wrong way around [blackhole89] return 0; } @@ -2534,10 +2534,10 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype) { unit->remove_map(&sd->bl,clrtype,ALC_MARK); - + //CLR_RESPAWN is the warp from logging out, CLR_TELEPORT is the warp from teleporting, but pets/homunc need to just 'vanish' instead of showing the warping animation. if (clrtype == CLR_RESPAWN || clrtype == CLR_TELEPORT) clrtype = CLR_OUTSIGHT; - + if(sd->pd) unit->remove_map(&sd->pd->bl, clrtype, ALC_MARK); if(homun_alive(sd->hd)) @@ -2566,7 +2566,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) { nullpo_ret(ud); map->freeblock_lock(); - if( bl->prev ) //Players are supposed to logout with a "warp" effect. + if( bl->prev ) //Players are supposed to logout with a "warp" effect. unit->remove_map(bl, clrtype, ALC_MARK); switch( bl->type ) { @@ -2577,7 +2577,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) { unsigned int k; sd->state.loggingout = 1; - + if( status->isdead(bl) ) pc->setrestartvalue(sd,2); @@ -2636,7 +2636,7 @@ int unit_free(struct block_list *bl, clr_type clrtype) { sd->quest_log = NULL; sd->num_quests = sd->avail_quests = 0; } - + for( k = 0; k < sd->hdatac; k++ ) { if( sd->hdata[k]->flag.free ) { aFree(sd->hdata[k]->data); @@ -2690,10 +2690,10 @@ int unit_free(struct block_list *bl, clr_type clrtype) { aFree (pd->loot); pd->loot = NULL; } - if( pd->pet.intimate > 0 ) + if (pd->pet.intimate > 0) { intif->save_petdata(pd->pet.account_id,&pd->pet); - else - { //Remove pet. + } else { + //Remove pet. intif->delete_petdata(pd->pet.pet_id); if (sd) sd->status.pet_id = 0; } @@ -2839,7 +2839,7 @@ int do_final_unit(void) { void unit_defaults(void) { unit = &unit_s; - + unit->init = do_init_unit; unit->final = do_final_unit; /* */ diff --git a/src/map/vending.c b/src/map/vending.c index 7e9393bf2..bd61d482f 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -134,11 +134,11 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, clif->buyvending(sd, idx, amount, 2); // you can not buy, because overweight return; } - + //Check to see if cart/vend info is in sync. if( vend[j].amount > vsd->status.cart[idx].amount ) vend[j].amount = vsd->status.cart[idx].amount; - + // if they try to add packets (example: get twice or more 2 apples if marchand has only 3 apples). // here, we check cumulative amounts if( vend[j].amount < amount ) { @@ -146,12 +146,12 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, clif->buyvending(sd, idx, vsd->vending[j].amount, 4); // not enough quantity return; } - + vend[j].amount -= amount; switch( pc->checkadditem(sd, vsd->status.cart[idx].nameid, amount) ) { case ADDITEM_EXIST: - break; //We'd add this item to the existing one (in buyers inventory) + break; //We'd add this item to the existing one (in buyers inventory) case ADDITEM_NEW: new_++; if (new_ > blank) @@ -190,7 +190,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid, for( i = 0, cursor = 0; i < vsd->vend_num; i++ ) { if( vsd->vending[i].amount == 0 ) continue; - + if( cursor != i ) { // speedup vsd->vending[cursor].index = vsd->vending[i].index; vsd->vending[cursor].amount = vsd->vending[i].amount; @@ -245,7 +245,7 @@ void vending_openvending(struct map_session_data* sd, const char* message, const clif->skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0); return; } - + // filter out invalid items i = 0; for( j = 0; j < count; j++ ) { @@ -256,13 +256,13 @@ void vending_openvending(struct map_session_data* sd, const char* message, const index -= 2; // offset adjustment (client says that the first cart position is 2) if( index < 0 || index >= MAX_CART // invalid position - || pc->cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity + || pc->cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity //NOTE: official server does not do any of the following checks! - || !sd->status.cart[index].identify // unidentified item - || sd->status.cart[index].attribute == 1 // broken item - || sd->status.cart[index].expire_time // It should not be in the cart but just in case - || (sd->status.cart[index].bound && !pc_can_give_bound_items(sd)) // can't trade bound items w/o permission - || !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item + || !sd->status.cart[index].identify // unidentified item + || sd->status.cart[index].attribute == 1 // broken item + || sd->status.cart[index].expire_time // It should not be in the cart but just in case + || (sd->status.cart[index].bound && !pc_can_give_bound_items(sd)) // can't trade bound items w/o permission + || !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item continue; sd->vending[i].index = index; @@ -287,7 +287,7 @@ void vending_openvending(struct map_session_data* sd, const char* message, const clif->openvending(sd,sd->bl.id,sd->vending); clif->showvendingboard(&sd->bl,message,0); - + idb_put(vending->db, sd->status.char_id, sd); } @@ -372,10 +372,10 @@ void init(bool minimal) { void vending_defaults(void) { vending = &vending_s; - + vending->init = init; vending->final = final; - + vending->close = vending_closevending; vending->open = vending_openvending; vending->list = vending_vendinglistreq; diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c index e6f52790d..d1b267cf1 100644 --- a/src/plugins/HPMHooking.c +++ b/src/plugins/HPMHooking.c @@ -145,11 +145,11 @@ HPExport bool Hooked (bool *fr) { HPExport bool HPM_Plugin_AddHook(enum HPluginHookType type, const char *target, void *hook, unsigned int pID) { struct HookingPointData *hpd; - + if( hp_db && (hpd = strdb_get(hp_db,target)) ) { struct HPMHookPoint **hp = NULL; int *count = NULL; - + if( type == HOOK_TYPE_PRE ) { hp = (struct HPMHookPoint **)((char *)&HPMHooks.list + (sizeof(struct HPMHookPoint *)*hpd->idx)); count = (int *)((char *)&HPMHooks.count + (sizeof(int)*hpd->idx)); @@ -157,21 +157,21 @@ HPExport bool HPM_Plugin_AddHook(enum HPluginHookType type, const char *target, hp = (struct HPMHookPoint **)((char *)&HPMHooks.list + (sizeof(struct HPMHookPoint *)*(hpd->idx+1))); count = (int *)((char *)&HPMHooks.count + (sizeof(int)*(hpd->idx+1))); } - + if( hp ) { *count += 1; - + RECREATE(*hp, struct HPMHookPoint, *count); - + (*hp)[*count - 1].func = hook; (*hp)[*count - 1].pID = pID; - + *(hpd->sref) = hpd->tref; - + return true; } } - + return false; } @@ -179,46 +179,45 @@ HPExport bool HPM_Plugin_AddHook(enum HPluginHookType type, const char *target, void HPM_HP_final(void) { int i, len = HPMHooks.data.total * 2; - + if( hp_db ) db_destroy(hp_db); - + for(i = 0; i < len; i++) { int *count = (int *)((char *)&HPMHooks.count + (sizeof(int)*(i))); - + if( count && *count ) { struct HPMHookPoint **hp = (struct HPMHookPoint **)((char *)&HPMHooks.list + (sizeof(struct HPMHookPoint *)*(i))); - + if( hp && *hp ) aFree(*hp); } } - } void HPM_HP_load(void) { #include HPM_POINTS_INCLUDE int i, len = ARRAYLENGTH(HookingPoints), idx = 0; - + memset(&HPMHooks,0,sizeof(struct HPMHooksCore)); - + hp_db = strdb_alloc(DB_OPT_BASE|DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, HookingPointsLenMax); - + for(i = 0; i < len; i++) { struct HookingPointData *hpd = NULL; - + CREATE(hpd, struct HookingPointData, 1); - + memcpy(hpd, &HookingPoints[i], sizeof(struct HookingPointData)); - + hpd->idx = idx; idx += 2; - + strdb_put(hp_db, HookingPoints[i].name, hpd); - + HPMHooks.data.total++; } - + #include HPM_SOURCES_INCLUDE } diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index 751f4be8a..eda61d026 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -49,7 +49,7 @@ void hstr(const char *str) { } int db2sql(config_setting_t *entry, int n, const char *source) { struct item_data *it = NULL; - + if( (it = itemdb->exists(itemdb_readdb_libconfig_sub(entry,n,source))) ) { char e_name[ITEM_NAME_LENGTH*2+1]; const char *bonus = NULL; @@ -67,7 +67,7 @@ int db2sql(config_setting_t *entry, int n, const char *source) { // name_english SQL->EscapeString(NULL, e_name, it->name); StrBuf->Printf(&buf, "'%s',", e_name); - + // name_japanese SQL->EscapeString(NULL, e_name, it->jname); StrBuf->Printf(&buf, "'%s',", e_name); @@ -200,7 +200,7 @@ int db2sql(config_setting_t *entry, int n, const char *source) { SQL->EscapeString(NULL, tosql.buf[0].p, str); } StrBuf->Printf(&buf, "'%s',", it->script?tosql.buf[0].p:""); - + // equip_script if (it->equip_script) { libconfig->setting_lookup_string(entry, "OnEquipScript", &bonus); @@ -290,56 +290,56 @@ void do_db2sql(void) { ShowInfo("db2sql: this should not be used with 'db_use_sql_item_db' enabled, skipping...\n"); return; } - + /* link */ itemdb_readdb_libconfig_sub = itemdb->readdb_libconfig_sub; itemdb->readdb_libconfig_sub = db2sql; /* */ - + if ((tosql.fp = fopen("sql-files/item_db_re.sql", "wt+")) == NULL) { ShowError("itemdb_tosql: File not found \"%s\".\n", "sql-files/item_db_re.sql"); return; - } - + } + tosql.db_name = map->item_db_re_db; totable(); - + memset(&tosql.buf, 0, sizeof(tosql.buf) ); - + itemdb->clear(false); itemdb->readdb_libconfig("re/item_db.conf"); - + fclose(tosql.fp); - + if ((tosql.fp = fopen("sql-files/item_db.sql", "wt+")) == NULL) { ShowError("itemdb_tosql: File not found \"%s\".\n", "sql-files/item_db.sql"); return; - } - + } + tosql.db_name = map->item_db_db; totable(); - + itemdb->clear(false); itemdb->readdb_libconfig("pre-re/item_db.conf"); - + fclose(tosql.fp); - + if ((tosql.fp = fopen("sql-files/item_db2.sql", "wt+")) == NULL) { ShowError("itemdb_tosql: File not found \"%s\".\n", "sql-files/item_db2.sql"); return; - } - + } + tosql.db_name = map->item_db2_db; totable(); - + itemdb->clear(false); itemdb->readdb_libconfig("item_db2.conf"); - + fclose(tosql.fp); - + /* unlink */ itemdb->readdb_libconfig_sub = itemdb_readdb_libconfig_sub; - + if( tosql.buf[0].p ) aFree(tosql.buf[0].p); if( tosql.buf[1].p ) aFree(tosql.buf[1].p); if( tosql.buf[2].p ) aFree(tosql.buf[2].p); @@ -359,7 +359,7 @@ HPExport void server_preinit (void) { iMalloc = GET_SYMBOL("iMalloc"); libconfig = GET_SYMBOL("libconfig"); StrBuf = GET_SYMBOL("StrBuf"); - + addArg("--db2sql",false,db2sql_arg,NULL); } HPExport void plugin_init (void) { diff --git a/src/plugins/dbghelpplug.c b/src/plugins/dbghelpplug.c index d121e9492..bf43c0b23 100644 --- a/src/plugins/dbghelpplug.c +++ b/src/plugins/dbghelpplug.c @@ -44,65 +44,65 @@ HPExport struct hplugin_info pinfo = { #ifdef _NO_CVCONST_H typedef enum _BasicType { - btNoType = 0, - btVoid = 1, - btChar = 2, - btWChar = 3, - btInt = 6, - btUInt = 7, - btFloat = 8, - btBCD = 9, - btBool = 10, - btLong = 13, - btULong = 14, - btCurrency = 25, - btDate = 26, - btVariant = 27, - btComplex = 28, - btBit = 29, - btBSTR = 30, - btHresult = 31 + btNoType = 0, + btVoid = 1, + btChar = 2, + btWChar = 3, + btInt = 6, + btUInt = 7, + btFloat = 8, + btBCD = 9, + btBool = 10, + btLong = 13, + btULong = 14, + btCurrency = 25, + btDate = 26, + btVariant = 27, + btComplex = 28, + btBit = 29, + btBSTR = 30, + btHresult = 31 } BasicType; typedef enum _UdtKind { - UdtStruct, - UdtClass, - UdtUnion + UdtStruct, + UdtClass, + UdtUnion } UdtKind; /* typedef enum _SymTag { - SymTagNull = 0, - SymTagExe = 1, - SymTagCompiland = 2, - SymTagCompilandDetails = 3, - SymTagCompilandEnv = 4, - SymTagFunction = 5, - SymTagBlock = 6, - SymTagData = 7, - SymTagAnnotation = 8, - SymTagLabel = 9, - SymTagPublicSymbol = 10, - SymTagUDT = 11, - SymTagEnum = 12, - SymTagFunctionType = 13, - SymTagPointerType = 14, - SymTagArrayType = 15, - SymTagBaseType = 16, - SymTagTypedef = 17, - SymTagBaseClass = 18, - SymTagFriend = 19, - SymTagFunctionArgType = 20, - SymTagFuncDebugStart = 21, - SymTagFuncDebugEnd = 22, - SymTagUsingNamespace = 23, - SymTagVTableShape = 24, - SymTagVTable = 25, - SymTagCustom = 26, - SymTagThunk = 27, - SymTagCustomType = 28, - SymTagManagedType = 29, - SymTagDimension = 30 + SymTagNull = 0, + SymTagExe = 1, + SymTagCompiland = 2, + SymTagCompilandDetails = 3, + SymTagCompilandEnv = 4, + SymTagFunction = 5, + SymTagBlock = 6, + SymTagData = 7, + SymTagAnnotation = 8, + SymTagLabel = 9, + SymTagPublicSymbol = 10, + SymTagUDT = 11, + SymTagEnum = 12, + SymTagFunctionType = 13, + SymTagPointerType = 14, + SymTagArrayType = 15, + SymTagBaseType = 16, + SymTagTypedef = 17, + SymTagBaseClass = 18, + SymTagFriend = 19, + SymTagFunctionArgType = 20, + SymTagFuncDebugStart = 21, + SymTagFuncDebugEnd = 22, + SymTagUsingNamespace = 23, + SymTagVTableShape = 24, + SymTagVTable = 25, + SymTagCustom = 26, + SymTagThunk = 27, + SymTagCustomType = 28, + SymTagManagedType = 29, + SymTagDimension = 30 } SymTag; */ #endif /* _NO_CVCONST_H */ @@ -429,17 +429,17 @@ Dhp__PrintProcessInfo( fprintf(log_file, "eip=%08x esp=%08x ebp=%08x iopl=%1x %s %s %s %s %s %s %s %s %s %s\n", context->Eip, context->Esp, context->Ebp, - (context->EFlags >> 12) & 3, // IOPL level value - context->EFlags & 0x00100000 ? "vip" : " ", // VIP (virtual interrupt pending) - context->EFlags & 0x00080000 ? "vif" : " ", // VIF (virtual interrupt flag) - context->EFlags & 0x00000800 ? "ov" : "nv", // VIF (virtual interrupt flag) - context->EFlags & 0x00000400 ? "dn" : "up", // OF (overflow flag) - context->EFlags & 0x00000200 ? "ei" : "di", // IF (interrupt enable flag) - context->EFlags & 0x00000080 ? "ng" : "pl", // SF (sign flag) - context->EFlags & 0x00000040 ? "zr" : "nz", // ZF (zero flag) - context->EFlags & 0x00000010 ? "ac" : "na", // AF (aux carry flag) - context->EFlags & 0x00000004 ? "po" : "pe", // PF (parity flag) - context->EFlags & 0x00000001 ? "cy" : "nc"); // CF (carry flag) + (context->EFlags >> 12) & 3, // IOPL level value + context->EFlags & 0x00100000 ? "vip" : " ", // VIP (virtual interrupt pending) + context->EFlags & 0x00080000 ? "vif" : " ", // VIF (virtual interrupt flag) + context->EFlags & 0x00000800 ? "ov" : "nv", // VIF (virtual interrupt flag) + context->EFlags & 0x00000400 ? "dn" : "up", // OF (overflow flag) + context->EFlags & 0x00000200 ? "ei" : "di", // IF (interrupt enable flag) + context->EFlags & 0x00000080 ? "ng" : "pl", // SF (sign flag) + context->EFlags & 0x00000040 ? "zr" : "nz", // ZF (zero flag) + context->EFlags & 0x00000010 ? "ac" : "na", // AF (aux carry flag) + context->EFlags & 0x00000004 ? "po" : "pe", // PF (parity flag) + context->EFlags & 0x00000001 ? "cy" : "nc"); // CF (carry flag) } if( context->ContextFlags & CONTEXT_SEGMENTS ) { @@ -525,9 +525,9 @@ Dhp__PrintTypeName( case btVoid: fprintf(log_file, "void"); break; case btChar: fprintf(log_file, "char"); break; case btWChar: fprintf(log_file, "wchar"); break; - case btULong: fprintf(log_file, "unsigned "); // next + case btULong: fprintf(log_file, "unsigned "); // next case btLong: fprintf(log_file, "long"); break; - case btUInt: fprintf(log_file, "unsigned "); // next + case btUInt: fprintf(log_file, "unsigned "); // next case btInt: if( length == sizeof(char) ) fprintf(log_file, "char"); else if( length == sizeof(short) ) fprintf(log_file, "short"); @@ -870,7 +870,7 @@ Dhp__PrintValueCWideString( } __except( EXCEPTION_EXECUTE_HANDLER ) { - if( length ) Dhp__PrintValueWideChars(log_file, str, length*sizeof(WCHAR), TRUE); // print readable part + if( length ) Dhp__PrintValueWideChars(log_file, str, length*sizeof(WCHAR), TRUE); // print readable part fprintf(log_file, "<invalid memory>"); return; } @@ -901,7 +901,7 @@ Dhp__PrintValueCString( } __except( EXCEPTION_EXECUTE_HANDLER ) { - if( length ) Dhp__PrintValueChars(log_file, str, length*sizeof(char), TRUE); // print readable part + if( length ) Dhp__PrintValueChars(log_file, str, length*sizeof(char), TRUE); // print readable part fprintf(log_file, "<invalid memory>"); return; } @@ -954,7 +954,7 @@ Dhp__PrintDataValue( ULONG i; BYTE b = 0; for( i = 0; i < length; ++i ) - b += p[i]; // add to make sure it's not optimized out in release mode + b += p[i]; // add to make sure it's not optimized out in release mode // Don't continue if there's no valid data if( b == 0 ) { @@ -1091,7 +1091,7 @@ Dhp__PrintDataValue( DWORD i; // count children - if( !SymGetTypeInfo_(hProcess, modBase, typeIndex, TI_GET_CHILDRENCOUNT, &childCount) + if( !SymGetTypeInfo_(hProcess, modBase, typeIndex, TI_GET_CHILDRENCOUNT, &childCount) || !childCount ) { fprintf(log_file, "<no children found>"); Dhp__PrintValueBytes(log_file, (BYTE*)pVariable, length); @@ -1228,28 +1228,27 @@ Dhp__PrintDataInfo( nr_of_var = pInterData->nr_of_var; // Determine the scope and address of the variable - if( pSymInfo->Flags & SYMFLAG_REGREL ) - { + if( pSymInfo->Flags & SYMFLAG_REGREL ) { pVariable = pStackframe->AddrFrame.Offset; pVariable += (DWORD_PTR)pSymInfo->Address; if( pSymInfo->Flags & SYMFLAG_PARAMETER ) - scope = PARAM; // parameter + scope = PARAM; // parameter else if( pSymInfo->Flags & SYMFLAG_LOCAL ) { - scope = LOCAL; // local + scope = LOCAL; // local #if defined(_M_IX86) - if( (LONG64)pSymInfo->Address > 0) scope = PARAM; // parameter as local (bug in DBGHELP 5.1) + if( (LONG64)pSymInfo->Address > 0) scope = PARAM; // parameter as local (bug in DBGHELP 5.1) #endif } } else if( pSymInfo->Flags & SYMFLAG_REGISTER ) { - scope = ( pSymInfo->Flags & SYMFLAG_PARAMETER ? PARAM : LOCAL ); // register, optimized out(?) + scope = ( pSymInfo->Flags & SYMFLAG_PARAMETER ? PARAM : LOCAL ); // register, optimized out(?) } else { pVariable = (DWORD_PTR)pSymInfo->Address; - scope = GLOBAL; // It must be a global variable + scope = GLOBAL; // It must be a global variable } // check if we should to log the variable @@ -1311,7 +1310,7 @@ Dhp__EnumSymbolsCallback( PVOID pData) { if( pSymInfo == NULL ) - return TRUE; // try other symbols + return TRUE; // try other symbols if( pData == NULL ) { @@ -1345,7 +1344,7 @@ Dhp__PrintSourceLine( assert( log_file != NULL ); // generate search paths - strcpy(path, filename); // original path + strcpy(path, filename); // original path p = strrchr(path, '\\'); if( p ) { @@ -1355,15 +1354,15 @@ Dhp__PrintSourceLine( { while( strstr(p+1, "\\src\\") ) p = strstr(p+1, "\\src\\"); - strcat(path, p+1); // last src folder path + strcat(path, p+1); // last src folder path p = strrchr(path, '\\'); memcpy(p, ";\0", 2); } filename = strrchr(filename, '\\')+1; } else - *path = '\0'; // no path - strcat(path, "."); // current directoy + *path = '\0'; // no path + strcat(path, "."); // current directoy // search for file and line if( SearchPathA(path, filename, NULL, MAX_PATH, pathBuffer, NULL) ) @@ -1668,8 +1667,8 @@ Dhp__CreateFiles( char* out_logFileName, char* out_dmpFileName) { -#define LEN_TIMESTAMP 14 // "YYYYMMDDhhmmss" -#define LEN_EXT 4 // ".rpt" or ".dmp" +#define LEN_TIMESTAMP 14 // "YYYYMMDDhhmmss" +#define LEN_EXT 4 // ".rpt" or ".dmp" char baseFileName[MAX_PATH+1]; char timestamp[LEN_TIMESTAMP+1]; FILE* fp; @@ -1682,7 +1681,7 @@ Dhp__CreateFiles( char* pTerm = strrchr(baseFileName, '\\'); if( pTerm == NULL ) pTerm = baseFileName; pTerm = strrchr(pTerm, '.'); - if( pTerm ) *pTerm = '\0'; // remove extension + if( pTerm ) *pTerm = '\0'; // remove extension } else if( GetTempPathA(MAX_PATH-6-LEN_TIMESTAMP-LEN_EXT, baseFileName) ) {// in temp folder @@ -1700,20 +1699,20 @@ Dhp__CreateFiles( strftime(timestamp, sizeof(timestamp), "%Y%m%d%H%M%S", localtime(&now)); #endif timestamp[LEN_TIMESTAMP] = '\0'; - + sprintf(out_logFileName, "%s%s.rpt", baseFileName, timestamp); fp = fopen(out_logFileName, "w"); if( fp == NULL ) - return FALSE; // failed to create log file + return FALSE; // failed to create log file fclose(fp); sprintf(out_dmpFileName, "%s%s.dmp", baseFileName, timestamp); fp = fopen(out_dmpFileName, "w"); if( fp == NULL) - return FALSE; // failed to create dump file + return FALSE; // failed to create dump file fclose(fp); - return TRUE; // success + return TRUE; // success #undef LEN_EXT #undef LEN_TIMESTAMP } diff --git a/src/plugins/sample.c b/src/plugins/sample.c index a2bf2c1bc..03d32b1f3 100644 --- a/src/plugins/sample.c +++ b/src/plugins/sample.c @@ -18,10 +18,10 @@ #include "../common/HPMDataCheck.h" /* should always be the last file included! (if you don't make it last, it'll intentionally break compile time) */ HPExport struct hplugin_info pinfo = { - "Sample", // Plugin name + "Sample", // Plugin name SERVER_TYPE_CHAR|SERVER_TYPE_LOGIN|SERVER_TYPE_MAP,// Which server types this plugin works with? - "0.1", // Plugin version - HPM_VERSION, // HPM Version (don't change, macro is automatically updated) + "0.1", // Plugin version + HPM_VERSION, // HPM Version (don't change, macro is automatically updated) }; ACMD(sample) {//@sample command - 5 params: const int fd, struct map_session_data* sd, const char* command, const char* message, struct AtCommandInfo *info printf("I'm being run! message -> '%s' by %s\n",message,sd->status.name); @@ -46,20 +46,20 @@ struct sample_data_struct { void sample_packet0f3(int fd) { struct map_session_data *sd = session[fd]->session_data; struct sample_data_struct *data; - + if( !sd ) return;/* socket didn't fully log-in? this packet shouldn't do anything then! */ - + ShowInfo("sample_packet0f3: Hello World! received 0xf3 for '%s', redirecting!\n",sd->status.name); - + /* sample usage of appending data to a socket_data (session[]) entry */ if( !(data = getFromSession(session[fd],0)) ) { CREATE(data,struct sample_data_struct,1); - + data->lastMSGPosition.map = sd->status.last_point.map; data->lastMSGPosition.x = sd->status.last_point.x; data->lastMSGPosition.y = sd->status.last_point.y; data->someNumber = rand()%777; - + ShowInfo("Created Appended session[] data, %d %d %d %d\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber); addToSession(session[fd],data,0,true); } else { @@ -69,16 +69,16 @@ void sample_packet0f3(int fd) { removeFromSession(session[fd],0); } } - + /* sample usage of appending data to a map_session_data (sd) entry */ if( !(data = getFromMSD(sd,0)) ) { CREATE(data,struct sample_data_struct,1); - + data->lastMSGPosition.map = sd->status.last_point.map; data->lastMSGPosition.x = sd->status.last_point.x; data->lastMSGPosition.y = sd->status.last_point.y; data->someNumber = rand()%777; - + ShowInfo("Created Appended map_session_data data, %d %d %d %d\n",data->lastMSGPosition.map,data->lastMSGPosition.x,data->lastMSGPosition.y,data->someNumber); addToMSD(sd,data,0,true); } else { @@ -89,7 +89,6 @@ void sample_packet0f3(int fd) { } } - clif->pGlobalMessage(fd,sd); } int my_pc_dropitem_storage;/* storage var */ @@ -120,7 +119,7 @@ void parse_my_setting(const char *val) { HPExport void plugin_init (void) { char *server_type; char *server_name; - + /* core vars */ server_type = GET_SYMBOL("SERVER_TYPE"); server_name = GET_SYMBOL("SERVER_NAME"); @@ -138,40 +137,40 @@ HPExport void plugin_init (void) { session = GET_SYMBOL("session"); ShowInfo ("Server type is "); - + switch (*server_type) { case SERVER_TYPE_LOGIN: printf ("Login Server\n"); break; case SERVER_TYPE_CHAR: printf ("Char Server\n"); break; case SERVER_TYPE_MAP: printf ("Map Server\n"); break; } - + ShowInfo ("I'm being run from the '%s' filename\n", server_name); - + /* addAtcommand("command-key",command-function) tells map server to call ACMD(sample) when "sample" command is used */ /* - it will print a warning when used on a non-map-server plugin */ addAtcommand("sample",sample);//link our '@sample' command - + /* addScriptCommand("script-command-name","script-command-params-info",script-function) tells map server to call BUILDIN(sample) for the "sample(i)" command */ /* - it will print a warning when used on a non-map-server plugin */ addScriptCommand("sample","i",sample); - + /* addCPCommand("console-command-name",command-function) tells server to call CPCMD(sample) for the 'this is a sample <optional-args>' console call */ /* in "console-command-name" usage of ':' indicates a category, for example 'this:is:a:sample' translates to 'this is a sample', * therefore 'this -> is -> a -> sample', it can be used to aggregate multiple commands under the same category or to append commands to existing categories * categories inherit the special keyword 'help' which prints the subsequent commands, e.g. 'server help' prints all categories and commands under 'server' * therefore 'this help' would inform about 'is (category) -> a (category) -> sample (command)'*/ addCPCommand("this:is:a:sample",sample); - + /* addPacket(packetID,packetLength,packetFunction,packetIncomingPoint) */ /* adds packetID of packetLength (-1 for dynamic length where length is defined in the packet { packetID (2 Byte) , packetLength (2 Byte) , ... }) * to trigger packetFunction in the packetIncomingPoint section ( available points listed in enum HPluginPacketHookingPoints within src/common/HPMi.h ) */ addPacket(0xf3,-1,sample_packet0f3,hpClif_Parse); - + /* in this sample we add a PreHook to pc->dropitem */ /* to identify whether the item being dropped is on amount higher than 1 */ /* if so, it stores the amount on a variable (my_pc_dropitem_storage) and changes the amount to 1 */ addHookPre("pc->dropitem",my_pc_dropitem_pre); - + /* in this sample we add a PostHook to pc->dropitem */ /* if the original pc->dropitem was successful and the amount stored on my_pc_dropitem_storage is higher than 1, */ /* our posthook will display a message to the user about the cap */ @@ -187,7 +186,6 @@ HPExport void server_preinit (void) { } /* run when server is ready (online) */ HPExport void server_online (void) { - } /* run when server is shutting down */ HPExport void plugin_final (void) { diff --git a/src/test/test_spinlock.c b/src/test/test_spinlock.c index 19a25f9d2..1b31e9b46 100644 --- a/src/test/test_spinlock.c +++ b/src/test/test_spinlock.c @@ -25,19 +25,19 @@ static volatile int32 done_threads = 0; static void *worker(void *p){ register int i; - + for(i = 0; i < PERINC; i++){ EnterSpinLock(&lock); EnterSpinLock(&lock); - + val++; - + LeaveSpinLock(&lock); LeaveSpinLock(&lock); } - + InterlockedIncrement(&done_threads); - + return NULL; }//end: worker() @@ -46,34 +46,31 @@ int do_init(int argc, char **argv){ rAthread *t[THRC]; int j, i; int ok; - + ShowStatus("==========\n"); ShowStatus("TEST: %u Runs, (%u Threads)\n", LOOPS, THRC); ShowStatus("This can take a while\n"); ShowStatus("\n\n"); - + ok =0; for(j = 0; j < LOOPS; j++){ val = 0; done_threads = 0; - + InitializeSpinLock(&lock); - for(i =0; i < THRC; i++){ t[i] = rathread_createEx( worker, NULL, 1024*512, RAT_PRIO_NORMAL); } - - + while(1){ if(InterlockedCompareExchange(&done_threads, THRC, THRC) == THRC) break; - rathread_yield(); } - + FinalizeSpinLock(&lock); - + // Everything fine? if(val != (THRC*PERINC) ){ printf("FAILED! (Result: %u, Expected: %u)\n", val, (THRC*PERINC) ); @@ -83,7 +80,6 @@ int do_init(int argc, char **argv){ } } - if(ok != LOOPS){ ShowFatalError("Test failed.\n"); |