-
-
Save T-Maxxx/d65bf998e4111fde3a581244dae8ca09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 0x080BE28A | |
int Scr_PrecacheItem_f() | |
{ | |
char *itemName; // eax@2 MAPDST | |
int result; // eax@2 | |
char *err; // eax@5 | |
if ( ISFIRSTFRAME == qfalse ) | |
Scr_Error("precacheItem must be called before any wait statements in the gametype or level script\n"); | |
itemName = Scr_GetString(0); | |
result = G_WeaponModelIndex(itemName, 0); | |
if ( !result ) | |
{ | |
err = va("unknown item '%s'", itemName); | |
result = Scr_ParamError(0, err); | |
} | |
return result; | |
} | |
// 0x080530EE | |
int __cdecl G_WeaponModelIndex(char *name, int model) | |
{ | |
unsigned int weapIdx; // eax@1 | |
int weapModelIdx; // edx@1 | |
weapIdx = G_WeaponIndex(name); | |
weapModelIdx = 0; | |
if ( weapIdx ) | |
weapModelIdx = (int)&dword_828BDE0[4 * ((model << 7) + weapIdx)];// Maximum 128 elements in array. Try bigger => overflow. | |
// Array of weapon indexes. | |
return weapModelIdx; | |
} | |
// 0x080A2182 | |
unsigned int __cdecl G_WeaponIndex(char *weapName) | |
{ | |
unsigned int result; // eax@2 | |
if ( ISFIRSTFRAME ) | |
result = sub_80616BA(weapName, (void (__cdecl *)(_DWORD))sub_8090230); | |
else | |
result = BG_GetWeaponIndexForString(weapName); | |
return result; | |
} | |
// 0x0805FFE8 | |
unsigned int __cdecl BG_GetWeaponIndexForString(char *name) | |
{ | |
unsigned int v1; // ebx@3 | |
unsigned int result; // eax@6 | |
if ( name && dword_828DE20 ) // dword_828DE20 looks like current precached weapons count | |
{ | |
v1 = 1; | |
while ( Q_strcmp(name, *(char **)dword_828DE40[v1]) )// dword_828DE40 pointer to WeaponDef structures? 128 elements in array hardcoded | |
{ | |
++v1; | |
if ( dword_828DE20 < v1 ) // Bigger than 128 => overflow ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
goto LABEL_7; | |
} | |
result = v1; | |
} | |
else | |
{ | |
LABEL_7: | |
result = 0; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment