diff --git a/src/char/char.c b/src/char/char.c index 549786d57a..54c7fb7af4 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -4766,7 +4766,7 @@ int parse_char(int fd) if( RFIFOREST(fd) < 6 ) return 0; if( pincode_enabled && RFIFOL(fd,2) == sd->account_id ){ - if( strlen( sd->pincode ) <= 0 ){ + if( sd->pincode[0] == '\0' ){ pincode_sendstate( fd, sd, PINCODE_NEW ); }else{ pincode_sendstate( fd, sd, PINCODE_ASK ); diff --git a/src/map/battle.c b/src/map/battle.c index 2e450ef639..3a81de5399 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -3378,7 +3378,7 @@ static int battle_calc_attack_skill_ratio(struct Damage wd, struct block_list *s case LG_SHIELDSPELL:// [(Casters Base Level x 4) + (Shield DEF x 10) + (Casters VIT x 2)] % if( sd ) { int index = sd->equip_index[EQI_HAND_L]; - struct item_data *shield_data; + struct item_data *shield_data = NULL; if( index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->type == IT_ARMOR ) shield_data = sd->inventory_data[index]; skillratio = status_get_lv(src) * 4 + status_get_vit(src) * 2; diff --git a/src/map/pc.c b/src/map/pc.c index 0fec653b1e..c91081520b 100755 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -8534,7 +8534,8 @@ static int pc_checkcombo(struct map_session_data *sd, struct item_data *data) { } CREATE(combo_idx,int16,data->combos[i]->count); - memset(combo_idx,-1,sizeof(combo_idx)); + memset(combo_idx,-1,data->combos[i]->count * sizeof(int16)); + for( j = 0; j < data->combos[i]->count; j++ ) { uint16 id = data->combos[i]->nameid[j], k; bool found = false; @@ -10136,7 +10137,7 @@ static int pc_read_statsdb(const char *basedir, int last_s, bool silent){ fclose(fp); ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s/%s"CL_RESET"'.\n", entries, basedir,"statpoint.txt"); } - return (i>1)?i:last_s; //If i == 1 means the file is empty. + return max(last_s,i); } /*========================================== diff --git a/src/map/script.c b/src/map/script.c index ca9736ac3f..ba04fcff8f 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -9230,7 +9230,10 @@ BUILDIN_FUNC(addtimer) if( sd == NULL ) return 0; - pc_addeventtimer(sd,tick,event); + if (!pc_addeventtimer(sd,tick,event)) { + ShowWarning("buildin_addtimer: Event timer is full, can't add new event timer. (cid:%d timer:%s)\n",sd->status.char_id,event); + return SCRIPT_CMD_FAILURE; + } return SCRIPT_CMD_SUCCESS; } @@ -17679,7 +17682,9 @@ BUILDIN_FUNC(npcskill) /* Consumes an item. * consumeitem ; - * consumeitem ""; */ + * consumeitem ""; + * @param item: Item ID or name + */ BUILDIN_FUNC(consumeitem) { TBL_NPC *nd; @@ -17698,30 +17703,30 @@ BUILDIN_FUNC(consumeitem) if( ( item_data = itemdb_searchname( name ) ) == NULL ){ ShowError( "buildin_consumeitem: Nonexistant item %s requested.\n", name ); - return 1; + return SCRIPT_CMD_FAILURE; } }else if( data_isint( data ) ){ int nameid = conv_num( st, data ); if( ( item_data = itemdb_exists( nameid ) ) == NULL ){ ShowError("buildin_consumeitem: Nonexistant item %d requested.\n", nameid ); - return 1; + return SCRIPT_CMD_FAILURE; } }else{ ShowError("buildin_consumeitem: invalid data type for argument #1 (%d).", data->type ); - return 1; + return SCRIPT_CMD_FAILURE; } run_script( item_data->script, 0, sd->bl.id, nd->bl.id ); return SCRIPT_CMD_SUCCESS; } -/*======================================================= - * Make a player sit/stand. +/** Makes a player sit/stand. * sit {""}; * stand {""}; * Note: Use readparam(Sitting) which returns 1 or 0 (sitting or standing). - *-------------------------------------------------------*/ + * @param name: Player name that will be invoked + */ BUILDIN_FUNC(sit) { TBL_PC *sd; @@ -17732,7 +17737,7 @@ BUILDIN_FUNC(sit) sd = script_rid2sd(st); if( sd == NULL) - return 0; + return SCRIPT_CMD_FAILURE; if( !pc_issit(sd) ) { unit_stop_walking(&sd->bl, 1|4); @@ -17743,6 +17748,9 @@ BUILDIN_FUNC(sit) return SCRIPT_CMD_SUCCESS; } +/** Makes player to stand +* @param name: Player name that will be set +*/ BUILDIN_FUNC(stand) { TBL_PC *sd; @@ -17753,7 +17761,7 @@ BUILDIN_FUNC(stand) sd = script_rid2sd(st); if( sd == NULL) - return 0; + return SCRIPT_CMD_FAILURE; if( pc_issit(sd) ) { pc_setstand(sd); @@ -17764,22 +17772,18 @@ BUILDIN_FUNC(stand) return SCRIPT_CMD_SUCCESS; } -/*========================================== +/** Creates an array of bounded item IDs * countbound {}; - * Creates an array of bounded item IDs - * Returns amount of items found - * Type: - * 1 - Account Bound - * 2 - Guild Bound - * 3 - Party Bound - *------------------------------------------*/ + * @param type: 1 - Account Bound; 2 - Guild Bound; 3 - Party Bound + * @return amt: Amount of items found + */ BUILDIN_FUNC(countbound) { int i, type, j=0, k=0; TBL_PC *sd; if( (sd = script_rid2sd(st)) == NULL ) - return 0; + return SCRIPT_CMD_FAILURE; type = script_hasdata(st,2)?script_getnum(st,2):0; @@ -17798,17 +17802,19 @@ BUILDIN_FUNC(countbound) return SCRIPT_CMD_SUCCESS; } -/*========================================== +/** Creates new party * party_create ""{,{,{,}}}; - * : 0-Each Take. 1-Party Share - * : 0-Each Take. 1-Even Share - * Return values: + * @param party_name: String of party name that will be created + * @param char_id: Chara that will be leader of this new party. If no char_id specified, the invoker will be party leader + * @param item_share: 0-Each Take. 1-Party Share + * @param item_share_type: 0-Each Take. 1-Even Share + * @return val: Result value * -3 - party name is exist * -2 - player is in party already * -1 - player is not found * 0 - unknown error * 1 - success, will return party id $@party_create_id - *------------------------------------------*/ + */ BUILDIN_FUNC(party_create) { char party_name[NAME_LENGTH]; @@ -17817,19 +17823,19 @@ BUILDIN_FUNC(party_create) if( (!script_hasdata(st,3) && !(sd = script_rid2sd(st))) || (script_hasdata(st,3) && !(sd = map_charid2sd(script_getnum(st,3)))) ) { script_pushint(st,-1); - return 0; + return SCRIPT_CMD_FAILURE; } if( sd->status.party_id ) { script_pushint(st,-2); - return 0; + return SCRIPT_CMD_FAILURE; } safestrncpy(party_name,script_getstr(st,2),NAME_LENGTH); trim(party_name); if( party_searchname(party_name) ) { script_pushint(st,-3); - return 0; + return SCRIPT_CMD_FAILURE; } if( script_getnum(st,4) ) item1 = 1; @@ -17841,17 +17847,18 @@ BUILDIN_FUNC(party_create) return SCRIPT_CMD_SUCCESS; } -/*========================================== +/** Adds player to specified party * party_addmember ,; - * Adds player to specified party - * Return values: + * @param party_id: The party that will be entered by player + * @param char_id: Char id of player that will be joined to the party + * @return val: Result value * -4 - party is full * -3 - party is not found * -2 - player is in party already * -1 - player is not found * 0 - unknown error * 1 - success - *------------------------------------------*/ + */ BUILDIN_FUNC(party_addmember) { int party_id = script_getnum(st,2); @@ -17860,46 +17867,46 @@ BUILDIN_FUNC(party_addmember) if( !(sd = map_charid2sd(script_getnum(st,3))) ) { script_pushint(st,-1); - return 0; + return SCRIPT_CMD_FAILURE; } if( sd->status.party_id ) { script_pushint(st,-2); - return 0; + return SCRIPT_CMD_FAILURE; } if( !(party = party_search(party_id)) ) { script_pushint(st,-3); - return 0; + return SCRIPT_CMD_FAILURE; } if( party->party.count >= MAX_PARTY ) { script_pushint(st,-4); - return 0; + return SCRIPT_CMD_FAILURE; } sd->party_invite = party_id; script_pushint(st,party_add_member(party_id,sd)); return SCRIPT_CMD_SUCCESS; } -/*========================================== +/** Removes player from his/her party. If party_id and char_id is empty remove the invoker from his/her party * party_delmember {,}; - * Removes player from his/her party. If party_id and char_id is empty - * remove the invoker from his/her party - * Return values: + * @param: char_id + * @param: party_id + * @return val: Result value * -3 - player is not in party * -2 - party is not found * -1 - player is not found * 0 - unknown error * 1 - success - *------------------------------------------*/ + */ BUILDIN_FUNC(party_delmember) { TBL_PC *sd = NULL; if( !script_hasdata(st,2) && !script_hasdata(st,3) && !(sd = script_rid2sd(st)) ) { script_pushint(st,-1); - return 0; + return SCRIPT_CMD_FAILURE; } if( sd || (script_getnum(st,2) && (sd = map_charid2sd(script_getnum(st,2)))) ) script_pushint(st,party_removemember2(sd,0,0)); @@ -17908,17 +17915,17 @@ BUILDIN_FUNC(party_delmember) return SCRIPT_CMD_SUCCESS; } -/*========================================== +/** Changes party leader of specified party (even the leader is offline) * party_changeleader ,; - * Can change party leader even the leader is not online - * Return values: + * @param party_id: ID of party + * @param char_id: Char ID of new leader + * @return val: Result value * -4 - player is party leader already * -3 - player is not in this party * -2 - player is not found * -1 - party is not found * 0 - unknown error - * 1 - success - *------------------------------------------*/ + * 1 - success */ BUILDIN_FUNC(party_changeleader) { int i, party_id = script_getnum(st,2); @@ -17928,59 +17935,55 @@ BUILDIN_FUNC(party_changeleader) if( !(party = party_search(party_id)) ) { script_pushint(st,-1); - return 0; + return SCRIPT_CMD_FAILURE; } if( !(tsd = map_charid2sd(script_getnum(st,3))) ) { script_pushint(st,-2); - return 0; + return SCRIPT_CMD_FAILURE; } if( tsd->status.party_id != party_id ) { script_pushint(st,-3); - return 0; + return SCRIPT_CMD_FAILURE; } ARR_FIND(0,MAX_PARTY,i,party->party.member[i].leader); if( i >= MAX_PARTY ) { //this is should impossible! script_pushint(st,0); - return 0; + return SCRIPT_CMD_FAILURE; } if( party->data[i].sd == tsd ) { script_pushint(st,-4); - return 0; + return SCRIPT_CMD_FAILURE; } script_pushint(st,party_changeleader(sd,tsd,party)); return SCRIPT_CMD_SUCCESS; } -/*========================================== +/** Changes party option * party_changeoption ,