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