Add Ctrl+click minimap ping sending

Ctrl+clicking on the minimap converts screen position to world coordinates
and sends MSG_MINIMAP_PING to the server. A local ping is also added
immediately so the sender sees their own ping.
This commit is contained in:
Kelsi 2026-03-11 23:00:03 -07:00
parent 97662800d5
commit ae8f900410
3 changed files with 48 additions and 0 deletions

View file

@ -7710,6 +7710,29 @@ void GameHandler::sendPing() {
socket->send(packet);
}
void GameHandler::sendMinimapPing(float wowX, float wowY) {
if (state != WorldState::IN_WORLD) return;
// MSG_MINIMAP_PING (CMSG direction): float posX + float posY
// Server convention: posX = east/west axis = canonical Y (west)
// posY = north/south axis = canonical X (north)
const float serverX = wowY; // canonical Y (west) → server posX
const float serverY = wowX; // canonical X (north) → server posY
network::Packet pkt(wireOpcode(Opcode::MSG_MINIMAP_PING));
pkt.writeFloat(serverX);
pkt.writeFloat(serverY);
socket->send(pkt);
// Add ping locally so the sender sees their own ping immediately
MinimapPing localPing;
localPing.senderGuid = activeCharacterGuid_;
localPing.wowX = wowX;
localPing.wowY = wowY;
localPing.age = 0.0f;
minimapPings_.push_back(localPing);
}
void GameHandler::handlePong(network::Packet& packet) {
LOG_DEBUG("Handling SMSG_PONG");

View file

@ -10654,6 +10654,28 @@ void GameScreen::renderMinimapMarkers(game::GameHandler& gameHandler) {
}
}
// Ctrl+click on minimap → send minimap ping to party
if (ImGui::IsMouseClicked(0) && ImGui::GetIO().KeyCtrl) {
ImVec2 mouse = ImGui::GetMousePos();
float mdx = mouse.x - centerX;
float mdy = mouse.y - centerY;
float distSq = mdx * mdx + mdy * mdy;
if (distSq <= mapRadius * mapRadius) {
// Invert projectToMinimap: px=mdx, py=mdy → rx=px*viewRadius/mapRadius
float rx = mdx * viewRadius / mapRadius;
float ry = mdy * viewRadius / mapRadius;
// rx/ry are in rotated frame; unrotate to get world dx/dy
// rx = -(dx*cosB + dy*sinB), ry = dx*sinB - dy*cosB
// Solving: dx = -(rx*cosB - ry*sinB), dy = -(rx*sinB + ry*cosB)
float wdx = -(rx * cosB - ry * sinB);
float wdy = -(rx * sinB + ry * cosB);
// playerRender is in render coords; add delta to get render position then convert to canonical
glm::vec3 clickRender = playerRender + glm::vec3(wdx, wdy, 0.0f);
glm::vec3 clickCanon = core::coords::renderToCanonical(clickRender);
gameHandler.sendMinimapPing(clickCanon.x, clickCanon.y);
}
}
auto applyMuteState = [&]() {
auto* activeRenderer = core::Application::getInstance().getRenderer();
float masterScale = soundMuted_ ? 0.0f : static_cast<float>(pendingMasterVolume) / 100.0f;