// File: /workspace/github_cpp_makefile_star2_O2/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 -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rsi, %rdi
callq 0x32b0
leaq -0x50(%rbp), %rsi
movq %rax, %rdi
callq 0x33c0
cmpq $0x0, -0x48(%rbp)
je 0x7ce3
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x7c5e
jmp 0x7deb
leaq 0xd4(%rbx), %r14
movq %r14, %rdi
callq 0xc574
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5e24
cmpq $0x0, 0x48(%r15)
je 0x7d5d
leaq 0x56fa(%rip), %rsi      # 0xd408
movq %rbx, %rdi
callq 0x939a
movq 0x38(%r15), %r13
addq $0x28, %r15
leaq 0x5c49(%rip), %r12      # 0xd96e
cmpq %r15, %r13
je 0x7d4e
leaq 0x20(%r13), %rsi
movq %rbx, %rdi
callq 0x5e24
movq %rax, %rdi
movq %r12, %rsi
callq 0x92f2
movq %r13, %rdi
callq 0x3390
movq %rax, %r13
jmp 0x7d25
leaq 0x537f(%rip), %rsi      # 0xd0d4
movq %rbx, %rdi
callq 0x92f2
movl $0x0, -0x2c(%rbp)
leaq 0xcaa5(%rip), %r15      # 0x14810
movq %r15, %r12
movq (%r12), %r12
cmpq %r15, %r12
je 0x7dd6
movq 0x10(%r12), %r13
cmpq %rbx, %r13
je 0x7d6e
movq %r13, %rdi
callq 0x5750
testb %al, %al
je 0x7d6e
movl 0xd4(%r13), %eax
cmpl (%r14), %eax
jne 0x7d6e
cmpl $0x0, -0x2c(%rbp)
je 0x7db0
movq %rbx, %rdi
leaq 0x5941(%rip), %rsi      # 0xd6ea
callq 0x94ea
jmp 0x7dbf
movq %rbx, %rdi
leaq 0x5656(%rip), %rsi      # 0xd410
callq 0x9442
incl -0x2c(%rbp)
addq $0x90, %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x5e24
jmp 0x7d6e
cmpl $0x0, -0x2c(%rbp)
je 0x7deb
leaq 0x529c(%rip), %rsi      # 0xd07f
movq %rbx, %rdi
callq 0x94ea
leaq -0x50(%rbp), %rdi
callq 0x35c8
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7e0d
jmp 0x7e0d
jmp 0x7e0d
jmp 0x7e0d
jmp 0x7e0d
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x35c8
movq %rbx, %rdi
callq 0x3500