1 // Emacs style mode select -*- C++ -*- 2 //----------------------------------------------------------------------------- 3 // 4 // $Id: p_snapshot.h 2785 2012-02-18 23:22:07Z dr_sean $ 5 // 6 // Copyright (C) 2000-2006 by Sergey Makovkin (CSDoom .62). 7 // Copyright (C) 2006-2014 by The Odamex Team. 8 // 9 // This program is free software; you can redistribute it and/or 10 // modify it under the terms of the GNU General Public License 11 // as published by the Free Software Foundation; either version 2 12 // of the License, or (at your option) any later version. 13 // 14 // This program is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // DESCRIPTION: 20 // Stores a limited view of actor, player, and sector objects at a particular 21 // point in time. Used with Unlagged, client-side prediction, and positional 22 // interpolation 23 // 24 //----------------------------------------------------------------------------- 25 26 #ifndef __P_SNAPSHOT_H__ 27 #define __P_SNAPSHOT_H__ 28 29 #include "m_fixed.h" 30 #include "doomdef.h" 31 #include "dsectoreffect.h" 32 33 class AActor; 34 class player_s; 35 typedef player_s player_t; 36 struct sector_s; 37 typedef sector_s sector_t; 38 struct line_s; 39 typedef line_s line_t; 40 41 class PlayerSnapshotManager; 42 43 extern int gametic; 44 45 #define NUM_SNAPSHOTS 32 46 47 //#define _WORLD_INDEX_DEBUG_ 48 //#define _SNAPSHOT_DEBUG_ 49 50 // ============================================================================ 51 // 52 // Snapshot Base Class Interface 53 // 54 // ============================================================================ 55 56 class Snapshot 57 { 58 public: 59 Snapshot(int time = -1); ~Snapshot()60 virtual ~Snapshot() {}; 61 62 bool operator==(const Snapshot &other) const; 63 isValid()64 bool isValid() const { return mValid; } isAuthoritative()65 bool isAuthoritative() const { return mAuthoritative; } isContinuous()66 bool isContinuous() const { return mContinuous; } isInterpolated()67 bool isInterpolated() const { return mInterpolated; } isExtrapolated()68 bool isExtrapolated() const { return mExtrapolated; } 69 setAuthoritative(bool val)70 virtual void setAuthoritative(bool val) { mAuthoritative = val; } setContinuous(bool val)71 virtual void setContinuous(bool val) { mContinuous = val; } setInterpolated(bool val)72 virtual void setInterpolated(bool val) { mInterpolated = val; } setExtrapolated(bool val)73 virtual void setExtrapolated(bool val) { mExtrapolated = val; } 74 getTime()75 int getTime() const { return mTime; } setTime(int time)76 void setTime(int time) { mTime = time; } 77 78 private: 79 int mTime; 80 bool mValid; 81 82 bool mAuthoritative; 83 bool mContinuous; 84 85 bool mInterpolated; 86 bool mExtrapolated; 87 }; 88 89 90 // ============================================================================ 91 // 92 // ActorSnapshot Interface 93 // 94 // ============================================================================ 95 96 class ActorSnapshot : public Snapshot 97 { 98 public: 99 ActorSnapshot(int time = -1); 100 ActorSnapshot(int time, const AActor *mo); ~ActorSnapshot()101 virtual ~ActorSnapshot() {}; 102 103 bool operator==(const ActorSnapshot &other) const; 104 105 void merge(const ActorSnapshot& other); 106 107 void toActor(AActor *mo) const; 108 getX()109 fixed_t getX() const { return mX; } getY()110 fixed_t getY() const { return mY; } getZ()111 fixed_t getZ() const { return mZ; } getMomX()112 fixed_t getMomX() const { return mMomX; } getMomY()113 fixed_t getMomY() const { return mMomY; } getMomZ()114 fixed_t getMomZ() const { return mMomZ; } getAngle()115 angle_t getAngle() const { return mAngle; } getPitch()116 angle_t getPitch() const { return mPitch; } getOnGround()117 bool getOnGround() const { return mOnGround; } getCeilingZ()118 fixed_t getCeilingZ() const { return mCeilingZ; } getFloorZ()119 fixed_t getFloorZ() const { return mFloorZ; } getReactionTime()120 int getReactionTime() const { return mReactionTime; } getWaterLevel()121 int getWaterLevel() const { return mWaterLevel; } getFlags()122 int getFlags() const { return mFlags; } getFlags2()123 int getFlags2() const { return mFlags2; } getFrame()124 int getFrame() const { return mFrame; } 125 setX(fixed_t val)126 void setX(fixed_t val) 127 { 128 mX = val; 129 mFields |= ACT_POSITIONX; 130 } 131 setY(fixed_t val)132 void setY(fixed_t val) 133 { 134 mY = val; 135 mFields |= ACT_POSITIONY; 136 } 137 setZ(fixed_t val)138 void setZ(fixed_t val) 139 { 140 mZ = val; 141 mFields |= ACT_POSITIONZ; 142 } 143 setMomX(fixed_t val)144 void setMomX(fixed_t val) 145 { 146 mMomX = val; 147 mFields |= ACT_MOMENTUMX; 148 } 149 setMomY(fixed_t val)150 void setMomY(fixed_t val) 151 { 152 mMomY = val; 153 mFields |= ACT_MOMENTUMY; 154 } 155 setMomZ(fixed_t val)156 void setMomZ(fixed_t val) 157 { 158 mMomZ = val; 159 mFields |= ACT_MOMENTUMZ; 160 } 161 setAngle(angle_t val)162 void setAngle(angle_t val) 163 { 164 mAngle = val; 165 mFields |= ACT_ANGLE; 166 } 167 setPitch(angle_t val)168 void setPitch(angle_t val) 169 { 170 mPitch = val; 171 mFields |= ACT_PITCH; 172 } 173 setOnGround(bool val)174 void setOnGround(bool val) 175 { 176 mOnGround = val; 177 mFields |= ACT_ONGROUND; 178 } 179 setCeilingZ(fixed_t val)180 void setCeilingZ(fixed_t val) 181 { 182 mCeilingZ = val; 183 mFields |= ACT_CEILINGZ; 184 } 185 setFloorZ(fixed_t val)186 void setFloorZ(fixed_t val) 187 { 188 mFloorZ = val; 189 mFields |= ACT_FLOORZ; 190 } 191 setReactionTime(int val)192 void setReactionTime(int val) 193 { 194 mReactionTime = val; 195 mFields |= ACT_REACTIONTIME; 196 } 197 setWaterLevel(int val)198 void setWaterLevel(int val) 199 { 200 mWaterLevel = val; 201 mFields |= ACT_WATERLEVEL; 202 } 203 setFlags(int val)204 void setFlags(int val) 205 { 206 mFlags = val; 207 mFields |= ACT_FLAGS; 208 } 209 setFlags2(int val)210 void setFlags2(int val) 211 { 212 mFlags2 = val; 213 mFields |= ACT_FLAGS2; 214 } 215 setFrame(int val)216 void setFrame(int val) 217 { 218 mFrame = val; 219 mFields |= ACT_FRAME; 220 } 221 222 private: 223 enum ActorFields { 224 ACT_POSITIONX = 0x00000001, 225 ACT_POSITIONY = 0x00000002, 226 ACT_POSITIONZ = 0x00000004, 227 ACT_MOMENTUMX = 0x00000008, 228 ACT_MOMENTUMY = 0x00000010, 229 ACT_MOMENTUMZ = 0x00000020, 230 ACT_ANGLE = 0x00000040, 231 ACT_PITCH = 0x00000080, 232 ACT_CEILINGZ = 0x00000100, 233 ACT_FLOORZ = 0x00000200, 234 ACT_ONGROUND = 0x00000400, 235 ACT_FLAGS = 0x00000800, 236 ACT_FLAGS2 = 0x00001000, 237 ACT_REACTIONTIME = 0x00002000, 238 ACT_WATERLEVEL = 0x00004000, 239 ACT_FRAME = 0x00008000 240 }; 241 242 unsigned int mFields; 243 244 fixed_t mX; 245 fixed_t mY; 246 fixed_t mZ; 247 fixed_t mMomX; 248 fixed_t mMomY; 249 fixed_t mMomZ; 250 angle_t mAngle; 251 angle_t mPitch; 252 253 bool mOnGround; 254 fixed_t mCeilingZ; 255 fixed_t mFloorZ; 256 257 int mReactionTime; 258 int mWaterLevel; 259 260 int mFlags; 261 int mFlags2; 262 int mFrame; 263 }; 264 265 266 // ============================================================================ 267 // 268 // PlayerSnapshot Interface 269 // 270 // ============================================================================ 271 272 class PlayerSnapshot : public Snapshot 273 { 274 public: 275 PlayerSnapshot(int time = -1); 276 PlayerSnapshot(int time, player_t *player); ~PlayerSnapshot()277 virtual ~PlayerSnapshot() {}; 278 279 bool operator==(const PlayerSnapshot &other) const; 280 281 void merge(const PlayerSnapshot& other); 282 283 void toPlayer(player_t *player) const; 284 getViewHeight()285 fixed_t getViewHeight() const { return mViewHeight; } getDeltaViewHeight()286 fixed_t getDeltaViewHeight() const { return mDeltaViewHeight; } getJumpTime()287 int getJumpTime() const { return mJumpTime; } 288 getX()289 fixed_t getX() const { return mActorSnap.getX(); } getY()290 fixed_t getY() const { return mActorSnap.getY(); } getZ()291 fixed_t getZ() const { return mActorSnap.getZ(); } getMomX()292 fixed_t getMomX() const { return mActorSnap.getMomX(); } getMomY()293 fixed_t getMomY() const { return mActorSnap.getMomY(); } getMomZ()294 fixed_t getMomZ() const { return mActorSnap.getMomZ(); } getAngle()295 angle_t getAngle() const { return mActorSnap.getAngle(); } getPitch()296 angle_t getPitch() const { return mActorSnap.getPitch(); } getOnGround()297 bool getOnGround() const { return mActorSnap.getOnGround(); } getCeilingZ()298 fixed_t getCeilingZ() const { return mActorSnap.getCeilingZ(); } getFloorZ()299 fixed_t getFloorZ() const { return mActorSnap.getFloorZ(); } getReactionTime()300 int getReactionTime() const { return mActorSnap.getReactionTime(); } getWaterLevel()301 int getWaterLevel() const { return mActorSnap.getWaterLevel(); } getFlags()302 int getFlags() const { return mActorSnap.getFlags(); } getFlags2()303 int getFlags2() const { return mActorSnap.getFlags2(); } getFrame()304 int getFrame() const { return mActorSnap.getFrame(); } 305 setAuthoritative(bool val)306 virtual void setAuthoritative(bool val) 307 { 308 Snapshot::setAuthoritative(val); 309 mActorSnap.setAuthoritative(val); 310 } 311 setContinuous(bool val)312 virtual void setContinuous(bool val) 313 { 314 Snapshot::setContinuous(val); 315 mActorSnap.setContinuous(val); 316 } 317 setInterpolated(bool val)318 virtual void setInterpolated(bool val) 319 { 320 Snapshot::setInterpolated(val); 321 mActorSnap.setInterpolated(val); 322 } 323 setExtrapolated(bool val)324 virtual void setExtrapolated(bool val) 325 { 326 Snapshot::setExtrapolated(val); 327 mActorSnap.setExtrapolated(val); 328 } 329 setX(fixed_t val)330 void setX(fixed_t val) 331 { 332 mActorSnap.setX(val); 333 mFields |= PLY_POSITIONX; 334 } 335 setY(fixed_t val)336 void setY(fixed_t val) 337 { 338 mActorSnap.setY(val); 339 mFields |= PLY_POSITIONY; 340 } 341 setZ(fixed_t val)342 void setZ(fixed_t val) 343 { 344 mActorSnap.setZ(val); 345 mFields |= PLY_POSITIONZ; 346 } 347 setMomX(fixed_t val)348 void setMomX(fixed_t val) 349 { 350 mActorSnap.setMomX(val); 351 mFields |= PLY_MOMENTUMX; 352 } 353 setMomY(fixed_t val)354 void setMomY(fixed_t val) 355 { 356 mActorSnap.setMomY(val); 357 mFields |= PLY_MOMENTUMY; 358 } 359 setMomZ(fixed_t val)360 void setMomZ(fixed_t val) 361 { 362 mActorSnap.setMomZ(val); 363 mFields |= PLY_MOMENTUMZ; 364 } 365 setAngle(angle_t val)366 void setAngle(angle_t val) 367 { 368 mActorSnap.setAngle(val); 369 mFields |= PLY_ANGLE; 370 } 371 setPitch(angle_t val)372 void setPitch(angle_t val) 373 { 374 mActorSnap.setPitch(val); 375 mFields |= PLY_PITCH; 376 } 377 setCeilingZ(fixed_t val)378 void setCeilingZ(fixed_t val) 379 { 380 mActorSnap.setCeilingZ(val); 381 mFields |= PLY_CEILINGZ; 382 } 383 setFloorZ(fixed_t val)384 void setFloorZ(fixed_t val) 385 { 386 mActorSnap.setFloorZ(val); 387 mFields |= PLY_FLOORZ; 388 } 389 setOnGround(fixed_t val)390 void setOnGround(fixed_t val) 391 { 392 mActorSnap.setOnGround(val != 0); 393 mFields |= PLY_ONGROUND; 394 } 395 setReactionTime(int val)396 void setReactionTime(int val) 397 { 398 mActorSnap.setReactionTime(val); 399 mFields |= PLY_REACTIONTIME; 400 } 401 setFlags(int val)402 void setFlags(int val) 403 { 404 mActorSnap.setFlags(val); 405 mFields |= PLY_FLAGS; 406 } 407 setFlags2(int val)408 void setFlags2(int val) 409 { 410 mActorSnap.setFlags2(val); 411 mFields |= PLY_FLAGS2; 412 } 413 setFrame(int val)414 void setFrame(int val) 415 { 416 mActorSnap.setFrame(val); 417 mFields |= PLY_FRAME; 418 } 419 setWaterLevel(int val)420 void setWaterLevel(int val) 421 { 422 mActorSnap.setWaterLevel(val); 423 mFields |= PLY_WATERLEVEL; 424 } 425 setViewHeight(fixed_t val)426 void setViewHeight(fixed_t val) 427 { 428 mViewHeight = val; 429 mFields |= PLY_VIEWHEIGHT; 430 } 431 setDeltaViewHeight(fixed_t val)432 void setDeltaViewHeight(fixed_t val) 433 { 434 mDeltaViewHeight = val; 435 mFields |= PLY_DELTAVIEWHEIGHT; 436 } 437 setJumpTime(int val)438 void setJumpTime(int val) 439 { 440 mJumpTime = val; 441 mFields |= PLY_JUMPTIME; 442 } 443 444 friend PlayerSnapshot P_LerpPlayerPosition(const PlayerSnapshot&, const PlayerSnapshot&, float); 445 friend PlayerSnapshot P_ExtrapolatePlayerPosition(const PlayerSnapshot&, float); 446 447 private: 448 enum PlayerFields { 449 PLY_POSITIONX = 0x00000001, 450 PLY_POSITIONY = 0x00000002, 451 PLY_POSITIONZ = 0x00000004, 452 PLY_MOMENTUMX = 0x00000008, 453 PLY_MOMENTUMY = 0x00000010, 454 PLY_MOMENTUMZ = 0x00000020, 455 PLY_ANGLE = 0x00000040, 456 PLY_PITCH = 0x00000080, 457 PLY_CEILINGZ = 0x00000100, 458 PLY_FLOORZ = 0x00000200, 459 PLY_ONGROUND = 0x00000400, 460 PLY_FLAGS = 0x00000800, 461 PLY_FLAGS2 = 0x00001000, 462 PLY_REACTIONTIME = 0x00002000, 463 PLY_WATERLEVEL = 0x00004000, 464 PLY_FRAME = 0x00008000, 465 PLY_VIEWHEIGHT = 0x00010000, 466 PLY_DELTAVIEWHEIGHT = 0x00020000, 467 PLY_JUMPTIME = 0x00040000 468 }; 469 470 unsigned int mFields; // bitfield of data present in snapshot 471 ActorSnapshot mActorSnap; 472 473 fixed_t mViewHeight; 474 fixed_t mDeltaViewHeight; 475 int mJumpTime; 476 }; 477 478 479 // ============================================================================ 480 // 481 // PlayerSnapshotManager Interface 482 // 483 // ============================================================================ 484 485 class PlayerSnapshotManager 486 { 487 public: 488 PlayerSnapshotManager(); 489 490 void clearSnapshots(); 491 getMostRecentTime()492 int getMostRecentTime() const { return mMostRecent; } 493 494 void addSnapshot(const PlayerSnapshot &snap); 495 PlayerSnapshot getSnapshot(int time) const; 496 497 private: 498 bool mValidSnapshot(int time) const; 499 int mFindValidSnapshot(int starttime, int endtime) const; 500 PlayerSnapshot mInterpolateSnapshots(int from, int to, int time) const; 501 PlayerSnapshot mExtrapolateSnapshot(int from, int time) const; 502 503 PlayerSnapshot mSnaps[NUM_SNAPSHOTS]; 504 int mMostRecent; 505 }; 506 507 508 // ============================================================================ 509 // 510 // SectorSnapshot Class Interface 511 // 512 // ============================================================================ 513 514 class SectorSnapshot : public Snapshot 515 { 516 public: 517 SectorSnapshot(int time = -1); 518 SectorSnapshot(int time, sector_t *sector); ~SectorSnapshot()519 virtual ~SectorSnapshot() {}; 520 521 void clear(); 522 void toSector(sector_t *sector) const; 523 setCeilingMoverType(movertype_t v)524 void setCeilingMoverType(movertype_t v) { mCeilingMoverType = v; } setFloorMoverType(movertype_t val)525 void setFloorMoverType(movertype_t val) { mFloorMoverType = val; } setSector(sector_t * val)526 void setSector(sector_t *val) { mSector = val; } setCeilingType(int val)527 void setCeilingType(int val) { mCeilingType = val; } setFloorType(int val)528 void setFloorType(int val) { mFloorType = val; } setCeilingTag(int val)529 void setCeilingTag(int val) { mCeilingTag = val; } setFloorTag(int val)530 void setFloorTag(int val) { mFloorTag = val; } setCeilingLine(line_t * val)531 void setCeilingLine(line_t *val) { mCeilingLine = val; } setFloorLine(line_t * val)532 void setFloorLine(line_t *val) { mFloorLine = val; } setCeilingHeight(fixed_t val)533 void setCeilingHeight(fixed_t val) { mCeilingHeight = val; } setFloorHeight(fixed_t val)534 void setFloorHeight(fixed_t val) { mFloorHeight = val; } setCeilingSpeed(fixed_t val)535 void setCeilingSpeed(fixed_t val) { mCeilingSpeed = val; } setFloorSpeed(fixed_t val)536 void setFloorSpeed(fixed_t val) { mFloorSpeed = val; } setCeilingDestination(fixed_t val)537 void setCeilingDestination(fixed_t val) { mCeilingDestination = val; } setFloorDestination(fixed_t val)538 void setFloorDestination(fixed_t val) { mFloorDestination = val; } setCeilingDirection(int val)539 void setCeilingDirection(int val) { mCeilingDirection = val; } setFloorDirection(int val)540 void setFloorDirection(int val) { mFloorDirection = val; } setCeilingOldDirection(int val)541 void setCeilingOldDirection(int val) { mCeilingOldDirection = val; } setFloorOldDirection(int val)542 void setFloorOldDirection(int val) { mFloorOldDirection = val; } setCeilingTexture(short val)543 void setCeilingTexture(short val) { mCeilingTexture = val; } setFloorTexture(short val)544 void setFloorTexture(short val) { mFloorTexture = val; } setCeilingSpecial(short val)545 void setCeilingSpecial(short val) { mNewCeilingSpecial = val; } setFloorSpecial(short val)546 void setFloorSpecial(short val) { mNewFloorSpecial = val; } setCeilingLow(fixed_t val)547 void setCeilingLow(fixed_t val) { mCeilingLow = val; } setCeilingHigh(fixed_t val)548 void setCeilingHigh(fixed_t val) { mCeilingHigh = val; } setFloorLow(fixed_t val)549 void setFloorLow(fixed_t val) { mFloorLow = val; } setFloorHigh(fixed_t val)550 void setFloorHigh(fixed_t val) { mFloorHigh = val; } setCeilingCrush(bool val)551 void setCeilingCrush(bool val) { mCeilingCrush = val; } setFloorCrush(bool val)552 void setFloorCrush(bool val) { mFloorCrush = val; } setSilent(bool val)553 void setSilent(bool val) { mSilent = val; } setCeilingWait(int val)554 void setCeilingWait(int val) { mCeilingWait = val; } setFloorWait(int val)555 void setFloorWait(int val) { mFloorWait = val; } setCeilingCounter(int val)556 void setCeilingCounter(int val) { mCeilingCounter = val; } setFloorCounter(int val)557 void setFloorCounter(int val) { mFloorCounter = val; } setResetCounter(int val)558 void setResetCounter(int val) { mResetCounter = val; } setCeilingStatus(int val)559 void setCeilingStatus(int val) { mCeilingStatus = val; } setFloorStatus(int val)560 void setFloorStatus(int val) { mFloorStatus = val; } setOldFloorStatus(int val)561 void setOldFloorStatus(int val) { mOldFloorStatus = val; } setCrusherSpeed1(fixed_t val)562 void setCrusherSpeed1(fixed_t val) { mCrusherSpeed1 = val; } setCrusherSpeed2(fixed_t val)563 void setCrusherSpeed2(fixed_t val) { mCrusherSpeed2 = val; } setStepTime(int val)564 void setStepTime(int val) { mStepTime = val; } setPerStepTime(int val)565 void setPerStepTime(int val) { mPerStepTime = val; } setPauseTime(int val)566 void setPauseTime(int val) { mPauseTime = val; } setOrgHeight(int val)567 void setOrgHeight(int val) { mOrgHeight = val; } setDelay(int val)568 void setDelay(int val) { mDelay = val; } setFloorLip(fixed_t val)569 void setFloorLip(fixed_t val) { mFloorLip = val; } setFloorOffset(fixed_t val)570 void setFloorOffset(fixed_t val) { mFloorOffset = val; } setCeilingChange(int val)571 void setCeilingChange(int val) { mCeilingChange = val; } setFloorChange(int val)572 void setFloorChange(int val) { mFloorChange = val; } 573 getCeilingMoverType()574 movertype_t getCeilingMoverType() const { return mCeilingMoverType; } getFloorMoverType()575 movertype_t getFloorMoverType() const { return mFloorMoverType; } getSector()576 sector_t* getSector() const { return mSector; } getCeilingType()577 int getCeilingType() const { return mCeilingType; } getFloorType()578 int getFloorType() const { return mFloorType; } getCeilingTag()579 int getCeilingTag() const { return mCeilingTag; } getFloorTag()580 int getFloorTag() const { return mFloorTag; } getCeilingLine()581 line_t* getCeilingLine() const { return mCeilingLine; } getFloorLine()582 line_t* getFloorLine() const { return mFloorLine; } getCeilingHeight()583 fixed_t getCeilingHeight() const { return mCeilingHeight; } getFloorHeight()584 fixed_t getFloorHeight() const { return mFloorHeight; } getCeilingSpeed()585 fixed_t getCeilingSpeed() const { return mCeilingSpeed; } getFloorSpeed()586 fixed_t getFloorSpeed() const { return mFloorSpeed; } getCeilingDestination()587 fixed_t getCeilingDestination() const { return mCeilingDestination; } getFloorDestination()588 fixed_t getFloorDestination() const { return mFloorDestination; } getCeilingDirection()589 int getCeilingDirection() const { return mCeilingDirection; } getFloorDirection()590 int getFloorDirection() const { return mFloorDirection; } getCeilingOldDirection()591 int getCeilingOldDirection() const { return mCeilingOldDirection; } getFloorOldDirection()592 int getFloorOldDirection() const { return mFloorOldDirection; } getCeilingTexture()593 short getCeilingTexture() const { return mCeilingTexture; } getFloorTexture()594 short getFloorTexture() const { return mFloorTexture; } getCeilingSpecial()595 short getCeilingSpecial() const { return mNewCeilingSpecial; } getFloorSpecial()596 short getFloorSpecial() const { return mNewFloorSpecial; } getCeilingLow()597 fixed_t getCeilingLow() const { return mCeilingLow; } getCeilingHigh()598 fixed_t getCeilingHigh() const { return mCeilingHigh; } getFloorLow()599 fixed_t getFloorLow() const { return mFloorLow; } getFloorHigh()600 fixed_t getFloorHigh() const { return mFloorHigh; } getCeilingCrush()601 bool getCeilingCrush() const { return mCeilingCrush; } getFloorCrush()602 bool getFloorCrush() const { return mFloorCrush; } getSilent()603 bool getSilent() const { return mSilent; } getCeilingWait()604 int getCeilingWait() const { return mCeilingWait; } getFloorWait()605 int getFloorWait() const { return mFloorWait; } getCeilingCounter()606 int getCeilingCounter() const { return mCeilingCounter; } getFloorCounter()607 int getFloorCounter() const { return mFloorCounter; } getResetCounter()608 int getResetCounter() const { return mResetCounter; } getCeilingStatus()609 int getCeilingStatus() const { return mCeilingStatus; } getFloorStatus()610 int getFloorStatus() const { return mFloorStatus; } getOldFloorStatus()611 int getOldFloorStatus() const { return mOldFloorStatus; } getCrusherSpeed1()612 fixed_t getCrusherSpeed1() const { return mCrusherSpeed1; } getCrusherSpeed2()613 fixed_t getCrusherSpeed2() const { return mCrusherSpeed1; } getStepTime()614 int getStepTime() const { return mStepTime; } getPerStepTime()615 int getPerStepTime() const { return mPerStepTime; } getPauseTime()616 int getPauseTime() const { return mPauseTime; } getOrgHeight()617 int getOrgHeight() const { return mOrgHeight; } getDelay()618 int getDelay() const { return mDelay; } getFloorLip()619 fixed_t getFloorLip() const { return mFloorLip; } getFloorOffset()620 fixed_t getFloorOffset() const { return mFloorOffset; } getCeilingChange()621 int getCeilingChange() const { return mCeilingChange; } getFloorChange()622 int getFloorChange() const { return mFloorChange; } 623 624 private: 625 movertype_t mCeilingMoverType; 626 movertype_t mFloorMoverType; 627 628 sector_t* mSector; 629 630 int mCeilingType; 631 int mFloorType; 632 int mCeilingTag; 633 int mFloorTag; 634 line_t* mCeilingLine; 635 line_t* mFloorLine; 636 637 fixed_t mCeilingHeight; 638 fixed_t mFloorHeight; 639 640 fixed_t mCeilingSpeed; 641 fixed_t mFloorSpeed; 642 643 fixed_t mCeilingDestination; 644 fixed_t mFloorDestination; 645 646 int mCeilingDirection; 647 int mFloorDirection; 648 649 int mCeilingOldDirection; 650 int mFloorOldDirection; 651 652 short mCeilingTexture; 653 short mFloorTexture; 654 655 short mNewCeilingSpecial; 656 short mNewFloorSpecial; 657 658 fixed_t mCeilingLow; 659 fixed_t mCeilingHigh; 660 661 fixed_t mFloorLow; 662 fixed_t mFloorHigh; 663 664 bool mCeilingCrush; 665 bool mFloorCrush; 666 bool mSilent; 667 int mCeilingWait; 668 int mFloorWait; 669 int mCeilingCounter; 670 int mFloorCounter; 671 int mResetCounter; 672 int mCeilingStatus; 673 int mFloorStatus; 674 int mOldFloorStatus; 675 676 fixed_t mCrusherSpeed1; 677 fixed_t mCrusherSpeed2; 678 679 int mStepTime; 680 int mPerStepTime; 681 int mPauseTime; 682 int mOrgHeight; 683 int mDelay; 684 685 fixed_t mFloorLip; 686 fixed_t mFloorOffset; 687 688 int mCeilingChange; 689 int mFloorChange; 690 }; 691 692 693 // ============================================================================ 694 // 695 // SectorSnapshotManager Interface 696 // 697 // ============================================================================ 698 699 class SectorSnapshotManager 700 { 701 public: 702 SectorSnapshotManager(); 703 704 bool empty(); 705 void clearSnapshots(); 706 getMostRecentTime()707 int getMostRecentTime() const { return mMostRecent; } 708 709 void addSnapshot(const SectorSnapshot &snap); 710 SectorSnapshot getSnapshot(int time) const; 711 712 private: 713 bool mValidSnapshot(int time) const; 714 715 SectorSnapshot mSnaps[NUM_SNAPSHOTS]; 716 int mMostRecent; 717 }; 718 719 720 // ============================================================================ 721 // 722 // Helper functions 723 // 724 // ============================================================================ 725 726 void P_SetPlayerSnapshotNoPosition(player_t *player, const PlayerSnapshot &snap); 727 728 ActorSnapshot P_LerpActorPosition(const ActorSnapshot &from, const ActorSnapshot &to, float amount); 729 ActorSnapshot P_ExtrapolateActorPosition(const ActorSnapshot &from, float amount); 730 731 PlayerSnapshot P_LerpPlayerPosition(const PlayerSnapshot &from, const PlayerSnapshot &to, float amount); 732 PlayerSnapshot P_ExtrapolatePlayerPosition(const PlayerSnapshot &from, float amount); 733 734 bool P_CeilingSnapshotDone(SectorSnapshot *snap); 735 bool P_FloorSnapshotDone(SectorSnapshot *snap); 736 737 #endif // __P_SNAPSHOT_H__ 738 739