// File: /workspace/github_cpp_makefile_star2_O2/nickgammon[P]tinymudserver/player.cpp
// Function: tPlayer::ProcessRead()
void tPlayer::ProcessRead ()
{
  
  if (closing)
    return;   // once closed, don't handle any pending input
  
  // I make it static to save allocating a buffer each time.
  // Hopefully this function won't be called recursively.
  static vector<char> buf (1000);  // reserve 1000 bytes for reading into
  
  int nRead = read (s, &buf [0], buf.size ());
  
  if (nRead == -1)
    {
    if (errno != EWOULDBLOCK)
      perror ("read from player");
    return;
    }

  if (nRead <= 0)
    {
    close (s);
    cerr << "Connection " << s << " closed" << endl;
    s = NO_SOCKET;
    DoCommand ("quit");  // tell others the s/he has left
    return;
    }

  inbuf += string (&buf [0], nRead);    /* add to input buffer */

  /* try to extract lines from the input buffer */
  for ( ; ; )
    {
    string::size_type i = inbuf.find ('\n');
    if (i == string::npos)
      break;  /* no more at present */

    string sLine = inbuf.substr (0, i);  /* extract first line */
    inbuf = inbuf.substr (i + 1, string::npos); /* get rest of string */

    ProcessPlayerInput (this, Trim (sLine));  /* now, do something with it */        
    }
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
cmpb $0x0, 0xd8(%rdi)
jne 0x51ae
movq %rdi, %rbx
movb 0xf4a5(%rip), %al       # 0x144e0
testb %al, %al
je 0x51bd
movl (%rbx), %edi
movq 0xf47c(%rip), %rsi      # 0x144c8
movq 0xf47d(%rip), %rdx      # 0x144d0
subq %rsi, %rdx
callq 0x3410
cmpl $-0x1, %eax
je 0x512f
testl %eax, %eax
jle 0x5147
movq 0xf455(%rip), %rsi      # 0x144c8
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq -0x38(%rbp), %rcx
movq %rcx, -0x10(%rcx)
addq %rsi, %rax
leaq -0x48(%rbp), %rdi
movq %rax, %rdx
callq 0x43f2
leaq 0x28(%rbx), %r14
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x3590
leaq -0x48(%rbp), %r15
movq %r15, %rdi
callq 0x35c8
leaq -0x68(%rbp), %r13
movq %r14, %rdi
pushq $0xa
popq %rsi
xorl %edx, %edx
callq 0x33e0
cmpq $-0x1, %rax
je 0x51ae
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x3350
incq %r12
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
pushq $-0x1
popq %rcx
callq 0x3350
movq %r14, %rdi
movq %r13, %rsi
callq 0x33b0
movq %r13, %rdi
callq 0x35c8
movq %r13, %rdi
movq %r15, %rsi
leaq 0xf39b(%rip), %rdx      # 0x144a8
callq 0x4501
movq %rbx, %rdi
movq %r13, %rsi
callq 0xbb85
movq %r13, %rdi
callq 0x35c8
movq %r15, %rdi
callq 0x35c8
jmp 0x50af
callq 0x3040
cmpl $0xb, (%rax)
je 0x51ae
leaq 0x80a7(%rip), %rdi      # 0xd1e7
callq 0x32a0
jmp 0x51ae
movl (%rbx), %edi
callq 0x35a0
movq 0xee93(%rip), %rdi      # 0x13fe8
leaq 0x809c(%rip), %rsi      # 0xd1f8
callq 0x3310
movl (%rbx), %esi
movq %rax, %rdi
callq 0x34f0
leaq 0x8092(%rip), %rsi      # 0xd204
movq %rax, %rdi
callq 0x3310
movq %rax, %rdi
callq 0x31a0
orl $-0x1, (%rbx)
leaq 0x8080(%rip), %rsi      # 0xd20c
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x43b6
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x4edc
leaq -0x48(%rbp), %rdi
callq 0x35c8
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf31c(%rip), %rdi      # 0x144e0
callq 0x3530
testl %eax, %eax
je 0x5043
leaq 0xf2f0(%rip), %rdi      # 0x144c8
leaq -0x48(%rbp), %rdx
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x5576
leaq 0x3db(%rip), %rdi       # 0x55c8
leaq 0xf2d4(%rip), %rsi      # 0x144c8
leaq 0xf0ed(%rip), %rdx      # 0x142e8
callq 0x32d0
leaq 0xf2d9(%rip), %rdi      # 0x144e0
callq 0x3240
jmp 0x5043
movq %rax, %rbx
leaq 0xf2c5(%rip), %rdi      # 0x144e0
callq 0x3220
jmp 0x5249
jmp 0x522f
jmp 0x5228
jmp 0x522f
movq %rax, %rbx
jmp 0x5249
jmp 0x522f
movq %rax, %rbx
jmp 0x5240
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x35c8
leaq -0x48(%rbp), %rdi
callq 0x35c8
movq %rbx, %rdi
callq 0x3500
nop