// File: /workspace/github_cpp_makefile_star2_O1/wrighteagle2d[P]wrighteaglebase/Debug/../src/ActionEffector.cpp
// Function: ActionEffector::SendCommands(char*)
void ActionEffector::SendCommands(char *msg) {
  if (PlayerParam::instance().isCoach() ||
      PlayerParam::instance().isTrainer()) {
    // Coach分条发送命令
    ActionEffector::CMD_QUEUE_MUTEX.Lock();
    for (std::list<CommandInfo>::iterator it = mCommandQueue.begin();
         it != mCommandQueue.end(); ++it) {
      if (it->mType != CT_None &&
          it->mTime == mWorldState.CurrentTime()) // TODO: seg fault here
      {
        NetworkTest::instance().SetCommandSendCount((*it));
      }
      if (!it->mString.empty()) {
        if (PlayerParam::instance().DynamicDebugMode()) {
          std::cerr << std::endl
                    << it->mString.c_str(); // 动态调试模式，直接输出命令即可
        } else if (UDPSocket::instance().Send(it->mString.c_str()) <
                   0) // 发送命令
        {
          PRINT_ERROR("UDPSocket error!");
        }
      }
      if (PlayerParam::instance().SaveServerMessage() &&
          msg != 0) //说明要记录命令信息
      {
        strcat(msg, it->mString.c_str());
      }
    }
    ActionEffector::CMD_QUEUE_MUTEX.UnLock();
  } else {
    //球员把命令放在一起发
    static char command_msg[MAX_MESSAGE];

    command_msg[0] = '\0';
    ActionEffector::CMD_QUEUE_MUTEX.Lock();
    for (std::list<CommandInfo>::iterator it = mCommandQueue.begin();
         it != mCommandQueue.end(); ++it) {
      if (it->mType != CT_None && it->mTime == mWorldState.CurrentTime()) {
        strcat(command_msg, it->mString.c_str());
        NetworkTest::instance().SetCommandSendCount((*it));
      }
    }
    ActionEffector::CMD_QUEUE_MUTEX.UnLock();

    if (command_msg[0] != '\0') {
      if (PlayerParam::instance().DynamicDebugMode()) {
        std::cerr << std::endl << command_msg; // 动态调试模式，直接输出命令即可
      } else if (UDPSocket::instance().Send(command_msg) < 0) // 发送命令
      {
        PRINT_ERROR("UDPSocket error!");
      }
    }
    if (PlayerParam::instance().SaveServerMessage() &&
        msg != 0) //说明要记录命令信息
    {
      strcat(msg, command_msg);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, -0x30(%rbp)
callq 0x450ba
cmpb $0x0, 0x31a5(%rax)
jne 0xe45d
callq 0x450ba
cmpb $0x1, 0x31a6(%rax)
jne 0xe62c
leaq 0x79114(%rip), %rdi     # 0x87578
callq 0x4f686
movq -0x30(%rbp), %rax
leaq 0x28(%rax), %r15
movq 0x28(%rax), %r14
cmpq %r15, %r14
je 0xe612
cmpl $0x0, 0x10(%r14)
je 0xe4b3
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x28(%r14), %ecx
cmpl 0x14(%rax), %ecx
jne 0xe4b3
movl 0x10(%rax), %eax
cmpl %eax, 0x24(%r14)
jne 0xe4b3
leaq 0x10(%r14), %r12
callq 0x3974e
movq %rax, %rdi
movq %r12, %rsi
callq 0x3a0a4
cmpq $0x0, 0x68(%r14)
je 0xe5eb
callq 0x450ba
cmpb $0x1, 0x5c40(%rax)
jne 0xe526
movq 0x78b1d(%rip), %r12     # 0x86ff0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r12, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
movq %rax, %r12
movq 0x60(%r14), %r13
testq %r13, %r13
je 0xe5d0
movq %r13, %rdi
callq 0x9200
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x9560
jmp 0xe5eb
callq 0x55830
movq 0x60(%r14), %rsi
movq %rax, %rdi
callq 0x55b22
testl %eax, %eax
jns 0xe5eb
movl $0x19, %edx
movq 0x78aa5(%rip), %r12     # 0x86ff0
movq %r12, %rdi
leaq 0x5cc62(%rip), %rsi     # 0x6b1b7
callq 0x9560
movl $0x1, %edx
movq %r12, %rdi
leaq 0x60c59(%rip), %rsi     # 0x6f1c2
callq 0x9560
movq %r12, %rdi
movl $0x486, %esi            # imm = 0x486
callq 0x9880
movq %rax, %r12
movl $0x3, %edx
movq %rax, %rdi
leaq 0x5eef2(%rip), %rsi     # 0x6d47f
callq 0x9560
movl $0x10, %edx
movq %r12, %rdi
leaq 0x5cc30(%rip), %rsi     # 0x6b1d1
callq 0x9560
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r12, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
jmp 0xe5eb
movq (%r12), %rax
movq -0x18(%rax), %rax
movq %r12, %rdi
addq %rax, %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x9860
callq 0x450ba
testq %rbx, %rbx
je 0xe60a
cmpb $0x0, 0x5c42(%rax)
je 0xe60a
movq 0x60(%r14), %rsi
movq %rbx, %rdi
callq 0x98c0
movq (%r14), %r14
jmp 0xe475
leaq 0x78f5f(%rip), %rdi     # 0x87578
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4f6a2
movb $0x0, 0x78f6d(%rip)     # 0x875a0
leaq 0x78f3e(%rip), %rdi     # 0x87578
callq 0x4f686
movq -0x30(%rbp), %rax
leaq 0x28(%rax), %r14
movq 0x28(%rax), %r13
cmpq %r14, %r13
je 0xe6a1
leaq 0x78f49(%rip), %r15     # 0x875a0
cmpl $0x0, 0x10(%r13)
je 0xe698
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x28(%r13), %ecx
cmpl 0x14(%rax), %ecx
jne 0xe698
movl 0x10(%rax), %eax
cmpl %eax, 0x24(%r13)
jne 0xe698
leaq 0x10(%r13), %r12
movq 0x60(%r13), %rsi
movq %r15, %rdi
callq 0x98c0
callq 0x3974e
movq %rax, %rdi
movq %r12, %rsi
callq 0x3a0a4
movq (%r13), %r13
cmpq %r14, %r13
jne 0xe657
leaq 0x78ed0(%rip), %rdi     # 0x87578
callq 0x4f6a2
cmpb $0x0, 0x78eec(%rip)     # 0x875a0
je 0xe7c5
callq 0x450ba
cmpb $0x1, 0x5c40(%rax)
jne 0xe71b
movq 0x78921(%rip), %r14     # 0x86ff0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r14, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
movq %rax, %r14
leaq 0x78ea0(%rip), %r15     # 0x875a0
movq %r15, %rdi
callq 0x9200
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x9560
jmp 0xe7c5
callq 0x55830
leaq 0x78e79(%rip), %rsi     # 0x875a0
movq %rax, %rdi
callq 0x55b22
testl %eax, %eax
jns 0xe7c5
movq 0x788b2(%rip), %r14     # 0x86ff0
leaq 0x5ca72(%rip), %rsi     # 0x6b1b7
movl $0x19, %edx
movq %r14, %rdi
callq 0x9560
leaq 0x60a69(%rip), %rsi     # 0x6f1c2
movl $0x1, %edx
movq %r14, %rdi
callq 0x9560
movq %r14, %rdi
movl $0x4a4, %esi            # imm = 0x4A4
callq 0x9880
movq %rax, %r14
leaq 0x5ed02(%rip), %rsi     # 0x6d47f
movl $0x3, %edx
movq %rax, %rdi
callq 0x9560
leaq 0x5ca40(%rip), %rsi     # 0x6b1d1
movl $0x10, %edx
movq %r14, %rdi
callq 0x9560
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r14, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
callq 0x450ba
testq %rbx, %rbx
je 0xe7f5
cmpb $0x0, 0x5c42(%rax)
je 0xe7f5
leaq 0x78dc1(%rip), %rsi     # 0x875a0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x98c0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq