… | |
… | |
106 | int itest = 0; |
106 | int itest = 0; |
107 | oblinkpt *obp; |
107 | oblinkpt *obp; |
108 | |
108 | |
109 | while (itest++ < 1000) |
109 | while (itest++ < 1000) |
110 | { |
110 | { |
111 | connected = 1 + rand () % 20000; |
111 | connected = rndm (0x20000000UL) + 0x60000000UL; |
|
|
112 | |
112 | for (obp = map->buttons; obp && (obp->value != connected); obp = obp->next); |
113 | for (obp = map->buttons; obp && (obp->value != connected); obp = obp->next) |
|
|
114 | ; |
113 | |
115 | |
114 | if (!obp) |
116 | if (!obp) |
115 | return connected; |
117 | return connected; |
116 | } |
118 | } |
117 | |
119 | |
118 | return -1; |
120 | return -1; |
119 | } |
121 | } |
120 | |
|
|
121 | |
122 | |
122 | /** |
123 | /** |
123 | * Helper function for door/button/connected item building. |
124 | * Helper function for door/button/connected item building. |
124 | * |
125 | * |
125 | * Will search the specified spot for a marking rune. |
126 | * Will search the specified spot for a marking rune. |
… | |
… | |
180 | * Returns the marking rune on the square, for purposes of building connections |
181 | * Returns the marking rune on the square, for purposes of building connections |
181 | */ |
182 | */ |
182 | object * |
183 | object * |
183 | get_connection_rune (object *pl, short x, short y) |
184 | get_connection_rune (object *pl, short x, short y) |
184 | { |
185 | { |
185 | object *rune; |
|
|
186 | |
|
|
187 | rune = GET_MAP_OB (pl->map, x, y); |
186 | object *rune = GET_MAP_OB (pl->map, x, y); |
|
|
187 | |
188 | while (rune && ((rune->type != SIGN) || (strcmp (rune->arch->archname, "rune_mark")))) |
188 | while (rune && ((rune->type != SIGN) || (strcmp (rune->arch->archname, "rune_mark")))) |
189 | rune = rune->above; |
189 | rune = rune->above; |
|
|
190 | |
190 | return rune; |
191 | return rune; |
191 | } |
192 | } |
192 | |
193 | |
193 | /** |
194 | /** |
194 | * Returns the book/scroll on the current square, for purposes of building |
195 | * Returns the book/scroll on the current square, for purposes of building |
195 | */ |
196 | */ |
196 | object * |
197 | object * |
197 | get_msg_book (object *pl, short x, short y) |
198 | get_msg_book (object *pl, short x, short y) |
198 | { |
199 | { |
199 | object *book; |
|
|
200 | |
|
|
201 | book = GET_MAP_OB (pl->map, x, y); |
200 | object *book = GET_MAP_OB (pl->map, x, y); |
|
|
201 | |
202 | while (book && (book->type != BOOK)) |
202 | while (book && (book->type != BOOK)) |
203 | book = book->above; |
203 | book = book->above; |
|
|
204 | |
204 | return book; |
205 | return book; |
205 | } |
206 | } |
206 | |
207 | |
207 | /** |
208 | /** |
208 | * Returns first item of type BUILDABLE_WALL. |
209 | * Returns first item of type BUILDABLE_WALL. |
209 | */ |
210 | */ |
210 | object * |
211 | object * |
211 | get_wall (maptile *map, int x, int y) |
212 | get_wall (maptile *map, int x, int y) |
212 | { |
213 | { |
213 | object *wall; |
|
|
214 | |
|
|
215 | wall = GET_MAP_OB (map, x, y); |
214 | object *wall = GET_MAP_OB (map, x, y); |
|
|
215 | |
216 | while (wall && (BUILDABLE_WALL != wall->type)) |
216 | while (wall && (BUILDABLE_WALL != wall->type)) |
217 | wall = wall->above; |
217 | wall = wall->above; |
218 | |
218 | |
219 | return wall; |
219 | return wall; |
220 | } |
220 | } |
… | |
… | |
231 | * Note: x & y must be valid map coordinates. |
231 | * Note: x & y must be valid map coordinates. |
232 | */ |
232 | */ |
233 | void |
233 | void |
234 | fix_walls (maptile *map, int x, int y) |
234 | fix_walls (maptile *map, int x, int y) |
235 | { |
235 | { |
236 | object *wall; |
|
|
237 | char archetype[MAX_BUF]; |
236 | char archetype[MAX_BUF]; |
238 | char *underscore; |
237 | char *underscore; |
239 | struct archetype *new_arch; |
238 | struct archetype *new_arch; |
240 | |
239 | |
241 | |
|
|
242 | /* First, find the wall on that spot */ |
240 | /* First, find the wall on that spot */ |
243 | wall = get_wall (map, x, y); |
241 | object *wall = get_wall (map, x, y); |
244 | if (!wall) |
242 | if (!wall) |
245 | /* Nothing -> bail out */ |
243 | /* Nothing -> bail out */ |
246 | return; |
244 | return; |
247 | |
245 | |
248 | /* Find base name */ |
246 | /* Find base name */ |