- Fixed addToQueue assertion bug
[crack-attack.git] / src / GarbageGenerator.h
blob487f2c78edf6cbfa451466505b7d00e276f93bb8
1 /*
2 * GarbageGenerator.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 GARBAGEGENERATOR_H
27 #define GARBAGEGENERATOR_H
29 using namespace std;
31 #include "Game.h"
32 #include "MetaState.h"
33 #include "Communicator.h"
34 #include "Random.h"
35 #include "ComputerPlayer.h"
37 class ComboTabulator;
38 class CommunicationBuffer;
40 class GarbageQueueElement {
41 public:
42 bool active;
43 int alarm;
44 int height;
45 int width;
46 int flavor;
49 class ComputerPlayer;
51 /* static */ class GarbageGenerator {
52 public:
53 static void gameStart ( );
55 static void comboElimination ( ComboTabulator &combo );
56 static void comboComplete ( ComboTabulator &combo );
57 static void timeStep ( );
58 static void addToQueue ( GarbageQueueElement *e );
59 static void addToQueue ( CommunicationBuffer &buffer );
60 static void addToQueue ( BufferElement garbage[], size_t size );
61 static void addToQueue ( uint32 height, uint32 width, uint32 flavor, uint32 stamp );
64 private:
65 static void sendGarbage ( int height, int width, int flavor );
66 static void sendSpecialGarbage ( int flavor );
68 static inline int determineDropTime ( int time_stamp )
70 return time_stamp
71 + (GC_AVERAGE_GARBAGE_DROP_DELAY - GC_SPREAD_GARBAGE_DROP_DELAY / 2)
72 + Random::number(GC_SPREAD_GARBAGE_DROP_DELAY);
75 static void dealLocalGarbage ( int height, int width, int flavor,
76 int time_stamp );
77 static void dealSpecialLocalGarbage ( int flavor, int time_stamp );
79 static GarbageQueueElement garbage_queue[GC_GARBAGE_QUEUE_SIZE];
80 static int waiting_count;
83 #endif