Bläddra i källkod

* Various accumulated cleanups and fixes.
- Improved the compile speed for files which include common/socket.h on windows builds (related r10471).
- Moved FIFOSIZE_SERVERLINK define from common/mmo.h to common/socket.h (since it is a server connection FIFO size setting).
- Fixed script command 'areamobuseskill' canceling monster's skill cast before it determined it's new target, which could be 'none' (bugreport:3272, since r13897).
- Added a protection against attempts to read an empty backup / write to a full backup in skill_dance_switch as per TODO from r11347.

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

ai4rei 14 år sedan
förälder
incheckning
7557d37013
7 ändrade filer med 28 tillägg och 15 borttagningar
  1. 5 0
      Changelog-Trunk.txt
  2. 0 2
      src/common/mmo.h
  3. 6 6
      src/common/socket.c
  4. 2 0
      src/common/socket.h
  5. 2 2
      src/map/pc.c
  6. 3 3
      src/map/script.c
  7. 10 2
      src/map/skill.c

+ 5 - 0
Changelog-Trunk.txt

@@ -1,6 +1,11 @@
 Date	Added
 
 2011/01/31
+	* Various accumulated cleanups and fixes. [Ai4rei]
+	- Improved the compile speed for files which include common/socket.h on windows builds (related r10471).
+	- Moved FIFOSIZE_SERVERLINK define from common/mmo.h to common/socket.h (since it is a server connection FIFO size setting).
+	- Fixed script command 'areamobuseskill' canceling monster's skill cast before it determined it's new target, which could be 'none' (bugreport:3272, since r13897).
+	- Added a protection against attempts to read an empty backup / write to a full backup in skill_dance_switch as per TODO from r11347.
 	* Fixed faulty WFIFO reallocation causing memory exhaustion (bugreport:4737, since r1816, related r11503, r11571, r11886 and r12232). [Ai4rei]
 2011/01/30
 	* Fixed equipped items' bonus no longer working after log-in until next status recalc, due to missing pc_setequipindex which was previously called by pc_checkitem (bugreport:2604, since r14685). [Ai4rei]

+ 0 - 2
src/common/mmo.h

@@ -53,8 +53,6 @@
 #define PACKETVER 20071106
 #endif
 
-#define FIFOSIZE_SERVERLINK	256*1024
-
 //Remove/Comment this line to disable sc_data saving. [Skotlex]
 #define ENABLE_SC_SAVING 
 //Remove/Comment this line to disable server-side hot-key saving support [Skotlex]

+ 6 - 6
src/common/socket.c

@@ -543,18 +543,16 @@ static int create_session(int fd, RecvFunc func_recv, SendFunc func_send, ParseF
 	return 0;
 }
 
-static int delete_session(int fd)
+static void delete_session(int fd)
 {
-	if (fd <= 0 || fd >= FD_SETSIZE)
-		return -1;
-	if (session[fd]) {
+	if( session_isValid(fd) )
+	{
 		aFree(session[fd]->rdata);
 		aFree(session[fd]->wdata);
 		aFree(session[fd]->session_data);
 		aFree(session[fd]);
 		session[fd] = NULL;
 	}
-	return 0;
 }
 
 int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size)
@@ -1333,10 +1331,12 @@ void send_shortlist_add_fd(int fd)
 	int i;
 	int bit;
 
-	if( fd < 0 || fd >= FD_SETSIZE )
+	if( !session_isValid(fd) )
 		return;// out of range
+
 	i = fd/32;
 	bit = fd%32;
+
 	if( (send_shortlist_set[i]>>bit)&1 )
 		return;// already in the list
 

+ 2 - 0
src/common/socket.h

@@ -9,6 +9,7 @@
 #endif
 
 #ifdef WIN32
+	#define WIN32_LEAN_AND_MEAN  // otherwise winsock2.h includes full windows.h
 	#include <winsock2.h>
 	typedef long in_addr_t;
 #else
@@ -19,6 +20,7 @@
 
 #include <time.h>
 
+#define FIFOSIZE_SERVERLINK 256*1024
 
 // socket I/O macros
 #define RFIFOHEAD(fd)

+ 2 - 2
src/map/pc.c

@@ -1541,7 +1541,7 @@ static int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id,
 	if (!(flag&(ATF_TARGET|ATF_SELF)))
 		flag|=ATF_TARGET; //Default target: enemy.
 	if (!(flag&(ATF_WEAPON|ATF_MAGIC|ATF_MISC)))
-		flag|=ATF_WEAPON; //Defatul type: weapon.
+		flag|=ATF_WEAPON; //Default type: weapon.
 
 	for (i = 0; i < max && effect[i].flag; i++) {
 		if (effect[i].id == id && effect[i].flag == flag)
@@ -2935,7 +2935,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val)
 			break;
 		}
 		if( sd->state.lr_flag != 2 )
-			pc_bonus_addeff_onskill(sd->addeff3, ARRAYLENGTH(sd->addeff3), (sc_type)type3, val, type2, 2);
+			pc_bonus_addeff_onskill(sd->addeff3, ARRAYLENGTH(sd->addeff3), (sc_type)type3, val, type2, ATF_TARGET);
 		break;
 		
 	case SP_ADDELE:

+ 3 - 3
src/map/script.c

@@ -14635,9 +14635,6 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap)
 	if( md->class_ != mobid )
 		return 0;
 
-	if( md->ud.skilltimer != INVALID_TIMER ) // Cancel the casting skill.
-		unit_skillcastcancel(bl,0);
-
 	// 0:self, 1:target, 2:master, default:random
 	switch( target )
 	{
@@ -14650,6 +14647,9 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap)
 	if( !tbl )
 		return 0;
 
+	if( md->ud.skilltimer != INVALID_TIMER ) // Cancel the casting skill.
+		unit_skillcastcancel(bl,0);
+
 	if( skill_get_casttype(skillid) == CAST_GROUND )
 		unit_skilluse_pos2(&md->bl, tbl->x, tbl->y, skillid, skilllv, casttime, cancel);
 	else

+ 10 - 2
src/map/skill.c

@@ -6754,15 +6754,23 @@ int skill_dance_overlap(struct skill_unit* unit, int flag)
  *------------------------------------------*/
 static bool skill_dance_switch(struct skill_unit* unit, int flag)
 {
+	static int prevflag = 1;  // by default the backup is empty
 	static struct skill_unit_group backup;
 	struct skill_unit_group* group = unit->group;
 
-	//TODO: add protection against attempts to read an empty backup / write to a full backup
-
 	// val2&UF_ENSEMBLE is a hack to indicate dissonance
 	if ( !(group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) )
 		return false;
 
+	if( flag == prevflag )
+	{// protection against attempts to read an empty backup / write to a full backup
+		ShowError("skill_dance_switch: Attempted to %s (skill_id=%d, skill_lv=%d, src_id=%d).\n",
+			flag ? "read an empty backup" : "write to a full backup",
+			group->skill_id, group->skill_lv, group->src_id);
+		return false;
+	}
+	prevflag = flag;
+
 	if( !flag )
 	{	//Transform
 		int skillid = unit->val2&UF_SONG ? BA_DISSONANCE : DC_UGLYDANCE;