// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movl -0x4(%rbp), %eax
movl %eax, -0x8(%rbp)
callq 0x187d0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x95f6(%rip), %rsi      # 0x24fdb
callq 0x8200
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x1ba14
movq -0x10(%rbp), %rdi
leaq 0x8602(%rip), %rsi      # 0x23fff
callq 0x8200
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x1ba14
movl $0x1, 0x20c458(%rip)    # 0x227e6c
callq 0x17fe0
movl 0x203e85(%rip), %ecx    # 0x21f8a4
addl 0x209edb(%rip), %ecx    # 0x225900
cmpl %ecx, %eax
jg 0x1ba30
movl $0x0, -0x8(%rbp)
cmpl $0x0, 0x20c435(%rip)    # 0x227e6c
je 0x1ba40
movl $0x0, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
je 0x1ba57
movq 0x20c433(%rip), %rdi    # 0x227e80
movl $0xa, %esi
callq 0x12a40
movl 0x1648b(%rip), %eax     # 0x31ee8
cmpl -0x8(%rbp), %eax
je 0x1bc6f
movl -0x8(%rbp), %eax
movl %eax, -0x14(%rbp)
subl $0x1, %eax
je 0x1ba80
jmp 0x1ba73
movl -0x14(%rbp), %eax
subl $0x2, %eax
je 0x1baf2
jmp 0x1bb64
leaq 0xb41b(%rip), %rdi      # 0x26ea2
leaq 0x203e12(%rip), %rsi    # 0x21f8a0
addq $0x1010, %rsi           # imm = 0x1010
callq 0x176f0
leaq 0xb425(%rip), %rdi      # 0x26ec6
leaq 0x203df8(%rip), %rsi    # 0x21f8a0
addq $0x1410, %rsi           # imm = 0x1410
callq 0x176f0
leaq 0x203de5(%rip), %rdi    # 0x21f8a0
addq $0xc10, %rdi            # imm = 0xC10
movb $0x0, %al
callq 0x1cac0
movl $0x2, %edi
leaq 0xb01d(%rip), %rsi      # 0x26af2
leaq 0xbc5d(%rip), %rdx      # 0x27739
movb $0x0, %al
callq 0x21bf0
movl $0x1, 0x163fb(%rip)     # 0x31ee8
jmp 0x1bc6d
leaq 0xb3a9(%rip), %rdi      # 0x26ea2
leaq 0x203da0(%rip), %rsi    # 0x21f8a0
addq $0x1c14, %rsi           # imm = 0x1C14
callq 0x176f0
leaq 0xb3b3(%rip), %rdi      # 0x26ec6
leaq 0x203d86(%rip), %rsi    # 0x21f8a0
addq $0x2014, %rsi           # imm = 0x2014
callq 0x176f0
leaq 0x203d73(%rip), %rdi    # 0x21f8a0
addq $0x1814, %rdi           # imm = 0x1814
movb $0x0, %al
callq 0x1cac0
movl $0x2, %edi
leaq 0xafab(%rip), %rsi      # 0x26af2
leaq 0xbc06(%rip), %rdx      # 0x27754
movb $0x0, %al
callq 0x21bf0
movl $0x2, 0x16389(%rip)     # 0x31ee8
jmp 0x1bc6d
leaq 0xb337(%rip), %rdi      # 0x26ea2
leaq 0x203d2e(%rip), %rsi    # 0x21f8a0
addq $0x40c, %rsi            # imm = 0x40C
callq 0x176f0
leaq 0xb341(%rip), %rdi      # 0x26ec6
leaq 0x203d14(%rip), %rsi    # 0x21f8a0
addq $0x80c, %rsi            # imm = 0x80C
callq 0x176f0
movl $0x0, 0x20c29e(%rip)    # 0x227e40
cmpl $0x0, 0x1633f(%rip)     # 0x31ee8
je 0x1bc49
callq 0x193d0
movq %rax, %rdi
leaq 0xb32e(%rip), %rsi      # 0x26eec
callq 0x8390
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x1bc07
movsbl 0x16300(%rip), %eax     # 0x31ed4
movl %eax, -0x18(%rbp)
callq 0x19560
movb %al, %cl
movl -0x18(%rbp), %eax
movsbl %cl, %ecx
cmpl %ecx, %eax
je 0x1bc05
leaq 0x203cb1(%rip), %rdi    # 0x21f8a0
addq $0xc, %rdi
movb $0x0, %al
callq 0x1cac0
callq 0x19560
movb %al, 0x162cf(%rip)      # 0x31ed4
jmp 0x1bc47
callq 0x193d0
movq %rax, %rdi
leaq 0xaf35(%rip), %rsi      # 0x26b4b
callq 0x8390
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x1bc45
cmpl $0x0, 0x20688c(%rip)    # 0x2224b8
je 0x1bc43
leaq 0x203c6b(%rip), %rdi    # 0x21f8a0
addq $0x2c20, %rdi           # imm = 0x2C20
movb $0x0, %al
callq 0x1cac0
jmp 0x1bc45
jmp 0x1bc47
jmp 0x1bc49
movl $0x2, %edi
leaq 0xae9d(%rip), %rsi      # 0x26af2
leaq 0xbb13(%rip), %rdx      # 0x2776f
movb $0x0, %al
callq 0x21bf0
movl $0x0, 0x1627b(%rip)     # 0x31ee8
jmp 0x1bc6f
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)