]> git.localhorst.tv Git - blank.git/blob - src/client/ChunkReceiver.hpp
cleanup of sdl event to string functions
[blank.git] / src / client / ChunkReceiver.hpp
1 #ifndef BLANK_CLIENT_CHUNKRECEIVER_HPP_
2 #define BLANK_CLIENT_CHUNKRECEIVER_HPP_
3
4 #include "../app/IntervalTimer.hpp"
5 #include "../net/Packet.hpp"
6
7 #include <cstdint>
8 #include <list>
9
10
11 namespace blank {
12
13 class ChunkStore;
14 class WorldSave;
15
16 namespace client {
17
18 class ChunkTransmission;
19 class Client;
20
21 class ChunkReceiver {
22
23 public:
24         ChunkReceiver(Client &, ChunkStore &, const WorldSave &);
25         ~ChunkReceiver();
26
27         void Update(int dt);
28
29         int ToLoad() const noexcept;
30
31         void LoadOne();
32         void LoadN(std::size_t n);
33
34         void StoreN(std::size_t n);
35
36         void Handle(const Packet::ChunkBegin &);
37         void Handle(const Packet::ChunkData &);
38
39 private:
40         ChunkTransmission &GetTransmission(std::uint32_t id);
41         void Commit(ChunkTransmission &);
42
43         void ReRequest(ChunkTransmission &);
44
45 private:
46         Client &client;
47         ChunkStore &store;
48         const WorldSave &save;
49         std::list<ChunkTransmission> transmissions;
50         CoarseTimer timer;
51
52 };
53
54 }
55 }
56
57 #endif