rev |
line source |
slaxemulator@7500
|
1 Index: foobillard-3.0a/src/billard.c
|
slaxemulator@7500
|
2 ===================================================================
|
slaxemulator@7500
|
3 --- foobillard-3.0a.orig/src/billard.c 2006-10-12 16:45:04.000000000 +0200
|
slaxemulator@7500
|
4 +++ foobillard-3.0a/src/billard.c 2006-10-12 16:45:23.000000000 +0200
|
slaxemulator@7500
|
5 @@ -31,6 +31,8 @@
|
slaxemulator@7500
|
6 void * (*billard_malloc)( size_t size ) = malloc;
|
slaxemulator@7500
|
7 void (*billard_free)( void * ptr ) = free;
|
slaxemulator@7500
|
8
|
slaxemulator@7500
|
9 +SnookerState snooker_state={SN_PLAY_RED};
|
slaxemulator@7500
|
10 +
|
slaxemulator@7500
|
11 void setfunc_create_scene( void (*func)( BallsType * balls ) )
|
slaxemulator@7500
|
12 {
|
slaxemulator@7500
|
13 create_scene=func;
|
slaxemulator@7500
|
14 Index: foobillard-3.0a/src/billard.h
|
slaxemulator@7500
|
15 ===================================================================
|
slaxemulator@7500
|
16 --- foobillard-3.0a.orig/src/billard.h 2006-10-12 16:45:05.000000000 +0200
|
slaxemulator@7500
|
17 +++ foobillard-3.0a/src/billard.h 2006-10-12 16:45:23.000000000 +0200
|
slaxemulator@7500
|
18 @@ -76,9 +76,30 @@
|
slaxemulator@7500
|
19 #define BALL_HALF 2
|
slaxemulator@7500
|
20 #define BALL_ANY 0
|
slaxemulator@7500
|
21
|
slaxemulator@7500
|
22 +typedef enum
|
slaxemulator@7500
|
23 +{
|
slaxemulator@7500
|
24 + SN_PLAY_RED,
|
slaxemulator@7500
|
25 + SN_PLAY_ANY_COLOR,
|
slaxemulator@7500
|
26 + SN_PLAY_YELLOW,
|
slaxemulator@7500
|
27 + SN_PLAY_GREEN,
|
slaxemulator@7500
|
28 + SN_PLAY_BROWN,
|
slaxemulator@7500
|
29 + SN_PLAY_BLUE,
|
slaxemulator@7500
|
30 + SN_PLAY_PINK,
|
slaxemulator@7500
|
31 + SN_PLAY_BLACK,
|
slaxemulator@7500
|
32 + SN_DONE
|
slaxemulator@7500
|
33 +}
|
slaxemulator@7500
|
34 +SnookerBallToPlay;
|
slaxemulator@7500
|
35 +
|
slaxemulator@7500
|
36 +typedef struct
|
slaxemulator@7500
|
37 +{
|
slaxemulator@7500
|
38 + SnookerBallToPlay to_play;
|
slaxemulator@7500
|
39 +}
|
slaxemulator@7500
|
40 +SnookerState;
|
slaxemulator@7500
|
41 +
|
slaxemulator@7500
|
42 #ifndef BILLARD_C
|
slaxemulator@7500
|
43 extern void (*create_scene)( BallsType * balls );
|
slaxemulator@7500
|
44 extern void (*create_walls)( BordersType * walls );
|
slaxemulator@7500
|
45 +extern SnookerState snooker_state;
|
slaxemulator@7500
|
46 #endif
|
slaxemulator@7500
|
47
|
slaxemulator@7500
|
48 void create_0hole_walls( BordersType * walls ); /* carambol */
|
slaxemulator@7500
|
49 Index: foobillard-3.0a/src/billard3d.c
|
slaxemulator@7500
|
50 ===================================================================
|
slaxemulator@7500
|
51 --- foobillard-3.0a.orig/src/billard3d.c 2006-10-12 16:45:08.000000000 +0200
|
slaxemulator@7500
|
52 +++ foobillard-3.0a/src/billard3d.c 2006-10-12 16:45:23.000000000 +0200
|
slaxemulator@7500
|
53 @@ -829,6 +829,7 @@
|
slaxemulator@7500
|
54 player[act_player].place_cue_ball=1;
|
slaxemulator@7500
|
55 human_player_roster.player[0].cue_ball=0; human_player_roster.player[1].cue_ball=0;
|
slaxemulator@7500
|
56 human_player_roster.player[act_player].place_cue_ball=1;
|
slaxemulator@7500
|
57 + snooker_state.to_play=SN_PLAY_RED;
|
slaxemulator@7500
|
58 }
|
slaxemulator@7500
|
59 }
|
slaxemulator@7500
|
60
|
slaxemulator@7500
|
61 @@ -1787,6 +1788,7 @@
|
slaxemulator@7500
|
62 /* score text */
|
slaxemulator@7500
|
63 for(i=0;i<2;i++){
|
slaxemulator@7500
|
64 char str[256];
|
slaxemulator@7500
|
65 + char *color;
|
slaxemulator@7500
|
66 switch(gametype){
|
slaxemulator@7500
|
67 case GAME_8BALL: strcpy(str,"0"); break;
|
slaxemulator@7500
|
68 case GAME_9BALL:
|
slaxemulator@7500
|
69 @@ -1805,7 +1807,44 @@
|
slaxemulator@7500
|
70 sprintf( str, "%d", player[i].score );
|
slaxemulator@7500
|
71 break;
|
slaxemulator@7500
|
72 case GAME_SNOOKER:
|
slaxemulator@7500
|
73 - sprintf( str, "%c%03d %s", (player[i].score<0)?'-':'+', abs(player[i].score), player[i].snooker_on_red ? "red":"col" );
|
slaxemulator@7500
|
74 + switch(snooker_state.to_play)
|
slaxemulator@7500
|
75 + {
|
slaxemulator@7500
|
76 + case SN_PLAY_RED:
|
slaxemulator@7500
|
77 + color="red";
|
slaxemulator@7500
|
78 + break;
|
slaxemulator@7500
|
79 + case SN_PLAY_ANY_COLOR:
|
slaxemulator@7500
|
80 + color="color";
|
slaxemulator@7500
|
81 + break;
|
slaxemulator@7500
|
82 + case SN_PLAY_YELLOW:
|
slaxemulator@7500
|
83 + color="yellow";
|
slaxemulator@7500
|
84 + break;
|
slaxemulator@7500
|
85 + case SN_PLAY_GREEN:
|
slaxemulator@7500
|
86 + color="green";
|
slaxemulator@7500
|
87 + break;
|
slaxemulator@7500
|
88 + case SN_PLAY_BROWN:
|
slaxemulator@7500
|
89 + color="brown";
|
slaxemulator@7500
|
90 + break;
|
slaxemulator@7500
|
91 + case SN_PLAY_BLUE:
|
slaxemulator@7500
|
92 + color="blue";
|
slaxemulator@7500
|
93 + break;
|
slaxemulator@7500
|
94 + case SN_PLAY_PINK:
|
slaxemulator@7500
|
95 + color="pink";
|
slaxemulator@7500
|
96 + break;
|
slaxemulator@7500
|
97 + case SN_PLAY_BLACK:
|
slaxemulator@7500
|
98 + color="black";
|
slaxemulator@7500
|
99 + break;
|
slaxemulator@7500
|
100 + case SN_DONE:
|
slaxemulator@7500
|
101 + color="";
|
slaxemulator@7500
|
102 + break;
|
slaxemulator@7500
|
103 + }
|
slaxemulator@7500
|
104 + if(i==act_player)
|
slaxemulator@7500
|
105 + {
|
slaxemulator@7500
|
106 + sprintf( str, "%.3d %s", player[i].score, color);
|
slaxemulator@7500
|
107 + }
|
slaxemulator@7500
|
108 + else
|
slaxemulator@7500
|
109 + {
|
slaxemulator@7500
|
110 + sprintf( str, "%.3d", player[i].score);
|
slaxemulator@7500
|
111 + }
|
slaxemulator@7500
|
112 break;
|
slaxemulator@7500
|
113 }
|
slaxemulator@7500
|
114 textObj_setText( player[i].score_text, str );
|
slaxemulator@7500
|
115 Index: foobillard-3.0a/src/evaluate_move.c
|
slaxemulator@7500
|
116 ===================================================================
|
slaxemulator@7500
|
117 --- foobillard-3.0a.orig/src/evaluate_move.c 2006-10-12 16:45:12.000000000 +0200
|
slaxemulator@7500
|
118 +++ foobillard-3.0a/src/evaluate_move.c 2006-10-12 16:45:23.000000000 +0200
|
slaxemulator@7500
|
119 @@ -30,26 +30,6 @@
|
slaxemulator@7500
|
120
|
slaxemulator@7500
|
121 #define MAX(x,y) ((x)>(y)?(x):(y));
|
slaxemulator@7500
|
122
|
slaxemulator@7500
|
123 -typedef enum
|
slaxemulator@7500
|
124 -{
|
slaxemulator@7500
|
125 - SN_PLAY_RED,
|
slaxemulator@7500
|
126 - SN_PLAY_ANY_COLOR,
|
slaxemulator@7500
|
127 - SN_PLAY_YELLOW,
|
slaxemulator@7500
|
128 - SN_PLAY_GREEN,
|
slaxemulator@7500
|
129 - SN_PLAY_BROWN,
|
slaxemulator@7500
|
130 - SN_PLAY_BLUE,
|
slaxemulator@7500
|
131 - SN_PLAY_PINK,
|
slaxemulator@7500
|
132 - SN_PLAY_BLACK,
|
slaxemulator@7500
|
133 - SN_DONE
|
slaxemulator@7500
|
134 -}
|
slaxemulator@7500
|
135 -SnookerBallToPlay;
|
slaxemulator@7500
|
136 -
|
slaxemulator@7500
|
137 -typedef struct
|
slaxemulator@7500
|
138 -{
|
slaxemulator@7500
|
139 - SnookerBallToPlay to_play;
|
slaxemulator@7500
|
140 -}
|
slaxemulator@7500
|
141 -SnookerState;
|
slaxemulator@7500
|
142 -
|
slaxemulator@7500
|
143
|
slaxemulator@7500
|
144 void spot_snooker_ball(BallsType *balls,int nr);
|
slaxemulator@7500
|
145
|
slaxemulator@7500
|
146 @@ -400,7 +380,6 @@
|
slaxemulator@7500
|
147 #define act_player (*pact_player)
|
slaxemulator@7500
|
148 #define IS_RED(x) ( x==1 || x>=8 )
|
slaxemulator@7500
|
149 int red_balls_are_in_game=0;
|
slaxemulator@7500
|
150 - static SnookerState st={SN_PLAY_RED};
|
slaxemulator@7500
|
151 int color_to_pot;
|
slaxemulator@7500
|
152 int i;
|
slaxemulator@7500
|
153 int act_score=0;
|
slaxemulator@7500
|
154 @@ -409,7 +388,7 @@
|
slaxemulator@7500
|
155 int ball_out;
|
slaxemulator@7500
|
156 int other_player=(act_player==1)?0:1;
|
slaxemulator@7500
|
157 int b1hit = BM_get_1st_ball_hit(); if (b1hit>=8) b1hit=1;
|
slaxemulator@7500
|
158 - if(st.to_play==SN_DONE)
|
slaxemulator@7500
|
159 + if(snooker_state.to_play==SN_DONE)
|
slaxemulator@7500
|
160 {
|
slaxemulator@7500
|
161 BM_reset_move_info();
|
slaxemulator@7500
|
162 return;
|
slaxemulator@7500
|
163 @@ -417,7 +396,7 @@
|
slaxemulator@7500
|
164
|
slaxemulator@7500
|
165 if( player[act_player].place_cue_ball ) player[act_player].place_cue_ball=0;
|
slaxemulator@7500
|
166 printf("EVAL start\n");
|
slaxemulator@7500
|
167 - printf("EVAL to_play=%d\n",st.to_play);
|
slaxemulator@7500
|
168 + printf("EVAL to_play=%d\n",snooker_state.to_play);
|
slaxemulator@7500
|
169 printf("EVAL b1hit=%d\n",b1hit);
|
slaxemulator@7500
|
170 for(i=0;i<pballs->nr;i++){
|
slaxemulator@7500
|
171 if( IS_RED(pballs->ball[i].nr) && pballs->ball[i].in_game ){
|
slaxemulator@7500
|
172 @@ -436,7 +415,7 @@
|
slaxemulator@7500
|
173 textObj_setText(last_fault_text, "White ball is potted");
|
slaxemulator@7500
|
174 }
|
slaxemulator@7500
|
175
|
slaxemulator@7500
|
176 - switch(st.to_play)
|
slaxemulator@7500
|
177 + switch(snooker_state.to_play)
|
slaxemulator@7500
|
178 {
|
slaxemulator@7500
|
179 case SN_PLAY_RED:
|
slaxemulator@7500
|
180 color_to_pot=1;
|
slaxemulator@7500
|
181 @@ -476,7 +455,7 @@
|
slaxemulator@7500
|
182 if( BM_get_ball_out(i))
|
slaxemulator@7500
|
183 spot_snooker_ball(pballs,i);
|
slaxemulator@7500
|
184 }
|
slaxemulator@7500
|
185 - st.to_play=SN_PLAY_ANY_COLOR;
|
slaxemulator@7500
|
186 + snooker_state.to_play=SN_PLAY_ANY_COLOR;
|
slaxemulator@7500
|
187 break;
|
slaxemulator@7500
|
188 case SN_PLAY_ANY_COLOR:
|
slaxemulator@7500
|
189 if(b1hit==1)
|
slaxemulator@7500
|
190 @@ -512,9 +491,9 @@
|
slaxemulator@7500
|
191 }
|
slaxemulator@7500
|
192 }
|
slaxemulator@7500
|
193 if(red_balls_are_in_game)
|
slaxemulator@7500
|
194 - st.to_play=SN_PLAY_RED;
|
slaxemulator@7500
|
195 + snooker_state.to_play=SN_PLAY_RED;
|
slaxemulator@7500
|
196 else
|
slaxemulator@7500
|
197 - st.to_play=SN_PLAY_YELLOW;
|
slaxemulator@7500
|
198 + snooker_state.to_play=SN_PLAY_YELLOW;
|
slaxemulator@7500
|
199
|
slaxemulator@7500
|
200 for(i=2;i<8;i++)
|
slaxemulator@7500
|
201 {
|
slaxemulator@7500
|
202 @@ -528,7 +507,7 @@
|
slaxemulator@7500
|
203 case SN_PLAY_BLUE:
|
slaxemulator@7500
|
204 case SN_PLAY_PINK:
|
slaxemulator@7500
|
205 case SN_PLAY_BLACK:
|
slaxemulator@7500
|
206 - color_to_pot=st.to_play;
|
slaxemulator@7500
|
207 + color_to_pot=snooker_state.to_play;
|
slaxemulator@7500
|
208 if(b1hit!=color_to_pot)
|
slaxemulator@7500
|
209 {
|
slaxemulator@7500
|
210 foul=1;
|
slaxemulator@7500
|
211 @@ -562,9 +541,9 @@
|
slaxemulator@7500
|
212 }
|
slaxemulator@7500
|
213 }
|
slaxemulator@7500
|
214 }
|
slaxemulator@7500
|
215 - if(!foul && act_score>0) st.to_play++;
|
slaxemulator@7500
|
216 + if(!foul && act_score>0) snooker_state.to_play++;
|
slaxemulator@7500
|
217
|
slaxemulator@7500
|
218 - for(i=st.to_play;i<8;i++)
|
slaxemulator@7500
|
219 + for(i=snooker_state.to_play;i<8;i++)
|
slaxemulator@7500
|
220 {
|
slaxemulator@7500
|
221 if( BM_get_ball_out(i))
|
slaxemulator@7500
|
222 spot_snooker_ball(pballs,i);
|
slaxemulator@7500
|
223 @@ -590,13 +569,13 @@
|
slaxemulator@7500
|
224 printf("EVAL next player\n");
|
slaxemulator@7500
|
225 if(red_balls_are_in_game)
|
slaxemulator@7500
|
226 {
|
slaxemulator@7500
|
227 - st.to_play=SN_PLAY_RED;
|
slaxemulator@7500
|
228 + snooker_state.to_play=SN_PLAY_RED;
|
slaxemulator@7500
|
229 }
|
slaxemulator@7500
|
230 else
|
slaxemulator@7500
|
231 {
|
slaxemulator@7500
|
232 - if(st.to_play<=SN_PLAY_ANY_COLOR)
|
slaxemulator@7500
|
233 + if(snooker_state.to_play<=SN_PLAY_ANY_COLOR)
|
slaxemulator@7500
|
234 {
|
slaxemulator@7500
|
235 - st.to_play=SN_PLAY_YELLOW;
|
slaxemulator@7500
|
236 + snooker_state.to_play=SN_PLAY_YELLOW;
|
slaxemulator@7500
|
237 }
|
slaxemulator@7500
|
238 }
|
slaxemulator@7500
|
239 player[act_player].queue_view=*pqueue_view;
|
slaxemulator@7500
|
240 @@ -605,11 +584,11 @@
|
slaxemulator@7500
|
241 *pqueue_view=player[act_player].queue_view;
|
slaxemulator@7500
|
242 }
|
slaxemulator@7500
|
243
|
slaxemulator@7500
|
244 - player[act_player].snooker_on_red=st.to_play==SN_PLAY_RED;
|
slaxemulator@7500
|
245 - player[act_player].snooker_next_color=st.to_play;
|
slaxemulator@7500
|
246 - printf("EVAL to_play=%d\n",st.to_play);
|
slaxemulator@7500
|
247 + player[act_player].snooker_on_red=snooker_state.to_play==SN_PLAY_RED;
|
slaxemulator@7500
|
248 + player[act_player].snooker_next_color=snooker_state.to_play;
|
slaxemulator@7500
|
249 + printf("EVAL to_play=%d\n",snooker_state.to_play);
|
slaxemulator@7500
|
250
|
slaxemulator@7500
|
251 - if(st.to_play==SN_DONE)
|
slaxemulator@7500
|
252 + if(snooker_state.to_play==SN_DONE)
|
slaxemulator@7500
|
253 {
|
slaxemulator@7500
|
254 int other_player;
|
slaxemulator@7500
|
255
|