diff --git a/src/char/char_mapif.cpp b/src/char/char_mapif.cpp index ef635e9b6c..cde673a6e6 100644 --- a/src/char/char_mapif.cpp +++ b/src/char/char_mapif.cpp @@ -215,14 +215,12 @@ void chmapif_send_maps(int fd, int map_id, int count, unsigned char *mapbuf) { // Transmitting the maps of the other map-servers to the new map-server for (x = 0; x < ARRAYLENGTH(map_server); x++) { if (session_isValid(map_server[x].fd) && x != map_id) { - uint16 i, j; - WFIFOHEAD(fd,10 +4*map_server[x].map.size()); WFIFOW(fd,0) = 0x2b04; WFIFOL(fd,4) = htonl(map_server[x].ip); WFIFOW(fd,8) = htons(map_server[x].port); - j = 0; - for(i = 0; i < map_server[x].map.size(); i++) + uint16 j = 0; + for(size_t i = 0; i < map_server[x].map.size(); i++) if (map_server[x].map[i]) WFIFOW(fd,10+(j++)*4) = map_server[x].map[i]; if (j > 0) { @@ -1500,7 +1498,7 @@ void chmapif_server_reset(int id){ WBUFW(buf,0) = 0x2b20; WBUFL(buf,4) = htonl(map_server[id].ip); WBUFW(buf,8) = htons(map_server[id].port); - for(uint16 i = 0; i < map_server[id].map.size(); i++) + for(size_t i = 0; i < map_server[id].map.size(); i++) if (map_server[id].map[i]) WBUFW(buf,10+(j++)*4) = map_server[id].map[i]; if (j > 0) { diff --git a/src/map/battle.cpp b/src/map/battle.cpp index 0a7ef94fa0..4ff4211571 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -8306,7 +8306,7 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i if (sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && skill_id != GN_HELLS_PLANT_ATK && !status_bl_has_mode(src,MD_STATUSIMMUNE)) { if (distance_bl(src,bl) <= 0 || !map_check_dir(map_calc_dir(bl,src->x,src->y), unit_getdir(bl))) { - int64 rd1 = min(damage, status_get_max_hp(bl)) * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage. + int64 rd1 = i64min(damage, status_get_max_hp(bl)) * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage. *dmg = rd1 * 30 / 100; // Received damage = 30% of amplified damage. clif_skill_damage(src, bl, gettick(), status_get_amotion(src), 0, -30000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, DMG_SINGLE); @@ -8349,7 +8349,7 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i rdamage = damage * sc->data[SC_MAXPAIN]->val1 * 10 / 100; } - return cap_value(min(rdamage,max_damage),INT_MIN,INT_MAX); + return cap_value(i64min(rdamage,max_damage),INT_MIN,INT_MAX); } /** diff --git a/src/map/clif.cpp b/src/map/clif.cpp index a369f4245f..889d94bafe 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -6283,7 +6283,7 @@ void clif_skill_produce_mix_list( struct map_session_data *sd, int skill_id, int int count = 0; for( int i = 0; i < MAX_SKILL_PRODUCE_DB; i++ ){ if (skill_can_produce_mix(sd,skill_produce_db[i].nameid, trigger, 1) && - (skill_id <= 0 || (skill_id > 0 && skill_produce_db[i].req_skill == skill_id)) + (skill_id <= 0 || skill_produce_db[i].req_skill == skill_id) ) { p->items[count].itemId = client_nameid( skill_produce_db[i].nameid ); @@ -20855,9 +20855,9 @@ void clif_parse_merge_item_req(int fd, struct map_session_data* sd) { } for (i = 0, j = 0; i < n; i++) { - unsigned short idx = RFIFOW(fd, info->pos[1] + i*2) - 2; + uint16 idx = server_index( RFIFOW( fd, info->pos[1] + i * 2 ) ); - if( idx < 0 || idx >= MAX_INVENTORY ){ + if( idx >= MAX_INVENTORY ){ return; } diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 5cd7c6d4e7..27f5bbbf4c 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -236,7 +236,7 @@ void mvptomb_destroy(struct mob_data *md) { struct npc_data *nd; if ( (nd = map_id2nd(md->tomb_nid)) ) { - int16 i; + int i; struct map_data *mapdata = map_getmapdata(nd->bl.m); clif_clearunit_area(&nd->bl,CLR_OUTSIGHT); diff --git a/src/map/npc.cpp b/src/map/npc.cpp index fe83f71430..8563538005 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -2638,17 +2638,17 @@ int npc_cashshop_buy(struct map_session_data *sd, t_itemid nameid, int amount, i return res; if( !pet_create_egg(sd, nameid) ) { - struct item item_tmp; - unsigned short get_amt = amount, j; + unsigned short get_amt = amount; + + struct item item_tmp = {}; - memset(&item_tmp, 0, sizeof(item_tmp)); item_tmp.nameid = nameid; item_tmp.identify = 1; if (item->flag.guid) get_amt = 1; - for (j = 0; j < amount; j += get_amt) + for (int j = 0; j < amount; j += get_amt) pc_additem(sd,&item_tmp, get_amt, LOG_TYPE_NPC); } @@ -3302,7 +3302,7 @@ e_purchase_result npc_barter_purchase( struct map_session_data& sd, std::shared_ //This doesn't remove it from map_db int npc_remove_map(struct npc_data* nd) { - int16 i; + int i; nullpo_retr(1, nd); if(nd->bl.prev == NULL || nd->bl.m < 0) diff --git a/src/map/script.cpp b/src/map/script.cpp index 2e3844f9c7..12614849d1 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -7435,7 +7435,7 @@ BUILDIN_FUNC(checkweight2) slots = pc_inventoryblank(sd); for(i=0; i= MAX_MAP_PER_SERVER) { script_pushconststr(st, ""); return SCRIPT_CMD_FAILURE; } @@ -23264,7 +23264,7 @@ BUILDIN_FUNC(mergeitem2) { if (!it || !it->unique_id || it->expire_time || !itemdb_isstackable(it->nameid)) continue; if ((!nameid || (nameid == it->nameid))) { - uint8 k; + uint16 k; if (!count) { CREATE(items, struct item, 1); memcpy(&items[count++], it, sizeof(struct item)); diff --git a/src/map/skill.cpp b/src/map/skill.cpp index f5aa78239e..595db869c4 100755 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -18457,7 +18457,7 @@ 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((int)time, 0); //ShowInfo("Castime castfix = %f\n",time); return (int)time; @@ -18643,7 +18643,7 @@ int skill_vfcastfix(struct block_list *bl, double time, uint16 skill_id, uint16 time = time * (1 - sqrt(((float)(status_get_dex(bl) * 2 + status_get_int(bl)) / battle_config.vcast_stat_scale))); time = time * (1 - (float)min(reduce_cast_rate, 100) / 100); - time = max(time, 0) + (1 - (float)min(fixcast_r, 100) / 100) * max(fixed, 0); //Underflow checking/capping + time = max((int)time, 0) + (1 - (float)min(fixcast_r, 100) / 100) * max(fixed, 0); //Underflow checking/capping return (int)time; } @@ -20326,8 +20326,8 @@ int skill_delunitgroup_(std::shared_ptr group, const char* f // remove all unit cells if(group->unit != NULL) - for( i = 0; i < group->unit_count; i++ ) - skill_delunit(&group->unit[i]); + for( int j = 0; j < group->unit_count; j++ ) + skill_delunit(&group->unit[j]); // clear Talkie-box string if( group->valstr != NULL ) { @@ -22236,7 +22236,7 @@ int skill_blockpc_start(struct map_session_data *sd, int skill_id, t_tick tick) sd->scd[i]->skill_id = skill_id; sd->scd[i]->timer = add_timer(gettick() + tick, skill_blockpc_end, sd->bl.id, i); - if (battle_config.display_status_timers && tick > 0) + if (battle_config.display_status_timers) clif_skill_cooldown(sd, skill_id, tick); return 1; @@ -24383,7 +24383,7 @@ static bool skill_parse_row_changematerialdb(char* split[], int columns, int cur } // Clear previous data, for importing support - if (id < ARRAYLENGTH(skill_changematerial_db) && skill_changematerial_db[id].nameid > 0) { + if (skill_changematerial_db[id].nameid > 0) { found = true; memset(&skill_changematerial_db[id], 0, sizeof(skill_changematerial_db[id])); }