// File: /workspace/github_cpp_makefile_star2_O2/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)
andl $0x0, -0x20(%rbp)
callq 0x38d94
cmpb $0x1, 0x31a5(%rax)
jne 0x35131
leaq 0x2427a(%rip), %rsi     # 0x59377
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x9260
xorl %r15d, %r15d
testl %eax, %eax
jne 0x35241
leaq 0x24263(%rip), %rsi     # 0x5937d
leaq -0x19(%rbp), %rdx
leaq -0xa0(%rbp), %rcx
movq %r14, %rdi
xorl %eax, %eax
callq 0x94a0
jmp 0x351af
callq 0x38d94
cmpb $0x1, 0x31a6(%rax)
jne 0x3516a
leaq 0x24246(%rip), %rsi     # 0x5938c
movq %r14, %rdi
callq 0x9690
testl %eax, %eax
jne 0x35180
movb $0x6c, -0x19(%rbp)
movl $0xc, -0x20(%rbp)
movb $0x62, -0xa0(%rbp)
pushq $0xc
popq %r15
jmp 0x351af
leaq 0x24206(%rip), %rsi     # 0x59377
pushq $0x4
popq %rdx
movq %r14, %rdi
callq 0x9260
testl %eax, %eax
je 0x35188
xorl %r15d, %r15d
jmp 0x35241
leaq 0x24207(%rip), %rsi     # 0x59396
leaq -0x19(%rbp), %rdx
leaq -0x20(%rbp), %r15
leaq -0xa0(%rbp), %r8
movq %r14, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x94a0
movsbl (%r15), %r15d
movq 0x10(%rbx), %rdi
movb -0x19(%rbp), %al
movb %al, 0x28(%rdi)
movb %al, 0x29(%rdi)
cmpb $0x6c, %al
pushq $0x72
popq %rax
pushq $0x6c
popq %rcx
cmovel %eax, %ecx
movb %cl, 0x2a(%rdi)
movl %r15d, 0x2c(%rdi)
incl 0x48(%rbx)
cmpb $0x62, -0xa0(%rbp)
je 0x351ec
callq 0x38d94
movq 0x10(%rbx), %rdi
cmpb $0x1, 0x31a5(%rax)
jne 0x3520f
movl $0x16, 0x1c(%rdi)
movl $0x1, 0x24(%rdi)
cmpb $0x6c, 0x28(%rdi)
jne 0x35206
andl $0x0, 0x20(%rdi)
jmp 0x3521d
movl $0x1, 0x20(%rdi)
jmp 0x3521d
movl $0x1, 0x1c(%rdi)
movl $0x3, 0x24(%rdi)
callq 0x31e2a
callq 0x4254e
movl -0x20(%rbp), %ecx
movl %ecx, 0x88(%rax)
callq 0x3018a
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