EOSERV Bug Tracker > Bug #216: Empty line on news.txt

Bug #216: Empty line on news.txt

Empty line on news.txt
ID #216
Submitter ♪ Doug ♫
Product EOSERV
Severity Normal
Status CLOSED, FIXED
Submitted 15th Jan 2013
Updated 3rd Mar 2013
Related SVN Revisions
Rev# Date Description
r379 03 Mar 2013 23:20:01 UTC Stop repeated news messages with an empty line at the end of the news file (bug #216)
♪ Doug ♫ Submitter 11 years, 46 weeks ago

Hi Guys,

I found a bug... I normally edit my files from SSH using nano. But when saving, nano keeps a empty line on the end of the file. I saved my news.txt and when I opened eoserv, the last news were repeated. Like:

news.txt:

"Welcome to Untitled Server!\n

Hello!\n

\n"

Client View:

"Hello!

Hello!"

Comments

Ryouken 11 years, 46 weeks ago

Find this in handlers/welcome.cpp:

for (int i = 0; i < 9; ++i)

{

if (newsfh)

{

(void)std::fgets(newsbuf, 4096, newsfh);

}

Replace it with this:

for (int i = 0; i < 9; ++i)

{

if (newsfh)

{

if(std::fgets(newsbuf, 4096, newsfh) == 0)

{

newseof = true;

}

}

The problem is that its getting the string from there and placing it in newsbuf, but if it doesn't find anything, newsbuf doesn't change and is therefor used again in the same state as it's last change. Thats what made it copy.

Sausage Developer 11 years, 39 weeks ago

Pretty sure this is caused by not having 9 lines of text in the file, rather than the addition of an empty line. Applying the fix above.

Updated Status to CONFIRMED

Sausage Developer 11 years, 39 weeks ago

Guess I made that up, code is just derpy. New lines at the end of the file are ignored now, also lines shorter than 2 characters (including empty ones) are displayed in the EO client.

Fixed in r379.

Updated Status to CLOSED, FIXED

Add Comment

Please don't post unless you have something relevant to the bug to say.
Do not comment to say "thanks" or "fix this please".

Please log in to add comments. EOSERV Bug Tracker > Bug #216: Empty line on news.txt