// File: /workspace/github_c_makefile_star2_O1/schroeder-lvb[P]sissm/src/piantirush.c
// Function: captureSpeed
static void _captureSpeed( int isSlow )
{
    int isSlowCopy;
    isSlowCopy = isSlow;
    char *v;

    // a wedge code to disable this plugin if non-Checkpoint mode is running
    //
    v = apiGetServerMode();
    // if (! ((0==strcmp( v, "checkpoint" )) || (0==strcmp( v, "hardcore"))) )  return;

    if (! ((0==strcmp( v, "checkpoint" )) || (0==strcmp( v, "hardcore"))) ) 
        _fastMode = 1;
 
    if ( apiPlayersGetCount() <=  ( piantirushConfig.nPlayerExemption + piantirushConfig.trNPlayerOfs ) )
        isSlowCopy = 0;

    // if we're in 'fast on' mode then always force capture speed to (0 = normal).
    // The static in _fastMode is updated from the periodic handler polling for p2p
    // variable change as set by an admin through picladmin plugin.
    // 
    if ( _fastMode ) {
        isSlowCopy = 0;
    }

    if ( isSlowCopy != 0 ) {
        alarmReset( wPtr, 10 );   // delayed prompt for cache destruction HOLD order
    }

    if (lastState != isSlowCopy) {
        switch ( isSlowCopy ) {
	case 1:    // slow rate when moderate number of people are in game
            apiGameModePropertySet( "ObjectiveCaptureTime", piantirushConfig.slowObjectiveCaptureTime );
            apiGameModePropertySet( "ObjectiveSpeedup"    , piantirushConfig.slowObjectiveSpeedup );
            _localSay( piantirushConfig.slowPrompt );

            // alarmReset( wPtr, 10 );  // delayed prompt for cache destruction HOLD order

            logPrintf(LOG_LEVEL_INFO, "piantirush", "**Set Capture Time to SLOW");
            lastState = 1;
            break;
        case 2:    // locked rate when lots of people are in game
            apiGameModePropertySet( "ObjectiveCaptureTime", piantirushConfig.lockObjectiveCaptureTime );
            apiGameModePropertySet( "ObjectiveSpeedup"    , piantirushConfig.lockObjectiveSpeedup );
            _localSay( piantirushConfig.lockPrompt );  

            // alarmReset( wPtr, 10 );   // delayed prompt for cache destruction HOLD order

            logPrintf(LOG_LEVEL_INFO, "piantirush", "**Set Capture Time to LOCK");
            lastState = 2;
            break;
        default:    // normal case: expected value '0' 
            apiGameModePropertySet( "ObjectiveCaptureTime", piantirushConfig.fastObjectiveCaptureTime );
            apiGameModePropertySet( "ObjectiveSpeedup"    , piantirushConfig.fastObjectiveSpeedup );

            kickArmed = 0;           // kick safety : do not kick

            if ( lastState != 0 ) { 
                if ( NULL != strstr( rosterGetObjectiveType(), "Capturable" )) {

                    // check if capture objective letter 'A', 'B', 'C'... has changed.  Only print
                    // fast prompt change if changed.  Letter does NOT change during the counterattack
                    // so this block of code keep extra prompt flashing on screen during C/A.
                    // The '_lastObjLetter' variable is cleared at round start.
                    //
                    if ( _lastObjLetter != rosterGetCoopObjectiveLetter() )  {
                        _localSay( piantirushConfig.fastPrompt );
                        _lastObjLetter = rosterGetCoopObjectiveLetter();
                    }
                }
                else if ( NULL != strstr( rosterGetObjectiveType(), "WeaponCache" )) {
                    if (piantirushConfig.autoKickEarlyDestruction) {
                        _localSay( piantirushConfig.destroyOkPrompt );
                    }
                }
            }
            logPrintf(LOG_LEVEL_INFO, "piantirush", "**Set Capture Time to NORMAL");
            lastState = 0;
            break;
        }
    }
    return;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edi, %ebx
callq 0x13a76
movq %rax, %r14
leaq 0x7552(%rip), %rsi      # 0x1cfdb
movq %rax, %rdi
callq 0x8220
testl %eax, %eax
je 0x15aaf
leaq 0x6563(%rip), %rsi      # 0x1bfff
movq %r14, %rdi
callq 0x8220
testl %eax, %eax
je 0x15aaf
movb $0x1, 0x20a3bd(%rip)    # 0x21fe6c
callq 0x134dc
movl 0x207e46(%rip), %ecx    # 0x21d900
addl 0x201de4(%rip), %ecx    # 0x2178a4
xorl %edx, %edx
cmpl %ecx, %eax
cmovlel %edx, %ebx
cmpb $0x0, 0x20a39e(%rip)    # 0x21fe6c
cmovnel %edx, %ebx
testl %ebx, %ebx
je 0x15ae6
movq 0x20a3a4(%rip), %rdi    # 0x21fe80
movl $0xa, %esi
callq 0xf953
cmpl %ebx, 0x143f8(%rip)     # 0x29ee4
je 0x15c4c
leaq 0x93a1(%rip), %rdi      # 0x1ee9a
cmpl $0x2, %ebx
je 0x15b41
cmpl $0x1, %ebx
jne 0x15b7f
leaq 0x202da6(%rip), %rsi    # 0x2188b0
callq 0x12e70
leaq 0x93a8(%rip), %rdi      # 0x1eebe
leaq 0x203193(%rip), %rsi    # 0x218cb0
callq 0x12e70
leaq 0x202987(%rip), %rdi    # 0x2184b0
xorl %eax, %eax
callq 0x16554
movl $0x1, %ebp
leaq 0x9bf5(%rip), %rbx      # 0x1f731
jmp 0x15c30
leaq 0x20396c(%rip), %rsi    # 0x2194b4
callq 0x12e70
leaq 0x936a(%rip), %rdi      # 0x1eebe
leaq 0x203d59(%rip), %rsi    # 0x2198b4
callq 0x12e70
leaq 0x20354d(%rip), %rdi    # 0x2190b4
xorl %eax, %eax
callq 0x16554
movl $0x2, %ebp
leaq 0x9bd2(%rip), %rbx      # 0x1f74c
jmp 0x15c30
leaq 0x202126(%rip), %rsi    # 0x217cac
callq 0x12e70
leaq 0x932c(%rip), %rdi      # 0x1eebe
leaq 0x202513(%rip), %rsi    # 0x2180ac
callq 0x12e70
movb $0x0, 0x20a29b(%rip)    # 0x21fe40
xorl %ebp, %ebp
leaq 0x9bb9(%rip), %rbx      # 0x1f767
cmpl $0x0, 0x1432f(%rip)     # 0x29ee4
je 0x15c30
callq 0x14246
leaq 0x9321(%rip), %rsi      # 0x1eee4
movq %rax, %rdi
callq 0x83b0
testq %rax, %rax
je 0x15bfe
movb 0x142f9(%rip), %r14b    # 0x29ed0
callq 0x1432d
cmpb %al, %r14b
je 0x15c30
leaq 0x201cc4(%rip), %rdi    # 0x2178ac
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x16554
callq 0x1432d
movb %al, 0x142d4(%rip)      # 0x29ed0
jmp 0x15c30
callq 0x14246
leaq 0x8f39(%rip), %rsi      # 0x1eb43
movq %rax, %rdi
callq 0x83b0
testq %rax, %rax
je 0x15c30
cmpl $0x0, 0x20489a(%rip)    # 0x21a4b8
je 0x15c30
leaq 0x204899(%rip), %rdi    # 0x21a4c0
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x16554
leaq 0x8eb3(%rip), %rsi      # 0x1eaea
movl $0x2, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1a227
movl %ebp, 0x14298(%rip)     # 0x29ee4
popq %rbx
popq %r14
popq %rbp
retq