# Copyright (C) 2009  Miriam Ruiz <little_miry@yahoo.es>
# Distributed under the same license as the software. See debian/copyright.

--- libtuxcap-1.4.0.orig/tuxcap/lib/ResourceManager.cpp
+++ libtuxcap-1.4.0/tuxcap/lib/ResourceManager.cpp
@@ -191,9 +191,10 @@
 		if (aPath==_S("!program"))
 			theRes->mFromProgram = true;
 	}
+	else if (aPath[0]==_S('/'))
+		theRes->mPath = SexyStringToStringFast(aPath);
 	else
 		theRes->mPath = mDefaultPath + SexyStringToStringFast(aPath);
-
 	
 	std::string anId;
 	XMLParamMap::iterator anItr = theElement.mAttributes.find(_S("id"));
@@ -595,8 +596,9 @@
 bool ResourceManager::ParseResourcesFile(const std::string& theFilename)
 {
 	mXMLParser = new XMLParser();
-	if (!mXMLParser->OpenFile(GetAppResourceFolder() + theFilename))
-		Fail("Resource file not found: " + GetAppResourceFolder() + theFilename);
+	std::string fname = ReplaceBackSlashes(theFilename[0]!='/'? GetAppResourceFolder() + theFilename : theFilename);
+	if (!mXMLParser->OpenFile(fname))
+		Fail("Resource file not found: " + fname);
 
 	XMLElement aXMLElement;
 	while (!mXMLParser->HasFailed())
--- libtuxcap-1.4.0.orig/tuxcap/hgeparticle/hgeparticle.cpp
+++ libtuxcap-1.4.0/tuxcap/hgeparticle/hgeparticle.cpp
@@ -58,7 +58,7 @@
     bInitOK = false;
 
     // LOAD FROM FILE
-    std::string fullfilename = Sexy::ReplaceBackSlashes(Sexy::GetAppResourceFolder() + filename);
+    std::string fullfilename = ReplaceBackSlashes(filename[0]!='/'? GetAppResourceFolder() + filename : std::string(filename));
     FILE *fp = fopen( fullfilename.c_str(), "rb" );
     if( fp == NULL ) 
         return ; 
--- libtuxcap-1.4.0.orig/tuxcap/lib/ImageFont.cpp
+++ libtuxcap-1.4.0/tuxcap/lib/ImageFont.cpp
@@ -1014,7 +1014,7 @@
 
 	bool hasErrors = false;	
 
-        std::string daFontDescFileName = GetAppResourceFolder() + theFontDescFileName;
+	std::string daFontDescFileName = ReplaceBackSlashes(theFontDescFileName[0]!='/'? GetAppResourceFolder() + theFontDescFileName : theFontDescFileName);
 
         daFontDescFileName = ReplaceBackSlashes(daFontDescFileName);
   
@@ -1046,7 +1046,7 @@
 	aFontLayer->mDefaultHeight = aFontLayer->mImage->GetHeight();	
 	aFontLayer->mAscent = aFontLayer->mImage->GetHeight();	
 
-        std::string daFontDescFileName = GetAppResourceFolder() + theFontDescFileName;
+        std::string daFontDescFileName = ReplaceBackSlashes(theFontDescFileName[0]!='/'? GetAppResourceFolder() + theFontDescFileName : theFontDescFileName);
 
         daFontDescFileName = ReplaceBackSlashes(daFontDescFileName);
 
--- libtuxcap-1.4.0.orig/tuxcap/lib/SDLMixerMusicInterface.cpp
+++ libtuxcap-1.4.0/tuxcap/lib/SDLMixerMusicInterface.cpp
@@ -70,7 +70,7 @@
 {
 	SDLMixerMusicInfo aMusicInfo;
 
-        std::string copy = Sexy::ReplaceBackSlashes(GetAppResourceFolder() + theFileName);
+	std::string copy = ReplaceBackSlashes(theFileName[0]!='/'? GetAppResourceFolder() + theFileName : theFileName);
 
 	int aLastDotPos = copy.rfind('.');
 	int aLastSlashPos = (int)copy.rfind('/');
--- libtuxcap-1.4.0.orig/tuxcap/lib/SDLMixerSoundManager.cpp
+++ libtuxcap-1.4.0/tuxcap/lib/SDLMixerSoundManager.cpp
@@ -125,7 +125,7 @@
 	if (!Initialized())
 		return true; // sounds just	won't play, but this is not treated as a failure condition
 
-	std::string aFilename = ReplaceBackSlashes(GetAppResourceFolder() + theFilename);
+	std::string aFilename = ReplaceBackSlashes(theFilename[0]!='/'? GetAppResourceFolder() + theFilename : theFilename);
 
 	mSourceSounds[theSfxID] = Mix_LoadWAV(aFilename.c_str());
 
--- libtuxcap-1.4.0.orig/tuxcap/lib/SexyAppBase.cpp
+++ libtuxcap-1.4.0/tuxcap/lib/SexyAppBase.cpp
@@ -5678,7 +5678,7 @@
 
   std::string resourcepath = GetAppResourceFolder();
   if (!resourcepath.empty()) {
-    if (theFileName.substr(0, resourcepath.size()) == resourcepath)
+    if (theFileName.substr(0, resourcepath.size()) == resourcepath || theFileName[0] == '/')
       aLoadedImage = ImageLib::GetImage(theFileName, true);
     else
       aLoadedImage = ImageLib::GetImage(resourcepath + theFileName, true);
@@ -6167,7 +6167,8 @@
         }
 
         if (!mWindowIconBMP.empty()) {
-            SDL_WM_SetIcon(SDL_LoadBMP((GetAppResourceFolder() + mWindowIconBMP).c_str()), NULL);
+            std::string fname = ReplaceBackSlashes(mWindowIconBMP[0]!='/'? GetAppResourceFolder() + mWindowIconBMP : mWindowIconBMP);
+            SDL_WM_SetIcon(SDL_LoadBMP(fname.c_str()), NULL);
         }
 
     if (mDDInterface->mIs3D) {
@@ -6996,7 +6997,8 @@
 bool SexyAppBase::LoadProperties(const std::string& theFileName, bool required, bool checkSig)
 {
 	Buffer aBuffer;
-	if (!ReadBufferFromFile(GetAppResourceFolder() + theFileName, &aBuffer))
+	std::string fname = ReplaceBackSlashes(theFileName[0]!='/'? GetAppResourceFolder() + theFileName : theFileName);
+	if (!ReadBufferFromFile(fname, &aBuffer))
 	{
 		if (!required)
 			return true;
