// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x90, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movb $0x3f, -0x11(%rbp)
movl $0x0, -0x18(%rbp)
callq 0x450ba
cmpb $0x1, 0x31a5(%rax)
jne 0x3f33d
leaq 0x2e0c9(%rip), %rsi     # 0x6d3d7
movl $0x4, %edx
movq %r14, %rdi
callq 0x9230
testl %eax, %eax
jne 0x3f38a
leaq 0x2e0b7(%rip), %rsi     # 0x6d3dd
leaq -0x11(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
movq %r14, %rdi
xorl %eax, %eax
callq 0x9490
jmp 0x3f3b1
callq 0x450ba
cmpb $0x1, 0x31a6(%rax)
jne 0x3f372
leaq 0x2e09a(%rip), %rsi     # 0x6d3ec
movq %r14, %rdi
callq 0x9670
testl %eax, %eax
jne 0x3f38a
movb $0x6c, -0x11(%rbp)
movl $0xc, -0x18(%rbp)
movb $0x62, -0xa0(%rbp)
jmp 0x3f3b1
leaq 0x2e05e(%rip), %rsi     # 0x6d3d7
movl $0x4, %edx
movq %r14, %rdi
callq 0x9230
testl %eax, %eax
je 0x3f391
xorl %eax, %eax
jmp 0x3f455
leaq 0x2e05e(%rip), %rsi     # 0x6d3f6
leaq -0x11(%rbp), %rdx
leaq -0x18(%rbp), %rcx
leaq -0xa0(%rbp), %r8
movq %r14, %rdi
xorl %eax, %eax
callq 0x9490
movq 0x10(%rbx), %rax
movb -0x11(%rbp), %cl
movb %cl, 0x28(%rax)
movb %cl, 0x29(%rax)
cmpb $0x6c, %cl
movl $0x72, %ecx
movl $0x6c, %edx
cmovel %ecx, %edx
movb %dl, 0x2a(%rax)
movsbl -0x18(%rbp), %ecx
movl %ecx, 0x2c(%rax)
incl 0x48(%rbx)
cmpb $0x62, -0xa0(%rbp)
je 0x3f3f2
callq 0x450ba
cmpb $0x1, 0x31a5(%rax)
jne 0x3f41c
movq 0x10(%rbx), %rax
movl $0x16, 0x1c(%rax)
movl $0x1, 0x24(%rax)
cmpb $0x6c, 0x28(%rax)
jne 0x3f413
movl $0x0, 0x20(%rax)
jmp 0x3f42e
movl $0x1, 0x20(%rax)
jmp 0x3f42e
movq 0x10(%rbx), %rax
movl $0x1, 0x1c(%rax)
movl $0x3, 0x24(%rax)
movq 0x10(%rbx), %rdi
callq 0x3ba04
callq 0x4fec4
movl -0x18(%rbp), %ecx
movl %ecx, 0x88(%rax)
callq 0x3974e
movl -0x18(%rbp), %ecx
movl %ecx, 0x80(%rax)
movb $0x1, %al
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop