// File: /workspace/github_cpp_makefile_star2_O3/nickgammon[P]tinymudserver/commands.cpp
// Function: DoLook(tPlayer*, std::istream&)
void DoLook (tPlayer * p, istream & sArgs)
{
 
  // TODO: add: look (thing)

  string whichObject;
  sArgs >> ws >> whichObject;

  if (!whichObject.empty ())
    {
    lookObject (p, whichObject);
    return;
    }
    
  
  // find our current room, throws exception if not there
  tRoom * r = FindRoom (p->room);
  
  // show room description
  *p << r->description;
  
  // show available exits
  if (!r->exits.empty ())
    {
    *p << "Exits: ";
    for (tExitMap::const_iterator exititer = r->exits.begin ();
         exititer != r->exits.end (); ++exititer)
      *p << exititer->first << " ";
    *p << "\n";        
    }
  
  /* list other players in the same room */
  
  int iOthers = 0;
  for (tPlayerListIterator listiter = playerlist.begin (); 
      listiter != playerlist.end (); 
      listiter++)
    {
    tPlayer *otherp = *listiter;
    if (otherp != p && /* we don't see ourselves */
        otherp->IsPlaying () &&
        otherp->room == p->room)  // need to be in same room
      {
      if (iOthers++ == 0)
        *p << "You also see ";
      else
        *p << ", ";
      *p << otherp->playername;
      }
    }   /* end of looping through all players */

  /* If we listed anyone, finish up the line with a period, newline */
  if (iOthers)
    *p << ".\n";

  
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq -0x38(%rbp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
movq %rsi, %rdi
callq 0x3280
leaq -0x48(%rbp), %rsi
movq %rax, %rdi
callq 0x33b0
cmpq $0x0, -0x40(%rbp)
je 0x9070
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x8fc8
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x9061
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32f0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xd4(%rbx), %rdi
movq %rdi, -0x50(%rbp)
callq 0xeecc
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6a0a
cmpq $0x0, 0x48(%r15)
je 0x90ef
leaq 0x737e(%rip), %rsi      # 0x1041a
movq %rbx, %rdi
callq 0xb140
movq 0x38(%r15), %r12
addq $0x28, %r15
cmpq %r15, %r12
je 0x90e0
leaq 0x78c8(%rip), %r13      # 0x10980
leaq 0x20(%r12), %rsi
movq %rbx, %rdi
callq 0x6a0a
movq %rax, %rdi
movq %r13, %rsi
callq 0xb044
movq %r12, %rdi
callq 0x3380
movq %rax, %r12
cmpq %r15, %rax
jne 0x90b8
leaq 0x6fe5(%rip), %rsi      # 0x100cc
movq %rbx, %rdi
callq 0xb044
leaq 0xd71a(%rip), %r15      # 0x16810
movq (%r15), %r12
cmpq %r15, %r12
je 0x904c
xorl %r14d, %r14d
movq 0x10(%r12), %r13
cmpq %rbx, %r13
je 0x9170
cmpl $-0x1, (%r13)
je 0x9170
cmpl $0x5, 0x68(%r13)
jne 0x9170
testb $0x1, 0xd8(%r13)
jne 0x9170
movl 0xd4(%r13), %eax
movq -0x50(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x9170
testl %r14d, %r14d
je 0x914c
movq %rbx, %rdi
leaq 0x75b7(%rip), %rsi      # 0x106fc
callq 0xb338
jmp 0x915b
movq %rbx, %rdi
leaq 0x72cc(%rip), %rsi      # 0x10422
callq 0xb23c
addq $0x90, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6a0a
incl %r14d
movq (%r12), %r12
cmpq %r15, %r12
jne 0x9105
testl %r14d, %r14d
leaq -0x38(%rbp), %r14
je 0x904c
leaq 0x6eea(%rip), %rsi      # 0x10077
movq %rbx, %rdi
callq 0xb338
jmp 0x904c
jmp 0x91a2
jmp 0x91a2
jmp 0x91a2
jmp 0x91a2
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x91be
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3530