filthy_freak_
12th June 2015, 22:59
So I need a bit more control over which dropped weapons get auto deleted by the server.
I have taken the stock function;
int __usercall sub_8103B6A@<eax>(long double a1@<st0>)
{
int v3; // [sp+14h] [bp-24h]@1
void *s; // [sp+1Ch] [bp-1Ch]@3
float v5; // [sp+20h] [bp-18h]@1
float v6; // [sp+24h] [bp-14h]@9
float v7; // [sp+28h] [bp-10h]@5
int v8; // [sp+2Ch] [bp-Ch]@1
int j; // [sp+30h] [bp-8h]@5
int i; // [sp+34h] [bp-4h]@1
v8 = 0;
v5 = -1.0;
v3 = *(_DWORD *)(dword_8793DB8 + 8);
for ( i = 0; i < v3; ++i )
{
s = (void *)dword_859D158[i];
if ( !s )
return i;
v7 = 9.9999803e11;
for ( j = 0; j < dword_859B5E4; ++j )
{
if ( *(_DWORD *)(dword_859B400 + 10404 * j + 9924) == 2 && !*(_DWORD *)(dword_859B400 + 10404 * j + 9896) )
{
v6 = sub_80A1DB2(560 * j + 140924344, (int)((char *)s + 312));
if ( v7 > (long double)v6 )
v7 = v6;
}
}
a1 = v5;
if ( v7 > (long double)v5 )
{
v5 = v7;
v8 = i;
}
}
sub_811C9C0(a1, (void *)dword_859D158[v8]);
dword_859D158[v8] = 0;
return v8;
}
and imported it to libcod
cHook *hook_delete_weapon;
int delete_weapon(long double a1)
{
long double (*sub_80A1DB2)(int a2, int a3);
*(int *)&sub_80A1DB2 = 0x080A1DB2;
int (*sub_811C9C0)(long double a4, void *d);
*(int *)&sub_811C9C0 = 0x0811C9C0;
int *dword_8793DB8 = (int *)0x8793DB8;
int *dword_859D158 = (int *)0x859D158;
int *dword_859B5E4 = (int *)0x859B5E4;
int *dword_859B400 = (int *)0x859B400;
int v3;
void *s;
float v5;
float v6;
float v7;
int v8;
int j;
int i;
v8 = 0;
v5 = -1.0;
v3 = int(dword_8793DB8 + 8);
for ( i = 0; i < v3; ++i )
{
s = (void *)dword_859D158[i];
if ( !s )
return i;
v7 = 9.9999803e11;
for ( j = 0; j < int(dword_859B5E4); ++j )
{
if ( int(dword_859B400 + 10404 * j + 9924) == 2 && !int(dword_859B400 + 10404 * j + 9896) )
{
v6 = sub_80A1DB2(560 * j + 140924344, (int)((char *)s + 312));
if ( v7 > (long double)v6 )
v7 = v6;
}
}
a1 = v5;
if ( v7 > (long double)v5 )
{
v5 = v7;
v8 = i;
}
}
sub_811C9C0(a1, (void *)dword_859D158[v8]);
dword_859D158[v8] = 0;
return v8;
}
Currently it will not reach sub_811C9C0(a1, (void *)dword_859D158[v8]); and lags more and more depending on how many weapons are dropped in the map.
Example;
Weapon 1 dropped.
Weapon 2 dropped.
Hitch warning: 627 msec frame time
Weapon 3 dropped.
Hitch warning: 920 msec frame time
Weapon 4 dropped.
Hitch warning: 1188 msec frame time
Weapon 5 dropped.
Hitch warning: 1494 msec frame time
Any ideas what I could have done wrong?
I have taken the stock function;
int __usercall sub_8103B6A@<eax>(long double a1@<st0>)
{
int v3; // [sp+14h] [bp-24h]@1
void *s; // [sp+1Ch] [bp-1Ch]@3
float v5; // [sp+20h] [bp-18h]@1
float v6; // [sp+24h] [bp-14h]@9
float v7; // [sp+28h] [bp-10h]@5
int v8; // [sp+2Ch] [bp-Ch]@1
int j; // [sp+30h] [bp-8h]@5
int i; // [sp+34h] [bp-4h]@1
v8 = 0;
v5 = -1.0;
v3 = *(_DWORD *)(dword_8793DB8 + 8);
for ( i = 0; i < v3; ++i )
{
s = (void *)dword_859D158[i];
if ( !s )
return i;
v7 = 9.9999803e11;
for ( j = 0; j < dword_859B5E4; ++j )
{
if ( *(_DWORD *)(dword_859B400 + 10404 * j + 9924) == 2 && !*(_DWORD *)(dword_859B400 + 10404 * j + 9896) )
{
v6 = sub_80A1DB2(560 * j + 140924344, (int)((char *)s + 312));
if ( v7 > (long double)v6 )
v7 = v6;
}
}
a1 = v5;
if ( v7 > (long double)v5 )
{
v5 = v7;
v8 = i;
}
}
sub_811C9C0(a1, (void *)dword_859D158[v8]);
dword_859D158[v8] = 0;
return v8;
}
and imported it to libcod
cHook *hook_delete_weapon;
int delete_weapon(long double a1)
{
long double (*sub_80A1DB2)(int a2, int a3);
*(int *)&sub_80A1DB2 = 0x080A1DB2;
int (*sub_811C9C0)(long double a4, void *d);
*(int *)&sub_811C9C0 = 0x0811C9C0;
int *dword_8793DB8 = (int *)0x8793DB8;
int *dword_859D158 = (int *)0x859D158;
int *dword_859B5E4 = (int *)0x859B5E4;
int *dword_859B400 = (int *)0x859B400;
int v3;
void *s;
float v5;
float v6;
float v7;
int v8;
int j;
int i;
v8 = 0;
v5 = -1.0;
v3 = int(dword_8793DB8 + 8);
for ( i = 0; i < v3; ++i )
{
s = (void *)dword_859D158[i];
if ( !s )
return i;
v7 = 9.9999803e11;
for ( j = 0; j < int(dword_859B5E4); ++j )
{
if ( int(dword_859B400 + 10404 * j + 9924) == 2 && !int(dword_859B400 + 10404 * j + 9896) )
{
v6 = sub_80A1DB2(560 * j + 140924344, (int)((char *)s + 312));
if ( v7 > (long double)v6 )
v7 = v6;
}
}
a1 = v5;
if ( v7 > (long double)v5 )
{
v5 = v7;
v8 = i;
}
}
sub_811C9C0(a1, (void *)dword_859D158[v8]);
dword_859D158[v8] = 0;
return v8;
}
Currently it will not reach sub_811C9C0(a1, (void *)dword_859D158[v8]); and lags more and more depending on how many weapons are dropped in the map.
Example;
Weapon 1 dropped.
Weapon 2 dropped.
Hitch warning: 627 msec frame time
Weapon 3 dropped.
Hitch warning: 920 msec frame time
Weapon 4 dropped.
Hitch warning: 1188 msec frame time
Weapon 5 dropped.
Hitch warning: 1494 msec frame time
Any ideas what I could have done wrong?