From 950fcfe4ef6da8aad5198fc12b029862545cfc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Fri, 28 Mar 2014 05:32:24 +0100 Subject: [PATCH] Reverted ConLog changes of commit 5ea58d94 This was causing a "Bad flip!" error on Arkedo Series 02 Swap!. I guess we will have to search for a better solution. I just reverted the ConLog.cpp / ConLog.h files. Related commit: https://github.com/DHrpcs3/rpcs3/commit/5ea58d9451c2af7884bb5d1fd74e47d0bcc5770a --- rpcs3/Gui/ConLog.cpp | 54 +++++++++++++++++++++++--------------------- rpcs3/Gui/ConLog.h | 6 ++--- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/rpcs3/Gui/ConLog.cpp b/rpcs3/Gui/ConLog.cpp index 4895d74113..953a4977ab 100644 --- a/rpcs3/Gui/ConLog.cpp +++ b/rpcs3/Gui/ConLog.cpp @@ -14,23 +14,22 @@ std::mutex g_cs_conlog; static const uint max_item_count = 500; static const uint buffer_size = 1024 * 64; -static const wxString g_log_colors[] = +static const std::string g_log_colors[] = { "Black", "Green", "White", "Yellow", "Red", }; struct LogPacket { - wxString m_prefix; - wxString m_text; - wxString m_colour; + std::string m_prefix; + std::string m_text; + std::string m_colour; - LogPacket(const wxString& prefix, const wxString& text, const wxString& colour) + LogPacket(const std::string& prefix, const std::string& text, const std::string& colour) : m_prefix(prefix) , m_text(text) , m_colour(colour) - { - + { } LogPacket() @@ -46,9 +45,9 @@ struct _LogBuffer : public MTPacketBuffer void _push(const LogPacket& data) { - const u32 sprefix = data.m_prefix.length() * sizeof(wxChar); - const u32 stext = data.m_text.length() * sizeof(wxChar); - const u32 scolour = data.m_colour.length() * sizeof(wxChar); + const u32 sprefix = data.m_prefix.length(); + const u32 stext = data.m_text.length(); + const u32 scolour = data.m_colour.length(); m_buffer.Reserve( sizeof(u32) + sprefix + @@ -59,17 +58,17 @@ struct _LogBuffer : public MTPacketBuffer memcpy(&m_buffer[c_put], &sprefix, sizeof(u32)); c_put += sizeof(u32); - memcpy(&m_buffer[c_put], data.m_prefix.wx_str(), sprefix); + memcpy(&m_buffer[c_put], data.m_prefix.c_str(), sprefix); c_put += sprefix; memcpy(&m_buffer[c_put], &stext, sizeof(u32)); c_put += sizeof(u32); - memcpy(&m_buffer[c_put], data.m_text.wx_str(), stext); + memcpy(&m_buffer[c_put], data.m_text.c_str(), stext); c_put += stext; memcpy(&m_buffer[c_put], &scolour, sizeof(u32)); c_put += sizeof(u32); - memcpy(&m_buffer[c_put], data.m_colour.wx_str(), scolour); + memcpy(&m_buffer[c_put], data.m_colour.c_str(), scolour); c_put += scolour; m_put = c_put; @@ -84,17 +83,20 @@ struct _LogBuffer : public MTPacketBuffer const u32& sprefix = *(u32*)&m_buffer[c_get]; c_get += sizeof(u32); - ret.m_prefix = wxString((wxChar*)&m_buffer[c_get], sprefix / sizeof(wxChar)); + ret.m_prefix.resize(sprefix); + if(sprefix) memcpy((void*)ret.m_prefix.c_str(), &m_buffer[c_get], sprefix); c_get += sprefix; const u32& stext = *(u32*)&m_buffer[c_get]; c_get += sizeof(u32); - ret.m_text = wxString((wxChar*)&m_buffer[c_get], stext / sizeof(wxChar)); + ret.m_text.resize(stext); + if(stext) memcpy((void*)ret.m_text.c_str(), &m_buffer[c_get], stext); c_get += stext; const u32& scolour = *(u32*)&m_buffer[c_get]; c_get += sizeof(u32); - ret.m_colour = wxString((wxChar*)&m_buffer[c_get], scolour / sizeof(wxChar)); + ret.m_colour.resize(scolour); + if(scolour) memcpy((void*)ret.m_colour.c_str(), &m_buffer[c_get], scolour); c_get += scolour; m_get = c_get; @@ -114,7 +116,7 @@ LogWriter::LogWriter() } } -void LogWriter::WriteToLog(wxString prefix, wxString value, u8 lvl/*, wxColour bgcolour*/) +void LogWriter::WriteToLog(std::string prefix, std::string value, u8 lvl/*, wxColour bgcolour*/) { if(!prefix.empty()) { @@ -124,8 +126,8 @@ void LogWriter::WriteToLog(wxString prefix, wxString value, u8 lvl/*, wxColour b } } - if(m_logfile.IsOpened() && !prefix.empty()) - m_logfile.Write(wxString("[") + prefix + "]: " + value + "\n"); + if(m_logfile.IsOpened()) + m_logfile.Write(wxString(prefix.empty() ? "" : std::string("[" + prefix + "]: ") + value + "\n").wx_str()); if(!ConLogFrame || Ini.HLELogLvl.GetValue() == 4 || (lvl != 0 && lvl <= Ini.HLELogLvl.GetValue())) return; @@ -172,7 +174,7 @@ void LogWriter::Write(const wxString fmt, ...) va_end(list); - WriteToLog("!", frmt, 2); + WriteToLog("!", (const char *)frmt.ToAscii(), 2); } void LogWriter::Error(const wxString fmt, ...) @@ -185,7 +187,7 @@ void LogWriter::Error(const wxString fmt, ...) va_end(list); - WriteToLog("E", frmt, 4); + WriteToLog("E", static_cast(frmt), 4); } void LogWriter::Warning(const wxString fmt, ...) @@ -198,7 +200,7 @@ void LogWriter::Warning(const wxString fmt, ...) va_end(list); - WriteToLog("W", frmt, 3); + WriteToLog("W", static_cast(frmt), 3); } void LogWriter::Success(const wxString fmt, ...) @@ -211,7 +213,7 @@ void LogWriter::Success(const wxString fmt, ...) va_end(list); - WriteToLog("S", frmt, 1); + WriteToLog("S", static_cast(frmt), 1); } void LogWriter::SkipLn() @@ -276,9 +278,9 @@ void LogFrame::Task() const int cur_item = m_log.GetItemCount(); - m_log.InsertItem(cur_item, item.m_prefix); - m_log.SetItem(cur_item, 1, item.m_text); - m_log.SetItemTextColour(cur_item, item.m_colour); + m_log.InsertItem(cur_item, wxString(item.m_prefix).wx_str()); + m_log.SetItem(cur_item, 1, wxString(item.m_text).wx_str()); + m_log.SetItemTextColour(cur_item, wxString(item.m_colour).wx_str()); m_log.SetColumnWidth(0, -1); // crashes on exit m_log.SetColumnWidth(1, -1); diff --git a/rpcs3/Gui/ConLog.h b/rpcs3/Gui/ConLog.h index 79aec07cf1..fec015d43a 100644 --- a/rpcs3/Gui/ConLog.h +++ b/rpcs3/Gui/ConLog.h @@ -8,10 +8,10 @@ class LogWriter wxFile m_logfile; wxColour m_txtcolour; - //wxString m_prefix; - //wxString m_value; + std::string m_prefix; + std::string m_value; - virtual void WriteToLog(wxString prefix, wxString value, u8 lvl); + virtual void WriteToLog(std::string prefix, std::string value, u8 lvl); public: LogWriter();