-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1] mmCullCity::Init() #140
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,23 @@ 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 "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*/) | ||
|
@@ -85,3 +98,162 @@ 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 or 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you comment out these two lines? There's a patch in patches.cpp which removes this |
||
|
||
lm_dlp = GetDLPTemplate(lm_path); | ||
} | ||
|
||
BeginMemStat("mmCullCity::Init"); | ||
InitProblems(); | ||
|
||
Camera = camera; | ||
asNode::AddChild(&BangerDataManager); | ||
asNode::AddChild(&BangerActiveManager); | ||
asNode::AddChild(&BangerManager); | ||
asNode::AddChild(&asnode34AF0); | ||
asNode::AddChild(&PHYS); | ||
asNode::AddChild(&RenderWeb); | ||
asNode::AddChild(&Particles); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need the |
||
|
||
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(); | ||
|
||
LoadBangers(name); | ||
|
||
if (MMSTATE.GameMode == mmGameMode::Blitz) | ||
{ | ||
LoadBangers(arts_formatf<64>("%s_b%d", name, MMSTATE.EventId)); | ||
} | ||
else if (MMSTATE.GameMode == mmGameMode::Checkpoint) | ||
{ | ||
LoadBangers(arts_formatf<64>("%s_r%d", name, MMSTATE.EventId)); | ||
} | ||
else if (MMSTATE.GameMode == mmGameMode::Circuit) | ||
{ | ||
LoadBangers(arts_formatf<64>("%s_c%d", name, MMSTATE.EventId)); | ||
} | ||
else if (MMSTATE.GameMode == mmGameMode::Cruise) | ||
{ | ||
LoadBangers(arts_formatf<64>("%s_roam", name)); | ||
} | ||
else if (MMSTATE.GameMode == mmGameMode::CnR) | ||
{ | ||
LoadBangers(arts_formatf<64>("%s_cops", name)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this a switch instead of lots of if-elses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed them to a switch, and also reordered them so they're consistent with the codebase. |
||
|
||
ResetInst = new mmYInstance(); | ||
|
||
LoadFacades(name); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing the |
||
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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code and onwards shouldn't be inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hopefully the new code matches what you intended. In the future it would be nice to have something like this (next to the Chicago case)
|
||
|
||
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(); | ||
|
||
void ShowRenderStats(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing the CULLMGR->AddPage call. Since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the function and the import. |
||
|
||
if (StaticLog) | ||
{ | ||
delete StaticLog; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,49 @@ 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; | ||
u8 gap[0x3]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove this gap, since it's just from alignment padding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought this would mess with the |
||
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 +314,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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
||
, notor