Merge pull request #76 from Kilkenni/player-bindings-return-values
return values for bookmark Lua callbacks
This commit is contained in:
commit
4b0d1cb90d
@ -71,30 +71,30 @@ List<pair<Vec3I, OrbitBookmark>> PlayerUniverseMap::orbitBookmarks() const {
|
||||
return bookmarks;
|
||||
}
|
||||
|
||||
void PlayerUniverseMap::addOrbitBookmark(CelestialCoordinate const& system, OrbitBookmark const& bookmark) {
|
||||
bool PlayerUniverseMap::addOrbitBookmark(CelestialCoordinate const& system, OrbitBookmark const& bookmark) {
|
||||
if (system.isNull())
|
||||
throw StarException("Cannot add orbit bookmark to null system");
|
||||
|
||||
m_universeMaps[*m_serverUuid].systems[system.location()].bookmarks.add(std::move(bookmark));
|
||||
return m_universeMaps[*m_serverUuid].systems[system.location()].bookmarks.add(std::move(bookmark));
|
||||
}
|
||||
|
||||
void PlayerUniverseMap::removeOrbitBookmark(CelestialCoordinate const& system, OrbitBookmark const& bookmark) {
|
||||
bool PlayerUniverseMap::removeOrbitBookmark(CelestialCoordinate const& system, OrbitBookmark const& bookmark) {
|
||||
if (system.isNull())
|
||||
throw StarException("Cannot remove orbit bookmark from null system");
|
||||
|
||||
m_universeMaps[*m_serverUuid].systems[system.location()].bookmarks.remove(bookmark);
|
||||
return m_universeMaps[*m_serverUuid].systems[system.location()].bookmarks.remove(bookmark);
|
||||
}
|
||||
|
||||
List<TeleportBookmark> PlayerUniverseMap::teleportBookmarks() const {
|
||||
return universeMap().teleportBookmarks.values();
|
||||
}
|
||||
|
||||
void PlayerUniverseMap::addTeleportBookmark(TeleportBookmark bookmark) {
|
||||
m_universeMaps[*m_serverUuid].teleportBookmarks.add(std::move(bookmark));
|
||||
bool PlayerUniverseMap::addTeleportBookmark(TeleportBookmark bookmark) {
|
||||
return m_universeMaps[*m_serverUuid].teleportBookmarks.add(std::move(bookmark));
|
||||
}
|
||||
|
||||
void PlayerUniverseMap::removeTeleportBookmark(TeleportBookmark const& bookmark) {
|
||||
m_universeMaps[*m_serverUuid].teleportBookmarks.remove(bookmark);
|
||||
bool PlayerUniverseMap::removeTeleportBookmark(TeleportBookmark const& bookmark) {
|
||||
return m_universeMaps[*m_serverUuid].teleportBookmarks.remove(bookmark);
|
||||
}
|
||||
|
||||
void PlayerUniverseMap::invalidateWarpAction(WarpAction const& warpAction) {
|
||||
|
@ -53,12 +53,12 @@ public:
|
||||
|
||||
// pair of system location and bookmark, not all orbit bookmarks include the system
|
||||
List<pair<Vec3I, OrbitBookmark>> orbitBookmarks() const;
|
||||
void addOrbitBookmark(CelestialCoordinate const& system, OrbitBookmark const& bookmark);
|
||||
void removeOrbitBookmark(CelestialCoordinate const& system, OrbitBookmark const& bookmark);
|
||||
bool addOrbitBookmark(CelestialCoordinate const& system, OrbitBookmark const& bookmark);
|
||||
bool removeOrbitBookmark(CelestialCoordinate const& system, OrbitBookmark const& bookmark);
|
||||
|
||||
List<TeleportBookmark> teleportBookmarks() const;
|
||||
void addTeleportBookmark(TeleportBookmark bookmark);
|
||||
void removeTeleportBookmark(TeleportBookmark const& bookmark);
|
||||
bool addTeleportBookmark(TeleportBookmark bookmark);
|
||||
bool removeTeleportBookmark(TeleportBookmark const& bookmark);
|
||||
void invalidateWarpAction(WarpAction const& bookmark);
|
||||
|
||||
Maybe<OrbitBookmark> worldBookmark(CelestialCoordinate const& world) const;
|
||||
|
@ -594,12 +594,12 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) {
|
||||
});
|
||||
});
|
||||
|
||||
callbacks.registerCallback("addOrbitBookmark", [player](Json const& system, Json const& bookmarkConfig) {
|
||||
callbacks.registerCallback("addOrbitBookmark", [player](Json const& system, Json const& bookmarkConfig) -> bool {
|
||||
CelestialCoordinate coordinate = CelestialCoordinate(system);
|
||||
return player->universeMap()->addOrbitBookmark(coordinate, OrbitBookmark::fromJson(bookmarkConfig));
|
||||
});
|
||||
|
||||
callbacks.registerCallback("removeOrbitBookmark", [player](Json const& system, Json const& bookmarkConfig) {
|
||||
callbacks.registerCallback("removeOrbitBookmark", [player](Json const& system, Json const& bookmarkConfig) -> bool {
|
||||
CelestialCoordinate coordinate = CelestialCoordinate(system);
|
||||
return player->universeMap()->removeOrbitBookmark(coordinate, OrbitBookmark::fromJson(bookmarkConfig));
|
||||
});
|
||||
@ -610,12 +610,12 @@ LuaCallbacks LuaBindings::makePlayerCallbacks(Player* player) {
|
||||
});
|
||||
});
|
||||
|
||||
callbacks.registerCallback("addTeleportBookmark", [player](Json const& bookmarkConfig) {
|
||||
callbacks.registerCallback("addTeleportBookmark", [player](Json const& bookmarkConfig) -> bool {
|
||||
return player->universeMap()->addTeleportBookmark(TeleportBookmark::fromJson(bookmarkConfig));
|
||||
});
|
||||
|
||||
callbacks.registerCallback("removeTeleportBookmark", [player](Json const& bookmarkConfig) {
|
||||
player->universeMap()->removeTeleportBookmark(TeleportBookmark::fromJson(bookmarkConfig));
|
||||
callbacks.registerCallback("removeTeleportBookmark", [player](Json const& bookmarkConfig) -> bool {
|
||||
return player->universeMap()->removeTeleportBookmark(TeleportBookmark::fromJson(bookmarkConfig));
|
||||
});
|
||||
|
||||
callbacks.registerCallback("isMapped", [player](Json const& coords) {
|
||||
|
Loading…
Reference in New Issue
Block a user