Kill off replaceable usages of s[n]printf.

This commit is contained in:
Lioncash 2014-06-03 01:08:54 -04:00
parent dccd9ead7d
commit ce54c1e571
29 changed files with 216 additions and 243 deletions

View File

@ -2,6 +2,9 @@
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <string>
#include "Common/StringUtil.h"
#include "Core/HW/SI_Device.h" #include "Core/HW/SI_Device.h"
#include "Core/HW/SI_DeviceAMBaseboard.h" #include "Core/HW/SI_DeviceAMBaseboard.h"
#include "Core/HW/SI_DeviceDanceMat.h" #include "Core/HW/SI_DeviceDanceMat.h"
@ -14,24 +17,24 @@
int ISIDevice::RunBuffer(u8* _pBuffer, int _iLength) int ISIDevice::RunBuffer(u8* _pBuffer, int _iLength)
{ {
#ifdef _DEBUG #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; int num = 0;
while (num < _iLength) while (num < _iLength)
{ {
char szTemp2[128] = ""; temp += StringFromFormat("0x%02x ", _pBuffer[num^3]);
sprintf(szTemp2, "0x%02x ", _pBuffer[num^3]);
strcat(szTemp, szTemp2);
num++; num++;
if ((num % 8) == 0) if ((num % 8) == 0)
{ {
DEBUG_LOG(SERIALINTERFACE, "%s", szTemp); DEBUG_LOG(SERIALINTERFACE, "%s", temp.c_str());
szTemp[0] = '\0'; temp.clear();
} }
} }
DEBUG_LOG(SERIALINTERFACE, "%s", szTemp);
DEBUG_LOG(SERIALINTERFACE, "%s", temp.c_str());
#endif #endif
return 0; 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) for (int i = 0; remoteHost->h_addr_list[i]; ++i)
{ {
u32 ip = Common::swap32(*(u32*)(remoteHost->h_addr_list[i])); u32 ip = Common::swap32(*(u32*)(remoteHost->h_addr_list[i]));
char ip_s[16]; std::string ip_s = StringFromFormat("%i.%i.%i.%i", ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
sprintf(ip_s, "%i.%i.%i.%i", DEBUG_LOG(WII_IPC_NET, "addr%i:%s", i, ip_s.c_str());
ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff);
DEBUG_LOG(WII_IPC_NET, "addr%i:%s", i, ip_s);
} }
Memory::Memset(BufferOut, 0, BufferOutSize); Memory::Memset(BufferOut, 0, BufferOutSize);

View File

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

View File

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

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <map> #include <map>
#include <string>
// for the PROFILER stuff // for the PROFILER stuff
#ifdef _WIN32 #ifdef _WIN32
@ -10,6 +11,7 @@
#endif #endif
#include "Common/Common.h" #include "Common/Common.h"
#include "Common/StringUtil.h"
#include "Core/PatchEngine.h" #include "Core/PatchEngine.h"
#include "Core/HLE/HLE.h" #include "Core/HLE/HLE.h"
#include "Core/HW/ProcessorInterface.h" #include "Core/HW/ProcessorInterface.h"
@ -363,31 +365,27 @@ void Jit64::SingleStep()
void Jit64::Trace() void Jit64::Trace()
{ {
char regs[500] = ""; std::string regs;
char fregs[750] = ""; std::string fregs;
#ifdef JIT_LOG_GPR #ifdef JIT_LOG_GPR
for (int i = 0; i < 32; i++) for (int i = 0; i < 32; i++)
{ {
char reg[50]; regs += StringFromFormat("r%02d: %08x ", i, PowerPC::ppcState.gpr[i]);
sprintf(reg, "r%02d: %08x ", i, PowerPC::ppcState.gpr[i]);
strncat(regs, reg, sizeof(regs) - 1);
} }
#endif #endif
#ifdef JIT_LOG_FPR #ifdef JIT_LOG_FPR
for (int i = 0; i < 32; i++) for (int i = 0; i < 32; i++)
{ {
char reg[50]; fregs += StringFromFormat("f%02d: %016x ", i, riPS0(i));
sprintf(reg, "f%02d: %016x ", i, riPS0(i));
strncat(fregs, reg, sizeof(fregs) - 1);
} }
#endif #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", 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], 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.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) void STACKALIGN Jit64::Jit(u32 em_address)

View File

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

View File

@ -3,10 +3,12 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <sstream> #include <sstream>
#include <string>
#include "disasm.h" #include "disasm.h"
#include "PowerPCDisasm.h" #include "PowerPCDisasm.h"
#include "Common/StringUtil.h"
#include "Core/PowerPC/JitCommon/JitBase.h" #include "Core/PowerPC/JitCommon/JitBase.h"
JitBase *jit; 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) 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++) for (int i = 0; i < size; i++)
{ {
char temp[256] = ""; char temp[256] = "";
const PPCAnalyst::CodeOp &op = code_buffer->codebuffer[i]; const PPCAnalyst::CodeOp &op = code_buffer->codebuffer[i];
DisassembleGekko(op.inst.hex, op.address, temp, 256); DisassembleGekko(op.inst.hex, op.address, temp, 256);
sprintf(pDis, "%08x %s", op.address, temp); ppcdisasm += StringFromFormat("%08x %s", op.address, temp);
DEBUG_LOG(DYNA_REC,"IR_X86 PPC: %s\n", pDis); DEBUG_LOG(DYNA_REC, "IR_X86 PPC: %s\n", ppcdisasm.c_str());
} }
disassembler x64disasm; disassembler x64disasm;

View File

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

View File

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

View File

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

View File

@ -17,6 +17,7 @@
#include "Common/Common.h" #include "Common/Common.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/Hash.h" #include "Common/Hash.h"
#include "Common/StringUtil.h"
#include "DiscIO/Blob.h" #include "DiscIO/Blob.h"
#include "DiscIO/CompressedBlob.h" #include "DiscIO/CompressedBlob.h"
#include "DiscIO/DiscScrubber.h" #include "DiscIO/DiscScrubber.h"
@ -203,8 +204,8 @@ bool CompressFileToBlob(const std::string& infile, const std::string& outfile, u
int ratio = 0; int ratio = 0;
if (inpos != 0) if (inpos != 0)
ratio = (int)(100 * position / inpos); 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); callback(temp, (float)i / (float)header.num_blocks, arg);
} }

View File

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

View File

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

View File

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

View File

@ -113,6 +113,6 @@ private:
static size_t m_currentItem; static size_t m_currentItem;
static std::string m_currentFilename; static std::string m_currentFilename;
static size_t m_numberItem; static size_t m_numberItem;
static void CompressCB(const char* text, float percent, void* arg); static void CompressCB(const std::string& text, float percent, void* arg);
static void MultiCompressCB(const char* 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 <string>
#include "Common/StringUtil.h"
#include "VideoBackends/D3D/D3DBase.h" #include "VideoBackends/D3D/D3DBase.h"
#include "VideoBackends/D3D/D3DShader.h" #include "VideoBackends/D3D/D3DShader.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
@ -47,17 +48,16 @@ bool CompileVertexShader(const char* code, unsigned int len, D3DBlob** blob)
if (FAILED(hr)) if (FAILED(hr))
{ {
static int num_failures = 0; static int num_failures = 0;
char szTemp[MAX_PATH]; std::string filename = StringFromFormat("%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
sprintf(szTemp, "%sbad_vs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file; std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out); OpenFStream(file, filename, std::ios_base::out);
file << code; file << code;
file.close(); 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", 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(), D3D::VertexShaderVersionString(),
(char*)errorBuffer->GetBufferPointer()); (const char*)errorBuffer->GetBufferPointer());
*blob = nullptr; *blob = nullptr;
errorBuffer->Release(); errorBuffer->Release();
@ -105,17 +105,16 @@ bool CompileGeometryShader(const char* code, unsigned int len, D3DBlob** blob,
if (FAILED(hr)) if (FAILED(hr))
{ {
static int num_failures = 0; static int num_failures = 0;
char szTemp[MAX_PATH]; std::string filename = StringFromFormat("%sbad_gs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
sprintf(szTemp, "%sbad_gs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file; std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out); OpenFStream(file, filename, std::ios_base::out);
file << code; file << code;
file.close(); 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", 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(), D3D::GeometryShaderVersionString(),
(char*)errorBuffer->GetBufferPointer()); (const char*)errorBuffer->GetBufferPointer());
*blob = nullptr; *blob = nullptr;
errorBuffer->Release(); errorBuffer->Release();
@ -165,17 +164,16 @@ bool CompilePixelShader(const char* code, unsigned int len, D3DBlob** blob,
if (FAILED(hr)) if (FAILED(hr))
{ {
static int num_failures = 0; static int num_failures = 0;
char szTemp[MAX_PATH]; std::string filename = StringFromFormat("%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
sprintf(szTemp, "%sbad_ps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), num_failures++);
std::ofstream file; std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out); OpenFStream(file, filename, std::ios_base::out);
file << code; file << code;
file.close(); 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", 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(), D3D::PixelShaderVersionString(),
(char*)errorBuffer->GetBufferPointer()); (const char*)errorBuffer->GetBufferPointer());
*blob = nullptr; *blob = nullptr;
errorBuffer->Release(); errorBuffer->Release();

View File

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

View File

@ -2,8 +2,11 @@
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <string>
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/LinearDiskCache.h" #include "Common/LinearDiskCache.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
@ -143,8 +146,7 @@ void VertexShaderCache::Init()
SETSTAT(stats.numVertexShadersCreated, 0); SETSTAT(stats.numVertexShadersCreated, 0);
SETSTAT(stats.numVertexShadersAlive, 0); SETSTAT(stats.numVertexShadersAlive, 0);
char cache_filename[MAX_PATH]; std::string cache_filename = StringFromFormat("%sdx11-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
sprintf(cache_filename, "%sdx11-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
VertexShaderCacheInserter inserter; VertexShaderCacheInserter inserter;
g_vs_disk_cache.OpenAndRead(cache_filename, 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 // TODO: These don't get updated on adapter change, yet
if (adapter_index == g_Config.iAdapter) if (adapter_index == g_Config.iAdapter)
{ {
char buf[32]; std::string samples;
std::vector<DXGI_SAMPLE_DESC> modes; std::vector<DXGI_SAMPLE_DESC> modes = DX11::D3D::EnumAAModes(ad);
modes = DX11::D3D::EnumAAModes(ad);
for (unsigned int i = 0; i < modes.size(); ++i) for (unsigned int i = 0; i < modes.size(); ++i)
{ {
if (i == 0) sprintf_s(buf, 32, _trans("None")); if (i == 0)
else if (modes[i].Quality) sprintf_s(buf, 32, _trans("%d samples (quality level %d)"), modes[i].Count, modes[i].Quality); samples = _trans("None");
else sprintf_s(buf, 32, _trans("%d samples"), modes[i].Count); else if (modes[i].Quality)
g_Config.backend_info.AAModes.push_back(buf); 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) // Requires the earlydepthstencil attribute (only available in shader model 5)

View File

@ -5,6 +5,7 @@
#include <string> #include <string>
#include "Common/MathUtil.h" #include "Common/MathUtil.h"
#include "Common/StringUtil.h"
#include "VideoBackends/OGL/ProgramShaderCache.h" #include "VideoBackends/OGL/ProgramShaderCache.h"
#include "VideoBackends/OGL/Render.h" #include "VideoBackends/OGL/Render.h"
@ -204,13 +205,14 @@ SHADER* ProgramShaderCache::SetShader ( DSTALPHA_MODE dstAlphaMode, u32 componen
} }
#if defined(_DEBUG) || defined(DEBUGFAST) #if defined(_DEBUG) || defined(DEBUGFAST)
if (g_ActiveConfig.iLog & CONF_SAVESHADERS) { if (g_ActiveConfig.iLog & CONF_SAVESHADERS)
{
static int counter = 0; static int counter = 0;
char szTemp[MAX_PATH]; std::string filename = StringFromFormat("%svs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
sprintf(szTemp, "%svs_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++); SaveData(filename, vcode.GetBuffer());
SaveData(szTemp, vcode.GetBuffer());
sprintf(szTemp, "%sps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++); filename = StringFromFormat("%sps_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), counter++);
SaveData(szTemp, pcode.GetBuffer()); SaveData(filename, pcode.GetBuffer());
} }
#endif #endif
@ -265,16 +267,16 @@ bool ProgramShaderCache::CompileShader ( SHADER& shader, const char* vcode, cons
GLchar* infoLog = new GLchar[length]; GLchar* infoLog = new GLchar[length];
glGetProgramInfoLog(pid, length, &charsWritten, infoLog); glGetProgramInfoLog(pid, length, &charsWritten, infoLog);
ERROR_LOG(VIDEO, "Program info log:\n%s", 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; 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 << s_glsl_header << vcode << s_glsl_header << pcode << infoLog;
file.close(); file.close();
if (linkStatus != GL_TRUE) 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", 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_vendor,
g_ogl_config.gl_renderer, g_ogl_config.gl_renderer,
g_ogl_config.gl_version, g_ogl_config.gl_version,
@ -319,21 +321,20 @@ GLuint ProgramShaderCache::CompileSingleShader (GLuint type, const char* code )
GLchar* infoLog = new GLchar[length]; GLchar* infoLog = new GLchar[length];
glGetShaderInfoLog(result, length, &charsWritten, infoLog); glGetShaderInfoLog(result, length, &charsWritten, infoLog);
ERROR_LOG(VIDEO, "%s Shader info log:\n%s", type==GL_VERTEX_SHADER ? "VS" : "PS", infoLog); ERROR_LOG(VIDEO, "%s Shader info log:\n%s", type==GL_VERTEX_SHADER ? "VS" : "PS", infoLog);
char szTemp[MAX_PATH];
sprintf(szTemp, std::string filename = StringFromFormat("%sbad_%s_%04i.txt",
"%sbad_%s_%04i.txt",
File::GetUserPath(D_DUMP_IDX).c_str(), File::GetUserPath(D_DUMP_IDX).c_str(),
type==GL_VERTEX_SHADER ? "vs" : "ps", type==GL_VERTEX_SHADER ? "vs" : "ps",
num_failures++); num_failures++);
std::ofstream file; std::ofstream file;
OpenFStream(file, szTemp, std::ios_base::out); OpenFStream(file, filename, std::ios_base::out);
file << s_glsl_header << code << infoLog; file << s_glsl_header << code << infoLog;
file.close(); file.close();
if (compileStatus != GL_TRUE) 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", 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", type==GL_VERTEX_SHADER ? "vertex" : "pixel",
szTemp, filename.c_str(),
g_ogl_config.gl_vendor, g_ogl_config.gl_vendor,
g_ogl_config.gl_renderer, g_ogl_config.gl_renderer,
g_ogl_config.gl_version, g_ogl_config.gl_version,
@ -405,8 +406,7 @@ void ProgramShaderCache::Init(void)
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX))) if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX)); File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
char cache_filename[MAX_PATH]; std::string cache_filename = StringFromFormat("%sogl-%s-shaders.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
sprintf(cache_filename, "%sogl-%s-shaders.cache", File::GetUserPath(D_SHADERCACHE_IDX).c_str(),
SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str());
ProgramShaderCacheInserter inserter; ProgramShaderCacheInserter inserter;

View File

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

View File

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

View File

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

View File

@ -6,6 +6,12 @@
#define __STDC_CONSTANT_MACROS 1 #define __STDC_CONSTANT_MACROS 1
#endif #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 "Core/HW/VideoInterface.h" //for TargetRefreshRate
#include "VideoCommon/AVIDump.h" #include "VideoCommon/AVIDump.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
@ -19,10 +25,6 @@
#include <vfw.h> #include <vfw.h>
#include <winerror.h> #include <winerror.h>
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/Log.h"
HWND m_emuWnd; HWND m_emuWnd;
LONG m_byteBuffer; LONG m_byteBuffer;
LONG m_frameCount; LONG m_frameCount;
@ -53,22 +55,23 @@ bool AVIDump::CreateFile()
{ {
m_totalBytes = 0; m_totalBytes = 0;
m_frameCount = 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 // Create path
File::CreateFullPath(movie_file_name); File::CreateFullPath(movie_file_name);
// Ask to delete file // Ask to delete file
if (File::Exists(movie_file_name)) 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); File::Delete(movie_file_name);
} }
AVIFileInit(); 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 // 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 (FAILED(hr))
{ {
if (hr == AVIERR_BADFORMAT) NOTICE_LOG(VIDEO, "The file couldn't be read, indicating a corrupt file or an unrecognized format."); 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 #else
#include "Common/FileUtil.h"
#include "Common/Log.h"
#include "Common/StringUtil.h"
extern "C" { extern "C" {
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>

View File

@ -3,13 +3,14 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <list> #include <list>
#include <string>
#include <vector> #include <vector>
#include "png.h" #include "png.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "VideoCommon/ImageWrite.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; std::ofstream f;
OpenFStream(f, filename, std::ios::binary); OpenFStream(f, filename, std::ios::binary);

View File

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

View File

@ -12,6 +12,7 @@
#include <vector> #include <vector>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoCommon.h"
/** /**
@ -179,14 +180,12 @@ public:
{ {
static int num_failures = 0; static int num_failures = 0;
char szTemp[MAX_PATH]; std::string temp = StringFromFormat("%s%ssuid_mismatch_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(),
sprintf(szTemp, "%s%ssuid_mismatch_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(), dump_prefix, ++num_failures);
dump_prefix,
++num_failures);
// TODO: Should also dump uids // TODO: Should also dump uids
std::ofstream file; 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 << "Old shader code:\n" << old_code;
file << "\n\nNew shader code:\n" << new_code.GetBuffer(); file << "\n\nNew shader code:\n" << new_code.GetBuffer();
file << "\n\nShader uid:\n"; file << "\n\nShader uid:\n";
@ -206,9 +205,8 @@ public:
else else
file << std::endl; 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. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <string>
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/MemoryUtil.h" #include "Common/MemoryUtil.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h" #include "Core/ConfigManager.h"
#include "Core/HW/Memmap.h" #include "Core/HW/Memmap.h"
@ -227,36 +229,34 @@ bool TextureCache::CheckForCustomTextureLODs(u64 tex_hash, int texformat, unsign
return false; return false;
// Just checking if the necessary files exist, if they can't be loaded or have incorrect dimensions LODs will be black // 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]; std::string texBasePathTemp = StringFromFormat("%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), (u32) (tex_hash & 0x00000000FFFFFFFFLL), texformat);
char texPathTemp[MAX_PATH];
sprintf(texBasePathTemp, "%s_%08x_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), (u32) (tex_hash & 0x00000000FFFFFFFFLL), texformat);
for (unsigned int level = 1; level < levels; ++level) 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 (!HiresTextures::HiresTexExists(texPathTemp))
{ {
if (level > 1) 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 false;
} }
} }
return true; return true;
} }
PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsigned int level, unsigned int& width, unsigned int& height) 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 newWidth = 0;
unsigned int newHeight = 0; unsigned int newHeight = 0;
u32 tex_hash_u32 = tex_hash & 0x00000000FFFFFFFFLL; u32 tex_hash_u32 = tex_hash & 0x00000000FFFFFFFFLL;
if (level == 0) 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 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; unsigned int required_size = 0;
PC_TexFormat ret = HiresTextures::GetHiresTex(texPathTemp, &newWidth, &newHeight, &required_size, texformat, temp_size, temp); 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 (ret != PC_TEX_FMT_NONE)
{ {
if (level > 0 && (newWidth != width || newHeight != height)) 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) 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) 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; width = newWidth;
height = newHeight; height = newHeight;