Rev 57 | Rev 75 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 1 | pmbaty | 1 | // common.h | 
        
| 2 | |||
| 3 | #ifndef COMMON_H | 
        ||
| 4 | #define COMMON_H | 
        ||
| 5 | |||
| 6 | |||
| 7 | // standard includes | 
        ||
| 8 | #include <windows.h> | 
        ||
| 9 | #include <windowsx.h> | 
        ||
| 10 | #include <wininet.h> | 
        ||
| 11 | #include <commctrl.h> | 
        ||
| 12 | #include <richedit.h> | 
        ||
| 13 | #include <stdio.h> | 
        ||
| 59 | pmbaty | 14 | #include <io.h> | 
        
| 1 | pmbaty | 15 | #include <malloc.h> | 
        
| 16 | #include <math.h> | 
        ||
| 17 | #include <time.h> | 
        ||
| 18 | #include <share.h> | 
        ||
| 19 | #include <shlwapi.h> | 
        ||
| 20 | #include <shlobj.h> | 
        ||
| 21 | #include <process.h> | 
        ||
| 22 | #include <sys/stat.h> | 
        ||
| 23 | |||
| 24 | |||
| 25 | // project resources includes | 
        ||
| 26 | #include "resource/resource.h" | 
        ||
| 27 | |||
| 28 | |||
| 29 | // link with specific libraries | 
        ||
| 30 | #pragma comment (lib, "comctl32.lib") // for ImageList_*() | 
        ||
| 31 | #pragma comment (lib, "winmm.lib") // for PlaySound() | 
        ||
| 32 | #pragma comment (lib, "ws2_32.lib") // for network | 
        ||
| 33 | |||
| 34 | |||
| 35 | // global preprocessor defines | 
        ||
| 36 | #include "defines.h" | 
        ||
| 37 | |||
| 38 | |||
| 39 | // modeless message box definition | 
        ||
| 40 | typedef struct messagebox_s  | 
        ||
| 41 | { | 
        ||
| 42 | HWND hWndParent; // message box parent window  | 
        ||
| 43 | wchar_t title[128]; // message box title  | 
        ||
| 44 | wchar_t text[4096]; // message box text  | 
        ||
| 45 | int flags; // message box flags (such as MB_OK, MB_ICONEXCLAMATION, etc...)  | 
        ||
| 46 | } messagebox_t;  | 
        ||
| 47 | |||
| 48 | |||
| 49 | // part color theme data definition | 
        ||
| 50 | typedef struct partcolor_s  | 
        ||
| 51 | { | 
        ||
| 52 | int texture; // index of the texture used for the pieces in this theme  | 
        ||
| 53 | int material; // index of the material used for the pieces in this theme  | 
        ||
| 54 | } partcolor_t;  | 
        ||
| 55 | |||
| 56 | |||
| 57 | // background sprite definition | 
        ||
| 58 | typedef struct backgroundsprite_s  | 
        ||
| 59 | { | 
        ||
| 60 | int sprite_index; // index of the sprite used as the background in this theme  | 
        ||
| 61 | int sprite_width; // nominal width of bg sprite in pixels, rounded to the nearest higher power of 2  | 
        ||
| 62 | int sprite_height; // nominal height of bg sprite in pixels, rounded to the nearest higher power of 2  | 
        ||
| 63 | } backgroundsprite_t;  | 
        ||
| 64 | |||
| 65 | |||
| 66 | // light definition | 
        ||
| 67 | typedef struct light_s  | 
        ||
| 68 | { | 
        ||
| 69 | int type; // one of LIGHT_DIRECTIONAL, LIGHT_POINT, or LIGHT_SPOT  | 
        ||
| 70 | unsigned long color; // diffuse color (RGBA)  | 
        ||
| 71 | float pos_x; // X position in space  | 
        ||
| 72 | float pos_y; // Y position in space  | 
        ||
| 73 | float pos_z; // Z position in space  | 
        ||
| 74 | float direction_x; // X direction in space  | 
        ||
| 75 | float direction_y; // Y direction in space  | 
        ||
| 76 | float direction_z; // Z direction in space  | 
        ||
| 77 | float range; // distance after which the light won't be computed  | 
        ||
| 78 | float attenuation_constant; // constant light attenuation  | 
        ||
| 79 | float attenuation_proportional; // light attenuation that is proportional to distance  | 
        ||
| 80 | float attenuation_square; // light attenuation that is proportional to distance squared  | 
        ||
| 81 | float cone_inner; // inner cone angle, in degrees  | 
        ||
| 82 | float cone_outer; // outer cone angle, in degrees  | 
        ||
| 83 | } light_t;  | 
        ||
| 84 | |||
| 85 | |||
| 86 | // definition for the scene illumination | 
        ||
| 87 | typedef struct illumination_s  | 
        ||
| 88 | { | 
        ||
| 89 | unsigned long ambient_light; // scene ambient light color (RGBA)  | 
        ||
| 90 | light_t *lights; // mallocated array of lights to render  | 
        ||
| 91 | int light_count; // size of the lights array  | 
        ||
| 92 | } illumination_t;  | 
        ||
| 93 | |||
| 94 | |||
| 95 | // theme definition | 
        ||
| 96 | typedef struct theme_s  | 
        ||
| 97 | { | 
        ||
| 98 | bool is_loaded; // set to TRUE when this theme is fully loaded  | 
        ||
| 99 | int load_index; // when loading asynchronously, index of the item to load for each pass  | 
        ||
| 100 | |||
| 101 | wchar_t name[64]; // theme name (folder name)  | 
        ||
| 102 | wchar_t *description; // theme description or credits (mallocated)  | 
        ||
| 103 | backgroundsprite_t bg; // background sprite structure  | 
        ||
| 104 | illumination_t illum; // scene lights  | 
        ||
| 105 | int board_texture; // index of the texture used for the chess grid in this theme  | 
        ||
| 106 | int table_texture; // index of the texture used for the rest of the table in this theme  | 
        ||
| 107 | int grid_texture; // index of the texture used for the board grid numbers and letters  | 
        ||
| 108 | int trim_texture; // index of the texture used for the table/board delimiter  | 
        ||
| 109 | int board_material; // index of the material used for the chess grid in this theme  | 
        ||
| 110 | int table_material; // index of the material used for the rest of the table in this theme  | 
        ||
| 111 | int trim_material; // index of the material used for the table/board delimiter  | 
        ||
| 112 | unsigned char reflection_alpha; // table reflection alpha from 0 to 255 (high for marble, low for wood)  | 
        ||
| 113 | partcolor_t part_colors[2]; // part theme data for the two colors, COLOR_BLACK and COLOR_WHITE  | 
        ||
| 114 | |||
| 115 |    // meshes | 
        ||
| 116 | int board_meshindex;  | 
        ||
| 117 | int table_meshindex;  | 
        ||
| 118 | int trim_meshindex;  | 
        ||
| 119 | int tile_meshindex;  | 
        ||
| 120 | int part_meshes[7]; // first slot unused  | 
        ||
| 121 |    // textures | 
        ||
| 122 | int shadow_textureindex;  | 
        ||
| 123 | int hovered_textureindex;  | 
        ||
| 124 | int check_textureindex;  | 
        ||
| 125 | int threat_textureindex;  | 
        ||
| 126 | int lastmovesource_textureindex;  | 
        ||
| 127 | int lastmovetarget_textureindex;  | 
        ||
| 128 | int selected_textureindex;  | 
        ||
| 129 | int possiblemove_textureindex;  | 
        ||
| 130 | int takeable_textureindex;  | 
        ||
| 131 | int flattextures[2][7]; // [color][part], with first slot of the 7 unused  | 
        ||
| 132 |    // sprites | 
        ||
| 133 | int flatsprites[2][7]; // [color][part], with first slot of the 7 unused  | 
        ||
| 134 | int lastmovesource_spriteindex;  | 
        ||
| 135 | int lastmovetarget_spriteindex;  | 
        ||
| 136 | } theme_t;  | 
        ||
| 137 | |||
| 138 | |||
| 139 | // local typedefs | 
        ||
| 140 | typedef struct pgngame_s  | 
        ||
| 141 | { | 
        ||
| 142 | wchar_t event_str[64]; // [Event "blah"]  | 
        ||
| 143 | wchar_t site_str[64]; // [Site "blah"]  | 
        ||
| 144 | wchar_t date_str[16]; // [Date "YYYY.MM.DD"]  | 
        ||
| 145 | wchar_t round_str[16]; // [Round "N"]  | 
        ||
| 146 | wchar_t white_str[64]; // [White "blah"]  | 
        ||
| 147 | wchar_t black_str[64]; // [Black "blah"]  | 
        ||
| 148 | wchar_t result_str[16]; // [Result "blah"]  | 
        ||
| 149 | wchar_t eco_str[8]; // [ECO "XNN"] <-- this tag is optional, but useful nevertheless  | 
        ||
| 150 | wchar_t fen_str[128]; // [FEN "start pos"] <-- this tag is optional, but VERY useful  | 
        ||
| 151 | int gamedata_start; // offset at which the game data begins for this entry  | 
        ||
| 152 | } pgngame_t;  | 
        ||
| 153 | |||
| 154 | |||
| 155 | // player definition | 
        ||
| 156 | typedef struct player_s  | 
        ||
| 157 | { | 
        ||
| 158 |    // common data | 
        ||
| 159 | int type; // PLAYER_COMPUTER, PLAYER_INTERNET or PLAYER_HUMAN  | 
        ||
| 160 | char color; // either COLOR_BLACK, COLOR_WHITE or COLOR_UNSPECIFIED  | 
        ||
| 161 | wchar_t name[64]; // player name (machine name if human vs human or human vs cpu, login if human vs network)  | 
        ||
| 162 | float view_pitch; // current view pitch (vertical axis orientation towards the table center)  | 
        ||
| 163 | float view_yaw; // current view yaw (horizontal axis orientation towards the table center)  | 
        ||
| 164 | float view_distance; // current view distance to the table center  | 
        ||
| 165 | float custom_pitch; // user-saved view pitch  | 
        ||
| 166 | float custom_yaw; // user-saved view yaw  | 
        ||
| 167 | float custom_distance; // user-saved view distance  | 
        ||
| 168 | bool wants_cancel; // set to TRUE when this player wants to cancel its last move  | 
        ||
| 169 | |||
| 170 |    // PLAYER_HUMAN related data | 
        ||
| 171 | |||
| 172 |    // PLAYER_COMPUTER related data | 
        ||
| 173 | bool wants_hint;  | 
        ||
| 174 | |||
| 175 |    // PLAYER_INTERNET related data | 
        ||
| 176 | int our_socket;  | 
        ||
| 177 | bool is_connected;  | 
        ||
| 178 | bool is_logged_in;  | 
        ||
| 179 | bool is_in_game;  | 
        ||
| 180 | int game_number;  | 
        ||
| 181 | int remaining_seconds;  | 
        ||
| 182 | |||
| 183 |    // PLAYER_COMPUTER and PLAYER_INTERNET related data | 
        ||
| 184 | bool sendbuffer_locked; // set to TRUE if a thread currently locks the send buffer  | 
        ||
| 185 | wchar_t *sendbuffer; // used both for PLAYER_COMPUTER and PLAYER_INTERNET, mallocated  | 
        ||
| 186 | int sendbuffer_size; // size of the sendbuffer buffer  | 
        ||
| 187 | char *ascii_recvbuffer; // mallocated  | 
        ||
| 188 | wchar_t *recvbuffer; // used both for PLAYER_COMPUTER and PLAYER_INTERNET, mallocated  | 
        ||
| 189 | int recvbuffer_size; // size of the recvbuffer buffer  | 
        ||
| 190 | |||
| 191 | } player_t;  | 
        ||
| 192 | |||
| 193 | |||
| 194 | // definitions for a grid slot, a board side and a chess board | 
        ||
| 195 | typedef struct boardslot_s  | 
        ||
| 196 | { | 
        ||
| 197 | unsigned char part; // part ID of the part occupying this slot, or PART_NONE if not occupied  | 
        ||
| 198 | unsigned char color; // color ID of the part occupying this slot (either COLOR_WHITE or COLOR_BLACK)  | 
        ||
| 199 | unsigned char flags; // bitmap of slot flags (e.g: selected, move allowed, etc)  | 
        ||
| 200 | } boardslot_t;  | 
        ||
| 201 | |||
| 202 | |||
| 203 | typedef struct boardside_s  | 
        ||
| 204 | { | 
        ||
| 205 | unsigned char *takenparts; // mallocated array of part IDs that this side has captured from the opposing side  | 
        ||
| 206 | int takenpart_count; // size of the takenparts array  | 
        ||
| 207 | bool shortcastle_allowed; // set to TRUE if this side's king can still castle to G (column id 6)  | 
        ||
| 208 | bool longcastle_allowed; // set to TRUE if this side's king can still castle queenside, to C (column id 3)  | 
        ||
| 209 | } boardside_t;  | 
        ||
| 210 | |||
| 211 | |||
| 212 | typedef struct boardmove_s  | 
        ||
| 213 | { | 
        ||
| 214 | char color; // color this board move was for (either COLOR_UNSPECIFIED, COLOR_BLACK or COLOR_WHITE)  | 
        ||
| 215 | char part; // board move part type (to handle promotions)  | 
        ||
| 216 | char promotion_type; // in case of a pawn promotion, the new part's type  | 
        ||
| 217 | bool has_captured; // set to TRUE if this part has just captured another part  | 
        ||
| 218 | bool is_enpassant; // set to TRUE if the move was an "en passant" capture move  | 
        ||
| 219 | bool is_check; // set to TRUE if this move puts the opponent's king to check  | 
        ||
| 220 | bool is_stalemate; // set to TRUE if this move puts the opponent to stalemate  | 
        ||
| 221 | char source[2]; // this chess board's move source position ([line][column] array)  | 
        ||
| 222 | char target[2]; // this chess board's move target position ([line][column] array)  | 
        ||
| 223 | wchar_t pgntext[16]; // move PGN text  | 
        ||
| 224 | wchar_t *comment; // comment about that move (mallocated)  | 
        ||
| 225 | int comment_size; // size of the mallocated space used for comments, *IN WCHARS*  | 
        ||
| 226 | boardside_t sides[2]; // game state data structure for both opposing sides (COLOR_BLACK and COLOR_WHITE) after move is made  | 
        ||
| 227 | boardslot_t slots[8][8]; // this chess board's slots (8x8 array) after move is made  | 
        ||
| 228 | wchar_t fen_string[128]; // FEN string describing that move  | 
        ||
| 229 | } boardmove_t;  | 
        ||
| 230 | |||
| 231 | |||
| 232 | typedef struct board_s  | 
        ||
| 233 | { | 
        ||
| 234 | bool was_setup; // set to TRUE when the board has just been set up  | 
        ||
| 235 | int hovered_position[2]; // this chess board's hovered position ([line][column] array)  | 
        ||
| 236 | int selected_position[2]; // this chess board's selected position ([line][column] array)  | 
        ||
| 237 | boardmove_t *moves; // array of moves describing the game (mallocated)  | 
        ||
| 238 | int move_count; // amount of moves in this game so far  | 
        ||
| 239 | int viewed_move; // index of the move currently viewed (for watching game history)  | 
        ||
| 240 | player_t players[2]; // game state data structure for both opposing sides (COLOR_BLACK and COLOR_WHITE)  | 
        ||
| 241 | bool has_playerchanged; // set to TRUE when the current player has just changed  | 
        ||
| 242 | bool want_playerswap; // set to TRUE when a players swap is requested  | 
        ||
| 243 | int game_state; // one of the STATE_XXX #defines that describe the game and victory state  | 
        ||
| 244 | float lastmove_time; // date of last move  | 
        ||
| 245 | bool reevaluate; // set to TRUE if the game state should be reevaluated  | 
        ||
| 246 | } board_t;  | 
        ||
| 247 | |||
| 248 | |||
| 249 | // scene object definition | 
        ||
| 250 | typedef struct sceneobject_s  | 
        ||
| 251 | { | 
        ||
| 252 | int mesh_index; // object mesh index  | 
        ||
| 253 | int texture_index; // object texture index  | 
        ||
| 254 | int material_index; // object material index  | 
        ||
| 255 | float scale; // object scale, 1.0f = default size  | 
        ||
| 256 | float simpleshadow_size; // multiplier for the size of the original texture  | 
        ||
| 257 | float x; // X position in space  | 
        ||
| 258 | float y; // Y position in space  | 
        ||
| 259 | float z; // Z position in space  | 
        ||
| 260 | float pitch; // object pitch in degrees (leaning left/right)  | 
        ||
| 261 | float yaw; // object yaw in degrees (turning left/right)  | 
        ||
| 262 | } sceneobject_t;  | 
        ||
| 263 | |||
| 264 | |||
| 265 | // chatter channel reply | 
        ||
| 266 | typedef struct ccreply_s  | 
        ||
| 267 | { | 
        ||
| 268 | float arrival_time; // date at which this reply arrived  | 
        ||
| 269 | unsigned long color; // text color (RGBA)  | 
        ||
| 270 | wchar_t channelname[64]; // id of the channel this message is sent on  | 
        ||
| 271 | wchar_t nickname[32]; // sender's nickname  | 
        ||
| 272 | wchar_t *text; // message text (mallocated)  | 
        ||
| 273 | int text_length; // length of the above text, in characters, NOT including the null terminator  | 
        ||
| 274 | } ccreply_t;  | 
        ||
| 275 | |||
| 276 | |||
| 277 | // user interface button definition | 
        ||
| 278 | typedef struct guibutton_s  | 
        ||
| 279 | { | 
        ||
| 280 | int state; // render state: 0 = invisible, 1 = enabled, 2 = hovered  | 
        ||
| 281 | float left; // position of the top left corner, in percentage of screen width  | 
        ||
| 282 | float top; // position of the top left corner, in percentage of screen height  | 
        ||
| 283 | float width; // button tile width, in percentage of screen width  | 
        ||
| 284 | float height; // button tile height, in percentage of screen height  | 
        ||
| 285 | int sprite_index; // index of the sprite this button displays  | 
        ||
| 286 | } guibutton_t;  | 
        ||
| 287 | |||
| 288 | |||
| 289 | // user interface text field definition | 
        ||
| 290 | typedef struct guitext_s  | 
        ||
| 291 | { | 
        ||
| 292 | bool is_displayed; // set to TRUE if this text is displayed  | 
        ||
| 293 | float xpos_percent; // text's X position, in percents from left to right  | 
        ||
| 294 | float ypos_percent; // text's Y position, in percents from top to bottom  | 
        ||
| 295 | float maxwidth_percent; // text's max width before word wrapping, in percents of draw area width  | 
        ||
| 296 | int horizontal_align; // bounding rectangle's horizontal alignment regarding the X position (one of the ALIGN_xxx defines)  | 
        ||
| 297 | int vertical_align; // bounding rectangle's vertical alignment regarding the Y position (one of the ALIGN_xxx defines)  | 
        ||
| 298 | int text_align; // text's horizontal alignment inside that bounding rectangle  | 
        ||
| 299 | int font_index; // index of the font with which to display this text  | 
        ||
| 300 | unsigned long color; // text's color (RGBA)  | 
        ||
| 301 | wchar_t *buffer; // text printed in this area of the screen (mallocated)  | 
        ||
| 302 | int buffer_size; // size of the text buffer  | 
        ||
| 303 | float appear_time; // date at which this text was put  | 
        ||
| 304 | float disappear_time; // date at which this text should disappear  | 
        ||
| 305 | bool want_fade; // set to TRUE if this text is to be faded in and out  | 
        ||
| 306 | } guitext_t;  | 
        ||
| 307 | |||
| 308 | |||
| 309 | // game user interface definition | 
        ||
| 310 | typedef struct gui_s  | 
        ||
| 311 | { | 
        ||
| 312 |    // IMPORTANT: ensure all guitext_t buffers are freed in Scene_Shutdown() | 
        ||
| 313 | |||
| 314 | guibutton_t larrow; // render state: 0 = invisible, 1 = enabled, 2 = hovered  | 
        ||
| 315 | guibutton_t rarrow; // render state: 0 = invisible, 1 = enabled, 2 = hovered  | 
        ||
| 316 | guitext_t arrow_text; // usually, viewed move number versus the total of moves  | 
        ||
| 317 | guibutton_t chatbutton; // render state: 0 = invisible, 1 = enabled, 2 = hovered  | 
        ||
| 318 | guibutton_t gamesbutton; // render state: 0 = invisible, 1 = enabled, 2 = hovered  | 
        ||
| 319 | guibutton_t peoplebutton; // render state: 0 = invisible, 1 = enabled, 2 = hovered  | 
        ||
| 320 | guitext_t comment_text; // text printed in the comments area  | 
        ||
| 321 | guitext_t history_text; // text printed in the moves text area  | 
        ||
| 322 | guitext_t clock_text; // text printed in the game clock area  | 
        ||
| 323 | guitext_t turn_text; // text printed in the "X moves" area  | 
        ||
| 324 | guitext_t central_text; // text printed in the center of the screen  | 
        ||
| 325 | ccreply_t *cchistory; // mallocated array of chatter channel replies  | 
        ||
| 326 | int cchistory_count; // number of elements in the above array  | 
        ||
| 327 | bool is_entering_text; // set to TRUE if player is entering text  | 
        ||
| 328 | ccreply_t entered_ccreply; // text that is currently being entered  | 
        ||
| 329 | bool is_partspick_displayed; // set to TRUE if the parts pick line is displayed  | 
        ||
| 330 | bool want_spinwheel; // set to TRUE to display a spinning wheel  | 
        ||
| 331 | char partspick_hoveredpart; // one of "PRNBQK kqbnrp"  | 
        ||
| 332 | char partspick_selectedpart; // one of "PRNBQK kqbnrp"  | 
        ||
| 333 | } gui_t;  | 
        ||
| 334 | |||
| 335 | |||
| 336 | // rendering scene definition | 
        ||
| 337 | typedef struct scene_s  | 
        ||
| 338 | { | 
        ||
| 339 | int background_spriteindex; // index of the background sprite (-1 if none)  | 
        ||
| 340 | sceneobject_t *objects; // mallocated array of objects to render  | 
        ||
| 341 | int object_count; // size of the objects array  | 
        ||
| 342 | int overlay_spriteindex; // index of the overlay sprite (-1 if none)  | 
        ||
| 343 | gui_t gui; // GUI laid over this scene  | 
        ||
| 344 | bool update; // set to TRUE if the scene needs to be updated  | 
        ||
| 345 | } scene_t;  | 
        ||
| 346 | |||
| 347 | |||
| 40 | pmbaty | 348 | // engine program options definition (populated from "engines/<program>/engine.ini") | 
        
| 349 | typedef struct engineprogramoptions_s  | 
        ||
| 1 | pmbaty | 350 | { | 
        
| 32 | pmbaty | 351 | wchar_t name[64]; // chess engine name (will be used as player name)  | 
        
| 352 | wchar_t cmdline[MAX_PATH]; // chess engine binary startup command-line, e.g "gnuchess.exe"  | 
        ||
| 353 | wchar_t replystring_move[64]; // chess engine reply string for a move (positions come right after)  | 
        ||
| 44 | pmbaty | 354 | wchar_t command_new[64]; // command to send the chess engine to tell him we are starting a new game  | 
        
| 355 | wchar_t command_setboard[64]; // command to send the chess engine to tell him to set the table in a particular way (FEN notation)  | 
        ||
| 356 | wchar_t command_sd[64]; // command to send the chess engine to instruct it about its allowed depth (will be followed by numeric)  | 
        ||
| 357 | wchar_t command_go[64]; // command to send the chess engine to make it play the current move  | 
        ||
| 358 | wchar_t command_move[64]; // command to send the chess engine to instruct it that its opponent played a particular move  | 
        ||
| 359 | wchar_t command_force[64]; // command to send the chess engine to force it to play a particular move instead of the one it wants  | 
        ||
| 360 | wchar_t command_quit[64]; // command to send the chess engine to make it exit cleanly  | 
        ||
| 40 | pmbaty | 361 | } engineprogramoptions_t;  | 
        
| 362 | |||
| 363 | |||
| 364 | // engine options definition | 
        ||
| 365 | typedef struct engineoptions_s  | 
        ||
| 366 | { | 
        ||
| 367 | wchar_t program[MAX_PATH]; // chess engine program name (must be a subdirectory in "engines")  | 
        ||
| 368 | int depth; // chess engine's currently allowed search depth  | 
        ||
| 369 | int max_depth; // chess engine maximum search depth (used just for slider display)  | 
        ||
| 370 | int blunder_chances; // chess engine blunder chances, in percent  | 
        ||
| 371 | int obstinacy_level; // chess engine obstinacy level, in number of moves  | 
        ||
| 372 | bool is_expert_mode; // set to TRUE if this player claims to be an expert player (in the game settings)  | 
        ||
| 373 | engineprogramoptions_t program_options; // engine program options  | 
        ||
| 1 | pmbaty | 374 | } engineoptions_t;  | 
        
| 375 | |||
| 376 | |||
| 377 | // network options definition | 
        ||
| 378 | typedef struct networkoptions_s  | 
        ||
| 379 | { | 
        ||
| 380 | wchar_t server_address[MAX_PATH]; // chess server URL for online gaming  | 
        ||
| 381 | int server_port; // chess server listen port (usually 5000) for online gaming  | 
        ||
| 382 | wchar_t login[32]; // login for online gaming  | 
        ||
| 383 | wchar_t password[32]; // password for online gaming  | 
        ||
| 384 | bool want_servermessages; // set to TRUE if server messages are to be displayed (MOTD, RoboAdmin messages, announcements)  | 
        ||
| 385 | bool want_publicchat; // set to TRUE if public chat messages and chatter channels list are to be displayed  | 
        ||
| 386 | bool want_motdonconnect; // set to TRUE if the MOTD is to be displayed when connecting to the chess server  | 
        ||
| 387 | } networkoptions_t;  | 
        ||
| 388 | |||
| 389 | |||
| 14 | pmbaty | 390 | // registration options definition | 
        
| 391 | typedef struct registrationoptions_s  | 
        ||
| 392 | { | 
        ||
| 393 | wchar_t user_email[MAX_PATH]; // registered user's email address  | 
        ||
| 394 | unsigned long activation_code; // registered user's activation code  | 
        ||
| 395 | } registrationoptions_t;  | 
        ||
| 396 | |||
| 397 | |||
| 1 | pmbaty | 398 | // game options definition | 
        
| 399 | typedef struct options_s  | 
        ||
| 400 | { | 
        ||
| 401 | bool want_fullscreen; // set to TRUE to run in fullscreen mode  | 
        ||
| 402 | int window_width; // window width when not in fullscreen mode  | 
        ||
| 403 | int window_height; // window height when not in fullscreen mode  | 
        ||
| 404 | bool want_sounds; // set to TRUE to enable sounds  | 
        ||
| 405 | bool want_animations; // set to TRUE to enable part animations  | 
        ||
| 406 | bool want_possiblemoves; // set to TRUE to show possible moves  | 
        ||
| 407 | bool want_lastmove; // set to TRUE to show the last move  | 
        ||
| 408 | bool want_threats; // set to TRUE to display king's threats  | 
        ||
| 409 | bool want_autorotateon1vs1; // set to TRUE to enable board auto-rotation when playing human vs human locally  | 
        ||
| 410 | bool want_takenparts; // set to TRUE to display the taken parts on the side of the board  | 
        ||
| 411 | bool want_turn; // set to TRUE to display the current turn  | 
        ||
| 412 | bool want_clock; // set to TRUE to display a game clock  | 
        ||
| 413 | unsigned long clock_color; // RGBA color of the game clock  | 
        ||
| 414 | bool want_history; // set to TRUE to enable the display of game history  | 
        ||
| 415 | unsigned long history_color; // RGBA color of the game history  | 
        ||
| 416 | bool want_sepiafilter; // set to TRUE to enable the sepia filter when displaying past moves  | 
        ||
| 417 | bool want_filtering; // set to TRUE to enable texture filtering  | 
        ||
| 418 | bool want_hiquality; // set to TRUE to enable maximum possible quality filtering  | 
        ||
| 419 | bool want_reflections; // set to TRUE to enable part reflections  | 
        ||
| 420 | bool want_specularlighting; // set to TRUE to enable specular lighting  | 
        ||
| 421 | int rotate_speed; // board rotation speed  | 
        ||
| 14 | pmbaty | 422 | registrationoptions_t registration; // registration options  | 
        
| 1 | pmbaty | 423 | engineoptions_t engine; // engine options  | 
        
| 424 | networkoptions_t network; // network options  | 
        ||
| 425 | } options_t;  | 
        ||
| 426 | |||
| 427 | |||
| 428 | // online player definition | 
        ||
| 429 | typedef struct onlineplayer_s  | 
        ||
| 430 | { | 
        ||
| 431 | int rating; // player rating (ELO estimate)  | 
        ||
| 432 | unsigned char ratingtype; // either one of RATING_xxx (default, estimated or provisional)  | 
        ||
| 433 | unsigned char handlestatus; // either one of HANDLESTATUS_xxx values  | 
        ||
| 434 | wchar_t nickname[32]; // this player's nickname  | 
        ||
| 435 | unsigned short handlecodes; // bitmap: one or several of HANDLECODE_xxx flag  | 
        ||
| 436 | } onlineplayer_t;  | 
        ||
| 437 | |||
| 438 | |||
| 439 | // chatter channel member definition | 
        ||
| 440 | typedef struct chatterchannelmember_s  | 
        ||
| 441 | { | 
        ||
| 442 | bool is_silenced; // set to TRUE if this player plays in silence  | 
        ||
| 443 | wchar_t nickname[32]; // this player's nickname  | 
        ||
| 444 | } chatterchannelmember_t;  | 
        ||
| 445 | |||
| 446 | |||
| 447 | // chatter channel definition | 
        ||
| 448 | typedef struct chatterchannel_s  | 
        ||
| 449 | { | 
        ||
| 450 | int id; // channel's numeric ID  | 
        ||
| 451 | bool is_open; // set to TRUE if listening is currently enabled for this channel  | 
        ||
| 452 | wchar_t theme[64]; // channel theme, as reported by the server  | 
        ||
| 453 | unsigned long color; // channel text color (RGBA)  | 
        ||
| 454 | chatterchannelmember_t *members; // mallocated array of members  | 
        ||
| 455 | int member_count; // number of members in this channel  | 
        ||
| 456 | } chatterchannel_t;  | 
        ||
| 457 | |||
| 458 | |||
| 459 | // challenge definition | 
        ||
| 460 | typedef struct challenge_s  | 
        ||
| 461 | { | 
        ||
| 462 | bool is_active; // set to TRUE if this challenge is active  | 
        ||
| 463 | wchar_t challenger[32]; // challenger nickname  | 
        ||
| 464 | HWND hWnd; // challenge window handle  | 
        ||
| 465 | int challenger_level; // challenger level  | 
        ||
| 466 | int color; // color this challenger wants to play  | 
        ||
| 467 | bool is_rated; // whether this game is rated or not  | 
        ||
| 468 | wchar_t game_type[32]; // game type, literally  | 
        ||
| 469 | float initial_time; // initial time of the game for each color  | 
        ||
| 470 | float increment; // eventual time increment (Fischer pace)  | 
        ||
| 471 | bool update_dialog; // set to TRUE when the dialog window should be updated  | 
        ||
| 472 | } challenge_t;  | 
        ||
| 473 | |||
| 474 | |||
| 475 | // sought game definition | 
        ||
| 476 | typedef struct soughtgame_s  | 
        ||
| 477 | { | 
        ||
| 478 | int id; // sought game ID  | 
        ||
| 479 | int rating; // player rating (ELO estimate)  | 
        ||
| 480 | wchar_t nickname[32]; // this player's nickname  | 
        ||
| 481 | float initial_time; // initial time of the game for each color  | 
        ||
| 482 | float increment; // eventual time increment (Fischer pace)  | 
        ||
| 483 | unsigned char rating_type; // one of GAMERATINGTYPE_xxx #defines  | 
        ||
| 484 | wchar_t game_type[32]; // game type, literally  | 
        ||
| 485 | int color; // color this player will have  | 
        ||
| 486 | int lowest_accepted; // lowest ELO accepted  | 
        ||
| 487 | int highest_accepted; // highest ELO accepted  | 
        ||
| 488 | bool manual_start; // set to TRUE if the game should start manually  | 
        ||
| 489 | bool formula_checked; // set to TRUE if the filter formula will be used  | 
        ||
| 490 | } soughtgame_t;  | 
        ||
| 491 | |||
| 492 | |||
| 493 | // chat interlocutor | 
        ||
| 494 | typedef struct interlocutor_s  | 
        ||
| 495 | { | 
        ||
| 496 | bool is_active; // set to TRUE if this interlocutor is active  | 
        ||
| 497 | wchar_t nickname[32]; // interlocutor nickname (don't point to player list, because it changes...)  | 
        ||
| 498 | HWND hWnd; // chat window handle  | 
        ||
| 499 | int current_displaypicture; // current display picture index  | 
        ||
| 500 | wchar_t *dialogtext; // mallocated wchar_t buffer of dialog text (beware: RTF is ASCII-only)  | 
        ||
| 501 | int dialogtext_size; // size of the dialog text buffer, in WCHARs  | 
        ||
| 502 | bool update_dialog; // set to TRUE when the dialog window should be updated  | 
        ||
| 503 | } interlocutor_t;  | 
        ||
| 504 | |||
| 505 | |||
| 506 | // game style ratings | 
        ||
| 507 | typedef struct gamestylerating_s  | 
        ||
| 508 | { | 
        ||
| 509 | wchar_t name[32]; // game style name (e.g, "standard", "blitz", etc.)  | 
        ||
| 510 | int rating; // ELO rating for this style of play  | 
        ||
| 511 | float rd; // unknown data ???  | 
        ||
| 512 | int win_count; // amount of won matches in this style of play  | 
        ||
| 513 | int loss_count; // amount of lost matches in this style of play  | 
        ||
| 514 | int draw_count; // amount of draw matches in this style of play  | 
        ||
| 515 | int total_matches; // amount of played matches in this style of play (basically, sum of win + loss + draws)  | 
        ||
| 516 | } gamestylerating_t;  | 
        ||
| 517 | |||
| 518 | |||
| 519 | // player cards | 
        ||
| 520 | typedef struct playercard_s  | 
        ||
| 521 | { | 
        ||
| 522 | bool is_active; // set to TRUE if this slot is active  | 
        ||
| 523 | bool is_own; // set to TRUE if this card is the local player's one  | 
        ||
| 524 | wchar_t nickname[32]; // interlocutor nickname (don't point to player list, because it changes...)  | 
        ||
| 525 | HWND hWnd; // player card window handle  | 
        ||
| 526 | bool got_reply; // set to TRUE when this player card slot got server reply (i.e, it contains actual data)  | 
        ||
| 527 | bool doesnt_exist; // set to TRUE when the chess server reports that this player doesn't exist  | 
        ||
| 528 | int minutes_online; // amount of minutes this player has been online  | 
        ||
| 529 | int seconds_idle; // amount of seconds elapsed since this player's last activity  | 
        ||
| 530 | unsigned char disconnection_day; // day of disconnection  | 
        ||
| 531 | unsigned char disconnection_month; // month of disconnection  | 
        ||
| 532 | unsigned short disconnection_year; // year of disconnection  | 
        ||
| 533 | int game_played; // index of the game currently played by this player  | 
        ||
| 534 | wchar_t game_name[64]; // name of the game currently played by this player  | 
        ||
| 535 | wchar_t *fingertext; // mallocated wchar_t buffer of personal finger text  | 
        ||
| 536 | int fingertext_length; // size of the finger text buffer, in WCHARs  | 
        ||
| 537 | gamestylerating_t *gamestyleratings; // mallocated array of game styles for which this player is rated  | 
        ||
| 538 | int gamestylerating_count; // amount of different game styles for which this player is rated  | 
        ||
| 539 | bool update_dialog; // set to TRUE when the dialog window should be updated  | 
        ||
| 540 | } playercard_t;  | 
        ||
| 541 | |||
| 542 | |||
| 543 | // handle status pictures | 
        ||
| 544 | typedef struct handlestatus_s  | 
        ||
| 545 | { | 
        ||
| 546 | HICON icon; // icon handle  | 
        ||
| 547 | HBITMAP bitmap; // bitmap handle  | 
        ||
| 548 | wchar_t *text; // pointer to the text string describing this status  | 
        ||
| 549 | } handlestatus_t;  | 
        ||
| 550 | |||
| 551 | |||
| 552 | // smilies | 
        ||
| 553 | typedef struct smiley_s  | 
        ||
| 554 | { | 
        ||
| 555 | wchar_t name[32]; // smiley name  | 
        ||
| 556 | wchar_t filename[MAX_PATH]; // filename of that smiley's PNG picture  | 
        ||
| 557 | wchar_t *rtf_data; // smiley RTF data, mallocated  | 
        ||
| 558 | int rtf_len; // length of the above data string (minus the null terminator)  | 
        ||
| 559 | } smiley_t;  | 
        ||
| 560 | |||
| 561 | |||
| 562 | // localized texts | 
        ||
| 563 | typedef struct text_s  | 
        ||
| 564 | { | 
        ||
| 565 | wchar_t *id_string; // ID string for the given text (mallocated), example: "AboutBox_Title"  | 
        ||
| 566 | wchar_t *localized_string; // localized string for the given text (mallocated), example: "A propos de ce logiciel"  | 
        ||
| 567 | } text_t;  | 
        ||
| 568 | |||
| 569 | |||
| 59 | pmbaty | 570 | // languages | 
        
| 571 | typedef struct language_s  | 
        ||
| 572 | { | 
        ||
| 573 | wchar_t name[64]; // language name, e.g. "French", "English" or "Norwegian (norsk)"  | 
        ||
| 574 | text_t *texts; // mallocated array of localized texts  | 
        ||
| 575 | int text_count; // size of the texts array  | 
        ||
| 576 | } language_t;  | 
        ||
| 577 | |||
| 578 | |||
| 1 | pmbaty | 579 | // global declarations | 
        
| 580 | #ifndef DEFINE_GLOBALS | 
        ||
| 581 | #define GLOBAL extern | 
        ||
| 582 | #else | 
        ||
| 583 | #define GLOBAL | 
        ||
| 584 | #endif | 
        ||
| 59 | pmbaty | 585 | GLOBAL int language_id;  | 
        
| 14 | pmbaty | 586 | GLOBAL bool is_registered;  | 
        
| 1 | pmbaty | 587 | GLOBAL bool terminate_everything;  | 
        
| 588 | GLOBAL HINSTANCE hAppInstance; | 
        ||
| 589 | GLOBAL wchar_t app_path[MAX_PATH];  | 
        ||
| 590 | GLOBAL wchar_t load_pathname[MAX_PATH];  | 
        ||
| 591 | GLOBAL wchar_t save_pathname[MAX_PATH];  | 
        ||
| 59 | pmbaty | 592 | GLOBAL HMENU hMainMenu; | 
        
| 593 | GLOBAL HACCEL hMainAccelerators; | 
        ||
| 1 | pmbaty | 594 | GLOBAL HWND hMainWnd; | 
        
| 595 | GLOBAL HWND hChatterChannelsWnd; | 
        ||
| 596 | GLOBAL HWND hGamesWnd; | 
        ||
| 597 | GLOBAL HWND hMOTDWnd; | 
        ||
| 598 | GLOBAL HWND hOpponentsWnd; | 
        ||
| 599 | GLOBAL HWND hSoughtWnd; | 
        ||
| 600 | GLOBAL messagebox_t messagebox; | 
        ||
| 601 | GLOBAL bool want_framerate;  | 
        ||
| 602 | GLOBAL float current_time;  | 
        ||
| 603 | GLOBAL float animation_endtime;  | 
        ||
| 21 | pmbaty | 604 | GLOBAL float command_ignoretime;  | 
        
| 1 | pmbaty | 605 | GLOBAL float sound_playtime;  | 
        
| 606 | GLOBAL float highlight_endtime;  | 
        ||
| 607 | GLOBAL float current_pitch;  | 
        ||
| 608 | GLOBAL float current_yaw;  | 
        ||
| 609 | GLOBAL float current_distance;  | 
        ||
| 610 | GLOBAL int current_viewer;  | 
        ||
| 611 | GLOBAL handlestatus_t handlestatus[9]; // first slot unused  | 
        ||
| 612 | // dialog boxes and windows | 
        ||
| 613 | GLOBAL bool is_dialogbox_about_validated;  | 
        ||
| 614 | GLOBAL bool is_dialogbox_challenge_validated;  | 
        ||
| 615 | GLOBAL bool is_dialogbox_changeappearance_validated;  | 
        ||
| 616 | GLOBAL bool is_dialogbox_comment_validated;  | 
        ||
| 617 | GLOBAL bool is_dialogbox_endgame_validated;  | 
        ||
| 618 | GLOBAL bool is_dialogbox_gotomove_validated;  | 
        ||
| 619 | GLOBAL bool is_dialogbox_load_validated;  | 
        ||
| 620 | GLOBAL bool is_dialogbox_message_validated;  | 
        ||
| 621 | GLOBAL bool is_dialogbox_newgame_validated;  | 
        ||
| 622 | GLOBAL bool is_dialogbox_options_validated;  | 
        ||
| 623 | GLOBAL bool is_dialogbox_pawnpromotion_validated;  | 
        ||
| 624 | GLOBAL bool is_dialogbox_playercard_validated;  | 
        ||
| 625 | GLOBAL bool is_dialogbox_playerinfoname_validated;  | 
        ||
| 626 | GLOBAL bool is_dialogbox_quit_validated;  | 
        ||
| 627 | GLOBAL bool is_dialogbox_resign_validated;  | 
        ||
| 628 | GLOBAL bool is_dialogbox_save_validated;  | 
        ||
| 629 | GLOBAL bool is_dialogbox_saveposition_validated;  | 
        ||
| 630 | GLOBAL bool is_dialogbox_sendchallenge_validated;  | 
        ||
| 631 | GLOBAL bool is_dialogbox_sendseek_validated;  | 
        ||
| 632 | GLOBAL bool is_dialogbox_takeback_validated;  | 
        ||
| 633 | GLOBAL bool is_window_chat_validated;  | 
        ||
| 634 | GLOBAL bool is_window_chatterchannels_validated;  | 
        ||
| 635 | GLOBAL bool is_window_games_validated;  | 
        ||
| 636 | GLOBAL bool is_window_motd_validated;  | 
        ||
| 637 | GLOBAL bool is_window_opponents_validated;  | 
        ||
| 638 | GLOBAL bool is_window_sought_validated;  | 
        ||
| 639 | // themes | 
        ||
| 640 | GLOBAL theme_t *themes; // mallocated, slot 0 must always be valid (default theme)  | 
        ||
| 641 | GLOBAL int theme_count;  | 
        ||
| 642 | GLOBAL theme_t *theme; // pointer to current theme  | 
        ||
| 643 | GLOBAL wchar_t wantedtheme_name[64];  | 
        ||
| 644 | GLOBAL bool want_grid;  | 
        ||
| 645 | GLOBAL bool want_flaticons;  | 
        ||
| 646 | GLOBAL bool want_custombackground;  | 
        ||
| 647 | GLOBAL wchar_t custombackground_pathname[MAX_PATH];  | 
        ||
| 648 | GLOBAL backgroundsprite_t custombg; | 
        ||
| 649 | // main objects | 
        ||
| 650 | GLOBAL options_t options; | 
        ||
| 651 | GLOBAL board_t the_board; | 
        ||
| 652 | GLOBAL scene_t the_scene; | 
        ||
| 59 | pmbaty | 653 | // languages | 
        
| 654 | GLOBAL language_t *languages; // mallocated  | 
        ||
| 655 | GLOBAL int language_count;  | 
        ||
| 1 | pmbaty | 656 | // online stuff | 
        
| 657 | GLOBAL wchar_t server_motd[USHRT_MAX];  | 
        ||
| 658 | GLOBAL onlineplayer_t *onlineplayers; // mallocated  | 
        ||
| 659 | GLOBAL int onlineplayer_count; // -1 means "reply not arrived"  | 
        ||
| 660 | GLOBAL bool onlineplayers_updated; // TRUE when display is to be updated  | 
        ||
| 661 | GLOBAL float lastonlineplayers_time; // date at which the last update was received  | 
        ||
| 662 | GLOBAL soughtgame_t *soughtgames; // mallocated  | 
        ||
| 663 | GLOBAL int soughtgame_count; // -1 means "reply not arrived"  | 
        ||
| 664 | GLOBAL bool soughtgames_updated; // TRUE when display is to be updated  | 
        ||
| 665 | GLOBAL float lastsought_time; // date at which the last update was received  | 
        ||
| 666 | GLOBAL chatterchannel_t *chatterchannels; // mallocated  | 
        ||
| 667 | GLOBAL int chatterchannel_count; // -1 means "reply not arrived"  | 
        ||
| 668 | GLOBAL chatterchannel_t *selected_chatterchannel;  | 
        ||
| 669 | GLOBAL bool chatterchannels_updated;  | 
        ||
| 670 | GLOBAL interlocutor_t *interlocutors; // mallocated  | 
        ||
| 671 | GLOBAL int interlocutor_count;  | 
        ||
| 672 | GLOBAL playercard_t *playercards; // mallocated  | 
        ||
| 673 | GLOBAL int playercard_count;  | 
        ||
| 674 | GLOBAL challenge_t *challenges; // mallocated  | 
        ||
| 675 | GLOBAL int challenge_count;  | 
        ||
| 676 | // smilies | 
        ||
| 677 | GLOBAL smiley_t *smilies; // mallocated  | 
        ||
| 678 | GLOBAL int smiley_count;  | 
        ||
| 679 | // PGN games | 
        ||
| 680 | GLOBAL pgngame_t *games; // mallocated  | 
        ||
| 681 | GLOBAL int game_count;  | 
        ||
| 682 | // fonts | 
        ||
| 683 | GLOBAL int players_fontindex;  | 
        ||
| 684 | GLOBAL int centermsg_fontindex;  | 
        ||
| 685 | GLOBAL int chat_fontindex;  | 
        ||
| 686 | GLOBAL int arrow_fontindex;  | 
        ||
| 687 | GLOBAL HFONT hFontChat; | 
        ||
| 688 | // sprites | 
        ||
| 689 | GLOBAL int larrow_spriteindex;  | 
        ||
| 690 | GLOBAL int rarrow_spriteindex;  | 
        ||
| 691 | GLOBAL int chatbutton_spriteindex;  | 
        ||
| 692 | GLOBAL int gamesbutton_spriteindex;  | 
        ||
| 693 | GLOBAL int peoplebutton_spriteindex;  | 
        ||
| 694 | GLOBAL int sepia_spriteindex;  | 
        ||
| 695 | GLOBAL int spinner_spriteindex[12];  | 
        ||
| 696 | // debug logging facilities | 
        ||
| 697 | GLOBAL wchar_t logfile_pathname[MAX_PATH];  | 
        ||
| 698 | |||
| 699 | |||
| 700 | // function prototypes | 
        ||
| 701 | #include "prototypes.h" | 
        ||
| 702 | |||
| 703 | |||
| 704 | #endif // COMMON_H |