diff --git a/code/loader/symbols.cpp b/code/loader/symbols.cpp index 4b3ea182..6553573b 100644 --- a/code/loader/symbols.cpp +++ b/code/loader/symbols.cpp @@ -22,6 +22,7 @@ __pragma(comment(linker, "/ALTERNATENAME:__imp_" NAME "=_Symbol_" #ADDRESS)); \ extern "C" const usize Symbol_##ADDRESS = ADDRESS; +import_symbol(0x48CC30, "?ShowRenderStats@@YAXXZ"); import_symbol(0x5248E0, "?PrintRenderPerf@@YAXXZ"); import_symbol(0x63650C, "?DashColorScale@@3MA"); import_symbol(0x6A6F1C, "?JoinViaZone@@3HA"); diff --git a/code/midtown/agiworld/texsheet.h b/code/midtown/agiworld/texsheet.h index e5af0122..e9eb95a4 100644 --- a/code/midtown/agiworld/texsheet.h +++ b/code/midtown/agiworld/texsheet.h @@ -117,7 +117,7 @@ class agiTexSheet return prop_count_; } -private: +public: agiTexProp* props_ {}; i32 prop_count_ {}; b32 allow_remapping_ {}; // UseAlternate diff --git a/code/midtown/localize/lang_english.h b/code/midtown/localize/lang_english.h index de068d89..5659350e 100644 --- a/code/midtown/localize/lang_english.h +++ b/code/midtown/localize/lang_english.h @@ -29,7 +29,7 @@ X(MM_IDS_8, "Creating ambients...") X(MM_IDS_9, "Creating pedestrians...") X(MM_IDS_10, "Initializing AI collidables...") X(MM_IDS_11, "Resetting all AI...") -X(MM_IDS_12, "Loading city layout...") +X(MM_IDS_LOADING_CITY_LAYOUT, "Loading city layout...") X(MM_IDS_13, "Loading bangers...") X(MM_IDS_14, "Loading facades...") X(MM_IDS_15, "Gill Sans MT, 12, 24, 0, 400") diff --git a/code/midtown/localize/lang_german.h b/code/midtown/localize/lang_german.h index 990b71e9..44dc1629 100644 --- a/code/midtown/localize/lang_german.h +++ b/code/midtown/localize/lang_german.h @@ -29,7 +29,7 @@ X(MM_IDS_8, "Umgebungen werden erstellt...") X(MM_IDS_9, "Fußgänger werden erstellt...") X(MM_IDS_10, "Kollisions-KI wird initialisiert...") X(MM_IDS_11, "KI wird zurückgesetzt...") -X(MM_IDS_12, "Stadtlayout wird geladen...") +X(MM_IDS_LOADING_CITY_LAYOUT, "Stadtlayout wird geladen...") X(MM_IDS_13, "Klapperkisten werden geladen...") X(MM_IDS_14, "Fassaden werden geladen...") X(MM_IDS_15, "Gill Sans MT, 12, 24, 0, 400") diff --git a/code/midtown/localize/lang_japan.h b/code/midtown/localize/lang_japan.h index 06cb89c9..6120d3ca 100644 --- a/code/midtown/localize/lang_japan.h +++ b/code/midtown/localize/lang_japan.h @@ -29,7 +29,7 @@ X(MM_IDS_8, "背景データを作成中") X(MM_IDS_9, "歩行者データを作成中") X(MM_IDS_10, "障害物データを初期化中") X(MM_IDS_11, "AI をリセット中") -X(MM_IDS_12, "シティー レイアウトをロード中") +X(MM_IDS_LOADING_CITY_LAYOUT, "シティー レイアウトをロード中") X(MM_IDS_13, "車データをロード中") X(MM_IDS_14, "建物データをロード中") X(MM_IDS_15, "MS Pゴシック, 10,14, 128, 400") diff --git a/code/midtown/localize/lang_russian.h b/code/midtown/localize/lang_russian.h index 68dabb2f..7be5507c 100644 --- a/code/midtown/localize/lang_russian.h +++ b/code/midtown/localize/lang_russian.h @@ -29,7 +29,7 @@ X(MM_IDS_8, "Создаю окружение...") X(MM_IDS_9, "Создаю пешеходов...") X(MM_IDS_10, "Считываю данные о просшествиях...") X(MM_IDS_11, "Сброс ИИ...") -X(MM_IDS_12, "Загружаю карту города...") +X(MM_IDS_LOADING_CITY_LAYOUT, "Загружаю карту города...") X(MM_IDS_13, "Загружаю баннеры...") X(MM_IDS_14, "Загружаю фасады...") X(MM_IDS_15, "System, 11, 22, 0, 400") diff --git a/code/midtown/localize/string_ids.h b/code/midtown/localize/string_ids.h index 2c218c65..590abc8c 100644 --- a/code/midtown/localize/string_ids.h +++ b/code/midtown/localize/string_ids.h @@ -29,7 +29,7 @@ #define MM_IDS_9 9 #define MM_IDS_10 10 #define MM_IDS_11 11 -#define MM_IDS_12 12 +#define MM_IDS_LOADING_CITY_LAYOUT 12 #define MM_IDS_13 13 #define MM_IDS_14 14 #define MM_IDS_15 15 diff --git a/code/midtown/mmcity/cullcity.cpp b/code/midtown/mmcity/cullcity.cpp index 167ed1fb..65e09191 100644 --- a/code/midtown/mmcity/cullcity.cpp +++ b/code/midtown/mmcity/cullcity.cpp @@ -20,10 +20,24 @@ define_dummy_symbol(mmcity_cullcity); #include "cullcity.h" +#include "agi/dlptmpl.h" +#include "agi/getdlp.h" #include "agi/rsys.h" #include "agisw/swrend.h" +#include "agiworld/getmesh.h" #include "agiworld/meshset.h" #include "agiworld/quality.h" +#include "agiworld/texsheet.h" +#include "arts7/cullmgr.h" +#include "data7/memstat.h" +#include "localize/localize.h" +#include "mmcityinfo/state.h" +#include "mmdyna/bndtmpl.h" +#include "mmphysics/phys.h" +#include "stream/problems.h" +#include "stream/stream.h" + +#include "loader.h" #ifdef ARTS_DEV_BUILD void mmRunwayLight::AddWidgets(Bank* /*arg1*/) @@ -54,6 +68,9 @@ ARTS_IMPORT /*static*/ void parseRGB(u32& arg1); // ?parseVector3@@YAXAAVVector3@@@Z ARTS_IMPORT /*static*/ void parseVector3(Vector3& arg1); +// ?ShowRenderStats@@YAXXZ +ARTS_IMPORT /*static*/ void ShowRenderStats(); + void mmCullCity::Cull() { if (FogEnd == 0.0f || agiCurState.GetDrawMode() == agiDrawDepth) @@ -85,3 +102,153 @@ void mmCullCity::Cull() } } } + +static agiMeshCardVertex RainMeshCard[4] { + {-0.1f, 2.0f, 0.4f, 1.0f}, + {-0.1f, -2.0f, 0.4f, 0.0f}, + {0.1f, -2.0f, 0.6f, 0.0f}, + {0.1f, 2.0f, 0.6f, 1.0f}, +}; + +void mmCullCity::Init(char* name, asCamera* camera) +{ + char city_path[64]; + char lm_path[64]; + + IsSnowing = (MMSTATE.Weather == mmWeather::Snow); + CityName = arts_strdup(name); + + arts_strcpy(city_path, name); + arts_strcat(city_path, "city"); + + arts_strcpy(lm_path, name); + arts_strcat(lm_path, "lm"); + + TEXSHEET.allow_remapping_ = MMSTATE.TimeOfDay == mmTimeOfDay::Sunset || MMSTATE.TimeOfDay == mmTimeOfDay::Night; + + switch (MMSTATE.Weather) + { + case mmWeather::Rain: TextureSuffix = "_fall"_xconst; break; + case mmWeather::Snow: TextureSuffix = "_win"_xconst; break; + default: TextureSuffix = nullptr; break; + } + + StaticLog = arts_fopen(arts_formatf<64>("%s_static.csv", name), "w"); + + Loader()->BeginTask(LOC_STRING(MM_IDS_LOADING_CITY_LAYOUT), 0.0f); + + DLPTemplate* city_dlp = nullptr; + DLPTemplate* lm_dlp = nullptr; + + if (DevelopmentMode) + { + city_dlp = GetDLPTemplate(city_path); + // if (!city_dlp) + // Quitf("Unable to load city '%s'", name); + + lm_dlp = GetDLPTemplate(lm_path); + } + + BeginMemStat("mmCullCity::Init"); + InitProblems(); + + Camera = camera; + AddChild(&BangerDataManager); + AddChild(&BangerActiveManager); + AddChild(&BangerManager); + AddChild(&asnode34AF0); + AddChild(&PHYS); + AddChild(&RenderWeb); + AddChild(&Particles); + + agiMeshCardVertex* vertex = NULL; + + if (MMSTATE.Weather == mmWeather::Rain) + vertex = RainMeshCard; + else + vertex = agiMeshSet::DefaultQuad; + + Particles.Init(100, 4, 4, 4, vertex); + + SnowBirthRule.SetName("SnowRule"); + AddChild(&SnowBirthRule); + SnowBirthRule.Load(); + + RainBirthRule.SetName("RainRule"); + AddChild(&RainBirthRule); + RainBirthRule.Load(); + + BirthRule = 0; + + Sky.Init("mmsky"_xconst); + Loader()->EndTask(0.0f); + + BeginMemStat("mmCullCity.WEB"); + RenderWeb.Load(name, 1); + EndMemStat(); + + HitIdBound = RenderWeb.HitIdBound; + HitIdBound->AddRef(); + + BuildingChain.Init(RenderWeb.MaxCells); + ObjectsChain.Init(RenderWeb.MaxCells); + ShadowChain.Init(RenderWeb.MaxCells); + + InitObjectDetail(); + + LastInstance = (mmInstance*) mmInstanceHeap.HeapHead; + ResetInst = new mmYInstance(); + + EnableSphereCull = CHICAGO; + + LoadBangers(name); + + switch (MMSTATE.GameMode) + { + case mmGameMode::Cruise: LoadBangers(arts_formatf<64>("%s_roam", name)); break; + case mmGameMode::Checkpoint: LoadBangers(arts_formatf<64>("%s_r%d", name, MMSTATE.EventId)); break; + case mmGameMode::CnR: LoadBangers(arts_formatf<64>("%s_cops", name)); break; + case mmGameMode::Circuit: LoadBangers(arts_formatf<64>("%s_c%d", name, MMSTATE.EventId)); break; + case mmGameMode::Blitz: LoadBangers(arts_formatf<64>("%s_b%d", name, MMSTATE.EventId)); break; + } + + ResetInst = new mmYInstance(); + + LoadFacades(name); + + if (CHICAGO) + { + Vector3 pos_1 = {995.782, 0.173, 1188.804}; + Vector3 pos_2 = {995.782, 0.173, 742.411}; + Vector3 pos_3 = {1015.383, 0.173, 1188.805}; + Vector3 pos_4 = {1015.383, 0.173, 742.411}; + + mmRunwayLight* light_1 = new mmRunwayLight("fxltglow"_xconst, pos_1, pos_2); + mmRunwayLight* light_2 = new mmRunwayLight("fxltglow"_xconst, pos_3, pos_4); + + BuildingChain.Parent(light_1, 35); + BuildingChain.Parent(light_2, 35); + } + + InitTimeOfDayAndWeather(); + + if (IsSnowing) + InitSnowTextures(); + + BangerMgr()->Init(40); + + if (city_dlp && city_dlp->Release()) + Errorf("Someone is still holding a ref on the city's template"); + + if (lm_dlp) + lm_dlp->Release(); + + EndMemStat(); + + CULLMGR->AddPage(ShowRenderStats); + + if (StaticLog) + { + delete StaticLog; + } +} diff --git a/code/midtown/mmcity/cullcity.h b/code/midtown/mmcity/cullcity.h index c2b5ecf3..c4cd74ff 100644 --- a/code/midtown/mmcity/cullcity.h +++ b/code/midtown/mmcity/cullcity.h @@ -106,12 +106,17 @@ 0x6A8E7C | int DisableUpper | ?DisableUpper@@3HA */ +#include "agiworld/texsort.h" #include "arts7/node.h" +#include "mmbangers/active.h" +#include "mmbangers/banger.h" +#include "mmbangers/data.h" #include "vector7/matrix34.h" #include "inst.h" #include "instchn.h" #include "renderweb.h" +#include "sky.h" class agiTexDef; class asCamera; @@ -156,7 +161,7 @@ class mmCullCity final : public asNode ARTS_IMPORT i16 GetRoomFlags(i16 arg1); // ?Init@mmCullCity@@QAEXPADPAVasCamera@@@Z - ARTS_IMPORT void Init(char* arg1, asCamera* arg2); + ARTS_EXPORT void Init(char* name, asCamera* camera); // ?InitObjectDetail@mmCullCity@@QAEXXZ ARTS_IMPORT void InitObjectDetail(); @@ -191,26 +196,6 @@ class mmCullCity final : public asNode // ?GetInstance@mmCullCity@@SAPAV1@XZ | inline ARTS_IMPORT static mmCullCity* GetInstance(); - offset_field(0x20, asCamera*, Camera); - - offset_field(0x2B950, asRenderWeb, RenderWeb); - - offset_field(0x34ACC, mmInstChain, BuildingChain); // StaticChain? - offset_field(0x34AD8, mmInstChain, ObjectsChain); // DynamicChain? - offset_field(0x34AE4, mmInstChain, ShadowChain); - - offset_field(0x34B30, f32, WeatherFriction); - - offset_field(0x34B48, agiTexDef*, ShadowMap); - offset_field(0x34B50, Matrix34, EnvMatrix); - - offset_field(0x34D54, u32, SkyColor); - offset_field(0x34D58, b32, UseFogEnd2); - offset_field(0x34D5C, f32, FogEnd); - offset_field(0x34D60, f32, FogEnd2); - - ARTS_ZEROED; - private: // ?AddInstance@mmCullCity@@AAEXHPAD0HPAVVector3@@11M@Z ARTS_IMPORT void AddInstance( @@ -230,9 +215,48 @@ class mmCullCity final : public asNode // ?Instance@mmCullCity@@0PAV1@A ARTS_IMPORT static mmCullCity* Instance; - u8 gap20[0x34D4C]; +public: + asCamera* Camera; + mmBoundTemplate* HitIdBound; + mmBangerDataManager BangerDataManager; + mmBangerActiveManager BangerActiveManager; + mmBangerManager BangerManager; + mmSky Sky; + asRenderWeb RenderWeb; + agiTexSorter TexSorter; + mmInstChain BuildingChain; + mmInstChain ObjectsChain; + mmInstChain ShadowChain; + asNode asnode34AF0; + i32 field_34B10; + char* CityName; + i32 SnowTextureCount; + i32 CurrentSnowTexture; + agiTexDef** SnowTexturesDst; + agiTexDef** SnowTexturesSrc; + i8* ShowTextureWidthRatios; + i8* SnowTextureHeightRatios; + f32 WeatherFriction; + f32 RainFriction; + f32 SnowFrictionStart; + f32 SnowFrictionMin; + f32 SnowFrictionTime; + f32 SnowTotalElapsed; + agiTexDef* ShadowMap; + agiTexDef* SphereMap; + Matrix34 EnvMatrix; + asParticles Particles; + asBirthRule* BirthRule; + asBirthRule SnowBirthRule; + asBirthRule RainBirthRule; + i32 field_34D50; + u32 SkyColor; + b32 UseFogEnd2; + f32 FogEnd; + f32 FogEnd2; + mmInstance* LastInstance; + mmInstance* ResetInst; }; - check_size(mmCullCity, 0x34D6C); inline mmCullCity* CullCity() @@ -289,9 +313,15 @@ class mmRunwayLight final : public mmInstance // ?Phase@mmRunwayLight@@2MA ARTS_IMPORT static f32 Phase; - u8 gap14[0x4C]; + Vector3 Start; + Vector3 End; + Vector3 Step; + Vector3 Center; + f32 Scale; + i32 NumLights; + i32 Texture; + agiMeshCardInfo MeshCard; }; - check_size(mmRunwayLight, 0x60); // ?fix_clip@@YAXXZ diff --git a/code/midtown/mmcity/heap.h b/code/midtown/mmcity/heap.h index d65fb6d6..78391c32 100644 --- a/code/midtown/mmcity/heap.h +++ b/code/midtown/mmcity/heap.h @@ -30,7 +30,7 @@ template class mmHeap { -private: +public: u8* HeapBase {}; u8* HeapEnd {}; u8* HeapHead {}; diff --git a/code/midtown/mmcity/inst.h b/code/midtown/mmcity/inst.h index 54b0ad89..301d0f3d 100644 --- a/code/midtown/mmcity/inst.h +++ b/code/midtown/mmcity/inst.h @@ -132,9 +132,11 @@ */ #include "data7/base.h" +#include "vector7/matrix34.h" +#include "vector7/vector2.h" +#include "vector7/vector3.h" #include "heap.h" -#include "vector7/matrix34.h" class agiMeshSet; class mmBoundTemplate; @@ -465,7 +467,7 @@ class mmShearInstance final : public mmMatrixInstance // ?DeclareFields@mmShearInstance@@SAXXZ ARTS_IMPORT static void DeclareFields(); - u8 gap44[0x4]; + f32 Scale; }; check_size(mmShearInstance, 0x48); @@ -549,7 +551,9 @@ class mmYInstance : public mmInstance // ?DeclareFields@mmYInstance@@SAXXZ ARTS_IMPORT static void DeclareFields(); - u8 gap14[0x18]; + Vector3 Position; + Vector2 Rotation; + f32 Scale; }; check_size(mmYInstance, 0x2C); diff --git a/code/midtown/mmcity/sky.h b/code/midtown/mmcity/sky.h index 3c970e37..19e98a4d 100644 --- a/code/midtown/mmcity/sky.h +++ b/code/midtown/mmcity/sky.h @@ -56,14 +56,14 @@ class mmSky // ?Color@mmSky@@2IA ARTS_IMPORT static u32 Color; -private: // ?DoFlash@mmSky@@0HA ARTS_IMPORT static i32 DoFlash; // ?Instance@mmSky@@0PAV1@A ARTS_IMPORT static mmSky* Instance; - u8 gap0[0x8]; + f32 RotationSpeed; + f32 Mesh; }; check_size(mmSky, 0x8);