createConnection.h 838 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include <enet/enet.h>
  3. #include <stdint.h>
  4. #include <vector>
  5. #include "packet.h"
  6. struct Task
  7. {
  8. enum Type
  9. {
  10. none = 0,
  11. placeBlock,
  12. generateChunk,
  13. };
  14. glm::ivec3 pos = {};
  15. int type = 0;
  16. BlockType blockType = 0;
  17. EventId eventId = {};
  18. };
  19. void submitTaskClient(Task &t);
  20. void submitTaskClient(std::vector<Task> &t);
  21. struct Chunk;
  22. struct ConnectionData
  23. {
  24. ENetHost *client = 0;
  25. ENetPeer *server = 0;
  26. int32_t cid = 0;
  27. std::vector<Chunk *> recievedChunks = {};
  28. std::vector<Packet_PlaceBlocks> recievedBlocks = {};
  29. bool conected = false;
  30. };
  31. std::vector<Chunk *> getRecievedChunks();
  32. std::vector<Packet_PlaceBlocks> getRecievedBlocks();
  33. ConnectionData getConnectionData();
  34. bool createConnection();
  35. void clientMessageLoop(EventCounter &validatedEvent, RevisionNumber &invalidateRevision);
  36. void closeConnection();