10616
|
1 |
unit uFLSchemes;
|
|
2 |
interface
|
|
3 |
uses uFLTypes;
|
|
4 |
|
|
5 |
function getSchemesList: PPChar; cdecl;
|
|
6 |
procedure freeSchemesList;
|
|
7 |
|
|
8 |
implementation
|
|
9 |
uses uFLUtils, uFLIPC, uPhysFSLayer, uFLData;
|
|
10 |
|
|
11 |
const MAX_SCHEME_NAMES = 64;
|
|
12 |
type
|
|
13 |
TScheme = record
|
10754
|
14 |
schemeName
|
|
15 |
, scriptparam : shortstring;
|
|
16 |
fortsmode
|
|
17 |
, divteams
|
|
18 |
, solidland
|
|
19 |
, border
|
|
20 |
, lowgrav
|
|
21 |
, laser
|
|
22 |
, invulnerability
|
|
23 |
, mines
|
|
24 |
, vampiric
|
|
25 |
, karma
|
|
26 |
, artillery
|
|
27 |
, randomorder
|
|
28 |
, king
|
|
29 |
, placehog
|
|
30 |
, sharedammo
|
|
31 |
, disablegirders
|
|
32 |
, randomorder
|
|
33 |
, king
|
|
34 |
, placehog
|
|
35 |
, sharedammo
|
|
36 |
, disablegirders
|
|
37 |
, randomorder
|
|
38 |
, king
|
|
39 |
, placehog
|
|
40 |
, sharedammo
|
|
41 |
, disablegirders
|
|
42 |
, disablewind
|
|
43 |
, morewind
|
|
44 |
, tagteam
|
|
45 |
, bottomborder: boolean;
|
|
46 |
damagefactor
|
|
47 |
, turntime
|
|
48 |
, health
|
|
49 |
, suddendeath
|
|
50 |
, caseprobability
|
|
51 |
, minestime
|
|
52 |
, landadds
|
|
53 |
, minedudpct
|
|
54 |
, explosives
|
|
55 |
, minesnum
|
|
56 |
, healthprobability
|
|
57 |
, healthcaseamount
|
|
58 |
, waterrise
|
|
59 |
, healthdecrease
|
|
60 |
, ropepct
|
|
61 |
, getawaytime
|
|
62 |
, worldedge: LongInt
|
10616
|
63 |
end;
|
|
64 |
PScheme = ^TScheme;
|
|
65 |
TSchemeArray = array [0..0] of TScheme;
|
|
66 |
PSchemeArray = ^TSchemeArray;
|
|
67 |
var
|
|
68 |
schemesList: PScheme;
|
|
69 |
schemesNumber: LongInt;
|
|
70 |
listOfSchemeNames: array[0..MAX_SCHEME_NAMES] of PChar;
|
|
71 |
|
|
72 |
procedure loadSchemes;
|
|
73 |
var f: PFSFile;
|
|
74 |
scheme: PScheme;
|
|
75 |
schemes: PSchemeArray;
|
|
76 |
s: shortstring;
|
|
77 |
l, i: Longword;
|
|
78 |
begin
|
|
79 |
f:= pfsOpenRead('/Config/schemes.ini');
|
|
80 |
schemesNumber:= 0;
|
|
81 |
|
|
82 |
if f <> nil then
|
|
83 |
begin
|
|
84 |
while (not pfsEOF(f)) and (schemesNumber = 0) do
|
|
85 |
begin
|
|
86 |
pfsReadLn(f, s);
|
|
87 |
|
|
88 |
if copy(s, 1, 5) = 'size=' then
|
|
89 |
schemesNumber:= strToInt(midStr(s, 6));
|
|
90 |
end;
|
|
91 |
|
|
92 |
//inc(schemesNumber); // add some default schemes
|
|
93 |
|
|
94 |
schemesList:= GetMem(sizeof(schemesList^) * (schemesNumber + 1));
|
|
95 |
schemes:= PSchemeArray(schemesList);
|
|
96 |
|
|
97 |
while (not pfsEOF(f)) do
|
|
98 |
begin
|
|
99 |
pfsReadLn(f, s);
|
|
100 |
|
|
101 |
i:= 1;
|
|
102 |
while(i <= length(s)) and (s[i] <> '\') do inc(i);
|
|
103 |
|
|
104 |
if i < length(s) then
|
|
105 |
begin
|
|
106 |
l:= strToInt(copy(s, 1, i - 1));
|
|
107 |
|
|
108 |
if (l < schemesNumber) and (l > 0) then
|
|
109 |
begin
|
|
110 |
scheme:= @schemes^[l - 1];
|
|
111 |
|
|
112 |
if copy(s, i + 1, 5) = 'name=' then
|
|
113 |
scheme^. schemeName:= midStr(s, i + 6);
|
|
114 |
end;
|
|
115 |
end;
|
|
116 |
end;
|
|
117 |
|
|
118 |
pfsClose(f)
|
|
119 |
end;
|
|
120 |
{
|
|
121 |
name=AI TEST
|
10754
|
122 |
fortsmode
|
|
123 |
divteams
|
|
124 |
solidland
|
|
125 |
border
|
|
126 |
lowgrav
|
|
127 |
laser
|
|
128 |
invulnerability
|
|
129 |
mines
|
10616
|
130 |
damagefactor=100
|
|
131 |
turntime=40
|
|
132 |
health=100
|
|
133 |
suddendeath=0
|
|
134 |
caseprobability=5
|
10754
|
135 |
vampiric
|
|
136 |
karma
|
|
137 |
artillery
|
10616
|
138 |
minestime=0
|
|
139 |
landadds=4
|
10754
|
140 |
randomorder
|
|
141 |
king
|
|
142 |
placehog
|
|
143 |
sharedammo
|
|
144 |
disablegirders
|
10616
|
145 |
minedudpct=100
|
|
146 |
explosives=40
|
10754
|
147 |
disablelandobjects
|
|
148 |
aisurvival
|
|
149 |
resethealth
|
|
150 |
infattack
|
|
151 |
resetweps
|
|
152 |
perhogammo
|
10616
|
153 |
minesnum=0
|
|
154 |
healthprobability=100
|
|
155 |
healthcaseamount=50
|
|
156 |
waterrise=0
|
|
157 |
healthdecrease=0
|
10754
|
158 |
disablewind
|
|
159 |
morewind
|
10616
|
160 |
ropepct=100
|
10754
|
161 |
tagteam
|
10616
|
162 |
getawaytime=100
|
10754
|
163 |
bottomborder
|
10616
|
164 |
worldedge=1
|
|
165 |
scriptparam=@Invalid()
|
|
166 |
}
|
|
167 |
end;
|
|
168 |
|
|
169 |
|
|
170 |
function getSchemesList: PPChar; cdecl;
|
|
171 |
var i, t, l: Longword;
|
|
172 |
scheme: PScheme;
|
|
173 |
begin
|
|
174 |
if schemesList = nil then
|
|
175 |
loadSchemes;
|
|
176 |
|
|
177 |
t:= schemesNumber;
|
|
178 |
if t >= MAX_SCHEME_NAMES then
|
|
179 |
t:= MAX_SCHEME_NAMES;
|
|
180 |
|
|
181 |
scheme:= schemesList;
|
|
182 |
for i:= 0 to Pred(t) do
|
|
183 |
begin
|
|
184 |
l:= length(scheme^.schemeName);
|
|
185 |
if l >= 255 then l:= 254;
|
|
186 |
scheme^.schemeName[l + 1]:= #0;
|
|
187 |
listOfSchemeNames[i]:= @scheme^.schemeName[1];
|
|
188 |
inc(scheme)
|
|
189 |
end;
|
|
190 |
|
|
191 |
listOfSchemeNames[t]:= nil;
|
|
192 |
|
|
193 |
getSchemesList:= listOfSchemeNames
|
|
194 |
end;
|
|
195 |
|
|
196 |
|
|
197 |
procedure freeSchemesList;
|
|
198 |
begin
|
|
199 |
if schemesList <> nil then
|
|
200 |
FreeMem(schemesList, sizeof(schemesList^) * schemesNumber)
|
|
201 |
end;
|
|
202 |
|
|
203 |
end.
|