1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 02:12:45 +01:00

Set ptr to const if possible

Also:
- make args name matching in header
and source file,
- make more ptrs to const ref,
This commit is contained in:
Filip Gawin 2018-05-16 19:13:11 +02:00
parent 4e1948c23c
commit 09c5d36398
14 changed files with 29 additions and 29 deletions

View File

@ -79,22 +79,22 @@ GameWorld::~GameWorld() {
}
}
bool GameWorld::placeItems(const std::string& path) {
bool GameWorld::placeItems(const std::string& name) {
LoaderIPL ipll;
if (ipll.load(path)) {
if (ipll.load(name)) {
// Find the object.
for (const auto &inst : ipll.m_instances) {
if (!createInstance(inst->id, inst->pos, inst->rot)) {
logger->error("World", "No object data for instance " +
std::to_string(inst->id) + " in " +
path);
name);
}
}
return true;
} else {
logger->error("Data", "Failed to load IPL " + path);
logger->error("Data", "Failed to load IPL " + name);
return false;
}

View File

@ -12,7 +12,7 @@
#include "data/CutsceneData.hpp"
#include "platform/FileHandle.hpp"
void LoaderCutsceneDAT::load(CutsceneTracks &tracks, FileHandle file) {
void LoaderCutsceneDAT::load(CutsceneTracks &tracks, const FileHandle& file) {
std::string dataStr(file->data, file->length);
std::stringstream ss(dataStr);

View File

@ -7,7 +7,7 @@ struct CutsceneTracks;
class LoaderCutsceneDAT {
public:
void load(CutsceneTracks& tracks, FileHandle file);
void load(CutsceneTracks& tracks, const FileHandle& file);
};
#endif

View File

@ -9,7 +9,7 @@
#include "data/GameTexts.hpp"
void LoaderGXT::load(GameTexts &texts, FileHandle &file) {
void LoaderGXT::load(GameTexts &texts, const FileHandle &file) {
auto data = file->data;
data += 4; // TKEY

View File

@ -6,7 +6,7 @@ class GameTexts;
class LoaderGXT {
public:
void load(GameTexts& texts, FileHandle& file);
void load(GameTexts& texts, const FileHandle& file);
};
#endif

View File

@ -6,7 +6,7 @@
#include "engine/Animator.hpp"
CutsceneObject::CutsceneObject(GameWorld *engine, const glm::vec3 &pos,
const glm::quat &rot, ClumpPtr model,
const glm::quat &rot, const ClumpPtr& model,
BaseModelInfo *modelinfo)
: GameObject(engine, pos, rot, modelinfo)
, _parent(nullptr)

View File

@ -19,7 +19,7 @@ class CutsceneObject : public GameObject, public ClumpObject {
public:
CutsceneObject(GameWorld* engine, const glm::vec3& pos,
const glm::quat& rot, ClumpPtr model,
const glm::quat& rot, const ClumpPtr& model,
BaseModelInfo* modelinfo);
~CutsceneObject() override;

View File

@ -42,7 +42,7 @@ void ModelFrame::updateHierarchyTransform() {
}
}
void ModelFrame::addChild(ModelFramePtr child) {
void ModelFrame::addChild(const ModelFramePtr& child) {
// Make sure the child is an orphan
if (child->getParent()) {
auto& other_children = child->getParent()->children_;

View File

@ -87,7 +87,7 @@ public:
return parent_;
}
void addChild(ModelFramePtr child);
void addChild(const ModelFramePtr& child);
const std::vector<ModelFramePtr>& getChildren() const {
return children_;
@ -259,7 +259,7 @@ public:
return boundingRadius;
}
void addAtomic(AtomicPtr& atomic) {
void addAtomic(const AtomicPtr& atomic) {
atomics_.push_back(atomic);
}
@ -267,7 +267,7 @@ public:
return atomics_;
}
void setFrame(ModelFramePtr& root) {
void setFrame(const ModelFramePtr& root) {
rootframe_ = root;
}

View File

@ -270,7 +270,7 @@ GeometryPtr LoaderDFF::readGeometry(const RWBStream &stream) {
return geom;
}
void LoaderDFF::readMaterialList(GeometryPtr &geom, const RWBStream &stream) {
void LoaderDFF::readMaterialList(const GeometryPtr &geom, const RWBStream &stream) {
auto listStream = stream.getInnerStream();
auto listStructID = listStream.getNextChunk();
@ -294,7 +294,7 @@ void LoaderDFF::readMaterialList(GeometryPtr &geom, const RWBStream &stream) {
}
}
void LoaderDFF::readMaterial(GeometryPtr &geom, const RWBStream &stream) {
void LoaderDFF::readMaterial(const GeometryPtr &geom, const RWBStream &stream) {
auto materialStream = stream.getInnerStream();
auto matStructID = materialStream.getNextChunk();
@ -367,7 +367,7 @@ void LoaderDFF::readTexture(Geometry::Material &material,
material.textures.emplace_back(std::move(name), std::move(alpha), textureinst);
}
void LoaderDFF::readGeometryExtension(GeometryPtr &geom,
void LoaderDFF::readGeometryExtension(const GeometryPtr &geom,
const RWBStream &stream) {
auto extStream = stream.getInnerStream();
@ -383,7 +383,7 @@ void LoaderDFF::readGeometryExtension(GeometryPtr &geom,
}
}
void LoaderDFF::readBinMeshPLG(GeometryPtr &geom, const RWBStream &stream) {
void LoaderDFF::readBinMeshPLG(const GeometryPtr &geom, const RWBStream &stream) {
auto data = stream.getCursor();
geom->facetype = static_cast<Geometry::FaceType>(bit_cast<std::uint32_t>(*data));
@ -454,7 +454,7 @@ AtomicPtr LoaderDFF::readAtomic(FrameList &framelist,
return atomic;
}
ClumpPtr LoaderDFF::loadFromMemory(FileHandle file) {
ClumpPtr LoaderDFF::loadFromMemory(const FileHandle& file) {
auto model = std::make_shared<Clump>();
RWBStream rootStream(file->data, file->length);

View File

@ -31,7 +31,7 @@ public:
using GeometryList = std::vector<GeometryPtr>;
using FrameList = std::vector<ModelFramePtr>;
ClumpPtr loadFromMemory(FileHandle file);
ClumpPtr loadFromMemory(const FileHandle& file);
void setTextureLookupCallback(const TextureLookupCallback& tlc) {
texturelookup = tlc;
@ -46,15 +46,15 @@ private:
GeometryPtr readGeometry(const RWBStream& stream);
void readMaterialList(GeometryPtr& geom, const RWBStream& stream);
void readMaterialList(const GeometryPtr& geom, const RWBStream& stream);
void readMaterial(GeometryPtr& geom, const RWBStream& stream);
void readMaterial(const GeometryPtr& geom, const RWBStream& stream);
void readTexture(Geometry::Material& material, const RWBStream& stream);
void readGeometryExtension(GeometryPtr& geom, const RWBStream& stream);
void readGeometryExtension(const GeometryPtr& geom, const RWBStream& stream);
void readBinMeshPLG(GeometryPtr& geom, const RWBStream& stream);
void readBinMeshPLG(const GeometryPtr& geom, const RWBStream& stream);
AtomicPtr readAtomic(FrameList& framelist, GeometryList& geometrylist,
const RWBStream& stream);

View File

@ -29,9 +29,9 @@ typedef struct {
} data;
} WaveHeader;
bool LoaderSDT::load(const std::string& baseName) {
const auto sdtName = baseName + ".SDT";
const auto rawName = baseName + ".RAW";
bool LoaderSDT::load(const std::string& filename) {
const auto sdtName = filename + ".SDT";
const auto rawName = filename + ".RAW";
FILE* fp = fopen(sdtName.c_str(), "rb");
if (fp) {

View File

@ -172,7 +172,7 @@ TextureData::Handle createTexture(RW::BSTextureNative& texNative,
transparent);
}
bool TextureLoader::loadFromMemory(FileHandle file,
bool TextureLoader::loadFromMemory(const FileHandle& file,
TextureArchive& inTextures) {
auto data = file->data;
RW::BinaryStreamSection root(data);

View File

@ -6,7 +6,7 @@
class TextureLoader {
public:
bool loadFromMemory(FileHandle file, TextureArchive& inTextures);
bool loadFromMemory(const FileHandle& file, TextureArchive& inTextures);
};
#endif