-
Notifications
You must be signed in to change notification settings - Fork 522
/
am_map.cpp
3408 lines (2952 loc) · 86 KB
/
am_map.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//-----------------------------------------------------------------------------
//
// Copyright 1993-1996 id Software
// Copyright 1994-1996 Raven Software
// Copyright 1999-2016 Randy Heit
// Copyright 2002-2016 Christoph Oelckers
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//-----------------------------------------------------------------------------
//
//
// DESCRIPTION: the automap code
//
//-----------------------------------------------------------------------------
#include <stdio.h>
#include <array>
#include "doomdef.h"
#include "templates.h"
#include "g_level.h"
#include "st_stuff.h"
#include "p_local.h"
#include "p_lnspec.h"
#include "filesystem.h"
#include "a_sharedglobal.h"
#include "d_event.h"
#include "gi.h"
#include "p_setup.h"
#include "c_bind.h"
#include "serializer_doom.h"
#include "r_sky.h"
#include "sbar.h"
#include "d_player.h"
#include "p_blockmap.h"
#include "g_game.h"
#include "v_video.h"
#include "d_main.h"
#include "v_draw.h"
#include "m_cheat.h"
#include "c_dispatch.h"
#include "d_netinf.h"
// State.
#include "r_state.h"
#include "r_utility.h"
// Data.
#include "gstrings.h"
#include "am_map.h"
#include "po_man.h"
#include "a_keys.h"
#include "g_levellocals.h"
#include "actorinlines.h"
#include "earcut.hpp"
#include "c_buttons.h"
#include "d_buttons.h"
#include "texturemanager.h"
//=============================================================================
//
// Global state
//
//=============================================================================
enum
{
AM_NUMMARKPOINTS = 10,
};
// C++ cannot do static const floats in a class, so these need to be global...
static const double PLAYERRADIUS = 16.; // player radius for automap checking
static const double M_ZOOMIN = 2; // how much zoom-in per second
static const double M_ZOOMOUT = 0.25; // how much zoom-out per second
static FTextureID marknums[AM_NUMMARKPOINTS]; // numbers used for marking by the automap
bool automapactive = false;
//=============================================================================
//
// Types
//
//=============================================================================
struct fpoint_t
{
int x, y;
};
struct fline_t
{
fpoint_t a, b;
};
struct mpoint_t
{
double x, y;
};
struct mline_t
{
mpoint_t a, b;
};
struct islope_t
{
double slp, islp;
};
//=============================================================================
//
// CVARs
//
//=============================================================================
CVAR(Bool, am_textured, false, CVAR_ARCHIVE)
CVAR(Bool, am_thingrenderstyles, true, CVAR_ARCHIVE)
CVAR(Int, am_showsubsector, -1, 0);
CUSTOM_CVAR(Int, am_showalllines, -1, CVAR_NOINITCALL) // This is a cheat so don't save it.
{
if (primaryLevel && primaryLevel->automap)
primaryLevel->automap->UpdateShowAllLines();
}
EXTERN_CVAR(Bool, sv_cheats)
CUSTOM_CVAR(Int, am_cheat, 0, 0)
{
// No automap cheat in net games when cheats are disabled!
if (netgame && !sv_cheats && self != 0)
{
self = 0;
}
}
CVAR(Int, am_rotate, 0, CVAR_ARCHIVE);
CVAR(Int, am_overlay, 0, CVAR_ARCHIVE);
CVAR(Bool, am_showsecrets, true, CVAR_ARCHIVE);
CVAR(Bool, am_showmonsters, true, CVAR_ARCHIVE);
CVAR(Bool, am_showitems, false, CVAR_ARCHIVE);
CVAR(Bool, am_showtime, true, CVAR_ARCHIVE);
CVAR(Bool, am_showtotaltime, false, CVAR_ARCHIVE);
CVAR(Int, am_colorset, 0, CVAR_ARCHIVE);
CVAR(Bool, am_customcolors, true, CVAR_ARCHIVE);
CVAR(Int, am_map_secrets, 1, CVAR_ARCHIVE);
CVAR(Int, am_drawmapback, 1, CVAR_ARCHIVE);
CVAR(Bool, am_showkeys, true, CVAR_ARCHIVE);
CVAR(Int, am_showtriggerlines, 0, CVAR_ARCHIVE);
CVAR(Int, am_showthingsprites, 0, CVAR_ARCHIVE);
CVAR (Bool, am_showkeys_always, false, CVAR_ARCHIVE);
CUSTOM_CVAR(Int, am_emptyspacemargin, 0, CVAR_ARCHIVE)
{
if (self < 0)
{
self = 0;
}
else if (self > 90)
{
self = 90;
}
if (nullptr != StatusBar && primaryLevel && primaryLevel->automap)
{
primaryLevel->automap->NewResolution();
}
}
//=============================================================================
//
// map functions
//
//=============================================================================
CVAR(Bool, am_followplayer, true, CVAR_ARCHIVE)
CVAR(Bool, am_portaloverlay, true, CVAR_ARCHIVE)
CVAR(Bool, am_showgrid, false, CVAR_ARCHIVE)
CVAR(Float, am_zoomdir, 0, CVAR_ARCHIVE)
static const char *const DEFAULT_FONT_NAME = "AMMNUMx";
CVAR(String, am_markfont, DEFAULT_FONT_NAME, CVAR_ARCHIVE)
CVAR(Int, am_markcolor, CR_GREY, CVAR_ARCHIVE)
CCMD(am_togglefollow)
{
am_followplayer = !am_followplayer;
if (primaryLevel && primaryLevel->automap)
primaryLevel->automap->ResetFollowLocation();
Printf("%s\n", GStrings(am_followplayer ? "AMSTR_FOLLOWON" : "AMSTR_FOLLOWOFF"));
}
CCMD(am_togglegrid)
{
am_showgrid = !am_showgrid;
Printf("%s\n", GStrings(am_showgrid ? "AMSTR_GRIDON" : "AMSTR_GRIDOFF"));
}
CCMD(am_toggletexture)
{
am_textured = !am_textured;
Printf("%s\n", GStrings(am_textured ? "AMSTR_TEXON" : "AMSTR_TEXOFF"));
}
CCMD(am_setmark)
{
if (primaryLevel && primaryLevel->automap)
{
int m = primaryLevel->automap->addMark();
if (m >= 0)
{
Printf("%s %d\n", GStrings("AMSTR_MARKEDSPOT"), m);
}
}
}
CCMD(am_clearmarks)
{
if (primaryLevel && primaryLevel->automap && primaryLevel->automap->clearMarks())
{
Printf("%s\n", GStrings("AMSTR_MARKSCLEARED"));
}
}
CCMD(am_gobig)
{
if (primaryLevel && primaryLevel->automap)
primaryLevel->automap->GoBig();
}
CCMD(togglemap)
{
if (gameaction == ga_nothing)
{
gameaction = ga_togglemap;
}
}
CCMD(am_zoom)
{
if (argv.argc() >= 2)
{
am_zoomdir = (float)atof(argv[1]);
}
}
//=============================================================================
//
// Automap colors
//
//=============================================================================
CVAR (Color, am_backcolor, 0x6c5440, CVAR_ARCHIVE);
CVAR (Color, am_yourcolor, 0xfce8d8, CVAR_ARCHIVE);
CVAR (Color, am_wallcolor, 0x2c1808, CVAR_ARCHIVE);
CVAR (Color, am_secretwallcolor, 0x000000, CVAR_ARCHIVE);
CVAR (Color, am_specialwallcolor, 0xffffff, CVAR_ARCHIVE);
CVAR (Color, am_tswallcolor, 0x888888, CVAR_ARCHIVE);
CVAR (Color, am_fdwallcolor, 0x887058, CVAR_ARCHIVE);
CVAR (Color, am_cdwallcolor, 0x4c3820, CVAR_ARCHIVE);
CVAR (Color, am_efwallcolor, 0x665555, CVAR_ARCHIVE);
CVAR (Color, am_thingcolor, 0xfcfcfc, CVAR_ARCHIVE);
CVAR (Color, am_gridcolor, 0x8b5a2b, CVAR_ARCHIVE);
CVAR (Color, am_xhaircolor, 0x808080, CVAR_ARCHIVE);
CVAR (Color, am_notseencolor, 0x6c6c6c, CVAR_ARCHIVE);
CVAR (Color, am_lockedcolor, 0x007800, CVAR_ARCHIVE);
CVAR (Color, am_intralevelcolor, 0x0000ff, CVAR_ARCHIVE);
CVAR (Color, am_interlevelcolor, 0xff0000, CVAR_ARCHIVE);
CVAR (Color, am_secretsectorcolor, 0xff00ff, CVAR_ARCHIVE);
CVAR (Color, am_unexploredsecretcolor, 0xff00ff, CVAR_ARCHIVE);
CVAR (Color, am_thingcolor_friend, 0xfcfcfc, CVAR_ARCHIVE);
CVAR (Color, am_thingcolor_monster, 0xfcfcfc, CVAR_ARCHIVE);
CVAR (Color, am_thingcolor_ncmonster, 0xfcfcfc, CVAR_ARCHIVE);
CVAR (Color, am_thingcolor_item, 0xfcfcfc, CVAR_ARCHIVE);
CVAR (Color, am_thingcolor_citem, 0xfcfcfc, CVAR_ARCHIVE);
CVAR (Color, am_portalcolor, 0x404040, CVAR_ARCHIVE);
CVAR (Color, am_ovyourcolor, 0xfce8d8, CVAR_ARCHIVE);
CVAR (Color, am_ovwallcolor, 0x00ff00, CVAR_ARCHIVE);
CVAR (Color, am_ovsecretwallcolor, 0x008844, CVAR_ARCHIVE);
CVAR (Color, am_ovspecialwallcolor, 0xffffff, CVAR_ARCHIVE);
CVAR (Color, am_ovotherwallscolor, 0x008844, CVAR_ARCHIVE);
CVAR (Color, am_ovlockedcolor, 0x008844, CVAR_ARCHIVE);
CVAR (Color, am_ovefwallcolor, 0x008844, CVAR_ARCHIVE);
CVAR (Color, am_ovfdwallcolor, 0x008844, CVAR_ARCHIVE);
CVAR (Color, am_ovcdwallcolor, 0x008844, CVAR_ARCHIVE);
CVAR (Color, am_ovunseencolor, 0x00226e, CVAR_ARCHIVE);
CVAR (Color, am_ovtelecolor, 0xffff00, CVAR_ARCHIVE);
CVAR (Color, am_ovinterlevelcolor, 0xffff00, CVAR_ARCHIVE);
CVAR (Color, am_ovsecretsectorcolor,0x00ffff, CVAR_ARCHIVE);
CVAR (Color, am_ovunexploredsecretcolor,0x00ffff, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor_friend, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor_monster, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor_ncmonster, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor_item, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor_citem, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovportalcolor, 0x004022, CVAR_ARCHIVE);
//=============================================================================
//
// internal representation of a single color
//
//=============================================================================
struct AMColor
{
uint32_t RGB;
void FromCVar(FColorCVar & cv)
{
RGB = uint32_t(cv) | MAKEARGB(255, 0, 0, 0);
}
void FromRGB(int r,int g, int b)
{
RGB = MAKEARGB(255, r, g, b);
}
void setInvalid()
{
RGB = 0;
}
bool isValid() const
{
return RGB != 0;
}
};
//=============================================================================
//
// a complete color set
//
//=============================================================================
static const char *ColorNames[] = {
"Background",
"YourColor",
"WallColor",
"TwoSidedWallColor",
"FloorDiffWallColor",
"CeilingDiffWallColor",
"ExtraFloorWallColor",
"ThingColor",
"ThingColor_Item",
"ThingColor_CountItem",
"ThingColor_Monster",
"ThingColor_NocountMonster",
"ThingColor_Friend",
"SpecialWallColor",
"SecretWallColor",
"GridColor",
"XHairColor",
"NotSeenColor",
"LockedColor",
"IntraTeleportColor",
"InterTeleportColor",
"SecretSectorColor",
"UnexploredSecretColor",
"PortalColor",
"AlmostBackgroundColor",
nullptr
};
struct AMColorset
{
enum
{
Background,
YourColor,
WallColor,
TSWallColor,
FDWallColor,
CDWallColor,
EFWallColor,
ThingColor,
ThingColor_Item,
ThingColor_CountItem,
ThingColor_Monster,
ThingColor_NocountMonster,
ThingColor_Friend,
SpecialWallColor,
SecretWallColor,
GridColor,
XHairColor,
NotSeenColor,
LockedColor,
IntraTeleportColor,
InterTeleportColor,
SecretSectorColor,
UnexploredSecretColor,
PortalColor,
AlmostBackgroundColor,
AM_NUM_COLORS
};
AMColor c[AM_NUM_COLORS];
bool displayLocks;
bool forcebackground;
bool defined; // only for mod specific colorsets: must be true to be usable
void initFromCVars(FColorCVar **values)
{
for(int i=0;i<AlmostBackgroundColor; i++)
{
c[i].FromCVar(*values[i]);
}
uint32_t ba = *(values[0]);
int r = RPART(ba) - 16;
int g = GPART(ba) - 16;
int b = BPART(ba) - 16;
if (r < 0)
r += 32;
if (g < 0)
g += 32;
if (b < 0)
b += 32;
c[AlmostBackgroundColor].FromRGB(r, g, b);
displayLocks = true;
forcebackground = false;
}
void initFromColors(const unsigned char *colors, bool showlocks)
{
for(int i=0, j=0; i<AM_NUM_COLORS; i++, j+=3)
{
if (colors[j] == 1 && colors[j+1] == 0 && colors[j+2] == 0)
{
c[i].setInvalid();
}
else
{
c[i].FromRGB(colors[j], colors[j+1], colors[j+2]);
}
}
displayLocks = showlocks;
forcebackground = false;
}
void setWhite()
{
c[0].FromRGB(0,0,0);
for(int i=1; i<AM_NUM_COLORS; i++)
{
c[i].FromRGB(255,255,255);
}
}
const AMColor &operator[](int index) const
{
return c[index];
}
bool isValid(int index) const
{
return c[index].isValid();
}
};
//=============================================================================
//
// automap colors forced by linedef
//
//=============================================================================
static const int AUTOMAP_LINE_COLORS[AMLS_COUNT] =
{
-1, // AMLS_Default (unused)
AMColorset::WallColor, // AMLS_OneSided,
AMColorset::TSWallColor, // AMLS_TwoSided
AMColorset::FDWallColor, // AMLS_FloorDiff
AMColorset::CDWallColor, // AMLS_CeilingDiff
AMColorset::EFWallColor, // AMLS_ExtraFloor
AMColorset::SpecialWallColor, // AMLS_Special
AMColorset::SecretWallColor, // AMLS_Secret
AMColorset::NotSeenColor, // AMLS_NotSeen
AMColorset::LockedColor, // AMLS_Locked
AMColorset::IntraTeleportColor, // AMLS_IntraTeleport
AMColorset::InterTeleportColor, // AMLS_InterTeleport
AMColorset::UnexploredSecretColor, // AMLS_UnexploredSecret
AMColorset::PortalColor, // AMLS_Portal
};
//=============================================================================
//
// predefined colorsets
//
//=============================================================================
static FColorCVar *cv_standard[] = {
&am_backcolor,
&am_yourcolor,
&am_wallcolor,
&am_tswallcolor,
&am_fdwallcolor,
&am_cdwallcolor,
&am_efwallcolor,
&am_thingcolor,
&am_thingcolor_item,
&am_thingcolor_citem,
&am_thingcolor_monster,
&am_thingcolor_ncmonster,
&am_thingcolor_friend,
&am_specialwallcolor,
&am_secretwallcolor,
&am_gridcolor,
&am_xhaircolor,
&am_notseencolor,
&am_lockedcolor,
&am_intralevelcolor,
&am_interlevelcolor,
&am_secretsectorcolor,
&am_unexploredsecretcolor,
&am_portalcolor
};
static FColorCVar *cv_overlay[] = {
&am_backcolor, // this will not be used in overlay mode
&am_ovyourcolor,
&am_ovwallcolor,
&am_ovotherwallscolor,
&am_ovfdwallcolor,
&am_ovcdwallcolor,
&am_ovefwallcolor,
&am_ovthingcolor,
&am_ovthingcolor_item,
&am_ovthingcolor_citem,
&am_ovthingcolor_monster,
&am_ovthingcolor_ncmonster,
&am_ovthingcolor_friend,
&am_ovspecialwallcolor,
&am_ovsecretwallcolor,
&am_gridcolor, // this will not be used in overlay mode
&am_xhaircolor, // this will not be used in overlay mode
&am_ovunseencolor,
&am_ovlockedcolor,
&am_ovtelecolor,
&am_ovinterlevelcolor,
&am_ovsecretsectorcolor,
&am_ovunexploredsecretcolor,
&am_ovportalcolor
};
CCMD(am_restorecolors)
{
for (unsigned i = 0; i < countof(cv_standard); i++)
{
cv_standard[i]->ResetToDefault();
}
for (unsigned i = 0; i < countof(cv_overlay); i++)
{
cv_overlay[i]->ResetToDefault();
}
}
#define NOT_USED 1,0,0 // use almost black as indicator for an unused color
static unsigned char DoomColors[]= {
0x00,0x00,0x00, // background
0xff,0xff,0xff, // yourcolor
0xfc,0x00,0x00, // wallcolor
0x80,0x80,0x80, // tswallcolor
0xbc,0x78,0x48, // fdwallcolor
0xfc,0xfc,0x00, // cdwallcolor
0xbc,0x78,0x48, // efwallcolor
0x74,0xfc,0x6c, // thingcolor
0x74,0xfc,0x6c, // thingcolor_item
0x74,0xfc,0x6c, // thingcolor_citem
0x74,0xfc,0x6c, // thingcolor_monster
0x74,0xfc,0x6c, // thingcolor_ncmonster
0x74,0xfc,0x6c, // thingcolor_friend
NOT_USED, // specialwallcolor
NOT_USED, // secretwallcolor
0x4c,0x4c,0x4c, // gridcolor
0x80,0x80,0x80, // xhaircolor
0x6c,0x6c,0x6c, // notseencolor
0xfc,0xfc,0x00, // lockedcolor
NOT_USED, // intrateleport
NOT_USED, // interteleport
NOT_USED, // secretsector
NOT_USED, // unexploredsecretsector
0x10,0x10,0x10, // almostbackground
0x40,0x40,0x40 // portal
};
static unsigned char StrifeColors[]= {
0x00,0x00,0x00, // background
239, 239, 0, // yourcolor
199, 195, 195, // wallcolor
119, 115, 115, // tswallcolor
55, 59, 91, // fdwallcolor
119, 115, 115, // cdwallcolor
55, 59, 91, // efwallcolor
187, 59, 0, // thingcolor
219, 171, 0, // thingcolor_item
219, 171, 0, // thingcolor_citem
0xfc,0x00,0x00, // thingcolor_monster
0xfc,0x00,0x00, // thingcolor_ncmonster
0xfc,0x00,0x00, // thingcolor_friend
NOT_USED, // specialwallcolor
NOT_USED, // secretwallcolor
0x4c,0x4c,0x4c, // gridcolor
0x80,0x80,0x80, // xhaircolor
0x6c,0x6c,0x6c, // notseencolor
119, 115, 115, // lockedcolor
NOT_USED, // intrateleport
NOT_USED, // interteleport
NOT_USED, // secretsector
NOT_USED, // unexploredsecretsector
0x10,0x10,0x10, // almostbackground
0x40,0x40,0x40 // portal
};
static unsigned char RavenColors[]= {
0x6c,0x54,0x40, // background
0xff,0xff,0xff, // yourcolor
75, 50, 16, // wallcolor
88, 93, 86, // tswallcolor
208, 176, 133, // fdwallcolor
103, 59, 31, // cdwallcolor
208, 176, 133, // efwallcolor
236, 236, 236, // thingcolor
236, 236, 236, // thingcolor_item
236, 236, 236, // thingcolor_citem
236, 236, 236, // thingcolor_monster
236, 236, 236, // thingcolor_ncmonster
236, 236, 236, // thingcolor_friend
NOT_USED, // specialwallcolor
NOT_USED, // secretwallcolor
75, 50, 16, // gridcolor
0x00,0x00,0x00, // xhaircolor
0x00,0x00,0x00, // notseencolor
103, 59, 31, // lockedcolor
NOT_USED, // intrateleport
NOT_USED, // interteleport
NOT_USED, // secretsector
NOT_USED, // unexploredsecretsector
0x10,0x10,0x10, // almostbackground
0x50,0x50,0x50 // portal
};
#undef NOT_USED
static AMColorset AMColors;
static AMColorset AMMod;
static AMColorset AMModOverlay;
void AM_ClearColorsets()
{
AMModOverlay.defined = false;
AMMod.defined = false;
}
//=============================================================================
//
//
//
//=============================================================================
static void AM_initColors(bool overlayed)
{
if (overlayed)
{
if (am_customcolors && AMModOverlay.defined)
{
AMColors = AMModOverlay;
}
else
{
AMColors.initFromCVars(cv_overlay);
}
}
else if (am_customcolors && AMMod.defined)
{
AMColors = AMMod;
}
else switch (am_colorset)
{
default:
/* Use the custom colors in the am_* cvars */
AMColors.initFromCVars(cv_standard);
break;
case 1: // Doom
// Use colors corresponding to the original Doom's
AMColors.initFromColors(DoomColors, false);
break;
case 2: // Strife
// Use colors corresponding to the original Strife's
AMColors.initFromColors(StrifeColors, false);
break;
case 3: // Raven
// Use colors corresponding to the original Raven's
AMColors.initFromColors(RavenColors, true);
break;
}
}
//=============================================================================
//
// custom color parser
//
//=============================================================================
void FMapInfoParser::ParseAMColors(bool overlay)
{
bool colorset = false;
AMColorset &cset = overlay? AMModOverlay : AMMod;
cset.setWhite();
cset.defined = true;
sc.MustGetToken('{');
while(sc.GetToken())
{
if (sc.TokenType == '}') return;
sc.TokenMustBe(TK_Identifier);
FString nextKey = sc.String;
sc.MustGetToken('=');
if (nextKey.CompareNoCase("base") == 0)
{
if (colorset) sc.ScriptError("'base' must be specified before the first color");
sc.MustGetToken(TK_StringConst);
if (sc.Compare("doom"))
{
cset.initFromColors(DoomColors, false);
}
else if (sc.Compare("raven"))
{
cset.initFromColors(RavenColors, true);
}
else if (sc.Compare("strife"))
{
cset.initFromColors(StrifeColors, false);
}
else
{
sc.ScriptError("Unknown value for 'base'. Must be 'Doom', 'Strife' or 'Raven'.");
}
}
else if (nextKey.CompareNoCase("showlocks") == 0)
{
if(sc.CheckToken(TK_False))
cset.displayLocks = false;
else
{
sc.MustGetToken(TK_True);
cset.displayLocks = true;
}
}
else
{
int i;
for (i = 0; ColorNames[i] != nullptr; i++)
{
if (nextKey.CompareNoCase(ColorNames[i]) == 0)
{
sc.MustGetToken(TK_StringConst);
FString color = sc.String;
FString colorName = V_GetColorStringByName(color);
if(!colorName.IsEmpty()) color = colorName;
int colorval = V_GetColorFromString(nullptr, color);
cset.c[i].FromRGB(RPART(colorval), GPART(colorval), BPART(colorval));
colorset = true;
break;
}
}
if (ColorNames[i]== nullptr)
{
sc.ScriptError("Unknown key '%s'", nextKey.GetChars());
}
}
}
}
//=============================================================================
//
// The vector graphics for the automap.
// A line drawing of the player pointing right,
// starting from the middle.
//
//=============================================================================
static TArray<mline_t> MapArrow;
static TArray<mline_t> CheatMapArrow;
static TArray<mline_t> CheatKey;
static TArray<mline_t> EasyKey;
static std::array<mline_t, 3> thintriangle_guy = { {
{{-.5,-.7}, {1,0}},
{{1,0}, {-.5,.7}},
{{-.5,.7}, {-.5,-.7}}
} };
//=============================================================================
//
// vector graphics
//
//=============================================================================
static void AM_ParseArrow(TArray<mline_t> &Arrow, const char *lumpname)
{
const int R = int((8 * PLAYERRADIUS) / 7);
FScanner sc;
int lump = fileSystem.CheckNumForFullName(lumpname, true);
if (lump >= 0)
{
sc.OpenLumpNum(lump);
sc.SetCMode(true);
while (sc.GetToken())
{
mline_t line;
sc.TokenMustBe('(');
sc.MustGetFloat();
line.a.x = sc.Float*R;
sc.MustGetToken(',');
sc.MustGetFloat();
line.a.y = sc.Float*R;
sc.MustGetToken(')');
sc.MustGetToken(',');
sc.MustGetToken('(');
sc.MustGetFloat();
line.b.x = sc.Float*R;
sc.MustGetToken(',');
sc.MustGetFloat();
line.b.y = sc.Float*R;
sc.MustGetToken(')');
Arrow.Push(line);
}
}
}
void AM_StaticInit()
{
MapArrow.Clear();
CheatMapArrow.Clear();
CheatKey.Clear();
EasyKey.Clear();
if (gameinfo.mMapArrow.IsNotEmpty()) AM_ParseArrow(MapArrow, gameinfo.mMapArrow);
if (gameinfo.mCheatMapArrow.IsNotEmpty()) AM_ParseArrow(CheatMapArrow, gameinfo.mCheatMapArrow);
AM_ParseArrow(CheatKey, gameinfo.mCheatKey);
AM_ParseArrow(EasyKey, gameinfo.mEasyKey);
if (MapArrow.Size() == 0) I_FatalError("No automap arrow defined");
char namebuf[9];
for (int i = 0; i < AM_NUMMARKPOINTS; i++)
{
mysnprintf(namebuf, countof(namebuf), "AMMNUM%d", i);
marknums[i] = TexMan.CheckForTexture(namebuf, ETextureType::MiscPatch);
}
}
//=============================================================================
//
// the actual automap class definition
//
//=============================================================================
IMPLEMENT_CLASS(DAutomapBase, true, false);
class DAutomap :public DAutomapBase
{
DECLARE_CLASS(DAutomap, DAutomapBase)
enum
{
F_PANINC = 140 / TICRATE, // how much the automap moves window per tic in frame-buffer coordinates moves 140 pixels at 320x200 in 1 second
};
//FLevelLocals *Level;
// scale on entry
// used by MTOF to scale from map-to-frame-buffer coords
double scale_mtof = .2;
// used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof)
double scale_ftom;
int bigstate;
int MapPortalGroup;
// Disable the ML_DONTDRAW line flag if x% of all lines in a map are flagged with it
// (To counter annoying mappers who think they are smart by making the automap unusable)
bool am_showallenabled;
// location of window on screen
int f_x;
int f_y;
// size of window on screen
int f_w;
int f_h;
int amclock;
mpoint_t m_paninc; // how far the window pans each tic (map coords)
double mtof_zoommul; // how far the window zooms in each tic (map coords)
double m_x, m_y; // LL x,y where the window is on the map (map coords)
double m_x2, m_y2; // UR x,y where the window is on the map (map coords)
//
// width/height of window on map (map coords)
//
double m_w;
double m_h;
// based on level size
double min_x, min_y, max_x, max_y;
double max_w; // max_x-min_x,
double max_h; // max_y-min_y
// based on player size
double min_w;
double min_h;
double min_scale_mtof; // used to tell when to stop zooming out
double max_scale_mtof; // used to tell when to stop zooming in
// old stuff for recovery later
double old_m_w, old_m_h;
double old_m_x, old_m_y;
// old location used by the Follower routine
mpoint_t f_oldloc;
mpoint_t markpoints[AM_NUMMARKPOINTS]; // where the points are
int markpointnum = 0; // next point to be assigned
FTextureID mapback; // the automap background
double mapystart = 0; // y-value for the start of the map bitmap...used in the parallax stuff.
double mapxstart = 0; //x-value for the bitmap.
TArray<FVector2> points;
// translates between frame-buffer and map distances
double FTOM(double x)
{
return x * scale_ftom;
}
double MTOF(double x)
{
return x * scale_mtof;
}
// translates between frame-buffer and map coordinates
int CXMTOF(double x)
{
return int(MTOF((x)-m_x)/* - f_x*/);
}
int CYMTOF(double y)
{
return int(f_h - MTOF((y)-m_y)/* + f_y*/);
}
void calcMinMaxMtoF();
void DrawMarker(FGameTexture *tex, double x, double y, int yadjust,
INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle);
void rotatePoint(double *x, double *y);
void rotate(double *x, double *y, DAngle an);
void doFollowPlayer();
void saveScaleAndLoc();
void restoreScaleAndLoc();