From f81a0dd585097c7c09ccf6c66c5ae0604b825f82 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Tue, 27 Apr 2021 23:21:07 +0100 Subject: [PATCH 01/15] [TD] Fixes map loading in remaster builds. Fixes issue where custom scenarios were not loaded correctly which lead to tiles being misplaced in game. Also removes some duplicate code from the map loading code to simplify things. --- tiberiandawn/map.cpp | 167 +++++++++++-------------------------------- 1 file changed, 43 insertions(+), 124 deletions(-) diff --git a/tiberiandawn/map.cpp b/tiberiandawn/map.cpp index 97ce5e41..ac887970 100644 --- a/tiberiandawn/map.cpp +++ b/tiberiandawn/map.cpp @@ -935,131 +935,16 @@ long MapClass::Overpass(void) * 11/14/1994 BR : Created. * * 01/08/1995 JLB : Fixup any obsolete icons detected. * *=============================================================================================*/ -#ifdef DEMO -bool MapClass::Read_Binary(char const* root, unsigned long*) -#else bool MapClass::Read_Binary(char const* root, uint32_t* crc) -#endif { -#ifdef MEGAMAPS - if (MapBinaryVersion == MAP_VERSION_MEGA) { - return Read_Binary_Big(root, crc); - } -#endif - - CCFileClass file; char fname[_MAX_FNAME + _MAX_EXT]; - int i; - char* map; - void* rawmap; - void const* shape; - CellClass* cellptr = NULL; /* ** Filename = INI name with BIN extension. */ sprintf(fname, "%s.BIN", root); - /* - ** Create object & open file. - */ - file.Set_Name(fname); - if (!file.Is_Available()) { - return (false); - } - file.Open(READ); - -#ifdef MEGAMAPS - /* - ** Loop through all cells and set all to the clear tile. - */ - for (i = 0; i < MAP_CELL_TOTAL; i++) { - //CCDebugString("Cell: %d:%d\n", Cell_X(i), Cell_Y(i)); - cellptr = &Map[i]; - cellptr->TType = (TemplateType)255; - cellptr->TIcon = 0; - cellptr->Recalc_Attributes(); - } -#endif - - /* - ** We need to handle the orignal maps differently now as MAP_CELL_TOTAL is larger - ** and will break all maps made the old way. This new piece of code will offset the - ** cells of the smaller maps to be within the new MAP_CELL_TOTAL range. - */ -#ifdef MEGAMAPS - /* - ** Loop through all cells. The helper funtion will convert the old map binary cell - ** to a position in the new big map array. - */ - for (i = 0; i < (MAP_CELL_TOTAL / 4); i++) { - CELL cell = Confine_Old_Cell(i); - cellptr = &Map[cell]; -#else - /* - ** Loop through all cells. - */ - cellptr = &Map[0]; - for (i = 0; i < MAP_CELL_TOTAL; i++) { -#endif - -#pragma pack(push, 1) - struct - { - TemplateType TType; // Template type. - unsigned char TIcon; // Template icon number. - } temp; -#pragma pack(pop) - - if (file.Read(&temp, sizeof(temp)) != sizeof(temp)) - break; - if (temp.TType == (TemplateType)255) { - temp.TType = TEMPLATE_NONE; - } - - /* - ** Verify that the template type actually contains the template number specified. If - ** an illegal icon was specified, then replace it with clear terrain. - */ - if (temp.TType != TEMPLATE_CLEAR1 && temp.TType != TEMPLATE_NONE) { - TemplateTypeClass const& ttype = TemplateTypeClass::As_Reference(temp.TType); - shape = ttype.Get_Image_Data(); - if (shape) { - rawmap = Get_Icon_Set_Map(shape); - if (rawmap) { - map = (char*)rawmap; - if ((temp.TIcon >= (ttype.Width * ttype.Height)) || (map[temp.TIcon] == -1)) { - temp.TIcon = 0; - temp.TType = TEMPLATE_NONE; - } - } - } - } - - cellptr->TType = temp.TType; - cellptr->TIcon = temp.TIcon; - cellptr->Recalc_Attributes(); - -#ifndef DEMO - Add_CRC(crc, (uint32_t)cellptr->TType); - Add_CRC(crc, (uint32_t)cellptr->TIcon); -#endif - -#ifndef MEGAMAPS - cellptr++; -#endif - } - - /* - ** Close the file. - */ - file.Close(); - -#ifdef MEGAMAPS - return (i == (MAP_CELL_TOTAL / 4)); -#else - return (i == MAP_CELL_TOTAL); -#endif + return Read_Binary_File(fname, crc); } #ifdef MEGAMAPS @@ -1080,21 +965,15 @@ bool MapClass::Read_Binary(char const* root, uint32_t* crc) * 11/14/1994 BR : Created. * * 01/08/1995 JLB : Fixup any obsolete icons detected. * *=============================================================================================*/ -bool MapClass::Read_Binary_Big(char const* root, uint32_t* crc) +bool MapClass::Read_Binary_Big(char const* fname, uint32_t* crc) { CCFileClass file; - char fname[_MAX_FNAME + _MAX_EXT]; int i; char* map; void* rawmap; void const* shape; CellClass* cellptr = NULL; - /* - ** Filename = INI name with BIN extension. - */ - sprintf(fname, "%s.BIN", root); - /* ** Create object & open file. */ @@ -1202,6 +1081,13 @@ bool MapClass::Read_Binary_File(char const* fname, uint32_t* crc) char* map; void* rawmap; void const* shape; + CellClass* cellptr = NULL; + +#ifdef MEGAMAPS + if (MapBinaryVersion == MAP_VERSION_MEGA) { + return Read_Binary_Big(fname, crc); + } +#endif /* ** Create object & open file. @@ -1212,11 +1098,38 @@ bool MapClass::Read_Binary_File(char const* fname, uint32_t* crc) } file.Open(READ); +#ifdef MEGAMAPS + /* + ** Loop through all cells and set all to the clear tile. + */ + for (i = 0; i < MAP_CELL_TOTAL; i++) { + cellptr = &Map[i]; + cellptr->TType = (TemplateType)255; + cellptr->TIcon = 0; + cellptr->Recalc_Attributes(); + } +#endif + + /* + ** We need to handle the orignal maps differently now as MAP_CELL_TOTAL is larger + ** and will break all maps made the old way. This new piece of code will offset the + ** cells of the smaller maps to be within the new MAP_CELL_TOTAL range. + */ +#ifdef MEGAMAPS + /* + ** Loop through all cells. The helper funtion will convert the old map binary cell + ** to a position in the new big map array. + */ + for (i = 0; i < (MAP_CELL_TOTAL / 4); i++) { + CELL cell = Confine_Old_Cell(i); + cellptr = &Map[cell]; +#else /* ** Loop through all cells. */ - CellClass* cellptr = &Map[0]; + cellptr = &Map[0]; for (i = 0; i < MAP_CELL_TOTAL; i++) { +#endif #pragma pack(push, 1) struct { @@ -1258,7 +1171,9 @@ bool MapClass::Read_Binary_File(char const* fname, uint32_t* crc) Add_CRC(crc, (uint32_t)cellptr->TIcon); #endif +#ifndef MEGAMAPS cellptr++; +#endif } /* @@ -1266,7 +1181,11 @@ bool MapClass::Read_Binary_File(char const* fname, uint32_t* crc) */ file.Close(); +#ifdef MEGAMAPS + return (i == (MAP_CELL_TOTAL / 4)); +#else return (i == MAP_CELL_TOTAL); +#endif } /*********************************************************************************************** From ce33a40a1a0c688225d175bb11e9fc867e99e69a Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Thu, 29 Apr 2021 23:32:16 +0100 Subject: [PATCH 02/15] Revert "Use range loop if it's possible" This reverts commit 5ed3cfdda10d6865e569ddd2d88f9e22d98c0c51. --- common/blowfish.cpp | 6 +-- common/ccfile.cpp | 4 +- common/mp.cpp | 4 +- common/palettec.cpp | 8 ++-- common/sha.cpp | 4 +- common/soundio_openal.cpp | 16 ++++---- common/video_sdl2.cpp | 6 +-- common/vqaaudio_openal.cpp | 4 +- redalert/audio.cpp | 4 +- redalert/base.cpp | 6 +-- redalert/bdata.cpp | 5 ++- redalert/cell.cpp | 29 ++++++++------- redalert/dial8.cpp | 4 +- redalert/egos.cpp | 4 +- redalert/flasher.cpp | 6 +-- redalert/foot.cpp | 18 ++++----- redalert/house.cpp | 12 +++--- redalert/init.cpp | 18 ++++----- redalert/iomap.cpp | 16 ++++---- redalert/map.cpp | 20 +++++----- redalert/msglist.cpp | 4 +- redalert/scenario.cpp | 12 +++--- redalert/score.cpp | 18 ++++----- redalert/sidebar.cpp | 20 +++++----- redalert/teamtype.cpp | 6 +-- redalert/techno.cpp | 14 +++---- tests/face.cpp | 36 +++++++++--------- tests/irandom.cpp | 22 ++++++----- tests/miscasm.cpp | 40 +++++++++++--------- tests/rect.cpp | 72 +++++++++++++++++++----------------- tiberiandawn/base.cpp | 8 ++-- tiberiandawn/bdata.cpp | 6 +-- tiberiandawn/cell.cpp | 20 +++++----- tiberiandawn/conquer.cpp | 8 ++-- tiberiandawn/dial8.cpp | 4 +- tiberiandawn/ending.cpp | 8 ++-- tiberiandawn/flasher.cpp | 6 +-- tiberiandawn/foot.cpp | 8 ++-- tiberiandawn/house.cpp | 12 +++--- tiberiandawn/idata.cpp | 8 ++-- tiberiandawn/intro.cpp | 12 +++--- tiberiandawn/iomap.cpp | 8 ++-- tiberiandawn/map.cpp | 4 +- tiberiandawn/mapsel.cpp | 4 +- tiberiandawn/overlay.cpp | 4 +- tiberiandawn/scenarioini.cpp | 4 +- tiberiandawn/score.cpp | 24 ++++++------ tiberiandawn/sidebar.cpp | 20 +++++----- tiberiandawn/techno.cpp | 4 +- 49 files changed, 314 insertions(+), 296 deletions(-) diff --git a/common/blowfish.cpp b/common/blowfish.cpp index 9250fcb0..1f0f9d06 100644 --- a/common/blowfish.cpp +++ b/common/blowfish.cpp @@ -172,11 +172,11 @@ void BlowfishEngine::Submit_Key(void const* key, int length) ** working 64 bit number is carried into this process from the previous ** operation. */ - for (auto& sbox_index : bf_S) { + for (int sbox_index = 0; sbox_index < 4; sbox_index++) { for (int ss_index = 0; ss_index < UCHAR_MAX + 1; ss_index += 2) { Sub_Key_Encrypt(left, right); - sbox_index[ss_index] = left; - sbox_index[ss_index + 1] = right; + bf_S[sbox_index][ss_index] = left; + bf_S[sbox_index][ss_index + 1] = right; } } diff --git a/common/ccfile.cpp b/common/ccfile.cpp index 5d9bc4eb..eed68bad 100644 --- a/common/ccfile.cpp +++ b/common/ccfile.cpp @@ -542,8 +542,8 @@ unsigned long Seek_File(int handle, long offset, int starting) void WWDOS_Shutdown(void) { - for (CCFileClass& Handle : Handles) { - Handle.Set_Name(NULL); + for (int index = 0; index < 10; index++) { + Handles[index].Set_Name(NULL); } } diff --git a/common/mp.cpp b/common/mp.cpp index 73b9bf70..c6c76aa4 100644 --- a/common/mp.cpp +++ b/common/mp.cpp @@ -2203,8 +2203,8 @@ bool XMP_Small_Divisors_Test(const digit* candidate, int precision) { digit quotient[MAX_UNIT_PRECISION]; - for (unsigned short i : primeTable) { - if (XMP_Unsigned_Div_Int(quotient, candidate, i, precision) == 0) + for (unsigned i = 0; i < ARRAY_SIZE(primeTable); i++) { + if (XMP_Unsigned_Div_Int(quotient, candidate, primeTable[i], precision) == 0) return (false); } return (true); diff --git a/common/palettec.cpp b/common/palettec.cpp index 8cd81b7f..a578d263 100644 --- a/common/palettec.cpp +++ b/common/palettec.cpp @@ -70,8 +70,8 @@ PaletteClass const& PaletteClass::CurrentPalette = *(PaletteClass*)&::CurrentPal *=============================================================================================*/ PaletteClass::PaletteClass(RGBClass const& rgb) { - for (RGBClass& index : Palette) { - index = rgb; + for (int index = 0; index < COLOR_COUNT; index++) { + Palette[index] = rgb; } } @@ -141,8 +141,8 @@ PaletteClass& PaletteClass::operator=(PaletteClass const& palette) *=============================================================================================*/ void PaletteClass::Adjust(int ratio) { - for (RGBClass& index : Palette) { - index.Adjust(ratio, BlackColor); + for (int index = 0; index < COLOR_COUNT; index++) { + Palette[index].Adjust(ratio, BlackColor); } } diff --git a/common/sha.cpp b/common/sha.cpp index c5149aad..ac951b43 100644 --- a/common/sha.cpp +++ b/common/sha.cpp @@ -218,9 +218,9 @@ int SHAEngine::Result(void* result) const Process_Block(&partial[0], acc); memcpy((char*)&FinalResult, &acc, sizeof(acc)); - for (unsigned int index : FinalResult.Long) { + for (int index = 0; index < sizeof(FinalResult) / sizeof(int32_t); index++) { // for (int index = 0; index < SRC_BLOCK_SIZE/sizeof(int32_t); index++) { - (int32_t&)index = htobe32(index); + (int32_t&)FinalResult.Long[index] = htobe32(FinalResult.Long[index]); } (bool&)IsCached = true; memcpy(result, &FinalResult, sizeof(FinalResult)); diff --git a/common/soundio_openal.cpp b/common/soundio_openal.cpp index 47600b66..6125f90e 100644 --- a/common/soundio_openal.cpp +++ b/common/soundio_openal.cpp @@ -566,8 +566,8 @@ int File_Stream_Sample_Vol(char const* filename, int volume, bool real_time_star if (FileStreamBuffer == nullptr) { FileStreamBuffer = malloc((unsigned long)(LockedData.StreamBufferSize * LockedData.StreamBufferCount)); - for (SampleTrackerType& i : LockedData.SampleTracker) { - i.FileBuffer = FileStreamBuffer; + for (int i = 0; i < MAX_SAMPLE_TRACKERS; ++i) { + LockedData.SampleTracker[i].FileBuffer = FileStreamBuffer; } } @@ -844,8 +844,8 @@ bool Audio_Init(int bits_per_sample, bool stereo, int rate, bool reverse_channel } // Create placback buffers for all trackers. - for (SampleTrackerType& i : LockedData.SampleTracker) { - SampleTrackerType* st = &i; + for (int i = 0; i < MAX_SAMPLE_TRACKERS; ++i) { + SampleTrackerType* st = &LockedData.SampleTracker[i]; // Gen buffers on audio start? // alGenBuffers(OPENAL_BUFFER_COUNT, st->AudioBuffers); @@ -1157,9 +1157,11 @@ int Set_Score_Vol(int volume) int old = LockedData.ScoreVolume; LockedData.ScoreVolume = volume; - for (SampleTrackerType& st : LockedData.SampleTracker) { - if (st.IsScore & st.Active) { - alSourcef(st.OpenALSource, AL_GAIN, ((LockedData.ScoreVolume * st.Volume) / 256) / 256.0f); + for (int i = 0; i < MAX_SAMPLE_TRACKERS; ++i) { + SampleTrackerType* st = &LockedData.SampleTracker[i]; + + if (st->IsScore & st->Active) { + alSourcef(st->OpenALSource, AL_GAIN, ((LockedData.ScoreVolume * st->Volume) / 256) / 256.0f); } } diff --git a/common/video_sdl2.cpp b/common/video_sdl2.cpp index 59a5460f..e4b0a3d9 100644 --- a/common/video_sdl2.cpp +++ b/common/video_sdl2.cpp @@ -107,9 +107,9 @@ Uint32 SettingsPixelFormat() c = toupper(c); } - for (auto& format : formats) { - if (str.compare(format.name) == 0) { - return format.format; + for (int i = 0; i < ARRAY_SIZE(formats); i++) { + if (str.compare(formats[i].name) == 0) { + return formats[i].format; } } diff --git a/common/vqaaudio_openal.cpp b/common/vqaaudio_openal.cpp index 2cde67ad..258e0cdc 100644 --- a/common/vqaaudio_openal.cpp +++ b/common/vqaaudio_openal.cpp @@ -275,8 +275,8 @@ int VQA_StartAudio(VQAHandle* handle) audio->field_B0 = 0; audio->field_B4 = 0; - for (unsigned int AudioBuffer : audio->AudioBuffers) { - Queue_Audio(AudioBuffer); + for (unsigned i = 0; i < OPENAL_BUFFER_COUNT; ++i) { + Queue_Audio(audio->AudioBuffers[i]); } alSourcef(audio->OpenALSource, AL_GAIN, config->Volume / 256.0f); diff --git a/redalert/audio.cpp b/redalert/audio.cpp index 9c138b43..0651f0d9 100644 --- a/redalert/audio.cpp +++ b/redalert/audio.cpp @@ -722,8 +722,8 @@ void Speak_AI(void) ** speech buffers. */ void const* speech = NULL; - for (VoxType& index : SpeechRecord) { - if (index == SpeakQueue) + for (int index = 0; index < ARRAY_SIZE(SpeechRecord); index++) { + if (SpeechRecord[index] == SpeakQueue) break; } diff --git a/redalert/base.cpp b/redalert/base.cpp index bae07fb6..fae1ad9d 100644 --- a/redalert/base.cpp +++ b/redalert/base.cpp @@ -263,9 +263,9 @@ BuildingClass* BaseClass::Get_Building(int index) const obj[0] = Map[cell].Cell_Building(); int count = 1; - for (ObjectClass* xindex : Map[cell].Overlapper) { - if (xindex != NULL) { - obj[count++] = xindex; + for (int xindex = 0; xindex < ARRAY_SIZE(Map[cell].Overlapper); xindex++) { + if (Map[cell].Overlapper[xindex] != NULL) { + obj[count++] = Map[cell].Overlapper[xindex]; } } diff --git a/redalert/bdata.cpp b/redalert/bdata.cpp index 720c420b..68a1b705 100644 --- a/redalert/bdata.cpp +++ b/redalert/bdata.cpp @@ -3055,8 +3055,9 @@ void BuildingTypeClass::One_Time(void) /* ** Install all the special animation sequences for the different building types. */ - for (auto _anim : _anims) { - As_Reference(_anim.Class).Init_Anim(_anim.Stage, _anim.Start, _anim.Length, _anim.Rate); + for (unsigned index = 0; index < (sizeof(_anims) / sizeof(_anims[0])); index++) { + As_Reference(_anims[index].Class) + .Init_Anim(_anims[index].Stage, _anims[index].Start, _anims[index].Length, _anims[index].Rate); } } diff --git a/redalert/cell.cpp b/redalert/cell.cpp index 50326adf..b4ce29c9 100644 --- a/redalert/cell.cpp +++ b/redalert/cell.cpp @@ -132,8 +132,8 @@ CellClass::CellClass(void) Zones[zone] = 0; } Flag.Composite = 0; - for (ObjectClass* index : Overlapper) { - index = 0; + for (int index = 0; index < ARRAY_SIZE(Overlapper); index++) { + Overlapper[index] = 0; } } @@ -407,11 +407,12 @@ void CellClass::Redraw_Objects(bool forced) /* ** Flag any overlapping object in this cell to be redrawn. */ - for (ObjectClass* ptr : Overlapper) { - if (ptr) { - assert(ptr->IsActive); - if (ptr->Is_Techno() && ((TechnoClass*)ptr)->Visual_Character() != VISUAL_NORMAL) { - ptr->Mark(MARK_CHANGE); + for (int index = 0; index < ARRAY_SIZE(Overlapper); index++) { + if (Overlapper[index]) { + assert(Overlapper[index]->IsActive); + if (Overlapper[index]->Is_Techno() + && ((TechnoClass*)Overlapper[index])->Visual_Character() != VISUAL_NORMAL) { + Overlapper[index]->Mark(MARK_CHANGE); } } } @@ -816,9 +817,9 @@ void CellClass::Overlap_Up(ObjectClass* object) assert((unsigned)Cell_Number() <= MAP_CELL_TOTAL); assert(object != NULL && object->IsActive); - for (ObjectClass* ptr : Overlapper) { - if (ptr == object) { - ptr = 0; + for (int index = 0; index < ARRAY_SIZE(Overlapper); index++) { + if (Overlapper[index] == object) { + Overlapper[index] = 0; break; } } @@ -1300,8 +1301,8 @@ void CellClass::Draw_It(int x, int y, bool objects) const object->IsToDisplay = true; object = object->Next; } - for (ObjectClass* ptr : Overlapper) { - object = ptr; + for (int index = 0; index < ARRAY_SIZE(Overlapper); index++) { + object = Overlapper[index]; if (object != NULL && object->IsActive) { object->IsToDisplay = true; optr.Add(object); @@ -1631,8 +1632,8 @@ void CellClass::Wall_Update(void) static FacingType _offsets[5] = {FACING_N, FACING_E, FACING_S, FACING_W, FACING_NONE}; - for (FacingType& _offset : _offsets) { - CellClass* newcell = Adjacent_Cell(_offset); + for (unsigned index = 0; index < (sizeof(_offsets) / sizeof(_offsets[0])); index++) { + CellClass* newcell = Adjacent_Cell(_offsets[index]); if (newcell && newcell->Overlay != OVERLAY_NONE && OverlayTypeClass::As_Reference(newcell->Overlay).IsWall) { int icon = 0; diff --git a/redalert/dial8.cpp b/redalert/dial8.cpp index 240346c2..cb8462e7 100644 --- a/redalert/dial8.cpp +++ b/redalert/dial8.cpp @@ -245,8 +245,8 @@ int Dial8Class::Draw_Me(int forced) ** Draw background & decorations. */ Draw_Box(X, Y, Width, Height, BOXSTYLE_DOWN, true); - for (auto& i : FacePoint) { - Draw_Box(i[0] - 1, i[1] - 1, 3, 3, BOXSTYLE_RAISED, false); + for (int i = 0; i < 8; i++) { + Draw_Box(FacePoint[i][0] - 1, FacePoint[i][1] - 1, 3, 3, BOXSTYLE_RAISED, false); } /* diff --git a/redalert/egos.cpp b/redalert/egos.cpp index 3079f836..8f38090c 100644 --- a/redalert/egos.cpp +++ b/redalert/egos.cpp @@ -915,8 +915,8 @@ void Show_Who_Was_Responsible(void) Theme.Stop(); Options.Set_Score_Volume(oldvolume, false); - for (GraphicBufferClass* SlideBuffer : SlideBuffers) { - delete SlideBuffer; + for (int index = 0; index < NUM_SLIDES; index++) { + delete SlideBuffers[index]; } delete BackgroundPage; diff --git a/redalert/flasher.cpp b/redalert/flasher.cpp index 732cec1b..dfc44b45 100644 --- a/redalert/flasher.cpp +++ b/redalert/flasher.cpp @@ -78,9 +78,9 @@ void FlasherClass::Debug_Dump(MonoClass* mono) const bool FlasherClass::Process(void) { // 2019/09/20 JAS - Flashing info needs to exist per player - for (unsigned int& i : FlashCountPerPlayer) { - if (i) { - i--; + for (int i = 0; i < HOUSE_COUNT; i++) { + if (FlashCountPerPlayer[i]) { + FlashCountPerPlayer[i]--; } } diff --git a/redalert/foot.cpp b/redalert/foot.cpp index 62f55aeb..d2dd2f94 100644 --- a/redalert/foot.cpp +++ b/redalert/foot.cpp @@ -128,8 +128,8 @@ FootClass::FootClass(RTTIType rtti, int id, HousesType house) , HeadToCoord(0) { Path[0] = FACING_NONE; - for (long& index : NavQueue) { - index = TARGET_NONE; + for (int index = 0; index < ARRAY_SIZE(NavQueue); index++) { + NavQueue[index] = TARGET_NONE; } } @@ -935,8 +935,8 @@ void FootClass::Approach_Target(void) for (int range = maxrange; range > 0x0080; range -= 0x0100) { static int _angles[] = {0, 8, -8, 16, -16, 24, -24, 32, -32, 48, -48, 64, -64}; - for (int _angle : _angles) { - trycoord = Coord_Move(tcoord, (DirType)(dir + _angle), range); + for (int index = 0; index < (sizeof(_angles) / sizeof(_angles[0])); index++) { + trycoord = Coord_Move(tcoord, (DirType)(dir + _angles[index]), range); if (::Distance(trycoord, tcoord) < range) { trycell = Coord_Cell(trycoord); @@ -2354,9 +2354,9 @@ void FootClass::Handle_Navigation_List(void) ** target value from the first part to the end of the queue. */ if (IsNavQueueLoop) { - for (long& index : NavQueue) { - if (index == TARGET_NONE) { - index = target; + for (int index = 0; index < ARRAY_SIZE(NavQueue); index++) { + if (NavQueue[index] == TARGET_NONE) { + NavQueue[index] = target; break; } } @@ -2439,8 +2439,8 @@ void FootClass::Queue_Navigation_List(TARGET target) *=============================================================================================*/ void FootClass::Clear_Navigation_List(void) { - for (long& index : NavQueue) { - index = TARGET_NONE; + for (int index = 0; index < ARRAY_SIZE(NavQueue); index++) { + NavQueue[index] = TARGET_NONE; } } diff --git a/redalert/house.cpp b/redalert/house.cpp index 47efe03c..b38957a4 100644 --- a/redalert/house.cpp +++ b/redalert/house.cpp @@ -5521,9 +5521,9 @@ bool HouseClass::AI_Raise_Power(UrgencyType urgency) const ** Find a structure to sell and then sell it. Bail from further scanning until ** the next time. */ - for (auto& _type : _types) { - if (urgency >= _type.Urgency) { - BuildingClass* b = Find_Building(_type.Structure); + for (int i = 0; i < ARRAY_SIZE(_types); i++) { + if (urgency >= _types[i].Urgency) { + BuildingClass* b = Find_Building(_types[i].Structure); if (b != NULL) { b->Sell_Back(1); return (true); @@ -5582,9 +5582,9 @@ bool HouseClass::AI_Raise_Money(UrgencyType urgency) const ** Find a structure to sell and then sell it. Bail from further scanning until ** the next time. */ - for (auto& _type : _types) { - if (urgency >= _type.Urgency) { - b = Find_Building(_type.Structure); + for (int i = 0; i < ARRAY_SIZE(_types); i++) { + if (urgency >= _types[i].Urgency) { + b = Find_Building(_types[i].Structure); if (b != NULL) { b->Sell_Back(1); return (true); diff --git a/redalert/init.cpp b/redalert/init.cpp index 6e12349d..ac0a9308 100644 --- a/redalert/init.cpp +++ b/redalert/init.cpp @@ -375,11 +375,11 @@ bool Init_Game(int, char*[]) Session.GamesPlayed = 0; Session.NumScores = 0; Session.CurGame = 0; - for (MPlayerScoreType& i : Session.Score) { - i.Name[0] = '\0'; - i.Wins = 0; - for (int& Kill : i.Kills) { - Kill = -1; // -1 = this player didn't play this round + for (int i = 0; i < MAX_MULTI_NAMES; i++) { + Session.Score[i].Name[0] = '\0'; + Session.Score[i].Wins = 0; + for (int j = 0; j < MAX_MULTI_GAMES; j++) { + Session.Score[i].Kills[j] = -1; // -1 = this player didn't play this round } } @@ -2937,10 +2937,10 @@ void Free_Heaps(void) ** into a custom holding tank only as large as the largest speech file to ** be played. */ - for (auto& ptr : SpeechBuffer) { - if (ptr) { - delete[] ptr; - ptr = NULL; + for (int index = 0; index < ARRAY_SIZE(SpeechBuffer); index++) { + if (SpeechBuffer[index]) { + delete[] SpeechBuffer[index]; + SpeechBuffer[index] = NULL; } } diff --git a/redalert/iomap.cpp b/redalert/iomap.cpp index 7f8b13bb..6153df1d 100644 --- a/redalert/iomap.cpp +++ b/redalert/iomap.cpp @@ -131,11 +131,11 @@ void CellClass::Code_Pointers(void) OccupierPtr = (ObjectClass*)OccupierPtr->As_Target(); } - for (ObjectClass* ptr : Overlapper) { - if (ptr != NULL && ptr->IsActive) { - ptr = (ObjectClass*)ptr->As_Target(); + for (int index = 0; index < ARRAY_SIZE(Overlapper); index++) { + if (Overlapper[index] != NULL && Overlapper[index]->IsActive) { + Overlapper[index] = (ObjectClass*)Overlapper[index]->As_Target(); } else { - ptr = NULL; + Overlapper[index] = NULL; } } @@ -168,10 +168,10 @@ void CellClass::Decode_Pointers(void) assert(OccupierPtr != NULL); } - for (ObjectClass* index : Overlapper) { - if (index != NULL) { - index = As_Object((TARGET)index, false); - assert(index != NULL); + for (int index = 0; index < ARRAY_SIZE(Overlapper); index++) { + if (Overlapper[index] != NULL) { + Overlapper[index] = As_Object((TARGET)Overlapper[index], false); + assert(Overlapper[index] != NULL); } } diff --git a/redalert/map.cpp b/redalert/map.cpp index c51547e7..ded15ba3 100644 --- a/redalert/map.cpp +++ b/redalert/map.cpp @@ -435,8 +435,8 @@ void MapClass::Init_Clear(void) TiberiumGrowthExcess = 0; TiberiumSpreadCount = 0; TiberiumSpreadExcess = 0; - for (CrateClass& Crate : Crates) { - Crate.Init(); + for (int index = 0; index < ARRAY_SIZE(Crates); index++) { + Crates[index].Init(); } } @@ -1316,9 +1316,9 @@ void MapClass::Logic(void) ** Find any crate that has expired and then regenerate it at a new ** spot. */ - for (CrateClass& Crate : Crates) { - if (Crate.Is_Expired()) { - Crate.Remove_It(); + for (int index = 0; index < ARRAY_SIZE(Crates); index++) { + if (Crates[index].Is_Expired()) { + Crates[index].Remove_It(); Place_Random_Crate(); } } @@ -1531,9 +1531,9 @@ bool MapClass::Place_Random_Crate(void) bool MapClass::Remove_Crate(CELL cell) { if (Session.Type != GAME_NORMAL) { - for (CrateClass& Crate : Crates) { - if (Crate.Is_Here(cell)) { - return (Crate.Remove_It()); + for (int index = 0; index < ARRAY_SIZE(Crates); index++) { + if (Crates[index].Is_Here(cell)) { + return (Crates[index].Remove_It()); } } } @@ -1708,13 +1708,13 @@ ObjectClass* MapClass::Close_Object(COORDINATE coord) const */ static int _offsets[] = { 0, -1, 1, -MAP_CELL_W, MAP_CELL_W, MAP_CELL_W - 1, MAP_CELL_W + 1, -(MAP_CELL_W - 1), -(MAP_CELL_W + 1)}; - for (int _offset : _offsets) { + for (int index = 0; index < (sizeof(_offsets) / sizeof(_offsets[0])); index++) { /* ** Examine the cell for close object. Make sure that the cell actually is a ** legal one. */ - CELL newcell = cell + _offset; + CELL newcell = cell + _offsets[index]; if (In_Radar(newcell)) { /* diff --git a/redalert/msglist.cpp b/redalert/msglist.cpp index 00cc6aff..e121f027 100644 --- a/redalert/msglist.cpp +++ b/redalert/msglist.cpp @@ -279,8 +279,8 @@ void MessageListClass::Reset(void) //------------------------------------------------------------------------ // Mark all buffers as available //------------------------------------------------------------------------ - for (char& index : BufferAvail) { - index = 1; + for (int index = 0; index < MAX_NUM_MESSAGES; index++) { + BufferAvail[index] = 1; } //------------------------------------------------------------------------ diff --git a/redalert/scenario.cpp b/redalert/scenario.cpp index fcfb46a7..79e35049 100644 --- a/redalert/scenario.cpp +++ b/redalert/scenario.cpp @@ -173,8 +173,8 @@ ScenarioClass::ScenarioClass(void) #endif FadeTimer(0) { - for (short& index : Waypoint) { - index = -1; + for (int index = 0; index < ARRAY_SIZE(Waypoint); index++) { + Waypoint[index] = -1; } strcpy(Description, ""); strcpy(ScenarioName, ""); @@ -822,8 +822,8 @@ void Clear_Scenario(void) CurrentObject.Clear_All(); - for (short& index : Scen.Waypoint) { - index = -1; + for (int index = 0; index < WAYPT_COUNT; index++) { + Scen.Waypoint[index] = -1; } #ifdef FIXIT_VERSION_3 // For endgame auto-sonar pulse. @@ -2612,8 +2612,8 @@ bool Read_Scenario_INI(char* fname, bool) long start_x = 0; long start_y = 0; Map.Compute_Start_Pos(start_x, start_y); - for (short& View : Scen.Views) { - View = XY_Cell(start_x, start_y); + for (int i = 0; i < ARRAY_SIZE(Scen.Views); ++i) { + Scen.Views[i] = XY_Cell(start_x, start_y); } Scen.Waypoint[98] = XY_Cell(start_x, start_y); COORDINATE pos = Cell_Coord(XY_Cell(start_x, start_y)); diff --git a/redalert/score.cpp b/redalert/score.cpp index dbf93b86..de2f6faf 100644 --- a/redalert/score.cpp +++ b/redalert/score.cpp @@ -195,9 +195,9 @@ void ScorePrintClass::Update(void) 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F}; if (Stage && (((char*)DataPtr)[Stage - 1] == 0)) { - for (ScoreAnimClass* ScoreObj : ScoreObjs) { - if (ScoreObj == this) { - ScoreObj = 0; + for (int i = 0; i < MAXSCOREOBJS; i++) { + if (ScoreObjs[i] == this) { + ScoreObjs[i] = 0; } } delete this; @@ -278,9 +278,9 @@ void ScoreScaleClass::Update(void) Stage--; } else { Set_Font_Palette(Palette); - for (ScoreAnimClass* ScoreObj : ScoreObjs) { - if (ScoreObj == this) - ScoreObj = 0; + for (int i = 0; i < MAXSCOREOBJS; i++) { + if (ScoreObjs[i] == this) + ScoreObjs[i] = 0; } HidPage.Print((char*)DataPtr, XPos, YPos, TBLACK, TBLACK); HidPage.Blit(SeenPage, XPos, YPos, XPos, YPos, 6 * RESFACTOR, 6 * RESFACTOR); @@ -1637,9 +1637,9 @@ void Animate_Score_Objs() AllSurfaces.SurfacesRestored = false; PseudoSeenBuff->Blit(SeenPage); } - for (ScoreAnimClass* ScoreObj : ScoreObjs) { - if (ScoreObj) { - ScoreObj->Update(); + for (int i = 0; i < MAXSCOREOBJS; i++) { + if (ScoreObjs[i]) { + ScoreObjs[i]->Update(); } } } diff --git a/redalert/sidebar.cpp b/redalert/sidebar.cpp index c10872d3..707f74a0 100644 --- a/redalert/sidebar.cpp +++ b/redalert/sidebar.cpp @@ -1075,11 +1075,11 @@ SidebarClass::StripClass::StripClass(InitClass const&) , Slid(0) , BuildableCount(0) { - for (BuildType& Buildable : Buildables) { - Buildable.BuildableID = 0; - Buildable.BuildableType = RTTI_NONE; - Buildable.Factory = -1; - Buildable.BuildableViaCapture = false; // Added for new sidebar functionality. ST - 9/24/2019 3:10PM + for (int index = 0; index < MAX_BUILDABLES; index++) { + Buildables[index].BuildableID = 0; + Buildables[index].BuildableType = RTTI_NONE; + Buildables[index].Factory = -1; + Buildables[index].BuildableViaCapture = false; // Added for new sidebar functionality. ST - 9/24/2019 3:10PM } } @@ -1163,11 +1163,11 @@ void SidebarClass::StripClass::Init_Clear(void) /* ** Since we're resetting the strips, clear out all the buildables & factory pointers. */ - for (BuildType& Buildable : Buildables) { - Buildable.BuildableID = 0; - Buildable.BuildableType = RTTI_NONE; - Buildable.Factory = -1; - Buildable.BuildableViaCapture = false; // Added for new sidebar functionality. ST - 9/24/2019 3:10PM + for (int index = 0; index < MAX_BUILDABLES; index++) { + Buildables[index].BuildableID = 0; + Buildables[index].BuildableType = RTTI_NONE; + Buildables[index].Factory = -1; + Buildables[index].BuildableViaCapture = false; // Added for new sidebar functionality. ST - 9/24/2019 3:10PM } } diff --git a/redalert/teamtype.cpp b/redalert/teamtype.cpp index ad8cbd6c..8d003018 100644 --- a/redalert/teamtype.cpp +++ b/redalert/teamtype.cpp @@ -184,9 +184,9 @@ TeamTypeClass::TeamTypeClass(void) , MissionCount(0) , ClassCount(0) { - for (TeamMemberClass& Member : Members) { - Member.Class = NULL; - Member.Quantity = 0; + for (int i = 0; i < MAX_TEAM_CLASSCOUNT; i++) { + Members[i].Class = NULL; + Members[i].Quantity = 0; } } diff --git a/redalert/techno.cpp b/redalert/techno.cpp index 51a7911c..7b900916 100644 --- a/redalert/techno.cpp +++ b/redalert/techno.cpp @@ -162,7 +162,7 @@ const char* NewName[] = { "Fire Ant", "Feuer-Ameise", "Queen Ant", - "Ameisenk�nigin", + "Ameisenk”nigin", "ATS", "Angriffs-U-Boot", "Tesla Tank", @@ -188,7 +188,7 @@ const char* NewName[] = { "Scout Ant", "Fourmi de Reconnaissance", "Warrior Ant", - "Fourmi Guerri�re", + "Fourmi GuerriŠre", "Fire Ant", "Fourmi Lance-Flammes", "Queen Ant", @@ -204,11 +204,11 @@ const char* NewName[] = { "Stavros", "Stavros", "F-A Longbow", - "HAA (H�licopt�re d'Assaut Avanc�)", + "HAA (H‚licoptŠre d'Assaut Avanc‚)", "Civilian Specialist", - "Sp�cialiste Civil", + "Sp‚cialiste Civil", "Alloy Facility", - "Usine M�tallurgique", + "Usine M‚tallurgique", NULL, }; @@ -2463,8 +2463,8 @@ bool TechnoClass::Evaluate_Object(ThreatType method, FlashCountPerPlayer[house] = count; } else { // receiving HOUSE_COUNT means do it for every player - for (unsigned int& i : FlashCountPerPlayer) { - i = count; + for (int i = 0; i < HOUSE_COUNT; ++i) { + FlashCountPerPlayer[i] = count; } } } diff --git a/tests/face.cpp b/tests/face.cpp index ed4333d8..1b723d7c 100644 --- a/tests/face.cpp +++ b/tests/face.cpp @@ -5,7 +5,7 @@ int test_facings() { - struct Test_data + struct test_data { int l; int t; @@ -17,7 +17,7 @@ int test_facings() int ret = 0; - static const Test_data test_data[] = { + struct test_data test_data[] = { {0, 0, 0, 0, 255, 32}, {5, 5, 20, 20, 95, 96}, {-5, -5, 20, 20, 95, 96}, @@ -35,31 +35,33 @@ int test_facings() {9, 50, 50, 50, 63, 64}, }; - for (const Test_data& test : test_data) { - int out256 = Desired_Facing256(test.l, test.t, test.r, test.b); - int out8 = Desired_Facing8(test.l, test.t, test.r, test.b); + for (int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) { + struct test_data* test = &test_data[i]; - if (out256 != test.out256) { + int out256 = Desired_Facing256(test->l, test->t, test->r, test->b); + int out8 = Desired_Facing8(test->l, test->t, test->r, test->b); + + if (out256 != test->out256) { fprintf(stderr, "Desired_Facing256(%d, %d, %d, %d) -> %d, expected %d\n", - test.l, - test.t, - test.r, - test.b, + test->l, + test->t, + test->r, + test->b, out256, - test.out256); + test->out256); ret = 1; } - if (out8 != test.out8) { + if (out8 != test->out8) { fprintf(stderr, "Desired_Facing8(%d, %d, %d, %d) -> %d, expected %d\n", - test.l, - test.t, - test.r, - test.b, + test->l, + test->t, + test->r, + test->b, out8, - test.out8); + test->out8); ret = 1; } } diff --git a/tests/irandom.cpp b/tests/irandom.cpp index f1fbec80..ca06f9d3 100644 --- a/tests/irandom.cpp +++ b/tests/irandom.cpp @@ -11,13 +11,13 @@ int test_random() int ret = 0; RandNumb = 0x12349876; // Game defaults to this initial value, but randomises it normally. - static const unsigned char test_data[] = {139, 61, 111, 84, 109, 56}; + unsigned char test_data[] = {139, 61, 111, 84, 109, 56}; - for (unsigned char test : test_data) { + for (int i = 0; i < sizeof(test_data); i++) { int value = Random(); - if (value != test) { - fprintf(stderr, "Random() -> %u, expected %u\n", value, test); + if (value != test_data[i]) { + fprintf(stderr, "Random() -> %u, expected %u\n", value, test_data[i]); ret = 1; } } @@ -27,7 +27,7 @@ int test_random() int test_random_mask() { - struct Test_data + struct test_data { int max_val; int mask; @@ -35,7 +35,7 @@ int test_random_mask() int ret = 0; - static const Test_data test_data[] = { + struct test_data test_data[] = { {0, 1}, {1, 1}, {1234, 2047}, @@ -43,11 +43,13 @@ int test_random_mask() {123456, 131071}, }; - for (const Test_data& test : test_data) { - int mask = Get_Random_Mask(test.max_val); + for (int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) { + struct test_data* test = &test_data[i]; - if (mask != test.mask) { - fprintf(stderr, "Get_Random_Mask(%d) -> %d, expected %d\n", test.max_val, mask, test.mask); + int mask = Get_Random_Mask(test->max_val); + + if (mask != test->mask) { + fprintf(stderr, "Get_Random_Mask(%d) -> %d, expected %d\n", test->max_val, mask, test->mask); ret = 1; } } diff --git a/tests/miscasm.cpp b/tests/miscasm.cpp index 0406e978..b79ebcc9 100644 --- a/tests/miscasm.cpp +++ b/tests/miscasm.cpp @@ -6,7 +6,7 @@ int test_calcx_calcy() { - struct Test_data + struct test_data { int16_t a; int16_t b; @@ -16,7 +16,7 @@ int test_calcx_calcy() int ret = 0; - static const Test_data test_data[] = { + struct test_data test_data[] = { {0, 0, 0, 0}, {1000, 1000, 7812, -7812}, {3123, -827, 45358, -45358}, @@ -25,17 +25,19 @@ int test_calcx_calcy() {127, 304, 301, -301}, }; - for (const Test_data& test : test_data) { - int outx = calcx(test.a, test.b); - int outy = calcy(test.a, test.b); + for (int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) { + struct test_data* test = &test_data[i]; + + int outx = calcx(test->a, test->b); + int outy = calcy(test->a, test->b); - if (outx != test.outx) { - fprintf(stderr, "calcx(%d, %d) -> %d, expected %d\n", test.a, test.b, outx, test.outx); + if (outx != test->outx) { + fprintf(stderr, "calcx(%d, %d) -> %d, expected %d\n", test->a, test->b, outx, test->outx); ret = 1; } - if (outy != test.outy) { - fprintf(stderr, "calcy(%d, %d) -> %d, expected %d\n", test.a, test.b, outy, test.outy); + if (outy != test->outy) { + fprintf(stderr, "calcy(%d, %d) -> %d, expected %d\n", test->a, test->b, outy, test->outy); ret = 1; } } @@ -45,7 +47,7 @@ int test_calcx_calcy() int test_fixed_cardinal() { - struct Test_data + struct test_data { int16_t a; int16_t b; @@ -55,7 +57,7 @@ int test_fixed_cardinal() int ret = 0; - static const Test_data test_data[] = { + struct test_data test_data[] = { {0, 0, 65535, 0}, {1000, 1000, 256, 3906}, {3123, -827, 1375201, 65535}, @@ -63,17 +65,19 @@ int test_fixed_cardinal() {-1, -1, 0, 0}, }; - for (const Test_data& test : test_data) { - int outx = Cardinal_To_Fixed(test.a, test.b); - int outy = Fixed_To_Cardinal(test.a, test.b); + for (int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) { + struct test_data* test = &test_data[i]; + + int outx = Cardinal_To_Fixed(test->a, test->b); + int outy = Fixed_To_Cardinal(test->a, test->b); - if (outx != test.outx) { - fprintf(stderr, "Cardinal_To_Fixed(%d, %d) -> %d, expected %d\n", test.a, test.b, outx, test.outx); + if (outx != test->outx) { + fprintf(stderr, "Cardinal_To_Fixed(%d, %d) -> %d, expected %d\n", test->a, test->b, outx, test->outx); ret = 1; } - if (outy != test.outy) { - fprintf(stderr, "Fixed_To_Cardinal(%d, %d) -> %d, expected %d\n", test.a, test.b, outy, test.outy); + if (outy != test->outy) { + fprintf(stderr, "Fixed_To_Cardinal(%d, %d) -> %d, expected %d\n", test->a, test->b, outy, test->outy); ret = 1; } } diff --git a/tests/rect.cpp b/tests/rect.cpp index f5258b27..fc91a73b 100644 --- a/tests/rect.cpp +++ b/tests/rect.cpp @@ -5,7 +5,7 @@ int test_rect() { - struct Test_data + struct test_data { Rect rect; int width; @@ -18,7 +18,7 @@ int test_rect() int ret = 0; - static const Test_data test_data[] = { + struct test_data test_data[] = { {{-5, -5, 4, 4}, 10, 10, -1, {-5, -5, 4, 4}, 1, {0, 0, 4, 4}}, {{15, 15, 4, 4}, 10, 10, -1, {15, 15, 4, 4}, 1, {6, 6, 4, 4}}, {{-5, -5, 10, 10}, 10, 10, 1, {0, 0, 5, 5}, 1, {0, 0, 10, 10}}, @@ -30,55 +30,61 @@ int test_rect() {{-2, -2, 15, 15}, 10, 10, 1, {0, 0, 10, 10}, 1, {0, 0, 15, 15}}, }; - for (const Test_data& test : test_data) { - Rect outClipRect = test.rect; - int outClip = - Clip_Rect(&outClipRect.X, &outClipRect.Y, &outClipRect.Width, &outClipRect.Height, test.width, test.height); - Rect outConfineRect = test.rect; - int outConfine = Confine_Rect( - &outConfineRect.X, &outConfineRect.Y, outConfineRect.Width, outConfineRect.Height, test.width, test.height); + for (int i = 0; i < sizeof(test_data) / sizeof(test_data[0]); i++) { + struct test_data* test = &test_data[i]; - if ((outClip != test.outClip) || (outClipRect != test.outClipRect)) { + Rect outClipRect = test->rect; + int outClip = Clip_Rect( + &outClipRect.X, &outClipRect.Y, &outClipRect.Width, &outClipRect.Height, test->width, test->height); + Rect outConfineRect = test->rect; + int outConfine = Confine_Rect(&outConfineRect.X, + &outConfineRect.Y, + outConfineRect.Width, + outConfineRect.Height, + test->width, + test->height); + + if ((outClip != test->outClip) || (outClipRect != test->outClipRect)) { fprintf(stderr, "Clip_Rect(%d, %d, %d, %d, %d, %d) -> %d (%d, %d, %d, %d), expected %d (%d, %d, %d, %d)\n", - test.rect.X, - test.rect.Y, - test.rect.Width, - test.rect.Height, - test.width, - test.height, + test->rect.X, + test->rect.Y, + test->rect.Width, + test->rect.Height, + test->width, + test->height, outClip, outClipRect.X, outClipRect.Y, outClipRect.Width, outClipRect.Height, - test.outClip, - test.outClipRect.X, - test.outClipRect.Y, - test.outClipRect.Width, - test.outClipRect.Height); + test->outClip, + test->outClipRect.X, + test->outClipRect.Y, + test->outClipRect.Width, + test->outClipRect.Height); ret = 1; } - if ((outConfine != test.outConfine) || (outConfineRect != test.outConfineRect)) { + if ((outConfine != test->outConfine) || (outConfineRect != test->outConfineRect)) { fprintf(stderr, "Confine_Rect(%d, %d, %d, %d, %d, %d) -> %d (%d, %d, %d, %d), expected %d (%d, %d, %d, %d)\n", - test.rect.X, - test.rect.Y, - test.rect.Width, - test.rect.Height, - test.width, - test.height, + test->rect.X, + test->rect.Y, + test->rect.Width, + test->rect.Height, + test->width, + test->height, outConfine, outConfineRect.X, outConfineRect.Y, outConfineRect.Width, outConfineRect.Height, - test.outConfine, - test.outConfineRect.X, - test.outConfineRect.Y, - test.outConfineRect.Width, - test.outConfineRect.Height); + test->outConfine, + test->outConfineRect.X, + test->outConfineRect.Y, + test->outConfineRect.Width, + test->outConfineRect.Height); ret = 1; } } diff --git a/tiberiandawn/base.cpp b/tiberiandawn/base.cpp index ae3886e8..28009830 100644 --- a/tiberiandawn/base.cpp +++ b/tiberiandawn/base.cpp @@ -401,11 +401,11 @@ BuildingClass* BaseClass::Get_Building(int index) obj[3] = Map[cell].Overlapper[2]; bldg = NULL; - for (ObjectClass* ptr : obj) { - if (ptr && ptr->Coord == Nodes[index].Coord && ptr->What_Am_I() == RTTI_BUILDING - && ((BuildingClass*)ptr)->Class->Type == Nodes[index].Type) { + for (int i = 0; i < 4; i++) { + if (obj[i] && obj[i]->Coord == Nodes[index].Coord && obj[i]->What_Am_I() == RTTI_BUILDING + && ((BuildingClass*)obj[i])->Class->Type == Nodes[index].Type) { - bldg = (BuildingClass*)ptr; + bldg = (BuildingClass*)obj[i]; break; } } diff --git a/tiberiandawn/bdata.cpp b/tiberiandawn/bdata.cpp index 0db876fd..903f6a59 100644 --- a/tiberiandawn/bdata.cpp +++ b/tiberiandawn/bdata.cpp @@ -3863,10 +3863,10 @@ void BuildingTypeClass::One_Time(void) /* ** Install all the special animation sequences for the different building types. */ - for (auto _anim : _anims) { - BuildingTypeClass const* b = &As_Reference(_anim.Class); + for (unsigned index = 0; index < (sizeof(_anims) / sizeof(_anims[0])); index++) { + BuildingTypeClass const* b = &As_Reference(_anims[index].Class); if (b) { - b->Init_Anim(_anim.Stage, _anim.Start, _anim.Length, _anim.Rate); + b->Init_Anim(_anims[index].Stage, _anims[index].Start, _anims[index].Length, _anims[index].Rate); } } } diff --git a/tiberiandawn/cell.cpp b/tiberiandawn/cell.cpp index 0cfd24ef..4883146d 100644 --- a/tiberiandawn/cell.cpp +++ b/tiberiandawn/cell.cpp @@ -390,12 +390,12 @@ void CellClass::Redraw_Objects(bool forced) /* ** Flag any overlapping object in this cell to be redrawn. */ - for (ObjectClass* ptr : Overlapper) { - if (ptr) { - if (!ptr->IsActive) { - ptr = 0; + for (int index = 0; index < sizeof(Overlapper) / sizeof(Overlapper[0]); index++) { + if (Overlapper[index]) { + if (!Overlapper[index]->IsActive) { + Overlapper[index] = 0; } else { - ptr->Mark(MARK_CHANGE); + Overlapper[index]->Mark(MARK_CHANGE); } } } @@ -783,9 +783,9 @@ void CellClass::Overlap_Down(ObjectClass* object) void CellClass::Overlap_Up(ObjectClass* object) { Validate(); - for (ObjectClass* ptr : Overlapper) { - if (ptr == object) { - ptr = 0; + for (int index = 0; index < sizeof(Overlapper) / sizeof(Overlapper[0]); index++) { + if (Overlapper[index] == object) { + Overlapper[index] = 0; break; } } @@ -1417,8 +1417,8 @@ void CellClass::Wall_Update(void) return; } - for (FacingType& _offset : _offsets) { - CellClass* newcell = Adjacent_Cell(_offset); + for (unsigned index = 0; index < (sizeof(_offsets) / sizeof(_offsets[0])); index++) { + CellClass* newcell = Adjacent_Cell(_offsets[index]); if (newcell && newcell->Overlay != OVERLAY_NONE && OverlayTypeClass::As_Reference(newcell->Overlay).IsWall) { int icon = 0; diff --git a/tiberiandawn/conquer.cpp b/tiberiandawn/conquer.cpp index 284fb681..57fa9a92 100644 --- a/tiberiandawn/conquer.cpp +++ b/tiberiandawn/conquer.cpp @@ -1973,10 +1973,10 @@ int Load_Interpolated_Palettes(char const* filename, bool add) void Free_Interpolated_Palettes(void) { - for (auto& InterpolatedPalette : InterpolatedPalettes) { - if (InterpolatedPalette) { - free(InterpolatedPalette); - InterpolatedPalette = NULL; + for (int i = 0; i < ARRAY_SIZE(InterpolatedPalettes); i++) { + if (InterpolatedPalettes[i]) { + free(InterpolatedPalettes[i]); + InterpolatedPalettes[i] = NULL; } } } diff --git a/tiberiandawn/dial8.cpp b/tiberiandawn/dial8.cpp index d709242d..05a404f1 100644 --- a/tiberiandawn/dial8.cpp +++ b/tiberiandawn/dial8.cpp @@ -242,8 +242,8 @@ int Dial8Class::Draw_Me(int forced) ** Draw background & decorations. */ Draw_Box(X, Y, Width, Height, BOXSTYLE_GREEN_DOWN, true); - for (auto& i : FacePoint) { - Draw_Box(i[0] - 1, i[1] - 1, 3, 3, BOXSTYLE_GREEN_RAISED, false); + for (int i = 0; i < 8; i++) { + Draw_Box(FacePoint[i][0] - 1, FacePoint[i][1] - 1, 3, 3, BOXSTYLE_GREEN_RAISED, false); } /* diff --git a/tiberiandawn/ending.cpp b/tiberiandawn/ending.cpp index 0ed700f3..96a3d2e7 100644 --- a/tiberiandawn/ending.cpp +++ b/tiberiandawn/ending.cpp @@ -207,10 +207,10 @@ void Nod_Ending(void) #endif // NOT_FOR_WIN95 /* get rid of all the animating objects */ - for (ScoreAnimClass* ScoreObj : ScoreObjs) - if (ScoreObj) { - delete ScoreObj; - ScoreObj = 0; + for (int i = 0; i < MAXSCOREOBJS; i++) + if (ScoreObjs[i]) { + delete ScoreObjs[i]; + ScoreObjs[i] = 0; } // erase the "choose a target" text SeenBuff.Fill_Rect(0, 180 * 2, 319 * 2, 199 * 2, 0); diff --git a/tiberiandawn/flasher.cpp b/tiberiandawn/flasher.cpp index 16d342c1..05e581f5 100644 --- a/tiberiandawn/flasher.cpp +++ b/tiberiandawn/flasher.cpp @@ -78,9 +78,9 @@ void FlasherClass::Debug_Dump(MonoClass* mono) const bool FlasherClass::Process(void) { // 2019/09/20 JAS - Flashing info needs to exist per player - for (unsigned int& i : FlashCountPerPlayer) { - if (i) { - i--; + for (int i = 0; i < HOUSE_COUNT; i++) { + if (FlashCountPerPlayer[i]) { + FlashCountPerPlayer[i]--; } } diff --git a/tiberiandawn/foot.cpp b/tiberiandawn/foot.cpp index 18a006eb..e3e75038 100644 --- a/tiberiandawn/foot.cpp +++ b/tiberiandawn/foot.cpp @@ -368,10 +368,10 @@ bool FootClass::Basic_Path(void) static int _faceadjust[8] = {0, 1, -1, 2, -2, 3, -3, 4}; FacingType f2 = (FacingType)(((unsigned)::Direction(cell, Coord_Cell(Coord))) >> 5); - for (int index : _faceadjust) { + for (unsigned index = 0; index < (sizeof(_faceadjust) / sizeof(_faceadjust[0])); index++) { CELL cell2; - cell2 = Adjacent_Cell(cell, (FacingType)((f2 + index) & 0x7)); + cell2 = Adjacent_Cell(cell, (FacingType)((f2 + _faceadjust[index]) & 0x7)); if (Can_Enter_Cell(cell2, FACING_NONE) <= MOVE_CLOAK) { cell = cell2; break; @@ -923,8 +923,8 @@ void FootClass::Approach_Target(void) for (int range = maxrange; range > 0x0080; range -= 0x0100) { static int _angles[] = {0, 8, -8, 16, -16, 24, -24, 32, -32, 48, -48, 64, -64}; - for (int _angle : _angles) { - trycoord = Coord_Move(tcoord, (DirType)(dir + _angle), range); + for (int index = 0; index < (sizeof(_angles) / sizeof(_angles[0])); index++) { + trycoord = Coord_Move(tcoord, (DirType)(dir + _angles[index]), range); if (::Distance(trycoord, tcoord) < range) { trycell = Coord_Cell(trycoord); diff --git a/tiberiandawn/house.cpp b/tiberiandawn/house.cpp index 9b1f7058..a3c30b9d 100644 --- a/tiberiandawn/house.cpp +++ b/tiberiandawn/house.cpp @@ -5990,9 +5990,9 @@ bool HouseClass::AI_Raise_Power(UrgencyType urgency) const ** Find a structure to sell and then sell it. Bail from further scanning until ** the next time. */ - for (auto& _type : _types) { - if (urgency >= _type.Urgency) { - BuildingClass* b = Find_Building(_type.Structure); + for (int i = 0; i < ARRAY_SIZE(_types); i++) { + if (urgency >= _types[i].Urgency) { + BuildingClass* b = Find_Building(_types[i].Structure); if (b != NULL) { b->Sell_Back(1); return (true); @@ -6072,9 +6072,9 @@ bool HouseClass::AI_Raise_Money(UrgencyType urgency) const ** Find a structure to sell and then sell it. Bail from further scanning until ** the next time. */ - for (auto& _type : _types) { - if (urgency >= _type.Urgency) { - b = Find_Building(_type.Structure); + for (int i = 0; i < ARRAY_SIZE(_types); i++) { + if (urgency >= _types[i].Urgency) { + b = Find_Building(_types[i].Structure); if (b != NULL) { b->Sell_Back(1); return (true); diff --git a/tiberiandawn/idata.cpp b/tiberiandawn/idata.cpp index acffe0ac..a48a2f3d 100644 --- a/tiberiandawn/idata.cpp +++ b/tiberiandawn/idata.cpp @@ -1537,10 +1537,10 @@ InfantryTypeClass::InfantryTypeClass(InfantryType type, ** Set the animation sequence custom values. */ - for (DoInfoStruct& DoControl : DoControls) { - DoControl.Frame = *do_table++; - DoControl.Count = *do_table++; - DoControl.Jump = *do_table++; + for (int i = 0; i < DO_COUNT; i++) { + DoControls[i].Frame = *do_table++; + DoControls[i].Count = *do_table++; + DoControls[i].Jump = *do_table++; } #ifdef cuts // ST - 10/3/95 10:09AM diff --git a/tiberiandawn/intro.cpp b/tiberiandawn/intro.cpp index 917ba705..0db6fd80 100644 --- a/tiberiandawn/intro.cpp +++ b/tiberiandawn/intro.cpp @@ -203,8 +203,8 @@ void Choose_Side(void) /* keep the mouse hidden until the letters are thru printing */ if (!lettersdone) { lettersdone = true; - for (ScoreAnimClass* ScoreObj : ScoreObjs) - if (ScoreObj) + for (int i = 0; i < MAXSCOREOBJS; i++) + if (ScoreObjs[i]) lettersdone = 0; if (lettersdone) { Show_Mouse(); @@ -292,10 +292,10 @@ void Choose_Side(void) Free_Interpolated_Palettes(); Set_Primary_Buffer_Format(); /* get rid of all the animating objects */ - for (ScoreAnimClass* ScoreObj : ScoreObjs) - if (ScoreObj) { - delete ScoreObj; - ScoreObj = 0; + for (int i = 0; i < MAXSCOREOBJS; i++) + if (ScoreObjs[i]) { + delete ScoreObjs[i]; + ScoreObjs[i] = 0; } if (Whom == HOUSE_GOOD) { diff --git a/tiberiandawn/iomap.cpp b/tiberiandawn/iomap.cpp index a181796f..c57d8224 100644 --- a/tiberiandawn/iomap.cpp +++ b/tiberiandawn/iomap.cpp @@ -732,8 +732,8 @@ void PowerClass::Decode_Pointers(void) *=============================================================================================*/ void SidebarClass::Code_Pointers(void) { - for (auto& i : Column) { - i.Code_Pointers(); + for (int i = 0; i < COLUMNS; i++) { + Column[i].Code_Pointers(); } PowerClass::Code_Pointers(); @@ -759,8 +759,8 @@ void SidebarClass::Code_Pointers(void) *=============================================================================================*/ void SidebarClass::Decode_Pointers(void) { - for (auto& i : Column) { - i.Decode_Pointers(); + for (int i = 0; i < COLUMNS; i++) { + Column[i].Decode_Pointers(); } PowerClass::Decode_Pointers(); diff --git a/tiberiandawn/map.cpp b/tiberiandawn/map.cpp index ac887970..497173d9 100644 --- a/tiberiandawn/map.cpp +++ b/tiberiandawn/map.cpp @@ -1872,13 +1872,13 @@ ObjectClass* MapClass::Close_Object(COORDINATE coord) const */ static int _offsets[] = { 0, -1, 1, -MAP_CELL_W, MAP_CELL_W, MAP_CELL_W - 1, MAP_CELL_W + 1, -(MAP_CELL_W - 1), -(MAP_CELL_W + 1)}; - for (int _offset : _offsets) { + for (int index = 0; index < (sizeof(_offsets) / sizeof(_offsets[0])); index++) { /* ** Examine the cell for close object. Make sure that the cell actually is a ** legal one. */ - CELL newcell = cell + _offset; + CELL newcell = cell + _offsets[index]; if (In_Radar(newcell)) { /* diff --git a/tiberiandawn/mapsel.cpp b/tiberiandawn/mapsel.cpp index 87c3087c..f0672f85 100644 --- a/tiberiandawn/mapsel.cpp +++ b/tiberiandawn/mapsel.cpp @@ -1309,8 +1309,8 @@ void Print_Statistics(int country, int xpos, int ypos) int done = 0; while (!done) { done = 1; - for (ScoreAnimClass* ScoreObj : ScoreObjs) - if (ScoreObj) { + for (int x = 0; x < MAXSCOREOBJS; x++) + if (ScoreObjs[x]) { done = 0; Call_Back_Delay(1); } diff --git a/tiberiandawn/overlay.cpp b/tiberiandawn/overlay.cpp index 45c53fa3..90ef69c6 100644 --- a/tiberiandawn/overlay.cpp +++ b/tiberiandawn/overlay.cpp @@ -303,8 +303,8 @@ bool OverlayClass::Mark(MarkType mark) */ static FacingType _face[4] = {FACING_N, FACING_E, FACING_S, FACING_W}; - for (FacingType& index : _face) { - CellClass* adjcell = cellptr->Adjacent_Cell(index); + for (int index = 0; index < (sizeof(_face) / sizeof(_face[0])); index++) { + CellClass* adjcell = cellptr->Adjacent_Cell(_face[index]); if (adjcell) adjcell->Concrete_Calc(); } diff --git a/tiberiandawn/scenarioini.cpp b/tiberiandawn/scenarioini.cpp index 800dc37b..f61b5dc8 100644 --- a/tiberiandawn/scenarioini.cpp +++ b/tiberiandawn/scenarioini.cpp @@ -631,8 +631,8 @@ bool Read_Scenario_Ini(char* root, bool fresh) long start_x = 0; long start_y = 0; Map.Compute_Start_Pos(start_x, start_y); - for (short& View : Views) { - View = XY_Cell(start_x, start_y); + for (int i = 0; i < ARRAY_SIZE(Views); ++i) { + Views[i] = XY_Cell(start_x, start_y); } Waypoint[27] = XY_Cell(start_x, start_y); COORDINATE pos = Cell_Coord(XY_Cell(start_x, start_y)); diff --git a/tiberiandawn/score.cpp b/tiberiandawn/score.cpp index edba600c..74f6986f 100644 --- a/tiberiandawn/score.cpp +++ b/tiberiandawn/score.cpp @@ -281,9 +281,9 @@ void ScorePrintClass::Update(void) 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F}; if (Stage && (((char*)DataPtr)[Stage - 1] == 0)) { - for (ScoreAnimClass* ScoreObj : ScoreObjs) { - if (ScoreObj == this) { - ScoreObj = 0; + for (int i = 0; i < MAXSCOREOBJS; i++) { + if (ScoreObjs[i] == this) { + ScoreObjs[i] = 0; } } BlitList.Add(XPos * 2, YPos * 2, XPos * 2, YPos * 2, (Stage * 6) + 14, 8 * 2); @@ -362,9 +362,9 @@ void MultiStagePrintClass::Update(void) 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F}; if (Stage && (((char*)DataPtr)[Stage - 1] == 0)) { - for (ScoreAnimClass* ScoreObj : ScoreObjs) { - if (ScoreObj == this) { - ScoreObj = 0; + for (int i = 0; i < MAXSCOREOBJS; i++) { + if (ScoreObjs[i] == this) { + ScoreObjs[i] = 0; } } BlitList.Add(XPos * 2, YPos * 2, XPos * 2, YPos * 2, (Stage * 6) + 14, 8 * 2); @@ -470,9 +470,9 @@ void ScoreScaleClass::Update(void) Stage--; } else { Set_Font_Palette(Palette); - for (ScoreAnimClass* ScoreObj : ScoreObjs) { - if (ScoreObj == this) - ScoreObj = 0; + for (int i = 0; i < MAXSCOREOBJS; i++) { + if (ScoreObjs[i] == this) + ScoreObjs[i] = 0; } TextPrintBuffer->Print((char*)DataPtr, XPos * 2, YPos * 2, TBLACK, TBLACK); // TextPrintBuffer->Blit(HidPage, XPos*2, YPos*2, XPos*2, YPos*2,2*6,2*6); @@ -1898,9 +1898,9 @@ void Call_Back_Delay(int time) void Animate_Score_Objs() { StillUpdating = false; - for (ScoreAnimClass* ScoreObj : ScoreObjs) { - if (ScoreObj) { - ScoreObj->Update(); + for (int i = 0; i < MAXSCOREOBJS; i++) { + if (ScoreObjs[i]) { + ScoreObjs[i]->Update(); } } } diff --git a/tiberiandawn/sidebar.cpp b/tiberiandawn/sidebar.cpp index 0ca1c2a2..8f981be1 100644 --- a/tiberiandawn/sidebar.cpp +++ b/tiberiandawn/sidebar.cpp @@ -1049,11 +1049,11 @@ SidebarClass::StripClass::StripClass(InitClass const&) , Slid(0) , BuildableCount(0) { - for (BuildType& Buildable : Buildables) { - Buildable.BuildableID = 0; - Buildable.BuildableType = RTTI_NONE; - Buildable.Factory = -1; - Buildable.BuildableViaCapture = false; // Added for new sidebar functionality. ST - 9/24/2019 3:10PM + for (int index = 0; index < MAX_BUILDABLES; index++) { + Buildables[index].BuildableID = 0; + Buildables[index].BuildableType = RTTI_NONE; + Buildables[index].Factory = -1; + Buildables[index].BuildableViaCapture = false; // Added for new sidebar functionality. ST - 9/24/2019 3:10PM } } @@ -1148,11 +1148,11 @@ void SidebarClass::StripClass::Init_Clear(void) /* ** Since we're resetting the strips, clear out all the buildables & factory pointers. */ - for (BuildType& Buildable : Buildables) { - Buildable.BuildableID = 0; - Buildable.BuildableType = RTTI_NONE; - Buildable.Factory = -1; - Buildable.BuildableViaCapture = false; // Added for new sidebar functionality. ST - 9/24/2019 3:10PM + for (int index = 0; index < MAX_BUILDABLES; index++) { + Buildables[index].BuildableID = 0; + Buildables[index].BuildableType = RTTI_NONE; + Buildables[index].Factory = -1; + Buildables[index].BuildableViaCapture = false; // Added for new sidebar functionality. ST - 9/24/2019 3:10PM } } diff --git a/tiberiandawn/techno.cpp b/tiberiandawn/techno.cpp index 6be0d905..44dcbf49 100644 --- a/tiberiandawn/techno.cpp +++ b/tiberiandawn/techno.cpp @@ -1868,8 +1868,8 @@ void TechnoClass::Clicked_As_Target(HousesType house, FlashCountPerPlayer[house] = count; } else { // receiving HOUSE_COUNT means do it for every player - for (unsigned int& i : FlashCountPerPlayer) { - i = count; + for (int i = 0; i < HOUSE_COUNT; ++i) { + FlashCountPerPlayer[i] = count; } } } From d13e88dd4b0338799620072f3e40cc14f5cf63b0 Mon Sep 17 00:00:00 2001 From: JohnsterID <69278611+JohnsterID@users.noreply.github.com> Date: Sun, 2 May 2021 17:36:53 +1000 Subject: [PATCH 03/15] Replace TD freeware links Replace fileplanet links with moddb links to avoid potential issues with fileplanet as reported on discord. https://discord.com/channels/409121752921276426/768522258993119262/835164657362010152 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b60244c0..93c44bac 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Binary releases of the latest commit are available from [here](https://github.co Copy the Vanilla executable (`vanillatd.exe` or `vanillara.exe`) to your legacy game directory, on Windows also copy `SDL2.dll` and `OpenAL32.dll`. -For Tiberian Dawn the final freeware Gold CD release ([GDI](https://www.fileplanet.com/archive/p-63497/Command-Conquer-Gold), [NOD](https://www.fileplanet.com/archive/p-8778/Command-Conquer-Gold)) works fine. +For Tiberian Dawn the final freeware Gold CD release ([GDI](https://www.moddb.com/games/cc-gold/downloads/command-conquer-gold-free-game-gdi-iso), [NOD](https://www.moddb.com/games/cc-gold/downloads/command-conquer-gold-free-game-nod-iso)) works fine. For Red Alert the freeware [CD release](https://web.archive.org/web/20080901183216/http://www.ea.com/redalert/news-detail.jsp?id=62) works fine as well. The official [Red Alert demo](https://www.moddb.com/games/cc-red-alert/downloads/command-conquer-red-alert-demo) is also fully playable. From d3ffd962c84fa12485a9917eb1a1f798606f3e6b Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Thu, 29 Apr 2021 22:41:50 +0100 Subject: [PATCH 04/15] Silences several type conversion warnings in MSVC. --- common/filepcx.cpp | 2 +- common/mixfile.h | 2 +- common/mp.cpp | 2 +- common/smartptr.h | 6 ++++-- redalert/building.cpp | 2 +- redalert/edit.cpp | 4 ++-- redalert/egos.cpp | 4 ++-- redalert/msglist.cpp | 12 ++++++------ tiberiandawn/building.cpp | 4 +--- tiberiandawn/conquer.cpp | 2 +- tiberiandawn/display.cpp | 2 +- tiberiandawn/house.cpp | 12 ++++++------ tiberiandawn/infantry.cpp | 2 -- tiberiandawn/init.cpp | 4 ++-- tiberiandawn/monoc.h | 4 +++- tiberiandawn/msglist.cpp | 2 +- tiberiandawn/overlay.cpp | 2 -- tiberiandawn/reinf.cpp | 2 +- 18 files changed, 34 insertions(+), 36 deletions(-) diff --git a/common/filepcx.cpp b/common/filepcx.cpp index 41ecaafa..349f1fae 100644 --- a/common/filepcx.cpp +++ b/common/filepcx.cpp @@ -309,5 +309,5 @@ void Write_Pcx_ScanLine(int file_handle, int scansize, unsigned char* ptr) } } - Write_File(file_handle, pool, (intptr_t)file_ptr - (intptr_t)pool); + Write_File(file_handle, pool, unsigned((intptr_t)file_ptr - (intptr_t)pool)); } diff --git a/common/mixfile.h b/common/mixfile.h index 084b5dd6..779552a0 100644 --- a/common/mixfile.h +++ b/common/mixfile.h @@ -738,7 +738,7 @@ bool MixFileClass::Offset(char const* filename, void** realptr, MixFileClass* char filename_upper[_MAX_PATH]; strcpy(filename_upper, filename); strupr(filename_upper); - int32_t crc = Calculate_CRC(strupr(filename_upper), strlen(filename_upper)); + int32_t crc = Calculate_CRC(strupr(filename_upper), int(strlen(filename_upper))); SubBlock key; key.CRC = crc; diff --git a/common/mp.cpp b/common/mp.cpp index c6c76aa4..f2af8a46 100644 --- a/common/mp.cpp +++ b/common/mp.cpp @@ -1643,7 +1643,7 @@ void XMP_Decode_ASCII(char const* str, digit* mpn, int precision) */ if (!str) return; - int i = strlen(str); + int i = (int)strlen(str); if (i == 0) return; diff --git a/common/smartptr.h b/common/smartptr.h index 4b00cb16..108d498e 100644 --- a/common/smartptr.h +++ b/common/smartptr.h @@ -15,6 +15,8 @@ #pragma once +#include + template class SmartPtr { public: @@ -39,9 +41,9 @@ template class SmartPtr return (Pointer); } - operator long(void) const + operator intptr_t(void) const { - return ((long)Pointer); + return ((intptr_t)Pointer); } SmartPtr operator++(int) diff --git a/redalert/building.cpp b/redalert/building.cpp index 91f5e10e..0a09eff7 100644 --- a/redalert/building.cpp +++ b/redalert/building.cpp @@ -3181,7 +3181,7 @@ bool BuildingClass::Toggle_Primary(void) // if ((HouseClass *)House == PlayerPtr) { // Speak(VOX_PRIMARY_SELECTED); // } - if ((HouseClass*)House->IsHuman) { + if (House->IsHuman) { Speak(VOX_PRIMARY_SELECTED, House); } } diff --git a/redalert/edit.cpp b/redalert/edit.cpp index 86a6defb..9f6278f8 100644 --- a/redalert/edit.cpp +++ b/redalert/edit.cpp @@ -144,7 +144,7 @@ void EditClass::Set_Text(char* text, int max_len) { String = text; MaxLength = max_len - 1; - Length = strlen(String); + Length = int(strlen(String)); Flag_To_Redraw(); } @@ -449,7 +449,7 @@ void EditClass::Set_Focus(void) { Length = 0; if (String) { - Length = strlen(String); + Length = int(strlen(String)); } ControlClass::Set_Focus(); } diff --git a/redalert/egos.cpp b/redalert/egos.cpp index 8f38090c..a22d4e16 100644 --- a/redalert/egos.cpp +++ b/redalert/egos.cpp @@ -605,8 +605,8 @@ void Show_Who_Was_Responsible(void) ** Fix up our outer loop parsing variables. */ cptr = strparse; - column += strparse - strstart; - length -= strparse - strstart - 1; + column += int(strparse - strstart); + length -= int(strparse - strstart - 1); if (ch == 13) { line++; diff --git a/redalert/msglist.cpp b/redalert/msglist.cpp index e121f027..1c824739 100644 --- a/redalert/msglist.cpp +++ b/redalert/msglist.cpp @@ -364,7 +364,7 @@ TextLabelClass* MessageListClass::Add_Message(char const* name, //------------------------------------------------------------------------ if (name) { sprintf(temp, "%s:", name); - mess_start = strlen(name) + 1; + mess_start = (int)strlen(name) + 1; } else { mess_start = 0; } @@ -630,7 +630,7 @@ int MessageListClass::Concat_Message(char const* name, int id, char const* txt, while (width >= Width - 8) { - max_chars = strlen(msg); + max_chars = (int)strlen(msg); if (max_chars < min_chars) { max_chars = min_chars; } @@ -654,8 +654,8 @@ int MessageListClass::Concat_Message(char const* name, int id, char const* txt, // Trim from left to right to remove the minimum required text. //------------------------------------------------------------------------ else { - min_chars = (strlen(msg) + strlen(txt)) - MaxChars; - max_chars = strlen(msg); + min_chars = (int)(strlen(msg) + strlen(txt)) - MaxChars; + max_chars = (int)strlen(msg); if (max_chars < min_chars) { max_chars = min_chars; } @@ -781,7 +781,7 @@ TextLabelClass* MessageListClass::Add_Edit(PlayerColorType color, TextPrintType memset(EditBuf, 0, sizeof(EditBuf)); strcpy(EditBuf, to); OverflowBuf[0] = 0; - EditCurPos = EditInitPos = strlen(to); + EditCurPos = EditInitPos = (int)strlen(to); EditLabel = new TextLabelClass(EditBuf, EditX, EditY, &ColorRemaps[color], style); Width = width; @@ -1275,7 +1275,7 @@ int MessageListClass::Trim_Message(char* dest, char* src, int min_chars, int max return (0); } - len = strlen(src); + len = (int)strlen(src); if (max_chars > len) { max_chars = len; } diff --git a/tiberiandawn/building.cpp b/tiberiandawn/building.cpp index d2fdc3ae..fcf6c4ad 100644 --- a/tiberiandawn/building.cpp +++ b/tiberiandawn/building.cpp @@ -2133,8 +2133,6 @@ void BuildingClass::Assign_Target(TARGET target) *=============================================================================================*/ void BuildingClass::Init(void) { - BuildingClass* ptr; - Buildings.Free_All(); } @@ -3551,7 +3549,7 @@ bool BuildingClass::Toggle_Primary(void) // if (House == PlayerPtr) { // Speak(VOX_PRIMARY_SELECTED); // } - if ((HouseClass*)House->IsHuman) { + if (House->IsHuman) { Speak(VOX_PRIMARY_SELECTED, House); } } diff --git a/tiberiandawn/conquer.cpp b/tiberiandawn/conquer.cpp index 57fa9a92..de238149 100644 --- a/tiberiandawn/conquer.cpp +++ b/tiberiandawn/conquer.cpp @@ -2360,7 +2360,7 @@ void CC_Texture_Fill(void const* shapefile, int shapenum, int xpos, int ypos, in { unsigned char* shape_pointer; // unsigned char *shape_save; - unsigned long shape_size; + uintptr_t shape_size; // int x,y; if (shapefile && shapenum != -1) { diff --git a/tiberiandawn/display.cpp b/tiberiandawn/display.cpp index 63202603..38b73842 100644 --- a/tiberiandawn/display.cpp +++ b/tiberiandawn/display.cpp @@ -2723,7 +2723,7 @@ COORDINATE DisplayClass::Pixel_To_Coord(int x, int y) */ // Possibly ignore the view constraints if we aren't using the internal renderer. ST - 4/17/2019 9:06AM // if (x < TacLeptonWidth && y < TacLeptonHeight) { - if (IgnoreViewConstraints || ((unsigned)x < TacLeptonWidth && (unsigned)y < TacLeptonHeight)) { + if (IgnoreViewConstraints || ((unsigned)x < (unsigned)TacLeptonWidth && (unsigned)y < (unsigned)TacLeptonHeight)) { return (Coord_Add(TacticalCoord, XY_Coord(x, y))); } return (0); diff --git a/tiberiandawn/house.cpp b/tiberiandawn/house.cpp index a3c30b9d..dc46705a 100644 --- a/tiberiandawn/house.cpp +++ b/tiberiandawn/house.cpp @@ -3583,7 +3583,7 @@ TechnoTypeClass const* HouseClass::Suggest_New_Object(RTTIType objecttype) const TeamTypeClass const* team = tptr->Class; if ((/*team->IsReinforcable || */ !tptr->IsFullStrength) && team->House == Class->House) { - for (int subindex = 0; subindex < team->ClassCount; subindex++) { + for (unsigned subindex = 0; subindex < team->ClassCount; subindex++) { if (team->Class[subindex]->What_Am_I() == RTTI_UNITTYPE) { counter[((UnitTypeClass const*)(team->Class[subindex]))->Type] = 1; // counter[((UnitTypeClass const *)(team->Class[subindex]))->Type] += @@ -3603,7 +3603,7 @@ TechnoTypeClass const* HouseClass::Suggest_New_Object(RTTIType objecttype) const TeamTypeClass const* team = TeamTypes.Ptr(index); if (team) { if (team->House == Class->House && team->IsPrebuilt && (!team->IsAutocreate || IsAlerted)) { - for (int subindex = 0; subindex < team->ClassCount; subindex++) { + for (unsigned subindex = 0; subindex < team->ClassCount; subindex++) { if (team->Class[subindex]->What_Am_I() == RTTI_UNITTYPE) { int subtype = ((UnitTypeClass const*)(team->Class[subindex]))->Type; counter[subtype] = MAX(counter[subtype], (int)team->DesiredNum[subindex]); @@ -3684,7 +3684,7 @@ TechnoTypeClass const* HouseClass::Suggest_New_Object(RTTIType objecttype) const TeamTypeClass const* team = tptr->Class; if ((team->IsReinforcable || !tptr->IsFullStrength) && team->House == Class->House) { - for (int subindex = 0; subindex < team->ClassCount; subindex++) { + for (unsigned subindex = 0; subindex < team->ClassCount; subindex++) { if (team->Class[subindex]->What_Am_I() == RTTI_INFANTRYTYPE) { counter[((InfantryTypeClass const*)(team->Class[subindex]))->Type] += team->DesiredNum[subindex] + 1; @@ -3703,7 +3703,7 @@ TechnoTypeClass const* HouseClass::Suggest_New_Object(RTTIType objecttype) const TeamTypeClass const* team = TeamTypes.Ptr(index); if (team) { if (team->House == Class->House && team->IsPrebuilt && (!team->IsAutocreate || IsAlerted)) { - for (int subindex = 0; subindex < team->ClassCount; subindex++) { + for (unsigned subindex = 0; subindex < team->ClassCount; subindex++) { if (team->Class[subindex]->What_Am_I() == RTTI_INFANTRYTYPE) { int subtype = ((InfantryTypeClass const*)(team->Class[subindex]))->Type; // counter[subtype] = 1; @@ -6590,7 +6590,7 @@ int HouseClass::AI_Unit(void) if (((team->IsReinforcable && !tptr->IsFullStrength) || (!tptr->IsForcedActive && !tptr->IsHasBeen && !tptr->IsAltered)) && team->House == Class->House) { - for (int subindex = 0; subindex < team->ClassCount; subindex++) { + for (unsigned subindex = 0; subindex < team->ClassCount; subindex++) { // TechnoTypeClass const * memtype = team->Members[subindex].Class; TechnoTypeClass const* memtype = team->Class[subindex]; if (memtype->What_Am_I() == RTTI_UNITTYPE) { @@ -6609,7 +6609,7 @@ int HouseClass::AI_Unit(void) for (index = 0; index < TeamTypes.Count(); index++) { TeamTypeClass const* team = TeamTypes.Ptr(index); if (team != NULL && team->House == Class->House && team->IsPrebuilt && (!team->IsAutocreate || IsAlerted)) { - for (int subindex = 0; subindex < team->ClassCount; subindex++) { + for (unsigned subindex = 0; subindex < team->ClassCount; subindex++) { // TechnoTypeClass const * memtype = team->Members[subindex].Class; TechnoTypeClass const* memtype = team->Class[subindex]; diff --git a/tiberiandawn/infantry.cpp b/tiberiandawn/infantry.cpp index 639ed8c5..98a42490 100644 --- a/tiberiandawn/infantry.cpp +++ b/tiberiandawn/infantry.cpp @@ -848,8 +848,6 @@ TARGET InfantryClass::As_Target(void) const *=============================================================================================*/ void InfantryClass::Init(void) { - InfantryClass* ptr; - Infantry.Free_All(); } diff --git a/tiberiandawn/init.cpp b/tiberiandawn/init.cpp index d4042291..bbad14c8 100644 --- a/tiberiandawn/init.cpp +++ b/tiberiandawn/init.cpp @@ -1783,7 +1783,7 @@ bool Parse_Command_Line(int argc, char* argv[]) long code = 0; char arg_string[512]; - int str_len = strlen(argv[index]); + int str_len = (int)strlen(argv[index]); char* src = argv[index]; char* dest = arg_string; for (int i = 0; i < str_len; i++) { @@ -2539,7 +2539,7 @@ long Obfuscate(char const* string) */ strncpy(buffer, string, sizeof(buffer)); buffer[sizeof(buffer) - 1] = '\0'; - int length = strlen(buffer); + int length = (int)strlen(buffer); /* ** Only upper case letters are significant. diff --git a/tiberiandawn/monoc.h b/tiberiandawn/monoc.h index 06015ab6..3800ff1d 100644 --- a/tiberiandawn/monoc.h +++ b/tiberiandawn/monoc.h @@ -35,6 +35,8 @@ #ifndef MONOC_H #define MONOC_H +#include + class MonoClass { /* @@ -171,7 +173,7 @@ class MonoClass void Scroll(int lines); void Store_Cell(CellType& cell, int x, int y) { - *(CellType*)((long)MonoSegment + Offset(x, y)) = cell; + *(CellType*)((intptr_t)MonoSegment + Offset(x, y)) = cell; }; /* diff --git a/tiberiandawn/msglist.cpp b/tiberiandawn/msglist.cpp index e132530e..01b705dd 100644 --- a/tiberiandawn/msglist.cpp +++ b/tiberiandawn/msglist.cpp @@ -465,7 +465,7 @@ TextLabelClass* MessageListClass::Add_Edit(int color, TextPrintType style, char* /*------------------------------------------------------------------------ Initialize the buffer positions; add a new label to the label list. ------------------------------------------------------------------------*/ - EditCurPos = EditInitPos = strlen(to); + EditCurPos = EditInitPos = int(strlen(to)); EditLabel = Add_Message(to, color, style, -1, 0, 0); Width = width; diff --git a/tiberiandawn/overlay.cpp b/tiberiandawn/overlay.cpp index 90ef69c6..7897e98d 100644 --- a/tiberiandawn/overlay.cpp +++ b/tiberiandawn/overlay.cpp @@ -104,8 +104,6 @@ int OverlayClass::Validate(void) const *=============================================================================================*/ void OverlayClass::Init(void) { - OverlayClass* ptr; - Overlays.Free_All(); } diff --git a/tiberiandawn/reinf.cpp b/tiberiandawn/reinf.cpp index 88ae9c92..31cb6008 100644 --- a/tiberiandawn/reinf.cpp +++ b/tiberiandawn/reinf.cpp @@ -89,7 +89,7 @@ bool Do_Reinforcements(TeamTypeClass* teamtype) bool watertransport = false; // Transport needs a beach to land at? bool onlytransport = true; // Just transport is in reinforcement? bool hastransport = false; // Group comes with transport? - int index; + unsigned index; for (index = 0; index < teamtype->ClassCount; index++) { if (teamtype->Class[index]->IsTransporter || teamtype->Class[index]->What_Am_I() == RTTI_AIRCRAFTTYPE) { hastransport = true; From e3c89f1a0f228757463656a4166b739fa4296412 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Thu, 29 Apr 2021 22:42:16 +0100 Subject: [PATCH 05/15] Silences macro redefinition warning. --- common/macros.h | 22 ++++++++++++++++++++++ common/mp.h | 4 +--- redalert/jshell.h | 7 +------ 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 common/macros.h diff --git a/common/macros.h b/common/macros.h new file mode 100644 index 00000000..8adeb387 --- /dev/null +++ b/common/macros.h @@ -0,0 +1,22 @@ +// TiberianDawn.DLL and RedAlert.dll and corresponding source code is free +// software: you can redistribute it and/or modify it under the terms of +// the GNU General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. + +// TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed +// in the hope that it will be useful, but with permitted additional restrictions +// under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT +// distributed with this program. You should have received a copy of the +// GNU General Public License along with permitted additional restrictions +// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection + +#ifndef COMMON_MACROS_H +#define COMMON_MACROS_H + +/* +** This macro serves as a general way to determine the number of elements +** within an array. +*/ +#define ARRAY_SIZE(x) int(sizeof(x) / sizeof(x[0])) + +#endif /* COMMON_MACROS_H */ diff --git a/common/mp.h b/common/mp.h index d6d03914..20eb1b91 100644 --- a/common/mp.h +++ b/common/mp.h @@ -35,6 +35,7 @@ #ifndef MP_H #define MP_H +#include "macros.h" #include "straw.h" #include #include @@ -50,9 +51,6 @@ extern uint16_t primeTable[3511]; #define SEMI_MASK ((uint16_t)~0) #define MAX_BIT_PRECISION 2048 #define MAX_UNIT_PRECISION (MAX_BIT_PRECISION / UNITSIZE) -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) -#endif int XMP_Significance(const digit* r, int precision); void XMP_Inc(digit* r, int precision); diff --git a/redalert/jshell.h b/redalert/jshell.h index 21efd0cb..6a68d792 100644 --- a/redalert/jshell.h +++ b/redalert/jshell.h @@ -35,6 +35,7 @@ #ifndef JSHELL_H #define JSHELL_H +#include #include struct NoInitClass; @@ -112,12 +113,6 @@ int Bound(signed int, signed int, signed int); unsigned Bound(unsigned, unsigned, unsigned); long Bound(long, long, long); -/* -** This macro serves as a general way to determine the number of elements -** within an array. -*/ -#define ARRAY_SIZE(x) int(sizeof(x) / sizeof(x[0])) - template void Bubble_Sort(T* array, int count) { if (array != NULL && count > 1) { From e6f5ce669e25050168c05eb2aab85884603a493f Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Thu, 29 Apr 2021 22:46:46 +0100 Subject: [PATCH 06/15] Silences no matching operator delete warnings. --- redalert/aircraft.h | 3 +++ redalert/anim.h | 3 +++ redalert/building.h | 3 +++ redalert/bullet.h | 3 +++ redalert/factory.h | 3 +++ redalert/house.h | 3 +++ redalert/infantry.h | 3 +++ redalert/overlay.h | 3 +++ redalert/smudge.h | 3 +++ redalert/team.h | 3 +++ redalert/template.h | 3 +++ redalert/terrain.h | 3 +++ redalert/trigger.h | 3 +++ redalert/trigtype.h | 3 +++ redalert/type.h | 36 ++++++++++++++++++++++++++++++++++++ redalert/unit.h | 3 +++ redalert/vessel.h | 3 +++ redalert/warhead.h | 3 +++ redalert/weapon.h | 3 +++ tiberiandawn/aircraft.h | 3 +++ tiberiandawn/anim.h | 3 +++ tiberiandawn/building.h | 3 +++ tiberiandawn/bullet.h | 3 +++ tiberiandawn/factory.h | 3 +++ tiberiandawn/house.h | 3 +++ tiberiandawn/infantry.h | 3 +++ tiberiandawn/overlay.h | 3 +++ tiberiandawn/smudge.h | 3 +++ tiberiandawn/team.h | 3 +++ tiberiandawn/teamtype.h | 3 +++ tiberiandawn/template.h | 3 +++ tiberiandawn/terrain.h | 3 +++ tiberiandawn/trigger.h | 3 +++ tiberiandawn/unit.h | 3 +++ 34 files changed, 135 insertions(+) diff --git a/redalert/aircraft.h b/redalert/aircraft.h index 7cec00f6..9147b161 100644 --- a/redalert/aircraft.h +++ b/redalert/aircraft.h @@ -62,6 +62,9 @@ class AircraftClass : public FootClass, public FlyClass return (ptr); }; static void operator delete(void*); + static void operator delete(void*, void*) + { + } operator AircraftType(void) const { return Class->Type; diff --git a/redalert/anim.h b/redalert/anim.h index 0da4f5b2..a24f790b 100644 --- a/redalert/anim.h +++ b/redalert/anim.h @@ -68,6 +68,9 @@ class AnimClass : public ObjectClass, public StageClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } /*--------------------------------------------------------------------- ** Member function prototypes. diff --git a/redalert/building.h b/redalert/building.h index 9365e506..953ee61e 100644 --- a/redalert/building.h +++ b/redalert/building.h @@ -216,6 +216,9 @@ class BuildingClass : public TechnoClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } BuildingClass(StructType type, HousesType house); #ifdef FIXIT_MULTI_SAVE BuildingClass(NoInitClass const& x) diff --git a/redalert/bullet.h b/redalert/bullet.h index 7d7e9029..907bd5a5 100644 --- a/redalert/bullet.h +++ b/redalert/bullet.h @@ -70,6 +70,9 @@ class BulletClass : public ObjectClass, public FlyClass, public FuseClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } BulletClass(BulletType id, TARGET target, TechnoClass* Payback, int strength, WarheadType warhead, int speed); #ifdef FIXIT_MULTI_SAVE BulletClass(NoInitClass const& x) diff --git a/redalert/factory.h b/redalert/factory.h index 3bb9f854..cb13fd3a 100644 --- a/redalert/factory.h +++ b/redalert/factory.h @@ -53,6 +53,9 @@ class FactoryClass : private StageClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init(void); diff --git a/redalert/house.h b/redalert/house.h index b1392e9e..0915a54b 100644 --- a/redalert/house.h +++ b/redalert/house.h @@ -656,6 +656,9 @@ class HouseClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } HouseClass(HousesType house); HouseClass(NoInitClass const& x) : Class(x) diff --git a/redalert/infantry.h b/redalert/infantry.h index 3d35e3ea..d08e1838 100644 --- a/redalert/infantry.h +++ b/redalert/infantry.h @@ -115,6 +115,9 @@ class InfantryClass : public FootClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } InfantryClass(InfantryType classid, HousesType house); InfantryClass(NoInitClass const& x) : FootClass(x) diff --git a/redalert/overlay.h b/redalert/overlay.h index 704e20c5..d27e7ed6 100644 --- a/redalert/overlay.h +++ b/redalert/overlay.h @@ -60,6 +60,9 @@ class OverlayClass : public ObjectClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } OverlayClass(OverlayType type, CELL pos = -1, HousesType = HOUSE_NONE); OverlayClass(NoInitClass const& x) : ObjectClass(x) diff --git a/redalert/smudge.h b/redalert/smudge.h index a7ca532c..2330b438 100644 --- a/redalert/smudge.h +++ b/redalert/smudge.h @@ -61,6 +61,9 @@ class SmudgeClass : public ObjectClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } SmudgeClass(SmudgeType type, COORDINATE pos = UINT_MAX, HousesType house = HOUSE_NONE); SmudgeClass(NoInitClass const& x) : ObjectClass(x) diff --git a/redalert/team.h b/redalert/team.h index 9d6c5895..d9189515 100644 --- a/redalert/team.h +++ b/redalert/team.h @@ -204,6 +204,9 @@ class TeamClass : public AbstractClass , Member(x){}; virtual ~TeamClass(void); static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void* operator new(size_t size); static void* operator new(size_t, void* ptr) { diff --git a/redalert/template.h b/redalert/template.h index d403b960..354d2afb 100644 --- a/redalert/template.h +++ b/redalert/template.h @@ -60,6 +60,9 @@ class TemplateClass : public ObjectClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } TemplateClass(TemplateType type, CELL pos = -1); TemplateClass(NoInitClass const& x) : ObjectClass(x) diff --git a/redalert/terrain.h b/redalert/terrain.h index c5b4688a..268b02ce 100644 --- a/redalert/terrain.h +++ b/redalert/terrain.h @@ -60,6 +60,9 @@ class TerrainClass : public ObjectClass, public StageClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } TerrainClass(TerrainType id, CELL cell); TerrainClass(NoInitClass const& x) : ObjectClass(x) diff --git a/redalert/trigger.h b/redalert/trigger.h index 72976db9..b6dfdc5e 100644 --- a/redalert/trigger.h +++ b/redalert/trigger.h @@ -98,6 +98,9 @@ class TriggerClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } /* ** If this trigger object is active, then this flag will be true. Trigger diff --git a/redalert/trigtype.h b/redalert/trigtype.h index 9df2ec3b..cbf8aacd 100644 --- a/redalert/trigtype.h +++ b/redalert/trigtype.h @@ -111,6 +111,9 @@ class TriggerTypeClass : public AbstractTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } /* ** Initialization: clears all trigger types in preparation for new scenario diff --git a/redalert/type.h b/redalert/type.h index a37d7927..5a54960b 100644 --- a/redalert/type.h +++ b/redalert/type.h @@ -181,6 +181,9 @@ class HouseTypeClass : public AbstractTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static HousesType From_Name(char const* name); static HouseTypeClass& As_Reference(HousesType house); @@ -820,6 +823,9 @@ class BuildingTypeClass : public TechnoTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init_Heap(void); static BuildingTypeClass& As_Reference(StructType type); @@ -1032,6 +1038,9 @@ class UnitTypeClass : public TechnoTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init_Heap(void); static UnitType From_Name(char const* name); @@ -1139,6 +1148,9 @@ class VesselTypeClass : public TechnoTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init_Heap(void); static VesselType From_Name(char const* name); @@ -1295,6 +1307,9 @@ class InfantryTypeClass : public TechnoTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init_Heap(void); static InfantryType From_Name(char const* name); @@ -1398,6 +1413,9 @@ class AircraftTypeClass : public TechnoTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init_Heap(void); static AircraftType From_Name(char const* name); @@ -1582,6 +1600,9 @@ class BulletTypeClass : public ObjectTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init_Heap(void); static BulletTypeClass& As_Reference(BulletType type); @@ -1651,6 +1672,9 @@ class TerrainTypeClass : public ObjectTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init_Heap(void); static TerrainType From_Name(char const* name); @@ -1711,6 +1735,9 @@ class TemplateTypeClass : public ObjectTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init_Heap(void); static TemplateType From_Name(char const* name); @@ -1937,6 +1964,9 @@ class AnimTypeClass : public ObjectTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static AnimTypeClass& As_Reference(AnimType type); static void Init(TheaterType theater); @@ -2054,6 +2084,9 @@ class OverlayTypeClass : public ObjectTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init_Heap(void); static OverlayType From_Name(char const* name); @@ -2127,6 +2160,9 @@ class SmudgeTypeClass : public ObjectTypeClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init_Heap(void); static SmudgeType From_Name(char const* name); diff --git a/redalert/unit.h b/redalert/unit.h index a86ba6bf..3eb05a35 100644 --- a/redalert/unit.h +++ b/redalert/unit.h @@ -131,6 +131,9 @@ class UnitClass : public DriveClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } UnitClass(UnitType classid, HousesType house); UnitClass(NoInitClass const& x) : DriveClass(x) diff --git a/redalert/vessel.h b/redalert/vessel.h index 57954832..3ab02b64 100644 --- a/redalert/vessel.h +++ b/redalert/vessel.h @@ -84,6 +84,9 @@ class VesselClass : public DriveClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } operator VesselType(void) const { return Class->Type; diff --git a/redalert/warhead.h b/redalert/warhead.h index 347a907a..a2e83bf0 100644 --- a/redalert/warhead.h +++ b/redalert/warhead.h @@ -53,6 +53,9 @@ class WarheadTypeClass return (ptr); }; void operator delete(void* pointer); + static void operator delete(void*, void*) + { + } void Code_Pointers(void) { diff --git a/redalert/weapon.h b/redalert/weapon.h index 4ef55671..b0d2c394 100644 --- a/redalert/weapon.h +++ b/redalert/weapon.h @@ -55,6 +55,9 @@ class WeaponTypeClass return (ptr); }; void operator delete(void* pointer); + static void operator delete(void*, void*) + { + } char const* Name(void) const { diff --git a/tiberiandawn/aircraft.h b/tiberiandawn/aircraft.h index 25e7844d..ca8ac23e 100644 --- a/tiberiandawn/aircraft.h +++ b/tiberiandawn/aircraft.h @@ -54,6 +54,9 @@ class AircraftClass : public FootClass, public FlyClass { return (ptr); }; + static void operator delete(void*, void*) + { + } operator AircraftType(void) const { return Class->Type; diff --git a/tiberiandawn/anim.h b/tiberiandawn/anim.h index 953e96ef..14354f65 100644 --- a/tiberiandawn/anim.h +++ b/tiberiandawn/anim.h @@ -51,6 +51,9 @@ class AnimClass : public ObjectClass, private StageClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } AnimClass(void) : Class(0) { diff --git a/tiberiandawn/building.h b/tiberiandawn/building.h index d29754e7..63d2d491 100644 --- a/tiberiandawn/building.h +++ b/tiberiandawn/building.h @@ -168,6 +168,9 @@ class BuildingClass : public TechnoClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } BuildingClass(void) : Class(0){}; BuildingClass(NoInitClass const& x) diff --git a/tiberiandawn/bullet.h b/tiberiandawn/bullet.h index b568e032..bd15246c 100644 --- a/tiberiandawn/bullet.h +++ b/tiberiandawn/bullet.h @@ -72,6 +72,9 @@ class BulletClass : public ObjectClass, public FlyClass, public FuseClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } BulletClass(void); BulletClass(BulletType id); BulletClass(NoInitClass const& x) diff --git a/tiberiandawn/factory.h b/tiberiandawn/factory.h index ab8529a2..9762ba35 100644 --- a/tiberiandawn/factory.h +++ b/tiberiandawn/factory.h @@ -52,6 +52,9 @@ class FactoryClass : private StageClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } static void Init(void); diff --git a/tiberiandawn/house.h b/tiberiandawn/house.h index b9e59cda..7fa52fc7 100644 --- a/tiberiandawn/house.h +++ b/tiberiandawn/house.h @@ -416,6 +416,9 @@ class HouseClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } HouseClass(void) : Class(0){}; HouseClass(HousesType house); diff --git a/tiberiandawn/infantry.h b/tiberiandawn/infantry.h index 70b79648..964f0c26 100644 --- a/tiberiandawn/infantry.h +++ b/tiberiandawn/infantry.h @@ -118,6 +118,9 @@ class InfantryClass : public FootClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } InfantryClass(void); InfantryClass(NoInitClass const& x) : FootClass(x) diff --git a/tiberiandawn/overlay.h b/tiberiandawn/overlay.h index 7fb49bea..abb92ea7 100644 --- a/tiberiandawn/overlay.h +++ b/tiberiandawn/overlay.h @@ -55,6 +55,9 @@ class OverlayClass : public ObjectClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } OverlayClass(void); OverlayClass(OverlayType type, CELL pos = -1, HousesType = HOUSE_NONE); OverlayClass(NoInitClass const& x) diff --git a/tiberiandawn/smudge.h b/tiberiandawn/smudge.h index 75b7a304..ef86ecc4 100644 --- a/tiberiandawn/smudge.h +++ b/tiberiandawn/smudge.h @@ -56,6 +56,9 @@ class SmudgeClass : public ObjectClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } SmudgeClass(SmudgeType type, COORDINATE pos = UINT_MAX, HousesType house = HOUSE_NONE); SmudgeClass(void) : Class(0){}; diff --git a/tiberiandawn/team.h b/tiberiandawn/team.h index 27114fd4..32a6c4be 100644 --- a/tiberiandawn/team.h +++ b/tiberiandawn/team.h @@ -191,6 +191,9 @@ class TeamClass : public AbstractClass return (ptr); }; static void* operator new(size_t size); + static void operator delete(void*, void*) + { + } static void Init(void); static void Suspend_Teams(int priority); diff --git a/tiberiandawn/teamtype.h b/tiberiandawn/teamtype.h index e6e2a4f6..8656b33e 100644 --- a/tiberiandawn/teamtype.h +++ b/tiberiandawn/teamtype.h @@ -147,6 +147,9 @@ class TeamTypeClass : public AbstractTypeClass return (ptr); }; void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } /* ** Dee-buggin' support. diff --git a/tiberiandawn/template.h b/tiberiandawn/template.h index a784702a..a11494e6 100644 --- a/tiberiandawn/template.h +++ b/tiberiandawn/template.h @@ -55,6 +55,9 @@ class TemplateClass : public ObjectClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } TemplateClass(void); TemplateClass(NoInitClass const& x) : ObjectClass(x) diff --git a/tiberiandawn/terrain.h b/tiberiandawn/terrain.h index 2201b22a..7417459e 100644 --- a/tiberiandawn/terrain.h +++ b/tiberiandawn/terrain.h @@ -60,6 +60,9 @@ class TerrainClass : public ObjectClass, public StageClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } TerrainClass(void); TerrainClass(NoInitClass const& x) : ObjectClass(x) diff --git a/tiberiandawn/trigger.h b/tiberiandawn/trigger.h index abe80af0..a3ec168f 100644 --- a/tiberiandawn/trigger.h +++ b/tiberiandawn/trigger.h @@ -201,6 +201,9 @@ class TriggerClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } /* ** Dee-buggin' support. diff --git a/tiberiandawn/unit.h b/tiberiandawn/unit.h index f517dee5..a99b346e 100644 --- a/tiberiandawn/unit.h +++ b/tiberiandawn/unit.h @@ -63,6 +63,9 @@ class UnitClass : public TarComClass return (ptr); }; static void operator delete(void* ptr); + static void operator delete(void*, void*) + { + } UnitClass(void){}; UnitClass(UnitType classid, HousesType house); UnitClass(NoInitClass const& x) From 656104ad0077e0cfaa0a6d7792e5beecf664f3fd Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Mon, 3 May 2021 23:06:49 +0100 Subject: [PATCH 07/15] Implements base type get and put in Pipe/Straw. Implements wrappers around the virtual Get/Put functions that read/write base data types in an endian consistent way. --- common/fixed.h | 2 ++ common/pipe.h | 78 +++++++++++++++++++++++++++++++++--------- common/straw.h | 93 +++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 139 insertions(+), 34 deletions(-) diff --git a/common/fixed.h b/common/fixed.h index feac771b..e79a99db 100644 --- a/common/fixed.h +++ b/common/fixed.h @@ -66,6 +66,8 @@ class fixed { static constexpr unsigned int PRECISION = 1 << 16; + friend class Pipe; + friend class Straw; public: // The default constructor must not touch the data members in any way. diff --git a/common/pipe.h b/common/pipe.h index cb819e9d..1457f7d8 100644 --- a/common/pipe.h +++ b/common/pipe.h @@ -35,24 +35,10 @@ #ifndef PIPE_H #define PIPE_H +#include "endianness.h" +#include "fixed.h" #include - -/* -** The "bool" integral type was defined by the C++ committee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#ifndef __BORLANDC__ -#ifndef TRUE_FALSE_DEFINED -#define TRUE_FALSE_DEFINED -enum -{ - false = 0, - true = 1 -}; -typedef int bool; -#endif -#endif +#include /* ** A "push through" pipe interface abstract class used for such purposes as compression @@ -83,6 +69,64 @@ class Pipe } virtual int Put(void const* source, int slen); + /* + ** Write fixed width data to the stream. + */ + void Put(int8_t val) + { + uint8_t data = val; + Put(&data, sizeof(data)); + } + + void Put(uint8_t val) + { + uint8_t data = val; + Put(&data, sizeof(data)); + } + + void Put(int16_t val) + { + uint16_t data = htole16(val); + Put(&data, sizeof(data)); + } + + void Put(uint16_t val) + { + uint16_t data = htole16(val); + Put(&data, sizeof(data)); + } + + void Put(int32_t val) + { + uint32_t data = htole32(val); + Put(&data, sizeof(data)); + } + + void Put(uint32_t val) + { + uint32_t data = htole32(val); + Put(&data, sizeof(data)); + } + + void Put(int64_t val) + { + uint64_t data = htole64(val); + Put(&data, sizeof(data)); + } + + void Put(uint64_t val) + { + uint64_t data = htole64(val); + Put(&data, sizeof(data)); + } + + void Put(const fixed& val) + { + uint32_t data = htole32(val.Data.Raw); + static_assert(sizeof(data) == sizeof(val.Data.Raw), "Fixed point data does not match written data size."); + Put(&data, sizeof(data)); + } + /* ** Pointer to the next pipe segment in the chain. */ diff --git a/common/straw.h b/common/straw.h index bcd56495..7e61e036 100644 --- a/common/straw.h +++ b/common/straw.h @@ -35,24 +35,10 @@ #ifndef STRAW_H #define STRAW_H +#include "endianness.h" +#include "fixed.h" #include - -/* -** The "bool" integral type was defined by the C++ committee in -** November of '94. Until the compiler supports this, use the following -** definition. -*/ -#ifndef __BORLANDC__ -#ifndef TRUE_FALSE_DEFINED -#define TRUE_FALSE_DEFINED -enum -{ - false = 0, - true = 1 -}; -typedef int bool; -#endif -#endif +#include /* ** This is a demand driven data carrier. It will retrieve the byte request by passing @@ -78,6 +64,79 @@ class Straw } virtual int Get(void* buffer, int slen); + bool Get(int8_t& val) + { + uint8_t data; + bool success = Get(&data, sizeof(data)) == sizeof(data); + val = data; + return success; + } + + bool Get(uint8_t& val) + { + uint8_t data; + bool success = Get(&data, sizeof(data)) == sizeof(data); + val = data; + return success; + } + + bool Get(int16_t& val) + { + uint16_t data; + bool success = Get(&data, sizeof(data)) == sizeof(data); + val = le16toh(data); + return success; + } + + bool Get(uint16_t& val) + { + uint16_t data; + bool success = Get(&data, sizeof(data)) == sizeof(data); + val = le16toh(data); + return success; + } + + bool Get(int32_t& val) + { + uint32_t data; + bool success = Get(&data, sizeof(data)) == sizeof(data); + val = le32toh(data); + return success; + } + + bool Get(uint32_t& val) + { + uint32_t data; + bool success = Get(&data, sizeof(data)) == sizeof(data); + val = le32toh(data); + return success; + } + + bool Get(int64_t& val) + { + uint64_t data; + bool success = Get(&data, sizeof(data)) == sizeof(data); + val = le64toh(data); + return success; + } + + bool Get(uint64_t& val) + { + uint64_t data; + bool success = Get(&data, sizeof(data)) == sizeof(data); + val = le64toh(data); + return success; + } + + bool Get(fixed& val) + { + uint32_t data; + bool success = Get(&data, sizeof(data)) == sizeof(data); + static_assert(sizeof(data) == sizeof(val.Data.Raw), "Fixed point data does not match written data size."); + val.Data.Raw = le32toh(data); + return success; + } + /* ** Pointer to the next pipe segment in the chain. */ From 27ba5d63df40729e8e8097a87555b687058e6663 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Sun, 23 May 2021 00:04:01 +0100 Subject: [PATCH 08/15] Validates calls to Cell_Object for both editors code. Fixes crash in RA editor clicking out of bounds. --- redalert/mapedsel.cpp | 6 ++++-- tiberiandawn/mapedsel.cpp | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/redalert/mapedsel.cpp b/redalert/mapedsel.cpp index 999a3fe6..0b3fcf3b 100644 --- a/redalert/mapedsel.cpp +++ b/redalert/mapedsel.cpp @@ -88,9 +88,11 @@ int MapEditClass::Select_Object(void) y = (y - TacPixelY) % ICON_PIXEL_H; /* - ** Get object at that x,y + ** Get object at that x,y if cell is within map. */ - object = Cell_Object(cell, x, y); + if ((unsigned)cell < MAP_CELL_TOTAL) { + object = Cell_Object(cell, x, y); + } /* ** If no object, unselect the current one diff --git a/tiberiandawn/mapedsel.cpp b/tiberiandawn/mapedsel.cpp index 64afc1af..6d743c38 100644 --- a/tiberiandawn/mapedsel.cpp +++ b/tiberiandawn/mapedsel.cpp @@ -86,7 +86,9 @@ int MapEditClass::Select_Object(void) /* ......................... Get object at that x,y ......................... */ - object = Cell_Object(cell, x, y); + if ((unsigned)cell < MAP_CELL_TOTAL) { + object = Cell_Object(cell, x, y); + } /* ----------------- If no object, unselect the current one ----------------- From 38b474d421e9aa88b52fefb9d2da2490202266f5 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Sun, 23 May 2021 00:04:46 +0100 Subject: [PATCH 09/15] [RA] Adds frame limiter to Team editor code. Allows menu to be drawn correctly in none ddraw builds. --- redalert/teamtype.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/redalert/teamtype.cpp b/redalert/teamtype.cpp index 8d003018..471cfe7f 100644 --- a/redalert/teamtype.cpp +++ b/redalert/teamtype.cpp @@ -63,6 +63,7 @@ #include "checkbox.h" #include "drop.h" #include "textbtn.h" +#include "framelimit.h" #endif TeamMissionClass TeamMissions[TMISSION_COUNT] = { @@ -1495,6 +1496,8 @@ bool TeamTypeClass::Edit(void) if (input & KN_BUTTON) { lastbutton = (input & ~KN_BUTTON); } + + Frame_Limiter(); } return (!cancel); From 6a4d26084672e63bf3a0c3f3981330d5552379b7 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Sun, 23 May 2021 00:05:38 +0100 Subject: [PATCH 10/15] [RA] Posts SDL2 quit event in Emergency_Exit. Exit would loop infinitely in some cases when quit was not posted to event queue. --- redalert/startup.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/redalert/startup.cpp b/redalert/startup.cpp index f5c3e0df..85455c5b 100644 --- a/redalert/startup.cpp +++ b/redalert/startup.cpp @@ -48,6 +48,11 @@ bool Read_Private_Config_Struct(FileClass& file, NewConfigType* config); void Print_Error_End_Exit(char* string); void Print_Error_Exit(char* string); +#ifdef SDL2_BUILD +#define SDL_MAIN_HANDLED +#include +#endif + #ifdef _WIN32 #include #include "common/utf.h" @@ -576,7 +581,11 @@ void Emergency_Exit(int code) /* ** Post a message to our message handler to tell it to clean up. */ -#ifdef _WIN32 +#ifdef SDL2_BUILD + SDL_Event sdlevent; + sdlevent.type = SDL_QUIT; + SDL_PushEvent(&sdlevent); +#elif defined _WIN32 PostMessage(MainWindow, WM_DESTROY, 0, 0); #endif From 51252fcb2e7318d4f15e6e27b582221bbe234ccd Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Sun, 23 May 2021 23:45:46 +0100 Subject: [PATCH 11/15] Fixes TAB key crash in editor mode. Fixes TAB key crashing when nothing is selected. TAB moves to next unit but code didn't check if there was anything selected to start with. --- redalert/mapedsel.cpp | 7 +++++++ tiberiandawn/mapedsel.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/redalert/mapedsel.cpp b/redalert/mapedsel.cpp index 0b3fcf3b..cb555aa1 100644 --- a/redalert/mapedsel.cpp +++ b/redalert/mapedsel.cpp @@ -172,6 +172,13 @@ void MapEditClass::Select_Next(void) int tcell_x; // cell-x of TacticalCell int tcell_y; // cell-y of TacticalCell + /* + ** Can't select next if we don't have any selected. + */ + if (CurrentObject.Count() <= 0) { + return; + } + /* ** Get next object on the map */ diff --git a/tiberiandawn/mapedsel.cpp b/tiberiandawn/mapedsel.cpp index 6d743c38..859e2d90 100644 --- a/tiberiandawn/mapedsel.cpp +++ b/tiberiandawn/mapedsel.cpp @@ -166,6 +166,13 @@ void MapEditClass::Select_Next(void) int tcell_x; // cell-x of TacticalCell int tcell_y; // cell-y of TacticalCell + /* + ** Can't select next if we don't have any selected. + */ + if (CurrentObject.Count() <= 0) { + return; + } + /* ----------------------- Get next object on the map ----------------------- */ From 6bea0da13e6a3a35a6945d1afcd4ac44c1d451b6 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Sat, 29 May 2021 22:55:20 +0100 Subject: [PATCH 12/15] [RA] Fixes hang on sidebar tab area when in editor. Ports TD code difference where mouse input is consumed by editor layer. --- redalert/mapedit.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/redalert/mapedit.cpp b/redalert/mapedit.cpp index 9776eabd..0fa6bf32 100644 --- a/redalert/mapedit.cpp +++ b/redalert/mapedit.cpp @@ -1345,6 +1345,10 @@ void MapEditClass::AI(KeyNumType& input, int x, int y) input = KN_NONE; break; + case (KN_LMOUSE): + input = KN_NONE; + break; + default: break; } From d988e373060db3eb6390e293fea975bba5f21824 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Sat, 29 May 2021 22:56:09 +0100 Subject: [PATCH 13/15] [RA] Fixes incorrect area being used for input. RA was using DOS scale rather than Win95 scale. --- redalert/mapedit.cpp | 2 +- redalert/mapedit.h | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/redalert/mapedit.cpp b/redalert/mapedit.cpp index 0fa6bf32..78851c17 100644 --- a/redalert/mapedit.cpp +++ b/redalert/mapedit.cpp @@ -150,7 +150,7 @@ void MapEditClass::One_Time(void) ** The map: a single large "button" */ MapArea = - new ControlClass(MAP_AREA, 0, 8, 640 - 8, 400 - 8, GadgetClass::LEFTPRESS | GadgetClass::LEFTRELEASE, false); + new ControlClass(MAP_AREA, 0, 16, 640 - 16, 400 - 16, GadgetClass::LEFTPRESS | GadgetClass::LEFTRELEASE, false); /* ** House buttons diff --git a/redalert/mapedit.h b/redalert/mapedit.h index 1258e539..4c26dd01 100644 --- a/redalert/mapedit.h +++ b/redalert/mapedit.h @@ -116,25 +116,25 @@ enum MapEdit1Enum // POPUP_MULTI4_X = 35, // POPUP_MULTI4_Y = 169, - POPUP_MISSION_W = 80, - POPUP_MISSION_H = 40, - POPUP_MISSION_X = 70, - POPUP_MISSION_Y = 150, - - POPUP_FACEBOX_W = 30, - POPUP_FACEBOX_H = 30, - POPUP_FACEBOX_X = 160, - POPUP_FACEBOX_Y = 160, - - POPUP_HEALTH_W = 50, - POPUP_HEALTH_H = 10, - POPUP_HEALTH_X = 200, - POPUP_HEALTH_Y = 170, - - POPUP_BASE_W = 50, - POPUP_BASE_H = 8, - POPUP_BASE_X = 300 - 50, - POPUP_BASE_Y = 0 + POPUP_MISSION_W = 160, + POPUP_MISSION_H = 80, + POPUP_MISSION_X = 140, + POPUP_MISSION_Y = 300, + + POPUP_FACEBOX_W = 60, + POPUP_FACEBOX_H = 60, + POPUP_FACEBOX_X = 320, + POPUP_FACEBOX_Y = 320, + + POPUP_HEALTH_W = 100, + POPUP_HEALTH_H = 20, + POPUP_HEALTH_X = 400, + POPUP_HEALTH_Y = 340, + + POPUP_BASE_W = 100, + POPUP_BASE_H = 16, + POPUP_BASE_X = 600 - POPUP_BASE_W, + POPUP_BASE_Y = 0, }; /* From b8c0ff31e1951915761ce8d80069f13bee87d846 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Sun, 30 May 2021 22:37:12 +0100 Subject: [PATCH 14/15] [RA] Fixes default mission assignment in map editor. Issue caused by added handling of Mission == MISSION_NONE condition. Appears to have been added to prevent negative index into an array. This fixes it to only check Mission != MISSION_NONE for those array checks. --- redalert/infantry.cpp | 7 +++++-- redalert/unit.cpp | 7 +++++-- redalert/vessel.cpp | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/redalert/infantry.cpp b/redalert/infantry.cpp index 777e8ace..dee22137 100644 --- a/redalert/infantry.cpp +++ b/redalert/infantry.cpp @@ -1836,8 +1836,11 @@ void InfantryClass::Enter_Idle_Mode(bool) } } else { - if (Mission == MISSION_NONE || Mission == MISSION_GUARD || Mission == MISSION_GUARD_AREA - || MissionControl[Mission].IsZombie || MissionControl[Mission].IsParalyzed) { + if (Mission == MISSION_GUARD || Mission == MISSION_GUARD_AREA) { + return; + } + + if (Mission != MISSION_NONE && (MissionControl[Mission].IsParalyzed || MissionControl[Mission].IsZombie)) { return; } diff --git a/redalert/unit.cpp b/redalert/unit.cpp index ad06729c..f8e67ceb 100644 --- a/redalert/unit.cpp +++ b/redalert/unit.cpp @@ -1392,8 +1392,11 @@ void UnitClass::Enter_Idle_Mode(bool initial) #endif } else { - if (Mission == MISSION_NONE || Mission == MISSION_GUARD || Mission == MISSION_GUARD_AREA - || MissionControl[Mission].IsParalyzed || MissionControl[Mission].IsZombie) { + if (Mission == MISSION_GUARD || Mission == MISSION_GUARD_AREA) { + return; + } + + if (Mission != MISSION_NONE && (MissionControl[Mission].IsParalyzed || MissionControl[Mission].IsZombie)) { return; } diff --git a/redalert/vessel.cpp b/redalert/vessel.cpp index ee342fb7..a4af41a9 100644 --- a/redalert/vessel.cpp +++ b/redalert/vessel.cpp @@ -1354,8 +1354,11 @@ void VesselClass::Enter_Idle_Mode(bool) } else { - if (Mission == MISSION_NONE || Mission == MISSION_GUARD || Mission == MISSION_GUARD_AREA - || MissionControl[Mission].IsParalyzed || MissionControl[Mission].IsZombie) { + if (Mission == MISSION_GUARD || Mission == MISSION_GUARD_AREA) { + return; + } + + if (Mission != MISSION_NONE && (MissionControl[Mission].IsParalyzed || MissionControl[Mission].IsZombie)) { return; } From 6aca35736090ac89ecca2aab42b6616aec8748f8 Mon Sep 17 00:00:00 2001 From: OmniBlade Date: Mon, 31 May 2021 22:10:25 +0100 Subject: [PATCH 15/15] [RA] Fixes invisible trigger editor in editor mode. Another missed loop that needs a frame limiter call. --- redalert/trigtype.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/redalert/trigtype.cpp b/redalert/trigtype.cpp index 25f93447..d8a6c5d5 100644 --- a/redalert/trigtype.cpp +++ b/redalert/trigtype.cpp @@ -54,6 +54,7 @@ #ifdef SCENARIO_EDITOR #include "drop.h" #include "textbtn.h" +#include "common/framelimit.h" #endif /*********************************************************************************************** @@ -1921,6 +1922,8 @@ bool TriggerTypeClass::Edit(void) } break; } + + Frame_Limiter(); } return (false); }