[ScryMUD] SVN Commit Info r767 - branches/people/eroper/automapper/mud/grrmud/server
scrymud at wanfear.com
scrymud at wanfear.com
Fri Dec 17 00:52:47 PST 2004
Author: eroper
Date: 2004-12-17 00:52:47 -0800 (Fri, 17 Dec 2004)
New Revision: 767
Modified:
branches/people/eroper/automapper/mud/grrmud/server/commands.cc
branches/people/eroper/automapper/mud/grrmud/server/commands.h
branches/people/eroper/automapper/mud/grrmud/server/gen_cmds.spec
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:
Door "distances" are now honored.
Added IMM (>=9) "make_maps" command. (got tired of restarting all the time)
Newly created issues:
Room collision correction on distance > 1 doors is sloppy. Rather than
shifting by the difference of the needed space and the available before
collision space we just shift the whole distance. It won't be hard to fix this
but I want to get the changes up to this point committed.
i.e.
[a] x x [b]
If [c] is to be added west of b at a distance of 3 we detect the collision and
shift [b] right by 3. We should see that we have 2 spaces before [a] and only
shift [b] by 1.
Modified: branches/people/eroper/automapper/mud/grrmud/server/commands.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/commands.cc 2004-12-17 02:37:04 UTC (rev 766)
+++ branches/people/eroper/automapper/mud/grrmud/server/commands.cc 2004-12-17 08:52:47 UTC (rev 767)
@@ -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: branches/people/eroper/automapper/mud/grrmud/server/commands.h
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/commands.h 2004-12-17 02:37:04 UTC (rev 766)
+++ branches/people/eroper/automapper/mud/grrmud/server/commands.h 2004-12-17 08:52:47 UTC (rev 767)
@@ -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: branches/people/eroper/automapper/mud/grrmud/server/gen_cmds.spec
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/gen_cmds.spec 2004-12-17 02:37:04 UTC (rev 766)
+++ branches/people/eroper/automapper/mud/grrmud/server/gen_cmds.spec 2004-12-17 08:52:47 UTC (rev 767)
@@ -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: branches/people/eroper/automapper/mud/grrmud/server/mapper.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.cc 2004-12-17 02:37:04 UTC (rev 766)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.cc 2004-12-17 08:52:47 UTC (rev 767)
@@ -55,125 +55,221 @@
return NULL;
}
-int maprooms::shift_n(int from_y) {
+int maprooms::shift_n(int from_y, int count) {
Cell<maproom*> cll(rlist);
maproom *cur_rm;
+ if ( count == 0 ) {
+ return 0;
+ }
while ( (cur_rm = cll.next()) ) {
if ( cur_rm->y() <= from_y ) {
- cur_rm->y(cur_rm->y()-1);
+ cur_rm->y(cur_rm->y()-count);
}
}
- return 0;
+ return count;
}
-int maprooms::shift_s(int from_y) {
+int maprooms::shift_s(int from_y, int count) {
Cell<maproom*> cll(rlist);
maproom *cur_rm;
+ if ( count == 0 ) {
+ return 0;
+ }
while ( (cur_rm = cll.next()) ) {
if ( cur_rm->y() >= from_y ) {
- cur_rm->y(cur_rm->y()+1);
+ cur_rm->y(cur_rm->y()+count);
}
}
- return 0;
+ return count;
}
-int maprooms::shift_e(int from_x) {
+int maprooms::shift_e(int from_x, int count) {
Cell<maproom*> cll(rlist);
maproom *cur_rm;
+ if ( count == 0 ) {
+ return 0;
+ }
while ( (cur_rm = cll.next()) ) {
if ( cur_rm->x() >= from_x ) {
- cur_rm->x(cur_rm->x()+1);
+ cur_rm->x(cur_rm->x()+count);
}
}
- return 0;
+ return count;
}
-int maprooms::shift_w(int from_x) {
+int maprooms::shift_w(int from_x, int count) {
Cell<maproom*> cll(rlist);
maproom *cur_rm;
+ if ( count == 0 ) {
+ return 0;
+ }
while ( (cur_rm = cll.next()) ) {
if ( cur_rm->x() <= from_x ) {
- cur_rm->x(cur_rm->x()-1);
+ cur_rm->x(cur_rm->x()-count);
}
}
- return 0;
+ return count;
}
-int maprooms::shift_ne(int from_x, int from_y) {
+int maprooms::shift_ne(int from_x, int from_y, int count) {
Cell<maproom*> cll(rlist);
maproom *cur_rm;
+ if ( count == 0 ) {
+ return 0;
+ }
while ( (cur_rm = cll.next()) ) {
if ( cur_rm->x() >= from_x ) {
- cur_rm->x(cur_rm->x()+1);
+ cur_rm->x(cur_rm->x()+count);
}
if ( cur_rm->y() <= from_y ) {
- cur_rm->y(cur_rm->y()-1);
+ cur_rm->y(cur_rm->y()-count);
}
}
- return 0;
+ return count;
}
-int maprooms::shift_se(int from_x, int from_y) {
+int maprooms::shift_se(int from_x, int from_y, int count) {
Cell<maproom*> cll(rlist);
maproom *cur_rm;
+ if ( count == 0 ) {
+ return 0;
+ }
while ( (cur_rm = cll.next()) ) {
if ( cur_rm->x() >= from_x ) {
- cur_rm->x(cur_rm->x()+1);
+ cur_rm->x(cur_rm->x()+count);
}
if ( cur_rm->y() >= from_y ) {
- cur_rm->y(cur_rm->y()+1);
+ cur_rm->y(cur_rm->y()+count);
}
}
- return 0;
+ return count;
}
-int maprooms::shift_sw(int from_x, int from_y) {
+int maprooms::shift_sw(int from_x, int from_y, int count) {
Cell<maproom*> cll(rlist);
maproom *cur_rm;
+ if ( count == 0 ) {
+ return 0;
+ }
while ( (cur_rm = cll.next()) ) {
if ( cur_rm->x() <= from_x ) {
- cur_rm->x(cur_rm->x()-1);
+ cur_rm->x(cur_rm->x()-count);
}
if ( cur_rm->y() >= from_y ) {
- cur_rm->y(cur_rm->y()+1);
+ cur_rm->y(cur_rm->y()+count);
}
}
- return 0;
+ return count;
}
-int maprooms::shift_nw(int from_x, int from_y) {
+int maprooms::shift_nw(int from_x, int from_y, int count) {
Cell<maproom*> cll(rlist);
maproom *cur_rm;
+ if ( count == 0 ) {
+ return 0;
+ }
while ( (cur_rm = cll.next()) ) {
if ( cur_rm->x() <= from_x ) {
- cur_rm->x(cur_rm->x()-1);
+ cur_rm->x(cur_rm->x()-count);
}
if ( cur_rm->y() <= from_y ) {
- cur_rm->y(cur_rm->y()-1);
+ cur_rm->y(cur_rm->y()-count);
}
}
- return 0;
+ return count;
}
-bool maprooms::collision(maproom &test_rm) {
+int maprooms::collision(direction dir, int range, maproom &test_rm) {
int x,y,z;
x = test_rm.x();
y = test_rm.y();
z = test_rm.z();
- return collision(x, y, z);
+ return collision(dir, range, x, y, z);
}
-bool maprooms::collision(int x, int y, int z) {
+int maprooms::collision(direction dir, int range, int x, int y, int z) {
Cell<maproom*> cll(rlist);
maproom *cur_rm;
+ int cdist = 0; //how far do we go before colliding
+ int i;
+
while ( (cur_rm = cll.next()) ) {
- if (
- (cur_rm->x() == x) &&
- (cur_rm->y() == y) &&
- (cur_rm->z() == z)
- ) {
- return true;
- }
+ switch (dir) {
+ case NORTH:
+ for(i=1;i<=range;i++) {
+ if ((cur_rm->x()==x)&&(cur_rm->y()==y-i)&&(cur_rm->z()==z)) {
+ cdist = ( (cdist>i||cdist==0) ? i : cdist );
+ }
+ }
+ break;
+ case SOUTH:
+ for(i=1;i<=range;i++) {
+ if ((cur_rm->x()==x)&&(cur_rm->y()==y+i)&&(cur_rm->z()==z)) {
+ cdist = ( (cdist>i||cdist==0) ? i : cdist );
+ }
+ }
+ break;
+ case EAST:
+ for(i=1;i<=range;i++) {
+ if ((cur_rm->x()==x+i)&&(cur_rm->y()==y)&&(cur_rm->z()==z)) {
+ cdist = ( (cdist>i||cdist==0) ? i : cdist );
+ }
+ }
+ break;
+ case WEST:
+ for(i=1;i<=range;i++) {
+ if ((cur_rm->x()==x-i)&&(cur_rm->y()==y)&&(cur_rm->z()==z)) {
+ cdist = ( (cdist>i||cdist==0) ? i : cdist );
+ }
+ }
+ break;
+ case NORTHEAST:
+ for(i=1;i<=range;i++) {
+ if ((cur_rm->x()==x+i)&&(cur_rm->y()==y-i)&&(cur_rm->z()==z)) {
+ cdist = ( (cdist>i||cdist==0) ? i : cdist );
+ }
+ }
+ break;
+ case SOUTHEAST:
+ for(i=1;i<=range;i++) {
+ if ((cur_rm->x()==x+i)&&(cur_rm->y()==y+i)&&(cur_rm->z()==z)) {
+ cdist = ( (cdist>i||cdist==0) ? i : cdist );
+ }
+ }
+ break;
+ case SOUTHWEST:
+ for(i=1;i<=range;i++) {
+ if ((cur_rm->x()==x-i)&&(cur_rm->y()==y+i)&&(cur_rm->z()==z)) {
+ cdist = ( (cdist>i||cdist==0) ? i : cdist );
+ }
+ }
+ break;
+ case NORTHWEST:
+ for(i=1;i<=range;i++) {
+ if ((cur_rm->x()==x-i)&&(cur_rm->y()==y-i)&&(cur_rm->z()==z)) {
+ cdist = ( (cdist>i||cdist==0) ? i : cdist );
+ }
+ }
+ break;
+ case UP:
+ for(i=1;i<=range;i++) {
+ if ((cur_rm->x()==x)&&(cur_rm->y()==y)&&(cur_rm->z()==z+i)) {
+ cdist = ( (cdist>i||cdist==0) ? i : cdist );
+ }
+ }
+ break;
+ case DOWN:
+ for(i=1;i<=range;i++) {
+ if ((cur_rm->x()==x)&&(cur_rm->y()==y)&&(cur_rm->z()==z-i)) {
+ cdist = ( (cdist>i||cdist==0) ? i : cdist );
+ }
+ }
+ break;
+ }//switch(dir)
+ }//while cur_rm
+
+ if ( cdist > 0) {
+ return ((range-cdist)+1); //amount of shift needed to avoid collision.
}
- return false;
-}
+ return 0;
+}//maprooms::collision()
Modified: branches/people/eroper/automapper/mud/grrmud/server/mapper.h
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.h 2004-12-17 02:37:04 UTC (rev 766)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.h 2004-12-17 08:52:47 UTC (rev 767)
@@ -77,20 +77,33 @@
maprooms();
~maprooms();
+ enum direction {
+ NORTH,
+ SOUTH,
+ EAST,
+ WEST,
+ NORTHEAST,
+ SOUTHEAST,
+ SOUTHWEST,
+ NORTHWEST,
+ UP,
+ DOWN
+ };
+
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);
+ int shift_n(int from_y, int count);
+ int shift_s(int from_y, int count);
+ int shift_e(int from_x, int count);
+ int shift_w(int from_x, int count);
+ int shift_ne(int from_x, int from_y, int count);
+ int shift_se(int from_x, int from_y, int count);
+ int shift_sw(int from_x, int from_y, int count);
+ int shift_nw(int from_x, int from_y, int count);
maproom *byNum(int room_num);
- bool collision(int x, int y, int z);
- bool maprooms::collision(maproom &test_rm);
+ int collision(direction dir, int range, int x, int y, int z);
+ int collision(direction dir, int range, maproom &test_rm);
};
class path {
Modified: branches/people/eroper/automapper/mud/grrmud/server/zone.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/zone.cc 2004-12-17 02:37:04 UTC (rev 766)
+++ branches/people/eroper/automapper/mud/grrmud/server/zone.cc 2004-12-17 08:52:47 UTC (rev 767)
@@ -581,6 +581,8 @@
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();
@@ -590,6 +592,11 @@
case 0:
start_room = 22;
break;
+ case 29:
+ start_room = 2724;
+ break;
+ case 46:
+ start_room = 4480;
}
Tree2<int> tree(start_room);
@@ -629,6 +636,7 @@
new_maproom.zone(room_list[new_maproom.num()].getZoneNum());
new_maproom.placeholder(false);
dr_dir = ptr->getDirection();
+ distance = ptr->distance;
if (
(strcmp((const char*)(*dr_dir), "northeast") == 0) ||
@@ -668,105 +676,117 @@
if ( !room_list[tmp_rm].getFlag(29) ) {
if (strcmp((const char *)(*dr_dir), "northeast") == 0) {
- new_maproom.x(cur_maproom->x()+1);
- new_maproom.y(cur_maproom->y()-1);
+ new_maproom.x(cur_maproom->x()+1+distance);
+ new_maproom.y(cur_maproom->y()-1-distance);
new_maproom.z(cur_maproom->z());
- if ( my_rlist.collision(new_maproom) ) {
+ if ( (shift_by = my_rlist.collision(maprooms::NORTHEAST,
+ distance+1, *cur_maproom)) ) {
x = cur_maproom->x();
y = cur_maproom->y();
z = cur_maproom->z();
- my_rlist.shift_sw(cur_maproom->x(), cur_maproom->y());
+ my_rlist.shift_sw(cur_maproom->x(),
+ cur_maproom->y(), shift_by);
new_maproom.x(x);
new_maproom.y(y);
new_maproom.z(z);
}
} else if (strcmp((const char *)(*dr_dir), "southeast") == 0) {
- new_maproom.x(cur_maproom->x()+1);
- new_maproom.y(cur_maproom->y()+1);
+ new_maproom.x(cur_maproom->x()+1+distance);
+ new_maproom.y(cur_maproom->y()+1+distance);
new_maproom.z(cur_maproom->z());
- if ( my_rlist.collision(new_maproom) ) {
+ if ( (shift_by = my_rlist.collision(maprooms::SOUTHEAST,
+ distance+1, *cur_maproom)) ) {
x = cur_maproom->x();
y = cur_maproom->y();
z = cur_maproom->z();
- my_rlist.shift_nw(cur_maproom->x(), cur_maproom->y());
+ my_rlist.shift_nw(cur_maproom->x(), cur_maproom->y(),
+ shift_by);
new_maproom.x(x);
new_maproom.y(y);
new_maproom.z(z);
}
} else if (strcmp((const char *)(*dr_dir), "southwest") == 0) {
- new_maproom.x(cur_maproom->x()-1);
- new_maproom.y(cur_maproom->y()+1);
+ new_maproom.x(cur_maproom->x()-1-distance);
+ new_maproom.y(cur_maproom->y()+1+distance);
new_maproom.z(cur_maproom->z());
- if ( my_rlist.collision(new_maproom) ) {
+ if ( (shift_by = my_rlist.collision(maprooms::SOUTHWEST,
+ distance+1, *cur_maproom)) ) {
x = cur_maproom->x();
y = cur_maproom->y();
z = cur_maproom->z();
- my_rlist.shift_ne(cur_maproom->x(), cur_maproom->y());
+ my_rlist.shift_ne(cur_maproom->x(), cur_maproom->y(),
+ shift_by);
new_maproom.x(x);
new_maproom.y(y);
new_maproom.z(z);
}
} else if (strcmp((const char *)(*dr_dir), "northwest") == 0) {
- new_maproom.x(cur_maproom->x()-1);
- new_maproom.y(cur_maproom->y()-1);
+ new_maproom.x(cur_maproom->x()-1-distance);
+ new_maproom.y(cur_maproom->y()-1-distance);
new_maproom.z(cur_maproom->z());
- if ( my_rlist.collision(new_maproom) ) {
+ if ( (shift_by = my_rlist.collision(maprooms::NORTHWEST,
+ distance+1, *cur_maproom)) ) {
x = cur_maproom->x();
y = cur_maproom->y();
z = cur_maproom->z();
- my_rlist.shift_se(cur_maproom->x(), cur_maproom->y());
+ my_rlist.shift_se(cur_maproom->x(), cur_maproom->y(),
+ shift_by);
new_maproom.x(x);
new_maproom.y(y);
new_maproom.z(z);
}
} else if (strcmp((const char *)(*dr_dir), "north") == 0) {
new_maproom.x(cur_maproom->x());
- new_maproom.y(cur_maproom->y()-1);
+ new_maproom.y(cur_maproom->y()-1-distance);
new_maproom.z(cur_maproom->z());
- if ( my_rlist.collision(new_maproom) ) {
+ if ( (shift_by = my_rlist.collision(maprooms::NORTH,
+ distance+1, *cur_maproom)) ) {
x = cur_maproom->x();
y = cur_maproom->y();
z = cur_maproom->z();
- my_rlist.shift_s(cur_maproom->y());
+ my_rlist.shift_s(cur_maproom->y(), shift_by);
new_maproom.x(x);
new_maproom.y(y);
new_maproom.z(z);
}
} else if (strcmp((const char *)(*dr_dir), "south") == 0) {
new_maproom.x(cur_maproom->x());
- new_maproom.y(cur_maproom->y()+1);
+ new_maproom.y(cur_maproom->y()+1+distance);
new_maproom.z(cur_maproom->z());
- if ( my_rlist.collision(new_maproom) ) {
+ if ( (shift_by = my_rlist.collision(maprooms::SOUTH,
+ distance+1, *cur_maproom)) ) {
x = cur_maproom->x();
y = cur_maproom->y();
z = cur_maproom->z();
- my_rlist.shift_n(cur_maproom->y());
+ my_rlist.shift_n(cur_maproom->y(), shift_by);
new_maproom.x(x);
new_maproom.y(y);
new_maproom.z(z);
}
} else if (strcmp((const char *)(*dr_dir), "east") == 0) {
- new_maproom.x(cur_maproom->x()+1);
+ new_maproom.x(cur_maproom->x()+1+distance);
new_maproom.y(cur_maproom->y());
new_maproom.z(cur_maproom->z());
- if ( my_rlist.collision(new_maproom) ) {
+ if ( (shift_by = my_rlist.collision(maprooms::EAST,
+ distance+1, *cur_maproom)) ) {
x = cur_maproom->x();
y = cur_maproom->y();
z = cur_maproom->z();
- my_rlist.shift_w(cur_maproom->x());
+ my_rlist.shift_w(cur_maproom->x(), shift_by);
new_maproom.x(x);
new_maproom.y(y);
new_maproom.z(z);
}
} else if (strcmp((const char *)(*dr_dir), "west") == 0) {
- new_maproom.x(cur_maproom->x()-1);
+ new_maproom.x(cur_maproom->x()-1-distance);
new_maproom.y(cur_maproom->y());
new_maproom.z(cur_maproom->z());
- if ( my_rlist.collision(new_maproom) ) {
+ if ( (shift_by = my_rlist.collision(maprooms::WEST,
+ distance+1, *cur_maproom)) ) {
x = cur_maproom->x();
y = cur_maproom->y();
z = cur_maproom->z();
- my_rlist.shift_e(cur_maproom->x());
+ my_rlist.shift_e(cur_maproom->x(), shift_by );
new_maproom.x(x);
new_maproom.y(y);
new_maproom.z(z);
@@ -774,11 +794,11 @@
} else if (strcmp((const char *)(*dr_dir), "up") == 0) {
new_maproom.x(cur_maproom->x());
new_maproom.y(cur_maproom->y());
- new_maproom.z(cur_maproom->z()+1);
+ new_maproom.z(cur_maproom->z()+1+distance);
} else if (strcmp((const char *)(*dr_dir), "down") == 0) {
new_maproom.x(cur_maproom->x());
new_maproom.y(cur_maproom->y());
- new_maproom.z(cur_maproom->z()-1);
+ new_maproom.z(cur_maproom->z()-1-distance);
} else {
continue;
}
More information about the ScryMUD
mailing list