MudBytes
» MUDBytes Community » Codebase Specific » DikuMUD » Rom » RaM » Proposed bug fixes
Pages: << prev ... 7, 8, 9, 10, 11 ... next >>
Proposed bug fixes, stuff to fix stock ROM
Runter
Wizard






Group: Members
Posts: 1,850
Joined: Jun 1, 2006

Go to the bottom of the page Go to the top of the page
#121 id:14361 Posted Oct 25, 2008, 4:07 am

Yeah, std::map let's you access elements through [].  A rom version could look like:
Code (text):
1
2
3
4
5
6
7
8
 
std::map<int, ROOM_INDEX_DATA *>   room_index;
 
while(more_rooms_to_load) 
    room_index[vnum_to_load]  =  new_room;
 

However, it's a non-intrusive  container class that implements by default a self balancing binary tree. (Which is perfect for this problem.) Since we all know a balance binary tree gives us logarithmic search times.

Another interesting feature of a map in C++ is being able to assign it multiple types to be the "key". Such as

Code (text):
1
2
3
4
5
6
7
 
std::map<char *, ROOM_INDEX_DATA *> room_index;
 
room_index["A chessboard tile"] = new_room;
 

Not really practical for our case, but still interesting.


Multimaps are also interesting. It allows a single key to point to multiple instances of a type. Such as the key being a room vnum, and the multiple objects being the CHAR_DATA*'s inside of said room.  boost library uses a 2way map that I actually employ that lets you lookup the key by value or, like one way maps, value by key.
.........................
CoralMud project

For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
                                              Leonardo Da Vinci Yukihiro Matsumoto

quixadhal
Wizard






Group: Members
Posts: 1,472
Joined: Oct 17, 2007

Go to the bottom of the page Go to the top of the page
#122 id:14378 Posted Oct 25, 2008, 7:10 pm

It's nice to know that drugs and/or alcohol were cheaper and easier to come by in our youth....

Code (text):
1
2
3
4
5
6
7
8
9
10
11
    /*
     * Set time and weather.
     */
    {   
        int                     lhour,
                                lday,
                                lmonth;
 
        lhour = ( current_time - 650336715 ) / ( PULSE_TICK / PULSE_PER_SECOND );


Anyone want to guess why 650336715 is significant?  Birthday?  Date DikuMUD Alpha went live?  Date developers got accepted to Diku University?  PostgreSQL says:

Code (text):
1
2
3
4
5
6
7
wiley=> SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 650336715 * INTERVAL '1 second';
        ?column?        
------------------------
 1990-08-10 21:05:15-04
(1 row)


Anyone know their history?
.........................
http://i302.photobucket.com/albums/nn96/quixadhal/DramaBytes.png

quixadhal
Wizard






Group: Members
Posts: 1,472
Joined: Oct 17, 2007

Go to the bottom of the page Go to the top of the page
#123 id:14379 Posted Oct 25, 2008, 7:30 pm

Heh, while I'm ragging on the devs....
Code (text):
1
2
3
4
5
6
        /*
         * Check age and reset.
         * Note: Mud School resets every 3 minutes (not 15).
         */


but...

Code (text):
1
2
3
4
5
6
7
8
9
<: 2008-10-25 19:23:57.004 : BOOT     (comm.c;main,208)
 : RaM is ready to rock on port 4000.
<: 2008-10-25 19:23:57.005 : RESET    : mud school has just been reset.
<: 2008-10-25 19:25:57.970 : RESET    : mud school has just been reset.
<: 2008-10-25 19:27:58.935 : RESET    : mud school has just been reset.
<: 2008-10-25 19:28:07.091 : FATAL    (comm.c;proper_exit,2207)
 : Shutdown by SYSTEM -- Received SIGINT or SIGTERM.


Unless my math is really bad, that's every 2 minutes, not every 3.
Just sayin'.....
.........................
http://i302.photobucket.com/albums/nn96/quixadhal/DramaBytes.png

David Haley
Wizard






Group: Members
Posts: 6,874
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#124 id:14381 Posted Oct 25, 2008, 7:36 pm

Having the abstraction layer of collection types is one of the most important contributors toward programmer-time efficiency, I have found.

FWIW, with some discipline, you can do it in C too, as long as you force yourself (and everybody else...) to talk to the container object through a function interface. (C++ just makes it easier to encapsulate and enforce this interface.)
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Last edited Oct 25, 2008, 7:36 pm by David Haley
quixadhal
Wizard






Group: Members
Posts: 1,472
Joined: Oct 17, 2007

Go to the bottom of the page Go to the top of the page
#125 id:14388 Posted Oct 25, 2008, 9:20 pm

Also, while I'm in seek & destroy mode.... here's a long-standing bug that's been with us since Diku Alpha.

Allow me to quote from the Gospel of TELNET, RFC 854:

Quote:
      The sequence "CR LF", as defined, will cause the NVT to be
      positioned at the left margin of the next print line (as would,
      for example, the sequence "LF CR").  However, many systems and
      terminals do not treat CR and LF independently, and will have to
      go to some effort to simulate their effect.  (For example, some
      terminals do not have a CR independent of the LF, but on such
      terminals it may be possible to simulate a CR by backspacing.)
      Therefore, the sequence "CR LF" must be treated as a single "new
      line" character and used whenever their combined action is
      intended; the sequence "CR NUL" must be used where a carriage
      return alone is actually desired; and the CR character must be
      avoided in other contexts.  This rule gives assurance to systems
      which must decide whether to perform a "new line" function or a
      multiple-backspace that the TELNET stream contains a character
      following a CR that will allow a rational decision.


Now, from our 2nd grade C classes, we'll remember that the symbol "\n" is a linefeed character, and the "\r" symbol is a carriage return.  Those of us on UNIX-style systems generally only use LF, and those on really old Macs only use CR, while those on MS_DOS actually use CRLF as a single unit.

So, you'll note that pretty much EVERY SINGLE DIKU-derived MUD has thousands of "\n\r" sequences scattered throughout the code.  That's LFCR, and is doubly-wrong!  First, it should be "\r\n", and secondly -- even if you did want to send LFCR -- you'd send it as "\n\r\0", which is a PITA for C, but there you have it.

I first ran into this back in 1993 when I couldn't get triggers to work properly in TinyFugue, because I was anchoring them to the beginning of the line.  But since the order was backwards, the line actually looked like "blah$^\rfoo", where there's an extra leading CR.  The developer of a popular Java MUD actually got annoyed at me for trying to point out how this was wrong, and invoked the "it can't be wrong because every other MUD out there does it that way" rule.

I'd rather fix it here, if you guys don't mind. :)

EDIT:  Oh, and there are actually a few places it was done right!  egrep reports 1629 occurances of it the wrong way, and 9 the right way!  Of course, two of those are lies, as they're double lines.
.........................
http://i302.photobucket.com/albums/nn96/quixadhal/DramaBytes.png

Last edited Oct 25, 2008, 9:28 pm by quixadhal
Runter
Wizard






Group: Members
Posts: 1,850
Joined: Jun 1, 2006

Go to the bottom of the page Go to the top of the page
#126 id:14391 Posted Oct 25, 2008, 9:30 pm

Can you show which lines it was done correctly on?
.........................
CoralMud project

For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
                                              Leonardo Da Vinci Yukihiro Matsumoto

quixadhal
Wizard






Group: Members
Posts: 1,472
Joined: Oct 17, 2007

Go to the bottom of the page Go to the top of the page
#127 id:14393 Posted Oct 25, 2008, 9:40 pm

Code (text):
1
2
3
4
5
6
7
8
9
10
11
12
quixadhal@virt2:~/svn/ram-project/src$ egrep '\\r\\n' *.c        
act_info.c:                         "\n\r============================================================\n\r\n\r" );
act_wiz.c:    send_to_char( "You cannot abbreviate the prefix command.\r\n", ch );
act_wiz.c:            send_to_char( "You have no prefix to clear.\r\n", ch );
act_wiz.c:        send_to_char( "Prefix removed.\r\n", ch );
act_wiz.c:        sprintf( buf, "Prefix changed to %s.\r\n", argument );
act_wiz.c:        sprintf( buf, "Prefix set to %s.\r\n", argument );
alias.c:            send_to_char( "Line to long, prefix not processed.\r\n", ch );
alias.c:                    send_to_char( "Alias substitution too long. Truncated.\r\n", ch );
fight.c:            send_to_char( "You have been KILLED!!\n\r\n\r", victim );


The one in act_info.c, and the one in fight.c are false positives... it's hitting on the middle of the 4-character LFCRLFCR sequence.
.........................
http://i302.photobucket.com/albums/nn96/quixadhal/DramaBytes.png

David Haley
Wizard






Group: Members
Posts: 6,874
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#128 id:14399 Posted Oct 26, 2008, 2:45 pm

I would argue that the server should only send \n and forget the \r silliness. Clients these days are quite able to figure that one out on their own.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Runter
Wizard






Group: Members
Posts: 1,850
Joined: Jun 1, 2006

Go to the bottom of the page Go to the top of the page
#129 id:14404 Posted Oct 26, 2008, 3:07 pm

Quote:
I would argue that the server should only send \n and forget the \r silliness. Clients these days are quite able to figure that one out on their own.


That's what I was thinking. I'm just not authoritative enough on the subject to be the first one to say it. ;)

I've never really seen a problem with just \n. Although I guess it could still be relevant for some users?
.........................
CoralMud project

For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
                                              Leonardo Da Vinci Yukihiro Matsumoto

David Haley
Wizard






Group: Members
Posts: 6,874
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#130 id:14405 Posted Oct 26, 2008, 3:33 pm

It would only be relevant for users with clients who only understand one of the other conventions (\r\n or just \r). The latter category are Mac users, and I believe that Mac clients have known for a long time that most servers don't speak \r and have dealt with it. The former category are Windows people, but many Windows clients know that they have to talk to Unix servers and so understand \n on its own as well. Furthermore, many (MUD) clients go to some effort to handle line endings correctly, because they have to deal with the correct \r\n and the incorrect \n\r. In the end of the day, from what I have heard, most clients only look for \n and ignore \r because it's too confusing to deal with it.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

quixadhal
Wizard






Group: Members
Posts: 1,472
Joined: Oct 17, 2007

Go to the bottom of the page Go to the top of the page
#131 id:14406 Posted Oct 26, 2008, 4:29 pm

Just so you know.... your arguments break down to:

Most telnet clients are broken, so we should make the server broken too, since it's less work.

I will NOT promote broken telnet clients, ever.  In fact, if there weren't so much else on the plate, I'd suggest properly implementing a full telnet stack.  If we don't want to follow the TELNET protocol, then we need to develop and maintain a custom client.  I've advocated abandoning telnet in favor of a custom protocol for a while now, but as has been pointed out in those discussions, to many folk that moves us out of the realm of "MUD" and into a seperate "online text game" space.

Probably not a proper fit for a project whose stated goal is to produce a server which acts like ROM, but is technically superior.

I'd actually argue the opposite... detect if a client sends an LFCR sequence (or a CR that is NOT followed by a NULL) and send them a line back saying

***NOTICE:  You are using a BROKEN telnet client!  Things may not work properly, and it's YOUR FAULT, not ours. ****
.........................
http://i302.photobucket.com/albums/nn96/quixadhal/DramaBytes.png

David Haley
Wizard






Group: Members
Posts: 6,874
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#132 id:14407 Posted Oct 26, 2008, 4:42 pm

I don't think it's entirely unreasonable to follow the Unix convention for line endings. I think you are exaggerating a wee bit when you say that our only choices are to either (a) implement a full telnet stack or (b) develop and maintain a custom client. That's a false dilemma if I've ever seen one. :wink:

I'm all for yelling at clients that don't implement things properly, but that will accomplish next to nothing and will mainly irritate players who are stuck with non-conforming clients.

Incidentally, if you really want to get nitty-gritty about it, the servers should all be sending the GA code at the appropriate times.

Anyhow, this could also be solved by having a "NEWLINE" define that has the correct value, and then all strings that want to use a newline do this:

"Hello there" NEWLINE "How are you?"
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Runter
Wizard






Group: Members
Posts: 1,850
Joined: Jun 1, 2006

Go to the bottom of the page Go to the top of the page
#133 id:14408 Posted Oct 26, 2008, 4:53 pm

I say let's assume the terminal width is 80 characters and just pad everything with spaces til it wraps around to the desired formats.
.........................
CoralMud project

For once you have tasted flight Ruby you will walk the earth with your eyes turned skywards,
for there you have been and there you will long to return. --
                                              Leonardo Da Vinci Yukihiro Matsumoto

quixadhal
Wizard






Group: Members
Posts: 1,472
Joined: Oct 17, 2007

Go to the bottom of the page Go to the top of the page
#134 id:14411 Posted Oct 26, 2008, 5:39 pm

It's unreasonable to follow the UNIX convention when people are using the TELNET protocol to connect to the game.

I never said those were the only two choices.  In fact, I said if there weren't other, more important, things to fix first, I'd suggest a full telnet stack... but changing the line endings is a global search and replace that I've already done on my working copy, with no ill effects.

I think the GA sequence is one of the extensions to the protocol, but it probably would be useful to send one after a prompt, since that won't be terminated by a newline.  In fact, the code does do this IF a bit on the character is set, but AFAIK no negotiation is done to determine if the client supports it (which means, only people who think about it get to use it).

As for a NEWLINE definition (which will ALWAYS be CRLF, because it's the standard... regardless of what your local architecture uses -- hence the reason for a standard). that's already done for C++ (endl), assuming whomever overloaded socket streams did their job properly... good luck convincing anyone to use sprintf(tmp, "You died again.%s", NEWLINE); send_to_char(tmp, ch);  Being able to concatonate adjacent strings is, I think, a GNU specific extension to C (unless it's part of C99, perhaps)?

I guess I've worked in production environments for too many years, so I can't see the value in NOT following an established standard correctly, especially when it's trivial to do so.  Do you have any compelling reasons to deviate from the standard, other than it being less typing, or because everyone else does it wrong too?
.........................
http://i302.photobucket.com/albums/nn96/quixadhal/DramaBytes.png

David Haley
Wizard






Group: Members
Posts: 6,874
Joined: Jun 30, 2007

Go to the bottom of the page Go to the top of the page
#135 id:14412 Posted Oct 26, 2008, 5:49 pm

quixadhal said:
I never said those were the only two choices.  In fact, I said if there weren't other, more important, things to fix first, I'd suggest a full telnet stack...

That was one of the choices :wink: (choice a to be precise)

quixadhal said:
Being able to concatonate adjacent strings is, I think, a GNU specific extension to C (unless it's part of C99, perhaps)?

No, I don't believe it's an extension. I've used it in ANSI C, IIRC.

quixadhal said:
I guess I've worked in production environments for too many years, so I can't see the value in NOT following an established standard correctly, especially when it's trivial to do so.  Do you have any compelling reasons to deviate from the standard, other than it being less typing, or because everyone else does it wrong too?

I think it's somewhat wishful thinking to believe that the MUD world actually follows the telnet standard. Everybody follows some strange mashup of telnet and other things. Basically, the MUD world uses a line-by-line protocol, and people get bonus points for supporting telnet negotiation.

I think it's dangerous to try to stick to a standard -- without additional help like a wrapper around sending data -- when empirical evidence suggests that people are terrible at following it.
.........................
-- d.c.h --
BabbleMUD Project (custom codebase)
Legends of the Darkstone (head coder)
http://david.the-haleys.org
.........................

Pages:<< prev ... 7, 8, 9, 10, 11 ... next >>
Tags
[+]

Valid XHTML 1.1! Valid CSS!