- fixed segfault when a unit is selected and they die (this is a long standing bug and not related to savegame)
This commit is contained in:
parent
80e1e45ba8
commit
76c3fa1949
|
@ -1675,6 +1675,17 @@ void Game::renderWorker() {
|
|||
|
||||
// ==================== tick ====================
|
||||
|
||||
void Game::removeUnitFromSelection(const Unit *unit) {
|
||||
Selection *selection= getGuiPtr()->getSelectionPtr();
|
||||
for(int i=0; i < selection->getCount(); ++i) {
|
||||
const Unit *currentUnit = selection->getUnit(i);
|
||||
if(currentUnit == unit) {
|
||||
selection->unSelect(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Game::tick() {
|
||||
ProgramState::tick();
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ public:
|
|||
const GameCamera *getGameCamera() const {return &gameCamera;}
|
||||
GameCamera *getGameCameraPtr() {return &gameCamera;}
|
||||
const Commander *getCommander() const {return &commander;}
|
||||
Gui *getGui() {return &gui;}
|
||||
Gui *getGuiPtr() {return &gui;}
|
||||
const Gui *getGui() const {return &gui;}
|
||||
Commander *getCommander() {return &commander;}
|
||||
Console *getConsole() {return &console;}
|
||||
|
@ -178,6 +178,8 @@ public:
|
|||
|
||||
Program *getProgram() {return program;}
|
||||
|
||||
void removeUnitFromSelection(const Unit *unit);
|
||||
|
||||
bool getPaused();
|
||||
void setPaused(bool value, bool forceAllowPauseStateChange=false);
|
||||
const int getTotalRenderFps() const {return totalRenderFps;}
|
||||
|
|
|
@ -164,6 +164,7 @@ public:
|
|||
const Mouse3d *getMouse3d() const {return &mouse3d;}
|
||||
const Display *getDisplay() const {return &display;}
|
||||
const Selection *getSelection() const {return &selection;}
|
||||
Selection *getSelectionPtr() {return &selection;}
|
||||
const Object *getSelectedResourceObject() const;
|
||||
Object *getHighlightedResourceObject() const;
|
||||
Unit *getHighlightedUnit() const;
|
||||
|
|
|
@ -552,6 +552,7 @@ Unit::~Unit() {
|
|||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.removeUnitFromQuadCache(this);
|
||||
game->removeUnitFromSelection(this);
|
||||
|
||||
//MutexSafeWrapper safeMutex1(&mutexDeletedUnits,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
//deletedUnits[this]=true;
|
||||
|
@ -2716,7 +2717,11 @@ bool Unit::morph(const MorphCommandType *mct){
|
|||
// ==================== PRIVATE ====================
|
||||
|
||||
float Unit::computeHeight(const Vec2i &pos) const{
|
||||
//printf("CRASHING FOR UNIT: %d alive = %d\n",this->getId(),this->isAlive());
|
||||
//printf("[%s]\n",this->getType()->getName().c_str());
|
||||
if(map->isInside(pos) == false || map->isInsideSurface(map->toSurfCoords(pos)) == false) {
|
||||
//printf("CRASHING FOR UNIT: %d [%s] alive = %d\n",this->getId(),this->getType()->getName().c_str(),this->isAlive());
|
||||
//abort();
|
||||
throw runtime_error("#7 Invalid path position = " + pos.getString());
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ UnitUpdater::UnitUpdater() {
|
|||
void UnitUpdater::init(Game *game){
|
||||
|
||||
this->game= game;
|
||||
this->gui= game->getGui();
|
||||
this->gui= game->getGuiPtr();
|
||||
this->gameCamera= game->getGameCamera();
|
||||
this->world= game->getWorld();
|
||||
this->map= world->getMap();
|
||||
|
|
Loading…
Reference in New Issue