| 1 |
/* Emacs style mode select -*- C -*- |
| 2 |
*----------------------------------------------------------------------------- |
| 3 |
* |
| 4 |
* |
| 5 |
* PrBoom: a Doom port merged with LxDoom and LSDLDoom |
| 6 |
* based on BOOM, a modified and improved DOOM engine |
| 7 |
* Copyright (C) 1999 by |
| 8 |
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman |
| 9 |
* Copyright (C) 1999-2000 by |
| 10 |
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze |
| 11 |
* Copyright 2005, 2006 by |
| 12 |
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko |
| 13 |
* |
| 14 |
* This program is free software; you can redistribute it and/or |
| 15 |
* modify it under the terms of the GNU General Public License |
| 16 |
* as published by the Free Software Foundation; either version 2 |
| 17 |
* of the License, or (at your option) any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 27 |
* 02111-1307, USA. |
| 28 |
* |
| 29 |
* DESCRIPTION: |
| 30 |
* the automap code |
| 31 |
* |
| 32 |
*----------------------------------------------------------------------------- |
| 33 |
*/ |
| 34 |
|
| 35 |
#ifdef HAVE_CONFIG_H |
| 36 |
#include "config.h" |
| 37 |
#endif |
| 38 |
|
| 39 |
#include <math.h> |
| 40 |
#include <float.h> |
| 41 |
|
| 42 |
#include "gl_opengl.h" |
| 43 |
#include "doomstat.h" |
| 44 |
#include "st_stuff.h" |
| 45 |
#include "r_main.h" |
| 46 |
#include "p_setup.h" |
| 47 |
#include "p_maputl.h" |
| 48 |
#include "w_wad.h" |
| 49 |
#include "v_video.h" |
| 50 |
#include "p_spec.h" |
| 51 |
#include "am_map.h" |
| 52 |
#include "d_deh.h" // Ty 03/27/98 - externalizations |
| 53 |
#include "lprintf.h" // jff 08/03/98 - declaration of lprintf |
| 54 |
#include "g_game.h" |
| 55 |
#include "r_fps.h" |
| 56 |
#include "smooth.h" |
| 57 |
#include "m_misc.h" |
| 58 |
#include "m_bbox.h" |
| 59 |
#include "d_main.h" |
| 60 |
#include "m_menu.h" |
| 61 |
|
| 62 |
#include "dsda/id_list.h" |
| 63 |
#include "dsda/input.h" |
| 64 |
#include "dsda/map_format.h" |
| 65 |
#include "dsda/messenger.h" |
| 66 |
#include "dsda/settings.h" |
| 67 |
#include "dsda/stretch.h" |
| 68 |
#include "dsda/utility.h" |
| 69 |
|
| 70 |
mapcolor_t mapcolor = { |
| 71 |
.plyr = { 112, 96, 64, 176 }, |
| 72 |
}; |
| 73 |
|
| 74 |
mapcolor_t mapcolor_heretic = { |
| 75 |
.back = 0, |
| 76 |
.grid = 5 * 8, |
| 77 |
.wall = 104, |
| 78 |
.fchg = 88, |
| 79 |
.cchg = 10 * 8, |
| 80 |
// .clsd |
| 81 |
.rkey = 220, |
| 82 |
.bkey = 197, |
| 83 |
.ykey = 144, |
| 84 |
.rdor = 220, |
| 85 |
.bdor = 197, |
| 86 |
.ydor = 144, |
| 87 |
.tele = 88, |
| 88 |
.secr = 88, |
| 89 |
.revsecr = 88, |
| 90 |
// .exit |
| 91 |
.unsn = 5 * 8 + 3, |
| 92 |
// .flat |
| 93 |
.sprt = 224, |
| 94 |
.item = 144, |
| 95 |
.frnd = 224, |
| 96 |
.enemy = 160, |
| 97 |
.hair = 5 * 8, |
| 98 |
.sngl = 4 * 8, |
| 99 |
.plyr = { 220, 144, 150, 197 }, |
| 100 |
.trail_1 = 33, |
| 101 |
.trail_2 = 15, |
| 102 |
}; |
| 103 |
|
| 104 |
mapcolor_t mapcolor_hexen = { |
| 105 |
.back = 0, |
| 106 |
.grid = 5 * 8, |
| 107 |
.wall = 12 * 8, |
| 108 |
.fchg = 14 * 8, |
| 109 |
.cchg = 10 * 8, |
| 110 |
// .clsd |
| 111 |
// .rkey |
| 112 |
// .bkey |
| 113 |
// .ykey |
| 114 |
.rdor = 198, |
| 115 |
.bdor = 198, |
| 116 |
.ydor = 198, |
| 117 |
.tele = 157, |
| 118 |
// .secr |
| 119 |
// .revsecr |
| 120 |
.exit = 177, |
| 121 |
.unsn = 5 * 8 + 3, |
| 122 |
// .flat |
| 123 |
.sprt = 216, |
| 124 |
.item = 230, |
| 125 |
.frnd = 216, |
| 126 |
.enemy = 176, |
| 127 |
.hair = 5 * 8, |
| 128 |
.sngl = 4 * 8, |
| 129 |
.plyr = { 157, 177, 137, 198, 215, 32, 106, 234 }, |
| 130 |
.trail_1 = 33, |
| 131 |
.trail_2 = 15, |
| 132 |
}; |
| 133 |
|
| 134 |
static mapcolor_t *mapcolor_p; |
| 135 |
|
| 136 |
static void AM_SetColors(void) |
| 137 |
{ |
| 138 |
mapcolor_p = hexen ? &mapcolor_hexen : |
| 139 |
heretic ? &mapcolor_heretic : |
| 140 |
&mapcolor; |
| 141 |
} |
| 142 |
|
| 143 |
typedef struct |
| 144 |
{ |
| 145 |
mpoint_t a, b; |
| 146 |
} mline_t; |
| 147 |
|
| 148 |
typedef struct |
| 149 |
{ |
| 150 |
int tag; |
| 151 |
fixed_t x, y; |
| 152 |
sector_t *sec; |
| 153 |
line_t *line; |
| 154 |
mline_t *connections; |
| 155 |
int connection_count; |
| 156 |
int connection_max; |
| 157 |
} highlight_t; |
| 158 |
|
| 159 |
static highlight_t highlight; |
| 160 |
|
| 161 |
static int map_blinking_locks; |
| 162 |
static int map_secret_after; |
| 163 |
static int map_grid_size; |
| 164 |
static int map_pan_speed; |
| 165 |
static int map_scroll_speed; |
| 166 |
static int map_wheel_zoom; |
| 167 |
int map_textured; |
| 168 |
int map_use_multisampling; |
| 169 |
|
| 170 |
static map_things_appearance_t map_things_appearance; |
| 171 |
|
| 172 |
// drawing stuff |
| 173 |
#define FB 0 |
| 174 |
|
| 175 |
// scale on entry |
| 176 |
#define INITSCALEMTOF (.2*FRACUNIT) |
| 177 |
// how much the automap moves window per tic in frame-buffer coordinates |
| 178 |
// moves 140 pixels in 1 second |
| 179 |
#define F_SPEED (dsda_InputActive(dsda_input_speed) ? !dsda_AutoRun() : dsda_AutoRun()) |
| 180 |
#define F_PANINC (F_SPEED ? map_pan_speed * 2 : map_pan_speed) |
| 181 |
#define F_ZOOMINC (F_SPEED ? map_scroll_speed * 2 : map_scroll_speed) |
| 182 |
// how much zoom-in per tic |
| 183 |
// goes to 2x in 1 second |
| 184 |
#define M_ZOOMIN ((int) ((float)FRACUNIT * (1.00f + F_ZOOMINC / 200.0f))) |
| 185 |
// how much zoom-out per tic |
| 186 |
// pulls out to 0.5x in 1 second |
| 187 |
#define M_ZOOMOUT ((int) ((float)FRACUNIT / (1.00f + F_ZOOMINC / 200.0f))) |
| 188 |
|
| 189 |
#define PLAYERRADIUS (16*(1<<MAPBITS)) // e6y |
| 190 |
|
| 191 |
// translates between frame-buffer and map distances |
| 192 |
#define FTOM(x) FixedMul(((x)<<16),scale_ftom) |
| 193 |
// e6y: int64 version to avoid overflows |
| 194 |
//#define MTOF(x) (FixedMul((x),scale_mtof)>>16) |
| 195 |
#define MTOF(x) (fixed_t)((((int64_t)(x) * scale_mtof) >> FRACBITS)>>FRACBITS) |
| 196 |
// translates between frame-buffer and map coordinates |
| 197 |
#define CXMTOF(x) (f_x + MTOF((x)-m_x)) |
| 198 |
#define CYMTOF(y) (f_y + (f_h - MTOF((y)-m_y))) |
| 199 |
// precise versions |
| 200 |
#define MTOF_F(x) (((float)(x)*scale_mtof)/(float)FRACUNIT/(float)FRACUNIT) |
| 201 |
#define CXMTOF_F(x) ((float)f_x + MTOF_F((x)-m_x)) |
| 202 |
#define CYMTOF_F(y) ((float)f_y + (f_h - MTOF_F((y)-m_y))) |
| 203 |
|
| 204 |
#define R ((8*PLAYERRADIUS)/7) |
| 205 |
mline_t hexen_player_arrow[] = { |
| 206 |
{ { -R+R/4, 0 }, { 0, 0} }, // center line. |
| 207 |
{ { -R+R/4, R/8 }, { R, 0} }, // blade |
| 208 |
{ { -R+R/4, -R/8 }, { R, 0 } }, |
| 209 |
{ { -R+R/4, -R/4 }, { -R+R/4, R/4 } }, // crosspiece |
| 210 |
{ { -R+R/8, -R/4 }, { -R+R/8, R/4 } }, |
| 211 |
{ { -R+R/8, -R/4 }, { -R+R/4, -R/4} }, //crosspiece connectors |
| 212 |
{ { -R+R/8, R/4 }, { -R+R/4, R/4} }, |
| 213 |
{ { -R-R/4, R/8 }, { -R-R/4, -R/8 } }, //pommel |
| 214 |
{ { -R-R/4, R/8 }, { -R+R/8, R/8 } }, |
| 215 |
{ { -R-R/4, -R/8}, { -R+R/8, -R/8 } } |
| 216 |
}; |
| 217 |
#undef R |
| 218 |
#define HEXEN_NUMPLYRLINES (sizeof(hexen_player_arrow)/sizeof(mline_t)) |
| 219 |
|
| 220 |
// |
| 221 |
// The vector graphics for the automap. |
| 222 |
// A line drawing of the player pointing right, |
| 223 |
// starting from the middle. |
| 224 |
// |
| 225 |
#define R ((8*PLAYERRADIUS)/7) |
| 226 |
mline_t doom_player_arrow[] = |
| 227 |
{ |
| 228 |
{ { -R+R/8, 0 }, { R, 0 } }, // ----- |
| 229 |
{ { R, 0 }, { R-R/2, R/4 } }, // -----> |
| 230 |
{ { R, 0 }, { R-R/2, -R/4 } }, |
| 231 |
{ { -R+R/8, 0 }, { -R-R/8, R/4 } }, // >----> |
| 232 |
{ { -R+R/8, 0 }, { -R-R/8, -R/4 } }, |
| 233 |
{ { -R+3*R/8, 0 }, { -R+R/8, R/4 } }, // >>---> |
| 234 |
{ { -R+3*R/8, 0 }, { -R+R/8, -R/4 } } |
| 235 |
}; |
| 236 |
#undef R |
| 237 |
#define NUMPLYRLINES (sizeof(doom_player_arrow)/sizeof(mline_t)) |
| 238 |
|
| 239 |
static int numplyrlines; |
| 240 |
static mline_t *player_arrow; |
| 241 |
|
| 242 |
#define R ((8*PLAYERRADIUS)/7) |
| 243 |
mline_t cheat_player_arrow[] = |
| 244 |
{ // killough 3/22/98: He's alive, Jim :) |
| 245 |
{ { -R+R/8, 0 }, { R, 0 } }, // ----- |
| 246 |
{ { R, 0 }, { R-R/2, R/4 } }, // -----> |
| 247 |
{ { R, 0 }, { R-R/2, -R/4 } }, |
| 248 |
{ { -R+R/8, 0 }, { -R-R/8, R/4 } }, // >----> |
| 249 |
{ { -R+R/8, 0 }, { -R-R/8, -R/4 } }, |
| 250 |
{ { -R+3*R/8, 0 }, { -R+R/8, R/4 } }, // >>---> |
| 251 |
{ { -R+3*R/8, 0 }, { -R+R/8, -R/4 } }, |
| 252 |
{ { -R/10-R/6, R/4}, {-R/10-R/6, -R/4} }, // J |
| 253 |
{ { -R/10-R/6, -R/4}, {-R/10-R/6-R/8, -R/4} }, |
| 254 |
{ { -R/10-R/6-R/8, -R/4}, {-R/10-R/6-R/8, -R/8} }, |
| 255 |
{ { -R/10, R/4}, {-R/10, -R/4}}, // F |
| 256 |
{ { -R/10, R/4}, {-R/10+R/8, R/4}}, |
| 257 |
{ { -R/10+R/4, R/4}, {-R/10+R/4, -R/4}}, // F |
| 258 |
{ { -R/10+R/4, R/4}, {-R/10+R/4+R/8, R/4}}, |
| 259 |
}; |
| 260 |
#undef R |
| 261 |
#define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t)) |
| 262 |
|
| 263 |
//jff 1/5/98 new symbol for keys on automap |
| 264 |
#define R (FRACUNIT) |
| 265 |
mline_t cross_mark[] = |
| 266 |
{ |
| 267 |
{ { -R, 0 }, { R, 0} }, |
| 268 |
{ { 0, -R }, { 0, R } }, |
| 269 |
}; |
| 270 |
#undef R |
| 271 |
#define NUMCROSSMARKLINES (sizeof(cross_mark)/sizeof(mline_t)) |
| 272 |
//jff 1/5/98 end of new symbol |
| 273 |
|
| 274 |
#define R (FRACUNIT) |
| 275 |
mline_t thintriangle_guy[] = |
| 276 |
{ |
| 277 |
{ { (fixed_t)(-.5*R), (fixed_t)(-.7*R) }, { (fixed_t)( R), (fixed_t)( 0) } }, |
| 278 |
{ { (fixed_t)( R), (fixed_t)( 0) }, { (fixed_t)(-.5*R), (fixed_t)( .7*R) } }, |
| 279 |
{ { (fixed_t)(-.5*R), (fixed_t)( .7*R) }, { (fixed_t)(-.5*R), (fixed_t)(-.7*R) } } |
| 280 |
}; |
| 281 |
#undef R |
| 282 |
#define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) |
| 283 |
|
| 284 |
#define R (FRACUNIT) |
| 285 |
mline_t thingbox_guy[] = |
| 286 |
{ |
| 287 |
{ { (fixed_t)(-R), (fixed_t)(-R) }, { (fixed_t)( R), (fixed_t)(-R) } }, |
| 288 |
{ { (fixed_t)( R), (fixed_t)(-R) }, { (fixed_t)( R), (fixed_t)( R) } }, |
| 289 |
{ { (fixed_t)( R), (fixed_t)( R) }, { (fixed_t)(-R), (fixed_t)( R) } }, |
| 290 |
{ { (fixed_t)(-R), (fixed_t)( R) }, { (fixed_t)(-R), (fixed_t)(-R) } } |
| 291 |
}; |
| 292 |
#undef R |
| 293 |
#define NUMTHINGBOXGUYLINES (sizeof(thingbox_guy)/sizeof(mline_t)) |
| 294 |
|
| 295 |
int automap_active; |
| 296 |
int automap_overlay; |
| 297 |
int automap_rotate; |
| 298 |
int automap_follow; |
| 299 |
int automap_grid; |
| 300 |
|
| 301 |
// location of window on screen |
| 302 |
static int f_x; |
| 303 |
static int f_y; |
| 304 |
|
| 305 |
// size of window on screen |
| 306 |
static int f_w; |
| 307 |
static int f_h; |
| 308 |
|
| 309 |
static mpoint_t m_paninc; // how far the window pans each tic (map coords) |
| 310 |
static fixed_t mtof_zoommul; // how far the window zooms each tic (map coords) |
| 311 |
static fixed_t ftom_zoommul; // how far the window zooms each tic (fb coords) |
| 312 |
static fixed_t curr_mtof_zoommul; |
| 313 |
|
| 314 |
static fixed_t m_x, m_y; // LL x,y window location on the map (map coords) |
| 315 |
static fixed_t m_x2, m_y2; // UR x,y window location on the map (map coords) |
| 316 |
|
| 317 |
static fixed_t prev_m_x, prev_m_y; |
| 318 |
|
| 319 |
// |
| 320 |
// width/height of window on map (map coords) |
| 321 |
// |
| 322 |
static fixed_t m_w; |
| 323 |
static fixed_t m_h; |
| 324 |
|
| 325 |
// based on level size |
| 326 |
static fixed_t min_x; |
| 327 |
static fixed_t min_y; |
| 328 |
static fixed_t max_x; |
| 329 |
static fixed_t max_y; |
| 330 |
|
| 331 |
static fixed_t max_w; // max_x-min_x, |
| 332 |
static fixed_t max_h; // max_y-min_y |
| 333 |
|
| 334 |
static fixed_t min_scale_mtof; // used to tell when to stop zooming out |
| 335 |
static fixed_t max_scale_mtof; // used to tell when to stop zooming in |
| 336 |
|
| 337 |
// old stuff for recovery later |
| 338 |
static fixed_t old_m_w, old_m_h; |
| 339 |
static fixed_t old_m_x, old_m_y; |
| 340 |
|
| 341 |
// used by MTOF to scale from map-to-frame-buffer coords |
| 342 |
static fixed_t scale_mtof = (fixed_t)INITSCALEMTOF; |
| 343 |
// used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof) |
| 344 |
static fixed_t scale_ftom; |
| 345 |
static fixed_t prev_scale_mtof = (fixed_t)INITSCALEMTOF; |
| 346 |
|
| 347 |
static player_t *plr; // the player represented by an arrow |
| 348 |
|
| 349 |
// killough 2/22/98: Remove limit on automap marks, |
| 350 |
// and make variables external for use in savegames. |
| 351 |
|
| 352 |
markpoint_t *markpoints = NULL; // where the points are |
| 353 |
int markpointnum = 0; // next point to be assigned (also number of points now) |
| 354 |
int markpointnum_max = 0; // killough 2/22/98 |
| 355 |
|
| 356 |
typedef struct |
| 357 |
{ |
| 358 |
fixed_t x; |
| 359 |
fixed_t y; |
| 360 |
} trailpoint_t; |
| 361 |
|
| 362 |
#define TRAIL_SIZE 350 // ten seconds |
| 363 |
static trailpoint_t player_trail[TRAIL_SIZE]; |
| 364 |
static int trail_index; |
| 365 |
static int trail_size; |
| 366 |
static int trail_collisions; |
| 367 |
static int trail_size_max; |
| 368 |
|
| 369 |
map_trail_mode_t map_trail_mode; |
| 370 |
|
| 371 |
am_frame_t am_frame; |
| 372 |
|
| 373 |
array_t map_lines; |
| 374 |
|
| 375 |
static void AM_rotate(fixed_t* x, fixed_t* y, angle_t a); |
| 376 |
|
| 377 |
static void AM_SetMPointFloatValue(mpoint_t *p) |
| 378 |
{ |
| 379 |
if (am_frame.precise) |
| 380 |
{ |
| 381 |
p->fx = (float)p->x; |
| 382 |
p->fy = (float)p->y; |
| 383 |
} |
| 384 |
} |
| 385 |
|
| 386 |
static void AM_SetFPointFloatValue(fpoint_t *p) |
| 387 |
{ |
| 388 |
p->fx = (float)p->x; |
| 389 |
p->fy = (float)p->y; |
| 390 |
} |
| 391 |
|
| 392 |
static dboolean stop_zooming; |
| 393 |
static int zoom_leveltime; |
| 394 |
|
| 395 |
static void AM_StopZooming(void) |
| 396 |
{ |
| 397 |
mtof_zoommul = FRACUNIT; |
| 398 |
ftom_zoommul = FRACUNIT; |
| 399 |
stop_zooming = false; |
| 400 |
} |
| 401 |
|
| 402 |
// |
| 403 |
// AM_activateNewScale() |
| 404 |
// |
| 405 |
// Changes the map scale after zooming or translating |
| 406 |
// |
| 407 |
// Passed nothing, returns nothing |
| 408 |
// |
| 409 |
static void AM_activateNewScale(void) |
| 410 |
{ |
| 411 |
m_x += m_w/2; |
| 412 |
m_y += m_h/2; |
| 413 |
m_w = FTOM(f_w); |
| 414 |
m_h = FTOM(f_h); |
| 415 |
m_x -= m_w/2; |
| 416 |
m_y -= m_h/2; |
| 417 |
m_x2 = m_x + m_w; |
| 418 |
m_y2 = m_y + m_h; |
| 419 |
} |
| 420 |
|
| 421 |
// |
| 422 |
// AM_saveScaleAndLoc() |
| 423 |
// |
| 424 |
// Saves the current center and zoom |
| 425 |
// Affects the variables that remember old scale and loc |
| 426 |
// |
| 427 |
// Passed nothing, returns nothing |
| 428 |
// |
| 429 |
static void AM_saveScaleAndLoc(void) |
| 430 |
{ |
| 431 |
old_m_x = m_x; |
| 432 |
old_m_y = m_y; |
| 433 |
old_m_w = m_w; |
| 434 |
old_m_h = m_h; |
| 435 |
} |
| 436 |
|
| 437 |
// |
| 438 |
// AM_restoreScaleAndLoc() |
| 439 |
// |
| 440 |
// restores the center and zoom from locally saved values |
| 441 |
// Affects global variables for location and scale |
| 442 |
// |
| 443 |
// Passed nothing, returns nothing |
| 444 |
// |
| 445 |
static void AM_restoreScaleAndLoc(void) |
| 446 |
{ |
| 447 |
m_w = old_m_w; |
| 448 |
m_h = old_m_h; |
| 449 |
if (!automap_follow) |
| 450 |
{ |
| 451 |
m_x = old_m_x; |
| 452 |
m_y = old_m_y; |
| 453 |
} |
| 454 |
else |
| 455 |
{ |
| 456 |
m_x = (viewx >> FRACTOMAPBITS) - m_w/2;//e6y |
| 457 |
m_y = (viewy >> FRACTOMAPBITS) - m_h/2;//e6y |
| 458 |
} |
| 459 |
m_x2 = m_x + m_w; |
| 460 |
m_y2 = m_y + m_h; |
| 461 |
|
| 462 |
// Change the scaling multipliers |
| 463 |
scale_mtof = FixedDiv(f_w<<FRACBITS, m_w); |
| 464 |
scale_ftom = FixedDiv(FRACUNIT, scale_mtof); |
| 465 |
} |
| 466 |
|
| 467 |
void AM_setMarkParams(int num) |
| 468 |
{ |
| 469 |
int i, namelen; |
| 470 |
char namebuf[16]; |
| 471 |
|
| 472 |
snprintf(namebuf, sizeof(namebuf), "%s", !raven ? "AMMNUM0" : "SMALLIN0"); |
| 473 |
namelen = !raven ? 6 : 7; |
| 474 |
|
| 475 |
markpoints[num].w = 0; |
| 476 |
markpoints[num].h = 0; |
| 477 |
|
| 478 |
snprintf(markpoints[num].label, sizeof(markpoints[num].label), "%d", num); |
| 479 |
for (i = 0; i < (int)strlen(markpoints[num].label); i++) |
| 480 |
{ |
| 481 |
namebuf[namelen] = markpoints[num].label[i]; |
| 482 |
markpoints[num].widths[i] = V_NamePatchWidth(namebuf); |
| 483 |
markpoints[num].w += markpoints[num].widths[i] + 1; |
| 484 |
markpoints[num].h = MAX(markpoints[num].h, V_NamePatchHeight(namebuf)); |
| 485 |
} |
| 486 |
} |
| 487 |
|
| 488 |
// |
| 489 |
// AM_addMark() |
| 490 |
// |
| 491 |
// Adds a marker at the current location |
| 492 |
// Affects global variables for marked points |
| 493 |
// |
| 494 |
// Passed nothing, returns nothing |
| 495 |
// |
| 496 |
static void AM_addMark(void) |
| 497 |
{ |
| 498 |
// killough 2/22/98: |
| 499 |
// remove limit on automap marks |
| 500 |
|
| 501 |
if (markpointnum >= markpointnum_max) |
| 502 |
markpoints = Z_Realloc(markpoints, |
| 503 |
(markpointnum_max = markpointnum_max ? |
| 504 |
markpointnum_max*2 : 16) * sizeof(*markpoints)); |
| 505 |
|
| 506 |
markpoints[markpointnum].x = m_x + m_w/2; |
| 507 |
markpoints[markpointnum].y = m_y + m_h/2; |
| 508 |
AM_setMarkParams(markpointnum); |
| 509 |
markpointnum++; |
| 510 |
} |
| 511 |
|
| 512 |
// |
| 513 |
// AM_findMinMaxBoundaries() |
| 514 |
// |
| 515 |
// Determines bounding box of all vertices, |
| 516 |
// sets global variables controlling zoom range. |
| 517 |
// |
| 518 |
// Passed nothing, returns nothing |
| 519 |
// |
| 520 |
static void AM_findMinMaxBoundaries(void) |
| 521 |
{ |
| 522 |
int i; |
| 523 |
|
| 524 |
min_x = min_y = INT_MAX; |
| 525 |
max_x = max_y = -INT_MAX; |
| 526 |
|
| 527 |
for (i=0;i<numvertexes;i++) |
| 528 |
{ |
| 529 |
if (vertexes[i].x < min_x) |
| 530 |
min_x = vertexes[i].x; |
| 531 |
else if (vertexes[i].x > max_x) |
| 532 |
max_x = vertexes[i].x; |
| 533 |
|
| 534 |
if (vertexes[i].y < min_y) |
| 535 |
min_y = vertexes[i].y; |
| 536 |
else if (vertexes[i].y > max_y) |
| 537 |
max_y = vertexes[i].y; |
| 538 |
} |
| 539 |
|
| 540 |
max_w = (max_x >>= FRACTOMAPBITS) - (min_x >>= FRACTOMAPBITS);//e6y |
| 541 |
max_h = (max_y >>= FRACTOMAPBITS) - (min_y >>= FRACTOMAPBITS);//e6y |
| 542 |
} |
| 543 |
|
| 544 |
void AM_SetMapCenter(fixed_t x, fixed_t y) |
| 545 |
{ |
| 546 |
m_x = (x >> FRACTOMAPBITS) - m_w / 2; |
| 547 |
m_y = (y >> FRACTOMAPBITS) - m_h / 2; |
| 548 |
m_x2 = m_x + m_w; |
| 549 |
m_y2 = m_y + m_h; |
| 550 |
} |
| 551 |
|
| 552 |
// |
| 553 |
// AM_changeWindowLoc() |
| 554 |
// |
| 555 |
// Moves the map window by the global variables m_paninc.x, m_paninc.y |
| 556 |
// |
| 557 |
// Passed nothing, returns nothing |
| 558 |
// |
| 559 |
static void AM_changeWindowLoc(void) |
| 560 |
{ |
| 561 |
fixed_t incx, incy; |
| 562 |
|
| 563 |
if (m_paninc.x || m_paninc.y) |
| 564 |
{ |
| 565 |
dsda_UpdateIntConfig(dsda_config_automap_follow, false, true); |
| 566 |
} |
| 567 |
|
| 568 |
if (movement_smooth) |
| 569 |
{ |
| 570 |
incx = FixedMul(m_paninc.x, tic_vars.frac); |
| 571 |
incy = FixedMul(m_paninc.y, tic_vars.frac); |
| 572 |
} |
| 573 |
else |
| 574 |
{ |
| 575 |
incx = m_paninc.x; |
| 576 |
incy = m_paninc.y; |
| 577 |
} |
| 578 |
|
| 579 |
if (automap_rotate) |
| 580 |
{ |
| 581 |
AM_rotate(&incx, &incy, viewangle - ANG90); |
| 582 |
} |
| 583 |
|
| 584 |
m_x = prev_m_x + incx; |
| 585 |
m_y = prev_m_y + incy; |
| 586 |
|
| 587 |
if (!automap_rotate) |
| 588 |
{ |
| 589 |
if (m_x + m_w/2 > max_x) |
| 590 |
m_x = max_x - m_w/2; |
| 591 |
else if (m_x + m_w/2 < min_x) |
| 592 |
m_x = min_x - m_w/2; |
| 593 |
|
| 594 |
if (m_y + m_h/2 > max_y) |
| 595 |
m_y = max_y - m_h/2; |
| 596 |
else if (m_y + m_h/2 < min_y) |
| 597 |
m_y = min_y - m_h/2; |
| 598 |
} |
| 599 |
|
| 600 |
m_x2 = m_x + m_w; |
| 601 |
m_y2 = m_y + m_h; |
| 602 |
} |
| 603 |
|
| 604 |
// |
| 605 |
// AM_SetScale |
| 606 |
// |
| 607 |
void AM_SetScale(void) |
| 608 |
{ |
| 609 |
{ |
| 610 |
fixed_t a, b; |
| 611 |
fixed_t scale_w, scale_h; |
| 612 |
|
| 613 |
scale_w = SCREENWIDTH << FRACBITS; |
| 614 |
scale_h = (SCREENHEIGHT - ST_SCALED_HEIGHT) << FRACBITS; |
| 615 |
|
| 616 |
a = FixedDiv(scale_w, max_w); |
| 617 |
b = FixedDiv(scale_h, max_h); |
| 618 |
min_scale_mtof = a < b ? a : b; |
| 619 |
max_scale_mtof = FixedDiv(scale_h, 2 * PLAYERRADIUS); |
| 620 |
} |
| 621 |
|
| 622 |
scale_mtof = FixedDiv(min_scale_mtof, (int) (0.7*FRACUNIT)); |
| 623 |
if (scale_mtof > max_scale_mtof) |
| 624 |
scale_mtof = min_scale_mtof; |
| 625 |
scale_ftom = FixedDiv(FRACUNIT, scale_mtof); |
| 626 |
} |
| 627 |
|
| 628 |
// |
| 629 |
// AM_SetPosition |
| 630 |
// |
| 631 |
void AM_SetPosition(void) |
| 632 |
{ |
| 633 |
if (automap_active) |
| 634 |
{ |
| 635 |
f_x = f_y = 0; |
| 636 |
f_w = SCREENWIDTH; |
| 637 |
|
| 638 |
if (automap_overlay > 0) |
| 639 |
{ |
| 640 |
f_h = viewheight; |
| 641 |
} |
| 642 |
else |
| 643 |
{ |
| 644 |
f_h = SCREENHEIGHT - ST_SCALED_HEIGHT; |
| 645 |
} |
| 646 |
} |
| 647 |
else if (dsda_ShowMinimap()) |
| 648 |
{ |
| 649 |
void dsda_CopyMinimapCoordinates(int* f_x, int* f_y, int* f_w, int* f_h); |
| 650 |
|
| 651 |
dsda_CopyMinimapCoordinates(&f_x, &f_y, &f_w, &f_h); |
| 652 |
} |
| 653 |
} |
| 654 |
|
| 655 |
void AM_initPlayerTrail(void) |
| 656 |
{ |
| 657 |
trail_index = -1; |
| 658 |
trail_size = 0; |
| 659 |
trail_size_max = dsda_IntConfig(dsda_config_map_trail_size); |
| 660 |
trail_collisions = dsda_IntConfig(dsda_config_map_trail_collisions) ? map_trail_mode_include_collisions : map_trail_mode_ignore_collisions; |
| 661 |
map_trail_mode = dsda_IntConfig(dsda_config_map_trail) ? trail_collisions : map_trail_mode_off; |
| 662 |
} |
| 663 |
|
| 664 |
// |
| 665 |
// AM_initVariables() |
| 666 |
// |
| 667 |
// Initialize the variables for the automap |
| 668 |
// |
| 669 |
// Affects the automap global variables |
| 670 |
// Status bar is notified that the automap has been entered |
| 671 |
// Passed nothing, returns nothing |
| 672 |
// |
| 673 |
static void AM_initVariables(void) |
| 674 |
{ |
| 675 |
int pnum; |
| 676 |
|
| 677 |
AM_initPlayerTrail(); |
| 678 |
|
| 679 |
if (hexen) |
| 680 |
{ |
| 681 |
numplyrlines = HEXEN_NUMPLYRLINES; |
| 682 |
player_arrow = hexen_player_arrow; |
| 683 |
} |
| 684 |
else |
| 685 |
{ |
| 686 |
numplyrlines = NUMPLYRLINES; |
| 687 |
player_arrow = doom_player_arrow; |
| 688 |
} |
| 689 |
|
| 690 |
m_paninc.x = m_paninc.y = 0; |
| 691 |
ftom_zoommul = FRACUNIT; |
| 692 |
mtof_zoommul = FRACUNIT; |
| 693 |
|
| 694 |
m_w = FTOM(f_w); |
| 695 |
m_h = FTOM(f_h); |
| 696 |
|
| 697 |
// find player to center on initially |
| 698 |
if (!playeringame[pnum = consoleplayer]) |
| 699 |
for (pnum = 0; pnum < g_maxplayers; pnum++) |
| 700 |
if (playeringame[pnum]) |
| 701 |
break; |
| 702 |
|
| 703 |
plr = &players[pnum]; |
| 704 |
m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2;//e6y |
| 705 |
m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2;//e6y |
| 706 |
AM_Ticker(); |
| 707 |
AM_changeWindowLoc(); |
| 708 |
|
| 709 |
AM_SetColors(); |
| 710 |
|
| 711 |
// for saving & restoring |
| 712 |
old_m_x = m_x; |
| 713 |
old_m_y = m_y; |
| 714 |
old_m_w = m_w; |
| 715 |
old_m_h = m_h; |
| 716 |
|
| 717 |
// inform the status bar of the change |
| 718 |
ST_Refresh(); |
| 719 |
} |
| 720 |
|
| 721 |
void AM_SetResolution(void) |
| 722 |
{ |
| 723 |
AM_SetPosition(); |
| 724 |
AM_SetScale(); |
| 725 |
} |
| 726 |
|
| 727 |
static void AM_ResetTagHighlight(void) |
| 728 |
{ |
| 729 |
Z_Free(highlight.connections); |
| 730 |
ZERO_DATA(highlight); |
| 731 |
highlight.x = INT_MIN; |
| 732 |
highlight.y = INT_MIN; |
| 733 |
} |
| 734 |
|
| 735 |
// |
| 736 |
// AM_clearMarks() |
| 737 |
// |
| 738 |
// Sets the number of marks to 0, thereby clearing them from the display |
| 739 |
// |
| 740 |
// Affects the global variable markpointnum |
| 741 |
// Passed nothing, returns nothing |
| 742 |
// |
| 743 |
void AM_clearMarks(void) |
| 744 |
{ |
| 745 |
AM_initPlayerTrail(); |
| 746 |
AM_ResetTagHighlight(); |
| 747 |
|
| 748 |
markpointnum = 0; |
| 749 |
} |
| 750 |
|
| 751 |
// [Alaux] Clear just the last mark |
| 752 |
static void AM_clearLastMark(void) |
| 753 |
{ |
| 754 |
AM_initPlayerTrail(); |
| 755 |
AM_ResetTagHighlight(); |
| 756 |
|
| 757 |
if (markpointnum) |
| 758 |
markpointnum--; |
| 759 |
} |
| 760 |
|
| 761 |
void AM_InitParams(void) |
| 762 |
{ |
| 763 |
map_blinking_locks = dsda_IntConfig(dsda_config_map_blinking_locks); |
| 764 |
map_secret_after = dsda_IntConfig(dsda_config_map_secret_after); |
| 765 |
map_pan_speed = dsda_IntConfig(dsda_config_map_pan_speed); |
| 766 |
map_scroll_speed = dsda_IntConfig(dsda_config_map_scroll_speed); |
| 767 |
map_grid_size = dsda_IntConfig(dsda_config_map_grid_size); |
| 768 |
map_wheel_zoom = dsda_IntConfig(dsda_config_map_wheel_zoom); |
| 769 |
map_things_appearance = dsda_IntConfig(dsda_config_map_things_appearance); |
| 770 |
} |
| 771 |
|
| 772 |
void AM_ExchangeScales(int full_automap, int *last_full_automap) |
| 773 |
{ |
| 774 |
static int full_min_scale_mtof; |
| 775 |
static int full_max_scale_mtof; |
| 776 |
static int full_scale_mtof; |
| 777 |
static int full_scale_ftom; |
| 778 |
|
| 779 |
if (*last_full_automap && !full_automap) |
| 780 |
{ |
| 781 |
int dsda_MinimapScale(void); |
| 782 |
|
| 783 |
full_min_scale_mtof = min_scale_mtof; |
| 784 |
full_max_scale_mtof = max_scale_mtof; |
| 785 |
full_scale_mtof = scale_mtof; |
| 786 |
full_scale_ftom = scale_ftom; |
| 787 |
|
| 788 |
min_scale_mtof = |
| 789 |
max_scale_mtof = |
| 790 |
scale_mtof = FixedDiv(f_w << FRACBITS, dsda_MinimapScale() << MAPBITS); |
| 791 |
scale_ftom = FixedDiv(FRACUNIT, scale_mtof); |
| 792 |
} |
| 793 |
else if (!*last_full_automap && full_automap) |
| 794 |
{ |
| 795 |
min_scale_mtof = full_min_scale_mtof; |
| 796 |
max_scale_mtof = full_max_scale_mtof; |
| 797 |
scale_mtof = full_scale_mtof; |
| 798 |
scale_ftom = full_scale_ftom; |
| 799 |
} |
| 800 |
|
| 801 |
*last_full_automap = full_automap; |
| 802 |
} |
| 803 |
|
| 804 |
// |
| 805 |
// AM_Stop() |
| 806 |
// |
| 807 |
// Cease automap operations, unload patches, notify status bar |
| 808 |
// |
| 809 |
// Passed nothing, returns nothing |
| 810 |
// |
| 811 |
void AM_Stop (dboolean minimap) |
| 812 |
{ |
| 813 |
automap_active = false; |
| 814 |
|
| 815 |
if (minimap && dsda_ShowMinimap()) |
| 816 |
AM_Start(false); |
| 817 |
} |
| 818 |
|
| 819 |
// |
| 820 |
// AM_Start() |
| 821 |
// |
| 822 |
// Start up automap operations, |
| 823 |
// if a new level, or game start, (re)initialize level variables |
| 824 |
// init map variables |
| 825 |
// load mark patches |
| 826 |
// |
| 827 |
// Passed nothing, returns nothing |
| 828 |
// |
| 829 |
void AM_Start(dboolean full_automap) |
| 830 |
{ |
| 831 |
static int lastlevel = -1, lastepisode = -1; |
| 832 |
static int last_full_automap; |
| 833 |
|
| 834 |
AM_InitParams(); |
| 835 |
|
| 836 |
automap_active = full_automap; |
| 837 |
|
| 838 |
AM_SetPosition(); |
| 839 |
|
| 840 |
if (lastlevel != gamemap || lastepisode != gameepisode) |
| 841 |
{ |
| 842 |
AM_findMinMaxBoundaries(); |
| 843 |
AM_SetScale(); |
| 844 |
lastlevel = gamemap; |
| 845 |
lastepisode = gameepisode; |
| 846 |
last_full_automap = true; |
| 847 |
} |
| 848 |
|
| 849 |
AM_ExchangeScales(full_automap, &last_full_automap); |
| 850 |
|
| 851 |
AM_initVariables(); |
| 852 |
} |
| 853 |
|
| 854 |
// |
| 855 |
// AM_minOutWindowScale() |
| 856 |
// |
| 857 |
// Set the window scale to the maximum size |
| 858 |
// |
| 859 |
// Passed nothing, returns nothing |
| 860 |
// |
| 861 |
static void AM_minOutWindowScale(void) |
| 862 |
{ |
| 863 |
scale_mtof = min_scale_mtof; |
| 864 |
scale_ftom = FixedDiv(FRACUNIT, scale_mtof); |
| 865 |
AM_activateNewScale(); |
| 866 |
} |
| 867 |
|
| 868 |
// |
| 869 |
// AM_maxOutWindowScale(void) |
| 870 |
// |
| 871 |
// Set the window scale to the minimum size |
| 872 |
// |
| 873 |
// Passed nothing, returns nothing |
| 874 |
// |
| 875 |
static void AM_maxOutWindowScale(void) |
| 876 |
{ |
| 877 |
scale_mtof = max_scale_mtof; |
| 878 |
scale_ftom = FixedDiv(FRACUNIT, scale_mtof); |
| 879 |
AM_activateNewScale(); |
| 880 |
} |
| 881 |
|
| 882 |
static line_t *AM_ClosestLine(fixed_t x, fixed_t y, sector_t *sec) |
| 883 |
{ |
| 884 |
int i; |
| 885 |
line_t *closest_line = NULL; |
| 886 |
double closest_distance = DBL_MAX; |
| 887 |
|
| 888 |
for (i = 0; i < sec->linecount; ++i) |
| 889 |
{ |
| 890 |
line_t *line; |
| 891 |
double dist; |
| 892 |
|
| 893 |
line = sec->lines[i]; |
| 894 |
dist = dsda_DistancePointToLine( |
| 895 |
line->v1->x >> FRACTOMAPBITS, line->v1->y >> FRACTOMAPBITS, |
| 896 |
line->v2->x >> FRACTOMAPBITS, line->v2->y >> FRACTOMAPBITS, |
| 897 |
x, y |
| 898 |
); |
| 899 |
|
| 900 |
if (dist < closest_distance) |
| 901 |
{ |
| 902 |
closest_line = line; |
| 903 |
closest_distance = dist; |
| 904 |
} |
| 905 |
} |
| 906 |
|
| 907 |
return closest_line; |
| 908 |
} |
| 909 |
|
| 910 |
static void AM_AddHighlightConnection(mpoint_t a, mpoint_t b) |
| 911 |
{ |
| 912 |
if (!highlight.connection_max) |
| 913 |
{ |
| 914 |
highlight.connection_max = 4; |
| 915 |
highlight.connections = |
| 916 |
Z_Realloc(highlight.connections, |
| 917 |
highlight.connection_max * sizeof(*highlight.connections)); |
| 918 |
} |
| 919 |
|
| 920 |
if (highlight.connection_count == highlight.connection_max) |
| 921 |
{ |
| 922 |
highlight.connection_max *= 2; |
| 923 |
highlight.connections = |
| 924 |
Z_Realloc(highlight.connections, |
| 925 |
highlight.connection_max * sizeof(*highlight.connections)); |
| 926 |
} |
| 927 |
|
| 928 |
highlight.connections[highlight.connection_count].a = a; |
| 929 |
highlight.connections[highlight.connection_count].b = b; |
| 930 |
++highlight.connection_count; |
| 931 |
} |
| 932 |
|
| 933 |
static void AM_HighlightByTag(void) |
| 934 |
{ |
| 935 |
fixed_t x, y; |
| 936 |
sector_t *sec; |
| 937 |
line_t *line; |
| 938 |
dboolean repeat; |
| 939 |
|
| 940 |
x = m_x + m_w / 2; |
| 941 |
y = m_y + m_h / 2; |
| 942 |
|
| 943 |
repeat = (x == highlight.x && y == highlight.y); |
| 944 |
highlight.x = x; |
| 945 |
highlight.y = y; |
| 946 |
|
| 947 |
sec = R_PointInSector(x << FRACTOMAPBITS, y << FRACTOMAPBITS); |
| 948 |
line = AM_ClosestLine(x, y, sec); |
| 949 |
|
| 950 |
if (!repeat || (!highlight.sec && !highlight.line)) |
| 951 |
{ |
| 952 |
highlight.sec = sec; |
| 953 |
highlight.line = NULL; |
| 954 |
highlight.tag = sec->tag; |
| 955 |
|
| 956 |
doom_printf("Highlight sector %d, tag %d\n", highlight.sec->iSectorID, sec->tag); |
| 957 |
} |
| 958 |
else if (highlight.sec) |
| 959 |
{ |
| 960 |
highlight.sec = NULL; |
| 961 |
highlight.line = line; |
| 962 |
highlight.tag = line->tag; |
| 963 |
|
| 964 |
doom_printf("Highlight line %d, tag %d\n", highlight.line->iLineID, line->tag); |
| 965 |
} |
| 966 |
else |
| 967 |
{ |
| 968 |
highlight.line = NULL; |
| 969 |
highlight.tag = 0; |
| 970 |
|
| 971 |
doom_printf("Highlight nothing\n"); |
| 972 |
} |
| 973 |
|
| 974 |
Z_Free(highlight.connections); |
| 975 |
highlight.connections = NULL; |
| 976 |
highlight.connection_count = 0; |
| 977 |
highlight.connection_max = 0; |
| 978 |
|
| 979 |
if (highlight.tag) |
| 980 |
{ |
| 981 |
const int *id_p; |
| 982 |
mpoint_t origin; |
| 983 |
mpoint_t destination; |
| 984 |
|
| 985 |
if (highlight.line) |
| 986 |
{ |
| 987 |
sector_t *sec; |
| 988 |
|
| 989 |
R_LineCenter(&origin.x, &origin.y, highlight.line); |
| 990 |
origin.x >>= FRACTOMAPBITS; |
| 991 |
origin.y >>= FRACTOMAPBITS; |
| 992 |
|
| 993 |
FIND_SECTORS(id_p, highlight.tag) |
| 994 |
{ |
| 995 |
sec = §ors[*id_p]; |
| 996 |
|
| 997 |
R_SectorCenter(&destination.x, &destination.y, sec); |
| 998 |
destination.x >>= FRACTOMAPBITS; |
| 999 |
destination.y >>= FRACTOMAPBITS; |
| 1000 |
|
| 1001 |
AM_AddHighlightConnection(origin, destination); |
| 1002 |
} |
| 1003 |
} |
| 1004 |
else |
| 1005 |
{ |
| 1006 |
line_t *line; |
| 1007 |
|
| 1008 |
R_SectorCenter(&origin.x, &origin.y, highlight.sec); |
| 1009 |
origin.x >>= FRACTOMAPBITS; |
| 1010 |
origin.y >>= FRACTOMAPBITS; |
| 1011 |
|
| 1012 |
FIND_LINES(id_p, highlight.tag) |
| 1013 |
{ |
| 1014 |
line = &lines[*id_p]; |
| 1015 |
|
| 1016 |
R_LineCenter(&destination.x, &destination.y, line); |
| 1017 |
destination.x >>= FRACTOMAPBITS; |
| 1018 |
destination.y >>= FRACTOMAPBITS; |
| 1019 |
|
| 1020 |
AM_AddHighlightConnection(origin, destination); |
| 1021 |
} |
| 1022 |
} |
| 1023 |
} |
| 1024 |
} |
| 1025 |
|
| 1026 |
// |
| 1027 |
// AM_Responder() |
| 1028 |
// |
| 1029 |
// Handle events (user inputs) in automap mode |
| 1030 |
// |
| 1031 |
// Passed an input event, returns true if its handled |
| 1032 |
// |
| 1033 |
dboolean AM_Responder |
| 1034 |
( event_t* ev ) |
| 1035 |
{ |
| 1036 |
static int bigstate=0; |
| 1037 |
|
| 1038 |
if (dsda_InputActivated(dsda_input_map_overlay) && (automap_input || dsda_ShowMinimap())) |
| 1039 |
{ |
| 1040 |
dsda_CycleConfig(dsda_config_automap_overlay, true); |
| 1041 |
dsda_AddMessage(automap_overlay == 0 ? s_AMSTR_OVERLAYOFF : |
| 1042 |
automap_overlay == 1 ? s_AMSTR_OVERLAYON : |
| 1043 |
"Overlay Mode Dark"); |
| 1044 |
AM_SetPosition(); |
| 1045 |
AM_activateNewScale(); |
| 1046 |
|
| 1047 |
return true; |
| 1048 |
} |
| 1049 |
|
| 1050 |
if (!automap_input) |
| 1051 |
{ |
| 1052 |
if (dsda_InputActivated(dsda_input_map)) |
| 1053 |
{ |
| 1054 |
AM_Start(true); |
| 1055 |
return true; |
| 1056 |
} |
| 1057 |
} |
| 1058 |
else if (dsda_InputActivated(dsda_input_map)) |
| 1059 |
{ |
| 1060 |
bigstate = 0; |
| 1061 |
AM_Stop(true); |
| 1062 |
|
| 1063 |
return true; |
| 1064 |
} |
| 1065 |
else if (dsda_InputActivated(dsda_input_map_right)) |
| 1066 |
{ |
| 1067 |
if (!automap_follow) |
| 1068 |
{ |
| 1069 |
m_paninc.x = FTOM(F_PANINC); |
| 1070 |
return true; |
| 1071 |
} |
| 1072 |
} |
| 1073 |
else if (dsda_InputActivated(dsda_input_map_left)) |
| 1074 |
{ |
| 1075 |
if (!automap_follow) |
| 1076 |
{ |
| 1077 |
m_paninc.x = -FTOM(F_PANINC); |
| 1078 |
return true; |
| 1079 |
} |
| 1080 |
} |
| 1081 |
else if (dsda_InputDeactivated(dsda_input_map_right)) |
| 1082 |
{ |
| 1083 |
if (!automap_follow) |
| 1084 |
m_paninc.x = 0; |
| 1085 |
} |
| 1086 |
else if (dsda_InputDeactivated(dsda_input_map_left)) |
| 1087 |
{ |
| 1088 |
if (!automap_follow) |
| 1089 |
m_paninc.x = 0; |
| 1090 |
} |
| 1091 |
else if (dsda_InputActivated(dsda_input_map_up)) |
| 1092 |
{ |
| 1093 |
if (!automap_follow) |
| 1094 |
{ |
| 1095 |
m_paninc.y = FTOM(F_PANINC); |
| 1096 |
return true; |
| 1097 |
} |
| 1098 |
} |
| 1099 |
else if (dsda_InputActivated(dsda_input_map_down)) |
| 1100 |
{ |
| 1101 |
if (!automap_follow) |
| 1102 |
{ |
| 1103 |
m_paninc.y = -FTOM(F_PANINC); |
| 1104 |
return true; |
| 1105 |
} |
| 1106 |
} |
| 1107 |
else if (dsda_InputDeactivated(dsda_input_map_up)) |
| 1108 |
{ |
| 1109 |
if (!automap_follow) |
| 1110 |
m_paninc.y = 0; |
| 1111 |
} |
| 1112 |
else if (dsda_InputDeactivated(dsda_input_map_down)) |
| 1113 |
{ |
| 1114 |
if (!automap_follow) |
| 1115 |
m_paninc.y = 0; |
| 1116 |
} |
| 1117 |
else if ( |
| 1118 |
dsda_InputActivated(dsda_input_map_zoomout) || |
| 1119 |
(map_wheel_zoom && ev->type == ev_keydown && ev->data1.i == KEYD_MWHEELDOWN) |
| 1120 |
) |
| 1121 |
{ |
| 1122 |
mtof_zoommul = M_ZOOMOUT; |
| 1123 |
ftom_zoommul = M_ZOOMIN; |
| 1124 |
curr_mtof_zoommul = mtof_zoommul; |
| 1125 |
zoom_leveltime = leveltime; |
| 1126 |
|
| 1127 |
return true; |
| 1128 |
} |
| 1129 |
else if ( |
| 1130 |
dsda_InputActivated(dsda_input_map_zoomin) || |
| 1131 |
(map_wheel_zoom && ev->type == ev_keydown && ev->data1.i == KEYD_MWHEELUP) |
| 1132 |
) |
| 1133 |
{ |
| 1134 |
mtof_zoommul = M_ZOOMIN; |
| 1135 |
ftom_zoommul = M_ZOOMOUT; |
| 1136 |
curr_mtof_zoommul = mtof_zoommul; |
| 1137 |
zoom_leveltime = leveltime; |
| 1138 |
|
| 1139 |
return true; |
| 1140 |
} |
| 1141 |
else if (dsda_InputActivated(dsda_input_map_gobig)) |
| 1142 |
{ |
| 1143 |
bigstate = !bigstate; |
| 1144 |
if (bigstate) |
| 1145 |
{ |
| 1146 |
AM_saveScaleAndLoc(); |
| 1147 |
AM_minOutWindowScale(); |
| 1148 |
} |
| 1149 |
else |
| 1150 |
AM_restoreScaleAndLoc(); |
| 1151 |
|
| 1152 |
return true; |
| 1153 |
} |
| 1154 |
else if (dsda_InputActivated(dsda_input_map_follow)) |
| 1155 |
{ |
| 1156 |
dsda_ToggleConfig(dsda_config_automap_follow, true); |
| 1157 |
dsda_AddMessage(automap_follow ? s_AMSTR_FOLLOWON : s_AMSTR_FOLLOWOFF); |
| 1158 |
|
| 1159 |
return true; |
| 1160 |
} |
| 1161 |
else if (dsda_InputActivated(dsda_input_map_grid)) |
| 1162 |
{ |
| 1163 |
dsda_ToggleConfig(dsda_config_automap_grid, true); |
| 1164 |
dsda_AddMessage(automap_grid ? s_AMSTR_GRIDON : s_AMSTR_GRIDOFF); |
| 1165 |
|
| 1166 |
return true; |
| 1167 |
} |
| 1168 |
else if (dsda_InputActivated(dsda_input_map_mark)) |
| 1169 |
{ |
| 1170 |
/* Ty 03/27/98 - *not* externalized |
| 1171 |
* cph 2001/11/20 - use doom_printf so we don't have our own buffer */ |
| 1172 |
doom_printf("%s %d", s_AMSTR_MARKEDSPOT, markpointnum); |
| 1173 |
AM_addMark(); |
| 1174 |
|
| 1175 |
return true; |
| 1176 |
} |
| 1177 |
else if (dsda_InputActivated(dsda_input_map_clear)) |
| 1178 |
{ |
| 1179 |
// [Alaux] Clear just the last mark |
| 1180 |
if (markpointnum) |
| 1181 |
AM_clearLastMark(); |
| 1182 |
|
| 1183 |
if (markpointnum) |
| 1184 |
doom_printf("Cleared spot %d", markpointnum); |
| 1185 |
else |
| 1186 |
dsda_AddMessage(s_AMSTR_MARKSCLEARED); |
| 1187 |
|
| 1188 |
return true; |
| 1189 |
} |
| 1190 |
else if (dsda_InputActivated(dsda_input_map_rotate)) |
| 1191 |
{ |
| 1192 |
dsda_ToggleConfig(dsda_config_automap_rotate, true); |
| 1193 |
dsda_AddMessage(automap_rotate ? s_AMSTR_ROTATEON : s_AMSTR_ROTATEOFF); |
| 1194 |
|
| 1195 |
return true; |
| 1196 |
} |
| 1197 |
else if (dsda_InputActivated(dsda_input_map_textured)) |
| 1198 |
{ |
| 1199 |
dsda_ToggleConfig(dsda_config_map_textured, true); |
| 1200 |
dsda_AddMessage(map_textured ? s_AMSTR_TEXTUREDON : s_AMSTR_TEXTUREDOFF); |
| 1201 |
|
| 1202 |
return true; |
| 1203 |
} |
| 1204 |
else if ( |
| 1205 |
dsda_InputDeactivated(dsda_input_map_zoomout) || |
| 1206 |
dsda_InputDeactivated(dsda_input_map_zoomin) || |
| 1207 |
( |
| 1208 |
map_wheel_zoom && ev->type == ev_keyup && |
| 1209 |
(ev->data1.i == KEYD_MWHEELDOWN || ev->data1.i == KEYD_MWHEELUP) |
| 1210 |
) |
| 1211 |
) |
| 1212 |
{ |
| 1213 |
stop_zooming = true; |
| 1214 |
|
| 1215 |
if (leveltime != zoom_leveltime) |
| 1216 |
AM_StopZooming(); |
| 1217 |
} |
| 1218 |
else if (dsda_InputActivated(dsda_input_map_highlight_by_tag)) |
| 1219 |
{ |
| 1220 |
if (!dsda_RevealAutomap()) |
| 1221 |
doom_printf("Highlight requires iddt"); |
| 1222 |
else |
| 1223 |
AM_HighlightByTag(); |
| 1224 |
|
| 1225 |
return true; |
| 1226 |
} |
| 1227 |
|
| 1228 |
return false; |
| 1229 |
} |
| 1230 |
|
| 1231 |
// |
| 1232 |
// AM_rotate() |
| 1233 |
// |
| 1234 |
// Rotation in 2D. |
| 1235 |
// Used to rotate player arrow line character. |
| 1236 |
// |
| 1237 |
// Passed the coordinates of a point, and an angle |
| 1238 |
// Returns the coordinates rotated by the angle |
| 1239 |
// |
| 1240 |
// CPhipps - made static & enhanced for automap rotation |
| 1241 |
|
| 1242 |
static void AM_rotate(fixed_t* x, fixed_t* y, angle_t a) |
| 1243 |
{ |
| 1244 |
fixed_t tmpx; |
| 1245 |
|
| 1246 |
tmpx = FixedMul(*x, finecosine[a>>ANGLETOFINESHIFT]) - |
| 1247 |
FixedMul(*y, finesine[a>>ANGLETOFINESHIFT]); |
| 1248 |
|
| 1249 |
*y = FixedMul(*x, finesine[a>>ANGLETOFINESHIFT]) + |
| 1250 |
FixedMul(*y, finecosine[a>>ANGLETOFINESHIFT]); |
| 1251 |
|
| 1252 |
*x = tmpx; |
| 1253 |
} |
| 1254 |
|
| 1255 |
void AM_rotatePoint(mpoint_t *p) |
| 1256 |
{ |
| 1257 |
fixed_t tmpx; |
| 1258 |
|
| 1259 |
if (am_frame.precise) |
| 1260 |
{ |
| 1261 |
float f; |
| 1262 |
|
| 1263 |
p->fx = (float)p->x - am_frame.centerx_f; |
| 1264 |
p->fy = (float)p->y - am_frame.centery_f; |
| 1265 |
|
| 1266 |
f = (p->fx * am_frame.cos_f) - (p->fy * am_frame.sin_f) + am_frame.centerx_f; |
| 1267 |
p->fy = (p->fx * am_frame.sin_f) + (p->fy * am_frame.cos_f) + am_frame.centery_f; |
| 1268 |
p->fx = f; |
| 1269 |
} |
| 1270 |
|
| 1271 |
p->x -= am_frame.centerx; |
| 1272 |
p->y -= am_frame.centery; |
| 1273 |
|
| 1274 |
tmpx = FixedMul(p->x, am_frame.cos) - FixedMul(p->y, am_frame.sin) + am_frame.centerx; |
| 1275 |
p->y = FixedMul(p->x, am_frame.sin) + FixedMul(p->y, am_frame.cos) + am_frame.centery; |
| 1276 |
p->x = tmpx; |
| 1277 |
} |
| 1278 |
|
| 1279 |
// |
| 1280 |
// AM_changeWindowScale() |
| 1281 |
// |
| 1282 |
// Automap zooming |
| 1283 |
// |
| 1284 |
// Passed nothing, returns nothing |
| 1285 |
// |
| 1286 |
static void AM_changeWindowScale(void) |
| 1287 |
{ |
| 1288 |
if (movement_smooth) |
| 1289 |
{ |
| 1290 |
float f_zoominc = (float)F_ZOOMINC / (float)FRACUNIT * (float)tic_vars.frac; |
| 1291 |
|
| 1292 |
if (f_zoominc < 0.01f) |
| 1293 |
f_zoominc = 0.01f; |
| 1294 |
|
| 1295 |
scale_mtof = prev_scale_mtof; |
| 1296 |
if (curr_mtof_zoommul == M_ZOOMIN) |
| 1297 |
{ |
| 1298 |
mtof_zoommul = ((int) ((float)FRACUNIT * (1.00f + f_zoominc / 200.0f))); |
| 1299 |
ftom_zoommul = ((int) ((float)FRACUNIT / (1.00f + f_zoominc / 200.0f))); |
| 1300 |
} |
| 1301 |
if (curr_mtof_zoommul == M_ZOOMOUT) |
| 1302 |
{ |
| 1303 |
mtof_zoommul = ((int) ((float)FRACUNIT / (1.00f + f_zoominc / 200.0f))); |
| 1304 |
ftom_zoommul = ((int) ((float)FRACUNIT * (1.00f + f_zoominc / 200.0f))); |
| 1305 |
} |
| 1306 |
} |
| 1307 |
|
| 1308 |
scale_mtof = FixedMul(scale_mtof, mtof_zoommul); |
| 1309 |
scale_ftom = FixedDiv(FRACUNIT, scale_mtof); |
| 1310 |
|
| 1311 |
if (scale_mtof < min_scale_mtof) |
| 1312 |
AM_minOutWindowScale(); |
| 1313 |
else if (scale_mtof > max_scale_mtof) |
| 1314 |
AM_maxOutWindowScale(); |
| 1315 |
else |
| 1316 |
AM_activateNewScale(); |
| 1317 |
} |
| 1318 |
|
| 1319 |
// |
| 1320 |
// AM_doFollowPlayer() |
| 1321 |
// |
| 1322 |
// Turn on follow mode - the map scrolls opposite to player motion |
| 1323 |
// |
| 1324 |
// Passed nothing, returns nothing |
| 1325 |
// |
| 1326 |
static void AM_doFollowPlayer(void) |
| 1327 |
{ |
| 1328 |
AM_SetMapCenter(viewx, viewy); |
| 1329 |
} |
| 1330 |
|
| 1331 |
// |
| 1332 |
// AM_Ticker() |
| 1333 |
// |
| 1334 |
// Updates on gametic - enter follow mode, zoom, or change map location |
| 1335 |
// |
| 1336 |
// Passed nothing, returns nothing |
| 1337 |
// |
| 1338 |
void AM_Ticker (void) |
| 1339 |
{ |
| 1340 |
prev_scale_mtof = scale_mtof; |
| 1341 |
prev_m_x = m_x; |
| 1342 |
prev_m_y = m_y; |
| 1343 |
|
| 1344 |
if (stop_zooming && leveltime - zoom_leveltime != 1) |
| 1345 |
AM_StopZooming(); |
| 1346 |
} |
| 1347 |
|
| 1348 |
// |
| 1349 |
// AM_clipMline() |
| 1350 |
// |
| 1351 |
// Automap clipping of lines. |
| 1352 |
// |
| 1353 |
// Based on Cohen-Sutherland clipping algorithm but with a slightly |
| 1354 |
// faster reject and precalculated slopes. If the speed is needed, |
| 1355 |
// use a hash algorithm to handle the common cases. |
| 1356 |
// |
| 1357 |
// Passed the line's coordinates on map and in the frame buffer performs |
| 1358 |
// clipping on them in the lines frame coordinates. |
| 1359 |
// Returns true if any part of line was not clipped |
| 1360 |
// |
| 1361 |
static dboolean AM_clipMline |
| 1362 |
( mline_t* ml, |
| 1363 |
fline_t* fl ) |
| 1364 |
{ |
| 1365 |
enum |
| 1366 |
{ |
| 1367 |
LEFT =1, |
| 1368 |
RIGHT =2, |
| 1369 |
BOTTOM =4, |
| 1370 |
TOP =8 |
| 1371 |
}; |
| 1372 |
|
| 1373 |
register int outcode1 = 0; |
| 1374 |
register int outcode2 = 0; |
| 1375 |
register int outside; |
| 1376 |
|
| 1377 |
fpoint_t tmp; |
| 1378 |
int dx; |
| 1379 |
int dy; |
| 1380 |
float dx_f, dy_f; |
| 1381 |
|
| 1382 |
|
| 1383 |
#define DOOUTCODE(oc, mx, my) \ |
| 1384 |
(oc) = 0; \ |
| 1385 |
if ((my) < f_y) (oc) |= TOP; \ |
| 1386 |
else if ((my) >= f_y + f_h) (oc) |= BOTTOM; \ |
| 1387 |
if ((mx) < f_x) (oc) |= LEFT; \ |
| 1388 |
else if ((mx) >= f_x + f_w) (oc) |= RIGHT; |
| 1389 |
|
| 1390 |
|
| 1391 |
// do trivial rejects and outcodes |
| 1392 |
if (ml->a.y > m_y2) |
| 1393 |
outcode1 = TOP; |
| 1394 |
else if (ml->a.y < m_y) |
| 1395 |
outcode1 = BOTTOM; |
| 1396 |
|
| 1397 |
if (ml->b.y > m_y2) |
| 1398 |
outcode2 = TOP; |
| 1399 |
else if (ml->b.y < m_y) |
| 1400 |
outcode2 = BOTTOM; |
| 1401 |
|
| 1402 |
if (outcode1 & outcode2) |
| 1403 |
return false; // trivially outside |
| 1404 |
|
| 1405 |
if (ml->a.x < m_x) |
| 1406 |
outcode1 |= LEFT; |
| 1407 |
else if (ml->a.x > m_x2) |
| 1408 |
outcode1 |= RIGHT; |
| 1409 |
|
| 1410 |
if (ml->b.x < m_x) |
| 1411 |
outcode2 |= LEFT; |
| 1412 |
else if (ml->b.x > m_x2) |
| 1413 |
outcode2 |= RIGHT; |
| 1414 |
|
| 1415 |
if (outcode1 & outcode2) |
| 1416 |
return false; // trivially outside |
| 1417 |
|
| 1418 |
// transform to frame-buffer coordinates. |
| 1419 |
fl->a.x = CXMTOF(ml->a.x); |
| 1420 |
fl->a.y = CYMTOF(ml->a.y); |
| 1421 |
fl->b.x = CXMTOF(ml->b.x); |
| 1422 |
fl->b.y = CYMTOF(ml->b.y); |
| 1423 |
|
| 1424 |
DOOUTCODE(outcode1, fl->a.x, fl->a.y); |
| 1425 |
DOOUTCODE(outcode2, fl->b.x, fl->b.y); |
| 1426 |
|
| 1427 |
if (outcode1 & outcode2) |
| 1428 |
return false; |
| 1429 |
|
| 1430 |
if (am_frame.precise) |
| 1431 |
{ |
| 1432 |
fl->a.fx = CXMTOF_F(ml->a.fx); |
| 1433 |
fl->a.fy = CYMTOF_F(ml->a.fy); |
| 1434 |
fl->b.fx = CXMTOF_F(ml->b.fx); |
| 1435 |
fl->b.fy = CYMTOF_F(ml->b.fy); |
| 1436 |
} |
| 1437 |
|
| 1438 |
while (outcode1 | outcode2) |
| 1439 |
{ |
| 1440 |
// may be partially inside box |
| 1441 |
// find an outside point |
| 1442 |
if (outcode1) |
| 1443 |
outside = outcode1; |
| 1444 |
else |
| 1445 |
outside = outcode2; |
| 1446 |
|
| 1447 |
// clip to each side |
| 1448 |
if (outside & TOP) |
| 1449 |
{ |
| 1450 |
dy = fl->a.y - fl->b.y; |
| 1451 |
dx = fl->b.x - fl->a.x; |
| 1452 |
// 'int64' math to avoid overflows on long lines |
| 1453 |
tmp.x = fl->a.x + (fixed_t)(((int64_t)dx*(fl->a.y-f_y))/dy); |
| 1454 |
tmp.y = f_y; |
| 1455 |
if (am_frame.precise) |
| 1456 |
{ |
| 1457 |
dy_f = fl->a.fy - fl->b.fy; |
| 1458 |
dx_f = fl->b.fx - fl->a.fx; |
| 1459 |
tmp.fx = fl->a.fx + (dx_f*(fl->a.fy-f_y))/dy_f; |
| 1460 |
tmp.fy = (float)f_y; |
| 1461 |
} |
| 1462 |
} |
| 1463 |
else if (outside & BOTTOM) |
| 1464 |
{ |
| 1465 |
dy = fl->a.y - fl->b.y; |
| 1466 |
dx = fl->b.x - fl->a.x; |
| 1467 |
tmp.x = fl->a.x + (fixed_t)(((int64_t)dx*(fl->a.y-(f_y+f_h)))/dy); |
| 1468 |
tmp.y = f_y+f_h-1; |
| 1469 |
if (am_frame.precise) |
| 1470 |
{ |
| 1471 |
dy_f = fl->a.fy - fl->b.fy; |
| 1472 |
dx_f = fl->b.fx - fl->a.fx; |
| 1473 |
tmp.fx = fl->a.fx + (dx_f*(fl->a.fy-(f_y+f_h)))/dy_f; |
| 1474 |
tmp.fy = (float)(f_y+f_h-1); |
| 1475 |
} |
| 1476 |
} |
| 1477 |
else if (outside & RIGHT) |
| 1478 |
{ |
| 1479 |
dy = fl->b.y - fl->a.y; |
| 1480 |
dx = fl->b.x - fl->a.x; |
| 1481 |
tmp.y = fl->a.y + (fixed_t)(((int64_t)dy*(f_x+f_w-1 - fl->a.x))/dx); |
| 1482 |
tmp.x = f_x+f_w-1; |
| 1483 |
if (am_frame.precise) |
| 1484 |
{ |
| 1485 |
dy_f = fl->b.fy - fl->a.fy; |
| 1486 |
dx_f = fl->b.fx - fl->a.fx; |
| 1487 |
tmp.fy = fl->a.fy + (dy_f*(f_x+f_w-1 - fl->a.fx))/dx_f; |
| 1488 |
tmp.fx = (float)(f_x+f_w-1); |
| 1489 |
} |
| 1490 |
} |
| 1491 |
else if (outside & LEFT) |
| 1492 |
{ |
| 1493 |
dy = fl->b.y - fl->a.y; |
| 1494 |
dx = fl->b.x - fl->a.x; |
| 1495 |
tmp.y = fl->a.y + (fixed_t)(((int64_t)dy*(f_x-fl->a.x))/dx); |
| 1496 |
tmp.x = f_x; |
| 1497 |
if (am_frame.precise) |
| 1498 |
{ |
| 1499 |
dy_f = fl->b.fy - fl->a.fy; |
| 1500 |
dx_f = fl->b.fx - fl->a.fx; |
| 1501 |
tmp.fy = fl->a.fy + (dy_f*(f_x-fl->a.fx))/dx_f; |
| 1502 |
tmp.fx = (float)f_x; |
| 1503 |
} |
| 1504 |
} |
| 1505 |
|
| 1506 |
if (outside == outcode1) |
| 1507 |
{ |
| 1508 |
fl->a = tmp; |
| 1509 |
DOOUTCODE(outcode1, fl->a.x, fl->a.y); |
| 1510 |
} |
| 1511 |
else |
| 1512 |
{ |
| 1513 |
fl->b = tmp; |
| 1514 |
DOOUTCODE(outcode2, fl->b.x, fl->b.y); |
| 1515 |
} |
| 1516 |
|
| 1517 |
if (outcode1 & outcode2) |
| 1518 |
return false; // trivially outside |
| 1519 |
} |
| 1520 |
|
| 1521 |
return true; |
| 1522 |
} |
| 1523 |
#undef DOOUTCODE |
| 1524 |
|
| 1525 |
// |
| 1526 |
// AM_drawMline() |
| 1527 |
// |
| 1528 |
// Clip lines, draw visible parts of lines. |
| 1529 |
// |
| 1530 |
// Passed the map coordinates of the line, and the color to draw it |
| 1531 |
// Color -1 is special and prevents drawing. Color 247 is special and |
| 1532 |
// is translated to black, allowing Color 0 to represent feature disable |
| 1533 |
// in the defaults file. |
| 1534 |
// Returns nothing. |
| 1535 |
// |
| 1536 |
static void AM_drawMline |
| 1537 |
( mline_t* ml, |
| 1538 |
int color ) |
| 1539 |
{ |
| 1540 |
static fline_t fl; |
| 1541 |
|
| 1542 |
if (color==-1) // jff 4/3/98 allow not drawing any sort of line |
| 1543 |
return; // by setting its color to -1 |
| 1544 |
if (color==247) // jff 4/3/98 if color is 247 (xparent), use black |
| 1545 |
color=0; |
| 1546 |
|
| 1547 |
if (AM_clipMline(ml, &fl)) |
| 1548 |
{ |
| 1549 |
// draws it on frame buffer using fb coords |
| 1550 |
if (!raven && map_use_multisampling) |
| 1551 |
V_DrawLineWu(&fl, color); |
| 1552 |
else |
| 1553 |
V_DrawLine(&fl, color); |
| 1554 |
} |
| 1555 |
} |
| 1556 |
|
| 1557 |
// |
| 1558 |
// AM_drawGrid() |
| 1559 |
// |
| 1560 |
// Draws blockmap aligned grid lines. |
| 1561 |
// |
| 1562 |
// Passed the color to draw the grid lines |
| 1563 |
// Returns nothing |
| 1564 |
// |
| 1565 |
static void AM_drawGrid(int color) |
| 1566 |
{ |
| 1567 |
fixed_t x, y; |
| 1568 |
fixed_t start, end; |
| 1569 |
mline_t ml; |
| 1570 |
fixed_t minlen, extx, exty; |
| 1571 |
fixed_t minx, miny; |
| 1572 |
fixed_t gridsize = map_grid_size << MAPBITS; |
| 1573 |
|
| 1574 |
// [RH] Calculate a minimum for how long the grid lines should be so that |
| 1575 |
// they cover the screen at any rotation. |
| 1576 |
minlen = M_DoubleToInt(sqrt ((float)m_w*(float)m_w + (float)m_h*(float)m_h)); |
| 1577 |
extx = (minlen - m_w) / 2; |
| 1578 |
exty = (minlen - m_h) / 2; |
| 1579 |
|
| 1580 |
minx = m_x; |
| 1581 |
miny = m_y; |
| 1582 |
|
| 1583 |
// Fix vanilla automap grid bug: losing grid lines near the map boundary |
| 1584 |
// due to unnecessary addition of MAPBLOCKUNITS to start |
| 1585 |
// Proper math is to just subtract the remainder; AM_drawMLine will take care |
| 1586 |
// of clipping if an extra line is offscreen. |
| 1587 |
|
| 1588 |
// Figure out start of vertical gridlines |
| 1589 |
start = minx - extx; |
| 1590 |
if ((start - (bmaporgx>>FRACTOMAPBITS)) % gridsize) |
| 1591 |
start -= ((start - (bmaporgx>>FRACTOMAPBITS)) % gridsize); |
| 1592 |
end = minx + minlen - extx; |
| 1593 |
|
| 1594 |
// draw vertical gridlines |
| 1595 |
for (x = start; x < end; x += gridsize) |
| 1596 |
{ |
| 1597 |
ml.a.x = x; |
| 1598 |
ml.b.x = x; |
| 1599 |
ml.a.y = miny - exty; |
| 1600 |
ml.b.y = ml.a.y + minlen; |
| 1601 |
if (automap_rotate) |
| 1602 |
{ |
| 1603 |
AM_rotatePoint (&ml.a); |
| 1604 |
AM_rotatePoint (&ml.b); |
| 1605 |
} |
| 1606 |
else |
| 1607 |
{ |
| 1608 |
AM_SetMPointFloatValue(&ml.a); |
| 1609 |
AM_SetMPointFloatValue(&ml.b); |
| 1610 |
} |
| 1611 |
AM_drawMline(&ml, color); |
| 1612 |
} |
| 1613 |
|
| 1614 |
// Figure out start of horizontal gridlines |
| 1615 |
start = miny - exty; |
| 1616 |
if ((start - (bmaporgy>>FRACTOMAPBITS)) % gridsize) |
| 1617 |
start -= ((start - (bmaporgy>>FRACTOMAPBITS)) % gridsize); |
| 1618 |
end = miny + minlen - exty; |
| 1619 |
|
| 1620 |
// draw horizontal gridlines |
| 1621 |
for (y = start; y < end; y += gridsize) |
| 1622 |
{ |
| 1623 |
ml.a.x = minx - extx; |
| 1624 |
ml.b.x = ml.a.x + minlen; |
| 1625 |
ml.a.y = y; |
| 1626 |
ml.b.y = y; |
| 1627 |
if (automap_rotate) |
| 1628 |
{ |
| 1629 |
AM_rotatePoint (&ml.a); |
| 1630 |
AM_rotatePoint (&ml.b); |
| 1631 |
} |
| 1632 |
else |
| 1633 |
{ |
| 1634 |
AM_SetMPointFloatValue(&ml.a); |
| 1635 |
AM_SetMPointFloatValue(&ml.b); |
| 1636 |
} |
| 1637 |
AM_drawMline(&ml, color); |
| 1638 |
} |
| 1639 |
} |
| 1640 |
|
| 1641 |
static dboolean AM_DrawHiddenSecrets(void) |
| 1642 |
{ |
| 1643 |
return !!mapcolor_p->secr && !map_secret_after; |
| 1644 |
} |
| 1645 |
|
| 1646 |
static dboolean AM_DrawRevealedSecrets(void) |
| 1647 |
{ |
| 1648 |
return !!mapcolor_p->revsecr; |
| 1649 |
} |
| 1650 |
|
| 1651 |
// |
| 1652 |
// Determines visible lines, draws them. |
| 1653 |
// This is LineDef based, not LineSeg based. |
| 1654 |
// |
| 1655 |
// jff 1/5/98 many changes in this routine |
| 1656 |
// backward compatibility not needed, so just changes, no ifs |
| 1657 |
// addition of clauses for: |
| 1658 |
// doors opening, keyed door id, secret sectors, |
| 1659 |
// teleports, exit lines, key things |
| 1660 |
// ability to suppress any of added features or lines with no height changes |
| 1661 |
// |
| 1662 |
// support for gamma correction in automap abandoned |
| 1663 |
// |
| 1664 |
// jff 4/3/98 changed mapcolor_xxxx=0 as control to disable feature |
| 1665 |
// jff 4/3/98 changed mapcolor_xxxx=-1 to disable drawing line completely |
| 1666 |
// |
| 1667 |
|
| 1668 |
static automap_style_t AM_wallStyle(int i) |
| 1669 |
{ |
| 1670 |
switch (lines[i].automap_style) |
| 1671 |
{ |
| 1672 |
case ams_default: |
| 1673 |
break; |
| 1674 |
|
| 1675 |
// These styles have no corresponding colors in dsda-doom |
| 1676 |
case ams_extra_floor: |
| 1677 |
case ams_portal: |
| 1678 |
case ams_special: |
| 1679 |
if (!lines[i].backsector) |
| 1680 |
return ams_one_sided; |
| 1681 |
return ams_two_sided; |
| 1682 |
|
| 1683 |
default: |
| 1684 |
return lines[i].automap_style; |
| 1685 |
} |
| 1686 |
|
| 1687 |
// if line has been seen or IDDT has been used |
| 1688 |
if (dsda_RevealAutomap() || (lines[i].flags & ML_MAPPED)) |
| 1689 |
{ |
| 1690 |
if ((lines[i].flags & ML_DONTDRAW) && !dsda_RevealAutomap()) |
| 1691 |
return ams_invisible; |
| 1692 |
|
| 1693 |
if ( |
| 1694 |
(mapcolor_p->bdor || mapcolor_p->ydor || mapcolor_p->rdor) && |
| 1695 |
!(lines[i].flags & ML_SECRET) && dsda_DoorType(i) != -1 |
| 1696 |
) |
| 1697 |
return ams_locked; |
| 1698 |
|
| 1699 |
if (mapcolor_p->exitsecr && (dsda_IsSecretExitLine(i) && !dsda_IsExitLine(i))) |
| 1700 |
return ams_exit_secret; |
| 1701 |
|
| 1702 |
if (mapcolor_p->exit && (dsda_IsExitLine(i) || dsda_IsSecretExitLine(i))) |
| 1703 |
return ams_exit; |
| 1704 |
|
| 1705 |
if (mapcolor_p->exitsecr && (dsda_IsDeathSecretExitLine(i) && !dsda_IsDeathExitLine(i))) |
| 1706 |
return ams_exit_secret; |
| 1707 |
|
| 1708 |
if (mapcolor_p->exit && (dsda_IsDeathExitLine(i) || dsda_IsDeathSecretExitLine(i))) |
| 1709 |
return ams_exit; |
| 1710 |
|
| 1711 |
if (!lines[i].backsector) // 1-sided |
| 1712 |
{ |
| 1713 |
if (AM_DrawHiddenSecrets() && P_IsSecret(lines[i].frontsector)) |
| 1714 |
return ams_secret; |
| 1715 |
else if (AM_DrawRevealedSecrets() && P_RevealedSecret(lines[i].frontsector)) |
| 1716 |
return ams_revealed_secret; |
| 1717 |
else |
| 1718 |
return ams_one_sided; |
| 1719 |
} |
| 1720 |
else // 2-sided |
| 1721 |
{ |
| 1722 |
if (mapcolor_p->tele && !(lines[i].flags & ML_SECRET) && dsda_IsTeleportLine(i)) |
| 1723 |
{ |
| 1724 |
return ams_teleport; |
| 1725 |
} |
| 1726 |
else if (lines[i].flags & ML_SECRET) |
| 1727 |
{ |
| 1728 |
return ams_one_sided; |
| 1729 |
} |
| 1730 |
else if ( |
| 1731 |
mapcolor_p->clsd && |
| 1732 |
!(lines[i].flags & ML_SECRET) && |
| 1733 |
((lines[i].backsector->floorheight==lines[i].backsector->ceilingheight) || |
| 1734 |
(lines[i].frontsector->floorheight==lines[i].frontsector->ceilingheight)) |
| 1735 |
) |
| 1736 |
{ |
| 1737 |
return ams_closed_door; |
| 1738 |
} |
| 1739 |
else if ( |
| 1740 |
AM_DrawHiddenSecrets() && |
| 1741 |
(P_IsSecret(lines[i].frontsector) || P_IsSecret(lines[i].backsector)) |
| 1742 |
) |
| 1743 |
{ |
| 1744 |
return ams_secret; |
| 1745 |
} |
| 1746 |
else if ( |
| 1747 |
AM_DrawRevealedSecrets() && |
| 1748 |
(P_RevealedSecret(lines[i].frontsector) || P_RevealedSecret(lines[i].backsector)) |
| 1749 |
) |
| 1750 |
{ |
| 1751 |
return ams_revealed_secret; |
| 1752 |
} |
| 1753 |
else if ( |
| 1754 |
(mapcolor_p->exitsecr && !mapcolor_p->exit) && |
| 1755 |
(P_IsDeathExit(lines[i].frontsector) || P_IsDeathExit(lines[i].backsector)) |
| 1756 |
) |
| 1757 |
{ |
| 1758 |
return ams_exit_secret; |
| 1759 |
} |
| 1760 |
else if ( |
| 1761 |
(mapcolor_p->exit || mapcolor_p->exitsecr) && |
| 1762 |
(P_IsDeathExit(lines[i].frontsector) || P_IsDeathExit(lines[i].backsector)) |
| 1763 |
) |
| 1764 |
{ |
| 1765 |
return ams_exit; |
| 1766 |
} |
| 1767 |
else if (lines[i].backsector->floorheight != |
| 1768 |
lines[i].frontsector->floorheight) |
| 1769 |
{ |
| 1770 |
return ams_floor_diff; |
| 1771 |
} |
| 1772 |
else if (lines[i].backsector->ceilingheight != |
| 1773 |
lines[i].frontsector->ceilingheight) |
| 1774 |
{ |
| 1775 |
return ams_ceiling_diff; |
| 1776 |
} |
| 1777 |
else if (mapcolor_p->flat && dsda_RevealAutomap()) |
| 1778 |
{ |
| 1779 |
return ams_two_sided; |
| 1780 |
} |
| 1781 |
} |
| 1782 |
} |
| 1783 |
else if (plr->powers[pw_allmap] || (lines[i].flags & ML_REVEALED)) |
| 1784 |
{ |
| 1785 |
if (!(lines[i].flags & ML_DONTDRAW)) |
| 1786 |
{ |
| 1787 |
if |
| 1788 |
( |
| 1789 |
mapcolor_p->flat || |
| 1790 |
!lines[i].backsector || |
| 1791 |
lines[i].backsector->floorheight != lines[i].frontsector->floorheight || |
| 1792 |
lines[i].backsector->ceilingheight != lines[i].frontsector->ceilingheight |
| 1793 |
) |
| 1794 |
return ams_unseen; |
| 1795 |
} |
| 1796 |
} |
| 1797 |
|
| 1798 |
return ams_invisible; |
| 1799 |
} |
| 1800 |
|
| 1801 |
static void AM_drawWalls(void) |
| 1802 |
{ |
| 1803 |
int i; |
| 1804 |
automap_style_t automap_style; |
| 1805 |
static mline_t l; |
| 1806 |
int hide_locks; |
| 1807 |
|
| 1808 |
hide_locks = map_blinking_locks && (gametic & 16); |
| 1809 |
|
| 1810 |
// draw the unclipped visible portions of all lines |
| 1811 |
for (i=0;i<numlines;i++) |
| 1812 |
{ |
| 1813 |
if (lines[i].bbox[BOXLEFT] >> FRACTOMAPBITS > am_frame.bbox[BOXRIGHT] || |
| 1814 |
lines[i].bbox[BOXRIGHT] >> FRACTOMAPBITS < am_frame.bbox[BOXLEFT] || |
| 1815 |
lines[i].bbox[BOXBOTTOM] >> FRACTOMAPBITS > am_frame.bbox[BOXTOP] || |
| 1816 |
lines[i].bbox[BOXTOP] >> FRACTOMAPBITS < am_frame.bbox[BOXBOTTOM]) |
| 1817 |
{ |
| 1818 |
continue; |
| 1819 |
} |
| 1820 |
|
| 1821 |
l.a.x = lines[i].v1->x >> FRACTOMAPBITS; |
| 1822 |
l.a.y = lines[i].v1->y >> FRACTOMAPBITS; |
| 1823 |
l.b.x = lines[i].v2->x >> FRACTOMAPBITS; |
| 1824 |
l.b.y = lines[i].v2->y >> FRACTOMAPBITS; |
| 1825 |
|
| 1826 |
if (automap_rotate) |
| 1827 |
{ |
| 1828 |
AM_rotatePoint(&l.a); |
| 1829 |
AM_rotatePoint(&l.b); |
| 1830 |
} |
| 1831 |
else |
| 1832 |
{ |
| 1833 |
AM_SetMPointFloatValue(&l.a); |
| 1834 |
AM_SetMPointFloatValue(&l.b); |
| 1835 |
} |
| 1836 |
|
| 1837 |
automap_style = AM_wallStyle(i); |
| 1838 |
|
| 1839 |
switch (automap_style) |
| 1840 |
{ |
| 1841 |
case ams_invisible: |
| 1842 |
continue; |
| 1843 |
|
| 1844 |
case ams_locked: |
| 1845 |
if (hide_locks) |
| 1846 |
{ |
| 1847 |
AM_drawMline(&l, mapcolor_p->grid); |
| 1848 |
continue; |
| 1849 |
} |
| 1850 |
|
| 1851 |
switch (dsda_DoorType(i)) |
| 1852 |
{ |
| 1853 |
case 0: // red |
| 1854 |
AM_drawMline(&l, mapcolor_p->rdor? mapcolor_p->rdor : mapcolor_p->cchg); |
| 1855 |
continue; |
| 1856 |
case 1: // blue |
| 1857 |
AM_drawMline(&l, mapcolor_p->bdor? mapcolor_p->bdor : mapcolor_p->cchg); |
| 1858 |
continue; |
| 1859 |
case 2: // yellow |
| 1860 |
AM_drawMline(&l, mapcolor_p->ydor? mapcolor_p->ydor : mapcolor_p->cchg); |
| 1861 |
continue; |
| 1862 |
default: |
| 1863 |
AM_drawMline(&l, mapcolor_p->clsd? mapcolor_p->clsd : mapcolor_p->cchg); |
| 1864 |
continue; |
| 1865 |
} |
| 1866 |
|
| 1867 |
case ams_exit: |
| 1868 |
AM_drawMline(&l, mapcolor_p->exit); |
| 1869 |
continue; |
| 1870 |
|
| 1871 |
case ams_exit_secret: |
| 1872 |
AM_drawMline(&l, mapcolor_p->exitsecr); |
| 1873 |
continue; |
| 1874 |
|
| 1875 |
case ams_one_sided: |
| 1876 |
AM_drawMline(&l, mapcolor_p->wall); |
| 1877 |
continue; |
| 1878 |
|
| 1879 |
case ams_secret: |
| 1880 |
case ams_unseen_secret: |
| 1881 |
AM_drawMline(&l, mapcolor_p->secr); |
| 1882 |
continue; |
| 1883 |
|
| 1884 |
case ams_revealed_secret: |
| 1885 |
AM_drawMline(&l, mapcolor_p->revsecr); |
| 1886 |
continue; |
| 1887 |
|
| 1888 |
case ams_teleport: |
| 1889 |
AM_drawMline(&l, mapcolor_p->tele); |
| 1890 |
continue; |
| 1891 |
|
| 1892 |
case ams_closed_door: |
| 1893 |
AM_drawMline(&l, mapcolor_p->clsd); |
| 1894 |
continue; |
| 1895 |
|
| 1896 |
case ams_floor_diff: |
| 1897 |
AM_drawMline(&l, mapcolor_p->fchg); |
| 1898 |
continue; |
| 1899 |
|
| 1900 |
case ams_ceiling_diff: |
| 1901 |
AM_drawMline(&l, mapcolor_p->cchg); |
| 1902 |
continue; |
| 1903 |
|
| 1904 |
case ams_two_sided: |
| 1905 |
AM_drawMline(&l, mapcolor_p->flat); |
| 1906 |
continue; |
| 1907 |
|
| 1908 |
case ams_unseen: |
| 1909 |
AM_drawMline(&l, mapcolor_p->unsn); |
| 1910 |
continue; |
| 1911 |
|
| 1912 |
default: |
| 1913 |
continue; |
| 1914 |
} |
| 1915 |
} |
| 1916 |
} |
| 1917 |
|
| 1918 |
static void AM_DrawConnections(void) |
| 1919 |
{ |
| 1920 |
int i; |
| 1921 |
mline_t l; |
| 1922 |
|
| 1923 |
if (!dsda_RevealAutomap()) |
| 1924 |
return; |
| 1925 |
|
| 1926 |
for (i = 0; i < highlight.connection_count; ++i) |
| 1927 |
{ |
| 1928 |
l = highlight.connections[i]; |
| 1929 |
|
| 1930 |
if (automap_rotate) |
| 1931 |
{ |
| 1932 |
AM_rotatePoint(&l.a); |
| 1933 |
AM_rotatePoint(&l.b); |
| 1934 |
} |
| 1935 |
else |
| 1936 |
{ |
| 1937 |
AM_SetMPointFloatValue(&l.a); |
| 1938 |
AM_SetMPointFloatValue(&l.b); |
| 1939 |
} |
| 1940 |
|
| 1941 |
AM_drawMline(&l, mapcolor_p->tagfinder); |
| 1942 |
} |
| 1943 |
} |
| 1944 |
|
| 1945 |
// |
| 1946 |
// AM_drawLineCharacter() |
| 1947 |
// |
| 1948 |
// Draws a vector graphic according to numerous parameters |
| 1949 |
// |
| 1950 |
// Passed the structure defining the vector graphic shape, the number |
| 1951 |
// of vectors in it, the scale to draw it at, the angle to draw it at, |
| 1952 |
// the color to draw it with, and the map coordinates to draw it at. |
| 1953 |
// Returns nothing |
| 1954 |
// |
| 1955 |
static void AM_drawLineCharacter |
| 1956 |
( mline_t* lineguy, |
| 1957 |
int lineguylines, |
| 1958 |
fixed_t scale, |
| 1959 |
angle_t angle, |
| 1960 |
int color, |
| 1961 |
fixed_t x, |
| 1962 |
fixed_t y ) |
| 1963 |
{ |
| 1964 |
int i; |
| 1965 |
mline_t l; |
| 1966 |
|
| 1967 |
if (automap_rotate) angle -= viewangle - ANG90; // cph |
| 1968 |
|
| 1969 |
for (i=0;i<lineguylines;i++) |
| 1970 |
{ |
| 1971 |
l.a.x = lineguy[i].a.x; |
| 1972 |
l.a.y = lineguy[i].a.y; |
| 1973 |
|
| 1974 |
if (scale) |
| 1975 |
{ |
| 1976 |
l.a.x = FixedMul(scale, l.a.x); |
| 1977 |
l.a.y = FixedMul(scale, l.a.y); |
| 1978 |
} |
| 1979 |
|
| 1980 |
if (angle) |
| 1981 |
AM_rotate(&l.a.x, &l.a.y, angle); |
| 1982 |
|
| 1983 |
l.a.x += x; |
| 1984 |
l.a.y += y; |
| 1985 |
|
| 1986 |
l.b.x = lineguy[i].b.x; |
| 1987 |
l.b.y = lineguy[i].b.y; |
| 1988 |
|
| 1989 |
if (scale) |
| 1990 |
{ |
| 1991 |
l.b.x = FixedMul(scale, l.b.x); |
| 1992 |
l.b.y = FixedMul(scale, l.b.y); |
| 1993 |
} |
| 1994 |
|
| 1995 |
if (angle) |
| 1996 |
AM_rotate(&l.b.x, &l.b.y, angle); |
| 1997 |
|
| 1998 |
l.b.x += x; |
| 1999 |
l.b.y += y; |
| 2000 |
|
| 2001 |
l.a.fx = (float)l.a.x; |
| 2002 |
l.a.fy = (float)l.a.y; |
| 2003 |
l.b.fx = (float)l.b.x; |
| 2004 |
l.b.fy = (float)l.b.y; |
| 2005 |
|
| 2006 |
AM_drawMline(&l, color); |
| 2007 |
} |
| 2008 |
} |
| 2009 |
|
| 2010 |
INLINE static void AM_GetMobjPosition(mobj_t *mo, mpoint_t *p, angle_t *angle) |
| 2011 |
{ |
| 2012 |
if (R_ViewInterpolation()) |
| 2013 |
{ |
| 2014 |
p->x = mo->PrevX + FixedMul(tic_vars.frac, mo->x - mo->PrevX); |
| 2015 |
p->y = mo->PrevY + FixedMul(tic_vars.frac, mo->y - mo->PrevY); |
| 2016 |
if (mo->player) |
| 2017 |
*angle = mo->player->prev_viewangle + FixedMul(tic_vars.frac, R_SmoothPlaying_Get(mo->player) - mo->player->prev_viewangle); |
| 2018 |
else |
| 2019 |
*angle = mo->angle; |
| 2020 |
} |
| 2021 |
else |
| 2022 |
{ |
| 2023 |
p->x = mo->x; |
| 2024 |
p->y = mo->y; |
| 2025 |
*angle = mo->angle; |
| 2026 |
} |
| 2027 |
|
| 2028 |
p->x = p->x >> FRACTOMAPBITS; |
| 2029 |
p->y = p->y >> FRACTOMAPBITS; |
| 2030 |
} |
| 2031 |
|
| 2032 |
// |
| 2033 |
// AM_drawPlayers() |
| 2034 |
// |
| 2035 |
// Draws the player arrow in single player, |
| 2036 |
// or all the player arrows in a netgame. |
| 2037 |
// |
| 2038 |
// Passed nothing, returns nothing |
| 2039 |
// |
| 2040 |
static void AM_drawPlayers(void) |
| 2041 |
{ |
| 2042 |
int i; |
| 2043 |
angle_t angle; |
| 2044 |
mpoint_t pt; |
| 2045 |
fixed_t scale; |
| 2046 |
|
| 2047 |
#if defined(HAVE_LIBSDL2_IMAGE) |
| 2048 |
if (V_IsOpenGLMode()) |
| 2049 |
{ |
| 2050 |
if (map_things_appearance == map_things_appearance_icon) |
| 2051 |
return; |
| 2052 |
} |
| 2053 |
#endif |
| 2054 |
|
| 2055 |
if (map_things_appearance == map_things_appearance_scaled) |
| 2056 |
scale = (BETWEEN(4<<FRACBITS, 256<<FRACBITS, plr->mo->radius)>>FRACTOMAPBITS); |
| 2057 |
else |
| 2058 |
scale = 16<<MAPBITS; |
| 2059 |
|
| 2060 |
if (!netgame) |
| 2061 |
{ |
| 2062 |
pt.x = viewx >> FRACTOMAPBITS; |
| 2063 |
pt.y = viewy >> FRACTOMAPBITS; |
| 2064 |
if (automap_rotate) |
| 2065 |
AM_rotatePoint(&pt); |
| 2066 |
else |
| 2067 |
AM_SetMPointFloatValue(&pt); |
| 2068 |
|
| 2069 |
if (dsda_RevealAutomap()) |
| 2070 |
AM_drawLineCharacter(cheat_player_arrow, NUMCHEATPLYRLINES, scale, viewangle, mapcolor_p->sngl, pt.x, pt.y); |
| 2071 |
else |
| 2072 |
AM_drawLineCharacter(player_arrow, numplyrlines, scale, viewangle, mapcolor_p->sngl, pt.x, pt.y); |
| 2073 |
return; |
| 2074 |
} |
| 2075 |
|
| 2076 |
for (i = 0; i < g_maxplayers; i++) { |
| 2077 |
player_t* p = &players[i]; |
| 2078 |
|
| 2079 |
if ( (deathmatch && !demoplayback) && p != plr) |
| 2080 |
continue; |
| 2081 |
|
| 2082 |
if (playeringame[i]) |
| 2083 |
{ |
| 2084 |
AM_GetMobjPosition(p->mo, &pt, &angle); |
| 2085 |
|
| 2086 |
if (automap_rotate) |
| 2087 |
AM_rotatePoint(&pt); |
| 2088 |
else |
| 2089 |
AM_SetMPointFloatValue(&pt); |
| 2090 |
|
| 2091 |
AM_drawLineCharacter (player_arrow, numplyrlines, scale, angle, |
| 2092 |
p->powers[pw_invisibility] ? 246 /* *close* to black */ |
| 2093 |
: mapcolor_p->plyr[i], //jff 1/6/98 use default color |
| 2094 |
pt.x, pt.y); |
| 2095 |
} |
| 2096 |
} |
| 2097 |
} |
| 2098 |
|
| 2099 |
static void AM_ProcessNiceThing(mobj_t* mobj, angle_t angle, fixed_t x, fixed_t y) |
| 2100 |
{ |
| 2101 |
const float shadow_scale_factor = 1.3f; |
| 2102 |
angle_t ang; |
| 2103 |
int i, type, radius, rotate, need_shadow; |
| 2104 |
float fx, fy, fradius, rot, shadow_radius; |
| 2105 |
unsigned char r, g, b, a; |
| 2106 |
|
| 2107 |
typedef struct map_nice_icon_param_s |
| 2108 |
{ |
| 2109 |
spritenum_t sprite; |
| 2110 |
int icon; |
| 2111 |
int radius; |
| 2112 |
int rotate; |
| 2113 |
unsigned char r, g, b; |
| 2114 |
} map_nice_icon_param_t; |
| 2115 |
|
| 2116 |
static const map_nice_icon_param_t icons[] = |
| 2117 |
{ |
| 2118 |
{SPR_STIM, am_icon_health, 12, 0, 100, 100, 200}, |
| 2119 |
{SPR_MEDI, am_icon_health, 16, 0, 100, 100, 200}, |
| 2120 |
{SPR_BON1, am_icon_health, 10, 0, 0, 0, 200}, |
| 2121 |
|
| 2122 |
{SPR_BON2, am_icon_armor, 10, 0, 0, 200, 0}, |
| 2123 |
{SPR_ARM1, am_icon_armor, 16, 0, 100, 200, 100}, |
| 2124 |
{SPR_ARM2, am_icon_armor, 16, 0, 100, 100, 200}, |
| 2125 |
|
| 2126 |
{SPR_CLIP, am_icon_ammo, 10, 0, 180, 150, 50}, |
| 2127 |
{SPR_AMMO, am_icon_ammo, 16, 0, 180, 150, 50}, |
| 2128 |
{SPR_ROCK, am_icon_ammo, 10, 0, 180, 150, 50}, |
| 2129 |
{SPR_BROK, am_icon_ammo, 16, 0, 180, 150, 50}, |
| 2130 |
|
| 2131 |
{SPR_CELL, am_icon_ammo, 10, 0, 180, 150, 50}, |
| 2132 |
{SPR_CELP, am_icon_ammo, 16, 0, 180, 150, 50}, |
| 2133 |
{SPR_SHEL, am_icon_ammo, 10, 0, 180, 150, 50}, |
| 2134 |
{SPR_SBOX, am_icon_ammo, 16, 0, 180, 150, 50}, |
| 2135 |
{SPR_BPAK, am_icon_ammo, 16, 0, 180, 150, 50}, |
| 2136 |
|
| 2137 |
{SPR_BKEY, am_icon_key, 10, 0, 0, 0, 255}, |
| 2138 |
{SPR_BSKU, am_icon_key, 10, 0, 0, 0, 255}, |
| 2139 |
{SPR_YKEY, am_icon_key, 10, 0, 255, 255, 0}, |
| 2140 |
{SPR_YSKU, am_icon_key, 10, 0, 255, 255, 0}, |
| 2141 |
{SPR_RKEY, am_icon_key, 10, 0, 255, 0, 0}, |
| 2142 |
{SPR_RSKU, am_icon_key, 10, 0, 255, 0, 0}, |
| 2143 |
|
| 2144 |
{SPR_PINV, am_icon_power, 16, 0, 220, 100, 220}, |
| 2145 |
{SPR_PSTR, am_icon_power, 16, 0, 220, 100, 220}, |
| 2146 |
{SPR_PINS, am_icon_power, 16, 0, 220, 100, 220}, |
| 2147 |
{SPR_SUIT, am_icon_power, 16, 0, 220, 100, 220}, |
| 2148 |
{SPR_PMAP, am_icon_power, 16, 0, 220, 100, 220}, |
| 2149 |
{SPR_PVIS, am_icon_power, 16, 0, 220, 100, 220}, |
| 2150 |
{SPR_SOUL, am_icon_power, 16, 0, 220, 100, 220}, |
| 2151 |
{SPR_MEGA, am_icon_power, 16, 0, 220, 100, 220}, |
| 2152 |
|
| 2153 |
{SPR_BFUG, am_icon_weap, 20, 0, 220, 180, 100}, |
| 2154 |
{SPR_MGUN, am_icon_weap, 20, 0, 220, 180, 100}, |
| 2155 |
{SPR_CSAW, am_icon_weap, 20, 0, 220, 180, 100}, |
| 2156 |
{SPR_LAUN, am_icon_weap, 20, 0, 220, 180, 100}, |
| 2157 |
{SPR_PLAS, am_icon_weap, 20, 0, 220, 180, 100}, |
| 2158 |
{SPR_SHOT, am_icon_weap, 20, 0, 220, 180, 100}, |
| 2159 |
{SPR_SGN2, am_icon_weap, 20, 0, 220, 180, 100}, |
| 2160 |
|
| 2161 |
{SPR_BLUD, am_icon_bullet, 8, 0, 255, 0, 0}, |
| 2162 |
{SPR_PUFF, am_icon_bullet, 8, 0, 255, 255, 115}, |
| 2163 |
{SPR_MISL, am_icon_bullet, 8, 0, 91, 71, 43}, |
| 2164 |
{SPR_PLSS, am_icon_bullet, 8, 0, 115, 115, 255}, |
| 2165 |
{SPR_PLSE, am_icon_bullet, 8, 0, 115, 115, 255}, |
| 2166 |
{SPR_BFS1, am_icon_bullet, 12, 0, 119, 255, 111}, |
| 2167 |
{SPR_BFE1, am_icon_bullet, 12, 0, 119, 255, 111}, |
| 2168 |
|
| 2169 |
{DOOM_NUMSPRITES} |
| 2170 |
}; |
| 2171 |
|
| 2172 |
need_shadow = true; |
| 2173 |
|
| 2174 |
type = am_icon_normal; |
| 2175 |
r = 220; |
| 2176 |
g = 180; |
| 2177 |
b = 100; |
| 2178 |
a = 255; |
| 2179 |
radius = mobj->radius; |
| 2180 |
rotate = true; |
| 2181 |
|
| 2182 |
if (mobj->player) |
| 2183 |
{ |
| 2184 |
player_t *p = mobj->player; |
| 2185 |
int color = mapcolor_p->plyr[p - players]; |
| 2186 |
const unsigned char *playpal = V_GetPlaypal(); |
| 2187 |
|
| 2188 |
if ((deathmatch && !demoplayback) && p != plr) |
| 2189 |
return; |
| 2190 |
|
| 2191 |
type = am_icon_player; |
| 2192 |
|
| 2193 |
r = playpal[3 * color + 0]; |
| 2194 |
g = playpal[3 * color + 1]; |
| 2195 |
b = playpal[3 * color + 2]; |
| 2196 |
a = p->powers[pw_invisibility] ? 128 : 255; |
| 2197 |
|
| 2198 |
radius = mobj->radius; |
| 2199 |
rotate = true; |
| 2200 |
} |
| 2201 |
else if (mobj->flags & MF_COUNTKILL) |
| 2202 |
{ |
| 2203 |
if (mobj->flags & MF_CORPSE) |
| 2204 |
{ |
| 2205 |
need_shadow = false; |
| 2206 |
type = am_icon_corpse; |
| 2207 |
r = 120; |
| 2208 |
a = 128; |
| 2209 |
} |
| 2210 |
else |
| 2211 |
{ |
| 2212 |
type = am_icon_monster; |
| 2213 |
r = 200; |
| 2214 |
} |
| 2215 |
g = 0; |
| 2216 |
b = 0; |
| 2217 |
radius = BETWEEN(4<<FRACBITS, 256<<FRACBITS, mobj->radius); |
| 2218 |
rotate = true; |
| 2219 |
} |
| 2220 |
else |
| 2221 |
{ |
| 2222 |
i = 0; |
| 2223 |
while (icons[i].sprite < DOOM_NUMSPRITES) |
| 2224 |
{ |
| 2225 |
if (mobj->sprite == icons[i].sprite) |
| 2226 |
{ |
| 2227 |
type = icons[i].icon; |
| 2228 |
r = icons[i].r; |
| 2229 |
g = icons[i].g; |
| 2230 |
b = icons[i].b; |
| 2231 |
radius = icons[i].radius << 16; |
| 2232 |
rotate = icons[i].rotate; |
| 2233 |
|
| 2234 |
break; |
| 2235 |
} |
| 2236 |
i++; |
| 2237 |
} |
| 2238 |
} |
| 2239 |
|
| 2240 |
fradius = MTOF_F(radius >> FRACTOMAPBITS); |
| 2241 |
if (fradius < 1.0f) |
| 2242 |
return; |
| 2243 |
if (fradius < 4.0f) |
| 2244 |
need_shadow = false; |
| 2245 |
|
| 2246 |
fx = CXMTOF_F(x); |
| 2247 |
fy = CYMTOF_F(y); |
| 2248 |
|
| 2249 |
shadow_radius = fradius * shadow_scale_factor; |
| 2250 |
if (fx + shadow_radius < 0 || |
| 2251 |
fx - shadow_radius > (float)SCREENWIDTH || |
| 2252 |
fy + shadow_radius < 0 || |
| 2253 |
fy - shadow_radius > (float)SCREENHEIGHT) |
| 2254 |
{ |
| 2255 |
return; |
| 2256 |
} |
| 2257 |
|
| 2258 |
ang = (rotate ? angle : 0) + (automap_rotate ? ANG90 - viewangle : 0); |
| 2259 |
rot = -(float)ang / (float)(1u << 31) * (float)M_PI; |
| 2260 |
|
| 2261 |
gld_AddNiceThing(type, fx, fy, fradius, rot, r, g, b, a); |
| 2262 |
if (need_shadow) |
| 2263 |
{ |
| 2264 |
gld_AddNiceThing(am_icon_shadow, fx, fy, shadow_radius, rot, 0, 0, 0, 128); |
| 2265 |
} |
| 2266 |
} |
| 2267 |
|
| 2268 |
static void AM_DrawNiceThings(void) |
| 2269 |
{ |
| 2270 |
int i; |
| 2271 |
mobj_t* t; |
| 2272 |
mpoint_t p; |
| 2273 |
angle_t angle; |
| 2274 |
|
| 2275 |
gld_ClearNiceThings(); |
| 2276 |
|
| 2277 |
// draw players |
| 2278 |
for (i = 0; i < g_maxplayers; i++) |
| 2279 |
{ |
| 2280 |
if ((deathmatch && !demoplayback) && &players[i] != plr) |
| 2281 |
continue; |
| 2282 |
|
| 2283 |
if (playeringame[i]) |
| 2284 |
{ |
| 2285 |
t = players[i].mo; |
| 2286 |
AM_GetMobjPosition(t, &p, &angle); |
| 2287 |
if (automap_rotate) |
| 2288 |
AM_rotatePoint(&p); |
| 2289 |
else |
| 2290 |
AM_SetMPointFloatValue(&p); |
| 2291 |
AM_ProcessNiceThing(t, angle, p.x, p.y); |
| 2292 |
} |
| 2293 |
} |
| 2294 |
|
| 2295 |
// walls |
| 2296 |
if (dsda_RevealAutomap() == 2) |
| 2297 |
{ |
| 2298 |
// for all sectors |
| 2299 |
for (i = 0; i < numsectors; i++) |
| 2300 |
{ |
| 2301 |
if (!(players[displayplayer].cheats & CF_NOCLIP) && |
| 2302 |
(sectors[i].bbox[BOXLEFT] > am_frame.bbox[BOXRIGHT] || |
| 2303 |
sectors[i].bbox[BOXRIGHT] < am_frame.bbox[BOXLEFT] || |
| 2304 |
sectors[i].bbox[BOXBOTTOM] > am_frame.bbox[BOXTOP] || |
| 2305 |
sectors[i].bbox[BOXTOP] < am_frame.bbox[BOXBOTTOM])) |
| 2306 |
{ |
| 2307 |
continue; |
| 2308 |
} |
| 2309 |
|
| 2310 |
t = sectors[i].thinglist; |
| 2311 |
while (t) // for all things in that sector |
| 2312 |
{ |
| 2313 |
if (!t->player) |
| 2314 |
{ |
| 2315 |
AM_GetMobjPosition(t, &p, &angle); |
| 2316 |
if (automap_rotate) |
| 2317 |
AM_rotatePoint(&p); |
| 2318 |
AM_ProcessNiceThing(t, angle, p.x, p.y); |
| 2319 |
} |
| 2320 |
t = t->snext; |
| 2321 |
} |
| 2322 |
} |
| 2323 |
} |
| 2324 |
|
| 2325 |
// marked locations on the automap |
| 2326 |
{ |
| 2327 |
float radius; |
| 2328 |
int anim_flash_level = (gametic % 32); |
| 2329 |
|
| 2330 |
// Flashing animation for hilight |
| 2331 |
// Pulsates between 0.5-1.0f (multiplied with hilight alpha) |
| 2332 |
if (anim_flash_level >= 16) |
| 2333 |
{ |
| 2334 |
anim_flash_level = 32 - anim_flash_level; |
| 2335 |
} |
| 2336 |
anim_flash_level = 127 + anim_flash_level * 8; |
| 2337 |
|
| 2338 |
// do not want to have too small marks |
| 2339 |
radius = MTOF_F(16 << MAPBITS); |
| 2340 |
radius = BETWEEN(8.0f, 128.0f, radius); |
| 2341 |
|
| 2342 |
for (i = 0; i < markpointnum; i++) // killough 2/22/98: remove automap mark limit |
| 2343 |
{ |
| 2344 |
if (markpoints[i].x != -1) |
| 2345 |
{ |
| 2346 |
mpoint_t p = { 0 }; |
| 2347 |
|
| 2348 |
p.x = markpoints[i].x; |
| 2349 |
p.y = markpoints[i].y; |
| 2350 |
|
| 2351 |
if (automap_rotate) |
| 2352 |
AM_rotatePoint(&p); |
| 2353 |
else |
| 2354 |
AM_SetMPointFloatValue(&p); |
| 2355 |
|
| 2356 |
p.fx = CXMTOF_F(p.fx); |
| 2357 |
p.fy = CYMTOF_F(p.fy); |
| 2358 |
|
| 2359 |
gld_AddNiceThing(am_icon_mark, p.fx, p.fy, radius, 0, 255, 255, 0, (unsigned char)anim_flash_level); |
| 2360 |
} |
| 2361 |
} |
| 2362 |
} |
| 2363 |
} |
| 2364 |
|
| 2365 |
// |
| 2366 |
// AM_drawThings() |
| 2367 |
// |
| 2368 |
// Draws the things on the automap in double IDDT cheat mode |
| 2369 |
// |
| 2370 |
// Passed colors and colorrange, no longer used |
| 2371 |
// Returns nothing |
| 2372 |
// |
| 2373 |
static void AM_drawThings(void) |
| 2374 |
{ |
| 2375 |
int i; |
| 2376 |
mobj_t* t; |
| 2377 |
mline_t* lineguy = thintriangle_guy; |
| 2378 |
int lineguylines = NUMTHINTRIANGLEGUYLINES; |
| 2379 |
|
| 2380 |
#if defined(HAVE_LIBSDL2_IMAGE) |
| 2381 |
if (V_IsOpenGLMode()) |
| 2382 |
{ |
| 2383 |
if (map_things_appearance == map_things_appearance_icon) |
| 2384 |
{ |
| 2385 |
AM_DrawNiceThings(); |
| 2386 |
return; |
| 2387 |
} |
| 2388 |
} |
| 2389 |
#endif |
| 2390 |
|
| 2391 |
if (dsda_RevealAutomap() != 2) |
| 2392 |
return; |
| 2393 |
|
| 2394 |
// for all sectors |
| 2395 |
for (i=0;i<numsectors;i++) |
| 2396 |
{ |
| 2397 |
// e6y |
| 2398 |
// Two-pass method for better usability of automap: |
| 2399 |
// The first one will draw all things except enemies |
| 2400 |
// The second one is for enemies only |
| 2401 |
// Stop after first pass if the current sector has no enemies |
| 2402 |
int pass; |
| 2403 |
int enemies = 0; |
| 2404 |
|
| 2405 |
if (!(players[displayplayer].cheats & CF_NOCLIP) && |
| 2406 |
(sectors[i].bbox[BOXLEFT] > am_frame.bbox[BOXRIGHT] || |
| 2407 |
sectors[i].bbox[BOXRIGHT] < am_frame.bbox[BOXLEFT] || |
| 2408 |
sectors[i].bbox[BOXBOTTOM] > am_frame.bbox[BOXTOP] || |
| 2409 |
sectors[i].bbox[BOXTOP] < am_frame.bbox[BOXBOTTOM])) |
| 2410 |
{ |
| 2411 |
continue; |
| 2412 |
} |
| 2413 |
|
| 2414 |
for (pass = 0; pass < 2; pass += (enemies ? 1 : 2)) |
| 2415 |
{ |
| 2416 |
t = sectors[i].thinglist; |
| 2417 |
while (t) // for all things in that sector |
| 2418 |
{ |
| 2419 |
int color; |
| 2420 |
mpoint_t p; |
| 2421 |
angle_t angle; |
| 2422 |
fixed_t scale; |
| 2423 |
|
| 2424 |
//e6y: stop if all enemies from current sector already has been drawn |
| 2425 |
if (pass == 1 && enemies == 0) |
| 2426 |
break; |
| 2427 |
if (pass == ((t->flags & (MF_COUNTKILL | MF_CORPSE)) == MF_COUNTKILL ? |
| 2428 |
(pass == 0 ? enemies++: enemies--), 0 : 1)) |
| 2429 |
{ |
| 2430 |
t = t->snext; |
| 2431 |
continue; |
| 2432 |
} |
| 2433 |
|
| 2434 |
if (map_things_appearance == map_things_appearance_scaled |
| 2435 |
|| map_things_appearance == map_things_appearance_box) |
| 2436 |
scale = (BETWEEN(4<<FRACBITS, 256<<FRACBITS, t->radius)>>FRACTOMAPBITS);// * 16 / 20; |
| 2437 |
else |
| 2438 |
scale = 16<<MAPBITS; |
| 2439 |
|
| 2440 |
AM_GetMobjPosition(t, &p, &angle); |
| 2441 |
|
| 2442 |
if (automap_rotate) |
| 2443 |
AM_rotatePoint(&p); |
| 2444 |
else |
| 2445 |
AM_SetMPointFloatValue(&p); |
| 2446 |
|
| 2447 |
//jff 1/5/98 case over doomednum of thing being drawn |
| 2448 |
if (mapcolor_p->rkey || mapcolor_p->ykey || mapcolor_p->bkey) |
| 2449 |
{ |
| 2450 |
color = -1; |
| 2451 |
|
| 2452 |
if (heretic) |
| 2453 |
{ |
| 2454 |
switch(t->info->doomednum) |
| 2455 |
{ |
| 2456 |
//jff 1/5/98 treat keys special |
| 2457 |
case 73: //jff red key |
| 2458 |
color = mapcolor_p->rkey != -1? mapcolor_p->rkey : mapcolor_p->sprt; break; |
| 2459 |
case 80: //jff yellow key |
| 2460 |
color = mapcolor_p->ykey != -1? mapcolor_p->ykey : mapcolor_p->sprt; break; |
| 2461 |
case 79: //jff blue key |
| 2462 |
color = mapcolor_p->bkey != -1? mapcolor_p->bkey : mapcolor_p->sprt; break; |
| 2463 |
} |
| 2464 |
} |
| 2465 |
else |
| 2466 |
{ |
| 2467 |
switch(t->info->doomednum) |
| 2468 |
{ |
| 2469 |
//jff 1/5/98 treat keys special |
| 2470 |
case 38: case 13: //jff red key |
| 2471 |
color = mapcolor_p->rkey != -1? mapcolor_p->rkey : mapcolor_p->sprt; break; |
| 2472 |
case 39: case 6: //jff yellow key |
| 2473 |
color = mapcolor_p->ykey != -1? mapcolor_p->ykey : mapcolor_p->sprt; break; |
| 2474 |
case 40: case 5: //jff blue key |
| 2475 |
color = mapcolor_p->bkey != -1? mapcolor_p->bkey : mapcolor_p->sprt; break; |
| 2476 |
} |
| 2477 |
} |
| 2478 |
|
| 2479 |
if (color != -1) |
| 2480 |
{ |
| 2481 |
AM_drawLineCharacter(cross_mark, NUMCROSSMARKLINES, |
| 2482 |
scale, t->angle, color, p.x, p.y); |
| 2483 |
t = t->snext; |
| 2484 |
continue; |
| 2485 |
} |
| 2486 |
} |
| 2487 |
|
| 2488 |
if (map_things_appearance == map_things_appearance_box) |
| 2489 |
{ |
| 2490 |
lineguy = thingbox_guy; |
| 2491 |
lineguylines = NUMTHINGBOXGUYLINES; |
| 2492 |
angle = 0x40000000; |
| 2493 |
} |
| 2494 |
|
| 2495 |
color = mapcolor_p->sprt; |
| 2496 |
|
| 2497 |
if (t->flags & MF_FRIEND && !t->player) |
| 2498 |
color = mapcolor_p->frnd; |
| 2499 |
/* cph 2006/07/30 - Show count-as-kills in red. */ |
| 2500 |
else if ((t->flags & (MF_COUNTKILL | MF_CORPSE)) == MF_COUNTKILL) |
| 2501 |
color = mapcolor_p->enemy; |
| 2502 |
/* bbm 2/28/03 Show countable items in yellow. */ |
| 2503 |
else if (t->flags & MF_COUNTITEM) |
| 2504 |
color = mapcolor_p->item; |
| 2505 |
else if (t->flags & MF_SPECIAL) |
| 2506 |
color = mapcolor_p->pickup; |
| 2507 |
|
| 2508 |
//jff 1/5/98 end added code for keys |
| 2509 |
//jff previously entire code |
| 2510 |
AM_drawLineCharacter(lineguy, lineguylines, scale, angle, color, p.x, p.y); |
| 2511 |
t = t->snext; |
| 2512 |
} |
| 2513 |
} |
| 2514 |
} |
| 2515 |
} |
| 2516 |
|
| 2517 |
void AM_updatePlayerTrail(fixed_t x, fixed_t y) |
| 2518 |
{ |
| 2519 |
trailpoint_t pt; |
| 2520 |
|
| 2521 |
pt.x = x >> FRACTOMAPBITS; |
| 2522 |
pt.y = y >> FRACTOMAPBITS; |
| 2523 |
|
| 2524 |
if (trail_index == -1 || |
| 2525 |
player_trail[trail_index].x != pt.x || |
| 2526 |
player_trail[trail_index].y != pt.y) |
| 2527 |
{ |
| 2528 |
trail_index = (trail_index + 1) % trail_size_max; |
| 2529 |
player_trail[trail_index] = pt; |
| 2530 |
|
| 2531 |
if (trail_size < trail_index + 1) |
| 2532 |
trail_size = trail_index + 1; |
| 2533 |
} |
| 2534 |
} |
| 2535 |
|
| 2536 |
static void AM_drawPlayerTrail(void) |
| 2537 |
{ |
| 2538 |
int i; |
| 2539 |
|
| 2540 |
for (i = 0; i < trail_size; ++i) |
| 2541 |
{ |
| 2542 |
mpoint_t p; |
| 2543 |
|
| 2544 |
p.x = player_trail[i].x; |
| 2545 |
p.y = player_trail[i].y; |
| 2546 |
|
| 2547 |
if (automap_rotate) |
| 2548 |
AM_rotatePoint(&p); |
| 2549 |
else |
| 2550 |
AM_SetMPointFloatValue(&p); |
| 2551 |
|
| 2552 |
p.x = CXMTOF(p.x); |
| 2553 |
p.y = CYMTOF(p.y); |
| 2554 |
if (am_frame.precise) |
| 2555 |
{ |
| 2556 |
p.fx = CXMTOF_F(p.fx); |
| 2557 |
p.fy = CYMTOF_F(p.fy); |
| 2558 |
} |
| 2559 |
|
| 2560 |
if (p.x >= f_x && p.y >= f_y && p.x < f_x + f_w && p.y < f_y + f_h) |
| 2561 |
{ |
| 2562 |
mpoint_t a, b, c, d; |
| 2563 |
mpoint_t e, f, g, h; |
| 2564 |
mline_t line; |
| 2565 |
|
| 2566 |
a.x = b.x = player_trail[i].x - FRACUNIT; |
| 2567 |
c.x = d.x = player_trail[i].x + FRACUNIT; |
| 2568 |
a.y = d.y = player_trail[i].y - FRACUNIT; |
| 2569 |
b.y = c.y = player_trail[i].y + FRACUNIT; |
| 2570 |
|
| 2571 |
e.x = player_trail[i].x - FRACUNIT / 8; |
| 2572 |
e.y = player_trail[i].y - FRACUNIT / 8; |
| 2573 |
f.x = player_trail[i].x + FRACUNIT / 8; |
| 2574 |
f.y = player_trail[i].y + FRACUNIT / 8; |
| 2575 |
g.x = player_trail[i].x - FRACUNIT / 8; |
| 2576 |
g.y = player_trail[i].y + FRACUNIT / 8; |
| 2577 |
h.x = player_trail[i].x + FRACUNIT / 8; |
| 2578 |
h.y = player_trail[i].y - FRACUNIT / 8; |
| 2579 |
|
| 2580 |
if (automap_rotate) |
| 2581 |
{ |
| 2582 |
AM_rotatePoint(&a); |
| 2583 |
AM_rotatePoint(&b); |
| 2584 |
AM_rotatePoint(&c); |
| 2585 |
AM_rotatePoint(&d); |
| 2586 |
AM_rotatePoint(&e); |
| 2587 |
AM_rotatePoint(&f); |
| 2588 |
AM_rotatePoint(&g); |
| 2589 |
AM_rotatePoint(&h); |
| 2590 |
} |
| 2591 |
else |
| 2592 |
{ |
| 2593 |
AM_SetMPointFloatValue(&a); |
| 2594 |
AM_SetMPointFloatValue(&b); |
| 2595 |
AM_SetMPointFloatValue(&c); |
| 2596 |
AM_SetMPointFloatValue(&d); |
| 2597 |
AM_SetMPointFloatValue(&e); |
| 2598 |
AM_SetMPointFloatValue(&f); |
| 2599 |
AM_SetMPointFloatValue(&g); |
| 2600 |
AM_SetMPointFloatValue(&h); |
| 2601 |
} |
| 2602 |
|
| 2603 |
{ |
| 2604 |
int color; |
| 2605 |
|
| 2606 |
color = (i % 2) ? mapcolor_p->trail_1 : mapcolor_p->trail_2; |
| 2607 |
|
| 2608 |
// Cross marking center |
| 2609 |
line.a = e; line.b = f; |
| 2610 |
AM_drawMline(&line, color); |
| 2611 |
line.a = g; line.b = h; |
| 2612 |
AM_drawMline(&line, color); |
| 2613 |
|
| 2614 |
// Bounding box |
| 2615 |
line.a = a; line.b = b; |
| 2616 |
AM_drawMline(&line, color); |
| 2617 |
line.a = b; line.b = c; |
| 2618 |
AM_drawMline(&line, color); |
| 2619 |
line.a = c; line.b = d; |
| 2620 |
AM_drawMline(&line, color); |
| 2621 |
line.a = d; line.b = a; |
| 2622 |
AM_drawMline(&line, color); |
| 2623 |
} |
| 2624 |
} |
| 2625 |
} |
| 2626 |
} |
| 2627 |
|
| 2628 |
// |
| 2629 |
// AM_drawMarks() |
| 2630 |
// |
| 2631 |
// Draw the marked locations on the automap |
| 2632 |
// |
| 2633 |
// Passed nothing, returns nothing |
| 2634 |
// |
| 2635 |
// killough 2/22/98: |
| 2636 |
// Rewrote AM_drawMarks(). Removed limit on marks. |
| 2637 |
// |
| 2638 |
static void AM_drawMarks(void) |
| 2639 |
{ |
| 2640 |
int i, namelen; |
| 2641 |
char namebuf[16]; |
| 2642 |
|
| 2643 |
snprintf(namebuf, sizeof(namebuf), "%s", !raven ? "AMMNUM0" : "SMALLIN0"); |
| 2644 |
namelen = !raven ? 6 : 7; |
| 2645 |
|
| 2646 |
if (map_trail_mode && dsda_RevealAutomap()) |
| 2647 |
AM_drawPlayerTrail(); |
| 2648 |
|
| 2649 |
#if defined(HAVE_LIBSDL2_IMAGE) |
| 2650 |
if (V_IsOpenGLMode()) |
| 2651 |
{ |
| 2652 |
if (map_things_appearance == map_things_appearance_icon) |
| 2653 |
return; |
| 2654 |
} |
| 2655 |
#endif |
| 2656 |
|
| 2657 |
for (i = 0; i < markpointnum; i++) // killough 2/22/98: remove automap mark limit |
| 2658 |
{ |
| 2659 |
if (markpoints[i].x != -1) |
| 2660 |
{ |
| 2661 |
int k, w; |
| 2662 |
mpoint_t p; |
| 2663 |
|
| 2664 |
p.x = markpoints[i].x;// - m_x + prev_m_x; |
| 2665 |
p.y = markpoints[i].y;// - m_y + prev_m_y; |
| 2666 |
|
| 2667 |
if (automap_rotate) |
| 2668 |
AM_rotatePoint(&p); |
| 2669 |
else |
| 2670 |
AM_SetMPointFloatValue(&p); |
| 2671 |
|
| 2672 |
p.x = CXMTOF(p.x) - markpoints[i].w * SCREENWIDTH / 320 / 2; |
| 2673 |
p.y = CYMTOF(p.y) - markpoints[i].h * SCREENHEIGHT / 200 / 2; |
| 2674 |
if (am_frame.precise) |
| 2675 |
{ |
| 2676 |
p.fx = CXMTOF_F(p.fx) - (float)markpoints[i].w * SCREENWIDTH / 320.0f / 2.0f; |
| 2677 |
p.fy = CYMTOF_F(p.fy) - (float)markpoints[i].h * SCREENHEIGHT / 200.0f / 2.0f; |
| 2678 |
} |
| 2679 |
|
| 2680 |
if (V_IsOpenGLMode() ? |
| 2681 |
p.y < f_y + f_h && p.y + markpoints[i].h * SCREENHEIGHT / 200 >= f_y : |
| 2682 |
p.y < f_y + f_h && p.y >= f_y) |
| 2683 |
{ |
| 2684 |
w = 0; |
| 2685 |
for (k = 0; k < (int)strlen(markpoints[i].label); k++) |
| 2686 |
{ |
| 2687 |
namebuf[namelen] = markpoints[i].label[k]; |
| 2688 |
|
| 2689 |
if (p.x < f_x + f_w && |
| 2690 |
p.x + markpoints[i].widths[k] * SCREENWIDTH / 320 >= f_x) |
| 2691 |
{ |
| 2692 |
float fx, fy; |
| 2693 |
int x, y, flags; |
| 2694 |
|
| 2695 |
switch (render_stretch_hud) |
| 2696 |
{ |
| 2697 |
default: |
| 2698 |
case patch_stretch_not_adjusted: |
| 2699 |
fx = (float)p.fx / patches_scalex; |
| 2700 |
fy = (float)p.fy * 200.0f / SCREENHEIGHT; |
| 2701 |
|
| 2702 |
x = p.x / patches_scalex; |
| 2703 |
y = p.y * 200 / SCREENHEIGHT; |
| 2704 |
|
| 2705 |
flags = VPT_ALIGN_LEFT | VPT_STRETCH; |
| 2706 |
break; |
| 2707 |
case patch_stretch_doom_format: |
| 2708 |
fx = (float)p.fx * 320.0f / WIDE_SCREENWIDTH; |
| 2709 |
fy = (float)p.fy * 200.0f / WIDE_SCREENHEIGHT; |
| 2710 |
|
| 2711 |
x = p.x * 320 / WIDE_SCREENWIDTH; |
| 2712 |
y = p.y * 200 / WIDE_SCREENHEIGHT; |
| 2713 |
|
| 2714 |
flags = VPT_ALIGN_LEFT | VPT_STRETCH; |
| 2715 |
break; |
| 2716 |
case patch_stretch_fit_to_width: |
| 2717 |
fx = (float)p.fx * 320.0f / SCREENWIDTH; |
| 2718 |
fy = (float)p.fy * 200.0f / SCREENHEIGHT; |
| 2719 |
|
| 2720 |
x = p.x * 320 / SCREENWIDTH; |
| 2721 |
y = p.y * 200 / SCREENHEIGHT; |
| 2722 |
|
| 2723 |
flags = VPT_ALIGN_WIDE | VPT_STRETCH; |
| 2724 |
break; |
| 2725 |
} |
| 2726 |
|
| 2727 |
if (am_frame.precise) |
| 2728 |
{ |
| 2729 |
V_DrawNamePatchPrecise(fx, fy, FB, namebuf, CR_DEFAULT, flags); |
| 2730 |
} |
| 2731 |
else |
| 2732 |
{ |
| 2733 |
V_DrawNamePatch(x, y, FB, namebuf, CR_DEFAULT, flags); |
| 2734 |
} |
| 2735 |
} |
| 2736 |
|
| 2737 |
w += markpoints[i].widths[k] + 1; |
| 2738 |
p.x += w * SCREENWIDTH / 320; |
| 2739 |
if (am_frame.precise) |
| 2740 |
{ |
| 2741 |
p.fx += (float)w * SCREENWIDTH / 320.0f; |
| 2742 |
} |
| 2743 |
} |
| 2744 |
} |
| 2745 |
} |
| 2746 |
} |
| 2747 |
} |
| 2748 |
|
| 2749 |
// |
| 2750 |
// AM_drawCrosshair() |
| 2751 |
// |
| 2752 |
// Draw the single point crosshair representing map center |
| 2753 |
// |
| 2754 |
// Passed the color to draw the pixel with |
| 2755 |
// Returns nothing |
| 2756 |
// |
| 2757 |
// CPhipps - made static inline, and use the general pixel plotter function |
| 2758 |
|
| 2759 |
static void AM_drawCrosshair(int color) |
| 2760 |
{ |
| 2761 |
fline_t line; |
| 2762 |
|
| 2763 |
line.a.x = f_x+(f_w/2)-1; |
| 2764 |
line.a.y = f_y+(f_h/2); |
| 2765 |
line.b.x = f_x+(f_w/2)+1; |
| 2766 |
line.b.y = f_y+(f_h/2); |
| 2767 |
AM_SetFPointFloatValue(&line.a); |
| 2768 |
AM_SetFPointFloatValue(&line.b); |
| 2769 |
V_DrawLine(&line, color); |
| 2770 |
|
| 2771 |
line.a.x = f_x+(f_w/2); |
| 2772 |
line.a.y = f_y+(f_h/2)-1; |
| 2773 |
line.b.x = f_x+(f_w/2); |
| 2774 |
line.b.y = f_y+(f_h/2)+1; |
| 2775 |
AM_SetFPointFloatValue(&line.a); |
| 2776 |
AM_SetFPointFloatValue(&line.b); |
| 2777 |
V_DrawLine(&line, color); |
| 2778 |
} |
| 2779 |
|
| 2780 |
void M_ChangeMapTextured(void) |
| 2781 |
{ |
| 2782 |
map_textured = dsda_IntConfig(dsda_config_map_textured); |
| 2783 |
|
| 2784 |
if (in_game && gamestate == GS_LEVEL && V_IsOpenGLMode()) |
| 2785 |
{ |
| 2786 |
gld_ProcessTexturedMap(); |
| 2787 |
} |
| 2788 |
} |
| 2789 |
|
| 2790 |
void M_ChangeMapMultisamling(void) |
| 2791 |
{ |
| 2792 |
map_use_multisampling = dsda_IntConfig(dsda_config_map_use_multisamling); |
| 2793 |
|
| 2794 |
if (!raven && map_use_multisampling && V_IsSoftwareMode()) |
| 2795 |
{ |
| 2796 |
V_InitFlexTranTable(); |
| 2797 |
} |
| 2798 |
} |
| 2799 |
|
| 2800 |
//============================================================================= |
| 2801 |
// |
| 2802 |
// AM_drawSubsectors |
| 2803 |
// |
| 2804 |
//============================================================================= |
| 2805 |
|
| 2806 |
void AM_drawSubsectors(void) |
| 2807 |
{ |
| 2808 |
if (V_IsOpenGLMode()) |
| 2809 |
{ |
| 2810 |
gld_MapDrawSubsectors(plr, f_x, f_y, m_x, m_y, f_w, f_h, scale_mtof); |
| 2811 |
} |
| 2812 |
} |
| 2813 |
|
| 2814 |
static void AM_setFrameVariables(void) |
| 2815 |
{ |
| 2816 |
float angle; |
| 2817 |
|
| 2818 |
angle = (float)(ANG90 - viewangle) / (float)(1u << 31) * (float)M_PI; |
| 2819 |
am_frame.sin_f = (float)sin(angle); |
| 2820 |
am_frame.cos_f = (float)cos(angle); |
| 2821 |
am_frame.sin = finesine[(ANG90 - viewangle)>>ANGLETOFINESHIFT]; |
| 2822 |
am_frame.cos = finecosine[(ANG90 - viewangle)>>ANGLETOFINESHIFT]; |
| 2823 |
|
| 2824 |
am_frame.centerx = m_x + m_w / 2; |
| 2825 |
am_frame.centery = m_y + m_h / 2; |
| 2826 |
am_frame.centerx_f = (float)m_x + (float)m_w / 2.0f; |
| 2827 |
am_frame.centery_f = (float)m_y + (float)m_h / 2.0f; |
| 2828 |
|
| 2829 |
if (automap_rotate) |
| 2830 |
{ |
| 2831 |
float dx = (float)(m_x2 - am_frame.centerx); |
| 2832 |
float dy = (float)(m_y2 - am_frame.centery); |
| 2833 |
fixed_t r = M_DoubleToInt(sqrt(dx * dx + dy * dy)); |
| 2834 |
|
| 2835 |
am_frame.bbox[BOXLEFT] = am_frame.centerx - r; |
| 2836 |
am_frame.bbox[BOXRIGHT] = am_frame.centerx + r; |
| 2837 |
am_frame.bbox[BOXBOTTOM] = am_frame.centery - r; |
| 2838 |
am_frame.bbox[BOXTOP] = am_frame.centery + r; |
| 2839 |
} |
| 2840 |
else |
| 2841 |
{ |
| 2842 |
am_frame.bbox[BOXLEFT] = m_x; |
| 2843 |
am_frame.bbox[BOXRIGHT] = m_x2; |
| 2844 |
am_frame.bbox[BOXBOTTOM] = m_y; |
| 2845 |
am_frame.bbox[BOXTOP] = m_y2; |
| 2846 |
} |
| 2847 |
|
| 2848 |
am_frame.precise = (V_IsOpenGLMode()); |
| 2849 |
} |
| 2850 |
|
| 2851 |
// |
| 2852 |
// AM_Drawer() |
| 2853 |
// |
| 2854 |
// Draws the entire automap |
| 2855 |
// |
| 2856 |
// Passed nothing, returns nothing |
| 2857 |
// |
| 2858 |
|
| 2859 |
void AM_Drawer (dboolean minimap) |
| 2860 |
{ |
| 2861 |
if (!automap_active && !minimap) |
| 2862 |
return; |
| 2863 |
|
| 2864 |
if (automap_active && automap_overlay == 2 && minimap) |
| 2865 |
return; |
| 2866 |
|
| 2867 |
V_BeginAutomapDraw(); |
| 2868 |
|
| 2869 |
if (automap_follow) |
| 2870 |
AM_doFollowPlayer(); |
| 2871 |
|
| 2872 |
// Change the zoom if necessary |
| 2873 |
if (ftom_zoommul != FRACUNIT) |
| 2874 |
AM_changeWindowScale(); |
| 2875 |
|
| 2876 |
// Change x,y location |
| 2877 |
if (m_paninc.x || m_paninc.y) |
| 2878 |
AM_changeWindowLoc(); |
| 2879 |
|
| 2880 |
AM_setFrameVariables(); |
| 2881 |
|
| 2882 |
if (V_IsOpenGLMode()) |
| 2883 |
{ |
| 2884 |
// do not use multisampling in automap mode if map_use_multisampling 0 |
| 2885 |
gld_MultisamplingSet(); |
| 2886 |
} |
| 2887 |
|
| 2888 |
if (!automap_overlay) // cph - If not overlay mode, clear background for the automap |
| 2889 |
V_FillRect(FB, f_x, f_y, f_w, f_h, (byte)mapcolor_p->back); //jff 1/5/98 background default color |
| 2890 |
if (automap_overlay == 2 && !M_MenuIsShaded()) |
| 2891 |
V_DrawShaded(FB, f_x, f_y, f_w, f_h, FULLSHADE); |
| 2892 |
|
| 2893 |
if (map_textured) |
| 2894 |
{ |
| 2895 |
V_BeginUIDraw(); |
| 2896 |
AM_drawSubsectors(); |
| 2897 |
V_EndUIDraw(); |
| 2898 |
} |
| 2899 |
|
| 2900 |
if (automap_grid) |
| 2901 |
AM_drawGrid(mapcolor_p->grid); //jff 1/7/98 grid default color |
| 2902 |
AM_drawWalls(); |
| 2903 |
AM_drawPlayers(); |
| 2904 |
AM_drawThings(); //jff 1/5/98 default double IDDT sprite |
| 2905 |
AM_DrawConnections(); |
| 2906 |
AM_drawCrosshair(mapcolor_p->hair); //jff 1/7/98 default crosshair color |
| 2907 |
|
| 2908 |
if (V_IsOpenGLMode()) |
| 2909 |
{ |
| 2910 |
gld_DrawMapLines(); |
| 2911 |
M_ArrayClear(&map_lines); |
| 2912 |
|
| 2913 |
#if defined(HAVE_LIBSDL2_IMAGE) |
| 2914 |
if (map_things_appearance == map_things_appearance_icon) |
| 2915 |
{ |
| 2916 |
gld_DrawNiceThings(f_x, f_y, f_w, f_h); |
| 2917 |
} |
| 2918 |
#endif |
| 2919 |
} |
| 2920 |
|
| 2921 |
AM_drawMarks(); |
| 2922 |
|
| 2923 |
V_EndAutomapDraw(); |
| 2924 |
} |