Skip to content

Commit

Permalink
small bug fix with remove_event from map
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Feb 25, 2024
1 parent eb25dca commit 90dc667
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions base/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2005,13 +2005,18 @@ export class Map {
* Removes a tile event in a custom location.
* @param location_key the LocationKey of the event.
* @param event_id the id of the event.
* @returns returns true if the event was removed.
*/
remove_event(location_key: number, event_id: number) {
this.events[location_key] = this.events[location_key].filter(event => event.id !== event_id);
if (!this.events[location_key].length) {
delete this.events[location_key];
if (location_key in this.events) {
this.events[location_key] = this.events[location_key].filter(event => event.id !== event_id);
if (!this.events[location_key].length) {
delete this.events[location_key];
}
TileEvent.get_event(event_id).in_map = false;
return true;
}
TileEvent.get_event(event_id).in_map = false;
return false;
}

/**
Expand Down

0 comments on commit 90dc667

Please sign in to comment.