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 |
, disablewind
|
|
33 |
, morewind
|
|
34 |
, tagteam
|
|
35 |
, bottomborder: boolean;
|
|
36 |
damagefactor
|
|
37 |
, turntime
|
|
38 |
, health
|
|
39 |
, suddendeath
|
|
40 |
, caseprobability
|
|
41 |
, minestime
|
|
42 |
, landadds
|
|
43 |
, minedudpct
|
|
44 |
, explosives
|
|
45 |
, minesnum
|
|
46 |
, healthprobability
|
|
47 |
, healthcaseamount
|
|
48 |
, waterrise
|
|
49 |
, healthdecrease
|
|
50 |
, ropepct
|
|
51 |
, getawaytime
|
|
52 |
, worldedge: LongInt
|
10616
|
53 |
end;
|
|
54 |
PScheme = ^TScheme;
|
|
55 |
TSchemeArray = array [0..0] of TScheme;
|
|
56 |
PSchemeArray = ^TSchemeArray;
|
|
57 |
var
|
|
58 |
schemesList: PScheme;
|
|
59 |
schemesNumber: LongInt;
|
|
60 |
listOfSchemeNames: array[0..MAX_SCHEME_NAMES] of PChar;
|
10757
|
61 |
tmpScheme: TScheme;
|
|
62 |
|
|
63 |
const ints: array[0 .. 16] of record
|
|
64 |
name: shortstring;
|
|
65 |
param: ^LongInt;
|
|
66 |
end = (
|
|
67 |
(name: 'damagefactor'; param: @tmpScheme.damagefactor)
|
|
68 |
, (name: 'turntime'; param: @tmpScheme.turntime)
|
|
69 |
, (name: 'health'; param: @tmpScheme.health)
|
|
70 |
, (name: 'suddendeath'; param: @tmpScheme.suddendeath)
|
|
71 |
, (name: 'caseprobability'; param: @tmpScheme.caseprobability)
|
|
72 |
, (name: 'minestime'; param: @tmpScheme.minestime)
|
|
73 |
, (name: 'landadds'; param: @tmpScheme.landadds)
|
|
74 |
, (name: 'minedudpct'; param: @tmpScheme.minedudpct)
|
|
75 |
, (name: 'explosives'; param: @tmpScheme.explosives)
|
|
76 |
, (name: 'minesnum'; param: @tmpScheme.minesnum)
|
|
77 |
, (name: 'healthprobability'; param: @tmpScheme.healthprobability)
|
|
78 |
, (name: 'healthcaseamount'; param: @tmpScheme.healthcaseamount)
|
|
79 |
, (name: 'waterrise'; param: @tmpScheme.waterrise)
|
|
80 |
, (name: 'healthdecrease'; param: @tmpScheme.healthdecrease)
|
|
81 |
, (name: 'ropepct'; param: @tmpScheme.ropepct)
|
|
82 |
, (name: 'getawaytime'; param: @tmpScheme.getawaytime)
|
|
83 |
, (name: 'worldedge'; param: @tmpScheme.worldedge)
|
|
84 |
);
|
|
85 |
const bools: array[0 .. 19] of record
|
|
86 |
name: shortstring;
|
|
87 |
param: ^boolean;
|
|
88 |
end = (
|
|
89 |
(name: 'fortsmode'; param: @tmpScheme.fortsmode)
|
|
90 |
, (name: 'divteams'; param: @tmpScheme.divteams)
|
|
91 |
, (name: 'solidland'; param: @tmpScheme.solidland)
|
|
92 |
, (name: 'border'; param: @tmpScheme.border)
|
|
93 |
, (name: 'lowgrav'; param: @tmpScheme.lowgrav)
|
|
94 |
, (name: 'laser'; param: @tmpScheme.laser)
|
|
95 |
, (name: 'invulnerability'; param: @tmpScheme.invulnerability)
|
|
96 |
, (name: 'mines'; param: @tmpScheme.mines)
|
|
97 |
, (name: 'vampiric'; param: @tmpScheme.vampiric)
|
|
98 |
, (name: 'karma'; param: @tmpScheme.karma)
|
|
99 |
, (name: 'artillery'; param: @tmpScheme.artillery)
|
|
100 |
, (name: 'randomorder'; param: @tmpScheme.randomorder)
|
|
101 |
, (name: 'king'; param: @tmpScheme.king)
|
|
102 |
, (name: 'placehog'; param: @tmpScheme.placehog)
|
|
103 |
, (name: 'sharedammo'; param: @tmpScheme.sharedammo)
|
|
104 |
, (name: 'disablegirders'; param: @tmpScheme.disablegirders)
|
|
105 |
, (name: 'disablewind'; param: @tmpScheme.disablewind)
|
|
106 |
, (name: 'morewind'; param: @tmpScheme.morewind)
|
|
107 |
, (name: 'tagteam'; param: @tmpScheme.tagteam)
|
|
108 |
, (name: 'bottomborder'; param: @tmpScheme.bottomborder)
|
|
109 |
);
|
|
110 |
|
10616
|
111 |
|
|
112 |
procedure loadSchemes;
|
|
113 |
var f: PFSFile;
|
|
114 |
scheme: PScheme;
|
|
115 |
schemes: PSchemeArray;
|
|
116 |
s: shortstring;
|
10757
|
117 |
l, i, ii: Longword;
|
|
118 |
isFound: boolean;
|
10616
|
119 |
begin
|
|
120 |
f:= pfsOpenRead('/Config/schemes.ini');
|
|
121 |
schemesNumber:= 0;
|
|
122 |
|
|
123 |
if f <> nil then
|
|
124 |
begin
|
|
125 |
while (not pfsEOF(f)) and (schemesNumber = 0) do
|
|
126 |
begin
|
|
127 |
pfsReadLn(f, s);
|
|
128 |
|
|
129 |
if copy(s, 1, 5) = 'size=' then
|
|
130 |
schemesNumber:= strToInt(midStr(s, 6));
|
|
131 |
end;
|
|
132 |
|
|
133 |
//inc(schemesNumber); // add some default schemes
|
|
134 |
|
|
135 |
schemesList:= GetMem(sizeof(schemesList^) * (schemesNumber + 1));
|
|
136 |
schemes:= PSchemeArray(schemesList);
|
|
137 |
|
|
138 |
while (not pfsEOF(f)) do
|
|
139 |
begin
|
|
140 |
pfsReadLn(f, s);
|
|
141 |
|
|
142 |
i:= 1;
|
|
143 |
while(i <= length(s)) and (s[i] <> '\') do inc(i);
|
|
144 |
|
|
145 |
if i < length(s) then
|
|
146 |
begin
|
|
147 |
l:= strToInt(copy(s, 1, i - 1));
|
10757
|
148 |
delete(s, 1, i);
|
10616
|
149 |
|
10757
|
150 |
if (l <= schemesNumber) and (l > 0) then
|
10616
|
151 |
begin
|
|
152 |
scheme:= @schemes^[l - 1];
|
|
153 |
|
10757
|
154 |
if copy(s, 1, 5) = 'name=' then
|
|
155 |
tmpScheme. schemeName:= midStr(s, 6)
|
|
156 |
else if copy(s, 1, 12) = 'scriptparam=' then
|
|
157 |
tmpScheme. schemeName:= midStr(s, 13) else
|
|
158 |
begin
|
|
159 |
ii:= 0;
|
|
160 |
repeat
|
|
161 |
isFound:= readInt(ints[ii].name, s, ints[ii].param^);
|
|
162 |
inc(ii)
|
|
163 |
until isFound or (ii > High(ints));
|
|
164 |
|
|
165 |
if not isFound then
|
|
166 |
begin
|
|
167 |
ii:= 0;
|
|
168 |
repeat
|
|
169 |
isFound:= readBool(bools[ii].name, s, bools[ii].param^);
|
|
170 |
inc(ii)
|
|
171 |
until isFound or (ii > High(bools));
|
|
172 |
end;
|
|
173 |
end;
|
|
174 |
|
|
175 |
scheme^:= tmpScheme
|
10616
|
176 |
end;
|
|
177 |
end;
|
|
178 |
end;
|
|
179 |
|
|
180 |
pfsClose(f)
|
|
181 |
end;
|
|
182 |
end;
|
|
183 |
|
|
184 |
|
|
185 |
function getSchemesList: PPChar; cdecl;
|
|
186 |
var i, t, l: Longword;
|
|
187 |
scheme: PScheme;
|
|
188 |
begin
|
|
189 |
if schemesList = nil then
|
|
190 |
loadSchemes;
|
|
191 |
|
|
192 |
t:= schemesNumber;
|
|
193 |
if t >= MAX_SCHEME_NAMES then
|
|
194 |
t:= MAX_SCHEME_NAMES;
|
|
195 |
|
|
196 |
scheme:= schemesList;
|
|
197 |
for i:= 0 to Pred(t) do
|
|
198 |
begin
|
|
199 |
l:= length(scheme^.schemeName);
|
|
200 |
if l >= 255 then l:= 254;
|
|
201 |
scheme^.schemeName[l + 1]:= #0;
|
|
202 |
listOfSchemeNames[i]:= @scheme^.schemeName[1];
|
|
203 |
inc(scheme)
|
|
204 |
end;
|
|
205 |
|
|
206 |
listOfSchemeNames[t]:= nil;
|
|
207 |
|
|
208 |
getSchemesList:= listOfSchemeNames
|
|
209 |
end;
|
|
210 |
|
|
211 |
|
|
212 |
procedure freeSchemesList;
|
|
213 |
begin
|
|
214 |
if schemesList <> nil then
|
10757
|
215 |
FreeMem(schemesList, sizeof(schemesList^) * (schemesNumber + 1))
|
10616
|
216 |
end;
|
|
217 |
|
|
218 |
end.
|