// File: /workspace/github_c_makefile_star2_O3/QwazyWabbitWOS[P]lmctf60/g_combat.c
// Function: T_RadiusDamage
void T_RadiusDamage (edict_t *inflictor, edict_t *attacker, float damage, edict_t *ignore, float radius, int mod)
{
	float	points;
	edict_t	*ent = NULL;
	vec3_t	v;
	vec3_t	dir;

#ifdef WEAP_BALANCE_OK	
	float vlength, adjuster; //surt weaponbalance
#endif

	while ((ent = findradius(ent, inflictor->s.origin, radius)) != NULL)
	{
		if (ent == ignore)
			continue;
		if (!ent->takedamage)
			continue;

		VectorAdd (ent->mins, ent->maxs, v);
		VectorMA (ent->s.origin, 0.5, v, v);
		VectorSubtract (inflictor->s.origin, v, v);

#ifdef WEAP_BALANCE_OK	
		if ((int)ctfflags->value & CTF_WEAP_BALANCE)
		{
			vlength = VectorLength(v); //hopefully in id-units
			//'corrected' radius damage formula
			if (vlength < 1)
				vlength = 0; //no negatives
			if (radius < 1)
				radius = 1; //no divide by zero, no negatives
			adjuster = 1 - (vlength / radius);
			//as vlength approaches radius, adjuster approaches zero
			//we then multiply this value into the damage, so that
			//damage approaches zero at the radius of the explosion
			points = damage * adjuster;
			//assuming id calculated the vector length correctly, then
			//this should be a drop off of r over the radius, making
			//it worst to be very close to the center of an explosion,
			//but also allowing you to 'feel' a big explosion nearby
		}
		else //original id code
			points = damage - 0.5 * VectorLength (v);
#else
		points = damage - 0.5 * VectorLength (v);
#endif

		if (ent == attacker)
			points = points * 0.5;
		if (points > 0)
		{
			if (CanDamage (ent, inflictor))
			{
				VectorSubtract (ent->s.origin, inflictor->s.origin, dir);
				T_Damage (ent, inflictor, attacker, dir, inflictor->s.origin, vec3_origin, (int)points, (int)points, DAMAGE_RADIUS, mod);
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, 0x20(%rsp)
movq %rdx, %r14
movss %xmm0, 0x10(%rsp)
movq %rsi, %r15
movq %rdi, %r12
leaq 0x4(%rdi), %r13
xorl %edi, %edi
movq %r13, %rsi
movss %xmm1, 0x1c(%rsp)
movaps %xmm1, %xmm0
callq 0x19870
testq %rax, %rax
je 0x2c0e8
movq %rax, %rbp
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movss 0x2845a(%rip), %xmm0    # 0x54400
movq %rsp, %rbx
cmpq %r14, %rbp
je 0x2c0c3
cmpl $0x0, 0x27c(%rbp)
je 0x2c0c3
movsd 0xcc(%rbp), %xmm2
movsd 0xd8(%rbp), %xmm1
addps %xmm2, %xmm1
movlps %xmm1, (%rsp)
movss 0xd4(%rbp), %xmm1
addss 0xe0(%rbp), %xmm1
movss %xmm1, 0x8(%rsp)
leaq 0x4(%rbp), %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x19760
movsd 0x4(%r12), %xmm0
movsd (%rsp), %xmm1
subps %xmm1, %xmm0
movlps %xmm0, (%rsp)
movss 0xc(%r12), %xmm0
subss 0x8(%rsp), %xmm0
movss %xmm0, 0x8(%rsp)
movq %rbx, %rdi
callq 0x192e0
cvtss2sd %xmm0, %xmm0
mulsd 0x29be3(%rip), %xmm0    # 0x55c18
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
cmpq %r15, %rbp
jne 0x2c04c
mulss 0x283b4(%rip), %xmm0    # 0x54400
ucomiss 0x2793d(%rip), %xmm0    # 0x53990
jbe 0x2c0c3
movq %rbp, %rdi
movq %r12, %rsi
movss %xmm0, 0x18(%rsp)
callq 0x18930
movss 0x18(%rsp), %xmm2
testl %eax, %eax
je 0x2c0c3
movsd 0x4(%rbp), %xmm0
movsd 0x4(%r12), %xmm1
subps %xmm1, %xmm0
movlps %xmm0, 0x28(%rsp)
movss 0xc(%rbp), %xmm0
subss 0xc(%r12), %xmm0
movss %xmm0, 0x30(%rsp)
cvttss2si %xmm2, %eax
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
leaq 0x28(%rsp), %rcx
movq %r13, %r8
movq 0x3c6b6(%rip), %r9      # 0x68768
pushq 0x20(%rsp)
pushq $0x1
pushq %rax
pushq %rax
callq 0x190f0
addq $0x20, %rsp
movq %rbp, %rdi
movq %r13, %rsi
movss 0x1c(%rsp), %xmm0
callq 0x19870
movss 0x28324(%rip), %xmm0    # 0x54400
movq %rax, %rbp
testq %rax, %rax
jne 0x2bfa9
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop