From e49fa612f7f3021e66a4b105c2ab519e963416f9 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Thu, 6 Aug 2020 16:24:01 -0700 Subject: [PATCH] Placement cells are now based on the width/height of the icon and are now more flush with the assets. --- code/redalert/bdata.cpp | 68 +++++++++++++++++--------------------- code/redalert/building.cpp | 2 +- code/redalert/cell.cpp | 2 +- code/redalert/mission.cpp | 2 ++ code/redalert/type.h | 3 ++ 5 files changed, 37 insertions(+), 40 deletions(-) diff --git a/code/redalert/bdata.cpp b/code/redalert/bdata.cpp index 92dfd0a..cea377c 100644 --- a/code/redalert/bdata.cpp +++ b/code/redalert/bdata.cpp @@ -3283,7 +3283,7 @@ void BuildingTypeClass::One_Time(void) for (int sindex = STRUCT_FIRST; sindex < STRUCT_COUNT; sindex++) { char fullname[_MAX_FNAME+_MAX_EXT]; char buffer[_MAX_FNAME]; - BuildingTypeClass const & building = As_Reference((StructType)sindex); + BuildingTypeClass & building = As_Reference((StructType)sindex); /* ** Fetch the sidebar cameo image for this building. */ @@ -3351,6 +3351,32 @@ void BuildingTypeClass::One_Time(void) // building.HDImageData->renderheight[d] = height; // } //} + + { + short* ptr = &building._occupy[0]; + int height = building.Height(); + int width = building.Width(); + + //for (int y = 0; y < height; y++) { + // for (int x = 0; x < width; x++) { + // *ptr++ = y + (x * (MAP_CELL_W - 1)); + // } + //} + *ptr++ = MAP_CELL_W; + for (int y = 0; y < width; y++) { + *ptr++ = (MAP_CELL_W) + (y + 1) * (MAP_CELL_W + 1); + } + + for (int x = 0; x < height / 2; x++) { + *ptr++ = (MAP_CELL_W)+ (x + 1) * (MAP_CELL_W); + } + + for (int x = 0; x < height / 2; x++) { + *ptr++ = (MAP_CELL_W)+ (x + 1); + } + + *ptr = REFRESH_EOL; + } } int specialNumHDImages = 0; @@ -3728,41 +3754,7 @@ BuildingTypeClass & BuildingTypeClass::As_Reference(StructType type) *=============================================================================================*/ short const * BuildingTypeClass::Occupy_List(bool placement) const { - SmudgeType bib = SMUDGE_NONE; - CELL cell=0; - - if (placement && Bib_And_Offset(bib, cell)) { - - SmudgeTypeClass const & smudge = SmudgeTypeClass::As_Reference(bib); - static short _list[25]; - short * dest = &_list[0]; - - /* - ** Copy the bib overlap list into the working buffer. - */ - short const * src = smudge.Occupy_List(); - while (*src != REFRESH_EOL) { - *dest++ = (*src++) + cell; - } - - /* - ** Append the building occupy list to this working buffer. - */ - src = OccupyList; - while (src && *src != REFRESH_EOL) { - *dest++ = *src++; - } - *dest = REFRESH_EOL; - - return(&_list[0]); - } - - if (OccupyList != NULL) { - return(OccupyList); - } - - static short const _templap[] = {REFRESH_EOL}; - return(&_templap[0]); + return &_occupy[0]; } @@ -3810,7 +3802,7 @@ short const * BuildingTypeClass::Overlap_List(void) const *=============================================================================================*/ int BuildingTypeClass::Width(void) const { - return (Get_Build_Frame_Width(Get_Image_Data(), 0) / ICON_PIXEL_W) + 1; + return (ceil((float)Get_Build_Frame_Width(Get_Image_Data(), 0) / (float)ICON_PIXEL_W)); } @@ -3830,7 +3822,7 @@ int BuildingTypeClass::Width(void) const *=============================================================================================*/ int BuildingTypeClass::Height(bool bib) const { - return (Get_Build_Frame_Height(Get_Image_Data(), 0) / ICON_PIXEL_H) + 1; + return (ceil((float)Get_Build_Frame_Height(Get_Image_Data(), 0) / (float)ICON_PIXEL_H)); } diff --git a/code/redalert/building.cpp b/code/redalert/building.cpp index 6da38a1..d25a88f 100644 --- a/code/redalert/building.cpp +++ b/code/redalert/building.cpp @@ -296,7 +296,7 @@ RadioMessageType BuildingClass::Receive_Message(RadioClass * from, RadioMessageT break; case STRUCT_REFINERY: - param = ::As_Target(Coord_Cell(Adjacent_Cell(Center_Coord(), DIR_S))); + param = ::As_Target(Coord_Cell(Center_Coord() + (MAP_CELL_W /*+ 1)*/))); // jmarshall: changed from Adjacent_Cell(Center_Coord(), DIR_S)) break; } diff --git a/code/redalert/cell.cpp b/code/redalert/cell.cpp index d5d7a68..75e0a18 100644 --- a/code/redalert/cell.cpp +++ b/code/redalert/cell.cpp @@ -1358,7 +1358,7 @@ void CellClass::Draw_It(int x, int y, bool objects) // ConvertCoordsToIsometric(isox, isoy); // char tmp[12]; // sprintf(tmp, "%d", cell); - // GL_DrawText(6, isox, isoy, tmp); + // GL_DrawForegroundText(6, isox, isoy, tmp); //} BEnd(BENCH_CELL); diff --git a/code/redalert/mission.cpp b/code/redalert/mission.cpp index 0ea8e18..b92d9d4 100644 --- a/code/redalert/mission.cpp +++ b/code/redalert/mission.cpp @@ -222,6 +222,8 @@ void MissionClass::AI(void) return; } + + /* ** This is the script AI equivalent processing. */ diff --git a/code/redalert/type.h b/code/redalert/type.h index 61bbb3f..b23bf00 100644 --- a/code/redalert/type.h +++ b/code/redalert/type.h @@ -855,6 +855,9 @@ class BuildingTypeClass : public TechnoTypeClass { */ void const * BuildupData; + // Occupy list. + short _occupy[25 * 25]; + void Init_Anim(BStateType state, int start, int count, int rate) const; static Image_t* LoadHDImage(const char* fullname, int &numHDShapes, bool remapHouse); };