Ok, here's some rough ideas for things that need to be done to make Fire a true C++ game driver. 1 Replace all char *'s with std::string or a similar shared string class. Initially std::string is probably our best bet, since most shared string classes will be drop-in replacements, more or less. The sticking point is that we need a case INsensitive compare function. Obviously, it's not hard to code a version of strcasecmp() to take strings instead of char *'s. It's ugly though. It would be nice to have it an operator, but I don't see that being possible since you won't ALWAYS want it to be case insensitive. 2 Replace the room array with a std::map of either int to room *, or maybe just int to room. The idea is that we should be able to simply access the rooms by vnum directly, not futz around with lookups. Since rooms only have one instance of each vnum, a map should work fine. Virtual rooms can be implemented either in a seperate map, or perhaps a dyanmic counting trick, like INT_MAX - vnum. Not a big deal, since they aren't widely used in ROM. 3 Replace the mob and object arrays with std::map for the prototypes, and std::multimap for the instances. There should only be one prototype of each mob or object, but there may be many instances. Changing an instance should not affect the prototype. Changing a prototype might or might not change the instances, I'm leaning towards not since they will be changed on a reboot anyways. 4 Many of the list structures in ROM are cobbled up so the pointers are embedded IN the objects. Bad practice. We should instead allow the objects to be stored in multiple containers (via pointers). Here's some code to handle printf formatting for std::string #include <string> #include <cstdarg> #include <vector> #include <string> std::string format (const char *fmt, ...) { va_list ap; va_start (ap, fmt); std::string buf = vformat (fmt, ap); va_end (ap); return buf; } std::string vformat (const char *fmt, va_list ap) { // Allocate a buffer on the stack that's big enough for us almost // all the time. size_t size = 1024; char buf[size]; // Try to vsnprintf into our buffer. va_list apcopy; va_copy (apcopy, ap); int needed = vsnprintf (&buf[0], size, fmt, ap); if (needed <= size) { // It fit fine the first time, we're done. return std::string (&buf[0]); } else { // vsnprintf reported that it wanted to write more characters // than we allotted. So do a malloc of the right size and try again. // This doesn't happen very often if we chose our initial size // well. std::vector <char> buf; size = needed; buf.resize (size); needed = vsnprintf (&buf[0], size, fmt, apcopy); return std::string (&buf[0]); } } // Case insensitive compare (useable in sorting, thanks Tyche!) int str_cmp(const std::string & s1, const std::string & s2) { std::string::const_iterator p1 = s1.begin(), p2 = s2.begin(); while(p1 != s1.end() && p2 != s2.end()) { if(tolower(*p1) != tolower(*p2)) return (tolower(*p1) < tolower(*p2)) ? -1 : 1; p1++; p2++; } if (s1.size() == s2.size()) return 0; return (s1.size() < s2.size()) ? -1 : 1; } ----- ACT CODES: $$ $ $t arg1 $T arg2 $n PERS(ch) $N PERS(vch) $e HESHE(ch) $E HESHE(vch) $m HIMHER(ch) $M HIMHER(vch) $s HISHER(ch) $S HISHER(vch) $p OPERS(obj1) $P OPERS(obj2) $a ANA(obj1->name) $A ANA(obj2->name) $d "door" or exit name of arg2 COLOR CODES: Note that ANSI uses BOLD to indicate bright colours on terminals that support more than the 8 original colours. Hence, a composite code of \e[1m and \e[32m can be written as \e[1;32m. CHANNEL COLOUR ANSI ROM SMAUG --------------- ----------------------- -------- --- ----- black \e[0;30m &x dark red \e[0;31m {r &r dark green \e[0;32m {g &g orange \e[0;33m {y &O dark blue \e[0;34m {b &b purple/magenta \e[0;35m {m &p cyan \e[0;36m {c &c light grey \e[0;37m {w &w dark grey \e[1;30m {D &z red \e[1;31m {R &R green \e[1;32m {G &G yellow \e[1;33m {Y &Y blue \e[1;34m {B &B pink \e[1;35m {M &P light blue \e[1;36m {C &C white \e[1;37m {W &W random color &Z background black \e[40m ^x background dark red \e[41m ^r background dark green \e[42m ^g background orange \e[43m ^O background dark blue \e[44m ^b background purple \e[45m ^p background cyan \e[46m ^c background light grey \e[47m ^w background dark grey \e[50m ^z background red \e[51m ^R background green \e[52m ^G background yellow \e[53m ^Y background blue \e[54m ^B background pink \e[55m ^P background light blue \e[56m ^C background white \e[57m ^W random background color ^Z blinking black \e[0;5;30m }x blinking dark red \e[0;5;31m }r blinking dark green \e[0;5;32m }g blinking orange \e[0;5;33m }O blinking dark blue \e[0;5;34m }b blinking purple \e[0;5;35m }p blinking cyan \e[0;5;36m }c blinking light grey \e[0;5;37m }w blinking dark grey \e[1;5;30m }z blinking red \e[1;5;31m }R blinking green \e[1;5;32m }G blinking yellow \e[1;5;33m }Y blinking blue \e[1;5;34m }B blinking pink \e[1;5;35m }P blinking light blue \e[1;5;36m }C blinking white \e[1;5;37m }W random blinking color }Z reset \e[0m &d bold \e[1m italic \e[3m &i/&I underline \e[4m &u/&U blink \e[5m reverse \e[7m &v/&V strikethru \e[9m &s/&S bell \007 {* CRLF \r\n {/ ~ ~ {- { { {{ & & && reset to content &D action aflags aname answer (bright yellow) {f answer_text (bright white) {F arena auction auction (bright yellow) {a auction_text (bright white) {A board board2 board3 bye carnage consider damage danger dead diemsg divider dying exits falling fight_death (red) {1 fight_ohit (yellow) {3 fight_skill (white) {5 fight_thit (red) {4 fight_yhit (green) {2 fire flee gold gossip gossip (magenta) {d gossip_text (bright magenta) {9 gtell gtell_text (green) {n gtell_type (red) {N guildtalk help hit hitme hungry hurt ignore immort immtalk_text (cyan) {i immtalk_type (yellow) {I info (yellow) {j intermud list log magic morph muse music (red) {e music_text (bright red) {E mxpprompt note object person plain poison prac prac2 prac3 prac4 prompt (cyan) {p question (bright yellow) {q question_text (bright white) {Q quote (green) {h quote_text (bright green) {H racetalk reply (green) {l reply_text (bright green) {L report reset rflags rmdesc rmname room_exits (green) {o room_text (white) {S room_things (cyan) {O room_title (cyan) {s say say (green) {6 say_text (bright green) {7 score score2 score3 score4 score5 shout skill sober social stype tell tell (green) {k tell_text (bright green) {K text (white) {t think thirsty wartalk wearoff whisper who who2 who3 who4 who5 who6 who7 wiznet (green -- conflicts) {B yell