| 1 |
/* |
| 2 |
* Portions of this file are copyright Rebirth contributors and licensed as |
| 3 |
* described in COPYING.txt. |
| 4 |
* Portions of this file are copyright Parallax Software and licensed |
| 5 |
* according to the Parallax license below. |
| 6 |
* See COPYING.txt for license details. |
| 7 |
|
| 8 |
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX |
| 9 |
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO |
| 10 |
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A |
| 11 |
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS |
| 12 |
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS |
| 13 |
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE |
| 14 |
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE |
| 15 |
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS |
| 16 |
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE. |
| 17 |
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. |
| 18 |
*/ |
| 19 |
|
| 20 |
/* |
| 21 |
* |
| 22 |
* Routines for displaying the auto-map. |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
#include "dxxsconf.h" |
| 27 |
#include <algorithm> |
| 28 |
#include <stdio.h> |
| 29 |
#include <stdlib.h> |
| 30 |
#include <string.h> |
| 31 |
|
| 32 |
#if DXX_USE_OGL |
| 33 |
#include "ogl_init.h" |
| 34 |
#endif |
| 35 |
|
| 36 |
#include "dxxerror.h" |
| 37 |
#include "3d.h" |
| 38 |
#include "inferno.h" |
| 39 |
#include "u_mem.h" |
| 40 |
#include "render.h" |
| 41 |
#include "object.h" |
| 42 |
#include "game.h" |
| 43 |
#include "polyobj.h" |
| 44 |
#include "sounds.h" |
| 45 |
#include "player.h" |
| 46 |
#include "bm.h" |
| 47 |
#include "key.h" |
| 48 |
#include "newmenu.h" |
| 49 |
#include "textures.h" |
| 50 |
#include "hudmsg.h" |
| 51 |
#include "timer.h" |
| 52 |
#include "segpoint.h" |
| 53 |
#include "joy.h" |
| 54 |
#include "pcx.h" |
| 55 |
#include "palette.h" |
| 56 |
#include "wall.h" |
| 57 |
#include "physfsx.h" |
| 58 |
#include "gameseq.h" |
| 59 |
#include "gamefont.h" |
| 60 |
#include "gameseg.h" |
| 61 |
#include "common/3d/globvars.h" |
| 62 |
#include "multi.h" |
| 63 |
#include "kconfig.h" |
| 64 |
#include "endlevel.h" |
| 65 |
#include "text.h" |
| 66 |
#include "gauges.h" |
| 67 |
#include "powerup.h" |
| 68 |
#include "switch.h" |
| 69 |
#include "automap.h" |
| 70 |
#include "timer.h" |
| 71 |
#include "config.h" |
| 72 |
#include "playsave.h" |
| 73 |
#include "window.h" |
| 74 |
#include "playsave.h" |
| 75 |
#include "args.h" |
| 76 |
#include "physics.h" |
| 77 |
|
| 78 |
#include "compiler-range_for.h" |
| 79 |
#include "d_enumerate.h" |
| 80 |
#include "d_levelstate.h" |
| 81 |
#include "d_range.h" |
| 82 |
#include "d_zip.h" |
| 83 |
#include <memory> |
| 84 |
|
| 85 |
#define EF_USED 1 // This edge is used |
| 86 |
#define EF_DEFINING 2 // A structure defining edge that should always draw. |
| 87 |
#define EF_FRONTIER 4 // An edge between the known and the unknown. |
| 88 |
#define EF_SECRET 8 // An edge that is part of a secret wall. |
| 89 |
#define EF_GRATE 16 // A grate... draw it all the time. |
| 90 |
#define EF_NO_FADE 32 // An edge that doesn't fade with distance |
| 91 |
#define EF_TOO_FAR 64 // An edge that is too far away |
| 92 |
|
| 93 |
namespace dcx { |
| 94 |
|
| 95 |
namespace { |
| 96 |
|
| 97 |
struct Edge_info |
| 98 |
{ |
| 99 |
std::array<vertnum_t, 2> verts; // 8 bytes |
| 100 |
std::array<sidenum_t, 4> sides; // 4 bytes |
| 101 |
std::array<segnum_t, 4> segnum; // 16 bytes // This might not need to be stored... If you can access the normals of a side. |
| 102 |
ubyte flags; // 1 bytes // See the EF_??? defines above. |
| 103 |
color_t color; // 1 bytes |
| 104 |
ubyte num_faces; // 1 bytes // 31 bytes... |
| 105 |
}; |
| 106 |
|
| 107 |
struct automap : ::dcx::window |
| 108 |
{ |
| 109 |
using ::dcx::window::window; |
| 110 |
fix64 entry_time; |
| 111 |
fix64 t1, t2; |
| 112 |
static_assert(PF_WIGGLE < UINT8_MAX, "storing PF_WIGGLE into old_wiggle would truncate the value"); |
| 113 |
uint8_t old_wiggle; |
| 114 |
uint8_t leave_mode{}; |
| 115 |
uint8_t pause_game; |
| 116 |
vms_angvec tangles; |
| 117 |
int max_segments_away{}; |
| 118 |
int segment_limit{1}; |
| 119 |
|
| 120 |
// Edge list variables |
| 121 |
int num_edges{}; |
| 122 |
unsigned max_edges; //set each frame |
| 123 |
unsigned end_valid_edges{}; |
| 124 |
std::unique_ptr<Edge_info[]> edges; |
| 125 |
std::unique_ptr<Edge_info *[]> drawingListBright; |
| 126 |
|
| 127 |
// Screen canvas variables |
| 128 |
grs_subcanvas automap_view; |
| 129 |
|
| 130 |
grs_main_bitmap automap_background; |
| 131 |
|
| 132 |
// Rendering variables |
| 133 |
fix zoom{0x9000}; |
| 134 |
vms_vector view_target; |
| 135 |
vms_vector view_position; |
| 136 |
fix farthest_dist{(F1_0 * 20 * 50)}; // 50 segments away |
| 137 |
vms_matrix viewMatrix; |
| 138 |
fix viewDist{}; |
| 139 |
|
| 140 |
segment_depth_array_t depth_array; |
| 141 |
color_t wall_normal_color; |
| 142 |
color_t wall_door_color; |
| 143 |
color_t wall_door_blue; |
| 144 |
color_t wall_door_gold; |
| 145 |
color_t wall_door_red; |
| 146 |
color_t hostage_color; |
| 147 |
color_t green_31; |
| 148 |
}; |
| 149 |
|
| 150 |
// ---------------------------------------------------------------------------------------------------------- |
| 151 |
// Set the segment depth of all segments from start_seg in `depth`. |
| 152 |
// Returns maximum depth value. |
| 153 |
[[nodiscard]] |
| 154 |
unsigned set_segment_depths(vcsegidx_t start_seg, const std::array<uint8_t, MAX_SEGMENTS> *const limit, segment_depth_array_t &depth) |
| 155 |
{ |
| 156 |
std::array<segnum_t, MAX_SEGMENTS> queue; |
| 157 |
int head, tail; |
| 158 |
|
| 159 |
head = 0; |
| 160 |
tail = 0; |
| 161 |
|
| 162 |
visited_segment_bitarray_t visited; |
| 163 |
|
| 164 |
queue[tail++] = start_seg; |
| 165 |
visited[start_seg] = true; |
| 166 |
depth[start_seg] = 1; |
| 167 |
|
| 168 |
unsigned parent_depth; |
| 169 |
do { |
| 170 |
const auto curseg = queue[head++]; |
| 171 |
auto &children = vcsegptr(curseg)->shared_segment::children; |
| 172 |
parent_depth = depth[curseg]; |
| 173 |
|
| 174 |
for (const auto childnum : children) |
| 175 |
{ |
| 176 |
if (childnum != segment_none && childnum != segment_exit) |
| 177 |
if (!limit || (*limit)[childnum]) |
| 178 |
{ |
| 179 |
auto &&v = visited[childnum]; |
| 180 |
if (!v) |
| 181 |
{ |
| 182 |
v = true; |
| 183 |
depth[childnum] = std::min(static_cast<unsigned>(std::numeric_limits<segment_depth_array_t::value_type>::max()), parent_depth + 1); |
| 184 |
queue[tail++] = childnum; |
| 185 |
} |
| 186 |
} |
| 187 |
} |
| 188 |
} while (head < tail); |
| 189 |
|
| 190 |
return parent_depth+1; |
| 191 |
} |
| 192 |
|
| 193 |
} |
| 194 |
|
| 195 |
} |
| 196 |
|
| 197 |
namespace dsx { |
| 198 |
|
| 199 |
namespace { |
| 200 |
|
| 201 |
struct automap : ::dcx::automap |
| 202 |
{ |
| 203 |
using ::dcx::automap::automap; |
| 204 |
#if DXX_BUILD_DESCENT == 2 |
| 205 |
color_t white_63; |
| 206 |
color_t blue_48; |
| 207 |
color_t wall_revealed_color; |
| 208 |
#endif |
| 209 |
control_info controls; |
| 210 |
virtual window_event_result event_handler(const d_event &) override; |
| 211 |
}; |
| 212 |
|
| 213 |
static void init_automap_subcanvas(grs_subcanvas &view, grs_canvas &container) |
| 214 |
{ |
| 215 |
#if DXX_BUILD_DESCENT == 1 |
| 216 |
if (MacHog) |
| 217 |
gr_init_sub_canvas(view, container, 38*(SWIDTH/640.0), 77*(SHEIGHT/480.0), 564*(SWIDTH/640.0), 381*(SHEIGHT/480.0)); |
| 218 |
else |
| 219 |
#endif |
| 220 |
gr_init_sub_canvas(view, container, (SWIDTH/23), (SHEIGHT/6), (SWIDTH/1.1), (SHEIGHT/1.45)); |
| 221 |
} |
| 222 |
|
| 223 |
static void automap_build_edge_list(automap &am, int add_all_edges); |
| 224 |
} |
| 225 |
|
| 226 |
} |
| 227 |
|
| 228 |
namespace dcx { |
| 229 |
|
| 230 |
#define MAX_EDGES_FROM_VERTS(v) ((v)*4) |
| 231 |
|
| 232 |
#define K_WALL_NORMAL_COLOR BM_XRGB(29, 29, 29 ) |
| 233 |
#define K_WALL_DOOR_COLOR BM_XRGB(5, 27, 5 ) |
| 234 |
#define K_WALL_DOOR_BLUE BM_XRGB(0, 0, 31) |
| 235 |
#define K_WALL_DOOR_GOLD BM_XRGB(31, 31, 0) |
| 236 |
#define K_WALL_DOOR_RED BM_XRGB(31, 0, 0) |
| 237 |
#define K_WALL_REVEALED_COLOR BM_XRGB(0, 0, 25 ) //what you see when you have the full map powerup |
| 238 |
#define K_HOSTAGE_COLOR BM_XRGB(0, 31, 0 ) |
| 239 |
#define K_FONT_COLOR_20 BM_XRGB(20, 20, 20 ) |
| 240 |
#define K_GREEN_31 BM_XRGB(0, 31, 0) |
| 241 |
|
| 242 |
uint8_t Automap_active; |
| 243 |
|
| 244 |
namespace { |
| 245 |
|
| 246 |
#ifndef NDEBUG |
| 247 |
static uint8_t Automap_debug_show_all_segments; |
| 248 |
#endif |
| 249 |
|
| 250 |
static void automap_clear_visited(d_level_unique_automap_state &LevelUniqueAutomapState) |
| 251 |
{ |
| 252 |
#ifndef NDEBUG |
| 253 |
Automap_debug_show_all_segments = 0; |
| 254 |
#endif |
| 255 |
LevelUniqueAutomapState.Automap_visited = {}; |
| 256 |
} |
| 257 |
|
| 258 |
static void init_automap_colors(automap &am) |
| 259 |
{ |
| 260 |
am.wall_normal_color = K_WALL_NORMAL_COLOR; |
| 261 |
am.wall_door_color = K_WALL_DOOR_COLOR; |
| 262 |
am.wall_door_blue = K_WALL_DOOR_BLUE; |
| 263 |
am.wall_door_gold = K_WALL_DOOR_GOLD; |
| 264 |
am.wall_door_red = K_WALL_DOOR_RED; |
| 265 |
am.hostage_color = K_HOSTAGE_COLOR; |
| 266 |
am.green_31 = K_GREEN_31; |
| 267 |
} |
| 268 |
|
| 269 |
void adjust_segment_limit(automap &am, const unsigned SegmentLimit) |
| 270 |
{ |
| 271 |
const auto &depth_array{am.depth_array}; |
| 272 |
const auto predicate = [&depth_array, SegmentLimit](const segnum_t &e1) { |
| 273 |
return depth_array[e1] <= SegmentLimit; |
| 274 |
}; |
| 275 |
for (auto &i : unchecked_partial_range(am.edges.get(), am.end_valid_edges)) |
| 276 |
{ |
| 277 |
// Unchecked for speed |
| 278 |
const auto &&range{unchecked_partial_range(i.segnum, i.num_faces)}; |
| 279 |
if (std::any_of(range.begin(), range.end(), predicate)) |
| 280 |
i.flags &= ~EF_TOO_FAR; |
| 281 |
else |
| 282 |
i.flags |= EF_TOO_FAR; |
| 283 |
} |
| 284 |
} |
| 285 |
|
| 286 |
} |
| 287 |
|
| 288 |
} |
| 289 |
|
| 290 |
namespace dsx { |
| 291 |
|
| 292 |
namespace { |
| 293 |
|
| 294 |
static void recompute_automap_segment_visibility(const d_level_unique_automap_state &LevelUniqueAutomapState, unsigned compute_depth_all_segments, const segnum_t initial_segnum, automap &am) |
| 295 |
{ |
| 296 |
#ifndef NDEBUG |
| 297 |
if (Automap_debug_show_all_segments) |
| 298 |
compute_depth_all_segments = 1; |
| 299 |
#endif |
| 300 |
if (cheats.fullautomap) |
| 301 |
compute_depth_all_segments = 1; |
| 302 |
automap_build_edge_list(am, compute_depth_all_segments); |
| 303 |
am.max_segments_away = set_segment_depths(initial_segnum, compute_depth_all_segments ? nullptr : &LevelUniqueAutomapState.Automap_visited, am.depth_array); |
| 304 |
am.segment_limit = am.max_segments_away; |
| 305 |
adjust_segment_limit(am, am.segment_limit); |
| 306 |
} |
| 307 |
|
| 308 |
#if DXX_BUILD_DESCENT == 2 |
| 309 |
#ifdef RELEASE |
| 310 |
constexpr |
| 311 |
#endif |
| 312 |
static float MarkerScale{2.0f}; |
| 313 |
static unsigned Marker_index; |
| 314 |
|
| 315 |
struct marker_delete_are_you_sure_menu : std::array<newmenu_item, 2>, newmenu |
| 316 |
{ |
| 317 |
using array_type = std::array<newmenu_item, 2>; |
| 318 |
d_level_unique_object_state &LevelUniqueObjectState; |
| 319 |
segment_array &Segments; |
| 320 |
d_marker_state &MarkerState; |
| 321 |
marker_delete_are_you_sure_menu(grs_canvas &canvas, d_level_unique_object_state &LevelUniqueObjectState, segment_array &Segments, d_marker_state &MarkerState) : |
| 322 |
array_type{{ |
| 323 |
newmenu_item::nm_item_menu{TXT_YES}, |
| 324 |
newmenu_item::nm_item_menu{TXT_NO}, |
| 325 |
}}, |
| 326 |
newmenu(menu_title{nullptr}, menu_subtitle{"Delete Marker?"}, menu_filename{nullptr}, tiny_mode_flag::normal, tab_processing_flag::ignore, adjusted_citem::create(*static_cast<array_type *>(this), 0), canvas), |
| 327 |
LevelUniqueObjectState(LevelUniqueObjectState), |
| 328 |
Segments(Segments), |
| 329 |
MarkerState(MarkerState) |
| 330 |
{ |
| 331 |
} |
| 332 |
virtual window_event_result event_handler(const d_event &) override; |
| 333 |
static std::pair<imobjidx_t *, game_marker_index> get_marker_object(d_marker_state &MarkerState); |
| 334 |
void handle_selected_yes() const; |
| 335 |
}; |
| 336 |
|
| 337 |
window_event_result marker_delete_are_you_sure_menu::event_handler(const d_event &event) |
| 338 |
{ |
| 339 |
switch (event.type) |
| 340 |
{ |
| 341 |
case event_type::newmenu_selected: |
| 342 |
{ |
| 343 |
const auto citem{static_cast<const d_select_event &>(event).citem}; |
| 344 |
if (citem == 0) |
| 345 |
/* User chose Yes */ |
| 346 |
handle_selected_yes(); |
| 347 |
/* The dialog should close after the user picks Yes or No. |
| 348 |
*/ |
| 349 |
return window_event_result::close; |
| 350 |
} |
| 351 |
default: |
| 352 |
return newmenu::event_handler(event); |
| 353 |
} |
| 354 |
} |
| 355 |
|
| 356 |
std::pair<imobjidx_t *, game_marker_index> marker_delete_are_you_sure_menu::get_marker_object(d_marker_state &MarkerState) |
| 357 |
{ |
| 358 |
const auto HighlightMarker{MarkerState.HighlightMarker}; |
| 359 |
if (!MarkerState.imobjidx.valid_index(HighlightMarker)) |
| 360 |
return {nullptr, HighlightMarker}; |
| 361 |
auto &mo{MarkerState.imobjidx[HighlightMarker]}; |
| 362 |
return {mo == object_none ? nullptr : &mo, HighlightMarker}; |
| 363 |
} |
| 364 |
|
| 365 |
void marker_delete_are_you_sure_menu::handle_selected_yes() const |
| 366 |
{ |
| 367 |
const auto &&[mo, HighlightMarker]{get_marker_object(MarkerState)}; |
| 368 |
if (!mo) |
| 369 |
/* Check that the selected marker is still a valid object. */ |
| 370 |
return; |
| 371 |
/* FIXME: this event should be sent to other players |
| 372 |
* so that they remove the marker. |
| 373 |
*/ |
| 374 |
obj_delete(LevelUniqueObjectState, Segments, LevelUniqueObjectState.Objects.vmptridx(std::exchange(*mo, object_none))); |
| 375 |
MarkerState.message[HighlightMarker] = {}; |
| 376 |
MarkerState.HighlightMarker = game_marker_index::None; |
| 377 |
} |
| 378 |
|
| 379 |
void init_automap_colors(automap &am) |
| 380 |
{ |
| 381 |
::dcx::init_automap_colors(am); |
| 382 |
am.white_63 = gr_find_closest_color_current(63, 63, 63); |
| 383 |
am.blue_48 = gr_find_closest_color_current(0, 0, 48); |
| 384 |
am.wall_revealed_color = K_WALL_REVEALED_COLOR; |
| 385 |
} |
| 386 |
#endif |
| 387 |
|
| 388 |
// Map movement defines |
| 389 |
#define PITCH_DEFAULT 9000 |
| 390 |
#define ZOOM_DEFAULT i2f(20*10) |
| 391 |
#define ZOOM_MIN_VALUE i2f(20*5) |
| 392 |
#define ZOOM_MAX_VALUE i2f(20*100) |
| 393 |
|
| 394 |
} |
| 395 |
|
| 396 |
/* MAX_DROP_MULTI_* must be a power of 2 for LastMarkerDropped to work |
| 397 |
* properly. |
| 398 |
*/ |
| 399 |
#define MAX_DROP_MULTI_COOP_0 2 |
| 400 |
#define MAX_DROP_MULTI_COOP_1 4 |
| 401 |
#define MAX_DROP_MULTI_COOP_P (max_numplayers > 4) |
| 402 |
#define MAX_DROP_MULTI_COOP (MAX_DROP_MULTI_COOP_P ? MAX_DROP_MULTI_COOP_0 : MAX_DROP_MULTI_COOP_1) |
| 403 |
#define MAX_DROP_MULTI_COMPETITIVE 2 |
| 404 |
#define MAX_DROP_SINGLE 9 |
| 405 |
|
| 406 |
#if DXX_BUILD_DESCENT == 2 |
| 407 |
marker_message_text_t Marker_input; |
| 408 |
|
| 409 |
d_marker_state MarkerState; |
| 410 |
|
| 411 |
game_marker_index convert_player_marker_index_to_game_marker_index(const game_mode_flags game_mode, const unsigned max_numplayers, const unsigned player_num, const player_marker_index player_marker_num) |
| 412 |
{ |
| 413 |
if (game_mode & GM_MULTI_COOP) |
| 414 |
return static_cast<game_marker_index>((player_num * MAX_DROP_MULTI_COOP) + static_cast<unsigned>(player_marker_num)); |
| 415 |
if (game_mode & GM_MULTI) |
| 416 |
return static_cast<game_marker_index>((player_num * MAX_DROP_MULTI_COMPETITIVE) + static_cast<unsigned>(player_marker_num)); |
| 417 |
return static_cast<game_marker_index>(player_marker_num); |
| 418 |
} |
| 419 |
|
| 420 |
unsigned d_marker_state::get_markers_per_player(const game_mode_flags game_mode, const unsigned max_numplayers) |
| 421 |
{ |
| 422 |
if (game_mode & GM_MULTI_COOP) |
| 423 |
return MAX_DROP_MULTI_COOP; |
| 424 |
if (game_mode & GM_MULTI) |
| 425 |
return MAX_DROP_MULTI_COMPETITIVE; |
| 426 |
return MAX_DROP_SINGLE; |
| 427 |
} |
| 428 |
|
| 429 |
xrange<player_marker_index> get_player_marker_range(const unsigned maxdrop) |
| 430 |
{ |
| 431 |
const auto base{player_marker_index::_0}; |
| 432 |
return {base, static_cast<player_marker_index>(static_cast<unsigned>(base) + maxdrop)}; |
| 433 |
} |
| 434 |
|
| 435 |
playernum_t get_marker_owner(const game_mode_flags game_mode, const game_marker_index gmi, const unsigned max_numplayers) |
| 436 |
{ |
| 437 |
const auto ugmi{static_cast<unsigned>(gmi)}; |
| 438 |
if (game_mode & GM_MULTI_COOP) |
| 439 |
{ |
| 440 |
/* This is split out to encourage the compiler to recognize that |
| 441 |
* the divisor is a constant in every path, and in every path, |
| 442 |
* the divisor was chosen to allow use of right shift in place |
| 443 |
* of division. |
| 444 |
*/ |
| 445 |
if (MAX_DROP_MULTI_COOP_P) |
| 446 |
return ugmi / MAX_DROP_MULTI_COOP_0; |
| 447 |
return ugmi / MAX_DROP_MULTI_COOP_1; |
| 448 |
} |
| 449 |
if (game_mode & GM_MULTI) |
| 450 |
return ugmi / MAX_DROP_MULTI_COMPETITIVE; |
| 451 |
return 0; |
| 452 |
} |
| 453 |
|
| 454 |
namespace { |
| 455 |
|
| 456 |
xrange<game_marker_index> get_game_marker_range(const game_mode_flags game_mode, const unsigned max_numplayers, const unsigned player_num, const unsigned maxdrop) |
| 457 |
{ |
| 458 |
const auto base{convert_player_marker_index_to_game_marker_index(game_mode, max_numplayers, player_num, player_marker_index::_0)}; |
| 459 |
return {base, static_cast<game_marker_index>(static_cast<unsigned>(base) + maxdrop)}; |
| 460 |
} |
| 461 |
|
| 462 |
} |
| 463 |
#endif |
| 464 |
|
| 465 |
// ------------------------------------------------------------- |
| 466 |
|
| 467 |
namespace { |
| 468 |
|
| 469 |
static void draw_all_edges(automap &am); |
| 470 |
#if DXX_BUILD_DESCENT == 2 |
| 471 |
static void DrawMarkerNumber(grs_canvas &canvas, const automap &am, const game_marker_index gmi, const player_marker_index pmi, const g3_draw_sphere_point &BasePoint) |
| 472 |
{ |
| 473 |
struct xy |
| 474 |
{ |
| 475 |
float x0, y0, x1, y1; |
| 476 |
}; |
| 477 |
static constexpr enumerated_array<std::array<xy, 5>, 9, player_marker_index> sArray{{{ |
| 478 |
{{ |
| 479 |
{-0.25, 0.75, 0, 1}, |
| 480 |
{0, 1, 0, -1}, |
| 481 |
{-1, -1, 1, -1}, |
| 482 |
}}, |
| 483 |
{{ |
| 484 |
{-1, 1, 1, 1}, |
| 485 |
{1, 1, 1, 0}, |
| 486 |
{-1, 0, 1, 0}, |
| 487 |
{-1, 0, -1, -1}, |
| 488 |
{-1, -1, 1, -1} |
| 489 |
}}, |
| 490 |
{{ |
| 491 |
{-1, 1, 1, 1}, |
| 492 |
{1, 1, 1, -1}, |
| 493 |
{-1, -1, 1, -1}, |
| 494 |
{0, 0, 1, 0}, |
| 495 |
}}, |
| 496 |
{{ |
| 497 |
{-1, 1, -1, 0}, |
| 498 |
{-1, 0, 1, 0}, |
| 499 |
{1, 1, 1, -1}, |
| 500 |
}}, |
| 501 |
{{ |
| 502 |
{-1, 1, 1, 1}, |
| 503 |
{-1, 1, -1, 0}, |
| 504 |
{-1, 0, 1, 0}, |
| 505 |
{1, 0, 1, -1}, |
| 506 |
{-1, -1, 1, -1} |
| 507 |
}}, |
| 508 |
{{ |
| 509 |
{-1, 1, 1, 1}, |
| 510 |
{-1, 1, -1, -1}, |
| 511 |
{-1, -1, 1, -1}, |
| 512 |
{1, -1, 1, 0}, |
| 513 |
{-1, 0, 1, 0} |
| 514 |
}}, |
| 515 |
{{ |
| 516 |
{-1, 1, 1, 1}, |
| 517 |
{1, 1, 1, -1}, |
| 518 |
}}, |
| 519 |
{{ |
| 520 |
{-1, 1, 1, 1}, |
| 521 |
{1, 1, 1, -1}, |
| 522 |
{-1, -1, 1, -1}, |
| 523 |
{-1, -1, -1, 1}, |
| 524 |
{-1, 0, 1, 0} |
| 525 |
}}, |
| 526 |
{{ |
| 527 |
{-1, 1, 1, 1}, |
| 528 |
{1, 1, 1, -1}, |
| 529 |
{-1, 0, 1, 0}, |
| 530 |
{-1, 0, -1, 1}, |
| 531 |
}} |
| 532 |
}}}; |
| 533 |
static constexpr enumerated_array<uint_fast8_t, 9, player_marker_index> NumOfPoints{{{3, 5, 4, 3, 5, 5, 2, 5, 4}}}; |
| 534 |
|
| 535 |
const auto color{gmi == MarkerState.HighlightMarker ? am.white_63 : am.blue_48}; |
| 536 |
const g3_draw_line_context text_line_context{canvas, color}; |
| 537 |
const auto scale_x{Matrix_scale.x}; |
| 538 |
const auto scale_y{Matrix_scale.y}; |
| 539 |
range_for (const auto &i, unchecked_partial_range(sArray[pmi], NumOfPoints[pmi])) |
| 540 |
{ |
| 541 |
const auto ax0{i.x0 * MarkerScale}; |
| 542 |
const auto ay0{i.y0 * MarkerScale}; |
| 543 |
const auto ax1{i.x1 * MarkerScale}; |
| 544 |
const auto ay1{i.y1 * MarkerScale}; |
| 545 |
const auto build_displaced_point{[](const g3_rotated_point &BasePoint, const fix x, const fix y) { |
| 546 |
auto result{BasePoint}; |
| 547 |
result.p3_vec.x += x; |
| 548 |
result.p3_vec.y += y; |
| 549 |
return result; |
| 550 |
}}; |
| 551 |
g3_draw_line_point FromPoint{build_displaced_point(BasePoint, fixmul(fl2f(ax0), scale_x), fixmul(fl2f(ay0), scale_y))}; |
| 552 |
g3_draw_line_point ToPoint{build_displaced_point(BasePoint, fixmul(fl2f(ax1), scale_x), fixmul(fl2f(ay1), scale_y))}; |
| 553 |
g3_draw_line(text_line_context, FromPoint, ToPoint); |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
static void DropMarker(fvmobjptridx &vmobjptridx, fvmsegptridx &vmsegptridx, const object &plrobj, const game_marker_index marker_num, const player_marker_index player_marker_num) |
| 558 |
{ |
| 559 |
auto &marker_objidx{MarkerState.imobjidx[marker_num]}; |
| 560 |
if (marker_objidx != object_none) |
| 561 |
obj_delete(LevelUniqueObjectState, Segments, vmobjptridx(marker_objidx)); |
| 562 |
|
| 563 |
marker_objidx = drop_marker_object(plrobj.pos, vmsegptridx(plrobj.segnum), plrobj.orient, marker_num); |
| 564 |
#if DXX_USE_MULTIPLAYER |
| 565 |
if (Game_mode & GM_MULTI) |
| 566 |
multi_send_drop_marker(Player_num, plrobj.pos, player_marker_num, MarkerState.message[marker_num]); |
| 567 |
#else |
| 568 |
(void)player_marker_num; |
| 569 |
#endif |
| 570 |
} |
| 571 |
|
| 572 |
} |
| 573 |
|
| 574 |
void DropBuddyMarker(object &objp) |
| 575 |
{ |
| 576 |
auto &Objects{LevelUniqueObjectState.Objects}; |
| 577 |
auto &vmobjptridx{Objects.vmptridx}; |
| 578 |
|
| 579 |
constexpr auto marker_num{game_marker_index::GuidebotDeathSite}; |
| 580 |
static_assert(MarkerState.message.valid_index(marker_num), "not enough markers"); |
| 581 |
|
| 582 |
auto &MarkerMessage{MarkerState.message[marker_num]}; |
| 583 |
snprintf(MarkerMessage.data(), MarkerMessage.size(), "RIP: %s", static_cast<const char *>(PlayerCfg.GuidebotName)); |
| 584 |
|
| 585 |
auto &marker_objidx{MarkerState.imobjidx[marker_num]}; |
| 586 |
if (marker_objidx != object_none) |
| 587 |
obj_delete(LevelUniqueObjectState, Segments, vmobjptridx(marker_objidx)); |
| 588 |
|
| 589 |
marker_objidx = drop_marker_object(objp.pos, vmsegptridx(objp.segnum), objp.orient, marker_num); |
| 590 |
} |
| 591 |
|
| 592 |
namespace { |
| 593 |
|
| 594 |
static void DrawMarkers(const g3_instance_context &viewer_context, fvcobjptr &vcobjptr, grs_canvas &canvas, automap &am) |
| 595 |
{ |
| 596 |
static int cyc=10,cycdir=1; |
| 597 |
|
| 598 |
const auto game_mode{Game_mode}; |
| 599 |
const auto max_numplayers{ |
| 600 |
#if DXX_USE_MULTIPLAYER |
| 601 |
Netgame.max_numplayers |
| 602 |
#else |
| 603 |
1u |
| 604 |
#endif |
| 605 |
}; |
| 606 |
const auto maxdrop{MarkerState.get_markers_per_player(game_mode, max_numplayers)}; |
| 607 |
const auto &&game_marker_range{get_game_marker_range(game_mode, max_numplayers, Player_num, maxdrop)}; |
| 608 |
const auto &&player_marker_range{get_player_marker_range(maxdrop)}; |
| 609 |
const auto &&zipped_marker_range{zip(game_marker_range, player_marker_range, unchecked_partial_range(&MarkerState.imobjidx[*game_marker_range.begin()], maxdrop))}; |
| 610 |
const auto &&mb{zipped_marker_range.begin()}; |
| 611 |
const auto &&me{zipped_marker_range.end()}; |
| 612 |
auto iter{mb}; |
| 613 |
/* Find the first marker object in the player's marker range that is |
| 614 |
* not object_none. If every marker object in the range is |
| 615 |
* object_none, then there are no markers to draw, so return. |
| 616 |
*/ |
| 617 |
for (;;) |
| 618 |
{ |
| 619 |
auto &&[gmi, pmi, objidx]{*iter}; |
| 620 |
(void)gmi; |
| 621 |
(void)pmi; |
| 622 |
if (objidx != object_none) |
| 623 |
break; |
| 624 |
if (++ iter == me) |
| 625 |
return; |
| 626 |
} |
| 627 |
/* A marker was found, so at least one marker will be drawn. Set up |
| 628 |
* colors for the markers. |
| 629 |
*/ |
| 630 |
const auto current_cycle_color{cyc}; |
| 631 |
const std::array<color_t, 3> colors{{ |
| 632 |
gr_find_closest_color_current(current_cycle_color, 0, 0), |
| 633 |
gr_find_closest_color_current(current_cycle_color + 10, 0, 0), |
| 634 |
gr_find_closest_color_current(current_cycle_color + 20, 0, 0), |
| 635 |
}}; |
| 636 |
for (; iter != me; ++iter) |
| 637 |
{ |
| 638 |
auto &&[gmi, pmi, objidx]{*iter}; |
| 639 |
if (objidx != object_none) |
| 640 |
{ |
| 641 |
g3_draw_sphere_point sphere_point{viewer_context, vcobjptr(objidx)->pos}; |
| 642 |
static constexpr fix MARKER_SPHERE_SIZE{0x58000}; |
| 643 |
g3_draw_sphere(canvas, sphere_point, MARKER_SPHERE_SIZE, colors[0]); |
| 644 |
g3_draw_sphere(canvas, sphere_point, MARKER_SPHERE_SIZE / 2, colors[1]); |
| 645 |
g3_draw_sphere(canvas, sphere_point, MARKER_SPHERE_SIZE / 4, colors[2]); |
| 646 |
DrawMarkerNumber(canvas, am, gmi, pmi, sphere_point); |
| 647 |
} |
| 648 |
} |
| 649 |
|
| 650 |
if (cycdir) |
| 651 |
cyc+=2; |
| 652 |
else |
| 653 |
cyc-=2; |
| 654 |
|
| 655 |
if (cyc>43) |
| 656 |
{ |
| 657 |
cyc=43; |
| 658 |
cycdir=0; |
| 659 |
} |
| 660 |
else if (cyc<10) |
| 661 |
{ |
| 662 |
cyc=10; |
| 663 |
cycdir=1; |
| 664 |
} |
| 665 |
} |
| 666 |
|
| 667 |
static void ClearMarkers() |
| 668 |
{ |
| 669 |
static_cast<d_marker_object_numbers &>(MarkerState) = {}; |
| 670 |
MarkerState.message = {}; |
| 671 |
} |
| 672 |
#endif |
| 673 |
|
| 674 |
} |
| 675 |
|
| 676 |
void automap_clear_visited(d_level_unique_automap_state &LevelUniqueAutomapState) |
| 677 |
{ |
| 678 |
#if DXX_BUILD_DESCENT == 2 |
| 679 |
ClearMarkers(); |
| 680 |
#endif |
| 681 |
::dcx::automap_clear_visited(LevelUniqueAutomapState); |
| 682 |
} |
| 683 |
|
| 684 |
namespace { |
| 685 |
|
| 686 |
static void draw_player(const g3_instance_context &viewer_context, const g3_draw_line_context &context, const object_base &obj) |
| 687 |
{ |
| 688 |
// Draw Console player -- shaped like a ellipse with an arrow. |
| 689 |
g3_draw_sphere_point sphere_point{viewer_context, obj.pos}; |
| 690 |
const auto obj_size{obj.size}; |
| 691 |
g3_draw_sphere(context.canvas, sphere_point, obj_size, context.color); |
| 692 |
|
| 693 |
// Draw shaft of arrow |
| 694 |
const auto head_pos{vm_vec_scale_add(obj.pos, obj.orient.fvec, obj_size * 2)}; |
| 695 |
{ |
| 696 |
g3_draw_line_point arrow_point{viewer_context, vm_vec_scale_add(obj.pos, obj.orient.fvec, obj_size * 3)}; |
| 697 |
g3_draw_line(context, sphere_point, arrow_point); |
| 698 |
|
| 699 |
// Draw right head of arrow |
| 700 |
g3_draw_line_point lhead_point{viewer_context, /* rhead_pos = */ vm_vec_scale_add(head_pos, obj.orient.rvec, obj_size)}; |
| 701 |
g3_draw_line(context, arrow_point, lhead_point); |
| 702 |
|
| 703 |
// Draw left head of arrow |
| 704 |
g3_draw_line_point rhead_point{viewer_context, /* lhead_pos = */ vm_vec_scale_add(head_pos, obj.orient.rvec, -obj_size)}; |
| 705 |
g3_draw_line(context, arrow_point, rhead_point); |
| 706 |
} |
| 707 |
|
| 708 |
// Draw player's up vector |
| 709 |
g3_draw_line_point arrow_point{viewer_context, /* arrow_pos = */ vm_vec_scale_add(obj.pos, obj.orient.uvec, obj_size * 2)}; |
| 710 |
g3_draw_line(context, sphere_point, arrow_point); |
| 711 |
} |
| 712 |
|
| 713 |
#if DXX_BUILD_DESCENT == 2 |
| 714 |
//name for each group. maybe move somewhere else |
| 715 |
constexpr char system_name[][17] = { |
| 716 |
"Zeta Aquilae", |
| 717 |
"Quartzon System", |
| 718 |
"Brimspark System", |
| 719 |
"Limefrost Spiral", |
| 720 |
"Baloris Prime", |
| 721 |
"Omega System"}; |
| 722 |
#endif |
| 723 |
|
| 724 |
static void name_frame(grs_canvas &canvas, automap &am) |
| 725 |
{ |
| 726 |
gr_set_fontcolor(canvas, am.green_31, -1); |
| 727 |
char name_level_left[128]; |
| 728 |
|
| 729 |
auto &game_font{*GAME_FONT}; |
| 730 |
#if DXX_BUILD_DESCENT == 1 |
| 731 |
const char *name_level; |
| 732 |
if (Current_level_num > 0) |
| 733 |
{ |
| 734 |
snprintf(name_level_left, sizeof(name_level_left), "%s %i: %s",TXT_LEVEL, Current_level_num, static_cast<const char *>(Current_level_name)); |
| 735 |
name_level = name_level_left; |
| 736 |
} |
| 737 |
else |
| 738 |
name_level = Current_level_name; |
| 739 |
|
| 740 |
gr_string(canvas, game_font, (SWIDTH / 64), (SHEIGHT / 48), name_level); |
| 741 |
#elif DXX_BUILD_DESCENT == 2 |
| 742 |
char name_level_right[128]; |
| 743 |
if (Current_level_num > 0) |
| 744 |
snprintf(name_level_left, sizeof(name_level_left), "%s %i",TXT_LEVEL, Current_level_num); |
| 745 |
else |
| 746 |
snprintf(name_level_left, sizeof(name_level_left), "Secret Level %i",-Current_level_num); |
| 747 |
|
| 748 |
const char *const current_level_name{Current_level_name}; |
| 749 |
if (PLAYING_BUILTIN_MISSION && Current_level_num > 0) |
| 750 |
snprintf(name_level_right, sizeof(name_level_right), "%s %d: %s", system_name[(Current_level_num-1)/4], ((Current_level_num - 1) % 4) + 1, current_level_name); |
| 751 |
else |
| 752 |
snprintf(name_level_right, sizeof(name_level_right), " %s", current_level_name); |
| 753 |
|
| 754 |
gr_string(canvas, game_font, (SWIDTH / 64), (SHEIGHT / 48), name_level_left); |
| 755 |
const auto &&[wr, h]{gr_get_string_size(game_font, name_level_right)}; |
| 756 |
gr_string(canvas, game_font, canvas.cv_bitmap.bm_w - wr - (SWIDTH / 64), (SHEIGHT / 48), name_level_right, wr, h); |
| 757 |
#endif |
| 758 |
} |
| 759 |
|
| 760 |
static void automap_apply_input(automap &am, const vms_matrix &plrorient, const vms_vector &plrpos) |
| 761 |
{ |
| 762 |
constexpr int SLIDE_SPEED{350}; |
| 763 |
constexpr int ZOOM_SPEED_FACTOR{500}; //(1500) |
| 764 |
constexpr int ROT_SPEED_DIVISOR{115000}; |
| 765 |
if (PlayerCfg.AutomapFreeFlight) |
| 766 |
{ |
| 767 |
if (am.controls.state.fire_primary) |
| 768 |
{ |
| 769 |
// Reset orientation |
| 770 |
am.controls.state.fire_primary = 0; |
| 771 |
am.viewMatrix = plrorient; |
| 772 |
am.view_position = vm_vec_scale_add(plrpos, am.viewMatrix.fvec, -ZOOM_DEFAULT); |
| 773 |
} |
| 774 |
|
| 775 |
if (am.controls.pitch_time || am.controls.heading_time || am.controls.bank_time) |
| 776 |
{ |
| 777 |
vms_angvec tangles; |
| 778 |
|
| 779 |
tangles.p = fixdiv(am.controls.pitch_time, ROT_SPEED_DIVISOR); |
| 780 |
tangles.h = fixdiv(am.controls.heading_time, ROT_SPEED_DIVISOR); |
| 781 |
tangles.b = fixdiv(am.controls.bank_time, ROT_SPEED_DIVISOR * 2); |
| 782 |
|
| 783 |
const auto &&tempm{vm_angles_2_matrix(tangles)}; |
| 784 |
am.viewMatrix = vm_matrix_x_matrix(am.viewMatrix, tempm); |
| 785 |
check_and_fix_matrix(am.viewMatrix); |
| 786 |
} |
| 787 |
|
| 788 |
if (am.controls.forward_thrust_time || am.controls.vertical_thrust_time || am.controls.sideways_thrust_time) |
| 789 |
{ |
| 790 |
vm_vec_scale_add2(am.view_position, am.viewMatrix.fvec, am.controls.forward_thrust_time * ZOOM_SPEED_FACTOR); |
| 791 |
vm_vec_scale_add2(am.view_position, am.viewMatrix.uvec, am.controls.vertical_thrust_time * SLIDE_SPEED); |
| 792 |
vm_vec_scale_add2(am.view_position, am.viewMatrix.rvec, am.controls.sideways_thrust_time * SLIDE_SPEED); |
| 793 |
|
| 794 |
// Crude wrapping check |
| 795 |
clamp_fix_symmetric(am.view_position.x, F1_0*32000); |
| 796 |
clamp_fix_symmetric(am.view_position.y, F1_0*32000); |
| 797 |
clamp_fix_symmetric(am.view_position.z, F1_0*32000); |
| 798 |
} |
| 799 |
} |
| 800 |
else |
| 801 |
{ |
| 802 |
if (am.controls.state.fire_primary) |
| 803 |
{ |
| 804 |
// Reset orientation |
| 805 |
am.viewDist = ZOOM_DEFAULT; |
| 806 |
am.tangles.p = PITCH_DEFAULT; |
| 807 |
am.tangles.h = 0; |
| 808 |
am.tangles.b = 0; |
| 809 |
am.view_target = plrpos; |
| 810 |
am.controls.state.fire_primary = 0; |
| 811 |
} |
| 812 |
|
| 813 |
am.viewDist -= am.controls.forward_thrust_time * ZOOM_SPEED_FACTOR; |
| 814 |
am.tangles.p += fixdiv(am.controls.pitch_time, ROT_SPEED_DIVISOR); |
| 815 |
am.tangles.h += fixdiv(am.controls.heading_time, ROT_SPEED_DIVISOR); |
| 816 |
am.tangles.b += fixdiv(am.controls.bank_time, ROT_SPEED_DIVISOR * 2); |
| 817 |
|
| 818 |
if (am.controls.vertical_thrust_time || am.controls.sideways_thrust_time) |
| 819 |
{ |
| 820 |
vms_vector old_vt{am.view_target}; |
| 821 |
vms_angvec tangles1{am.tangles}; |
| 822 |
const auto &&tempm{vm_angles_2_matrix(tangles1)}; |
| 823 |
vm_matrix_x_matrix(am.viewMatrix, plrorient, tempm); |
| 824 |
vm_vec_scale_add2(am.view_target, am.viewMatrix.uvec, am.controls.vertical_thrust_time * SLIDE_SPEED); |
| 825 |
vm_vec_scale_add2(am.view_target, am.viewMatrix.rvec, am.controls.sideways_thrust_time * SLIDE_SPEED); |
| 826 |
if (vm_vec_dist_quick(am.view_target, plrpos) > i2f(1000)) |
| 827 |
am.view_target = old_vt; |
| 828 |
} |
| 829 |
|
| 830 |
const auto &&tempm{vm_angles_2_matrix(am.tangles)}; |
| 831 |
vm_matrix_x_matrix(am.viewMatrix, plrorient, tempm); |
| 832 |
|
| 833 |
clamp_fix_lh(am.viewDist, ZOOM_MIN_VALUE, ZOOM_MAX_VALUE); |
| 834 |
} |
| 835 |
} |
| 836 |
|
| 837 |
static void draw_automap(fvcobjptr &vcobjptr, automap &am) |
| 838 |
{ |
| 839 |
if ( am.leave_mode==0 && am.controls.state.automap && (timer_query()-am.entry_time)> /* LEAVE_TIME = */ 0x4000) |
| 840 |
am.leave_mode = 1; |
| 841 |
|
| 842 |
{ |
| 843 |
auto &canvas{am.w_canv}; |
| 844 |
show_fullscr(canvas, am.automap_background); |
| 845 |
gr_set_fontcolor(canvas, BM_XRGB(20, 20, 20), -1); |
| 846 |
{ |
| 847 |
int x, y; |
| 848 |
#if DXX_BUILD_DESCENT == 1 |
| 849 |
if (MacHog) |
| 850 |
x = 80 * (SWIDTH / 640.), y = 36 * (SHEIGHT / 480.); |
| 851 |
else |
| 852 |
#endif |
| 853 |
x = SWIDTH / 8, y = SHEIGHT / 16; |
| 854 |
gr_string(canvas, *HUGE_FONT, x, y, TXT_AUTOMAP); |
| 855 |
} |
| 856 |
{ |
| 857 |
int x; |
| 858 |
int y0, y1, y2; |
| 859 |
#if DXX_BUILD_DESCENT == 1 |
| 860 |
const auto s1{TXT_SLIDE_UPDOWN}; |
| 861 |
const auto &s2{"F9/F10 Changes viewing distance"}; |
| 862 |
if (!MacHog) |
| 863 |
{ |
| 864 |
x = SWIDTH / 4.923; |
| 865 |
y0 = SHEIGHT / 1.126; |
| 866 |
y1 = SHEIGHT / 1.083; |
| 867 |
y2 = SHEIGHT / 1.043; |
| 868 |
} |
| 869 |
else |
| 870 |
{ |
| 871 |
// for the Mac automap they're shown up the top, hence the different layout |
| 872 |
x = 265 * (SWIDTH / 640.); |
| 873 |
y0 = 27 * (SHEIGHT / 480.); |
| 874 |
y1 = 44 * (SHEIGHT / 480.); |
| 875 |
y2 = 61 * (SHEIGHT / 480.); |
| 876 |
} |
| 877 |
#elif DXX_BUILD_DESCENT == 2 |
| 878 |
const auto &s1{"F9/F10 Changes viewing distance"}; |
| 879 |
const auto s2{TXT_AUTOMAP_MARKER}; |
| 880 |
x = SWIDTH / 10.666; |
| 881 |
y0 = SHEIGHT / 1.126; |
| 882 |
y1 = SHEIGHT / 1.083; |
| 883 |
y2 = SHEIGHT / 1.043; |
| 884 |
#endif |
| 885 |
auto &game_font{*GAME_FONT}; |
| 886 |
gr_string(canvas, game_font, x, y0, TXT_TURN_SHIP); |
| 887 |
gr_string(canvas, game_font, x, y1, s1); |
| 888 |
gr_string(canvas, game_font, x, y2, s2); |
| 889 |
} |
| 890 |
|
| 891 |
} |
| 892 |
auto &canvas{am.automap_view}; |
| 893 |
|
| 894 |
gr_clear_canvas(canvas, BM_XRGB(0,0,0)); |
| 895 |
|
| 896 |
g3_start_frame(canvas); |
| 897 |
render_start_frame(); |
| 898 |
|
| 899 |
if (!PlayerCfg.AutomapFreeFlight) |
| 900 |
am.view_position = vm_vec_scale_add(am.view_target, am.viewMatrix.fvec, -am.viewDist); |
| 901 |
|
| 902 |
g3_set_view_matrix(am.view_position,am.viewMatrix,am.zoom); |
| 903 |
|
| 904 |
draw_all_edges(am); |
| 905 |
|
| 906 |
// Draw player... |
| 907 |
const auto &self_ship_rgb{player_rgb[get_player_or_team_color(Netgame, Game_mode, Player_num)]}; |
| 908 |
const auto closest_color{BM_XRGB(self_ship_rgb.r, self_ship_rgb.g, self_ship_rgb.b)}; |
| 909 |
const g3_instance_context viewer_context{View_matrix, View_position}; |
| 910 |
draw_player(viewer_context, g3_draw_line_context{canvas, closest_color}, vcobjptr(get_local_player().objnum)); |
| 911 |
|
| 912 |
#if DXX_BUILD_DESCENT == 2 |
| 913 |
DrawMarkers(viewer_context, vcobjptr, canvas, am); |
| 914 |
#endif |
| 915 |
|
| 916 |
// Draw player(s)... |
| 917 |
#if DXX_USE_MULTIPLAYER |
| 918 |
const unsigned show_all_players{(Game_mode & GM_MULTI_COOP) || underlying_value(Netgame.game_flag & netgame_rule_flags::show_all_players_on_automap)}; |
| 919 |
if (show_all_players || (Game_mode & GM_TEAM)) |
| 920 |
{ |
| 921 |
const auto local_player_team{multi_get_team_from_player(Netgame, Player_num)}; |
| 922 |
const auto n_players{N_players}; |
| 923 |
for (const auto iu : xrange(n_players)) |
| 924 |
{ |
| 925 |
const auto i{static_cast<playernum_t>(iu)}; |
| 926 |
if (i == Player_num) |
| 927 |
continue; |
| 928 |
if (show_all_players || local_player_team == multi_get_team_from_player(Netgame, i)) |
| 929 |
{ |
| 930 |
auto &plr{*vcplayerptr(i)}; |
| 931 |
auto &objp{*vcobjptr(plr.objnum)}; |
| 932 |
if (objp.type == OBJ_PLAYER) |
| 933 |
{ |
| 934 |
const auto &other_ship_rgb{player_rgb[get_player_or_team_color(Netgame, Game_mode, i)]}; |
| 935 |
draw_player(viewer_context, g3_draw_line_context{canvas, BM_XRGB(other_ship_rgb.r, other_ship_rgb.g, other_ship_rgb.b)}, objp); |
| 936 |
} |
| 937 |
} |
| 938 |
} |
| 939 |
} |
| 940 |
#endif |
| 941 |
|
| 942 |
for (auto &obj : vcobjptr) |
| 943 |
{ |
| 944 |
switch(obj.type) |
| 945 |
{ |
| 946 |
case OBJ_HOSTAGE: |
| 947 |
g3_draw_sphere(canvas, /* sphere_point = */ g3_rotate_point(obj.pos), obj.size, am.hostage_color); |
| 948 |
break; |
| 949 |
case OBJ_POWERUP: |
| 950 |
if (LevelUniqueAutomapState.Automap_visited[obj.segnum] |
| 951 |
#ifndef NDEBUG |
| 952 |
|| Automap_debug_show_all_segments |
| 953 |
#endif |
| 954 |
) |
| 955 |
{ |
| 956 |
unsigned r, g, b; |
| 957 |
if (const auto id{get_powerup_id(obj)}; id == powerup_type_t::POW_KEY_RED) |
| 958 |
r = 63 * 2, g = 5 * 2, b = 5 * 2; |
| 959 |
else if (id == powerup_type_t::POW_KEY_BLUE) |
| 960 |
r = 5 * 2, g = 5 * 2, b = 63 * 2; |
| 961 |
else if (id == powerup_type_t::POW_KEY_GOLD) |
| 962 |
r = 63 * 2, g = 63 * 2, b = 10 * 2; |
| 963 |
else |
| 964 |
break; |
| 965 |
g3_draw_sphere(canvas, /* sphere_point = */ g3_rotate_point(obj.pos), obj.size * 4, /* color = */ gr_find_closest_color(r, g, b)); |
| 966 |
} |
| 967 |
break; |
| 968 |
default: |
| 969 |
break; |
| 970 |
} |
| 971 |
} |
| 972 |
|
| 973 |
g3_end_frame(); |
| 974 |
|
| 975 |
name_frame(canvas, am); |
| 976 |
|
| 977 |
#if DXX_BUILD_DESCENT == 2 |
| 978 |
{ |
| 979 |
const auto HighlightMarker{MarkerState.HighlightMarker}; |
| 980 |
if (MarkerState.message.valid_index(HighlightMarker)) |
| 981 |
{ |
| 982 |
auto &p{MarkerState.message[HighlightMarker][0u]}; |
| 983 |
gr_printf(canvas, *canvas.cv_font, (SWIDTH / 64), (SHEIGHT / 18), "Marker %u%c %s", static_cast<unsigned>(HighlightMarker) + 1, p ? ':' : 0, &p); |
| 984 |
} |
| 985 |
} |
| 986 |
#endif |
| 987 |
|
| 988 |
if (PlayerCfg.MouseFlightSim && PlayerCfg.MouseFSIndicator) |
| 989 |
{ |
| 990 |
const auto gwidth{canvas.cv_bitmap.bm_w}; |
| 991 |
const auto gheight{canvas.cv_bitmap.bm_h}; |
| 992 |
auto &raw_mouse_axis{am.controls.raw_mouse_axis}; |
| 993 |
show_mousefs_indicator(canvas, raw_mouse_axis[0], raw_mouse_axis[1], raw_mouse_axis[2], gwidth - (gheight / 8), gheight - (gheight / 8), gheight / 5); |
| 994 |
} |
| 995 |
|
| 996 |
am.t2 = timer_query(); |
| 997 |
const auto vsync{CGameCfg.VSync}; |
| 998 |
const auto bound{F1_0 / (vsync ? MAXIMUM_FPS : CGameArg.SysMaxFPS)}; |
| 999 |
const auto may_sleep{!CGameArg.SysNoNiceFPS && !vsync}; |
| 1000 |
const auto multiplayer{Game_mode & GM_MULTI}; |
| 1001 |
while (am.t2 - am.t1 < bound) // ogl is fast enough that the automap can read the input too fast and you start to turn really slow. So delay a bit (and free up some cpu :) |
| 1002 |
{ |
| 1003 |
if (multiplayer) |
| 1004 |
multi_do_frame(); // during long wait, keep packets flowing |
| 1005 |
if (may_sleep) |
| 1006 |
timer_delay(F1_0>>8); |
| 1007 |
am.t2 = timer_update(); |
| 1008 |
} |
| 1009 |
if (am.pause_game) |
| 1010 |
{ |
| 1011 |
FrameTime=am.t2-am.t1; |
| 1012 |
calc_d_tick(); |
| 1013 |
} |
| 1014 |
am.t1 = am.t2; |
| 1015 |
} |
| 1016 |
|
| 1017 |
#if DXX_BUILD_DESCENT == 1 |
| 1018 |
#define MAP_BACKGROUND_FILENAME (((SWIDTH>=640&&SHEIGHT>=480) && PHYSFS_exists("maph.pcx")) ? "maph.pcx" : "map.pcx") |
| 1019 |
#elif DXX_BUILD_DESCENT == 2 |
| 1020 |
#define MAP_BACKGROUND_FILENAME ((HIRESMODE && PHYSFS_exists("mapb.pcx")) ? "mapb.pcx" : "map.pcx") |
| 1021 |
#endif |
| 1022 |
|
| 1023 |
static void recompute_automap_segment_visibility(const d_level_unique_automap_state &LevelUniqueAutomapState, const object &plrobj, automap &am) |
| 1024 |
{ |
| 1025 |
recompute_automap_segment_visibility(LevelUniqueAutomapState, plrobj.ctype.player_info.powerup_flags & PLAYER_FLAGS_MAP_ALL, plrobj.segnum, am); |
| 1026 |
} |
| 1027 |
|
| 1028 |
static window_event_result automap_key_command(const d_event &event, automap &am) |
| 1029 |
{ |
| 1030 |
#if DXX_BUILD_DESCENT == 1 || !defined(NDEBUG) |
| 1031 |
auto &Objects{LevelUniqueObjectState.Objects}; |
| 1032 |
auto &vmobjptr{Objects.vmptr}; |
| 1033 |
#endif |
| 1034 |
int c{event_key_get(event)}; |
| 1035 |
|
| 1036 |
switch (c) |
| 1037 |
{ |
| 1038 |
#if DXX_USE_SCREENSHOT |
| 1039 |
case KEY_PRINT_SCREEN: { |
| 1040 |
gr_set_default_canvas(); |
| 1041 |
save_screen_shot(1); |
| 1042 |
return window_event_result::handled; |
| 1043 |
} |
| 1044 |
#endif |
| 1045 |
case KEY_ESC: |
| 1046 |
if (am.leave_mode == 0) |
| 1047 |
{ |
| 1048 |
return window_event_result::close; |
| 1049 |
} |
| 1050 |
return window_event_result::handled; |
| 1051 |
#if DXX_BUILD_DESCENT == 1 |
| 1052 |
case KEY_ALTED+KEY_F: // Alt+F shows full map, if cheats enabled |
| 1053 |
if (cheats.enabled) |
| 1054 |
{ |
| 1055 |
cheats.fullautomap = !cheats.fullautomap; |
| 1056 |
// if cheat of map powerup, work with full depth |
| 1057 |
auto &plrobj{get_local_plrobj()}; |
| 1058 |
recompute_automap_segment_visibility(LevelUniqueAutomapState, plrobj, am); |
| 1059 |
} |
| 1060 |
return window_event_result::handled; |
| 1061 |
#endif |
| 1062 |
#ifndef NDEBUG |
| 1063 |
case KEY_DEBUGGED+KEY_F: { |
| 1064 |
Automap_debug_show_all_segments = !Automap_debug_show_all_segments; |
| 1065 |
auto &plrobj{get_local_plrobj()}; |
| 1066 |
recompute_automap_segment_visibility(LevelUniqueAutomapState, plrobj, am); |
| 1067 |
} |
| 1068 |
return window_event_result::handled; |
| 1069 |
#endif |
| 1070 |
case KEY_F9: |
| 1071 |
if (am.segment_limit > 1) |
| 1072 |
{ |
| 1073 |
am.segment_limit--; |
| 1074 |
adjust_segment_limit(am, am.segment_limit); |
| 1075 |
} |
| 1076 |
return window_event_result::handled; |
| 1077 |
case KEY_F10: |
| 1078 |
if (am.segment_limit < am.max_segments_away) { |
| 1079 |
am.segment_limit++; |
| 1080 |
adjust_segment_limit(am, am.segment_limit); |
| 1081 |
} |
| 1082 |
return window_event_result::handled; |
| 1083 |
#if DXX_BUILD_DESCENT == 2 |
| 1084 |
case KEY_1: |
| 1085 |
case KEY_2: |
| 1086 |
case KEY_3: |
| 1087 |
case KEY_4: |
| 1088 |
case KEY_5: |
| 1089 |
case KEY_6: |
| 1090 |
case KEY_7: |
| 1091 |
case KEY_8: |
| 1092 |
case KEY_9: |
| 1093 |
case KEY_0: |
| 1094 |
{ |
| 1095 |
const auto game_mode{Game_mode}; |
| 1096 |
const auto max_numplayers{Netgame.max_numplayers}; |
| 1097 |
const auto maxdrop{MarkerState.get_markers_per_player(game_mode, max_numplayers)}; |
| 1098 |
const uint8_t marker_num = c - KEY_1; |
| 1099 |
if (marker_num <= maxdrop) |
| 1100 |
{ |
| 1101 |
const auto gmi{convert_player_marker_index_to_game_marker_index(game_mode, max_numplayers, Player_num, player_marker_index{marker_num})}; |
| 1102 |
if (MarkerState.imobjidx[gmi] != object_none) |
| 1103 |
MarkerState.HighlightMarker = gmi; |
| 1104 |
} |
| 1105 |
else |
| 1106 |
MarkerState.HighlightMarker = game_marker_index::None; |
| 1107 |
} |
| 1108 |
return window_event_result::handled; |
| 1109 |
case KEY_D+KEY_CTRLED: |
| 1110 |
{ |
| 1111 |
if (const auto &&[mo, HighlightMarker]{marker_delete_are_you_sure_menu::get_marker_object(MarkerState)}; mo == nullptr) |
| 1112 |
{ |
| 1113 |
(void)HighlightMarker; |
| 1114 |
/* If the selected index is not a valid marker, do |
| 1115 |
* not offer to delete anything. |
| 1116 |
*/ |
| 1117 |
return window_event_result::handled; |
| 1118 |
} |
| 1119 |
auto menu{window_create<marker_delete_are_you_sure_menu>(grd_curscreen->sc_canvas, LevelUniqueObjectState, Segments, MarkerState)}; |
| 1120 |
(void)menu; |
| 1121 |
} |
| 1122 |
return window_event_result::handled; |
| 1123 |
#ifndef RELEASE |
| 1124 |
case KEY_F11: //KEY_COMMA: |
| 1125 |
if (MarkerScale>.5) |
| 1126 |
MarkerScale-=.5; |
| 1127 |
return window_event_result::handled; |
| 1128 |
case KEY_F12: //KEY_PERIOD: |
| 1129 |
if (MarkerScale<30.0) |
| 1130 |
MarkerScale+=.5; |
| 1131 |
return window_event_result::handled; |
| 1132 |
#endif |
| 1133 |
#endif |
| 1134 |
} |
| 1135 |
return window_event_result::ignored; |
| 1136 |
} |
| 1137 |
|
| 1138 |
static window_event_result automap_process_input(const d_event &event, automap &am) |
| 1139 |
{ |
| 1140 |
kconfig_read_controls(am.controls, event, 1); |
| 1141 |
|
| 1142 |
if (!am.controls.state.automap && am.leave_mode == 1) |
| 1143 |
{ |
| 1144 |
return window_event_result::close; |
| 1145 |
} |
| 1146 |
if (am.controls.state.automap) |
| 1147 |
{ |
| 1148 |
am.controls.state.automap = 0; |
| 1149 |
if (am.leave_mode == 0) |
| 1150 |
{ |
| 1151 |
return window_event_result::close; |
| 1152 |
} |
| 1153 |
} |
| 1154 |
return window_event_result::ignored; |
| 1155 |
} |
| 1156 |
|
| 1157 |
} |
| 1158 |
|
| 1159 |
window_event_result automap::event_handler(const d_event &event) |
| 1160 |
{ |
| 1161 |
auto &Objects{LevelUniqueObjectState.Objects}; |
| 1162 |
auto &vcobjptr{Objects.vcptr}; |
| 1163 |
auto &vmobjptr{Objects.vmptr}; |
| 1164 |
switch (event.type) |
| 1165 |
{ |
| 1166 |
case event_type::window_activated: |
| 1167 |
game_flush_inputs(controls); |
| 1168 |
event_toggle_focus(1); |
| 1169 |
key_toggle_repeat(1); |
| 1170 |
break; |
| 1171 |
|
| 1172 |
case event_type::window_deactivated: |
| 1173 |
event_toggle_focus(0); |
| 1174 |
key_toggle_repeat(1); |
| 1175 |
break; |
| 1176 |
|
| 1177 |
#if SDL_MAJOR_VERSION == 2 |
| 1178 |
case event_type::window_resize: |
| 1179 |
init_automap_subcanvas(automap_view, grd_curscreen->sc_canvas); |
| 1180 |
break; |
| 1181 |
#endif |
| 1182 |
|
| 1183 |
case event_type::idle: |
| 1184 |
#if DXX_MAX_BUTTONS_PER_JOYSTICK |
| 1185 |
case event_type::joystick_button_up: |
| 1186 |
case event_type::joystick_button_down: |
| 1187 |
#endif |
| 1188 |
#if DXX_MAX_AXES_PER_JOYSTICK |
| 1189 |
case event_type::joystick_moved: |
| 1190 |
#endif |
| 1191 |
case event_type::mouse_button_up: |
| 1192 |
case event_type::mouse_button_down: |
| 1193 |
case event_type::mouse_moved: |
| 1194 |
case event_type::key_release: |
| 1195 |
return automap_process_input(event, *this); |
| 1196 |
case event_type::key_command: |
| 1197 |
{ |
| 1198 |
window_event_result kret{automap_key_command(event, *this)}; |
| 1199 |
if (kret == window_event_result::ignored) |
| 1200 |
kret = automap_process_input(event, *this); |
| 1201 |
return kret; |
| 1202 |
} |
| 1203 |
case event_type::window_draw: |
| 1204 |
{ |
| 1205 |
auto &plrobj{get_local_plrobj()}; |
| 1206 |
automap_apply_input(*this, plrobj.orient, plrobj.pos); |
| 1207 |
} |
| 1208 |
draw_automap(vcobjptr, *this); |
| 1209 |
break; |
| 1210 |
case event_type::window_close: |
| 1211 |
if (!pause_game) |
| 1212 |
ConsoleObject->mtype.phys_info.flags |= old_wiggle; // Restore wiggle |
| 1213 |
event_toggle_focus(0); |
| 1214 |
key_toggle_repeat(1); |
| 1215 |
/* grd_curcanv points to `automap_view`, so grd_curcanv |
| 1216 |
* would become a dangling pointer after the call to delete. |
| 1217 |
* Redirect it to the default screen to avoid pointing to |
| 1218 |
* freed memory. Setting grd_curcanv to nullptr would be |
| 1219 |
* better, but some code assumes that grd_curcanv is never |
| 1220 |
* nullptr, so instead set it to the default canvas. |
| 1221 |
* Eventually, grd_curcanv will be removed entirely. |
| 1222 |
*/ |
| 1223 |
gr_set_default_canvas(); |
| 1224 |
Game_wind->set_visible(1); |
| 1225 |
Automap_active = 0; |
| 1226 |
#if DXX_USE_MULTIPLAYER |
| 1227 |
if (Game_mode & GM_MULTI) |
| 1228 |
multi_send_msgsend_state(msgsend_state::none); |
| 1229 |
#endif |
| 1230 |
return window_event_result::ignored; // continue closing |
| 1231 |
|
| 1232 |
case event_type::loop_begin_loop: |
| 1233 |
kconfig_begin_loop(controls); |
| 1234 |
break; |
| 1235 |
case event_type::loop_end_loop: |
| 1236 |
kconfig_end_loop(controls, FrameTime); |
| 1237 |
break; |
| 1238 |
|
| 1239 |
default: |
| 1240 |
return window_event_result::ignored; |
| 1241 |
} |
| 1242 |
return window_event_result::handled; |
| 1243 |
} |
| 1244 |
|
| 1245 |
void do_automap() |
| 1246 |
{ |
| 1247 |
auto &Objects{LevelUniqueObjectState.Objects}; |
| 1248 |
auto &vmobjptr{Objects.vmptr}; |
| 1249 |
palette_array_t pal; |
| 1250 |
auto am{window_create<automap>(grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT)}; |
| 1251 |
const auto max_edges{LevelSharedSegmentState.Num_segments * 12}; |
| 1252 |
am->max_edges = max_edges; |
| 1253 |
am->edges = std::make_unique<Edge_info[]>(max_edges); |
| 1254 |
am->drawingListBright = std::make_unique<Edge_info *[]>(max_edges); |
| 1255 |
|
| 1256 |
init_automap_colors(*am); |
| 1257 |
am->pause_game = !((Game_mode & GM_MULTI) && (!Endlevel_sequence)); // Set to 1 if everything is paused during automap...No pause during net. |
| 1258 |
|
| 1259 |
if (am->pause_game) { |
| 1260 |
Game_wind->set_visible(0); |
| 1261 |
} |
| 1262 |
else |
| 1263 |
{ |
| 1264 |
am->old_wiggle = ConsoleObject->mtype.phys_info.flags & PF_WIGGLE; // Save old wiggle |
| 1265 |
ConsoleObject->mtype.phys_info.flags &= ~PF_WIGGLE; // Turn off wiggle |
| 1266 |
} |
| 1267 |
|
| 1268 |
//Max_edges = min(MAX_EDGES_FROM_VERTS(Num_vertices),MAX_EDGES); //make maybe smaller than max |
| 1269 |
|
| 1270 |
gr_set_default_canvas(); |
| 1271 |
|
| 1272 |
if ( am->viewDist==0 ) |
| 1273 |
am->viewDist = ZOOM_DEFAULT; |
| 1274 |
|
| 1275 |
auto &plrobj{get_local_plrobj()}; |
| 1276 |
am->viewMatrix = plrobj.orient; |
| 1277 |
am->tangles.p = PITCH_DEFAULT; |
| 1278 |
am->tangles.h = 0; |
| 1279 |
am->tangles.b = 0; |
| 1280 |
am->view_target = plrobj.pos; |
| 1281 |
|
| 1282 |
if (PlayerCfg.AutomapFreeFlight) |
| 1283 |
am->view_position = vm_vec_scale_add(plrobj.pos, am->viewMatrix.fvec, -ZOOM_DEFAULT); |
| 1284 |
|
| 1285 |
am->t1 = am->entry_time = timer_query(); |
| 1286 |
am->t2 = am->t1; |
| 1287 |
|
| 1288 |
//Fill in Automap_visited from Objects[Players[Player_num].objnum].segnum |
| 1289 |
recompute_automap_segment_visibility(LevelUniqueAutomapState, plrobj, *am); |
| 1290 |
|
| 1291 |
// ZICO - code from above to show frame in OGL correctly. Redundant, but better readable. |
| 1292 |
// KREATOR - Now applies to all platforms so double buffering is supported |
| 1293 |
{ |
| 1294 |
const auto pcx_error{pcx_read_bitmap_or_default(MAP_BACKGROUND_FILENAME, am->automap_background, pal)}; |
| 1295 |
if (pcx_error != pcx_result::SUCCESS) |
| 1296 |
con_printf(CON_URGENT, DXX_STRINGIZE_FL(__FILE__, __LINE__, "automap: File %s - PCX error: %s"), MAP_BACKGROUND_FILENAME, pcx_errormsg(pcx_error)); |
| 1297 |
gr_remap_bitmap_good(am->automap_background, pal, -1, -1); |
| 1298 |
} |
| 1299 |
init_automap_subcanvas(am->automap_view, grd_curscreen->sc_canvas); |
| 1300 |
|
| 1301 |
gr_palette_load( gr_palette ); |
| 1302 |
Automap_active = 1; |
| 1303 |
#if DXX_USE_MULTIPLAYER |
| 1304 |
if (Game_mode & GM_MULTI) |
| 1305 |
multi_send_msgsend_state(msgsend_state::automap); |
| 1306 |
#endif |
| 1307 |
} |
| 1308 |
|
| 1309 |
namespace { |
| 1310 |
|
| 1311 |
void draw_all_edges(automap &am) |
| 1312 |
{ |
| 1313 |
auto &canvas{am.automap_view}; |
| 1314 |
auto &LevelSharedVertexState{LevelSharedSegmentState.get_vertex_state()}; |
| 1315 |
auto &Vertices{LevelSharedVertexState.get_vertices()}; |
| 1316 |
unsigned nbright{0}; |
| 1317 |
fix min_distance{INT32_MAX}; |
| 1318 |
|
| 1319 |
auto &vcvertptr{Vertices.vcptr}; |
| 1320 |
range_for (auto &i, unchecked_partial_range(am.edges.get(), am.end_valid_edges)) |
| 1321 |
{ |
| 1322 |
const auto e{&i}; |
| 1323 |
if (!(e->flags & EF_USED)) continue; |
| 1324 |
|
| 1325 |
if ( e->flags & EF_TOO_FAR) continue; |
| 1326 |
|
| 1327 |
if (e->flags&EF_FRONTIER) { // A line that is between what we have seen and what we haven't |
| 1328 |
if ((!(e->flags & EF_SECRET)) && (e->color == am.wall_normal_color)) |
| 1329 |
continue; // If a line isn't secret and is normal color, then don't draw it |
| 1330 |
} |
| 1331 |
if (const fix distance{Segment_points[e->verts[1]].p3_vec.z}; min_distance > distance) |
| 1332 |
min_distance = distance; |
| 1333 |
|
| 1334 |
if (rotate_list(vcvertptr, e->verts).uand == clipping_code::None) |
| 1335 |
{ //all off screen? |
| 1336 |
uint8_t nfacing{}; |
| 1337 |
uint8_t nnfacing{}; |
| 1338 |
auto &tv1{*vcvertptr(e->verts[0])}; |
| 1339 |
int j{0}; |
| 1340 |
while( j<e->num_faces && (nfacing==0 || nnfacing==0) ) { |
| 1341 |
if (!g3_check_normal_facing(tv1, vcsegptr(e->segnum[j])->shared_segment::sides[e->sides[j]].normals[0])) |
| 1342 |
nfacing++; |
| 1343 |
else |
| 1344 |
nnfacing++; |
| 1345 |
j++; |
| 1346 |
} |
| 1347 |
|
| 1348 |
if ( nfacing && nnfacing ) { |
| 1349 |
// a contour line |
| 1350 |
am.drawingListBright[nbright++] = e; |
| 1351 |
} else if ( e->flags&(EF_DEFINING|EF_GRATE) ) { |
| 1352 |
if ( nfacing == 0 ) { |
| 1353 |
const uint8_t color = (e->flags & EF_NO_FADE) |
| 1354 |
? e->color |
| 1355 |
: gr_fade_table[(gr_fade_level{8})][e->color]; |
| 1356 |
g3_draw_line(g3_draw_line_context{canvas, color}, Segment_points[e->verts[0]], Segment_points[e->verts[1]]); |
| 1357 |
} else { |
| 1358 |
am.drawingListBright[nbright++] = e; |
| 1359 |
} |
| 1360 |
} |
| 1361 |
} |
| 1362 |
} |
| 1363 |
|
| 1364 |
if ( min_distance < 0 ) min_distance = 0; |
| 1365 |
|
| 1366 |
/* Sort the bright ones using a projection to extract the z coordinate of |
| 1367 |
* the rotated point. |
| 1368 |
*/ |
| 1369 |
const auto &&range{unchecked_partial_range(am.drawingListBright.get(), nbright)}; |
| 1370 |
std::ranges::sort(range, {}, [](const Edge_info *const a) { return Segment_points[a->verts[0]].p3_vec.z; }); |
| 1371 |
// Draw the bright ones |
| 1372 |
range_for (const auto e, range) |
| 1373 |
{ |
| 1374 |
const auto p1{&Segment_points[e->verts[0]]}; |
| 1375 |
const auto p2{&Segment_points[e->verts[1]]}; |
| 1376 |
fix dist{p1->p3_vec.z - min_distance}; |
| 1377 |
// Make distance be 1.0 to 0.0, where 0.0 is 10 segments away; |
| 1378 |
if ( dist < 0 ) dist=0; |
| 1379 |
if ( dist >= am.farthest_dist ) continue; |
| 1380 |
|
| 1381 |
const auto color{(e->flags & EF_NO_FADE) |
| 1382 |
? e->color |
| 1383 |
: gr_fade_table[static_cast<gr_fade_level>(f2i((F1_0 - fixdiv(dist, am.farthest_dist)) * 31))][e->color] |
| 1384 |
}; |
| 1385 |
g3_draw_line(g3_draw_line_context{canvas, color}, *p1, *p2); |
| 1386 |
} |
| 1387 |
} |
| 1388 |
|
| 1389 |
//================================================================== |
| 1390 |
// |
| 1391 |
// All routines below here are used to build the Edge list |
| 1392 |
// |
| 1393 |
//================================================================== |
| 1394 |
|
| 1395 |
//finds edge, filling in edge_ptr. if found old edge, returns index, else return -1 |
| 1396 |
static std::pair<Edge_info &, std::size_t> automap_find_edge(automap &am, const vertnum_t v0, const vertnum_t v1) |
| 1397 |
{ |
| 1398 |
const auto &&hash_object{std::hash<vertnum_t>{}}; |
| 1399 |
const auto initial_hash_slot{(hash_object(v0) ^ (hash_object(v1) << 10)) % am.max_edges}; |
| 1400 |
|
| 1401 |
for (auto current_hash_slot{initial_hash_slot};;) |
| 1402 |
{ |
| 1403 |
auto &e{am.edges[current_hash_slot]}; |
| 1404 |
const auto ev0{e.verts[0]}; |
| 1405 |
const auto ev1{e.verts[1]}; |
| 1406 |
if (e.num_faces == 0) |
| 1407 |
return {e, current_hash_slot}; |
| 1408 |
if (v1 == ev1 && v0 == ev0) |
| 1409 |
return {e, UINT32_MAX}; |
| 1410 |
else { |
| 1411 |
if (++ current_hash_slot == am.max_edges) |
| 1412 |
current_hash_slot = 0; |
| 1413 |
if (current_hash_slot == initial_hash_slot) |
| 1414 |
throw std::runtime_error("edge list full: search wrapped without finding a free slot"); |
| 1415 |
} |
| 1416 |
} |
| 1417 |
} |
| 1418 |
|
| 1419 |
static void add_one_edge(automap &am, vertnum_t va, vertnum_t vb, const uint8_t color, const sidenum_t side, const segnum_t segnum, const uint8_t flags) |
| 1420 |
{ |
| 1421 |
if (am.num_edges >= am.max_edges) |
| 1422 |
{ |
| 1423 |
// GET JOHN! (And tell him that his |
| 1424 |
// MAX_EDGES_FROM_VERTS formula is hosed.) |
| 1425 |
// If he's not around, save the mine, |
| 1426 |
// and send him mail so he can look |
| 1427 |
// at the mine later. Don't modify it. |
| 1428 |
// This is important if this happens. |
| 1429 |
Int3(); // LOOK ABOVE!!!!!! |
| 1430 |
return; |
| 1431 |
} |
| 1432 |
|
| 1433 |
if ( va > vb ) { |
| 1434 |
std::swap(va, vb); |
| 1435 |
} |
| 1436 |
const auto &&ef{automap_find_edge(am, va, vb)}; |
| 1437 |
const auto e{&ef.first}; |
| 1438 |
|
| 1439 |
if (ef.second != UINT32_MAX) |
| 1440 |
{ |
| 1441 |
e->verts[0] = va; |
| 1442 |
e->verts[1] = vb; |
| 1443 |
e->color = color; |
| 1444 |
e->num_faces = 1; |
| 1445 |
e->flags = EF_USED | EF_DEFINING; // Assume a normal line |
| 1446 |
e->sides[0] = side; |
| 1447 |
e->segnum[0] = segnum; |
| 1448 |
++ am.num_edges; |
| 1449 |
const auto i{ef.second + 1}; |
| 1450 |
if (am.end_valid_edges < i) |
| 1451 |
am.end_valid_edges = i; |
| 1452 |
} else { |
| 1453 |
if ( color != am.wall_normal_color ) |
| 1454 |
#if DXX_BUILD_DESCENT == 2 |
| 1455 |
if (color != am.wall_revealed_color) |
| 1456 |
#endif |
| 1457 |
e->color = color; |
| 1458 |
|
| 1459 |
if ( e->num_faces < 4 ) { |
| 1460 |
e->sides[e->num_faces] = side; |
| 1461 |
e->segnum[e->num_faces] = segnum; |
| 1462 |
e->num_faces++; |
| 1463 |
} |
| 1464 |
} |
| 1465 |
e->flags |= flags; |
| 1466 |
} |
| 1467 |
|
| 1468 |
static void add_one_unknown_edge(automap &am, vertnum_t va, vertnum_t vb) |
| 1469 |
{ |
| 1470 |
if ( va > vb ) { |
| 1471 |
std::swap(va, vb); |
| 1472 |
} |
| 1473 |
|
| 1474 |
const auto &&ef{automap_find_edge(am, va, vb)}; |
| 1475 |
if (ef.second == UINT32_MAX) |
| 1476 |
ef.first.flags |= EF_FRONTIER; // Mark as a border edge |
| 1477 |
} |
| 1478 |
|
| 1479 |
static void add_segment_edges(fvcsegptr &vcsegptr, fvcwallptr &vcwallptr, automap &am, const vcsegptridx_t seg) |
| 1480 |
{ |
| 1481 |
auto &ControlCenterState{LevelUniqueObjectState.ControlCenterState}; |
| 1482 |
auto &WallAnims{GameSharedState.WallAnims}; |
| 1483 |
#if DXX_BUILD_DESCENT == 2 |
| 1484 |
auto &Objects{LevelUniqueObjectState.Objects}; |
| 1485 |
auto &vmobjptr{Objects.vmptr}; |
| 1486 |
#endif |
| 1487 |
for (const auto sn : MAX_SIDES_PER_SEGMENT) |
| 1488 |
{ |
| 1489 |
uint8_t hidden_flag{0}; |
| 1490 |
uint8_t is_grate{0}; |
| 1491 |
uint8_t no_fade{0}; |
| 1492 |
|
| 1493 |
uint8_t color{255}; |
| 1494 |
if (seg->shared_segment::children[sn] == segment_none) { |
| 1495 |
color = am.wall_normal_color; |
| 1496 |
} |
| 1497 |
|
| 1498 |
switch( seg->special ) { |
| 1499 |
case segment_special::nothing: |
| 1500 |
case segment_special::goal_blue: |
| 1501 |
case segment_special::goal_red: |
| 1502 |
break; |
| 1503 |
case segment_special::repaircen: |
| 1504 |
color = BM_XRGB(0, 0, 26); |
| 1505 |
break; |
| 1506 |
case segment_special::fuelcen: |
| 1507 |
color = BM_XRGB( 29, 27, 13 ); |
| 1508 |
break; |
| 1509 |
case segment_special::controlcen: |
| 1510 |
if (ControlCenterState.Control_center_present) |
| 1511 |
color = BM_XRGB( 29, 0, 0 ); |
| 1512 |
break; |
| 1513 |
case segment_special::robotmaker: |
| 1514 |
color = BM_XRGB( 29, 0, 31 ); |
| 1515 |
break; |
| 1516 |
} |
| 1517 |
|
| 1518 |
const auto wall_num{seg->shared_segment::sides[sn].wall_num}; |
| 1519 |
if (wall_num != wall_none) |
| 1520 |
{ |
| 1521 |
auto &w{*vcwallptr(wall_num)}; |
| 1522 |
#if DXX_BUILD_DESCENT == 2 |
| 1523 |
auto trigger_num{w.trigger}; |
| 1524 |
auto &Triggers{LevelUniqueWallSubsystemState.Triggers}; |
| 1525 |
auto &vmtrgptr{Triggers.vmptr}; |
| 1526 |
if (trigger_num != trigger_none && vmtrgptr(trigger_num)->type == trigger_action::secret_exit) |
| 1527 |
{ |
| 1528 |
color = BM_XRGB( 29, 0, 31 ); |
| 1529 |
no_fade = EF_NO_FADE; |
| 1530 |
goto Here; |
| 1531 |
} |
| 1532 |
#endif |
| 1533 |
|
| 1534 |
switch(w.type) |
| 1535 |
{ |
| 1536 |
case WALL_DOOR: |
| 1537 |
if ((w.keys == wall_key::blue && (color = am.wall_door_blue, true)) || |
| 1538 |
(w.keys == wall_key::gold && (color = am.wall_door_gold, true)) || |
| 1539 |
(w.keys == wall_key::red && (color = am.wall_door_red, true))) |
| 1540 |
{ |
| 1541 |
no_fade = EF_NO_FADE; |
| 1542 |
} else if (!(WallAnims[w.clip_num].flags & WCF_HIDDEN)) { |
| 1543 |
const auto connected_seg{seg->shared_segment::children[sn]}; |
| 1544 |
if (connected_seg != segment_none) { |
| 1545 |
const shared_segment &vcseg{*vcsegptr(connected_seg)}; |
| 1546 |
const auto &connected_side{find_connect_side(seg, vcseg)}; |
| 1547 |
if (connected_side == side_none) |
| 1548 |
break; |
| 1549 |
auto &wall{*vcwallptr(vcseg.sides[connected_side].wall_num)}; |
| 1550 |
switch (wall.keys) |
| 1551 |
{ |
| 1552 |
case wall_key::blue: |
| 1553 |
color = am.wall_door_blue; |
| 1554 |
no_fade = EF_NO_FADE; |
| 1555 |
break; |
| 1556 |
case wall_key::gold: |
| 1557 |
color = am.wall_door_gold; |
| 1558 |
no_fade = EF_NO_FADE; |
| 1559 |
break; |
| 1560 |
case wall_key::red: |
| 1561 |
color = am.wall_door_red; |
| 1562 |
no_fade = EF_NO_FADE; |
| 1563 |
break; |
| 1564 |
default: |
| 1565 |
color = am.wall_door_color; |
| 1566 |
break; |
| 1567 |
} |
| 1568 |
} |
| 1569 |
} else { |
| 1570 |
color = am.wall_normal_color; |
| 1571 |
hidden_flag = EF_SECRET; |
| 1572 |
} |
| 1573 |
break; |
| 1574 |
case WALL_CLOSED: |
| 1575 |
// Make grates draw properly |
| 1576 |
// NOTE: In original D1, is_grate is 1, hidden_flag not used so grates never fade. I (zico) like this so I leave this alone for now. |
| 1577 |
if (!(is_grate = WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, seg, sn) & WALL_IS_DOORWAY_FLAG::rendpast)) |
| 1578 |
hidden_flag = EF_SECRET; |
| 1579 |
color = am.wall_normal_color; |
| 1580 |
break; |
| 1581 |
case WALL_BLASTABLE: |
| 1582 |
// Hostage doors |
| 1583 |
color = am.wall_door_color; |
| 1584 |
break; |
| 1585 |
} |
| 1586 |
} |
| 1587 |
|
| 1588 |
if (seg==Player_init[Player_num].segnum) |
| 1589 |
color = BM_XRGB(31,0,31); |
| 1590 |
|
| 1591 |
if ( color != 255 ) { |
| 1592 |
#if DXX_BUILD_DESCENT == 2 |
| 1593 |
// If they have a map powerup, draw unvisited areas in dark blue. |
| 1594 |
// NOTE: D1 originally had this part of code but w/o cheat-check. It's only supposed to draw blue with powerup that does not exist in D1. So make this D2-only |
| 1595 |
#ifndef NDEBUG |
| 1596 |
if (!Automap_debug_show_all_segments) |
| 1597 |
#endif |
| 1598 |
{ |
| 1599 |
auto &player_info{get_local_plrobj().ctype.player_info}; |
| 1600 |
if ((cheats.fullautomap || player_info.powerup_flags & PLAYER_FLAGS_MAP_ALL) && !LevelUniqueAutomapState.Automap_visited[seg]) |
| 1601 |
color = am.wall_revealed_color; |
| 1602 |
} |
| 1603 |
Here: |
| 1604 |
#endif |
| 1605 |
const auto vertex_list{get_side_verts(seg,sn)}; |
| 1606 |
const uint8_t flags = hidden_flag | no_fade; |
| 1607 |
add_one_edge(am, vertex_list[0], vertex_list[1], color, sn, seg, flags); |
| 1608 |
add_one_edge(am, vertex_list[1], vertex_list[2], color, sn, seg, flags); |
| 1609 |
add_one_edge(am, vertex_list[2], vertex_list[3], color, sn, seg, flags); |
| 1610 |
add_one_edge(am, vertex_list[3], vertex_list[0], color, sn, seg, flags); |
| 1611 |
|
| 1612 |
if ( is_grate ) { |
| 1613 |
const uint8_t grate_flags = flags | EF_GRATE; |
| 1614 |
add_one_edge(am, vertex_list[0], vertex_list[2], color, sn, seg, grate_flags); |
| 1615 |
add_one_edge(am, vertex_list[1], vertex_list[3], color, sn, seg, grate_flags); |
| 1616 |
} |
| 1617 |
} |
| 1618 |
} |
| 1619 |
} |
| 1620 |
|
| 1621 |
|
| 1622 |
// Adds all the edges from a segment we haven't visited yet. |
| 1623 |
|
| 1624 |
static void add_unknown_segment_edges(automap &am, const shared_segment &seg) |
| 1625 |
{ |
| 1626 |
for (const auto &&[sn, child] : enumerate(seg.children)) |
| 1627 |
{ |
| 1628 |
// Only add edges that have no children |
| 1629 |
if (child == segment_none) |
| 1630 |
{ |
| 1631 |
const auto vertex_list{get_side_verts(seg, static_cast<sidenum_t>(sn))}; |
| 1632 |
|
| 1633 |
add_one_unknown_edge( am, vertex_list[0], vertex_list[1] ); |
| 1634 |
add_one_unknown_edge( am, vertex_list[1], vertex_list[2] ); |
| 1635 |
add_one_unknown_edge( am, vertex_list[2], vertex_list[3] ); |
| 1636 |
add_one_unknown_edge( am, vertex_list[3], vertex_list[0] ); |
| 1637 |
} |
| 1638 |
} |
| 1639 |
} |
| 1640 |
|
| 1641 |
void automap_build_edge_list(automap &am, int add_all_edges) |
| 1642 |
{ |
| 1643 |
// clear edge list |
| 1644 |
for (auto &i : unchecked_partial_range(am.edges.get(), am.max_edges)) |
| 1645 |
{ |
| 1646 |
i.num_faces = 0; |
| 1647 |
i.flags = 0; |
| 1648 |
} |
| 1649 |
am.num_edges = 0; |
| 1650 |
am.end_valid_edges = 0; |
| 1651 |
|
| 1652 |
auto &Walls{LevelUniqueWallSubsystemState.Walls}; |
| 1653 |
auto &vcwallptr{Walls.vcptr}; |
| 1654 |
if (add_all_edges) { |
| 1655 |
// Cheating, add all edges as visited |
| 1656 |
range_for (const auto &&segp, vcsegptridx) |
| 1657 |
{ |
| 1658 |
#if DXX_USE_EDITOR |
| 1659 |
if (segp->shared_segment::segnum != segment_none) |
| 1660 |
#endif |
| 1661 |
{ |
| 1662 |
add_segment_edges(vcsegptr, vcwallptr, am, segp); |
| 1663 |
} |
| 1664 |
} |
| 1665 |
} else { |
| 1666 |
// Not cheating, add visited edges, and then unvisited edges |
| 1667 |
range_for (const auto &&segp, vcsegptridx) |
| 1668 |
{ |
| 1669 |
#if DXX_USE_EDITOR |
| 1670 |
if (segp->shared_segment::segnum != segment_none) |
| 1671 |
#endif |
| 1672 |
if (LevelUniqueAutomapState.Automap_visited[segp]) |
| 1673 |
{ |
| 1674 |
add_segment_edges(vcsegptr, vcwallptr, am, segp); |
| 1675 |
} |
| 1676 |
} |
| 1677 |
range_for (const auto &&segp, vcsegptridx) |
| 1678 |
{ |
| 1679 |
#if DXX_USE_EDITOR |
| 1680 |
if (segp->shared_segment::segnum != segment_none) |
| 1681 |
#endif |
| 1682 |
if (!LevelUniqueAutomapState.Automap_visited[segp]) |
| 1683 |
{ |
| 1684 |
add_unknown_segment_edges(am, segp); |
| 1685 |
} |
| 1686 |
} |
| 1687 |
} |
| 1688 |
|
| 1689 |
// Find unnecessary lines (These are lines that don't have to be drawn because they have small curvature) |
| 1690 |
for (auto &i : unchecked_partial_range(am.edges.get(), am.end_valid_edges)) |
| 1691 |
{ |
| 1692 |
const auto e{&i}; |
| 1693 |
if (!(e->flags&EF_USED)) continue; |
| 1694 |
|
| 1695 |
const auto num_faces{e->num_faces}; |
| 1696 |
if (num_faces < 2) |
| 1697 |
continue; |
| 1698 |
for (unsigned e1{0}; e1 < num_faces; ++e1) |
| 1699 |
{ |
| 1700 |
const auto e1segnum{e->segnum[e1]}; |
| 1701 |
const auto &e1siden0{vcsegptr(e1segnum)->shared_segment::sides[e->sides[e1]].normals[0]}; |
| 1702 |
for (unsigned e2{1}; e2 < num_faces; ++e2) |
| 1703 |
{ |
| 1704 |
if (e1 == e2) |
| 1705 |
continue; |
| 1706 |
const auto e2segnum{e->segnum[e2]}; |
| 1707 |
if (e1segnum == e2segnum) |
| 1708 |
continue; |
| 1709 |
if (vm_vec_build_dot(e1siden0, vcsegptr(e2segnum)->shared_segment::sides[e->sides[e2]].normals[0]) > (F1_0 - (F1_0 / 10))) |
| 1710 |
{ |
| 1711 |
e->flags &= (~EF_DEFINING); |
| 1712 |
break; |
| 1713 |
} |
| 1714 |
} |
| 1715 |
if (!(e->flags & EF_DEFINING)) |
| 1716 |
break; |
| 1717 |
} |
| 1718 |
} |
| 1719 |
} |
| 1720 |
|
| 1721 |
} |
| 1722 |
|
| 1723 |
#if DXX_BUILD_DESCENT == 2 |
| 1724 |
void InitMarkerInput () |
| 1725 |
{ |
| 1726 |
//find free marker slot |
| 1727 |
const auto game_mode{Game_mode}; |
| 1728 |
const auto max_numplayers{Netgame.max_numplayers}; |
| 1729 |
const auto maxdrop{MarkerState.get_markers_per_player(game_mode, max_numplayers)}; |
| 1730 |
const auto &&game_marker_range{get_game_marker_range(game_mode, max_numplayers, Player_num, maxdrop)}; |
| 1731 |
const auto &&player_marker_range{get_player_marker_range(maxdrop)}; |
| 1732 |
const auto &&zipped_marker_range{zip(player_marker_range, unchecked_partial_range(&MarkerState.imobjidx[*game_marker_range.begin()], maxdrop))}; |
| 1733 |
const auto &&mb{zipped_marker_range.begin()}; |
| 1734 |
const auto &&me{zipped_marker_range.end()}; |
| 1735 |
auto iter{mb}; |
| 1736 |
for (;;) |
| 1737 |
{ |
| 1738 |
auto &&[pmi, objidx]{*iter}; |
| 1739 |
if (objidx == object_none) //found free slot! |
| 1740 |
{ |
| 1741 |
MarkerState.MarkerBeingDefined = pmi; |
| 1742 |
break; |
| 1743 |
} |
| 1744 |
if (++ iter == me) //no free slot |
| 1745 |
{ |
| 1746 |
if (game_mode & GM_MULTI) |
| 1747 |
{ |
| 1748 |
//in multi, replace oldest |
| 1749 |
MarkerState.MarkerBeingDefined = static_cast<player_marker_index>((static_cast<unsigned>(MarkerState.LastMarkerDropped) + 1) & (maxdrop - 1)); |
| 1750 |
break; |
| 1751 |
} |
| 1752 |
else |
| 1753 |
{ |
| 1754 |
HUD_init_message_literal(HM_DEFAULT, "No free marker slots"); |
| 1755 |
return; |
| 1756 |
} |
| 1757 |
} |
| 1758 |
} |
| 1759 |
|
| 1760 |
//got a free slot. start inputting marker message |
| 1761 |
|
| 1762 |
Marker_input.front() = 0; |
| 1763 |
Marker_index=0; |
| 1764 |
key_toggle_repeat(1); |
| 1765 |
} |
| 1766 |
|
| 1767 |
window_event_result MarkerInputMessage(int key, control_info &Controls) |
| 1768 |
{ |
| 1769 |
auto &Objects{LevelUniqueObjectState.Objects}; |
| 1770 |
auto &vmobjptr{Objects.vmptr}; |
| 1771 |
auto &vmobjptridx{Objects.vmptridx}; |
| 1772 |
switch( key ) |
| 1773 |
{ |
| 1774 |
case KEY_LEFT: |
| 1775 |
case KEY_BACKSP: |
| 1776 |
case KEY_PAD4: |
| 1777 |
if (Marker_index > 0) |
| 1778 |
Marker_index--; |
| 1779 |
Marker_input[Marker_index] = 0; |
| 1780 |
break; |
| 1781 |
case KEY_ENTER: |
| 1782 |
{ |
| 1783 |
const auto player_marker_num{MarkerState.MarkerBeingDefined}; |
| 1784 |
MarkerState.LastMarkerDropped = player_marker_num; |
| 1785 |
const auto game_marker_num{convert_player_marker_index_to_game_marker_index(Game_mode, Netgame.max_numplayers, Player_num, player_marker_num)}; |
| 1786 |
MarkerState.message[game_marker_num] = Marker_input; |
| 1787 |
DropMarker(vmobjptridx, vmsegptridx, get_local_plrobj(), game_marker_num, player_marker_num); |
| 1788 |
} |
| 1789 |
[[fallthrough]]; |
| 1790 |
case KEY_F8: |
| 1791 |
case KEY_ESC: |
| 1792 |
MarkerState.MarkerBeingDefined = player_marker_index::None; |
| 1793 |
key_toggle_repeat(0); |
| 1794 |
game_flush_inputs(Controls); |
| 1795 |
break; |
| 1796 |
default: |
| 1797 |
{ |
| 1798 |
int ascii{key_ascii()}; |
| 1799 |
if ((ascii < 255 )) |
| 1800 |
if (Marker_index < Marker_input.size() - 1) |
| 1801 |
{ |
| 1802 |
Marker_input[Marker_index++] = ascii; |
| 1803 |
Marker_input[Marker_index] = 0; |
| 1804 |
} |
| 1805 |
return window_event_result::ignored; |
| 1806 |
} |
| 1807 |
} |
| 1808 |
return window_event_result::handled; |
| 1809 |
} |
| 1810 |
#endif |
| 1811 |
|
| 1812 |
} |