[ScryMUD] SVN Commit Info r775 - branches/people/eroper/automapper/mud/grrmud/server
scrymud at wanfear.com
scrymud at wanfear.com
Fri Dec 17 19:54:35 PST 2004
Author: eroper
Date: 2004-12-17 19:54:34 -0800 (Fri, 17 Dec 2004)
New Revision: 775
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:
A little cleanup moving some of the workhorse stuff from zone.cc to mapper.cc.
Modified: branches/people/eroper/automapper/mud/grrmud/server/mapper.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.cc 2004-12-18 02:17:02 UTC (rev 774)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.cc 2004-12-18 03:54:34 UTC (rev 775)
@@ -354,3 +354,83 @@
}
return 0;
}//maprooms::collision()
+
+maproom &maprooms::placeroom(maproom ¤t, maproom &newroom,
+ const direction placement_dir, int distance) {
+ int shift_by;
+ int x, y, z;
+
+ //shift_by is 0 if we don't need to shift and the calls to shift_?? below
+ //will return immediately if passed a 0.
+ if ( (shift_by = collision(placement_dir, distance, current)) ) {
+ newroom.collided(true);
+ }
+
+ switch(placement_dir) {
+ case NORTHEAST:
+ shift_sw(current.x(), current.y(), shift_by);
+ x = current.x()+distance;
+ y = current.y()-distance;
+ z = current.z();
+ break;
+ case SOUTHEAST:
+ shift_nw(current.x(), current.y(), shift_by);
+ x = current.x()+distance;
+ y = current.y()+distance;
+ z = current.z();
+ break;
+ case SOUTHWEST:
+ shift_ne(current.x(), current.y(), shift_by);
+ x = current.x()-distance;
+ y = current.y()+distance;
+ z = current.z();
+ break;
+ case NORTHWEST:
+ shift_se(current.x(), current.y(), shift_by);
+ x = current.x()-distance;
+ y = current.y()-distance;
+ z = current.z();
+ break;
+ case NORTH:
+ shift_s(current.y(), shift_by);
+ x = current.x();
+ y = current.y()-distance;
+ z = current.z();
+ break;
+ case SOUTH:
+ shift_n(current.y(), shift_by);
+ x = current.x();
+ y = current.y()+distance;
+ z = current.z();
+ break;
+ case EAST:
+ shift_w(current.x(), shift_by);
+ x = current.x()+distance;
+ y = current.y();
+ z = current.z();
+ break;
+ case WEST:
+ shift_e(current.x(), shift_by);
+ x = current.x()-distance;
+ y = current.y();
+ z = current.z();
+ break;
+ case UP:
+ shift_d(current.z(), shift_by);
+ x = current.x();
+ y = current.y();
+ z = current.z()+distance;
+ break;
+ case DOWN:
+ shift_u(current.z(), shift_by);
+ x = current.x();
+ y = current.y();
+ z = current.z()-distance;
+ break;
+ }//switch
+
+ newroom.x(x);
+ newroom.y(y);
+ newroom.z(z);
+ return newroom;
+}//maprooms::placeroom
Modified: branches/people/eroper/automapper/mud/grrmud/server/mapper.h
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.h 2004-12-18 02:17:02 UTC (rev 774)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.h 2004-12-18 03:54:34 UTC (rev 775)
@@ -116,6 +116,9 @@
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);
+
+ maproom &placeroom(maproom ¤t, maproom &newroom,
+ const direction placement_dir, int distance);
};
class path {
Modified: branches/people/eroper/automapper/mud/grrmud/server/zone.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/zone.cc 2004-12-18 02:17:02 UTC (rev 774)
+++ branches/people/eroper/automapper/mud/grrmud/server/zone.cc 2004-12-18 03:54:34 UTC (rev 775)
@@ -578,11 +578,9 @@
door* ptr;
int tmp, tmp_rm;
int counter;
- int x,y,z;
String buf(100);
String *dr_dir;
int distance;
- int shift_by;
int start_room = begin_room_num;
int zone = room_list[start_room].getZoneNum();
@@ -694,133 +692,37 @@
if ( !room_list[tmp_rm].getFlag(29) ) {
+ //place the room on a grid point.
if (strcmp((const char *)(*dr_dir), "northeast") == 0) {
- if ( (shift_by = my_rlist.collision(maprooms::NORTHEAST,
- distance, *cur_maproom)) ) {
- my_rlist.shift_sw(cur_maproom->x(),
- 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);
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::NORTHEAST, distance);
} else if (strcmp((const char *)(*dr_dir), "southeast") == 0) {
- if ( (shift_by = my_rlist.collision(maprooms::SOUTHEAST,
- distance, *cur_maproom)) ) {
- my_rlist.shift_nw(cur_maproom->x(), 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);
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::SOUTHEAST, distance);
} else if (strcmp((const char *)(*dr_dir), "southwest") == 0) {
- if ( (shift_by = my_rlist.collision(maprooms::SOUTHWEST,
- distance, *cur_maproom)) ) {
- my_rlist.shift_ne(cur_maproom->x(), 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);
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::SOUTHWEST, distance);
} 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);
- new_maproom.z(cur_maproom->z());
- if ( (shift_by = my_rlist.collision(maprooms::NORTHWEST,
- distance, *cur_maproom)) ) {
- my_rlist.shift_se(cur_maproom->x(), 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);
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::NORTHWEST, distance);
} 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);
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::NORTH, distance);
} 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);
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::SOUTH, distance);
} 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);
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::EAST, distance);
} 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);
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::WEST, distance);
} else if (strcmp((const char *)(*dr_dir), "up") == 0) {
- 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);
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::UP, distance);
} else if (strcmp((const char *)(*dr_dir), "down") == 0) {
- 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);
+ my_rlist.placeroom(*cur_maproom, new_maproom,
+ maprooms::DOWN, distance);
} else {
continue;
}
@@ -870,7 +772,6 @@
* we've been queuing onto our tree
*/
if ( (!par) && (!IsEmpty(vertical_rooms)) ) {
- cerr << "Pushing vertical rooms...\n";
vertical_rooms.head(vr_cll);
while ( (tmp = vr_cll.next()) ) {
par2.Push_Child(tmp);
@@ -924,9 +825,9 @@
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() )
+ ( 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");
}
More information about the ScryMUD
mailing list