Fixed a crash bug with launch commands missing %ROM%.

Added relative path operator (".") support for gamelist.xml, in both game paths and image paths.
This commit is contained in:
Aloshi 2012-09-23 16:01:56 -05:00
parent b225d0c9c8
commit 7e6498df60
5 changed files with 38 additions and 9 deletions

View file

@ -1,3 +1,7 @@
September 23
-Fixed crash when "%ROM%" isn't present in a launch command. Not sure why you'd ever do this on purpose, but hey.
-Added relative path operator ("./") support for gamelist.xml, for both game paths and image paths.
September 16
-Fixed a bug with skipping over unicode characters. [X] will be displayed if the character is not standard ASCII (characters 32 to 127).

View file

@ -31,7 +31,7 @@ namespace Renderer
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
sdlScreen = SDL_SetVideoMode(display_width, display_height, 16, SDL_OPENGL); //SDL_FULLSCREEN
sdlScreen = SDL_SetVideoMode(display_width, display_height, 16, SDL_OPENGL | SDL_FULLSCREEN);
if(sdlScreen == NULL)
{

View file

@ -61,7 +61,10 @@ std::string strreplace(std::string& str, std::string replace, std::string with)
{
size_t pos = str.find(replace);
return str.replace(pos, replace.length(), with.c_str(), with.length());
if(pos != std::string::npos)
return str.replace(pos, replace.length(), with.c_str(), with.length());
else
return str;
}
void SystemData::launchGame(GameData* game)
@ -196,13 +199,15 @@ void SystemData::loadConfig()
if(varName == "NAME")
sysName = varValue;
else if(varName == "PATH")
sysPath = varValue;
else if(varName == "EXTENSION")
{
if(varValue[varValue.length() - 1] == '/')
sysPath = varValue.substr(0, varValue.length() - 1);
else
sysPath = varValue;
}else if(varName == "EXTENSION")
sysExtension = varValue;
else if(varName == "COMMAND")
sysCommand = varValue;
//else
// std::cout << "Warning reading config file - unknown variable name \"" << varName << "\", ignoring.\n";
//we have all our variables - create the system object
if(!sysName.empty() && !sysPath.empty() &&!sysExtension.empty() && !sysCommand.empty())

View file

@ -5,7 +5,6 @@
#include <boost/filesystem.hpp>
//this is obviously an incredibly inefficient way to go about searching
//some day I may change this to use hash tables or something
//but I don't think it'll matter too much with the size of most collections
GameData* searchFolderByPath(FolderData* folder, std::string const& path)
{
@ -138,6 +137,13 @@ void parseGamelist(SystemData* system)
std::string path = pathNode.text().get();
//expand "."
if(path[0] == '.')
{
path.erase(0, 1);
path.insert(0, system->getRootFolder()->getPath());
}
if(boost::filesystem::exists(path))
{
GameData* game = searchFolderByPath(system->getRootFolder(), path);
@ -153,8 +159,17 @@ void parseGamelist(SystemData* system)
if(gameNode.child("desc"))
newDesc = gameNode.child("desc").text().get();
if(gameNode.child("image"))
{
newImage = gameNode.child("image").text().get();
//expand "."
if(newImage[0] == '.')
{
newImage.erase(0, 1);
newImage.insert(0, system->getRootFolder()->getPath());
}
}
game->set(newName, newDesc, newImage);
}else{

View file

@ -72,6 +72,7 @@ int main(int argc, char* argv[])
bool running = true;
//desktop uses SDL to set up an OpenGL context, and has its own SDL window...so I #ifdefed here.
//this should be moved to the RPi init/deinit file
//ALWAYS INITIALIZE VIDEO. It starts SDL's event system, and without it, input won't work.
#ifdef _RPI_
@ -79,12 +80,16 @@ int main(int argc, char* argv[])
{
std::cerr << "Error - could not initialize SDL!\n";
std::cerr << " " << SDL_GetError() << "\n";
std::cerr << "Are you in the 'video' and 'input' groups? Are you running with X closed? Is your firmware up to date?\n";
std::cerr << "Are you in the 'video' and 'input' groups? Are you running with X closed? Is your firmware up to date? Are you using at least the 192/64 memory split?\n";
return 1;
}
SDL_Surface* sdlScreen = SDL_SetVideoMode(1, 1, 0, SDL_SWSURFACE);
std::cout << "Fake SDL window is " << sdlScreen->w << "x" << sdlScreen->h << "\n";
if(sdlScreen == NULL)
{
std::cerr << "Error initializing SDL screen!\n";
running = false;
}
#endif
bool renderInit = Renderer::init(width, height);