diff --git a/src/Common/Game/T6/T6.h b/src/Common/Game/T6/T6.h index 24e55e2a..0837344a 100644 --- a/src/Common/Game/T6/T6.h +++ b/src/Common/Game/T6/T6.h @@ -98,6 +98,9 @@ namespace T6 WFT_ATTACHMENTS, WFT_ATTACHMENT_UNIQUES, + // Custom + WFT_ANIM_NAME, + WFT_NUM_FIELD_TYPES }; diff --git a/src/Linker/Game/T6/ZoneCreatorT6.cpp b/src/Linker/Game/T6/ZoneCreatorT6.cpp index 9b70c5f7..6a6c4ec1 100644 --- a/src/Linker/Game/T6/ZoneCreatorT6.cpp +++ b/src/Linker/Game/T6/ZoneCreatorT6.cpp @@ -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(), std::vector()); + zone->m_pools->AddAsset(std::make_unique>(ASSET_TYPE_KEYVALUEPAIRS, zone->m_name, kvps)); } } diff --git a/src/ObjCommon/Game/T6/InfoString/WeaponFields.h b/src/ObjCommon/Game/T6/InfoString/WeaponFields.h index 0ae5b90d..cb8f4757 100644 --- a/src/ObjCommon/Game/T6/InfoString/WeaponFields.h +++ b/src/ObjCommon/Game/T6/InfoString/WeaponFields.h @@ -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 }, diff --git a/src/ObjLoading/AssetLoading/AssetLoadingManager.cpp b/src/ObjLoading/AssetLoading/AssetLoadingManager.cpp index 371239e9..83a350ed 100644 --- a/src/ObjLoading/AssetLoading/AssetLoadingManager.cpp +++ b/src/ObjLoading/AssetLoading/AssetLoadingManager.cpp @@ -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 dependencies, - std::vector usedScriptStrings, - Zone* zone) +XAssetInfoGeneric* AssetLoadingManager::AddAssetInternal(std::unique_ptr 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 dependencies, std::vector 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(assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings))); +} + +XAssetInfoGeneric* AssetLoadingManager::AddAsset(asset_type_t assetType, + const std::string& assetName, + void* asset, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector indirectAssetReferences) +{ + return AddAsset(std::make_unique( + assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences))); +} + +XAssetInfoGeneric* AssetLoadingManager::AddAsset(std::unique_ptr 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 dependencies; - AddAsset(existingAsset->m_type, - existingAsset->m_name, - existingAsset->m_ptr, - std::vector(), - std::vector(), - existingAsset->m_zone); + AddAssetInternal(std::make_unique(*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 dependencies; + std::vector 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(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); +} diff --git a/src/ObjLoading/AssetLoading/AssetLoadingManager.h b/src/ObjLoading/AssetLoading/AssetLoadingManager.h index aaa1380e..23fac1f0 100644 --- a/src/ObjLoading/AssetLoading/AssetLoadingManager.h +++ b/src/ObjLoading/AssetLoading/AssetLoadingManager.h @@ -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 dependencies, - std::vector usedScriptStrings, - Zone* zone); + XAssetInfoGeneric* AddAssetInternal(std::unique_ptr xAssetInfo); public: AssetLoadingManager(const std::map>& assetLoadersByType, AssetLoadingContext& context); @@ -33,5 +28,13 @@ public: void* asset, std::vector dependencies, std::vector usedScriptStrings) override; + XAssetInfoGeneric* AddAsset(asset_type_t assetType, + const std::string& assetName, + void* asset, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector indirectAssetReferences) override; + XAssetInfoGeneric* AddAsset(std::unique_ptr xAssetInfo) override; XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) override; + IndirectAssetReference LoadIndirectAssetReference(asset_type_t assetType, const std::string& assetName) override; }; diff --git a/src/ObjLoading/AssetLoading/IAssetLoadingManager.h b/src/ObjLoading/AssetLoading/IAssetLoadingManager.h index 65d0bc70..aa6f1dcb 100644 --- a/src/ObjLoading/AssetLoading/IAssetLoadingManager.h +++ b/src/ObjLoading/AssetLoading/IAssetLoadingManager.h @@ -23,6 +23,13 @@ public: void* asset, std::vector dependencies, std::vector usedScriptStrings) = 0; + virtual XAssetInfoGeneric* AddAsset(asset_type_t assetType, + const std::string& assetName, + void* asset, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector indirectAssetReferences) = 0; + virtual XAssetInfoGeneric* AddAsset(std::unique_ptr 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; }; diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp index 88c950a1..b9491f58 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderWeapon.cpp @@ -227,7 +227,7 @@ namespace T6 { std::cout << "Cannot have more than " << (std::extent_v - std::extent_v) - << " combined attachment attachment unique entries!" << std::endl; + << " combined attachment attachment unique entries!\n"; return false; } @@ -239,15 +239,14 @@ namespace T6 if (static_cast(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; } diff --git a/src/ObjLoading/InfoString/InfoStringToStructConverterBase.cpp b/src/ObjLoading/InfoString/InfoStringToStructConverterBase.cpp index d9d5fb0c..d79c8ef4 100644 --- a/src/ObjLoading/InfoString/InfoStringToStructConverterBase.cpp +++ b/src/ObjLoading/InfoString/InfoStringToStructConverterBase.cpp @@ -41,7 +41,7 @@ bool InfoStringToStructConverterBase::ParseAsArray(const std::string& value, std return true; } -bool InfoStringToStructConverterBase::ParseAsPairs(const std::string& value, std::vector>& valueArray) const +bool InfoStringToStructConverterBase::ParseAsPairs(const std::string& value, std::vector>& valueArray) { std::string key; auto isKey = true; @@ -227,6 +227,7 @@ bool InfoStringToStructConverterBase::ConvertEnumInt(const std::string& value, c std::vector InfoStringToStructConverterBase::GetUsedScriptStrings() const { std::vector 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 InfoStringToStructConverterBase::GetUsedScriptStrings( std::vector InfoStringToStructConverterBase::GetDependencies() const { std::vector dependencyList; + dependencyList.reserve(m_dependencies.size()); for (auto* dependency : m_dependencies) { dependencyList.push_back(dependency); @@ -245,3 +247,15 @@ std::vector InfoStringToStructConverterBase::GetDependencies return dependencyList; } + +std::vector InfoStringToStructConverterBase::GetIndirectAssetReferences() const +{ + std::vector indirectAssetReferences; + indirectAssetReferences.reserve(m_indirect_asset_references.size()); + for (auto& assetReference : m_indirect_asset_references) + { + indirectAssetReferences.emplace_back(assetReference); + } + + return indirectAssetReferences; +} diff --git a/src/ObjLoading/InfoString/InfoStringToStructConverterBase.h b/src/ObjLoading/InfoString/InfoStringToStructConverterBase.h index d544127a..8d74fcdc 100644 --- a/src/ObjLoading/InfoString/InfoStringToStructConverterBase.h +++ b/src/ObjLoading/InfoString/InfoStringToStructConverterBase.h @@ -17,11 +17,12 @@ protected: ZoneScriptStrings& m_zone_script_strings; std::unordered_set m_used_script_string_list; std::unordered_set m_dependencies; + std::unordered_set m_indirect_asset_references; MemoryManager* m_memory; void* m_structure; static bool ParseAsArray(const std::string& value, std::vector& valueArray); - bool ParseAsPairs(const std::string& value, std::vector>& valueArray) const; + static bool ParseAsPairs(const std::string& value, std::vector>& 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 GetUsedScriptStrings() const; _NODISCARD std::vector GetDependencies() const; + _NODISCARD std::vector GetIndirectAssetReferences() const; }; diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp index 7c76d914..40803c60 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperWeapon.cpp @@ -22,50 +22,50 @@ namespace T6 switch (static_cast(field.iFieldType)) { case WFT_WEAPONTYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapTypeNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapTypeNames, std::extent_v); break; case WFT_WEAPONCLASS: - FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClassNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClassNames, std::extent_v); break; case WFT_OVERLAYRETICLE: - FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapOverlayReticleNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapOverlayReticleNames, std::extent_v); break; case WFT_PENETRATE_TYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, penetrateTypeNames, std::extent_v); break; case WFT_IMPACT_TYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, impactTypeNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, impactTypeNames, std::extent_v); break; case WFT_STANCE: - FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapStanceNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapStanceNames, std::extent_v); break; case WFT_PROJ_EXPLOSION: - FillFromEnumInt(std::string(field.szName), field.iOffset, szProjectileExplosionNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, szProjectileExplosionNames, std::extent_v); break; case WFT_OFFHAND_CLASS: - FillFromEnumInt(std::string(field.szName), field.iOffset, offhandClassNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, offhandClassNames, std::extent_v); break; case WFT_OFFHAND_SLOT: - FillFromEnumInt(std::string(field.szName), field.iOffset, offhandSlotNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, offhandSlotNames, std::extent_v); break; case WFT_ANIMTYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, playerAnimTypeNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, playerAnimTypeNames, std::extent_v); break; case WFT_ACTIVE_RETICLE_TYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, activeReticleNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, activeReticleNames, std::extent_v); break; case WFT_GUIDED_MISSILE_TYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, guidedMissileNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, guidedMissileNames, std::extent_v); break; case WFT_BOUNCE_SOUND: @@ -92,31 +92,31 @@ namespace T6 } case WFT_STICKINESS: - FillFromEnumInt(std::string(field.szName), field.iOffset, stickinessNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, stickinessNames, std::extent_v); break; case WFT_ROTATETYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, rotateTypeNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, rotateTypeNames, std::extent_v); break; case WFT_OVERLAYINTERFACE: - FillFromEnumInt(std::string(field.szName), field.iOffset, overlayInterfaceNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, overlayInterfaceNames, std::extent_v); break; case WFT_INVENTORYTYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapInventoryTypeNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapInventoryTypeNames, std::extent_v); break; case WFT_FIRETYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapFireTypeNames, std::extent_v); break; case WFT_CLIPTYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClipTypeNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, szWeapClipTypeNames, std::extent_v); break; case WFT_AMMOCOUNTER_CLIPTYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, ammoCounterClipNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, ammoCounterClipNames, std::extent_v); 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::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, weapIconRatioNames, std::extent_v); break; case WFT_BARRELTYPE: - FillFromEnumInt(std::string(field.szName), field.iOffset, barrelTypeNames, std::extent::value); + FillFromEnumInt(std::string(field.szName), field.iOffset, barrelTypeNames, std::extent_v); break; case WFT_HIDETAGS: @@ -137,7 +137,7 @@ namespace T6 std::stringstream ss; bool first = true; - for (auto i = 0u; i < std::extent::value; i++) + for (auto i = 0u; i < std::extent_v; 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(reinterpret_cast(m_structure) + field.iOffset); - const auto* values = &keys[std::extent::value]; + const auto* values = &keys[std::extent_v]; std::stringstream ss; bool first = true; - for (auto i = 0u; i < std::extent::value; i++) + for (auto i = 0u; i < std::extent_v; 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::value; i++) + for (auto i = 0u; i < std::extent_v; i++) { if (attachments[i]) { @@ -227,7 +227,7 @@ namespace T6 std::stringstream ss; auto first = true; - for (auto i = 0u; i < std::extent::value; i++) + for (auto i = 0u; i < std::extent_v; 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::value); - memcpy(fullDef->attachments, weapon->attachments, sizeof(void*) * std::extent::value); + memcpy(fullDef->attachments, weapon->attachments, sizeof(void*) * std::extent_v); fullDef->weapVariantDef.attachments = fullDef->attachments; } if (weapon->attachmentUniques) { assert(sizeof(WeaponFullDef::attachmentUniques) >= sizeof(void*) * std::extent::value); - memcpy(fullDef->attachmentUniques, weapon->attachmentUniques, sizeof(void*) * std::extent::value); + memcpy(fullDef->attachmentUniques, weapon->attachmentUniques, sizeof(void*) * std::extent_v); fullDef->weapVariantDef.attachmentUniques = fullDef->attachmentUniques; } if (fullDef->weapDef.gunXModel) { assert(sizeof(WeaponFullDef::gunXModel) >= sizeof(void*) * std::extent::value); - memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent::value); + memcpy(fullDef->gunXModel, fullDef->weapDef.gunXModel, sizeof(void*) * std::extent_v); 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::value); - memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent::value); + memcpy(fullDef->hideTags, weapon->hideTags, sizeof(scr_string_t) * std::extent_v); 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::value); memcpy(fullDef->notetrackSoundMapKeys, fullDef->weapDef.notetrackSoundMapKeys, - sizeof(scr_string_t) * std::extent::value); + sizeof(scr_string_t) * std::extent_v); 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::value); memcpy(fullDef->notetrackSoundMapValues, fullDef->weapDef.notetrackSoundMapValues, - sizeof(scr_string_t) * std::extent::value); + sizeof(scr_string_t) * std::extent_v); fullDef->weapDef.notetrackSoundMapValues = fullDef->notetrackSoundMapValues; } if (fullDef->weapDef.worldModel) { assert(sizeof(WeaponFullDef::worldModel) >= sizeof(void*) * std::extent::value); - memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent::value); + memcpy(fullDef->worldModel, fullDef->weapDef.worldModel, sizeof(void*) * std::extent_v); fullDef->weapDef.worldModel = fullDef->worldModel; } if (weapon->attachViewModel) { assert(sizeof(WeaponFullDef::attachViewModel) >= sizeof(void*) * std::extent::value); - memcpy(fullDef->attachViewModel, weapon->attachViewModel, sizeof(void*) * std::extent::value); + memcpy(fullDef->attachViewModel, weapon->attachViewModel, sizeof(void*) * std::extent_v); fullDef->weapVariantDef.attachViewModel = fullDef->attachViewModel; } if (weapon->attachWorldModel) { assert(sizeof(WeaponFullDef::attachWorldModel) >= sizeof(void*) * std::extent::value); - memcpy(fullDef->attachWorldModel, weapon->attachWorldModel, sizeof(void*) * std::extent::value); + memcpy(fullDef->attachWorldModel, weapon->attachWorldModel, sizeof(void*) * std::extent_v); fullDef->weapVariantDef.attachWorldModel = fullDef->attachWorldModel; } if (weapon->attachViewModelTag) { assert(sizeof(WeaponFullDef::attachViewModelTag) >= sizeof(void*) * std::extent::value); - memcpy(fullDef->attachViewModelTag, weapon->attachViewModelTag, sizeof(void*) * std::extent::value); + memcpy(fullDef->attachViewModelTag, weapon->attachViewModelTag, sizeof(void*) * std::extent_v); fullDef->weapVariantDef.attachViewModelTag = fullDef->attachViewModelTag; } if (weapon->attachWorldModelTag) { assert(sizeof(WeaponFullDef::attachWorldModelTag) >= sizeof(void*) * std::extent::value); - memcpy(fullDef->attachWorldModelTag, weapon->attachWorldModelTag, sizeof(void*) * std::extent::value); + memcpy(fullDef->attachWorldModelTag, weapon->attachWorldModelTag, sizeof(void*) * std::extent_v); 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::value); + strncpy(fullDef->weaponCamo, fullDef->weapDef.weaponCamo->name, std::extent_v); } } @@ -394,7 +398,7 @@ InfoString AssetDumperWeapon::CreateInfoString(XAssetInfo* ass InfoStringFromWeaponConverter converter(fullDef.get(), weapon_fields, - std::extent::value, + std::extent_v, [asset](const scr_string_t scrStr) -> std::string { assert(scrStr < asset->m_zone->m_script_strings.Count()); diff --git a/src/ZoneCode/Game/IW3/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/IW3/XAssets/FxEffectDef.txt index 9698c3d0..93875b29 100644 --- a/src/ZoneCode/Game/IW3/XAssets/FxEffectDef.txt +++ b/src/ZoneCode/Game/IW3/XAssets/FxEffectDef.txt @@ -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; diff --git a/src/ZoneCode/Game/IW3/XAssets/WeaponDef.txt b/src/ZoneCode/Game/IW3/XAssets/WeaponDef.txt index 2a276d2c..8b4d4a9a 100644 --- a/src/ZoneCode/Game/IW3/XAssets/WeaponDef.txt +++ b/src/ZoneCode/Game/IW3/XAssets/WeaponDef.txt @@ -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; diff --git a/src/ZoneCode/Game/IW4/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/IW4/XAssets/FxEffectDef.txt index 261df4c7..1c89cf80 100644 --- a/src/ZoneCode/Game/IW4/XAssets/FxEffectDef.txt +++ b/src/ZoneCode/Game/IW4/XAssets/FxEffectDef.txt @@ -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; diff --git a/src/ZoneCode/Game/IW4/XAssets/WeaponCompleteDef.txt b/src/ZoneCode/Game/IW4/XAssets/WeaponCompleteDef.txt index d55ed68f..17164c84 100644 --- a/src/ZoneCode/Game/IW4/XAssets/WeaponCompleteDef.txt +++ b/src/ZoneCode/Game/IW4/XAssets/WeaponCompleteDef.txt @@ -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; diff --git a/src/ZoneCode/Game/IW5/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/IW5/XAssets/FxEffectDef.txt index ceeca471..4748a515 100644 --- a/src/ZoneCode/Game/IW5/XAssets/FxEffectDef.txt +++ b/src/ZoneCode/Game/IW5/XAssets/FxEffectDef.txt @@ -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; diff --git a/src/ZoneCode/Game/IW5/XAssets/WeaponCompleteDef.txt b/src/ZoneCode/Game/IW5/XAssets/WeaponCompleteDef.txt index ca209224..7d37e025 100644 --- a/src/ZoneCode/Game/IW5/XAssets/WeaponCompleteDef.txt +++ b/src/ZoneCode/Game/IW5/XAssets/WeaponCompleteDef.txt @@ -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; diff --git a/src/ZoneCode/Game/T5/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/T5/XAssets/FxEffectDef.txt index a7a32ce5..9a48c1fa 100644 --- a/src/ZoneCode/Game/T5/XAssets/FxEffectDef.txt +++ b/src/ZoneCode/Game/T5/XAssets/FxEffectDef.txt @@ -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; diff --git a/src/ZoneCode/Game/T5/XAssets/WeaponVariantDef.txt b/src/ZoneCode/Game/T5/XAssets/WeaponVariantDef.txt index 295c08b1..6a3899d6 100644 --- a/src/ZoneCode/Game/T5/XAssets/WeaponVariantDef.txt +++ b/src/ZoneCode/Game/T5/XAssets/WeaponVariantDef.txt @@ -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; diff --git a/src/ZoneCode/Game/T6/XAssets/FxEffectDef.txt b/src/ZoneCode/Game/T6/XAssets/FxEffectDef.txt index 569379af..57043d46 100644 --- a/src/ZoneCode/Game/T6/XAssets/FxEffectDef.txt +++ b/src/ZoneCode/Game/T6/XAssets/FxEffectDef.txt @@ -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; diff --git a/src/ZoneCode/Game/T6/XAssets/WeaponVariantDef.txt b/src/ZoneCode/Game/T6/XAssets/WeaponVariantDef.txt index 4778378c..590bbb7c 100644 --- a/src/ZoneCode/Game/T6/XAssets/WeaponVariantDef.txt +++ b/src/ZoneCode/Game/T6/XAssets/WeaponVariantDef.txt @@ -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; diff --git a/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.cpp b/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.cpp index a19fc05c..ab4b5323 100644 --- a/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.cpp +++ b/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.cpp @@ -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) { } diff --git a/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.h b/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.h index 1c93235a..ee421c35 100644 --- a/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.h +++ b/src/ZoneCodeGeneratorLib/Domain/Information/MemberInformation.h @@ -23,6 +23,7 @@ public: std::unique_ptr m_condition; std::unique_ptr m_alloc_alignment; const FastFileBlock* m_fast_file_block; + const EnumMember* m_asset_ref; MemberInformation(StructureInformation* parent, StructureInformation* type, Variable* member); }; diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp index 7866f580..ce5c3b5a 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp @@ -1075,7 +1075,8 @@ class ZoneLoadTemplate::Internal final : BaseTemplate LINE("marker.Mark(*pAsset);") LINE("") LINE("m_asset_info = reinterpret_castm_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--; diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp index 45eacaa6..ae5b8c39 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp @@ -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(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); diff --git a/src/ZoneCodeGeneratorLib/Parsing/Commands/Impl/CommandsParser.cpp b/src/ZoneCodeGeneratorLib/Parsing/Commands/Impl/CommandsParser.cpp index f86e1f8f..617d2ca6 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Commands/Impl/CommandsParser.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Commands/Impl/CommandsParser.cpp @@ -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::GetTestsForState new SequenceArrayCount(), new SequenceArraySize(), new SequenceAsset(), + new SequenceAssetRef(), new SequenceBlock(), new SequenceCondition(), new SequenceCount(), diff --git a/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAssetRef.cpp b/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAssetRef.cpp new file mode 100644 index 00000000..e15512e2 --- /dev/null +++ b/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAssetRef.cpp @@ -0,0 +1,72 @@ +#include "SequenceAssetRef.h" + +#include "Parsing/Commands/Matcher/CommandsCommonMatchers.h" +#include "Parsing/Commands/Matcher/CommandsMatcherFactory.h" + +#include + +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& 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 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& modifier) + { + return modifier->GetType() == DeclarationModifierType::POINTER; + }); + } + + if (typeDecl->m_type->GetType() == DataDefinitionType::TYPEDEF) + { + const auto* typedefDef = dynamic_cast(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; +} diff --git a/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAssetRef.h b/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAssetRef.h new file mode 100644 index 00000000..1feeffbf --- /dev/null +++ b/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAssetRef.h @@ -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& result) const override; + +public: + SequenceAssetRef(); +}; diff --git a/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/MarkingRequiredPostProcessor.cpp b/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/MarkingRequiredPostProcessor.cpp index 439b41ff..1eeb9fbd 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/MarkingRequiredPostProcessor.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/MarkingRequiredPostProcessor.cpp @@ -44,8 +44,8 @@ bool MarkingRequiredPostProcessor::CalculateRequiresMarking(std::unordered_setm_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; diff --git a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp index d802128d..fe986855 100644 --- a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp +++ b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.cpp @@ -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::value == ASSET_TYPE_COUNT); + static_assert(std::extent_v == 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>(capacity, m_priority, (assetType)); \ + (poolName) = std::make_unique>(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>(m_priority, (assetType)); \ + (poolName) = std::make_unique>(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 dependencies, std::vector usedScriptStrings, Zone* zone) +XAssetInfoGeneric* GameAssetPoolIW3::AddAssetToPool(std::unique_ptr xAssetInfo) { - XAsset xAsset{}; - - xAsset.type = static_cast(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>( \ + static_cast*>(xAssetInfo.release()))); \ } - switch (xAsset.type) + switch (static_cast(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(std::extent::value)) + if (assetType >= 0 && assetType < static_cast(std::extent_v)) return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_INVALID; diff --git a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h index 40e7c82f..a75a4037 100644 --- a/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h +++ b/src/ZoneCommon/Game/IW3/GameAssetPoolIW3.h @@ -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 dependencies, - std::vector usedScriptStrings, - Zone* zone) override; + XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; public: std::unique_ptr> m_phys_preset; diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp index 5ddea61d..8bc5cfbe 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.cpp @@ -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::value == ASSET_TYPE_COUNT); + assert(std::extent_v == 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>(capacity, m_priority, (assetType)); \ + (poolName) = std::make_unique>(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>(m_priority, (assetType)); \ + (poolName) = std::make_unique>(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 dependencies, std::vector usedScriptStrings, Zone* zone) +XAssetInfoGeneric* GameAssetPoolIW4::AddAssetToPool(std::unique_ptr xAssetInfo) { - XAsset xAsset{}; - - xAsset.type = static_cast(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>( \ + static_cast*>(xAssetInfo.release()))); \ } - switch (xAsset.type) + switch (static_cast(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(std::extent::value)) + if (assetType >= 0 && assetType < static_cast(std::extent_v)) return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_INVALID; diff --git a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h index 90d70ff5..3889db03 100644 --- a/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h +++ b/src/ZoneCommon/Game/IW4/GameAssetPoolIW4.h @@ -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 dependencies, - std::vector usedScriptStrings, - Zone* zone) override; + XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; public: std::unique_ptr> m_phys_preset; diff --git a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp index 673c9a7a..d641fa54 100644 --- a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp +++ b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.cpp @@ -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::value == ASSET_TYPE_COUNT); + assert(std::extent_v == 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>(capacity, m_priority, (assetType)); \ + (poolName) = std::make_unique>(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>(m_priority, (assetType)); \ + (poolName) = std::make_unique>(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 dependencies, std::vector usedScriptStrings, Zone* zone) +XAssetInfoGeneric* GameAssetPoolIW5::AddAssetToPool(std::unique_ptr xAssetInfo) { - XAsset xAsset{}; - - xAsset.type = static_cast(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>( \ + static_cast*>(xAssetInfo.release()))); \ } - switch (xAsset.type) + switch (static_cast(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(std::extent::value)) + if (assetType >= 0 && assetType < static_cast(std::extent_v)) return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_INVALID; diff --git a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h index 435bc833..407f028c 100644 --- a/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h +++ b/src/ZoneCommon/Game/IW5/GameAssetPoolIW5.h @@ -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 dependencies, - std::vector usedScriptStrings, - Zone* zone) override; + XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; public: std::unique_ptr> m_phys_preset; diff --git a/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp b/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp index b5e6effa..505a7e21 100644 --- a/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp +++ b/src/ZoneCommon/Game/T5/GameAssetPoolT5.cpp @@ -22,56 +22,56 @@ GameAssetPoolT5::GameAssetPoolT5(Zone* zone, const int priority) : ZoneAssetPools(zone), m_priority(priority) { - assert(std::extent::value == ASSET_TYPE_COUNT); + assert(std::extent_v == 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>(capacity, m_priority, (assetType)); \ + (poolName) = std::make_unique>(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>(m_priority, (assetType)); \ + (poolName) = std::make_unique>(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 dependencies, std::vector usedScriptStrings, Zone* zone) +XAssetInfoGeneric* GameAssetPoolT5::AddAssetToPool(std::unique_ptr xAssetInfo) { - XAsset xAsset{}; - - xAsset.type = static_cast(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>( \ + static_cast*>(xAssetInfo.release()))); \ } - switch (xAsset.type) + switch (static_cast(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(std::extent::value)) + if (assetType >= 0 && assetType < static_cast(std::extent_v)) return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_INVALID; diff --git a/src/ZoneCommon/Game/T5/GameAssetPoolT5.h b/src/ZoneCommon/Game/T5/GameAssetPoolT5.h index 29b4306a..77fcd019 100644 --- a/src/ZoneCommon/Game/T5/GameAssetPoolT5.h +++ b/src/ZoneCommon/Game/T5/GameAssetPoolT5.h @@ -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 dependencies, - std::vector usedScriptStrings, - Zone* zone) override; + XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; public: std::unique_ptr> m_phys_preset; diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp index 300cab7d..3c750292 100644 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp +++ b/src/ZoneCommon/Game/T6/GameAssetPoolT6.cpp @@ -75,72 +75,72 @@ GameAssetPoolT6::GameAssetPoolT6(Zone* zone, const int priority) : ZoneAssetPools(zone), m_priority(priority) { - assert(std::extent::value == ASSET_TYPE_COUNT); + assert(std::extent_v == 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>(capacity, m_priority, (assetType)); \ + (poolName) = std::make_unique>(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>(m_priority, (assetType)); \ + (poolName) = std::make_unique>(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 dependencies, std::vector usedScriptStrings, Zone* zone) +XAssetInfoGeneric* GameAssetPoolT6::AddAssetToPool(std::unique_ptr xAssetInfo) { - XAsset xAsset{}; - - xAsset.type = static_cast(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>( \ + static_cast*>(xAssetInfo.release()))); \ } - switch (xAsset.type) + switch (static_cast(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(std::extent::value)) + if (assetType >= 0 && assetType < static_cast(std::extent_v)) return ASSET_TYPE_NAMES[assetType]; return ASSET_TYPE_INVALID; diff --git a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h index 891a43aa..7ea69875 100644 --- a/src/ZoneCommon/Game/T6/GameAssetPoolT6.h +++ b/src/ZoneCommon/Game/T6/GameAssetPoolT6.h @@ -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 dependencies, - std::vector usedScriptStrings, - Zone* zone) override; + XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) override; public: std::unique_ptr> m_phys_preset; diff --git a/src/ZoneCommon/Pool/AssetPool.h b/src/ZoneCommon/Pool/AssetPool.h index a19f9026..43e5a780 100644 --- a/src/ZoneCommon/Pool/AssetPool.h +++ b/src/ZoneCommon/Pool/AssetPool.h @@ -11,6 +11,8 @@ class Zone; template class AssetPool { public: + using type = T; + std::map*> m_asset_lookup; class Iterator @@ -46,8 +48,7 @@ public: virtual ~AssetPool() = default; - virtual XAssetInfo* - AddAsset(std::string name, T* asset, Zone* zone, std::vector dependencies, std::vector usedScriptStrings) = 0; + virtual XAssetInfo* AddAsset(std::unique_ptr> xAssetInfo) = 0; XAssetInfo* GetAsset(const std::string& name) { diff --git a/src/ZoneCommon/Pool/AssetPoolDynamic.h b/src/ZoneCommon/Pool/AssetPoolDynamic.h index c8a642f4..d6f79d88 100644 --- a/src/ZoneCommon/Pool/AssetPoolDynamic.h +++ b/src/ZoneCommon/Pool/AssetPoolDynamic.h @@ -10,7 +10,7 @@ template class AssetPoolDynamic final : public AssetPool { using AssetPool::m_asset_lookup; - std::vector*> m_assets; + std::vector>> m_assets; asset_type_t m_type; public: @@ -29,35 +29,27 @@ public: { GlobalAssetPool::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* - AddAsset(std::string name, T* asset, Zone* zone, std::vector dependencies, std::vector usedScriptStrings) override + XAssetInfo* AddAsset(std::unique_ptr> xAssetInfo) override { - auto* newInfo = new XAssetInfo(); - 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::LinkAsset(this, newInfo); + GlobalAssetPool::LinkAsset(this, pAssetInfo); - return newInfo; + return pAssetInfo; } }; diff --git a/src/ZoneCommon/Pool/AssetPoolStatic.h b/src/ZoneCommon/Pool/AssetPoolStatic.h index 5151cfd4..bf9b3bb8 100644 --- a/src/ZoneCommon/Pool/AssetPoolStatic.h +++ b/src/ZoneCommon/Pool/AssetPoolStatic.h @@ -67,9 +67,7 @@ public: ~AssetPoolStatic() override { if (m_capacity > 0) - { GlobalAssetPool::UnlinkAssetPool(this); - } delete[] m_pool; m_pool = nullptr; @@ -81,25 +79,19 @@ public: m_capacity = 0; } - XAssetInfo* - AddAsset(std::string name, T* asset, Zone* zone, std::vector dependencies, std::vector usedScriptStrings) override + XAssetInfo* AddAsset(std::unique_ptr> 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(&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; diff --git a/src/ZoneCommon/Pool/XAssetInfo.cpp b/src/ZoneCommon/Pool/XAssetInfo.cpp new file mode 100644 index 00000000..c208db10 --- /dev/null +++ b/src/ZoneCommon/Pool/XAssetInfo.cpp @@ -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::operator()(const IndirectAssetReference& v) const noexcept +{ + std::size_t seed = 0x01A627D3; + seed ^= (seed << 6) + (seed >> 2) + 0x0BCEF9CE + static_cast(v.m_type); + seed ^= (seed << 6) + (seed >> 2) + 0x7225148B + std::hash()(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 dependencies, std::vector 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 dependencies, + std::vector usedScriptStrings, + std::vector 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 dependencies, + std::vector usedScriptStrings, + std::vector 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) +{ +} diff --git a/src/ZoneCommon/Pool/XAssetInfo.h b/src/ZoneCommon/Pool/XAssetInfo.h index 59aa3e1d..788fb8cb 100644 --- a/src/ZoneCommon/Pool/XAssetInfo.h +++ b/src/ZoneCommon/Pool/XAssetInfo.h @@ -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 +{ + 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 m_dependencies; std::vector m_used_script_strings; - void* m_ptr; + std::vector 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 dependencies, std::vector usedScriptStrings); + XAssetInfoGeneric(asset_type_t type, + std::string name, + void* ptr, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector indirectAssetReferences); + XAssetInfoGeneric(asset_type_t type, + std::string name, + void* ptr, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector 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 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(ptr)) + { + } + + XAssetInfo(const asset_type_t type, std::string name, T* ptr, std::vector dependencies, std::vector usedScriptStrings) + : XAssetInfoGeneric(type, std::move(name), static_cast(ptr), std::move(dependencies), std::move(usedScriptStrings)) + { + } + + XAssetInfo(const asset_type_t type, + std::string name, + T* ptr, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector indirectAssetReferences) + : XAssetInfoGeneric( + type, std::move(name), static_cast(ptr), std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences)) + { + } + + XAssetInfo(const asset_type_t type, + std::string name, + T* ptr, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector indirectAssetReferences, + Zone* zone) + : XAssetInfoGeneric( + type, std::move(name), static_cast(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(m_ptr); diff --git a/src/ZoneCommon/Pool/ZoneAssetPools.cpp b/src/ZoneCommon/Pool/ZoneAssetPools.cpp index 088358af..ef13b01e 100644 --- a/src/ZoneCommon/Pool/ZoneAssetPools.cpp +++ b/src/ZoneCommon/Pool/ZoneAssetPools.cpp @@ -5,24 +5,22 @@ ZoneAssetPools::ZoneAssetPools(Zone* zone) { } -XAssetInfoGeneric* ZoneAssetPools::AddAsset( - const asset_type_t type, std::string name, void* asset, std::vector dependencies, std::vector 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 dependencies, std::vector usedScriptStrings, - Zone* zone) + std::vector indirectAssetReferences) { - auto* assetInfo = AddAssetToPool(type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), zone); + return AddAsset(std::make_unique( + type, std::move(name), asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences), m_zone)); +} + +XAssetInfoGeneric* ZoneAssetPools::AddAsset(std::unique_ptr xAssetInfo) +{ + auto* assetInfo = AddAssetToPool(std::move(xAssetInfo)); if (assetInfo) - { m_assets_in_order.push_back(assetInfo); - } return assetInfo; } diff --git a/src/ZoneCommon/Pool/ZoneAssetPools.h b/src/ZoneCommon/Pool/ZoneAssetPools.h index 22ba0372..76e6208e 100644 --- a/src/ZoneCommon/Pool/ZoneAssetPools.h +++ b/src/ZoneCommon/Pool/ZoneAssetPools.h @@ -5,10 +5,12 @@ #include "Zone/ZoneTypes.h" #include +#include #include #include class Zone; +class IndirectAssetReference; class XAssetInfoGeneric; class ZoneAssetPools @@ -17,12 +19,7 @@ protected: Zone* m_zone; std::vector m_assets_in_order; - virtual XAssetInfoGeneric* AddAssetToPool(asset_type_t type, - std::string name, - void* asset, - std::vector dependencies, - std::vector usedScriptStrings, - Zone* zone) = 0; + virtual XAssetInfoGeneric* AddAssetToPool(std::unique_ptr xAssetInfo) = 0; public: using iterator = std::vector::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 dependencies, std::vector usedScriptStrings); + XAssetInfoGeneric* AddAsset(std::unique_ptr xAssetInfo); XAssetInfoGeneric* AddAsset(asset_type_t type, std::string name, void* asset, std::vector dependencies, std::vector usedScriptStrings, - Zone* zone); + std::vector 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; }; diff --git a/src/ZoneLoading/Loading/AssetLoader.cpp b/src/ZoneLoading/Loading/AssetLoader.cpp index c56cfe23..c61e1f2a 100644 --- a/src/ZoneLoading/Loading/AssetLoader.cpp +++ b/src/ZoneLoading/Loading/AssetLoader.cpp @@ -10,10 +10,14 @@ AssetLoader::AssetLoader(const asset_type_t assetType, Zone* zone, IZoneInputStr { } -XAssetInfoGeneric* - AssetLoader::LinkAsset(std::string name, void* asset, std::vector scriptStrings, std::vector dependencies) const +XAssetInfoGeneric* AssetLoader::LinkAsset(std::string name, + void* asset, + std::vector dependencies, + std::vector scriptStrings, + std::vector 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 diff --git a/src/ZoneLoading/Loading/AssetLoader.h b/src/ZoneLoading/Loading/AssetLoader.h index 47246188..d4ec283e 100644 --- a/src/ZoneLoading/Loading/AssetLoader.h +++ b/src/ZoneLoading/Loading/AssetLoader.h @@ -16,7 +16,11 @@ protected: AssetLoader(asset_type_t assetType, Zone* zone, IZoneInputStream* stream); - XAssetInfoGeneric* LinkAsset(std::string name, void* asset, std::vector scriptStrings, std::vector dependencies) const; + XAssetInfoGeneric* LinkAsset(std::string name, + void* asset, + std::vector dependencies, + std::vector scriptStrings, + std::vector indirectAssetReferences) const; _NODISCARD XAssetInfoGeneric* GetAssetInfo(std::string name) const; }; diff --git a/src/ZoneLoading/Loading/AssetMarker.cpp b/src/ZoneLoading/Loading/AssetMarker.cpp index ecf14dd9..c6ce0d17 100644 --- a/src/ZoneLoading/Loading/AssetMarker.cpp +++ b/src/ZoneLoading/Loading/AssetMarker.cpp @@ -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 AssetMarker::GetUsedScriptStrings() const return usedScriptStrings; } + +std::vector AssetMarker::GetIndirectAssetReferences() const +{ + std::vector 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; +} diff --git a/src/ZoneLoading/Loading/AssetMarker.h b/src/ZoneLoading/Loading/AssetMarker.h index cb3837bd..92cc449d 100644 --- a/src/ZoneLoading/Loading/AssetMarker.h +++ b/src/ZoneLoading/Loading/AssetMarker.h @@ -13,6 +13,7 @@ class AssetMarker std::unordered_set m_dependencies; std::unordered_set m_used_script_strings; + std::unordered_set 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 GetDependencies() const; _NODISCARD std::vector GetUsedScriptStrings() const; + _NODISCARD std::vector GetIndirectAssetReferences() const; }; diff --git a/test/ObjLoadingTests/Mock/MockAssetLoadingManager.cpp b/test/ObjLoadingTests/Mock/MockAssetLoadingManager.cpp index a97ff559..ea45e05e 100644 --- a/test/ObjLoadingTests/Mock/MockAssetLoadingManager.cpp +++ b/test/ObjLoadingTests/Mock/MockAssetLoadingManager.cpp @@ -12,18 +12,32 @@ AssetLoadingContext* MockAssetLoadingManager::GetAssetLoadingContext() const return m_context.get(); } +XAssetInfoGeneric* MockAssetLoadingManager::AddAsset(std::unique_ptr 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 dependencies, std::vector usedScriptStrings) { - XAssetInfoGeneric assetInfoObj{assetType, assetName, m_zone, std::move(dependencies), std::move(usedScriptStrings), asset}; - auto assetInfo = std::make_unique(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(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 dependencies, + std::vector usedScriptStrings, + std::vector indirectAssetReferences) +{ + return AddAsset(std::make_unique( + 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(), std::vector(), asset}; - auto assetInfo = std::make_unique(std::move(assetInfoObj)); - m_available_dependencies.emplace(std::make_pair(assetInfo->m_name, std::move(assetInfo))); + auto assetInfo = std::make_unique(assetType, std::move(assetName), asset); + m_available_dependencies.emplace(assetInfo->m_name, std::move(assetInfo)); } XAssetInfoGeneric* MockAssetLoadingManager::MockGetAddedAsset(const std::string& assetName) diff --git a/test/ObjLoadingTests/Mock/MockAssetLoadingManager.h b/test/ObjLoadingTests/Mock/MockAssetLoadingManager.h index e6bee03d..107e61ee 100644 --- a/test/ObjLoadingTests/Mock/MockAssetLoadingManager.h +++ b/test/ObjLoadingTests/Mock/MockAssetLoadingManager.h @@ -17,12 +17,20 @@ public: MockAssetLoadingManager(Zone* zone, ISearchPath* searchPath); _NODISCARD AssetLoadingContext* GetAssetLoadingContext() const override; + XAssetInfoGeneric* AddAsset(std::unique_ptr xAssetInfo) override; XAssetInfoGeneric* AddAsset(asset_type_t assetType, const std::string& assetName, void* asset, std::vector dependencies, std::vector usedScriptStrings) override; + XAssetInfoGeneric* AddAsset(asset_type_t assetType, + const std::string& assetName, + void* asset, + std::vector dependencies, + std::vector usedScriptStrings, + std::vector 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);