game_shared/weapon_parse.cpp
32333435363738
"melee_hit_world",
"special1",
"special2",
"special3"
};
#else
extern const char *pWeaponSoundCategories[ NUM_SHOOT_SOUND_TYPES ];
323334353637383940
"melee_hit_world",
"special1",
"special2",
"special3",
"cock", // |-- Mirv: Cock sfx
"stop" // |-- Mirv: Stops weapon sounds
};
#else
extern const char *pWeaponSoundCategories[ NUM_SHOOT_SOUND_TYPES ];
154155156157158159160161162163164165166167168169170171172173174175176
#if !defined( _XBOX )
FileFindHandle_t findHandle;
const char *pFilename = filesystem->FindFirstEx( "scripts/weapon_*.txt", IsXbox() ? "XGAME" : "GAME", &findHandle );
while ( pFilename != NULL )
{
char fileBase[512];
Q_FileBase( pFilename, fileBase, sizeof(fileBase) );
WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
{
gWR.LoadWeaponSprites( tmp );
}
#else
ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
pFilename = filesystem->FindNext( findHandle );
}
filesystem->FindClose( findHandle );
#else
#define WEAPON_SCRIPT_MANIFEST_FILE "scripts/_weapon_manifest.txt"
156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
#if !defined( _XBOX )
FileFindHandle_t findHandle;
if (!pICEKey)
{
const char *pFilename = filesystem->FindFirstEx( "scripts/weapon_*.txt", IsXbox() ? "XGAME" : "GAME", &findHandle );
while ( pFilename != NULL )
{
char fileBase[512];
Q_FileBase( pFilename, fileBase, sizeof(fileBase) );
WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
{
gWR.LoadWeaponSprites( tmp );
}
#else
ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
pFilename = filesystem->FindNext( findHandle );
}
filesystem->FindClose( findHandle );
}
else
{
const char *pFilename = filesystem->FindFirstEx( "scripts/weapon_*.ctx", IsXbox() ? "XGAME" : "GAME", &findHandle );
while ( pFilename != NULL )
{
char fileBase[512];
Q_FileBase( pFilename, fileBase, sizeof(fileBase) );
WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
{
gWR.LoadWeaponSprites( tmp );
}
#else
ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
pFilename = filesystem->FindNext( findHandle );
}
filesystem->FindClose( findHandle );
}
#else
#define WEAPON_SCRIPT_MANIFEST_FILE "scripts/_weapon_manifest.txt"
219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
// Open the weapon data file, and abort if we can't
KeyValues *pKV = new KeyValues( "WeaponDatafile" );
Q_snprintf(szFullName,sizeof(szFullName), "%s.txt", szFilenameWithoutExtension);
if ( !pKV->LoadFromFile( filesystem, szFullName, pSearchPath ) ) // try to load the normal .txt file first
{
#ifndef _XBOX
if ( pICEKey )
{
Q_snprintf(szFullName,sizeof(szFullName), "%s.ctx", szFilenameWithoutExtension); // fall back to the .ctx file
FileHandle_t f = filesystem->Open( szFullName, "rb", pSearchPath );
if (!f)
{
pKV->deleteThis();
return NULL;
}
// load file into a null-terminated buffer
int fileSize = filesystem->Size(f);
char *buffer = (char*)MemAllocScratch(fileSize + 1);
Assert(buffer);
filesystem->Read(buffer, fileSize, f); // read into local buffer
buffer[fileSize] = 0; // null terminate file as EOF
filesystem->Close( f ); // close file after reading
UTIL_DecodeICE( (unsigned char*)buffer, fileSize, pICEKey );
bool retOK = pKV->LoadFromBuffer( szFullName, buffer, filesystem );
MemFreeScratch();
if ( !retOK )
{
pKV->deleteThis();
return NULL;
}
}
else
{
pKV->deleteThis();
return NULL;
}
#else
pKV->deleteThis();
return NULL;
#endif
}
return pKV;
}
244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
// Open the weapon data file, and abort if we can't
KeyValues *pKV = new KeyValues( "WeaponDatafile" );
#ifndef _XBOX
Q_snprintf(szFullName,sizeof(szFullName), "%s.ctx", szFilenameWithoutExtension); // try to use the .ctx file
if ( pICEKey && filesystem->FileExists( szFullName, pSearchPath ) )
{
FileHandle_t f = filesystem->Open( szFullName, "rb", pSearchPath );
if (!f)
{
pKV->deleteThis();
return NULL;
}
// load file into a null-terminated buffer
int fileSize = filesystem->Size(f);
char *buffer = (char*)MemAllocScratch(fileSize + 1);
Assert(buffer);
filesystem->Read(buffer, fileSize, f); // read into local buffer
buffer[fileSize] = 0; // null terminate file as EOF
filesystem->Close( f ); // close file after reading
UTIL_DecodeICE( (unsigned char*)buffer, fileSize, pICEKey );
bool retOK = pKV->LoadFromBuffer( szFullName, buffer, filesystem );
MemFreeScratch();
if ( !retOK )
{
pKV->deleteThis();
return NULL;
}
}
else
{
#endif
Q_snprintf(szFullName,sizeof(szFullName), "%s.txt", szFilenameWithoutExtension);
if ( !pKV->LoadFromFile( filesystem, szFullName, pSearchPath ) ) // try to load the normal .txt
{
pKV->deleteThis();
return NULL;
}
#ifndef _XBOX
}
#endif
return pKV;
}