From ac0ad1b0262a1fb701e7599000683f67a61e4963 Mon Sep 17 00:00:00 2001 From: Vsevolod Kremianskii Date: Tue, 10 Nov 2020 14:49:01 +0700 Subject: [PATCH] refactor: Move PthFile and DlgFile into game namespace --- CMakeLists.txt | 12 ++-- src/{resource/dlgfile.cpp => game/dialog.cpp} | 28 ++++---- src/{resource/dlgfile.h => game/dialog.h} | 20 +++--- src/game/game.cpp | 2 +- src/game/game.h | 2 +- src/game/gui/dialog.cpp | 68 +++++++++---------- src/game/gui/dialog.h | 10 +-- src/game/gui/saveload.cpp | 16 ++--- src/game/gui/saveload.h | 4 +- src/game/object/area.cpp | 6 +- src/{resource/pthfile.cpp => game/path.cpp} | 10 +-- src/{resource/pthfile.h => game/path.h} | 16 ++--- src/game/pathfinder.cpp | 6 +- src/game/pathfinder.h | 4 +- src/game/{savfile.cpp => savedgame.cpp} | 12 ++-- src/game/{savfile.h => savedgame.h} | 8 +-- src/render/mesh/mesh.h | 8 +-- src/render/model/animation.h | 4 +- src/render/model/model.h | 2 +- tests/pathfinder.cpp | 4 +- 20 files changed, 122 insertions(+), 120 deletions(-) rename src/{resource/dlgfile.cpp => game/dialog.cpp} (81%) rename src/{resource/dlgfile.h => game/dialog.h} (82%) rename src/{resource/pthfile.cpp => game/path.cpp} (91%) rename src/{resource/pthfile.h => game/path.h} (81%) rename src/game/{savfile.cpp => savedgame.cpp} (89%) rename src/game/{savfile.h => savedgame.h} (86%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e452e36..964baf20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,14 +90,12 @@ set(RESOURCE_HEADERS src/resource/2dafile.h src/resource/biffile.h src/resource/binfile.h - src/resource/dlgfile.h src/resource/erffile.h src/resource/folder.h src/resource/gfffile.h src/resource/keyfile.h src/resource/lytfile.h src/resource/pefile.h - src/resource/pthfile.h src/resource/resources.h src/resource/rimfile.h src/resource/tlkfile.h @@ -109,14 +107,12 @@ set(RESOURCE_SOURCES src/resource/2dafile.cpp src/resource/biffile.cpp src/resource/binfile.cpp - src/resource/dlgfile.cpp src/resource/erffile.cpp src/resource/folder.cpp src/resource/gfffile.cpp src/resource/keyfile.cpp src/resource/lytfile.cpp src/resource/pefile.cpp - src/resource/pthfile.cpp src/resource/rimfile.cpp src/resource/resources.cpp src/resource/tlkfile.cpp @@ -366,6 +362,7 @@ set(GAME_HEADERS src/game/collisiondetect.h src/game/console.h src/game/cursors.h + src/game/dialog.h src/game/game.h src/game/gui/chargen/chargen.h src/game/gui/chargen/classselect.h @@ -407,13 +404,14 @@ set(GAME_HEADERS src/game/object/waypoint.h src/game/objectselect.h src/game/party.h + src/game/path.h src/game/pathfinder.h src/game/player.h src/game/portraits.h src/game/room.h src/game/rp/classes.h src/game/rp/types.h - src/game/savfile.h + src/game/savedgame.h src/game/script/routines.h src/game/script/util.h src/game/types.h) @@ -445,6 +443,7 @@ set(GAME_SOURCES src/game/collisiondetect.cpp src/game/console.cpp src/game/cursors.cpp + src/game/dialog.cpp src/game/game.cpp src/game/gui/chargen/chargen.cpp src/game/gui/chargen/classselect.cpp @@ -485,12 +484,13 @@ set(GAME_SOURCES src/game/object/waypoint.cpp src/game/objectselect.cpp src/game/party.cpp + src/game/path.cpp src/game/pathfinder.cpp src/game/player.cpp src/game/portraits.cpp src/game/room.cpp src/game/rp/classes.cpp - src/game/savfile.cpp + src/game/savedgame.cpp src/game/script/routines.cpp src/game/script/routines_common.cpp src/game/script/routines_kotor.cpp diff --git a/src/resource/dlgfile.cpp b/src/game/dialog.cpp similarity index 81% rename from src/resource/dlgfile.cpp rename to src/game/dialog.cpp index 36c87b99..ccf740cf 100644 --- a/src/resource/dlgfile.cpp +++ b/src/game/dialog.cpp @@ -15,26 +15,28 @@ * along with this program. If not, see . */ -#include "dlgfile.h" +#include "dialog.h" #include -#include "resources.h" +#include "../resource/resources.h" using namespace std; +using namespace reone::resource; + namespace reone { -namespace resource { +namespace game { -void DlgFile::reset() { +void Dialog::reset() { _entries.clear(); _replies.clear(); _startEntries.clear(); _endScript.clear(); } -void DlgFile::load(const string &resRef, const GffStruct &dlg) { +void Dialog::load(const string &resRef, const GffStruct &dlg) { _skippable = dlg.getInt("Skippable") != 0; _cameraModel = dlg.getString("CameraModel"); _endScript = dlg.getString("EndConversation"); @@ -50,7 +52,7 @@ void DlgFile::load(const string &resRef, const GffStruct &dlg) { } } -DlgFile::EntryReplyLink DlgFile::getEntryReplyLink(const GffStruct &gffs) const { +Dialog::EntryReplyLink Dialog::getEntryReplyLink(const GffStruct &gffs) const { EntryReplyLink link; link.index = gffs.getInt("Index"); link.active = gffs.getString("Active"); @@ -58,7 +60,7 @@ DlgFile::EntryReplyLink DlgFile::getEntryReplyLink(const GffStruct &gffs) const return move(link); } -DlgFile::EntryReply DlgFile::getEntryReply(const GffStruct &gffs) const { +Dialog::EntryReply Dialog::getEntryReply(const GffStruct &gffs) const { int strRef = gffs.getInt("Text"); EntryReply entry; @@ -93,27 +95,27 @@ DlgFile::EntryReply DlgFile::getEntryReply(const GffStruct &gffs) const { return move(entry); } -bool DlgFile::isSkippable() const { +bool Dialog::isSkippable() const { return _skippable; } -const string &DlgFile::cameraModel() const { +const string &Dialog::cameraModel() const { return _cameraModel; } -const vector &DlgFile::startEntries() const { +const vector &Dialog::startEntries() const { return _startEntries; } -const DlgFile::EntryReply &DlgFile::getEntry(int index) const { +const Dialog::EntryReply &Dialog::getEntry(int index) const { return _entries[index]; } -const DlgFile::EntryReply &DlgFile::getReply(int index) const { +const Dialog::EntryReply &Dialog::getReply(int index) const { return _replies[index]; } -const string &DlgFile::endScript() const { +const string &Dialog::endScript() const { return _endScript; } diff --git a/src/resource/dlgfile.h b/src/game/dialog.h similarity index 82% rename from src/resource/dlgfile.h rename to src/game/dialog.h index 7d2e8207..2931ce6b 100644 --- a/src/resource/dlgfile.h +++ b/src/game/dialog.h @@ -20,17 +20,17 @@ #include #include -#include "gfffile.h" +#include "../resource/gfffile.h" namespace reone { -namespace resource { +namespace game { enum DialogWaitFlags { kDialogWaitAnimFinish = 1 }; -class DlgFile { +class Dialog { public: struct EntryReplyLink { int index { 0 }; @@ -53,10 +53,10 @@ public: std::vector entries; }; - DlgFile() = default; + Dialog() = default; void reset(); - void load(const std::string &resRef, const GffStruct &dlg); + void load(const std::string &resRef, const resource::GffStruct &dlg); bool isSkippable() const; const std::string &cameraModel() const; @@ -74,13 +74,13 @@ private: std::string _endScript; int _entryIndex { -1 }; - DlgFile(const DlgFile &) = delete; - DlgFile &operator=(const DlgFile &) = delete; + Dialog(const Dialog &) = delete; + Dialog &operator=(const Dialog &) = delete; - EntryReplyLink getEntryReplyLink(const GffStruct &gffs) const; - EntryReply getEntryReply(const GffStruct &gffs) const; + EntryReplyLink getEntryReplyLink(const resource::GffStruct &gffs) const; + EntryReply getEntryReply(const resource::GffStruct &gffs) const; }; -} // namespace resource +} // namespace game } // namespace reone diff --git a/src/game/game.cpp b/src/game/game.cpp index 466ec143..d0d071d1 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -317,7 +317,7 @@ void Game::loadHUD() { } void Game::loadDialog() { - _dialog.reset(new Dialog(this)); + _dialog.reset(new DialogGUI(this)); _dialog->load(); } diff --git a/src/game/game.h b/src/game/game.h index ea99f9f3..96ec409b 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -178,7 +178,7 @@ private: std::unique_ptr _charGen; std::unique_ptr _hud; std::unique_ptr _inGame; - std::unique_ptr _dialog; + std::unique_ptr _dialog; std::unique_ptr _container; std::unique_ptr _partySelect; std::unique_ptr _saveLoad; diff --git a/src/game/gui/dialog.cpp b/src/game/gui/dialog.cpp index 8ebc1ceb..c9b7a273 100644 --- a/src/game/gui/dialog.cpp +++ b/src/game/gui/dialog.cpp @@ -23,11 +23,11 @@ #include "../../audio/files.h" #include "../../audio/player.h" +#include "../../common/random.h" #include "../../gui/control/listbox.h" #include "../../gui/control/panel.h" #include "../../resource/resources.h" #include "../../script/execution.h" -#include "../../common/random.h" #include "../game.h" #include "../script/routines.h" @@ -54,7 +54,7 @@ enum EndEntryFlags { kEndEntryOnAudioStop = 2 }; -Dialog::Dialog(Game *game) : +DialogGUI::DialogGUI(Game *game) : GUI(game->version(), game->options().graphics), _game(game) { @@ -65,7 +65,7 @@ Dialog::Dialog(Game *game) : _scaling = ScalingMode::Stretch; } -void Dialog::load() { +void DialogGUI::load() { GUI::load(); configureMessage(); @@ -74,11 +74,11 @@ void Dialog::load() { loadBottomFrame(); } -void Dialog::loadTopFrame() { +void DialogGUI::loadTopFrame() { addFrame(-_rootControl->extent().top, getControl("LBL_MESSAGE").extent().height); } -void Dialog::addFrame(int top, int height) { +void DialogGUI::addFrame(int top, int height) { unique_ptr frame(new Panel(this)); Control::Extent extent; @@ -93,14 +93,14 @@ void Dialog::addFrame(int top, int height) { _controls.insert(_controls.begin(), move(frame)); } -void Dialog::loadBottomFrame() { +void DialogGUI::loadBottomFrame() { int rootTop = _rootControl->extent().top; int height = _gfxOpts.height - rootTop; addFrame(_gfxOpts.height - rootTop - height, height); } -void Dialog::configureMessage() { +void DialogGUI::configureMessage() { Control &message = getControl("LBL_MESSAGE"); Control::Extent extent(message.extent()); @@ -110,7 +110,7 @@ void Dialog::configureMessage() { message.setTextColor(getBaseColor(_version)); } -void Dialog::configureReplies() { +void DialogGUI::configureReplies() { ListBox &replies = static_cast(getControl("LB_REPLIES")); Control &protoItem = replies.protoItem(); @@ -118,18 +118,18 @@ void Dialog::configureReplies() { protoItem.setTextColor(getBaseColor(_version)); } -void Dialog::onReplyClicked(int index) { +void DialogGUI::onReplyClicked(int index) { pickReply(index); } -void Dialog::onListBoxItemClick(const string &control, const string &item) { +void DialogGUI::onListBoxItemClick(const string &control, const string &item) { if (control != "LB_REPLIES") return; int replyIdx = stoi(item); onReplyClicked(replyIdx); } -void Dialog::startDialog(SpatialObject &owner, const string &resRef) { +void DialogGUI::startDialog(SpatialObject &owner, const string &resRef) { shared_ptr dlg(Resources::instance().getGFF(resRef, ResourceType::Conversation)); if (!dlg) { _game->openInGame(); @@ -138,14 +138,14 @@ void Dialog::startDialog(SpatialObject &owner, const string &resRef) { _owner = &owner; _currentSpeaker = _owner; - _dialog.reset(new DlgFile()); + _dialog.reset(new Dialog()); _dialog->load(resRef, *dlg); loadAnimatedCamera(); loadStartEntry(); } -void Dialog::loadAnimatedCamera() { +void DialogGUI::loadAnimatedCamera() { string modelResRef(_dialog->cameraModel()); if (modelResRef.empty()) return; @@ -153,7 +153,7 @@ void Dialog::loadAnimatedCamera() { camera.setModel(modelResRef); } -void Dialog::loadStartEntry() { +void DialogGUI::loadStartEntry() { int entryIdx = -1; for (auto &link : _dialog->startEntries()) { if (link.active.empty()) { @@ -169,16 +169,16 @@ void Dialog::loadStartEntry() { _game->openInGame(); return; } - _currentEntry.reset(new DlgFile::EntryReply(_dialog->getEntry(entryIdx))); + _currentEntry.reset(new Dialog::EntryReply(_dialog->getEntry(entryIdx))); loadCurrentEntry(); } -bool Dialog::checkCondition(const string &script) { +bool DialogGUI::checkCondition(const string &script) { int result = runScript(script, _owner->id(), kObjectInvalid, -1); return result == -1 || result == 1; } -void Dialog::loadCurrentEntry() { +void DialogGUI::loadCurrentEntry() { if (!_currentEntry->script.empty()) { runScript(_currentEntry->script, _owner->id(), kObjectInvalid, -1); } @@ -192,7 +192,7 @@ void Dialog::loadCurrentEntry() { updateCamera(); } -void Dialog::loadReplies() { +void DialogGUI::loadReplies() { ListBox &replies = static_cast(getControl("LB_REPLIES")); replies.clear(); @@ -206,7 +206,7 @@ void Dialog::loadReplies() { bool singleEmptyReply = false; int replyNumber = 0; for (auto &replyIdx : activeReplies) { - const DlgFile::EntryReply &reply = _dialog->getReply(replyIdx); + const Dialog::EntryReply &reply = _dialog->getReply(replyIdx); string text(reply.text); if (text.empty()) { if (activeReplies.size() == 1) { @@ -229,7 +229,7 @@ void Dialog::loadReplies() { } } -void Dialog::finish() { +void DialogGUI::finish() { if (!_dialog->endScript().empty()) { runScript(_dialog->endScript(), _owner->id(), kObjectInvalid, -1); } @@ -239,7 +239,7 @@ void Dialog::finish() { _game->openInGame(); } -void Dialog::loadCurrentSpeaker() { +void DialogGUI::loadCurrentSpeaker() { shared_ptr area(_game->module()->area()); SpatialObject *speaker = nullptr; @@ -265,7 +265,7 @@ void Dialog::loadCurrentSpeaker() { speakerCreature.face(*partyLeader); } -void Dialog::updateCamera() { +void DialogGUI::updateCamera() { shared_ptr area(_game->module()->area()); shared_ptr partyLeader(_game->party().leader()); glm::vec3 listenerPosition; @@ -294,7 +294,7 @@ void Dialog::updateCamera() { } } -DialogCamera::Variant Dialog::getRandomCameraVariant() const { +DialogCamera::Variant DialogGUI::getRandomCameraVariant() const { int r = random(0, 2); switch (r) { case 0: @@ -306,7 +306,7 @@ DialogCamera::Variant Dialog::getRandomCameraVariant() const { } } -void Dialog::playVoiceOver() { +void DialogGUI::playVoiceOver() { if (_currentVoice) { _currentVoice->stop(); _currentVoice.reset(); @@ -324,7 +324,7 @@ void Dialog::playVoiceOver() { } } -void Dialog::scheduleEndOfEntry() { +void DialogGUI::scheduleEndOfEntry() { _entryEnded = false; _endEntryFlags = 0; @@ -346,8 +346,8 @@ void Dialog::scheduleEndOfEntry() { _endEntryTimestamp = now + kDefaultEntryDuration; } -void Dialog::pickReply(uint32_t index) { - const DlgFile::EntryReply &reply = _dialog->getReply(index); +void DialogGUI::pickReply(uint32_t index) { + const Dialog::EntryReply &reply = _dialog->getReply(index); if (!reply.script.empty()) { runScript(reply.script, _owner->id(), kObjectInvalid, -1); @@ -370,12 +370,12 @@ void Dialog::pickReply(uint32_t index) { } if (entryIdx != -1) { - _currentEntry.reset(new DlgFile::EntryReply(_dialog->getEntry(entryIdx))); + _currentEntry.reset(new Dialog::EntryReply(_dialog->getEntry(entryIdx))); loadCurrentEntry(); } } -bool Dialog::handle(const SDL_Event &event) { +bool DialogGUI::handle(const SDL_Event &event) { if (!_entryEnded && _dialog->isSkippable() && event.type == SDL_MOUSEBUTTONUP && @@ -388,7 +388,7 @@ bool Dialog::handle(const SDL_Event &event) { return GUI::handle(event); } -void Dialog::endCurrentEntry() { +void DialogGUI::endCurrentEntry() { _entryEnded = true; if (_currentVoice) { @@ -404,11 +404,11 @@ void Dialog::endCurrentEntry() { } } -bool Dialog::handleKeyDown(SDL_Scancode key) { +bool DialogGUI::handleKeyDown(SDL_Scancode key) { return false; } -bool Dialog::handleKeyUp(SDL_Scancode key) { +bool DialogGUI::handleKeyUp(SDL_Scancode key) { if (!_entryEnded) return false; if (key >= SDL_SCANCODE_1 && key <= SDL_SCANCODE_9) { @@ -424,7 +424,7 @@ bool Dialog::handleKeyUp(SDL_Scancode key) { return false; } -void Dialog::update(float dt) { +void DialogGUI::update(float dt) { GUI::update(dt); if (!_entryEnded) { @@ -450,7 +450,7 @@ void Dialog::update(float dt) { } } -Camera &Dialog::camera() const { +Camera &DialogGUI::camera() const { string cameraModel(_dialog->cameraModel()); shared_ptr area(_game->module()->area()); diff --git a/src/game/gui/dialog.h b/src/game/gui/dialog.h index eaa36735..34b37320 100644 --- a/src/game/gui/dialog.h +++ b/src/game/gui/dialog.h @@ -19,10 +19,10 @@ #include "../../audio/soundinstance.h" #include "../../gui/gui.h" -#include "../../resource/dlgfile.h" #include "../../resource/types.h" #include "../camera/dialogcamera.h" +#include "../dialog.h" #include "../object/spatial.h" namespace reone { @@ -31,9 +31,9 @@ namespace game { class Game; -class Dialog : public gui::GUI { +class DialogGUI : public gui::GUI { public: - Dialog(Game *game); + DialogGUI(Game *game); void load() override; void startDialog(SpatialObject &owner, const std::string &resRef); @@ -47,8 +47,8 @@ public: private: Game *_game { nullptr }; SpatialObject *_owner { nullptr }; - std::shared_ptr _dialog; - std::shared_ptr _currentEntry; + std::shared_ptr _dialog; + std::shared_ptr _currentEntry; std::shared_ptr _currentVoice; SpatialObject *_currentSpeaker { nullptr }; int _autoPickReplyIdx { -1 }; diff --git a/src/game/gui/saveload.cpp b/src/game/gui/saveload.cpp index 9820e188..e5623683 100644 --- a/src/game/gui/saveload.cpp +++ b/src/game/gui/saveload.cpp @@ -19,12 +19,12 @@ #include +#include "../../common/log.h" #include "../../gui/control/listbox.h" #include "../../resource/resources.h" -#include "../../common/log.h" #include "../game.h" -#include "../savfile.h" +#include "../savedgame.h" #include "colors.h" @@ -133,10 +133,10 @@ void SaveLoad::indexSavedGame(int index, const fs::path &path) { warn("SaveLoad: SAV file not found"); return; } - SavFile sav(savPath); + SavedGame sav(savPath); sav.peek(); - SavedGame save; + GameDescriptor save; save.index = index; save.path = savPath; save.name = sav.name(); @@ -216,7 +216,7 @@ void SaveLoad::saveGame(int index) { fs::path savPath(saveDirPath); savPath.append(kSaveFilename); - SavFile sav(savPath); + SavedGame sav(savPath); sav.save(_game, getSaveName(index)); } @@ -231,15 +231,15 @@ string SaveLoad::getSaveName(int index) const { } void SaveLoad::loadGame(int index) { - auto maybeSave = find_if(_saves.begin(), _saves.end(), [&index](const SavedGame &save) { return save.index == index; }); + auto maybeSave = find_if(_saves.begin(), _saves.end(), [&index](const GameDescriptor &save) { return save.index == index; }); if (maybeSave == _saves.end()) return; - SavFile sav(maybeSave->path); + SavedGame sav(maybeSave->path); sav.load(_game); } void SaveLoad::deleteGame(int index) { - auto maybeSave = find_if(_saves.begin(), _saves.end(), [&index](const SavedGame &save) { return save.index == index; }); + auto maybeSave = find_if(_saves.begin(), _saves.end(), [&index](const GameDescriptor &save) { return save.index == index; }); if (maybeSave == _saves.end()) return; fs::path saveDirPath(getSaveDirPath(index)); diff --git a/src/game/gui/saveload.h b/src/game/gui/saveload.h index 821b0c75..1db27c66 100644 --- a/src/game/gui/saveload.h +++ b/src/game/gui/saveload.h @@ -44,7 +44,7 @@ public: void setMode(Mode mode); private: - struct SavedGame { + struct GameDescriptor { int index { 0 }; std::string name; boost::filesystem::path path; @@ -52,7 +52,7 @@ private: Game *_game { nullptr }; Mode _mode { Mode::Save }; - std::vector _saves; + std::vector _saves; int _selectedSaveIdx { -1 }; void onClick(const std::string &control) override; diff --git a/src/game/object/area.cpp b/src/game/object/area.cpp index ecc6ada9..98de70b1 100644 --- a/src/game/object/area.cpp +++ b/src/game/object/area.cpp @@ -114,14 +114,14 @@ void Area::loadVIS() { void Area::loadPTH() { shared_ptr pth(Resources::instance().getGFF(_name, ResourceType::Path)); - PthFile path; + Path path; path.load(*pth); - const vector &points = path.points(); + const vector &points = path.points(); unordered_map pointZ; for (int i = 0; i < points.size(); ++i) { - const PthFile::Point &point = points[i]; + const Path::Point &point = points[i]; Room *room = nullptr; float z = 0.0f; diff --git a/src/resource/pthfile.cpp b/src/game/path.cpp similarity index 91% rename from src/resource/pthfile.cpp rename to src/game/path.cpp index 6fbc7648..41747fe9 100644 --- a/src/resource/pthfile.cpp +++ b/src/game/path.cpp @@ -15,15 +15,17 @@ * along with this program. If not, see . */ -#include "pthfile.h" +#include "path.h" using namespace std; +using namespace reone::resource; + namespace reone { -namespace resource { +namespace game { -void PthFile::load(const GffStruct &pth) { +void Path::load(const GffStruct &pth) { vector connections; for (auto &connection : pth.getList("Path_Conections")) { @@ -50,7 +52,7 @@ void PthFile::load(const GffStruct &pth) { } } -const vector &PthFile::points() const { +const vector &Path::points() const { return _points; } diff --git a/src/resource/pthfile.h b/src/game/path.h similarity index 81% rename from src/resource/pthfile.h rename to src/game/path.h index 0b2ad6eb..00c79fbd 100644 --- a/src/resource/pthfile.h +++ b/src/game/path.h @@ -21,13 +21,13 @@ #include -#include "gfffile.h" +#include "../resource/gfffile.h" namespace reone { -namespace resource { +namespace game { -class PthFile { +class Path { public: struct Point { float x { 0.0f }; @@ -35,19 +35,19 @@ public: std::vector adjPoints; }; - PthFile() = default; + Path() = default; - void load(const GffStruct &pth); + void load(const resource::GffStruct &pth); const std::vector &points() const; private: std::vector _points; - PthFile(const PthFile &) = delete; - PthFile &operator=(const PthFile &) = delete; + Path(const Path &) = delete; + Path &operator=(const Path &) = delete; }; -} // namespace resource +} // namespace game } // namespace reone diff --git a/src/game/pathfinder.cpp b/src/game/pathfinder.cpp index 63b346ba..5fe43bb0 100644 --- a/src/game/pathfinder.cpp +++ b/src/game/pathfinder.cpp @@ -30,15 +30,15 @@ namespace game { Pathfinder::Edge::Edge(uint16_t toIndex, float length) : toIndex(toIndex), length(length) { } -void Pathfinder::load(const vector &points, const unordered_map &pointZ) { +void Pathfinder::load(const vector &points, const unordered_map &pointZ) { for (uint16_t i = 0; i < points.size(); ++i) { - const PthFile::Point &point = points[i]; + const Path::Point &point = points[i]; glm::vec3 pointVec(point.x, point.y, pointZ.find(i)->second); _vertices.push_back(pointVec); glm::vec3 adjPointVec; for (auto &adjPointIdx : point.adjPoints) { - const PthFile::Point &adjPoint = points[adjPointIdx]; + const Path::Point &adjPoint = points[adjPointIdx]; adjPointVec = glm::vec3(adjPoint.x, adjPoint.y, pointZ.find(adjPointIdx)->second); float distance = glm::distance2(pointVec, adjPointVec); diff --git a/src/game/pathfinder.h b/src/game/pathfinder.h index cd4bca7d..f0f95d8b 100644 --- a/src/game/pathfinder.h +++ b/src/game/pathfinder.h @@ -26,7 +26,7 @@ #include "glm/vec3.hpp" -#include "../resource/pthfile.h" +#include "path.h" namespace reone { @@ -36,7 +36,7 @@ class Pathfinder { public: Pathfinder() = default; - void load(const std::vector &points, const std::unordered_map &pointZ); + void load(const std::vector &points, const std::unordered_map &pointZ); const std::vector findPath(const glm::vec3 &from, const glm::vec3 &to) const; diff --git a/src/game/savfile.cpp b/src/game/savedgame.cpp similarity index 89% rename from src/game/savfile.cpp rename to src/game/savedgame.cpp index d00e8eae..9e9884e1 100644 --- a/src/game/savfile.cpp +++ b/src/game/savedgame.cpp @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -#include "savfile.h" +#include "savedgame.h" #include #include @@ -37,10 +37,10 @@ namespace game { static const char kSignature[] = "SAV"; -SavFile::SavFile(const fs::path &path) : _path(path) { +SavedGame::SavedGame(const fs::path &path) : _path(path) { } -void SavFile::save(const Game *game, const string &name) { +void SavedGame::save(const Game *game, const string &name) { shared_ptr stream(new fs::ofstream(_path, ios::binary)); StreamWriter writer(stream); @@ -50,7 +50,7 @@ void SavFile::save(const Game *game, const string &name) { writer.putCString(game->module()->name()); } -void SavFile::peek() { +void SavedGame::peek() { shared_ptr stream(new fs::ifstream(_path, ios::binary)); StreamReader reader(stream); @@ -63,7 +63,7 @@ void SavFile::peek() { _name = reader.getCString(); } -void SavFile::load(Game *game) { +void SavedGame::load(Game *game) { shared_ptr stream(new fs::ifstream(_path, ios::binary)); StreamReader reader(stream); @@ -80,7 +80,7 @@ void SavFile::load(Game *game) { game->scheduleModuleTransition(moduleName, ""); } -const string &SavFile::name() const { +const string &SavedGame::name() const { return _name; } diff --git a/src/game/savfile.h b/src/game/savedgame.h similarity index 86% rename from src/game/savfile.h rename to src/game/savedgame.h index aaa2f18d..304b8c68 100644 --- a/src/game/savfile.h +++ b/src/game/savedgame.h @@ -27,9 +27,9 @@ namespace game { class Game; -class SavFile { +class SavedGame { public: - SavFile(const boost::filesystem::path &path); + SavedGame(const boost::filesystem::path &path); void save(const Game *game, const std::string &name); void peek(); @@ -42,8 +42,8 @@ private: uint64_t _timestamp { 0 }; std::string _name; - SavFile(const SavFile &) = delete; - SavFile &operator=(const SavFile &) = delete; + SavedGame(const SavedGame &) = delete; + SavedGame &operator=(const SavedGame &) = delete; }; } // namespace game diff --git a/src/render/mesh/mesh.h b/src/render/mesh/mesh.h index 16dc2e57..9438fd17 100644 --- a/src/render/mesh/mesh.h +++ b/src/render/mesh/mesh.h @@ -24,14 +24,10 @@ namespace reone { -namespace resource { +namespace render { class MdlFile; -} - -namespace render { - /** * Polygonal mesh, containing vertex and index data. Renders itself, * but does not manage textures and shaders. @@ -76,7 +72,7 @@ private: Mesh(const Mesh &) = delete; Mesh &operator=(const Mesh &) = delete; - friend class resource::MdlFile; + friend class MdlFile; }; } // namespace render diff --git a/src/render/model/animation.h b/src/render/model/animation.h index d83229c7..83795531 100644 --- a/src/render/model/animation.h +++ b/src/render/model/animation.h @@ -25,6 +25,8 @@ namespace reone { namespace render { +class MdlFile; + class Animation { public: Animation(const std::string &name, float length, float transitionTime, const std::shared_ptr &rootNode); @@ -46,7 +48,7 @@ private: Animation(const Animation &) = delete; Animation &operator=(const Animation &) = delete; - friend class resource::MdlFile; + friend class MdlFile; }; } // namespace render diff --git a/src/render/model/model.h b/src/render/model/model.h index 89de1985..08b5beab 100644 --- a/src/render/model/model.h +++ b/src/render/model/model.h @@ -73,7 +73,7 @@ private: void init(const std::shared_ptr &node); - friend class resource::MdlFile; + friend class MdlFile; }; } // namespace render diff --git a/tests/pathfinder.cpp b/tests/pathfinder.cpp index 59533866..4004bae0 100644 --- a/tests/pathfinder.cpp +++ b/tests/pathfinder.cpp @@ -23,8 +23,8 @@ #include +#include "../src/game/path.h" #include "../src/game/pathfinder.h" -#include "../src/resource/pthfile.h" using namespace std; @@ -32,7 +32,7 @@ using namespace reone::game; using namespace reone::resource; BOOST_AUTO_TEST_CASE(test_find_path) { - vector points = { + vector points = { { 1.0f, 1.0f, { 1, 2 } }, { 1.0f, 2.0f, { 0, 2 } }, { 2.0f, 2.0f, { 1, 3, 4 } },