// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/Parser.cpp
// Function: Parser::ParseInitializeMsg(char const*)
bool Parser::ParseInitializeMsg(const char *msg) {
  char play_mode[128];
  char my_side = '?';
  Unum my_unum = 0;
  // TODO: how about reconnect

  if (PlayerParam::instance().isCoach()) {
    if (!(strncmp(msg, "(init", 4))) { // initialize message
      sscanf(msg, "(init %c %[^)]", &my_side, play_mode);
    } else {
      return false;
    }
  } else if (PlayerParam::instance().isTrainer()) {
    if (!(strcmp(msg, "(init ok)"))) { // initialize message
      //初始信息没有我们的信息，Trainer是全局的
    } else {
      return false;
    }
    my_side = 'l';          //设定trainer是我方的
    my_unum = TRAINER_UNUM; //设定trainer的号码为12号
    play_mode[0] = 'b';
  } else {
    if (!(strncmp(msg, "(init", 4))) { // initialize message
      sscanf(msg, "(init %c %d %[^)]", &my_side, &my_unum, play_mode);
    } else {
      return false;
    }
  }

  mpObserver->SetOurInitSide(my_side);
  mpObserver->SetOurSide(my_side);
  mpObserver->SetSelfUnum(my_unum);
  ++mHalfTime;
  if (play_mode[0] == 'b' ||
      PlayerParam::instance().isCoach()) { /* Before_kick_off */
    mpObserver->SetPlayMode(PM_Before_Kick_Off);
    mpObserver->SetServerPlayMode(SPM_BeforeKickOff);
    if (mpObserver->OurInitSide() == 'l')
      mpObserver->SetKickOffMode(KO_Ours);
    else
      mpObserver->SetKickOffMode(KO_Opps);
  } else {
    mpObserver->SetPlayMode(PM_Play_On);
    mpObserver->SetServerPlayMode(SPM_PlayOn);
  }

  mpObserver->Initialize(); //必须知道自己是哪边的才能初始化

  TimeTest::instance().SetUnum(my_unum); // TimeTest的记录文件名会用到
  NetworkTest::instance().SetUnum(my_unum);

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movb $0x3f, -0x19(%rbp)
movl $0x0, -0x20(%rbp)
callq 0x43dce
cmpb $0x1, 0x31a5(%rax)
jne 0x3e2f9
leaq 0x2d0ef(%rip), %rsi     # 0x6b3af
movl $0x4, %edx
movq %r14, %rdi
callq 0x9230
xorl %r15d, %r15d
testl %eax, %eax
jne 0x3e414
leaq 0x2d0d6(%rip), %rsi     # 0x6b3b5
leaq -0x19(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
movq %r14, %rdi
xorl %eax, %eax
callq 0x9490
jmp 0x3e37b
callq 0x43dce
cmpb $0x1, 0x31a6(%rax)
jne 0x3e334
leaq 0x2d0b6(%rip), %rsi     # 0x6b3c4
movq %r14, %rdi
callq 0x9670
testl %eax, %eax
jne 0x3e34c
movb $0x6c, -0x19(%rbp)
movl $0xc, -0x20(%rbp)
movb $0x62, -0xa0(%rbp)
movl $0xc, %r15d
jmp 0x3e37b
leaq 0x2d074(%rip), %rsi     # 0x6b3af
movl $0x4, %edx
movq %r14, %rdi
callq 0x9230
testl %eax, %eax
je 0x3e354
xorl %r15d, %r15d
jmp 0x3e414
leaq 0x2d073(%rip), %rsi     # 0x6b3ce
leaq -0x19(%rbp), %rdx
leaq -0x20(%rbp), %r15
leaq -0xa0(%rbp), %r8
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x9490
movsbl (%r15), %r15d
movq 0x10(%rbx), %rdi
movb -0x19(%rbp), %al
movb %al, 0x28(%rdi)
movb %al, 0x29(%rdi)
cmpb $0x6c, %al
movl $0x72, %eax
movl $0x6c, %ecx
cmovel %eax, %ecx
movb %cl, 0x2a(%rdi)
movl %r15d, 0x2c(%rdi)
incl 0x48(%rbx)
cmpb $0x62, -0xa0(%rbp)
je 0x3e3bc
callq 0x43dce
movq 0x10(%rbx), %rdi
cmpb $0x1, 0x31a5(%rax)
jne 0x3e3e2
movl $0x16, 0x1c(%rdi)
movl $0x1, 0x24(%rdi)
cmpb $0x6c, 0x28(%rdi)
jne 0x3e3d9
movl $0x0, 0x20(%rdi)
jmp 0x3e3f0
movl $0x1, 0x20(%rdi)
jmp 0x3e3f0
movl $0x1, 0x1c(%rdi)
movl $0x3, 0x24(%rdi)
callq 0x3aa20
callq 0x4e858
movl -0x20(%rbp), %ecx
movl %ecx, 0x88(%rax)
callq 0x38882
movl -0x20(%rbp), %ecx
movl %ecx, 0x80(%rax)
movb $0x1, %r15b
movl %r15d, %eax
addq $0x88, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop