Przeglądaj źródła

* Fixed a few map crashes when char-server crashes [Wizputer]
* Added fix of 0x2aff and 0x2af8 flooding [Wizputer - thanks Toster]

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

wizputer 20 lat temu
rodzic
commit
e10dec5a1b
2 zmienionych plików z 39 dodań i 14 usunięć
  1. 2 0
      Changelog.txt
  2. 37 14
      src/map/chrif.c

+ 2 - 0
Changelog.txt

@@ -1,5 +1,7 @@
 Date	Added
 11/27
+	* Fixed a few map crashes when char-server crashes [Wizputer]
+	* Added fix of 0x2aff and 0x2af8 flooding [Wizputer - thanks Toster] 
 	* Fixed Map crash when person uses global message hacks [Wizputer]
 	* Fixed online system, online column works and prevent double login at the login server [Wizputer]
 	* Fixed some compile time errors associated with showmsg [MouseJstr]

+ 37 - 14
src/map/chrif.c

@@ -98,7 +98,7 @@ int chrif_save(struct map_session_data *sd)
 {
 	nullpo_retr(-1, sd);
 
-	if (char_fd < 0)
+	if (char_fd < 1)
 		return -1;
 
 	pc_makesavestatus(sd);
@@ -184,7 +184,10 @@ int chrif_changemapserver(struct map_session_data *sd, char *name, int x, int y,
 	int i, s_ip;
 
 	nullpo_retr(-1, sd);
-
+	
+	if (!sd || char_fd < 1 )
+		return -1;
+		
 	s_ip = 0;
 	for(i = 0; i < fd_max; i++)
 		if (session[i] && session[i]->session_data == sd) {
@@ -283,7 +286,7 @@ int chrif_authreq(struct map_session_data *sd)
 
 	nullpo_retr(-1, sd);
 
-	if (!sd || !char_fd || !sd->bl.id || !sd->login_id1)
+	if (!sd || char_fd < 1 || !sd->bl.id || !sd->login_id1)
 		return -1;
 
 	for(i = 0; i < fd_max; i++)
@@ -311,7 +314,7 @@ int chrif_charselectreq(struct map_session_data *sd)
 
 	nullpo_retr(-1, sd);
 
-	if(!sd || !char_fd || !sd->bl.id || !sd->login_id1)
+	if(!sd || char_fd < 1 || !sd->bl.id || !sd->login_id1)
 		return -1;
 
 	s_ip = 0;
@@ -337,7 +340,7 @@ int chrif_charselectreq(struct map_session_data *sd)
  */
 int chrif_searchcharid(int char_id) 
 {
-	if (!char_id)
+	if (!char_id || char_fd < 1)
 		return -1;
 
 	WFIFOW(char_fd,0) = 0x2b08;
@@ -355,6 +358,9 @@ int chrif_changegm(int id, const char *pass, int len)
 {
 	if (battle_config.etc_log)
 		printf("chrif_changegm: account: %d, password: '%s'.\n", id, pass);
+	
+	if (char_fd < 1 )
+		return -1;
 
 	WFIFOW(char_fd,0) = 0x2b0a;
 	WFIFOW(char_fd,2) = len + 8;
@@ -373,7 +379,10 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email)
 {
 	if (battle_config.etc_log)
 		printf("chrif_changeemail: account: %d, actual_email: '%s', new_email: '%s'.\n", id, actual_email, new_email);
-
+		
+	if (char_fd < 1 )
+		return -1;
+		
 	WFIFOW(char_fd,0) = 0x2b0c;
 	WFIFOL(char_fd,2) = id;
 	memcpy(WFIFOP(char_fd,6), actual_email, 40);
@@ -396,6 +405,9 @@ int chrif_changeemail(int id, const char *actual_email, const char *new_email)
  */
 int chrif_char_ask_name(int id, char * character_name, short operation_type, int year, int month, int day, int hour, int minute, int second) 
 {
+   	if (char_fd < 1 )
+		return -1;
+		
 	WFIFOW(char_fd, 0) = 0x2b0e;
 	WFIFOL(char_fd, 2) = id; // account_id of who ask (for answer) -1 if nobody
 	memcpy(WFIFOP(char_fd,6), character_name, 24);
@@ -419,6 +431,9 @@ int chrif_char_ask_name(int id, char * character_name, short operation_type, int
  *------------------------------------------
  */
 int chrif_changesex(int id, int sex) {
+   	if (char_fd < 1 )
+		return -1;
+
 	WFIFOW(char_fd,0) = 0x3000;
 	WFIFOW(char_fd,2) = 9;
 	WFIFOL(char_fd,4) = id;
@@ -649,7 +664,10 @@ int chrif_saveaccountreg2(struct map_session_data *sd)
 {
 	int p, j;
 	nullpo_retr(-1, sd);
-
+	
+	if (char_fd < 1 )
+		return -1;
+	
 	p = 8;
 	for(j = 0; j < sd->status.account_reg2_num; j++) {
 		struct global_reg *reg = &sd->status.account_reg2[j];
@@ -820,7 +838,7 @@ int chrif_chardisconnect(struct map_session_data *sd)
 {
 	nullpo_retr(-1, sd);
 
-	if(char_fd<=0)
+	if(char_fd < 1)
 		return -1;
 
 	WFIFOW(char_fd,0)=0x2b18;
@@ -849,7 +867,9 @@ int chrif_recvgmaccounts(int fd)
  */
 int chrif_reloadGMdb(void) 
 {
-
+   	if (char_fd < 1 )
+		return -1;
+    
 	WFIFOW(char_fd,0) = 0x2af7;
 	WFIFOSET(char_fd, 2);
 
@@ -865,7 +885,10 @@ int chrif_reloadGMdb(void)
 	char buf[256];
 	FILE *fp;
 	int i;
-
+	
+	if (char_fd < 1 )
+		return -1;
+		
 	WFIFOW(char_fd,0) = 0x2b16;
 	WFIFOW(char_fd,2) = base_rate;
 	WFIFOW(char_fd,4) = job_rate;
@@ -899,7 +922,7 @@ int chrif_reloadGMdb(void)
 
 int chrif_char_offline(struct map_session_data *sd) 
 {
-	if (char_fd < 0)
+	if (char_fd < 1)
 		return -1;
 
 	WFIFOW(char_fd,0) = 0x2b17;
@@ -915,7 +938,7 @@ int chrif_char_offline(struct map_session_data *sd)
  *-----------------------------------------
  */
 int chrif_char_reset_offline(void) {
-	if (char_fd < 0)
+	if (char_fd < 1)
 		return -1;
 
 	WFIFOW(char_fd,0) = 0x2b18;
@@ -931,7 +954,7 @@ int chrif_char_reset_offline(void) {
 
 int chrif_char_online(struct map_session_data *sd) 
 {
-	if (char_fd < 0)
+	if (char_fd < 1)
 		return -1;
 
 	WFIFOW(char_fd,0) = 0x2b19;
@@ -1025,7 +1048,7 @@ int send_users_tochar(int tid, unsigned int tick, int id, int data) {
 	int users = 0, i;
 	struct map_session_data *sd;
 
-	if (char_fd <= 0 || session[char_fd] == NULL)
+	if (char_fd < 1 || session[char_fd] == NULL || !chrif_isconnect()) // Thanks to Toster
 		return 0;
 
 	WFIFOW(char_fd,0) = 0x2aff;