@@ -2325,6 +2325,55 @@ void CClientGame::ProcessServerControlBind(CControlFunctionBind* pBind)
23252325 m_pNetAPI->RPC (KEY_BIND, bitStream.pBitStream );
23262326}
23272327
2328+ CClientEntity* CClientGame::CheckClientSideEntityClick (float fScreenX , float fScreenY )
2329+ {
2330+ if (!m_pMarkerManager)
2331+ return NULL ;
2332+
2333+ CClientMarker* pClosestMarker = NULL ;
2334+ float fClosestDist = 99999 .9f ;
2335+
2336+ CFastList<CClientMarker*>::const_iterator iter = m_pMarkerManager->m_Markers .begin ();
2337+ for (; iter != m_pMarkerManager->m_Markers .end (); ++iter)
2338+ {
2339+ CClientMarker* pMarker = *iter;
2340+ if (pMarker && pMarker->IsStreamedIn () && pMarker->IsVisible ())
2341+ {
2342+ CVector vecPosition;
2343+ pMarker->GetPosition (vecPosition);
2344+
2345+ CVector vecScreen;
2346+ g_pCore->GetGraphics ()->CalcScreenCoors (&vecPosition, &vecScreen);
2347+
2348+ if (pMarker->IsClientSideOnScreen ())
2349+ {
2350+ CSphere boundingSphere = pMarker->GetWorldBoundingSphere ();
2351+
2352+ CVector vecEdgePos = boundingSphere.vecPosition ;
2353+ vecEdgePos.fX += boundingSphere.fRadius ;
2354+
2355+ CVector vecCenterScreen, vecEdgeScreen;
2356+ g_pCore->GetGraphics ()->CalcScreenCoors (&boundingSphere.vecPosition , &vecCenterScreen);
2357+ g_pCore->GetGraphics ()->CalcScreenCoors (&vecEdgePos, &vecEdgeScreen);
2358+
2359+ float fScreenRadius = abs (vecEdgeScreen.fX - vecCenterScreen.fX );
2360+
2361+ float fDistX = vecCenterScreen.fX - fScreenX ;
2362+ float fDistY = vecCenterScreen.fY - fScreenY ;
2363+ float fDist = sqrt (fDistX * fDistX + fDistY * fDistY );
2364+
2365+ if (fDist < fScreenRadius && fDist < fClosestDist )
2366+ {
2367+ fClosestDist = fDist ;
2368+ pClosestMarker = pMarker;
2369+ }
2370+ }
2371+ }
2372+ }
2373+
2374+ return pClosestMarker;
2375+ }
2376+
23282377bool CClientGame::ProcessMessageForCursorEvents (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
23292378{
23302379 bool bCursorForcedVisible = g_pCore->IsCursorForcedVisible ();
@@ -2419,6 +2468,17 @@ bool CClientGame::ProcessMessageForCursorEvents(HWND hwnd, UINT uMsg, WPARAM wPa
24192468 pColPoint->Destroy ();
24202469 }
24212470
2471+ if (!pCollisionEntity)
2472+ {
2473+ CClientEntity* pClientSideEntity = CheckClientSideEntityClick ((float )iX, (float )iY);
2474+ if (pClientSideEntity)
2475+ {
2476+ pCollisionEntity = pClientSideEntity;
2477+ if (!pClientSideEntity->IsLocalEntity ())
2478+ CollisionEntityID = pClientSideEntity->GetID ();
2479+ }
2480+ }
2481+
24222482 const char * szButton = NULL ;
24232483 const char * szState = NULL ;
24242484 switch (ucButtonHit)
0 commit comments