-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fix a narrowing conversion #964
base: vanilla
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments apply to both games code, seems like a lot of changes to just silence a warning?
@@ -205,19 +205,19 @@ extern int RESFACTOR; | |||
** Enable the set of limited cheat key options. | |||
*/ | |||
#ifdef VIRGIN_CHEAT_KEYS | |||
#define PARM_PLAYTEST 0xF7DDC227 // "PLAYTEST" | |||
#define PARM_PLAYTEST 0xF7DDC227UL // "PLAYTEST" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint32_t is not unsigned long on all platforms.
@@ -165,7 +165,7 @@ class xTargetClass | |||
void Invalidate(void) | |||
{ | |||
Target.Sub.Exponent = RTTI_NONE; | |||
Target.Sub.Mantissa = -1; | |||
Target.Sub.Mantissa = (1UL << TARGET_MANTISSA) - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is equivalent?
@@ -2318,7 +2318,7 @@ void Load_Recording_Values(void) | |||
* HISTORY: * | |||
* 08/19/1995 JLB : Created. * | |||
*=============================================================================================*/ | |||
long Obfuscate(char const* string) | |||
uint32_t Obfuscate(char const* string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The long type needs to go as its width varies between platforms but it should just change to int to match the ra code?
It's not only to get rid of the warning. Obfuscate() currently operates on an int, but in TD returns a long (unlike RA, which currently returns an int). Comparing that to a constant like 0xF7DDC227 may fail if the function actually returned 0xFFFFFFFFF7DDC227 because it was sign-extended to long. The only safe way is to declare them to return unsigned int (or uint32_t in this case), since this is what they actually calculate. |
I'd be happy to see it changed to unsigned int in both cases. |
No description provided.