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

* Updates to dynamic server information `ragsrvinfo` on SQL.
- Fixed exp and drop rates (int) getting truncated (short) when sent to char-server.
- Removed `motd` from `ragsrvinfo` as it is not dynamically changed by the server and as such can be read by 3rd party applications directly from conf/motd.txt if required.

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

ai4rei преди 14 години
родител
ревизия
d173283814
променени са 5 файла, в които са добавени 18 реда и са изтрити 41 реда
  1. 3 0
      Changelog-Trunk.txt
  2. 1 0
      sql-files/upgrade_svn14579.sql
  3. 2 2
      src/char/char.c
  4. 4 9
      src/char_sql/char.c
  5. 8 30
      src/map/chrif.c

+ 3 - 0
Changelog-Trunk.txt

@@ -1,6 +1,9 @@
 Date	Added
 
 2010/12/11
+	* Updates to dynamic server information `ragsrvinfo` on SQL. [Ai4rei]
+	- Fixed exp and drop rates (int) getting truncated (short) when sent to char-server.
+	- Removed `motd` from `ragsrvinfo` as it is not dynamically changed by the server and as such can be read by 3rd party applications directly from conf/motd.txt if required.
 	* Added support for checking argument data type of built-in script functions (bugreport:1701, topic:261833, related r14573). [Ai4rei]
 	* Fixed error message in intif_parse_mercenary_received printing wrong struct size (bugreport:4633, since r13116). [Ai4rei]
 2010/12/10

+ 1 - 0
sql-files/upgrade_svn14579.sql

@@ -0,0 +1 @@
+ALTER TABLE `ragsrvinfo` DROP `motd`;

+ 2 - 2
src/char/char.c

@@ -3053,10 +3053,10 @@ int parse_frommap(int fd)
 		break;
 
 		case 0x2b16: // Receive rates [Wizputer]
-			if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd,8))
+			if( RFIFOREST(fd) < 14 )
 				return 0;
 			// Txt doesn't need this packet, so just skip it
-			RFIFOSKIP(fd,RFIFOW(fd,8));
+			RFIFOSKIP(fd,14);
 		break;
 
 		case 0x2b17: // Character disconnected set online 0 [Wizputer]

+ 4 - 9
src/char_sql/char.c

@@ -2738,22 +2738,17 @@ int parse_frommap(int fd)
 		break;
 
 		case 0x2b16: // Receive rates [Wizputer]
-			if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd,8))
+			if( RFIFOREST(fd) < 14 )
 				return 0;
 		{
-			char motd[256];
-			char esc_motd[sizeof(motd)*2+1];
 			char esc_server_name[sizeof(server_name)*2+1];
 
-			strncpy(motd, (char*)RFIFOP(fd,10), 255); //First copy it to make sure the motd fits.
-			motd[255] = '\0';
-			Sql_EscapeString(sql_handle, esc_motd, motd);
 			Sql_EscapeString(sql_handle, esc_server_name, server_name);
 
-			if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `ragsrvinfo` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d',`motd`='%s'",
-				fd, esc_server_name, RFIFOW(fd,2), RFIFOW(fd,4), RFIFOW(fd,6), esc_motd) )
+			if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `ragsrvinfo` SET `index`='%d',`name`='%s',`exp`='%d',`jexp`='%d',`drop`='%d'",
+				fd, esc_server_name, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)) )
 				Sql_ShowDebug(sql_handle);
-			RFIFOSKIP(fd,RFIFOW(fd,8));
+			RFIFOSKIP(fd,14);
 		}
 		break;
 

+ 8 - 30
src/map/chrif.c

@@ -74,7 +74,7 @@ static const int packet_len_table[0x3d] = { // U - used, F - free
 //2b13: Incoming, chrif_accountdeletion -> 'Delete acc XX, if the player is on, kick ....'
 //2b14: Incoming, chrif_accountban -> 'not sure: kick the player with message XY'
 //2b15: FREE
-//2b16: Outgoing, chrif_ragsrvinfo -> 'sends motd / rates ....'
+//2b16: Outgoing, chrif_ragsrvinfo -> 'sends base / job / drop rates ....'
 //2b17: Outgoing, chrif_char_offline -> 'tell the charserver that the char is now offline'
 //2b18: Outgoing, chrif_char_reset_offline -> 'set all players OFF!'
 //2b19: Outgoing, chrif_char_online -> 'tell the charserver that the char .. is online'
@@ -1229,40 +1229,18 @@ int chrif_load_scdata(int fd)
 
 /*==========================================
  * Send rates and motd to char server [Wizputer]
- * S 2b16 <base rate>.w <job rate>.w <drop rate>.w <motd len>.w <motd>.256B
+ * S 2b16 <base rate>.L <job rate>.L <drop rate>.L
  *------------------------------------------*/
- int chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate)
+int chrif_ragsrvinfo(int base_rate, int job_rate, int drop_rate)
 {
-	char buf[256];
-	FILE *fp;
-	int i;
-
 	chrif_check(-1);
 
-	WFIFOHEAD(char_fd, sizeof(buf) + 10);
+	WFIFOHEAD(char_fd,14);
 	WFIFOW(char_fd,0) = 0x2b16;
-	WFIFOW(char_fd,2) = base_rate;
-	WFIFOW(char_fd,4) = job_rate;
-	WFIFOW(char_fd,6) = drop_rate;
-	WFIFOW(char_fd,8) = sizeof(buf) + 10;
-
-	if ((fp = fopen(motd_txt, "r")) != NULL) {
-		if (fgets(buf, sizeof(buf), fp) != NULL)
-		{
-			for(i = 0; buf[i]; i++) {
-				if (buf[i] == '\r' || buf[i] == '\n') {
-					buf[i] = 0;
-					break;
-				}
-			}
-			memcpy(WFIFOP(char_fd,10), buf, sizeof(buf));
-		}
-		fclose(fp);
-	} else {
-		memset(buf, 0, sizeof(buf)); //No data found, send empty packets?
-		memcpy(WFIFOP(char_fd,10), buf, sizeof(buf));
-	}
-	WFIFOSET(char_fd,WFIFOW(char_fd,8));
+	WFIFOL(char_fd,2) = base_rate;
+	WFIFOL(char_fd,6) = job_rate;
+	WFIFOL(char_fd,10) = drop_rate;
+	WFIFOSET(char_fd,14);
 	return 0;
 }