Changeset 69
- Timestamp:
- 04/23/07 17:53:20 (1 year ago)
- Files:
-
- trunk/src/Makefile.inc (modified) (1 diff)
- trunk/src/cmd1.c (modified) (2 diffs)
- trunk/src/cmd2.c (modified) (2 diffs)
- trunk/src/dungeon.c (modified) (2 diffs)
- trunk/src/externs.h (modified) (5 diffs)
- trunk/src/main-win.c (modified) (6 diffs)
- trunk/src/main-x11.c (modified) (3 diffs)
- trunk/src/pathfind.c (added)
- trunk/src/types.h (modified) (2 diffs)
- trunk/src/util.c (modified) (16 diffs)
- trunk/src/xtra2.c (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/Makefile.inc
r42 r69 32 32 object2 \ 33 33 obj-info \ 34 pathfind \ 34 35 randart \ 35 36 randname \ trunk/src/cmd1.c
r48 r69 2111 2111 void run_step(int dir) 2112 2112 { 2113 int x, y; 2114 2113 2115 /* Start run */ 2114 2116 if (dir) … … 2127 2129 else 2128 2130 { 2129 /* Update run */ 2130 if (run_test()) 2131 { 2132 /* Disturb */ 2133 disturb(0, 0); 2134 2135 /* Done */ 2136 return; 2131 if (!p_ptr->running_withpathfind) 2132 { 2133 /* Update run */ 2134 if (run_test()) 2135 { 2136 /* Disturb */ 2137 disturb(0, 0); 2138 2139 /* Done */ 2140 return; 2141 } 2142 } 2143 else 2144 { 2145 if (pf_result_index < 0) 2146 { 2147 disturb(0, 0); 2148 p_ptr->running_withpathfind = 0; 2149 return; 2150 } 2151 p_ptr->run_cur_dir = pf_result[pf_result_index--] - '0'; 2152 x = p_ptr->px + ddx[p_ptr->run_cur_dir]; 2153 y = p_ptr->py + ddy[p_ptr->run_cur_dir]; 2154 if (!do_cmd_walk_test(y, x)) return; 2137 2155 } 2138 2156 } trunk/src/cmd2.c
r24 r69 2001 2001 * Determine if a given grid may be "walked" 2002 2002 */ 2003 staticbool do_cmd_walk_test(int y, int x)2003 bool do_cmd_walk_test(int y, int x) 2004 2004 { 2005 2005 /* Hack -- walking obtains knowledge XXX XXX */ … … 2154 2154 /* Start run */ 2155 2155 run_step(dir); 2156 } 2157 2158 /* 2159 * Start running with pathfinder. 2160 * 2161 * Note that running while confused is not allowed. 2162 */ 2163 void do_cmd_pathfind(int y, int x) 2164 { 2165 /* Hack XXX XXX XXX */ 2166 if (p_ptr->timed[TMD_CONFUSED]) 2167 { 2168 msg_print("You are too confused!"); 2169 return; 2170 } 2171 2172 if (findpath(y, x)) 2173 { 2174 p_ptr->running = 1000; 2175 /* Calculate torch radius */ 2176 p_ptr->update |= (PU_TORCH); 2177 p_ptr->running_withpathfind = TRUE; 2178 run_step(0); 2179 } 2156 2180 } 2157 2181 trunk/src/dungeon.c
r59 r69 1238 1238 static void process_command(void) 1239 1239 { 1240 1240 int x, y; 1241 1241 1242 #ifdef ALLOW_REPEAT 1242 1243 … … 1811 1812 { 1812 1813 do_cmd_save_screen(); 1814 break; 1815 } 1816 1817 /* Mouse click */ 1818 case '\xff': 1819 { 1820 x = p_ptr->command_cmd_ex.mousex + Term->offset_x; 1821 y = p_ptr->command_cmd_ex.mousey + Term->offset_y; 1822 do_cmd_pathfind(y, x); 1813 1823 break; 1814 1824 } trunk/src/externs.h
r38 r69 26 26 extern cptr macro_trigger_name[MAX_MACRO_TRIGGER]; 27 27 extern cptr macro_trigger_keycode[2][MAX_MACRO_TRIGGER]; 28 29 /* pathfind.c */ 30 extern char pf_result[]; 31 extern int pf_result_index; 28 32 29 33 /* tables.c */ … … 304 308 extern void move_player(int dir, int jumping); 305 309 extern void run_step(int dir); 310 bool do_cmd_walk_test(int y, int x); 306 311 307 312 /* cmd2.c */ … … 320 325 extern void do_cmd_jump(void); 321 326 extern void do_cmd_run(void); 327 extern void do_cmd_pathfind(int y, int x); 322 328 extern void do_cmd_hold(void); 323 329 extern void do_cmd_stay(void); … … 547 553 extern void print_spells(const byte *spells, int num, int y, int x); 548 554 extern void display_koff(int k_idx); 555 556 /* pathfind.c */ 557 extern bool findpath(int y, int x); 549 558 550 559 /* save.c */ … … 721 730 extern bool get_check(cptr prompt); 722 731 extern bool get_com(cptr prompt, char *command); 732 extern bool get_com_ex(cptr prompt, event_type *command); 723 733 extern void pause_line(int row); 724 734 extern void request_command(bool shopping); trunk/src/main-win.c
r63 r69 246 246 */ 247 247 #include <windows.h> 248 #include <windowsx.h> 248 249 249 250 #ifdef USE_SOUND … … 3936 3937 int i; 3937 3938 3939 int xPos, yPos, button; 3940 3938 3941 #ifdef USE_SAVER 3939 3942 static int iMouse = 0; … … 4051 4054 } 4052 4055 4053 #ifdef USE_SAVER4054 4055 4056 case WM_MBUTTONDOWN: 4056 4057 case WM_RBUTTONDOWN: 4057 4058 case WM_LBUTTONDOWN: 4058 4059 { 4060 #ifdef USE_SAVER 4059 4061 if (screensaver_active) 4060 4062 { … … 4062 4064 return 0; 4063 4065 } 4064 4065 4066 break; 4066 } 4067 4067 #else 4068 xPos = GET_X_LPARAM(lParam); 4069 yPos = GET_Y_LPARAM(lParam); 4070 xPos = (xPos - 13 * td->font_wid) / td->tile_wid; 4071 if (use_bigtile) 4072 xPos /= 2; 4073 yPos = yPos / td->tile_hgt - 1; 4074 if (uMsg == WM_LBUTTONDOWN) 4075 button = 1; 4076 else if (uMsg == WM_RBUTTONDOWN) 4077 button = 2; 4078 else 4079 button = 3; 4080 Term_mousepress(xPos,yPos,button); 4081 break; 4082 #endif /* USE_SAVER */ 4083 } 4084 4085 #ifdef USE_SAVER 4068 4086 case WM_MOUSEMOVE: 4069 4087 { … … 4447 4465 } 4448 4466 4467 4449 4468 #ifdef USE_SAVER 4450 4451 4469 case WM_MBUTTONDOWN: 4452 4470 case WM_RBUTTONDOWN: … … 4458 4476 return 0; 4459 4477 } 4460 4461 4478 break; 4462 4479 } trunk/src/main-x11.c
r41 r69 1672 1672 term_data *td = (term_data*)(Term->data); 1673 1673 1674 (*x) = (ox - Infowin->ox ) / td->tile_wid;1675 (*y) = (oy - Infowin->oy) / td->tile_hgt ;1674 (*x) = (ox - Infowin->ox - 13 * Infofnt->wid) / td->tile_wid; 1675 (*y) = (oy - Infowin->oy) / td->tile_hgt - 1; 1676 1676 } 1677 1677 … … 1943 1943 pixel_to_square(&x, &y, x, y); 1944 1944 1945 #if 0 1945 1946 if (press && button == 1) copy_x11_start(x, y); 1946 1947 if (!press && button == 1) copy_x11_end(time); 1948 #endif 1949 1950 if (press) Term_mousepress(x,y,button); 1947 1951 } 1948 1952 … … 2046 2050 pixel_to_square(&x, &y, x, y); 2047 2051 2052 #if 0 2048 2053 /* Alter the selection if appropriate. */ 2049 2054 copy_x11_cont(x, y, z); 2050 2055 #endif 2056 2051 2057 break; 2052 2058 } trunk/src/types.h
r48 r69 935 935 s16b resting; /* Resting counter */ 936 936 s16b running; /* Running counter */ 937 bool running_withpathfind; /* Are we using the pathfinder ? */ 937 938 938 939 s16b run_cur_dir; /* Direction we are running */ … … 947 948 s16b command_rep; /* Gives repetition of current command */ 948 949 s16b command_dir; /* Gives direction of current command */ 950 event_type command_cmd_ex; /* Gives additional information of current command */ 949 951 950 952 s16b command_see; /* See "cmd1.c" */ trunk/src/util.c
r48 r69 3068 3068 bool get_com(cptr prompt, char *command) 3069 3069 { 3070 char ch; 3070 event_type ke; 3071 bool result; 3072 3073 result = get_com_ex(prompt, &ke); 3074 *command = ke.key; 3075 3076 return result; 3077 } 3078 3079 bool get_com_ex(cptr prompt, event_type *command) 3080 { 3081 event_type ke; 3071 3082 3072 3083 /* Paranoia XXX XXX XXX */ … … 3077 3088 3078 3089 /* Get a key */ 3079 ch = inkey();3090 ke = inkey_ex(); 3080 3091 3081 3092 /* Clear the prompt */ … … 3083 3094 3084 3095 /* Save the command */ 3085 *command = ch;3096 *command = ke; 3086 3097 3087 3098 /* Done */ 3088 return ( ch!= ESCAPE);3099 return (ke.key != ESCAPE); 3089 3100 } 3090 3101 … … 3135 3146 int i; 3136 3147 3137 char ch;3148 event_type ke; 3138 3149 3139 3150 int mode; … … 3175 3186 3176 3187 /* Use auto-command */ 3177 ch= (char)p_ptr->command_new;3188 ke.key = (char)p_ptr->command_new; 3178 3189 3179 3190 /* Forget it */ … … 3191 3202 3192 3203 /* Get a command */ 3193 ch = inkey();3204 ke = inkey_ex(); 3194 3205 } 3195 3206 … … 3199 3210 3200 3211 /* Command Count */ 3201 if ( ch== '0')3212 if (ke.key == '0') 3202 3213 { 3203 3214 int old_arg = p_ptr->command_arg; … … 3213 3224 { 3214 3225 /* Get a new keypress */ 3215 ch= inkey();3226 ke.key = inkey(); 3216 3227 3217 3228 /* Simple editing (delete or backspace) */ 3218 if (( ch == 0x7F) || (ch== KTRL('H')))3229 if ((ke.key == 0x7F) || (ke.key == KTRL('H'))) 3219 3230 { 3220 3231 /* Delete a digit */ … … 3226 3237 3227 3238 /* Actual numeric data */ 3228 else if (isdigit((unsigned char) ch))3239 else if (isdigit((unsigned char)ke.key)) 3229 3240 { 3230 3241 /* Stop count at 9999 */ … … 3242 3253 { 3243 3254 /* Incorporate that digit */ 3244 p_ptr->command_arg = p_ptr->command_arg * 10 + D2I( ch);3255 p_ptr->command_arg = p_ptr->command_arg * 10 + D2I(ke.key); 3245 3256 } 3246 3257 … … 3277 3288 3278 3289 /* Hack -- white-space means "enter command now" */ 3279 if (( ch == ' ') || (ch == '\n') || (ch== '\r'))3290 if ((ke.key == ' ') || (ke.key == '\n') || (ke.key == '\r')) 3280 3291 { 3281 3292 /* Get a real command */ 3282 if (!get_com("Command: ", & ch))3293 if (!get_com("Command: ", &ke.key)) 3283 3294 { 3284 3295 /* Clear count */ … … 3293 3304 3294 3305 /* Special case for the arrow keys */ 3295 if (isarrow( ch))3296 { 3297 switch ( ch)3306 if (isarrow(ke.key)) 3307 { 3308 switch (ke.key) 3298 3309 { 3299 case ARROW_DOWN: ch= '2'; break;3300 case ARROW_LEFT: ch= '4'; break;3301 case ARROW_RIGHT: ch= '6'; break;3302 case ARROW_UP: ch= '8'; break;3310 case ARROW_DOWN: ke.key = '2'; break; 3311 case ARROW_LEFT: ke.key = '4'; break; 3312 case ARROW_RIGHT: ke.key = '6'; break; 3313 case ARROW_UP: ke.key = '8'; break; 3303 3314 } 3304 3315 } … … 3306 3317 3307 3318 /* Allow "keymaps" to be bypassed */ 3308 if ( ch== '\\')3319 if (ke.key == '\\') 3309 3320 { 3310 3321 /* Get a real command */ 3311 (void)get_com("Command: ", & ch);3322 (void)get_com("Command: ", &ke.key); 3312 3323 3313 3324 /* Hack -- bypass keymaps */ … … 3317 3328 3318 3329 /* Allow "control chars" to be entered */ 3319 if ( ch== '^')3330 if (ke.key == '^') 3320 3331 { 3321 3332 /* Get a new command and controlify it */ 3322 if (get_com("Control: ", & ch)) ch = KTRL(ch);3333 if (get_com("Control: ", &ke.key)) ke.key = KTRL(ke.key); 3323 3334 } 3324 3335 3325 3336 3326 3337 /* Look up applicable keymap */ 3327 act = keymap_act[mode][(byte)( ch)];3338 act = keymap_act[mode][(byte)(ke.key)]; 3328 3339 3329 3340 /* Apply keymap if not inside a keymap already */ … … 3343 3354 3344 3355 /* Paranoia */ 3345 if ( ch== '\0') continue;3356 if (ke.key == '\0') continue; 3346 3357 3347 3358 3348 3359 /* Use command */ 3349 p_ptr->command_cmd = ch; 3360 p_ptr->command_cmd = ke.key; 3361 p_ptr->command_cmd_ex = ke; 3350 3362 3351 3363 /* Done */ … … 3421 3433 /* Hack -- erase the message line. */ 3422 3434 prt("", 0, 0); 3435 3436 /* Hack again -- apply the modified key command */ 3437 p_ptr->command_cmd_ex.key = p_ptr->command_cmd; 3423 3438 } 3424 3439 trunk/src/xtra2.c
r48 r69 2384 2384 * This function must handle blindness/hallucination. 2385 2385 */ 2386 static inttarget_set_interactive_aux(int y, int x, int mode, cptr info)2386 static event_type target_set_interactive_aux(int y, int x, int mode, cptr info) 2387 2387 { 2388 2388 s16b this_o_idx, next_o_idx = 0; … … 2396 2396 int feat; 2397 2397 2398 intquery;2398 event_type query; 2399 2399 2400 2400 char out_val[256]; … … 2405 2405 { 2406 2406 /* Paranoia */ 2407 query = ' ';2407 query.key = ' '; 2408 2408 2409 2409 /* Assume boring */ … … 2446 2446 prt(out_val, 0, 0); 2447 2447 move_cursor_relative(y, x); 2448 query = inkey ();2448 query = inkey_ex(); 2449 2449 2450 2450 /* Stop on everything but "return" */ 2451 if ((query != '\n') && (query != '\r')) break;2451 if ((query.key != '\n') && (query.key != '\r')) break; 2452 2452 2453 2453 /* Repeat forever */ … … 2500 2500 2501 2501 /* Command */ 2502 query = inkey ();2502 query = inkey_ex(); 2503 2503 2504 2504 /* Load screen */ … … 2534 2534 2535 2535 /* Command */ 2536 query = inkey ();2536 query = inkey_ex(); 2537 2537 } 2538 2538 2539 2539 /* Normal commands */ 2540 if (query != 'r') break;2540 if (query.key != 'r') break; 2541 2541 2542 2542 /* Toggle recall */ … … 2545 2545 2546 2546 /* Stop on everything but "return"/"space" */ 2547 if ((query != '\n') && (query != '\r') && (query != ' ')) break;2547 if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break; 2548 2548 2549 2549 /* Sometimes stop at "space" key */ 2550 if ((query == ' ') && !(mode & (TARGET_LOOK))) break;2550 if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break; 2551 2551 2552 2552 /* Change the intro */ … … 2591 2591 prt(out_val, 0, 0); 2592 2592 move_cursor_relative(y, x); 2593 query = inkey ();2593 query = inkey_ex(); 2594 2594 2595 2595 /* Stop on everything but "return"/"space" */ 2596 if ((query != '\n') && (query != '\r') && (query != ' ')) break;2596 if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break; 2597 2597 2598 2598 /* Sometimes stop at "space" key */ 2599 if ((query == ' ') && !(mode & (TARGET_LOOK))) break;2599 if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break; 2600 2600 2601 2601 /* Change the intro */ … … 2652 2652 prt(out_val, 0, 0); 2653 2653 move_cursor_relative(y, x); 2654 query = inkey ();2654 query = inkey_ex(); 2655 2655 2656 2656 /* Display objects */ 2657 if (query == 'r')2657 if (query.key == 'r') 2658 2658 { 2659 2659 /* Save screen */ … … 2665 2665 /* Describe the pile */ 2666 2666 prt(out_val, 0, 0); 2667 query = inkey ();2667 query = inkey_ex(); 2668 2668 2669 2669 /* Load screen */ … … 2671 2671 2672 2672 /* Continue on 'r' only */ 2673 if (query == 'r') continue;2673 if (query.key == 'r') continue; 2674 2674 } 2675 2675 … … 2679 2679 2680 2680 /* Stop on everything but "return"/"space" */ 2681 if ((query != '\n') && (query != '\r') && (query != ' ')) break;2681 if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break; 2682 2682 2683 2683 /* Sometimes stop at "space" key */ 2684 if ((query == ' ') && !(mode & (TARGET_LOOK))) break;2684 if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break; 2685 2685 2686 2686 /* Change the intro */ … … 2732 2732 prt(out_val, 0, 0); 2733 2733 move_cursor_relative(y, x); 2734 query = inkey ();2734 query = inkey_ex(); 2735 2735 2736 2736 /* Stop on everything but "return"/"space" */ 2737 if ((query != '\n') && (query != '\r') && (query != ' ')) break;2737 if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break; 2738 2738 2739 2739 /* Sometimes stop at "space" key */ 2740 if ((query == ' ') && !(mode & (TARGET_LOOK))) break;2740 if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break; 2741 2741 2742 2742 /* Change the intro */ … … 2799 2799 prt(out_val, 0, 0); 2800 2800 move_cursor_relative(y, x); 2801 query = inkey ();2801 query = inkey_ex(); 2802 2802 2803 2803 /* Stop on everything but "return"/"space" */ 2804 if ((query != '\n') && (query != '\r') && (query != ' ')) break;2804 if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break; 2805 2805 } 2806 2806 2807 2807 /* Stop on everything but "return" */ 2808 if ((query != '\n') && (query != '\r')) break;2808 if ((query.key != '\n') && (query.key != '\r')) break; 2809 2809 } 2810 2810 … … 2871 2871 bool flag = TRUE; 2872 2872 2873 charquery;2873 event_type query; 2874 2874 2875 2875 char info[80]; … … 2928 2928 2929 2929 /* Analyze */ 2930 switch (query )2930 switch (query.key) 2931 2931 { 2932 2932 case ESCAPE: … … 2978 2978 } 2979 2979 2980 case '\xff': 2981 { 2982 x = query.mousex + Term->offset_x; 2983 y = query.mousey + Term->offset_y; 2984 target_set_location(y, x); 2985 done = TRUE; 2986 break; 2987 } 2980 2988 case 't': 2981 2989 case '5': … … 2998 3006 } 2999 3007 3008 case 'g': 3009 { 3010 do_cmd_pathfind(y,x); 3011 done = TRUE; 3012 break; 3013 } 3014 3000 3015 default: 3001 3016 { 3002 3017 /* Extract direction */ 3003 d = target_dir(query );3018 d = target_dir(query.key); 3004 3019 3005 3020 /* Oops */ … … 3067 3082 3068 3083 /* Analyze the keypress */ 3069 switch (query )3084 switch (query.key) 3070 3085 { 3071 3086 case ESCAPE: … … 3127 3142 } 3128 3143 3144 case '\xff': 3145 { 3146 x = query.mousex + Term->offset_x; 3147 y = query.mousey + Term->offset_y; 3148 } 3129 3149 case 't': 3130 3150 case '5': … … 3137 3157 } 3138 3158 3159 case 'g': 3160 { 3161 do_cmd_pathfind(y,x); 3162 done = TRUE; 3163 break; 3164 } 3165 3139 3166 default: 3140 3167 { 3141 3168 /* Extract a direction */ 3142 d = target_dir(query );3169 d = target_dir(query.key); 3143 3170 3144 3171 /* Oops */ … … 3220 3247 int dir; 3221 3248 3222 char ch;3249 event_type ke; 3223 3250 3224 3251 cptr p; … … 3265 3292 3266 3293 /* Get a command (or Cancel) */ 3267 if (!get_com (p, &ch)) break;3294 if (!get_com_ex(p, &ke)) break; 3268 3295 3269 3296 /* Analyze */ 3270 switch (ch) 3271 { 3297 switch (ke.key) 3298 { 3299 /* Mouse aiming */ 3300 case '\xff': 3301 { 3302 target_set_location(ke.mousey + Term->offset_y, ke.mousex + Term->offset_x); 3303 dir = 5; 3304 break; 3305 } 3306 3272 3307 /* Set new target, use target if legal */ 3273 3308 case '*': … … 3290 3325 default: 3291 3326 { 3292 dir = target_dir( ch);3327 dir = target_dir(ke.key); 3293 3328 break; 3294 3329 }
