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

scrymud at wanfear.com scrymud at wanfear.com
Wed Dec 15 17:21:59 PST 2004


Author: eroper
Date: 2004-12-15 17:21:58 -0800 (Wed, 15 Dec 2004)
New Revision: 763

Added:
   branches/people/eroper/automapper/mud/grrmud/server/mapper.cc
Modified:
   branches/people/eroper/automapper/mud/grrmud/server/Makefile
   branches/people/eroper/automapper/mud/grrmud/server/mapper.h
   branches/people/eroper/automapper/mud/grrmud/server/zone.cc
Log:
Added mapper.cc.
This commit breaks compilation.
A few baby-steps closer to collision resolution.


Modified: branches/people/eroper/automapper/mud/grrmud/server/Makefile
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/Makefile	2004-12-15 23:21:59 UTC (rev 762)
+++ branches/people/eroper/automapper/mud/grrmud/server/Makefile	2004-12-16 01:21:58 UTC (rev 763)
@@ -23,7 +23,7 @@
 ez_spll.cc dam_spll.cc trv_spll.cc rm_spll.cc dam_skll.cc wep_skll.cc \
 ez_skll.cc social2.cc cr_skll.cc ar_skll.cc pet_spll.cc vehicle.cc \
 script.cc SkillSpell.cc zone.cc rm_parse.cc rm_cmds.cc obj_parse.cc \
-obj_cmds.cc BugEntry.cc MudStats.cc clients.cc ServerConfig.cc
+obj_cmds.cc BugEntry.cc MudStats.cc clients.cc ServerConfig.cc mapper.cc
 
 OBJS = parse_gen.o lang_strings.o classes.o object.o critter.o \
 Filters.o room.o door.o skills.o command3.o \
@@ -33,7 +33,8 @@
 ez_spll.o dam_spll.o trv_spll.o rm_spll.o dam_skll.o wep_skll.o \
 ez_skll.o social2.o cr_skll.o ar_skll.o pet_spll.o vehicle.o const.o \
 script.o SkillSpell.o zone.o rm_parse.o rm_cmds.o obj_parse.o \
-obj_cmds.o BuildInfo.o BugEntry.o MudStats.o clients.o ServerConfig.o
+obj_cmds.o BuildInfo.o BugEntry.o MudStats.o clients.o ServerConfig.o \
+mapper.o
 
 GEN_SPEC = gen_cmds.spec
 LANG_SPEC = translations.spec translations_classes.spec translation2.spec \

Added: branches/people/eroper/automapper/mud/grrmud/server/mapper.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.cc	2004-12-15 23:21:59 UTC (rev 762)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.cc	2004-12-16 01:21:58 UTC (rev 763)
@@ -0,0 +1,160 @@
+// $Id$
+
+//
+//ScryMUD Server Code
+//Copyright (C) 1998  Ben Greear
+//
+//This program is free software; you can redistribute it and/or
+//modify it under the terms of the GNU General Public License
+//as published by the Free Software Foundation; either version 2
+//of the License, or (at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+//
+// To contact the Author, Ben Greear:  greear at cyberhighway.net, (preferred)
+//                                     greearb at agcs.com
+//
+
+#include "mapper.h"
+
+maprooms::maprooms() {
+   return;
+}
+
+int maprooms::gain(maproom new_room) {
+   rlist.append(new_room);
+   return 0;
+}
+
+maproom *maprooms::byNum(int room_num) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->num() == room_num ) {
+         return cur_rm;
+      }
+   }
+   return NULL;
+}
+
+int maprooms::shift_n(int from_y) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->y() <= from_y ) {
+         cur_rm->y(cur_rm->y()-1);
+      }
+   }
+   return 0;
+}
+
+int maprooms::shift_s(int from_y) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->y() >= from_y ) {
+         cur_rm->y(cur_rm->y()+1);
+      }
+   }
+   return 0;
+}
+
+int maprooms::shift_e(int from_x) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->x() >= from_x ) {
+         cur_rm->x(cur_rm->x()+1);
+      }
+   }
+   return 0;
+}
+
+int maprooms::shift_w(int from_x) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->x() <= from_x ) {
+         cur_rm->x(cur_rm->x()-1);
+      }
+   }
+   return 0;
+}
+
+int maprooms::shift_ne(int from_x, int from_y) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->x() >= from_x ) {
+         cur_rm->x(cur_rm->x()+1);
+      }
+      if ( cur_rm->y() <= from_y ) {
+         cur_rm->y(cur_rm->y()-1);
+      }
+   }
+   return 0;
+}
+
+int maprooms::shift_se(int from_x, int from_y) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->x() >= from_x ) {
+         cur_rm->x(cur_rm->x()+1);
+      }
+      if ( cur_rm->y() >= from_y ) {
+         cur_rm->y(cur_rm->y()+1);
+      }
+   }
+   return 0;
+}
+
+int maprooms::shift_sw(int from_x, int from_y) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->x() <= from_x ) {
+         cur_rm->x(cur_rm->x()-1);
+      }
+      if ( cur_rm->y() >= from_y ) {
+         cur_rm->y(cur_rm->y()+1);
+      }
+   }
+   return 0;
+}
+
+int maprooms::shift_nw(int from_x, int from_y) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      if ( cur_rm->x() <= from_x ) {
+         cur_rm->x(cur_rm->x()-1);
+      }
+      if ( cur_rm->y() <= from_y ) {
+         cur_rm->y(cur_rm->y()-1);
+      }
+   }
+   return 0;
+}
+
+bool maprooms::collision(int x, int y, int z) {
+   Cell<maproom*> cll(rlist);
+   maproom *cur_rm;
+   while ( (cur_rm = cll.next()) ) {
+      if (
+            (cur_rm->x() == x) &&
+            (cur_rm->y() == y) &&
+            (cur_rm->z() == z)
+         ) {
+         return true;
+      }
+   }
+   return false;
+}


Property changes on: branches/people/eroper/automapper/mud/grrmud/server/mapper.cc
___________________________________________________________________
Name: svn:keywords
   + Id Author Date Revision

Modified: branches/people/eroper/automapper/mud/grrmud/server/mapper.h
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.h	2004-12-15 23:21:59 UTC (rev 762)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.h	2004-12-16 01:21:58 UTC (rev 763)
@@ -25,6 +25,63 @@
 #ifndef GRRMUD_MAPPER_INCLUDE_H
 #define GRRMUD_MAPPER_INCLUDE_H
 
+#include <list2.h>
+
+class maproom {
+   protected:
+      int room_num;
+      int xpos;
+      int ypos;
+      int zpos;
+      bool iswater;
+      bool isdeepwater;
+
+   public:
+      maproom() {
+         room_num = 0;
+         xpos = 0;
+         ypos=0;
+         zpos=0;
+         iswater = false;
+         isdeepwater = false;
+      }
+
+      int num(void) { return room_num; }
+      int num(int newval) { room_num = newval; return room_num; }
+      int x(void) { return xpos; }
+      int x(int newval) { xpos = newval; return xpos; }
+      int y(void) { return ypos; }
+      int y(int newval) { ypos = newval; return ypos; }
+      int z(void) { return zpos; }
+      int z(int newval) { zpos = newval; return zpos; }
+
+      bool water(void) { return iswater; }
+      bool water(bool newval) { iswater = newval; return iswater; }
+      bool deepwater(void) { return isdeepwater; }
+      bool deepwater(bool newval) { isdeepwater = newval; return isdeepwater; }
+};
+
+class maprooms {
+   protected:
+      PtrList<maproom> rlist;
+   public:
+      maprooms();
+
+      PtrList<maproom> *getList(void) { return &rlist; }
+
+      int gain(maproom new_room);
+      int shift_n(int from_y);
+      int shift_s(int from_y);
+      int shift_e(int from_x);
+      int shift_w(int from_x);
+      int shift_ne(int from_x, int from_y);
+      int shift_se(int from_x, int from_y);
+      int shift_sw(int from_x, int from_y);
+      int shift_nw(int from_x, int from_y);
+      maproom *byNum(int room_num);
+      bool collision(int x, int y, int z);
+};
+
 class path {
    protected:
       int start_room;

Modified: branches/people/eroper/automapper/mud/grrmud/server/zone.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/zone.cc	2004-12-15 23:21:59 UTC (rev 762)
+++ branches/people/eroper/automapper/mud/grrmud/server/zone.cc	2004-12-16 01:21:58 UTC (rev 763)
@@ -579,7 +579,6 @@
    int tmp_rm;
    int counter;
    String buf(100);
-   int room_coords[NUMBER_OF_ROOMS + 1][3];
    String *dr_dir;
 
    int start_room = begin_room_num;
@@ -593,66 +592,73 @@
    Cell<path*> path_cll(path_list);
    List<zonepath*> zpath_list(NULL);
    Cell<zonepath*> zpath_cll(zpath_list);
+   Cell<maproom*> mrl_cll;
 
+
+   maproom *cur_maproom;
+   maproom new_maproom;
+   maprooms my_rlist;
+
    path* path_ptr = NULL;
    zonepath* zpath_ptr = NULL;
 
-   memset(room_coords, 0, sizeof(room_coords));
+   new_maproom.num(start_room);
+   new_maproom.x(0);
+   new_maproom.y(0);
+   new_maproom.z(0);
+   my_rlist.gain(new_maproom);
 
-   //current room coordinates
-   room_coords[start_room][0] = 0;
-   room_coords[start_room][1] = 0;
-   room_coords[start_room][2] = 0;
-
    int zone = room_list[start_room].getZoneNum();
 
    while ( par ) {
       room_list[par.Data()].DOORS.head(cll);
+      cur_maproom = my_rlist.byNum(par.Data());
 
       while ( ( ptr = cll.next() ) ) {
          tmp_rm = abs(ptr->destination);
+         new_maproom.num(tmp_rm);
          dr_dir = ptr->getDirection();
 
          if (strcmp((const char *)(*dr_dir), "northeast") == 0) {
-            room_coords[tmp_rm][0] = room_coords[par.Data()][0]+1;
-            room_coords[tmp_rm][1] = room_coords[par.Data()][1]-1;
-            room_coords[tmp_rm][2] = room_coords[par.Data()][2];
+            new_maproom.x(cur_maproom->x()+1);
+            new_maproom.y(cur_maproom->y()-1);
+            new_maproom.z(cur_maproom->z());
          } else if (strcmp((const char *)(*dr_dir), "southeast") == 0) {
-            room_coords[tmp_rm][0] = room_coords[par.Data()][0]+1;
-            room_coords[tmp_rm][1] = room_coords[par.Data()][1]+1;
-            room_coords[tmp_rm][2] = room_coords[par.Data()][2];
+            new_maproom.x(cur_maproom->x()+1);
+            new_maproom.y(cur_maproom->y()+1);
+            new_maproom.z(cur_maproom->z());
          } else if (strcmp((const char *)(*dr_dir), "southwest") == 0) {
-            room_coords[tmp_rm][0] = room_coords[par.Data()][0]-1;
-            room_coords[tmp_rm][1] = room_coords[par.Data()][1]+1;
-            room_coords[tmp_rm][2] = room_coords[par.Data()][2];
+            new_maproom.x(cur_maproom->x()-1);
+            new_maproom.y(cur_maproom->y()+1);
+            new_maproom.z(cur_maproom->z());
          } else if (strcmp((const char *)(*dr_dir), "northwest") == 0) {
-            room_coords[tmp_rm][0] = room_coords[par.Data()][0]-1;
-            room_coords[tmp_rm][1] = room_coords[par.Data()][1]-1;
-            room_coords[tmp_rm][2] = room_coords[par.Data()][2];
+            new_maproom.x(cur_maproom->x()-1);
+            new_maproom.y(cur_maproom->y()-1);
+            new_maproom.z(cur_maproom->z());
          } else if (strcmp((const char *)(*dr_dir), "north") == 0) {
-            room_coords[tmp_rm][0] = room_coords[par.Data()][0];
-            room_coords[tmp_rm][1] = room_coords[par.Data()][1]-1;
-            room_coords[tmp_rm][2] = room_coords[par.Data()][2];
+            new_maproom.x(cur_maproom->x());
+            new_maproom.y(cur_maproom->y()-1);
+            new_maproom.z(cur_maproom->z());
          } else if (strcmp((const char *)(*dr_dir), "south") == 0) {
-            room_coords[tmp_rm][0] = room_coords[par.Data()][0];
-            room_coords[tmp_rm][1] = room_coords[par.Data()][1]+1;
-            room_coords[tmp_rm][2] = room_coords[par.Data()][2];
+            new_maproom.x(cur_maproom->x());
+            new_maproom.y(cur_maproom->y()+1);
+            new_maproom.z(cur_maproom->z());
          } else if (strcmp((const char *)(*dr_dir), "east") == 0) {
-            room_coords[tmp_rm][0] = room_coords[par.Data()][0]+1;
-            room_coords[tmp_rm][1] = room_coords[par.Data()][1];
-            room_coords[tmp_rm][2] = room_coords[par.Data()][2];
+            new_maproom.x(cur_maproom->x()+1);
+            new_maproom.y(cur_maproom->y());
+            new_maproom.z(cur_maproom->z());
          } else if (strcmp((const char *)(*dr_dir), "west") == 0) {
-            room_coords[tmp_rm][0] = room_coords[par.Data()][0]-1;
-            room_coords[tmp_rm][1] = room_coords[par.Data()][1];
-            room_coords[tmp_rm][2] = room_coords[par.Data()][2];
+            new_maproom.x(cur_maproom->x()-1);
+            new_maproom.y(cur_maproom->y());
+            new_maproom.z(cur_maproom->z());
          } else if (strcmp((const char *)(*dr_dir), "up") == 0) {
-            room_coords[tmp_rm][0] = room_coords[par.Data()][0];
-            room_coords[tmp_rm][1] = room_coords[par.Data()][1];
-            room_coords[tmp_rm][2] = room_coords[par.Data()][2]+1;
+            new_maproom.x(cur_maproom->x());
+            new_maproom.y(cur_maproom->y());
+            new_maproom.z(cur_maproom->z()+1);
          } else if (strcmp((const char *)(*dr_dir), "down") == 0) {
-            room_coords[tmp_rm][0] = room_coords[par.Data()][0];
-            room_coords[tmp_rm][1] = room_coords[par.Data()][1];
-            room_coords[tmp_rm][2] = room_coords[par.Data()][2]-1;
+            new_maproom.x(cur_maproom->x());
+            new_maproom.y(cur_maproom->y());
+            new_maproom.z(cur_maproom->z()-1);
          } else {
             continue;
          }
@@ -665,10 +671,7 @@
             tmp_child = par.Push_Child(tmp_rm);
             room_list[tmp_rm].setFlag(29, TRUE);
 
-            Sprintf(tmp_buf, "room %d %d %d %d\n", tmp_rm,
-                  room_coords[tmp_rm][0], room_coords[tmp_rm][1],
-                  room_coords[tmp_rm][2]);
-            retval.append(tmp_buf);
+            my_rlist.gain(new_maproom);
          } else {
             if ( room_list[tmp_rm].getZoneNum() == zone ) {
                // next room is in the current zone. even if it's been
@@ -689,7 +692,6 @@
                zpath_ptr = NULL;
             }
          }
-         //}//if not already in path
       }//doors left
       par.Next_Breadth();
    }//while par
@@ -698,33 +700,52 @@
       counter = tcll.Next_Breadth();
       room_list[counter].setFlag(29, FALSE);
    }//while
+
+   my_rlist.getList()->head(mrl_cll);
+   while ( (cur_maproom = mrl_cll.next()) ) {
+      Sprintf(tmp_buf, "room %d %d %d %d\n",
+            cur_maproom->num(),
+            cur_maproom->x(),
+            cur_maproom->y(),
+            cur_maproom->z());
+      retval.append(tmp_buf);
+   }
+
+   maproom *start_rm;
+   maproom *end_rm;
+
    path_list.head(path_cll);
    while(path_cll.next()) {
+      start_rm = my_rlist.byNum(path_cll.item()->start());
+      end_rm = my_rlist.byNum(path_cll.item()->end());
       Sprintf(tmp_buf, "path %d-%d %d %d %d %d %d %d\n",
             path_cll.item()->start(),
             path_cll.item()->end(),
-            room_coords[path_cll.item()->start()][0],
-            room_coords[path_cll.item()->start()][1],
-            room_coords[path_cll.item()->start()][2],
-            room_coords[path_cll.item()->end()][0],
-            room_coords[path_cll.item()->end()][1],
-            room_coords[path_cll.item()->end()][2]);
+            start_rm->x(),
+            start_rm->y(),
+            start_rm->z(),
+            end_rm->x(),
+            end_rm->y(),
+            end_rm->z());
       retval.append(tmp_buf);
       delete path_cll.item();
 
    }
+
    zpath_list.head(zpath_cll);
    while(zpath_cll.next()) {
+      start_rm = my_rlist.byNum(path_cll.item()->start());
+      end_rm = my_rlist.byNum(path_cll.item()->end());
       Sprintf(tmp_buf, "zonepath %d %d-%d %d %d %d %d %d %d\n",
             zpath_cll.item()->zone(),
             zpath_cll.item()->start(),
             zpath_cll.item()->end(),
-            room_coords[zpath_cll.item()->start()][0],
-            room_coords[zpath_cll.item()->start()][1],
-            room_coords[zpath_cll.item()->start()][2],
-            room_coords[zpath_cll.item()->end()][0],
-            room_coords[zpath_cll.item()->end()][1],
-            room_coords[zpath_cll.item()->end()][2]);
+            start_rm->x(),
+            start_rm->y(),
+            start_rm->z(),
+            end_rm->x(),
+            end_rm->y(),
+            end_rm->z());
       retval.append(tmp_buf);
       delete zpath_cll.item();
 




More information about the ScryMUD mailing list