[ScryMUD] SVN Commit Info r773 - branches/people/eroper/automapper/mud/grrmud/server

scrymud at wanfear.com scrymud at wanfear.com
Fri Dec 17 17:15:02 PST 2004


Author: eroper
Date: 2004-12-17 17:15:01 -0800 (Fri, 17 Dec 2004)
New Revision: 773

Modified:
   branches/people/eroper/automapper/mud/grrmud/server/mapper.cc
   branches/people/eroper/automapper/mud/grrmud/server/mapper.h
   branches/people/eroper/automapper/mud/grrmud/server/zone.cc
Log:
Empty z-layers caused by door distance>0 on up/down exits are now "compressed"
so that we don't end up with blank map layers.


Modified: branches/people/eroper/automapper/mud/grrmud/server/mapper.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.cc	2004-12-18 00:54:45 UTC (rev 772)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.cc	2004-12-18 01:15:01 UTC (rev 773)
@@ -207,6 +207,59 @@
    return count;
 }
 
+int maprooms::min_z(void) {
+   int ret_val = 0;
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      ret_val = ( (ret_val > cur_rm->z()) ? cur_rm->z() : ret_val );
+   }
+   return ret_val;
+}//maprooms::min_z
+
+int maprooms::max_z(void) {
+   int ret_val = 0;
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      ret_val = ( (ret_val < cur_rm->z()) ? cur_rm->z() : ret_val );
+   }
+   return ret_val;
+}//maprooms::max_z
+
+int maprooms::compress_zlayers(void) {
+   int squash_count = 0;
+   bool used;
+   Cell<maproom*> cll;
+   Cell<maproom*> sq_cll;
+   maproom *cur_rm;
+   maproom *sq_rm;
+
+   //walk all z layers
+   for(int i=min_z();i<=max_z();i++) {
+      used = false;
+      rlist.head(cll);
+      while ( (cur_rm = cll.next()) ) {
+         if ( cur_rm->z() == i ) {
+            used = true;
+            break;
+         }//if
+      }//while
+
+      if ( !used ) {
+         //everything below this layer needs to shift up by one.
+         rlist.head(sq_cll);
+         while ( (sq_rm = cll.next()) ) {
+            if ( sq_rm->z() < i ) {
+               sq_rm->z(sq_rm->z()+1);
+            }//if
+         }//while more rooms
+         squash_count++;
+      }//if !used
+   }//for all z-layers
+   return squash_count;
+}//maprooms::compress_zlayers
+
 int maprooms::collision(direction dir, int range, maproom &test_rm) {
    int x,y,z;
    x = test_rm.x();

Modified: branches/people/eroper/automapper/mud/grrmud/server/mapper.h
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.h	2004-12-18 00:54:45 UTC (rev 772)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.h	2004-12-18 01:15:01 UTC (rev 773)
@@ -109,6 +109,10 @@
       int shift_u(int from_z, int count);
       int shift_d(int from_z, int count);
 
+      int min_z(void);
+      int max_z(void);
+      int compress_zlayers(void);
+
       maproom *byNum(int room_num);
       int collision(direction dir, int range, int x, int y, int z);
       int collision(direction dir, int range, maproom &test_rm);

Modified: branches/people/eroper/automapper/mud/grrmud/server/zone.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/zone.cc	2004-12-18 00:54:45 UTC (rev 772)
+++ branches/people/eroper/automapper/mud/grrmud/server/zone.cc	2004-12-18 01:15:01 UTC (rev 773)
@@ -844,6 +844,9 @@
       room_list[counter].setFlag(29, FALSE);
    }//while
 
+   //get rid of unused z-layers caused by distance>0 doors going up and down.
+   my_rlist.compress_zlayers();
+
    my_rlist.getList()->head(mrl_cll);
    while ( (cur_maproom = mrl_cll.next()) ) {
       if ( cur_maproom->placeholder() ) {




More information about the ScryMUD mailing list