Fixes for GCC 11

This commit is contained in:
wiidev 2021-08-01 18:00:15 +01:00
parent d79ce271aa
commit 0ac4d8249c
41 changed files with 287 additions and 265 deletions

View File

@ -39,6 +39,12 @@
#include "cache/cache.hpp"
#include "channels.h"
/* GCC 11 false positives */
#if __GNUC__ > 10
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
typedef struct _dolheader
{
u32 section_pos[18];
@ -126,7 +132,7 @@ void Channels::InternalGetNandChannelList(u32 type)
}
}
vector<struct discHdr> &Channels::GetNandHeaders(void)
std::vector<struct discHdr> &Channels::GetNandHeaders(void)
{
if (NandChannels.empty())
this->GetChannelList();
@ -134,7 +140,7 @@ vector<struct discHdr> &Channels::GetNandHeaders(void)
return NandChannels;
}
vector<struct discHdr> &Channels::GetEmuHeaders(void)
std::vector<struct discHdr> &Channels::GetEmuHeaders(void)
{
if (Settings.UseGameHeaderCache && isCacheFile(EMUNAND_HEADER_CACHE_FILE))
{

View File

@ -30,8 +30,6 @@
#include <gccore.h>
#include "usbloader/disc.h"
using namespace std;
class Channels
{
public:
@ -46,8 +44,8 @@ public:
void GetChannelList();
void GetEmuChannelList();
vector<struct discHdr> & GetNandHeaders(void);
vector<struct discHdr> & GetEmuHeaders(void);
std::vector<struct discHdr> & GetNandHeaders(void);
std::vector<struct discHdr> & GetEmuHeaders(void);
private:
static Channels *instance;
@ -58,8 +56,8 @@ private:
bool ParseTitleDir(char *path, int language);
bool GetEmuChanTitle(char *tmdpath, int language, std::string &Title);
vector<struct discHdr> NandChannels;
vector<struct discHdr> EmuChannels;
std::vector<struct discHdr> NandChannels;
std::vector<struct discHdr> EmuChannels;
};
#endif

View File

@ -81,7 +81,7 @@ void GuiCheckboxBrowser::Clear()
checkBoxList.clear();
}
bool GuiCheckboxBrowser::AddEntrie(const string &text, bool checked, int style, bool multistates)
bool GuiCheckboxBrowser::AddEntrie(const std::string &text, bool checked, int style, bool multistates)
{
LOCK(this);
int currentSize = checkBoxList.size();

View File

@ -29,14 +29,12 @@
#include "gui_checkbox.hpp"
#include "gui_scrollbar.hpp"
using namespace std;
class GuiCheckboxBrowser : public GuiElement, public sigslot::has_slots<>
{
public:
GuiCheckboxBrowser(int w, int h, int maxSize = 7);
virtual ~GuiCheckboxBrowser();
bool AddEntrie(const string &text, bool checked = false, int style = GuiCheckbox::CHECKSIGN, bool multistates = false);
bool AddEntrie(const std::string &text, bool checked = false, int style = GuiCheckbox::CHECKSIGN, bool multistates = false);
int GetSelected() const { return pageIndex+selectedItem; }
bool IsChecked(u32 i) { if(i >= checkBoxList.size()) return false; else return checkBoxList[i]->IsChecked(); }
GuiCheckbox *GetCheckbox(u32 i) { if(i >= checkBoxList.size()) return NULL; else return checkBoxList[i]; }
@ -62,10 +60,10 @@ class GuiCheckboxBrowser : public GuiElement, public sigslot::has_slots<>
GuiImage *backgroundImg;
GuiImageData *markImgData;
GuiImage *markImg;
vector<GuiText *> textLineDrawn;
vector<GuiCheckbox *> checkBoxDrawn;
vector<GuiText *> textLineList;
vector<GuiCheckbox *> checkBoxList;
std::vector<GuiText *> textLineDrawn;
std::vector<GuiCheckbox *> checkBoxDrawn;
std::vector<GuiText *> textLineList;
std::vector<GuiCheckbox *> checkBoxList;
};
#endif

View File

@ -30,8 +30,6 @@
#include <gctypes.h>
#include <vector>
using namespace std;
class GCDumper
{
public:
@ -42,14 +40,14 @@ public:
int ReadDiscInfo(const u64 &game_offset);
void SetForceAlign(bool b) { force_align32 = b; }
void SetCompressed(bool b) { compressed = b; }
vector<struct discHdr> & GetDiscHeaders() { return discHeaders; }
vector<u32> & GetDiscSizes() { return gameSizes; }
std::vector<struct discHdr> & GetDiscHeaders() { return discHeaders; }
std::vector<u32> & GetDiscSizes() { return gameSizes; }
private:
s32 CopyDiscData(FILE *f, u64 offset, u32 length, u8 *buffer);
vector<struct discHdr> discHeaders;
vector<u32> gameSizes;
vector<u64> gameOffsets;
std::vector<struct discHdr> discHeaders;
std::vector<u32> gameSizes;
std::vector<u64> gameOffsets;
bool force_align32;
bool compressed;
u32 discWrote;

View File

@ -58,7 +58,7 @@ const char *GCGames::GetPath(const char *gameID) const
return "";
}
void GCGames::LoadGameList(const string &path, vector<struct discHdr> &headerList, vector<string> &pathList)
void GCGames::LoadGameList(const std::string &path, std::vector<struct discHdr> &headerList, std::vector<std::string> &pathList)
{
struct discHdr tmpHdr;
struct stat st;
@ -183,7 +183,7 @@ void GCGames::LoadGameList(const string &path, vector<struct discHdr> &headerLis
if (*id != 0 && strlen(title) > 0)
{
string gamePath = string(path) + dirname + (extracted ? "/" : strrchr(fpath, '/'));
std::string gamePath = std::string(path) + dirname + (extracted ? "/" : strrchr(fpath, '/'));
memset(&tmpHdr, 0, sizeof(tmpHdr));
memcpy(tmpHdr.id, id, sizeof(tmpHdr.id));
snprintf(tmpHdr.title, sizeof(tmpHdr.title), "%s", title);
@ -206,7 +206,7 @@ void GCGames::LoadGameList(const string &path, vector<struct discHdr> &headerLis
if (tmpHdr.gc_magic == GCGames::MAGIC)
{
string gamePath = string(path) + dirname + (extracted ? "/" : strrchr(fpath, '/'));
std::string gamePath = std::string(path) + dirname + (extracted ? "/" : strrchr(fpath, '/'));
tmpHdr.magic = tmpHdr.gc_magic;
tmpHdr.type = extracted ? TYPE_GAME_GC_EXTRACTED : TYPE_GAME_GC_IMG;
headerList.push_back(tmpHdr);

View File

@ -26,8 +26,6 @@
int nintendontBuildDate(const char *NIN_loader_path, char* NINBuildDate);
int nintendontVersion(const char *NIN_loader_path, char* NINVersion, int len);
using namespace std;
class GCGames
{
public:
@ -40,7 +38,7 @@ public:
u32 LoadAllGames(void);
void LoadGameList(const string &path, vector<struct discHdr> &headerList, vector<string> &pathList);
void LoadGameList(const std::string &path, std::vector<struct discHdr> &headerList, std::vector<std::string> &pathList);
bool RemoveGame(const char *gameID);
bool RemoveSDGame(const char *gameID);
@ -48,14 +46,14 @@ public:
const char *GetPath(const char *gameID) const;
vector<struct discHdr> & GetHeaders(void)
std::vector<struct discHdr> & GetHeaders(void)
{
LoadAllGames();
return HeaderList;
}
vector<struct discHdr> & GetSDHeaders(void) {
std::vector<struct discHdr> & GetSDHeaders(void) {
return sdGCList;
}
@ -65,10 +63,10 @@ private:
static GCGames *instance;
vector<string> PathList;
vector<struct discHdr> HeaderList;
vector<struct discHdr> sdGCList;
vector<string> sdGCPathList;
std::vector<std::string> PathList;
std::vector<struct discHdr> HeaderList;
std::vector<struct discHdr> sdGCList;
std::vector<std::string> sdGCPathList;
};
#endif

View File

@ -28,8 +28,8 @@ distribution.
#include "OpeningBNR.hpp"
#include "BannerAsync.h"
vector<BannerAsync *> BannerAsync::List;
queue<BannerAsync *> BannerAsync::DeleteList;
std::vector<BannerAsync *> BannerAsync::List;
std::queue<BannerAsync *> BannerAsync::DeleteList;
lwp_t BannerAsync::Thread = LWP_THREAD_NULL;
mutex_t BannerAsync::ListLock = LWP_THREAD_NULL;
BannerAsync * BannerAsync::InUse = NULL;

View File

@ -29,8 +29,6 @@ distribution.
#include "usbloader/GameList.h"
#include "Banner.h"
using namespace std;
class BannerAsync : public Banner
{
public:
@ -52,8 +50,8 @@ private:
static void ThreadAdd(BannerAsync* banner);
static void ThreadRemove(BannerAsync* banner);
static vector<BannerAsync *> List;
static queue<BannerAsync *> DeleteList;
static std::vector<BannerAsync *> List;
static std::queue<BannerAsync *> DeleteList;
static lwp_t Thread;
static mutex_t ListLock;
static BannerAsync * InUse;

View File

@ -20,8 +20,6 @@
#include <vector>
#include "Banner.h"
using namespace std;
class CustomBanner : public Banner
{
public:
@ -37,7 +35,7 @@ public:
void SetBannerPaneVisible(const char *pane, bool visible);
private:
u8 *LoadTextureFromPng(const u8 * img, u32 imgSize, int *width, int *height);
vector<u16 *> text_list;
std::vector<u16 *> text_list;
};
#endif /*CUSTOM_BANNER_H_*/

View File

@ -330,7 +330,7 @@ u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len)
}
else if(header->type == TYPE_GAME_GC_EXTRACTED)
{
string gamePath = path;
std::string gamePath = path;
gamePath += "root/";
//! open default file first
file = fopen((gamePath + "opening.bnr").c_str(), "rb");
@ -446,7 +446,7 @@ CustomBanner *OpeningBNR::CreateGCBanner(const discHdr * header)
// sets the description and converts encodings (Japan and Taiwan)
if(header->id[3] == 'J' || header->id[3] == 'W')
{
string description((char *) openingBnr->description[language].long_description);
std::string description((char *) openingBnr->description[language].long_description);
banner->SetBannerText("T_short_descript", sj2utf8(description).c_str());
}
else

View File

@ -21,9 +21,9 @@ void ResetGameHeaderCache()
}
// emuNAND
void SaveGameHeaderCache(vector<struct discHdr> &list)
void SaveGameHeaderCache(std::vector<struct discHdr> &list)
{
string path = string(Settings.GameHeaderCachePath) + EMUNAND_HEADER_CACHE_FILE;
std::string path = std::string(Settings.GameHeaderCachePath) + EMUNAND_HEADER_CACHE_FILE;
if (!CheckFile(Settings.GameHeaderCachePath))
CreateSubfolder(Settings.GameHeaderCachePath);
@ -38,9 +38,9 @@ void SaveGameHeaderCache(vector<struct discHdr> &list)
fclose(cache);
}
void LoadGameHeaderCache(vector<struct discHdr> &list)
void LoadGameHeaderCache(std::vector<struct discHdr> &list)
{
string path = string(Settings.GameHeaderCachePath) + EMUNAND_HEADER_CACHE_FILE;
std::string path = std::string(Settings.GameHeaderCachePath) + EMUNAND_HEADER_CACHE_FILE;
FILE *cache = fopen(path.c_str(), "rb");
@ -66,9 +66,9 @@ void LoadGameHeaderCache(vector<struct discHdr> &list)
}
// Wii
void SaveGameHeaderCache(vector<struct discHdr> &list, vector<int> &plist)
void SaveGameHeaderCache(std::vector<struct discHdr> &list, std::vector<int> &plist)
{
vector<struct wiiCache> wiictmp;
std::vector<struct wiiCache> wiictmp;
struct wiiCache gtmp;
for (u32 i = 0; i < list.size(); ++i)
@ -79,7 +79,7 @@ void SaveGameHeaderCache(vector<struct discHdr> &list, vector<int> &plist)
wiictmp.push_back(gtmp);
}
string path = string(Settings.GameHeaderCachePath) + WII_HEADER_CACHE_FILE;
std::string path = std::string(Settings.GameHeaderCachePath) + WII_HEADER_CACHE_FILE;
if (!CheckFile(Settings.GameHeaderCachePath))
CreateSubfolder(Settings.GameHeaderCachePath);
@ -94,9 +94,9 @@ void SaveGameHeaderCache(vector<struct discHdr> &list, vector<int> &plist)
fclose(cache);
}
void LoadGameHeaderCache(vector<struct discHdr> &list, vector<int> &plist)
void LoadGameHeaderCache(std::vector<struct discHdr> &list, std::vector<int> &plist)
{
string path = string(Settings.GameHeaderCachePath) + WII_HEADER_CACHE_FILE;
std::string path = std::string(Settings.GameHeaderCachePath) + WII_HEADER_CACHE_FILE;
FILE *cache = fopen(path.c_str(), "rb");
@ -124,9 +124,9 @@ void LoadGameHeaderCache(vector<struct discHdr> &list, vector<int> &plist)
}
// GameCube
void SaveGameHeaderCache(vector<struct discHdr> &list, vector<string> &plist)
void SaveGameHeaderCache(std::vector<struct discHdr> &list, std::vector<std::string> &plist)
{
vector<struct gcCache> gcctmp;
std::vector<struct gcCache> gcctmp;
struct gcCache gtmp;
for (u32 i = 0; i < list.size(); ++i)
@ -139,7 +139,7 @@ void SaveGameHeaderCache(vector<struct discHdr> &list, vector<string> &plist)
gcctmp.push_back(gtmp);
}
string path = string(Settings.GameHeaderCachePath) + GAMECUBE_HEADER_CACHE_FILE;
std::string path = std::string(Settings.GameHeaderCachePath) + GAMECUBE_HEADER_CACHE_FILE;
if (!CheckFile(Settings.GameHeaderCachePath))
CreateSubfolder(Settings.GameHeaderCachePath);
@ -154,9 +154,9 @@ void SaveGameHeaderCache(vector<struct discHdr> &list, vector<string> &plist)
fclose(cache);
}
void LoadGameHeaderCache(vector<struct discHdr> &list, vector<string> &plist)
void LoadGameHeaderCache(std::vector<struct discHdr> &list, std::vector<std::string> &plist)
{
string path = string(Settings.GameHeaderCachePath) + GAMECUBE_HEADER_CACHE_FILE;
std::string path = std::string(Settings.GameHeaderCachePath) + GAMECUBE_HEADER_CACHE_FILE;
FILE *cache = fopen(path.c_str(), "rb");
@ -178,15 +178,15 @@ void LoadGameHeaderCache(vector<struct discHdr> &list, vector<string> &plist)
fread((void *)&gcctmp, 1, sizeof(struct gcCache), cache);
list.push_back(gcctmp.header);
string tmp((char *)gcctmp.path);
std::string tmp((char *)gcctmp.path);
plist.push_back(tmp);
}
fclose(cache);
}
void SaveFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFilter)
void SaveFilteredListCache(std::vector<struct discHdr *> &list, const wchar_t *gameFilter)
{
string path = string(Settings.GameHeaderCachePath) + FilteredListCacheFileName(gameFilter);
std::string path = std::string(Settings.GameHeaderCachePath) + FilteredListCacheFileName(gameFilter);
if (!CheckFile(Settings.GameHeaderCachePath))
CreateSubfolder(Settings.GameHeaderCachePath);
@ -196,7 +196,7 @@ void SaveFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFi
if (!cache)
return;
vector<struct gameHdr> tmplist;
std::vector<struct gameHdr> tmplist;
struct gameHdr tmp;
for (u32 i = 0; i < list.size(); ++i)
@ -209,9 +209,9 @@ void SaveFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFi
fclose(cache);
}
void LoadFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFilter)
void LoadFilteredListCache(std::vector<struct discHdr *> &list, const wchar_t *gameFilter)
{
string path = string(Settings.GameHeaderCachePath) + FilteredListCacheFileName(gameFilter);
std::string path = std::string(Settings.GameHeaderCachePath) + FilteredListCacheFileName(gameFilter);
if (!CheckFile(Settings.GameHeaderCachePath))
CreateSubfolder(Settings.GameHeaderCachePath);
@ -238,7 +238,7 @@ void LoadFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFi
if (!found)
{
vector<struct discHdr> &tmplist = gameList.GetFullGameList();
std::vector<struct discHdr> &tmplist = gameList.GetFullGameList();
for (u32 c = 0; c < tmplist.size(); ++c)
{
struct discHdr *header = &tmplist[c];
@ -253,7 +253,7 @@ void LoadFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFi
if (!found)
{
vector<struct discHdr> &tmplist = GCGames::Instance()->GetHeaders();
std::vector<struct discHdr> &tmplist = GCGames::Instance()->GetHeaders();
for (u32 c = 0; c < tmplist.size(); ++c)
{
struct discHdr *header = &tmplist[c];
@ -268,7 +268,7 @@ void LoadFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFi
if (!found)
{
vector<struct discHdr> &tmplist = Channels::Instance()->GetNandHeaders();
std::vector<struct discHdr> &tmplist = Channels::Instance()->GetNandHeaders();
for (u32 c = 0; c < tmplist.size(); ++c)
{
struct discHdr *header = &tmplist[c];
@ -283,7 +283,7 @@ void LoadFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFi
if (!found)
{
vector<struct discHdr> &tmplist = Channels::Instance()->GetEmuHeaders();
std::vector<struct discHdr> &tmplist = Channels::Instance()->GetEmuHeaders();
for (u32 c = 0; c < tmplist.size(); ++c)
{
struct discHdr *header = &tmplist[c];
@ -300,16 +300,16 @@ void LoadFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFi
fclose(cache);
}
string FilteredListCacheFileName(const wchar_t *gameFilter)
std::string FilteredListCacheFileName(const wchar_t *gameFilter)
{
string tmp;
std::string tmp;
tmp = "FL";
tmp += "_" + to_string(Settings.LoaderMode);
tmp += "_" + to_string(Settings.GameSort);
tmp += "_" + std::to_string(Settings.LoaderMode);
tmp += "_" + std::to_string(Settings.GameSort);
if (gameFilter)
{
wstring ws(gameFilter);
string gf(ws.begin(), ws.end());
std::wstring ws(gameFilter);
std::string gf(ws.begin(), ws.end());
if ((gf.length()) > 0)
tmp += "_" + gf;
}
@ -317,19 +317,19 @@ string FilteredListCacheFileName(const wchar_t *gameFilter)
return tmp;
}
string FilteredListCacheFileName()
std::string FilteredListCacheFileName()
{
string tmp;
std::string tmp;
tmp = "FL";
tmp += "_" + to_string(Settings.LoaderMode);
tmp += "_" + to_string(Settings.GameSort);
tmp += "_" + std::to_string(Settings.LoaderMode);
tmp += "_" + std::to_string(Settings.GameSort);
tmp += ".cache";
return tmp;
}
bool isCacheFile(string filename)
bool isCacheFile(std::string filename)
{
string path = string(Settings.GameHeaderCachePath) + filename;
std::string path = std::string(Settings.GameHeaderCachePath) + filename;
if (CheckFile(path.c_str()))
return true;

View File

@ -9,8 +9,6 @@
#define GAMECUBE_HEADER_CACHE_FILE "GAMECUBE.cache"
#define EMUNAND_HEADER_CACHE_FILE "EMUNAND.cache"
using namespace std;
struct gameHdr
{
/* Game ID */
@ -33,22 +31,22 @@ struct gcCache
};
// emuNAND
void SaveGameHeaderCache(vector<struct discHdr> &list);
void LoadGameHeaderCache(vector<struct discHdr> &list);
void SaveGameHeaderCache(std::vector<struct discHdr> &list);
void LoadGameHeaderCache(std::vector<struct discHdr> &list);
// Wii
void SaveGameHeaderCache(vector<struct discHdr> &list, vector<int> &plist);
void LoadGameHeaderCache(vector<struct discHdr> &list, vector<int> &plist);
void SaveGameHeaderCache(std::vector<struct discHdr> &list, std::vector<int> &plist);
void LoadGameHeaderCache(std::vector<struct discHdr> &list, std::vector<int> &plist);
// GameCube
void SaveGameHeaderCache(vector<struct discHdr> &list, vector<string> &plist);
void LoadGameHeaderCache(vector<struct discHdr> &list, vector<string> &plist);
void SaveGameHeaderCache(std::vector<struct discHdr> &list, std::vector<std::string> &plist);
void LoadGameHeaderCache(std::vector<struct discHdr> &list, std::vector<std::string> &plist);
void ResetGameHeaderCache();
void SaveFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFilter);
void LoadFilteredListCache(vector<struct discHdr *> &list, const wchar_t *gameFilter);
void SaveFilteredListCache(std::vector<struct discHdr *> &list, const wchar_t *gameFilter);
void LoadFilteredListCache(std::vector<struct discHdr *> &list, const wchar_t *gameFilter);
string FilteredListCacheFileName(const wchar_t *gameFilter);
string FilteredListCacheFileName();
bool isCacheFile(string filename);
std::string FilteredListCacheFileName(const wchar_t *gameFilter);
std::string FilteredListCacheFileName();
bool isCacheFile(std::string filename);

View File

@ -141,7 +141,7 @@ int CheatMenu(const char * gameID)
{
if (cntcheats > 0)
{
vector<int> vActiveCheats;
std::vector<int> vActiveCheats;
for (int i = 0; i < cntcheats; i++)
{
const char *strCheck = cheatslst.GetName(i);

View File

@ -42,25 +42,25 @@ void GCTCheats::Clear(void)
}
string GCTCheats::getGameName(void)
std::string GCTCheats::getGameName(void)
{
return sGameTitle;
}
string GCTCheats::getGameID(void)
std::string GCTCheats::getGameID(void)
{
return sGameID;
}
vector<unsigned int> GCTCheats::getCheat(int nr)
std::vector<unsigned int> GCTCheats::getCheat(int nr)
{
if((unsigned int)nr >= cheatList.size())
return vector<unsigned int>();
return std::vector<unsigned int>();
return cheatList[nr].sCheats;
}
string GCTCheats::getCheatName(int nr)
std::string GCTCheats::getCheatName(int nr)
{
if((unsigned int)nr >= cheatList.size())
return ERRORRANGE;
@ -68,7 +68,7 @@ string GCTCheats::getCheatName(int nr)
return cheatList[nr].sCheatName;
}
string GCTCheats::getCheatComment(int nr)
std::string GCTCheats::getCheatComment(int nr)
{
if((unsigned int)nr >= cheatList.size())
return ERRORRANGE;
@ -76,7 +76,7 @@ string GCTCheats::getCheatComment(int nr)
return cheatList[nr].sCheatComment;
}
int GCTCheats::createGCT(const vector<int> &vCheats, const char * filename)
int GCTCheats::createGCT(const std::vector<int> &vCheats, const char * filename)
{
if (vCheats.size() == 0 || !filename)
return 0;
@ -95,7 +95,7 @@ int GCTCheats::createGCT(const vector<int> &vCheats, const char * filename)
if((unsigned int)vCheats[c] >= cheatList.size())
continue;
vector<unsigned int> &cheatBuf = cheatList[vCheats[c]].sCheats;
std::vector<unsigned int> &cheatBuf = cheatList[vCheats[c]].sCheats;
if(cheatBuf.size() > 0)
fwrite((char*)&cheatBuf[0], cheatBuf.size() * sizeof(unsigned int), 1, pFile);
@ -223,7 +223,7 @@ bool GCTCheats::IsCheatIncluded(int iCheat, const unsigned char *gctBuf, unsigne
if(!gctBuf || (unsigned int)iCheat >= cheatList.size())
return false;
vector<unsigned int> &Cheat = cheatList[iCheat].sCheats;
std::vector<unsigned int> &Cheat = cheatList[iCheat].sCheats;
int len = Cheat.size() * sizeof(unsigned int);
for(unsigned int i = sizeof(GCT_Header); i + len <= gctSize - sizeof(GCT_Footer); i += 4)

View File

@ -21,21 +21,19 @@
#include <string>
#include <vector>
using namespace std;
//!Handles Ocarina TXT Cheatfiles
class GCTCheats
{
private:
string sGameID;
string sGameTitle;
std::string sGameID;
std::string sGameTitle;
struct CheatEntry
{
string sCheatName;
string sCheatComment;
vector<unsigned int> sCheats;
std::string sCheatName;
std::string sCheatComment;
std::vector<unsigned int> sCheats;
};
vector<CheatEntry> cheatList;
std::vector<CheatEntry> cheatList;
public:
//!Constructor
GCTCheats(void);
@ -50,25 +48,25 @@ class GCTCheats
//!\param cnt size of array
//!\param filename name of GCT file
//!\return error code
int createGCT(const vector<int> &vCheats, const char * filename);
int createGCT(const std::vector<int> &vCheats, const char * filename);
//!Gets Count cheats
//!\return Count cheats
int getCnt() const { return cheatList.size(); }
//!Gets Game Name
//!\return Game Name
string getGameName(void);
std::string getGameName(void);
//!Gets GameID
//!\return GameID
string getGameID(void);
std::string getGameID(void);
//!Gets cheat data
//!\return cheat data
vector<unsigned int> getCheat(int nr);
std::vector<unsigned int> getCheat(int nr);
//!Gets Cheat Name
//!\return Cheat Name
string getCheatName(int nr);
std::string getCheatName(int nr);
//!Gets Cheat Comment
//!\return Cheat Comment
string getCheatComment(int nr);
std::string getCheatComment(int nr);
//!Clear all loaded cheats
void Clear(void);
//!Check if string is a code

View File

@ -15,6 +15,12 @@
#include "sys.h"
#include "gecko.h"
/* GCC 11 false positives */
#if __GNUC__ > 10
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
#define EXECUTE_ADDR ((u8 *) 0x92000000)
#define BOOTER_ADDR ((u8 *) 0x93000000)
#define ARGS_ADDR ((u8 *) 0x93200000)

View File

@ -205,13 +205,13 @@ void WDMMenu::CheckGameFiles(const struct discHdr * header)
WBFS_CloseDisc(disc);
int position = 0;
vector<pair<int, string> > FilesNotInWDM;
std::vector<std::pair<int, std::string> > FilesNotInWDM;
for(int i = 0; i < wdmFile->size(); ++i)
{
if(stringcompare(wdmFile->GetDolName(i), "main") == true)
{
DOLOffsetList.push_back(pair<int, int>(0, wdmFile->GetParameter(i)));
DOLOffsetList.push_back(std::pair<int, int>(0, wdmFile->GetParameter(i)));
Options->SetName(position, "%i.", position+1);
Options->SetValue(position, wdmFile->GetReplaceName(i));
position++;
@ -239,7 +239,7 @@ void WDMMenu::CheckGameFiles(const struct discHdr * header)
{
if(stringcompare(wdmFile->GetDolName(j), NameCpy) == true)
{
DOLOffsetList.push_back(pair<int, int>(i, wdmFile->GetParameter(j)));
DOLOffsetList.push_back(std::pair<int, int>(i, wdmFile->GetParameter(j)));
Options->SetName(position, "%i.", position+1);
Options->SetValue(position, wdmFile->GetReplaceName(j));
position++;
@ -248,13 +248,13 @@ void WDMMenu::CheckGameFiles(const struct discHdr * header)
}
if(j == wdmFile->size())
FilesNotInWDM.push_back(pair<int, string>(i, filename));
FilesNotInWDM.push_back(std::pair<int, std::string>(i, filename));
}
}
for(u32 i = 0; i < FilesNotInWDM.size(); ++i)
{
DOLOffsetList.push_back(pair<int, int>(FilesNotInWDM[i].first, 1));
DOLOffsetList.push_back(std::pair<int, int>(FilesNotInWDM[i].first, 1));
Options->SetName(position, "%i.", position+1);
Options->SetValue(position, FilesNotInWDM[i].second.c_str());
position++;

View File

@ -22,7 +22,7 @@ class WDMMenu : public GuiWindow
static u32 AlternateDolParameter;
WDMFile * wdmFile;
vector<pair<int, int> > DOLOffsetList;
std::vector<std::pair<int, int> > DOLOffsetList;
GuiImageData * btnOutline;
GuiTrigger * trigA;

View File

@ -32,12 +32,12 @@
using namespace tinyxml2;
Wiinnertag::Wiinnertag(const string &filepath)
Wiinnertag::Wiinnertag(const std::string &filepath)
{
ReadXML(filepath);
}
bool Wiinnertag::ReadXML(const string &filepath)
bool Wiinnertag::ReadXML(const std::string &filepath)
{
XMLDocument xmlDoc;
if(xmlDoc.LoadFile(filepath.c_str()) != 0)
@ -88,7 +88,7 @@ bool Wiinnertag::Send(const char *gameID)
bool Wiinnertag::TagGame(const char *gameID)
{
string fullpath = Settings.WiinnertagPath;
std::string fullpath = Settings.WiinnertagPath;
if(fullpath.size() == 0)
return false;
@ -100,14 +100,14 @@ bool Wiinnertag::TagGame(const char *gameID)
return Tag.Send(gameID);
}
bool Wiinnertag::CreateExample(const string &filepath)
bool Wiinnertag::CreateExample(const std::string &filepath)
{
if(filepath.size() == 0)
return false;
CreateSubfolder(filepath.c_str());
string fullpath = filepath;
std::string fullpath = filepath;
if(fullpath[fullpath.size()-1] != '/')
fullpath += '/';
fullpath += "Wiinnertag.xml";

View File

@ -28,18 +28,16 @@
#include <string>
#include <gctypes.h>
using namespace std;
class Wiinnertag
{
public:
static bool CreateExample(const string &filepath);
static bool CreateExample(const std::string &filepath);
static bool TagGame(const char *gameID);
private:
Wiinnertag(const string &filepath);
Wiinnertag(const std::string &filepath);
bool Send(const char *gameID);
bool ReadXML(const string &filepath);
vector<pair<string, string> > tagList;
bool ReadXML(const std::string &filepath);
std::vector<std::pair<std::string, std::string> > tagList;
};
#endif

View File

@ -118,7 +118,7 @@ int UpdateGameTDB()
gprintf("Updating GameTDB...\n");
string ZipPath = Settings.titlestxt_path;
std::string ZipPath = Settings.titlestxt_path;
if (Settings.titlestxt_path[ZipPath.size() - 1] != '/')
ZipPath += '/';

View File

@ -13,6 +13,13 @@
#include "settings/SettingsEnums.h"
#include "svnrev.h"
/* GCC 11 false positives */
#if __GNUC__ > 10
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#pragma GCC diagnostic ignored "-Wstringop-overread"
#endif
typedef struct _appDOL
{
u8 *dst;

View File

@ -37,6 +37,12 @@
#include "memory/memory.h"
#include "gecko.h"
/* GCC 11 false positives */
#if __GNUC__ > 10
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
static u8 *codelistend = (u8 *)0x80003000;
static u8 *codelist = (u8 *)0x800022A8;

View File

@ -30,7 +30,7 @@
#include "themes/Resources.h"
#include "menu/menus.h"
CategoryPrompt::CategoryPrompt(const string &title)
CategoryPrompt::CategoryPrompt(const std::string &title)
: GuiWindow(0, 0)
{
changed = false;

View File

@ -29,7 +29,7 @@
class CategoryPrompt : public GuiWindow, public sigslot::has_slots<>
{
public:
CategoryPrompt(const string &title);
CategoryPrompt(const std::string &title);
virtual ~CategoryPrompt();
int Show();
bool categoriesChanged() const { return changed; }

View File

@ -51,7 +51,7 @@ void CategorySelectPrompt::onBrowserRefresh()
do
{
bool checked = false;
const vector<unsigned int> gameCat = GameCategories[gameHeader->id];
const std::vector<unsigned int> gameCat = GameCategories[gameHeader->id];
for(u32 i = 0; i < gameCat.size(); ++i)
{
@ -82,7 +82,7 @@ void CategorySelectPrompt::OnCheckboxClick(GuiCheckbox *checkBox, int index)
return;
}
const vector<unsigned int> gameCat = GameCategories[gameHeader->id];
const std::vector<unsigned int> gameCat = GameCategories[gameHeader->id];
u32 i;
for(i = 0; i < gameCat.size(); ++i)

View File

@ -47,20 +47,20 @@ void CCategoryList::clear()
const char * CCategoryList::operator[](unsigned int id)
{
map<unsigned int, string>::iterator itr = nameList.find(id);
std::map<unsigned int, std::string>::iterator itr = nameList.find(id);
if(itr == nameList.end())
return NULL;
return nameList[id].c_str();
}
bool CCategoryList::AddCategory(const string &name)
bool CCategoryList::AddCategory(const std::string &name)
{
if(findCategory(name))
return false;
unsigned int i = 1;
map<unsigned int, string>::iterator itr;
std::map<unsigned int, std::string>::iterator itr;
//! Find next free key
while((itr = nameList.find(i)) != nameList.end())
@ -72,7 +72,7 @@ bool CCategoryList::AddCategory(const string &name)
return true;
}
bool CCategoryList::SetCategory(unsigned int id, const string &name)
bool CCategoryList::SetCategory(unsigned int id, const std::string &name)
{
RemoveCategory(name);
nameList[id] = name;
@ -80,9 +80,9 @@ bool CCategoryList::SetCategory(unsigned int id, const string &name)
return true;
}
void CCategoryList::RemoveCategory(const string &name)
void CCategoryList::RemoveCategory(const std::string &name)
{
for (map<unsigned int, string>::iterator itr = nameList.begin(); itr != nameList.end(); itr++)
for (std::map<unsigned int, std::string>::iterator itr = nameList.begin(); itr != nameList.end(); itr++)
{
if(strcasecmp(name.c_str(), itr->second.c_str()) == 0)
{
@ -94,13 +94,13 @@ void CCategoryList::RemoveCategory(const string &name)
void CCategoryList::RemoveCategory(unsigned int id)
{
map<unsigned int, string>::iterator itr = nameList.find(id);
std::map<unsigned int, std::string>::iterator itr = nameList.find(id);
if(itr != nameList.end())
nameList.erase(itr);
}
bool CCategoryList::findCategory(const string &name)
bool CCategoryList::findCategory(const std::string &name)
{
for (listIter = nameList.begin(); listIter != nameList.end(); listIter++)
{

View File

@ -27,35 +27,33 @@
#include <map>
#include <string>
using namespace std;
class CCategoryList
{
public:
CCategoryList();
bool Load(string filepath);
bool Load(std::string filepath);
bool Save();
bool AddCategory(const string &name);
bool SetCategory(unsigned int id, const string &name);
bool AddCategory(const std::string &name);
bool SetCategory(unsigned int id, const std::string &name);
void RemoveCategory(unsigned int id);
void RemoveCategory(const string &name);
void RemoveCategory(const std::string &name);
bool goToFirst() { listIter = nameList.begin(); return true; }
bool goToNext() { listIter++; return listIter != nameList.end(); }
unsigned int getCurrentID() const { return listIter->first; }
const string &getCurrentName() const { return listIter->second; }
const std::string &getCurrentName() const { return listIter->second; }
const char * operator[](unsigned int id);
const char *at(unsigned int id) { return operator[](id); }
void goToNextCicle() { listIter++; if(listIter == nameList.end()) listIter = nameList.begin(); }
void goToPreviousCicle() { if(listIter == nameList.begin()) listIter = nameList.end(); listIter--; }
bool findCategory(const string &name);
bool findCategory(const std::string &name);
bool findCategory(unsigned int id) { listIter = nameList.find(id); return listIter != nameList.end(); };
int pos() const { return distance(nameList.begin(), listIter); }
int size() const { return nameList.size(); }
void clear();
private:
string configPath;
map<unsigned int, string>::const_iterator listIter;
map<unsigned int, string> nameList;
std::string configPath;
std::map<unsigned int, std::string>::const_iterator listIter;
std::map<unsigned int, std::string> nameList;
};
#endif

View File

@ -46,11 +46,11 @@ CGameCategories::CGameCategories()
{
}
const vector<unsigned int> &CGameCategories::operator[](const char *id) const
const std::vector<unsigned int> &CGameCategories::operator[](const char *id) const
{
if(!id) return defaultCategory;
for(map<string, vector<unsigned int> >::const_iterator itr = List.begin(); itr != List.end(); itr++)
for(std::map<std::string, std::vector<unsigned int> >::const_iterator itr = List.begin(); itr != List.end(); itr++)
{
if(strncasecmp(itr->first.c_str(), id, 6) == 0)
return itr->second;
@ -59,7 +59,7 @@ const vector<unsigned int> &CGameCategories::operator[](const char *id) const
return defaultCategory;
}
bool CGameCategories::Load(string filepath)
bool CGameCategories::Load(std::string filepath)
{
if(filepath.size() == 0)
return false;
@ -179,7 +179,7 @@ bool CGameCategories::Save()
//! This is more memory efficient than making another copy of the elements.
XMLElement *GameCategories = xmlDoc.NewElement("GameCategories");
for(map<string, vector<unsigned int> >::iterator itr = List.begin(); itr != List.end(); itr++)
for(std::map<std::string, std::vector<unsigned int> >::iterator itr = List.begin(); itr != List.end(); itr++)
{
ShowProgress(progress, progressSize);
@ -232,17 +232,17 @@ bool CGameCategories::SetCategory(const char *gameID, unsigned int id)
char gameID6[7];
snprintf(gameID6, sizeof(gameID6), gameID);
string stringGameID(gameID6);
std::string stringGameID(gameID6);
return SetCategory(stringGameID, id);
}
bool CGameCategories::SetCategory(const string &gameID, unsigned int id)
bool CGameCategories::SetCategory(const std::string &gameID, unsigned int id)
{
if(List[gameID].empty())
List[gameID] = defaultCategory;
vector<unsigned int> tmpVect(List[gameID]);
std::vector<unsigned int> tmpVect(List[gameID]);
for(u32 i = 0; i < tmpVect.size(); ++i)
{
@ -261,13 +261,13 @@ bool CGameCategories::ReplaceCategory(const char *gameID, unsigned int id)
char gameID6[7];
snprintf(gameID6, sizeof(gameID6), gameID);
List[string(gameID6)] = defaultCategory;
List[string(gameID6)].push_back(id);
List[std::string(gameID6)] = defaultCategory;
List[std::string(gameID6)].push_back(id);
return true;
}
bool CGameCategories::ReplaceCategory(const string &gameID, unsigned int id)
bool CGameCategories::ReplaceCategory(const std::string &gameID, unsigned int id)
{
List[gameID] = defaultCategory;
List[gameID].push_back(id);
@ -276,7 +276,7 @@ bool CGameCategories::ReplaceCategory(const string &gameID, unsigned int id)
void CGameCategories::RemoveCategory(unsigned int id)
{
for(map<string, vector<unsigned int> >::iterator itr = List.begin(); itr != List.end(); itr++)
for(std::map<std::string, std::vector<unsigned int> >::iterator itr = List.begin(); itr != List.end(); itr++)
{
for(u32 i = 0; i < itr->second.size(); ++i)
{
@ -289,9 +289,9 @@ void CGameCategories::RemoveCategory(unsigned int id)
}
}
void CGameCategories::RemoveGameCategories(const string &gameID)
void CGameCategories::RemoveGameCategories(const std::string &gameID)
{
for (map<string, vector<unsigned int> >::iterator itr = List.begin(); itr != List.end(); itr++)
for (std::map<std::string, std::vector<unsigned int> >::iterator itr = List.begin(); itr != List.end(); itr++)
{
if(gameID == itr->first)
{
@ -304,16 +304,16 @@ void CGameCategories::RemoveCategory(const char *gameID, unsigned int id)
{
if(!gameID) return;
string gameID6;
std::string gameID6;
for(int i = 0; i < 6 && gameID[i] != 0; ++i)
gameID6.push_back(gameID[i]);
RemoveCategory(gameID6, id);
}
void CGameCategories::RemoveCategory(const string &gameID, unsigned int id)
void CGameCategories::RemoveCategory(const std::string &gameID, unsigned int id)
{
for (map<string, vector<unsigned int> >::iterator itr = List.begin(); itr != List.end(); itr++)
for (std::map<std::string, std::vector<unsigned int> >::iterator itr = List.begin(); itr != List.end(); itr++)
{
if(gameID == itr->first)
{
@ -337,11 +337,11 @@ bool CGameCategories::isInCategory(const char *gameID, unsigned int id)
if(!gameID) return false;
string gameID6;
std::string gameID6;
for(int i = 0; i < 6 && gameID[i] != 0; ++i)
gameID6.push_back(gameID[i]);
for (map<string, vector<unsigned int> >::iterator itr = GameCategories.List.begin(); itr != GameCategories.List.end(); itr++)
for (std::map<std::string, std::vector<unsigned int> >::iterator itr = GameCategories.List.begin(); itr != GameCategories.List.end(); itr++)
{
if(itr->first == gameID6)
{
@ -357,7 +357,7 @@ bool CGameCategories::isInCategory(const char *gameID, unsigned int id)
return false;
}
bool CGameCategories::ImportFromGameTDB(const string &xmlpath)
bool CGameCategories::ImportFromGameTDB(const std::string &xmlpath)
{
GameTDB XML_DB;
@ -374,8 +374,8 @@ bool CGameCategories::ImportFromGameTDB(const string &xmlpath)
{
ShowProgress(i, gameList.size());
vector<string> genreList;
string GameType;
std::vector<std::string> genreList;
std::string GameType;
if(XML_DB.GetGameType((const char *) gameList[i]->id, GameType))
{

View File

@ -37,22 +37,22 @@ class CGameCategories
{
public:
CGameCategories();
bool Load(string filepath);
bool Load(std::string filepath);
bool Save();
bool SetCategory(const string &gameID, unsigned int id);
bool SetCategory(const std::string &gameID, unsigned int id);
bool SetCategory(const char *gameID, unsigned int id);
bool SetCategory(const unsigned char *gameID, int unsigned id) { return SetCategory((const char *) gameID, id); };
bool ReplaceCategory(const string &gameID, unsigned int id);
bool ReplaceCategory(const std::string &gameID, unsigned int id);
bool ReplaceCategory(const char *gameID, unsigned int id);
bool ReplaceCategory(const unsigned char *gameID, int unsigned id) { return SetCategory((const char *) gameID, id); };
void RemoveCategory(unsigned int id);
void RemoveCategory(const string &gameID, unsigned int id);
void RemoveCategory(const std::string &gameID, unsigned int id);
void RemoveCategory(const char *gameID, unsigned int id);
void RemoveCategory(const unsigned char *gameID, unsigned int id) { RemoveCategory((const char *) gameID, id); };
void RemoveGameCategories(const string &gameID);
const vector<unsigned int> &operator[](const char *gameID) const;
const vector<unsigned int> &operator[](const unsigned char *gameID) const { return operator[]((const char *) gameID); }
bool ImportFromGameTDB(const string &xmlpath);
void RemoveGameCategories(const std::string &gameID);
const std::vector<unsigned int> &operator[](const char *gameID) const;
const std::vector<unsigned int> &operator[](const unsigned char *gameID) const { return operator[]((const char *) gameID); }
bool ImportFromGameTDB(const std::string &xmlpath);
void clear() { List.clear(); CategoryList.clear(); };
static bool isInCategory(const char *gameID, unsigned int id);
@ -60,9 +60,9 @@ class CGameCategories
protected:
bool ValidVersion(XMLElement *xmlfile);
string configPath;
const vector<unsigned int> defaultCategory;
map<string, vector<unsigned int> > List;
std::string configPath;
const std::vector<unsigned int> defaultCategory;
std::map<std::string, std::vector<unsigned int> > List;
};
extern CGameCategories GameCategories;

View File

@ -56,6 +56,12 @@
#include "prompts/ProgressWindow.h"
#include "neek.hpp"
/* GCC 11 false positives */
#if __GNUC__ > 10
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
//appentrypoint has to be global because of asm
u32 AppEntrypoint = 0;

View File

@ -6,8 +6,6 @@
#include <string>
#include <vector>
using namespace std;
class WDMFile
{
public:
@ -19,12 +17,12 @@ class WDMFile
private:
struct WDMEntry
{
string DolName;
string ReplaceName;
std::string DolName;
std::string ReplaceName;
int Parameter;
};
vector<WDMEntry> WDMEntries;
std::vector<WDMEntry> WDMEntries;
};
#endif

View File

@ -9,6 +9,12 @@
#include "wdvd.h"
#include "fstfile.h"
/* GCC 11 false positives */
#if __GNUC__ > 10
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstringop-overread"
#endif
typedef struct _dolheader
{
u32 text_pos[7];

View File

@ -19,6 +19,13 @@
#include "GameCube/NIN_Config.h"
#include "gecko.h"
/* GCC 11 false positives */
#if __GNUC__ > 10
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#pragma GCC diagnostic ignored "-Wstringop-overread"
#endif
// Global app entry point
extern u32 AppEntrypoint;

View File

@ -28,6 +28,11 @@
#include "sys.h"
#include "gecko.h"
/* GCC 11 false positives */
#if __GNUC__ > 10
#pragma GCC diagnostic ignored "-Wstringop-overread"
#endif
typedef struct {
u32 hdrsize;
u32 loadersize;

View File

@ -248,7 +248,7 @@ int NandTitle::IndexOf(u64 tid)
const char* NandTitle::NameOf(u64 tid)
{
map<u64, string>::iterator itr = NameList.find(tid);
std::map<u64, std::string>::iterator itr = NameList.find(tid);
if (itr != NameList.end()) return itr->second.c_str();
return NULL;
@ -258,7 +258,7 @@ const char* NandTitle::NameFromIndex(u32 i)
{
if (i >= titleIds.size()) return NULL;
map<u64, string>::iterator itr = NameList.find(titleIds.at(i));
std::map<u64, std::string>::iterator itr = NameList.find(titleIds.at(i));
if (itr != NameList.end()) return itr->second.c_str();
return NULL;

View File

@ -11,7 +11,6 @@
#include <map>
#include "wstring.hpp"
using namespace std;
#define TITLE_ID(x,y) (((u64)(x) << 32) | (y))
#define TITLE_UPPER(x) ((u32)((x) >> 32))
@ -106,7 +105,7 @@ class NandTitle
static int InternalExtractDir(char *nandPath, std::string &filepath);
std::vector<u64> titleIds;
std::map<u64, string> NameList;
std::map<u64, std::string> NameList;
u32 currentIndex;
u32 currentType;

View File

@ -1,19 +1,17 @@
#include <wctype.h>
#include "wstring.hpp"
using namespace std;
wString::wString(const wchar_t *s) :
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >(s)
{
}
wString::wString(const basic_string<wchar_t, char_traits<wchar_t> , allocator<wchar_t> > &ws) :
basic_string<wchar_t, char_traits<wchar_t> , allocator<wchar_t> > (ws)
wString::wString(const basic_string<wchar_t, std::char_traits<wchar_t> , std::allocator<wchar_t> > &ws) :
std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > (ws)
{
}
wString::wString(const string &s)
wString::wString(const std::string &s)
{
std::string::size_type size;
@ -23,7 +21,7 @@ wString::wString(const string &s)
(*this)[i] = (unsigned char) s[i];
}
wString &wString::operator=(const string & s)
wString &wString::operator=(const std::string & s)
{
std::string::size_type size;
@ -68,9 +66,9 @@ void wString::fromUTF8(const char *s)
}
}
string wString::toUTF8(void) const
std::string wString::toUTF8(void) const
{
string s;
std::string s;
size_t len = 0;
wchar_t wc;

View File

@ -73,8 +73,8 @@ bool GameTDB::OpenFile(const char * filepath)
if(file)
{
int pos;
string OffsetsPath = filepath;
if((pos = OffsetsPath.find_last_of('/')) != (int) string::npos)
std::string OffsetsPath = filepath;
if((pos = OffsetsPath.find_last_of('/')) != (int) std::string::npos)
OffsetsPath[pos] = '\0';
else
OffsetsPath.clear(); //! Relative path
@ -88,7 +88,7 @@ bool GameTDB::OpenFile(const char * filepath)
void GameTDB::CloseFile()
{
OffsetMap.clear();
vector<GameOffsets>().swap(OffsetMap);
std::vector<GameOffsets>().swap(OffsetMap);
if(GameNodeCache)
delete [] GameNodeCache;
@ -104,7 +104,7 @@ bool GameTDB::LoadGameOffsets(const char * path)
if(!path)
return false;
string OffsetDBPath = path;
std::string OffsetDBPath = path;
if(strlen(path) > 0 && path[strlen(path)-1] != '/')
OffsetDBPath += '/';
OffsetDBPath += NAME_OFFSET_DB;
@ -467,7 +467,7 @@ bool GameTDB::ParseFile()
return true;
}
bool GameTDB::GetTitle(const char * id, string & title)
bool GameTDB::GetTitle(const char * id, std::string & title)
{
if(!id)
return false;
@ -501,7 +501,7 @@ bool GameTDB::GetTitle(const char * id, string & title)
return true;
}
bool GameTDB::GetSynopsis(const char * id, string & synopsis)
bool GameTDB::GetSynopsis(const char * id, std::string & synopsis)
{
if(!id)
return false;
@ -535,7 +535,7 @@ bool GameTDB::GetSynopsis(const char * id, string & synopsis)
return true;
}
bool GameTDB::GetRegion(const char * id, string & region)
bool GameTDB::GetRegion(const char * id, std::string & region)
{
if(!id)
return false;
@ -558,7 +558,7 @@ bool GameTDB::GetRegion(const char * id, string & region)
return true;
}
bool GameTDB::GetDeveloper(const char * id, string & dev)
bool GameTDB::GetDeveloper(const char * id, std::string & dev)
{
if(!id)
return false;
@ -581,7 +581,7 @@ bool GameTDB::GetDeveloper(const char * id, string & dev)
return true;
}
bool GameTDB::GetPublisher(const char * id, string & pub)
bool GameTDB::GetPublisher(const char * id, std::string & pub)
{
if(!id)
return false;
@ -651,7 +651,7 @@ unsigned int GameTDB::GetPublishDate(const char * id)
return ((year & 0xFFFF) << 16 | (month & 0xFF) << 8 | (day & 0xFF));
}
bool GameTDB::GetGenreList(const char * id, vector<string> & genre)
bool GameTDB::GetGenreList(const char * id, std::vector<std::string> & genre)
{
if(!id)
return false;
@ -706,7 +706,7 @@ bool GameTDB::GetGenreList(const char * id, vector<string> & genre)
return true;
}
void GameTDB::TranslateGenres(vector<string> &GenreList)
void GameTDB::TranslateGenres(std::vector<std::string> &GenreList)
{
char * data = GetGameNode("gnrmap");
if(!data)
@ -716,7 +716,7 @@ void GameTDB::TranslateGenres(vector<string> &GenreList)
{
for(unsigned int n = 0; n < 2; n++)
{
string nodeStart;
std::string nodeStart;
if(n == 0)
nodeStart = "<genre name=\"";
@ -738,7 +738,7 @@ void GameTDB::TranslateGenres(vector<string> &GenreList)
if(!genreNodeEnd)
continue;
string localStr = "<locale lang=\"";
std::string localStr = "<locale lang=\"";
localStr += LangCode;
localStr += "\">";
@ -904,7 +904,7 @@ int GameTDB::GetRating(const char * id)
return rating;
}
bool GameTDB::GetRatingValue(const char * id, string & rating_value)
bool GameTDB::GetRatingValue(const char * id, std::string & rating_value)
{
if(!id)
return false;
@ -934,7 +934,7 @@ bool GameTDB::GetRatingValue(const char * id, string & rating_value)
return true;
}
int GameTDB::GetRatingDescriptorList(const char * id, vector<string> & desc_list)
int GameTDB::GetRatingDescriptorList(const char * id, std::vector<std::string> & desc_list)
{
if(!id)
return -1;
@ -980,7 +980,7 @@ int GameTDB::GetRatingDescriptorList(const char * id, vector<string> & desc_list
return desc_list.size();
}
void GameTDB::TranslateDescriptors(vector<string> &DescList)
void GameTDB::TranslateDescriptors(std::vector<std::string> &DescList)
{
char * data = GetGameNode("dscmap");
if(!data)
@ -988,7 +988,7 @@ void GameTDB::TranslateDescriptors(vector<string> &DescList)
for(unsigned int i = 0; i < DescList.size(); ++i)
{
string nodeStart = "<descriptor name=\"";
std::string nodeStart = "<descriptor name=\"";
nodeStart += DescList[i];
const char *genreNode = strcasestr(data, nodeStart.c_str());
@ -1001,7 +1001,7 @@ void GameTDB::TranslateDescriptors(vector<string> &DescList)
if(!genreNodeEnd)
continue;
string localStr = "<locale lang=\"";
std::string localStr = "<locale lang=\"";
localStr += LangCode;
localStr += "\">";
@ -1060,7 +1060,7 @@ int GameTDB::GetWifiPlayers(const char * id)
return players;
}
int GameTDB::GetWifiFeatureList(const char * id, vector<string> & feat_list)
int GameTDB::GetWifiFeatureList(const char * id, std::vector<std::string> & feat_list)
{
if(!id)
return -1;
@ -1133,7 +1133,7 @@ int GameTDB::GetPlayers(const char * id)
return players;
}
int GameTDB::GetAccessoirList(const char * id, vector<Accessoir> & acc_list)
int GameTDB::GetAccessoirList(const char * id, std::vector<Accessoir> & acc_list)
{
if(!id)
return -1;
@ -1205,7 +1205,7 @@ int GameTDB::GetCaseColor(const char * id)
return color;
}
bool GameTDB::GetGameType(const char * id, string &GameType)
bool GameTDB::GetGameType(const char * id, std::string &GameType)
{
if(!id)
return false;

View File

@ -27,31 +27,29 @@
#include <vector>
#include <string>
using namespace std;
typedef struct _Accessoir
{
string Name;
std::string Name;
bool Required;
} Accessoir;
typedef struct _GameXMLInfo
{
string GameID;
string Region;
string Title;
string Synopsis;
string Developer;
string Publisher;
std::string GameID;
std::string Region;
std::string Title;
std::string Synopsis;
std::string Developer;
std::string Publisher;
unsigned int PublishDate;
vector<string> GenreList;
std::vector<std::string> GenreList;
int RatingType;
string RatingValue;
vector<string> RatingDescriptorList;
std::string RatingValue;
std::vector<std::string> RatingDescriptorList;
int WifiPlayers;
vector<string> WifiFeatureList;
std::vector<std::string> WifiFeatureList;
int Players;
vector<Accessoir> AccessoirList;
std::vector<Accessoir> AccessoirList;
long CaseColor;
} GameXMLInfo;
@ -83,55 +81,55 @@ class GameTDB
//! Get the current set language code
const char * GetLanguageCode() { return LangCode.c_str(); };
//! Get the title of a specific game id in the language defined in LangCode
bool GetTitle(const char * id, string & title);
bool GetTitle(const char * id, std::string & title);
//! Get the synopsis of a specific game id in the language defined in LangCode
bool GetSynopsis(const char * id, string & synopsis);
bool GetSynopsis(const char * id, std::string & synopsis);
//! Get the region of a game for a specific game id
bool GetRegion(const char * id, string & region);
bool GetRegion(const char * id, std::string & region);
//! Get the developer of a game for a specific game id
bool GetDeveloper(const char * id, string & dev);
bool GetDeveloper(const char * id, std::string & dev);
//! Get the publisher of a game for a specific game id
bool GetPublisher(const char * id, string & pub);
bool GetPublisher(const char * id, std::string & pub);
//! Get the publish date of a game for a specific game id
//! First 1 byte is the day, than 1 byte month and last 2 bytes is the year
//! year = (return >> 16), month = (return >> 8) & 0xFF, day = return & 0xFF
unsigned int GetPublishDate(const char * id);
//! Get the genre list of a game for a specific game id
bool GetGenreList(const char * id, vector<string> & genre);
bool GetGenreList(const char * id, std::vector<std::string> & genre);
//! Get the rating type for a specific game id
//! The rating type can be converted to a string with GameTDB::RatingToString(rating)
//! The rating type can be converted to a std::string with GameTDB::RatingTostd::string(rating)
int GetRating(const char * id);
//! Get the rating value for a specific game id
bool GetRatingValue(const char * id, string & rating_value);
//! Get the rating descriptor list inside a vector for a specific game id
bool GetRatingValue(const char * id, std::string & rating_value);
//! Get the rating descriptor list inside a std::vector for a specific game id
//! Returns the amount of descriptors found or -1 if failed
int GetRatingDescriptorList(const char * id, vector<string> & desc_list);
int GetRatingDescriptorList(const char * id, std::vector<std::string> & desc_list);
//! Get the wifi player count for a specific game id
//! Returns the amount of wifi players or -1 if failed
int GetWifiPlayers(const char * id);
//! Get the wifi feature list inside a vector for a specific game id
//! Get the wifi feature list inside a std::vector for a specific game id
//! Returns the amount of wifi features found or -1 if failed
int GetWifiFeatureList(const char * id, vector<string> & feat_list);
int GetWifiFeatureList(const char * id, std::vector<std::string> & feat_list);
//! Get the player count for a specific game id
//! Returns the amount of players or -1 if failed
int GetPlayers(const char * id);
//! Returns the amount of accessoirs found or -1 if failed
//! Get the accessoir (inputs) list inside a vector for a specific game id
int GetAccessoirList(const char * id, vector<Accessoir> & acc_list);
//! Get the accessoir (inputs) list inside a std::vector for a specific game id
int GetAccessoirList(const char * id, std::vector<Accessoir> & acc_list);
//! Get the box (case) color for a specific game id
//! Returns the color in RGB (first 3 bytes)
int GetCaseColor(const char * id);
//! Get the complete game info in the GameXMLInfo struct
bool GetGameXMLInfo(const char * id, GameXMLInfo * gameInfo);
//! Get the type of the game. If blank the game is a Wii game.
bool GetGameType(const char * id, string &GameType);
bool GetGameType(const char * id, std::string &GameType);
//! Translate genre list to configure language code
void TranslateGenres(vector<string> &GenreList);
void TranslateGenres(std::vector<std::string> &GenreList);
//! Translate descriptors list to configure language code
void TranslateDescriptors(vector<string> &DescList);
//! Convert a specific game rating to a string
void TranslateDescriptors(std::vector<std::string> &DescList);
//! Convert a specific game rating to a std::string
static const char * RatingToString(int rating);
//! Convert a rating string to a rating number
//! Convert a rating std::string to a rating number
static int StringToRating(const char *rate_string);
//! Convert a rating to another rating
static int ConvertRating(const char *value, const char *from, const char *to);
@ -150,9 +148,9 @@ class GameTDB
inline char * SeekLang(char * text, const char * langcode);
inline char * GetNodeText(char * data, const char * nodestart, const char * nodeend);
vector<GameOffsets> OffsetMap;
std::vector<GameOffsets> OffsetMap;
FILE * file;
string LangCode;
std::string LangCode;
char * GameNodeCache;
char GameIDCache[7];
};