Fix not supporting nullptr scriptstrings

This commit is contained in:
Jan
2021-12-30 16:51:16 +01:00
parent 7283cc5640
commit 538c4be839
20 changed files with 209 additions and 142 deletions

View File

@ -33,9 +33,9 @@
using namespace IW3;
ContentLoader::ContentLoader()
: varXAsset(nullptr),
varScriptStringList(nullptr)
{
varXAsset = nullptr;
varScriptStringList = nullptr;
}
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
@ -55,17 +55,8 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
varXString = varScriptStringList->strings;
LoadXStringArray(true, varScriptStringList->count);
for (int i = 0; i < varScriptStringList->count; i++)
{
if (varScriptStringList->strings[i])
{
m_zone->m_script_strings.AddScriptString(varScriptStringList->strings[i]);
}
else
{
m_zone->m_script_strings.AddScriptString("");
}
}
if (varScriptStringList->strings && varScriptStringList->count > 0)
m_zone->m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
}
m_stream->PopBlock();
@ -73,7 +64,7 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1);
}
void ContentLoader::LoadXAsset(const bool atStreamStart)
void ContentLoader::LoadXAsset(const bool atStreamStart) const
{
#define LOAD_ASSET(type_index, typeName, headerEntry) \
case type_index: \
@ -93,33 +84,33 @@ void ContentLoader::LoadXAsset(const bool atStreamStart)
switch (varXAsset->type)
{
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
LOAD_ASSET(ASSET_TYPE_SOUND, snd_alias_list_t, sound)
LOAD_ASSET(ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve)
LOAD_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd)
LOAD_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap)
LOAD_ASSET(ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap)
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp)
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp)
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponDef, weapon)
SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals)
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
LOAD_ASSET(ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset)
LOAD_ASSET(ASSET_TYPE_XANIMPARTS, XAnimParts, parts)
LOAD_ASSET(ASSET_TYPE_XMODEL, XModel, model)
LOAD_ASSET(ASSET_TYPE_MATERIAL, Material, material)
LOAD_ASSET(ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet)
LOAD_ASSET(ASSET_TYPE_IMAGE, GfxImage, image)
LOAD_ASSET(ASSET_TYPE_SOUND, snd_alias_list_t, sound)
LOAD_ASSET(ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve)
LOAD_ASSET(ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd)
LOAD_ASSET(ASSET_TYPE_CLIPMAP, clipMap_t, clipMap)
LOAD_ASSET(ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap)
LOAD_ASSET(ASSET_TYPE_COMWORLD, ComWorld, comWorld)
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp)
LOAD_ASSET(ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp)
LOAD_ASSET(ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts)
LOAD_ASSET(ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld)
LOAD_ASSET(ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef)
LOAD_ASSET(ASSET_TYPE_FONT, Font_s, font)
LOAD_ASSET(ASSET_TYPE_MENULIST, MenuList, menuList)
LOAD_ASSET(ASSET_TYPE_MENU, menuDef_t, menu)
LOAD_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize)
LOAD_ASSET(ASSET_TYPE_WEAPON, WeaponDef, weapon)
SKIP_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals)
LOAD_ASSET(ASSET_TYPE_FX, FxEffectDef, fx)
LOAD_ASSET(ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx)
LOAD_ASSET(ASSET_TYPE_RAWFILE, RawFile, rawfile)
LOAD_ASSET(ASSET_TYPE_STRINGTABLE, StringTable, stringTable)
default:
{

View File

@ -12,7 +12,7 @@ namespace IW3
void LoadScriptStringList(bool atStreamStart);
void LoadXAsset(bool atStreamStart);
void LoadXAsset(bool atStreamStart) const;
void LoadXAssetArray(bool atStreamStart, size_t count);
public:

View File

@ -43,9 +43,9 @@
using namespace IW4;
ContentLoader::ContentLoader()
: varXAsset(nullptr),
varScriptStringList(nullptr)
{
varXAsset = nullptr;
varScriptStringList = nullptr;
}
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
@ -65,17 +65,8 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
varXString = varScriptStringList->strings;
LoadXStringArray(true, varScriptStringList->count);
for (int i = 0; i < varScriptStringList->count; i++)
{
if (varScriptStringList->strings[i])
{
m_zone->m_script_strings.AddScriptString(varScriptStringList->strings[i]);
}
else
{
m_zone->m_script_strings.AddScriptString("");
}
}
if (varScriptStringList->strings && varScriptStringList->count > 0)
m_zone->m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
}
m_stream->PopBlock();
@ -83,7 +74,7 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1);
}
void ContentLoader::LoadXAsset(const bool atStreamStart)
void ContentLoader::LoadXAsset(const bool atStreamStart) const
{
#define LOAD_ASSET(type_index, typeName, headerEntry) \
case type_index: \

View File

@ -12,7 +12,7 @@ namespace IW4
void LoadScriptStringList(bool atStreamStart);
void LoadXAsset(bool atStreamStart);
void LoadXAsset(bool atStreamStart) const;
void LoadXAssetArray(bool atStreamStart, size_t count);
public:

View File

@ -48,9 +48,9 @@
using namespace IW5;
ContentLoader::ContentLoader()
: varXAsset(nullptr),
varScriptStringList(nullptr)
{
varXAsset = nullptr;
varScriptStringList = nullptr;
}
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
@ -70,17 +70,8 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
varXString = varScriptStringList->strings;
LoadXStringArray(true, varScriptStringList->count);
for (int i = 0; i < varScriptStringList->count; i++)
{
if (varScriptStringList->strings[i])
{
m_zone->m_script_strings.AddScriptString(varScriptStringList->strings[i]);
}
else
{
m_zone->m_script_strings.AddScriptString("");
}
}
if (varScriptStringList->strings && varScriptStringList->count > 0)
m_zone->m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
}
m_stream->PopBlock();
@ -88,7 +79,7 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1);
}
void ContentLoader::LoadXAsset(const bool atStreamStart)
void ContentLoader::LoadXAsset(const bool atStreamStart) const
{
#define LOAD_ASSET(type_index, typeName, headerEntry) \
case type_index: \

View File

@ -12,7 +12,7 @@ namespace IW5
void LoadScriptStringList(bool atStreamStart);
void LoadXAsset(bool atStreamStart);
void LoadXAsset(bool atStreamStart) const;
void LoadXAssetArray(bool atStreamStart, size_t count);
public:

View File

@ -40,9 +40,9 @@
using namespace T5;
ContentLoader::ContentLoader()
: varXAsset(nullptr),
varScriptStringList(nullptr)
{
varXAsset = nullptr;
varScriptStringList = nullptr;
}
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
@ -62,17 +62,8 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
varXString = varScriptStringList->strings;
LoadXStringArray(true, varScriptStringList->count);
for (int i = 0; i < varScriptStringList->count; i++)
{
if (varScriptStringList->strings[i])
{
m_zone->m_script_strings.AddScriptString(varScriptStringList->strings[i]);
}
else
{
m_zone->m_script_strings.AddScriptString("");
}
}
if (varScriptStringList->strings && varScriptStringList->count > 0)
m_zone->m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
}
m_stream->PopBlock();
@ -80,7 +71,7 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1);
}
void ContentLoader::LoadXAsset(const bool atStreamStart)
void ContentLoader::LoadXAsset(const bool atStreamStart) const
{
#define LOAD_ASSET(type_index, typeName, headerEntry) \
case type_index: \

View File

@ -12,7 +12,7 @@ namespace T5
void LoadScriptStringList(bool atStreamStart);
void LoadXAsset(bool atStreamStart);
void LoadXAsset(bool atStreamStart) const;
void LoadXAssetArray(bool atStreamStart, size_t count);
public:

View File

@ -56,9 +56,9 @@
using namespace T6;
ContentLoader::ContentLoader()
: varXAsset(nullptr),
varScriptStringList(nullptr)
{
varXAsset = nullptr;
varScriptStringList = nullptr;
}
void ContentLoader::LoadScriptStringList(const bool atStreamStart)
@ -78,17 +78,8 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
varXString = varScriptStringList->strings;
LoadXStringArray(true, varScriptStringList->count);
for (int i = 0; i < varScriptStringList->count; i++)
{
if (varScriptStringList->strings[i])
{
m_zone->m_script_strings.AddScriptString(varScriptStringList->strings[i]);
}
else
{
m_zone->m_script_strings.AddScriptString("");
}
}
if (varScriptStringList->strings && varScriptStringList->count > 0)
m_zone->m_script_strings.InitializeForExistingZone(varScriptStringList->strings, static_cast<size_t>(varScriptStringList->count));
}
m_stream->PopBlock();
@ -96,7 +87,7 @@ void ContentLoader::LoadScriptStringList(const bool atStreamStart)
assert(m_zone->m_script_strings.Count() <= SCR_STRING_MAX + 1);
}
void ContentLoader::LoadXAsset(const bool atStreamStart)
void ContentLoader::LoadXAsset(const bool atStreamStart) const
{
#define LOAD_ASSET(type_index, typeName, headerEntry) \
case type_index: \

View File

@ -12,7 +12,7 @@ namespace T6
void LoadScriptStringList(bool atStreamStart);
void LoadXAsset(bool atStreamStart);
void LoadXAsset(bool atStreamStart) const;
void LoadXAssetArray(bool atStreamStart, size_t count);
public:

View File

@ -8,10 +8,6 @@ AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStr
m_asset_type(assetType),
varScriptString(nullptr)
{
m_asset_type = assetType;
m_zone = zone;
m_stream = stream;
varScriptString = nullptr;
}
void AssetLoader::AddDependency(XAssetInfoGeneric* assetInfo)