// File: /workspace/github_cpp_makefile_star2_O1/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 0x90df
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x9037
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x90d0
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 0xef64
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6a44
cmpq $0x0, 0x48(%r15)
je 0x915e
leaq 0x730f(%rip), %rsi      # 0x1041a
movq %rbx, %rdi
callq 0xb1ac
movq 0x38(%r15), %r12
addq $0x28, %r15
cmpq %r15, %r12
je 0x914f
leaq 0x7859(%rip), %r13      # 0x10980
leaq 0x20(%r12), %rsi
movq %rbx, %rdi
callq 0x6a44
movq %rax, %rdi
movq %r13, %rsi
callq 0xb0b0
movq %r12, %rdi
callq 0x3380
movq %rax, %r12
cmpq %r15, %rax
jne 0x9127
leaq 0x6f76(%rip), %rsi      # 0x100cc
movq %rbx, %rdi
callq 0xb0b0
leaq 0xd6ab(%rip), %r15      # 0x16810
movq (%r15), %r12
cmpq %r15, %r12
je 0x90bb
xorl %r14d, %r14d
movq 0x10(%r12), %r13
cmpq %rbx, %r13
je 0x91df
cmpl $-0x1, (%r13)
je 0x91df
cmpl $0x5, 0x68(%r13)
jne 0x91df
testb $0x1, 0xd8(%r13)
jne 0x91df
movl 0xd4(%r13), %eax
movq -0x50(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x91df
testl %r14d, %r14d
je 0x91bb
movq %rbx, %rdi
leaq 0x7548(%rip), %rsi      # 0x106fc
callq 0xb3a4
jmp 0x91ca
movq %rbx, %rdi
leaq 0x725d(%rip), %rsi      # 0x10422
callq 0xb2a8
addq $0x90, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6a44
incl %r14d
movq (%r12), %r12
cmpq %r15, %r12
jne 0x9174
testl %r14d, %r14d
leaq -0x38(%rbp), %r14
je 0x90bb
leaq 0x6e7b(%rip), %rsi      # 0x10077
movq %rbx, %rdi
callq 0xb3a4
jmp 0x90bb
jmp 0x9211
jmp 0x9211
jmp 0x9211
jmp 0x9211
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x922d
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rdi
callq 0x3530