1 | |
|
|
2 | /* |
1 | /* |
3 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
4 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | |
7 | * |
8 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. |
11 | * (at your option) any later version. |
12 | |
12 | * |
13 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | |
17 | * |
18 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | |
21 | * |
22 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <random_map.h> |
26 | #include <random_map.h> |
27 | #include <rproto.h> |
27 | #include <rproto.h> |
28 | |
28 | |
… | |
… | |
92 | * 8 = blocked below |
92 | * 8 = blocked below |
93 | */ |
93 | */ |
94 | |
94 | |
95 | int surround_index = 0; |
95 | int surround_index = 0; |
96 | |
96 | |
|
|
97 | // don't forget to update the mapspace! |
|
|
98 | if (i > 0) map->at (i - 1, j ).update (); |
|
|
99 | if (i < RP->Xsize - 1) map->at (i + 1, j ).update (); |
|
|
100 | if (j > 0) map->at (i , j - 1).update (); |
|
|
101 | if (j < RP->Ysize - 1) map->at (i , j + 1).update (); |
|
|
102 | |
97 | if ((i > 0) && (GET_MAP_MOVE_BLOCK (map, i - 1, j) & ~MOVE_BLOCK_DEFAULT)) |
103 | if ((i > 0) && (GET_MAP_MOVE_BLOCK (map, i - 1, j) & MOVE_WALK)) |
98 | surround_index |= 1; |
104 | surround_index |= 1; |
99 | if ((i < RP->Xsize - 1) && (GET_MAP_MOVE_BLOCK (map, i + 1, j) & ~MOVE_BLOCK_DEFAULT)) |
105 | if ((i < RP->Xsize - 1) && (GET_MAP_MOVE_BLOCK (map, i + 1, j) & MOVE_WALK)) |
100 | surround_index |= 2; |
106 | surround_index |= 2; |
101 | if ((j > 0) && (GET_MAP_MOVE_BLOCK (map, i, j - 1) & ~MOVE_BLOCK_DEFAULT)) |
107 | if ((j > 0) && (GET_MAP_MOVE_BLOCK (map, i, j - 1) & MOVE_WALK)) |
102 | surround_index |= 4; |
108 | surround_index |= 4; |
103 | if ((j < RP->Ysize - 1) && (GET_MAP_MOVE_BLOCK (map, i, j + 1) & ~MOVE_BLOCK_DEFAULT)) |
109 | if ((j < RP->Ysize - 1) && (GET_MAP_MOVE_BLOCK (map, i, j + 1) & MOVE_WALK)) |
104 | surround_index |= 8; |
110 | surround_index |= 8; |
105 | |
111 | |
106 | return surround_index; |
112 | return surround_index; |
107 | } |
113 | } |
108 | |
114 | |
… | |
… | |
133 | w_style) at '#' marks. */ |
139 | w_style) at '#' marks. */ |
134 | |
140 | |
135 | void |
141 | void |
136 | make_map_walls (maptile *map, char **layout, char *w_style, random_map_params *RP) |
142 | make_map_walls (maptile *map, char **layout, char *w_style, random_map_params *RP) |
137 | { |
143 | { |
138 | char styledirname[256]; |
144 | char styledirname[1024]; |
139 | char stylefilepath[256]; |
145 | char stylefilepath[1024]; |
140 | maptile *style_map = 0; |
146 | maptile *style_map = 0; |
141 | object *the_wall; |
147 | object *the_wall; |
142 | |
148 | |
143 | /* get the style map */ |
149 | /* get the style map */ |
144 | if (!strcmp (w_style, "none")) |
150 | if (!strcmp (w_style, "none")) |
145 | return; |
151 | return; |
146 | sprintf (styledirname, "%s", "/styles/wallstyles"); |
152 | sprintf (styledirname, "%s", "/styles/wallstyles"); |
147 | sprintf (stylefilepath, "%s/%s", styledirname, w_style); |
153 | sprintf (stylefilepath, "%s/%s", styledirname, w_style); |
148 | style_map = find_style (styledirname, w_style, -1); |
154 | style_map = find_style (styledirname, w_style, -1); |
149 | if (style_map == 0) |
155 | if (!style_map) |
150 | return; |
156 | return; |
151 | |
157 | |
152 | /* fill up the map with the given floor style */ |
158 | /* fill up the map with the given floor style */ |
153 | if ((the_wall = pick_random_object (style_map)) != NULL) |
159 | if ((the_wall = style_map->pick_random_object ())) |
154 | { |
160 | { |
155 | int i, j; |
161 | int i, j; |
156 | char *cp; |
162 | char *cp; |
157 | int joinedwalls = 0; |
163 | int joinedwalls = 0; |
158 | object *thiswall; |
164 | object *thiswall; |
… | |
… | |
193 | 2 = wall to right, |
199 | 2 = wall to right, |
194 | 4 = wall above |
200 | 4 = wall above |
195 | 8 = wall below */ |
201 | 8 = wall below */ |
196 | int surround_index = 0; |
202 | int surround_index = 0; |
197 | int l; |
203 | int l; |
198 | char wall_name[64]; |
204 | char wall_name[1024]; |
199 | archetype *wall_arch = 0; |
205 | archetype *wall_arch = 0; |
200 | |
206 | |
201 | strcpy (wall_name, the_wall->arch->name); |
207 | assign (wall_name, the_wall->arch->name); |
202 | |
208 | |
203 | /* conventionally, walls are named like this: |
209 | /* conventionally, walls are named like this: |
204 | wallname_wallcode, where wallcode indicates |
210 | wallname_wallcode, where wallcode indicates |
205 | a joinedness, and wallname is the wall. |
211 | a joinedness, and wallname is the wall. |
206 | this code depends on the convention for |
212 | this code depends on the convention for |