Browse Source

- Some cleaning of the pc_eventtimer and pc enqueue code, it should fix some memory leaks when the event counter does not matches with the actual number of queued timers during logout.
- Minor typos, corrections, etc.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9072 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 18 years ago
parent
commit
c4932353bf
6 changed files with 29 additions and 29 deletions
  1. 3 0
      Changelog-Trunk.txt
  2. 3 1
      conf-tmpl/battle/battle.conf
  3. 1 1
      conf-tmpl/battle/skill.conf
  4. 0 1
      src/map/log.c
  5. 2 2
      src/map/npc.c
  6. 20 24
      src/map/pc.c

+ 3 - 0
Changelog-Trunk.txt

@@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
 2006/10/25
 2006/10/25
+	* Some cleaning of the pc_eventtimer and pc enqueue code, it should fix
+	  some memory leaks when the event counter does not matches with the actual
+	  number of queued timers during logout. [Skotlex]
 	* Fixed "skill_sp_override_grffile: yes" causing crashes when parsing
 	* Fixed "skill_sp_override_grffile: yes" causing crashes when parsing
 	  Homuncuus/Guild skills. [Skotlex]
 	  Homuncuus/Guild skills. [Skotlex]
 	* Made the exp bonus settings be adjustable: [Skotlex]
 	* Made the exp bonus settings be adjustable: [Skotlex]

+ 3 - 1
conf-tmpl/battle/battle.conf

@@ -141,7 +141,9 @@ vit_penalty_count_lv: 3
 attack_direction_change: 15
 attack_direction_change: 15
 
 
 // For those who is set, attacks of Neutral element will not get any elemental
 // For those who is set, attacks of Neutral element will not get any elemental
-// modifiers (they will hit for full damage on Ghost types) (Note 4)
+// adjustment (100% versus on all defense-elements) (Note 4)
+// NOTE: This is the setting that makes it so non-players can hit for full
+// damage against Ghost-type targets (eg: Ghostring wearing players).
 attack_attr_none: 14
 attack_attr_none: 14
 
 
 // Rate at which equipment can break (base rate before it's modified by any skills)
 // Rate at which equipment can break (base rate before it's modified by any skills)

+ 1 - 1
conf-tmpl/battle/skill.conf

@@ -132,7 +132,7 @@ traps_setting: 0
 
 
 // Restrictions applied to the Alchemist's Summon Flora skill (add as necessary)
 // Restrictions applied to the Alchemist's Summon Flora skill (add as necessary)
 // 1: Enable players to damage the floras outside of versus grounds.
 // 1: Enable players to damage the floras outside of versus grounds.
-// 3: Disable having different types out at the same time
+// 2: Disable having different types out at the same time
 //    (eg: forbid summoning anything except hydras when there's already 
 //    (eg: forbid summoning anything except hydras when there's already 
 //     one hydra out)
 //     one hydra out)
 summon_flora_setting: 3
 summon_flora_setting: 3

+ 0 - 1
src/map/log.c

@@ -212,7 +212,6 @@ int log_pick_mob(struct mob_data *md, const char *type, int nameid, int amount,
 	return 1; //Logged
 	return 1; //Logged
 }
 }
 
 
-
 int log_zeny(struct map_session_data *sd, char *type, struct map_session_data *src_sd, int amount)
 int log_zeny(struct map_session_data *sd, char *type, struct map_session_data *src_sd, int amount)
 {
 {
 //	FILE *logfp;
 //	FILE *logfp;

+ 2 - 2
src/map/npc.c

@@ -182,8 +182,8 @@ int npc_event_dequeue(struct map_session_data *sd)
 			// clear the last event
 			// clear the last event
 			sd->eventqueue[MAX_EVENTQUEUE-1][0]=0;
 			sd->eventqueue[MAX_EVENTQUEUE-1][0]=0;
 			// add the timer
 			// add the timer
-			sd->eventtimer[ev]=add_timer(gettick()+100,pc_eventtimer,sd->bl.id,(int)name);//!!todo!!
-
+			sd->eventtimer[ev]=add_timer(gettick()+100,pc_eventtimer,sd->bl.id,(int)name);//TODO: Someone wrote here "!!todo!!", but what the hell is missing?
+			sd->eventcount++;
 		}else
 		}else
 			ShowWarning("npc_event_dequeue: event timer is full !\n");
 			ShowWarning("npc_event_dequeue: event timer is full !\n");
 	}
 	}

+ 20 - 24
src/map/pc.c

@@ -6139,19 +6139,16 @@ int pc_eventtimer(int tid,unsigned int tick,int id,int data)
 	if(sd==NULL)
 	if(sd==NULL)
 		return 0;
 		return 0;
 
 
-	for(i=0;i < MAX_EVENTTIMER;i++){
-		if( sd->eventtimer[i]==tid ){
-			sd->eventtimer[i]=-1;
-			npc_event(sd,p,0);
-			break;
-		}
-	}
-	if (p) aFree(p);
-	if(i==MAX_EVENTTIMER) {
-		if(battle_config.error_log)
-			ShowError("pc_eventtimer: no such event timer\n");
-	}
+	for(i=0;i < MAX_EVENTTIMER && sd->eventtimer[i]!=tid; i++);
+
+	if(i < MAX_EVENTTIMER){
+		sd->eventtimer[i]=-1;
+		npc_event(sd,p,0);
+		sd->eventcount--;
+	} else if(battle_config.error_log)
+		ShowError("pc_eventtimer: no such event timer\n");
 
 
+	if (p) aFree(p);
 	return 0;
 	return 0;
 }
 }
 
 
@@ -6162,20 +6159,19 @@ int pc_eventtimer(int tid,unsigned int tick,int id,int data)
 int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name)
 int pc_addeventtimer(struct map_session_data *sd,int tick,const char *name)
 {
 {
 	int i;
 	int i;
+	char *evname;
 
 
 	nullpo_retr(0, sd);
 	nullpo_retr(0, sd);
 
 
-	for(i=0;i<MAX_EVENTTIMER;i++)
-		if( sd->eventtimer[i]==-1 )
-			break;
-	if(i<MAX_EVENTTIMER){
-		char *evname = aStrdup(name);
-		//char *evname=(char *)aMallocA((strlen(name)+1)*sizeof(char));
-		//memcpy(evname,name,(strlen(name)+1));
-		sd->eventtimer[i]=add_timer(gettick()+tick,
-			pc_eventtimer,sd->bl.id,(int)evname);
-		sd->eventcount++;
-	}
+	for(i=0;i<MAX_EVENTTIMER && sd->eventtimer[i]!=-1;i++);
+	
+	if(i==MAX_EVENTTIMER)
+		return 0;
+
+	evname = aStrdup(name);
+	sd->eventtimer[i]=add_timer(gettick()+tick,
+		pc_eventtimer,sd->bl.id,(int)evname);
+	sd->eventcount++;
 
 
 	return 0;
 	return 0;
 }
 }
@@ -6246,9 +6242,9 @@ int pc_cleareventtimer(struct map_session_data *sd)
 			char *p = (char *)(get_timer(sd->eventtimer[i])->data);
 			char *p = (char *)(get_timer(sd->eventtimer[i])->data);
 			delete_timer(sd->eventtimer[i],pc_eventtimer);
 			delete_timer(sd->eventtimer[i],pc_eventtimer);
 			sd->eventtimer[i]=-1;
 			sd->eventtimer[i]=-1;
+			sd->eventcount--;
 			if (p) aFree(p);
 			if (p) aFree(p);
 		}
 		}
-
 	return 0;
 	return 0;
 }
 }