protected void fillExitsOfGridRoom(Room R, int x, int y) { if ((x < 0) || (y < 0) || (y >= yGridSize()) || (x >= xGridSize())) return; synchronized (R.baseEnvStats()) { int mask = R.baseEnvStats().sensesMask(); if (CMath.bset(mask, EnvStats.SENSE_ROOMGRIDSYNC)) return; R.baseEnvStats().setSensesMask(mask | EnvStats.SENSE_ROOMGRIDSYNC); } // the adjacent rooms created by this method should also take // into account the possibility that they are on the edge. // it does NOT if (ox == null) ox = CMClass.getExit("Open"); Room R2 = null; if (y > 0) { R2 = getMakeSingleGridRoom(x, y - 1); if (R2 != null) linkRoom(R, R2, Directions.NORTH, ox, ox); } else if ((rawDoors()[Directions.NORTH] != null) && (exits[Directions.NORTH] != null)) linkRoom( R, rawDoors()[Directions.NORTH], Directions.NORTH, exits[Directions.NORTH], exits[Directions.NORTH]); if (x > 0) { R2 = getMakeSingleGridRoom(x - 1, y); if (R2 != null) linkRoom(R, R2, Directions.WEST, ox, ox); } else if ((rawDoors()[Directions.WEST] != null) && (exits[Directions.WEST] != null)) linkRoom( R, rawDoors()[Directions.WEST], Directions.WEST, exits[Directions.WEST], exits[Directions.WEST]); if (y < (yGridSize() - 1)) { R2 = getMakeSingleGridRoom(x, y + 1); if (R2 != null) linkRoom(R, R2, Directions.SOUTH, ox, ox); } else if ((rawDoors()[Directions.SOUTH] != null) && (exits[Directions.SOUTH] != null)) linkRoom( R, rawDoors()[Directions.SOUTH], Directions.SOUTH, exits[Directions.SOUTH], exits[Directions.SOUTH]); if (x < (xGridSize() - 1)) { R2 = getMakeSingleGridRoom(x + 1, y); if (R2 != null) linkRoom(R, R2, Directions.EAST, ox, ox); } else if ((rawDoors()[Directions.EAST] != null) && (exits[Directions.EAST] != null)) linkRoom( R, rawDoors()[Directions.EAST], Directions.EAST, exits[Directions.EAST], exits[Directions.EAST]); if (Directions.NORTHEAST < Directions.NUM_DIRECTIONS()) { if ((y > 0) && (x > 0)) { R2 = getMakeSingleGridRoom(x - 1, y - 1); if (R2 != null) linkRoom(R, R2, Directions.NORTHWEST, ox, ox); } else if ((rawDoors()[Directions.NORTHWEST] != null) && (exits[Directions.NORTHWEST] != null)) linkRoom( R, rawDoors()[Directions.NORTHWEST], Directions.NORTHWEST, exits[Directions.NORTHWEST], exits[Directions.NORTHWEST]); if ((x > 0) && (y < (yGridSize() - 1))) { R2 = getMakeSingleGridRoom(x - 1, y + 1); if (R2 != null) linkRoom(R, R2, Directions.SOUTHWEST, ox, ox); } else if ((rawDoors()[Directions.SOUTHWEST] != null) && (exits[Directions.SOUTHWEST] != null)) linkRoom( R, rawDoors()[Directions.SOUTHWEST], Directions.SOUTHWEST, exits[Directions.SOUTHWEST], exits[Directions.SOUTHWEST]); if ((x < (xGridSize() - 1)) && (y > 0)) { R2 = getMakeSingleGridRoom(x + 1, y - 1); if (R2 != null) linkRoom(R, R2, Directions.NORTHEAST, ox, ox); } else if ((rawDoors()[Directions.NORTHEAST] != null) && (exits[Directions.NORTHEAST] != null)) linkRoom( R, rawDoors()[Directions.NORTHEAST], Directions.NORTHEAST, exits[Directions.NORTHEAST], exits[Directions.NORTHEAST]); if ((x < (xGridSize() - 1)) && (y < (yGridSize() - 1))) { R2 = getMakeSingleGridRoom(x + 1, y + 1); if (R2 != null) linkRoom(R, R2, Directions.SOUTHEAST, ox, ox); } else if ((rawDoors()[Directions.SOUTHEAST] != null) && (exits[Directions.SOUTHEAST] != null)) linkRoom( R, rawDoors()[Directions.SOUTHEAST], Directions.SOUTHEAST, exits[Directions.SOUTHEAST], exits[Directions.SOUTHEAST]); } for (int d = 0; d < gridexits.size(); d++) { WorldMap.CrossExit EX = (WorldMap.CrossExit) gridexits.elementAt(d); try { if ((EX.out) && (EX.x == x) && (EX.y == y)) switch (EX.dir) { case Directions.NORTH: if (EX.y == 0) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.SOUTH: if (EX.y == yGridSize() - 1) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.EAST: if (EX.x == xGridSize() - 1) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.WEST: if (EX.x == 0) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.NORTHEAST: if ((EX.y == 0) && (EX.x == xGridSize() - 1)) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.SOUTHWEST: if ((EX.y == yGridSize() - 1) && (EX.x == 0)) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.NORTHWEST: if ((EX.y == 0) && (EX.x == 0)) tryFillInExtraneousExternal(EX, ox, R); break; case Directions.SOUTHEAST: if ((EX.y == yGridSize() - 1) && (EX.x == xGridSize() - 1)) tryFillInExtraneousExternal(EX, ox, R); break; } } catch (Exception e) { } } R.baseEnvStats() .setSensesMask(CMath.unsetb(R.baseEnvStats().sensesMask(), EnvStats.SENSE_ROOMGRIDSYNC)); }