// File: /workspace/github_c_makefile_star2_O3/schroeder-lvb[P]sissm/src/api.c
// Function: apiMapChange
int apiMapChange( char *mapName, char *gameMode, int secIns, int dayNight, char *mutatorsList, int clearMutators )
{
    int i, errCode = 1;
    char strOut[300], strResp[300];

    for (i = 0; i<API_MAXMAPS; i++ ) {

        if ( 0 == strlen( mapCycleList[i].reqName ))  
            break;

        // For map change to execute, the mapCycleList[].travel element must match input parameters 
        // on 1) day-night, 2) ins-security, and 3) either gamemode must be 'blank' or must match what is specified
        //
        if ( NULL != strcasestr( mapCycleList[i].reqName, mapName ) ) {
            if ( mapCycleList[i].dayNight == dayNight ) {
                if (( mapCycleList[i].secIns == -1 ) || ( mapCycleList[i].secIns == secIns )) {
                    if ( ( 0 == strlen( gameMode )) || ( 0 == strcasecmp( mapCycleList[i].gameMode, gameMode )) ) {
                        snprintf( strOut, 300, "travel %s", mapCycleList[i].traveler );
                        if ( 0 != strlen( mutatorsList )) {
                            strlcat( strOut, "?Mutators=", 300 );
                            if ( clearMutators ) strlcat( strOut, "?", 300 );
                            strlcat( strOut, mutatorsList, 300 );
                        }
                        logPrintf( LOG_LEVEL_INFO, "api", "*** Admin command map change ::%s::", strOut );
                        apiRcon( strOut, strResp );
                        errCode = 0;
                        break;
                    }
                } 
            }
        } 
    }

    if ( errCode ) {
        logPrintf( LOG_LEVEL_INFO, "api", 
            "Admin issued invalid map change ::%s::%d::%d", 
            mapName, secIns, dayNight );
    }
                        
    return( errCode );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movl %r9d, 0xc(%rsp)
movq %r8, 0x10(%rsp)
movl %ecx, %r14d
movl %edx, %r15d
movq %rsi, %r13
movq %rdi, %r12
leaq 0x1643fc(%rip), %rbx    # 0x1782f8
xorl %ebp, %ebp
cmpb $0x0, -0x308(%rbx)
je 0x13f61
leaq -0x308(%rbx), %rdi
movq %r12, %rsi
callq 0x8350
testq %rax, %rax
je 0x13f4a
cmpl %r14d, -0x8(%rbx)
jne 0x13f4a
movl -0x4(%rbx), %eax
cmpl $-0x1, %eax
setne %cl
cmpl %r15d, %eax
setne %al
testb %al, %cl
jne 0x13f4a
cmpb $0x0, (%r13)
je 0x13f9f
movq %rbx, %rdi
movq %r13, %rsi
callq 0x8060
testl %eax, %eax
je 0x13f9f
addq $-0x430, %rbp           # imm = 0xFBD0
addq $0x430, %rbx            # imm = 0x430
cmpq $-0x86000, %rbp         # imm = 0xFFF7A000
jne 0x13efe
leaq 0x9f17(%rip), %rsi      # 0x1de7f
leaq 0xa700(%rip), %rdx      # 0x1e66f
movl $0x2, %edi
movq %r12, %rcx
movl %r15d, %r8d
movl %r14d, %r9d
xorl %eax, %eax
callq 0x1a3e3
movl $0x1, %r14d
movl %r14d, %eax
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x163f4a(%rip), %rcx    # 0x177ef0
subq %rbp, %rcx
addq $0x300, %rcx            # imm = 0x300
leaq 0xa67d(%rip), %rdx      # 0x1e634
xorl %r14d, %r14d
leaq 0x20(%rsp), %rdi
movl $0x12c, %esi            # imm = 0x12C
xorl %eax, %eax
callq 0x8190
movq 0x10(%rsp), %rbx
cmpb $0x0, (%rbx)
je 0x1401a
leaq 0xa662(%rip), %rsi      # 0x1e63e
leaq 0x20(%rsp), %rdi
movl $0x12c, %edx            # imm = 0x12C
callq 0xf310
cmpl $0x0, 0xc(%rsp)
je 0x14008
leaq 0xa650(%rip), %rsi      # 0x1e649
leaq 0x20(%rsp), %rdi
movl $0x12c, %edx            # imm = 0x12C
callq 0xf310
leaq 0x20(%rsp), %rdi
movl $0x12c, %edx            # imm = 0x12C
movq %rbx, %rsi
callq 0xf310
leaq 0x9e5e(%rip), %rsi      # 0x1de7f
leaq 0xa623(%rip), %rdx      # 0x1e64b
leaq 0x20(%rsp), %rbx
movl $0x2, %edi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1a3e3
movq 0xc5445(%rip), %rdi     # 0xd9488
leaq 0x150(%rsp), %rcx
leaq 0x1c(%rsp), %r8
movl $0x2, %esi
movq %rbx, %rdx
callq 0x972d
jmp 0x13f8a