Add a delay after digging before place node can happen
This commit is contained in:
parent
3be722c135
commit
d9662039df
16
src/game.cpp
16
src/game.cpp
|
@ -1354,6 +1354,7 @@ struct GameRunData {
|
||||||
bool update_wielded_item_trigger;
|
bool update_wielded_item_trigger;
|
||||||
bool reset_jump_timer;
|
bool reset_jump_timer;
|
||||||
float nodig_delay_timer;
|
float nodig_delay_timer;
|
||||||
|
float noplace_delay_timer;
|
||||||
float dig_time;
|
float dig_time;
|
||||||
float dig_time_complete;
|
float dig_time_complete;
|
||||||
float repeat_rightclick_timer;
|
float repeat_rightclick_timer;
|
||||||
|
@ -2339,6 +2340,9 @@ inline void Game::updateInteractTimers(GameRunData *runData, f32 dtime)
|
||||||
if (runData->object_hit_delay_timer >= 0)
|
if (runData->object_hit_delay_timer >= 0)
|
||||||
runData->object_hit_delay_timer -= dtime;
|
runData->object_hit_delay_timer -= dtime;
|
||||||
|
|
||||||
|
if (runData->noplace_delay_timer >= 0)
|
||||||
|
runData->noplace_delay_timer -= dtime;
|
||||||
|
|
||||||
runData->time_from_last_punch += dtime;
|
runData->time_from_last_punch += dtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3524,13 +3528,16 @@ void Game::handlePointingAtNode(GameRunData *runData,
|
||||||
digging = true;
|
digging = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_TOUCHSCREENGUI
|
||||||
|
bool place = (input->getRightClicked() || input->getLeftReleased() ||
|
||||||
|
runData->repeat_rightclick_timer >= m_repeat_right_click_time) &&
|
||||||
|
client->checkPrivilege("interact");
|
||||||
|
place &= !digging;
|
||||||
|
place &= runData->noplace_delay_timer <= 0.0;
|
||||||
|
#else
|
||||||
bool place = (input->getRightClicked() ||
|
bool place = (input->getRightClicked() ||
|
||||||
runData->repeat_rightclick_timer >= m_repeat_right_click_time) &&
|
runData->repeat_rightclick_timer >= m_repeat_right_click_time) &&
|
||||||
client->checkPrivilege("interact");
|
client->checkPrivilege("interact");
|
||||||
|
|
||||||
#ifdef HAVE_TOUCHSCREENGUI
|
|
||||||
place &= !digging;
|
|
||||||
place |= input->getLeftReleased();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (place) {
|
if (place) {
|
||||||
|
@ -3707,6 +3714,7 @@ void Game::handleDigging(GameRunData *runData,
|
||||||
client->setCrack(runData->dig_index, nodepos);
|
client->setCrack(runData->dig_index, nodepos);
|
||||||
} else {
|
} else {
|
||||||
infostream << "Digging completed" << std::endl;
|
infostream << "Digging completed" << std::endl;
|
||||||
|
runData->noplace_delay_timer = 1.0;
|
||||||
client->interact(2, pointed);
|
client->interact(2, pointed);
|
||||||
client->setCrack(-1, v3s16(0, 0, 0));
|
client->setCrack(-1, v3s16(0, 0, 0));
|
||||||
bool is_valid_position;
|
bool is_valid_position;
|
||||||
|
|
Loading…
Reference in New Issue