1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-23 11:13:19 +01:00

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:
5ea58d9451
This commit is contained in:
Alexandro Sánchez Bach 2014-03-28 05:32:24 +01:00
parent 2c7269e3de
commit 950fcfe4ef
2 changed files with 31 additions and 29 deletions

View File

@ -14,23 +14,22 @@ std::mutex g_cs_conlog;
static const uint max_item_count = 500; static const uint max_item_count = 500;
static const uint buffer_size = 1024 * 64; 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", "Black", "Green", "White", "Yellow", "Red",
}; };
struct LogPacket struct LogPacket
{ {
wxString m_prefix; std::string m_prefix;
wxString m_text; std::string m_text;
wxString m_colour; 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_prefix(prefix)
, m_text(text) , m_text(text)
, m_colour(colour) , m_colour(colour)
{ {
} }
LogPacket() LogPacket()
@ -46,9 +45,9 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
void _push(const LogPacket& data) void _push(const LogPacket& data)
{ {
const u32 sprefix = data.m_prefix.length() * sizeof(wxChar); const u32 sprefix = data.m_prefix.length();
const u32 stext = data.m_text.length() * sizeof(wxChar); const u32 stext = data.m_text.length();
const u32 scolour = data.m_colour.length() * sizeof(wxChar); const u32 scolour = data.m_colour.length();
m_buffer.Reserve( m_buffer.Reserve(
sizeof(u32) + sprefix + sizeof(u32) + sprefix +
@ -59,17 +58,17 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
memcpy(&m_buffer[c_put], &sprefix, sizeof(u32)); memcpy(&m_buffer[c_put], &sprefix, sizeof(u32));
c_put += 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; c_put += sprefix;
memcpy(&m_buffer[c_put], &stext, sizeof(u32)); memcpy(&m_buffer[c_put], &stext, sizeof(u32));
c_put += 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; c_put += stext;
memcpy(&m_buffer[c_put], &scolour, sizeof(u32)); memcpy(&m_buffer[c_put], &scolour, sizeof(u32));
c_put += 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; c_put += scolour;
m_put = c_put; m_put = c_put;
@ -84,17 +83,20 @@ struct _LogBuffer : public MTPacketBuffer<LogPacket>
const u32& sprefix = *(u32*)&m_buffer[c_get]; const u32& sprefix = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32); 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; c_get += sprefix;
const u32& stext = *(u32*)&m_buffer[c_get]; const u32& stext = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32); 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; c_get += stext;
const u32& scolour = *(u32*)&m_buffer[c_get]; const u32& scolour = *(u32*)&m_buffer[c_get];
c_get += sizeof(u32); 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; c_get += scolour;
m_get = c_get; 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()) if(!prefix.empty())
{ {
@ -124,8 +126,8 @@ void LogWriter::WriteToLog(wxString prefix, wxString value, u8 lvl/*, wxColour b
} }
} }
if(m_logfile.IsOpened() && !prefix.empty()) if(m_logfile.IsOpened())
m_logfile.Write(wxString("[") + prefix + "]: " + value + "\n"); 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())) if(!ConLogFrame || Ini.HLELogLvl.GetValue() == 4 || (lvl != 0 && lvl <= Ini.HLELogLvl.GetValue()))
return; return;
@ -172,7 +174,7 @@ void LogWriter::Write(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("!", frmt, 2); WriteToLog("!", (const char *)frmt.ToAscii(), 2);
} }
void LogWriter::Error(const wxString fmt, ...) void LogWriter::Error(const wxString fmt, ...)
@ -185,7 +187,7 @@ void LogWriter::Error(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("E", frmt, 4); WriteToLog("E", static_cast<const char *>(frmt), 4);
} }
void LogWriter::Warning(const wxString fmt, ...) void LogWriter::Warning(const wxString fmt, ...)
@ -198,7 +200,7 @@ void LogWriter::Warning(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("W", frmt, 3); WriteToLog("W", static_cast<const char *>(frmt), 3);
} }
void LogWriter::Success(const wxString fmt, ...) void LogWriter::Success(const wxString fmt, ...)
@ -211,7 +213,7 @@ void LogWriter::Success(const wxString fmt, ...)
va_end(list); va_end(list);
WriteToLog("S", frmt, 1); WriteToLog("S", static_cast<const char *>(frmt), 1);
} }
void LogWriter::SkipLn() void LogWriter::SkipLn()
@ -276,9 +278,9 @@ void LogFrame::Task()
const int cur_item = m_log.GetItemCount(); const int cur_item = m_log.GetItemCount();
m_log.InsertItem(cur_item, item.m_prefix); m_log.InsertItem(cur_item, wxString(item.m_prefix).wx_str());
m_log.SetItem(cur_item, 1, item.m_text); m_log.SetItem(cur_item, 1, wxString(item.m_text).wx_str());
m_log.SetItemTextColour(cur_item, item.m_colour); m_log.SetItemTextColour(cur_item, wxString(item.m_colour).wx_str());
m_log.SetColumnWidth(0, -1); // crashes on exit m_log.SetColumnWidth(0, -1); // crashes on exit
m_log.SetColumnWidth(1, -1); m_log.SetColumnWidth(1, -1);

View File

@ -8,10 +8,10 @@ class LogWriter
wxFile m_logfile; wxFile m_logfile;
wxColour m_txtcolour; wxColour m_txtcolour;
//wxString m_prefix; std::string m_prefix;
//wxString m_value; 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: public:
LogWriter(); LogWriter();