-
Notifications
You must be signed in to change notification settings - Fork 77
Allow user to load difficulty #518
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
Conversation
InfElevator* data = (InfElevator*)allocator_getByIndex(s_infSerState.infElevators, elev->m_id); | ||
return data->type == IELEV_ROTATE_WALL ? floor16(angleToFloat(data->speed)) : floor16(data->speed); | ||
} | ||
|
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.
Thanks for adding this Karjala.
I have realised a (reasonably minor) flaw in my Elevator speed setter. Namely, in INF, it is possible to set an elevator to a floating point speed (like 6.5) whereas I have forced it to be integer (s32).
@luciusDXL and @ifeldshteyn Do you think we should correct this, and allow getting/setting of speed as a float via scripting? If so, would you be able to please make that amendment with this PR?
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.
This function should return a float - both angles and speed are fixed point.
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.
@ifeldshteyn @luciusDXL
Ok I'm pretty much responsible for creating this issue (used int instead of float when I made the setter), so here is the fix
Karjala, please go ahead and cherry pick it.
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.
Looking at this now, I think there is still a problem.
In the infUpdate_rotateWall() function, you can see the speed is a fixed-point angle that gets rounded in the function. This code still truncates it before returning, losing the fractional part of the angle delta, which will break if used in cases like the tram in Harkov.
So you should treat it as a fixed-point value, convert to float and then convert to degrees.
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'm a bit confused, I think you will need to explain in more detail please.
Let's say we want to set a speed of 20.5 degrees / sec
the formula currently there is intToFixed16(floatToAngle(20.5))
floatToAngle(20.5) = 20.5 * 45.51 = 932
intToFixed(932) = 932 << 16 = 61079552
That seems correct, doesn't it? It looks the same as what is done when INF is parsed.
Then back the other way, formula is
angleToFloat(61079552 >> FRAC_BITS_16)
61079552 >> FRAC_BITS_16 = 932
angleToFloat(932) = 932 / 45.51 = 20.479
A small amount of precision has been lost but that's acceptable, isn't it?
ScriptPropertyGetFunc("bool get_master()", getElevMaster); | ||
|
||
|
||
ScriptPropertyGetFunc("int get_speed()", getElevSpeed); |
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.
If you decide to make the change, then this would become
float get_speed()
and
void set_speed(float)
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.
Yeah, non-integer speeds are used in mods and even vanilla levels. So it would make sense to make it float instead of int.
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.
That was me with my brain not being fully engaged when I made the original addition :-)
If you can be bothered Karjala, you can make the amendment, otherwise I'll raise a change (for both the get and set) after this is merged.
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v141</PlatformToolset> | ||
<PlatformToolset>v143</PlatformToolset> |
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.
Oooh, I wonder if Lucius will approve this. I have it as v143 too, it would save me the hassle of continually stashing and unstashing this file whenever I merge/rebase etc.
I assumed he must have some reason to want to keep it at v141....
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.
CRUD - accidental commit =)
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.
lol
TheForceEngine/crashdump.dmp
Outdated
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 meant to be here? Mistake?
<ContentFiles /> | ||
<SatelliteDlls /> | ||
<NonRecipeFileRefs /> | ||
</Project> No newline at end of file |
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 these recipe files are supposed to be committed?
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.
This recipe file is still here
Currently VS2017 is used to preserve support for Win7 and 8 (theoretically at least). |
The ForceEngine Github builds work in Windows 7 x64 so far, practically that is. |
|
||
InfElevator* data = (InfElevator*)allocator_getByIndex(s_infSerState.infElevators, elev->m_id); | ||
data->speed = data->type == IELEV_ROTATE_WALL ? FIXED(floatToAngle(value)) : FIXED(value); | ||
data->speed = data->type == IELEV_ROTATE_WALL ? intToFixed16(floatToAngle(value)) : floatToFixed16(value); |
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.
Same issue here, you are losing the fractional part of the angular speed. angle degrees to DF angles -> float to fixed I think is the order here.
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.
Ok, I think see what you are saying. But line 2157 of infSystem.cpp
uses intToFixed
and therefore loses the precision as well. That is from vanilla, isn't it? Isn't it reasonable to just copy what vanilla does when it parses INF?
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.
Just looked at this again. A couple issues, I think
if (!ScriptElev::isScriptElevValid(elev)) { return 0; } | ||
|
||
InfElevator* data = (InfElevator*)allocator_getByIndex(s_infSerState.infElevators, elev->m_id); | ||
return data->type == IELEV_ROTATE_WALL ? degreesToFixedAngle(data->speed) : fixed16ToFloat(data->speed); |
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.
Just looking at this again -- I think you've got these round the wrong way.
This is the getter, so it should call fixedAngleToDegrees
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.
@Karjala22 I've built this and tested it and yes, you need to swap these functions around
Here it should be fixedAngleToDegrees
And in the setter below it should be degreesToFixedAngle
|
||
InfElevator* data = (InfElevator*)allocator_getByIndex(s_infSerState.infElevators, elev->m_id); | ||
data->speed = data->type == IELEV_ROTATE_WALL ? FIXED(floatToAngle(value)) : FIXED(value); | ||
data->speed = data->type == IELEV_ROTATE_WALL ? fixedAngleToDegrees(value) : floatToFixed16(value); |
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.
This is the setter, so I think it should call degreesToFixedAngle
<ContentFiles /> | ||
<SatelliteDlls /> | ||
<NonRecipeFileRefs /> | ||
</Project> No newline at end of file |
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.
This recipe file is still here
if (!ScriptElev::isScriptElevValid(elev)) { return 0; } | ||
|
||
InfElevator* data = (InfElevator*)allocator_getByIndex(s_infSerState.infElevators, elev->m_id); | ||
return data->type == IELEV_ROTATE_WALL ? degreesToFixedAngle(data->speed) : fixed16ToFloat(data->speed); |
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.
@Karjala22 I've built this and tested it and yes, you need to swap these functions around
Here it should be fixedAngleToDegrees
And in the setter below it should be degreesToFixedAngle
Removing spurious file.
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.
This looks all good to me now. Thanks Karjala
Allow FS to load the current difficulty