-
Notifications
You must be signed in to change notification settings - Fork 1
/
Game_Lib.pas
1293 lines (1176 loc) · 29.5 KB
/
Game_Lib.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit Game_Lib;
interface
uses
Windows, SysUtils, OpenGL,
Engine_Reg,
Constants_Lib,
Type_Lib,
Graph_Lib,
MyEntries,
Math_Lib,
Func_Lib,
Weapon_Lib,
Player_Lib,
PlayersUtils_Lib,
Map_Lib,
Phys_Lib,
HUD_Lib,
Particle_Lib,
ItemObj_Lib,
binds_lib,
Bot_Lib,
TFKBot_Lib;
procedure Game_Init;
procedure Game_Update;
procedure Game_Draw;
function Game_Cmd(Cmd: ShortString): boolean;
function Bot_Cmd(Cmd: ShortString): boolean;
function IsGame: boolean;
function FindMap(const FileName: string): string;
function LoadMap(const FileName: string; mapfind: boolean = true; multi: byte = 0): boolean;
function GetGameType(gametype: Byte): string;
function SetGameType(str: string): boolean;
procedure queue_add(cmd: shortstring);
implementation
uses Menu_lib, Mouse_Lib, Real_Lib, Timing_Lib, Net_Lib, Net_Server_Lib;
var
comm_queue: array [1..100] of shortstring;
comm_length: integer;
procedure queue_add(cmd: shortstring);
begin
inc(comm_length);
comm_queue[comm_length]:=cmd;
end;
function GetFilePath(const Dir, Name: string): string;
var
fd : TFindData;
s : string;
begin
Result := '';
s := LowerCase(Name);
if FindFirst(Dir + '*', fd) then
repeat
if fd.Data.cFileName[0] = '.' then continue;
if DirectoryExists(Dir + fd.Data.cFileName) then
Result := GetFilePath(Dir + fd.Data.cFileName + '\', Name)
else
if LowerCase(fd.Data.cFileName) = s then
Result := Dir + Name;
if Result <> '' then
break;
until not FindNext(fd);
end;
procedure Game_Init;
begin
Randomize;
HUD_Init;
Particle_Init;
bg := 'bg_11';
Map := TMap.Create;
Const_Init;
Phys_Init;
Weapon_Init;
Phys_Player_Init;
Bind_Init;
Mouse_Init;
WeaponCreate;
tfkbot_Init;//CMD commands for TFK bot
Console_CmdReg('phys', @Phys_cmd);
Log_ConWrite(false);
Console_Cmd('exec phys.cfg');
Log_ConWrite(true);
Console_CmdReg('activate', @Game_Cmd);
Console_CmdReg('map', @Game_Cmd);
Console_CmdReg('map_list', @Game_Cmd);
Console_CmdReg('model_list', @Game_Cmd);
Console_CmdReg('gametype', @Game_Cmd);
Console_CmdReg('spgame', @Game_Cmd);
Console_CmdReg('spgame_free', @Game_Cmd);
Console_CmdReg('demo', @Game_Cmd);
Console_CmdReg('restart', @Game_Cmd);
Console_CmdReg('ready', @Game_Cmd);
Console_CmdReg('stats', @Game_Cmd);
Console_CmdReg('autorecord', @Game_Cmd);
Console_CmdReg('record', @Game_Cmd);
Console_CmdReg('stoprecord', @Game_Cmd);
{
Console_CmdReg('sc_record', @Game_Cmd);
Console_CmdReg('sc_stop', @Game_Cmd);
Console_CmdReg('sc_play', @Game_Cmd);
Console_CmdReg('sc_clear', @Game_Cmd);
Console_CmdReg('sc_list', @Game_Cmd);
}
Console_CmdReg('give', @Game_Cmd);
Console_CmdReg('demo_goto', @Game_Cmd);
Console_CmdReg('demo_skip', @Game_Cmd);
Console_CmdReg('cam_nextplayer', @Game_Cmd);
Console_CmdReg('cam_prevplayer', @Game_Cmd);
Console_CmdReg('sv_name', @Game_Cmd);
Console_CmdReg('sv_pass', @Game_Cmd);
Console_CmdReg('name', @Game_Cmd);
Console_CmdReg('p2name', @Game_Cmd);
Console_CmdReg('model', @Game_Cmd);
Console_CmdReg('p2model', @Game_Cmd);
Console_CmdReg('disjoin', @Game_Cmd);
Console_CmdReg('join', @Game_Cmd);
Console_CmdReg('p2join', @Game_Cmd);
Console_CmdReg('say', @Game_Cmd);
Console_CmdReg('onsay', @Game_Cmd);
Console_CmdReg('bg', @Game_Cmd);
Console_CmdReg('r_rail', @Game_Cmd);
Console_CmdReg('r_rail_p2', @Game_Cmd);
Console_CmdReg('r_rail_enemy', @Game_Cmd);
//îòëàäêà
Console_CmdReg('fade', @Game_Cmd);
// BOT
Console_CmdReg('bot_load', @Bot_Cmd);
Console_CmdReg('bot_version', @Bot_Cmd);
Console_CmdReg('íàõ', @Game_Cmd);
Console_CmdReg('sp_save', @Game_Cmd);
Console_CmdReg('sp_load', @Game_Cmd);
// Îáíóëÿåì âñå ïðîöåäóðû áîòà
BOT_DLL := 0;
FreeBotDll;
Console_Cmd('exec autoexec.cfg'); // exec'àåì autoexec %)
Log_ConWrite(false);
Console_Cmd('exec config.cfg'); //XProger: òîëüêî ïîñëå ðåãèñòðàöèè âñåõ êîìàíä!
Log_ConWrite(true);
//Neoff: ñïàñèáî ÷òî èñïðàâèë
end;
procedure Game_Update;
var
i: integer;
begin
if not IsGame then Exit;
Inc(sound_off);
Log_ConWrite(false);
for i:=1 to comm_length do
Console_CMD(comm_queue[i]);
comm_length:=0;
Log_ConWrite(true);
Dec(sound_off);
if not inMenu then
begin
UpdateKeys;
if onSay then
SayEdit.Update
else
Mouse.Update;
end;
Timing_Start('HUD Update');
HUD_Update;
Timing_End('HUD Update');
Timing_Start('Map Update');
Map.Update;
Timing_End('Map Update');
// Listen sound pos
if cam_fixed then
begin
sndPos := Point2f(Map.Width*16, Map.Height*8);;
splitscreen := SPLIT_NONE;
end
else
if Map.Players > 0 then
if splitscreen = SPLIT_NONE then
sndPos := Map.Camera.Pos
else
begin
if Map.pl_find(-1, C_PLAYER_P1) then
sndPos := Map.pl_current.Pos
else sndPos := Map.Camera.Pos;
end;
if sound_off=0 then
snd_SetGlobalPos(sndPos)
end;
procedure Game_Draw;
procedure ViewPort(X, Y, Width, Height: integer);
begin
if SplitScreen = SPLIT_NONE then
if dis_scale then
begin
if (xglWidth > 640) or (xglHeight > 480) then
begin
X := (xglWidth - 640) div 2;
Y := (xglHeight - 480) div 2;
Width := 640;
Height := 480;
end;
end;
glViewport(X, Y, Width, Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
gluOrtho2D(0, Map.Camera.View.X*2 , Map.Camera.View.Y*2, 0);
glMatrixMode(GL_MODELVIEW); // glLoadIdentity;
end;
var
s : PChar;
x : integer;
begin
if not IsGame then Exit;
Particle_inframe := 0;
if not Map.pl_find(-1, C_PLAYER_p2) then
SplitScreen := SPLIT_NONE
else if (SplitScreen=SPLIT_NONE) and not cam_fixed then
SplitScreen := 2;
if cam_fixed then
begin
ViewPort(0, 0, xglWidth, xglHeight);
Timing_Start('Map draw');
Map.Draw;
Timing_End('Map draw');
end
else
case SplitScreen of
SPLIT_NONE :
begin
ViewPort(0, 0, xglWidth, xglHeight);
if Map.pl_find(-1, C_PLAYER_p1) then
Map.Camera.Target := Map.pl_current;
Timing_Start('Map draw');
Map.Draw;
Timing_End('Map draw');
end;
SPLIT_HORIZ :
begin
ViewPort(0, xglHeight div 2, xglWidth, xglHeight div 2);
if Map.pl_find(-1, C_PLAYER_p1) then
Map.Camera.Target := Map.pl_current;
Map.Camera.Update;
Map.Draw;
ViewPort(0, 0, xglWidth, xglHeight div 2);
if Map.pl_find(-1, C_PLAYER_p2) then
Map.Camera.Target := Map.pl_current;
Map.Camera.Update;
Map.Draw;
//split line
xglViewPort(0, 0, xglWidth, xglHeight, false);
xglTex_Disable;
glColor4f(0.5, 0.5, 0.5, 1);
glLineWidth(3);
glBegin(GL_LINES);
glVertex2f(0, xglHeight div 2);
glVertex2f(xglWidth, xglHeight div 2);
glEnd;
end;
SPLIT_VERT :
begin
ViewPort(xglWidth div 2, 0, xglWidth div 2, xglHeight);
if Map.pl_find(-1, C_PLAYER_p1) then
Map.Camera.Target := Map.pl_current;
Map.Camera.Update;
Map.Draw;
if not p2disable then
begin
glViewPort(0, 0, xglWidth div 2, xglHeight);
if Map.pl_find(-1, C_PLAYER_p2) then
Map.Camera.Target := Map.pl_current;
Map.Camera.Update;
Map.Draw;
end;
//split line
xglViewPort(0, 0, xglWidth, xglHeight, false);
xglTex_Disable;
glColor4f(0.5, 0.5, 0.5, 1);
glLineWidth(3);
glBegin(GL_LINES);
glVertex2f(xglWidth div 2, 0);
glVertex2f(xglWidth div 2, xglHeight);
glEnd;
end;
end;
HUD_Draw;
// XProger: âûâîä èíôîðìàöèè î ðàçìåðå äåìêè :)
if demo_showinfo then
if Map.demorec then
begin
// XProger: Neoff, ÿ òàê ïîíÿë, ÷òî ïèøó ðàçìåð äýìêè à íå êîíå÷íîãî ôàéëà,
// Âêëþ÷àþùåãî â ñåáÿ êàðòó, êàê òû äóìàåøü ýòî òàê è îñòàâèòü?
s := PChar('Recording demo "' + Map.Demo.demofilename + '" Size: ' +
IntToStr(Map.Fullsize div 1024)+ ' Kb');
// FloatToStrF(Map.Demo.position/1024, ffGeneral, 3, 4) + ' Kb');
x := 320 - Length(s)*4;
xglAlphaBlend(1);
glColor3f(0, 0, 0);
TextOut(x + 1, 17, s);
glColor3f(1, 1, 0);
TextOut(x, 16, s);
end;
if onSay then
SayEdit.Draw;
// îòîáðàçèòü èíôîðìàöèþ î ïàðòèêëàõ
if d_particles then
begin
xglAlphaBlend(1);
glColor3f(0, 0, 0);
TextOut(17, 51, PChar('Particles'));
TextOut(17, 67, PChar(' Count : ' + IntToStr(Particle_Count)));
TextOut(17, 83, PChar(' inFrame : ' + IntToStr(Particle_inFrame)));
glColor3f(1, 0.2, 0.2);
TextOut(16, 50, PChar('Particles'));
TextOut(16, 66, PChar(' Count : ' + IntToStr(Particle_Count)));
TextOut(16, 82, PChar(' inFrame : ' + IntToStr(Particle_inFrame)));
end;
if d_realobjs then
begin
xglAlphaBlend(1);
glColor3f(0, 0, 0);
TextOut(17, 51, PChar('Real Objects'));
TextOut(17, 67, PChar(' Size : ' + IntToStr(RealObj_Count)));
glColor3f(1, 0.2, 0.2);
TextOut(16, 50, PChar('Real Objects'));
TextOut(16, 66, PChar(' Size : ' + IntToStr(RealObj_Count)));
end;
end;
function FindMap(const FileName: string): string;
var
dir, s, name: string;
begin
if (ExtractFileExt(filename) <> 'tm') then
name := filename + '.tm'
else name:=filename;
dir:=Engine_Dir + Engine_ModDir + MAPS_FOLDER;
s:=GetFilePath(dir, name);
if s<>'' then
Result:=s
else Result:='';
end;
function LoadMap(const FileName: string; mapfind: boolean=true; multi: byte=0): boolean;
var
s, name: string;
begin
Result := false;
gametype := gametype_c;
if (ExtractFileExt(filename) <> 'tm') and
(ExtractFileExt(filename) <> 'tdm') then
name := filename + '.tm'
else name:=filename;
if mapfind then
s:=FindMap(name)
else
begin
if pos(Engine_Dir+Engine_ModDir, Name)=0 then
s:=Engine_Dir + Engine_ModDir + Name
else
s:=Name;
end;
if s<>'' then
begin
Name:=s;
Delete(Name, 1, length(Engine_Dir+Engine_ModDir));
end;
if (s='') or not FileExists(s) then
begin
//âíèìàíèå: êàðòà íå ñóùåñòâóåò. ïðè ðàçëè÷íûõ ðåæèìàõ èãðû ýòî ÷ðåâàòî
//ðàçíûìè ïîñëåäñòâèÿìè
if NET.Type_=NT_CLIENT then
begin
if NET_MapDownload(FileName) then
begin
s:=FindMap(name);
if s = '' then
begin
Log('^1Error: TFK map "^7' + FileName + '^1" ^1is not found!');
NET_Create(false);
CallMainMenu;
end
else
begin
if Map.lastfilename<>'' then
Map.Demo.RecStop;
if Map.LoadFromFile(s)=0 then
begin
Log('^2Load TFK map ^7"' + Name + '^7"');
Result:=true;
end else
begin
Log('^1Error: file ^7"' + Name + '^7" ^1is not TFK map!');
NET_Create(false);
CallMainMenu;
end;
end;
end else
begin
NET_Create(false);
CallMainMenu;
end;
end else Log('^1Error: TFK map "^7' + FileName + '^1" ^1is not found!');
end
else
begin
if Map.lastfilename<>'' then
Map.Demo.RecStop;
if Map.LoadFromFile(s) = 0 then
begin
Log('^2Load TFK map ^7"' + Name + '^7"');
Result := true;
if NET.Type_=NT_NONE then
net_Create(not Map.demoplay and not (multi=1) and ( (multi=2) or net_mapmode ) );
if NET.Type_=NT_SERVER then
NET_Server.changemap_send;
end
else
begin
Log('^1Error: file ^7"' + Name + '^7" ^1is not TFK map!');
NET_Create(false);
CallMainMenu;
end;
end;
end;
var
ModelUpdate : boolean = false;
function GetGameType(gametype: Byte): string;
begin
case gametype of
GT_FFA : Result := 'FFA : Free For All';
GT_TRIX : Result := 'TRIX : Trix Arena';
GT_RAIL : Result := 'RAIL : Rail Arena';
GT_TDM : Result := 'TDM : Team Deathmatch';
GT_CTF : Result := 'CTF : Capture The Flag';
GT_DOM : Result := 'DOM : Domination';
GT_CTC : Result := 'CTC : Catch The Chicken';
GT_SINGLE: Result := 'SP : Single player';
else
Result := '';
end;
if gametype = gametype_c then
Result := '^b' + Result + '^n';
end;
function SetGameType(str: string): boolean;
begin
Result := true;
if str = 'ffa' then gametype_c := GT_FFA else
if str = 'trix' then gametype_c := GT_TRIX else
if str = 'rail' then gametype_c := GT_RAIL else
if str = 'tdm' then gametype_c := GT_TDM else
if str = 'ctf' then gametype_c := GT_CTF else
if str = 'dom' then gametype_c := GT_DOM else
if str = 'ctc' then gametype_c := GT_CTC else
if str = 'sp' then gametype_c := GT_SINGLE else
Result := false;
end;
function Game_Cmd(Cmd: ShortString): boolean;
var
par : array [1..5] of string;
i, j, k, l : integer;
s, s1, str, str_ : string;
tex : TTexdata;
procedure GetMapList(Dir: string);
var
fd : TFindData;
begin
if FindFirst(Dir + '*', fd) then
repeat
if fd.Data.cFileName[0] = '.' then continue;
if DirectoryExists(Dir + fd.Data.cFileName) then
GetMapList(Dir + fd.Data.cFileName + '\')
else
if ExtractFileExt(fd.Data.cFileName) = 'tm' then
Log(' ' + ExtractFileNameEx(string(fd.Data.cFileName)));
until not FindNext(fd);
end;
function GetMapCount(Dir: string): integer;
var
fd : TFindData;
begin
Result := 0;
if FindFirst(Dir + '*', fd) then
repeat
if fd.Data.cFileName[0] = '.' then continue;
if DirectoryExists(Dir + fd.Data.cFileName) then
Result := Result + GetMapCount(Dir + fd.Data.cFileName + '\')
else
if ExtractFileExt(fd.Data.cFileName) = 'tm' then
inc(Result);
until not FindNext(fd);
end;
begin
Result := true;
str := Func_Lib.LowerCase(trim(cmd));
str_ := str;
for i := 1 to 5 do
par[i] := StrSpace(str);
if par[1] = 'íàõ' then
begin
case random(6) of
0 : Log('^2à ïîõ!');
1 : Log('^2à çàõ!');
2 : Log('^2èííàõ!');
3 : Log('^2êóé â íîñ!');
4 : Log('^2ïîõ!');
5 : Log('^23.14çäåö òû óìíûé...');
end;
// XProger: :)))
Exit;
end;
if par[1] = 'spgame' then
begin
if DirectoryExists(Engine_ModDir+par[2]) then
begin
Console_CMD('^2starting SP game ^b'+par[2]);
if par[2][length(par[2])]<>'\' then
par[2]:=par[2]+'\';
spgame_folder:=par[2];
maps_folder:=par[2]+'maps\';
// Log_Conwrite(false);
Console_CMD('exec '+par[2]+'autoexec.cfg');
Log_Conwrite(true);
end else Log('^1Wrong path');
Result:=true;
Exit;
end;
if par[2] = 'spgame_free' then
begin
if spgame_folder<>'' then
Log('^2spgame mode off')
else Log('^1There no SP game');
spgame_folder:='';
maps_folder:='maps\';
Result:=true;
Exit;
end;
//////////////////////////////////
// map
if par[1] = 'map' then
begin
Result:=true;
if NET.Type_=NT_CLIENT then
begin
Log('^1 Server-side command!');
Exit;
end;
par[2] := trim(par[2]);
str := Engine_Dir + Engine_ModDir;
i := pos(str, par[2]);
if i <> 0 then
Delete(par[2], i , Length(str));
LoadMap(par[2]);
Exit;
end;
if par[1] = 'map_list' then
begin
str := Engine_Dir + Engine_ModDir + MAPS_FOLDER;
Log('^3--- Map List (' + IntTostr(GetMapCount(str)) + ') ---');
GetMapList(str);
Log('^3-------------------');
Exit;
end;
if par[1] = 'model_list' then
begin
Log('^3--- Model List (' + IntTostr(Length(ModelName)) + ') ---');
for i := 0 to Length(ModelName) - 1 do
Log(' ' + ModelName[i]);
Log('^3---------------------');
Exit;
end;
if par[1] = 'gametype' then
begin
if par[2] = '' then
begin
Log('^3GameType is ^7"' + GetGameType(gametype_c) + '^7"');
Log('^3Possible values:');
j := 1;
for i := 1 to 8 do
begin
str := ' ' + GetGameType(j);
if str = ' ' then
break;
Log(str);
j := j shl 1;
end;
Log('^3----------------');
end
else
if SetGameType(par[2]) then
begin
Log('^2GameType changed to ^7"' + GetGameType(gametype_c) + '^7"');
cfgProc(cmd);
end
else
Log('^1Invalid GameType ^7"' + par[2] + '^7"');
Exit;
end;
if par[1] = 'demo' then
begin
if ExtractFileExt(par[2]) <> 'tdm' then
par[2] := par[2] + '.tdm';
str_ := trim(par[2]);
str := Engine_Dir + Engine_ModDir + 'demos\';
par[2] := GetFilePath(str, str_);
if FileExists(par[2]) then
if NET.Type_=NT_Client then
NET_Create(false);
str := Engine_Dir + Engine_ModDir;
i := pos(str, par[2]);
if i <> 0 then
Delete(par[2], i , Length(str));
if par[2] = '' then
par[2] := str_;
LoadMap(par[2], false);
Exit;
end;
if par[1] = 'sp_load' then
begin
Result:=true;
s:=Engine_Dir + Engine_ModDir+'saves\'+par[2]+'.tsg';
if FileExists(s) then
begin
s1:=s;
s:=Map.LoadGameFileName(s);
if ExtractFileExt(s) <> 'tm' then
s := s + '.tm';
str := Engine_Dir + Engine_ModDir + MAPS_FOLDER;
str_ := trim(s);
s := GetFilePath(str, str_);
str := Engine_Dir + Engine_ModDir;
if Map.LoadGame(s1, s)<>0 then
Log('Savegame is broken');
end else Log('^1Savegame not found');
Exit;
end;
if par[1] = 'fade' then
begin
if not Map.IsClientGame then
Map.fade_out:=not Map.fade_out;
Result:=true;
Exit;
end;
/// ÊÎÌÌÀÍÄÛ ÈÃÐÛ
if par[1] = 'say' then
begin
if Map.pl_find(-1, C_PLAYER_p1) then
begin
Result := true;
str_ := trim(cmd); // Íàì íå íóæåí lowercase
Delete(str_, 1, 4);
//Console_DeleteMsg(0); // Óäàëÿåì ïðåäûäóùóþ ìåññàãó :)
Map.Say(Map.pl_current.uid, str_);
end;
Exit;
end;
if par[1] = 'onsay' then
begin
onsay := not onsay;
SayEdit.Text := '';
Exit;
end;
if par[1] = 'sv_name' then
begin
if trim(par[2]) = '' then
Log('^3sv_name is ^7"^b' + sv_name + '^n^7"')
else
begin
sv_name := trim(Copy(cmd, Length(par[1]) + 1, Length(cmd)));
cfgProc('sv_name ' + sv_name);
Log('^2sv_name changed to ^7"^b' + sv_name + '^n^7"');
end;
Exit;
end;
if par[1] = 'sv_pass' then
begin
if trim(par[2]) = '' then
begin
sv_pass := '';
Log('^2sv_pass removed')
end
else
begin
sv_pass := trim(Copy(cmd, Length(par[1]) + 1, Length(cmd)));
Log('^2sv_pass changed to ^7"' + sv_pass + '^7"');
end;
cfgProc('sv_pass ' + sv_pass);
Exit;
end;
if par[1] = 'name' then
begin
if Map <> nil then
if trim(par[2]) <> '' then
begin
str := trim(cmd);
StrSpace(str);
p1name := trim(str);
cfgProc('name ' + p1name);
with Map do
if pl_find(-1, C_PLAYER_p1) then
SetPlayerName(pl_current.uid, p1name);
end
else
Log('name is: ' + p1name);
Exit;
end;
if par[1] = 'p2name' then
begin
if Map <> nil then
if trim(par[2]) <> '' then
begin
str := trim(cmd);
StrSpace(str);
p2name := trim(str);
cfgProc('p2name ' + p2name);
with Map do
if pl_find(-1, C_PLAYER_p2) then
SetPlayerName(pl_current.UID, p2name);
end
else
Log('p2name is: ' + p2name);
Exit;
end;
if par[1] = 'disjoin' then
if NET.Type_=NT_CLIENT then
par[1]:='net_disjoin'
else
begin
Result:=true;
while Map.pl_find(-1, C_Player_LOCAL) do
Map.pl_delete_current(true);
Exit;
end;
if (par[1] = 'r_rail') or
(par[1] = 'r_rail_p2') or
(par[1] = 'r_rail_enemy') then
begin
Result:=true;
if (par[2]='') then
begin
if par[1]='r_rail' then
Log('^3 R: '+IntToStr(r_rail_color.r)+' G: '+IntToStr(r_rail_color.g)+' B: '+IntToStr(r_rail_color.b)+' [0-255] type: '+IntToStr(r_rail_type)+' [0-'+IntToStr(railtype_high)+']');
if par[1]='r_rail_p2' then
Log('^3 R: '+IntToStr(r_p2_rail_color.r)+' G: '+IntToStr(r_p2_rail_color.g)+' B: '+IntToStr(r_p2_rail_color.b)+' [0-255] type: '+IntToStr(r_p2_rail_type)+' [0-'+IntToStr(railtype_high)+']');
if par[1]='r_rail_enemy' then
Log('^3 R: '+IntToStr(r_enemy_rail_color.r)+' G: '+IntToStr(r_enemy_rail_color.g)+' B: '+IntToStr(r_enemy_rail_color.b)+' [0-255] type: '+IntToStr(r_enemy_rail_type)+' [0-'+IntToStr(railtype_high)+']');
Exit;
end;
if (par[5]='') then
begin
Log('^1Parameter missing: '+par[1]+' R G B [0-255] railtype [0-'+IntToStr(railtype_high)+']');
Exit;
end;
i:=strtoint(par[2]);
j:=strtoint(par[3]);
k:=strtoint(par[4]);
l:=strtoint(par[5]);
if (i<0) or (i>=256) or (j<0) or (j>=256) or (k<0) or (k>=256) or
(l<0) or (l>railtype_high) then
begin
Log('^1Invalid Parameter: '+par[1]+' R G B [0-255] railtype [0-'+IntToStr(railtype_high)+']');
Exit;
end;
if par[1] = 'r_rail' then
begin
r_rail_color:=RGB(i, j, k);
r_rail_type:=l;
if Map.pl_find(-1, C_PLAYER_P1) then
with Map.pl_current do
begin
railcolor:=r_rail_color;
railtype:=r_rail_type;
if NET.Type_=NT_SERVER then
NET_Server.changename_Send(uid, name, modelname);
end;
str:='^2 Player1 rail set to';
end else
if par[1] = 'r_rail_p2' then
begin
r_p2_rail_color:=RGB(i, j, k);
r_p2_rail_type:=l;
if Map.pl_find(-1, C_PLAYER_P2) then
with Map.pl_current do
begin
railcolor:=r_p2_rail_color;
railtype:=r_p2_rail_type;
if NET.Type_=NT_SERVER then
NET_Server.changename_Send(uid, name, modelname);
end;
str:='^2 Player2 rail set to';
end else
begin
r_enemy_rail_color:=RGB(i, j, k);
r_enemy_rail_type:=l;
str:='^2 Enemy rail set to';
end;
Log(str+'^3 R: '+par[2]+' G: '+par[3]+' B: '+par[4]+' type: '+par[5]);
cfgproc(par[1]+' '+par[2]+' '+par[3]+' '+par[4]+' '+par[5]);
Exit;
end;
// Ñìåíà ìîäåëè èãðîêà
if par[1] = 'model' then
begin
if Map <> nil then
if trim(par[2]) <> '' then
begin
p1model := trim(par[2]);
with Map do
if pl_find(-1, C_PLAYER_p1) then
SetPlayerModel(pl_current.uid, p1model);
cfgProc('model ' + p1model);
if not ModelUpdate then
begin
ModelUpdate := true;
Menu_SetModel(1);
ModelUpdate := false;
end;
end
else
Log('model is: ' + p1model);
Exit;
end;
if par[1] = 'p2model' then
begin
if Map <> nil then
if trim(par[2]) <> '' then
begin
p2model := trim(par[2]);
with Map do
if pl_find(-1, C_PLAYER_p2) then
SetPlayerModel(pl_current.uid, p2model);
cfgProc('p2model ' + p2model);
if not ModelUpdate then
begin
ModelUpdate := true;
Menu_SetModel(2);
ModelUpdate := false;
end;
end
else
Log('p2model is: ' + p2model);
Exit;
end;
if not IsGame then
begin
Log('^2This command does not work in main menu!');
Exit;
end;
if par[1] = 'join' then
begin
Result:=true;
if gametype and GT_TEAMS=0 then
begin
Log('^2You are not in TeamPlay');
Exit;
end;
if par[2]='' then
begin
Log('^2There are BLUE and RED commands');
Exit;
end;
if par[2]='red' then
begin
with Map do
if pl_find(-1, C_PLAYER_P1) then
TeamJoin(pl_current.uid, TEAM_RED, true);
Exit;
end;
if par[2]='blue' then
begin
with Map do
if pl_find(-1, C_PLAYER_P1) then
TeamJoin(pl_current.uid, TEAM_BLUE, true);
Exit;
end;
Log('^2Invalid command name');
Exit;
end;
if par[1] = 'p2join' then
begin
Result:=true;
if gametype and GT_TEAMS=0 then
begin
Log('^2You are not in TeamPlay');
Exit;
end;
if par[2]='' then
begin
Log('^2There are BLUE and RED commands');
Exit;
end;
if par[2]='red' then
begin
with Map do
if pl_find(-1, C_PLAYER_P2) then
TeamJoin(pl_current.uid, TEAM_RED, true);
Exit;
end;
if par[2]='blue' then
begin
with Map do
if pl_find(-1, C_PLAYER_P2) then
TeamJoin(pl_current.uid, TEAM_BLUE, true);
Exit;
end;
Log('^2Invalid command name');
Exit;
end;
if par[1] = 'sp_save' then
begin
Result:=true;
if not Map.stopped then
if NET.Type_=NT_NONE then
begin
CreateDir(Engine_Dir + Engine_ModDir+'saves');
s:=Engine_Dir + Engine_ModDir+'saves\'+par[2]+'.tsg';
Map.SaveGame(s);
Log('^2Game saved to '+s);
end else Log('^1I can''t save multiplayer game');
Exit;