# Conflicts, ignored these upstream changes:
#	REDALERT/MiscAsm.cpp
#	REDALERT/WIN32LIB/DrawMisc.cpp
This commit is contained in:
Justin Marshall
2020-06-22 17:19:05 -07:00
68 changed files with 1189 additions and 571 deletions
+90 -67
View File
@@ -130,7 +130,8 @@ CellClass::CellClass(void) :
Land(LAND_CLEAR),
OverrideLand(LAND_NONE),
IsMappedByPlayerMask(0),
IsVisibleByPlayerMask(0)
IsVisibleByPlayerMask(0),
CTFFlag(NULL)
{
for (int zone = MZONE_FIRST; zone < MZONE_COUNT; zone++) {
Zones[zone] = 0;
@@ -217,7 +218,7 @@ TechnoClass * CellClass::Cell_Techno(int x, int y) const
if (Cell_Occupier()) {
object = Cell_Occupier();
while (object) {
while (object && object->IsActive) {
if (object->Is_Techno()) {
COORDINATE coord = Coord_Fraction(object->Center_Coord());
long dist = Distance(coord, click);
@@ -253,7 +254,7 @@ ObjectClass * CellClass::Cell_Find_Object(RTTIType rtti) const
ObjectClass * object = Cell_Occupier();
while (object != NULL) {
while (object != NULL && object->IsActive) {
if (object->What_Am_I() == rtti) {
return(object);
}
@@ -1243,14 +1244,6 @@ void CellClass::Draw_It(int x, int y, bool objects) const
#endif
}
/*
** Draw the flag if there is one located at this cell.
*/
if (IsFlagged) {
void const * flag_remap = HouseClass::As_Pointer(Owner)->Remap_Table(false, REMAP_NORMAL);
CC_Draw_Shape(MFCD::Retrieve("FLAGFLY.SHP"), Frame % 14, x+(ICON_PIXEL_W/2), y+(ICON_PIXEL_H/2), WINDOW_TACTICAL, SHAPE_CENTER|SHAPE_GHOST|SHAPE_FADING, flag_remap, DisplayClass::UnitShadow);
}
#ifdef CHEAT_KEYS
}
#endif
@@ -1270,22 +1263,20 @@ void CellClass::Draw_It(int x, int y, bool objects) const
** hack overpass after the cells are redrawn so that subs can be
** redrawn separately.
*/
ObjectClass * optr[20 + ARRAY_SIZE(Overlapper)];
int count = 0;
static DynamicVectorClass<ObjectClass*> optr(20 + ARRAY_SIZE(Overlapper));
optr.Delete_All();
ObjectClass * object = Cell_Occupier();
while (object != NULL) {
if (!object->IsActive) break;
optr[count] = object;
optr.Add(object);
object->IsToDisplay = true;
object = object->Next;
count++;
}
for (int index = 0; index < ARRAY_SIZE(Overlapper); index++) {
object = Overlapper[index];
if (object != NULL && object->IsActive) {
object->IsToDisplay = true;
optr[count] = object;
count++;
optr.Add(object);
}
}
@@ -1293,7 +1284,7 @@ void CellClass::Draw_It(int x, int y, bool objects) const
** Sort the object list so that objects will be drawn from
** back to front.
*/
switch (count) {
switch (optr.Count()) {
/*
** If there are zero or one object, then sorting is
@@ -1332,14 +1323,14 @@ void CellClass::Draw_It(int x, int y, bool objects) const
** a quicksort.
*/
default:
qsort(optr, count, sizeof(optr[0]), _ocompare);
qsort(&optr[0], optr.Count(), sizeof(ObjectClass*), _ocompare);
break;
}
/*
** Draw any objects that happen to be in or overlapping this cell.
*/
for (int index = 0; index < count; index++) {
for (int index = 0; index < optr.Count(); index++) {
object = optr[index];
if (HasRenderedObject(object)) {
continue;
@@ -1619,9 +1610,9 @@ void CellClass::Wall_Update(void)
static FacingType _offsets[5] = {FACING_N, FACING_E, FACING_S, FACING_W, FACING_NONE};
for (unsigned index = 0; index < (sizeof(_offsets)/sizeof(_offsets[0])); index++) {
CellClass & newcell = Adjacent_Cell(_offsets[index]);
CellClass * newcell = Adjacent_Cell(_offsets[index]);
if (newcell.Overlay != OVERLAY_NONE && OverlayTypeClass::As_Reference(newcell.Overlay).IsWall) {
if (newcell && newcell->Overlay != OVERLAY_NONE && OverlayTypeClass::As_Reference(newcell->Overlay).IsWall) {
int icon = 0;
/*
@@ -1629,45 +1620,46 @@ void CellClass::Wall_Update(void)
** cells.
*/
for (unsigned i = 0; i < 4; i++) {
if (newcell.Adjacent_Cell(_offsets[i]).Overlay == newcell.Overlay) {
CellClass * adjcell = newcell->Adjacent_Cell(_offsets[i]);
if (adjcell && adjcell->Overlay == newcell->Overlay) {
icon |= 1 << i;
}
}
newcell.OverlayData = (newcell.OverlayData & 0xFFF0) | icon;
newcell->OverlayData = (newcell->OverlayData & 0xFFF0) | icon;
/*
** Handle special cases for the incomplete damaged wall sets. If a damage stage
** is calculated, but there is no artwork for it, then consider the wall to be
** completely destroyed.
*/
if (newcell.Overlay == OVERLAY_BRICK_WALL && newcell.OverlayData == 48) {
newcell.Overlay = OVERLAY_NONE;
newcell.OverlayData = 0;
Detach_This_From_All(::As_Target(newcell.Cell_Number()), true);
if (newcell->Overlay == OVERLAY_BRICK_WALL && newcell->OverlayData == 48) {
newcell->Overlay = OVERLAY_NONE;
newcell->OverlayData = 0;
Detach_This_From_All(::As_Target(newcell->Cell_Number()), true);
}
if (newcell.Overlay == OVERLAY_SANDBAG_WALL && newcell.OverlayData == 16) {
newcell.Overlay = OVERLAY_NONE;
newcell.OverlayData = 0;
Detach_This_From_All(::As_Target(newcell.Cell_Number()), true);
if (newcell->Overlay == OVERLAY_SANDBAG_WALL && newcell->OverlayData == 16) {
newcell->Overlay = OVERLAY_NONE;
newcell->OverlayData = 0;
Detach_This_From_All(::As_Target(newcell->Cell_Number()), true);
}
if (newcell.Overlay == OVERLAY_CYCLONE_WALL && newcell.OverlayData == 32) {
newcell.Overlay = OVERLAY_NONE;
newcell.OverlayData = 0;
Detach_This_From_All(::As_Target(newcell.Cell_Number()), true);
if (newcell->Overlay == OVERLAY_CYCLONE_WALL && newcell->OverlayData == 32) {
newcell->Overlay = OVERLAY_NONE;
newcell->OverlayData = 0;
Detach_This_From_All(::As_Target(newcell->Cell_Number()), true);
}
if (newcell.Overlay == OVERLAY_FENCE && (newcell.OverlayData == 16 || newcell.OverlayData == 32)) {
newcell.Overlay = OVERLAY_NONE;
newcell.OverlayData = 0;
Detach_This_From_All(::As_Target(newcell.Cell_Number()), true);
if (newcell->Overlay == OVERLAY_FENCE && (newcell->OverlayData == 16 || newcell->OverlayData == 32)) {
newcell->Overlay = OVERLAY_NONE;
newcell->OverlayData = 0;
Detach_This_From_All(::As_Target(newcell->Cell_Number()), true);
}
if (newcell.Overlay == OVERLAY_BARBWIRE_WALL && newcell.OverlayData == 16) {
newcell.Overlay = OVERLAY_NONE;
newcell.OverlayData = 0;
Detach_This_From_All(::As_Target(newcell.Cell_Number()), true);
if (newcell->Overlay == OVERLAY_BARBWIRE_WALL && newcell->OverlayData == 16) {
newcell->Overlay = OVERLAY_NONE;
newcell->OverlayData = 0;
Detach_This_From_All(::As_Target(newcell->Cell_Number()), true);
}
newcell.Recalc_Attributes();
newcell.Redraw_Objects();
newcell->Recalc_Attributes();
newcell->Redraw_Objects();
}
}
}
@@ -1784,10 +1776,14 @@ int CellClass::Reduce_Wall(int damage)
OverlayData = 0;
Recalc_Attributes();
Redraw_Objects();
Adjacent_Cell(FACING_N).Wall_Update();
Adjacent_Cell(FACING_W).Wall_Update();
Adjacent_Cell(FACING_S).Wall_Update();
Adjacent_Cell(FACING_E).Wall_Update();
CellClass * ncell = Adjacent_Cell(FACING_N);
if (ncell) ncell->Wall_Update();
CellClass * wcell = Adjacent_Cell(FACING_W);
if (wcell) wcell->Wall_Update();
CellClass * scell = Adjacent_Cell(FACING_S);
if (scell) scell->Wall_Update();
CellClass * ecell = Adjacent_Cell(FACING_E);
if (ecell) ecell->Wall_Update();
Detach_This_From_All(As_Target());
/*
@@ -2033,27 +2029,24 @@ void CellClass::Incoming(COORDINATE threat, bool forced, bool nokidding)
* HISTORY: *
* 03/19/1995 JLB : Created. *
*=============================================================================================*/
CellClass const & CellClass::Adjacent_Cell(FacingType face) const
CellClass const * CellClass::Adjacent_Cell(FacingType face) const
{
assert((unsigned)Cell_Number() <= MAP_CELL_TOTAL);
if (face == FACING_NONE) {
return(this);
}
if ((unsigned)face >= FACING_COUNT) {
return(*this);
return(NULL);
}
//The top row doesn't have any adjacent cells to the north. - LLL
if (ID < MAP_CELL_W && (face == FACING_N || face == FACING_NE || face == FACING_NW)) {
return (*this);
CELL newcell = ::Adjacent_Cell(Cell_Number(), face);
if ((unsigned)newcell >= MAP_CELL_TOTAL) {
return(NULL);
}
//The bottom row doesn't have any adjacent cells to the south. - LLL
if ((ID > MAP_CELL_TOTAL - MAP_CELL_W) && (face == FACING_S || face == FACING_SE || face == FACING_SW)) {
return (*this);
}
CellClass const * ptr = this + AdjacentCell[face];
if ((unsigned)ptr->Cell_Number() > MAP_CELL_TOTAL) return(*this);
return(*ptr);
return &Map[newcell];
}
@@ -2155,10 +2148,10 @@ long CellClass::Tiberium_Adjust(bool pregame)
*/
for (FacingType face = FACING_FIRST; face < FACING_COUNT; face++) {
if ((unsigned)::Adjacent_Cell(Cell_Number(), face) >= MAP_CELL_TOTAL) continue;
CellClass & adj = Adjacent_Cell(face);
CellClass * adj = Adjacent_Cell(face);
if (adj.Overlay != OVERLAY_NONE &&
OverlayTypeClass::As_Reference(adj.Overlay).Land == LAND_TIBERIUM) {
if (adj && adj->Overlay != OVERLAY_NONE &&
OverlayTypeClass::As_Reference(adj->Overlay).Land == LAND_TIBERIUM) {
count++;
}
}
@@ -2774,6 +2767,7 @@ bool CellClass::Flag_Place(HousesType house)
if (!IsFlagged && Is_Clear_To_Move(SPEED_TRACK, false, false)) {
IsFlagged = true;
Owner = house;
Flag_Update();
Redraw_Objects();
return(true);
}
@@ -2802,6 +2796,7 @@ bool CellClass::Flag_Remove(void)
if (IsFlagged) {
IsFlagged = false;
Owner = HOUSE_NONE;
Flag_Update();
Redraw_Objects();
return(true);
}
@@ -2809,6 +2804,34 @@ bool CellClass::Flag_Remove(void)
}
void CellClass::Flag_Update(void)
{
if (IsFlagged && !CTFFlag) {
Flag_Create();
} else if (!IsFlagged && CTFFlag) {
Flag_Destroy();
}
}
void CellClass::Flag_Create(void)
{
if (!CTFFlag) {
CTFFlag = new AnimClass(ANIM_FLAG, Cell_Coord());
if (CTFFlag) {
CTFFlag->OwnerHouse = Owner;
}
}
}
void CellClass::Flag_Destroy(void)
{
delete CTFFlag;
CTFFlag = NULL;
}
/***********************************************************************************************
* CellClass::Shimmer -- Causes all objects in the cell to shimmer. *
* *
@@ -3099,7 +3122,7 @@ bool CellClass::Spread_Tiberium(bool forced)
}
FacingType offset = Random_Pick(FACING_N, FACING_NW);
for (FacingType index = FACING_N; index < FACING_COUNT; index++) {
CellClass * newcell = &Adjacent_Cell(index+offset);
CellClass * newcell = Adjacent_Cell(index+offset);
if (newcell != NULL && newcell->Can_Tiberium_Germinate()) {
new OverlayClass(Random_Pick(OVERLAY_GOLD1, OVERLAY_GOLD4), newcell->Cell_Number());