// File: nickgammon[P]tinymudserver/states.cpp
// Function: ProcessNewPlayerName(tPlayer*, std::istream&)
void ProcessNewPlayerName (tPlayer * p, istream & sArgs)
{
  string playername;
  sArgs >> playername;
  
  /* name can't be blank */
  if (playername.empty ())
    throw runtime_error ("Name cannot be blank.");

  if (playername.find_first_not_of (valid_player_name) != string::npos)
    throw runtime_error ("That player name contains disallowed characters.");
        
  // check for bad names here (from list in control file)
  if (badnameset.find (playername) != badnameset.end ())
    throw runtime_error ("That name is not permitted.");
    
  ifstream f ((PLAYER_DIR + tocapitals (playername) + PLAYER_EXT).c_str (), ios::in);
  if (f || FindPlayer (playername))  // player file on disk, or playing without saving yet
    throw runtime_error ("That player already exists, please choose another name.");
  
  p->playername = tocapitals (playername);
  
  p->connstate = eAwaitingNewPassword;
  p->prompt = "Choose a password for " + p->playername + " ... ";  
  p->badPasswordCount = 0;
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x320(%rbp)
callq 0x45b0
movq -0x320(%rbp), %rsi
movq -0x10(%rbp), %rdi
callq 0x4550
jmp 0x16915
leaq -0x30(%rbp), %rdi
callq 0x4660
testb $0x1, %al
jne 0x16924
jmp 0x16996
movl $0x10, %edi
callq 0x4250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x328(%rbp)
leaq 0x5de1(%rip), %rsi      # 0x1c723
callq 0x41c0
jmp 0x16949
movq -0x328(%rbp), %rdi
movq 0x12699(%rip), %rsi     # 0x28ff0
movq 0x1265a(%rip), %rdx     # 0x28fb8
callq 0x46a0
jmp 0x16d6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x16d5a
movq -0x328(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x4350
jmp 0x16d5a
leaq -0x30(%rbp), %rdi
leaq 0x12e9f(%rip), %rsi     # 0x29840
xorl %eax, %eax
movl %eax, %edx
callq 0x4390
cmpq $-0x1, %rax
je 0x16a11
movl $0x10, %edi
callq 0x4250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x330(%rbp)
leaq 0x5d82(%rip), %rsi      # 0x1c750
callq 0x41c0
jmp 0x169d5
movq -0x330(%rbp), %rdi
movq 0x1260d(%rip), %rsi     # 0x28ff0
movq 0x125ce(%rip), %rdx     # 0x28fb8
callq 0x46a0
jmp 0x16d6c
movq -0x330(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x4350
jmp 0x16d5a
leaq 0x13020(%rip), %rdi     # 0x29a38
leaq -0x30(%rbp), %rsi
callq 0x8fc0
movq %rax, -0x338(%rbp)
jmp 0x16a2a
movq -0x338(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq 0x12ffc(%rip), %rdi     # 0x29a38
callq 0x8f30
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x8f90
testb $0x1, %al
jne 0x16a58
jmp 0x16ab9
movl $0x10, %edi
callq 0x4250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x340(%rbp)
leaq 0x5d59(%rip), %rsi      # 0x1c7cf
callq 0x41c0
jmp 0x16a7d
movq -0x340(%rbp), %rdi
movq 0x12565(%rip), %rsi     # 0x28ff0
movq 0x12526(%rip), %rdx     # 0x28fb8
callq 0x46a0
jmp 0x16d6c
movq -0x340(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x4350
jmp 0x16d5a
leaq -0x2b8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x6e20
jmp 0x16acb
leaq 0x12d2e(%rip), %rsi     # 0x29800
leaq -0x298(%rbp), %rdi
leaq -0x2b8(%rbp), %rdx
callq 0x17830
jmp 0x16ae7
leaq 0x12d32(%rip), %rdx     # 0x29820
leaq -0x278(%rbp), %rdi
leaq -0x298(%rbp), %rsi
callq 0x8c40
jmp 0x16b03
leaq -0x278(%rbp), %rdi
callq 0x41e0
movq %rax, %rsi
leaq -0x258(%rbp), %rdi
movl $0x8, %edx
callq 0x4730
jmp 0x16b25
leaq -0x278(%rbp), %rdi
callq 0x47d8
leaq -0x298(%rbp), %rdi
callq 0x47d8
leaq -0x2b8(%rbp), %rdi
callq 0x47d8
movq -0x258(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x258(%rbp,%rax), %rdi
callq 0x4540
movb %al, -0x341(%rbp)
jmp 0x16b69
movb -0x341(%rbp), %al
testb $0x1, %al
jne 0x16b98
jmp 0x16b75
leaq -0x30(%rbp), %rdi
callq 0x7700
movq %rax, -0x350(%rbp)
jmp 0x16b87
movq -0x350(%rbp), %rax
cmpq $0x0, %rax
je 0x16c5b
movl $0x10, %edi
callq 0x4250
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x358(%rbp)
leaq 0x5c35(%rip), %rsi      # 0x1c7eb
callq 0x41c0
jmp 0x16bbd
movq -0x358(%rbp), %rdi
movq 0x12425(%rip), %rsi     # 0x28ff0
movq 0x123e6(%rip), %rdx     # 0x28fb8
callq 0x46a0
jmp 0x16d6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x16c1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x16c10
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x47d8
leaq -0x298(%rbp), %rdi
callq 0x47d8
leaq -0x2b8(%rbp), %rdi
callq 0x47d8
jmp 0x16d5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x16d4e
movq -0x358(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x4350
jmp 0x16d4e
leaq -0x2d8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x6e20
jmp 0x16c6d
movq -0x8(%rbp), %rdi
addq $0x90, %rdi
leaq -0x2d8(%rbp), %rsi
movq %rsi, -0x360(%rbp)
callq 0x4520
movq -0x360(%rbp), %rdi
callq 0x47d8
movq -0x8(%rbp), %rax
movl $0x3, 0x68(%rax)
movq -0x8(%rbp), %rdx
addq $0x90, %rdx
leaq 0x5b6f(%rip), %rsi      # 0x1c823
leaq -0x318(%rbp), %rdi
callq 0x13750
jmp 0x16cc2
leaq 0x5b00(%rip), %rdx      # 0x1c7c9
leaq -0x2f8(%rbp), %rdi
leaq -0x318(%rbp), %rsi
callq 0xc6c0
jmp 0x16cde
movq -0x8(%rbp), %rdi
addq $0x70, %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x4520
leaq -0x2f8(%rbp), %rdi
callq 0x47d8
leaq -0x318(%rbp), %rdi
callq 0x47d8
movq -0x8(%rbp), %rax
movl $0x0, 0xd0(%rax)
leaq -0x258(%rbp), %rdi
callq 0x4120
leaq -0x30(%rbp), %rdi
callq 0x47d8
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x47d8
leaq -0x258(%rbp), %rdi
callq 0x4120
leaq -0x30(%rbp), %rdi
callq 0x47d8
movq -0x38(%rbp), %rdi
callq 0x46d0
nopl (%rax)