ManaPlus
delayedmanager.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2011-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
23 
25 
26 #include "utils/foreach.h"
27 #include "utils/timer.h"
28 
29 #include "debug.h"
30 
32 
34 {
35  BLOCK_START("DelayedManager::delayedLoad")
36  static int loadTime = 0;
37  if (loadTime < cur_time)
38  {
39  loadTime = tick_time;
40 
41  int k = 0;
43  const DelayedAnimIter it_end = mDelayedAnimations.end();
44  while (it != it_end && k < 1)
45  {
46  (*it)->load();
47  AnimationDelayLoad *tmp = *it;
48  it = mDelayedAnimations.erase(it);
49  delete tmp;
50  k ++;
51  }
52  const int time2 = tick_time;
53  if (time2 > loadTime)
54  loadTime = time2 + (time2 - loadTime) * 2 + 10;
55  else
56  loadTime = time2 + 3;
57  }
58  BLOCK_END("DelayedManager::delayedLoad")
59 }
60 
62  *const delayedLoad)
63 {
65  {
66  if (*it == delayedLoad)
67  {
68  mDelayedAnimations.erase(it);
69  return;
70  }
71  }
72 }
volatile time_t cur_time
Definition: timer.cpp:58
static void delayedLoad()
static DelayedAnim mDelayedAnimations
static void removeDelayLoad(const AnimationDelayLoad *const delayedLoad)
DelayedAnim::iterator DelayedAnimIter
std::list< AnimationDelayLoad * > DelayedAnim
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
volatile int tick_time
Definition: timer.cpp:53
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79