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

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


Author: eroper
Date: 2004-12-15 15:21:59 -0800 (Wed, 15 Dec 2004)
New Revision: 762

Added:
   branches/people/eroper/automapper/mud/grrmud/server/mapper.h
Modified:
   branches/people/eroper/automapper/mud/grrmud/server/zone.cc
Log:
Added mapper.h.
Paths/Zonepaths are now stored in lists. This will allow me to not calculate
their grid coordinates until all room collisions have been resolved.


Added: branches/people/eroper/automapper/mud/grrmud/server/mapper.h
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.h	2004-12-15 20:26:55 UTC (rev 761)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.h	2004-12-15 23:21:59 UTC (rev 762)
@@ -0,0 +1,50 @@
+// $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
+//
+
+#ifndef GRRMUD_MAPPER_INCLUDE_H
+#define GRRMUD_MAPPER_INCLUDE_H
+
+class path {
+   protected:
+      int start_room;
+      int end_room;
+      bool hidden;
+   public:
+      path() { start_room = -1; end_room = -1; hidden = false; }
+      int start(void) { return start_room; }
+      int end(void) { return end_room; }
+      int start(int s) { start_room = s; return start_room; }
+      int end(int e) { end_room = e; return end_room; }
+};
+
+class zonepath : public path {
+   protected:
+      int dst_zone;
+   public:
+      zonepath() { path(); dst_zone = -1; }
+      int zone(int z) { dst_zone = z; return dst_zone; }
+      int zone(void) { return dst_zone; }
+};
+
+#endif


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

Modified: branches/people/eroper/automapper/mud/grrmud/server/zone.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/zone.cc	2004-12-15 20:26:55 UTC (rev 761)
+++ branches/people/eroper/automapper/mud/grrmud/server/zone.cc	2004-12-15 23:21:59 UTC (rev 762)
@@ -32,6 +32,7 @@
 #include "misc2.h"
 #include "command4.h"
 #include "command5.h"
+#include "mapper.h"
 
 
 int ZoneList::_cnt = 0; //instance count
@@ -588,6 +589,14 @@
    Tree2Cell<int> par(tree);
    Tree2Cell<int> tcll;
 
+   List<path*> path_list(NULL);
+   Cell<path*> path_cll(path_list);
+   List<zonepath*> zpath_list(NULL);
+   Cell<zonepath*> zpath_cll(zpath_list);
+
+   path* path_ptr = NULL;
+   zonepath* zpath_ptr = NULL;
+
    memset(room_coords, 0, sizeof(room_coords));
 
    //current room coordinates
@@ -602,10 +611,6 @@
 
       while ( ( ptr = cll.next() ) ) {
          tmp_rm = abs(ptr->destination);
-         //also check for zone boundary here
-         //if ((!room_list[tmp_rm].getFlag(29)) &&
-         //      (room_list[tmp_rm].getZoneNum() == zone)) {
-
          dr_dir = ptr->getDirection();
 
          if (strcmp((const char *)(*dr_dir), "northeast") == 0) {
@@ -664,45 +669,24 @@
                   room_coords[tmp_rm][0], room_coords[tmp_rm][1],
                   room_coords[tmp_rm][2]);
             retval.append(tmp_buf);
-
-            /*
-               tmp_buf << "room " << tmp_rm << " " << room_coords[tmp_rm][0] << " "
-               << room_coords[tmp_rm][1] << " " << room_coords[tmp_rm][2] <<
-               endl;
-             */
          } else {
             if ( room_list[tmp_rm].getZoneNum() == zone ) {
                // next room is in the current zone. even if it's been
                //added to the bfs we do this or we don't get all paths
-               /*
-                  cout << "path " << par.Data() << "-" << tmp_rm << " " <<
-                  room_coords[par.Data()][0] << " " << room_coords[par.Data()][1]
-                  << " " << room_coords[par.Data()][2] << " " <<
-                  room_coords[tmp_rm][0] << " " << room_coords[tmp_rm][1] << " "
-                  << room_coords[tmp_rm][2] << endl; */
-               Sprintf(tmp_buf, "path %d-%d %d %d %d %d %d %d\n", par.Data(),
-                     tmp_rm, room_coords[par.Data()][0],
-                     room_coords[par.Data()][1], room_coords[par.Data()][2],
-                     room_coords[tmp_rm][0], room_coords[tmp_rm][1],
-                     room_coords[tmp_rm][2]);
-               retval.append(tmp_buf);
+               path_ptr = new path;
+               path_ptr->start(par.Data());
+               path_ptr->end(tmp_rm);
+               path_list.append(path_ptr);
+               path_ptr = NULL;
 
             } else {
                // next room is in a different zone
-               /*
-                  cout << "zonepath " << room_list[tmp_rm].getZoneNum() << " " <<
-                  par.Data() << "-" << tmp_rm << " " <<
-                  room_coords[par.Data()][0] << " " << room_coords[par.Data()][1]
-                  << " " << room_coords[par.Data()][2] << " " <<
-                  room_coords[tmp_rm][0] << " " << room_coords[tmp_rm][1] << " "
-                  << room_coords[tmp_rm][2] << endl;*/
-               Sprintf(tmp_buf, "zonepath %d %d-%d %d %d %d %d %d %d\n",
-                     room_list[tmp_rm].getZoneNum(), par.Data(),
-                     tmp_rm, room_coords[par.Data()][0],
-                     room_coords[par.Data()][1], room_coords[par.Data()][2],
-                     room_coords[tmp_rm][0], room_coords[tmp_rm][1],
-                     room_coords[tmp_rm][2]);
-               retval.append(tmp_buf);
+               zpath_ptr = new zonepath;
+               zpath_ptr->start(par.Data());
+               zpath_ptr->end(tmp_rm);
+               zpath_ptr->zone(room_list[tmp_rm].getZoneNum());
+               zpath_list.append(zpath_ptr);
+               zpath_ptr = NULL;
             }
          }
          //}//if not already in path
@@ -714,6 +698,37 @@
       counter = tcll.Next_Breadth();
       room_list[counter].setFlag(29, FALSE);
    }//while
+   path_list.head(path_cll);
+   while(path_cll.next()) {
+      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]);
+      retval.append(tmp_buf);
+      delete path_cll.item();
+
+   }
+   zpath_list.head(zpath_cll);
+   while(zpath_cll.next()) {
+      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]);
+      retval.append(tmp_buf);
+      delete zpath_cll.item();
+
+   }
    return retval;
 }//createMapFile
 




More information about the ScryMUD mailing list