Merge pull request #109 from Laupetin/fix/assets-referenced-by-string

fix: assets referenced by their name in a string are not recognized as dependencies
This commit is contained in:
Jan 2024-02-07 01:39:19 +01:00 committed by GitHub
commit d2827e5e4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
51 changed files with 1500 additions and 1226 deletions

View File

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

View File

@ -19,17 +19,15 @@ AssetLoadingContext* AssetLoadingManager::GetAssetLoadingContext() const
return &m_context;
}
XAssetInfoGeneric* AssetLoadingManager::AddAsset(const asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone)
XAssetInfoGeneric* AssetLoadingManager::AddAssetInternal(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
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)
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << assetName << "\""
<< std::endl;
std::cout << "Failed to add asset of type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\" to pool: \"" << pAssetName << "\"\n";
return m_last_dependency_loaded;
}
@ -39,11 +37,24 @@ XAssetInfoGeneric* AssetLoadingManager::AddAsset(const asset_type_t assetType,
std::vector<XAssetInfoGeneric*> dependencies,
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));
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;
return m_last_dependency_loaded;
return AddAsset(std::make_unique<XAssetInfoGeneric>(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings)));
}
XAssetInfoGeneric* AssetLoadingManager::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* 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)
@ -64,20 +75,13 @@ XAssetInfoGeneric* AssetLoadingManager::LoadIgnoredDependency(const asset_type_t
auto* existingAsset = loader->LoadFromGlobalAssetPools(assetName);
if (existingAsset)
{
std::vector<XAssetInfoGeneric*> dependencies;
AddAsset(existingAsset->m_type,
existingAsset->m_name,
existingAsset->m_ptr,
std::vector<XAssetInfoGeneric*>(),
std::vector<scr_string_t>(),
existingAsset->m_zone);
AddAssetInternal(std::make_unique<XAssetInfoGeneric>(*existingAsset));
auto* lastDependency = m_last_dependency_loaded;
m_last_dependency_loaded = nullptr;
return lastDependency;
}
std::cout << "Failed to create empty asset \"" << assetName << "\" for type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\""
<< std::endl;
std::cout << "Failed to create empty asset \"" << assetName << "\" for type \"" << m_context.m_zone->m_pools->GetAssetTypeName(assetType) << "\"\n";
return nullptr;
}
@ -105,6 +109,7 @@ XAssetInfoGeneric* AssetLoadingManager::LoadAssetDependency(const asset_type_t a
if (existingAsset)
{
std::vector<XAssetInfoGeneric*> dependencies;
std::vector<IndirectAssetReference> indirectAssetReferences;
for (const auto* dependency : existingAsset->m_dependencies)
{
auto* newDependency = LoadDependency(dependency->m_type, dependency->m_name);
@ -114,23 +119,29 @@ XAssetInfoGeneric* AssetLoadingManager::LoadAssetDependency(const asset_type_t a
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
// The replacement of the scr_string_t values will be done upon writing
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));
AddAsset(existingAsset->m_type,
existingAsset->m_name,
existingAsset->m_ptr,
std::move(dependencies),
existingAsset->m_used_script_strings,
existingAsset->m_zone);
AddAssetInternal(std::make_unique<XAssetInfoGeneric>(existingAsset->m_type,
existingAsset->m_name,
existingAsset->m_ptr,
std::move(dependencies),
existingAsset->m_used_script_strings,
std::move(indirectAssetReferences),
existingAsset->m_zone));
auto* lastDependency = m_last_dependency_loaded;
m_last_dependency_loaded = nullptr;
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;
}
@ -154,6 +165,27 @@ XAssetInfoGeneric* AssetLoadingManager::LoadDependency(const asset_type_t assetT
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;
}
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* LoadAssetDependency(asset_type_t assetType, const std::string& assetName, IAssetLoader* loader);
XAssetInfoGeneric* AddAsset(asset_type_t assetType,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings,
Zone* zone);
XAssetInfoGeneric* AddAssetInternal(std::unique_ptr<XAssetInfoGeneric> xAssetInfo);
public:
AssetLoadingManager(const std::map<asset_type_t, std::unique_ptr<IAssetLoader>>& assetLoadersByType, AssetLoadingContext& context);
@ -33,5 +28,13 @@ public:
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
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;
IndirectAssetReference LoadIndirectAssetReference(asset_type_t assetType, const std::string& assetName) override;
};

View File

@ -23,6 +23,13 @@ public:
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
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)
{
@ -30,4 +37,5 @@ public:
}
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

@ -227,7 +227,7 @@ namespace T6
{
std::cout << "Cannot have more than "
<< (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;
}
@ -239,15 +239,14 @@ namespace T6
if (static_cast<unsigned>(attachmentUniqueAsset->attachmentType) >= ATTACHMENT_TYPE_COUNT)
{
std::cout << "Invalid attachment type " << attachmentUniqueAsset->attachmentType << " for attachment unique asset \""
<< attachmentUniqueName << "\"" << std::endl;
<< attachmentUniqueName << "\"\n";
return false;
}
if (attachmentUniques[attachmentUniqueAsset->attachmentType] != nullptr)
{
std::cout << "Already loaded attachment unique with same type " << attachmentUniqueAsset->attachmentType << ": \""
<< attachmentUniques[attachmentUniqueAsset->attachmentType]->szInternalName << "\", \"" << attachmentUniqueName << "\""
<< std::endl;
<< attachmentUniques[attachmentUniqueAsset->attachmentType]->szInternalName << "\", \"" << attachmentUniqueName << "\"\n";
return false;
}
@ -259,6 +258,18 @@ namespace T6
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:
bool ConvertExtensionField(const cspField_t& field, const std::string& value) override
{
@ -352,7 +363,9 @@ namespace T6
case WFT_ATTACHMENT_UNIQUES:
return ConvertAttachmentUniques(field, value);
case WFT_NUM_FIELD_TYPES:
case WFT_ANIM_NAME:
return ConvertAnimName(field, value);
default:
assert(false);
return false;
@ -553,7 +566,12 @@ bool AssetLoaderWeapon::LoadFromInfoString(
CalculateWeaponFields(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;
}

View File

@ -41,7 +41,7 @@ bool InfoStringToStructConverterBase::ParseAsArray(const std::string& value, std
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;
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> scrStringList;
scrStringList.reserve(m_used_script_string_list.size());
for (auto scrStr : m_used_script_string_list)
{
scrStringList.push_back(scrStr);
@ -238,6 +239,7 @@ std::vector<scr_string_t> InfoStringToStructConverterBase::GetUsedScriptStrings(
std::vector<XAssetInfoGeneric*> InfoStringToStructConverterBase::GetDependencies() const
{
std::vector<XAssetInfoGeneric*> dependencyList;
dependencyList.reserve(m_dependencies.size());
for (auto* dependency : m_dependencies)
{
dependencyList.push_back(dependency);
@ -245,3 +247,15 @@ std::vector<XAssetInfoGeneric*> InfoStringToStructConverterBase::GetDependencies
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;
std::unordered_set<scr_string_t> m_used_script_string_list;
std::unordered_set<XAssetInfoGeneric*> m_dependencies;
std::unordered_set<IndirectAssetReference> m_indirect_asset_references;
MemoryManager* m_memory;
void* m_structure;
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 ConvertStringBuffer(const std::string& value, size_t offset, size_t bufferSize);
@ -45,4 +46,5 @@ public:
virtual bool Convert() = 0;
_NODISCARD std::vector<scr_string_t> GetUsedScriptStrings() 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))
{
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
case WFT_BOUNCE_SOUND:
@ -92,31 +92,31 @@ namespace T6
}
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;
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;
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;
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;
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;
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;
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;
case WFT_ICONRATIO_HUD:
@ -124,11 +124,11 @@ namespace T6
case WFT_ICONRATIO_KILL:
case WFT_ICONRATIO_DPAD:
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;
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;
case WFT_HIDETAGS:
@ -137,7 +137,7 @@ namespace T6
std::stringstream ss;
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]);
if (!str.empty())
@ -162,11 +162,11 @@ namespace T6
case WFT_NOTETRACKSOUNDMAP:
{
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;
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& value = m_get_scr_string(values[i]);
@ -205,7 +205,7 @@ namespace T6
std::stringstream ss;
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])
{
@ -227,7 +227,7 @@ namespace T6
std::stringstream ss;
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])
{
@ -243,6 +243,10 @@ namespace T6
break;
}
case WFT_ANIM_NAME:
FillFromString(std::string(field.szName), field.iOffset);
break;
case WFT_NUM_FIELD_TYPES:
default:
assert(false);
@ -274,21 +278,21 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
if (weapon->attachments)
{
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;
}
if (weapon->attachmentUniques)
{
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;
}
if (fullDef->weapDef.gunXModel)
{
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;
}
@ -302,7 +306,7 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
if (weapon->hideTags)
{
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;
}
@ -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);
memcpy(fullDef->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;
}
@ -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);
memcpy(fullDef->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;
}
if (fullDef->weapDef.worldModel)
{
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;
}
if (weapon->attachViewModel)
{
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;
}
if (weapon->attachWorldModel)
{
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;
}
if (weapon->attachViewModelTag)
{
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;
}
if (weapon->attachWorldModelTag)
{
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;
}
@ -382,7 +386,7 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponVariantDef* weapon, WeaponFull
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(),
weapon_fields,
std::extent<decltype(weapon_fields)>::value,
std::extent_v<decltype(weapon_fields)>,
[asset](const scr_string_t scrStr) -> std::string
{
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;
set condition handle never;
set string name;
set assetref name ASSET_TYPE_FX;
// FxTrailDef
use FxTrailDef;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,7 @@ MemberInformation::MemberInformation(StructureInformation* parent, StructureInfo
m_is_script_string(false),
m_is_reusable(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_alloc_alignment;
const FastFileBlock* m_fast_file_block;
const EnumMember* m_asset_ref;
MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member);
};

View File

@ -1075,7 +1075,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate
LINE("marker.Mark(*pAsset);")
LINE("")
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();")
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,
MemberInformation* member,
const DeclarationModifierComputations& modifier,
@ -308,6 +337,10 @@ class ZoneMarkTemplate::Internal final : BaseTemplate
{
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())
{
MarkMember_Asset(info, member, modifier, loadType);
@ -541,7 +574,8 @@ class ZoneMarkTemplate::Internal final : BaseTemplate
if (computations.ShouldIgnore() || computations.IsInRuntimeBlock())
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)
MarkMember_Condition_Union(info, member);

View File

@ -6,6 +6,7 @@
#include "Parsing/Commands/Sequence/SequenceArrayCount.h"
#include "Parsing/Commands/Sequence/SequenceArraySize.h"
#include "Parsing/Commands/Sequence/SequenceAsset.h"
#include "Parsing/Commands/Sequence/SequenceAssetRef.h"
#include "Parsing/Commands/Sequence/SequenceBlock.h"
#include "Parsing/Commands/Sequence/SequenceCondition.h"
#include "Parsing/Commands/Sequence/SequenceCount.h"
@ -33,6 +34,7 @@ const std::vector<CommandsParser::sequence_t*>& CommandsParser::GetTestsForState
new SequenceArrayCount(),
new SequenceArraySize(),
new SequenceAsset(),
new SequenceAssetRef(),
new SequenceBlock(),
new SequenceCondition(),
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)
continue;
// Any ScriptStrings or Strings need to be processed.
if (member->m_is_script_string || member->m_type && member->m_type->m_asset_enum_entry)
// Any script strings, asset refs and assets need to be processed.
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;
return true;

View File

@ -15,87 +15,53 @@ const char* GameAssetPoolIW3::ASSET_TYPE_NAMES[]{
"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)
: ZoneAssetPools(zone),
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)
{
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \
{ \
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; \
}
switch (type)
{
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
default:
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)
{
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \
{ \
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; \
}
switch (type)
{
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
default:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
@ -154,49 +120,44 @@ void GameAssetPoolIW3::InitPoolDynamic(const asset_type_t type)
#undef CASE_INIT_POOL_STATIC
}
XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
XAsset xAsset{};
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
#define CASE_ADD_TO_POOL(assetType, poolName) \
case assetType: \
{ \
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_XANIMPARTS, m_xanim_parts, parts);
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model);
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material);
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet);
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve);
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp);
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font);
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize);
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon);
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx);
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx);
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile);
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_PVS, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
default:
assert(false);
@ -220,32 +181,32 @@ XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, std::stri
switch (type)
{
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset);
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts);
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel);
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material);
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set);
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image);
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound);
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_CLIPMAP, 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_GAMEWORLD_SP, m_game_world_sp);
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_GFXWORLD, m_gfx_world);
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def);
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font);
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize);
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon);
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx);
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_STRINGTABLE, m_string_table);
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound)
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_CLIPMAP, 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_GAMEWORLD_SP, m_game_world_sp)
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_GFXWORLD, m_gfx_world)
CASE_GET_ASSET(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_GET_ASSET(ASSET_TYPE_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
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_STRINGTABLE, m_string_table)
default:
assert(false);
@ -257,9 +218,9 @@ XAssetInfoGeneric* GameAssetPoolIW3::GetAsset(const asset_type_t type, std::stri
#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_INVALID;

View File

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

View File

@ -16,107 +16,63 @@ const char* GameAssetPoolIW4::ASSET_TYPE_NAMES[]{
"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)
: ZoneAssetPools(zone),
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)
{
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \
{ \
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; \
}
switch (type)
{
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
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)
{
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \
{ \
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; \
}
switch (type)
{
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, GameWorldSp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, GameWorldMp);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
break;
}
#undef CASE_INIT_POOL_STATIC
#undef CASE_INIT_POOL_DYNAMIC
}
XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
XAsset xAsset{};
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
#define CASE_ADD_TO_POOL(assetType, poolName) \
case assetType: \
{ \
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_PHYSCOLLMAP, m_phys_collmap, physCollmap);
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts);
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model);
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material);
CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, pixelShader);
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, vertexShader);
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, vertexDecl);
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet);
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve);
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp, gameWorldSp);
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp, gameWorldMp);
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world, fxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font);
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize);
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon);
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx);
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx);
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile);
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable);
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard, leaderboardDef);
CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, structuredDataDefSet);
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef);
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle, vehDef);
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_SP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP_MP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_SP, m_game_world_sp)
CASE_ADD_TO_POOL(ASSET_TYPE_GAMEWORLD_MP, m_game_world_mp)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
assert(false);
@ -261,42 +212,42 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri
switch (type)
{
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset);
CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap);
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts);
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel);
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material);
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_VERTEXDECL, m_material_vertex_decl);
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set);
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image);
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound);
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_CLIPMAP_SP, 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_GAMEWORLD_SP, m_game_world_sp);
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_FXWORLD, m_fx_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_FONT, m_font);
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize);
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon);
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx);
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_STRINGTABLE, m_string_table);
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_TRACER, m_tracer);
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_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_GET_ASSET(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_GET_ASSET(ASSET_TYPE_XMODEL, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
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_VERTEXDECL, m_material_vertex_decl)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound)
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_CLIPMAP_SP, 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_GAMEWORLD_SP, m_game_world_sp)
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_FXWORLD, m_fx_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_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
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_STRINGTABLE, m_string_table)
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_TRACER, m_tracer)
CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
assert(false);
@ -308,9 +259,9 @@ XAssetInfoGeneric* GameAssetPoolIW4::GetAsset(const asset_type_t type, std::stri
#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_INVALID;

View File

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

View File

@ -57,114 +57,67 @@ const char* GameAssetPoolIW5::ASSET_TYPE_NAMES[]{
"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)
: ZoneAssetPools(zone),
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)
{
#define CASE_INIT_POOL_STATIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_STATIC(assetType, poolName) \
case assetType: \
{ \
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; \
}
switch (type)
{
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs, XModelSurfs);
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSWORLD, m_glass_world, GlassWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PATHDATA, m_path_data, PathData);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track, VehicleTrack);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment);
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table, SurfaceFxTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTFILE, m_script_file, ScriptFile);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet);
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef);
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
CASE_INIT_POOL_STATIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_STATIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_STATIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_PATHDATA, m_path_data)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_STATIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_INIT_POOL_STATIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_STATIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_STATIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_STATIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_STATIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_INIT_POOL_STATIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_STATIC(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_INIT_POOL_STATIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
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)
{
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName, poolType) \
#define CASE_INIT_POOL_DYNAMIC(assetType, poolName) \
case assetType: \
{ \
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; \
}
switch (type)
{
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset, PhysPreset);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap, PhysCollmap);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts, XAnimParts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs, XModelSurfs);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel, XModel);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material, Material);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, MaterialPixelShader);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, MaterialVertexShader);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, MaterialVertexDeclaration);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, MaterialTechniqueSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image, GfxImage);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound, snd_alias_list_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve, SndCurve);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, LoadedSound);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world, ComWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSWORLD, m_glass_world, GlassWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PATHDATA, m_path_data, PathData);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track, VehicleTrack);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents, MapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world, FxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world, GfxWorld);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, GfxLightDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font, Font_s);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list, MenuList);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def, menuDef_t);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, LocalizeEntry);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment, WeaponAttachment);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon, WeaponCompleteDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx, FxEffectDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, FxImpactTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table, SurfaceFxTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file, RawFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTFILE, m_script_file, ScriptFile);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table, StringTable);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard, LeaderboardDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, StructuredDataDefSet);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer, TracerDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle, VehicleDef);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, AddonMapEnts);
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_XMODEL, m_xmodel)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MATERIAL, m_material)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMAGE, m_image)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND, m_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_COMWORLD, m_com_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_PATHDATA, m_path_data)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FONT, m_font)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENULIST, m_menu_list)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_MENU, m_menu_def)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_WEAPON, m_weapon)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_FX, m_fx)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_TRACER, m_tracer)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_INIT_POOL_DYNAMIC(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
assert(type >= 0 && type < ASSET_TYPE_COUNT);
break;
}
#undef CASE_INIT_POOL_STATIC
#undef CASE_INIT_POOL_DYNAMIC
}
XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(
asset_type_t type, std::string name, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings, Zone* zone)
XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr<XAssetInfoGeneric> xAssetInfo)
{
XAsset xAsset{};
xAsset.type = static_cast<XAssetType>(type);
xAsset.header.data = asset;
#define CASE_ADD_TO_POOL(assetType, poolName, headerName) \
#define CASE_ADD_TO_POOL(assetType, poolName) \
case assetType: \
{ \
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_PHYSCOLLMAP, m_phys_collmap, physCollmap);
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts, parts);
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs, modelSurfs);
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel, model);
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material, material);
CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader, pixelShader);
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader, vertexShader);
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl, vertexDecl);
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set, techniqueSet);
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image, image);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound, sound);
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve, sndCurve);
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound, loadSnd);
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map, clipMap);
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world, comWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSWORLD, m_glass_world, glassWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_PATHDATA, m_path_data, pathData);
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track, vehicleTrack);
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents, mapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world, fxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world, gfxWorld);
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def, lightDef);
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font, font);
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list, menuList);
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def, menu);
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize, localize);
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment, attachment);
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon, weapon);
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx, fx);
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table, impactFx);
CASE_ADD_TO_POOL(ASSET_TYPE_SURFACE_FX, m_surface_fx_table, surfaceFx);
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file, rawfile);
CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTFILE, m_script_file, scriptfile);
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table, stringTable);
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard, leaderboardDef);
CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set, structuredDataDefSet);
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer, tracerDef);
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle, vehDef);
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents, addonMapEnts);
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSPRESET, m_phys_preset)
CASE_ADD_TO_POOL(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
CASE_ADD_TO_POOL(ASSET_TYPE_XANIMPARTS, m_xanim_parts)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL_SURFS, m_xmodel_surfs)
CASE_ADD_TO_POOL(ASSET_TYPE_XMODEL, m_xmodel)
CASE_ADD_TO_POOL(ASSET_TYPE_MATERIAL, m_material)
CASE_ADD_TO_POOL(ASSET_TYPE_PIXELSHADER, m_material_pixel_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXSHADER, m_material_vertex_shader)
CASE_ADD_TO_POOL(ASSET_TYPE_VERTEXDECL, m_material_vertex_decl)
CASE_ADD_TO_POOL(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_ADD_TO_POOL(ASSET_TYPE_IMAGE, m_image)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND, m_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_SOUND_CURVE, m_sound_curve)
CASE_ADD_TO_POOL(ASSET_TYPE_LOADED_SOUND, m_loaded_sound)
CASE_ADD_TO_POOL(ASSET_TYPE_CLIPMAP, m_clip_map)
CASE_ADD_TO_POOL(ASSET_TYPE_COMWORLD, m_com_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_ADD_TO_POOL(ASSET_TYPE_PATHDATA, m_path_data)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE_TRACK, m_vehicle_track)
CASE_ADD_TO_POOL(ASSET_TYPE_MAP_ENTS, m_map_ents)
CASE_ADD_TO_POOL(ASSET_TYPE_FXWORLD, m_fx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_GFXWORLD, m_gfx_world)
CASE_ADD_TO_POOL(ASSET_TYPE_LIGHT_DEF, m_gfx_light_def)
CASE_ADD_TO_POOL(ASSET_TYPE_FONT, m_font)
CASE_ADD_TO_POOL(ASSET_TYPE_MENULIST, m_menu_list)
CASE_ADD_TO_POOL(ASSET_TYPE_MENU, m_menu_def)
CASE_ADD_TO_POOL(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_ADD_TO_POOL(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_ADD_TO_POOL(ASSET_TYPE_WEAPON, m_weapon)
CASE_ADD_TO_POOL(ASSET_TYPE_FX, m_fx)
CASE_ADD_TO_POOL(ASSET_TYPE_IMPACT_FX, m_fx_impact_table)
CASE_ADD_TO_POOL(ASSET_TYPE_SURFACE_FX, m_surface_fx_table)
CASE_ADD_TO_POOL(ASSET_TYPE_RAWFILE, m_raw_file)
CASE_ADD_TO_POOL(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_ADD_TO_POOL(ASSET_TYPE_STRINGTABLE, m_string_table)
CASE_ADD_TO_POOL(ASSET_TYPE_LEADERBOARD, m_leaderboard)
CASE_ADD_TO_POOL(ASSET_TYPE_STRUCTURED_DATA_DEF, m_structed_data_def_set)
CASE_ADD_TO_POOL(ASSET_TYPE_TRACER, m_tracer)
CASE_ADD_TO_POOL(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_ADD_TO_POOL(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
assert(false);
@ -317,46 +265,46 @@ XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, std::stri
switch (type)
{
CASE_GET_ASSET(ASSET_TYPE_PHYSPRESET, m_phys_preset);
CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap);
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, m_xmodel);
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material);
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_VERTEXDECL, m_material_vertex_decl);
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set);
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image);
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound);
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_CLIPMAP, m_clip_map);
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world);
CASE_GET_ASSET(ASSET_TYPE_GLASSWORLD, m_glass_world);
CASE_GET_ASSET(ASSET_TYPE_PATHDATA, m_path_data);
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_FXWORLD, m_fx_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_FONT, m_font);
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list);
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def);
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize);
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment);
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon);
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx);
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_RAWFILE, m_raw_file);
CASE_GET_ASSET(ASSET_TYPE_SCRIPTFILE, m_script_file);
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table);
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_TRACER, m_tracer);
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_PHYSPRESET, m_phys_preset)
CASE_GET_ASSET(ASSET_TYPE_PHYSCOLLMAP, m_phys_collmap)
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, m_xmodel)
CASE_GET_ASSET(ASSET_TYPE_MATERIAL, m_material)
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_VERTEXDECL, m_material_vertex_decl)
CASE_GET_ASSET(ASSET_TYPE_TECHNIQUE_SET, m_technique_set)
CASE_GET_ASSET(ASSET_TYPE_IMAGE, m_image)
CASE_GET_ASSET(ASSET_TYPE_SOUND, m_sound)
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_CLIPMAP, m_clip_map)
CASE_GET_ASSET(ASSET_TYPE_COMWORLD, m_com_world)
CASE_GET_ASSET(ASSET_TYPE_GLASSWORLD, m_glass_world)
CASE_GET_ASSET(ASSET_TYPE_PATHDATA, m_path_data)
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_FXWORLD, m_fx_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_FONT, m_font)
CASE_GET_ASSET(ASSET_TYPE_MENULIST, m_menu_list)
CASE_GET_ASSET(ASSET_TYPE_MENU, m_menu_def)
CASE_GET_ASSET(ASSET_TYPE_LOCALIZE_ENTRY, m_localize)
CASE_GET_ASSET(ASSET_TYPE_ATTACHMENT, m_attachment)
CASE_GET_ASSET(ASSET_TYPE_WEAPON, m_weapon)
CASE_GET_ASSET(ASSET_TYPE_FX, m_fx)
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_RAWFILE, m_raw_file)
CASE_GET_ASSET(ASSET_TYPE_SCRIPTFILE, m_script_file)
CASE_GET_ASSET(ASSET_TYPE_STRINGTABLE, m_string_table)
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_TRACER, m_tracer)
CASE_GET_ASSET(ASSET_TYPE_VEHICLE, m_vehicle)
CASE_GET_ASSET(ASSET_TYPE_ADDON_MAP_ENTS, m_addon_map_ents)
default:
assert(false);
@ -368,9 +316,9 @@ XAssetInfoGeneric* GameAssetPoolIW5::GetAsset(const asset_type_t type, std::stri
#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_INVALID;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,6 +11,8 @@ class Zone;
template<typename T> class AssetPool
{
public:
using type = T;
std::map<std::string, XAssetInfo<T>*> m_asset_lookup;
class Iterator
@ -46,8 +48,7 @@ public:
virtual ~AssetPool() = default;
virtual XAssetInfo<T>*
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) = 0;
virtual XAssetInfo<T>* AddAsset(std::unique_ptr<XAssetInfo<T>> xAssetInfo) = 0;
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;
std::vector<XAssetInfo<T>*> m_assets;
std::vector<std::unique_ptr<XAssetInfo<T>>> m_assets;
asset_type_t m_type;
public:
@ -29,35 +29,27 @@ public:
{
GlobalAssetPool<T>::UnlinkAssetPool(this);
for (auto* entry : m_assets)
for (auto& entry : m_assets)
{
delete entry->Asset();
delete entry;
}
m_assets.clear();
m_asset_lookup.clear();
}
XAssetInfo<T>*
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override
XAssetInfo<T>* AddAsset(std::unique_ptr<XAssetInfo<T>> xAssetInfo) 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();
memcpy(newAsset, asset, sizeof(T));
newInfo->m_ptr = newAsset;
memcpy(newAsset, xAssetInfo->Asset(), sizeof(T));
xAssetInfo->m_ptr = newAsset;
m_assets.push_back(newInfo);
m_asset_lookup[newInfo->m_name] = newInfo;
auto* pAssetInfo = xAssetInfo.get();
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
{
if (m_capacity > 0)
{
GlobalAssetPool<T>::UnlinkAssetPool(this);
}
delete[] m_pool;
m_pool = nullptr;
@ -81,25 +79,19 @@ public:
m_capacity = 0;
}
XAssetInfo<T>*
AddAsset(std::string name, T* asset, Zone* zone, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override
XAssetInfo<T>* AddAsset(std::unique_ptr<XAssetInfo<T>> xAssetInfo) override
{
if (m_free == nullptr)
{
throw std::runtime_error("Could not add asset to static asset pool: capacity exhausted.");
}
AssetPoolEntry* poolSlot = m_free;
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->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);
*poolSlot->m_info = std::move(*xAssetInfo);
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;
// 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
{
public:
asset_type_t m_type = -1;
asset_type_t m_type;
std::string m_name;
Zone* m_zone;
void* m_ptr;
std::vector<XAssetInfoGeneric*> m_dependencies;
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
{
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()
{
return static_cast<T*>(m_ptr);

View File

@ -5,24 +5,22 @@ 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,
std::string name,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
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>(
type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences), m_zone));
}
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;
}

View File

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

View File

@ -10,10 +10,14 @@ AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStr
{
}
XAssetInfoGeneric*
AssetLoader::LinkAsset(std::string name, void* asset, std::vector<scr_string_t> scriptStrings, std::vector<XAssetInfoGeneric*> dependencies) const
XAssetInfoGeneric* AssetLoader::LinkAsset(std::string name,
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

View File

@ -16,7 +16,11 @@ protected:
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;
};

View File

@ -39,6 +39,22 @@ void AssetMarker::MarkArray_ScriptString(const scr_string_t* scrStringArray, con
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
{
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;
}
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<scr_string_t> m_used_script_strings;
std::unordered_set<IndirectAssetReference> m_indirect_asset_references;
protected:
AssetMarker(asset_type_t assetType, Zone* zone);
@ -22,6 +23,9 @@ protected:
void Mark_ScriptString(scr_string_t scrString);
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;
Zone* m_zone;
@ -29,4 +33,5 @@ protected:
public:
_NODISCARD std::vector<XAssetInfoGeneric*> GetDependencies() 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();
}
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,
const std::string& assetName,
void* asset,
std::vector<XAssetInfoGeneric*> dependencies,
std::vector<scr_string_t> usedScriptStrings)
{
XAssetInfoGeneric assetInfoObj{assetType, assetName, m_zone, std::move(dependencies), std::move(usedScriptStrings), asset};
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 AddAsset(std::make_unique<XAssetInfoGeneric>(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings)));
}
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)
@ -41,11 +55,15 @@ XAssetInfoGeneric* MockAssetLoadingManager::LoadDependency(const asset_type_t as
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)
{
XAssetInfoGeneric assetInfoObj{assetType, std::move(assetName), m_zone, std::vector<XAssetInfoGeneric*>(), std::vector<scr_string_t>(), asset};
auto assetInfo = std::make_unique<XAssetInfoGeneric>(std::move(assetInfoObj));
m_available_dependencies.emplace(std::make_pair(assetInfo->m_name, std::move(assetInfo)));
auto assetInfo = std::make_unique<XAssetInfoGeneric>(assetType, std::move(assetName), asset);
m_available_dependencies.emplace(assetInfo->m_name, std::move(assetInfo));
}
XAssetInfoGeneric* MockAssetLoadingManager::MockGetAddedAsset(const std::string& assetName)

View File

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