[ScryMUD] SVN Commit Info r764 - branches/people/eroper/automapper/mud/grrmud/server
scrymud at wanfear.com
scrymud at wanfear.com
Wed Dec 15 23:42:53 PST 2004
Author: eroper
Date: 2004-12-15 23:42:52 -0800 (Wed, 15 Dec 2004)
New Revision: 764
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:
(mostly) retarded room collision avoidance works now. up/down collisions are
still unresolved.
Modified: branches/people/eroper/automapper/mud/grrmud/server/mapper.cc
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.cc 2004-12-16 01:21:58 UTC (rev 763)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.cc 2004-12-16 07:42:52 UTC (rev 764)
@@ -25,11 +25,22 @@
#include "mapper.h"
maprooms::maprooms() {
+ rlist.clear();
return;
}
-int maprooms::gain(maproom new_room) {
- rlist.append(new_room);
+maprooms::~maprooms() {
+ Cell<maproom*> cll(rlist);
+ maproom *cur_rm;
+ while ( (cur_rm = cll.next()) ) {
+ delete cur_rm;
+ }
+}
+
+int maprooms::gain(maproom &new_room) {
+ maproom *tmp = new maproom;
+ *tmp = new_room;
+ rlist.append(tmp);
return 0;
}
@@ -144,6 +155,14 @@
return 0;
}
+bool maprooms::collision(maproom &test_rm) {
+ int x,y,z;
+ x = test_rm.x();
+ y = test_rm.y();
+ z = test_rm.z();
+ return collision(x, y, z);
+}
+
bool maprooms::collision(int x, int y, int z) {
Cell<maproom*> cll(rlist);
maproom *cur_rm;
Modified: branches/people/eroper/automapper/mud/grrmud/server/mapper.h
===================================================================
--- branches/people/eroper/automapper/mud/grrmud/server/mapper.h 2004-12-16 01:21:58 UTC (rev 763)
+++ branches/people/eroper/automapper/mud/grrmud/server/mapper.h 2004-12-16 07:42:52 UTC (rev 764)
@@ -33,17 +33,21 @@
int xpos;
int ypos;
int zpos;
+ int zone_num;
bool iswater;
bool isdeepwater;
+ bool isplaceholder;
public:
maproom() {
room_num = 0;
xpos = 0;
- ypos=0;
- zpos=0;
+ ypos = 0;
+ zpos = 0;
+ zone_num = 0;
iswater = false;
isdeepwater = false;
+ isplaceholder = false;
}
int num(void) { return room_num; }
@@ -54,11 +58,16 @@
int y(int newval) { ypos = newval; return ypos; }
int z(void) { return zpos; }
int z(int newval) { zpos = newval; return zpos; }
+ int zone(void) { return zone_num; }
+ int zone(int newval) { zone_num = newval; return zone_num; }
bool water(void) { return iswater; }
bool water(bool newval) { iswater = newval; return iswater; }
bool deepwater(void) { return isdeepwater; }
bool deepwater(bool newval) { isdeepwater = newval; return isdeepwater; }
+ bool placeholder(void) { return isplaceholder; }
+ bool placeholder(bool newval) { isplaceholder = newval; return
+ isplaceholder; }
};
class maprooms {
@@ -66,10 +75,11 @@
PtrList<maproom> rlist;
public:
maprooms();
+ ~maprooms();
PtrList<maproom> *getList(void) { return &rlist; }
- int gain(maproom new_room);
+ int gain(maproom &new_room);
int shift_n(int from_y);
int shift_s(int from_y);
int shift_e(int from_x);
@@ -80,6 +90,7 @@
int shift_nw(int from_x, int from_y);
maproom *byNum(int room_num);
bool collision(int x, int y, int z);
+ bool maprooms::collision(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-16 01:21:58 UTC (rev 763)
+++ branches/people/eroper/automapper/mud/grrmud/server/zone.cc 2004-12-16 07:42:52 UTC (rev 764)
@@ -578,13 +578,21 @@
door* ptr;
int tmp_rm;
int counter;
+ int x,y,z;
String buf(100);
String *dr_dir;
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;
+ }
+
Tree2<int> tree(start_room);
- Tree2Node<int>* tmp_child;
Tree2Cell<int> par(tree);
Tree2Cell<int> tcll;
@@ -606,10 +614,11 @@
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);
- int zone = room_list[start_room].getZoneNum();
-
while ( par ) {
room_list[par.Data()].DOORS.head(cll);
cur_maproom = my_rlist.byNum(par.Data());
@@ -617,81 +626,180 @@
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);
dr_dir = ptr->getDirection();
- if (strcmp((const char *)(*dr_dir), "northeast") == 0) {
- new_maproom.x(cur_maproom->x()+1);
- new_maproom.y(cur_maproom->y()-1);
- new_maproom.z(cur_maproom->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.z(cur_maproom->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.z(cur_maproom->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.z(cur_maproom->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.z(cur_maproom->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.z(cur_maproom->z());
- } else if (strcmp((const char *)(*dr_dir), "east") == 0) {
- new_maproom.x(cur_maproom->x()+1);
- new_maproom.y(cur_maproom->y());
- new_maproom.z(cur_maproom->z());
- } else if (strcmp((const char *)(*dr_dir), "west") == 0) {
- new_maproom.x(cur_maproom->x()-1);
- new_maproom.y(cur_maproom->y());
- new_maproom.z(cur_maproom->z());
- } 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);
- } 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);
- } 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);
-
- my_rlist.gain(new_maproom);
- } else {
- if ( room_list[tmp_rm].getZoneNum() == zone ) {
+ 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(par.Data());
- path_ptr->end(tmp_rm);
+ path_ptr->start(cur_maproom->num());
+ path_ptr->end(new_maproom.num());
path_list.append(path_ptr);
path_ptr = NULL;
-
} else {
// next room is in a different zone
zpath_ptr = new zonepath;
- zpath_ptr->start(par.Data());
- zpath_ptr->end(tmp_rm);
- zpath_ptr->zone(room_list[tmp_rm].getZoneNum());
+ zpath_ptr->start(cur_maproom->num());
+ zpath_ptr->end(new_maproom.num());
+ zpath_ptr->zone(new_maproom.zone());
zpath_list.append(zpath_ptr);
zpath_ptr = NULL;
}
- }
+ }//valid direction
+
+ 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.z(cur_maproom->z());
+ if ( my_rlist.collision(new_maproom) ) {
+ x = cur_maproom->x();
+ y = cur_maproom->y();
+ z = cur_maproom->z();
+ my_rlist.shift_sw(cur_maproom->x(), cur_maproom->y());
+ 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.z(cur_maproom->z());
+ if ( my_rlist.collision(new_maproom) ) {
+ x = cur_maproom->x();
+ y = cur_maproom->y();
+ z = cur_maproom->z();
+ my_rlist.shift_nw(cur_maproom->x(), cur_maproom->y());
+ 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.z(cur_maproom->z());
+ if ( my_rlist.collision(new_maproom) ) {
+ x = cur_maproom->x();
+ y = cur_maproom->y();
+ z = cur_maproom->z();
+ my_rlist.shift_ne(cur_maproom->x(), cur_maproom->y());
+ 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.z(cur_maproom->z());
+ if ( my_rlist.collision(new_maproom) ) {
+ x = cur_maproom->x();
+ y = cur_maproom->y();
+ z = cur_maproom->z();
+ my_rlist.shift_se(cur_maproom->x(), cur_maproom->y());
+ 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.z(cur_maproom->z());
+ if ( my_rlist.collision(new_maproom) ) {
+ x = cur_maproom->x();
+ y = cur_maproom->y();
+ z = cur_maproom->z();
+ my_rlist.shift_s(cur_maproom->y());
+ 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.z(cur_maproom->z());
+ if ( my_rlist.collision(new_maproom) ) {
+ x = cur_maproom->x();
+ y = cur_maproom->y();
+ z = cur_maproom->z();
+ my_rlist.shift_n(cur_maproom->y());
+ 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.y(cur_maproom->y());
+ new_maproom.z(cur_maproom->z());
+ if ( my_rlist.collision(new_maproom) ) {
+ x = cur_maproom->x();
+ y = cur_maproom->y();
+ z = cur_maproom->z();
+ my_rlist.shift_w(cur_maproom->x());
+ 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.y(cur_maproom->y());
+ new_maproom.z(cur_maproom->z());
+ if ( my_rlist.collision(new_maproom) ) {
+ x = cur_maproom->x();
+ y = cur_maproom->y();
+ z = cur_maproom->z();
+ my_rlist.shift_e(cur_maproom->x());
+ new_maproom.x(x);
+ new_maproom.y(y);
+ new_maproom.z(z);
+ }
+ } 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);
+ } 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);
+ } else {
+ continue;
+ }
+
+ tmp_buf.clear();
+
+
+ if (
+ (new_maproom.zone() == zone) ||
+ (new_maproom.zone() == 17) || //garland shops & houses
+ (new_maproom.zone() == 22) //more garland shops & houses
+ ) {
+ par.Push_Child(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
par.Next_Breadth();
}//while par
@@ -703,6 +811,9 @@
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\n",
cur_maproom->num(),
cur_maproom->x(),
@@ -715,12 +826,12 @@
maproom *end_rm;
path_list.head(path_cll);
- while(path_cll.next()) {
- start_rm = my_rlist.byNum(path_cll.item()->start());
- end_rm = my_rlist.byNum(path_cll.item()->end());
+ 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\n",
- path_cll.item()->start(),
- path_cll.item()->end(),
+ path_ptr->start(),
+ path_ptr->end(),
start_rm->x(),
start_rm->y(),
start_rm->z(),
@@ -728,18 +839,17 @@
end_rm->y(),
end_rm->z());
retval.append(tmp_buf);
- delete path_cll.item();
-
+ delete path_ptr;
}
zpath_list.head(zpath_cll);
- while(zpath_cll.next()) {
- start_rm = my_rlist.byNum(path_cll.item()->start());
- end_rm = my_rlist.byNum(path_cll.item()->end());
+ 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_cll.item()->zone(),
- zpath_cll.item()->start(),
- zpath_cll.item()->end(),
+ zpath_ptr->zone(),
+ zpath_ptr->start(),
+ zpath_ptr->end(),
start_rm->x(),
start_rm->y(),
start_rm->z(),
@@ -747,7 +857,7 @@
end_rm->y(),
end_rm->z());
retval.append(tmp_buf);
- delete zpath_cll.item();
+ delete zpath_ptr;
}
return retval;
More information about the ScryMUD
mailing list