Re: [SNIPPET] Sea Warfare, the beginning

From: Thomas Arp (t_arp@stofanet.dk)
Date: 05/18/03


From: "Tristan Haynes" <natsirt86@YAHOO.COM>
> http://sse.wolfpaw.net/ships.snippet
>
Impressive snippet, I must say. Just noted a small performance hit:

void perform_slook(struct char_data *ch)
{
-  struct obj_data *ship = NULL, *i = NULL, *obj;
-  int ship_num, found = FALSE, k, door, len = 0;
+  struct obj_data *ship = NULL, *i = NULL;
+  int ship_num, k, door, len = 0;

  ship_num = world[IN_ROOM(ch)].ship_num - 1;

-  for (k = 0; k < top_of_world; k++) {
-    obj = world[k].contents;
-    for (i = obj; i; i = i->next_content) {
+  for (k = 0; k < top_of_world && !ship; k++) {
+    for (i = world[k].contents; i; i = i->next_content) {
      if (GET_OBJ_VNUM(i) == SHIP.ship_object) {
        ship = i;
-        found = TRUE;
      }
    }
  }

-  if (!found) {
+  if (!ship) {

Same thing in do_disembark - no need for the temp vars obj and found,
or to keep searching when you've found the room.

Great contribution! Keep it up.

Welcor

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/26/03 PDT