Merge branch 'implement-new-codo-maps' into 'develop'

Resolve "Implement new CODO maps"
This commit is contained in:
momo5502 2016-10-23 17:32:30 +02:00
commit b6a5c18662
17 changed files with 261 additions and 15 deletions

2
deps/fmt vendored

@ -1 +1 @@
Subproject commit ed874df293f8c0831477a2abbdabfb3a0d0441a8 Subproject commit abbefd71666055daac9e14e78262620f9e845850

2
deps/mongoose vendored

@ -1 +1 @@
Subproject commit a17eae4142f3ab5eea8189810189ab1fec67294a Subproject commit c722cfec18231c6d18ab8a73993b763aa1e0dd7e

View File

@ -63,6 +63,7 @@ namespace Components
Loader::Register(new QuickPatch()); Loader::Register(new QuickPatch());
Loader::Register(new ServerInfo()); Loader::Register(new ServerInfo());
Loader::Register(new ServerList()); Loader::Register(new ServerList());
Loader::Register(new SlowMotion());
Loader::Register(new StringTable()); Loader::Register(new StringTable());
Loader::Register(new ZoneBuilder()); Loader::Register(new ZoneBuilder());
Loader::Register(new AssetHandler()); Loader::Register(new AssetHandler());

View File

@ -76,6 +76,7 @@ namespace Components
#include "Modules\QuickPatch.hpp" #include "Modules\QuickPatch.hpp"
#include "Modules\ServerInfo.hpp" #include "Modules\ServerInfo.hpp"
#include "Modules\ServerList.hpp" #include "Modules\ServerList.hpp"
#include "Modules\SlowMotion.hpp"
#include "Modules\StringTable.hpp" #include "Modules\StringTable.hpp"
#include "Modules\ZoneBuilder.hpp" #include "Modules\ZoneBuilder.hpp"
#include "Modules\AssetHandler.hpp" #include "Modules\AssetHandler.hpp"

View File

@ -132,7 +132,57 @@ namespace Components
} }
} }
if (type == 5 && name == "wc/codo_ui_viewer_black_decal3"s) #if DEBUG
if (type == 9 && false)
{
static Game::MaterialTechniqueSet* technique = nullptr;
auto printTechset = [] (Game::MaterialTechniqueSet* technique, std::string zone)
{
FILE* fp;
fopen_s(&fp, "test.txt", "a");
fprintf(fp, "%s: %s\n", zone.data(), technique->name);
for (int i = 0; i < 48; i++)
{
if (technique->techniques[i])
{
fprintf(fp, "\t%d: %s\n", i, technique->techniques[i]->name);
for (int j = 0; j < technique->techniques[i]->numPasses; j++)
{
Game::MaterialPass* pass = &technique->techniques[i]->passes[j];
for (int k = 0; k < (pass->argCount1 + pass->argCount2 + pass->argCount3); k++)
{
fprintf(fp, "\t\t\t%d.%d.%d Para: %d\n", i, j, k, pass->argumentDef[k].paramID & 0xFFFF);
}
}
}
}
fprintf(fp, "\n");
fclose(fp);
};
static std::map<std::string, Game::MaterialTechniqueSet*> techs;
if (FastFiles::Current() == "mp_rust_long")
{
techs[name] = asset->materialTechset;
printTechset(asset->materialTechset, "mp_rust_long");
}
else
{
if (techs.find(name) != techs.end())
{
printTechset(asset->materialTechset, FastFiles::Current());
}
}
}
#endif
if (type == Game::XAssetType::ASSET_TYPE_MATERIAL && name == "wc/codo_ui_viewer_black_decal3"s)
{ {
asset->material->sortKey = 0xE; asset->material->sortKey = 0xE;
} }
@ -321,7 +371,7 @@ namespace Components
// Log missing empty assets // Log missing empty assets
QuickPatch::OnFrame([] () QuickPatch::OnFrame([] ()
{ {
if (Game::Sys_IsDatabaseReady() && Game::Sys_IsDatabaseReady2() && !AssetHandler::EmptyAssets.empty()) if (FastFiles::Ready() && !AssetHandler::EmptyAssets.empty())
{ {
for (auto& asset : AssetHandler::EmptyAssets) for (auto& asset : AssetHandler::EmptyAssets)
{ {

View File

@ -197,7 +197,7 @@ namespace Components
{ {
if (ConnectProtocol::Used()) if (ConnectProtocol::Used())
{ {
if (!Game::Sys_IsDatabaseReady() && !Game::Sys_IsDatabaseReady2()) if (!FastFiles::Ready())
{ {
QuickPatch::Once(ConnectProtocol::Invocation); QuickPatch::Once(ConnectProtocol::Invocation);
} }

View File

@ -218,6 +218,11 @@ namespace Components
return std::ifstream(path.data()).good(); return std::ifstream(path.data()).good();
} }
bool FastFiles::Ready()
{
return (Game::Sys_IsDatabaseReady() && Game::Sys_IsDatabaseReady2());
}
const char* FastFiles::GetZoneLocation(const char* file) const char* FastFiles::GetZoneLocation(const char* file)
{ {
const char* dir = Dvar::Var("fs_basepath").Get<const char*>(); const char* dir = Dvar::Var("fs_basepath").Get<const char*>();

View File

@ -12,7 +12,7 @@ namespace Components
static void AddZonePath(std::string path); static void AddZonePath(std::string path);
static std::string Current(); static std::string Current();
static bool Ready();
static bool Exists(std::string file); static bool Exists(std::string file);
static void LoadLocalizeZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); static void LoadLocalizeZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);

View File

@ -314,7 +314,15 @@ namespace Components
Assert_Size(Game::XAssetEntry, 16); Assert_Size(Game::XAssetEntry, 16);
Maps::EntryPool.clear(); Maps::EntryPool.clear();
if (ZoneBuilder::IsEnabled())
{
Maps::EntryPool.resize(1183968);
}
else
{
Maps::EntryPool.resize(789312); Maps::EntryPool.resize(789312);
}
// Apply new size // Apply new size
Utils::Hook::Set<DWORD>(0x5BAEB0, Maps::EntryPool.size()); Utils::Hook::Set<DWORD>(0x5BAEB0, Maps::EntryPool.size());
@ -404,11 +412,11 @@ namespace Components
Maps::AddDependency("mp_bloc_sh", "iw4x_dependencies_mp"); Maps::AddDependency("mp_bloc_sh", "iw4x_dependencies_mp");
Maps::AddDependency("mp_cargoship_sh", "iw4x_dependencies_mp"); Maps::AddDependency("mp_cargoship_sh", "iw4x_dependencies_mp");
//Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp"); Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp");
//Maps::AddDependency("mp_shipment_long", "iw4x_dependencies_mp"); Maps::AddDependency("mp_shipment_long", "iw4x_dependencies_mp");
//Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp"); Maps::AddDependency("mp_firingrange", "iw4x_dependencies_mp");
//Maps::AddDependency("mp_firingrange", "mp_underpass"); Maps::AddDependency("mp_rust_long", "iw4x_dependencies_mp");
//Maps::AddDependency("mp_underpass", "mp_firingrange"); Maps::AddDependency("mp_rust_long", "mp_rust");
#if defined(DEBUG) && defined(ENABLE_DXSDK) #if defined(DEBUG) && defined(ENABLE_DXSDK)
Command::Add("dumpmap", [] (Command::Params) Command::Add("dumpmap", [] (Command::Params)

View File

@ -0,0 +1,85 @@
#include "STDInclude.hpp"
namespace Components
{
int SlowMotion::Delay = 0;
void SlowMotion::ApplySlowMotion(int timePassed)
{
if (SlowMotion::Delay <= 0)
{
Utils::Hook::Call<void(int)>(0x60B2D0)(timePassed);
}
else
{
SlowMotion::Delay -= timePassed;
}
}
__declspec(naked) void SlowMotion::ApplySlowMotionStub()
{
__asm
{
pushad
push [esp + 20h]
call SlowMotion::ApplySlowMotion
pop ecx
popad
retn
}
}
void SlowMotion::SetSlowMotion()
{
int duration = 1000;
float start = Game::Scr_GetFloat(0);
float end = 1.0f;
if (Game::Scr_GetNumParam() >= 2)
{
end = Game::Scr_GetFloat(1);
}
if (Game::Scr_GetNumParam() >= 3)
{
duration = static_cast<int>(Game::Scr_GetFloat(2) * 1000.0);
}
int delay = 0;
if (start > end)
{
if (duration < 150)
{
delay = duration;
}
else
{
delay = 150;
}
}
duration = duration - delay;
Game::Com_SetSlowMotion(start, end, duration);
SlowMotion::Delay = delay;
// set snapshot num to 1 behind (T6 does this, why shouldn't we?)
for (int i = 0; i < *Game::svs_numclients; i++)
{
Game::svs_clients[i].snapNum = (*reinterpret_cast<DWORD*>(0x31D9384)) - 1;
}
}
SlowMotion::SlowMotion()
{
if (!Dedicated::IsEnabled()) return;
SlowMotion::Delay = 0;
Utils::Hook(0x5F5FF2, SlowMotion::SetSlowMotion, HOOK_JUMP).Install()->Quick();
Utils::Hook(0x60B38A, SlowMotion::ApplySlowMotionStub, HOOK_CALL).Install()->Quick();
}
}

View File

@ -0,0 +1,22 @@
#define BUTTON_FLAG_LEANLEFT 0x40
#define BUTTON_FLAG_LEANRIGHT 0x80
namespace Components
{
class SlowMotion : public Component
{
public:
SlowMotion();
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
const char* GetName() { return "SlowMotion"; };
#endif
private:
static int Delay;
static void SetSlowMotion();
static void ApplySlowMotion(int timePassed);
static void ApplySlowMotionStub();
};
}

View File

@ -493,8 +493,11 @@ namespace Components
Utils::Hook::Nop(0x5BB3F2, 5); Utils::Hook::Nop(0x5BB3F2, 5);
Utils::Hook::Nop(0x5BB422, 5); Utils::Hook::Nop(0x5BB422, 5);
Utils::Hook::Nop(0x5BB43A, 5); Utils::Hook::Nop(0x5BB43A, 5);
// Increase asset pools // Increase asset pools
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_MAP_ENTS, 10); Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_MAP_ENTS, 10);
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XMODELSURFS, 8192);
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMAGE, 14336);
// hunk size (was 300 MiB) // hunk size (was 300 MiB)
Utils::Hook::Set<DWORD>(0x64A029, 0x38400000); // 900 MiB Utils::Hook::Set<DWORD>(0x64A029, 0x38400000); // 900 MiB

View File

@ -1005,12 +1005,29 @@ namespace Components
if (arg->paramID >= 58 && arg->paramID <= 135) // >= 34 would be 31 in iw4 terms if (arg->paramID >= 58 && arg->paramID <= 135) // >= 34 would be 31 in iw4 terms
{ {
arg->paramID -= 3; arg->paramID -= 3;
if (Zones::Version() >= 359/* && arg->paramID <= 113*/)
{
arg->paramID -= 7;
}
} }
// >= 21 works fine for specular, but breaks trees // >= 21 works fine for specular, but breaks trees
// >= 4 is too low, breaks specular // >= 4 is too low, breaks specular
else if (arg->paramID >= 11 && arg->paramID < 58) else if (arg->paramID >= 11 && arg->paramID < 58)
{ {
arg->paramID -= 2; arg->paramID -= 2;
if (Zones::Version() >= 359)
{
if (arg->paramID > 15 && arg->paramID < 34)
{
arg->paramID -= 1;
}
else if (arg->paramID >= 50)
{
arg->paramID += 6;
}
}
} }
} }
@ -1126,7 +1143,12 @@ namespace Components
{ {
bool result = Game::Load_Stream(atStreamStart, buffer, size + 4); bool result = Game::Load_Stream(atStreamStart, buffer, size + 4);
// This shouldn't make any difference.
// The new entry is an additional remapped techset which is linked at runtime.
// It's used when the 0x100 gameFlag in a material is set.
// As MW2 flags are only 1 byte large, this won't be possible anyways
int shiftTest = 4; int shiftTest = 4;
std::memmove(buffer + 8 + shiftTest, buffer + 12 + shiftTest, 196 - shiftTest); std::memmove(buffer + 8 + shiftTest, buffer + 12 + shiftTest, 196 - shiftTest);
AssetHandler::Relocate(buffer + 12 + shiftTest, buffer + 8 + shiftTest, 196 - shiftTest); AssetHandler::Relocate(buffer + 12 + shiftTest, buffer + 8 + shiftTest, 196 - shiftTest);
@ -1143,8 +1165,12 @@ namespace Components
//int surfaceTypeBits; //int surfaceTypeBits;
const char *name; const char *name;
char drawSurf[6]; char drawSurf[6];
union
{
char gameFlags; char gameFlags;
char pad; short sGameFlags;
};
char sortKey; char sortKey;
char textureAtlasRowCount; char textureAtlasRowCount;
char textureAtlasColumnCount; char textureAtlasColumnCount;
@ -1177,6 +1203,11 @@ namespace Components
material->drawSurf[10] = material359.drawSurf[2]; material->drawSurf[10] = material359.drawSurf[2];
material->drawSurf[11] = material359.drawSurf[3]; material->drawSurf[11] = material359.drawSurf[3];
if (material359.sGameFlags & 0x100)
{
//OutputDebugStringA("");
}
return result; return result;
} }

View File

@ -28,6 +28,7 @@ namespace Game
Com_Printf_t Com_Printf = (Com_Printf_t)0x402500; Com_Printf_t Com_Printf = (Com_Printf_t)0x402500;
Com_PrintMessage_t Com_PrintMessage = (Com_PrintMessage_t)0x4AA830; Com_PrintMessage_t Com_PrintMessage = (Com_PrintMessage_t)0x4AA830;
Com_ParseExt_t Com_ParseExt = (Com_ParseExt_t)0x474D60; Com_ParseExt_t Com_ParseExt = (Com_ParseExt_t)0x474D60;
Com_SetSlowMotion_t Com_SetSlowMotion = (Com_SetSlowMotion_t)0x446E20;
Con_DrawMiniConsole_t Con_DrawMiniConsole = (Con_DrawMiniConsole_t)0x464F30; Con_DrawMiniConsole_t Con_DrawMiniConsole = (Con_DrawMiniConsole_t)0x464F30;
Con_DrawSolidConsole_t Con_DrawSolidConsole = (Con_DrawSolidConsole_t)0x5A5040; Con_DrawSolidConsole_t Con_DrawSolidConsole = (Con_DrawSolidConsole_t)0x5A5040;
@ -176,6 +177,9 @@ namespace Game
Scr_LoadScript_t Scr_LoadScript = (Scr_LoadScript_t)0x45D940; Scr_LoadScript_t Scr_LoadScript = (Scr_LoadScript_t)0x45D940;
Scr_GetFunctionHandle_t Scr_GetFunctionHandle = (Scr_GetFunctionHandle_t)0x4234F0; Scr_GetFunctionHandle_t Scr_GetFunctionHandle = (Scr_GetFunctionHandle_t)0x4234F0;
Scr_GetFloat_t Scr_GetFloat = (Scr_GetFloat_t)0x443140;
Scr_GetNumParam_t Scr_GetNumParam = (Scr_GetNumParam_t)0x4B0E90;
Scr_ExecThread_t Scr_ExecThread = (Scr_ExecThread_t)0x4AD0B0; Scr_ExecThread_t Scr_ExecThread = (Scr_ExecThread_t)0x4AD0B0;
Scr_FreeThread_t Scr_FreeThread = (Scr_FreeThread_t)0x4BD320; Scr_FreeThread_t Scr_FreeThread = (Scr_FreeThread_t)0x4BD320;

View File

@ -60,6 +60,9 @@ namespace Game
typedef char* (__cdecl * Com_ParseExt_t)(const char **data_p); typedef char* (__cdecl * Com_ParseExt_t)(const char **data_p);
extern Com_ParseExt_t Com_ParseExt; extern Com_ParseExt_t Com_ParseExt;
typedef void(__cdecl * Com_SetSlowMotion_t)(float start, float end, int duration);
extern Com_SetSlowMotion_t Com_SetSlowMotion;
typedef char* (__cdecl * Con_DrawMiniConsole_t)(int localClientNum, int xPos, int yPos, float alpha); typedef char* (__cdecl * Con_DrawMiniConsole_t)(int localClientNum, int xPos, int yPos, float alpha);
extern Con_DrawMiniConsole_t Con_DrawMiniConsole; extern Con_DrawMiniConsole_t Con_DrawMiniConsole;
@ -425,6 +428,12 @@ namespace Game
typedef int(__cdecl * Scr_LoadScript_t)(const char*); typedef int(__cdecl * Scr_LoadScript_t)(const char*);
extern Scr_LoadScript_t Scr_LoadScript; extern Scr_LoadScript_t Scr_LoadScript;
typedef float(__cdecl * Scr_GetFloat_t)(int);
extern Scr_GetFloat_t Scr_GetFloat;
typedef int(__cdecl * Scr_GetNumParam_t)(void);
extern Scr_GetNumParam_t Scr_GetNumParam;
typedef int(__cdecl * Scr_GetFunctionHandle_t)(const char*, const char*); typedef int(__cdecl * Scr_GetFunctionHandle_t)(const char*, const char*);
extern Scr_GetFunctionHandle_t Scr_GetFunctionHandle; extern Scr_GetFunctionHandle_t Scr_GetFunctionHandle;

View File

@ -2476,6 +2476,33 @@ namespace Game
GfxColor groundLighting; GfxColor groundLighting;
}; };
enum surfaceType_t
{
SF_TRIANGLES = 0x0,
SF_TRIANGLES_NO_SUN_SHADOW = 0x1,
SF_BEGIN_STATICMODEL = 0x2,
SF_STATICMODEL_RIGID = 0x2,
SF_STATICMODEL_INSTANCED = 0x3,
SF_STATICMODEL_RIGID_NO_SUN_SHADOW = 0x4,
SF_STATICMODEL_INSTANCED_NO_SUN_SHADOW = 0x5,
SF_END_STATICMODEL = 0x6,
SF_BMODEL = 0x6,
SF_BEGIN_XMODEL = 0x7,
SF_XMODEL_RIGID = 0x7,
SF_XMODEL_SKINNED = 0x8,
SF_END_XMODEL = 0x9,
SF_BEGIN_FX = 0x9,
SF_CODE = 0x9,
SF_GLASS = 0xA,
SF_MARK = 0xB,
SF_SPARK = 0xC,
SF_PARTICLE_CLOUD = 0xD,
SF_PARTICLE_SPARK_CLOUD = 0xE,
SF_END_FX = 0xF,
SF_NUM_SURFACE_TYPES = 0xF,
SF_FORCE_32_BITS = 0xFFFFFFFF,
};
struct srfTriangles_t struct srfTriangles_t
{ {
int vertexLayerData; int vertexLayerData;