// File: /workspace/github_c_makefile_star2_O2/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 0x12f75
movq %rax, %r14
leaq 0x7268(%rip), %rsi      # 0x1bfbb
movq %rax, %rdi
callq 0x8220
testl %eax, %eax
je 0x14d79
leaq 0x6291(%rip), %rsi      # 0x1aff7
movq %r14, %rdi
callq 0x8220
testl %eax, %eax
je 0x14d79
movb $0x1, 0x20b0f3(%rip)    # 0x21fe6c
callq 0x12ab4
movl 0x208b7c(%rip), %ecx    # 0x21d900
addl 0x202b1a(%rip), %ecx    # 0x2178a4
xorl %edx, %edx
cmpl %ecx, %eax
cmovlel %edx, %ebx
cmpb $0x0, 0x20b0d4(%rip)    # 0x21fe6c
cmovnel %edx, %ebx
testl %ebx, %ebx
je 0x14dae
movq 0x20b0da(%rip), %rdi    # 0x21fe80
pushq $0xa
popq %rsi
callq 0xf1b1
cmpl %ebx, 0x15130(%rip)     # 0x29ee4
je 0x14f15
cmpl $0x2, %ebx
je 0x14e07
leaq 0x90a4(%rip), %rdi      # 0x1de6a
cmpl $0x1, %ebx
jne 0x14e4a
leaq 0x203ade(%rip), %rsi    # 0x2188b0
callq 0x12464
leaq 0x90b0(%rip), %rdi      # 0x1de8e
leaq 0x203ecb(%rip), %rsi    # 0x218cb0
callq 0x12464
leaq 0x2036bf(%rip), %rdi    # 0x2184b0
xorl %eax, %eax
callq 0x1579b
pushq $0x1
popq %rbp
leaq 0x98ff(%rip), %rbx      # 0x1e701
jmp 0x14efb
pushq $0x2
popq %rbp
leaq 0x9059(%rip), %rdi      # 0x1de6a
leaq 0x20469c(%rip), %rsi    # 0x2194b4
callq 0x12464
leaq 0x906a(%rip), %rdi      # 0x1de8e
leaq 0x204a89(%rip), %rsi    # 0x2198b4
callq 0x12464
leaq 0x20427d(%rip), %rdi    # 0x2190b4
xorl %eax, %eax
callq 0x1579b
leaq 0x98d7(%rip), %rbx      # 0x1e71c
jmp 0x14efb
leaq 0x202e5b(%rip), %rsi    # 0x217cac
callq 0x12464
leaq 0x9031(%rip), %rdi      # 0x1de8e
leaq 0x203248(%rip), %rsi    # 0x2180ac
callq 0x12464
movb $0x0, 0x20afd0(%rip)    # 0x21fe40
xorl %ebp, %ebp
leaq 0x98be(%rip), %rbx      # 0x1e737
cmpl $0x0, 0x15064(%rip)     # 0x29ee4
je 0x14efb
callq 0x13648
leaq 0x9026(%rip), %rsi      # 0x1deb4
movq %rax, %rdi
callq 0x83c0
testq %rax, %rax
je 0x14ec9
movb 0x1502e(%rip), %r14b    # 0x29ed0
callq 0x1372b
cmpb %al, %r14b
je 0x14efb
leaq 0x2029f9(%rip), %rdi    # 0x2178ac
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1579b
callq 0x1372b
movb %al, 0x15009(%rip)      # 0x29ed0
jmp 0x14efb
callq 0x13648
leaq 0x8c3e(%rip), %rsi      # 0x1db13
movq %rax, %rdi
callq 0x83c0
testq %rax, %rax
je 0x14efb
cmpl $0x0, 0x2055cf(%rip)    # 0x21a4b8
je 0x14efb
leaq 0x2055ce(%rip), %rdi    # 0x21a4c0
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1579b
leaq 0x8bb8(%rip), %rsi      # 0x1daba
pushq $0x2
popq %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1920b
movl %ebp, 0x14fcf(%rip)     # 0x29ee4
popq %rbx
popq %r14
popq %rbp
retq