Skip to content

Commit

Permalink
August 12th Hotfix
Browse files Browse the repository at this point in the history
Includes fix for infinite loop in FootClass::Detach
  • Loading branch information
PG-SteveT committed Aug 12, 2020
1 parent ae72fce commit 1f6350f
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 10 deletions.
13 changes: 12 additions & 1 deletion REDALERT/DLLInterface.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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;
}


Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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];
Expand Down
11 changes: 10 additions & 1 deletion REDALERT/FOOT.CPP
Expand Up @@ -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;
}
}

/*
Expand Down Expand Up @@ -2606,4 +2615,4 @@ int FootClass::Mission_Retreat(void)
}

return(MissionControl[Mission].Normal_Delay() + Random_Pick(0, 2));
}
}
2 changes: 1 addition & 1 deletion REDALERT/MiscAsm.cpp
Expand Up @@ -428,7 +428,7 @@ int __cdecl Desired_Facing8(long x1, long y1, long x2, long y2)
#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 **
;***************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion REDALERT/WIN32LIB/DrawMisc.cpp
Expand Up @@ -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 **
;***************************************************************************
Expand Down
10 changes: 9 additions & 1 deletion TIBERIANDAWN/DLLInterface.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion TIBERIANDAWN/MiscAsm.cpp
Expand Up @@ -428,7 +428,7 @@ int __cdecl Desired_Facing8(long x1, long y1, long x2, long y2)
#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 **
;***************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions TIBERIANDAWN/TECHNO.CPP
Expand Up @@ -2426,15 +2426,15 @@ 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);
if (obj) {
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);
}
Expand Down
2 changes: 1 addition & 1 deletion TIBERIANDAWN/WIN32LIB/DrawMisc.cpp
Expand Up @@ -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 **
;***************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion TIBERIANDAWN/WIN32LIB/FACINGFF.h
Expand Up @@ -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 **
;***************************************************************************
Expand Down

0 comments on commit 1f6350f

Please sign in to comment.