Преглед на файлове

- Added the required changes to support the 2008-09-10+ clients
- Cleaned around the char set offline function to properly avoid setting offline a character that had relogged faster than the map server's packet arrival to the char-server (I presume this was the bugfix that Kevin attempted a long time ago, but the current code for that causes a dangling pointer problem).


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

skotlex преди 16 години
родител
ревизия
0167134620
променени са 4 файла, в които са добавени 27 реда и са изтрити 16 реда
  1. 7 1
      db/packet_db.txt
  2. 8 6
      src/char/char.c
  3. 10 7
      src/char_sql/char.c
  4. 2 2
      src/map/clif.h

+ 7 - 1
db/packet_db.txt

@@ -1202,6 +1202,12 @@ packet_ver: 22
 0x035f,-1
 0x0389,-1
 
+//2008-09-10aSakexe
+packet_ver: 23
+0x0436,19,wanttoconnection,2:6:10:14:18
+0x0437,7,actionrequest,2:6
+0x0438,10,useskilltoid,2:4:6
+0x0439,8,useitem,2:4
 
 //Add new packets here
-//packet_ver: 23
+//packet_ver: 24

+ 8 - 6
src/char/char.c

@@ -245,14 +245,16 @@ void set_char_offline(int char_id, int account_id)
 			character->waiting_disconnect = -1;
 		}
 
-		//If user is NOT at char screen, delete entry [Kevin]
-		if(character->char_id != -1)
+		if(character->char_id == char_id)
 		{
-			idb_remove(online_char_db, account_id);
+			character->char_id = -1;
+			character->server = -1;
 		}
+
+		//FIXME? Why Kevin free'd the online information when the char was effectively in the map-server?
 	}
 	
-	if (login_fd > 0 && !session[login_fd]->flag.eof && (char_id == -1 || character == NULL || character->char_id != -1))
+	if (login_fd > 0 && !session[login_fd]->flag.eof && (char_id == -1 || character == NULL || character->fd == -1))
 	{
 		WFIFOHEAD(login_fd,6);
 		WFIFOW(login_fd,0) = 0x272c;
@@ -3218,10 +3220,10 @@ int parse_char(int fd)
 		if( sd != NULL && sd->auth )
 		{
 			struct online_char_data* data = (struct online_char_data*)idb_get(online_char_db, sd->account_id);
-			if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
-				set_char_offline(-1,sd->account_id);
 			if( data != NULL && data->fd == fd)
 				data->fd = -1;
+			if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
+				set_char_offline(-1,sd->account_id);
 		}
 		do_close(fd);
 		return 0;

+ 10 - 7
src/char_sql/char.c

@@ -309,14 +309,17 @@ void set_char_offline(int char_id, int account_id)
 			character->waiting_disconnect = -1;
 		}
 
-		//If user is NOT at char screen, delete entry [Kevin]
-		if(character->char_id != -1)
+		if(character->char_id == char_id)
 		{
-			idb_remove(online_char_db, account_id);
+			character->char_id = -1;
+			character->server = -1;
 		}
+
+		//FIXME? Why Kevin free'd the online information when the char was effectively in the map-server?
 	}
-	
-	if (login_fd > 0 && !session[login_fd]->flag.eof && (char_id == -1 || character == NULL || character->char_id != -1))
+
+	//Remove char if 1- Set all offline, or 2- character is no longer connected to char-server.
+	if (login_fd > 0 && !session[login_fd]->flag.eof && (char_id == -1 || character == NULL || character->fd == -1))
 	{
 		WFIFOHEAD(login_fd,6);
 		WFIFOW(login_fd,0) = 0x272c;
@@ -2870,10 +2873,10 @@ int parse_char(int fd)
 		if( sd != NULL && sd->auth )
 		{	// already authed client
 			struct online_char_data* data = (struct online_char_data*)idb_get(online_char_db, sd->account_id);
-			if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
-				set_char_offline(-1,sd->account_id);
 			if( data != NULL && data->fd == fd)
 				data->fd = -1;
+			if( data == NULL || data->server == -1) //If it is not in any server, send it offline. [Skotlex]
+				set_char_offline(-1,sd->account_id);
 		}
 		do_close(fd);
 		return 0;

+ 2 - 2
src/map/clif.h

@@ -53,8 +53,8 @@ struct quest;
 #endif
 
 // packet DB
-#define MAX_PACKET_DB		0x400
-#define MAX_PACKET_VER		22
+#define MAX_PACKET_DB		0x500
+#define MAX_PACKET_VER		25
 
 struct s_packet_db {
 	short len;