diff options
author | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-12-12 14:53:57 +0000 |
---|---|---|
committer | ai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2010-12-12 14:53:57 +0000 |
commit | b0361ff113aaa873b1f9d9696f2e5e1e5c73d574 (patch) | |
tree | cb639f83e37c58f26bf379d2170d7ebaeacca333 /src/map/atcommand.c | |
parent | 2486b455b32116d23b62ba9ffeed18fc64feac48 (diff) | |
download | hercules-b0361ff113aaa873b1f9d9696f2e5e1e5c73d574.tar.gz hercules-b0361ff113aaa873b1f9d9696f2e5e1e5c73d574.tar.bz2 hercules-b0361ff113aaa873b1f9d9696f2e5e1e5c73d574.tar.xz hercules-b0361ff113aaa873b1f9d9696f2e5e1e5c73d574.zip |
* Cleaned up MOTD reading (related r292 and r4552).
- Added a warning for common client crash caused by the sequence ' :' in MOTD.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14584 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r-- | src/map/atcommand.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 6f008c3af..0c584223f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -6862,26 +6862,36 @@ ACMD_FUNC(identify) *------------------------------------------*/ ACMD_FUNC(gmotd) { - char buf[CHAT_SIZE_MAX]; - FILE *fp; - nullpo_retr(-1, sd); - if((fp = fopen(motd_txt, "r"))!=NULL){ - while(fgets(buf, sizeof(buf), fp) != NULL) + char buf[CHAT_SIZE_MAX]; + size_t len; + FILE* fp; + + if( ( fp = fopen(motd_txt, "r") ) != NULL ) + { + while( fgets(buf, sizeof(buf), fp) ) + { + if( buf[0] == '/' && buf[1] == '/' ) { - int i; - if (buf[0] == '/' && buf[1] == '/') - continue; - for(i=0; buf[i]; i++){ - if(buf[i]=='\r' || buf[i]=='\n'){ - buf[i]=0; - break; - } - } - intif_broadcast(buf, strlen(buf)+1, 0); + continue; + } + + len = strlen(buf); + + while( len && ( buf[len-1] == '\r' || buf[len-1] == '\n' ) ) + {// strip trailing EOL characters + len--; + } + + if( len ) + { + buf[len] = 0; + + intif_broadcast(buf, len+1, 0); } - fclose(fp); } - return 0; + fclose(fp); + } + return 0; } ACMD_FUNC(misceffect) |