2010-09-24 23:22:01 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2010
|
|
|
|
* by Dimok
|
|
|
|
*
|
|
|
|
* This software is provided 'as-is', without any express or implied
|
|
|
|
* warranty. In no event will the authors be held liable for any
|
|
|
|
* damages arising from the use of this software.
|
|
|
|
*
|
|
|
|
* Permission is granted to anyone to use this software for any
|
|
|
|
* purpose, including commercial applications, and to alter it and
|
|
|
|
* redistribute it freely, subject to the following restrictions:
|
|
|
|
*
|
|
|
|
* 1. The origin of this software must not be misrepresented; you
|
|
|
|
* must not claim that you wrote the original software. If you use
|
|
|
|
* this software in a product, an acknowledgment in the product
|
|
|
|
* documentation would be appreciated but is not required.
|
|
|
|
*
|
|
|
|
* 2. Altered source versions must be plainly marked as such, and
|
|
|
|
* must not be misrepresented as being the original software.
|
|
|
|
*
|
|
|
|
* 3. This notice may not be removed or altered from any source
|
|
|
|
* distribution.
|
|
|
|
***************************************************************************/
|
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2011-01-21 20:43:59 +01:00
|
|
|
#include "CSettings.h"
|
2010-09-24 23:22:01 +02:00
|
|
|
#include "CGameSettings.h"
|
2010-09-25 08:54:27 +02:00
|
|
|
#include "FileOperations/fileops.h"
|
2011-01-06 19:59:45 +01:00
|
|
|
#include "svnrev.h"
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
#define VALID_CONFIG_REV 1031
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-01-06 19:59:45 +01:00
|
|
|
CGameSettings GameSettings;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
|
|
|
CGameSettings::CGameSettings()
|
|
|
|
{
|
2011-12-20 22:41:00 +01:00
|
|
|
SetDefault(DefaultConfig);
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CGameSettings::~CGameSettings()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GameCFG * CGameSettings::GetGameCFG(const char * id)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
if(!id)
|
2011-12-20 22:41:00 +01:00
|
|
|
{
|
|
|
|
DefaultConfig.id[0] = '\0';
|
|
|
|
return &DefaultConfig;
|
|
|
|
}
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
for(u32 i = 0; i < GameList.size(); ++i)
|
|
|
|
{
|
|
|
|
if(strncasecmp(id, GameList[i].id, 6) == 0)
|
|
|
|
return &GameList[i];
|
|
|
|
}
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-12-20 22:41:00 +01:00
|
|
|
memcpy(DefaultConfig.id, id, 6);
|
2011-01-21 21:59:49 +01:00
|
|
|
|
2011-12-20 22:41:00 +01:00
|
|
|
return &DefaultConfig;
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
|
|
|
|
2010-09-25 10:51:44 +02:00
|
|
|
bool CGameSettings::AddGame(const GameCFG & NewGame)
|
2010-09-24 23:22:01 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
for(u32 i = 0; i < GameList.size(); ++i)
|
|
|
|
{
|
|
|
|
if(strncasecmp(NewGame.id, GameList[i].id, 6) == 0)
|
|
|
|
{
|
2011-12-20 22:41:00 +01:00
|
|
|
GameList[i] = NewGame;
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GameList.push_back(NewGame);
|
|
|
|
|
|
|
|
return true;
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CGameSettings::RemoveAll()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
GameList.clear();
|
|
|
|
std::vector<GameCFG>().swap(GameList);
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return Save();
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CGameSettings::Remove(const char * id)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
if(!id)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for(u32 i = 0; i < GameList.size(); ++i)
|
|
|
|
{
|
|
|
|
if(strncasecmp(id, GameList[i].id, 6) == 0)
|
|
|
|
{
|
|
|
|
GameList.erase(GameList.begin()+i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CGameSettings::Load(const char * path)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
char filepath[300];
|
|
|
|
snprintf(filepath, sizeof(filepath), "%sGXGameSettings.cfg", path);
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
ConfigPath = filepath;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
FILE *file = fopen(filepath, "r");
|
|
|
|
if (!file) return false;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
if(!ValidVersion(file))
|
|
|
|
{
|
|
|
|
fclose(file);
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-06 19:59:45 +01:00
|
|
|
|
2011-12-20 22:41:00 +01:00
|
|
|
const int lineSize = 20*1024;
|
|
|
|
|
|
|
|
char *line = new (std::nothrow) char[lineSize];
|
|
|
|
if(!line) {
|
|
|
|
fclose(file);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (fgets(line, lineSize, file))
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
|
|
|
if (line[0] == '#')
|
|
|
|
continue;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
this->ParseLine(line);
|
|
|
|
}
|
2011-12-20 22:41:00 +01:00
|
|
|
|
|
|
|
delete [] line;
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
fclose(file);
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
|
|
|
|
2011-01-06 19:59:45 +01:00
|
|
|
bool CGameSettings::ValidVersion(FILE * file)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
if(!file) return false;
|
2011-01-06 19:59:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
char line[255];
|
|
|
|
int revision = 0;
|
2011-01-06 19:59:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
while (fgets(line, sizeof(line), file))
|
|
|
|
{
|
|
|
|
const char * ptr = strcasestr(line, "USB Loader GX R");
|
|
|
|
if(ptr)
|
|
|
|
{
|
|
|
|
ptr += strlen("USB Loader GX R");
|
|
|
|
revision = atoi(ptr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-01-06 19:59:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
rewind(file);
|
2011-01-06 19:59:45 +01:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return revision >= VALID_CONFIG_REV;
|
2011-01-06 19:59:45 +01:00
|
|
|
}
|
|
|
|
|
2010-09-24 23:22:01 +02:00
|
|
|
bool CGameSettings::Save()
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
char filepath[300];
|
2012-05-06 12:59:58 +02:00
|
|
|
strlcpy(filepath, ConfigPath.c_str(), sizeof(filepath));
|
2011-07-26 00:28:22 +02:00
|
|
|
|
|
|
|
char * ptr = strrchr(filepath, '/');
|
|
|
|
if(ptr)
|
|
|
|
ptr[0] = 0;
|
|
|
|
|
|
|
|
CreateSubfolder(filepath);
|
|
|
|
|
|
|
|
FILE * f = fopen(ConfigPath.c_str(), "w");
|
|
|
|
if (!f) return false;
|
|
|
|
|
|
|
|
fprintf(f, "# USB Loader GX R%s - Individual game settings file\n", GetRev());
|
|
|
|
fprintf(f, "# note: this file is automatically generated\n");
|
|
|
|
fprintf(f, "# Num Games: %d\n", GameList.size());
|
|
|
|
for (u32 i = 0; i < GameList.size(); ++i)
|
|
|
|
{
|
|
|
|
fprintf(f, "game:%s = ", GameList[i].id);
|
|
|
|
fprintf(f, "video:%d; ", GameList[i].video);
|
2011-12-23 16:48:20 +01:00
|
|
|
fprintf(f, "aspectratio:%d; ", GameList[i].aspectratio);
|
2011-07-26 00:28:22 +02:00
|
|
|
fprintf(f, "language:%d; ", GameList[i].language);
|
|
|
|
fprintf(f, "ocarina:%d; ", GameList[i].ocarina);
|
|
|
|
fprintf(f, "vipatch:%d; ", GameList[i].vipatch);
|
|
|
|
fprintf(f, "ios:%d; ", GameList[i].ios);
|
|
|
|
fprintf(f, "parentalcontrol:%d; ", GameList[i].parentalcontrol);
|
|
|
|
fprintf(f, "errorfix002:%d; ", GameList[i].errorfix002);
|
|
|
|
fprintf(f, "iosreloadblock:%d; ", GameList[i].iosreloadblock);
|
|
|
|
fprintf(f, "patchcountrystrings:%d; ", GameList[i].patchcountrystrings);
|
|
|
|
fprintf(f, "loadalternatedol:%d; ", GameList[i].loadalternatedol);
|
|
|
|
fprintf(f, "alternatedolstart:%d; ", GameList[i].alternatedolstart);
|
2011-12-20 22:41:00 +01:00
|
|
|
fprintf(f, "alternatedolname:%s; ", GameList[i].alternatedolname.c_str());
|
2011-07-26 00:28:22 +02:00
|
|
|
fprintf(f, "returnTo:%d; ", GameList[i].returnTo);
|
|
|
|
fprintf(f, "sneekVideoPatch:%d; ", GameList[i].sneekVideoPatch);
|
2011-09-03 11:39:26 +02:00
|
|
|
fprintf(f, "NandEmuMode:%d; ", GameList[i].NandEmuMode);
|
2011-12-20 22:41:00 +01:00
|
|
|
fprintf(f, "NandEmuPath:%s; ", GameList[i].NandEmuPath.c_str());
|
2011-09-03 11:39:26 +02:00
|
|
|
fprintf(f, "Hooktype:%d; ", GameList[i].Hooktype);
|
|
|
|
fprintf(f, "WiirdDebugger:%d; ", GameList[i].WiirdDebugger);
|
2012-05-06 12:59:58 +02:00
|
|
|
fprintf(f, "DMLVideo:%d; ", GameList[i].DMLVideo);
|
|
|
|
fprintf(f, "DMLNMM:%d; ", GameList[i].DMLNMM);
|
|
|
|
fprintf(f, "DMLActivityLED:%d; ", GameList[i].DMLActivityLED);
|
|
|
|
fprintf(f, "DMLPADHOOK:%d; ", GameList[i].DMLPADHOOK);
|
|
|
|
fprintf(f, "DMLNoDisc:%d; ", GameList[i].DMLNoDisc);
|
|
|
|
fprintf(f, "DMLDebug:%d; ", GameList[i].DMLDebug);
|
2011-07-26 00:28:22 +02:00
|
|
|
fprintf(f, "Locked:%d;\n", GameList[i].Locked);
|
|
|
|
}
|
|
|
|
fprintf(f, "# END\n");
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
return true;
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
|
|
|
|
2011-12-20 22:41:00 +01:00
|
|
|
bool CGameSettings::SetSetting(GameCFG & game, const char *name, const char *value)
|
2010-09-24 23:22:01 +02:00
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
if (strcmp(name, "video") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.video = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-12-23 16:48:20 +01:00
|
|
|
else if(strcmp(name, "aspectratio") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.aspectratio = atoi(value);
|
2011-12-23 16:48:20 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcmp(name, "language") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.language = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "ocarina") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.ocarina = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "vipatch") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.vipatch = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "ios") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.ios = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "parentalcontrol") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.parentalcontrol = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "errorfix002") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.errorfix002 = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "iosreloadblock") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.iosreloadblock = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "loadalternatedol") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.loadalternatedol = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "alternatedolstart") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.alternatedolstart = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "patchcountrystrings") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.patchcountrystrings = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "alternatedolname") == 0)
|
|
|
|
{
|
2011-12-20 22:41:00 +01:00
|
|
|
game.alternatedolname = value;
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "returnTo") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.returnTo = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "sneekVideoPatch") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.sneekVideoPatch = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-09-03 11:39:26 +02:00
|
|
|
else if(strcmp(name, "NandEmuMode") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.NandEmuMode = atoi(value);
|
2011-09-03 11:39:26 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-12-20 22:41:00 +01:00
|
|
|
else if(strcmp(name, "NandEmuPath") == 0)
|
|
|
|
{
|
|
|
|
game.NandEmuPath = value;
|
|
|
|
return true;
|
|
|
|
}
|
2011-09-03 11:39:26 +02:00
|
|
|
else if(strcmp(name, "Hooktype") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.Hooktype = atoi(value);
|
2011-09-03 11:39:26 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "WiirdDebugger") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.WiirdDebugger = atoi(value);
|
2011-09-03 11:39:26 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-07-26 00:28:22 +02:00
|
|
|
else if(strcmp(name, "Locked") == 0)
|
|
|
|
{
|
2012-05-06 12:59:58 +02:00
|
|
|
game.Locked = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "DMLVideo") == 0)
|
|
|
|
{
|
|
|
|
game.DMLVideo = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "DMLNMM") == 0)
|
|
|
|
{
|
|
|
|
game.DMLNMM = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "DMLActivityLED") == 0)
|
|
|
|
{
|
|
|
|
game.DMLActivityLED = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "DMLPADHOOK") == 0)
|
|
|
|
{
|
|
|
|
game.DMLPADHOOK = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "DMLNoDisc") == 0)
|
|
|
|
{
|
|
|
|
game.DMLNoDisc = atoi(value);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(strcmp(name, "DMLDebug") == 0)
|
|
|
|
{
|
|
|
|
game.DMLDebug = atoi(value);
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CGameSettings::ReadGameID(const char * src, char * GameID, int size)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
if(strncasecmp(src, "game:", 5) != 0)
|
|
|
|
return false;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
char * ptr = strchr(src, ':');
|
|
|
|
if(!ptr)
|
|
|
|
return false;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
ptr++;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
int i = 0;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
for(i = 0; i < size; i++, ptr++)
|
|
|
|
{
|
|
|
|
if(*ptr == ' ' || *ptr == '\0')
|
|
|
|
break;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
GameID[i] = *ptr;
|
|
|
|
}
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
GameID[i] = 0;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
return true;
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGameSettings::ParseLine(char *line)
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
char GameID[8];
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
if(!ReadGameID(line, GameID, 6))
|
|
|
|
return;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-11-12 19:14:09 +01:00
|
|
|
if(strlen(GameID) != 6 && strlen(GameID) != 4)
|
2011-07-26 00:28:22 +02:00
|
|
|
return;
|
2010-09-25 10:51:44 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
GameCFG NewCFG;
|
2011-12-20 22:41:00 +01:00
|
|
|
SetDefault(NewCFG);
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
strcpy(NewCFG.id, GameID);
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
char * LinePtr = strchr(line, '=');
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
while(LinePtr != NULL)
|
|
|
|
{
|
|
|
|
LinePtr++;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
char * eq = strchr(LinePtr, ':');
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
if (!eq) break;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-12-20 22:41:00 +01:00
|
|
|
std::string name, value;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-12-20 22:41:00 +01:00
|
|
|
this->TrimLine(name, LinePtr, ':');
|
|
|
|
this->TrimLine(value, eq + 1, ';');
|
|
|
|
|
|
|
|
SetSetting(NewCFG, name.c_str(), value.c_str());
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
LinePtr = strchr(LinePtr, ';');
|
|
|
|
}
|
2010-09-24 23:43:46 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
AddGame(NewCFG);
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
|
|
|
|
2011-12-20 22:41:00 +01:00
|
|
|
void CGameSettings::TrimLine(std::string &dest, const char *src, char stopChar)
|
2010-09-24 23:22:01 +02:00
|
|
|
{
|
2011-12-20 22:41:00 +01:00
|
|
|
if(!src)
|
|
|
|
return;
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
while (*src == ' ')
|
|
|
|
src++;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-12-20 22:41:00 +01:00
|
|
|
while(*src != 0)
|
2011-07-26 00:28:22 +02:00
|
|
|
{
|
2011-12-20 22:41:00 +01:00
|
|
|
if(*src == stopChar || *src == '\n' || *src == '\r')
|
2011-07-26 00:28:22 +02:00
|
|
|
break;
|
2010-09-24 23:22:01 +02:00
|
|
|
|
2011-12-20 22:41:00 +01:00
|
|
|
dest.push_back(*src);
|
|
|
|
src++;
|
2011-07-26 00:28:22 +02:00
|
|
|
}
|
2010-09-24 23:22:01 +02:00
|
|
|
}
|
2010-10-28 11:00:52 +02:00
|
|
|
|
|
|
|
int CGameSettings::GetPartenalPEGI(int parental)
|
|
|
|
{
|
|
|
|
switch(parental)
|
|
|
|
{
|
|
|
|
case 1: return 7;
|
|
|
|
case 2: return 12;
|
|
|
|
case 3: return 16;
|
|
|
|
case 4: return 18;
|
|
|
|
default: return -1;
|
|
|
|
}
|
|
|
|
}
|
2011-01-21 20:43:59 +01:00
|
|
|
|
2011-12-20 22:41:00 +01:00
|
|
|
void CGameSettings::SetDefault(GameCFG &game)
|
2011-01-21 20:43:59 +01:00
|
|
|
{
|
2011-12-20 22:41:00 +01:00
|
|
|
memset(game.id, 0, sizeof(game.id));
|
|
|
|
game.video = INHERIT;
|
2011-12-23 16:48:20 +01:00
|
|
|
game.aspectratio = INHERIT;
|
2011-12-20 22:41:00 +01:00
|
|
|
game.language = INHERIT;
|
|
|
|
game.ocarina = INHERIT;
|
|
|
|
game.vipatch = INHERIT;
|
|
|
|
game.ios = INHERIT;
|
|
|
|
game.parentalcontrol = PARENTAL_LVL_EVERYONE;
|
|
|
|
game.errorfix002 = INHERIT;
|
|
|
|
game.patchcountrystrings = INHERIT;
|
|
|
|
game.loadalternatedol = ALT_DOL_DEFAULT;
|
|
|
|
game.alternatedolstart = 0;
|
|
|
|
game.iosreloadblock = INHERIT;
|
|
|
|
game.alternatedolname.clear();
|
2012-01-01 18:58:10 +01:00
|
|
|
game.returnTo = ON;
|
2011-12-20 22:41:00 +01:00
|
|
|
game.sneekVideoPatch = INHERIT;
|
|
|
|
game.NandEmuMode = INHERIT;
|
|
|
|
game.NandEmuPath.clear();
|
|
|
|
game.Hooktype = INHERIT;
|
|
|
|
game.WiirdDebugger = INHERIT;
|
2012-05-06 12:59:58 +02:00
|
|
|
game.DMLVideo = INHERIT;
|
|
|
|
game.DMLNMM = INHERIT;
|
|
|
|
game.DMLActivityLED = INHERIT;
|
|
|
|
game.DMLPADHOOK = INHERIT;
|
|
|
|
game.DMLNoDisc = INHERIT;
|
|
|
|
game.DMLDebug = INHERIT;
|
2011-12-20 22:41:00 +01:00
|
|
|
game.Locked = OFF;
|
2011-01-21 20:43:59 +01:00
|
|
|
}
|