Created an implementation and header file to check the user input, if it is entered through the GUI

This commit is contained in:
2024-03-08 14:43:45 -05:00
parent bc0d644399
commit 7812611fe6
2 changed files with 84 additions and 0 deletions

27
includes/check_input.hpp Normal file
View File

@@ -0,0 +1,27 @@
#ifndef _CHECK_INPUT_H
#define _CHECK_INPUT_H
#include "includes/sock.hpp"
typedef enum {M_SINGLE, M_CLIENT, M_SERVER} Mode;
/* This struct contains a Mode enum, which indicates the type of game we are
playing (Single player, client mode or server mode). The netsock parameter is
a 'Sock' object - Client and Server classes inherit from this object, so this
parameter can be instantiated to either a client or server, depending on the
game type. */
typedef struct {
Mode mode;
Sock* netsock;
} GameType;
/* This function checks the IP address and port passed to it, and returns a struct,
that contains information about the game mode, and contains the server socket.
TODO - Add better error checking. */
GameType check_server(char* ip_text, char* port_text);
/* NOT IMPLEMENTED YET - This function checks the code given to it, and returns a struct
that contains information about the game mode, and contains the client socket. */
GameType check_client(char* code);
#endif