desktop file ended up in the wrong place.
[crack-attack.git] / src / ComboManager.h
blob62c446b14e0d1d8fa43456df11c8b1c0e49a993e
1 /*
2 * ComboManager.h
3 * Daniel Nelson - 8/24/0
5 * Copyright (C) 2000 Daniel Nelson
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * Daniel Nelson - aluminumangel.org
22 * 174 W. 18th Ave.
23 * Columbus, OH 43210
26 #ifndef COMBOMANAGER_H
27 #define COMBOMANAGER_H
29 #include <cassert>
31 using namespace std;
33 #include "ComboTabulator.h"
34 #include "BlockManager.h"
35 #include "Block.h"
37 class Block;
39 /* static */ class ComboManager {
40 public:
41 static void gameStart ( );
42 static void timeStep ( );
44 static inline ComboTabulator &newComboTabulator ( )
46 int id = findFreeId();
47 allocateId(id);
48 ComboTabulator &combo = tabulatorStore[id];
50 combo.initialize();
51 return combo;
54 static inline void deleteComboTabulator ( ComboTabulator &combo )
56 freeId(combo.id);
59 static inline void specialBlockTally ( ComboTabulator &combo, Block &block )
61 if (BlockManager::isBaseFlavor(block.flavor)) return;
62 combo.special[BlockManager::mapSpecialFlavorToCode(block.flavor)]++;
66 private:
67 static inline int findFreeId ( )
69 int n;
70 for (n = 0; storeMap[n]; n++);
71 return n;
74 static inline void allocateId ( int id )
76 assert(!storeMap[id]);
77 storeMap[id] = true;
78 combo_count++;
81 static inline void freeId ( int id )
83 assert(storeMap[id]);
84 storeMap[id] = false;
85 combo_count--;
88 static ComboTabulator tabulatorStore[GC_COMBO_TABULATOR_STORE_SIZE];
89 static bool storeMap[GC_COMBO_TABULATOR_STORE_SIZE];
90 static int combo_count;
93 #endif