Selaa lähdekoodia

Minor cleanups, mostly reducing scopes.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15504 54d463be-8e91-2dee-dedb-b68131a5f0ec
xazax-hun 13 vuotta sitten
vanhempi
commit
d4cae50fe1
12 muutettua tiedostoa jossa 37 lisäystä ja 35 poistoa
  1. 1 2
      src/char/char.c
  2. 0 1
      src/map/atcommand.c
  3. 2 2
      src/map/clif.c
  4. 1 2
      src/map/instance.c
  5. 2 2
      src/map/mob.c
  6. 1 1
      src/map/party.c
  7. 4 3
      src/map/pc.c
  8. 2 1
      src/map/pet.c
  9. 5 3
      src/map/script.c
  10. 7 8
      src/map/skill.c
  11. 8 6
      src/map/status.c
  12. 4 4
      src/map/unit.c

+ 1 - 2
src/char/char.c

@@ -3992,9 +3992,8 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len)
 
 int mapif_send(int fd, unsigned char *buf, unsigned int len)
 {
-	int i;
-
 	if (fd >= 0) {
+		int i;
 		ARR_FIND( 0, ARRAYLENGTH(server), i, fd == server[i].fd );
 		if( i < ARRAYLENGTH(server) )
 		{

+ 0 - 1
src/map/atcommand.c

@@ -183,7 +183,6 @@ ACMD_FUNC(send)
 {
 	int len=0,off,end,type;
 	long num;
-	(void)command; // not used
 
 	// read message type as hex number (without the 0x)
 	if(!message || !*message ||

+ 2 - 2
src/map/clif.c

@@ -4423,7 +4423,7 @@ int clif_outsight(struct block_list *bl,va_list ap)
 	if (sd && sd->fd)
 	{	//sd is watching tbl go out of view.
 		if (((vd=status_get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) &&
-			!(bl->type == BL_NPC && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE)))
+			!(tbl->type == BL_NPC && (((TBL_NPC*)tbl)->sc.option&OPTION_INVISIBLE)))
 			clif_clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd);
 	}
 	return 0;
@@ -10652,7 +10652,6 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
  *------------------------------------------*/
 static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, short skilllv, short skillnum, short x, short y, int skillmoreinfo)
 {
-	int lv;
 	unsigned int tick = gettick();
 
 	if( !(skill_get_inf(skillnum)&INF_GROUND_SKILL) )
@@ -10716,6 +10715,7 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, sho
 	}
 	else
 	{
+		int lv;
 		sd->skillitem = sd->skillitemlv = 0;
 		if( (lv = pc_checkskill(sd, skillnum)) > 0 )
 		{

+ 1 - 2
src/map/instance.c

@@ -260,14 +260,13 @@ int instance_del_load(struct map_session_data* sd, va_list args)
  *--------------------------------------*/
 void instance_del_map(int m)
 {
-	int sm, i;
+	int i;
 	if( m <= 0 || !map[m].instance_id )
 	{
 		ShowError("Tried to remove non-existing instance map (%d)\n", m);
 		return;
 	}
 
-	sm = map[m].instance_src_map;
 	map_foreachpc(instance_del_load, m);
 	map_foreachinmap(cleanup_sub, m, BL_ALL);
 

+ 2 - 2
src/map/mob.c

@@ -1113,7 +1113,6 @@ static int mob_warpchase_sub(struct block_list *bl,va_list ap)
 static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
 {
 	struct block_list *bl;
-	int old_dist;
 
 	bl=map_id2bl(md->master_id);
 
@@ -1126,7 +1125,8 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
 
 	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.
 		old_dist=md->master_dist;
 		md->master_dist=distance_bl(&md->bl, bl);

+ 1 - 1
src/map/party.c

@@ -560,10 +560,10 @@ int party_member_withdraw(int party_id, int account_id, int char_id)
 {
 	struct map_session_data* sd = map_id2sd(account_id);
 	struct party_data* p = party_search(party_id);
-	int i;
 
 	if( p )
 	{
+		int i;
 		ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id );
 		if( i < MAX_PARTY )
 		{

+ 4 - 3
src/map/pc.c

@@ -8541,9 +8541,6 @@ int pc_readdb(void)
 // Read MOTD on startup. [Valaris]
 int pc_read_motd(void)
 {
-	char* buf, * ptr;
-	unsigned int lines = 0, entries = 0;
-	size_t len;
 	FILE* fp;
 
 	// clear old MOTD
@@ -8552,6 +8549,10 @@ int pc_read_motd(void)
 	// read current MOTD
 	if( ( fp = fopen(motd_txt, "r") ) != NULL )
 	{
+		char* buf, * ptr;
+		unsigned int lines = 0, entries = 0;
+		size_t len;
+
 		while( entries < MOTD_LINE_SIZE && fgets(motd_text[entries], sizeof(motd_text[entries]), fp) )
 		{
 			lines++;

+ 2 - 1
src/map/pet.c

@@ -101,7 +101,6 @@ int pet_unlocktarget(struct pet_data *pd)
 int pet_attackskill(struct pet_data *pd, int target_id)
 {
 	struct block_list *bl;
-	int inf;
 
 	if (!battle_config.pet_status_support || !pd->a_skill || 
 		(battle_config.pet_equip_required && !pd->pet.equip))
@@ -112,6 +111,8 @@ int pet_attackskill(struct pet_data *pd, int target_id)
 	
 	if (rnd()%100 < (pd->a_skill->rate +pd->pet.intimate*pd->a_skill->bonusrate/1000))
 	{	//Skotlex: Use pet's skill 
+		int inf;
+
 		bl=map_id2bl(target_id);
 		if(bl == NULL || pd->bl.m != bl->m || bl->prev == NULL || status_isdead(bl) ||
 			!check_distance_bl(&pd->bl, bl, pd->db->range3))

+ 5 - 3
src/map/script.c

@@ -3878,7 +3878,6 @@ int script_reload()
 /// mes "<message>";
 BUILDIN_FUNC(mes)
 {
-	int i;
 	TBL_PC* sd = script_rid2sd(st);
 	if( sd == NULL )
 		return 0;
@@ -3889,6 +3888,8 @@ BUILDIN_FUNC(mes)
 	}
 	else
 	{// parse multiple lines as they exist
+		int i;
+
 		for( i = 2; script_hasdata(st, i); i++ )
 		{
 			// send the message to the client
@@ -11817,10 +11818,11 @@ BUILDIN_FUNC(getmercinfo)
 BUILDIN_FUNC(checkequipedcard)
 {
 	TBL_PC *sd=script_rid2sd(st);
-	int n,i,c=0;
-	c=script_getnum(st,2);
 
 	if(sd){
+		int n,i,c=0;
+		c=script_getnum(st,2);
+
 		for(i=0;i<MAX_INVENTORY;i++){
 			if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount && sd->inventory_data[i]){
 				if (itemdb_isspecial(sd->status.inventory[i].card[0]))

+ 7 - 8
src/map/skill.c

@@ -8329,7 +8329,6 @@ int skill_castend_pos2(struct block_list* src, int x, int y, int skillid, int sk
 	// Plant Cultivation [Celest]
 	case CR_CULTIVATION:
 		if (sd) {
-			int i;
 			if( map_count_oncell(src->m,x,y,BL_CHAR) > 0 )
 			{
 				clif_skill_fail(sd,skillid,USESKILL_FAIL_LEVEL,0);
@@ -8340,6 +8339,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, int skillid, int sk
 				clif_skill_fail(sd,skillid,USESKILL_FAIL_LEVEL,0);
 			} else {
 				TBL_MOB* md = mob_once_spawn_sub(src, src->m, x, y, "--ja--",(skilllv < 2 ? 1084+rnd()%2 : 1078+rnd()%6),"");
+				int i;
 				if (!md) break;
 				if ((i = skill_get_time(skillid, skilllv)) > 0)
 				{
@@ -11096,7 +11096,6 @@ int skill_check_condition_castend(struct map_session_data* sd, short skill, shor
 // type&1: consume the others (before skill was used)
 int skill_consume_requirement( struct map_session_data *sd, short skill, short lv, short type)
 {
-	int n,i;
 	struct skill_condition req;
 
 	nullpo_ret(sd);
@@ -11126,6 +11125,7 @@ int skill_consume_requirement( struct map_session_data *sd, short skill, short l
 	if( type&2 )
 	{
 		struct status_change *sc = &sd->sc;
+		int n,i;
 
 		if( !sc->count )
 			sc = NULL;
@@ -11752,14 +11752,13 @@ void skill_identify (struct map_session_data *sd, int idx)
  *------------------------------------------*/
 void skill_weaponrefine (struct map_session_data *sd, int idx)
 {
-	int i = 0, ep = 0, per;
-	int material[5] = { 0, 1010, 1011, 984, 984 };
-	struct item *item;
-
 	nullpo_retv(sd);
 
 	if (idx >= 0 && idx < MAX_INVENTORY)
 	{
+		int i = 0, ep = 0, per;
+		int material[5] = { 0, 1010, 1011, 984, 984 };
+		struct item *item;
 		struct item_data *ditem = sd->inventory_data[idx];
 		item = &sd->status.inventory[idx];
 
@@ -12384,11 +12383,11 @@ bool skill_check_cloaking(struct block_list *bl, struct status_change_entry *sce
 	static int dx[] = { 0, 1, 0, -1, -1,  1, 1, -1};
 	static int dy[] = {-1, 0, 1,  0, -1, -1, 1,  1};
 	bool wall = true;
-	int i;
 
 	if( (bl->type == BL_PC && battle_config.pc_cloak_check_type&1)
 	||	(bl->type != BL_PC && battle_config.monster_cloak_check_type&1) )
 	{	//Check for walls.
+		int i;
 		ARR_FIND( 0, 8, i, map_getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 );
 		if( i == 8 )
 			wall = false;
@@ -12424,10 +12423,10 @@ bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *s
 	static int dx[] = { 0, 1, 0, -1, -1,  1, 1, -1};
 	static int dy[] = {-1, 0, 1,  0, -1, -1, 1,  1};
 	bool wall = true;
-	int i;
 
 	if( bl->type == BL_PC )
 	{	//Check for walls.
+		int i;
 		ARR_FIND( 0, 8, i, map_getcell(bl->m, bl->x+dx[i], bl->y+dy[i], CELL_CHKNOPASS) != 0 );
 		if( i == 8 )
 			wall = false;

+ 8 - 6
src/map/status.c

@@ -6380,17 +6380,19 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
 		case SC_DEFENDER:
 			if (!(flag&1))
 			{	
-				struct map_session_data *tsd;
-				int i;
 				val2 = 5 + 15*val1; //Damage reduction
 				val3 = 0; // unused, previously speed adjustment
 				val4 = 250 - 50*val1; //Aspd adjustment 
 
 				if (sd)
-				for (i = 0; i < 5; i++)
-				{	//See if there are devoted characters, and pass the status to them. [Skotlex]
-					if (sd->devotion[i] && (tsd = map_id2sd(sd->devotion[i])))
-						status_change_start(&tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,1);
+				{
+					struct map_session_data *tsd;
+					int i;
+					for (i = 0; i < 5; i++)
+					{	//See if there are devoted characters, and pass the status to them. [Skotlex]
+						if (sd->devotion[i] && (tsd = map_id2sd(sd->devotion[i])))
+							status_change_start(&tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,1);
+					}
 				}
 			}
 			break;

+ 4 - 4
src/map/unit.c

@@ -665,12 +665,12 @@ uint8 unit_getdir(struct block_list *bl)
 //  &1  Do not send position update packets.
 int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
 {
-	int nx, ny, result;
-	struct map_session_data* sd;
-	struct skill_unit* su = NULL;
-
 	if(count)
 	{
+		struct map_session_data* sd;
+		struct skill_unit* su = NULL;
+		int nx, ny, result;
+				
 		sd = BL_CAST(BL_PC, bl);
 		su = BL_CAST(BL_SKILL, bl);