summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a3bcb61)
raw | patch | inline | side by side (parent: a3bcb61)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 26 Aug 2017 00:47:31 +0000 (03:47 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 26 Aug 2017 05:12:37 +0000 (08:12 +0300) |
src/shared/mapdesc.txt | patch | blob | history | |
src/shared/xdynrec.pas | patch | blob | history |
diff --git a/src/shared/mapdesc.txt b/src/shared/mapdesc.txt
index 759d3759549920e675299181de3639ad7f76aa53..ed949e46c3f798daf426417ad0c990e9fbed631b 100644 (file)
--- a/src/shared/mapdesc.txt
+++ b/src/shared/mapdesc.txt
////////////////////////////////////////////////////////////////////////////////
// main blocks
-TMapHeaderRec_1 is "map" size 452 bytes header {
+TMapHeaderRec_1 is "map" size 452 bytes header binblock 7 {
//_ is "version" type uint minvalue 1 maxvalue 1;
MapName is "name" type char[32] offset 0;
MapAuthor is "author" type char[32] offset 32 default "" omitdefault;
Title is "title" type string default "" omitdefault;
}
-TTextureRec_1 is "texture" size 65 bytes {
+TTextureRec_1 is "texture" size 65 bytes binblock 1 {
Resource is "path" type char[64] offset 0;
Anim is "animated" type bool offset 64 default false omitdefault;
// internals
TexIdx is "texidx" type uint internal;
}
-TPanelRec_1 is "panel" size 18 bytes {
+TPanelRec_1 is "panel" size 18 bytes binblock 2 {
//X is "x" type int offset 0;
//Y is "y" type int offset 4;
Pos is "position" type point offset 0 as xy;
PanIdx is "panidx" type uint internal;
}
-TItemRec_1 is "item" size 10 bytes {
+TItemRec_1 is "item" size 10 bytes binblock 3 {
//X is "x" type int offset 0;
//Y is "y" type int offset 4;
Pos is "position" type point offset 0 as xy;
ItemIdx is "itemidx" type uint internal;
}
-TMonsterRec_1 is "monster" size 10 bytes {
+TMonsterRec_1 is "monster" size 10 bytes binblock 5 {
//X is "x" type int offset 0;
//Y is "y" type int offset 4;
Pos is "position" type point offset 0 as xy;
MonsIdx is "monsidx" type uint internal;
}
-TAreaRec_1 is "area" size 10 bytes {
+TAreaRec_1 is "area" size 10 bytes binblock 4 {
//X is "x" type int offset 0;
//Y is "y" type int offset 4;
Pos is "position" type point offset 0 as xy;
AreaIdx is "areaidx" type uint internal;
}
-TTriggerRec_1 is "trigger" size 148 bytes {
+TTriggerRec_1 is "trigger" size 148 bytes binblock 6 {
//X is "x" type int offset 0;
//Y is "y" type int offset 4;
Pos is "position" type point offset 0 as xy;
diff --git a/src/shared/xdynrec.pas b/src/shared/xdynrec.pas
index 71a95bf609811affa3c20776fe1d7b2d9ed489ed..f3400d87730d0594b176a233c5d5913558c5be21 100644 (file)
--- a/src/shared/xdynrec.pas
+++ b/src/shared/xdynrec.pas
private
procedure cleanup ();
- procedure parse (pr: TTextParser);
+ procedure parseDef (pr: TTextParser);
procedure setIVal (v: Integer); inline;
procedure setSVal (const v: AnsiString); inline;
mFields: TDynField.TDynFieldArray;
mTrigTypes: array of AnsiString; // if this is triggerdata, we'll hold list of triggers here
mHeader: Boolean; // true for header record
+ mBinBlock: Integer; // -1: none
private
- procedure parse (pr: TTextParser); // parse definition
+ procedure parseDef (pr: TTextParser); // parse definition
function findByName (const aname: AnsiString): Integer; inline;
function hasByName (const aname: AnsiString): Boolean; inline;
private
procedure cleanup ();
- procedure parse (pr: TTextParser); // parse definition
+ procedure parseDef (pr: TTextParser); // parse definition
function findByName (const aname: AnsiString): Integer; inline;
function hasByName (const aname: AnsiString): Boolean; inline;
ebs: array of TDynEBS;
private
- procedure parse (pr: TTextParser);
+ procedure parseDef (pr: TTextParser);
function getHeader (): TDynRecord; inline;
constructor TDynField.Create (pr: TTextParser);
begin
cleanup();
- parse(pr);
+ parseDef(pr);
end;
end;
-procedure TDynField.parse (pr: TTextParser);
+procedure TDynField.parseDef (pr: TTextParser);
var
fldname: AnsiString;
fldtype: AnsiString;
mFields := nil;
mTrigTypes := nil;
mHeader := false;
- parse(pr);
+ mBinBlock := -1;
+ parseDef(pr);
end;
end;
-procedure TDynRecord.parse (pr: TTextParser);
+procedure TDynRecord.parseDef (pr: TTextParser);
var
fld: TDynField;
tdn: AnsiString;
mPasName := pr.expectId(); // pascal record name
pr.expectId('is');
mName := pr.expectStr();
- if pr.eatId('header') then mHeader := true;
- if pr.eatId('size') then
+ while (pr.tokType <> pr.TTBegin) do
begin
- mSize := pr.expectInt();
- if (mSize < 1) then raise Exception.Create(Format('invalid record ''%s'' size: %d', [mName, mSize]));
- pr.expectId('bytes');
+ if pr.eatId('header') then begin mHeader := true; continue; end;
+ if pr.eatId('size') then
+ begin
+ if (mSize > 0) then raise Exception.Create(Format('duplicate `size` in record ''%s''', [mName]));
+ mSize := pr.expectInt();
+ if (mSize < 1) then raise Exception.Create(Format('invalid record ''%s'' size: %d', [mName, mSize]));
+ pr.expectId('bytes');
+ continue;
+ end;
+ if pr.eatId('binblock') then
+ begin
+ if (mBinBlock >= 0) then raise Exception.Create(Format('duplicate `binblock` in record ''%s''', [mName]));
+ mBinBlock := pr.expectInt();
+ if (mBinBlock < 1) then raise Exception.Create(Format('invalid record ''%s'' binblock: %d', [mName, mBinBlock]));
+ continue;
+ end;
end;
- if pr.eatId('header') then mHeader := true;
end;
pr.expectTT(pr.TTBegin);
constructor TDynEBS.Create (pr: TTextParser);
begin
cleanup();
- parse(pr);
+ parseDef(pr);
end;
end;
-procedure TDynEBS.parse (pr: TTextParser);
+procedure TDynEBS.parseDef (pr: TTextParser);
var
idname: AnsiString;
cv, v: Integer;
trigDatas := nil;
ebs := nil;
curheader := nil;
- parse(pr);
+ parseDef(pr);
end;
end;
-procedure TDynMapDef.parse (pr: TTextParser);
+procedure TDynMapDef.parseDef (pr: TTextParser);
var
dr, hdr: TDynRecord;
eb: TDynEBS;