--- cf.schmorp.de/server/random_maps/room_gen_onion.C 2006/09/14 22:34:02 1.4 +++ cf.schmorp.de/server/random_maps/room_gen_onion.C 2006/12/31 19:02:24 1.6 @@ -1,3 +1,4 @@ + /* CrossFire, A Multiplayer game for X-windows @@ -82,24 +83,24 @@ { switch (RANDOM () % 3) { - case 0: - option |= OPT_CENTERED; - break; - case 1: - option |= OPT_BOTTOM_C; - break; - case 2: - option |= OPT_BOTTOM_R; - break; + case 0: + option |= RMOPT_CENTERED; + break; + case 1: + option |= RMOPT_BOTTOM_C; + break; + case 2: + option |= RMOPT_BOTTOM_R; + break; } if (RANDOM () % 2) - option |= OPT_LINEAR; + option |= RMOPT_LINEAR; if (RANDOM () % 2) - option |= OPT_IRR_SPACE; + option |= RMOPT_IRR_SPACE; } /* write the outer walls, if appropriate. */ - if (!(option & OPT_WALL_OFF)) + if (!(option & RMOPT_WALL_OFF)) { for (i = 0; i < xsize; i++) maze[i][0] = maze[i][ysize - 1] = '#'; @@ -107,15 +108,15 @@ maze[0][j] = maze[xsize - 1][j] = '#'; }; - if (option & OPT_WALLS_ONLY) + if (option & RMOPT_WALLS_ONLY) return maze; /* pick off the mutually exclusive options */ - if (option & OPT_BOTTOM_R) + if (option & RMOPT_BOTTOM_R) bottom_right_centered_onion (maze, xsize, ysize, option, layers); - else if (option & OPT_BOTTOM_C) + else if (option & RMOPT_BOTTOM_C) bottom_centered_onion (maze, xsize, ysize, option, layers); - else if (option & OPT_CENTERED) + else if (option & RMOPT_CENTERED) centered_onion (maze, xsize, ysize, option, layers); return maze; @@ -140,7 +141,7 @@ /* place all the walls */ - if (option & OPT_IRR_SPACE) /* randomly spaced */ + if (option & RMOPT_IRR_SPACE) /* randomly spaced */ { int x_spaces_available, y_spaces_available; @@ -166,7 +167,7 @@ } } - if (!(option & OPT_IRR_SPACE)) + if (!(option & RMOPT_IRR_SPACE)) { /* evenly spaced */ float xpitch, ypitch; /* pitch of the onion layers */ @@ -207,7 +208,7 @@ /* place all the walls */ - if (option & OPT_IRR_SPACE) /* randomly spaced */ + if (option & RMOPT_IRR_SPACE) /* randomly spaced */ { int x_spaces_available, y_spaces_available; @@ -236,7 +237,7 @@ } } - if (!(option & OPT_IRR_SPACE)) + if (!(option & RMOPT_IRR_SPACE)) { /* evenly spaced */ float xpitch, ypitch; /* pitch of the onion layers */ @@ -302,9 +303,9 @@ int l, x1 = 0, x2, y1 = 0, y2; freedoms = 4; /* centered */ - if (options & OPT_BOTTOM_C) + if (options & RMOPT_BOTTOM_C) freedoms = 3; - if (options & OPT_BOTTOM_R) + if (options & RMOPT_BOTTOM_R) freedoms = 2; if (layers <= 0) return; @@ -312,34 +313,34 @@ which_wall = RANDOM () % freedoms + 1; for (l = 0; l < layers; l++) { - if (options & OPT_LINEAR) + if (options & RMOPT_LINEAR) { /* linear door placement. */ switch (which_wall) { - case 1: - { /* left hand wall */ - x1 = (int) xlocations[l]; - y1 = (int) ((ylocations[l] + ylocations[2 * layers - l - 1]) / 2); - break; - } - case 2: - { /* top wall placement */ - x1 = (int) ((xlocations[l] + xlocations[2 * layers - l - 1]) / 2); - y1 = (int) ylocations[l]; - break; - } - case 3: - { /* right wall placement */ - x1 = (int) xlocations[2 * layers - l - 1]; - y1 = (int) ((ylocations[l] + ylocations[2 * layers - l - 1]) / 2); - break; - } - case 4: - { /* bottom wall placement */ - x1 = (int) ((xlocations[l] + xlocations[2 * layers - l - 1]) / 2); - y1 = (int) ylocations[2 * layers - l - 1]; - break; - } + case 1: + { /* left hand wall */ + x1 = (int) xlocations[l]; + y1 = (int) ((ylocations[l] + ylocations[2 * layers - l - 1]) / 2); + break; + } + case 2: + { /* top wall placement */ + x1 = (int) ((xlocations[l] + xlocations[2 * layers - l - 1]) / 2); + y1 = (int) ylocations[l]; + break; + } + case 3: + { /* right wall placement */ + x1 = (int) xlocations[2 * layers - l - 1]; + y1 = (int) ((ylocations[l] + ylocations[2 * layers - l - 1]) / 2); + break; + } + case 4: + { /* bottom wall placement */ + x1 = (int) ((xlocations[l] + xlocations[2 * layers - l - 1]) / 2); + y1 = (int) ylocations[2 * layers - l - 1]; + break; + } } } else @@ -347,51 +348,51 @@ which_wall = RANDOM () % freedoms + 1; switch (which_wall) { - case 1: - { /* left hand wall */ - x1 = (int) xlocations[l]; - y2 = (int) (ylocations[2 * layers - l - 1] - ylocations[l] - 1); - if (y2 > 0) - y1 = (int) (ylocations[l] + RANDOM () % y2 + 1); - else - y1 = (int) (ylocations[l] + 1); - break; - } - case 2: - { /* top wall placement */ - x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1; - if (x2 > 0) - x1 = (int) (xlocations[l] + RANDOM () % x2 + 1); - else - x1 = (int) (xlocations[l] + 1); - y1 = (int) ylocations[l]; - break; - } - case 3: - { /* right wall placement */ - x1 = (int) xlocations[2 * layers - l - 1]; - y2 = (int) ((-ylocations[l] + ylocations[2 * layers - l - 1])) - 1; - if (y2 > 0) - y1 = (int) (ylocations[l] + RANDOM () % y2 + 1); - else - y1 = (int) (ylocations[l] + 1); - - break; - } - case 4: - { /* bottom wall placement */ - x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1; - if (x2 > 0) - x1 = (int) (xlocations[l] + RANDOM () % x2 + 1); - else - x1 = (int) (xlocations[l] + 1); - y1 = (int) ylocations[2 * layers - l - 1]; - break; - } + case 1: + { /* left hand wall */ + x1 = (int) xlocations[l]; + y2 = (int) (ylocations[2 * layers - l - 1] - ylocations[l] - 1); + if (y2 > 0) + y1 = (int) (ylocations[l] + RANDOM () % y2 + 1); + else + y1 = (int) (ylocations[l] + 1); + break; + } + case 2: + { /* top wall placement */ + x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1; + if (x2 > 0) + x1 = (int) (xlocations[l] + RANDOM () % x2 + 1); + else + x1 = (int) (xlocations[l] + 1); + y1 = (int) ylocations[l]; + break; + } + case 3: + { /* right wall placement */ + x1 = (int) xlocations[2 * layers - l - 1]; + y2 = (int) ((-ylocations[l] + ylocations[2 * layers - l - 1])) - 1; + if (y2 > 0) + y1 = (int) (ylocations[l] + RANDOM () % y2 + 1); + else + y1 = (int) (ylocations[l] + 1); + + break; + } + case 4: + { /* bottom wall placement */ + x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1; + if (x2 > 0) + x1 = (int) (xlocations[l] + RANDOM () % x2 + 1); + else + x1 = (int) (xlocations[l] + 1); + y1 = (int) ylocations[2 * layers - l - 1]; + break; + } } } - if (options & OPT_NO_DOORS) + if (options & RMOPT_NO_DOORS) maze[x1][y1] = '#'; /* no door. */ else maze[x1][y1] = 'D'; /* write the door */ @@ -428,7 +429,7 @@ /* place all the walls */ - if (option & OPT_IRR_SPACE) /* randomly spaced */ + if (option & RMOPT_IRR_SPACE) /* randomly spaced */ { int x_spaces_available, y_spaces_available; @@ -461,7 +462,7 @@ } } - if (!(option & OPT_IRR_SPACE)) + if (!(option & RMOPT_IRR_SPACE)) { /* evenly spaced */ float xpitch, ypitch; /* pitch of the onion layers */