Subversion Repositories Games.Chess Giants

Rev

Rev 81 | Rev 116 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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