NetworkLagPredictedPack.h 925 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * NetworkLagPredictedPack.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../../lib/networkPacks/NetPacksBase.h"
  12. #include "../../lib/serializer/CSerializer.h"
  13. /// Class that contains data for a single pack that client expects to receive from server
  14. class NetworkLagPredictedPack final : public IBinaryWriter
  15. {
  16. public:
  17. /// Serialized data of predicted pack, for comparison with version from server
  18. std::vector<std::byte> predictedPackData;
  19. /// List of packs that must be applied on client in case of failed prediction
  20. std::vector<std::unique_ptr<CPackForClient>> rollbackPacks;
  21. int write(const std::byte * data, unsigned size) final
  22. {
  23. predictedPackData.insert(predictedPackData.end(), data, data + size);
  24. return size;
  25. }
  26. };