[MUD-Dev] New Here

MIKE MacMartin mike at igs.net
Fri Jun 20 00:16:06 New Zealand Standard Time 2003


I'm new here.  I'd like to introduce myself:

  I'm Mike MacMartin, just finished 1st year of a Computer Science
  program at Carleton University.  Been coding for ages, know C,
  C++, TCL, a little BASIC ... and so on.  Linux geek.  Recently
  became mud coder for a Godwars base.  Then acquired some source
  that I thought to translate to C++.  It didn't work like that;
  instead, I decided it would be easier just to start from scratch.
  So start from scratch I did.  I've come a long way.

Unfortunately, I'm blocked at a conundrum I can't solve: basically,
my string substitution for my prompt (and consequently, anything
requiring name/gender etc) fails.  I've got ANSI colour support in,
which works, using the same algorithm.

The prompt I'm looking for is /C$N/r>/x ... which, before the colour
substitution (/ is the colour escape, $ is the string escape), flips
the order of the > and the name ($N is the acting character's name).

Here is the code I've got written (using C++ and std::string):

  string CCharacter::expand(string fmt, bool victim) {
    string::size_type pos = 0;
    while ((pos = fmt.find('$', pos + 1)), pos != string::npos) {
      fmt.insert(pos + 2, text(fmt[pos+1], victim));
      fmt.erase(pos, 2);
    }
    return fmt;
  }

where text(char, bool) returns appropriate string replacements
(usually m_strings["whichever"] ... looks up in a
map<string,string>).

Like I said, my prompt is (essentially, ignoring colours) $N> which,
with a character name of "Lazarus" _should_ produce Lazarus>.  With
me so far?  I get >azarus, with the input cursor where it should be
- that is, next to the >.

It appears that I can't do an insert then check for a character in
an STL string.  Is that correct?

MIKE
--
Beware the JabberOrk
_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev




More information about the MUD-Dev mailing list