// File: 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
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movb $0x3f, -0xa1(%rbp)
movl $0x0, -0xa8(%rbp)
callq 0x798a0
movq %rax, %rdi
callq 0x10de0
testb $0x1, (%rax)
je 0x7203b
movq -0x18(%rbp), %rdi
leaq 0x514bb(%rip), %rsi     # 0xc34b7
movl $0x4, %edx
callq 0xa2c0
cmpl $0x0, %eax
jne 0x7202d
movq -0x18(%rbp), %rdi
leaq -0xa0(%rbp), %rcx
leaq 0x514a0(%rip), %rsi     # 0xc34bd
leaq -0xa1(%rbp), %rdx
movb $0x0, %al
callq 0xa580
jmp 0x72036
movb $0x0, -0x1(%rbp)
jmp 0x7221d
jmp 0x720d7
callq 0x798a0
movq %rax, %rdi
callq 0x12080
testb $0x1, (%rax)
je 0x72087
movq -0x18(%rbp), %rdi
leaq 0x51474(%rip), %rsi     # 0xc34cc
callq 0xa830
cmpl $0x0, %eax
jne 0x72064
jmp 0x7206d
movb $0x0, -0x1(%rbp)
jmp 0x7221d
movb $0x6c, -0xa1(%rbp)
movl $0xc, -0xa8(%rbp)
movb $0x62, -0xa0(%rbp)
jmp 0x720d5
movq -0x18(%rbp), %rdi
leaq 0x51425(%rip), %rsi     # 0xc34b7
movl $0x4, %edx
callq 0xa2c0
cmpl $0x0, %eax
jne 0x720ca
movq -0x18(%rbp), %rdi
leaq -0xa0(%rbp), %r8
leaq 0x51423(%rip), %rsi     # 0xc34d6
leaq -0xa1(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
movb $0x0, %al
callq 0xa580
jmp 0x720d3
movb $0x0, -0x1(%rbp)
jmp 0x7221d
jmp 0x720d5
jmp 0x720d7
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
movsbl -0xa1(%rbp), %esi
callq 0x77ac0
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
movsbl -0xa1(%rbp), %esi
callq 0x77ae0
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0xa8(%rbp), %eax
movsbl %al, %esi
callq 0x77b30
movq -0xb0(%rbp), %rax
movl 0x48(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x48(%rax)
movsbl -0xa0(%rbp), %eax
cmpl $0x62, %eax
je 0x7214c
callq 0x798a0
movq %rax, %rdi
callq 0x10de0
testb $0x1, (%rax)
je 0x721b9
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x16, %esi
callq 0x77b50
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %esi
callq 0x77b70
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x6e590
movsbl (%rax), %eax
cmpl $0x6c, %eax
jne 0x721a2
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
xorl %esi, %esi
callq 0x77b90
jmp 0x721b7
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %esi
callq 0x77b90
jmp 0x721e3
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %esi
callq 0x77b50
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
movl $0x3, %esi
callq 0x77b70
movq -0xb0(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x68ef0
callq 0x8f5b0
movq %rax, %rdi
movl -0xa8(%rbp), %esi
callq 0x77bb0
callq 0x63700
movq %rax, %rdi
movl -0xa8(%rbp), %esi
callq 0x77bd0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)