hifiMoveList.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _MOVELIST_HIFI_H_
  23. #define _MOVELIST_HIFI_H_
  24. #ifndef _MOVELIST_H_
  25. #include "T3D/gameBase/moveList.h"
  26. #endif
  27. class HifiMoveList : public MoveList
  28. {
  29. typedef MoveList Parent;
  30. public:
  31. HifiMoveList();
  32. void init() { mTotalServerTicks = ServerTicksUninitialized; }
  33. void ghostReadExtra(NetObject *,BitStream *, bool newGhost);
  34. void ghostPreRead(NetObject *, bool newGhost);
  35. void clientWriteMovePacket(BitStream *bstream);
  36. void clientReadMovePacket(BitStream *);
  37. void serverWriteMovePacket(BitStream *);
  38. void serverReadMovePacket(BitStream *bstream);
  39. void markControlDirty();
  40. U32 getMoves(Move**,U32* numMoves);
  41. void onAdvanceObjects() { if (mMoveVec.size() > mLastSentMove-mFirstMoveIndex) mLastSentMove++; }
  42. void advanceMove();
  43. protected:
  44. void resetMoveList();
  45. S32 getServerTicks(U32 serverTickNum);
  46. void updateClientServerTickDiff(S32 & tickDiff);
  47. bool serverTicksInitialized() { return mTotalServerTicks!=ServerTicksUninitialized; }
  48. protected:
  49. U32 mLastSentMove;
  50. F32 mAvgMoveQueueSize;
  51. // server side move list management
  52. U32 mTargetMoveListSize; // Target size of move buffer on server
  53. U32 mMaxMoveListSize; // Max size move buffer allowed to grow to
  54. F32 mSmoothMoveAvg; // Smoothing parameter for move list size running average
  55. F32 mMoveListSizeSlack; // Amount above/below target size move list running average allowed to diverge
  56. bool mSuppressMove; // If true, don't return move on server
  57. // client side tracking of server ticks
  58. enum { TotalTicksBits=10, TotalTicksMask = (1<<TotalTicksBits)-1, ServerTicksUninitialized=0xFFFFFFFF };
  59. U32 mTotalServerTicks;
  60. };
  61. #endif // _MOVELIST_HIFI_H_