diff --git a/JGE/src/JAudio.cpp b/JGE/src/JAudio.cpp index 234afdeed..42ff6b858 100644 --- a/JGE/src/JAudio.cpp +++ b/JGE/src/JAudio.cpp @@ -403,6 +403,8 @@ void audioInit() // 初始化 void audioDestroy() { + pspAudioEndPre(); + sceKernelDelayThread(100000); pspAudioEnd(); } diff --git a/projects/mtg/bin/Res/campaigns/01.Where it all begins/_gfx/back_green.jpg b/projects/mtg/bin/Res/campaigns/01.Where it all begins/_gfx/back_green.jpg new file mode 100644 index 000000000..b2c8b8dc0 Binary files /dev/null and b/projects/mtg/bin/Res/campaigns/01.Where it all begins/_gfx/back_green.jpg differ diff --git a/projects/mtg/bin/Res/campaigns/01.Where it all begins/_sfx/siege.mp3 b/projects/mtg/bin/Res/campaigns/01.Where it all begins/_sfx/siege.mp3 new file mode 100644 index 000000000..6eaaf90eb Binary files /dev/null and b/projects/mtg/bin/Res/campaigns/01.Where it all begins/_sfx/siege.mp3 differ diff --git a/projects/mtg/bin/Res/campaigns/01.Where it all begins/story.xml b/projects/mtg/bin/Res/campaigns/01.Where it all begins/story.xml index 5492070ac..8fc7d90f9 100644 --- a/projects/mtg/bin/Res/campaigns/01.Where it all begins/story.xml +++ b/projects/mtg/bin/Res/campaigns/01.Where it all begins/story.xml @@ -2,6 +2,7 @@ dialog +_sfx/siege.mp3 Welcome young adventurer... _gfx/shopkeeper.jpg So you want to become a sorcerer? @@ -15,6 +16,7 @@ dialog Tapping lands for mana +I unlocked ${SET} for you In your quests you will have to fight against other wizards. You will only have your brain and your spells to help you. The basic Energy to cast your spells in Wagic is called mana. @@ -26,6 +28,7 @@ duel +_gfx/back_green.jpg tap_mana_ok tap_mana_try_again @@ -41,8 +44,10 @@ dialog +none Well done...now let's cast a spell That was too easy for you! +As a reward, I give you a ${CARD} Now let's see if you can cast a spell... Spells have a cost represented by mana symbols on the top right corner of the card. For example, 2 white mana icons on the top right of the card @@ -169,6 +174,7 @@ dialog Great! You now understand the basics of the combat phase +I unlocked ${SET} for you Continue diff --git a/projects/mtg/bin/Res/campaigns/README.txt b/projects/mtg/bin/Res/campaigns/README.txt index 9ab43a3fb..d486bd564 100644 --- a/projects/mtg/bin/Res/campaigns/README.txt +++ b/projects/mtg/bin/Res/campaigns/README.txt @@ -3,6 +3,9 @@ Documentation for the Basic campaign system in Wagic Each subfolder that contains a "story.xml" is considered as a "story". Stories appear in the menu and represent a series of dialogs and duels. +*: 0 to n +?: 0 to 1 + ################################# 1.Structure of story.xml: ################################# @@ -20,6 +23,7 @@ Elements of the page node =========================================== type (dialog,duel,end) +music ? (path to a music file) =========================================== @@ -30,6 +34,7 @@ title * img * text * answer * +reward * title, img, text, answer have the following common attributes: x (optional - default 0) @@ -53,14 +58,22 @@ answer specific attributes: goto id of a page to go to +reward attributes: +type + unlockset , card, credits +value + number of credits, or name/id of the card (random if undef), or name of the set (random if undef) +Additionally, the fowllowing variables can be used in the reward text : ${SET}, ${CARD} + =========================================== -Additional Elmts of the "page" node if type == dialog +Additional Elmts of the "page" node if type == duel =========================================== onwin id of a page to go to if duel lost onlose id of a page to go to if duel won - +bg + path to a background file diff --git a/projects/mtg/include/Credits.h b/projects/mtg/include/Credits.h index efa82e2f1..fb414dd95 100644 --- a/projects/mtg/include/Credits.h +++ b/projects/mtg/include/Credits.h @@ -44,7 +44,10 @@ public: void compute(Player * _p1, Player * _p2, GameApp * _app); void Render(); static int unlockRandomSet(bool force = false); + static int unlockSetByName(string name); static int addCreditBonus(int value); + static int addCardToCollection(int cardId, MTGDeck * collection); + static int addCardToCollection(int cardId); }; #endif diff --git a/projects/mtg/include/GameApp.h b/projects/mtg/include/GameApp.h index 727cfa52b..7d3310892 100644 --- a/projects/mtg/include/GameApp.h +++ b/projects/mtg/include/GameApp.h @@ -87,6 +87,7 @@ class GameApp: public JApp static int HasMusic; static string systemError; static JMusic* music; + static void playMusic(string filename, bool loop = true); static MTGAllCards * collection; static int players[2]; diff --git a/projects/mtg/include/GameObserver.h b/projects/mtg/include/GameObserver.h index 0b277b2eb..5f1bad755 100644 --- a/projects/mtg/include/GameObserver.h +++ b/projects/mtg/include/GameObserver.h @@ -49,6 +49,7 @@ class GameObserver{ Player * gameOver; Player * players[2]; //created outside time_t startedAt; + Rules * mRules; TargetChooser * getCurrentTargetChooser(); void stackObjectClicked(Interruptible * action); diff --git a/projects/mtg/include/Rules.h b/projects/mtg/include/Rules.h index 9efa81004..8e2f78606 100644 --- a/projects/mtg/include/Rules.h +++ b/projects/mtg/include/Rules.h @@ -60,7 +60,10 @@ public: PARSE_PLAYER2, PARSE_PLAYERS }; - Rules(string filename); + + string bg; + + Rules(string filename, string bg = ""); int load(string filename); int gamemode; void initPlayers(); @@ -71,6 +74,7 @@ public: RulesState initState; static int getMTGId(string name); static MTGCardInstance * getCardByMTGId(int mtgid); + }; #endif diff --git a/projects/mtg/include/StoryFlow.h b/projects/mtg/include/StoryFlow.h index 1c39b3625..7192d2aba 100644 --- a/projects/mtg/include/StoryFlow.h +++ b/projects/mtg/include/StoryFlow.h @@ -8,6 +8,7 @@ using namespace std; #include "../../../JGE/src/tinyxml/tinyxml.h" #include class GameObserver; +class MTGDeck; #define CAMPAIGNS_FOLDER "Res/campaigns/" @@ -49,7 +50,8 @@ class StoryReward:public StoryText { public: enum { STORY_REWARD_CREDITS, - STORY_REWARD_SET + STORY_REWARD_SET, + STORY_REWARD_CARD, }; int rewardDone; @@ -62,6 +64,7 @@ public: static bool rewardSoundPlayed; static bool rewardsEnabled; + static MTGDeck * collection; }; class StoryChoice:public StoryText { @@ -85,18 +88,21 @@ public: class StoryFlow; class StoryPage { +protected: + string safeAttribute(TiXmlElement* element, string attribute); public: StoryFlow * mParent; + string musicFile; StoryPage(StoryFlow * mParent); virtual void Update(float dt)=0; virtual void Render()=0; virtual ~StoryPage(){}; + int loadElement(TiXmlElement* element); }; class StoryDialog:public StoryPage, public JGuiListener,public JGuiController { private: vectorgraphics; - string safeAttribute(TiXmlElement* element, string attribute); void RenderElement(StoryDialogElement * elmt); public: StoryDialog(TiXmlElement* el,StoryFlow * mParent); @@ -115,6 +121,7 @@ class StoryDuel:public StoryPage { public: string pageId; string onWin, onLose; + string bg; //background file GameObserver * game; Rules * rules; StoryDuel(TiXmlElement* el,StoryFlow * mParent); diff --git a/projects/mtg/src/Credits.cpp b/projects/mtg/src/Credits.cpp index 92d82c588..2142424d7 100644 --- a/projects/mtg/src/Credits.cpp +++ b/projects/mtg/src/Credits.cpp @@ -8,6 +8,7 @@ #include "../include/MTGDeck.h" #include "../include/GameObserver.h" #include "../include/GameStateShop.h" +#include "../include/PlayerData.h" CreditBonus::CreditBonus(int _value, string _text){ value = _value; @@ -289,6 +290,37 @@ int Credits::addCreditBonus(int value){ SAFE_DELETE(playerdata); return value; } +/* + * adds a Card to a deck + * @param cardId id of the card + * @param collection deck representing player's collection +*/ +int Credits::addCardToCollection(int cardId, MTGDeck * collection) { + return collection->add(cardId); +} + +/* + * adds a Card to player's collection + * prefer to call the above function if you want to add several cards, since saving is expensive + */ +int Credits::addCardToCollection(int cardId) { + MTGAllCards * ac = GameApp::collection; + PlayerData * playerdata = NEW PlayerData(ac); + int result = addCardToCollection(cardId, playerdata->collection); + playerdata->collection->save(); + return result; +} + +int Credits::unlockSetByName(string name){ + int setId = setlist.findSet(name); + if (setId < 0) return 0; + + GameOptionAward* goa = (GameOptionAward*) &options[Options::optionSet(setId)]; + goa->giveAward(); + options.save(); + return setId + 1; //We add 1 here to show success/failure. Be sure to subtract later. + +} int Credits::unlockRandomSet(bool force){ int setId = WRand() % setlist.size(); diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index 6d04587ca..a39ca3789 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -254,7 +254,8 @@ void GameApp::Destroy() SAFE_DELETE(Subtypes::subtypesList); SAFE_DELETE(DeckMetaDataList::decksMetaData); - SAFE_DELETE(music); + playMusic("none"); + Translator::EndInstance(); WCFilterFactory::Destroy(); SimpleMenu::destroy(); @@ -426,3 +427,15 @@ void GameApp::DoTransition(int trans, int tostate, float dur, bool animonly){ void GameApp::DoAnimation(int trans, float dur){ DoTransition(trans,GAME_STATE_NONE,dur,true); } + +void GameApp::playMusic(string filename, bool loop) { + if (music) { + JSoundSystem::GetInstance()->StopMusic(music); + SAFE_DELETE(music); + } + + if (HasMusic && options[Options::MUSICVOLUME].number > 0){ + music = resources.ssLoadMusic(filename.c_str()); + if (music) JSoundSystem::GetInstance()->PlayMusic(music, loop); + } +} \ No newline at end of file diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 540b16492..c64223979 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -46,6 +46,7 @@ GameObserver::GameObserver(Player * _players[], int _nb_players){ phaseRing = NULL; replacementEffects = NEW ReplacementEffects(); combatStep = BLOCKERS; + mRules = NULL; } int GameObserver::getCurrentGamePhase(){ @@ -187,6 +188,7 @@ int GameObserver::forceShuffleLibraries(){ void GameObserver::startGame(Rules * rules){ turn = 0; + mRules = rules; if (rules) rules->initPlayers(); @@ -200,6 +202,7 @@ void GameObserver::startGame(Rules * rules){ if (rules) rules->initGame(); + //Preload images from hand if (!players[0]->isAI()){ diff --git a/projects/mtg/src/GameStateDeckViewer.cpp b/projects/mtg/src/GameStateDeckViewer.cpp index 8c27d57ae..d78e800e9 100644 --- a/projects/mtg/src/GameStateDeckViewer.cpp +++ b/projects/mtg/src/GameStateDeckViewer.cpp @@ -168,16 +168,7 @@ void GameStateDeckViewer::Start() //init welcome menu updateDecks(); - if (GameApp::HasMusic && options[Options::MUSICVOLUME].number > 0){ - if (GameApp::music){ - JSoundSystem::GetInstance()->StopMusic(GameApp::music); - SAFE_DELETE(GameApp::music); - } - GameApp::music = resources.ssLoadMusic("track1.mp3"); - if (GameApp::music){ - JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true); - } - } + GameApp::playMusic("track1.mp3"); loadIndexes(); mEngine->ResetInput(); @@ -188,10 +179,7 @@ void GameStateDeckViewer::Start() void GameStateDeckViewer::End() { JRenderer::GetInstance()->EnableVSync(false); - if (GameApp::music){ - JSoundSystem::GetInstance()->StopMusic(GameApp::music); - SAFE_DELETE(GameApp::music); - } + SAFE_DELETE(welcome_menu); SAFE_DELETE(menu); SAFE_DELETE(subMenu); diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index b7274314c..3a61231f9 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -173,11 +173,7 @@ void GameStateDuel::End() OutputDebugString("Ending GamestateDuel\n"); #endif SAFE_DELETE(deckmenu); - //stop game music - if (GameApp::music){ - JSoundSystem::GetInstance()->StopMusic(GameApp::music); - SAFE_DELETE(GameApp::music); - } + JRenderer::GetInstance()->EnableVSync(false); if (mPlayers[0] && mPlayers[1]) mPlayers[0]->End(); GameObserver::EndInstance(); @@ -304,13 +300,8 @@ void GameStateDuel::Update(float dt) if (mParent->gameType == GAME_TYPE_MOMIR){ game->addObserver(NEW MTGMomirRule(-1, mParent->collection)); } - //stop menu music - if (GameApp::music){ - JSoundSystem::GetInstance()->StopMusic(GameApp::music); - SAFE_DELETE(GameApp::music); - } + //start of in game music code - if (GameApp::HasMusic && options[Options::MUSICVOLUME].number > 0){ musictrack = ""; //check opponent id and choose the music track based on it if(OpponentsDeckid) { @@ -328,12 +319,7 @@ void GameStateDuel::Update(float dt) if(!MusicExist(musictrack)) musictrack = "ai_baka_music.mp3"; - if (MusicExist(musictrack)){ - GameApp::music = resources.ssLoadMusic(musictrack.c_str()); - JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true); - } - } - //end of music code + GameApp::playMusic(musictrack); } game->Update(dt); if (game->gameOver){ diff --git a/projects/mtg/src/GameStateMenu.cpp b/projects/mtg/src/GameStateMenu.cpp index 28109dd0e..fa9e726cf 100644 --- a/projects/mtg/src/GameStateMenu.cpp +++ b/projects/mtg/src/GameStateMenu.cpp @@ -135,15 +135,7 @@ void GameStateMenu::Start(){ subMenuController = NULL; SAFE_DELETE(mGuiController); - if (GameApp::HasMusic && !GameApp::music && options[Options::MUSICVOLUME].number > 0){ - GameApp::music = resources.ssLoadMusic("Track0.mp3"); - JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true); - } - - if (GameApp::HasMusic && GameApp::music && options[Options::MUSICVOLUME].number == 0){ - JSoundSystem::GetInstance()->StopMusic(GameApp::music); - SAFE_DELETE(GameApp::music); - } + GameApp::playMusic("Track0.mp3"); hasChosenGameType = 0; mParent->gameType = GAME_TYPE_CLASSIC; diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index 52392daf2..27cb6b6ba 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -53,6 +53,7 @@ GameStateShop::GameStateShop(GameApp* parent): GameState(parent) { GameStateShop::~GameStateShop() { End(); + } void GameStateShop::Create(){ @@ -74,7 +75,7 @@ void GameStateShop::Start(){ bigSync = 0; shopMenu = NEW WGuiMenu(JGE_BTN_DOWN, JGE_BTN_UP, true, &bigSync); MTGAllCards * ac = GameApp::collection; - playerdata = NEW PlayerData(ac);; + playerdata = NEW PlayerData(ac); myCollection = NEW DeckDataWrapper(playerdata->collection); pricelist = NEW PriceList(RESPATH"/settings/prices.dat",ac); for(int i=0;iRenderQuad(resources.RetrieveTempQuad("backdrop.jpg"), 0, 18); + JQuad * quad = NULL; + GameObserver * go = GameObserver::GetInstance(); + if (go && go->mRules && go->mRules->bg.size()) { + quad = resources.RetrieveTempQuad(go->mRules->bg); + } + if (!quad) { + quad = resources.RetrieveTempQuad("backdrop.jpg"); + } + if (!quad) return; + renderer->RenderQuad(quad, 0, 18); } diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index d9bfa1c82..5d8ab7fcc 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -426,6 +426,12 @@ MTGCard * MTGAllCards::_(int index){ MTGCard * MTGAllCards::getCardByName(string name){ if (!name.size()) return NULL; if (name[0] == '#') return NULL; + + int cardnb = atoi(name.c_str()); + if (cardnb){ + return getCardById(cardnb); + } + std::transform(name.begin(), name.end(), name.begin(),::tolower ); int setId = -1; size_t found = name.find(" ("); diff --git a/projects/mtg/src/Rules.cpp b/projects/mtg/src/Rules.cpp index 10886f73b..804e7a8e7 100644 --- a/projects/mtg/src/Rules.cpp +++ b/projects/mtg/src/Rules.cpp @@ -330,9 +330,9 @@ void Rules::cleanup(){ initState.cleanup(); } -Rules::Rules(string filename){ +Rules::Rules(string filename, string _bg){ + bg = _bg; load(filename); - } int Rules::load(string _filename){ diff --git a/projects/mtg/src/StoryFlow.cpp b/projects/mtg/src/StoryFlow.cpp index 7c995adc0..931c6aa1f 100644 --- a/projects/mtg/src/StoryFlow.cpp +++ b/projects/mtg/src/StoryFlow.cpp @@ -6,6 +6,7 @@ #include "../include/Rules.h" #include "../include/Credits.h" #include "../include/PlayerData.h" +#include "../include/MTGDeck.h" #include #include #include @@ -18,6 +19,7 @@ float StoryDialog::currentY = 2; float StoryDialog::previousY = 2; bool StoryReward::rewardSoundPlayed = false; bool StoryReward::rewardsEnabled = true; +MTGDeck * StoryReward::collection = NULL; StoryDialogElement::StoryDialogElement(float x, float y, int id): JGuiObject(id), mX(x),mY(y) { } @@ -58,6 +60,8 @@ float StoryText::getHeight() { type = STORY_REWARD_CREDITS; if (_type.compare("unlockset") == 0) { type = STORY_REWARD_SET; + } else if (_type.compare("card") == 0) { + type = STORY_REWARD_CARD; } value = _value; rewardDone = 0; @@ -82,7 +86,12 @@ void StoryReward::Update(float dt){ break; case STORY_REWARD_SET: { - result = Credits::unlockRandomSet(true); + if (value.size()) { + result = Credits::unlockSetByName(value); + } else { + result = Credits::unlockRandomSet(true); + } + if (!result) break; MTGSetInfo * si = setlist.getInfo(result - 1); if(si) { string unlockedString = si->getName(); @@ -93,6 +102,33 @@ void StoryReward::Update(float dt){ } break; } + case STORY_REWARD_CARD: + { + int cardId = 0; + MTGCard * card = NULL; + if (value.size()) { + card = GameApp::collection->getCardByName(value); + if (card) { + cardId = card->getId(); + } + } else { + cardId = GameApp::collection->randomCardId(); + card = GameApp::collection->getCardById(cardId); + } + + if (!cardId) break; + + if (!collection) { + collection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), GameApp::collection); + } + + result = Credits::addCardToCollection(cardId, collection); + size_t pos = text.find("${CARD}"); + if (pos != string::npos && card) { + text.replace(pos,pos + 7,card->data->getName()); + } + break; + } default: break; } @@ -228,7 +264,7 @@ StoryChoice::StoryChoice(string pageId, string text, int JGOid, float mX, float if(hasFocus) mTargetScale = 1.2f; } -//Actually loads "game" +//Actually loads a duel void StoryDuel::init(){ Player * players[2]; @@ -249,7 +285,7 @@ void StoryDuel::init(){ string rulesFile = folder; rulesFile.append("/rules.txt"); - rules = NEW Rules(rulesFile); + rules = NEW Rules(rulesFile, bg); GameObserver::Init(players, 2); game = GameObserver::GetInstance(); @@ -263,15 +299,18 @@ StoryDuel::StoryDuel(TiXmlElement* root,StoryFlow * mParent): StoryPage(mParent) for (TiXmlNode* node = root->FirstChild(); node; node = node->NextSibling()) { TiXmlElement* element = node->ToElement(); if (element) { - if (strcmp(element->Value(), "onwin")==0) { - const char* textC = element->GetText(); + const char* textC = element->GetText(); + if (strcmp(element->Value(), "onwin")==0) { onWin = textC; } else if (strcmp(element->Value(), "onlose")==0) { - const char* textC = element->GetText(); onLose = textC; - }else { - //Error + } else if (strcmp(element->Value(), "bg")==0) { + string text = textC; + bg = string("campaigns/").append(mParent->folder).append("/").append(text); + if (!fileExists(bg.c_str())) bg = text; + } else { + StoryPage::loadElement(element); //Father } } } @@ -299,7 +338,7 @@ void StoryDuel::Render(){ game->Render(); } -string StoryDialog::safeAttribute(TiXmlElement* element, string attribute) { +string StoryPage::safeAttribute(TiXmlElement* element, string attribute) { string s; if (element->Attribute(attribute.c_str())){ s = element->Attribute(attribute.c_str()); @@ -307,6 +346,18 @@ string StoryDialog::safeAttribute(TiXmlElement* element, string attribute) { return s; } +int StoryPage::loadElement(TiXmlElement* element) { + if (!element) return 0; + const char* textC = element->GetText(); + string text = textC; + if (strcmp(element->Value(), "music")==0) { + musicFile = string("campaigns/").append(mParent->folder).append("/").append(text); + if (!fileExists(musicFile.c_str())) + musicFile = text; + return 1; + } + return 0; +} StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent):StoryPage(mParent), JGuiListener(), JGuiController(1,NULL) { @@ -357,7 +408,7 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent):StoryPage(mPar string value = safeAttribute(element,"value"); graphics.push_back(NEW StoryReward(type, value, text,x,y,align, font)); }else { - //Error + StoryPage::loadElement(element); //Father } } } @@ -370,6 +421,11 @@ void StoryDialog::Update(float dt){ graphics[i]->Update(dt); } + if (StoryReward::collection) { + StoryReward::collection->save(); + SAFE_DELETE(StoryReward::collection); + } + JButton key = mEngine->ReadButton(); CheckUserInput(key); @@ -441,6 +497,9 @@ bool StoryFlow::_gotoPage(string id){ return false; } currentPageId = id; + if (pages[currentPageId]->musicFile.size()) { + GameApp::playMusic(pages[currentPageId]->musicFile); + } return true; } @@ -476,9 +535,15 @@ bool StoryFlow::parse(string path) if (element != NULL) { if (strcmp(element->Value(), "page")==0) { string id = element->Attribute("id"); + + OutputDebugString("\nparsing "); + OutputDebugString(id.c_str()); + OutputDebugString("...\n"); + StoryPage * sp = loadPage(element); pages[id] = sp; if (!currentPageId.size()) gotoPage(id); + OutputDebugString("OK\n"); } else { //Error diff --git a/projects/mtg/src/WResourceManager.cpp b/projects/mtg/src/WResourceManager.cpp index 61a173c6d..3b3b01e78 100644 --- a/projects/mtg/src/WResourceManager.cpp +++ b/projects/mtg/src/WResourceManager.cpp @@ -700,9 +700,15 @@ string WResourceManager::musicFile(const string filename){ sprintf(defdir,"sound/%s",filename.c_str()); if(fileOK(defdir,true)) return defdir; - + + //Failure. Check raw faile. + sprintf(defdir,"%s",filename.c_str()); + if(fileOK(defdir,true)) + return defdir; + + //Complete abject failure. Probably a crash... - return defdir; + return ""; } string WResourceManager::sfxFile(const string filename){ @@ -826,7 +832,9 @@ void WResourceManager::autoResize(){ } JMusic * WResourceManager::ssLoadMusic(const char *fileName){ - return JSoundSystem::GetInstance()->LoadMusic(musicFile(fileName).c_str()); + string file = musicFile(fileName); + if (!file.size()) return NULL; + return JSoundSystem::GetInstance()->LoadMusic(file.c_str()); }