All pastes #349757 Raw Edit

Someone

public text v1 · immutable
·published 2007-02-11 01:02 UTC
rendered paste body
--- cl_employee.cSAV    2007-02-11 00:34:14.000000000 +0100
+++ cl_employee.c       2007-02-11 01:03:42.000000000 +0100
@@ -372,12 +372,15 @@
                        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 {
+                       j--;
                        continue;
+               }
        }
        return NULL;
 }

PS : The Com_Printf is just for debug.

Before the crash:

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 soldier with id 7 is in base, the id 8 is in team. The problem is because j is not decremented for the unhired soldier number 7. With the correction i have :

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




But then there is a problem in CL_UpdateHireVar wich use the same function

Changing to Singleplayer
E_GetHiredEmployee: i: 0 idx: -1, j -1
E_GetHiredEmployee: i: 0 idx: -2, j -1
E_GetHiredEmployee: i: 1 idx: -2, j -2
E_GetHiredEmployee: i: 0 idx: -3, j -1
E_GetHiredEmployee: i: 1 idx: -3, j -2
E_GetHiredEmployee: i: 2 idx: -3, j -3
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
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
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
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
E_GetHiredEmployee: i: 0 idx: -8, j -1
E_GetHiredEmployee: i: 1 idx: -8, j -2
E_GetHiredEmployee: i: 2 idx: -8, j -3
E_GetHiredEmployee: i: 3 idx: -8, j -4
E_GetHiredEmployee: i: 4 idx: -8, j -5
E_GetHiredEmployee: i: 5 idx: -8, j -6
E_GetHiredEmployee: i: 6 idx: -8, j -7
E_GetHiredEmployee: i: 8 idx: -8, j -9
SDL audio device shut down.
Error: CL_UpdateHireVar: Could not get employee 7