-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Итоговый PR: mouseartiom #6
base: master
Are you sure you want to change the base?
Conversation
…лен using ns std. В GetArtifact() возвращается указатель на артефакт. Добавлены Get/Set.
… into mouseartiom
…бавлен в конструктор Item для генерации из вне.
… into mouseartiom
… into mouseartiom
This reverts commit 1f5d458, where event, item and location were deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почти нет паттернов
database/items_data.cpp
Outdated
// using unique_ptr for two-dim array isn't a good idea though | ||
// std::unique_ptr<Event[][]> eventMatrix (nullptr); | ||
|
||
eventMatrix = new std::vector<Event>** [gameData.mapHeight]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему используется двойной указатель на вектор?
это же очень не очень
database/items_data.cpp
Outdated
else return NULL; | ||
} | ||
|
||
void EventsData::PulverizeEvents(std::unordered_map<str, Event>& list) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
интересное название метода
database/items_data.cpp
Outdated
|
||
bool ArtifactsData::Init() { | ||
ArtifactFactory aFactory; | ||
str path = systemData.resourcesDirectory + systemData.nextLocationName + "/artifacts"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
этот путь должен передаваться в конструкторе
/ - это системный разделитель - используйте системную функцию/std::filesystem
database/items_data.cpp
Outdated
|
||
SystemData::SystemData(str _nextLocationName) | ||
: | ||
resourcesDirectory("resources/"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это должно задаваться ещё выше
database/session_data.cpp
Outdated
str writer; | ||
|
||
// hero initialization | ||
std::string name = "Moleque"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это не должно инициализироваться тут
surfaces/surface.cpp
Outdated
MapScanner scanner; | ||
scanner.FillMatrix( | ||
systemData.resourcesDirectory + | ||
systemData.nextLocationName + "/" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
системный разделитель
surfaces/surface.cpp
Outdated
return surfaceMatrix; | ||
} | ||
|
||
// DO NOT use this! It's full of bugs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!!!
surfaces/surface.h
Outdated
int mapWidth; | ||
int mapHeight; | ||
Matrix<char> surfaceMatrix; | ||
// std::unordered_map<str, Surface> currentSurfaceList; // currently useless |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
public: | ||
AccessMap(Coord, Coord); | ||
~AccessMap(); | ||
char** getMatrix() {return matrix;}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
используйте умные указатели
например, тут можно использовать array>, так как размер жёстко задан
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
так и не поправлено
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int width; | ||
}; | ||
|
||
/* template<class T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не идеально, конечно
Но более-менее ок
: nextLocationName(_nextLocationName) { | ||
cout << "systemData initialized" << endl; | ||
resourcesPath = resourcesDirectory; | ||
artifactsPath = resourcesPath / nextLocationName / "artifacts"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут точно деление?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public: | ||
AccessMap(Coord, Coord); | ||
~AccessMap(); | ||
char** getMatrix() {return matrix;}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
так и не поправлено
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
только паттернов нет
поэтому баллы могу поставить за первые два модуля
|
||
class GameData { | ||
// stores finished events and other stuff | ||
public: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
если это public class, то лучше использовать struct...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вобщем было бы хоршо убрать комментарии. Поменять необходимые методы на const. Использовать умные указатели. Почаще использовать auto. Побольше проверок исключений нужно
if (!surfaceData.CoordIsValid(point)) return NULL; | ||
if (!eventMatrix[point]) return NULL; | ||
if (!eventMatrix[point]->empty()) | ||
// return eventMatrix[point]->front(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
коммент
add event to map | ||
*/ | ||
for (auto i : list) { | ||
Event &event = i.second; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему reference. Вместо auto i. Можно использовать const auto& i, чтобы не копировать
Event &event = i.second; | ||
int counter = 0; | ||
|
||
Coord eventCenter = event.GetCoord(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно использовать auto, чтобы не писать лишнего. Тип сам выведется
current.y++) { | ||
counter++; | ||
if (!eventMatrix[current]) { | ||
eventMatrix[current] = new std::vector<str>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему, raw указатель на контейнер. Это же фиаско. Используй умные указатели
} | ||
} | ||
} | ||
cout << "event " << event.GetName() << " was sprayed " << counter << " times" << endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше использовать логгер
return surfaceMatrix[point]; | ||
} | ||
|
||
short SurfaceData::getSurfSpeed(Coord point) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const метод. И вобще везде getter-ы. Const методы
} | ||
|
||
short SurfaceData::getSurfSpeed(Coord point) { | ||
return surfaceList.at(getSurface(point)).getSpeed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если at не находит элемент, то он бросает exception out_of_range. Нужен try catch
|
||
/* | ||
// struct for terrain modifiers, contains name and power factor | ||
struct surfaceModifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
опять комменты в релиз коде
class SurfaceData { | ||
public: | ||
SurfaceData(); | ||
// ~SurfaceData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
public: | ||
AccessMap(Coord, Coord); | ||
~AccessMap(); | ||
char** getMatrix() {return matrix;}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
С момента последнего ревью была проделана следующая работа: