DEADSOFTWARE

graphics: lerp mplats
[d2df-sdl.git] / src / game / g_panel.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
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, version 3 of the License ONLY.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *)
15 {$INCLUDE ../shared/a_modes.inc}
16 {$M+}
17 unit g_panel;
19 interface
21 uses
22 SysUtils, Classes,
23 MAPDEF, g_textures, xdynrec;
25 type
26 TAddTextureArray = Array of
27 record
28 Texture: Cardinal;
29 Anim: Boolean;
30 end;
32 PPanel = ^TPanel;
33 TPanel = Class (TObject)
34 private
35 const
36 private
37 mGUID: Integer; // will be assigned in "g_map.pas"
38 FTextureWidth: Word;
39 FTextureHeight: Word;
40 FAlpha: Byte;
41 FBlending: Boolean;
42 FTextureIDs: Array of
43 record
44 case Anim: Boolean of
45 False: (Tex: Cardinal);
46 True: (AnTex: TAnimation);
47 end;
49 mMovingSpeed: TDFPoint;
50 mMovingStart: TDFPoint;
51 mMovingEnd: TDFPoint;
52 mMovingActive: Boolean;
53 mMoveOnce: Boolean;
55 mOldMovingActive: Boolean;
57 mSizeSpeed: TDFSize;
58 mSizeEnd: TDFSize;
60 mEndPosTrig: Integer;
61 mEndSizeTrig: Integer;
63 mNeedSend: Boolean; // for network
65 private
66 function getx1 (): Integer; inline;
67 function gety1 (): Integer; inline;
68 function getvisvalid (): Boolean; inline;
70 function getMovingSpeedX (): Integer; inline;
71 procedure setMovingSpeedX (v: Integer); inline;
72 function getMovingSpeedY (): Integer; inline;
73 procedure setMovingSpeedY (v: Integer); inline;
75 function getMovingStartX (): Integer; inline;
76 procedure setMovingStartX (v: Integer); inline;
77 function getMovingStartY (): Integer; inline;
78 procedure setMovingStartY (v: Integer); inline;
80 function getMovingEndX (): Integer; inline;
81 procedure setMovingEndX (v: Integer); inline;
82 function getMovingEndY (): Integer; inline;
83 procedure setMovingEndY (v: Integer); inline;
85 function getSizeSpeedX (): Integer; inline;
86 procedure setSizeSpeedX (v: Integer); inline;
87 function getSizeSpeedY (): Integer; inline;
88 procedure setSizeSpeedY (v: Integer); inline;
90 function getSizeEndX (): Integer; inline;
91 procedure setSizeEndX (v: Integer); inline;
92 function getSizeEndY (): Integer; inline;
93 procedure setSizeEndY (v: Integer); inline;
95 public
96 FCurTexture: Integer; // Íîìåð òåêóùåé òåêñòóðû
97 FCurFrame: Integer;
98 FCurFrameCount: Byte;
99 FX, FY: Integer;
100 FOldX, FOldY: Integer;
101 FWidth, FHeight: Word;
102 FOldW, FOldH: Word;
103 FPanelType: Word;
104 FEnabled: Boolean;
105 FDoor: Boolean;
106 FLiftType: Byte;
107 FLastAnimLoop: Byte;
108 // sorry, there fields are public to allow setting 'em in g_map; this should be fixed later
109 // for now, PLEASE, don't modify 'em, or all hell will break loose
110 arrIdx: Integer; // index in one of internal arrays; sorry
111 tag: Integer; // used in coldets and such; sorry; see g_map.GridTagXXX
112 proxyId: Integer; // proxy id in map grid (DO NOT USE!)
113 mapId: AnsiString; // taken directly from map file; dunno why it is here
114 hasTexTrigger: Boolean; // HACK: true when there's a trigger than can change my texture
116 constructor Create(PanelRec: TDynRecord;
117 AddTextures: TAddTextureArray;
118 CurTex: Integer;
119 var Textures: TLevelTextureArray; aguid: Integer);
120 destructor Destroy(); override;
122 procedure Draw (hasAmbient: Boolean; constref ambColor: TDFColor);
123 procedure DrawShadowVolume(lightX: Integer; lightY: Integer; radius: Integer);
124 procedure Update();
125 procedure SetFrame(Frame: Integer; Count: Byte);
126 procedure NextTexture(AnimLoop: Byte = 0);
127 procedure SetTexture(ID: Integer; AnimLoop: Byte = 0);
128 function GetTextureID(): Cardinal;
129 function GetTextureCount(): Integer;
130 function CanChangeTexture(): Boolean;
132 procedure SaveState (st: TStream);
133 procedure LoadState (st: TStream);
135 procedure positionChanged (); inline;
137 function getIsGBack (): Boolean; inline; // gRenderBackgrounds
138 function getIsGStep (): Boolean; inline; // gSteps
139 function getIsGWall (): Boolean; inline; // gWalls
140 function getIsGAcid1 (): Boolean; inline; // gAcid1
141 function getIsGAcid2 (): Boolean; inline; // gAcid2
142 function getIsGWater (): Boolean; inline; // gWater
143 function getIsGFore (): Boolean; inline; // gRenderForegrounds
144 function getIsGLift (): Boolean; inline; // gLifts
145 function getIsGBlockMon (): Boolean; inline; // gBlockMon
147 // get-and-clear
148 function gncNeedSend (): Boolean; inline;
149 procedure setDirty (); inline; // why `dirty`? 'cause i may introduce property `needSend` later
151 procedure lerp (t: Single; out tX, tY, tW, tH: Integer);
153 public
154 property visvalid: Boolean read getvisvalid; // panel is "visvalid" when it's width and height are positive
156 published
157 property guid: Integer read mGUID; // will be assigned in "g_map.pas"
158 property x0: Integer read FX;
159 property y0: Integer read FY;
160 property x1: Integer read getx1; // inclusive!
161 property y1: Integer read gety1; // inclusive!
162 property x: Integer read FX write FX;
163 property y: Integer read FY write FY;
164 property width: Word read FWidth write FWidth;
165 property height: Word read FHeight write FHeight;
166 property panelType: Word read FPanelType write FPanelType;
167 property enabled: Boolean read FEnabled write FEnabled;
168 property door: Boolean read FDoor write FDoor;
169 property liftType: Byte read FLiftType write FLiftType;
170 property lastAnimLoop: Byte read FLastAnimLoop write FLastAnimLoop;
172 property movingSpeedX: Integer read getMovingSpeedX write setMovingSpeedX;
173 property movingSpeedY: Integer read getMovingSpeedY write setMovingSpeedY;
174 property movingStartX: Integer read getMovingStartX write setMovingStartX;
175 property movingStartY: Integer read getMovingStartY write setMovingStartY;
176 property movingEndX: Integer read getMovingEndX write setMovingEndX;
177 property movingEndY: Integer read getMovingEndY write setMovingEndY;
178 property movingActive: Boolean read mMovingActive write mMovingActive;
179 property moveOnce: Boolean read mMoveOnce write mMoveOnce;
181 property sizeSpeedX: Integer read getSizeSpeedX write setSizeSpeedX;
182 property sizeSpeedY: Integer read getSizeSpeedY write setSizeSpeedY;
183 property sizeEndX: Integer read getSizeEndX write setSizeEndX;
184 property sizeEndY: Integer read getSizeEndY write setSizeEndY;
186 property isGBack: Boolean read getIsGBack;
187 property isGStep: Boolean read getIsGStep;
188 property isGWall: Boolean read getIsGWall;
189 property isGAcid1: Boolean read getIsGAcid1;
190 property isGAcid2: Boolean read getIsGAcid2;
191 property isGWater: Boolean read getIsGWater;
192 property isGFore: Boolean read getIsGFore;
193 property isGLift: Boolean read getIsGLift;
194 property isGBlockMon: Boolean read getIsGBlockMon;
196 public
197 property movingSpeed: TDFPoint read mMovingSpeed write mMovingSpeed;
198 property movingStart: TDFPoint read mMovingStart write mMovingStart;
199 property movingEnd: TDFPoint read mMovingEnd write mMovingEnd;
201 property sizeSpeed: TDFSize read mSizeSpeed write mSizeSpeed;
202 property sizeEnd: TDFSize read mSizeEnd write mSizeEnd;
204 property endPosTrigId: Integer read mEndPosTrig write mEndPosTrig;
205 property endSizeTrigId: Integer read mEndSizeTrig write mEndSizeTrig;
206 end;
208 TPanelArray = Array of TPanel;
210 const
211 LIFTTYPE_UP = 0;
212 LIFTTYPE_DOWN = 1;
213 LIFTTYPE_LEFT = 2;
214 LIFTTYPE_RIGHT = 3;
216 var
217 g_dbgpan_mplat_active: Boolean = {$IF DEFINED(D2F_DEBUG)}true{$ELSE}true{$ENDIF};
218 g_dbgpan_mplat_step: Boolean = false; // one step, and stop
221 implementation
223 uses
224 {$INCLUDE ../nogl/noGLuses.inc}
225 e_texture, g_basic, g_map, g_game, g_gfx, e_graphics, g_weapons, g_triggers,
226 g_console, g_language, g_monsters, g_player, g_grid, e_log, geom, utils, xstreams;
228 const
229 PANEL_SIGNATURE = $4C4E4150; // 'PANL'
231 { T P a n e l : }
233 constructor TPanel.Create(PanelRec: TDynRecord;
234 AddTextures: TAddTextureArray;
235 CurTex: Integer;
236 var Textures: TLevelTextureArray; aguid: Integer);
237 var
238 i: Integer;
239 tnum: Integer;
240 begin
241 X := PanelRec.X;
242 Y := PanelRec.Y;
243 FOldX := X;
244 FOldY := Y;
245 Width := PanelRec.Width;
246 Height := PanelRec.Height;
247 FOldW := Width;
248 FOldH := Height;
249 FAlpha := 0;
250 FBlending := False;
251 FCurFrame := 0;
252 FCurFrameCount := 0;
253 LastAnimLoop := 0;
255 mapId := PanelRec.id;
256 mGUID := aguid;
258 mMovingSpeed := PanelRec.moveSpeed;
259 mMovingStart := PanelRec.moveStart;
260 mMovingEnd := PanelRec.moveEnd;
261 mMovingActive := PanelRec['move_active'].value;
262 mOldMovingActive := mMovingActive;
263 mMoveOnce := PanelRec.moveOnce;
265 mSizeSpeed := PanelRec.sizeSpeed;
266 mSizeEnd := PanelRec.sizeEnd;
268 mEndPosTrig := PanelRec.endPosTrig;
269 mEndSizeTrig := PanelRec.endSizeTrig;
271 mNeedSend := false;
273 // Òèï ïàíåëè:
274 PanelType := PanelRec.PanelType;
275 Enabled := True;
276 Door := False;
277 LiftType := LIFTTYPE_UP;
278 hasTexTrigger := False;
280 case PanelType of
281 PANEL_OPENDOOR: begin Enabled := False; Door := True; end;
282 PANEL_CLOSEDOOR: Door := True;
283 PANEL_LIFTUP: LiftType := LIFTTYPE_UP; //???
284 PANEL_LIFTDOWN: LiftType := LIFTTYPE_DOWN;
285 PANEL_LIFTLEFT: LiftType := LIFTTYPE_LEFT;
286 PANEL_LIFTRIGHT: LiftType := LIFTTYPE_RIGHT;
287 end;
289 // Íåâèäèìàÿ:
290 if ByteBool(PanelRec.Flags and PANEL_FLAG_HIDE) then
291 begin
292 SetLength(FTextureIDs, 0);
293 FCurTexture := -1;
294 Exit;
295 end;
296 // Ïàíåëè, íå èñïîëüçóþùèå òåêñòóðû:
297 if ByteBool(PanelType and
298 (PANEL_LIFTUP or
299 PANEL_LIFTDOWN or
300 PANEL_LIFTLEFT or
301 PANEL_LIFTRIGHT or
302 PANEL_BLOCKMON)) then
303 begin
304 SetLength(FTextureIDs, 0);
305 FCurTexture := -1;
306 Exit;
307 end;
309 // Åñëè ýòî æèäêîñòü áåç òåêñòóðû - ñïåöòåêñòóðó:
310 if WordBool(PanelType and (PANEL_WATER or PANEL_ACID1 or PANEL_ACID2)) and
311 (not ByteBool(PanelRec.Flags and PANEL_FLAG_WATERTEXTURES)) then
312 begin
313 SetLength(FTextureIDs, 1);
314 FTextureIDs[0].Anim := False;
316 case PanelRec.PanelType of
317 PANEL_WATER:
318 FTextureIDs[0].Tex := LongWord(TEXTURE_SPECIAL_WATER);
319 PANEL_ACID1:
320 FTextureIDs[0].Tex := LongWord(TEXTURE_SPECIAL_ACID1);
321 PANEL_ACID2:
322 FTextureIDs[0].Tex := LongWord(TEXTURE_SPECIAL_ACID2);
323 end;
325 FCurTexture := 0;
326 Exit;
327 end;
329 SetLength(FTextureIDs, Length(AddTextures));
331 if CurTex < 0 then
332 FCurTexture := -1
333 else
334 if CurTex >= Length(FTextureIDs) then
335 FCurTexture := Length(FTextureIDs) - 1
336 else
337 FCurTexture := CurTex;
339 for i := 0 to Length(FTextureIDs)-1 do
340 begin
341 FTextureIDs[i].Anim := AddTextures[i].Anim;
342 if FTextureIDs[i].Anim then
343 begin // Àíèìèðîâàííàÿ òåêñòóðà
344 FTextureIDs[i].AnTex :=
345 TAnimation.Create(Textures[AddTextures[i].Texture].FramesID,
346 True, Textures[AddTextures[i].Texture].Speed);
347 FTextureIDs[i].AnTex.Blending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING);
348 FTextureIDs[i].AnTex.Alpha := PanelRec.Alpha;
349 end
350 else
351 begin // Îáû÷íàÿ òåêñòóðà
352 FTextureIDs[i].Tex := Textures[AddTextures[i].Texture].TextureID;
353 end;
354 end;
356 // Òåêñòóð íåñêîëüêî - íóæíî ñîõðàíÿòü òåêóùóþ:
357 //if Length(FTextureIDs) > 1 then SaveIt := True;
359 if (PanelRec.TextureRec = nil) then tnum := -1 else tnum := PanelRec.tagInt;
360 if (tnum < 0) then tnum := Length(Textures);
362 // Åñëè íå ñïåöòåêñòóðà, òî çàäàåì ðàçìåðû:
363 if ({PanelRec.TextureNum}tnum > High(Textures)) then
364 begin
365 e_WriteLog(Format('WTF?! tnum is out of limits! (%d : %d)', [tnum, High(Textures)]), TMsgType.Warning);
366 FTextureWidth := 2;
367 FTextureHeight := 2;
368 FAlpha := 0;
369 FBlending := ByteBool(0);
370 end
371 else if not g_Map_IsSpecialTexture(Textures[{PanelRec.TextureNum}tnum].TextureName) then
372 begin
373 FTextureWidth := Textures[{PanelRec.TextureNum}tnum].Width;
374 FTextureHeight := Textures[{PanelRec.TextureNum}tnum].Height;
375 FAlpha := PanelRec.Alpha;
376 FBlending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING);
377 end;
378 end;
380 destructor TPanel.Destroy();
381 var
382 i: Integer;
383 begin
384 for i := 0 to High(FTextureIDs) do
385 if FTextureIDs[i].Anim then
386 FTextureIDs[i].AnTex.Free();
387 SetLength(FTextureIDs, 0);
389 Inherited;
390 end;
392 procedure TPanel.lerp (t: Single; out tX, tY, tW, tH: Integer);
393 begin
394 if mMovingActive then
395 begin
396 tX := nlerp(FOldX, FX, t);
397 tY := nlerp(FOldY, FY, t);
398 tW := nlerp(FOldW, FWidth, t);
399 tH := nlerp(FOldH, FHeight, t);
400 end
401 else
402 begin
403 tX := FX;
404 tY := FY;
405 tW := FWidth;
406 tH := FHeight;
407 end;
408 end;
410 function TPanel.getx1 (): Integer; inline; begin result := X+Width-1; end;
411 function TPanel.gety1 (): Integer; inline; begin result := Y+Height-1; end;
412 function TPanel.getvisvalid (): Boolean; inline; begin result := (Width > 0) and (Height > 0); end;
414 function TPanel.getMovingSpeedX (): Integer; inline; begin result := mMovingSpeed.X; end;
415 procedure TPanel.setMovingSpeedX (v: Integer); inline; begin mMovingSpeed.X := v; end;
416 function TPanel.getMovingSpeedY (): Integer; inline; begin result := mMovingSpeed.Y; end;
417 procedure TPanel.setMovingSpeedY (v: Integer); inline; begin mMovingSpeed.Y := v; end;
419 function TPanel.getMovingStartX (): Integer; inline; begin result := mMovingStart.X; end;
420 procedure TPanel.setMovingStartX (v: Integer); inline; begin mMovingStart.X := v; end;
421 function TPanel.getMovingStartY (): Integer; inline; begin result := mMovingStart.Y; end;
422 procedure TPanel.setMovingStartY (v: Integer); inline; begin mMovingStart.Y := v; end;
424 function TPanel.getMovingEndX (): Integer; inline; begin result := mMovingEnd.X; end;
425 procedure TPanel.setMovingEndX (v: Integer); inline; begin mMovingEnd.X := v; end;
426 function TPanel.getMovingEndY (): Integer; inline; begin result := mMovingEnd.Y; end;
427 procedure TPanel.setMovingEndY (v: Integer); inline; begin mMovingEnd.Y := v; end;
429 function TPanel.getSizeSpeedX (): Integer; inline; begin result := mSizeSpeed.w; end;
430 procedure TPanel.setSizeSpeedX (v: Integer); inline; begin mSizeSpeed.w := v; end;
431 function TPanel.getSizeSpeedY (): Integer; inline; begin result := mSizeSpeed.h; end;
432 procedure TPanel.setSizeSpeedY (v: Integer); inline; begin mSizeSpeed.h := v; end;
434 function TPanel.getSizeEndX (): Integer; inline; begin result := mSizeEnd.w; end;
435 procedure TPanel.setSizeEndX (v: Integer); inline; begin mSizeEnd.w := v; end;
436 function TPanel.getSizeEndY (): Integer; inline; begin result := mSizeEnd.h; end;
437 procedure TPanel.setSizeEndY (v: Integer); inline; begin mSizeEnd.h := v; end;
439 function TPanel.getIsGBack (): Boolean; inline; begin result := ((tag and GridTagBack) <> 0); end;
440 function TPanel.getIsGStep (): Boolean; inline; begin result := ((tag and GridTagStep) <> 0); end;
441 function TPanel.getIsGWall (): Boolean; inline; begin result := ((tag and (GridTagWall or GridTagDoor)) <> 0); end;
442 function TPanel.getIsGAcid1 (): Boolean; inline; begin result := ((tag and GridTagAcid1) <> 0); end;
443 function TPanel.getIsGAcid2 (): Boolean; inline; begin result := ((tag and GridTagAcid2) <> 0); end;
444 function TPanel.getIsGWater (): Boolean; inline; begin result := ((tag and GridTagWater) <> 0); end;
445 function TPanel.getIsGFore (): Boolean; inline; begin result := ((tag and GridTagFore) <> 0); end;
446 function TPanel.getIsGLift (): Boolean; inline; begin result := ((tag and GridTagLift) <> 0); end;
447 function TPanel.getIsGBlockMon (): Boolean; inline; begin result := ((tag and GridTagBlockMon) <> 0); end;
449 function TPanel.gncNeedSend (): Boolean; inline; begin result := mNeedSend; mNeedSend := false; end;
450 procedure TPanel.setDirty (); inline; begin mNeedSend := true; end;
453 procedure TPanel.Draw (hasAmbient: Boolean; constref ambColor: TDFColor);
454 var
455 tx, ty, tw, th: Integer;
456 xx, yy: Integer;
457 NoTextureID: DWORD;
458 NW, NH: Word;
459 begin
460 if {Enabled and} (FCurTexture >= 0) and
461 (Width > 0) and (Height > 0) and (FAlpha < 255) {and
462 g_Collide(X, Y, Width, Height, sX, sY, sWidth, sHeight)} then
463 begin
464 lerp(gLerpFactor, tx, ty, tw, th);
465 if FTextureIDs[FCurTexture].Anim then
466 begin // Àíèìèðîâàííàÿ òåêñòóðà
467 if FTextureIDs[FCurTexture].AnTex = nil then
468 Exit;
470 for xx := 0 to (tw div FTextureWidth)-1 do
471 for yy := 0 to (th div FTextureHeight)-1 do
472 FTextureIDs[FCurTexture].AnTex.Draw(
473 tx + xx*FTextureWidth,
474 ty + yy*FTextureHeight, TMirrorType.None);
475 end
476 else
477 begin // Îáû÷íàÿ òåêñòóðà
478 case FTextureIDs[FCurTexture].Tex of
479 LongWord(TEXTURE_SPECIAL_WATER): e_DrawFillQuad(tx, ty, tx+tw-1, ty+th-1, 0, 0, 255, 0, TBlending.Filter);
480 LongWord(TEXTURE_SPECIAL_ACID1): e_DrawFillQuad(tx, ty, tx+tw-1, ty+th-1, 0, 230, 0, 0, TBlending.Filter);
481 LongWord(TEXTURE_SPECIAL_ACID2): e_DrawFillQuad(tx, ty, tx+tw-1, ty+th-1, 230, 0, 0, 0, TBlending.Filter);
482 LongWord(TEXTURE_NONE):
483 if g_Texture_Get('NOTEXTURE', NoTextureID) then
484 begin
485 e_GetTextureSize(NoTextureID, @NW, @NH);
486 e_DrawFill(NoTextureID, tx, ty, tw div NW, th div NH, 0, False, False);
487 end
488 else
489 begin
490 xx := tx + (tw div 2);
491 yy := ty + (th div 2);
492 e_DrawFillQuad(tx, ty, xx, yy, 255, 0, 255, 0);
493 e_DrawFillQuad(xx, ty, tx+tw-1, yy, 255, 255, 0, 0);
494 e_DrawFillQuad(tx, yy, xx, ty+th-1, 255, 255, 0, 0);
495 e_DrawFillQuad(xx, yy, tx+tw-1, ty+th-1, 255, 0, 255, 0);
496 end;
497 else
498 begin
499 if not mMovingActive then
500 e_DrawFill(FTextureIDs[FCurTexture].Tex, tx, ty, tw div FTextureWidth, th div FTextureHeight, FAlpha, True, FBlending, hasAmbient)
501 else
502 e_DrawFillX(FTextureIDs[FCurTexture].Tex, tx, ty, tw, th, FAlpha, True, FBlending, g_dbg_scale, hasAmbient);
503 if hasAmbient then e_AmbientQuad(tx, ty, tw, th, ambColor.r, ambColor.g, ambColor.b, ambColor.a);
504 end;
505 end;
506 end;
507 end;
508 end;
510 procedure TPanel.DrawShadowVolume(lightX: Integer; lightY: Integer; radius: Integer);
511 var
512 tx, ty, tw, th: Integer;
514 procedure extrude (x: Integer; y: Integer);
515 begin
516 glVertex2i(x+(x-lightX)*500, y+(y-lightY)*500);
517 //e_WriteLog(Format(' : (%d,%d)', [x+(x-lightX)*300, y+(y-lightY)*300]), MSG_WARNING);
518 end;
520 procedure drawLine (x0: Integer; y0: Integer; x1: Integer; y1: Integer);
521 begin
522 // does this side facing the light?
523 if ((x1-x0)*(lightY-y0)-(lightX-x0)*(y1-y0) >= 0) then exit;
524 //e_WriteLog(Format('lightpan: (%d,%d)-(%d,%d)', [x0, y0, x1, y1]), MSG_WARNING);
525 // this edge is facing the light, extrude and draw it
526 glVertex2i(x0, y0);
527 glVertex2i(x1, y1);
528 extrude(x1, y1);
529 extrude(x0, y0);
530 end;
532 begin
533 if radius < 4 then exit;
534 if Enabled and (FCurTexture >= 0) and (Width > 0) and (Height > 0) and (FAlpha < 255) {and
535 g_Collide(X, Y, tw, th, sX, sY, sWidth, sHeight)} then
536 begin
537 lerp(gLerpFactor, tx, ty, tw, th);
538 if not FTextureIDs[FCurTexture].Anim then
539 begin
540 case FTextureIDs[FCurTexture].Tex of
541 LongWord(TEXTURE_SPECIAL_WATER): exit;
542 LongWord(TEXTURE_SPECIAL_ACID1): exit;
543 LongWord(TEXTURE_SPECIAL_ACID2): exit;
544 LongWord(TEXTURE_NONE): exit;
545 end;
546 end;
547 if (tx+tw < lightX-radius) then exit;
548 if (ty+th < lightY-radius) then exit;
549 if (tx > lightX+radius) then exit;
550 if (ty > lightY+radius) then exit;
551 //e_DrawFill(FTextureIDs[FCurTexture].Tex, X, Y, tw div FTextureWidth, th div FTextureHeight, FAlpha, True, FBlending);
553 glBegin(GL_QUADS);
554 drawLine(tx, ty, tx+tw, ty); // top
555 drawLine(tx+tw, ty, tx+tw, ty+th); // right
556 drawLine(tx+tw, ty+th, tx, ty+th); // bottom
557 drawLine(tx, ty+th, tx, ty); // left
558 glEnd();
559 end;
560 end;
563 procedure TPanel.positionChanged (); inline;
564 var
565 px, py, pw, ph: Integer;
566 begin
567 if (proxyId >= 0) then
568 begin
569 mapGrid.getBodyDims(proxyId, px, py, pw, ph);
570 if (px <> x) or (py <> y) or (pw <> Width) or (ph <> Height) then
571 begin
573 e_LogWritefln('panel moved: arridx=%s; guid=%s; proxyid=%s; old:(%s,%s)-(%sx%s); new:(%s,%s)-(%sx%s)',
574 [arrIdx, mGUID, proxyId, px, py, pw, ph, x, y, width, height]);
576 g_Mark(px, py, pw, ph, MARK_WALL, false);
577 if (Width < 1) or (Height < 1) then
578 begin
579 mapGrid.proxyEnabled[proxyId] := false;
580 end
581 else
582 begin
583 mapGrid.proxyEnabled[proxyId] := Enabled;
584 if (pw <> Width) or (ph <> Height) then
585 begin
586 //writeln('panel resize!');
587 mapGrid.moveResizeBody(proxyId, X, Y, Width, Height)
588 end
589 else
590 begin
591 mapGrid.moveBody(proxyId, X, Y);
592 end;
593 g_Mark(X, Y, Width, Height, MARK_WALL);
594 end;
595 end;
596 end;
597 end;
600 var
601 monCheckList: array of TMonster = nil;
602 monCheckListUsed: Integer = 0;
604 procedure TPanel.Update();
605 var
606 ox, oy: Integer;
607 nx, ny, nw, nh: Integer;
608 ex, ey, nex, ney: Integer;
609 mpw, mph: Integer;
611 // return `true` if we should move by dx,dy
612 function tryMPlatMove (px, py, pw, ph: Integer; out dx, dy: Integer; out squash: Boolean; ontop: PBoolean=nil): Boolean;
613 var
614 u0: Single;
615 tex, tey: Integer;
616 pdx, pdy: Integer;
617 trtag: Integer;
618 szdx, szdy: Integer;
619 begin
620 squash := false;
621 tex := px;
622 tey := py;
623 pdx := mMovingSpeed.X;
624 pdy := mMovingSpeed.Y;
625 // standing on the platform?
626 if (py+ph = oy) then
627 begin
628 if (ontop <> nil) then ontop^ := true;
629 // yes, move with it; but skip steps (no need to process size change here, 'cause platform top cannot be changed with it)
630 mapGrid.traceBox(tex, tey, px, py, pw, ph, pdx, pdy, (GridTagWall or GridTagDoor));
631 end
632 else
633 begin
634 if (ontop <> nil) then ontop^ := false;
635 // not standing on the platform: trace platform to see if it hits the entity
636 // first, process size change (as we cannot sweeptest both move and size change)
637 // but we don't have to check for pushing if the panel is shrinking
638 szdx := nw-mpw;
639 szdy := nh-mph;
640 if (szdx > 0) or (szdy > 0) then
641 begin
642 // ignore shrinking dimension
643 if (szdx < 0) then szdx := 0;
644 if (szdy < 0) then szdy := 0;
645 // move platform by szd* back, and check for szd* movement
646 if sweepAABB(ox-szdx, oy-szdy, nw, nh, szdx, szdy, px, py, pw, ph, @u0) then
647 begin
648 // yes, platform hits the entity, push the entity in the resizing direction
649 u0 := 1.0-u0; // how much path left?
650 szdx := trunc(szdx*u0);
651 szdy := trunc(szdy*u0);
652 if (szdx <> 0) or (szdy <> 0) then
653 begin
654 // has some path to go, trace the entity
655 trtag := (GridTagWall or GridTagDoor);
656 // if we're moving down, consider steps too
657 if (szdy > 0) then trtag := trtag or GridTagStep;
658 mapGrid.traceBox(tex, tey, px, py, pw, ph, szdx, szdy, trtag);
659 end;
660 end;
661 end;
662 // second, process platform movement, using te* as entity starting point
663 if sweepAABB(ox, oy, nw, nh, pdx, pdy, tex, tey, pw, ph, @u0) then
664 begin
665 //e_LogWritefln('T: platsweep; u0=%s; u1=%s; hedge=%s; sweepAABB(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)', [u0, u1, hedge, ox, oy, mpw, mph, pdx, pdy, px-1, py-1, pw+2, ph+2]);
666 // yes, platform hits the entity, push the entity in the direction of the platform
667 u0 := 1.0-u0; // how much path left?
668 pdx := trunc(pdx*u0);
669 pdy := trunc(pdy*u0);
670 //e_LogWritefln(' platsweep; uleft=%s; pd=(%s,%s)', [u0, pdx, pdy]);
671 if (pdx <> 0) or (pdy <> 0) then
672 begin
673 // has some path to go, trace the entity
674 trtag := (GridTagWall or GridTagDoor);
675 // if we're moving down, consider steps too
676 if (pdy > 0) then trtag := trtag or GridTagStep;
677 mapGrid.traceBox(tex, tey, px, py, pw, ph, pdx, pdy, trtag);
678 end;
679 end;
680 end;
681 // done with entity movement, new coords are in te*
682 dx := tex-px;
683 dy := tey-py;
684 result := (dx <> 0) or (dy <> 0);
685 if ((tag and (GridTagWall or GridTagDoor)) <> 0) then
686 begin
687 // check for squashing; as entity cannot be pushed into a wall, check only collision with the platform itself
688 squash := g_Collide(tex, tey, pw, ph, nx, ny, nw, nh); // squash, if still in platform
689 end;
690 end;
692 function monCollect (mon: TMonster): Boolean;
693 begin
694 result := false; // don't stop
695 if (monCheckListUsed >= Length(monCheckList)) then SetLength(monCheckList, monCheckListUsed+128);
696 monCheckList[monCheckListUsed] := mon;
697 Inc(monCheckListUsed);
698 end;
700 var
701 cx0, cy0, cx1, cy1, cw, ch: Integer;
702 f: Integer;
703 px, py, pw, ph, pdx, pdy: Integer;
704 squash: Boolean;
705 plr: TPlayer;
706 gib: PGib;
707 cor: TCorpse;
708 mon: TMonster;
709 mpfrid: LongWord;
710 ontop: Boolean;
711 actMoveTrig: Boolean;
712 actSizeTrig: Boolean;
713 begin
714 if (not Enabled) or (Width < 1) or (Height < 1) then exit;
716 if (FCurTexture >= 0) and
717 (FTextureIDs[FCurTexture].Anim) and
718 (FTextureIDs[FCurTexture].AnTex <> nil) and
719 (FAlpha < 255) then
720 begin
721 FTextureIDs[FCurTexture].AnTex.Update();
722 FCurFrame := FTextureIDs[FCurTexture].AnTex.CurrentFrame;
723 FCurFrameCount := FTextureIDs[FCurTexture].AnTex.CurrentCounter;
724 end;
726 if not g_dbgpan_mplat_active then exit;
728 if (mOldMovingActive <> mMovingActive) then mNeedSend := true;
729 mOldMovingActive := mMovingActive;
731 if not mMovingActive then exit;
732 if mMovingSpeed.isZero and mSizeSpeed.isZero then exit;
734 //TODO: write wall size change processing
736 // moving platform?
737 begin
738 (*
739 * collect all monsters and players (aka entities) along the possible platform path
740 * if entity is standing on a platform:
741 * try to move it along the platform path, checking wall collisions
742 * if entity is NOT standing on a platform, but hit with sweeped platform aabb:
743 * try to push entity
744 * if we can't push entity all the way, squash it
745 *)
746 ox := X;
747 oy := Y;
748 mpw := Width;
749 mph := Height;
751 nw := mpw+mSizeSpeed.w;
752 nh := mph+mSizeSpeed.h;
753 nx := ox+mMovingSpeed.X;
754 ny := oy+mMovingSpeed.Y;
756 // force network updates only if some sudden change happened
757 // set the flag here, so we can sync affected monsters
758 if not mSizeSpeed.isZero and (nw = mSizeEnd.w) and (nh = mSizeEnd.h) then
759 begin
760 mNeedSend := true;
761 end
762 else if ((mMovingSpeed.X < 0) and (nx <= mMovingStart.X)) or ((mMovingSpeed.X > 0) and (nx >= mMovingEnd.X)) then
763 begin
764 mNeedSend := true;
765 end
766 else if ((mMovingSpeed.Y < 0) and (ny <= mMovingStart.Y)) or ((mMovingSpeed.Y > 0) and (ny >= mMovingEnd.Y)) then
767 begin
768 mNeedSend := true;
769 end;
771 // if pannel disappeared, we don't have to do anything
772 if (nw > 0) and (nh > 0) then
773 begin
774 // old rect
775 ex := ox+mpw-1;
776 ey := ox+mph-1;
777 // new rect
778 nex := nx+nw-1;
779 ney := ny+nh-1;
780 // full rect
781 cx0 := nmin(ox, nx);
782 cy0 := nmin(oy, ny);
783 cx1 := nmax(ex, nex);
784 cy1 := nmax(ey, ney);
785 // extrude
786 cx0 -= 1;
787 cy0 -= 1;
788 cx1 += 1;
789 cy1 += 1;
790 cw := cx1-cx0+1;
791 ch := cy1-cy0+1;
793 // process "obstacle" panels
794 if ((tag and GridTagObstacle) <> 0) then
795 begin
796 // temporarily turn off this panel, so it won't interfere with collision checks
797 mapGrid.proxyEnabled[proxyId] := false;
799 // process players
800 for f := 0 to High(gPlayers) do
801 begin
802 plr := gPlayers[f];
803 if (plr = nil) or (not plr.alive) then continue;
804 plr.getMapBox(px, py, pw, ph);
805 if not g_Collide(px, py, pw, ph, cx0, cy0, cw, ch) then continue;
806 if tryMPlatMove(px, py, pw, ph, pdx, pdy, squash) then
807 begin
808 // set new position
809 plr.moveBy(pdx, pdy); // this will call `positionChanged()` for us
810 end;
811 // squash player, if necessary
812 if not g_Game_IsClient and squash then plr.Damage(15000, 0, 0, 0, HIT_TRAP);
813 end;
815 // process gibs
816 for f := 0 to High(gGibs) do
817 begin
818 gib := @gGibs[f];
819 if not gib.alive then continue;
820 gib.getMapBox(px, py, pw, ph);
821 if not g_Collide(px, py, pw, ph, cx0, cy0, cw, ch) then continue;
822 if tryMPlatMove(px, py, pw, ph, pdx, pdy, squash, @ontop) then
823 begin
824 // set new position
825 gib.moveBy(pdx, pdy); // this will call `positionChanged()` for us
826 end;
827 end;
829 // move and push corpses
830 for f := 0 to High(gCorpses) do
831 begin
832 cor := gCorpses[f];
833 if (cor = nil) then continue;
834 cor.getMapBox(px, py, pw, ph);
835 if not g_Collide(px, py, pw, ph, cx0, cy0, cw, ch) then continue;
836 if tryMPlatMove(px, py, pw, ph, pdx, pdy, squash, @ontop) then
837 begin
838 // set new position
839 cor.moveBy(pdx, pdy); // this will call `positionChanged()` for us
840 end;
841 end;
843 // collect monsters
844 monCheckListUsed := 0;
845 g_Mons_ForEachAt(cx0, cy0, cw, ch, monCollect);
847 // process collected monsters
848 if (monCheckListUsed > 0) then
849 begin
850 mpfrid := g_Mons_getNewMPlatFrameId();
851 for f := 0 to monCheckListUsed do
852 begin
853 mon := monCheckList[f];
854 if (mon = nil) or (not mon.alive) or (mon.mplatCheckFrameId = mpfrid) then continue;
855 mon.mplatCheckFrameId := mpfrid;
856 mon.getMapBox(px, py, pw, ph);
857 //if not g_Collide(px, py, pw, ph, cx0, cy0, cw, ch) then continue;
858 if tryMPlatMove(px, py, pw, ph, pdx, pdy, squash) then
859 begin
860 // set new position
861 mon.moveBy(pdx, pdy); // this will call `positionChanged()` for us
862 //???FIXME: do we really need to send monsters over the net?
863 // i don't think so, as dead reckoning should take care of 'em
864 // ok, send new monster position only if platform is going to change it's direction
865 if mNeedSend then mon.setDirty();
866 end;
867 // squash monster, if necessary
868 if not g_Game_IsClient and squash then mon.Damage(15000, 0, 0, 0, HIT_TRAP);
869 end;
870 end;
872 // restore panel state
873 mapGrid.proxyEnabled[proxyId] := true;
874 end;
875 end;
877 // move panel
878 FOldX := X;
879 FOldY := Y;
880 X := nx;
881 Y := ny;
882 FOldW := FWidth;
883 FOldH := FHeight;
884 FWidth := nw;
885 FHeight := nh;
886 positionChanged();
888 actMoveTrig := false;
889 actSizeTrig := false;
891 // `mNeedSend` was set above
893 // check "size stop"
894 if not mSizeSpeed.isZero and (nw = mSizeEnd.w) and (nh = mSizeEnd.h) then
895 begin
896 mSizeSpeed.w := 0;
897 mSizeSpeed.h := 0;
898 actSizeTrig := true;
899 if (nw < 1) or (nh < 1) then mMovingActive := false; //HACK!
900 end;
902 // reverse moving direction, if necessary
903 if ((mMovingSpeed.X < 0) and (nx <= mMovingStart.X)) or ((mMovingSpeed.X > 0) and (nx >= mMovingEnd.X)) then
904 begin
905 if mMoveOnce then mMovingActive := false else mMovingSpeed.X := -mMovingSpeed.X;
906 actMoveTrig := true;
907 end;
909 if ((mMovingSpeed.Y < 0) and (ny <= mMovingStart.Y)) or ((mMovingSpeed.Y > 0) and (ny >= mMovingEnd.Y)) then
910 begin
911 if mMoveOnce then mMovingActive := false else mMovingSpeed.Y := -mMovingSpeed.Y;
912 actMoveTrig := true;
913 end;
915 if (mOldMovingActive <> mMovingActive) then mNeedSend := true;
916 mOldMovingActive := mMovingActive;
918 if not g_Game_IsClient then
919 begin
920 if actMoveTrig then g_Triggers_Press(mEndPosTrig, ACTIVATE_CUSTOM);
921 if actSizeTrig then g_Triggers_Press(mEndSizeTrig, ACTIVATE_CUSTOM);
922 end;
924 // some triggers may activate this, don't delay sending
925 //TODO: when triggers will be able to control speed and size, check that here too
926 if (mOldMovingActive <> mMovingActive) then mNeedSend := true;
927 mOldMovingActive := mMovingActive;
928 end;
929 end;
932 procedure TPanel.SetFrame(Frame: Integer; Count: Byte);
934 function ClampInt(X, A, B: Integer): Integer;
935 begin
936 Result := X;
937 if X < A then Result := A else if X > B then Result := B;
938 end;
940 begin
941 if Enabled and (FCurTexture >= 0) and
942 (FTextureIDs[FCurTexture].Anim) and
943 (FTextureIDs[FCurTexture].AnTex <> nil) and
944 (Width > 0) and (Height > 0) and (FAlpha < 255) then
945 begin
946 FCurFrame := ClampInt(Frame, 0, FTextureIDs[FCurTexture].AnTex.TotalFrames - 1);
947 FCurFrameCount := Count;
948 FTextureIDs[FCurTexture].AnTex.CurrentFrame := FCurFrame;
949 FTextureIDs[FCurTexture].AnTex.CurrentCounter := FCurFrameCount;
950 end;
951 end;
953 procedure TPanel.NextTexture(AnimLoop: Byte = 0);
954 begin
955 Assert(FCurTexture >= -1, 'FCurTexture < -1');
957 // Íåò òåêñòóð:
958 if Length(FTextureIDs) = 0 then
959 FCurTexture := -1
960 else
961 // Òîëüêî îäíà òåêñòóðà:
962 if Length(FTextureIDs) = 1 then
963 begin
964 if FCurTexture = 0 then
965 FCurTexture := -1
966 else
967 FCurTexture := 0;
968 end
969 else
970 // Áîëüøå îäíîé òåêñòóðû:
971 begin
972 // Ñëåäóþùàÿ:
973 Inc(FCurTexture);
974 // Ñëåäóþùåé íåò - âîçâðàò ê íà÷àëó:
975 if FCurTexture >= Length(FTextureIDs) then
976 FCurTexture := 0;
977 end;
979 // Ïåðåêëþ÷èëèñü íà âèäèìóþ àíèì. òåêñòóðó:
980 if (FCurTexture >= 0) and FTextureIDs[FCurTexture].Anim then
981 begin
982 if (FTextureIDs[FCurTexture].AnTex = nil) then
983 begin
984 g_FatalError(_lc[I_GAME_ERROR_SWITCH_TEXTURE]);
985 Exit;
986 end;
988 if AnimLoop = 1 then
989 FTextureIDs[FCurTexture].AnTex.Loop := True
990 else
991 if AnimLoop = 2 then
992 FTextureIDs[FCurTexture].AnTex.Loop := False;
994 FTextureIDs[FCurTexture].AnTex.Reset();
995 end;
997 LastAnimLoop := AnimLoop;
998 end;
1000 procedure TPanel.SetTexture(ID: Integer; AnimLoop: Byte = 0);
1001 begin
1002 if (ID >= -1) and (ID < Length(FTextureIDs)) then
1003 FCurTexture := ID;
1005 // Ïåðåêëþ÷èëèñü íà âèäèìóþ àíèì. òåêñòóðó:
1006 if (FCurTexture >= 0) and FTextureIDs[FCurTexture].Anim then
1007 begin
1008 if (FTextureIDs[FCurTexture].AnTex = nil) then
1009 begin
1010 g_FatalError(_lc[I_GAME_ERROR_SWITCH_TEXTURE]);
1011 Exit;
1012 end;
1014 if AnimLoop = 1 then
1015 FTextureIDs[FCurTexture].AnTex.Loop := True
1016 else
1017 if AnimLoop = 2 then
1018 FTextureIDs[FCurTexture].AnTex.Loop := False;
1020 FTextureIDs[FCurTexture].AnTex.Reset();
1021 end;
1023 LastAnimLoop := AnimLoop;
1024 end;
1026 function TPanel.GetTextureID(): DWORD;
1027 begin
1028 Result := LongWord(TEXTURE_NONE);
1030 if (FCurTexture >= 0) then
1031 begin
1032 if FTextureIDs[FCurTexture].Anim then
1033 Result := FTextureIDs[FCurTexture].AnTex.FramesID
1034 else
1035 Result := FTextureIDs[FCurTexture].Tex;
1036 end;
1037 end;
1039 function TPanel.GetTextureCount(): Integer;
1040 begin
1041 Result := Length(FTextureIDs);
1042 if Enabled and (FCurTexture >= 0) then
1043 if (FTextureIDs[FCurTexture].Anim) and
1044 (FTextureIDs[FCurTexture].AnTex <> nil) and
1045 (Width > 0) and (Height > 0) and (FAlpha < 255) then
1046 Result := Result + 100;
1047 end;
1049 function TPanel.CanChangeTexture(): Boolean;
1050 begin
1051 Result := (GetTextureCount() > 1) or hasTexTrigger;
1052 end;
1054 const
1055 PAN_SAVE_VERSION = 1;
1057 procedure TPanel.SaveState (st: TStream);
1058 var
1059 anim: Boolean;
1060 begin
1061 if (st = nil) then exit;
1063 // Ñèãíàòóðà ïàíåëè
1064 utils.writeSign(st, 'PANL');
1065 utils.writeInt(st, Byte(PAN_SAVE_VERSION));
1066 // Îòêðûòà/çàêðûòà, åñëè äâåðü
1067 utils.writeBool(st, FEnabled);
1068 // Íàïðàâëåíèå ëèôòà, åñëè ëèôò
1069 utils.writeInt(st, Byte(FLiftType));
1070 // Íîìåð òåêóùåé òåêñòóðû
1071 utils.writeInt(st, Integer(FCurTexture));
1072 // Êîîðäèíàòû è ðàçìåð
1073 utils.writeInt(st, Integer(FX));
1074 utils.writeInt(st, Integer(FY));
1075 utils.writeInt(st, Word(FWidth));
1076 utils.writeInt(st, Word(FHeight));
1077 // Àíèìèðîâàíà ëè òåêóùàÿ òåêñòóðà
1078 if (FCurTexture >= 0) and (FTextureIDs[FCurTexture].Anim) then
1079 begin
1080 assert(FTextureIDs[FCurTexture].AnTex <> nil, 'TPanel.SaveState: No animation object');
1081 anim := true;
1082 end
1083 else
1084 begin
1085 anim := false;
1086 end;
1087 utils.writeBool(st, anim);
1088 // Åñëè äà - ñîõðàíÿåì àíèìàöèþ
1089 if anim then FTextureIDs[FCurTexture].AnTex.SaveState(st);
1091 // moving platform state
1092 utils.writeInt(st, Integer(mMovingSpeed.X));
1093 utils.writeInt(st, Integer(mMovingSpeed.Y));
1094 utils.writeInt(st, Integer(mMovingStart.X));
1095 utils.writeInt(st, Integer(mMovingStart.Y));
1096 utils.writeInt(st, Integer(mMovingEnd.X));
1097 utils.writeInt(st, Integer(mMovingEnd.Y));
1099 utils.writeInt(st, Integer(mSizeSpeed.w));
1100 utils.writeInt(st, Integer(mSizeSpeed.h));
1101 utils.writeInt(st, Integer(mSizeEnd.w));
1102 utils.writeInt(st, Integer(mSizeEnd.h));
1104 utils.writeBool(st, mMovingActive);
1105 utils.writeBool(st, mMoveOnce);
1107 utils.writeInt(st, Integer(mEndPosTrig));
1108 utils.writeInt(st, Integer(mEndSizeTrig));
1109 end;
1112 procedure TPanel.LoadState (st: TStream);
1113 begin
1114 if (st = nil) then exit;
1116 // Ñèãíàòóðà ïàíåëè
1117 if not utils.checkSign(st, 'PANL') then raise XStreamError.create('wrong panel signature');
1118 if (utils.readByte(st) <> PAN_SAVE_VERSION) then raise XStreamError.create('wrong panel version');
1119 // Îòêðûòà/çàêðûòà, åñëè äâåðü
1120 FEnabled := utils.readBool(st);
1121 // Íàïðàâëåíèå ëèôòà, åñëè ëèôò
1122 FLiftType := utils.readByte(st);
1123 // Íîìåð òåêóùåé òåêñòóðû
1124 FCurTexture := utils.readLongInt(st);
1125 // Êîîðäèíàòû è ðàçìåð
1126 FX := utils.readLongInt(st);
1127 FY := utils.readLongInt(st);
1128 FOldX := FX;
1129 FOldY := FY;
1130 FWidth := utils.readWord(st);
1131 FHeight := utils.readWord(st);
1132 FOldW := FWidth;
1133 FOldH := FHeight;
1134 // Àíèìèðîâàííàÿ ëè òåêóùàÿ òåêñòóðà
1135 if utils.readBool(st) then
1136 begin
1137 // Åñëè äà - çàãðóæàåì àíèìàöèþ
1138 Assert((FCurTexture >= 0) and
1139 (FTextureIDs[FCurTexture].Anim) and
1140 (FTextureIDs[FCurTexture].AnTex <> nil),
1141 'TPanel.LoadState: No animation object');
1142 FTextureIDs[FCurTexture].AnTex.LoadState(st);
1143 end;
1145 // moving platform state
1146 mMovingSpeed.X := utils.readLongInt(st);
1147 mMovingSpeed.Y := utils.readLongInt(st);
1148 mMovingStart.X := utils.readLongInt(st);
1149 mMovingStart.Y := utils.readLongInt(st);
1150 mMovingEnd.X := utils.readLongInt(st);
1151 mMovingEnd.Y := utils.readLongInt(st);
1153 mSizeSpeed.w := utils.readLongInt(st);
1154 mSizeSpeed.h := utils.readLongInt(st);
1155 mSizeEnd.w := utils.readLongInt(st);
1156 mSizeEnd.h := utils.readLongInt(st);
1158 mMovingActive := utils.readBool(st);
1159 mMoveOnce := utils.readBool(st);
1161 mEndPosTrig := utils.readLongInt(st);
1162 mEndSizeTrig := utils.readLongInt(st);
1164 positionChanged();
1165 //mapGrid.proxyEnabled[proxyId] := FEnabled; // done in g_map.pas
1166 end;
1169 end.