void CReplayFrame::CreateReplayFrame(void){ FILE *fp = NULL; ULARGE_INTEGER free_bytes_for_user_on_disk = {0}, total_bytes_on_disk = {0}, free_bytes_total_on_disk = {0}; // Sanity check: Enough disk-space for replay frame? GetDiskFreeSpaceEx( p_filenames->OpenHoldemDirectory(), // Directory on disk of interest &free_bytes_for_user_on_disk, &total_bytes_on_disk, &free_bytes_total_on_disk); if (free_bytes_for_user_on_disk.QuadPart < FREE_SPACE_NEEDED_FOR_REPLAYFRAME) { write_log(preferences.debug_replayframes(), "[CReplayFrame] Not enough disk-space\n"); OH_MessageBox_Error_Warning("Not enough disk space to create replay-frame."); return; } // Get exclusive access to CScraper and CSymbols variables // (Wait for scrape/symbol cycle to finish before saving frame) EnterCriticalSection(&p_heartbeat_thread->cs_update_in_progress); CString next_frame; next_frame.Format("[%06d]", _next_replay_frame); // Replay-frame should always be mentioned in the log for easy reference write_log(k_always_log_basic_information, "[CReplayFrame] Shooting frame %s\n", next_frame); CreateBitMapFile(); // Create HTML file CString path = p_filenames->ReplayHTMLFilename(_next_replay_frame); if (fopen_s(&fp, path.GetString(), "w")==0) { write_log(preferences.debug_replayframes(), "[CReplayFrame] Creating HTML file: %s\n", path); // First line has to be the "title" of the table. // This is no longer valid HTML, but the way Ray.E.Bornert did it // for WinHoldem and WinScrape. fprintf(fp, "%s\n", p_table_state->TableTitle()->Title()); fprintf(fp, "<br>\n"); // HTML header fprintf(fp, "<html>\n"); fprintf(fp, " <head>\n"); fprintf(fp, " <title>%s</title>\n", p_table_state->TableTitle()->Title()); fprintf(fp, " </head>"); fprintf(fp, "<style>\n"); fprintf(fp, "td {text-align:right;}\n"); fprintf(fp, "</style>\n"); fprintf(fp, "<body>\n"); fprintf(fp, "<font face=courier>\n"); // Bitmap image fprintf(fp, "<img src=\"frame%06d.bmp\">\n", _next_replay_frame); fprintf(fp, "<br>\n"); // Title, data, frame-number, OH-version fprintf(fp, "%s", GeneralInfo()); // Links forwards and backwards to the next frames fprintf(fp, "%s", LPCSTR(GetLinksToPrevAndNextFile())); fprintf(fp, "<br>\n"); fprintf(fp, "<br>\n"); // Header of main table for smaller data tables fprintf(fp, "<table>\n"); fprintf(fp, "<tr>\n"); fprintf(fp, "<td>\n"); // Data tables fprintf(fp, "%s", LPCSTR(GetPlayerInfoAsHTML())); fprintf(fp, "/<td>\n"); fprintf(fp, "<td>\n"); fprintf(fp, "%s", LPCSTR(GetButtonStatesAsHTML())); fprintf(fp, "%s", LPCSTR(GetBlindInfoAsHTML())); fprintf(fp, "%s", LPCSTR(GetCommonCardsAsHTML())); fprintf(fp, "%s", LPCSTR(GetPotsAsHTML())); fprintf(fp, "</td>\n"); // Footer of main table fprintf(fp, "</tr>\n"); fprintf(fp, "</table>\n"); // End of HTML fprintf(fp, "</body></html>\n"); fclose(fp); } LeaveCriticalSection(&p_heartbeat_thread->cs_update_in_progress); }
void CReplayFrame::CreateReplayFrame(void) { FILE *fp = NULL; int i = 0; time_t ltime = 0; tm now_time = {0}; char now_time_str[100] = {0}; ULARGE_INTEGER free_bytes_for_user_on_disk = {0}, total_bytes_on_disk = {0}, free_bytes_total_on_disk = {0}; int e = SUCCESS; // Sanity check: Enough disk-space for replay frame? GetDiskFreeSpaceEx( p_filenames->OpenHoldemDirectory(), // Directory on disk of interest &free_bytes_for_user_on_disk, &total_bytes_on_disk, &free_bytes_total_on_disk); if (free_bytes_for_user_on_disk.QuadPart < FREE_SPACE_NEEDED_FOR_REPLAYFRAME) { write_log(prefs.debug_replayframes(), "[CReplayFrame] Not enough disk-space\n"); OH_MessageBox_Error_Warning("Not enough disk space to create replay-frame.", "ERROR"); return; } // Get current time time(<ime); localtime_s(&now_time, <ime); strftime(now_time_str, 100, "%Y-%m-%d %H:%M:%S", &now_time); // Get exclusive access to CScraper and CSymbols variables // (Wait for scrape/symbol cycle to finish before saving frame) EnterCriticalSection(&p_heartbeat_thread->cs_update_in_progress); CreateBitMapFile(); // Create HTML file CString path = p_filenames->ReplayHTMLFilename(_next_replay_frame); if (fopen_s(&fp, path.GetString(), "w")==0) { write_log(prefs.debug_replayframes(), "[CReplayFrame] Creating HTML file: $s\n", path); // First line has to be the "title" of the table. // This is no longer valid HTML, but the way Ray.E.Bornert did it // for WinHoldem and WinScrape. fprintf(fp, "%s\n", p_scraper->title()); // HTML header fprintf(fp, "<html>\n"); fprintf(fp, " <head>\n"); fprintf(fp, " <title>%s</title>\n", p_scraper->title()); fprintf(fp, " </head>"); fprintf(fp, "<style>\n"); fprintf(fp, "td {text-align:right;}\n"); fprintf(fp, "</style>\n"); fprintf(fp, "<body>\n"); fprintf(fp, "<font face=courier>\n"); // Bitmap image fprintf(fp, "<img src=\"frame%06d.bmp\">\n", _next_replay_frame); fprintf(fp, "<br>\n"); // Table title fprintf(fp, "[%s]", p_scraper->title()); fprintf(fp, "<br>\n"); // Session, frame number and time fprintf(fp, " [Session %lu]", p_sessioncounter->session_id()); fprintf(fp, " [Frame: %06d]", _next_replay_frame); fprintf(fp, " [%s]<br>\n", now_time_str); fprintf(fp, "<br>\n"); // Links forwards and backwards to the next frames fprintf(fp, "%s", LPCSTR(GetLinksToPrevAndNextFile())); fprintf(fp, "<br>\n"); fprintf(fp, "<br>\n"); // Header of main table for smaller data tables fprintf(fp, "<table>\n"); fprintf(fp, "<tr>\n"); fprintf(fp, "<td>\n"); // Data tables fprintf(fp, "%s", LPCSTR(GetPlayerInfoAsHTML())); fprintf(fp, "/<td>\n"); fprintf(fp, "<td>\n"); fprintf(fp, "%s", LPCSTR(GetButtonStatesAsHTML())); fprintf(fp, "%s", LPCSTR(GetBlindInfoAsHTML())); fprintf(fp, "%s", LPCSTR(GetCommonCardsAsHTML())); fprintf(fp, "%s", LPCSTR(GetPotsAsHTML())); fprintf(fp, "</td>\n"); // Footer of main table fprintf(fp, "</tr>\n"); fprintf(fp, "</table>\n"); // End of HTML fprintf(fp, "</body></html>\n"); fclose(fp); } LeaveCriticalSection(&p_heartbeat_thread->cs_update_in_progress); }