tibia-rme/source/waypoints.cpp

74 lines
2.2 KiB
C++
Raw Permalink Normal View History

//////////////////////////////////////////////////////////////////////
// This file is part of Remere's Map Editor
//////////////////////////////////////////////////////////////////////
2020-07-30 11:42:28 -03:00
// Remere's Map Editor is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
2016-09-29 19:24:45 -03:00
//
2020-07-30 11:42:28 -03:00
// Remere's Map Editor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
2020-07-30 11:42:28 -03:00
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
2016-09-29 19:24:45 -03:00
//
// You should have received a copy of the GNU General Public License
2020-07-30 11:42:28 -03:00
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//////////////////////////////////////////////////////////////////////
#include "main.h"
#include "waypoints.h"
#include "map.h"
2023-10-09 19:12:16 -07:00
Waypoints::~Waypoints() {
for (auto it = waypoints.begin(); it != waypoints.end(); ++it) {
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
delete it->second;
2023-10-09 19:12:16 -07:00
}
feat: synchronizing commits with the official rme repository (#36) * Show indicators for pickupable and moveable items * Fix: drawing always refreshing ui * Fix crash on invalid friend for wallbrush * Option to remove empty spawns * Draws position indicator, some code cleanup * Teleport copy/paste improvements * Fix flood fill * Add function to get minimap/8bit color * Small code cleanup * Cleanup Position * Code cleanup and small optimizations * Code cleanup * Code cleanup and small optimizations (#406) * Cleanup and cast functions. * Avoid adding a new Unique ID if it already exists * Code cleanup and small optimizations * More changes and cleanup * Changes and cleanup * Some changes * Fix copy position. * Only show uid/aid alert if it really changed * Add actions history panel * Does not draw tooltips on minimap mode * Use constexpr * Replace items fix (#408) * Draw grid small optimization * Small change in selection box and Fix #409 * Fix some xpm * Ingame box improvements, add lights support. * Fix go to previous position (#410) * Fix depot crash (#411) * Fix XPMs * Export minimap as .otmm (otclient format) or .png (#413) * Fix glitch after drawing secondary map * fix * Update about_window.cpp * sonar * fix Minimap and progress bar * fix erro load items.xml * fix * fix doodad brush * fix: slightly more accurate house size estimation * feat: update items.otb and items.xml * fix: bad merge * Revert "feat: update items.otb and items.xml" This reverts commit 40f1edc70f17c423282d546a41541a8fe9b92dcc. --------- Co-authored-by: Nailson <Mignari@users.noreply.github.com> Co-authored-by: wtver <51377408+maattch@users.noreply.github.com> Co-authored-by: Majesty <32709570+majestyotbr@users.noreply.github.com> Co-authored-by: Luan Santos <github@luan.sh>
2023-10-09 23:02:37 -03:00
waypoints.clear();
}
2023-10-09 19:12:16 -07:00
void Waypoints::addWaypoint(Waypoint* wp) {
removeWaypoint(wp->name);
2023-10-09 19:12:16 -07:00
if (wp->pos.isValid()) {
Tile* t = map.getTile(wp->pos);
2023-10-09 19:12:16 -07:00
if (!t) {
map.setTile(wp->pos, t = map.allocator(map.createTileL(wp->pos)));
2023-10-09 19:12:16 -07:00
}
t->getLocation()->increaseWaypointCount();
}
waypoints.insert(std::make_pair(as_lower_str(wp->name), wp));
}
2023-10-09 19:12:16 -07:00
Waypoint* Waypoints::getWaypoint(std::string name) {
to_lower_str(name);
WaypointMap::iterator iter = waypoints.find(name);
2023-10-09 19:12:16 -07:00
if (iter == waypoints.end()) {
return nullptr;
2023-10-09 19:12:16 -07:00
}
return iter->second;
}
2023-10-09 19:12:16 -07:00
Waypoint* Waypoints::getWaypoint(const Position &position) {
if (!position.isValid()) {
2016-12-03 11:03:29 -03:00
return nullptr;
2023-10-09 19:12:16 -07:00
}
2016-12-03 11:03:29 -03:00
// TODO find waypoint by position hash.
2023-10-09 19:12:16 -07:00
for (WaypointMap::iterator it = waypoints.begin(); it != waypoints.end(); it++) {
2016-12-03 11:03:29 -03:00
Waypoint* waypoint = it->second;
2023-10-09 19:12:16 -07:00
if (waypoint && waypoint->pos == position) {
2016-12-03 11:03:29 -03:00
return waypoint;
2023-10-09 19:12:16 -07:00
}
2016-12-03 11:03:29 -03:00
}
return nullptr;
}
2023-10-09 19:12:16 -07:00
void Waypoints::removeWaypoint(std::string name) {
to_lower_str(name);
WaypointMap::iterator iter = waypoints.find(name);
2023-10-09 19:12:16 -07:00
if (iter == waypoints.end()) {
return;
2023-10-09 19:12:16 -07:00
}
delete iter->second;
waypoints.erase(iter);
}