My coders are attempting to order out wholist by level, higher levs being on top, sorting down to lower levs. We're unsure of how to do it really, and we're just screwing around with stuff that works, forgetting about efficiency (yes, i know, *shudder*). It's not my project, really, so I can't modify the files, but the constant crashing of the mud is beginnning to annoy me greatly...so I'm trying to help out. Here it is, hacky as can be. Right after the while parser, they've added this: struct descriptor_data *sorted_list_head; struct descriptor_data *newd; struct descriptor_data *sorted_list_end; struct descriptor_data *utility_pointer; struct descriptor_data *current_node; int sockets_connected = 0; // Get number of descriptors to sort for (utility_pointer = descriptor_list; utility_pointer; utility_pointer = utility_pointer->next) sockets_connected++; // Start copying list with first node of d // There must be at least one because someone has to type who right?? // Set the current_node pointer to the node in d that we are on current_node = descriptor_list; /* create a new descriptor */ CREATE(newd, struct descriptor_data, 1); memset((char *) newd, 0, sizeof(struct descriptor_data)); // Circularly link the list and copy it to duplicate d format newd->next = newd; *newd = *current_node; // First node is the head of the new list sorted_list_head = newd; // It is also the last sorted_list_end = newd; // If there are more than 1 sockets connected, // add them to the list also. for(int sockets_done = 1; sockets_done < sockets_connected; sockets_done++) { // Go to next node in the d list current_node = current_node->next; /* create a new descriptor */ CREATE(newd, struct descriptor_data, 1); memset((char *) newd, 0, sizeof(struct descriptor_data)); // Copy the d node to the new node *newd = *current_node; // Does it go at the top of the list? if(GET_TOT_LEVEL(newd->character) > GET_TOT_LEVEL(sorted_list_head->character)) { newd->next = sorted_list_head; sorted_list_head = newd; } // Does it go at the bottom? if(GET_TOT_LEVEL(newd->character) <= GET_TOT_LEVEL(sorted_list_end->character)) { sorted_list_end->next = newd; newd->next = sorted_list_head; sorted_list_end = newd; } // It must go in the middle if it wasn't the other two // Start at the top and work down, comparing total level utility_pointer = sorted_list_head; while(utility_pointer->next != sorted_list_head) { if(GET_TOT_LEVEL(newd->character) > GET_TOT_LEVEL(current_node->next->character)) { newd->next = utility_pointer->next; utility_pointer->next = newd; } // Compare with next d node utility_pointer = utility_pointer->next; } } // end of for that inserts the rest of the nodes +------------------------------------------------------------+ | 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 : 12/15/00 PST