wok diff foobillard/stuff/06_show_ball_to_hit @ rev 13315
octave: update deps
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Aug 30 08:40:52 2012 +0200 (2012-08-30) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/foobillard/stuff/06_show_ball_to_hit Thu Aug 30 08:40:52 2012 +0200 1.3 @@ -0,0 +1,255 @@ 1.4 +Index: foobillard-3.0a/src/billard.c 1.5 +=================================================================== 1.6 +--- foobillard-3.0a.orig/src/billard.c 2006-10-12 16:45:04.000000000 +0200 1.7 ++++ foobillard-3.0a/src/billard.c 2006-10-12 16:45:23.000000000 +0200 1.8 +@@ -31,6 +31,8 @@ 1.9 + void * (*billard_malloc)( size_t size ) = malloc; 1.10 + void (*billard_free)( void * ptr ) = free; 1.11 + 1.12 ++SnookerState snooker_state={SN_PLAY_RED}; 1.13 ++ 1.14 + void setfunc_create_scene( void (*func)( BallsType * balls ) ) 1.15 + { 1.16 + create_scene=func; 1.17 +Index: foobillard-3.0a/src/billard.h 1.18 +=================================================================== 1.19 +--- foobillard-3.0a.orig/src/billard.h 2006-10-12 16:45:05.000000000 +0200 1.20 ++++ foobillard-3.0a/src/billard.h 2006-10-12 16:45:23.000000000 +0200 1.21 +@@ -76,9 +76,30 @@ 1.22 + #define BALL_HALF 2 1.23 + #define BALL_ANY 0 1.24 + 1.25 ++typedef enum 1.26 ++{ 1.27 ++ SN_PLAY_RED, 1.28 ++ SN_PLAY_ANY_COLOR, 1.29 ++ SN_PLAY_YELLOW, 1.30 ++ SN_PLAY_GREEN, 1.31 ++ SN_PLAY_BROWN, 1.32 ++ SN_PLAY_BLUE, 1.33 ++ SN_PLAY_PINK, 1.34 ++ SN_PLAY_BLACK, 1.35 ++ SN_DONE 1.36 ++} 1.37 ++SnookerBallToPlay; 1.38 ++ 1.39 ++typedef struct 1.40 ++{ 1.41 ++ SnookerBallToPlay to_play; 1.42 ++} 1.43 ++SnookerState; 1.44 ++ 1.45 + #ifndef BILLARD_C 1.46 + extern void (*create_scene)( BallsType * balls ); 1.47 + extern void (*create_walls)( BordersType * walls ); 1.48 ++extern SnookerState snooker_state; 1.49 + #endif 1.50 + 1.51 + void create_0hole_walls( BordersType * walls ); /* carambol */ 1.52 +Index: foobillard-3.0a/src/billard3d.c 1.53 +=================================================================== 1.54 +--- foobillard-3.0a.orig/src/billard3d.c 2006-10-12 16:45:08.000000000 +0200 1.55 ++++ foobillard-3.0a/src/billard3d.c 2006-10-12 16:45:23.000000000 +0200 1.56 +@@ -829,6 +829,7 @@ 1.57 + player[act_player].place_cue_ball=1; 1.58 + human_player_roster.player[0].cue_ball=0; human_player_roster.player[1].cue_ball=0; 1.59 + human_player_roster.player[act_player].place_cue_ball=1; 1.60 ++ snooker_state.to_play=SN_PLAY_RED; 1.61 + } 1.62 + } 1.63 + 1.64 +@@ -1787,6 +1788,7 @@ 1.65 + /* score text */ 1.66 + for(i=0;i<2;i++){ 1.67 + char str[256]; 1.68 ++ char *color; 1.69 + switch(gametype){ 1.70 + case GAME_8BALL: strcpy(str,"0"); break; 1.71 + case GAME_9BALL: 1.72 +@@ -1805,7 +1807,44 @@ 1.73 + sprintf( str, "%d", player[i].score ); 1.74 + break; 1.75 + case GAME_SNOOKER: 1.76 +- sprintf( str, "%c%03d %s", (player[i].score<0)?'-':'+', abs(player[i].score), player[i].snooker_on_red ? "red":"col" ); 1.77 ++ switch(snooker_state.to_play) 1.78 ++ { 1.79 ++ case SN_PLAY_RED: 1.80 ++ color="red"; 1.81 ++ break; 1.82 ++ case SN_PLAY_ANY_COLOR: 1.83 ++ color="color"; 1.84 ++ break; 1.85 ++ case SN_PLAY_YELLOW: 1.86 ++ color="yellow"; 1.87 ++ break; 1.88 ++ case SN_PLAY_GREEN: 1.89 ++ color="green"; 1.90 ++ break; 1.91 ++ case SN_PLAY_BROWN: 1.92 ++ color="brown"; 1.93 ++ break; 1.94 ++ case SN_PLAY_BLUE: 1.95 ++ color="blue"; 1.96 ++ break; 1.97 ++ case SN_PLAY_PINK: 1.98 ++ color="pink"; 1.99 ++ break; 1.100 ++ case SN_PLAY_BLACK: 1.101 ++ color="black"; 1.102 ++ break; 1.103 ++ case SN_DONE: 1.104 ++ color=""; 1.105 ++ break; 1.106 ++ } 1.107 ++ if(i==act_player) 1.108 ++ { 1.109 ++ sprintf( str, "%.3d %s", player[i].score, color); 1.110 ++ } 1.111 ++ else 1.112 ++ { 1.113 ++ sprintf( str, "%.3d", player[i].score); 1.114 ++ } 1.115 + break; 1.116 + } 1.117 + textObj_setText( player[i].score_text, str ); 1.118 +Index: foobillard-3.0a/src/evaluate_move.c 1.119 +=================================================================== 1.120 +--- foobillard-3.0a.orig/src/evaluate_move.c 2006-10-12 16:45:12.000000000 +0200 1.121 ++++ foobillard-3.0a/src/evaluate_move.c 2006-10-12 16:45:23.000000000 +0200 1.122 +@@ -30,26 +30,6 @@ 1.123 + 1.124 + #define MAX(x,y) ((x)>(y)?(x):(y)); 1.125 + 1.126 +-typedef enum 1.127 +-{ 1.128 +- SN_PLAY_RED, 1.129 +- SN_PLAY_ANY_COLOR, 1.130 +- SN_PLAY_YELLOW, 1.131 +- SN_PLAY_GREEN, 1.132 +- SN_PLAY_BROWN, 1.133 +- SN_PLAY_BLUE, 1.134 +- SN_PLAY_PINK, 1.135 +- SN_PLAY_BLACK, 1.136 +- SN_DONE 1.137 +-} 1.138 +-SnookerBallToPlay; 1.139 +- 1.140 +-typedef struct 1.141 +-{ 1.142 +- SnookerBallToPlay to_play; 1.143 +-} 1.144 +-SnookerState; 1.145 +- 1.146 + 1.147 + void spot_snooker_ball(BallsType *balls,int nr); 1.148 + 1.149 +@@ -400,7 +380,6 @@ 1.150 + #define act_player (*pact_player) 1.151 + #define IS_RED(x) ( x==1 || x>=8 ) 1.152 + int red_balls_are_in_game=0; 1.153 +- static SnookerState st={SN_PLAY_RED}; 1.154 + int color_to_pot; 1.155 + int i; 1.156 + int act_score=0; 1.157 +@@ -409,7 +388,7 @@ 1.158 + int ball_out; 1.159 + int other_player=(act_player==1)?0:1; 1.160 + int b1hit = BM_get_1st_ball_hit(); if (b1hit>=8) b1hit=1; 1.161 +- if(st.to_play==SN_DONE) 1.162 ++ if(snooker_state.to_play==SN_DONE) 1.163 + { 1.164 + BM_reset_move_info(); 1.165 + return; 1.166 +@@ -417,7 +396,7 @@ 1.167 + 1.168 + if( player[act_player].place_cue_ball ) player[act_player].place_cue_ball=0; 1.169 + printf("EVAL start\n"); 1.170 +- printf("EVAL to_play=%d\n",st.to_play); 1.171 ++ printf("EVAL to_play=%d\n",snooker_state.to_play); 1.172 + printf("EVAL b1hit=%d\n",b1hit); 1.173 + for(i=0;i<pballs->nr;i++){ 1.174 + if( IS_RED(pballs->ball[i].nr) && pballs->ball[i].in_game ){ 1.175 +@@ -436,7 +415,7 @@ 1.176 + textObj_setText(last_fault_text, "White ball is potted"); 1.177 + } 1.178 + 1.179 +- switch(st.to_play) 1.180 ++ switch(snooker_state.to_play) 1.181 + { 1.182 + case SN_PLAY_RED: 1.183 + color_to_pot=1; 1.184 +@@ -476,7 +455,7 @@ 1.185 + if( BM_get_ball_out(i)) 1.186 + spot_snooker_ball(pballs,i); 1.187 + } 1.188 +- st.to_play=SN_PLAY_ANY_COLOR; 1.189 ++ snooker_state.to_play=SN_PLAY_ANY_COLOR; 1.190 + break; 1.191 + case SN_PLAY_ANY_COLOR: 1.192 + if(b1hit==1) 1.193 +@@ -512,9 +491,9 @@ 1.194 + } 1.195 + } 1.196 + if(red_balls_are_in_game) 1.197 +- st.to_play=SN_PLAY_RED; 1.198 ++ snooker_state.to_play=SN_PLAY_RED; 1.199 + else 1.200 +- st.to_play=SN_PLAY_YELLOW; 1.201 ++ snooker_state.to_play=SN_PLAY_YELLOW; 1.202 + 1.203 + for(i=2;i<8;i++) 1.204 + { 1.205 +@@ -528,7 +507,7 @@ 1.206 + case SN_PLAY_BLUE: 1.207 + case SN_PLAY_PINK: 1.208 + case SN_PLAY_BLACK: 1.209 +- color_to_pot=st.to_play; 1.210 ++ color_to_pot=snooker_state.to_play; 1.211 + if(b1hit!=color_to_pot) 1.212 + { 1.213 + foul=1; 1.214 +@@ -562,9 +541,9 @@ 1.215 + } 1.216 + } 1.217 + } 1.218 +- if(!foul && act_score>0) st.to_play++; 1.219 ++ if(!foul && act_score>0) snooker_state.to_play++; 1.220 + 1.221 +- for(i=st.to_play;i<8;i++) 1.222 ++ for(i=snooker_state.to_play;i<8;i++) 1.223 + { 1.224 + if( BM_get_ball_out(i)) 1.225 + spot_snooker_ball(pballs,i); 1.226 +@@ -590,13 +569,13 @@ 1.227 + printf("EVAL next player\n"); 1.228 + if(red_balls_are_in_game) 1.229 + { 1.230 +- st.to_play=SN_PLAY_RED; 1.231 ++ snooker_state.to_play=SN_PLAY_RED; 1.232 + } 1.233 + else 1.234 + { 1.235 +- if(st.to_play<=SN_PLAY_ANY_COLOR) 1.236 ++ if(snooker_state.to_play<=SN_PLAY_ANY_COLOR) 1.237 + { 1.238 +- st.to_play=SN_PLAY_YELLOW; 1.239 ++ snooker_state.to_play=SN_PLAY_YELLOW; 1.240 + } 1.241 + } 1.242 + player[act_player].queue_view=*pqueue_view; 1.243 +@@ -605,11 +584,11 @@ 1.244 + *pqueue_view=player[act_player].queue_view; 1.245 + } 1.246 + 1.247 +- player[act_player].snooker_on_red=st.to_play==SN_PLAY_RED; 1.248 +- player[act_player].snooker_next_color=st.to_play; 1.249 +- printf("EVAL to_play=%d\n",st.to_play); 1.250 ++ player[act_player].snooker_on_red=snooker_state.to_play==SN_PLAY_RED; 1.251 ++ player[act_player].snooker_next_color=snooker_state.to_play; 1.252 ++ printf("EVAL to_play=%d\n",snooker_state.to_play); 1.253 + 1.254 +- if(st.to_play==SN_DONE) 1.255 ++ if(snooker_state.to_play==SN_DONE) 1.256 + { 1.257 + int other_player; 1.258 +