Code:
void Send(SOCKET s)
{
char newarray[sizeof(NoughtsAndCrosses)];
memcpy( newarray, this, sizeof(NoughtsAndCrosses));
int sendCount = send(s, newarray,sizeof(NoughtsAndCrosses), 0);
}
Why are you copying the data to a new buffer (rather than just sending "NoughtsAndCrosses" itself)? Also, the function should be virtual, as it needs to be overridden by derived classes.
Code:
#define SQUARE_NULL 0
#define SQUARE_X 1
#define SQUARE_O 2
/*#define SQUARE2_X 4
#define SQUARE2_O 8
#define SQUARE3_X 16
#define SQUARE3_O 32
#define SQUARE4_X 64
#define SQUARE4_O 128
#define SQUARE5_X 252
#define SQUARE5_O 516
#define SQUARE6_X 1032
#define SQUARE6_O 2064
#define SQUARE7_X 1
#define SQUARE7_O 2
#define SQUARE8_X 1
#define SQUARE8_O 2
#define SQUARE9_X 1
#define SQUARE9_O 2
Using defines like this isn't considered a good practice (macro "pollution"). Use enums, eg:
Code:
enum
{
ABC = 12,
XYZ = 13
};
Also, as already mentioned, your bitmasks should be powers of two, and shouldn't overlap with eachother.
Code:
void Packing()
{
GameData *data = new GameData();
data->playerData = SQUARE_X;
data->aiData = SQUARE_O;
if(board[1] = SQUARE_O)
cout << "ai here";
}
Why are you even using "new" (not to mention that there is no corresponding "delete")? Just declare a local variable. At any rate, it isn't really clear what you're trying to do here. Moreover, if you are packing the board state into an integer, how are you to mark cells that aren't yet filled (eg, you need 3 states: X, O, and UNDEFINED (not set))?