// File: /workspace/github_c_makefile_star2_O2/schroeder-lvb[P]sissm/src/pitacnomic.c
// Function: pitacnomicChatCB
int pitacnomicChatCB( char *strIn )
{
    int errCode = 0, i;
    char *typeObj, clientID[256], chatText[256];
    char *w, *v;

    logPrintf( LOG_LEVEL_INFO, "pitacnomic", "Client chat ::%s::", strIn );

    // check if this is a valid chat line 
    //
    if ( 0 == (errCode = rosterParsePlayerChat( strIn, 256, clientID, chatText ))) {
        if (( 2 == strlen( chatText ))) {
            chatText[2] = 0;

            // check if the command issuer is 'dead' -- if so, consult list of prohibited 
            // codes that can only be issued by players that are alive.
            // Exemption-1 is when SISSM is hot-restarted (but not the game server) -- in this condition
            // SISSM thinks everybody is 'dead' so, override this condition, forcing everyone is 'alive'
            // until start of the next round.
            // Exemption-2 is if the players has "deadcmdr" privilege attribute (admins/moderators) then
            // s/he may be dead, but will may issue the stack/breach/blow commands.
            //
            if ((0 == apiIsPlayerAliveByGUID( clientID )) 
                  && !apiIsHotRestart() 
                  && !apiAuthIsAttribute( clientID, "deadcmdr" )) {  // if the issuer is "dead"

                 // check if this 2-letter-code is in the "live player only" list
                 // 
                 if ( NULL != strcasestr( pitacnomicConfig.livePlayersOnly, chatText ) ) {
                     // if so, invalidate the entered text (ignored by this plugin
                     //
                     chatText[0] = ' ';  chatText[1] = ' ';
                 }
            }

            // Resume regular processing of two-letter-code.  Do a table lookup
            // and send translated string to the player chat
            //
            for (i = 0; i<PITACNOMIC_MAXSHORTS; i++) {
                if ( 0 == strncmp( pitacnomicConfig.shorts[i], chatText, 2 )) {
                    // match is found on the table.  Parse for phrase to be
                    // sent to the game.
                    //
                    if (NULL != (w = getWord( pitacnomicConfig.shorts[i], 1, "\007" ) )) {
                        typeObj = rosterGetObjectiveType();
                        if ( NULL != strcasestr( typeObj, "capturable"  ) ) {
                            ;
                        }
                        if ( NULL != strcasestr( typeObj, "weaponcache" ) ) {
                            if (NULL != (v = getWord( pitacnomicConfig.shorts[i], 2, "\007" ) )) {
                                w = v;
                             }
                        }
                        apiSaySys( w );
                    }
                    break;
                }
            }       
        }
    }

    return errCode;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rdi, %rbx
leaq 0xeef8(%rip), %rsi      # 0x1b7ce
leaq 0xeefc(%rip), %rdx      # 0x1b7d9
pushq $0x2
popq %rdi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1920b
leaq 0x100(%rsp), %rdx
movq %rsp, %rcx
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x145db
movl %eax, %ebx
testl %eax, %eax
jne 0xca14
movq %rsp, %rdi
callq 0x8120
cmpq $0x2, %rax
jne 0xca14
movb $0x0, 0x2(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x11270
testl %eax, %eax
jne 0xc96f
callq 0x13472
testl %eax, %eax
jne 0xc96f
leaq 0xeea8(%rip), %rsi      # 0x1b7ec
leaq 0x100(%rsp), %rdi
callq 0x12e42
testl %eax, %eax
jne 0xc96f
leaq 0x6a718(%rip), %rdi     # 0x77074
movq %rsp, %rsi
callq 0x8360
testq %rax, %rax
je 0xc96f
movw $0x2020, (%rsp)         # imm = 0x2020
leaq 0x516fe(%rip), %rdi     # 0x5e074
xorl %r12d, %r12d
movq %rsp, %r14
pushq $0x2
popq %r15
addq $-0x400, %r12           # imm = 0xFC00
cmpq $-0x19400, %r12         # imm = 0xFFFE6C00
je 0xca14
leaq 0x400(%rdi), %r13
movq %r14, %rsi
movq %r15, %rdx
callq 0x8080
movq %r13, %rdi
testl %eax, %eax
jne 0xc980
leaq 0x516bc(%rip), %r15     # 0x5e070
subq %r12, %r15
addq $-0x3fc, %r15           # imm = 0xFC04
leaq 0xdd43(%rip), %rdx      # 0x1a708
pushq $0x1
popq %rsi
movq %r15, %rdi
callq 0xed9c
testq %rax, %rax
je 0xca14
movq %rax, %r14
callq 0x13648
leaq 0xe4ee(%rip), %rsi      # 0x1aed2
movq %rax, %rdi
callq 0x8360
testq %rax, %rax
je 0xca0a
leaq 0xdd10(%rip), %rdx      # 0x1a708
pushq $0x2
popq %rsi
movq %r15, %rdi
callq 0xed9c
testq %rax, %rax
cmovneq %rax, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x12753
movl %ebx, %eax
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq