// File: 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
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
testb $0x1, 0xd8(%rax)
je 0x83e8
jmp 0x87a1
cmpb $0x0, 0x21211(%rip)     # 0x29600
jne 0x845b
leaq 0x21208(%rip), %rdi     # 0x29600
callq 0x4710
cmpl $0x0, %eax
je 0x845b
leaq -0x9(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x46e0
movq -0xe8(%rbp), %rdx
leaq 0x211c8(%rip), %rdi     # 0x295e8
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x9000
jmp 0x842c
leaq -0x9(%rbp), %rdi
callq 0x44a0
leaq 0xc34(%rip), %rdi       # 0x9070
leaq 0x211a5(%rip), %rsi     # 0x295e8
leaq 0x20fa6(%rip), %rdx     # 0x293f0
callq 0x43c0
leaq 0x211aa(%rip), %rdi     # 0x29600
callq 0x4300
movq -0xe0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xf4(%rbp)
leaq 0x21177(%rip), %rdi     # 0x295e8
xorl %eax, %eax
movl %eax, %esi
callq 0x90d0
movq %rax, -0xf0(%rbp)
leaq 0x21160(%rip), %rdi     # 0x295e8
callq 0x90f0
movl -0xf4(%rbp), %edi
movq -0xf0(%rbp), %rsi
movq %rax, %rdx
callq 0x45d0
movl %eax, -0x20(%rbp)
cmpl $-0x1, -0x20(%rbp)
jne 0x84ee
callq 0x4070
cmpl $0xb, (%rax)
je 0x84e9
leaq 0x13d2b(%rip), %rdi     # 0x1c1e7
callq 0x4380
jmp 0x84e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x9(%rbp), %rdi
callq 0x44a0
leaq 0x21121(%rip), %rdi     # 0x29600
callq 0x42e0
jmp 0x87aa
jmp 0x87a1
cmpl $0x0, -0x20(%rbp)
jg 0x85d8
movq -0xe0(%rbp), %rax
movl (%rax), %edi
callq 0x47a0
movq 0x20adb(%rip), %rdi     # 0x28fe8
leaq 0x13ce4(%rip), %rsi     # 0x1c1f8
callq 0x4410
movq %rax, %rdi
movq -0xe0(%rbp), %rax
movl (%rax), %esi
callq 0x46c0
movq %rax, %rdi
leaq 0x13cd0(%rip), %rsi     # 0x1c204
callq 0x4410
movq %rax, %rdi
movq 0x20a55(%rip), %rsi     # 0x28f98
callq 0x4480
movq -0xe0(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
leaq -0x41(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x46e0
movq -0x100(%rbp), %rdx
leaq 0x13c99(%rip), %rsi     # 0x1c20c
leaq -0x40(%rbp), %rdi
callq 0x67d0
jmp 0x857e
movq -0xe0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x81c0
jmp 0x8590
leaq -0x40(%rbp), %rdi
callq 0x47d8
leaq -0x41(%rbp), %rdi
callq 0x44a0
jmp 0x87a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x85ca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x47d8
leaq -0x41(%rbp), %rdi
callq 0x44a0
jmp 0x87aa
leaq 0x21009(%rip), %rdi     # 0x295e8
xorl %eax, %eax
movl %eax, %esi
callq 0x90d0
movq %rax, -0x118(%rbp)
movslq -0x20(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x46e0
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rdx
movq -0x108(%rbp), %rcx
leaq -0x68(%rbp), %rdi
callq 0x44e0
jmp 0x862a
movq -0xe0(%rbp), %rdi
addq $0x28, %rdi
leaq -0x68(%rbp), %rsi
callq 0x4560
jmp 0x8640
leaq -0x68(%rbp), %rdi
callq 0x47d8
leaq -0x69(%rbp), %rdi
callq 0x44a0
movq -0xe0(%rbp), %rdi
addq $0x28, %rdi
movl $0xa, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x4580
movq %rax, -0x78(%rbp)
cmpq $-0x1, -0x78(%rbp)
jne 0x86ac
jmp 0x87a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x869e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x47d8
leaq -0x69(%rbp), %rdi
callq 0x44a0
jmp 0x87aa
movq -0xe0(%rbp), %rsi
addq $0x28, %rsi
movq %rsi, -0x120(%rbp)
movq -0x78(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x98(%rbp), %rdi
callq 0x4460
movq -0x120(%rbp), %rsi
movq -0x78(%rbp), %rdx
incq %rdx
leaq -0xb8(%rbp), %rdi
movq $-0x1, %rcx
callq 0x4460
jmp 0x86f5
movq -0xe0(%rbp), %rdi
addq $0x28, %rdi
leaq -0xb8(%rbp), %rsi
movq %rsi, -0x128(%rbp)
callq 0x4520
movq -0x128(%rbp), %rdi
callq 0x47d8
leaq 0x20ea2(%rip), %rdx     # 0x295c8
leaq -0xd8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x6c20
jmp 0x873b
movq -0xe0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x1a4c0
jmp 0x8750
leaq -0xd8(%rbp), %rdi
callq 0x47d8
leaq -0x98(%rbp), %rdi
callq 0x47d8
jmp 0x8652
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
jmp 0x8793
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x47d8
leaq -0x98(%rbp), %rdi
callq 0x47d8
jmp 0x87aa
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0x46d0
nopw %cs:(%rax,%rax)