[Project64] Clean up some code and warnings in Common code

This commit is contained in:
zilmar 2018-11-18 11:36:02 +10:30
parent e7f93f2def
commit 3b0e7a8527
10 changed files with 43 additions and 22 deletions

View File

@ -55,7 +55,7 @@ void CIniFileBase::fInsertSpaces(int Pos, int NoOfSpaces)
if (NoOfSpaces < 0)
{
int ReadPos = Pos + (NoOfSpaces * -1);
int WritePos = Pos;
WritePos = Pos;
do
{
@ -338,6 +338,18 @@ bool CIniFileBase::MoveToSectionNameData(const char * lpSectionName, bool Change
} while (result >= 0);
}
if (!bFoundSection && strcmp(lpSectionName, "default") == 0)
{
m_SectionsPos.insert(FILELOC::value_type(lpSectionName, 0));
if (ChangeCurrentSection)
{
m_CurrentSection = lpSectionName;
m_CurrentSectionFilePos = 0;
}
m_File.Seek(m_lastSectionSearch, CFileBase::begin);
bFoundSection = true;
}
if (bFoundSection && ChangeCurrentSection)
{
m_CurrentSectionData.clear();
@ -482,7 +494,7 @@ bool CIniFileBase::DeleteSection(const char * lpSectionName)
{
return false;
}
uint32_t dwRet = m_File.Read(pData.get(), dwSize);
uint32_t dwRet = m_File.Read(pData.get(), (uint32_t)dwSize);
if (dwRet == 0 || dwRet < dwSize)
{
return false;
@ -502,11 +514,11 @@ bool CIniFileBase::DeleteSection(const char * lpSectionName)
char *pEndSection = pSection + strlen(strSection.c_str()), *Data = pData.get();
char *pNextSection = NULL;
int result, ReadPos = pEndSection - pData.get();
int result, ReadPos = (int)(pEndSection - pData.get());
do
{
char * Input = NULL;
int MaxDataSize = dwSize + 1;
int MaxDataSize = (int)(dwSize + 1);
result = -1;
for (int count = ReadPos; count < MaxDataSize; count++)
{

View File

@ -27,8 +27,9 @@ class CIniFileBase
typedef std::map<std::string, std::string, insensitive_compare> KeyValueList;
public:
typedef std::map<std::string, std::string> KeyValueData;
typedef std::vector<std::string> SectionList;
typedef std::map<std::string, std::string> KeyValueData;
typedef std::vector<std::string> SectionList;
typedef std::list<std::string> strlist;
protected:
CFileBase & m_File;

View File

@ -82,7 +82,7 @@ void CLog::LogArgs(const char * Message, va_list & args )
void CLog::Log( const char * Message )
{
if (!m_hLogFile.IsOpen()) { return; }
uint32_t message_len = strlen(Message);
uint32_t message_len = (uint32_t)strlen(Message);
m_hLogFile.Write(Message, message_len);
if (m_FlushOnWrite)
{
@ -113,8 +113,6 @@ void CLog::Log( const char * Message )
do
{
uint8_t Data[300];
uint32_t dwRead;
dwRead = m_hLogFile.Read(Data,sizeof(Data));
if (dwRead == 0)
{
@ -146,7 +144,6 @@ void CLog::Log( const char * Message )
m_hLogFile.Seek(ReadPos,CFile::begin);
uint32_t dwRead;
dwRead = m_hLogFile.Read(Data,SizeToRead);
m_hLogFile.Seek(WritePos,CFile::begin);

View File

@ -66,6 +66,7 @@ void* AllocateAddressSpace(size_t size, void * base_address)
bool FreeAddressSpace(void* addr, size_t size)
{
#ifdef _WIN32
size = 0; //unused
return VirtualFree(addr, 0, MEM_RELEASE) != 0;
#else
msync(addr, size, MS_SYNC);

View File

@ -60,5 +60,5 @@ public:
};
#endif
typedef std::list<stdstr> strlist;
typedef strlist::iterator strlist_iter;
typedef std::list<stdstr> strlist;
typedef strlist::iterator strlist_iter;

View File

@ -66,7 +66,11 @@ void * CThread::ThreadWrapper (CThread * _this)
void * res = NULL;
try
{
#if defined(__i386__) || defined(_M_IX86) || defined(__arm__) || defined(_M_ARM)
res = (void *)_this->m_StartAddress(_this->m_lpThreadParameter);
#else
res = (void *)((uint64_t)_this->m_StartAddress(_this->m_lpThreadParameter));
#endif
}
catch (...)
{

View File

@ -1,4 +1,5 @@
#pragma once
#include <Common\stdtypes.h>
class CThread
{

View File

@ -122,12 +122,18 @@ void CTraceLog::CloseTrace(void)
{
CGuard Guard(m_CS);
m_Modules.clear();
if (g_ModuleLogLevel)
{
delete g_ModuleLogLevel;
g_ModuleLogLevel = NULL;
}
}
void CTraceLog::FlushTrace(void)
{
CGuard Guard(m_CS);
for (uint32_t i = 0, n = m_Modules.size(); i < n; i++)
for (size_t i = 0, n = m_Modules.size(); i < n; i++)
{
m_Modules[i]->FlushTrace();
}
@ -138,7 +144,7 @@ void CTraceLog::TraceMessage(uint32_t module, uint8_t severity, const char * fil
{
CGuard Guard(m_CS);
for (uint32_t i = 0, n = m_Modules.size(); i < n; i++)
for (size_t i = 0, n = m_Modules.size(); i < n; i++)
{
m_Modules[i]->Write(module, severity, file, line, function, Message);
}
@ -200,7 +206,7 @@ CTraceFileLog::CTraceFileLog(const char * FileName, bool FlushFile, CLog::LOG_OP
{ /* Clamp file size to 5 MB if it exceeds 2047 or falls short of 3. */
dwMaxFileSize = 5;
}
m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB);
m_hLogFile.SetMaxFileSize((uint32_t)(dwMaxFileSize * MB));
m_hLogFile.Open(FileName, eMode);
}

View File

@ -7,7 +7,7 @@ class CPath
//Enums
public:
enum DIR_CURRENT_DIRECTORY { CURRENT_DIRECTORY = 1 };
enum DIR_CURRENT_DIRECTORY { CURRENT_DIRECTORY = 1 };
#ifdef _WIN32
enum DIR_MODULE_DIRECTORY { MODULE_DIRECTORY = 2 };
enum DIR_MODULE_FILE { MODULE_FILE = 3 };
@ -22,7 +22,6 @@ public:
//Attributes
private:
std::string m_strPath;
#ifdef _WIN32
void * m_hFindFile;
@ -119,10 +118,10 @@ public:
bool DirectoryExists() const;
//File Information
bool IsFile() const { return !IsDirectory(); }
bool Exists() const;
bool IsFile() const { return !IsDirectory(); }
bool Exists() const;
#ifdef _WIN32
bool SelectFile(void * hwndOwner, const char * InitialDir, const char * FileFilter, bool FileMustExist);
bool SelectFile(void * hwndOwner, const char * InitialDir, const char * FileFilter, bool FileMustExist);
#endif
//Directory operations

View File

@ -21,7 +21,7 @@ CGameStatusPage::CGameStatusPage(HWND hParent, const RECT & rcDispay)
}
CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
strlist Keys;
CIniFile::strlist Keys;
RomIniFile.GetKeyList("Rom Status", Keys);
stdstr Status = UISettingsLoadStringVal(Rdb_Status);
@ -29,7 +29,7 @@ CGameStatusPage::CGameStatusPage(HWND hParent, const RECT & rcDispay)
ComboBox = AddModComboBoxTxt(GetDlgItem(IDC_STATUS_TYPE), Rdb_Status);
if (ComboBox)
{
for (strlist::iterator item = Keys.begin(); item != Keys.end(); item++)
for (CIniFile::strlist::iterator item = Keys.begin(); item != Keys.end(); item++)
{
if (strstr(item->c_str(), ".Sel") != NULL) { continue; }
if (strstr(item->c_str(), ".Auto") != NULL) { continue; }