1 (* Copyright (C) DooM 2D:Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE a_modes.inc}
21 -----------------------------------
22 MAPDEF.PAS ÂÅÐÑÈß ÎÒ 22.03.09
24 Ïîääåðæêà êàðò âåðñèè 1
25 -----------------------------------
35 MAP_SIGNATURE
= 'MAP';
39 TEXTURE_NAME_WATER
= '_water_0';
40 TEXTURE_NAME_ACID1
= '_water_1';
41 TEXTURE_NAME_ACID2
= '_water_2';
45 TDFPoint
= packed record
49 Char16
= packed array[0..15] of Char;
50 Char32
= packed array[0..31] of Char;
51 Char64
= packed array[0..63] of Char;
52 Char100
= packed array[0..99] of Char;
53 Char256
= packed array[0..255] of Char;
54 Byte128
= packed array[0..127] of Byte;
59 TTexturesRec1Array
= array of TTextureRec_1
;
60 TPanelsRec1Array
= array of TPanelRec_1
;
61 TItemsRec1Array
= array of TItemRec_1
;
62 TMonsterRec1Array
= array of TMonsterRec_1
;
63 TAreasRec1Array
= array of TAreaRec_1
;
64 TTriggersRec1Array
= array of TTriggerRec_1
;
67 function GetMapHeader (rec
: TDynRecord
): TMapHeaderRec_1
;
68 function GetTextures (rec
: TDynRecord
): TTexturesRec1Array
;
69 function GetPanels (rec
: TDynRecord
): TPanelsRec1Array
;
70 function GetItems (rec
: TDynRecord
): TItemsRec1Array
;
71 function GetAreas (rec
: TDynRecord
): TAreasRec1Array
;
72 function GetMonsters (rec
: TDynRecord
): TMonsterRec1Array
;
73 function GetTriggers (rec
: TDynRecord
): TTriggersRec1Array
;
79 {e_log,} xparser
, xstreams
;
82 function GetMapHeader (rec
: TDynRecord
): TMapHeaderRec_1
;
84 ws
: TSFSMemoryChunkStream
= nil;
86 FillChar(result
, sizeof(result
), 0);
87 if (rec
= nil) then exit
;
89 ws
:= TSFSMemoryChunkStream
.Create(@result
, sizeof(result
));
90 rec
.writeBinTo(ws
, -1, true); // only fields
92 FillChar(result
, sizeof(result
), 0);
98 function GetTextures (rec
: TDynRecord
): TTexturesRec1Array
;
100 ws
: TSFSMemoryChunkStream
= nil;
105 fld
:= rec
.field
['texture'];
106 if (fld
= nil) or (fld
.baseType
<> fld
.TType
.TList
) or (fld
.list
.count
= 0) then exit
;
107 ws
:= TSFSMemoryChunkStream
.Create(nil, 0);
109 SetLength(result
, fld
.list
.count
);
110 for f
:= 0 to fld
.list
.count
-1 do
112 FillChar(result
[f
], sizeof(result
[f
]), 0);
113 ws
.setup(@result
[f
], sizeof(result
[f
]));
114 fld
.list
[f
].writeBinTo(ws
, -1, true); // only fields
123 function GetPanels (rec
: TDynRecord
): TPanelsRec1Array
;
125 ws
: TSFSMemoryChunkStream
= nil;
130 fld
:= rec
.field
['panel'];
131 if (fld
= nil) or (fld
.baseType
<> fld
.TType
.TList
) or (fld
.list
.count
= 0) then exit
;
132 ws
:= TSFSMemoryChunkStream
.Create(nil, 0);
134 SetLength(result
, fld
.list
.count
);
135 for f
:= 0 to fld
.list
.count
-1 do
137 FillChar(result
[f
], sizeof(result
[f
]), 0);
138 ws
.setup(@result
[f
], sizeof(result
[f
]));
139 fld
.list
[f
].writeBinTo(ws
, -1, true); // only fields
148 function GetItems (rec
: TDynRecord
): TItemsRec1Array
;
150 ws
: TSFSMemoryChunkStream
= nil;
155 fld
:= rec
.field
['item'];
156 if (fld
= nil) or (fld
.baseType
<> fld
.TType
.TList
) or (fld
.list
.count
= 0) then exit
;
157 ws
:= TSFSMemoryChunkStream
.Create(nil, 0);
159 SetLength(result
, fld
.list
.count
);
160 for f
:= 0 to fld
.list
.count
-1 do
162 FillChar(result
[f
], sizeof(result
[f
]), 0);
163 ws
.setup(@result
[f
], sizeof(result
[f
]));
164 fld
.list
[f
].writeBinTo(ws
, -1, true); // only fields
173 function GetAreas (rec
: TDynRecord
): TAreasRec1Array
;
175 ws
: TSFSMemoryChunkStream
= nil;
180 fld
:= rec
.field
['area'];
181 if (fld
= nil) or (fld
.baseType
<> fld
.TType
.TList
) or (fld
.list
.count
= 0) then exit
;
182 ws
:= TSFSMemoryChunkStream
.Create(nil, 0);
184 SetLength(result
, fld
.list
.count
);
185 for f
:= 0 to fld
.list
.count
-1 do
187 FillChar(result
[f
], sizeof(result
[f
]), 0);
188 ws
.setup(@result
[f
], sizeof(result
[f
]));
189 fld
.list
[f
].writeBinTo(ws
, -1, true); // only fields
198 function GetMonsters (rec
: TDynRecord
): TMonsterRec1Array
;
200 ws
: TSFSMemoryChunkStream
= nil;
205 fld
:= rec
.field
['monster'];
206 if (fld
= nil) or (fld
.baseType
<> fld
.TType
.TList
) or (fld
.list
.count
= 0) then exit
;
207 ws
:= TSFSMemoryChunkStream
.Create(nil, 0);
209 SetLength(result
, fld
.list
.count
);
210 for f
:= 0 to fld
.list
.count
-1 do
212 FillChar(result
[f
], sizeof(result
[f
]), 0);
213 ws
.setup(@result
[f
], sizeof(result
[f
]));
214 fld
.list
[f
].writeBinTo(ws
, -1, true); // only fields
223 function GetTriggers (rec
: TDynRecord
): TTriggersRec1Array
;
225 ws
: TSFSMemoryChunkStream
= nil;
232 fld
:= rec
.field
['trigger'];
233 if (fld
= nil) or (fld
.baseType
<> fld
.TType
.TList
) or (fld
.list
.count
= 0) then exit
;
234 ws
:= TSFSMemoryChunkStream
.Create(nil, 0);
236 //wr := TFileTextWriter.Create('z00.txt');
237 SetLength(result
, fld
.list
.count
);
238 for f
:= 0 to fld
.list
.count
-1 do
240 FillChar(result
[f
], sizeof(result
[f
]), 0);
241 //e_LogWritefln(': trigger #%s; TexturePanel=%s', [f, result[f].TexturePanel]);
242 ws
.setup(@result
[f
], sizeof(result
[f
]));
243 fld
.list
[f
].writeBinTo(ws
, -1, true); // only fields
245 e_LogWritefln(': trigger #%s; X=%s; Y=%s; Width=%s; Height=%s; Enabled=%s; TexturePanel=%s; TriggerType=%s; ActivateType=%s; Keys=%s', [f,
251 result[f].TexturePanel,
252 result[f].TriggerType,
253 result[f].ActivateType,
256 //e_LogWritefln('***'#10'%s'#10'***', [);
257 fld.list[f].writeTo(wr);
260 AssignFile(fo, 'z00.bin');
262 BlockWrite(fo, result[f], sizeof(result[f]));