Skip to content

Commit

Permalink
v0.1.4-alpha
Browse files Browse the repository at this point in the history
- Save each record-time in a separate file, and include date and time in the name of the file (naming format: YYYY-MM-DD-HH-MM-SS-record-time.txt),
- Save the files with record-times in a separate folder - `records`,
- Add time-stamps to the debugging output
  • Loading branch information
tomasz-rozanski committed Oct 26, 2019
1 parent e89409c commit 9bc635d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Generated\ Files/
*.txt
temp
game_stats/
game_stats/records/
debug/

# Batch files
shell.bat
Expand Down
12 changes: 11 additions & 1 deletion includes/vst_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions includes/vst_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 2 additions & 24 deletions includes/vst_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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();

Expand Down
21 changes: 19 additions & 2 deletions includes/vst_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 4 additions & 14 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();

Expand Down

0 comments on commit 9bc635d

Please sign in to comment.