-+-+-+-+-+-+-+-+ START OF PART 19 -+-+-+-+-+-+-+-+ X while (fgets(in_line, 80, file1) != CNIL) X`09if (strlen(in_line) > 3) X`09 `7B X`09 if (!strncmp(in_line, "SUN:", 4)) X`09 (void) strcpy(days`5B0`5D, in_line); X`09 else if (!strncmp(in_line, "MON:", 4)) X`09 (void) strcpy(days`5B1`5D, in_line); X`09 else if (!strncmp(in_line, "TUE:", 4)) X`09 (void) strcpy(days`5B2`5D, in_line); X`09 else if (!strncmp(in_line, "WED:", 4)) X`09 (void) strcpy(days`5B3`5D, in_line); X`09 else if (!strncmp(in_line, "THU:", 4)) X`09 (void) strcpy(days`5B4`5D, in_line); X`09 else if (!strncmp(in_line, "FRI:", 4)) X`09 (void) strcpy(days`5B5`5D, in_line); X`09 else if (!strncmp(in_line, "SAT:", 4)) X`09 (void) strcpy(days`5B6`5D, in_line); X`09 `7D X (void) fclose(file1); X `7D X else X `7B X restore_term(); X (void) fprintf(stderr, "There is no hours file \"%s\".\n", MORIA_HOU); X (void) fprintf(stderr, "Please inform the wizard, %s, so he ", WIZARD) V; X (void) fprintf(stderr, "can correct this!\n"); X exit(1); X `7D X X /* Check the hours, if closed`09then exit. */ X if (!check_time()) X `7B X if ((file1 = fopen(MORIA_HOU, "r")) != NULL) X`09`7B X`09 clear_screen(); X#ifdef VMS X`09 restore_screen(); X#endif X`09 for (i = 0; fgets(in_line, 80, file1) != CNIL; i++) X`09 put_buffer(in_line, i, 0); X`09 pause_line (23); X`09 (void) fclose(file1); X`09`7D X exit_game(); X `7D X#endif X X /* Print the introduction message, news, etc.`09`09 */ X if ((file1 = fopen(MORIA_MOR, "r")) != NULL) X `7B X clear_screen(); X#ifdef VMS X restore_screen(); X#endif X for (i = 0; fgets(in_line, 80, file1) != CNIL; i++) X`09put_buffer(in_line, i, 0); X pause_line(23); X (void) fclose(file1); X `7D X`7D X#endif X X/* File perusal.`09 -CJS- X primitive, but portable */ Xvoid helpfile(filename) Xchar *filename; X#ifdef MAC X`7B X mac_helpfile(filename, TRUE); X`7D X#else X`7B X bigvtype tmp_str; X FILE *file; X char input; X int i; X X file = fopen(filename, "r"); X if (file == NULL) X `7B X (void) sprintf (tmp_str, "Can not find help file \"%s\".\n", filename) V; X prt (tmp_str, 0, 0); X return; X `7D X X save_screen(); X X while (!feof(file)) X `7B X clear_screen(); X for (i = 0; i < 23; i++) X`09if (fgets (tmp_str, BIGVTYPESIZ-1, file) != CNIL) X`09 put_buffer (tmp_str, i, 0); X prt("`5BPress any key to continue.`5D", 23, 23); X input = inkey(); X if (input == ESCAPE) X`09break; X `7D X X (void) fclose(file); X restore_screen(); X`7D X#endif X X/* Prints a list of random objects to a file. Note that -RAK-`09 */ X/* the objects produced is a sampling of objects which`09`09 */ X/* be expected to appear on that level.`09`09`09`09 */ Xvoid print_objects() X`7B X register int i; X int nobj, j, level; X vtype filename1; bigvtype tmp_str; X register FILE *file1; X register inven_type *i_ptr; X#ifdef MAC X short vrefnum; X#endif X#ifdef ATARIST_MWC X int32u holder; X#endif X X prt("Produce objects on what level?: ", 0, 0); X level = 0; X if (!get_string(tmp_str, 0, 32, 10)) X return; X level = atoi(tmp_str); X prt("Produce how many objects?: ", 0, 0); X nobj = 0; X if (!get_string(tmp_str, 0, 27, 10)) X return; X nobj = atoi(tmp_str); X if ((nobj > 0) && (level > -1) && (level < 1201)) X `7B X if (nobj > 10000) X`09nobj = 10000; X#ifdef MAC X (void) strcpy(filename1, "Objects"); X if (doputfile("Save objects in:", filename1, &vrefnum)) X#else X prt("File name: ", 0, 0); X if (get_string(filename1, 0, 11, 64)) X#endif X`09`7B X`09 if (strlen(filename1) == 0) X`09 return; X#ifdef MAC X`09 changedirectory(vrefnum); X#endif X`09 if ((file1 = fopen(filename1, "w")) != NULL) X`09 `7B X#ifdef MAC X`09 macbeginwait (); X#endif X X`09 (void) sprintf(tmp_str, "%d", nobj); X`09 prt(strcat(tmp_str, " random objects being produced..."), 0, 0); X`09 put_qio(); X`09 (void) fprintf(file1, "*** Random Object Sampling:\n"); X`09 (void) fprintf(file1, "*** %d objects\n", nobj); X`09 (void) fprintf(file1, "*** For Level %d\n", level); X`09 (void) fprintf(file1, "\n"); X`09 (void) fprintf(file1, "\n"); X`09 j = popt(); X`09 for (i = 0; i < nobj; i++) X`09`09`7B X`09`09 invcopy(&t_list`5Bj`5D, sorted_objects`5Bget_obj_num(level)`5D); X`09`09 magic_treasure(j, level); X`09`09 i_ptr = &t_list`5Bj`5D; X`09`09 store_bought(i_ptr); X#ifdef ATARIST_MWC X`09`09 if (i_ptr->flags & (holder = TR_CURSED)) X#else X`09`09 if (i_ptr->flags & TR_CURSED) X#endif X`09`09 add_inscribe(i_ptr, ID_DAMD); X`09`09 objdes(tmp_str, i_ptr, TRUE); X`09`09 (void) fprintf(file1, "%d %s\n", i_ptr->level, tmp_str); X`09`09`7D X`09 pusht((int8u)j); X`09 (void) fclose(file1); X#ifdef MAC X`09 setfileinfo(filename1, vrefnum, INFO_FTYPE); X`09 macendwait (); X#endif X`09 prt("Completed.", 0, 0); X`09 `7D X`09 else X`09 prt("File could not be opened.", 0, 0); X#ifdef MAC X`09 restoredirectory(); X#endif X`09`7D X `7D X else X prt ("Parameters no good.", 0, 0); X`7D X X X/* Print the character to a file or device`09`09-RAK-`09 */ X#ifdef MAC Xint file_character() X#else Xint file_character(filename1) Xchar *filename1; X#endif X`7B X register int i; X int j, xbth, xbthb, xfos, xsrh, xstl, xdis, xsave, xdev; X vtype xinfra; X int fd; X register FILE *file1; X bigvtype prt2; X register struct misc *p_ptr; X register inven_type *i_ptr; X vtype out_val, prt1; X char *p, *colon, *blank; X#ifdef MAC X vtype filename1; X short vrefnum; X#endif X X#ifdef MAC X (void) makefilename(filename1, "Stats", TRUE); X if (!doputfile("Save character description in:", filename1, &vrefnum)) X return (FALSE); X#endif X X#ifndef VMS X /* VMS creates a new version of a file, so no need to check for rewrite. * V/ X#ifdef MAC X changedirectory(vrefnum); X fd = open (filename1, O_WRONLY`7CO_CREAT`7CO_TRUNC); X restoredirectory(); X macbeginwait (); X#else X#if defined(GEMDOS) && (__STDC__ == 0) && !defined(ATARIST_TC) X if (!access(filename1, AREAD)) X `7B X (void) sprintf(out_val, "Replace existing file %s?", filename1); X if (get_check(out_val)) X`09fd = creat(filename1, 1); X `7D X else X fd = creat (filename1, 1); X#else X fd = open (filename1, O_WRONLY`7CO_CREAT`7CO_EXCL, 0644); X if (fd < 0 && errno == EEXIST) X `7B X (void) sprintf(out_val, "Replace existing file %s?", filename1); X if (get_check(out_val)) X`09fd = open(filename1, O_WRONLY, 0644); X `7D X#endif X#endif X if (fd >= 0) X `7B X /* on some non-unix machines, fdopen() is not reliable, hence must cal Vl X`09 close() and then fopen() */ X (void) close(fd); X file1 = fopen(filename1, "w"); X `7D X else X file1 = NULL; X#else /* VMS */ X fd = -1; X file1 = fopen (filename1, "w"); X#endif X X if (file1 != NULL) X `7B X prt("Writing character sheet...", 0, 0); X put_qio(); X colon = ":"; X blank = " "; X#ifdef MAC X (void) fprintf(file1, "\n\n"); X#else X (void) fprintf(file1, "%c\n\n", CTRL('L')); X#endif X (void) fprintf(file1, " Name%9s %-23s", colon, py.misc.name); X (void) fprintf(file1, " Age%11s %6d", colon, (int)py.misc.age); X cnv_stat(py.stats.use_stat`5BA_STR`5D, prt1); X (void) fprintf(file1, " STR : %s\n", prt1); X (void) fprintf(file1, " Race%9s %-23s", colon, X`09`09 race`5Bpy.misc.prace`5D.trace); X (void) fprintf(file1, " Height%8s %6d", colon, (int)py.misc.ht); X cnv_stat(py.stats.use_stat`5BA_INT`5D, prt1); X (void) fprintf(file1, " INT : %s\n", prt1); X (void) fprintf(file1, " Sex%10s %-23s", colon, X`09`09 (py.misc.male ? "Male" : "Female")); X (void) fprintf(file1, " Weight%8s %6d", colon, (int)py.misc.wt); X cnv_stat(py.stats.use_stat`5BA_WIS`5D, prt1); X (void) fprintf(file1, " WIS : %s\n", prt1); X (void) fprintf(file1, " Class%8s %-23s", colon, X`09`09 class`5Bpy.misc.pclass`5D.title); X (void) fprintf(file1, " Social Class : %6d", py.misc.sc); X cnv_stat(py.stats.use_stat`5BA_DEX`5D, prt1); X (void) fprintf(file1, " DEX : %s\n", prt1); X (void) fprintf(file1, " Title%8s %-23s", colon, title_string()); X (void) fprintf(file1, "%22s", blank); X cnv_stat(py.stats.use_stat`5BA_CON`5D, prt1); X (void) fprintf(file1, " CON : %s\n", prt1); X (void) fprintf(file1, "%34s", blank); X (void) fprintf(file1, "%26s", blank); X cnv_stat(py.stats.use_stat`5BA_CHR`5D, prt1); X (void) fprintf(file1, " CHR : %s\n\n", prt1); X X (void) fprintf(file1, " + To Hit : %6d", py.misc.dis_th); X (void) fprintf(file1, "%8sLevel : %6d", blank, (int)py.misc.lev); X (void) fprintf(file1, " Max Hit Points : %6d\n", py.misc.mhp); X (void) fprintf(file1, " + To Damage : %6d", py.misc.dis_td); X (void) fprintf(file1, "%8sExperience : %6ld", blank, py.misc.exp); X (void) fprintf(file1, " Cur Hit Points : %6d\n", py.misc.chp); X (void) fprintf(file1, " + To AC : %6d", py.misc.dis_tac); X (void) fprintf(file1, "%8sMax Exp : %6ld", blank, py.misc.max_exp); X (void) fprintf(file1, " Max Mana%8s %6d\n", colon, py.misc.mana); X (void) fprintf(file1, " Total AC : %6d", py.misc.dis_ac); X if (py.misc.lev == MAX_PLAYER_LEVEL) X`09(void) fprintf (file1, "%8sExp to Adv : ******", blank); X else X`09(void) fprintf(file1, "%8sExp to Adv : %6ld", blank, X`09`09 (int32)(player_exp`5Bpy.misc.lev-1`5D X`09`09`09 * py.misc.expfact / 100)); X (void) fprintf(file1, " Cur Mana%8s %6d\n", colon, py.misc.cmana); X (void) fprintf(file1, "%29sGold%8s %6ld\n\n", blank, colon, X`09`09 py.misc.au); X X p_ptr = &py.misc; X xbth = p_ptr->bth + p_ptr->ptohit * BTH_PLUS_ADJ X`09+ (class_level_adj`5Bp_ptr->pclass`5D`5BCLA_BTH`5D * p_ptr->lev); X xbthb = p_ptr->bthb + p_ptr->ptohit * BTH_PLUS_ADJ X`09+ (class_level_adj`5Bp_ptr->pclass`5D`5BCLA_BTHB`5D * p_ptr->lev); X /* this results in a range from 0 to 29 */ X xfos = 40 - p_ptr->fos; X if (xfos < 0) X`09xfos = 0; X xsrh = p_ptr->srh; X /* this results in a range from 0 to 9 */ X xstl = p_ptr->stl + 1; X xdis = p_ptr->disarm + 2 * todis_adj() + stat_adj(A_INT) X`09+ (class_level_adj`5Bp_ptr->pclass`5D`5BCLA_DISARM`5D * p_ptr->lev / 3); X xsave = p_ptr->save + stat_adj(A_WIS) X`09+ (class_level_adj`5Bp_ptr->pclass`5D`5BCLA_SAVE`5D * p_ptr->lev / 3); X xdev = p_ptr->save + stat_adj(A_INT) X`09+ (class_level_adj`5Bp_ptr->pclass`5D`5BCLA_DEVICE`5D * p_ptr->lev / 3); X X (void) sprintf(xinfra, "%d feet", py.flags.see_infra * 10); X X (void) fprintf(file1, "(Miscellaneous Abilities)\n\n"); X (void) fprintf(file1, " Fighting : %-10s", likert(xbth, 12)); X (void) fprintf(file1, " Stealth : %-10s", likert(xstl, 1)); X (void) fprintf(file1, " Perception : %s\n", likert(xfos, 3)); X (void) fprintf(file1, " Bows/Throw : %-10s", likert(xbthb, 12)); X (void) fprintf(file1, " Disarming : %-10s", likert(xdis, 8)); X (void) fprintf(file1, " Searching : %s\n", likert(xsrh, 6)); X (void) fprintf(file1, " Saving Throw: %-10s", likert(xsave, 6)); X (void) fprintf(file1, " Magic Device: %-10s", likert(xdev, 6)); X (void) fprintf(file1, " Infra-Vision: %s\n\n", xinfra); X /* Write out the character's history */ X (void) fprintf(file1, "Character Background\n"); X for (i = 0; i < 4; i++) X`09(void) fprintf(file1, " %s\n", py.misc.history`5Bi`5D); X /* Write out the equipment list.`09 */ X j = 0; X (void) fprintf(file1, "\n `5BCharacter's Equipment List`5D\n\n"); X if (equip_ctr == 0) X`09(void) fprintf(file1, " Character has no equipment in use.\n"); X else X`09for (i = INVEN_WIELD; i < INVEN_ARRAY_SIZE; i++) X`09 `7B X`09 i_ptr = &inventory`5Bi`5D; X`09 if (i_ptr->tval != TV_NOTHING) X`09 `7B X`09`09switch (i) X`09`09 `7B X`09`09 case INVEN_WIELD:`09p = "You are wielding";`09break; X`09`09 case INVEN_HEAD:`09p = "Worn on head";`09break; X`09`09 case INVEN_NECK:`09p = "Worn around neck";`09break; X`09`09 case INVEN_BODY:`09p = "Worn on body";`09break; X`09`09 case INVEN_ARM:`09p = "Worn on shield arm";break; X`09`09 case INVEN_HANDS:`09p = "Worn on hands";`09break; X`09`09 case INVEN_RIGHT:`09p = "Right ring finger";break; X`09`09 case INVEN_LEFT:`09p = "Left ring finger";break; X`09`09 case INVEN_FEET:`09p = "Worn on feet";`09break; X`09`09 case INVEN_OUTER:`09p = "Worn about body";`09break; X`09`09 case INVEN_LIGHT:`09p = "Light source is";`09break; X`09`09 case INVEN_AUX:`09p = "Secondary weapon";`09break; X`09`09 default: p = "*Unknown value*"; break; X`09`09 `7D X`09`09objdes(prt2, &inventory`5Bi`5D, TRUE); X`09`09(void) fprintf(file1, " %c) %-19s: %s\n", j+'a', p, prt2); X`09`09j++; X`09 `7D X`09 `7D X X /* Write out the character's inventory.`09 */ X#ifdef MAC X (void) fprintf(file1, "\n\n"); X#else X (void) fprintf(file1, "%c\n\n", CTRL('L')); X#endif X (void) fprintf(file1, " `5BGeneral Inventory List`5D\n\n"); X if (inven_ctr == 0) X`09(void) fprintf(file1, " Character has no objects in inventory.\n"); X else X`09`7B X`09 for (i = 0; i < inven_ctr; i++) X`09 `7B X`09 objdes(prt2, &inventory`5Bi`5D, TRUE); X`09 (void) fprintf(file1, "%c) %s\n", i+'a', prt2); X`09 `7D X`09`7D X#ifndef MAC X (void) fprintf(file1, "%c", CTRL('L')); X#endif X (void) fclose(file1); X#ifdef MAC X setfileinfo(filename1, vrefnum, INFO_FTYPE); X macendwait (); X#endif X prt("Completed.", 0, 0); X return TRUE; X `7D X else X `7B X if (fd >= 0) X`09(void) close (fd); X (void) sprintf (out_val, "Can't open file %s:", filename1); X msg_print(out_val); X return FALSE; X `7D X`7D $ CALL UNPACK FILES.C;1 488052767 $ create 'f' X/* source/generate.c: initialize/create a dungeon or town level X X Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke X +-+-+-+-+-+-+-+- END OF PART 19 +-+-+-+-+-+-+-+-