-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynamic_gamemodes.pas
More file actions
94 lines (76 loc) · 1.9 KB
/
dynamic_gamemodes.pas
File metadata and controls
94 lines (76 loc) · 1.9 KB
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
unit dynamic_gamemodes;
interface
uses gunsl_config, BaseGameData;
const
SERVER_GAMETYPES_SECTION:PChar = 'sv_script_gametypes';
CLIENT_GAMETYPES_SECTION:PChar = 'cl_script_gametypes';
function Init(dwFlags:cardinal):boolean;
implementation
function GetClientGameCLSIDByName(name:PChar):PChar; stdcall;
begin
Log('Searching client script CLSID for gametype '+name);
if game_ini_line_exist(CLIENT_GAMETYPES_SECTION, name) then begin
result:=game_ini_read_string(CLIENT_GAMETYPES_SECTION, name);
Log('Found CLSID '+result);
end else begin
Log('Client gametype '+name+' not found!');
result:='';
end;
end;
function GetServerGameCLSIDByName(name:PChar):PChar; stdcall;
begin
Log('Searching server script CLSID for gametype '+name);
if game_ini_line_exist(SERVER_GAMETYPES_SECTION, name) then begin
result:=game_ini_read_string(SERVER_GAMETYPES_SECTION, name);
Log('Found CLSID '+result);
end else begin
Log('Server gametype '+name+' not found!');
result:='';
end;
end;
procedure ServerCLSIDSelector_Patch();
asm
pop ecx //ret addr
push 0
push ecx //ret addr
lea ecx, [esp+4]
pushad
lea ebx, [esp+$40]
push ecx
push ebx
call GetServerGameCLSIDByName
pop ecx
mov [ecx], eax
popad
end;
procedure ClientCLSIDSelector_Patch();
asm
pop ecx //ret addr
push 0
push ecx //ret addr
lea ecx, [esp+4]
pushad
lea ebx, [esp+$30]
push ecx
push ebx
call GetClientGameCLSIDByName
pop ecx
mov [ecx], eax
popad
end;
function Init(dwFlags:cardinal):boolean;
var
addr:cardinal;
begin
result:=false;
if dwFlags and FLG_PATCH_GAME >0 then begin
//ñåðâåðíûé òèï èãðû
addr:=xrGame_addr+$31d30c;
if not WriteJump(addr, cardinal(@ServerCLSIDSelector_Patch), 5, true) then exit;
//êëèåíòñêèé òèï èãðû
addr:=xrGame_addr+$1E9292;
if not WriteJump(addr, cardinal(@ClientCLSIDSelector_Patch), 5, true) then exit;
end;
result:=true;
end;
end.