From: Ketmar Dark Date: Sat, 26 Aug 2017 00:47:31 +0000 (+0300) Subject: added `binblock` to mapdef X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=bfebb0f03424f28d5241607f5d927c5b4c460ebe;p=d2df-sdl.git added `binblock` to mapdef --- diff --git a/src/shared/mapdesc.txt b/src/shared/mapdesc.txt index 759d375..ed949e4 100644 --- a/src/shared/mapdesc.txt +++ b/src/shared/mapdesc.txt @@ -19,7 +19,7 @@ //////////////////////////////////////////////////////////////////////////////// // 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; @@ -33,14 +33,14 @@ TMapHeaderRec_1 is "map" size 452 bytes header { 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; @@ -57,7 +57,7 @@ TPanelRec_1 is "panel" size 18 bytes { 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; @@ -69,7 +69,7 @@ TItemRec_1 is "item" size 10 bytes { 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; @@ -81,7 +81,7 @@ TMonsterRec_1 is "monster" size 10 bytes { 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; @@ -93,7 +93,7 @@ TAreaRec_1 is "area" size 10 bytes { 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 71a95bf..f3400d8 100644 --- a/src/shared/xdynrec.pas +++ b/src/shared/xdynrec.pas @@ -80,7 +80,7 @@ type private procedure cleanup (); - procedure parse (pr: TTextParser); + procedure parseDef (pr: TTextParser); procedure setIVal (v: Integer); inline; procedure setSVal (const v: AnsiString); inline; @@ -140,9 +140,10 @@ type 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; @@ -190,7 +191,7 @@ type 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; @@ -223,7 +224,7 @@ type ebs: array of TDynEBS; private - procedure parse (pr: TTextParser); + procedure parseDef (pr: TTextParser); function getHeader (): TDynRecord; inline; @@ -263,7 +264,7 @@ end; constructor TDynField.Create (pr: TTextParser); begin cleanup(); - parse(pr); + parseDef(pr); end; @@ -504,7 +505,7 @@ begin end; -procedure TDynField.parse (pr: TTextParser); +procedure TDynField.parseDef (pr: TTextParser); var fldname: AnsiString; fldtype: AnsiString; @@ -1060,7 +1061,8 @@ begin mFields := nil; mTrigTypes := nil; mHeader := false; - parse(pr); + mBinBlock := -1; + parseDef(pr); end; @@ -1148,7 +1150,7 @@ begin end; -procedure TDynRecord.parse (pr: TTextParser); +procedure TDynRecord.parseDef (pr: TTextParser); var fld: TDynField; tdn: AnsiString; @@ -1180,14 +1182,25 @@ begin 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); @@ -1383,7 +1396,7 @@ end; constructor TDynEBS.Create (pr: TTextParser); begin cleanup(); - parse(pr); + parseDef(pr); end; @@ -1463,7 +1476,7 @@ begin end; -procedure TDynEBS.parse (pr: TTextParser); +procedure TDynEBS.parseDef (pr: TTextParser); var idname: AnsiString; cv, v: Integer; @@ -1546,7 +1559,7 @@ begin trigDatas := nil; ebs := nil; curheader := nil; - parse(pr); + parseDef(pr); end; @@ -1639,7 +1652,7 @@ begin end; -procedure TDynMapDef.parse (pr: TTextParser); +procedure TDynMapDef.parseDef (pr: TTextParser); var dr, hdr: TDynRecord; eb: TDynEBS;