This repository has been archived by the owner on May 27, 2019. It is now read-only.
/
max_60_3.patch
executable file
·925 lines (843 loc) · 32.5 KB
/
max_60_3.patch
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
Index: graph_gui.c
===================================================================
--- graph_gui.c (revision 2833)
+++ graph_gui.c (working copy)
@@ -15,17 +15,17 @@
#include "debug.h"
#include "variables.h"
-static uint _legend_excludebits;
+static uint64 _legend_excludebits;
static uint _legend_cargobits;
/************************/
/* GENERIC GRAPH DRAWER */
/************************/
-enum {GRAPH_NUM = 16};
+enum {GRAPH_NUM = (MAX_PLAYERS < 16) ? 16 : MAX_PLAYERS};
typedef struct GraphDrawer {
- uint sel; // bitmask of the players *excluded* (e.g. 11111111 means that no players are shown)
+ uint64 sel; // bitmask of the players *excluded* (e.g. 11111111 means that no players are shown)
byte num_dataset;
byte num_on_x_axis;
byte month;
@@ -58,10 +58,11 @@
uint64 y_scaling, tmp;
int64 value;
int64 cur_val;
- uint sel;
+ uint64 sel;
/* the colors and cost array of GraphDrawer must accomodate
* both values for cargo and players. So if any are higher, quit */
+
assert(GRAPH_NUM >= NUM_CARGO && GRAPH_NUM >= MAX_PLAYERS);
color = _color_list[gw->bg_line_color].window_color_1b;
@@ -219,33 +220,41 @@
static void GraphLegendWndProc(Window *w, WindowEvent *e)
{
- Player *p;
+ Player *p, *plist[MAX_PLAYERS];
+ int pl_num, i;
switch(e->event) {
- case WE_PAINT:
+ case WE_PAINT:
+ pl_num = 0;
FOR_ALL_PLAYERS(p) {
if (!p->is_active)
SETBIT(_legend_excludebits, p->index);
+ else
+ plist[pl_num++] = p;
}
- w->click_state = ((~_legend_excludebits) << 3);
+
+ w->click_state = (~_legend_excludebits) >> w->vscroll.pos;
+ w->click_state = w->click_state << 3;
+
DrawWindowWidgets(w);
- FOR_ALL_PLAYERS(p) {
- if (!p->is_active)
- continue;
+ SetVScrollCount(w, pl_num);
- DrawPlayerIcon(p->index, 4, 18+p->index*12);
+ i = w->vscroll.pos;
+ do {
+ p = plist[i];
+ DrawPlayerIcon(p->index, 4, 18 + (i - w->vscroll.pos) * 12);
SetDParam(0, p->name_1);
SetDParam(1, p->name_2);
SetDParam(2, GetPlayerNameString(p->index, 3));
- DrawString(21,17+p->index*12,STR_7021,HASBIT(_legend_excludebits, p->index) ? 0x10 : 0xC);
- }
- break;
-
+ DrawString(21, 17 + (i - w->vscroll.pos) * 12, STR_7021, HASBIT(_legend_excludebits, p->index) ? 0x10 : 0xC);
+ if (i + 1>= w->vscroll.cap + w->vscroll.pos)
+ break;
+ } while (++i != pl_num);
case WE_CLICK:
if (IS_INT_INSIDE(e->click.widget, 3, 11)) {
- _legend_excludebits ^= (1 << (e->click.widget-3));
+ _legend_excludebits ^= (1 << (e->click.widget - 3 + w->vscroll.pos));
SetWindowDirty(w);
InvalidateWindow(WC_INCOME_GRAPH, 0);
InvalidateWindow(WC_OPERATING_PROFIT, 0);
@@ -259,8 +268,8 @@
static const Widget _graph_legend_widgets[] = {
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, 14, 11, 249, 0, 13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 249, 14, 113, 0x0,STR_NULL},
+{ WWT_CAPTION, RESIZE_NONE, 14, 11, 259, 0, 13, STR_704E_KEY_TO_COMPANY_GRAPHS, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 259, 14, 113, 0x0,STR_NULL},
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 247, 16, 27, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 247, 28, 39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 247, 40, 51, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
@@ -269,11 +278,12 @@
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 247, 76, 87, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 247, 88, 99, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 247, 100, 111, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_SCROLLBAR, RESIZE_NONE, 14, 248, 259, 14, 113, 0x1,STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WIDGETS_END},
};
static const WindowDesc _graph_legend_desc = {
- -1, -1, 250, 114,
+ -1, -1, 260, 114,
WC_GRAPH_LEGEND,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_graph_legend_widgets,
@@ -282,7 +292,13 @@
static void ShowGraphLegend(void)
{
- AllocateWindowDescFront(&_graph_legend_desc, 0);
+ Window *w;
+ w = AllocateWindowDescFront(&_graph_legend_desc, 0);
+ if (w)
+ {
+ w->vscroll.pos = 0;
+ w->vscroll.cap = 8;
+ }
}
/********************/
@@ -292,7 +308,7 @@
static void SetupGraphDrawerForPlayers(GraphDrawer *gd)
{
Player *p;
- uint excludebits = _legend_excludebits;
+ uint64 excludebits = _legend_excludebits;
int nums;
int mo,yr;
@@ -841,7 +857,9 @@
qsort(plist, pl_num, sizeof(Player*), _perf_hist_comp);
- i = 0;
+ SetVScrollCount(w, pl_num);
+
+ i = w->vscroll.pos;
do {
SetDParam(0, i + STR_01AC_1ST);
p = plist[i];
@@ -850,8 +868,10 @@
SetDParam(3, GetPlayerNameString(p->index, 4));
SetDParam(5, GetPerformanceTitleFromValue(p->old_economy[1].performance_history));
- DrawString(2, 15 + i * 10, i == 0 ? STR_7054 : STR_7055, 0);
- DrawPlayerIcon(p->index, 27, 16 + i * 10);
+ DrawString(2, 15 + (i - w->vscroll.pos) * 10, i == 0 ? STR_7054 : STR_7055, 0);
+ DrawPlayerIcon(p->index, 27, 16 + (i - w->vscroll.pos) * 10);
+ if (i + 1>= w->vscroll.cap + w->vscroll.pos)
+ break;
} while (++i != pl_num);
break;
@@ -864,6 +884,7 @@
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_7053_COMPANY_LEAGUE_TABLE, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 399, 14, 96, 0x0, STR_NULL},
+{ WWT_SCROLLBAR, RESIZE_NONE, 14, 388, 399, 14, 96, 0x1, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WIDGETS_END},
};
@@ -877,7 +898,10 @@
void ShowCompanyLeagueTable(void)
{
- AllocateWindowDescFront(&_company_league_desc,0);
+ Window *w;
+ w = AllocateWindowDescFront(&_company_league_desc,0);
+ w->vscroll.pos = 0;
+ w->vscroll.cap = 8;
}
/*****************************/
@@ -889,8 +913,9 @@
switch(e->event) {
case WE_PAINT: {
int val, needed, score, i;
- byte owner, x;
- uint16 y=14;
+ byte owner;
+ int x, y2;
+ uint16 y=26;
int total_score = 0;
int color_done, color_notdone;
@@ -901,31 +926,49 @@
owner = FindFirstBit(w->click_state) - 13;
// Paint the player icons
- for (i=0;i<MAX_PLAYERS;i++) {
- if (!GetPlayer(i)->is_active) {
- // Check if we have the player as an active player
- if (!(w->disabled_state & (1 << (i+13)))) {
- // Bah, player gone :(
- w->disabled_state += 1 << (i+13);
- // Is this player selected? If so, select first player (always save? :s)
- if (w->click_state == 1U << (i + 13))
- w->click_state = 1 << 13;
- // We need a repaint
- SetWindowDirty(w);
- }
- continue;
- }
+ x = 13;
+ y2 = 16;
+ for (i = 0; i < MAX_PLAYERS; i++) {
+ if (!GetPlayer(i)->is_active) {
+ // Check if we have the player as an active player
+ if (!(w->disabled_state & (1 << (i+13)))) {
+ // Bah, player gone :(
+ w->disabled_state += 1 << (i+13);
+
+ // Is this player selected? If so, select first player (always save? :s)
+ if (w->click_state == 1U << (i + 13))
+ w->click_state = 1 << 13;
+
+ // We need a repaint
+ SetWindowDirty(w);
+ }
+
+ x += 37;
+ if (x >= 309) {
+ x = 13;
+ y2 = 29;
+ }
+ continue;
+ }
// Check if we have the player marked as inactive
if ((w->disabled_state & (1 << (i+13)))) {
// New player! Yippie :p
w->disabled_state -= 1 << (i+13);
- // We need a repaint
- SetWindowDirty(w);
- }
-
- if (i == owner) x = 1; else x = 0;
- DrawPlayerIcon(i, i * 37 + 13 + x, 16 + x);
+ // We need a repaint
+ SetWindowDirty(w);
+ }
+
+ if (i == owner)
+ DrawPlayerIcon(i, x + 1, y2 + 1);
+ else
+ DrawPlayerIcon(i, x, y2);
+
+ x += 37;
+ if (x >= 309) {
+ x = 13;
+ y2 = 29;
+ }
}
// The colors used to show how the progress is going
@@ -935,76 +978,76 @@
// Draw all the score parts
for (i=0;i<NUM_SCORE;i++) {
y += 20;
- val = _score_part[owner][i];
- needed = _score_info[i].needed;
- score = _score_info[i].score;
- // SCORE_TOTAL has his own rulez ;)
- if (i == SCORE_TOTAL) {
- needed = total_score;
- score = SCORE_MAX;
- } else
- total_score += score;
+ val = _score_part[owner][i];
+ needed = _score_info[i].needed;
+ score = _score_info[i].score;
+ // SCORE_TOTAL has his own rulez ;)
+ if (i == SCORE_TOTAL) {
+ needed = total_score;
+ score = SCORE_MAX;
+ } else
+ total_score += score;
- DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, 0);
+ DrawString(7, y, STR_PERFORMANCE_DETAIL_VEHICLES + i, 0);
- // Draw the score
- SetDParam(0, score);
- DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
-
- // Calculate the %-bar
- if (val > needed) x = 50;
- else if (val == 0) x = 0;
- else x = ((val * 50) / needed);
-
- // SCORE_LOAN is inversed
- if (val < 0 && i == SCORE_LOAN)
- x = 0;
-
- // Draw the bar
- if (x != 0)
- GfxFillRect(112, y-2, x + 112, y+10, color_done);
- if (x != 50)
- GfxFillRect(x + 112, y-2, 50 + 112, y+10, color_notdone);
-
+ // Draw the score
+ SetDParam(0, score);
+ DrawStringRightAligned(107, y, SET_PERFORMANCE_DETAIL_INT, 0);
+
+ // Calculate the %-bar
+ if (val > needed) x = 50;
+ else if (val == 0) x = 0;
+ else x = ((val * 50) / needed);
+
+ // SCORE_LOAN is inversed
+ if (val < 0 && i == SCORE_LOAN)
+ x = 0;
+
+ // Draw the bar
+ if (x != 0)
+ GfxFillRect(112, y-2, x + 112, y+10, color_done);
+ if (x != 50)
+ GfxFillRect(x + 112, y-2, 50 + 112, y+10, color_notdone);
+
// Calculate the %
- if (val > needed) x = 100;
- else x = ((val * 100) / needed);
+ if (val > needed) x = 100;
+ else x = ((val * 100) / needed);
+
+ // SCORE_LOAN is inversed
+ if (val < 0 && i == SCORE_LOAN)
+ x = 0;
- // SCORE_LOAN is inversed
- if (val < 0 && i == SCORE_LOAN)
- x = 0;
-
- // Draw it
- SetDParam(0, x);
- DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, 0);
-
- // SCORE_LOAN is inversed
- if (i == SCORE_LOAN)
- val = needed - val;
-
- // Draw the amount we have against what is needed
- // For some of them it is in currency format
- SetDParam(0, val);
- SetDParam(1, needed);
- switch (i) {
- case SCORE_MIN_PROFIT:
- case SCORE_MIN_INCOME:
- case SCORE_MAX_INCOME:
- case SCORE_MONEY:
- case SCORE_LOAN:
- DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, 0);
- break;
- default:
- DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, 0);
- }
- }
-
+ // Draw it
+ SetDParam(0, x);
+ DrawStringCentered(137, y, STR_PERFORMANCE_DETAIL_PERCENT, 0);
+
+ // SCORE_LOAN is inversed
+ if (i == SCORE_LOAN)
+ val = needed - val;
+
+ // Draw the amount we have against what is needed
+ // For some of them it is in currency format
+ SetDParam(0, val);
+ SetDParam(1, needed);
+ switch (i) {
+ case SCORE_MIN_PROFIT:
+ case SCORE_MIN_INCOME:
+ case SCORE_MAX_INCOME:
+ case SCORE_MONEY:
+ case SCORE_LOAN:
+ DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY, 0);
+ break;
+ default:
+ DrawString(167, y, STR_PERFORMANCE_DETAIL_AMOUNT_INT, 0);
+ }
+ }
+
break;
}
case WE_CLICK:
// Check which button is clicked
- if (IS_INT_INSIDE(e->click.widget, 13, 21)) {
+ if (IS_INT_INSIDE(e->click.widget, 13, 33)) {
// Is it no on disable?
if ((w->disabled_state & (1 << e->click.widget)) == 0) {
w->click_state = 1 << e->click.widget;
@@ -1013,8 +1056,7 @@
}
break;
- case WE_CREATE:
- {
+ case WE_CREATE: {
int i;
Player *p2;
w->hidden_state = 0;
@@ -1038,43 +1080,41 @@
w->click_state = 1 << 13;
SetWindowDirty(w);
- }
- break;
- case WE_TICK:
- {
- // Update the player score every 5 days
- if (--w->custom[0] == 0) {
- w->custom[0] = DAY_TICKS;
- if (--w->custom[1] == 0) {
- Player *p2;
- w->custom[1] = 5;
- FOR_ALL_PLAYERS(p2)
- // Skip if player is not active
- if (p2->is_active)
- UpdateCompanyRatingAndValue(p2, false);
- SetWindowDirty(w);
+ }
+ break;
+ case WE_TICK: {
+ // Update the player score every 5 days
+ if (--w->custom[0] == 0) {
+ w->custom[0] = DAY_TICKS;
+ if (--w->custom[1] == 0) {
+ Player *p2;
+ w->custom[1] = 5;
+ FOR_ALL_PLAYERS(p2)
+ // Skip if player is not active
+ if (p2->is_active)
+ UpdateCompanyRatingAndValue(p2, false);
+ SetWindowDirty(w);
+ }
}
- }
- }
- break;
+ } break;
}
}
static const Widget _performance_rating_detail_widgets[] = {
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 298, 0, 13, STR_PERFORMANCE_DETAIL, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 14, 27, 0x0, STR_NULL},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 14, 40, 0x0, STR_NULL},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 28, 47, 0x0,STR_PERFORMANCE_DETAIL_VEHICLES_TIP},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 48, 67, 0x0,STR_PERFORMANCE_DETAIL_STATIONS_TIP},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 68, 87, 0x0,STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 88, 107, 0x0,STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 108, 127, 0x0,STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 128, 147, 0x0,STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 148, 167, 0x0,STR_PERFORMANCE_DETAIL_CARGO_TIP},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 168, 187, 0x0,STR_PERFORMANCE_DETAIL_MONEY_TIP},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 188, 207, 0x0,STR_PERFORMANCE_DETAIL_LOAN_TIP},
-{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 208, 227, 0x0,STR_PERFORMANCE_DETAIL_TOTAL_TIP},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 40, 59, 0x0,STR_PERFORMANCE_DETAIL_VEHICLES_TIP},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 60, 79, 0x0,STR_PERFORMANCE_DETAIL_STATIONS_TIP},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 80, 99, 0x0,STR_PERFORMANCE_DETAIL_MIN_PROFIT_TIP},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 100, 119, 0x0,STR_PERFORMANCE_DETAIL_MIN_INCOME_TIP},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 120, 139, 0x0,STR_PERFORMANCE_DETAIL_MAX_INCOME_TIP},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 140, 159, 0x0,STR_PERFORMANCE_DETAIL_DELIVERED_TIP},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 160, 179, 0x0,STR_PERFORMANCE_DETAIL_CARGO_TIP},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 180, 199, 0x0,STR_PERFORMANCE_DETAIL_MONEY_TIP},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 200, 219, 0x0,STR_PERFORMANCE_DETAIL_LOAN_TIP},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 298, 220, 239, 0x0,STR_PERFORMANCE_DETAIL_TOTAL_TIP},
{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 38, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_IMGBTN, RESIZE_NONE, 14, 39, 75, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
@@ -1084,11 +1124,19 @@
{ WWT_IMGBTN, RESIZE_NONE, 14, 187, 223, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_IMGBTN, RESIZE_NONE, 14, 224, 260, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WWT_IMGBTN, RESIZE_NONE, 14, 261, 297, 14, 26, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 2, 38, 27, 39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 39, 75, 27, 39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 76, 112, 27, 39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 113, 149, 27, 39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 150, 186, 27, 39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 187, 223, 27, 39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 224, 260, 27, 39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
+{ WWT_IMGBTN, RESIZE_NONE, 14, 261, 297, 27, 39, 0x0,STR_704F_CLICK_HERE_TO_TOGGLE_COMPANY},
{ WIDGETS_END},
};
static const WindowDesc _performance_rating_detail_desc = {
- -1, -1, 299, 228,
+ -1, -1, 299, 240,
WC_PERFORMANCE_DETAIL,0,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_performance_rating_detail_widgets,
@@ -1172,9 +1220,7 @@
}
{ const SignStruct *ss;
- uint16 i;
-
- /* Start drawing the signs */
+ uint16 i; /* Start drawing the signs */
for (i = w->vscroll.pos; i < w->vscroll.cap + w->vscroll.pos && i < w->vscroll.count; i++) {
ss = GetSign(_sign_sort[i]);
Index: engine.h
===================================================================
--- engine.h (revision 2833)
+++ engine.h (working copy)
@@ -85,7 +85,7 @@
PlayerID preview_player;
byte preview_wait;
byte railtype;
- PlayerID player_avail;
+ uint64 player_avail;
byte type; // type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h
} Engine;
Index: network.c
===================================================================
--- network.c (revision 2833)
+++ network.c (working copy)
@@ -1303,7 +1303,7 @@
}
#endif // __MORPHOS__ / __AMIGA__
- // Network is available
+ // Network is available
_network_available = true;
_network_dedicated = false;
_network_last_advertise_date = 0;
@@ -1320,9 +1320,8 @@
memset(&_network_game_info, 0, sizeof(_network_game_info));
- /* XXX - Hard number here, because the strings can currently handle no more
- than 10 clients -- TrueLight */
- _network_game_info.clients_max = 10;
+ // Default, can be anything up to MAX_CLIENTS
+ _network_game_info.clients_max = 40;
// Let's load the network in windows
#if defined(WIN32)
Index: network.h
===================================================================
--- network.h (revision 2833)
+++ network.h (working copy)
@@ -22,11 +22,11 @@
// so in theory, this next define can be left off.
//#define NETWORK_SEND_DOUBLE_SEED
-// How many clients can we have? Like.. MAX_PLAYERS - 1 is the amount of
-// players that can really play.. so.. a max of 4 spectators.. gives us..
-// MAX_PLAYERS + 3
-#define MAX_CLIENTS (MAX_PLAYERS + 3)
+// That maximum number of spectators we can have
+#define MAX_SPECTATORS 10
+// How many clients can we have? As many as you want really...
+#define MAX_CLIENTS 40
// Do not change this next line. It should _ALWAYS_ be MAX_CLIENTS + 1
#define MAX_CLIENT_INFO (MAX_CLIENTS + 1)
@@ -40,7 +40,6 @@
#define MAX_INTERFACES 9
-
// How many vehicle/station types we put over the network
#define NETWORK_VEHICLE_TYPES 5
#define NETWORK_STATION_TYPES 5
Index: lang/english.txt
===================================================================
--- lang/english.txt (revision 2833)
+++ lang/english.txt (working copy)
@@ -1226,19 +1226,10 @@
STR_NETWORK_INTERNET :Internet
STR_NETWORK_LAN_INTERNET :LAN / Internet
STR_NETWORK_INTERNET_ADVERTISE :Internet (advertise)
-STR_NETWORK_COMBO2 :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
-STR_NETWORK_2_CLIENTS :2 clients
-STR_NETWORK_3_CLIENTS :3 clients
-STR_NETWORK_4_CLIENTS :4 clients
-STR_NETWORK_5_CLIENTS :5 clients
-STR_NETWORK_6_CLIENTS :6 clients
-STR_NETWORK_7_CLIENTS :7 clients
-STR_NETWORK_8_CLIENTS :8 clients
-STR_NETWORK_9_CLIENTS :9 clients
-STR_NETWORK_10_CLIENTS :10 clients
+STR_NETWORK_NUM_CLIENTS :{NUM} clients
STR_NETWORK_LANGUAGE_SPOKEN :{BLACK}Language spoken:
STR_NETWORK_LANGUAGE_TIP :{BLACK}Other players will know which language is spoken on the server
-STR_NETWORK_COMBO3 :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
+STR_NETWORK_COMBO2 :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
STR_NETWORK_START_GAME :{BLACK}Start Game
STR_NETWORK_START_GAME_TIP :{BLACK}Start a new network game from a random map, or scenario
STR_NETWORK_LOAD_GAME :{BLACK}Load Game
Index: openttd.c
===================================================================
--- openttd.c (revision 2833)
+++ openttd.c (working copy)
@@ -1121,7 +1121,29 @@
SetTileOwner(tile_cur, OWNER_WATER);
END_TILE_LOOP(tile_cur, w, h, tile)
}
+
+ // update new special owners so up to 60 human / ai players can be used
+ //
+ // Note: We can't use GetTileOwner or SetTileOwnder, because the owners
+ // have not yet been converted, so this will give us assertions
+ //
+ if (version <= 0xf00) {
+ TileIndex tile = TileXY(0, 0);
+ uint w = MapSizeX();
+ uint h = MapSizeY();
+ BEGIN_TILE_LOOP(tile_cur, w, h, tile)
+ if (_m[tile_cur].owner == 0xf)
+ _m[tile_cur].owner = OWNER_TOWN;
+ if (_m[tile_cur].owner == 0x10)
+ _m[tile_cur].owner = OWNER_NONE;
+ if (_m[tile_cur].owner == 0x11)
+ _m[tile_cur].owner = OWNER_WATER;
+ if (_m[tile_cur].owner == 0xff)
+ _m[tile_cur].owner = OWNER_SPECTATOR;
+ END_TILE_LOOP(tile_cur, w, h, tile)
+ }
+
// convert road side to my format.
if (_opt.road_side) _opt.road_side = 1;
Index: saveload.c
===================================================================
--- saveload.c (revision 2833)
+++ saveload.c (working copy)
@@ -28,7 +28,7 @@
#include "variables.h"
enum {
- SAVEGAME_MAJOR_VERSION = 16,
+ SAVEGAME_MAJOR_VERSION = 17,
SAVEGAME_MINOR_VERSION = 0,
SAVEGAME_LOADABLE_VERSION = (SAVEGAME_MAJOR_VERSION << 8) + SAVEGAME_MINOR_VERSION
Index: player.h
===================================================================
--- player.h (revision 2833)
+++ player.h (working copy)
@@ -203,7 +203,11 @@
extern PlayerID _current_player;
-#define MAX_PLAYERS 8
+// Remember there need to be 4 reserved players (see map.h)
+// Without major changes this will not work above 64
+// There will also be a few bugs (i.e. not enough colours) if you
+// set it to anything above 16
+#define MAX_PLAYERS 16
VARDEF Player _players[MAX_PLAYERS];
// NOSAVE: can be determined from player structs
VARDEF byte _player_colors[MAX_PLAYERS];
Index: smallmap_gui.c
===================================================================
--- smallmap_gui.c (revision 2833)
+++ smallmap_gui.c (working copy)
@@ -506,7 +506,7 @@
}
-static uint32 _owner_colors[256];
+static uint64 _owner_colors[256];
/**
* Return the color a tile would be displayed with in the small map in mode "Owner".
@@ -519,7 +519,7 @@
TileType t = GetTileType(tile);
if (t == MP_INDUSTRY) {
- t = 0xff;
+ t = 0x3f;
} else if (t == MP_HOUSE || IsTileOwner(tile, OWNER_TOWN)) {
t = 0x80;
} else {
@@ -610,9 +610,9 @@
memset(&_owner_colors[128], 0xB4, 128 * sizeof(*_owner_colors));
/* fill with some special colors */
- _owner_colors[0x10] = MKCOLOR(0x54545454);
- _owner_colors[0x11] = MKCOLOR(0xCACACACA);
- _owner_colors[0xff] = MKCOLOR(0x20202020); /* industry */
+ _owner_colors[OWNER_NONE] = MKCOLOR(0x54545454);
+ _owner_colors[OWNER_WATER] = MKCOLOR(0xCACACACA);
+ _owner_colors[0x3f] = MKCOLOR(0x20202020); /* industry */
/* now fill with the player colors */
FOR_ALL_PLAYERS(p) {
Index: map.h
===================================================================
--- map.h (revision 2833)
+++ map.h (working copy)
@@ -71,10 +71,10 @@
}
typedef enum {
- OWNER_TOWN = 0xf, // a town owns the tile
- OWNER_NONE = 0x10, // nobody owns the tile
- OWNER_WATER = 0x11, // "water" owns the tile
- OWNER_SPECTATOR = 0xff, // spectator in MP or in scenario editor
+ OWNER_TOWN = 0x3C, // a town owns the tile
+ OWNER_NONE = 0x3D, // nobody owns the tile
+ OWNER_WATER = 0x3E, // "water" owns the tile
+ OWNER_SPECTATOR = 0x3F, // spectator in MP or in scenario editor
} Owner;
enum {
Index: network_gui.c
===================================================================
--- network_gui.c (revision 2833)
+++ network_gui.c (working copy)
@@ -414,19 +414,6 @@
UpdateNetworkGameWindow(true);
}
-static const StringID _players_dropdown[] = {
- STR_NETWORK_2_CLIENTS,
- STR_NETWORK_3_CLIENTS,
- STR_NETWORK_4_CLIENTS,
- STR_NETWORK_5_CLIENTS,
- STR_NETWORK_6_CLIENTS,
- STR_NETWORK_7_CLIENTS,
- STR_NETWORK_8_CLIENTS,
- STR_NETWORK_9_CLIENTS,
- STR_NETWORK_10_CLIENTS,
- INVALID_STRING_ID
-};
-
static const StringID _language_dropdown[] = {
STR_NETWORK_LANG_ANY,
STR_NETWORK_LANG_ENGLISH,
@@ -450,10 +437,10 @@
case WE_PAINT: {
int y = NSSWND_START, pos;
+ int color = PALETTE_MODIFIER_COLOR | _color_list[3].unk2;
const FiosItem *item;
SetDParam(7, STR_NETWORK_LAN_INTERNET + _network_advertise);
- SetDParam(9, STR_NETWORK_2_CLIENTS + _network_game_info.clients_max - 2);
SetDParam(11, STR_NETWORK_LANG_ANY + _network_game_info.server_lang);
DrawWindowWidgets(w);
@@ -465,11 +452,25 @@
DrawString(10, 43, STR_NETWORK_SELECT_MAP, 2);
DrawString(280, 63, STR_NETWORK_CONNECTION, 2);
- DrawString(280, 95, STR_NETWORK_NUMBER_OF_CLIENTS, 2);
+ DrawString(280, 98, STR_NETWORK_NUMBER_OF_CLIENTS, 2);
DrawString(280, 127, STR_NETWORK_LANGUAGE_SPOKEN, 2);
if (_network_game_info.use_password) DoDrawString("*", 408, 23, 3);
+ // draw number of clients selecter
+ DrawFrameRect( 280, 112, 280 + 8, 112 + 8, 3, 0);
+ DrawFrameRect(290, 112, 290 + 8, 112 + 8, 3, 0);
+ if (_network_game_info.clients_max <= 1)
+ GfxFillRect( 281, 112 + 1, 281 + 8, 112 + 8, color);
+ if (_network_game_info.clients_max >= MAX_CLIENTS)
+ GfxFillRect(291, 112 + 1, 291 + 8, 112 + 8, color);
+
+ DrawStringCentered(285, 112, STR_6819, 0);
+ DrawStringCentered(295, 112, STR_681A, 0);
+
+ SetDParam(0, _network_game_info.clients_max);
+ DrawString(311, 112, STR_NETWORK_NUM_CLIENTS, 2);
+
// draw list of maps
pos = w->vscroll.pos;
while (pos < _fios_num + 1) {
@@ -484,12 +485,26 @@
if (y >= w->vscroll.cap * NSSWND_ROWSIZE + NSSWND_START) break;
}
- } break;
+ } break;
- case WE_CLICK:
+ case WE_CLICK: {
+ int x, y;
_selected_field = e->click.widget;
+
+ x = e->click.pt.x;
+ y = e->click.pt.y;
+ if (IS_INT_INSIDE(x, 280, 300) && IS_INT_INSIDE(y, 112, 120)) // Button area
+ {
+ if (IS_INT_INSIDE(x, 280, 290) && _network_game_info.clients_max > 1)
+ _network_game_info.clients_max--;
+ if (IS_INT_INSIDE(x, 290, 300) && _network_game_info.clients_max < MAX_CLIENTS)
+ _network_game_info.clients_max++;
+ SetWindowDirty(w);
+ break;
+ }
+
switch(e->click.widget) {
- case 0: case 15: /* Close 'X' | Cancel button */
+ case 0: case 13: /* Close 'X' | Cancel button */
ShowNetworkGameWindow();
break;
case 4: { /* Set password button */
@@ -507,13 +522,10 @@
case 7: case 8: /* Connection type */
ShowDropDownMenu(w, _connection_types_dropdown, _network_advertise, 8, 0, 0); // do it for widget 8
break;
- case 9: case 10: /* Number of Players */
- ShowDropDownMenu(w, _players_dropdown, _network_game_info.clients_max - 2, 10, 0, 0); // do it for widget 10
+ case 9: case 10: /* Language */
+ ShowDropDownMenu(w, _language_dropdown, _network_game_info.server_lang, 10, 0, 0); // do it for widget 10
return;
- case 11: case 12: /* Language */
- ShowDropDownMenu(w, _language_dropdown, _network_game_info.server_lang, 12, 0, 0); // do it for widget 12
- return;
- case 13: /* Start game */
+ case 11: /* Start game */
_is_network_server = true;
ttd_strlcpy(_network_server_name, WP(w, querystr_d).text.buf, sizeof(_network_server_name));
UpdateTextBufferSize(&WP(w, querystr_d).text);
@@ -531,7 +543,7 @@
}
}
break;
- case 14: /* Load game */
+ case 12: /* Load game */
_is_network_server = true;
ttd_strlcpy(_network_server_name, WP(w, querystr_d).text.buf, sizeof(_network_server_name));
UpdateTextBufferSize(&WP(w, querystr_d).text);
@@ -542,16 +554,13 @@
break;
}
break;
-
+ } break;
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
switch(e->dropdown.button) {
case 8:
_network_advertise = (e->dropdown.index != 0);
break;
case 10:
- _network_game_info.clients_max = e->dropdown.index + 2;
- break;
- case 12:
_network_game_info.server_lang = e->dropdown.index;
break;
}
@@ -592,10 +601,7 @@
{ WWT_6, RESIZE_NONE, BGC, 280, 410, 77, 88, STR_NETWORK_COMBO1, STR_NETWORK_CONNECTION_TIP},
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 399, 409, 78, 87, STR_0225, STR_NETWORK_CONNECTION_TIP},
-{ WWT_6, RESIZE_NONE, BGC, 280, 410, 109, 120, STR_NETWORK_COMBO2, STR_NETWORK_NUMBER_OF_CLIENTS_TIP},
-{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 399, 409, 110, 119, STR_0225, STR_NETWORK_NUMBER_OF_CLIENTS_TIP},
-
-{ WWT_6, RESIZE_NONE, BGC, 280, 410, 141, 152, STR_NETWORK_COMBO3, STR_NETWORK_LANGUAGE_TIP},
+{ WWT_6, RESIZE_NONE, BGC, 280, 410, 141, 152, STR_NETWORK_COMBO2, STR_NETWORK_LANGUAGE_TIP},
{ WWT_CLOSEBOX, RESIZE_NONE, BGC, 399, 409, 142, 151, STR_0225, STR_NETWORK_LANGUAGE_TIP},
{ WWT_PUSHTXTBTN, RESIZE_NONE, BTC, 40, 140, 180, 191, STR_NETWORK_START_GAME, STR_NETWORK_START_GAME_TIP},
@@ -662,6 +668,7 @@
if (_network_lobby_company_count == 0)
SETBIT(w->disabled_state, 9);
+ SetVScrollCount(w, _network_lobby_company_count);
DrawWindowWidgets(w);
SetDParamStr(0, _selected_item->info.server_name);
@@ -687,7 +694,7 @@
pos++;
y += NET_PRC__SIZE_OF_ROW_COMPANY;
- if (pos >= w->vscroll.cap)
+ if (pos >= w->vscroll.cap + w->vscroll.pos)
break;
}
@@ -838,7 +845,7 @@
w = AllocateWindowDesc(&_network_lobby_window_desc);
strcpy(_edit_str_buf, "");
w->vscroll.pos = 0;
- w->vscroll.cap = 8;
+ w->vscroll.cap = 10;
}
@@ -1050,7 +1057,7 @@
}
}
- // A server can kick clients (but not hisself)
+ // A server can kick clients (but not himself)
if (_network_server && _network_own_client_index != ci->client_index) {
GetString(_clientlist_action[i], STR_NETWORK_CLIENTLIST_KICK);
_clientlist_proc[i++] = &ClientList_Kick;
Index: settings_gui.c
===================================================================
--- settings_gui.c (revision 2833)
+++ settings_gui.c (working copy)
@@ -291,7 +291,7 @@
} GameSettingData;
static const GameSettingData _game_setting_info[] = {
- { 0, 7, 1, STR_NULL},
+ { 0, MAX_PLAYERS - 1, 1, STR_NULL},
{ 0, 3, 1, STR_6830_IMMEDIATE},
{ 0, 2, 1, STR_6816_LOW},
{ 0, 3, 1, STR_26816_NONE},