This is something I've been actually toying with the idea of rewriting
through an SQL perspective recently.
player enters game, insert them into an SQL temp table
player leaves game, remove them from said SQL temp table
player goes linkdead, remove them from SQL temp table
Any time a player connects, have it check the validity of SQL temp
table.
Why? Easy, because you're not dealing with the whole loopish code that
youre looking at right there.
Secondly, you can have the wholist sorted by level, rather easily
(SELECT * from who_table, ORDER by level)
Thirdly, what if you let your USERS make the options.
What do I mean? Well, say you set up a config option for your users to
allow THEM to sort the wholist how they wanted to (by clan, name, level,
guild, class, race, etc).. Would be unique ehh?
Fourthly, this'd virtually eliminate do_whois from the code. Sure, it'd
have to be there, but it'd simply be SELECT * from who_table where name
like %%s%, making the code just a little bit more efficient.
Of course, them's just my 0.02..
On Sat, 2002-07-13 at 18:25, Jeremy Hill wrote:
> Based on:
>
> int i;
> for (i = 1; i <= MAX_LEVEL; i++)
> {
> for ( d = descriptor_list; d != NULL; d = d->next )
> {
> CHAR_DATA *wch;
> ...
> (wch to descriptor)
> ...
> if (wch->level == i)
> print_to_who(wch);
> }
> }
>
> I figure this will work, but on a MUD with 310 levels and just 10 people on,
> it
> would generate 3,100 loops.
>
> A couple of questions:
> 1. In your expert opinion, is this a miserable way to do it? Pros? Cons? I
> figure sorting or qsorting the linked list of characters would be better.
>
> 2. Would it be easier to add players to the list of players on connect so they
> are automatically sorted by level?
>
>
> --
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
--
TJW :Head tech, designer, bum:P
Mud :http://dreamless.wolfstream.net
telnet :telnet://dreamless.wolfstream.net 9275
OLC Pages:http://olc.wolfstream.net