diff --git a/.gitignore b/.gitignore index c7f9abc..c08b9d3 100644 --- a/.gitignore +++ b/.gitignore @@ -91,6 +91,8 @@ Generated\ Files/ *.txt temp game_stats/ +game_stats/records/ +debug/ # Batch files shell.bat diff --git a/includes/vst_console.h b/includes/vst_console.h index ca7875f..1bed18f 100644 --- a/includes/vst_console.h +++ b/includes/vst_console.h @@ -209,8 +209,18 @@ WriteDebugMessage(HANDLE hConsole) void WriteDebugLog(TCHAR *message) { - FILE *fpDebugInfo = fopen("debug/debug.log", "a"); + SYSTEMTIME stLocalTime; + + GetLocalTime(&stLocalTime); + FILE *fpDebugInfo = fopen("debug/debug.log", "a"); + fprintf(fpDebugInfo, "%04d-%02d-%02d %02d:%02d:%02d: ", // + stLocalTime.wYear, // + stLocalTime.wMonth, // + stLocalTime.wDay, // + stLocalTime.wHour, // + stLocalTime.wMinute, // + stLocalTime.wSecond); fprintf(fpDebugInfo, message); fclose(fpDebugInfo); diff --git a/includes/vst_debug.h b/includes/vst_debug.h index 253cc18..588b418 100644 --- a/includes/vst_debug.h +++ b/includes/vst_debug.h @@ -6,6 +6,10 @@ WriteDebugInfo(void) { TCHAR szBuffer[1024]; + processBaseAddress = GetModuleDllBase(processID, szModuleName); + sprintf(szBuffer, "processBaseAddress: 0x%08x\n", processBaseAddress); + WriteDebugLog(szBuffer); + // Maximum window dimensions sprintf( szBuffer, "conMaxSizeX: %i, conMaxSizeY: %i\n", conMaxSizeX, conMaxSizeY); diff --git a/includes/vst_player.h b/includes/vst_player.h index 32530ca..a28987c 100644 --- a/includes/vst_player.h +++ b/includes/vst_player.h @@ -345,29 +345,6 @@ ReadLastBossHealth(UINT16 *BossHP) return BytesRead; } -void -LastBossHandleIt() -{ - printf("\n\n== LAST BOSS FIGHT IS ON ==\n\n"); - - ReadLastBossHealth(&LastBossHP); - - if (LastBossHP > 0) - { - fprintf(stdout, "Guildenstern's HP: %i\n", LastBossHP); - } - else - { - fprintf(stdout, "Guildenstern is dead. Good Job!!!\n"); - ReadPlayTime(&RecordTime); - - WriteRecordTimeToFile(&RecordTime, _T("game_stats/record-time.txt")); - Sleep(5000); - - GameOver = TRUE; - } -} - void LastBossHandleIt2() { @@ -387,7 +364,8 @@ LastBossHandleIt2() WriteToBackBuffer(); ReadPlayTime(&RecordTime); - WriteRecordTimeToFile(&RecordTime, _T("game_stats/record-time.txt")); + WriteRecordTimeToFile( + &RecordTime, _T("game_stats/records"), _T("record-time.txt")); CopyFromBackBuffer(); diff --git a/includes/vst_time.h b/includes/vst_time.h index 19b466e..90c7649 100644 --- a/includes/vst_time.h +++ b/includes/vst_time.h @@ -105,13 +105,30 @@ WritePlayTimeToFile(playtime *PlayTime, TCHAR FileName[MAX_PATH]) } void -WriteRecordTimeToFile(playtime *RecordTime, TCHAR FileName[MAX_PATH]) +WriteRecordTimeToFile( + playtime *RecordTime, TCHAR szFolderName[128], TCHAR FileName[128]) { + SYSTEMTIME stLocalTime; + TCHAR szLocalTime[64]; + TCHAR szFullPath[MAX_PATH]; + + GetLocalTime(&stLocalTime); + + sprintf(szLocalTime, "%04d-%02d-%02d-%02d-%02d-%02d", // + stLocalTime.wYear, // + stLocalTime.wMonth, // + stLocalTime.wDay, // + stLocalTime.wHour, // + stLocalTime.wMinute, // + stLocalTime.wSecond); + + sprintf(szFullPath, "%s/%s-%s", szFolderName, szLocalTime, FileName); + UINT8 Seconds = RecordTime->Time.Seconds; UINT8 Minutes = RecordTime->Time.Minutes; UINT8 Hours = RecordTime->Time.Hours; - FILE *fpRecordTime = fopen(FileName, "w"); + FILE *fpRecordTime = fopen(szFullPath, "w"); // Standard time (seconds accuracy) fprintf(fpRecordTime, "Record Time\n%02i:%02i:%02i", Hours, Minutes, Seconds); diff --git a/main.c b/main.c index 46ff109..159bfc5 100644 --- a/main.c +++ b/main.c @@ -98,26 +98,16 @@ wmain(int argc, wchar_t *argv[]) Sleep(1000); }; - // Display this info when DEBUG is ON. - // Create separate function for this. - + // Setup the folders mkdir("debug"); + mkdir("game_stats"); + mkdir("game_stats/records"); - FILE *fpDebugInfo = fopen("debug/debug.log", "w"); - - processBaseAddress = GetModuleDllBase(processID, szModuleName); - fprintf(fpDebugInfo, "processBaseAddress: 0x%08x\n", processBaseAddress); - - fclose(fpDebugInfo); - // exit(1); // PrintProcessInfo(processID); // PrintProcessNameAndID(processID); // PrintProcessVersion(processID); - // PrintModuleFileName(processID); - mkdir("game_stats"); - SetConsoleHandles(); cls(hStdout); @@ -138,7 +128,7 @@ wmain(int argc, wchar_t *argv[]) SetCursorPosition(hBackBuffer, 0, 0); sprintf(szBuffer, "============================\n" - "== VSTracker v0.1.3-alpha ==\n" + "== VSTracker v0.1.4-alpha ==\n" "============================\n"); WriteToBackBuffer();