Prechádzať zdrojové kódy

yet another minor performance improvement. walking mobs no longer waste bandwidth by sending clif_move to nearby players if they haven't been damaged recently. (bandwidth&process time saver <3)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15857 54d463be-8e91-2dee-dedb-b68131a5f0ec
shennetsind 13 rokov pred
rodič
commit
2f7dbc7729
3 zmenil súbory, kde vykonal 7 pridanie a 4 odobranie
  1. 5 2
      src/map/mob.c
  2. 1 1
      src/map/mob.h
  3. 1 1
      src/map/unit.c

+ 5 - 2
src/map/mob.c

@@ -899,6 +899,7 @@ int mob_spawn (struct mob_data *md)
 	md->state.skillstate = MSS_IDLE;
 	md->next_walktime = tick+rnd()%5000+1000;
 	md->last_linktime = tick;
+	md->dmgtick = tick - 5000;
 	md->last_pcneartime = 0;
 
 	for (i = 0, c = tick-MOB_MAX_DELAY; i < MAX_MOBSKILL; i++)
@@ -1950,12 +1951,14 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage)
 				md->state.skillstate = MSS_RUSH;
 		}
 		//Log damage
-		if (src) mob_log_damage(md, src, damage);
+		if (src)
+			mob_log_damage(md, src, damage);
+		md->dmgtick = gettick();
 	}
 
 	if (battle_config.show_mob_info&3)
 		clif_charnameack (0, &md->bl);
-	
+
 	if (!src)
 		return;
 	

+ 1 - 1
src/map/mob.h

@@ -151,7 +151,7 @@ struct mob_data {
 	int areanpc_id; //Required in OnTouchNPC (to avoid multiple area touchs)
 	unsigned int bg_id; // BattleGround System
 
-	unsigned int next_walktime,last_thinktime,last_linktime,last_pcneartime;
+	unsigned int next_walktime,last_thinktime,last_linktime,last_pcneartime,dmgtick;
 	short move_fail_count;
 	short lootitem_count;
 	short min_chase;

+ 1 - 1
src/map/unit.c

@@ -225,7 +225,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
 
 	if(i > 0) {
 		ud->walktimer = add_timer(tick+i,unit_walktoxy_timer,id,i);
-		if( md )
+		if( md && DIFF_TICK(tick,md->dmgtick) < 3000 )//not required not damaged recently
 			clif_move(ud);
 	} else if(ud->state.running) {
 		//Keep trying to run.