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

Method OnLButtonClick

engine/Poseidon/UI/Map/UIMapMain.cpp:2107–2188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2105extern RString GMapOnSingleClick;
2106
2107void CStaticMapMain::OnLButtonClick(float x, float y)
2108{
2109 if (!_dragging)
2110 {
2111 // Click-to-teleport cheat — if active, snap the player's
2112 // vehicle (the soldier when on foot, the transport when
2113 // crewed) to the clicked world point and swallow the click so
2114 // the normal move/watch handler doesn't also fire. Same
2115 // entity-resolution rule the setPos SQF operator uses for
2116 // soldiers in vehicles.
2117 if (DebugCheats::Cmd_MapTeleport::IsActive() && GWorld)
2118 {
2119 Person* player = GWorld->GetRealPlayer();
2120 if (player && player->Brain())
2121 {
2122 EntityAI* veh = player->Brain()->GetVehicle();
2123 if (veh)
2124 {
2125 Vector3 pos = ScreenToWorld(DrawCoord(x, y));
2126 if (GLandscape)
2127 pos[1] = GLandscape->SurfaceYAboveWater(pos[0], pos[2]) + 0.5f;
2128 Matrix4 trans = veh->Transform();
2129 trans.SetPosition(pos);
2130 veh->Move(trans);
2131 return;
2132 }
2133 }
2134 }
2135
2136 bool alt = InputSubsystem::Instance().IsKeyDown(SDL_SCANCODE_LALT);
2137 bool shift = InputSubsystem::Instance().IsKeyDown(SDL_SCANCODE_LSHIFT);
2138 bool issueMove = true;
2139 if (GMapOnSingleClick.GetLength() > 0)
2140 {
2141 Vector3 pos = ScreenToWorld(DrawCoord(x, y));
2142 GameState* state = GWorld->GetGameState();
2143 GameValue value = state->CreateGameValue(GameArray);
2144 GameArrayType& array = value;
2145 AIUnit* me = GetMyUnit();
2146 AIGroup* myGroup = me ? me->GetGroup() : nullptr;
2147 if (myGroup && me == myGroup->Leader())
2148 {
2149 for (int i = 0; i < MAX_UNITS_PER_GROUP; i++)
2150 {
2151 AIUnit* unit = Poseidon::GetSelectedUnit(i);
2152 if (unit)
2153 {
2154 array.Add(GameValueExt(unit->GetPerson()));
2155 }
2156 }
2157 }
2158
2159 GameValue posValue = state->CreateGameValue(GameArray);
2160 GameArrayType& posArray = posValue;
2161 posArray.Realloc(3);
2162 posArray.Add(pos[0]);
2163 posArray.Add(pos[2]);
2164 posArray.Add(pos[1] - GLandscape->SurfaceYAboveWater(pos[0], pos[2]));

Callers

nothing calls this directly

Calls 15

GetSelectedUnitFunction · 0.85
GameValueExtClass · 0.85
GetRealPlayerMethod · 0.80
BrainMethod · 0.80
SurfaceYAboveWaterMethod · 0.80
IsKeyDownMethod · 0.80
CreateGameValueMethod · 0.80
GetPersonMethod · 0.80
BeginContextMethod · 0.80
VarSetLocalMethod · 0.80
EvaluateMultipleBoolMethod · 0.80
EndContextMethod · 0.80

Tested by

no test coverage detected