// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
callq 0x38d94
cmpb $0x0, 0x31a5(%rax)
jne 0xca26
callq 0x38d94
cmpb $0x1, 0x31a6(%rax)
jne 0xcb5a
leaq 0x6ab4b(%rip), %rdi     # 0x77578
callq 0x4206e
leaq 0x28(%r14), %r15
movq %r15, %r13
movq (%r13), %r13
cmpq %r15, %r13
je 0xcb40
cmpl $0x0, 0x10(%r13)
je 0xca77
movq 0x10(%r14), %rax
movl 0x28(%r13), %ecx
cmpl 0x14(%rax), %ecx
jne 0xca77
movl 0x10(%rax), %eax
cmpl %eax, 0x24(%r13)
jne 0xca77
leaq 0x10(%r13), %r12
callq 0x3018a
movq %rax, %rdi
movq %r12, %rsi
callq 0x30854
cmpq $0x0, 0x68(%r13)
je 0xcb14
callq 0x38d94
cmpb $0x1, 0x5c40(%rax)
jne 0xcaaa
movq 0x6a559(%rip), %rdi     # 0x76ff0
callq 0x99e8
movq 0x60(%r13), %rsi
movq %rax, %rdi
callq 0x94b0
jmp 0xcb14
callq 0x471ac
movq 0x60(%r13), %rsi
movq %rax, %rdi
callq 0x473e8
testl %eax, %eax
jns 0xcb14
movq 0x6a52a(%rip), %rdi     # 0x76ff0
leaq 0x4a6da(%rip), %rsi     # 0x571a7
callq 0x94b0
movq %rax, %rdi
leaq 0x4e696(%rip), %rsi     # 0x5b172
callq 0x94b0
movq %rax, %rdi
movl $0x486, %esi            # imm = 0x486
callq 0x9890
movq %rax, %rdi
leaq 0x4c927(%rip), %rsi     # 0x5941f
callq 0x94b0
movq %rax, %rdi
leaq 0x4a6ba(%rip), %rsi     # 0x571c1
callq 0x94b0
movq %rax, %rdi
callq 0x99e8
callq 0x38d94
testq %rbx, %rbx
je 0xca39
cmpb $0x0, 0x5c42(%rax)
je 0xca39
movq 0x60(%r13), %rsi
movq %rbx, %rdi
callq 0x98c0
jmp 0xca39
leaq 0x6aa31(%rip), %rdi     # 0x77578
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4208a
movb $0x0, 0x6aa3f(%rip)     # 0x775a0
leaq 0x6aa10(%rip), %rdi     # 0x77578
callq 0x4206e
leaq 0x28(%r14), %r15
movq %r15, %r13
movq (%r13), %r13
cmpq %r15, %r13
je 0xcbc0
cmpl $0x0, 0x10(%r13)
je 0xcb74
movq 0x10(%r14), %rax
movl 0x28(%r13), %ecx
cmpl 0x14(%rax), %ecx
jne 0xcb74
movl 0x10(%rax), %eax
cmpl %eax, 0x24(%r13)
jne 0xcb74
leaq 0x10(%r13), %r12
movq 0x60(%r13), %rsi
leaq 0x6a9f7(%rip), %rdi     # 0x775a0
callq 0x98c0
callq 0x3018a
movq %rax, %rdi
movq %r12, %rsi
callq 0x30854
jmp 0xcb74
leaq 0x6a9b1(%rip), %rdi     # 0x77578
callq 0x4208a
cmpb $0x0, 0x6a9cd(%rip)     # 0x775a0
je 0xcc71
callq 0x38d94
cmpb $0x1, 0x5c40(%rax)
jne 0xcc04
movq 0x6a402(%rip), %rdi     # 0x76ff0
callq 0x99e8
leaq 0x6a9a6(%rip), %rsi     # 0x775a0
movq %rax, %rdi
callq 0x94b0
jmp 0xcc71
callq 0x471ac
leaq 0x6a990(%rip), %rsi     # 0x775a0
movq %rax, %rdi
callq 0x473e8
testl %eax, %eax
jns 0xcc71
movq 0x6a3cd(%rip), %rdi     # 0x76ff0
leaq 0x4a57d(%rip), %rsi     # 0x571a7
callq 0x94b0
leaq 0x4e53c(%rip), %rsi     # 0x5b172
movq %rax, %rdi
callq 0x94b0
movq %rax, %rdi
movl $0x4a4, %esi            # imm = 0x4A4
callq 0x9890
leaq 0x4c7cd(%rip), %rsi     # 0x5941f
movq %rax, %rdi
callq 0x94b0
leaq 0x4a560(%rip), %rsi     # 0x571c1
movq %rax, %rdi
callq 0x94b0
movq %rax, %rdi
callq 0x99e8
callq 0x38d94
testq %rbx, %rbx
je 0xcca1
cmpb $0x0, 0x5c42(%rax)
je 0xcca1
leaq 0x6a915(%rip), %rsi     # 0x775a0
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