// File: /workspace/github_c_makefile_star2_O3/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 0x13dc1
movq %rax, %r14
leaq 0x72bc(%rip), %rsi      # 0x1cfb3
movq %rax, %rdi
callq 0x8220
testl %eax, %eax
je 0x15d1d
leaq 0x62ed(%rip), %rsi      # 0x1bff7
movq %r14, %rdi
callq 0x8220
testl %eax, %eax
je 0x15d1d
movb $0x1, 0x20a14f(%rip)    # 0x21fe6c
callq 0x13853
movl 0x207bd8(%rip), %ecx    # 0x21d900
addl 0x201b76(%rip), %ecx    # 0x2178a4
xorl %edx, %edx
cmpl %ecx, %eax
cmovlel %edx, %ebx
cmpb $0x0, 0x20a130(%rip)    # 0x21fe6c
cmovnel %edx, %ebx
testl %ebx, %ebx
je 0x15d54
movq 0x20a136(%rip), %rdi    # 0x21fe80
movl $0xa, %esi
callq 0xfc98
cmpl %ebx, 0x1418a(%rip)     # 0x29ee4
je 0x15eba
leaq 0x911b(%rip), %rdi      # 0x1ee82
cmpl $0x2, %ebx
je 0x15daf
cmpl $0x1, %ebx
jne 0x15ded
leaq 0x202b38(%rip), %rsi    # 0x2188b0
callq 0x131ed
leaq 0x9122(%rip), %rdi      # 0x1eea6
leaq 0x202f25(%rip), %rsi    # 0x218cb0
callq 0x131ed
leaq 0x202719(%rip), %rdi    # 0x2184b0
xorl %eax, %eax
callq 0x16799
movl $0x1, %ebp
leaq 0x996f(%rip), %rbx      # 0x1f719
jmp 0x15e9e
leaq 0x2036fe(%rip), %rsi    # 0x2194b4
callq 0x131ed
leaq 0x90e4(%rip), %rdi      # 0x1eea6
leaq 0x203aeb(%rip), %rsi    # 0x2198b4
callq 0x131ed
leaq 0x2032df(%rip), %rdi    # 0x2190b4
xorl %eax, %eax
callq 0x16799
movl $0x2, %ebp
leaq 0x994c(%rip), %rbx      # 0x1f734
jmp 0x15e9e
leaq 0x201eb8(%rip), %rsi    # 0x217cac
callq 0x131ed
leaq 0x90a6(%rip), %rdi      # 0x1eea6
leaq 0x2022a5(%rip), %rsi    # 0x2180ac
callq 0x131ed
movb $0x0, 0x20a02d(%rip)    # 0x21fe40
xorl %ebp, %ebp
leaq 0x9933(%rip), %rbx      # 0x1f74f
cmpl $0x0, 0x140c1(%rip)     # 0x29ee4
je 0x15e9e
callq 0x14563
leaq 0x909b(%rip), %rsi      # 0x1eecc
movq %rax, %rdi
callq 0x83b0
testq %rax, %rax
je 0x15e6c
movb 0x1408b(%rip), %r14b    # 0x29ed0
callq 0x1464a
cmpb %al, %r14b
je 0x15e9e
leaq 0x201a56(%rip), %rdi    # 0x2178ac
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x16799
callq 0x1464a
movb %al, 0x14066(%rip)      # 0x29ed0
jmp 0x15e9e
callq 0x14563
leaq 0x8cb3(%rip), %rsi      # 0x1eb2b
movq %rax, %rdi
callq 0x83b0
testq %rax, %rax
je 0x15e9e
cmpl $0x0, 0x20462c(%rip)    # 0x21a4b8
je 0x15e9e
leaq 0x20462b(%rip), %rdi    # 0x21a4c0
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x16799
leaq 0x8c2d(%rip), %rsi      # 0x1ead2
movl $0x2, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1a3e3
movl %ebp, 0x1402a(%rip)     # 0x29ee4
popq %rbx
popq %r14
popq %rbp
retq