Skip to content

Commit

Permalink
core: Fix a handful of types that were added after this PR was origin…
Browse files Browse the repository at this point in the history
…ally drafted
  • Loading branch information
kmeisthax committed Nov 30, 2022
1 parent a98f3e2 commit 042ee49
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/src/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct Duration(f64);
impl Duration {
pub const ZERO: Self = Self(0.0);
pub const ONE_SECOND: Self = Self(1.0);
pub const MAX: Self = Self(f64::MAX);

pub fn from_secs(secs: f64) -> Self {
Self::from_nanos(secs * 1_000_000_000.0)
Expand Down
4 changes: 2 additions & 2 deletions core/src/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl ExecutionLimit {
Self {
current_oplimit: Some(0),
max_ops_per_check: Some(0),
time_limit: Duration::from_secs(0),
time_limit: Duration::from_secs(0.0),
}
}

Expand All @@ -80,7 +80,7 @@ impl ExecutionLimit {
*oplimit = oplimit.saturating_sub(ops);

if *oplimit == 0 {
if context.update_start.elapsed() >= self.time_limit {
if context.update_start.elapsed().as_nanos() as f64 >= self.time_limit.as_nanos() {
return true;
}

Expand Down
5 changes: 4 additions & 1 deletion core/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,10 @@ impl<'gc> Loader<'gc> {
Loader::preload_tick(
handle,
uc,
&mut ExecutionLimit::with_max_ops_and_time(10000, Duration::from_millis(1)),
&mut ExecutionLimit::with_max_ops_and_time(
10000,
Duration::from_millis(1.0),
),
)?;

return Ok(());
Expand Down
2 changes: 1 addition & 1 deletion core/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ impl Player {
}

pub fn run_frame(&mut self) {
let frame_time = std::time::Duration::from_nanos((750_000_000.0 / self.frame_rate) as u64);
let frame_time = Duration::from_nanos(750_000_000.0 / self.frame_rate);
let (mut execution_limit, may_execute_while_streaming) = match self.load_behavior {
LoadBehavior::Streaming => (
ExecutionLimit::with_max_ops_and_time(10000, frame_time),
Expand Down

0 comments on commit 042ee49

Please sign in to comment.