Skip to content

Commit 1a6acd9

Browse files
committed
Slight adjustment to how time is displayed
1 parent ea4a5d0 commit 1a6acd9

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

ttyd-tools/rel/source/memorywatch.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,15 @@ const char *getValueString(int32_t slot)
123123
uint32_t FPS = getCurrentFPS();
124124

125125
int64_t CurrentTime = *reinterpret_cast<int64_t *>(Address) / (TimeBase / FPS);
126-
const char *NegativeSign = "";
126+
bool ValueIsPositive = true;
127127

128128
// Check if the value is negative
129129
if (CurrentTime < 0)
130130
{
131+
ValueIsPositive = false;
132+
131133
// Convert the number to positive
132134
CurrentTime = -CurrentTime;
133-
NegativeSign = "-";
134135
}
135136

136137
// Handle the value as unsigned
@@ -141,13 +142,24 @@ const char *getValueString(int32_t slot)
141142
uint32_t second = (CurrentTimeUnsigned / FPS) % 60;
142143
uint32_t frame = CurrentTimeUnsigned % FPS;
143144

144-
sprintf(tempDisplayBuffer,
145-
"%s%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%02" PRIu32,
146-
NegativeSign,
147-
hour,
148-
minute,
149-
second,
150-
frame);
145+
if (ValueIsPositive)
146+
{
147+
sprintf(tempDisplayBuffer,
148+
"%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%02" PRIu32,
149+
hour,
150+
minute,
151+
second,
152+
frame);
153+
}
154+
else
155+
{
156+
sprintf(tempDisplayBuffer,
157+
"-%02" PRIu32 ":%02" PRIu32 ":%02" PRIu32 ".%02" PRIu32,
158+
hour,
159+
minute,
160+
second,
161+
frame);
162+
}
151163
return tempDisplayBuffer;
152164
}
153165
case s8:

0 commit comments

Comments
 (0)