Changeset 134

Show
Ignore:
Timestamp:
05/14/07 03:18:32 (2 years ago)
Author:
takkaria
Message:
  • Create cmd0.c, with new command lists and command menu code. (closes #9)
  • arg_wizard now just resurrects the player.
  • The POSIX directory scanner now ignores subdirectories, and compiles.
  • process_command() should be the only caller of request_command() now. (in anticipation of future changes)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/Makefile.src

    r128 r134  
    1919        birth \ 
    2020        cave \ 
     21        cmd0 \ 
    2122        cmd1 \ 
    2223        cmd2 \ 
  • trunk/src/birth.c

    r132 r134  
    1010 
    1111#include "angband.h" 
    12  
     12#include "cmds.h" 
    1313#include "script.h" 
    1414 
  • trunk/src/dungeon.c

    r130 r134  
    10111011 
    10121012 
    1013  
    1014 /* 
    1015  * Verify use of "wizard" mode 
    1016  */ 
    1017 static bool enter_wizard_mode(void) 
    1018 { 
    1019         /* Ask first time - unless resurrecting a dead character */ 
    1020         if (verify_special && !(p_ptr->noscore & 0x0002) && !(p_ptr->is_dead)) 
    1021         { 
    1022                 /* Mention effects */ 
    1023                 msg_print("You are about to enter 'wizard' mode for the very first time!"); 
    1024                 msg_print("This is a form of cheating, and your game will not be scored!"); 
    1025                 message_flush(); 
    1026  
    1027                 /* Verify request */ 
    1028                 if (!get_check("Are you sure you want to enter wizard mode? ")) 
    1029                 { 
    1030                         return (FALSE); 
    1031                 } 
    1032         } 
    1033  
    1034         /* Mark savefile */ 
    1035         p_ptr->noscore |= 0x0002; 
    1036  
    1037         /* Success */ 
    1038         return (TRUE); 
    1039 } 
    1040  
    1041  
    1042  
    1043 #ifdef ALLOW_DEBUG 
    1044  
    1045 /* 
    1046  * Verify use of "debug" mode 
    1047  */ 
    1048 static bool verify_debug_mode(void) 
    1049 { 
    1050         /* Ask first time */ 
    1051         if (verify_special && !(p_ptr->noscore & 0x0008)) 
    1052         { 
    1053                 /* Mention effects */ 
    1054                 msg_print("You are about to use the dangerous, unsupported, debug commands!"); 
    1055                 msg_print("Your machine may crash, and your savefile may become corrupted!"); 
    1056                 message_flush(); 
    1057  
    1058                 /* Verify request */ 
    1059                 if (!get_check("Are you sure you want to use the debug commands? ")) 
    1060                 { 
    1061                         return (FALSE); 
    1062                 } 
    1063         } 
    1064  
    1065         /* Mark savefile */ 
    1066         p_ptr->noscore |= 0x0008; 
    1067  
    1068         /* Okay */ 
    1069         return (TRUE); 
    1070 } 
    1071  
    1072 #endif /* ALLOW_DEBUG */ 
    1073  
    1074  
    1075  
    1076 #ifdef ALLOW_BORG 
    1077  
    1078 /* 
    1079  * Verify use of "borg" mode 
    1080  */ 
    1081 static bool verify_borg_mode(void) 
    1082 { 
    1083         /* Ask first time */ 
    1084         if (verify_special && !(p_ptr->noscore & 0x0010)) 
    1085         { 
    1086                 /* Mention effects */ 
    1087                 msg_print("You are about to use the dangerous, unsupported, borg commands!"); 
    1088                 msg_print("Your machine may crash, and your savefile may become corrupted!"); 
    1089                 message_flush(); 
    1090  
    1091                 /* Verify request */ 
    1092                 if (!get_check("Are you sure you want to use the borg commands? ")) 
    1093                 { 
    1094                         return (FALSE); 
    1095                 } 
    1096         } 
    1097  
    1098         /* Mark savefile */ 
    1099         p_ptr->noscore |= 0x0010; 
    1100  
    1101         /* Okay */ 
    1102         return (TRUE); 
    1103 } 
    1104  
    1105 #endif /* ALLOW_BORG */ 
    1106  
    1107  
    1108 /* 
    1109  * Toggle wizard mode 
    1110  */ 
    1111 static void do_cmd_toggle_wizard(void) 
    1112 { 
    1113         if (p_ptr->wizard) 
    1114         { 
    1115                 p_ptr->wizard = FALSE; 
    1116                 msg_print("Wizard mode off."); 
    1117         } 
    1118         else if (enter_wizard_mode()) 
    1119         { 
    1120                 p_ptr->wizard = TRUE; 
    1121                 msg_print("Wizard mode on."); 
    1122         } 
    1123  
    1124         /* Update monsters */ 
    1125         p_ptr->update |= (PU_MONSTERS); 
    1126  
    1127         /* Redraw "title" */ 
    1128         p_ptr->redraw |= (PR_TITLE); 
    1129 } 
    1130  
    1131 #ifdef ALLOW_DEBUG 
    1132  
    1133 static void do_cmd_do_debug(void) 
    1134 { 
    1135         if (verify_debug_mode()) do_cmd_debug(); 
    1136 } 
    1137  
    1138 #endif 
    1139  
    1140 #ifdef ALLOW_BORG 
    1141  
    1142 static void do_cmd_do_borg(void) 
    1143 { 
    1144         if (verify_borg_mode()) do_cmd_borg(); 
    1145 } 
    1146  
    1147 #endif 
    1148  
    1149 static void do_cmd_cast_or_pray(void) 
    1150 { 
    1151         if (cp_ptr->spell_book == TV_PRAYER_BOOK) 
    1152                 do_cmd_pray(); 
    1153         else 
    1154                 do_cmd_cast(); 
    1155 } 
    1156  
    1157 static void do_cmd_quit(void) 
    1158 { 
    1159         /* Stop playing */ 
    1160         p_ptr->playing = FALSE; 
    1161  
    1162         /* Leaving */ 
    1163         p_ptr->leaving = TRUE; 
    1164 } 
    1165  
    1166 static void do_cmd_mouseclick(void) 
    1167 { 
    1168         int x, y; 
    1169  
    1170         x = p_ptr->command_cmd_ex.mousex - COL_MAP; 
    1171         if (use_bigtile) x /= 2; 
    1172         x += Term->offset_x; 
    1173         y = p_ptr->command_cmd_ex.mousey - ROW_MAP + Term->offset_y; 
    1174  
    1175         if (x < 0 || y < 0) 
    1176                 return; 
    1177  
    1178         do_cmd_pathfind(y, x); 
    1179 } 
    1180  
    1181 static void do_cmd_port(void) 
    1182 { 
    1183         (void)Term_user(0); 
    1184 } 
    1185  
    1186 static void do_cmd_xxx_options(void) 
    1187 { 
    1188         do_cmd_options(); 
    1189         do_cmd_redraw(); 
    1190 } 
    1191  
    1192 static void do_cmd_monlist(void) 
    1193 { 
    1194         /* Save the screen and display the list */ 
    1195         screen_save(); 
    1196         display_monlist(); 
    1197  
    1198         /* Wait */ 
    1199         inkey(); 
    1200  
    1201         /* Return */ 
    1202         screen_load(); 
    1203 } 
    1204  
    1205 /* 
    1206  * Useful typedef. 
    1207  */ 
    1208 typedef void do_cmd_type(void); 
    1209  
    1210 /* 
    1211  * List of all commands and their descriptions. 
    1212  */ 
    1213 static const struct 
    1214 { 
    1215         const char *desc; 
    1216         unsigned char key; 
    1217         do_cmd_type *hook; 
    1218 } commands[] = 
    1219 { 
    1220  
    1221         /*** Cheating commands ***/ 
    1222  
    1223         { "Toggle wizard mode",  KTRL('W'), do_cmd_toggle_wizard }, 
    1224  
    1225 #ifdef ALLOW_DEBUG 
    1226         { "Debug mode commands", KTRL('A'), do_cmd_do_debug }, 
    1227 #endif 
    1228 #ifdef ALLOW_BORG 
    1229         { "Borg commands",       KTRL('Z'), do_cmd_do_borg }, 
    1230 #endif 
    1231  
    1232  
    1233         /*** Inventory commands ***/ 
    1234  
    1235         { "Display equipment listing", 'e', do_cmd_equip }, 
    1236         { "Display inventory listing", 'i', do_cmd_inven }, 
    1237         { "Toggle windows",      KTRL('E'), toggle_inven_equip }, /* XXX */ 
    1238  
    1239  
    1240         /*** Movement commands ***/ 
    1241  
    1242         { "Alter a grid",  '+', do_cmd_alter }, 
    1243         { "Dig a tunnel",  'T', do_cmd_tunnel }, 
    1244         { "Walk",          ';', do_cmd_walk }, 
    1245         { "Jump (into a trap)", '-', do_cmd_jump }, 
    1246  
    1247  
    1248         /*** Running, Resting, Searching, Staying */ 
    1249  
    1250         { "Start running",          '.', do_cmd_run }, 
    1251         { "Hold still for a turn",  ',', do_cmd_hold }, 
    1252         { "Pick up objects",        'g', do_cmd_pickup }, 
    1253         { "Rest for a while",       'R', do_cmd_rest }, 
    1254         { "Search for traps/doors", 's', do_cmd_search }, 
    1255         { "Toggle search mode",     'S', do_cmd_toggle_search }, 
    1256  
    1257  
    1258         /*** Stairs and Doors and Chests and Traps ***/ 
    1259  
    1260         { "Enter a store",          '_', do_cmd_store }, 
    1261         { "Go up staircase",        '<', do_cmd_go_up }, 
    1262         { "Go down staircase",      '>', do_cmd_go_down }, 
    1263         { "Open a door or a chest", 'o', do_cmd_open }, 
    1264         { "Close a door",           'c', do_cmd_close }, 
    1265         { "Jam a door shut",        'j', do_cmd_spike }, 
    1266         { "Bash a door open",       'B', do_cmd_bash }, 
    1267         { "Disarm a trap or chest", 'D', do_cmd_disarm }, 
    1268  
    1269  
    1270         /*** Magic and Prayers ***/ 
    1271  
    1272         { "Gain new spells or prayers", 'G', do_cmd_study }, 
    1273         { "Browse a book",              'b', do_cmd_browse }, 
    1274         { "Cast a spell",               'm', do_cmd_cast_or_pray }, 
    1275         { "Pray a prayer",              'p', do_cmd_cast_or_pray }, 
    1276  
    1277  
    1278         /*** Use various objects ***/ 
    1279  
    1280         { "Wear/wield an item",       'w', do_cmd_wield }, 
    1281         { "Take/unwield off an item", 't', do_cmd_takeoff }, 
    1282         { "Drop an item",             'd', do_cmd_drop }, 
    1283         { "Destroy an item",          'k', do_cmd_destroy }, 
    1284         { "Examine an item",          'I', do_cmd_observe }, 
    1285         { "Inscribe an object",       '{', do_cmd_inscribe }, 
    1286         { "Uninscribe an object",     '}', do_cmd_uninscribe }, 
    1287         { "Activate an object",       'A', do_cmd_activate }, 
    1288         { "Eat some food",            'E', do_cmd_eat_food }, 
    1289         { "Fuel your light source",   'F', do_cmd_refill }, 
    1290         { "Fire your missile weapon", 'f', do_cmd_fire }, 
    1291         { "Throw an item",            'v', do_cmd_throw }, 
    1292         { "Aim a wand",               'a', do_cmd_aim_wand }, 
    1293         { "Zap a rod",                'z', do_cmd_zap_rod }, 
    1294         { "Quaff a potion",           'q', do_cmd_quaff_potion }, 
    1295         { "Read a scroll",            'r', do_cmd_read_scroll }, 
    1296         { "Use a staff",              'u', do_cmd_use_staff }, 
    1297  
    1298  
    1299         /*** Looking at Things (nearby or on map) ***/ 
    1300  
    1301         { "Full dungeon map",           'M', do_cmd_view_map }, 
    1302         { "Locate player on map",       'L', do_cmd_locate }, 
    1303         { "Look around",                'l', do_cmd_look }, 
    1304         { "Target monster or location", '*', do_cmd_target }, 
    1305  
    1306  
    1307         /*** Help and Such ***/ 
    1308  
    1309         { "Help",                  '?', do_cmd_help }, 
    1310         { "Identify symbol",       '/', do_cmd_query_symbol }, 
    1311         { "Character description", 'C', do_cmd_change_name }, 
    1312         { "Display monster list",  '[', do_cmd_monlist }, 
    1313  
    1314  
    1315         /*** System Commands ***/ 
    1316  
    1317         { "Load a single pref line",   '"', do_cmd_pref }, 
    1318         { "Interact with options",     '=', do_cmd_xxx_options }, 
    1319         { "Port-specific preferences", '!', do_cmd_port }, 
    1320         { "Check knowledge",           '~', do_cmd_knowledge }, 
    1321         { "Check knowledge",           '|', do_cmd_knowledge }, 
    1322  
    1323  
    1324         /*** Misc Commands ***/ 
    1325  
    1326         { "Take notes",                   ':', do_cmd_note }, 
    1327         { "Version info",                 'V', do_cmd_version }, 
    1328         { "Repeat level feeling",   KTRL('F'), do_cmd_feeling }, 
    1329         { "Show previous message",  KTRL('O'), do_cmd_message_one }, 
    1330         { "Show previous messages", KTRL('P'), do_cmd_messages }, 
    1331         { "Redraw the screen",      KTRL('R'), do_cmd_redraw }, 
    1332         { "Save and don't quit",    KTRL('S'), do_cmd_save_game }, 
    1333         { "Save and quit",          KTRL('X'), do_cmd_quit }, 
    1334         { "Quit (commit suicide)",        'Q', do_cmd_suicide }, 
    1335  
    1336         { "Load \"screen dump\"", '(', do_cmd_load_screen }, 
    1337         { "Save \"screen dump\"", ')', do_cmd_save_screen }, 
    1338         { "Mouse click",       '\xff', do_cmd_mouseclick } 
    1339 }; 
    1340  
    1341  
    1342 /* List indexed by char */ 
    1343 do_cmd_type *converted_list[UCHAR_MAX+1]; 
    1344  
    1345  
    1346 static void do_cmd_unknown(void) 
    1347 { 
    1348         prt("Type '?' for help.", 0, 0); 
    1349 } 
    1350  
    1351 /* 
    1352  * Parse and execute the current command 
    1353  * Give "Warning" on illegal commands. 
    1354  */ 
    1355 static void process_command(void) 
    1356 { 
    1357         static bool first = TRUE; 
    1358  
    1359 #ifdef ALLOW_REPEAT 
    1360  
    1361         /* Handle repeating the last command */ 
    1362         repeat_check(); 
    1363  
    1364 #endif /* ALLOW_REPEAT */ 
    1365  
    1366         if (first) 
    1367         { 
    1368                 size_t i; 
    1369  
    1370                 first = FALSE; 
    1371  
    1372                 /* Fill everything in at first */ 
    1373                 for (i = 0; i < N_ELEMENTS(commands); i++) 
    1374                 { 
    1375                         unsigned char key = commands[i].key; 
    1376                         assert(key < N_ELEMENTS(converted_list)); 
    1377                         converted_list[key] = commands[i].hook; 
    1378                 } 
    1379  
    1380                 /* Fill in the rest */ 
    1381                 for (i = 0; i < N_ELEMENTS(converted_list); i++) 
    1382                 { 
    1383                         switch (i) 
    1384                         { 
    1385                                 /* Ignore */ 
    1386                                 case ESCAPE: 
    1387                                 case ' ': 
    1388                                 case '\n': 
    1389                                 case '\r': 
    1390                                 case '\a': 
    1391                                 { 
    1392                                         break; 
    1393                                 } 
    1394  
    1395                                 default: 
    1396                                 { 
    1397                                         if (!converted_list[i]) 
    1398                                                 converted_list[i] = do_cmd_unknown; 
    1399                                 } 
    1400                         }                
    1401                 } 
    1402         } 
    1403  
    1404         /* Handle resize events XXX */ 
    1405         if (p_ptr->command_cmd_ex.type == EVT_RESIZE) 
    1406         { 
    1407                 do_cmd_redraw(); 
    1408         } 
    1409         else 
    1410         { 
    1411                 /* Within these boundaries, the cast to unsigned char will have the desired effect */ 
    1412                 assert(p_ptr->command_cmd >= CHAR_MIN && p_ptr->command_cmd <= CHAR_MAX); 
    1413  
    1414                 /* Execute the command */ 
    1415                 if (converted_list[(unsigned char) p_ptr->command_cmd]) 
    1416                         converted_list[(unsigned char) p_ptr->command_cmd](); 
    1417         } 
    1418 } 
    14191013 
    14201014 
     
    17001294 
    17011295                        /* Process the command */ 
    1702                         process_command(); 
     1296                        process_command(TRUE); 
    17031297 
    17041298                        /* Count this execution */ 
     
    17231317 
    17241318                        /* Get and process a command */ 
    1725                         request_command(); 
    1726                         process_command(); 
     1319                        process_command(FALSE); 
    17271320                } 
    17281321 
     
    23741967 
    23751968 
    2376         /* Hack -- Enter wizard mode */ 
    2377         if (arg_wizard && enter_wizard_mode()) p_ptr->wizard = TRUE; 
    2378  
    2379  
    23801969        /* Flavor the objects */ 
    23811970        flavor_init(); 
  • trunk/src/externs.h

    r127 r134  
    310310bool do_cmd_walk_test(int y, int x); 
    311311 
    312 /* cmd2.c */ 
    313 extern void do_cmd_go_up(void); 
    314 extern void do_cmd_go_down(void); 
    315 extern void do_cmd_search(void); 
    316 extern void do_cmd_toggle_search(void); 
    317 extern void do_cmd_open(void); 
    318 extern void do_cmd_close(void); 
    319 extern void do_cmd_tunnel(void); 
    320 extern void do_cmd_disarm(void); 
    321 extern void do_cmd_bash(void); 
    322 extern void do_cmd_alter(void); 
    323 extern void do_cmd_spike(void); 
    324 extern void do_cmd_walk(void); 
    325 extern void do_cmd_jump(void); 
    326 extern void do_cmd_run(void); 
    327 extern void do_cmd_pathfind(int y, int x); 
    328 extern void do_cmd_hold(void); 
    329 extern void do_cmd_pickup(void); 
    330 extern void do_cmd_rest(void); 
    331 extern void do_cmd_fire(void); 
    332 extern void do_cmd_throw(void); 
    333  
    334 /* cmd3.c */ 
    335 extern void do_cmd_inven(void); 
    336 extern void do_cmd_equip(void); 
    337 extern void do_cmd_wield(void); 
    338 extern void do_cmd_takeoff(void); 
    339 extern void do_cmd_drop(void); 
    340 extern void do_cmd_destroy(void); 
    341 extern void do_cmd_observe(void); 
    342 extern void do_cmd_uninscribe(void); 
    343 extern void do_cmd_inscribe(void); 
    344 extern void do_cmd_refill(void); 
    345 extern void do_cmd_target(void); 
    346 extern void do_cmd_look(void); 
    347 extern void do_cmd_locate(void); 
    348 extern void do_cmd_query_symbol(void); 
    349 extern bool ang_sort_comp_hook(const void *u, const void *v, int a, int b); 
    350 extern void ang_sort_swap_hook(void *u, void *v, int a, int b); 
    351  
    352 /* cmd4.c */ 
    353 extern void do_cmd_redraw(void); 
    354 extern void do_cmd_resize(void); 
    355 extern void do_cmd_change_name(void); 
    356 extern void do_cmd_message_one(void); 
    357 extern void do_cmd_messages(void); 
    358 extern void do_cmd_options(void); 
    359 extern void do_cmd_pref(void); 
    360 extern void do_cmd_macros(void); 
    361 extern void do_cmd_visuals(void); 
    362 extern void do_cmd_colors(void); 
    363 extern void do_cmd_note(void); 
    364 extern void do_cmd_version(void); 
    365 extern void do_cmd_feeling(void); 
    366 extern void do_cmd_load_screen(void); 
    367 extern void do_cmd_save_screen(void); 
    368 extern void do_cmd_knowledge(void); 
    369 extern void init_cmd4_c(void); 
    370  
    371 /* cmd5.c */ 
    372 extern void do_cmd_browse_aux(const object_type *o_ptr); 
    373 extern void do_cmd_browse(void); 
    374 extern void do_cmd_study(void); 
    375 extern void do_cmd_cast(void); 
    376 extern void do_cmd_pray(void); 
    377  
    378 /* cmd6.c */ 
    379 extern void do_cmd_eat_food(void); 
    380 extern void do_cmd_quaff_potion(void); 
    381 extern void do_cmd_read_scroll(void); 
    382 extern void do_cmd_use_staff(void); 
    383 extern void do_cmd_aim_wand(void); 
    384 extern void do_cmd_zap_rod(void); 
    385 extern void do_cmd_activate(void); 
    386  
    387312/* dungeon.c */ 
    388313extern void play_game(bool new_game); 
  • trunk/src/init2.c

    r103 r134  
    1414#include "init.h" 
    1515#include "script.h" 
     16#include "cmds.h" 
    1617 
    1718/* 
     
    17741775 
    17751776 
    1776         /* initialize the menus. This must occur before preference files are read */ 
     1777        /* Initialize the menus */ 
     1778        /* This must occur before preference files are read */ 
    17771779        init_cmd4_c(); 
    17781780         
     
    18581860        /* Done */ 
    18591861        note("[Initialization complete]"); 
     1862 
     1863        /* Sneakily init command list */ 
     1864        cmd_init(); 
    18601865} 
    18611866 
  • trunk/src/load.c

    r121 r134  
    22882288                                character_loaded = TRUE; 
    22892289 
     2290                                /* Mark the savefile */ 
     2291                                p_ptr->noscore |= 0x0002; 
     2292 
    22902293                                /* Done */ 
    22912294                                return (TRUE); 
  • trunk/src/store.c

    r133 r134  
    1212#include "angband.h" 
    1313#include "script.h" 
     14#include "cmds.h" 
    1415 
    1516/*** Constants and definitions ***/ 
  • trunk/src/ui.c

    r116 r134  
    10921092 
    10931093 
     1094 
     1095/*** Miscellaneous things ***/ 
     1096 
     1097/* 
     1098 * A Hengband-like 'window' function, that draws a surround box in ASCII art. 
     1099 */ 
     1100void window_make(int origin_x, int origin_y, int end_x, int end_y) 
     1101{ 
     1102        int n; 
     1103        region to_clear; 
     1104 
     1105        to_clear.col = origin_x; 
     1106        to_clear.row = origin_y; 
     1107        to_clear.width = end_x - origin_x; 
     1108        to_clear.page_rows = end_y - origin_y; 
     1109 
     1110        region_erase(&to_clear); 
     1111 
     1112        Term_putch(origin_x, origin_y, TERM_WHITE, '+'); 
     1113        Term_putch(end_x, origin_y, TERM_WHITE, '+'); 
     1114        Term_putch(origin_x, end_y, TERM_WHITE, '+'); 
     1115        Term_putch(end_x, end_y, TERM_WHITE, '+'); 
     1116 
     1117        for (n = 1; n < (end_x - origin_x); n++) 
     1118        { 
     1119                Term_putch(origin_x + n, origin_y, TERM_WHITE, '-'); 
     1120                Term_putch(origin_x + n, end_y, TERM_WHITE, '-'); 
     1121        } 
     1122 
     1123        for (n = 1; n < (end_y - origin_y); n++) 
     1124        { 
     1125                Term_putch(origin_x, origin_y + n, TERM_WHITE, '|'); 
     1126                Term_putch(end_x, origin_y + n, TERM_WHITE, '|'); 
     1127        } 
     1128} 
     1129 
  • trunk/src/ui.h

    r120 r134  
    373373 
    374374 
     375 
     376 
     377 
     378/*** Misc ***/ 
     379 
     380void window_make(int origin_x, int origin_y, int end_x, int end_y); 
     381 
     382 
    375383#endif /* UI_H */ 
    376384 
     385 
     386 
     387 
  • trunk/src/wizard1.c

    r127 r134  
    1111#include "angband.h" 
    1212#include "z-file.h" 
    13  
     13#include "cmds.h" 
    1414 
    1515#ifdef ALLOW_SPOILERS 
  • trunk/src/wizard2.c

    r24 r134  
    1010 
    1111#include "angband.h" 
    12  
     12#include "cmds.h" 
    1313#include "script.h" 
    1414 
  • trunk/src/xtra2.c

    r123 r134  
    1010 
    1111#include "angband.h" 
     12#include "cmds.h" 
     13 
    1214 
    1315/*** Timed effects ***/ 
     
    30043006                                case 'g': 
    30053007                                { 
    3006                                         do_cmd_pathfind(y,x); 
     3008                                        do_cmd_pathfind(y, x); 
    30073009                                        done = TRUE; 
    30083010                                        break; 
  • trunk/src/z-file.c

    r130 r134  
    4646#ifdef HAVE_MKSTEMP 
    4747 
     48#include <unistd.h> 
     49 
    4850FILE *my_fopen_temp(char *buf, size_t max) 
    4951{ 
     
    854856        WIN32_FIND_DATA fd; 
    855857        BOOL ok; 
    856         bool next = TRUE; 
    857858 
    858859        /* Try the first file */ 
     
    869870 
    870871        /* Try the next file */ 
    871         while (next
     872        while (1
    872873        { 
    873874                ok = FindNextFile(dir->h, &fd); 
     
    881882 
    882883                /* Take this one */ 
    883                 my_strcpy(fname, fd.cFileName, len); 
    884                 next = FALSE; 
    885         } 
     884                break; 
     885        } 
     886 
     887        /* Copy name */ 
     888        my_strcpy(fname, fd.cFileName, len); 
    886889 
    887890        return TRUE; 
     
    917920{ 
    918921        ang_dir *dir; 
    919         DIR d; 
     922        DIR *d; 
    920923 
    921924        /* Try to open the directory */ 
     
    943946 
    944947        /* Try reading another entry */ 
    945         entry = readdir(dir->d); 
    946         if (!entry) return FALSE; 
     948        while (1) 
     949        { 
     950                entry = readdir(dir->d); 
     951                if (!entry) return FALSE; 
     952 
     953                /* Check to see if it exists */ 
     954                if (stat(entry->d_name, &filedata) != 0) 
     955                        continue; 
     956 
     957                /* Check to see if it's a directory */ 
     958                if (S_ISDIR(filedata.st_mode)) 
     959                        continue; 
     960 
     961                /* We've found something worth returning */ 
     962                break; 
     963        } 
    947964 
    948965        /* Copy the filename */ 
    949         /* XXX ignore overflow */ 
    950966        my_strcpy(fname, entry->d_name, len); 
    951967