Skip to content

Commit

Permalink
Merge pull request #8776 from osjc/FixGetNode
Browse files Browse the repository at this point in the history
Finish getNode cleanup
  • Loading branch information
osjc authored and sfan5 committed Aug 10, 2019
1 parent 291e773 commit 86d7f84
Show file tree
Hide file tree
Showing 26 changed files with 120 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/client/camera.cpp
Expand Up @@ -412,7 +412,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, f32 tool_r
// Prevent camera positioned inside nodes
const NodeDefManager *nodemgr = m_client->ndef();
MapNode n = m_client->getEnv().getClientMap()
.getNodeNoEx(floatToInt(my_cp, BS));
.getNode(floatToInt(my_cp, BS));

const ContentFeatures& features = nodemgr->get(n);
if (features.walkable) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/client.cpp
Expand Up @@ -1301,7 +1301,7 @@ MapNode Client::getNode(v3s16 p, bool *is_valid_position)
return {};
}
}
return m_env.getMap().getNodeNoEx(p, is_valid_position);
return m_env.getMap().getNode(p, is_valid_position);
}

void Client::addNode(v3s16 p, MapNode n, bool remove_metadata)
Expand Down
8 changes: 4 additions & 4 deletions src/client/clientenvironment.cpp
Expand Up @@ -218,7 +218,7 @@ void ClientEnvironment::step(float dtime)
f32 post_factor = 1; // 1 hp per node/s
if (info.type == COLLISION_NODE) {
const ContentFeatures &f = m_client->ndef()->
get(m_map->getNodeNoEx(info.node_p));
get(m_map->getNode(info.node_p));
// Determine fall damage multiplier
int addp = itemgroup_get(f.groups, "fall_damage_add_percent");
pre_factor = 1.0f + (float)addp / 100.0f;
Expand Down Expand Up @@ -248,7 +248,7 @@ void ClientEnvironment::step(float dtime)
MapNode node_at_lplayer(CONTENT_AIR, 0x0f, 0);

v3s16 p = lplayer->getLightPosition();
node_at_lplayer = m_map->getNodeNoEx(p);
node_at_lplayer = m_map->getNode(p);

u16 light = getInteriorLight(node_at_lplayer, 0, m_client->ndef());
final_color_blend(&lplayer->light_color, light, day_night_ratio);
Expand All @@ -270,7 +270,7 @@ void ClientEnvironment::step(float dtime)

// Get node at head
v3s16 p = cao->getLightPosition();
MapNode n = this->m_map->getNodeNoEx(p, &pos_ok);
MapNode n = this->m_map->getNode(p, &pos_ok);
if (pos_ok)
light = n.getLightBlend(day_night_ratio, m_client->ndef());
else
Expand Down Expand Up @@ -351,7 +351,7 @@ u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)

// Get node at head
v3s16 p = object->getLightPosition();
MapNode n = m_map->getNodeNoEx(p, &pos_ok);
MapNode n = m_map->getNode(p, &pos_ok);
if (pos_ok)
light = n.getLightBlend(getDayNightRatio(), m_client->ndef());
else
Expand Down
12 changes: 6 additions & 6 deletions src/client/clientmap.cpp
Expand Up @@ -160,7 +160,7 @@ void ClientMap::updateDrawList()
// inside ground
bool occlusion_culling_enabled = true;
if (g_settings->getBool("free_move")) {
MapNode n = getNodeNoEx(cam_pos_nodes);
MapNode n = getNode(cam_pos_nodes);
if (n.getContent() == CONTENT_IGNORE ||
m_nodedef->get(n).solidness == 2)
occlusion_culling_enabled = false;
Expand Down Expand Up @@ -497,15 +497,15 @@ static bool getVisibleBrightness(Map *map, const v3f &p0, v3f dir, float step,
// Check content nearly at camera position
{
v3s16 p = floatToInt(p0 /*+ dir * 3*BS*/, BS);
MapNode n = map->getNodeNoEx(p);
MapNode n = map->getNode(p);
if(ndef->get(n).param_type == CPT_LIGHT &&
!ndef->get(n).sunlight_propagates)
allow_allowing_non_sunlight_propagates = true;
}
// If would start at CONTENT_IGNORE, start closer
{
v3s16 p = floatToInt(pf, BS);
MapNode n = map->getNodeNoEx(p);
MapNode n = map->getNode(p);
if(n.getContent() == CONTENT_IGNORE){
float newd = 2*BS;
pf = p0 + dir * 2*newd;
Expand All @@ -519,7 +519,7 @@ static bool getVisibleBrightness(Map *map, const v3f &p0, v3f dir, float step,
step *= step_multiplier;

v3s16 p = floatToInt(pf, BS);
MapNode n = map->getNodeNoEx(p);
MapNode n = map->getNode(p);
if (allow_allowing_non_sunlight_propagates && i == 0 &&
ndef->get(n).param_type == CPT_LIGHT &&
!ndef->get(n).sunlight_propagates) {
Expand Down Expand Up @@ -621,7 +621,7 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,

int ret = 0;
if(brightness_count == 0){
MapNode n = getNodeNoEx(floatToInt(m_camera_position, BS));
MapNode n = getNode(floatToInt(m_camera_position, BS));
if(m_nodedef->get(n).param_type == CPT_LIGHT){
ret = decode_light(n.getLightBlend(daylight_factor, m_nodedef));
} else {
Expand All @@ -640,7 +640,7 @@ void ClientMap::renderPostFx(CameraMode cam_mode)
// Sadly ISceneManager has no "post effects" render pass, in that case we
// could just register for that and handle it in renderMap().

MapNode n = getNodeNoEx(floatToInt(m_camera_position, BS));
MapNode n = getNode(floatToInt(m_camera_position, BS));

// - If the player is in a solid node, make everything black.
// - If the player is in liquid, draw a semi-transparent overlay.
Expand Down
2 changes: 1 addition & 1 deletion src/client/content_cao.cpp
Expand Up @@ -991,7 +991,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
const NodeDefManager *ndef = m_client->ndef();
v3s16 p = floatToInt(getPosition() +
v3f(0.0f, (m_prop.collisionbox.MinEdge.Y - 0.5f) * BS, 0.0f), BS);
MapNode n = m_env->getMap().getNodeNoEx(p);
MapNode n = m_env->getMap().getNode(p);
SimpleSoundSpec spec = ndef->get(n).sound_footstep;
// Reduce footstep gain, as non-local-player footsteps are
// somehow louder.
Expand Down
2 changes: 1 addition & 1 deletion src/client/content_cso.cpp
Expand Up @@ -48,7 +48,7 @@ class SmokePuffCSO: public ClientSimpleObject
/* Update brightness */
u8 light;
bool pos_ok;
MapNode n = env->getMap().getNodeNoEx(floatToInt(pos, BS), &pos_ok);
MapNode n = env->getMap().getNode(floatToInt(pos, BS), &pos_ok);
light = pos_ok ? decode_light(n.getLightBlend(env->getDayNightRatio(),
env->getGameDef()->ndef()))
: 64;
Expand Down
26 changes: 13 additions & 13 deletions src/client/game.cpp
Expand Up @@ -2926,7 +2926,7 @@ void Game::updateSound(f32 dtime)
soundmaker->step(dtime);

ClientMap &map = client->getEnv().getClientMap();
MapNode n = map.getNodeNoEx(player->getFootstepNodePos());
MapNode n = map.getNode(player->getFootstepNodePos());
soundmaker->m_player_step_sound = nodedef_manager->get(n).sound_footstep;
}

Expand Down Expand Up @@ -3105,7 +3105,7 @@ PointedThing Game::updatePointedThing(
}
} else if (result.type == POINTEDTHING_NODE) {
// Update selection boxes
MapNode n = map.getNodeNoEx(result.node_undersurface);
MapNode n = map.getNode(result.node_undersurface);
std::vector<aabb3f> boxes;
n.getSelectionBoxes(nodedef, &boxes,
n.getNeighbors(result.node_undersurface, &map));
Expand All @@ -3132,12 +3132,12 @@ PointedThing Game::updatePointedThing(
v3s16 p = floatToInt(pf, BS);

// Get selection mesh light level
MapNode n = map.getNodeNoEx(p);
MapNode n = map.getNode(p);
u16 node_light = getInteriorLight(n, -1, nodedef);
u16 light_level = node_light;

for (const v3s16 &dir : g_6dirs) {
n = map.getNodeNoEx(p + dir);
n = map.getNode(p + dir);
node_light = getInteriorLight(n, -1, nodedef);
if (node_light > light_level)
light_level = node_light;
Expand Down Expand Up @@ -3198,7 +3198,7 @@ void Game::handlePointingAtNode(const PointedThing &pointed,
m_game_ui->setInfoText(unescape_translate(utf8_to_wide(
meta->getString("infotext"))));
} else {
MapNode n = map.getNodeNoEx(nodepos);
MapNode n = map.getNode(nodepos);

if (nodedef_manager->get(n).tiledef[0].name == "unknown_node.png") {
m_game_ui->setInfoText(L"Unknown node: " +
Expand All @@ -3215,7 +3215,7 @@ void Game::handlePointingAtNode(const PointedThing &pointed,
if (meta && !meta->getString("formspec").empty() && !random_input
&& !isKeyDown(KeyType::SNEAK)) {
// Report right click to server
if (nodedef_manager->get(map.getNodeNoEx(nodepos)).rightclickable) {
if (nodedef_manager->get(map.getNode(nodepos)).rightclickable) {
client->interact(INTERACT_PLACE, pointed);
}

Expand Down Expand Up @@ -3258,7 +3258,7 @@ void Game::handlePointingAtNode(const PointedThing &pointed,
SimpleSoundSpec();

if (def.node_placement_prediction.empty() ||
nodedef_manager->get(map.getNodeNoEx(nodepos)).rightclickable) {
nodedef_manager->get(map.getNode(nodepos)).rightclickable) {
client->interact(INTERACT_PLACE, pointed); // Report to server
} else {
soundmaker->m_player_rightpunch_sound =
Expand All @@ -3278,7 +3278,7 @@ bool Game::nodePlacementPrediction(const ItemDefinition &selected_def,
MapNode node;
bool is_valid_position;

node = map.getNodeNoEx(nodepos, &is_valid_position);
node = map.getNode(nodepos, &is_valid_position);
if (!is_valid_position)
return false;

Expand All @@ -3290,13 +3290,13 @@ bool Game::nodePlacementPrediction(const ItemDefinition &selected_def,
v3s16 p = neighbourpos;

// Place inside node itself if buildable_to
MapNode n_under = map.getNodeNoEx(nodepos, &is_valid_position);
MapNode n_under = map.getNode(nodepos, &is_valid_position);
if (is_valid_position)
{
if (nodedef->get(n_under).buildable_to)
p = nodepos;
else {
node = map.getNodeNoEx(p, &is_valid_position);
node = map.getNode(p, &is_valid_position);
if (is_valid_position &&!nodedef->get(node).buildable_to)
return false;
}
Expand Down Expand Up @@ -3363,7 +3363,7 @@ bool Game::nodePlacementPrediction(const ItemDefinition &selected_def,
else
pp = p + v3s16(0, -1, 0);

if (!nodedef->get(map.getNodeNoEx(pp)).walkable)
if (!nodedef->get(map.getNode(pp)).walkable)
return false;
}

Expand Down Expand Up @@ -3477,7 +3477,7 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
// See also: serverpackethandle.cpp, action == 2
LocalPlayer *player = client->getEnv().getLocalPlayer();
ClientMap &map = client->getEnv().getClientMap();
MapNode n = client->getEnv().getClientMap().getNodeNoEx(nodepos);
MapNode n = client->getEnv().getClientMap().getNode(nodepos);

// NOTE: Similar piece of code exists on the server side for
// cheat detection.
Expand Down Expand Up @@ -3565,7 +3565,7 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
runData.nodig_delay_timer = 0.15;

bool is_valid_position;
MapNode wasnode = map.getNodeNoEx(nodepos, &is_valid_position);
MapNode wasnode = map.getNode(nodepos, &is_valid_position);
if (is_valid_position) {
if (client->moddingEnabled() &&
client->getScript()->on_dignode(nodepos, wasnode)) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/gameui.cpp
Expand Up @@ -136,7 +136,7 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
if (pointed_old.type == POINTEDTHING_NODE) {
ClientMap &map = client->getEnv().getClientMap();
const NodeDefManager *nodedef = client->getNodeDefManager();
MapNode n = map.getNodeNoEx(pointed_old.node_undersurface);
MapNode n = map.getNode(pointed_old.node_undersurface);

if (n.getContent() != CONTENT_IGNORE && nodedef->get(n).name != "unknown") {
os << ", pointed: " << nodedef->get(n).name
Expand Down

0 comments on commit 86d7f84

Please sign in to comment.