Explorar el Código

Replaced occurences of '-1' with the more appropriate 'INVALID_TIMER' value where appropriate.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12998 54d463be-8e91-2dee-dedb-b68131a5f0ec
ultramage hace 17 años
padre
commit
6c8cf8d611
Se han modificado 11 ficheros con 71 adiciones y 70 borrados
  1. 1 1
      src/char_sql/int_auction.c
  2. 1 1
      src/map/atcommand.c
  3. 1 1
      src/map/guild.c
  4. 3 3
      src/map/map.c
  5. 3 3
      src/map/mercenary.c
  6. 5 5
      src/map/mob.c
  7. 9 9
      src/map/pc.c
  8. 7 7
      src/map/pet.c
  9. 12 12
      src/map/script.c
  10. 15 14
      src/map/skill.c
  11. 14 14
      src/map/unit.c

+ 1 - 1
src/char_sql/int_auction.c

@@ -151,7 +151,7 @@ static int auction_end_timer(int tid, unsigned int tick, int id, intptr data)
 		
 		ShowInfo("Auction End: id %u.\n", auction->auction_id);
 
-		auction->auction_end_timer = -1;
+		auction->auction_end_timer = INVALID_TIMER;
 		auction_delete(auction);
 	}
 

+ 1 - 1
src/map/atcommand.c

@@ -1924,7 +1924,7 @@ static int atcommand_pvpoff_sub(struct block_list *bl,va_list ap)
 	clif_pvpset(sd, 0, 0, 2);
 	if (sd->pvp_timer != -1) {
 		delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
-		sd->pvp_timer = -1;
+		sd->pvp_timer = INVALID_TIMER;
 	}
 	return 0;
 }

+ 1 - 1
src/map/guild.c

@@ -63,7 +63,7 @@ struct{
 
 // timer for auto saving guild data during WoE
 #define GUILD_SAVE_INTERVAL 300000
-int guild_save_timer = -1;
+int guild_save_timer = INVALID_TIMER;
 
 int guild_payexp_timer(int tid, unsigned int tick, int id, intptr data);
 int guild_save_sub(int tid, unsigned int tick, int id, intptr data);

+ 3 - 3
src/map/map.c

@@ -2070,7 +2070,7 @@ void map_spawnmobs(int m)
 	if (map[m].mob_delete_timer != -1)
 	{	//Mobs have not been removed yet [Skotlex]
 		delete_timer(map[m].mob_delete_timer, map_removemobs_timer);
-		map[m].mob_delete_timer = -1;
+		map[m].mob_delete_timer = INVALID_TIMER;
 		return;
 	}
 	for(i=0; i<MAX_MOB_LIST_PER_MAP; i++)
@@ -2122,7 +2122,7 @@ int map_removemobs_timer(int tid, unsigned int tick, int id, intptr data)
 		ShowError("map_removemobs_timer mismatch: %d != %d (map %s)\n",map[m].mob_delete_timer, tid, map[m].name);
 		return 0;
 	}
-	map[m].mob_delete_timer = -1;
+	map[m].mob_delete_timer = INVALID_TIMER;
 	if (map[m].users > 0) //Map not empty!
 		return 1;
 
@@ -2738,7 +2738,7 @@ int map_readallmaps (void)
 
 		map[i].m = i;
 		memset(map[i].moblist, 0, sizeof(map[i].moblist));	//Initialize moblist [Skotlex]
-		map[i].mob_delete_timer = -1;	//Initialize timer [Skotlex]
+		map[i].mob_delete_timer = INVALID_TIMER;	//Initialize timer [Skotlex]
 		if(battle_config.pk_mode)
 			map[i].flag.pvp = 1; // make all maps pvp for pk_mode [Valaris]
 

+ 3 - 3
src/map/mercenary.c

@@ -496,7 +496,7 @@ static int merc_hom_hungry(int tid, unsigned int tick, int id, intptr data)
 		return 0;
 	}
 
-	hd->hungry_timer = -1;
+	hd->hungry_timer = INVALID_TIMER;
 	
 	hd->homunculus.hunger-- ;
 	if(hd->homunculus.hunger <= 10) {
@@ -525,7 +525,7 @@ int merc_hom_hungry_timer_delete(struct homun_data *hd)
 	nullpo_retr(0, hd);
 	if(hd->hungry_timer != -1) {
 		delete_timer(hd->hungry_timer,merc_hom_hungry);
-		hd->hungry_timer = -1;
+		hd->hungry_timer = INVALID_TIMER;
 	}
 	return 1;
 }
@@ -634,7 +634,7 @@ int merc_hom_alloc(struct map_session_data *sd, struct s_homunculus *hom)
 	map_addiddb(&hd->bl);
 	status_calc_homunculus(hd,1);
 
-	hd->hungry_timer = -1;
+	hd->hungry_timer = INVALID_TIMER;
 	return 0;
 }
 

+ 5 - 5
src/map/mob.c

@@ -228,7 +228,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data)
 
 	if(md->db->status.mode&MD_LOOTER)
 		md->lootitem = (struct item *)aCalloc(LOOTITEM_SIZE,sizeof(struct item));
-	md->deletetimer = -1;
+	md->deletetimer = INVALID_TIMER;
 	md->skillidx = -1;
 	status_set_viewdata(&md->bl, md->class_);
 	status_change_init(&md->bl);
@@ -1007,7 +1007,7 @@ int mob_spawn (struct mob_data *md)
 	md->attacked_id = 0;
 	md->target_id = 0;
 	md->move_fail_count = 0;
-	md->spawn_timer = -1;
+	md->spawn_timer = INVALID_TIMER;
 
 //	md->master_id = 0;
 	md->master_dist = 0;
@@ -1903,8 +1903,8 @@ int mob_timer_delete(int tid, unsigned int tick, int id, intptr data)
 	nullpo_retr(0, bl);
 	if (bl->type != BL_MOB)
 		return 0; //??
-//for Alchemist CANNIBALIZE [Lupus]
-	((TBL_MOB*)bl)->deletetimer = -1;
+	//for Alchemist CANNIBALIZE [Lupus]
+	((TBL_MOB*)bl)->deletetimer = INVALID_TIMER;
 	unit_free(bl,3);
 	return 0;
 }
@@ -2579,7 +2579,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 
 	if(md->deletetimer!=-1) {
 		delete_timer(md->deletetimer,mob_timer_delete);
-		md->deletetimer=-1;
+		md->deletetimer = INVALID_TIMER;
 	}
 
 	mob_deleteslave(md);

+ 9 - 9
src/map/pc.c

@@ -126,7 +126,7 @@ static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr data)
 		ShowError("invincible_timer %d != %d\n",sd->invincible_timer,tid);
 		return 0;
 	}
-	sd->invincible_timer=-1;
+	sd->invincible_timer = INVALID_TIMER;
 	skill_unit_move(&sd->bl,tick,1);
 
 	return 0;
@@ -734,10 +734,10 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
 	if(!sd->status.hp) pc_setdead(sd);
 	sd->state.connect_new = 1;
 
-	sd->followtimer = -1; // [MouseJstr]
-	sd->invincible_timer = -1;
+	sd->followtimer = INVALID_TIMER; // [MouseJstr]
+	sd->invincible_timer = INVALID_TIMER;
 	sd->npc_timer_id = -1;
-	sd->pvp_timer = -1;
+	sd->pvp_timer = INVALID_TIMER;
 	
 	sd->canuseitem_tick = tick;
 	sd->cantalk_tick = tick;
@@ -4114,11 +4114,11 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr data)
 
 	if (sd->followtimer != tid){
 		ShowError("pc_follow_timer %d != %d\n",sd->followtimer,tid);
-		sd->followtimer = -1;
+		sd->followtimer = INVALID_TIMER;
 		return 0;
 	}
 
-	sd->followtimer = -1;
+	sd->followtimer = INVALID_TIMER;
 	if (pc_isdead(sd))
 		return 0;
 
@@ -4149,9 +4149,9 @@ int pc_stop_following (struct map_session_data *sd)
 {
 	nullpo_retr(0, sd);
 
-	if (sd->followtimer != -1) {
+	if (sd->followtimer != INVALID_TIMER) {
 		delete_timer(sd->followtimer,pc_follow_timer);
-		sd->followtimer = -1;
+		sd->followtimer = INVALID_TIMER;
 	}
 	sd->followtarget = -1;
 
@@ -6697,7 +6697,7 @@ int pc_calc_pvprank_timer(int tid, unsigned int tick, int id, intptr data)
 	sd=map_id2sd(id);
 	if(sd==NULL)
 		return 0;
-	sd->pvp_timer = -1;
+	sd->pvp_timer = INVALID_TIMER;
 	if( pc_calc_pvprank(sd) > 0 )
 		sd->pvp_timer = add_timer(gettick()+PVP_CALCRANK_INTERVAL,pc_calc_pvprank_timer,id,data);
 	return 0;

+ 7 - 7
src/map/pet.c

@@ -246,7 +246,7 @@ static int pet_hungry(int tid, unsigned int tick, int id, intptr data)
 		ShowError("pet_hungry_timer %d != %d\n",pd->pet_hungry_timer,tid);
 		return 0;
 	}
-	pd->pet_hungry_timer = -1;
+	pd->pet_hungry_timer = INVALID_TIMER;
 
 	if (pd->pet.intimate <= 0)
 		return 1; //You lost the pet already, the rest is irrelevant.
@@ -303,7 +303,7 @@ int pet_hungry_timer_delete(struct pet_data *pd)
 	nullpo_retr(0, pd);
 	if(pd->pet_hungry_timer != -1) {
 		delete_timer(pd->pet_hungry_timer,pet_hungry);
-		pd->pet_hungry_timer = -1;
+		pd->pet_hungry_timer = INVALID_TIMER;
 	}
 
 	return 1;
@@ -751,12 +751,12 @@ static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd)
 				delete_timer(pd->s_skill->timer, pet_skill_support_timer);
 			else
 				delete_timer(pd->s_skill->timer, pet_heal_timer);
-			pd->s_skill->timer = -1;
+			pd->s_skill->timer = INVALID_TIMER;
 		}
 		if (pd->bonus && pd->bonus->timer != -1)
 		{
 			delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
-			pd->bonus->timer = -1;
+			pd->bonus->timer = INVALID_TIMER;
 		}
 	}
 
@@ -1088,7 +1088,7 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr data)
 
 	if(pd->bonus->timer != tid) {
 		ShowError("pet_skill_bonus_timer %d != %d\n",pd->bonus->timer,tid);
-		pd->bonus->timer = -1;
+		pd->bonus->timer = INVALID_TIMER;
 		return 0;
 	}
 	
@@ -1100,7 +1100,7 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr data)
 		bonus = 1;
 		timer = pd->bonus->duration*1000;	// the duration for pet bonuses to be in effect
 	} else { //Lost pet...
-		pd->bonus->timer = -1;
+		pd->bonus->timer = INVALID_TIMER;
 		return 0;
 	}
 
@@ -1139,7 +1139,7 @@ int pet_recovery_timer(int tid, unsigned int tick, int id, intptr data)
 		clif_emotion(&pd->bl, 33);
 	}
 
-	pd->recovery->timer = -1;
+	pd->recovery->timer = INVALID_TIMER;
 	
 	return 0;
 }

+ 12 - 12
src/map/script.c

@@ -3043,7 +3043,7 @@ int run_script_timer(int tid, unsigned int tick, int id, intptr data)
 	while( node && st->sleep.timer != -1 ) {
 		if( (int)node->key == st->oid && ((struct script_state *)node->data)->sleep.timer == st->sleep.timer ) {
 			script_erase_sleepdb(node);
-			st->sleep.timer = -1;
+			st->sleep.timer = INVALID_TIMER;
 			break;
 		}
 		node = node->next;
@@ -9187,7 +9187,7 @@ static int buildin_pvpoff_sub(struct block_list *bl,va_list ap)
 	clif_pvpset(sd, 0, 0, 2);
 	if (sd->pvp_timer != -1) {
 		delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
-		sd->pvp_timer = -1;
+		sd->pvp_timer = INVALID_TIMER;
 	}
 	return 0;
 }
@@ -10244,9 +10244,9 @@ BUILDIN_FUNC(petskillbonus)
 
 	// wait for timer to start
 	if (battle_config.pet_equip_required && pd->pet.equip == 0)
-		pd->bonus->timer=-1;
+		pd->bonus->timer = INVALID_TIMER;
 	else
-		pd->bonus->timer=add_timer(gettick()+pd->bonus->delay*1000, pet_skill_bonus_timer, sd->bl.id, 0);
+		pd->bonus->timer = add_timer(gettick()+pd->bonus->delay*1000, pet_skill_bonus_timer, sd->bl.id, 0);
 
 	return 0;
 }
@@ -10521,9 +10521,9 @@ BUILDIN_FUNC(petrecovery)
 	} else //Init
 		pd->recovery = (struct pet_recovery *)aMalloc(sizeof(struct pet_recovery));
 		
-	pd->recovery->type=(sc_type)script_getnum(st,2);
-	pd->recovery->delay=script_getnum(st,3);
-	pd->recovery->timer=-1;
+	pd->recovery->type = (sc_type)script_getnum(st,2);
+	pd->recovery->delay = script_getnum(st,3);
+	pd->recovery->timer = INVALID_TIMER;
 
 	return 0;
 }
@@ -10561,9 +10561,9 @@ BUILDIN_FUNC(petheal)
 
 	//Use delay as initial offset to avoid skill/heal exploits
 	if (battle_config.pet_equip_required && pd->pet.equip == 0)
-		pd->s_skill->timer=-1;
+		pd->s_skill->timer = INVALID_TIMER;
 	else
-		pd->s_skill->timer=add_timer(gettick()+pd->s_skill->delay*1000,pet_heal_timer,sd->bl.id,0);
+		pd->s_skill->timer = add_timer(gettick()+pd->s_skill->delay*1000,pet_heal_timer,sd->bl.id,0);
 
 	return 0;
 }
@@ -10654,9 +10654,9 @@ BUILDIN_FUNC(petskillsupport)
 
 	//Use delay as initial offset to avoid skill/heal exploits
 	if (battle_config.pet_equip_required && pd->pet.equip == 0)
-		pd->s_skill->timer=-1;
+		pd->s_skill->timer = INVALID_TIMER;
 	else
-		pd->s_skill->timer=add_timer(gettick()+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0);
+		pd->s_skill->timer = add_timer(gettick()+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0);
 
 	return 0;
 }
@@ -13114,7 +13114,7 @@ BUILDIN_FUNC(awake)
 
 			delete_timer(tst->sleep.timer, run_script_timer);
 			node = script_erase_sleepdb(node);
-			tst->sleep.timer = -1;
+			tst->sleep.timer = INVALID_TIMER;
 			tst->sleep.tick = 0;
 			run_script_main(tst);
 		}

+ 15 - 14
src/map/skill.c

@@ -5244,7 +5244,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr data)
 	md = BL_CAST(BL_MOB, src);
 
 	if( src->prev == NULL ) {
-		ud->skilltimer = -1;
+		ud->skilltimer = INVALID_TIMER;
 		return 0;
 	}
 
@@ -5252,17 +5252,17 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr data)
 	{// otherwise handled in unit_skillcastcancel()
 		if( ud->skilltimer != tid ) {
 			ShowError("skill_castend_id: Timer mismatch %d!=%d!\n", ud->skilltimer, tid);
-			ud->skilltimer = -1;
+			ud->skilltimer = INVALID_TIMER;
 			return 0;
 		}
 
 		if( sd && ud->skilltimer != -1 && pc_checkskill(sd,SA_FREECAST) > 0 )
 		{// restore original walk speed
-			ud->skilltimer = -1;
+			ud->skilltimer = INVALID_TIMER;
 			status_calc_bl(&sd->bl, SCB_SPEED);
 		}
 
-		ud->skilltimer = -1;
+		ud->skilltimer = INVALID_TIMER;
 	}
 
 	if (ud->skilltarget == id)
@@ -5475,23 +5475,23 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr data)
 	md = BL_CAST(BL_MOB, src);
 
 	if( src->prev == NULL ) {
-		ud->skilltimer = -1;
+		ud->skilltimer = INVALID_TIMER;
 		return 0;
 	}
 	
 	if( ud->skilltimer != tid )
 	{
 		ShowError("skill_castend_pos: Timer mismatch %d!=%d\n", ud->skilltimer, tid);
-		ud->skilltimer = -1;
+		ud->skilltimer = INVALID_TIMER;
 		return 0;
 	}
 
 	if( sd && ud->skilltimer != -1 && pc_checkskill(sd,SA_FREECAST) > 0 )
 	{// restore original walk speed
-		ud->skilltimer=-1;
+		ud->skilltimer = INVALID_TIMER;
 		status_calc_bl(&sd->bl, SCB_SPEED);
 	}
-	ud->skilltimer=-1;
+	ud->skilltimer = INVALID_TIMER;
 
 	do {
 		if(status_isdead(src))
@@ -7822,12 +7822,13 @@ int skill_check_condition(struct map_session_data* sd, short skill, short lv, in
 				return 0; //Can't repeat previous combo skill.				
 			}
 			break;
-		} else 
-		if(sc->data[SC_COMBO]->val1 == skill)
-			break; //Combo ready.
-		//Cancel combo wait.
-		unit_cancel_combo(&sd->bl);
-		return 0;
+		}
+		if(sc->data[SC_COMBO]->val1 != skill)
+		{	//Cancel combo wait.
+			unit_cancel_combo(&sd->bl);
+			return 0;
+		}
+		break; //Combo ready.
 	case BD_ADAPTATION:
 		{
 			int time;

+ 14 - 14
src/map/unit.c

@@ -124,7 +124,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr data)
 		ShowError("unit_walk_timer mismatch %d != %d\n",ud->walktimer,tid);
 		return 0;
 	}
-	ud->walktimer=-1;
+	ud->walktimer = INVALID_TIMER;
 	if( bl->prev == NULL ) return 0; // block_list から抜けているので移動停止する
 
 	if(ud->walkpath.path_pos>=ud->walkpath.path_len)
@@ -156,9 +156,9 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr data)
 	if (bl->x != x || bl->y != y || ud->walktimer != -1)
 		return 0; //map_moveblock has altered the object beyond what we expected (moved/warped it)
 
-	ud->walktimer = 1;
+	ud->walktimer = 1; //FIXME: why '1'? [ultramage]
 	map_foreachinmovearea(clif_insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl);
-	ud->walktimer = -1;
+	ud->walktimer = INVALID_TIMER;
 	
 	if(sd) {
 		if(map_getcell(bl->m,x,y,CELL_CHKNPC)) {
@@ -315,7 +315,7 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
 
 	if(ud->attacktimer != -1) {
 		delete_timer( ud->attacktimer, unit_attack_timer );
-		ud->attacktimer = -1;
+		ud->attacktimer = INVALID_TIMER;
 	}
 
 	return unit_walktoxy_sub(bl);
@@ -391,7 +391,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
 
 	if(ud->attacktimer != -1) {
 		delete_timer( ud->attacktimer, unit_attack_timer );
-		ud->attacktimer = -1;
+		ud->attacktimer = INVALID_TIMER;
 	}
 
 	if (unit_walktoxy_sub(bl)) {
@@ -512,9 +512,9 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
 
 	map_moveblock(bl, dst_x, dst_y, gettick());
 	
-	ud->walktimer = 1;
+	ud->walktimer = 1; //FIXME: why '1'? [ultramage]
 	map_foreachinmovearea(clif_insight, bl, AREA_SIZE, -dx, -dy, sd?BL_ALL:BL_PC, bl);
-	ud->walktimer = -1;
+	ud->walktimer = INVALID_TIMER;
 		
 	if(sd) {
 		if(map_getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) {
@@ -656,7 +656,7 @@ int unit_stop_walking(struct block_list *bl,int type)
 	//behaviour changes in the future, this code could break!
 	td = get_timer(ud->walktimer);
 	delete_timer(ud->walktimer, unit_walktoxy_timer);
-	ud->walktimer = -1;
+	ud->walktimer = INVALID_TIMER;
 	ud->state.change_walk_target = 0;
 	tick = gettick();
 	if ((type&0x02 && !ud->walkpath.path_pos) //Force moving at least one cell.
@@ -1193,7 +1193,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, sh
 			unit_stop_walking(src,1);
 	}
 	else {
-		ud->skilltimer = -1;
+		ud->skilltimer = INVALID_TIMER;
 		skill_castend_pos(ud->skilltimer,tick,src->id,0);
 	}
 	return 1;
@@ -1210,7 +1210,7 @@ int unit_stop_attack(struct block_list *bl)
 		return 0;
 
 	delete_timer( ud->attacktimer, unit_attack_timer );
-	ud->attacktimer = -1;
+	ud->attacktimer = INVALID_TIMER;
 	ud->target = 0;
 	return 0;
 }
@@ -1384,7 +1384,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
 	}
 	sd = BL_CAST(BL_PC, src);
 	md = BL_CAST(BL_MOB, src);
-	ud->attacktimer=-1;
+	ud->attacktimer = INVALID_TIMER;
 	target=map_id2bl(ud->target);
 
 	if(src == NULL || src->prev == NULL || target==NULL || target->prev == NULL)
@@ -1534,7 +1534,7 @@ int unit_skillcastcancel(struct block_list *bl,int type)
 	if(ret<0)
 		ShowError("delete timer error : skillid : %d\n",ret);
 
-	ud->skilltimer = -1;
+	ud->skilltimer = INVALID_TIMER;
 
 	if( sd && pc_checkskill(sd,SA_FREECAST) > 0 )
 		status_calc_bl(&sd->bl, SCB_SPEED);
@@ -1711,7 +1711,7 @@ int unit_remove_map_(struct block_list *bl, int clrtype, const char* file, int l
 
 		if(sd->pvp_timer!=-1) {
 			delete_timer(sd->pvp_timer,pc_calc_pvprank_timer);
-			sd->pvp_timer = -1;
+			sd->pvp_timer = INVALID_TIMER;
 			sd->pvp_rank = 0;
 		}
 		if(sd->duel_group > 0)
@@ -1935,7 +1935,7 @@ int unit_free(struct block_list *bl, int clrtype)
 		struct mob_data *md = (struct mob_data*)bl;
 		if(md->deletetimer!=-1) {
 			delete_timer(md->deletetimer,mob_timer_delete);
-			md->deletetimer=-1;
+			md->deletetimer = INVALID_TIMER;
 		}
 		if(md->lootitem) {
 			aFree(md->lootitem);