Browse Source

August 12th Hotfix

Includes fix for infinite loop in FootClass::Detach
PG-SteveT 5 years ago
parent
commit
1f6350fe6e

+ 12 - 1
REDALERT/DLLInterface.cpp

@@ -302,6 +302,8 @@ class DLLExportClass {
 		static int CurrentDrawCount;
 		static int TotalObjectCount;
 		static int SortOrder;
+		static int ExportLayer;
+
 		static CNCObjectListStruct *ObjectList;
 
 		static CNC_Event_Callback_Type EventCallback;
@@ -346,6 +348,7 @@ class DLLExportClass {
 int DLLExportClass::CurrentDrawCount = 0;
 int DLLExportClass::TotalObjectCount = 0;
 int DLLExportClass::SortOrder = 0;
+int DLLExportClass::ExportLayer = 0;
 CNCObjectListStruct *DLLExportClass::ObjectList = NULL;
 SidebarGlyphxClass DLLExportClass::MultiplayerSidebars [MAX_PLAYERS];
 uint64 DLLExportClass::GlyphxPlayerIDs[MAX_PLAYERS] = {0xffffffffl};
@@ -1109,6 +1112,8 @@ void GlyphX_Assign_Houses(void)
 			strncpy(housep->IniName, Text_String(TXT_COMPUTER), HOUSE_NAME_MAX);
 			housep->IQ = Rule.MaxIQ;
 			//housep->Control.TechLevel = _build_tech[BuildLevel];
+		} else {
+			housep->IQ = 0;
 		}
 
 
@@ -3313,7 +3318,11 @@ void DLLExportClass::DLL_Draw_Intercept(int shape_number, int x, int y, int widt
 
 	new_object.CNCInternalObjectPointer = (void*)object;
 	new_object.OccupyListLength = 0;
-	new_object.SortOrder = SortOrder++;
+	if (CurrentDrawCount == 0) {
+		new_object.SortOrder = (ExportLayer << 29) + (object->Sort_Y() >> 3);
+	} else {
+		new_object.SortOrder = ObjectList->Objects[TotalObjectCount].SortOrder + CurrentDrawCount;
+	}	
 
 	strncpy(new_object.TypeName, object->Class_Of().IniName, CNC_OBJECT_ASSET_NAME_LENGTH);
 
@@ -3700,6 +3709,8 @@ bool DLLExportClass::Get_Layer_State(uint64 player_id, unsigned char *buffer_in,
 	*/
 	for (int layer = 0; layer < DLL_LAYER_COUNT; layer++) {
 		
+		ExportLayer = layer;
+		
 		for (int index = 0; index < Map.Layer[layer].Count(); index++) {
 			
 			ObjectClass *object = Map.Layer[layer][index];

+ 10 - 1
REDALERT/FOOT.CPP

@@ -2048,14 +2048,23 @@ void FootClass::Detach(TARGET target, bool all)
 	/*
 	**	Remove the target from the NavQueue list as well.
 	*/
+	int loop_count = 0;
 	for (int index = 0; index < ARRAY_SIZE(NavQueue); index++) {
 		if (NavQueue[index] == target) {
 			NavQueue[index] = TARGET_NONE;
 			if (index < ARRAY_SIZE(NavQueue)-1) {
 				memmove(&NavQueue[index], &NavQueue[index+1], ((ARRAY_SIZE(NavQueue)-index)-1) * sizeof(NavQueue[0]));
+				NavQueue[ARRAY_SIZE(NavQueue)-1] = TARGET_NONE;
 				index--;
 			}
 		}
+		/*
+		** Extra safety check
+		*/
+		loop_count++;
+		if (loop_count > ARRAY_SIZE(NavQueue)) {
+			break;
+		}
 	}
 
 	/*
@@ -2606,4 +2615,4 @@ int FootClass::Mission_Retreat(void)
 	}
 
 	return(MissionControl[Mission].Normal_Delay() + Random_Pick(0, 2));
-}
+}

+ 1 - 1
REDALERT/MiscAsm.cpp

@@ -428,7 +428,7 @@ dxisbig:
 #if (0)
 
 /*
-	; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/REDALERT/MiscAsm.cpp#95 $
+	; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/REDALERT/MiscAsm.cpp#97 $
 ;***************************************************************************
 ;**   C O N F I D E N T I A L --- W E S T W O O D   A S S O C I A T E S   **
 ;***************************************************************************

+ 1 - 1
REDALERT/WIN32LIB/DrawMisc.cpp

@@ -4842,7 +4842,7 @@ extern "C" int __cdecl Confine_Rect ( int * x , int * y , int w , int h , int wi
 
 
 /*
-; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/REDALERT/WIN32LIB/DrawMisc.cpp#95 $
+; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/REDALERT/WIN32LIB/DrawMisc.cpp#97 $
 ;***************************************************************************
 ;**   C O N F I D E N T I A L --- W E S T W O O D   A S S O C I A T E S   **
 ;***************************************************************************

+ 9 - 1
TIBERIANDAWN/DLLInterface.cpp

@@ -296,6 +296,7 @@ class DLLExportClass {
 		static int CurrentDrawCount;
 		static int TotalObjectCount;
 		static int SortOrder;
+		static int ExportLayer;
 		static CNCObjectListStruct *ObjectList;
 
 		static CNC_Event_Callback_Type EventCallback;
@@ -337,6 +338,7 @@ class DLLExportClass {
 int DLLExportClass::CurrentDrawCount = 0;
 int DLLExportClass::TotalObjectCount = 0;
 int DLLExportClass::SortOrder = 0;
+int DLLExportClass::ExportLayer = 0;
 CNCObjectListStruct *DLLExportClass::ObjectList = NULL;
 SidebarGlyphxClass DLLExportClass::MultiplayerSidebars [MAX_PLAYERS];
 uint64 DLLExportClass::GlyphxPlayerIDs[MAX_PLAYERS] = {0xffffffffl};
@@ -2964,7 +2966,11 @@ void DLLExportClass::DLL_Draw_Intercept(int shape_number, int x, int y, int widt
 
 	new_object.CNCInternalObjectPointer = (void*)object;
 	new_object.OccupyListLength = 0;
-	new_object.SortOrder = SortOrder++;
+	if (CurrentDrawCount == 0) {
+		new_object.SortOrder = (ExportLayer << 29) + (object->Sort_Y() >> 3);
+	} else {
+		new_object.SortOrder = ObjectList->Objects[TotalObjectCount].SortOrder + CurrentDrawCount;
+	}
 
 	strncpy(new_object.TypeName, object->Class_Of().IniName, CNC_OBJECT_ASSET_NAME_LENGTH);
 
@@ -3332,6 +3338,8 @@ bool DLLExportClass::Get_Layer_State(uint64 player_id, unsigned char *buffer_in,
 	*/
 	for (int layer = 0; layer < DLL_LAYER_COUNT; layer++) {
 		
+		ExportLayer = layer;
+
 		for (int index = 0; index < Map.Layer[layer].Count(); index++) {
 			
 			ObjectClass *object = Map.Layer[layer][index];

+ 1 - 1
TIBERIANDAWN/MiscAsm.cpp

@@ -428,7 +428,7 @@ dxisbig:
 #if (0)
 
 /*
-	; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/TIBERIANDAWN/MiscAsm.cpp#95 $
+	; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/TIBERIANDAWN/MiscAsm.cpp#97 $
 ;***************************************************************************
 ;**   C O N F I D E N T I A L --- W E S T W O O D   A S S O C I A T E S   **
 ;***************************************************************************

+ 2 - 2
TIBERIANDAWN/TECHNO.CPP

@@ -2426,7 +2426,7 @@ BulletClass * TechnoClass::Fire_At(TARGET target, int which)
 		}
 #else
 		/*
-		** Now need to reveal for any player that is the target. ST - 3/13/2019 5:43PM
+		** Now need to reveal for any player (only humans in normal node) that is the target. ST - 3/13/2019 5:43PM
 		*/
 
 		ObjectClass *obj = As_Object(target);
@@ -2434,7 +2434,7 @@ BulletClass * TechnoClass::Fire_At(TARGET target, int which)
 			HousesType tgt_owner = obj->Owner();
 
 			HouseClass *player = HouseClass::As_Pointer(tgt_owner);
-			if (player != nullptr) {
+			if (player != nullptr && (player->IsHuman || GameToPlay != GAME_NORMAL)) {
 				if ((!Is_Owned_By_Player(player) && !Is_Discovered_By_Player(player)) || !Map[Coord_Cell(Center_Coord())].Is_Mapped(House)) {
 					Map.Sight_From(player, Coord_Cell(Center_Coord()), 1, false);
 				}

+ 1 - 1
TIBERIANDAWN/WIN32LIB/DrawMisc.cpp

@@ -4841,7 +4841,7 @@ extern "C" int __cdecl Confine_Rect ( int * x , int * y , int w , int h , int wi
 
 
 /*
-; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/TIBERIANDAWN/WIN32LIB/DrawMisc.cpp#95 $
+; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/TIBERIANDAWN/WIN32LIB/DrawMisc.cpp#97 $
 ;***************************************************************************
 ;**   C O N F I D E N T I A L --- W E S T W O O D   A S S O C I A T E S   **
 ;***************************************************************************

+ 1 - 1
TIBERIANDAWN/WIN32LIB/FACINGFF.h

@@ -321,7 +321,7 @@ int __cdecl Desired_Facing8(long x1, long y1, long x2, long y2);
 
 
 /*
-	; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/TIBERIANDAWN/WIN32LIB/FACINGFF.h#95 $
+	; $Header: //depot/Projects/Mobius/QA/Project/Run/SOURCECODE/TIBERIANDAWN/WIN32LIB/FACINGFF.h#97 $
 ;***************************************************************************
 ;**   C O N F I D E N T I A L --- W E S T W O O D   A S S O C I A T E S   **
 ;***************************************************************************