Просмотр исходного кода

* Removed code in socket.c that tries to avoid send buffer overloading, as there is a scenario (many players and charserver disconnect) where mass char saving produces huge ammounts of data to send (see r11503)
* Cleaned up player respawning code (bugreport:1022)
* Increased the max amount of different autocast skills from 5 to 10
* Added a missing function declaration, for real this time (followup to r12229)

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

ultramage 17 лет назад
Родитель
Сommit
f4347446d4
7 измененных файлов с 51 добавлено и 62 удалено
  1. 5 0
      Changelog-Trunk.txt
  2. 1 1
      npc/Changelog.txt
  3. 0 12
      src/common/socket.c
  4. 6 12
      src/map/clif.c
  5. 1 0
      src/map/clif.h
  6. 1 1
      src/map/map.h
  7. 37 36
      src/map/pc.c

+ 5 - 0
Changelog-Trunk.txt

@@ -4,6 +4,11 @@ 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.
 
 2008/02/22
+	* Removed code in socket.c that tries to avoid send buffer overloading,
+	  as there is a scenario (many players and charserver disconnect) where
+	  mass char saving produces huge ammounts of data to send (see r11503)
+	* Cleaned up player respawning code (bugreport:1022)
+	* Increased the max amount of different autocast skills from 5 to 10
 	* Fixed @whomap not unlocking the player db (bug in r12204) [ultramage]
 	* Added $(CUSTOM_CFLAGS) into all Makefile.in to provide any custom defs
 	  directly to all sub make files. How to use:

+ 1 - 1
npc/Changelog.txt

@@ -8,7 +8,7 @@ Date		Added
 	- Added Dimensional Gorge map spawns (According to RO Future Wiki)
 	- Updated Lighthalzen boss spawning mechanisim to official.
 	- Fixed a small error in the novice potion exchanger.
-	- Resolves the following: bugreport:879 bugreport:973 bugreport:983
+	- Resolves the following: bugreport:897 bugreport:973 bugreport:983
 	- bugreport:1013 bugreport:1021 bugreport:1024 bugreport:1026
 2008/02/21
 	* Fixed Hugel Airship Staff from teleporting you to the wrong airplane. [Paradox924X]

+ 0 - 12
src/common/socket.c

@@ -528,7 +528,6 @@ static int create_session(int fd, RecvFunc func_recv, SendFunc func_send, ParseF
 	session[fd]->func_send  = func_send;
 	session[fd]->func_parse = func_parse;
 	session[fd]->rdata_tick = last_tick;
-	session[fd]->session_data = NULL;
 	return 0;
 }
 
@@ -584,17 +583,6 @@ int realloc_writefifo(int fd, size_t addition)
 	else // no change
 		return 0;
 
-	// crash prevention for bugs that cause the send queue to fill up in an infinite loop
-	if( newsize > 5*1024*1024 ) // 5 MB is way beyond reasonable
-	{
-		ShowError("realloc_writefifo: session #%d's send buffer was overloaded! Disconnecting...\n", fd);
-		// drop all data (but the space will still be available)
-		session[fd]->wdata_size = 0;
-		// request disconnect
-		set_eof(fd);
-		return 0;
-	}
-
 	RECREATE(session[fd]->wdata, unsigned char, newsize);
 	session[fd]->max_wdata  = newsize;
 

+ 6 - 12
src/map/clif.c

@@ -642,8 +642,8 @@ int clif_clearflooritem(struct flooritem_data *fitem, int fd)
  * id  : the id of the unit
  * type: 0 - moved out of sight
  *       1 - died
- *       2 - logged out
- *       3 - teleported / winged away
+ *       2 - respawned
+ *       3 - teleported / logged out
  * fd  : the target client
  *------------------------------------------*/
 int clif_clearunit_single(int id, uint8 type, int fd)
@@ -661,8 +661,8 @@ int clif_clearunit_single(int id, uint8 type, int fd)
  * make a unit (char, npc, mob, homun) disappear to all clients in area
  * type: 0 - moved out of sight
  *       1 - died
- *       2 - logged out
- *       3 - teleported / winged away
+ *       2 - respawned
+ *       3 - teleported / logged out
  *------------------------------------------*/
 int clif_clearunit_area(struct block_list* bl, uint8 type)
 {
@@ -7187,8 +7187,7 @@ int clif_charnameack (int fd, struct block_list *bl)
 				if (battle_config.show_mob_info&1)
 					str_p += sprintf(str_p, "HP: %u/%u | ", md->status.hp, md->status.max_hp);
 				if (battle_config.show_mob_info&2)
-					str_p += sprintf(str_p, "HP: %d%% | ", 
-						status_calc_life(md->status.hp, md->status.max_hp));
+					str_p += sprintf(str_p, "HP: %d%% | ", status_calc_life(md->status.hp, md->status.max_hp));
 				//Even thought mobhp ain't a name, we send it as one so the client
 				//can parse it. [Skotlex]
 				if (str_p != mobhp) {
@@ -8362,12 +8361,7 @@ void clif_parse_Restart(int fd, struct map_session_data *sd)
 {
 	switch(RFIFOB(fd,2)) {
 	case 0x00:
-		if (!pc_isdead(sd))
-			break;
-		pc_setstand(sd);
-		pc_setrestartvalue(sd, 3);
-		if (pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 2))
-			clif_resurrection(&sd->bl, 1); //If warping fails, send a normal stand up packet.
+		pc_respawn(sd,2);
 		break;
 	case 0x01:
 		/*	Rovert's Prevent logout option - Fixed [Valaris]	*/

+ 1 - 0
src/map/clif.h

@@ -295,6 +295,7 @@ int clif_hpmeter(struct map_session_data *sd);
 // guild
 int clif_guild_created(struct map_session_data *sd,int flag);
 int clif_guild_belonginfo(struct map_session_data *sd,struct guild *g);
+int clif_guild_masterormember(struct map_session_data *sd);
 int clif_guild_basicinfo(struct map_session_data *sd);
 int clif_guild_allianceinfo(struct map_session_data *sd);
 int clif_guild_memberlist(struct map_session_data *sd);

+ 1 - 1
src/map/map.h

@@ -674,7 +674,7 @@ struct map_session_data {
 	struct s_autoscript {
 		unsigned short rate, flag;
 		struct script_code *script;
-	} autoscript[5], autoscript2[5]; //Auto script on attack, when attacked
+	} autoscript[10], autoscript2[10]; //Auto script on attack, when attacked
 	// manually zeroed structures end here.
 	// zeroed vars start here.
 	int arrow_atk,arrow_ele,arrow_cri,arrow_hit;

+ 37 - 36
src/map/pc.c

@@ -4735,17 +4735,21 @@ int pc_skillheal_bonus(struct map_session_data *sd, int skill_num)
 	return 0;
 }
 
-static int pc_respawn(int tid,unsigned int tick,int id,int data)
+void pc_respawn(struct map_session_data* sd, uint8 clrtype)
 {
-	struct map_session_data *sd = map_id2sd(id);
-	if (sd && pc_isdead(sd))
-	{	//Auto-respawn [Skotlex]
-		pc_setstand(sd);
-		pc_setrestartvalue(sd,3);
-		if(pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0))
-			clif_resurrection(&sd->bl, 1); //If warping fails, send a normal stand up packet.
+	if( !pc_isdead(sd) )
+		return; // not applicable
 
-	}
+	pc_setstand(sd);
+	pc_setrestartvalue(sd,3);
+	if(pc_setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, clrtype))
+		clif_resurrection(&sd->bl, 1); //If warping fails, send a normal stand up packet.
+}
+
+static int pc_respawn_timer(int tid,unsigned int tick,int id,int data)
+{
+	struct map_session_data *sd = map_id2sd(id);
+	pc_respawn(sd,0);
 	return 0;
 }
 
@@ -5064,13 +5068,13 @@ int pc_dead(struct map_session_data *sd,struct block_list *src)
 		}
 		if( sd->pvp_point < 0 ){
 			sd->pvp_point=0;
-			add_timer(tick+1000, pc_respawn,sd->bl.id,0);
+			add_timer(tick+1000, pc_respawn_timer,sd->bl.id,0);
 			return 1;
 		}
 	}
 	//GvG
 	if(map_flag_gvg(sd->bl.m)){
-		add_timer(tick+1000, pc_respawn,sd->bl.id,0);
+		add_timer(tick+1000, pc_respawn_timer,sd->bl.id,0);
 		return 1;
 	}
 
@@ -6806,42 +6810,39 @@ int pc_setsavepoint(struct map_session_data *sd, short mapindex,int x,int y)
 	return 0;
 }
 
-/*==========================================
- * 自動セ?ブ 各クライアント
- *------------------------------------------*/
-static int last_save_id=0,save_flag=0;
-static int pc_autosave_sub(DBKey key,void * data,va_list ap)
-{
-	struct map_session_data *sd = (TBL_PC*)data;
-	
-	if(sd->bl.id == last_save_id && save_flag != 1) {
-		save_flag = 1;
-		return 1;
-	}
-
-	if(save_flag != 1) //Not our turn to save yet.
-		return 0;
-
-	//Save char.
-	last_save_id = sd->bl.id;
-	save_flag=2;
-
-	chrif_save(sd,0);
-	return 1;
-}
-
 /*==========================================
  * 自動セ?ブ (timer??)
  *------------------------------------------*/
 int pc_autosave(int tid,unsigned int tick,int id,int data)
 {
 	int interval;
+	struct s_mapiterator* iter;
+	struct map_session_data* sd;
+	static int last_save_id = 0, save_flag = 0;
 
 	if(save_flag == 2) //Someone was saved on last call, normal cycle
 		save_flag = 0;
 	else
 		save_flag = 1; //Noone was saved, so save first found char.
-	map_foreachpc(pc_autosave_sub);
+
+	iter = mapit_getallusers();
+	for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
+	{
+		if(sd->bl.id == last_save_id) {
+			save_flag = 1;
+			continue;
+		}
+
+		if(save_flag != 1) //Not our turn to save yet.
+			continue;
+
+		//Save char.
+		last_save_id = sd->bl.id;
+		save_flag = 2;
+
+		chrif_save(sd,0);
+	}
+	mapit_free(iter);
 
 	interval = autosave_interval/(clif_countusers()+1);
 	if(interval < minsave_interval)