-
Notifications
You must be signed in to change notification settings - Fork 6
/
region.hpp
1423 lines (1039 loc) · 39 KB
/
region.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// region.hpp
// Undiscovered Worlds
//
// Created by Jonathan Hill on 27/10/2019.
//
// Please see functions.hpp for notes.
#ifndef region_hpp
#define region_hpp
#include <stdio.h>
#include <string>
#include <iostream>
#define RARRAYWIDTH 1000
#define RARRAYHEIGHT 1000
#define STRIPWIDTH 6
using namespace std;
class region
{
public:
region(); // constructor
~region(); // destructor
// Accessor functions
inline int tilewidth() const; // tilewidth
inline void settilewidth(int amount);
int tileheight() const; // tileheight
void settileheight(int amount);
int centreface() const; // centreface
void setcentreface(int amount);
int centrex() const; // centrex
void setcentrex(int amount);
int centrey() const; // centrey
void setcentrey(int amount);
int leftx() const; // leftx
void setleftx(int amount);
int lefty() const; // lefty
void setlefty(int amount);
int rwidth() const; // rwidth
int rheight() const; // rheight
int rstart() const; // rstart
void setrstart(int amount);
int regwidthbegin() const; // regwidthbegin
int regwidthend() const; // regwidthend
int regheightbegin() const; // regheightbegin
int regheightend() const; // regheightend
int sealevel() const; // sea level
void setsealevel(int amount);
int pixelmetres() const; // pixelmetres
void setpixelmetres(int amount);
int gridlines() const; // grid lines
void setgridlines(int amount);
// Accessor functions for location-specific information
int map(int x, int y) const; // terrain elevation
void setmap(int, int y, int amount);
int surface(int x, int y) const; // surface elevation (terrain or lake, whichever is higher)
bool sea(int x, int y) const; // whether this is sea or not
void longitude(int x, int xx, int tilex, int width, int& degrees, int& minutes, int& seconds, bool& negative) const; // longitude of this point
void latitude(int y, int yy, int tiley, int height, int& degrees, int& minutes, int& seconds, bool& negative) const; // latitude of this point
bool outline(int x, int y) const; // whether this is coast, next to sea
int jantemp(int x, int y) const; // jan temperature
void setjantemp(int x, int y, int amount);
int jultemp(int x, int y) const; // jul temperature
void setjultemp(int x, int y, int amount);
int aprtemp(int x, int y, int yy, int globalheight, float tilt, float eccentricity, int perihelion) const; // April temperature
int octtemp(int x, int y, int yy, int globalheight, float tilt, float eccentricity, int perihelion) const; // October temperature
int maxtemp(int x, int y) const; // maximum temperature
void setmaxtemp(int x, int y, int amount);
int mintemp(int x, int y) const; // minimum temperature
void setmintemp(int x, int y, int amount);
/*
int extrajantemp(int x, int y) const; // jan temperature for map drawing
void setextrajantemp(int x, int y, int amount);
int extrajultemp(int x, int y) const; // jul temperature for map drawing
void setextrajultemp(int x, int y, int amount);
int extramaxtemp(int x, int y) const; // maximum temperature for map drawing
void setextramaxtemp(int x, int y, int amount);
int extramintemp(int x, int y) const; // minimum temperature for map drawing
void setextramintemp(int x, int y, int amount);
*/
int avetemp(int x, int y) const; // average temperature
int janrain(int x, int y) const; // jan precipitation
void setjanrain(int x, int y, int amount);
int julrain(int x, int y) const; // jul precipitation
void setjulrain(int x, int y, int amount);
int aprrain(int x, int y) const; // April precipitation
int octrain(int x, int y) const; // October precipitation
int summerrain(int x, int y) const; // summer precipitation
void setsummerrain(int x, int y, int amount);
int winterrain(int x, int y) const; // winter precipitation
void setwinterrain(int x, int y, int amount);
int averain(int x, int y) const; // average precipitation
int climate(int x, int y) const; // climate type
void setclimate(int x, int y, int amount);
int seaice(int x, int y) const; // sea ice
void setseaice(int x, int y, int amount);
int riverdir(int x, int y) const; // river flow direction
void setriverdir(int x, int y, int amount);
int riverjan(int x, int y) const; // January river flow volume
void setriverjan(int x, int y, int amount);
int riverjul(int x, int y) const; // July river flow volume
void setriverjul(int x, int y, int amount);
int riveraveflow(int x, int y) const; // average river flow
int fakedir(int x, int y) const; // fake river flow direction
void setfakedir(int x, int y, int amount);
int fakejan(int x, int y) const; // January fake river flow volume
void setfakejan(int x, int y, int amount);
int fakejul(int x, int y) const; // July fake river flow volume
void setfakejul(int x, int y, int amount);
int fakeaveflow(int x, int y) const; // average fake river flow
int lakesurface(int x, int y) const; // lake surface elevation
void setlakesurface(int x, int y, int amount);
int truelake(int x, int y) const; // whether this is a true lake
int special(int x, int y) const; // special features
void setspecial(int x, int y, int amount);
int deltadir(int x, int y) const; // delta branch flow direction (reversed)
void setdeltadir(int x, int y, int amount);
int deltajan(int x, int y) const; // January delta branch flow volume
void setdeltajan(int x, int y, int amount);
int deltajul(int x, int y) const; // July delta branch flow volume
void setdeltajul(int x, int y, int amount);
int waterdir(int x, int y, bool delta) const; // river/delta flow direction
void setwaterdir(int x, int y, bool delta, int amount);
int waterjan(int x, int y, bool delta) const; // January river/delta flow volume
void setwaterjan(int x, int y, bool delta, int amount);
int waterjul(int x, int y, bool delta) const; // July river/delta flow volume
void setwaterjul(int x, int y, bool delta, int amount);
float roughness(int x, int y) const; // roughness
void setroughness(int x, int y, float amount);
bool rivervalley(int x, int y) const; // Whether this is a river valley.
int tide(int x, int y) const; // Information about tides
void settide(int x, int y, int amount);
bool mud(int x, int y) const; // Mud flats
void setmud(int x, int y, bool amount);
bool sand(int x, int y) const; // Sandy beach
void setsand(int x, int y, bool amount);
bool shingle(int x, int y) const; // Shingle beach
void setshingle(int x, int y, bool amount);
bool barrierisland(int x, int y) const; // Barrier island
void setbarrierisland(int x, int y, bool amount);
bool mountainsdone(int x, int y) const; // Whether this cell has had mountains applied to it.
void setmountainsdone(int x, int y, bool amount);
bool volcano(int x, int y) const; // Whether this cell is volcanic.
void setvolcano(int x, int y, bool amount);
bool mangrove(int x, int y) const; // Tells whether this point is a mangrove.
int clouds(int x, int y) const; // Clouds
void setclouds(int x, int y, int amount);
//int test(int x, int y) const; // Test array.
//void settest(int x, int y, int amount);
//int test2(int x, int y) const; // Test array 2.
//void settest2(int x, int y, int amount);
//float testfloat(int x, int y) const; // Float test array.
//void settestfloat(int x, int y, float amount);
// Other public functions
void clear(); // Clears all of the maps.
/*
void shiftright(); // Shifts everything in the maps a tile to the right.
void copylefttostrip(); // Copies a line of tiles from the left-hand side of the map onto the strip.
void copyleftfromstrip(); // Copies that line back again onto the map.
*/
private:
// Private variables.
int itstilewidth;
int itstileheight; // Dimensions of the region in tiles.
int itscentreface;
int itscentrex;
int itscentrey; // Location of central tile in global coordinates.
int itsleftx;
int itslefty; // Location of top-left tile in global coordinates.
int itsrwidth;
int itsrheight; // Dimensions of the regional map.
int itsrstart; // Amount to ignore on the edge of the regional map for most purposes.
int itsregwidthbegin; // Amount to ignore on the left of the regional map for creating the images.
int itsregwidthend; // Amount to ignore on the right of the regional map for creating the images.
int itsregheightbegin; // Amount to ignore on the top of the regional map for creating the images.
int itsregheightend; // Amount to ignore on the bottom of the regional map for creating the images.
int itssealevel; // Sea level.
int itspixelmetres; // Number of metres each regional map pixel represents.
bool itsgridlines; // Whether to display grid lines on the map.
short rmap[RARRAYWIDTH][RARRAYHEIGHT];
short rjantempmap[RARRAYWIDTH][RARRAYHEIGHT];
short rjultempmap[RARRAYWIDTH][RARRAYHEIGHT];
//short rextrajantempmap[RARRAYWIDTH][RARRAYHEIGHT];
//short rextrajultempmap[RARRAYWIDTH][RARRAYHEIGHT];
short rjanrainmap[RARRAYWIDTH][RARRAYHEIGHT];
short rjulrainmap[RARRAYWIDTH][RARRAYHEIGHT];
unsigned char rclimatemap[RARRAYWIDTH][RARRAYHEIGHT];
int rlakemap[RARRAYWIDTH][RARRAYHEIGHT];
unsigned char rrivermapdir[RARRAYWIDTH][RARRAYHEIGHT];
int rrivermapjan[RARRAYWIDTH][RARRAYHEIGHT];
int rrivermapjul[RARRAYWIDTH][RARRAYHEIGHT];
short rseaicemap[RARRAYWIDTH][RARRAYHEIGHT];
unsigned char rfakeriversdir[RARRAYWIDTH][RARRAYHEIGHT];
int rfakeriversjan[RARRAYWIDTH][RARRAYHEIGHT];
int rfakeriversjul[RARRAYWIDTH][RARRAYHEIGHT];
unsigned char rspecials[RARRAYWIDTH][RARRAYHEIGHT]; // 140: glacier.
unsigned char rdeltamapdir[RARRAYWIDTH][RARRAYHEIGHT];
int rdeltamapjan[RARRAYWIDTH][RARRAYHEIGHT];
int rdeltamapjul[RARRAYWIDTH][RARRAYHEIGHT];
float rroughnessmap[RARRAYWIDTH][RARRAYHEIGHT];
bool rmountainsdone[RARRAYWIDTH][RARRAYHEIGHT];
bool rvolcanomap[RARRAYWIDTH][RARRAYHEIGHT];
short rtidalmap[RARRAYWIDTH][RARRAYHEIGHT];
bool rmudmap[RARRAYWIDTH][RARRAYHEIGHT];
bool rsandmap[RARRAYWIDTH][RARRAYHEIGHT];
bool rshinglemap[RARRAYWIDTH][RARRAYHEIGHT];
bool rbarrierislandmap[RARRAYWIDTH][RARRAYHEIGHT];
short rclouds[RARRAYWIDTH][RARRAYHEIGHT];
//int testmap[RARRAYWIDTH][RARRAYHEIGHT];
//int testmap2[RARRAYWIDTH][RARRAYHEIGHT];
//float testmapfloat[RARRAYWIDTH][RARRAYHEIGHT];
};
inline int region::tilewidth() const { return itstilewidth; }
inline void region::settilewidth(int amount)
{
itstilewidth = amount;
itsrwidth = amount * 16 + 33;
itsregwidthbegin = 48; //32;
itsregwidthend = itsrwidth - 48; //32;
}
inline int region::tileheight() const { return itstileheight; }
inline void region::settileheight(int amount)
{
itstileheight = amount;
itsrheight = amount * 16 + 33;
itsregheightbegin = 48; //32;
itsregheightend = itsrheight - 48; //32;
}
inline int region::centreface() const { return itscentreface; }
inline void region::setcentreface(int amount)
{
itscentreface = amount;
}
inline int region::centrex() const { return itscentrex; }
inline void region::setcentrex(int amount)
{
itscentrex = amount;
itsleftx = amount - itstilewidth / 2;
}
inline int region::centrey() const { return itscentrey; }
inline void region::setcentrey(int amount)
{
itscentrey = amount;
itslefty = amount - itstileheight / 2;
}
inline int region::leftx() const { return itsleftx; }
inline void region::setleftx(int amount) { itsleftx = amount; }
inline int region::lefty() const { return itslefty; }
inline void region::setlefty(int amount) { itslefty = amount; }
inline int region::rwidth() const { return itsrwidth; }
inline int region::rheight() const { return itsrheight; }
inline int region::rstart() const { return itsrstart; }
inline void region::setrstart(int amount) { itsrstart = amount; }
inline int region::regwidthbegin() const { return itsregwidthbegin; }
inline int region::regwidthend() const { return itsregwidthend; }
inline int region::regheightbegin() const { return itsregheightbegin; }
inline int region::regheightend() const { return itsregheightend; }
inline int region::sealevel() const { return itssealevel; }
inline void region::setsealevel(int amount) { itssealevel = amount; }
inline int region::pixelmetres() const { return itspixelmetres; }
inline void region::setpixelmetres(int amount) { itspixelmetres = amount; }
inline int region::gridlines() const { return itsgridlines; }
inline void region::setgridlines(int amount) { itsgridlines = amount; }
// Accessor functions for location-specific information
inline int region::map(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)rmap[x][y];
}
inline void region::setmap(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rmap[x][y] = (short)amount;
}
inline int region::surface(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
if (rlakemap[x][y] != 0)
return rlakemap[x][y];
else
return (int)rmap[x][y];
}
inline bool region::sea(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
if (rmap[x][y] <= itssealevel && rlakemap[x][y] == 0)
return 1;
else
return 0;
}
inline void region::longitude(int x, int xx, int tilex, int width, int& degrees, int& minutes, int& seconds, bool& negative) const
{
if (x < 0 || x >= RARRAYWIDTH)
return;
if (itscentrex == 16) // For some reason, if the region is on the left-hand edge of the map, the tile coordinates need correcting.
xx = xx - width;
float fx = (float)xx;
int basex = (x / 16) * 16; // the coordinate of the start of this tile on the regional map.
float extra = (float)(x - basex); // the location within this tile of our point.
if (tilex < 34)
extra = extra / 16.0f; // expressed as a fraction.
else
extra = extra / 32.0f;
fx = fx + extra;
float worldwidth = (float)width + 1.0f;
float pixelsperlong = worldwidth / 360.0f;
float longitude = fx / pixelsperlong;
longitude = longitude - 180.0f;
degrees = (int)longitude;
float dec = (longitude - (float)degrees) * 60.0f;
minutes = (int)dec;
float dec2 = (dec - (float)minutes) * 60.0f;
seconds = (int)dec2;
if (degrees < 0)
degrees = 0 - degrees;
if (minutes < 0)
minutes = 0 - minutes;
if (seconds < 0)
seconds = 0 - seconds;
negative = 0;
if (fx < worldwidth / 2.0f)
negative = 1;
return;
}
inline void region::latitude(int y, int yy, int tiley, int height, int& degrees, int& minutes, int& seconds, bool& negative) const
{
if (y < 0 || y >= RARRAYHEIGHT)
return;
bool hemisphere = 0; // 1 for southern
float fy = (float)yy;
int basey = (y / 16) * 16; // the coordinate of the start of this tile on the regional map.
float extra = (float)(y - basey); // the location within this tile of our point.
if (tiley < 34)
extra = extra / 16.0f; // expressed as a fraction.
else
extra = extra / 32.0f;
fy = fy + extra;
float worldheight = (float)height;
float worldhalfheight = worldheight / 2.0f;
float pixelsperlat = worldhalfheight / 90.0f;
float latitude;
if (fy <= worldhalfheight)
latitude = (worldhalfheight - fy) / pixelsperlat;
else
{
latitude = (fy - worldhalfheight) / pixelsperlat;
hemisphere = 1;
}
degrees = (int)latitude;
float dec = (latitude - (float)degrees) * 60.0f;
minutes = (int)dec;
float dec2 = (dec - (float)minutes) * 60.0f;
seconds = (int)dec2;
negative = 0;
if (hemisphere == 1)
negative = 1;
return;
}
inline int region::jantemp(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (short)rjantempmap[x][y];
}
inline void region::setjantemp(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rjantempmap[x][y] = (short)amount;
}
inline int region::jultemp(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)rjultempmap[x][y];
}
inline void region::setjultemp(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rjultempmap[x][y] = (short)amount;
}
inline int region::aprtemp(int x, int y, int yy, int globalheight, float tilt, float eccentricity, int perihelion) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
float summertemp = (float)rjultempmap[x][y];
float wintertemp = (float)rjantempmap[x][y];
if (perihelion == 1)
{
summertemp = (float)rjantempmap[x][y];
wintertemp = (float)rjultempmap[x][y];
}
float winterstrength = 0.5f + eccentricity * 0.5f; // The higher the eccentricity, the shorter the "summer".
float summerstrength = 1.0f - winterstrength;
float thistemp = summertemp * summerstrength + wintertemp * winterstrength;
// Now adjust for four-seasonality (if the obliquity is high)
float fourseason = tilt * 0.294592f - 2.45428f;
float lat = (float)yy;
if (yy > globalheight / 2)
lat = (float)(globalheight - yy);
float fourseasonstrength = lat / (float)(globalheight / 2); // This measures the strength of the four-season cycle as determined by proximity to the equator.
float thistempdiff = (fourseason * fourseasonstrength) / 2.0f;
thistemp = thistemp + thistempdiff;
return (int)thistemp;
}
inline int region::octtemp(int x, int y, int yy, int globalheight, float tilt, float eccentricity, int perihelion) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
float summertemp = (float)rjultempmap[x][y];
float wintertemp = (float)rjantempmap[x][y];
if (perihelion == 1)
{
summertemp = (float)rjantempmap[x][y];
wintertemp = (float)rjultempmap[x][y];
}
float winterstrength = 0.5f + eccentricity * 0.5f; // The higher the eccentricity, the shorter the "summer".
float summerstrength = 1.0f - winterstrength;
float thistemp = summertemp * summerstrength + wintertemp * winterstrength;
// Now adjust for four-seasonality (if the obliquity is high)
float fourseason = tilt * 0.294592f - 2.45428f;
float lat = (float)yy;
if (yy > globalheight / 2)
lat = (float)(globalheight - yy);
float fourseasonstrength = lat / (float)(globalheight / 2); // This measures the strength of the four-season cycle as determined by proximity to the equator.
float thistempdiff = (fourseason * fourseasonstrength) / 2.0f;
thistemp = thistemp + thistempdiff;
return (int)thistemp;
}
inline int region::maxtemp(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
if (rjantempmap[x][y] < rjultempmap[x][y])
return (int)rjultempmap[x][y];
else
return (int)rjantempmap[x][y];
}
inline void region::setmaxtemp(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
if (rjantempmap[x][y] < rjultempmap[x][y])
rjultempmap[x][y] = (short)amount;
else
rjantempmap[x][y] = (short)amount;
}
inline int region::mintemp(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
if (rjantempmap[x][y] >= rjultempmap[x][y])
return (int)rjultempmap[x][y];
else
return (int)rjantempmap[x][y];
}
inline void region::setmintemp(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
if (rjantempmap[x][y] >= rjultempmap[x][y])
rjultempmap[x][y] = (short)amount;
else
rjantempmap[x][y] = (short)amount;
}
/*
inline int region::extrajantemp(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)rextrajantempmap[x][y];
}
inline void region::setextrajantemp(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rextrajantempmap[x][y] = (short)amount;
}
inline int region::extrajultemp(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)rextrajultempmap[x][y];
}
inline void region::setextrajultemp(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rextrajultempmap[x][y] = (short)amount;
}
inline int region::extramaxtemp(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
if (rjantempmap[x][y] < rjultempmap[x][y])
return (int)rextrajultempmap[x][y];
else
return (int)rextrajantempmap[x][y];
}
inline void region::setextramaxtemp(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
if (rjantempmap[x][y] < rjultempmap[x][y])
rextrajultempmap[x][y] = (short)amount;
else
rextrajantempmap[x][y] = (short)amount;
}
inline int region::extramintemp(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
if (rjantempmap[x][y] >= rjultempmap[x][y])
return (int)rextrajultempmap[x][y];
else
return (int)rextrajantempmap[x][y];
}
inline void region::setextramintemp(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
if (rjantempmap[x][y] >= rjultempmap[x][y])
rextrajultempmap[x][y] = (short)amount;
else
rextrajantempmap[x][y] = (short)amount;
}
*/
inline int region::avetemp(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)((rjantempmap[x][y] + rjultempmap[x][y]) / 2);
}
inline int region::janrain(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)rjanrainmap[x][y];
}
inline void region::setjanrain(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rjanrainmap[x][y] = (short)amount;
}
inline int region::julrain(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)rjulrainmap[x][y];
}
inline void region::setjulrain(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rjulrainmap[x][y] = (short)amount;
}
inline int region::aprrain(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
float janfactor = 0.5f;
float julfactor = 0.5f;
float janrain = (float)rjanrainmap[x][y];
float julrain = (float)rjulrainmap[x][y];
if (rjultempmap[x][y] > rjantempmap[x][y] && rjulrainmap[x][y] > rjanrainmap[x][y]) // Monsoon in July
{
float monsoonfactor = 1.0f - janrain / julrain;
janfactor = monsoonfactor * 0.9f; // The stronger the July monsoon, the more the April rain should be like January (low).
julfactor = 1.0f - janfactor;
}
if (rjultempmap[x][y] < rjantempmap[x][y] && rjulrainmap[x][y] < rjanrainmap[x][y]) // Monsoon in January
{
float monsoonfactor = 1.0f - julrain / janrain;
janfactor = monsoonfactor * 0.7f; // The stronger the January monsoon, the more the April rain should be like January (high) (though not *too* close too it!).
julfactor = 1.0f - janfactor;
}
float total = janrain * janfactor + julrain * julfactor;
return (int)total;
}
inline int region::octrain(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
float janfactor = 0.5f;
float julfactor = 0.5f;
float janrain = (float)rjanrainmap[x][y];
float julrain = (float)rjulrainmap[x][y];
if (rjultempmap[x][y] > rjantempmap[x][y] && rjulrainmap[x][y] > rjanrainmap[x][y]) // Monsoon in July
{
float monsoonfactor = 1.0f - janrain / julrain;
julfactor = monsoonfactor * 0.7f; // The stronger the July monsoon, the more the October rain should be like July (high) (though not *too* close too it!).
janfactor = 1.0f - julfactor;
}
if (rjultempmap[x][y] < rjantempmap[x][y] && rjulrainmap[x][y] < rjanrainmap[x][y]) // Monsoon in January
{
float monsoonfactor = 1.0f - julrain / janrain;
julfactor = monsoonfactor * 0.9f; // The stronger the January monsoon, the more the April rain should be like July (low).
janfactor = 1.0f - julfactor;
}
float total = janrain * janfactor + julrain * julfactor;
return (int)total;
}
inline int region::summerrain(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
if (rjantempmap[x][y] < rjultempmap[x][y])
return (int)rjulrainmap[x][y];
else
return (int)rjanrainmap[x][y];
}
inline void region::setsummerrain(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
if (rjantempmap[x][y] < rjultempmap[x][y])
rjulrainmap[x][y] = (short)amount;
else
rjanrainmap[x][y] = (short)amount;
}
inline int region::winterrain(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
if (rjantempmap[x][y] >= rjultempmap[x][y])
return (int)rjulrainmap[x][y];
else
return (int)rjanrainmap[x][y];
}
inline void region::setwinterrain(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
if (rjantempmap[x][y] >= rjultempmap[x][y])
rjulrainmap[x][y] = (short)amount;
else
rjanrainmap[x][y] = (short)amount;
}
inline int region::averain(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)((rjanrainmap[x][y] + rjulrainmap[x][y]) / 2);
}
inline int region::climate(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)rclimatemap[x][y];
}
inline void region::setclimate(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rclimatemap[x][y] = (unsigned char)amount;
}
inline int region::seaice(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)rseaicemap[x][y];
}
inline void region::setseaice(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rseaicemap[x][y] = (short)amount;
}
inline int region::riverdir(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)rrivermapdir[x][y];
}
inline void region::setriverdir(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rrivermapdir[x][y] = (unsigned char)amount;
}
inline int region::riverjan(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return rrivermapjan[x][y];
}
inline void region::setriverjan(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rrivermapjan[x][y] = amount;
}
inline int region::riverjul(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return rrivermapjul[x][y];
}
inline void region::setriverjul(int x, int y, int amount)
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return;
rrivermapjul[x][y] = amount;
}
inline int region::riveraveflow(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (rrivermapjan[x][y] + rrivermapjul[x][y]) / 2;
}
inline int region::fakedir(int x, int y) const
{
if (x < 0 || x >= RARRAYWIDTH || y < 0 || y >= RARRAYHEIGHT)
return 0;
return (int)rfakeriversdir[x][y];
}