Basic packet system done.
This commit is contained in:
17
src/main.c
17
src/main.c
@ -34,9 +34,14 @@ int32_t main(const int32_t argc, const char **argv) {
|
||||
|
||||
entityInit(&GAME.entities[GAME.entityCount++], ENTITY_TYPE_PLAYER);
|
||||
|
||||
float_t lastPing = -1;
|
||||
float_t time = 0;
|
||||
|
||||
while(true) {
|
||||
inputUpdate();
|
||||
consoleUpdate();
|
||||
serverUpdate();
|
||||
clientUpdate();
|
||||
|
||||
if(!CONSOLE.open) {
|
||||
for(uint32_t i = 0; i < GAME.entityCount; i++) {
|
||||
@ -47,8 +52,18 @@ int32_t main(const int32_t argc, const char **argv) {
|
||||
|
||||
renderresult_t result = renderDraw();
|
||||
if(result != RENDER_OK) break;
|
||||
|
||||
if(exitRequested) break;
|
||||
|
||||
time += GetFrameTime();
|
||||
if(time - lastPing > 1.0f) {
|
||||
lastPing = time;
|
||||
|
||||
if(CLIENT.state != CLIENT_STATE_CONNECTED) continue;
|
||||
packet_t packet;
|
||||
packetPingCreate(&packet);
|
||||
packetQueuePushOut(&CLIENT.packetQueue, &packet);
|
||||
lastPing = time;
|
||||
}
|
||||
}
|
||||
|
||||
serverDispose();
|
||||
|
Reference in New Issue
Block a user