On Mon, 24 Feb 1997, Thomas Hansen wrote: > I'm trying to implement it on my mud so that players dont know each other > from the start, and instead of a normal room description, they might see: > > Now, anyone think of a more efficient way of storing my information about > who this players knows ? (memory_rec uses id_numbers but is a linked list) > Would an array of fixed size be better? And would I be able to make a fast > macro that way? I don't think you should worry about it. I use pretty much this system: PERS() is not a macro, but a function, that returns the pointer to a static string. The only thing to worry about then is that you don't use PERS() again without taking of the result of previous PERS(), e.g. sprintf (buf, "%s hits %s.\n", PERS(a,b), PERS(c,b)). I don't have my profile info handy, but though the PERS() function is called a lot, it uses nearly no time compared to things like combat update functions. I stored the numbers as an array: The 0th element is number of known people, then one integer for each person containg that person's ID. When checking if someone knows someone else, I run through all of it. If you really want to optimize it, I suppose you could pick out one byte of the 4-byte ID, and use memchr() to see if you can find it. I don't see it as a problem at present though. Having an array like this rather than a linked list does save some memory: at least 4 bytes for 'next' pointer + whatever overhead your memory manager gives. In addition to race, I also let each player pick an appearance, e.g. grumpy, dark-haired or so: other players then see "a grumpy elf leaves west" rather than just "an elf". I also have separate attribute for voice BTW, so if someone that you do not know shouts, you don't see their race, just, "A hoarse voice". Another thing to look out for are keywords: I use a function, get_name, which doesn't add the true name unless you know the person. It does add race and the attribute however. I don't use Circle but Envy, so not all of the above may apply to you :) ============================================================================== Erwin Andreasen Viby J, Denmark Computer Science Student at Aarhus Business erwin@pip.dknet.dk <URL:http://pip.dknet.dk/~pip1773/> College ============================================================================== +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | | Or send 'info circle' to majordomo@cspo.queensu.ca | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST