// File: /workspace/github_cpp_makefile_star2_O3/nickgammon[P]tinymudserver/states.cpp
// Function: ProcessPlayerName(tPlayer*, std::istream&)
void ProcessPlayerName (tPlayer * p, istream & sArgs)
{
  string playername;
  sArgs >> playername;

  /* name can't be blank */
  if (playername.empty ())
    throw runtime_error ("Name cannot be blank.");
  
  /* don't allow two of the same name */
  if (FindPlayer (playername))
    throw runtime_error (playername + " is already connected.");

  if (playername.find_first_not_of (valid_player_name) != string::npos)
    throw runtime_error ("That player name contains disallowed characters.");
        
  if (tolower (playername) == "new")
    {
    p->connstate = eAwaitingNewName;
    p->prompt = "Please choose a name for your new character ... ";
    }   // end of new player
  else
    {   // old player
  
    p->playername = tocapitals (playername);
    p->Load ();   // load player so we know the password etc.
    
    p->connstate = eAwaitingPassword;
    p->prompt = "Enter your password ... ";
    p->badPasswordCount = 0;
    } // end of old player
        
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %rax
movq %rdi, %rbx
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
leaq -0x40(%rbp), %rsi
movq %rax, %rdi
callq 0x33b0
cmpq $0x0, -0x38(%rbp)
je 0xc7e5
leaq -0x40(%rbp), %rdi
callq 0x5260
testq %rax, %rax
jne 0xc803
movq 0xa04a(%rip), %rsi      # 0x16720
movq 0xa04b(%rip), %rcx      # 0x16728
leaq -0x40(%rbp), %rdi
xorl %edx, %edx
callq 0x34e0
cmpq $-0x1, %rax
jne 0xc84c
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4e3b
leaq 0x408d(%rip), %rsi      # 0x10793
leaq -0x60(%rbp), %r15
movq %r15, %rdi
callq 0x30e0
movl %eax, %r14d
movq (%r15), %rdi
leaq -0x50(%rbp), %r15
cmpq %r15, %rdi
je 0xc72d
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32f0
testl %r14d, %r14d
je 0xc79d
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4e93
leaq 0x90(%rbx), %rdi
leaq -0x60(%rbp), %r14
movq %r14, %rsi
callq 0x33a0
movq (%r14), %rdi
cmpq %r15, %rdi
je 0xc766
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x569a
movl $0x1, 0x68(%rbx)
leaq 0x70(%rbx), %rdi
movq 0x78(%rbx), %rdx
leaq 0x4044(%rip), %rcx      # 0x107c8
movl $0x18, %r8d
xorl %esi, %esi
callq 0x3460
movl $0x0, 0xd0(%rbx)
jmp 0xc7c3
movl $0x2, 0x68(%rbx)
movq 0x78(%rbx), %rdx
addq $0x70, %rbx
leaq 0x3fe4(%rip), %rcx      # 0x10797
movl $0x30, %r8d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3460
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xc7d8
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x32f0
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x3180
movq %rax, %r14
leaq 0x3f3c(%rip), %rsi      # 0x10735
movq %rax, %rdi
callq 0x3130
jmp 0xc868
movl $0x10, %edi
callq 0x3180
movq %rax, %r14
leaq 0x3f34(%rip), %rdx      # 0x1074b
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xd5b5
movb $0x1, %r15b
leaq -0x60(%rbp), %rsi
movq %r14, %rdi
callq 0x3490
xorl %r15d, %r15d
movq 0x97b3(%rip), %rsi      # 0x15ff0
movq 0x976c(%rip), %rdx      # 0x15fb0
movq %r14, %rdi
callq 0x3500
movl $0x10, %edi
callq 0x3180
movq %rax, %r14
leaq 0x3f02(%rip), %rsi      # 0x10762
movq %rax, %rdi
callq 0x3130
movq 0x9781(%rip), %rsi      # 0x15ff0
movq 0x973a(%rip), %rdx      # 0x15fb0
movq %r14, %rdi
callq 0x3500
jmp 0xc8a5
movq %rax, %rbx
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc89c
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32f0
testb %r15b, %r15b
jne 0xc8a8
jmp 0xc8b9
jmp 0xc8a5
movq %rax, %rbx
movq %r14, %rdi
callq 0x3250
jmp 0xc8b9
jmp 0xc8b6
jmp 0xc8b6
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xc8ce
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3530