// File: wrighteagle2d[P]wrighteaglebase/Debug/../src/DynamicDebug.cpp
// Function: DynamicDebug::Initial(Observer*)
void DynamicDebug::Initial(Observer *pObserver) {
  if (mInitialOK == true) {
    return;
  }

  if (pObserver == 0) {
    PRINT_ERROR("Observer Null Pointer");
    return;
  }

  mpObserver = pObserver;

  if (PlayerParam::instance().DynamicDebugMode() == true) // 动态调试
  {
    mpFileStream = new std::ifstream("dynamicdebug.txt");
    if (mpFileStream) {
      std::cin.rdbuf(mpFileStream->rdbuf());
    }
  } else // 正常比赛时
  {
    if (PlayerParam::instance().SaveServerMessage() ==
        true) // 需要保存server信息
    {
      char file_name[64];
      sprintf(file_name, "%s/%s-%d-msg.log",
              PlayerParam::instance().logDir().c_str(),
              PlayerParam::instance().teamName().c_str(),
              mpObserver->SelfUnum());
      mpFile = fopen(file_name, "wb");
      if (mpFile) {
        if (setvbuf(mpFile, 0, _IOFBF, 1024 * 8192) != 0) {
          PRINT_ERROR("set buffer for file \"" << file_name << "\" error");
        }
      } else {
        PRINT_ERROR("open file \"" << file_name << "\" error");
      }
    }

    if (mpFile != 0) {
      fseek(mpFile, sizeof(mFileHead) + 2 * sizeof(char),
            SEEK_SET); // 留出mFileHead的地方，最后再填
      mFileHead.mIndexTableSize = 0;
      mIndexTable.reserve(8192);
      mMessageTable.reserve(8192);
    }
  }
  mInitialOK = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movb 0x8(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x33fad
jmp 0x3430d
cmpq $0x0, -0x10(%rbp)
jne 0x34017
jmp 0x33fb6
movq 0xca033(%rip), %rdi     # 0xfdff0
leaq 0x8e2f6(%rip), %rsi     # 0xc22ba
callq 0xa5a0
movq %rax, %rdi
leaq 0x9127e(%rip), %rsi     # 0xc5251
callq 0xa5a0
movq %rax, %rdi
movl $0x59, %esi
callq 0xaa40
movq %rax, %rdi
leaq 0x8f570(%rip), %rsi     # 0xc355f
callq 0xa5a0
movq %rax, %rdi
leaq 0x8e2d4(%rip), %rsi     # 0xc22d2
callq 0xa5a0
movq %rax, %rdi
movq 0xc9fa3(%rip), %rsi     # 0xfdfb0
callq 0xa630
jmp 0x3430d
movq -0x68(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rcx, (%rax)
callq 0x798a0
movq %rax, %rdi
callq 0x12140
movb (%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x340da
movl $0x208, %edi            # imm = 0x208
callq 0xa5c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x70(%rbp)
leaq 0x8e28e(%rip), %rsi     # 0xc22e8
movl $0x8, %edx
callq 0xab00
jmp 0x34066
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rcx, 0x128(%rax)
cmpq $0x0, 0x128(%rax)
je 0x340d5
movq -0x68(%rbp), %rax
movq 0xc9f4e(%rip), %rcx     # 0xfdfd8
movq (%rcx), %rdx
movq 0xc9f44(%rip), %rcx     # 0xfdfd8
addq -0x18(%rdx), %rcx
movq %rcx, -0x78(%rbp)
movq 0x128(%rax), %rdi
callq 0xa950
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0xab50
jmp 0x340d5
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x18(%rbp)
movl %eax, -0x1c(%rbp)
movl $0x208, %esi            # imm = 0x208
callq 0xa5e0
jmp 0x34316
jmp 0x34305
callq 0x798a0
movq %rax, %rdi
callq 0x12160
movb (%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x342af
leaq -0x60(%rbp), %rax
movq %rax, -0x90(%rbp)
callq 0x798a0
movq %rax, %rdi
callq 0x35b80
movq %rax, %rdi
callq 0xa240
movq %rax, -0x88(%rbp)
callq 0x798a0
movq %rax, %rdi
callq 0x11db0
movq %rax, %rdi
callq 0xa240
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x80(%rbp)
movq (%rax), %rdi
callq 0x11dd0
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rdx
movq -0x80(%rbp), %rcx
movl (%rax), %r8d
leaq 0x8e197(%rip), %rsi     # 0xc22f9
movb $0x0, %al
callq 0xa130
leaq -0x60(%rbp), %rdi
leaq 0x8e196(%rip), %rsi     # 0xc230a
callq 0xa710
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x120(%rax)
cmpq $0x0, 0x120(%rax)
je 0x34232
movq -0x68(%rbp), %rax
movq 0x120(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
movl $0x800000, %ecx         # imm = 0x800000
callq 0xa060
cmpl $0x0, %eax
je 0x34230
jmp 0x341b7
movq 0xc9e32(%rip), %rdi     # 0xfdff0
leaq 0x8e0f5(%rip), %rsi     # 0xc22ba
callq 0xa5a0
movq %rax, %rdi
leaq 0x9107d(%rip), %rsi     # 0xc5251
callq 0xa5a0
movq %rax, %rdi
movl $0x72, %esi
callq 0xaa40
movq %rax, %rdi
leaq 0x8f36f(%rip), %rsi     # 0xc355f
callq 0xa5a0
movq %rax, %rdi
leaq 0x8e10e(%rip), %rsi     # 0xc230d
callq 0xa5a0
movq %rax, %rdi
leaq -0x60(%rbp), %rsi
callq 0xa5a0
movq %rax, %rdi
leaq 0x8e109(%rip), %rsi     # 0xc2323
callq 0xa5a0
movq %rax, %rdi
movq 0xc9d87(%rip), %rsi     # 0xfdfb0
callq 0xa630
jmp 0x34230
jmp 0x342ad
jmp 0x34234
movq 0xc9db5(%rip), %rdi     # 0xfdff0
leaq 0x8e078(%rip), %rsi     # 0xc22ba
callq 0xa5a0
movq %rax, %rdi
leaq 0x91000(%rip), %rsi     # 0xc5251
callq 0xa5a0
movq %rax, %rdi
movl $0x75, %esi
callq 0xaa40
movq %rax, %rdi
leaq 0x8f2f2(%rip), %rsi     # 0xc355f
callq 0xa5a0
movq %rax, %rdi
leaq 0x8e0af(%rip), %rsi     # 0xc232b
callq 0xa5a0
movq %rax, %rdi
leaq -0x60(%rbp), %rsi
callq 0xa5a0
movq %rax, %rdi
leaq 0x8e08c(%rip), %rsi     # 0xc2323
callq 0xa5a0
movq %rax, %rdi
movq 0xc9d0a(%rip), %rsi     # 0xfdfb0
callq 0xa630
jmp 0x342ad
jmp 0x342af
movq -0x68(%rbp), %rax
cmpq $0x0, 0x120(%rax)
je 0x34303
movq -0x68(%rbp), %rax
movq 0x120(%rax), %rdi
movl $0x4a, %esi
xorl %edx, %edx
callq 0xa690
movq -0x68(%rbp), %rdi
movq $0x0, 0x18(%rdi)
addq $0x58, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x35ba0
movq -0x68(%rbp), %rdi
addq $0xb8, %rdi
movl $0x2000, %esi           # imm = 0x2000
callq 0x35ca0
jmp 0x34305
movq -0x68(%rbp), %rax
movb $0x1, 0x8(%rax)
addq $0x90, %rsp
popq %rbp
retq
movq -0x18(%rbp), %rdi
callq 0xaa60
nop