Merge pull request #456 from lioncash/adios-sprintf

Kill off replaceable usages of s[n]printf.
This commit is contained in:
Pierre Bourdon 2014-06-19 01:59:02 +02:00
commit 591a27e328
29 changed files with 216 additions and 243 deletions

View file

@ -2,6 +2,9 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <string>
#include "Common/StringUtil.h"
#include "Core/HW/SI_Device.h"
#include "Core/HW/SI_DeviceAMBaseboard.h"
#include "Core/HW/SI_DeviceDanceMat.h"
@ -14,24 +17,24 @@
int ISIDevice::RunBuffer(u8* _pBuffer, int _iLength)
{
#ifdef _DEBUG
DEBUG_LOG(SERIALINTERFACE, "Send Data Device(%i) - Length(%i) ", ISIDevice::m_iDeviceNumber,_iLength);
DEBUG_LOG(SERIALINTERFACE, "Send Data Device(%i) - Length(%i) ", ISIDevice::m_iDeviceNumber, _iLength);
char szTemp[256] = "";
std::string temp;
int num = 0;
while (num < _iLength)
{
char szTemp2[128] = "";
sprintf(szTemp2, "0x%02x ", _pBuffer[num^3]);
strcat(szTemp, szTemp2);
temp += StringFromFormat("0x%02x ", _pBuffer[num^3]);
num++;
if ((num % 8) == 0)
{
DEBUG_LOG(SERIALINTERFACE, "%s", szTemp);
szTemp[0] = '\0';
DEBUG_LOG(SERIALINTERFACE, "%s", temp.c_str());
temp.clear();
}
}
DEBUG_LOG(SERIALINTERFACE, "%s", szTemp);
DEBUG_LOG(SERIALINTERFACE, "%s", temp.c_str());
#endif
return 0;
};

View file

@ -1043,10 +1043,8 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress)
for (int i = 0; remoteHost->h_addr_list[i]; ++i)
{
u32 ip = Common::swap32(*(u32*)(remoteHost->h_addr_list[i]));
char ip_s[16];
sprintf(ip_s, "%i.%i.%i.%i",
ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
DEBUG_LOG(WII_IPC_NET, "addr%i:%s", i, ip_s);
std::string ip_s = StringFromFormat("%i.%i.%i.%i", ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
DEBUG_LOG(WII_IPC_NET, "addr%i:%s", i, ip_s.c_str());
}
Memory::Memset(BufferOut, 0, BufferOutSize);

View file

@ -2,8 +2,10 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <string>
#include <vector>
#include "Common/StringUtil.h"
#include "Core/NetPlayServer.h"
NetPlayServer::~NetPlayServer()
@ -686,15 +688,12 @@ bool NetPlayServer::initUPnP()
// Attempt to portforward!
bool NetPlayServer::UPnPMapPort(const std::string& addr, const u16 port)
{
char port_str[6] = { 0 };
int result;
if (m_upnp_mapped > 0)
UPnPUnmapPort(m_upnp_mapped);
sprintf(port_str, "%d", port);
result = UPNP_AddPortMapping(m_upnp_urls.controlURL, m_upnp_data.first.servicetype,
port_str, port_str, addr.c_str(),
std::string port_str = StringFromFormat("%d", port);
int result = UPNP_AddPortMapping(m_upnp_urls.controlURL, m_upnp_data.first.servicetype,
port_str.c_str(), port_str.c_str(), addr.c_str(),
(std::string("dolphin-emu TCP on ") + addr).c_str(),
"TCP", nullptr, nullptr);
@ -716,11 +715,9 @@ bool NetPlayServer::UPnPMapPort(const std::string& addr, const u16 port)
// --
bool NetPlayServer::UPnPUnmapPort(const u16 port)
{
char port_str[6] = { 0 };
sprintf(port_str, "%d", port);
std::string port_str = StringFromFormat("%d", port);
UPNP_DeletePortMapping(m_upnp_urls.controlURL, m_upnp_data.first.servicetype,
port_str, "TCP", nullptr);
port_str.c_str(), "TCP", nullptr);
return true;
}

View file

@ -3,9 +3,11 @@
// Refer to the license.txt file included.
#include <cinttypes>
#include <string>
#include "PowerPCDisasm.h"
#include "Common/StringUtil.h"
#include "Core/Host.h"
#include "Core/Debugger/Debugger_SymbolMap.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
@ -65,22 +67,18 @@ static void patches()
int startTrace = 0;
void Trace( UGeckoInstruction &instCode )
void Trace(UGeckoInstruction& instCode)
{
char reg[25]="";
std::string regs = "";
for (int i=0; i<32; i++)
for (int i = 0; i < 32; i++)
{
sprintf(reg, "r%02d: %08x ", i, PowerPC::ppcState.gpr[i]);
regs.append(reg);
regs += StringFromFormat("r%02d: %08x ", i, PowerPC::ppcState.gpr[i]);
}
char freg[25]="";
std::string fregs = "";
for (int i=0; i<32; i++)
for (int i = 0; i < 32; i++)
{
sprintf(freg, "f%02d: %08" PRIx64 " %08" PRIx64 " ", i, PowerPC::ppcState.ps[i][0], PowerPC::ppcState.ps[i][1]);
fregs.append(freg);
fregs += StringFromFormat("f%02d: %08" PRIx64 " %08" PRIx64 " ", i, PowerPC::ppcState.ps[i][0], PowerPC::ppcState.ps[i][1]);
}
char ppcInst[256];

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <map>
#include <string>
// for the PROFILER stuff
#ifdef _WIN32
@ -10,6 +11,7 @@
#endif
#include "Common/Common.h"
#include "Common/StringUtil.h"
#include "Core/PatchEngine.h"
#include "Core/HLE/HLE.h"
#include "Core/HW/ProcessorInterface.h"
@ -363,31 +365,27 @@ void Jit64::SingleStep()
void Jit64::Trace()
{
char regs[500] = "";
char fregs[750] = "";
std::string regs;
std::string fregs;
#ifdef JIT_LOG_GPR
for (int i = 0; i < 32; i++)
{
char reg[50];
sprintf(reg, "r%02d: %08x ", i, PowerPC::ppcState.gpr[i]);
strncat(regs, reg, sizeof(regs) - 1);
regs += StringFromFormat("r%02d: %08x ", i, PowerPC::ppcState.gpr[i]);
}
#endif
#ifdef JIT_LOG_FPR
for (int i = 0; i < 32; i++)
{
char reg[50];
sprintf(reg, "f%02d: %016x ", i, riPS0(i));
strncat(fregs, reg, sizeof(fregs) - 1);
fregs += StringFromFormat("f%02d: %016x ", i, riPS0(i));
}
#endif
DEBUG_LOG(DYNA_REC, "JIT64 PC: %08x SRR0: %08x SRR1: %08x CRfast: %02x%02x%02x%02x%02x%02x%02x%02x FPSCR: %08x MSR: %08x LR: %08x %s %s",
PC, SRR0, SRR1, PowerPC::ppcState.cr_fast[0], PowerPC::ppcState.cr_fast[1], PowerPC::ppcState.cr_fast[2], PowerPC::ppcState.cr_fast[3],
PowerPC::ppcState.cr_fast[4], PowerPC::ppcState.cr_fast[5], PowerPC::ppcState.cr_fast[6], PowerPC::ppcState.cr_fast[7], PowerPC::ppcState.fpscr,
PowerPC::ppcState.msr, PowerPC::ppcState.spr[8], regs, fregs);
PowerPC::ppcState.msr, PowerPC::ppcState.spr[8], regs.c_str(), fregs.c_str());
}
void STACKALIGN Jit64::Jit(u32 em_address)

View file

@ -6,9 +6,11 @@
#include <ctime> // For profiling
#include <map>
#include <memory>
#include <string>
#include "Common/Common.h"
#include "Common/StdMakeUnique.h"
#include "Common/StringUtil.h"
#include "Core/PatchEngine.h"
#include "Core/HLE/HLE.h"
#include "Core/PowerPC/Profiler.h"
@ -205,9 +207,8 @@ namespace JitILProfiler
{
virtual ~JitILProfilerFinalizer()
{
char buffer[1024];
sprintf(buffer, "JitIL_profiling_%d.csv", (int)time(nullptr));
File::IOFile file(buffer, "w");
std::string filename = StringFromFormat("JitIL_profiling_%d.csv", (int)time(nullptr));
File::IOFile file(filename, "w");
setvbuf(file.GetHandle(), nullptr, _IOFBF, 1024 * 1024);
fprintf(file.GetHandle(), "code hash,total elapsed,number of calls,elapsed per call\n");
for (auto& block : blocks)
@ -464,31 +465,27 @@ void JitIL::SingleStep()
void JitIL::Trace()
{
char regs[500] = "";
char fregs[750] = "";
std::string regs;
std::string fregs;
#ifdef JIT_LOG_GPR
for (int i = 0; i < 32; i++)
{
char reg[50];
sprintf(reg, "r%02d: %08x ", i, PowerPC::ppcState.gpr[i]);
strncat(regs, reg, sizeof(regs) - 1);
regs += StringFromFormat("r%02d: %08x ", i, PowerPC::ppcState.gpr[i]);
}
#endif
#ifdef JIT_LOG_FPR
for (int i = 0; i < 32; i++)
{
char reg[50];
sprintf(reg, "f%02d: %016x ", i, riPS0(i));
strncat(fregs, reg, sizeof(fregs) - 1);
fregs += StringFromFormat("f%02d: %016x ", i, riPS0(i));
}
#endif
DEBUG_LOG(DYNA_REC, "JITIL PC: %08x SRR0: %08x SRR1: %08x CRfast: %02x%02x%02x%02x%02x%02x%02x%02x FPSCR: %08x MSR: %08x LR: %08x %s %s",
PC, SRR0, SRR1, PowerPC::ppcState.cr_fast[0], PowerPC::ppcState.cr_fast[1], PowerPC::ppcState.cr_fast[2], PowerPC::ppcState.cr_fast[3],
PowerPC::ppcState.cr_fast[4], PowerPC::ppcState.cr_fast[5], PowerPC::ppcState.cr_fast[6], PowerPC::ppcState.cr_fast[7], PowerPC::ppcState.fpscr,
PowerPC::ppcState.msr, PowerPC::ppcState.spr[8], regs, fregs);
PowerPC::ppcState.msr, PowerPC::ppcState.spr[8], regs.c_str(), fregs.c_str());
}
void STACKALIGN JitIL::Jit(u32 em_address)

View file

@ -3,10 +3,12 @@
// Refer to the license.txt file included.
#include <sstream>
#include <string>
#include "disasm.h"
#include "PowerPCDisasm.h"
#include "Common/StringUtil.h"
#include "Core/PowerPC/JitCommon/JitBase.h"
JitBase *jit;
@ -27,15 +29,15 @@ u32 Helper_Mask(u8 mb, u8 me)
void LogGeneratedX86(int size, PPCAnalyst::CodeBuffer *code_buffer, const u8 *normalEntry, JitBlock *b)
{
char pDis[1000] = "";
std::string ppcdisasm;
for (int i = 0; i < size; i++)
{
char temp[256] = "";
const PPCAnalyst::CodeOp &op = code_buffer->codebuffer[i];
DisassembleGekko(op.inst.hex, op.address, temp, 256);
sprintf(pDis, "%08x %s", op.address, temp);
DEBUG_LOG(DYNA_REC,"IR_X86 PPC: %s\n", pDis);
ppcdisasm += StringFromFormat("%08x %s", op.address, temp);
DEBUG_LOG(DYNA_REC, "IR_X86 PPC: %s\n", ppcdisasm.c_str());
}
disassembler x64disasm;

View file

@ -124,8 +124,10 @@ TODO (in no particular order):
#include <ctime>
#include <memory>
#include <set>
#include <string>
#include "Common/StdMakeUnique.h"
#include "Common/StringUtil.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/HW/GPFifo.h"
@ -1220,9 +1222,8 @@ struct Writer
File::IOFile file;
Writer() : file(nullptr)
{
char buffer[1024];
sprintf(buffer, "JitIL_IR_%d.txt", (int)time(nullptr));
file.Open(buffer, "w");
std::string filename = StringFromFormat("JitIL_IR_%d.txt", (int)time(nullptr));
file.Open(filename, "w");
setvbuf(file.GetHandle(), nullptr, _IOFBF, 1024 * 1024);
}

View file

@ -24,15 +24,12 @@ CBannerLoaderWii::CBannerLoaderWii(DiscIO::IVolume *pVolume)
: m_pBannerFile(nullptr)
, m_IsValid(false)
{
char Filename[260];
u64 TitleID;
pVolume->GetTitleID((u8*)&TitleID);
TitleID = Common::swap64(TitleID);
sprintf(Filename, "%stitle/%08x/%08x/data/banner.bin",
File::GetUserPath(D_WIIUSER_IDX).c_str(), (u32)(TitleID>>32), (u32)TitleID);
std::string Filename = StringFromFormat("%stitle/%08x/%08x/data/banner.bin",
File::GetUserPath(D_WIIUSER_IDX).c_str(), (u32)(TitleID>>32), (u32)TitleID);
if (!File::Exists(Filename))
{
@ -40,26 +37,26 @@ CBannerLoaderWii::CBannerLoaderWii(DiscIO::IVolume *pVolume)
// from the savefiles is very different from the banner.bin
// inside opening.bnr
#if 0
char bnrFilename[260], titleFolder[260];
// Creating title folder
sprintf(titleFolder, "%stitle/%08x/%08x/data/",
std::string titleFolder = StringFromFormat("%stitle/%08x/%08x/data/",
File::GetUserPath(D_WIIUSER_IDX).c_str(), (u32)(TitleID>>32), (u32)TitleID);
if (!File::Exists(titleFolder))
File::CreateFullPath(titleFolder);
// Extracting banner.bin from opening.bnr
sprintf(bnrFilename, "%stitle/%08x/%08x/data/opening.bnr",
std::string bnrFilename = StringFromFormat("%stitle/%08x/%08x/data/opening.bnr",
File::GetUserPath(D_WIIUSER_IDX).c_str(), (u32)(TitleID>>32), (u32)TitleID);
if (!_rFileSystem.ExportFile("opening.bnr", bnrFilename)) {
if (!_rFileSystem.ExportFile("opening.bnr", bnrFilename))
{
m_IsValid = false;
return;
}
CARCFile bnrArc (bnrFilename, 0x600);
if (!bnrArc.ExportFile("meta/banner.bin", Filename)) {
if (!bnrArc.ExportFile("meta/banner.bin", Filename))
{
m_IsValid = false;
return;
}

View file

@ -66,7 +66,7 @@ public:
// Factory function - examines the path to choose the right type of IBlobReader, and returns one.
IBlobReader* CreateBlobReader(const std::string& filename);
typedef void (*CompressCB)(const char *text, float percent, void* arg);
typedef void (*CompressCB)(const std::string& text, float percent, void* arg);
bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u32 sub_type = 0, int sector_size = 16384,
CompressCB callback = nullptr, void *arg = nullptr);

View file

@ -17,6 +17,7 @@
#include "Common/Common.h"
#include "Common/FileUtil.h"
#include "Common/Hash.h"
#include "Common/StringUtil.h"
#include "DiscIO/Blob.h"
#include "DiscIO/CompressedBlob.h"
#include "DiscIO/DiscScrubber.h"
@ -203,8 +204,8 @@ bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u
int ratio = 0;
if (inpos != 0)
ratio = (int)(100 * position / inpos);
char temp[512];
sprintf(temp, "%i of %i blocks. Compression ratio %i%%", i, header.num_blocks, ratio);
std::string temp = StringFromFormat("%i of %i blocks. Compression ratio %i%%", i, header.num_blocks, ratio);
callback(temp, (float)i / (float)header.num_blocks, arg);
}

View file

@ -38,7 +38,7 @@ void CSharedContent::UpdateLocation()
{
m_Elements.clear();
lastID = 0;
sprintf(contentMap, "%sshared1/content.map", File::GetUserPath(D_WIIUSER_IDX).c_str());
contentMap = StringFromFormat("%sshared1/content.map", File::GetUserPath(D_WIIUSER_IDX).c_str());
File::IOFile pFile(contentMap, "rb");
SElement Element;
@ -58,11 +58,9 @@ std::string CSharedContent::GetFilenameFromSHA1(const u8* _pHash)
{
if (memcmp(_pHash, Element.SHA1Hash, 20) == 0)
{
char szFilename[1024];
sprintf(szFilename, "%sshared1/%c%c%c%c%c%c%c%c.app", File::GetUserPath(D_WIIUSER_IDX).c_str(),
Element.FileName[0], Element.FileName[1], Element.FileName[2], Element.FileName[3],
Element.FileName[4], Element.FileName[5], Element.FileName[6], Element.FileName[7]);
return szFilename;
return StringFromFormat("%sshared1/%c%c%c%c%c%c%c%c.app", File::GetUserPath(D_WIIUSER_IDX).c_str(),
Element.FileName[0], Element.FileName[1], Element.FileName[2], Element.FileName[3],
Element.FileName[4], Element.FileName[5], Element.FileName[6], Element.FileName[7]);
}
}
return "unk";
@ -70,13 +68,13 @@ std::string CSharedContent::GetFilenameFromSHA1(const u8* _pHash)
std::string CSharedContent::AddSharedContent(const u8* _pHash)
{
std::string szFilename = GetFilenameFromSHA1(_pHash);
if (strcasecmp(szFilename.c_str(), "unk") == 0)
std::string filename = GetFilenameFromSHA1(_pHash);
if (strcasecmp(filename.c_str(), "unk") == 0)
{
char tempFilename[1024], c_ID[9];
std::string id = StringFromFormat("%08x", lastID);
SElement Element;
sprintf(c_ID, "%08x", lastID);
memcpy(Element.FileName, c_ID, 8);
memcpy(Element.FileName, id.c_str(), 8);
memcpy(Element.SHA1Hash, _pHash, 20);
m_Elements.push_back(Element);
@ -85,11 +83,11 @@ std::string CSharedContent::AddSharedContent(const u8* _pHash)
File::IOFile pFile(contentMap, "ab");
pFile.WriteArray(&Element, 1);
sprintf(tempFilename, "%sshared1/%s.app", File::GetUserPath(D_WIIUSER_IDX).c_str(), c_ID);
szFilename = tempFilename;
filename = StringFromFormat("%sshared1/%s.app", File::GetUserPath(D_WIIUSER_IDX).c_str(), id.c_str());
lastID++;
}
return szFilename;
return filename;
}
@ -97,9 +95,7 @@ std::string CSharedContent::AddSharedContent(const u8* _pHash)
class CNANDContentLoader : public INANDContentLoader
{
public:
CNANDContentLoader(const std::string& _rName);
virtual ~CNANDContentLoader();
bool IsValid() const override { return m_Valid; }
@ -122,7 +118,6 @@ public:
u8 GetCountryChar() const override {return m_Country; }
private:
bool m_Valid;
bool m_isWAD;
std::string m_Path;
@ -148,8 +143,6 @@ private:
};
CNANDContentLoader::CNANDContentLoader(const std::string& _rName)
: m_Valid(false)
, m_isWAD(false)
@ -222,8 +215,7 @@ bool CNANDContentLoader::Initialize(const std::string& _rName)
File::IOFile pTMDFile(TMDFileName, "rb");
if (!pTMDFile)
{
WARN_LOG(DISCIO, "CreateFromDirectory: error opening %s",
TMDFileName.c_str());
WARN_LOG(DISCIO, "CreateFromDirectory: error opening %s", TMDFileName.c_str());
return false;
}
u32 pTMDSize = (u32)File::GetSize(TMDFileName);
@ -374,10 +366,9 @@ void CNANDContentLoader::RemoveTitle() const
{
if (!(m_Content[i].m_Type & 0x8000)) // skip shared apps
{
char szFilename[1024];
sprintf(szFilename, "%s%08x.app", Common::GetTitleContentPath(m_TitleID).c_str(), m_Content[i].m_ContentID);
INFO_LOG(DISCIO, "Delete %s", szFilename);
File::Delete(szFilename);
std::string filename = StringFromFormat("%s%08x.app", Common::GetTitleContentPath(m_TitleID).c_str(), m_Content[i].m_ContentID);
INFO_LOG(DISCIO, "Delete %s", filename.c_str());
File::Delete(filename);
}
}
}
@ -392,7 +383,7 @@ void cUIDsys::UpdateLocation()
{
m_Elements.clear();
lastUID = 0x00001000;
sprintf(uidSys, "%ssys/uid.sys", File::GetUserPath(D_WIIUSER_IDX).c_str());
uidSys = StringFromFormat("%ssys/uid.sys", File::GetUserPath(D_WIIUSER_IDX).c_str());
File::IOFile pFile(uidSys, "rb");
SElement Element;
@ -411,7 +402,7 @@ void cUIDsys::UpdateLocation()
File::CreateFullPath(uidSys);
pFile.Open(uidSys, "wb");
if (!pFile.WriteArray(&Element, 1))
ERROR_LOG(DISCIO, "Failed to write to %s", uidSys);
ERROR_LOG(DISCIO, "Failed to write to %s", uidSys.c_str());
}
}
@ -491,15 +482,14 @@ u64 CNANDContentManager::Install_WiiWAD(std::string &fileName)
pTMDFile.WriteBytes(Content.m_Header, INANDContentLoader::CONTENT_HEADER_SIZE);
char APPFileName[1024];
std::string APPFileName;
if (Content.m_Type & 0x8000) //shared
{
sprintf(APPFileName, "%s",
CSharedContent::AccessInstance().AddSharedContent(Content.m_SHA1Hash).c_str());
APPFileName = CSharedContent::AccessInstance().AddSharedContent(Content.m_SHA1Hash);
}
else
{
sprintf(APPFileName, "%s%08x.app", ContentPath.c_str(), Content.m_ContentID);
APPFileName = StringFromFormat("%s%08x.app", ContentPath.c_str(), Content.m_ContentID);
}
if (!File::Exists(APPFileName))
@ -508,7 +498,7 @@ u64 CNANDContentManager::Install_WiiWAD(std::string &fileName)
File::IOFile pAPPFile(APPFileName, "wb");
if (!pAPPFile)
{
PanicAlertT("WAD installation failed: error creating %s", APPFileName);
PanicAlertT("WAD installation failed: error creating %s", APPFileName.c_str());
return 0;
}
@ -516,15 +506,10 @@ u64 CNANDContentManager::Install_WiiWAD(std::string &fileName)
}
else
{
INFO_LOG(DISCIO, "Content %s already exists.", APPFileName);
INFO_LOG(DISCIO, "Content %s already exists.", APPFileName.c_str());
}
}
pTMDFile.Close();
//Extract and copy WAD's ticket to ticket directory
if (!Add_Ticket(TitleID, ContentLoader.GetTIK(), ContentLoader.GetTIKSize()))
{
@ -534,7 +519,6 @@ u64 CNANDContentManager::Install_WiiWAD(std::string &fileName)
cUIDsys::AccessInstance().AddTitle(TitleID);
return TitleID;
}

View file

@ -68,30 +68,26 @@ public:
class CNANDContentManager
{
public:
static CNANDContentManager& Access() { return m_Instance; }
u64 Install_WiiWAD(std::string &fileName);
const INANDContentLoader& GetNANDLoader(const std::string& _rName, bool forceReload = false);
const INANDContentLoader& GetNANDLoader(u64 _titleId, bool forceReload = false);
bool RemoveTitle(u64 _titleID);
private:
CNANDContentManager() {};
~CNANDContentManager();
static CNANDContentManager m_Instance;
typedef std::map<std::string, INANDContentLoader*> CNANDContentMap;
CNANDContentMap m_Map;
};
class CSharedContent
{
public:
static CSharedContent& AccessInstance() { return m_Instance; }
std::string GetFilenameFromSHA1(const u8* _pHash);
@ -99,10 +95,7 @@ public:
void UpdateLocation();
private:
CSharedContent();
virtual ~CSharedContent();
#pragma pack(push,1)
@ -114,7 +107,7 @@ private:
#pragma pack(pop)
u32 lastID;
char contentMap[1024];
std::string contentMap;
std::vector<SElement> m_Elements;
static CSharedContent m_Instance;
};
@ -122,18 +115,15 @@ private:
class cUIDsys
{
public:
static cUIDsys& AccessInstance() { return m_Instance; }
u32 GetUIDFromTitle(u64 _Title);
void AddTitle(u64 _Title);
void GetTitleIDs(std::vector<u64>& _TitleIDs, bool _owned = false);
void UpdateLocation();
private:
cUIDsys();
virtual ~cUIDsys();
#pragma pack(push,1)
@ -143,8 +133,9 @@ private:
u8 UID[4];
};
#pragma pack(pop)
u32 lastUID;
char uidSys[1024];
std::string uidSys;
std::vector<SElement> m_Elements;
static cUIDsys m_Instance;
};

View file

@ -1070,12 +1070,12 @@ void CGameListCtrl::OnWiki(wxCommandEvent& WXUNUSED (event))
WxUtils::Launch(wikiUrl);
}
void CGameListCtrl::MultiCompressCB(const char* text, float percent, void* arg)
void CGameListCtrl::MultiCompressCB(const std::string& text, float percent, void* arg)
{
percent = (((float)m_currentItem) + percent) / (float)m_numberItem;
wxString textString(StrToWxStr(StringFromFormat("%s (%i/%i) - %s",
m_currentFilename.c_str(), (int)m_currentItem+1,
(int)m_numberItem, text)));
(int)m_numberItem, text.c_str())));
((wxProgressDialog*)arg)->Update((int)(percent*1000), textString);
}
@ -1180,7 +1180,7 @@ void CGameListCtrl::CompressSelection(bool _compress)
Update();
}
void CGameListCtrl::CompressCB(const char* text, float percent, void* arg)
void CGameListCtrl::CompressCB(const std::string& text, float percent, void* arg)
{
((wxProgressDialog*)arg)->
Update((int)(percent*1000), StrToWxStr(text));

View file

@ -113,6 +113,6 @@ private:
static size_t m_currentItem;
static std::string m_currentFilename;
static size_t m_numberItem;
static void CompressCB(const char* text, float percent, void* arg);
static void MultiCompressCB(const char* text, float percent, void* arg);
static void CompressCB(const std::string& text, float percent, void* arg);
static void MultiCompressCB(const std::string& text, float percent, void* arg);
};

View file

@ -4,6 +4,7 @@
#include <string>
#include "Common/StringUtil.h"
#include "VideoBackends/D3D/D3DBase.h"
#include "VideoBackends/D3D/D3DShader.h"
#include "VideoCommon/VideoConfig.h"
@ -47,17 +48,16 @@ bool CompileVertexShader(const char* code, unsigned int len, D3DBlob** blob)
if (FAILED(hr))
{
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::string filename = StringFromFormat("%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
OpenFStream(file, filename, std::ios_base::out);
file << code;
file.close();
PanicAlert("Failed to compile vertex shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s):\n%s",
szTemp,
filename.c_str(),
D3D::VertexShaderVersionString(),
(char*)errorBuffer->GetBufferPointer());
(const char*)errorBuffer->GetBufferPointer());
*blob = nullptr;
errorBuffer->Release();
@ -105,17 +105,16 @@ bool CompileGeometryShader(const char* code, unsigned int len, D3DBlob** blob,
if (FAILED(hr))
{
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_gs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::string filename = StringFromFormat("%sbad_gs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
OpenFStream(file, filename, std::ios_base::out);
file << code;
file.close();
PanicAlert("Failed to compile geometry shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s):\n%s",
szTemp,
filename.c_str(),
D3D::GeometryShaderVersionString(),
(char*)errorBuffer->GetBufferPointer());
(const char*)errorBuffer->GetBufferPointer());
*blob = nullptr;
errorBuffer->Release();
@ -165,17 +164,16 @@ bool CompilePixelShader(const char* code, unsigned int len, D3DBlob** blob,
if (FAILED(hr))
{
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::string filename = StringFromFormat("%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
OpenFStream(file, filename, std::ios_base::out);
file << code;
file.close();
PanicAlert("Failed to compile pixel shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s):\n%s",
szTemp,
filename.c_str(),
D3D::PixelShaderVersionString(),
(char*)errorBuffer->GetBufferPointer());
(const char*)errorBuffer->GetBufferPointer());
*blob = nullptr;
errorBuffer->Release();

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <string>
#include "Common/FileUtil.h"
#include "Common/LinearDiskCache.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
@ -396,8 +399,7 @@ void PixelShaderCache::Init()
SETSTAT(stats.numPixelShadersCreated, 0);
SETSTAT(stats.numPixelShadersAlive, 0);
char cache_filename[MAX_PATH];
sprintf(cache_filename, "%sdx11-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
std::string cache_filename = StringFromFormat("%sdx11-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
PixelShaderCacheInserter inserter;
g_ps_disk_cache.OpenAndRead(cache_filename, inserter);

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
#include <string>
#include "Common/FileUtil.h"
#include "Common/LinearDiskCache.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
@ -143,8 +146,7 @@ void VertexShaderCache::Init()
SETSTAT(stats.numVertexShadersCreated, 0);
SETSTAT(stats.numVertexShadersAlive, 0);
char cache_filename[MAX_PATH];
sprintf(cache_filename, "%sdx11-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
std::string cache_filename = StringFromFormat("%sdx11-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
VertexShaderCacheInserter inserter;
g_vs_disk_cache.OpenAndRead(cache_filename, inserter);

View file

@ -108,15 +108,18 @@ void InitBackendInfo()
// TODO: These don't get updated on adapter change, yet
if (adapter_index == g_Config.iAdapter)
{
char buf[32];
std::vector<DXGI_SAMPLE_DESC> modes;
modes = DX11::D3D::EnumAAModes(ad);
std::string samples;
std::vector<DXGI_SAMPLE_DESC> modes = DX11::D3D::EnumAAModes(ad);
for (unsigned int i = 0; i < modes.size(); ++i)
{
if (i == 0) sprintf_s(buf, 32, _trans("None"));
else if (modes[i].Quality) sprintf_s(buf, 32, _trans("%d samples (quality level %d)"), modes[i].Count, modes[i].Quality);
else sprintf_s(buf, 32, _trans("%d samples"), modes[i].Count);
g_Config.backend_info.AAModes.push_back(buf);
if (i == 0)
samples = _trans("None");
else if (modes[i].Quality)
samples = StringFromFormat(_trans("%d samples (quality level %d)"), modes[i].Count, modes[i].Quality);
else
samples = StringFromFormat(_trans("%d samples"), modes[i].Count);
g_Config.backend_info.AAModes.push_back(samples);
}
// Requires the earlydepthstencil attribute (only available in shader model 5)

View file

@ -5,6 +5,7 @@
#include <string>
#include "Common/MathUtil.h"
#include "Common/StringUtil.h"
#include "VideoBackends/OGL/ProgramShaderCache.h"
#include "VideoBackends/OGL/Render.h"
@ -204,13 +205,14 @@ SHADER* ProgramShaderCache::SetShader ( DSTALPHA_MODE dstAlphaMode, u32 componen
}
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_ActiveConfig.iLog & CONF_SAVESHADERS) {
if (g_ActiveConfig.iLog & CONF_SAVESHADERS)
{
static int counter = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%svs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
SaveData(szTemp, vcode.GetBuffer());
sprintf(szTemp, "%sps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
SaveData(szTemp, pcode.GetBuffer());
std::string filename = StringFromFormat("%svs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
SaveData(filename, vcode.GetBuffer());
filename = StringFromFormat("%sps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
SaveData(filename, pcode.GetBuffer());
}
#endif
@ -265,16 +267,16 @@ bool ProgramShaderCache::CompileShader ( SHADER& shader, const char* vcode, cons
GLchar* infoLog = new GLchar[length];
glGetProgramInfoLog(pid, length, &charsWritten, infoLog);
ERROR_LOG(VIDEO, "Program info log:\n%s", infoLog);
char szTemp[MAX_PATH];
sprintf(szTemp, "%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::string filename = StringFromFormat("%sbad_p_%d.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
OpenFStream(file, filename, std::ios_base::out);
file << s_glsl_header << vcode << s_glsl_header << pcode << infoLog;
file.close();
if (linkStatus != GL_TRUE)
PanicAlert("Failed to link shaders!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s, %s, %s):\n%s",
szTemp,
filename.c_str(),
g_ogl_config.gl_vendor,
g_ogl_config.gl_renderer,
g_ogl_config.gl_version,
@ -319,21 +321,20 @@ GLuint ProgramShaderCache::CompileSingleShader (GLuint type, const char* code )
GLchar* infoLog = new GLchar[length];
glGetShaderInfoLog(result, length, &charsWritten, infoLog);
ERROR_LOG(VIDEO, "%s Shader info log:\n%s", type==GL_VERTEX_SHADER ? "VS" : "PS", infoLog);
char szTemp[MAX_PATH];
sprintf(szTemp,
"%sbad_%s_%04i.txt",
std::string filename = StringFromFormat("%sbad_%s_%04i.txt",
File::GetUserPath(D_DUMP_IDX).c_str(),
type==GL_VERTEX_SHADER ? "vs" : "ps",
num_failures++);
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
OpenFStream(file, filename, std::ios_base::out);
file << s_glsl_header << code << infoLog;
file.close();
if (compileStatus != GL_TRUE)
PanicAlert("Failed to compile %s shader!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%s, %s, %s):\n%s",
type==GL_VERTEX_SHADER ? "vertex" : "pixel",
szTemp,
filename.c_str(),
g_ogl_config.gl_vendor,
g_ogl_config.gl_renderer,
g_ogl_config.gl_version,
@ -405,8 +406,7 @@ void ProgramShaderCache::Init(void)
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
char cache_filename[MAX_PATH];
sprintf(cache_filename, "%sogl-%s-shaders.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
std::string cache_filename = StringFromFormat("%sogl-%s-shaders.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
ProgramShaderCacheInserter inserter;

View file

@ -4,7 +4,10 @@
// Fast image conversion using OpenGL shaders.
#include <string>
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
#include "Core/HW/Memmap.h"
@ -145,10 +148,9 @@ static SHADER &GetOrCreateEncodingShader(u32 format)
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && shader)
{
static int counter = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%senc_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
std::string filename = StringFromFormat("%senc_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
SaveData(szTemp, shader);
SaveData(filename, shader);
}
#endif

View file

@ -3,10 +3,12 @@
// Refer to the license.txt file included.
#include <fstream>
#include <string>
#include <vector>
#include "Common/FileUtil.h"
#include "Common/MemoryUtil.h"
#include "Common/StringUtil.h"
#include "VideoBackends/OGL/main.h"
#include "VideoBackends/OGL/ProgramShaderCache.h"
@ -185,27 +187,26 @@ void VertexManager::vFlush(bool useDstAlpha)
{
// save the shaders
ProgramShaderCache::PCacheEntry prog = ProgramShaderCache::GetShaderProgram();
char strfile[255];
sprintf(strfile, "%sps%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
std::string filename = StringFromFormat("%sps%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
std::ofstream fps;
OpenFStream(fps, strfile, std::ios_base::out);
OpenFStream(fps, filename, std::ios_base::out);
fps << prog.shader.strpprog.c_str();
sprintf(strfile, "%svs%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
filename = StringFromFormat("%svs%.3d.txt", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
std::ofstream fvs;
OpenFStream(fvs, strfile, std::ios_base::out);
OpenFStream(fvs, filename, std::ios_base::out);
fvs << prog.shader.strvprog.c_str();
}
if (g_ActiveConfig.iLog & CONF_SAVETARGETS)
{
char str[128];
sprintf(str, "%starg%.3d.png", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
std::string filename = StringFromFormat("%starg%.3d.png", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), g_ActiveConfig.iSaveTargetId);
TargetRectangle tr;
tr.left = 0;
tr.right = Renderer::GetTargetWidth();
tr.top = 0;
tr.bottom = Renderer::GetTargetHeight();
g_renderer->SaveScreenshot(str, tr);
g_renderer->SaveScreenshot(filename, tr);
}
#endif
g_Config.iSaveTargetId++;

View file

@ -3,8 +3,10 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <string>
#include "Common/Common.h"
#include "Common/StringUtil.h"
#include "Core/Core.h"
#include "VideoBackends/OGL/GLUtil.h"
#include "VideoBackends/Software/RasterFont.h"
@ -126,30 +128,28 @@ void SWRenderer::RenderText(const char* pstr, int left, int top, u32 color)
void SWRenderer::DrawDebugText()
{
char debugtext_buffer[8192];
char *p = debugtext_buffer;
p[0] = 0;
std::string debugtext;
if (g_SWVideoConfig.bShowStats)
{
p+=sprintf(p,"Objects: %i\n",swstats.thisFrame.numDrawnObjects);
p+=sprintf(p,"Primitives: %i\n",swstats.thisFrame.numPrimatives);
p+=sprintf(p,"Vertices Loaded: %i\n",swstats.thisFrame.numVerticesLoaded);
debugtext += StringFromFormat("Objects: %i\n", swstats.thisFrame.numDrawnObjects);
debugtext += StringFromFormat("Primitives: %i\n", swstats.thisFrame.numPrimatives);
debugtext += StringFromFormat("Vertices Loaded: %i\n", swstats.thisFrame.numVerticesLoaded);
p+=sprintf(p,"Triangles Input: %i\n",swstats.thisFrame.numTrianglesIn);
p+=sprintf(p,"Triangles Rejected: %i\n",swstats.thisFrame.numTrianglesRejected);
p+=sprintf(p,"Triangles Culled: %i\n",swstats.thisFrame.numTrianglesCulled);
p+=sprintf(p,"Triangles Clipped: %i\n",swstats.thisFrame.numTrianglesClipped);
p+=sprintf(p,"Triangles Drawn: %i\n",swstats.thisFrame.numTrianglesDrawn);
debugtext += StringFromFormat("Triangles Input: %i\n", swstats.thisFrame.numTrianglesIn);
debugtext += StringFromFormat("Triangles Rejected: %i\n", swstats.thisFrame.numTrianglesRejected);
debugtext += StringFromFormat("Triangles Culled: %i\n", swstats.thisFrame.numTrianglesCulled);
debugtext += StringFromFormat("Triangles Clipped: %i\n", swstats.thisFrame.numTrianglesClipped);
debugtext += StringFromFormat("Triangles Drawn: %i\n", swstats.thisFrame.numTrianglesDrawn);
p+=sprintf(p,"Rasterized Pix: %i\n",swstats.thisFrame.rasterizedPixels);
p+=sprintf(p,"TEV Pix In: %i\n",swstats.thisFrame.tevPixelsIn);
p+=sprintf(p,"TEV Pix Out: %i\n",swstats.thisFrame.tevPixelsOut);
debugtext += StringFromFormat("Rasterized Pix: %i\n", swstats.thisFrame.rasterizedPixels);
debugtext += StringFromFormat("TEV Pix In: %i\n", swstats.thisFrame.tevPixelsIn);
debugtext += StringFromFormat("TEV Pix Out: %i\n", swstats.thisFrame.tevPixelsOut);
}
// Render a shadow, and then the text.
SWRenderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
SWRenderer::RenderText(debugtext_buffer, 20, 20, 0xFFFFFF00);
SWRenderer::RenderText(debugtext.c_str(), 21, 21, 0xDD000000);
SWRenderer::RenderText(debugtext.c_str(), 20, 20, 0xFFFFFF00);
}
u8* SWRenderer::getColorTexture() {

View file

@ -6,6 +6,12 @@
#define __STDC_CONSTANT_MACROS 1
#endif
#include <string>
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/Log.h"
#include "Common/StringUtil.h"
#include "Core/HW/VideoInterface.h" //for TargetRefreshRate
#include "VideoCommon/AVIDump.h"
#include "VideoCommon/VideoConfig.h"
@ -19,10 +25,6 @@
#include <vfw.h>
#include <winerror.h>
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/Log.h"
HWND m_emuWnd;
LONG m_byteBuffer;
LONG m_frameCount;
@ -53,22 +55,23 @@ bool AVIDump::CreateFile()
{
m_totalBytes = 0;
m_frameCount = 0;
char movie_file_name[255];
sprintf(movie_file_name, "%sframedump%d.avi", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), m_fileCount);
std::string movie_file_name = StringFromFormat("%sframedump%d.avi", File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), m_fileCount);
// Create path
File::CreateFullPath(movie_file_name);
// Ask to delete file
if (File::Exists(movie_file_name))
{
if (AskYesNoT("Delete the existing file '%s'?", movie_file_name))
if (AskYesNoT("Delete the existing file '%s'?", movie_file_name.c_str()))
File::Delete(movie_file_name);
}
AVIFileInit();
NOTICE_LOG(VIDEO, "Opening AVI file (%s) for dumping", movie_file_name);
NOTICE_LOG(VIDEO, "Opening AVI file (%s) for dumping", movie_file_name.c_str());
// TODO: Make this work with AVIFileOpenW without it throwing REGDB_E_CLASSNOTREG
HRESULT hr = AVIFileOpenA(&m_file, movie_file_name, OF_WRITE | OF_CREATE, nullptr);
HRESULT hr = AVIFileOpenA(&m_file, movie_file_name.c_str(), OF_WRITE | OF_CREATE, nullptr);
if (FAILED(hr))
{
if (hr == AVIERR_BADFORMAT) NOTICE_LOG(VIDEO, "The file couldn't be read, indicating a corrupt file or an unrecognized format.");
@ -204,10 +207,6 @@ bool AVIDump::SetVideoFormat()
#else
#include "Common/FileUtil.h"
#include "Common/Log.h"
#include "Common/StringUtil.h"
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>

View file

@ -3,13 +3,14 @@
// Refer to the license.txt file included.
#include <list>
#include <string>
#include <vector>
#include "png.h"
#include "Common/FileUtil.h"
#include "VideoCommon/ImageWrite.h"
bool SaveData(const char* filename, const char* data)
bool SaveData(const std::string& filename, const char* data)
{
std::ofstream f;
OpenFStream(f, filename, std::ios::binary);

View file

@ -4,7 +4,8 @@
#pragma once
#include <string>
#include "Common/Common.h"
bool SaveData(const char* filename, const char* pdata);
bool SaveData(const std::string& filename, const char* pdata);
bool TextureToPng(u8* data, int row_stride, const std::string& filename, int width, int height, bool saveAlpha = true);

View file

@ -219,22 +219,21 @@ u32 FifoCommandRunnable(u32 &command_size)
else
{
// TODO(Omega): Maybe dump FIFO to file on this error
char szTemp[1024];
sprintf(szTemp, "GFX FIFO: Unknown Opcode (0x%x).\n"
std::string temp = StringFromFormat(
"GFX FIFO: Unknown Opcode (0x%x).\n"
"This means one of the following:\n"
"* The emulated GPU got desynced, disabling dual core can help\n"
"* Command stream corrupted by some spurious memory bug\n"
"* This really is an unknown opcode (unlikely)\n"
"* Some other sort of bug\n\n"
"Dolphin will now likely crash or hang. Enjoy." , cmd_byte);
Host_SysMessage(szTemp);
INFO_LOG(VIDEO, "%s", szTemp);
Host_SysMessage(temp.c_str());
INFO_LOG(VIDEO, "%s", temp.c_str());
{
SCPFifoStruct &fifo = CommandProcessor::fifo;
char szTmp[512];
// sprintf(szTmp, "Illegal command %02x (at %08x)",cmd_byte,g_pDataReader->GetPtr());
sprintf(szTmp, "Illegal command %02x\n"
std::string tmp = StringFromFormat(
"Illegal command %02x\n"
"CPBase: 0x%08x\n"
"CPEnd: 0x%08x\n"
"CPHiWatermark: 0x%08x\n"
@ -252,8 +251,8 @@ u32 FifoCommandRunnable(u32 &command_size)
,fifo.bFF_BPEnable ? "true" : "false" ,fifo.bFF_BPInt ? "true" : "false"
,fifo.bFF_Breakpoint ? "true" : "false");
Host_SysMessage(szTmp);
INFO_LOG(VIDEO, "%s", szTmp);
Host_SysMessage(tmp.c_str());
INFO_LOG(VIDEO, "%s", tmp.c_str());
}
}
break;

View file

@ -12,6 +12,7 @@
#include <vector>
#include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
#include "VideoCommon/VideoCommon.h"
/**
@ -179,14 +180,12 @@ public:
{
static int num_failures = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%s%ssuid_mismatch_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(),
dump_prefix,
++num_failures);
std::string temp = StringFromFormat("%s%ssuid_mismatch_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(),
dump_prefix, ++num_failures);
// TODO: Should also dump uids
std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out);
OpenFStream(file, temp, std::ios_base::out);
file << "Old shader code:\n" << old_code;
file << "\n\nNew shader code:\n" << new_code.GetBuffer();
file << "\n\nShader uid:\n";
@ -206,9 +205,8 @@ public:
else
file << std::endl;
}
file.close();
ERROR_LOG(VIDEO, "%s shader uid mismatch! See %s for details", shader_type, szTemp);
ERROR_LOG(VIDEO, "%s shader uid mismatch! See %s for details", shader_type, temp.c_str());
}
}
}

View file

@ -3,9 +3,11 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <string>
#include "Common/FileUtil.h"
#include "Common/MemoryUtil.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
#include "Core/HW/Memmap.h"
@ -227,36 +229,34 @@ bool TextureCache::CheckForCustomTextureLODs(u64 tex_hash, int texformat, unsign
return false;
// Just checking if the necessary files exist, if they can't be loaded or have incorrect dimensions LODs will be black
char texBasePathTemp[MAX_PATH];
char texPathTemp[MAX_PATH];
sprintf(texBasePathTemp, "%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), (u32) (tex_hash & 0x00000000FFFFFFFFLL), texformat);
std::string texBasePathTemp = StringFromFormat("%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), (u32) (tex_hash & 0x00000000FFFFFFFFLL), texformat);
for (unsigned int level = 1; level < levels; ++level)
{
sprintf(texPathTemp, "%s_mip%u", texBasePathTemp, level);
std::string texPathTemp = StringFromFormat("%s_mip%u", texBasePathTemp.c_str(), level);
if (!HiresTextures::HiresTexExists(texPathTemp))
{
if (level > 1)
WARN_LOG(VIDEO, "Couldn't find custom texture LOD with index %u (filename: %s), disabling custom LODs for this texture", level, texPathTemp);
WARN_LOG(VIDEO, "Couldn't find custom texture LOD with index %u (filename: %s), disabling custom LODs for this texture", level, texPathTemp.c_str());
return false;
}
}
return true;
}
PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsigned int level, unsigned int& width, unsigned int& height)
{
char texPathTemp[MAX_PATH];
std::string texPathTemp;
unsigned int newWidth = 0;
unsigned int newHeight = 0;
u32 tex_hash_u32 = tex_hash & 0x00000000FFFFFFFFLL;
if (level == 0)
sprintf(texPathTemp, "%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), tex_hash_u32, texformat);
texPathTemp = StringFromFormat("%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), tex_hash_u32, texformat);
else
sprintf(texPathTemp, "%s_%08x_%i_mip%u", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), tex_hash_u32, texformat, level);
texPathTemp = StringFromFormat("%s_%08x_%i_mip%u", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), tex_hash_u32, texformat, level);
unsigned int required_size = 0;
PC_TexFormat ret = HiresTextures::GetHiresTex(texPathTemp, &newWidth, &newHeight, &required_size, texformat, temp_size, temp);
@ -273,11 +273,11 @@ PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsign
if (ret != PC_TEX_FMT_NONE)
{
if (level > 0 && (newWidth != width || newHeight != height))
ERROR_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. This mipmap layer _must_ be %dx%d.", newWidth, newHeight, texPathTemp, width, height);
ERROR_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. This mipmap layer _must_ be %dx%d.", newWidth, newHeight, texPathTemp.c_str(), width, height);
if (newWidth * height != newHeight * width)
ERROR_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. The aspect differs from the native size %dx%d.", newWidth, newHeight, texPathTemp, width, height);
ERROR_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. The aspect differs from the native size %dx%d.", newWidth, newHeight, texPathTemp.c_str(), width, height);
if (newWidth % width || newHeight % height)
WARN_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. Please use an integer upscaling factor based on the native size %dx%d.", newWidth, newHeight, texPathTemp, width, height);
WARN_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. Please use an integer upscaling factor based on the native size %dx%d.", newWidth, newHeight, texPathTemp.c_str(), width, height);
width = newWidth;
height = newHeight;