Changeset 538
- Timestamp:
- 08/19/07 12:46:27 (1 year ago)
- Files:
-
- trunk/src/Makefile.src (modified) (1 diff)
- trunk/src/dungeon.c (modified) (1 diff)
- trunk/src/externs.h (modified) (2 diffs)
- trunk/src/init2.c (modified) (6 diffs)
- trunk/src/main-win.c (modified) (9 diffs)
- trunk/src/main.c (modified) (4 diffs)
- trunk/src/ui-event.c (modified) (1 diff)
- trunk/src/ui-event.h (modified) (3 diffs)
- trunk/src/xtra3.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/Makefile.src
r528 r538 35 35 effects.o \ 36 36 files.o \ 37 game-cmd.o \ 37 38 generate.o \ 38 39 init1.o \ trunk/src/dungeon.c
r522 r538 1767 1767 * flag, which is a hack, but which optimizes loading of savefiles. 1768 1768 */ 1769 void play_game( bool new_game)1769 void play_game(void) 1770 1770 { 1771 /* Initialize */ 1772 bool new_game = init_angband(); 1773 1774 1775 1771 1776 /*** Do horrible, hacky things, to start the game off ***/ 1772 1777 trunk/src/externs.h
r532 r538 315 315 316 316 /* dungeon.c */ 317 extern void play_game( bool new_game);317 extern void play_game(void); 318 318 extern int value_check_aux1(const object_type *o_ptr); 319 319 … … 344 344 extern void init_file_paths(const char *path); 345 345 extern void create_user_dirs(void); 346 extern voidinit_angband(void);346 extern bool init_angband(void); 347 347 extern void cleanup_angband(void); 348 348 trunk/src/init2.c
r522 r538 15 15 #include "cmds.h" 16 16 #include "option.h" 17 #include "ui-event.h" 18 #include "game-cmd.h" 17 19 18 20 /* … … 1351 1353 1352 1354 1353 /*1354 * Hack -- take notes on line 231355 */1356 static void note(cptr str)1357 {1358 Term_erase(0, 23, 255);1359 Term_putstr(20, 23, -1, TERM_WHITE, str);1360 Term_fresh();1361 }1362 1363 1364 1365 /*1366 * Hack -- Explain a broken "lib" folder and quit (see below).1367 */1368 static void init_angband_aux(cptr why)1369 {1370 quit_fmt("%s\n\n%s", why,1371 "The 'lib' directory is probably missing or broken.\n"1372 "Perhaps the archive was not extracted correctly.\n"1373 "See the 'readme.txt' file for more information.");1374 }1375 1376 1355 1377 1356 /* … … 1422 1401 * if needed, in the first (?) pass through "TERM_XTRA_REACT". 1423 1402 */ 1424 void init_angband(void) 1425 { 1426 ang_file *fp; 1427 1428 char buf[1024]; 1429 1430 /* Set up the display handlers and things. */ 1431 init_display(); 1432 1433 /*** Verify the "news" file ***/ 1434 1435 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "news.txt"); 1436 if (!file_exists(buf)) 1437 { 1438 char why[1024]; 1439 1440 /* Crash and burn */ 1441 strnfmt(why, sizeof(why), "Cannot access the '%s' file!", buf); 1442 init_angband_aux(why); 1443 } 1444 1445 1446 /*** Display the "news" file ***/ 1447 1448 Term_clear(); 1449 1450 /* Open the News file */ 1451 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "news.txt"); 1452 fp = file_open(buf, MODE_READ, -1); 1453 1454 /* Dump */ 1455 if (fp) 1456 { 1457 int i = 0; 1458 1459 /* Dump the file to the screen */ 1460 while (file_getl(fp, buf, sizeof(buf))) 1461 Term_putstr(0, i++, -1, TERM_WHITE, buf); 1462 1463 file_close(fp); 1464 } 1465 1466 /* Flush it */ 1467 Term_fresh(); 1468 1469 1403 bool init_angband(void) 1404 { 1405 ui_event_signal(ui_ENTER_INIT); 1470 1406 1471 1407 /* Initialize the menus */ … … 1475 1411 /*** Initialize some arrays ***/ 1476 1412 1477 1478 1413 /* Initialize size info */ 1479 note("[Initializing array sizes...]");1414 ui_event_signal_string(ui_INIT_STATUS, "Initializing array sizes..."); 1480 1415 if (init_z_info()) quit("Cannot initialize sizes"); 1481 1416 1482 1417 /* Initialize feature info */ 1483 note("[Initializing arrays... (features)]");1418 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (features)"); 1484 1419 if (init_f_info()) quit("Cannot initialize features"); 1485 1420 1486 1421 /* Initialize object info */ 1487 note("[Initializing arrays... (objects)]");1422 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (objects)"); 1488 1423 if (init_k_info()) quit("Cannot initialize objects"); 1489 1424 1490 1425 /* Initialize artifact info */ 1491 note("[Initializing arrays... (artifacts)]");1426 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (artifacts)"); 1492 1427 if (init_a_info()) quit("Cannot initialize artifacts"); 1493 1428 1494 1429 /* Initialize ego-item info */ 1495 note("[Initializing arrays... (ego-items)]");1430 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (ego-items"); 1496 1431 if (init_e_info()) quit("Cannot initialize ego-items"); 1497 1432 1498 1433 /* Initialize monster info */ 1499 note("[Initializing arrays... (monsters)]");1434 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (monsters)"); 1500 1435 if (init_r_info()) quit("Cannot initialize monsters"); 1501 1436 1502 1437 /* Initialize feature info */ 1503 note("[Initializing arrays... (vaults)]");1438 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (vaults)"); 1504 1439 if (init_v_info()) quit("Cannot initialize vaults"); 1505 1440 1506 1441 /* Initialize history info */ 1507 note("[Initializing arrays... (histories)]");1442 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (histories)"); 1508 1443 if (init_h_info()) quit("Cannot initialize histories"); 1509 1444 1510 1445 /* Initialize race info */ 1511 note("[Initializing arrays... (races)]");1446 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (races)"); 1512 1447 if (init_p_info()) quit("Cannot initialize races"); 1513 1448 1514 1449 /* Initialize class info */ 1515 note("[Initializing arrays... (classes)]");1450 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (classes)"); 1516 1451 if (init_c_info()) quit("Cannot initialize classes"); 1517 1452 1518 1453 /* Initialize owner info */ 1519 note("[Initializing arrays... (owners)]");1454 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (owners)"); 1520 1455 if (init_b_info()) quit("Cannot initialize owners"); 1521 1456 1522 1457 /* Initialize price info */ 1523 note("[Initializing arrays... (prices)]");1458 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (prices)"); 1524 1459 if (init_g_info()) quit("Cannot initialize prices"); 1525 1460 1526 1461 /* Initialize flavor info */ 1527 note("[Initializing arrays... (flavors)]");1462 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (flavors)"); 1528 1463 if (init_flavor_info()) quit("Cannot initialize flavors"); 1529 1464 1530 1465 /* Initialize spell info */ 1531 note("[Initializing arrays... (spells)]");1466 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (spells)"); 1532 1467 if (init_s_info()) quit("Cannot initialize spells"); 1533 1468 1534 1469 /* Initialize spellbook info */ 1535 note("[Initializing arrays... (spellbooks)]");1470 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (spellbooks)"); 1536 1471 init_books(); 1537 1472 1538 1473 /* Initialize some other arrays */ 1539 note("[Initializing arrays... (other)]");1474 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (other)"); 1540 1475 if (init_other()) quit("Cannot initialize other stuff"); 1541 1476 1542 1477 /* Initialize some other arrays */ 1543 note("[Initializing arrays... (alloc)]");1478 ui_event_signal_string(ui_INIT_STATUS, "Initializing arrays... (alloc)"); 1544 1479 if (init_alloc()) quit("Cannot initialize alloc stuff"); 1545 1480 … … 1547 1482 1548 1483 /* Initialize feature info */ 1549 note("[Loading basic user pref file...]");1484 ui_event_signal_string(ui_INIT_STATUS, "Loading basic user pref file..."); 1550 1485 1551 1486 /* Process that file */ … … 1553 1488 1554 1489 /* Done */ 1555 note("[Initialization complete]");1490 ui_event_signal_string(ui_INIT_STATUS, "Initialization complete"); 1556 1491 1557 1492 /* Sneakily init command list */ 1558 1493 cmd_init(); 1494 1495 /* Ask for a "command" until we get one we like. */ 1496 while (1) 1497 { 1498 game_command command_req = get_game_command(); 1499 1500 if (command_req.command == CMD_QUIT) 1501 quit(NULL); 1502 1503 else if (command_req.command == CMD_NEWGAME) 1504 return TRUE; 1505 1506 else if (command_req.command == CMD_LOADFILE) 1507 /* In future we might want to pass back or set the savefile 1508 path here. */ 1509 return FALSE; 1510 } 1559 1511 } 1560 1512 trunk/src/main-win.c
r529 r538 661 661 }; 662 662 663 #include "game-cmd.h" 664 665 static game_command cmd = { CMD_NULL, 0 }; 666 663 667 #if 0 664 668 /* … … 2946 2950 /* Next arg */ 2947 2951 p = strchr(s, ' '); 2948 2952 2949 2953 /* Tokenize */ 2950 2954 if (p) *p = '\0'; … … 2956 2960 validate_file(savefile); 2957 2961 2958 /* Game in progress */ 2959 game_in_progress = TRUE; 2960 2961 Term_fresh(); 2962 2963 /* Play game */ 2964 play_game(FALSE); 2965 2966 /* Quit */ 2967 quit(NULL); 2962 /* Set the command now so that we skip the "Open File" prompt. */ 2963 cmd.command = CMD_LOADFILE; 2968 2964 } 2969 2965 … … 3159 3155 else 3160 3156 { 3161 game_in_progress = TRUE; 3162 Term_flush(); 3163 play_game(TRUE); 3164 quit(NULL); 3157 /* We'll return NEWGAME to the game. */ 3158 cmd.command = CMD_NEWGAME; 3165 3159 } 3166 3160 break; … … 3194 3188 /* Load 'savefile' */ 3195 3189 validate_file(savefile); 3196 game_in_progress = TRUE; 3197 Term_flush(); 3198 play_game(FALSE); 3199 quit(NULL); 3190 3191 /* We'll return NEWGAME to the game. */ 3192 cmd.command = CMD_LOADFILE; 3200 3193 } 3201 3194 } … … 4554 4547 4555 4548 exit(0); 4549 } 4550 4551 4552 static game_command get_init_cmd() 4553 { 4554 MSG msg; 4555 4556 /* Prompt the user */ 4557 prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 17); 4558 Term_fresh(); 4559 4560 /* Process messages forever */ 4561 while (cmd.command == CMD_NULL && GetMessage(&msg, NULL, 0, 0)) 4562 { 4563 TranslateMessage(&msg); 4564 DispatchMessage(&msg); 4565 } 4566 4567 /* Bit of a hack, we'll do this when we leave the INIT context in future. */ 4568 game_in_progress = TRUE; 4569 4570 return cmd; 4556 4571 } 4557 4572 … … 4709 4724 WNDCLASS wc; 4710 4725 HDC hdc; 4711 MSG msg;4712 4726 4713 4727 /* Unused parameter */ … … 4843 4857 ANGBAND_SYS = "win"; 4844 4858 4845 /* Initialize */4846 init_angband();4847 4848 /* We are now initialized */4849 initialized = TRUE;4850 4851 4859 #ifdef USE_SAVER 4852 4860 if (screensaver) … … 4870 4878 check_for_save_file(lpCmdLine); 4871 4879 4872 /* Prompt the user*/4873 prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 17);4874 Term_fresh(); 4875 4876 /* Process messages forever */4877 while (GetMessage(&msg, NULL, 0, 0)) 4878 {4879 TranslateMessage(&msg); 4880 DispatchMessage(&msg);4881 }4880 /* Set command hook */ 4881 get_game_command = get_init_cmd; 4882 4883 /* Set up the display handlers and things. */ 4884 init_display(); 4885 4886 initialized = TRUE; 4887 4888 /* Play the game */ 4889 play_game(); 4882 4890 4883 4891 /* Paranoia */ trunk/src/main.c
r529 r538 30 30 31 31 #include "main.h" 32 #include "game-cmd.h" 32 33 33 34 … … 193 194 #endif /* SET_UID */ 194 195 196 static bool new_game; 197 198 /* 199 * Pass the appropriate "Initialisation screen" command to the game, 200 * getting user input if needed. 201 */ 202 static game_command get_init_cmd() 203 { 204 game_command cmd; 205 206 /* Wait for response */ 207 pause_line(Term->hgt - 1); 208 209 if (new_game) 210 cmd.command = CMD_NEWGAME; 211 else 212 /* This might be modified to supply the filename in future. */ 213 cmd.command = CMD_LOADFILE; 214 215 return cmd; 216 } 217 195 218 196 219 /* … … 206 229 207 230 bool done = FALSE; 208 bool new_game = FALSE;209 231 210 232 int show_score = 0; … … 435 457 signals_init(); 436 458 437 /* Initialize */ 438 init_angband(); 439 440 /* Hack -- If requested, display scores and quit */ 441 if (show_score > 0) display_scores(0, show_score); 442 443 /* Wait for response */ 444 pause_line(Term->hgt - 1); 459 /* Set up the command hooks */ 460 get_game_command = get_init_cmd; 461 462 /* Set up the display handlers and things. */ 463 init_display(); 445 464 446 465 /* Play the game */ 447 play_game( new_game);466 play_game(); 448 467 449 468 /* Free resources */ trunk/src/ui-event.c
r536 r538 129 129 ui_event_dispatch(type, &data); 130 130 } 131 132 133 void ui_event_signal_string(ui_event_type type, const char *s) 134 { 135 ui_event_data data; 136 data.string = s; 137 138 ui_event_dispatch(type, &data); 139 } trunk/src/ui-event.h
r523 r538 34 34 ui_MESSAGES_CHANGED, 35 35 36 ui_event_REDRAW /* It's the end of a "set" of events, so safe to update */ 36 ui_event_REDRAW, /* It's the end of a "set" of events, so safe to update */ 37 38 ui_INIT_STATUS, /* New status message for initialisation */ 39 40 /* Changing of the game state/context. */ 41 ui_ENTER_INIT, 42 ui_ENTER_BIRTH, 43 ui_ENTER_GAME, 44 ui_ENTER_STORE, 45 ui_ENTER_DEATH 37 46 } ui_event_type; 38 47 39 #define N_UI_EVENTS ui_ event_REDRAW48 #define N_UI_EVENTS ui_ENTER_DEATH 40 49 41 50 typedef union … … 46 55 int y; 47 56 } point; 57 58 const char *string; 48 59 49 60 } ui_event_data; … … 57 68 58 69 void ui_event_signal_point(ui_event_type, int x, int y); 70 void ui_event_signal_string(ui_event_type, const char *s); 59 71 void ui_event_signal(ui_event_type); 60 72 trunk/src/xtra3.c
r534 r538 1460 1460 1461 1461 /* ------------------------------------------------------------------------ 1462 * Showing and updating the splash screen. 1463 * ------------------------------------------------------------------------ */ 1464 /* 1465 * Hack -- Explain a broken "lib" folder and quit (see below). 1466 */ 1467 static void init_angband_aux(cptr why) 1468 { 1469 quit_fmt("%s\n\n%s", why, 1470 "The 'lib' directory is probably missing or broken.\n" 1471 "Perhaps the archive was not extracted correctly.\n" 1472 "See the 'readme.txt' file for more information."); 1473 } 1474 1475 /* 1476 * Hack -- take notes on line 23 1477 */ 1478 static void splashscreen_note(ui_event_type type, ui_event_data *data, void *user) 1479 { 1480 Term_erase(0, 23, 255); 1481 Term_putstr(20, 23, -1, TERM_WHITE, format("[%s]", data->string)); 1482 Term_fresh(); 1483 } 1484 1485 static void show_splashscreen(ui_event_type type, ui_event_data *data, void *user) 1486 { 1487 ang_file *fp; 1488 1489 char buf[1024]; 1490 1491 /*** Verify the "news" file ***/ 1492 1493 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "news.txt"); 1494 if (!file_exists(buf)) 1495 { 1496 char why[1024]; 1497 1498 /* Crash and burn */ 1499 strnfmt(why, sizeof(why), "Cannot access the '%s' file!", buf); 1500 init_angband_aux(why); 1501 } 1502 1503 1504 /*** Display the "news" file ***/ 1505 1506 Term_clear(); 1507 1508 /* Open the News file */ 1509 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "news.txt"); 1510 fp = file_open(buf, MODE_READ, -1); 1511 1512 /* Dump */ 1513 if (fp) 1514 { 1515 int i = 0; 1516 1517 /* Dump the file to the screen */ 1518 while (file_getl(fp, buf, sizeof(buf))) 1519 Term_putstr(0, i++, -1, TERM_WHITE, buf); 1520 1521 file_close(fp); 1522 } 1523 1524 /* Flush it */ 1525 Term_fresh(); 1526 } 1527 1528 1529 /* ------------------------------------------------------------------------ 1462 1530 * Temporary (hopefully) hackish solutions. 1463 1531 * ------------------------------------------------------------------------ */ … … 1492 1560 /* Check if the panel should shift when the player's moved */ 1493 1561 ui_event_register(ui_PLAYER_MOVED, check_panel, NULL); 1494 } 1562 1563 1564 /* Set up our splashscreen handlers */ 1565 ui_event_register(ui_ENTER_INIT, show_splashscreen, NULL); 1566 ui_event_register(ui_INIT_STATUS, splashscreen_note, NULL); 1567 }
