Files @ r5313:3f75777ce3cb
Branch filter:

Location: cpp/openttd-patchpack/source/clear_cmd.c - annotation

peter1138
(svn r7469) -Fix (r7348): NewGRF settings weren't loaded in cases.
  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
r2186:5ee653b1b5e1
r2186:5ee653b1b5e1
r0:d63b455452f6
r1891:c5c5466afa35
r3144:5b175fed4b0b
r4041:22c02258c9b7
r507:b1b0a0a3c313
r2163:ae001e2aa5b0
r679:3a7b08cc8504
r2154:83cf5a3d6634
r1209:5955f8748394
r0:d63b455452f6
r0:d63b455452f6
r3156:c9d8084e145c
r2153:b45e3461c6c4
r2517:f67017080a5a
r3310:2b8d6cab0269
r4300:642b2431578b
r4328:abeae2374271
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2639:e298192a7c03
r0:d63b455452f6
r0:d63b455452f6
r2639:e298192a7c03
r2639:e298192a7c03
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r2639:e298192a7c03
r2639:e298192a7c03
r0:d63b455452f6
r0:d63b455452f6
r1044:d63b879a32db
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2639:e298192a7c03
r0:d63b455452f6
r2952:e97f823d2dbe
r2639:e298192a7c03
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1981:addba4bccc89
r1981:addba4bccc89
r1981:addba4bccc89
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4067:a9c6af704de1
r0:d63b455452f6
r0:d63b455452f6
r4067:a9c6af704de1
r0:d63b455452f6
r863:a3262138da98
r193:6aa65dc5a4b4
r4068:7a0a08cafe29
r4068:7a0a08cafe29
r4067:a9c6af704de1
r4067:a9c6af704de1
r4068:7a0a08cafe29
r4068:7a0a08cafe29
r193:6aa65dc5a4b4
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r4069:6b1532b672ec
r4068:7a0a08cafe29
r4068:7a0a08cafe29
r2686:b5fec3dac0f5
r4067:a9c6af704de1
r2686:b5fec3dac0f5
r2686:b5fec3dac0f5
r2686:b5fec3dac0f5
r4067:a9c6af704de1
r4067:a9c6af704de1
r4068:7a0a08cafe29
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4069:6b1532b672ec
r4067:a9c6af704de1
r4067:a9c6af704de1
r0:d63b455452f6
r0:d63b455452f6
r4067:a9c6af704de1
r4067:a9c6af704de1
r4560:a5208774f99e
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r2639:e298192a7c03
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r863:a3262138da98
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2639:e298192a7c03
r193:6aa65dc5a4b4
r0:d63b455452f6
r2639:e298192a7c03
r193:6aa65dc5a4b4
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2639:e298192a7c03
r0:d63b455452f6
r4000:702cb45b8eab
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1986:40fe0be5bb1e
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1986:40fe0be5bb1e
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r909:898755bd4512
r0:d63b455452f6
r909:898755bd4512
r909:898755bd4512
r909:898755bd4512
r909:898755bd4512
r909:898755bd4512
r909:898755bd4512
r0:d63b455452f6
r2952:e97f823d2dbe
r909:898755bd4512
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1775:0a21bebb2211
r3491:10ed78e15d31
r1782:0fd68043a2ea
r1775:0a21bebb2211
r0:d63b455452f6
r3491:10ed78e15d31
r0:d63b455452f6
r0:d63b455452f6
r4000:702cb45b8eab
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1878:686a15360edf
r2934:94158a76ebcf
r1878:686a15360edf
r0:d63b455452f6
r4000:702cb45b8eab
r4000:702cb45b8eab
r4000:702cb45b8eab
r4000:702cb45b8eab
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4000:702cb45b8eab
r4000:702cb45b8eab
r4000:702cb45b8eab
r4000:702cb45b8eab
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4000:702cb45b8eab
r4000:702cb45b8eab
r4000:702cb45b8eab
r4000:702cb45b8eab
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4000:702cb45b8eab
r4000:702cb45b8eab
r4000:702cb45b8eab
r4000:702cb45b8eab
r0:d63b455452f6
r0:d63b455452f6
r4067:a9c6af704de1
r4067:a9c6af704de1
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r1775:0a21bebb2211
r4067:a9c6af704de1
r1977:1f8b99c96041
r0:d63b455452f6
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r4067:a9c6af704de1
r3279:91e2701faa6f
r4067:a9c6af704de1
r4067:a9c6af704de1
r2639:e298192a7c03
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1775:0a21bebb2211
r3491:10ed78e15d31
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1775:0a21bebb2211
r1979:2ece0cb73ecf
r193:6aa65dc5a4b4
r1059:bbcabb62c19c
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1775:0a21bebb2211
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1796:4bbf4ea0805e
r3491:10ed78e15d31
r1796:4bbf4ea0805e
r1796:4bbf4ea0805e
r0:d63b455452f6
r3491:10ed78e15d31
r0:d63b455452f6
r0:d63b455452f6
r3491:10ed78e15d31
r3491:10ed78e15d31
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2934:94158a76ebcf
r1796:4bbf4ea0805e
r889:ed9a6e2f24bb
r889:ed9a6e2f24bb
r0:d63b455452f6
r1044:d63b879a32db
r0:d63b455452f6
r0:d63b455452f6
r3491:10ed78e15d31
r3491:10ed78e15d31
r926:fcf36609eb94
r926:fcf36609eb94
r0:d63b455452f6
r0:d63b455452f6
r1981:addba4bccc89
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1796:4bbf4ea0805e
r1044:d63b879a32db
r0:d63b455452f6
r3491:10ed78e15d31
r1796:4bbf4ea0805e
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3491:10ed78e15d31
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1796:4bbf4ea0805e
r0:d63b455452f6
r1796:4bbf4ea0805e
r0:d63b455452f6
r0:d63b455452f6
r1782:0fd68043a2ea
r1782:0fd68043a2ea
r3491:10ed78e15d31
r1782:0fd68043a2ea
r1782:0fd68043a2ea
r0:d63b455452f6
r3491:10ed78e15d31
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r193:6aa65dc5a4b4
r1782:0fd68043a2ea
r0:d63b455452f6
r3310:2b8d6cab0269
r0:d63b455452f6
r3310:2b8d6cab0269
r0:d63b455452f6
r3491:10ed78e15d31
r1782:0fd68043a2ea
r0:d63b455452f6
r0:d63b455452f6
r3310:2b8d6cab0269
r3310:2b8d6cab0269
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r1095:c4ca8dd7cd3e
r2220:ffd09009ed77
r2220:ffd09009ed77
r2220:ffd09009ed77
r2220:ffd09009ed77
r2220:ffd09009ed77
r2220:ffd09009ed77
r2220:ffd09009ed77
r2955:af9992213b85
r0:d63b455452f6
r2955:af9992213b85
r2955:af9992213b85
r3447:1cf4fdb2e0fa
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r0:d63b455452f6
r2220:ffd09009ed77
r0:d63b455452f6
r2955:af9992213b85
r0:d63b455452f6
r0:d63b455452f6
r1782:0fd68043a2ea
r1782:0fd68043a2ea
r3491:10ed78e15d31
r1782:0fd68043a2ea
r1782:0fd68043a2ea
r1782:0fd68043a2ea
r3491:10ed78e15d31
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3310:2b8d6cab0269
r1878:686a15360edf
r1878:686a15360edf
r0:d63b455452f6
r1782:0fd68043a2ea
r0:d63b455452f6
r4000:702cb45b8eab
r0:d63b455452f6
r1782:0fd68043a2ea
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2436:963efe8b84cc
r0:d63b455452f6
r2517:f67017080a5a
r0:d63b455452f6
r0:d63b455452f6
r2436:963efe8b84cc
r0:d63b455452f6
r3636:a8e0c73aca96
r2517:f67017080a5a
r0:d63b455452f6
r2140:efb49af98a17
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2220:ffd09009ed77
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r3636:a8e0c73aca96
r3645:de3cfb719308
r3645:de3cfb719308
r0:d63b455452f6
r0:d63b455452f6
r2979:d7600d949c77
r2979:d7600d949c77
r0:d63b455452f6
r0:d63b455452f6
r2979:d7600d949c77
r2979:d7600d949c77
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3166:0075e683c1ef
r3447:1cf4fdb2e0fa
r3166:0075e683c1ef
r2955:af9992213b85
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r2955:af9992213b85
r2955:af9992213b85
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r2955:af9992213b85
r2955:af9992213b85
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r2979:d7600d949c77
r2955:af9992213b85
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r3166:0075e683c1ef
r2955:af9992213b85
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r3166:0075e683c1ef
r2955:af9992213b85
r0:d63b455452f6
r193:6aa65dc5a4b4
r2220:ffd09009ed77
r0:d63b455452f6
r0:d63b455452f6
r4231:a4beff4c54cb
r1095:c4ca8dd7cd3e
r4231:a4beff4c54cb
r4231:a4beff4c54cb
r4231:a4beff4c54cb
r4231:a4beff4c54cb
r1095:c4ca8dd7cd3e
r0:d63b455452f6
r3636:a8e0c73aca96
r39:c8e54423ac24
r3418:cff6e454339a
r39:c8e54423ac24
r39:c8e54423ac24
r1977:1f8b99c96041
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1293:ff36218460f9
r0:d63b455452f6
r2221:90ca9dcf90f1
r2221:90ca9dcf90f1
r1293:ff36218460f9
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r2979:d7600d949c77
r2221:90ca9dcf90f1
r2979:d7600d949c77
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r2221:90ca9dcf90f1
r2979:d7600d949c77
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r2979:d7600d949c77
r2221:90ca9dcf90f1
r2979:d7600d949c77
r0:d63b455452f6
r193:6aa65dc5a4b4
r0:d63b455452f6
r2221:90ca9dcf90f1
r2979:d7600d949c77
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2221:90ca9dcf90f1
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r4157:ed8cf13e1648
r193:6aa65dc5a4b4
r4157:ed8cf13e1648
r3447:1cf4fdb2e0fa
r3447:1cf4fdb2e0fa
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r3447:1cf4fdb2e0fa
r2955:af9992213b85
r4157:ed8cf13e1648
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r0:d63b455452f6
r3379:e72a0eb00c30
r3447:1cf4fdb2e0fa
r0:d63b455452f6
r3379:e72a0eb00c30
r3379:e72a0eb00c30
r3379:e72a0eb00c30
r3379:e72a0eb00c30
r1981:addba4bccc89
r3447:1cf4fdb2e0fa
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r0:d63b455452f6
r193:6aa65dc5a4b4
r2989:c7c58e254010
r2989:c7c58e254010
r2989:c7c58e254010
r0:d63b455452f6
r0:d63b455452f6
r2955:af9992213b85
r3447:1cf4fdb2e0fa
r2955:af9992213b85
r193:6aa65dc5a4b4
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r3447:1cf4fdb2e0fa
r0:d63b455452f6
r2955:af9992213b85
r2955:af9992213b85
r3447:1cf4fdb2e0fa
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r4333:f8e6d7e95d89
r4328:abeae2374271
r4815:d523741bb2ba
r4328:abeae2374271
r4328:abeae2374271
r4328:abeae2374271
r4328:abeae2374271
r4328:abeae2374271
r2955:af9992213b85
r0:d63b455452f6
r2955:af9992213b85
r2955:af9992213b85
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1093:18f56ef2d029
r0:d63b455452f6
r4300:642b2431578b
r1977:1f8b99c96041
r0:d63b455452f6
r4300:642b2431578b
r2635:2b74892d089b
r4300:642b2431578b
r4300:642b2431578b
r4300:642b2431578b
r0:d63b455452f6
r4300:642b2431578b
r2051:04d7c352ccc4
r4300:642b2431578b
r0:d63b455452f6
r0:d63b455452f6
r4300:642b2431578b
r4300:642b2431578b
r0:d63b455452f6
r2150:8d17c2dcd791
r2051:04d7c352ccc4
r4300:642b2431578b
r4300:642b2431578b
r4300:642b2431578b
r2150:8d17c2dcd791
r2951:a52cbb930051
r1977:1f8b99c96041
r1977:1f8b99c96041
r3447:1cf4fdb2e0fa
r0:d63b455452f6
r0:d63b455452f6
r4559:2222e3ea9700
r4300:642b2431578b
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2220:ffd09009ed77
r2955:af9992213b85
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2955:af9992213b85
r0:d63b455452f6
r0:d63b455452f6
r1977:1f8b99c96041
r0:d63b455452f6
r3447:1cf4fdb2e0fa
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r2955:af9992213b85
r1901:e806afa50723
r0:d63b455452f6
r0:d63b455452f6
r2436:963efe8b84cc
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1093:18f56ef2d029
r1093:18f56ef2d029
r3422:cca72d7a228c
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r0:d63b455452f6
/* $Id$ */

#include "stdafx.h"
#include "openttd.h"
#include "clear_map.h"
#include "rail_map.h"
#include "table/strings.h"
#include "functions.h"
#include "map.h"
#include "player.h"
#include "tile.h"
#include "viewport.h"
#include "command.h"
#include "tunnel_map.h"
#include "variables.h"
#include "table/sprites.h"
#include "unmovable_map.h"
#include "genworld.h"
#include "industry.h"

typedef struct TerraformerHeightMod {
	TileIndex tile;
	byte height;
} TerraformerHeightMod;

typedef struct TerraformerState {
	int height[4];
	uint32 flags;

	int direction;
	int modheight_count;
	int tile_table_count;

	int32 cost;

	TileIndex *tile_table;
	TerraformerHeightMod *modheight;

} TerraformerState;

static int TerraformAllowTileProcess(TerraformerState *ts, TileIndex tile)
{
	TileIndex *t;
	int count;

	if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return -1;

	t = ts->tile_table;
	for (count = ts->tile_table_count; count != 0; count--, t++) {
		if (*t == tile) return 0;
	}

	return 1;
}

static int TerraformGetHeightOfTile(TerraformerState *ts, TileIndex tile)
{
	TerraformerHeightMod *mod = ts->modheight;
	int count;

	for (count = ts->modheight_count; count != 0; count--, mod++) {
		if (mod->tile == tile) return mod->height;
	}

	return TileHeight(tile);
}

static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile)
{
	int count;
	TileIndex *t;

	count = ts->tile_table_count;

	if (count >= 625) return;

	for (t = ts->tile_table; count != 0; count--,t++) {
		if (*t == tile) return;
	}

	ts->tile_table[ts->tile_table_count++] = tile;
}

static void TerraformAddDirtyTileAround(TerraformerState *ts, TileIndex tile)
{
	TerraformAddDirtyTile(ts, tile + TileDiffXY( 0, -1));
	TerraformAddDirtyTile(ts, tile + TileDiffXY(-1, -1));
	TerraformAddDirtyTile(ts, tile + TileDiffXY(-1,  0));
	TerraformAddDirtyTile(ts, tile);
}

static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode)
{
	int r;
	int32 ret;

	assert(tile < MapSize());

	r = TerraformAllowTileProcess(ts, tile);
	if (r <= 0) return r;

	if (IsTileType(tile, MP_RAILWAY)) {
		static const TrackBits safe_track[] = { TRACK_BIT_LOWER, TRACK_BIT_LEFT, TRACK_BIT_UPPER, TRACK_BIT_RIGHT };
		static const Slope unsafe_slope[] = { SLOPE_S, SLOPE_W, SLOPE_N, SLOPE_E };

		Slope tileh;
		uint z;

		// Nothing could be built at the steep slope - this avoids a bug
		// when you have a single diagonal track in one corner on a
		// basement and then you raise/lower the other corner.
		tileh = GetTileSlope(tile, &z);
		if (tileh == unsafe_slope[mode] ||
				tileh == ComplementSlope(unsafe_slope[mode])) {
			_terraform_err_tile = tile;
			_error_message = STR_1008_MUST_REMOVE_RAILROAD_TRACK;
			return -1;
		}

		// If we have a single diagonal track there, the other side of
		// tile can be terraformed.
		if (IsPlainRailTile(tile) && GetTrackBits(tile) == safe_track[mode]) {
			/* If terraforming downwards prevent damaging a potential tunnel below.
			 * This check is only necessary for flat tiles, because if the tile is
			 * non-flat, then the corner opposing the rail is raised. Only this corner
			 * can be lowered and this is a safe action
			 */
			if (tileh == SLOPE_FLAT &&
					ts->direction == -1 &&
					IsTunnelInWay(tile, z - TILE_HEIGHT)) {
				_terraform_err_tile = tile;
				_error_message = STR_1002_EXCAVATION_WOULD_DAMAGE;
				return -1;
			}
			return 0;
		}
	}

	ret = DoCommand(tile, 0,0, ts->flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);

	if (CmdFailed(ret)) {
		_terraform_err_tile = tile;
		return -1;
	}

	ts->cost += ret;

	if (ts->tile_table_count >= 625) return -1;
	ts->tile_table[ts->tile_table_count++] = tile;

	return 0;
}

static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height)
{
	int nh;
	TerraformerHeightMod *mod;
	int count;

	assert(tile < MapSize());

	if (height < 0) {
		_error_message = STR_1003_ALREADY_AT_SEA_LEVEL;
		return false;
	}

	_error_message = STR_1004_TOO_HIGH;

	if (height > 15) return false;

	nh = TerraformGetHeightOfTile(ts, tile);
	if (nh < 0 || height == nh) return false;

	if (TerraformProc(ts, tile, 0) < 0) return false;
	if (TerraformProc(ts, tile + TileDiffXY( 0, -1), 1) < 0) return false;
	if (TerraformProc(ts, tile + TileDiffXY(-1, -1), 2) < 0) return false;
	if (TerraformProc(ts, tile + TileDiffXY(-1,  0), 3) < 0) return false;

	mod = ts->modheight;
	count = ts->modheight_count;

	for (;;) {
		if (count == 0) {
			if (ts->modheight_count >= 576) return false;
			ts->modheight_count++;
			break;
		}
		if (mod->tile == tile) break;
		mod++;
		count--;
	}

	mod->tile = tile;
	mod->height = (byte)height;

	ts->cost += _price.terraform;

	{
		int direction = ts->direction, r;
		const TileIndexDiffC *ttm;

		static const TileIndexDiffC _terraform_tilepos[] = {
			{ 1,  0},
			{-2,  0},
			{ 1,  1},
			{ 0, -2}
		};

		for (ttm = _terraform_tilepos; ttm != endof(_terraform_tilepos); ttm++) {
			tile += ToTileIndexDiff(*ttm);

			r = TerraformGetHeightOfTile(ts, tile);
			if (r != height && r-direction != height && r+direction != height) {
				if (!TerraformTileHeight(ts, tile, r+direction))
					return false;
			}
		}
	}

	return true;
}

/** Terraform land
 * @param tile tile to terraform
 * @param p1 corners to terraform.
 * @param p2 direction; eg up or down
 */
int32 CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
	TerraformerState ts;
	TileIndex t;
	int direction;

	TerraformerHeightMod modheight_data[576];
	TileIndex tile_table_data[625];

	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);

	_terraform_err_tile = 0;

	ts.direction = direction = p2 ? 1 : -1;
	ts.flags = flags;
	ts.modheight_count = ts.tile_table_count = 0;
	ts.cost = 0;
	ts.modheight = modheight_data;
	ts.tile_table = tile_table_data;

	/* Make an extra check for map-bounds cause we add tiles to the originating tile */
	if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR;

	if (p1 & 1) {
		t = tile + TileDiffXY(1, 0);
		if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) {
			return CMD_ERROR;
		}
	}

	if (p1 & 2) {
		t = tile + TileDiffXY(1, 1);
		if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) {
			return CMD_ERROR;
		}
	}

	if (p1 & 4) {
		t = tile + TileDiffXY(0, 1);
		if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) {
			return CMD_ERROR;
		}
	}

	if (p1 & 8) {
		t = tile + TileDiffXY(0, 0);
		if (!TerraformTileHeight(&ts, t, TileHeight(t) + direction)) {
			return CMD_ERROR;
		}
	}

	if (direction == -1) {
		/* Check if tunnel would take damage */
		int count;
		TileIndex *ti = ts.tile_table;

		for (count = ts.tile_table_count; count != 0; count--, ti++) {
			uint z, t;
			TileIndex tile = *ti;

			z = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 0));
			t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 0));
			if (t <= z) z = t;
			t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(1, 1));
			if (t <= z) z = t;
			t = TerraformGetHeightOfTile(&ts, tile + TileDiffXY(0, 1));
			if (t <= z) z = t;

			if (IsTunnelInWay(tile, z * TILE_HEIGHT)) {
				return_cmd_error(STR_1002_EXCAVATION_WOULD_DAMAGE);
			}
		}
	}

	if (flags & DC_EXEC) {
		/* Clear the landscape at the tiles */
		{
			int count;
			TileIndex *ti = ts.tile_table;
			for (count = ts.tile_table_count; count != 0; count--, ti++) {
				DoCommand(*ti, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
			}
		}

		/* change the height */
		{
			int count;
			TerraformerHeightMod *mod;

			mod = ts.modheight;
			for (count = ts.modheight_count; count != 0; count--, mod++) {
				TileIndex til = mod->tile;

				SetTileHeight(til, mod->height);
				TerraformAddDirtyTileAround(&ts, til);
			}
		}

		/* finally mark the dirty tiles dirty */
		{
			int count;
			TileIndex *ti = ts.tile_table;
			for (count = ts.tile_table_count; count != 0; count--, ti++) {
				MarkTileDirtyByTile(*ti);
			}
		}
	}
	return ts.cost;
}


/** Levels a selected (rectangle) area of land
 * @param tile end tile of area-drag
 * @param p1 start tile of area drag
 * @param p2 unused
 */
int32 CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
	int size_x, size_y;
	int ex;
	int ey;
	int sx, sy;
	uint h, curh;
	int32 ret, cost, money;

	if (p1 >= MapSize()) return CMD_ERROR;

	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);

	// remember level height
	h = TileHeight(p1);

	// make sure sx,sy are smaller than ex,ey
	ex = TileX(tile);
	ey = TileY(tile);
	sx = TileX(p1);
	sy = TileY(p1);
	if (ex < sx) intswap(ex, sx);
	if (ey < sy) intswap(ey, sy);
	tile = TileXY(sx, sy);

	size_x = ex-sx+1;
	size_y = ey-sy+1;

	money = GetAvailableMoneyForCommand();
	cost = 0;

	BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
		curh = TileHeight(tile2);
		while (curh != h) {
			ret = DoCommand(tile2, 8, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
			if (CmdFailed(ret)) break;
			cost += ret;

			if (flags & DC_EXEC) {
				if ((money -= ret) < 0) {
					_additional_cash_required = ret;
					return cost - ret;
				}
				DoCommand(tile2, 8, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
			}

			curh += (curh > h) ? -1 : 1;
		}
	} END_TILE_LOOP(tile2, size_x, size_y, tile)

	return (cost == 0) ? CMD_ERROR : cost;
}

/** Purchase a land area. Actually you only purchase one tile, so
 * the name is a bit confusing ;p
 * @param tile the tile the player is purchasing
 * @param p1 unused
 * @param p2 unused
 */
int32 CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
	int32 cost;

	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);

	if (!EnsureNoVehicle(tile)) return CMD_ERROR;

	if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_player)) {
		return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
	}

	cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
	if (CmdFailed(cost)) return CMD_ERROR;

	if (flags & DC_EXEC) {
		MakeOwnedLand(tile, _current_player);
		MarkTileDirtyByTile(tile);
	}

	return cost + _price.purchase_land * 10;
}


static int32 ClearTile_Clear(TileIndex tile, byte flags)
{
	static const int32* clear_price_table[] = {
		&_price.clear_1,
		&_price.purchase_land,
		&_price.clear_2,
		&_price.clear_3,
		&_price.purchase_land,
		&_price.purchase_land,
		&_price.clear_2, // XXX unused?
	};
	int32 price;

	if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) {
		price = 0;
	} else {
		price = *clear_price_table[GetClearGround(tile)];
	}

	if (flags & DC_EXEC) DoClearSquare(tile);

	return price;
}

/** Sell a land area. Actually you only sell one tile, so
 * the name is a bit confusing ;p
 * @param tile the tile the player is selling
 * @param p1 unused
 * @param p2 unused
 */
int32 CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);

	if (!IsOwnedLandTile(tile)) return CMD_ERROR;
	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;


	if (!EnsureNoVehicle(tile)) return CMD_ERROR;

	if (flags & DC_EXEC) DoClearSquare(tile);

	return - _price.purchase_land * 2;
}


#include "table/clear_land.h"


void DrawClearLandTile(const TileInfo *ti, byte set)
{
	DrawGroundSprite(SPR_FLAT_BARE_LAND + _tileh_to_sprite[ti->tileh] + set * 19);
}

void DrawHillyLandTile(const TileInfo *ti)
{
	if (ti->tileh != SLOPE_FLAT) {
		DrawGroundSprite(SPR_FLAT_ROUGH_LAND + _tileh_to_sprite[ti->tileh]);
	} else {
		DrawGroundSprite(_landscape_clear_sprites[GB(ti->x ^ ti->y, 4, 3)]);
	}
}

void DrawClearLandFence(const TileInfo *ti)
{
	byte z = ti->z;

	if (ti->tileh & SLOPE_S) {
		z += TILE_HEIGHT;
		if (ti->tileh == SLOPE_STEEP_S) z += TILE_HEIGHT;
	}

	if (GetFenceSW(ti->tile) != 0) {
		DrawGroundSpriteAt(_clear_land_fence_sprites_1[GetFenceSW(ti->tile) - 1] + _fence_mod_by_tileh[ti->tileh], ti->x, ti->y, z);
	}

	if (GetFenceSE(ti->tile) != 0) {
		DrawGroundSpriteAt(_clear_land_fence_sprites_1[GetFenceSE(ti->tile) - 1] + _fence_mod_by_tileh_2[ti->tileh], ti->x, ti->y, z);
	}
}

static void DrawTile_Clear(TileInfo *ti)
{
	switch (GetClearGround(ti->tile)) {
		case CLEAR_GRASS:
			DrawClearLandTile(ti, GetClearDensity(ti->tile));
			break;

		case CLEAR_ROUGH:
			DrawHillyLandTile(ti);
			break;

		case CLEAR_ROCKS:
			DrawGroundSprite(SPR_FLAT_ROCKY_LAND_1 + _tileh_to_sprite[ti->tileh]);
			break;

		case CLEAR_FIELDS:
			DrawGroundSprite(_clear_land_sprites_1[GetFieldType(ti->tile)] + _tileh_to_sprite[ti->tileh]);
			break;

		case CLEAR_SNOW:
			DrawGroundSprite(_clear_land_sprites_2[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh]);
			break;

		case CLEAR_DESERT:
			DrawGroundSprite(_clear_land_sprites_3[GetClearDensity(ti->tile)] + _tileh_to_sprite[ti->tileh]);
			break;
	}

	DrawClearLandFence(ti);
}

static uint GetSlopeZ_Clear(TileIndex tile, uint x, uint y)
{
	uint z;
	uint tileh = GetTileSlope(tile, &z);

	return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
}

static Slope GetSlopeTileh_Clear(TileIndex tile, Slope tileh)
{
	return tileh;
}

static void GetAcceptedCargo_Clear(TileIndex tile, AcceptedCargo ac)
{
	/* unused */
}

static void AnimateTile_Clear(TileIndex tile)
{
	/* unused */
}

void TileLoopClearHelper(TileIndex tile)
{
	byte self;
	byte neighbour;
	TileIndex dirty = INVALID_TILE;

	self = (IsTileType(tile, MP_CLEAR) && IsClearGround(tile, CLEAR_FIELDS));

	neighbour = (IsTileType(TILE_ADDXY(tile, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 1, 0), CLEAR_FIELDS));
	if (GetFenceSW(tile) == 0) {
		if (self != neighbour) {
			SetFenceSW(tile, 3);
			dirty = tile;
		}
	} else {
		if (self == 0 && neighbour == 0) {
			SetFenceSW(tile, 0);
			dirty = tile;
		}
	}

	neighbour = (IsTileType(TILE_ADDXY(tile, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(tile, 0, 1), CLEAR_FIELDS));
	if (GetFenceSE(tile) == 0) {
		if (self != neighbour) {
			SetFenceSE(tile, 3);
			dirty = tile;
		}
	} else {
		if (self == 0 && neighbour == 0) {
			SetFenceSE(tile, 0);
			dirty = tile;
		}
	}

	if (dirty != INVALID_TILE) MarkTileDirtyByTile(dirty);
}


/* convert into snowy tiles */
static void TileLoopClearAlps(TileIndex tile)
{
	int k = GetTileZ(tile) - _opt.snow_line + TILE_HEIGHT;

	if (k < 0) { // well below the snow line
		if (!IsClearGround(tile, CLEAR_SNOW)) return;
		if (GetClearDensity(tile) == 0) SetClearGroundDensity(tile, CLEAR_GRASS, 3);
	} else {
		if (!IsClearGround(tile, CLEAR_SNOW)) {
			SetClearGroundDensity(tile, CLEAR_SNOW, 0);
		} else {
			uint density = min((uint)k / TILE_HEIGHT, 3);

			if (GetClearDensity(tile) < density) {
				AddClearDensity(tile, 1);
			} else if (GetClearDensity(tile) > density) {
				AddClearDensity(tile, -1);
			} else {
				return;
			}
		}
	}

	MarkTileDirtyByTile(tile);
}

static void TileLoopClearDesert(TileIndex tile)
{
	if (IsClearGround(tile, CLEAR_DESERT)) return;

	if (GetTropicZone(tile) == TROPICZONE_DESERT) {
		SetClearGroundDensity(tile, CLEAR_DESERT, 3);
	} else {
		if (GetTropicZone(tile + TileDiffXY( 1,  0)) != TROPICZONE_DESERT &&
				GetTropicZone(tile + TileDiffXY(-1,  0)) != TROPICZONE_DESERT &&
				GetTropicZone(tile + TileDiffXY( 0,  1)) != TROPICZONE_DESERT &&
				GetTropicZone(tile + TileDiffXY( 0, -1)) != TROPICZONE_DESERT)
			return;
		SetClearGroundDensity(tile, CLEAR_DESERT, 1);
	}

	MarkTileDirtyByTile(tile);
}

static void TileLoop_Clear(TileIndex tile)
{
	TileLoopClearHelper(tile);

	switch (_opt.landscape) {
		case LT_DESERT: TileLoopClearDesert(tile); break;
		case LT_HILLY:  TileLoopClearAlps(tile);   break;
	}

	switch (GetClearGround(tile)) {
		case CLEAR_GRASS:
			if (GetClearDensity(tile) == 3) return;

			if (_game_mode != GM_EDITOR) {
				if (GetClearCounter(tile) < 7) {
					AddClearCounter(tile, 1);
					return;
				} else {
					SetClearCounter(tile, 0);
					AddClearDensity(tile, 1);
				}
			} else {
				SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3);
			}
			break;

		case CLEAR_FIELDS: {
			uint field_type;

			if (_game_mode == GM_EDITOR) return;

			if (GetClearCounter(tile) < 7) {
				AddClearCounter(tile, 1);
				return;
			} else {
				SetClearCounter(tile, 0);
			}

			if (GetIndustryIndexOfField(tile) == INVALID_INDUSTRY && GetFieldType(tile) >= 7) {
				/* This farmfield is no longer farmfield, so make it grass again */
				MakeClear(tile, CLEAR_GRASS, 2);
			} else {
				field_type = GetFieldType(tile);
				field_type = (field_type < 8) ? field_type + 1 : 0;
				SetFieldType(tile, field_type);
			}
			break;
		}

		default:
			return;
	}

	MarkTileDirtyByTile(tile);
}

void GenerateClearTile(void)
{
	uint i, gi;
	TileIndex tile;

	/* add rough tiles */
	i = ScaleByMapSize(GB(Random(), 0, 10) + 0x400);
	gi = ScaleByMapSize(GB(Random(), 0, 7) + 0x80);

	SetGeneratingWorldProgress(GWP_ROUGH_ROCKY, gi + i);
	do {
		IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY);
		tile = RandomTile();
		if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) SetClearGroundDensity(tile, CLEAR_ROUGH, 3);
	} while (--i);

	/* add rocky tiles */
	i = gi;
	do {
		uint32 r = Random();
		tile = RandomTileSeed(r);

		IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY);
		if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) {
			uint j = GB(r, 16, 4) + 5;
			for (;;) {
				TileIndex tile_new;

				SetClearGroundDensity(tile, CLEAR_ROCKS, 3);
				do {
					if (--j == 0) goto get_out;
					tile_new = tile + TileOffsByDiagDir(GB(Random(), 0, 2));
				} while (!IsTileType(tile_new, MP_CLEAR) || IsClearGround(tile_new, CLEAR_DESERT));
				tile = tile_new;
			}
get_out:;
		}
	} while (--i);
}

static void ClickTile_Clear(TileIndex tile)
{
	/* not used */
}

static uint32 GetTileTrackStatus_Clear(TileIndex tile, TransportType mode)
{
	return 0;
}

static const StringID _clear_land_str[] = {
	STR_080D_GRASS,
	STR_080B_ROUGH_LAND,
	STR_080A_ROCKS,
	STR_080E_FIELDS,
	STR_080F_SNOW_COVERED_LAND,
	STR_0810_DESERT
};

static void GetTileDesc_Clear(TileIndex tile, TileDesc *td)
{
	if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) {
		td->str = STR_080C_BARE_LAND;
	} else {
		td->str = _clear_land_str[GetClearGround(tile)];
	}
	td->owner = GetTileOwner(tile);
}

static void ChangeTileOwner_Clear(TileIndex tile, PlayerID old_player, PlayerID new_player)
{
	return;
}

void InitializeClearLand(void)
{
	_opt.snow_line = _patches.snow_line_height * TILE_HEIGHT;
}

const TileTypeProcs _tile_type_clear_procs = {
	DrawTile_Clear,           /* draw_tile_proc */
	GetSlopeZ_Clear,          /* get_slope_z_proc */
	ClearTile_Clear,          /* clear_tile_proc */
	GetAcceptedCargo_Clear,   /* get_accepted_cargo_proc */
	GetTileDesc_Clear,        /* get_tile_desc_proc */
	GetTileTrackStatus_Clear, /* get_tile_track_status_proc */
	ClickTile_Clear,          /* click_tile_proc */
	AnimateTile_Clear,        /* animate_tile_proc */
	TileLoop_Clear,           /* tile_loop_clear */
	ChangeTileOwner_Clear,    /* change_tile_owner_clear */
	NULL,                     /* get_produced_cargo_proc */
	NULL,                     /* vehicle_enter_tile_proc */
	GetSlopeTileh_Clear,      /* get_slope_tileh_proc */
};