1 /* 2 * src/client/data.h, part of Complete Goban (game program) 3 * Copyright (C) 1995-1997 William Shubert. 4 * See "configure.h.in" for more copyright information. 5 */ 6 7 8 #ifndef _CLIENT_DATA_H_ 9 10 #ifndef _CLIENT_SERVER_H_ 11 #include "server.h" 12 #endif 13 #ifndef _CGOBAN_H_ 14 #include "../cgoban.h" 15 #endif 16 #ifndef _CLIENT_CONN_H_ 17 #include "conn.h" 18 #endif 19 #ifndef _WMS_STR_H_ 20 #include <wms/str.h> 21 #endif 22 #ifdef _CLIENT_DATA_H_ 23 #error LEVELIZATION ERROR 24 #endif 25 26 #define _CLIENT_DATA_H_ 1 27 28 29 /********************************************************************** 30 * Data Types 31 **********************************************************************/ 32 typedef struct CliActions_struct { 33 /* 34 * Passing board as a void is really ugly. What I should do is move 35 * this data type into board.h and keep it in the main data structure, 36 * passing it down as needed. 37 */ 38 void (*newGame)(void *packet, GoStone localColor, int size, int handicap, 39 float komi, int mainTime, int byTime, void *board); 40 void (*gotMove)(void *packet, GoStone color, int loc); 41 void (*gotUndo)(void *packet); 42 void (*endGame)(void *packet); 43 void (*logout)(void *packet); 44 } CliActions; 45 46 47 typedef enum { 48 cliData_setup, cliData_login, cliData_main 49 } CliDataState; 50 51 52 typedef struct CliData_struct { 53 CliDataState state; 54 Cgoban *cg; 55 int serverNum; 56 CliServer server; 57 const char *serverName; 58 Str userName; 59 Str cmdBuild; 60 ClpEntry *numKibitz; 61 62 bool connValid; 63 CliConn conn; 64 65 const CliActions *actions; 66 void *packet; 67 68 int refCount; 69 70 /* Not sure I like this. */ 71 ButOut (*observeGame)(void *obPacket, int boardId); 72 void *obPacket; 73 74 MAGIC_STRUCT 75 } CliData; 76 77 78 /********************************************************************** 79 * Functions 80 **********************************************************************/ 81 extern CliData *cliData_create(Cgoban *cg, int serverNum, 82 const CliActions *actions, void *packet); 83 #define cliData_incRef(cd) (++((cd)->refCount)) 84 extern void cliData_closeConns(CliData *cd); 85 extern void cliData_decRef(CliData *cd); 86 87 #endif /* _CLIENT_DATA_H_ */ 88