Gets a name from the user, making sure it's unique Returns true if got new name, false if cancelled. the data in buf not changed if cancel is pressed
| 1578 | // Returns true if got new name, false if cancelled. |
| 1579 | // the data in buf not changed if cancel is pressed |
| 1580 | bool InputWeaponName(char *buf, int len, char *title, char *prompt, CWnd *wnd) { |
| 1581 | char *tempbuf = (char *)mem_malloc(len); |
| 1582 | |
| 1583 | strcpy(tempbuf, buf); |
| 1584 | |
| 1585 | try_again: |
| 1586 | |
| 1587 | if (!InputString(tempbuf, len, title, prompt, wnd)) { |
| 1588 | mem_free(tempbuf); |
| 1589 | return 0; |
| 1590 | } |
| 1591 | |
| 1592 | if (FindWeaponName(tempbuf) != -1) { |
| 1593 | OutrageMessageBox("The name you specified is already in use. Enter another name."); |
| 1594 | goto try_again; |
| 1595 | } |
| 1596 | |
| 1597 | strcpy(buf, tempbuf); |
| 1598 | mem_free(tempbuf); |
| 1599 | |
| 1600 | return 1; |
| 1601 | } |
| 1602 | |
| 1603 | void CWorldWeaponsDialog::OnChangeName() { |
| 1604 | char name[PAGENAME_LEN]; |
no test coverage detected