Skip to content

Commit d4f8849

Browse files
authored
Fix inconsistent extra component names (#3645)
1 parent 5ac6c8a commit d4f8849

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

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/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
};

0 commit comments

Comments
 (0)