// File: /workspace/github_cpp_makefile_star2_O1/wrighteagle2d[P]wrighteaglebase/Debug/../src/Formation.cpp
// Function: OpponentFormation::SetFormationRole()
void OpponentFormation::SetFormationRole() {
  mLineArrange[0] = 1;
  mLineArrange[1] = mLineMember[0].size();
  mLineArrange[2] = mLineMember[1].size();
  mLineArrange[3] = mLineMember[2].size();
  //建立位置索引
  //第一个是门将，索引(0,1)
  //其他队员
  int xidx;
  int yidx;
  int n;
  for (n = 1; n <= 11; n++)
    mPlayerRole[n].mLineType = LT_Null;
  for (xidx = 1; xidx <= 3; xidx++) {
    for (yidx = 1; yidx <= mLineArrange[xidx]; yidx++) {
      n = mLineMember[xidx - 1][yidx - 1]; // 得到号码
      if (n == mGoalieUnum) {
        mPos2Index[0][1] = n;
        mPlayerRole[mGoalieUnum].mIndexX = 0;
        mPlayerRole[mGoalieUnum].mIndexY = 1;
        mPlayerRole[mGoalieUnum].mLineType = LT_Goalie;
      } else {
        mPos2Index[xidx][yidx] = n;
        mPlayerRole[n].mIndexX = xidx;
        mPlayerRole[n].mIndexY = yidx;
        mPlayerRole[n].mLineType = LineType(xidx + 1);
        double midoffset = yidx - (mLineArrange[xidx] + 1) * 0.5;
        if (fabs(midoffset) < FLOAT_EPS) {
          mPlayerRole[n].mPositionType = PT_Middle;
        } else if (fabs(midoffset - 0.5) < FLOAT_EPS) {
          mPlayerRole[n].mPositionType = PT_RightMiddle;
        } else if (fabs(midoffset + 0.5) < FLOAT_EPS) {
          mPlayerRole[n].mPositionType = PT_LeftMiddle;
        } else if (fabs(midoffset - 1.25) < 0.25 + FLOAT_EPS) { // 1.5 or 1.0
          mPlayerRole[n].mPositionType = PT_Right;
        } else if (fabs(midoffset + 1.25) < 0.25 + FLOAT_EPS) { // 1.5 or 1.0
          mPlayerRole[n].mPositionType = PT_Left;
        } else if (midoffset > 2.0 - FLOAT_EPS) {
          mPlayerRole[n].mPositionType = PT_RightRight;
        } else {
          mPlayerRole[n].mPositionType = PT_LeftLeft;
        }
      }
    }
  }
}

// Assembly:
movl $0x1, 0x40(%rdi)
movq 0xc98(%rdi), %rax
movq 0xcb0(%rdi), %rcx
subq 0xc90(%rdi), %rax
shrq $0x2, %rax
movl %eax, 0x44(%rdi)
subq 0xca8(%rdi), %rcx
shrq $0x2, %rcx
movl %ecx, 0x48(%rdi)
movq 0xcc8(%rdi), %rcx
subq 0xcc0(%rdi), %rcx
leaq 0xc90(%rdi), %rax
shrq $0x2, %rcx
movl %ecx, 0x4c(%rdi)
xorl %ecx, %ecx
movl $0xffffffff, 0x68(%rdi,%rcx) # imm = 0xFFFFFFFF
addq $0x10, %rcx
cmpq $0xb0, %rcx
jne 0x267c9
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
leaq 0x60(%rdi), %rcx
leaq 0x2a0(%rdi), %rdx
movl $0x1, %esi
movabsq $0x100000000, %r8       # imm = 0x100000000
movsd 0x4487f(%rip), %xmm0    # 0x6b088
movapd 0x447ff(%rip), %xmm1    # 0x6b010
movsd 0x44827(%rip), %xmm2    # 0x6b040
movsd 0x45057(%rip), %xmm3    # 0x6b878
movsd 0x45dbf(%rip), %xmm4    # 0x6c5e8
movsd 0x45dbf(%rip), %xmm5    # 0x6c5f0
movsd 0x45dbf(%rip), %xmm6    # 0x6c5f8
movsd 0x45dbf(%rip), %xmm7    # 0x6c600
cmpl $0x0, 0x40(%rdi,%rsi,4)
jle 0x26994
leaq (%rsi,%rsi,2), %r9
movq -0x18(%rax,%r9,8), %r9
leal 0x1(%rsi), %r10d
xorl %r11d, %r11d
movl (%r9,%r11,4), %r14d
movslq 0xce8(%rdi), %rbx
cmpl %ebx, %r14d
jne 0x26889
movl %r14d, 0x274(%rdi)
shlq $0x4, %rbx
movq %r8, -0x10(%rbx,%rcx)
movl $0x0, -0x8(%rbx,%rcx)
jmp 0x26983
movslq %r14d, %r15
movl %r14d, (%rdx,%r11,4)
shlq $0x4, %r15
leaq (%r15,%rcx), %rbx
addq $-0x10, %rbx
movl %esi, -0x10(%r15,%rcx)
leal 0x1(%r11), %r14d
movl %r14d, -0xc(%r15,%rcx)
movl %r10d, -0x8(%r15,%rcx)
xorps %xmm9, %xmm9
cvtsi2sd %r14d, %xmm9
movl 0x40(%rdi,%rsi,4), %r14d
incl %r14d
xorps %xmm8, %xmm8
cvtsi2sd %r14d, %xmm8
mulsd %xmm0, %xmm8
addsd %xmm9, %xmm8
movapd %xmm8, %xmm9
andpd %xmm1, %xmm9
ucomisd %xmm9, %xmm2
jbe 0x268f0
movl $0x2, 0xc(%rbx)
jmp 0x26983
movapd %xmm8, %xmm9
addsd %xmm0, %xmm9
andpd %xmm1, %xmm9
ucomisd %xmm9, %xmm2
jbe 0x2690f
movl $0x5, 0xc(%rbx)
jmp 0x26983
movapd %xmm8, %xmm9
addsd %xmm3, %xmm9
andpd %xmm1, %xmm9
ucomisd %xmm9, %xmm2
jbe 0x2692e
movl $0x6, 0xc(%rbx)
jmp 0x26983
movapd %xmm8, %xmm9
addsd %xmm4, %xmm9
andpd %xmm1, %xmm9
ucomisd %xmm9, %xmm5
jbe 0x2694d
movl $0x3, 0xc(%rbx)
jmp 0x26983
movapd %xmm8, %xmm9
addsd %xmm6, %xmm9
andpd %xmm1, %xmm9
ucomisd %xmm9, %xmm5
jbe 0x2696c
movl $0x1, 0xc(%rbx)
jmp 0x26983
ucomisd %xmm7, %xmm8
jbe 0x2697c
movl $0x4, 0xc(%rbx)
jmp 0x26983
movl $0x7, 0xc(%rbx)
movslq 0x40(%rdi,%rsi,4), %rbx
incq %r11
cmpq %rbx, %r11
jl 0x2685c
incq %rsi
addq $0x2c, %rdx
cmpq $0x4, %rsi
jne 0x26841
popq %rbx
popq %r14
popq %r15
popq %rbp
retq