Fixes for datatype size on amd64.
[crack-attack.git] / src / ComboManager.h
blob3b0b845bd1fd7f950c0bd68a1bd2867a6ecf5bef
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>
32 #include "ComboTabulator.h"
33 #include "BlockManager.h"
34 #include "Block.h"
36 class Block;
38 /* static */ class ComboManager {
39 public:
40 static void gameStart ( );
41 static void timeStep ( );
43 static inline ComboTabulator &newComboTabulator ( )
45 int id = findFreeId();
46 allocateId(id);
47 ComboTabulator &combo = tabulatorStore[id];
49 combo.initialize();
50 return combo;
53 static inline void deleteComboTabulator ( ComboTabulator &combo )
55 freeId(combo.id);
58 static inline void specialBlockTally ( ComboTabulator &combo, Block &block )
60 if (BlockManager::isBaseFlavor(block.flavor)) return;
61 combo.special[BlockManager::mapSpecialFlavorToCode(block.flavor)]++;
65 private:
66 static inline int findFreeId ( )
68 int n;
69 for (n = 0; storeMap[n]; n++);
70 return n;
73 static inline void allocateId ( int id )
75 assert(!storeMap[id]);
76 storeMap[id] = true;
77 combo_count++;
80 static inline void freeId ( int id )
82 assert(storeMap[id]);
83 storeMap[id] = false;
84 combo_count--;
87 static ComboTabulator tabulatorStore[GC_COMBO_TABULATOR_STORE_SIZE];
88 static bool storeMap[GC_COMBO_TABULATOR_STORE_SIZE];
89 static int combo_count;
92 #endif