diff options
-rw-r--r-- | src/char/char.c | 28 | ||||
-rw-r--r-- | src/char/inter.c | 4 | ||||
-rw-r--r-- | src/common/mmo.h | 4 | ||||
-rw-r--r-- | src/map/atcommand.c | 69 | ||||
-rw-r--r-- | src/map/battle.c | 6 | ||||
-rw-r--r-- | src/map/chat.c | 16 | ||||
-rw-r--r-- | src/map/chat.h | 8 | ||||
-rw-r--r-- | src/map/guild.c | 12 | ||||
-rw-r--r-- | src/map/mob.c | 2 | ||||
-rw-r--r-- | src/map/pc.c | 119 | ||||
-rw-r--r-- | src/map/pc.h | 22 | ||||
-rw-r--r-- | src/map/script.c | 4 | ||||
-rw-r--r-- | src/map/skill.c | 4 | ||||
-rw-r--r-- | src/map/status.c | 6 |
14 files changed, 138 insertions, 166 deletions
diff --git a/src/char/char.c b/src/char/char.c index 5f92e37bf..9275678e6 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -474,9 +474,9 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) if( p->show_equip ) opt |= OPT_SHOW_EQUIP; - if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `base_level`='%u', `job_level`='%u'," + 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`='%u',`skill_point`='%u'," + "`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d'," "`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d'," "`option`='%u',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d',`elemental_id`='%d'," "`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d'," @@ -958,8 +958,8 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || 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, 4, SQLDT_INT, &p.base_level, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 5, SQLDT_INT, &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) @@ -973,8 +973,8 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || 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, 19, SQLDT_INT, &p.status_point, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_INT, &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) @@ -1068,8 +1068,8 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || 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, 5, SQLDT_INT, &p->base_level, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 6, SQLDT_INT, &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) @@ -1083,8 +1083,8 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || 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, 20, SQLDT_INT, &p->status_point, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_INT, &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) @@ -4222,7 +4222,7 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) {// CH: <0829>.W <char id>.L <birth date:YYMMDD>.6B char birthdate[8+1]; int char_id, i; - unsigned int base_level; + int base_level; char* data; time_t delete_date; @@ -4256,7 +4256,7 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) return; } - SQL->GetData(inter->sql_handle, 0, &data, NULL); base_level = (unsigned int)strtoul(data, NULL, 10); + SQL->GetData(inter->sql_handle, 0, &data, NULL); base_level = atoi(data); SQL->GetData(inter->sql_handle, 1, &data, NULL); delete_date = strtoul(data, NULL, 10); if( !delete_date || delete_date>time(NULL) ) @@ -4271,8 +4271,8 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) return; } - if( ( char_del_level > 0 && base_level >= (unsigned int)char_del_level ) || ( char_del_level < 0 && base_level <= (unsigned int)(-char_del_level) ) ) - {// character level config restriction + if ((char_del_level > 0 && base_level >= char_del_level) || (char_del_level < 0 && base_level <= -char_del_level)) { + // character level config restriction chr->delete2_accept_ack(fd, char_id, 2); // 2: Due to system settings can not be deleted return; } diff --git a/src/char/inter.c b/src/char/inter.c index d277abec9..756ae32c7 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -474,7 +474,7 @@ void mapif_parse_accinfo(int fd) inter->msg_to_fd(fd, u_fd, aid, "Your query returned the following %d results, please be more specific...",(int)SQL->NumRows(inter->sql_handle)); while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) { int class_; - short base_level, job_level, online; + int base_level, job_level, online; char name[NAME_LENGTH]; SQL->GetData(inter->sql_handle, 0, &data, NULL); account_id = atoi(data); @@ -546,7 +546,7 @@ void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int acc while ( SQL_SUCCESS == SQL->NextRow(inter->sql_handle) ) { char *data; int char_id, class_; - short char_num, base_level, job_level, online; + int char_num, base_level, job_level, online; char name[NAME_LENGTH]; SQL->GetData(inter->sql_handle, 0, &data, NULL); char_id = atoi(data); diff --git a/src/common/mmo.h b/src/common/mmo.h index 3d3360132..0a5d9d053 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -570,7 +570,7 @@ struct mmo_charstatus { int bank_vault; short class_; - unsigned int status_point,skill_point; + int status_point, skill_point; int hp,max_hp,sp,max_sp; unsigned int option; short manner; // Defines how many minutes a char will be muted, each negative point is equivalent to a minute. @@ -590,7 +590,7 @@ struct mmo_charstatus { short robe; char name[NAME_LENGTH]; - unsigned int base_level,job_level; + int base_level, job_level; short str,agi,vit,int_,dex,luk; unsigned char slot,sex; diff --git a/src/map/atcommand.c b/src/map/atcommand.c index eef67189a..66ccbe3b0 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -1368,13 +1368,13 @@ ACMD(baselevelup) clif->message(fd, msg_fd(fd,47)); // Base level can't go any higher. return false; } // End Addition - if ((unsigned int)level > pc->maxbaselv(sd) || (unsigned int)level > pc->maxbaselv(sd) - sd->status.base_level) // fix positive overflow + if (level > pc->maxbaselv(sd) || level > pc->maxbaselv(sd) - sd->status.base_level) // fix positive overflow 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; + sd->status.base_level += level; status_calc_pc(sd, SCO_FORCE); status_percent_heal(&sd->bl, 100, 100); clif->misceffect(&sd->bl, 0); @@ -1385,7 +1385,7 @@ ACMD(baselevelup) return false; } level*=-1; - if ((unsigned int)level >= sd->status.base_level) + if (level >= sd->status.base_level) level = sd->status.base_level-1; for (i = 0; i > -level; i--) status_point += pc->gets_status_point(sd->status.base_level + i - 1); @@ -1395,7 +1395,7 @@ ACMD(baselevelup) sd->status.status_point = 0; else sd->status.status_point -= status_point; - sd->status.base_level -= (unsigned int)level; + sd->status.base_level -= level; clif->message(fd, msg_fd(fd,22)); // Base level lowered. status_calc_pc(sd, SCO_FORCE); } @@ -1426,9 +1426,9 @@ ACMD(joblevelup) clif->message(fd, msg_fd(fd,23)); // Job level can't go any higher. return false; } - if ((unsigned int)level > pc->maxjoblv(sd) || (unsigned int)level > pc->maxjoblv(sd) - sd->status.job_level) // fix positive overflow + if (level > pc->maxjoblv(sd) || level > pc->maxjoblv(sd) - sd->status.job_level) // fix positive overflow level = pc->maxjoblv(sd) - sd->status.job_level; - sd->status.job_level += (unsigned int)level; + sd->status.job_level += level; sd->status.skill_point += level; clif->misceffect(&sd->bl, 1); clif->message(fd, msg_fd(fd,24)); // Job level raised. @@ -1438,9 +1438,9 @@ ACMD(joblevelup) return false; } level *=-1; - if ((unsigned int)level >= sd->status.job_level) // fix negative overflow + if (level >= sd->status.job_level) // fix negative overflow level = sd->status.job_level-1; - sd->status.job_level -= (unsigned int)level; + sd->status.job_level -= level; if (sd->status.skill_point < level) pc->resetskill(sd, PCRESETSKILL_NONE); //Reset skills since we need to subtract more points. if (sd->status.skill_point < level) @@ -2296,30 +2296,18 @@ ACMD(displaystatus) ACMD(statuspoint) { int point; - unsigned int new_status_point; + int new_status_point; if (!*message || (point = atoi(message)) == 0) { clif->message(fd, msg_fd(fd,1010)); // Please enter a number (usage: @stpoint <number of points>). return false; } - if(point < 0) - { - if(sd->status.status_point < (unsigned int)(-point)) - { - new_status_point = 0; - } - else - { - new_status_point = sd->status.status_point + point; - } - } - else if(UINT_MAX - sd->status.status_point < (unsigned int)point) - { - new_status_point = UINT_MAX; - } - else - { + if (point < 0 && sd->status.status_point + point < 0) { + new_status_point = 0; + } else if (point > 0 && (int64)sd->status.status_point + point > INT_MAX) { + new_status_point = INT_MAX; + } else { new_status_point = sd->status.status_point + point; } @@ -2344,30 +2332,18 @@ ACMD(statuspoint) ACMD(skillpoint) { int point; - unsigned int new_skill_point; + int new_skill_point; if (!*message || (point = atoi(message)) == 0) { clif->message(fd, msg_fd(fd,1011)); // Please enter a number (usage: @skpoint <number of points>). return false; } - if(point < 0) - { - if(sd->status.skill_point < (unsigned int)(-point)) - { - new_skill_point = 0; - } - else - { - new_skill_point = sd->status.skill_point + point; - } - } - else if(UINT_MAX - sd->status.skill_point < (unsigned int)point) - { - new_skill_point = UINT_MAX; - } - else - { + if (point < 0 && sd->status.skill_point + point < 0) { + new_skill_point = 0; + } else if (point > 0 && (int64)sd->status.skill_point + point > INT_MAX) { + new_skill_point = INT_MAX; + } else { new_skill_point = sd->status.skill_point + point; } @@ -9295,8 +9271,9 @@ ACMD(costume){ } /* for debugging purposes (so users can easily provide us with debug info) */ /* should be trashed as soon as its no longer necessary */ -ACMD(skdebug) { - safesnprintf(atcmd_output, sizeof(atcmd_output),"second: %u; third: %u", sd->sktree.second, sd->sktree.third); +ACMD(skdebug) +{ + safesnprintf(atcmd_output, sizeof(atcmd_output),"second: %d; third: %d", sd->sktree.second, sd->sktree.third); clif->message(fd,atcmd_output); safesnprintf(atcmd_output, sizeof(atcmd_output),"pc_calc_skilltree_normalize_job: %d",pc->calc_skilltree_normalize_job(sd)); clif->message(fd,atcmd_output); diff --git a/src/map/battle.c b/src/map/battle.c index 6182d1ff5..79048457c 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -6774,9 +6774,9 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if ( (s_sd->class_&MAPID_UPPERMASK) == MAPID_NOVICE || (t_sd->class_&MAPID_UPPERMASK) == MAPID_NOVICE || - (int)s_sd->status.base_level < battle_config.pk_min_level || - (int)t_sd->status.base_level < battle_config.pk_min_level || - (battle_config.pk_level_range && abs((int)s_sd->status.base_level - (int)t_sd->status.base_level) > battle_config.pk_level_range) + s_sd->status.base_level < battle_config.pk_min_level || + t_sd->status.base_level < battle_config.pk_min_level || + (battle_config.pk_level_range && abs(s_sd->status.base_level - t_sd->status.base_level) > battle_config.pk_level_range) ) state &= ~BCT_ENEMY; } diff --git a/src/map/chat.c b/src/map/chat.c index df48e1f2c..2fe1aacd4 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -44,7 +44,7 @@ struct chat_interface *chat; /// Initializes a chatroom object (common functionality for both pc and npc chatrooms). /// Returns a chatroom object on success, or NULL on failure. -struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl) +struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int min_level, int max_level) { struct chat_data* cd; nullpo_retr(NULL, bl); @@ -62,8 +62,8 @@ struct chat_data* chat_createchat(struct block_list* bl, const char* title, cons cd->limit = min(limit, ARRAYLENGTH(cd->usersd)); cd->trigger = trigger; cd->zeny = zeny; - cd->minLvl = minLvl; - cd->maxLvl = maxLvl; + cd->min_level = min_level; + cd->max_level = max_level; memset(cd->usersd, 0, sizeof(cd->usersd)); cd->owner = bl; safestrncpy(cd->npc_event, ev, sizeof(cd->npc_event)); @@ -156,8 +156,8 @@ bool chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) { return false; } - if( sd->status.base_level < cd->minLvl || sd->status.base_level > cd->maxLvl ) { - if(sd->status.base_level < cd->minLvl) + if (sd->status.base_level < cd->min_level || sd->status.base_level > cd->max_level) { + if(sd->status.base_level < cd->min_level) clif->joinchatfail(sd,5); // too low level else clif->joinchatfail(sd,6); // too high level @@ -375,7 +375,7 @@ bool chat_kickchat(struct map_session_data* sd, const char* kickusername) { /*========================================== * Creates a chat room for the npc *------------------------------------------*/ -bool chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl) +bool chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int min_level, int max_level) { struct chat_data* cd; nullpo_ret(nd); @@ -385,12 +385,12 @@ bool chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool return false; } - if( zeny > MAX_ZENY || maxLvl > MAX_LEVEL ) { + if (zeny > MAX_ZENY || max_level > MAX_LEVEL) { ShowError("chat_createnpcchat: npc '%s' has a required lvl or amount of zeny over the max limit!\n", nd->exname); return false; } - cd = chat->create(&nd->bl, title, "", limit, pub, trigger, ev, zeny, minLvl, maxLvl); + cd = chat->create(&nd->bl, title, "", limit, pub, trigger, ev, zeny, min_level, max_level); if( cd ) { nd->chat_id = cd->bl.id; diff --git a/src/map/chat.h b/src/map/chat.h index 59d61a46e..af43d9703 100644 --- a/src/map/chat.h +++ b/src/map/chat.h @@ -41,8 +41,8 @@ struct chat_data { 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 + int min_level; ///< minimum base level to join + int max_level; ///< maximum base level allowed to join struct map_session_data* usersd[MAX_CHAT_USERS]; struct block_list* owner; char npc_event[EVENT_NAME_LENGTH]; @@ -63,13 +63,13 @@ struct chat_interface { bool (*change_owner) (struct map_session_data* sd, const char* nextownername); bool (*change_status) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub); bool (*kick) (struct map_session_data* sd, const char* kickusername); - bool (*create_npc_chat) (struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl); + bool (*create_npc_chat) (struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int min_level, int max_level); bool (*delete_npc_chat) (struct npc_data* nd); bool (*enable_event) (struct chat_data* cd); bool (*disable_event) (struct chat_data* cd); bool (*npc_kick_all) (struct chat_data* cd); bool (*trigger_event) (struct chat_data *cd); - struct chat_data* (*create) (struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl); + struct chat_data* (*create) (struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int min_level, int max_level); }; #ifdef HERCULES_CORE diff --git a/src/map/guild.c b/src/map/guild.c index ae3887aca..83afc9538 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -416,20 +416,18 @@ int guild_request_info(int guild_id) //Information request with event int guild_npc_request_info(int guild_id,const char *event) { - if( guild->search(guild_id) ) - { - if( event && *event ) + if (guild->search(guild_id) != NULL) { + if (event != NULL && *event != '\0') npc->event_do(event); return 0; } - if( event && *event ) - { + if (event != NULL && *event != '\0') { struct eventlist *ev; struct DBData prev; - ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1); - memcpy(ev->name,event,strlen(event)); + CREATE(ev, struct eventlist, 1); + safestrncpy(ev->name, event, sizeof(ev->name)); //The one in the db (if present) becomes the next event from this. if (guild->infoevent_db->put(guild->infoevent_db, DB->i2key(guild_id), DB->ptr2data(ev), &prev)) ev->next = DB->data2ptr(&prev); diff --git a/src/map/mob.c b/src/map/mob.c index b6b36dd61..bede7deed 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2405,7 +2405,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) { drop_rate += (int)(0.5+drop_rate*status_get_luk(src)*battle_config.drops_by_luk2/10000.); } if (sd && battle_config.pk_mode && - (int)(md->level - sd->status.base_level) >= 20) + md->level - sd->status.base_level >= 20) drop_rate = (int)(drop_rate*1.25); // pk_mode increase drops if 20 level difference [Valaris] // Increase drop rate if user has SC_CASH_RECEIVEITEM diff --git a/src/map/pc.c b/src/map/pc.c index 93470493a..27bd71b64 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -960,11 +960,11 @@ int pc_isequip(struct map_session_data *sd,int n) if(pc_has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT)) return 1; - if (item->elv && sd->status.base_level < (unsigned int)item->elv) { + if (item->elv && sd->status.base_level < item->elv) { clif->msgtable(sd, MSG_ITEM_CANT_EQUIP_LVL); return 0; } - if (item->elvmax && sd->status.base_level > (unsigned int)item->elvmax) { + if (item->elvmax && sd->status.base_level > item->elvmax) { clif->msgtable(sd, MSG_ITEM_CANT_EQUIP_LVL); return 0; } @@ -1583,7 +1583,7 @@ int pc_calc_skilltree(struct map_session_data *sd) break; } } - if (sd->status.job_level < pc->skill_tree[c][i].joblv) { + if (sd->status.job_level < (int)pc->skill_tree[c][i].joblv) { int jobid = pc->mapid2jobid(sd->class_, sd->status.sex); // need to get its own skilltree if (jobid > -1) { if (!pc->skill_tree[pc->class2idx(jobid)][i].inherited) @@ -1687,7 +1687,7 @@ void pc_check_skilltree(struct map_session_data *sd, int skill_id) if (!satisfied) continue; - if (sd->status.job_level < pc->skill_tree[c][i].joblv) { + if (sd->status.job_level < (int)pc->skill_tree[c][i].joblv) { int jobid = pc->mapid2jobid(sd->class_, sd->status.sex); // need to get its own skilltree if (jobid > -1) { if (!pc->skill_tree[pc->class2idx(jobid)][i].inherited) @@ -1756,28 +1756,25 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) else if ((sd->class_&JOBL_2) && (sd->class_&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) { // regenerate change_level_2nd - if (!sd->change_level_2nd) - { - if (sd->class_&JOBL_THIRD) - { + if (sd->change_level_2nd == 0) { + if (sd->class_&JOBL_THIRD) { // if neither 2nd nor 3rd jobchange levels are known, we have to assume a default for 2nd - if (!sd->change_level_3rd) + if (sd->change_level_3rd == 0) { sd->change_level_2nd = pc->max_level[pc->class2idx(pc->mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex))][1]; - else + } else { sd->change_level_2nd = 1 + skill_point + sd->status.skill_point - (sd->status.job_level - 1) - (sd->change_level_3rd - 1) - novice_skills; - } - else - { + } + } else { sd->change_level_2nd = 1 + skill_point + sd->status.skill_point - (sd->status.job_level - 1) - novice_skills; } - pc_setglobalreg (sd, script->add_str("jobchange_level"), sd->change_level_2nd); + pc_setglobalreg(sd, script->add_str("jobchange_level"), sd->change_level_2nd); } if (skill_point < novice_skills + (sd->change_level_2nd - 1)) { @@ -1785,12 +1782,12 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) sd->sktree.second = ( novice_skills + (sd->change_level_2nd - 1) ) - skill_point; } else if(sd->class_&JOBL_THIRD) { // limit 3rd class to 2nd class/trans job levels // regenerate change_level_3rd - if (!sd->change_level_3rd) { + if (sd->change_level_3rd == 0) { sd->change_level_3rd = 1 + skill_point + sd->status.skill_point - (sd->status.job_level - 1) - (sd->change_level_2nd - 1) - novice_skills; - pc_setglobalreg (sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); + pc_setglobalreg(sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); } if (skill_point < novice_skills + (sd->change_level_2nd - 1) + (sd->change_level_3rd - 1)) { @@ -4878,12 +4875,12 @@ int pc_isUseitem(struct map_session_data *sd,int n) if(item->sex != 2 && sd->status.sex != item->sex) return 0; //Required level check - if (item->elv && sd->status.base_level < (unsigned int)item->elv) { + if (item->elv && sd->status.base_level < item->elv) { clif->msgtable(sd, MSG_ITEM_CANT_USE_LVL); return 0; } - if (item->elvmax && sd->status.base_level > (unsigned int)item->elvmax) { + if (item->elvmax && sd->status.base_level > item->elvmax) { clif->msgtable(sd, MSG_ITEM_CANT_USE_LVL); return 0; } @@ -6578,14 +6575,15 @@ int pc_checkbaselevelup(struct map_session_data *sd) { return 0; do { + int status_points = 0; sd->status.base_exp -= next; //Kyoki pointed out that the max overcarry exp is the exp needed for the previous level -1. [Skotlex] if(!battle_config.multi_level_up && sd->status.base_exp > next-1) sd->status.base_exp = next-1; - next = pc->gets_status_point(sd->status.base_level); - sd->status.base_level ++; - sd->status.status_point += next; + status_points = pc->gets_status_point(sd->status.base_level); + sd->status.base_level++; + sd->status.status_point += status_points; } while ((next=pc->nextbaseexp(sd)) > 0 && sd->status.base_exp >= next); @@ -6626,7 +6624,7 @@ void pc_baselevelchanged(struct map_session_data *sd) { nullpo_retv(sd); for( i = 0; i < EQI_MAX; i++ ) { if( sd->equip_index[i] >= 0 ) { - if( sd->inventory_data[ sd->equip_index[i] ]->elvmax && sd->status.base_level > (unsigned int)sd->inventory_data[ sd->equip_index[i] ]->elvmax ) + if (sd->inventory_data[sd->equip_index[i]]->elvmax != 0 && sd->status.base_level > sd->inventory_data[ sd->equip_index[i] ]->elvmax) pc->unequipitem(sd, sd->equip_index[i], PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); } } @@ -6646,8 +6644,8 @@ int pc_checkjoblevelup(struct map_session_data *sd) if(!battle_config.multi_level_up && sd->status.job_exp > next-1) sd->status.job_exp = next-1; - sd->status.job_level ++; - sd->status.skill_point ++; + sd->status.job_level++; + sd->status.skill_point++; } while ((next=pc->nextjobexp(sd)) > 0 && sd->status.job_exp >= next); @@ -6700,7 +6698,7 @@ void pc_calcexp(struct map_session_data *sd, unsigned int *base_exp, unsigned in //PK modifier /* this doesn't exist in Aegis, instead there's a CrazyKiller check which double all EXP from this point */ - if (battle_config.pk_mode && (int)(status->get_lv(src) - sd->status.base_level) >= 20) + if (battle_config.pk_mode && status->get_lv(src) - sd->status.base_level >= 20) pk_ratio += 15; // pk_mode additional exp if monster >20 levels [Valaris] @@ -6829,12 +6827,12 @@ bool pc_gainexp(struct map_session_data *sd, struct block_list *src, unsigned in /*========================================== * Returns max level for this character. *------------------------------------------*/ -unsigned int pc_maxbaselv(struct map_session_data *sd) +int pc_maxbaselv(const struct map_session_data *sd) { return pc->max_level[pc->class2idx(sd->status.class_)][0]; } -unsigned int pc_maxjoblv(struct map_session_data *sd) +int pc_maxjoblv(const struct map_session_data *sd) { return pc->max_level[pc->class2idx(sd->status.class_)][1]; } @@ -6844,20 +6842,20 @@ unsigned int pc_maxjoblv(struct map_session_data *sd) *------------------------------------------*/ //Base exp needed for next level. -unsigned int pc_nextbaseexp(struct map_session_data *sd) +unsigned int pc_nextbaseexp(const struct map_session_data *sd) { nullpo_ret(sd); - if(sd->status.base_level>=pc->maxbaselv(sd) || sd->status.base_level<=0) + if (sd->status.base_level >= pc->maxbaselv(sd) || sd->status.base_level <= 0) return 0; return pc->exp_table[pc->class2idx(sd->status.class_)][0][sd->status.base_level-1]; } //Base exp needed for this level. -unsigned int pc_thisbaseexp(struct map_session_data *sd) +unsigned int pc_thisbaseexp(const struct map_session_data *sd) { - if(sd->status.base_level>pc->maxbaselv(sd) || sd->status.base_level<=1) + if (sd->status.base_level > pc->maxbaselv(sd) || sd->status.base_level <= 1) return 0; return pc->exp_table[pc->class2idx(sd->status.class_)][0][sd->status.base_level-2]; @@ -6871,19 +6869,19 @@ unsigned int pc_thisbaseexp(struct map_session_data *sd) *------------------------------------------*/ //Job exp needed for next level. -unsigned int pc_nextjobexp(struct map_session_data *sd) +unsigned int pc_nextjobexp(const struct map_session_data *sd) { nullpo_ret(sd); - if(sd->status.job_level>=pc->maxjoblv(sd) || sd->status.job_level<=0) + if (sd->status.job_level >= pc->maxjoblv(sd) || sd->status.job_level <= 0) return 0; return pc->exp_table[pc->class2idx(sd->status.class_)][1][sd->status.job_level-1]; } //Job exp needed for this level. -unsigned int pc_thisjobexp(struct map_session_data *sd) +unsigned int pc_thisjobexp(const struct map_session_data *sd) { - if(sd->status.job_level>pc->maxjoblv(sd) || sd->status.job_level<=1) + if (sd->status.job_level > pc->maxjoblv(sd) || sd->status.job_level <= 1) return 0; return pc->exp_table[pc->class2idx(sd->status.class_)][1][sd->status.job_level-2]; } @@ -7134,9 +7132,9 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { if (!pc_has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown clif->skillinfoblock(sd); } else if( battle_config.skillup_limit ){ - if (sd->sktree.second) + if (sd->sktree.second != 0) clif->msgtable_num(sd, MSG_SKILL_POINTS_LEFT_JOB1, sd->sktree.second); - else if (sd->sktree.third) + else if (sd->sktree.third != 0) clif->msgtable_num(sd, MSG_SKILL_POINTS_LEFT_JOB2, sd->sktree.third); else if (pc->calc_skillpoint(sd) < 9) /* TODO: official response? */ clif->messagecolor_self(sd->fd, COLOR_RED, "You need the basic skills"); @@ -7298,7 +7296,7 @@ int pc_resetstate(struct map_session_data* sd) // 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 (%u) is greater than the max level supported (%d)\n", + 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; } @@ -7722,7 +7720,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) { 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->level < pc->maxbaselv(sd) && !md->guardian_data && md->special_state.ai == AI_NONE// Guardians/summons should not level. [Skotlex] ) { // monster level up [Valaris] @@ -7989,7 +7987,7 @@ void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp) { /*========================================== * script reading pc status registry *------------------------------------------*/ -int pc_readparam(struct map_session_data* sd,int type) +int pc_readparam(const struct map_session_data *sd, int type) { int val = 0; @@ -8047,7 +8045,7 @@ int pc_readparam(struct map_session_data* sd,int type) case SP_VARCASTRATE: #endif case SP_CASTRATE: - val = sd->castrate+=val; + val = sd->castrate; break; case SP_MAXHPRATE: val = sd->hprate; break; case SP_MAXSPRATE: val = sd->sprate; break; @@ -8147,15 +8145,15 @@ int pc_setparam(struct map_session_data *sd,int type,int val) switch(type){ case SP_BASELEVEL: - if ((unsigned int)val > pc->maxbaselv(sd)) //Capping to max + if (val > pc->maxbaselv(sd)) //Capping to max val = pc->maxbaselv(sd); - if ((unsigned int)val > sd->status.base_level) { + if (val > sd->status.base_level) { int stat = 0, i; - for (i = 0; i < (int)((unsigned int)val - sd->status.base_level); i++) + for (i = 0; i < val - sd->status.base_level; i++) stat += pc->gets_status_point(sd->status.base_level + i); sd->status.status_point += stat; } - sd->status.base_level = (unsigned int)val; + sd->status.base_level = val; sd->status.base_exp = 0; // clif->updatestatus(sd, SP_BASELEVEL); // Gets updated at the bottom clif->updatestatus(sd, SP_NEXTBASEEXP); @@ -8168,12 +8166,13 @@ int pc_setparam(struct map_session_data *sd,int type,int val) } break; case SP_JOBLEVEL: - if ((unsigned int)val >= sd->status.job_level) { - if ((unsigned int)val > pc->maxjoblv(sd)) val = pc->maxjoblv(sd); + if (val >= sd->status.job_level) { + if (val > pc->maxjoblv(sd)) + val = pc->maxjoblv(sd); sd->status.skill_point += val - sd->status.job_level; clif->updatestatus(sd, SP_SKILLPOINT); } - sd->status.job_level = (unsigned int)val; + sd->status.job_level = val; sd->status.job_exp = 0; // clif->updatestatus(sd, SP_JOBLEVEL); // Gets updated at the bottom clif->updatestatus(sd, SP_NEXTJOBEXP); @@ -8492,12 +8491,12 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) // changing from 1st to 2nd job if ((b_class&JOBL_2) && !(sd->class_&JOBL_2) && (b_class&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) { sd->change_level_2nd = sd->status.job_level; - pc_setglobalreg (sd, script->add_str("jobchange_level"), sd->change_level_2nd); + pc_setglobalreg(sd, script->add_str("jobchange_level"), sd->change_level_2nd); } // changing from 2nd to 3rd job else if((b_class&JOBL_THIRD) && !(sd->class_&JOBL_THIRD)) { sd->change_level_3rd = sd->status.job_level; - pc_setglobalreg (sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); + pc_setglobalreg(sd, script->add_str("jobchange_level_3rd"), sd->change_level_3rd); } if(sd->cloneskill_id) { @@ -11051,7 +11050,7 @@ int pc_readdb(void) { while(fgets(line, sizeof(line), fp)) { int jobs[CLASS_COUNT], job_count, job, job_id; int type; - unsigned int ui,maxlv; + int maxlv; char *split[4]; if(line[0]=='/' && line[1]=='/') continue; @@ -11073,7 +11072,7 @@ int pc_readdb(void) { } maxlv = atoi(split[0]); if (maxlv > MAX_LEVEL) { - ShowWarning("pc_readdb: Specified max level %u for job %d is beyond server's limit (%d).\n ", maxlv, job_id, MAX_LEVEL); + ShowWarning("pc_readdb: Specified max level %d for job %d is beyond server's limit (%d).\n ", maxlv, job_id, MAX_LEVEL); maxlv = MAX_LEVEL; } count++; @@ -11084,15 +11083,15 @@ int pc_readdb(void) { //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. - while ((ui = pc->max_level[job][type]) >= 2 && pc->exp_table[job][type][ui-2] <= 0) + while ((i = pc->max_level[job][type]) >= 2 && pc->exp_table[job][type][i-2] <= 0) pc->max_level[job][type]--; if (pc->max_level[job][type] < maxlv) { - ShowWarning("pc_readdb: Specified max %u for job %d, but that job's exp table only goes up to level %u.\n", maxlv, job_id, pc->max_level[job][type]); + ShowWarning("pc_readdb: Specified max %d for job %d, but that job's exp table only goes up to level %d.\n", maxlv, job_id, pc->max_level[job][type]); ShowInfo("Filling the missing values with the last exp entry.\n"); //Fill the requested values with the last entry. - ui = (pc->max_level[job][type] <= 2? 0: pc->max_level[job][type]-2); - for (; ui+2 < maxlv; ui++) - pc->exp_table[job][type][ui] = pc->exp_table[job][type][ui-1]; + i = (pc->max_level[job][type] <= 2 ? 0: pc->max_level[job][type]-2); + for (; i+2 < maxlv; i++) + pc->exp_table[job][type][i] = pc->exp_table[job][type][i-1]; pc->max_level[job][type] = maxlv; } //ShowDebug("%s - Class %d: %d\n", type?"Job":"Base", job_id, pc->max_level[job][type]); @@ -11105,7 +11104,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: %d\n", type?"Job":"Base", job_id, pc->max_level[job][type]); } } fclose(fp); @@ -11233,9 +11232,9 @@ void pc_validate_levels(void) { if (i == JOB_WEDDING || i == JOB_XMAS || i == JOB_SUMMER) continue; //Classes that do not need exp tables. j = pc->class2idx(i); - if (!pc->max_level[j][0]) + if (pc->max_level[j][0] == 0) ShowWarning("Class %s (%d) does not has a base exp table.\n", pc->job_name(i), i); - if (!pc->max_level[j][1]) + if (pc->max_level[j][1] == 0) ShowWarning("Class %s (%d) does not has a job exp table.\n", pc->job_name(i), i); } } diff --git a/src/map/pc.h b/src/map/pc.h index 58f7a2266..df5416bc1 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -456,8 +456,8 @@ END_ZEROED_BLOCK; int eventtimer[MAX_EVENTTIMER]; unsigned short eventcount; // [celest] - unsigned char change_level_2nd; // job level when changing from 1st to 2nd class [jobchange_level in global_reg_value] - unsigned char change_level_3rd; // job level when changing from 2nd to 3rd class [jobchange_level_3rd in global_reg_value] + int change_level_2nd; // job level when changing from 1st to 2nd class [jobchange_level in global_reg_value] + int change_level_3rd; // job level when changing from 2nd to 3rd class [jobchange_level_3rd in global_reg_value] char fakename[NAME_LENGTH]; // fake names [Valaris] @@ -564,7 +564,7 @@ END_ZEROED_BLOCK; /* */ struct { - unsigned int second,third; + int second, third; } sktree; /** @@ -795,7 +795,7 @@ struct pc_interface { BEGIN_ZEROED_BLOCK; /* Everything within this block will be memset to 0 when status_defaults() is executed */ unsigned int exp_table[CLASS_COUNT][2][MAX_LEVEL]; - unsigned int max_level[CLASS_COUNT][2]; + int max_level[CLASS_COUNT][2]; unsigned int statp[MAX_LEVEL+1]; unsigned int level_penalty[3][RC_MAX][MAX_LEVEL*2+1]; /* */ @@ -909,15 +909,15 @@ END_ZEROED_BLOCK; /* End */ 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 (*maxbaselv) (const struct map_session_data *sd); + int (*maxjoblv) (const struct map_session_data *sd); int (*checkbaselevelup) (struct map_session_data *sd); int (*checkjoblevelup) (struct map_session_data *sd); bool (*gainexp) (struct map_session_data *sd, struct block_list *src, unsigned int base_exp, unsigned int job_exp, bool is_quest); - unsigned int (*nextbaseexp) (struct map_session_data *sd); - unsigned int (*thisbaseexp) (struct map_session_data *sd); - unsigned int (*nextjobexp) (struct map_session_data *sd); - unsigned int (*thisjobexp) (struct map_session_data *sd); + unsigned int (*nextbaseexp) (const struct map_session_data *sd); + unsigned int (*thisbaseexp) (const struct map_session_data *sd); + unsigned int (*nextjobexp) (const struct map_session_data *sd); + unsigned int (*thisjobexp) (const struct map_session_data *sd); int (*gets_status_point) (int level); int (*need_status_point) (struct map_session_data *sd,int type,int val); int (*maxparameterincrease) (struct map_session_data* sd, int type); @@ -958,7 +958,7 @@ END_ZEROED_BLOCK; /* End */ 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 (*readparam) (const 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); void (*setreg) (struct map_session_data *sd, int64 reg,int val); diff --git a/src/map/script.c b/src/map/script.c index effe40ea5..353d57a67 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11928,8 +11928,8 @@ BUILDIN(getwaitingroomstate) case 32: script_pushint(st, (cd->users >= cd->limit)); break; case 33: script_pushint(st, (cd->users >= cd->trigger)); break; - case 34: script_pushint(st, cd->minLvl); break; - case 35: script_pushint(st, cd->maxLvl); break; + case 34: script_pushint(st, cd->min_level); break; + case 35: script_pushint(st, cd->max_level); break; case 36: script_pushint(st, cd->zeny); break; default: script_pushint(st, -1); break; } diff --git a/src/map/skill.c b/src/map/skill.c index 2962cb76e..0c2f099fb 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -6891,7 +6891,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin return 1; } if( skill_id == AM_BERSERKPITCHER ) { - if( dstsd && dstsd->status.base_level < (unsigned int)sd->inventory_data[i]->elv ) { + if (dstsd && dstsd->status.base_level < sd->inventory_data[i]->elv) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); map->freeblock_unlock(); return 1; @@ -15322,7 +15322,7 @@ void skill_weaponrefine (struct map_session_data *sd, int idx) if( sd->status.class_ == JOB_MECHANIC_T ) per += 100; else - per += 5 * ((signed int)sd->status.job_level - 50); + per += 5 * (sd->status.job_level - 50); pc->delitem(sd, i, 1, 0, DELITEM_NORMAL, LOG_TYPE_REFINE); // FIXME: is this the correct reason flag? if (per > rnd() % 1000) { diff --git a/src/map/status.c b/src/map/status.c index 315f6bb19..3c3b15312 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2169,9 +2169,7 @@ int status_calc_pet_(struct pet_data *pd, enum e_status_calc_opt opt) if (battle_config.pet_lv_rate && pd->msd) { struct map_session_data *sd = pd->msd; - int lv; - - lv =sd->status.base_level*battle_config.pet_lv_rate/100; + int lv = sd->status.base_level * battle_config.pet_lv_rate / 100; if (lv < 0) lv = 1; if (lv != pd->pet.level || opt&SCO_FIRST) { @@ -2630,7 +2628,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) { // Job bonuses index = pc->class2idx(sd->status.class_); - for(i=0;i<(int)sd->status.job_level && i<MAX_LEVEL;i++){ + for (i = 0; i < sd->status.job_level && i < MAX_LEVEL; i++) { if(!status->dbs->job_bonus[index][i]) continue; switch(status->dbs->job_bonus[index][i]) { |