do not crash and exit game when core data textures are not found

This commit is contained in:
Mark Vejvoda 2013-11-06 02:02:00 +00:00
parent 70421d1b3d
commit eb6466889f
4 changed files with 238 additions and 63 deletions

View File

@ -35,6 +35,7 @@ namespace Glest{ namespace Game{
// class CoreData // class CoreData
// ===================================================== // =====================================================
static string tempDataLocation = getUserHome();
// ===================== PUBLIC ======================== // ===================== PUBLIC ========================
CoreData &CoreData::getInstance() { CoreData &CoreData::getInstance() {
@ -172,6 +173,13 @@ Texture2D *CoreData::getTextureBySystemId(TextureSystemType type) const {
return result; return result;
} }
void CoreData::cleanupTexture(Texture2D **texture) {
Renderer &renderer= Renderer::getInstance();
renderer.endTexture(rsGlobal, *texture);
*texture=NULL;
}
void CoreData::load() { void CoreData::load() {
string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
if(data_path != "") { if(data_path != "") {
@ -187,24 +195,42 @@ void CoreData::load() {
backgroundTexture= renderer.newTexture2D(rsGlobal); backgroundTexture= renderer.newTexture2D(rsGlobal);
if(backgroundTexture) { if(backgroundTexture) {
backgroundTexture->setMipmap(false); backgroundTexture->setMipmap(false);
backgroundTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/back.tga")); try {
backgroundTexture->setTextureSystemId(tsyst_backgroundTexture); backgroundTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/back.tga"));
backgroundTexture->setTextureSystemId(tsyst_backgroundTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&backgroundTexture);
}
} }
fireTexture= renderer.newTexture2D(rsGlobal); fireTexture= renderer.newTexture2D(rsGlobal);
if(fireTexture) { if(fireTexture) {
fireTexture->setFormat(Texture::fAlpha); fireTexture->setFormat(Texture::fAlpha);
fireTexture->getPixmap()->init(1); fireTexture->getPixmap()->init(1);
fireTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/fire_particle.tga")); try {
fireTexture->setTextureSystemId(tsyst_fireTexture); fireTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/fire_particle.tga"));
fireTexture->setTextureSystemId(tsyst_fireTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&fireTexture);
}
} }
teamColorTexture= renderer.newTexture2D(rsGlobal); teamColorTexture= renderer.newTexture2D(rsGlobal);
if(teamColorTexture) { if(teamColorTexture) {
teamColorTexture->setFormat(Texture::fAlpha); teamColorTexture->setFormat(Texture::fAlpha);
teamColorTexture->getPixmap()->init(1); teamColorTexture->getPixmap()->init(1);
teamColorTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/team_color_texture.tga")); try {
teamColorTexture->setTextureSystemId(tsyst_teamColorTexture); teamColorTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/team_color_texture.tga"));
teamColorTexture->setTextureSystemId(tsyst_teamColorTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&fireTexture);
}
} }
snowTexture= renderer.newTexture2D(rsGlobal); snowTexture= renderer.newTexture2D(rsGlobal);
@ -212,59 +238,120 @@ void CoreData::load() {
snowTexture->setMipmap(false); snowTexture->setMipmap(false);
snowTexture->setFormat(Texture::fAlpha); snowTexture->setFormat(Texture::fAlpha);
snowTexture->getPixmap()->init(1); snowTexture->getPixmap()->init(1);
snowTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/snow_particle.tga")); try {
snowTexture->setTextureSystemId(tsyst_snowTexture); snowTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/snow_particle.tga"));
snowTexture->setTextureSystemId(tsyst_snowTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&snowTexture);
}
} }
statusReadyTexture= renderer.newTexture2D(rsGlobal); statusReadyTexture= renderer.newTexture2D(rsGlobal);
if(statusReadyTexture) { if(statusReadyTexture) {
statusReadyTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/status_ready.png")); try {
statusReadyTexture->setTextureSystemId(tsyst_statusReadyTexture); statusReadyTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/status_ready.png"));
statusReadyTexture->setTextureSystemId(tsyst_statusReadyTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&statusReadyTexture);
}
} }
statusNotReadyTexture= renderer.newTexture2D(rsGlobal); statusNotReadyTexture= renderer.newTexture2D(rsGlobal);
if(statusNotReadyTexture) { if(statusNotReadyTexture) {
statusNotReadyTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/status_notready.png")); try {
statusNotReadyTexture->setTextureSystemId(tsyst_statusNotReadyTexture); statusNotReadyTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/status_notready.png"));
statusNotReadyTexture->setTextureSystemId(tsyst_statusNotReadyTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&statusNotReadyTexture);
}
} }
statusBRBTexture= renderer.newTexture2D(rsGlobal); statusBRBTexture= renderer.newTexture2D(rsGlobal);
if(statusBRBTexture) { if(statusBRBTexture) {
statusBRBTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/status_brb.png")); try {
statusBRBTexture->setTextureSystemId(tsyst_statusBRBTexture); statusBRBTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/status_brb.png"));
statusBRBTexture->setTextureSystemId(tsyst_statusBRBTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&statusBRBTexture);
}
} }
customTexture= renderer.newTexture2D(rsGlobal); customTexture= renderer.newTexture2D(rsGlobal);
if(customTexture) { if(customTexture) {
customTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/custom_texture.tga")); try {
customTexture->setTextureSystemId(tsyst_customTexture); customTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/custom_texture.tga"));
customTexture->setTextureSystemId(tsyst_customTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&customTexture);
}
} }
notOnServerTexture= renderer.newTexture2D(rsGlobal); notOnServerTexture= renderer.newTexture2D(rsGlobal);
if(notOnServerTexture) { if(notOnServerTexture) {
notOnServerTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/not_on_server.tga")); try {
notOnServerTexture->setTextureSystemId(tsyst_notOnServerTexture); notOnServerTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/not_on_server.tga"));
notOnServerTexture->setTextureSystemId(tsyst_notOnServerTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&notOnServerTexture);
}
} }
onServerDifferentTexture= renderer.newTexture2D(rsGlobal); onServerDifferentTexture= renderer.newTexture2D(rsGlobal);
if(onServerDifferentTexture) { if(onServerDifferentTexture) {
onServerDifferentTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/on_server_different.tga")); try {
onServerDifferentTexture->setTextureSystemId(tsyst_onServerDifferentTexture); onServerDifferentTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/on_server_different.tga"));
onServerDifferentTexture->setTextureSystemId(tsyst_onServerDifferentTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&onServerDifferentTexture);
}
onServerTexture= renderer.newTexture2D(rsGlobal); onServerTexture= renderer.newTexture2D(rsGlobal);
onServerTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/on_server.tga")); try {
onServerTexture->setTextureSystemId(tsyst_onServerTexture); onServerTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/on_server.tga"));
onServerTexture->setTextureSystemId(tsyst_onServerTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&onServerTexture);
}
onServerInstalledTexture= renderer.newTexture2D(rsGlobal); onServerInstalledTexture= renderer.newTexture2D(rsGlobal);
onServerInstalledTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/on_server_installed.tga"));
onServerInstalledTexture->setTextureSystemId(tsyst_onServerInstalledTexture); try {
onServerInstalledTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/on_server_installed.tga"));
onServerInstalledTexture->setTextureSystemId(tsyst_onServerInstalledTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&onServerInstalledTexture);
}
} }
logoTexture= renderer.newTexture2D(rsGlobal); logoTexture= renderer.newTexture2D(rsGlobal);
if(logoTexture) { if(logoTexture) {
logoTexture->setMipmap(false); logoTexture->setMipmap(false);
logoTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/logo.tga")); try {
logoTexture->setTextureSystemId(tsyst_logoTexture); logoTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/logo.tga"));
logoTexture->setTextureSystemId(tsyst_logoTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&logoTexture);
}
} }
logoTextureList.clear(); logoTextureList.clear();
@ -279,8 +366,14 @@ void CoreData::load() {
Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal); Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal);
if(logoTextureExtra) { if(logoTextureExtra) {
logoTextureExtra->setMipmap(true); logoTextureExtra->setMipmap(true);
logoTextureExtra->getPixmap()->load(getGameCustomCoreDataPath(data_path, "") + "data/core/menu/textures/" + logo); try {
logoTextureList.push_back(logoTextureExtra); logoTextureExtra->getPixmap()->load(getGameCustomCoreDataPath(data_path, "") + "data/core/menu/textures/" + logo);
logoTextureList.push_back(logoTextureExtra);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&logoTextureExtra);
}
} }
} }
} }
@ -295,8 +388,14 @@ void CoreData::load() {
Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal); Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal);
if(logoTextureExtra) { if(logoTextureExtra) {
logoTextureExtra->setMipmap(true); logoTextureExtra->setMipmap(true);
logoTextureExtra->getPixmap()->load(data_path + "data/core/menu/textures/" + logo); try {
logoTextureList.push_back(logoTextureExtra); logoTextureExtra->getPixmap()->load(data_path + "data/core/menu/textures/" + logo);
logoTextureList.push_back(logoTextureExtra);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&logoTextureExtra);
}
} }
} }
} }
@ -313,8 +412,14 @@ void CoreData::load() {
Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal); Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal);
if(logoTextureExtra) { if(logoTextureExtra) {
logoTextureExtra->setMipmap(true); logoTextureExtra->setMipmap(true);
logoTextureExtra->getPixmap()->load(getGameCustomCoreDataPath(data_path, "") + "data/core/menu/textures/" + logo); try {
miscTextureList.push_back(logoTextureExtra); logoTextureExtra->getPixmap()->load(getGameCustomCoreDataPath(data_path, "") + "data/core/menu/textures/" + logo);
miscTextureList.push_back(logoTextureExtra);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&logoTextureExtra);
}
} }
//} //}
} }
@ -328,8 +433,14 @@ void CoreData::load() {
Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal); Texture2D *logoTextureExtra= renderer.newTexture2D(rsGlobal);
if(logoTextureExtra) { if(logoTextureExtra) {
logoTextureExtra->setMipmap(true); logoTextureExtra->setMipmap(true);
logoTextureExtra->getPixmap()->load(data_path + "data/core/menu/textures/" + logo); try {
miscTextureList.push_back(logoTextureExtra); logoTextureExtra->getPixmap()->load(data_path + "data/core/menu/textures/" + logo);
miscTextureList.push_back(logoTextureExtra);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&logoTextureExtra);
}
} }
//} //}
} }
@ -339,68 +450,121 @@ void CoreData::load() {
if(waterSplashTexture) { if(waterSplashTexture) {
waterSplashTexture->setFormat(Texture::fAlpha); waterSplashTexture->setFormat(Texture::fAlpha);
waterSplashTexture->getPixmap()->init(1); waterSplashTexture->getPixmap()->init(1);
waterSplashTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/water_splash.tga")); try {
waterSplashTexture->setTextureSystemId(tsyst_waterSplashTexture); waterSplashTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/water_splash.tga"));
waterSplashTexture->setTextureSystemId(tsyst_waterSplashTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&waterSplashTexture);
}
} }
buttonSmallTexture= renderer.newTexture2D(rsGlobal); buttonSmallTexture= renderer.newTexture2D(rsGlobal);
if(buttonSmallTexture) { if(buttonSmallTexture) {
buttonSmallTexture->setForceCompressionDisabled(true); buttonSmallTexture->setForceCompressionDisabled(true);
buttonSmallTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/button_small.tga")); try {
buttonSmallTexture->setTextureSystemId(tsyst_buttonSmallTexture); buttonSmallTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/button_small.tga"));
buttonSmallTexture->setTextureSystemId(tsyst_buttonSmallTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&buttonSmallTexture);
}
} }
buttonBigTexture= renderer.newTexture2D(rsGlobal); buttonBigTexture= renderer.newTexture2D(rsGlobal);
if(buttonBigTexture) { if(buttonBigTexture) {
buttonBigTexture->setForceCompressionDisabled(true); buttonBigTexture->setForceCompressionDisabled(true);
buttonBigTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/button_big.tga")); try {
buttonBigTexture->setTextureSystemId(tsyst_buttonBigTexture); buttonBigTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/button_big.tga"));
buttonBigTexture->setTextureSystemId(tsyst_buttonBigTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&buttonBigTexture);
}
} }
horizontalLineTexture= renderer.newTexture2D(rsGlobal); horizontalLineTexture= renderer.newTexture2D(rsGlobal);
if(horizontalLineTexture) { if(horizontalLineTexture) {
horizontalLineTexture->setForceCompressionDisabled(true); horizontalLineTexture->setForceCompressionDisabled(true);
horizontalLineTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/line_horizontal.tga")); try {
horizontalLineTexture->setTextureSystemId(tsyst_horizontalLineTexture); horizontalLineTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/line_horizontal.tga"));
horizontalLineTexture->setTextureSystemId(tsyst_horizontalLineTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&horizontalLineTexture);
}
} }
verticalLineTexture= renderer.newTexture2D(rsGlobal); verticalLineTexture= renderer.newTexture2D(rsGlobal);
if(verticalLineTexture) { if(verticalLineTexture) {
verticalLineTexture->setForceCompressionDisabled(true); verticalLineTexture->setForceCompressionDisabled(true);
verticalLineTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/line_vertical.tga")); try {
verticalLineTexture->setTextureSystemId(tsyst_verticalLineTexture); verticalLineTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/line_vertical.tga"));
verticalLineTexture->setTextureSystemId(tsyst_verticalLineTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&verticalLineTexture);
}
} }
checkBoxTexture= renderer.newTexture2D(rsGlobal); checkBoxTexture= renderer.newTexture2D(rsGlobal);
if(checkBoxTexture) { if(checkBoxTexture) {
checkBoxTexture->setForceCompressionDisabled(true); checkBoxTexture->setForceCompressionDisabled(true);
checkBoxTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/checkbox.tga")); try {
checkBoxTexture->setTextureSystemId(tsyst_checkBoxTexture); checkBoxTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/checkbox.tga"));
checkBoxTexture->setTextureSystemId(tsyst_checkBoxTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&checkBoxTexture);
}
} }
checkedCheckBoxTexture= renderer.newTexture2D(rsGlobal); checkedCheckBoxTexture= renderer.newTexture2D(rsGlobal);
if(checkedCheckBoxTexture) { if(checkedCheckBoxTexture) {
checkedCheckBoxTexture->setForceCompressionDisabled(true); checkedCheckBoxTexture->setForceCompressionDisabled(true);
checkedCheckBoxTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/checkbox_checked.tga")); try {
checkedCheckBoxTexture->setTextureSystemId(tsyst_checkedCheckBoxTexture); checkedCheckBoxTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/menu/textures/checkbox_checked.tga"));
checkedCheckBoxTexture->setTextureSystemId(tsyst_checkedCheckBoxTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&checkedCheckBoxTexture);
}
} }
gameWinnerTexture= renderer.newTexture2D(rsGlobal); gameWinnerTexture= renderer.newTexture2D(rsGlobal);
if(gameWinnerTexture) { if(gameWinnerTexture) {
gameWinnerTexture->setForceCompressionDisabled(true); gameWinnerTexture->setForceCompressionDisabled(true);
gameWinnerTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/game_winner.png")); try {
gameWinnerTexture->setTextureSystemId(tsyst_gameWinnerTexture); gameWinnerTexture->getPixmap()->load(getGameCustomCoreDataPath(data_path, "data/core/misc_textures/game_winner.png"));
gameWinnerTexture->setTextureSystemId(tsyst_gameWinnerTexture);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
cleanupTexture(&gameWinnerTexture);
}
} }
loadFonts(); loadFonts();
//sounds //sounds
clickSoundA.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_a.wav")); try {
clickSoundB.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_b.wav")); clickSoundA.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_a.wav"));
clickSoundC.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_c.wav")); clickSoundB.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_b.wav"));
attentionSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/attention.wav")); clickSoundC.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/click_c.wav"));
highlightSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/highlight.wav")); attentionSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/attention.wav"));
markerSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/sonar.wav")); highlightSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/highlight.wav"));
markerSound.load(getGameCustomCoreDataPath(data_path, "data/core/menu/sound/sonar.wav"));
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
}
XmlTree xmlTree; XmlTree xmlTree;
//string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); //string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
@ -422,10 +586,15 @@ void CoreData::load() {
const XmlNode *menuMusicNode= introNode->getChild("menu-music"); const XmlNode *menuMusicNode= introNode->getChild("menu-music");
menuMusicFile = menuMusicNode->getAttribute("value")->getRestrictedValue(); menuMusicFile = menuMusicNode->getAttribute("value")->getRestrictedValue();
} }
introMusic.open(getGameCustomCoreDataPath(data_path, "data/core/" + menuMusicPath + menuIntroMusicFile)); try {
introMusic.setNext(&menuMusic); introMusic.open(getGameCustomCoreDataPath(data_path, "data/core/" + menuMusicPath + menuIntroMusicFile));
menuMusic.open(getGameCustomCoreDataPath(data_path, "data/core/" + menuMusicPath + menuMusicFile)); introMusic.setNext(&menuMusic);
menuMusic.setNext(&menuMusic); menuMusic.open(getGameCustomCoreDataPath(data_path, "data/core/" + menuMusicPath + menuMusicFile));
menuMusic.setNext(&menuMusic);
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
}
cleanup(); cleanup();
waterSounds.resize(6); waterSounds.resize(6);
@ -433,7 +602,12 @@ void CoreData::load() {
for(int i=0; i<6; ++i){ for(int i=0; i<6; ++i){
waterSounds[i]= new StaticSound(); waterSounds[i]= new StaticSound();
if(waterSounds[i]) { if(waterSounds[i]) {
waterSounds[i]->load(getGameCustomCoreDataPath(data_path, "data/core/water_sounds/water"+intToStr(i)+".wav")); try {
waterSounds[i]->load(getGameCustomCoreDataPath(data_path, "data/core/water_sounds/water"+intToStr(i)+".wav"));
}
catch(const megaglest_runtime_error &ex) {
message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),tempDataLocation);
}
} }
} }

View File

@ -223,6 +223,7 @@ private:
CoreData(); CoreData();
int computeFontSize(int size); int computeFontSize(int size);
void cleanupTexture(Texture2D **texture);
}; };
}} //end namespace }} //end namespace

View File

@ -930,7 +930,7 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy) {
if(error != GL_NO_ERROR) { if(error != GL_NO_ERROR) {
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error)); const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[8096]=""; char szBuf[8096]="";
snprintf(szBuf,8096,"Error creating texture 2D [%s], returned: %d [%s] (%X) [%s] w = %d, h = %d, glInternalFormat = %d, glFormat = %d, glCompressionFormat = %d",this->path.c_str(),error,errorString,error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),glInternalFormat,glFormat,glCompressionFormat); snprintf(szBuf,8096,"Error creating texture 2D path [%s], returned: %d [%s] (%X) [%s] w = %d, h = %d, glInternalFormat = %d, glFormat = %d, glCompressionFormat = %d",this->path.c_str(),error,errorString,error,pixmap.getPath().c_str(),pixmap.getW(),pixmap.getH(),glInternalFormat,glFormat,glCompressionFormat);
throw megaglest_runtime_error(szBuf); throw megaglest_runtime_error(szBuf);
} }
} }

View File

@ -85,7 +85,7 @@ bool showMessage(std::string warning,string writepath) {
//command += " --title \"Error\" --msgbox \"`printf \"" + warning + "\"`\""; //command += " --title \"Error\" --msgbox \"`printf \"" + warning + "\"`\"";
command += " --title \"Error\" --text-info --filename=" + text_file; command += " --title \"Error\" --text-info --filename=" + text_file;
printf("\n\n\nzenity command [%s]\n\n\n",command.c_str()); //printf("\n\n\nzenity command [%s]\n\n\n",command.c_str());
FILE *fp = popen(command.c_str(),"r"); FILE *fp = popen(command.c_str(),"r");
if (fp != 0) if (fp != 0)