summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3d8489b)
raw | patch | inline | side by side (parent: 3d8489b)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 7 Sep 2017 04:56:51 +0000 (07:56 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 7 Sep 2017 04:57:04 +0000 (07:57 +0300) |
src/game/g_map.pas | patch | blob | history | |
src/game/g_triggers.pas | patch | blob | history | |
src/shared/MAPDEF.pas | patch | blob | history |
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index e976be49c616045a92b12fd0b2c4844fd9227be2..d18aeceac9bad1055d4cdcf0c94f963d715b00c8 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
//TexturePanel: Integer;
tnum: Integer;
id: Integer;
- texPanIdx: Integer;
- LiftPanelIdx: Integer;
- DoorPanelIdx: Integer;
- ShotPanelIdx: Integer;
- MPlatPanelIdx: Integer;
trigrec: TDynRecord;
- texPan: TDynRecord;
- liftPan: TDynRecord;
- doorPan: TDynRecord;
- shotPan: TDynRecord;
- mplatPan: TDynRecord;
+ // texture pane;
+ texPanelIdx: Integer;
+ texPanel: TDynRecord;
+ // "action" panel
+ actPanelIdx: Integer;
+ actPanel: TDynRecord;
end;
var
WAD: TWADFile;
//SetLength(TriggersTable, triggers.count);
g_Game_SetLoadingText(_lc[I_LOAD_TRIGGERS_TABLE], triggers.count-1, False);
+ SetLength(TriggersTable, triggers.count);
+ trignum := -1;
for rec in triggers do
begin
- SetLength(TriggersTable, Length(TriggersTable)+1);
- pttit := @TriggersTable[High(TriggersTable)];
+ Inc(trignum);
+ pttit := @TriggersTable[trignum];
pttit.trigrec := rec;
// Ñìåíà òåêñòóðû (âîçìîæíî, êíîïêè)
- pttit.texPan := mapReader.panel[rec.TexturePanel];
- pttit.liftPan := nil;
- pttit.doorPan := nil;
- pttit.shotPan := nil;
- pttit.mplatPan := nil;
- pttit.texPanIdx := -1;
- pttit.LiftPanelIdx := -1;
- pttit.DoorPanelIdx := -1;
- pttit.ShotPanelIdx := -1;
- pttit.MPlatPanelIdx := -1;
- // Ëèôòû
- if rec.TriggerType in [TRIGGER_LIFTUP, TRIGGER_LIFTDOWN, TRIGGER_LIFT] then
- begin
- pttit.liftPan := mapReader.panel[rec.trigRec.tgPanelID];
- end;
- // Äâåðè
- if rec.TriggerType in [TRIGGER_OPENDOOR, TRIGGER_CLOSEDOOR, TRIGGER_DOOR, TRIGGER_DOOR5, TRIGGER_CLOSETRAP, TRIGGER_TRAP] then
- begin
- pttit.doorPan := mapReader.panel[rec.trigRec.tgPanelID];
- end;
- // Òóðåëü
- if (rec.TriggerType = TRIGGER_SHOT) then
- begin
- pttit.shotPan := mapReader.panel[rec.trigRec.tgShotPanelID];
- end;
- //
- if rec.TriggerType in [TRIGGER_PRESS, TRIGGER_ON, TRIGGER_OFF, TRIGGER_ONOFF] then
- begin
- pttit.mplatPan := mapReader.panel[rec.trigRec.tgPanelID];
- end;
-
- if (pttit.texPan <> nil) then pttit.texPan.userPanelTrigRef := true;
- if (pttit.liftPan <> nil) then pttit.liftPan.userPanelTrigRef := true;
- if (pttit.doorPan <> nil) then pttit.doorPan.userPanelTrigRef := true;
- if (pttit.shotPan <> nil) then pttit.shotPan.userPanelTrigRef := true;
- if (pttit.mplatPan <> nil) then pttit.mplatPan.userPanelTrigRef := true;
-
+ pttit.texPanelIdx := -1; // will be fixed later
+ pttit.texPanel := rec.TexturePanelRec;
+ // action panel
+ pttit.actPanelIdx := -1;
+ if (rec.trigRec <> nil) then pttit.actPanel := rec.trigRec.tgPanelRec else pttit.actPanel := nil;
+ // set flag
+ if (pttit.texPanel <> nil) then pttit.texPanel.userPanelTrigRef := true;
+ if (pttit.actPanel <> nil) then pttit.actPanel.userPanelTrigRef := true;
+ // update progress
g_Game_StepLoading();
end;
end;
// ×èíèì ID'û ïàíåëåé, êîòîðûå èñïîëüçóþòñÿ â òðèããåðàõ
for b := 0 to High(TriggersTable) do
begin
- if (TriggersTable[b].texPan <> nil) then TriggersTable[b].texPanIdx := TriggersTable[b].texPan.userPanelId;
- if (TriggersTable[b].liftPan <> nil) then TriggersTable[b].LiftPanelIdx := TriggersTable[b].liftPan.userPanelId;
- if (TriggersTable[b].doorPan <> nil) then TriggersTable[b].DoorPanelIdx := TriggersTable[b].doorPan.userPanelId;
- if (TriggersTable[b].shotPan <> nil) then TriggersTable[b].ShotPanelIdx := TriggersTable[b].shotPan.userPanelId;
- if (TriggersTable[b].mplatPan <> nil) then TriggersTable[b].MPlatPanelIdx := TriggersTable[b].mplatPan.userPanelId;
+ if (TriggersTable[b].texPanel <> nil) then TriggersTable[b].texPanelIdx := TriggersTable[b].texPanel.userPanelId;
+ if (TriggersTable[b].actPanel <> nil) then TriggersTable[b].actPanelIdx := TriggersTable[b].actPanel.userPanelId;
end;
// create map grid, init other grids (for monsters, for example)
for rec in triggers do
begin
Inc(trignum);
- if (TriggersTable[trignum].texPan <> nil) then b := TriggersTable[trignum].texPan.PanelType else b := 0;
- if (TriggersTable[trignum].shotPan <> nil) then c := TriggersTable[trignum].shotPan.PanelType else c := 0;
+ if (TriggersTable[trignum].texPanel <> nil) then b := TriggersTable[trignum].texPanel.PanelType else b := 0;
+ if (TriggersTable[trignum].actPanel <> nil) then c := TriggersTable[trignum].actPanel.PanelType else c := 0;
// we can have only one of those
- if (TriggersTable[trignum].LiftPanelIdx <> -1) then tgpid := TriggersTable[trignum].LiftPanelIdx
- else if (TriggersTable[trignum].DoorPanelIdx <> -1) then tgpid := TriggersTable[trignum].DoorPanelIdx
- else if (TriggersTable[trignum].ShotPanelIdx <> -1) then tgpid := TriggersTable[trignum].ShotPanelIdx
- else if (TriggersTable[trignum].MPlatPanelIdx <> -1) then tgpid := TriggersTable[trignum].MPlatPanelIdx
- else tgpid := -1;
+ tgpid := TriggersTable[trignum].actPanelIdx;
//e_LogWritefln('creating trigger #%s; texpantype=%s; shotpantype=%s (%d,%d)', [trignum, b, c, TriggersTable[trignum].texPanIdx, TriggersTable[trignum].ShotPanelIdx]);
TriggersTable[trignum].tnum := trignum;
- TriggersTable[trignum].id := CreateTrigger(trignum, rec, TriggersTable[trignum].texPanIdx, tgpid, Word(b), Word(c));
+ TriggersTable[trignum].id := CreateTrigger(trignum, rec, TriggersTable[trignum].texPanelIdx, tgpid, Word(b), Word(c));
end;
end;
index 88e51347a9ef53678adcbdf23bd8e4f0c8b45f16..fab30ec3324c2627cc4140c93b72a5cabad3b180 100644 (file)
--- a/src/game/g_triggers.pas
+++ b/src/game/g_triggers.pas
mapIndex: Integer; // index in fields['trigger'], used in save/load
trigPanelGUID: Integer;
- //TrigData: TTriggerData;
- trigDataRec: TDynRecord; // triggerdata; owned by trigger
+ trigDataRec: TDynRecord; // triggerdata; owned by trigger (cloned)
{$INCLUDE ../shared/mapdef_tgc_def.inc}
public
function trigCenter (): TDFPoint; inline;
-
- public
- property trigShotPanelGUID: Integer read trigPanelGUID write trigPanelGUID;
end;
function g_Triggers_Create(Trigger: TTrigger; forceInternalIndex: Integer=-1): DWORD;
begin
if (tgcAmmo = 0) or ((tgcAmmo > 0) and (ShotAmmoCount > 0)) then
begin
- if (trigShotPanelGUID <> -1) and (ShotPanelTime = 0) then
+ if (trigPanelGUID <> -1) and (ShotPanelTime = 0) then
begin
- g_Map_SwitchTextureGUID(ShotPanelType, trigShotPanelGUID);
+ g_Map_SwitchTextureGUID(ShotPanelType, trigPanelGUID);
ShotPanelTime := 4; // òèêîâ íà âñïûøêó âûñòðåëà
end;
if ShotPanelTime > 0 then
begin
Dec(ShotPanelTime);
- if ShotPanelTime = 0 then g_Map_SwitchTextureGUID(ShotPanelType, trigShotPanelGUID);
+ if ShotPanelTime = 0 then g_Map_SwitchTextureGUID(ShotPanelType, trigPanelGUID);
end;
if ShotSightTime > 0 then
begin
diff --git a/src/shared/MAPDEF.pas b/src/shared/MAPDEF.pas
index 9875fa1fd26aa35501d8ee4609f9ddeec47113e2..53bedb79b1c329fa632fee6755cd1a82312133e6 100644 (file)
--- a/src/shared/MAPDEF.pas
+++ b/src/shared/MAPDEF.pas
function getPanelByIdx (idx: Integer): TDynRecord; inline;
- //function getPanelId (): Integer; inline;
- //procedure setPanelId (v: Integer); inline;
-
function getTexturePanel (): Integer; inline;
- //procedure setTexturePanel (v: Integer); inline;
+ function getTexturePanelRec (): TDynRecord; inline;
function getPanelIndex (pan: TDynRecord): Integer;
{$INCLUDE mapdef_help.inc}
function trigMonsterId (): Integer; inline;
function trigPanelId (): Integer; inline; // panel index in list
+ function trigPanelRec (): TDynRecord; inline;
private
// user fields
property panel[idx: Integer]: TDynRecord read getPanelByIdx;
property panelIndex[pan: TDynRecord]: Integer read getPanelIndex;
// triggers
- property tgPanelID: Integer read trigPanelId {write setPanelId};
- property tgShotPanelID: Integer read trigPanelId {write setPanelId};
- property TexturePanel: Integer read getTexturePanel {write setTexturePanel}; // texturepanel, int
+ property tgPanelId: Integer read trigPanelId;
+ property tgPanelRec: TDynRecord read trigPanelRec;
+ property TexturePanelId: Integer read getTexturePanel; // texturepanel, int
+ property TexturePanelRec: TDynRecord read getTexturePanelRec;
// user fields
property userPanelId: Integer read getUserPanelId write setUserPanelId;
property userPanelTrigRef: Boolean read getUserTrigRef write setUserTrigRef;
if (fld <> nil) then result := fld.recref else result := nil;
end;
-
function TDynRecordHelper.trigMonsterId (): Integer; inline;
var
fld: TDynField;
result := fld.recrefIndex;
end;
+function TDynRecordHelper.trigPanelRec (): TDynRecord; inline;
+var
+ fld: TDynField;
+begin
+ result := nil;
+ fld := field['panelid'];
+ if (fld = nil) then exit;
+ if (fld.baseType <> TDynField.TType.TInt) then exit;
+ result := fld.recref;
+ if (result <> nil) and (result.typeName <> 'panel') then result := nil;
+end;
// panel index in list
function TDynRecordHelper.trigPanelId (): Integer; inline;
if (fld = nil) then exit;
if (fld.baseType <> TDynField.TType.TInt) then exit;
if (fld.recref = nil) then exit;
+ if (fld.recref.typeName <> 'panel') then exit;
+ result := fld.recrefIndex;
+end;
+
+function TDynRecordHelper.getTexturePanelRec (): TDynRecord;
+var
+ fld: TDynField;
+begin
+ result := nil;
+ fld := field['texture_panel'];
+ if (fld = nil) then exit;
+ if (fld.baseType <> TDynField.TType.TInt) then exit;
+ result := fld.recref;
+ if (result <> nil) and (result.typeName <> 'panel') then result := nil;
+end;
+
+function TDynRecordHelper.getTexturePanel (): Integer;
+var
+ fld: TDynField;
+begin
+ result := -1;
+ fld := field['texture_panel'];
+ if (fld = nil) then exit;
+ if (fld.baseType <> TDynField.TType.TInt) then exit;
+ if (fld.recref = nil) then exit;
+ if (fld.recref.typeName <> 'panel') then exit;
result := fld.recrefIndex;
end;
@@ -382,9 +417,6 @@ function TDynRecordHelper.TriggerType (): Byte; inline; begin result := Byte(get
function TDynRecordHelper.ActivateType (): Byte; inline; begin result := Byte(getFieldWithType('activate_type', TDynField.TType.TUByte).ival); end;
function TDynRecordHelper.Keys (): Byte; inline; begin result := Byte(getFieldWithType('keys', TDynField.TType.TUByte).ival); end;
-//function TDynRecordHelper.getPanelId (): Integer; inline; begin result := getFieldWithType('panelid', TDynField.TType.TInt).recrefIndex; end;
-function TDynRecordHelper.getTexturePanel (): Integer; begin result := getFieldWithType('texture_panel', TDynField.TType.TInt).recrefIndex; end;
-
{$INCLUDE mapdef_impl.inc}