From f619b0b8e18d0e0de3c6dcd4fb229f7590d8c3c3 Mon Sep 17 00:00:00 2001 From: avolkov Date: Thu, 8 Oct 2009 00:07:52 +0000 Subject: [PATCH] Ensure that lander explosion element gets allocated; bug #584 git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3192 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 2 ++ sc2/src/sc2code/planets/lander.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index e46fb2abf..854ba8616 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Lander will no longer hang when killed on planets with a lot of + natural disasters (bug #584) - Alex - Canceling load from the main menu returns to main menu (bug #679) - Alex - Fixed inputting numbers with the numpad, except directx (bug #934) - Alex - Better location description in savegame summaries (bug #844) - Alex diff --git a/sc2/src/sc2code/planets/lander.c b/sc2/src/sc2code/planets/lander.c index e5e7d248b..888367ab6 100644 --- a/sc2/src/sc2code/planets/lander.c +++ b/sc2/src/sc2code/planets/lander.c @@ -31,6 +31,7 @@ #include "element.h" #include "libs/graphics/gfx_common.h" #include "libs/mathlib.h" +#include "libs/log.h" //define SPIN_ON_LAUNCH to let the planet spin while @@ -1660,12 +1661,14 @@ SetVelocityComponents ( { HELEMENT hExplosionElement; - ++pMS->CurState; hExplosionElement = AllocElement (); if (hExplosionElement) { ELEMENT *ExplosionElementPtr; + // Advance the state only once we've got the element + ++pMS->CurState; + LockElement (hExplosionElement, &ExplosionElementPtr); ExplosionElementPtr->mass_points = DEATH_EXPLOSION; @@ -1692,6 +1695,12 @@ SetVelocityComponents ( LanderSounds, LANDER_DESTROYED ), NotPositional (), NULL, GAME_SOUND_PRIORITY + 1); } + else + { // We could not allocate because the queue was full, but + // we will get another chance on the next iteration + log_add (log_Warning, "DoPlanetSide(): could not" + " allocate explosion element!"); + } } ScrollPlanetSide (0, 0, -1);