Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
887 lines (783 loc) · 61 KB
/
Copy pathMakefile
File metadata and controls
887 lines (783 loc) · 61 KB
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
# Modified by Mickael DE LA ROQUE on 2026-09-08 to build and test the
# unofficial custom-map stream-stall workaround.
TARGET = BO3MacFix.dylib
TEST_TARGETS = tests/test_stream_stall_recovery tests/test_display_policy tests/test_sdl_displays tests/test_prepatch \
tests/test_settings_ini tests/test_notice_queue tests/test_controllers tests/test_gc_bridge tests/test_frame_limit \
tests/test_players_cfg tests/test_aae_build tests/test_notch tests/test_notch_hooks tests/test_checkpoint \
tests/test_zm_inventory tests/test_zm_loadout tests/test_checkpoint_autosave tests/test_checkpoint_autosave_tsan \
tests/test_aae_cheats tests/test_script_errors tests/test_quick_save tests/test_dynres tests/test_gpu_diag \
tests/test_t7o_subtitle
TEST_TARGETS += tests/test_launch_args
# IdleDisplaySleep's decisions (display_sleep.c)
TEST_TARGETS += tests/test_display_sleep
# BatterySaver's levels against the user's settings (battery_saver.c)
TEST_TARGETS += tests/test_battery_saver
# VoiceMicrophone: the voice system's start of recording refused or left alone (voice_mic.c)
TEST_TARGETS += tests/test_voice_mic
# StartWithMod: which mods are remembered and when, the launcher's decisions, the marker of a start given the mod, its
# notices, and the game's half against a made-up loaded mod (start_mod.c, start_mod_game.c)
TEST_TARGETS += tests/test_start_mod
TEST_TARGETS += tests/test_frame_pace
# AAEEngineDefaults: its rule and the game's half against made-up dvars (aae_engine_defaults.c)
TEST_TARGETS += tests/test_aae_engine_defaults
# the plugin's packets and rules for joining a game on the local network, its listener over the loopback (aae_lan.c)
TEST_TARGETS += tests/test_aae_lan
# compiled scripts and All-around Enhancement 4's patch scripts (gsc_obj.c)
TEST_TARGETS += tests/test_gsc_obj
# loading them and redirecting calls, against a made-up game (gsc_detours.c)
TEST_TARGETS += tests/test_gsc_detours
# the script variable table's free list and the bigger table for the server (script_vars.c)
TEST_TARGETS += tests/test_script_vars
# glyphs drawn twice as detailed into the font atlas (font_resolution.c)
TEST_TARGETS += tests/test_font_resolution
# the UI's Lua heap growing past its 60 MB (lua_heap.c)
TEST_TARGETS += tests/test_lua_heap
# OfflineMode: which addresses and names are local, the automatic test, the replacements of the network calls
# (offline_mode.c)
TEST_TARGETS += tests/test_offline_mode
# releases of Lua reference 0 (lua_unref.c)
TEST_TARGETS += tests/test_lua_unref
# the lobby's Lua files kept as copies, and freed with the VM (mod_unload_fix.c)
TEST_TARGETS += tests/test_mod_unload_fix
# the second address space for loaded files (pmem_spill.c)
TEST_TARGETS += tests/test_pmem_spill
# All-around Enhancement's rules for traversal (aae_mantle.c)
TEST_TARGETS += tests/test_aae_mantle
# the plugin's rules for a host who leaves, and the handlers of its detour and hooks (aae_hostmig.c)
TEST_TARGETS += tests/test_aae_hostmig
# T7Overcharged's fastjump: its rules, its table of times in the air, its handlers (aae_move_fastjump.c), and again with
# the thread sanitizer, since the server's and the client's movement use that table at once
TEST_TARGETS += tests/test_aae_move_fastjump tests/test_aae_move_fastjump_tsan
# T7Overcharged's movement switches: its commands, its start and its dvars (aae_movement.c)
TEST_TARGETS += tests/test_aae_movement tests/test_aae_movement_x86_64
# startweaponanim's weapAnim value (weapon_anim.h)
TEST_TARGETS += tests/test_weapon_anim
# T7Overcharged's slide changes, their places and its own slide push compared with T7Overcharged (aae_move_slide.c)
TEST_TARGETS += tests/test_aae_move_slide tests/test_aae_move_slide_x86
# T7Overcharged's anim_event: its tests of the entity and what it asks of the game, against a made-up game
# (t7o_anim_event.c)
TEST_TARGETS += tests/test_t7o_anim_event
# the thunks for detours inside the game's functions (detour.h); x86_64 code, so this test is built for x86_64
TEST_TARGETS += tests/test_detour
# All-around Enhancement's prompts in the world (aae_prompt.c) and the test for its plugin (aae_plugin.c)
TEST_TARGETS += tests/test_aae_prompt
# T7Overcharged's changes to sprinting: its rules, and the handlers against a made-up game (aae_move_sprint.c)
TEST_TARGETS += tests/test_aae_move_sprint
# when the mod's free aim is on, and the crosshair test's hook (aae_freeaim.c)
TEST_TARGETS += tests/test_aae_freeaim
# the left-hand gestures' entities at the camera, against a made-up game (aae_linkcam.c)
TEST_TARGETS += tests/test_aae_linkcam
# free aim for players on other machines: what is sent, what the server keeps (aae_freeaim_net.c)
TEST_TARGETS += tests/test_aae_freeaim_net
# T7Overcharged's jumpslowdown: its rules, hooks and detours against a made-up game (aae_move_jump.c)
TEST_TARGETS += tests/test_aae_move_jump
# T7Overcharged's bigger table of client effects: its rules, and the six hooks against a made-up cache (aae_clientfx.c)
TEST_TARGETS += tests/test_aae_clientfx
# T7Overcharged's weapon attachment and local client guards (t7o_guards.c)
TEST_TARGETS += tests/test_t7o_guards
# T7Overcharged's FixUIErrorOnRestart: which UI errors are kept off the screen, and the stack they leave (t7o_uierror.c)
TEST_TARGETS += tests/test_t7o_uierror
# the pause for everybody in a co-op game: the plugin's packets and rules, machines playing together (aae_coop_pause.c)
TEST_TARGETS += tests/test_aae_coop_pause
# FrameStats' detail: the threads' line and the phases' line, and the process's own threads read by name
TEST_TARGETS += tests/test_thread_stats tests/test_thread_stats_x86_64
# T7Overcharged's aim status where the game draws its hold breath hint (aae_breath.c)
TEST_TARGETS += tests/test_aae_breath
# T7Overcharged's moves of the first person gun's bones: the texts, the rules and the hook (aae_viewmodel.c)
TEST_TARGETS += tests/test_aae_viewmodel
# a client field nobody registered: which places get a script error or a field that reads as 0 (clientfield_guard.c)
TEST_TARGETS += tests/test_clientfield_guard
# a lobby start of a map that can't be had: refused before the menus are shut down (missing_map_guard.c)
TEST_TARGETS += tests/test_missing_map_guard
# texture views the game replaces while they may be drawn: which places hand them to the game's delayed release, and
# the hook against a made-up untrack, delayed release and render thread (texture_swap_guard.c)
TEST_TARGETS += tests/test_texture_swap_guard
# the Direct3D layer's Release and ReleaseInternal deciding with one atomic exchange: against the game's own code one
# thread at a time, and two threads releasing together, here and (x86_64) under Rosetta (asl_refcount.c)
TEST_TARGETS += tests/test_asl_refcount tests/test_asl_refcount_x86_64
# the workshop preview pictures and the cache of the last few, against a made-up device, game and files
# (workshop_preview.c)
TEST_TARGETS += tests/test_workshop_preview
# a surface whose material isn't in the renderer's sorted table yet is left out of the frame (material_sort_guard.c)
TEST_TARGETS += tests/test_material_sort_guard
# the grenade's prediction line: T7Overcharged's test, the plugin's sums and the hooks (aae_arc.c)
TEST_TARGETS += tests/test_aae_arc
# the mod's widgets on the first person weapon: the plugin's tables, sums and methods (aae_vmwidget.c)
TEST_TARGETS += tests/test_aae_vmwidget
# two writers of one of its bones at once, under the thread sanitizer (aae_vmwidget.c)
TEST_TARGETS += tests/test_aae_vmwidget_tsan
# the one hook on DObjCalcSkel for both pieces that work after the view model's skeleton (aae_skeleton.c)
TEST_TARGETS += tests/test_aae_skeleton
# T7Overcharged's smaller pieces: customkeymap (t7o_small.c)
TEST_TARGETS += tests/test_t7o_small
# KeepCrashLogs: macOS's crash report read with every read checked, on real reports, every cut of them and random
# bytes (crash_report.c); the logs kept, the start's and the time lines, the report looked for (crash_log.c)
TEST_TARGETS += tests/test_crash_report tests/test_crash_log
# the navmesh converter's map names and arguments, against a made-up wine (navmesh_convert.c)
TEST_TARGETS += tests/test_navmesh_convert
# utilities.c's file and text helpers: Mac binaries told from others without keeping files open, hex, file names
TEST_TARGETS += tests/test_utilities
# AudioFollowsDefault's moves of the game's audio queues, against CoreAudio stand-ins that wait as CoreAudio does (qol.c)
TEST_TARGETS += tests/test_qol_audio
DEBUG ?= 0
ARCH ?= x86_64
SDK ?= macosx
OSXVER ?= 10.13
SYSROOT := $(shell xcrun --sdk $(SDK) --show-sdk-path)
ifeq ($(SYSROOT),)
$(error Could not find SDK "$(SDK)")
endif
CLANG := clang
CC := $(CLANG) -isysroot $(SYSROOT) -arch $(ARCH) -mmacosx-version-min=$(OSXVER)
CFLAGS = -O1 -Wall -g -I include/ -I src/ -fvisibility=hidden
LDFLAGS = -shared -Wl,-undefined -Wl,dynamic_lookup -Llib -ldobby -lz
FRAMEWORKS = -framework CoreFoundation -framework IOKit -framework CoreGraphics -framework ImageIO
SOURCES = source/bo3macfix.c source/bo3macnative.m source/stream_stall_recovery.c source/utilities.c source/steam.c source/exports.c source/havok.c source/t7overcharged.c source/cpu_tuning.c
# repeated script errors in console_mp.log (script_errors.c)
SOURCES += source/script_errors.c
# T7Overcharged's anim_event, AAE's inspect on the player's body in third person (t7o_anim_event.c)
SOURCES += source/t7o_anim_event.c
SOURCES += source/controllers.c source/gpu_tweaks.c
# which players folder a .cfg comes from, for mods that save them from Lua (players_cfg.c)
SOURCES += source/players_cfg.c
# which frame rate limit applies to a frame, and the pause menu's and the menus' state for PauseMenuFPS and MenuFPS
# (frame_limit.c), and whether the game is in the background for BackgroundFPS (app_focus.m)
SOURCES += source/frame_limit.c source/app_focus.m
# IdleDisplaySleep: when the game's display sleep assertion goes (display_sleep.c, plain C) and the glue that finds it,
# lets it go and declares a controller's input as activity (display_sleep_mac.c)
SOURCES += source/display_sleep.c source/display_sleep_mac.c
# BatterySaver: the battery settings at a level's values on battery (battery_saver.c, plain C)
SOURCES += source/battery_saver.c
# VoiceMicrophone: the voice system's start of recording refused, so Steam keeps the microphone closed (voice_mic.c)
SOURCES += source/voice_mic.c
# how many refreshes each frame stayed on screen, for FrameStats with BO3MACFIX_FRAMEPACESTATS=1 (frame_pace.c)
SOURCES += source/frame_pace.c
# DynamicResolution's controller (dynres.c), plain C like frame_limit.c
SOURCES += source/dynres.c
# PlayStation controllers through macOS's GameController framework (gc_bridge.m), weak-linked because it needs macOS 11.3
SOURCES += source/gc_bridge.m
FRAMEWORKS += -framework Foundation -weak_framework GameController -weak_framework CoreHaptics
# MetalFX upscaling (metalfx.m), MetalFX is weak-linked because it needs macOS 13
SOURCES += source/metalfx.m source/gpu_diag.m
# AAEEngineDefaults: the gun's shadow resolution at the game's own values while All-around Enhancement raises it
# (aae_engine_defaults.c)
SOURCES += source/aae_engine_defaults.c
# FrameStats' detail: the threads' CPU time by name and the frame's phases (thread_stats.c, thread_stats_game.c)
SOURCES += source/thread_stats.c source/thread_stats_game.c
# running the navmesh converter for a custom map without a shell (navmesh_convert.c)
SOURCES += source/navmesh_convert.c
# the pre-patched executable (prepatch.c), the launcher builds it with BO3MacFix_BuildPrepatched
SOURCES += source/prepatch.c
# whether the command line starts a map at launch, for SkipIntro (launch_args.c)
SOURCES += source/launch_args.c
# StartWithMod: the loaded mod noted for the launcher, which starts the game with it next time (start_mod.c, which the
# launcher builds too, and start_mod_game.c)
SOURCES += source/start_mod.c source/start_mod_game.c
# the build All-around Enhancement checks for, read from its fastfile (aae_build.c)
SOURCES += source/aae_build.c
# a map started with AAE keeping cheats off, so its bank and weapon locker load (aae_cheats.c)
SOURCES += source/aae_cheats.c
# All-around Enhancement 4's patch scripts: the compiled script format (gsc_obj.c) and loading them (gsc_detours.c)
SOURCES += source/gsc_obj.c source/gsc_detours.c
# the server's script variables: counting them and a higher limit (script_vars.c)
SOURCES += source/script_vars.c
# SharpFonts: menu and HUD text from glyphs twice as detailed (font_resolution.c)
SOURCES += source/font_resolution.c
# LuaHeapGrowth: more memory for the UI's Lua VM when its 60 MB are full (lua_heap.c)
SOURCES += source/lua_heap.c
# LuaUnrefFix: releasing Lua reference 0 does nothing (lua_unref.c)
SOURCES += source/lua_unref.c
# ModUnloadFix: the lobby's Lua runs from copies of its files, so a mod unloaded in the game can't take them away
# (mod_unload_fix.c)
SOURCES += source/mod_unload_fix.c
# MoreMapMemory: 2 GB more address space for loaded files (pmem_spill.c)
SOURCES += source/pmem_spill.c
# AAEMantling: mantling by the rules All-around Enhancement 4 gives its Windows plugin (aae_mantle.c)
SOURCES += source/aae_mantle.c
# AAEHostMigration: a host who leaves hands the game on instead of ending it, as the plugin makes it (aae_hostmig.c)
SOURCES += source/aae_hostmig.c
# AAEMovement: T7Overcharged's movement changes that the mod switches on; the switches (aae_movement.c)
SOURCES += source/aae_movement.c
# its patch fastjump: the next jump at once, more air control, the speed kept through a landing (aae_move_fastjump.c)
SOURCES += source/aae_move_fastjump.c
# its jumpslowdown: no penalty for jumping again and again (aae_move_jump.c)
SOURCES += source/aae_move_jump.c
# its changes to sprinting (aae_move_sprint.c)
SOURCES += source/aae_move_sprint.c
# whether the mod with that plugin is the one loaded (aae_plugin.c)
SOURCES += source/aae_plugin.c
# AAEPrompts: the mod's prompts in the world, kept by distance as the plugin makes the game keep them (aae_prompt.c)
SOURCES += source/aae_prompt.c
# AAEMovement: T7Overcharged's slide changes (aae_move_slide.c)
SOURCES += source/aae_move_slide.c
# AAEFreeAim: a crosshair in the mod's third person view, and shots that go to what is under it (aae_freeaim.c);
# what a player on another machine sends the server for that (aae_freeaim_net.c)
SOURCES += source/aae_freeaim.c source/aae_freeaim_net.c
# MoreClientEffects: T7Overcharged's table of 2048 client effects instead of the game's 1024 (aae_clientfx.c)
SOURCES += source/aae_clientfx.c
# AAEGestures: the mod's left-hand gestures put at the camera, as its plugin does (aae_linkcam.c)
SOURCES += source/aae_linkcam.c
# AAECoopPause: the pause for everybody in a co-op game, as the mod's plugin does it (aae_coop_pause.c)
SOURCES += source/aae_coop_pause.c
# AAEHoldBreath: the aim status the mod's T7Overcharged works out where the game draws its hold breath hint
# (aae_breath.c)
SOURCES += source/aae_breath.c
# AAEGunPosition: the mod's moves of the first person gun's bones, as its T7Overcharged makes them (aae_viewmodel.c)
SOURCES += source/aae_viewmodel.c
# AAEGrenadeArc: the line that shows where a held grenade will fly (aae_arc.c)
SOURCES += source/aae_arc.c
# AAEViewmodelWidgets: the two UI element methods the plugin adds for widgets on the first person weapon
# (aae_vmwidget.c)
SOURCES += source/aae_vmwidget.c
# the hook both of them do their work after the view model's skeleton through (aae_skeleton.c)
SOURCES += source/aae_skeleton.c
# the arguments of T7Overcharged's printsubtitle command, which prints AAE's game messages (t7overcharged.c)
SOURCES += source/t7o_subtitle.c
# T7OCrashGuards: two of T7Overcharged's guards against crashes of the game itself (t7o_guards.c)
SOURCES += source/t7o_guards.c
# FixUIErrorOnRestart: a UI model subscriber's errors counted instead of shown, as T7Overcharged does (t7o_uierror.c)
SOURCES += source/t7o_uierror.c
# ClientFieldGuard: a script error instead of a crash for a client field nobody registered (clientfield_guard.c)
SOURCES += source/clientfield_guard.c
# MissingMapGuard: a lobby start the game's preload would refuse is refused before the teardown (missing_map_guard.c)
SOURCES += source/missing_map_guard.c
# TextureSwapGuard: views the game replaces while they may be drawn die a few frames later (texture_swap_guard.c)
SOURCES += source/texture_swap_guard.c
# AtomicRelease: an object of the Direct3D layer released by two threads at once is destroyed once (asl_refcount.c)
SOURCES += source/asl_refcount.c
# the workshop preview pictures' loader and PreviewCache (workshop_preview.c)
SOURCES += source/workshop_preview.c
# MaterialSortGuard: a surface whose material isn't sorted in yet is left out, not a crash (material_sort_guard.c)
SOURCES += source/material_sort_guard.c
# AAELanJoin: joining a game of the mod on the local network as its plugin makes it work (aae_lan.c)
SOURCES += source/aae_lan.c
# T7Overcharged's smaller pieces: customkeymap, SendMenuResponse's debounce, the dvars it changes (t7o_small.c)
SOURCES += source/t7o_small.c
# saving a zombies game and resuming it through AAE's starting options (checkpoint.c, checkpoint.lua), and giving its
# weapons back with their camo, attachments and ammo types, and its perks (zm_inventory.c, zm_loadout.c)
SOURCES += source/checkpoint.c source/zm_inventory.c source/zm_loadout.c
# saving it by itself at each new round, on a background queue, and deleting the save (checkpoint_autosave.c)
SOURCES += source/checkpoint_autosave.c
# settings.ini's options for an in-game menu, the settings.ini writer and restarting (settings.c), with the
# settings.ini reading and writing (settings_ini.c)
SOURCES += source/settings.c source/settings_ini.c
# the in-game settings page that uses it (settings_menu.c)
SOURCES += source/settings_menu.c
# quitting without a crash and audio following the default output device (qol.c)
SOURCES += source/qol.c source/rawmouse.c
# OfflineMode: the game's process without the internet, always or when it doesn't answer at launch (offline_mode.c)
SOURCES += source/offline_mode.c
FRAMEWORKS += -framework AudioToolbox -framework CoreAudio
FRAMEWORKS += -framework Metal -framework QuartzCore -framework AppKit -weak_framework MetalFX
# following display changes (display_follow.m, display_policy.c), with SDL's display list (sdl_displays.c and its
# AppKit half sdl_displays_cocoa.m) and the engine's video code (engine_display.c) doing the moving, and the display
# tests' hooks (display_testhooks.m)
SOURCES += source/display_follow.m source/display_policy.c source/sdl_displays.c source/sdl_displays_cocoa.m
SOURCES += source/engine_display.c source/display_testhooks.m
# keeping the picture below the built-in display's camera housing in fullscreen (notch.m, AvoidNotch), with its
# geometry in notch_layout.c
SOURCES += source/notch.m source/notch_layout.c
# on-screen notices in the game (notices.m with the queue in notice_queue.c, drawn by notices.lua) and pausing when the
# controller disconnects
SOURCES += source/notices.m source/notice_queue.c
# a key, or L3 + R3 in the pause menu, saving a solo zombies game like the settings page's Save game (quick_save.m, with
# its rules in quick_save_rules.c; checkpoint.lua does the saving)
SOURCES += source/quick_save.m source/quick_save_rules.c
# ColorSync for display UUIDs, CoreVideo for the refresh rate of SDL's display modes
FRAMEWORKS += -framework ColorSync -framework CoreVideo
# KeepCrashLogs: the log of a run that didn't end by quitting kept, with macOS's crash report summarised into it, and
# the time, menus and maps in every log (crash_log.c, crash_log.lua, crash_report.c)
SOURCES += source/crash_log.c source/crash_report.c
# what names this build in the log's first lines (KeepCrashLogs): the commit it was built from, "+" when tracked files
# differ from it (source/build_name.h, below)
BUILD_NAME := $(shell git rev-parse --short HEAD 2>/dev/null)$(shell git status --porcelain --untracked-files=no \
2>/dev/null | grep -q . && echo +)
all: $(TARGET)
test: $(TEST_TARGETS)
for test in $(TEST_TARGETS); do ./$$test || exit 1; done
@# every setting can be overridden at env (BO3MACFIX_<NAME>)
sh tests/test_env_overrides.sh
@# StartWithMod in the launcher: what it puts on the game's command line, through its dry run
sh tests/test_launcher_startmod.sh
@# each setting's default agrees in the code, its settings page row (settings.c) and README.md
python3 tests/test_settings_defaults.py
python3 tests/test_hook_returns.py
@# notices.lua against a made-up LUI, with any Lua 5.x
if command -v lua >/dev/null; then lua tests/test_notices.lua; else echo "no lua, skipping tests/test_notices.lua"; fi
@# the T7Overcharged stand-in's watch for missing Engine and CoD functions (BO3MACFIX_LUAMISSING)
if command -v lua >/dev/null; then lua tests/test_t7overcharged.lua; else echo "no lua, skipping tests/test_t7overcharged.lua"; fi
@# checkpoint.lua (saving and resuming a zombies game) against a made-up Engine and AAE
if command -v lua >/dev/null; then lua tests/test_checkpoint.lua; else echo "no lua, skipping tests/test_checkpoint.lua"; fi
@# ResumeKeepsBank: a resumed game's points above the mod's 500, handed over after the first points earned
if command -v lua >/dev/null; then lua tests/test_resume_bank.lua; else echo "no lua, skipping tests/test_resume_bank.lua"; fi
@# AutoSave's round trigger and the Delete saved game row in checkpoint.lua
if command -v lua >/dev/null; then lua tests/test_autosave.lua; else echo "no lua, skipping tests/test_autosave.lua"; fi
@# the quick save (a key, or L3 + R3 in the pause menu) and the saved game's details on the settings page
if command -v lua >/dev/null; then lua tests/test_quick_save.lua; else echo "no lua, skipping tests/test_quick_save.lua"; fi
@# KeepCrashLogs' menu lines: the engine's RegisterOpenedMenu and UnregisterOpenedMenu wrapped, against a made-up UI
if command -v lua >/dev/null; then lua tests/test_crash_log.lua; else echo "no lua, skipping tests/test_crash_log.lua"; fi
tests/test_weapon_anim: tests/test_weapon_anim.c source/weapon_anim.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -o $@ tests/test_weapon_anim.c
tests/test_stream_stall_recovery: tests/test_stream_stall_recovery.c source/stream_stall_recovery.c source/stream_stall_recovery.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -o $@ tests/test_stream_stall_recovery.c source/stream_stall_recovery.c
# aae_build.c against made-up Lua constants, fastfiles and caches, and the installed All-around Enhancement's
# core_mod.ff if there is one, with the address and undefined behaviour sanitizers since it parses files
tests/test_aae_build: tests/test_aae_build.c source/aae_build.c source/aae_build.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_aae_build.c \
source/aae_build.c -lz
# gsc_obj.c against made-up scripts and patch scripts, and the installed All-around Enhancement's core_mod.ff if
# there is one, with the address and undefined behaviour sanitizers since it parses files
tests/test_gsc_obj: tests/test_gsc_obj.c tests/fake_gsc.h source/gsc_obj.c source/gsc_obj.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_gsc_obj.c \
source/gsc_obj.c -lz
# gsc_detours.c against a made-up game: script assets, the table of loaded scripts, a loader and linker, mapname
tests/test_gsc_detours: tests/test_gsc_detours.c tests/fake_gsc.h source/gsc_detours.c source/gsc_detours.h \
source/gsc_obj.c source/gsc_obj.h source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_gsc_detours.c \
source/gsc_obj.c
# script_vars.c against a made-up game that sets up, takes from and returns to the variable table as the game does
tests/test_script_vars: tests/test_script_vars.c source/script_vars.c source/script_vars.h source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_script_vars.c
# font_resolution.c against a made-up game: an atlas, its allocator, a FreeType and a glyph function
tests/test_font_resolution: tests/test_font_resolution.c source/font_resolution.c source/font_resolution.h \
source/gsc_obj.c source/gsc_obj.h source/offsets.h source/dobby.h source/prepatch.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_font_resolution.c \
source/gsc_obj.c
# lua_heap.c against a made-up heap that asks its callbacks as the game's dlmalloc does
tests/test_lua_heap: tests/test_lua_heap.c source/lua_heap.c source/lua_heap.h source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_lua_heap.c
# lua_unref.c: which releases reach the game's luaL_unref
tests/test_lua_unref: tests/test_lua_unref.c source/lua_unref.c source/lua_unref.h source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_lua_unref.c
# mod_unload_fix.c: the copies kept and freed, and the two hooks against a made-up game
tests/test_mod_unload_fix: tests/test_mod_unload_fix.c source/mod_unload_fix.c source/mod_unload_fix.h \
source/havok.h source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_mod_unload_fix.c
# pmem_spill.c against a made-up PMem: stacks, address spaces and the game's own allocation
tests/test_pmem_spill: tests/test_pmem_spill.c source/pmem_spill.c source/pmem_spill.h source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_pmem_spill.c
# aae_mantle.c: the mod's traversal rules, and its hooks against a made-up scan, dvars and per-mode dvar. Undefined
# behaviour stops the test: a division by zero is a crash in the game (x86_64) and nothing at all on an Apple CPU
tests/test_aae_mantle: tests/test_aae_mantle.c source/aae_mantle.c source/aae_mantle.h source/aae_plugin.c \
source/aae_plugin.h source/gsc_obj.c source/gsc_obj.h source/offsets.h source/dobby.h source/prepatch.h \
source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_mantle.c source/gsc_obj.c
# detour.h: its thunks against two made-up game functions in assembly
tests/test_detour: tests/test_detour.c source/detour.h
$(CLANG) -arch x86_64 -std=gnu11 -O1 -g -Wall -Wextra -Werror -o $@ tests/test_detour.c
# T7Overcharged's slide changes against a made-up game, with the cases its own slide push was compared on
# (tests/slide_cases.h)
tests/test_aae_move_slide: tests/test_aae_move_slide.c tests/slide_cases.h source/aae_move_slide.c \
source/aae_move_slide.h source/aae_movement.h source/detour.h source/offsets.h source/dobby.h source/prepatch.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_move_slide.c
# and for x86_64, the game's own code, where the cases are compared with every NaN's bits
tests/test_aae_move_slide_x86: tests/test_aae_move_slide.c tests/slide_cases.h source/aae_move_slide.c \
source/aae_move_slide.h source/aae_movement.h source/detour.h source/offsets.h source/dobby.h source/prepatch.h
$(CLANG) -arch x86_64 -std=gnu11 -O1 -g -Wall -Wextra -Werror -o $@ tests/test_aae_move_slide.c
# aae_hostmig.c: the plugin's rules and the detour's and hooks' handlers against a made-up game
tests/test_aae_hostmig: tests/test_aae_hostmig.c source/aae_hostmig.c source/aae_hostmig.h source/aae_plugin.c \
source/aae_plugin.h source/detour.h source/offsets.h source/dobby.h source/prepatch.h source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_hostmig.c
# aae_move_fastjump.c: T7Overcharged's rules and its table of times in the air, the hooks and detours against a
# made-up game, and the same cases as T7Overcharged's own code under Wine (tests/fastjump_cases.h)
FASTJUMP_TEST_FILES = tests/test_aae_move_fastjump.c tests/fastjump_cases.h source/aae_move_fastjump.c \
source/aae_move_fastjump.h source/aae_movement.h source/detour.h source/offsets.h source/dobby.h source/prepatch.h
tests/test_aae_move_fastjump: $(FASTJUMP_TEST_FILES)
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_move_fastjump.c
tests/test_aae_move_fastjump_tsan: $(FASTJUMP_TEST_FILES)
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=thread -o $@ tests/test_aae_move_fastjump.c
# aae_movement.c: T7Overcharged's movement switches against a made-up game (the test includes the source)
tests/test_aae_movement: tests/test_aae_movement.c source/aae_movement.c source/aae_movement.h source/aae_plugin.h \
source/gsc_obj.c source/gsc_obj.h source/offsets.h source/detour.h source/dobby.h source/prepatch.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_movement.c source/gsc_obj.c
# the same built for x86_64, the game's own: that build has the detours' thunks, and runs the perk test's setup
# (Rosetta on an Apple CPU, so without the sanitizers, like test_detour)
tests/test_aae_movement_x86_64: tests/test_aae_movement.c source/aae_movement.c source/aae_movement.h \
source/aae_plugin.h source/gsc_obj.c source/gsc_obj.h source/offsets.h source/detour.h source/dobby.h \
source/prepatch.h
$(CLANG) -arch x86_64 -std=gnu11 -O1 -g -Wall -Wextra -Werror -o $@ tests/test_aae_movement.c source/gsc_obj.c
# aae_prompt.c and aae_plugin.c: the handlers against a made-up prompt element and made-up models
tests/test_aae_prompt: tests/test_aae_prompt.c tests/prompt_glide_frames.h source/aae_prompt.c source/aae_prompt.h \
source/aae_plugin.c source/aae_plugin.h source/detour.h source/offsets.h source/dobby.h source/prepatch.h \
source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_prompt.c
# aae_freeaim.c: the plugin's rule for free aim being on, and the crosshair test's hook against a made-up game
tests/test_aae_freeaim: tests/test_aae_freeaim.c tests/freeaim_cases.h tests/freeaim_endpos_cases.h tests/freeaim_endpos_side.h source/aae_freeaim.c source/aae_freeaim.h \
source/aae_plugin.c source/aae_freeaim_net.c source/aae_freeaim_net.h \
source/aae_plugin.h source/detour.h source/gsc_obj.c source/gsc_obj.h source/offsets.h source/dobby.h \
source/prepatch.h source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_freeaim.c source/gsc_obj.c source/aae_freeaim_net.c
# aae_breath.c: T7Overcharged's aim status and the hint's hook against a made-up game
tests/test_aae_breath: tests/test_aae_breath.c source/aae_breath.c source/aae_breath.h source/aae_plugin.c \
source/aae_plugin.h source/gsc_obj.c source/gsc_obj.h source/offsets.h source/dobby.h source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_breath.c source/gsc_obj.c
# aae_move_sprint.c: T7Overcharged's rules for sprinting against its own (the numbers in tests/move_sprint_cases.h),
# and the handlers against a made-up game, through every value a compared register can hold
tests/test_aae_move_sprint: tests/test_aae_move_sprint.c tests/move_sprint_cases.h source/aae_move_sprint.c \
source/aae_move_sprint.h source/aae_movement.h source/detour.h source/offsets.h source/dobby.h source/prepatch.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_move_sprint.c
# aae_clientfx.c: T7Overcharged's rules for its table of client effects, and the six hooks against a made-up cache
tests/test_aae_clientfx: tests/test_aae_clientfx.c source/aae_clientfx.c source/aae_clientfx.h source/gsc_obj.c \
source/gsc_obj.h source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_clientfx.c source/gsc_obj.c
# aae_freeaim_net.c: what a client sends the server, what the server keeps and looks up, against a made-up game and
# against what the plugin's own code gave for the same cases
tests/test_aae_freeaim_net: tests/test_aae_freeaim_net.c tests/freeaim_net_cases.h tests/freeaim_net_side.h \
source/aae_freeaim_net.c source/aae_freeaim_net.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_freeaim_net.c
# aae_move_jump.c: T7Overcharged's jumpslowdown rules, its hooks and detours against a made-up game, two threads
# landing at once, and the cases T7Overcharged's own code gave under Wine
tests/test_aae_move_jump: tests/test_aae_move_jump.c tests/move_jump_cases.h tests/move_jump_side.h \
source/aae_move_jump.c source/aae_move_jump.h source/aae_movement.h source/detour.h source/offsets.h \
source/dobby.h source/prepatch.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_move_jump.c
# t7o_guards.c: the weapon attachment guard against a made-up weapon field lookup, the local client guard against a
# made-up controller lookup
tests/test_t7o_guards: tests/test_t7o_guards.c source/t7o_guards.c source/t7o_guards.h source/detour.h \
source/offsets.h source/dobby.h source/prepatch.h source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_t7o_guards.c
# t7o_uierror.c: the LUI error handler's hook against a made-up Lua stack and handler
tests/test_t7o_uierror: tests/test_t7o_uierror.c source/t7o_uierror.c source/t7o_uierror.h source/havok.h \
source/offsets.h source/dobby.h source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_t7o_uierror.c
# aae_linkcam.c: the plugin's rules for entities linked to the camera, and its hooks against a made-up game
tests/test_aae_linkcam: tests/test_aae_linkcam.c tests/linkcam_cases.h tests/linkcam_side.h source/aae_linkcam.c \
source/aae_linkcam.h source/aae_plugin.c source/aae_plugin.h source/detour.h source/offsets.h source/dobby.h \
source/prepatch.h source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_linkcam.c
# aae_coop_pause.c: the plugin's packets and rules against made-up games, a host and three clients over a made-up
# network that loses and reorders packets, and the hooks
tests/test_aae_coop_pause: tests/test_aae_coop_pause.c source/aae_coop_pause.c source/aae_coop_pause.h \
source/aae_plugin.c source/aae_plugin.h source/detour.h source/gsc_obj.c source/gsc_obj.h source/offsets.h \
source/dobby.h source/prepatch.h source/t7overcharged.h source/thread_stats.h source/thread_stats.c \
source/thread_stats_game.c
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_coop_pause.c source/gsc_obj.c source/thread_stats.c source/thread_stats_game.c
# aae_viewmodel.c: T7Overcharged's reading of the dvars and the file, its rules, and the hook against a made-up game
tests/test_aae_viewmodel: tests/test_aae_viewmodel.c source/aae_viewmodel.c source/aae_viewmodel.h \
source/aae_plugin.c source/aae_plugin.h source/gsc_obj.c source/gsc_obj.h source/offsets.h source/dobby.h \
source/t7overcharged.h source/thread_stats.h source/thread_stats.c source/thread_stats_game.c
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_viewmodel.c source/gsc_obj.c source/thread_stats.c source/thread_stats_game.c
# workshop_preview.c: the loader and the cache against a made-up device, texture memory table, decoder and files
tests/test_workshop_preview: tests/test_workshop_preview.c source/workshop_preview.c source/workshop_preview.h \
source/bo3macnative.h source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_workshop_preview.c
# asl_refcount.c: its replacement of Release against the game's code and under two threads; the x86_64 build runs the
# game's own four functions (tests/asl_refcount_game.s) next to it under Rosetta
tests/test_asl_refcount: tests/test_asl_refcount.c source/asl_refcount.c source/asl_refcount.h source/offsets.h \
source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_asl_refcount.c
tests/test_asl_refcount_x86_64: tests/test_asl_refcount.c tests/asl_refcount_game.s source/asl_refcount.c \
source/asl_refcount.h source/offsets.h source/dobby.h
$(CLANG) -arch x86_64 -std=gnu11 -O1 -g -Wall -Wextra -Werror -o $@ tests/test_asl_refcount.c \
tests/asl_refcount_game.s
# texture_swap_guard.c: its places and rule, and its hook against a made-up untrack, delayed release and render thread
tests/test_texture_swap_guard: tests/test_texture_swap_guard.c source/texture_swap_guard.c source/texture_swap_guard.h \
source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_texture_swap_guard.c
# clientfield_guard.c: its rules, and its hook against a made-up lookup, script engine and mod
tests/test_clientfield_guard: tests/test_clientfield_guard.c source/clientfield_guard.c source/clientfield_guard.h \
source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_clientfield_guard.c
# missing_map_guard.c: the preload stage's decisions and the hook against a made-up launch task
tests/test_missing_map_guard: tests/test_missing_map_guard.c source/missing_map_guard.c source/missing_map_guard.h \
source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_missing_map_guard.c
# material_sort_guard.c: its rules, and its hook against a made-up merge, frame and renderer table
tests/test_material_sort_guard: tests/test_material_sort_guard.c source/material_sort_guard.c \
source/material_sort_guard.h source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_material_sort_guard.c
# aae_arc.c: T7Overcharged's arc test, the plugin's checks and sums, and the hooks against a made-up game
tests/test_aae_arc: tests/test_aae_arc.c tests/arc_bend_cases.h source/aae_arc.c source/aae_arc.h source/aae_skeleton.h \
source/aae_plugin.c \
source/aae_plugin.h source/detour.h source/gsc_obj.c source/gsc_obj.h source/offsets.h source/dobby.h \
source/prepatch.h source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_arc.c source/gsc_obj.c
# aae_vmwidget.c: the plugin's tables and sums, its two methods and the updates they give an element, against a
# made-up game and Lua stack
tests/test_aae_vmwidget: tests/test_aae_vmwidget.c source/aae_vmwidget.c source/aae_vmwidget.h source/aae_plugin.c \
source/aae_plugin.h source/aae_skeleton.h source/havok.h source/offsets.h source/dobby.h source/prepatch.h \
source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_vmwidget.c
# aae_vmwidget.c's bones written by two threads at once, in the order that left the plugin's count odd, and many at once
# (it uses only the bone writers of the piece it includes, so the rest may go unused)
tests/test_aae_vmwidget_tsan: tests/test_aae_vmwidget_tsan.c source/aae_vmwidget.c source/aae_vmwidget.h \
source/aae_plugin.c source/aae_plugin.h source/aae_skeleton.h source/havok.h source/offsets.h source/dobby.h \
source/prepatch.h source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -Wno-unused-function -fsanitize=thread -o $@ \
tests/test_aae_vmwidget_tsan.c
# aae_skeleton.c: the one hook on DObjCalcSkel, the order of the pieces' work and the two calls, against a made-up
# game; it finds out where the hook returns to through the frame pointers
tests/test_aae_skeleton: tests/test_aae_skeleton.c source/aae_skeleton.c source/aae_skeleton.h source/offsets.h \
source/dobby.h source/thread_stats.h source/thread_stats.c source/thread_stats_game.c
$(CLANG) -std=gnu11 -O1 -g -fno-omit-frame-pointer -Wall -Wextra -Werror -fsanitize=address,undefined \
-fno-sanitize-recover=undefined -o $@ tests/test_aae_skeleton.c source/thread_stats.c source/thread_stats_game.c
# aae_lan.c: the plugin's packets and rules, and the host's listener talking to the test over the loopback
tests/test_aae_lan: tests/test_aae_lan.c source/aae_lan.c source/aae_lan.h source/aae_plugin.c source/aae_plugin.h \
source/detour.h source/gsc_obj.c source/gsc_obj.h source/offsets.h source/dobby.h source/prepatch.h \
source/steam.h source/t7overcharged.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_lan.c source/gsc_obj.c
# settings_ini.c's reading and writing, against odd settings.ini files
tests/test_settings_ini: tests/test_settings_ini.c source/settings_ini.c source/settings_ini.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -o $@ tests/test_settings_ini.c source/settings_ini.c
# display_policy.c's decisions are plain C, so they're tested with made-up displays, without the game
tests/test_display_policy: tests/test_display_policy.c source/display_policy.c source/display_policy.h source/display_follow.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -o $@ tests/test_display_policy.c source/display_policy.c
# sdl_displays.c against a fake SDL device (the test includes the source itself), for the dylib's macOS version since
# the CVDisplayLink calls it makes are deprecated from macOS 15
tests/test_sdl_displays: tests/test_sdl_displays.c source/sdl_displays.c source/sdl_displays.h source/engine_display.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -mmacosx-version-min=$(OSXVER) -framework CoreFoundation \
-framework CoreGraphics -framework CoreVideo -o $@ tests/test_sdl_displays.c
# AvoidNotch's geometry (notch_layout.c) against Aspyr's mouse mapping, plain C
tests/test_notch: tests/test_notch.c source/notch_layout.c source/notch_layout.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_notch.c source/notch_layout.c
# notch.m's letterbox and Metal client rect hooks against a made-up ASL window and stand-ins for Aspyr's functions
tests/test_notch_hooks: tests/test_notch_hooks.m source/notch.m source/notch.h source/notch_layout.c source/notch_layout.h \
source/offsets.h
$(CLANG) -O1 -g -Wall -Wextra -Werror -Wno-unused-parameter -fsanitize=address,undefined -mmacosx-version-min=$(OSXVER) \
-framework AppKit -o $@ tests/test_notch_hooks.m source/notch_layout.c
# prepatch.c's builder and runtime against a made-up executable with the game's layout (the test includes the source
# itself), with the address and undefined behaviour sanitizers since it's all byte offsets
tests/test_prepatch: tests/test_prepatch.c source/prepatch.c source/prepatch.h source/offsets.h source/dobby.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_prepatch.c
# the notices' queue and low battery levels (notice_queue.c) are plain C too
# quick_save_rules.c: when L3 + R3 count as held, and the request waiting for checkpoint.lua
tests/test_dynres: tests/test_dynres.c source/dynres.c source/dynres.h source/frame_limit.c source/frame_limit.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_dynres.c source/dynres.c source/frame_limit.c
tests/test_launch_args: tests/test_launch_args.c source/launch_args.c source/launch_args.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_launch_args.c \
source/launch_args.c
# start_mod.c and start_mod_game.c in made-up game, workshop and BO3MacFix folders, with the address and undefined
# behaviour sanitizers since they read files
tests/test_start_mod: tests/test_start_mod.c source/start_mod.c source/start_mod.h source/start_mod_game.c \
source/start_mod_game.h source/launch_args.c source/launch_args.h source/offsets.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_start_mod.c source/start_mod.c source/start_mod_game.c source/launch_args.c
# offline_mode.c against stand-ins for the system's network calls, made-up lookups and connections, and this Mac's
# loopback (nothing leaves the machine), with the address and undefined behaviour sanitizers
tests/test_offline_mode: tests/test_offline_mode.c source/offline_mode.c source/offline_mode.h source/dyld-interposing.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_offline_mode.c \
source/offline_mode.c
tests/test_quick_save: tests/test_quick_save.c source/quick_save_rules.c source/quick_save_rules.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -o $@ tests/test_quick_save.c source/quick_save_rules.c
tests/test_notice_queue: tests/test_notice_queue.c source/notice_queue.c source/notice_queue.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -o $@ tests/test_notice_queue.c source/notice_queue.c
# which frame rate limit applies to a frame and the pause menu's state (frame_limit.c), plain C as well
tests/test_frame_pace: tests/test_frame_pace.c source/frame_pace.c source/frame_pace.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_frame_pace.c source/frame_pace.c
tests/test_aae_engine_defaults: tests/test_aae_engine_defaults.c source/aae_engine_defaults.c \
source/aae_engine_defaults.h source/gsc_obj.c source/gsc_obj.h source/offsets.h source/gpu_tweaks.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_aae_engine_defaults.c source/gsc_obj.c
tests/test_frame_limit: tests/test_frame_limit.c source/frame_limit.c source/frame_limit.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -o $@ tests/test_frame_limit.c source/frame_limit.c
# VoiceMicrophone 0 refuses the voice system's start of recording, 1 hooks nothing (voice_mic.c, against a made-up game)
tests/test_voice_mic: tests/test_voice_mic.c source/voice_mic.c source/voice_mic.h source/offsets.h source/dobby.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -Wno-unused-parameter -fsanitize=address,undefined \
-fno-sanitize-recover=undefined -o $@ tests/test_voice_mic.c
# what BatterySaver's levels set on battery and plugged in (battery_saver.c)
tests/test_battery_saver: tests/test_battery_saver.c source/battery_saver.c source/battery_saver.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -o $@ tests/test_battery_saver.c source/battery_saver.c
# when IdleDisplaySleep lets the display sleep and declares a controller's input (display_sleep.c)
tests/test_display_sleep: tests/test_display_sleep.c source/display_sleep.c source/display_sleep.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -o $@ tests/test_display_sleep.c source/display_sleep.c
# which players folder a .cfg comes from (players_cfg.c), against made-up folders
tests/test_players_cfg: tests/test_players_cfg.c source/players_cfg.c source/players_cfg.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -o $@ tests/test_players_cfg.c source/players_cfg.c
# checkpoint.c (AAE's mutations lines, saving, applying and clearing a checkpoint) with made-up files, and the
# sanitizers since it parses files
tests/test_checkpoint: tests/test_checkpoint.c source/checkpoint.c source/checkpoint.h source/zm_loadout.c \
source/zm_loadout.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_checkpoint.c \
source/checkpoint.c source/zm_loadout.c
# zm_loadout.c (a loadout's names and checkpoint.ini text, reading the script VM's variables, restoring) against a
# made-up memory image and made-up game calls, with the sanitizers since it's all offsets and parsing
tests/test_zm_loadout: tests/test_zm_loadout.c source/zm_loadout.c source/zm_loadout.h tests/fake_vm.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_zm_loadout.c \
source/zm_loadout.c
# aae_cheats.c's decision and its reads of the game's command and mod name, against made-up memory (the test
# includes the source itself)
tests/test_aae_cheats: tests/test_aae_cheats.c source/aae_cheats.c source/aae_cheats.h source/offsets.h \
source/dobby.h source/zm_loadout.c source/zm_loadout.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_aae_cheats.c \
source/zm_loadout.c
# anim_event's tests of the entity and what it asks of the game, against a made-up game (the test includes the source)
tests/test_t7o_anim_event: tests/test_t7o_anim_event.c source/t7o_anim_event.c source/t7o_anim_event.h \
source/offsets.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_t7o_anim_event.c
# printsubtitle's arguments (t7o_subtitle.c), as AAE's HUD gives them
tests/test_t7o_subtitle: tests/test_t7o_subtitle.c source/t7o_subtitle.c source/t7o_subtitle.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_t7o_subtitle.c \
source/t7o_subtitle.c
# crash_log.c against made-up logs in a temporary folder, made-up reports in made-up report folders, and its game side
# with the output in a file, a made-up frame counter, notices and Lua; the address and undefined behaviour sanitizers
tests/test_crash_log: tests/test_crash_log.c source/crash_log.c source/crash_log.h source/crash_report.c \
source/crash_report.h source/crash_log_lua.h source/offsets.h source/notices.h source/havok.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-framework CoreFoundation -framework IOKit -o $@ tests/test_crash_log.c source/crash_report.c
# crash_report.c against a made-up report, the game's real ones on this Mac cut at every length, random bytes and nesting
# past its limit, with the address and undefined behaviour sanitizers since it reads files anybody could have written
tests/test_crash_report: tests/test_crash_report.c source/crash_report.c source/crash_report.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_crash_report.c source/crash_report.c
# t7o_small.c: T7Overcharged's rules, and its game side against a made-up game (the test includes the source)
tests/test_t7o_small: tests/test_t7o_small.c source/t7o_small.c source/t7o_small.h source/offsets.h source/dobby.h \
source/havok.h source/t7overcharged.h source/gsc_obj.c source/gsc_obj.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_t7o_small.c source/gsc_obj.c
# navmesh_convert.c: which map names it converts, and its arguments reaching a made-up wine as they are
tests/test_navmesh_convert: tests/test_navmesh_convert.c source/navmesh_convert.c source/navmesh_convert.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_navmesh_convert.c source/navmesh_convert.c
# qol.c's audio moves (the test includes the source): a made-up SDL audio thread and CoreAudio stand-ins
tests/test_qol_audio: tests/test_qol_audio.c source/qol.c source/qol.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -Wno-unused-parameter -fsanitize=address,undefined \
-fno-sanitize-recover=undefined -mmacosx-version-min=$(OSXVER) -framework AudioToolbox -framework CoreAudio \
-framework CoreFoundation -o $@ tests/test_qol_audio.c
# utilities.c's helpers (the test includes the source)
tests/test_utilities: tests/test_utilities.c source/utilities.c source/utilities.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-mmacosx-version-min=$(OSXVER) -o $@ tests/test_utilities.c
# script_errors.c's QuietScriptErrors: which script errors it shows, against made-up script engine memory (the test
# includes the source itself)
tests/test_script_errors: tests/test_script_errors.c source/script_errors.c source/script_errors.h source/offsets.h \
source/dobby.h source/thread_stats.h source/thread_stats.c source/thread_stats_game.c
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_script_errors.c \
source/thread_stats.c source/thread_stats_game.c
# zm_inventory.c's pass through the game's cheat check for BO3MacFix's give and take commands, against a made-up
# g_entities (the test includes the source)
tests/test_zm_inventory: tests/test_zm_inventory.c source/zm_inventory.c source/zm_inventory.h source/offsets.h \
source/dobby.h source/zm_loadout.c source/zm_loadout.h tests/fake_vm.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -Wno-unused-parameter -fsanitize=address,undefined -o $@ \
tests/test_zm_inventory.c source/zm_loadout.c
# checkpoint_autosave.c (AutoSave's background writer, its rules, deleting the save, the lock) with made-up files, with
# the address and undefined behaviour sanitizers, and again with the thread sanitizer since it's about two threads
tests/test_checkpoint_autosave: tests/test_checkpoint_autosave.c source/checkpoint_autosave.c source/checkpoint_autosave.h \
source/checkpoint.c source/checkpoint.h source/zm_loadout.c source/zm_loadout.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -o $@ tests/test_checkpoint_autosave.c \
source/checkpoint_autosave.c source/checkpoint.c source/zm_loadout.c
tests/test_checkpoint_autosave_tsan: tests/test_checkpoint_autosave.c source/checkpoint_autosave.c \
source/checkpoint_autosave.h source/checkpoint.c source/checkpoint.h source/zm_loadout.c source/zm_loadout.h
$(CLANG) -std=c11 -O1 -g -Wall -Wextra -Werror -fsanitize=thread -o $@ tests/test_checkpoint_autosave.c \
source/checkpoint_autosave.c source/checkpoint.c source/zm_loadout.c
# controllers.c (when the game is asked to look for controllers, the version SDL is given) against a fake game image and
# fake HID devices, and gc_bridge.m's player slots as the game's XInput calls see them, with stand-in controllers
tests/test_controllers: tests/test_controllers.c source/controllers.c source/controllers.h source/offsets.h
$(CLANG) -std=c11 -O1 -Wall -Wextra -Werror -Wno-unused-parameter -mmacosx-version-min=$(OSXVER) \
-framework CoreFoundation -framework IOKit -o $@ tests/test_controllers.c
# gpu_diag.m's command buffer timing (FrameStats detail, DynamicResolution): the commit swizzle, with a stand-in command
# buffer class and another thread committing while it goes in
tests/test_gpu_diag: tests/test_gpu_diag.m source/gpu_diag.m source/gpu_diag.h source/metalfx.h
$(CLANG) -O1 -Wall -Wextra -Werror -Wno-unused-parameter -mmacosx-version-min=$(OSXVER) -framework AppKit \
-framework Metal -framework QuartzCore -o $@ tests/test_gpu_diag.m
tests/test_gc_bridge: tests/test_gc_bridge.m source/gc_bridge.m source/gc_bridge.h source/controllers.h source/offsets.h
$(CLANG) -O1 -Wall -Wextra -Werror -Wno-unused-parameter -mmacosx-version-min=$(OSXVER) -framework Foundation \
-weak_framework GameController -weak_framework CoreHaptics -framework IOKit -o $@ tests/test_gc_bridge.m
$(TARGET): $(SOURCES) $(wildcard source/*.h) source/t7overcharged_lua.h source/settings_menu_lua.h source/notices_lua.h source/checkpoint_lua.h \
source/crash_log_lua.h source/build_name.h
$(CC) $(CFLAGS) $(FRAMEWORKS) $(DEFINES) $(LDFLAGS) -o $@ $(SOURCES)
# the Lua half of our T7Overcharged support, embedded as a byte array
source/t7overcharged_lua.h: source/t7overcharged.lua
cd source && xxd -i t7overcharged.lua > t7overcharged_lua.h
# the in-game settings page's Lua (settings_menu.c), embedded as a byte array
source/settings_menu_lua.h: source/settings_menu.lua
cd source && xxd -i settings_menu.lua > settings_menu_lua.h
# the notices' Lua (notices.m), embedded as a byte array
source/notices_lua.h: source/notices.lua
cd source && xxd -i notices.lua > notices_lua.h
source/checkpoint_lua.h: source/checkpoint.lua
cd source && xxd -i checkpoint.lua > checkpoint_lua.h
# KeepCrashLogs' menu lines (crash_log.c), embedded as a byte array
source/crash_log_lua.h: source/crash_log.lua
cd source && xxd -i crash_log.lua > crash_log_lua.h
# the build's name (BUILD_NAME), rewritten only when it changes, so a commit builds the library again and nothing else
# does; outside a git checkout it is empty and the log names the time of the build instead
source/build_name.h: FORCE
@printf '#define MACFIX_BUILD "%s"\n' '$(BUILD_NAME)' | cmp -s - $@ || \
printf '#define MACFIX_BUILD "%s"\n' '$(BUILD_NAME)' > $@
FORCE:
clean:
rm -f -- $(TARGET) $(TEST_TARGETS) source/t7overcharged_lua.h source/settings_menu_lua.h source/notices_lua.h source/checkpoint_lua.h \
source/crash_log_lua.h source/build_name.h
rm -rf -- tests/san tests/fuzz/out tests/quietcrash.dylib
.PHONY: all clean test sanitize fuzz fuzz-build FORCE
# A test program that may crash is started with tests/quietcrash.dylib (a fatal signal then ends it with exit status
# 128 + the signal, and macOS writes no crash report into ~/Library/Logs/DiagnosticReports) and with the sanitizers
# exiting instead of aborting. The variables have to be set by env right before the program: macOS drops DYLD_
# variables when it starts one of its own protected programs (sh, nice, env), and so for everything those start.
QUIETCRASH = tests/quietcrash.dylib
QUIET_RUN = env DYLD_INSERT_LIBRARIES=$(CURDIR)/$(QUIETCRASH) ASAN_OPTIONS=abort_on_error=0 \
UBSAN_OPTIONS=abort_on_error=0:halt_on_error=1
$(QUIETCRASH): tests/quietcrash.c
$(CLANG) -arch arm64 -arch x86_64 -dynamiclib -O1 -o $@ tests/quietcrash.c
# The fuzzers (tests/fuzz, see fuzz_engine.c): each harness feeds what another machine, a mod or a file can give to
# the parsing functions, under the address and undefined behaviour sanitizers. make fuzz runs each for FUZZ_SECONDS
# (60) one after the other, niced; each goes on from the corpus its last run left in tests/fuzz/out/<name>/corpus, and
# an input that brings it down is left there as crash-<hash> (run the fuzzer with that file to repeat it). make fuzz
# FUZZERS=lan for one. Not part of make test.
FUZZERS ?= lan freeaim_net coop_pause gsc aae_build text_files commands
FUZZ_SECONDS ?= 60
FUZZ_FLAGS = -std=gnu11 -O1 -g -fno-omit-frame-pointer -Wall -Wextra -Wno-unused-function -fsanitize=address,undefined \
-fno-sanitize-recover=all
fuzz-build: $(FUZZERS:%=tests/fuzz/out/bin/fuzz_%)
fuzz: fuzz-build $(QUIETCRASH)
for name in $(FUZZERS); do \
mkdir -p tests/fuzz/out/$$name/corpus; \
nice -n 10 $(QUIET_RUN) ./tests/fuzz/out/bin/fuzz_$$name -seconds=$(FUZZ_SECONDS) -out=tests/fuzz/out/$$name \
tests/fuzz/out/$$name/corpus || exit 1; \
done
tests/fuzz/out/bin/fuzz_engine.o: tests/fuzz/fuzz_engine.c
mkdir -p tests/fuzz/out/bin
$(CLANG) $(FUZZ_FLAGS) -c -o $@ tests/fuzz/fuzz_engine.c
# a harness includes the sources it feeds, so it depends on all of them
tests/fuzz/out/bin/fuzz_%: tests/fuzz/fuzz_%.c tests/fuzz/out/bin/fuzz_engine.o $(wildcard source/*.c source/*.h)
$(CLANG) $(FUZZ_FLAGS) -fsanitize-coverage=trace-pc-guard -o $@ $< $(FUZZ_SOURCES_$*) tests/fuzz/out/bin/fuzz_engine.o \
$(FUZZ_LIBS_$*)
# sources a harness doesn't include itself (they would clash with the ones it does), and libraries
FUZZ_SOURCES_freeaim_net = source/aae_freeaim_net.c source/gsc_obj.c
FUZZ_SOURCES_text_files = source/checkpoint.c source/zm_loadout.c
FUZZ_SOURCES_commands = source/t7o_small.c source/t7o_subtitle.c source/launch_args.c source/players_cfg.c \
source/offline_mode.c source/notice_queue.c source/gsc_obj.c
FUZZ_LIBS_aae_build = -lz
# every test again under the address and undefined behaviour sanitizers, for arm64 and x86_64 (tests/sanitize.py;
# SANITIZE_ARCHS=arm64 for one, SANITIZE_ONLY=<regular expression> for some tests); slow, so not part of make test.
# SANITIZE_ONLY goes to the script as it was given, a "$" in it too (make would read "$|" and the like as its own
# variables); only a single quote can't be in it.
sanitize: $(QUIETCRASH)
SANITIZE_ONLY='$(value SANITIZE_ONLY)' python3 tests/sanitize.py $(TEST_TARGETS)
# FrameStats' detail: the threads' and the phases' lines (thread_stats.c), and this process's own threads read by name
# with their CPU time (thread_stats_game.c)
tests/test_thread_stats: tests/test_thread_stats.c source/thread_stats.c source/thread_stats_game.c source/thread_stats.h
$(CLANG) -std=gnu11 -O1 -g -Wall -Wextra -Werror -fsanitize=address,undefined -fno-sanitize-recover=undefined \
-o $@ tests/test_thread_stats.c source/thread_stats.c
# the same as x86_64 code under Rosetta, as the library runs in the game: the threads' names, ids and times read there
tests/test_thread_stats_x86_64: tests/test_thread_stats.c source/thread_stats.c source/thread_stats_game.c \
source/thread_stats.h
$(CLANG) -arch x86_64 -std=gnu11 -O1 -g -Wall -Wextra -Werror -o $@ tests/test_thread_stats.c source/thread_stats.c