[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: crimson-0.4.0pre2 (was: Re: 0.4.0 Testing)



On 04.02.2004 12:19, Chang wrote:
> Hi,
> 
> I have installed it and played it, but I have met a crash, 
> not systemically, which occured and gave me the following line 
> "Fatal signal: Segmentation Fault (SDL Parachute Deployed)"
> what I can remember is that I was clicking fast on "OK" going through
> the battle results in a hot seat mode (yeah, I played both side).

This is really getting embarrassing...

Fix attached.

Jens
Index: src/cf/game.cpp
===================================================================
RCS file: /home/cvspsrv/cvsroot/games/crimson/src/cf/game.cpp,v
retrieving revision 1.14
diff -u -r1.14 game.cpp
--- src/cf/game.cpp	3 Feb 2004 17:55:25 -0000	1.14
+++ src/cf/game.cpp	4 Feb 2004 17:53:30 -0000
@@ -670,6 +670,10 @@
 ////////////////////////////////////////////////////////////////////////
 
 void Game::ResolveBattle( Combat *com ) {
+  Unit *att = com->GetAttacker();
+  Unit *def = com->GetDefender();
+  if ( !att->IsAlive() || !def->IsAlive() ) return;
+
   // calculate modifiers for combat
   Map &map = mission->GetMap();
   History *hist = mission->GetHistory();
@@ -678,16 +682,15 @@
   if ( mission->GetPlayer().Type() == HUMAN )
     cwin = new CombatWindow( com, mwin, view );
 
+  Point apos( att->Position() ), dpos( def->Position() );
   Point hits( com->CalcResults() );
-  Unit *u = com->GetAttacker();
 
   // record as a combat event
-  if ( hist && !u->IsDummy() )
-    hist->RecordCombatEvent( *com, hits.x, hits.y );
+  if ( hist && !att->IsDummy() )
+    hist->RecordCombatEvent( *com, hits.y, hits.x );
 
-  if ( !u->IsAlive() ) map.SetUnit( 0, u->Position() );
-  u = com->GetDefender();
-  if ( !u->IsAlive() ) map.SetUnit( 0, u->Position() );
+  if ( !att->IsAlive() ) map.SetUnit( 0, apos );
+  if ( !def->IsAlive() ) map.SetUnit( 0, dpos );
 
   if ( cwin ) {
     cwin->Draw();