[ScryMUD] SVN Commit Info r777 - in trunk: . mud/grrmud/server tools
scrymud at wanfear.com
scrymud at wanfear.com
Fri Dec 17 22:43:19 PST 2004
Author: eroper
Date: 2004-12-17 22:43:18 -0800 (Fri, 17 Dec 2004)
New Revision: 777
Added:
trunk/mud/grrmud/server/mapper.cc
trunk/mud/grrmud/server/mapper.h
trunk/tools/
trunk/tools/scrymapper.pl
Removed:
trunk/tools/scrymapper.pl
Modified:
trunk/mud/grrmud/server/Makefile
trunk/mud/grrmud/server/commands.cc
trunk/mud/grrmud/server/commands.h
trunk/mud/grrmud/server/gen_cmds.spec
trunk/mud/grrmud/server/grrmud.cc
trunk/mud/grrmud/server/misc.cc
trunk/mud/grrmud/server/zone.cc
trunk/mud/grrmud/server/zone.h
Log:
Merged 750:776 from the people/eroper/automapper branch.
Though not entirely where I'd like it to be, the current incarnation produces
maps useful for builders. Any further improvements are unlikely to cause any
major disruption to the codebase.
Commented out the automatic generation of maps at server startup from
grrmud.cc
Modified: trunk/mud/grrmud/server/Makefile
===================================================================
--- trunk/mud/grrmud/server/Makefile 2004-12-18 06:26:30 UTC (rev 776)
+++ trunk/mud/grrmud/server/Makefile 2004-12-18 06:43:18 UTC (rev 777)
@@ -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 \
Modified: trunk/mud/grrmud/server/commands.cc
===================================================================
--- trunk/mud/grrmud/server/commands.cc 2004-12-18 06:26:30 UTC (rev 776)
+++ trunk/mud/grrmud/server/commands.cc 2004-12-18 06:43:18 UTC (rev 777)
@@ -51,7 +51,6 @@
#include "Filters.h"
#include "clients.h"
-
int inventory(critter& pc) {
String buf(100);
@@ -4172,3 +4171,18 @@
return TRUE;
}//eq_put_by
+
+int make_maps(critter& pc) {
+ if (ok_to_do_action(NULL, "I", 0, pc, pc.getCurRoom(), NULL, TRUE)) {
+
+ if (pc.getImmLevel() <= 8) {
+ pc.show("You must be level IMM-9 or greater.\n");
+ return -1;
+ }
+
+ ZoneCollection::instance().createMapFiles();
+ return 0;
+ }
+ return -1;
+}//make_maps
+
Modified: trunk/mud/grrmud/server/commands.h
===================================================================
--- trunk/mud/grrmud/server/commands.h 2004-12-18 06:26:30 UTC (rev 776)
+++ trunk/mud/grrmud/server/commands.h 2004-12-18 06:43:18 UTC (rev 777)
@@ -147,5 +147,6 @@
int donate_eq_effects(object& obj, critter& pc, short do_msg);
int consume_eq_effects(object& obj, critter& pc, short do_msg);
+int make_maps(critter& pc);
#endif //include
Modified: trunk/mud/grrmud/server/gen_cmds.spec
===================================================================
--- trunk/mud/grrmud/server/gen_cmds.spec 2004-12-18 06:26:30 UTC (rev 776)
+++ trunk/mud/grrmud/server/gen_cmds.spec 2004-12-18 06:43:18 UTC (rev 777)
@@ -512,6 +512,8 @@
# IMM Commands - M
make_builder ~
return make_builder(i, &(cooked_strs[1]), pc);
+make_maps ~
+return make_maps(pc);
make_pso ~
return make_pso(i, &(cooked_strs[1]), pc);
mclear ~
Modified: trunk/mud/grrmud/server/grrmud.cc
===================================================================
--- trunk/mud/grrmud/server/grrmud.cc 2004-12-18 06:26:30 UTC (rev 776)
+++ trunk/mud/grrmud/server/grrmud.cc 2004-12-18 06:43:18 UTC (rev 777)
@@ -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();
Copied: trunk/mud/grrmud/server/mapper.cc (from rev 776, branches/people/eroper/automapper/mud/grrmud/server/mapper.cc)
Property changes on: trunk/mud/grrmud/server/mapper.cc
___________________________________________________________________
Name: svn:keywords
+ Id Author Date Revision
Copied: trunk/mud/grrmud/server/mapper.h (from rev 776, branches/people/eroper/automapper/mud/grrmud/server/mapper.h)
Property changes on: trunk/mud/grrmud/server/mapper.h
___________________________________________________________________
Name: svn:keywords
+ Id Author Date Revision
Modified: trunk/mud/grrmud/server/misc.cc
===================================================================
--- trunk/mud/grrmud/server/misc.cc 2004-12-18 06:26:30 UTC (rev 776)
+++ trunk/mud/grrmud/server/misc.cc 2004-12-18 06:43:18 UTC (rev 777)
@@ -3173,6 +3173,10 @@
String *dr_dir;
String *dst_dir;
+ if (! ok_to_do_action(NULL, "I", 0, pc, pc.getCurRoom(), NULL, TRUE)) {
+ return -1;
+ }
+
for(i=0;i<NUMBER_OF_ROOMS;i++) {
rm_ptr = &room_list[i];
if ( (rm_ptr) && (rm_ptr->isUsed()) &&
@@ -3204,6 +3208,24 @@
pc.show(buf);
//if it isn't reflexive in any direction.
} else {
+ //there's a way back
+
+ //warn us if the distances aren't the same in both directions
+ if ( dr_ptr->distance != dst_dr_ptr->distance ) {
+ Sprintf(buf, "^c[^B%d^c:^B%d^c:^B%S^c] ^m(^M%d^m)"
+ "^w--> <--"
+ "^m(^M%d^m) ^c[^B%d^c:^B%d^c:^B%S^c]"
+ " ^GDistance mismatch.\n"
+ "^cLHS: ^C%S ^cRHS: ^C%S\n\n^0",
+ rm_ptr->getZoneNum(), cur_rm_num, dr_dir,
+ dr_ptr->distance, dst_dr_ptr->distance,
+ dr_ptr->getDestRoom()->getZoneNum(),
+ chk_rm_num, dst_dir, &(rm_ptr->short_desc),
+ &(dr_ptr->getDestRoom()->short_desc));
+ pc.show(buf);
+
+ }
+
//if it does have a way back, make sure it's the opposite
//direction.
dr_dir = dr_ptr->getDirection();
Modified: trunk/mud/grrmud/server/zone.cc
===================================================================
--- trunk/mud/grrmud/server/zone.cc 2004-12-18 06:26:30 UTC (rev 776)
+++ trunk/mud/grrmud/server/zone.cc 2004-12-18 06:43:18 UTC (rev 777)
@@ -32,6 +32,7 @@
#include "misc2.h"
#include "command4.h"
#include "command5.h"
+#include "mapper.h"
int ZoneList::_cnt = 0; //instance count
@@ -407,7 +408,20 @@
}//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 " << i << " " << (const char*)(zone_list[i].getName())
+ << endl;
+ 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 +571,292 @@
return retval;
}//createNeatoFile
+String zone::createMapFile() {
+ String retval(10000);
+ String tmp_buf(1000);
+ Cell<door *> cll;
+ door* ptr;
+ int tmp, tmp_rm;
+ int counter;
+ String buf(100);
+ String *dr_dir;
+ int distance;
+ int start_room = begin_room_num;
+ int zone = room_list[start_room].getZoneNum();
+
+ // special start rooms for weird zones
+ switch (zone) {
+ case 0:
+ start_room = 22;
+ break;
+ case 29:
+ start_room = 2724;
+ break;
+ case 46:
+ start_room = 4480;
+ }
+
+ Tree2<int> tree(start_room);
+ Tree2Cell<int> par(tree);
+ Tree2Cell<int> par2;
+ 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);
+ Cell<maproom*> mrl_cll;
+
+ /* used so that we only walk up/down *after* fully exploring the current
+ * z-layer. This guarantees that up/down connections are correct as far as
+ * start/end rooms on each z-layer. Essentially this forces any skewing to
+ * be done to paths between rooms on the same z-layer rather than causing
+ * vertical collisions into the wrong area (connection room) of a different
+ * z-layer. These same z-layer distance skews/stretches are then easy to
+ * detect and fix due to the config-distance vs. map distance warning
+ * flags. Essentially we won't push these room numbers onto our BFS tree
+ * until we have exausted all same z-layer breadths.
+ */
+ List<int> vertical_rooms(0);
+ vertical_rooms.clear();
+ Cell<int> vr_cll;
+
+ maproom *cur_maproom;
+ maproom new_maproom;
+ maprooms my_rlist;
+
+ path* path_ptr = NULL;
+ zonepath* zpath_ptr = NULL;
+
+ new_maproom.num(start_room);
+ new_maproom.x(0);
+ new_maproom.y(0);
+ new_maproom.z(0);
+ new_maproom.zone(room_list[new_maproom.num()].getZoneNum());
+ new_maproom.placeholder(false);
+ my_rlist.gain(new_maproom);
+ room_list[new_maproom.num()].setFlag(29, TRUE);
+
+ 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);
+ new_maproom.zone(room_list[new_maproom.num()].getZoneNum());
+ new_maproom.placeholder(false);
+ new_maproom.collided(false);
+ new_maproom.water(false);
+ new_maproom.deepwater(false);
+ dr_dir = ptr->getDirection();
+ distance = ptr->distance + 1;
+
+ if (
+ (strcmp((const char*)(*dr_dir), "northeast") == 0) ||
+ (strcmp((const char*)(*dr_dir), "northwest") == 0) ||
+ (strcmp((const char*)(*dr_dir), "southeast") == 0) ||
+ (strcmp((const char*)(*dr_dir), "southwest") == 0) ||
+ (strcmp((const char*)(*dr_dir), "north") == 0) ||
+ (strcmp((const char*)(*dr_dir), "south") == 0) ||
+ (strcmp((const char*)(*dr_dir), "east") == 0) ||
+ (strcmp((const char*)(*dr_dir), "west") == 0) ||
+ (strcmp((const char*)(*dr_dir), "up") == 0) ||
+ (strcmp((const char*)(*dr_dir), "down") == 0)
+ ) {
+ if (
+ (new_maproom.zone() == zone) ||
+ (new_maproom.zone() == 17) || //garland shops & houses
+ (new_maproom.zone() == 22) //more garland shops & houses
+ ) {
+ // 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
+ path_ptr = new path;
+ path_ptr->start(cur_maproom->num());
+ path_ptr->end(new_maproom.num());
+ path_ptr->distance(distance);
+ path_list.append(path_ptr);
+ path_ptr = NULL;
+ } else {
+ // next room is in a different zone
+ zpath_ptr = new zonepath;
+ zpath_ptr->start(cur_maproom->num());
+ zpath_ptr->end(new_maproom.num());
+ zpath_ptr->distance(distance);
+ zpath_ptr->zone(new_maproom.zone());
+ zpath_list.append(zpath_ptr);
+ zpath_ptr = NULL;
+ }
+ }//valid direction
+
+ if ( !room_list[tmp_rm].getFlag(29) ) {
+
+ //place the room on a grid point.
+ if (strcmp((const char *)(*dr_dir), "northeast") == 0) {
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::NORTHEAST, distance);
+ } else if (strcmp((const char *)(*dr_dir), "southeast") == 0) {
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::SOUTHEAST, distance);
+ } else if (strcmp((const char *)(*dr_dir), "southwest") == 0) {
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::SOUTHWEST, distance);
+ } else if (strcmp((const char *)(*dr_dir), "northwest") == 0) {
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::NORTHWEST, distance);
+ } else if (strcmp((const char *)(*dr_dir), "north") == 0) {
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::NORTH, distance);
+ } else if (strcmp((const char *)(*dr_dir), "south") == 0) {
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::SOUTH, distance);
+ } else if (strcmp((const char *)(*dr_dir), "east") == 0) {
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::EAST, distance);
+ } else if (strcmp((const char *)(*dr_dir), "west") == 0) {
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::WEST, distance);
+ } else if (strcmp((const char *)(*dr_dir), "up") == 0) {
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::UP, distance);
+ } else if (strcmp((const char *)(*dr_dir), "down") == 0) {
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::DOWN, distance);
+ } else {
+ continue;
+ }
+
+ tmp_buf.clear();
+
+ //note any interesting characteristics about this new room.
+ if ( room_list[new_maproom.num()].isSmallWater() ) {
+ new_maproom.water(true);
+ }
+ if ( room_list[new_maproom.num()].isBigWater() ) {
+ new_maproom.deepwater(true);
+ }
+
+ if (
+ (new_maproom.zone() == zone) ||
+ (new_maproom.zone() == 17) || //garland shops & houses
+ (new_maproom.zone() == 22) //more garland shops & houses
+ ) {
+
+
+ /* if it's not a z-layer direction, add it to our tree,
+ * otherwise delay it until this z-layer is done
+ */
+ if (
+ (! strcmp((const char *)(*dr_dir), "up") == 0 ) &&
+ (! strcmp((const char *)(*dr_dir), "down") == 0 )
+ ) {
+ par.Push_Child(tmp_rm);
+ } else {
+ vertical_rooms.append(tmp_rm);
+ }
+
+ room_list[tmp_rm].setFlag(29, TRUE);
+ } else {
+ new_maproom.placeholder(true);
+ }
+
+ my_rlist.gain(new_maproom);
+
+ }//room isn't in list
+ }//doors left
+ par2 = par;
+ par.Next_Breadth();
+
+ /* if the current z-layer is depleted, push the vertical rooms that
+ * we've been queuing onto our tree
+ */
+ if ( (!par) && (!IsEmpty(vertical_rooms)) ) {
+ vertical_rooms.head(vr_cll);
+ while ( (tmp = vr_cll.next()) ) {
+ par2.Push_Child(tmp);
+ }
+ vertical_rooms.clear();
+ par = par2;
+ par.Next_Breadth();
+ }
+
+ }//while par
+ tcll.Head(tree);
+ while ( tcll ) {
+ counter = tcll.Next_Breadth();
+ 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() ) {
+ continue;
+ }
+ Sprintf(tmp_buf, "room %d %d %d %d",
+ cur_maproom->num(),
+ cur_maproom->x(),
+ cur_maproom->y(),
+ cur_maproom->z());
+ retval.append(tmp_buf);
+ if ( cur_maproom->collided() ) {
+ retval.append(" collided");
+ }
+ retval.append("\n");
+ }//while
+
+ maproom *start_rm;
+ maproom *end_rm;
+
+ path_list.head(path_cll);
+ while( (path_ptr = path_cll.next()) ) {
+ start_rm = my_rlist.byNum(path_ptr->start());
+ end_rm = my_rlist.byNum(path_ptr->end());
+ Sprintf(tmp_buf, "path %d-%d %d %d %d %d %d %d",
+ path_ptr->start(),
+ path_ptr->end(),
+ start_rm->x(),
+ start_rm->y(),
+ start_rm->z(),
+ end_rm->x(),
+ end_rm->y(),
+ end_rm->z());
+ retval.append(tmp_buf);
+ if (
+ ( abs((start_rm->x()-end_rm->x())) != path_ptr->distance() ) ||
+ ( abs((start_rm->y()-end_rm->y())) != path_ptr->distance() ) ||
+ ( abs((start_rm->z()-end_rm->z())) != path_ptr->distance() )
+ ) {
+ retval.append(" stretched");
+ }
+ retval.append("\n");
+ delete path_ptr;
+ }
+
+ zpath_list.head(zpath_cll);
+ while( (zpath_ptr = zpath_cll.next()) ) {
+ start_rm = my_rlist.byNum(zpath_ptr->start());
+ end_rm = my_rlist.byNum(zpath_ptr->end());
+ Sprintf(tmp_buf, "zonepath %d %d-%d %d %d %d %d %d %d\n",
+ zpath_ptr->zone(),
+ zpath_ptr->start(),
+ zpath_ptr->end(),
+ start_rm->x(),
+ start_rm->y(),
+ start_rm->z(),
+ end_rm->x(),
+ end_rm->y(),
+ end_rm->z());
+ retval.append(tmp_buf);
+ delete zpath_ptr;
+
+ }
+ return retval;
+}//createMapFile
+
void zone::spaceToNewlines(String& str) {
for (int i = 0; i<str.Strlen(); i++) {
if (isspace(str[i])) {
Modified: trunk/mud/grrmud/server/zone.h
===================================================================
--- trunk/mud/grrmud/server/zone.h 2004-12-18 06:26:30 UTC (rev 776)
+++ trunk/mud/grrmud/server/zone.h 2004-12-18 06:43:18 UTC (rev 777)
@@ -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"
@@ -121,6 +122,7 @@
int getEndRoomNum() const { return end_room_num; }
int getIdNum() const { return zone_num; }
int isInUse() const { return end_room_num > 0; }
+ const String &getName() { return zone_name; }
void resetTicksTillRegen() { ticks_till_regen = ticks_in_regen_cycle; }
void decrementTicksTillRegen() { ticks_till_regen--; }
@@ -153,6 +155,7 @@
* create a horribly complex looking graph of the zone!
*/
String createNeatoMapFile();
+ String createMapFile();
int isTotallyLoaded();
@@ -201,6 +204,7 @@
const String& name);
void createNeatoFiles();
+ void createMapFiles();
zone& getZoneFor(room& rm);
zone& elementAt(int i);
Copied: trunk/tools (from rev 776, branches/people/eroper/automapper/tools)
Deleted: trunk/tools/scrymapper.pl
===================================================================
--- branches/people/eroper/automapper/tools/scrymapper.pl 2004-12-18 06:26:30 UTC (rev 776)
+++ trunk/tools/scrymapper.pl 2004-12-18 06:43:18 UTC (rev 777)
@@ -1,241 +0,0 @@
-#!/usr/bin/perl
-
-# $Id$
-# Takes ScryMUD .map files and produces (sloppy) SVG files.
-# Copyright (C) 2004, Edward Roper <eroper at wanfear.com>
-
-# 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.
-
-sub doheader {
- print MAPFILE<<ENDOUT;
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
-"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
- id="svg1"
- sodipodi:version="0.32"
- inkscape:version="0.37"
- width="210mm"
- height="297mm"
- sodipodi:docbase="/home/eroper/docs/ScryMUD/mapmaker"
- sodipodi:docname="mapmaker.svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:xlink="http://www.w3.org/1999/xlink">
- <defs
- id="defs3" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="1.38926677"
- inkscape:cx="234.346519"
- inkscape:cy="753.365732"
- inkscape:window-width="640"
- inkscape:window-height="501"
- inkscape:window-x="383"
- inkscape:window-y="121"
- showgrid="true"
- snaptogrid="true"
- gridspacingx="5mm"
- gridspacingy="5mm"
- gridtolerance="1px"
- vertgrid="false" />
-ENDOUT
-}
-
-sub placebox {
-my ($x,$y,$rname,$color) = @_;
-print MAPFILE<<ENDOUT;
-<rect
- style="font-size:12;fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:$color;stroke-width:1.875;stroke-dasharray:none;stroke-linejoin:miter;"
- id="$rname"
- width="40.0"
- height="40.0"
- x="$x"
- y="$y"
- ry="8.0"
- rx="8.0" />
-ENDOUT
-}
-
-sub placeline {
- my($sx,$sy,$dx,$dy,$pname,$color) = @_;
- print MAPFILE<<ENDOUT;
- <path
- style="fill:none;fill-rule:evenodd;stroke:$color;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:round;fill-opacity:0.75;"
- d="M $sx $sy L $dx $dy"
- id="$pname" />
-ENDOUT
-}
-
-sub placetext {
- my($x,$y,$text) = @_;
- print MAPFILE<<ENDOUT;
-<text
- x="$x"
- y="$y"
- style="font-size:20.000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;fill:#000000;fill-opacity:1.0000000;stroke:none;stroke-width:1.0000000pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;font-family:Arial;text-anchor:start;writing-mode:lr"
- >
- $text
-</text>
-ENDOUT
-}
-
-
-$zone_num;
-$zone_name;
-
-$rnum = 0;
-$pnum = 0;
-$zpnum = 0;
-
- at rooms;
- at paths;
- at zpaths;
-
-$min_level = 0;
-$max_level = 0;
-$min_x = 0;
-$min_y = 0;
-
-while (<>) {
- chomp;
- if ( $_ =~ /^zone\s(\d+)\s([\w\s]+)$/ ) {
- $zone_num = $1;
- $zone_name = $2;
- } elsif ( $_ =~ /^room/ ) {
- ( $waste,
- $rooms[$rnum]{'rname'},
- $rooms[$rnum]{'qx'},
- $rooms[$rnum]{'qy'},
- $rooms[$rnum]{'qz'},
- $rooms[$rnum]{'collided'}
- ) = split;
-#print "$_ || $rooms[$rnum]{'qz'}\n";
- $rnum++;
- } elsif ( $_ =~ /^path/ ) {
- ( $waste,
- $paths[$pnum]{'pname'},
- $paths[$pnum]{'sx'},
- $paths[$pnum]{'sy'},
- $paths[$pnum]{'sz'},
- $paths[$pnum]{'dx'},
- $paths[$pnum]{'dy'},
- $paths[$pnum]{'dz'},
- $paths[$pnum]{'stretched'}
- ) = split;
- $pnum++;
- } elsif ( $_ =~ /^zonepath/ ) {
-
- ( $waste,
- $zpaths[$zpnum]{'zone'},
- $zpaths[$zpnum]{'pname'},
- $zpaths[$zpnum]{'sx'},
- $zpaths[$zpnum]{'sy'},
- $zpaths[$zpnum]{'sz'},
- $zpaths[$zpnum]{'dx'},
- $zpaths[$zpnum]{'dy'},
- $zpaths[$zpnum]{'dz'}
- ) = split;
- $zpnum++;
-
- }#if zonepath
-}#while there's more input
-
-#figure out the minimum and maximum z-layer.
-foreach $rm (@rooms) {
-
- if (int($rm->{'qz'}) > $max_level) {
- $max_level = $rm->{'qz'};
- } elsif (int($rm->{'qz'}) < $min_level) {
- $min_level = $rm->{'qz'};
- }
-
- if ($rm->{'qx'} < $min_x) {
- $min_x = $rm->{'qx'};
- }
- if ($rm->{'qy'} < $min_y) {
- $min_y = $rm->{'qy'};
- }
-
-}
-
-my $i;
-for ($i=$min_level;$i<=$max_level;$i++) {
- my $fname;
- if ($zone_num eq "") {
- next;
- }
- if ( $i >= 0 ) {
- $fname = sprintf("zone_%03d-level%03d.svg", $zone_num, $i);
- } else {
- $fname = sprintf("zone_%03d-sublevel%03d.svg", $zone_num, abs($i));
- }
- open MAPFILE, ">$fname";
-
- doheader();
-
- foreach $rm (@rooms) {
- if ( $rm->{'qz'} == $i ) {
- if ( $rm->{'collided'} ) {
- $color = "red";
- } else {
- $color = "black";
- }
- placebox($rm->{'qx'}*45, $rm->{'qy'}*45, $rm->{'rname'}, $color);
-#placenum($qx*45+2, $qy*45+20, $num++);
- }
- }
-
- foreach $pth (@paths) {
- if ( $pth->{'dz'} == $i ) {
- if ($pth->{'stretched'}) {
- $color = "red";
- } else {
- $color = "black";
- }
- $pth->{'sx'} = ( $pth->{'sx'}*45+20 );
- $pth->{'sy'} = ( $pth->{'sy'}*45+20 );
- $pth->{'dx'} = ( $pth->{'dx'}*45+20 );
- $pth->{'dy'} = ( $pth->{'dy'}*45+20 );
- placeline($pth->{'sx'},$pth->{'sy'},$pth->{'dx'},$pth->{'dy'},
- $pth->{'pname'}, $color);
- }
- }
-
- foreach $pth (@zpaths) {
- if ( $pth->{'dz'} == $i ) {
- $pth->{'sx'} = ( $pth->{'sx'}*45+20 );
- $pth->{'sy'} = ( $pth->{'sy'}*45+20 );
- $pth->{'dx'} = ( $pth->{'dx'}*45+20 );
- $pth->{'dy'} = ( $pth->{'dy'}*45+20 );
- placeline($pth->{'sx'},$pth->{'sy'},$pth->{'dx'},$pth->{'dy'},
- $pth->{'pname'}, "black");
- placetext($pth->{'dx'}+1, $pth->{'dy'}, $zone_num . ":" . $pth->{'zone'});
- }
- }
-
- placetext($min_x*45, $min_y*45-20, $zone_num . ":" . $zone_name .
- " layer: " . $i);
-
- print MAPFILE "</svg>\n";
- close MAPFILE;
-}#for()
Copied: trunk/tools/scrymapper.pl (from rev 776, branches/people/eroper/automapper/tools/scrymapper.pl)
Property changes on: trunk/tools/scrymapper.pl
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Id Author Date Revision
More information about the ScryMUD
mailing list