-
Notifications
You must be signed in to change notification settings - Fork 156
Common - Fix CBA_missionTime in long missions (above 7 days)
#1324
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
Open
commy2
wants to merge
5
commits into
master
Choose a base branch
from
fixLongMission_missionTime
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6771127
fix CBA_missionTime in long missions (above 7 days)
commy2 5435118
Update addons/common/init_perFrameHandler.sqf
commy2 e349411
Merge branch 'master' of https://github.com/CBATeam/CBA_A3 into fixLo…
commy2 e1870bf
fix JIP synch and add CBA_fnc_missionTimeDelta
commy2 2d56569
fix JIP synch and add CBA_fnc_missionTimeDelta
commy2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #include "script_component.hpp" | ||
| /* ---------------------------------------------------------------------------- | ||
| Function: CBA_fnc_missionTimeDelta | ||
|
|
||
| Description: | ||
| Return precise time in seconds between two CBA_missionTimeSTR timestamps. | ||
|
|
||
| Parameters: | ||
| _t0 - Smaller time string <STRING> | ||
| _t1 - Larger time string <STRING> | ||
|
|
||
| Returns: | ||
| Time difference <NUMBER> | ||
|
|
||
| Examples: | ||
| (begin example) | ||
| _elapsedTime = my_oldTimeString call CBA_fnc_missionTimeDelta; | ||
|
|
||
| _deltaTime = [my_oldTimeString, my_newTimeString] call CBA_fnc_missionTimeDelta; | ||
|
|
||
| _missionTime = [] call CBA_fnc_missionTimeDelta; | ||
| (end) | ||
|
|
||
| Author: | ||
| commy2 | ||
| ---------------------------------------------------------------------------- */ | ||
|
|
||
| params [["_t0", "0000.000000", [""]], ["_t1", CBA_missionTimeStr, [""]]]; | ||
|
|
||
| private _len0 = count _t0 - 10; | ||
| private _len1 = count _t1 - 10; | ||
|
|
||
| (parseNumber (_t1 select [0, _len1]) - parseNumber (_t0 select [0, _len0])) * 1000 + | ||
| (parseNumber (_t1 select [_len1]) - parseNumber (_t0 select [_len0])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 think this is better written as:
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.
Isn't that slower though? That shit runs every frame.
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.
It is slightly faster.
Uh oh!
There was an error while loading. Please reload this page.
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.
What was
cba_common_missionTimeSynchronizedin your example? It will betrueall mission long.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.
It was
true; the overall result for both statements was alsotrue.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.
hows the speed without the lazy eval?
creating array, calling "true" command 3 times, creating another array, calling isEqualTo command surely is a bit expensive.
But lazy eval is also expensive but in this case as commy said, we don't expect neither missionTimeSynchronized or the time check to ever be false, so why lazy eval?
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, no lazy eval is the fastest.
Updated the suggestion.