mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #258 from lioncash/emplaced
General: Make use of emplace_back where applicable
This commit is contained in:
commit
2e43266714
|
@ -30,12 +30,12 @@ bool CSaveWorldIntermediate::InitializePump() {
|
|||
|
||||
x4_strgId = wld.IGetStringTableAssetId();
|
||||
x8_savwId = wld.IGetSaveWorldAssetId();
|
||||
u32 areaCount = wld.IGetAreaCount();
|
||||
const u32 areaCount = wld.IGetAreaCount();
|
||||
|
||||
xc_areaIds.reserve(areaCount);
|
||||
for (u32 i = 0; i < areaCount; ++i) {
|
||||
const IGameArea* area = wld.IGetAreaAlways(i);
|
||||
xc_areaIds.push_back(area->IGetAreaId());
|
||||
xc_areaIds.emplace_back(area->IGetAreaId());
|
||||
}
|
||||
|
||||
CAssetId mlvlId = wld.IGetWorldAssetId();
|
||||
|
|
|
@ -14,13 +14,13 @@ CSaveWorld::CSaveWorld(CInputStream& in) {
|
|||
const u32 cinematicCount = in.readUint32Big();
|
||||
x4_cinematics.reserve(cinematicCount);
|
||||
for (u32 i = 0; i < cinematicCount; ++i) {
|
||||
x4_cinematics.push_back(in.readUint32Big());
|
||||
x4_cinematics.emplace_back(in.readUint32Big());
|
||||
}
|
||||
|
||||
const u32 relayCount = in.readUint32Big();
|
||||
x14_relays.reserve(relayCount);
|
||||
for (u32 i = 0; i < relayCount; ++i) {
|
||||
x14_relays.push_back(in.readUint32Big());
|
||||
x14_relays.emplace_back(in.readUint32Big());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ CSaveWorld::CSaveWorld(CInputStream& in) {
|
|||
const u32 doorCount = in.readUint32Big();
|
||||
x34_doors.reserve(doorCount);
|
||||
for (u32 i = 0; i < doorCount; ++i) {
|
||||
x34_doors.push_back(in.readUint32Big());
|
||||
x34_doors.emplace_back(in.readUint32Big());
|
||||
}
|
||||
|
||||
if (version <= 0) {
|
||||
|
|
|
@ -475,7 +475,7 @@ CHudDecoInterfaceThermal::CHudDecoInterfaceThermal(CGuiFrame& selHud) {
|
|||
if (CGuiWidget* w = selHud.FindWidget("basewidget_lock")) {
|
||||
for (CGuiWidget* c = static_cast<CGuiWidget*>(w->GetChildObject()); c;
|
||||
c = static_cast<CGuiWidget*>(c->GetNextSibling())) {
|
||||
x84_lockonWidgets.push_back({c, c->GetLocalTransform()});
|
||||
x84_lockonWidgets.emplace_back(c, c->GetLocalTransform());
|
||||
c->SetLocalTransform(c->GetLocalTransform() * zeus::CTransform::Scale(x68_lockonScale));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) {
|
|||
baseline = in.readByte();
|
||||
kernStart = in.readInt16Big();
|
||||
}
|
||||
xc_glyphs.push_back(std::make_pair(
|
||||
chr, CGlyph(a, b, c, startU, startV, endU, endV, cellWidth, cellHeight, baseline, kernStart, layer)));
|
||||
xc_glyphs.emplace_back(
|
||||
chr, CGlyph(a, b, c, startU, startV, endU, endV, cellWidth, cellHeight, baseline, kernStart, layer));
|
||||
}
|
||||
|
||||
std::sort(xc_glyphs.begin(), xc_glyphs.end(), [=](auto& a, auto& b) -> bool { return a.first < b.first; });
|
||||
|
|
|
@ -188,7 +188,7 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len,
|
|||
texs.reserve(commaCount - 1);
|
||||
do {
|
||||
AdvanceCommaPos();
|
||||
texs.push_back(x0_store.GetObj({SBIG('TXTR'), GetAssetIdFromString(&iterable[tokenPos], len, txtrMap)}));
|
||||
texs.emplace_back(x0_store.GetObj({SBIG('TXTR'), GetAssetIdFromString(&iterable[tokenPos], len, txtrMap)}));
|
||||
AdvanceTokenPos();
|
||||
} while (commaPos != iterable.size());
|
||||
|
||||
|
@ -211,7 +211,7 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len,
|
|||
texs.reserve(commaCount - 3);
|
||||
do {
|
||||
AdvanceCommaPos();
|
||||
texs.push_back(x0_store.GetObj({SBIG('TXTR'), GetAssetIdFromString(&iterable[tokenPos], len, txtrMap)}));
|
||||
texs.emplace_back(x0_store.GetObj({SBIG('TXTR'), GetAssetIdFromString(&iterable[tokenPos], len, txtrMap)}));
|
||||
AdvanceTokenPos();
|
||||
} while (commaPos != iterable.size());
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ void CTextRenderBuffer::AddImage(const zeus::CVector2i& offset, const CFontImage
|
|||
if (x0_mode == EMode::AllocTally)
|
||||
m_primitiveMarks.push_back({Command::ImageRender, m_imagesCount++, 0});
|
||||
else
|
||||
m_images.push_back({image, offset});
|
||||
m_images.emplace_back(image, offset);
|
||||
}
|
||||
|
||||
void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& offset, char16_t ch, const zeus::CColor& color) {
|
||||
|
@ -209,7 +209,7 @@ void CTextRenderBuffer::AddFontChange(const TToken<CRasterFont>& font) {
|
|||
}
|
||||
|
||||
m_activeFontCh = m_fontCharacters.size();
|
||||
m_fontCharacters.push_back({font});
|
||||
m_fontCharacters.emplace_back(font);
|
||||
}
|
||||
|
||||
bool CTextRenderBuffer::HasSpaceAvailable(const zeus::CVector2i& origin, const zeus::CVector2i& extent) const {
|
||||
|
|
|
@ -19,10 +19,11 @@ CCEKeyframeEmitter::CCEKeyframeEmitter(CInputStream& in) {
|
|||
x10_loopEnd = in.readUint32Big();
|
||||
x14_loopStart = in.readUint32Big();
|
||||
|
||||
u32 count = in.readUint32Big();
|
||||
const u32 count = in.readUint32Big();
|
||||
x18_keys.reserve(count);
|
||||
for (u32 i = 0; i < count; ++i)
|
||||
x18_keys.push_back(in.readVec4fBig());
|
||||
for (u32 i = 0; i < count; ++i) {
|
||||
x18_keys.emplace_back(in.readVec4fBig());
|
||||
}
|
||||
}
|
||||
|
||||
bool CCEKeyframeEmitter::GetValue(int frame, zeus::CColor& valOut) const {
|
||||
|
|
|
@ -333,7 +333,7 @@ void CParticleElectric::CreateNewParticles(int count) {
|
|||
if (CIntElement* slif = x1c_elecDesc->x4_SLIF.get())
|
||||
slif->GetValue(x28_currentFrame, lifetime);
|
||||
|
||||
x3e8_electricManagers.push_back(CParticleElectricManager(allocIdx, lifetime, x28_currentFrame));
|
||||
x3e8_electricManagers.emplace_back(allocIdx, lifetime, x28_currentFrame);
|
||||
CParticleElectricManager& elec = x3e8_electricManagers.back();
|
||||
CParticleGlobals::instance()->SetParticleLifetime(elec.xc_endFrame - elec.x8_startFrame);
|
||||
int frame = x28_currentFrame - elec.x8_startFrame;
|
||||
|
|
|
@ -19,10 +19,11 @@ CVEKeyframeEmitter::CVEKeyframeEmitter(CInputStream& in) {
|
|||
x10_loopEnd = in.readUint32Big();
|
||||
x14_loopStart = in.readUint32Big();
|
||||
|
||||
u32 count = in.readUint32Big();
|
||||
const u32 count = in.readUint32Big();
|
||||
x18_keys.reserve(count);
|
||||
for (u32 i = 0; i < count; ++i)
|
||||
x18_keys.push_back(in.readVec3fBig());
|
||||
for (u32 i = 0; i < count; ++i) {
|
||||
x18_keys.emplace_back(in.readVec3fBig());
|
||||
}
|
||||
}
|
||||
|
||||
bool CVEKeyframeEmitter::GetValue(int frame, zeus::CVector3f& valOut) const {
|
||||
|
|
|
@ -353,28 +353,31 @@ CGameArea::CGameArea(CInputStream& in, int idx, int mlvlVersion) : x4_selfIdx(id
|
|||
else
|
||||
x88_areaId = -1;
|
||||
|
||||
u32 attachedCount = in.readUint32Big();
|
||||
const u32 attachedCount = in.readUint32Big();
|
||||
x8c_attachedAreaIndices.reserve(attachedCount);
|
||||
for (u32 i = 0; i < attachedCount; ++i)
|
||||
x8c_attachedAreaIndices.push_back(in.readUint16Big());
|
||||
for (u32 i = 0; i < attachedCount; ++i) {
|
||||
x8c_attachedAreaIndices.emplace_back(in.readUint16Big());
|
||||
}
|
||||
|
||||
x9c_deps1 = ::urde::ReadDependencyList(in);
|
||||
xac_deps2 = ::urde::ReadDependencyList(in);
|
||||
|
||||
zeus::CAABox aabb = x6c_aabb.getTransformedAABox(xc_transform);
|
||||
const zeus::CAABox aabb = x6c_aabb.getTransformedAABox(xc_transform);
|
||||
x6c_aabb = aabb;
|
||||
|
||||
if (mlvlVersion > 13) {
|
||||
u32 depCount = in.readUint32Big();
|
||||
const u32 depCount = in.readUint32Big();
|
||||
xbc_layerDepOffsets.reserve(depCount);
|
||||
for (u32 i = 0; i < depCount; ++i)
|
||||
xbc_layerDepOffsets.push_back(in.readUint32Big());
|
||||
for (u32 i = 0; i < depCount; ++i) {
|
||||
xbc_layerDepOffsets.emplace_back(in.readUint32Big());
|
||||
}
|
||||
}
|
||||
|
||||
u32 dockCount = in.readUint32Big();
|
||||
const u32 dockCount = in.readUint32Big();
|
||||
xcc_docks.reserve(dockCount);
|
||||
for (u32 i = 0; i < dockCount; ++i)
|
||||
xcc_docks.push_back({in, xc_transform});
|
||||
for (u32 i = 0; i < dockCount; ++i) {
|
||||
xcc_docks.emplace_back(in, xc_transform);
|
||||
}
|
||||
|
||||
ClearTokenList();
|
||||
|
||||
|
|
|
@ -89,10 +89,10 @@ float CScriptPickupGenerator::GetPickupTemplates(CStateManager& mgr,
|
|||
doAlways = true;
|
||||
break;
|
||||
}
|
||||
bool thirtyPercTest = mgr.GetActiveRandom()->Float() < 0.3f;
|
||||
const bool thirtyPercTest = mgr.GetActiveRandom()->Float() < 0.3f;
|
||||
if ((doAlways || (doThirtyPerc && thirtyPercTest)) && possibility > 0.f) {
|
||||
totalPossibility += possibility * multiplier;
|
||||
idsOut.push_back(std::make_pair(possibility, conn.x8_objId));
|
||||
idsOut.emplace_back(possibility, conn.x8_objId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
|||
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
||||
for (auto it = search.first; it != search.second; ++it) {
|
||||
if (TCastToPtr<CActor> act = mgr.ObjectById(it->second)) {
|
||||
x198_ringControllers.push_back(SRingController(it->second, 0.f, false));
|
||||
x198_ringControllers.emplace_back(it->second, 0.f, false);
|
||||
act->RemoveMaterial(EMaterialTypes::Occluder, mgr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ void CScriptTrigger::Touch(CActor& act, CStateManager& mgr) {
|
|||
}
|
||||
|
||||
if (True(testFlags & x12c_flags)) {
|
||||
xe8_inhabitants.push_back(act.GetUniqueId());
|
||||
xe8_inhabitants.emplace_back(act.GetUniqueId());
|
||||
InhabitantAdded(act, mgr);
|
||||
|
||||
if (pl) {
|
||||
|
|
Loading…
Reference in New Issue