From 2ce7aa656df82a7261c94fe14b9abc59ab6e4826 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sun, 12 Dec 2010 00:44:38 +0000 Subject: * 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://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14579 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/char/char.c | 4 ++-- src/char_sql/char.c | 13 ++++--------- src/map/chrif.c | 38 ++++++++------------------------------ 3 files changed, 14 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/char/char.c b/src/char/char.c index 91ad7d33d..ad18658ba 100644 --- a/src/char/char.c +++ b/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] diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 36944cd35..95e4b3471 100644 --- a/src/char_sql/char.c +++ b/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; diff --git a/src/map/chrif.c b/src/map/chrif.c index 40e7ca8d1..a9634d2c2 100644 --- a/src/map/chrif.c +++ b/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 .w .w .w .w .256B + * S 2b16 .L .L .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; } -- cgit v1.2.3-60-g2f50