// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
subq $0x48, %rsp
movq %rsi, %rax
movq %rdi, %rbx
leaq -0x28(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
leaq -0x38(%rbp), %rsi
movq %rax, %rdi
callq 0x33c0
cmpq $0x0, -0x30(%rbp)
je 0xa4d3
leaq -0x38(%rbp), %rdi
callq 0x48f8
testq %rax, %rax
jne 0xa4ef
leaq 0xa30c(%rip), %rsi      # 0x14720
leaq -0x38(%rbp), %rdi
xorl %edx, %edx
callq 0x32c0
cmpq $-0x1, %rax
jne 0xa536
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x45b7
leaq 0x3344(%rip), %rsi      # 0xd781
leaq -0x58(%rbp), %r14
movq %r14, %rdi
callq 0xaee5
movl %eax, %r15d
movq %r14, %rdi
callq 0x35c8
testb %r15b, %r15b
je 0xa475
movl $0x2, 0x68(%rbx)
addq $0x70, %rbx
leaq 0x331a(%rip), %rsi      # 0xd785
movq %rbx, %rdi
callq 0x3580
jmp 0xa4bf
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x45f8
leaq 0x90(%rbx), %rdi
movq %r14, %rsi
callq 0x33b0
movq %r14, %rdi
callq 0x35c8
movq %rbx, %rdi
callq 0x4c30
movl $0x1, 0x68(%rbx)
leaq 0x70(%rbx), %rdi
leaq 0x3303(%rip), %rsi      # 0xd7b6
callq 0x3580
andl $0x0, 0xd0(%rbx)
leaq -0x38(%rbp), %rdi
callq 0x35c8
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x31b0
movq %rax, %rbx
leaq 0x323e(%rip), %rsi      # 0xd723
movq %rax, %rdi
callq 0x3140
jmp 0xa550
pushq $0x10
popq %rdi
callq 0x31b0
movq %rax, %rbx
leaq 0x3238(%rip), %rdx      # 0xd739
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x9169
movb $0x1, %r15b
leaq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x3490
xorl %r15d, %r15d
movq 0x9ac9(%rip), %rsi      # 0x13ff0
movq 0x9a8a(%rip), %rdx      # 0x13fb8
movq %rbx, %rdi
callq 0x34e0
pushq $0x10
popq %rdi
callq 0x31b0
movq %rax, %rbx
leaq 0x3208(%rip), %rsi      # 0xd750
movq %rax, %rdi
callq 0x3140
movq 0x9a99(%rip), %rsi      # 0x13ff0
movq 0x9a5a(%rip), %rdx      # 0x13fb8
movq %rbx, %rdi
callq 0x34e0
jmp 0xa58e
jmp 0xa57f
movq %rax, %r14
leaq -0x58(%rbp), %rdi
callq 0x35c8
testb %r15b, %r15b
jne 0xa582
jmp 0xa591
jmp 0xa57f
movq %rax, %r14
movq %rbx, %rdi
callq 0x3270
jmp 0xa591
jmp 0xa58e
movq %rax, %r14
leaq -0x38(%rbp), %rdi
callq 0x35c8
movq %r14, %rdi
callq 0x3500