Legend:
- Unmodified
- Added
- Removed
-
trunk/src/birth.c
r1422 r1433 1006 1006 int points_spent[A_MAX]; 1007 1007 int points_left; 1008 char *buf; 1008 1009 1009 1010 bool rolled_stats = FALSE; … … 1039 1040 reset_stats(stats, points_spent, &points_left); 1040 1041 do_birth_reset(quickstart_allowed, &quickstart_prev); 1042 1043 /* Handle incrementing name suffix */ 1044 if (op_ptr->name_suffix) 1045 { 1046 ++op_ptr->name_suffix; 1047 buf = find_roman_suffix_start(op_ptr->full_name); 1048 if (buf) 1049 { 1050 romanify(op_ptr->name_suffix, buf, 1051 sizeof(op_ptr->full_name) - (buf - (char *)&op_ptr->full_name)); 1052 } 1053 } 1041 1054 1042 1055 /* We're ready to start the interactive birth process. */ -
trunk/src/externs.h
r1431 r1433 586 586 extern void text_to_ascii(char *buf, size_t len, cptr str); 587 587 extern void ascii_to_text(char *buf, size_t len, cptr str); 588 extern void romanify(int in, char *buf, size_t len); 589 extern char *find_roman_suffix_start(cptr buf); 588 590 extern int macro_find_exact(cptr pat); 589 591 extern errr macro_add(cptr pat, cptr act); -
trunk/src/files.c
r1417 r1433 1614 1614 * when a new character is created, and then when the character is done 1615 1615 * being created, they call this function to choose a new savefile name. 1616 * 1617 * This also now handles the turning on and off of the automatic 1618 * sequential numbering of character names with Roman numerals. 1616 1619 */ 1617 1620 void process_player_name(bool sf) … … 1619 1622 int i; 1620 1623 1624 /* If the selected name ends in " I", i.e. "the first", then we're using 1625 * Roman numerals style suffices, so set the savefile flag. 1626 * Equally if there's no roman numerals at all, switch off suffices.*/ 1627 char *buf = find_roman_suffix_start(op_ptr->full_name); 1628 if (!buf) 1629 { 1630 op_ptr->name_suffix = 0; 1631 } 1632 else 1633 { 1634 if (buf[0] == 'I' && buf[1] == '\0') 1635 { 1636 op_ptr->name_suffix = 1; 1637 } 1638 } 1621 1639 1622 1640 /* Process the player name */ -
trunk/src/load-old.c
r1377 r1433 782 782 sp_ptr = &sex_info[p_ptr->psex]; 783 783 784 strip_bytes(1); 784 /* Numeric name suffix */ 785 rd_byte(&op_ptr->name_suffix); 785 786 786 787 /* Special Race/Class info */ -
trunk/src/load.c
r1377 r1433 664 664 sp_ptr = &sex_info[p_ptr->psex]; 665 665 666 strip_bytes(1); 666 /* Numeric name suffix */ 667 rd_byte(&op_ptr->name_suffix); 667 668 668 669 /* Special Race/Class info */ -
trunk/src/player/types.h
r1405 r1433 400 400 401 401 byte delay_factor; /* Delay factor (0 to 9) */ 402 403 byte name_suffix; /* numeric suffix for player name */ 402 404 } player_other; 403 405 -
trunk/src/save.c
r1346 r1433 326 326 wr_byte(p_ptr->pclass); 327 327 wr_byte(p_ptr->psex); 328 wr_byte( 0); /* oops */328 wr_byte(op_ptr->name_suffix); 329 329 330 330 wr_byte(p_ptr->hitdie); -
trunk/src/util.c
r1376 r1433 469 469 } 470 470 471 471 static char *roman_order[] = {"", "a", "aa", "aaa", "ab", "b", "ba", "baa", "baaa", "ac"}; 472 473 /* 474 * Fill in buf (up to size len) with the roman digits corresponding to the 475 * input digit, based on the radix string specified. This will be the 476 * characters of the current decimal position, e.g. IVX for digits, XLC for 477 * tens, CDM for hundreds. 478 * 479 * Returns number of chars put in the string. 480 */ 481 static size_t roman_digits(char *buf, size_t len, int digit, char *radix) 482 { 483 char *template = roman_order[digit]; 484 size_t radix_len = strlen(radix); 485 size_t added = 0; 486 487 while (*template && len) { 488 int offset = *template - 'a'; 489 if (offset < radix_len) 490 { 491 *buf = radix[offset]; 492 } 493 else 494 { 495 *buf = '?'; 496 } 497 ++buf; 498 ++template; 499 ++added; 500 --len; 501 } 502 return added; 503 } 504 505 /* 506 * Convert a number into a string in roman numerals 507 * Ignores any value over a thousand, on the grounds that it's hard to 508 * print characters with bars on top in ASCII... 509 */ 510 void romanify(int in, char *buf, size_t len) 511 { 512 int hundreds = (in / 100) % 10; 513 int tens = (in / 10) % 10; 514 int ones = in % 10; 515 size_t ret; 516 517 if (hundreds) 518 { 519 ret = roman_digits(buf, len, hundreds, "CDM"); 520 buf += ret; 521 len -= ret; 522 } 523 if (tens) 524 { 525 ret = roman_digits(buf, len, tens, "XLC"); 526 buf += ret; 527 len -= ret; 528 } 529 if (ones) 530 { 531 ret = roman_digits(buf, len, ones, "IVX"); 532 buf += ret; 533 len -= ret; 534 } 535 if (len) 536 { 537 *buf = '\0'; 538 } 539 } 540 541 /* 542 * Find the start of a possible Roman numerals suffix by going back from the 543 * end of the string to a space, then checking that all the remaining chars 544 * are valid Roman numerals. 545 * 546 * Return the start position, or NULL if there isn't a valid suffix. 547 */ 548 char *find_roman_suffix_start(cptr buf) 549 { 550 const char *start = strrchr(buf, ' '); 551 const char *p; 552 553 if (start) 554 { 555 start++; 556 p = start; 557 while (*p) 558 { 559 if (*p != 'I' && *p != 'V' && *p != 'X' && *p != 'L' && 560 *p != 'C' && *p != 'D' && *p != 'M') 561 { 562 start = NULL; 563 break; 564 } 565 ++p; 566 } 567 } 568 return (char *)start; 569 } 472 570 473 571 /*
