Skip to content

Commit

Permalink
SCUMM: Fixed compilation with MSVC
Browse files Browse the repository at this point in the history
Both double and float parameters were passed to atan2(), which didn't match
any variants of atan2()
  • Loading branch information
bluegr committed Apr 27, 2011
1 parent c06dd90 commit 3ab0a13
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions engines/scumm/he/logic_he.cpp
Expand Up @@ -1020,7 +1020,7 @@ int LogicHEsoccer::op_1011(int32 a1, int32 a2, int32 a3, int32 a4, int32 a5) {
// This is called on each frame by startOfFrame() if activated by op_1012.
// This seems to do player placement!

float v28;
float v28 = 0.0;

for (int i = 0; i < 18; i++) {
// These seem to be some sort of percent? of angles?
Expand Down Expand Up @@ -1060,15 +1060,15 @@ int LogicHEsoccer::op_1011(int32 a1, int32 a2, int32 a3, int32 a4, int32 a5) {
putInArray(a5, 0, i, v24 + 11 * v21);
}

float v7 = atan2(_userDataD[524] - v28, v31);
float v7 = atan2(_userDataD[524] - v28, (double)v31);
int v8 = (int)(_userDataD[526] - (_userDataD[521] - v7) * _userDataD[522] + 300.0);

double v9 = atan2(_userDataD[523], v31);
double v9 = atan2(_userDataD[523], (double)v31);
// x/y position?
putInArray(a2, i, 0, (int32)(v29 * v9 + 640.0));
putInArray(a2, i, 1, v8);

double v10 = atan2(_userDataD[524], v31);
double v10 = atan2(_userDataD[524], (double)v31);
int v12 = (int)(_userDataD[526] - (_userDataD[521] - (float)v10) * _userDataD[522] + 300.0);
double v13 = _userDataD[523];

Expand Down

5 comments on commit 3ab0a13

@lordhoto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exactly is the explicit cast to double required here? It should do that implicitly.

@Strangerke
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because MSVC doesn't implicitely cast in that case.

@lordhoto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really a great explanation :-P. What does it complain about exactly?

@Strangerke
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It complains because it knows atan2(double, double) and atan2(float, float) and don't know what to decide.

@bluegr
Copy link
Member Author

@bluegr bluegr commented on 3ab0a13 Apr 27, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error thrown is:
error C2666: 'atan2': 3 overloads have similar conversions

MSVC doesn't promote floats to doubles, thus it can't find an atan2 overload that contains both a double and a float parameter

Please sign in to comment.