Debian Codegraph @

src/pipequeue.cpp

raw symbols SCIP
1 /***************************************************************************
2 pipequeue.cpp - description
3 -------------------
4 begin : Sat Sep 30 2000
5 copyright : (C) 2000 by Waldemar Baraldi
6 email : [email protected]
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include "pipequeue.h"cxx . . $ `<file>/src/pipequeue.h`/
19 #include "cross.h"cxx . . $ `<file>/src/cross.h`/
20 #include "horizontal.h"cxx . . $ `<file>/src/horizontal.h`/
21 #include "vertical.h"cxx . . $ `<file>/src/vertical.h`/
22 #include "elbowupright.h"cxx . . $ `<file>/src/elbowupright.h`/
23 #include "elbowdownright.h"cxx . . $ `<file>/src/elbowdownright.h`/
24 #include "elbowupleft.h"cxx . . $ `<file>/src/elbowupleft.h`/
25 #include "elbowdownleft.h"cxx . . $ `<file>/src/elbowdownleft.h`/
26 #include "horizontalbowl.h"cxx . . $ `<file>/src/horizontalbowl.h`/
27 #include "verticalbowl.h"cxx . . $ `<file>/src/verticalbowl.h`/
28 #include "random.h"cxx . . $ `<file>/src/random.h`/
29
30 PipeQueuecxx . . $ PipeQueue#::PipeQueuecxx . . $ PipeQueue#PipeQueue(49f6e7a06ebc5aa8).():AnimatedCanvascxx . . $ AnimatedCanvas#(){
31 indexcxx . . $ PipeQueue#index.=0;
32 changecxx . . $ PipeQueue#change.=true;
33 res_coefcxx . . $ PipeQueue#res_coef.=0;
34 fixed_coefcxx . . $ PipeQueue#fixed_coef.=0;
35 filledcxx . . $ PipeQueue#filled.=false;
36 }
37
38 PipeQueuecxx . . $ PipeQueue#::~cxx . . $ PipeQueue#`~PipeQueue`(ced63f7c635d850d).PipeQueuecxx . . $ PipeQueue#(){
39 if (filledcxx . . $ PipeQueue#filled.)
40 for (int i=0;i<MaxPipescxx . . $ PipeQueue#MaxPipes.;i++)
41 delete queuecxx . . $ PipeQueue#queue.[i];
42 }
43
44 int PipeQueuecxx . . $ PipeQueue#::widthcxx . . $ PipeQueue#width(b126dc7c1de90089).(){
45 return PipeWidthcxx . . $ PipeWidth.;
46 }
47
48 int PipeQueuecxx . . $ PipeQueue#::heightcxx . . $ PipeQueue#height(b126dc7c1de90089).(){
49 return PipeHeightcxx . . $ PipeHeight.;
50 }
51
52 Pipecxx . . $ Pipe# * PipeQueuecxx . . $ PipeQueue#::getPipecxx . . $ PipeQueue#getPipe(2fbaffac9791ec43).(int pos){
53 changecxx . . $ PipeQueue#change.=true;
54 if (!filledcxx . . $ PipeQueue#filled.) fillUpcxx . . $ PipeQueue#fillUp(49f6e7a06ebc5aa8).();
55 return queuecxx . . $ PipeQueue#queue.[(pos+indexcxx . . $ PipeQueue#index.)%MaxPipescxx . . $ PipeQueue#MaxPipes.];
56 }
57
58 Pipecxx . . $ Pipe# * PipeQueuecxx . . $ PipeQueue#::getHeadcxx . . $ PipeQueue#getHead(4e868c031ff97e2e).(){
59 if (!filledcxx . . $ PipeQueue#filled.) fillUpcxx . . $ PipeQueue#fillUp(49f6e7a06ebc5aa8).();
60
61 Pipecxx . . $ Pipe# * aux=queuecxx . . $ PipeQueue#queue.[indexcxx . . $ PipeQueue#index.];
62 queuecxx . . $ PipeQueue#queue.[indexcxx . . $ PipeQueue#index.]=generatePipecxx . . $ PipeQueue#generatePipe(4e868c031ff97e2e).();
63 indexcxx . . $ PipeQueue#index.=(indexcxx . . $ PipeQueue#index.+1)% MaxPipescxx . . $ PipeQueue#MaxPipes.;
64 changecxx . . $ PipeQueue#change.=true;
65 return aux;
66 }
67
68 void PipeQueuecxx . . $ PipeQueue#::setRestrictionCoefcxx . . $ PipeQueue#setRestrictionCoef(cb2f890c2fdad230).(unsigned int coef){
69 if (coef > 100)
70 res_coefcxx . . $ PipeQueue#res_coef.=100;
71 else res_coefcxx . . $ PipeQueue#res_coef.=coef;
72 }
73
74 void PipeQueuecxx . . $ PipeQueue#::setFixedCoefcxx . . $ PipeQueue#setFixedCoef(cb2f890c2fdad230).(unsigned int coef){
75 if (coef > 100)
76 fixed_coefcxx . . $ PipeQueue#fixed_coef.=100;
77 else fixed_coefcxx . . $ PipeQueue#fixed_coef.=coef;
78
79 }
80
81 bool PipeQueuecxx . . $ PipeQueue#::isChangedcxx . . $ PipeQueue#isChanged(c9857a73d68e59ba).(){
82 return changecxx . . $ PipeQueue#change.;
83 }
84
85 void PipeQueuecxx . . $ PipeQueue#::fillUpcxx . . $ PipeQueue#fillUp(49f6e7a06ebc5aa8).(){
86 for (indexcxx . . $ PipeQueue#index.=0;indexcxx . . $ PipeQueue#index.<MaxPipescxx . . $ PipeQueue#MaxPipes.;indexcxx . . $ PipeQueue#index.++)
87 queuecxx . . $ PipeQueue#queue.[indexcxx . . $ PipeQueue#index.]=generatePipecxx . . $ PipeQueue#generatePipe(4e868c031ff97e2e).();
88 indexcxx . . $ PipeQueue#index.=0;
89 changecxx . . $ PipeQueue#change.=true;
90 filledcxx . . $ PipeQueue#filled.=true;
91 }
92
93 void PipeQueuecxx . . $ PipeQueue#::paintcxx . . $ PipeQueue#paint(dec28a01b93bce57).(VideoManagercxx . . $ VideoManager# * vm){
94 if (changecxx . . $ PipeQueue#change.){
95 int i,j;
96 Imagecxx . . $ Image# * ima=vm->getImageManagercxx . . $ VideoManager#getImageManager(d5fe12bbc8163445).()->getImagecxx . . $ ImageManager#getImage(3ac71a4852078d03).(new Strcxx . . $ Str#("queue_one.png"));
97 vm->blitcxx . . $ VideoManager#blit(d6e51777aa68e081).(ima, xcxx . . $ Canvas#x.,ycxx . . $ Canvas#y.);
98
99 //Pintar los pipes
100 j=indexcxx . . $ PipeQueue#index.;
101 for (i=0;i<MaxPipescxx . . $ PipeQueue#MaxPipes.;i++){
102 j=(j+MaxPipescxx . . $ PipeQueue#MaxPipes. -1)% MaxPipescxx . . $ PipeQueue#MaxPipes.;
103 queuecxx . . $ PipeQueue#queue.[j]->setPoscxx . . $ Canvas#setPos(3e454b8ccf442868).(xcxx . . $ Canvas#x.+27, ycxx . . $ Canvas#y.+5+i*queuecxx . . $ PipeQueue#queue.[j]->heightcxx . . $ Pipe#height(b126dc7c1de90089).());
104 queuecxx . . $ PipeQueue#queue.[j]->paintcxx . . $ Canvas#paint(dec28a01b93bce57).(vm);
105 }
106 }
107 changecxx . . $ PipeQueue#change.=false;
108 }
109
110 Pipecxx . . $ Pipe# * PipeQueuecxx . . $ PipeQueue#::generatePipecxx . . $ PipeQueue#generatePipe(4e868c031ff97e2e).(){
111
112 Pipecxx . . $ Pipe# * aux=NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
113 Randomcxx . . $ Random# * r=new Randomcxx . . $ Random#();
114 switch ((r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0, 6))){
115
116 case 0: {
117 aux=new Crosscxx . . $ Cross#();
118 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=fixed_coefcxx . . $ PipeQueue#fixed_coef.)
119 aux->setFixedcxx . . $ Pipe#setFixed(b45ddcbc8423892c).(true);
120 for (int i=0;i<2;i++)
121 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=res_coefcxx . . $ PipeQueue#res_coef.)
122 switch (r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0, 3)){
123 case 0:{
124 if (!aux->isRestrictedAsOutputcxx . . $ Pipe#isRestrictedAsOutput(eebf787ddd78fff5).(Southcxx . . $ South.))
125 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Northcxx . . $ North.);
126 break;
127 }
128 case 1:{
129 if (!aux->isRestrictedAsOutputcxx . . $ Pipe#isRestrictedAsOutput(eebf787ddd78fff5).(Northcxx . . $ North.))
130 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Southcxx . . $ South.);
131 break;
132 }
133 case 2:{
134 if (!aux->isRestrictedAsOutputcxx . . $ Pipe#isRestrictedAsOutput(eebf787ddd78fff5).(Eastcxx . . $ East.))
135 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Westcxx . . $ West.);
136 break;
137 }
138 case 3:{
139 if (!aux->isRestrictedAsOutputcxx . . $ Pipe#isRestrictedAsOutput(eebf787ddd78fff5).(Westcxx . . $ West.))
140 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Eastcxx . . $ East.);
141 break;
142 }
143 default:break;
144 }
145 break;
146 }
147 case 1: {
148 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0,3))
149 aux=new Horizontalcxx . . $ Horizontal#();
150 else aux= new HorizontalBowlcxx . . $ HorizontalBowl#();
151 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=fixed_coefcxx . . $ PipeQueue#fixed_coef.)
152 aux->setFixedcxx . . $ Pipe#setFixed(b45ddcbc8423892c).(true);
153 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=res_coefcxx . . $ PipeQueue#res_coef.)
154 switch (r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0, 1)){
155 case 0:{
156 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Westcxx . . $ West.);
157 break;
158 }
159 case 1:{
160 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Eastcxx . . $ East.);
161 break;
162 }
163 default:break;
164 }
165 break;
166 }
167 case 2: {
168 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0,3))
169 aux= new Verticalcxx . . $ Vertical#();
170 else aux= new VerticalBowlcxx . . $ VerticalBowl#();
171 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=fixed_coefcxx . . $ PipeQueue#fixed_coef.)
172 aux->setFixedcxx . . $ Pipe#setFixed(b45ddcbc8423892c).(true);
173 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=res_coefcxx . . $ PipeQueue#res_coef.)
174 switch (r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0, 1)){
175 case 0:{
176 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Northcxx . . $ North.);
177 break;
178 }
179 case 1:{
180 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Southcxx . . $ South.);
181 break;
182 }
183 default:break;
184 }
185 break;
186 }
187 case 3: {
188 aux= new ElbowUpRightcxx . . $ ElbowUpRight#();
189 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=fixed_coefcxx . . $ PipeQueue#fixed_coef.)
190 aux->setFixedcxx . . $ Pipe#setFixed(b45ddcbc8423892c).(true);
191 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=res_coefcxx . . $ PipeQueue#res_coef.)
192 switch (r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0, 1)){
193 case 0:{
194 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Northcxx . . $ North.);
195 break;
196 }
197 case 1:{
198 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Eastcxx . . $ East.);
199 break;
200 }
201 default:break;
202 }
203 break;
204 }
205 case 4: {
206 aux= new ElbowUpLeftcxx . . $ ElbowUpLeft#();
207 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=fixed_coefcxx . . $ PipeQueue#fixed_coef.)
208 aux->setFixedcxx . . $ Pipe#setFixed(b45ddcbc8423892c).(true);
209 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=res_coefcxx . . $ PipeQueue#res_coef.)
210 switch (r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0, 1)){
211 case 0:{
212 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Northcxx . . $ North.);
213 break;
214 }
215 case 1:{
216 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Westcxx . . $ West.);
217 break;
218 }
219 default:break;
220 }
221 break;
222 }
223 case 5: {
224 aux= new ElbowDownRightcxx . . $ ElbowDownRight#();
225 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=fixed_coefcxx . . $ PipeQueue#fixed_coef.)
226 aux->setFixedcxx . . $ Pipe#setFixed(b45ddcbc8423892c).(true);
227 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=res_coefcxx . . $ PipeQueue#res_coef.)
228 switch (r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0, 1)){
229 case 0:{
230 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Southcxx . . $ South.);
231 break;
232 }
233 case 1:{
234 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Eastcxx . . $ East.);
235 break;
236 }
237 default:break;
238 }
239 break;
240 }
241 case 6: {
242 aux= new ElbowDownLeftcxx . . $ ElbowDownLeft#();
243 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=fixed_coefcxx . . $ PipeQueue#fixed_coef.)
244 aux->setFixedcxx . . $ Pipe#setFixed(b45ddcbc8423892c).(true);
245 if ((unsigned int)r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(1,100)<=res_coefcxx . . $ PipeQueue#res_coef.)
246 switch (r->getRandomNumbercxx . . $ Random#getRandomNumber(9b79fb6aee4c0440).(0, 1)){
247 case 0:{
248 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Southcxx . . $ South.);
249 break;
250 }
251 case 1:{
252 aux->restrictAsOutputcxx . . $ Pipe#restrictAsOutput(c47d336573415769).(Westcxx . . $ West.);
253 break;
254 }
255 default:break;
256 }
257 }
258 break;
259 }
260 delete r;
261 return aux;
262 }
263