C client: Fix clipboard being stuffed up

This commit is contained in:
UnknownShadow200 2018-09-04 13:05:33 +10:00
parent e6a0f0623d
commit 77a2292d45
6 changed files with 12 additions and 14 deletions

View File

@ -195,7 +195,7 @@ static void AsyncDownloader_ProcessRequest(struct AsyncRequest* request) {
Platform_Log2("Downloading from %s (type %b)", &url, &request->RequestType);
struct Stopwatch stopwatch;
Stopwatch_Start(&stopwatch);
Stopwatch_Measure(&stopwatch);
request->Result = Http_Do(request, &async_curProgress);
UInt32 elapsed = Stopwatch_ElapsedMicroseconds(&stopwatch) / 1000;

View File

@ -652,7 +652,7 @@ void Game_TakeScreenshot(void) {
}
static void Game_RenderFrame(Real64 delta) {
Stopwatch_Start(&game_frameTimer);
Stopwatch_Measure(&game_frameTimer);
Gfx_BeginFrame();
Gfx_BindIb(GfxCommon_defaultIb);
@ -731,7 +731,7 @@ void Game_Run(Int32 width, Int32 height, STRING_REF String* title, struct Displa
Game_Load();
Event_RaiseVoid(&WindowEvents_Resized);
Stopwatch_Start(&game_renderTimer);
Stopwatch_Measure(&game_renderTimer);
for (;;) {
Window_ProcessEvents();
if (!Window_Exists) break;
@ -741,7 +741,7 @@ void Game_Run(Int32 width, Int32 height, STRING_REF String* title, struct Displa
if (time > 1.0) time = 1.0;
if (time <= 0.0) continue;
Stopwatch_Start(&game_renderTimer);
Stopwatch_Measure(&game_renderTimer);
Game_RenderFrame(time);
}
}

View File

@ -209,7 +209,6 @@ void Stopwatch_Measure(struct Stopwatch* timer) {
timer->Data[0] = (Int64)value.dwLowDateTime | ((Int64)value.dwHighDateTime << 32);
}
}
void Stopwatch_Start(struct Stopwatch* timer) { Stopwatch_Measure(timer); }
/* TODO: check this is actually accurate */
Int32 Stopwatch_ElapsedMicroseconds(struct Stopwatch* timer) {
@ -269,7 +268,6 @@ void Stopwatch_Measure(struct Stopwatch* timer) {
timer->Data[0] = value.tv_sec;
timer->Data[1] = value.tv_nsec;
}
void Stopwatch_Start(struct Stopwatch* timer) { Stopwatch_Measure(timer); }
/* TODO: check this is actually accurate */
Int32 Stopwatch_ElapsedMicroseconds(struct Stopwatch* timer) {

View File

@ -53,7 +53,7 @@ UInt64 DateTime_CurrentUTC_MS(void);
void DateTime_CurrentUTC(DateTime* time);
void DateTime_CurrentLocal(DateTime* time);
struct Stopwatch { Int64 Data[2]; };
void Stopwatch_Start(struct Stopwatch* timer);
void Stopwatch_Measure(struct Stopwatch* timer);
Int32 Stopwatch_ElapsedMicroseconds(struct Stopwatch* timer);
bool Directory_Exists(STRING_PURE String* path);

View File

@ -481,9 +481,10 @@ UInt16 Convert_ExtendedChars[129] = { 0x2302,
};
UInt16 Convert_CP437ToUnicode(char c) {
if (c < 0x20) return Convert_ControlChars[(UInt8)c];
if (c < 0x7F) return c;
return Convert_ExtendedChars[(UInt8)c - 0x7F];
UInt8 raw = (UInt8)c;
if (raw < 0x20) return Convert_ControlChars[raw];
if (raw < 0x7F) return raw;
return Convert_ExtendedChars[raw - 0x7F];
}
char Convert_UnicodeToCP437(UInt16 c) {

View File

@ -478,10 +478,9 @@ void Window_SetClipboardText(STRING_PURE String* value) {
HANDLE hGlobal = GlobalAlloc(GMEM_MOVEABLE, (value->length + 1) * sizeof(UInt16));
if (!hGlobal) { CloseClipboard(); return; }
LPVOID dst = GlobalLock(hGlobal);
UInt16* text = (UInt16*)dst;
for (i = 0; i < value->length; i++) {
*text = Convert_CP437ToUnicode(value->buffer[i]); text++;
UInt16* text = GlobalLock(hGlobal);
for (i = 0; i < value->length; i++, text++) {
*text = Convert_CP437ToUnicode(value->buffer[i]);
}
*text = '\0';