// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/Parser.cpp
// Function: Parser::ParseFullstateMsg(char*)
void Parser::ParseFullstateMsg(char *msg) {
  //(fullstate 336 (pmode goal_l) (vmode high narrow) (count 0 0 313 0 1 290 8
  //743) (arm (movable 0) (expires 0) (target 0 0) (count 0)) (score 1 0)
  //((b) 52.6578 -4.41664 0 0)
  //((p l 1 g 8) -47.5 0 0 0 -66.8915 -80 (stamina 8000 0.829636 1 130600))
  //((p l 2 4) -25 -13 7.7863e-25 4.77769e-24 151.664 34 (stamina 8000 0.974746
  //1 123249))
  //((p l 3 12) -5.00073 -8.01793 -1.54512e-19 -8.12881e-18 -25.8413 -66
  //(stamina 7621.08 0.985774 1 111028))
  //...
  //((p r 11 14) 0.385 -7.01275e-12 -1.15337e-23 -8.33192e-24 46.129 0 (stamina
  //8000 0.933173 1 124249)))

  int time = parser::get_int(&msg);

  if (time != mpObserver->CurrentTime().T()) {
    mpObserver->SetCurrentTime(Time(time, mpObserver->CurrentTime().S()));
  }

  parser::get_word(&msg);
  parser::get_next_word(&msg); // skip 'pmode'

  parser::get_word(&msg);

  {
    static char buffer[MAX_MESSAGE];
    char *end = msg;

    while (*end != ')')
      end++;
    int n = end - msg;
    strncpy(buffer, msg, n * sizeof(char));
    buffer[n] = '\0';

    ParsePlayMode(buffer);

    msg = end;
  }

  parser::get_next_word(&msg); // skip 'vmode'
  parser::get_next_word(&msg); // skip not used view quality

  ViewWidth view_width = VW_None;
  switch (msg[1]) {
  case 'o':
    view_width = VW_Normal;
    break; /* normal */
  case 'a':
    view_width = VW_Narrow;
    break; /* narrow */
  case 'i':
    view_width = VW_Wide;
    break; /* wide   */
  default:
    PARSE_ERROR("Unknown view quality");
    break;
  }

  int kicks = parser::get_int(&msg);
  int dashes = parser::get_int(&msg);
  int turns = parser::get_int(&msg);
  int catchs = parser::get_int(&msg);
  int moves = parser::get_int(&msg);
  int turn_necks = parser::get_int(&msg);
  int change_views = parser::get_int(&msg);
  int says = parser::get_int(&msg);

  int arm_movable_ban = parser::get_int(&msg); // 直到下次手臂能动的剩余周期数
  int arm_expires = parser::get_int(&msg); // 直到手臂动作失效剩余的周期数
  double arm_target_dist = parser::get_double(&msg); // 指向的目标的距离
  AngleDeg arm_target_dir = parser::get_double(&msg); // 指向的目标的方向
  int arm_count = parser::get_int(&msg);              // point count

  mpObserver->SetSensePartialBody(
      view_width,

      kicks, dashes, turns, says, turn_necks, catchs, moves, change_views,

      arm_movable_ban, arm_expires, arm_target_dist, arm_target_dir, arm_count,

      mpObserver->CurrentTime());

  for (int i = 1; i <= TEAMSIZE; ++i) {
    mpObserver->Teammate_Fullstate(i).SetIsAlive(false);
    mpObserver->Opponent_Fullstate(i).SetIsAlive(false);
  }

  msg = strstr(msg, "((");

  while (msg != 0) {                           // 直到没有object为止
    msg += 2;                                  // 跳过 ((
    ObjType obj = ParseObjType_Fullstate(msg); // 获得object的类型
    msg = strchr(msg, ')');
    ObjProperty_Fullstate prop =
        ParseObjProperty_Fullstate(msg + 1); // 获得object的属性

    switch (obj.type) {
    case OBJ_Ball:
      mpObserver->Ball_Fullstate().UpdatePos(Vector(prop.x, prop.y), 0, 1.0);
      mpObserver->Ball_Fullstate().UpdateVel(Vector(prop.vx, prop.vy), 0, 1.0);
      break;
    case OBJ_Player:
      if (obj.side == mpObserver->OurSide()) {
        mpObserver->Teammate_Fullstate(obj.num).UpdatePlayerType(
            obj.player_type);
        mpObserver->Teammate_Fullstate(obj.num).SetIsAlive(true);
        mpObserver->Teammate_Fullstate(obj.num).UpdatePos(
            Vector(prop.x, prop.y), 0, 1.0);
        mpObserver->Teammate_Fullstate(obj.num).UpdateVel(
            Vector(prop.vx, prop.vy), 0, 1.0);
        mpObserver->Teammate_Fullstate(obj.num).UpdateBodyDir(prop.body_dir, 0,
                                                              1.0);
        mpObserver->Teammate_Fullstate(obj.num).UpdateNeckDir(prop.head_dir, 0,
                                                              1.0);
        mpObserver->Teammate_Fullstate(obj.num).UpdateStamina(prop.stamina);
        mpObserver->Teammate_Fullstate(obj.num).UpdateEffort(prop.effort);
        mpObserver->Teammate_Fullstate(obj.num).UpdateRecovery(prop.recovery);
        mpObserver->Teammate_Fullstate(obj.num).UpdateCapacity(prop.capacity);
        mpObserver->Teammate_Fullstate(obj.num).UpdateCardType(prop.card_type);

        if (prop.pointing) {
          mpObserver->Teammate_Fullstate(obj.num).UpdateArmPoint(
              prop.point_dir, 0, 1.0, 0.0, 0, 0);
          // TODO:
          // 这个接口不好，因为是看不到dist，ban等信息的，这些要自己算然后维护
        }
        if (prop.tackling) {
          if (mpObserver->Teammate_Fullstate(obj.num).GetTackleBan() == 0) {
            mpObserver->Teammate_Fullstate(obj.num).UpdateTackleBan(
                ServerParam::instance().tackleCycles() - 1);
          }
        } else {
          mpObserver->Teammate_Fullstate(obj.num).UpdateTackleBan(0);
        }
        if (prop.lying) {
          if (mpObserver->Teammate_Fullstate(obj.num).GetFoulChargedCycle() ==
              0) {
            mpObserver->Teammate_Fullstate(obj.num).UpdateFoulChargedCycle(
                ServerParam::instance().foulCycles() - 1);
          }
        } else {
          mpObserver->Teammate_Fullstate(obj.num).UpdateFoulChargedCycle(0);
        }
      } else {
        mpObserver->Opponent_Fullstate(obj.num).UpdatePlayerType(
            obj.player_type);
        mpObserver->Opponent_Fullstate(obj.num).SetIsAlive(true);
        mpObserver->Opponent_Fullstate(obj.num).UpdatePos(
            Vector(prop.x, prop.y), 0, 1.0);
        mpObserver->Opponent_Fullstate(obj.num).UpdateVel(
            Vector(prop.vx, prop.vy), 0, 1.0);
        mpObserver->Opponent_Fullstate(obj.num).UpdateBodyDir(prop.body_dir, 0,
                                                              1.0);
        mpObserver->Opponent_Fullstate(obj.num).UpdateNeckDir(prop.head_dir, 0,
                                                              1.0);
        mpObserver->Opponent_Fullstate(obj.num).UpdateStamina(prop.stamina);
        mpObserver->Opponent_Fullstate(obj.num).UpdateEffort(prop.effort);
        mpObserver->Opponent_Fullstate(obj.num).UpdateRecovery(prop.recovery);
        mpObserver->Opponent_Fullstate(obj.num).UpdateCapacity(prop.capacity);
        mpObserver->Opponent_Fullstate(obj.num).UpdateCardType(prop.card_type);

        if (prop.pointing) {
          mpObserver->Opponent_Fullstate(obj.num).UpdateArmPoint(
              prop.point_dir, 0, 1.0, 0.0, 0, 0);
          // TODO:
          // 这个接口不好，因为是看不到dist，ban等信息的，这些要自己算然后维护
        }
        if (prop.tackling) {
          if (mpObserver->Opponent_Fullstate(obj.num).GetTackleBan() == 0) {
            mpObserver->Opponent_Fullstate(obj.num).UpdateTackleBan(
                ServerParam::instance().tackleCycles() - 1);
          }
        } else {
          mpObserver->Opponent_Fullstate(obj.num).UpdateTackleBan(0);
        }
        if (prop.lying) {
          if (mpObserver->Opponent_Fullstate(obj.num).GetFoulChargedCycle() ==
              0) {
            mpObserver->Opponent_Fullstate(obj.num).UpdateFoulChargedCycle(
                ServerParam::instance().foulCycles() - 1);
          }
        } else {
          mpObserver->Opponent_Fullstate(obj.num).UpdateFoulChargedCycle(0);
        }
      }
      break;
    default:
      break;
    }
    msg = strstr(msg, "(("); // 下一个object
  }

  mpObserver->mReceiveFullstateMsg = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
leaq -0x30(%rbp), %rdi
movq %rsi, (%rdi)
callq 0x38103
movq 0x10(%rbx), %rcx
cmpl 0xc(%rcx), %eax
je 0x362c6
movl 0x10(%rcx), %edx
shlq $0x20, %rdx
movl %eax, %eax
orq %rdx, %rax
movq %rax, 0xc(%rcx)
leaq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x38145
movq %r14, %rdi
callq 0x38180
movq %r14, %rdi
callq 0x38145
movq (%r14), %rsi
leaq -0x1(%rsi), %r12
movabsq $-0x100000000, %r14     # imm = 0xFFFFFFFF00000000
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %r14
cmpb $0x29, 0x1(%r12)
leaq 0x1(%r12), %r12
jne 0x362fd
sarq $0x20, %r14
leaq 0x312438(%rip), %r15    # 0x348750
movq %r15, %rdi
movq %r14, %rdx
callq 0x9290
movb $0x0, (%r14,%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x36ce0
leaq -0x30(%rbp), %r14
movq %r12, (%r14)
movq %r14, %rdi
callq 0x38180
movq %r14, %rdi
callq 0x38180
movq (%r14), %rax
movzbl 0x1(%rax), %eax
cmpl $0x61, %eax
je 0x3636a
cmpl $0x69, %eax
je 0x36366
xorl %ecx, %ecx
cmpl $0x6f, %eax
jne 0x3636d
pushq $0x2
jmp 0x3636c
pushq $0x3
jmp 0x3636c
pushq $0x1
popq %rcx
movl %ecx, -0x50(%rbp)
leaq -0x30(%rbp), %r13
movq %r13, %rdi
callq 0x38103
movl %eax, -0x4c(%rbp)
movq %r13, %rdi
callq 0x38103
movl %eax, -0x48(%rbp)
movq %r13, %rdi
callq 0x38103
movl %eax, -0x44(%rbp)
movq %r13, %rdi
callq 0x38103
movq %rax, -0xf0(%rbp)
movq %r13, %rdi
callq 0x38103
movq %rax, -0xe8(%rbp)
movq %r13, %rdi
callq 0x38103
movq %rax, -0xe0(%rbp)
movq %r13, %rdi
callq 0x38103
movq %rax, -0xd8(%rbp)
movq %r13, %rdi
callq 0x38103
movl %eax, %r14d
movq %r13, %rdi
callq 0x38103
movl %eax, %r12d
movq %r13, %rdi
callq 0x38103
movl %eax, %r15d
movq %r13, %rdi
callq 0x381af
movsd %xmm0, -0xd0(%rbp)
movq %r13, %rdi
callq 0x381af
movsd %xmm0, -0xc8(%rbp)
movq %r13, %rdi
callq 0x38103
movq 0x10(%rbx), %rdi
movl -0x50(%rbp), %esi
movl -0x4c(%rbp), %edx
movl -0x48(%rbp), %ecx
movl -0x44(%rbp), %r8d
movl %r14d, %r9d
movsd -0xd0(%rbp), %xmm0
movsd -0xc8(%rbp), %xmm1
pushq 0xc(%rdi)
pushq %rax
pushq %r15
pushq %r12
pushq -0xd8(%rbp)
pushq -0xe8(%rbp)
pushq -0xf0(%rbp)
pushq -0xe0(%rbp)
callq 0x330a2
addq $0x40, %rsp
movl $0x35e8, %r14d          # imm = 0x35E8
cmpq $0x4610, %r14           # imm = 0x4610
je 0x364a3
movq 0x10(%rbx), %rdi
addq %r14, %rdi
xorl %esi, %esi
callq 0x381ec
movq 0x10(%rbx), %rax
leaq (%rax,%r14), %rdi
addq $0x1028, %rdi           # imm = 0x1028
xorl %esi, %esi
callq 0x381ec
addq $0x178, %r14            # imm = 0x178
jmp 0x3646d
movq -0x30(%rbp), %rdi
leaq 0x224fd(%rip), %r14     # 0x589ab
movq %r14, %rsi
callq 0x9140
leaq -0x108(%rbp), %r13
pushq $0x29
popq %r15
testq %rax, %rax
je 0x368ec
addq $0x2, %rax
movq %rax, -0x30(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x3721e
movq -0x30(%rbp), %rdi
movl %r15d, %esi
callq 0x91f0
movq %rax, -0x30(%rbp)
leaq 0x1(%rax), %rdx
leaq -0xc0(%rbp), %rdi
callq 0x3728c
movl -0x108(%rbp), %eax
cmpl $0x4, %eax
je 0x3656f
cmpl $0x1, %eax
jne 0x368d7
movq 0x10(%rbx), %rdi
movl $0x3570, %eax           # imm = 0x3570
addq %rax, %rdi
movups -0xc0(%rbp), %xmm0
movups %xmm0, -0x40(%rbp)
leaq -0x40(%rbp), %r12
movq %r12, %rsi
xorl %edx, %edx
movsd 0x20b0c(%rip), %xmm0    # 0x57048
callq 0xde1c
movq 0x10(%rbx), %rdi
movl $0x3570, %eax           # imm = 0x3570
addq %rax, %rdi
movups -0xb0(%rbp), %xmm0
movups %xmm0, -0x40(%rbp)
movq %r12, %rsi
xorl %edx, %edx
movsd 0x20ae3(%rip), %xmm0    # 0x57048
callq 0xdde8
jmp 0x368d7
movq %r13, %r14
movb -0xfc(%rbp), %cl
movq 0x10(%rbx), %rdi
movslq -0xf8(%rbp), %rax
decq %rax
movl -0xf4(%rbp), %esi
cmpb 0x29(%rdi), %cl
jne 0x36718
imulq $0x178, %rax, %r13      # imm = 0x178
movl $0x35e8, %r12d          # imm = 0x35E8
addq %r12, %rdi
addq %r13, %rdi
callq 0x38238
movq 0x10(%rbx), %rax
leaq (%rax,%r12), %rdi
addq %r13, %rdi
movb $0x1, 0x36fa(%rax,%r13)
movups -0xc0(%rbp), %xmm0
movups %xmm0, -0x40(%rbp)
leaq -0x40(%rbp), %r15
movq %r15, %rsi
xorl %edx, %edx
movsd 0x20a6b(%rip), %xmm0    # 0x57048
callq 0xde1c
movq 0x10(%rbx), %rdi
addq %r13, %rdi
addq %r12, %rdi
movups -0xb0(%rbp), %xmm0
movups %xmm0, -0x40(%rbp)
movq %r15, %rsi
xorl %edx, %edx
movsd 0x20a44(%rip), %xmm0    # 0x57048
callq 0xdde8
movq 0x10(%rbx), %rdi
addq %r13, %rdi
addq %r12, %rdi
movsd -0xa0(%rbp), %xmm0
xorl %esi, %esi
movsd 0x20a23(%rip), %xmm1    # 0x57048
callq 0x382a6
movq 0x10(%rbx), %rdi
addq %r13, %rdi
addq %r12, %rdi
movsd -0x98(%rbp), %xmm0
xorl %esi, %esi
movsd 0x20a02(%rip), %xmm1    # 0x57048
callq 0x382f8
movq 0x10(%rbx), %rcx
leaq (%rcx,%r12), %rdi
addq %r13, %rdi
movsd -0x78(%rbp), %xmm0
movsd %xmm0, 0x3660(%rcx,%r13)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x3668(%rcx,%r13)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, 0x3678(%rcx,%r13)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, 0x3670(%rcx,%r13)
movl -0x54(%rbp), %eax
movl 0x3758(%rcx,%r13), %ecx
testl %ecx, %ecx
je 0x366ab
cmpl $0x2, %eax
jne 0x366b1
cmpl $0x1, %ecx
jne 0x366b1
movl %eax, 0x170(%rdi)
cmpb $0x1, -0x90(%rbp)
jne 0x366d5
movsd -0x80(%rbp), %xmm0
xorps %xmm2, %xmm2
xorl %esi, %esi
movsd 0x2097c(%rip), %xmm1    # 0x57048
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3834a
movq 0x10(%rbx), %rax
leaq (%rax,%r13), %r12
addq $0x36b0, %r12           # imm = 0x36B0
xorl %eax, %eax
cmpb $0x1, -0x58(%rbp)
jne 0x36700
cmpl $0x0, (%r12)
jne 0x36704
callq 0x3db2c
movl 0x3320(%rax), %eax
decl %eax
movl %eax, (%r12)
movq 0x10(%rbx), %rax
leaq (%rax,%r13), %r12
addq $0x370c, %r12           # imm = 0x370C
jmp 0x36896
imulq $0x178, %rax, %r13      # imm = 0x178
movl $0x4610, %r12d          # imm = 0x4610
addq %r12, %rdi
addq %r13, %rdi
callq 0x38238
movq 0x10(%rbx), %rax
leaq (%rax,%r12), %rdi
addq %r13, %rdi
movb $0x1, 0x4722(%rax,%r13)
movups -0xc0(%rbp), %xmm0
movups %xmm0, -0x40(%rbp)
leaq -0x40(%rbp), %r15
movq %r15, %rsi
xorl %edx, %edx
movsd 0x208e8(%rip), %xmm0    # 0x57048
callq 0xde1c
movq 0x10(%rbx), %rdi
addq %r13, %rdi
addq %r12, %rdi
movups -0xb0(%rbp), %xmm0
movups %xmm0, -0x40(%rbp)
movq %r15, %rsi
xorl %edx, %edx
movsd 0x208c1(%rip), %xmm0    # 0x57048
callq 0xdde8
movq 0x10(%rbx), %rdi
addq %r13, %rdi
addq %r12, %rdi
movsd -0xa0(%rbp), %xmm0
xorl %esi, %esi
movsd 0x208a0(%rip), %xmm1    # 0x57048
callq 0x382a6
movq 0x10(%rbx), %rdi
addq %r13, %rdi
addq %r12, %rdi
movsd -0x98(%rbp), %xmm0
xorl %esi, %esi
movsd 0x2087f(%rip), %xmm1    # 0x57048
callq 0x382f8
movq 0x10(%rbx), %rcx
leaq (%rcx,%r12), %rdi
addq %r13, %rdi
movsd -0x78(%rbp), %xmm0
movsd %xmm0, 0x4688(%rcx,%r13)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, 0x4690(%rcx,%r13)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, 0x46a0(%rcx,%r13)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, 0x4698(%rcx,%r13)
movl -0x54(%rbp), %eax
movl 0x4780(%rcx,%r13), %ecx
testl %ecx, %ecx
je 0x3682e
cmpl $0x2, %eax
jne 0x36834
cmpl $0x1, %ecx
jne 0x36834
movl %eax, 0x170(%rdi)
cmpb $0x1, -0x90(%rbp)
jne 0x36858
movsd -0x80(%rbp), %xmm0
xorps %xmm2, %xmm2
xorl %esi, %esi
movsd 0x207f9(%rip), %xmm1    # 0x57048
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3834a
movq 0x10(%rbx), %rax
leaq (%rax,%r13), %r12
addq $0x46d8, %r12           # imm = 0x46D8
xorl %eax, %eax
cmpb $0x1, -0x58(%rbp)
jne 0x36883
cmpl $0x0, (%r12)
jne 0x36887
callq 0x3db2c
movl 0x3320(%rax), %eax
decl %eax
movl %eax, (%r12)
movq 0x10(%rbx), %rax
leaq (%rax,%r13), %r12
addq $0x4734, %r12           # imm = 0x4734
cmpb $0x1, -0x57(%rbp)
jne 0x368c4
cmpl $0x0, (%r12)
movq %r14, %r13
leaq 0x22100(%rip), %r14     # 0x589ab
pushq $0x29
popq %r15
jne 0x368d7
callq 0x3db2c
movl 0x33e8(%rax), %eax
decl %eax
movl %eax, (%r12)
jmp 0x368d7
andl $0x0, (%r12)
movq %r14, %r13
leaq 0x220d8(%rip), %r14     # 0x589ab
pushq $0x29
popq %r15
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x9140
movq %rax, -0x30(%rbp)
jmp 0x364c1
movq 0x10(%rbx), %rax
movb $0x1, 0x8(%rax)
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq