// prototypes.h
#ifndef PROTOTYPES_H
#define PROTOTYPES_H
// audio.cpp function prototypes
bool Audio_Init (void);
void Audio_Shutdown (void);
void Audio_Think (void);
void Audio_PlaySound (int sound_type, float pos_x, float pos_y, float pos_z);
#define Audio_PlaySoundAtCenter(soundtype) Audio_PlaySound ((soundtype), 0.0f, 0.0f, 0.04f)
#define Audio_PlaySoundAtSlot(soundtype,line,column) Audio_PlaySound ((soundtype), 17.5f - (7 - (column)) * 5.0f, 17.5f - (line) * 5.0f, 0.04f)
// base64.cpp function prototypes
size_t base64_encode (char *dest, const char *source, size_t source_len);
size_t base64_decode (unsigned char *dest, const unsigned char *source, size_t source_len);
// board.cpp function prototypes
bool Board_Init (board_t *board, int white_playertype, int black_playertype, wchar_t *game_rules, wchar_t *fen_string);
void Board_Shutdown (board_t *board);
bool Board_Reset (board_t *board, wchar_t *fen_string);
bool Board_Think (board_t *board);
void Board_SwapSides (board_t *board);
void Board_EnterSetupPosition (board_t *board);
void Board_SetSelectedAndHovered (board_t *board, int selected_line, int selected_column, int hovered_line, int hovered_column);
char Board_ColorToMove (board_t *board);
void Board_AppendMove (board_t *board, int from_line, int from_column, int to_line, int to_column, char promotion_type, wchar_t *comment);
// buffer.cpp function prototypes
void Buffer_Initialize (buffer_t *buffer);
void Buffer_Forget (buffer_t *buffer);
int Buffer_Append (buffer_t *buffer, char *data, unsigned long data_size);
#define Buffer_AppendCString(buffer,string_data) Buffer_Append ((buffer), (string_data), strlen (string_data))
#define Buffer_AppendCharArray(buffer,char_array) Buffer_Append ((buffer), (char_array), sizeof (char_array) - 1)
#define Buffer_AppendBuffer(buffer,appendable) Buffer_Append ((buffer), (appendable)->data, (appendable)->size)
int Buffer_Prepend (buffer_t *buffer, char *data, unsigned long data_size);
#define Buffer_PrependCString(buffer,string_data) Buffer_Prepend ((buffer), (string_data), strlen (string_data))
#define Buffer_PrependCharArray(buffer,char_array) Buffer_Prepend ((buffer), (char_array), sizeof (char_array) - 1)
#define Buffer_PrependBuffer(buffer,prependable) Buffer_Prepend ((buffer), (prependable)->data, (prependable)->size)
int Buffer_WriteAt (buffer_t *buffer, unsigned long write_index, char *data, unsigned long data_size);
int Buffer_ReadFromFile (buffer_t *buffer, const char *file_pathname);
int Buffer_ReadFromFileW (buffer_t *buffer, const wchar_t *file_pathname);
int Buffer_WriteToFile (buffer_t *buffer, const char *file_pathname);
int Buffer_WriteToFileW (buffer_t *buffer, const wchar_t *file_pathname);
char *Buffer_Find (buffer_t *buffer, char *needle, unsigned long needle_length);
int Buffer_Compare (buffer_t *buffer1, buffer_t *buffer2);
unsigned long Buffer_OffsetOf (buffer_t *buffer, void *something);
// challenge.cpp function prototypes
void Challenges_Init (void);
void Challenges_Shutdown (void);
challenge_t *Challenge_FindOrCreate (const wchar_t *nickname);
challenge_t *Challenge_Find (const wchar_t *nickname);
void Challenge_UpdateData (challenge_t *challenge, challenge_t *new_challenge);
// chessengine.cpp function prototypes
bool PlayerEngine_Init (player_t *player);
void PlayerEngine_Shutdown (player_t *player);
bool PlayerEngine_Think (player_t *player);
// config.cpp function prototypes
void Config_Load (void);
void Config_LoadEngines (void);
void Config_Save (void);
// fenfile.cpp function prototypes
bool FENFile_Load (const wchar_t *fenfile_pathname, wchar_t *fen_string, int fenstring_maxsize);
bool FENFile_Save (const wchar_t *fenfile_pathname, wchar_t *fen_string);
// hyperlinks.cpp function prototypes
void ConvertStaticToHyperlink (HWND hWndStatic);
// inifile.cpp function prototypes
void *INIFile_NewINIFile (void);
int INIFile_GetNumberOfSections (void *ini_data);
wchar_t *INIFile_GetSectionName (void *ini_data, int section_index);
int INIFile_GetNumberOfEntries (void *ini_data, wchar_t *section);
wchar_t *INIFile_GetEntryName (void *ini_data, wchar_t *section, int entry_index);
unsigned char INIFile_ReadEntryAsBool (void *ini_data, wchar_t *section, wchar_t *entry, unsigned char default_value);
long INIFile_ReadEntryAsLong (void *ini_data, wchar_t *section, wchar_t *entry, long default_value);
unsigned long INIFile_ReadEntryAsUnsignedLong (void *ini_data, wchar_t *section, wchar_t *entry, unsigned long default_value);
double INIFile_ReadEntryAsDouble (void *ini_data, wchar_t *section, wchar_t *entry, double default_value);
wchar_t *INIFile_ReadEntryAsString (void *ini_data, wchar_t *section, wchar_t *entry, wchar_t *default_value);
void INIFile_WriteEntryAsBool (void *ini_data, wchar_t *section, wchar_t *entry, unsigned char value);
void INIFile_WriteEntryAsLong (void *ini_data, wchar_t *section, wchar_t *entry, long value);
void INIFile_WriteEntryAsUnsignedLong (void *ini_data, wchar_t *section, wchar_t *entry, unsigned long value);
void INIFile_WriteEntryAsDouble (void *ini_data, wchar_t *section, wchar_t *entry, double value);
void INIFile_WriteEntryAsString (void *ini_data, wchar_t *section, wchar_t *entry, wchar_t *value);
void INIFile_DeleteEntry (void *ini_data, wchar_t *section, wchar_t *entry);
void INIFile_DeleteSection (void *ini_data, wchar_t *section);
void *INIFile_LoadINIFile (const wchar_t *filename);
unsigned char INIFile_SaveINIFile (const wchar_t *filename, void *ini_data);
void INIFile_FreeINIFile (void *ini_data);
// interlocutor.cpp function prototypes
void Interlocutors_Init (void);
void Interlocutors_Shutdown (void);
interlocutor_t *Interlocutor_FindOrCreate (const wchar_t *nickname);
interlocutor_t *Interlocutor_FindByWindowHandle (HWND window_handle);
void Interlocutor_Chat (interlocutor_t *interlocutor, const wchar_t *sender, bool is_localsender, const wchar_t *message);
void Interlocutor_Notify (interlocutor_t *interlocutor, const wchar_t *fmt, ...);
// localizedtexts.cpp function prototypes
void LocalizedTexts_Init (void);
void LocalizedTexts_Shutdown (void);
wchar_t *LocalizedTexts_GetLocalizedTextFor (wchar_t *id_string);
// move.cpp function prototypes
void Move_SetSlot (boardmove_t *move, int line, int column, int color, int part_type);
bool Move_IsKingThreatenedAtLocation (boardmove_t *move, int color, int at_line, int at_column, int *threat_line, int *threat_column);
bool Move_IsCheck (boardmove_t *move, int color);
bool Move_IsStaleMate (boardmove_t *move, int color);
bool Move_IsMoveValid (boardmove_t *move, int from_line, int from_column, int to_line, int to_column);
bool Move_FindRandomMove (boardmove_t *move, int color, boardmove_t *random_move);
int Move_CountPartsByColorAndType (boardmove_t *move, int color, int part_type);
bool Move_IsColorInCheckAfterTestMove (boardmove_t *move, int source_line, int source_column, int target_line, int target_column, int color);
bool Move_IsColorInCheckAfterTestMoveEP (boardmove_t *move, int source_line, int source_column, int target_line, int target_column, int clear_line, int clear_column, int color);
void Move_DescribeInFEN (boardmove_t *move);
bool Move_SetupFromFEN (boardmove_t *move, wchar_t *fen_string);
bool Move_SetupFromStyle12 (boardmove_t *move, wchar_t *positions, int move_color, int pawnrush_column,
bool can_white_castle_short, bool can_white_castle_long, bool can_black_castle_short, bool can_black_castle_long, wchar_t *pretty_movestring);
// network.cpp function prototypes
bool PlayerNetwork_Init (player_t *player);
void PlayerNetwork_Shutdown (player_t *player);
bool PlayerNetwork_Think (player_t *player);
// network-eval.cpp function prototypes
void EvaluateServerReply_MOTD (player_t *player);
void EvaluateServerReply_Seek (player_t *player);
void EvaluateServerReply_Challenge (player_t *player);
void EvaluateServerReply_Finger (player_t *player);
void EvaluateServerReply_PrivateMessage (player_t *player);
void EvaluateServerReply_ChallengeAccepted (player_t *player);
void EvaluateServerReply_ChallengeDeclined (player_t *player);
void EvaluateServerReply_Takeback (player_t *player);
void EvaluateServerReply_TakebackDeclinedByOther (player_t *player);
void EvaluateServerReply_TakebackDeclinedByYou (player_t *player);
void EvaluateServerReply_PlayNotAllowed (player_t *player);
void EvaluateServerReply_PlayUnexistent (player_t *player);
void EvaluateServerReply_PlayWrongRating (player_t *player);
void EvaluateServerReply_Announcement (player_t *player);
void EvaluateServerReply_ChannelMessage (player_t *player);
void EvaluateServerReply_ChannelsAndMembers (player_t *player);
void EvaluateServerReply_SoughtList (player_t *player);
void EvaluateServerReply_PlayersList (player_t *player);
void EvaluateServerReply_GameStarting (player_t *player);
void EvaluateServerReply_GameState (player_t *player);
void EvaluateServerReply_GameResults (player_t *player);
// pgnfile.cpp function prototypes
bool PGNFile_Load (const wchar_t *pgnfile_pathname);
bool PGNFile_LoadGame (board_t *board, const wchar_t *pgnfile_pathname, pgngame_t *game);
bool PGNFile_Save (board_t *board, const wchar_t *pgnfile_pathname);
// pipe.cpp function prototypes
FILE *pipe_open (const wchar_t *shell_command, const wchar_t *mode);
int pipe_close (FILE *stream);
int pipe_isalive (FILE *stream, int64_t *exit_code);
int pipe_hasdata (FILE *stream);
int pipe_read (FILE *stream, void *dstbuf, int nbytes);
int pipe_write (FILE *stream, void *srcbuf, int nbytes);
// player.cpp function prototypes
void Player_Init (player_t *player, int color, int type);
void Player_Shutdown (player_t *player);
void Player_ResetView (player_t *player);
bool Player_RotateTable (player_t *player, float frame_time);
bool Player_Think (player_t *player);
bool Player_SendBuffer_Add (player_t *player, int milliseconds_max, const wchar_t *fmt, ...);
player_t *Player_FindByType (int player_type);
player_t *Player_GetCurrent (void);
player_t *Player_GetOpposite (void);
// playercard.cpp function prototypes
void PlayerCards_Init (void);
void PlayerCards_Shutdown (void);
playercard_t *PlayerCard_FindOrCreate (const wchar_t *nickname);
void PlayerCard_AppendPersonalData (playercard_t *playercard, const wchar_t *text);
// render.cpp function prototypes
bool Render_Init (const wchar_t *fmt, ...); // parameter = splash screen pathname
void Render_Shutdown (void);
void Render_RenderFrame (scene_t *scene);
int Render_LoadMesh (const wchar_t *fmt, ...);
int Render_LoadTexture (const wchar_t *fmt, ...);
int Render_LoadSprite (const wchar_t *fmt, ...);
int Render_MaterialIndexOf (const wchar_t *material_name);
void Render_MouseToFloor (short mouse_x, short mouse_y, float *floor_x, float *floor_y);
bool Render_IsMouseInBox (short mouse_x, short mouse_y, float x_percent, float y_percent, float width_percent, float height_percent);
// safelib.cpp function prototypes
void *SAFE_malloc (int count, size_t element_size, bool cleanup);
void *SAFE_realloc (void *allocation, int old_count, int new_count, size_t element_size, bool cleanup);
void SAFE_free (void **address_of_pointer_to_allocation);
// san.cpp function prototypes
bool Move_SetupFromSAN (boardmove_t *move, boardmove_t *new_move, int move_color);
bool Move_DescribeInSAN (boardmove_t *move, boardmove_t *previousmove);
// scene.cpp function prototypes
void Scene_Init (scene_t *scene, board_t *board);
void Scene_Shutdown (scene_t *scene);
void Scene_Update (scene_t *scene, board_t *board);
void Scene_AddCCReply (scene_t *scene, wchar_t *nickname, wchar_t *channelname, unsigned long color_rgbx, wchar_t *fmt, ...);
void Scene_AddCCAnnouncement (scene_t *scene, wchar_t *announcement_label, wchar_t *fmt, ...);
void Scene_SetupButton (guibutton_t *button, float left_percent, float top_percent, float width_percent, float height_percent, int sprite_index, wchar_t *font_face, float font_sizepct, bool is_bold, bool is_italic, wchar_t *fmt, ...);
void Scene_SetupTextArea (guitext_t *text, float xpos_percent, float ypos_percent, float maxwidth_percent, int horizontal_align, int vertical_align, int text_align, wchar_t *font_face, float font_sizepct, bool is_bold, bool is_italic);
void Scene_UpdateText (guitext_t *text, unsigned long color_rgba, float duration, bool want_fade, wchar_t *fmt, ...);
// tabcontrol.cpp function prototypes
void *TabControl_New (HWND hTabControlWnd, WNDPROC ParentProc);
void TabControl_AddPage (void *tab_control, wchar_t *page_name, int dialog_id);
void TabControl_SelectTab (void *tab_control, int page_index);
HWND TabControl_GetItem (void *tab_control, int item_id);
void TabControl_Destroy (void *tab_control);
bool TabControl_Notify (NMHDR *notification);
// theme.cpp function prototypes
bool Themes_Init (void);
void Themes_Shutdown (void);
void Theme_LoadABitMore (theme_t *theme);
void Background_LoadImage (backgroundsprite_t *bg, const wchar_t *fmt, ...);
// util.cpp function prototypes
const wchar_t *GetDirectoryPath (const wchar_t *pathname, wchar_t *path);
void CreateOrUpdateApplicationMenu (void);
void CenterWindow (HWND hWnd, HWND hParentWnd);
void HintWindow (HWND hWnd);
float ProcessTime (void);
float WrapAngle (float angle);
bool SafeTerminateProcess (HANDLE hProcess, unsigned int uExitCode);
wchar_t *ReachBeginningOfCurrentLine (wchar_t *string, wchar_t *current_pos);
wchar_t *ReachBeginningOfNextLine (wchar_t *string, wchar_t *current_pos);
wchar_t *ReadACompleteLine (wchar_t *destination_line, int max_length, wchar_t *source_buffer);
wchar_t *wcsgets (wchar_t *destination_line, int max_length, wchar_t *source_buffer);
wchar_t *wcsistr (const wchar_t *haystack, const wchar_t *needle);
void ConvertCRLFsToSingleSpaces (wchar_t *multiline_string);
void ConvertTo7BitASCII (char *dest, size_t dest_size_in_bytes, wchar_t *source);
void ConvertToWideChar (wchar_t *dest, size_t dest_size_in_wchars, char *source);
void MinutesToWideCharString (wchar_t *dest, size_t dest_size_in_wchars, int minutes);
void SecondsToWideCharString (wchar_t *dest, size_t dest_size_in_wchars, int seconds);
int MonthStringToNumber (wchar_t *month_string);
bool GetImageSize (const wchar_t *imagefile_pathname, int *width, int *height);
void Debug_Init (const wchar_t *logfile_name);
void Debug_Log (const wchar_t *fmt, ...);
void Debug_LogMove (boardmove_t *move, const wchar_t *fmt, ...);
bool Debug_SendLogToAuthor (char *reason, bool should_include_description);
int RecvWithTimeout (int socket_id, float timeout_in_seconds, char *outbuf, size_t outbuf_size, int flags);
const wchar_t *GetLastNetworkError (void);
HICON W32LoadIcon (const wchar_t *fmt, ...);
HBITMAP W32LoadImage (const wchar_t *fmt, ...);
bool IsRegistrationCorrect (const wchar_t *email, const unsigned __int32 code);
// dialog_xxx.cpp and window_xxx.cpp function prototypes
void DialogBox_Registration (void);
void DialogBox_About (void); void DialogBox_About_Validated (void);
void DialogBox_Challenge (int challenge_index); void DialogBox_Challenge_Validated (void);
void DialogBox_ChangeAppearance (void); void DialogBox_ChangeAppearance_Validated (void);
void DialogBox_Comment (void); void DialogBox_Comment_Validated (void);
void DialogBox_EndGame (void); void DialogBox_EndGame_Validated (void);
void DialogBox_GoToMove (void); void DialogBox_GoToMove_Validated (void);
void DialogBox_RenameSides (void); void DialogBox_RenameSides_Validated (void);
void DialogBox_Load (void); void DialogBox_Load_Validated (void);
void DialogBox_Message (messagebox_t *messagebox_parms); void DialogBox_Message_Validated (void);
void DialogBox_NewGame (void); void DialogBox_NewGame_Validated (void);
void DialogBox_Options (void); void DialogBox_Options_Validated (void);
void DialogBox_PawnPromotion (void); void DialogBox_PawnPromotion_Validated (void);
void DialogBox_PlayerCard (int playercard_index); void DialogBox_PlayerCard_Validated (void);
void DialogBox_PlayerInfoName (void); void DialogBox_PlayerInfoName_Validated (void);
void DialogBox_Quit (void); void DialogBox_Quit_Validated (void);
void DialogBox_Resign (int type); void DialogBox_Resign_Validated (void);
void DialogBox_Save (bool want_quit_after_save); void DialogBox_Save_Validated (void);
void DialogBox_SavePosition (void); void DialogBox_SavePosition_Validated (void);
void DialogBox_SendChallenge (wchar_t *challengee_name); void DialogBox_SendChallenge_Validated (void);
void DialogBox_SendSeek (void); void DialogBox_SendSeek_Validated (void);
void DialogBox_Takeback (int howmany_halfmoves); void DialogBox_Takeback_Validated (void);
void Window_Chat (int interlocutor_index); void Window_Chat_Validated (void);
void Window_ChatterChannels (void); void Window_ChatterChannels_Validated (void);
void Window_Games (void); void Window_Games_Validated (void);
void Window_MOTD (void); void Window_MOTD_Validated (void);
void Window_Opponents (void); void Window_Opponents_Validated (void);
void Window_Sought (void); void Window_Sought_Validated (void);
LRESULT CALLBACK WindowProc_Main (HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam);
#endif // PROTOTYPES_H