This commit is contained in:
MarcEricMartel
2023-10-29 14:54:36 -04:00
parent 0b07d46dba
commit b54f8c31e5
9 changed files with 56 additions and 71 deletions

View File

@@ -801,6 +801,13 @@ bool netprot::emptyPack(netprot::Packet pck) {
}
}
netprot::Packet netprot::makePack(void* ptr, PACKET_TYPE type) {
Packet pck;
pck.ptr = ptr;
pck.type = type;
return pck;
}
std::vector<netprot::Packet> netprot::recvPacks(SOCKET sock, Buffer* buf) {
std::vector<Packet> lsPck;
int len = 0, end = 0;

View File

@@ -166,7 +166,7 @@ namespace netprot {
void sendPack(SOCKET sock, T* pack, char** buf, uint32_t* buflen) {
netprot::Serialize(pack, buf, buflen);
memset(&buf[*buflen], '\0', sizeof(uint64_t) + sizeof(uint8_t));
buflen += sizeof(uint64_t) + sizeof(uint8_t);
buflen += (sizeof(uint64_t) + sizeof(uint8_t));
send(sock, *buf, *buflen, 0);
*buflen = BUFFER_LENGTH;
}
@@ -176,7 +176,7 @@ namespace netprot {
sockaddr_in addr = *sockad;
netprot::Serialize(pack, buf, buflen);
memset(&buf[*buflen], '\0', sizeof(uint64_t) + sizeof(uint8_t));
buflen += sizeof(uint64_t) + sizeof(uint8_t);
buflen += (sizeof(uint64_t) + sizeof(uint8_t));
sendto(sock, *buf, *buflen, 0, (sockaddr*)&addr, sizeof(addr));
*buflen = BUFFER_LENGTH;
}

View File

@@ -6,6 +6,12 @@ World::~World() {}
Array2d<Chunk*>& World::GetChunks() { return m_chunks; }
void World::BuildWorld() {
for (int x = 0; x < WORLD_SIZE_X; ++x)
for (int y = 0; y < WORLD_SIZE_Y; ++y)
m_chunks.Set(x - m_center[0], y - m_center[1], new Chunk(x + m_center[0], y + m_center[1], m_seed));
}
void World::SetSeed(uint64_t seed) {
m_seed = seed;
}

View File

@@ -21,6 +21,7 @@ public:
~World();
Array2d<Chunk*>& GetChunks();
void BuildWorld();
void SetSeed(uint64_t seed);
@@ -45,7 +46,7 @@ private:
unsigned int m_center[2] = { UINT16_MAX / 2 - WORLD_SIZE_X, UINT16_MAX / 2 - WORLD_SIZE_Y };
void UpdateChunk(int& updates, unsigned int chx, unsigned int chy, BlockInfo* blockinfo[BTYPE_LAST]);
//void UpdateChunk(int& updates, unsigned int chx, unsigned int chy, BlockInfo* blockinfo[BTYPE_LAST]);
void UpdateWorld(const Vector3f& player, BlockInfo* blockinfo[BTYPE_LAST]);
void TransposeWorld(Vector3f& player, Bullet* bullets[MAX_BULLETS]);