diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/client.cpp | 13 | ||||
-rw-r--r-- | src/client/client.h | 2 | ||||
-rw-r--r-- | src/client/game.cpp | 28 |
3 files changed, 18 insertions, 25 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp index 430784b95..cb6b68278 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -908,7 +908,7 @@ void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket * *pkt << fov << wanted_range; } -void Client::interact(u8 action, const PointedThing& pointed) +void Client::interact(InteractAction action, const PointedThing& pointed) { if(m_state != LC_Ready) { errorstream << "Client::interact() " @@ -928,18 +928,11 @@ void Client::interact(u8 action, const PointedThing& pointed) [5] u32 length of the next item (plen) [9] serialized PointedThing [9 + plen] player position information - actions: - 0: start digging (from undersurface) or use - 1: stop digging (all parameters ignored) - 2: digging completed - 3: place block or item (to abovesurface) - 4: use item - 5: perform secondary action of item */ NetworkPacket pkt(TOSERVER_INTERACT, 1 + 2 + 0); - pkt << action; + pkt << (u8)action; pkt << myplayer->getWieldIndex(); std::ostringstream tmp_os(std::ios::binary); @@ -1203,7 +1196,7 @@ void Client::clearOutChatQueue() } void Client::sendChangePassword(const std::string &oldpassword, - const std::string &newpassword) + const std::string &newpassword) { LocalPlayer *player = m_env.getLocalPlayer(); if (player == NULL) diff --git a/src/client/client.h b/src/client/client.h index 8ee34a4bd..15a4689c1 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -232,7 +232,7 @@ public: void Send(NetworkPacket* pkt); - void interact(u8 action, const PointedThing& pointed); + void interact(InteractAction action, const PointedThing &pointed); void sendNodemetaFields(v3s16 p, const std::string &formname, const StringMap &fields); diff --git a/src/client/game.cpp b/src/client/game.cpp index b7838c22f..6ad87d351 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2962,7 +2962,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug) shootline = core::line3d<f32>(player_eye_position, player_eye_position + camera_direction * BS * d); } else { - // prevent player pointing anything in front-view + // prevent player pointing anything in front-view shootline = core::line3d<f32>(camera_position, camera_position); } @@ -3002,7 +3002,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug) if (runData.digging) { if (input->getLeftReleased()) { infostream << "Left button released" - << " (stopped digging)" << std::endl; + << " (stopped digging)" << std::endl; runData.digging = false; } else if (pointed != runData.pointed_old) { if (pointed.type == POINTEDTHING_NODE @@ -3013,14 +3013,14 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug) // Don't reset. } else { infostream << "Pointing away from node" - << " (stopped digging)" << std::endl; + << " (stopped digging)" << std::endl; runData.digging = false; hud->updateSelectionMesh(camera_offset); } } if (!runData.digging) { - client->interact(1, runData.pointed_old); + client->interact(INTERACT_STOP_DIGGING, runData.pointed_old); client->setCrack(-1, v3s16(0, 0, 0)); runData.dig_time = 0.0; } @@ -3048,7 +3048,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug) if (selected_def.usable && input->getLeftState()) { if (input->getLeftClicked() && (!client->moddingEnabled() || !client->getScript()->on_item_use(selected_item, pointed))) - client->interact(4, pointed); + client->interact(INTERACT_USE, pointed); } else if (pointed.type == POINTEDTHING_NODE) { handlePointingAtNode(pointed, selected_item, hand_item, dtime); } else if (pointed.type == POINTEDTHING_OBJECT) { @@ -3169,7 +3169,7 @@ void Game::handlePointingAtNothing(const ItemStack &playerItem) infostream << "Right Clicked in Air" << std::endl; PointedThing fauxPointed; fauxPointed.type = POINTEDTHING_NOTHING; - client->interact(5, fauxPointed); + client->interact(INTERACT_ACTIVATE, fauxPointed); } @@ -3216,7 +3216,7 @@ void Game::handlePointingAtNode(const PointedThing &pointed, && !isKeyDown(KeyType::SNEAK)) { // Report right click to server if (nodedef_manager->get(map.getNodeNoEx(nodepos)).rightclickable) { - client->interact(3, pointed); + client->interact(INTERACT_PLACE, pointed); } infostream << "Launching custom inventory view" << std::endl; @@ -3246,7 +3246,7 @@ void Game::handlePointingAtNode(const PointedThing &pointed, if (placed) { // Report to server - client->interact(3, pointed); + client->interact(INTERACT_PLACE, pointed); // Read the sound soundmaker->m_player_rightpunch_sound = def.sound_place; @@ -3259,7 +3259,7 @@ void Game::handlePointingAtNode(const PointedThing &pointed, if (def.node_placement_prediction.empty() || nodedef_manager->get(map.getNodeNoEx(nodepos)).rightclickable) { - client->interact(3, pointed); // Report to server + client->interact(INTERACT_PLACE, pointed); // Report to server } else { soundmaker->m_player_rightpunch_sound = def.sound_place_failed; @@ -3462,11 +3462,11 @@ void Game::handlePointingAtObject(const PointedThing &pointed, runData.time_from_last_punch = 0; if (!disable_send) - client->interact(0, pointed); + client->interact(INTERACT_START_DIGGING, pointed); } } else if (input->getRightClicked()) { infostream << "Right-clicked object" << std::endl; - client->interact(3, pointed); // place + client->interact(INTERACT_PLACE, pointed); // place } } @@ -3509,7 +3509,7 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos, runData.dig_instantly = runData.dig_time_complete == 0; if (client->moddingEnabled() && client->getScript()->on_punchnode(nodepos, n)) return; - client->interact(0, pointed); + client->interact(INTERACT_START_DIGGING, pointed); runData.digging = true; runData.ldown_for_dig = true; } @@ -3568,7 +3568,7 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos, MapNode wasnode = map.getNodeNoEx(nodepos, &is_valid_position); if (is_valid_position) { if (client->moddingEnabled() && - client->getScript()->on_dignode(nodepos, wasnode)) { + client->getScript()->on_dignode(nodepos, wasnode)) { return; } @@ -3584,7 +3584,7 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos, // implicit else: no prediction } - client->interact(2, pointed); + client->interact(INTERACT_DIGGING_COMPLETED, pointed); if (m_cache_enable_particles) { const ContentFeatures &features = |