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