Home » MODDING HQ 1.13 » v1.13 General Development Talk » Any introduction to the code?
Any introduction to the code?[message #357677]
|
Tue, 23 July 2019 01:45
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
Dear gentlemen,
We are just a small team on a mission trying to get into the C++ code of Ja2 1.13 hoping to fix some annoying bugs related to inventory managment.
We are capable to compile and run the code, but there are still a lot of unclear stuff for us.
Is here any introduction or general code structure description?
We are interested in location of log files for debugging, intermediate data output and for any software infrastructure available for debugging.
Thank you in advance for your help!
[Updated on: Tue, 23 July 2019 01:45] Report message to a moderator
|
Corporal
|
|
|
|
Re: Any introduction to the code?[message #357733 is a reply to message #357680]
|
Tue, 30 July 2019 05:04 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
sevenfm wrote on Tue, 23 July 2019 21:26Dear Sir/Madam, if you are interested in inventory management, you may want to search main trunk for The_Bob's commits as he made some fixes to inventory system.
I don't think you need any other debugging software apart from VS debugger which works well.
As far as I remember, debug logging goes to debug window in VS, but you need to enable various levels of debug info by using defines in the code and registering debug topics.
I don't think there's any introduction or code description, in general, if you are interested in inventory management, you just open Tactical folder and search for keywords you are interested in, and then start digging into the code. You probably need items.cpp file and all files containing "inventory" in them (look at those commits by The_Bob and see what files he changed).
Dear SevenFM, thank you very much for your reply!
The VS debugger works fine, but the debugging version of the code aborts its execution due to absence of *.ini files (ja2.ini, vfs_config.ini etc).
Are you aware where I have to place all the files for the _DEBUG project configuration?
Thanx again, bro!
Report message to a moderator
|
Corporal
|
|
|
|
|
|
Re: Any introduction to the code?[message #357753 is a reply to message #357680]
|
Sat, 03 August 2019 12:08 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
sevenfm wrote on Tue, 23 July 2019 21:26Dear Sir/Madam, if you are interested in inventory management, you may want to search main trunk for The_Bob's commits as he made some fixes to inventory system.
...
You probably need items.cpp file and all files containing "inventory" in them (look at those commits by The_Bob and see what files he changed).
Thanks! Exploring the revision history of items.cpp I see that last commit of The_Bob happened a while ago (20 Nov 2017). Unfortunately, I cant reproduce the problem on the exe-revisions after his changes. Hope this bug is gone (otherwise my wife will eat me alive).
By the way, are you aware about other bug described here: http://thepit.ja-galaxy-forum.com/index.php?t=msg&goto=354552 ?
First: is this a bug or a feature?
If this is bug, I'm capable to reproduce it on my PC. Did anyone try to fix it?
[Updated on: Sat, 03 August 2019 12:11] Report message to a moderator
|
Corporal
|
|
|
|
Re: Any introduction to the code?[message #357764 is a reply to message #357758]
|
Sun, 04 August 2019 08:43 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
sevenfm wrote on Sat, 03 August 2019 21:27MH17 wrote on Sat, 03 August 2019 14:08By the way, are you aware about other bug described here: http://thepit.ja-galaxy-forum.com/index.php?t=msg&goto=354552 ?
First: is this a bug or a feature?
If this is bug, I'm capable to reproduce it on my PC. Did anyone try to fix it?
Sorry, don't know anything about it, but I have reported a few reproducible bugs that noone could fix yet:
http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=22776&goto=357357&#msg_357357
http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=22776&goto=357365&#msg_357365
http://thepit.ja-galaxy-forum.com/index.php?t=msg&th=22776&goto=357459&#msg_357459
Maybe you would be interested in fixing them?
Hi! Yeah, I will try after finishing the aforementioned Problem with Squad Movement from the Strat Map.
At the moment I can say that the problem is related to default branch of operator "switch" in function "ReportMapScreenMovementError" (project "Strategic", file "Map Screen Interface.cpp", line 6279).
I tried to place a couple of breakpoints there to use F10/F11, but my VS debugger just hangs. I'm pretty sure you guys have some functions to perform an output of data into left-bottom window of strategic screen, do you? Or may be you got any classes or functions to dump necessary data into file on my HDD? It looks like there is function "LiveMessage" in file "Debug Control.cpp" exactly for that.
[Updated on: Sun, 04 August 2019 09:51] Report message to a moderator
|
Corporal
|
|
|
|
|
|
|
|
|
Re: Any introduction to the code?[message #357784 is a reply to message #357781]
|
Mon, 05 August 2019 14:41 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
@MH17
In Tactical\Overhead.cpp:
void RemoveStaticEnemiesFromSectorInfo( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
{
if ( !bMapZ ) // Battle ended Above-ground
{
SECTORINFO *pSectorInfo = &(SectorInfo[SECTOR( sMapX, sMapY )]);
pSectorInfo->ubNumAdmins = pSectorInfo->ubNumTroops = pSectorInfo->ubNumElites = 0;
pSectorInfo->ubAdminsInBattle = pSectorInfo->ubTroopsInBattle = pSectorInfo->ubElitesInBattle = 0;
}
else
{
UNDERGROUND_SECTORINFO *pSectorInfo;
pSectorInfo = FindUnderGroundSector( sMapX, sMapY, bMapZ );
pSectorInfo->ubNumAdmins = pSectorInfo->ubNumTroops = pSectorInfo->ubNumElites = 0;
pSectorInfo->ubAdminsInBattle = pSectorInfo->ubTroopsInBattle = pSectorInfo->ubElitesInBattle = 0;
}
}
which is called at the end of the battle in CheckForEndOfBattle()
// Kill all enemies. Sometime even after killing all the enemies, there appeares "in battle" enemies in sector info
RemoveStaticEnemiesFromSectorInfo( gWorldSectorX, gWorldSectorY, gbWorldSectorZ );
Maybe it would be enough to add
pSectorInfo->ubNumCreatures = 0
pSectorInfo->ubCreaturesInBattle = 0
to RemoveStaticEnemiesFromSectorInfo() to fix the bug?
This still leaves question why this information is not updated when creature is killed.
Looks like this information should be updated in ProcessQueenCmdImplicationsOfDeath(), which updates sector info:
AdjustToNextAnimationFrame->CheckForAndHandleSoldierDeath->HandleSoldierDeath->HandleNPCTeamMemberDeath->ProcessQueenCmdImplicationsOfDeath
but it only updates sector data for all creatures except bloodcats (bugs, zombies...?), and for bloodcats it only decrements bBloodCats
if( pSector->bBloodCats )
{
pSector->bBloodCats--;
}
and calls HandleBloodCatDeaths() (but only for UB)
#ifdef JA2UB
//JA25 UB
//handle anything important when bloodcats die
HandleBloodCatDeaths( pSector );
#endif
if we look at HandleBloodCatDeaths(), it only does quest/dialog related things.
So the best place to individually decrement ubNumCreatures and ubCreaturesInBattle should probably be in ProcessQueenCmdImplicationsOfDeath() when the game checks for creature type, but currently bloodcats are excluded (intentionally?)
@silversurfer, @Flugente can you comment on this?
[Updated on: Mon, 05 August 2019 17:57]
Left this community.Report message to a moderator
|
|
|
|
|
Re: Any introduction to the code?[message #357787 is a reply to message #357784]
|
Tue, 06 August 2019 05:25 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
sevenfm wrote on Mon, 05 August 2019 14:41@MH17
In Tactical\Overhead.cpp:
void RemoveStaticEnemiesFromSectorInfo( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
{
if ( !bMapZ ) // Battle ended Above-ground
{
SECTORINFO *pSectorInfo = &(SectorInfo[SECTOR( sMapX, sMapY )]);
pSectorInfo->ubNumAdmins = pSectorInfo->ubNumTroops = pSectorInfo->ubNumElites = 0;
pSectorInfo->ubAdminsInBattle = pSectorInfo->ubTroopsInBattle = pSectorInfo->ubElitesInBattle = 0;
}
else
{
UNDERGROUND_SECTORINFO *pSectorInfo;
pSectorInfo = FindUnderGroundSector( sMapX, sMapY, bMapZ );
pSectorInfo->ubNumAdmins = pSectorInfo->ubNumTroops = pSectorInfo->ubNumElites = 0;
pSectorInfo->ubAdminsInBattle = pSectorInfo->ubTroopsInBattle = pSectorInfo->ubElitesInBattle = 0;
}
}
which is called at the end of the battle in CheckForEndOfBattle()
// Kill all enemies. Sometime even after killing all the enemies, there appeares "in battle" enemies in sector info
RemoveStaticEnemiesFromSectorInfo( gWorldSectorX, gWorldSectorY, gbWorldSectorZ );
Maybe it would be enough to add
pSectorInfo->ubNumCreatures = 0
pSectorInfo->ubCreaturesInBattle = 0
to RemoveStaticEnemiesFromSectorInfo() to fix the bug?
Thank you, bro!
Yes, it did help in my situation when I added these lines in the each branch of the if-operator.
Probably you guys can make a commit, but in my opinion it is only partial solution.
I think this way cause my girlfriend reports that she observed a very similar problem when zombies-option was totally OFF during all the game process.
She says, that after applying the Alt+O cheat code all enemies in tactical mode died, but their red markers on the strategic screen remained the same.
And the sector remained to be hostile.
Most probably, there is something else hidden deep in the code. And it is waiting for our attention.
At the moment I'm trying to reproduce the bug from her saved games.
Quote:This still leaves question why this information is not updated when creature is killed.
I would like to know that too...
The function "RaiseZombies" correctly increases a counter of the raised deadmen (file "Rotting Corpses.cpp", line 2730) right in the sector data structure.
pSector->ubNumCreatures++;
pSector->ubCreaturesInBattle++;
Why we postpone the decrement of the counter to the end of the combat? I think we should decrease the counter in the moment when the creature died.
[Updated on: Tue, 06 August 2019 05:29] Report message to a moderator
|
Corporal
|
|
|
Re: Any introduction to the code?[message #357788 is a reply to message #357787]
|
Tue, 06 August 2019 07:28 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
Hello again, gentlemen!
As it was suggested in the previous post I have managed to reproduce a similar bug with the sector's enemy counters.
Problem description:
I moved my squad from A9 (Atremo Airport, Urban Chaos Mod) to sector B9, where I never ever been before. In the beginning there were 28 enemies.
Right after arrival I pressed Alt+O to kill all of them, but after using the cheat-code 14 soldiers left on the strategic map (as a red dots) together with my team (yellow dots).
But in the tactical screen (Alt+E) each visible enemy died. The zombi-option is OFF, noone of them raised up again.
Moreover, on the tactical screen for the DEBUG version of the code the bug has been announced by debug message "Sector troop counters are bad. What were the last 2-3 things to die, and how? Save game and send to KM with info!!!"
Direction of Work:
It makes me think that comrade SevenFM was right when he mentioned the function "ProcessQueenCmdImplicationsOfDeath" ("Strategic\Queen Command.cpp"), cause the function contains the debug message in line 1428.
Staying on the strategic map with the 14 enemies I tried to send my squad out and got the same old song: "Movement Orders? This is a hostile sector!", but after some walking around the code with debugger I found out that the reason is NOT related to sector counters!!! All of them are correct and equal to zero!
As I see, like in the previous bug (related to zombi) the movement order was blocked by function "NumHostilesInSector" ("Strategic\Queen Command.cpp"). But this time problem comes from loop in line 179:
As I understand in this situation one of the enemy groups was not affected by the cheat-code and its size didnt change (still equal to 14).
I tried to have a look into "ObliterateSector" -> "EVENT_SoldierGotHit", but failed to find anything of interest.
I'd like to explore how the gamecode changes the number of enemy red markers on the strategic screen and how it modifies the number of groups/number of individuals in groups. Could you please tell me where it is located?
Thank you in advance!
[Updated on: Tue, 06 August 2019 07:34] Report message to a moderator
|
Corporal
|
|
|
|
Re: Any introduction to the code?[message #357791 is a reply to message #357790]
|
Wed, 07 August 2019 07:51 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
silversurfer wrote on Tue, 06 August 2019 19:16It seems you had multiple groups of enemies, not all in the sector but some recently departed. They should appear after some time because reinforcements take time. At least that is my guess what happened here.
Hi, SilverSurfer!
Yeah, I got two groups of enemies (with pTSoldier->ubGroupID equal to 23 and 24), each group has 14 soldiers.
But all of them are staying in the sector for sure, cause for each one of the 28 soldiers:
1. I checked flag "pTSoldier->bInSector", it is equal 1.
2. I manually found all the soldiers on the tactical map using cheatcode Alt+E.
After using Alt+O everyone dies in tactics, but in strategic map one of the groups stays untouched.
In order to find out which enemy group has managed to survive after Alt+O I tried to check the ubGroupID in "NumHostilesInSector" and suddenly it gave me ubGroupID is equal to 24.
Do you know where I can find a code responsible for update of gpGroupList->ubGroupID after the death of last soldier in the group? I believe the problem is going to be somewhere around.
UPD: After some walking around the code with debugger I can conclude, that one enemy group (with ubGroupID = 23) was correctly deleted in function "ProcessQueenCmdImplicationsOfDeath" (file "Queen Command.cpp", line 1371, does anyone understands its logic?). The second group (with ubGroupID = 24) left as it is despite the fact, that all the soldiers were killed by the cheat code Alt+O. It seems to me that the call of the function "ProcessQueenCmdImplicationsOfDeath" has been missed somewhere...
UPD 2: Finally: after some extra research I see, that the soldiers from one of the groups with ubGroupID = 24 just absent in vector MercSlots (file "Overhead.cpp"). I have no idea why instead of 24 there are soldiers with ubGroupID = 25. As a result a function "ExecuteOverhead" cant process the array properly. Does anyone know what is the purpose of the vector MercSlots? Any advices or recomendations will be highly appreciated!
[Updated on: Wed, 07 August 2019 15:18] Report message to a moderator
|
Corporal
|
|
|
|
Re: Any introduction to the code?[message #357802 is a reply to message #357801]
|
Thu, 08 August 2019 11:43 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
@MH17 you can make a patch file with TortoiseSVN and post it here so silversurfer or other 1.13 coders could commit it.
[Updated on: Thu, 08 August 2019 12:00]
Left this community.Report message to a moderator
|
|
|
|
Re: Any introduction to the code?[message #357803 is a reply to message #357802]
|
Thu, 08 August 2019 12:12 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
Thanks, bro!
Unfortunately I'm not on my PC at the moment, and I have no idea why the SVN doesnt allow me to create patches from here.
Please, have a look on the modified piece of code with the aforementioned "while"-loop, hope it will help.
unsigned firstSlot = gTacticalStatus.Team[ENEMY_TEAM].bFirstID;
unsigned lastSlot = gTacticalStatus.Team[ENEMY_TEAM].bLastID;
unsigned slotsAvailable = lastSlot - firstSlot + 1;
while( pGroup && sNumSlots > 0 )
{
if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle &&
pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ )
{
ubNumAdmins = pGroup->pEnemyGroup->ubAdminsInBattle;
ubNumTroops = pGroup->pEnemyGroup->ubTroopsInBattle;
ubNumElites = pGroup->pEnemyGroup->ubElitesInBattle;
ubNumTanks = pGroup->pEnemyGroup->ubTanksInBattle;
ubNumJeeps = pGroup->pEnemyGroup->ubJeepsInBattle;
unsigned num = ubNumAdmins + ubNumTroops + ubNumElites + ubNumTanks + ubNumJeeps;
AssertGE((int)slotsAvailable, sNumSlots);
for (unsigned slot = firstSlot;
(slot <= lastSlot) && num && sNumSlots;
++slot)
{
pSoldier = &Menptr[ slot ];
// Skip inactive and already grouped soldiers
if (!pSoldier->bActive || pSoldier->ubGroupID)
{
// if this guy already has an ID, reduce the number of people who still need one
--num;
--sNumSlots;
continue;
}
// At this point we should not have added more soldiers than are in slots
AssertGT( sNumSlots, 0 );
switch( pSoldier->ubSoldierClass )
{
case SOLDIER_CLASS_ADMINISTRATOR:
if( ubNumAdmins )
{
num--;
sNumSlots--;
ubNumAdmins--;
pSoldier->ubGroupID = pGroup->ubGroupID;
firstSlot = slot + 1;
}
break;
case SOLDIER_CLASS_ARMY:
if( ubNumTroops )
{
num--;
sNumSlots--;
ubNumTroops--;
pSoldier->ubGroupID = pGroup->ubGroupID;
firstSlot = slot + 1;
}
break;
case SOLDIER_CLASS_ELITE:
if( ubNumElites )
{
num--;
sNumSlots--;
ubNumElites--;
pSoldier->ubGroupID = pGroup->ubGroupID;
firstSlot = slot + 1;
}
break;
// silversurfer: bugfix for Jaggzilla bug #623
// Mike or Iggy can be part of the enemy team and they are created from an Elite but they don't have SOLDIER_CLASS_ELITE.
// Therefore once this for loop was done ubNumElites was still 1 which caused an assertion error.
case SOLDIER_CLASS_NONE:
if( ubNumElites )
{
if ( pSoldier->ubProfile == MIKE || pSoldier->ubProfile == IGGY )
{
num--;
sNumSlots--;
ubNumElites--;
pSoldier->ubGroupID = pGroup->ubGroupID;
firstSlot = slot + 1;
}
}
break;
case SOLDIER_CLASS_TANK:
if( ubNumTanks )
{
num--;
sNumSlots--;
ubNumTanks--;
pSoldier->ubGroupID = pGroup->ubGroupID;
firstSlot = slot + 1;
}
break;
case SOLDIER_CLASS_JEEP:
if ( ubNumJeeps )
{
num--;
sNumSlots--;
ubNumJeeps--;
pSoldier->ubGroupID = pGroup->ubGroupID;
firstSlot = slot + 1;
}
break;
}
}
// Flugente: instead of just crashing the game without any explanation to the user, ignore this issue if it still exists.
// The worst that should happen is a warning that a soldier has no group id.
/*AssertEQ( ubNumElites , 0);
AssertEQ( ubNumTroops , 0);
AssertEQ( ubNumAdmins , 0);
AssertEQ( ubNumTanks , 0);
AssertEQ( ubNumJeeps , 0);
AssertEQ( num , 0);*/
}
pGroup = pGroup->next;
}
And please, apply your changes from message #357784 (file "Overhead.cpp") to deal the with zombies:
pSectorInfo->ubNumCreatures = 0
pSectorInfo->ubCreaturesInBattle = 0
Report message to a moderator
|
Corporal
|
|
|
Re: Any introduction to the code?[message #357805 is a reply to message #357803]
|
Thu, 08 August 2019 12:39 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
Here's the patch with MH17's changes, if people more competent in strategic code are interested.
link removed
[Updated on: Thu, 08 August 2019 13:59]
Left this community.Report message to a moderator
|
|
|
|
Re: Any introduction to the code?[message #357806 is a reply to message #357805]
|
Thu, 08 August 2019 12:59 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
Not sure about this code.
There is should be declaration of variables in the very beginning. Its the main point, they must be declared just one time.
[Updated on: Thu, 08 August 2019 13:02] Report message to a moderator
|
Corporal
|
|
|
Re: Any introduction to the code?[message #357807 is a reply to message #357806]
|
Thu, 08 August 2019 13:10 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
Deleted. |
![](/images/ranks/liutenant.png) |
Messages:2656
Registered:December 2012 Location: Russian Federation |
|
|
MH17 wrote on Thu, 08 August 2019 14:59Not sure about this code.
There is should be declaration of variables in the very beginning. Its the main point, they must be declared just one time.
You can simply post here your version of Queen Command.cpp then, I applied your patch according to your post:
Quote:file "Queen Command.cpp", lines 960-1047
[Updated on: Thu, 08 August 2019 13:11]
Left this community.Report message to a moderator
|
|
|
|
Re: Any introduction to the code?[message #357809 is a reply to message #357807]
|
Thu, 08 August 2019 13:45 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
Most probably I wasn't clear in my previous post.
Please, try to employ this piece of code:
Index: Queen Command.cpp
===================================================================
--- Queen Command.cpp (revision 8684)
+++ Queen Command.cpp (working copy)
@@ -945,28 +945,29 @@
sNumSlots = min( mapMaximumNumberOfEnemies, NumNonPlayerTeamMembersInSector( gWorldSectorX, gWorldSectorY, ENEMY_TEAM ) );
pGroup = gpGroupList;
- while( pGroup && sNumSlots > 0 )
+
+ unsigned firstSlot = gTacticalStatus.Team[ENEMY_TEAM].bFirstID;
+ unsigned lastSlot = gTacticalStatus.Team[ENEMY_TEAM].bLastID;
+ unsigned slotsAvailable = lastSlot - firstSlot + 1;
+ while (pGroup && sNumSlots > 0)
{
- if ( pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle &&
- pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ )
+ if (pGroup->usGroupTeam != OUR_TEAM && !pGroup->fVehicle &&
+ pGroup->ubSectorX == gWorldSectorX && pGroup->ubSectorY == gWorldSectorY && !gbWorldSectorZ)
{
ubNumAdmins = pGroup->pEnemyGroup->ubAdminsInBattle;
ubNumTroops = pGroup->pEnemyGroup->ubTroopsInBattle;
ubNumElites = pGroup->pEnemyGroup->ubElitesInBattle;
- ubNumTanks = pGroup->pEnemyGroup->ubTanksInBattle;
+ ubNumTanks = pGroup->pEnemyGroup->ubTanksInBattle;
ubNumJeeps = pGroup->pEnemyGroup->ubJeepsInBattle;
unsigned num = ubNumAdmins + ubNumTroops + ubNumElites + ubNumTanks + ubNumJeeps;
- unsigned firstSlot = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID;
- unsigned lastSlot = gTacticalStatus.Team[ ENEMY_TEAM ].bLastID;
- unsigned slotsAvailable = lastSlot-firstSlot+1;
AssertGE((int)slotsAvailable, sNumSlots);
for (unsigned slot = firstSlot;
- (slot <= lastSlot) && num && sNumSlots;
+ (slot <= lastSlot) && num && sNumSlots;
++slot)
{
- pSoldier = &Menptr[ slot ];
+ pSoldier = &Menptr[slot];
// Skip inactive and already grouped soldiers
if (!pSoldier->bActive || pSoldier->ubGroupID)
@@ -974,75 +975,81 @@
// if this guy already has an ID, reduce the number of people who still need one
--num;
--sNumSlots;
-
+
continue;
}
// At this point we should not have added more soldiers than are in slots
- AssertGT( sNumSlots, 0 );
+ AssertGT(sNumSlots, 0);
- switch( pSoldier->ubSoldierClass )
+ switch (pSoldier->ubSoldierClass)
{
- case SOLDIER_CLASS_ADMINISTRATOR:
- if( ubNumAdmins )
- {
- num--;
- sNumSlots--;
- ubNumAdmins--;
- pSoldier->ubGroupID = pGroup->ubGroupID;
- }
- break;
- case SOLDIER_CLASS_ARMY:
- if( ubNumTroops )
- {
- num--;
- sNumSlots--;
- ubNumTroops--;
- pSoldier->ubGroupID = pGroup->ubGroupID;
- }
- break;
- case SOLDIER_CLASS_ELITE:
- if( ubNumElites )
- {
- num--;
- sNumSlots--;
- ubNumElites--;
- pSoldier->ubGroupID = pGroup->ubGroupID;
- }
- break;
+ case SOLDIER_CLASS_ADMINISTRATOR:
+ if (ubNumAdmins)
+ {
+ num--;
+ sNumSlots--;
+ ubNumAdmins--;
+ pSoldier->ubGroupID = pGroup->ubGroupID;
+ firstSlot = slot + 1;
+ }
+ break;
+ case SOLDIER_CLASS_ARMY:
+ if (ubNumTroops)
+ {
+ num--;
+ sNumSlots--;
+ ubNumTroops--;
+ pSoldier->ubGroupID = pGroup->ubGroupID;
+ firstSlot = slot + 1;
+ }
+ break;
+ case SOLDIER_CLASS_ELITE:
+ if (ubNumElites)
+ {
+ num--;
+ sNumSlots--;
+ ubNumElites--;
+ pSoldier->ubGroupID = pGroup->ubGroupID;
+ firstSlot = slot + 1;
+ }
+ break;
// silversurfer: bugfix for Jaggzilla bug #623
// Mike or Iggy can be part of the enemy team and they are created from an Elite but they don't have SOLDIER_CLASS_ELITE.
// Therefore once this for loop was done ubNumElites was still 1 which caused an assertion error.
- case SOLDIER_CLASS_NONE:
- if( ubNumElites )
+ case SOLDIER_CLASS_NONE:
+ if (ubNumElites)
+ {
+ if (pSoldier->ubProfile == MIKE || pSoldier->ubProfile == IGGY)
{
- if ( pSoldier->ubProfile == MIKE || pSoldier->ubProfile == IGGY )
- {
- num--;
- sNumSlots--;
- ubNumElites--;
- pSoldier->ubGroupID = pGroup->ubGroupID;
- }
- }
- break;
- case SOLDIER_CLASS_TANK:
- if( ubNumTanks )
- {
num--;
sNumSlots--;
- ubNumTanks--;
+ ubNumElites--;
pSoldier->ubGroupID = pGroup->ubGroupID;
+ firstSlot = slot + 1;
}
- break;
- case SOLDIER_CLASS_JEEP:
- if ( ubNumJeeps )
- {
- num--;
- sNumSlots--;
- ubNumJeeps--;
- pSoldier->ubGroupID = pGroup->ubGroupID;
- }
- break;
+ }
+ break;
+ case SOLDIER_CLASS_TANK:
+ if (ubNumTanks)
+ {
+ num--;
+ sNumSlots--;
+ ubNumTanks--;
+ pSoldier->ubGroupID = pGroup->ubGroupID;
+ firstSlot = slot + 1;
+ }
+ break;
+ case SOLDIER_CLASS_JEEP:
+ if (ubNumJeeps)
+ {
+ num--;
+ sNumSlots--;
+ ubNumJeeps--;
+ pSoldier->ubGroupID = pGroup->ubGroupID;
+ firstSlot = slot + 1;
+ }
+ break;
}
}
Report message to a moderator
|
Corporal
|
|
|
|
Re: Any introduction to the code?[message #357812 is a reply to message #357811]
|
Thu, 08 August 2019 20:53 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
Dear SllverSurfer,
I think you got the idea right.
As to your question: I'm not sure that within my plan to fix the bug the function needs the if-check within the while-loop at all.
I tried to run the code with few tests including that one described above (two different groups in sector B9) and I see that a condition of the if-operator never becomes true.
In other words we skip inactive soldiers and soldiers labelled on previous iterations of the while-loop moving the initial value of the index firstSlot.
Since I'm not capable to create a situation when the execution point drops within the if-check I dont think that I should modify it.
PS: I suggest that most probably your idea makes sense.
[Updated on: Thu, 08 August 2019 21:05] Report message to a moderator
|
Corporal
|
|
|
|
|
|
|
|
Re: Any introduction to the code?[message #357949 is a reply to message #357947]
|
Fri, 23 August 2019 12:56 ![Go to previous message Go to previous message](/theme/Bear_Classic_Brown/images/up.png)
|
|
MH17 |
![](/images/ranks/corporal.png) |
Messages:46
Registered:November 2018 Location: Antarctica |
|
|
silversurfer wrote on Fri, 23 August 2019 10:26I don't have UC so I can't comment on map specific issues. I assume the ubNumCreatures is higher than 30 after you enter the sector or are there 30 zombies?
If there are e.g. 20 Zombies and the counter goes to 50 and after you kill them all the counter is reduced properly and goes back to 30 it means at least the fix for zombies in ProcessQueenCmdImplicationsOfDeath() is working. In this case maybe you can figure out where the 30 is coming from.
Hi, SilverSurfer!
Yeah, it looks like after your update the counter of zombies has been correctly increased and decreased.
But its initial value upon arriving my team into city sector D13 is equal to 30. It is before any zombie was generated and long before any enemy was killed.
My girlfriend just started the game and she never ever been before in this location during the short campaign.
This is Callisto Mine in UC (or Drassen Mine in the Vanilla).
Using cheat codes I couldn't find any zombies or monsters in the sector, just some enemy troops.
And very interesting moment: just look at the function "ValidateAndCorrectInBattleCounters" (file "strategic\prebattle interface.cpp").
This function sets some of combat counters to 0 in line 270.
May be it make sense to zeroize all of them?
All of this looks extremely strange to me.
[Updated on: Fri, 23 August 2019 12:57] Report message to a moderator
|
Corporal
|
|
|
|
|
|
|
Goto Forum:
Current Time: Wed Feb 12 12:13:59 GMT+2 2025
Total time taken to generate the page: 0.01797 seconds
|