// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_ctffunc.c
// Function: ctf_SpamCheck
qboolean ctf_SpamCheck(edict_t *ent)
{
	qboolean result = false;

	if (ent->client->ctf.extra_flags & CTF_EXTRAFLAGS_REFEREE)
		result = true;

	else if (	(ent->client->spam_band_count <= 0) || //no bandwidth available
					(ent->client->spam_freq_count > CTF_SPAM_FREQ_MAX_ALLOWED) || //no frequency available
					(level.time - ent->client->spam_lock_time < CTF_SPAM_LOCKOUT_TIME)    ) //already in penalty box
	{
		ctf_SafePrint(ent, PRINT_HIGH, "That action has been blocked by spam control.\n");
		ent->client->spam_lock_time = level.time; //you triggered spam lock
	}
	else
	{
		result = true;
		
		//here we have a player who has done too many long says, or some such
		if (ent->client->spam_band_count < CTF_SPAM_BAND_WARN_LEVEL)
		{
			ctf_SafePrint(ent, PRINT_HIGH, "Warning: Approaching spam bandwidth limits.\n");
		}
		
	}

	//here we have a player who has done a few actions in a short time
	if (ent->client->spam_freq_time - level.time < CTF_SPAM_FREQ_EXTRA_PENALTY_TIME)
	{
		ent->client->spam_freq_count += CTF_SPAM_FREQ_EXTRA_PENALTY;
		if (ent->client->spam_band_count < CTF_SPAM_FREQ_BAND_EXTRA_PENALTY_LEVEL) //compound penalty for bandwidth
			ent->client->spam_freq_count += CTF_SPAM_FREQ_BAND_EXTRA_PENALTY;
	}


	ent->client->spam_freq_time = level.time; //see test of this above

/*	gi.dprintf("Time: %f Freq-Time: %f Freq-Count: %ld Lock-Time: %f Band: %ld", 
		level.time,
		ent->client->spam_freq_time,
		ent->client->spam_freq_count,
		ent->client->spam_lock_time,
		ent->client->spam_band_count
		); */

	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movl 0x1108(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x24d05
movl $0x1, -0xc(%rbp)
jmp 0x24db7
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, 0x10e0(%rax)
jle 0x24d52
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x32, 0x10d8(%rax)
jg 0x24d52
movq 0x5e070(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm1
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
subss 0x10cc(%rax), %xmm1
movss 0x4b1bb(%rip), %xmm0    # 0x6ff08
ucomiss %xmm1, %xmm0
jbe 0x24d85
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x4bad7(%rip), %rdx     # 0x70839
callq 0x18f20
movq 0x5e032(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0x10cc(%rax)
jmp 0x24db5
movl $0x1, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x5a, 0x10e0(%rax)
jge 0x24db3
movq -0x8(%rbp), %rdi
movl $0x2, %esi
leaq 0x4baba(%rip), %rdx     # 0x70868
callq 0x18f20
jmp 0x24db5
jmp 0x24db7
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss 0x10d0(%rax), %xmm1
movq 0x5dfd2(%rip), %rax     # 0x82da0
subss 0x4(%rax), %xmm1
movss 0x4b6b9(%rip), %xmm0    # 0x70494
ucomiss %xmm1, %xmm0
jbe 0x24e2b
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x10d8(%rax), %rcx
addq $0x14, %rcx
movq %rcx, 0x10d8(%rax)
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0xbe, 0x10e0(%rax)
jge 0x24e29
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x10d8(%rax), %rcx
addq $0x5, %rcx
movq %rcx, 0x10d8(%rax)
jmp 0x24e2b
movq 0x5df6e(%rip), %rax     # 0x82da0
movss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movss %xmm0, 0x10d0(%rax)
movl -0xc(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq