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

scrymud at wanfear.com scrymud at wanfear.com
Mon Dec 13 02:34:14 PST 2004


Author: eroper
Date: 2004-12-13 02:34:13 -0800 (Mon, 13 Dec 2004)
New Revision: 751

Modified:
   branches/people/eroper/automapper/mud/grrmud/server/grrmud.cc
   branches/people/eroper/automapper/mud/grrmud/server/zone.cc
   branches/people/eroper/automapper/mud/grrmud/server/zone.h
Log:
Everything is pretty much a mess (and in a state of flux) as far as the
auto mapper goes. It does however produce legible maps for most zones.

In it's current incarnation it will spit out one file per zone: i.e.
World/zone_0.map.

This map file contains data of three types:
(example data)
room 22 0 0 -1
path 17-22 0 1 0 0 0 0
zonepath 17 29-1498 2 0 0 2 0 -1

These lines break down as follows (with x,y,z as grid coordinates):
room room_number x_pos y_pos z_pos
path room_num-room_num start_x start_y start_z end_x end_y end_z
zonepath zone_num room_num-room_num start_x start_y start_z end_x end_y end_z

I currently have a perl script which will take these files as input and
produce SVG files as output. From here it's easy to drag overlapping rooms to
their correct position, resize, produce .png and stitch zones together. The
perl script is currently very quick and dirty and some (more) polished
incarnation will eventually end up committed here.

Since SVG isn't very heavyweight (XML based) I may eventually have ScryMUD
output the SVG files itself.

On the TODO list:
* Figure out some sort of automatic room-collision recovery algorithm.
* Mark hidden rooms, !violence rooms, shallow water, deep water, stores, etc.
* A builder command to specify an arbitrary start room for a map generation
  (ending at zone boundary). This may prove entirely unnecessary if a good
  collision repair algorithm is identified.

For now examples of the current output can be found here:
http://www.wanfear.com/~eroper/scry-automapper/

Entries of notable interest:
garland-fullauto.png: a non-modified run-result for zone 0.
garland-original.png: a non-modified run-result for zone 0. (different spacing)
big.png: a non-modified non zone boundary run starting at room #22
darthane.png: result of a 5 minute cleanup of the automatically generated map.

The darker shaded rooms indicate that two or more rooms have collided at this
coordinate. The darker the shade, the more collisions.



Modified: branches/people/eroper/automapper/mud/grrmud/server/grrmud.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/grrmud.cc	2004-12-13 10:13:36 UTC (rev 750)
+++ branches/people/eroper/automapper/mud/grrmud/server/grrmud.cc	2004-12-13 10:34:13 UTC (rev 751)
@@ -651,6 +651,7 @@
 
    ZoneList::instance().readSelf();
    ZoneList::instance().execute(); //modify zones as needed
+   ZoneCollection::instance().createMapFiles();
 
    // Read in the bug and idea list.
    bl_bugs.read();

Modified: branches/people/eroper/automapper/mud/grrmud/server/zone.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/zone.cc	2004-12-13 10:13:36 UTC (rev 750)
+++ branches/people/eroper/automapper/mud/grrmud/server/zone.cc	2004-12-13 10:34:13 UTC (rev 751)
@@ -407,7 +407,18 @@
    }//for
 }//createNeatoFiles
 
+void ZoneCollection::createMapFiles() {
+   String buf(100);
 
+   for (int i = 0; i<NUMBER_OF_ZONES; i++) {
+      if (zone_list[i].isInUse()) {
+         Sprintf(buf, "./World/zone_%i.map", i);
+         ofstream ofile(buf);
+         ofile << zone_list[i].createMapFile();
+      }//if
+   }//for
+}//createMapFiles
+
 void ZoneCollection::createNewZone(critter& pc, int num_ticks, int num_rooms,
                                    const String& name) {
    String buf(100);
@@ -557,7 +568,153 @@
    return retval;
 }//createNeatoFile
 
+String zone::createMapFile() {
+   String retval(10000);
+   String tmp_buf(1000);
+   Cell<door *> cll;
+   door* ptr;
+   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;
+
+   Tree2<int> tree(start_room);
+   Tree2Node<int>* tmp_child;
+   Tree2Cell<int> par(tree);
+   Tree2Cell<int> tcll;
+
+   memset(room_coords, 0, sizeof(room_coords));
+
+   //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);
+
+      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) {
+            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];
+         } 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];
+         } 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];
+         } 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];
+         } 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];
+         } 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];
+         } 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];
+         } 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];
+         } 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;
+         } 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;
+         } else {
+            continue;
+         }
+
+         tmp_buf.clear();
+         if (!room_list[tmp_rm].getFlag(29) &&
+               (room_list[tmp_rm].getZoneNum() == zone )) {
+            //if it's not already in our list and it's in the current
+            //zone.
+            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);
+
+            /*
+               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);
+
+            } 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);
+            }
+         }
+         //}//if not already in path
+      }//doors left
+      par.Next_Breadth();
+   }//while par
+   tcll.Head(tree);
+   while ( tcll ) {
+      counter = tcll.Next_Breadth();
+      room_list[counter].setFlag(29, FALSE);
+   }//while
+   return retval;
+}//createMapFile
+
 void zone::spaceToNewlines(String& str) {
    for (int i = 0; i<str.Strlen(); i++) {
       if (isspace(str[i])) {

Modified: branches/people/eroper/automapper/mud/grrmud/server/zone.h
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/zone.h	2004-12-13 10:13:36 UTC (rev 750)
+++ branches/people/eroper/automapper/mud/grrmud/server/zone.h	2004-12-13 10:34:13 UTC (rev 751)
@@ -34,6 +34,7 @@
 #include <stdlib.h>
 #include <PtrArray.h>
 #include <string2.h>
+#include <tree2.h>
 #include <list2.h>
 #include <bitfield.h>
 #include "const.h"
@@ -153,6 +154,7 @@
     * create a horribly complex looking graph of the zone!
     */
    String createNeatoMapFile(); 
+   String createMapFile();
 
 
    int isTotallyLoaded();
@@ -201,6 +203,7 @@
                       const String& name);
 
    void createNeatoFiles();
+   void createMapFiles();
 
    zone& getZoneFor(room& rm);
    zone& elementAt(int i);




More information about the ScryMUD mailing list