… | |
… | |
178 | * client/server bandwidth (client could keep track of various strings |
178 | * client/server bandwidth (client could keep track of various strings |
179 | */ |
179 | */ |
180 | void |
180 | void |
181 | new_draw_info_format (int flags, int pri, const object *pl, const char *format, ...) |
181 | new_draw_info_format (int flags, int pri, const object *pl, const char *format, ...) |
182 | { |
182 | { |
183 | char buf[HUGE_BUF]; |
|
|
184 | |
|
|
185 | va_list ap; |
183 | va_list ap; |
186 | va_start (ap, format); |
184 | va_start (ap, format); |
187 | vsnprintf (buf, HUGE_BUF, format, ap); |
185 | new_draw_info (flags, pri, pl, vformat (format, ap)); |
188 | va_end (ap); |
186 | va_end (ap); |
189 | |
|
|
190 | new_draw_info (flags, pri, pl, buf); |
|
|
191 | } |
187 | } |
192 | |
188 | |
193 | void |
189 | void |
194 | draw_ext_info (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *message, const char *oldmessage) |
190 | draw_ext_info (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *message, const char *oldmessage) |
195 | { |
191 | { |
… | |
… | |
216 | } |
212 | } |
217 | |
213 | |
218 | void |
214 | void |
219 | draw_ext_info_format (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *old_format, char *new_format, ...) |
215 | draw_ext_info_format (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *old_format, char *new_format, ...) |
220 | { |
216 | { |
221 | char buf[HUGE_BUF]; |
217 | va_list ap; |
|
|
218 | va_start (ap, new_format); |
222 | |
219 | |
223 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
220 | if (!pl || !pl->is_player ()) |
224 | return; |
221 | return; |
225 | |
222 | |
|
|
223 | // TODO: just assume, and rip out? |
226 | if (!CLIENT_SUPPORT_READABLES (pl->contr->ns, type)) |
224 | if (!CLIENT_SUPPORT_READABLES (pl->contr->ns, type)) |
227 | { |
225 | { |
228 | va_list ap; |
|
|
229 | |
|
|
230 | LOG (llevDebug, "Non supported extension text type for client.\n"); |
226 | LOG (llevDebug, "Non supported extension text type for client.\n"); |
231 | va_start (ap, new_format); |
|
|
232 | vsnprintf (buf, HUGE_BUF, old_format, ap); |
|
|
233 | va_end (ap); |
|
|
234 | new_draw_info (flags, pri, pl, buf); |
227 | new_draw_info (flags, pri, pl, vformat (old_format, ap)); |
235 | return; |
|
|
236 | } |
228 | } |
237 | else |
229 | else |
238 | { |
230 | { |
239 | va_list ap; |
231 | char *buf = vformat (new_format, ap); |
240 | |
|
|
241 | va_start (ap, new_format); |
|
|
242 | vsnprintf (buf, HUGE_BUF, new_format, ap); |
|
|
243 | va_end (ap); |
|
|
244 | strip_media_tag (buf); |
232 | strip_media_tag (buf); |
245 | esrv_print_ext_msg (pl->contr->ns, flags & NDI_COLOR_MASK, type, subtype, buf); |
233 | esrv_print_ext_msg (pl->contr->ns, flags & NDI_COLOR_MASK, type, subtype, buf); |
246 | } |
234 | } |
|
|
235 | |
|
|
236 | va_end (ap); |
247 | } |
237 | } |
248 | |
238 | |
249 | /** |
239 | /** |
250 | * Writes to everyone on the map *except* op. This is useful for emotions. |
240 | * Writes to everyone on the map *except* op. This is useful for emotions. |
251 | */ |
241 | */ |
… | |
… | |
293 | sprintf (buf, "Player: %s %s", (const char *) pl->name, (const char *) pl->contr->own_title); |
283 | sprintf (buf, "Player: %s %s", (const char *) pl->name, (const char *) pl->contr->own_title); |
294 | } |
284 | } |
295 | |
285 | |
296 | // formerly a macro, used only by magic map, so optimised it out |
286 | // formerly a macro, used only by magic map, so optimised it out |
297 | static inline faceidx |
287 | static inline faceidx |
298 | GET_MAP_FACE (maptile *m, int x, int y, int layer) |
288 | GET_MAP_FACE (mapspace &ms, int layer) |
299 | { |
289 | { |
300 | if (object *op = GET_MAP_FACE_OBJ (m, x, y, layer)) |
290 | if (object *op = ms.faces_obj [layer]) |
301 | return op->face; |
291 | return op->face; |
302 | else |
292 | else |
303 | return 0; |
293 | return 0; |
304 | } |
294 | } |
305 | |
295 | |
… | |
… | |
315 | * for various code values. |
305 | * for various code values. |
316 | */ |
306 | */ |
317 | static void |
307 | static void |
318 | magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) |
308 | magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) |
319 | { |
309 | { |
320 | int x, y, dx, dy, mflags; |
|
|
321 | sint16 nx, ny; |
|
|
322 | maptile *mp; |
|
|
323 | |
|
|
324 | for (dx = -1; dx <= 1; dx++) |
310 | for (int dx = -1; dx <= 1; dx++) |
325 | { |
311 | { |
326 | for (dy = -1; dy <= 1; dy++) |
312 | for (int dy = -1; dy <= 1; dy++) |
327 | { |
313 | { |
328 | x = px + dx; |
314 | int x = px + dx; |
329 | y = py + dy; |
315 | int y = py + dy; |
330 | |
316 | |
331 | if (FABS (x) >= MAGIC_MAP_HALF || FABS (y) >= MAGIC_MAP_HALF) |
317 | if (abs (x) >= MAGIC_MAP_HALF || abs (y) >= MAGIC_MAP_HALF) |
332 | continue; |
318 | continue; |
333 | |
319 | |
334 | mp = pl->map; |
320 | mapxy pos (pl); |
335 | nx = pl->x + x; |
321 | pos.move (x, y); |
336 | ny = pl->y + y; |
|
|
337 | |
322 | |
338 | mflags = get_map_flags (pl->map, &mp, nx, ny, &nx, &ny); |
323 | if (!pos.normalise ()) |
339 | if (mflags & P_OUT_OF_MAP) |
|
|
340 | continue; |
324 | continue; |
|
|
325 | |
|
|
326 | mapspace &ms = pos.ms (); |
341 | |
327 | |
342 | if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] == 0) |
328 | if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] == 0) |
343 | { |
329 | { |
|
|
330 | int mflags = ms.flags (); |
|
|
331 | |
344 | int f = GET_MAP_FACE (mp, nx, ny, 0); |
332 | int f = GET_MAP_FACE (ms, 0); |
345 | if (f == blank_face) |
333 | if (f == blank_face) |
346 | { |
334 | { |
347 | f = GET_MAP_FACE (mp, nx, ny, 1); |
335 | f = GET_MAP_FACE (ms, 1); |
348 | if (f == blank_face) |
336 | if (f == blank_face) |
349 | f = GET_MAP_FACE (mp, nx, ny, 2); |
337 | f = GET_MAP_FACE (ms, 2); |
350 | } |
338 | } |
351 | |
339 | |
352 | int magicmap = faces [f].magicmap; |
340 | int magicmap = faces [f].magicmap; |
353 | |
341 | |
354 | /* Should probably have P_NO_MAGIC here also, but then shops don't |
342 | /* Should probably have P_NO_MAGIC here also, but then shops don't |
… | |
… | |
367 | } |
355 | } |
368 | |
356 | |
369 | /** |
357 | /** |
370 | * Creates magic map for player. |
358 | * Creates magic map for player. |
371 | * |
359 | * |
372 | * Note: For improved magic mapping display, the space that blocks |
360 | * Note: For improved magic mapping display, the space that blocks |
373 | * the view is now marked with value 2. Any dependencies of map_mark |
361 | * the view is now marked with value 2. Any dependencies of map_mark |
374 | * being nonzero have been changed to check for 1. Also, since |
362 | * being nonzero have been changed to check for 1. Also, since |
375 | * map_mark is a char value, putting 2 in should cause no problems. |
363 | * map_mark is a char value, putting 2 in should cause no problems. |
376 | * |
364 | * |
377 | * This function examines the map the player is on, and determines what |
365 | * This function examines the map the player is on, and determines what |
378 | * is visible. 2 is set for walls or objects that blocks view. 1 |
366 | * is visible. 2 is set for walls or objects that blocks view. 1 |
379 | * is for open spaces. map_mark should already have been initialised |
367 | * is for open spaces. map_mark should already have been initialised |
380 | * to zero before this is called. |
368 | * to zero before this is called. |
381 | * strength is an initial strength*2 rectangular area that we automatically |
369 | * strength is an initial strength*2 rectangular area that we automatically |
382 | * see in/penetrate through. |
370 | * see in/penetrate through. |
383 | */ |
371 | */ |
384 | void |
372 | void |
385 | magic_mapping_mark (object *pl, char *map_mark, int strength) |
373 | magic_mapping_mark (object *pl, char *map_mark, int strength) |
386 | { |
374 | { |
387 | int x, y, mflags; |
|
|
388 | sint16 nx, ny; |
|
|
389 | maptile *mp; |
|
|
390 | |
|
|
391 | for (x = -strength; x < strength; x++) |
375 | for (int x = -strength; x < strength; x++) |
392 | { |
376 | { |
393 | for (y = -strength; y < strength; y++) |
377 | for (int y = -strength; y < strength; y++) |
394 | { |
378 | { |
395 | mp = pl->map; |
379 | mapxy pos (pl); |
396 | nx = pl->x + x; |
380 | pos.move (x, y); |
397 | ny = pl->y + y; |
|
|
398 | |
381 | |
399 | mflags = get_map_flags (pl->map, &mp, nx, ny, &nx, &ny); |
382 | if (!pos.normalise ()) |
400 | if (mflags & P_OUT_OF_MAP) |
|
|
401 | continue; |
383 | continue; |
402 | |
384 | |
|
|
385 | mapspace &ms = pos.ms (); |
|
|
386 | |
|
|
387 | int mflags = ms.flags (); |
|
|
388 | |
403 | int f = GET_MAP_FACE (mp, nx, ny, 0); |
389 | int f = GET_MAP_FACE (ms, 0); |
404 | if (f == blank_face) |
390 | if (f == blank_face) |
405 | { |
391 | { |
406 | f = GET_MAP_FACE (mp, nx, ny, 1); |
392 | f = GET_MAP_FACE (ms, 1); |
407 | if (f == blank_face) |
393 | if (f == blank_face) |
408 | f = GET_MAP_FACE (mp, nx, ny, 2); |
394 | f = GET_MAP_FACE (ms, 2); |
409 | } |
395 | } |
410 | |
396 | |
411 | int magicmap = faces [f].magicmap; |
397 | int magicmap = faces [f].magicmap; |
412 | |
398 | |
413 | if (mflags & P_BLOCKSVIEW) |
399 | if (mflags & P_BLOCKSVIEW) |