فهرست منبع

static_cast<int> => static_cast<int32> (#8958)

Lemongrass3110 3 ماه پیش
والد
کامیت
296a98c6fc
13فایلهای تغییر یافته به همراه42 افزوده شده و 42 حذف شده
  1. 1 1
      src/common/socket.cpp
  2. 1 1
      src/common/strlib.cpp
  3. 2 2
      src/common/utilities.cpp
  4. 9 9
      src/map/battle.cpp
  5. 3 3
      src/map/battleground.cpp
  6. 2 2
      src/map/instance.cpp
  7. 1 1
      src/map/map.cpp
  8. 3 3
      src/map/npc.cpp
  9. 10 10
      src/map/pc.cpp
  10. 5 5
      src/map/script.cpp
  11. 1 1
      src/map/skill.cpp
  12. 1 1
      src/map/status.cpp
  13. 3 3
      src/map/unit.cpp

+ 1 - 1
src/common/socket.cpp

@@ -1696,7 +1696,7 @@ void send_shortlist_add_fd(int32 fd)
 // Do pending network sends and eof handling from the shortlist.
 void send_shortlist_do_sends()
 {
-	for( int32 i = static_cast<int>( send_shortlist_count - 1 ); i >= 0; --i ){
+	for( int32 i = static_cast<int32>( send_shortlist_count - 1 ); i >= 0; --i ){
 		int32 fd = send_shortlist_array[i];
 		int32 idx = fd/32;
 		int32 bit = fd%32;

+ 1 - 1
src/common/strlib.cpp

@@ -908,7 +908,7 @@ bool sv_readdb( const char* directory, const char* filename, char delim, size_t
 	line = (char*)aMalloc(nb_cols*colsize);
 
 	// process rows one by one
-	while( fgets( line, static_cast<int>( maxcols * colsize ), fp ) ){
+	while( fgets( line, static_cast<int32>( maxcols * colsize ), fp ) ){
 		char *match;
 		lines++;
 

+ 2 - 2
src/common/utilities.cpp

@@ -44,8 +44,8 @@ int32 levenshtein(const std::string &s1, const std::string &s2)
 {
 	// To change the type this function manipulates and returns, change
 	// the return type and the types of the two variables below.
-	int32 s1len = static_cast<int>(s1.size());
-	int32 s2len = static_cast<int>(s2.size());
+	int32 s1len = static_cast<int32>(s1.size());
+	int32 s2len = static_cast<int32>(s2.size());
 	
 	auto column_start = (decltype(s1len))1;
 	

+ 9 - 9
src/map/battle.cpp

@@ -1231,7 +1231,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe
 
 	// SC Types that must be first because they may or may not block damage
 	if ((sce = sc->getSCE(SC_KYRIE)) && damage > 0) {
-		sce->val2 -= static_cast<int>(cap_value(damage, INT_MIN, INT_MAX));
+		sce->val2 -= static_cast<int32>(cap_value(damage, INT_MIN, INT_MAX));
 		if (flag & BF_WEAPON || skill_id == TF_THROWSTONE) {
 			if (sce->val2 >= 0)
 				damage = 0;
@@ -1319,7 +1319,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe
 
 	if ((sce = sc->getSCE(SC_P_ALTER)) && damage > 0) {
 		clif_specialeffect(target, EF_GUARD, AREA);
-		sce->val3 -= static_cast<int>(cap_value(damage, INT_MIN, INT_MAX));
+		sce->val3 -= static_cast<int32>(cap_value(damage, INT_MIN, INT_MAX));
 		if (sce->val3 >= 0)
 			damage = 0;
 		else
@@ -1329,7 +1329,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe
 	}
 
 	if ((sce = sc->getSCE(SC_TUNAPARTY)) && damage > 0) {
-		sce->val2 -= static_cast<int>(cap_value(damage, INT_MIN, INT_MAX));
+		sce->val2 -= static_cast<int32>(cap_value(damage, INT_MIN, INT_MAX));
 		if (sce->val2 >= 0)
 			damage = 0;
 		else
@@ -1339,14 +1339,14 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe
 	}
 
 	if ((sce = sc->getSCE(SC_DIMENSION1)) && damage > 0) {
-		sce->val2 -= static_cast<int>(cap_value(damage, INT_MIN, INT_MAX));
+		sce->val2 -= static_cast<int32>(cap_value(damage, INT_MIN, INT_MAX));
 		if (sce->val2 <= 0)
 			status_change_end(target, SC_DIMENSION1);
 		return false;
 	}
 
 	if ((sce = sc->getSCE(SC_DIMENSION2)) && damage > 0) {
-		sce->val2 -= static_cast<int>(cap_value(damage, INT_MIN, INT_MAX));
+		sce->val2 -= static_cast<int32>(cap_value(damage, INT_MIN, INT_MAX));
 		if (sce->val2 <= 0)
 			status_change_end(target, SC_DIMENSION2);
 		return false;
@@ -1354,7 +1354,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe
 
 	if ((sce = sc->getSCE(SC_GUARDIAN_S)) && damage > 0) {
 		clif_specialeffect(target, EF_GUARD3, AREA);// Not official but we gotta show some way the barrier is working. [Rytech]
-		sce->val2 -= static_cast<int>(cap_value(damage, INT_MIN, INT_MAX));
+		sce->val2 -= static_cast<int32>(cap_value(damage, INT_MIN, INT_MAX));
 		if (flag & BF_WEAPON) {
 			if (sce->val2 >= 0)
 				damage = 0;
@@ -1391,7 +1391,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe
 				}
 #ifdef RENEWAL
 				if (group->val3 - damage > 0)
-					group->val3 -= static_cast<int>(cap_value(damage, INT_MIN, INT_MAX));
+					group->val3 -= static_cast<int32>(cap_value(damage, INT_MIN, INT_MAX));
 				else
 					skill_delunitgroup(group);
 #endif
@@ -1402,7 +1402,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe
 					break;
 				}
 				if (group->val3 - damage > 0)
-					group->val3 -= static_cast<int>(cap_value(damage, INT_MIN, INT_MAX));
+					group->val3 -= static_cast<int32>(cap_value(damage, INT_MIN, INT_MAX));
 				else
 					skill_delunitgroup(group);
 				break;
@@ -1446,7 +1446,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe
 	}
 
 	if ((sce = sc->getSCE(SC_MILLENNIUMSHIELD)) && sce->val2 > 0 && damage > 0) {
-		sce->val3 -= static_cast<int>(cap_value(damage, INT_MIN, INT_MAX)); // absorb damage
+		sce->val3 -= static_cast<int32>(cap_value(damage, INT_MIN, INT_MAX)); // absorb damage
 		d->dmg_lv = ATK_BLOCK;
 		if (sce->val3 <= 0) { // Shield Down
 			sce->val2--;

+ 3 - 3
src/map/battleground.cpp

@@ -612,7 +612,7 @@ int32 bg_team_leave(map_session_data *sd, bool quit, bool deserter)
 				sc_start(nullptr, &sd->bl, SC_ENTRY_QUEUE_NOTIFY_ADMISSION_TIME_OUT, 100, 1, static_cast<t_tick>(bg->deserter_time) * 1000); // Deserter timer
 		}
 
-		return static_cast<int>( bgteam->members.size() );
+		return static_cast<int32>( bgteam->members.size() );
 	}
 
 	return -1;
@@ -1395,7 +1395,7 @@ void bg_join_active(map_session_data *sd, std::shared_ptr<s_battleground_queue>
 
 	pc_delete_bg_queue_timer(sd); // Cancel timer so player doesn't leave the queue.
 
-	int32 bg_id_team_1 = static_cast<int>(mapreg_readreg(add_str(queue->map->team1.bg_id_var.c_str())));
+	int32 bg_id_team_1 = static_cast<int32>(mapreg_readreg(add_str(queue->map->team1.bg_id_var.c_str())));
 	std::shared_ptr<s_battleground_data> bgteam_1 = util::umap_find(bg_team_db, bg_id_team_1);
 
 	for (auto &pl_sd : queue->teama_members) {
@@ -1415,7 +1415,7 @@ void bg_join_active(map_session_data *sd, std::shared_ptr<s_battleground_queue>
 		return;
 	}
 
-	int32 bg_id_team_2 = static_cast<int>(mapreg_readreg(add_str(queue->map->team2.bg_id_var.c_str())));
+	int32 bg_id_team_2 = static_cast<int32>(mapreg_readreg(add_str(queue->map->team2.bg_id_var.c_str())));
 	std::shared_ptr<s_battleground_data> bgteam_2 = util::umap_find(bg_team_db, bg_id_team_2);
 
 	for (auto &pl_sd : queue->teamb_members) {

+ 2 - 2
src/map/instance.cpp

@@ -807,8 +807,8 @@ void instance_generate_mapname(int32 map_id, int32 instance_id, char outname[MAP
 	static const int32 prefix_length = 4;
 	// Full map name length - prefix length - seperator character - zero termination
 	static const int32 suffix_length = MAP_NAME_LENGTH - prefix_length - 1 - 1;
-	static const int32 prefix_limit = static_cast<int>(pow(10, prefix_length));
-	static const int32 suffix_limit = static_cast<int>(pow(10, suffix_length));
+	static const int32 prefix_limit = static_cast<int32>(pow(10, prefix_length));
+	static const int32 suffix_limit = static_cast<int32>(pow(10, suffix_length));
 	safesnprintf(outname, MAP_NAME_LENGTH, "%0*u#%0*u", prefix_length, map_id % prefix_limit, suffix_length, instance_id % suffix_limit);
 }
 

+ 1 - 1
src/map/map.cpp

@@ -2873,7 +2873,7 @@ int32 map_addmobtolist(unsigned short m, struct spawn_data *spawn)
 	if( i < MAX_MOB_LIST_PER_MAP )
 	{
 		mapdata->moblist[i] = spawn;
-		return static_cast<int>(i);
+		return static_cast<int32>(i);
 	}
 	return -1;
 }

+ 3 - 3
src/map/npc.cpp

@@ -2626,7 +2626,7 @@ void npc_shop_currency_type(map_session_data *sd, struct npc_data *nd, int32 cos
 				clif_broadcast(&sd->bl, output, strlen(output) + 1, BC_BLUE,SELF);
 			}
 			
-			cost[0] = static_cast<int>(pc_readreg2(sd, nd->u.shop.pointshop_str));
+			cost[0] = static_cast<int32>(pc_readreg2(sd, nd->u.shop.pointshop_str));
 			break;
 	}
 }
@@ -3738,13 +3738,13 @@ int32 npc_parseview(const char* w4, const char* start, const char* buffer, const
 		if(!script_get_constant(viewid, &val_tmp)) {
 			std::shared_ptr<s_mob_db> mob = mobdb_search_aegisname(viewid);
 			if (mob != nullptr)
-				val = static_cast<int>(mob->id);
+				val = static_cast<int32>(mob->id);
 			else {
 				ShowWarning("npc_parseview: Invalid NPC constant '%s' specified in file '%s', line'%d'. Defaulting to INVISIBLE. \n", viewid, filepath, strline(buffer,start-buffer));
 				val = JT_INVISIBLE;
 			}
 		} else
-			val = static_cast<int>(val_tmp);
+			val = static_cast<int32>(val_tmp);
 	}
 
 	return val;

+ 10 - 10
src/map/pc.cpp

@@ -2293,15 +2293,15 @@ void pc_reg_received(map_session_data *sd)
 	sd->change_level_2nd = static_cast<unsigned char>(pc_readglobalreg(sd, add_str(JOBCHANGE2ND_VAR)));
 	sd->change_level_3rd = static_cast<unsigned char>(pc_readglobalreg(sd, add_str(JOBCHANGE3RD_VAR)));
 	sd->change_level_4th = static_cast<unsigned char>(pc_readglobalreg(sd, add_str(JOBCHANGE4TH_VAR)));
-	sd->die_counter = static_cast<int>(pc_readglobalreg(sd, add_str(PCDIECOUNTER_VAR)));
+	sd->die_counter = static_cast<int32>(pc_readglobalreg(sd, add_str(PCDIECOUNTER_VAR)));
 
-	sd->langtype = static_cast<int>(pc_readaccountreg(sd, add_str(LANGTYPE_VAR)));
+	sd->langtype = static_cast<int32>(pc_readaccountreg(sd, add_str(LANGTYPE_VAR)));
 	if (msg_checklangtype(sd->langtype,true) < 0)
 		sd->langtype = 0; //invalid langtype reset to default
 
 	// Cash shop
-	sd->cashPoints = static_cast<int>(pc_readaccountreg(sd, add_str(CASHPOINT_VAR)));
-	sd->kafraPoints = static_cast<int>(pc_readaccountreg(sd, add_str(KAFRAPOINT_VAR)));
+	sd->cashPoints = static_cast<int32>(pc_readaccountreg(sd, add_str(CASHPOINT_VAR)));
+	sd->kafraPoints = static_cast<int32>(pc_readaccountreg(sd, add_str(KAFRAPOINT_VAR)));
 
 	// Cooking Exp
 	sd->cook_mastery = static_cast<short>(pc_readglobalreg(sd, add_str(COOKMASTERY_VAR)));
@@ -2313,12 +2313,12 @@ void pc_reg_received(map_session_data *sd)
 	}
 
 	if (battle_config.feature_banking)
-		sd->bank_vault = static_cast<int>(pc_readreg2(sd, BANK_VAULT_VAR));
+		sd->bank_vault = static_cast<int32>(pc_readreg2(sd, BANK_VAULT_VAR));
 
 	if (battle_config.feature_roulette) {
-		sd->roulette_point.bronze = static_cast<int>(pc_readreg2(sd, ROULETTE_BRONZE_VAR));
-		sd->roulette_point.silver = static_cast<int>(pc_readreg2(sd, ROULETTE_SILVER_VAR));
-		sd->roulette_point.gold = static_cast<int>(pc_readreg2(sd, ROULETTE_GOLD_VAR));
+		sd->roulette_point.bronze = static_cast<int32>(pc_readreg2(sd, ROULETTE_BRONZE_VAR));
+		sd->roulette_point.silver = static_cast<int32>(pc_readreg2(sd, ROULETTE_SILVER_VAR));
+		sd->roulette_point.gold = static_cast<int32>(pc_readreg2(sd, ROULETTE_GOLD_VAR));
 	}
 	sd->roulette.prizeIdx = -1;
 
@@ -14133,7 +14133,7 @@ static bool pc_readdb_job_noenter_map( char *str[], size_t columns, size_t curre
 			ShowError("pc_readdb_job_noenter_map: Invalid job %s specified.\n", str[0]);
 			return false;
 		}
-		class_ = static_cast<int>(class_tmp);
+		class_ = static_cast<int32>(class_tmp);
 	}
 
 	if (!pcdb_checkid(class_)) {
@@ -15307,7 +15307,7 @@ int32 pc_attendance_counter( map_session_data* sd ){
 	}
 
 	// Get the counter for the current period
-	int32 counter = static_cast<int>(pc_readreg2( sd, ATTENDANCE_COUNT_VAR ));
+	int32 counter = static_cast<int32>(pc_readreg2( sd, ATTENDANCE_COUNT_VAR ));
 
 	// Check if we have a remaining counter from a previous period
 	if( counter > 0 && pc_readreg2( sd, ATTENDANCE_DATE_VAR ) < period->start ){

+ 5 - 5
src/map/script.cpp

@@ -1689,7 +1689,7 @@ const char* parse_syntax(const char* p)
 					//Check for constants
 					p2 = skip_word(p);
 					v = (int32)(size_t) (p2-p); // length of word at p2
-					memcpy(label,p,static_cast<int>(v));
+					memcpy(label,p,static_cast<int32>(v));
 					label[v]='\0';
 					if( !script_get_constant(label, &v) )
 						disp_error_message("parse_syntax: 'case' label is not an integer",p);
@@ -3439,7 +3439,7 @@ int64 conv_num64(struct script_state* st, struct script_data* data)
 
 int32 conv_num(struct script_state* st, struct script_data* data)
 {
-	return static_cast<int>(conv_num_(st, data, nullptr));
+	return static_cast<int32>(conv_num_(st, data, nullptr));
 }
 
 //
@@ -8819,7 +8819,7 @@ BUILDIN_FUNC(readparam)
 		get_val_(st, data, sd);
 		value = (int32)data->u.num;
 	}else{
-		value = static_cast<int>(pc_readparam(sd,script_getnum(st, 2)));
+		value = static_cast<int32>(pc_readparam(sd,script_getnum(st, 2)));
 	}
 
 	script_pushint(st,value);
@@ -14742,7 +14742,7 @@ BUILDIN_FUNC(setiteminfo)
 		case ITEMINFO_BUY: i_data->value_buy = static_cast<uint32>(value); break;
 		case ITEMINFO_SELL: i_data->value_sell = static_cast<uint32>(value); break;
 		case ITEMINFO_TYPE: i_data->type = static_cast<item_types>(value); break;
-		case ITEMINFO_MAXCHANCE: i_data->maxchance = static_cast<int>(value); break;
+		case ITEMINFO_MAXCHANCE: i_data->maxchance = static_cast<int32>(value); break;
 		case ITEMINFO_GENDER: i_data->sex = static_cast<uint8>(value); break;
 		case ITEMINFO_LOCATIONS: i_data->equip = static_cast<uint32>(value); break;
 		case ITEMINFO_WEIGHT: i_data->weight = static_cast<uint32>(value); break;
@@ -21459,7 +21459,7 @@ BUILDIN_FUNC(bg_info)
 			size_t i;
 
 			for( i = 0; i < bg->maps.size(); i++ ){
-				setd_sub_str( st, nullptr, ".@bgmaps$", static_cast<int>( i ), mapindex_id2name( bg->maps[i].mapindex ), nullptr );
+				setd_sub_str( st, nullptr, ".@bgmaps$", static_cast<int32>( i ), mapindex_id2name( bg->maps[i].mapindex ), nullptr );
 			}
 
 			setd_sub_num(st, nullptr, ".@bgmapscount", 0, i, nullptr);

+ 1 - 1
src/map/skill.cpp

@@ -20750,7 +20750,7 @@ int32 skill_clear_group(block_list *bl, uint8 flag)
 		}
 	}
 
-	return static_cast<int>(count);
+	return static_cast<int32>(count);
 }
 
 /**

+ 1 - 1
src/map/status.cpp

@@ -500,7 +500,7 @@ uint64 SizeFixDatabase::parseBodyNode(const ryml::NodeRef& node) {
 		return 0;
 	}
 
-	int32 weapon_id = static_cast<int>(constant);
+	int32 weapon_id = static_cast<int32>(constant);
 	std::shared_ptr<s_sizefix_db> size = this->find(weapon_id);
 	bool exists = size != nullptr;
 

+ 3 - 3
src/map/unit.cpp

@@ -213,7 +213,7 @@ TIMER_FUNC(unit_teleport_timer){
 	else {
 		map_session_data* msd = unit_get_master( bl );
 
-		if( msd != nullptr && !check_distance_bl( &msd->bl, bl, static_cast<int>( data ) ) ){
+		if( msd != nullptr && !check_distance_bl( &msd->bl, bl, static_cast<int32>( data ) ) ){
 			*mast_tid = INVALID_TIMER;
 			unit_warp(bl, msd->bl.m, msd->bl.x, msd->bl.y, CLR_TELEPORT );
 		} else // No timer needed
@@ -711,7 +711,7 @@ TIMER_FUNC(unit_delay_walktoxy_timer){
  */
 TIMER_FUNC(unit_delay_walktobl_timer){
 	block_list* bl = map_id2bl( id );
-	block_list* tbl = map_id2bl( static_cast<int>( data ) );
+	block_list* tbl = map_id2bl( static_cast<int32>( data ) );
 
 	if(!bl || bl->prev == nullptr || tbl == nullptr)
 		return 0;
@@ -3849,7 +3849,7 @@ void unit_addshadowscar(unit_data &ud, int32 interval) {
 
 	if (sc != nullptr) {
 		if (sc->getSCE(SC_SHADOW_SCAR) != nullptr) {
-			sc->getSCE(SC_SHADOW_SCAR)->val1 = static_cast<int>(ud.shadow_scar_timer.size());
+			sc->getSCE(SC_SHADOW_SCAR)->val1 = static_cast<int32>(ud.shadow_scar_timer.size());
 		} else {
 			sc_start(ud.bl, ud.bl, SC_SHADOW_SCAR, 100, 1, INFINITE_TICK);
 		}