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

scrymud at wanfear.com scrymud at wanfear.com
Fri Dec 17 16:54:46 PST 2004


Author: eroper
Date: 2004-12-17 16:54:45 -0800 (Fri, 17 Dec 2004)
New Revision: 772

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:
Collision correction now handles the Z axis.


Modified: branches/people/eroper/automapper/mud/grrmud/server/mapper.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.cc	2004-12-17 11:44:33 UTC (rev 771)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.cc	2004-12-18 00:54:45 UTC (rev 772)
@@ -179,6 +179,34 @@
    return count;
 }
 
+int maprooms::shift_u(int from_z, int count) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   if ( count == 0 ) {
+      return 0;
+   }
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->z() >= from_z ) {
+         cur_rm->z(cur_rm->z()+count);
+      }
+   }
+   return count;
+}
+
+int maprooms::shift_d(int from_z, int count) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   if ( count == 0 ) {
+      return 0;
+   }
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->z() <= from_z ) {
+         cur_rm->z(cur_rm->z()-count);
+      }
+   }
+   return count;
+}
+
 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-17 11:44:33 UTC (rev 771)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.h	2004-12-18 00:54:45 UTC (rev 772)
@@ -106,6 +106,9 @@
       int shift_se(int from_x, int from_y, int count);
       int shift_sw(int from_x, int from_y, int count);
       int shift_nw(int from_x, int from_y, int count);
+      int shift_u(int from_z, int count);
+      int shift_d(int from_z, int count);
+
       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-17 11:44:33 UTC (rev 771)
+++ branches/people/eroper/automapper/mud/grrmud/server/zone.cc	2004-12-18 00:54:45 UTC (rev 772)
@@ -687,12 +687,12 @@
                         cur_maproom->y(), shift_by);
                   new_maproom.collided(true);
                }
-                  x = cur_maproom->x()+distance;
-                  y = cur_maproom->y()-distance;
-                  z = cur_maproom->z();
-                  new_maproom.x(x);
-                  new_maproom.y(y);
-                  new_maproom.z(z);
+               x = cur_maproom->x()+distance;
+               y = cur_maproom->y()-distance;
+               z = cur_maproom->z();
+               new_maproom.x(x);
+               new_maproom.y(y);
+               new_maproom.z(z);
             } else if (strcmp((const char *)(*dr_dir), "southeast") == 0) {
                if ( (shift_by = my_rlist.collision(maprooms::SOUTHEAST,
                            distance, *cur_maproom)) ) {
@@ -700,12 +700,12 @@
                         shift_by);
                   new_maproom.collided(true);
                }
-                  x = cur_maproom->x()+distance;
-                  y = cur_maproom->y()+distance;
-                  z = cur_maproom->z();
-                  new_maproom.x(x);
-                  new_maproom.y(y);
-                  new_maproom.z(z);
+               x = cur_maproom->x()+distance;
+               y = cur_maproom->y()+distance;
+               z = cur_maproom->z();
+               new_maproom.x(x);
+               new_maproom.y(y);
+               new_maproom.z(z);
             } else if (strcmp((const char *)(*dr_dir), "southwest") == 0) {
                if ( (shift_by = my_rlist.collision(maprooms::SOUTHWEST,
                            distance, *cur_maproom)) ) {
@@ -713,12 +713,12 @@
                         shift_by);
                   new_maproom.collided(true);
                }
-                  x = cur_maproom->x()-distance;
-                  y = cur_maproom->y()+distance;
-                  z = cur_maproom->z();
-                  new_maproom.x(x);
-                  new_maproom.y(y);
-                  new_maproom.z(z);
+               x = cur_maproom->x()-distance;
+               y = cur_maproom->y()+distance;
+               z = cur_maproom->z();
+               new_maproom.x(x);
+               new_maproom.y(y);
+               new_maproom.z(z);
             } else if (strcmp((const char *)(*dr_dir), "northwest") == 0) {
                new_maproom.x(cur_maproom->x()-1-distance);
                new_maproom.y(cur_maproom->y()-1-distance);
@@ -729,68 +729,84 @@
                         shift_by);
                   new_maproom.collided(true);
                }
-                  x = cur_maproom->x()-distance;
-                  y = cur_maproom->y()-distance;
-                  z = cur_maproom->z();
-                  new_maproom.x(x);
-                  new_maproom.y(y);
-                  new_maproom.z(z);
+               x = cur_maproom->x()-distance;
+               y = cur_maproom->y()-distance;
+               z = cur_maproom->z();
+               new_maproom.x(x);
+               new_maproom.y(y);
+               new_maproom.z(z);
             } else if (strcmp((const char *)(*dr_dir), "north") == 0) {
                if ( (shift_by = my_rlist.collision(maprooms::NORTH,
                            distance, *cur_maproom)) ) {
                   my_rlist.shift_s(cur_maproom->y(), shift_by);
                   new_maproom.collided(true);
                }
-                  x = cur_maproom->x();
-                  y = cur_maproom->y()-distance;
-                  z = cur_maproom->z();
-                  new_maproom.x(x);
-                  new_maproom.y(y);
-                  new_maproom.z(z);
+               x = cur_maproom->x();
+               y = cur_maproom->y()-distance;
+               z = cur_maproom->z();
+               new_maproom.x(x);
+               new_maproom.y(y);
+               new_maproom.z(z);
             } else if (strcmp((const char *)(*dr_dir), "south") == 0) {
                if ( (shift_by = my_rlist.collision(maprooms::SOUTH,
                            distance, *cur_maproom)) ) {
                   my_rlist.shift_n(cur_maproom->y(), shift_by);
                   new_maproom.collided(true);
                }
-                  x = cur_maproom->x();
-                  y = cur_maproom->y()+distance;
-                  z = cur_maproom->z();
-                  new_maproom.x(x);
-                  new_maproom.y(y);
-                  new_maproom.z(z);
+               x = cur_maproom->x();
+               y = cur_maproom->y()+distance;
+               z = cur_maproom->z();
+               new_maproom.x(x);
+               new_maproom.y(y);
+               new_maproom.z(z);
             } else if (strcmp((const char *)(*dr_dir), "east") == 0) {
                if ( (shift_by = my_rlist.collision(maprooms::EAST,
                            distance, *cur_maproom)) ) {
                   my_rlist.shift_w(cur_maproom->x(), shift_by);
                   new_maproom.collided(true);
                }
-                  x = cur_maproom->x()+distance;
-                  y = cur_maproom->y();
-                  z = cur_maproom->z();
-                  new_maproom.x(x);
-                  new_maproom.y(y);
-                  new_maproom.z(z);
+               x = cur_maproom->x()+distance;
+               y = cur_maproom->y();
+               z = cur_maproom->z();
+               new_maproom.x(x);
+               new_maproom.y(y);
+               new_maproom.z(z);
             } else if (strcmp((const char *)(*dr_dir), "west") == 0) {
                if ( (shift_by = my_rlist.collision(maprooms::WEST,
                            distance, *cur_maproom)) ) {
                   my_rlist.shift_e(cur_maproom->x(), shift_by );
                   new_maproom.collided(true);
                }
-                  x = cur_maproom->x()-distance;
-                  y = cur_maproom->y();
-                  z = cur_maproom->z();
-                  new_maproom.x(x);
-                  new_maproom.y(y);
-                  new_maproom.z(z);
+               x = cur_maproom->x()-distance;
+               y = cur_maproom->y();
+               z = cur_maproom->z();
+               new_maproom.x(x);
+               new_maproom.y(y);
+               new_maproom.z(z);
             } else if (strcmp((const char *)(*dr_dir), "up") == 0) {
-               new_maproom.x(cur_maproom->x());
-               new_maproom.y(cur_maproom->y());
-               new_maproom.z(cur_maproom->z()+distance);
+               if ( (shift_by = my_rlist.collision(maprooms::UP,
+                           distance, *cur_maproom)) ) {
+                  my_rlist.shift_d(cur_maproom->z(), shift_by);
+                  new_maproom.collided(true);
+               }
+               x = cur_maproom->x();
+               y = cur_maproom->y();
+               z = cur_maproom->z()+distance;
+               new_maproom.x(x);
+               new_maproom.y(y);
+               new_maproom.z(z);
             } else if (strcmp((const char *)(*dr_dir), "down") == 0) {
-               new_maproom.x(cur_maproom->x());
-               new_maproom.y(cur_maproom->y());
-               new_maproom.z(cur_maproom->z()-distance);
+               if ( (shift_by = my_rlist.collision(maprooms::DOWN,
+                           distance, *cur_maproom)) ) {
+                  my_rlist.shift_u(cur_maproom->z(), shift_by);
+                  new_maproom.collided(true);
+               }
+               x = cur_maproom->x();
+               y = cur_maproom->y();
+               z = cur_maproom->z()-distance;
+               new_maproom.x(x);
+               new_maproom.y(y);
+               new_maproom.z(z);
             } else {
                continue;
             }




More information about the ScryMUD mailing list