Home » MODDING HQ 1.13 » v1.13 General Development Talk » Any introduction to the code?
Re: Any introduction to the code?[message #357809 is a reply to message #357807] Thu, 08 August 2019 13:45 Go to previous messageGo to previous message
MH17 is currently offline MH17

 
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
 
Read Message icon12.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon14.gif
Read Message icon9.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message film28.png
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: An easy way of editing the XML files in dev builds (XML Editor broken?)
Next Topic: How to change loading screens?
Goto Forum:
  


Current Time: Wed Feb 12 17:48:35 GMT+2 2025

Total time taken to generate the page: 0.01017 seconds