// File: /workspace/github_c_makefile_star2_O0/schroeder-lvb[P]sissm/src/piprotect.c
// Function: piprotectClientAddCB
int piprotectClientAddCB( char *strIn )
{
    char playerName[256], playerGUID[256], playerIP[256];
    char gameMode[256], objName[256], mapName[256], objLetter;
    int limitPlayers;

    rosterParsePlayerConn( strIn, 256, playerName, playerGUID, playerIP );
    logPrintf( LOG_LEVEL_CRITICAL, "piprotect", "Add Client ::%s::%s::%s::", playerName, playerGUID, playerIP );


    // get current game mode - only process if 'checkpoint' or 'hardcore' 
    // 
    strlcpy( gameMode, apiGetServerMode(), 256 );
    if ( (0 == strcasecmp( gameMode, "hardcore" ) ) || (0 == strcasecmp( gameMode, "checkpoint" )) ) {

        // get current map/objective information
        //
        strlcpy( objName, rosterGetObjective(), 256 );       // e.g., "OCCheckpoint_A"
        strlcpy( mapName, rosterGetMapName(), 255 );   // e.g., "Farmhouse_Checkpoint_Security"
        objLetter = rosterGetCoopObjectiveLetter();          // e.g., 'A', 'B', 'C', ... ' '

        objLetter = tolower( objLetter ) ; 
        if ( apiIsCounterAttack() )             // non-zero if in counterattack state
            objLetter = toupper( objLetter );

        // Check join limit criteria - kick players if join limit criteria is met
        // 
        limitPlayers = _joinLimit( objName, mapName, objLetter ) ;
        if ( apiPlayersGetCount() >= limitPlayers ) {
            if ( 1 == rosterIsValidGUID( playerGUID ) ) {        // if Steam
                apiKick( playerGUID, "Join temporarily blocked for this objective - try again in few minutes" );
                apiSay( "Unable to connect '%s' for this objective", playerName );
                logPrintf( LOG_LEVEL_WARN, "piprotect", "Protective Kick: '%s'  Map: '%s' Obj: '%c' Limit %d", playerName, mapName, objLetter, limitPlayers );
            }
            else if ( 2 == rosterIsValidGUID( playerGUID ) ) {   // if EPIC
                apiKick( playerName, "Join temporarily blocked for this objective - try again in few minutes" );
                apiSay( "Unable to connect '%s' for this objective", playerName );
                logPrintf( LOG_LEVEL_WARN, "piprotect", "Protective Kick: '%s'  Map: '%s' Obj: '%c' Limit %d", playerName, mapName, objLetter, limitPlayers );
            }
            else if ( 3 == rosterIsValidGUID( playerGUID ) ) {   // if WinGDK
                apiKick( playerName, "Join temporarily blocked for this objective - try again in few minutes" );
                apiSay( "Unable to connect '%s' for this objective", playerName );
                logPrintf( LOG_LEVEL_WARN, "piprotect", "Protective Kick: '%s'  Map: '%s' Obj: '%c' Limit %d", playerName, mapName, objLetter, limitPlayers );
            }
            else {
                logPrintf( LOG_LEVEL_WARN, "piprotect", "Protective kick failed: '%s'  Map: '%s' Obj: '%c' Limit %d", playerName, mapName, objLetter, limitPlayers );
            }
        }
        else {
            logPrintf( LOG_LEVEL_WARN, "piprotect", "Join permitted: '%s'  Map: '%s' Obj: '%c' Limit %d", playerName, mapName, objLetter, limitPlayers );
        }
    }
   
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x640, %rsp            # imm = 0x640
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x110(%rbp), %rdx
leaq -0x210(%rbp), %rcx
leaq -0x310(%rbp), %r8
movl $0x100, %esi            # imm = 0x100
callq 0x1ace0
leaq -0x110(%rbp), %rcx
leaq -0x210(%rbp), %r8
leaq -0x310(%rbp), %r9
xorl %edi, %edi
leaq 0x14142(%rip), %rsi     # 0x25292
leaq 0x17213(%rip), %rdx     # 0x2836a
movb $0x0, %al
callq 0x21bf0
leaq -0x410(%rbp), %rax
movq %rax, -0x620(%rbp)
callq 0x187d0
movq -0x620(%rbp), %rdi
movq %rax, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x11bc0
leaq -0x410(%rbp), %rdi
leaq 0x12e6c(%rip), %rsi     # 0x23fff
callq 0x8040
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x111bf
leaq -0x410(%rbp), %rdi
leaq 0x13e2d(%rip), %rsi     # 0x24fdb
callq 0x8040
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x11465
leaq -0x510(%rbp), %rax
movq %rax, -0x630(%rbp)
callq 0x193c0
movq -0x630(%rbp), %rdi
movq %rax, %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x11bc0
leaq -0x610(%rbp), %rax
movq %rax, -0x628(%rbp)
callq 0x19410
movq -0x628(%rbp), %rdi
movq %rax, %rsi
movl $0xff, %edx
callq 0x11bc0
callq 0x19560
movb %al, -0x611(%rbp)
movsbl -0x611(%rbp), %edi
callq 0x8290
movb %al, -0x611(%rbp)
callq 0x16490
cmpl $0x0, %eax
je 0x11246
movsbl -0x611(%rbp), %edi
callq 0x8080
movb %al, -0x611(%rbp)
leaq -0x510(%rbp), %rdi
leaq -0x610(%rbp), %rsi
movsbl -0x611(%rbp), %edx
callq 0x11470
movl %eax, -0x618(%rbp)
callq 0x17fe0
cmpl -0x618(%rbp), %eax
jl 0x1142a
leaq -0x210(%rbp), %rdi
callq 0x190a0
movl %eax, %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jne 0x112f4
leaq -0x210(%rbp), %rdi
leaq 0x14000(%rip), %rsi     # 0x2529c
callq 0x17ee0
leaq -0x110(%rbp), %rsi
leaq 0x14034(%rip), %rdi     # 0x252e3
movb $0x0, %al
callq 0x178d0
leaq -0x110(%rbp), %rcx
leaq -0x610(%rbp), %r8
movsbl -0x611(%rbp), %r9d
movl -0x618(%rbp), %eax
movl $0x1, %edi
leaq 0x13fb4(%rip), %rsi     # 0x25292
leaq 0x14028(%rip), %rdx     # 0x2530d
movl %eax, (%rsp)
movb $0x0, %al
callq 0x21bf0
jmp 0x11428
leaq -0x210(%rbp), %rdi
callq 0x190a0
movl %eax, %ecx
movl $0x2, %eax
cmpl %ecx, %eax
jne 0x11371
leaq -0x110(%rbp), %rdi
leaq 0x13f83(%rip), %rsi     # 0x2529c
callq 0x17ee0
leaq -0x110(%rbp), %rsi
leaq 0x13fb7(%rip), %rdi     # 0x252e3
movb $0x0, %al
callq 0x178d0
leaq -0x110(%rbp), %rcx
leaq -0x610(%rbp), %r8
movsbl -0x611(%rbp), %r9d
movl -0x618(%rbp), %eax
movl $0x1, %edi
leaq 0x13f37(%rip), %rsi     # 0x25292
leaq 0x13fab(%rip), %rdx     # 0x2530d
movl %eax, (%rsp)
movb $0x0, %al
callq 0x21bf0
jmp 0x11426
leaq -0x210(%rbp), %rdi
callq 0x190a0
movl %eax, %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jne 0x113eb
leaq -0x110(%rbp), %rdi
leaq 0x13f06(%rip), %rsi     # 0x2529c
callq 0x17ee0
leaq -0x110(%rbp), %rsi
leaq 0x13f3a(%rip), %rdi     # 0x252e3
movb $0x0, %al
callq 0x178d0
leaq -0x110(%rbp), %rcx
leaq -0x610(%rbp), %r8
movsbl -0x611(%rbp), %r9d
movl -0x618(%rbp), %eax
movl $0x1, %edi
leaq 0x13eba(%rip), %rsi     # 0x25292
leaq 0x13f2e(%rip), %rdx     # 0x2530d
movl %eax, (%rsp)
movb $0x0, %al
callq 0x21bf0
jmp 0x11424
leaq -0x110(%rbp), %rcx
leaq -0x610(%rbp), %r8
movsbl -0x611(%rbp), %r9d
movl -0x618(%rbp), %eax
movl $0x1, %edi
leaq 0x13e7f(%rip), %rsi     # 0x25292
leaq 0x13f27(%rip), %rdx     # 0x25341
movl %eax, (%rsp)
movb $0x0, %al
callq 0x21bf0
jmp 0x11426
jmp 0x11428
jmp 0x11463
leaq -0x110(%rbp), %rcx
leaq -0x610(%rbp), %r8
movsbl -0x611(%rbp), %r9d
movl -0x618(%rbp), %eax
movl $0x1, %edi
leaq 0x13e40(%rip), %rsi     # 0x25292
leaq 0x13f23(%rip), %rdx     # 0x2537c
movl %eax, (%rsp)
movb $0x0, %al
callq 0x21bf0
jmp 0x11465
xorl %eax, %eax
addq $0x640, %rsp            # imm = 0x640
popq %rbp
retq