MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / tryTeleporting

Method tryTeleporting

src/clientbase/LocalPlayer.cpp:938–1092  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

936//============================================================================//
937
938bool LocalPlayer::tryTeleporting(const MeshFace* linkSrc,
939 const fvec3& oldPos, fvec3& newPos,
940 const fvec3& oldVel, fvec3& newVel,
941 const float oldAngle, float& newAngle,
942 const float oldAngVel, float& newAngVel,
943 bool phased, bool& expel) {
944 if (!isAlive()) {
945 return false;
946 }
947
948 // see if we crossed a link source
949 if (linkSrc == NULL) {
950 World* world = World::getWorld();
951 linkSrc = world->crossesTeleporter(oldPos, newPos);
952 if (linkSrc == NULL) {
953 return false;
954 }
955 }
956
957 // PhantomZone tanks just change phase
958 if (getFlagType() == Flags::PhantomZone) {
959 // change zoned state
960 setStatus(getStatus() ^ PlayerState::PhantomZoned);
961 setStatus(getStatus() ^ PlayerState::FlagActive);
962 if (gettingSound) {
963 SOUNDSYSTEM.play(SFX_PHANTOM);
964 }
965 return false; // just a phase change
966 }
967
968 // get the destination link, the link IDs, and the link physics
969 int linkSrcID, linkDstID;
970 const LinkPhysics* linkPhysics;
971 const MeshFace* linkDst = linkManager.getTankLinkDst(linkSrc,
972 linkSrcID, linkDstID,
973 linkPhysics,
974 newPos, newVel,
975 getTeam(), getFlagType());
976 // no link, no love; bail out
977 if (!linkDst) {
978 const std::string& failMsg = linkSrc->getSpecialData()->linkSrcTankFailText;
979 if (!failMsg.empty()) {
980 addMessage(NULL, failMsg);
981 }
982 return false;
983 }
984
985 // get the destination's coordinates
986 linkSrc->teleportTank(*linkDst, *linkPhysics,
987 newPos, newPos,
988 newVel, newVel,
989 newAngle, newAngle,
990 newAngVel, newAngVel);
991
992 // check if the destination is blocked by an obstacle
993 const Obstacle* teleBlocker =
994 getHitBuilding(newPos, newAngle, newPos, newAngle, phased, expel);
995 if (teleBlocker) {

Callers

nothing calls this directly

Calls 15

getStatusFunction · 0.85
addMessageFunction · 0.85
computeGroundLimitFunction · 0.85
debugfFunction · 0.85
unescape_colorsFunction · 0.85
crossesTeleporterMethod · 0.80
getTankLinkDstMethod · 0.80
getSpecialDataMethod · 0.80
teleportTankMethod · 0.80
c_strMethod · 0.80
linkSrcReboundMethod · 0.80
getPlaneMethod · 0.80

Tested by

no test coverage detected