[Fix] Missing civilians[message #317704]
|
Tue, 23 April 2013 22:32
|
|
mgl |
|
Messages:255
Registered:December 2007 Location: France |
|
|
This is my patch to fix the missing civilians issue. It's against Tron's repository.
I left a comment in the code, it explains what happens.
missing_civilians.diff:
Index: Build/Tactical/Soldier_Init_List.cc
===================================================================
--- Build/Tactical/Soldier_Init_List.cc (revision 7072)
+++ Build/Tactical/Soldier_Init_List.cc (working copy)
@@ -616,7 +616,13 @@
for (SOLDIERINITNODE* i = gSoldierInitHead; i && !i->pSoldier; i = i->next)
{
if (i->pBasicPlacement->bTeam != team) continue;
- if (!AddPlacementToWorld(i))
+
+ /* mgl: Missing civilians Fix
+ * AddPlacementToWorld() returns false for people (civilians) who have a profile
+ * but are not currently in the sector of the loaded map. It doesn't mean that
+ * there isn't any remaining slot for them in this case.
+ */
+ if (!AddPlacementToWorld(i) && i->pBasicPlacement->bTeam != CIV_TEAM)
{ /* If it fails to create the soldier, it is likely that it is because the
* slots in the tactical engine are already full. Besides, the strategic
* AI shouldn't be trying to fill a map with more than the maximum
Edit:
This single line of code patch is very efficient but it doesn't deal with the real problem wich is that the AddPlacementToWorld() function returns the same error code when it fails for a game logic reason, like don't spawn Ira in the rebels' hideout if she is in your team, as when it fails for a technical reason, like no more memory space available for a new character. It simply returns "success" or "failure", leaving the caller with a case study to do. This function only has one caller though.
This bug is originally from Tron when he simplified the code and made it faster where the caller is, changing from two passes on the list of characters to create to one pass.
Edit:
Forgot to remind that sunshine spotted the bug before me and fixed it in his own repository of stracciatella by commenting out the action to take by the caller if the AddPlacementToWorld() function fails.
[Updated on: Thu, 25 April 2013 19:23] by Moderator Report message to a moderator
|
|
|
|
|