git had the makefile ignored and not im stranded. updated gitignoreand have a good starting point for the game server. working on moving it into the game

This commit is contained in:
2026-01-30 13:30:24 -06:00
parent d29e772272
commit 6856f6f2c8
9 changed files with 340 additions and 52 deletions

View File

@@ -3,15 +3,16 @@
#include <SDL2/SDL_net.h>
#include <SDL2/SDL.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <mydebug.h>
#include <net.h>
#define SECS 1
char buf[PACKSZ];
char pack[PACKSZ];
packet msg;
int main(void)
{
@@ -36,18 +37,46 @@ int main(void)
printf("SDL_Net_TCP_Open error: %s\n", SDLNet_GetError());
exit(1);
}
PRINT_M("starting");
msg.type = G_STATE;
write_to_buff((Uint32*)pack, (Uint32*)&msg, PACKSZ);
PRINT_M("packed up!");
SDLNet_TCP_Send(sock, pack, PACKSZ);
PRINT_M("sent");
sleep(SECS);
ret = SDLNet_TCP_Recv(sock, pack, PACKSZ);
if(ret <=0 )
{
printf("error in TCP Recv: %s\n", SDLNet_GetError());
}
read_to_buff(buf, pack, PACKSZ);
msg.type = S_STATE;
write_to_buff((Uint32*)pack, (Uint32*)&msg, PACKSZ);
SDLNet_TCP_Send(sock, pack, PACKSZ);
PRINT_M("sent");
sleep(SECS);
msg.type = HOSTS_REQ;
write_to_buff((Uint32*)pack, (Uint32*)&msg, PACKSZ);
SDLNet_TCP_Send(sock, pack, PACKSZ);
PRINT_M("sent");
sleep(SECS);
msg.type = NEW_HOST;
write_to_buff((Uint32*)pack, (Uint32*)&msg, PACKSZ);
SDLNet_TCP_Send(sock, pack, PACKSZ);
PRINT_M("sent");
sleep(SECS);
msg.type = JOIN_REQ;
write_to_buff((Uint32*)pack, (Uint32*)&msg, PACKSZ);
SDLNet_TCP_Send(sock, pack, PACKSZ);
PRINT_M("sent");
sleep(SECS);
msg.type = U_NAME;
write_to_buff((Uint32*)pack, (Uint32*)&msg, PACKSZ);
SDLNet_TCP_Send(sock, pack, PACKSZ);
PRINT_M("sent");
sleep(SECS);
printf("got msg: %s\n", buf);
SDLNet_TCP_Close(sock);
SDLNet_Quit();
SDL_Quit();