All pastes #350206 Raw Edit

Untitled

public text v1 · immutable
·published 2007-02-11 08:47 UTC
rendered paste body
Team description.

I have 9 soldier,
The soldiers id 0 to 6 are hired in and in the aricraft
Soldier id 7 is unhired
Soldier id 8 is hired in and in the aricraft

I have a systematic crash at the end of the first mission.

E_GetHiredEmployee: i: 0 idx: -1, j -1
CL_UpdateCharacterStats()... chr: Stephanie Coustillac 
E_GetHiredEmployee: i: 0 idx: -2, j -1
E_GetHiredEmployee: i: 1 idx: -2, j -2
CL_UpdateCharacterStats()... chr: Magnus Lie 
E_GetHiredEmployee: i: 0 idx: -3, j -1
E_GetHiredEmployee: i: 1 idx: -3, j -2
E_GetHiredEmployee: i: 2 idx: -3, j -3
CL_UpdateCharacterStats()... chr: Gary Cruise 
E_GetHiredEmployee: i: 0 idx: -4, j -1
E_GetHiredEmployee: i: 1 idx: -4, j -2
E_GetHiredEmployee: i: 2 idx: -4, j -3
E_GetHiredEmployee: i: 3 idx: -4, j -4
CL_UpdateCharacterStats()... chr: Maria Martinez 
E_GetHiredEmployee: i: 0 idx: -5, j -1
E_GetHiredEmployee: i: 1 idx: -5, j -2
E_GetHiredEmployee: i: 2 idx: -5, j -3
E_GetHiredEmployee: i: 3 idx: -5, j -4
E_GetHiredEmployee: i: 4 idx: -5, j -5
CL_UpdateCharacterStats()... chr: Kjell Sorenson 
E_GetHiredEmployee: i: 0 idx: -6, j -1
E_GetHiredEmployee: i: 1 idx: -6, j -2
E_GetHiredEmployee: i: 2 idx: -6, j -3
E_GetHiredEmployee: i: 3 idx: -6, j -4
E_GetHiredEmployee: i: 4 idx: -6, j -5
E_GetHiredEmployee: i: 5 idx: -6, j -6
CL_UpdateCharacterStats()... chr: Matsuko Hashimoto 
E_GetHiredEmployee: i: 0 idx: -7, j -1
E_GetHiredEmployee: i: 1 idx: -7, j -2
E_GetHiredEmployee: i: 2 idx: -7, j -3
E_GetHiredEmployee: i: 3 idx: -7, j -4
E_GetHiredEmployee: i: 4 idx: -7, j -5
E_GetHiredEmployee: i: 5 idx: -7, j -6
E_GetHiredEmployee: i: 6 idx: -7, j -7
CL_UpdateCharacterStats()... chr: Candice Quinn 
E_GetHiredEmployee: i: 0 idx: -9, j -1
E_GetHiredEmployee: i: 1 idx: -9, j -2
E_GetHiredEmployee: i: 2 idx: -9, j -3
E_GetHiredEmployee: i: 3 idx: -9, j -4
E_GetHiredEmployee: i: 4 idx: -9, j -5
E_GetHiredEmployee: i: 5 idx: -9, j -6
E_GetHiredEmployee: i: 6 idx: -9, j -7
E_GetHiredEmployee: i: 8 idx: -9, j -8
ufo: src/client/cl_campaign.c:2710: CL_UpdateCharacterStats:  l'assertion << chr >> a ?chou?.

Program received signal SIGABRT, Aborted.
[Switching to Thread -1208908064 (LWP 6904)]
0x00464402 in __kernel_vsyscall ()


The problem is because j is not decremented for the unhired soldier number 7. So it will never had idx==j

Patch i have made

--- cl_employee.cSAV    2007-02-11 00:34:14.000000000 +0100
+++ cl_employee.c       2007-02-11 02:09:00.000000000 +0100
@@ -372,12 +372,16 @@
                        if (i == idx)
                                return employee;
                        if (idx < 0) {
+                               Com_Printf("E_GetHiredEmployee: i: %i idx: %i, j %i\n",i,idx,j);
                                if (idx == j)
                                        return employee;
                                j--;
                        }
-               } else
+               } else {
+                       if (idx != j)
+                               j--;
                        continue;
+               }
        }
        return NULL;
 }


PS : The Com_Printf is just for debug.


E_GetHiredEmployee: i: 0 idx: -1, j -1
CL_UpdateCharacterStats()... chr: Stephanie Coustillac 
E_GetHiredEmployee: i: 0 idx: -2, j -1
E_GetHiredEmployee: i: 1 idx: -2, j -2
CL_UpdateCharacterStats()... chr: Magnus Lie 
E_GetHiredEmployee: i: 0 idx: -3, j -1
E_GetHiredEmployee: i: 1 idx: -3, j -2
E_GetHiredEmployee: i: 2 idx: -3, j -3
CL_UpdateCharacterStats()... chr: Gary Cruise 
E_GetHiredEmployee: i: 0 idx: -4, j -1
E_GetHiredEmployee: i: 1 idx: -4, j -2
E_GetHiredEmployee: i: 2 idx: -4, j -3
E_GetHiredEmployee: i: 3 idx: -4, j -4
CL_UpdateCharacterStats()... chr: Maria Martinez 
E_GetHiredEmployee: i: 0 idx: -5, j -1
E_GetHiredEmployee: i: 1 idx: -5, j -2
E_GetHiredEmployee: i: 2 idx: -5, j -3
E_GetHiredEmployee: i: 3 idx: -5, j -4
E_GetHiredEmployee: i: 4 idx: -5, j -5
CL_UpdateCharacterStats()... chr: Kjell Sorenson 
E_GetHiredEmployee: i: 0 idx: -6, j -1
E_GetHiredEmployee: i: 1 idx: -6, j -2
E_GetHiredEmployee: i: 2 idx: -6, j -3
E_GetHiredEmployee: i: 3 idx: -6, j -4
E_GetHiredEmployee: i: 4 idx: -6, j -5
E_GetHiredEmployee: i: 5 idx: -6, j -6
CL_UpdateCharacterStats()... chr: Matsuko Hashimoto 
E_GetHiredEmployee: i: 0 idx: -7, j -1
E_GetHiredEmployee: i: 1 idx: -7, j -2
E_GetHiredEmployee: i: 2 idx: -7, j -3
E_GetHiredEmployee: i: 3 idx: -7, j -4
E_GetHiredEmployee: i: 4 idx: -7, j -5
E_GetHiredEmployee: i: 5 idx: -7, j -6
E_GetHiredEmployee: i: 6 idx: -7, j -7
CL_UpdateCharacterStats()... chr: Candice Quinn 
E_GetHiredEmployee: i: 0 idx: -9, j -1
E_GetHiredEmployee: i: 1 idx: -9, j -2
E_GetHiredEmployee: i: 2 idx: -9, j -3
E_GetHiredEmployee: i: 3 idx: -9, j -4
E_GetHiredEmployee: i: 4 idx: -9, j -5
E_GetHiredEmployee: i: 5 idx: -9, j -6
E_GetHiredEmployee: i: 6 idx: -9, j -7
E_GetHiredEmployee: i: 8 idx: -9, j -9
CL_UpdateCharacterStats()... chr: Hao Zhao     <----- Last soldier

Seems to work now