Changeset 38
- Timestamp:
- 04/09/07 19:33:11 (2 years ago)
- Files:
-
- trunk/src/Makefile.std (modified) (1 diff)
- trunk/src/config.h (modified) (1 diff)
- trunk/src/dungeon.c (modified) (1 diff)
- trunk/src/externs.h (modified) (1 diff)
- trunk/src/files.c (modified) (1 diff)
- trunk/src/main.c (modified) (1 diff)
- trunk/src/store.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/Makefile.std
r27 r38 71 71 # Basic compiler stuff 72 72 CC = gcc 73 CFLAGS = -Wall -O2 - fno-strength-reduce73 CFLAGS = -Wall -O2 -Wno-unused-parameter 74 74 75 75 trunk/src/config.h
r1 r38 364 364 # define ALLOW_USER_SCRIPTS 365 365 #endif /* SET_UID */ 366 367 368 /*369 * OPTION: Check the "time" against "lib/file/hours.txt"370 */371 /* #define CHECK_TIME */372 366 373 367 trunk/src/dungeon.c
r27 r38 617 617 618 618 /*** Check the Time and Load ***/ 619 620 if (!(turn % 1000))621 {622 /* Check time and load */623 if (0 != check_time())624 {625 /* Warning */626 if (closing_flag <= 2)627 {628 /* Disturb */629 disturb(0, 0);630 631 /* Count warnings */632 closing_flag++;633 634 /* Message */635 msg_print("The gates to ANGBAND are closing...");636 msg_print("Please finish up and/or save your game.");637 }638 639 /* Slam the gate */640 else641 {642 /* Message */643 msg_print("The gates to ANGBAND are now closed.");644 645 /* Stop playing */646 p_ptr->playing = FALSE;647 648 /* Leaving */649 p_ptr->leaving = TRUE;650 }651 }652 }653 619 654 620 /* Play an ambient sound at regular intervals. */ trunk/src/externs.h
r36 r38 390 390 extern errr process_pref_file_command(char *buf); 391 391 extern errr process_pref_file(cptr name); 392 extern errr check_time(void);393 extern errr check_time_init(void);394 392 extern void player_flags(u32b *f1, u32b *f2, u32b *f3); 395 393 extern void display_player(int mode); trunk/src/files.c
r24 r38 1078 1078 1079 1079 1080 1081 1082 #ifdef CHECK_TIME1083 1084 /*1085 * Operating hours for ANGBAND (defaults to non-work hours)1086 */1087 static char days[7][29] =1088 {1089 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",1090 "MON:XXXXXXXX.........XXXXXXX",1091 "TUE:XXXXXXXX.........XXXXXXX",1092 "WED:XXXXXXXX.........XXXXXXX",1093 "THU:XXXXXXXX.........XXXXXXX",1094 "FRI:XXXXXXXX.........XXXXXXX",1095 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"1096 };1097 1098 /*1099 * Restict usage (defaults to no restrictions)1100 */1101 static bool check_time_flag = FALSE;1102 1103 #endif /* CHECK_TIME */1104 1105 1106 /*1107 * Handle CHECK_TIME1108 */1109 errr check_time(void)1110 {1111 1112 #ifdef CHECK_TIME1113 1114 time_t c;1115 struct tm *tp;1116 1117 /* No restrictions */1118 if (!check_time_flag) return (0);1119 1120 /* Check for time violation */1121 c = time((time_t *)0);1122 tp = localtime(&c);1123 1124 /* Violation */1125 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);1126 1127 #endif /* CHECK_TIME */1128 1129 /* Success */1130 return (0);1131 }1132 1133 1134 1135 /*1136 * Initialize CHECK_TIME1137 */1138 errr check_time_init(void)1139 {1140 1141 #ifdef CHECK_TIME1142 1143 FILE *fp;1144 1145 char buf[1024];1146 1147 1148 /* Build the filename */1149 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "time.txt");1150 1151 /* Open the file */1152 fp = my_fopen(buf, "r");1153 1154 /* No file, no restrictions */1155 if (!fp) return (0);1156 1157 /* Assume restrictions */1158 check_time_flag = TRUE;1159 1160 /* Parse the file */1161 while (0 == my_fgets(fp, buf, sizeof(buf)))1162 {1163 /* Skip comments and blank lines */1164 if (!buf[0] || (buf[0] == '#')) continue;1165 1166 /* Chop the buffer */1167 buf[sizeof(days[0]) - 1] = '\0';1168 1169 /* Extract the info */1170 if (prefix(buf, "SUN:")) my_strcpy(days[0], buf, sizeof(days[0]));1171 if (prefix(buf, "MON:")) my_strcpy(days[1], buf, sizeof(days[1]));1172 if (prefix(buf, "TUE:")) my_strcpy(days[2], buf, sizeof(days[2]));1173 if (prefix(buf, "WED:")) my_strcpy(days[3], buf, sizeof(days[3]));1174 if (prefix(buf, "THU:")) my_strcpy(days[4], buf, sizeof(days[4]));1175 if (prefix(buf, "FRI:")) my_strcpy(days[5], buf, sizeof(days[5]));1176 if (prefix(buf, "SAT:")) my_strcpy(days[6], buf, sizeof(days[6]));1177 }1178 1179 /* Close it */1180 my_fclose(fp);1181 1182 #endif /* CHECK_TIME */1183 1184 /* Success */1185 return (0);1186 }1187 1080 1188 1081 trunk/src/main.c
r2 r38 401 401 402 402 #ifdef SET_UID 403 404 /* Initialize the "time" checker */405 if (check_time_init() || check_time())406 {407 quit("The gates to Angband are closed (bad time).");408 }409 403 410 404 /* Get the "user name" as a default player name */ trunk/src/store.c
r37 r38 177 177 178 178 /* Get a title for the character */ 179 if ( i == 4)player_name = c_text + cp_ptr->title[(p_ptr->lev - 1) / 5];180 else if (rand_int(2)) player_name = op_ptr->full_name;181 else player_name = "sir";179 if ((i % 2) && rand_int(2)) player_name = c_text + cp_ptr->title[(p_ptr->lev - 1) / 5]; 180 else if (rand_int(2)) player_name = op_ptr->full_name; 181 else player_name = "sir"; 182 182 183 183 /* Balthazar says "Welcome" */ … … 1505 1505 1506 1506 /* Clip the width at a maximum of 104 (enough room for an 80-char item name) */ 1507 if (wid > 104) wid = 10 0;1507 if (wid > 104) wid = 104; 1508 1508 1509 1509 /* Clip the text_out function at two smaller than the screen width */
