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