> We need to get rid of the 'pointer twiddling' method of working with the > characters. Access the characters simply by their ID# and call various > methods/functions (pick your term) to modify values. Not only will this > make the code not crash, it'll allow characters to be stored in places that > cannot be described in terms of a pointer, like an SQL server or flat file. > Basically, a pair of set/accessor functions for each character part, based on idnum lookup? Sounds a bit annoying. Say I want to access the sex. ch->player->sex (or ch.player->sex depending on how you load up the file). My function should only require a unique player number. It should locate the character pointer, verify it's existance, verify the player structure existance, and then return the sex. If there are any problems, it will have to error out - in this case, returning a negative number. This is reasonable for this single function, but writing specific case functions for each member could end up to be time consuming. There should be a more easily extendable method. Perl-like hash tables? Some sort of structure registar for player/mob structs? There should be some way to make it as simple as possible, say one line of text, and the rest should be automatic. > In terms of now, I think instant extraction isn't too bad. All loops with > character extraction could be written with 'restart' logic to stop the > loop, go back to the beginning, and locate the next unprocessed character. > The only downside being that it would suck eggs through a straw. Well, yeah. :) As for the rest, the lists are setup in such a way that I don't ever have to worry about freezing/locking them. There are just three lists. Current, valid, invalid. Valid and invalid are only added too. Current has it's top member popped off, actions executed upon it. If it still exists at the end of it's actions, it's placed on the valid list. All to-be extractions remove their entry from the current list and are put on the invalid list. At the end, the current list will be empty - and so the valid and current lists switch. The invalid list is finally extracted. Repeat. This gets around the 'restart' logic; you simply ignore actions on an invalid - but still existant - player. It works, but the downside is that any actions (multiple hits, triggered spells, multiple weapons) all have to verify back through many levels of subroutines if they should stop. For example, if I call 'hit' _x_ number of times, and any one of those could result in my killing myself or my attacker. You end up having to write a difficult set of tests around the character; testing if he's been set invalid before each action. In the end, I copped out. I get around the multiple levels by using a global variable to indicate death or not. Still, it feels kludgy. I'll see if I can't write a general way using a sort of named lookup thing... get_value(chidnum,"gender"); or something.. PjD +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT