// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/WorldState.cpp
// Function: WorldStateUpdater::UpdateInfoFromPlayMode()
void WorldStateUpdater::UpdateInfoFromPlayMode() {
  double x, y;

  switch (mpWorldState->GetPlayMode()) {
  case PM_Our_Kick_Off:
  case PM_Opp_Kick_Off:
  case PM_Before_Kick_Off:
  case PM_Goal_Opps:
  case PM_Goal_Ours:
    Ball().UpdatePos(Vector(0, 0));
    Ball().UpdateVel(Vector(0, 0));
    break;

  case PM_Our_Penalty_Setup:
  case PM_Opp_Penalty_Setup:
    Ball().UpdatePos(Vector(ServerParam::instance().PITCH_LENGTH / 2.0 -
                                ServerParam::instance().penDistX(),
                            0.0));
    Ball().UpdateVel(Vector(0, 0));
    break;

  case PM_Our_Goalie_Free_Kick:
    Ball().UpdateVel(Vector(0, 0));
    if (mSelfUnum == mpWorldState->GetTeammateGoalieUnum()) {
      const PlayerState &self_state = mpWorldState->GetTeammate(mSelfUnum);
      const double dist =
          self_state.GetPlayerSize() + ServerParam::instance().ballSize();
      Ball().UpdatePos(self_state.GetPos() +
                       Vector(dist, 0.0).Rotate(self_state.GetBodyDir()));
    }
    break;

  case PM_Our_Kick_In:
  case PM_Opp_Kick_In:
    x = Ball().GetPos().X();
    y = Sign(mpWorldState->GetHistory(1)->GetBall().GetPos().Y()) *
        ServerParam::instance().PITCH_WIDTH * 0.5;
    Ball().UpdatePos(Vector(x, y));
    Ball().UpdateVel(Vector(0, 0));
    break;

  case PM_Our_Corner_Kick:
    x = ServerParam::instance().PITCH_LENGTH * 0.5 - 1.0;
    y = Sign(mpWorldState->GetHistory(1)->GetBall().GetPos().Y()) *
        (ServerParam::instance().PITCH_WIDTH * 0.5 - 1.0);
    Ball().UpdatePos(Vector(x, y));
    Ball().UpdateVel(Vector(0, 0));
    break;

  case PM_Opp_Corner_Kick:
    x = -ServerParam::instance().PITCH_LENGTH * 0.5 - 1.0;
    y = Sign(mpWorldState->GetHistory(1)->GetBall().GetPos().Y()) *
        (ServerParam::instance().PITCH_WIDTH * 0.5 - 1.0);
    Ball().UpdatePos(Vector(x, y));
    Ball().UpdateVel(Vector(0, 0));
    break;

  default:
    break;
  }

  //以下信息只在playMode改变时更新
  if (mpWorldState->GetPlayModeTime() == mpWorldState->CurrentTime()) {
    switch (mpWorldState->GetPlayMode()) {
    case PM_Our_Kick_Off:
    case PM_Opp_Kick_Off:
      // Ball().UpdatePos(Vector(0,0));
      // Ball().UpdateVel(Vector(0,0));
      break;
    case PM_Our_Goal_Kick:
      x = -1.0 * (ServerParam::instance().PITCH_LENGTH * 0.5 -
                  ServerParam::instance().GOAL_AREA_LENGTH);
      y = Sign(mpWorldState->GetHistory(1)->GetBall().GetPos().Y()) *
          ServerParam::instance().GOAL_AREA_WIDTH * 0.5;
      Ball().UpdatePos(Vector(x, y));
      Ball().UpdateVel(Vector(0, 0));
      break;
    case PM_Opp_Goal_Kick:
      x = 1.0 * (ServerParam::instance().PITCH_LENGTH * 0.5 -
                 ServerParam::instance().GOAL_AREA_LENGTH);
      y = Sign(mpWorldState->GetHistory(1)->GetBall().GetPos().Y()) *
          ServerParam::instance().GOAL_AREA_WIDTH * 0.5;
      Ball().UpdatePos(Vector(x, y));
      Ball().UpdateVel(Vector(0, 0));
      break;
    case PM_Our_Back_Pass_Kick:
    case PM_Opp_Back_Pass_Kick:
    case PM_Our_Foul_Charge_Kick:
    case PM_Opp_Foul_Charge_Kick:
      // TODO:we2008算法使用到了截球点,但是WE2009中此结果不支持使用截球信息,因此对此做了简化.
      Ball().UpdateVel(Vector(0, 0));
      break;
    case PM_Our_Offside_Kick:
    case PM_Opp_Offside_Kick:
      Ball().UpdateVel(Vector(0, 0));
      break;
    default:
      break;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %r14
movl 0x1c(%r14), %eax
leal -0x20(%rax), %ecx
pushq $0xa
popq %r12
cmpl $0x7, %ecx
jbe 0x50a92
leal -0x2(%rax), %ecx
cmpl $0x6, %ecx
ja 0x50b2e
leaq 0xace5(%rip), %rax      # 0x5b740
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
callq 0x3db2c
leaq 0x9458(%rip), %rax      # 0x59ec8
movsd 0x6dd0(%rip), %xmm1     # 0x57848
movsd (%rax), %xmm0
mulsd %xmm1, %xmm0
addsd 0x65e8(%rip), %xmm0     # 0x57070
movsd %xmm0, -0x50(%rbp)
jmp 0x50beb
leaq 0xacc3(%rip), %rax      # 0x5b75c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movsd 0x38(%r14), %xmm0
movsd %xmm0, -0x50(%rbp)
movq 0x8(%r14), %rcx
movl 0x14b90(%rcx), %eax
addl $0x9, %eax
cltd
idivl %r12d
movslq %edx, %rax
imulq $0x2128, %rax, %rax     # imm = 0x2128
xorpd %xmm0, %xmm0
cmplesd 0x40(%rcx,%rax), %xmm0
movapd %xmm0, -0x60(%rbp)
callq 0x3db2c
leaq 0x93ec(%rip), %rax      # 0x59ed0
movsd (%rax), %xmm0
movapd 0x6530(%rip), %xmm1     # 0x57020
xorpd %xmm0, %xmm1
movapd -0x60(%rbp), %xmm2
andpd %xmm2, %xmm0
andnpd %xmm1, %xmm2
orpd %xmm0, %xmm2
mulsd 0x6d3b(%rip), %xmm2     # 0x57848
movq 0x8(%rbx), %rdi
addq $0x30, %rdi
leaq -0x40(%rbp), %r14
movsd -0x50(%rbp), %xmm0
movsd %xmm0, (%r14)
movsd %xmm2, 0x8(%r14)
jmp 0x50c73
cmpl $0xe, %eax
je 0x50b54
cmpl $0x31, %eax
je 0x50b54
cmpl $0x16, %eax
jne 0x50ca7
addq $0x30, %r14
xorpd %xmm0, %xmm0
leaq -0x40(%rbp), %r15
movapd %xmm0, (%r15)
jmp 0x50b95
addq $0x30, %r14
callq 0x3db2c
leaq 0x9364(%rip), %rax      # 0x59ec8
movsd (%rax), %xmm0
mulsd 0x6cd8(%rip), %xmm0     # 0x57848
movsd %xmm0, -0x50(%rbp)
callq 0x3db2c
movsd -0x50(%rbp), %xmm0
subsd 0x3268(%rax), %xmm0
leaq -0x40(%rbp), %r15
movsd %xmm0, (%r15)
andq $0x0, 0x8(%r15)
movsd 0x64ab(%rip), %xmm0     # 0x57048
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xde1c
movq 0x8(%rbx), %rdi
addq $0x30, %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
jmp 0x50c94
callq 0x3db2c
leaq 0x92fe(%rip), %rax      # 0x59ec8
movsd 0x6c76(%rip), %xmm1     # 0x57848
movsd (%rax), %xmm0
mulsd %xmm1, %xmm0
movsd 0x648e(%rip), %xmm1     # 0x57070
subsd %xmm0, %xmm1
movsd %xmm1, -0x50(%rbp)
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rcx
movl 0x14b90(%rcx), %eax
addl $0x9, %eax
cltd
idivl %r12d
movslq %edx, %rax
imulq $0x2128, %rax, %rax     # imm = 0x2128
xorpd %xmm0, %xmm0
cmplesd 0x40(%rcx,%rax), %xmm0
movapd %xmm0, -0x60(%rbp)
callq 0x3db2c
leaq 0x92aa(%rip), %rax      # 0x59ed0
movsd 0x6c1a(%rip), %xmm1     # 0x57848
mulsd (%rax), %xmm1
addsd 0x6436(%rip), %xmm1     # 0x57070
movapd -0x60(%rbp), %xmm2
movapd %xmm2, %xmm0
andpd %xmm1, %xmm0
xorpd 0x63d1(%rip), %xmm1     # 0x57020
andnpd %xmm1, %xmm2
orpd %xmm0, %xmm2
movq 0x8(%rbx), %rdi
addq $0x30, %rdi
leaq -0x40(%rbp), %r14
movsd -0x50(%rbp), %xmm0
movsd %xmm0, (%r14)
movlpd %xmm2, 0x8(%r14)
movsd 0x63cd(%rip), %xmm0     # 0x57048
movq %r14, %rsi
xorl %edx, %edx
callq 0xde1c
movq 0x8(%rbx), %rdi
addq $0x30, %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
leaq -0x40(%rbp), %rsi
xorl %edx, %edx
movsd 0x63a6(%rip), %xmm0     # 0x57048
callq 0xdde8
movq 0x8(%rbx), %rdi
movl 0x28(%rdi), %eax
cmpl 0x14(%rdi), %eax
jne 0x50f7a
movl 0x10(%rdi), %eax
cmpl %eax, 0x24(%rdi)
jne 0x50f7a
movl 0x1c(%rdi), %eax
leal -0x5(%rax), %ecx
cmpl $0x8, %ecx
jbe 0x50da1
addl $-0x28, %eax
cmpl $0x8, %eax
ja 0x50f7a
leaq 0xaabb(%rip), %rcx      # 0x5b7a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x3db2c
leaq 0x91ce(%rip), %r14      # 0x59ec8
callq 0x3db2c
leaq 0x91f2(%rip), %rax      # 0x59ef8
movsd (%r14), %xmm0
mulsd 0x6b35(%rip), %xmm0     # 0x57848
subsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rcx
movl 0x14b90(%rcx), %eax
addl $0x9, %eax
cltd
idivl %r12d
movslq %edx, %rax
imulq $0x2128, %rax, %rax     # imm = 0x2128
xorpd %xmm0, %xmm0
cmplesd 0x40(%rcx,%rax), %xmm0
movapd %xmm0, -0x60(%rbp)
callq 0x3db2c
leaq 0x91a9(%rip), %rax      # 0x59f00
movsd (%rax), %xmm0
movapd 0x62bd(%rip), %xmm1     # 0x57020
xorpd %xmm0, %xmm1
movapd -0x60(%rbp), %xmm2
andpd %xmm2, %xmm0
andnpd %xmm1, %xmm2
orpd %xmm0, %xmm2
mulsd 0x6ac8(%rip), %xmm2     # 0x57848
movq 0x8(%rbx), %rdi
addq $0x30, %rdi
leaq -0x40(%rbp), %r14
movsd -0x50(%rbp), %xmm0
movsd %xmm0, (%r14)
movsd %xmm2, 0x8(%r14)
jmp 0x50f46
leaq 0xa9d4(%rip), %rax      # 0x5b77c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
addq $0x30, %rdi
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rsi
movaps %xmm0, (%rsi)
movsd 0x6281(%rip), %xmm0     # 0x57048
xorl %edx, %edx
jmp 0x50f75
addq $0x30, %r14
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rsi
movaps %xmm0, (%rsi)
movsd 0x6264(%rip), %xmm0     # 0x57048
movq %r14, %rdi
xorl %edx, %edx
callq 0xdde8
movslq 0x14(%rbx), %rax
movq 0x8(%rbx), %r13
cmpl 0x2110(%r13), %eax
jne 0x50ca7
imulq $0x178, %rax, %r12      # imm = 0x178
leaq (%r12,%r13), %r14
addq $-0xd0, %r14
movq %r14, %rdi
callq 0x2abf4
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
callq 0x3db2c
movsd -0x50(%rbp), %xmm0
addsd 0x30d8(%rax), %xmm0
movq 0x8(%rbx), %r15
addq $0x30, %r15
leaq -0x70(%rbp), %rdi
movsd %xmm0, (%rdi)
andq $0x0, 0x8(%rdi)
leaq (%r12,%r13), %rsi
addq $-0x20, %rsi
pushq $0xa
popq %r12
callq 0xd02c
addsd 0x8(%r14), %xmm0
addsd 0x10(%r14), %xmm1
leaq -0x40(%rbp), %rsi
movsd %xmm0, (%rsi)
movsd %xmm1, 0x8(%rsi)
movsd 0x61c9(%rip), %xmm0     # 0x57048
movq %r15, %rdi
xorl %edx, %edx
callq 0xde1c
jmp 0x50ca7
callq 0x3db2c
leaq 0x902e(%rip), %r14      # 0x59ec8
callq 0x3db2c
leaq 0x9052(%rip), %rax      # 0x59ef8
movsd (%r14), %xmm0
mulsd 0x6995(%rip), %xmm0     # 0x57848
subsd (%rax), %xmm0
xorpd 0x6161(%rip), %xmm0     # 0x57020
movapd %xmm0, -0x50(%rbp)
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rcx
movl 0x14b90(%rcx), %eax
addl $0x9, %eax
cltd
idivl %r12d
movslq %edx, %rax
imulq $0x2128, %rax, %rax     # imm = 0x2128
xorpd %xmm0, %xmm0
cmplesd 0x40(%rcx,%rax), %xmm0
movapd %xmm0, -0x60(%rbp)
callq 0x3db2c
leaq 0x9001(%rip), %rax      # 0x59f00
movsd (%rax), %xmm0
movapd 0x6115(%rip), %xmm2     # 0x57020
xorpd %xmm0, %xmm2
movapd -0x60(%rbp), %xmm3
movapd %xmm3, %xmm1
andnpd %xmm2, %xmm1
andpd %xmm0, %xmm3
orpd %xmm1, %xmm3
mulsd 0x691c(%rip), %xmm3     # 0x57848
movq 0x8(%rbx), %rdi
addq $0x30, %rdi
leaq -0x40(%rbp), %r14
movaps -0x50(%rbp), %xmm0
movlps %xmm0, (%r14)
movsd %xmm3, 0x8(%r14)
movsd 0x60fa(%rip), %xmm0     # 0x57048
movq %r14, %rsi
xorl %edx, %edx
callq 0xde1c
movq 0x8(%rbx), %rdi
addq $0x30, %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
leaq -0x40(%rbp), %rsi
xorl %edx, %edx
movsd 0x60d3(%rip), %xmm0     # 0x57048
callq 0xdde8
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop