Skip to content

Commit 859f7f4

Browse files
authored
Merge branch 'master' into 230724_Add_getLoadedFiles
2 parents 0d5e2e9 + eb66fa2 commit 859f7f4

22 files changed

+125
-73
lines changed

Client/core/CKeyBinds.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,8 @@ CCommandBind* CKeyBinds::FindCommandMatch(const char* szKey, const char* szComma
841841
NullEmptyStrings(szKey, szArguments, szResource, szOriginalScriptKey);
842842

843843
std::string arguments = szArguments ? szArguments : "";
844-
szArguments = SharedUtil::Trim(arguments.data());
844+
if (!arguments.empty())
845+
szArguments = SharedUtil::Trim(arguments.data());
845846

846847
for (KeyBindPtr& bind : m_binds)
847848
{

Client/game_sa/CHandlingManagerSA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9167,7 +9167,7 @@ void CHandlingManagerSA::CheckSuspensionChanges(CHandlingEntry* pEntry) noexcept
91679167

91689168
// Get Handling ID
91699169
const eHandlingTypes eHandling = static_cast<eHandlingTypes>(pEntry->GetVehicleID());
9170-
if (eHandling > HT_MAX)
9170+
if (eHandling >= HT_MAX)
91719171
return;
91729172

91739173
const CHandlingEntrySA* pOriginal = m_pOriginalEntries[eHandling];

Client/game_sa/CPoolsSA.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ CVehicle* CPoolsSA::AddVehicle(CClientVehicle* pClientVehicle, eVehicleTypes eVe
128128
{
129129
pVehicle->m_ucVariant = ucVariation;
130130
pVehicle->m_ucVariant2 = ucVariation2;
131+
132+
pVehicle->DumpVehicleFrames();
131133
}
132134
else
133135
{

Client/game_sa/CStreamingSA.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,3 +503,15 @@ void CStreamingSA::RemoveBigBuildings()
503503
{
504504
(reinterpret_cast<void(__cdecl*)()>(0x4093B0))();
505505
}
506+
507+
void CStreamingSA::LoadScene(const CVector* position)
508+
{
509+
auto CStreaming_LoadScene = (void(__cdecl*)(const CVector*))FUNC_CStreaming_LoadScene;
510+
CStreaming_LoadScene(position);
511+
}
512+
513+
void CStreamingSA::LoadSceneCollision(const CVector* position)
514+
{
515+
auto CStreaming_LoadSceneCollision = (void(__cdecl*)(const CVector*))FUNC_CStreaming_LoadSceneCollision;
516+
CStreaming_LoadSceneCollision(position);
517+
}

Client/game_sa/CStreamingSA.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#define FUNC_LoadAllRequestedModels 0x40EA10
2121
#define FUNC_CStreaming__HasVehicleUpgradeLoaded 0x407820
2222
#define FUNC_CStreaming_RequestSpecialModel 0x409d10
23+
#define FUNC_CStreaming_LoadScene 0x40EB70
24+
#define FUNC_CStreaming_LoadSceneCollision 0x40ED80
2325

2426
struct CArchiveInfo
2527
{
@@ -77,6 +79,9 @@ class CStreamingSA final : public CStreaming
7779
void MakeSpaceFor(std::uint32_t memoryToCleanInBytes) override;
7880
std::uint32_t GetMemoryUsed() const override;
7981

82+
void LoadScene(const CVector* position);
83+
void LoadSceneCollision(const CVector* position);
84+
8085
private:
8186
void AllocateArchive();
8287

Client/game_sa/CVehicleSA.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,6 @@ void CVehicleSA::Init()
186186
}
187187

188188
CopyGlobalSuspensionLinesToPrivate();
189-
190-
// clear our rw frames list
191-
m_ExtraFrames.clear();
192-
// dump the frames
193-
VehicleDump(this);
194-
FinalizeFramesList();
195189
}
196190

197191
CVehicleSA::~CVehicleSA()
@@ -1949,6 +1943,7 @@ void CVehicleSA::AddComponent(RwFrame* pFrame, bool bReadOnly)
19491943
// if the frame is invalid we don't want to be here
19501944
if (!pFrame)
19511945
return;
1946+
19521947
// if the frame already exists ignore it
19531948
if (IsComponentPresent(pFrame->szName) || pFrame->szName == "")
19541949
return;
@@ -1957,23 +1952,22 @@ void CVehicleSA::AddComponent(RwFrame* pFrame, bool bReadOnly)
19571952
// variants have no name field.
19581953
if (strName == "")
19591954
{
1955+
// In MTA variant 255 means no variant
1956+
if ((m_ucVariantCount == 0 && m_ucVariant == 255) || (m_ucVariantCount == 1 && m_ucVariant2 == 255))
1957+
return;
1958+
19601959
// name starts with extra
19611960
strName = "extra_";
1962-
if (m_ucVariantCount == 0)
1963-
{
1964-
// variants are extra_a, extra_b and so on
1965-
strName += ('a' - 1) + m_ucVariant;
1966-
}
1967-
if (m_ucVariantCount == 1)
1968-
{
1969-
// variants are extra_a, extra_b and so on
1970-
strName += ('a' - 1) + m_ucVariant2;
1971-
}
1961+
1962+
// variants are extra_a - extra_f
1963+
strName += 'a' + (m_ucVariantCount == 0 ? m_ucVariant : m_ucVariant2);
1964+
19721965
// increment the variant count ( we assume that the first variant created is variant1 and the second is variant2 )
19731966
m_ucVariantCount++;
19741967
}
1975-
SVehicleFrame frame = SVehicleFrame(pFrame, bReadOnly);
1968+
19761969
// insert our new frame
1970+
SVehicleFrame frame = SVehicleFrame(pFrame, bReadOnly);
19771971
m_ExtraFrames.insert(std::pair<SString, SVehicleFrame>(strName, frame));
19781972
}
19791973

@@ -2001,6 +1995,16 @@ void CVehicleSA::FinalizeFramesList()
20011995
}
20021996
}
20031997

1998+
void CVehicleSA::DumpVehicleFrames()
1999+
{
2000+
// clear our rw frames list
2001+
m_ExtraFrames.clear();
2002+
2003+
// dump the frames
2004+
VehicleDump(this);
2005+
FinalizeFramesList();
2006+
}
2007+
20042008
bool CVehicleSA::SetComponentVisible(const SString& vehicleComponent, bool bRequestVisible)
20052009
{
20062010
SVehicleFrame* pComponent = GetVehicleComponent(vehicleComponent);

Client/game_sa/CVehicleSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,4 +687,5 @@ class CVehicleSA : public virtual CVehicle, public virtual CPhysicalSA
687687
void CopyGlobalSuspensionLinesToPrivate();
688688
SVehicleFrame* GetVehicleComponent(const SString& vehicleComponent);
689689
void FinalizeFramesList();
690+
void DumpVehicleFrames();
690691
};

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,47 +1247,44 @@ bool CStaticFunctionDefinitions::SetElementAngularVelocity(CClientEntity& Entity
12471247

12481248
bool CStaticFunctionDefinitions::SetElementParent(CClientEntity& Entity, CClientEntity& Parent, CLuaMain* pLuaMain)
12491249
{
1250-
if (&Entity != &Parent && !Entity.IsMyChild(&Parent, true))
1250+
if (&Entity == &Parent || Entity.IsMyChild(&Parent, true))
1251+
return false;
1252+
1253+
if (Entity.GetType() == CCLIENTCAMERA || Parent.GetType() == CCLIENTCAMERA)
1254+
return false;
1255+
1256+
if (Entity.GetType() == CCLIENTGUI)
12511257
{
1252-
if (Entity.GetType() == CCLIENTCAMERA || Parent.GetType() == CCLIENTCAMERA)
1253-
{
1258+
if (Parent.GetType() != CCLIENTGUI && &Parent != pLuaMain->GetResource()->GetResourceGUIEntity())
12541259
return false;
1255-
}
1256-
else if (Entity.GetType() == CCLIENTGUI)
1257-
{
1258-
if (Parent.GetType() == CCLIENTGUI || &Parent == pLuaMain->GetResource()->GetResourceGUIEntity())
1259-
{
1260-
CClientGUIElement& GUIElement = static_cast<CClientGUIElement&>(Entity);
12611260

1262-
GUIElement.SetParent(&Parent);
1263-
return true;
1264-
}
1265-
}
1266-
else
1267-
{
1268-
CClientEntity* pTemp = &Parent;
1269-
CClientEntity* pRoot = m_pRootEntity;
1270-
bool bValidParent = false;
1271-
while (pTemp != pRoot && pTemp != NULL)
1272-
{
1273-
const char* szTypeName = pTemp->GetTypeName();
1274-
if (szTypeName && strcmp(szTypeName, "map") == 0)
1275-
{
1276-
bValidParent = true; // parents must be a map
1277-
break;
1278-
}
1261+
CClientGUIElement& GUIElement = static_cast<CClientGUIElement&>(Entity);
12791262

1280-
pTemp = pTemp->GetParent();
1281-
}
1263+
GUIElement.SetParent(&Parent);
1264+
return true;
1265+
}
12821266

1283-
// Make sure the entity we move is a client entity or we get a problem
1284-
if (bValidParent && Entity.IsLocalEntity())
1285-
{
1286-
// Set the new parent
1287-
Entity.SetParent(&Parent);
1288-
return true;
1289-
}
1267+
CClientEntity* pTemp = &Parent;
1268+
CClientEntity* pRoot = m_pRootEntity;
1269+
bool bValidParent = false;
1270+
while (pTemp != pRoot && pTemp != NULL)
1271+
{
1272+
const char* szTypeName = pTemp->GetTypeName();
1273+
if (szTypeName && strcmp(szTypeName, "map") == 0)
1274+
{
1275+
bValidParent = true; // parents must be a map
1276+
break;
12901277
}
1278+
1279+
pTemp = pTemp->GetParent();
1280+
}
1281+
1282+
// Make sure the entity we move is a client entity or we get a problem
1283+
if (bValidParent && Entity.IsLocalEntity())
1284+
{
1285+
// Set the new parent
1286+
Entity.SetParent(&Parent);
1287+
return true;
12911288
}
12921289

12931290
return false;

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,12 @@ ADD_ENUM(eModelLoadState::LOADSTATE_READING, "reading")
912912
ADD_ENUM(eModelLoadState::LOADSTATE_FINISHING, "finishing")
913913
IMPLEMENT_ENUM_CLASS_END("model-load-state")
914914

915+
IMPLEMENT_ENUM_CLASS_BEGIN(PreloadAreaOption)
916+
ADD_ENUM(PreloadAreaOption::MODELS, "models")
917+
ADD_ENUM(PreloadAreaOption::COLLISIONS, "collisions")
918+
ADD_ENUM(PreloadAreaOption::ALL, "all")
919+
IMPLEMENT_ENUM_CLASS_END("preload-area-option")
920+
915921
//
916922
// CResource from userdata
917923
//

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ DECLARE_ENUM(ePools);
8989
DECLARE_ENUM(eWorldProperty);
9090
DECLARE_ENUM_CLASS(CResourceFile::eResourceCategory);
9191
DECLARE_ENUM_CLASS(eModelLoadState);
92+
DECLARE_ENUM_CLASS(PreloadAreaOption);
9293

9394
class CRemoteCall;
9495

0 commit comments

Comments
 (0)