Skip to content

Commit 05725eb

Browse files
authored
refactor: Remove use of 'long' integral type. (w3dhub#80)
The 'long' type varies in size between different 64bit ABIs and as such is an issue for portability.
1 parent 336e68b commit 05725eb

489 files changed

Lines changed: 2702 additions & 2813 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Code/BandTest/BandTest.cpp

Lines changed: 70 additions & 70 deletions
Large diffs are not rendered by default.

Code/BandTest/BandTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ typedef struct tBandtestSettingsStruct {
115115

116116
#define BANDTEST_API_VERSION 0x101
117117

118-
BANDTEST_API unsigned long Detect_Bandwidth(unsigned long server_ip, unsigned long my_ip, int retries, int &failure_code, unsigned long &downstream, unsigned long api_version, BandtestSettingsStruct *settings = NULL, char *regpath = NULL);
118+
BANDTEST_API unsigned int Detect_Bandwidth(unsigned int server_ip, unsigned int my_ip, int retries, int &failure_code, unsigned int &downstream, unsigned int api_version, BandtestSettingsStruct *settings = NULL, char *regpath = NULL);

Code/BinkMovie/BinkPlayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void BINKMovieClass::Render()
254254
}
255255

256256
if (SubTitleManager) {
257-
unsigned long movieTime = (Bink->FrameNum * TicksPerFrame);
257+
unsigned int movieTime = (Bink->FrameNum * TicksPerFrame);
258258
SubTitleManager->Process(movieTime);
259259
SubTitleManager->Render();
260260
}

Code/BinkMovie/BinkPlayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class BINKMovieClass : public MovieClass
3434
HBINK Bink;
3535
bool FrameChanged;
3636
unsigned TextureCount;
37-
unsigned long TicksPerFrame;
37+
unsigned int TicksPerFrame;
3838

3939
struct TextureInfoStruct {
4040
TextureClass* Texture;

Code/BinkMovie/subtitle.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ void SubTitleClass::Set_RGB_Color(
113113
{
114114
// Combine components as 8:8:8
115115
mRGBColor = (
116-
((unsigned long)red << 16) |
117-
((unsigned long)green << 8) |
118-
(unsigned long)blue);
116+
((unsigned int)red << 16) |
117+
((unsigned int)green << 8) |
118+
(unsigned int)blue);
119119
}
120120

121121

Code/BinkMovie/subtitle.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,22 @@ class SubTitleClass
5252
~SubTitleClass();
5353

5454
// Set the time (in milliseconds) at which the subtitle is to be displayed.
55-
void Set_Display_Time(unsigned long time) { mTimeStamp = time; }
55+
void Set_Display_Time(unsigned int time) { mTimeStamp = time; }
5656

5757
// Retrieve the time in ticks (1/60 seconds) this subtitle is to be displayed.
58-
unsigned long Get_Display_Time(void) const { return mTimeStamp; }
58+
unsigned int Get_Display_Time(void) const { return mTimeStamp; }
5959

6060
// Set the time duration in ticks (1/60 seconds) for the subtitle to remain displayed.
61-
void Set_Display_Duration(unsigned long duration) { mDuration = duration; }
61+
void Set_Display_Duration(unsigned int duration) { mDuration = duration; }
6262

6363
// Retrieve the duration time in ticks (1/60 seconds) for the subtitle.
64-
unsigned long Get_Display_Duration(void) const { return mDuration; }
64+
unsigned int Get_Display_Duration(void) const { return mDuration; }
6565

6666
// Set the color the subtitle caption should be displayed in.
6767
void Set_RGB_Color(unsigned char red, unsigned char green, unsigned char blue);
6868

6969
// Retrieve the color of the subtitle
70-
unsigned long Get_RGB_Color(void) const { return mRGBColor; }
70+
unsigned int Get_RGB_Color(void) const { return mRGBColor; }
7171

7272
// Set the line position the subtitle should be displayed at.
7373
void Set_Line_Position(int linePos)
@@ -101,9 +101,9 @@ class SubTitleClass
101101
const wchar_t* Get_Caption(void) const { return mCaption; }
102102

103103
private:
104-
unsigned long mTimeStamp;
105-
unsigned long mDuration;
106-
unsigned long mRGBColor;
104+
unsigned int mTimeStamp;
105+
unsigned int mDuration;
106+
unsigned int mRGBColor;
107107
int mLinePosition;
108108
Alignment mAlignment;
109109
wchar_t* mCaption;

Code/BinkMovie/subtitlemanager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ bool SubTitleManagerClass::Load_Sub_Titles(const char* moviename, const char* su
214214
*
215215
******************************************************************************/
216216

217-
bool SubTitleManagerClass::Process(unsigned long movieTime)
217+
bool SubTitleManagerClass::Process(unsigned int movieTime)
218218
{
219219
if (mSubTitles == NULL) {
220220
return false;
@@ -234,7 +234,7 @@ bool SubTitleManagerClass::Process(unsigned long movieTime)
234234

235235
// Check the display time against the current movie time. If it is time
236236
// to display the subtitle then send a subtitle event to the client.
237-
unsigned long displayTime = subtitle->Get_Display_Time();
237+
unsigned int displayTime = subtitle->Get_Display_Time();
238238

239239
// If its not time then we are done.
240240
if (displayTime > movieTime) {
@@ -256,7 +256,7 @@ bool SubTitleManagerClass::Process(unsigned long movieTime)
256256
// If the active subtitles duration has expired then remove it as being active.
257257
if (mActiveSubTitle != NULL) {
258258
SubTitleClass* subtitle = mActiveSubTitle;
259-
unsigned long expireTime = subtitle->Get_Display_Time() + subtitle->Get_Display_Duration();
259+
unsigned int expireTime = subtitle->Get_Display_Time() + subtitle->Get_Display_Duration();
260260

261261
if (movieTime >= expireTime) {
262262
mActiveSubTitle = NULL;
@@ -339,7 +339,7 @@ void SubTitleManagerClass::Draw_Sub_Title(const SubTitleClass* subtitle)
339339
Renderer.Build_Sentence(string);
340340

341341
// Set font color
342-
unsigned long rgbColor = subtitle->Get_RGB_Color()|0xff000000;
342+
unsigned int rgbColor = subtitle->Get_RGB_Color()|0xff000000;
343343

344344
Renderer.Draw_Sentence(rgbColor);
345345
}

Code/BinkMovie/subtitlemanager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class SubTitleManagerClass
6565
void Reset(void);
6666

6767
// Process subtitles
68-
bool Process(unsigned long movieTime);
68+
bool Process(unsigned int movieTime);
6969
void Render();
7070

7171
private:

Code/BinkMovie/subtitleparser.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#define COLOR_TOKEN L"Color"
5353
#define TEXT_TOKEN L"Text"
5454

55-
unsigned long DecodeTimeString(wchar_t* string);
55+
unsigned int DecodeTimeString(wchar_t* string);
5656
void Parse_Time(wchar_t* string, SubTitleClass* subTitle);
5757
void Parse_Duration(wchar_t* string, SubTitleClass* subTitle);
5858
void Parse_Position(wchar_t* string, SubTitleClass* subTitle);
@@ -442,7 +442,7 @@ wchar_t* SubTitleParserClass::Get_Next_Line(void)
442442

443443

444444
// Convert a time string in the format hh:mm:ss:tt into 1/60 second ticks.
445-
unsigned long Decode_Time_String(wchar_t* string)
445+
unsigned int Decode_Time_String(wchar_t* string)
446446
{
447447
#define TICKS_PER_SECOND 60
448448
#define TICKS_PER_MINUTE (60 * TICKS_PER_SECOND)
@@ -460,27 +460,27 @@ unsigned long Decode_Time_String(wchar_t* string)
460460
wchar_t* separator = wcschr(ptr, L':');
461461
WWASSERT(separator != NULL);
462462
*separator++ = 0;
463-
unsigned long hours = wcstoul(ptr, NULL, 10);
463+
unsigned int hours = wcstoul(ptr, NULL, 10);
464464

465465
// Isolate minutes part
466466
ptr = separator;
467467
separator = wcschr(ptr, L':');
468468
WWASSERT(separator != NULL);
469469
*separator++ = 0;
470-
unsigned long minutes = wcstoul(ptr, NULL, 10);
470+
unsigned int minutes = wcstoul(ptr, NULL, 10);
471471

472472
// Isolate seconds part
473473
ptr = separator;
474474
separator = wcschr(ptr, L':');
475475
WWASSERT(separator != NULL);
476476
*separator++ = 0;
477-
unsigned long seconds = wcstoul(ptr, NULL, 10);
477+
unsigned int seconds = wcstoul(ptr, NULL, 10);
478478

479479
// Isolate hundredth part (1/100th of a second)
480480
ptr = separator;
481-
unsigned long hundredth = wcstoul(ptr, NULL, 10);
481+
unsigned int hundredth = wcstoul(ptr, NULL, 10);
482482

483-
unsigned long time = (hours * TICKS_PER_HOUR);
483+
unsigned int time = (hours * TICKS_PER_HOUR);
484484
time += (minutes * TICKS_PER_MINUTE);
485485
time += (seconds * TICKS_PER_SECOND);
486486
time += ((hundredth * TICKS_PER_SECOND) / 100);
@@ -493,7 +493,7 @@ void Parse_Time(wchar_t* param, SubTitleClass* subTitle)
493493
{
494494
WWASSERT(param != NULL);
495495
WWASSERT(subTitle != NULL);
496-
unsigned long time = Decode_Time_String(param);
496+
unsigned int time = Decode_Time_String(param);
497497
subTitle->Set_Display_Time(time);
498498
}
499499

@@ -502,7 +502,7 @@ void Parse_Duration(wchar_t* param, SubTitleClass* subTitle)
502502
{
503503
WWASSERT(param != NULL);
504504
WWASSERT(subTitle != NULL);
505-
unsigned long time = Decode_Time_String(param);
505+
unsigned int time = Decode_Time_String(param);
506506

507507
if (time > 0) {
508508
subTitle->Set_Display_Duration(time);

Code/Combat/actionparams.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ActionParamsStruct {
8080
ActionParamsStruct( void );
8181

8282
void Set_Basic( GameObjObserverClass * script, float priority, int action_id, SoldierAIState ai_state = NO_AI_STATE_CHANGE ) { ObserverID = script->Get_ID(); Priority = priority; ActionID = action_id; AIState = ai_state; }
83-
void Set_Basic( long observer_id, float priority, int action_id, SoldierAIState ai_state = NO_AI_STATE_CHANGE ) { ObserverID = observer_id; Priority = priority; ActionID = action_id; AIState = ai_state; }
83+
void Set_Basic( int observer_id, float priority, int action_id, SoldierAIState ai_state = NO_AI_STATE_CHANGE ) { ObserverID = observer_id; Priority = priority; ActionID = action_id; AIState = ai_state; }
8484

8585
void Set_Look( const Vector3 & location, float duration ) { LookLocation = location; LookDuration = duration; }
8686
void Set_Look( GameObject * object, float duration ) { LookObject = object; LookDuration = duration; }
@@ -106,7 +106,7 @@ class ActionParamsStruct {
106106
// Note: all of these must be saved in SafeActionParamsStruct::Save
107107
int Priority;
108108
int ActionID;
109-
long ObserverID;
109+
int ObserverID;
110110

111111
Vector3 LookLocation;
112112
GameObject * LookObject;

0 commit comments

Comments
 (0)