Skip to content

Commit

Permalink
Update Screen.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram authored Feb 13, 2019
1 parent 2f30c72 commit 4ac9bce
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions src/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,49 +111,6 @@ Screen::EndScreen()
m_bRunning = false;
}

inline void
Screen::UpdateTimedFunctions(float fDeltaTime)
{
for (auto it = delayedFunctions.begin(); it != delayedFunctions.end();
++it) {
auto& delayedF = *it;
delayedF.second -= fDeltaTime;
if (delayedF.second <= 0) {
delayedF.first();
}
}
// Doing this in place did weird things
delayedFunctions.erase(std::remove_if(delayedFunctions.begin(),
delayedFunctions.end(),
[](pair<function<void()>, float>& x) {
return x.second <= 0;
}),
delayedFunctions.end());
if (!delayedPeriodicFunctionIdsToDelete.empty()) {
auto* L = LUA->Get();
for (auto id : delayedPeriodicFunctionIdsToDelete) {
luaL_unref(L, LUA_REGISTRYINDEX, id);
auto& vec = this->delayedPeriodicFunctions;
vec.erase(std::remove_if(
vec.begin(),
vec.end(),
[id](tuple<function<void()>, float, float, int>& x) {
return std::get<3>(x) == id;
}),
vec.end());
}
LUA->Release(L);
delayedPeriodicFunctionIdsToDelete.clear();
}
for (auto& delayedF : delayedPeriodicFunctions) {
std::get<1>(delayedF) -= fDeltaTime;
if (std::get<1>(delayedF) <= 0) {
std::get<0>(delayedF)();
std::get<1>(delayedF) = std::get<2>(delayedF);
}
}
}

void
Screen::UpdateTimedFunctions(float fDeltaTime)
{
Expand Down

0 comments on commit 4ac9bce

Please sign in to comment.