MCPcopy Create free account
hub / github.com/EasyRPG/Player / CheckOrMakeWayEx

Method CheckOrMakeWayEx

src/game_map.cpp:816–930  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

814}
815
816bool Game_Map::CheckOrMakeWayEx(const Game_Character& self,
817 int from_x, int from_y,
818 int to_x, int to_y,
819 bool check_events_and_vehicles,
820 Span<int> ignore_some_events_by_id,
821 bool make_way
822 )
823{
824 // Infer directions before we do any rounding.
825 const int bit_from = GetPassableMask(from_x, from_y, to_x, to_y);
826 const int bit_to = GetPassableMask(to_x, to_y, from_x, from_y);
827
828 // Now round for looping maps.
829 to_x = Game_Map::RoundX(to_x);
830 to_y = Game_Map::RoundY(to_y);
831
832 // Note, even for diagonal, if the tile is invalid we still check vertical/horizontal first!
833 if (!Game_Map::IsValid(to_x, to_y)) {
834 return false;
835 }
836
837 if (self.GetThrough()) {
838 return true;
839 }
840
841 const auto vehicle_type = GetCollisionVehicleType(&self);
842 bool self_conflict = false;
843
844 // Depending on whether we're supposed to call MakeWayCollideEvent
845 // (which might change the map) or not, choose what to call:
846 auto CheckOrMakeCollideEvent = [&](auto& other) {
847 if (make_way) {
848 return MakeWayCollideEvent(to_x, to_y, self, other, self_conflict);
849 } else {
850 return CheckWayTestCollideEvent(
851 to_x, to_y, self, other, self_conflict
852 );
853 }
854 };
855
856 if (!self.IsJumping()) {
857 // Check for self conflict.
858 // If this event has a tile graphic and the tile itself has passage blocked in the direction
859 // we want to move, flag it as "self conflicting" for use later.
860 if (self.GetLayer() == lcf::rpg::EventPage::Layers_below && self.GetTileId() != 0) {
861 int tile_id = self.GetTileId();
862 if ((passages_up[tile_id] & bit_from) == 0) {
863 self_conflict = true;
864 }
865 }
866
867 if (vehicle_type == Game_Vehicle::None) {
868 // Check that we are allowed to step off of the current tile.
869 // Note: Vehicles can always step off a tile.
870
871 // The current coordinate can be invalid due to an out-of-bounds teleport or a "Set Location" event.
872 // Round it for looping maps to ensure the check passes
873 // This is not fully bug compatible to RPG_RT. Assuming the Y-Coordinate is out-of-bounds: When moving

Callers

nothing calls this directly

Calls 15

GetPassableMaskFunction · 0.85
GetCollisionVehicleTypeFunction · 0.85
MakeWayCollideEventFunction · 0.85
CheckWayTestCollideEventFunction · 0.85
GetThroughMethod · 0.80
IsJumpingMethod · 0.80
GetLayerMethod · 0.80
GetTileIdMethod · 0.80
IsInCurrentMapMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected