MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / FindSign

Method FindSign

engine/Poseidon/UI/Map/UIMapExt.cpp:1942–2110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1940}
1941
1942SignInfo CStaticMapArcadeViewer::FindSign(float x, float y)
1943{
1944 bool reverse = InputSubsystem::Instance().IsKeyDown(SDL_SCANCODE_LSHIFT) ||
1945 InputSubsystem::Instance().GetKey(SDL_SCANCODE_RSHIFT) > 0;
1946
1947 struct SignInfo info;
1948 info._type = signNone;
1949 info._unit = nullptr;
1950 info._id = nullptr;
1951
1952 Point3 pt = ScreenToWorld(DrawCoord(x, y));
1953 const float sizeLand = LandGrid * LandRange;
1954 float dist, minDist = 0.02 * sizeLand * _scaleX;
1955 minDist *= minDist;
1956
1957 int i, n = _template->groups.Size();
1958 if (!reverse) // search in waypoints first
1959 {
1960 for (i = 0; i < n; i++)
1961 {
1962 ArcadeGroupInfo& gInfo = _template->groups[i];
1963 int j, m;
1964 m = gInfo.waypoints.Size();
1965 for (j = 0; j < m; j++)
1966 {
1967 ArcadeWaypointInfo& wInfo = gInfo.waypoints[j];
1968 dist = (pt - wInfo.position).SquareSizeXZ();
1969 if (dist < minDist)
1970 {
1971 minDist = dist;
1972 info._type = signArcadeWaypoint;
1973 info._indexGroup = i;
1974 info._index = j;
1975 }
1976 }
1977 }
1978 }
1979
1980 // units, flags and sensors in groups
1981 for (i = 0; i < n; i++)
1982 {
1983 ArcadeGroupInfo& gInfo = _template->groups[i];
1984 int j, m;
1985 m = gInfo.units.Size();
1986 for (j = 0; j < m; j++)
1987 {
1988 ArcadeUnitInfo& uInfo = gInfo.units[j];
1989 if (uInfo.side != Glob.header.playerSide && uInfo.age == AAUnknown && !HasFullRights())
1990 {
1991 continue;
1992 }
1993
1994 dist = (pt - uInfo.position).SquareSizeXZ();
1995 if (dist < minDist)
1996 {
1997 minDist = dist;
1998 info._type = signArcadeUnit;
1999 info._indexGroup = i;

Callers

nothing calls this directly

Calls 5

IsKeyDownMethod · 0.80
GetKeyMethod · 0.45
SizeMethod · 0.45
SquareSizeXZMethod · 0.45
PositionMethod · 0.45

Tested by

no test coverage detected