DLC stuff
This commit is contained in:
parent
3e95fe4344
commit
d8c43f4e8c
@ -6,6 +6,7 @@ namespace Components
|
|||||||
std::vector<std::pair<std::string, std::string>> Maps::DependencyList;
|
std::vector<std::pair<std::string, std::string>> Maps::DependencyList;
|
||||||
std::vector<std::string> Maps::CurrentDependencies;
|
std::vector<std::string> Maps::CurrentDependencies;
|
||||||
|
|
||||||
|
std::vector<Maps::DLC> Maps::DlcPacks;
|
||||||
std::vector<Game::XAssetEntry> Maps::EntryPool;
|
std::vector<Game::XAssetEntry> Maps::EntryPool;
|
||||||
|
|
||||||
void Maps::LoadMapZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
|
void Maps::LoadMapZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
|
||||||
@ -329,6 +330,47 @@ namespace Components
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void Maps::AddDlc(Maps::DLC dlc)
|
||||||
|
{
|
||||||
|
for (auto& pack : Maps::DlcPacks)
|
||||||
|
{
|
||||||
|
if (pack.index == dlc.index)
|
||||||
|
{
|
||||||
|
pack.url = dlc.url;
|
||||||
|
pack.maps = dlc.maps;
|
||||||
|
Maps::UpdateDlcStatus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dvar::Register<bool>(Utils::String::VA("isDlcInstalled_%d", dlc.index), false, Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, "");
|
||||||
|
|
||||||
|
Maps::DlcPacks.push_back(dlc);
|
||||||
|
Maps::UpdateDlcStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Maps::UpdateDlcStatus()
|
||||||
|
{
|
||||||
|
bool hasAllDlcs = true;
|
||||||
|
for (auto& pack : Maps::DlcPacks)
|
||||||
|
{
|
||||||
|
bool hasAllMaps = true;
|
||||||
|
for (auto map : pack.maps)
|
||||||
|
{
|
||||||
|
if (!FastFiles::Exists(map))
|
||||||
|
{
|
||||||
|
hasAllMaps = false;
|
||||||
|
hasAllDlcs = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dvar::Var(Utils::String::VA("isDlcInstalled_%d", pack.index)).SetRaw(hasAllMaps ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dvar::Var("isDlcInstalled_All").SetRaw(hasAllDlcs ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
void Maps::ReallocateEntryPool()
|
void Maps::ReallocateEntryPool()
|
||||||
{
|
{
|
||||||
Assert_Size(Game::XAssetEntry, 16);
|
Assert_Size(Game::XAssetEntry, 16);
|
||||||
@ -383,6 +425,36 @@ namespace Components
|
|||||||
|
|
||||||
Maps::Maps()
|
Maps::Maps()
|
||||||
{
|
{
|
||||||
|
Dvar::OnInit([] ()
|
||||||
|
{
|
||||||
|
Dvar::Register<bool>("isDlcInstalled_All", false, Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, "");
|
||||||
|
|
||||||
|
Maps::AddDlc({ 1, "https://iw4xcachep26muba.onion.to/dlc/IW4.DLC.1.Stimulus.Package.zip", { "mp_complex", "mp_compact", "mp_storm", "mp_overgrown", "mp_crash" } });
|
||||||
|
Maps::AddDlc({ 2, "https://iw4xcachep26muba.onion.to/dlc/IW4.DLC.2.Resurgence.Pack.zip", { "mp_abandon", "mp_vacant", "mp_trailerpark", "mp_strike", "mp_fuel2" } });
|
||||||
|
Maps::AddDlc({ 3, "https://iw4xcachep26muba.onion.to/dlc/IW4.DLC.3.Nuketown.zip", { "mp_nuked" } });
|
||||||
|
Maps::AddDlc({ 4, "https://iw4xcachep26muba.onion.to/dlc/IW4.DLC.4.Classics.1.zip", { "mp_cross_fire", "mp_cargoship", "mp_bloc" } });
|
||||||
|
Maps::AddDlc({ 5, "https://iw4xcachep26muba.onion.to/dlc/IW4.DLC.5.Classics.2.zip", { "mp_killhouse", "mp_bog_sh" } });
|
||||||
|
Maps::AddDlc({ 6, "https://iw4xcachep26muba.onion.to/dlc/IW4.DLC.6.Cargoship.Winter.zip", { "mp_cargoship_sh" } });
|
||||||
|
Maps::AddDlc({ 7, "", { "mp_shipment_long", "mp_rust_long", "mp_firingrange" } });
|
||||||
|
|
||||||
|
Maps::UpdateDlcStatus();
|
||||||
|
|
||||||
|
UIScript::Add("downloadDLC", [] (UIScript::Token token)
|
||||||
|
{
|
||||||
|
int dlc = token.Get<int>();
|
||||||
|
|
||||||
|
for (auto pack : Maps::DlcPacks)
|
||||||
|
{
|
||||||
|
if (pack.index == dlc)
|
||||||
|
{
|
||||||
|
ShellExecuteA(NULL, "open", pack.url.data(), 0, 0, SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Game::MessageBox(fmt::sprintf("DLC %d does not exist!", dlc), "ERROR");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Restrict asset loading
|
// Restrict asset loading
|
||||||
AssetHandler::OnLoad(Maps::LoadAssetRestrict);
|
AssetHandler::OnLoad(Maps::LoadAssetRestrict);
|
||||||
|
|
||||||
@ -475,6 +547,7 @@ namespace Components
|
|||||||
|
|
||||||
Maps::~Maps()
|
Maps::~Maps()
|
||||||
{
|
{
|
||||||
|
Maps::DlcPacks.clear();
|
||||||
Maps::DependencyList.clear();
|
Maps::DependencyList.clear();
|
||||||
Maps::CurrentMainZone.clear();
|
Maps::CurrentMainZone.clear();
|
||||||
Maps::CurrentDependencies.clear();
|
Maps::CurrentDependencies.clear();
|
||||||
|
@ -13,6 +13,15 @@ namespace Components
|
|||||||
static void AddDependency(std::string expression, std::string zone);
|
static void AddDependency(std::string expression, std::string zone);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
class DLC
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int index;
|
||||||
|
std::string url;
|
||||||
|
std::vector<std::string> maps;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::vector<DLC> DlcPacks;
|
||||||
static std::vector<Game::XAssetEntry> EntryPool;
|
static std::vector<Game::XAssetEntry> EntryPool;
|
||||||
|
|
||||||
static std::string CurrentMainZone;
|
static std::string CurrentMainZone;
|
||||||
@ -30,6 +39,9 @@ namespace Components
|
|||||||
static Game::GameMap_Data** GetWorldData();
|
static Game::GameMap_Data** GetWorldData();
|
||||||
static void GetWorldDataStub();
|
static void GetWorldDataStub();
|
||||||
|
|
||||||
|
static void AddDlc(DLC dlc);
|
||||||
|
static void UpdateDlcStatus();
|
||||||
|
|
||||||
#if defined(DEBUG) && defined(ENABLE_DXSDK)
|
#if defined(DEBUG) && defined(ENABLE_DXSDK)
|
||||||
static void ExportMap(Game::GfxWorld* world);
|
static void ExportMap(Game::GfxWorld* world);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user