Fix gametype stuff

This commit is contained in:
momo5502 2016-10-17 22:38:59 +02:00
parent b606983835
commit b53f5bdf53
3 changed files with 14 additions and 11 deletions

View File

@ -28,7 +28,7 @@ namespace Components
Dvar::Var("g_gametype").Set(gametype);
}
bool Gametypes::BuildGametypeList(const char*, void* buffer, size_t size)
void* Gametypes::BuildGametypeList(const char*, void* buffer, size_t size)
{
std::vector<std::string> gametypes;
@ -78,14 +78,17 @@ namespace Components
std::string data;
for (auto& gametype : gametypes)
{
data.append(gametype);
data.append("\n");
if (Game::LoadModdableRawfile(0, Utils::String::VA("maps/mp/gametypes/%s.txt", gametype.data())))
{
data.append(gametype);
data.append("\r\n");
}
}
// Copy to the actual buffer
std::memcpy(buffer, data.data(), std::min(size, data.size()));
std::memcpy(buffer, data.data(), std::min(size, data.size() + 1));
return (!gametypes.empty());
return (data.empty() ? nullptr : buffer);
}
Gametypes::Gametypes()

View File

@ -14,6 +14,6 @@ namespace Components
static const char* GetGametypeText(unsigned int index, int column);
static void SelectGametype(unsigned int index);
static bool BuildGametypeList(const char* file, void* buffer, size_t size);
static void* BuildGametypeList(const char* file, void* buffer, size_t size);
};
}

View File

@ -399,11 +399,11 @@ namespace Components
Maps::AddDependency("mp_bloc_sh", "iw4x_dependencies_mp");
Maps::AddDependency("mp_cargoship_sh", "iw4x_dependencies_mp");
Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp");
Maps::AddDependency("mp_shipment_long", "iw4x_dependencies_mp");
Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp");
Maps::AddDependency("mp_firingrange", "mp_underpass");
Maps::AddDependency("mp_underpass", "mp_firingrange");
//Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp");
//Maps::AddDependency("mp_shipment_long", "iw4x_dependencies_mp");
//Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp");
//Maps::AddDependency("mp_firingrange", "mp_underpass");
//Maps::AddDependency("mp_underpass", "mp_firingrange");
#if defined(DEBUG) && defined(ENABLE_DXSDK)
Command::Add("dumpmap", [] (Command::Params)