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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
enum DisconnectSessionFlags
{
	NONE = 0,
	JOIN_ERROR_ENABLED = 1,
	JOIN_ERROR_CHECK = 2,
	DISCONNECT_ERROR_ENABLED = 4,
	SELECT_USER = 8,
	CLOSE_MENUS = 16,
	IGNORE_WHEN_IN_GAME = 32,
	ALWAYS_FORCE = 64,
}

const int DISCONNECT_SESSION_FLAGS_FORCE = int.MAX & ~DisconnectSessionFlags.IGNORE_WHEN_IN_GAME;
const int DISCONNECT_SESSION_FLAGS_JOIN = int.MAX & ~DisconnectSessionFlags.JOIN_ERROR_CHECK;
const int DISCONNECT_SESSION_FLAGS_ALL = int.MAX;

class ProjectileStoppedInfo : Managed
{
	proto native Object GetSource();
	proto native vector GetPos();
	proto native vector GetInVelocity();
	proto native string GetAmmoType();
	proto native float GetProjectileDamage();
}

class CollisionInfoBase: ProjectileStoppedInfo
{
	proto native vector GetSurfNormal();
}

class ObjectCollisionInfo: CollisionInfoBase
{
	proto native Object GetHitObj();
	proto native vector GetHitObjPos();
	proto native vector GetHitObjRot();
	proto native int GetComponentIndex();
}

class TerrainCollisionInfo: CollisionInfoBase
{
	proto native bool GetIsWater();
}

class CrashSoundSets
{
	static ref map<int, string> m_Mappings = new map<int, string>;
	
	static void RegisterSoundSet(string sound_set)
	{
		m_Mappings.Set(sound_set.Hash(), sound_set);
	}
	
	static string GetSoundSetByHash(int hash)
	{
		string sound_set;
		if (m_Mappings)
			m_Mappings.Find(hash,sound_set);
		return sound_set;
	}
};


class LoginScreenBase extends UIScriptedMenu
{
	protected ref UiHintPanelLoading m_HintPanel;
	protected bool m_IsStatic;
	protected float m_HintTimeAccu;
	
	override void Update(float timeslice)
	{
		if (m_HintPanel)
		{
			m_HintTimeAccu += timeslice;
			if (CanChangeHintPage(m_HintTimeAccu))
			{
				m_HintPanel.ShowRandomPage();
				m_HintTimeAccu = 0;
			}
		}
		
		if (GetUApi().GetInputByID(UAUIBack).LocalPress())
		{
			Leave();
		}
	}
	
	protected void Leave()
	{
		g_Game.SetGameState(DayZGameState.MAIN_MENU);
		g_Game.SetLoadState(DayZLoadState.MAIN_MENU_START);
		
		g_Game.GetCallQueue(CALL_CATEGORY_SYSTEM).Call(GetGame().DisconnectSessionForce);
		
		Close();
	}
	
	protected bool CanChangeHintPage(float timeAccu);
	
	bool IsStatic()
	{
		return m_IsStatic;
	}
}

class LoginQueueBase extends LoginScreenBase
{
	protected TextWidget m_txtPosition;
	protected TextWidget m_txtNote;
	protected ButtonWidget m_btnLeave;
	protected int m_iPosition = -1;
	
	void LoginQueueBase()
	{		
		g_Game.SetKeyboardHandle(this);	
	}

	void ~LoginQueueBase()
	{
		g_Game.SetKeyboardHandle(NULL);	
	}
	
	override Widget Init()
	{		
		layoutRoot 		= GetGame().GetWorkspace().CreateWidgets("gui/layouts/dialog_queue_position.layout");
		m_HintPanel	= new UiHintPanelLoading(layoutRoot.FindAnyWidget("hint_frame0"));
		m_txtPosition	= TextWidget.Cast(layoutRoot.FindAnyWidget("txtPosition"));
		m_txtNote 		= TextWidget.Cast(layoutRoot.FindAnyWidget("txtNote"));
		m_btnLeave 		= ButtonWidget.Cast(layoutRoot.FindAnyWidget("btnLeave"));
		m_txtNote.Show(true);
		layoutRoot.FindAnyWidget("notification_root").Show(false);
		
		#ifdef PLATFORM_CONSOLE
		layoutRoot.FindAnyWidget("toolbar_bg").Show(true);
		RichTextWidget toolbar_b = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
		toolbar_b.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
		#ifdef PLATFORM_XBOX
		#ifdef BUILD_EXPERIMENTAL
		layoutRoot.FindAnyWidget("notification_root").Show(true);
		#endif
		#endif
		#endif

		return layoutRoot;
	}
	
	override bool OnClick(Widget w, int x, int y, int button)
	{
		super.OnClick(w, x, y, button);
		if (w == m_btnLeave)
		{
			Leave();
			return true;
		}
		return false;
	}
	
	void Show()
	{
		if (layoutRoot)
		{
			layoutRoot.Show(true);
		}
	}
	
	void Hide()
	{
		if (layoutRoot)
			layoutRoot.Show(false);
		m_HintPanel = null;
	}
	
	void SetPosition(int position)
	{
		if (position != m_iPosition)
		{
			m_iPosition = position;
			m_txtPosition.SetText(position.ToString());
		}
	}
	
	override protected bool CanChangeHintPage(float timeAccu)
	{
		return timeAccu >= GameConstants.LOADING_SCREEN_HINT_INTERVAL;
	}
};


//! LoginQueue position when using -connect since mission is not created yet 
class LoginQueueStatic extends LoginQueueBase
{
	void LoginQueueStatic()
	{
		Init();
		
		m_IsStatic = true;
	}
};

class LoginTimeBase extends LoginScreenBase
{
	protected TextWidget m_txtDescription;
	protected TextWidget m_txtLabel;
	protected ButtonWidget m_btnLeave;
	
	protected bool m_IsRespawn;
	
	private ref FullTimeData m_FullTime;
	
	void LoginTimeBase()
	{
		g_Game.SetKeyboardHandle(this);
		m_IsRespawn = false;
		
		m_FullTime = new FullTimeData();
	}

	void ~LoginTimeBase()
	{
		if (g_Game)
			g_Game.SetKeyboardHandle(null);
		m_FullTime = null;
	}
	
	override Widget Init()
	{
		layoutRoot 			= GetGame().GetWorkspace().CreateWidgets("gui/layouts/dialog_login_time.layout");
		
		m_txtDescription 	= TextWidget.Cast(layoutRoot.FindAnyWidget("txtDescription"));
		m_txtLabel 			= TextWidget.Cast(layoutRoot.FindAnyWidget("txtLabel"));
		m_btnLeave 			= ButtonWidget.Cast(layoutRoot.FindAnyWidget("btnLeave"));
		m_txtDescription.Show(true);
		layoutRoot.FindAnyWidget("notification_root").Show(false);
		
		#ifdef PLATFORM_CONSOLE
		layoutRoot.FindAnyWidget("toolbar_bg").Show(true);
		RichTextWidget toolbar_b = RichTextWidget.Cast(layoutRoot.FindAnyWidget("BackIcon"));
		toolbar_b.SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
		#ifdef PLATFORM_XBOX
		#ifdef BUILD_EXPERIMENTAL
		layoutRoot.FindAnyWidget("notification_root").Show(true);
		#endif
		#endif
		#endif

		return layoutRoot;
	}
		
	override bool OnClick(Widget w, int x, int y, int button)
	{
		super.OnClick(w, x, y, button);
		if (w == m_btnLeave)
		{
			Leave();
			return true;
		}
		return false;
	}
		
	void Show()
	{
		if (layoutRoot)
		{
			layoutRoot.Show(true);
			m_HintPanel	= new UiHintPanelLoading(layoutRoot.FindAnyWidget("hint_frame0"));
		}
	}
	
	void Hide()
	{
		if (layoutRoot)
			layoutRoot.Show(false);
		m_HintPanel = null;
	}
	
	void SetTime(int time)
	{
		string text = "";
		TimeConversions.ConvertSecondsToFullTime(time, m_FullTime);
		if (!m_IsRespawn)
			text = "#menu_loading_in_";
		else
			text = "#dayz_game_spawning_in_";
		
		if (m_FullTime.m_Days > 0)
			text += "dhms";
		else if (m_FullTime.m_Hours > 0)
			text += "hms";
		else if (m_FullTime.m_Minutes > 0)
			text += "ms";
		else
			text += "s";
		
		text = Widget.TranslateString(text);
		text = string.Format(text, m_FullTime.m_Seconds, m_FullTime.m_Minutes, m_FullTime.m_Hours, m_FullTime.m_Days);
		m_txtLabel.SetText(text);
		
		if (m_IsRespawn && time <= 1)
			GetGame().SetLoginTimerFinished();
	}
		
	void SetStatus(string status)
	{
		m_txtDescription.SetText(status);
	}
	
	void SetRespawn(bool value)
	{
		m_IsRespawn = value;
	}
	
	bool IsRespawn()
	{
		return m_IsRespawn;
	}
	
	override protected bool CanChangeHintPage(float timeAccu)
	{
		return timeAccu >= GameConstants.LOADING_SCREEN_HINT_INTERVAL && m_FullTime.m_Seconds >= GameConstants.LOADING_SCREEN_HINT_INTERVAL_MIN;
	}
};

//! LoginTime when using -connect since mission is not created yet 
class LoginTimeStatic extends LoginTimeBase
{
	void LoginTimeStatic()
	{
		Init();
		
		m_IsStatic = true;
	}
	
	void ~LoginTimeStatic()
	{
	}
};



class ConnectionLost
{
	private ref Widget m_WidgetRoot;
	private TextWidget m_TextWidgetTitle;
	private float m_duration;
		
	void ConnectionLost(DayZGame game)
	{		
		m_WidgetRoot = game.GetWorkspace().CreateWidgets("gui/layouts/day_z_connection_lost.layout");
		m_WidgetRoot.Show(false);
		
		Class.CastTo(m_TextWidgetTitle, m_WidgetRoot.FindAnyWidget("TextWidget"));
		m_duration = 0.0;
	}
	
	void Show()
	{
		if (!m_WidgetRoot.IsVisible())
		{
			if (g_Game.GetUIManager().IsDialogVisible())
			{
				g_Game.GetUIManager().HideDialog();
			}
			
			m_WidgetRoot.Show(true);
			m_TextWidgetTitle.SetText("");
		}
	}
	
	void Hide()
	{
		if (m_WidgetRoot.IsVisible())
		{
			m_WidgetRoot.Show(false);
		}
	}
	
	void SetText(string text)
	{
		m_TextWidgetTitle.SetText(text);
	}
	
	float GetDuration()
	{
		return m_duration;
	}
	
	void SetDuration(float duration)
	{
		m_duration = duration;
	}
};

typedef Param3<string, bool, bool> DayZProfilesOption;
typedef DayZProfilesOption DayZProfilesOptionBool;
typedef Param3<string, int, int> DayZProfilesOptionInt;
typedef Param3<string, float, float> DayZProfilesOptionFloat;

class DayZProfilesOptions
{
	private ref map<EDayZProfilesOptions, ref DayZProfilesOptionBool> m_DayZProfilesOptionsBool;
	private ref map<EDayZProfilesOptions, ref DayZProfilesOptionInt> m_DayZProfilesOptionsInt;
	private ref map<EDayZProfilesOptions, ref DayZProfilesOptionFloat> m_DayZProfilesOptionsFloat;
	private DayZGame m_Game
	
	void DayZProfilesOptions()
	{
		m_DayZProfilesOptionsBool 	= new map<EDayZProfilesOptions, ref DayZProfilesOptionBool>();
		m_DayZProfilesOptionsInt 	= new map<EDayZProfilesOptions, ref DayZProfilesOptionInt>();
		m_DayZProfilesOptionsFloat 	= new map<EDayZProfilesOptions, ref DayZProfilesOptionFloat>();
	}

	void RegisterProfileOption(EDayZProfilesOptions option, string profileOptionName, bool def = true)
	{
		if (!m_DayZProfilesOptionsBool.Contains(option))
		{
			//! init of DayZProfilesOption - profileOptionName, value from Profiles files, or use default value
			bool profileVal = GetProfileValueBool(profileOptionName, def);

			m_DayZProfilesOptionsBool.Set(option, new DayZProfilesOptionBool(profileOptionName, profileVal, def));
			SetProfileOptionBool(option, profileVal);
		}
	}
	
	void RegisterProfileOptionBool(EDayZProfilesOptions option, string profileOptionName, bool defaultValue = true)
	{
		RegisterProfileOption(option, profileOptionName, defaultValue);
	}
	
	void RegisterProfileOptionInt(EDayZProfilesOptions option, string profileOptionName, int defaultValue = 0)
	{
		if (!m_DayZProfilesOptionsInt.Contains(option))
		{
			//! init of DayZProfilesOption - profileOptionName, value from Profiles files, or use default value
			string outValue;
			GetGame().GetProfileString(profileOptionName, outValue);
			int value = outValue.ToInt();

			m_DayZProfilesOptionsInt.Set(option, new DayZProfilesOptionInt(profileOptionName, value, defaultValue));
			SetProfileOptionInt(option, value);
		}
	}
	
	void RegisterProfileOptionFloat(EDayZProfilesOptions option, string profileOptionName, float defaultValue = 0.0)
	{
		if (!m_DayZProfilesOptionsFloat.Contains(option))
		{
			//! init of DayZProfilesOption - profileOptionName, value from Profiles files, or use default value
			string outValue;
			GetGame().GetProfileString(profileOptionName, outValue);
			float value = outValue.ToFloat();

			m_DayZProfilesOptionsFloat.Set(option, new DayZProfilesOptionFloat(profileOptionName, value, defaultValue));
			SetProfileOptionFloat(option, value);
		}
	}

	void ResetOptionsBool()
	{
		if (!m_DayZProfilesOptionsBool)
		{
			m_DayZProfilesOptionsBool = new map<EDayZProfilesOptions, ref DayZProfilesOptionBool>();
		}

		foreach (EDayZProfilesOptions e_opt, DayZProfilesOptionBool r_opt : m_DayZProfilesOptionsBool)
		{
			bool profileVal = GetProfileValueBool(r_opt.param1, r_opt.param3);
			SetProfileOptionBool(e_opt, profileVal);
		}	
	}
	
	void ResetOptions()
	{
		ResetOptionsBool();
	}
	
	void ResetOptionsInt()
	{
		if (!m_DayZProfilesOptionsInt)
		{
			m_DayZProfilesOptionsInt = new map<EDayZProfilesOptions, ref DayZProfilesOptionInt>();
		}

		foreach (EDayZProfilesOptions e_opt, DayZProfilesOptionInt r_opt : m_DayZProfilesOptionsInt)
		{
			string outValue;
			GetGame().GetProfileString(r_opt.param1, outValue);
			int value = outValue.ToInt();
			SetProfileOptionInt(e_opt, value);
		}	
	}
	
	void ResetOptionsFloat()
	{
		if (!m_DayZProfilesOptionsFloat)
		{
			m_DayZProfilesOptionsFloat = new map<EDayZProfilesOptions, ref DayZProfilesOptionFloat>();
		}

		foreach (EDayZProfilesOptions e_opt, DayZProfilesOptionFloat r_opt : m_DayZProfilesOptionsFloat)
		{
			string outValue;
			GetGame().GetProfileString(r_opt.param1, outValue);
			float value = outValue.ToFloat();
			SetProfileOptionFloat(e_opt, value);
		}	
	}
	
	void SetProfileOption(EDayZProfilesOptions option, bool value)
	{
		if (m_DayZProfilesOptionsBool && m_DayZProfilesOptionsBool.Contains(option))
		{
			DayZProfilesOptionBool po = m_DayZProfilesOptionsBool.Get(option);
			
			po.param2 = value;
			GetGame().SetProfileString(po.param1, value.ToString());
			GetGame().SaveProfile();
		}	
	}

	void SetProfileOptionBool(EDayZProfilesOptions option, bool value)
	{
		SetProfileOption(option, value);
	}
	
	void SetProfileOptionInt(EDayZProfilesOptions option, int value)
	{
		if (m_DayZProfilesOptionsInt && m_DayZProfilesOptionsInt.Contains(option))
		{
			DayZProfilesOptionInt po = m_DayZProfilesOptionsInt.Get(option);
			
			po.param2 = value;
			GetGame().SetProfileString(po.param1, value.ToString());
			GetGame().SaveProfile();
		}	
	}
	
	void SetProfileOptionFloat(EDayZProfilesOptions option, float value)
	{
		if (m_DayZProfilesOptionsFloat && m_DayZProfilesOptionsFloat.Contains(option))
		{
			DayZProfilesOptionFloat po = m_DayZProfilesOptionsFloat.Get(option);
			
			po.param2 = value;
			GetGame().SetProfileString(po.param1, value.ToString());
			GetGame().SaveProfile();
		}	
	}

	bool GetProfileOption(EDayZProfilesOptions option)
	{
		if (m_DayZProfilesOptionsBool && m_DayZProfilesOptionsBool.Contains(option))
		{
			DayZProfilesOptionBool po = m_DayZProfilesOptionsBool.Get(option);
			return po.param2;
		}
		
		return true;
	}
	
	bool GetProfileOptionBool(EDayZProfilesOptions option)
	{
		return GetProfileOption(option);
	}
	
	int GetProfileOptionInt(EDayZProfilesOptions option)
	{
		if (m_DayZProfilesOptionsInt && m_DayZProfilesOptionsInt.Contains(option))
		{
			DayZProfilesOptionInt po = m_DayZProfilesOptionsInt.Get(option);
			return po.param2;
		}
		
		return 0;
	}
	
	float GetProfileOptionFloat(EDayZProfilesOptions option)
	{
		if (m_DayZProfilesOptionsFloat && m_DayZProfilesOptionsFloat.Contains(option))
		{
			DayZProfilesOptionFloat po = m_DayZProfilesOptionsFloat.Get(option);
			return po.param2;
		}
		
		return 0.0;
	}
	
	bool GetProfileOptionDefault(EDayZProfilesOptions option)
	{
		return GetProfileOptionDefaultBool(option);
	}
	
	bool GetProfileOptionDefaultBool(EDayZProfilesOptions option)
	{
		if (m_DayZProfilesOptionsBool && m_DayZProfilesOptionsBool.Contains(option))
		{
			DayZProfilesOptionBool po = m_DayZProfilesOptionsBool.Get(option);
			return po.param3;
		}
		
		ErrorEx("Invalid profile option id! Returning 'true'.", ErrorExSeverity.WARNING);
		return true;
	}
	
	int GetProfileOptionDefaultInt(EDayZProfilesOptions option)
	{
		if (m_DayZProfilesOptionsInt && m_DayZProfilesOptionsInt.Contains(option))
		{
			DayZProfilesOptionInt po = m_DayZProfilesOptionsInt.Get(option);
			return po.param3;
		}
		
		ErrorEx("Invalid profile option id! Returning '0'.", ErrorExSeverity.WARNING);
		return 0;
	}
	
	float GetProfileOptionDefaultFloat(EDayZProfilesOptions option)
	{
		if (m_DayZProfilesOptionsFloat && m_DayZProfilesOptionsFloat.Contains(option))
		{
			DayZProfilesOptionFloat po = m_DayZProfilesOptionsFloat.Get(option);
			return po.param3;
		}
		
		ErrorEx("Invalid profile option id! Returning '0.0'.", ErrorExSeverity.WARNING);
		return 0.0;
	}
	
	map<EDayZProfilesOptions, ref DayZProfilesOptionBool> GetProfileOptionMap()
	{
		if (m_DayZProfilesOptions)
			return m_DayZProfilesOptions;

		return null;
	}

	//!
	//! DEPRECATED
	private ref map<EDayZProfilesOptions, ref DayZProfilesOption> m_DayZProfilesOptions;
}

enum DayZGameState
{
	UNDEFINED,
	MAIN_MENU,
	JOIN,
	PARTY,
	CONNECT,
	CONNECTING,
	IN_GAME
}

enum DayZLoadState
{
	UNDEFINED,
	MAIN_MENU_START,
	MAIN_MENU_CONTROLLER_SELECT,
	MAIN_MENU_USER_SELECT,
	JOIN_START,
	JOIN_CONTROLLER_SELECT,
	JOIN_USER_SELECT,
	PARTY_START,
	PARTY_CONTROLLER_SELECT,
	PARTY_USER_SELECT,
	CONNECT_START,
	CONNECT_USER_SELECT,
	CONNECT_CONTROLLER_SELECT,
	MISSION_START,
	MISSION_USER_SELECT,
	MISSION_CONTROLLER_SELECT
}

class LoadingScreen
{
	ref Widget m_WidgetRoot;
	TextWidget m_TextWidgetTitle;
	TextWidget m_TextWidgetStatus;
	TextWidget m_ModdedWarning;
	ImageWidget m_ImageWidgetBackground;
	DayZGame m_DayZGame;
	float m_LastProgressUpdate;
	
	ImageWidget m_ImageLogoMid;
	ImageWidget m_ImageLogoCorner;
	ImageWidget m_ImageLoadingIcon;
	ImageWidget m_ImageBackground;
	ProgressBarWidget m_ProgressLoading;
	float m_ImageLoadingIconRotation;
	TextWidget m_ProgressText;
	
	int m_Counter;
	ref Timer m_Timer;
	ref UiHintPanelLoading m_HintPanel;
	void LoadingScreen(DayZGame game)
	{
		m_DayZGame = game;
		
		m_WidgetRoot = game.GetLoadingWorkspace().CreateWidgets("gui/layouts/loading.layout");
		Class.CastTo(m_ImageLogoMid, m_WidgetRoot.FindAnyWidget("ImageLogoMid"));
		Class.CastTo(m_ImageLogoCorner, m_WidgetRoot.FindAnyWidget("ImageLogoCorner"));
		
		Class.CastTo(m_TextWidgetTitle, m_WidgetRoot.FindAnyWidget("TextWidget"));
		Class.CastTo(m_TextWidgetStatus, m_WidgetRoot.FindAnyWidget("StatusText"));
		Class.CastTo(m_ImageWidgetBackground, m_WidgetRoot.FindAnyWidget("ImageBackground"));
		Class.CastTo(m_ImageLoadingIcon, m_WidgetRoot.FindAnyWidget("ImageLoadingIcon"));
		Class.CastTo(m_ModdedWarning, m_WidgetRoot.FindAnyWidget("ModdedWarning"));

		m_ImageBackground = ImageWidget.Cast(m_WidgetRoot.FindAnyWidget("ImageBackground"));
		m_ProgressLoading = ProgressBarWidget.Cast(m_WidgetRoot.FindAnyWidget("LoadingBar"));
		
		string tmp;
		m_ProgressText = TextWidget.Cast(m_WidgetRoot.FindAnyWidget("ProgressText"));
		if (GetGame())
		{
			m_ProgressText.Show(GetGame().CommandlineGetParam("loadingTest", tmp));
		}
		m_WidgetRoot.FindAnyWidget("notification_root").Show(false);
		
		#ifdef PLATFORM_CONSOLE
		#ifdef PLATFORM_XBOX
		#ifdef BUILD_EXPERIMENTAL
			Widget expNotification = m_WidgetRoot.FindAnyWidget("notification_root");
			if (expNotification)
			{
				expNotification.Show(true);
			}
		#endif
		#endif
		#endif
		
		m_ModdedWarning.Show(g_Game.ReportModded());
		m_ImageLogoMid.Show(true);
		m_ImageLogoCorner.Show(false);
		
		m_ImageWidgetBackground.Show(true);		
		m_Counter = 0;
				
		// lighten up your desktop
		game.GetBacklit().LoadingAnim();
		
		ProgressAsync.SetProgressData(m_ProgressLoading);
		ProgressAsync.SetUserData(m_ImageBackground);
	}

	//! DEPRECATED
	void OnTimer();
	
	void Inc()
	{
		m_LastProgressUpdate = m_DayZGame.GetTickTime();
		m_Counter++;
		if (m_Counter == 1)
		{
			Show();
		}
	}
	
	void Dec()
	{
		m_Counter = m_Counter - 1;
	
		if (m_Counter <= 0)
		{
			m_Counter = 0;
			EndLoading();
			m_HintPanel = null;
		}
	}
	
	void EndLoading()
	{
		ProgressAsync.SetProgressData(null);
		ProgressAsync.SetUserData(null);
		m_WidgetRoot.Show(false);
		GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(g_Game.CheckDialogs);
	}
	
	bool IsLoading()
	{
		return m_WidgetRoot.IsVisible();
	}
	
	void SetTitle(string title)
	{
		m_TextWidgetTitle.SetText(title);
	}
	
	void SetStatus(string status)
	{
		m_TextWidgetStatus.SetText(status);
	}
	
	void SetProgress(float val)
	{
		float time_delta = m_DayZGame.GetTickTime() - m_LastProgressUpdate;
		
		m_LastProgressUpdate = m_DayZGame.GetTickTime();
	}
	
	void OnUpdate(float timeslice)
	{

	}
	
	void ShowEx(DayZGame game)
	{
		if (!m_HintPanel)
		{
			m_HintPanel					= new UiHintPanelLoading(m_WidgetRoot.FindAnyWidget("hint_frame"));
			m_HintPanel.Init(game);
		}

		Show();
	}
	
	void Show()
	{
		Widget lIcon = m_ImageBackground;
		Widget pText = m_ProgressLoading;
		m_ProgressText.SetText("");
		m_ProgressLoading.SetCurrent(0.0);
		m_ImageBackground.SetMaskProgress(0.0);
		
		if (!m_WidgetRoot.IsVisible())
		{
			if (m_DayZGame.GetUIManager().IsDialogVisible())
			{
				m_DayZGame.GetUIManager().HideDialog();
			}
			
			if (m_DayZGame.GetMissionState() == DayZGame.MISSION_STATE_MAINMENU)
			{
				m_ImageLogoMid.Show(false);
				m_ImageLogoCorner.Show(false);				
				m_ImageWidgetBackground.Show(true);		
				m_TextWidgetStatus.Show(true);
			}
			else
			{
				m_ImageLogoMid.Show(true);
				m_ImageLogoCorner.Show(false);
				m_ImageWidgetBackground.Show(true);
				m_TextWidgetStatus.Show(false);
			}
			
			m_WidgetRoot.Show(true);
			m_TextWidgetTitle.SetText("");
			m_TextWidgetStatus.SetText("");
		}
		
		ProgressAsync.SetProgressData(pText);
		ProgressAsync.SetUserData(lIcon);
	}
	
	void Hide(bool force)
	{
		if (force)
		{
			while (m_Counter > 0)
			{
				Dec();
			}
		}

		if (m_Counter <= 0)
		{
			m_WidgetRoot.Show(false);
			ProgressAsync.SetUserData(null);
			ProgressAsync.SetProgressData(null);
			m_HintPanel = null;
		}
	}
};


class DayZGame extends CGame
{
	protected ref BillboardSetHandler m_BillboardSetHandler;
	
	const int MISSION_STATE_MAINMENU = 0;
	const int MISSION_STATE_GAME = 1;
	const int MISSION_STATE_FINNISH = 2;
	
	private const int STATS_COUNT = EConnectivityStatType.COUNT;
	private EConnectivityStatLevel m_ConnectivityStatsStates[STATS_COUNT];
	
	private int m_MissionState;
	
	//HK stuff
	protected DayZGameState						m_GameState;
	protected DayZLoadState						m_LoadState;
	protected ref NotificationUI				m_Notifications;
	protected bool								m_FirstConnect = true;
	//End HK stuff
	
	ref LoadingScreen m_loading;
	private ref LoginTimeBase m_LoginTimeScreen;
	private ref LoginQueueBase m_LoginQueue;
	private int m_LoginTime;
	
	private ref ConnectionLost m_connectionLost;
	private ref TimerQueue m_timerQueue[CALL_CATEGORY_COUNT];
	private ref ScriptCallQueue m_callQueue[CALL_CATEGORY_COUNT];
	private ref ScriptInvoker m_updateQueue[CALL_CATEGORY_COUNT];
	private ref ScriptInvoker m_postUpdateQueue[CALL_CATEGORY_COUNT];
	private ref DragQueue m_dragQueue;
	private ref DayZProfilesOptions m_DayZProfileOptions;
	private bool m_early_access_dialog_accepted;
	private UIScriptedMenu m_keyboard_handler;
	private ScriptModule m_mission_module;
	private string 	m_MissionPath;
	private string 	m_MissionFolderPath;
	private bool	m_IsCtrlHolding;
	private bool	m_IsWinHolding;
	private bool	m_IsLeftAltHolding;
	private bool	m_IsRightAltHolding;
	
	private bool	m_IsWorldWetTempUpdateEnabled = true;
	private bool	m_IsFoodDecayEnabled = true;
	private float	m_FoodDecayModifier;
	
	static bool		m_ReportModded;
	private bool	m_IsStressTest;
	private bool 	m_AimLoggingEnabled;
	int 			m_OriginalCharactersCount;
	private string 	m_PlayerName;
	private bool 	m_IsNewCharacter;
	private bool 	m_IsConnecting;
	private bool	m_ConnectFromJoin;
	private bool	m_ShouldShowControllerDisconnect;
	private bool	m_CursorDesiredVisibilityScript = true;
	private int		m_PreviousGamepad;
	private float	m_UserFOV;

	private float	m_DeltaTime;

	float 	m_volume_sound;
	float 	m_volume_speechEX;
	float 	m_volume_music;
	float 	m_volume_VOIP;
	float 	m_volume_radio;
	
	float 	m_PreviousEVValue;
	float 	m_EVValue = 0;
	
	#ifdef DIAG_DEVELOPER
	private static ref ServerFpsStatsUpdatedEventParams m_ServerFpsStatsParams; 
	#endif
	
	static ref AmmoCamParams m_AmmoShakeParams = new AmmoCamParams();//TODO: make static, reuse
	
	static ref ScriptInvoker Event_OnRPC = new ScriptInvoker();
	
	private ref Backlit m_Backlit;
	
	private ref array<string> m_CharClassNames = new array<string>();
	private ref array<int> m_ConnectedInputDeviceList; //has to be owned here, 'Input' is a native class
	
	//Used for helicrash sound
	private ref EffectSound m_CrashSound;
	
	//Used for Artillery sound
	private ref EffectSound m_ArtySound;
	private const int MIN_ARTY_SOUND_RANGE = 300; // The distance under which sound is no longer heard
	
	static ref NoiseParams m_NoiseParams = new NoiseParams();
	#ifdef DEVELOPER
	static bool m_IsPreviewSpawn;//! we set this to 'true' when spawning item through Script Console only for item preview purposes
	#endif
	#ifdef DIAG_DEVELOPER
	ref CameraToolsMenuServer m_CameraToolsMenuServer;
	#endif
	// CGame override functions
	void DayZGame()
	{
		PPEManagerStatic.CreateManagerStatic();
		
#ifdef PLATFORM_CONSOLE
		SetMainMenuWorld("MainMenuSceneXbox");
#endif
		m_MissionState = MISSION_STATE_GAME;
		
		m_keyboard_handler = null;
		
		#ifdef DEVELOPER
		m_early_access_dialog_accepted = true;
		#endif
		
		for (int i = 0; i < CALL_CATEGORY_COUNT; i++)
		{
			m_callQueue[i] 		= new ScriptCallQueue();
			m_updateQueue[i] 	= new ScriptInvoker();
			m_timerQueue[i] 	= new TimerQueue();
			
			m_postUpdateQueue[i] = new ScriptInvoker();
		}
		
		m_dragQueue = new DragQueue;
		
		m_LoginTime 		 = 0;
		
		string tmp;
		if (CommandlineGetParam("stresstest", tmp))
		{
			m_IsStressTest = true;
		}

		if (CommandlineGetParam("doAimLogs", tmp))
		{
			m_AimLoggingEnabled = true;
		}
		
		// initialize backlit effects
		m_Backlit = new Backlit();
		m_Backlit.OnInit(this);
		
		m_ReportModded = GetModToBeReported();

	#ifndef NO_GUI
		if (m_loading == null)
		{
			m_loading = new LoadingScreen(this);
		}

		if (m_loading)
		{
			m_loading.ShowEx(this);
		}

		RefreshMouseCursorVisibility();
	#endif
			
		Debug.Init();
		Component.Init();
		CachedObjectsParams.Init();
		CachedObjectsArrays.Init();
		BleedChanceData.InitBleedChanceData();
		GetUApi().PresetSelect(GetUApi().PresetCurrent());

		m_DayZProfileOptions = new DayZProfilesOptions();
		
		GetCallQueue(CALL_CATEGORY_GUI).Call(DeferredInit);
		GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(GlobalsInit);
		
		string path = "cfgVehicles";
		string child_name = "";
		int count = ConfigGetChildrenCount(path);
		
		for (int p = 0; p < count; ++p)
		{
			ConfigGetChildName(path, p, child_name);
			
			if (ConfigGetInt(path + " " + child_name + " scope") == 2 && IsKindOf(child_name, "SurvivorBase"))
				m_CharClassNames.Insert(child_name);
		}
		
		m_IsConnecting = false;
		m_ConnectFromJoin = false;
	}
	
	// ------------------------------------------------------------
	private void ~DayZGame()
	{
		PPEManagerStatic.DestroyManagerStatic();
		BleedChanceData.Cleanup();
		NotificationSystem.CleanupInstance();
		
		g_Game = null;
		SetDispatcher(null);
		Print("~DayZGame()");
	}
	
	// ------------------------------------------------------------
	void DeferredInit()
	{
		GameOptions opt = new GameOptions();
		opt.Initialize();
		
		GetInput().UpdateConnectedInputDeviceList();

		m_UserFOV = GetUserFOVFromConfig();
		
		m_volume_sound 		= GetSoundScene().GetSoundVolume();
		m_volume_speechEX 	= GetSoundScene().GetSpeechExVolume();
		m_volume_music 		= GetSoundScene().GetMusicVolume();
		m_volume_VOIP 		= GetSoundScene().GetVOIPVolume();
		m_volume_radio 		= GetSoundScene().GetRadioVolume();
		
		PPEManagerStatic.GetPPEManager().Init();
		GetMenuDefaultCharacterData();
	}
	
	// ------------------------------------------------------------
	void GlobalsInit()
	{
		if (GetCEApi())
		{
			m_IsWorldWetTempUpdateEnabled = (GetCEApi().GetCEGlobalInt("WorldWetTempUpdate") == 1);
			
			m_FoodDecayModifier = GetCEApi().GetCEGlobalFloat("FoodDecay");
			
			//check for legacy INT format, if value == float.MIN when read as FLOAT, it is of type INT, so we read it as such below	
			if (m_FoodDecayModifier == float.MIN)
			{
				m_FoodDecayModifier = GetCEApi().GetCEGlobalInt("FoodDecay");
			}
		}
		
		//we need to perform the load here as some objects behaving correctly after spawn is dependent on CE being initialized before spawning them
		ObjectSpawnerHandler.OnGameplayDataHandlerLoad();
	}
	
	// ------------------------------------------------------------
	void RegisterProfilesOptions()
	{
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.CROSSHAIR, SHOW_CROSSHAIR);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.HUD, SHOW_HUD);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.QUICKBAR, SHOW_QUICKBAR);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.SERVER_MESSAGES, SYSTEM_CHAT_MSG);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.USERS_CHAT, DIRECT_CHAT_MSG);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.RADIO_CHAT, RADIO_CHAT_MSG);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.GAME_MESSAGES, GAME_CHAT_MSG, false);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.ADMIN_MESSAGES, ADMIN_CHAT_MSG, false);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.PLAYER_MESSAGES, PLAYER_CHAT_MSG, false);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.SERVERINFO_DISPLAY, SHOW_SERVERINFO, true);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.BLEEDINGINDICATION, ENABLE_BLEEDINGINDICATION, true);
		m_DayZProfileOptions.RegisterProfileOptionBool(EDayZProfilesOptions.CONNECTIVITY_INFO, SHOW_CONNECTIVITYINFO, true);
		
		m_DayZProfileOptions.RegisterProfileOptionFloat(EDayZProfilesOptions.HUD_BRIGHTNESS, HUD_BRIGHTNESS, 0.0);
	}
	
	void ResetProfileOptions()
	{
		m_DayZProfileOptions.ResetOptionsBool();
		m_DayZProfileOptions.ResetOptionsInt();
		m_DayZProfileOptions.ResetOptionsFloat();
	}
	
	//! Called from C++
	void SetMissionPath(string path)
	{
		m_MissionPath = path;
		
		int pos_end = 0;
		int pos_cur = 0;
				
		while (pos_cur != -1)
		{
			pos_end = pos_cur;
			pos_cur = path.IndexOfFrom(pos_cur + 1 , "\\");
		}
		
		m_MissionFolderPath = path.Substring(0, pos_end);	
	}
	
	string GetMissionPath()
	{
		return m_MissionPath;
	}
	
	string GetMissionFolderPath()
	{
		return m_MissionFolderPath;
	}
	
	override ScriptCallQueue GetCallQueue(int call_category)
	{
		return m_callQueue[call_category];
	}

	override ScriptInvoker GetUpdateQueue(int call_category)
	{
		return m_updateQueue[call_category];
	}

	override ScriptInvoker GetPostUpdateQueue(int call_category)
	{
		return m_postUpdateQueue[call_category];
	}
	
	override TimerQueue GetTimerQueue(int call_category)
	{
		return m_timerQueue[call_category];
	}

	override DragQueue GetDragQueue()
	{
		return m_dragQueue;
	}
	
	// ------------------------------------------------------------
	void OnGameplayDataHandlerLoad()
	{
	
	}
	

	// ------------------------------------------------------------
	int GetMissionState()
	{
		return m_MissionState;
	}
	
	// ------------------------------------------------------------
	void SetMissionState(int state)
	{
		m_MissionState = state;
	}
	
	// ------------------------------------------------------------
	bool GetProfileOption(EDayZProfilesOptions option)
	{
		return m_DayZProfileOptions.GetProfileOption(option);
	}
	 	
	bool GetProfileOptionBool(EDayZProfilesOptions option)
	{
		return GetProfileOption(option);
	}
	
	int GetProfileOptionInt(EDayZProfilesOptions option)
	{
		return m_DayZProfileOptions.GetProfileOptionInt(option);
	}
	
	float GetProfileOptionFloat(EDayZProfilesOptions option)
	{
		return m_DayZProfileOptions.GetProfileOptionFloat(option);
	}
	
	bool GetProfileOptionDefault(EDayZProfilesOptions option)
	{
		return m_DayZProfileOptions.GetProfileOptionDefaultBool(option);
	}
	
	bool GetProfileOptionDefaultBool(EDayZProfilesOptions option)
	{
		return GetProfileOptionDefault(option);
	}
	
	int GetProfileOptionDefaultInt(EDayZProfilesOptions option)
	{
		return m_DayZProfileOptions.GetProfileOptionDefaultInt(option);
	}
	
	float GetProfileOptionDefaultFloat(EDayZProfilesOptions option)
	{
		return m_DayZProfileOptions.GetProfileOptionDefaultFloat(option);
	}
	
	void SetProfileOption(EDayZProfilesOptions option, bool value)
	{
		m_DayZProfileOptions.SetProfileOptionBool(option, value);
	}
	
	void SetProfileOptionBool(EDayZProfilesOptions option, bool value)
	{
		SetProfileOption(option, value);
	}
	
	void SetProfileOptionInt(EDayZProfilesOptions option, int value)
	{
		m_DayZProfileOptions.SetProfileOptionInt(option, value);
	}
	
	void SetProfileOptionFloat(EDayZProfilesOptions option, float value)
	{
		m_DayZProfileOptions.SetProfileOptionFloat(option, value);
	}
	
	map<EDayZProfilesOptions, ref DayZProfilesOption> GetProfileOptionMap()
	{
		return m_DayZProfileOptions.GetProfileOptionMap();
	}
	
	bool IsStressTest()
	{
		return m_IsStressTest;
	}
	
	bool IsAimLogEnabled()
	{
		return m_AimLoggingEnabled;
	}
	
	void SetGameState(DayZGameState state)
	{
		m_GameState = state;
	}
	
	DayZGameState GetGameState()
	{
		return m_GameState;
	}
	
	void SetLoadState(DayZLoadState state)
	{
		m_LoadState = state;
	}
	
	DayZLoadState GetLoadState()
	{
		return m_LoadState;
	}
	
	static bool ReportModded()
	{
		return m_ReportModded;
	}
	
	Backlit GetBacklit()
	{
		return m_Backlit;
	}
	
	// ------------------------------------------------------------
	override bool IsInventoryOpen()
	{
#ifndef NO_GUI
		if (GetUIManager().FindMenu(MENU_INVENTORY) != NULL)
		{
			return true;
		}
#endif
		return false;
	}
	
	// ------------------------------------------------------------
	void EarlyAccessDialog(UIScriptedMenu parent)
	{
		if (!m_early_access_dialog_accepted)
		{
			g_Game.GetUIManager().EnterScriptedMenu(MENU_EARLYACCESS, parent);
			m_early_access_dialog_accepted = true;
		}
	}
	
	// ------------------------------------------------------------
	//! create custom main menu part (submenu)
	override UIScriptedMenu CreateScriptedMenu(int id)
	{
	#ifndef NO_GUI
		Mission mission = GetMission();
		if (mission)
		{
			return mission.CreateScriptedMenu(id);
		}
	#endif
		return NULL;
	}
		
	// ------------------------------------------------------------
	void ReloadMission()
	{
	#ifdef DEVELOPER
		Print("Reloading mission module!");
		CreateMission(m_MissionPath);
	#endif
	}
	
		// ------------------------------------------------------------
	void CancelLoginQueue()
	{
		if (m_LoginQueue)
		{
			if (m_LoginQueue.IsStatic())
			{
				m_LoginQueue.Hide();
				delete m_LoginQueue;
			}
			else
			{
				m_LoginQueue.Close();
			}
		}
	}
	// ------------------------------------------------------------
	void CancelLoginTimeCountdown()
	{
		GetCallQueue(CALL_CATEGORY_SYSTEM).Remove(this.LoginTimeCountdown);
		
		if (m_LoginTimeScreen)
		{
			if (m_LoginTimeScreen.IsStatic())
			{
				m_LoginTimeScreen.Hide();
				delete m_LoginTimeScreen;
			}
			else
			{
				m_LoginTimeScreen.Close();
			}
		}
	}
	// ------------------------------------------------------------
	private void ClearConnectivityStates()
	{
		for (int i = 0; i < STATS_COUNT; i++)
			m_ConnectivityStatsStates[i] = 0;
	}
	
	
	// ------------------------------------------------------------
	override void OnEvent(EventType eventTypeId, Param params)
	{
		string address;
		int port;
		int high, low;
		
		switch (eventTypeId)
		{
			case StartupEventTypeID:
			{
				#ifndef SERVER
				// Just call it, to create the global instance if it doesn't exist yet
				ParticleManager.GetInstance();
				#endif
				break;
			}
			case MPSessionStartEventTypeID:
			{
				#ifndef SERVER
				ClearConnectivityStates();
				#endif
				m_FirstConnect = true;
				ClientData.ResetClientData();
				break;
			}
			case MPSessionEndEventTypeID:
			{
				LoadingHide();
				CancelLoginTimeCountdown();
				SetConnecting(false);
				SetGameState(DayZGameState.MAIN_MENU);
				m_FirstConnect = true;
				#ifdef PLATFORM_CONSOLE
				if (GetUserManager().GetSelectedUser())
				{
					OnlineServices.LeaveGameplaySession();
					OnlineServices.ClearCurrentServerInfo();
					if (GetGameState() == DayZGameState.IN_GAME)
					{
						SetLoadState(DayZLoadState.MAIN_MENU_START);
					}
				}
				m_Notifications.ClearVoiceNotifications();
				#endif

				// analytics - disconnected player
				StatsEventDisconnectedData discData = new StatsEventDisconnectedData();
				discData.m_CharacterId = g_Game.GetDatabaseID();
				discData.m_Reason = "quit";
				Analytics.PlayerDisconnected(discData);
				break;
			}
			case MPSessionFailEventTypeID:
			{
				CancelLoginQueue();
				LoadingHide(true);
				SetConnecting(false);
				ProgressAsync.DestroyAllPendingProgresses();
				
				if (GetGameState() == DayZGameState.CONNECTING)
				{
					SetGameState(DayZGameState.MAIN_MENU);
				}
				
				break;
			}
			case MPSessionPlayerReadyEventTypeID:
			{
				LoadingHide(true);
				ProgressAsync.DestroyAllPendingProgresses();
				
				SetGameState(DayZGameState.IN_GAME);
				
				// analytics - spawned
				StatsEventSpawnedData spawnData = new StatsEventSpawnedData();
				spawnData.m_CharacterId = g_Game.GetDatabaseID();
				spawnData.m_Lifetime = 0;
				spawnData.m_Position = vector.Zero;
				if (GetPlayer())
				{
					spawnData.m_Position = GetPlayer().GetPosition();
				}
				spawnData.m_DaytimeHour = 0;
				spawnData.m_Population = 0;
				Analytics.PlayerSpawned(spawnData);
				
				#ifdef PLATFORM_CONSOLE
				m_Notifications.ClearVoiceNotifications();
				OnlineServices.SetMultiplayState(true);
				#endif
				if (m_FirstConnect)
				{
					m_FirstConnect = false;
					if (GetHostAddress(address, port))
					{
						AddVisitedServer(address, port);
					}
					
					#ifdef PLATFORM_CONSOLE
						#ifndef PLATFORM_WINDOWS // if app is not on Windows with -XBOX parameter
							if (null != GetUserManager().GetSelectedUser())
							{
								OnlineServices.EnterGameplaySession();
								OnlineServices.LoadVoicePrivilege();
							}
						#endif
					#endif
				}
				
				UpdateInputDeviceDisconnectWarning();
				
				break;
			}
			case MPConnectionLostEventTypeID:
			{
				MPConnectionLostEventParams conLost_params;
				if (Class.CastTo(conLost_params, params))
				{
					int duration = conLost_params.param1;
					OnMPConnectionLostEvent(duration);
				}
				break;
			}
			case WorldCleaupEventTypeID:
			{
				LoadingShow();
				break;
			}
			case DialogQueuedEventTypeID:
			{
				GetCallQueue(CALL_CATEGORY_SYSTEM).Call(g_Game.CheckDialogs);
				break;
			}
			case ChatMessageEventTypeID:
			{
				ChatMessageEventParams chat_params;
				if (Class.CastTo(chat_params, params))
				{
					
				}
				break;
			}
			case ProgressEventTypeID:
			{
				ProgressEventParams prog_params;
				if (Class.CastTo(prog_params, params))
					LoadProgressUpdate(prog_params.param1, prog_params.param2, prog_params.param3);
				break;
			}
			case LoginTimeEventTypeID:
			{
				LoginTimeEventParams loginTimeParams;
				if (Class.CastTo(loginTimeParams, params))
				{
					OnLoginTimeEvent(loginTimeParams.param1);
				}
				break;
			}	
			case RespawnEventTypeID:
			{
				RespawnEventParams respawnParams;
				if (Class.CastTo(respawnParams, params))
				{
					OnRespawnEvent(respawnParams.param1);
				}	
				break;
			}
			case PreloadEventTypeID:
			{
				PreloadEventParams preloadParams;
				if (Class.CastTo(preloadParams, params))
				{
					OnPreloadEvent(preloadParams.param1);
				}	
				break;
			}
			case LogoutEventTypeID:
			{
				LogoutEventParams logoutParams;
				if (Class.CastTo(logoutParams, params))
				{
					GetCallQueue(CALL_CATEGORY_GUI).Call(GetMission().StartLogoutMenu, logoutParams.param1);						
				}
				break;
			}
			case SelectedUserChangedEventTypeID:
			{
				OnlineServices.Init();
				break;
			}
			case LoginStatusEventTypeID:
			{
				LoginStatusEventParams loginStatusParams;
				Class.CastTo(loginStatusParams, params);
	
				string msg1 = loginStatusParams.param1;
				string msg2 = loginStatusParams.param2;
				string finalMsg;
					
				// write either to login time screen or loading screen
				if (m_LoginTimeScreen)
				{
					finalMsg = msg1;
					// login time screen supports two lines
					if (msg2.Length() > 0)
						finalMsg += "\n" + msg2;
						
					m_LoginTimeScreen.SetStatus(finalMsg);
				}
				else if (m_loading)
				{
					// loading only one line, but it's a long one
					finalMsg = msg1 + " " + msg2;
					m_loading.SetStatus(finalMsg);
				}
				break;
			}
			case ConnectingStartEventTypeID:
			{
				g_Game.SetGameState(DayZGameState.CONNECTING);
				SetConnecting(true);
				break;
			}
			case ConnectingAbortEventTypeID:
			{
				g_Game.SetGameState(DayZGameState.MAIN_MENU);
				SetConnecting(false);
				if (m_ConnectFromJoin)
				{
					m_ConnectFromJoin = false;
					AbortMission();
				}
				break;
			}
			case DLCOwnerShipFailedEventTypeID:
			{
				DLCOwnerShipFailedParams dlcParams;
				if (Class.CastTo(dlcParams, params))
				{
					Print("### DLC Ownership failed !!! Map: " + dlcParams.param1);
				}
				break;
			}
			case ConnectivityStatsUpdatedEventTypeID:
			{
				ConnectivityStatsUpdatedEventParams connectivityStatsParams; 
				if (Class.CastTo(connectivityStatsParams, params))
				{
					PlayerIdentity playerIdentity = connectivityStatsParams.param1;
					
					int pingAvg = playerIdentity.GetPingAvg();
					if (pingAvg < GetWorld().GetPingWarningThreshold())
					{
						SetConnectivityStatState(EConnectivityStatType.PING, EConnectivityStatLevel.OFF);
					}
					else if (pingAvg < GetWorld().GetPingCriticalThreshold())
					{
						SetConnectivityStatState(EConnectivityStatType.PING, EConnectivityStatLevel.LEVEL1);
					}
					else
					{
						SetConnectivityStatState(EConnectivityStatType.PING, EConnectivityStatLevel.LEVEL2);
					}
				}
				break;
			}
			case ServerFpsStatsUpdatedEventTypeID:
			{
				ServerFpsStatsUpdatedEventParams serverFpsStatsParams; 
				if (Class.CastTo(serverFpsStatsParams, params))
				{
					#ifdef DIAG_DEVELOPER
					m_ServerFpsStatsParams = serverFpsStatsParams;
					#endif
					float fps = serverFpsStatsParams.param1;
					if (fps > GetWorld().GetServerFpsWarningThreshold())
					{
						SetConnectivityStatState(EConnectivityStatType.SERVER_PERF, EConnectivityStatLevel.OFF);
					}
					else if (fps > GetWorld().GetServerFpsCriticalThreshold())
					{
						SetConnectivityStatState(EConnectivityStatType.SERVER_PERF, EConnectivityStatLevel.LEVEL1);
					}
					else
					{
						SetConnectivityStatState(EConnectivityStatType.SERVER_PERF, EConnectivityStatLevel.LEVEL2);
					}
				}
				break;
			}
		}
		
		VONManager.GetInstance().OnEvent(eventTypeId, params);

		Mission mission = GetMission();
		if (mission)
		{
			mission.OnEvent(eventTypeId, params);
		}
		
		ErrorModuleHandler emh = ErrorModuleHandler.GetInstance();
		if (emh)
			emh.OnEvent(eventTypeId, params);
	}
	
	protected void SetConnectivityStatState(EConnectivityStatType type, EConnectivityStatLevel level)
	{
		if (level != m_ConnectivityStatsStates[type])
		{
			if (OnConnectivityStatChange(type, level, m_ConnectivityStatsStates[type]))//before setting the prev. level to be the current level, we need to make sure we successfully set the icon
			{
				m_ConnectivityStatsStates[type] = level;
			}
		}
	}
	
	protected bool OnConnectivityStatChange(EConnectivityStatType type, EConnectivityStatLevel newLevel, EConnectivityStatLevel oldLevel)
	{
		if (!GetGame() || !GetGame().GetMission())
			return false;
		Hud hud = GetGame().GetMission().GetHud();
		if (!hud) 
			return false;

		hud.SetConnectivityStatIcon(type, newLevel);
		return true;
	}
	
	#ifdef DIAG_DEVELOPER
	private void DrawPerformaceStats(float pingAct, float pingAvg)
	{
		DbgUI.Begin("Performance Stats", 10, 520);
		DbgUI.Text("pingAct:" + pingAct );
		int color = COLOR_WHITE;
		if ( pingAvg >= GetWorld().GetPingCriticalThreshold())
			color = COLOR_RED;
		else if ( pingAvg >= GetWorld().GetPingWarningThreshold())
			color = COLOR_YELLOW;

		DbgUI.ColoredText(color, "pingAvg:" + pingAvg);
		DbgUI.Text("Ping Warning Threshold:" + GetWorld().GetPingWarningThreshold());
		DbgUI.Text("Ping Critical Threshold:" + GetWorld().GetPingCriticalThreshold());
		DbgUI.PlotLive("pingAvg history:", 300,150, pingAvg, 2000, 100 );
		DbgUI.Text("Server Fps Warning Threshold:" + GetWorld().GetServerFpsWarningThreshold());
		DbgUI.Text("Server Fps Critical Threshold:" + GetWorld().GetServerFpsCriticalThreshold());
		if (m_ServerFpsStatsParams)// SERVER FPS
		{
			color = COLOR_WHITE;
			if ( m_ServerFpsStatsParams.param1 <= GetWorld().GetServerFpsCriticalThreshold())
				color = COLOR_RED;
			else if ( m_ServerFpsStatsParams.param1 <= GetWorld().GetServerFpsWarningThreshold())
				color = COLOR_YELLOW;
			DbgUI.ColoredText(color, "serverFPS:" + m_ServerFpsStatsParams.param1.ToString() );
			DbgUI.PlotLive("serverFPS history:", 300,150, m_ServerFpsStatsParams.param1, 6000, 100 );
		}
		DbgUI.End();
	}
	#endif
	
	void AddVoiceNotification(VONStopSpeakingEventParams vonStartParams)
	{
		m_Notifications.AddVoiceNotification(vonStartParams.param2, vonStartParams.param1);
	}
	
	void RemoveVoiceNotification(VONStopSpeakingEventParams vonStopParams)
	{
		m_Notifications.RemoveVoiceNotification(vonStopParams.param2);
	}
	
	// ------------------------------------------------------------	
	void UpdateLoginQueue(float timeslice)
	{
		int pos = GetUIManager().GetLoginQueuePosition();
		
		//! Display login queue position dialog
		if (!m_LoginQueue && pos > 0)
		{	
			GetUIManager().CloseAll();
			
			if (GetMission())
			{
				UIScriptedMenu parent = GetUIManager().GetMenu();
				EnterLoginQueue(parent);
			}
			else
			{
				m_LoginQueue = new LoginQueueStatic();
				GetUIManager().ShowScriptedMenu(m_LoginQueue, null);
			}
		}
		if (m_LoginQueue)
		{
			m_LoginQueue.SetPosition(pos);

			//! manually update static login queue dialog
			LoginQueueStatic loginQueue;
			if (LoginQueueBase.CastTo(loginQueue, m_LoginQueue))
			{
				loginQueue.Update(timeslice);
			}
		}
	}
	
	// ------------------------------------------------------------
	void OnLoginTimeEvent(int loginTime)
	{
#ifndef NO_GUI
		// remove login queue if exits	
		CancelLoginQueue();	
		
		GetUserManager().GetUserDatabaseIdAsync();
		
		m_LoginTime = loginTime;
		
		// timer for login
		if (m_LoginTime > 0)
		{	
			if (!m_LoginTimeScreen)
			{
				GetUIManager().CloseAll();
				
				if (GetMission())
				{
					UIScriptedMenu parent = GetUIManager().GetMenu();
					EnterLoginTime(parent);
				}
				else
				{
					m_LoginTimeScreen = new LoginTimeStatic();
					GetUIManager().ShowScriptedMenu(m_LoginTimeScreen, null);
				}
			}
			
			m_LoginTimeScreen.SetTime(m_LoginTime);
			m_LoginTimeScreen.Show();
			
			GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(this.LoginTimeCountdown, 1000, true);
		}
#endif
	}
	
	// ------------------------------------------------------------
	void LoginTimeCountdown()
	{
		if (m_LoginTime > 0)
		{
			if (m_LoginTimeScreen)
				m_LoginTimeScreen.SetTime(m_LoginTime);

			m_LoginTime--;
		}
		else
		{
			// stop the call loop
			CancelLoginTimeCountdown();
		}
	}
	
	// ------------------------------------------------------------
	void OnRespawnEvent(int time)
	{	
		// use login time screen for respawn timer
		if (time >= 0)
		{	
			m_LoginTime = time;
			if (!m_LoginTimeScreen)
			{
				GetUIManager().CloseAll();
				
				UIScriptedMenu parent = GetUIManager().GetMenu();
				EnterLoginTime(parent);
			}
			
			m_LoginTimeScreen.SetRespawn(true);
			m_LoginTimeScreen.SetTime(m_LoginTime);
			m_LoginTimeScreen.Show();
			
			GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(this.LoginTimeCountdown, 1000, true);
		}

		if (GetPlayer())
			GetPlayer().StopDeathDarkeningEffect();

		PPERequesterBank.GetRequester(PPERequester_DeathDarkening).Start(new Param1<float>(1.0));
	}
	
	// ------------------------------------------------------------
	void OnPreloadEvent(vector pos)
	{
		// cancel only login time (respawn time is parallel with preload, but login time is not)
		if (m_LoginTimeScreen && !m_LoginTimeScreen.IsRespawn())
			CancelLoginTimeCountdown();
		
		// tell game to continue
		StoreLoginDataPrepare();
	}
		
	// ------------------------------------------------------------
	// Serialize and send default character information to server (must be called)
	void StoreLoginDataPrepare()
	{
		ScriptReadWriteContext ctx = new ScriptReadWriteContext;
		
		//GetMenuData().RequestGetDefaultCharacterData();
		GetMenuDefaultCharacterData().SerializeCharacterData(ctx.GetWriteContext());
		StoreLoginData(ctx.GetWriteContext());
	}
	
	// ------------------------------------------------------------
	void EnterLoginQueue(UIMenuPanel parent)
	{
		m_LoginQueue = LoginQueueBase.Cast(GetUIManager().EnterScriptedMenu(MENU_LOGIN_QUEUE, parent)); 		
	}
	
	// ------------------------------------------------------------
	void EnterLoginTime(UIMenuPanel parent)
	{			 	
		m_LoginTimeScreen = LoginTimeBase.Cast(GetUIManager().EnterScriptedMenu(MENU_LOGIN_TIME, parent)); 		
	}
	
	// ------------------------------------------------------------
	void OnMPConnectionLostEvent(int duration)
	{
		if (duration >= 0)//(-1 means conn. reestablished)
			SetConnectivityStatState(EConnectivityStatType.CONN_LOST, EConnectivityStatLevel.LEVEL1);
		else
			SetConnectivityStatState(EConnectivityStatType.CONN_LOST, EConnectivityStatLevel.OFF);
		
		#ifdef PLATFORM_PS4
		//PSN Set multiplay state	
		if (duration < 0 && GetGameState() == DayZGameState.IN_GAME)
		{
			OnlineServices.SetMultiplayState(true);
		}
		else
		{
			OnlineServices.SetMultiplayState(false);
		}
		#endif
	}
	
	// ------------------------------------------------------------
	void LoadProgressUpdate(int progressState, float progress, string title)
	{
	#ifndef NO_GUI
		switch (progressState)
		{
		case PROGRESS_START:
			{
			#ifndef NO_GUI	
				// get out of the black screen immediately
				GetUIManager().ScreenFadeOut(0);
			#endif
				m_loading.Inc();
				m_loading.SetTitle(title);
				if (m_loading.m_HintPanel)
					m_loading.m_HintPanel.ShowRandomPage();
				
			}
			break;
	
		case PROGRESS_FINISH:
			{
				m_loading.Dec();
			}
			break;
	
		case PROGRESS_PROGRESS:
			{
				m_loading.SetProgress(progress);
				
			}
			break;
	
		case PROGRESS_UPDATE:
			{
				m_loading.SetProgress(0);
			}
			break;
		}
	#endif
	}
	
	// ------------------------------------------------------------
	override void OnAfterCreate()
	{
		Math.Randomize(-1);
	}
	
	// ------------------------------------------------------------
	override void OnActivateMessage()
	{
		RefreshMouseCursorVisibility();
	}

	// ------------------------------------------------------------
	override void OnDeactivateMessage()
	{
		RefreshMouseCursorVisibility();
	}
	
	// ------------------------------------------------------------
	override bool OnInitialize()
	{
		ParticleList.PreloadParticles();
		
		RegisterProfilesOptions();
		SetHudBrightness(GetHUDBrightnessSetting());
		
		InitNotifications();
		m_Visited = new TStringArray;
		GetProfileStringList("SB_Visited", m_Visited);
		
		if (GetLoadState() == DayZLoadState.UNDEFINED)
		{
			string param;
			
			if (GetCLIParam("join", param))
			{
				JoinLaunch();
				#ifndef PLATFORM_PS4
				CreateTitleScreen();
				#endif
			}
			else if (GetCLIParam("connect", param))
			{
				ConnectLaunch();
			}
			else if (GetCLIParam("mission", param))
			{
				MissionLaunch();
			}
			else if (GetCLIParam("party", param))
			{
				PartyLaunch();
			}
			else
			{
				MainMenuLaunch();
			}
			
			return true;
		}
		
		return false;
	}
	
	void InitNotifications()
	{
		NotificationSystem.InitInstance();
		m_Notifications = new NotificationUI();
	}
	
	protected ref Widget		m_IntroMenu;
	protected ref Widget		m_GamepadDisconnectMenu; //DEPRECATED
	protected int				m_PrevBlur;
	
	protected string			m_DatabaseID;
	
	protected string			m_ConnectAddress;
	protected int				m_ConnectPort;
	protected string			m_ConnectPassword;
	
	protected const int			MAX_VISITED = 50;
	protected ref TStringArray	m_Visited;
	
	string GetDatabaseID()
	{
		return m_DatabaseID;
	}
	
	void SetDatabaseID(string id)
	{
		m_DatabaseID = id;
		if (GetUIManager().GetMenu())
		{
			GetUIManager().GetMenu().Refresh();
		}
	}
	
	void CreateTitleScreen()
	{
		DeleteTitleScreen();
		m_IntroMenu = GetWorkspace().CreateWidgets("gui/layouts/xbox/day_z_title_screen.layout");
		RichTextWidget text_widget = RichTextWidget.Cast(m_IntroMenu.FindAnyWidget("InputPromptText"));
		m_IntroMenu.FindAnyWidget("notification_root").Show(false);
		if (text_widget)
		{
			string text = Widget.TranslateString("#console_start_game");
			#ifdef PLATFORM_XBOX
				BiosUserManager user_manager = GetGame().GetUserManager();
				if (user_manager && user_manager.GetSelectedUser())
					text_widget.SetText(string.Format(text, "<image set=\"xbox_buttons\" name=\"A\" />"));
				else
					text_widget.SetText(string.Format(text, "<image set=\"xbox_buttons\" name=\"A\" />"));
			#endif
					
			#ifdef PLATFORM_PS4
				string confirm = "cross";
				if (GetGame().GetInput().GetEnterButton() == GamepadButton.A)
				{
					confirm = "cross";
				}
				else
				{
					confirm = "circle";
				}
				text_widget.SetText(string.Format(text, "<image set=\"playstation_buttons\" name=\"" + confirm + "\" />"));
			#endif
		}
		
		#ifdef PLATFORM_CONSOLE
		#ifdef PLATFORM_XBOX
		#ifdef BUILD_EXPERIMENTAL
			m_IntroMenu.FindAnyWidget("notification_root").Show(true);
		#endif
		#endif
		#endif
	}
	
	void DeleteTitleScreen()
	{
		if (m_IntroMenu)
		{
			delete m_IntroMenu;
		}
	}
	
	bool ShouldShowControllerDisconnect()
	{
		return m_ShouldShowControllerDisconnect;
	}
	
	void UpdateInputDeviceDisconnectWarning()
	{
		#ifdef PLATFORM_CONSOLE
		if (!GetUIManager().IsMenuOpen(MENU_WARNING_INPUTDEVICE_DISCONNECT))
		{
			m_ShouldShowControllerDisconnect = !GetInput().AreAllAllowedInputDevicesActive();
			if (m_ShouldShowControllerDisconnect)
			{
				GetCallQueue(CALL_CATEGORY_GUI).Call(GetUIManager().EnterScriptedMenu,MENU_WARNING_INPUTDEVICE_DISCONNECT,GetUIManager().GetMenu());
			}
		}
		#endif
	}
	
	void JoinLaunch()
	{
		SetGameState(DayZGameState.JOIN);
		SetLoadState(DayZLoadState.JOIN_START);
		
		#ifdef PLATFORM_CONSOLE
			string join_param;
			if (GetCLIParam("join", join_param))
			{
				BiosUserManager user_manager = GetUserManager();
				user_manager.ParseJoinAsync(join_param);
			}
		#endif
	}
	
	void ConnectLaunch()
	{
		BiosUserManager user_manager = GetUserManager();
		if (user_manager.GetTitleInitiator())
		{
			user_manager.SelectUserEx(user_manager.GetTitleInitiator());
		}
		
		SetGameState(DayZGameState.CONNECT);
		SetLoadState(DayZLoadState.CONNECT_START);
		
		#ifndef PLATFORM_WINDOWS
			#ifdef PLATFORM_CONSOLE
				CreateTitleScreen();
				GamepadCheck();
			#endif
		#else
			ConnectFromCLI();
		#endif
	}
	
	void PartyLaunch()
	{
		SetGameState(DayZGameState.PARTY);
		SetLoadState(DayZLoadState.PARTY_START);
		BiosUserManager user_manager = GetGame().GetUserManager();
		
		string param;
		if (GetCLIParam("party", param))
		{
			user_manager.ParsePartyAsync(param);
			StartRandomCutscene(GetMainMenuWorld());
		}
	}
	
	void MainMenuLaunch()
	{
#ifdef PLATFORM_WINDOWS
		BiosUserManager user_manager = GetUserManager();
		if (user_manager)
		{
			if (user_manager.GetTitleInitiator())
			{
				user_manager.SelectUserEx(user_manager.GetTitleInitiator());
			}
		}
#endif
		
		SetGameState(DayZGameState.MAIN_MENU);
		SetLoadState(DayZLoadState.MAIN_MENU_START);		
		StartRandomCutscene(GetMainMenuWorld());		
		DeleteTitleScreen();
	}
	
	void MissionLaunch()
	{
		BiosUserManager user_manager = GetUserManager();
		if (user_manager)
		{
			if (user_manager.GetTitleInitiator())
			{
				user_manager.SelectUserEx(user_manager.GetTitleInitiator());
			}
		}
		
		SetGameState(DayZGameState.IN_GAME);
		SetLoadState(DayZLoadState.MISSION_START);
		

		#ifndef PLATFORM_WINDOWS
			#ifdef PLATFORM_CONSOLE			
				#ifndef DEVELOPER
					CreateTitleScreen();
					GamepadCheck();
					return;
				#endif
			#endif
		#endif

		string mission;
		GetCLIParam("mission", mission);
		PlayMission(mission);
	}
	
	void SelectUser(int gamepad = -1)
	{
		BiosUserManager user_manager = GetUserManager();
		if (user_manager)
		{
			BiosUser selected_user;
			if (gamepad > -1)
			{
				GetInput().GetGamepadUser(gamepad, selected_user);
				#ifdef PLATFORM_PS4
				if (selected_user)
				#endif
				{
					if (user_manager.SelectUserEx(selected_user))
					{
						GetGame().GetInput().IdentifyGamepad(GamepadButton.BUTTON_NONE);
						GetInput().SelectActiveGamepad(gamepad);
					}
					else
					{
						selected_user = user_manager.GetSelectedUser();
					}
					
					#ifdef PLATFORM_PS4
					if (!selected_user.IsOnline())
					{
						user_manager.LogOnUserAsync(selected_user); 
						return;
					}
					#endif
				}
				#ifdef PLATFORM_PS4
				else
				{
					GetInput().ResetActiveGamepad();
					GamepadCheck();
				}
				#endif
			}
			
			if (!selected_user)
				selected_user = user_manager.GetSelectedUser();
			
			if (!selected_user)
			{
				user_manager.PickUserAsync();
				return;
			}
			
			user_manager.SelectUserEx(selected_user);
			
			switch (GetLoadState())
			{
				case DayZLoadState.JOIN_START:
				{
					SetLoadState(DayZLoadState.JOIN_USER_SELECT);				
					break;
				}
				case DayZLoadState.PARTY_START:
				{
					SetLoadState(DayZLoadState.PARTY_USER_SELECT);
					break;
				}
				case DayZLoadState.MAIN_MENU_START:
				{
					SetLoadState(DayZLoadState.MAIN_MENU_USER_SELECT);
					break;
				}
				case DayZLoadState.CONNECT_START:
				{
					SetLoadState(DayZLoadState.CONNECT_USER_SELECT);
					break;
				}
				case DayZLoadState.MISSION_START:
				{
					SetLoadState(DayZLoadState.MISSION_USER_SELECT);
					break;
				}
				default:
					break;
			}
			
			SelectGamepad();
			g_Game.SetHudBrightness(g_Game.GetHUDBrightnessSetting());
		}
	}
	
	void SetPreviousGamepad(int gamepad)
	{
		m_PreviousGamepad = gamepad;
	}
	
	int GetPreviousGamepad()
	{
		return m_PreviousGamepad;
	}
	
	void GamepadCheck()
	{
#ifndef AUTOTEST
		if (GetInput().IsActiveGamepadSelected())
		{
#endif
			DeleteTitleScreen();
			SelectUser();
#ifndef AUTOTEST
		}
		else
		{
	#ifdef PLATFORM_CONSOLE
		#ifndef PLATFORM_WINDOWS
			#ifdef PLATFORM_PS4
			if (GetUserManager().GetSelectedUser())
			{
				int gamepad = GetInput().GetUserGamepad(GetUserManager().GetSelectedUser());
				if (gamepad > -1)
				{
					SelectUser(gamepad);
				}
				else
				{
					if (!m_IntroMenu && !(GetGame().GetUIManager().GetMenu() && GetGame().GetUIManager().GetMenu().GetID() == MENU_TITLE_SCREEN))
						CreateTitleScreen();
					GetGame().GetInput().IdentifyGamepad(GetGame().GetInput().GetEnterButton());
				}
			}
			else
			#endif
			{
				if (!m_IntroMenu && !(GetUIManager().GetMenu() && GetUIManager().GetMenu().GetID() == MENU_TITLE_SCREEN))
					CreateTitleScreen();
				GetInput().IdentifyGamepad(GetInput().GetEnterButton());
			}
		#endif
	#endif
		}
#endif
	}
	
	void SelectGamepad()
	{
		ResetProfileOptions();
		BiosUserManager user_manager = GetUserManager();
		
		if (user_manager)
		{
			BiosUser selected_user = user_manager.GetSelectedUser();
			if (selected_user)
			{
				OnlineServices.SetBiosUser(selected_user);
				SetPlayerName(selected_user.GetName());
				SetUserFOV(GetUserFOVFromConfig());
				#ifdef PLATFORM_CONSOLE
				SetPlayerGameName(selected_user.GetName());
				user_manager.GetUserDatabaseIdAsync();
				#endif
			}
			
			if (GetUIManager().GetMenu())
			{
				GetUIManager().GetMenu().Refresh();
			}
		}
		
		switch (GetLoadState())
		{
			case DayZLoadState.JOIN_USER_SELECT:
			{
				SetLoadState(DayZLoadState.JOIN_CONTROLLER_SELECT);
				OnlineServices.LoadMPPrivilege();
				break;
			}
			case DayZLoadState.PARTY_USER_SELECT:
			{
				SetLoadState(DayZLoadState.PARTY_CONTROLLER_SELECT);
				DeleteTitleScreen();
				GetUIManager().EnterScriptedMenu(MENU_SERVER_BROWSER, GetUIManager().GetMenu());
				break;
			}
			case DayZLoadState.CONNECT_USER_SELECT:
			{
				SetLoadState(DayZLoadState.CONNECT_CONTROLLER_SELECT);
				OnlineServices.LoadMPPrivilege();
				break;
			}
			case DayZLoadState.MAIN_MENU_USER_SELECT:
			{
				SetLoadState(DayZLoadState.MAIN_MENU_CONTROLLER_SELECT);
				DeleteTitleScreen();
				GetUIManager().EnterScriptedMenu(MENU_MAIN, GetUIManager().GetMenu());
				break;
			}
			case DayZLoadState.MISSION_USER_SELECT:
			{
				SetLoadState(DayZLoadState.MISSION_CONTROLLER_SELECT);
				DeleteTitleScreen();
				string mission;
				GetCLIParam("mission", mission);
				PlayMission(mission);
				break;
			}
		}
	}
	
	void TryConnect()
	{
		if (GetLoadState() == DayZLoadState.JOIN_CONTROLLER_SELECT)
		{
			SetGameState(DayZGameState.CONNECTING);
			OnlineServices.GetSession();
		}
		else
		{
			if (GetGameState() != DayZGameState.CONNECTING)
			{
				switch (GetLoadState())
				{
					case DayZLoadState.CONNECT_CONTROLLER_SELECT:
					{
						SetGameState(DayZGameState.CONNECTING);
						ConnectFromCLI();
						break;
					}
					case DayZLoadState.PARTY_CONTROLLER_SELECT:
					{
						SetGameState(DayZGameState.CONNECTING);
						Connect();
						break;
					}
					case DayZLoadState.MAIN_MENU_CONTROLLER_SELECT:
					{
						SetGameState(DayZGameState.CONNECTING);
						Connect();
						break;
					}
				}
			}
			else
			{
				string address;
				int port;
				if (GetHostAddress(address, port))
				{
					if (m_ConnectAddress == address && m_ConnectPort == port)
						ErrorModuleHandler.ThrowError(ErrorCategory.ConnectErrorScript, EConnectErrorScript.ALREADY_CONNECTING_THIS);
					else
						ErrorModuleHandler.ThrowError(ErrorCategory.ConnectErrorScript, EConnectErrorScript.ALREADY_CONNECTING, string.Format("%1:%2", address, port));
				}
				else	
				{
					DisconnectSessionForce();
					DisconnectSessionScript();
					TryConnect();
				}
			}
		}
	}
	
	bool GetLastVisitedServer(out string ip, out int port)
	{
		if (m_Visited)
		{
			if (m_Visited.Count() > 0)
			{
				string uid = m_Visited.Get(m_Visited.Count() - 1);
				TStringArray output = new TStringArray;
				uid.Split(":", output);
				ip = output[0];
				port = output[1].ToInt();
				return true;
			}
		}
		return false;
	}
	
	void AddVisitedServer(string ip, int port)
	{
		string uid = ip + ":" + port;
		if (m_Visited)
		{
			int pos = m_Visited.Find(uid);
			 
			if (pos < 0)
			{
				if (m_Visited.Count() == MAX_VISITED)
					m_Visited.Remove(0);
				m_Visited.Insert(uid);
			}
			else
			{
				// if item is not saved as last server, move it
				if (pos != (m_Visited.Count() - 1))
				{
					m_Visited.Remove(pos);
					m_Visited.Insert(uid);
				}
			}
			SetProfileStringList("SB_Visited", m_Visited);
			SaveProfile();
		}
	}
	
	bool IsVisited(string ip, int port)
	{
		string uid = ip + ":" + port;
		int index = m_Visited.Find(uid);
		return (index >= 0);
	}
	
	void RefreshCurrentServerInfo()
	{
		string addr;
		int port;
		if (GetHostAddress(addr, port))
		{
			m_ConnectAddress = addr;
			m_ConnectPort = port;
		}
		OnlineServices.GetCurrentServerInfo(m_ConnectAddress, m_ConnectPort);
	}

	void Connect()
	{
		SetConnecting(true);
		
		DeleteTitleScreen();
		string addr;
		int port;
		if (GetHostAddress(addr, port))
		{
			if (m_ConnectAddress == addr && m_ConnectPort == port)
				return;
		}

		if (Connect(GetUIManager().GetMenu(), m_ConnectAddress, m_ConnectPort, m_ConnectPassword) != 0)
			DisconnectSessionScript(true);
	}
	
	void DisconnectSessionScript(bool displayJoinError = false)
	{
		DisconnectSessionFlags flags = DisconnectSessionFlags.SELECT_USER | DisconnectSessionFlags.IGNORE_WHEN_IN_GAME;
		if (displayJoinError)
		{
			flags |= DisconnectSessionFlags.JOIN_ERROR_ENABLED;
			flags |= DisconnectSessionFlags.JOIN_ERROR_CHECK;
		}
		
		DisconnectSessionEx(flags);
	}
	
	void DisconnectSessionEx(DisconnectSessionFlags flags)
	{
		if (flags & DisconnectSessionFlags.SELECT_USER && OnlineServices.GetBiosUser())
		{
			GetGame().GetUserManager().SelectUserEx(OnlineServices.GetBiosUser());
		}
		
		if (flags & DisconnectSessionFlags.JOIN_ERROR_ENABLED)
		{
			if (!(flags & DisconnectSessionFlags.JOIN_ERROR_CHECK) || GetGameState() == DayZGameState.JOIN)
			{
				NotificationSystem.AddNotification(NotificationType.JOIN_FAIL_GET_SESSION, NotificationSystem.DEFAULT_TIME_DISPLAYED);
			}
		}
		
		if (flags & DisconnectSessionFlags.IGNORE_WHEN_IN_GAME && GetGameState() == DayZGameState.IN_GAME)
		{
			return;
		}
		
		if (flags & DisconnectSessionFlags.CLOSE_MENUS && GetGame().GetUIManager())
		{
			GetGame().GetUIManager().CloseAllSubmenus();
			
			if ( GetGame().GetUIManager().IsDialogVisible() )
			{
				GetGame().GetUIManager().CloseDialog();
			}
		}
			
		if (flags & DisconnectSessionFlags.ALWAYS_FORCE)
		{
			DisconnectSessionForce();
		}
		
		if (GetGame().GetMission())
		{
			if (g_Game.GetGameState() != DayZGameState.MAIN_MENU)
			{	
				if (flags & DisconnectSessionFlags.DISCONNECT_ERROR_ENABLED)
				{
					NotificationSystem.AddNotification(NotificationType.DISCONNECTED, NotificationSystem.DEFAULT_TIME_DISPLAYED);
				}
				
				GetGame().GetMission().AbortMission();

				SetGameState(DayZGameState.MAIN_MENU);
				SetLoadState(DayZLoadState.MAIN_MENU_CONTROLLER_SELECT);
				
				GamepadCheck();
			}
		}
		
		else
		{
			MainMenuLaunch();
		}
	}
	
	void ConnectFromServerBrowser(string ip, int port, string password = "")
	{
		m_ConnectAddress	= ip;
		m_ConnectPort		= port;
		m_ConnectPassword	= password;
		m_ConnectFromJoin	= false;
		OnlineServices.LoadMPPrivilege();
	}
	
	void ConnectFromJoin(string ip, int port)
	{
		m_ConnectAddress	= ip;
		m_ConnectPort		= port;
		m_ConnectFromJoin	= true;
		Connect();
	}
	
	void ConnectFromCLI()
	{
		string port;
		if (GetCLIParam("connect", m_ConnectAddress))
		{
			GetCLIParam("port", port);
			m_ConnectPort = port.ToInt();
			
			GetCLIParam("password", m_ConnectPassword);
			
			m_ConnectFromJoin = false;
			Connect();
		}
	}
	
	bool IsLeftCtrlDown()
	{
		return m_IsCtrlHolding;
	}
	
	// ------------------------------------------------------------
	override void OnKeyPress(int key)
	{
	
		if (key == KeyCode.KC_LCONTROL) 
		{
			m_IsCtrlHolding = true;
		}

		if (key == KeyCode.KC_LMENU)
		{
			m_IsLeftAltHolding = true;
		}
			
		if (key == KeyCode.KC_RMENU)
		{
			m_IsRightAltHolding = true;
		}
	
		if (m_keyboard_handler)
		{
			m_keyboard_handler.OnKeyDown(NULL, 0, 0, key);
		}
		
		Mission mission = GetMission();
		if (mission)
		{
			mission.OnKeyPress(key);
		}
	
#ifdef DEVELOPER
		if ((m_IsLeftAltHolding || m_IsLeftAltHolding) && key == KeyCode.KC_F4)
		{
			RequestExit(0);
		}
#endif
		
	}
	
	// ------------------------------------------------------------
	override void OnKeyRelease(int key)
	{
		if (key == KeyCode.KC_LCONTROL) 
		{
			m_IsCtrlHolding = false;
		}
		
		if (key == KeyCode.KC_LWIN) 
		{
			m_IsWinHolding = false;
		}

		if (key == KeyCode.KC_LMENU || key == KeyCode.KC_RMENU)
		{
			m_IsLeftAltHolding = false;
		}

		if (key == KeyCode.KC_RMENU)
		{
			m_IsRightAltHolding  = false;
		}

		if (m_keyboard_handler)
		{
			m_keyboard_handler.OnKeyUp(NULL, 0, 0, key);
		}
	
		Mission mission = GetMission();
		if (mission)
		{
			mission.OnKeyRelease(key);
		}
	}
	
	// ------------------------------------------------------------	
	override void OnMouseButtonPress(int button)
	{
		Mission mission = GetMission();
		if (mission)
		{
			mission.OnMouseButtonPress(button);
		}
	}
	
	// ------------------------------------------------------------
	override void OnMouseButtonRelease(int button)
	{
		Mission mission = GetMission();
		if (mission)
		{
			mission.OnMouseButtonRelease(button);
		}
	}
	
	// ------------------------------------------------------------
	override void OnDeviceReset()
	{
		m_IsCtrlHolding = false;
		m_IsWinHolding = false;
		m_IsLeftAltHolding = false;
		m_IsRightAltHolding  = false;
	}

	// ------------------------------------------------------------
	float GetDeltaT()
	{
		return m_DeltaTime;
	}
	
	// ------------------------------------------------------------
	override void OnUpdate(bool doSim, float timeslice)
	{
		m_DeltaTime = timeslice;

		Mission mission = GetMission();
		bool gameIsRunning = false;
	
		if (doSim && mission && !mission.IsPaused())
		{
			gameIsRunning = true;
		}
	
		if (doSim && mission)
		{
			mission.OnUpdate(timeslice);
		}
	
		// queues and timers update
		GetCallQueue(CALL_CATEGORY_SYSTEM).Tick(timeslice);
		GetUpdateQueue(CALL_CATEGORY_SYSTEM).Invoke(timeslice);
		GetTimerQueue(CALL_CATEGORY_SYSTEM).Tick(timeslice);
	
	#ifndef NO_GUI	
		if (m_IsConnecting)
			UpdateLoginQueue(timeslice);
		
		if (m_loading && m_loading.IsLoading())
		{
			m_loading.OnUpdate(timeslice);
		}
		else if (m_LoginTimeScreen && m_LoginTimeScreen.IsStatic())
		{
			m_LoginTimeScreen.Update(timeslice);
		}
		else
		{
			GetCallQueue(CALL_CATEGORY_GUI).Tick(timeslice);
			GetUpdateQueue(CALL_CATEGORY_GUI).Invoke(timeslice);
			GetTimerQueue(CALL_CATEGORY_GUI).Tick(timeslice);
			GetDragQueue().Tick();
		}
		
		NotificationSystem.Update(timeslice);
		if (m_Notifications)
		{
			m_Notifications.Update(timeslice);
		}
		
		#ifndef SERVER
		#ifdef DIAG_DEVELOPER
		if (GetGame().IsMultiplayer() && GetPlayer() && DiagMenu.GetBool(DiagMenuIDs.MISC_CONNECTION_STATS))
		{
			PlayerIdentity playerIdentity = GetPlayer().GetIdentity();
			
			if (playerIdentity)
			{
				int pingAct = playerIdentity.GetPingAct();
				int pingAvg = playerIdentity.GetPingAvg();
			}
			
			DrawPerformaceStats(pingAct, pingAvg);
		}
		#endif
		#endif
		
	#endif
	
		if (gameIsRunning)
		{
			GetCallQueue(CALL_CATEGORY_GAMEPLAY).Tick(timeslice);
			GetUpdateQueue(CALL_CATEGORY_GAMEPLAY).Invoke(timeslice);
			GetTimerQueue(CALL_CATEGORY_GAMEPLAY).Tick(timeslice);
		}
	}
	
	// ------------------------------------------------------------
	override void OnPostUpdate(bool doSim, float timeslice)
	{
		Mission mission = GetMission();
		bool gameIsRunning = false;
	
		if (doSim && mission && !mission.IsPaused())
		{
			gameIsRunning = true;
		}
		
		GetPostUpdateQueue(CALL_CATEGORY_SYSTEM).Invoke(timeslice);
	
	#ifndef NO_GUI	
		if (m_loading && m_loading.IsLoading())
		{
		}
		else if (m_LoginTimeScreen && m_LoginTimeScreen.IsStatic())
		{
		}
		else
		{
			GetPostUpdateQueue(CALL_CATEGORY_GUI).Invoke(timeslice);
		}
	#endif
	
		if (gameIsRunning)
		{
			GetPostUpdateQueue(CALL_CATEGORY_GAMEPLAY).Invoke(timeslice);
		}
	}
	
	// ------------------------------------------------------------
	override void OnRPC(PlayerIdentity sender, Object target, int rpc_type, ParamsReadContext ctx)
	{
		super.OnRPC(sender, target, rpc_type, ctx);
		Event_OnRPC.Invoke(sender, target, rpc_type, ctx);
		
		//Print("["+ GetGame().GetTime().ToString() +"] => DayZGame::OnRPC = "+ EnumTools.EnumToString(ERPCs,rpc_type));
		
		if (target)
		{
			// call rpc on target
			target.OnRPC(sender, rpc_type, ctx);
		}
		else
		{
			switch (rpc_type)
			{
				#ifndef SERVER
				#ifndef NO_GUI
				case ERPCs.RPC_CFG_GAMEPLAY_SYNC:
				{
					CfgGameplayHandler.OnRPC(null, ctx);
					break;
				}
				case ERPCs.RPC_UNDERGROUND_SYNC:
				{
					UndergroundAreaLoader.OnRPC(ctx);
					break;
				}
				case ERPCs.RPC_SEND_NOTIFICATION:
				{
					NotificationType type;
					float show_time;
					string detail_text;
					
					ctx.Read(type);
					ctx.Read(show_time);
					ctx.Read(detail_text);
					
					NotificationSystem.AddNotification(type, show_time, detail_text);
					break;
				}
				case ERPCs.RPC_SEND_NOTIFICATION_EXTENDED:
				{
					float show_time_ext;
					string title_text_ext;
					string detail_text_ext;
					string icon_ext;
					
					ctx.Read(show_time_ext);
					ctx.Read(title_text_ext);
					ctx.Read(detail_text_ext);
					ctx.Read(icon_ext);
					
					NotificationSystem.AddNotificationExtended(show_time_ext, title_text_ext, detail_text_ext, icon_ext);
					break;
				}
				
				
				case ERPCs.RPC_SOUND_HELICRASH:
				{
					bool playSound;
					vector pos;
					string sound_set;
					
					//Helicrash is a world event, we want anyone to be able to hear it
					Param3<bool, vector, int> playCrashSound = new Param3<bool, vector, int>(false, "0 0 0",0);
					if (ctx.Read(playCrashSound))
					{
						playSound = playCrashSound.param1;
						pos = playCrashSound.param2;
						sound_set = CrashSoundSets.GetSoundSetByHash(playCrashSound.param3);
					}
					
					if (playSound)
					{
						m_CrashSound = SEffectManager.PlaySound(sound_set, pos, 0.1, 0.1);
						m_CrashSound.SetAutodestroy(true);
					}
				
				break;
				}
				//Random off map artillery barrage
				case ERPCs.RPC_SOUND_ARTILLERY:
				{
					vector position;
					Param1<vector> playArtySound = new Param1<vector>(vector.Zero);
					if (ctx.Read(playArtySound))
					{
						position = playArtySound.param1;
						if (position == vector.Zero)
							break;
					}
					else
						break;
					
					if (!GetGame().GetPlayer())
						break;
					
					if (vector.DistanceSq(GetGame().GetPlayer().GetPosition(), position) <= (MIN_ARTY_SOUND_RANGE * MIN_ARTY_SOUND_RANGE))
						break;
					
					m_ArtySound = SEffectManager.PlaySound("Artillery_Distant_Barrage_SoundSet", position, 0.1, 0.1);
					m_ArtySound.SetAutodestroy(true);
				
				break;
				}
				case ERPCs.RPC_SOUND_CONTAMINATION:
				{
					vector soundPos;
					
					Param1<vector> playContaminatedSound = new Param1<vector>(vector.Zero);
					if (ctx.Read(playContaminatedSound))
					{
						soundPos = playContaminatedSound.param1;
						if (soundPos == vector.Zero)
							break;
					}
					else
						break;
					
					if (!GetGame().GetPlayer())
						break;
					
					EffectSound closeArtySound = SEffectManager.PlaySound("Artillery_Close_SoundSet", soundPos);
					closeArtySound.SetAutodestroy(true);
					
					// We add camera shake upon shell detonation
					float distance_to_player = vector.DistanceSq(soundPos, GetGame().GetPlayer().GetPosition());
					if (distance_to_player <= GameConstants.CAMERA_SHAKE_ARTILLERY_DISTANCE2)
					{
						float strength_factor = Math.InverseLerp(GameConstants.CAMERA_SHAKE_ARTILLERY_DISTANCE, 0, Math.Sqrt(distance_to_player));
						DayZPlayerCamera camera = GetGame().GetPlayer().GetCurrentCamera();
						if (camera)
							camera.SpawnCameraShake(strength_factor * 4);
					}
					
					ParticleManager.GetInstance().PlayInWorld(ParticleList.CONTAMINATED_AREA_GAS_SHELL, soundPos);
					break;
				}
				// Single artillery shot to announce dynamic contaminated area
				case ERPCs.RPC_SOUND_ARTILLERY_SINGLE:
				{
					vector soundPosition;
					vector delayedSoundPos;
					float soundDelay;
					
					Param3<vector, vector, float> playArtyShotSound = new Param3<vector, vector, float>(vector.Zero, vector.Zero, 0);
					if (ctx.Read(playArtyShotSound))
					{
						soundPosition = playArtyShotSound.param1;
						delayedSoundPos = playArtyShotSound.param2;
						soundDelay = playArtyShotSound.param3;
						if (soundPosition == vector.Zero)
							break;
					}
					else
						break;
					
					if (!GetGame().GetPlayer())
						break;
					
					m_ArtySound = SEffectManager.PlaySound("Artillery_Distant_SoundSet", soundPosition, 0.1, 0.1);
					m_ArtySound.SetAutodestroy(true);
					
					// We remove the amount of time the incoming sound lasts
					soundDelay -= 5;
					// We convert to milliseconds
					soundDelay *= 1000;
					GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(DelayedMidAirDetonation, soundDelay, false, delayedSoundPos[0], delayedSoundPos[1], delayedSoundPos[2]);
					break;
				}
				case ERPCs.RPC_SET_BILLBOARDS:
				{
					if (!m_BillboardSetHandler)
						m_BillboardSetHandler = new BillboardSetHandler();
					
					Param1<int> indexP = new Param1<int>(-1);
					if (ctx.Read(indexP))
					{
						int index = indexP.param1;
						m_BillboardSetHandler.OnRPCIndex(index);
					}
					break;
				}
				#endif
				#endif

				case ERPCs.RPC_USER_SYNC_PERMISSIONS:
				{
					map<string, bool> mute_list;
					if (ctx.Read(mute_list))
					{
						for (int i = 0; i < mute_list.Count(); i++)
						{
							string uid = mute_list.GetKey(i);
							bool mute = mute_list.GetElement(i);
							MutePlayer(uid, sender.GetPlainId(), mute);
						}
					}
					break;
				}
				
				/*
				case ERPCs.RPC_SERVER_RESPAWN_MODE:
				{
					int mode;
					if (ctx.Read(mode) && !IsServer())
					{
						GetMission().SetRespawnModeClient(mode);
					}
				}
				*/

				#ifdef DEVELOPER
				case ERPCs.DEV_SET_WEATHER:
				{
					Param1<DebugWeatherRPCData> p1data = new Param1<DebugWeatherRPCData>(null);
					
					if ( ctx.Read(p1data) )
					{
						DebugWeatherRPCData data = p1data.param1;
						
						if (data.m_FogValue >= 0)
							GetGame().GetWeather().GetFog().Set(data.m_FogValue, data.m_FogInterpolation, data.m_FogDuration);
						
						if (data.m_OvercastValue >= 0)
							GetGame().GetWeather().GetOvercast().Set(data.m_OvercastValue, data.m_OvercastInterpolation, data.m_OvercastDuration);
						
						if (data.m_RainValue >= 0)
							GetGame().GetWeather().GetRain().Set(data.m_RainValue, data.m_RainInterpolation, data.m_RainDuration);
						
					}
					else
					{
						ErrorEx("Failed to read weather debug data");
					}
					break;
				}
				#endif
				
				
				#ifdef DIAG_DEVELOPER
				#ifdef SERVER
				case ERPCs.DIAG_CAMERATOOLS_CAM_DATA:
				{
					if (!m_CameraToolsMenuServer)
					{
						m_CameraToolsMenuServer = new CameraToolsMenuServer;
					}
					m_CameraToolsMenuServer.OnRPC(rpc_type, ctx);
					break;
				}
				
				case ERPCs.DIAG_CAMERATOOLS_CAM_SUBSCRIBE:
				{
					if (!m_CameraToolsMenuServer)
					{
						m_CameraToolsMenuServer = new CameraToolsMenuServer;
					}
					m_CameraToolsMenuServer.OnRPC(rpc_type, ctx);
					break;
				}

				#endif
				#endif

			}
			// global rpc's handling
		}
	}
	
	void DelayedMidAirDetonation(float x, float y, float z)
	{
		EffectSound artilleryFallSound = SEffectManager.PlaySound("Artillery_Fall_SoundSet", Vector(x, y, z));
		artilleryFallSound.SetAutodestroy(true);
	}
	
	// ------------------------------------------------------------
	void CheckDialogs()
	{
		#ifndef NO_GUI	
		Mission mission = GetMission();
		if (mission && !m_loading.IsLoading() && GetUIManager().IsDialogQueued())
		{
			mission.Pause();
			GetUIManager().ShowQueuedDialog();
		}
		#endif
	}
	
	//! Returns true when connecting to server
	void SetConnecting(bool value)
	{
		m_IsConnecting = value;
	}
	
	bool IsConnecting()
	{
		return m_IsConnecting;
	}
	
	// ------------------------------------------------------------
	bool IsLoading()
	{
		return m_loading && m_loading.IsLoading();
	}
	
	// ------------------------------------------------------------
	void SetKeyboardHandle(UIScriptedMenu handler)
	{
		m_keyboard_handler = handler;
	}
	
	// ------------------------------------------------------------
	void LoadingShow()
	{
		#ifndef NO_GUI	
		m_loading.ShowEx(this);
		#endif
	}
	
	// ------------------------------------------------------------
	void LoadingHide(bool force = false)
	{
		#ifndef NO_GUI
			m_loading.Hide(force);
			// turn the lights back on
			PPEManagerStatic.GetPPEManager().StopAllEffects();
			#ifdef PLATFORM_CONSOLE
			if (!IsLoading())
			{
				if (m_LoadState != DayZLoadState.MAIN_MENU_START && m_LoadState != DayZLoadState.MAIN_MENU_USER_SELECT)
				{
					UpdateInputDeviceDisconnectWarning();
				}
			}
			#endif
		#endif
	}

	// ------------------------------------------------------------
	override string CreateDefaultPlayer()
	{				
		if (m_CharClassNames.Count() > 0)
			return m_CharClassNames[0];

		return "";
	}
	
	// ------------------------------------------------------------
	override string CreateRandomPlayer()
	{
		return m_CharClassNames.GetRandomElement();
	}
	
	// ------------------------------------------------------------
	override TStringArray ListAvailableCharacters()
	{
		return m_CharClassNames;
	}
	
	// ------------------------------------------------------------
	void ExplosionEffectsEx(Object source, Object directHit, int componentIndex, float energyFactor, float explosionFactor, HitInfo hitInfo)
	{
		vector pos = hitInfo.GetPosition();
		string ammoType = hitInfo.GetAmmoType();
		
		// Call legacy method
		ExplosionEffects(source, directHit, componentIndex, hitInfo.GetSurface(), pos, hitInfo.GetSurfaceNormal(), energyFactor, explosionFactor, hitInfo.IsWater(), ammoType);
		
		// add explosion noise
		if (IsServer())
		{
			//NoiseParams npar = new NoiseParams();
			m_NoiseParams.LoadFromPath(string.Format("cfgAmmo %1 NoiseExplosion", ammoType));
			
			GetNoiseSystem().AddNoiseTarget(pos, 21, m_NoiseParams, hitInfo.GetSurfaceNoiseMultiplier());
		}
	}
	
	// ------------------------------------------------------------
	void ExplosionEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal,
		float energyFactor, float explosionFactor, bool isWater, string ammoType)
	{
		#ifndef SERVER
		if (source)
		{
			source.OnExplosionEffects(source, directHit, componentIndex, surface, pos, surfNormal, energyFactor, explosionFactor, isWater, ammoType);
			
			if (source.ShootsExplosiveAmmo() && ammoType == "Explosion_40mm_Ammo")
				ParticleManager.GetInstance().PlayInWorld(ParticleList.EXPLOSION_LANDMINE, pos);
			
			float distance_to_player = vector.Distance(pos, GetGame().GetPlayer().GetPosition());
			m_AmmoShakeParams.Load(ammoType);
			
			if (distance_to_player < m_AmmoShakeParams.m_Radius)
			{
				float dist01 = Math.InverseLerp(0, m_AmmoShakeParams.m_Radius, distance_to_player);
				float modifier = Math.Lerp(m_AmmoShakeParams.m_ModifierClose, m_AmmoShakeParams.m_ModifierFar,dist01);
				
				GetGame().GetPlayer().GetCurrentCamera().SpawnCameraShake(modifier * m_AmmoShakeParams.m_Strength);
			}
		}
		#endif
	}
	
	// ------------------------------------------------------------
	void OnProjectileStopped(ProjectileStoppedInfo info)
	{
		string simulation;
		
		GetGame().ConfigGetText("cfgAmmo " + info.GetAmmoType() + " simulation", simulation);	

		if (simulation == "shotArrow")
		{
			string pile;
			
			GetGame().ConfigGetText("cfgAmmo " + info.GetAmmoType() + " spawnPileType", pile);
			
			EntityAI arrow = EntityAI.Cast(GetGame().CreateObjectEx(pile, info.GetPos(), ECE_DYNAMIC_PERSISTENCY));
			arrow.PlaceOnSurface();	
			arrow.SetFromProjectile(info);
		}
	}
	
	const float ARROW_PIERCE_DEPTH = 0.05;
	
	// ------------------------------------------------------------
	void OnProjectileStoppedInTerrain(TerrainCollisionInfo info)
	{
		string simulation;
		
		if (info.GetIsWater())
			return;
		
		GetGame().ConfigGetText("cfgAmmo " + info.GetAmmoType() + " simulation", simulation);
		if (simulation == "shotArrow")
		{
			string pile;
			GetGame().ConfigGetText("cfgAmmo " + info.GetAmmoType() + " spawnPileType", pile);
			vector pos = info.GetPos();
			vector dir = -info.GetInVelocity();
			
			dir.Normalize();
			pos -= dir * ARROW_PIERCE_DEPTH;
			
			EntityAI arrow = EntityAI.Cast(GetGame().CreateObjectEx(pile, pos, ECE_KEEPHEIGHT|ECE_DYNAMIC_PERSISTENCY));
			arrow.SetDirection(dir);
			arrow.SetFromProjectile(info);
		}
	}
	
	// ------------------------------------------------------------
	void OnProjectileStoppedInObject(ObjectCollisionInfo info)
	{
		string simulation;
		
		GetGame().ConfigGetText("cfgAmmo " + info.GetAmmoType() + " simulation", simulation);	
		if (simulation == "shotArrow")
		{
			string pile;
			GetGame().ConfigGetText("cfgAmmo " + info.GetAmmoType() + " spawnPileType", pile);
			
			EntityAI arrow = null;
			EntityAI ent = EntityAI.Cast(info.GetHitObj());
			if (ent)
			{
				EntityAI parent = ent.GetHierarchyParent();
				if (parent && parent.IsPlayer())
				{
					arrow = EntityAI.Cast(GetGame().CreateObjectEx(pile, parent.GetPosition(), ECE_DYNAMIC_PERSISTENCY));
					arrow.PlaceOnSurface();	
					arrow.SetFromProjectile(info);
	
					return;
				}
			}
			
			vector pos = info.GetPos();
			vector dir = -info.GetInVelocity();
			
			dir.Normalize();
			pos -= dir * ARROW_PIERCE_DEPTH;
			
			arrow = EntityAI.Cast(GetGame().CreateObjectEx(pile, pos, ECE_KEEPHEIGHT|ECE_DYNAMIC_PERSISTENCY));
			arrow.SetDirection(dir);
			arrow.SetFromProjectile(info);
			
			info.GetHitObj().AddArrow(arrow, info.GetComponentIndex(), info.GetHitObjPos(), info.GetHitObjRot());
		}
	}
	
	// ------------------------------------------------------------
	void FirearmEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal,
		 vector exitPos, vector inSpeed, vector outSpeed, bool isWater, bool deflected, string ammoType) 
	{
		#ifndef SERVER
		ImpactEffectsData impactEffectsData = new ImpactEffectsData();
		impactEffectsData.m_DirectHit 		= directHit;
		impactEffectsData.m_ComponentIndex 	= componentIndex;
		impactEffectsData.m_Surface 		= surface;
		impactEffectsData.m_Position		= pos;
		impactEffectsData.m_ImpactType		= ImpactTypes.UNKNOWN;
		impactEffectsData.m_SurfaceNormal	= surfNormal;
		impactEffectsData.m_ExitPosition	= exitPos;
		impactEffectsData.m_InSpeed			= inSpeed;
		impactEffectsData.m_OutSpeed		= outSpeed;
		impactEffectsData.m_IsDeflected		= deflected;
		impactEffectsData.m_AmmoType		= ammoType;
		impactEffectsData.m_IsWater			= isWater;

		if (directHit)
		{
			directHit.OnReceivedHit(impactEffectsData);
		}

		ImpactMaterials.EvaluateImpactEffectEx(impactEffectsData);
		#endif
		
		
		if (IsServer())
		{
			if (source && source.ShootsExplosiveAmmo() && !deflected && outSpeed == vector.Zero)
			{
				if (ammoType == "Bullet_40mm_ChemGas")
				{
					GetGame().CreateObject("ContaminatedArea_Local", pos);
				}
				else if (ammoType == "Bullet_40mm_Explosive")
				{
					DamageSystem.ExplosionDamage(EntityAI.Cast(source), null, "Explosion_40mm_Ammo", pos, DamageType.EXPLOSION);
				}
			}
			
			// add hit noise
			m_NoiseParams.LoadFromPath("cfgAmmo " + ammoType + " NoiseHit");
			
			float surfaceCoef = SurfaceGetNoiseMultiplier(directHit, pos, componentIndex);
			float coefAdjusted = surfaceCoef * inSpeed.Length() / ConfigGetFloat("cfgAmmo " + ammoType + " initSpeed");
			GetNoiseSystem().AddNoiseTarget(pos, 10, m_NoiseParams, coefAdjusted); // Leave a ping for 5 seconds
		}
	}
	
	// ------------------------------------------------------------
	void CloseCombatEffects(Object source, Object directHit, int componentIndex, string surface, vector pos, vector surfNormal,
		 bool isWater, string ammoType) 
	{
		#ifndef SERVER
		ImpactEffectsData impactEffectsData = new ImpactEffectsData();
		impactEffectsData.m_DirectHit 		= directHit;
		impactEffectsData.m_ComponentIndex 	= componentIndex;
		impactEffectsData.m_Surface 		= surface;
		impactEffectsData.m_Position		= pos;
		impactEffectsData.m_ImpactType		= ImpactTypes.MELEE;
		impactEffectsData.m_SurfaceNormal	= Vector(Math.RandomFloat(-1,1), Math.RandomFloat(-1,1), Math.RandomFloat(-1,1));
		impactEffectsData.m_ExitPosition	= "0 0 0";
		impactEffectsData.m_InSpeed			= "0 0 0";
		impactEffectsData.m_OutSpeed		= "0 0 0";
		impactEffectsData.m_IsDeflected		= false;
		impactEffectsData.m_AmmoType		= ammoType;
		impactEffectsData.m_IsWater			= isWater;

		if (directHit)
			directHit.OnReceivedHit(impactEffectsData);
		
		ImpactMaterials.EvaluateImpactEffectEx(impactEffectsData);
		#endif
		
		// add hit noise
		if (IsServer())
		{
			m_NoiseParams.LoadFromPath("cfgAmmo " + ammoType + " NoiseHit");
			
			float surfaceCoef = SurfaceGetNoiseMultiplier(directHit, pos, componentIndex);
			GetNoiseSystem().AddNoisePos(EntityAI.Cast(source), pos, m_NoiseParams, surfaceCoef);
		}
	}
	
	void UpdateVoiceLevel(int level)
	{
		GetMission().UpdateVoiceLevelWidgets(level);	
	}
	
	void InitCharacterMenuDataInfo(int menudata_count)
	{
		m_OriginalCharactersCount = menudata_count;
	}
	
	void SetPlayerGameName(string name)
	{
		m_PlayerName = name;
	}
	
	string GetPlayerGameName()
	{
		return m_PlayerName;
	}
	
	void SetNewCharacter(bool state)
	{
		m_IsNewCharacter = state;
	}
	
	bool IsNewCharacter()
	{
		return m_IsNewCharacter;
	}
	
	void SetUserFOV(float pFov)
	{
		if (pFov < OPTIONS_FIELD_OF_VIEW_MIN)
			pFov = OPTIONS_FIELD_OF_VIEW_MIN;

		if (pFov > OPTIONS_FIELD_OF_VIEW_MAX)
			pFov = OPTIONS_FIELD_OF_VIEW_MAX;
		
		m_UserFOV = pFov;
	}
	
	float GetUserFOV()
	{
		return m_UserFOV;
	}
	
	static float GetUserFOVFromConfig()
	{
		GameOptions gameOptions = new GameOptions;
		NumericOptionsAccess noa;
		if (gameOptions && Class.CastTo(noa,gameOptions.GetOptionByType(OptionAccessType.AT_OPTIONS_FIELD_OF_VIEW)))
		{
			return noa.ReadValue();
		}
		return 1.0;
	}
	
	float GetFOVByZoomType(ECameraZoomType type)
	{
		switch (type)
		{
			case ECameraZoomType.NONE:
				return GetUserFOV();
			case ECameraZoomType.NORMAL:
				return Math.Min(GetUserFOV(), GameConstants.DZPLAYER_CAMERA_FOV_EYEZOOM);
			case ECameraZoomType.SHALLOW:
				return Math.Min(GetUserFOV(),GameConstants.DZPLAYER_CAMERA_FOV_EYEZOOM_SHALLOW);
			default:
				return GetUserFOV();
		}
		return GetUserFOV();
	}
	
	void SetHudBrightness(float value)
	{
		Widget.SetLV(value);
		Widget.SetTextLV(value);
	}
	
	float GetHUDBrightnessSetting()
	{
		return g_Game.GetProfileOptionFloat(EDayZProfilesOptions.HUD_BRIGHTNESS);
	}
	
	// Check if ammo is compatible with a weapon in hands 
	static bool CheckAmmoCompability(EntityAI weaponInHand, EntityAI ammo)
	{	
		TStringArray ammo_names = new TStringArray;										// Array of ammo types (their name) that can be used with weapon in hand
		
		string cfg_path = "CfgWeapons " + weaponInHand.GetType() + " chamberableFrom";	// Create config path 
		GetGame().ConfigGetTextArray(cfg_path, ammo_names);								// Get ammo types 
			
		foreach (string ammo_name : ammo_names)				// for every ammo in ammo string compare passed ammo 
		{
			if (ammo.GetType() == ammo_name)					
			{
				return true;			
			}
		}
		
		// if no ammo from the array matches with ammo passed, return false 
		return false;
	}
	
	void SetEVValue(float value)
	{
		m_PreviousEVValue = m_EVValue;
		SetEVUser(value);
		m_EVValue = value;
	}
	
	float GetCurrentEVValue()
	{
		return m_EVValue;
	}
	
	float GetPreviousEVValue()
	{
		return m_PreviousEVValue;
	}
	
	int GetCurrentDisplayLanguageIdx()
	{
		ListOptionsAccess	language_option;
		GameOptions options = new GameOptions();
		language_option = ListOptionsAccess.Cast(options.GetOptionByType(OptionAccessType.AT_OPTIONS_LANGUAGE));
		int idx = -1;
		if (language_option)
		{
			idx = language_option.GetIndex();
		}
		
		return idx;
	}
	
	bool IsWorldWetTempUpdateEnabled()
	{
		return m_IsWorldWetTempUpdateEnabled;
	}
	
	bool IsFoodDecayEnabled()
	{
		return (GetFoodDecayModifier() != 0);
	}	
	
	float GetFoodDecayModifier()
	{
		#ifdef DIAG_DEVELOPER
		
		if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.FOOD_DECAY))
		{
			return m_FoodDecayModifier * FeatureTimeAccel.GetFeatureTimeAccelValue();
		}
		#endif
		return m_FoodDecayModifier;
	}
	
	array<int> GetConnectedInputDeviceList()
	{
		if (!m_ConnectedInputDeviceList)
		{
			m_ConnectedInputDeviceList = new array<int>;
		}
		return m_ConnectedInputDeviceList;
	}
	
	void SetMouseCursorDesiredVisibility(bool visible)
	{
		m_CursorDesiredVisibilityScript = visible;

		RefreshMouseCursorVisibility();
	}
	
	bool GetMouseCursorDesiredVisibility()
	{
		return m_CursorDesiredVisibilityScript;
	}
	
	//! extend as needed, only game focus and M&K setting (consoles only!) are checked natively
	bool CanDisplayMouseCursor()
	{
		//! Only checking on console because while loading on PC, the mouse might not be detected
#ifdef PLATFORM_CONSOLE
		if (GetInput())
		{
			return GetInput().IsMouseConnected();
		}
#endif

		//! Platform defaults
#ifdef PLATFORM_CONSOLE
		return false;
#else
		return true;
#endif
	}
	
	void RefreshMouseCursorVisibility()
	{
#ifndef NO_GUI
#ifdef FEATURE_CURSOR
		if (!IsAppActive())
		{
			ShowCursorWidget(true);
		}
		else
#endif
		{
			bool showCursor = m_CursorDesiredVisibilityScript && CanDisplayMouseCursor();
			
			UIManager ui = GetUIManager();
			if (ui)
			{
				//! Handles app active-ness
				ui.ShowCursor(showCursor);
			}
			else
			{
				//! Fallback, just in-case
				ShowCursorWidget(showCursor);
			}
		}
#endif
	}

	BillboardSetHandler GetBillboardHandler()
	{
		return m_BillboardSetHandler;
	}
	
	///////////////
	//DEPRECATED//
	//////////////
	void CreateGamepadDisconnectMenu();
	void DeleteGamepadDisconnectMenu();
};

DayZGame g_Game;

DayZGame GetDayZGame()
{
	return g_Game;
}