Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup more use of the "long" data type. #1012

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions common/blowfish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ void BlowfishEngine::Submit_Key(void const* key, int length)
** the table data WHILE it is using the table data, the tables are
** thoroughly obfuscated by this process.
*/
unsigned int left = 0x00000000L;
unsigned int right = 0x00000000L;
unsigned int left = 0x00000000;
unsigned int right = 0x00000000;
unsigned int* p_en = &P_Encrypt[0]; // Encryption table.
unsigned int* p_de = &P_Decrypt[ROUNDS + 1]; // Decryption table.
for (int p_index = 0; p_index < ROUNDS + 2; p_index += 2) {
Expand Down
44 changes: 22 additions & 22 deletions common/combuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ void CommBufferClass::Init(void)
//------------------------------------------------------------------------
// Init data members
//------------------------------------------------------------------------
SendTotal = 0L;
ReceiveTotal = 0L;
SendTotal = 0;
ReceiveTotal = 0;

DelaySum = 0L;
NumDelay = 0L;
MeanDelay = 0L;
MaxDelay = 0L;
DelaySum = 0;
NumDelay = 0;
MeanDelay = 0;
MaxDelay = 0;

SendCount = 0;

Expand All @@ -202,9 +202,9 @@ void CommBufferClass::Init(void)
for (i = 0; i < MaxSend; i++) {
SendQueue[i].IsActive = 0;
SendQueue[i].IsACK = 0;
SendQueue[i].FirstTime = 0L;
SendQueue[i].LastTime = 0L;
SendQueue[i].SendCount = 0L;
SendQueue[i].FirstTime = 0;
SendQueue[i].LastTime = 0;
SendQueue[i].SendCount = 0;
SendQueue[i].BufLen = 0;
SendQueue[i].ExtraLen = 0;

Expand Down Expand Up @@ -261,9 +261,9 @@ void CommBufferClass::Init_Send_Queue(void)
for (i = 0; i < MaxSend; i++) {
SendQueue[i].IsActive = 0;
SendQueue[i].IsACK = 0;
SendQueue[i].FirstTime = 0L;
SendQueue[i].LastTime = 0L;
SendQueue[i].SendCount = 0L;
SendQueue[i].FirstTime = 0;
SendQueue[i].LastTime = 0;
SendQueue[i].SendCount = 0;
SendQueue[i].BufLen = 0;
SendQueue[i].ExtraLen = 0;

Expand Down Expand Up @@ -319,9 +319,9 @@ int CommBufferClass::Queue_Send(void* buf, int buflen, void* extrabuf, int extra
//------------------------------------------------------------------------
SendQueue[index].IsActive = 1; // entry is now active
SendQueue[index].IsACK = 0; // entry hasn't been ACK'd
SendQueue[index].FirstTime = 0L; // filled in by Manager when sent
SendQueue[index].LastTime = 0L; // filled in by Manager when sent
SendQueue[index].SendCount = 0L; // filled in by Manager when sent
SendQueue[index].FirstTime = 0; // filled in by Manager when sent
SendQueue[index].LastTime = 0; // filled in by Manager when sent
SendQueue[index].SendCount = 0; // filled in by Manager when sent
SendQueue[index].BufLen = buflen; // save buffer size

//------------------------------------------------------------------------
Expand Down Expand Up @@ -409,9 +409,9 @@ int CommBufferClass::UnQueue_Send(void* buf, int* buflen, int index, void* extra
//------------------------------------------------------------------------
SendQueue[SendIndex[index]].IsActive = 0;
SendQueue[SendIndex[index]].IsACK = 0;
SendQueue[SendIndex[index]].FirstTime = 0L;
SendQueue[SendIndex[index]].LastTime = 0L;
SendQueue[SendIndex[index]].SendCount = 0L;
SendQueue[SendIndex[index]].FirstTime = 0;
SendQueue[SendIndex[index]].LastTime = 0;
SendQueue[SendIndex[index]].SendCount = 0;
SendQueue[SendIndex[index]].BufLen = 0;
SendQueue[SendIndex[index]].ExtraLen = 0;

Expand Down Expand Up @@ -745,10 +745,10 @@ unsigned int CommBufferClass::Max_Response_Time(void)
*=========================================================================*/
void CommBufferClass::Reset_Response_Time(void)
{
DelaySum = 0L;
NumDelay = 0L;
MeanDelay = 0L;
MaxDelay = 0L;
DelaySum = 0;
NumDelay = 0;
MeanDelay = 0;
MaxDelay = 0;

} /* end of Reset_Response_Time */

Expand Down
2 changes: 1 addition & 1 deletion common/delay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Delay(int duration)
TimerClass timer(BT_SYSTEM, true);

while (duration--) {
count = timer.Time() + 1L;
count = timer.Time() + 1;
while (count >= (unsigned)timer.Time()) {
;
}
Expand Down
6 changes: 3 additions & 3 deletions common/iff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ unsigned int Get_Iff_Chunk_Size(int fh, int id)

/* Otherwise, go to the next chunk in the file */

chunksize = (chunksize + 1) & 0xFFFFFFFEL;
chunksize = (chunksize + 1) & 0xFFFFFFFE;
Seek_File(fh, chunksize, SEEK_CUR);
}
}
Expand Down Expand Up @@ -228,7 +228,7 @@ unsigned int Read_Iff_Chunk(int fh, int id, void* buffer, unsigned int maxsize)
maxsize = MIN(maxsize, chunksize);
Read_File(fh, buffer, maxsize); // Read the buffer.

chunksize = (chunksize + 1) & 0xFFFFFFFEL;
chunksize = (chunksize + 1) & 0xFFFFFFFE;
if (maxsize < chunksize) {
Seek_File(fh, chunksize - maxsize, SEEK_CUR);
}
Expand All @@ -243,7 +243,7 @@ unsigned int Read_Iff_Chunk(int fh, int id, void* buffer, unsigned int maxsize)

/* Otherwise, go to the next chunk in the file */

chunksize = (chunksize + 1) & 0xFFFFFFFEL;
chunksize = (chunksize + 1) & 0xFFFFFFFE;
Seek_File(fh, chunksize, SEEK_CUR);
}
}
Expand Down
16 changes: 8 additions & 8 deletions common/keyframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ uintptr_t Build_Frame(void const* dataptr, unsigned short framenumber, void* buf
ptr = (char*)Add_Long_To_Pointer(dataptr, (offset[0] & 0x00FFFFFFL));

if (keyfr.flags & 1) {
ptr = (char*)Add_Long_To_Pointer(ptr, 768L);
ptr = (char*)Add_Long_To_Pointer(ptr, 768);
}
length = LCW_Uncompress(ptr, buffptr, buffsize);
} else { // key delta or delta
Expand All @@ -366,19 +366,19 @@ uintptr_t Build_Frame(void const* dataptr, unsigned short framenumber, void* buf
}

// key frame
offcurr = offset[1] & 0x00FFFFFFL;
offcurr = offset[1] & 0x00FFFFFF;

// key delta
offdiff = (offset[0] & 0x00FFFFFFL) - offcurr;
offdiff = (offset[0] & 0x00FFFFFF) - offcurr;

ptr = (char*)Add_Long_To_Pointer(dataptr, offcurr);

if (keyfr.flags & 1) {
ptr = (char*)Add_Long_To_Pointer(ptr, 768L);
ptr = (char*)Add_Long_To_Pointer(ptr, 768);
}

#ifndef FIXIT_SCORE_CRASH
off16 = (unsigned int)lockptr & 0x00003FFFL;
off16 = (unsigned int)lockptr & 0x00003FFF;
#endif

length = LCW_Uncompress(ptr, buffptr, buffsize);
Expand All @@ -391,7 +391,7 @@ uintptr_t Build_Frame(void const* dataptr, unsigned short framenumber, void* buf
if (((offset[2] & 0x00FFFFFFL) - offcurr) >= (0x00010000L - off16)) {

ptr = (char*)Add_Long_To_Pointer(ptr, offdiff);
off16 = (unsigned int)ptr & 0x00003FFFL;
off16 = (unsigned int)ptr & 0x00003FFF;

offcurr += offdiff;
offdiff = 0;
Expand All @@ -414,7 +414,7 @@ uintptr_t Build_Frame(void const* dataptr, unsigned short framenumber, void* buf
if (((offset[subframe + 2] & 0x00FFFFFFL) - offcurr) >= (0x00010000L - off16)) {

ptr = (char*)Add_Long_To_Pointer(ptr, offdiff);
off16 = (unsigned int)lockptr & 0x00003FFFL;
off16 = (unsigned int)lockptr & 0x00003FFF;

offcurr += offdiff;
offdiff = 0;
Expand Down 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
2 changes: 1 addition & 1 deletion common/rawfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class RawFileClass : public FileClass
*/
int Transfer_Block_Size(void)
{
return (int)((unsigned)UINT_MAX) - 16L;
return (int)((unsigned)UINT_MAX) - 16;
};

int Raw_Seek(int pos, int dir = SEEK_CUR);
Expand Down
4 changes: 2 additions & 2 deletions common/wsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void* Open_Animation(char const* file_name,
// Else size is zero.
//
if (user_flags & WSA_OPEN_DIRECT) {
target_buffer_size = 0L;
target_buffer_size = 0;
} else {
anim_flags |= WSA_TARGET_IN_BUFFER;
target_buffer_size = (unsigned int)file_header.pixel_width * file_header.pixel_height;
Expand Down Expand Up @@ -1079,7 +1079,7 @@ static unsigned int Get_File_Frame_Offset(int file_handle, int frame, int palett
Seek_File(file_handle, (frame << 2) + WSA_FILE_HEADER_SIZE, SEEK_SET);

if (Read_File(file_handle, (char*)&offset, sizeof(uint32_t)) != sizeof(uint32_t)) {
offset = 0L;
offset = 0;
}
offset = le32toh(offset);
offset += palette_adjust;
Expand Down
6 changes: 3 additions & 3 deletions redalert/aircraft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ void AircraftClass::Read_INI(CCINIClass& ini)
if (token) {
coord = Cell_Coord((CELL)atoi(token));
} else {
coord = 0xFFFFFFFFL;
coord = 0xFFFFFFFF;
}

token = strtok(NULL, ",");
Expand Down 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
28 changes: 14 additions & 14 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 = 0x7FFFFFFF, miny = 0x7FFFFFFF;
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
Loading