aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/environment.cpp54
-rw-r--r--src/noise.cpp47
-rw-r--r--src/util/srp.cpp4
-rw-r--r--src/voxel.cpp138
4 files changed, 2 insertions, 241 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index 5d7321f60..cf0ebacfd 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -1314,51 +1314,6 @@ u16 ServerEnvironment::addActiveObject(ServerActiveObject *object)
return id;
}
-#if 0
-bool ServerEnvironment::addActiveObjectAsStatic(ServerActiveObject *obj)
-{
- assert(obj);
-
- v3f objectpos = obj->getBasePosition();
-
- // The block in which the object resides in
- v3s16 blockpos_o = getNodeBlockPos(floatToInt(objectpos, BS));
-
- /*
- Update the static data
- */
-
- // Create new static object
- std::string staticdata = obj->getStaticData();
- StaticObject s_obj(obj->getType(), objectpos, staticdata);
- // Add to the block where the object is located in
- v3s16 blockpos = getNodeBlockPos(floatToInt(objectpos, BS));
- // Get or generate the block
- MapBlock *block = m_map->emergeBlock(blockpos);
-
- bool succeeded = false;
-
- if(block)
- {
- block->m_static_objects.insert(0, s_obj);
- block->raiseModified(MOD_STATE_WRITE_AT_UNLOAD,
- "addActiveObjectAsStatic");
- succeeded = true;
- }
- else{
- infostream<<"ServerEnvironment::addActiveObjectAsStatic: "
- <<"Could not find or generate "
- <<"a block for storing static object"<<std::endl;
- succeeded = false;
- }
-
- if(obj->environmentDeletes())
- delete obj;
-
- return succeeded;
-}
-#endif
-
/*
Finds out what new objects have been added to
inside a radius around a position
@@ -2182,15 +2137,6 @@ void ClientEnvironment::step(float dtime)
v3f d = d_wanted.normalize() * dl;
speed += d;
-
-#if 0 // old code
- if(speed.X > lplayer->movement_liquid_fluidity + lplayer->movement_liquid_fluidity_smooth) speed.X -= lplayer->movement_liquid_fluidity_smooth;
- if(speed.X < -lplayer->movement_liquid_fluidity - lplayer->movement_liquid_fluidity_smooth) speed.X += lplayer->movement_liquid_fluidity_smooth;
- if(speed.Y > lplayer->movement_liquid_fluidity + lplayer->movement_liquid_fluidity_smooth) speed.Y -= lplayer->movement_liquid_fluidity_smooth;
- if(speed.Y < -lplayer->movement_liquid_fluidity - lplayer->movement_liquid_fluidity_smooth) speed.Y += lplayer->movement_liquid_fluidity_smooth;
- if(speed.Z > lplayer->movement_liquid_fluidity + lplayer->movement_liquid_fluidity_smooth) speed.Z -= lplayer->movement_liquid_fluidity_smooth;
- if(speed.Z < -lplayer->movement_liquid_fluidity - lplayer->movement_liquid_fluidity_smooth) speed.Z += lplayer->movement_liquid_fluidity_smooth;
-#endif
}
lplayer->setSpeed(speed);
diff --git a/src/noise.cpp b/src/noise.cpp
index 5b08eb942..443c405ce 100644
--- a/src/noise.cpp
+++ b/src/noise.cpp
@@ -192,14 +192,6 @@ inline float biLinearInterpolation(
{
float tx = easeCurve(x);
float ty = easeCurve(y);
-#if 0
- return (
- v00 * (1 - tx) * (1 - ty) +
- v10 * tx * (1 - ty) +
- v01 * (1 - tx) * ty +
- v11 * tx * ty
- );
-#endif
float u = linearInterpolation(v00, v10, tx);
float v = linearInterpolation(v01, v11, tx);
return linearInterpolation(u, v, ty);
@@ -225,18 +217,6 @@ float triLinearInterpolation(
float tx = easeCurve(x);
float ty = easeCurve(y);
float tz = easeCurve(z);
-#if 0
- return (
- v000 * (1 - tx) * (1 - ty) * (1 - tz) +
- v100 * tx * (1 - ty) * (1 - tz) +
- v010 * (1 - tx) * ty * (1 - tz) +
- v110 * tx * ty * (1 - tz) +
- v001 * (1 - tx) * (1 - ty) * tz +
- v101 * tx * (1 - ty) * tz +
- v011 * (1 - tx) * ty * tz +
- v111 * tx * ty * tz
- );
-#endif
float u = biLinearInterpolationNoEase(v000, v100, v010, v110, tx, ty);
float v = biLinearInterpolationNoEase(v001, v101, v011, v111, tx, ty);
return linearInterpolation(u, v, tz);
@@ -252,33 +232,6 @@ float triLinearInterpolationNoEase(
return linearInterpolation(u, v, z);
}
-
-#if 0
-float noise2d_gradient(float x, float y, int seed)
-{
- // Calculate the integer coordinates
- int x0 = (x > 0.0 ? (int)x : (int)x - 1);
- int y0 = (y > 0.0 ? (int)y : (int)y - 1);
- // Calculate the remaining part of the coordinates
- float xl = x - (float)x0;
- float yl = y - (float)y0;
- // Calculate random cosine lookup table indices for the integer corners.
- // They are looked up as unit vector gradients from the lookup table.
- int n00 = (int)((noise2d(x0, y0, seed)+1)*8);
- int n10 = (int)((noise2d(x0+1, y0, seed)+1)*8);
- int n01 = (int)((noise2d(x0, y0+1, seed)+1)*8);
- int n11 = (int)((noise2d(x0+1, y0+1, seed)+1)*8);
- // Make a dot product for the gradients and the positions, to get the values
- float s = dotProduct(cos_lookup[n00], cos_lookup[(n00+12)%16], xl, yl);
- float u = dotProduct(-cos_lookup[n10], cos_lookup[(n10+12)%16], 1.-xl, yl);
- float v = dotProduct(cos_lookup[n01], -cos_lookup[(n01+12)%16], xl, 1.-yl);
- float w = dotProduct(-cos_lookup[n11], -cos_lookup[(n11+12)%16], 1.-xl, 1.-yl);
- // Interpolate between the values
- return biLinearInterpolation(s,u,v,w,xl,yl);
-}
-#endif
-
-
float noise2d_gradient(float x, float y, int seed, bool eased)
{
// Calculate the integer coordinates
diff --git a/src/util/srp.cpp b/src/util/srp.cpp
index cc8bac6bb..6fafe8280 100644
--- a/src/util/srp.cpp
+++ b/src/util/srp.cpp
@@ -172,7 +172,7 @@ static NGConstant *new_ng( SRP_NGType ng_type, const char *n_hex, const char *g_
mpz_init(ng->N);
mpz_init(ng->g);
- if (!ng || !ng->N || !ng->g)
+ if (!ng)
return 0;
if (ng_type != SRP_NG_CUSTOM) {
@@ -823,7 +823,7 @@ struct SRPUser *srp_user_new(SRP_HashAlgorithm alg, SRP_NGType ng_type,
mpz_init(usr->A);
mpz_init(usr->S);
- if (!usr->ng || !usr->a || !usr->A || !usr->S)
+ if (!usr->ng)
goto err_exit;
usr->username = (char*)malloc(ulen);
diff --git a/src/voxel.cpp b/src/voxel.cpp
index a5e0b09fe..87773b240 100644
--- a/src/voxel.cpp
+++ b/src/voxel.cpp
@@ -390,7 +390,6 @@ void VoxelManipulator::unspreadLight(enum LightBank bank, v3s16 p, u8 oldlight,
}
}
-#if 1
/*
Goes recursively through the neighbours of the node.
@@ -421,115 +420,6 @@ void VoxelManipulator::unspreadLight(enum LightBank bank,
unspreadLight(bank, j->first, j->second, light_sources, nodemgr);
}
}
-#endif
-
-#if 0
-/*
- Goes recursively through the neighbours of the node.
-
- Alters only transparent nodes.
-
- If the lighting of the neighbour is lower than the lighting of
- the node was (before changing it to 0 at the step before), the
- lighting of the neighbour is set to 0 and then the same stuff
- repeats for the neighbour.
-
- The ending nodes of the routine are stored in light_sources.
- This is useful when a light is removed. In such case, this
- routine can be called for the light node and then again for
- light_sources to re-light the area without the removed light.
-
- values of from_nodes are lighting values.
-*/
-void VoxelManipulator::unspreadLight(enum LightBank bank,
- core::map<v3s16, u8> & from_nodes,
- core::map<v3s16, bool> & light_sources)
-{
- v3s16 dirs[6] = {
- v3s16(0,0,1), // back
- v3s16(0,1,0), // top
- v3s16(1,0,0), // right
- v3s16(0,0,-1), // front
- v3s16(0,-1,0), // bottom
- v3s16(-1,0,0), // left
- };
-
- if(from_nodes.size() == 0)
- return;
-
- core::map<v3s16, u8> unlighted_nodes;
- core::map<v3s16, u8>::Iterator j;
- j = from_nodes.getIterator();
-
- for(; j.atEnd() == false; j++)
- {
- v3s16 pos = j.getNode()->getKey();
-
- addArea(VoxelArea(pos - v3s16(1,1,1), pos + v3s16(1,1,1)));
-
- //MapNode &n = m_data[m_area.index(pos)];
-
- u8 oldlight = j.getNode()->getValue();
-
- // Loop through 6 neighbors
- for(u16 i=0; i<6; i++)
- {
- // Get the position of the neighbor node
- v3s16 n2pos = pos + dirs[i];
-
- u32 n2i = m_area.index(n2pos);
-
- if(m_flags[n2i] & VOXELFLAG_NO_DATA)
- continue;
-
- MapNode &n2 = m_data[n2i];
-
- /*
- If the neighbor is dimmer than what was specified
- as oldlight (the light of the previous node)
- */
- if(n2.getLight(bank, nodemgr) < oldlight)
- {
- /*
- And the neighbor is transparent and it has some light
- */
- if(nodemgr->get(n2).light_propagates && n2.getLight(bank, nodemgr) != 0)
- {
- /*
- Set light to 0 and add to queue
- */
-
- u8 current_light = n2.getLight(bank, nodemgr);
- n2.setLight(bank, 0);
-
- unlighted_nodes.insert(n2pos, current_light);
-
- /*
- Remove from light_sources if it is there
- NOTE: This doesn't happen nearly at all
- */
- /*if(light_sources.find(n2pos))
- {
- std::cout<<"Removed from light_sources"<<std::endl;
- light_sources.remove(n2pos);
- }*/
- }
- }
- else{
- light_sources.insert(n2pos, true);
- }
- }
- }
-
- /*dstream<<"unspreadLight(): Changed block "
- <<blockchangecount<<" times"
- <<" for "<<from_nodes.size()<<" nodes"
- <<std::endl;*/
-
- if(unlighted_nodes.size() > 0)
- unspreadLight(bank, unlighted_nodes, light_sources);
-}
-#endif
void VoxelManipulator::spreadLight(enum LightBank bank, v3s16 p,
INodeDefManager *nodemgr)
@@ -594,36 +484,9 @@ void VoxelManipulator::spreadLight(enum LightBank bank, v3s16 p,
}
}
-#if 0
-/*
- Lights neighbors of from_nodes, collects all them and then
- goes on recursively.
-
- NOTE: This is faster on small areas but will overflow the
- stack on large areas. Thus it is not used.
-*/
-void VoxelManipulator::spreadLight(enum LightBank bank,
- core::map<v3s16, bool> & from_nodes)
-{
- if(from_nodes.size() == 0)
- return;
-
- core::map<v3s16, bool> lighted_nodes;
- core::map<v3s16, bool>::Iterator j;
- j = from_nodes.getIterator();
-
- for(; j.atEnd() == false; j++)
- {
- v3s16 pos = j.getNode()->getKey();
-
- spreadLight(bank, pos);
- }
-}
-#endif
const MapNode VoxelManipulator::ContentIgnoreNode = MapNode(CONTENT_IGNORE);
-#if 1
/*
Lights neighbors of from_nodes, collects all them and then
goes on recursively.
@@ -716,6 +579,5 @@ void VoxelManipulator::spreadLight(enum LightBank bank,
if(!lighted_nodes.empty())
spreadLight(bank, lighted_nodes, nodemgr);
}
-#endif
//END