Fixed some memory leaks. Only one was mine ;P
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7392 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
017735b9ff
commit
f8620fcd0b
|
@ -31,6 +31,8 @@ namespace AudioCommon
|
||||||
{
|
{
|
||||||
SoundStream *InitSoundStream(CMixer *mixer, void *hWnd)
|
SoundStream *InitSoundStream(CMixer *mixer, void *hWnd)
|
||||||
{
|
{
|
||||||
|
// TODO: possible memleak with mixer
|
||||||
|
|
||||||
std::string backend = ac_Config.sBackend;
|
std::string backend = ac_Config.sBackend;
|
||||||
if (backend == BACKEND_OPENAL && OpenALStream::isValid())
|
if (backend == BACKEND_OPENAL && OpenALStream::isValid())
|
||||||
soundStream = new OpenALStream(mixer);
|
soundStream = new OpenALStream(mixer);
|
||||||
|
|
|
@ -119,9 +119,12 @@ public:
|
||||||
|
|
||||||
// Store vectors.
|
// Store vectors.
|
||||||
template<class T>
|
template<class T>
|
||||||
void Do(std::vector<T> &x) {
|
void Do(std::vector<T> &x)
|
||||||
// TODO
|
{
|
||||||
PanicAlert("Do(vector<>) does not yet work.");
|
u32 vec_size = (u32)x.size();
|
||||||
|
Do(vec_size);
|
||||||
|
x.resize(vec_size);
|
||||||
|
DoArray(&x[0], vec_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store strings.
|
// Store strings.
|
||||||
|
@ -139,23 +142,6 @@ public:
|
||||||
(*ptr) += stringLen;
|
(*ptr) += stringLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoBuffer(u8** pBuffer, u32& _Size)
|
|
||||||
{
|
|
||||||
Do(_Size);
|
|
||||||
|
|
||||||
if (_Size > 0) {
|
|
||||||
switch (mode) {
|
|
||||||
case MODE_READ: delete[] *pBuffer; *pBuffer = new u8[_Size]; memcpy(*pBuffer, *ptr, _Size); break;
|
|
||||||
case MODE_WRITE: memcpy(*ptr, *pBuffer, _Size); break;
|
|
||||||
case MODE_MEASURE: break;
|
|
||||||
case MODE_VERIFY: if(*pBuffer) for(u32 i = 0; i < _Size; i++) _dbg_assert_msg_(COMMON, (*pBuffer)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", (*pBuffer)[i], (*pBuffer)[i], &(*pBuffer)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*pBuffer = NULL;
|
|
||||||
}
|
|
||||||
(*ptr) += _Size;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void DoArray(T *x, int count) {
|
void DoArray(T *x, int count) {
|
||||||
DoVoid((void *)x, sizeof(T) * count);
|
DoVoid((void *)x, sizeof(T) * count);
|
||||||
|
@ -260,9 +246,9 @@ public:
|
||||||
u8 *ptr = 0;
|
u8 *ptr = 0;
|
||||||
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
PointerWrap p(&ptr, PointerWrap::MODE_MEASURE);
|
||||||
_class.DoState(p);
|
_class.DoState(p);
|
||||||
size_t sz = (size_t)ptr;
|
size_t const sz = (size_t)ptr;
|
||||||
u8 *buffer = new u8[sz];
|
std::vector<u8> buffer(sz);
|
||||||
ptr = buffer;
|
ptr = &buffer[0];
|
||||||
p.SetMode(PointerWrap::MODE_WRITE);
|
p.SetMode(PointerWrap::MODE_WRITE);
|
||||||
_class.DoState(p);
|
_class.DoState(p);
|
||||||
|
|
||||||
|
@ -279,7 +265,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pFile.WriteBytes(buffer, sz))
|
if (!pFile.WriteBytes(&buffer[0], sz))
|
||||||
{
|
{
|
||||||
ERROR_LOG(COMMON,"ChunkReader: Failed writing data");
|
ERROR_LOG(COMMON,"ChunkReader: Failed writing data");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <array>
|
||||||
#else
|
#else
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -175,8 +176,8 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
|
||||||
bool DAft = true;
|
bool DAft = true;
|
||||||
std::string SLog = "";
|
std::string SLog = "";
|
||||||
|
|
||||||
HWND hWnd = GetConsoleWindow();
|
const HWND hWnd = GetConsoleWindow();
|
||||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
// Get console info
|
// Get console info
|
||||||
CONSOLE_SCREEN_BUFFER_INFO ConInfo;
|
CONSOLE_SCREEN_BUFFER_INFO ConInfo;
|
||||||
|
@ -189,30 +190,30 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
|
||||||
DWORD cCharsRead = 0;
|
DWORD cCharsRead = 0;
|
||||||
COORD coordScreen = { 0, 0 };
|
COORD coordScreen = { 0, 0 };
|
||||||
|
|
||||||
std::vector<char*> Str;
|
static const int MAX_BYTES = 1024 * 16;
|
||||||
std::vector<WORD*> Attr;
|
|
||||||
|
std::vector<std::array<CHAR, MAX_BYTES>> Str;
|
||||||
|
std::vector<std::array<WORD, MAX_BYTES>> Attr;
|
||||||
|
|
||||||
// ReadConsoleOutputAttribute seems to have a limit at this level
|
// ReadConsoleOutputAttribute seems to have a limit at this level
|
||||||
const int MAX_BYTES = 1024 * 16;
|
static const int ReadBufferSize = MAX_BYTES - 32;
|
||||||
int ReadBufferSize = MAX_BYTES - 32;
|
|
||||||
DWORD cAttrRead = ReadBufferSize;
|
DWORD cAttrRead = ReadBufferSize;
|
||||||
DWORD BytesRead = 0;
|
DWORD BytesRead = 0;
|
||||||
int i = 0;
|
|
||||||
int LastAttrRead = 0;
|
|
||||||
while (BytesRead < BufferSize)
|
while (BytesRead < BufferSize)
|
||||||
{
|
{
|
||||||
Str.push_back(new char[MAX_BYTES]);
|
Str.resize(Str.size() + 1);
|
||||||
if (!ReadConsoleOutputCharacter(hConsole, Str[i], ReadBufferSize, coordScreen, &cCharsRead))
|
if (!ReadConsoleOutputCharacter(hConsole, Str.back().data(), ReadBufferSize, coordScreen, &cCharsRead))
|
||||||
SLog += StringFromFormat("WriteConsoleOutputCharacter error");
|
SLog += StringFromFormat("WriteConsoleOutputCharacter error");
|
||||||
Attr.push_back(new WORD[MAX_BYTES]);
|
|
||||||
if (!ReadConsoleOutputAttribute(hConsole, Attr[i], ReadBufferSize, coordScreen, &cAttrRead))
|
Attr.resize(Attr.size() + 1);
|
||||||
|
if (!ReadConsoleOutputAttribute(hConsole, Attr.back().data(), ReadBufferSize, coordScreen, &cAttrRead))
|
||||||
SLog += StringFromFormat("WriteConsoleOutputAttribute error");
|
SLog += StringFromFormat("WriteConsoleOutputAttribute error");
|
||||||
|
|
||||||
// Break on error
|
// Break on error
|
||||||
if (cAttrRead == 0) break;
|
if (cAttrRead == 0) break;
|
||||||
BytesRead += cAttrRead;
|
BytesRead += cAttrRead;
|
||||||
i++;
|
|
||||||
coordScreen = GetCoordinates(BytesRead, ConInfo.dwSize.X);
|
coordScreen = GetCoordinates(BytesRead, ConInfo.dwSize.X);
|
||||||
LastAttrRead = cAttrRead;
|
|
||||||
}
|
}
|
||||||
// Letter space
|
// Letter space
|
||||||
int LWidth = (int)(floor((float)Width / 8.0f) - 1.0f);
|
int LWidth = (int)(floor((float)Width / 8.0f) - 1.0f);
|
||||||
|
@ -232,16 +233,16 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
|
||||||
DWORD cAttrWritten = 0;
|
DWORD cAttrWritten = 0;
|
||||||
for (size_t i = 0; i < Attr.size(); i++)
|
for (size_t i = 0; i < Attr.size(); i++)
|
||||||
{
|
{
|
||||||
if (!WriteConsoleOutputCharacter(hConsole, Str[i], ReadBufferSize, coordScreen, &cCharsWritten))
|
if (!WriteConsoleOutputCharacter(hConsole, Str[i].data(), ReadBufferSize, coordScreen, &cCharsWritten))
|
||||||
SLog += StringFromFormat("WriteConsoleOutputCharacter error");
|
SLog += StringFromFormat("WriteConsoleOutputCharacter error");
|
||||||
if (!WriteConsoleOutputAttribute(hConsole, Attr[i], ReadBufferSize, coordScreen, &cAttrWritten))
|
if (!WriteConsoleOutputAttribute(hConsole, Attr[i].data(), ReadBufferSize, coordScreen, &cAttrWritten))
|
||||||
SLog += StringFromFormat("WriteConsoleOutputAttribute error");
|
SLog += StringFromFormat("WriteConsoleOutputAttribute error");
|
||||||
|
|
||||||
BytesWritten += cAttrWritten;
|
BytesWritten += cAttrWritten;
|
||||||
coordScreen = GetCoordinates(BytesWritten, LBufWidth);
|
coordScreen = GetCoordinates(BytesWritten, LBufWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OldCursor = ConInfo.dwCursorPosition.Y * ConInfo.dwSize.X + ConInfo.dwCursorPosition.X;
|
const int OldCursor = ConInfo.dwCursorPosition.Y * ConInfo.dwSize.X + ConInfo.dwCursorPosition.X;
|
||||||
COORD Coo = GetCoordinates(OldCursor, LBufWidth);
|
COORD Coo = GetCoordinates(OldCursor, LBufWidth);
|
||||||
SetConsoleCursorPosition(hConsole, Coo);
|
SetConsoleCursorPosition(hConsole, Coo);
|
||||||
|
|
||||||
|
|
|
@ -677,7 +677,7 @@ bool WriteStringToFile(bool text_file, const std::string &str, const char *filen
|
||||||
if (!f)
|
if (!f)
|
||||||
return false;
|
return false;
|
||||||
size_t len = str.size();
|
size_t len = str.size();
|
||||||
if (len != fwrite(str.data(), 1, str.size(), f))
|
if (len != fwrite(str.data(), 1, str.size(), f)) // TODO: string::data() may not be contiguous
|
||||||
{
|
{
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -41,7 +41,6 @@ DSPEmitter::DSPEmitter() : gpr(*this), storeIndex(-1), storeIndex2(-1)
|
||||||
blocks = new DSPCompiledCode[MAX_BLOCKS];
|
blocks = new DSPCompiledCode[MAX_BLOCKS];
|
||||||
blockLinks = new Block[MAX_BLOCKS];
|
blockLinks = new Block[MAX_BLOCKS];
|
||||||
blockSize = new u16[MAX_BLOCKS];
|
blockSize = new u16[MAX_BLOCKS];
|
||||||
unresolvedJumps = new std::list<u16>[MAX_BLOCKS];
|
|
||||||
|
|
||||||
compileSR = 0;
|
compileSR = 0;
|
||||||
compileSR |= SR_INT_ENABLE;
|
compileSR |= SR_INT_ENABLE;
|
||||||
|
|
|
@ -260,7 +260,7 @@ public:
|
||||||
u16 startAddr;
|
u16 startAddr;
|
||||||
Block *blockLinks;
|
Block *blockLinks;
|
||||||
u16 *blockSize;
|
u16 *blockSize;
|
||||||
std::list<u16> *unresolvedJumps;
|
std::list<u16> unresolvedJumps[MAX_BLOCKS];
|
||||||
|
|
||||||
DSPJitRegCache gpr;
|
DSPJitRegCache gpr;
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
#ifndef _DSPEMULATOR_H_
|
#ifndef _DSPEMULATOR_H_
|
||||||
#define _DSPEMULATOR_H_
|
#define _DSPEMULATOR_H_
|
||||||
|
|
||||||
|
|
||||||
#include "ChunkFile.h"
|
#include "ChunkFile.h"
|
||||||
|
#include "SoundStream.h"
|
||||||
|
|
||||||
class DSPEmulator
|
class DSPEmulator
|
||||||
{
|
{
|
||||||
|
@ -43,6 +43,9 @@ public:
|
||||||
virtual void DSP_Update(int cycles) = 0;
|
virtual void DSP_Update(int cycles) = 0;
|
||||||
virtual void DSP_StopSoundStream() = 0;
|
virtual void DSP_StopSoundStream() = 0;
|
||||||
virtual void DSP_ClearAudioBuffer(bool mute) = 0;
|
virtual void DSP_ClearAudioBuffer(bool mute) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SoundStream *soundStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
DSPEmulator *CreateDSPEmulator(bool LLE);
|
DSPEmulator *CreateDSPEmulator(bool LLE);
|
||||||
|
|
|
@ -61,7 +61,6 @@ private:
|
||||||
bool m_bWii;
|
bool m_bWii;
|
||||||
|
|
||||||
bool m_InitMixer;
|
bool m_InitMixer;
|
||||||
SoundStream *soundStream;
|
|
||||||
|
|
||||||
// Fake mailbox utility
|
// Fake mailbox utility
|
||||||
struct DSPState
|
struct DSPState
|
||||||
|
|
|
@ -48,7 +48,6 @@ private:
|
||||||
static void dsp_thread(DSPLLE* lpParameter);
|
static void dsp_thread(DSPLLE* lpParameter);
|
||||||
|
|
||||||
std::thread m_hDSPThread;
|
std::thread m_hDSPThread;
|
||||||
SoundStream *soundStream;
|
|
||||||
bool m_InitMixer;
|
bool m_InitMixer;
|
||||||
void *m_hWnd;
|
void *m_hWnd;
|
||||||
bool m_bWii;
|
bool m_bWii;
|
||||||
|
|
|
@ -117,25 +117,21 @@ bool CWII_IPC_HLE_Device_di::IOCtlV(u32 _CommandAddress)
|
||||||
_dbg_assert_msg_(WII_IPC_DVD, CommandBuffer.InBuffer[1].m_Address == 0, "DVDLowOpenPartition with ticket");
|
_dbg_assert_msg_(WII_IPC_DVD, CommandBuffer.InBuffer[1].m_Address == 0, "DVDLowOpenPartition with ticket");
|
||||||
_dbg_assert_msg_(WII_IPC_DVD, CommandBuffer.InBuffer[2].m_Address == 0, "DVDLowOpenPartition with cert chain");
|
_dbg_assert_msg_(WII_IPC_DVD, CommandBuffer.InBuffer[2].m_Address == 0, "DVDLowOpenPartition with cert chain");
|
||||||
|
|
||||||
bool readOK = false;
|
|
||||||
|
|
||||||
// Get TMD offset for requested partition...
|
// Get TMD offset for requested partition...
|
||||||
u64 TMDOffset = ((u64)Memory::Read_U32(CommandBuffer.InBuffer[0].m_Address + 4) << 2 ) + 0x2c0;
|
u64 const TMDOffset = ((u64)Memory::Read_U32(CommandBuffer.InBuffer[0].m_Address + 4) << 2 ) + 0x2c0;
|
||||||
|
|
||||||
INFO_LOG(WII_IPC_DVD, "DVDLowOpenPartition: TMDOffset 0x%016llx", TMDOffset);
|
INFO_LOG(WII_IPC_DVD, "DVDLowOpenPartition: TMDOffset 0x%016llx", TMDOffset);
|
||||||
|
|
||||||
u32 TMDsz = 0x208; //CommandBuffer.PayloadBuffer[0].m_Size;
|
static u32 const TMDsz = 0x208; //CommandBuffer.PayloadBuffer[0].m_Size;
|
||||||
u8 *pTMD = new u8[TMDsz];
|
u8 pTMD[TMDsz];
|
||||||
if (pTMD)
|
|
||||||
{
|
|
||||||
// Read TMD to the buffer
|
// Read TMD to the buffer
|
||||||
VolumeHandler::RAWReadToPtr(pTMD, TMDOffset, TMDsz);
|
VolumeHandler::RAWReadToPtr(pTMD, TMDOffset, TMDsz);
|
||||||
|
|
||||||
memcpy(Memory::GetPointer(CommandBuffer.PayloadBuffer[0].m_Address), pTMD, TMDsz);
|
memcpy(Memory::GetPointer(CommandBuffer.PayloadBuffer[0].m_Address), pTMD, TMDsz);
|
||||||
readOK |= true;
|
|
||||||
WII_IPC_HLE_Interface::ES_DIVerify(pTMD, TMDsz);
|
WII_IPC_HLE_Interface::ES_DIVerify(pTMD, TMDsz);
|
||||||
}
|
|
||||||
ReturnValue = readOK ? 1 : 0;
|
ReturnValue = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ private:
|
||||||
ACLQ(const u8* data, const size_t size, const u16 conn_handle)
|
ACLQ(const u8* data, const size_t size, const u16 conn_handle)
|
||||||
: m_size(size), m_conn_handle(conn_handle)
|
: m_size(size), m_conn_handle(conn_handle)
|
||||||
{
|
{
|
||||||
m_buffer = new u8[m_size];
|
m_buffer = new u8[m_size]; // TODO: memleak
|
||||||
memcpy(m_buffer, data, m_size);
|
memcpy(m_buffer, data, m_size);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -147,6 +147,12 @@ CGameListCtrl::~CGameListCtrl()
|
||||||
{
|
{
|
||||||
if (m_imageListSmall)
|
if (m_imageListSmall)
|
||||||
delete m_imageListSmall;
|
delete m_imageListSmall;
|
||||||
|
|
||||||
|
while (!m_ISOFiles.empty()) // so lazy
|
||||||
|
{
|
||||||
|
delete m_ISOFiles.back();
|
||||||
|
m_ISOFiles.pop_back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameListCtrl::InitBitmaps()
|
void CGameListCtrl::InitBitmaps()
|
||||||
|
@ -276,7 +282,7 @@ void CGameListCtrl::Update()
|
||||||
for (int i = 0; i < (int)m_ISOFiles.size(); i++)
|
for (int i = 0; i < (int)m_ISOFiles.size(); i++)
|
||||||
{
|
{
|
||||||
InsertItemInReportView(i);
|
InsertItemInReportView(i);
|
||||||
if (m_ISOFiles[i].IsCompressed())
|
if (m_ISOFiles[i]->IsCompressed())
|
||||||
SetItemTextColour(i, wxColour(0xFF0000));
|
SetItemTextColour(i, wxColour(0xFF0000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +381,7 @@ void CGameListCtrl::OnPaintDrawImages(wxPaintEvent& event)
|
||||||
if (GetItemRect(i, itemRect))
|
if (GetItemRect(i, itemRect))
|
||||||
{
|
{
|
||||||
int itemY = itemRect.GetTop();
|
int itemY = itemRect.GetTop();
|
||||||
const GameListItem& rISOFile = m_ISOFiles[GetItemData(i)];
|
const GameListItem& rISOFile = *m_ISOFiles[GetItemData(i)];
|
||||||
|
|
||||||
m_imageListSmall->Draw(m_PlatformImageIndex[rISOFile.GetPlatform()],
|
m_imageListSmall->Draw(m_PlatformImageIndex[rISOFile.GetPlatform()],
|
||||||
dc, itemRect.GetX()+3, itemY);
|
dc, itemRect.GetX()+3, itemY);
|
||||||
|
@ -415,7 +421,7 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
|
||||||
wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP));
|
wxCSConv SJISConv(wxFontMapper::GetEncodingName(wxFONTENCODING_EUC_JP));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GameListItem& rISOFile = m_ISOFiles[_Index];
|
GameListItem& rISOFile = *m_ISOFiles[_Index];
|
||||||
m_gamePath.append(rISOFile.GetFileName() + '\n');
|
m_gamePath.append(rISOFile.GetFileName() + '\n');
|
||||||
|
|
||||||
// Insert a first row with the platform image, that will be used as the Index
|
// Insert a first row with the platform image, that will be used as the Index
|
||||||
|
@ -612,7 +618,9 @@ void CGameListCtrl::ScanForISOs()
|
||||||
if (!Cont)
|
if (!Cont)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
GameListItem ISOFile(rFilenames[i]);
|
GameListItem* const iso_file = new GameListItem(rFilenames[i]);
|
||||||
|
const GameListItem& ISOFile = *iso_file;
|
||||||
|
|
||||||
if (ISOFile.IsValid())
|
if (ISOFile.IsValid())
|
||||||
{
|
{
|
||||||
bool list = true;
|
bool list = true;
|
||||||
|
@ -665,21 +673,21 @@ void CGameListCtrl::ScanForISOs()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list)
|
if (list)
|
||||||
m_ISOFiles.push_back(ISOFile);
|
m_ISOFiles.push_back(iso_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SConfig::GetInstance().m_ListDrives)
|
if (SConfig::GetInstance().m_ListDrives)
|
||||||
{
|
{
|
||||||
std::vector<std::string> drives = cdio_get_devices();
|
const std::vector<std::string> drives = cdio_get_devices();
|
||||||
GameListItem * Drive[24];
|
|
||||||
// Another silly Windows limitation of 24 drive letters
|
for (std::vector<std::string>::const_iterator iter = drives.begin(); iter != drives.end(); ++iter)
|
||||||
for (u32 i = 0; i < drives.size() && i < 24; i++)
|
|
||||||
{
|
{
|
||||||
Drive[i] = new GameListItem(drives[i].c_str());
|
std::auto_ptr<GameListItem> gli(new GameListItem(*iter));
|
||||||
if (Drive[i]->IsValid())
|
|
||||||
m_ISOFiles.push_back(*Drive[i]);
|
if (gli->IsValid())
|
||||||
|
m_ISOFiles.push_back(gli.release());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,10 +700,12 @@ void CGameListCtrl::OnColBeginDrag(wxListEvent& event)
|
||||||
event.Veto();
|
event.Veto();
|
||||||
}
|
}
|
||||||
|
|
||||||
const GameListItem *CGameListCtrl::GetISO(int index) const
|
const GameListItem *CGameListCtrl::GetISO(size_t index) const
|
||||||
{
|
{
|
||||||
if (index >= (int)m_ISOFiles.size()) return NULL;
|
if (index < m_ISOFiles.size())
|
||||||
return &m_ISOFiles[index];
|
return m_ISOFiles[index];
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGameListCtrl *caller;
|
CGameListCtrl *caller;
|
||||||
|
@ -906,7 +916,7 @@ void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GameListItem& rISO = m_ISOFiles[GetItemData(item)];
|
const GameListItem& rISO = *m_ISOFiles[GetItemData(item)];
|
||||||
|
|
||||||
IniFile ini;
|
IniFile ini;
|
||||||
ini.Load(File::GetUserPath(D_GAMECONFIG_IDX) + rISO.GetUniqueID() + ".ini");
|
ini.Load(File::GetUserPath(D_GAMECONFIG_IDX) + rISO.GetUniqueID() + ".ini");
|
||||||
|
@ -1061,7 +1071,7 @@ const GameListItem * CGameListCtrl::GetSelectedISO()
|
||||||
if (GetSelectedItemCount() > 1)
|
if (GetSelectedItemCount() > 1)
|
||||||
SetItemState(item, 0, wxLIST_STATE_SELECTED);
|
SetItemState(item, 0, wxLIST_STATE_SELECTED);
|
||||||
|
|
||||||
return &m_ISOFiles[GetItemData(item)];
|
return m_ISOFiles[GetItemData(item)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
|
|
||||||
void BrowseForDirectory();
|
void BrowseForDirectory();
|
||||||
const GameListItem *GetSelectedISO();
|
const GameListItem *GetSelectedISO();
|
||||||
const GameListItem *GetISO(int index) const;
|
const GameListItem *GetISO(size_t index) const;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ private:
|
||||||
std::vector<int> m_FlagImageIndex;
|
std::vector<int> m_FlagImageIndex;
|
||||||
std::vector<int> m_PlatformImageIndex;
|
std::vector<int> m_PlatformImageIndex;
|
||||||
std::vector<int> m_EmuStateImageIndex;
|
std::vector<int> m_EmuStateImageIndex;
|
||||||
std::vector<GameListItem> m_ISOFiles;
|
std::vector<GameListItem*> m_ISOFiles;
|
||||||
|
|
||||||
// NetPlay string for the gamelist
|
// NetPlay string for the gamelist
|
||||||
std::string m_gameList;
|
std::string m_gameList;
|
||||||
|
|
|
@ -47,8 +47,6 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
||||||
, m_FileSize(0)
|
, m_FileSize(0)
|
||||||
, m_Valid(false)
|
, m_Valid(false)
|
||||||
, m_BlobCompressed(false)
|
, m_BlobCompressed(false)
|
||||||
, m_pImage(NULL)
|
|
||||||
, m_ImageSize(0)
|
|
||||||
{
|
{
|
||||||
if (LoadFromCache())
|
if (LoadFromCache())
|
||||||
{
|
{
|
||||||
|
@ -100,9 +98,8 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
||||||
pBannerLoader->GetDescription(m_Description);
|
pBannerLoader->GetDescription(m_Description);
|
||||||
if (pBannerLoader->GetBanner(g_ImageTemp))
|
if (pBannerLoader->GetBanner(g_ImageTemp))
|
||||||
{
|
{
|
||||||
m_ImageSize = DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT * 3;
|
// resize vector to image size
|
||||||
//use malloc(), since wxImage::Create below calls free() afterwards.
|
m_pImage.resize(DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT * 3);
|
||||||
m_pImage = (u8*)malloc(m_ImageSize);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT; i++)
|
for (size_t i = 0; i < DVD_BANNER_WIDTH * DVD_BANNER_HEIGHT; i++)
|
||||||
{
|
{
|
||||||
|
@ -124,14 +121,14 @@ GameListItem::GameListItem(const std::string& _rFileName)
|
||||||
|
|
||||||
// If not Gamecube, create a cache file only if we have an image.
|
// If not Gamecube, create a cache file only if we have an image.
|
||||||
// Wii isos create their images after you have generated the first savegame
|
// Wii isos create their images after you have generated the first savegame
|
||||||
if (m_Platform == GAMECUBE_DISC || m_pImage)
|
if (m_Platform == GAMECUBE_DISC || !m_pImage.empty())
|
||||||
SaveToCache();
|
SaveToCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pImage)
|
if (!m_pImage.empty())
|
||||||
{
|
{
|
||||||
m_Image.Create(DVD_BANNER_WIDTH, DVD_BANNER_HEIGHT, m_pImage);
|
m_Image.Create(DVD_BANNER_WIDTH, DVD_BANNER_HEIGHT, &m_pImage[0], true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -173,7 +170,7 @@ void GameListItem::DoState(PointerWrap &p)
|
||||||
p.Do(m_VolumeSize);
|
p.Do(m_VolumeSize);
|
||||||
p.Do(m_Country);
|
p.Do(m_Country);
|
||||||
p.Do(m_BlobCompressed);
|
p.Do(m_BlobCompressed);
|
||||||
p.DoBuffer(&m_pImage, m_ImageSize);
|
p.Do(m_pImage);
|
||||||
p.Do(m_Platform);
|
p.Do(m_Platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class PointerWrap;
|
class PointerWrap;
|
||||||
class GameListItem
|
class GameListItem : NonCopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GameListItem(const std::string& _rFileName);
|
GameListItem(const std::string& _rFileName);
|
||||||
|
@ -78,7 +78,7 @@ private:
|
||||||
#endif
|
#endif
|
||||||
bool m_Valid;
|
bool m_Valid;
|
||||||
bool m_BlobCompressed;
|
bool m_BlobCompressed;
|
||||||
u8* m_pImage;
|
std::vector<u8> m_pImage;
|
||||||
u32 m_ImageSize;
|
u32 m_ImageSize;
|
||||||
|
|
||||||
bool LoadFromCache();
|
bool LoadFromCache();
|
||||||
|
|
|
@ -447,7 +447,7 @@ ControllerInterface::Device* ControllerInterface::FindDevice(const ControllerInt
|
||||||
ControllerInterface::Device::Control* ControllerInterface::InputReference::Detect(const unsigned int ms, Device* const device)
|
ControllerInterface::Device::Control* ControllerInterface::InputReference::Detect(const unsigned int ms, Device* const device)
|
||||||
{
|
{
|
||||||
unsigned int time = 0;
|
unsigned int time = 0;
|
||||||
bool* const states = new bool[device->Inputs().size()];
|
std::vector<bool> states(device->Inputs().size());
|
||||||
|
|
||||||
if (device->Inputs().size() == 0)
|
if (device->Inputs().size() == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -457,14 +457,14 @@ ControllerInterface::Device::Control* ControllerInterface::InputReference::Detec
|
||||||
std::vector<Device::Input*>::const_iterator
|
std::vector<Device::Input*>::const_iterator
|
||||||
i = device->Inputs().begin(),
|
i = device->Inputs().begin(),
|
||||||
e = device->Inputs().end();
|
e = device->Inputs().end();
|
||||||
for (bool* state=states; i != e; ++i)
|
for (std::vector<bool>::iterator state = states.begin(); i != e; ++i)
|
||||||
*state++ = ((*i)->GetState() > INPUT_DETECT_THRESHOLD);
|
*state++ = ((*i)->GetState() > INPUT_DETECT_THRESHOLD);
|
||||||
|
|
||||||
while (time < ms)
|
while (time < ms)
|
||||||
{
|
{
|
||||||
device->UpdateInput();
|
device->UpdateInput();
|
||||||
i = device->Inputs().begin();
|
i = device->Inputs().begin();
|
||||||
for (bool* state=states; i != e; ++i,++state)
|
for (std::vector<bool>::iterator state = states.begin(); i != e; ++i,++state)
|
||||||
{
|
{
|
||||||
// detected an input
|
// detected an input
|
||||||
if ((*i)->IsDetectable() && (*i)->GetState() > INPUT_DETECT_THRESHOLD)
|
if ((*i)->IsDetectable() && (*i)->GetState() > INPUT_DETECT_THRESHOLD)
|
||||||
|
@ -480,8 +480,6 @@ ControllerInterface::Device::Control* ControllerInterface::InputReference::Detec
|
||||||
Common::SleepCurrentThread(10); time += 10;
|
Common::SleepCurrentThread(10); time += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] states;
|
|
||||||
|
|
||||||
// no input was detected
|
// no input was detected
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ void TexDecoder_OpenCL_Initialize()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
binary_size = input.GetSize();
|
binary_size = input.GetSize();
|
||||||
header = new char[HEADER_SIZE];
|
header = new char[HEADER_SIZE]; // TODO: memleak possible
|
||||||
binary = new char[binary_size];
|
binary = new char[binary_size];
|
||||||
input.ReadBytes(header, HEADER_SIZE);
|
input.ReadBytes(header, HEADER_SIZE);
|
||||||
input.ReadBytes(binary, binary_size);
|
input.ReadBytes(binary, binary_size);
|
||||||
|
|
|
@ -1571,7 +1571,7 @@ bool Renderer::SaveScreenshot(const std::string &filename, const TargetRectangle
|
||||||
{
|
{
|
||||||
u32 W = back_rc.GetWidth();
|
u32 W = back_rc.GetWidth();
|
||||||
u32 H = back_rc.GetHeight();
|
u32 H = back_rc.GetHeight();
|
||||||
u8 *data = new u8[3 * W * H];
|
u8 *data = new u8[3 * W * H]; // TODO: possible memleak, and new'd data is given to wxImage which requires malloc
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
glReadPixels(back_rc.left, back_rc.bottom, W, H, GL_RGB, GL_UNSIGNED_BYTE, data);
|
glReadPixels(back_rc.left, back_rc.bottom, W, H, GL_RGB, GL_UNSIGNED_BYTE, data);
|
||||||
|
|
Loading…
Reference in New Issue