Skip to content

Commit

Permalink
Cleanup more use of the "long" data type.
Browse files Browse the repository at this point in the history
This datatype varies in length between platforms so its use is not portable.
  • Loading branch information
OmniBlade committed Jun 21, 2024
1 parent f4a3cff commit 478737f
Show file tree
Hide file tree
Showing 27 changed files with 207 additions and 207 deletions.
2 changes: 1 addition & 1 deletion common/keyframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ bool Get_Build_Frame_Palette(void const* dataptr, void* palette)
frames = le16toh(frames);
if (flags & 1) {
char const* ptr = (char const*)Add_Long_To_Pointer(
dataptr, ((((long)sizeof(unsigned long) << 1) * frames + 16 + sizeof(KeyFrameHeaderType))));
dataptr, ((((int)sizeof(unsigned) << 1) * frames + 16 + sizeof(KeyFrameHeaderType))));

memcpy(palette, ptr, 768L);
return (true);
Expand Down
4 changes: 2 additions & 2 deletions redalert/aircraft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2921,15 +2921,15 @@ RadioMessageType AircraftClass::Receive_Message(RadioClass* from, RadioMessageTy
if (cell == 0) {
Transmit_Message(RADIO_OVER_OUT, from);
} else {
param = (long)::As_Target(cell);
param = ::As_Target(cell);

/*
** Tell the potential passenger where it should go. If the passenger is
** already at the staging location, then tell it to move onto the transport
** directly.
*/
if (Transmit_Message(RADIO_MOVE_HERE, param, from) == RADIO_YEA_NOW_WHAT) {
param = (long)As_Target();
param = As_Target();
Transmit_Message(RADIO_TETHER);
if (Transmit_Message(RADIO_MOVE_HERE, param, from) != RADIO_ROGER) {
Transmit_Message(RADIO_OVER_OUT, from);
Expand Down
2 changes: 1 addition & 1 deletion redalert/bullet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ int BulletClass::Shape_Number(void) const
** For tumbling projectiles, fetch offset stage.
*/
if (Class->Tumble > 0) {
shapenum += (long)Frame % Class->Tumble;
shapenum += Frame % Class->Tumble;
}

return (shapenum);
Expand Down
32 changes: 16 additions & 16 deletions redalert/conquer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,8 @@ void Toggle_Formation(void)
// MBL 03.23.2020: this has been copied to DLLExportClass::Team_Units_Formation_Toggle_On(), and modified as needed
#ifndef REMASTER_BUILD
int team = -1;
long minx = 0x7FFFFFFFL, miny = 0x7FFFFFFFL;
long maxx = 0, maxy = 0;
int minx = 0x7FFFFFFF, miny = 0x7FFFFFFF;
int maxx = 0, maxy = 0;
int index;
bool setform = 0;

Expand Down Expand Up @@ -3540,8 +3540,8 @@ void Handle_Team(int team, int action)
** Create the team.
*/
case 2: {
long minx = 0x7FFFFFFFL, miny = 0x7FFFFFFFL;
long maxx = 0, maxy = 0;
int minx = 0x7FFFFFFFL, miny = 0x7FFFFFFFL;
int maxx = 0, maxy = 0;
team_form_data.TeamSpeed[team] = SPEED_WHEEL;
team_form_data.TeamMaxSpeed[team] = MPH_LIGHT_SPEED;
for (index = 0; index < Units.Count(); index++) {
Expand All @@ -3552,8 +3552,8 @@ void Handle_Team(int team, int action)
if (obj->Is_Selected_By_Player()) {
obj->Group = team;
obj->Mark(MARK_CHANGE);
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
if (xc < minx)
minx = xc;
if (xc > maxx)
Expand All @@ -3578,8 +3578,8 @@ void Handle_Team(int team, int action)
if (obj->Is_Selected_By_Player()) {
obj->Group = team;
obj->Mark(MARK_CHANGE);
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
if (xc < minx)
minx = xc;
if (xc > maxx)
Expand All @@ -3604,8 +3604,8 @@ void Handle_Team(int team, int action)
if (obj->Is_Selected_By_Player()) {
obj->Group = team;
obj->Mark(MARK_CHANGE);
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
if (xc < minx)
minx = xc;
if (xc > maxx)
Expand Down Expand Up @@ -3649,8 +3649,8 @@ void Handle_Team(int team, int action)
#else
#if (1)
// Old always-north formation stuff
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));

obj->XFormOffset = xc - centerx;
obj->YFormOffset = yc - centery;
Expand All @@ -3676,8 +3676,8 @@ void Handle_Team(int team, int action)
#else
#if (1)
// Old always-north formation stuff
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));

obj->XFormOffset = xc - centerx;
obj->YFormOffset = yc - centery;
Expand Down Expand Up @@ -4257,7 +4257,7 @@ bool Force_CD_Available(int cd)
#endif

#ifdef FRENCH
sprintf(buffer, "InsŠrez le %s", _cd_name[cd]);
sprintf(buffer, "Insrez le %s", _cd_name[cd]);
#else
#ifdef GERMAN
sprintf(buffer, "Bitte %s", _cd_name[cd]);
Expand All @@ -4268,7 +4268,7 @@ bool Force_CD_Available(int cd)
} else {
#ifdef DVD
#ifdef FRENCH
sprintf(buffer, "InsŠrez le %s", _cd_name[4]);
sprintf(buffer, "Insrez le %s", _cd_name[4]);
#else
#ifdef GERMAN
sprintf(buffer, "Bitte %s", _cd_name[4]);
Expand Down
28 changes: 14 additions & 14 deletions redalert/dllinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7568,8 +7568,8 @@ void DLLExportClass::Team_Units_Formation_Toggle_On(uint64 player_id)
//

int team = MAX_TEAMS;
long minx = 0x7FFFFFFFL, miny = 0x7FFFFFFFL;
long maxx = 0, maxy = 0;
int minx = 0x7FFFFFFFL, miny = 0x7FFFFFFFL;
int maxx = 0, maxy = 0;
int index;
bool setform = 0;

Expand Down Expand Up @@ -7659,8 +7659,8 @@ void DLLExportClass::Team_Units_Formation_Toggle_On(uint64 player_id)
if (obj && !obj->IsInLimbo && obj->House == PlayerPtr && obj->Group == team) {
obj->Mark(MARK_CHANGE);
if (setform) {
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
if (xc < minx)
minx = xc;
if (xc > maxx)
Expand All @@ -7684,8 +7684,8 @@ void DLLExportClass::Team_Units_Formation_Toggle_On(uint64 player_id)
if (obj && !obj->IsInLimbo && obj->House == PlayerPtr && obj->Group == team) {
obj->Mark(MARK_CHANGE);
if (setform) {
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
if (xc < minx)
minx = xc;
if (xc > maxx)
Expand All @@ -7708,8 +7708,8 @@ void DLLExportClass::Team_Units_Formation_Toggle_On(uint64 player_id)
if (obj && !obj->IsInLimbo && obj->House == PlayerPtr && obj->Group == team) {
obj->Mark(MARK_CHANGE);
if (setform) {
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
if (xc < minx)
minx = xc;
if (xc > maxx)
Expand Down Expand Up @@ -7739,8 +7739,8 @@ void DLLExportClass::Team_Units_Formation_Toggle_On(uint64 player_id)
for (index = 0; index < Units.Count(); index++) {
UnitClass* obj = Units.Ptr(index);
if (obj && !obj->IsInLimbo && obj->House == PlayerPtr && obj->Group == team) {
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));

obj->XFormOffset = xc - centerx;
obj->YFormOffset = yc - centery;
Expand All @@ -7750,8 +7750,8 @@ void DLLExportClass::Team_Units_Formation_Toggle_On(uint64 player_id)
for (index = 0; index < Infantry.Count(); index++) {
InfantryClass* obj = Infantry.Ptr(index);
if (obj && !obj->IsInLimbo && obj->House == PlayerPtr && obj->Group == team) {
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));

obj->XFormOffset = xc - centerx;
obj->YFormOffset = yc - centery;
Expand All @@ -7761,8 +7761,8 @@ void DLLExportClass::Team_Units_Formation_Toggle_On(uint64 player_id)
for (index = 0; index < Vessels.Count(); index++) {
VesselClass* obj = Vessels.Ptr(index);
if (obj && !obj->IsInLimbo && obj->House == PlayerPtr && obj->Group == team) {
long xc = Cell_X(Coord_Cell(obj->Center_Coord()));
long yc = Cell_Y(Coord_Cell(obj->Center_Coord()));
int xc = Cell_X(Coord_Cell(obj->Center_Coord()));
int yc = Cell_Y(Coord_Cell(obj->Center_Coord()));

obj->XFormOffset = xc - centerx;
obj->YFormOffset = yc - centery;
Expand Down
2 changes: 1 addition & 1 deletion redalert/foot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ RadioMessageType FootClass::Receive_Message(RadioClass* from, RadioMessageType m
** then it doesn't need further movement instructions.
*/
case RADIO_NEED_TO_MOVE:
param = (long)NavCom;
param = NavCom;
if (!Target_Legal(NavCom)) {
return (RADIO_ROGER);
}
Expand Down
4 changes: 2 additions & 2 deletions redalert/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ bool Read_Scenario_INI_Write_INB(char* root, bool fresh);
** INIT.CPP
*/
void Load_Title_Page(bool visible = false);
int Obfuscate(char const* string);
unsigned Obfuscate(char const* string);
void Anim_Init(void);
bool Init_Game(int argc, char* argv[]);
bool Select_Game(bool fade = false);
Expand All @@ -398,7 +398,7 @@ void* Conquer_Build_Fading_Table(PaletteClass const& palette, void* dest, int co
void* Small_Icon(void const* iconptr, int iconnum);
void Set_Window(int window, int x, int y, int w, int h);
int Load_Uncompress(FileClass& file, BufferClass& uncomp_buff, BufferClass& dest_buff, void* reserved_data);
long Translucent_Table_Size(int count);
int Translucent_Table_Size(int count);
void* Build_Translucent_Table(PaletteClass const& palette, TLucentType const* control, int count, void* buffer);
void* Conquer_Build_Translucent_Table(PaletteClass const& palette, TLucentType const* control, int count, void* buffer);
void* Make_Fading_Table(PaletteClass const& palette, void* dest, int color, int frac);
Expand Down
4 changes: 2 additions & 2 deletions redalert/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ bool Parse_Command_Line(int argc, char* argv[])
* HISTORY: *
* 08/19/1995 JLB : Created. *
*=============================================================================================*/
int Obfuscate(char const* string)
unsigned Obfuscate(char const* string)
{
char buffer[1024];

Expand Down Expand Up @@ -2610,7 +2610,7 @@ static void Init_Authorization(void)
#ifdef NEVER
while (!ok && counter) {
SmartPtr<char const> str = Fetch_Password(TXT_PASSWORD_CAPTION, TXT_PASSWORD_MESSAGE, TXT_OK);
SmartPtr<long const> lptr = &CheatCodes[0];
SmartPtr<int const> lptr = &CheatCodes[0];
while (*lptr) {
if (Obfuscate(str) == *lptr++) {
ok = true;
Expand Down
2 changes: 1 addition & 1 deletion redalert/jshell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ int Load_Picture(char const* filename,
* HISTORY: *
* 04/02/1994 JLB : Created. *
*=============================================================================================*/
long Translucent_Table_Size(int count)
int Translucent_Table_Size(int count)
{
return (256L + (256L * count));
}
Expand Down
4 changes: 2 additions & 2 deletions redalert/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void LogicClass::Debug_Dump(MonoClass* mono) const

_framecounter++;
mono->Set_Cursor(1, 1);
mono->Printf("%ld", (long)Scen.Timer);
mono->Printf("%d", (int)Scen.Timer);
mono->Set_Cursor(10, 1);
mono->Printf("%3d", FramesPerSecond);
mono->Set_Cursor(1, 3);
Expand Down Expand Up @@ -110,7 +110,7 @@ void LogicClass::Debug_Dump(MonoClass* mono) const
mono->Set_Cursor(1, 22);
mono->Printf("%3d", Factories.Count());

SpareTicks = min((long)SpareTicks, (long)TIMER_SECOND);
SpareTicks = min(SpareTicks, TIMER_SECOND);

/*
** CPU utilization record.
Expand Down
Loading

0 comments on commit 478737f

Please sign in to comment.