// Case insensitive compare
bool str_cmp(const std::string & s1, const std::string & s2)
{
if (s1.size() != s2.size())
return true;
std::string::const_iterator p1 = s1.begin(), p2 = s2.begin();
while(p1 != s1.end() && p2 != s2.end()) {
if(tolower(*p1) != tolower(*p2))
return true;
p1++;
p2++;
}
return false;
}
// Case insensitive compare
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;
}
I will endeavor to be more alert, have something useful for show and tell, and NOT have my hardware blow up so that next week's meeting will be somewhat more productive and/or entertaining!
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).
Just to show that I was online, although mostly AFK, here's a LOG!
18:51:47 # [200 Human IMP] Davion irrelivent.
18:51:47 #
18:51:47 # Players found: 2
19:00:04 #
19:00:04 # Asylumius has reconnected.
19:00:11 #
19:00:11 # Asylumius yawns.
19:14:56 # Quixadhal stretches and blinks.
19:24:04 # Quixadhal dozes off again.
19:46:51 # Quixadhal blinks and looks around.
19:46:54 # [200 Human IMP] Asylumius is AFK
19:46:54 # [200 Dwarf IMP] Quixadhal is taking a nice nap.
19:46:54 # [200 Human IMP] Davion irrelivent.
19:46:54 #
19:46:54 # Players found: 3
19:49:59 # You chuckle politely.
19:50:15 # You say 'Well, I figured it would be extra-quiet this week. :)'
19:50:50 # You say 'I will post my TODO list to the forums so folks can comment on how foolish or right I am, and offer ideas to make it work better!'
20:27:39 #
20:27:39 # Asylumius says 'I'm kinda here.'
20:27:42 #
20:27:42 # Asylumius says 'Unpacking from hunting.'
20:29:13 #
20:29:13 # Darva has entered the game.
20:32:27 #
20:46:27 # The sun slowly disappears in the west.
20:46:49 #
20:46:49 # Darva says 'someone needs to mark this room as indoors.'
20:47:00 #
20:47:00 # Darva grumbles and growls. You wonder what's wrong…
20:47:28 #
20:47:28 # The night has begun.
20:49:27 #
20:49:27 # Darva has left the game.
20:50:03 #
20:50:03 # Asylumius chuckles politely.
20:56:27 #
20:59:27 # The rain stopped.
21:01:43 #
21:01:43 # Asylumius sighs.
21:01:44 #
21:01:44 # Asylumius has left the game.
21:10:27 #