Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

UTGame.UTPlayerController


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321
02322
02323
02324
02325
02326
02327
02328
02329
02330
02331
02332
02333
02334
02335
02336
02337
02338
02339
02340
02341
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396
02397
02398
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409
02410
02411
02412
02413
02414
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440
02441
02442
02443
02444
02445
02446
02447
02448
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472
02473
02474
02475
02476
02477
02478
02479
02480
02481
02482
02483
02484
02485
02486
02487
02488
02489
02490
02491
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521
02522
02523
02524
02525
02526
02527
02528
02529
02530
02531
02532
02533
02534
02535
02536
02537
02538
02539
02540
02541
02542
02543
02544
02545
02546
02547
02548
02549
02550
02551
02552
02553
02554
02555
02556
02557
02558
02559
02560
02561
02562
02563
02564
02565
02566
02567
02568
02569
02570
02571
02572
02573
02574
02575
02576
02577
02578
02579
02580
02581
02582
02583
02584
02585
02586
02587
02588
02589
02590
02591
02592
02593
02594
02595
02596
02597
02598
02599
02600
02601
02602
02603
02604
02605
02606
02607
02608
02609
02610
02611
02612
02613
02614
02615
02616
02617
02618
02619
02620
02621
02622
02623
02624
02625
02626
02627
02628
02629
02630
02631
02632
02633
02634
02635
02636
02637
02638
02639
02640
02641
02642
02643
02644
02645
02646
02647
02648
02649
02650
02651
02652
02653
02654
02655
02656
02657
02658
02659
02660
02661
02662
02663
02664
02665
02666
02667
02668
02669
02670
02671
02672
02673
02674
02675
02676
02677
02678
02679
02680
02681
02682
02683
02684
02685
02686
02687
02688
02689
02690
02691
02692
02693
02694
02695
02696
02697
02698
02699
02700
02701
02702
02703
02704
02705
02706
02707
02708
02709
02710
02711
02712
02713
02714
02715
02716
02717
02718
02719
02720
02721
02722
02723
02724
02725
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735
02736
02737
02738
02739
02740
02741
02742
02743
02744
02745
02746
02747
02748
02749
02750
02751
02752
02753
02754
02755
02756
02757
02758
02759
02760
02761
02762
02763
02764
02765
02766
02767
02768
02769
02770
02771
02772
02773
02774
02775
02776
02777
02778
02779
02780
02781
02782
02783
02784
02785
02786
02787
02788
02789
02790
02791
02792
02793
02794
02795
02796
02797
02798
02799
02800
02801
02802
02803
02804
02805
02806
02807
02808
02809
02810
02811
02812
02813
02814
02815
02816
02817
02818
02819
02820
02821
02822
02823
02824
02825
02826
02827
02828
02829
02830
02831
02832
02833
02834
02835
02836
02837
02838
02839
02840
02841
02842
02843
02844
02845
02846
02847
02848
02849
02850
02851
02852
02853
02854
02855
02856
02857
02858
02859
02860
02861
02862
02863
02864
02865
02866
02867
02868
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878
02879
02880
02881
02882
02883
02884
02885
02886
02887
02888
02889
02890
02891
02892
02893
02894
02895
02896
02897
02898
02899
02900
02901
02902
02903
02904
02905
02906
02907
02908
02909
02910
02911
02912
02913
02914
02915
02916
02917
02918
02919
02920
02921
02922
02923
02924
02925
02926
02927
02928
02929
02930
02931
02932
02933
02934
02935
02936
02937
02938
02939
02940
02941
02942
02943
02944
02945
02946
02947
02948
02949
02950
02951
02952
02953
02954
02955
02956
02957
02958
02959
02960
02961
02962
02963
02964
02965
02966
02967
02968
02969
02970
02971
02972
02973
02974
02975
02976
02977
02978
02979
02980
02981
02982
02983
02984
02985
02986
02987
02988
02989
02990
02991
02992
02993
02994
02995
02996
02997
02998
02999
03000
03001
03002
03003
03004
03005
03006
03007
03008
03009
03010
03011
03012
03013
03014
03015
03016
03017
03018
03019
03020
03021
03022
03023
03024
03025
03026
03027
03028
03029
03030
03031
03032
03033
03034
03035
03036
03037
03038
03039
03040
03041
03042
03043
03044
03045
03046
03047
03048
03049
03050
03051
03052
03053
03054
03055
03056
03057
03058
03059
03060
03061
03062
03063
03064
03065
03066
03067
03068
03069
03070
03071
03072
03073
03074
03075
03076
03077
03078
03079
03080
03081
03082
03083
03084
03085
03086
03087
03088
03089
03090
03091
03092
03093
03094
03095
03096
03097
03098
03099
03100
03101
03102
03103
03104
03105
03106
03107
03108
03109
03110
03111
03112
03113
03114
03115
03116
03117
03118
03119
03120
03121
03122
03123
03124
03125
03126
03127
03128
03129
03130
03131
03132
03133
03134
03135
03136
03137
03138
03139
03140
03141
03142
03143
03144
03145
03146
03147
03148
03149
03150
03151
03152
03153
03154
03155
03156
03157
03158
03159
03160
03161
03162
03163
03164
03165
03166
03167
03168
03169
03170
03171
03172
03173
03174
03175
03176
03177
03178
03179
03180
03181
03182
03183
03184
03185
03186
03187
03188
03189
03190
03191
03192
03193
03194
03195
03196
03197
03198
03199
03200
03201
03202
03203
03204
03205
03206
03207
03208
03209
03210
03211
03212
03213
03214
03215
03216
03217
03218
03219
03220
03221
03222
03223
03224
03225
03226
03227
03228
03229
03230
03231
03232
03233
03234
03235
03236
03237
03238
03239
03240
03241
03242
03243
03244
03245
03246
03247
03248
03249
03250
03251
03252
03253
03254
03255
03256
03257
03258
03259
03260
03261
03262
03263
03264
03265
03266
03267
03268
03269
03270
03271
03272
03273
03274
03275
03276
03277
03278
03279
03280
03281
03282
03283
03284
03285
03286
03287
03288
03289
03290
03291
03292
03293
03294
03295
03296
03297
03298
03299
03300
03301
03302
03303
03304
03305
03306
03307
03308
03309
03310
03311
03312
03313
03314
03315
03316
03317
03318
03319
03320
03321
03322
03323
03324
03325
03326
03327
03328
03329
03330
03331
03332
03333
03334
03335
03336
03337
03338
03339
03340
03341
03342
03343
03344
03345
03346
03347
03348
03349
03350
03351
03352
03353
03354
03355
03356
03357
03358
03359
03360
03361
03362
03363
03364
03365
03366
03367
03368
03369
03370
03371
03372
03373
03374
03375
03376
03377
03378
03379
03380
03381
03382
03383
03384
03385
03386
03387
03388
03389
03390
03391
03392
03393
03394
03395
03396
03397
03398
03399
03400
03401
03402
03403
03404
03405
03406
03407
03408
03409
03410
03411
03412
03413
03414
03415
03416
03417
03418
03419
03420
03421
03422
03423
03424
03425
03426
03427
03428
03429
03430
03431
03432
03433
03434
03435
03436
03437
03438
03439
03440
03441
03442
03443
03444
03445
03446
03447
03448
03449
03450
03451
03452
03453
03454
03455
03456
03457
03458
03459
03460
03461
03462
03463
03464
03465
03466
03467
03468
03469
03470
03471
03472
03473
03474
03475
03476
03477
03478
03479
03480
03481
03482
03483
03484
03485
03486
03487
03488
03489
03490
03491
03492
03493
03494
03495
03496
03497
03498
03499
03500
03501
03502
03503
03504
03505
03506
03507
03508
03509
03510
03511
03512
03513
03514
03515
03516
03517
03518
03519
03520
03521
03522
03523
03524
03525
03526
03527
03528
03529
03530
03531
03532
03533
03534
03535
03536
03537
03538
03539
03540
03541
03542
03543
03544
03545
03546
03547
03548
03549
03550
03551
03552
03553
03554
03555
03556
03557
03558
03559
03560
03561
03562
03563
03564
03565
03566
03567
03568
03569
03570
03571
03572
03573
03574
03575
03576
03577
03578
03579
03580
03581
03582
03583
03584
03585
03586
03587
03588
03589
03590
03591
03592
03593
03594
03595
03596
03597
03598
03599
03600
03601
03602
03603
03604
03605
03606
03607
03608
03609
03610
03611
03612
03613
03614
03615
03616
03617
03618
03619
03620
03621
03622
03623
03624
03625
03626
03627
03628
03629
03630
03631
03632
03633
03634
03635
03636
03637
03638
03639
03640
03641
03642
03643
03644
03645
03646
03647
03648
03649
03650
03651
03652
03653
03654
03655
03656
03657
03658
03659
03660
03661
03662
03663
03664
03665
03666
03667
03668
03669
03670
03671
03672
03673
03674
03675
03676
03677
03678
03679
03680
03681
03682
03683
03684
03685
03686
03687
03688
03689
03690
03691
03692
03693
03694
03695
03696
03697
03698
03699
03700
03701
03702
03703
03704
03705
03706
03707
03708
03709
03710
03711
03712
03713
03714
03715
03716
03717
03718
03719
03720
03721
03722
03723
03724
03725
03726
03727
03728
03729
03730
03731
03732
03733
03734
03735
03736
03737
03738
03739
03740
03741
03742
03743
03744
03745
03746
03747
03748
03749
03750
03751
03752
03753
03754
03755
03756
03757
03758
03759
03760
03761
03762
03763
03764
03765
03766
03767
03768
03769
03770
03771
03772
03773
03774
03775
03776
03777
03778
03779
03780
03781
03782
03783
03784
03785
03786
03787
03788
03789
03790
03791
03792
03793
03794
03795
03796
03797
03798
03799
03800
03801
03802
03803
03804
03805
03806
03807
03808
03809
03810
03811
03812
03813
03814
03815
03816
03817
03818
03819
03820
03821
03822
03823
03824
03825
03826
03827
03828
03829
03830
03831
03832
03833
03834
03835
03836
03837
03838
03839
03840
03841
03842
03843
03844
03845
03846
03847
03848
03849
03850
03851
03852
03853
03854
03855
03856
03857
03858
03859
03860
03861
03862
03863
03864
03865
03866
03867
03868
03869
03870
03871
03872
03873
03874
03875
03876
03877
03878
03879
03880
03881
03882
03883
03884
03885
03886
03887
03888
03889
03890
03891
03892
03893
03894
03895
03896
03897
03898
03899
03900
03901
03902
03903
03904
03905
03906
03907
03908
03909
03910
03911
03912
03913
03914
03915
03916
03917
03918
03919
03920
03921
03922
03923
03924
03925
03926
03927
03928
03929
03930
03931
03932
03933
03934
03935
03936
03937
03938
03939
03940
03941
03942
03943
03944
03945
03946
03947
03948
03949
03950
03951
03952
03953
03954
03955
03956
03957
03958
03959
03960
03961
03962
03963
03964
03965
03966
03967
03968
03969
03970
03971
03972
03973
03974
03975
03976
03977
03978
03979
03980
03981
03982
03983
03984
03985
03986
03987
03988
03989
03990
03991
03992
03993
03994
03995
03996
03997
03998
03999
04000
04001
04002
04003
04004
04005
04006
04007
04008
04009
04010
04011
04012
04013
04014
04015
04016
04017
04018
04019
04020
04021
04022
04023
04024
04025
04026
04027
04028
04029
04030
04031
04032
04033
04034
04035
04036
04037
04038
04039
04040
04041
04042
04043
04044
04045
04046
04047
04048
04049
04050
04051
04052
04053
04054
04055
04056
04057
04058
04059
04060
04061
04062
04063
04064
04065
04066
04067
04068
04069
04070
04071
04072
04073
04074
04075
04076
04077
04078
04079
04080
04081
04082
04083
04084
04085
04086
04087
04088
04089
04090
04091
04092
04093
04094
04095
04096
04097
04098
04099
04100
04101
04102
04103
04104
04105
04106
04107
04108
04109
04110
04111
04112
04113
04114
04115
04116
04117
04118
04119
04120
04121
04122
04123
04124
04125
04126
04127
04128
04129
04130
04131
04132
04133
04134
04135
04136
04137
04138
04139
04140
04141
04142
04143
04144
04145
04146
04147
04148
04149
04150
04151
04152
04153
04154
04155
04156
04157
04158
04159
04160
04161
04162
04163
04164
04165
04166
04167
04168
04169
04170
04171
04172
04173
04174
04175
04176
04177
04178
04179
04180
04181
04182
04183
04184
04185
04186
04187
04188
04189
04190
04191
04192
04193
04194
04195
04196
04197
04198
04199
04200
04201
04202
04203
04204
04205
04206
04207
04208
04209
04210
04211
04212
04213
04214
04215
04216
04217
04218
04219
04220
04221
04222
04223
04224
04225
04226
04227
04228
04229
04230
04231
04232
04233
04234
04235
04236
04237
04238
04239
04240
04241
04242
04243
04244
04245
04246
04247
04248
04249
04250
04251
04252
04253
04254
04255
04256
04257
04258
04259
04260
04261
04262
04263
04264
04265
04266
04267
04268
04269
04270
04271
04272
04273
04274
04275
04276
04277
04278
04279
04280
04281
04282
04283
04284
04285
04286
04287
04288
04289
04290
04291
04292
04293
04294
04295
04296
04297
04298
04299
04300
04301
04302
04303
04304
04305
04306
04307
04308
04309
04310
04311
04312
04313
04314
04315
04316
04317
04318
04319
04320
04321
04322
04323
04324
04325
04326
04327
04328
04329
04330
04331
04332
04333
04334
04335
04336
04337
04338
04339
04340
04341
04342
04343
04344
04345
04346
04347
04348
04349
04350
04351
04352
04353
04354
04355
04356
04357
04358
04359
04360
04361
04362
04363
04364
04365
04366
04367
04368
04369
04370
04371
04372
04373
04374
04375
04376
04377
04378
04379
04380
04381
04382
04383
04384
04385
04386
04387
04388
04389
04390
04391
04392
04393
04394
04395
04396
04397
04398
04399
04400
04401
04402
04403
04404
04405
04406
04407
04408
04409
04410
04411
04412
04413
04414
04415
04416
04417
04418
04419
04420
04421
04422
04423
04424
04425
04426
04427
04428
04429
04430
04431
04432
04433
04434
04435
04436
04437
04438
04439
04440
04441
04442
04443
04444
04445
04446
04447
04448
04449
04450
04451
04452
04453
04454
04455
04456
04457
04458
04459
04460
04461
04462
04463
04464
04465
04466
04467
04468
04469
04470
04471
04472
04473
04474
04475
04476
04477
04478
04479
04480
04481
04482
04483
04484
04485
04486
04487
04488
04489
04490
04491
04492
04493
04494
04495
04496
04497
04498
04499
04500
04501
04502
04503
04504
04505
04506
04507
04508
04509
04510
04511
04512
04513
04514
04515
04516
04517
04518
04519
04520
04521
04522
04523
04524
04525
04526
04527
04528
04529
04530
04531
04532
04533
04534
04535
04536
04537
04538
04539
04540
04541
04542
04543
04544
04545
04546
04547
04548
04549
04550
04551
04552
04553
04554
04555
04556
04557
04558
04559
04560
04561
04562
04563
04564
04565
04566
04567
04568
04569
04570
04571
04572
04573
04574
04575
04576
04577
04578
04579
04580
04581
04582
04583
04584
04585
04586
04587
04588
04589
04590
04591
04592
04593
04594
04595
04596
04597
04598
04599
04600
04601
04602
04603
04604
04605
04606
04607
04608
04609
04610
04611
04612
04613
04614
04615
04616
04617
04618
04619
04620
04621
04622
04623
04624
04625
04626
04627
04628
04629
04630
04631
04632
04633
04634
04635
04636
04637
04638
04639
04640
04641
04642
04643
04644
04645
04646
04647
04648
04649
04650
04651
04652
04653
04654
04655
04656
04657
04658
04659
04660
04661
04662
04663
04664
04665
04666
04667
04668
04669
04670
04671
04672
04673
04674
04675
04676
04677
04678
04679
04680
04681
04682
04683
04684
04685
04686
04687
04688
04689
04690
04691
04692
04693
04694
04695
04696
04697
04698
04699
04700
04701
04702
04703
04704
04705
04706
04707
04708
04709
04710
04711
04712
04713
04714
04715
04716
04717
04718
04719
04720
04721
04722
04723
04724
04725
04726
04727
04728
04729
04730
04731
04732
04733
04734
04735
04736
04737
04738
04739
04740
04741
04742
04743
04744
04745
04746
04747
04748
04749
04750
04751
04752
04753
04754
04755
04756
04757
04758
04759
04760
04761
04762
04763
04764
04765
04766
04767
04768
04769
04770
04771
04772
04773
04774
04775
04776
04777
04778
04779
04780
04781
04782
04783
04784
04785
04786
04787
04788
04789
04790
04791
04792
04793
04794
04795
04796
04797
04798
04799
04800
04801
04802
04803
04804
04805
04806
04807
04808
04809
04810
04811
04812
04813
04814
04815
04816
04817
04818
04819
04820
04821
04822
04823
04824
04825
04826
04827
04828
04829
04830
04831
04832
04833
04834
04835
04836
04837
04838
04839
04840
04841
04842
04843
04844
04845
04846
04847
04848
04849
04850
04851
04852
04853
04854
04855
04856
04857
04858
04859
04860
04861
04862
04863
04864
04865
04866
04867
04868
04869
04870
04871
04872
04873
04874
04875
04876
04877
04878
04879
04880
04881
04882
04883
04884
04885
04886
04887
04888
04889
04890
04891
04892
04893
04894
04895
04896
04897
04898
04899
04900
04901
04902
04903
04904
04905
04906
04907
04908
04909
04910
04911
04912
04913
04914
04915
04916
04917
04918
04919
04920
04921
04922
04923
04924
04925
04926
04927
04928
04929
04930
04931
04932
04933
04934
04935
04936
04937
04938
04939
04940
04941
04942
04943
04944
04945
04946
04947
04948
04949
04950
04951
04952
04953
04954
04955
04956
04957
04958
04959
04960
04961
04962
04963
04964
04965
04966
04967
04968
04969
04970
04971
04972
04973
04974
04975
04976
04977
04978
04979
04980
04981
04982
04983
04984
04985
04986
04987
04988
04989
04990
04991
04992
04993
04994
04995
04996
04997
04998
04999
05000
05001
05002
05003
05004
05005
05006
05007
05008
05009
05010
05011
05012
05013
05014
05015
05016
05017
05018
05019
05020
05021
05022
05023
05024
05025
05026
05027
05028
05029
05030
05031
05032
05033
05034
05035
05036
05037
05038
05039
05040
05041
05042
05043
05044
05045
05046
05047
05048
05049
05050
05051
05052
05053
05054
05055
05056
05057
05058
05059
05060
05061
05062
05063
05064
05065
05066
05067
05068
05069
05070
05071
05072
05073
05074
05075
05076
05077
05078
05079
05080
05081
05082
05083
05084
05085
05086
05087
05088
05089
05090
05091
05092
05093
05094
05095
05096
05097
05098
05099
05100
05101
05102
05103
05104
05105
05106
05107
05108
05109
05110
05111
05112
05113
05114
05115
05116
05117
05118
05119
05120
05121
05122
05123
05124
05125
05126
05127
05128
05129
05130
05131
05132
05133
05134
05135
05136
05137
05138
05139
05140
05141
05142
05143
05144
05145
05146
05147
05148
05149
05150
05151
05152
05153
05154
05155
05156
05157
05158
05159
05160
05161
05162
05163
05164
05165
05166
05167
05168
05169
05170
05171
05172
05173
05174
05175
05176
05177
05178
05179
05180
05181
05182
05183
05184
05185
05186
05187
05188
05189
05190
05191
05192
05193
05194
05195
05196
05197
05198
05199
05200
05201
05202
05203
05204
05205
05206
05207
05208
05209
05210
05211
05212
05213
05214
05215
05216
05217
05218
05219
05220
05221
05222
05223
05224
05225
05226
05227
05228
05229
05230
05231
05232
05233
05234
05235
05236
05237
05238
05239
05240
05241
05242
05243
05244
05245
05246
05247
05248
05249
05250
05251
05252
05253
05254
05255
05256
05257
05258
05259
05260
05261
05262
05263
05264
05265
05266
05267
05268
05269
05270
05271
05272
05273
05274
05275
05276
05277
05278
05279
05280
05281
05282
05283
05284
05285
05286
05287
05288
05289
05290
05291
05292
05293
05294
05295
05296
05297
05298
05299
05300
05301
05302
05303
05304
05305
05306
05307
05308
05309
05310
05311
05312
05313
05314
05315
05316
05317
05318
05319
05320
05321
05322
05323
05324
05325
05326
05327
05328
05329
05330
05331
05332
05333
05334
05335
05336
05337
05338
05339
05340
05341
05342
05343
05344
05345
05346
05347
05348
05349
05350
05351
05352
05353
05354
05355
05356
05357
05358
05359
05360
05361
05362
05363
05364
05365
05366
05367
05368
05369
05370
05371
05372
05373
05374
05375
05376
05377
05378
05379
05380
05381
05382
05383
05384
05385
05386
05387
05388
05389
05390
05391
05392
05393
05394
05395
05396
05397
05398
05399
05400
05401
05402
05403
05404
05405
05406
05407
05408
05409
05410
05411
05412
05413
05414
05415
05416
05417
05418
05419
05420
05421
05422
05423
05424
05425
05426
05427
05428
05429
05430
05431
05432
05433
05434
05435
05436
05437
05438
05439
05440
05441
05442
05443
05444
05445
05446
05447
05448
05449
05450
05451
05452
05453
05454
05455
05456
05457
05458
05459
05460
05461
05462
05463
05464
05465
05466
05467
05468
05469
05470
05471
05472
05473
05474
05475
05476
05477
05478
05479
05480
05481
05482
05483
05484
05485
05486
05487
05488
05489
05490
05491
05492
05493
05494
05495
05496
05497
05498
05499
05500
05501
05502
05503
05504
05505
05506
05507
05508
05509
05510
05511
05512
05513
05514
05515
05516
05517
05518
05519
05520
05521
05522
05523
05524
05525
05526
05527
05528
05529
05530
05531
05532
05533
05534
05535
05536
05537
05538
05539
05540
05541
05542
05543
05544
05545
05546
05547
05548
05549
05550
05551
05552
05553
05554
05555
05556
05557
05558
05559
05560
05561
05562
05563
05564
05565
05566
05567
05568
05569
05570
05571
05572
05573
05574
05575
05576
05577
05578
05579
05580
05581
05582
05583
05584
05585
05586
05587
05588
05589
05590
05591
05592
05593
05594
05595
05596
05597
05598
05599
05600
05601
05602
05603
05604
05605
05606
05607
05608
05609
05610
05611
05612
05613
05614
05615
05616
05617
05618
05619
05620
05621
05622
05623
05624
05625
05626
05627
05628
05629
05630
05631
05632
05633
05634
05635
05636
05637
05638
05639
05640
05641
05642
05643
05644
05645
05646
05647
05648
05649
05650
05651
05652
05653
05654
05655
05656
05657
05658
05659
05660
05661
05662
05663
05664
05665
05666
05667
05668
05669
05670
05671
05672
05673
05674
05675
05676
05677
05678
05679
05680
05681
05682
05683
05684
05685
05686
05687
05688
05689
05690
05691
05692
05693
05694
05695
05696
05697
05698
05699
05700
05701
05702
05703
05704
05705
05706
05707
05708
05709
05710
05711
05712
05713
05714
05715
05716
05717
05718
05719
05720
05721
05722
05723
05724
05725
05726
05727
05728
05729
05730
05731
05732
05733
05734
05735
05736
05737
05738
05739
05740
05741
05742
05743
05744
05745
05746
05747
05748
05749
05750
05751
05752
05753
05754
05755
05756
05757
05758
05759
05760
05761
05762
05763
05764
05765
05766
05767
05768
05769
05770
05771
05772
05773
05774
05775
05776
05777
05778
05779
05780
05781
05782
05783
05784
05785
05786
05787
05788
05789
05790
05791
05792
05793
05794
05795
05796
05797
05798
05799
05800
05801
05802
05803
05804
05805
05806
05807
05808
05809
05810
05811
05812
05813
05814
05815
05816
05817
05818
05819
05820
05821
05822
05823
05824
05825
05826
05827
05828
05829
05830
05831
05832
05833
05834
05835
05836
05837
05838
05839
05840
05841
05842
05843
05844
05845
05846
05847
05848
05849
05850
05851
05852
05853
05854
05855
05856
05857
05858
05859
05860
05861
05862
05863
05864
05865
05866
05867
05868
05869
05870
05871
05872
05873
05874
05875
05876
05877
05878
05879
05880
05881
05882
05883
05884
05885
05886
05887
05888
05889
05890
05891
05892
05893
05894
05895
05896
05897
05898
05899
05900
05901
05902
05903
05904
05905
05906
05907
05908
05909
05910
05911
05912
05913
05914
05915
05916
05917
05918
05919
05920
05921
05922
05923
05924
05925
05926
05927
05928
05929
05930
05931
05932
05933
05934
05935
05936
05937
05938
05939
05940
05941
05942
05943
05944
05945
05946
05947
05948
05949
05950
05951
05952
05953
05954
05955
05956
05957
05958
05959
05960
05961
05962
05963
05964
05965
05966
05967
05968
05969
05970
05971
05972
05973
05974
05975
05976
05977
05978
05979
05980
05981
05982
05983
05984
05985
05986
05987
05988
05989
05990
05991
05992
05993
05994
05995
05996
05997
05998
05999
06000
06001
06002
06003
06004
06005
06006
06007
06008
06009
06010
06011
06012
06013
06014
06015
06016
06017
06018
06019
06020
06021
06022
06023
06024
06025
06026
06027
06028
06029
06030
06031
06032
06033
06034
06035
06036
06037
06038
06039
06040
06041
06042
06043
06044
06045
06046
06047
06048
06049
06050
06051
06052
06053
06054
06055
06056
06057
06058
06059
06060
06061
06062
06063
06064
06065
06066
06067
06068
06069
06070
06071
06072
06073
06074
06075
06076
06077
06078
06079
06080
06081
06082
06083
06084
06085
06086
06087
06088
06089
06090
06091
06092
06093
06094
06095
06096
06097
06098
06099
06100
06101
06102
06103
06104
06105
06106
06107
06108
06109
06110
06111
06112
06113
06114
06115
06116
06117
06118
06119
06120
06121
06122
06123
06124
06125
06126
06127
06128
06129
06130
06131
06132
06133
06134
06135
06136
06137
06138
06139
06140
06141
06142
06143
06144
06145
06146
06147
06148
06149
06150
06151
06152
06153
06154
06155
06156
06157
06158
06159
06160
06161
06162
06163
06164
06165
06166
06167
06168
06169
06170
06171
06172
06173
06174
06175
06176
06177
06178
06179
06180
06181
06182
06183
06184
06185
06186
06187
06188
06189
06190
06191
06192
06193
06194
06195
06196
06197
06198
06199
06200
06201
06202
06203
06204
06205
06206
06207
06208
06209
06210
06211
06212
06213
06214
06215
06216
06217
06218
06219
06220
06221
06222
06223
06224
06225
06226
06227
06228
06229
06230
06231
06232
06233
06234
06235
06236
06237
06238
06239
06240
06241
06242
06243
06244
06245
06246
06247
06248
06249
06250
06251
06252
06253
06254
06255
06256
06257
06258
06259
06260
06261
06262
06263
06264
06265
06266
06267
06268
06269
06270
06271
06272
06273
06274
06275
06276
06277
06278
06279
06280
06281
06282
06283
06284
06285
06286
06287
06288
06289
06290
06291
06292
06293
06294
06295
06296
06297
06298
06299
06300
06301
06302
06303
06304
06305
06306
06307
06308
06309
06310
06311
06312
06313
06314
06315
06316
06317
06318
06319
06320
06321
06322
06323
06324
06325
06326
06327
06328
06329
06330
06331
06332
06333
06334
06335
06336
06337
06338
06339
06340
06341
06342
06343
06344
06345
06346
06347
06348
06349
06350
06351
06352
06353
06354
06355
06356
06357
06358
06359
06360
06361
06362
06363
06364
06365
06366
06367
06368
06369
06370
06371
06372
06373
06374
06375
06376
06377
06378
06379
06380
06381
06382
06383
06384
06385
06386
06387
06388
06389
06390
06391
06392
06393
06394
06395
06396
06397
06398
06399
06400
06401
06402
06403
06404
06405
06406
06407
06408
06409
06410
06411
06412
06413
06414
06415
06416
06417
06418
06419
06420
06421
06422
06423
06424
06425
06426
06427
06428
06429
06430
06431
06432
06433
06434
06435
06436
06437
06438
06439
06440
06441
06442
06443
06444
06445
06446
06447
06448
06449
06450
06451
06452
06453
06454
06455
06456
06457
06458
06459
06460
06461
06462
06463
06464
06465
06466
06467
06468
06469
06470
06471
06472
06473
06474
06475
06476
06477
06478
06479
06480
06481
06482
06483
06484
06485
06486
06487
06488
06489
06490
06491
06492
06493
06494
06495
06496
06497
06498
06499
06500
06501
06502
06503
06504
06505
06506
06507
06508
06509
06510
06511
06512
06513
06514
06515
06516
06517
06518
06519
06520
06521
06522
06523
06524
06525
06526
06527
06528
06529
06530
06531
06532
06533
06534
06535
06536
06537
06538
06539
06540
06541
06542
06543
06544
06545
06546
06547
06548
06549
06550
06551
06552
06553
06554
06555
06556
06557
06558
06559
06560
06561
06562
06563
06564
06565
06566
06567
06568
06569
06570
06571
06572
06573
06574
06575
06576
06577
06578
06579
06580
06581
06582
06583
06584
06585
06586
06587
06588
06589
06590
06591
06592
06593
06594
06595
06596
06597
06598
06599
06600
06601
06602
06603
06604
06605
06606
06607
06608
06609
06610
06611
06612
06613
06614
06615
06616
06617
06618
06619
06620
06621
06622
06623
06624
06625
06626
06627
06628
06629
06630
06631
06632
06633
06634
06635
06636
06637
06638
06639
06640
06641
06642
06643
06644
06645
06646
06647
06648
06649
06650
06651
06652
06653
06654
06655
06656
06657
06658
06659
06660
06661
06662
06663
06664
06665
06666
06667
06668
06669
06670
06671
06672
06673
06674
06675
06676
06677
06678
06679
06680
06681
06682
06683
06684
06685
06686
06687
06688
06689
06690
06691
06692
06693
06694
06695
06696
06697
06698
06699
06700
06701
06702
06703
06704
06705
06706
06707
06708
06709
06710
06711
06712
06713
06714
06715
06716
06717
06718
06719
06720
06721
06722
06723
06724
06725
06726
06727
06728
06729
06730
06731
06732
06733
06734
06735
06736
06737
06738
06739
06740
06741
06742
06743
06744
06745
06746
06747
06748
06749
06750
06751
06752
06753
06754
06755
06756
06757
06758
06759
06760
06761
06762
06763
06764
06765
06766
06767
06768
06769
06770
06771
06772
06773
06774
06775
06776
06777
06778
06779
06780
06781
06782
06783
06784
06785
06786
06787
06788
06789
06790
06791
06792
06793
06794
06795
06796
06797
06798
06799
06800
06801
06802
06803
06804
06805
06806
06807
06808
06809
06810
06811
06812
06813
06814
06815
06816
06817
06818
06819
06820
06821
06822
06823
06824
06825
06826
06827
06828
06829
06830
06831
06832
06833
06834
06835
06836
06837
06838
06839
06840
06841
06842
06843
06844
06845
06846
06847
06848
06849
06850
06851
06852
06853
06854
06855
06856
06857
06858
06859
06860
06861
06862
06863
06864
06865
06866
06867
06868
06869
06870
06871
06872
06873
06874
06875
06876
06877
06878
06879
06880
06881
06882
06883
06884
06885
06886
06887
06888
06889
06890
06891
06892
06893
06894
06895
06896
06897
06898
06899
06900
06901
06902
06903
06904
06905
06906
06907
06908
06909
06910
06911
06912
06913
06914
06915
06916
06917
06918
06919
06920
06921
06922
06923
06924
06925
/**
 * UTPlayerController
 *
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */

class UTPlayerController extends GamePlayerController
	dependson(UTPawn)
	dependson(UTCustomChar_Data)
	dependson(UTProfileSettings)
	config(Game)
	native;
























































































































 



#linenumber 14









const GS_USERNAME_MAXLENGTH					 = 15;
const GS_PASSWORD_MAXLENGTH					 = 30;
const GS_MESSAGE_MAXLENGTH					 = 255;
const GS_EMAIL_MAXLENGTH					 = 50;
const GS_CDKEY_PART_MAXLENGTH				 = 4;


const CONTEXT_PRESENCE_MENUPRESENCE              = 0;

const CONTEXT_GAME_MODE							 = 0x0000800B;


const CONTEXT_GAME_MODE_DM                       = 0;
const CONTEXT_GAME_MODE_CTF                      = 1;
const CONTEXT_GAME_MODE_WAR                      = 2;
const CONTEXT_GAME_MODE_VCTF					 = 3;
const CONTEXT_GAME_MODE_TDM                      = 4;
const CONTEXT_GAME_MODE_DUEL                     = 5;
const CONTEXT_GAME_MODE_CUSTOM                   = 6;
const CONTEXT_GAME_MODE_CAMPAIGN                 = 7;
const CONTEXT_GAME_MODE_GREED					 = 8;
const CONTEXT_GAME_MODE_BETRAYAL				 = 9;

const CONTEXT_BOTSKILL                           = 0;
const CONTEXT_MAPNAME                            = 1;
const CONTEXT_PURESERVER                         = 6;
const CONTEXT_LOCKEDSERVER                       = 7;
const CONTEXT_VSBOTS                             = 8;
const CONTEXT_CAMPAIGN                           = 9;
const CONTEXT_FORCERESPAWN                       = 10;
const CONTEXT_ALLOWKEYBOARD                      = 11;
const CONTEXT_FULLSERVER                         = 12;
const CONTEXT_EMPTYSERVER                        = 13;
const CONTEXT_DEDICATEDSERVER                    = 14;


const CONTEXT_BOTSKILL_AUTOADJUSTSKILL                     = 0;
const CONTEXT_BOTSKILL_NOVICE                              = 1;
const CONTEXT_BOTSKILL_AVERAGE                             = 2;
const CONTEXT_BOTSKILL_EXPERIENCED                         = 3;
const CONTEXT_BOTSKILL_SKILLED                             = 4;
const CONTEXT_BOTSKILL_ADEPT                               = 5;
const CONTEXT_BOTSKILL_MASTERFUL                           = 6;
const CONTEXT_BOTSKILL_INHUMAN                             = 7;
const CONTEXT_BOTSKILL_GODLIKE                             = 8;




const CONTEXT_MAPNAME_CUSTOM                     = 0;
const CONTEXT_MAPNAME_CORET                      = 1;
const CONTEXT_MAPNAME_HYDROSIS                   = 2;
const CONTEXT_MAPNAME_OMICRON_DAWN               = 3;
const CONTEXT_MAPNAME_REFLECTION                 = 4;
const CONTEXT_MAPNAME_STRIDENT                   = 5;
const CONTEXT_MAPNAME_VERTEBRAE                  = 6;
const CONTEXT_MAPNAME_ARSENAL                    = 7;
const CONTEXT_MAPNAME_BIOHAZARD                  = 8;
const CONTEXT_MAPNAME_CARBON_FIRE                = 9;
const CONTEXT_MAPNAME_DECK                       = 10;
const CONTEXT_MAPNAME_DEFIANCE                   = 11;
const CONTEXT_MAPNAME_DEIMOS                     = 12;
const CONTEXT_MAPNAME_DIESEL                     = 13;
const CONTEXT_MAPNAME_FEARLESS                   = 14;
const CONTEXT_MAPNAME_GATEWAY                    = 15;
const CONTEXT_MAPNAME_HEAT_RAY                   = 16;
const CONTEXT_MAPNAME_RISING_SUN                 = 17;
const CONTEXT_MAPNAME_SANCTUARY                  = 18;
const CONTEXT_MAPNAME_SENTINEL                   = 19;
const CONTEXT_MAPNAME_SHANGRILA                  = 20;
const CONTEXT_MAPNAME_CONTAINMENT                = 21;
const CONTEXT_MAPNAME_CONTAINMENTSP              = 22;
const CONTEXT_MAPNAME_CORRUPTION                 = 23;
const CONTEXT_MAPNAME_KARGO                      = 24;
const CONTEXT_MAPNAME_NECROPOLIS                 = 25;
const CONTEXT_MAPNAME_SANDSTORM                  = 26;
const CONTEXT_MAPNAME_SUSPENSE                   = 27;
const CONTEXT_MAPNAME_AVALANCHE                  = 28;
const CONTEXT_MAPNAME_DOWNTOWN                   = 29;
const CONTEXT_MAPNAME_DUSK                       = 30;
const CONTEXT_MAPNAME_FLOODGATE                  = 31;
const CONTEXT_MAPNAME_ISLANDER                   = 32;
const CONTEXT_MAPNAME_ISLANDERNECRIS             = 33;
const CONTEXT_MAPNAME_MARKET_DISTRICT            = 34;
const CONTEXT_MAPNAME_ONYX_COAST                 = 35;
const CONTEXT_MAPNAME_POWER_SURGE                = 36;
const CONTEXT_MAPNAME_SERENITY                   = 37;
const CONTEXT_MAPNAME_SERENITYNECRIS             = 38;
const CONTEXT_MAPNAME_SINKHOLE                   = 39;
const CONTEXT_MAPNAME_TANK_CROSSING              = 40;
const CONTEXT_MAPNAME_TORLAN                     = 41;
const CONTEXT_MAPNAME_TORLANLEVIATHAN            = 42;
const CONTEXT_MAPNAME_TORLANNECRIS               = 43;
const CONTEXT_MAPNAME_MISSION_SELECTION          = 44;
const CONTEXT_MAPNAME_KBARGE					 = 45;
const CONTEXT_MAPNAME_MORBIAS					 = 46;
const CONTEXT_MAPNAME_FACINGWORLDS				 = 47;
const CONTEXT_MAPNAME_SEARCHLIGHT				 = 48;
const CONTEXT_MAPNAME_RAILS						 = 49;
const CONTEXT_MAPNAME_SUSPENSE_NECRIS			 = 50;
const CONTEXT_MAPNAME_COLDHARBOR				 = 51;
const CONTEXT_MAPNAME_DOWNTOWNNECRIS			 = 52;

const CONTEXT_MAPNAME_LOSTCAUSE					 = 53;
const CONTEXT_MAPNAME_MORBID					 = 54;
const CONTEXT_MAPNAME_NANOBLACK					 = 55;
const CONTEXT_MAPNAME_SHAFT						 = 56;
const CONTEXT_MAPNAME_DARKMATCH					 = 57;
const CONTEXT_MAPNAME_OCEANRELIC				 = 58;
const CONTEXT_MAPNAME_EDENINC					 = 59;
const CONTEXT_MAPNAME_TURBINE					 = 60;
const CONTEXT_MAPNAME_STRANDED					 = 61;
const CONTEXT_MAPNAME_CONFRONTATION				 = 62;
const CONTEXT_MAPNAME_HOSTILE					 = 63;



const CONTEXT_GOALSCORE_5                        = 0;
const CONTEXT_GOALSCORE_10                       = 1;
const CONTEXT_GOALSCORE_15                       = 2;
const CONTEXT_GOALSCORE_20                       = 3;
const CONTEXT_GOALSCORE_30                       = 4;



const CONTEXT_NUMBOTS_0                          = 0;
const CONTEXT_NUMBOTS_1                          = 1;
const CONTEXT_NUMBOTS_2                          = 2;
const CONTEXT_NUMBOTS_3                          = 3;
const CONTEXT_NUMBOTS_4                          = 4;
const CONTEXT_NUMBOTS_5                          = 5;
const CONTEXT_NUMBOTS_6                          = 6;
const CONTEXT_NUMBOTS_7                          = 7;
const CONTEXT_NUMBOTS_8                          = 8;



const CONTEXT_TIMELIMIT_5                        = 0;
const CONTEXT_TIMELIMIT_10                       = 1;
const CONTEXT_TIMELIMIT_15                       = 2;
const CONTEXT_TIMELIMIT_20                       = 3;
const CONTEXT_TIMELIMIT_30                       = 4;



const CONTEXT_PURESERVER_NO                                = 0;
const CONTEXT_PURESERVER_YES                               = 1;
const CONTEXT_PURESERVER_ANY                               = 2;



const CONTEXT_LOCKEDSERVER_NO                              = 0;
const CONTEXT_LOCKEDSERVER_YES                             = 1;



const CONTEXT_CAMPAIGN_NO                                  = 0;
const CONTEXT_CAMPAIGN_YES                                 = 1;



const CONTEXT_FORCERESPAWN_NO                              = 0;
const CONTEXT_FORCERESPAWN_YES                             = 1;



const CONTEXT_ALLOWKEYBOARD_NO                             = 0;
const CONTEXT_ALLOWKEYBOARD_YES                            = 1;
const CONTEXT_ALLOWKEYBOARD_ANY                            = 2;


const CONTEXT_FULLSERVER_NO                                = 0;
const CONTEXT_FULLSERVER_YES                               = 1;


const CONTEXT_EMPTYSERVER_NO					= 0;
const CONTEXT_EMPTYSERVER_YES					= 1;


const CONTEXT_DEDICATEDSERVER_NO                = 0;
const CONTEXT_DEDICATEDSERVER_YES               = 1;



const  CONTEXT_VSBOTS_NONE                       = 0;
const  CONTEXT_VSBOTS_1_TO_2                     = 1;
const  CONTEXT_VSBOTS_1_TO_1                     = 2;
const  CONTEXT_VSBOTS_3_TO_2					 = 3;
const  CONTEXT_VSBOTS_2_TO_1                     = 4;
const  CONTEXT_VSBOTS_3_TO_1                     = 5;
const  CONTEXT_VSBOTS_4_TO_1                     = 6;

const PROPERTY_NUMBOTS							 = 0x100000F7;
const PROPERTY_GOALSCORE						 = 0x100000F8;
const PROPERTY_TIMELIMIT				         = 0x100000F9;
const PROPERTY_NUMBOTSIA				         = 0x100000FA;
const PROPERTY_LEADERBOARDRATING	             = 0x20000004;
const PROPERTY_EPICMUTATORS                      = 0x10000105;
const PROPERTY_STEAMID					         = 0x10000200;
const PROPERTY_STEAMVAC					         = 0x10000201;


const PROPERTY_CUSTOMMAPNAME                     = 0x40000001;
const PROPERTY_CUSTOMGAMEMODE                    = 0x40000002;
const PROPERTY_SERVERDESCRIPTION                 = 0x40000003;
const PROPERTY_CUSTOMMUTATORS                    = 0x40000004;
const PROPERTY_CUSTOMMUTCLASSES                  = 0x40000005;


const QUERY_DM									 = 0;
const QUERY_TDM									 = 1;
const QUERY_CTF									 = 2;
const QUERY_VCTF								 = 3;
const QUERY_WAR									 = 4;
const QUERY_DUEL								 = 5;
const QUERY_CAMPAIGN							 = 6;
const QUERY_GREED								 = 7;
const QUERY_BETRAYAL							 = 8;



const STATS_VIEW_DM_PLAYER_ALLTIME                         = 1;
const STATS_VIEW_DM_RANKED_ALLTIME                         = 2;
const STATS_VIEW_DM_WEAPONS_ALLTIME                        = 3;
const STATS_VIEW_DM_VEHICLES_ALLTIME                       = 4;
const STATS_VIEW_DM_VEHICLEWEAPONS_ALLTIME                 = 5;
const STATS_VIEW_DM_VEHICLES_RANKED_ALLTIME                = 6;
const STATS_VIEW_DM_VEHICLEWEAPONS_RANKED_ALLTIME          = 7;
const STATS_VIEW_DM_WEAPONS_RANKED_ALLTIME                 = 8;

#linenumber 15

var					bool	bLateComer;
var					bool 	bDontUpdate;
var					bool	bIsTyping;
var					bool	bAcuteHearing;			/** makes playercontroller hear much better (used to magnify hit sounds caused by player) */

var globalconfig	bool	bNoVoiceMessages;
var globalconfig	bool	bNoTextToSpeechVoiceMessages;
var globalconfig	bool	bTextToSpeechTeamMessagesOnly;
var globalconfig	bool	bNoVoiceTaunts;
var globalconfig	bool	bNoAutoTaunts;
var globalconfig	bool	bAutoTaunt;
var globalconfig	bool	bNoMatureLanguage;

var globalconfig	bool	bEnableDodging;
var globalconfig    bool    bLookUpStairs;  // look up/down stairs (player)
var globalconfig    bool    bSnapToLevel;   // Snap to level eyeheight when not mouselooking
var globalconfig    bool    bAlwaysMouseLook;
var globalconfig    bool    bKeyboardLook;  // no snapping when true
var					bool    bCenterView;
var globalconfig	bool	bAlwaysLevel;
var					byte	IdentifiedTeam;

/** If true, switch to vehicle's rotation when possessing it (except for roll) */
var	globalconfig	bool	bUseVehicleRotationOnPossess;

var bool	bViewingMap;

/** If true, HUD minimap is zoomed and rotates around player */
var bool bRotateMinimap;

/** set when any initial clientside processing required before allowing the player to join the game has completed */
var bool bInitialProcessingComplete;

/** Used to keep spectator cameras from going out of world boundaries */
var bool	bCameraOutOfWorld;

var globalconfig enum EPawnShadowMode
{
	SHADOW_None,
	SHADOW_Self,
	SHADOW_All
} PawnShadowMode;

var globalconfig bool bFirstPersonWeaponsSelfShadow;

var		bool	bBehindView;

/** if true, while in the spectating state, behindview will be forced on a player */
var bool bForceBehindView;

/** if true, rotate smoothly to desiredrotation */
var bool bUsePhysicsRotation;

var bool bFreeCamera;

enum EWeaponHand
{
	HAND_Right,
	HAND_Left,
	HAND_Centered,
	HAND_Hidden,
};
var globalconfig EWeaponHand WeaponHandPreference;
var EWeaponHand	WeaponHand;

var vector		DesiredLocation;

var UTAnnouncer Announcer;
var UTMusicManager MusicManager;

var float LastTauntAnimTime;
var float LastKickWarningTime;

var localized string MsgPlayerNotFound;

/** plays camera animations (mostly used for viewshakes) */
var CameraAnimInst CameraAnimPlayer;
/** set when the last camera anim we played was caused by damage - we only let damage shakes override other damage shakes */
var bool bCurrentCamAnimIsDamageShake;
/** set if camera anim modifies FOV - don't do any FOV interpolation while camera anim is playing */
var bool bCurrentCamAnimAffectsFOV;
/** Vibration  */
var ForceFeedbackWaveform CameraShakeShortWaveForm, CameraShakeLongWaveForm;

/** stores post processing settings applied by the camera animation
 * applied additively to the default post processing whenever a camera anim is playing
 */
var PostProcessSettings CamOverridePostProcess;

/** camera anim played when hit (blend strength depends on damage taken) */
var CameraAnim DamageCameraAnim;

/** current offsets applied to the camera due to camera anims, etc */
var vector ShakeOffset; // current magnitude to offset camera position from shake
var rotator ShakeRot; // current magnitude to offset camera rotation from shake
var globalconfig	bool	bLandingShake;

/** additional post processing settings modifier that can be applied
 * @note: defaultproperties for this are hardcoded to zeroes in C++
 */
var PostProcessSettings PostProcessModifier;

var float LastCameraTimeStamp; /** Used during matinee sequences */
var class<Camera> MatineeCameraClass;

var config bool bCenteredWeaponFire;

/** This variable stores the objective that the player wishes to spawn closest to */
var UTGameObjective StartObjective;

/** cached result of GetPlayerViewPoint() */
var Actor CalcViewActor;
var vector CalcViewActorLocation;
var rotator CalcViewActorRotation;
var vector CalcViewLocation;
var rotator CalcViewRotation;
var float CalcEyeHeight;
var vector CalcWalkBob;

var float	LastWarningTime;	/** Last time a warning about a shot being fired at my pawn was accepted. */

/** How fast (degrees/sec) should a zoom occur */
var float FOVLinearZoomRate;

/** If TRUE, FOV interpolation for zooming is nonlineear, using FInterpTo.  If FALSE, use linear interp. */
var transient bool bNonlinearZoomInterpolation;

/** Interp speed (as used in FInterpTo) for nonlinear FOV interpolation. */
var transient float FOVNonlinearZoomInterpSpeed;

/** Used to scale changes in rotation when the FOV is zoomed */
var float ZoomRotationModifier;

/** Whether or not we should retrieve settings from the profile on next tick. */
var transient bool bRetrieveSettingsFromProfileOnNextTick;

/** Whether or not we are quitting to the main menu. */
var transient bool bQuittingToMainMenu;

/** vars for debug freecam, which allows camera to view player from all angles */
var transient bool		bDebugFreeCam;
var transient rotator	DebugFreeCamRot;

/** last time ServerShowPathToBase() was executed, to avoid spamming the world with path effects */
var float LastShowPathTime;

/** enum for the various options for the game telling the player what to do next */
enum EAutoObjectivePreference
{
	AOP_Disabled, // turned off
	AOP_NoPreference,
	AOP_Attack, // tell what to do to attack
	AOP_Defend, // tell what to do to defend
	AOP_OrbRunner,
	AOP_SpecialOps,

};
var globalconfig EAutoObjectivePreference AutoObjectivePreference;

/** set if player isn't using orb, to adjust orders given */
var bool bNotUsingOrb;

struct native ObjectiveAnnouncementInfo
{
	/** the default announcement sound to play (can be None) */
	var() SoundNodeWave AnnouncementSound;
	/** text displayed onscreen for this announcement */
	var() localized string AnnouncementText;
};

/** last objective CheckAutoObjective() sent a notification about */
var Actor LastAutoObjective;

/** last time auto objective was updated */
var float LastAutoObjectiveTime;

/** true if was defending last autoobjective */
var bool bWasDefendingObjective;

/** Custom scaling for vehicle check radius.  Used by UTConsolePlayerController */
var	float	VehicleCheckRadiusScaling;

/** Indicates what control mode is desired for vehicles. */
var EUTVehicleControls	VehicleControlType;

/** Set when use fails to enter nearby vehicle (to prevent smart use from also putting you on hoverboard) */
var bool bJustFoundVehicle;

/** If true, the quick pick menu will be disable and the key will act like PrevWeapon */
var() bool bDisableQuickPick;

/** Used for pulsing critical objective beacon */
var float BeaconPulseScale;
var float BeaconPulseMax;
var float BeaconPulseRate;
var bool bBeaconPulseDir;

var float PulseTimer;
var bool bPulseTeamColor;

var bool bConstructioningMeshes;
var string ConstructioningStatus;
var float ConstructioningProgress;

/** Holds the template for the command menu */
var UTUIScene_CommandMenu CommandMenuTemplate;
var UTUIScene_CommandMenu CommandMenu;

/** Holds the current Map Scene */
var UTUIScene CurrentMapScene;

var UTUIScene_MapVote TestSceneTemplate;

/** class to use for displaying progress messages */
var	string	ProgressMessageSceneClassName;

/** Struct to define values for different post processing presets. */
struct native PostProcessInfo
{
	var float Shadows;
	var float MidTones;
	var float HighLights;
	var float Desaturation;
};

/** Array of possible preset values for post process. */
var transient array<PostProcessInfo>	PostProcessPresets;

/** The effect to play on the camera **/
var UTEmitCameraEffect CameraEffect;

/** This player's Voter Registration Card */
var UTVoteReplicationInfo VoteRI;

/** Actors which may be hidden dynamically when rendering (by adding to PlayerController.HiddenActors array) */
var array<Actor> PotentiallyHiddenActors;

/** Last bullseye announcement (hacky - don't want multiple close together) */
var float LastBullseyeTime;

/** Last "use" time - used to limit "use" frequency */
var	float	LastUseTime;

/** to limit frequency of voice messages */
var float OldMessageTime;

/** To limit frequency of received "friendly fire" voice messages */
var float LastFriendlyFireTime;

/** If true, we will popup the map page when the player dies so they can select their spanw point */
var bool bPopupMapOnDeath;

/** How long after death should we wait to popup the map */
var float PopupWaitTime;

/** The data store that holds data needed to translate bound input events to strings for UI */
var UTUIDataStore_StringAliasBindingsMap BoundEventsStringDataStore;

var config bool bNoCrosshair;

var config bool bSimpleCrosshair;

/** Last time "incoming" message was received by this player */
var float LastIncomingMessageTime;

/** Last time combat update message was received by this player */
var float LastCombatUpdateTime;

/** Used to prevent too frequent team changes */
var float LastTeamChangeTime;

/** Currently playing text-to-speech generated sounds. */
var private array<SoundCue> ActiveTTSSoundCues;

var bool bAlreadyReset;

var float NextAdminCmdTime;

/** True if Hero post processing effects are on */
var bool bHeroPPEffectsOn;

var globalconfig float OnFootDefaultFOV;

/** If true, the server has muted all text chat from this player */
var bool bServerMutedText;

/** this is set when admin is sending local maplist to the server, so that game class changes due to travelling don't disrupt it */
var name MapListPublishGameClassName;

/** If true, don't show the path arrows to your objective */
var globalconfig bool bHideObjectivePaths;

/** when downloading during servertravel, we send console messages instead of the UI box so that the player can continue to talk, etc
 * this is the time of the last message so we don't spam too many
 */
var float LastConsoleDownloadMessageTime;

/** Cached value for achievement unlock */
var int LastAchievementIDUnlocked;

/** Cached values for the retrieved server ID/Name, set by the history saving code, and utilized by the 'add favourite' code */
var UniqueNetId SavedServerID;
var string SavedServerName;
var string SavedServerIP;

/** If this PC is used in client side demo recordings */
var bool bSmoothClientDemo;

// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)

/**
 * Change Camera mode - only in single player
 *
 * @param	New camera mode to set
 */
exec function Camera( name NewMode )
{
	if ( WorldInfo.NetMode == NM_Standalone )
	{
		ServerCamera(NewMode);
	}
}


exec function GetSessionInfo()
{
	local string StatGuid, PlayerIdString;
	local UTPlayerController UTPC;

	if ( OnlineSub != None && OnlineSub.GameInterface != None )
	{
		StatGuid = OnlineSub.StatsInterface.GetHostStatGuid();
		LogInternal("SessionID is"@StatGuid);

		foreach WorldInfo.AllControllers(class'UTPlayerController',UTPC)
		{
			PlayerIdString = class'Engine.OnlineSubsystem'.static.UniqueNetIdToString(UTPC.PlayerReplicationInfo.UniqueId);
			LogInternal("PlayerName:"@UTPC.PlayerReplicationInfo.PlayerName@"ID:"@PlayerIdString);
		}
	}
}


reliable server function ServerThrowWeapon()
{
    if ( Pawn.CanThrowWeapon() )
    {
		Pawn.ThrowActiveWeapon();
    }
}

event InitInputSystem()
{
	local UTGameReplicationInfo GRI;

	Super.InitInputSystem();

	AddOnlineDelegates(true);

	// we do this here so that we only bother to create it for local players
	CameraAnimPlayer = new(self) class'CameraAnimInst';

	// see if character processing was already completed
	// this can happen on clients if a PlayerController class switch is performed
	// and the GRI is received before the new PlayerController
	if (WorldInfo.NetMode == NM_Client)
	{
		GRI = UTGameReplicationInfo(WorldInfo.GRI);
		if (GRI != None && GRI.bProcessedInitialCharacters)
		{
			CharacterProcessingComplete();
		}
	}

	if (WorldInfo.NetMode == NM_ListenServer && PlayerReplicationInfo != none )
	{
		PlayerReplicationInfo.IsInvalidName();
	}

	SaveServerToHistory();
}

/**
 * Saves the UniqueNetId for the current server to the player's list of recently visited servers (server history).
 */
function SaveServerToHistory()
	{
	local LocalPlayer LP;
	local OnlineGameSettings CurrentGameSettings;
	local UTDataStore_GameSearchHistory HistoryDataStore;
	local UniqueNetID NullID;

	LP = LocalPlayer(Player);

	// we've successfully joined an online match - add this server's unique PlayerId to the list of recently joined matches
	if ( WorldInfo.NetMode == NM_Client && LP != None && OnlineSub != None && OnlineSub.GameInterface != None && OnlineSub.PlayerInterface != None )
	{
		CurrentGameSettings = OnlineSub.GameInterface.GetGameSettings();

		//Make sure we have valid game settings (OwningPlayerID is zero if you followed a friend)
		if ( CurrentGameSettings != None && CurrentGameSettings.OwningPlayerID != NullID)
		{
			//No history on LAN matches
			if (!CurrentGameSettings.bIsLanMatch)
			{
				HistoryDataStore = UTDataStore_GameSearchHistory(class'UTUIScene'.static.FindDataStore('UTGameHistory', LP));
				if ( HistoryDataStore != None )
				{
					SavedServerID = CurrentGameSettings.OwningPlayerId;
					SavedServerName = CurrentGameSettings.OwningPlayerName;
					SavedServerIP = CurrentGameSettings.ServerIP;

					if (SavedServerIP == "")
						SavedServerIP = GetServerNetworkAddress();

					HistoryDataStore.AddServerPlusIP(LP.ControllerId, SavedServerID, SavedServerName, SavedServerIP);
				}
			}
		}
		else
		{
            //Last ditch attempt to get data needed to save to history
			ServerGetGameHostNameAndId();
		}
	}
}

/**
 * Saves the current server info to the favourites
 */
exec function AddToFavorites()
{
	AddToFavourites();
}

exec function AddToFavourites()
{
	local LocalPlayer LP;
	local UniqueNetId NullID;
	local UTDataStore_GameSearchFavorites FavDataStore;

	LP = LocalPlayer(Player);

	// The server id/name should have been cached when the server was added to history; if not, then the info is unavailable
	if (LP == none || SavedServerID == NullID)
		return;


	FavDataStore = UTDataStore_GameSearchFavorites(Class'UTUIScene'.static.FindDataStore('UTGameFavorites', LP));

	if (FavDataStore != none)
	{
//		ClientMessage(Localize("UTPlayerController", "AddedToFavourites", "UTGame"));
		FavDataStore.AddServerPlusIP(LP.ControllerID, SavedServerID, SavedServerName, SavedServerIP);
	}
}

/* HACK - 
 * last resort attempt to grab the minimum amount of information to save this gaming session to the history datastore 
 * Gets the game settings and give the owning player id and server name to the client
 */
server reliable function ServerGetGameHostNameAndId()
{
	local OnlineGameSettings CurrentGameSettings;
	local string OwningPlayerIdString;

	if ( OnlineSub != None && OnlineSub.GameInterface != None )
	{
		CurrentGameSettings = OnlineSub.GameInterface.GetGameSettings();
		if (CurrentGameSettings != None && !CurrentGameSettings.bIsLanMatch)
		{
			OwningPlayerIdString = class'Engine.OnlineSubsystem'.static.UniqueNetIdToString(CurrentGameSettings.OwningPlayerId);
			ClientSetGameHostNameAndId(OwningPlayerIdString, CurrentGameSettings.OwningPlayerName);
		}
	}
}

/** Called by the server to tell the client what its OwningPlayerId and PlayerName is */
client reliable function ClientSetGameHostNameAndId(string OwningPlayerIdString, string OwningPlayerName)
{
	local LocalPlayer LP;
	local UniqueNetId OwningPlayerId;
	local UTDataStore_GameSearchHistory HistoryDataStore;

	LP = LocalPlayer(Player);

	// we've successfully joined an online match - add this server's unique PlayerId to the list of recently joined matches
	if ( WorldInfo.NetMode == NM_Client && LP != None && OnlineSub != None && OnlineSub.GameInterface != None && OnlineSub.PlayerInterface != None
		&& class'Engine.OnlineSubsystem'.static.StringToUniqueNetId(OwningPlayerIdString, OwningPlayerId))
	{
		SavedServerID = OwningPlayerId;
		SavedServerName = OwningPlayerName;
		SavedServerIP = GetServerNetworkAddress();

		HistoryDataStore = UTDataStore_GameSearchHistory(class'UTUIScene'.static.FindDataStore('UTGameHistory', LP));
		if ( HistoryDataStore != None )
			HistoryDataStore.AddServerPlusIP(LP.ControllerId, OwningPlayerId, OwningPlayerName, SavedServerIP);
	}
}

event PlayerTick( float DeltaTime )
{
	local Pawn P;
	Super.PlayerTick(DeltaTime);

	// This needs to be done here because it ensures that all datastores have been registered properly
	// it also ensures we do not update the profile settings more than once.
	if( bRetrieveSettingsFromProfileOnNextTick )
	{
		RetrieveSettingsFromProfile();
		bRetrieveSettingsFromProfileOnNextTick = FALSE;
	}

	if ( bSmoothClientDemo && WorldInfo.bWithinDemoPlayback )
	{
		// reacquire ViewTarget if the player switched Pawns
		if ( RealViewTarget != None && RealViewTarget != PlayerReplicationInfo &&
			(Pawn(ViewTarget) == None || Pawn(ViewTarget).PlayerReplicationInfo != RealViewTarget) )
		{
			foreach WorldInfo.AllPawns(class'Pawn', P)
			{
				if (P.PlayerReplicationInfo == RealViewTarget)
				{
					SetViewTarget(P);
					break;
				}
			}
		}

		if ( Pawn(ViewTarget) != None )
		{
			if ( UTPawn(ViewTarget) != None )
			{
				TargetViewRotation = ViewTarget.Rotation;
				TargetViewRotation.Pitch = Rotation.Pitch; 
			}
			else
			{
				TargetViewRotation = Rotation;
			}
		}
		
	}
}

/** Sex is set when mesh is set for pawn */
function UpdateSex() {}

/** Get the preferred custom character setup for this player (from player profile store). */
native function CustomCharData GetPlayerCustomCharData(string CharDataString);

/** tells the server about the character this player is using */
reliable server function ServerSetCharacterData(CustomCharData CharData)
{
	local UTPlayerReplicationInfo PRI;
	local UTTeamInfo Team;
	local class<UTFamilyInfo> FamilyInfoClass;

	PRI = UTPlayerReplicationInfo(PlayerReplicationInfo);
	if (PRI != None)
	{
		if ( UTGameReplicationInfo(WorldInfo.GRI).bStoryMode )
		{
			if ( PRI.SinglePlayerCharacterIndex < 0 )
			{
				UTGameReplicationInfo(WorldInfo.GRI).AssignSinglePlayerCharacters(PRI);
			}
			return;
		}

		PRI.SetCharacterData(CharData);
	}

	// force bots on player's team to be same faction
	if ((WorldInfo.NetMode == NM_Standalone || WorldInfo.NetMode == NM_ListenServer) && IsLocalPlayerController())
	{
		Team = UTTeamInfo(PlayerReplicationInfo.Team);
		if (Team != None)
		{
			FamilyInfoClass = class'UTCustomChar_Data'.static.FindFamilyInfo(CharData.FamilyID);
			if(FamilyInfoClass != None)
			{
				Team.Faction = FamilyInfoClass.default.Faction;
			}
		}
	}
}

/** Clear the contents of the command to bind key cache */
simulated function ClearStringAliasBindingMapCache()
{
	BoundEventsStringDataStore.ClearBoundKeyCache();
}

/**
* Creates and initializes the "PlayerOwner" and "PlayerSettings" data stores.  This function assumes that the PlayerReplicationInfo
* for this player has not yet been created, and that the PlayerOwner data store's PlayerDataProvider will be set when the PRI is registered.
*
* Overloaded so we can initialize game specific player data stores.
*/
simulated function RegisterPlayerDataStores()
{
	local LocalPlayer LP;
	local DataStoreClient DataStoreManager;
	local class<UTUIDataStore_StringAliasBindingsMap> StringAliasBindingsMapDataStoreClass;


	local string PlayerName;

	PlayerName = PlayerReplicationInfo != None ? PlayerReplicationInfo.PlayerName : "None";


	Super.RegisterPlayerDataStores();

	// only create player data store for local players
	LP = LocalPlayer(Player);
	if ( LP != None )
	{
		LogInternal(">> UTPlayerController::RegisterPlayerDataStores -" @ Self @ "(" $ PlayerName $ ")",'DevDataStore');

		// get a reference to the main data store client
		DataStoreManager = class'UIInteraction'.static.GetDataStoreClient();
		if ( DataStoreManager != None )
		{
			// find the "PlayerOwner" data store registered for this player; there shouldn't be one...
			BoundEventsStringDataStore = UTUIDataStore_StringAliasBindingsMap(DataStoreManager.FindDataStore('StringAliasBindings',LP));
			if ( BoundEventsStringDataStore == None )
			{
				// find the appropriate class to use for the PlayerSettings data store
				StringAliasBindingsMapDataStoreClass = class<UTUIDataStore_StringAliasBindingsMap>(DataStoreManager.FindDataStoreClass(class'UTUIDataStore_StringAliasBindingsMap'));
				if ( StringAliasBindingsMapDataStoreClass != None )
				{
					// create the PlayerOwner data store
					BoundEventsStringDataStore = DataStoreManager.CreateDataStore(StringAliasBindingsMapDataStoreClass);
					if ( BoundEventsStringDataStore != None )
					{
						// and register it
						if ( DataStoreManager.RegisterDataStore(BoundEventsStringDataStore, LP) )
						{
							if ( PlayerReplicationInfo != None )
							{
								// if our PRI was created and initialized before we were assigned a Player, then our PlayerDataProvider wasn't
								// linked to the PlayerOwner data store since we didn't have a valid Player, so do that now.
								PlayerReplicationInfo.BindPlayerOwnerDataProvider();
							}
						}
						else
						{
							LogInternal("Failed to register 'StringAliasBindings' data store for player:"@ Self @ "(" $ PlayerName $ ")");
						}
					}
					else
					{
						LogInternal("Failed to create 'StringAliasBindings' data store for player:"@ Self @ "(" $ PlayerName $ ") using class" @ StringAliasBindingsMapDataStoreClass,'DevDataStore');
					}
				}
			}
			else
			{
				LogInternal("'StringAliasBindings' data store already registered for player:"@ Self @ "(" $ PlayerName $ ")",'DevDataStore');
			}
		}

		LogInternal("<< UTPlayerController::RegisterPlayerDataStores -" @ Self @ "(" $ PlayerName $ ")",'DevDataStore');
	}
}

/**
* Unregisters the "PlayerOwner" data store for this player.  Called when this PlayerController is destroyed.
*
* Overloaded so we can unregister game specific player data stores.
*/
simulated function UnregisterPlayerDataStores()
{
	local LocalPlayer LP;
	local DataStoreClient DataStoreManager;


	local string PlayerName;

	PlayerName = PlayerReplicationInfo != None ? PlayerReplicationInfo.PlayerName : "None";


	// only execute for local players
	LP = LocalPlayer(Player);
	if ( LP != None )
	{
		LogInternal(">> UTPlayerController::UnregisterPlayerDataStores -" @ Self @ "(" $ PlayerName $ ")",'DevDataStore');

		// unregister it from the data store client and clear our reference
		// get a reference to the main data store client
		DataStoreManager = class'UIInteraction'.static.GetDataStoreClient();
		if ( DataStoreManager != None )
		{
			// unregister the bound events string data store
			if ( BoundEventsStringDataStore != None )
			{
				if ( !DataStoreManager.UnregisterDataStore(BoundEventsStringDataStore) )
				{
					LogInternal("Failed to unregister 'StringAliasBindings' data store for player:"@ Self @ "(" $ PlayerName $ ")");
				}

				// clear the reference
				BoundEventsStringDataStore = None;
			}
			else
			{
				LogInternal("'StringAliasBindings' data store not registered for player:" @ Self @ "(" $ PlayerName $ ")",'DevDataStore');
			}
		}
		else
		{
			LogInternal("Data store client not found!",'DevDataStore');
		}

		LogInternal("<< UTPlayerController::UnregisterPlayerDataStores" @ "(" $ PlayerName $ ")",'DevDataStore');
	}

	Super.UnregisterPlayerDataStores();
}

/** Sets online delegates to respond to for this PC. */
function AddOnlineDelegates(bool bRegisterVoice)
{
	// this is done automatically in net games so only need to call it for standalone.
	if (bRegisterVoice && WorldInfo.NetMode == NM_Standalone && VoiceInterface != None)
	{
		VoiceInterface.RegisterLocalTalker(LocalPlayer(Player).ControllerId);
		VoiceInterface.AddRecognitionCompleteDelegate(LocalPlayer(Player).ControllerId, SpeechRecognitionComplete);
	}

	// Register a callback for when the profile finishes reading.
	if (OnlineSub != None)
	{
		if (OnlineSub.PlayerInterface != None)
		{
			OnlineSub.PlayerInterface.AddReadProfileSettingsCompleteDelegate(LocalPlayer(Player).ControllerId, OnReadProfileSettingsComplete);
			OnlineSub.PlayerInterface.AddFriendInviteReceivedDelegate(LocalPlayer(Player).ControllerId,OnFriendInviteReceived);
			OnlineSub.PlayerInterface.AddReceivedGameInviteDelegate(LocalPlayer(Player).ControllerId,OnGameInviteReceived);
			OnlineSub.PlayerInterface.AddFriendMessageReceivedDelegate(LocalPlayer(Player).ControllerId,OnFriendMessageReceived);
		}

		if(OnlineSub.SystemInterface != None)
		{
			OnlineSub.SystemInterface.AddConnectionStatusChangeDelegate(OnConnectionStatusChange);
			OnlineSub.SystemInterface.AddLinkStatusChangeDelegate(OnLinkStatusChanged);

			// Do an initial controller check
			if(OnlineSub.SystemInterface.IsControllerConnected(LocalPlayer(Player).ControllerId)==false)
			{
				OnControllerChanged(LocalPlayer(Player).ControllerId, false);
			}
		}
	}
}

/** Clears previously set online delegates. */
event ClearOnlineDelegates()
{
	local LocalPlayer LP;

	Super.ClearOnlineDelegates();

	LP = LocalPlayer(Player);
	if ( OnlineSub != None
	&&	(Role < ROLE_Authority || LP != None))
	{
		if (LP != None)
		{
			if (VoiceInterface != None)
			{
				VoiceInterface.ClearRecognitionCompleteDelegate(LP.ControllerId, SpeechRecognitionComplete);
				// Only unregister voice support if we aren't traveling to a MP game
				if (OnlineSub.GameInterface == None ||
					(OnlineSub.GameInterface != None && OnlineSub.GameInterface.GetGameSettings() == None))
				{
					VoiceInterface.UnregisterLocalTalker(LP.ControllerId);
				}
			}

			if (OnlineSub.PlayerInterface != None)
			{
				OnlineSub.PlayerInterface.ClearReadProfileSettingsCompleteDelegate(LP.ControllerId, OnReadProfileSettingsComplete);
				OnlineSub.PlayerInterface.ClearFriendInviteReceivedDelegate(LP.ControllerId,OnFriendInviteReceived);
				OnlineSub.PlayerInterface.ClearReceivedGameInviteDelegate(LP.ControllerId,OnGameInviteReceived);
				OnlineSub.PlayerInterface.ClearFriendMessageReceivedDelegate(LP.ControllerId,OnFriendMessageReceived);
			}
		}

		if(OnlineSub.SystemInterface != None)
		{
			OnlineSub.SystemInterface.ClearConnectionStatusChangeDelegate(OnConnectionStatusChange);
			OnlineSub.SystemInterface.ClearLinkStatusChangeDelegate(OnLinkStatusChanged);
		}
	}
}

/**
 * Looks at the current game state and uses that to set the
 * rich presence strings
 *
 * Licensees should override this in their player controller derived class
 */
reliable client function ClientSetOnlineStatus()
{
	local LocalPlayer LP;
	local array<LocalizedStringSetting> StringSettings;
	local array<SettingsProperty> Properties;
	local OnlineGameSettings GameSettings;
	local string MapName;
	local string GameName;

	LP = LocalPlayer(Player);

	// If we are not a client, then set the game settings object info also.
	if( OnlineSub.GameInterface != None &&
		WorldInfo.NetMode != NM_Client)
	{
		GameSettings=OnlineSub.GameInterface.GetGameSettings();
		if(GameSettings != None)
		{
			MapName = WorldInfo.GetMapName();
			GameName = WorldInfo.GetGameClass().default.Outer.name$"."$WorldInfo.GetGameClass().name;

			GameSettings.SetPropertyFromStringByName('CustomMapName', MapName);
			GameSettings.SetPropertyFromStringByName('CustomGameMode', GameName);
			GameSettings.SetStringSettingValue(CONTEXT_PURESERVER, UTGame(WorldInfo.Game).IsPureGame() ? CONTEXT_PURESERVER_YES : CONTEXT_PURESERVER_NO, false);

			if(GameSettings.bIsLanMatch==false && OnlineSub.GameInterface.UpdateOnlineGame(GameSettings)==false)
			{
				LogInternal("UTPlayerController::ClientSetOnlineStatus() - Error occured updating online game settings.");
			}
			else
			{
				LogInternal("UTPlayerController::ClientSetOnlineStatus() - Updated online game settings.");
			}
		}
	}
 
	//@todo: Hook this up properly.
	LogInternal("UTPlayerController::ClientSetOnlineStatus() - Setting online status for ControllerId: "$LP.ControllerId);
	OnlineSub.PlayerInterface.SetOnlineStatus(LP.ControllerId, 0, StringSettings, Properties);
}







/**
 * Called when a system level connection change notification occurs. If we are
 * playing a Live match, we may need to notify and go back to the menu. Otherwise
 * silently ignore this.
 *
 * @param ConnectionStatus the new connection status.
 */
exec function OnConnectionStatusChange(EOnlineServerConnectionStatus ConnectionStatus)
{
	local GameUISceneClient SceneClient;
	local OnlineGameSettings GameSettings;
	local bool bInvalidConnectionStatus;

	// We need to always bail in this case
	if (ConnectionStatus == OSCS_DuplicateLoginDetected)
	{
		// Two people can't play or badness will happen
		LogInternal("Detected another user logging-in with this profile.");
		SetFrontEndErrorMessage("<Strings:UTGameUI.Errors.DuplicateLogin_Title>",
			"<Strings:UTGameUI.Errors.DuplicateLogin_Message>");

		bInvalidConnectionStatus = true;
	}
	else
	{
		// Only care about this if we aren't in a standalone netmode.
		if(WorldInfo.NetMode != NM_Standalone)
		{
			// We know we have an online subsystem or this delegate wouldn't be called
			GameSettings = OnlineSub.GameInterface.GetGameSettings();
			if (GameSettings != None)
			{
				// If we are a internet match, this really matters
				if (!GameSettings.bIsLanMatch)
				{
		// We are playing a internet match. Determine whether the connection
		// status change requires us to drop and go to the menu
		switch (ConnectionStatus)
		{
		case OSCS_ConnectionDropped:
		case OSCS_NoNetworkConnection:
		case OSCS_ServiceUnavailable:
		case OSCS_UpdateRequired:
		case OSCS_ServersTooBusy:
		case OSCS_NotConnected:
			SetFrontEndErrorMessage("<Strings:UTGameUI.Errors.ConnectionLost_Title>",
				"<Strings:UTGameUI.Errors.ConnectionLost_Message>");
						bInvalidConnectionStatus = true;
			break;
		}
	}
			}
		}
	}

	// notify the UI scene client, which will propagate the notification to all scenes.  Any scenes
	// which require a valid online service will close themselves.
	SceneClient = class'UIRoot'.static.GetSceneClient();
	if ( SceneClient != None )
	{
		SceneClient.NotifyOnlineServiceStatusChanged(ConnectionStatus);
	}

	LogInternal(Name$"::"$GetFuncName()@"ConnectionStatus:'"$GetEnum(Enum'EOnlineServerConnectionStatus',ConnectionStatus)$"'"@"bInvalidConnectionStatus:'"$bInvalidConnectionStatus$"'",'DevOnline');
	if ( bInvalidConnectionStatus )
	{
		QuitToMainMenu();
	}
}

/**
 * Called when the platform's network link status changes.  If we are playing a match on a remote server, we need to go back
 * to the front end menus and notify the player.
 */
exec function OnLinkStatusChanged( bool bConnected )
{
	local GameUISceneClient SceneClient;
	local string ErrorDisplay;

	LogInternal(Name$"::"$GetFuncName()@"bConnected:'"$bConnected$"'",'DevNet');

	// notify the UI scene client, which will propagate the notification to all scenes.  Any scenes
	// which require a valid network connection will close themselves.
	SceneClient = class'UIRoot'.static.GetSceneClient();
	if ( SceneClient != None )
	{
		SceneClient.NotifyLinkStatusChanged(bConnected);
	}

	if ( !bConnected && WorldInfo != None && WorldInfo.Game != None)
	{
		// Don't quit to main menu if we are playing instant action
		if (WorldInfo.NetMode != NM_Standalone)
		{
			// if we're no longer connected to the network, check to see if another error message has been set
			// only display our message if none are currently set.
			if (!class'UIRoot'.static.GetDataStoreStringValue("<Registry:FrontEndError_Display>", ErrorDisplay)
			||	int(ErrorDisplay) == 0 )
			{
				SetFrontEndErrorMessage("<Strings:UTGameUI.Errors.Error_Title>", "<Strings:UTGameUI.Errors.NetworkLinkLost_Message>");
				QuitToMainMenu();
			}
		}
	}
}

/** @return Returns whether or not we're in a epic internal build. */
native function bool IsEpicInternal();

/** Resets the profile to its default state. */
native function ResetProfileToDefault(OnlineProfileSettings Profile);

/** Callback for when the profile finishes reading for this PC. */
function OnReadProfileSettingsComplete(bool bWasSuccessful)
{

	local int ControllerId;

	if (LocalPlayer(Player) != None)
	{
		ControllerId = LocalPlayer(Player).ControllerId;
		LogInternal("UTPlayerController::OnReadProfileSettingsComplete() - bWasSuccessful: " $ bWasSuccessful $ ", ControllerId: " $ ControllerId);
	}


	if (bWasSuccessful)
	{
		bRetrieveSettingsFromProfileOnNextTick=TRUE;
	}
}

/** Callback for when a game invite has been received. */
function OnGameInviteReceived(byte LocalUserNum,string RequestingNick)
{
	local string FinalMsg;

	if(Len(RequestingNick) > 0)
	{
		FinalMsg = Repl(Localize("ToastMessages","ReceivedGameInviteSpecific","UTGameUI"), "`PlayerName`",RequestingNick, true);

		// Display toast
		class'UTUIScene'.static.ShowOnlineToast(FinalMsg);
	}
}

/** Callback for when a friend request has been received. */
function OnFriendInviteReceived(byte LocalUserNum,UniqueNetId RequestingPlayer,string RequestingNick,string Message)
{
	local string FinalMsg;

	if(Len(RequestingNick) > 0)
	{
		FinalMsg = Repl(Localize("ToastMessages","ReceivedFriendInviteSpecific","UTGameUI"), "`PlayerName`",RequestingNick, true);
	}
	else
	{
		FinalMsg = Localize("ToastMessages","ReceivedFriendInvite","UTGameUI");
	}

	// Display toast
	class'UTUIScene'.static.ShowOnlineToast(FinalMsg);
}

/**
 * Called when a friend invite arrives for a local player
 *
 * @param LocalUserNum the user that is receiving the invite
 * @param SendingPlayer the player sending the friend request
 * @param SendingNick the nick of the player sending the friend request
 * @param Message the message to display to the recipient
 *
 * @return true if successful, false otherwise
 */
function OnFriendMessageReceived(byte LocalUserNum,UniqueNetId SendingPlayer,string SendingNick,string Message)
{
	local string FinalMsg;

	if(Len(SendingNick) > 0)
	{
		FinalMsg = Repl(Localize("ToastMessages","ReceivedMessageSpecific","UTGameUI"), "`PlayerName`",SendingNick, true);
	}
	else
	{
		FinalMsg = Localize("ToastMessages","ReceivedMessage","UTGameUI");
	}

	// Display toast
	class'UTUIScene'.static.ShowOnlineToast(FinalMsg);
}

/** Override to display a message to the user */
function NotifyInviteFailed()
{
	Super.NotifyInviteFailed();
	SetFrontEndErrorMessage("<Strings:UTGameUI.Errors.UnableToJoinInvite_Title>",
		"<Strings:UTGameUI.Errors.UnableToJoinInvite_Message>");
	QuitToMainMenu();
}

/** Override to display a message to the user */
function NotifyNotAllPlayersCanJoinInvite()
{
	Super.NotifyNotAllPlayersCanJoinInvite();
	SetFrontEndErrorMessage("<Strings:UTGameUI.Errors.NotAllPlayersCanJoin_Title>",
		"<Strings:UTGameUI.Errors.NotAllPlayersCanJoin_Message>");
	QuitToMainMenu();
}

/** Override to display a message to the user */
function NotifyNotEnoughSpaceInInvite()
{
	Super.NotifyNotEnoughSpaceInInvite();
	SetFrontEndErrorMessage("<Strings:UTGameUI.Errors.NotEnoughInviteSpace_Title>",
		"<Strings:UTGameUI.Errors.NotEnoughInviteSpace_Message>");
	QuitToMainMenu();
}

/**
* Once the join completes, use the platform specific connection information
* to connect to it
*
* @param bWasSuccessful whether the join worked or not
*/
function OnInviteJoinComplete(bool bWasSuccessful)
{
	local string URL, ConnectPassword;
	local UniqueNetId ZeroNetId;

	if (bWasSuccessful)
	{
		if (OnlineSub != None && OnlineSub.GameInterface != None)
		{
			// Get the platform specific information
			if (OnlineSub.GameInterface.GetResolvedConnectString(URL))
			{
				// if a password was set in the registry (this would normally be done by the UI scene that handles accepting
				// the game invite or join friend request), append it to the URL
				if ( class'UIRoot'.static.GetDataStoreStringValue("<Registry:ConnectPassword>", ConnectPassword) && ConnectPassword != "" )
				{
					// we append "Password=" because that's what AccessControl checks for (see AccessControl.PreLogin)
					URL $= "?Password=" $ ConnectPassword;
				}

				if (PlayerReplicationInfo.FriendFollowedId != ZeroNetId)
				{
					// we append "Friend=" to check it later when we get into the game
					URL $= "?Friend=" $ class'OnlineSubsystem'.static.UniqueNetIdToString(PlayerReplicationInfo.FriendFollowedId);
				}

				LogInternal("Resulting url is ("$URL$")");

				// Open a network connection to it
				ConsoleCommand("open "$URL);
			}
		}
	}
	else
	{
		// Do some error handling
		NotifyInviteFailed();
	}
	ClearInviteDelegates();
	class'UIRoot'.static.SetDataStoreStringValue("<Registry:ConnectPassword>", "");
}


/**
 * Callback for when a character has been unlocked.
 */
event OnCharacterUnlocked()
{
	local string FinalMsg;

	FinalMsg = Localize("ToastMessages","CharacterUnlocked","UTGameUI");
	class'UTUIScene'.static.ShowOnlineToast(FinalMsg);

	SaveProfile();
}

/**
 * @return	a reference to the progress message scene, if it's already open.
 */
function UTUIScene_ConnectionStatus FindProgressMessageScene()
{
	local UTUIScene_ConnectionStatus ProgressScene;
	local GameUISceneClient SceneClient;

	SceneClient = class'UIInteraction'.static.GetSceneClient();
	if ( SceneClient != None )
	{
		ProgressScene = UTUIScene_ConnectionStatus(SceneClient.FindSceneByTag('ProgressMessageScene', LocalPlayer(Player)));
	}

	return ProgressScene;
}

/**
 * Opens the scene which is used to display connection/download progress & error messages.  If the scene is already open, will
 * return a reference to the existing scene rather than creating another one.
 *
 * @return	a reference to an instance of UTUIScene_ConnectionStatus which is fully initialized and ready to be used.
 */
function UTUIScene_ConnectionStatus OpenProgressMessageScene()
{
	local class<UTUIScene_ConnectionStatus> SceneClass;
	local UIScene InstancedScene;
	local UTUIScene_ConnectionStatus ProgressMessageScene;
	local GameUISceneClient SceneClient;

	// make sure we have a valid scene class name
	if ( ProgressMessageSceneClassName == "" )
	{
		ProgressMessageSceneClassName = "UTGame.UTUIScene_ConnectionStatus";
	}

	// load the scene class
	SceneClass = class<UTUIScene_ConnectionStatus>(DynamicLoadObject( ProgressMessageSceneClassName, class'Class' ));
	if ( SceneClass != None )
	{
		SceneClient = class'UIInteraction'.static.GetSceneClient();
		if ( SceneClient != None )
		{
			ProgressMessageScene = FindProgressMessageScene();
			if ( ProgressMessageScene == None )
			{
				ProgressMessageScene = SceneClient.CreateScene(SceneClass, 'ProgressMessageScene', CommandMenuTemplate.default.MessageBoxScene);
			}

			if ( ProgressMessageScene != None
			&&	!SceneClient.IsSceneInitialized(ProgressMessageScene) )
			{
				SceneClient.OpenScene(ProgressMessageScene, LocalPlayer(Player), InstancedScene);
				ProgressMessageScene = UTUIScene_ConnectionStatus(InstancedScene);
			}
		}
	}
	else
	{
		WarnInternal(Name$"::"$GetFuncName()@"Failed to load the configured scene class:" @ "ProgressMessageSceneClassName:'"$ProgressMessageSceneClassName$"'");
	}

	return ProgressMessageScene;
}

/**
 * Manually closes the progress message scene, if open.  Normally the progress message scene would be closed when the user
 * clicks one of its buttons.
 *
 * @param	bSimulateCancel		if TRUE, will set the message box's selection to the index of the Cancel button; otherwise,
 *								just closes the scene without touching the selection value.
 */
function ForceCloseProgressMessageScene( optional bool bSimulateCancel=true )
{
	local UTUIScene_ConnectionStatus ProgressMessageScene;
	local LocalPlayer LP;
	local int PlayerIndex;

	ProgressMessageScene = FindProgressMessageScene();
	if ( ProgressMessageScene != None )
	{
		// determine the player index that should be used for closing the scene
		PlayerIndex = INDEX_NONE;
		LP = ProgressMessageScene.GetPlayerOwner();
		if ( LP != None )
		{
			PlayerIndex = LP.GamePlayers.Find(LP);
		}

		if ( PlayerIndex == INDEX_NONE )
		{
			PlayerIndex = ProgressMessageScene.GetBestPlayerIndex();
		}

		ProgressMessageScene.Close(bSimulateCancel, PlayerIndex);
	}
}

/**
 * Sets or updates the any current progress message being displayed.
 *
 * @param	MessageType	the type of progress message
 * @param	Message		the message to display
 * @param	Title		the title to use for the progress message.
 */
reliable client function ClientSetProgressMessage( EProgressMessageType MessageType, string Message, optional string Title )
{
	local UTUIScene_ConnectionStatus ProgressMessageScene;

	switch ( MessageType )
	{
	case PMT_DownloadProgress:
		// if we are already connected to a server use console messages instead of the UI scene
		if (WorldInfo.NetMode == NM_Client)
		{
			if (WorldInfo.TimeSeconds - LastConsoleDownloadMessageTime > 3.0)
		{
				ClientMessage(Title $ ":" @ Message);
				LastConsoleDownloadMessageTime = WorldInfo.TimeSeconds;
			}
			break;
		}
		// intentional fall through
	case PMT_Information:
		ProgressMessageScene = OpenProgressMessageScene();
		if ( ProgressMessageScene != None )
		{
				ProgressMessageScene.DisplayCancelBox(Message, Title, CancelPendingConnection);
				ProgressMessageScene.ForceImmediateSceneUpdate();
			}
		break;

	case PMT_RedrawDownloadProgress:
		ProgressMessageScene = FindProgressMessageScene();
		if ( ProgressMessageScene != None )
		{
			ProgressMessageScene.ForceImmediateSceneUpdate();
		}
		break;

	case PMT_ConnectionFailure:
		NotifyConnectionError(Message, Title);
		break;

	case PMT_Clear:
		Super.ClientSetProgressMessage( MessageType, Message, Title );

		// close the progress message scene, if open
		ForceCloseProgressMessageScene();
		break;

	default:
		Super.ClientSetProgressMessage( MessageType, Message, Title );
		break;
	}
}

reliable client function ClientWasKicked()
{
	ClientSetProgressMessage(PMT_ConnectionFailure, Localize("AccessControl", "KickedMsg", "Engine"));
}

/**
 * Handler for the ProgressMessageScene's OnSelection delegate.  Kills any existing online game sessions.
 */
function CancelPendingConnection(UTUIScene_MessageBox MessageBox, int SelectedOption, int PlayerIndex)
{
	if ( OnlineSub != None && OnlineSub.GameInterface != None )
	{
		// Set the destroy delegate so we can know when that is complete
		OnlineSub.GameInterface.AddDestroyOnlineGameCompleteDelegate(OnDestroyOnlineGameComplete);
		
		// Now we can destroy the game
		LogInternal("UTPlayerController::CancelPendingConnection() - Destroying Online Game, ControllerId: " $ LocalPlayer(Player).ControllerId);
		// kill the pending connection
		if ( !OnlineSub.GameInterface.DestroyOnlineGame() )
		{
			OnDestroyOnlineGameComplete(true);
		}
	}
}

/**
 * Sets a error message in the registry datastore that will display to the user the next time they are in the frontend.
 *
 * @param Title		Title of the messagebox.
 * @param Message	Message of the messagebox.
 */
function SetFrontEndErrorMessage(string Title, string Message)
{
	class'UIRoot'.static.SetDataStoreStringValue("<Registry:FrontEndError_Title>", Title);
	class'UIRoot'.static.SetDataStoreStringValue("<Registry:FrontEndError_Message>", Message);
	class'UIRoot'.static.SetDataStoreStringValue("<Registry:FrontEndError_Display>", "1");
}

/**
 * Saves information to the registry about the last travel attempt, to allow the frontend to attempt a reconnect if necessary
 */
function SetFrontEndTravelRetryInfo(string URL, string ErrorCode)
{
	class'UIRoot'.static.SetDataStoreStringValue("<Registry:FrontEndError_LastURL>", URL);
	class'UIRoot'.static.SetDataStoreStringValue("<Registry:FrontEndError_LastErrorCode>", ErrorCode);
}

/**
 * Notifies the player that an attempt to connect to a remote server failed, or an existing connection was dropped.
 *
 * @param	Message		a description of why the connection was lost
 * @param	Title		the title to use in the connection failure message.
 */
function NotifyConnectionError( string Message, optional string Title )
{
	local UTGameReplicationInfo GRI;


	GRI = UTGameReplicationInfo(WorldInfo.GRI);
	if ( GRI != none && GRI.CurrentMidGameMenu != none )
	{
		GRI.CurrentMidGameMenu.CloseScene(GRI.CurrentMidGameMenu);
	}

	LogInternal("NOTIFYCONNECTIONERROR"@Name$"::"$GetFuncName()@"Message:'"$Message$"'"@"Title:'"$Title$"'");

	if ( WorldInfo.Game != None )
	{
		// Mark the server as having a problem
		WorldInfo.Game.bHasNetworkError = true;
	}

	SetFrontEndErrorMessage(Title, Message);
	SetFrontEndTravelRetryInfo(WorldInfo.LastTravelErrorURL, WorldInfo.LastTravelErrorCode);

	// Start quitting to the main menu
	QuitToMainMenu();
}

/** Called when returning to the main menu. */
function QuitToMainMenu()
{
	bQuittingToMainMenu = true;

	LogInternal("UTPlayerController::QuitToMainMenu() - Cleaning Up OnlineSubsystem, ControllerId: " $ LocalPlayer(Player).ControllerId);
	if(CleanupOnlineSubsystemSession(true)==false)
	{
		LogInternal("UTPlayerController::QuitToMainMenu() - Online cleanup failed, finishing quit.");
		FinishQuitToMainMenu();
	}
}

/** Called after onlinesubsystem game cleanup has completed. */
function FinishQuitToMainMenu()
{
	local string WasShowingBrowser;

	// stop any movies currently playing before we quit out
	class'Engine'.static.StopMovie();

	// If the player was viewing the server browser before joining, tell the main menu it should return to the browser
	if (Class'UIRoot'.static.GetDataStoreStringValue("<Registry:WasShowingBrowser>", WasShowingBrowser) && WasShowingBrowser == "1")
		Class'UIRoot'.static.SetDataStoreStringValue("<Registry:ReturnToBrowser>", "1");

	// Call disconnect to force us back to the menu level
	ConsoleCommand("NativeDisconnect");

	LogInternal("------ QUIT TO MAIN MENU --------");
}

/** Cleans up online subsystem game sessions and posts stats if the match is arbitrated. */
function bool CleanupOnlineSubsystemSession(bool bWasFromMenu)
{
	//local int Item;

	if (WorldInfo.NetMode != NM_Standalone &&
		OnlineSub != None &&
		OnlineSub.GameInterface != None &&
		OnlineSub.GameInterface.GetGameSettings() != None)
	{
		LogInternal("UTPlayerController::CleanupOnlineSubsystemSession() - Ending Online Game, ControllerId: " $ LocalPlayer(Player).ControllerId);

		// Set the end delegate so we can know when that is complete and call destroy
		OnlineSub.GameInterface.AddEndOnlineGameCompleteDelegate(OnEndOnlineGameComplete);
		OnlineSub.GameInterface.EndOnlineGame();

		return true;
	}

	return false;
}

/**
 * Called when the online game has finished ending.
 */
function OnEndOnlineGameComplete(bool bWasSuccessful)
{
	OnlineSub.GameInterface.ClearEndOnlineGameCompleteDelegate(OnEndOnlineGameComplete);

	if(bQuittingToMainMenu)
	{
		// Set the destroy delegate so we can know when that is complete
		OnlineSub.GameInterface.AddDestroyOnlineGameCompleteDelegate(OnDestroyOnlineGameComplete);
		// Now we can destroy the game
		LogInternal("UTPlayerController::OnEndOnlineGameComplete() - Destroying Online Game, ControllerId: " $ LocalPlayer(Player).ControllerId);
		if ( !OnlineSub.GameInterface.DestroyOnlineGame() )
		{
			OnDestroyOnlineGameComplete(true);
		}
	}
}

/**
 * Called when the destroy online game has completed. At this point it is safe
 * to travel back to the menus
 *
 * @param bWasSuccessful whether it worked ok or not
 */
function OnDestroyOnlineGameComplete(bool bWasSuccessful)
{
	LogInternal("UTPlayerController::OnDestroyOnlineGameComplete() - Finishing Quit to Main Menu, ControllerId: " $ LocalPlayer(Player).ControllerId);
	OnlineSub.GameInterface.ClearDestroyOnlineGameCompleteDelegate(OnDestroyOnlineGameComplete);
	//Clear out the gamesettings cache
	if (WorldInfo.Game != None)
	{
		WorldInfo.Game.GameSettings = None;
	}

	FinishQuitToMainMenu();
}

reliable client function ClientSetSpeechRecognitionObject(SpeechRecognition NewRecognitionData)
{
	if (VoiceInterface != None)
	{
		VoiceInterface.SetSpeechRecognitionObject(LocalPlayer(Player).ControllerId, NewRecognitionData);
	}
}

/** set to VoiceInterface's speech recognition delegate; called when words are recognized */
function SpeechRecognitionComplete()
{
	local array<SpeechRecognizedWord> Words;
	local SpeechRecognizedWord ReplicatedWords[3];
	local int i;
//	local String DebugStr;

	VoiceInterface.GetRecognitionResults(LocalPlayer(Player).ControllerId, Words);

	if (Words.length > 0)
	{
		for (i = 0; i < 3 && i < Words.length; i++)
		{
			ReplicatedWords[i] = Words[i];
//			DebugStr = DebugStr @ Words[i].WordText;
//			`log(WorldInfo.TimeSeconds@"recognized word"@Words[i].WordText);
		}

//		TeamMessage(PlayerReplicationInfo, DebugStr, 'Say', 8.f);

		ServerProcessSpeechRecognition(ReplicatedWords);
	}
}

reliable server function ServerProcessSpeechRecognition(SpeechRecognizedWord ReplicatedWords[3])
{
	local array<SpeechRecognizedWord> Words;
	local int i;
	local UTGame Game;

	Game = UTGame(WorldInfo.Game);
	if (Game != None)
	{
		for (i = 0; i < 3; i++)
		{
			if (ReplicatedWords[i].WordText != "")
			{
				Words[Words.length] = ReplicatedWords[i];
			}
		}

		Game.ProcessSpeechRecognition(self, Words);
	}
}

/** turns on/off voice chat/recognition */
exec function ToggleSpeaking(bool bNowOn)
{
	local LocalPlayer LP;

	if (VoiceInterface != None)
	{
		LP = LocalPlayer(Player);
		if (LP != None)
		{
			if (bNowOn)
			{
				VoiceInterface.StartNetworkedVoice(LP.ControllerId);
					bIsTyping = true;
				if ( WorldInfo.NetMode != NM_Client )
				{
					VoiceInterface.StartSpeechRecognition(LP.ControllerId);
				}
			}
			else
			{
				VoiceInterface.StopNetworkedVoice(LP.ControllerId);
				bIsTyping = false;
				if ( WorldInfo.NetMode != NM_Client )
	{
					VoiceInterface.StopSpeechRecognition(LP.ControllerId);
		}
	}
}
	}
}

/* ClientHearSound()
Replicated function from server for replicating audible sounds played on server
UTPlayerController implementation considers sounds from its pawn as local, even if the pawn is not the viewtarget
*/
unreliable client event ClientHearSound(SoundCue ASound, Actor SourceActor, vector SourceLocation, bool bStopWhenOwnerDestroyed, optional bool bIsOccluded, optional bool bIsUISound )
{
	local AudioComponent AC;

	if ( SourceActor == None )
	{
		AC = GetPooledAudioComponent(ASound, SourceActor, bStopWhenOwnerDestroyed, true, SourceLocation);
		if (AC == None)
		{
			return;
		}
		AC.bUseOwnerLocation = false;
		AC.Location = SourceLocation;
	}
	else if ( (SourceActor == GetViewTarget()) || (SourceActor == self) || (SourceActor == Pawn) )
	{
		AC = GetPooledAudioComponent(ASound, None, bStopWhenOwnerDestroyed);
		if (AC == None)
		{
			return;
		}
		AC.bAllowSpatialization = false;
	}
	else
	{
		AC = GetPooledAudioComponent(ASound, SourceActor, bStopWhenOwnerDestroyed);
		if (AC == None)
		{
			return;
		}
		if (!IsZero(SourceLocation) && SourceLocation != SourceActor.Location)
		{
			AC.bUseOwnerLocation = false;
			AC.Location = SourceLocation;
		}
	}
	if ( bIsOccluded )
	{
		// if occluded reduce volume: @FIXME do something better
		AC.VolumeMultiplier *= 0.5;
		// AC.LowPassFilterApplied = true;
	}

	// force UI sound if passed in as such
	AC.bIsUISound = AC.bIsUISound || bIsUISound;

	AC.Play();
}

function bool AimingHelp(bool bInstantHit)
{
	return bAimingHelp && ((WorldInfo.NetMode == NM_Standalone) || UTGameReplicationInfo(WorldInfo.GRI).bStoryMode) && (WorldInfo.Game.GameDifficulty < 4);
}

/**
* @returns the a scaling factor for the distance from the collision box of the target to accept aiming help (for instant hit shots)
*/
function float AimHelpModifier()
{
	local float AimingHelp;

	AimingHelp = FOVAngle < DefaultFOV - 8 ? 0.5 : 0.75;

	// reduce aiming help at higher difficulty levels
	if ( WorldInfo.Game.GameDifficulty > 2 )
		AimingHelp *= 0.33 * (5 - WorldInfo.Game.GameDifficulty);

	return AimingHelp;
}

/**
 * Adjusts weapon aiming direction.
 * Gives controller a chance to modify the aiming of the pawn. For example aim error, auto aiming, adhesion, AI help...
 * Requested by weapon prior to firing.
 * UTPlayerController implementation doesn't adjust aim, but sets the shottarget (for warning enemies)
 *
 * @param	W, weapon about to fire
 * @param	StartFireLoc, world location of weapon fire start trace, or projectile spawn loc.
 * @param	BaseAimRot, original aiming rotation without any modifications.
 */
function Rotator GetAdjustedAimFor( Weapon W, vector StartFireLoc )
{
	local vector	FireDir, HitLocation, HitNormal;
	local actor		BestTarget, HitActor;
	local float		bestAim, bestDist, MaxRange;
	local rotator	BaseAimRot;

	BaseAimRot = (Pawn != None) ? Pawn.GetBaseAimRotation() : Rotation;
	FireDir	= vector(BaseAimRot);
	MaxRange = W.MaxRange();
	HitActor = Trace(HitLocation, HitNormal, StartFireLoc + MaxRange * FireDir, StartFireLoc, true);

	if ( (HitActor != None) && HitActor.bProjTarget )
	{
		BestTarget = HitActor;
	}
	else if ( ((WorldInfo.Game != None) &&(WorldInfo.Game.Numbots > 0)) || AimingHelp(true) )
	{
		// guess who target is
		// @todo FIXMESTEVE
		bestAim = 0.95;
		BestTarget = PickTarget(class'Pawn', bestAim, bestDist, FireDir, StartFireLoc, MaxRange);
		if (W != None && W.GetProjectileClass() == None)
		{
			InstantWarnTarget(BestTarget, W, vector(BaseAimRot));
		}
	}

	ShotTarget = Pawn(BestTarget);
   	return BaseAimRot;
}


/** Tries to find a vehicle to drive within a limited radius. Returns true if successful */
function bool FindVehicleToDrive()
{
	if ( (UTPawn(Pawn) != None) && UTPawn(Pawn).IsHero() )
	{
		return false;
	}
	return ( CheckVehicleToDrive(true) != None );
}

/** returns the Vehicle passed in if it can be driven
  */
function UTVehicle CheckPickedVehicle(UTVehicle V, bool bEnterVehicle)
{
	local UTPlayerReplicationInfo PRI;

	if ( (V == None) || !bEnterVehicle )
	{
		return V;
	}
	// check if I would drop my flag
	PRI = UTPlayerReplicationInfo(PlayerReplicationInfo);
	if ( PRI.bHasFlag && !V.bCanCarryFlag && (!V.bTeamLocked || WorldInfo.GRI.OnSameTeam(self,V)) )
	{
		if ( V.bRequestedEntryWithFlag )
		{
			V.bRequestedEntryWithFlag = false;
			ClientSetRequestedEntryWithFlag(V, false, 0);
		}
		else
		{
			V.bRequestedEntryWithFlag = true;
			ClientSetRequestedEntryWithFlag(V, true, (UTOnslaughtFlag(PRI.GetFlag()) == None) ? 0 : 1);
			bJustFoundVehicle = true;
			return None;
		}
	}
	if ( V.TryToDrive(Pawn) )
	{
		return V;
	}
	bJustFoundVehicle = true;
	return None;
}

/** sets bRequestedEntryWithFlag on the given vehicle to update the HUD */
reliable client function ClientSetRequestedEntryWithFlag(UTVehicle V, bool bNewValue, int MessageIndex)
{
	if ( bNewValue )
	{
		ReceiveLocalizedMessage(class'UTVehicleCantCarryFlagMessage', MessageIndex);
	}
	if (V != None)
	{
		V.bRequestedEntryWithFlag = bNewValue;
	}
}

/** Returns vehicle which can be driven
  * @PARAM bEnterVehicle if true then player enters the found vehicle
  */
function UTVehicle CheckVehicleToDrive(bool bEnterVehicle)
{
	local UTVehicle V, PickedVehicle;
	local vector ViewDir, HitLocation, HitNormal, ViewPoint;
	local rotator ViewRotation;
	local Actor HitActor;
	local float CheckDist;

	bJustFoundVehicle = false;

	// first try to get in vehicle I'm standing on
	PickedVehicle = CheckPickedVehicle(UTVehicle(Pawn.Base), bEnterVehicle);
	if ( (PickedVehicle != None) || bJustFoundVehicle )
	{
		return PickedVehicle;
	}

	// see if looking at vehicle
	ViewPoint = Pawn.GetPawnViewLocation();
	ViewRotation = Rotation;
	CheckDist = Pawn.VehicleCheckRadius * VehicleCheckRadiusScaling;
	ViewDir = CheckDist * vector(ViewRotation);
	HitActor = Trace(HitLocation, HitNormal, ViewPoint + ViewDir, ViewPoint, true,,,TRACEFLAG_Blocking);

	PickedVehicle = CheckPickedVehicle(UTVehicle(HitActor), bEnterVehicle);
	if ( (PickedVehicle != None) || bJustFoundVehicle )
	{
		return PickedVehicle;
	}

	// make sure not just looking above vehicle
	ViewRotation.Pitch = 0;
	ViewDir = CheckDist * vector(ViewRotation);
	HitActor = Trace(HitLocation, HitNormal, ViewPoint + ViewDir, ViewPoint, true,,,TRACEFLAG_Blocking);

	PickedVehicle = CheckPickedVehicle(UTVehicle(HitActor), bEnterVehicle);
	if ( (PickedVehicle != None) || bJustFoundVehicle )
	{
		return PickedVehicle;
	}

	// make sure not just looking above vehicle
	ViewRotation.Pitch = -5000;
	ViewDir = CheckDist * vector(ViewRotation);
	HitActor = Trace(HitLocation, HitNormal, ViewPoint + ViewDir, ViewPoint, true,,,TRACEFLAG_Blocking);

	PickedVehicle = CheckPickedVehicle(UTVehicle(HitActor), bEnterVehicle);
	if ( (PickedVehicle != None) || bJustFoundVehicle )
	{
		return PickedVehicle;
	}

	// special case for vehicles like Darkwalker
	if ( UTGame(WorldInfo.Game) != None )
	{
		for ( V=UTGame(WorldInfo.Game).VehicleList; V!=None; V=V.NextVehicle )
		{
			if ( V.bHasCustomEntryRadius && V.InCustomEntryRadius(Pawn) )
			{
				V = CheckPickedVehicle(V, bEnterVehicle);
				if ( (V != None) || bJustFoundVehicle )
				{
					return V;
				}
			}
		}
	}

	return None;
}

exec function ToggleMinimap()
{
	local UTPlayerReplicationInfo PRI;

	// Don't toggle the minimap if the hero meter is full
	PRI = UTPlayerReplicationInfo(PlayerReplicationInfo);
	if ( PRI != None && PRI.GetHeroMeter() < PRI.HeroThreshold )
	{
		bRotateMiniMap = !bRotateMiniMap;
	}

	if ( (Pawn != None) && Pawn.IsA('UTHeroPawn') )
	{
		TriggerHero();
	}
}

exec function DropFlag()
{
	ServerDropFlag();
}

reliable server function ServerDropFlag()
{
	if ( UTPawn(Pawn) != None )
	{
		UTPawn(Pawn).DropFlag();
	}
}

/** LandingShake()
returns true if controller wants landing view shake
*/
simulated function bool LandingShake()
{
	return bLandingShake;
}

simulated function PlayBeepSound()
{
	PlaySound(SoundCue'A_Gameplay.Gameplay.MessageBeepCue', true);
}

/* epic ===============================================
* ::ReceiveWarning
*
* Notification that the pawn is about to be shot by a
* trace hit weapon.
*
* =====================================================
*/
event ReceiveWarning(Pawn shooter, float projSpeed, vector FireDir)
{
	if ( WorldInfo.TimeSeconds - LastWarningTime < 1.0 )
		return;
	LastWarningTime = WorldInfo.TimeSeconds;
	if ( (shooter != None) && !WorldInfo.GRI.OnSameTeam(shooter,self) )
		ClientMusicEvent(0);
}

/* epic ===============================================
* ::ReceiveProjectileWarning
*
* Notification that the pawn is about to be shot by a
* projectile.
*
* =====================================================
*/
function ReceiveProjectileWarning(Projectile proj)
{
	if ( WorldInfo.TimeSeconds - LastWarningTime < 1.0 )
		return;
	LastWarningTime = WorldInfo.TimeSeconds;
	if ( (proj.Instigator != None) && !WorldInfo.GRI.OnSameTeam(proj.Instigator,self) && (proj.Speed > 0) )
	{
		SetTimer(VSize(proj.Location - Pawn.Location)/proj.Speed,false,'ProjectileWarningTimer');
	}
}

function ProjectileWarningTimer()
{
	ClientMusicEvent(0);
}

function PlayWinMessage(bool bWinner)
{
/* //@todo FIXMESTEVE
	if ( bWinner )
		bDisplayWinner = true;
	else
		bDisplayLoser = true;
*/
}

simulated function bool TriggerInteracted()
{
	local UTGameObjective O, Best;
	local vector ViewDir, PawnLoc2D, VLoc2D;
	local float NewDot, BestDot;

	// check base UTGameObjective first
	if ((UTGameObjective(Pawn.Base) != None || UTOnslaughtNodeTeleporter(Pawn.Base) != None) && Pawn.Base.UsedBy(Pawn))
	{
		return true;
	}

	// handle touched UTGameObjectives next
	ForEach Pawn.TouchingActors(class'UTGameObjective', O)
	{
		if ( O.UsedBy(Pawn) )
			return true;
	}

	// now handle nearby UTGameObjectives
	ViewDir = vector(Rotation);
	PawnLoc2D = Pawn.Location;
	PawnLoc2D.Z = 0;
	ForEach Pawn.OverlappingActors(class'UTGameObjective', O, Pawn.VehicleCheckRadius)
	{
		if ( O.bAllowRemoteUse )
		{
			// Pawn must be facing objective or overlapping it
			VLoc2D = O.Location;
			Vloc2D.Z = 0;
			NewDot = Normal(VLoc2D-PawnLoc2D) Dot ViewDir;
			if ( NewDot > BestDot )
			{
				// check that objective is visible
				if ( FastTrace(O.Location,Pawn.Location) )
				{
					Best = O;
					BestDot = NewDot;
				}
			}
		}
	}
	if ( Best != None && Best.UsedBy(Pawn) )
		return true;

	// no UT specific triggers used, fall back to general case
	return super.TriggerInteracted();
}

/** Fastforward control for demo playback */
exec function DemoFF()
{
	if ( WorldInfo.bWithinDemoPlayback )
		WorldInfo.DemoPlayTimeDilation = (WorldInfo.DemoPlayTimeDilation < 10) ?  WorldInfo.DemoPlayTimeDilation * 3.3 : 1.0;
}

/** Slomo used in demo playback */
exec function DemoSloMo(float NewTimeDilation)
{
	if ( WorldInfo.bWithinDemoPlayback )
		WorldInfo.DemoPlayTimeDilation = NewTimeDilation;
}

exec function PlayVehicleHorn()
{
	local UTVehicle V;

	V = UTVehicle(Pawn);
	if ( (V != None) && (V.Health > 0) && (WorldInfo.TimeSeconds - LastTauntAnimTime > 0.3)  )
	{
		ServerPlayVehicleHorn();
		LastTauntAnimTime = WorldInfo.TimeSeconds;
	}
}

unreliable server function ServerPlayVehicleHorn()
{
	local UTVehicle V;

	V = UTVehicle(Pawn);
	if ( (V != None) && (V.Health > 0)  )
	{
		V.PlayHorn();
	}
}

exec function Taunt(int TauntIndex)
{
	local UTVehicle UTV;
	local UTPawn UTP;
	
	UTP = UTPawn(Pawn);
	if(UTP == None)
	{
		UTV = UTVehicle(Pawn);
		if(UTV != None)
		{
			UTP = UTPawn(UTV.Driver);
		}
	}

	if(UTP != None)
	{
		switch(TauntIndex)
		{
		case 0:
			UTP.PlayEmote('TauntA', -1);
			break;

		case 1:
			UTP.PlayEmote('TauntB', -1);
			break;

		case 2:
			UTP.PlayEmote('TauntC', -1);
			break;
		}
	}
}

function Typing( bool bTyping )
{
	bIsTyping = bTyping;
    if ( (Pawn != None) && !Pawn.bTearOff )
	UTPawn(Pawn).bIsTyping = bTyping;
}

simulated event Destroyed()
{
	Super.Destroyed();

	if (Announcer != None)
	{
		Announcer.Destroy();
	}
	if (MusicManager != None)
	{
		MusicManager.Destroy();
	}
}



/**
 * Attempts to pause/unpause the game when a controller becomes
 * disconnected/connected
 *
 * @param ControllerId the id of the controller that changed
 * @param bIsConnected whether the controller is connected or not
 */
function OnControllerChanged(int ControllerId,bool bIsConnected)
{
	local LocalPlayer LocPlayer;

		// Call parent implementation (this will pause/unpause the game if needed)
	super.OnControllerChanged( ControllerId, bIsConnected );

	// Don't worry about remote players
	LocPlayer = LocalPlayer(Player);

	if (WorldInfo.IsConsoleBuild() && (WorldInfo.Game == None || !WorldInfo.Game.bAutomatedPerfTesting))
	{
		// If the controller that changed, is attached to the this playercontroller
		if (LocPlayer != None && LocPlayer.ControllerId == ControllerId)
		{
			bIsControllerConnected = bIsConnected;

			if(bIsConnected)
			{
				class'UTUIScene'.static.HideOnlineToast();
			}
			else
			{
				class'UTUIScene'.static.ShowOnlineToast(Localize("ToastMessages","ReconnectController","UTGameUI")$" ("$(ControllerId+1)$")", -1);	// Time of -1 to make the toast stay up until we hide it.
			}
		}
	}
}



event SoakPause(Pawn P)
{
	LogInternal("Soak pause by "$P);
	SetViewTarget(P);
	SetPause(true);
	bBehindView = true;
	myHud.bShowDebugInfo = true;
}

function DrawHUD( HUD H )
{
	if( (Pawn != None) && (Pawn.Weapon != None) )
	{
		Pawn.Weapon.ActiveRenderOverlays(H);
	}
}

event KickWarning()
{
	if ( WorldInfo.TimeSeconds - LastKickWarningTime > 0.5 )
	{
		ReceiveLocalizedMessage( class'UTIdleKickWarningMessage', 0, None, None, self );
		LastKickWarningTime = WorldInfo.TimeSeconds;
	}
}

/* CheckJumpOrDuck()
Called by ProcessMove()
handle jump and duck buttons which are pressed
*/
function CheckJumpOrDuck()
{
	if ( Pawn == None )
	{
		return;
	}
	if ( bDoubleJump && (bUpdating || ((UTPawn(Pawn) != None) && UTPawn(Pawn).CanDoubleJump())) )
	{
		UTPawn(Pawn).DoDoubleJump( bUpdating );
	}
    else if ( bPressedJump )
	{
		Pawn.DoJump( bUpdating );
	}
	if ( Pawn.Physics != PHYS_Falling && Pawn.bCanCrouch )
	{
		// crouch if pressing duck
		Pawn.ShouldCrouch(bDuck != 0);
	}
}

exec function FOV(float F)
{
	if( (F >= 80.0) || (WorldInfo.NetMode==NM_Standalone) || PlayerReplicationInfo.bOnlySpectator )
	{
		OnFootDefaultFOV = FClamp(F, 80, 100);
		if ( Vehicle(Pawn) == None )
		{
			FixFOV();
		}
		SaveConfig();
	}
}

function FixFOV()
{
	if ( OnFootDefaultFOV < 80 )
	{
		OnFootDefaultFOV = 90.0;
	}
	OnFootDefaultFOV = FClamp(OnFootDefaultFOV, 80, 100);
	FOVAngle = OnFootDefaultFOV;
	DesiredFOV = OnFootDefaultFOV;
	DefaultFOV = OnFootDefaultFOV;
}

function Restart(bool bVehicleTransition)
{
	Super.Restart(bVehicleTransition);

	// re-check auto objective every time the player respawns
	if (!bVehicleTransition)
	{
		// use timer to spread out spawn CPU cost a little
		SetTimer(0.1, false, 'CheckAutoObjective');
	}
}

reliable client function ClientRestart(Pawn NewPawn)
{
	local UTVehicle V;

	Super.ClientRestart(NewPawn);
	ServerPlayerPreferences(WeaponHandPreference, bAutoTaunt, bCenteredWeaponFire, AutoObjectivePreference);

	if (NewPawn != None)
	{
		// apply vehicle FOV
		V = UTVehicle(NewPawn);
		if (V == None && NewPawn.IsA('UTWeaponPawn'))
		{
			V = UTVehicle(NewPawn.GetVehicleBase());
		}
		if (V != None)
		{
			DefaultFOV = V.DefaultFOV;
			DesiredFOV = DefaultFOV;
			FOVAngle = DesiredFOV;
		}
		else
		{
			FixFOV();
		}
		// if new pawn has empty weapon, autoswitch to new one
		// (happens when switching from Redeemer remote control, for example)
		if (NewPawn.Weapon != None && !NewPawn.Weapon.HasAnyAmmo())
		{
			SwitchToBestWeapon();
		}
	}
	else
	{
		FixFOV();
	}
}

function SetViewTarget(Actor NewViewTarget, optional ViewTargetTransitionParams TransitionParams)
{
	local UTVehicle V;
	local Pawn P;
	local EPawnShadowMode AdjustedShadowMode;

	ClearCameraEffect();

	Super.SetViewTarget(NewViewTarget, TransitionParams);

	// set sound pitch adjustment based on customtimedilation
	if ( ViewTarget.CustomTimeDilation < 1.0 )
	{
		ConsoleCommand( "SETSOUNDMODE 1", false );
	}
	else
	{
		ConsoleCommand( "SETSOUNDMODE 0", false );
	}

	// remove other players' shadows if viewing drop detail vehicle
	if (IsLocalPlayerController())
	{
		if (class'Engine'.static.IsSplitScreen())
		{
			AdjustedShadowMode = SHADOW_None;
		}
		else
		{
			V = UTVehicle(ViewTarget);
			if (V == None && Pawn(ViewTarget) != None)
			{
				V = UTVehicle(Pawn(ViewTarget).GetVehicleBase());
			}
			if (PawnShadowMode > SHADOW_None && V != None && V.bDropDetailWhenDriving && WorldInfo.GetDetailMode() < DM_Medium)
			{
				AdjustedShadowMode = SHADOW_Self;
			}
			else
			{
				AdjustedShadowMode = PawnShadowMode;
			}
		}
		foreach WorldInfo.AllPawns(class'Pawn', P)
		{
			if (UTPawn(P) != None)
			{
				UTPawn(P).UpdateShadowSettings(AdjustedShadowMode == SHADOW_All || (AdjustedShadowMode == SHADOW_Self && ViewTarget == P));
			}
			else if (UTVehicle(P) != None)
			{
				UTVehicle(P).UpdateShadowSettings(AdjustedShadowMode == SHADOW_All || (AdjustedShadowMode == SHADOW_Self && ViewTarget == P));
			}
		}
	}
}

/** attempts to find an objective for the player to complete depending on their settings and tells the player about it
 * @note: needs to be called on the server, not the client (because that's where the AI is)
 * @param bOnlyNotifyDifferent - if true, only send messages to the player if the selected objective is different from the previous one
 */
function CheckAutoObjective(bool bOnlyNotifyDifferent)
{
	local Actor ObjectiveActor;

	if (Pawn != None && PlayerReplicationInfo != None)
	{
		if (LastAutoObjectiveTime + 3.0 < WorldInfo.TimeSeconds)
		{
			LastAutoObjectiveTime = WorldInfo.TimeSeconds;
			ObjectiveActor = UTGame(WorldInfo.Game).GetAutoObjectiveFor(self);
			if ( ObjectiveActor != None )
			{
				SetAutoObjective(ObjectiveActor, bOnlyNotifyDifferent);
			}
			else
			{
				LastAutoObjective = None;
				ClientSetAutoObjective(LastAutoObjective);
			}
		}
	}
}

function SetAutoObjective(Actor ObjectiveActor, bool bOnlyNotifyDifferent)
{
	local UTGameObjective DesiredObjective;
	local int i;

	DesiredObjective = UTGameObjective(ObjectiveActor);
	if ( DesiredObjective != None )
	{
		ObjectiveActor = DesiredObjective.GetAutoObjectiveActor(self);
		DesiredObjective = UTGameObjective(ObjectiveActor);
	}
	if (ObjectiveActor != LastAutoObjective || !bOnlyNotifyDifferent)
	{
		LastAutoObjective = ObjectiveActor;
		bWasDefendingObjective = WorldInfo.GRI.OnSameTeam(LastAutoObjective, self);
		ClientSetAutoObjective(LastAutoObjective);

		if ( WorldInfo.TimeSeconds - LastShowPathTime > 0.5 )
		{
			LastShowPathTime = WorldInfo.TimeSeconds;

			// spawn willow whisp
			if (DesiredObjective != None)
			{
				for (i = 0; i < DesiredObjective.ShootSpots.length; i++)
				{
					if (DesiredObjective.ShootSpots[i] != None)
					{
						DesiredObjective.ShootSpots[i].bTransientEndPoint = true;
					}
				}
			}
			if (FindPathToward(LastAutoObjective) != None)
			{
				Spawn(class'UTWillowWhisp', self,, Pawn.Location);
			}
		}
	}
}

/** client-side notification of the current auto objective */
reliable client function ClientSetAutoObjective(Actor NewAutoObjective)
{
	LastAutoObjective = NewAutoObjective;

	ReceiveLocalizedMessage(class'UTObjectiveAnnouncement', AutoObjectivePreference,,, LastAutoObjective);
}

/* epic ===============================================
* ::Possess
*
* Handles attaching this controller to the specified
* pawn.
*
* =====================================================
*/
event Possess(Pawn inPawn, bool bVehicleTransition)
{
	Super.Possess(inPawn, bVehicleTransition);

	// force garbage collection when possessing pawn, to avoid GC during gameplay
	if ( bVehicleTransition )
	{
		if ( (WorldInfo.NetMode == NM_Client) || (WorldInfo.NetMode == NM_Standalone) )
		{
			WorldInfo.ForceGarbageCollection();
		}
	}
}

function AcknowledgePossession(Pawn P)
{
	local rotator NewViewRotation;

	Super.AcknowledgePossession(P);

	if ( LocalPlayer(Player) != None )
	{
		ClientEndZoom();
		if (bUseVehicleRotationOnPossess && Vehicle(P) != None && UTWeaponPawn(P) == None && UTVehicle_TrackTurretBase(P) == None)
		{
			NewViewRotation = P.Rotation;
			NewViewRotation.Roll = 0;
			SetRotation(NewViewRotation);
		}
		ServerPlayerPreferences(WeaponHandPreference, bAutoTaunt, bCenteredWeaponFire, AutoObjectivePreference);

		if ( (PlayerReplicationInfo != None)
			&& (PlayerReplicationInfo.Team != None)
			&& (IdentifiedTeam != PlayerReplicationInfo.Team.TeamIndex) )
		{
			// identify your team the first time you spawn on it
			IdentifiedTeam = PlayerReplicationInfo.Team.TeamIndex;
			if ( IdentifiedTeam < 2 )
			{
				ReceiveLocalizedMessage( class'UTTeamGameMessage', IdentifiedTeam+1, PlayerReplicationInfo);
			}
		}
	}
}

simulated event ReceivedPlayer()
{
	Super.ReceivedPlayer();

	if (LocalPlayer(Player) != None)
	{
		ServerPlayerPreferences(WeaponHandPreference, bAutoTaunt, bCenteredWeaponFire, AutoObjectivePreference);
	}
	else
	{
		// default auto objective preference to None for non-local players so we don't send objective info
		// until we've received the client's preference
		AutoObjectivePreference = AOP_Disabled;
	}
}

reliable server function ServerPlayerPreferences(EWeaponHand NewWeaponHand, bool bNewAutoTaunt, bool bNewCenteredWeaponFire, EAutoObjectivePreference NewAutoObjectivePreference)
{
	ServerSetHand(NewWeaponHand);
	ServerSetAutoTaunt(bNewAutoTaunt);

	bCenteredWeaponFire = bNewCenteredWeaponFire;

	if (AutoObjectivePreference != NewAutoObjectivePreference)
	{
		AutoObjectivePreference = NewAutoObjectivePreference;
		CheckAutoObjective(false);
	}
}

reliable server function ServerSetHand(EWeaponHand NewWeaponHand)
{
	WeaponHand = NewWeaponHand;
}

function SetHand(EWeaponHand NewWeaponHand)
{
	WeaponHandPreference = NewWeaponHand;
	WeaponHand = WeaponHandPreference;
	SaveConfig();

	ServerSetHand(NewWeaponHand);
}

event ResetCameraMode()
{}

/**
* return whether viewing in first person mode
*/
function bool UsingFirstPersonCamera()
{
	return !bBehindView;
}

// ------------------------------------------------------------------------

reliable server function ServerSetAutoTaunt(bool Value)
{
	bAutoTaunt = Value;
}

exec function SetAutoTaunt(bool Value)
{
	Default.bAutoTaunt = Value;
	StaticSaveConfig();
	bAutoTaunt = Value;

	ServerSetAutoTaunt(Value);
}

exec function ToggleScreenShotMode()
{
	if ( UTHUD(myHUD).bCrosshairShow )
	{
		UTHUD(myHUD).bCrosshairShow = false;
		SetHand(HAND_Hidden);
		myHUD.bShowHUD = false;
		if ( UTPawn(Pawn) != None )
			UTPawn(Pawn).TeamBeaconMaxDist = 0;
	}
	else
	{
		// return to normal
		UTHUD(myHUD).bCrosshairShow = true;
		SetHand(HAND_Right);
		myHUD.bShowHUD = true;
		if ( UTPawn(Pawn) != None )
			UTPawn(Pawn).TeamBeaconMaxDist = UTPawn(Pawn).default.TeamBeaconMaxDist;
	}
}

reliable client function PlayStartupMessage(byte StartupStage)
{
	if ( StartupStage == 7 )
	{
		ReceiveLocalizedMessage( class'UTTimerMessage', 17, PlayerReplicationInfo );
	}
	else
	{
		ReceiveLocalizedMessage( class'UTStartupMessage', StartupStage, PlayerReplicationInfo );
	}
}

function NotifyTakeHit(Controller InstigatedBy, vector HitLocation, int Damage, class<DamageType> damageType, vector Momentum)
{
	local int iDam;

	Super.NotifyTakeHit(InstigatedBy,HitLocation,Damage,DamageType,Momentum);

	iDam = Clamp(Damage,0,250);
	if ( (iDam > 0 || bGodMode) && (Pawn != None) )
	{
		ClientPlayTakeHit(hitLocation - Pawn.Location, iDam, damageType);
	}
}

unreliable client function ClientPlayTakeHit(vector HitLoc, byte Damage, class<DamageType> DamageType)
{
	DamageShake(Damage, DamageType);
	HitLoc += Pawn.Location;

	if (UTHud(MyHud) != None)
	{
		UTHud(MyHud).DisplayHit(HitLoc, Damage, DamageType);
	}
}

/**
 * Limit use frequency
 */
unreliable server function ServerUse()
{
	if ( (LastUseTime == WorldInfo.TimeSeconds) || ((Vehicle(Pawn) != None) && (WorldInfo.TimeSeconds - LastUseTime < 1.0)) )
	{
		return;
	}
	LastUseTime = WorldInfo.TimeSeconds;
	PerformedUseAction();
}

exec function Use()
{
	if( Role < Role_Authority )
	{
		PerformedUseAction();
	}
	ServerUse();
}

simulated function bool PerformedUseAction()
{
	local UTCarriedObject Flag;

	bJustFoundVehicle = false;

	if ( UTPawn(Pawn) != None && UTPawn(Pawn).IsHero() )
	{
		Pawn.ToggleMelee();
		return false;
}

	if (Pawn != None && Pawn.IsInState('FeigningDeath'))
	{
		// can't use things while feigning death
		return true;
	}

		if ( (Pawn != None) && (Vehicle(Pawn) == None) )
		{
		  ForEach Pawn.TouchingActors(class'UTCarriedObject', Flag)
		  {
			  if ( Flag.FlagUse(self) )
			  {
				  return true;
			  }
		  }
		}
	
	if ( Super.PerformedUseAction() )
	{
		return true;
	}
	
	if ( (Role == ROLE_Authority) && !bJustFoundVehicle )
	{
		// Gamepad smart use - bring out translocator or hoverboard if no other use possible
		ClientSmartUse();
		return true;
	}
	return false;
	}

function ClearDoubleClick()
{
	Super.ClearDoubleClick();

	if (Pawn != none && UTPawn(Pawn) != none)
		UTPawn(Pawn).DodgeResetTimestamp = WorldInfo.TimeSeconds + UTPawn(Pawn).DodgeResetTime;
}

// Player movement.
// Player Standing, walking, running, falling.
state PlayerWalking
{
	ignores SeePlayer, HearNoise, Bump;

	event bool NotifyLanded(vector HitNormal, Actor FloorActor)
	{
		if (DoubleClickDir == DCLICK_Active)
		{
			DoubleClickDir = DCLICK_Done;
			ClearDoubleClick();
		}
		else
		{
			DoubleClickDir = DCLICK_None;
		}

		if (Global.NotifyLanded(HitNormal, FloorActor))
		{
			return true;
		}

		return false;
	}

	function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
	{
		if ( !bEnableDodging )
		{
			DoubleClickMove = DCLICK_None;
		}
		if ( (DoubleClickMove == DCLICK_Active) && (Pawn.Physics == PHYS_Falling) )
			DoubleClickDir = DCLICK_Active;
		else if ( (DoubleClickMove != DCLICK_None) && (DoubleClickMove < DCLICK_Active) )
		{
			if ( UTPawn(Pawn).Dodge(DoubleClickMove) )
				DoubleClickDir = DCLICK_Active;
		}

		Super.ProcessMove(DeltaTime,NewAccel,DoubleClickMove,DeltaRot);
	}

    function PlayerMove( float DeltaTime )
    {
		GroundPitch = 0;
		Super.PlayerMove(DeltaTime);
	}
}

function ServerSpectate()
{
	GotoState('Spectating');
}

state RoundEnded
{
ignores SeePlayer, HearNoise, KilledBy, NotifyBump, HitWall, NotifyHeadVolumeChange, NotifyPhysicsVolumeChange, Falling, TakeDamage, Suicide, DrawHud;

	exec function PrevWeapon() {}
	exec function NextWeapon() {}
	exec function SwitchWeapon(byte T) {}
	exec function ShowQuickPick(){}
	exec function ToggleMelee() {}

	reliable server function ServerReStartGame()
	{
		if (UTGameReplicationInfo(WorldInfo.GRI).MapVoteTimeRemaining > 0.0f)
		{
			return;
		}
		Super.ServerRestartGame();
	}

	/**
	 * Limit the player's view rotation. (Pitch component).
	 */
	event Rotator LimitViewRotation( Rotator ViewRotation, float ViewPitchMin, float ViewPitchMax )
	{
		ViewRotation.Pitch = ViewRotation.Pitch & 65535;

		if( ViewRotation.Pitch > 8192 &&
			ViewRotation.Pitch < (65535+ViewPitchMin) )
		{
			if( ViewRotation.Pitch < 32768 )
			{
				ViewRotation.Pitch = 8192;
			}
			else
			{
				ViewRotation.Pitch = 65535 + ViewPitchMin;
			}
		}

		return ViewRotation;
	}

	unreliable client function LongClientAdjustPosition
	(
		float TimeStamp,
		name newState,
		EPhysics newPhysics,
		float NewLocX,
		float NewLocY,
		float NewLocZ,
		float NewVelX,
		float NewVelY,
		float NewVelZ,
		Actor NewBase,
		float NewFloorX,
		float NewFloorY,
		float NewFloorZ
	)
	{
		if ( newState == 'PlayerWaiting' )
			GotoState( newState );
	}

	function PlayerMove(float DeltaTime)
	{
		local vector X,Y,Z;
		local Rotator DeltaRot, ViewRotation;

		GetAxes(Rotation,X,Y,Z);
		// Update view rotation.
		ViewRotation = Rotation;
		// Calculate Delta to be applied on ViewRotation
		DeltaRot.Yaw	= PlayerInput.aTurn;
		DeltaRot.Pitch	= PlayerInput.aLookUp;
		ProcessViewRotation( DeltaTime, ViewRotation, DeltaRot );
		SetRotation(ViewRotation);

		ViewShake(DeltaTime);

		if ( Role < ROLE_Authority ) // then save this move and replicate it
			ReplicateMove(DeltaTime, vect(0,0,0), DCLICK_None, rot(0,0,0));
		bPressedJump = false;
	}

	function ShowScoreboard()
	{
		local UTGameReplicationInfo GRI;

		if ( CommandMenu != none )
		{
			CommandMenu.CloseScene(CommandMenu);
			CommandMenu = none;
		}

		GRI = UTGameReplicationInfo(WorldInfo.GRI);
		if (GRI != None && GRI.bMatchIsOver && !GRI.bStoryMode)
		{
			// If voting is currently active, then go to the vote tab instead of scoreboard tab
			if (VoteRI != none && GRI.VoteRoundTimeCounter != INDEX_None)
				ShowMidGameMenu('VoteTab', True);
			else
				ShowMidGameMenu('ScoreTab', True);
		}
		else if (myHUD != None)
		{
			myHUD.SetShowScores(true);
		}
		AutoContinueToNextRound();
	}

	/** This will auto continue to the next round.  Very useful doing soak testing and testing traveling to next level **/
	function AutoContinueToNextRound()
	{
		if (Role == ROLE_Authority && UTGame(WorldInfo.Game).bAutoContinueToNextRound)
		{
			myHUD.SetShowScores(false);
				StartFire( 0 );
			}
		}

	function BeginState(Name PreviousStateName)
	{
		Super.BeginState(PreviousStateName);

		// this is a good stop gap measure for any cases that we miss / other code getting turned on / called
		// there is never a case where we want the tilt to be on at this point
		SetOnlyUseControllerTiltInput( FALSE );
		SetUseTiltForwardAndBack( TRUE );
		SetControllerTiltActive( FALSE );

		if (UTGame(WorldInfo.Game) != None)
		{
			// don't let player restart the game until the end game sequence is complete
			SetTimer(FMax(GetTimerRate(), UTGame(WorldInfo.Game).ResetTimeDelay), false);
		}

		bAlreadyReset = false;

		if ( myHUD != None )
		{
			myHUD.SetShowScores(false);
			// the power core explosion is 15 seconds  so we wait 1 additional for the awe factor (the total time of the matinee is 18-20 seconds to avoid popping back to start)
			// so for DM/CTF will get to see the winner in GLORIOUS detail and listen to the smack talking
			SetTimer(16, false, 'ShowScoreboard');
		}
	}

	function EndState(name NextStateName)
	{
		local int i, j;
		local Sequence GameSequence;
		local array<SequenceObject> CoreEvents, LinkedObjects;
		local SeqAct_Interp InterpAction;

		Super.EndState(NextStateName);
		SetBehindView(false);
		StopViewShaking();
		StopCameraAnim(true);
		if (myHUD != None)
		{
			myHUD.SetShowScores(false);
		}

		// force stop powercore cinematic if necessary
		GameSequence = WorldInfo.GetGameSequence();
		if (GameSequence != None)
		{
			GameSequence.FindSeqObjectsByClass(class'UTSeqEvent_PowerCoreDestructionEffect', true, CoreEvents);
			for (i = 0; i < CoreEvents.length; i++)
			{
				UTSeqEvent_PowerCoreDestructionEffect(CoreEvents[i]).GetLinkedObjects(LinkedObjects, class'SeqAct_Interp', true);
				for (j = 0; j < LinkedObjects.length; j++)
				{
					InterpAction = SeqAct_Interp(LinkedObjects[j]);
					if (InterpAction.bActive)
					{
						InterpAction.SetPosition(0.0, true);
						InterpAction.Stop();
					}
				}
			}
		}
	}
}

function ShowScoreboard();

state Dead
{
	ignores SeePlayer, HearNoise, KilledBy, NextWeapon, PrevWeapon;

	exec function SwitchWeapon(byte T){}
	exec function ToggleMelee() {}
	exec function ShowQuickPick(){}
	exec function StartFire( optional byte FireModeNum )
	{
		if ( bFrozen )
		{
			if ( !IsTimerActive() || GetTimerCount() > MinRespawnDelay )
				bFrozen = false;
			return;
		}
		if ( PlayerReplicationInfo.bOutOfLives )
			ServerSpectate();
		else
			super.StartFire( FireModeNum );
	}

	function Timer()
	{
		if (!bFrozen)
			return;

		// force garbage collection while dead, to avoid GC during gameplay
		if ( (WorldInfo.NetMode == NM_Client) || (WorldInfo.NetMode == NM_Standalone) )
		{
			WorldInfo.ForceGarbageCollection();
		}
		bFrozen = false;
		bUsePhysicsRotation = false;
		bPressedJump = false;
	}

	reliable client event ClientSetViewTarget( Actor A, optional ViewTargetTransitionParams TransitionParams )
	{
		if( A == None )
		{
			ServerVerifyViewTarget();
			return;
		}
		// don't force view to self while dead (since server may be doing it having destroyed the pawn)
		if ( A == self )
			return;
		SetViewTarget( A, TransitionParams );
	}

	function FindGoodView()
	{
		local vector cameraLoc;
		local rotator cameraRot, ViewRotation, RealRotation;
		local int tries, besttry;
		local float bestdist, newdist, RealCameraScale;
		local int startYaw;
		local UTPawn P;

		if ( UTVehicle(ViewTarget) != None )
		{
			DesiredRotation = Rotation;
			bUsePhysicsRotation = true;
			return;
		}

		ViewRotation = Rotation;
		RealRotation = ViewRotation;
		ViewRotation.Pitch = 56000;
		SetRotation(ViewRotation);
		P = UTPawn(ViewTarget);
		if ( P != None )
		{
			RealCameraScale = P.CurrentCameraScale;
			P.CurrentCameraScale = P.CameraScale;
		}

		// use current rotation if possible
		CalcViewActor = None;
		cameraLoc = ViewTarget.Location;
		GetPlayerViewPoint( cameraLoc, cameraRot );
		if ( P != None )
		{
			newdist = VSize(cameraLoc - ViewTarget.Location);
			if (newdist < P.CylinderComponent.CollisionRadius + P.CylinderComponent.CollisionHeight )
			{
				// find alternate camera rotation
				tries = 0;
				besttry = 0;
				bestdist = 0.0;
				startYaw = ViewRotation.Yaw;

				for (tries=1; tries<16; tries++)
				{
					CalcViewActor = None;
					cameraLoc = ViewTarget.Location;
					ViewRotation.Yaw += 4096;
					SetRotation(ViewRotation);
					GetPlayerViewPoint( cameraLoc, cameraRot );
					newdist = VSize(cameraLoc - ViewTarget.Location);
					if (newdist > bestdist)
					{
						bestdist = newdist;
						besttry = tries;
					}
				}
				ViewRotation.Yaw = startYaw + besttry * 4096;
			}
			P.CurrentCameraScale = RealCameraScale;
		}
		SetRotation(RealRotation);
		DesiredRotation = ViewRotation;
		DesiredRotation.Roll = 0;
		bUsePhysicsRotation = true;
	}

	function BeginState(Name PreviousStateName)
	{
		local UTWeaponLocker WL;
		local UTWeaponPickupFactory WF;

		LastAutoObjective = None;
		if ( Pawn(Viewtarget) != None )
		{
			SetBehindView(true);
		}
		Super.BeginState(PreviousStateName);

		if ( LocalPlayer(Player) != None )
		{
			ForEach WorldInfo.AllNavigationPoints(class'UTWeaponLocker',WL)
				WL.NotifyLocalPlayerDead(self);
			ForEach WorldInfo.AllNavigationPoints(class'UTWeaponPickupFactory',WF)
				WF.NotifyLocalPlayerDead(self);
		}

		if ( CurrentMapScene != none )
		{
			CurrentMapScene.SceneClient.CloseScene(CurrentMapScene);
		}

		if ( UTGameReplicationInfo(WorldInfo.GRI).bShowMenuOnDeath && bPopupMapOnDeath && LocalPlayer(Player) != none )
		{
			SetTimer(PopupWaitTime,false,'PopupMap');
		}

		if (Role == ROLE_Authority && UTGame(WorldInfo.Game) != None && UTGame(WorldInfo.Game).ForceRespawn())
		{
			SetTimer(MinRespawnDelay, true, 'DoForcedRespawn');
		}
	}

	/** forces player to respawn if it is enabled */
	function DoForcedRespawn()
	{
		if (PlayerReplicationInfo.bOnlySpectator)
		{
			ClearTimer('DoForcedRespawn');
		}
		else
		{
			ServerRestartPlayer();
		}
	}

	simulated function PopupMap()
	{
		local UTUITabPage_MapTab MapTab;
		local UTUIScene_MidGameMenu CurrentMidGameMenu;

		CurrentMidGameMenu = ShowMidGameMenu('MapTab',true);

		if ( CurrentMidGameMenu != none )
		{
			MapTab = UTUITabPage_MapTab( CurrentMidGameMenu.FindChild('MapTab',true) );
			if ( MapTab != none )
			{
				MapTab.AllowSpawning();
			}
			ClearTimer('PopupMap');
		}
	}

	function EndState(name NextStateName)
	{
		bUsePhysicsRotation = false;
		Super.EndState(NextStateName);
		SetBehindView(false);
		StopViewShaking();
		ClearTimer('PopupMap');
		ClearTimer('DoForcedRespawn');
	}

Begin:
    Sleep(5.0);
	if ( (ViewTarget == None) || (ViewTarget == self) || (VSize(ViewTarget.Velocity) < 1.0) )
	{
		Sleep(1.0);
		if (myHUD != None)
		{
			//@FIXME: disabled temporarily for E3 due to scoreboard stealing input
			//myHUD.SetShowScores(true);
		}
	}
	else
		Goto('Begin');
}

/**
 * list important UTPlayerController variables on canvas. HUD will call DisplayDebug() on the current ViewTarget when
 * the ShowDebug exec is used
 *
 * @param	HUD		- HUD with canvas to draw on
 * @input	out_YL		- Height of the current font
 * @input	out_YPos	- Y position on Canvas. out_YPos += out_YL, gives position to draw text for next debug line.
 */
simulated function DisplayDebug(HUD HUD, out float out_YL, out float out_YPos)
{
	local Canvas Canvas;

	Canvas = HUD.Canvas;
	Canvas.SetDrawColor(255,255,255,255);

	Canvas.DrawText("CONTROLLER "$GetItemName(string(self))$" Physics "$GetPhysicsName()$" Pawn "$GetItemName(string(Pawn))$" Yaw "$Rotation.Yaw);
	out_YPos += out_YL;
	Canvas.SetPos(4, out_YPos);

	if ( Pawn == None )
	{
		if ( PlayerReplicationInfo == None )
			Canvas.DrawText("NO PLAYERREPLICATIONINFO", false);
		else
			PlayerReplicationInfo.DisplayDebug(HUD, out_YL, out_YPos);
		out_YPos += out_YL;
		Canvas.SetPos(4, out_YPos);

		super(Actor).DisplayDebug(HUD, out_YL, out_YPos);
	}
	else if (HUD.ShouldDisplayDebug('AI'))
	{
		if ( Enemy != None )
			Canvas.DrawText(" STATE: "$GetStateName()$" Timer: "$GetTimerCount()$" Enemy "$Enemy.GetHumanReadableName(), false);
		else
			Canvas.DrawText(" STATE: "$GetStateName()$" Timer: "$GetTimerCount()$" NO Enemy ", false);
		out_YPos += out_YL;
		Canvas.SetPos(4, out_YPos);
	}

	if (PlayerCamera != None && HUD.ShouldDisplayDebug('camera'))
	{
		PlayerCamera.DisplayDebug( HUD, out_YL, out_YPos );
	}
}

function Reset()
{
	Super.Reset();
	if ( PlayerCamera != None )
	{
		PlayerCamera.Destroy();
	}
}

reliable client function ClientReset()
{
	local UTGameObjective O;

	Super.ClientReset();
	if ( PlayerCamera != None )
	{
		PlayerCamera.Destroy();
	}

	foreach WorldInfo.AllNavigationPoints(class'UTGameObjective', O)
	{
		O.ClientReset();
	}
}

exec function BehindView()
{
	if (WorldInfo.NetMode == NM_Standalone || bDemoOwner)
		SetBehindView(!bBehindView);
}

function SetBehindView(bool bNewBehindView)
{
	bBehindView = bNewBehindView;
	if ( !bBehindView )
	{
		bFreeCamera = false;
	}

	if (LocalPlayer(Player) == None)
	{
		ClientSetBehindView(bNewBehindView);
	}
	else if (UTPawn(ViewTarget) != None)
	{
		UTPawn(ViewTarget).SetThirdPersonCamera(bNewBehindView);
	}
	// make sure we recalculate camera position for this frame
	LastCameraTimeStamp = WorldInfo.TimeSeconds - 1.0;
}

reliable client function ClientSetBehindView(bool bNewBehindView)
{
	if (LocalPlayer(Player) != None)
	{
		SetBehindView(bNewBehindView);
	}
	// make sure we recalculate camera position for this frame
	LastCameraTimeStamp = WorldInfo.TimeSeconds - 1.0;
}

/**
 * Set new camera mode
 *
 * @param	NewCamMode, new camera mode.
 */
function SetCameraMode( name NewCamMode )
{
	// will get set back to true below, if necessary
	bDebugFreeCam = FALSE;

	if ( PlayerCamera != None )
	{
		Super.SetCameraMode(NewCamMode);
	}
	else if ( NewCamMode == 'ThirdPerson' )
	{
		if ( !bBehindView )
			SetBehindView(true);
	}
	else if ( NewCamMode == 'FreeCam' )
	{
		if ( !bBehindView )
		{
			SetBehindView(true);
		}
		bDebugFreeCam = TRUE;
		DebugFreeCamRot = Rotation;
	}
	else
	{
		if ( bBehindView )
			SetBehindView(false);
	}
}

function SpawnCamera()
{
	local Actor OldViewTarget;

	// Associate Camera with PlayerController
	PlayerCamera = Spawn(MatineeCameraClass, self);
	if (PlayerCamera != None)
	{
		OldViewTarget = ViewTarget;
		PlayerCamera.InitializeFor(self);
		PlayerCamera.SetViewTarget(OldViewTarget);
	}
	else
	{
		LogInternal("Couldn't Spawn Camera Actor for Player!!");
	}
}

/* GetPlayerViewPoint: Returns Player's Point of View
	For the AI this means the Pawn's Eyes ViewPoint
	For a Human player, this means the Camera's ViewPoint */
simulated event GetPlayerViewPoint( out vector POVLocation, out Rotator POVRotation )
{
	local float DeltaTime;
	local UTPawn P;

	P = IsLocalPlayerController() ? UTPawn(CalcViewActor) : None;

	if (LastCameraTimeStamp == WorldInfo.TimeSeconds
		&& CalcViewActor == ViewTarget
		&& CalcViewActor != None
		&& CalcViewActor.Location == CalcViewActorLocation
		&& CalcViewActor.Rotation == CalcViewActorRotation
		)
	{
		if ( (P == None) || ((P.EyeHeight == CalcEyeHeight) && (P.WalkBob == CalcWalkBob)) )
		{
			// use cached result
			POVLocation = CalcViewLocation;
			POVRotation = CalcViewRotation;
			return;
		}
	}

	DeltaTime = WorldInfo.TimeSeconds - LastCameraTimeStamp;
	LastCameraTimeStamp = WorldInfo.TimeSeconds;

	// support for using CameraActor views
	if ( CameraActor(ViewTarget) != None )
	{
		if ( PlayerCamera == None )
		{
			super.ResetCameraMode();
			SpawnCamera();
		}
		super.GetPlayerViewPoint( POVLocation, POVRotation );
	}
	else
	{
		if ( PlayerCamera != None )
		{
			PlayerCamera.Destroy();
			PlayerCamera = None;
		}

		if ( ViewTarget != None )
		{
			POVRotation = Rotation;
			if ( (PlayerReplicationInfo != None) && PlayerReplicationInfo.bOnlySpectator && (UTVehicle(ViewTarget) != None) )
			{
				UTVehicle(ViewTarget).bSpectatedView = true;
				ViewTarget.CalcCamera( DeltaTime, POVLocation, POVRotation, FOVAngle );
				UTVehicle(ViewTarget).bSpectatedView = false;
			}
			else
			{
				ViewTarget.CalcCamera( DeltaTime, POVLocation, POVRotation, FOVAngle );
			}
			if ( bFreeCamera )
			{
				POVRotation = Rotation;
			}
		}
		else
		{
			CalcCamera( DeltaTime, POVLocation, POVRotation, FOVAngle );
			return;
		}
	}

	// apply view shake
	POVRotation = Normalize(POVRotation + ShakeRot);
	POVLocation += ShakeOffset >> Rotation;

	if( CameraEffect != none )
	{
		CameraEffect.UpdateLocation(POVLocation, POVRotation, GetFOVAngle());
	}


	// cache result
	CalcViewActor = ViewTarget;
	CalcViewActorLocation = ViewTarget.Location;
	CalcViewActorRotation = ViewTarget.Rotation;
	CalcViewLocation = POVLocation;
	CalcViewRotation = POVRotation;

	if ( P != None )
	{
		CalcEyeHeight = P.EyeHeight;
		CalcWalkBob = P.WalkBob;
	}
}


unreliable client function ClientMusicEvent(int EventIndex)
{
	if ( MusicManager != None )
		MusicManager.MusicEvent(EventIndex);
}

/**
  * return true if music manager is already playing action track
  * return true if no music manager (no need to tell non-existent music manager to change tracks
  */
function bool AlreadyInActionMusic()
{
	return (MusicManager != None) ? MusicManager.AlreadyInActionMusic() : true;
}

exec function Music(int EventIndex)
{
	MusicManager.MusicEvent(EventIndex);
}

reliable client function ClientPlayAnnouncement(class<UTLocalMessage> InMessageClass, int MessageIndex, optional PlayerReplicationInfo PRI, optional Object OptionalObject)
{
	PlayAnnouncement(InMessageClass, MessageIndex, PRI, OptionalObject);
}

function PlayAnnouncement(class<UTLocalMessage> InMessageClass, int MessageIndex, optional PlayerReplicationInfo PRI, optional Object OptionalObject)
{
	// Wait for player to be up to date with replication when joining a server, before stacking up messages
	if ( WorldInfo.GRI == None || Announcer == None )
	{
		return;
	}
	
	if ( UTGameReplicationInfo(WorldInfo.GRI) != None && UTGameReplicationInfo(WorldInfo.GRI).bAnnouncementsDisabled )
	{
		if ( !bCinematicMode && (string(WorldInfo.GetPackageName()) ~= "WAR-MarketDistrict") )
		{
			UTGameReplicationInfo(WorldInfo.GRI).bAnnouncementsDisabled = false;
		}
		else
		{
			return;
		}
	}
	Announcer.PlayAnnouncement(InMessageClass, MessageIndex, PRI, OptionalObject);
}


/** Causes a view shake based on the amount of damage
	Should only be called on the owning client */
function DamageShake(int Damage, class<DamageType> DamageType)
{
	local float BlendWeight;
	local class<UTDamageType> UTDamage;
	local CameraAnim AnimToPlay;

	UTDamage = class<UTDamageType>(DamageType);
	if (UTDamage != None && UTDamage.default.DamageCameraAnim != None)
	{
		AnimToPlay = UTDamage.default.DamageCameraAnim;
	}
	else
	{
		AnimToPlay = DamageCameraAnim;
	}
	if (AnimToPlay != None)
	{
		// don't override other anims unless it's another, weaker damage anim
		BlendWeight = FClamp(Damage / 200.0, 0.0, 1.0);
		if ( CameraAnimPlayer != None && ( CameraAnimPlayer.bFinished ||
						(bCurrentCamAnimIsDamageShake && CameraAnimPlayer.CurrentBlendWeight < BlendWeight) ) )
		{
			PlayCameraAnim(AnimToPlay, BlendWeight,,,,, true);
		}
	}
}

/** Turns off any view shaking */
function StopViewShaking()
{
	if (CameraAnimPlayer != None)
	{
		CameraAnimPlayer.Stop();
	}
}

/** plays the specified camera animation with the specified weight (0 to 1)
 * local client only
 */
function PlayCameraAnim( CameraAnim AnimToPlay, optional float Scale=1.f, optional float Rate=1.f,
			optional float BlendInTime, optional float BlendOutTime, optional bool bLoop, optional bool bIsDamageShake )
{
	local AnimatedCamera MatineeAnimatedCam;

	bCurrentCamAnimAffectsFOV = false;

	// if we have a real camera, e.g we're watching through a matinee camera,
	// send the CameraAnim to be played there
	MatineeAnimatedCam = AnimatedCamera(PlayerCamera);
	if (MatineeAnimatedCam != None)
	{
		MatineeAnimatedCam.PlayCameraAnim(AnimToPlay, Rate, Scale, BlendInTime, BlendOutTime, bLoop, FALSE);
	}
	else if (CameraAnimPlayer != None)
	{
		// play through normal UT camera
		CamOverridePostProcess = class'CameraActor'.default.CamOverridePostProcess;
		CameraAnimPlayer.Play(AnimToPlay, self, Rate, Scale, BlendInTime, BlendOutTime, bLoop, false);
	}

	// Play controller vibration - don't do this if damage, as that has its own handling
	if( !bIsDamageShake && !bLoop && WorldInfo.NetMode != NM_DedicatedServer )
	{
		if( AnimToPlay.AnimLength <= 1 )
		{
			ClientPlayForceFeedbackWaveform(CameraShakeShortWaveForm);
		}
		else
		{
			ClientPlayForceFeedbackWaveform(CameraShakeLongWaveForm);
		}
	}

	bCurrentCamAnimIsDamageShake = bIsDamageShake;
}

/** Stops the currently playing camera animation. */
function StopCameraAnim(optional bool bImmediate)
{
	if (CameraAnimPlayer != None)
	{
		CameraAnimPlayer.Stop(bImmediate);
	}
}

/** Allows changing camera anim strength on the fly */
function SetCameraAnimStrength(float NewStrength)
{
	if ( CameraAnimPlayer != None )
	{
		CameraAnimPlayer.PlayScale = NewStrength;
	}
}

reliable client function ClientPlayCameraAnim( CameraAnim AnimToPlay, optional float Scale=1.f, optional float Rate=1.f,
						optional float BlendInTime, optional float BlendOutTime, optional bool bLoop)
{
	PlayCameraAnim(AnimToPlay, Scale, Rate, BlendInTime, BlendOutTime, bLoop);
}

reliable client function ClientStopCameraAnim(bool bImmediate)
{
	StopCameraAnim(bImmediate);
}

function OnPlayCameraAnim(UTSeqAct_PlayCameraAnim InAction)
{
	ClientPlayCameraAnim(InAction.AnimToPlay, InAction.IntensityScale, InAction.Rate, InAction.BlendInTime, InAction.BlendOutTime);
}

function OnStopCameraAnim(UTSeqAct_StopCameraAnim InAction)
{
	ClientStopCameraAnim(InAction.bStopImmediately);
}


/** Sets ShakeOffset and ShakeRot to the current view shake that should be applied to the camera */
function ViewShake(float DeltaTime)
{
	if (CameraAnimPlayer != None && !CameraAnimPlayer.bFinished)
	{
		// advance the camera anim - the native code will set ShakeOffset/ShakeRot appropriately
		CamOverridePostProcess = class'CameraActor'.default.CamOverridePostProcess;
		CameraAnimPlayer.AdvanceAnim(DeltaTime, false);
	}
	else
	{
		ShakeOffset = vect(0,0,0);
		ShakeRot = rot(0,0,0);
	}
}

simulated exec function ToggleMelee()
{
	if ( Pawn != None )
	{
		Pawn.ToggleMelee();
	}
}

simulated exec function ToggleTranslocator()
{
	if ( (Pawn != None) && !IsMoveInputIgnored() )
	{
		if ( UTWeap_Translocator(Pawn.Weapon) != None )
		{
			UTInventoryManager(Pawn.InvManager).SwitchToPreviousWeapon();
		}
		else
		{
			SwitchWeapon(0);
		}
	}
}

//=====================================================================
// UT specific implementation of networked player movement functions
//

function CallServerMove
(
	SavedMove NewMove,
    vector ClientLoc,
    byte ClientRoll,
    int View,
    SavedMove OldMove
)
{
	local vector BuildAccel;
	local byte OldAccelX, OldAccelY, OldAccelZ;

	// compress old move if it exists
	if ( OldMove != None )
	{
		// old move important to replicate redundantly
		BuildAccel = 0.05 * OldMove.Acceleration + vect(0.5, 0.5, 0.5);
		OldAccelX = CompressAccel(BuildAccel.X);
		OldAccelY = CompressAccel(BuildAccel.Y);
		OldAccelZ = CompressAccel(BuildAccel.Z);

		OldServerMove(OldMove.TimeStamp,OldAccelX, OldAccelY, OldAccelZ, OldMove.CompressedFlags());
	}

	if ( PendingMove != None )
	{
		DualServerMove
		(
			PendingMove.TimeStamp,
			PendingMove.Acceleration * 10,
			PendingMove.CompressedFlags(),
			((PendingMove.Rotation.Yaw & 65535) << 16) + (PendingMove.Rotation.Pitch & 65535),
			NewMove.TimeStamp,
			NewMove.Acceleration * 10,
			ClientLoc,
			NewMove.CompressedFlags(),
			ClientRoll,
			View
		);
	}
    else if ( (NewMove.Acceleration * 10 == vect(0,0,0)) && (NewMove.DoubleClickMove == DCLICK_None) && !NewMove.bDoubleJump )
    {
		ShortServerMove
		(
			NewMove.TimeStamp,
			ClientLoc,
			NewMove.CompressedFlags(),
			ClientRoll,
			View
		);
    }
    else
		ServerMove
	(
	    NewMove.TimeStamp,
	    NewMove.Acceleration * 10,
	    ClientLoc,
			NewMove.CompressedFlags(),
	    ClientRoll,
	    View
	);
}

/* ShortServerMove()
compressed version of server move for bandwidth saving
*/
unreliable server function ShortServerMove
(
	float TimeStamp,
	vector ClientLoc,
	byte NewFlags,
	byte ClientRoll,
	int View
)
{
    ServerMove(TimeStamp,vect(0,0,0),ClientLoc,NewFlags,ClientRoll,View);
}

unreliable client function LongClientAdjustPosition( float TimeStamp, name NewState, EPhysics NewPhysics,
					float NewLocX, float NewLocY, float NewLocZ,
					float NewVelX, float NewVelY, float NewVelZ, Actor NewBase,
					float NewFloorX, float NewFloorY, float NewFloorZ )
{
	local UTPawn P;
	local vector OldPos, NewPos;

	P = UTPawn(Pawn);
	if (P != None)
	{
		OldPos = P.Mesh.GetPosition();
	}

	Super.LongClientAdjustPosition( TimeStamp, NewState, NewPhysics, NewLocX, NewLocY, NewLocZ,
					NewVelX, NewVelY, NewVelZ, NewBase, NewFloorX, NewFloorY, NewFloorZ );

	// allow changing location of rigid body pawn if feigning death
	if (P != None && P.bFeigningDeath && P.Physics == PHYS_RigidBody)
	{
		// the actor's location (and thus the mesh) were moved in the Super call, so we just need
		// to tell the physics system to do the same
		NewPos = P.Mesh.GetPosition();
		if (VSizeSq(NewPos - OldPos) > REP_RBLOCATION_ERROR_TOLERANCE_SQ)
		{
			P.Mesh.SetRBPosition(P.Mesh.GetPosition());
		}
	}
}

auto state PlayerWaiting
{
	exec function SwitchWeapon(byte F){}
	exec function ShowQuickPick(){}

	/** called when the actor falls out of the world 'safely' (below KillZ and such) */
	simulated event FellOutOfWorld(class<DamageType> dmgType)
	{
		bCameraOutOfWorld = true;
	}

	function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
	{
		local vector OldLocation;

		OldLocation = Location;
		super.ProcessMove(DeltaTime, NewAccel, DoubleClickMove, DeltaRot);

		if ( bCameraOutOfWorld )
		{
			bCameraOutOfWorld = false;
			SetLocation(OldLocation);
		}
	}

	exec function StartFire( optional byte FireModeNum )
	{
		ServerReStartPlayer();
	}

	reliable server function ServerRestartPlayer()
	{
		if (!WorldInfo.Game.bWaitingToStartMatch || PlayerReplicationInfo.bReadyToPlay || bInitialProcessingComplete)
		{
			Super.ServerRestartPlayer();
			if (WorldInfo.Game.bWaitingToStartMatch && UTGame(WorldInfo.Game).bWarmupRound && UTGame(WorldInfo.Game).WarmupTime > 1.0)
			{
				WorldInfo.Game.RestartPlayer(self);
			}
		}
	}
}

function ViewNextBot()
{
	if ( CheatManager != None )
		CheatManager.ViewBot();
}

exec function SwitchWeapon(byte T)
{
	if (UTPawn(Pawn) != None)
		UTPawn(Pawn).SwitchWeapon(t);
	else if (UTVehicleBase(Pawn) != none)
		UTVehicleBase(Pawn).SwitchWeapon(t);
}

unreliable server function ServerViewSelf()
{
	local rotator POVRotation;
	local vector POVLocation;

	GetPlayerViewPoint( POVLocation, POVRotation );
	SetLocation(POVLocation);
	SetRotation(POVRotation);
	SetBehindView(false);
	SetViewTarget( Self );
}

exec function ViewPlayerByName(string PlayerName);

unreliable server function ServerViewPlayerByName(string PlayerName)
{
	local int i;
	for (i=0;i<WorldInfo.GRI.PRIArray.Length;i++)
	{
		if (WorldInfo.GRI.PRIArray[i].GetPlayerAlias() ~= PlayerName)
		{
			if ( WorldInfo.Game.CanSpectate(self, WorldInfo.GRI.PRIArray[i]) )
			{
				SetViewTarget(WorldInfo.GRI.PRIArray[i]);
			}
			return;
		}
	}

	ClientMessage(MsgPlayerNotFound);
}

exec function ViewObjective()
{
	ServerViewObjective();
}

unreliable server function ServerViewObjective()
{
	if ( (UTGame(WorldInfo.Game) != none) && (WorldInfo.NetMode == NM_Standalone) )
		UTGame(WorldInfo.Game).ViewObjective(self);
}

exec function PrevWeapon()
{
	if ( (Vehicle(Pawn) != None) || (Pawn == None) )
	{
		AdjustCameraScale(true);
	}
	else if (!Pawn.IsInState('FeigningDeath'))
	{
		Super.PrevWeapon();
	}
}

exec function NextWeapon()
{
	if ( (Vehicle(Pawn) != None) || (Pawn == None) )
	{
		AdjustCameraScale(false);
	}
	else if (!Pawn.IsInState('FeigningDeath'))
	{
		Super.NextWeapon();
	}
}

/** moves the camera in or out */
exec function AdjustCameraScale(bool bIn)
{
	if (Pawn(ViewTarget) != None)
	{
		Pawn(ViewTarget).AdjustCameraScale(bIn);
	}
}

state WaitingForPawn
{
	exec function SwitchWeapon(byte F){}
	exec function ShowQuickPick(){}

	/** called when the actor falls out of the world 'safely' (below KillZ and such) */
	simulated event FellOutOfWorld(class<DamageType> dmgType)
	{
		bCameraOutOfWorld = true;
	}

	function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
	{
		local vector OldLocation;

		OldLocation = Location;
		super.ProcessMove(DeltaTime, NewAccel, DoubleClickMove, DeltaRot);

		if ( bCameraOutOfWorld )
		{
			bCameraOutOfWorld = false;
			SetLocation(OldLocation);
		}
	}

	simulated event GetPlayerViewPoint( out vector out_Location, out Rotator out_Rotation )
	{
		if ( PlayerCamera == None )
		{
			out_Location = Location;
			out_Rotation = BlendedTargetViewRotation;
		}
		else
			Global.GetPlayerViewPoint(out_Location, out_Rotation);
	}
}

state Spectating
{
	exec function SwitchWeapon(byte F){}
	exec function ShowQuickPick(){}

	function BeginState(Name PreviousStateName)
	{
		super.BeginState(PreviousStateName);

		if ( CurrentMapScene != none )
		{
			CurrentMapScene.SceneClient.CloseScene(CurrentMapScene);
		}

		// Ugly hack to change to follow bots around after they are spawned if automated perf testing is enabled.
		// This should be replaced with a more robust solution.
		if( UTGame(WorldInfo.Game)!=None && UTGame(WorldInfo.Game).bAutomatedPerfTesting )
		{
			SetTimer( 5.0f, FALSE, 'SetServerViewNextPlayer' ); // get the spectating going asap instead of waiting for 30secs.  need to wait some as the player will not be spawned yet
			SetTimer( 30.0f, TRUE, 'ServerViewNextPlayer');
		}
	}

	function EndState(Name NextStateName)
	{
		super.EndState(NextStateName);
		// Reset timer set in BeginState.
		ClearTimer( 'ServerViewNextPlayer' );
	}

	function SetServerViewNextPlayer()
	{
		ServerViewNextPlayer();
	}

	/** called when the actor falls out of the world 'safely' (below KillZ and such) */
	simulated event FellOutOfWorld(class<DamageType> dmgType)
	{
		bCameraOutOfWorld = true;
	}

	function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
	{
		local vector OldLocation;

		OldLocation = Location;
		super.ProcessMove(DeltaTime, NewAccel, DoubleClickMove, DeltaRot);

		if ( bCameraOutOfWorld )
		{
			bCameraOutOfWorld = false;
			SetLocation(OldLocation);
		}
	}

	exec function ViewPlayerByName(string PlayerName)
	{
		ServerViewPlayerByName(PlayerName);
	}

	exec function BehindView()
	{
		bForceBehindView = !bForceBehindview;
	}

	/**
	 * The Prev/Next weapon functions are used to move forward and backwards through the player list
	 */

	exec function PrevWeapon()
	{
		ServerViewPrevPlayer();
	}

	exec function NextWeapon()
	{
		ServerViewNextPlayer();
	}

	/**
	 * Fire will select the next/prev objective
	 */
	exec function StartFire( optional byte FireModeNum )
	{
		ServerViewObjective();
	}

	unreliable server function ServerViewObjective()
	{
		if ( UTGame(WorldInfo.Game) != none )
			UTGame(WorldInfo.Game).ViewObjective(self);
	}

	/**
	 * AltFire - Resets to Free Camera Mode
	 */
	exec function StartAltFire( optional byte FireModeNum )
	{
		ServerViewSelf();
	}

	/**
	 * Handle forcing behindview/etc
	 */
	simulated event GetPlayerViewPoint( out vector out_Location, out Rotator out_Rotation )
	{
		// Force first person mode if we're performing automated perf testing.
		if( UTGame(WorldInfo.Game)!=None && UTGame(WorldInfo.Game).bAutomatedPerfTesting )
		{
			SetBehindView(false);
		}
		else if (bBehindview != bForceBehindView && UTPawn(ViewTarget)!=None)
		{
			SetBehindView(bForceBehindView);
		}
		Global.GetPlayerViewPoint(out_Location, out_Rotation);
	}
}

/**
 * This state is used when the player is out of the match waiting to be brought back in
 */
state InQueue extends Spectating
{
	function BeginState(Name PreviousStateName)
	{
		Super.BeginState(PreviousStateName);
		PlayerReplicationInfo.bIsSpectator = true;
	}

	function EndState(Name NextStateName)
	{
		Super.EndState(NextStateName);

		SetBehindView(false);
	}
}


exec function TestMenu(string NewMenu)
{
	local class<UIScene> SceneClass;
	local UIInteraction UIController;

	UIController = LocalPlayer(Player).ViewportClient.UIController;

	LogInternal("#### TestMenu:"@NewMenu);
	if( LocalPlayer(Player) != None)
	{
		SceneClass = class<UIScene> ( DynamicLoadObject(NewMenu, class'Class'));
		LogInternal("### SceneClass:"@SceneClass);
		UIController.SceneClient.CreateMenu(SceneClass, );
	}
}


/** Internal.  Returns FALSE if we're restricted from commincating, TRUE otherwise. */
simulated private function bool CanCommunicate()
{
	if ( (OnlineSub != None) && (OnlineSub.PlayerInterface != None) && (LocalPlayer(Player) != None) )
	{
		return ( OnlineSub.PlayerInterface.CanCommunicate(LocalPlayer(Player).ControllerId) != FPL_Disabled && !bServerMutedText );
	}

	// assume we are allowed to talk unless the online layer specifically says we cannot
	return !bServerMutedText;
}

exec function Talk()
{
	local Console Console;
	local LocalPlayer LP;

	LP = LocalPlayer(Player);
	if ( (LP != None) && CanCommunicate() && (LP.ViewportClient.ViewportConsole != None) )
	{
		Console = LocalPlayer(Player).ViewportClient.ViewportConsole;
		Console.StartTyping("Say ");
	}
}

exec function TeamTalk()
{
	local Console Console;
	local LocalPlayer LP;

	LP = LocalPlayer(Player);
	if ( (LP != None) && CanCommunicate() && (LP.ViewportClient.ViewportConsole != None) )
	{
		Console = LocalPlayer(Player).ViewportClient.ViewportConsole;
		Console.StartTyping("TeamSay ");
	}
}

exec function ShowMap()
{
	local byte DesiredBase;

	if( (UTOnslaughtGRI(WorldInfo.GRI) != None ))
	{
		ShowMidGameMenu('MapTab',true);
	}
	else if ( (UTCTFHUD(myHUD) != None) && (PlayerReplicationInfo != None) && (PlayerReplicationInfo.Team != None) )
	{
		DesiredBase = PlayerReplicationInfo.bHasFlag ? PlayerReplicationInfo.Team.TeamIndex : (1 - PlayerReplicationInfo.Team.TeamIndex);
		BasePath(DesiredBase);
	}
	else if ( ClassIsChildOf(WorldInfo.GRI.GameClass, class'UTGreedGame') )
	{
		DesiredBase = 1 - PlayerReplicationInfo.Team.TeamIndex;
		BasePath(DesiredBase);
	}
}

server reliable function ServerViewingMap(bool bNewValue)
{
	bViewingMap = bNewValue;
}

client reliable function ShowHudMap()
{
	local UTUITabPage_MapTab MapTab;
	local UTUIScene_MidGameMenu CurrentMidGameMenu;

	CurrentMidGameMenu = ShowMidGameMenu('MapTab',true);

	if ( CurrentMidGameMenu != none )
	{
		MapTab = UTUITabPage_MapTab( CurrentMidGameMenu.FindChild('MapTab',true) );
		if ( MapTab != none )
		{
			MapTab.AllowTeleporting();
		}
	}

}
exec function ShowMenu()
{
	local Sequence GameSequence;
	local array<SequenceObject> SkipEvents;
	local int i;

	// on host, check if should skip tutorial
	if ( Role == ROLE_Authority && WorldInfo.GRI.bMatchHasBegun && UTGame(WorldInfo.Game) != None &&
		(WorldInfo.IsPlayInEditor() || UTCinematicGame(WorldInfo.Game) != None || UTGame(WorldInfo.Game).SinglePlayerMissionID != INDEX_NONE) )
	{
		//@HACK: Sinkhole's Kismet script has a bug that breaks things if you skip the tutorial less than a second in
		if (!(string(WorldInfo.GetPackageName()) ~= "WAR-Sinkhole") || WorldInfo.GRI.ElapsedTime >= 2)
		{
			GameSequence = WorldInfo.GetGameSequence();
			if (GameSequence != None)
			{
				GameSequence.FindSeqObjectsByClass(class'UTSeqEvent_SkipCinematic', true, SkipEvents);
				for (i = 0; i < SkipEvents.length; i++)
				{
					if ( UTSeqEvent_SkipCinematic(SkipEvents[i]).bEnabled &&
						UTSeqEvent_SkipCinematic(SkipEvents[i]).CheckActivate(self, self) )
					{
						// if we skipped something, don't show the menu
						return;
					}
				}
			}
		}
	}
	ShowMidGameMenu('',true);
}

exec function ShowVoteMenu()
{
	if (VoteRI != none)
		ShowMidGameMenu('VoteTab', True);
}

function UTUIScene_MidGameMenu ShowMidGameMenu(optional name TabTag,optional bool bEnableInput)
{
	local UTGameReplicationInfo GRI;

	if ( CommandMenu != none )
	{
		CommandMenu.CloseScene(CommandMenu);
		CommandMenu = none;
	}


    if (bInitialProcessingComplete)
    {
		GRI = UTGameReplicationInfo(WorldInfo.GRI);
		if ( GRI != none )
		{
			return GRI.ShowMidGameMenu(self, TabTag, bEnableInput);
		}
	}

	return none;
}


/* epic ===============================================
* ::ClientGameEnded
*
* Replicated equivalent to GameHasEnded().
*
 * @param	EndGameFocus - actor to view with camera
 * @param	bIsWinner - true if this controller is on winning team
* =====================================================
*/
reliable client function ClientGameEnded(optional Actor EndGameFocus, optional bool bIsWinner)
{
	local UTTimedPowerup Powerup;

	if( EndGameFocus == None )
		ServerVerifyViewTarget();
	else
	{
			SetViewTarget(EndGameFocus);
		}

	if ( (PlayerReplicationInfo != None) && !PlayerReplicationInfo.bOnlySpectator )
		PlayWinMessage( bIsWinner );

	ClientEndZoom();

	GotoState('RoundEnded');

	SetBehindView(true);

	ForEach Pawn.InvManager.InventoryActors( class'UTTimedPowerup', Powerup )
	{
		Powerup.ClientSetTimeRemaining(0.01);
	}
}

/* epic ===============================================
* ::RoundHasEnded
*
 * @param	EndRoundFocus - actor to view with camera
* =====================================================
*/
function RoundHasEnded(optional Actor EndRoundFocus)
{
	SetViewTarget(EndRoundFocus);
	ClientRoundEnded(EndRoundFocus);
	GotoState('RoundEnded');
}

/* epic ===============================================
* ::ClientRoundEnded
*
 * @param	EndRoundFocus - actor to view with camera
* =====================================================
*/
reliable client function ClientRoundEnded(Actor EndRoundFocus)
{
	if( EndRoundFocus == None )
		ServerVerifyViewTarget();
	else
	{
		SetViewTarget(EndRoundFocus);
	}
	ClientEndZoom();

	GotoState('RoundEnded');

	SetBehindView(true);
}

/* epic ===============================================
* ::CheckBulletWhip
*
 * @param	BulletWhip - whip sound to play
 * @param	FireLocation - where shot was fired
 * @param	FireDir	- direction shot was fired
 * @param	HitLocation - impact location of shot
* =====================================================
*/
function CheckBulletWhip(soundcue BulletWhip, vector FireLocation, vector FireDir, vector HitLocation)
{
	local vector PlayerDir;
	local float Dist, PawnDist;

	if ( ViewTarget != None  )
	{
		// if bullet passed by close enough, play sound
		// first check if bullet passed by at all
		PlayerDir = ViewTarget.Location - FireLocation;
		Dist = PlayerDir Dot FireDir;
		if ( (Dist > 0) && ((FireDir Dot (HitLocation - ViewTarget.Location)) > 0) )
		{
			// check distance from bullet to vector
			PawnDist = VSize(PlayerDir);
			if ( Square(PawnDist) - Square(Dist) < 40000 )
			{
				// check line of sight
				if ( FastTrace(ViewTarget.Location + class'UTPawn'.default.BaseEyeheight*vect(0,0,1), FireLocation + Dist*FireDir) )
				{
					PlaySound(BulletWhip, true,,, HitLocation);
				}
			}
		}
	}
}
/* epic ===============================================
* ::PawnDied - Called when a pawn dies
*
 * @param	P - The pawn that died
* =====================================================
*/

function PawnDied(Pawn P)
{
	LastAutoObjective = None;
	Super.PawnDied(P);
	ClientPawnDied();
}

/**
 * Client-side notification that the pawn has died.
 */
reliable client simulated function ClientPawnDied()
{
	// Unduck if ducking

	if (UTPlayerInput(PlayerInput) != none)
	{
		UTPlayerInput(PlayerInput).bDuck = 0;
	}

	// End Zooming

	EndZoom();
}

/** shows the path to the specified team's base or other main objective */
exec function BasePath(byte Num)
{
	if (PlayerReplicationInfo.Team != None)
	{
		ServerShowPathToBase(num);
	}
}

reliable server function ServerShowPathToBase(byte TeamNum)
{
	if (Pawn != None && WorldInfo.TimeSeconds - LastShowPathTime > 0.5)
	{
		LastShowPathTime = WorldInfo.TimeSeconds;

		UTGame(WorldInfo.Game).ShowPathTo(self, TeamNum);
	}
}

exec function BecomeActive()
{
	if (PlayerReplicationInfo.bOnlySpectator)
	{
		ServerBecomeActivePlayer();
	}
}

//spectating player wants to become active and join the game
reliable server function ServerBecomeActivePlayer()
{
	local UTGame Game;

	Game = UTGame(WorldInfo.Game);
	if ( PlayerReplicationInfo.bOnlySpectator && !WorldInfo.IsInSeamlessTravel() && HasClientLoadedCurrentWorld()
		&& Game != None && Game.AllowBecomeActivePlayer(self) )
	{
		SetBehindView(false);
		FixFOV();
		ServerViewSelf();
		PlayerReplicationInfo.bOnlySpectator = false;
		Game.NumSpectators--;
		Game.NumPlayers++;
		PlayerReplicationInfo.Reset();
		BroadcastLocalizedMessage(Game.GameMessageClass, 1, PlayerReplicationInfo);
		if (Game.bTeamGame)
		{
			//@FIXME: get team preference!
			Game.ChangeTeam(self, Game.PickTeam(0, None), false);
		}
		if (!Game.bDelayedStart)
		{
			// start match, or let player enter, immediately
			Game.bRestartLevel = false;  // let player spawn once in levels that must be restarted after every death
			if (Game.bWaitingToStartMatch)
			{
				Game.StartMatch();
			}
			else
			{
				Game.RestartPlayer(self);
			}
			Game.bRestartLevel = Game.Default.bRestartLevel;
		}
		else
		{
			GotoState('PlayerWaiting');
			ClientGotoState('PlayerWaiting');
		}

		ClientBecameActivePlayer();


		if (WorldInfo.Game.BaseMutator != none)
			WorldInfo.Game.BaseMutator.NotifyBecomeActivePlayer(Self);

		if (UTGame(WorldInfo.Game).VoteCollector != none)
			UTGame(WorldInfo.Game).VoteCollector.NotifyBecomeActivePlayer(Self);
	}
}

reliable client function ClientBecameActivePlayer()
{
	UpdateURL("SpectatorOnly", "", false);
}

exec function FlushDebug()
{
	FlushPersistentDebugLines();
}

/*********************************************************************************************
 * Zooming Functions
 *********************************************************************************************/

/** called through camera anim code when it modifies FOVAngle */
function OnUpdatePropertyFOVAngle()
{
	bCurrentCamAnimAffectsFOV = true;
	// adjust the anim's FOV so that it is relative to our desired FOV
	FOVAngle = DesiredFOV + (FOVAngle - 90.0);
}

/**
 * Called each frame from PlayerTick this function is used to transition towards the DesiredFOV
 * if not already at it.
 *
 * @Param	DeltaTime 	-	Time since last update
 */
function AdjustFOV(float DeltaTime)
{
	local float DeltaFOV;

	if (FOVAngle != DesiredFOV && (!bCurrentCamAnimAffectsFOV || CameraAnimPlayer.bFinished))
	{
		if (bNonlinearZoomInterpolation)
		{
			// do nonlinear interpolation
			FOVAngle = FInterpTo(FOVAngle, DesiredFOV, DeltaTime, FOVNonlinearZoomInterpSpeed);
		}
		else
		{
			// do linear interpolation
			if ( FOVLinearZoomRate > 0.0 )
			{
				DeltaFOV = FOVLinearZoomRate * DeltaTime;

				if (FOVAngle > DesiredFOV)
				{
					FOVAngle = FMax( DesiredFOV, (FOVAngle - DeltaFOV) );
				}
				else
				{
					FOVAngle = FMin( DesiredFOV, (FOVAngle + DeltaFOV) );
				}
			}
			else
			{
				FOVAngle = DesiredFOV;
			}
		}
	}
}

/**
 * This function will cause the PlayerController to begin zooming to a new FOV Level.
 *
 * @Param	NewDesiredFOV		-	The new FOV Value to head towards
 * @Param	NewZoomRate			- 	The rate of transition in degrees per second
 */

simulated function StartZoom(float NewDesiredFOV, float NewZoomRate)
{
	FOVLinearZoomRate = NewZoomRate;
	DesiredFOV = NewDesiredFOV;

	// clear out any nonlinear zoom info
	bNonlinearZoomInterpolation = FALSE;
	FOVNonlinearZoomInterpSpeed = 0.f;
}

/*
 * @Param	bNonlinearInterp	-	TRUE to use FInterpTo, which provides for a nonlinear interpolation with a decelerating arrival characteristic.
 *									FALSE for Linear interpolation.
 */
simulated function StartZoomNonlinear(float NewDesiredFOV, float NewZoomInterpSpeed)
{
	DesiredFOV = NewDesiredFOV;
	FOVNonlinearZoomInterpSpeed = NewZoomInterpSpeed;

	// clear out any linear zoom info
	bNonlinearZoomInterpolation = TRUE;
	FOVLinearZoomRate = 0.f;
}

/**
 * This function will stop the zooming process keeping the current FOV Angle
 */
simulated function StopZoom()
{
	DesiredFOV = FOVAngle;
	FOVLinearZoomRate = 0.0f;
}

/**
 * This function will end a zoom and reset the FOV to the default value
 */

simulated function EndZoom()
{
	DesiredFOV = DefaultFOV;
	FOVAngle = DefaultFOV;
	FOVLinearZoomRate = 0.0f;
	FOVNonlinearZoomInterpSpeed = 0.f;
}

/** Ends a zoom, but interpolates nonlinearly back to the default value. */
simulated function EndZoomNonlinear(float ZoomInterpSpeed)
{
	DesiredFOV = DefaultFOV;
	FOVNonlinearZoomInterpSpeed = ZoomInterpSpeed;

	// clear out any linear zoom info
	bNonlinearZoomInterpolation = TRUE;
	FOVLinearZoomRate = 0.f;
}

/**
 * Allows the server to tell the client to end zoom
 */
reliable simulated client function ClientEndZoom()
{
	EndZoom();
}

function UpdateRotation( float DeltaTime )
{
	local rotator DeltaRot;

	if (bDebugFreeCam)
	{
		// Calculate Delta to be applied on ViewRotation
		DeltaRot.Yaw	= PlayerInput.aTurn;
		DeltaRot.Pitch	= PlayerInput.aLookUp;
		ProcessViewRotation( DeltaTime, DebugFreeCamRot, DeltaRot );
	}
	else
	{
		super.UpdateRotation(DeltaTime);
	}
}

/**
 * Show the Quick Pick Scene
 */
exec function ShowQuickPick()
{
	if ( bDisableQuickPick || (Pawn != none && Vehicle(Pawn) != none) || CommandMenu != none )
	{
		PrevWeapon();
	}
	else
	{
		//SetTimer( 0.250f, FALSE, 'AtuallyShowQuickPickMenu' );
		UTHUD(myHUD).ShowQuickPickMenu(true);
	}
}

/**
 * Hide the Quick Pick Scene
 */
exec function HideQuickPick()
{
	// so if the timer is going then we have released the button before the QuickPick Menu popped up and we want to do NextWeapon()
	if( IsTimerActive( 'AtuallyShowQuickPickMenu' ) == TRUE )
	{
		ClearTimer( 'AtuallyShowQuickPickMenu' );
		PrevWeapon();
	}
	// we held the button down long enough for timer to run out and we actually want the QuickPick to be hidden
	else
	{
		UTHUD(myHUD).ShowQuickPickMenu(false);
	}
}

/** This will show the QuickPick Menu! **/
function AtuallyShowQuickPickMenu()
{
	UTHUD(myHUD).ShowQuickPickMenu(true);
}




/**
 * Turn the QuickPick System off
 */
exec function ToggleQuickPickOff()
{
	if ( bDisableQuickPick )
	{
		bDisableQuickPick = false;
	}
	else
	{

		// FIXMEUI - Tell hud to show the quickpick menu
		bDisableQuickPick=true;
	}
}

/** debug command for bug reports */
exec function GetPlayerLoc()
{
	LogInternal("Location:" @ Location,'PlayerLoc');
	LogInternal("Rotation:" @ Rotation,'PlayerLoc');
}

/** Called from the UTTeamGameMessage, this will cause all TeamColored Images on the hud to pulse. */
function PulseTeamColor()
{
	PulseTimer = default.PulseTimer;
	bPulseTeamColor = true;
}

function SetPawnConstructionScene(bool bShow)
{
	bConstructioningMeshes = bShow;
}

/** called when the GRI finishes processing custom character meshes */
function CharacterProcessingComplete()
{
	local UTUIScene_MidGameMenu Menu;
	local UTGameReplicationInfo GRI;
	local string LastMovie;
	local LocalPlayer LP;

	LastMovie = class'Engine'.Static.GetLastMovieName();

	if(InStr(LastMovie, "UT_loadmovie") != -1)
	{
		// stop the loading movie that was up during precaching
		class'Engine'.static.StopMovie();
	}

	SetPawnConstructionScene(false);
	bInitialProcessingComplete = true;
	ServerSetProcessingComplete();

	// If the match hasn't started, bring up the map

	GRI = UTGameReplicationInfo(WorldInfo.GRI);

//	if ( WorldInfo.NetMode != NM_Standalone && GRI != none && !GRI.bMatchHasBegun )
	if ( GRI != none && !GRI.bMatchHasBegun && !GRI.bStoryMode && !bAlreadyReset && WorldInfo.NetMode != NM_Standalone )
	{
		Menu = ShowMidGameMenu('ScoreTab',true);
		bAlreadyReset = true;
		if ( Menu != none )
		{
			Menu.Reset();
		}
	}

	// if the controller was yanked while we were loading, we couldn't pause the game because that would cause character construction
	// to never complete, so check for a missing controller now

	// don't check for None so that we know if we don't have a valid OnlineSub at this point.
	LP = LocalPlayer(Player);
	if ( LP != None )
	{
		if ( !OnlineSub.SystemInterface.IsControllerConnected(LP.ControllerId) )
		{
			OnControllerChanged(LP.ControllerId, false);
		}
	}
}


/** called after any initial clientside processing is complete to allow the client to spawn in */
reliable server function ServerSetProcessingComplete()
{
	bInitialProcessingComplete = true;
}

/** this is used in seamless travel when the PlayerController class got replaced to force bInitialProcessingComplete to true */
reliable client function ClientSetProcessingComplete()
{
	bInitialProcessingComplete = true;
}

event NotifyLoadedWorld(name WorldPackageName, bool bFinalDest)
{
	local UTGameReplicationInfo GRI;
	local UTPlayerReplicationInfo PRI;
	local int i;
	local UTPlayerController PC;

	Super.NotifyLoadedWorld(WorldPackageName, bFinalDest);

	if (!bFinalDest)
	{
		GRI = UTGameReplicationInfo(WorldInfo.GRI);
		if (GRI != None)
		{
			// look for players that need a custom character mesh
			foreach LocalPlayerControllers(class'UTPlayerController', PC)
			{
				PRI = UTPlayerReplicationInfo(PC.PlayerReplicationInfo);
				if (PRI != None && (PRI.CharacterMesh == None || PRI.bUsingReplacementCharacter))
				{
					GRI.ProcessCharacterData(PRI);
				}
			}
			for (i = 0; i < GRI.PRIArray.length; i++)
			{
				PRI = UTPlayerReplicationInfo(GRI.PRIArray[i]);
				if (PRI != None && (PRI.CharacterMesh == None || PRI.bUsingReplacementCharacter))
				{
					GRI.ProcessCharacterData(PRI);
				}
			}

			if (GRI.IsProcessingCharacterData())
			{
				WorldInfo.SetSeamlessTravelMidpointPause(true);
			}
		}
	}
}

function bool CanRestartPlayer()
{
	local UTGame Game;

	Game = UTGame(WorldInfo.Game);
	return ((bInitialProcessingComplete || (Game != None && Game.bQuickStart)) && Super.CanRestartPlayer());
}

/**
 * Sets the ClanTag for this player.
 *
 * @param InClanTag	New clan tag for the player.
 */
reliable server function ServerSetClanTag(string InClanTag)
{
	if ( Len(InClanTag) > 16 )
	{
		InClanTag = Left(InClanTag, 16);
	}
	UTPlayerReplicationInfo(PlayerReplicationInfo).ClanTag = InClanTag;
}


/**
 * @return Returns the index of this PC in the GamePlayers array.
 */
native function int GetUIPlayerIndex();

/**
 * Sets the current gamma value.
 *
 * @param New Gamma Value, must be between 0.0 and 1.0
 */
native function SetGamma(float GammaValue);

/**
 * Sets whether or not hardware physics are enabled.
 *
 * @param bEnabled	Whether to enable the physics or not.
 */
native function SetHardwarePhysicsEnabled(bool bEnabled);

/** Loads the player's custom character from their profile. */
function LoadCharacterFromProfile(UTProfileSettings Profile)
{
	local string OutStringValue;
	local bool bRandomCharacter;

	bRandomCharacter = true;

	// HACK to always return same char
	//ServerSetCharacterData(class'UTCustomChar_Data'.static.CharDataFromString("C,IRNM,B,NONE,NONE,NONE,A,A,B,A,C,T,T"));
	//return;

	// get character info and send to server
	if(Profile.GetProfileSettingValueStringByName('CustomCharData', OutStringValue))
	{
		if(Len(OutStringValue)>0)
		{
			LogInternal("UTPlayerController::LoadCharacterFromProfile() - Loaded character data from profile.");
			ServerSetCharacterData(GetPlayerCustomCharData(OutStringValue));
			bRandomCharacter = false;
		}
	}

	// Autogenerate character data if they do not have a character set.
	if (bRandomCharacter)
	{
		if(UTPlayerReplicationInfo(PlayerReplicationInfo) == None || UTPlayerReplicationInfo(PlayerReplicationInfo).CharacterData.FamilyID == "")
		{
			LogInternal("UTPlayerController::LoadCharacterFromProfile() - Character data not found, generating a random character.");
			ServerSetCharacterData(class'UTCustomChar_Data'.static.MakeRandomCharData());
		}
		else
		{
			ServerSetCharacterData(UTPlayerReplicationInfo(PlayerReplicationInfo).CharacterData);
		}
	}
}

function SendMessage(PlayerReplicationInfo Recipient, name MessageType, float Wait, optional class<DamageType> DamageType)
{
	if ( (MessageType == 'TAUNT') && (Recipient != None) && (UTPlayerController(Recipient.Owner) != None) && !UTPlayerController(Recipient.Owner).bAutoTaunt )
	{
		// don't autotaunt people who don't want it
		return;
	}
	UTPlayerReplicationInfo(PlayerReplicationInfo).VoiceClass.static.SendVoiceMessage(self, Recipient, MessageType, DamageType);
}

/**
  * Receive a taunt from a player - process locally, since character may be different on client
  */
unreliable client function ReceiveTauntMessage( UTPlayerReplicationInfo SenderPRI, Name EmoteTag, Int Seed)
{
	if ( SenderPRI.VoiceClass != None )
	{
		SenderPRI.VoiceClass.static.ClientPlayTauntAnim(self, SenderPRI, EmoteTag, Seed);
	}
}

/**
  * Receive a voice message from a bot - process locally, since character may be different on client
  */
unreliable client function ReceiveBotVoiceMessage(UTPlayerReplicationInfo SenderPRI, int MessageIndex, object LocationObject)
{
	if ( SenderPRI.VoiceClass != None )
	{
		ReceiveLocalizedMessage( SenderPRI.VoiceClass, MessageIndex, SenderPRI,, LocationObject );
	}
}

/** @return Whether or not the user has a keyboard plugged-in. */
native simulated function bool IsKeyboardAvailable() const;

/** @return Whether or not the user has a mouse plugged-in. */
native simulated function bool IsMouseAvailable() const;

/** Gathers player settings from the client's profile. */
exec function RetrieveSettingsFromProfile()
{
	LoadSettingsFromProfile(true);
}

/**
 * Updates sound volumes and screen brightness.
 * Done in a seperate function so it can be called by the sliders to update these values in real time without doing a lot of extra work.
 */
function UpdateVolumeAndBrightness()
{
	local int OutIntValue;
	local UTProfileSettings Profile;

	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);

	// Set volumes
	if(Profile.GetProfileSettingValueIntByName('SFXVolume', OutIntValue))
	{
		SetAudioGroupVolume( 'SFX', (OutIntValue / 10.0f) );
	}

	if(Profile.GetProfileSettingValueIntByName('VoiceVolume', OutIntValue))
	{
		SetAudioGroupVolume( 'Dialog', (OutIntValue / 10.0f) );
	}

	if(Profile.GetProfileSettingValueIntByName('AnnouncerVolume', OutIntValue))
	{
		SetAudioGroupVolume( 'Announcer', (OutIntValue / 10.0f) );
	}

	if(Profile.GetProfileSettingValueIntByName('MusicVolume', OutIntValue))
	{
		SetAudioGroupVolume( 'Music', (OutIntValue / 10.0f) );
	}

	if(Profile.GetProfileSettingValueIntByName('AmbianceVolume', OutIntValue))
	{
		SetAudioGroupVolume( 'Ambient', (OutIntValue / 10.0f) );
	}

	// Set Gamma
	if(Profile.GetProfileSettingValueIntByName('Gamma', OutIntValue))
	{
		SetGamma(OutIntValue / 10.0f);
	}
}

function LoadSettingsFromProfile(bool bLoadCharacter)
{
	local int PlayerIndex, OutIntValue, NewNetSpeed;
	local float OutFloatValue;
	local string OutStringValue;
	local UTProfileSettings Profile;
	local UTHUD MyUTHUD;
	local UTWeapon W;

	if (LocalPlayer(Player) == None)
	{
		return;
	}

	// If we are NOT epic internal, then do not set any settings.
	if (!IsEpicInternal())
	{
		LogInternal("UTPlayerController::LoadSettingsFromProfile() - Not an Epic internal build, skipping setting profile settings.");
		return;
	}

	MyUTHUD = UTHUD(myHUD);
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);

	if(Profile != none)
	{
		PlayerIndex = GetUIPlayerIndex();

		LogInternal("Retrieving Profile Settings for UI PlayerIndex " $ PlayerIndex);

		// If we're the 2nd player and we are not logged-in, then set the profile to defaults.
		if(PlayerIndex == 1 && OnlineSub!=None && OnlineSub.PlayerInterface!=None && OnlineSub.PlayerInterface.GetLoginStatus(LocalPlayer(Player).ControllerId)==LS_NotLoggedIn)
		{
			LogInternal("UTPlayerController::OnReadProfileSettingsComplete() - 2nd player not logged in, resetting profile to defaults, ControllerId: " $ LocalPlayer(Player).ControllerId);
			ResetProfileToDefault(OnlinePlayerData.ProfileProvider.Profile);
		}

		///////////////////////////////////////////////////////////////////////////
		// Player Custom Character
		///////////////////////////////////////////////////////////////////////////

		if(Profile.GetProfileSettingValueId(class'UTProfileSettings'.const.UTPID_AllowCustomCharacters, OutIntValue))
		{
			class'UTGameReplicationInfo'.default.bForceDefaultCharacter = (OutIntValue == UTPID_VALUE_NO);
			if (UTGameReplicationInfo(WorldInfo.GRI) != None)
			{
				UTGameReplicationInfo(WorldInfo.GRI).bForceDefaultCharacter = class'UTGameReplicationInfo'.default.bForceDefaultCharacter;
			}
		}

 		if(Profile.GetProfileSettingValueId(class'UTProfileSettings'.const.UTPID_AlwaysLoadCustomCharacters, OutIntValue))
 		{
 			class'UTGameReplicationInfo'.default.bAlwaysLoadCustomCharacters = (OutIntValue == UTPID_VALUE_YES);
 			if (UTGameReplicationInfo(WorldInfo.GRI) != None)
 			{
 				UTGameReplicationInfo(WorldInfo.GRI).bAlwaysLoadCustomCharacters = class'UTGameReplicationInfo'.default.bAlwaysLoadCustomCharacters;
			}
 		}

		if (bLoadCharacter)
		{
			LoadCharacterFromProfile(Profile);
		}

		///////////////////////////////////////////////////////////////////////////
		// Shared Options - These options are shared between all players on this machine.
		///////////////////////////////////////////////////////////////////////////

		// Only allow player 0 to set shared options.
		if(PlayerIndex==0)
		{
			UpdateVolumeAndBrightness();
		}

		///////////////////////////////////////////////////////////////////////////
		// Video Options
		///////////////////////////////////////////////////////////////////////////

		// PostProcessPreset
		if(Profile.GetProfileSettingValueIdByName('PostProcessPreset', OutIntValue))
		{
			if(OutIntValue < PostProcessPresets.length)
			{
				Player.PP_DesaturationMultiplier = PostProcessPresets[OutIntValue].Desaturation;
				Player.PP_HighlightsMultiplier = PostProcessPresets[OutIntValue].Highlights;
				Player.PP_MidTonesMultiplier = PostProcessPresets[OutIntValue].MidTones;
				Player.PP_ShadowsMultiplier = PostProcessPresets[OutIntValue].Shadows;
			}
		}

		/*
		// DefaultFOV
		if(Profile.GetProfileSettingValueIntByName('DefaultFOV', OutIntValue))
		{
			DefaultFOV = Clamp(OutIntValue, 80, 120);
		}
		*/

		if(Profile.GetProfileSettingValueIdByName('EnableHardwarePhysics', OutIntValue))
		{
			SetHardwarePhysicsEnabled(OutIntValue==UTPID_VALUE_YES);
		}

		if(Profile.GetProfileSettingValueIdByName('Subtitles', OutIntValue))
		{
			SetShowSubtitles(OutIntValue==UTPID_VALUE_YES);
		}



		///////////////////////////////////////////////////////////////////////////
		// Audio Options
		///////////////////////////////////////////////////////////////////////////

		// AnnounceSetting
		if (Announcer != None && Profile.GetProfileSettingValueIdByName('AnnounceSetting', OutIntValue))
		{
			Announcer.AnnouncerLevel = byte(OutIntValue);
		}

		// AutoTaunt
		if(Profile.GetProfileSettingValueIdByName('AutoTaunt', OutIntValue))
		{
			SetAutoTaunt(OutIntValue==UTPID_VALUE_YES);
		}

		/* - Disabled
		// MessageBeep
		if(Profile.GetProfileSettingValueIdByName('MessageBeep', OutIntValue))
		{
			if (myHUD != None)
			{
				myHUD.bMessageBeep = (OutIntValue==UTPID_VALUE_YES);
			}
			class'HUD'.default.bMessageBeep = (OutIntValue==UTPID_VALUE_YES);
		}
		*/

		// MuteVoice
		if( Profile.GetProfileSettingValueIdByName( 'MuteVoice', OutIntValue ) )
		{
			if( VoiceInterface != None )
			{
				// Is muting enabled?
				if( OutIntValue == 1 )
				{
					// Prevent us from hearing anyone
					VoiceInterface.MuteAll( PlayerIndex, false );		// Allow friends?
				}
				else
				{
					// Allow us to hear everyone
					VoiceInterface.UnmuteAll( PlayerIndex );
				}
			}
		}

		// TextToSpeechMode
		if(Profile.GetProfileSettingValueIdByName('TextToSpeechMode', OutIntValue))
		{
			switch(OutIntValue)
			{
			case TTSM_None:
				bNoTextToSpeechVoiceMessages=true;
				bTextToSpeechTeamMessagesOnly=false;
				break;
			case TTSM_TeamOnly:
				bNoTextToSpeechVoiceMessages=false;
				bTextToSpeechTeamMessagesOnly=true;
				break;
			case TTSM_All:default:
				bNoTextToSpeechVoiceMessages=false;
				bTextToSpeechTeamMessagesOnly=false;
			}
		}

		///////////////////////////////////////////////////////////////////////////
		// Input Options
		///////////////////////////////////////////////////////////////////////////

		if ( PlayerInput != none )
		{
			// Invert Y
			if(Profile.GetProfileSettingValueIdByName('InvertY', OutIntValue))
			{
				PlayerInput.bInvertMouse = (OutIntValue==PYIO_On);
			}

			// Invert X
			if(Profile.GetProfileSettingValueIdByName('InvertX', OutIntValue))
			{
				PlayerInput.bInvertTurn = (OutIntValue==PXIO_On);
			}

			// Mouse Smoothing
			if(Profile.GetProfileSettingValueIdByName('MouseSmoothing', OutIntValue))
			{
				PlayerInput.bEnableMouseSmoothing = (OutIntValue==UTPID_VALUE_YES);
			}

			// Mouse Sensitivity (Game)
			if(Profile.GetProfileSettingValueIntByName('MouseSensitivityGame', OutIntValue))
			{
				// Fix up non-patch values
				if ( OutIntValue < 11 )
				{
					OutIntValue = 5 * OutIntValue * 100;
					Profile.SetProfileSettingValueInt(423, OutIntValue); // UTPID_MouseSensitivityGame = 423
			}
				PlayerInput.MouseSensitivity = OutIntValue / 100.0;	// Mouse sensitivity is between 0-100
			}

			// MouseAccelTreshold
			if(Profile.GetProfileSettingValueIntByName('MouseAccelTreshold', OutIntValue))
			{
				// @todo: Hookup
				//PlayerInput.MouseAccelTreshold = OutIntValue / 10.0f;
			}

			// ReduceMouseLag
			if(Profile.GetProfileSettingValueIdByName('ReduceMouseLag', OutIntValue))
			{
				// @todo: Hookup
				//PlayerInput.ReduceMouseLag = (OutIntValue==UTPID_VALUE_YES);
			}

			// Enable Joystick
			if(Profile.GetProfileSettingValueIdByName('EnableJoystick', OutIntValue))
			{
				if ( OutIntValue==UTPID_VALUE_YES )
				{
					ConsoleCommand("ALLOWJOYSTICKINPUT");
				}
				else
				{
					ConsoleCommand("DISABLEJOYSTICKINPUT");
				}
			}

			// Vehicle control type
			if(Profile.GetProfileSettingValueIdByName('VehicleControls', OutIntValue))
			{
				VehicleControlType = EUTVehicleControls(OutIntValue);
			}

			// DodgeDoubleClickTime
			if(Profile.GetProfileSettingValueIntByName('DodgeDoubleClickTime', OutIntValue))
			{
				PlayerInput.DoubleClickTime = OutIntValue / 100.0f;
			}

			// ControllerSensitivityMultiplier
			if(Profile.GetProfileSettingValueIntByName('ControllerSensitivityMultiplier', OutIntValue))
			{
				UTPlayerInput(PlayerInput).SensitivityMultiplier = float(OutIntValue) / 10.0f;
			}
		}

		///////////////////////////////////////////////////////////////////////////
		// Game Options
		///////////////////////////////////////////////////////////////////////////

		// Crosshair Type
		if(Profile.GetProfileSettingValueIdByName('CrosshairType', OutIntValue))
		{
			switch(OutIntValue)
			{
			case CHT_None:
				bSimpleCrosshair=false;
				bNoCrosshair=true;
				break;
			case CHT_Simple:
				bSimpleCrosshair=true;
				bNoCrosshair=false;
				break;
			case CHT_Normal:default:
				bSimpleCrosshair=false;
				bNoCrosshair=false;
				break;
			}
		}

		// Weapon Bob
		if(Profile.GetProfileSettingValueIdByName('ViewBob', OutIntValue))
		{
			class'UTPawn'.default.bWeaponBob = (OutIntValue == PYIO_On);
			if (UTPawn(Pawn) != None)
			{
				UTPawn(Pawn).bWeaponBob = class'UTPawn'.default.bWeaponBob;
			}
		}

		// GoreLevel
		if(Profile.GetProfileSettingValueIdByName('GoreLevel', OutIntValue))
		{
			class'GameInfo'.default.GoreLevel = OutIntValue;
			if ( (class'UTOnslaughtFlag'.default.OrbString ~= "KUGEL") && class'UTGame'.static.IsLowGoreVersion() )
			{
				class'GameInfo'.default.GoreLevel = 1;
			}
		}

		/* - Disabled
		// EnableDodging
		if(Profile.GetProfileSettingValueIdByName('DodgingEnabled', OutIntValue))
		{
			bEnableDodging = (OutIntValue==UTPID_VALUE_YES);
		}
		*/

		// WeaponSwitchOnPickup
		if(Profile.GetProfileSettingValueIdByName('WeaponSwitchOnPickup', OutIntValue))
		{
			bNeverSwitchOnPickup = (OutIntValue != UTPID_VALUE_YES);
		}

		// Auto Aim
		if(Profile.GetProfileSettingValueIdByName('AutoAim', OutIntValue))
		{
			bAimingHelp = (OutIntValue==PAAO_On);
		}

		// NetworkConnection
		if(Profile.GetProfileSettingValueIdByName('NetworkConnection', OutIntValue))
		{
			// @todo: Find reasonable values for these.
			switch(OutIntValue)
			{
			case NETWORKTYPE_Modem:
				NewNetSpeed = 2600;
				break;
			case NETWORKTYPE_ISDN:
				NewNetSpeed = 7000;
				break;
			case NETWORKTYPE_Cable:
				NewNetSpeed = 10000;
				break;
			case NETWORKTYPE_LAN:
				NewNetSpeed = 15000;
				break;
			default:
				NewNetSpeed = 10000;
				break;
			}
			SetNetSpeed(NewNetSpeed);
			ServerSetNetSpeed(NewNetSpeed);
			LogInternal("UTPlayerController - Setting netspeed to "$NewNetSpeed);
		}

		// DynamicNetSpeed
		if(Profile.GetProfileSettingValueIdByName('DynamicNetspeed', OutIntValue))
		{
			bDynamicNetSpeed = (OutIntValue==UTPID_VALUE_YES);
		}

		// Set the player's name to their profile id.
			SetName(OnlinePlayerData.PlayerNick);
			ServerSetAlias(OnlinePlayerData.PlayerNick);

			// ClanTag
			if(Profile.GetProfileSettingValueByName('ClanTag', OutStringValue))
			{
			if ( Len(OutStringValue) > 16 )
			{
				OutStringValue = Left(OutStringValue, 16);
			}
				ServerSetClanTag(OutStringValue);
			}

		// SpeechRecognition
		/* @FIXME: currently there's no support for (de)activating speech recognition during gameplay
		if(Profile.GetProfileSettingValueIdByName('SpeechRecognition', OutIntValue))
		{
			OnlineSubsystemCommonImpl(OnlineSub).bIsUsingSpeechRecognition = (OutIntValue==UTPID_VALUE_YES);
		}
		*/

		///////////////////////////////////////////////////////////////////////////
		// Weapon Options
		///////////////////////////////////////////////////////////////////////////

		// WeaponHand
		if(Profile.GetProfileSettingValueIdByName('WeaponHand', OutIntValue))
		{
			SetHand(EWeaponHand(OutIntValue));
		}

		// SmallWeapons
		if(Profile.GetProfileSettingValueIdByName('SmallWeapons', OutIntValue))
		{
			class'UTWeapon'.default.bSmallWeapons = (OutIntValue==UTPID_VALUE_YES);
			foreach DynamicActors(class'UTWeapon', W)
			{
				W.bSmallWeapons = class'UTWeapon'.default.bSmallWeapons;
			}
		}

		// DisplayWeaponBar
		if(Profile.GetProfileSettingValueIdByName('DisplayWeaponBar', OutIntValue))
		{
			if(MyUTHUD != None)
			{
				MyUTHUD.bShowWeaponbar = (OutIntValue==UTPID_VALUE_YES);
			}
		}

		// ShowOnlyAvailableWeapons
		if(Profile.GetProfileSettingValueIdByName('ShowOnlyAvailableWeapons', OutIntValue))
		{
			if(MyUTHUD != None)
			{
				MyUTHUD.bShowOnlyAvailableWeapons = (OutIntValue==UTPID_VALUE_YES);
			}
		}

		// RocketLauncherPriority
		if(Profile.GetProfileSettingValueFloat(class'UTProfileSettings'.const.UTPID_RocketLauncherPriority, OutFloatValue))
		{
			class'UTWeap_RocketLauncher'.default.Priority=OutFloatValue;
		}

		// BioRiflePriority
		if(Profile.GetProfileSettingValueFloat(class'UTProfileSettings'.const.UTPID_BioRiflePriority, OutFloatValue))
		{
			class'UTWeap_BioRifle'.default.Priority=OutFloatValue;
		}

		// FlakCannonPriority
		if(Profile.GetProfileSettingValueFloat(class'UTProfileSettings'.const.UTPID_FlakCannonPriority, OutFloatValue))
		{
			class'UTWeap_FlakCannon'.default.Priority=OutFloatValue;
		}

		// SniperRiflePriority
		if(Profile.GetProfileSettingValueFloat(class'UTProfileSettings'.const.UTPID_SniperRiflePriority, OutFloatValue))
		{
			class'UTWeap_SniperRifle'.default.Priority=OutFloatValue;
		}

		// LinkGunPriority
		if(Profile.GetProfileSettingValueFloat(class'UTProfileSettings'.const.UTPID_LinkGunPriority, OutFloatValue))
		{
			class'UTWeap_LinkGun'.default.Priority=OutFloatValue;
		}

		// EnforcerPriority
		if(Profile.GetProfileSettingValueFloat(class'UTProfileSettings'.const.UTPID_EnforcerPriority, OutFloatValue))
		{
			class'UTWeap_Enforcer'.default.Priority=OutFloatValue;
		}

		// ShockRiflePriority
		if(Profile.GetProfileSettingValueFloat(class'UTProfileSettings'.const.UTPID_ShockRiflePriority, OutFloatValue))
		{
			class'UTWeap_ShockRifle'.default.Priority=OutFloatValue;
		}

		// StingerMinigunPriority
		if(Profile.GetProfileSettingValueFloat(class'UTProfileSettings'.const.UTPID_StingerPriority, OutFloatValue))
		{
			class'UTWeap_Stinger'.default.Priority=OutFloatValue;
		}

		// LongbowAVRILPriority
		if(Profile.GetProfileSettingValueFloat(class'UTProfileSettings'.const.UTPID_AVRILPriority, OutFloatValue))
		{
			class'UTWeap_Avril'.default.Priority=OutFloatValue;
		}

		// RedeemerPriority
		if(Profile.GetProfileSettingValueFloat(class'UTProfileSettings'.const.UTPID_RedeemerPriority, OutFloatValue))
			{
			class'UTWeap_Redeemer'.default.Priority=OutFloatValue;
		}

		///////////////////////////////////////////////////////////////////////////
		// HUD Options
		///////////////////////////////////////////////////////////////////////////

		if(MyUTHUD != None)
		{
			// ShowMap
			if(Profile.GetProfileSettingValueIdByName('ShowMap', OutIntValue))
			{
				MyUTHUD.bShowMap = (OutIntValue==UTPID_VALUE_YES);
			}

			// ShowClock
			if(Profile.GetProfileSettingValueIdByName('ShowClock', OutIntValue))
			{
				MyUTHUD.bShowClock = (OutIntValue==UTPID_VALUE_YES);
			}

			// Hijack ShowDoll for hiding path
			if(Profile.GetProfileSettingValueIdByName('ShowDoll', OutIntValue))
			{
				bHideObjectivePaths = (OutIntValue==UTPID_VALUE_NO);
			}
			/*
			// ShowAmmo
			if(Profile.GetProfileSettingValueIdByName('ShowAmmo', OutIntValue))
			{
				MyUTHUD.bShowAmmo = (OutIntValue==UTPID_VALUE_YES);
			}

			// ShowPowerups
			if(Profile.GetProfileSettingValueIdByName('ShowPowerups', OutIntValue))
			{
				MyUTHUD.bShowPowerups = (OutIntValue==UTPID_VALUE_YES);
			}
			*/

			// Hijack MouseSmoothingStrength for crosshair size
			if(Profile.GetProfileSettingValueIntByName('MouseSmoothingStrength', OutIntValue))
			{
				// Fix up non-patch values
				if ( OutIntValue < 2 )
				{
					OutIntValue = 10;
					Profile.SetProfileSettingValueInt(425, OutIntValue); // UTPID_MouseSmoothingStrength = 425
				}
				MyUTHUD.ConfiguredCrosshairScaling = 0.1 * OutIntValue;
			}

			// ShowScoring
			if(Profile.GetProfileSettingValueIdByName('ShowScoring', OutIntValue))
			{
				MyUTHUD.bShowScoring = (OutIntValue==UTPID_VALUE_YES);
			}

			// ShowLeaderboard
			if(Profile.GetProfileSettingValueIdByName('ShowLeaderboard', OutIntValue))
			{
				MyUTHUD.bShowLeaderboard = (OutIntValue==UTPID_VALUE_YES);
			}

			// ShowVehicleArmorCount
			if(Profile.GetProfileSettingValueIdByName('ShowVehicleArmorCount', OutIntValue))
			{
				MyUTHUD.bShowVehicleArmorCount = (OutIntValue==UTPID_VALUE_YES);
			}

			// RotateMap
			if(Profile.GetProfileSettingValueIdByName('RotateMap', OutIntValue))
			{
				bRotateMinimap = (OutIntValue==UTPID_VALUE_YES);
			}
		}


		// Set the popup on death value
		if (Profile.GetProfileSettingValueIdByName('PopupMapOnDeath', OutIntValue))
		{
			bPopupMapOnDeath = (OutIntValue==UTPID_VALUE_YES);
		}

		// Achievement settings
		if (Profile.CheckLikeTheBackOfMyHandMap(class'UTGame'.static.ConvertMapNameToContext(WorldInfo.GetMapName(true))))
		{
			UTPlayerReplicationInfo(PlayerReplicationInfo).bAllPickupsFoundThisMap = true;
		}

		///////////////////////////////////////////////////////////////////////////
		// Apply Keybindings
		///////////////////////////////////////////////////////////////////////////
		Profile.ApplyAllKeyBindings(PlayerInput);

		///////////////////////////////////////////////////////////////////////////
		// Finished Storing Options
		///////////////////////////////////////////////////////////////////////////
	}
}

/** Spawn ClientSide Camera Effects **/
unreliable client function ClientSpawnCameraEffect(class<UTEmitCameraEffect> CameraEffectClass)
{
	local vector CamLoc;
	local rotator CamRot;

	if (CameraEffectClass != None && CameraEffect == None)
	{
		CameraEffect = Spawn(CameraEffectClass, self);
		if (CameraEffect != None)
		{
			GetPlayerViewPoint(CamLoc, CamRot);
			CameraEffect.RegisterCamera(self);
			CameraEffect.UpdateLocation(CamLoc, CamRot, FOVAngle);
		}
	}
}

/** @param CamEmitter Clear the CameraEffect if it is the one passed in */
function RemoveCameraEffect( UTEmitCameraEffect CamEmitter )
{
	if (CameraEffect == CamEmitter)
	{
		CameraEffect = None;
	}
}


function ClearCameraEffect()
{
	if( CameraEffect != None )
	{
		CameraEffect.Destroy();
		CameraEffect = none;
	}
}

/**
 * Attempts to open a UI Scene.
 *
 * @Param	Template		The Template of the scene to open.
 * @Returns the opened scene
 */
simulated function UIScene OpenUIScene(UIScene Template)
{
	local UTGameReplicationInfo GRI;

	GRI = UTGameReplicationInfo(WorldInfo.GRI);
	if ( GRI != none )
	{
		return GRI.OpenUIScene(self, Template);
	}

	return none;
}

/**
 * Saves the current profile complete with UI scene
 */
function SaveProfile(optional Int PlayerIndex)
{
	local UTGameUISCeneClient SC;
	local UTUIScene_SaveProfile SP;

	SC = UTGameUISCeneClient(class'UIRoot'.static.GetSceneClient());
	if ( SC != none )
	{
		SP = SC.ShowSaveProfileScene(self);
		if ( SP != none )
		{
			SP.PlayerIndexToSave = PlayerIndex;
		}
	}
	}


event TriggerProfileSave()
{
	SaveProfile();
}



exec function ShowCommandMenu()
{
	local UIScene Scene;

	LogInternal("###ShowCommandMenu"@CommandMenu@CommandMenuTemplate);

	if ( CommandMenu == none )
	{
		Scene = OpenUIScene(CommandMenuTemplate);
		if (Scene != none)
		{
			UTHUD(myHUD).ShowQuickPickMenu(false);
			CommandMenu = UTUIScene_CommandMenu(Scene);
			CommandMenu.OnSceneDeactivated = CommandMenuDeactivated;
		}
	}
}

function CommandMenuDeactivated( UIScene DeactivatedScene )
{
	LogInternal("### Command Menu Deactivated");
	if (DeactivatedScene == CommandMenu)
	{
		CommandMenu = none;
	}
}


function AdjustPersistentKey(UTSeqAct_AdjustPersistentKey InAction)
{
	local UTProfileSettings Profile;
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);

	if (InAction.bRemoveKey)
	{
		Profile.RemovePersistentKey(InAction.TargetKey);
	}
	else
	{
		Profile.AddPersistentKey(InAction.TargetKey);
	}

	SaveProfile();

}

function bool HasPersistentKey(ESinglePlayerPersistentKeys SearchKey)
{
	local UTProfileSettings Profile;
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);

	return Profile.HasPersistentKey(SearchKey);
}

/**
 * @Returns true if the player has any of these cards
 */
function bool HasModifierCard(name Card)
{
	local UTProfileSettings Profile;
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
	if ( Profile != none )
	{
		return Profile.HasModifierCard(Card);
	}

	return false;
}

/**
 * Add Modifier Card
 *
 * @Param	Card 	The Modifier Card to Add
 *
 */
function AddModifierCard(name Card)
{
	local UTProfileSettings Profile;
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
	if ( Profile != none )
	{
		Profile.AddModifierCard(Card);
		SaveProfile();
	}
	else
	{
//		`log("[SinglePlayer] Attempted to Add a modifier card to a Player Controller ("$Self$") without a profile!");
	}
}

/**
 * Use Modifier Card
 *
 * @Param	Card 	The Modifier Card use
 */
function UseModifierCard(name Card)
{
	local UTProfileSettings Profile;
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
	if ( Profile != none )
	{
		Profile.UseModifierCard(Card);
	}
}

function BullseyeMessage()
{
	if ( WorldInfo.TimeSeconds - LastBullseyeTime > 2.0 )
	{
		ReceiveLocalizedMessage( class'UTWeaponKillRewardMessage', 1 );
		LastBullseyeTime = WorldInfo.TimeSeconds;
		UTPlayerReplicationInfo(PlayerReplicationInfo).IncrementEventStat('EVENT_BULLSEYE');
	}
}

simulated function UpdateAchievement(int AchievementId, optional int Value = 1)
{
	local LocalPlayer LocPlayer;
	local UTProfileSettings Profile;
	local bool UnlockedAchievement;
	local INT UnlockType;

	// check the special case of -1 which means the unlock criteria has already been checked, so just unlock it
	if (Value != -1)
	{
		//Get the player profile and update it
		Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
		if ( Profile != none )
		{
			if (Profile.GetAchievementUnlockType(AchievementId, UnlockType))
			{
				if (UnlockType == EUnlockType_Count)
				{
					UnlockedAchievement = Profile.UpdateAchievementCount(AchievementId, Value);
				}
				else if (UnlockType == EUnlockType_BitMask)
				{
					UnlockedAchievement = Profile.UpdateAchievementBitMask(AchievementId, Value);
				}
				else if (UnlockType == EUnlockType_ByteCount)
				{
					UnlockedAchievement = Profile.UpdateAchievementByteCount(AchievementId, Value);
				}
			}
			else
			{
				LogInternal("Failed to get unlock type for achievement "$AchievementId);
			}
		}
	}
	else
	{
		// special case for the 64 bit bitmask achievements, just unlock it
		UnlockedAchievement=true;
	}

	//If in updating, you exceeded the unlock requirement, unlock the achievement
	if (UnlockedAchievement)
	{
		//`log("Unlocked the achievement "$AchievementId);
		if (OnlineSub != None)
		{
			// if the extended interface is supported
			if (OnlineSub.PlayerInterfaceEx != None)
			{
				LocPlayer = LocalPlayer(Player);
				OnlineSub.PlayerInterfaceEx.AddUnlockAchievementCompleteDelegate(LocPlayer.ControllerId, AchievementDone);

				LastAchievementIDUnlocked = AchievementId;
				if (OnlineSub.PlayerInterfaceEx.UnlockAchievement(LocPlayer.ControllerId,AchievementId) == false)
				{
//					`log("UnlockAchievement("$LocPlayer.ControllerId$","$AchievementId$") failed");
					AchievementDone(false);
				}
			}
			else
			{
				LogInternal("Interface is not supported. Can't unlock an achievement");
			}
		}
		else
		{
			LogInternal("No online subsystem. Can't unlock an achievement");
		}
	}
}

/** Shows the achievement UI so you can enjoy the new shiny achievement */
function AchievementDone(bool bWasSuccessful)
{
	if (bWasSuccessful == true)
	{
		ShowAchievementToast(LastAchievementIDUnlocked);
	}

	LastAchievementIDUnlocked = 0;

	if (OnlineSub != None && OnlineSub.PlayerInterfaceEx != None)
	{
		OnlineSub.PlayerInterfaceEx.ClearUnlockAchievementCompleteDelegate(0, AchievementDone);
	}
}

function ShowAchievementToast(int AchievementId)
{
	local string UnlockedMsg, FinalMsg;
	local int AchievementIndex;

	if (!class'UIRoot'.static.IsConsole(CONSOLE_Any))
	{
		// Find the achievement with AchievementId, and get its Name
		for ( AchievementIndex = 0; AchievementIndex < class'UTUIDataProvider_AvailableContent'.default.AllAchievements.length; ++AchievementIndex )
		{
			if ( class'UTUIDataProvider_AvailableContent'.default.AllAchievements[AchievementIndex].Achievement.ID == AchievementId )
			{
				class'UIRoot'.static.GetDataStoreStringValue(class'UTUIDataProvider_AvailableContent'.default.AllAchievements[AchievementIndex].Achievement.Name, FinalMsg);
				UnlockedMsg = Localize("Achievements", "AchievementUnlocked", "UTGameUI");
				FinalMsg = UnlockedMsg$":"@FinalMsg;
				break;
			}
		}
		

		//Put some logic here to detect how many achievements and print something like "X Achievements unlocked" instead of multiple messages
		//prevents needing to add a queuing system to Toasts

		// Display toast
		class'UTUIScene'.static.ShowOnlineToast(FinalMsg,,8);
	}
}

exec function ShowHandMaps()
{
	local int i;
	local UTProfileSettings Profile;

	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
	if ( Profile != none )
	{
		for (i=0; i<class'UTGame'.default.MapContexts.length; i++)
		{
			if (Profile.CheckLikeTheBackOfMyHandMap(class'UTGame'.default.MapContexts[i].MapContextId))
			{
				LogInternal("Map:"@class'UTGame'.default.MapContexts[i].MapName@": COMPLETE");
			}
			else
			{
				LogInternal("Map:"@class'UTGame'.default.MapContexts[i].MapName@": NOT COMPLETE");
			}
		}
	}
}

/**
 * Handles the Kismet action to unlock an achievement
 *
 * @param Action the action containing which achievement to unlock
 */
function OnUnlockAchievement(UTSeqAct_UnlockAchievement Action)
{
	ClientUpdateAchievement(Action.AchievementId);
}

/**
 * Unlocks the achievement on the client (can only be done clientside)
 *
 * @param AchievementId the achievement to unlock
 */
reliable client function ClientUpdateAchievement(int AchievementId, optional int Count=1)
{
	//Spectators don't get any
	if (PlayerReplicationInfo.bOnlySpectator)
	{
		return;
	}

	//`log("ClientUpdateAchievement"@AchievementId@"Count:"@Count);
	UpdateAchievement(AchievementId, Count);
}


/** Used in the Character Editor - outputs current character setup as concise text form. */
native exec function ClipChar();

/** Used in the Character Editor - outputs total poly count for character setup on screen. */
native exec function CharPolyCount();


/**
 * Don't allow team changes if we are in single player, or too frequently
 */
reliable server function ServerChangeTeam(int N)
{
	if ( (WorldInfo.TimeSeconds > LastTeamChangeTime + 1.0) && !UTGameReplicationInfo(WorldInfo.GRI).bStoryMode)
	{
		LastTeamChangeTime = WorldInfo.TimeSeconds;
		Super.ServerChangeTeam(N);
	}
}

event GetSeamlessTravelActorList(bool bToEntry, out array<Actor> ActorList)
{
	local UTProcessedCharacterCache CharacterCache;

	if (!UTGameReplicationInfo(WorldInfo.GRI).bStoryMode)
	{
		ShowMidGameMenu('ChatTab',true);
	}
	else
	{
		ShowScoreboard();
	}
	Super.GetSeamlessTravelActorList(bToEntry, ActorList);

	if (!bToEntry)
	{
		// keep any cached character data
		foreach DynamicActors(class'UTProcessedCharacterCache', CharacterCache)
		{
			ActorList[ActorList.length] = CharacterCache;
		}
	}
}

/** Allows the local player or admin to kick a player */
reliable server function ServerKickBan(string PlayerToKick, bool bBan)
{
	if (PlayerReplicationInfo.bAdmin || LocalPlayer(Player) != none )
	{
		if (bBan)
		{
			WorldInfo.Game.AccessControl.KickBan(PlayerToKick);
		}
		else
		{
			WorldInfo.Game.AccessControl.Kick(PlayerToKick);
		}
	}
}

exec function DebugMission()
{
	local string text;
	local UTGameReplicationInfo GRI;
	local int i,r;
	local UTProfileSettings Profile;
	if (WorldInfo.NetMode == NM_ListenServer)
	{
		GRI = UTGameReplicationInfo(WorldInfo.GRI);
		if (GRI != none && GRI.bStoryMode )
		{
			Text = "Current Mission:"@GRI.SinglePlayerMissionID;
			Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
			Profile.GetCurrentMissionData(i,r);
			Text @= "Prev. Mission:"@i@" Result="@r;
			LogInternal(Text);
			ConsoleCommand("Say"@Text);
		}
	}
}

exec function TriggerHero()
{
	ServerTriggerHero();
}

simulated private function OnTTSAudioFinished(AudioComponent AC)
{
	// release our ref.  GC should nuke it soon.
	ActiveTTSSoundCues.RemoveItem(AC.SoundCue);
}

//exec function testtts(coerce string s)
//{
//	SpeakTTS(S, PlayerReplicationInfo);
//}

simulated function SpeakTTS(coerce string S, optional PlayerReplicationInfo PRI)
{
	local SoundCue Cue;
	local AudioComponent AC;

	Cue = CreateTTSSoundCue(S, UTPlayerReplicationInfo(PRI));
	if (Cue != None)
	{
		AC = CreateAudioComponent(Cue, FALSE, TRUE,,, TRUE);
		AC.bAllowSpatialization = FALSE;
		AC.bAutoDestroy = TRUE;
		AC.OnAudioFinished = OnTTSAudioFinished;
		AC.Play();

		ActiveTTSSoundCues.AddItem(Cue);
	}
}

/** Constructs a SoundCue, performs text-to-wavedata conversion. */
simulated private native function SoundCue CreateTTSSoundCue(string StrToSpeak, UTPlayerReplicationInfo PRI);

simulated private function bool AllowTTSMessageFrom(PlayerReplicationInfo PRI)
{
	local UTGameReplicationInfo GRI;
	local int SpeakerTeamID, MyTeamID;

	if (bNoTextToSpeechVoiceMessages)
	{
		return FALSE;
	}
	else if ( !bTextToSpeechTeamMessagesOnly || (PRI == PlayerReplicationInfo) )
	{
		return TRUE;
	}

	// else need to check for teammate (in a team game)
	GRI = UTGameReplicationInfo(WorldInfo.GRI);
	if (GRI != None)
	{
		if (GRI.GameClass.default.bTeamGame)
		{
			SpeakerTeamID = PRI.GetTeamNum();
			if (SpeakerTeamID != 255)
			{
				MyTeamID = PlayerReplicationInfo.GetTeamNum();
				if (MyTeamID == SpeakerTeamID)
				{
					return TRUE;
				}
			}
		}
	}

	return FALSE;
}

/** Overloaded to implement TTS. */
reliable client event TeamMessage( PlayerReplicationInfo PRI, coerce string S, name Type, optional float MsgLifeTime )
{
	if (CanCommunicate())
	{
		if ( ((Type == 'Say') || (Type == 'TeamSay')) && (PRI != None) && AllowTTSMessageFrom(PRI) )
		{
			if (CanViewUserCreatedContent())
			{
				SpeakTTS(S, PRI);
			}
		}

		super.TeamMessage(PRI, S, Type, MsgLifeTime);
	}
}

unreliable server function ServerSay( string Msg )
{
	if ( !bServerMutedText )
	{
		super.ServerSay(Msg);
	}
}

unreliable server function ServerTeamSay( string Msg )
{
	if ( !bServerMutedText )
	{
		Super.ServerTeamSay(Msg);
	}
}

function bool AllowTextMessage(string Msg)
{
	return (CanCommunicate() && Super.AllowTextMessage(Msg));
}

reliable server function ServerSetAlias(string NewAlias)
{
	UTGame(WorldInfo.Game).SetAlias(Self, NewAlias);
}

/******************************************
 Admin functions
 ******************************************/


/** Called when the convolve response has returned */
event ProcessConvolveResponse(string C)
{
	Super.ProcessConvolveResponse(C);

	//Stop the convolve timer since we have a response
	ClearTimer('ConvolveTimeout');

	//Store this value for later
	HashResponseCache = C;

	//Check this response against our list of banned keys
	if (WorldInfo.Game.AccessControl != None && WorldInfo.Game.AccessControl.IsHashBanned(HashResponseCache))
	{
		LogInternal(PlayerReplicationInfo.GetPlayerAlias()@"is banned, kicking...");   
		WorldInfo.Game.AccessControl.KickPlayer(self, WorldInfo.Game.AccessControl.BannedCDHashKeyString);
	}
}

/** Called when the convolve response has timed out */
function ConvolveTimeout()
{
	ClearTimer('ConvolveTimeout');

	if (WorldInfo.Game.AccessControl != None)
	{
		LogInternal(PlayerReplicationInfo.GetPlayerAlias()@"was kicked for a hash key response timeout...");
		WorldInfo.Game.AccessControl.KickPlayer(self, WorldInfo.Game.AccessControl.TimedOutCDHashKeyString);
	}
}

function bool AdminCmdOk()
{
	//If we are the server then commands are ok
	if (WorldInfo.NetMode == NM_ListenServer && LocalPlayer(Player) != None)
	{
		return true;
	}

	if (WorldInfo.TimeSeconds < NextAdminCmdTime)
	{
		return false;
	}

	NextAdminCmdTime = WorldInfo.TimeSeconds + 5.0;
	return true;
}

exec function AdminLogin(string Password)
{
	if (Password != "" && AdminCmdOk() )
	{
		ServerAdminLogin(Password);
	}
}

reliable server function ServerAdminLogin(string Password)
{
	if ( (WorldInfo.Game.AccessControl != none) && AdminCmdOk() )
	{
		if ( WorldInfo.Game.AccessControl.AdminLogin(self, Password) )
		{
			WorldInfo.Game.AccessControl.AdminEntered(Self);
		}
	}
}

exec function AdminLogOut()
{
	if ( AdminCmdOk() )
	{
		ServerAdminLogOut();
	}
}

reliable server function ServerAdminLogOut()
{
	if ( WorldInfo.Game.AccessControl != none )
	{
		if ( WorldInfo.Game.AccessControl.AdminLogOut(self) )
		{
			WorldInfo.Game.AccessControl.AdminExited(Self);
		}
	}
}

// Execute an administrative console command on the server.
exec function Admin( string CommandLine )
{
	if (PlayerReplicationInfo.bAdmin)
	{
		ServerAdmin(CommandLine);
	}
}

reliable server function ServerAdmin( string CommandLine )
{
	local string Result;

	if ( PlayerReplicationInfo.bAdmin )
	{
		Result = ConsoleCommand( CommandLine );
		if( Result!="" )
			ClientMessage( Result );
	}
}

exec function AdminKickBan( string S )
{
	if (PlayerReplicationInfo.bAdmin)
	{
		ServerKickBan(S,true);
	}
}


exec function AdminKick( string S )
{
	if ( PlayerReplicationInfo.bAdmin )
	{
		ServerKickBan(S,false);
	}
}

exec function AdminSessionBan(string S)
{
	if (PlayerReplicationInfo.bAdmin)
		ServerSessionBan(S);
}


exec function AdminPlayerList()
{
	local PlayerReplicationInfo PRI;

	if (PlayerReplicationInfo.bAdmin)
	{
		ClientMessage("Player List:");
		foreach DynamicActors(class'PlayerReplicationInfo', PRI)
		{
			ClientMessage(PRI.PlayerID$"."@PRI.PlayerName @ "Ping:" @ INT((float(PRI.Ping) / 250.0 * 1000.0)) $ "ms)");
		}
	}
}

exec function AdminRestartMap()
{
	if (PlayerReplicationInfo.bAdmin)
	{
		ServerRestartMap();
	}
}

reliable server function ServerRestartMap()
{
	if ( PlayerReplicationInfo.bAdmin )
	{
		WorldInfo.ServerTravel("?restart", false);
	}
}

exec function AdminChangeMap( string URL )
{
	if (PlayerReplicationInfo.bAdmin)
	{
		ServerChangeMap(URL);
	}
}

reliable server function ServerChangeMap(string URL)
{
	if ( PlayerReplicationInfo.bAdmin )
	{
		WorldInfo.ServerTravel(URL);
	}
}

exec function AdminForceVoiceMute(string TargetPlayer)
{
	if ( PlayerReplicationInfo.bAdmin )
	{
		ServerForceVoiceMute(TargetPlayer);
	}
}

reliable server function ServerForceVoiceMute(string TargetPlayer)
{
	local PlayerController PC;
	local PlayerController TargetPlayerPC;

	if ( PlayerReplicationInfo.bAdmin )
	{
		TargetPlayerPC = UTPlayerController(WorldInfo.Game.AccessControl.GetControllerFromString(TargetPlayer));
		if ( TargetPlayerPC != none )
		{
			ClientMessage("Muting (Voice):"@TargetPlayerPC.PlayerReplicationInfo.PlayerName);
			foreach WorldInfo.AllControllers(class'PlayerController', PC)
			{
				PC.ServerMutePlayer(TargetPlayerPC.PlayerReplicationInfo.UniqueId);
			}
		}
	}
}

exec function AdminForceVoiceUnMute(string TargetPlayer)
{
	if ( PlayerReplicationInfo.bAdmin )
	{
		ServerForceVoiceUnMute(TargetPlayer);
	}
}

reliable server function ServerForceVoiceUnMute(string TargetPlayer)
{
	local PlayerController PC;
	local PlayerController TargetPlayerPC;

	if ( PlayerReplicationInfo.bAdmin )
	{
		TargetPlayerPC = UTPlayerController(WorldInfo.Game.AccessControl.GetControllerFromString(TargetPlayer));
		ClientMessage("UnMuting (Voice):"@TargetPlayerPC.PlayerReplicationInfo.PlayerName);
		if ( TargetPlayerPC != none )
		{
			foreach WorldInfo.AllControllers(class'PlayerController', PC)
			{
				PC.ServerUnMutePlayer(TargetPlayerPC.PlayerReplicationInfo.UniqueId);
			}
		}
	}
}


exec function AdminForceTextMute(string TargetPlayer)
{
	if ( PlayerReplicationInfo.bAdmin )
	{
		ServerForceTextMute(TargetPlayer);
	}
}

reliable server function ServerForceTextMute(string TargetPlayer)
{
	local UTPlayerController TargetPlayerPC;

	if ( PlayerReplicationInfo.bAdmin )
	{
		TargetPlayerPC = UTPlayerController(WorldInfo.Game.AccessControl.GetControllerFromString(TargetPlayer));
		if ( TargetPlayerPC != none )
		{
			ClientMessage("Muting (Text):"@TargetPlayerPC.PlayerReplicationInfo.PlayerName);
			TargetPlayerPC.bServerMutedText = true;
		}
	}
}

exec function AdminForceTextUnMute(string TargetPlayer)
{
	if ( PlayerReplicationInfo.bAdmin )
	{
		ServerForceTextUnMute(TargetPlayer);
	}
}

reliable server function ServerForceTextUnMute(string TargetPlayer)
{
	local UTPlayerController TargetPlayerPC;

	if ( PlayerReplicationInfo.bAdmin )
	{
		TargetPlayerPC = UTPlayerController(WorldInfo.Game.AccessControl.GetControllerFromString(TargetPlayer));
		if ( TargetPlayerPC != none )
		{
			ClientMessage("UnMuting (Text):"@TargetPlayerPC.PlayerReplicationInfo.PlayerName);
			TargetPlayerPC.bServerMutedText = false;
		}
	}
}

/** changes an option for the current gametype on the server - only works for .ini configurable options and only if this player is the admin */
exec function AdminChangeOption(string Option, string Value)
{
	if (PlayerReplicationInfo.bAdmin)
	{
		ServerAdminChangeOption(Option, Value);
	}
}

/** changes an option for the current gametype on the server - only works for .ini configurable options and only if this player is the admin */
reliable server native function ServerAdminChangeOption(string Option, string Value);

/** sends the client's maplist for the current gametype to the server - must be admin */
// TODO(Shambler): Update this to work with the new maplist manager
exec function AdminPublishMapList()
{
	ClientMessage("Maplist publishing is not compatibile with the new maplist system");

	// TODO: Reimplement this
/*
	if (PlayerReplicationInfo.bAdmin && WorldInfo.NetMode == NM_Client)
	{
		if (MapListPublishGameClassName != 'None')
		{
			ClientMessage("Already updating map list for" @ MapListPublishGameClassName);
		}
		else if (WorldInfo.GRI == None || WorldInfo.GRI.GameClass == None)
		{
			ClientMessage("Unable to publish map list to server - not fully connected");
		}
		else
		{
			MapListPublishGameClassName = WorldInfo.GRI.GameClass.Name;
			ServerStartMapListPublish(MapListPublishGameClassName);
			ClientSendNextMap(0);
		}
	}
*/
}

/** sends a single map in the current gametype's maplist to the server for updating */
reliable client function ClientSendNextMap(int MapIndex)
{
	// TODO: Reimplement this
/*
	local int MapListIndex;

	MapListIndex = class'UTGame'.default.GameSpecificMapCycles.Find('GameClassName', MapListPublishGameClassName);
	if (MapListIndex != INDEX_NONE)
	{
		if (MapIndex < class'UTGame'.default.GameSpecificMapCycles[MapListIndex].Maps.length)
		{
			ServerReceiveNextMap(MapIndex, class'UTGame'.default.GameSpecificMapCycles[MapListIndex].Maps[MapIndex]);
		}
		else
		{
			ClientMessage("Map list publish complete.");
			MapListPublishGameClassName = 'None';
			ServerEndMapListPublish();
		}
	}
*/
}

/** gets the server started for receiving a map list */
reliable server function ServerStartMapListPublish(name GameClassName)
{
	// TODO: Reimplement this
/*
	local int MapListIndex;

	if (PlayerReplicationInfo.bAdmin)
	{
		MapListPublishGameClassName = GameClassName;
		// remove old map list entries
		MapListIndex = class'UTGame'.default.GameSpecificMapCycles.Find('GameClassName', GameClassName);

		// TODO: Implement remote named maplist editing (and set it up so that only one person can transfer at a time,
		//	and that the whole list must be received intact before it is applied)
		if ((Class'UTGame'.default.bAllowMapVoting && Class'UTGame'.default.bAllowGameVoting) ||
			Class'UTGame'.default.bUseNamedMapLists)
		{
			MapListPublishGameClassName = 'None';
			ClientResetMapListPublish();

			ClientMessage("The server is using named maplists, support for editing these remotely has not yet been added");

			return;
		}


		if (MapListIndex != INDEX_NONE)
		{
			class'UTGame'.default.GameSpecificMapCycles[MapListIndex].Maps.length = 0;
		}
		else
		{
			MapListIndex = class'UTGame'.default.GameSpecificMapCycles.length;
			class'UTGame'.default.GameSpecificMapCycles.length = MapListIndex + 1;
			class'UTGame'.default.GameSpecificMapCycles[MapListIndex].GameClassName = GameClassName;
		}
	}
*/
}

/** server receives a single map list entry and asks client for the next one */
reliable server function ServerReceiveNextMap(int MapIndex, string MapName)
{
	// TODO: Reimplement this
/*
	local int MapListIndex;

	if (PlayerReplicationInfo.bAdmin)
	{
		MapListIndex = class'UTGame'.default.GameSpecificMapCycles.Find('GameClassName', MapListPublishGameClassName);
		if (MapListIndex == INDEX_NONE)
		{
			`Warn("Maplist was modified by another source while receiving list from" @ PlayerReplicationInfo.PlayerName);

			MapListPublishGameClassName = 'None';
			ClientResetMapListPublish();

			ClientMessage("Error during maplist transmission, aborting");
		}
		else
		{
			class'UTGame'.default.GameSpecificMapCycles[MapListIndex].Maps[MapIndex] = MapName;
			ClientSendNextMap(MapIndex + 1);
		}
	}
*/
}

/** indicates server has received all maps in the client's list */
reliable server function ServerEndMapListPublish()
{
	// TODO: Reimplement this
/*
	if (PlayerReplicationInfo.bAdmin)
	{
		MapListPublishGameClassName = 'None';
		class'UTGame'.static.StaticSaveConfig();
		UTGame(WorldInfo.Game).GameSpecificMapCycles = class'UTGame'.default.GameSpecificMapCycles;
		UTGame(WorldInfo.Game).MapCycleIndex = INDEX_NONE;
	}
*/
}

exec function Disconnect()
{
	QuitToMainMenu();
}

unreliable client function ClientSmartUse()
{
	if ( PlayerInput.bUsingGamepad )
	{
		ToggleTranslocator();
	}
}

/** Spawn ClientSide gory Camera Effects (so low gore client can ignore) **/
unreliable client function ClientSpawnGoreCameraEffect(class<UTEmitCameraEffect> CameraEffectClass)
{
	if (  !class'GameInfo'.static.UseLowGore(WorldInfo) )
	{
		ClientSpawnCameraEffect(CameraEffectClass);
	}
}


reliable client function ClientIncrementMixItUp(int GameType, int AchievementType)
{
	local UTProfileSettings Profile;

	//Get the player profile and update it
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
	if ( Profile != none )
	{
		if (Profile.IncrementMixItUp(GameType, AchievementType))
		{
			if (AchievementType == 1)
				ClientUpdateAchievement(EUTA_IA_EveryGameMode);
			else if (AchievementType == 2)
				ClientUpdateAchievement(EUTA_VERSUS_GetItOn);
			//else if (AchievementType == 3)
			//	ClientUpdateAchievement(EUTA_RANKED_EqualOpportunityDestroyer);
		}
	}
}

reliable client function ClientIncrementAroundTheWorld(int mapIndex)
{
	local UTProfileSettings Profile;

	//Get the player profile and update it
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
	if ( Profile != none )
	{
		if (Profile.UpdateAroundTheWorld(mapIndex))
		{
			ClientUpdateAchievement(EUTA_VERSUS_AroundTheWorld, -1);
		}
	}
}

reliable client function ClientIncrementLikeTheBackOfMyHand(int mapIndex)
{
	local UTProfileSettings Profile;

	//Get the player profile and update it
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
	if ( Profile != none )
	{
		if (Profile.UpdateLikeTheBackOfMyHand(mapIndex))
		{
			ClientUpdateAchievement(EUTA_EXPLORE_AllPowerups, -1);
		}
	}
}

reliable client function ClientUpdateSpiceOfLife(int MutatorBitMask)
{
	local UTProfileSettings Profile;
	local int CurrentMask;
	local int index;
	local int MutatorBit;

	//Get the player profile and update it
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
	if ( Profile != none )
	{
		Profile.GetAchievementValue(EUTA_EXPLORE_EveryMutator,CurrentMask);

		for (index=0; index < 31; index++)
		{
			MutatorBit = 1<<index;
			if(((MutatorBitMask&MutatorBit)==MutatorBit) && ((CurrentMask&MutatorBit)==0))
			{
				ClientUpdateAchievement(EUTA_EXPLORE_EveryMutator, MutatorBit);
				break;
			}
		}
	}
}

reliable client function ClientUpdateGetALife()
{
	local UTProfileSettings Profile;

	//Get the player profile and update it
	Profile = UTProfileSettings(OnlinePlayerData.ProfileProvider.Profile);
	if ( Profile != none )
	{
		if (Profile.IncrementGetALife())
		{
			ClientUpdateAchievement(EUTA_VERSUS_GetALife);
		}
	}
}

reliable server function ServerSessionBan(string PlayerToBan)
{
	if (PlayerReplicationInfo.bAdmin || LocalPlayer(Player) != none)
		WorldInfo.Game.AccessControl.SessionBan(PlayerToBan);
}

reliable server function ServerTriggerHero()
{
	UTPlayerReplicationInfo(PlayerReplicationInfo).TriggerHero();
}


// Stop the clientside publishing code from breaking when transmission fails
reliable client function ClientResetMapListPublish()
{
	// TODO: Reimplement this
/*
	MapListPublishGameClassName = 'None';
*/
}

defaultproperties
{
   bNoTextToSpeechVoiceMessages=True
   bAutoTaunt=True
   bEnableDodging=True
   bAlwaysMouseLook=True
   bUseVehicleRotationOnPossess=True
   bFirstPersonWeaponsSelfShadow=True
   bForceBehindView=True
   bLandingShake=True
   bSmoothClientDemo=True
   IdentifiedTeam=255
   PawnShadowMode=SHADOW_All
   AutoObjectivePreference=AOP_NoPreference
   LastKickWarningTime=-1000.000000
   MsgPlayerNotFound="Player not Found!"
   CameraShakeShortWaveForm=ForceFeedbackWaveform'UTGame.Default__UTPlayerController:ForceFeedbackWaveform7'
   CameraShakeLongWaveForm=ForceFeedbackWaveform'UTGame.Default__UTPlayerController:ForceFeedbackWaveform8'
   CamOverridePostProcess=(bEnableBloom=True,bEnableSceneEffect=True,Bloom_Scale=1.000000,Bloom_InterpolationDuration=1.000000,DOF_FalloffExponent=4.000000,DOF_BlurKernelSize=16.000000,DOF_MaxNearBlurAmount=1.000000,DOF_MaxFarBlurAmount=1.000000,DOF_ModulateBlurColor=(B=255,G=255,R=255,A=255),DOF_FocusInnerRadius=2000.000000,DOF_InterpolationDuration=1.000000,MotionBlur_MaxVelocity=1.000000,MotionBlur_Amount=0.500000,MotionBlur_FullMotionBlur=True,MotionBlur_CameraRotationThreshold=45.000000,MotionBlur_CameraTranslationThreshold=10000.000000,MotionBlur_InterpolationDuration=1.000000,Scene_HighLights=(X=1.000000,Y=1.000000,Z=1.000000),Scene_MidTones=(X=1.000000,Y=1.000000,Z=1.000000),Scene_InterpolationDuration=1.000000)
   DamageCameraAnim=CameraAnim'FX_HitEffects.DamageViewShake'
   MatineeCameraClass=Class'Engine.AnimatedCamera'
   ZoomRotationModifier=0.500000
   VehicleCheckRadiusScaling=1.000000
   BeaconPulseMax=1.100000
   BeaconPulseRate=0.500000
   PulseTimer=5.000000
   CommandMenuTemplate=UTUIScene_CommandMenu'UI_InGameHud.Menus.CommandMenu'
   ProgressMessageSceneClassName="UTGame.UTUIScene_ConnectionStatus"
   OldMessageTime=-100.000000
   PopupWaitTime=5.000000
   LastTeamChangeTime=-1000.000000
   OnFootDefaultFOV=90.000000
   CameraClass=None
   bCheckSoundOcclusion=True
   FOVAngle=90.000000
   DesiredFOV=90.000000
   DefaultFOV=90.000000
   CheatClass=Class'UTGame.UTCheatManager'
   InputClass=Class'UTGame.UTPlayerInput'
   Begin Object Class=CylinderComponent Name=CollisionCylinder ObjName=CollisionCylinder Archetype=CylinderComponent'GameFramework.Default__GamePlayerController:CollisionCylinder'
      ObjectArchetype=CylinderComponent'GameFramework.Default__GamePlayerController:CollisionCylinder'
   End Object
   CylinderComponent=CollisionCylinder
   MinRespawnDelay=1.500000
   Begin Object Class=SpriteComponent Name=Sprite ObjName=Sprite Archetype=SpriteComponent'GameFramework.Default__GamePlayerController:Sprite'
      ObjectArchetype=SpriteComponent'GameFramework.Default__GamePlayerController:Sprite'
   End Object
   Components(0)=Sprite
   Components(1)=CollisionCylinder
   CollisionComponent=CollisionCylinder
   Name="Default__UTPlayerController"
   ObjectArchetype=GamePlayerController'GameFramework.Default__GamePlayerController'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:18:20.000 - Creation time: sk 18-3-2018 10:01:23.719 - Created with UnCodeX