// File: /workspace/github_c_makefile_star2_O2/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 $0x278, %rsp            # imm = 0x278
movl %r9d, 0x4(%rsp)
movq %r8, 0x8(%rsp)
movl %ecx, %r14d
movl %edx, %r15d
movq %rsi, %r13
movq %rdi, %r12
leaq 0x165244(%rip), %rbx    # 0x1782f8
xorl %ebp, %ebp
cmpq $-0x86000, %rbp         # imm = 0xFFF7A000
je 0x1311b
cmpb $0x0, -0x308(%rbx)
je 0x1311b
leaq -0x308(%rbx), %rdi
movq %r12, %rsi
callq 0x8360
testq %rax, %rax
je 0x1310b
cmpl %r14d, -0x8(%rbx)
jne 0x1310b
movl -0x4(%rbx), %eax
cmpl $-0x1, %eax
setne %cl
cmpl %r15d, %eax
setne %al
testb %al, %cl
jne 0x1310b
cmpb $0x0, (%r13)
je 0x13155
movq %rbx, %rdi
movq %r13, %rsi
callq 0x8060
testl %eax, %eax
je 0x13155
addq $-0x430, %rbp           # imm = 0xFBD0
addq $0x430, %rbx            # imm = 0x430
jmp 0x130b6
leaq 0x9d4d(%rip), %rsi      # 0x1ce6f
leaq 0xa536(%rip), %rdx      # 0x1d65f
pushq $0x2
popq %rdi
movq %r12, %rcx
movl %r15d, %r8d
movl %r14d, %r9d
xorl %eax, %eax
callq 0x1920b
pushq $0x1
popq %r14
movl %r14d, %eax
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x164d94(%rip), %rcx    # 0x177ef0
subq %rbp, %rcx
addq $0x300, %rcx            # imm = 0x300
leaq 0xa4b7(%rip), %rdx      # 0x1d624
xorl %r14d, %r14d
leaq 0x10(%rsp), %rdi
movl $0x12c, %esi            # imm = 0x12C
xorl %eax, %eax
callq 0x8190
movq 0x8(%rsp), %rbx
cmpb $0x0, (%rbx)
je 0x131d0
leaq 0xa49c(%rip), %rsi      # 0x1d62e
leaq 0x10(%rsp), %rdi
movl $0x12c, %edx            # imm = 0x12C
callq 0xe918
cmpl $0x0, 0x4(%rsp)
je 0x131be
leaq 0xa48a(%rip), %rsi      # 0x1d639
leaq 0x10(%rsp), %rdi
movl $0x12c, %edx            # imm = 0x12C
callq 0xe918
leaq 0x10(%rsp), %rdi
movl $0x12c, %edx            # imm = 0x12C
movq %rbx, %rsi
callq 0xe918
leaq 0x9c98(%rip), %rsi      # 0x1ce6f
leaq 0xa45d(%rip), %rdx      # 0x1d63b
pushq $0x2
popq %rdi
leaq 0x10(%rsp), %rbx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1920b
leaq 0x140(%rsp), %rsi
movq %rbx, %rdi
callq 0x12a8a
jmp 0x13140