Skip to content

Commit

Permalink
Use an integer when waiting
Browse files Browse the repository at this point in the history
Since the expected time is in milliseconds, it's best to use an integer instead. Floating-point numbers lose precision as they get larger, especially when the level's current time is long (e.g., over 24 hours). This loss of precision could cause scripts to wait unsuccessfully with small numbers, causing unexpected behaviors
  • Loading branch information
smallmodel committed Dec 13, 2024
1 parent 32bee26 commit acf2dd0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion code/fgame/scriptthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2478,7 +2478,7 @@ void ScriptThread::Stop(void)
}
}

void ScriptThread::Wait(float time)
void ScriptThread::Wait(int time)
{
StartTiming(level.inttime + time);
m_ScriptVM->Suspend();
Expand Down
2 changes: 1 addition & 1 deletion code/fgame/scriptthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class ScriptThread : public Listener
void Execute(Event *ev);
void Execute();
void Execute(ScriptVariable *data, int dataSize);
void Wait(float time);
void Wait(int time);
void Pause(void);
void ScriptExecute(ScriptVariable *data, int dataSize, ScriptVariable& returnValue);
void ScriptExecuteInternal(ScriptVariable *data = NULL, int dataSize = 0);
Expand Down

0 comments on commit acf2dd0

Please sign in to comment.