Changeset 461
- Timestamp:
- 08/07/07 16:50:02 (1 year ago)
- Files:
-
- trunk/src/externs.h (modified) (1 diff)
- trunk/src/util.c (modified) (40 diffs)
- trunk/src/z-rand.c (modified) (1 diff)
- trunk/src/z-rand.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/externs.h
r455 r461 671 671 extern void pause_line(int row); 672 672 extern void request_command(void); 673 extern int damroll(int num, int sides);674 extern int maxroll(int num, int sides);675 673 extern bool is_a_vowel(int ch); 676 674 extern int color_char_to_attr(char c); trunk/src/util.c
r460 r461 22 22 } 23 23 24 25 26 24 /* 27 25 * Convert a hexidecimal-digit into a decimal … … 81 79 82 80 /* Shift key might be going to change keycode */ 83 if ( 'S' == macro_modifier_chr[i])81 if (macro_modifier_chr[i] == 'S') 84 82 shiftstatus = 1; 85 83 } … … 127 125 { 128 126 char ch = macro_template[i]; 129 int j; 130 131 switch(ch) 132 { 133 case '&': 127 128 switch (ch) 129 { 134 130 /* Modifier key character */ 135 for (j = 0; macro_modifier_chr[j]; j++) 136 { 137 if (mod_status[j]) 138 strnfcat(buf, max, ¤t_len, "%c", macro_modifier_chr[j]); 139 } 140 break; 141 case '#': 131 case '&': 132 size_t j; 133 for (j = 0; macro_modifier_chr[j]; j++) 134 { 135 if (mod_status[j]) 136 strnfcat(buf, max, ¤t_len, "%c", macro_modifier_chr[j]); 137 } 138 break; 139 142 140 /* Key code */ 143 strnfcat(buf, max, ¤t_len, "%s", key_code); 144 break; 145 default: 141 case '#': 142 strnfcat(buf, max, ¤t_len, "%s", key_code); 143 break; 144 146 145 /* Fixed string */ 147 strnfcat(buf, max, ¤t_len, "%c", ch); 148 break; 146 default: 147 strnfcat(buf, max, ¤t_len, "%c", ch); 148 break; 149 149 } 150 150 } … … 180 180 if (*str == '\\') 181 181 { 182 /* Skip the backslash */183 182 str++; 184 185 /* Paranoia */ 186 if (!(*str)) break; 187 188 /* Macro Trigger */ 189 if (*str == '[') 183 if (*str == '\0') break; 184 185 switch (*str) 190 186 { 191 /* Terminate before appending the trigger */ 192 *s = '\0'; 193 194 s += trigger_text_to_ascii(buf, len, &str); 195 } 196 197 /* Hack -- simple way to specify Escape */ 198 else if (*str == 'e') 199 { 200 *s++ = ESCAPE; 201 } 202 203 /* Hack -- simple way to specify "space" */ 204 else if (*str == 's') 205 { 206 *s++ = ' '; 207 } 208 209 /* Backspace */ 210 else if (*str == 'b') 211 { 212 *s++ = '\b'; 213 } 214 215 /* Newline */ 216 else if (*str == 'n') 217 { 218 *s++ = '\n'; 219 } 220 221 /* Return */ 222 else if (*str == 'r') 223 { 224 *s++ = '\r'; 225 } 226 227 /* Tab */ 228 else if (*str == 't') 229 { 230 *s++ = '\t'; 231 } 232 233 /* Bell */ 234 else if (*str == 'a') 235 { 236 *s++ = '\a'; 237 } 238 239 /* Actual "backslash" */ 240 else if (*str == '\\') 241 { 242 *s++ = '\\'; 243 } 244 245 /* Hack -- Actual "caret" */ 246 else if (*str == '^') 247 { 248 *s++ = '^'; 249 } 250 251 /* Hack -- Hex-mode */ 252 else if (*str == 'x') 253 { 254 if (isxdigit((unsigned char)(*(str + 1))) && 255 isxdigit((unsigned char)(*(str + 2)))) 187 /* Macro trigger */ 188 case '[': 256 189 { 257 *s = 16 * dehex(*++str); 258 *s++ += dehex(*++str); 190 /* Terminate before appending the trigger */ 191 *s = '\0'; 192 s += trigger_text_to_ascii(buf, len, &str); 193 break; 259 194 } 260 else 195 196 /* Hex-mode */ 197 case 'x': 261 198 { 262 /* HACK - Invalid hex number */ 263 *s++ = '?'; 199 if (isxdigit((unsigned char)(*(str + 1))) && 200 isxdigit((unsigned char)(*(str + 2)))) 201 { 202 *s = 16 * dehex(*++str); 203 *s++ += dehex(*++str); 204 } 205 else 206 { 207 /* HACK - Invalid hex number */ 208 *s++ = '?'; 209 } 210 break; 264 211 } 265 } 266 267 /* Oops */ 268 else 269 { 270 *s = *str; 212 213 case 'e': 214 *s++ = ESCAPE; 215 break; 216 case 's': 217 *s++ = ' '; 218 break; 219 case 'b': 220 *s++ = '\b'; 221 break; 222 case 'n': 223 *s++ = '\n'; 224 break; 225 case 'r': 226 *s++ = '\r'; 227 break; 228 case 't': 229 *s++ = '\t'; 230 break; 231 case 'a': 232 *s++ = '\a'; 233 break; 234 case '\\': 235 *s++ = '\\'; 236 break; 237 case '^': 238 *s++ = '^'; 239 break; 240 241 default: 242 *s = *str; 243 break; 271 244 } 272 245 … … 279 252 { 280 253 str++; 281 282 if (*str) 283 { 284 *s++ = KTRL(*str); 285 str++; 286 } 254 if (*str == '\0') break; 255 256 *s++ = KTRL(*str); 257 str++; 287 258 } 288 259 … … 321 292 for (i = 0; macro_template[i]; i++) 322 293 { 323 int j;324 294 char ch = macro_template[i]; 325 295 326 switch(ch) 327 { 328 case '&': 296 switch (ch) 297 { 329 298 /* Read modifier */ 330 while ((tmp = strchr(macro_modifier_chr, *str))) 331 { 332 j = (int)(tmp - macro_modifier_chr); 333 strnfcat(buf, max, ¤t_len, "%s", macro_modifier_name[j]); 299 case '&': 300 size_t j; 301 while ((tmp = strchr(macro_modifier_chr, *str))) 302 { 303 j = tmp - macro_modifier_chr; 304 strnfcat(buf, max, ¤t_len, "%s", macro_modifier_name[j]); 305 str++; 306 } 307 break; 308 309 /* Read key code */ 310 case '#': 311 size_t j; 312 for (j = 0; *str && (*str != '\r') && (j < sizeof(key_code) - 1); j++) 313 key_code[j] = *str++; 314 key_code[j] = '\0'; 315 break; 316 317 /* Skip fixed strings */ 318 default: 319 if (ch != *str) return 0; 334 320 str++; 335 }336 break;337 case '#':338 /* Read key code */339 for (j = 0; *str && (*str != '\r') && (j < (int)sizeof(key_code) - 1); j++)340 key_code[j] = *str++;341 key_code[j] = '\0';342 break;343 default:344 /* Skip fixed strings */345 if (ch != *str) return 0;346 str++;347 321 } 348 322 } … … 502 476 /* Nothing possible */ 503 477 if (!macro__use[(byte)(pat[0])]) 504 { 505 return (-1); 506 } 478 return -1; 507 479 508 480 /* Scan the macros */ 509 481 for (i = 0; i < macro__num; ++i) 510 482 { 511 /* Skip macros which do not match the pattern */ 512 if (!streq(macro__pat[i], pat)) continue; 513 514 /* Found one */ 515 return (i); 483 if (streq(macro__pat[i], pat)) 484 return i; 516 485 } 517 486 518 487 /* No matches */ 519 return (-1);488 return -1; 520 489 } 521 490 … … 530 499 /* Nothing possible */ 531 500 if (!macro__use[(byte)(pat[0])]) 532 { 533 return (-1); 534 } 501 return -1; 535 502 536 503 /* Scan the macros */ 537 504 for (i = 0; i < macro__num; ++i) 538 505 { 539 /* Skip macros which do not contain the pattern */ 540 if (!prefix(macro__pat[i], pat)) continue; 541 542 /* Found one */ 543 return (i); 506 if (prefix(macro__pat[i], pat)) 507 return i; 544 508 } 545 509 546 510 /* Nothing */ 547 return (-1); 548 } 549 511 return -1; 512 } 550 513 551 514 … … 559 522 /* Nothing possible */ 560 523 if (!macro__use[(byte)(pat[0])]) 561 { 562 return (-1); 563 } 524 return -1; 564 525 565 526 /* Scan the macros */ 566 527 for (i = 0; i < macro__num; ++i) 567 528 { 568 /* Skip macros which do not contain the pattern */ 569 if (!prefix(macro__pat[i], pat)) continue; 570 571 /* Skip macros which exactly match the pattern XXX XXX */ 572 if (streq(macro__pat[i], pat)) continue; 573 574 /* Found one */ 575 return (i); 529 if (prefix(macro__pat[i], pat) && !streq(macro__pat[i], pat)) 530 return i; 576 531 } 577 532 578 533 /* Nothing */ 579 return (-1); 580 } 534 return -1; 535 } 536 581 537 582 538 … … 590 546 /* Nothing possible */ 591 547 if (!macro__use[(byte)(pat[0])]) 592 { 593 return (-1); 594 } 548 return -1; 595 549 596 550 /* Scan the macros */ … … 612 566 613 567 /* Result */ 614 return (n);568 return n; 615 569 } 616 570 … … 634 588 int n; 635 589 636 637 /* Paranoia -- require data */638 590 if (!pat || !act) return (-1); 639 591 … … 645 597 if (n >= 0) 646 598 { 647 /* Free the old macro action */648 599 string_free(macro__act[n]); 649 600 } … … 654 605 /* Get a new index */ 655 606 n = macro__num++; 656 657 /* Boundary check */658 607 if (macro__num >= MACRO_MAX) quit("Too many macros!"); 659 608 … … 695 644 errr macro_free(void) 696 645 { 697 int i, j; 646 int i; 647 size_t j; 698 648 699 649 /* Free the macros */ … … 710 660 for (i = 0; i < KEYMAP_MODES; ++i) 711 661 { 712 for (j = 0; j < (int)N_ELEMENTS(keymap_act[i]); ++j)662 for (j = 0; j < N_ELEMENTS(keymap_act[i]); ++j) 713 663 { 714 664 string_free(keymap_act[i][j]); … … 1298 1248 char anykey(void) 1299 1249 { 1300 event_type ke = EVENT_EMPTY;1250 event_type ke = EVENT_EMPTY; 1301 1251 1302 /* Only accept a keypress or mouse click*/1303 do1304 {1305 ke = inkey_ex();1306 } while (!(ke.type & (EVT_MOUSE|EVT_KBRD)));1307 1308 return ke.key;1252 /* Only accept a keypress or mouse click*/ 1253 do 1254 { 1255 ke = inkey_ex(); 1256 } while ((ke.type != EVT_MOUSE) && (ke.type != EVT_KBRD)); 1257 1258 return ke.key; 1309 1259 } 1310 1260 … … 1314 1264 char inkey(void) 1315 1265 { 1316 event_type ke ;1266 event_type ke = EVENT_EMPTY; 1317 1267 1318 1268 /* Only accept a keypress */ … … 1320 1270 { 1321 1271 ke = inkey_ex(); 1322 } while (!(ke.type & (EVT_KBRD|EVT_ESCAPE))); 1272 } while ((ke.type != EVT_ESCAPE) && (ke.type != EVT_KBRD)); 1273 1323 1274 /* Paranoia */ 1324 if(ke.type == EVT_ESCAPE) ke.key = ESCAPE; 1325 1275 if (ke.type == EVT_ESCAPE) ke.key = ESCAPE; 1326 1276 return ke.key; 1327 1277 } … … 1344 1294 /* Window stuff */ 1345 1295 p_ptr->window |= (PW_MESSAGE); 1346 1347 /* Force window redraw */1348 1296 window_stuff(); 1349 1297 } … … 1364 1312 { 1365 1313 /* No sound */ 1366 if (!use_sound) return; 1367 1368 /* Make a noise */ 1369 if (sound_hook) 1370 sound_hook(val); 1314 if (!use_sound || !sound_hook) return; 1315 1316 sound_hook(val); 1371 1317 } 1372 1318 … … 1385 1331 return FALSE; 1386 1332 } 1333 1387 1334 1388 1335 /* … … 1533 1480 u16b message_type(s16b age) 1534 1481 { 1535 s16b x;1536 1537 1482 /* Paranoia */ 1538 if (!message__type) return (MSG_GENERIC); 1483 if (!message__type) 1484 return MSG_GENERIC; 1539 1485 1540 1486 /* Forgotten messages are generic */ 1541 if ((age < 0) || (age >= message_num())) return (MSG_GENERIC); 1542 1543 /* Get the "logical" index */ 1544 x = message_age2idx(age); 1487 if ((age < 0) || (age >= message_num())) 1488 return MSG_GENERIC; 1545 1489 1546 1490 /* Return the message type */ 1547 return (message__type[ x]);1491 return (message__type[message_age2idx(age)]); 1548 1492 } 1549 1493 … … 1558 1502 if (color == TERM_DARK) color = TERM_WHITE; 1559 1503 1560 return (color);1504 return color; 1561 1505 } 1562 1506 … … 1573 1517 errr message_color_define(u16b type, byte color) 1574 1518 { 1575 /* Ignore illegal types */ 1576 if (type >= MSG_MAX) return (1); 1519 if (type >= MSG_MAX) return 1; 1577 1520 1578 1521 /* Store the color */ 1579 1522 message__color[type] = color; 1580 1581 /* Success */ 1582 return (0); 1523 return 0; 1583 1524 } 1584 1525 … … 1634 1575 /* Increase the message count */ 1635 1576 message__count[x]++; 1636 1637 /* Success */1638 1577 return; 1639 1578 } … … 1822 1761 1823 1762 /* Success */ 1824 return (0);1763 return 0; 1825 1764 } 1826 1765 … … 1839 1778 1840 1779 1841 /* 1842 * XXX XXX XXX Important note about "colors" XXX XXX XXX 1843 * 1844 * The "TERM_*" color definitions list the "composition" of each 1845 * "Angband color" in terms of "quarters" of each of the three color 1846 * components (Red, Green, Blue), for example, TERM_UMBER is defined 1847 * as 2/4 Red, 1/4 Green, 0/4 Blue. 1848 * 1849 * The following info is from "Torbjorn Lindgren" (see "main-xaw.c"). 1850 * 1851 * These values are NOT gamma-corrected. On most machines (with the 1852 * Macintosh being an important exception), you must "gamma-correct" 1853 * the given values, that is, "correct for the intrinsic non-linearity 1854 * of the phosphor", by converting the given intensity levels based 1855 * on the "gamma" of the target screen, which is usually 1.7 (or 1.5). 1856 * 1857 * The actual formula for conversion is unknown to me at this time, 1858 * but you can use the table below for the most common gamma values. 1859 * 1860 * So, on most machines, simply convert the values based on the "gamma" 1861 * of the target screen, which is usually in the range 1.5 to 1.7, and 1862 * usually is closest to 1.7. The converted value for each of the five 1863 * different "quarter" values is given below: 1864 * 1865 * Given Gamma 1.0 Gamma 1.5 Gamma 1.7 Hex 1.7 1866 * ----- ---- ---- ---- --- 1867 * 0/4 0.00 0.00 0.00 #00 1868 * 1/4 0.25 0.27 0.28 #47 1869 * 2/4 0.50 0.55 0.56 #8f 1870 * 3/4 0.75 0.82 0.84 #d7 1871 * 4/4 1.00 1.00 1.00 #ff 1872 * 1873 * Note that some machines (i.e. most IBM machines) are limited to a 1874 * hard-coded set of colors, and so the information above is useless. 1875 * 1876 * Also, some machines are limited to a pre-determined set of colors, 1877 * for example, the IBM can only display 16 colors, and only 14 of 1878 * those colors resemble colors used by Angband, and then only when 1879 * you ignore the fact that "Slate" and "cyan" are not really matches, 1880 * so on the IBM, we use "orange" for both "Umber", and "Light Umber" 1881 * in addition to the obvious "Orange", since by combining all of the 1882 * "indeterminate" colors into a single color, the rest of the colors 1883 * are left with "meaningful" values. 1884 */ 1780 1885 1781 1886 1782 … … 2655 2551 } 2656 2552 2553 2657 2554 /* 2658 2555 * Get some input at the cursor location. … … 2679 2576 bool askfor_aux(char *buf, size_t len, bool keypress_h(char *, size_t, size_t *, size_t *, char, bool)) 2680 2577 { 2681 2682 2578 int y, x; 2683 2579 … … 2739 2635 return (ch != ESCAPE); 2740 2636 } 2637 2741 2638 2742 2639 /* … … 2911 2808 } 2912 2809 2913 /*2914 * Hack - duplication of get_check prompt to give option of setting destroyed2915 * option to squelch.2916 *2917 * 0 - No2918 * 1 = Yes2919 * 2 = third option2920 *2921 * The "prompt" should take the form "Query? "2922 *2923 * Note that "[y/n/{char}]" is appended to the prompt.2924 */2925 int get_check_other(cptr prompt, char other)2926 {2927 char ch;2928 char buf[80];2929 2930 int result;2931 2932 /* Paranoia XXX XXX XXX */2933 message_flush();2934 2935 /* Hack -- Build a "useful" prompt */2936 strnfmt(buf, 78, "%.70s[y/n/%c] ", prompt, other);2937 2938 /* Prompt for it */2939 prt(buf, 0, 0);2940 2941 /* Get an acceptable answer */2942 while (TRUE)2943 {2944 ch = inkey();2945 if (quick_messages) break;2946 if (ch == ESCAPE) break;2947 if (strchr("YyNn", ch)) break;2948 if (ch == toupper((unsigned char) other)) break;2949 if (ch == tolower((unsigned char) other)) break;2950 bell("Illegal response to question!");2951 }2952 2953 /* Erase the prompt */2954 prt("", 0, 0);2955 2956 2957 /* Yes */2958 if ((ch == 'Y') || (ch == 'y'))2959 result = 1;2960 2961 /* Third option */2962 else if ((ch == toupper((unsigned char) other)) || (ch == tolower((unsigned char) other)))2963 result = 2;2964 2965 /* Default to no */2966 else2967 result = 0;2968 2969 2970 /* Success */2971 return (result);2972 }2973 2974 2810 2975 2811 /* … … 3034 2870 } 3035 2871 2872 3036 2873 bool get_com_ex(cptr prompt, event_type *command) 3037 2874 { … … 3102 2939 { 3103 2940 int i; 2941 int mode; 3104 2942 3105 2943 event_type ke = EVENT_EMPTY; 3106 2944 3107 int mode;3108 3109 2945 cptr act; 3110 2946 3111 2947 3112 /* Roguelike */3113 2948 if (rogue_like_commands) 3114 {3115 2949 mode = KEYMAP_MODE_ROGUE; 3116 }3117 3118 /* Original */3119 2950 else 3120 {3121 2951 mode = KEYMAP_MODE_ORIG; 3122 } 3123 3124 3125 /* No command yet */ 2952 2953 2954 /* Reset command/argument/direction */ 3126 2955 p_ptr->command_cmd = 0; 3127 3128 /* No "argument" yet */3129 2956 p_ptr->command_arg = 0; 3130 3131 /* No "direction" yet */3132 2957 p_ptr->command_dir = 0; 3133 2958 … … 3378 3203 3379 3204 3380 /*3381 * Generates damage for "2d6" style dice rolls3382 */3383 int damroll(int num, int sides)3384 {3385 int i;3386 int sum = 0;3387 3388 3389 /* HACK - prevent undefined behaviour */3390 if (sides <= 0) return (0);3391 3392 for (i = 0; i < num; i++)3393 {3394 sum += rand_die(sides);3395 }3396 3397 return (sum);3398 }3399 3400 3401 3402 3205 3403 3206 /* … … 3413 3216 case 'o': 3414 3217 case 'u': 3218 { 3415 3219 return (TRUE); 3220 } 3416 3221 } 3417 3222 … … 3456 3261 int color_text_to_attr(cptr name) 3457 3262 { 3458 if (my_stricmp(name, "dark") == 0) return (TERM_DARK);3459 if (my_stricmp(name, "white") == 0) return (TERM_WHITE);3460 if (my_stricmp(name, "slate") == 0) return (TERM_SLATE);3461 if (my_stricmp(name, "orange") == 0) return (TERM_ORANGE);3462 if (my_stricmp(name, "red") == 0) return (TERM_RED);3463 if (my_stricmp(name, "green") == 0) return (TERM_GREEN);3464 if (my_stricmp(name, "blue") == 0) return (TERM_BLUE);3465 if (my_stricmp(name, "umber") == 0) return (TERM_UMBER);3466 if (my_stricmp(name, "violet") == 0) return (TERM_VIOLET);3467 if (my_stricmp(name, "yellow") == 0) return (TERM_YELLOW);3468 if (my_stricmp(name, "lightdark") == 0) return (TERM_L_DARK);3469 if (my_stricmp(name, "lightwhite") == 0) return (TERM_L_WHITE);3470 if (my_stricmp(name, "lightred") == 0) return (TERM_L_RED);3471 if (my_stricmp(name, "lightgreen") == 0) return (TERM_L_GREEN);3472 if (my_stricmp(name, "lightblue") == 0) return (TERM_L_BLUE);3473 if (my_stricmp(name, "lightumber") == 0) return (TERM_L_UMBER);3263 if (my_stricmp(name, "dark") == 0) return TERM_DARK; 3264 if (my_stricmp(name, "white") == 0) return TERM_WHITE; 3265 if (my_stricmp(name, "slate") == 0) return TERM_SLATE; 3266 if (my_stricmp(name, "orange") == 0) return TERM_ORANGE; 3267 if (my_stricmp(name, "red") == 0) return TERM_RED; 3268 if (my_stricmp(name, "green") == 0) return TERM_GREEN; 3269 if (my_stricmp(name, "blue") == 0) return TERM_BLUE; 3270 if (my_stricmp(name, "umber") == 0) return TERM_UMBER; 3271 if (my_stricmp(name, "violet") == 0) return TERM_VIOLET; 3272 if (my_stricmp(name, "yellow") == 0) return TERM_YELLOW; 3273 if (my_stricmp(name, "lightdark") == 0) return TERM_L_DARK; 3274 if (my_stricmp(name, "lightwhite") == 0) return TERM_L_WHITE; 3275 if (my_stricmp(name, "lightred") == 0) return TERM_L_RED; 3276 if (my_stricmp(name, "lightgreen") == 0) return TERM_L_GREEN; 3277 if (my_stricmp(name, "lightblue") == 0) return TERM_L_BLUE; 3278 if (my_stricmp(name, "lightumber") == 0) return TERM_L_UMBER; 3474 3279 3475 3280 /* Oops */ 3476 return (-1);3281 return -1; 3477 3282 } 3478 3283 … … 3485 3290 switch (a) 3486 3291 { 3487 case TERM_DARK: return ("Dark");3488 case TERM_WHITE: return ("White");3489 case TERM_SLATE: return ("Slate");3490 case TERM_ORANGE: return ("Orange");3491 case TERM_RED: return ("Red");3492 case TERM_GREEN: return ("Green");3493 case TERM_BLUE: return ("Blue");3494 case TERM_UMBER: return ("Umber");3495 case TERM_L_DARK: return ("L.Dark");3496 case TERM_L_WHITE: return ("L.Slate");3497 case TERM_VIOLET: return ("Violet");3498 case TERM_YELLOW: return ("Yellow");3499 case TERM_L_RED: return ("L.Red");3500 case TERM_L_GREEN: return ("L.Green");3501 case TERM_L_BLUE: return ("L.Blue");3502 case TERM_L_UMBER: return ("L.Umber");3292 case TERM_DARK: return "Dark"; 3293 case TERM_WHITE: return "White"; 3294 case TERM_SLATE: return "Slate"; 3295 case TERM_ORANGE: return "Orange"; 3296 case TERM_RED: return "Red"; 3297 case TERM_GREEN: return "Green"; 3298 case TERM_BLUE: return "Blue"; 3299 case TERM_UMBER: return "Umber"; 3300 case TERM_L_DARK: return "L.Dark"; 3301 case TERM_L_WHITE: return "L.Slate"; 3302 case TERM_VIOLET: return "Violet"; 3303 case TERM_YELLOW: return "Yellow"; 3304 case TERM_L_RED: return "L.Red"; 3305 case TERM_L_GREEN: return "L.Green"; 3306 case TERM_L_BLUE: return "L.Blue"; 3307 case TERM_L_UMBER: return "L.Umber"; 3503 3308 } 3504 3309 3505 3310 /* Oops */ 3506 return ("Icky");3311 return "Icky"; 3507 3312 } 3508 3313 … … 3558 3363 if (repeat__idx) 3559 3364 repeat__cnt = --repeat__idx; 3365 3560 3366 /* Paranoia */ 3561 3367 else … … 3610 3416 3611 3417 #ifdef SUPPORT_GAMMA 3418 3419 /* 3420 * XXX XXX XXX Important note about "colors" XXX XXX XXX 3421 * 3422 * The "TERM_*" color definitions list the "composition" of each 3423 * "Angband color" in terms of "quarters" of each of the three color 3424 * components (Red, Green, Blue), for example, TERM_UMBER is defined 3425 * as 2/4 Red, 1/4 Green, 0/4 Blue. 3426 * 3427 * The following info is from "Torbjorn Lindgren" (see "main-xaw.c"). 3428 * 3429 * These values are NOT gamma-corrected. On most machines (with the 3430 * Macintosh being an important exception), you must "gamma-correct" 3431 * the given values, that is, "correct for the intrinsic non-linearity 3432 * of the phosphor", by converting the given intensity levels based 3433 * on the "gamma" of the target screen, which is usually 1.7 (or 1.5). 3434 * 3435 * The actual formula for conversion is unknown to me at this time, 3436 * but you can use the table below for the most common gamma values. 3437 * 3438 * So, on most machines, simply convert the values based on the "gamma" 3439 * of the target screen, which is usually in the range 1.5 to 1.7, and 3440 * usually is closest to 1.7. The converted value for each of the five 3441 * different "quarter" values is given below: 3442 * 3443 * Given Gamma 1.0 Gamma 1.5 Gamma 1.7 Hex 1.7 3444 * ----- ---- ---- ---- --- 3445 * 0/4 0.00 0.00 0.00 #00 3446 * 1/4 0.25 0.27 0.28 #47 3447 * 2/4 0.50 0.55 0.56 #8f 3448 * 3/4 0.75 0.82 0.84 #d7 3449 * 4/4 1.00 1.00 1.00 #ff 3450 */ 3612 3451 3613 3452 /* Table of gamma values */ trunk/src/z-rand.c
r1 r461 346 346 return (result); 347 347 } 348 349 350 351 /* 352 * Generates damage for "2d6" style dice rolls 353 */ 354 int damroll(int num, int sides) 355 { 356 int i; 357 int sum = 0; 358 359 if (sides <= 0) return (0); 360 361 for (i = 0; i < num; i++) 362 sum += rand_die(sides); 363 364 return (sum); 365 }&nbs
