summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d884101)
raw | patch | inline | side by side (parent: d884101)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Tue, 29 Aug 2017 20:14:55 +0000 (23:14 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Tue, 29 Aug 2017 21:53:42 +0000 (00:53 +0300) |
src/shared/xdynrec.pas | patch | blob | history |
diff --git a/src/shared/xdynrec.pas b/src/shared/xdynrec.pas
index 087724d7949217d016d2a03006c6470a6422e324..c6897578d7d6334e3f9f71f964e64753013b6338 100644 (file)
--- a/src/shared/xdynrec.pas
+++ b/src/shared/xdynrec.pas
procedure writeTo (wr: TTextWriter; putHeader: Boolean=true);
procedure writeBinTo (st: TStream; trigbufsz: Integer=-1);
+ // find field with `TriggerType` type
+ function trigTypeField (): TDynField;
+
public
property id: AnsiString read mId; // for map parser
property pasname: AnsiString read mPasName;
raise Exception.Create(Format('cannot parse field ''%s'' yet', [mName]));
end;
-
procedure TDynField.parseBinValue (st: TStream);
var
rec, rc: TDynRecord;
assert(mMaxDim > 0);
rec := mOwner;
// find trigger definition
- tfld := rec.field['type'];
- if (tfld = nil) then raise Exception.Create(Format('triggerdata value for field ''%s'' in record ''%s'' without ''type'' field', [mName, rec.mName]));
- if (tfld.mEBS <> TEBS.TEnum) then raise Exception.Create(Format('triggerdata value for field ''%s'' in record ''%s'' with bad ''type'' field', [mName, rec.mName]));
+ tfld := rec.trigTypeField();
+ if (tfld = nil) then raise Exception.Create(Format('triggerdata value for field ''%s'' in record ''%s'' without TriggerType field', [mName, rec.mName]));
rc := mOwner.mOwner.findTrigFor(tfld.mSVal); // find in mapdef
if (rc = nil) then raise Exception.Create(Format('triggerdata definition for field ''%s'' in record ''%s'' with type ''%s'' not found', [mName, rec.mName, tfld.mSVal]));
rc := rc.clone();
begin
rec := mOwner;
// find trigger definition
- tfld := rec.field['type'];
+ tfld := rec.trigTypeField();
if (tfld = nil) then raise Exception.Create(Format('triggerdata value for field ''%s'' in record ''%s'' without ''type'' field', [mName, rec.mName]));
- if (tfld.mEBS <> TEBS.TEnum) then raise Exception.Create(Format('triggerdata value for field ''%s'' in record ''%s'' with bad ''type'' field', [mName, rec.mName]));
rc := mOwner.mOwner.findTrigFor(tfld.mSVal); // find in mapdef
if (rc = nil) then raise Exception.Create(Format('triggerdata definition for field ''%s'' in record ''%s'' with type ''%s'' not found', [mName, rec.mName, tfld.mSVal]));
rc := rc.clone();
end;
+function TDynRecord.trigTypeField (): TDynField;
+var
+ fld: TDynField;
+ es: TDynEBS = nil;
+begin
+ for fld in mFields do
+ begin
+ if (fld.mEBS <> TDynField.TEBS.TEnum) then continue;
+ if not (fld.mEBSType is TDynEBS) then continue;
+ es := (fld.mEBSType as TDynEBS);
+ assert(es <> nil);
+ if (CompareText(es.mName, 'TriggerType') = 0) then begin result := fld; exit; end;
+ end;
+ result := nil;
+end;
+
+
procedure TDynRecord.parseDef (pr: TTextParser);
var
fld: TDynField;