From 1f6350fe6e0a720dcf9cdf31fc39f77e198d7802 Mon Sep 17 00:00:00 2001 From: PG-SteveT <63470275+PG-SteveT@users.noreply.github.com> Date: Wed, 12 Aug 2020 11:32:36 -0700 Subject: [PATCH] August 12th Hotfix Includes fix for infinite loop in FootClass::Detach --- REDALERT/DLLInterface.cpp | 13 ++++++++++++- REDALERT/FOOT.CPP | 11 ++++++++++- REDALERT/MiscAsm.cpp | 2 +- REDALERT/WIN32LIB/DrawMisc.cpp | 2 +- TIBERIANDAWN/DLLInterface.cpp | 10 +++++++++- TIBERIANDAWN/MiscAsm.cpp | 2 +- TIBERIANDAWN/TECHNO.CPP | 4 ++-- TIBERIANDAWN/WIN32LIB/DrawMisc.cpp | 2 +- TIBERIANDAWN/WIN32LIB/FACINGFF.h | 2 +- 9 files changed, 38 insertions(+), 10 deletions(-) diff --git a/REDALERT/DLLInterface.cpp b/REDALERT/DLLInterface.cpp index 87012a2..d0ead4d 100644 --- a/REDALERT/DLLInterface.cpp +++ b/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]; diff --git a/REDALERT/FOOT.CPP b/REDALERT/FOOT.CPP index e5c005d..dc2353b 100644 --- a/REDALERT/FOOT.CPP +++ b/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)); -} +} \ No newline at end of file diff --git a/REDALERT/MiscAsm.cpp b/REDALERT/MiscAsm.cpp index adcf35d..fc6a767 100644 --- a/REDALERT/MiscAsm.cpp +++ b/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 ** ;*************************************************************************** diff --git a/REDALERT/WIN32LIB/DrawMisc.cpp b/REDALERT/WIN32LIB/DrawMisc.cpp index 1704bfa..6c3abe1 100644 --- a/REDALERT/WIN32LIB/DrawMisc.cpp +++ b/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 ** ;*************************************************************************** diff --git a/TIBERIANDAWN/DLLInterface.cpp b/TIBERIANDAWN/DLLInterface.cpp index f2de68d..ee67bb0 100644 --- a/TIBERIANDAWN/DLLInterface.cpp +++ b/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]; diff --git a/TIBERIANDAWN/MiscAsm.cpp b/TIBERIANDAWN/MiscAsm.cpp index 4f03422..8865770 100644 --- a/TIBERIANDAWN/MiscAsm.cpp +++ b/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 ** ;*************************************************************************** diff --git a/TIBERIANDAWN/TECHNO.CPP b/TIBERIANDAWN/TECHNO.CPP index ae97d9e..4d3993c 100644 --- a/TIBERIANDAWN/TECHNO.CPP +++ b/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); } diff --git a/TIBERIANDAWN/WIN32LIB/DrawMisc.cpp b/TIBERIANDAWN/WIN32LIB/DrawMisc.cpp index 27f9940..c0be513 100644 --- a/TIBERIANDAWN/WIN32LIB/DrawMisc.cpp +++ b/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 ** ;*************************************************************************** diff --git a/TIBERIANDAWN/WIN32LIB/FACINGFF.h b/TIBERIANDAWN/WIN32LIB/FACINGFF.h index 7183104..68b39d8 100644 --- a/TIBERIANDAWN/WIN32LIB/FACINGFF.h +++ b/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 ** ;***************************************************************************