[This verbose description is being committed with role.c only;
the dozen or so other affected files will use a much shorter one.]
Executive summary: using Unix (or VMS) with tty, start up via
nethack -u player
and follow the prompts. Seeing this in action will be much clearer than
any description. It might work as is with Mac and Be too, where you
don't need to bother with "-u player" to get "who are you?". Only half
of it will work with other ports using tty so far, and it does nothing
for ports which don't use tty.
I started out attempting to add an option which would let you defer
picking your character name until after you'd picked role and race and
so forth (so that you could let the game pick randomly, then use your own
role- or race- or gender-specific name for the result) but threw my ends
up in frustration. Instead, this allows you to specify race and/or gender
and/or alignment before role when interactively choosing them (ie, after
giving 'n' to the "shall I pick for you?" prompt), by adding extra menu
entries to the role menu, with similar entries in the other menus so you
can actually bounce back and forth picking whichever of the four role/race/
gender/alignment attributes in any order. (<Someone> has a patch to
control the order of the four prompts via option setting, but it's not as
versatile as this ended up being.)
That works pretty well, so I added a confirmation prompt when you're
done (which can be bypassed by picking new 'a' instead 'y' at the "shall
I pick your character's role [ynaq]?" prompt). And I introduced a chance
to rename the character during that confirmation, with a quite modest
amount of spaghetti being added into main() to support it. Picking a new
name which matches a save file will result restoring the saved game just
as if you'd used that name from the start. [One thing which hasn't been
resolved yet is whether anything special needs to be done when changing
name to or from "wizard", particulary for ports which allow/reject wizard
mode access based on character name rather than user name.]
Right now, renaming is only available if you've gone through the
"who are you?" prompt (thereby demonstrating that you're allowed to use
an arbitrary name), since some multi-user sites may be using scripting to
force the character name for players who share an account. There should
be a new SYSCF option to let sites explicitly allow renaming, but this
had already grown pretty big so that is deferred. (And I haven't yet
implemented sysconf for VMS so wouldn't have been able to test it....)
Unfortunately, role selection has been implemented in the interface
code instead of in the core--a big mistake, in my opinion, even if some
interfaces can give easy point and click control to the player--so this
has only been implemented for tty.
Also, renaming needs to manipulate lock files in the case where the
file name is based on the character name. I moved the file name part
into getlock() itself, removing some clutter from main(). But getlock()
handling in pcmain.c is something I won't touch with a pole of any length.
It needs to be cleaned up before the rename capability can be activated
for ports that use that main(). The rest of the rename support there is
present but bracketed by #if 0.
Lastly, the handling of generic character names like "player" and
"games" has been moved into plnamesuffix(), again to eliminate a bit of
clutter from main(). And plnamesuffix()'s potential for uncontrolled
recursion (if player keeps giving -Role instead of Name to askname()) has
been replaced by iteration. It could still go on forever if the player
is persistent or askname() goes haywire, but I don't think we really care.
The interface-specific changes are limited to player_selection() and
askname(), so folks can add this to other interfaces as desired without
flailing all over the place. But the changes to tty's player_selection()
were quite extensive. (Fortunately, some of it is just fixing up the
indentation to match changes in block nesting.) Like tty, win32 and gem
use build_plselection_prompt(). It now returns a string ending in "[ynaq]"
rather than just "[ynq]" so if they don't bother with these changes, they
should either fix that up or at least accept 'a' as a synonym for 'y'
during the initial "shall I pick your character's role?" prompt.