mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Queue transport pre-spawn moves and add Z weapon sheath toggle
This commit is contained in:
parent
d6e7b0809c
commit
5d63bb0988
4 changed files with 120 additions and 47 deletions
|
|
@ -351,6 +351,7 @@ void Application::logoutToLogin() {
|
|||
}
|
||||
npcsSpawned = false;
|
||||
playerCharacterSpawned = false;
|
||||
weaponsSheathed_ = false;
|
||||
world.reset();
|
||||
if (renderer) {
|
||||
// Remove old player model so it doesn't persist into next session
|
||||
|
|
@ -408,6 +409,16 @@ void Application::update(float deltaTime) {
|
|||
auto gh2 = std::chrono::high_resolution_clock::now();
|
||||
ghTime += std::chrono::duration<float, std::milli>(gh2 - gh1).count();
|
||||
|
||||
// Toggle weapon sheathe state with Z (ignored while UI captures keyboard).
|
||||
{
|
||||
const bool uiWantsKeyboard = ImGui::GetIO().WantCaptureKeyboard;
|
||||
auto& input = Input::getInstance();
|
||||
if (!uiWantsKeyboard && input.isKeyJustPressed(SDL_SCANCODE_Z)) {
|
||||
weaponsSheathed_ = !weaponsSheathed_;
|
||||
loadEquippedWeapons();
|
||||
}
|
||||
}
|
||||
|
||||
auto w1 = std::chrono::high_resolution_clock::now();
|
||||
if (world) {
|
||||
world->update(deltaTime);
|
||||
|
|
@ -1235,6 +1246,16 @@ void Application::setupUICallbacks() {
|
|||
// Server-authoritative movement - set initial position from spawn data
|
||||
glm::vec3 canonicalPos(x, y, z);
|
||||
transportManager->updateServerTransport(guid, canonicalPos, orientation);
|
||||
|
||||
// If a move packet arrived before registration completed, replay latest now.
|
||||
auto pendingIt = pendingTransportMoves_.find(guid);
|
||||
if (pendingIt != pendingTransportMoves_.end()) {
|
||||
const PendingTransportMove pending = pendingIt->second;
|
||||
transportManager->updateServerTransport(guid, glm::vec3(pending.x, pending.y, pending.z), pending.orientation);
|
||||
LOG_INFO("Replayed queued transport move for GUID=0x", std::hex, guid, std::dec,
|
||||
" pos=(", pending.x, ", ", pending.y, ", ", pending.z, ") orientation=", pending.orientation);
|
||||
pendingTransportMoves_.erase(pendingIt);
|
||||
}
|
||||
LOG_INFO("Transport registered - server-authoritative movement");
|
||||
});
|
||||
|
||||
|
|
@ -1329,13 +1350,15 @@ void Application::setupUICallbacks() {
|
|||
|
||||
transportManager->registerTransport(guid, wmoInstanceId, pathId, canonicalSpawnPos);
|
||||
} else {
|
||||
pendingTransportMoves_[guid] = PendingTransportMove{x, y, z, orientation};
|
||||
LOG_WARNING("Cannot auto-spawn transport 0x", std::hex, guid, std::dec,
|
||||
" - WMO instance not found");
|
||||
" - WMO instance not found (queued move for replay)");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
pendingTransportMoves_[guid] = PendingTransportMove{x, y, z, orientation};
|
||||
LOG_WARNING("Cannot auto-spawn transport 0x", std::hex, guid, std::dec,
|
||||
" - entity not found in EntityManager");
|
||||
" - entity not found in EntityManager (queued move for replay)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1879,6 +1902,13 @@ void Application::loadEquippedWeapons() {
|
|||
{ game::EquipSlot::OFF_HAND, 2 },
|
||||
};
|
||||
|
||||
if (weaponsSheathed_) {
|
||||
for (const auto& ws : weaponSlots) {
|
||||
charRenderer->detachWeapon(charInstanceId, ws.attachmentId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& ws : weaponSlots) {
|
||||
const auto& equipSlot = inventory.getEquipSlot(ws.slot);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue