Various fixes and optimizations.
This commit is contained in:
parent
ac4548f4c2
commit
f509e67953
@ -97,6 +97,7 @@ workspace "iw4x"
|
|||||||
-- Pre-compiled header
|
-- Pre-compiled header
|
||||||
pchheader "STDInclude.hpp" -- must be exactly same as used in #include directives
|
pchheader "STDInclude.hpp" -- must be exactly same as used in #include directives
|
||||||
pchsource "src/STDInclude.cpp" -- real path
|
pchsource "src/STDInclude.cpp" -- real path
|
||||||
|
buildoptions { "-Zm200" } -- allocate ~150mb memory for the precompiled header. This should be enough, increase if necessary
|
||||||
|
|
||||||
-- Dependency on zlib, json11 and asio
|
-- Dependency on zlib, json11 and asio
|
||||||
links { "zlib", "json11", "pdcurses" }
|
links { "zlib", "json11", "pdcurses" }
|
||||||
|
@ -2,16 +2,6 @@
|
|||||||
|
|
||||||
namespace Assets
|
namespace Assets
|
||||||
{
|
{
|
||||||
void IGfxImage::Save_GfxImageLoadDef(Components::ZoneBuilder::Zone* builder, const char* name)
|
|
||||||
{
|
|
||||||
Game::GfxImageLoadDef loadDef;
|
|
||||||
ZeroMemory(&loadDef, sizeof(loadDef));
|
|
||||||
|
|
||||||
Utils::Stream* buffer = builder->GetBuffer();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void IGfxImage::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
void IGfxImage::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||||
{
|
{
|
||||||
Assert_AssetStruct(Game::GfxImage, 32);
|
Assert_AssetStruct(Game::GfxImage, 32);
|
||||||
|
@ -5,8 +5,5 @@ namespace Assets
|
|||||||
virtual Game::XAssetType GetType() override { return Game::XAssetType::ASSET_TYPE_IMAGE; };
|
virtual Game::XAssetType GetType() override { return Game::XAssetType::ASSET_TYPE_IMAGE; };
|
||||||
|
|
||||||
virtual void Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
|
virtual void Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
|
||||||
|
|
||||||
private:
|
|
||||||
void Save_GfxImageLoadDef(Components::ZoneBuilder::Zone* builder, const char* name);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -59,7 +59,15 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
Assert_AssetStruct(Game::MaterialTextureDef, 12);
|
Assert_AssetStruct(Game::MaterialTextureDef, 12);
|
||||||
|
|
||||||
|
// Pointer/Offset insertion is untested, but it worked in T6, so I think it's fine
|
||||||
|
if (builder->HasPointer(asset->textureTable))
|
||||||
|
{
|
||||||
|
dest->textureTable = builder->GetPointer(asset->textureTable);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
buffer->Align(Utils::Stream::ALIGN_4);
|
buffer->Align(Utils::Stream::ALIGN_4);
|
||||||
|
builder->StorePointer(asset->textureTable);
|
||||||
|
|
||||||
Game::MaterialTextureDef* destTextureTable = (Game::MaterialTextureDef*)buffer->At();
|
Game::MaterialTextureDef* destTextureTable = (Game::MaterialTextureDef*)buffer->At();
|
||||||
buffer->SaveArray(asset->textureTable, asset->textureCount);
|
buffer->SaveArray(asset->textureTable, asset->textureCount);
|
||||||
@ -80,7 +88,7 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
buffer->Align(Utils::Stream::ALIGN_4);
|
buffer->Align(Utils::Stream::ALIGN_4);
|
||||||
buffer->Save(water, sizeof(Game::water_t));
|
buffer->Save(water, sizeof(Game::water_t));
|
||||||
destTextureDef->info.water = (Game::water_t *)-1;
|
destTextureDef->info.water = (Game::water_t *) - 1;
|
||||||
|
|
||||||
// Save_water_t
|
// Save_water_t
|
||||||
if (water->H0X)
|
if (water->H0X)
|
||||||
@ -103,30 +111,49 @@ namespace Assets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(textureDef->info.image)
|
else if (textureDef->info.image)
|
||||||
{
|
{
|
||||||
destTextureDef->info.image = builder->RequireAsset(Game::XAssetType::ASSET_TYPE_IMAGE, textureDef->info.image->name).image;
|
destTextureDef->info.image = builder->RequireAsset(Game::XAssetType::ASSET_TYPE_IMAGE, textureDef->info.image->name).image;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dest->textureTable = (Game::MaterialTextureDef*)-1;
|
dest->textureTable = (Game::MaterialTextureDef*) - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asset->constantTable)
|
if (asset->constantTable)
|
||||||
{
|
{
|
||||||
Assert_AssetStruct(Game::MaterialConstantDef, 32);
|
Assert_AssetStruct(Game::MaterialConstantDef, 32);
|
||||||
|
|
||||||
|
if (builder->HasPointer(asset->constantTable))
|
||||||
|
{
|
||||||
|
dest->constantTable = builder->GetPointer(asset->constantTable);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
buffer->Align(Utils::Stream::ALIGN_16);
|
buffer->Align(Utils::Stream::ALIGN_16);
|
||||||
|
builder->StorePointer(asset->constantTable);
|
||||||
|
|
||||||
buffer->SaveArray(asset->constantTable, asset->constantCount);
|
buffer->SaveArray(asset->constantTable, asset->constantCount);
|
||||||
dest->constantTable = (Game::MaterialConstantDef *)-1;
|
dest->constantTable = (Game::MaterialConstantDef *) - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asset->stateBitTable)
|
if (asset->stateBitTable)
|
||||||
|
{
|
||||||
|
if (builder->HasPointer(asset->stateBitTable))
|
||||||
|
{
|
||||||
|
dest->stateBitTable = builder->GetPointer(asset->stateBitTable);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
buffer->Align(Utils::Stream::ALIGN_4);
|
buffer->Align(Utils::Stream::ALIGN_4);
|
||||||
|
builder->StorePointer(asset->stateBitTable);
|
||||||
|
|
||||||
buffer->Save(asset->stateBitTable, 8, asset->stateBitsCount);
|
buffer->Save(asset->stateBitTable, 8, asset->stateBitsCount);
|
||||||
dest->stateBitTable = (void *)-1;
|
dest->stateBitTable = (void *)-1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buffer->PopBlock();
|
buffer->PopBlock();
|
||||||
}
|
}
|
||||||
|
@ -59,13 +59,19 @@ namespace Assets
|
|||||||
Game::MaterialTechnique* technique = asset->techniques[i];
|
Game::MaterialTechnique* technique = asset->techniques[i];
|
||||||
|
|
||||||
if (technique)
|
if (technique)
|
||||||
|
{
|
||||||
|
if (builder->HasPointer(technique))
|
||||||
|
{
|
||||||
|
dest->techniques[i] = builder->GetPointer(technique);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Size-check is obsolete, as the structure is dynamic
|
// Size-check is obsolete, as the structure is dynamic
|
||||||
buffer->Align(Utils::Stream::ALIGN_4);
|
buffer->Align(Utils::Stream::ALIGN_4);
|
||||||
|
builder->StorePointer(technique);
|
||||||
|
|
||||||
Game::MaterialTechnique* destTechnique = (Game::MaterialTechnique*)buffer->At();
|
Game::MaterialTechnique* destTechnique = (Game::MaterialTechnique*)buffer->At();
|
||||||
buffer->Save(technique, 8);
|
buffer->Save(technique, 8);
|
||||||
dest->techniques[i] = (Game::MaterialTechnique*) - 1;
|
|
||||||
|
|
||||||
// Save_MaterialPassArray
|
// Save_MaterialPassArray
|
||||||
for (short i = 0; i < technique->numPasses; i++)
|
for (short i = 0; i < technique->numPasses; i++)
|
||||||
@ -95,7 +101,7 @@ namespace Assets
|
|||||||
{
|
{
|
||||||
buffer->Align(Utils::Stream::ALIGN_4);
|
buffer->Align(Utils::Stream::ALIGN_4);
|
||||||
buffer->SaveArray(pass->argumentDef, pass->argCount1 + pass->argCount2 + pass->argCount3);
|
buffer->SaveArray(pass->argumentDef, pass->argCount1 + pass->argCount2 + pass->argCount3);
|
||||||
destPass->argumentDef = (Game::ShaderArgumentDef*)-1;
|
destPass->argumentDef = (Game::ShaderArgumentDef*) - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +116,8 @@ namespace Assets
|
|||||||
}
|
}
|
||||||
|
|
||||||
destTechnique->name = (char*)-1;
|
destTechnique->name = (char*)-1;
|
||||||
|
dest->techniques[i] = (Game::MaterialTechnique*) - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@ namespace Components
|
|||||||
|
|
||||||
Discovery::Discovery()
|
Discovery::Discovery()
|
||||||
{
|
{
|
||||||
|
Dvar::Register<int>("net_discoveryPortRangeMin", 25000, 0, 65535, Game::dvar_flag::DVAR_FLAG_SAVED, "Minimum scan range port for local server discovery");
|
||||||
|
Dvar::Register<int>("net_discoveryPortRangeMax", 35000, 1, 65536, Game::dvar_flag::DVAR_FLAG_SAVED, "Maximum scan range port for local server discovery");
|
||||||
|
|
||||||
Discovery::DiscoveryContainer.Perform = false;
|
Discovery::DiscoveryContainer.Perform = false;
|
||||||
Discovery::DiscoveryContainer.Terminate = false;
|
Discovery::DiscoveryContainer.Terminate = false;
|
||||||
Discovery::DiscoveryContainer.Thread = new std::thread([] ()
|
Discovery::DiscoveryContainer.Thread = new std::thread([] ()
|
||||||
@ -28,7 +31,9 @@ namespace Components
|
|||||||
Discovery::DiscoveryContainer.Challenge = Utils::VA("%d", Game::Com_Milliseconds());
|
Discovery::DiscoveryContainer.Challenge = Utils::VA("%d", Game::Com_Milliseconds());
|
||||||
|
|
||||||
//Network::BroadcastAll("discovery\n");
|
//Network::BroadcastAll("discovery\n");
|
||||||
Network::BroadcastRange(25000, 35000, Utils::VA("discovery\n%s", Discovery::DiscoveryContainer.Challenge.data()));
|
unsigned int minPort = Dvar::Var("net_discoveryPortRangeMin").Get<unsigned int>();
|
||||||
|
unsigned int maxPort = Dvar::Var("net_discoveryPortRangeMax").Get<unsigned int>();
|
||||||
|
Network::BroadcastRange(minPort, maxPort, Utils::VA("discovery\n%s", Discovery::DiscoveryContainer.Challenge.data()));
|
||||||
|
|
||||||
Logger::Print("Discovery sent within %dms, awaiting responses...\n", Game::Com_Milliseconds() - start);
|
Logger::Print("Discovery sent within %dms, awaiting responses...\n", Game::Com_Milliseconds() - start);
|
||||||
|
|
||||||
|
@ -42,6 +42,10 @@ namespace Components
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
template <> unsigned int Dvar::Var::Get()
|
||||||
|
{
|
||||||
|
return (unsigned int)this->Get<int>();
|
||||||
|
}
|
||||||
template <> float Dvar::Var::Get()
|
template <> float Dvar::Var::Get()
|
||||||
{
|
{
|
||||||
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT)
|
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT)
|
||||||
|
@ -105,6 +105,18 @@ namespace Components
|
|||||||
float color[4] = { 1.0f, 1.0f, 1.0f, (Game::CL_IsCgameInitialized() ? 0.3f : 1.0f) };
|
float color[4] = { 1.0f, 1.0f, 1.0f, (Game::CL_IsCgameInitialized() ? 0.3f : 1.0f) };
|
||||||
Game::R_AddCmdDrawText(Utils::VA("Loading FastFile: %s", FastFiles::Current().data()), 0x7FFFFFFF, font, 5.0f, (float)(Renderer::Height() - 5), 1.0f, 1.0f, 0.0f, color, 0);
|
Game::R_AddCmdDrawText(Utils::VA("Loading FastFile: %s", FastFiles::Current().data()), 0x7FFFFFFF, font, 5.0f, (float)(Renderer::Height() - 5), 1.0f, 1.0f, 0.0f, color, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Command::Add("loadzone", [] (Command::Params params)
|
||||||
|
{
|
||||||
|
if (params.Length() < 2) return;
|
||||||
|
|
||||||
|
Game::XZoneInfo info;
|
||||||
|
info.name = params[1];
|
||||||
|
info.allocFlags = 0x01000000;
|
||||||
|
info.freeFlags = 0;
|
||||||
|
|
||||||
|
Game::DB_LoadXAssets(&info, 1, true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FastFiles::~FastFiles()
|
FastFiles::~FastFiles()
|
||||||
|
@ -330,6 +330,11 @@ namespace Components
|
|||||||
ZoneBuilder::Zone::PointerMap[pointer] = ZoneBuilder::Zone::Buffer.GetPackedOffset();
|
ZoneBuilder::Zone::PointerMap[pointer] = ZoneBuilder::Zone::Buffer.GetPackedOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZoneBuilder::Zone::AddScriptString(std::string str)
|
||||||
|
{
|
||||||
|
return ZoneBuilder::Zone::AddScriptString(Game::SL_GetString(str.data(), 0));
|
||||||
|
}
|
||||||
|
|
||||||
// Mark a scriptString for writing and map it.
|
// Mark a scriptString for writing and map it.
|
||||||
int ZoneBuilder::Zone::AddScriptString(unsigned short gameIndex)
|
int ZoneBuilder::Zone::AddScriptString(unsigned short gameIndex)
|
||||||
{
|
{
|
||||||
@ -405,17 +410,6 @@ namespace Components
|
|||||||
return (Flags::HasFlag("zonebuilder") && !Dedicated::IsDedicated());
|
return (Flags::HasFlag("zonebuilder") && !Dedicated::IsDedicated());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove and replace with loadzone command
|
|
||||||
void TestZoneLoading(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
|
|
||||||
{
|
|
||||||
std::vector<Game::XZoneInfo> data;
|
|
||||||
Utils::Merge(data, zoneInfo, zoneCount);
|
|
||||||
|
|
||||||
data.push_back({ "penis", zoneInfo->allocFlags, zoneInfo->freeFlags });
|
|
||||||
|
|
||||||
Game::DB_LoadXAssets(data.data(), data.size(), sync);
|
|
||||||
}
|
|
||||||
|
|
||||||
ZoneBuilder::ZoneBuilder()
|
ZoneBuilder::ZoneBuilder()
|
||||||
{
|
{
|
||||||
static_assert(sizeof(Game::XFileHeader) == 21, "Invalid XFileHeader structure!");
|
static_assert(sizeof(Game::XFileHeader) == 21, "Invalid XFileHeader structure!");
|
||||||
@ -449,7 +443,7 @@ namespace Components
|
|||||||
// Prevent destroying textures
|
// Prevent destroying textures
|
||||||
Utils::Hook::Set<BYTE>(0x51F03D, 0xEB);
|
Utils::Hook::Set<BYTE>(0x51F03D, 0xEB);
|
||||||
|
|
||||||
Command::Add("build", [] (Command::Params params)
|
Command::Add("buildzone", [] (Command::Params params)
|
||||||
{
|
{
|
||||||
if (params.Length() < 2) return;
|
if (params.Length() < 2) return;
|
||||||
|
|
||||||
@ -473,19 +467,5 @@ namespace Components
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//else
|
|
||||||
//Utils::Hook(0x4546DF, TestZoneLoading, HOOK_CALL).Install()->Quick();
|
|
||||||
|
|
||||||
Command::Add("loadzone", [] (Command::Params params)
|
|
||||||
{
|
|
||||||
if (params.Length() < 2) return;
|
|
||||||
|
|
||||||
Game::XZoneInfo info;
|
|
||||||
info.name = params[1];
|
|
||||||
info.allocFlags = 0x01000000;
|
|
||||||
info.freeFlags = 0;
|
|
||||||
|
|
||||||
Game::DB_LoadXAssets(&info, 1, true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ namespace Components
|
|||||||
bool LoadAsset(Game::XAssetType type, std::string name);
|
bool LoadAsset(Game::XAssetType type, std::string name);
|
||||||
|
|
||||||
int AddScriptString(unsigned short gameIndex);
|
int AddScriptString(unsigned short gameIndex);
|
||||||
|
int AddScriptString(std::string str);
|
||||||
int FindScriptString(std::string str);
|
int FindScriptString(std::string str);
|
||||||
|
|
||||||
void MapScriptString(unsigned short* gameIndex);
|
void MapScriptString(unsigned short* gameIndex);
|
||||||
|
@ -121,6 +121,7 @@ namespace Game
|
|||||||
SetConsole_t SetConsole = (SetConsole_t)0x44F060;
|
SetConsole_t SetConsole = (SetConsole_t)0x44F060;
|
||||||
|
|
||||||
SL_ConvertToString_t SL_ConvertToString = (SL_ConvertToString_t)0x4EC1D0;
|
SL_ConvertToString_t SL_ConvertToString = (SL_ConvertToString_t)0x4EC1D0;
|
||||||
|
SL_GetString_t SL_GetString = (SL_GetString_t)0x4CDC10;
|
||||||
|
|
||||||
Steam_JoinLobby_t Steam_JoinLobby = (Steam_JoinLobby_t)0x49CF70;
|
Steam_JoinLobby_t Steam_JoinLobby = (Steam_JoinLobby_t)0x49CF70;
|
||||||
|
|
||||||
|
@ -280,9 +280,12 @@ namespace Game
|
|||||||
typedef void(__cdecl * SetConsole_t)(const char* cvar, const char* value);
|
typedef void(__cdecl * SetConsole_t)(const char* cvar, const char* value);
|
||||||
extern SetConsole_t SetConsole;
|
extern SetConsole_t SetConsole;
|
||||||
|
|
||||||
typedef char* (__cdecl * SL_ConvertToString_t)(unsigned short);
|
typedef char* (__cdecl * SL_ConvertToString_t)(unsigned short stringValue);
|
||||||
extern SL_ConvertToString_t SL_ConvertToString;
|
extern SL_ConvertToString_t SL_ConvertToString;
|
||||||
|
|
||||||
|
typedef short(__cdecl * SL_GetString_t)(const char *str, unsigned int user);
|
||||||
|
extern SL_GetString_t SL_GetString;
|
||||||
|
|
||||||
typedef void(__cdecl * Steam_JoinLobby_t)(SteamID, char);
|
typedef void(__cdecl * Steam_JoinLobby_t)(SteamID, char);
|
||||||
extern Steam_JoinLobby_t Steam_JoinLobby;
|
extern Steam_JoinLobby_t Steam_JoinLobby;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user