summaryrefslogtreecommitdiff
path: root/PKGBUILD
blob: 796c4eda1280d702a1ae83a6c42be783e855b6a6 (plain)
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
# Maintainer: jc_gargma <jc_gargma@iserlohn-fortress.net>
# Contributor: aqua <aqua@iserlohn-fortress.net>
# Maintainer (Arch): Kyle Keen <keenerd@gmail.com>

# # I maintain this because:
# Arch version is not BN
# Arch version has non-functional desktop file
# Arch version lacks additional optimization and hardening flags
# Arch version lacks numerous bugfixes I created
# Arch version has some vanilla balancing changes I disagree with
# Arch version segfaults due to -Wp,-D_GLIBCXX_ASSERTIONS

pkgbase=cataclysm-bn
pkgname=(cataclysm-bn cataclysm-bn-tiles)
pkgname=cataclysm-bn
#_pkgname=Cataclysm-BN-cbn
_pkgname=Cataclysm-BN
pkgver=0.5.2
#pkgver=202310040030
#_pkgver=2023-10-04-0030
pkgrel=6
pkgdesc="A post-apocalyptic roguelike."
#url="http://cataclysmrl.blogspot.com/"
#url="http://www.cataclysm.glyphgryph.com/"
#url="http://en.cataclysmdda.com/"
url="https://github.com/cataclysmbnteam/Cataclysm-BN"
arch=('x86_64' 'aarch64')
license=("CCPL:by-sa")
options=('lto')
depends=('ncurses' 'hicolor-icon-theme' 'gettext')
makedepends=('sdl2_image' 'sdl2_ttf' 'sdl2_mixer' 'freetype2' 'astyle')
#source=("$pkgname-$_pkgver.tar.gz::https://github.com/cataclysmbnteam/Cataclysm-BN/archive/refs/tags/cbn-experimental-$_pkgver.tar.gz"
#source=("$pkgname-$pkgver.tar.gz::https://github.com/cataclysmbnteam/Cataclysm-BN/archive/refs/tags/cbn-$pkgver.tar.gz" # Pre 0.5.2
source=("$pkgname-$pkgver.tar.gz::https://github.com/cataclysmbnteam/Cataclysm-BN/archive/refs/tags/v$pkgver.tar.gz"
        "cataclysm-bn.desktop"
        "cataclysm-bn-tiles.desktop"
        "icon_128x128.png"

        "revert-01_removed-traits.patch"
        "revert-02_revert-book-revamp.patch"
        "revert-03_generic-nv.patch"
        "revert-04_telescopic-lenses.patch"
        "revert-06_Obsolete-useless-hub01-basement-1457.patch"
        "revert-07_Remove-handload-quality-distinction-1481.patch"
        "revert-07.5_Use-bismuth-in-recipes-related-ammo-fixes-2952.patch"
        "revert-09_undo-yet-more-ammo-balancing.patch"
        "revert-11_Obsoletion-and-removal-of-useless-bathroom-fluff-247.patch"
        "revert-12_fix-i18n-metric-bullets-part-1-rename-.223-5.56x45mm.patch"
        "revert-13_fix-i18n-metric-bullets-part-2-rename-.308-7.62x51mm.patch"
        "revert-15_Fix-mutant-scenarios-adding-an-obsoleted-trait-2929.patch"
        "revert-18-Simplify-broken-limb-mending-3054.patch"
        "revert-19_Fix-Repair-Nanobots-3308.patch"
        "revert-20_Fix-tidy-warnings-3310.patch"
        "revert-21_fix-Erased-the-npc-Alonso-from-history-the-game-3582.patch"
        "revert-22_feat-content-Biodiesel-Fuel-for-Gasoline-Engines-371.patch"
        "revert-23_fix-balance-no-more-EXP-gain-when-a-skill-is-maxed-o.patch"
        "revert-24_fix-repair-nanobots-not-working-at-all-on-broken-lim.patch"
        "revert-26_fix-npc-splints-and-clean-up-iterator-errors-3592.patch"
        "revert-27_fix-NPCs-keep-their-splints-on-3589.patch"
        "revert-28_feat-content-semi-plausible-smokeless-gunpowder-reci.patch"

        "hotfix-01_fix-monsters-ignore-mechs-that-aren-t-being-piloted-.patch"
        "hotfix-02_fix-Prevents-reloading-from-deleting-containers-4104.patch"
        "hotfix-03_fix-Fix-overlapping-text-in-look-around.-4156.patch"
        "hotfix-04_fix-uaf-in-safe-references-4165.patch"
        "hotfix-05_feat-balance-closed-glass-windows-block-scent-4114.patch"
        "hotfix-06_fix-two-cases-of-NPCs-printing-messages-in-odd-conte.patch"
        "hotfix-07_fix-allow-card-readers-to-despawn-riot-turrets-too-4.patch"
        "hotfix-09_fix-NPCs-no-longer-magically-aware-of-explosives-the.patch"

        "ammo-10_ammo-order-fix.patch"
        "ammo-11_fix-volume-40mm.patch"
        "ammo-12_fix-20x66mm-loudness.patch"
        "ammo-13_fix-reloaded-50bmg.patch"

        "armor-01_ankle-ammo-pouch-is-not-a-backpack.patch"
        "armor-02_fix-survivor-fingerless-gloves-warmth.patch"

        "bionics-01_npc-can-use-more-bionics.patch"

        "faction-01_more-factions.patch"
        "faction-03_fix-food-supply-calculations.patch"

        "factioncamp-01_remove-legacy-recruiting-penalty.patch"

        "foods-01_fix-food-materials.patch"
        "foods-02_fix-food-naming.patch"
        "foods-03_fix-mutant-bad-taste.patch"
        "foods-04_allow-canned-corn-as-veggy.patch"
        "foods-05_fix-missing-price-postapoc.patch"
        "foods-06_sealed-foods-not-full.patch"

        "itemgroups-01_hk46-is-milspec.patch"
        "itemgroups-02_add-missing-mre.patch"
        "itemgroups-03_fix-shelter-batteries.patch"

        "meds-01_antibiotics-unhealthy.patch"

        "migration-01_remove-ucp.patch"

        "mission-01_typos.patch"
        "mission-02_reorder-gunslinger-quest.patch"

        "monsters-01_medical-zombies-called-zombies.patch"

        "mutations-01_nerf-lightstep.patch"
        "mutations-02_fix-evac3-background-visible.patch"

        "npc-01_isherwood-update.patch"
        "npc-02_tacoma-update.patch"
        "npc-03_godco-update.patch"
        "npc-04_island-prison-update.patch"
        "npc-05_kindred-update.patch"
        "npc-06_lapin-update.patch"
        "npc-07_lighthouse-family_v2.patch"
        "npc-08_nurse-takes-more-meds.patch"
        "npc-09_broker-takes-more-foods.patch"
        "npc-10_bunker-merchant.patch"
        "npc-11_npcs-reload-gas-mask.patch"
        "npc-12_fix-eddie-requiring-1000-clay.patch"
        "npc-20_dialogue-fixes.patch"

        "recipes-01_4570-dragon-can-be-dismantled.patch"

        "terrain-02_fix-doors-for-npcs.patch"
        "terrain-03_tacoma-clinic-add-missing-floor.patch"
        "terrain-04_lumbermill-gasoline-not-spilled.patch"
        "terrain-07_rehide-redacted.patch"
        "terrain-09_make-firestation-shelter-wells-npc-drinkable.patch"
        "terrain-10_fix-milbase_minefield.patch"
        "terrain-11_clean-up-map-extras.patch"
        "terrain-13_fix-mapgen-palettes.patch"

        "tools-01_foldable-bottle-is-container.patch"
        "tools-03_shears-use-light-battery.patch"

        "vehicles-01_portable-generator-engine.patch"
        "vehicles-02_fix-fbi-car-name.patch"
        "vehicles-03_black-box-can-be-installed.patch"

        "weapon-02_Fix-usp45-load-order.patch"

        "etc-02_add-missing-price-postapoc.patch"
        "etc-03_fix-abstracts.patch"

        "src-01_radio-can-use-ups.patch"
        "src-02_ammo-loudness-ap-times-2.patch"
        "src-03_allow-bio-firestarter-on-smoker.patch"
        "src-04_stop-non-faction-npc-sleep-depirvation.patch"
        "src-05_stop-non-faction-npc-malnourishment.patch"
        "src-06_stop-sleeping-on-tables.patch"
        "src-07_allow-hacker-laptop.patch"
        "src-08_more-military-base-overmap.patch"
        "src-09_npc-eat-from-further-camp.patch"
        "src-10_reduced-kcal-during-sleep.patch"
        "src-11_fix-tacoma-farmfield.patch"
        "src-12_lower-lockpicking-experience.patch"
        "src-13_searchlights-with-plut-gen-furn.patch"
        "src-14_fix-npc_melee-calculations.patch"
        "src-20_fix-default-mods.patch"
        
        "vampirism.patch"
        )
b2sums=('9daaba287ef99aa3b33b6f3fbb129b97a2b4dcc265dd7affa08ccee1bdd41b4568e061aa9e8b4090346c30040e8fb6e582648ededbd14534e32d44bbac1a1546'
        '069ecde58859b3d44cd687c4b6e718610cefb693ff86e66f199ebfb1b3072023ad2b6f0c28e27ef9c1ce4997f6a5b2ca0d45046996b3ff35a4aeaeb1a7cf9421'
        'ad88bc6c1e3c8183a313b5eec42f98d6956afea349feff34a86e4536c9921fa99d2594282caf27de8ebb7ffb56376ed2e76d572227bfd6d8173c7bb1f01e23b8'
        '6f70e90359a14e4839d9a2683debb88850e5dd387add911ad68fd87e5512cfcdd435da63e1e370358153673fd5a72a9b1e9c94f1979edb7948b4da8c82407bad'
        'fdef1f81084e7b08203b8464f37a00e2efc8b11d423c6e6b82e612392d91047160d2bc472b63c836ebc48adee0b4f2b3434c3e07eed5876275b234e69d7f6b9c'
        '2b42190f1d7189a38b3424efe64fd1b3921919a4f6fc872462ef684587de94b900e93f159597ab3e6f576268fed3e6966cddc3fa7250e1b746095fd7a2cbf6e9'
        'e417a1786fbafb685099431f7f9926201ab80636bf3812da67acc341c7ef2b6a3853734d5b8b1bc355acbd5c0bedefb0401f8854aa5cb00032550afc8a7b9ebe'
        '5b0e957a5f80ea878c554711dab2fe6759deb3371532cd0f149cfc7a54ec914f445a4aeeff4263df58c947f03fe7be30f2ef175b9a81708e668fd037f9b8ccf8'
        '2d197903715263628e767e867e9b20b9ebd3d85f8983ac8f1e2b534f2b6f8c0470886c79a409f117ad43348aa6aef2a6298925ae27faa32814183ad7677528ac'
        '4a03288ecc9bb0f342add15413bdc060cb071105d35a4f53d4cce121956e4d95e2b7a9ab9dd9fbf1009c5f54c34776e1f724c3fd171eb5b6ff41db0dbe2fce07'
        '8ed59f0237d4becee71c5f79dd434972eda3a02c56c29642f69c8ac7e638d866df633e0e087b4392bb74017b6ea3641fd6155d86f0c71fc188be19e7a81cc23b'
        'aaf108d56813472ba3e53b63fabc49adbbec01008e0df17f3fecf821784221f03c77eb822858983437dce993913eaa3679217830b101e54d57c6976c52559717'
        '1588c497a7f324cc96ed7aa194a9d99cd5f0ed9dd5db03321f03afcda381b7b2262bbc386f01cb756dd4cd53f73c244012339bb66315ef374a95afcfc2301085'
        '406130adb1be38e25bf750e10166ea55bd8e5c5e500ea81d8af547131a2eea04ce1e4b415f3fe87f4825aa515186b23e612a4961d2b44f538466044d7ec49624'
        'c6854d23ec8eec198e3ee1ca9a7cdb2c8c6f2c20a4e670d6752eb09ec99713dd52d659690e4dce935b11954f7d435d5ea35b4eda23bee3ee5759ef395c18b6ff'
        '2de96509a572c1eca36d63f1a049a27583cd0f2df53605b927c9b5112d4e2385bccc82ba1a37af06fe756f96cc1e8c9d4b6cd081ad70651ec09ac57b93cee84f'
        '9c8c49c7c70a40a195e4cafcb22b7e1fab1e276bc59c186e9b09fd77c525dc63fc64719e0f87083f2761172761c9a6dfaf8ff11b405976502e7f55e9606c42c0'
        'dcb8a004230da09e73a340c1acaf3c0071a8c26e3bce9a707b8e1624854aadc9e45f6f3f0d99549ccef5c11a6396dc082691895c437d50188e1b292cb8c10751'
        'b4ca2cb0e7c6c908277b178dae1b946ecdc2b88a8b0b4930450758e03c1f280b3740118cee274886693c158cd4604dc8487211b9185538eaa72852b18f0c67f2'
        '677c476df28e0f5d0ddf789bf2b26f2dc49a9d1523ba07f2a0607bb47d00b17c9f7ae86737d5a69f7fb8c7bfc82231a8a1d5b756ae49934adf1eff315c7a9a5b'
        '80d5920380282ba1c9bd81e8e7055af3c88ff2ecfb1d375ad9f1ddc29b3f61760119b9ec27c14266a020a32d8bdc6f1eb1bce35e847ed87faea0c7623f8b906e'
        '84b9d7d78ad2ab43f24aed79f6843e7fb8f600bb8edea384fa446f0a70bbbd5bdcc391de8bfa25667d3906df8ae8e9154701bb582e058d77e9326a08de3fc00e'
        'bdc83eecf20d82bd314ea6c053c19a990ab25aa067cdec8dab479d59b5169563bf7f368776ca18749918b5ce4a8df4e2a2e700dbbc3a36b38ee61f1b57cd416a'
        '6735377f8611451333c8d7f009001aa652af9edeeddfcd0cd163d03ea84607803d260eb1338fa35f688954c3cb75bb7bdc41a5ad0497771815dd16afa86d54b3'
        '13e61e9144f4d7325c409553c72ea1fca07009939b53491ea24d208fba7539e7f09063911c76e7d45f7e6bda12a61bbde17a75c319a0b79518e6639d520fa4ef'
        'c4ee693418d394e3b946aa2b9a5f11c04bb0ff11234f830056963f4a755357552f9a769688a086f56f492ed479cf1a44032cfde45c03627adc5fb55f88f806e6'
        '32714f9869cbf44847c5cd2d4b4d6e69a47450a3dd2bd92a195686d938162a86717c4e1c28dab48d8b62fbe0271e0eead5ea9c727aa547787643172fe3b48751'
        '54ed3733d646b549b4db8eded9aeb08de1df328c63c4a535971cf03de172349421b4e96d495995ea5abd2cf63b2df46c2fee9d526eea414bd9463e920802fe78'
        '29bc7e4f9ca7437930a43455be8d1166ff2b7bbaaa58209692d4a15fa7c4b19a4b185881d9a1c5abafe363de31f31fe44585da24dbeecaba183e884539443228'
        'af8d397d3b42ec0ff461337c19e470dd05b367a362cff092dbe6083841fee062cf899799e69db11fba05179775ac398f8ef3bf79a9f0e25b8774350451e73363'
        'b388513e6e2d67b3c6ae4f7c27d59bcd78fac9909e887fa4c58932052c0f3355b1dad23abfe404ca2bec82e278759e5be5982abb8b5b1dc7c908c51f7a510d05'
        '8dd1ade1242764bb7b69bf3b564f4e0ad7a2a53e4153a421f2b901c811daa038508e6eae21cd25d48f1c685024229a286e57f9357a04608332b3c8de1cb904e2'
        'f6a8421d0aaf32e1062ce9b90b4a699b66374ddd6a3f7bd1705b476d2e74c627f594b99006c6f88389c444f7ed3a5d87fc2b323b2331c4221706120d6eb52abb'
        'c1cdb13cf76e0f3b879c463258701a8ef268097323f6befcda1a1027be19256daf38ad4d80d982347e36570a5df4339a3020159b7498a997e0e26998fdaa564d'
        'df26a597afe46a35e07f02c32839e2f7f57cf4d4d9bf0e62eb645d1b720f601fe2e9787462a0ab0ba8b788c727b846272a4ca6ecf81f96bb058d070b53633dcc'
        'ba2964e64df20167c722e71951db28d039e637397a6be2e7f5312da10ab3c57a1982ec1ae1c37dd361317292b8c519f678472eb06360d4368294e0b636704c15'
        '365e1ac9f9ee636f2578f6fd8ab16b6460894cb9b76cf0aee5d8a55f42d882d6ee0b04e80194f4c346bfdb0778e11e30b8c03541b4d351602ccfd63cee7e3cf0'
        '6f79418343f29e3758e826417e475d957e0c372fab8c06855f5a86b4636ce6e8c68a770a4a3ec327361ec69d042d627062b2c2db23e5e437cef855683242545e'
        'bf952e4c5e8ad3851f2ab5a812fdf65e0a6e7e1726150d7fa6cb582f4408eed85edc7b8cf9dabc07fab62217d14fa7ee5493b45bddb282da44247291e84c990d'
        'f4ad4c90cfcf11af42c6cfc6d2027b21af3f58ac274b9bd0852a52ef60b606476766f194b281f6baf12f81647b384a98f745519bb48bc2e4f5fe03984c7c0e65'
        '172c611008cb8893a8a8cbf83ef929f5727fbf341f3303c6f38749e3742f96ba7352624112ac231a8df7be9031649e41d54cc52152776e52e3a7a620ea8f33e3'
        '1ce956dbcd0af3e16c336ce15995a7df19b8bed78765890304ff9dcaf6d30c602580bef050d6c659fdff945a31dce880f5f4042dfc295cdef44c34155a3e644c'
        '804cea67bb0a2fab62dd9cf633d1959a3fe59b3e24f0c2e01a6db951100fa4426ae946a90a93fa7fd6a7d0ece478633d0091144c2fa776858157edec1310f837'
        'a611964c224c7751c3afeaadb159135e5ed5d87d3ed254be63b4b12450f4f63f414c90f8e29f3d14c0b854f4c9938bf5d12db69d2e258f1947e353302ca07da7'
        '554bc4acb13f2eb70b14dad095c609cd1515bf462a147511fefb935ad64a4dbffe6aa2a89db7342728a212e4e87f7def120c136d87202dc754700ed62449fa12'
        '32975862668e4c28bf345cf9e2e3a2f754f7d7d50208f1d840e3b2ca47da1c19bcff9bdf6dc841ec803c64fd633b479d1d598ee22119589732f7cff1fa6dd6dd'
        '7da2d555f4b21da6704675400dc97367ff3e6bb60213d86c972b6740f074bcef98482ad7f759ddbee09f67d0ee8687c26c425d697ab586a784385971aec72bb0'
        'c3b8dcce2fe41c8d9dab2d35d56304f426e06f9a6a220fcb2f413ac4aa32c7f466e2001cc7bf0bbf6127aeef55c837bb344f08afbb392f202c4ad8ce83a592a9'
        'e85003201457633ab56789aef908ad4e8f9ed4728fc2bceb0344b851bf65f13264dfe9459afd4c1ba69c0d89f83e841f4829dcf6b0f8fb456bc9f2176c66ca87'
        '7b4369a2535029e214af7f51f7d6292d91989249374c9969a140f8954dedca2a2c04f626ac0bcf33f9ea8ab1710fadcc79034156405249b885b01e5c53be2188'
        '76c816df10aceec8f1a7d1356220eb3f00b16fac455e84eb8aefe76db29cd037dc74fb5cfa344b8d283b188951bd100c26e351ce2e27c16c836a547fe2c99e46'
        '417cd957f188b2b06e41d5413bea5f13481c6d5bfa8f184157379d5ac2afa9ba6f7ebc966856f50603f89b9173b6fbfdb3ccf4e3cc0b1bedb53f935591e4a35c'
        'dae75d9cd00f1f3ceabf257f1d82d245ace6582cf7ea98a40c1d1eb9b7e1832cb2a0c13f25c814a05a70931c42a06694a67829ea55554cc680eaa8ddf16c84a8'
        '931ac85c657c1c504de1ea629205b19f79a11acdd7c62cf71b909323ec1588610b1f575bc58ab01c3fbcd334fca8fbc114316570732f55a3f7fb3dd2984cd442'
        'b9bf63ed06aee848fa70adceaf9674e842343e6f92e9a2e57be372814b481d54bdfee602eac9e3c05dc5c8e35ec36146f28491de39b7ea2c8c3a8b9ac80c0354'
        '536c59b274923d36fbfc6dc39ef373a0d1e497422dea6fcdc16cfacb6b9ba421f14c5d7c4db31bab083199d859ff57ae5b19842f95367cfa39059e7156e96093'
        '69891c188f233e5174c2ddabce9371e84fdffdb105345686d71a9d823422969f77f9c44bc6571c6e5a72dbc9b9bdb6abf8c72cf9480bb87dca6f998f62f3de02'
        'e466392190e0aa58c02acda287bc8ac6fef30160207d08805ca9acd42b7f024d0680c0a76fcb4f29a7d7ca884920bba3a6714b5ad40f64dd1b40bcf0e2621d26'
        'f2ad02ac73e7ab5c26f986b640b88ed10ad30b103d98ede377b3868a3d0f84cabbc4c06f5f6b2e05c18c672370d1c25a7bfe3b3ea5d057ac7f3d7ef35b814c7e'
        'ab35d6663b864449d46da4a9e1c51e11956ff4c38e16db58c831b71f7b964fc25b0283122dbc8aa0549f240f01c4a910fb5c6c82937258c6b736c05b54bcf768'
        '75877d9c6090a4e75529b1840f875ef04941a643c2c3b0c2e2a605c0d43d6b7ac23abf7f0316885441b8310f8a39339f2e12c7763b2d9875ee772949e6dcfcaa'
        '761938b9d05430a72ff1102671d963e44d647ddb63b9a6e78979f365c6cd1e98b6a3763a4b9667ca75fbf23ee3812b4f09838061e8ba101d89d6f4dbd1104dc0'
        '3bc768194ae94a95eb8a5f7e1536e81bbb885d9d2f6dd799350d272d2f87d4bfb4ebb5dbd215157b000f29821ce43fc7b0ed45a142329a5ffc207463b054d9fd'
        'fa3f9c021097115fd180c83a6640a696240783b165add09b48f624f3b91546aa75bdb05b12a0edfaa009f69f5aaeabb20e2e52267c7d4be4c1d4d8567d8f4eca'
        '09ad88d1eebdb6433c2429cea4b775384b65d6cd52945e0de536dbac9fb6d9c345bec9bb49ede6fc6ce01a73e8297d3c8901c4e91d1b5a12eebc36ffd8c21ac4'
        '49d39404138e5e45fdb05b772636388eb7aada9dab6e549904e4b87053329d9df506ad6f390d73fb25c518299459df657ca6e02142fed9d29f4cd1c5f89734d7'
        '246a189a0002e755bbed91257c324d0f34bab724f38a31bad1d5eb8bc5b126ecb3a0af8f69a6d0f5f084930c670d2747942beabab0b684f7f66a13044dec394a'
        '739d0a1acbf6cdd1c6e78cac75a792d475b140219ffbf8c44d4db9fa82dc93f0822763be14c81afe69ab167a611a5d89fceb3df39d28b191835e14628c369140'
        'eeb7565ca52f3be3b6ae3396bd48c06722f32b3e0a6f2ba9abdda89e658ec05393f7849d13134006889da11e0a02dc7e7603b8b354576e0021a3f0a593b75b46'
        '88ea84a5affa0d59a613d3806b01912f2728f7f995ee957754a77d8ad3b44033e1bec452d2bb9ac7a79fc6aba1aaee1d452d2ca3fecdd2d1c953d334cbd3beb3'
        '0449ffab9ecf7183253cfb56c7bf489ca6f0a2002f96caa37f2cdb9c77e51e7f8561589e5179496cfb6760b1e8c34a5aefcce4fe0790cab81db3409582a2c835'
        'abafa39e57cf04396b841833215aca427655dd3b56ebc260b8a57d6376360b31a4b1d4493da76ec4dc0129939ab9e23cada70dd6f49e647f02bce12c81f6451a'
        'a7449cb77ce47e09177290ffbb99c29c6695177464eb4c8902b605c9edc2bd6288c8dc741b3c772274c2e204c55380b3c37204419c6341c2aaaa30ccb776e2f3'
        '8eba2f66280defcc930424d695baff297cff32e91e73f01210bb3f26389ea9e93b4b4d9e2c5a5a048756eff219d51c3fbf3f05690c3c984afcc32c3928df91aa'
        '80da2c341d8564a47bc460fcdaf9196ac3bb77f0f2ba56bd71089e80e7481728a3ccbdcfcbc3bf70a9c9e5d9d9b01f2ca6615b67c7ab61003808ce00f6545ba3'
        'b8a64accada87ee5be989c5307805610c9b5c0327bc107aab237ac3225dd9e4c51b6c79a2a7de15fe187d3c32d7cbe1c462f9b0e9fb5d5a55a74236c7061e96e'
        '85aeb5920ee5879848be4057324153a077fe907bed527ed8f9b80a3c5ee1ef64786f63ee2999f5ba74e80a43e99ded3280ce27759c1f7b73259a6e2b5e584aa8'
        '651de880cefd51665d854414c451cc80a33ed8f34e7559a95514abd81a2f58348c37dd75f272468eefd56562ba8c99093a6dd9af3ea57796a9db15164a40eda3'
        '2cdcf9ab03eb92f384caf1a2d90f82c75f880cb6286811e83217c883e421c116e7844ca193a010dc35e12eec46ede3663171a2f45f660ef5a8be95c474f61bfc'
        'f830baa8e9d2f2d844520ef3199a7ac62913afb016d40028d99865ba5c6143c08aa8cec9322a67d808fa526954a78416c90cf35ef31cc8dc4dec64950f58adfd'
        '6ce1b6808b48ba0e64a07d2ff84f0283a7b172e470c8b934ab8824afe2eaf6322927807a985f4a333544f20743f39d75f7b83591ae885fcabb344f6f2476ef74'
        '8cd8393b544a389f3d29465d9b817495e6fb7a8706ea967d0785688fbdeb393d0856c71deeeeca623c374bcbc85708733aab6a2f985417e5e1b1936ae7b1d4f3'
        '7cae5e42b6e16f3c4bf64dca3c7573c1b552424ff70bb6da0a21f121b53b2546b239c87953a090cd90f46a1c3c124e2fe19c560b1830b11334f8e64c92fb614d'
        '4c178d330117886848d232372a25ecf5cac46ad48a6fed580957d295eb1c4266836f4f807593d381f9089b2078c4185ba972f697ab353a850ebf35b6f140a4ac'
        '74a51f04237fba3caa25b2e0d49659f2e8330ce82288de866943d06b53690f31d48a77a4dd2e57db1f435b715fbca792268f2e191ffb59e57170d327ed41ac0a'
        '4a1724784d6b4f113e8c1954d399d07adc941a2e992e1c95ab38dbc5c31940e90ff4cec51d22da3bf971880817b4356e473747303146c2ab1be55ee4565aca41'
        '209387731490549d7b3d546ab149cea22e0ea1291356884f358cd87ca7d5425ca9a72f6f2cb7af46956634ffdb1a61d1ebfbfdbb5a2fc9fdc26d29acdc2ab0c0'
        '83d5a89f14ff8d79f90e677def2f58b1a8a0430ec16bbe3865315b63b3702e699bae157235e70a4c613e84f05b0f7ecf8de4ecef789cb8146edfbe92020c89f0'
        '60fac0fd3c098c8a38f634372b889c4ac7d2d61f1e08fd79b6216ee6a7116cadc06b974ab2ea5efc74801a9f4a8ad029dde973d1494f6467c57ac860be64acad'
        'b41ce5db19de2f4a5857debe31560b7b8216412e5df795032363839429f732b2d2359b3679a795c55a997913588f7d495c300df402529317ef2d03de24a74273'
        'ccf74105e4268eaa35ba2a79b21c89ea5ce22f5d23c297688f5731681926536cfe0f430347fb6e6e70cac8110c7c64ca944b696b0248796434cf667db171e058'
        '92cde696eec00e6758b58e73e8bc60ad1a73bb2a18d4fdfd24a19b5be715305a047943a02d94a9703c101ca0c769dbeb816f1f28809345bae0fec42fbc27bb34'
        '1d54ef96ff6875878ac6a6992de7e23a7b98cb5b68d7e444c4f02a6628f657ad26efc757fbeaff34fc89d41fa440d8b57bd0eb437a9d04ad1e06a31ba148061c'
        'ce82294e480ad42f0001c799fd8131b60024b6097653f3c57564c75e54596616e376f0d7f1cf4e54d8c302a61ef164b4323f795bfa19b2c13ab9e927d37f1600'
        'd006a51f306a1397c14111788a23029a894e223a196649cac476acab761479db543bf4537ed5a2f4173ec94af04874b521a1d598ed8e98406cc2cf526d8e0083'
        '0cb9f39fd0b87e40bbce50ec7e834803bd0d28ff3c5ad25d2542498cfc5b625e7fc20880e34d325e05c51f411cf91721fe6b5a03565686be6cd6fe88772f80d0'
        'f25f01c5b27dced202fe76c1717b9eaec65dfa5f28db1910529f60f5ec21cc89c1a15df26c2dd09066a0d89e3f7d87c790e7886c3c2f0978a25f5ec7d1236099'
        'e3302d903d053f25aa666d572f74a8bbd3b65dde40eedcbf46e537ceb2294ac22b3772087fce04c4a780c2f18e855179c6ddc8af12d72a89b82957ce09deb52f'
        '4bd44cbe85c53902b8a360509703e3d38e8a5da75dd2c534a77f03ce6440632f6c83c92939069c60473c88ffb3abab0fbf11e39271f44f813b9f6432ea5f9a6b'
        '6f78478f642c18101e9cd24a0c693abaa1348bb5c730c9d29b8f80d6309aa4bf16f6672dbc36161875db81a071256a0a388769c96810a7c67e3687ec750605d8'
        'e0a9e8f1129650208f7a5a37680091a6d2abaa60f5d4fd7fc691854d49c9f59317ca18dbe764cb05cacd4a2a95de702bbdd072571862ee0b27bd8df3be7a5764'
        'a5e8bca3ccec2990098e8cf1c504ce6bec03cecef03b0450a4396d5b1e0ffc4e91592f40c3e389eea74fc53114cce0f2c1d2237a779e5ec7e6c12b2863d6c731'
        'c0ccf5af2fbf0c9bb59bd226ce17084658cbe6bc859bd8a76c292845dbf57679ac08de339d4cb90736bfa48fcc9f2f734c3fadaa5b91b0fc6e58d157c848a328'
        'f10ba62a41e6c0f627b501b907c879ae66e480e90e2ca324d09ba084a6fc0f25e33b384847558f00feb992efcba44eb355ed202351597c5a10a3480bd659f88d'
        'a408f468a4a0b0fea78b3c1cc31be22fc913c0a27052b08e9dde523135ed473008bba6a0245d64ed9863431c3905f6e7663d19e3aa9ba769053a160bcb8bcbfa'
        'e3799c733e213f336df765fc1b4f33eb695b07998c9752fdd40d59e7fa687be415d3f48b9964b38810892f247d681df6ba33117f36342cf61fe03f8aa61320e9')

prepare() {
#  cd "${_pkgname}-${_pkgver}"
  cd "${_pkgname}-${pkgver}"

  # Assorted workarounds
  sed \
    -e 's/-Werror//' \
    -e 's/ncursesw5-config/ncursesw6-config/' \
    -e 's/shell git/shell false/' \
    -i Makefile

  # Disable default optimizations
  sed \
    -e 's/-Os/-O3/' \
    -e 's/-O0/-O3/' \
    -e 's/-Og/-O3/' \
    -e 's/CXXFLAGS += -ffast-math/#CXXFLAGS += -ffast-math/' \
    -i Makefile

  # Remove non-existent flags generating warnings
  sed \
    -e 's/-Wzero-as-null-pointer-constant \\/-Wzero-as-null-pointer-constant/' \
    -e 's/-Wno-range-loop-analysis/#-Wno-range-loop-analysis/' \
    -e 's/-Wno-unknown-warning-option/#-Wno-unknown-warning-option/' \
    -i Makefile

  # Fix filenames and paths
  sed -i 's|cataclysm-dda|cataclysm-bn|' CMakeLists.txt
  sed -i 's|TARGET_NAME = cataclysm|TARGET_NAME = cataclysm-bn|' Makefile
  sed -i 's|cataclysm.a|cataclysm-bn.a|' Makefile
  sed -i 's|cataclysm.a|cataclysm-bn.a|' tests/Makefile
  sed -i 's|cataclysm-dda|cataclysm-bn|' src/path_info.cpp

  # Fix version
#  sed -i 's|VERSION = unstable|VERSION = "0.2-experimental 2023-10-04-0030"|' Makefile
  sed -i 's|VERSION = unstable|VERSION = "0.5.2"|' Makefile


  # # # Hotfixes
  echo "Applying hotfixes"

  # Fix monsters attacking idle mechsuits
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/hotfix-01_fix-monsters-ignore-mechs-that-aren-t-being-piloted-.patch

  # Fix containers being deleted when reloading empties a container
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/hotfix-02_fix-Prevents-reloading-from-deleting-containers-4104.patch

  # Fix overlapping text when looking around
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/hotfix-03_fix-Fix-overlapping-text-in-look-around.-4156.patch

  # Fix safe reference error on throwing explosives. fix for error on save and quit still MIA.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/hotfix-04_fix-uaf-in-safe-references-4165.patch

  # Fix zombies having a psychic sense of smell
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/hotfix-05_feat-balance-closed-glass-windows-block-scent-4114.patch

  # Fix player being given a wakeup from noise notice when it happens to npcs
  # also reduces npc 'move please' chat spam when following the player
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/hotfix-06_fix-two-cases-of-NPCs-printing-messages-in-odd-conte.patch

  # Fix card readers not despawning riot turrets
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/hotfix-07_fix-allow-card-readers-to-despawn-riot-turrets-too-4.patch

  # Fix npcs detecting explosives using psychic powers
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/hotfix-09_fix-NPCs-no-longer-magically-aware-of-explosives-the.patch


  # # Adjust default mods
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-20_fix-default-mods.patch


  # # # Reverts
  echo "Applying revert patches"

  # Revert craftable smokeless gunpowder. Not realistic and makes black powder obsolete.
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-28_feat-content-semi-plausible-smokeless-gunpowder-reci.patch

  # Revert hard capping skills at level 10 for now
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-23_fix-balance-no-more-EXP-gain-when-a-skill-is-maxed-o.patch

  # # Nope, no biodiesel in petrol engines. Altered patch to allow ethanol instead.
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-22_feat-content-Biodiesel-Fuel-for-Gasoline-Engines-371.patch

  # # I don't get why people are so upset about this guy.
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-21_fix-Erased-the-npc-Alonso-from-history-the-game-3582.patch

  # # Revert easy-mode limb mending and related commits
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-27_fix-NPCs-keep-their-splints-on-3589.patch
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-26_fix-npc-splints-and-clean-up-iterator-errors-3592.patch
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-24_fix-repair-nanobots-not-working-at-all-on-broken-lim.patch
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-20_Fix-tidy-warnings-3310.patch
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-19_Fix-Repair-Nanobots-3308.patch
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-18-Simplify-broken-limb-mending-3054.patch

  # # More reverts for generic night vision
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-15_Fix-mutant-scenarios-adding-an-obsoleted-trait-2929.patch

  # # Yet more bad ammo ideas
  # This prevents sorting 223 and 556 ammo into different piles as sorting is assumed wildcard.
  # And a second for 308 and 762.
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-13_fix-i18n-metric-bullets-part-2-rename-.308-7.62x51mm.patch
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-12_fix-i18n-metric-bullets-part-1-rename-.223-5.56x45mm.patch

  # Needless item removal
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-11_Obsoletion-and-removal-of-useless-bathroom-fluff-247.patch

  # Revert ammo reblance 6,7,8
  #patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-10_still-another-ammo-patch-to-undo.patch
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-09_undo-yet-more-ammo-balancing.patch
  #patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-08_undo-rifle-balance-pass.patch

  # Fix the duplication of 4570_bp
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-07.5_Use-bismuth-in-recipes-related-ammo-fixes-2952.patch

  # Revert removal of reloaded ammunition.
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-07_Remove-handload-quality-distinction-1481.patch

  # Revert Hub 01 basement removal.
  patch -NREp1 --no-backup-if-mismatch -i "$srcdir"/revert-06_Obsolete-useless-hub01-basement-1457.patch

  # Revert the removal of book chapters and the generic overhaul of them.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/revert-02_revert-book-revamp.patch
  rm -f data/json/items/book/bloat.json

  # Revert generic night vision.
  patch -NRp1 --no-backup-if-mismatch -i "$srcdir"/revert-03_generic-nv.patch

  # Revert telescopic lenses.
  patch -NRp1 --no-backup-if-mismatch -i "$srcdir"/revert-04_telescopic-lenses.patch

  # Revert the Infection Immune Trait and Revert Infection Resistant to as before. Also keep Truthteller.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/revert-01_removed-traits.patch


  # # # Various fixes for bugs I came across
  # # Ammo fixes
  echo "Applying ammo fixes"
  # Fix mulitple inconsistent ammunition names and handloaded status.
  # Offladed to ammo rebalance mod
  #patch -Np1 --no-backup-if-mismatch -i "$srcdir"/ammo-01_inconsistent-ammo-names.patch

  # Fix black powder scrap shot not being flagged as black powder.
  # Offloaded to ammo rebalance mod
  #patch -Np1 --no-backup-if-mismatch -i "$srcdir"/ammo-06_fix-bp-scrap-not-being-bp.patch

  # Fix ammo ordering so as to not prevent those items being modded:
  # Having copy-from items occuring earlier in a json than the item being copied from prevents items based on it being modified.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/ammo-10_ammo-order-fix.patch

  # Fix 40mm round volume:
  # Changing abstracts with mods does not seem to work, so here this is.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/ammo-11_fix-volume-40mm.patch

  # Set a fixed loudness for 20x66mm shotgun shells like that of other shotguns:
  # Other shotguns have fixed loudness to work around how the short range causes the loudness value to be far lower than one would otherwise expect.
  # Abstract change, so this cannot be fixed by a mod.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/ammo-12_fix-20x66mm-loudness.patch

  # Change reloaded_50bmg to be based on 50bmg:
  # The id and description make it pretty clear that reloaded_50bmg is not supposed to be based on Match rounds.
  # This is fixed here instead of a mod so as to prevent copy-from dependency loops.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/ammo-13_fix-reloaded-50bmg.patch


  # # armor fixes
  echo "Applying armor fixes"
  # Fix Ankle Ammo Pouch to not look like a backpack:
  # SDG added a tile for ammo pouches to bypass this bug, but this fix still makes sense.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/armor-01_ankle-ammo-pouch-is-not-a-backpack.patch

  # Fix fingerless survivor gloves losing base warmth:
  # They lose warmth already from the lack of coverage, no need to double up.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/armor-02_fix-survivor-fingerless-gloves-warmth.patch


  # # bionics fixes
  echo "Applying bionic fixes"
  # Fix npc not being able to install some additional CBMs:
  #  ie, soporific inducer, gasoline fuel cell, enhanced hearing, surgical scalpels.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/bionics-01_npc-can-use-more-bionics.patch


  # # faction fixes
  echo "Applying faction fixes"
  # Backport the factions.json updates from DDA
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/faction-01_more-factions.patch

  # Fix faction food supply being calculated at 288 calories per person instead of 2500.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/faction-03_fix-food-supply-calculations.patch


  # # faction camp fixes
  echo "Applying faction camp fixes"
  # cur_level is set to -1 on all modern basecamps. Remove the recruiting penalty this legacy variable inadvertently induces.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/factioncamp-01_remove-legacy-recruiting-penalty.patch


  # # food fixes
  echo "Applying food fixes"
  # Fix several foods not being marked as the correct material:
  # This prevents odd outcomes such as carnivores drinking almond/soy milk and eating peanut butter.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/foods-01_fix-food-materials.patch

  # Fix several foods using unclear naming:
  # Rename can_corn from corn to canned corn to make its limited use in recipes more clear.
  # Fix pluralization of canned beans to also be canned beans.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/foods-02_fix-food-naming.patch

  # Fix several mutant components lacking the BAD_TASTE flag:
  # If raw mutant meat is flagged as disgusting, raw mutant fat must be just awful.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/foods-03_fix-mutant-bad-taste.patch

  # Allow canned corn to be used as a veggy_any requirement:
  # Canned corn was pretty much useless beyond making fish soup despite being a perfectly fine cooked vegetable.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/foods-04_allow-canned-corn-as-veggy.patch

  # Fix some foods lacking price_postapoc values:
  # Fruit slices were several times as valuable as canned fruit.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/foods-05_fix-missing-price-postapoc.patch

  # Fix several sealed foods spawning only half full:
  # And one spawning double-full.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/foods-06_sealed-foods-not-full.patch


  # # itemgroups fixes
  echo "Applying itemgroup fixes"
  # Stop police and SWAT carrying 4.6mm magazines despite having no compatible weapons:
  # The H&K UCP was removed from the base game some time ago.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/itemgroups-01_hk46-is-milspec.patch

  # Fix the pepperjack beef and burrito bowl MREs never dropping:
  # They weren't in the itemgroups for MREs or soldier class.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/itemgroups-02_add-missing-mre.patch

  # Fix items in unlooted, unused lockers and cabinets missing batteries:
  # They need to be marked as the battery contained inside the item.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/itemgroups-03_fix-shelter-batteries.patch


  # # medicine fixes
  echo "Applying medicine fixes"
  # Add -4 health to antibiotics:
  # weak are -2, strong are -10, this feels like a nice middle ground.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/meds-01_antibiotics-unhealthy.patch


  # # missions fixes
  echo "Applying migration fixes"
  # Remove UCP from migration list:
  # Removing item migrations with mods does not seem to work, so here this is.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/migration-01_remove-ucp.patch


  # # missions fixes
  echo "Applying mission fixes"
  # Fix Typos:
  # Foraging encounter has inconsistent monster references. Change all to cougar.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/mission-01_typos.patch

  # Move the gunslinger quest in front of the zombie horde quest:
  # The context of the horde mission suggests that the player should obtain another follower before attempting it,
  # thus it makes more sense to have the obtain gunslinger mission occur before, not after. Simultaneously makes even more sense, but the game doesn't support it.
  # Note: The gunslinger mission is prone to errors. Save before accepting it, make sure you are on ground level, and increase the search_range if it still fails.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/mission-02_reorder-gunslinger-quest.patch


  # # monster fixes
  echo "Applying monster fixes"
  # Prefix medical zombies with "zombie" like other zombies:
  # It just felt weird seeing "nurse" in the enemy list.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/monsters-01_medical-zombies-called-zombies.patch


  # # mutation fixes
  echo "Applying mutation fixes"
  # Light Step feels too powerful in Bright Nights.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/mutations-01_nerf-lightstep.patch

  # Fix Evacuee 3 background 3 being player visible:
  # It was missing "player_display": false
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/mutations-02_fix-evac3-background-visible.patch


  # # npc fixes
  echo "Applying NPC fixes"
  # Port the updates to Isherwood Farm from DDA
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-01_isherwood-update.patch

  # Port the updates to Tacoma Commune from DDA
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-02_tacoma-update.patch

  # Port the updates to New England Church Community from DDA
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-03_godco-update.patch

  # Port the updates to prison and island prison from DDA
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-04_island-prison-update.patch

  # Port the updates to kindred from DDA
  rm data/json/npcs/NPC_Brigitte_LaCroix.json
  patch -NEp1 --no-backup-if-mismatch -i "$srcdir"/npc-05_kindred-update.patch

  # Port the updates to Mr Lapin from DDA
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-06_lapin-update.patch

  # Port the lighthouse family from DDA
  # Hack in some effects to use as timers and probe NPC mechanic skill.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-07_lighthouse-family_v2.patch

  # Update the Tacoma Nurse to buy almost every non-dangerous, non-electrical, and non-expensive medicine.
  # Also remove acceptance for various tools that are not correctly taken, such as first aid kits.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-08_nurse-takes-more-meds.patch

  # Update the FMC broker to buy most preserved foods.
  # Also update the dialogue to specify that he buys more types.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-09_broker-takes-more-foods.patch

  # Port the bunker merchant from DDA
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-10_bunker-merchant.patch

  # Fix npcs failing to reload activated gas masks:
  # Most masks lacked a "charges_per_use: 1" field, required for npcs to know they can reload it.
  # They still won't activate a fresh mask on their own though. :/
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-11_npcs-reload-gas-mask.patch

  # Reduce Eddie Isherwood mission from requiring 1000 clay down to 100:
  # 1000 units of clay is such an enormous amount compared to the previous 100 sand,
  # I can only reason it is a typo.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-12_fix-eddie-requiring-1000-clay.patch

  # Assorted typos in NPC dialogue.
  # Fix Jack Isherwood mission listing 10 jars, when it is actually 20.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/npc-20_dialogue-fixes.patch


  # # recipe fixes
  echo "Applying recipe fixes"
  # Fix reloaded 45-70 rounds and reloaded dragon shot not allowing dismantling when every other non-caseless round does.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/recipes-01_4570-dragon-can-be-dismantled.patch


  # # terrain and overmap fixes
  echo "Applying terrain and overmap fixes"
  # Fix some doors being unusable by npcs (incorrect door flag):
  # The DOOR flag is for terrain that can be opened, not those already open.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/terrain-02_fix-doors-for-npcs.patch

  # Fix missing floor in the tacoma clinic:
  # The hospital is still a mess. :/
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/terrain-03_tacoma-clinic-add-missing-floor.patch

  # Fix lumbermill gasoline being spilled instead of being inside the gas pump:
  # The gas pump was placed on top of a tile that didn't allow items inside, causing the gasoline to be shunted to the next valid one.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/terrain-04_lumbermill-gasoline-not-spilled.patch

  # Re-hide something that feels like spoilers.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/terrain-07_rehide-redacted.patch

  # Fix npcs unable to drink from firestation and shelter basecamps wells:
  # They were missing the water_well blueprint_provides.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/terrain-09_make-firestation-shelter-wells-npc-drinkable.patch

  # Fix military base minefield entrance rotation:
  # Both sides use the same tile, but it was incorrectly rotated 180 degrees. Fixed to 270 degrees.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/terrain-10_fix-milbase_minefield.patch

  # Fix up several typos, missing symbols, odd naming, and many extras lacking map notes support in map extras:
  # More choice is better than less. You can disable undesired map notes in the map notes settings menu.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/terrain-11_clean-up-map-extras.patch

  # Fix mismatched mapgen palettes:
  # Fixes light machinery incorrectly appearing under various lab furniture
  # All said items define C as the tile in question, but C is already in lab_palette as t_machinery_electronic.
  # Changed all such C to K since it was unused in either lab_palette or lab_loot_home_office.
  # Also fixes sandbag walls at fema camps having indoor flooring underneath.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/terrain-13_fix-mapgen-palettes.patch


  # # tool fixes
  echo "Applying tool fixes"
  # Mark the foldable plastic bottle and steel water bottle as containers:
  # Being counted as tools didn't seem to fit their role.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/tools-01_foldable-bottle-is-container.patch

  # Fix electric shears not using batteries nor charging via UPS:
  # Item was unusable without this patch.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/tools-03_shears-use-light-battery.patch


  # # vehicle fixes
  echo "Applying vehicle fixes"
  # Replace the portable generator twin engine with a large 1 cylinder:
  # This way it can actually function as is.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/vehicles-01_portable-generator-engine.patch

  # Rename the FBI Car:
  # The stock name was clearly a typo of some sort.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/vehicles-02_fix-fbi-car-name.patch

  # Fix the black box to actually be installable:
  # No tool provided screwing 3 and wrenching 3.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/vehicles-03_black-box-can-be-installed.patch


  # # weapon fixes
  echo "Applying weapon fixes"
  # Fix the USP45 handgun not being modifiable:
  # It uses copy-from usp_9mm that loads later, which prevented modifying it.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/weapon-02_Fix-usp45-load-order.patch


  # # Uncategorized for now
  echo "Applying uncategorized fixes"

  # Add price_postapoc to a number of items that did not have one set.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/etc-02_add-missing-price-postapoc.patch

  # Convert a number of items to abstracts:
  # From the usage, these are intended to be abstracts but have not yet been converted from legacy items.
  # This fixes some erroneous weapon listings in custom martial arts.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/etc-03_fix-abstracts.patch


  # # # Various other fixes for bugs I came across that modify src
  echo "Applying source code fixes"
  # Fix radio, e-ink reader music, tactical tonfa not working with UPS.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-01_radio-can-use-ups.patch

  # Fix ammo loudness mulitplying by six instead of two.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-02_ammo-loudness-ap-times-2.patch

  # Fix smoker racks not accepting bionic firestarter.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-03_allow-bio-firestarter-on-smoker.patch

  # Fix Non-Player facton NPCs from becoming sleep deprived.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-04_stop-non-faction-npc-sleep-depirvation.patch

  # Fix Non-Player facton NPCs from becoming malnourished.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-05_stop-non-faction-npc-malnourishment.patch

  # Fix NPCs preferring tables to cots or woodstoves to the floor.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-06_stop-sleeping-on-tables.patch

  # Allow the hacker_laptop to utilize the extra functions.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-07_allow-hacker-laptop.patch

  # Expand the overmap tiles for the miltiary base to be less MMMM
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-08_more-military-base-overmap.patch

  # Allow npcs to pull food from the camp larder at the full range of tiles camp actions can be assigned from:
  # Should allow bases larger than 3x3 to have less food micromanagment for NPCs.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-09_npc-eat-from-further-camp.patch

  # Revert removal of half calorie consumption while sleeping:
  # Managing the food supply of more than a few NPCs in BN is extremely difficult compared to DDA.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-10_reduced-kcal-during-sleep.patch

  # Fix tacoma crop overseer failing to detect player current cash:
  # The two plot purchasing functions use the seemingly obsolete player_character.cash instead of g->u.cash
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-11_fix-tacoma-farmfield.patch

  # Reduce the mechanical skill experience from lockpicking:
  # With lock_roll being 1-120 and used in place of difficulty,
  # it often caused a level up with every lock, even at very high skill levels
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-12_lower-lockpicking-experience.patch

  # Allow military searchlights to be powered by the plutonium generator grid furniture:
  # Searchlights check for a nearby plutonium generator terrain to function,
  # but the function was never updated to include the new grid furniture version.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-13_searchlights-with-plut-gen-furn.patch

  # Fix calculation of npc npc_melee assessment:
  # dist == 1 always fails, but dist <= 1 works.
  # Without this, npcs in melee range will never take any action and be swiftly slain.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/src-14_fix-npc_melee-calculations.patch


  # # # Additional changes
  echo "Applying vampirism patch"
  # Add vampire mutation lines and modify a number of functions to facilitate these traits.
  patch -Np1 --no-backup-if-mismatch -i "$srcdir"/vampirism.patch
}

build() {
#  cd "${_pkgname}-${_pkgver}"
  cd "${_pkgname}-${pkgver}"

  #export CFLAGS="$CFLAGS -fPIE"
  export CXXFLAGS="$CXXFLAGS -fPIE"
  export LDFLAGS="$LDFLAGS,-pie"

  # Prevent segfaults when examine tile->search returns no results.
  #export CXXFLAGS="$(echo $CXXFLAGS | sed -i 's/-Wp,-D_GLIBCXX_ASSERTIONS//' - )" # No longer works
  export CXXFLAGS="$(echo $CXXFLAGS | sed 's/-Wp,-D_GLIBCXX_ASSERTIONS//')"
  #echo $CXXFLAGS

  make PREFIX=/usr RELEASE=1 USE_XDG_DIR=1 BACKTRACE=0 LOCALIZE=1 LANGUAGES=all RUNTESTS=0 VERBOSE=1 PCH=0 LUA=0 CCACHE=0
  make PREFIX=/usr RELEASE=1 USE_XDG_DIR=1 BACKTRACE=0 LOCALIZE=1 LANGUAGES=all RUNTESTS=0 VERBOSE=1 PCH=0 LUA=0 CCACHE=0 TILES=1 SOUND=1
  ./lang/compile_mo.sh
}

package_cataclysm-bn() {
#  cd "${_pkgname}-${_pkgver}"
  cd "${_pkgname}-${pkgver}"

  make DESTDIR="$pkgdir" PREFIX="/usr" RELEASE=1 USE_HOME_DIR=1 LOCALIZE=1 LANGUAGES=all RUNTESTS=0 VERBOSE=1 PCH=0 LUA=0 CCACHE=0 install

  # Docs
  install -d "$pkgdir/usr/share/doc/cataclysm-bn"
  cp --reflink -r doc/* "$pkgdir/usr/share/doc/cataclysm-bn"

  # Fix tileset readme being duplicated in curses package
  rm "$pkgdir/usr/share/cataclysm-bn/json/external_tileset/README.md"

  # License
  install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  # Languages
  cd lang/mo
  for i in *; do
    install -d "${pkgdir}/usr/share/locale/${i}/LC_MESSAGES"
    cp --reflink "${i}/LC_MESSAGES/cataclysm-bn.mo" "${pkgdir}/usr/share/locale/${i}/LC_MESSAGES"
  done

  # Help
  cd ./../..
  cp -r --reflink --no-preserve=ownership "./data/help" "${pkgdir}/usr/share/${pkgname}/"

#  install -Dm644 "${srcdir}/${pkgname}.desktop" "${pkgdir}/usr/share/applications/${pkgname}.desktop"
}

package_cataclysm-bn-tiles() {
  pkgdesc="A graphical post-apocalyptic roguelike."
  depends=('cataclysm-bn' 'sdl2_image' 'sdl2_ttf' 'freetype2' 'sdl2_mixer')
#  cd "${_pkgname}-${_pkgver}"
  cd "${_pkgname}-${pkgver}"

  make DESTDIR="$pkgdir" PREFIX="/usr" RELEASE=1 LOCALIZE=1 LANGUAGES=all RUNTESTS=0 VERBOSE=1 PCH=0 LUA=0 CCACHE=0 TILES=1 SOUND=1 install


  # Icon
  #install -D 'data/osx/AppIcon.iconset/icon_128x128.png' "$pkgdir/usr/share/icons/hicolor/128x128/apps/$pkgname.png"
  #install -D 'data/osx/AppIcon.iconset/icon_128x128.png' "$pkgdir/usr/share/pixmaps/$pkgname.png"
  install -Dm644 "${srcdir}/icon_128x128.png" "$pkgdir/usr/share/icons/hicolor/128x128/apps/$pkgname.png"
  install -Dm644 "${srcdir}/icon_128x128.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
  install -Dm644 "${srcdir}/$pkgname.desktop" "${pkgdir}/usr/share/applications/$pkgname.desktop"

  install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"


  # Remove unmaintained UDP tileset
  # Use my forked cataclysm-bn-tileset package for a working UDP tileset
  rm -rf "$pkgdir/usr/share/cataclysm-bn/gfx/MSX++UnDeadPeopleEdition"


  # hack: remove overlapping files
  cd "$pkgdir/../cataclysm-bn"
  find . -type f -exec rm -f "$pkgdir"/{} \;
  cd "$pkgdir"
  find . -type d -empty -delete

  # Fix mapgen readme being duplicated in tileset package
  rm "$pkgdir/usr/share/cataclysm-bn/json/mapgen/lab/README.md"
}