// common.h
 
 
 
#ifndef COMMON_H
 
#define COMMON_H
 
 
 
 
 
// standard includes
 
#include <windows.h>
 
#include <windowsx.h>
 
#include <wininet.h>
 
#include <commctrl.h>
 
#include <richedit.h>
 
#include <stdio.h>
 
#include <stdint.h>
 
#include <io.h>
 
#include <malloc.h>
 
#include <math.h>
 
#include <time.h>
 
#include <share.h>
 
#include <shlwapi.h>
 
#pragma warning(disable:4091)
 
#include <shlobj.h>
 
#pragma warning(default:4091)
 
#include <process.h>
 
#include <sys/stat.h>
 
 
 
 
 
// project resources includes
 
#include "resource/resource.h"
 
 
 
 
 
// link with specific libraries
 
#pragma comment (lib, "comctl32.lib") // for ImageList_*()
 
#pragma comment (lib, "winmm.lib") // for PlaySound()
 
#pragma comment (lib, "ws2_32.lib") // for network
 
 
 
 
 
// global preprocessor defines
 
#include "defines.h"
 
 
 
 
 
// modeless message box definition
 
typedef struct messagebox_s
 
{
 
   HWND hWndParent; // message box parent window
 
   wchar_t title[128]; // message box title
 
   wchar_t text[4096]; // message box text
 
   int flags; // message box flags (such as MB_OK, MB_ICONEXCLAMATION, etc...)
 
} messagebox_t;
 
 
 
 
 
// resizeable buffer structure type definition
 
typedef struct buffer_s
 
{
 
   char *data; // buffer data, mallocated
 
   unsigned long size; // buffer size in bytes
 
} buffer_t;
 
 
 
 
 
// part color theme data definition
 
typedef struct partcolor_s
 
{
 
   int texture; // index of the texture used for the pieces in this theme
 
   int material; // index of the material used for the pieces in this theme
 
} partcolor_t;
 
 
 
 
 
// background sprite definition
 
typedef struct backgroundsprite_s
 
{
 
   int sprite_index; // index of the sprite used as the background in this theme
 
   int sprite_width; // nominal width of bg sprite in pixels, rounded to the nearest higher power of 2
 
   int sprite_height; // nominal height of bg sprite in pixels, rounded to the nearest higher power of 2
 
} backgroundsprite_t;
 
 
 
 
 
// light definition
 
typedef struct light_s
 
{
 
   int type; // one of LIGHT_DIRECTIONAL, LIGHT_POINT, or LIGHT_SPOT
 
   unsigned long color; // diffuse color (RGBA)
 
   float pos_x; // X position in space
 
   float pos_y; // Y position in space
 
   float pos_z; // Z position in space
 
   float direction_x; // X direction in space
 
   float direction_y; // Y direction in space
 
   float direction_z; // Z direction in space
 
   float range; // distance after which the light won't be computed
 
   float attenuation_constant; // constant light attenuation
 
   float attenuation_proportional; // light attenuation that is proportional to distance
 
   float attenuation_square; // light attenuation that is proportional to distance squared
 
   float cone_inner; // inner cone angle, in degrees
 
   float cone_outer; // outer cone angle, in degrees
 
} light_t;
 
 
 
 
 
// definition for the scene illumination
 
typedef struct illumination_s
 
{
 
   unsigned long ambient_light; // scene ambient light color (RGBA)
 
   light_t *lights; // mallocated array of lights to render
 
   int light_count; // size of the lights array
 
} illumination_t;
 
 
 
 
 
// theme definition
 
typedef struct theme_s
 
{
 
   bool is_loaded; // set to TRUE when this theme is fully loaded
 
   int load_index; // when loading asynchronously, index of the item to load for each pass
 
 
 
   wchar_t name[64]; // theme name (folder name)
 
   wchar_t *description; // theme description or credits (mallocated)
 
   backgroundsprite_t bg; // background sprite structure
 
   illumination_t illum; // scene lights
 
   int board_texture; // index of the texture used for the chess grid in this theme
 
   int table_texture; // index of the texture used for the rest of the table in this theme
 
   int grid_texture; // index of the texture used for the board grid numbers and letters
 
   int trim_texture; // index of the texture used for the table/board delimiter
 
   int board_material; // index of the material used for the chess grid in this theme
 
   int table_material; // index of the material used for the rest of the table in this theme
 
   int trim_material; // index of the material used for the table/board delimiter
 
   unsigned char reflection_alpha; // table reflection alpha from 0 to 255 (high for marble, low for wood)
 
   partcolor_t part_colors[2]; // part theme data for the two colors, COLOR_BLACK and COLOR_WHITE
 
 
 
   // meshes
 
   int board_meshindex;
 
   int table_meshindex;
 
   int trim_meshindex;
 
   int tile_meshindex;
 
   int part_meshes[7]; // first slot unused
 
   // textures
 
   int shadow_textureindex;
 
   int hovered_textureindex;
 
   int check_textureindex;
 
   int threat_textureindex;
 
   int lastmovesource_textureindex;
 
   int lastmovetarget_textureindex;
 
   int selected_textureindex;
 
   int possiblemove_textureindex;
 
   int takeable_textureindex;
 
   int flattextures[2][7]; // [color][part], with first slot of the 7 unused
 
   // sprites
 
   int flatsprites[2][7]; // [color][part], with first slot of the 7 unused
 
   int lastmovesource_spriteindex;
 
   int lastmovetarget_spriteindex;
 
} theme_t;
 
 
 
 
 
// local typedefs
 
typedef struct pgngame_s
 
{
 
   wchar_t event_str[64]; // [Event "blah"]
 
   wchar_t site_str[64]; // [Site "blah"]
 
   wchar_t date_str[16]; // [Date "YYYY.MM.DD"]
 
   wchar_t round_str[16]; // [Round "N"]
 
   wchar_t white_str[64]; // [White "blah"]
 
   wchar_t black_str[64]; // [Black "blah"]
 
   wchar_t result_str[16]; // [Result "blah"]
 
   wchar_t eco_str[8]; // [ECO "XNN"] <-- this tag is optional, but useful nevertheless
 
   wchar_t fen_str[128]; // [FEN "start pos"] <-- this tag is optional, but VERY useful
 
   int gamedata_start; // offset at which the game data begins for this entry
 
} pgngame_t;
 
 
 
 
 
// player definition
 
typedef struct player_s
 
{
 
   // common data
 
   int type; // PLAYER_COMPUTER, PLAYER_INTERNET or PLAYER_HUMAN
 
   char color; // either COLOR_BLACK, COLOR_WHITE or COLOR_UNSPECIFIED
 
   wchar_t name[64]; // player name (machine name if human vs human or human vs cpu, login if human vs network)
 
   float view_pitch; // current view pitch (vertical axis orientation towards the table center)
 
   float view_yaw; // current view yaw (horizontal axis orientation towards the table center)
 
   float view_distance; // current view distance to the table center
 
   float custom_pitch; // user-saved view pitch
 
   float custom_yaw; // user-saved view yaw
 
   float custom_distance; // user-saved view distance
 
   bool wants_cancel; // set to TRUE when this player wants to cancel its last move
 
 
 
   // PLAYER_HUMAN related data
 
 
 
   // PLAYER_COMPUTER related data
 
   bool wants_hint;
 
 
 
   // PLAYER_INTERNET related data
 
   int our_socket;
 
   bool is_connected;
 
   bool is_logged_in;
 
   bool is_in_game;
 
   int game_number;
 
   int remaining_seconds;
 
 
 
   // PLAYER_COMPUTER and PLAYER_INTERNET related data
 
   bool sendbuffer_locked; // set to TRUE if a thread currently locks the send buffer
 
   wchar_t *sendbuffer; // used both for PLAYER_COMPUTER and PLAYER_INTERNET, mallocated
 
   int sendbuffer_size; // size of the sendbuffer buffer
 
   char *ascii_recvbuffer; // mallocated
 
   wchar_t *recvbuffer; // used both for PLAYER_COMPUTER and PLAYER_INTERNET, mallocated
 
   int recvbuffer_size; // size of the recvbuffer buffer
 
 
 
} player_t;
 
 
 
 
 
// definitions for a grid slot, a board side and a chess board
 
typedef struct boardslot_s
 
{
 
   unsigned char part; // part ID of the part occupying this slot, or PART_NONE if not occupied
 
   unsigned char color; // color ID of the part occupying this slot (either COLOR_WHITE or COLOR_BLACK)
 
   unsigned char flags; // bitmap of slot flags (e.g: selected, move allowed, etc)
 
} boardslot_t;
 
 
 
 
 
typedef struct boardside_s
 
{
 
   unsigned char *takenparts; // mallocated array of part IDs that this side has captured from the opposing side
 
   int takenpart_count; // size of the takenparts array
 
   bool shortcastle_allowed; // set to TRUE if this side's king can still castle to G (column id 6)
 
   bool longcastle_allowed; // set to TRUE if this side's king can still castle queenside, to C (column id 3)
 
} boardside_t;
 
 
 
 
 
typedef struct boardmove_s
 
{
 
   char color; // color this board move was for (either COLOR_UNSPECIFIED, COLOR_BLACK or COLOR_WHITE)
 
   char part; // board move part type (to handle promotions)
 
   char promotion_type; // in case of a pawn promotion, the new part's type
 
   bool has_captured; // set to TRUE if this part has just captured another part
 
   bool is_enpassant; // set to TRUE if the move was an "en passant" capture move
 
   bool is_check; // set to TRUE if this move puts the opponent's king to check
 
   bool is_stalemate; // set to TRUE if this move puts the opponent to stalemate
 
   char source[2]; // this chess board's move source position ([line][column] array)
 
   char target[2]; // this chess board's move target position ([line][column] array)
 
   wchar_t pgntext[16]; // move PGN text
 
   wchar_t *comment; // comment about that move (mallocated)
 
   int comment_size; // size of the mallocated space used for comments, *IN WCHARS*
 
   boardside_t sides[2]; // game state data structure for both opposing sides (COLOR_BLACK and COLOR_WHITE) after move is made
 
   boardslot_t slots[8][8]; // this chess board's slots (8x8 array) after move is made
 
   wchar_t fen_string[128]; // FEN string describing that move
 
} boardmove_t;
 
 
 
 
 
typedef struct board_s
 
{
 
   bool was_setup; // set to TRUE when the board has just been set up
 
   int hovered_position[2]; // this chess board's hovered position ([line][column] array)
 
   int selected_position[2]; // this chess board's selected position ([line][column] array)
 
   boardmove_t *moves; // array of moves describing the game (mallocated)
 
   int move_count; // amount of moves in this game so far
 
   int viewed_move; // index of the move currently viewed (for watching game history)
 
   player_t players[2]; // game state data structure for both opposing sides (COLOR_BLACK and COLOR_WHITE)
 
   bool has_playerchanged; // set to TRUE when the current player has just changed
 
   bool want_playerswap; // set to TRUE when a players swap is requested
 
   int game_state; // one of the STATE_XXX #defines that describe the game and victory state
 
   float lastmove_time; // date of last move
 
   bool reevaluate; // set to TRUE if the game state should be reevaluated
 
} board_t;
 
 
 
 
 
// scene object definition
 
typedef struct sceneobject_s
 
{
 
   int mesh_index; // object mesh index
 
   int texture_index; // object texture index
 
   int material_index; // object material index
 
   float scale; // object scale, 1.0f = default size
 
   float simpleshadow_size; // multiplier for the size of the original texture
 
   float x; // X position in space
 
   float y; // Y position in space
 
   float z; // Z position in space
 
   float pitch; // object pitch in degrees (leaning left/right)
 
   float yaw; // object yaw in degrees (turning left/right)
 
} sceneobject_t;
 
 
 
 
 
// chatter channel reply
 
typedef struct ccreply_s
 
{
 
   float arrival_time; // date at which this reply arrived
 
   unsigned long color; // text color (RGBA)
 
   wchar_t channelname[64]; // id of the channel this message is sent on
 
   wchar_t nickname[32]; // sender's nickname
 
   wchar_t *text; // message text (mallocated)
 
   int text_length; // length of the above text, in characters, NOT including the null terminator
 
} ccreply_t;
 
 
 
 
 
// user interface button definition
 
typedef struct guibutton_s
 
{
 
   int state; // render state: 0 = invisible, 1 = enabled, 2 = hovered
 
   float left; // position of the top left corner, in percentage of screen width
 
   float top; // position of the top left corner, in percentage of screen height
 
   float width; // button tile width, in percentage of screen width
 
   float height; // button tile height, in percentage of screen height
 
   int sprite_index; // index of the sprite this button displays
 
} guibutton_t;
 
 
 
 
 
// user interface text field definition
 
typedef struct guitext_s
 
{
 
   bool is_displayed; // set to TRUE if this text is displayed
 
   float xpos_percent; // text's X position, in percents from left to right
 
   float ypos_percent; // text's Y position, in percents from top to bottom
 
   float maxwidth_percent; // text's max width before word wrapping, in percents of draw area width
 
   int horizontal_align; // bounding rectangle's horizontal alignment regarding the X position (one of the ALIGN_xxx defines)
 
   int vertical_align; // bounding rectangle's vertical alignment regarding the Y position (one of the ALIGN_xxx defines)
 
   int text_align; // text's horizontal alignment inside that bounding rectangle
 
   int font_index; // index of the font with which to display this text
 
   unsigned long color; // text's color (RGBA)
 
   wchar_t *buffer; // text printed in this area of the screen (mallocated)
 
   int buffer_size; // size of the text buffer
 
   float appear_time; // date at which this text was put
 
   float disappear_time; // date at which this text should disappear
 
   bool want_fade; // set to TRUE if this text is to be faded in and out
 
} guitext_t;
 
 
 
 
 
// game user interface definition
 
typedef struct gui_s
 
{
 
   // IMPORTANT: ensure all guitext_t buffers are freed in Scene_Shutdown()
 
 
 
   guibutton_t larrow; // render state: 0 = invisible, 1 = enabled, 2 = hovered
 
   guibutton_t rarrow; // render state: 0 = invisible, 1 = enabled, 2 = hovered
 
   guitext_t arrow_text; // usually, viewed move number versus the total of moves
 
   guibutton_t chatbutton; // render state: 0 = invisible, 1 = enabled, 2 = hovered
 
   guibutton_t gamesbutton; // render state: 0 = invisible, 1 = enabled, 2 = hovered
 
   guibutton_t peoplebutton; // render state: 0 = invisible, 1 = enabled, 2 = hovered
 
   guitext_t comment_text; // text printed in the comments area
 
   guitext_t history_text; // text printed in the moves text area
 
   guitext_t clock_text; // text printed in the game clock area
 
   guitext_t turn_text; // text printed in the "X moves" area
 
   guitext_t central_text; // text printed in the center of the screen
 
   ccreply_t *cchistory; // mallocated array of chatter channel replies
 
   int cchistory_count; // number of elements in the above array
 
   bool is_entering_text; // set to TRUE if player is entering text
 
   ccreply_t entered_ccreply; // text that is currently being entered
 
   bool is_partspick_displayed; // set to TRUE if the parts pick line is displayed
 
   bool want_spinwheel; // set to TRUE to display a spinning wheel
 
   char partspick_hoveredpart; // one of "PRNBQK kqbnrp"
 
   char partspick_selectedpart; // one of "PRNBQK kqbnrp"
 
} gui_t;
 
 
 
 
 
// rendering scene definition
 
typedef struct scene_s
 
{
 
   int background_spriteindex; // index of the background sprite (-1 if none)
 
   sceneobject_t *objects; // mallocated array of objects to render
 
   int object_count; // size of the objects array
 
   int overlay_spriteindex; // index of the overlay sprite (-1 if none)
 
   gui_t gui; // GUI laid over this scene
 
   bool update; // set to TRUE if the scene needs to be updated
 
} scene_t;
 
 
 
 
 
// engine program options definition (populated from "engines/<program>/engine.ini")
 
typedef struct engineprogram_s
 
{
 
   wchar_t folder[MAX_PATH]; // chess engine folder name
 
   wchar_t name[64]; // chess engine name (will be used as player name)
 
   wchar_t cmdline[MAX_PATH]; // chess engine binary startup command-line, e.g "gnuchess.exe"
 
   wchar_t replystring_move[64]; // chess engine reply string for a move (positions come right after)
 
   wchar_t command_new[64]; // command to send the chess engine to tell him we are starting a new game
 
   wchar_t command_setboard[64]; // command to send the chess engine to tell him to set the table in a particular way (FEN notation)
 
   wchar_t command_sd[64]; // command to send the chess engine to instruct it about its allowed depth (will be followed by numeric)
 
   wchar_t command_go[64]; // command to send the chess engine to make it play the current move
 
   wchar_t command_move[64]; // command to send the chess engine to instruct it that its opponent played a particular move
 
   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
 
   wchar_t command_quit[64]; // command to send the chess engine to make it exit cleanly
 
} engineprogram_t;
 
 
 
 
 
// engine options definition
 
typedef struct engineoptions_s
 
{
 
   int depth; // chess engine's currently allowed search depth
 
   int max_depth; // chess engine maximum search depth (used just for slider display)
 
   int blunder_chances; // chess engine blunder chances, in percent
 
   int obstinacy_level; // chess engine obstinacy level, in number of moves
 
   bool is_expert_mode; // set to TRUE if this player claims to be an expert player (in the game settings)
 
   engineprogram_t *programs; // engine programs
 
   int program_count; // size of the engines array
 
   int selected_program; // index of the selected engine
 
} engineoptions_t;
 
 
 
 
 
// network options definition
 
typedef struct networkoptions_s
 
{
 
   wchar_t server_address[MAX_PATH]; // chess server URL for online gaming
 
   int server_port; // chess server listen port (usually 5000) for online gaming
 
   wchar_t login[32]; // login for online gaming
 
   wchar_t password[32]; // password for online gaming
 
   bool want_servermessages; // set to TRUE if server messages are to be displayed (MOTD, RoboAdmin messages, announcements)
 
   bool want_publicchat; // set to TRUE if public chat messages and chatter channels list are to be displayed
 
   bool want_motdonconnect; // set to TRUE if the MOTD is to be displayed when connecting to the chess server
 
} networkoptions_t;
 
 
 
 
 
// registration options definition
 
typedef struct registrationoptions_s
 
{
 
   wchar_t user_email[MAX_PATH]; // registered user's email address
 
   unsigned __int32 activation_code; // registered user's activation code (a 32-bit integer)
 
} registrationoptions_t;
 
 
 
 
 
// game options definition
 
typedef struct options_s
 
{
 
   bool want_fullscreen; // set to TRUE to run in fullscreen mode
 
   int window_width; // window width when not in fullscreen mode
 
   int window_height; // window height when not in fullscreen mode
 
   bool want_sounds; // set to TRUE to enable sounds
 
   bool want_animations; // set to TRUE to enable part animations
 
   bool want_possiblemoves; // set to TRUE to show possible moves
 
   bool want_lastmove; // set to TRUE to show the last move
 
   bool want_threats; // set to TRUE to display king's threats
 
   bool want_autorotateon1vs1; // set to TRUE to enable board auto-rotation when playing human vs human locally
 
   bool want_takenparts; // set to TRUE to display the taken parts on the side of the board
 
   bool want_turn; // set to TRUE to display the current turn
 
   bool want_clock; // set to TRUE to display a game clock
 
   unsigned long clock_color; // RGBA color of the game clock
 
   bool want_history; // set to TRUE to enable the display of game history
 
   unsigned long history_color; // RGBA color of the game history
 
   bool want_sepiafilter; // set to TRUE to enable the sepia filter when displaying past moves
 
   bool want_filtering; // set to TRUE to enable texture filtering
 
   bool want_hiquality; // set to TRUE to enable maximum possible quality filtering
 
   bool want_reflections; // set to TRUE to enable part reflections
 
   bool want_specularlighting; // set to TRUE to enable specular lighting
 
   int rotate_speed; // board rotation speed
 
   registrationoptions_t registration; // registration options
 
   engineoptions_t engine; // engine options
 
   networkoptions_t network; // network options
 
} options_t;
 
 
 
 
 
// online player definition
 
typedef struct onlineplayer_s
 
{
 
   int rating; // player rating (ELO estimate)
 
   unsigned char ratingtype; // either one of RATING_xxx (default, estimated or provisional)
 
   unsigned char handlestatus; // either one of HANDLESTATUS_xxx values
 
   wchar_t nickname[32]; // this player's nickname
 
   unsigned short handlecodes; // bitmap: one or several of HANDLECODE_xxx flag
 
} onlineplayer_t;
 
 
 
 
 
// chatter channel member definition
 
typedef struct chatterchannelmember_s
 
{
 
   bool is_silenced; // set to TRUE if this player plays in silence
 
   wchar_t nickname[32]; // this player's nickname
 
} chatterchannelmember_t;
 
 
 
 
 
// chatter channel definition
 
typedef struct chatterchannel_s
 
{
 
   int id; // channel's numeric ID
 
   bool is_open; // set to TRUE if listening is currently enabled for this channel
 
   wchar_t theme[64]; // channel theme, as reported by the server
 
   unsigned long color; // channel text color (RGBA)
 
   chatterchannelmember_t *members; // mallocated array of members
 
   int member_count; // number of members in this channel
 
} chatterchannel_t;
 
 
 
 
 
// challenge definition
 
typedef struct challenge_s
 
{
 
   bool is_active; // set to TRUE if this challenge is active
 
   wchar_t challenger[32]; // challenger nickname
 
   HWND hWnd; // challenge window handle
 
   int challenger_level; // challenger level
 
   int color; // color this challenger wants to play
 
   bool is_rated; // whether this game is rated or not
 
   wchar_t game_type[32]; // game type, literally
 
   float initial_time; // initial time of the game for each color
 
   float increment; // eventual time increment (Fischer pace)
 
   bool update_dialog; // set to TRUE when the dialog window should be updated
 
} challenge_t;
 
 
 
 
 
// sought game definition
 
typedef struct soughtgame_s
 
{
 
   int id; // sought game ID
 
   int rating; // player rating (ELO estimate)
 
   wchar_t nickname[32]; // this player's nickname
 
   float initial_time; // initial time of the game for each color
 
   float increment; // eventual time increment (Fischer pace)
 
   unsigned char rating_type; // one of GAMERATINGTYPE_xxx #defines
 
   wchar_t game_type[32]; // game type, literally
 
   int color; // color this player will have
 
   int lowest_accepted; // lowest ELO accepted
 
   int highest_accepted; // highest ELO accepted
 
   bool manual_start; // set to TRUE if the game should start manually
 
   bool formula_checked; // set to TRUE if the filter formula will be used
 
} soughtgame_t;
 
 
 
 
 
// chat interlocutor
 
typedef struct interlocutor_s
 
{
 
   bool is_active; // set to TRUE if this interlocutor is active
 
   wchar_t nickname[32]; // interlocutor nickname (don't point to player list, because it changes...)
 
   HWND hWnd; // chat window handle
 
   int current_displaypicture; // current display picture index
 
   wchar_t *dialogtext; // mallocated wchar_t buffer of dialog text (beware: RTF is ASCII-only)
 
   int dialogtext_size; // size of the dialog text buffer, in WCHARs
 
   bool update_dialog; // set to TRUE when the dialog window should be updated
 
} interlocutor_t;
 
 
 
 
 
// game style ratings
 
typedef struct gamestylerating_s
 
{
 
   wchar_t name[32]; // game style name (e.g, "standard", "blitz", etc.)
 
   int rating; // ELO rating for this style of play
 
   float rd; // unknown data ???
 
   int win_count; // amount of won matches in this style of play
 
   int loss_count; // amount of lost matches in this style of play
 
   int draw_count; // amount of draw matches in this style of play
 
   int total_matches; // amount of played matches in this style of play (basically, sum of win + loss + draws)
 
} gamestylerating_t;
 
 
 
 
 
// player cards
 
typedef struct playercard_s
 
{
 
   bool is_active; // set to TRUE if this slot is active
 
   bool is_own; // set to TRUE if this card is the local player's one
 
   wchar_t nickname[32]; // interlocutor nickname (don't point to player list, because it changes...)
 
   HWND hWnd; // player card window handle
 
   bool got_reply; // set to TRUE when this player card slot got server reply (i.e, it contains actual data)
 
   bool doesnt_exist; // set to TRUE when the chess server reports that this player doesn't exist
 
   int minutes_online; // amount of minutes this player has been online
 
   int seconds_idle; // amount of seconds elapsed since this player's last activity
 
   unsigned char disconnection_day; // day of disconnection
 
   unsigned char disconnection_month; // month of disconnection
 
   unsigned short disconnection_year; // year of disconnection
 
   int game_played; // index of the game currently played by this player
 
   wchar_t game_name[64]; // name of the game currently played by this player
 
   wchar_t *fingertext; // mallocated wchar_t buffer of personal finger text
 
   int fingertext_length; // size of the finger text buffer, in WCHARs
 
   gamestylerating_t *gamestyleratings; // mallocated array of game styles for which this player is rated
 
   int gamestylerating_count; // amount of different game styles for which this player is rated
 
   bool update_dialog; // set to TRUE when the dialog window should be updated
 
} playercard_t;
 
 
 
 
 
// handle status pictures
 
typedef struct handlestatus_s
 
{
 
   HICON icon; // icon handle
 
   HBITMAP bitmap; // bitmap handle
 
   wchar_t *text; // pointer to the text string describing this status
 
} handlestatus_t;
 
 
 
 
 
// smilies
 
typedef struct smiley_s
 
{
 
   wchar_t name[32]; // smiley name
 
   wchar_t filename[MAX_PATH]; // filename of that smiley's PNG picture
 
   wchar_t *rtf_data; // smiley RTF data, mallocated
 
   int rtf_len; // length of the above data string (minus the null terminator)
 
} smiley_t;
 
 
 
 
 
// localized texts
 
typedef struct text_s
 
{
 
   wchar_t *id_string; // ID string for the given text (mallocated), example: "AboutBox_Title"
 
   wchar_t *localized_string; // localized string for the given text (mallocated), example: "A propos de ce logiciel"
 
} text_t;
 
 
 
 
 
// languages
 
typedef struct language_s
 
{
 
   wchar_t name[64]; // language name, e.g. "French", "English" or "Norwegian (norsk)"
 
   text_t *texts; // mallocated array of localized texts
 
   int text_count; // size of the texts array
 
} language_t;
 
 
 
 
 
// global declarations
 
#ifndef DEFINE_GLOBALS
 
#define GLOBAL extern
 
#else
 
#define GLOBAL
 
#endif
 
GLOBAL int language_id;
 
GLOBAL bool is_registered;
 
GLOBAL bool terminate_everything;
 
GLOBAL HINSTANCE hAppInstance;
 
GLOBAL wchar_t app_path[MAX_PATH];
 
GLOBAL wchar_t load_pathname[MAX_PATH];
 
GLOBAL wchar_t save_pathname[MAX_PATH];
 
GLOBAL HMENU hMainMenu;
 
GLOBAL HACCEL hMainAccelerators;
 
GLOBAL HWND hMainWnd;
 
GLOBAL HWND hChatterChannelsWnd;
 
GLOBAL HWND hGamesWnd;
 
GLOBAL HWND hMOTDWnd;
 
GLOBAL HWND hOpponentsWnd;
 
GLOBAL HWND hSoughtWnd;
 
GLOBAL messagebox_t messagebox;
 
GLOBAL bool want_framerate;
 
GLOBAL bool is_paused;
 
GLOBAL float current_time;
 
GLOBAL float stoppage_time;
 
GLOBAL float animation_endtime;
 
GLOBAL float command_ignoretime;
 
GLOBAL float sound_playtime;
 
GLOBAL float highlight_endtime;
 
GLOBAL float current_pitch;
 
GLOBAL float current_yaw;
 
GLOBAL float current_distance;
 
GLOBAL int current_viewer;
 
GLOBAL handlestatus_t handlestatus[9]; // first slot unused
 
// dialog boxes and windows
 
GLOBAL bool is_dialogbox_about_validated;
 
GLOBAL bool is_dialogbox_challenge_validated;
 
GLOBAL bool is_dialogbox_changeappearance_validated;
 
GLOBAL bool is_dialogbox_comment_validated;
 
GLOBAL bool is_dialogbox_endgame_validated;
 
GLOBAL bool is_dialogbox_gotomove_validated;
 
GLOBAL bool is_dialogbox_renamesides_validated;
 
GLOBAL bool is_dialogbox_load_validated;
 
GLOBAL bool is_dialogbox_message_validated;
 
GLOBAL bool is_dialogbox_newgame_validated;
 
GLOBAL bool is_dialogbox_options_validated;
 
GLOBAL bool is_dialogbox_pawnpromotion_validated;
 
GLOBAL bool is_dialogbox_playercard_validated;
 
GLOBAL bool is_dialogbox_playerinfoname_validated;
 
GLOBAL bool is_dialogbox_quit_validated;
 
GLOBAL bool is_dialogbox_resign_validated;
 
GLOBAL bool is_dialogbox_save_validated;
 
GLOBAL bool is_dialogbox_saveposition_validated;
 
GLOBAL bool is_dialogbox_sendchallenge_validated;
 
GLOBAL bool is_dialogbox_sendseek_validated;
 
GLOBAL bool is_dialogbox_takeback_validated;
 
GLOBAL bool is_window_chat_validated;
 
GLOBAL bool is_window_chatterchannels_validated;
 
GLOBAL bool is_window_games_validated;
 
GLOBAL bool is_window_motd_validated;
 
GLOBAL bool is_window_opponents_validated;
 
GLOBAL bool is_window_sought_validated;
 
// themes
 
GLOBAL theme_t *themes; // mallocated, slot 0 must always be valid (default theme)
 
GLOBAL int theme_count;
 
GLOBAL theme_t *theme; // pointer to current theme
 
GLOBAL wchar_t wantedtheme_name[64];
 
GLOBAL bool want_grid;
 
GLOBAL bool want_flaticons;
 
GLOBAL bool want_custombackground;
 
GLOBAL wchar_t custombackground_pathname[MAX_PATH];
 
GLOBAL backgroundsprite_t custombg;
 
// main objects
 
GLOBAL options_t options;
 
GLOBAL board_t the_board;
 
GLOBAL scene_t the_scene;
 
// languages
 
GLOBAL language_t *languages; // mallocated
 
GLOBAL int language_count;
 
// online stuff
 
GLOBAL wchar_t server_motd[USHRT_MAX];
 
GLOBAL onlineplayer_t *onlineplayers; // mallocated
 
GLOBAL int onlineplayer_count; // -1 means "reply not arrived"
 
GLOBAL bool onlineplayers_updated; // TRUE when display is to be updated
 
GLOBAL float lastonlineplayers_time; // date at which the last update was received
 
GLOBAL soughtgame_t *soughtgames; // mallocated
 
GLOBAL int soughtgame_count; // -1 means "reply not arrived"
 
GLOBAL bool soughtgames_updated; // TRUE when display is to be updated
 
GLOBAL float lastsought_time; // date at which the last update was received
 
GLOBAL chatterchannel_t *chatterchannels; // mallocated
 
GLOBAL int chatterchannel_count; // -1 means "reply not arrived"
 
GLOBAL chatterchannel_t *selected_chatterchannel;
 
GLOBAL bool chatterchannels_updated;
 
GLOBAL interlocutor_t *interlocutors; // mallocated
 
GLOBAL int interlocutor_count;
 
GLOBAL playercard_t *playercards; // mallocated
 
GLOBAL int playercard_count;
 
GLOBAL challenge_t *challenges; // mallocated
 
GLOBAL int challenge_count;
 
// smilies
 
GLOBAL smiley_t *smilies; // mallocated
 
GLOBAL int smiley_count;
 
// PGN games
 
GLOBAL pgngame_t *games; // mallocated
 
GLOBAL int game_count;
 
// fonts
 
GLOBAL int players_fontindex;
 
GLOBAL int centermsg_fontindex;
 
GLOBAL int chat_fontindex;
 
GLOBAL int arrow_fontindex;
 
GLOBAL HFONT hFontChat;
 
// sprites
 
GLOBAL int larrow_spriteindex;
 
GLOBAL int rarrow_spriteindex;
 
GLOBAL int chatbutton_spriteindex;
 
GLOBAL int gamesbutton_spriteindex;
 
GLOBAL int peoplebutton_spriteindex;
 
GLOBAL int sepia_spriteindex;
 
GLOBAL int spinner_spriteindex[12];
 
// debug logging facilities
 
GLOBAL wchar_t logfile_pathname[MAX_PATH];
 
 
 
 
 
// function prototypes
 
#include "prototypes.h"
 
 
 
 
 
#endif // COMMON_H