From 6fdd71cb9e4f7cc8c3f11ebe1dcec7299d2c8495 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 15 Oct 2012 20:39:54 +0000 Subject: [PATCH] - bugfix for lua usage of system generated cell flashing --- source/glest_game/game/game.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 81dbdc44..8860e9a7 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -1855,7 +1855,9 @@ void Game::updateNetworkHighligtedCells() { std::vector highlighList = gameNetworkInterface->getHighlightedCellList(true); for(int idx = 0; idx < highlighList.size(); idx++) { MarkedCell mc = highlighList[idx]; // I want a copy here - mc.setFaction((const Faction *)world.getFaction(mc.getFactionIndex())); // set faction pointer + if(mc.getFactionIndex() >= 0) { + mc.setFaction((const Faction *)world.getFaction(mc.getFactionIndex())); // set faction pointer + } addOrReplaceInHighlightedCells(mc); } } @@ -1883,7 +1885,14 @@ void Game::addOrReplaceInHighlightedCells(MarkedCell mc){ highlightedCells.push_back(mc); CoreData &coreData= CoreData::getInstance(); SoundRenderer &soundRenderer= SoundRenderer::getInstance(); - if(mc.getFaction() == NULL || (mc.getFaction()->getTeam() == getWorld()->getThisFaction()->getTeam())) { + + const Faction *faction = mc.getFaction(); + if(getWorld()->getThisFaction() == NULL) { + throw megaglest_runtime_error("getWorld()->getThisFaction() == NULL"); + } + //printf("faction [%p][%s]\n",faction,(faction != NULL ? faction->getType()->getName().c_str() : "")); + if((faction == NULL) || + (faction->getTeam() == getWorld()->getThisFaction()->getTeam())) { soundRenderer.playFx(coreData.getMarkerSound()); } }