You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
netpong/includes/check_input.hpp

31 lines
1.2 KiB
C++

#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.
It assumes that both ip_text and port_text are non-null.
Any errors are printed using the display_text function, with the given if_type.
TODO - Add better error checking. */
GameType check_server(char* ip_text, char* port_text, const int if_type);
/* 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.
Any errors are printed using the display_text function, with the given if_type. */
GameType check_client(char* code, const int if_type);
#endif