// File: /workspace/github_cpp_makefile_star2_O1/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 0xc855
leaq -0x40(%rbp), %rdi
callq 0x527c
testq %rax, %rax
jne 0xc873
movq 0x9fda(%rip), %rsi      # 0x16720
movq 0x9fdb(%rip), %rcx      # 0x16728
leaq -0x40(%rbp), %rdi
xorl %edx, %edx
callq 0x34e0
cmpq $-0x1, %rax
jne 0xc8bc
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4e39
leaq 0x401d(%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 0xc79d
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32f0
testl %r14d, %r14d
je 0xc80d
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4e91
leaq 0x90(%rbx), %rdi
leaq -0x60(%rbp), %r14
movq %r14, %rsi
callq 0x33a0
movq (%r14), %rdi
cmpq %r15, %rdi
je 0xc7d6
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x56d6
movl $0x1, 0x68(%rbx)
leaq 0x70(%rbx), %rdi
movq 0x78(%rbx), %rdx
leaq 0x3fd4(%rip), %rcx      # 0x107c8
movl $0x18, %r8d
xorl %esi, %esi
callq 0x3460
movl $0x0, 0xd0(%rbx)
jmp 0xc833
movl $0x2, 0x68(%rbx)
movq 0x78(%rbx), %rdx
addq $0x70, %rbx
leaq 0x3f74(%rip), %rcx      # 0x10797
movl $0x30, %r8d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3460
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xc848
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 0x3ecc(%rip), %rsi      # 0x10735
movq %rax, %rdi
callq 0x3130
jmp 0xc8d8
movl $0x10, %edi
callq 0x3180
movq %rax, %r14
leaq 0x3ec4(%rip), %rdx      # 0x1074b
leaq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xd62b
movb $0x1, %r15b
leaq -0x60(%rbp), %rsi
movq %r14, %rdi
callq 0x3490
xorl %r15d, %r15d
movq 0x9743(%rip), %rsi      # 0x15ff0
movq 0x96fc(%rip), %rdx      # 0x15fb0
movq %r14, %rdi
callq 0x3500
movl $0x10, %edi
callq 0x3180
movq %rax, %r14
leaq 0x3e92(%rip), %rsi      # 0x10762
movq %rax, %rdi
callq 0x3130
movq 0x9711(%rip), %rsi      # 0x15ff0
movq 0x96ca(%rip), %rdx      # 0x15fb0
movq %r14, %rdi
callq 0x3500
jmp 0xc91b
movq %rax, %rbx
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xc914
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32f0
jmp 0xc914
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
jne 0xc91e
jmp 0xc92f
movq %rax, %rbx
movq %r14, %rdi
callq 0x3250
jmp 0xc92f
jmp 0xc92c
jmp 0xc92c
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0xc944
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3530