Merge branch 'Laupetin:main' into main

This commit is contained in:
Alex 2024-02-06 22:01:47 -05:00 committed by GitHub
commit aa2bebedde
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
57 changed files with 1573 additions and 1290 deletions

View File

@ -60,7 +60,7 @@ jobs:
submodules: recursive submodules: recursive
- name: Add MSBuild to PATH - name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.3.1 uses: microsoft/setup-msbuild@v2.0.0
- name: Setup premake - name: Setup premake
uses: abel0b/setup-premake@v2.3 uses: abel0b/setup-premake@v2.3

View File

@ -55,7 +55,7 @@ jobs:
submodules: recursive submodules: recursive
- name: Add MSBuild to PATH - name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v1.3.1 uses: microsoft/setup-msbuild@v2.0.0
- name: Setup premake - name: Setup premake
uses: abel0b/setup-premake@v2.3 uses: abel0b/setup-premake@v2.3

View File

@ -98,6 +98,9 @@ namespace T6
WFT_ATTACHMENTS, WFT_ATTACHMENTS,
WFT_ATTACHMENT_UNIQUES, WFT_ATTACHMENT_UNIQUES,
// Custom
WFT_ANIM_NAME,
WFT_NUM_FIELD_TYPES WFT_NUM_FIELD_TYPES
}; };

View File

@ -102,7 +102,7 @@ void ZoneCreator::HandleMetadata(Zone* zone, const ZoneCreationContext& context)
for (auto i = 0u; i < kvpList.size(); i++) for (auto i = 0u; i < kvpList.size(); i++)
kvps->keyValuePairs[i] = kvpList[i]; kvps->keyValuePairs[i] = kvpList[i];
zone->m_pools->AddAsset(ASSET_TYPE_KEYVALUEPAIRS, zone->m_name, kvps, std::vector<XAssetInfoGeneric*>(), std::vector<scr_string_t>()); zone->m_pools->AddAsset(std::make_unique<XAssetInfo<KeyValuePairs>>(ASSET_TYPE_KEYVALUEPAIRS, zone->m_name, kvps));
} }
} }

View File

@ -27,93 +27,93 @@ namespace T6
{"handModel", offsetof(WeaponFullDef, weapDef.handXModel), CSPFT_XMODEL }, {"handModel", offsetof(WeaponFullDef, weapDef.handXModel), CSPFT_XMODEL },
{"hideTags", offsetof(WeaponFullDef, hideTags), WFT_HIDETAGS }, {"hideTags", offsetof(WeaponFullDef, hideTags), WFT_HIDETAGS },
{"notetrackSoundMap", offsetof(WeaponFullDef, notetrackSoundMapKeys), WFT_NOTETRACKSOUNDMAP }, {"notetrackSoundMap", offsetof(WeaponFullDef, notetrackSoundMapKeys), WFT_NOTETRACKSOUNDMAP },
{"idleAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_IDLE]), CSPFT_STRING }, {"idleAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_IDLE]), WFT_ANIM_NAME },
{"idleAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_IDLE_LEFT]), CSPFT_STRING }, {"idleAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_IDLE_LEFT]), WFT_ANIM_NAME },
{"emptyIdleAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_EMPTY_IDLE]), CSPFT_STRING }, {"emptyIdleAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_EMPTY_IDLE]), WFT_ANIM_NAME },
{"emptyIdleAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_EMPTY_IDLE_LEFT]), CSPFT_STRING }, {"emptyIdleAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_EMPTY_IDLE_LEFT]), WFT_ANIM_NAME },
{"fireIntroAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FIRE_INTRO]), CSPFT_STRING }, {"fireIntroAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FIRE_INTRO]), WFT_ANIM_NAME },
{"fireAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FIRE]), CSPFT_STRING }, {"fireAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FIRE]), WFT_ANIM_NAME },
{"fireAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FIRE_LEFT]), CSPFT_STRING }, {"fireAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FIRE_LEFT]), WFT_ANIM_NAME },
{"holdFireAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_HOLD_FIRE]), CSPFT_STRING }, {"holdFireAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_HOLD_FIRE]), WFT_ANIM_NAME },
{"lastShotAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_LASTSHOT]), CSPFT_STRING }, {"lastShotAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_LASTSHOT]), WFT_ANIM_NAME },
{"lastShotAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_LASTSHOT_LEFT]), CSPFT_STRING }, {"lastShotAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_LASTSHOT_LEFT]), WFT_ANIM_NAME },
{"flourishAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FINALSHOT]), CSPFT_STRING }, {"flourishAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FINALSHOT]), WFT_ANIM_NAME },
{"flourishAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FINALSHOT_LEFT]), CSPFT_STRING }, {"flourishAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FINALSHOT_LEFT]), WFT_ANIM_NAME },
{"detonateAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DETONATE]), CSPFT_STRING }, {"detonateAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DETONATE]), WFT_ANIM_NAME },
{"rechamberAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RECHAMBER]), CSPFT_STRING }, {"rechamberAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RECHAMBER]), WFT_ANIM_NAME },
{"meleeAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE]), CSPFT_STRING }, {"meleeAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE]), WFT_ANIM_NAME },
{"meleeAnimEmpty", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE_EMPTY]), CSPFT_STRING }, {"meleeAnimEmpty", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE_EMPTY]), WFT_ANIM_NAME },
{"meleeAnim1", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE1]), CSPFT_STRING }, {"meleeAnim1", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE1]), WFT_ANIM_NAME },
{"meleeAnim2", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE2]), CSPFT_STRING }, {"meleeAnim2", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE2]), WFT_ANIM_NAME },
{"meleeAnim3", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE3]), CSPFT_STRING }, {"meleeAnim3", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE3]), WFT_ANIM_NAME },
{"meleeChargeAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE_CHARGE]), CSPFT_STRING }, {"meleeChargeAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE_CHARGE]), WFT_ANIM_NAME },
{"meleeChargeAnimEmpty", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE_CHARGE_EMPTY]), CSPFT_STRING }, {"meleeChargeAnimEmpty", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MELEE_CHARGE_EMPTY]), WFT_ANIM_NAME },
{"reloadAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD]), CSPFT_STRING }, {"reloadAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD]), WFT_ANIM_NAME },
{"reloadAnimRight", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_RIGHT]), CSPFT_STRING }, {"reloadAnimRight", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_RIGHT]), WFT_ANIM_NAME },
{"reloadAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_LEFT]), CSPFT_STRING }, {"reloadAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_LEFT]), WFT_ANIM_NAME },
{"reloadEmptyAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_EMPTY]), CSPFT_STRING }, {"reloadEmptyAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_EMPTY]), WFT_ANIM_NAME },
{"reloadEmptyAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_EMPTY_LEFT]), CSPFT_STRING }, {"reloadEmptyAnimLeft", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_EMPTY_LEFT]), WFT_ANIM_NAME },
{"reloadStartAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_START]), CSPFT_STRING }, {"reloadStartAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_START]), WFT_ANIM_NAME },
{"reloadEndAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_END]), CSPFT_STRING }, {"reloadEndAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_END]), WFT_ANIM_NAME },
{"reloadQuickAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_QUICK]), CSPFT_STRING }, {"reloadQuickAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_QUICK]), WFT_ANIM_NAME },
{"reloadQuickEmptyAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_QUICK_EMPTY]), CSPFT_STRING }, {"reloadQuickEmptyAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RELOAD_QUICK_EMPTY]), WFT_ANIM_NAME },
{"raiseAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RAISE]), CSPFT_STRING }, {"raiseAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_RAISE]), WFT_ANIM_NAME },
{"dropAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DROP]), CSPFT_STRING }, {"dropAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DROP]), WFT_ANIM_NAME },
{"firstRaiseAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FIRST_RAISE]), CSPFT_STRING }, {"firstRaiseAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_FIRST_RAISE]), WFT_ANIM_NAME },
{"altRaiseAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ALT_RAISE]), CSPFT_STRING }, {"altRaiseAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ALT_RAISE]), WFT_ANIM_NAME },
{"altDropAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ALT_DROP]), CSPFT_STRING }, {"altDropAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ALT_DROP]), WFT_ANIM_NAME },
{"quickRaiseAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_QUICK_RAISE]), CSPFT_STRING }, {"quickRaiseAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_QUICK_RAISE]), WFT_ANIM_NAME },
{"quickDropAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_QUICK_DROP]), CSPFT_STRING }, {"quickDropAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_QUICK_DROP]), WFT_ANIM_NAME },
{"emptyRaiseAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_EMPTY_RAISE]), CSPFT_STRING }, {"emptyRaiseAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_EMPTY_RAISE]), WFT_ANIM_NAME },
{"emptyDropAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_EMPTY_DROP]), CSPFT_STRING }, {"emptyDropAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_EMPTY_DROP]), WFT_ANIM_NAME },
{"sprintInAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_IN]), CSPFT_STRING }, {"sprintInAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_IN]), WFT_ANIM_NAME },
{"sprintLoopAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_LOOP]), CSPFT_STRING }, {"sprintLoopAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_LOOP]), WFT_ANIM_NAME },
{"sprintOutAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_OUT]), CSPFT_STRING }, {"sprintOutAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_OUT]), WFT_ANIM_NAME },
{"sprintInEmptyAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_EMPTY_IN]), CSPFT_STRING }, {"sprintInEmptyAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_EMPTY_IN]), WFT_ANIM_NAME },
{"sprintLoopEmptyAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_EMPTY_LOOP]), CSPFT_STRING }, {"sprintLoopEmptyAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_EMPTY_LOOP]), WFT_ANIM_NAME },
{"sprintOutEmptyAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_EMPTY_OUT]), CSPFT_STRING }, {"sprintOutEmptyAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SPRINT_EMPTY_OUT]), WFT_ANIM_NAME },
{"lowReadyInAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_LOWREADY_IN]), CSPFT_STRING }, {"lowReadyInAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_LOWREADY_IN]), WFT_ANIM_NAME },
{"lowReadyLoopAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_LOWREADY_LOOP]), CSPFT_STRING }, {"lowReadyLoopAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_LOWREADY_LOOP]), WFT_ANIM_NAME },
{"lowReadyOutAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_LOWREADY_OUT]), CSPFT_STRING }, {"lowReadyOutAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_LOWREADY_OUT]), WFT_ANIM_NAME },
{"contFireInAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CONT_FIRE_IN]), CSPFT_STRING }, {"contFireInAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CONT_FIRE_IN]), WFT_ANIM_NAME },
{"contFireLoopAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CONT_FIRE_LOOP]), CSPFT_STRING }, {"contFireLoopAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CONT_FIRE_LOOP]), WFT_ANIM_NAME },
{"contFireOutAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CONT_FIRE_OUT]), CSPFT_STRING }, {"contFireOutAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CONT_FIRE_OUT]), WFT_ANIM_NAME },
{"crawlInAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_IN]), CSPFT_STRING }, {"crawlInAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_IN]), WFT_ANIM_NAME },
{"crawlForwardAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_FORWARD]), CSPFT_STRING }, {"crawlForwardAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_FORWARD]), WFT_ANIM_NAME },
{"crawlBackAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_BACK]), CSPFT_STRING }, {"crawlBackAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_BACK]), WFT_ANIM_NAME },
{"crawlRightAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_RIGHT]), CSPFT_STRING }, {"crawlRightAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_RIGHT]), WFT_ANIM_NAME },
{"crawlLeftAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_LEFT]), CSPFT_STRING }, {"crawlLeftAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_LEFT]), WFT_ANIM_NAME },
{"crawlOutAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_OUT]), CSPFT_STRING }, {"crawlOutAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_OUT]), WFT_ANIM_NAME },
{"crawlEmptyInAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_IN]), CSPFT_STRING }, {"crawlEmptyInAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_IN]), WFT_ANIM_NAME },
{"crawlEmptyForwardAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_FORWARD]), CSPFT_STRING }, {"crawlEmptyForwardAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_FORWARD]), WFT_ANIM_NAME },
{"crawlEmptyBackAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_BACK]), CSPFT_STRING }, {"crawlEmptyBackAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_BACK]), WFT_ANIM_NAME },
{"crawlEmptyRightAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_RIGHT]), CSPFT_STRING }, {"crawlEmptyRightAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_RIGHT]), WFT_ANIM_NAME },
{"crawlEmptyLeftAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_LEFT]), CSPFT_STRING }, {"crawlEmptyLeftAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_LEFT]), WFT_ANIM_NAME },
{"crawlEmptyOutAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_OUT]), CSPFT_STRING }, {"crawlEmptyOutAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CRAWL_EMPTY_OUT]), WFT_ANIM_NAME },
{"deployAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DEPLOY]), CSPFT_STRING }, {"deployAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DEPLOY]), WFT_ANIM_NAME },
{"nightVisionWearAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_NIGHTVISION_WEAR]), CSPFT_STRING }, {"nightVisionWearAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_NIGHTVISION_WEAR]), WFT_ANIM_NAME },
{"nightVisionRemoveAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_NIGHTVISION_REMOVE]), CSPFT_STRING }, {"nightVisionRemoveAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_NIGHTVISION_REMOVE]), WFT_ANIM_NAME },
{"adsFireAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_FIRE]), CSPFT_STRING }, {"adsFireAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_FIRE]), WFT_ANIM_NAME },
{"adsLastShotAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_LASTSHOT]), CSPFT_STRING }, {"adsLastShotAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_LASTSHOT]), WFT_ANIM_NAME },
{"adsRechamberAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_RECHAMBER]), CSPFT_STRING }, {"adsRechamberAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_RECHAMBER]), WFT_ANIM_NAME },
{"adsUpAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_UP]), CSPFT_STRING }, {"adsUpAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_UP]), WFT_ANIM_NAME },
{"adsDownAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_DOWN]), CSPFT_STRING }, {"adsDownAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_DOWN]), WFT_ANIM_NAME },
{"adsUpOtherScopeAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_UP_OTHER_SCOPE]), CSPFT_STRING }, {"adsUpOtherScopeAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_UP_OTHER_SCOPE]), WFT_ANIM_NAME },
{"adsFireIntroAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_FIRE_INTRO]), CSPFT_STRING }, {"adsFireIntroAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_ADS_FIRE_INTRO]), WFT_ANIM_NAME },
{"breakdownAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_BREAKDOWN]), CSPFT_STRING }, {"breakdownAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_BREAKDOWN]), WFT_ANIM_NAME },
{"dtp_in", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_IN]), CSPFT_STRING }, {"dtp_in", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_IN]), WFT_ANIM_NAME },
{"dtp_loop", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_LOOP]), CSPFT_STRING }, {"dtp_loop", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_LOOP]), WFT_ANIM_NAME },
{"dtp_out", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_OUT]), CSPFT_STRING }, {"dtp_out", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_OUT]), WFT_ANIM_NAME },
{"dtp_empty_in", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_EMPTY_IN]), CSPFT_STRING }, {"dtp_empty_in", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_EMPTY_IN]), WFT_ANIM_NAME },
{"dtp_empty_loop", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_EMPTY_LOOP]), CSPFT_STRING }, {"dtp_empty_loop", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_EMPTY_LOOP]), WFT_ANIM_NAME },
{"dtp_empty_out", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_EMPTY_OUT]), CSPFT_STRING }, {"dtp_empty_out", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_DTP_EMPTY_OUT]), WFT_ANIM_NAME },
{"slide_in", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SLIDE_IN]), CSPFT_STRING }, {"slide_in", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_SLIDE_IN]), WFT_ANIM_NAME },
{"mantleAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MANTLE]), CSPFT_STRING }, {"mantleAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_MANTLE]), WFT_ANIM_NAME },
{"sprintCameraAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CAMERA_SPRINT_LOOP]), CSPFT_STRING }, {"sprintCameraAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CAMERA_SPRINT_LOOP]), WFT_ANIM_NAME },
{"dtpInCameraAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CAMERA_DTP_IN]), CSPFT_STRING }, {"dtpInCameraAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CAMERA_DTP_IN]), WFT_ANIM_NAME },
{"dtpLoopCameraAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CAMERA_DTP_LOOP]), CSPFT_STRING }, {"dtpLoopCameraAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CAMERA_DTP_LOOP]), WFT_ANIM_NAME },
{"dtpOutCameraAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CAMERA_DTP_OUT]), CSPFT_STRING }, {"dtpOutCameraAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CAMERA_DTP_OUT]), WFT_ANIM_NAME },
{"mantleCameraAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CAMERA_MANTLE]), CSPFT_STRING }, {"mantleCameraAnim", offsetof(WeaponFullDef, szXAnims[WEAP_ANIM_CAMERA_MANTLE]), WFT_ANIM_NAME },
{"script", offsetof(WeaponFullDef, weapDef.szScript), CSPFT_STRING }, {"script", offsetof(WeaponFullDef, weapDef.szScript), CSPFT_STRING },
{"weaponType", offsetof(WeaponFullDef, weapDef.weapType), WFT_WEAPONTYPE }, {"weaponType", offsetof(WeaponFullDef, weapDef.weapType), WFT_WEAPONTYPE },
{"weaponClass", offsetof(WeaponFullDef, weapDef.weapClass), WFT_WEAPONCLASS }, {"weaponClass", offsetof(WeaponFullDef, weapDef.weapClass), WFT_WEAPONCLASS },

View File

@ -19,17 +19,15 @@ AssetLoadingContext* AssetLoadingManager::GetAssetLoadingContext() const
return &m_context; return &m_context;
} }
XAssetInfoGeneric* AssetLoadingManager::AddAsset(const asset_type_t assetType, XAssetInfoGeneric* AssetLoadingManager::AddAssetInternal(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone)
{ {
m_last_dependency_loaded = m_context.m_zone->m_pools->AddAsset(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), zone); const auto assetType = xAssetInfo->m_type;
const auto* pAssetName = xAssetInfo->m_name.c_str();
m_last_dependency_loaded = m_context.m_zone->m_pools->AddAsset(std::move(xAssetInfo));
if (m_last_dependency_loaded == nullptr) if (m_last_dependency_loaded == nullptr)
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << assetName << "\"" std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << pAssetName << "\"\n";
<< std::endl;
return m_last_dependency_loaded; return m_last_dependency_loaded;
} }
@ -39,11 +37,24 @@ XAssetInfoGeneric* AssetLoadingManager::AddAsset(const asset_type_t assetType,
std::vector<XAssetInfoGeneric*> dependencies, std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings) std::vector<scr_string_t> usedScriptStrings)
{ {
m_last_dependency_loaded = m_context.m_zone->m_pools->AddAsset(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings)); return AddAsset(std::make_unique<XAssetInfoGeneric>(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings)));
if (m_last_dependency_loaded == nullptr) }
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << assetName << "\""
<< std::endl; XAssetInfoGeneric* AssetLoadingManager::AddAsset(asset_type_t assetType,
return m_last_dependency_loaded; const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences)
{
return AddAsset(std::make_unique<XAssetInfoGeneric>(
assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences)));
}
XAssetInfoGeneric* AssetLoadingManager::AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
xAssetInfo->m_zone = m_context.m_zone;
return AddAssetInternal(std::move(xAssetInfo));
} }
XAssetInfoGeneric* AssetLoadingManager::LoadIgnoredDependency(const asset_type_t assetType, const std::string& assetName, IAssetLoader* loader) XAssetInfoGeneric* AssetLoadingManager::LoadIgnoredDependency(const asset_type_t assetType, const std::string& assetName, IAssetLoader* loader)
@ -64,20 +75,13 @@ XAssetInfoGeneric* AssetLoadingManager::LoadIgnoredDependency(const asset_type_t
auto* existingAsset = loader->LoadFromGlobalAssetPools(assetName); auto* existingAsset = loader->LoadFromGlobalAssetPools(assetName);
if (existingAsset) if (existingAsset)
{ {
std::vector<XAssetInfoGeneric*> dependencies; AddAssetInternal(std::make_unique<XAssetInfoGeneric>(*existingAsset));
AddAsset(existingAsset->m_type,
existingAsset->m_name,
existingAsset->m_ptr,
std::vector<XAssetInfoGeneric*>(),
std::vector<scr_string_t>(),
existingAsset->m_zone);
auto* lastDependency = m_last_dependency_loaded; auto* lastDependency = m_last_dependency_loaded;
m_last_dependency_loaded = nullptr; m_last_dependency_loaded = nullptr;
return lastDependency; return lastDependency;
} }
std::cout << "Failed to create empty asset \"" << assetName << "\" for type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"" std::cout << "Failed to create empty asset \"" << assetName << "\" for type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"\n";
<< std::endl;
return nullptr; return nullptr;
} }
@ -105,6 +109,7 @@ XAssetInfoGeneric* AssetLoadingManager::LoadAssetDependency(const asset_type_t a
if (existingAsset) if (existingAsset)
{ {
std::vector<XAssetInfoGeneric*> dependencies; std::vector<XAssetInfoGeneric*> dependencies;
std::vector<IndirectAssetReference> indirectAssetReferences;
for (const auto* dependency : existingAsset->m_dependencies) for (const auto* dependency : existingAsset->m_dependencies)
{ {
auto* newDependency = LoadDependency(dependency->m_type, dependency->m_name); auto* newDependency = LoadDependency(dependency->m_type, dependency->m_name);
@ -114,23 +119,29 @@ XAssetInfoGeneric* AssetLoadingManager::LoadAssetDependency(const asset_type_t a
return nullptr; return nullptr;
} }
indirectAssetReferences.reserve(existingAsset->m_indirect_asset_references.size());
for (const auto& indirectAssetReference : existingAsset->m_indirect_asset_references)
indirectAssetReferences.emplace_back(LoadIndirectAssetReference(indirectAssetReference.m_type, indirectAssetReference.m_name));
// Make sure any used script string is available in the created zone // Make sure any used script string is available in the created zone
// The replacement of the scr_string_t values will be done upon writing // The replacement of the scr_string_t values will be done upon writing
for (const auto scrString : existingAsset->m_used_script_strings) for (const auto scrString : existingAsset->m_used_script_strings)
m_context.m_zone->m_script_strings.AddOrGetScriptString(existingAsset->m_zone->m_script_strings.CValue(scrString)); m_context.m_zone->m_script_strings.AddOrGetScriptString(existingAsset->m_zone->m_script_strings.CValue(scrString));
AddAsset(existingAsset->m_type, AddAssetInternal(std::make_unique<XAssetInfoGeneric>(existingAsset->m_type,
existingAsset->m_name, existingAsset->m_name,
existingAsset->m_ptr, existingAsset->m_ptr,
std::move(dependencies), std::move(dependencies),
existingAsset->m_used_script_strings, existingAsset->m_used_script_strings,
existingAsset->m_zone); std::move(indirectAssetReferences),
existingAsset->m_zone));
auto* lastDependency = m_last_dependency_loaded; auto* lastDependency = m_last_dependency_loaded;
m_last_dependency_loaded = nullptr; m_last_dependency_loaded = nullptr;
return lastDependency; return lastDependency;
} }
std::cout << "Failed to load asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\": \"" << assetName << "\"" << std::endl; std::cout << "Failed to load asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\": \"" << assetName << "\"\n";
return nullptr; return nullptr;
} }
@ -154,6 +165,27 @@ XAssetInfoGeneric* AssetLoadingManager::LoadDependency(const asset_type_t assetT
return LoadAssetDependency(assetType, assetName, loader->second.get()); return LoadAssetDependency(assetType, assetName, loader->second.get());
} }
std::cout << "Failed to find loader for asset type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"" << std::endl; std::cout << "Failed to find loader for asset type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"\n";
return nullptr; return nullptr;
} }
IndirectAssetReference AssetLoadingManager::LoadIndirectAssetReference(const asset_type_t assetType, const std::string& assetName)
{
const auto* alreadyLoadedAsset = m_context.m_zone->m_pools->GetAsset(assetType, assetName);
if (alreadyLoadedAsset)
return IndirectAssetReference(assetType, assetName);
const auto ignoreEntry = m_context.m_ignored_asset_map.find(assetName);
if (ignoreEntry != m_context.m_ignored_asset_map.end() && ignoreEntry->second == assetType)
return IndirectAssetReference(assetType, assetName);
const auto loader = m_asset_loaders_by_type.find(assetType);
if (loader != m_asset_loaders_by_type.end())
{
LoadAssetDependency(assetType, assetName, loader->second.get());
return IndirectAssetReference(assetType, assetName);
}
std::cout << "Failed to find loader for asset type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"\n";
return IndirectAssetReference(assetType, assetName);
}

View File

@ -14,12 +14,7 @@ class AssetLoadingManager final : public IAssetLoadingManager
XAssetInfoGeneric* LoadIgnoredDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader); XAssetInfoGeneric* LoadIgnoredDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader);
XAssetInfoGeneric* LoadAssetDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader); XAssetInfoGeneric* LoadAssetDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader);
XAssetInfoGeneric* AddAsset(asset_type_t assetType, XAssetInfoGeneric* AddAssetInternal(std::unique_ptr<XAssetInfoGeneric> xAssetInfo);
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone);
public: public:
AssetLoadingManager(const std::map<asset_type_t, std::unique_ptr<IAssetLoader>>& assetLoadersByType, AssetLoadingContext& context); AssetLoadingManager(const std::map<asset_type_t, std::unique_ptr<IAssetLoader>>& assetLoadersByType, AssetLoadingContext& context);
@ -33,5 +28,13 @@ public:
void* asset, void* asset,
std::vector<XAssetInfoGeneric*> dependencies, std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings) override; std::vector<scr_string_t> usedScriptStrings) override;
XAssetInfoGeneric* AddAsset(asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences) override;
XAssetInfoGeneric* AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) override; XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) override;
IndirectAssetReference LoadIndirectAssetReference(asset_type_t assetType, const std::string& assetName) override;
}; };

View File

@ -23,6 +23,13 @@ public:
void* asset, void* asset,
std::vector<XAssetInfoGeneric*> dependencies, std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings) = 0; std::vector<scr_string_t> usedScriptStrings) = 0;
virtual XAssetInfoGeneric* AddAsset(asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences) = 0;
virtual XAssetInfoGeneric* AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) = 0;
XAssetInfoGeneric* AddAsset(const asset_type_t assetType, const std::string& assetName, void* asset) XAssetInfoGeneric* AddAsset(const asset_type_t assetType, const std::string& assetName, void* asset)
{ {
@ -30,4 +37,5 @@ public:
} }
virtual XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) = 0; virtual XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) = 0;
virtual IndirectAssetReference LoadIndirectAssetReference(asset_type_t assetType, const std::string& assetName) = 0;
}; };

View File

@ -24,34 +24,36 @@ namespace T6
std::vector<std::string> valueArray; std::vector<std::string> valueArray;
if (!ParseAsArray(value, valueArray)) if (!ParseAsArray(value, valueArray))
{ {
std::cout << "Failed to parse hide tags as array" << std::endl; std::cout << "Failed to parse hide tags as array\n";
return false; return false;
} }
if (valueArray.size() > std::extent<decltype(WeaponFullDef::hideTags)>::value) if (valueArray.size() > std::extent_v<decltype(WeaponFullDef::hideTags)>)
{ {
std::cout << "Cannot have more than " << std::extent<decltype(WeaponFullDef::hideTags)>::value << " hide tags!" << std::endl; std::cout << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::hideTags)> << " hide tags!\n";
return false; return false;
} }
auto* hideTags = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset); auto* hideTags = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
auto currentHideTag = 0u;
if (valueArray.size() < std::extent<decltype(WeaponFullDef::hideTags)>::value) if (valueArray.size() < std::extent_v<decltype(WeaponFullDef::hideTags)>)
{ {
m_used_script_string_list.emplace(m_zone_script_strings.AddOrGetScriptString("")); m_used_script_string_list.emplace(m_zone_script_strings.AddOrGetScriptString(nullptr));
} }
auto currentHideTag = 0u;
for (; currentHideTag < valueArray.size(); currentHideTag++) for (; currentHideTag < valueArray.size(); currentHideTag++)
{ {
const auto scrString = m_zone_script_strings.AddOrGetScriptString(valueArray[currentHideTag]); const auto& currentValue = valueArray[currentHideTag];
const auto scrString =
!currentValue.empty() ? m_zone_script_strings.AddOrGetScriptString(currentValue) : m_zone_script_strings.AddOrGetScriptString(nullptr);
hideTags[currentHideTag] = scrString; hideTags[currentHideTag] = scrString;
m_used_script_string_list.emplace(scrString); m_used_script_string_list.emplace(scrString);
} }
for (; currentHideTag < std::extent<decltype(WeaponFullDef::hideTags)>::value; currentHideTag++) for (; currentHideTag < std::extent_v<decltype(WeaponFullDef::hideTags)>; currentHideTag++)
{ {
hideTags[currentHideTag] = m_zone_script_strings.GetScriptString(""); hideTags[currentHideTag] = m_zone_script_strings.GetScriptString(nullptr);
} }
return true; return true;
@ -81,38 +83,43 @@ namespace T6
std::vector<std::pair<std::string, std::string>> pairs; std::vector<std::pair<std::string, std::string>> pairs;
if (!ParseAsPairs(value, pairs)) if (!ParseAsPairs(value, pairs))
{ {
std::cout << "Failed to parse notetracksoundmap as pairs" << std::endl; std::cout << "Failed to parse notetracksoundmap as pairs\n";
return false; return false;
} }
if (pairs.size() > std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value) if (pairs.size() > std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>)
{ {
std::cout << "Cannot have more than " << std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value << " notetracksoundmap entries!" std::cout << "Cannot have more than " << std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)> << " notetracksoundmap entries!\n";
<< std::endl;
return false; return false;
} }
auto* keys = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset); auto* keys = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
auto* values = &keys[std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value]; auto* values = &keys[std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>];
auto currentEntryNum = 0u; auto currentEntryNum = 0u;
if (pairs.size() < std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value) if (pairs.size() < std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>)
{ {
m_used_script_string_list.emplace(m_zone_script_strings.AddOrGetScriptString("")); m_used_script_string_list.emplace(m_zone_script_strings.AddOrGetScriptString(nullptr));
} }
for (; currentEntryNum < pairs.size(); currentEntryNum++) for (; currentEntryNum < pairs.size(); currentEntryNum++)
{ {
keys[currentEntryNum] = m_zone_script_strings.AddOrGetScriptString(pairs[currentEntryNum].first); const auto& currentValue = pairs[currentEntryNum];
m_used_script_string_list.emplace(keys[currentEntryNum]); const auto keyScriptString = !currentValue.first.empty() ? m_zone_script_strings.AddOrGetScriptString(currentValue.first)
: m_zone_script_strings.AddOrGetScriptString(nullptr);
const auto valueScriptString = !currentValue.second.empty() ? m_zone_script_strings.AddOrGetScriptString(currentValue.second)
: m_zone_script_strings.AddOrGetScriptString(nullptr);
values[currentEntryNum] = m_zone_script_strings.AddOrGetScriptString(pairs[currentEntryNum].second); keys[currentEntryNum] = keyScriptString;
m_used_script_string_list.emplace(values[currentEntryNum]); m_used_script_string_list.emplace(keyScriptString);
values[currentEntryNum] = valueScriptString;
m_used_script_string_list.emplace(valueScriptString);
} }
for (; currentEntryNum < std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value; currentEntryNum++) for (; currentEntryNum < std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>; currentEntryNum++)
{ {
const auto emptyScr = m_zone_script_strings.GetScriptString(""); const auto emptyScr = m_zone_script_strings.GetScriptString(nullptr);
keys[currentEntryNum] = emptyScr; keys[currentEntryNum] = emptyScr;
values[currentEntryNum] = emptyScr; values[currentEntryNum] = emptyScr;
} }
@ -201,7 +208,7 @@ namespace T6
} }
auto** attachmentUniques = reinterpret_cast<WeaponAttachmentUnique**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset); auto** attachmentUniques = reinterpret_cast<WeaponAttachmentUnique**>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
auto attachmentCombinationIndex = std::extent<decltype(WeaponFullDef::attachments)>::value; auto attachmentCombinationIndex = std::extent_v<decltype(WeaponFullDef::attachments)>;
for (const auto& attachmentUniqueName : valueArray) for (const auto& attachmentUniqueName : valueArray)
{ {
@ -216,11 +223,11 @@ namespace T6
if (HasMoreThanOneAttachmentSetInMask(attachmentUniqueAsset->combinedAttachmentTypeMask)) if (HasMoreThanOneAttachmentSetInMask(attachmentUniqueAsset->combinedAttachmentTypeMask))
{ {
if (attachmentCombinationIndex >= std::extent<decltype(WeaponFullDef::attachmentUniques)>::value) if (attachmentCombinationIndex >= std::extent_v<decltype(WeaponFullDef::attachmentUniques)>)
{ {
std::cout << "Cannot have more than " std::cout << "Cannot have more than "
<< (std::extent<decltype(WeaponFullDef::attachmentUniques)>::value - std::extent<decltype(WeaponFullDef::attachments)>::value) << (std::extent_v<decltype(WeaponFullDef::attachmentUniques)> - std::extent_v<decltype(WeaponFullDef::attachments)>)
<< " combined attachment attachment unique entries!" << std::endl; << " combined attachment attachment unique entries!\n";
return false; return false;
} }
@ -232,15 +239,14 @@ namespace T6
if (static_cast<unsigned>(attachmentUniqueAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT) if (static_cast<unsigned>(attachmentUniqueAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT)
{ {
std::cout << "Invalid attachment type " << attachmentUniqueAsset->attachmentType << " for attachment unique asset \"" std::cout << "Invalid attachment type " << attachmentUniqueAsset->attachmentType << " for attachment unique asset \""
<< attachmentUniqueName << "\"" << std::endl; << attachmentUniqueName << "\"\n";
return false; return false;
} }
if (attachmentUniques[attachmentUniqueAsset->attachmentType] != nullptr) if (attachmentUniques[attachmentUniqueAsset->attachmentType] != nullptr)
{ {
std::cout << "Already loaded attachment unique with same type " << attachmentUniqueAsset->attachmentType << ": \"" std::cout << "Already loaded attachment unique with same type " << attachmentUniqueAsset->attachmentType << ": \""
<< attachmentUniques[attachmentUniqueAsset->attachmentType]->szInternalName << "\", \"" << attachmentUniqueName << "\"" << attachmentUniques[attachmentUniqueAsset->attachmentType]->szInternalName << "\", \"" << attachmentUniqueName << "\"\n";
<< std::endl;
return false; return false;
} }
@ -252,80 +258,92 @@ namespace T6
return true; return true;
} }
bool ConvertAnimName(const cspField_t& field, const std::string& value)
{
if (ConvertString(value, field.iOffset))
{
if (!value.empty())
m_indirect_asset_references.emplace(m_loading_manager->LoadIndirectAssetReference(ASSET_TYPE_XANIMPARTS, value));
return true;
}
return false;
}
protected: protected:
bool ConvertExtensionField(const cspField_t& field, const std::string& value) override bool ConvertExtensionField(const cspField_t& field, const std::string& value) override
{ {
switch (static_cast<weapFieldType_t>(field.iFieldType)) switch (static_cast<weapFieldType_t>(field.iFieldType))
{ {
case WFT_WEAPONTYPE: case WFT_WEAPONTYPE:
return ConvertEnumInt(value, field.iOffset, szWeapTypeNames, std::extent<decltype(szWeapTypeNames)>::value); return ConvertEnumInt(value, field.iOffset, szWeapTypeNames, std::extent_v<decltype(szWeapTypeNames)>);
case WFT_WEAPONCLASS: case WFT_WEAPONCLASS:
return ConvertEnumInt(value, field.iOffset, szWeapClassNames, std::extent<decltype(szWeapClassNames)>::value); return ConvertEnumInt(value, field.iOffset, szWeapClassNames, std::extent_v<decltype(szWeapClassNames)>);
case WFT_OVERLAYRETICLE: case WFT_OVERLAYRETICLE:
return ConvertEnumInt(value, field.iOffset, szWeapOverlayReticleNames, std::extent<decltype(szWeapOverlayReticleNames)>::value); return ConvertEnumInt(value, field.iOffset, szWeapOverlayReticleNames, std::extent_v<decltype(szWeapOverlayReticleNames)>);
case WFT_PENETRATE_TYPE: case WFT_PENETRATE_TYPE:
return ConvertEnumInt(value, field.iOffset, penetrateTypeNames, std::extent<decltype(penetrateTypeNames)>::value); return ConvertEnumInt(value, field.iOffset, penetrateTypeNames, std::extent_v<decltype(penetrateTypeNames)>);
case WFT_IMPACT_TYPE: case WFT_IMPACT_TYPE:
return ConvertEnumInt(value, field.iOffset, impactTypeNames, std::extent<decltype(impactTypeNames)>::value); return ConvertEnumInt(value, field.iOffset, impactTypeNames, std::extent_v<decltype(impactTypeNames)>);
case WFT_STANCE: case WFT_STANCE:
return ConvertEnumInt(value, field.iOffset, szWeapStanceNames, std::extent<decltype(szWeapStanceNames)>::value); return ConvertEnumInt(value, field.iOffset, szWeapStanceNames, std::extent_v<decltype(szWeapStanceNames)>);
case WFT_PROJ_EXPLOSION: case WFT_PROJ_EXPLOSION:
return ConvertEnumInt(value, field.iOffset, szProjectileExplosionNames, std::extent<decltype(szProjectileExplosionNames)>::value); return ConvertEnumInt(value, field.iOffset, szProjectileExplosionNames, std::extent_v<decltype(szProjectileExplosionNames)>);
case WFT_OFFHAND_CLASS: case WFT_OFFHAND_CLASS:
return ConvertEnumInt(value, field.iOffset, offhandClassNames, std::extent<decltype(offhandClassNames)>::value); return ConvertEnumInt(value, field.iOffset, offhandClassNames, std::extent_v<decltype(offhandClassNames)>);
case WFT_OFFHAND_SLOT: case WFT_OFFHAND_SLOT:
return ConvertEnumInt(value, field.iOffset, offhandSlotNames, std::extent<decltype(offhandSlotNames)>::value); return ConvertEnumInt(value, field.iOffset, offhandSlotNames, std::extent_v<decltype(offhandSlotNames)>);
case WFT_ANIMTYPE: case WFT_ANIMTYPE:
return ConvertEnumInt(value, field.iOffset, playerAnimTypeNames, std::extent<decltype(playerAnimTypeNames)>::value); return ConvertEnumInt(value, field.iOffset, playerAnimTypeNames, std::extent_v<decltype(playerAnimTypeNames)>);
case WFT_ACTIVE_RETICLE_TYPE: case WFT_ACTIVE_RETICLE_TYPE:
return ConvertEnumInt(value, field.iOffset, activeReticleNames, std::extent<decltype(activeReticleNames)>::value); return ConvertEnumInt(value, field.iOffset, activeReticleNames, std::extent_v<decltype(activeReticleNames)>);
case WFT_GUIDED_MISSILE_TYPE: case WFT_GUIDED_MISSILE_TYPE:
return ConvertEnumInt(value, field.iOffset, guidedMissileNames, std::extent<decltype(guidedMissileNames)>::value); return ConvertEnumInt(value, field.iOffset, guidedMissileNames, std::extent_v<decltype(guidedMissileNames)>);
case WFT_BOUNCE_SOUND: case WFT_BOUNCE_SOUND:
return ConvertBounceSounds(field, value); return ConvertBounceSounds(field, value);
case WFT_STICKINESS: case WFT_STICKINESS:
return ConvertEnumInt(value, field.iOffset, stickinessNames, std::extent<decltype(stickinessNames)>::value); return ConvertEnumInt(value, field.iOffset, stickinessNames, std::extent_v<decltype(stickinessNames)>);
case WFT_ROTATETYPE: case WFT_ROTATETYPE:
return ConvertEnumInt(value, field.iOffset, rotateTypeNames, std::extent<decltype(rotateTypeNames)>::value); return ConvertEnumInt(value, field.iOffset, rotateTypeNames, std::extent_v<decltype(rotateTypeNames)>);
case WFT_OVERLAYINTERFACE: case WFT_OVERLAYINTERFACE:
return ConvertEnumInt(value, field.iOffset, overlayInterfaceNames, std::extent<decltype(overlayInterfaceNames)>::value); return ConvertEnumInt(value, field.iOffset, overlayInterfaceNames, std::extent_v<decltype(overlayInterfaceNames)>);
case WFT_INVENTORYTYPE: case WFT_INVENTORYTYPE:
return ConvertEnumInt(value, field.iOffset, szWeapInventoryTypeNames, std::extent<decltype(szWeapInventoryTypeNames)>::value); return ConvertEnumInt(value, field.iOffset, szWeapInventoryTypeNames, std::extent_v<decltype(szWeapInventoryTypeNames)>);
case WFT_FIRETYPE: case WFT_FIRETYPE:
return ConvertEnumInt(value, field.iOffset, szWeapFireTypeNames, std::extent<decltype(szWeapFireTypeNames)>::value); return ConvertEnumInt(value, field.iOffset, szWeapFireTypeNames, std::extent_v<decltype(szWeapFireTypeNames)>);
case WFT_CLIPTYPE: case WFT_CLIPTYPE:
return ConvertEnumInt(value, field.iOffset, szWeapClipTypeNames, std::extent<decltype(szWeapClipTypeNames)>::value); return ConvertEnumInt(value, field.iOffset, szWeapClipTypeNames, std::extent_v<decltype(szWeapClipTypeNames)>);
case WFT_AMMOCOUNTER_CLIPTYPE: case WFT_AMMOCOUNTER_CLIPTYPE:
return ConvertEnumInt(value, field.iOffset, ammoCounterClipNames, std::extent<decltype(ammoCounterClipNames)>::value); return ConvertEnumInt(value, field.iOffset, ammoCounterClipNames, std::extent_v<decltype(ammoCounterClipNames)>);
case WFT_ICONRATIO_HUD: case WFT_ICONRATIO_HUD:
case WFT_ICONRATIO_AMMOCOUNTER: case WFT_ICONRATIO_AMMOCOUNTER:
case WFT_ICONRATIO_KILL: case WFT_ICONRATIO_KILL:
case WFT_ICONRATIO_DPAD: case WFT_ICONRATIO_DPAD:
case WFT_ICONRATIO_INDICATOR: case WFT_ICONRATIO_INDICATOR:
return ConvertEnumInt(value, field.iOffset, weapIconRatioNames, std::extent<decltype(weapIconRatioNames)>::value); return ConvertEnumInt(value, field.iOffset, weapIconRatioNames, std::extent_v<decltype(weapIconRatioNames)>);
case WFT_BARRELTYPE: case WFT_BARRELTYPE:
return ConvertEnumInt(value, field.iOffset, barrelTypeNames, std::extent<decltype(barrelTypeNames)>::value); return ConvertEnumInt(value, field.iOffset, barrelTypeNames, std::extent_v<decltype(barrelTypeNames)>);
case WFT_HIDETAGS: case WFT_HIDETAGS:
return ConvertHideTags(field, value); return ConvertHideTags(field, value);
@ -345,7 +363,9 @@ namespace T6
case WFT_ATTACHMENT_UNIQUES: case WFT_ATTACHMENT_UNIQUES:
return ConvertAttachmentUniques(field, value); return ConvertAttachmentUniques(field, value);
case WFT_NUM_FIELD_TYPES: case WFT_ANIM_NAME:
return ConvertAnimName(field, value);
default: default:
assert(false); assert(false);
return false; return false;
@ -418,7 +438,7 @@ bool AssetLoaderWeapon::IsStringOverride(const char* str1, const char* str2)
return strcmp(str1, str2) != 0; return strcmp(str1, str2) != 0;
} }
bool AssetLoaderWeapon::IsFxOverride(FxEffectDef* effect1, FxEffectDef* effect2) bool AssetLoaderWeapon::IsFxOverride(const FxEffectDef* effect1, const FxEffectDef* effect2)
{ {
if ((effect1 == nullptr) != (effect2 == nullptr)) if ((effect1 == nullptr) != (effect2 == nullptr))
return true; return true;
@ -439,20 +459,20 @@ void AssetLoaderWeapon::HandleSoundOverride(WeaponAttachmentUnique* attachmentUn
} }
void AssetLoaderWeapon::HandleFxOverride(WeaponAttachmentUnique* attachmentUnique, void AssetLoaderWeapon::HandleFxOverride(WeaponAttachmentUnique* attachmentUnique,
FxEffectDef* effect1, const FxEffectDef* effect1,
FxEffectDef* effect2, const FxEffectDef* effect2,
const eAttachmentOverrideEffects fxOverrideIndex) const eAttachmentOverrideEffects fxOverrideIndex)
{ {
if (IsFxOverride(effect1, effect2)) if (IsFxOverride(effect1, effect2))
attachmentUnique->effectOverrides |= 1 << static_cast<unsigned>(fxOverrideIndex); attachmentUnique->effectOverrides |= 1 << static_cast<unsigned>(fxOverrideIndex);
} }
void AssetLoaderWeapon::CalculateAttachmentFields(WeaponFullDef* weapon, unsigned attachmentIndex, WeaponAttachmentUnique* attachmentUnique) void AssetLoaderWeapon::CalculateAttachmentFields(const WeaponFullDef* weapon, unsigned attachmentIndex, WeaponAttachmentUnique* attachmentUnique)
{ {
for (auto& val : attachmentUnique->animationOverrides) for (auto& val : attachmentUnique->animationOverrides)
val = 0; val = 0;
for (auto animIndex = 0u; animIndex < std::extent<decltype(WeaponFullDef::szXAnims)>::value; animIndex++) for (auto animIndex = 0u; animIndex < std::extent_v<decltype(WeaponFullDef::szXAnims)>; animIndex++)
{ {
if (IsStringOverride(weapon->szXAnims[animIndex], attachmentUnique->szXAnims[animIndex])) if (IsStringOverride(weapon->szXAnims[animIndex], attachmentUnique->szXAnims[animIndex]))
attachmentUnique->animationOverrides[animIndex / 32] |= 1 << (animIndex % 32); attachmentUnique->animationOverrides[animIndex / 32] |= 1 << (animIndex % 32);
@ -485,8 +505,8 @@ void AssetLoaderWeapon::CalculateAttachmentFields(WeaponFullDef* weapon, unsigne
if (attachmentUnique->combinedAttachmentTypeMask == 0) if (attachmentUnique->combinedAttachmentTypeMask == 0)
{ {
WeaponAttachmentUnique* lastSibling = nullptr; WeaponAttachmentUnique* lastSibling = nullptr;
for (auto attachmentUniqueIndex = std::extent<decltype(WeaponFullDef::attachments)>::value; for (auto attachmentUniqueIndex = std::extent_v<decltype(WeaponFullDef::attachments)>;
attachmentUniqueIndex < std::extent<decltype(WeaponFullDef::attachmentUniques)>::value; attachmentUniqueIndex < std::extent_v<decltype(WeaponFullDef::attachmentUniques)>;
attachmentUniqueIndex++) attachmentUniqueIndex++)
{ {
if (weapon->attachmentUniques[attachmentUniqueIndex] != nullptr if (weapon->attachmentUniques[attachmentUniqueIndex] != nullptr
@ -516,7 +536,7 @@ void AssetLoaderWeapon::CalculateAttachmentFields(WeaponFullDef* weapon, unsigne
void AssetLoaderWeapon::CalculateAttachmentFields(WeaponFullDef* weapon) void AssetLoaderWeapon::CalculateAttachmentFields(WeaponFullDef* weapon)
{ {
for (auto attachmentUniqueIndex = 0u; attachmentUniqueIndex < std::extent<decltype(WeaponFullDef::attachmentUniques)>::value; attachmentUniqueIndex++) for (auto attachmentUniqueIndex = 0u; attachmentUniqueIndex < std::extent_v<decltype(WeaponFullDef::attachmentUniques)>; attachmentUniqueIndex++)
{ {
if (weapon->attachmentUniques[attachmentUniqueIndex] == nullptr) if (weapon->attachmentUniques[attachmentUniqueIndex] == nullptr)
continue; continue;
@ -533,7 +553,7 @@ bool AssetLoaderWeapon::LoadFromInfoString(
LinkWeaponFullDefSubStructs(weaponFullDef); LinkWeaponFullDefSubStructs(weaponFullDef);
InfoStringToWeaponConverter converter( InfoStringToWeaponConverter converter(
infoString, weaponFullDef, zone->m_script_strings, memory, manager, weapon_fields, std::extent<decltype(weapon_fields)>::value); infoString, weaponFullDef, zone->m_script_strings, memory, manager, weapon_fields, std::extent_v<decltype(weapon_fields)>);
if (!converter.Convert()) if (!converter.Convert())
{ {
std::cout << "Failed to parse weapon: \"" << assetName << "\"" << std::endl; std::cout << "Failed to parse weapon: \"" << assetName << "\"" << std::endl;
@ -546,7 +566,12 @@ bool AssetLoaderWeapon::LoadFromInfoString(
CalculateWeaponFields(weaponFullDef); CalculateWeaponFields(weaponFullDef);
CalculateAttachmentFields(weaponFullDef); CalculateAttachmentFields(weaponFullDef);
manager->AddAsset(ASSET_TYPE_WEAPON, assetName, &weaponFullDef->weapVariantDef, converter.GetDependencies(), converter.GetUsedScriptStrings()); manager->AddAsset(ASSET_TYPE_WEAPON,
assetName,
&weaponFullDef->weapVariantDef,
converter.GetDependencies(),
converter.GetUsedScriptStrings(),
converter.GetIndirectAssetReferences());
return true; return true;
} }

View File

@ -12,14 +12,16 @@ namespace T6
static void LinkWeaponFullDefSubStructs(WeaponFullDef* weapon); static void LinkWeaponFullDefSubStructs(WeaponFullDef* weapon);
static bool IsStringOverride(const char* str1, const char* str2); static bool IsStringOverride(const char* str1, const char* str2);
static bool IsFxOverride(FxEffectDef* effect1, FxEffectDef* effect2); static bool IsFxOverride(const FxEffectDef* effect1, const FxEffectDef* effect2);
static void static void
HandleSoundOverride(WeaponAttachmentUnique* attachmentUnique, const char* snd1, const char* snd2, eAttachmentOverrideSounds sndOverrideIndex); HandleSoundOverride(WeaponAttachmentUnique* attachmentUnique, const char* snd1, const char* snd2, eAttachmentOverrideSounds sndOverrideIndex);
static void static void HandleFxOverride(WeaponAttachmentUnique* attachmentUnique,
HandleFxOverride(WeaponAttachmentUnique* attachmentUnique, FxEffectDef* effect1, FxEffectDef* effect2, eAttachmentOverrideEffects fxOverrideIndex); const FxEffectDef* effect1,
const FxEffectDef* effect2,
eAttachmentOverrideEffects fxOverrideIndex);
static void CalculateWeaponFields(WeaponFullDef* weapon); static void CalculateWeaponFields(WeaponFullDef* weapon);
static void CalculateAttachmentFields(WeaponFullDef* weapon, unsigned attachmentIndex, WeaponAttachmentUnique* attachmentUnique); static void CalculateAttachmentFields(const WeaponFullDef* weapon, unsigned attachmentIndex, WeaponAttachmentUnique* attachmentUnique);
static void CalculateAttachmentFields(WeaponFullDef* weapon); static void CalculateAttachmentFields(WeaponFullDef* weapon);
static bool static bool

View File

@ -41,7 +41,7 @@ bool InfoStringToStructConverterBase::ParseAsArray(const std::string& value, std
return true; return true;
} }
bool InfoStringToStructConverterBase::ParseAsPairs(const std::string& value, std::vector<std::pair<std::string, std::string>>& valueArray) const bool InfoStringToStructConverterBase::ParseAsPairs(const std::string& value, std::vector<std::pair<std::string, std::string>>& valueArray)
{ {
std::string key; std::string key;
auto isKey = true; auto isKey = true;
@ -227,6 +227,7 @@ bool InfoStringToStructConverterBase::ConvertEnumInt(const std::string& value, c
std::vector<scr_string_t> InfoStringToStructConverterBase::GetUsedScriptStrings() const std::vector<scr_string_t> InfoStringToStructConverterBase::GetUsedScriptStrings() const
{ {
std::vector<scr_string_t> scrStringList; std::vector<scr_string_t> scrStringList;
scrStringList.reserve(m_used_script_string_list.size());
for (auto scrStr : m_used_script_string_list) for (auto scrStr : m_used_script_string_list)
{ {
scrStringList.push_back(scrStr); scrStringList.push_back(scrStr);
@ -238,6 +239,7 @@ std::vector<scr_string_t> InfoStringToStructConverterBase::GetUsedScriptStrings(
std::vector<XAssetInfoGeneric*> InfoStringToStructConverterBase::GetDependencies() const std::vector<XAssetInfoGeneric*> InfoStringToStructConverterBase::GetDependencies() const
{ {
std::vector<XAssetInfoGeneric*> dependencyList; std::vector<XAssetInfoGeneric*> dependencyList;
dependencyList.reserve(m_dependencies.size());
for (auto* dependency : m_dependencies) for (auto* dependency : m_dependencies)
{ {
dependencyList.push_back(dependency); dependencyList.push_back(dependency);
@ -245,3 +247,15 @@ std::vector<XAssetInfoGeneric*> InfoStringToStructConverterBase::GetDependencies
return dependencyList; return dependencyList;
} }
std::vector<IndirectAssetReference> InfoStringToStructConverterBase::GetIndirectAssetReferences() const
{
std::vector<IndirectAssetReference> indirectAssetReferences;
indirectAssetReferences.reserve(m_indirect_asset_references.size());
for (auto& assetReference : m_indirect_asset_references)
{
indirectAssetReferences.emplace_back(assetReference);
}
return indirectAssetReferences;
}

View File

@ -17,11 +17,12 @@ protected:
ZoneScriptStrings& m_zone_script_strings; ZoneScriptStrings& m_zone_script_strings;
std::unordered_set<scr_string_t> m_used_script_string_list; std::unordered_set<scr_string_t> m_used_script_string_list;
std::unordered_set<XAssetInfoGeneric*> m_dependencies; std::unordered_set<XAssetInfoGeneric*> m_dependencies;
std::unordered_set<IndirectAssetReference> m_indirect_asset_references;
MemoryManager* m_memory; MemoryManager* m_memory;
void* m_structure; void* m_structure;
static bool ParseAsArray(const std::string& value, std::vector<std::string>& valueArray); static bool ParseAsArray(const std::string& value, std::vector<std::string>& valueArray);
bool ParseAsPairs(const std::string& value, std::vector<std::pair<std::string, std::string>>& valueArray) const; static bool ParseAsPairs(const std::string& value, std::vector<std::pair<std::string, std::string>>& valueArray);
bool ConvertString(const std::string& value, size_t offset); bool ConvertString(const std::string& value, size_t offset);
bool ConvertStringBuffer(const std::string& value, size_t offset, size_t bufferSize); bool ConvertStringBuffer(const std::string& value, size_t offset, size_t bufferSize);
@ -45,4 +46,5 @@ public:
virtual bool Convert() = 0; virtual bool Convert() = 0;
_NODISCARD std::vector<scr_string_t> GetUsedScriptStrings() const; _NODISCARD std::vector<scr_string_t> GetUsedScriptStrings() const;
_NODISCARD std::vector<XAssetInfoGeneric*> GetDependencies() const; _NODISCARD std::vector<XAssetInfoGeneric*> GetDependencies() const;
_NODISCARD std::vector<IndirectAssetReference> GetIndirectAssetReferences() const;
}; };

View File

@ -22,50 +22,50 @@ namespace T6
switch (static_cast<weapFieldType_t>(field.iFieldType)) switch (static_cast<weapFieldType_t>(field.iFieldType))
{ {
case WFT_WEAPONTYPE: case WFT_WEAPONTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapTypeNames, std::extent<decltype(szWeapTypeNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapTypeNames, std::extent_v<decltype(szWeapTypeNames)>);
break; break;
case WFT_WEAPONCLASS: case WFT_WEAPONCLASS:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClassNames, std::extent<decltype(szWeapClassNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClassNames, std::extent_v<decltype(szWeapClassNames)>);
break; break;
case WFT_OVERLAYRETICLE: case WFT_OVERLAYRETICLE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapOverlayReticleNames, std::extent<decltype(szWeapOverlayReticleNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapOverlayReticleNames, std::extent_v<decltype(szWeapOverlayReticleNames)>);
break; break;
case WFT_PENETRATE_TYPE: case WFT_PENETRATE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, std::extent<decltype(penetrateTypeNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, std::extent_v<decltype(penetrateTypeNames)>);
break; break;
case WFT_IMPACT_TYPE: case WFT_IMPACT_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, impactTypeNames, std::extent<decltype(impactTypeNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, impactTypeNames, std::extent_v<decltype(impactTypeNames)>);
break; break;
case WFT_STANCE: case WFT_STANCE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapStanceNames, std::extent<decltype(szWeapStanceNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapStanceNames, std::extent_v<decltype(szWeapStanceNames)>);
break; break;
case WFT_PROJ_EXPLOSION: case WFT_PROJ_EXPLOSION:
FillFromEnumInt(std::string(field.szName), field.iOffset, szProjectileExplosionNames, std::extent<decltype(szProjectileExplosionNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, szProjectileExplosionNames, std::extent_v<decltype(szProjectileExplosionNames)>);
break; break;
case WFT_OFFHAND_CLASS: case WFT_OFFHAND_CLASS:
FillFromEnumInt(std::string(field.szName), field.iOffset, offhandClassNames, std::extent<decltype(offhandClassNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, offhandClassNames, std::extent_v<decltype(offhandClassNames)>);
break; break;
case WFT_OFFHAND_SLOT: case WFT_OFFHAND_SLOT:
FillFromEnumInt(std::string(field.szName), field.iOffset, offhandSlotNames, std::extent<decltype(offhandSlotNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, offhandSlotNames, std::extent_v<decltype(offhandSlotNames)>);
break; break;
case WFT_ANIMTYPE: case WFT_ANIMTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, playerAnimTypeNames, std::extent<decltype(playerAnimTypeNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, playerAnimTypeNames, std::extent_v<decltype(playerAnimTypeNames)>);
break; break;
case WFT_ACTIVE_RETICLE_TYPE: case WFT_ACTIVE_RETICLE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, activeReticleNames, std::extent<decltype(activeReticleNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, activeReticleNames, std::extent_v<decltype(activeReticleNames)>);
break; break;
case WFT_GUIDED_MISSILE_TYPE: case WFT_GUIDED_MISSILE_TYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, guidedMissileNames, std::extent<decltype(guidedMissileNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, guidedMissileNames, std::extent_v<decltype(guidedMissileNames)>);
break; break;
case WFT_BOUNCE_SOUND: case WFT_BOUNCE_SOUND:
@ -92,31 +92,31 @@ namespace T6
} }
case WFT_STICKINESS: case WFT_STICKINESS:
FillFromEnumInt(std::string(field.szName), field.iOffset, stickinessNames, std::extent<decltype(stickinessNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, stickinessNames, std::extent_v<decltype(stickinessNames)>);
break; break;
case WFT_ROTATETYPE: case WFT_ROTATETYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, rotateTypeNames, std::extent<decltype(rotateTypeNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, rotateTypeNames, std::extent_v<decltype(rotateTypeNames)>);
break; break;
case WFT_OVERLAYINTERFACE: case WFT_OVERLAYINTERFACE:
FillFromEnumInt(std::string(field.szName), field.iOffset, overlayInterfaceNames, std::extent<decltype(overlayInterfaceNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, overlayInterfaceNames, std::extent_v<decltype(overlayInterfaceNames)>);
break; break;
case WFT_INVENTORYTYPE: case WFT_INVENTORYTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapInventoryTypeNames, std::extent<decltype(szWeapInventoryTypeNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapInventoryTypeNames, std::extent_v<decltype(szWeapInventoryTypeNames)>);
break; break;
case WFT_FIRETYPE: case WFT_FIRETYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, std::extent<decltype(szWeapFireTypeNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, std::extent_v<decltype(szWeapFireTypeNames)>);
break; break;
case WFT_CLIPTYPE: case WFT_CLIPTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClipTypeNames, std::extent<decltype(szWeapClipTypeNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClipTypeNames, std::extent_v<decltype(szWeapClipTypeNames)>);
break; break;
case WFT_AMMOCOUNTER_CLIPTYPE: case WFT_AMMOCOUNTER_CLIPTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, ammoCounterClipNames, std::extent<decltype(ammoCounterClipNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, ammoCounterClipNames, std::extent_v<decltype(ammoCounterClipNames)>);
break; break;
case WFT_ICONRATIO_HUD: case WFT_ICONRATIO_HUD:
@ -124,11 +124,11 @@ namespace T6
case WFT_ICONRATIO_KILL: case WFT_ICONRATIO_KILL:
case WFT_ICONRATIO_DPAD: case WFT_ICONRATIO_DPAD:
case WFT_ICONRATIO_INDICATOR: case WFT_ICONRATIO_INDICATOR:
FillFromEnumInt(std::string(field.szName), field.iOffset, weapIconRatioNames, std::extent<decltype(weapIconRatioNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, weapIconRatioNames, std::extent_v<decltype(weapIconRatioNames)>);
break; break;
case WFT_BARRELTYPE: case WFT_BARRELTYPE:
FillFromEnumInt(std::string(field.szName), field.iOffset, barrelTypeNames, std::extent<decltype(barrelTypeNames)>::value); FillFromEnumInt(std::string(field.szName), field.iOffset, barrelTypeNames, std::extent_v<decltype(barrelTypeNames)>);
break; break;
case WFT_HIDETAGS: case WFT_HIDETAGS:
@ -137,7 +137,7 @@ namespace T6
std::stringstream ss; std::stringstream ss;
bool first = true; bool first = true;
for (auto i = 0u; i < std::extent<decltype(WeaponFullDef::hideTags)>::value; i++) for (auto i = 0u; i < std::extent_v<decltype(WeaponFullDef::hideTags)>; i++)
{ {
const auto& str = m_get_scr_string(hideTags[i]); const auto& str = m_get_scr_string(hideTags[i]);
if (!str.empty()) if (!str.empty())
@ -162,11 +162,11 @@ namespace T6
case WFT_NOTETRACKSOUNDMAP: case WFT_NOTETRACKSOUNDMAP:
{ {
const auto* keys = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset); const auto* keys = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
const auto* values = &keys[std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value]; const auto* values = &keys[std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>];
std::stringstream ss; std::stringstream ss;
bool first = true; bool first = true;
for (auto i = 0u; i < std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value; i++) for (auto i = 0u; i < std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>; i++)
{ {
const auto& key = m_get_scr_string(keys[i]); const auto& key = m_get_scr_string(keys[i]);
const auto& value = m_get_scr_string(values[i]); const auto& value = m_get_scr_string(values[i]);
@ -205,7 +205,7 @@ namespace T6
std::stringstream ss; std::stringstream ss;
auto first = true; auto first = true;
for (auto i = 0u; i < std::extent<decltype(WeaponFullDef::attachments)>::value; i++) for (auto i = 0u; i < std::extent_v<decltype(WeaponFullDef::attachments)>; i++)
{ {
if (attachments[i]) if (attachments[i])
{ {
@ -227,7 +227,7 @@ namespace T6
std::stringstream ss; std::stringstream ss;
auto first = true; auto first = true;
for (auto i = 0u; i < std::extent<decltype(WeaponFullDef::attachmentUniques)>::value; i++) for (auto i = 0u; i < std::extent_v<decltype(WeaponFullDef::attachmentUniques)>; i++)
{ {
if (attachmentUniques[i]) if (attachmentUniques[i])
{ {
@ -243,6 +243,10 @@ namespace T6
break; break;
} }
case WFT_ANIM_NAME:
FillFromString(std::string(field.szName), field.iOffset);
break;
case WFT_NUM_FIELD_TYPES: case WFT_NUM_FIELD_TYPES:
default: default:
assert(false); assert(false);
@ -274,21 +278,21 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
if (weapon->attachments) if (weapon->attachments)
{ {
assert(sizeof(WeaponFullDef::attachments) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachments)>::value); assert(sizeof(WeaponFullDef::attachments) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachments)>::value);
memcpy(fullDef->attachments, weapon->attachments, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachments)>::value); memcpy(fullDef->attachments, weapon->attachments, sizeof(void*) * std::extent_v<decltype(WeaponFullDef::attachments)>);
fullDef->weapVariantDef.attachments = fullDef->attachments; fullDef->weapVariantDef.attachments = fullDef->attachments;
} }
if (weapon->attachmentUniques) if (weapon->attachmentUniques)
{ {
assert(sizeof(WeaponFullDef::attachmentUniques) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachmentUniques)>::value); assert(sizeof(WeaponFullDef::attachmentUniques) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachmentUniques)>::value);
memcpy(fullDef->attachmentUniques, weapon->attachmentUniques, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachmentUniques)>::value); memcpy(fullDef->attachmentUniques, weapon->attachmentUniques, sizeof(void*) * std::extent_v<decltype(WeaponFullDef::attachmentUniques)>);
fullDef->weapVariantDef.attachmentUniques = fullDef->attachmentUniques; fullDef->weapVariantDef.attachmentUniques = fullDef->attachmentUniques;
} }
if (fullDef->weapDef.gunXModel) if (fullDef->weapDef.gunXModel)
{ {
assert(sizeof(WeaponFullDef::gunXModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::gunXModel)>::value); assert(sizeof(WeaponFullDef::gunXModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::gunXModel)>::value);
memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent<decltype(WeaponFullDef::gunXModel)>::value); memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent_v<decltype(WeaponFullDef::gunXModel)>);
fullDef->weapDef.gunXModel = fullDef->gunXModel; fullDef->weapDef.gunXModel = fullDef->gunXModel;
} }
@ -302,7 +306,7 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
if (weapon->hideTags) if (weapon->hideTags)
{ {
assert(sizeof(WeaponFullDef::hideTags) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::hideTags)>::value); assert(sizeof(WeaponFullDef::hideTags) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::hideTags)>::value);
memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::hideTags)>::value); memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent_v<decltype(WeaponFullDef::hideTags)>);
fullDef->weapVariantDef.hideTags = fullDef->hideTags; fullDef->weapVariantDef.hideTags = fullDef->hideTags;
} }
@ -311,7 +315,7 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
assert(sizeof(WeaponFullDef::notetrackSoundMapKeys) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value); assert(sizeof(WeaponFullDef::notetrackSoundMapKeys) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value);
memcpy(fullDef->notetrackSoundMapKeys, memcpy(fullDef->notetrackSoundMapKeys,
fullDef->weapDef.notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys,
sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapKeys)>::value); sizeof(scr_string_t) * std::extent_v<decltype(WeaponFullDef::notetrackSoundMapKeys)>);
fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys; fullDef->weapDef.notetrackSoundMapKeys = fullDef->notetrackSoundMapKeys;
} }
@ -320,42 +324,42 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
assert(sizeof(WeaponFullDef::notetrackSoundMapValues) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapValues)>::value); assert(sizeof(WeaponFullDef::notetrackSoundMapValues) >= sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapValues)>::value);
memcpy(fullDef->notetrackSoundMapValues, memcpy(fullDef->notetrackSoundMapValues,
fullDef->weapDef.notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues,
sizeof(scr_string_t) * std::extent<decltype(WeaponFullDef::notetrackSoundMapValues)>::value); sizeof(scr_string_t) * std::extent_v<decltype(WeaponFullDef::notetrackSoundMapValues)>);
fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues; fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues;
} }
if (fullDef->weapDef.worldModel) if (fullDef->weapDef.worldModel)
{ {
assert(sizeof(WeaponFullDef::worldModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::worldModel)>::value); assert(sizeof(WeaponFullDef::worldModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::worldModel)>::value);
memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent<decltype(WeaponFullDef::worldModel)>::value); memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent_v<decltype(WeaponFullDef::worldModel)>);
fullDef->weapDef.worldModel = fullDef->worldModel; fullDef->weapDef.worldModel = fullDef->worldModel;
} }
if (weapon->attachViewModel) if (weapon->attachViewModel)
{ {
assert(sizeof(WeaponFullDef::attachViewModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachViewModel)>::value); assert(sizeof(WeaponFullDef::attachViewModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachViewModel)>::value);
memcpy(fullDef->attachViewModel, weapon->attachViewModel, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachViewModel)>::value); memcpy(fullDef->attachViewModel, weapon->attachViewModel, sizeof(void*) * std::extent_v<decltype(WeaponFullDef::attachViewModel)>);
fullDef->weapVariantDef.attachViewModel = fullDef->attachViewModel; fullDef->weapVariantDef.attachViewModel = fullDef->attachViewModel;
} }
if (weapon->attachWorldModel) if (weapon->attachWorldModel)
{ {
assert(sizeof(WeaponFullDef::attachWorldModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachWorldModel)>::value); assert(sizeof(WeaponFullDef::attachWorldModel) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachWorldModel)>::value);
memcpy(fullDef->attachWorldModel, weapon->attachWorldModel, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachWorldModel)>::value); memcpy(fullDef->attachWorldModel, weapon->attachWorldModel, sizeof(void*) * std::extent_v<decltype(WeaponFullDef::attachWorldModel)>);
fullDef->weapVariantDef.attachWorldModel = fullDef->attachWorldModel; fullDef->weapVariantDef.attachWorldModel = fullDef->attachWorldModel;
} }
if (weapon->attachViewModelTag) if (weapon->attachViewModelTag)
{ {
assert(sizeof(WeaponFullDef::attachViewModelTag) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachViewModelTag)>::value); assert(sizeof(WeaponFullDef::attachViewModelTag) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachViewModelTag)>::value);
memcpy(fullDef->attachViewModelTag, weapon->attachViewModelTag, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachViewModelTag)>::value); memcpy(fullDef->attachViewModelTag, weapon->attachViewModelTag, sizeof(void*) * std::extent_v<decltype(WeaponFullDef::attachViewModelTag)>);
fullDef->weapVariantDef.attachViewModelTag = fullDef->attachViewModelTag; fullDef->weapVariantDef.attachViewModelTag = fullDef->attachViewModelTag;
} }
if (weapon->attachWorldModelTag) if (weapon->attachWorldModelTag)
{ {
assert(sizeof(WeaponFullDef::attachWorldModelTag) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachWorldModelTag)>::value); assert(sizeof(WeaponFullDef::attachWorldModelTag) >= sizeof(void*) * std::extent<decltype(WeaponFullDef::attachWorldModelTag)>::value);
memcpy(fullDef->attachWorldModelTag, weapon->attachWorldModelTag, sizeof(void*) * std::extent<decltype(WeaponFullDef::attachWorldModelTag)>::value); memcpy(fullDef->attachWorldModelTag, weapon->attachWorldModelTag, sizeof(void*) * std::extent_v<decltype(WeaponFullDef::attachWorldModelTag)>);
fullDef->weapVariantDef.attachWorldModelTag = fullDef->attachWorldModelTag; fullDef->weapVariantDef.attachWorldModelTag = fullDef->attachWorldModelTag;
} }
@ -382,7 +386,7 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
if (fullDef->weapDef.weaponCamo && fullDef->weapDef.weaponCamo->name) if (fullDef->weapDef.weaponCamo && fullDef->weapDef.weaponCamo->name)
{ {
strncpy(fullDef->weaponCamo, fullDef->weapDef.weaponCamo->name, std::extent<decltype(WeaponFullDef::weaponCamo)>::value); strncpy(fullDef->weaponCamo, fullDef->weapDef.weaponCamo->name, std::extent_v<decltype(WeaponFullDef::weaponCamo)>);
} }
} }
@ -394,7 +398,7 @@ InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo<WeaponVariantDef>* ass
InfoStringFromWeaponConverter converter(fullDef.get(), InfoStringFromWeaponConverter converter(fullDef.get(),
weapon_fields, weapon_fields,
std::extent<decltype(weapon_fields)>::value, std::extent_v<decltype(weapon_fields)>,
[asset](const scr_string_t scrStr) -> std::string [asset](const scr_string_t scrStr) -> std::string
{ {
assert(scrStr < asset->m_zone->m_script_strings.Count()); assert(scrStr < asset->m_zone->m_script_strings.Count());

View File

@ -36,6 +36,7 @@ set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD
use FxEffectDefRef; use FxEffectDefRef;
set condition handle never; set condition handle never;
set string name; set string name;
set assetref name ASSET_TYPE_FX;
// FxTrailDef // FxTrailDef
use FxTrailDef; use FxTrailDef;

View File

@ -8,6 +8,7 @@ set name szInternalName;
set string szDisplayName; set string szDisplayName;
set string szOverlayName; set string szOverlayName;
set string szXAnims; set string szXAnims;
set assetref szXAnims ASSET_TYPE_XANIMPARTS;
set string szModeName; set string szModeName;
set scriptstring hideTags; set scriptstring hideTags;
set scriptstring notetrackSoundMapKeys; set scriptstring notetrackSoundMapKeys;

View File

@ -38,6 +38,7 @@ set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD
use FxEffectDefRef; use FxEffectDefRef;
set condition handle never; set condition handle never;
set string name; set string name;
set assetref name ASSET_TYPE_FX;
// FxElemExtendedDefPtr // FxElemExtendedDefPtr
use FxElemExtendedDefPtr; use FxElemExtendedDefPtr;

View File

@ -11,6 +11,7 @@ set reusable hideTags;
set scriptstring hideTags; set scriptstring hideTags;
set count hideTags 32; set count hideTags 32;
set string szXAnims; set string szXAnims;
set assetref szXAnims ASSET_TYPE_XANIMPARTS;
set reusable szXAnims; set reusable szXAnims;
set count szXAnims 37; set count szXAnims 37;
set string szAltWeaponName; set string szAltWeaponName;
@ -25,9 +26,11 @@ set reusable gunXModel;
set count gunXModel 16; set count gunXModel 16;
set reusable szXAnimsRightHanded; set reusable szXAnimsRightHanded;
set string szXAnimsRightHanded; set string szXAnimsRightHanded;
set assetref szXAnimsRightHanded ASSET_TYPE_XANIMPARTS;
set count szXAnimsRightHanded 37; set count szXAnimsRightHanded 37;
set reusable szXAnimsLeftHanded; set reusable szXAnimsLeftHanded;
set string szXAnimsLeftHanded; set string szXAnimsLeftHanded;
set assetref szXAnimsLeftHanded ASSET_TYPE_XANIMPARTS;
set count szXAnimsLeftHanded 37; set count szXAnimsLeftHanded 37;
set string szModeName; set string szModeName;
set reusable notetrackSoundMapKeys; set reusable notetrackSoundMapKeys;

View File

@ -38,6 +38,7 @@ set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD
use FxEffectDefRef; use FxEffectDefRef;
set condition handle never; set condition handle never;
set string name; set string name;
set assetref name ASSET_TYPE_FX;
// FxElemExtendedDefPtr // FxElemExtendedDefPtr
use FxElemExtendedDefPtr; use FxElemExtendedDefPtr;

View File

@ -17,6 +17,7 @@ set count underBarrels 3;
set reusable others; set reusable others;
set count others 4; set count others 4;
set string szXAnims; set string szXAnims;
set assetref szXAnims ASSET_TYPE_XANIMPARTS;
set reusable szXAnims; set reusable szXAnims;
set count szXAnims NUM_WEAP_ANIMS; set count szXAnims NUM_WEAP_ANIMS;
set reusable animOverrides; set reusable animOverrides;
@ -55,9 +56,11 @@ set reusable gunXModel;
set count gunXModel 16; set count gunXModel 16;
set reusable szXAnimsRightHanded; set reusable szXAnimsRightHanded;
set string szXAnimsRightHanded; set string szXAnimsRightHanded;
set assetref szXAnimsRightHanded ASSET_TYPE_XANIMPARTS;
set count szXAnimsRightHanded NUM_WEAP_ANIMS; set count szXAnimsRightHanded NUM_WEAP_ANIMS;
set reusable szXAnimsLeftHanded; set reusable szXAnimsLeftHanded;
set string szXAnimsLeftHanded; set string szXAnimsLeftHanded;
set assetref szXAnimsLeftHanded ASSET_TYPE_XANIMPARTS;
set count szXAnimsLeftHanded NUM_WEAP_ANIMS; set count szXAnimsLeftHanded NUM_WEAP_ANIMS;
set string szModeName; set string szModeName;
set reusable notetrackSoundMapKeys; set reusable notetrackSoundMapKeys;

View File

@ -38,6 +38,7 @@ set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD
use FxEffectDefRef; use FxEffectDefRef;
set condition handle never; set condition handle never;
set string name; set string name;
set assetref name ASSET_TYPE_FX;
// FxTrailDef // FxTrailDef
use FxTrailDef; use FxTrailDef;

View File

@ -9,6 +9,7 @@ set reusable weapDef;
set string szDisplayName; set string szDisplayName;
set string szAltWeaponName; set string szAltWeaponName;
set string szXAnims; set string szXAnims;
set assetref szXAnims ASSET_TYPE_XANIMPARTS;
set count szXAnims NUM_WEAP_ANIMS; set count szXAnims NUM_WEAP_ANIMS;
set reusable szXAnims; set reusable szXAnims;
set scriptstring hideTags; set scriptstring hideTags;

View File

@ -39,6 +39,7 @@ set condition material FxElemDef::elemType == FX_ELEM_TYPE_SPRITE_BILLBOARD
use FxEffectDefRef; use FxEffectDefRef;
set condition handle never; set condition handle never;
set string name; set string name;
set assetref name ASSET_TYPE_FX;
// FxElemExtendedDefPtr // FxElemExtendedDefPtr
use FxElemExtendedDefPtr; use FxElemExtendedDefPtr;

View File

@ -14,6 +14,7 @@ set reusable attachments;
set count attachmentUniques 95; set count attachmentUniques 95;
set reusable attachmentUniques; set reusable attachmentUniques;
set string szXAnims; set string szXAnims;
set assetref szXAnims ASSET_TYPE_XANIMPARTS;
set count szXAnims NUM_WEAP_ANIMS; set count szXAnims NUM_WEAP_ANIMS;
set reusable szXAnims; set reusable szXAnims;
set scriptstring hideTags; set scriptstring hideTags;

View File

@ -8,6 +8,7 @@ MemberInformation::MemberInformation(StructureInformation* parent, StructureInfo
m_is_script_string(false), m_is_script_string(false),
m_is_reusable(false), m_is_reusable(false),
m_is_leaf(false), m_is_leaf(false),
m_fast_file_block(nullptr) m_fast_file_block(nullptr),
m_asset_ref(nullptr)
{ {
} }

View File

@ -23,6 +23,7 @@ public:
std::unique_ptr<IEvaluation> m_condition; std::unique_ptr<IEvaluation> m_condition;
std::unique_ptr<IEvaluation> m_alloc_alignment; std::unique_ptr<IEvaluation> m_alloc_alignment;
const FastFileBlock* m_fast_file_block; const FastFileBlock* m_fast_file_block;
const EnumMember* m_asset_ref;
MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member); MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member);
}; };

View File

@ -1075,7 +1075,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
LINE("marker.Mark(*pAsset);") LINE("marker.Mark(*pAsset);")
LINE("") LINE("")
LINE("m_asset_info = reinterpret_cast<XAssetInfo<" LINE("m_asset_info = reinterpret_cast<XAssetInfo<"
<< info->m_definition->GetFullName() << ">*>(LinkAsset(GetAssetName(*pAsset), *pAsset, marker.GetUsedScriptStrings(), marker.GetDependencies()));") << info->m_definition->GetFullName()
<< ">*>(LinkAsset(GetAssetName(*pAsset), *pAsset, marker.GetDependencies(), marker.GetUsedScriptStrings(), marker.GetIndirectAssetReferences()));")
LINE("*pAsset = m_asset_info->Asset();") LINE("*pAsset = m_asset_info->Asset();")
m_intendation--; m_intendation--;

View File

@ -225,6 +225,35 @@ class ZoneMarkTemplate::Internal final : BaseTemplate
} }
} }
void MarkMember_AssetRef(StructureInformation* info,
MemberInformation* member,
const DeclarationModifierComputations& modifier,
const MemberLoadType loadType) const
{
if (loadType == MemberLoadType::POINTER_ARRAY)
{
if (modifier.IsArray())
{
LINE("MarkArray_IndirectAssetRef(" << member->m_asset_ref->m_name << ", " << MakeMemberAccess(info, member, modifier) << ", "
<< modifier.GetArraySize() << ");")
}
else
{
LINE("MarkArray_IndirectAssetRef(" << member->m_asset_ref->m_name << ", " << MakeMemberAccess(info, member, modifier) << ", "
<< MakeEvaluation(modifier.GetPointerArrayCountEvaluation()) << ");")
}
}
else if (loadType == MemberLoadType::SINGLE_POINTER)
{
LINE("Mark_IndirectAssetRef(" << member->m_asset_ref->m_name << ", " << MakeMemberAccess(info, member, modifier) << ");")
}
else
{
assert(false);
LINE("#error unsupported loadType " << static_cast<int>(loadType) << " for scriptstring")
}
}
void MarkMember_Asset(StructureInformation* info, void MarkMember_Asset(StructureInformation* info,
MemberInformation* member, MemberInformation* member,
const DeclarationModifierComputations& modifier, const DeclarationModifierComputations& modifier,
@ -308,6 +337,10 @@ class ZoneMarkTemplate::Internal final : BaseTemplate
{ {
MarkMember_ScriptString(info, member, modifier, loadType); MarkMember_ScriptString(info, member, modifier, loadType);
} }
else if (member->m_asset_ref)
{
MarkMember_AssetRef(info, member, modifier, loadType);
}
else if (member->m_type && StructureComputations(member->m_type).IsAsset()) else if (member->m_type && StructureComputations(member->m_type).IsAsset())
{ {
MarkMember_Asset(info, member, modifier, loadType); MarkMember_Asset(info, member, modifier, loadType);
@ -541,7 +574,8 @@ class ZoneMarkTemplate::Internal final : BaseTemplate
if (computations.ShouldIgnore() || computations.IsInRuntimeBlock()) if (computations.ShouldIgnore() || computations.IsInRuntimeBlock())
return; return;
if (member->m_is_script_string || member->m_type && (member->m_type->m_requires_marking || StructureComputations(member->m_type).IsAsset())) if (member->m_is_script_string || member->m_asset_ref
|| member->m_type && (member->m_type->m_requires_marking || StructureComputations(member->m_type).IsAsset()))
{ {
if (info->m_definition->GetType() == DataDefinitionType::UNION) if (info->m_definition->GetType() == DataDefinitionType::UNION)
MarkMember_Condition_Union(info, member); MarkMember_Condition_Union(info, member);

View File

@ -6,6 +6,7 @@
#include "Parsing/Commands/Sequence/SequenceArrayCount.h" #include "Parsing/Commands/Sequence/SequenceArrayCount.h"
#include "Parsing/Commands/Sequence/SequenceArraySize.h" #include "Parsing/Commands/Sequence/SequenceArraySize.h"
#include "Parsing/Commands/Sequence/SequenceAsset.h" #include "Parsing/Commands/Sequence/SequenceAsset.h"
#include "Parsing/Commands/Sequence/SequenceAssetRef.h"
#include "Parsing/Commands/Sequence/SequenceBlock.h" #include "Parsing/Commands/Sequence/SequenceBlock.h"
#include "Parsing/Commands/Sequence/SequenceCondition.h" #include "Parsing/Commands/Sequence/SequenceCondition.h"
#include "Parsing/Commands/Sequence/SequenceCount.h" #include "Parsing/Commands/Sequence/SequenceCount.h"
@ -33,6 +34,7 @@ const std::vector<CommandsParser::sequence_t*>& CommandsParser::GetTestsForState
new SequenceArrayCount(), new SequenceArrayCount(),
new SequenceArraySize(), new SequenceArraySize(),
new SequenceAsset(), new SequenceAsset(),
new SequenceAssetRef(),
new SequenceBlock(), new SequenceBlock(),
new SequenceCondition(), new SequenceCondition(),
new SequenceCount(), new SequenceCount(),

View File

@ -0,0 +1,72 @@
#include "SequenceAssetRef.h"
#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h"
#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h"
#include <algorithm>
SequenceAssetRef::SequenceAssetRef()
{
const CommandsMatcherFactory create(this);
AddLabeledMatchers(CommandsCommonMatchers::Typename(this), CommandsCommonMatchers::LABEL_TYPENAME);
AddMatchers({
create.Keyword("set"),
create.Keyword("assetref"),
create.Label(CommandsCommonMatchers::LABEL_TYPENAME).Capture(CAPTURE_TYPE),
create.Identifier().Capture(CAPTURE_ASSET_TYPE_ENUM_ENTRY),
create.Char(';'),
});
}
void SequenceAssetRef::ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const
{
const auto& enumEntryToken = result.NextCapture(CAPTURE_ASSET_TYPE_ENUM_ENTRY);
const auto* enumMember = state->GetRepository()->GetEnumMemberByName(enumEntryToken.IdentifierValue());
if (enumMember == nullptr)
throw ParsingException(enumEntryToken.GetPos(), "Unknown asset type enum entry");
const auto& typeNameToken = result.NextCapture(CAPTURE_TYPE);
StructureInformation* type;
std::vector<MemberInformation*> members;
if (!state->GetTypenameAndMembersFromTypename(typeNameToken.TypeNameValue(), type, members))
throw ParsingException(typeNameToken.GetPos(), "Unknown type");
if (members.empty())
throw ParsingException(typeNameToken.GetPos(), "Need to specify a member when trying to mark as string.");
auto* lastMember = members.back();
const auto* typeDecl = lastMember->m_member->m_type_declaration.get();
auto hasPointerRef = false;
while (true)
{
if (!hasPointerRef)
{
const auto& modifiers = typeDecl->m_declaration_modifiers;
hasPointerRef = std::any_of(modifiers.begin(),
modifiers.end(),
[](const std::unique_ptr<DeclarationModifier>& modifier)
{
return modifier->GetType() == DeclarationModifierType::POINTER;
});
}
if (typeDecl->m_type->GetType() == DataDefinitionType::TYPEDEF)
{
const auto* typedefDef = dynamic_cast<const TypedefDefinition*>(typeDecl->m_type);
typeDecl = typedefDef->m_type_declaration.get();
}
else
break;
}
if (!hasPointerRef)
throw ParsingException(typeNameToken.GetPos(), "Invalid type for string, must be a pointer");
if (typeDecl->m_type->GetType() != DataDefinitionType::BASE_TYPE)
throw ParsingException(typeNameToken.GetPos(), "Invalid type for string, must be a base type");
lastMember->m_asset_ref = enumMember;
}

View File

@ -0,0 +1,17 @@
#pragma once
#include "Parsing/Commands/Impl/CommandsParser.h"
class SequenceAssetRef final : public CommandsParser::sequence_t
{
static constexpr auto TAG_DEFAULT = 1;
static constexpr auto CAPTURE_TYPE = 1;
static constexpr auto CAPTURE_ASSET_TYPE_ENUM_ENTRY = 2;
protected:
void ProcessMatch(CommandsParserState* state, SequenceResult<CommandsParserValue>& result) const override;
public:
SequenceAssetRef();
};

View File

@ -44,8 +44,8 @@ bool MarkingRequiredPostProcessor::CalculateRequiresMarking(std::unordered_set<c
if (skip) if (skip)
continue; continue;
// Any ScriptStrings or Strings need to be processed. // Any script strings, asset refs and assets need to be processed.
if (member->m_is_script_string || member->m_type && member->m_type->m_asset_enum_entry) if (member->m_is_script_string || member->m_asset_ref || member->m_type && member->m_type->m_asset_enum_entry)
{ {
info->m_requires_marking = true; info->m_requires_marking = true;
return true; return true;

View File

@ -15,87 +15,53 @@ const char* GameAssetPoolIW3::ASSET_TYPE_NAMES[]{
"xmodelalias", "rawfile", "stringtable", "xmodelalias", "rawfile", "stringtable",
}; };
/*
Asset Pool Table
Useful for macro generation via regex-replace for example
#assetType, #typeName, #unionEntry, #poolName
ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset, m_phys_preset
ASSET_TYPE_XANIMPARTS, XAnimParts, parts, m_xanim_parts
ASSET_TYPE_XMODEL, XModel, model, m_xmodel
ASSET_TYPE_MATERIAL, Material, material, m_material
ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet, m_technique_set
ASSET_TYPE_IMAGE, GfxImage, image, m_image
ASSET_TYPE_SOUND, snd_alias_list_t, sound, m_sound
ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve, m_sound_curve
ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd, m_loaded_sound
ASSET_TYPE_CLIPMAP, clipMap_t, clipMap, m_clip_map
ASSET_TYPE_CLIPMAP_PVS, clipMap_t, clipMap, m_clip_map
ASSET_TYPE_COMWORLD, ComWorld, comWorld, m_com_world
ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp, m_game_world_sp
ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp, m_game_world_mp
ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts, m_map_ents
ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld, m_gfx_world
ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef, m_gfx_light_def
ASSET_TYPE_FONT, Font_s, font, m_font
ASSET_TYPE_MENULIST, MenuList, menuList, m_menu_list
ASSET_TYPE_MENU, menuDef_t, menu, m_menu_def
ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize, m_localize
ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon, m_weapon
ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals, m_snd_driver_globals
ASSET_TYPE_FX, FxEffectDef, fx, m_fx
ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx, m_fx_impact_table
ASSET_TYPE_RAWFILE, RawFile, rawfile, m_raw_file
ASSET_TYPE_STRINGTABLE, StringTable, stringTable, m_string_table
*/
GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const int priority) GameAssetPoolIW3::GameAssetPoolIW3(Zone* zone, const int priority)
: ZoneAssetPools(zone), : ZoneAssetPools(zone),
m_priority(priority) m_priority(priority)
{ {
static_assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT); static_assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
} }
void GameAssetPoolIW3::InitPoolStatic(const asset_type_t type, const size_t capacity) void GameAssetPoolIW3::InitPoolStatic(const asset_type_t type, const size_t capacity)
{ {
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \ #define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \ case assetType: \
{ \ { \
if ((poolName) == nullptr && capacity > 0) \ if ((poolName) == nullptr && capacity > 0) \
{ \ { \
(poolName) = std::make_unique<AssetPoolStatic<poolType>>(capacity, m_priority, (assetType)); \ (poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
} \ } \
break; \ break; \
} }
switch (type) switch (type)
{ {
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material); CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage); CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve); CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound); CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s); CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
default: default:
assert(type >= 0 && type < ASSET_TYPE_COUNT); assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -107,44 +73,44 @@ void GameAssetPoolIW3::InitPoolStatic(const asset_type_t type, const size_t capa
void GameAssetPoolIW3::InitPoolDynamic(const asset_type_t type) void GameAssetPoolIW3::InitPoolDynamic(const asset_type_t type)
{ {
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \ #define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \ case assetType: \
{ \ { \
if ((poolName) == nullptr) \ if ((poolName) == nullptr) \
{ \ { \
(poolName) = std::make_unique<AssetPoolDynamic<poolType>>(m_priority, (assetType)); \ (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
} \ } \
break; \ break; \
} }
switch (type) switch (type)
{ {
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
default: default:
assert(type >= 0 && type < ASSET_TYPE_COUNT); assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -154,49 +120,44 @@ void GameAssetPoolIW3::InitPoolDynamic(const asset_type_t type)
#undef CASE_INIT_POOL_STATIC #undef CASE_INIT_POOL_STATIC
} }
XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool( XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
{ {
XAsset xAsset{}; #define CASE_ADD_TO_POOL(assetType, poolName) \
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
case assetType: \ case assetType: \
{ \ { \
assert((poolName) != nullptr); \ assert((poolName) != nullptr); \
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, zone, std::move(dependencies), std::move(usedScriptStrings)); \ return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
} }
switch (xAsset.type) switch (static_cast<XAssetType>(xAssetInfo->m_type))
{ {
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset); CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts); CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model); CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material); CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet); CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image); CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound); CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve); CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd); CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld); CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp); CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp); CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts); CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld); CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef); CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font); CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList); CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu); CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize); CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon); CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx); CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx); CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile); CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable); CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
default: default:
assert(false); assert(false);
@ -220,32 +181,32 @@ XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, std::stri
switch (type) switch (type)
{ {
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset); CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts); CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel); CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material); CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set); CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image); CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound); CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound)
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve); CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound); CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world); CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp); CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp); CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents); CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world); CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def); CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font); CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list); CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def); CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize); CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon); CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx); CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table); CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file); CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table); CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
default: default:
assert(false); assert(false);
@ -257,9 +218,9 @@ XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, std::stri
#undef CASE_GET_ASSET #undef CASE_GET_ASSET
} }
const char* GameAssetPoolIW3::AssetTypeNameByType(asset_type_t assetType) const char* GameAssetPoolIW3::AssetTypeNameByType(const asset_type_t assetType)
{ {
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value)) if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID; return ASSET_TYPE_INVALID;

View File

@ -14,12 +14,7 @@ class GameAssetPoolIW3 final : public ZoneAssetPools
static const char* ASSET_TYPE_NAMES[]; static const char* ASSET_TYPE_NAMES[];
protected: protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type, XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) override;
public: public:
std::unique_ptr<AssetPool<IW3::PhysPreset>> m_phys_preset; std::unique_ptr<AssetPool<IW3::PhysPreset>> m_phys_preset;

View File

@ -16,107 +16,63 @@ const char* GameAssetPoolIW4::ASSET_TYPE_NAMES[]{
"tracer", "vehicle", "addonmapents", "tracer", "vehicle", "addonmapents",
}; };
/*
Asset Pool Table
Useful for macro generation via regex-replace for example
#assetType, #typeName, #unionEntry, #poolName
ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset, m_phys_preset
ASSET_TYPE_PHYSCOLLMAP, PhysCollmap, physCollmap, m_phys_collmap
ASSET_TYPE_XANIMPARTS, XAnimParts, parts, m_xanim_parts
ASSET_TYPE_XMODEL, XModel, model, m_xmodel
ASSET_TYPE_MATERIAL, Material, material, m_material
ASSET_TYPE_PIXELSHADER, MaterialPixelShader, pixelShader, m_material_pixel_shader
ASSET_TYPE_VERTEXSHADER, MaterialVertexShader, vertexShader, m_material_vertex_shader
ASSET_TYPE_VERTEXDECL, MaterialVertexDeclaration, vertexDecl, m_material_vertex_decl
ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet, m_technique_set
ASSET_TYPE_IMAGE, GfxImage, image, m_image
ASSET_TYPE_SOUND, snd_alias_list_t, sound, m_sound
ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve, m_sound_curve
ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd, m_loaded_sound
ASSET_TYPE_CLIPMAP_SP, clipMap_t, clipMap, m_clip_map
ASSET_TYPE_CLIPMAP_MP, clipMap_t, clipMap, m_clip_map
ASSET_TYPE_COMWORLD, ComWorld, comWorld, m_com_world
ASSET_TYPE_GAMEWORLD_SP, GameWorldSp, gameWorldSp, m_game_world_sp
ASSET_TYPE_GAMEWORLD_MP, GameWorldMp, gameWorldMp, m_game_world_mp
ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts, m_map_ents
ASSET_TYPE_FXWORLD, FxWorld, fxWorld, m_fx_world
ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld, m_gfx_world
ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef, m_gfx_light_def
ASSET_TYPE_FONT, Font_s, font, m_font
ASSET_TYPE_MENULIST, MenuList, menuList, m_menu_list
ASSET_TYPE_MENU, menuDef_t, menu, m_menu_def
ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize, m_localize
ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon, m_weapon
ASSET_TYPE_SNDDRIVER_GLOBALS, SndDriverGlobals, sndDriverGlobals, m_snd_driver_globals
ASSET_TYPE_FX, FxEffectDef, fx, m_fx
ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx, m_fx_impact_table
ASSET_TYPE_RAWFILE, RawFile, rawfile, m_raw_file
ASSET_TYPE_STRINGTABLE, StringTable, stringTable, m_string_table
ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef, m_leaderboard
ASSET_TYPE_STRUCTURED_DATA_DEF, StructuredDataDefSet, structuredDataDefSet, m_structed_data_def_set
ASSET_TYPE_TRACER, TracerDef, tracerDef, m_tracer
ASSET_TYPE_VEHICLE, VehicleDef, vehDef, m_vehicle
ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts, m_addon_map_ents
*/
GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority) GameAssetPoolIW4::GameAssetPoolIW4(Zone* zone, const int priority)
: ZoneAssetPools(zone), : ZoneAssetPools(zone),
m_priority(priority) m_priority(priority)
{ {
assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT); assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
} }
void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capacity) void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capacity)
{ {
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \ #define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \ case assetType: \
{ \ { \
if ((poolName) == nullptr && capacity > 0) \ if ((poolName) == nullptr && capacity > 0) \
{ \ { \
(poolName) = std::make_unique<AssetPoolStatic<poolType>>(capacity, m_priority, (assetType)); \ (poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
} \ } \
break; \ break; \
} }
switch (type) switch (type)
{ {
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap); CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material); CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader); CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader); CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration); CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage); CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve); CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound); CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s); CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet); CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default: default:
assert(type >= 0 && type < ASSET_TYPE_COUNT); assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -128,116 +84,111 @@ void GameAssetPoolIW4::InitPoolStatic(const asset_type_t type, const size_t capa
void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type) void GameAssetPoolIW4::InitPoolDynamic(const asset_type_t type)
{ {
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \ #define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \ case assetType: \
{ \ { \
if ((poolName) == nullptr) \ if ((poolName) == nullptr) \
{ \ { \
(poolName) = std::make_unique<AssetPoolDynamic<poolType>>(m_priority, (assetType)); \ (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
} \ } \
break; \ break; \
} }
switch (type) switch (type)
{ {
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default: default:
assert(type >= 0 && type < ASSET_TYPE_COUNT); assert(type >= 0 && type < ASSET_TYPE_COUNT);
break; break;
} }
#undef CASE_INIT_POOL_STATIC #undef CASE_INIT_POOL_DYNAMIC
} }
XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool( XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
{ {
XAsset xAsset{}; #define CASE_ADD_TO_POOL(assetType, poolName) \
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
case assetType: \ case assetType: \
{ \ { \
assert((poolName) != nullptr); \ assert((poolName) != nullptr); \
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, zone, std::move(dependencies), std::move(usedScriptStrings)); \ return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
} }
switch (xAsset.type) switch (static_cast<XAssetType>(xAssetInfo->m_type))
{ {
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset); CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, physCollmap); CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts); CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model); CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material); CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, pixelShader); CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, vertexShader); CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, vertexDecl); CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet); CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image); CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound); CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve); CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd); CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld); CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp); CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp); CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts); CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world, fxWorld); CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld); CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef); CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font); CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList); CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu); CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize); CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon); CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx); CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx); CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile); CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable); CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard, leaderboardDef); CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, structuredDataDefSet); CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef); CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle, vehDef); CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts); CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default: default:
assert(false); assert(false);
@ -261,42 +212,42 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri
switch (type) switch (type)
{ {
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset); CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap); CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts); CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel); CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material); CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader); CASE_GET_ASSET(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_GET_ASSET(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader); CASE_GET_ASSET(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl); CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set); CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image); CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound); CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound)
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve); CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound); CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_SP, m_clip_map); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_MP, m_clip_map); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world); CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp); CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp); CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents); CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world); CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world); CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def); CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font); CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list); CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def); CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize); CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon); CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx); CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table); CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file); CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table); CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard); CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set); CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer); CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer)
CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle); CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents); CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default: default:
assert(false); assert(false);
@ -308,9 +259,9 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri
#undef CASE_GET_ASSET #undef CASE_GET_ASSET
} }
const char* GameAssetPoolIW4::AssetTypeNameByType(asset_type_t assetType) const char* GameAssetPoolIW4::AssetTypeNameByType(const asset_type_t assetType)
{ {
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value)) if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID; return ASSET_TYPE_INVALID;

View File

@ -15,12 +15,7 @@ class GameAssetPoolIW4 final : public ZoneAssetPools
static const char* ASSET_TYPE_NAMES[]; static const char* ASSET_TYPE_NAMES[];
protected: protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type, XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) override;
public: public:
std::unique_ptr<AssetPool<IW4::PhysPreset>> m_phys_preset; std::unique_ptr<AssetPool<IW4::PhysPreset>> m_phys_preset;

View File

@ -57,114 +57,67 @@ const char* GameAssetPoolIW5::ASSET_TYPE_NAMES[]{
"addonmapents", "addonmapents",
}; };
/*
Asset Pool Table
Useful for macro generation via regex-replace for example
#assetType, #typeName, #unionEntry, #poolName
ASSET_TYPE_PHYSPRESET, PhysPreset, physPreset, m_phys_preset
ASSET_TYPE_PHYSCOLLMAP, PhysCollmap, physCollmap, m_phys_collmap
ASSET_TYPE_XANIMPARTS, XAnimParts, parts, m_xanim_parts
ASSET_TYPE_XMODEL_SURFS, XModelSurfs, modelSurfs, m_xmodel_surfs
ASSET_TYPE_XMODEL, XModel, model, m_xmodel
ASSET_TYPE_MATERIAL, Material, material, m_material
ASSET_TYPE_PIXELSHADER, MaterialPixelShader, pixelShader, m_material_pixel_shader
ASSET_TYPE_VERTEXSHADER, MaterialVertexShader, vertexShader, m_material_vertex_shader
ASSET_TYPE_VERTEXDECL, MaterialVertexDeclaration, vertexDecl, m_material_vertex_decl
ASSET_TYPE_TECHNIQUE_SET, MaterialTechniqueSet, techniqueSet, m_technique_set
ASSET_TYPE_IMAGE, GfxImage, image, m_image
ASSET_TYPE_SOUND, snd_alias_list_t, sound, m_sound
ASSET_TYPE_SOUND_CURVE, SndCurve, sndCurve, m_sound_curve
ASSET_TYPE_LOADED_SOUND, LoadedSound, loadSnd, m_loaded_sound
ASSET_TYPE_CLIPMAP, clipMap_t, clipMap, m_clip_map
ASSET_TYPE_COMWORLD, ComWorld, comWorld, m_com_world
ASSET_TYPE_GLASSWORLD, GlassWorld, glassWorld, m_glass_world
ASSET_TYPE_PATHDATA, PathData, pathData, m_path_data
ASSET_TYPE_VEHICLE_TRACK, VehicleTrack, vehicleTrack, m_vehicle_track
ASSET_TYPE_MAP_ENTS, MapEnts, mapEnts, m_map_ents
ASSET_TYPE_FXWORLD, FxWorld, fxWorld, m_fx_world
ASSET_TYPE_GFXWORLD, GfxWorld, gfxWorld, m_gfx_world
ASSET_TYPE_LIGHT_DEF, GfxLightDef, lightDef, m_gfx_light_def
ASSET_TYPE_FONT, Font_s, font, m_font
ASSET_TYPE_MENULIST, MenuList, menuList, m_menu_list
ASSET_TYPE_MENU, menuDef_t, menu, m_menu_def
ASSET_TYPE_LOCALIZE_ENTRY, LocalizeEntry, localize, m_localize
ASSET_TYPE_ATTACHMENT, WeaponAttachment, attachment, m_attachment
ASSET_TYPE_WEAPON, WeaponCompleteDef, weapon, m_weapon
ASSET_TYPE_FX, FxEffectDef, fx, m_fx
ASSET_TYPE_IMPACT_FX, FxImpactTable, impactFx, m_fx_impact_table
ASSET_TYPE_SURFACE_FX, SurfaceFxTable, surfaceFx, m_surface_fx_table
ASSET_TYPE_RAWFILE, RawFile, rawfile, m_raw_file
ASSET_TYPE_SCRIPTFILE, ScriptFile, scriptfile, m_script_file
ASSET_TYPE_STRINGTABLE, StringTable, stringTable, m_string_table
ASSET_TYPE_LEADERBOARD, LeaderboardDef, leaderboardDef, m_leaderboard
ASSET_TYPE_STRUCTURED_DATA_DEF, StructuredDataDefSet, structuredDataDefSet, m_structed_data_def_set
ASSET_TYPE_TRACER, TracerDef, tracerDef, m_tracer
ASSET_TYPE_VEHICLE, VehicleDef, vehDef, m_vehicle
ASSET_TYPE_ADDON_MAP_ENTS, AddonMapEnts, addonMapEnts, m_addon_map_ents
*/
GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const int priority) GameAssetPoolIW5::GameAssetPoolIW5(Zone* zone, const int priority)
: ZoneAssetPools(zone), : ZoneAssetPools(zone),
m_priority(priority) m_priority(priority)
{ {
assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT); assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
} }
void GameAssetPoolIW5::InitPoolStatic(const asset_type_t type, const size_t capacity) void GameAssetPoolIW5::InitPoolStatic(const asset_type_t type, const size_t capacity)
{ {
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \ #define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \ case assetType: \
{ \ { \
if ((poolName) == nullptr && capacity > 0) \ if ((poolName) == nullptr && capacity > 0) \
{ \ { \
(poolName) = std::make_unique<AssetPoolStatic<poolType>>(capacity, m_priority, (assetType)); \ (poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
} \ } \
break; \ break; \
} }
switch (type) switch (type)
{ {
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap); CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs, XModelSurfs); CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material); CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader); CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader); CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration); CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage); CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve); CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound); CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSWORLD, m_glass_world, GlassWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PATHDATA, m_path_data, PathData); CASE_INIT_POOL_STATIC(ASSET_TYPE_PATHDATA, m_path_data)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track, VehicleTrack); CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s); CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment); CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table, SurfaceFxTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTFILE, m_script_file, ScriptFile); CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet); CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default: default:
assert(type >= 0 && type < ASSET_TYPE_COUNT); assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -176,124 +129,119 @@ void GameAssetPoolIW5::InitPoolStatic(const asset_type_t type, const size_t capa
void GameAssetPoolIW5::InitPoolDynamic(const asset_type_t type) void GameAssetPoolIW5::InitPoolDynamic(const asset_type_t type)
{ {
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \ #define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \ case assetType: \
{ \ { \
if ((poolName) == nullptr) \ if ((poolName) == nullptr) \
{ \ { \
(poolName) = std::make_unique<AssetPoolDynamic<poolType>>(m_priority, (assetType)); \ (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
} \ } \
break; \ break; \
} }
switch (type) switch (type)
{ {
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs, XModelSurfs); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSWORLD, m_glass_world, GlassWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PATHDATA, m_path_data, PathData); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PATHDATA, m_path_data)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track, VehicleTrack); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table, SurfaceFxTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTFILE, m_script_file, ScriptFile); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default: default:
assert(type >= 0 && type < ASSET_TYPE_COUNT); assert(type >= 0 && type < ASSET_TYPE_COUNT);
break; break;
} }
#undef CASE_INIT_POOL_STATIC #undef CASE_INIT_POOL_DYNAMIC
} }
XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool( XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
{ {
XAsset xAsset{}; #define CASE_ADD_TO_POOL(assetType, poolName) \
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
case assetType: \ case assetType: \
{ \ { \
assert((poolName) != nullptr); \ assert((poolName) != nullptr); \
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, zone, std::move(dependencies), std::move(usedScriptStrings)); \ return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
} }
switch (xAsset.type) switch (static_cast<XAssetType>(xAssetInfo->m_type))
{ {
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset); CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, physCollmap); CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts); CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs, modelSurfs); CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model); CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material); CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, pixelShader); CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, vertexShader); CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, vertexDecl); CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet); CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image); CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound); CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve); CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd); CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld); CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSWORLD, m_glass_world, glassWorld); CASE_ADD_TO_POOL(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_ADD_TO_POOL(ASSET_TYPE_PATHDATA, m_path_data, pathData); CASE_ADD_TO_POOL(ASSET_TYPE_PATHDATA, m_path_data)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track, vehicleTrack); CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts); CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world, fxWorld); CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld); CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef); CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font); CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList); CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu); CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize); CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment, attachment); CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon); CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx); CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx); CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_SURFACE_FX, m_surface_fx_table, surfaceFx); CASE_ADD_TO_POOL(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile); CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTFILE, m_script_file, scriptfile); CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable); CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard, leaderboardDef); CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, structuredDataDefSet); CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef); CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle, vehDef); CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts); CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default: default:
assert(false); assert(false);
@ -317,46 +265,46 @@ XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, std::stri
switch (type) switch (type)
{ {
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset); CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap); CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts); CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs); CASE_GET_ASSET(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel); CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material); CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader); CASE_GET_ASSET(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_GET_ASSET(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader); CASE_GET_ASSET(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl); CASE_GET_ASSET(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set); CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image); CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound); CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound)
CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve); CASE_GET_ASSET(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound); CASE_GET_ASSET(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world); CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GLASSWORLD, m_glass_world); CASE_GET_ASSET(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_GET_ASSET(ASSET_TYPE_PATHDATA, m_path_data); CASE_GET_ASSET(ASSET_TYPE_PATHDATA, m_path_data)
CASE_GET_ASSET(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track); CASE_GET_ASSET(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents); CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world); CASE_GET_ASSET(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world); CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def); CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font); CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list); CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def); CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize); CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment); CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon); CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx); CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table); CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_GET_ASSET(ASSET_TYPE_SURFACE_FX, m_surface_fx_table); CASE_GET_ASSET(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file); CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_SCRIPTFILE, m_script_file); CASE_GET_ASSET(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table); CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard); CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set); CASE_GET_ASSET(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer); CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer)
CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle); CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents); CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default: default:
assert(false); assert(false);
@ -368,9 +316,9 @@ XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, std::stri
#undef CASE_GET_ASSET #undef CASE_GET_ASSET
} }
const char* GameAssetPoolIW5::AssetTypeNameByType(asset_type_t assetType) const char* GameAssetPoolIW5::AssetTypeNameByType(const asset_type_t assetType)
{ {
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value)) if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID; return ASSET_TYPE_INVALID;

View File

@ -14,12 +14,7 @@ class GameAssetPoolIW5 final : public ZoneAssetPools
static const char* ASSET_TYPE_NAMES[]; static const char* ASSET_TYPE_NAMES[];
protected: protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type, XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) override;
public: public:
std::unique_ptr<AssetPool<IW5::PhysPreset>> m_phys_preset; std::unique_ptr<AssetPool<IW5::PhysPreset>> m_phys_preset;

View File

@ -22,56 +22,56 @@ GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const int priority)
: ZoneAssetPools(zone), : ZoneAssetPools(zone),
m_priority(priority) m_priority(priority)
{ {
assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT); assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
} }
void GameAssetPoolT5::InitPoolStatic(const asset_type_t type, const size_t capacity) void GameAssetPoolT5::InitPoolStatic(const asset_type_t type, const size_t capacity)
{ {
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \ #define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \ case assetType: \
{ \ { \
if ((poolName) == nullptr && capacity > 0) \ if ((poolName) == nullptr && capacity > 0) \
{ \ { \
(poolName) = std::make_unique<AssetPoolStatic<poolType>>(capacity, m_priority, (assetType)); \ (poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
} \ } \
break; \ break; \
} }
switch (type) switch (type)
{ {
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints); CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material); CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage); CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank); CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch); CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s); CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals); CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PACK_INDEX, m_pack_index, PackIndex); CASE_INIT_POOL_STATIC(ASSET_TYPE_PACK_INDEX, m_pack_index)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals, XGlobals); CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses, Glasses); CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses)
CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet); CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
default: default:
assert(type >= 0 && type < ASSET_TYPE_COUNT); assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -83,110 +83,105 @@ void GameAssetPoolT5::InitPoolStatic(const asset_type_t type, const size_t capac
void GameAssetPoolT5::InitPoolDynamic(const asset_type_t type) void GameAssetPoolT5::InitPoolDynamic(const asset_type_t type)
{ {
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \ #define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \ case assetType: \
{ \ { \
if ((poolName) == nullptr) \ if ((poolName) == nullptr) \
{ \ { \
(poolName) = std::make_unique<AssetPoolDynamic<poolType>>(m_priority, (assetType)); \ (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
} \ } \
break; \ break; \
} }
switch (type) switch (type)
{ {
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PACK_INDEX, m_pack_index, PackIndex); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PACK_INDEX, m_pack_index)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals, XGlobals); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses, Glasses); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
default: default:
assert(type >= 0 && type < ASSET_TYPE_COUNT); assert(type >= 0 && type < ASSET_TYPE_COUNT);
break; break;
} }
#undef CASE_INIT_POOL_STATIC #undef CASE_INIT_POOL_DYNAMIC
} }
XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool( XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
{ {
XAsset xAsset{}; #define CASE_ADD_TO_POOL(assetType, poolName) \
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
case assetType: \ case assetType: \
{ \ { \
assert((poolName) != nullptr); \ assert((poolName) != nullptr); \
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, zone, std::move(dependencies), std::move(usedScriptStrings)); \ return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
} }
switch (xAsset.type) switch (static_cast<XAssetType>(xAssetInfo->m_type))
{ {
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset); CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, physConstraints); CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, destructibleDef); CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts); CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model); CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material); CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet); CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image); CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank, sound); CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch, soundPatch); CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld); CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp); CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp); CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts); CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld); CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef); CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font); CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList); CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu); CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize); CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon); CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, sndDriverGlobals); CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx); CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx); CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile); CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable); CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_ADD_TO_POOL(ASSET_TYPE_PACK_INDEX, m_pack_index, packIndex); CASE_ADD_TO_POOL(ASSET_TYPE_PACK_INDEX, m_pack_index)
CASE_ADD_TO_POOL(ASSET_TYPE_XGLOBALS, m_xglobals, xGlobals); CASE_ADD_TO_POOL(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl, ddlRoot); CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl)
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses, glasses); CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses)
CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set, emblemSet); CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set)
default: default:
assert(false); assert(false);
@ -210,39 +205,39 @@ XAssetInfoGeneric* GameAssetPoolT5::GetAsset(const asset_type_t type, std::strin
switch (type) switch (type)
{ {
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset); CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints); CASE_GET_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_GET_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def); CASE_GET_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts); CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel); CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material); CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set); CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image); CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound_bank); CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound_bank)
CASE_GET_ASSET(ASSET_TYPE_SOUND_PATCH, m_sound_patch); CASE_GET_ASSET(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world); CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp); CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp); CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents); CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world); CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def); CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font); CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list); CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def); CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize); CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon); CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals); CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx); CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table); CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file); CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table); CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_GET_ASSET(ASSET_TYPE_PACK_INDEX, m_pack_index); CASE_GET_ASSET(ASSET_TYPE_PACK_INDEX, m_pack_index)
CASE_GET_ASSET(ASSET_TYPE_XGLOBALS, m_xglobals); CASE_GET_ASSET(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_GET_ASSET(ASSET_TYPE_DDL, m_ddl); CASE_GET_ASSET(ASSET_TYPE_DDL, m_ddl)
CASE_GET_ASSET(ASSET_TYPE_GLASSES, m_glasses); CASE_GET_ASSET(ASSET_TYPE_GLASSES, m_glasses)
CASE_GET_ASSET(ASSET_TYPE_EMBLEMSET, m_emblem_set); CASE_GET_ASSET(ASSET_TYPE_EMBLEMSET, m_emblem_set)
default: default:
assert(false); assert(false);
@ -254,9 +249,9 @@ XAssetInfoGeneric* GameAssetPoolT5::GetAsset(const asset_type_t type, std::strin
#undef CASE_GET_ASSET #undef CASE_GET_ASSET
} }
const char* GameAssetPoolT5::AssetTypeNameByType(asset_type_t assetType) const char* GameAssetPoolT5::AssetTypeNameByType(const asset_type_t assetType)
{ {
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value)) if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID; return ASSET_TYPE_INVALID;

View File

@ -14,12 +14,7 @@ class GameAssetPoolT5 final : public ZoneAssetPools
static const char* ASSET_TYPE_NAMES[]; static const char* ASSET_TYPE_NAMES[];
protected: protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type, XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) override;
public: public:
std::unique_ptr<AssetPool<T5::PhysPreset>> m_phys_preset; std::unique_ptr<AssetPool<T5::PhysPreset>> m_phys_preset;

View File

@ -75,72 +75,72 @@ GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority)
: ZoneAssetPools(zone), : ZoneAssetPools(zone),
m_priority(priority) m_priority(priority)
{ {
assert(std::extent<decltype(ASSET_TYPE_NAMES)>::value == ASSET_TYPE_COUNT); assert(std::extent_v<decltype(ASSET_TYPE_NAMES)> == ASSET_TYPE_COUNT);
} }
void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capacity) void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capacity)
{ {
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \ #define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \ case assetType: \
{ \ { \
if ((poolName) == nullptr && capacity > 0) \ if ((poolName) == nullptr && capacity > 0) \
{ \ { \
(poolName) = std::make_unique<AssetPoolStatic<poolType>>(capacity, m_priority, (assetType)); \ (poolName) = std::make_unique<AssetPoolStatic<decltype(poolName)::element_type::type>>(capacity, m_priority, (assetType)); \
} \ } \
break; \ break; \
} }
switch (type) switch (type)
{ {
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints); CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material); CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage); CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank); CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound_bank)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch); CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s); CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONTICON, m_font_icon, FontIcon); CASE_INIT_POOL_STATIC(ASSET_TYPE_FONTICON, m_font_icon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment); CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, WeaponAttachmentUnique); CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON_CAMO, m_camo, WeaponCamo); CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON_CAMO, m_camo)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals); CASE_INIT_POOL_STATIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals, XGlobals); CASE_INIT_POOL_STATIC(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t); CASE_INIT_POOL_STATIC(ASSET_TYPE_DDL, m_ddl)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses, Glasses); CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSES, m_glasses)
CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet); CASE_INIT_POOL_STATIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTPARSETREE, m_script, ScriptParseTree); CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTPARSETREE, m_script)
CASE_INIT_POOL_STATIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, KeyValuePairs); CASE_INIT_POOL_STATIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLEDEF, m_vehicle, VehicleDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLEDEF, m_vehicle)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block, MemoryBlock); CASE_INIT_POOL_STATIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, SkinnedVertsDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_QDB, m_qdb, Qdb); CASE_INIT_POOL_STATIC(ASSET_TYPE_QDB, m_qdb)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SLUG, m_slug, Slug); CASE_INIT_POOL_STATIC(ASSET_TYPE_SLUG, m_slug)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, FootstepTableDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, FootstepFXTableDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ZBARRIER, m_zbarrier, ZBarrierDef); CASE_INIT_POOL_STATIC(ASSET_TYPE_ZBARRIER, m_zbarrier)
default: default:
assert(type >= 0 && type < ASSET_TYPE_COUNT); assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -152,142 +152,137 @@ void GameAssetPoolT6::InitPoolStatic(const asset_type_t type, const size_t capac
void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type) void GameAssetPoolT6::InitPoolDynamic(const asset_type_t type)
{ {
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \ #define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \ case assetType: \
{ \ { \
if ((poolName) == nullptr) \ if ((poolName) == nullptr) \
{ \ { \
(poolName) = std::make_unique<AssetPoolDynamic<poolType>>(m_priority, (assetType)); \ (poolName) = std::make_unique<AssetPoolDynamic<decltype(poolName)::element_type::type>>(m_priority, (assetType)); \
} \ } \
break; \ break; \
} }
switch (type) switch (type)
{ {
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, PhysConstraints); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, DestructibleDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank, SndBank); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound_bank)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch, SndPatch); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONTICON, m_font_icon, FontIcon); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONTICON, m_font_icon)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponVariantDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, WeaponAttachmentUnique); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON_CAMO, m_camo, WeaponCamo); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON_CAMO, m_camo)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, SndDriverGlobals); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals, XGlobals); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl, ddlRoot_t); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_DDL, m_ddl)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses, Glasses); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSES, m_glasses)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set, EmblemSet); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_EMBLEMSET, m_emblem_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTPARSETREE, m_script, ScriptParseTree); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTPARSETREE, m_script)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, KeyValuePairs); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLEDEF, m_vehicle, VehicleDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLEDEF, m_vehicle)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block, MemoryBlock); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, SkinnedVertsDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_QDB, m_qdb, Qdb); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_QDB, m_qdb)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SLUG, m_slug, Slug); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SLUG, m_slug)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, FootstepTableDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, FootstepFXTableDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ZBARRIER, m_zbarrier, ZBarrierDef); CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ZBARRIER, m_zbarrier)
default: default:
assert(type >= 0 && type < ASSET_TYPE_COUNT); assert(type >= 0 && type < ASSET_TYPE_COUNT);
break; break;
} }
#undef CASE_INIT_POOL_STATIC #undef CASE_INIT_POOL_DYNAMIC
} }
XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool( XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
{ {
XAsset xAsset{}; #define CASE_ADD_TO_POOL(assetType, poolName) \
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
case assetType: \ case assetType: \
{ \ { \
assert((poolName) != nullptr); \ assert((poolName) != nullptr); \
return (poolName)->AddAsset(std::move(name), xAsset.header.headerName, zone, std::move(dependencies), std::move(usedScriptStrings)); \ return (poolName)->AddAsset(std::unique_ptr<XAssetInfo<decltype(poolName)::element_type::type>>( \
static_cast<XAssetInfo<decltype(poolName)::element_type::type>*>(xAssetInfo.release()))); \
} }
switch (xAsset.type) switch (static_cast<XAssetType>(xAssetInfo->m_type))
{ {
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset, physPreset); CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints, physConstraints); CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def, destructibleDef); CASE_ADD_TO_POOL(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts); CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model); CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material); CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet); CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image); CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank, sound); CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound_bank)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch, soundPatch); CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap); CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld); CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp); CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp); CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts); CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld); CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef); CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font); CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_FONTICON, m_font_icon, fontIcon); CASE_ADD_TO_POOL(ASSET_TYPE_FONTICON, m_font_icon)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList); CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu); CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize); CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon); CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment, attachment); CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique, attachmentUnique); CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON_CAMO, m_camo, weaponCamo); CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON_CAMO, m_camo)
CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals, sndDriverGlobals); CASE_ADD_TO_POOL(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx); CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx); CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile); CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable); CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard, leaderboardDef); CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_ADD_TO_POOL(ASSET_TYPE_XGLOBALS, m_xglobals, xGlobals); CASE_ADD_TO_POOL(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl, ddlRoot); CASE_ADD_TO_POOL(ASSET_TYPE_DDL, m_ddl)
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses, glasses); CASE_ADD_TO_POOL(ASSET_TYPE_GLASSES, m_glasses)
CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set, emblemSet); CASE_ADD_TO_POOL(ASSET_TYPE_EMBLEMSET, m_emblem_set)
CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTPARSETREE, m_script, scriptParseTree); CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTPARSETREE, m_script)
CASE_ADD_TO_POOL(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs, keyValuePairs); CASE_ADD_TO_POOL(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLEDEF, m_vehicle, vehicleDef); CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLEDEF, m_vehicle)
CASE_ADD_TO_POOL(ASSET_TYPE_MEMORYBLOCK, m_memory_block, memoryBlock); CASE_ADD_TO_POOL(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts); CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef); CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer)
CASE_ADD_TO_POOL(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts, skinnedVertsDef); CASE_ADD_TO_POOL(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
CASE_ADD_TO_POOL(ASSET_TYPE_QDB, m_qdb, qdb); CASE_ADD_TO_POOL(ASSET_TYPE_QDB, m_qdb)
CASE_ADD_TO_POOL(ASSET_TYPE_SLUG, m_slug, slug); CASE_ADD_TO_POOL(ASSET_TYPE_SLUG, m_slug)
CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table, footstepTableDef); CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table)
CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table, footstepFXTableDef); CASE_ADD_TO_POOL(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table)
CASE_ADD_TO_POOL(ASSET_TYPE_ZBARRIER, m_zbarrier, zbarrierDef); CASE_ADD_TO_POOL(ASSET_TYPE_ZBARRIER, m_zbarrier)
default: default:
assert(false); assert(false);
@ -311,55 +306,55 @@ XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, std::strin
switch (type) switch (type)
{ {
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset); CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints); CASE_GET_ASSET(ASSET_TYPE_PHYSCONSTRAINTS, m_phys_constraints)
CASE_GET_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def); CASE_GET_ASSET(ASSET_TYPE_DESTRUCTIBLEDEF, m_destructible_def)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts); CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel); CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material); CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set); CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image); CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound_bank); CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound_bank)
CASE_GET_ASSET(ASSET_TYPE_SOUND_PATCH, m_sound_patch); CASE_GET_ASSET(ASSET_TYPE_SOUND_PATCH, m_sound_patch)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map); CASE_GET_ASSET(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world); CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp); CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp); CASE_GET_ASSET(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents); CASE_GET_ASSET(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world); CASE_GET_ASSET(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def); CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font); CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_FONTICON, m_font_icon); CASE_GET_ASSET(ASSET_TYPE_FONTICON, m_font_icon)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list); CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def); CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize); CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon); CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment); CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique); CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT_UNIQUE, m_attachment_unique)
CASE_GET_ASSET(ASSET_TYPE_WEAPON_CAMO, m_camo); CASE_GET_ASSET(ASSET_TYPE_WEAPON_CAMO, m_camo)
CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals); CASE_GET_ASSET(ASSET_TYPE_SNDDRIVER_GLOBALS, m_snd_driver_globals)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx); CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table); CASE_GET_ASSET(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file); CASE_GET_ASSET(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table); CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard); CASE_GET_ASSET(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_GET_ASSET(ASSET_TYPE_XGLOBALS, m_xglobals); CASE_GET_ASSET(ASSET_TYPE_XGLOBALS, m_xglobals)
CASE_GET_ASSET(ASSET_TYPE_DDL, m_ddl); CASE_GET_ASSET(ASSET_TYPE_DDL, m_ddl)
CASE_GET_ASSET(ASSET_TYPE_GLASSES, m_glasses); CASE_GET_ASSET(ASSET_TYPE_GLASSES, m_glasses)
CASE_GET_ASSET(ASSET_TYPE_EMBLEMSET, m_emblem_set); CASE_GET_ASSET(ASSET_TYPE_EMBLEMSET, m_emblem_set)
CASE_GET_ASSET(ASSET_TYPE_SCRIPTPARSETREE, m_script); CASE_GET_ASSET(ASSET_TYPE_SCRIPTPARSETREE, m_script)
CASE_GET_ASSET(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs); CASE_GET_ASSET(ASSET_TYPE_KEYVALUEPAIRS, m_key_value_pairs)
CASE_GET_ASSET(ASSET_TYPE_VEHICLEDEF, m_vehicle); CASE_GET_ASSET(ASSET_TYPE_VEHICLEDEF, m_vehicle)
CASE_GET_ASSET(ASSET_TYPE_MEMORYBLOCK, m_memory_block); CASE_GET_ASSET(ASSET_TYPE_MEMORYBLOCK, m_memory_block)
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents); CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer); CASE_GET_ASSET(ASSET_TYPE_TRACER, m_tracer)
CASE_GET_ASSET(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts); CASE_GET_ASSET(ASSET_TYPE_SKINNEDVERTS, m_skinned_verts)
CASE_GET_ASSET(ASSET_TYPE_QDB, m_qdb); CASE_GET_ASSET(ASSET_TYPE_QDB, m_qdb)
CASE_GET_ASSET(ASSET_TYPE_SLUG, m_slug); CASE_GET_ASSET(ASSET_TYPE_SLUG, m_slug)
CASE_GET_ASSET(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table); CASE_GET_ASSET(ASSET_TYPE_FOOTSTEP_TABLE, m_footstep_table)
CASE_GET_ASSET(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table); CASE_GET_ASSET(ASSET_TYPE_FOOTSTEPFX_TABLE, m_footstep_fx_table)
CASE_GET_ASSET(ASSET_TYPE_ZBARRIER, m_zbarrier); CASE_GET_ASSET(ASSET_TYPE_ZBARRIER, m_zbarrier)
default: default:
assert(false); assert(false);
@ -371,9 +366,9 @@ XAssetInfoGeneric* GameAssetPoolT6::GetAsset(const asset_type_t type, std::strin
#undef CASE_GET_ASSET #undef CASE_GET_ASSET
} }
const char* GameAssetPoolT6::AssetTypeNameByType(asset_type_t assetType) const char* GameAssetPoolT6::AssetTypeNameByType(const asset_type_t assetType)
{ {
if (assetType >= 0 && assetType < static_cast<int>(std::extent<decltype(ASSET_TYPE_NAMES)>::value)) if (assetType >= 0 && assetType < static_cast<int>(std::extent_v<decltype(ASSET_TYPE_NAMES)>))
return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_NAMES[assetType];
return ASSET_TYPE_INVALID; return ASSET_TYPE_INVALID;

View File

@ -14,12 +14,7 @@ class GameAssetPoolT6 final : public ZoneAssetPools
static const char* ASSET_TYPE_NAMES[]; static const char* ASSET_TYPE_NAMES[];
protected: protected:
XAssetInfoGeneric* AddAssetToPool(asset_type_t type, XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) override;
public: public:
std::unique_ptr<AssetPool<T6::PhysPreset>> m_phys_preset; std::unique_ptr<AssetPool<T6::PhysPreset>> m_phys_preset;

View File

@ -11,6 +11,8 @@ class Zone;
template<typename T> class AssetPool template<typename T> class AssetPool
{ {
public: public:
using type = T;
std::map<std::string, XAssetInfo<T>*> m_asset_lookup; std::map<std::string, XAssetInfo<T>*> m_asset_lookup;
class Iterator class Iterator
@ -46,8 +48,7 @@ public:
virtual ~AssetPool() = default; virtual ~AssetPool() = default;
virtual XAssetInfo<T>* virtual XAssetInfo<T>* AddAsset(std::unique_ptr<XAssetInfo<T>> xAssetInfo) = 0;
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) = 0;
XAssetInfo<T>* GetAsset(const std::string& name) XAssetInfo<T>* GetAsset(const std::string& name)
{ {

View File

@ -10,7 +10,7 @@ template<typename T> class AssetPoolDynamic final : public AssetPool<T>
{ {
using AssetPool<T>::m_asset_lookup; using AssetPool<T>::m_asset_lookup;
std::vector<XAssetInfo<T>*> m_assets; std::vector<std::unique_ptr<XAssetInfo<T>>> m_assets;
asset_type_t m_type; asset_type_t m_type;
public: public:
@ -29,35 +29,27 @@ public:
{ {
GlobalAssetPool<T>::UnlinkAssetPool(this); GlobalAssetPool<T>::UnlinkAssetPool(this);
for (auto* entry : m_assets) for (auto& entry : m_assets)
{ {
delete entry->Asset(); delete entry->Asset();
delete entry;
} }
m_assets.clear(); m_assets.clear();
m_asset_lookup.clear(); m_asset_lookup.clear();
} }
XAssetInfo<T>* XAssetInfo<T>* AddAsset(std::unique_ptr<XAssetInfo<T>> xAssetInfo) override
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override
{ {
auto* newInfo = new XAssetInfo<T>();
newInfo->m_type = m_type;
newInfo->m_name = std::move(name);
newInfo->m_zone = zone;
newInfo->m_dependencies = std::move(dependencies);
newInfo->m_used_script_strings = std::move(usedScriptStrings);
T* newAsset = new T(); T* newAsset = new T();
memcpy(newAsset, asset, sizeof(T)); memcpy(newAsset, xAssetInfo->Asset(), sizeof(T));
newInfo->m_ptr = newAsset; xAssetInfo->m_ptr = newAsset;
m_assets.push_back(newInfo); auto* pAssetInfo = xAssetInfo.get();
m_asset_lookup[newInfo->m_name] = newInfo; m_asset_lookup[xAssetInfo->m_name] = pAssetInfo;
m_assets.emplace_back(std::move(xAssetInfo));
GlobalAssetPool<T>::LinkAsset(this, newInfo); GlobalAssetPool<T>::LinkAsset(this, pAssetInfo);
return newInfo; return pAssetInfo;
} }
}; };

View File

@ -67,9 +67,7 @@ public:
~AssetPoolStatic() override ~AssetPoolStatic() override
{ {
if (m_capacity > 0) if (m_capacity > 0)
{
GlobalAssetPool<T>::UnlinkAssetPool(this); GlobalAssetPool<T>::UnlinkAssetPool(this);
}
delete[] m_pool; delete[] m_pool;
m_pool = nullptr; m_pool = nullptr;
@ -81,25 +79,19 @@ public:
m_capacity = 0; m_capacity = 0;
} }
XAssetInfo<T>* XAssetInfo<T>* AddAsset(std::unique_ptr<XAssetInfo<T>> xAssetInfo) override
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override
{ {
if (m_free == nullptr) if (m_free == nullptr)
{
throw std::runtime_error("Could not add asset to static asset pool: capacity exhausted."); throw std::runtime_error("Could not add asset to static asset pool: capacity exhausted.");
}
AssetPoolEntry* poolSlot = m_free; AssetPoolEntry* poolSlot = m_free;
m_free = m_free->m_next; m_free = m_free->m_next;
memcpy(&poolSlot->m_entry, asset, sizeof(T)); const T* pAsset = xAssetInfo->Asset();
xAssetInfo->m_ptr = static_cast<void*>(&poolSlot->m_entry);
memcpy(&poolSlot->m_entry, pAsset, sizeof(T));
poolSlot->m_info->m_type = m_type; *poolSlot->m_info = std::move(*xAssetInfo);
poolSlot->m_info->m_name = std::move(name);
poolSlot->m_info->m_ptr = &poolSlot->m_entry;
poolSlot->m_info->m_zone = zone;
poolSlot->m_info->m_dependencies = std::move(dependencies);
poolSlot->m_info->m_used_script_strings = std::move(usedScriptStrings);
m_asset_lookup[poolSlot->m_info->m_name] = poolSlot->m_info; m_asset_lookup[poolSlot->m_info->m_name] = poolSlot->m_info;

View File

@ -0,0 +1,89 @@
#include "XAssetInfo.h"
IndirectAssetReference::IndirectAssetReference()
: m_type(-1)
{
}
IndirectAssetReference::IndirectAssetReference(const asset_type_t type, std::string name)
: m_type(type),
m_name(std::move(name))
{
}
bool operator==(const IndirectAssetReference& lhs, const IndirectAssetReference& rhs)
{
return lhs.m_type == rhs.m_type && lhs.m_name == rhs.m_name;
}
bool operator!=(const IndirectAssetReference& lhs, const IndirectAssetReference& rhs)
{
return !(lhs == rhs);
}
std::size_t std::hash<IndirectAssetReference>::operator()(const IndirectAssetReference& v) const noexcept
{
std::size_t seed = 0x01A627D3;
seed ^= (seed << 6) + (seed >> 2) + 0x0BCEF9CE + static_cast<std::size_t>(v.m_type);
seed ^= (seed << 6) + (seed >> 2) + 0x7225148B + std::hash<std::string>()(v.m_name);
return seed;
}
XAssetInfoGeneric::XAssetInfoGeneric()
: m_type(-1),
m_ptr(nullptr),
m_zone(nullptr)
{
}
XAssetInfoGeneric::XAssetInfoGeneric(const asset_type_t type, std::string name, void* ptr)
: m_type(type),
m_name(std::move(name)),
m_ptr(ptr),
m_zone(nullptr)
{
}
XAssetInfoGeneric::XAssetInfoGeneric(
const asset_type_t type, std::string name, void* ptr, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings)
: m_type(type),
m_name(std::move(name)),
m_ptr(ptr),
m_dependencies(std::move(dependencies)),
m_used_script_strings(std::move(usedScriptStrings)),
m_zone(nullptr)
{
}
XAssetInfoGeneric::XAssetInfoGeneric(asset_type_t type,
std::string name,
void* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences)
: m_type(type),
m_name(std::move(name)),
m_ptr(ptr),
m_dependencies(std::move(dependencies)),
m_used_script_strings(std::move(usedScriptStrings)),
m_indirect_asset_references(std::move(indirectAssetReferences)),
m_zone(nullptr)
{
}
XAssetInfoGeneric::XAssetInfoGeneric(const asset_type_t type,
std::string name,
void* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences,
Zone* zone)
: m_type(type),
m_name(std::move(name)),
m_ptr(ptr),
m_dependencies(std::move(dependencies)),
m_used_script_strings(std::move(usedScriptStrings)),
m_indirect_asset_references(std::move(indirectAssetReferences)),
m_zone(zone)
{
}

View File

@ -7,20 +7,107 @@
class Zone; class Zone;
// An indirect asset reference is a reference that is not done per pointer but by mentioning the asset
// in a string or requiring the asset to exist in some other way
class IndirectAssetReference
{
public:
asset_type_t m_type;
std::string m_name;
IndirectAssetReference();
IndirectAssetReference(asset_type_t type, std::string name);
friend bool operator==(const IndirectAssetReference& lhs, const IndirectAssetReference& rhs);
friend bool operator!=(const IndirectAssetReference& lhs, const IndirectAssetReference& rhs);
};
template<> struct std::hash<IndirectAssetReference>
{
std::size_t operator()(const IndirectAssetReference& v) const noexcept;
};
class XAssetInfoGeneric class XAssetInfoGeneric
{ {
public: public:
asset_type_t m_type = -1; asset_type_t m_type;
std::string m_name; std::string m_name;
Zone* m_zone; void* m_ptr;
std::vector<XAssetInfoGeneric*> m_dependencies; std::vector<XAssetInfoGeneric*> m_dependencies;
std::vector<scr_string_t> m_used_script_strings; std::vector<scr_string_t> m_used_script_strings;
void* m_ptr; std::vector<IndirectAssetReference> m_indirect_asset_references;
Zone* m_zone;
XAssetInfoGeneric();
XAssetInfoGeneric(asset_type_t type, std::string name, void* ptr);
XAssetInfoGeneric(
asset_type_t type, std::string name, void* ptr, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings);
XAssetInfoGeneric(asset_type_t type,
std::string name,
void* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences);
XAssetInfoGeneric(asset_type_t type,
std::string name,
void* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences,
Zone* zone);
~XAssetInfoGeneric() = default;
XAssetInfoGeneric(const XAssetInfoGeneric& other) = default;
XAssetInfoGeneric(XAssetInfoGeneric&& other) noexcept = default;
XAssetInfoGeneric& operator=(const XAssetInfoGeneric& other) = default;
XAssetInfoGeneric& operator=(XAssetInfoGeneric&& other) noexcept = default;
}; };
template<typename T> class XAssetInfo : public XAssetInfoGeneric template<typename T> class XAssetInfo : public XAssetInfoGeneric
{ {
public: public:
XAssetInfo() = default;
XAssetInfo(const asset_type_t type, std::string name, T* ptr)
: XAssetInfoGeneric(type, std::move(name), static_cast<void*>(ptr))
{
}
XAssetInfo(const asset_type_t type, std::string name, T* ptr, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings)
: XAssetInfoGeneric(type, std::move(name), static_cast<void*>(ptr), std::move(dependencies), std::move(usedScriptStrings))
{
}
XAssetInfo(const asset_type_t type,
std::string name,
T* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences)
: XAssetInfoGeneric(
type, std::move(name), static_cast<void*>(ptr), std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences))
{
}
XAssetInfo(const asset_type_t type,
std::string name,
T* ptr,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences,
Zone* zone)
: XAssetInfoGeneric(
type, std::move(name), static_cast<void*>(ptr), std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences), zone)
{
}
~XAssetInfo() = default;
XAssetInfo(const XAssetInfo& other) = default;
XAssetInfo(XAssetInfo&& other) noexcept = default;
XAssetInfo& operator=(const XAssetInfo& other) = default;
XAssetInfo& operator=(XAssetInfo&& other) noexcept = default;
T* Asset() T* Asset()
{ {
return static_cast<T*>(m_ptr); return static_cast<T*>(m_ptr);

View File

@ -5,25 +5,23 @@ ZoneAssetPools::ZoneAssetPools(Zone* zone)
{ {
} }
XAssetInfoGeneric* ZoneAssetPools::AddAsset(
const asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings)
{
return AddAsset(type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), m_zone);
}
XAssetInfoGeneric* ZoneAssetPools::AddAsset(const asset_type_t type, XAssetInfoGeneric* ZoneAssetPools::AddAsset(const asset_type_t type,
std::string name, std::string name,
void* asset, void* asset,
std::vector<XAssetInfoGeneric*> dependencies, std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings, std::vector<scr_string_t> usedScriptStrings,
Zone* zone) std::vector<IndirectAssetReference> indirectAssetReferences)
{ {
auto* assetInfo = AddAssetToPool(type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), zone); return AddAsset(std::make_unique<XAssetInfoGeneric>(
if (assetInfo) type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences), m_zone));
{
m_assets_in_order.push_back(assetInfo);
} }
XAssetInfoGeneric* ZoneAssetPools::AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
auto* assetInfo = AddAssetToPool(std::move(xAssetInfo));
if (assetInfo)
m_assets_in_order.push_back(assetInfo);
return assetInfo; return assetInfo;
} }

View File

@ -5,10 +5,12 @@
#include "Zone/ZoneTypes.h" #include "Zone/ZoneTypes.h"
#include <cstddef> #include <cstddef>
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
class Zone; class Zone;
class IndirectAssetReference;
class XAssetInfoGeneric; class XAssetInfoGeneric;
class ZoneAssetPools class ZoneAssetPools
@ -17,12 +19,7 @@ protected:
Zone* m_zone; Zone* m_zone;
std::vector<XAssetInfoGeneric*> m_assets_in_order; std::vector<XAssetInfoGeneric*> m_assets_in_order;
virtual XAssetInfoGeneric* AddAssetToPool(asset_type_t type, virtual XAssetInfoGeneric* AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) = 0;
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone) = 0;
public: public:
using iterator = std::vector<XAssetInfoGeneric*>::const_iterator; using iterator = std::vector<XAssetInfoGeneric*>::const_iterator;
@ -34,14 +31,13 @@ public:
ZoneAssetPools& operator=(const ZoneAssetPools& other) = delete; ZoneAssetPools& operator=(const ZoneAssetPools& other) = delete;
ZoneAssetPools& operator=(ZoneAssetPools&& other) noexcept = default; ZoneAssetPools& operator=(ZoneAssetPools&& other) noexcept = default;
XAssetInfoGeneric* XAssetInfoGeneric* AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo);
AddAsset(asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings);
XAssetInfoGeneric* AddAsset(asset_type_t type, XAssetInfoGeneric* AddAsset(asset_type_t type,
std::string name, std::string name,
void* asset, void* asset,
std::vector<XAssetInfoGeneric*> dependencies, std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings, std::vector<scr_string_t> usedScriptStrings,
Zone* zone); std::vector<IndirectAssetReference> indirectAssetReferences);
_NODISCARD virtual XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const = 0; _NODISCARD virtual XAssetInfoGeneric* GetAsset(asset_type_t type, std::string name) const = 0;
_NODISCARD virtual asset_type_t GetAssetTypeCount() const = 0; _NODISCARD virtual asset_type_t GetAssetTypeCount() const = 0;
_NODISCARD virtual const char* GetAssetTypeName(asset_type_t assetType) const = 0; _NODISCARD virtual const char* GetAssetTypeName(asset_type_t assetType) const = 0;
@ -51,6 +47,6 @@ public:
_NODISCARD size_t GetTotalAssetCount() const; _NODISCARD size_t GetTotalAssetCount() const;
iterator begin() const; _NODISCARD iterator begin() const;
iterator end() const; _NODISCARD iterator end() const;
}; };

View File

@ -10,10 +10,14 @@ AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStr
{ {
} }
XAssetInfoGeneric* XAssetInfoGeneric* AssetLoader::LinkAsset(std::string name,
AssetLoader::LinkAsset(std::string name, void* asset, std::vector<scr_string_t> scriptStrings, std::vector<XAssetInfoGeneric*> dependencies) const void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> scriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences) const
{ {
return m_zone->m_pools->AddAsset(m_asset_type, std::move(name), asset, std::move(dependencies), std::move(scriptStrings)); return m_zone->m_pools->AddAsset(
m_asset_type, std::move(name), asset, std::move(dependencies), std::move(scriptStrings), std::move(indirectAssetReferences));
} }
XAssetInfoGeneric* AssetLoader::GetAssetInfo(std::string name) const XAssetInfoGeneric* AssetLoader::GetAssetInfo(std::string name) const

View File

@ -16,7 +16,11 @@ protected:
AssetLoader(asset_type_t assetType, Zone* zone, IZoneInputStream* stream); AssetLoader(asset_type_t assetType, Zone* zone, IZoneInputStream* stream);
XAssetInfoGeneric* LinkAsset(std::string name, void* asset, std::vector<scr_string_t> scriptStrings, std::vector<XAssetInfoGeneric*> dependencies) const; XAssetInfoGeneric* LinkAsset(std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> scriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences) const;
_NODISCARD XAssetInfoGeneric* GetAssetInfo(std::string name) const; _NODISCARD XAssetInfoGeneric* GetAssetInfo(std::string name) const;
}; };

View File

@ -39,6 +39,22 @@ void AssetMarker::MarkArray_ScriptString(const scr_string_t* scrStringArray, con
Mark_ScriptString(scrStringArray[index]); Mark_ScriptString(scrStringArray[index]);
} }
void AssetMarker::Mark_IndirectAssetRef(asset_type_t type, const char* assetRefName)
{
if (!assetRefName || !assetRefName[0])
return;
m_indirect_asset_references.emplace(type, assetRefName);
}
void AssetMarker::MarkArray_IndirectAssetRef(const asset_type_t type, const char** assetRefNames, const size_t count)
{
assert(assetRefNames != nullptr);
for (size_t index = 0; index < count; index++)
Mark_IndirectAssetRef(type, assetRefNames[index]);
}
XAssetInfoGeneric* AssetMarker::GetAssetInfoByName(std::string name) const XAssetInfoGeneric* AssetMarker::GetAssetInfoByName(std::string name) const
{ {
return m_zone->m_pools->GetAsset(m_asset_type, std::move(name)); return m_zone->m_pools->GetAsset(m_asset_type, std::move(name));
@ -71,3 +87,16 @@ std::vector<scr_string_t> AssetMarker::GetUsedScriptStrings() const
return usedScriptStrings; return usedScriptStrings;
} }
std::vector<IndirectAssetReference> AssetMarker::GetIndirectAssetReferences() const
{
std::vector<IndirectAssetReference> assetReferences;
if (!m_indirect_asset_references.empty())
{
assetReferences.reserve(m_indirect_asset_references.size());
for (const auto& assetReference : m_indirect_asset_references)
assetReferences.emplace_back(assetReference);
}
return assetReferences;
}

View File

@ -13,6 +13,7 @@ class AssetMarker
std::unordered_set<XAssetInfoGeneric*> m_dependencies; std::unordered_set<XAssetInfoGeneric*> m_dependencies;
std::unordered_set<scr_string_t> m_used_script_strings; std::unordered_set<scr_string_t> m_used_script_strings;
std::unordered_set<IndirectAssetReference> m_indirect_asset_references;
protected: protected:
AssetMarker(asset_type_t assetType, Zone* zone); AssetMarker(asset_type_t assetType, Zone* zone);
@ -22,6 +23,9 @@ protected:
void Mark_ScriptString(scr_string_t scrString); void Mark_ScriptString(scr_string_t scrString);
void MarkArray_ScriptString(const scr_string_t* scrStringArray, size_t count); void MarkArray_ScriptString(const scr_string_t* scrStringArray, size_t count);
void Mark_IndirectAssetRef(asset_type_t type, const char* assetRefName);
void MarkArray_IndirectAssetRef(asset_type_t type, const char** assetRefNames, size_t count);
_NODISCARD XAssetInfoGeneric* GetAssetInfoByName(std::string name) const; _NODISCARD XAssetInfoGeneric* GetAssetInfoByName(std::string name) const;
Zone* m_zone; Zone* m_zone;
@ -29,4 +33,5 @@ protected:
public: public:
_NODISCARD std::vector<XAssetInfoGeneric*> GetDependencies() const; _NODISCARD std::vector<XAssetInfoGeneric*> GetDependencies() const;
_NODISCARD std::vector<scr_string_t> GetUsedScriptStrings() const; _NODISCARD std::vector<scr_string_t> GetUsedScriptStrings() const;
_NODISCARD std::vector<IndirectAssetReference> GetIndirectAssetReferences() const;
}; };

View File

@ -12,18 +12,32 @@ AssetLoadingContext* MockAssetLoadingManager::GetAssetLoadingContext() const
return m_context.get(); return m_context.get();
} }
XAssetInfoGeneric* MockAssetLoadingManager::AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
const auto assetInfoPtr = xAssetInfo.get();
m_added_assets.emplace(std::make_pair(xAssetInfo->m_name, std::move(xAssetInfo)));
return assetInfoPtr;
}
XAssetInfoGeneric* MockAssetLoadingManager::AddAsset(const asset_type_t assetType, XAssetInfoGeneric* MockAssetLoadingManager::AddAsset(const asset_type_t assetType,
const std::string& assetName, const std::string& assetName,
void* asset, void* asset,
std::vector<XAssetInfoGeneric*> dependencies, std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings) std::vector<scr_string_t> usedScriptStrings)
{ {
XAssetInfoGeneric assetInfoObj{assetType, assetName, m_zone, std::move(dependencies), std::move(usedScriptStrings), asset}; return AddAsset(std::make_unique<XAssetInfoGeneric>(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings)));
auto assetInfo = std::make_unique<XAssetInfoGeneric>(std::move(assetInfoObj)); }
const auto assetInfoPtr = assetInfo.get();
m_added_assets.emplace(std::make_pair(assetInfo->m_name, std::move(assetInfo)));
return assetInfoPtr; XAssetInfoGeneric* MockAssetLoadingManager::AddAsset(asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences)
{
return AddAsset(std::make_unique<XAssetInfoGeneric>(
assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences)));
} }
XAssetInfoGeneric* MockAssetLoadingManager::LoadDependency(const asset_type_t assetType, const std::string& assetName) XAssetInfoGeneric* MockAssetLoadingManager::LoadDependency(const asset_type_t assetType, const std::string& assetName)
@ -41,11 +55,15 @@ XAssetInfoGeneric* MockAssetLoadingManager::LoadDependency(const asset_type_t as
return nullptr; return nullptr;
} }
IndirectAssetReference MockAssetLoadingManager::LoadIndirectAssetReference(const asset_type_t assetType, const std::string& assetName)
{
return IndirectAssetReference(assetType, assetName);
}
void MockAssetLoadingManager::MockAddAvailableDependency(const asset_type_t assetType, std::string assetName, void* asset) void MockAssetLoadingManager::MockAddAvailableDependency(const asset_type_t assetType, std::string assetName, void* asset)
{ {
XAssetInfoGeneric assetInfoObj{assetType, std::move(assetName), m_zone, std::vector<XAssetInfoGeneric*>(), std::vector<scr_string_t>(), asset}; auto assetInfo = std::make_unique<XAssetInfoGeneric>(assetType, std::move(assetName), asset);
auto assetInfo = std::make_unique<XAssetInfoGeneric>(std::move(assetInfoObj)); m_available_dependencies.emplace(assetInfo->m_name, std::move(assetInfo));
m_available_dependencies.emplace(std::make_pair(assetInfo->m_name, std::move(assetInfo)));
} }
XAssetInfoGeneric* MockAssetLoadingManager::MockGetAddedAsset(const std::string& assetName) XAssetInfoGeneric* MockAssetLoadingManager::MockGetAddedAsset(const std::string& assetName)

View File

@ -17,12 +17,20 @@ public:
MockAssetLoadingManager(Zone* zone, ISearchPath* searchPath); MockAssetLoadingManager(Zone* zone, ISearchPath* searchPath);
_NODISCARD AssetLoadingContext* GetAssetLoadingContext() const override; _NODISCARD AssetLoadingContext* GetAssetLoadingContext() const override;
XAssetInfoGeneric* AddAsset(std::unique_ptr<XAssetInfoGeneric> xAssetInfo) override;
XAssetInfoGeneric* AddAsset(asset_type_t assetType, XAssetInfoGeneric* AddAsset(asset_type_t assetType,
const std::string& assetName, const std::string& assetName,
void* asset, void* asset,
std::vector<XAssetInfoGeneric*> dependencies, std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings) override; std::vector<scr_string_t> usedScriptStrings) override;
XAssetInfoGeneric* AddAsset(asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
std::vector<IndirectAssetReference> indirectAssetReferences) override;
XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) override; XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) override;
IndirectAssetReference LoadIndirectAssetReference(asset_type_t assetType, const std::string& assetName) override;
void MockAddAvailableDependency(asset_type_t assetType, std::string assetName, void* asset); void MockAddAvailableDependency(asset_type_t assetType, std::string assetName, void* asset);
XAssetInfoGeneric* MockGetAddedAsset(const std::string& assetName); XAssetInfoGeneric* MockGetAddedAsset(const std::string& assetName);

2
thirdparty/catch2 vendored

@ -1 +1 @@
Subproject commit 79205da6a67f5ad3d7874cf1c6423283dfeab199 Subproject commit 1078e7e95b3a06d4dadc75188de48bc4afffb955

2
thirdparty/json vendored

@ -1 +1 @@
Subproject commit 7efe875495a3ed7d805ddbb01af0c7725f50c88b Subproject commit 0457de21cffb298c22b629e538036bfeb96130b7

2
thirdparty/zlib vendored

@ -1 +1 @@
Subproject commit 7af6320ad78b390de42f414fabdc64dc6d67a5ea Subproject commit f1f503da85d52e56aae11557b4d79a42bcaa2b86