clang-modernize -loop-convert

and some manual adjustments
This commit is contained in:
Tillmann Karras 2014-03-03 06:25:15 +01:00
parent f401263867
commit c89f04a7c5
22 changed files with 339 additions and 293 deletions

View File

@ -17,10 +17,10 @@ bool OpenALStream::Start()
{ {
bool bReturn = false; bool bReturn = false;
ALDeviceList *pDeviceList = new ALDeviceList(); ALDeviceList pDeviceList;
if ((pDeviceList) && (pDeviceList->GetNumDevices())) if (pDeviceList.GetNumDevices())
{ {
char *defDevName = pDeviceList->GetDeviceName(pDeviceList->GetDefaultDevice()); char *defDevName = pDeviceList.GetDeviceName(pDeviceList.GetDefaultDevice());
WARN_LOG(AUDIO, "Found OpenAL device %s", defDevName); WARN_LOG(AUDIO, "Found OpenAL device %s", defDevName);
@ -49,7 +49,6 @@ bool OpenALStream::Start()
{ {
PanicAlertT("OpenAL: can't open device %s", defDevName); PanicAlertT("OpenAL: can't open device %s", defDevName);
} }
delete pDeviceList;
} }
else else
{ {

View File

@ -12,15 +12,15 @@
void SymbolDB::List() void SymbolDB::List()
{ {
for (XFuncMap::iterator iter = functions.begin(); iter != functions.end(); ++iter) for (const auto& func : functions)
{ {
DEBUG_LOG(OSHLE, "%s @ %08x: %i bytes (hash %08x) : %i calls", DEBUG_LOG(OSHLE, "%s @ %08x: %i bytes (hash %08x) : %i calls",
iter->second.name.c_str(), iter->second.address, func.second.name.c_str(), func.second.address,
iter->second.size, iter->second.hash, func.second.size, func.second.hash,
iter->second.numCalls); func.second.numCalls);
} }
INFO_LOG(OSHLE, "%lu functions known in this program above.", INFO_LOG(OSHLE, "%lu functions known in this program above.",
(unsigned long)functions.size()); (unsigned long)functions.size());
} }
void SymbolDB::Clear(const char *prefix) void SymbolDB::Clear(const char *prefix)

View File

@ -492,7 +492,7 @@ const char* pdname(u16 val)
{ {
static char tmpstr[12]; // nasty static char tmpstr[12]; // nasty
for (auto& pdlabel : pdlabels) for (const pdlabel_t& pdlabel : pdlabels)
{ {
if (pdlabel.addr == val) if (pdlabel.addr == val)
return pdlabel.name; return pdlabel.name;
@ -527,31 +527,37 @@ void InitInstructionTable()
{ {
extOpTable[i] = &cw; extOpTable[i] = &cw;
for (auto& ext : opcodes_ext) for (const DSPOPCTemplate& ext : opcodes_ext)
{ {
u16 mask = ext.opcode_mask; u16 mask = ext.opcode_mask;
if ((mask & i) == ext.opcode) if ((mask & i) == ext.opcode)
{ {
if (extOpTable[i] == &cw) if (extOpTable[i] == &cw)
{
extOpTable[i] = &ext; extOpTable[i] = &ext;
}
else else
{ {
//if the entry already in the table //if the entry already in the table
//is a strict subset, allow it //is a strict subset, allow it
if ((extOpTable[i]->opcode_mask | ext.opcode_mask) != extOpTable[i]->opcode_mask) if ((extOpTable[i]->opcode_mask | ext.opcode_mask) != extOpTable[i]->opcode_mask)
{
ERROR_LOG(DSPLLE, "opcode ext table place %d already in use by %s when inserting %s", i, extOpTable[i]->name, ext.name); ERROR_LOG(DSPLLE, "opcode ext table place %d already in use by %s when inserting %s", i, extOpTable[i]->name, ext.name);
}
} }
} }
} }
} }
// op table // op table
for (int i = 0; i < OPTABLE_SIZE; i++) for (const DSPOPCTemplate*& opcode : opTable)
opTable[i] = &cw; {
opcode = &cw;
}
for (int i = 0; i < OPTABLE_SIZE; i++) for (int i = 0; i < OPTABLE_SIZE; i++)
{ {
for (auto& opcode : opcodes) for (const DSPOPCTemplate& opcode : opcodes)
{ {
u16 mask = opcode.opcode_mask; u16 mask = opcode.opcode_mask;
if ((mask & i) == opcode.opcode) if ((mask & i) == opcode.opcode)
@ -564,6 +570,8 @@ void InitInstructionTable()
} }
} }
for (int i=0; i < WRITEBACKLOGSIZE; i++) for (int& elem : writeBackLogIdx)
writeBackLogIdx[i] = -1; {
elem = -1;
}
} }

View File

@ -81,7 +81,7 @@ static void *reg_ptr(int reg)
DSPJitRegCache::DSPJitRegCache(DSPEmitter &_emitter) DSPJitRegCache::DSPJitRegCache(DSPEmitter &_emitter)
: emitter(_emitter), temporary(false), merged(false) : emitter(_emitter), temporary(false), merged(false)
{ {
for(auto& xreg : xregs) for (X64CachedReg& xreg : xregs)
{ {
xreg.guest_reg = DSP_REG_STATIC; xreg.guest_reg = DSP_REG_STATIC;
xreg.pushed = false; xreg.pushed = false;
@ -475,7 +475,7 @@ void DSPJitRegCache::pushRegs()
} }
int push_count = 0; int push_count = 0;
for(auto& xreg : xregs) for (X64CachedReg& xreg : xregs)
{ {
if (xreg.guest_reg == DSP_REG_USED) if (xreg.guest_reg == DSP_REG_USED)
push_count++; push_count++;
@ -533,7 +533,7 @@ void DSPJitRegCache::popRegs() {
emitter.MOV(32, M(&ebp_store), R(EBP)); emitter.MOV(32, M(&ebp_store), R(EBP));
#endif #endif
int push_count = 0; int push_count = 0;
for(auto& xreg : xregs) for (X64CachedReg& xreg : xregs)
{ {
if (xreg.pushed) if (xreg.pushed)
{ {
@ -1062,9 +1062,8 @@ X64Reg DSPJitRegCache::spillXReg()
{ {
int max_use_ctr_diff = 0; int max_use_ctr_diff = 0;
X64Reg least_recent_use_reg = INVALID_REG; X64Reg least_recent_use_reg = INVALID_REG;
for(size_t i = 0; i < sizeof(alloc_order)/sizeof(alloc_order[0]); i++) for (X64Reg reg : alloc_order)
{ {
X64Reg reg = alloc_order[i];
if (xregs[reg].guest_reg <= DSP_REG_MAX_MEM_BACKED && if (xregs[reg].guest_reg <= DSP_REG_MAX_MEM_BACKED &&
!regs[xregs[reg].guest_reg].used) !regs[xregs[reg].guest_reg].used)
{ {
@ -1084,9 +1083,8 @@ X64Reg DSPJitRegCache::spillXReg()
} }
//just choose one. //just choose one.
for(size_t i = 0; i < sizeof(alloc_order)/sizeof(alloc_order[0]); i++) for (X64Reg reg : alloc_order)
{ {
X64Reg reg = alloc_order[i];
if (xregs[reg].guest_reg <= DSP_REG_MAX_MEM_BACKED && if (xregs[reg].guest_reg <= DSP_REG_MAX_MEM_BACKED &&
!regs[xregs[reg].guest_reg].used) !regs[xregs[reg].guest_reg].used)
{ {
@ -1118,7 +1116,7 @@ void DSPJitRegCache::spillXReg(X64Reg reg)
X64Reg DSPJitRegCache::findFreeXReg() X64Reg DSPJitRegCache::findFreeXReg()
{ {
for(auto& x : alloc_order) for (X64Reg x : alloc_order)
{ {
if (xregs[x].guest_reg == DSP_REG_NONE) if (xregs[x].guest_reg == DSP_REG_NONE)
{ {

View File

@ -52,8 +52,7 @@ bool FifoDataFile::Save(const char *filename)
// Add space for frame list // Add space for frame list
u64 frameListOffset = file.Tell(); u64 frameListOffset = file.Tell();
for (size_t i = 0; i < m_Frames.size(); i++) PadFile(m_Frames.size() * sizeof(FileFrameInfo), file);
PadFile(sizeof(FileFrameInfo), file);
u64 bpMemOffset = file.Tell(); u64 bpMemOffset = file.Tell();
file.WriteArray(m_BPMem, BP_MEM_SIZE); file.WriteArray(m_BPMem, BP_MEM_SIZE);
@ -194,12 +193,10 @@ FifoDataFile *FifoDataFile::Load(const std::string &filename, bool flagsOnly)
return dataFile; return dataFile;
} }
void FifoDataFile::PadFile(u32 numBytes, File::IOFile &file) void FifoDataFile::PadFile(u32 numBytes, File::IOFile& file)
{ {
FILE *handle = file.GetHandle(); const u8 zero = 0;
fwrite(&zero, sizeof(zero), numBytes, file.GetHandle());
for (u32 i = 0; i < numBytes; ++i)
fputc(0, handle);
} }
void FifoDataFile::SetFlag(u32 flag, bool set) void FifoDataFile::SetFlag(u32 flag, bool set)
@ -219,8 +216,7 @@ u64 FifoDataFile::WriteMemoryUpdates(const std::vector<MemoryUpdate> &memUpdates
{ {
// Add space for memory update list // Add space for memory update list
u64 updateListOffset = file.Tell(); u64 updateListOffset = file.Tell();
for (size_t i = 0; i < memUpdates.size(); i++) PadFile(memUpdates.size() * sizeof(FileMemoryUpdate), file);
PadFile(sizeof(FileMemoryUpdate), file);
for (unsigned int i = 0; i < memUpdates.size(); ++i) for (unsigned int i = 0; i < memUpdates.size(); ++i)
{ {

View File

@ -20,8 +20,8 @@ CUCode_AXWii::CUCode_AXWii(DSPHLE *dsp_hle, u32 l_CRC)
: CUCode_AX(dsp_hle, l_CRC), : CUCode_AX(dsp_hle, l_CRC),
m_last_main_volume(0x8000) m_last_main_volume(0x8000)
{ {
for (int i = 0; i < 3; ++i) for (u16& volume : m_last_aux_volumes)
m_last_aux_volumes[i] = 0x8000; volume = 0x8000;
WARN_LOG(DSPHLE, "Instantiating CUCode_AXWii"); WARN_LOG(DSPHLE, "Instantiating CUCode_AXWii");

View File

@ -173,11 +173,15 @@ void Init()
m_DTVStatus.ntsc_j = Core::g_CoreStartupParameter.bForceNTSCJ; m_DTVStatus.ntsc_j = Core::g_CoreStartupParameter.bForceNTSCJ;
for (int i = 0; i < 4; i++) for (UVIInterruptRegister& reg : m_InterruptRegister)
m_InterruptRegister[i].Hex = 0; {
reg.Hex = 0;
}
for (int i = 0; i < 2; i++) for (UVILatchRegister& reg : m_LatchRegister)
m_LatchRegister[i].Hex = 0; {
reg.Hex = 0;
}
m_DisplayControlRegister.Hex = 0; m_DisplayControlRegister.Hex = 0;
UpdateParameters(); UpdateParameters();
@ -359,8 +363,10 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
{ {
// shuffle2 clear all data, reset to default vals, and enter idle mode // shuffle2 clear all data, reset to default vals, and enter idle mode
m_DisplayControlRegister.RST = 0; m_DisplayControlRegister.RST = 0;
for (int i = 0; i < 4; i++) for (UVIInterruptRegister& reg : m_InterruptRegister)
m_InterruptRegister[i].Hex = 0; {
reg.Hex = 0;
}
UpdateInterrupts(); UpdateInterrupts();
} }
@ -576,10 +582,12 @@ void Update()
if (++m_VBeamPos > s_lineCount * fields) if (++m_VBeamPos > s_lineCount * fields)
m_VBeamPos = 1; m_VBeamPos = 1;
for (int i = 0; i < 4; i++) for (UVIInterruptRegister& reg : m_InterruptRegister)
{ {
if (m_VBeamPos == m_InterruptRegister[i].VCT) if (m_VBeamPos == reg.VCT)
m_InterruptRegister[i].IR_INT = 1; {
reg.IR_INT = 1;
}
} }
UpdateInterrupts(); UpdateInterrupts();
} }

View File

@ -92,20 +92,20 @@ void Init()
{ {
_dbg_assert_msg_(WII_IPC_HLE, g_DeviceMap.empty(), "DeviceMap isn't empty on init"); _dbg_assert_msg_(WII_IPC_HLE, g_DeviceMap.empty(), "DeviceMap isn't empty on init");
CWII_IPC_HLE_Device_es::m_ContentFile = ""; CWII_IPC_HLE_Device_es::m_ContentFile = "";
u32 i;
for (i=0; i<IPC_MAX_FDS; i++) for (IWII_IPC_HLE_Device*& dev : g_FdMap)
{ {
g_FdMap[i] = NULL; dev = NULL;
} }
i = 0; u32 i = 0;
// Build hardware devices // Build hardware devices
g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_oh1_57e_305(i, std::string("/dev/usb/oh1/57e/305")); i++; g_DeviceMap[i] = new CWII_IPC_HLE_Device_usb_oh1_57e_305(i, std::string("/dev/usb/oh1/57e/305")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_immediate(i, std::string("/dev/stm/immediate")); i++; g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_immediate(i, std::string("/dev/stm/immediate")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_eventhook(i, std::string("/dev/stm/eventhook")); i++; g_DeviceMap[i] = new CWII_IPC_HLE_Device_stm_eventhook(i, std::string("/dev/stm/eventhook")); i++;
g_DeviceMap[i] = new CWII_IPC_HLE_Device_fs(i, std::string("/dev/fs")); i++; g_DeviceMap[i] = new CWII_IPC_HLE_Device_fs(i, std::string("/dev/fs")); i++;
// IOS allows two ES devices at a time< // IOS allows two ES devices at a time
for (u32 j=0; j<ES_MAX_COUNT; j++) for (u32 j=0; j<ES_MAX_COUNT; j++)
{ {
g_DeviceMap[i] = es_handles[j] = new CWII_IPC_HLE_Device_es(i, std::string("/dev/es")); i++; g_DeviceMap[i] = es_handles[j] = new CWII_IPC_HLE_Device_es(i, std::string("/dev/es")); i++;
@ -137,21 +137,21 @@ void Reset(bool _bHard)
{ {
CoreTiming::RemoveAllEvents(enque_reply); CoreTiming::RemoveAllEvents(enque_reply);
for (u32 i=0; i<IPC_MAX_FDS; i++) for (IWII_IPC_HLE_Device*& dev : g_FdMap)
{ {
if (g_FdMap[i] != NULL && !g_FdMap[i]->IsHardware()) if (dev != NULL && !dev->IsHardware())
{ {
// close all files and delete their resources // close all files and delete their resources
g_FdMap[i]->Close(0, true); dev->Close(0, true);
delete g_FdMap[i]; delete dev;
} }
g_FdMap[i] = NULL; dev = NULL;
} }
for (u32 j=0; j<ES_MAX_COUNT; j++) for (bool& in_use : es_inuse)
{ {
es_inuse[j] = false; in_use = false;
} }
for (const auto& entry : g_DeviceMap) for (const auto& entry : g_DeviceMap)
@ -228,7 +228,9 @@ IWII_IPC_HLE_Device* GetDeviceByName(const std::string& _rDeviceName)
for (const auto& entry : g_DeviceMap) for (const auto& entry : g_DeviceMap)
{ {
if (entry.second && entry.second->GetDeviceName() == _rDeviceName) if (entry.second && entry.second->GetDeviceName() == _rDeviceName)
{
return entry.second; return entry.second;
}
} }
return NULL; return NULL;
@ -237,9 +239,11 @@ IWII_IPC_HLE_Device* GetDeviceByName(const std::string& _rDeviceName)
IWII_IPC_HLE_Device* AccessDeviceByID(u32 _ID) IWII_IPC_HLE_Device* AccessDeviceByID(u32 _ID)
{ {
if (g_DeviceMap.find(_ID) != g_DeviceMap.end()) if (g_DeviceMap.find(_ID) != g_DeviceMap.end())
{
return g_DeviceMap[_ID]; return g_DeviceMap[_ID];
}
return NULL; return NULL;
} }
// This is called from ExecuteCommand() COMMAND_OPEN_DEVICE // This is called from ExecuteCommand() COMMAND_OPEN_DEVICE
@ -310,22 +314,22 @@ void DoState(PointerWrap &p)
} }
else else
{ {
for (u32 i=0; i<IPC_MAX_FDS; i++) for (IWII_IPC_HLE_Device*& dev : g_FdMap)
{ {
u32 exists = g_FdMap[i] ? 1 : 0; u32 exists = dev ? 1 : 0;
p.Do(exists); p.Do(exists);
if (exists) if (exists)
{ {
u32 isHw = g_FdMap[i]->IsHardware() ? 1 : 0; u32 isHw = dev->IsHardware() ? 1 : 0;
p.Do(isHw); p.Do(isHw);
if (isHw) if (isHw)
{ {
u32 hwId = g_FdMap[i]->GetDeviceID(); u32 hwId = dev->GetDeviceID();
p.Do(hwId); p.Do(hwId);
} }
else else
{ {
g_FdMap[i]->DoState(p); dev->DoState(p);
} }
} }
} }

View File

@ -11,32 +11,32 @@ WII_SSL CWII_IPC_HLE_Device_net_ssl::_SSL[NET_SSL_MAXINSTANCES];
CWII_IPC_HLE_Device_net_ssl::CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName) CWII_IPC_HLE_Device_net_ssl::CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
{ {
for (int i = 0; i < NET_SSL_MAXINSTANCES; ++i) for (WII_SSL& ssl : _SSL)
{ {
memset(&_SSL[i], 0, sizeof(WII_SSL)); memset(&ssl, 0, sizeof(WII_SSL));
} }
} }
CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl() CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl()
{ {
// Cleanup sessions // Cleanup sessions
for (int i = 0; i < NET_SSL_MAXINSTANCES; i++) for (WII_SSL& ssl : _SSL)
{ {
if (_SSL[i].active) if (ssl.active)
{ {
ssl_close_notify(&_SSL[i].ctx); ssl_close_notify(&ssl.ctx);
ssl_session_free(&_SSL[i].session); ssl_session_free(&ssl.session);
ssl_free(&_SSL[i].ctx); ssl_free(&ssl.ctx);
x509_crt_free(&_SSL[i].cacert); x509_crt_free(&ssl.cacert);
x509_crt_free(&_SSL[i].clicert); x509_crt_free(&ssl.clicert);
memset(&_SSL[i].ctx, 0, sizeof(ssl_context)); memset(&ssl.ctx, 0, sizeof(ssl_context));
memset(&_SSL[i].session, 0, sizeof(ssl_session)); memset(&ssl.session, 0, sizeof(ssl_session));
memset(&_SSL[i].entropy, 0, sizeof(entropy_context)); memset(&ssl.entropy, 0, sizeof(entropy_context));
memset(_SSL[i].hostname, 0, NET_SSL_MAX_HOSTNAME_LEN); memset(ssl.hostname, 0, NET_SSL_MAX_HOSTNAME_LEN);
_SSL[i].active = false; ssl.active = false;
} }
} }
} }
@ -79,9 +79,9 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtl(u32 _CommandAddress)
u32 Command = Memory::Read_U32(_CommandAddress + 0x0C); u32 Command = Memory::Read_U32(_CommandAddress + 0x0C);
INFO_LOG(WII_IPC_SSL, "%s unknown %i " INFO_LOG(WII_IPC_SSL, "%s unknown %i "
"(BufferIn: (%08x, %i), BufferOut: (%08x, %i)", "(BufferIn: (%08x, %i), BufferOut: (%08x, %i)",
GetDeviceName().c_str(), Command, GetDeviceName().c_str(), Command,
BufferIn, BufferInSize, BufferOut, BufferOutSize); BufferIn, BufferInSize, BufferOut, BufferOutSize);
Memory::Write_U32(0, _CommandAddress + 0x4); Memory::Write_U32(0, _CommandAddress + 0x4);
return true; return true;
} }
@ -139,45 +139,46 @@ bool CWII_IPC_HLE_Device_net_ssl::IOCtlV(u32 _CommandAddress)
if (freeSSL) if (freeSSL)
{ {
int sslID = freeSSL - 1; int sslID = freeSSL - 1;
int ret = ssl_init(&_SSL[sslID].ctx); WII_SSL* ssl = &_SSL[sslID];
int ret = ssl_init(&ssl->ctx);
if (ret) if (ret)
{ {
// Cleanup possibly dirty ctx // Cleanup possibly dirty ctx
memset(&_SSL[sslID].ctx, 0, sizeof(ssl_context)); memset(&ssl->ctx, 0, sizeof(ssl_context));
goto _SSL_NEW_ERROR; goto _SSL_NEW_ERROR;
} }
entropy_init(&_SSL[sslID].entropy); entropy_init(&ssl->entropy);
const char* pers = "dolphin-emu"; const char* pers = "dolphin-emu";
ret = ctr_drbg_init(&_SSL[sslID].ctr_drbg, entropy_func, ret = ctr_drbg_init(&ssl->ctr_drbg, entropy_func,
&_SSL[sslID].entropy, &ssl->entropy,
(const unsigned char*)pers, (const unsigned char*)pers,
strlen(pers)); strlen(pers));
if (ret) if (ret)
{ {
ssl_free(&_SSL[sslID].ctx); ssl_free(&ssl->ctx);
// Cleanup possibly dirty ctx // Cleanup possibly dirty ctx
memset(&_SSL[sslID].ctx, 0, sizeof(ssl_context)); memset(&ssl->ctx, 0, sizeof(ssl_context));
entropy_free(&_SSL[sslID].entropy); entropy_free(&ssl->entropy);
goto _SSL_NEW_ERROR; goto _SSL_NEW_ERROR;
} }
ssl_set_rng(&_SSL[sslID].ctx, ctr_drbg_random, &_SSL[sslID].ctr_drbg); ssl_set_rng(&ssl->ctx, ctr_drbg_random, &ssl->ctr_drbg);
// For some reason we can't use TLSv1.2, v1.1 and below are fine! // For some reason we can't use TLSv1.2, v1.1 and below are fine!
ssl_set_max_version(&_SSL[sslID].ctx, SSL_MAJOR_VERSION_3, SSL_MINOR_VERSION_2); ssl_set_max_version(&ssl->ctx, SSL_MAJOR_VERSION_3, SSL_MINOR_VERSION_2);
ssl_set_session(&_SSL[sslID].ctx, &_SSL[sslID].session); ssl_set_session(&ssl->ctx, &ssl->session);
ssl_set_endpoint(&_SSL[sslID].ctx, SSL_IS_CLIENT); ssl_set_endpoint(&ssl->ctx, SSL_IS_CLIENT);
ssl_set_authmode(&_SSL[sslID].ctx, SSL_VERIFY_NONE); ssl_set_authmode(&ssl->ctx, SSL_VERIFY_NONE);
ssl_set_renegotiation(&_SSL[sslID].ctx, SSL_RENEGOTIATION_ENABLED); ssl_set_renegotiation(&ssl->ctx, SSL_RENEGOTIATION_ENABLED);
memcpy(_SSL[sslID].hostname, hostname, min((int)BufferOutSize2, NET_SSL_MAX_HOSTNAME_LEN)); memcpy(ssl->hostname, hostname, min((int)BufferOutSize2, NET_SSL_MAX_HOSTNAME_LEN));
_SSL[sslID].hostname[NET_SSL_MAX_HOSTNAME_LEN-1] = '\0'; ssl->hostname[NET_SSL_MAX_HOSTNAME_LEN-1] = '\0';
ssl_set_hostname(&_SSL[sslID].ctx, _SSL[sslID].hostname); ssl_set_hostname(&ssl->ctx, ssl->hostname);
_SSL[sslID].active = true; ssl->active = true;
Memory::Write_U32(freeSSL, _BufferIn); Memory::Write_U32(freeSSL, _BufferIn);
} }
else else
@ -201,21 +202,22 @@ _SSL_NEW_ERROR:
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
ssl_close_notify(&_SSL[sslID].ctx); WII_SSL* ssl = &_SSL[sslID];
ssl_session_free(&_SSL[sslID].session); ssl_close_notify(&ssl->ctx);
ssl_free(&_SSL[sslID].ctx); ssl_session_free(&ssl->session);
ssl_free(&ssl->ctx);
entropy_free(&_SSL[sslID].entropy); entropy_free(&ssl->entropy);
x509_crt_free(&_SSL[sslID].cacert); x509_crt_free(&ssl->cacert);
x509_crt_free(&_SSL[sslID].clicert); x509_crt_free(&ssl->clicert);
memset(&_SSL[sslID].ctx, 0, sizeof(ssl_context)); memset(&ssl->ctx, 0, sizeof(ssl_context));
memset(&_SSL[sslID].session, 0, sizeof(ssl_session)); memset(&ssl->session, 0, sizeof(ssl_session));
memset(&_SSL[sslID].entropy, 0, sizeof(entropy_context)); memset(&ssl->entropy, 0, sizeof(entropy_context));
memset(_SSL[sslID].hostname, 0, NET_SSL_MAX_HOSTNAME_LEN); memset(ssl->hostname, 0, NET_SSL_MAX_HOSTNAME_LEN);
_SSL[sslID].active = false; ssl->active = false;
Memory::Write_U32(SSL_OK, _BufferIn); Memory::Write_U32(SSL_OK, _BufferIn);
} }
@ -246,8 +248,9 @@ _SSL_NEW_ERROR:
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
WII_SSL* ssl = &_SSL[sslID];
int ret = x509_crt_parse_der( int ret = x509_crt_parse_der(
&_SSL[sslID].cacert, &ssl->cacert,
Memory::GetPointer(BufferOut2), Memory::GetPointer(BufferOut2),
BufferOutSize2); BufferOutSize2);
@ -257,7 +260,7 @@ _SSL_NEW_ERROR:
} }
else else
{ {
ssl_set_ca_chain(&_SSL[sslID].ctx, &_SSL[sslID].cacert, NULL, _SSL[sslID].hostname); ssl_set_ca_chain(&ssl->ctx, &ssl->cacert, NULL, ssl->hostname);
Memory::Write_U32(SSL_OK, _BufferIn); Memory::Write_U32(SSL_OK, _BufferIn);
} }
@ -282,20 +285,21 @@ _SSL_NEW_ERROR:
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
WII_SSL* ssl = &_SSL[sslID];
std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX)); std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX));
int ret = x509_crt_parse_file(&_SSL[sslID].clicert, (cert_base_path + "clientca.pem").c_str()); int ret = x509_crt_parse_file(&ssl->clicert, (cert_base_path + "clientca.pem").c_str());
int pk_ret = pk_parse_keyfile(&_SSL[sslID].pk, (cert_base_path + "clientcakey.pem").c_str(), NULL); int pk_ret = pk_parse_keyfile(&ssl->pk, (cert_base_path + "clientcakey.pem").c_str(), NULL);
if (ret || pk_ret) if (ret || pk_ret)
{ {
x509_crt_free(&_SSL[sslID].clicert); x509_crt_free(&ssl->clicert);
pk_free(&_SSL[sslID].pk); pk_free(&ssl->pk);
memset(&_SSL[sslID].clicert, 0, sizeof(x509_crt)); memset(&ssl->clicert, 0, sizeof(x509_crt));
memset(&_SSL[sslID].pk, 0, sizeof(pk_context)); memset(&ssl->pk, 0, sizeof(pk_context));
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn); Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
} }
else else
{ {
ssl_set_own_cert(&_SSL[sslID].ctx, &_SSL[sslID].clicert, &_SSL[sslID].pk); ssl_set_own_cert(&ssl->ctx, &ssl->clicert, &ssl->pk);
Memory::Write_U32(SSL_OK, _BufferIn); Memory::Write_U32(SSL_OK, _BufferIn);
} }
@ -321,12 +325,13 @@ _SSL_NEW_ERROR:
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
x509_crt_free(&_SSL[sslID].clicert); WII_SSL* ssl = &_SSL[sslID];
pk_free(&_SSL[sslID].pk); x509_crt_free(&ssl->clicert);
memset(&_SSL[sslID].clicert, 0, sizeof(x509_crt)); pk_free(&ssl->pk);
memset(&_SSL[sslID].pk, 0, sizeof(pk_context)); memset(&ssl->clicert, 0, sizeof(x509_crt));
memset(&ssl->pk, 0, sizeof(pk_context));
ssl_set_own_cert(&_SSL[sslID].ctx, NULL, NULL); ssl_set_own_cert(&ssl->ctx, NULL, NULL);
Memory::Write_U32(SSL_OK, _BufferIn); Memory::Write_U32(SSL_OK, _BufferIn);
} }
else else
@ -341,17 +346,18 @@ _SSL_NEW_ERROR:
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
WII_SSL* ssl = &_SSL[sslID];
std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX)); std::string cert_base_path(File::GetUserPath(D_WIIUSER_IDX));
int ret = x509_crt_parse_file(&_SSL[sslID].cacert, (cert_base_path + "rootca.pem").c_str()); int ret = x509_crt_parse_file(&ssl->cacert, (cert_base_path + "rootca.pem").c_str());
if (ret) if (ret)
{ {
x509_crt_free(&_SSL[sslID].clicert); x509_crt_free(&ssl->clicert);
Memory::Write_U32(SSL_ERR_FAILED, _BufferIn); Memory::Write_U32(SSL_ERR_FAILED, _BufferIn);
} }
else else
{ {
ssl_set_ca_chain(&_SSL[sslID].ctx, &_SSL[sslID].cacert, NULL, _SSL[sslID].hostname); ssl_set_ca_chain(&ssl->ctx, &ssl->cacert, NULL, ssl->hostname);
Memory::Write_U32(SSL_OK, _BufferIn); Memory::Write_U32(SSL_OK, _BufferIn);
} }
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret); INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret);
@ -374,9 +380,10 @@ _SSL_NEW_ERROR:
int sslID = Memory::Read_U32(BufferOut) - 1; int sslID = Memory::Read_U32(BufferOut) - 1;
if (SSLID_VALID(sslID)) if (SSLID_VALID(sslID))
{ {
_SSL[sslID].sockfd = Memory::Read_U32(BufferOut2); WII_SSL* ssl = &_SSL[sslID];
INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", _SSL[sslID].sockfd); ssl->sockfd = Memory::Read_U32(BufferOut2);
ssl_set_bio(&_SSL[sslID].ctx, net_recv, &_SSL[sslID].sockfd, net_send, &_SSL[sslID].sockfd); INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", ssl->sockfd);
ssl_set_bio(&ssl->ctx, net_recv, &ssl->sockfd, net_send, &ssl->sockfd);
Memory::Write_U32(SSL_OK, _BufferIn); Memory::Write_U32(SSL_OK, _BufferIn);
} }
else else

View File

@ -27,8 +27,10 @@ bool CWII_IPC_HLE_Device_usb_kbd::Open(u32 _CommandAddress, u32 _Mode)
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
ini.Get("USB Keyboard", "Layout", &m_KeyboardLayout, KBD_LAYOUT_QWERTY); ini.Get("USB Keyboard", "Layout", &m_KeyboardLayout, KBD_LAYOUT_QWERTY);
for(int i = 0; i < 256; i++) for (bool& pressed : m_OldKeyBuffer)
m_OldKeyBuffer[i] = false; {
pressed = false;
}
m_OldModifiers = 0x00; m_OldModifiers = 0x00;

View File

@ -184,8 +184,10 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
case NP_MSG_PAD_MAPPING : case NP_MSG_PAD_MAPPING :
{ {
for (PadMapping i = 0; i < 4; i++) for (PadMapping& mapping : m_pad_map)
packet >> m_pad_map[i]; {
packet >> mapping;
}
UpdateDevices(); UpdateDevices();
@ -195,8 +197,10 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
case NP_MSG_WIIMOTE_MAPPING : case NP_MSG_WIIMOTE_MAPPING :
{ {
for (PadMapping i = 0; i < 4; i++) for (PadMapping& mapping : m_wiimote_map)
packet >> m_wiimote_map[i]; {
packet >> mapping;
}
m_dialog->Update(); m_dialog->Update();
} }
@ -759,15 +763,19 @@ void NetPlayClient::Stop()
if (m_is_running == false) if (m_is_running == false)
return; return;
bool isPadMapped = false; bool isPadMapped = false;
for (unsigned int i = 0; i < 4; ++i) for (PadMapping mapping : m_pad_map)
{ {
if (m_pad_map[i] == m_local_player->pid) if (mapping == m_local_player->pid)
{
isPadMapped = true; isPadMapped = true;
}
} }
for (unsigned int i = 0; i < 4; ++i) for (PadMapping mapping : m_wiimote_map)
{ {
if (m_wiimote_map[i] == m_local_player->pid) if (mapping == m_local_player->pid)
{
isPadMapped = true; isPadMapped = true;
}
} }
// tell the server to stop if we have a pad mapped in game. // tell the server to stop if we have a pad mapped in game.
if (isPadMapped) if (isPadMapped)

View File

@ -156,11 +156,11 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket)
player.pid = (PlayerId)(m_players.size() + 1); player.pid = (PlayerId)(m_players.size() + 1);
// try to automatically assign new user a pad // try to automatically assign new user a pad
for (unsigned int m = 0; m < 4; ++m) for (PadMapping& mapping : m_pad_map)
{ {
if (m_pad_map[m] == -1) if (mapping == -1)
{ {
m_pad_map[m] = player.pid; mapping = player.pid;
break; break;
} }
} }
@ -229,9 +229,9 @@ unsigned int NetPlayServer::OnDisconnect(sf::SocketTCP& socket)
if (m_is_running) if (m_is_running)
{ {
for (int i = 0; i < 4; i++) for (PadMapping mapping : m_pad_map)
{ {
if (m_pad_map[i] == pid) if (mapping == pid)
{ {
PanicAlertT("Client disconnect while game is running!! NetPlay is disabled. You must manually stop the game."); PanicAlertT("Client disconnect while game is running!! NetPlay is disabled. You must manually stop the game.");
std::lock_guard<std::recursive_mutex> lkg(m_crit.game); std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
@ -260,14 +260,22 @@ unsigned int NetPlayServer::OnDisconnect(sf::SocketTCP& socket)
std::lock_guard<std::recursive_mutex> lks(m_crit.send); std::lock_guard<std::recursive_mutex> lks(m_crit.send);
SendToClients(spac); SendToClients(spac);
for (int i = 0; i < 4; i++) for (PadMapping& mapping : m_pad_map)
if (m_pad_map[i] == pid) {
m_pad_map[i] = -1; if (mapping == pid)
{
mapping = -1;
}
}
UpdatePadMapping(); UpdatePadMapping();
for (int i = 0; i < 4; i++) for (PadMapping& mapping : m_wiimote_map)
if (m_wiimote_map[i] == pid) {
m_wiimote_map[i] = -1; if (mapping == pid)
{
mapping = -1;
}
}
UpdateWiimoteMapping(); UpdateWiimoteMapping();
return 0; return 0;
@ -307,8 +315,10 @@ void NetPlayServer::UpdatePadMapping()
{ {
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_PAD_MAPPING; spac << (MessageId)NP_MSG_PAD_MAPPING;
for (int i = 0; i < 4; i++) for (PadMapping mapping : m_pad_map)
spac << m_pad_map[i]; {
spac << mapping;
}
SendToClients(spac); SendToClients(spac);
} }
@ -317,8 +327,10 @@ void NetPlayServer::UpdateWiimoteMapping()
{ {
sf::Packet spac; sf::Packet spac;
spac << (MessageId)NP_MSG_WIIMOTE_MAPPING; spac << (MessageId)NP_MSG_WIIMOTE_MAPPING;
for (int i = 0; i < 4; i++) for (PadMapping mapping : m_wiimote_map)
spac << m_wiimote_map[i]; {
spac << mapping;
}
SendToClients(spac); SendToClients(spac);
} }
@ -552,12 +564,14 @@ bool NetPlayServer::StartGame(const std::string &path)
// called from multiple threads // called from multiple threads
void NetPlayServer::SendToClients(sf::Packet& packet, const PlayerId skip_pid) void NetPlayServer::SendToClients(sf::Packet& packet, const PlayerId skip_pid)
{ {
std::map<sf::SocketTCP, Client>::iterator for (std::pair<const sf::SocketTCP, Client>& p : m_players)
i = m_players.begin(), {
e = m_players.end(); if (p.second.pid &&
for ( ; i!=e; ++i) p.second.pid != skip_pid)
if (i->second.pid && (i->second.pid != skip_pid)) {
i->second.socket.Send(packet); p.second.socket.Send(packet);
}
}
} }
#ifdef USE_UPNP #ifdef USE_UPNP

View File

@ -34,8 +34,10 @@ void SectorReader::SetSectorSize(int blocksize)
} }
SectorReader::~SectorReader() { SectorReader::~SectorReader() {
for (int i = 0; i < CACHE_SIZE; i++) for (u8*& block : cache)
delete [] cache[i]; {
delete [] block;
}
} }
const u8 *SectorReader::GetBlockData(u64 block_num) const u8 *SectorReader::GetBlockData(u64 block_num)

View File

@ -325,11 +325,9 @@ CNANDContentManager CNANDContentManager::m_Instance;
CNANDContentManager::~CNANDContentManager() CNANDContentManager::~CNANDContentManager()
{ {
CNANDContentMap::iterator itr = m_Map.begin(); for (auto& entry : m_Map)
while (itr != m_Map.end())
{ {
delete itr->second; delete entry.second;
++itr;
} }
m_Map.clear(); m_Map.clear();
} }

View File

@ -170,14 +170,14 @@ static IVolume* CreateVolumeFromCryptedWiiImage(IBlobReader& _rReader, u32 _Part
SPartitionGroup PartitionGroup[4]; SPartitionGroup PartitionGroup[4];
// read all partitions // read all partitions
for (u32 x = 0; x < 4; x++) for (SPartitionGroup& group : PartitionGroup)
{ {
for (u32 i = 0; i < numPartitions; i++) for (u32 i = 0; i < numPartitions; i++)
{ {
SPartition Partition; SPartition Partition;
Partition.Offset = ((u64)Reader.Read32(PartitionsOffset + (i * 8) + 0)) << 2; Partition.Offset = ((u64)Reader.Read32(PartitionsOffset + (i * 8) + 0)) << 2;
Partition.Type = Reader.Read32(PartitionsOffset + (i * 8) + 4); Partition.Type = Reader.Read32(PartitionsOffset + (i * 8) + 4);
PartitionGroup[x].PartitionsVec.push_back(Partition); group.PartitionsVec.push_back(Partition);
} }
} }

View File

@ -338,11 +338,11 @@ void wxCheatsWindow::OnEvent_CheatsList_ItemSelected(wxCommandEvent& WXUNUSED (e
m_Label_NumCodes->SetLabel(StrToWxStr(numcodes)); m_Label_NumCodes->SetLabel(StrToWxStr(numcodes));
m_ListBox_CodesList->Clear(); m_ListBox_CodesList->Clear();
for (size_t j = 0; j < code.ops.size(); j++) for (const AREntry& entry : code.ops)
{ {
char text2[CHAR_MAX]; char text2[CHAR_MAX];
char* ops = text2; char* ops = text2;
sprintf(ops, "%08x %08x", code.ops[j].cmd_addr, code.ops[j].value); sprintf(ops, "%08x %08x", entry.cmd_addr, entry.value);
m_ListBox_CodesList->Append(StrToWxStr(ops)); m_ListBox_CodesList->Append(StrToWxStr(ops));
} }
} }
@ -352,11 +352,11 @@ void wxCheatsWindow::OnEvent_CheatsList_ItemSelected(wxCommandEvent& WXUNUSED (e
void wxCheatsWindow::OnEvent_CheatsList_ItemToggled(wxCommandEvent& WXUNUSED (event)) void wxCheatsWindow::OnEvent_CheatsList_ItemToggled(wxCommandEvent& WXUNUSED (event))
{ {
int index = m_CheckListBox_CheatsList->GetSelection(); int index = m_CheckListBox_CheatsList->GetSelection();
for (size_t i = 0; i < indexList.size(); i++) for (const ARCodeIndex& code_index : indexList)
{ {
if ((int)indexList[i].uiIndex == index) if ((int)code_index.uiIndex == index)
{ {
ActionReplay::SetARCode_IsActive(m_CheckListBox_CheatsList->IsChecked(index), indexList[i].index); ActionReplay::SetARCode_IsActive(m_CheckListBox_CheatsList->IsChecked(index), code_index.index);
} }
} }
} }
@ -364,9 +364,9 @@ void wxCheatsWindow::OnEvent_CheatsList_ItemToggled(wxCommandEvent& WXUNUSED (ev
void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& ev) void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& ev)
{ {
// Apply AR Code changes // Apply AR Code changes
for (size_t i = 0; i < indexList.size(); i++) for (const ARCodeIndex& code_index : indexList)
{ {
ActionReplay::SetARCode_IsActive(m_CheckListBox_CheatsList->IsChecked(indexList[i].uiIndex), indexList[i].index); ActionReplay::SetARCode_IsActive(m_CheckListBox_CheatsList->IsChecked(code_index.uiIndex), code_index.index);
} }
// Apply Gecko Code changes // Apply Gecko Code changes
@ -385,10 +385,9 @@ void wxCheatsWindow::OnEvent_ApplyChanges_Press(wxCommandEvent& ev)
void wxCheatsWindow::OnEvent_ButtonUpdateLog_Press(wxCommandEvent& WXUNUSED (event)) void wxCheatsWindow::OnEvent_ButtonUpdateLog_Press(wxCommandEvent& WXUNUSED (event))
{ {
m_TextCtrl_Log->Clear(); m_TextCtrl_Log->Clear();
const std::vector<std::string> &arLog = ActionReplay::GetSelfLog(); for (const std::string& text : ActionReplay::GetSelfLog())
for (u32 i = 0; i < arLog.size(); i++)
{ {
m_TextCtrl_Log->AppendText(StrToWxStr(arLog[i])); m_TextCtrl_Log->AppendText(StrToWxStr(text));
} }
} }
@ -440,10 +439,6 @@ void CheatSearchTab::FilterCheatSearchResults(wxCommandEvent&)
return; return;
} }
std::vector<CheatSearchResult>::iterator
i = search_results.begin(),
e = search_results.end();
// Set up the sub-search results efficiently to prevent automatic re-allocations. // Set up the sub-search results efficiently to prevent automatic re-allocations.
std::vector<CheatSearchResult> filtered_results; std::vector<CheatSearchResult> filtered_results;
filtered_results.reserve(search_results.size()); filtered_results.reserve(search_results.size());
@ -459,10 +454,10 @@ void CheatSearchTab::FilterCheatSearchResults(wxCommandEvent&)
if (value_x_radiobtn.rad_oldvalue->GetValue()) // using old value comparison if (value_x_radiobtn.rad_oldvalue->GetValue()) // using old value comparison
{ {
for (; i!=e; ++i) for (CheatSearchResult& result : search_results)
{ {
// with big endian, can just use memcmp for ><= comparison // with big endian, can just use memcmp for ><= comparison
int cmp_result = memcmp(memptr + i->address, &i->old_value, search_type_size); int cmp_result = memcmp(memptr + result.address, &result.old_value, search_type_size);
if (cmp_result < 0) if (cmp_result < 0)
cmp_result = 4; cmp_result = 4;
else else
@ -470,8 +465,8 @@ void CheatSearchTab::FilterCheatSearchResults(wxCommandEvent&)
if (cmp_result & filter_mask) if (cmp_result & filter_mask)
{ {
memcpy(&i->old_value, memptr + i->address, search_type_size); memcpy(&result.old_value, memptr + result.address, search_type_size);
filtered_results.push_back(*i); filtered_results.push_back(result);
} }
} }
} }
@ -510,10 +505,10 @@ void CheatSearchTab::FilterCheatSearchResults(wxCommandEvent&)
// #endif // #endif
} }
for (; i!=e; ++i) for (CheatSearchResult& result : search_results)
{ {
// with big endian, can just use memcmp for ><= comparison // with big endian, can just use memcmp for ><= comparison
int cmp_result = memcmp(memptr + i->address, &user_x_val, search_type_size); int cmp_result = memcmp(memptr + result.address, &user_x_val, search_type_size);
if (cmp_result < 0) if (cmp_result < 0)
cmp_result = 4; cmp_result = 4;
else if (cmp_result) else if (cmp_result)
@ -523,8 +518,8 @@ void CheatSearchTab::FilterCheatSearchResults(wxCommandEvent&)
if (cmp_result & filter_mask) if (cmp_result & filter_mask)
{ {
memcpy(&i->old_value, memptr + i->address, search_type_size); memcpy(&result.old_value, memptr + result.address, search_type_size);
filtered_results.push_back(*i); filtered_results.push_back(result);
} }
} }
} }

View File

@ -42,16 +42,13 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage(m_pad_notebook->GetSelection()); GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage(m_pad_notebook->GetSelection());
std::vector< ControlGroupBox* >::iterator for (ControlGroupBox* g : current_page->control_groups)
g = current_page->control_groups.begin(),
ge = current_page->control_groups.end();
for ( ; g != ge; ++g )
{ {
// if this control group has a bitmap // if this control group has a bitmap
if ( (*g)->static_bitmap ) if (g->static_bitmap)
{ {
wxMemoryDC dc; wxMemoryDC dc;
wxBitmap bitmap((*g)->static_bitmap->GetBitmap()); wxBitmap bitmap(g->static_bitmap->GetBitmap());
dc.SelectObject(bitmap); dc.SelectObject(bitmap);
dc.Clear(); dc.Clear();
@ -60,9 +57,9 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
// label for sticks and stuff // label for sticks and stuff
if (64 == bitmap.GetHeight()) if (64 == bitmap.GetHeight())
dc.DrawText(StrToWxStr((*g)->control_group->name).Upper(), 4, 2); dc.DrawText(StrToWxStr(g->control_group->name).Upper(), 4, 2);
switch ( (*g)->control_group->type ) switch (g->control_group->type)
{ {
case GROUP_TYPE_TILT : case GROUP_TYPE_TILT :
case GROUP_TYPE_STICK : case GROUP_TYPE_STICK :
@ -73,32 +70,32 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
float x = 0, y = 0, z = 0; float x = 0, y = 0, z = 0;
float xx, yy; float xx, yy;
switch ((*g)->control_group->type) switch (g->control_group->type)
{ {
case GROUP_TYPE_STICK : case GROUP_TYPE_STICK :
((ControllerEmu::AnalogStick*)(*g)->control_group)->GetState( &x, &y, 32.0, 32-1.5 ); ((ControllerEmu::AnalogStick*)g->control_group)->GetState(&x, &y, 32.0, 32-1.5);
break; break;
case GROUP_TYPE_TILT : case GROUP_TYPE_TILT :
((ControllerEmu::Tilt*)(*g)->control_group)->GetState( &x, &y, 32.0, 32-1.5 ); ((ControllerEmu::Tilt*)g->control_group)->GetState(&x, &y, 32.0, 32-1.5);
break; break;
case GROUP_TYPE_CURSOR : case GROUP_TYPE_CURSOR :
((ControllerEmu::Cursor*)(*g)->control_group)->GetState( &x, &y, &z ); ((ControllerEmu::Cursor*)g->control_group)->GetState(&x, &y, &z);
x *= (32-1.5); x+= 32; x *= (32-1.5); x+= 32;
y *= (32-1.5); y+= 32; y *= (32-1.5); y+= 32;
break; break;
} }
xx = (*g)->control_group->controls[3]->control_ref->State(); xx = g->control_group->controls[3]->control_ref->State();
xx -= (*g)->control_group->controls[2]->control_ref->State(); xx -= g->control_group->controls[2]->control_ref->State();
yy = (*g)->control_group->controls[1]->control_ref->State(); yy = g->control_group->controls[1]->control_ref->State();
yy -= (*g)->control_group->controls[0]->control_ref->State(); yy -= g->control_group->controls[0]->control_ref->State();
xx *= 32 - 1; xx += 32; xx *= 32 - 1; xx += 32;
yy *= 32 - 1; yy += 32; yy *= 32 - 1; yy += 32;
// draw the shit // draw the shit
// ir cursor forward movement // ir cursor forward movement
if (GROUP_TYPE_CURSOR == (*g)->control_group->type) if (GROUP_TYPE_CURSOR == g->control_group->type)
{ {
if (z) if (z)
{ {
@ -110,13 +107,13 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
dc.SetPen(*wxGREY_PEN); dc.SetPen(*wxGREY_PEN);
dc.SetBrush(*wxGREY_BRUSH); dc.SetBrush(*wxGREY_BRUSH);
} }
dc.DrawRectangle( 0, 31 - z*31, 64, 2); dc.DrawRectangle(0, 31 - z*31, 64, 2);
} }
// octagon for visual aid for diagonal adjustment // octagon for visual aid for diagonal adjustment
dc.SetPen(*wxLIGHT_GREY_PEN); dc.SetPen(*wxLIGHT_GREY_PEN);
dc.SetBrush(*wxWHITE_BRUSH); dc.SetBrush(*wxWHITE_BRUSH);
if ( GROUP_TYPE_STICK == (*g)->control_group->type ) if (GROUP_TYPE_STICK == g->control_group->type)
{ {
// outline and fill colors // outline and fill colors
wxBrush LightGrayBrush(_T("#dddddd")); wxBrush LightGrayBrush(_T("#dddddd"));
@ -131,12 +128,12 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
, d_of = box / 256.0 , d_of = box / 256.0
, x_of = box / 2.0; , x_of = box / 2.0;
if (strcmp((*g)->control_group->name, "Main Stick") == 0) if (strcmp(g->control_group->name, "Main Stick") == 0)
{ {
max = (87.0f / 127.0f) * 100; max = (87.0f / 127.0f) * 100;
diagonal = (55.0f / 127.0f) * 100.0; diagonal = (55.0f / 127.0f) * 100.0;
} }
else if (strcmp((*g)->control_group->name,"C-Stick") == 0) else if (strcmp(g->control_group->name,"C-Stick") == 0)
{ {
max = (74.0f / 127.0f) * 100; max = (74.0f / 127.0f) * 100;
diagonal = (46.0f / 127.0f) * 100; diagonal = (46.0f / 127.0f) * 100;
@ -163,33 +160,33 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
} }
else else
{ {
dc.DrawRectangle( 16, 16, 32, 32 ); dc.DrawRectangle(16, 16, 32, 32);
} }
if ( GROUP_TYPE_CURSOR != (*g)->control_group->type ) if (GROUP_TYPE_CURSOR != g->control_group->type)
{ {
// deadzone circle // deadzone circle
dc.SetBrush(*wxLIGHT_GREY_BRUSH); dc.SetBrush(*wxLIGHT_GREY_BRUSH);
dc.DrawCircle( 32, 32, ((*g)->control_group)->settings[SETTING_DEADZONE]->value * 32 ); dc.DrawCircle(32, 32, g->control_group->settings[SETTING_DEADZONE]->value * 32);
} }
// raw dot // raw dot
dc.SetPen(*wxGREY_PEN); dc.SetPen(*wxGREY_PEN);
dc.SetBrush(*wxGREY_BRUSH); dc.SetBrush(*wxGREY_BRUSH);
// i like the dot better than the cross i think // i like the dot better than the cross i think
dc.DrawRectangle( xx - 2, yy - 2, 4, 4 ); dc.DrawRectangle(xx - 2, yy - 2, 4, 4);
//dc.DrawRectangle( xx-1, 64-yy-4, 2, 8 ); //dc.DrawRectangle(xx-1, 64-yy-4, 2, 8);
//dc.DrawRectangle( xx-4, 64-yy-1, 8, 2 ); //dc.DrawRectangle(xx-4, 64-yy-1, 8, 2);
// adjusted dot // adjusted dot
if (x!=32 || y!=32) if (x!=32 || y!=32)
{ {
dc.SetPen(*wxRED_PEN); dc.SetPen(*wxRED_PEN);
dc.SetBrush(*wxRED_BRUSH); dc.SetBrush(*wxRED_BRUSH);
dc.DrawRectangle( x-2, 64-y-2, 4, 4 ); dc.DrawRectangle(x-2, 64-y-2, 4, 4);
// i like the dot better than the cross i think // i like the dot better than the cross i think
//dc.DrawRectangle( x-1, 64-y-4, 2, 8 ); //dc.DrawRectangle(x-1, 64-y-4, 2, 8);
//dc.DrawRectangle( x-4, 64-y-1, 8, 2 ); //dc.DrawRectangle(x-4, 64-y-1, 8, 2);
} }
} }
@ -198,64 +195,64 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
{ {
float raw_dot[3]; float raw_dot[3];
float adj_dot[3]; float adj_dot[3];
const float deadzone = 32 * ((*g)->control_group)->settings[0]->value; const float deadzone = 32 * g->control_group->settings[0]->value;
// adjusted // adjusted
((ControllerEmu::Force*)(*g)->control_group)->GetState( adj_dot, 32.0, 32-1.5 ); ((ControllerEmu::Force*)g->control_group)->GetState(adj_dot, 32.0, 32-1.5);
// raw // raw
for ( unsigned int i=0; i<3; ++i ) for (unsigned int i=0; i<3; ++i)
{ {
raw_dot[i] = (*g)->control_group->controls[i*2 + 1]->control_ref->State() raw_dot[i] = g->control_group->controls[i*2 + 1]->control_ref->State()
- (*g)->control_group->controls[i*2]->control_ref->State(); - g->control_group->controls[i*2]->control_ref->State();
raw_dot[i] *= 32 - 1; raw_dot[i] += 32; raw_dot[i] *= 32 - 1; raw_dot[i] += 32;
} }
// deadzone rect for forward/backward visual // deadzone rect for forward/backward visual
dc.SetBrush(*wxLIGHT_GREY_BRUSH); dc.SetBrush(*wxLIGHT_GREY_BRUSH);
dc.SetPen(*wxLIGHT_GREY_PEN); dc.SetPen(*wxLIGHT_GREY_PEN);
dc.DrawRectangle( 0, 32 - deadzone, 64, deadzone * 2 ); dc.DrawRectangle(0, 32 - deadzone, 64, deadzone * 2);
// raw forward/background line // raw forward/background line
dc.SetPen(*wxGREY_PEN); dc.SetPen(*wxGREY_PEN);
dc.SetBrush(*wxGREY_BRUSH); dc.SetBrush(*wxGREY_BRUSH);
dc.DrawRectangle( 0, raw_dot[2] - 1, 64, 2 ); dc.DrawRectangle(0, raw_dot[2] - 1, 64, 2);
// adjusted forward/background line // adjusted forward/background line
if ( adj_dot[2]!=32 ) if (adj_dot[2]!=32)
{ {
dc.SetPen(*wxRED_PEN); dc.SetPen(*wxRED_PEN);
dc.SetBrush(*wxRED_BRUSH); dc.SetBrush(*wxRED_BRUSH);
dc.DrawRectangle( 0, adj_dot[2] - 1, 64, 2 ); dc.DrawRectangle(0, adj_dot[2] - 1, 64, 2);
} }
// a rectangle, for looks i guess // a rectangle, for looks i guess
dc.SetBrush(*wxWHITE_BRUSH); dc.SetBrush(*wxWHITE_BRUSH);
dc.SetPen(*wxLIGHT_GREY_PEN); dc.SetPen(*wxLIGHT_GREY_PEN);
dc.DrawRectangle( 16, 16, 32, 32 ); dc.DrawRectangle(16, 16, 32, 32);
// deadzone square // deadzone square
dc.SetBrush(*wxLIGHT_GREY_BRUSH); dc.SetBrush(*wxLIGHT_GREY_BRUSH);
dc.DrawRectangle( 32 - deadzone, 32 - deadzone, deadzone * 2, deadzone * 2 ); dc.DrawRectangle(32 - deadzone, 32 - deadzone, deadzone * 2, deadzone * 2);
// raw dot // raw dot
dc.SetPen(*wxGREY_PEN); dc.SetPen(*wxGREY_PEN);
dc.SetBrush(*wxGREY_BRUSH); dc.SetBrush(*wxGREY_BRUSH);
dc.DrawRectangle( raw_dot[1] - 2, raw_dot[0] - 2, 4, 4 ); dc.DrawRectangle(raw_dot[1] - 2, raw_dot[0] - 2, 4, 4);
// adjusted dot // adjusted dot
if ( adj_dot[1]!=32 || adj_dot[0]!=32 ) if (adj_dot[1]!=32 || adj_dot[0]!=32)
{ {
dc.SetPen(*wxRED_PEN); dc.SetPen(*wxRED_PEN);
dc.SetBrush(*wxRED_BRUSH); dc.SetBrush(*wxRED_BRUSH);
dc.DrawRectangle( adj_dot[1]-2, adj_dot[0]-2, 4, 4 ); dc.DrawRectangle(adj_dot[1]-2, adj_dot[0]-2, 4, 4);
} }
} }
break; break;
case GROUP_TYPE_BUTTONS : case GROUP_TYPE_BUTTONS :
{ {
const unsigned int button_count = ((unsigned int)(*g)->control_group->controls.size()); const unsigned int button_count = ((unsigned int)g->control_group->controls.size());
// draw the shit // draw the shit
dc.SetPen(*wxGREY_PEN); dc.SetPen(*wxGREY_PEN);
@ -265,23 +262,23 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
bitmasks[n] = (1 << n); bitmasks[n] = (1 << n);
unsigned int buttons = 0; unsigned int buttons = 0;
((ControllerEmu::Buttons*)(*g)->control_group)->GetState( &buttons, bitmasks ); ((ControllerEmu::Buttons*)g->control_group)->GetState(&buttons, bitmasks);
for (unsigned int n = 0; n<button_count; ++n) for (unsigned int n = 0; n<button_count; ++n)
{ {
if ( buttons & bitmasks[n] ) if (buttons & bitmasks[n])
{ {
dc.SetBrush( *wxRED_BRUSH ); dc.SetBrush(*wxRED_BRUSH);
} }
else else
{ {
unsigned char amt = 255 - (*g)->control_group->controls[n]->control_ref->State() * 128; unsigned char amt = 255 - g->control_group->controls[n]->control_ref->State() * 128;
dc.SetBrush(wxBrush(wxColor(amt, amt, amt))); dc.SetBrush(wxBrush(wxColor(amt, amt, amt)));
} }
dc.DrawRectangle(n * 12, 0, 14, 12); dc.DrawRectangle(n * 12, 0, 14, 12);
// text // text
const char* const name = (*g)->control_group->controls[n]->name; const char* const name = g->control_group->controls[n]->name;
// bit of hax so ZL, ZR show up as L, R // bit of hax so ZL, ZR show up as L, R
dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n*12 + 2, 1); dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n*12 + 2, 1);
} }
@ -292,18 +289,18 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
break; break;
case GROUP_TYPE_TRIGGERS : case GROUP_TYPE_TRIGGERS :
{ {
const unsigned int trigger_count = ((unsigned int)((*g)->control_group->controls.size())); const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size()));
// draw the shit // draw the shit
dc.SetPen(*wxGREY_PEN); dc.SetPen(*wxGREY_PEN);
ControlState deadzone = (*g)->control_group->settings[0]->value; ControlState deadzone = g->control_group->settings[0]->value;
unsigned int* const trigs = new unsigned int[trigger_count]; unsigned int* const trigs = new unsigned int[trigger_count];
((ControllerEmu::Triggers*)(*g)->control_group)->GetState( trigs, 64 ); ((ControllerEmu::Triggers*)g->control_group)->GetState(trigs, 64);
for ( unsigned int n = 0; n < trigger_count; ++n ) for (unsigned int n = 0; n < trigger_count; ++n)
{ {
ControlState trig_r = (*g)->control_group->controls[n]->control_ref->State(); ControlState trig_r = g->control_group->controls[n]->control_ref->State();
// outline // outline
dc.SetPen(*wxGREY_PEN); dc.SetPen(*wxGREY_PEN);
@ -319,7 +316,7 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
dc.DrawRectangle(0, n*12, trigs[n], 14); dc.DrawRectangle(0, n*12, trigs[n], 14);
// text // text
dc.DrawText(StrToWxStr((*g)->control_group->controls[n]->name), 3, n*12 + 1); dc.DrawText(StrToWxStr(g->control_group->controls[n]->name), 3, n*12 + 1);
} }
delete[] trigs; delete[] trigs;
@ -333,29 +330,29 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
break; break;
case GROUP_TYPE_MIXED_TRIGGERS : case GROUP_TYPE_MIXED_TRIGGERS :
{ {
const unsigned int trigger_count = ((unsigned int)((*g)->control_group->controls.size() / 2)); const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size() / 2));
// draw the shit // draw the shit
dc.SetPen(*wxGREY_PEN); dc.SetPen(*wxGREY_PEN);
ControlState thresh = (*g)->control_group->settings[0]->value; ControlState thresh = g->control_group->settings[0]->value;
for ( unsigned int n = 0; n < trigger_count; ++n ) for (unsigned int n = 0; n < trigger_count; ++n)
{ {
dc.SetBrush(*wxRED_BRUSH); dc.SetBrush(*wxRED_BRUSH);
ControlState trig_d = (*g)->control_group->controls[n]->control_ref->State(); ControlState trig_d = g->control_group->controls[n]->control_ref->State();
ControlState trig_a = trig_d > thresh ? 1 ControlState trig_a = trig_d > thresh ? 1
: (*g)->control_group->controls[n+trigger_count]->control_ref->State(); : g->control_group->controls[n+trigger_count]->control_ref->State();
dc.DrawRectangle(0, n*12, 64+20, 14); dc.DrawRectangle(0, n*12, 64+20, 14);
if ( trig_d <= thresh ) if (trig_d <= thresh)
dc.SetBrush(*wxWHITE_BRUSH); dc.SetBrush(*wxWHITE_BRUSH);
dc.DrawRectangle(trig_a*64, n*12, 64+20, 14); dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
dc.DrawRectangle(64, n*12, 32, 14); dc.DrawRectangle(64, n*12, 32, 14);
// text // text
dc.DrawText(StrToWxStr((*g)->control_group->controls[n+trigger_count]->name), 3, n*12 + 1); dc.DrawText(StrToWxStr(g->control_group->controls[n+trigger_count]->name), 3, n*12 + 1);
dc.DrawText(StrToWxStr(std::string(1, (*g)->control_group->controls[n]->name[0])), 64 + 3, n*12 + 1); dc.DrawText(StrToWxStr(std::string(1, g->control_group->controls[n]->name[0])), 64 + 3, n*12 + 1);
} }
// threshold box // threshold box
@ -367,14 +364,14 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
break; break;
case GROUP_TYPE_SLIDER: case GROUP_TYPE_SLIDER:
{ {
const ControlState deadzone = (*g)->control_group->settings[0]->value; const ControlState deadzone = g->control_group->settings[0]->value;
ControlState state = (*g)->control_group->controls[1]->control_ref->State() - (*g)->control_group->controls[0]->control_ref->State(); ControlState state = g->control_group->controls[1]->control_ref->State() - g->control_group->controls[0]->control_ref->State();
dc.SetPen(*wxGREY_PEN); dc.SetPen(*wxGREY_PEN);
dc.SetBrush(*wxGREY_BRUSH); dc.SetBrush(*wxGREY_BRUSH);
dc.DrawRectangle(31 + state * 30, 0, 2, 14); dc.DrawRectangle(31 + state * 30, 0, 2, 14);
((ControllerEmu::Slider*)(*g)->control_group)->GetState(&state, 1); ((ControllerEmu::Slider*)g->control_group)->GetState(&state, 1);
if (state) if (state)
{ {
dc.SetPen(*wxRED_PEN); dc.SetPen(*wxRED_PEN);
@ -399,7 +396,7 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight()); dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());
dc.SelectObject(wxNullBitmap); dc.SelectObject(wxNullBitmap);
(*g)->static_bitmap->SetBitmap(bitmap); g->static_bitmap->SetBitmap(bitmap);
} }
} }
} }

View File

@ -404,21 +404,26 @@ void ProgramShaderCache::Shutdown(void)
// store all shaders in cache on disk // store all shaders in cache on disk
if (g_ogl_config.bSupportsGLSLCache && !g_Config.bEnableShaderDebugging) if (g_ogl_config.bSupportsGLSLCache && !g_Config.bEnableShaderDebugging)
{ {
PCache::iterator iter = pshaders.begin(); for (auto& entry : pshaders)
for (; iter != pshaders.end(); ++iter)
{ {
if(iter->second.in_cache) continue; if(entry.second.in_cache)
{
continue;
}
GLint binary_size; GLint binary_size;
glGetProgramiv(iter->second.shader.glprogid, GL_PROGRAM_BINARY_LENGTH, &binary_size); glGetProgramiv(entry.second.shader.glprogid, GL_PROGRAM_BINARY_LENGTH, &binary_size);
if(!binary_size) continue; if(!binary_size)
{
continue;
}
u8 *data = new u8[binary_size+sizeof(GLenum)]; u8 *data = new u8[binary_size+sizeof(GLenum)];
u8 *binary = data + sizeof(GLenum); u8 *binary = data + sizeof(GLenum);
GLenum *prog_format = (GLenum*)data; GLenum *prog_format = (GLenum*)data;
glGetProgramBinary(iter->second.shader.glprogid, binary_size, NULL, prog_format, binary); glGetProgramBinary(entry.second.shader.glprogid, binary_size, NULL, prog_format, binary);
g_program_disk_cache.Append(iter->first, data, binary_size+sizeof(GLenum)); g_program_disk_cache.Append(entry.first, data, binary_size+sizeof(GLenum));
delete [] data; delete [] data;
} }
@ -428,9 +433,10 @@ void ProgramShaderCache::Shutdown(void)
glUseProgram(0); glUseProgram(0);
PCache::iterator iter = pshaders.begin(); for (auto& entry : pshaders)
for (; iter != pshaders.end(); ++iter) {
iter->second.Destroy(); entry.second.Destroy();
}
pshaders.clear(); pshaders.clear();
pixel_uid_checker.Invalidate(); pixel_uid_checker.Invalidate();

View File

@ -54,12 +54,12 @@ void DoState(PointerWrap &p)
{ {
ZSlope.DoState(p); ZSlope.DoState(p);
WSlope.DoState(p); WSlope.DoState(p);
for (auto& ColorSlope : ColorSlopes) for (auto& color_slopes_1d : ColorSlopes)
for (int n=0; n<4; ++n) for (Slope& color_slope : color_slopes_1d)
ColorSlope[n].DoState(p); color_slope.DoState(p);
for (auto& TexSlope : TexSlopes) for (auto& tex_slopes_1d : TexSlopes)
for (int n=0; n<3; ++n) for (Slope& tex_slope : tex_slopes_1d)
TexSlope[n].DoState(p); tex_slope.DoState(p);
p.Do(vertex0X); p.Do(vertex0X);
p.Do(vertex0Y); p.Do(vertex0Y);
p.Do(vertexOffsetX); p.Do(vertexOffsetX);

View File

@ -33,8 +33,10 @@ void Tev::Init()
FixedConstants[7] = 223; FixedConstants[7] = 223;
FixedConstants[8] = 255; FixedConstants[8] = 255;
for (int i = 0; i < 4; i++) for (s16& comp : Zero16)
Zero16[i] = 0; {
comp = 0;
}
m_ColorInputLUT[0][RED_INP] = &Reg[0][RED_C]; m_ColorInputLUT[0][GRN_INP] = &Reg[0][GRN_C]; m_ColorInputLUT[0][BLU_INP] = &Reg[0][BLU_C]; // prev.rgb m_ColorInputLUT[0][RED_INP] = &Reg[0][RED_C]; m_ColorInputLUT[0][GRN_INP] = &Reg[0][GRN_C]; m_ColorInputLUT[0][BLU_INP] = &Reg[0][BLU_C]; // prev.rgb
m_ColorInputLUT[1][RED_INP] = &Reg[0][ALP_C]; m_ColorInputLUT[1][GRN_INP] = &Reg[0][ALP_C]; m_ColorInputLUT[1][BLU_INP] = &Reg[0][ALP_C]; // prev.aaa m_ColorInputLUT[1][RED_INP] = &Reg[0][ALP_C]; m_ColorInputLUT[1][GRN_INP] = &Reg[0][ALP_C]; m_ColorInputLUT[1][BLU_INP] = &Reg[0][ALP_C]; // prev.aaa
@ -148,21 +150,27 @@ void Tev::SetRasColor(int colorChan, int swaptable)
break; break;
case 5: // alpha bump case 5: // alpha bump
{ {
for(int i = 0; i < 4; i++) for (s16& comp : RasColor)
RasColor[i] = AlphaBump; {
comp = AlphaBump;
}
} }
break; break;
case 6: // alpha bump normalized case 6: // alpha bump normalized
{ {
u8 normalized = AlphaBump | AlphaBump >> 5; u8 normalized = AlphaBump | AlphaBump >> 5;
for(int i = 0; i < 4; i++) for (s16& comp : RasColor)
RasColor[i] = normalized; {
comp = normalized;
}
} }
break; break;
default: // zero default: // zero
{ {
for(int i = 0; i < 4; i++) for (s16& comp : RasColor)
RasColor[i] = 0; {
comp = 0;
}
} }
break; break;
} }

View File

@ -22,12 +22,10 @@ FramebufferManagerBase::FramebufferManagerBase()
FramebufferManagerBase::~FramebufferManagerBase() FramebufferManagerBase::~FramebufferManagerBase()
{ {
VirtualXFBListType::iterator for (VirtualXFB& vxfb : m_virtualXFBList)
it = m_virtualXFBList.begin(), {
vlend = m_virtualXFBList.end(); delete vxfb.xfbSource;
for (; it != vlend; ++it) }
delete it->xfbSource;
m_virtualXFBList.clear(); m_virtualXFBList.clear();
delete m_realXFBSource; delete m_realXFBSource;

View File

@ -61,12 +61,10 @@ void TextureCache::RequestInvalidateTextureCache()
void TextureCache::Invalidate() void TextureCache::Invalidate()
{ {
TexCache::iterator for (auto& tex : textures)
iter = textures.begin(), {
tcend = textures.end(); delete tex.second;
for (; iter != tcend; ++iter) }
delete iter->second;
textures.clear(); textures.clear();
} }