Skip to content

Commit aab7c83

Browse files
committed
Remove some old dead code. Fix some Clang warnings in SRP (ng->N... will
always evaluate to true.
1 parent 2eb329c commit aab7c83

File tree

4 files changed

+2
-241
lines changed

4 files changed

+2
-241
lines changed

src/environment.cpp

-54
Original file line numberDiff line numberDiff line change
@@ -1314,51 +1314,6 @@ u16 ServerEnvironment::addActiveObject(ServerActiveObject *object)
13141314
return id;
13151315
}
13161316

1317-
#if 0
1318-
bool ServerEnvironment::addActiveObjectAsStatic(ServerActiveObject *obj)
1319-
{
1320-
assert(obj);
1321-
1322-
v3f objectpos = obj->getBasePosition();
1323-
1324-
// The block in which the object resides in
1325-
v3s16 blockpos_o = getNodeBlockPos(floatToInt(objectpos, BS));
1326-
1327-
/*
1328-
Update the static data
1329-
*/
1330-
1331-
// Create new static object
1332-
std::string staticdata = obj->getStaticData();
1333-
StaticObject s_obj(obj->getType(), objectpos, staticdata);
1334-
// Add to the block where the object is located in
1335-
v3s16 blockpos = getNodeBlockPos(floatToInt(objectpos, BS));
1336-
// Get or generate the block
1337-
MapBlock *block = m_map->emergeBlock(blockpos);
1338-
1339-
bool succeeded = false;
1340-
1341-
if(block)
1342-
{
1343-
block->m_static_objects.insert(0, s_obj);
1344-
block->raiseModified(MOD_STATE_WRITE_AT_UNLOAD,
1345-
"addActiveObjectAsStatic");
1346-
succeeded = true;
1347-
}
1348-
else{
1349-
infostream<<"ServerEnvironment::addActiveObjectAsStatic: "
1350-
<<"Could not find or generate "
1351-
<<"a block for storing static object"<<std::endl;
1352-
succeeded = false;
1353-
}
1354-
1355-
if(obj->environmentDeletes())
1356-
delete obj;
1357-
1358-
return succeeded;
1359-
}
1360-
#endif
1361-
13621317
/*
13631318
Finds out what new objects have been added to
13641319
inside a radius around a position
@@ -2182,15 +2137,6 @@ void ClientEnvironment::step(float dtime)
21822137

21832138
v3f d = d_wanted.normalize() * dl;
21842139
speed += d;
2185-
2186-
#if 0 // old code
2187-
if(speed.X > lplayer->movement_liquid_fluidity + lplayer->movement_liquid_fluidity_smooth) speed.X -= lplayer->movement_liquid_fluidity_smooth;
2188-
if(speed.X < -lplayer->movement_liquid_fluidity - lplayer->movement_liquid_fluidity_smooth) speed.X += lplayer->movement_liquid_fluidity_smooth;
2189-
if(speed.Y > lplayer->movement_liquid_fluidity + lplayer->movement_liquid_fluidity_smooth) speed.Y -= lplayer->movement_liquid_fluidity_smooth;
2190-
if(speed.Y < -lplayer->movement_liquid_fluidity - lplayer->movement_liquid_fluidity_smooth) speed.Y += lplayer->movement_liquid_fluidity_smooth;
2191-
if(speed.Z > lplayer->movement_liquid_fluidity + lplayer->movement_liquid_fluidity_smooth) speed.Z -= lplayer->movement_liquid_fluidity_smooth;
2192-
if(speed.Z < -lplayer->movement_liquid_fluidity - lplayer->movement_liquid_fluidity_smooth) speed.Z += lplayer->movement_liquid_fluidity_smooth;
2193-
#endif
21942140
}
21952141

21962142
lplayer->setSpeed(speed);

src/noise.cpp

-47
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,6 @@ inline float biLinearInterpolation(
192192
{
193193
float tx = easeCurve(x);
194194
float ty = easeCurve(y);
195-
#if 0
196-
return (
197-
v00 * (1 - tx) * (1 - ty) +
198-
v10 * tx * (1 - ty) +
199-
v01 * (1 - tx) * ty +
200-
v11 * tx * ty
201-
);
202-
#endif
203195
float u = linearInterpolation(v00, v10, tx);
204196
float v = linearInterpolation(v01, v11, tx);
205197
return linearInterpolation(u, v, ty);
@@ -225,18 +217,6 @@ float triLinearInterpolation(
225217
float tx = easeCurve(x);
226218
float ty = easeCurve(y);
227219
float tz = easeCurve(z);
228-
#if 0
229-
return (
230-
v000 * (1 - tx) * (1 - ty) * (1 - tz) +
231-
v100 * tx * (1 - ty) * (1 - tz) +
232-
v010 * (1 - tx) * ty * (1 - tz) +
233-
v110 * tx * ty * (1 - tz) +
234-
v001 * (1 - tx) * (1 - ty) * tz +
235-
v101 * tx * (1 - ty) * tz +
236-
v011 * (1 - tx) * ty * tz +
237-
v111 * tx * ty * tz
238-
);
239-
#endif
240220
float u = biLinearInterpolationNoEase(v000, v100, v010, v110, tx, ty);
241221
float v = biLinearInterpolationNoEase(v001, v101, v011, v111, tx, ty);
242222
return linearInterpolation(u, v, tz);
@@ -252,33 +232,6 @@ float triLinearInterpolationNoEase(
252232
return linearInterpolation(u, v, z);
253233
}
254234

255-
256-
#if 0
257-
float noise2d_gradient(float x, float y, int seed)
258-
{
259-
// Calculate the integer coordinates
260-
int x0 = (x > 0.0 ? (int)x : (int)x - 1);
261-
int y0 = (y > 0.0 ? (int)y : (int)y - 1);
262-
// Calculate the remaining part of the coordinates
263-
float xl = x - (float)x0;
264-
float yl = y - (float)y0;
265-
// Calculate random cosine lookup table indices for the integer corners.
266-
// They are looked up as unit vector gradients from the lookup table.
267-
int n00 = (int)((noise2d(x0, y0, seed)+1)*8);
268-
int n10 = (int)((noise2d(x0+1, y0, seed)+1)*8);
269-
int n01 = (int)((noise2d(x0, y0+1, seed)+1)*8);
270-
int n11 = (int)((noise2d(x0+1, y0+1, seed)+1)*8);
271-
// Make a dot product for the gradients and the positions, to get the values
272-
float s = dotProduct(cos_lookup[n00], cos_lookup[(n00+12)%16], xl, yl);
273-
float u = dotProduct(-cos_lookup[n10], cos_lookup[(n10+12)%16], 1.-xl, yl);
274-
float v = dotProduct(cos_lookup[n01], -cos_lookup[(n01+12)%16], xl, 1.-yl);
275-
float w = dotProduct(-cos_lookup[n11], -cos_lookup[(n11+12)%16], 1.-xl, 1.-yl);
276-
// Interpolate between the values
277-
return biLinearInterpolation(s,u,v,w,xl,yl);
278-
}
279-
#endif
280-
281-
282235
float noise2d_gradient(float x, float y, int seed, bool eased)
283236
{
284237
// Calculate the integer coordinates

src/util/srp.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static NGConstant *new_ng( SRP_NGType ng_type, const char *n_hex, const char *g_
172172
mpz_init(ng->N);
173173
mpz_init(ng->g);
174174

175-
if (!ng || !ng->N || !ng->g)
175+
if (!ng)
176176
return 0;
177177

178178
if (ng_type != SRP_NG_CUSTOM) {
@@ -823,7 +823,7 @@ struct SRPUser *srp_user_new(SRP_HashAlgorithm alg, SRP_NGType ng_type,
823823
mpz_init(usr->A);
824824
mpz_init(usr->S);
825825

826-
if (!usr->ng || !usr->a || !usr->A || !usr->S)
826+
if (!usr->ng)
827827
goto err_exit;
828828

829829
usr->username = (char*)malloc(ulen);

src/voxel.cpp

-138
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ void VoxelManipulator::unspreadLight(enum LightBank bank, v3s16 p, u8 oldlight,
390390
}
391391
}
392392

393-
#if 1
394393
/*
395394
Goes recursively through the neighbours of the node.
396395
@@ -421,115 +420,6 @@ void VoxelManipulator::unspreadLight(enum LightBank bank,
421420
unspreadLight(bank, j->first, j->second, light_sources, nodemgr);
422421
}
423422
}
424-
#endif
425-
426-
#if 0
427-
/*
428-
Goes recursively through the neighbours of the node.
429-
430-
Alters only transparent nodes.
431-
432-
If the lighting of the neighbour is lower than the lighting of
433-
the node was (before changing it to 0 at the step before), the
434-
lighting of the neighbour is set to 0 and then the same stuff
435-
repeats for the neighbour.
436-
437-
The ending nodes of the routine are stored in light_sources.
438-
This is useful when a light is removed. In such case, this
439-
routine can be called for the light node and then again for
440-
light_sources to re-light the area without the removed light.
441-
442-
values of from_nodes are lighting values.
443-
*/
444-
void VoxelManipulator::unspreadLight(enum LightBank bank,
445-
core::map<v3s16, u8> & from_nodes,
446-
core::map<v3s16, bool> & light_sources)
447-
{
448-
v3s16 dirs[6] = {
449-
v3s16(0,0,1), // back
450-
v3s16(0,1,0), // top
451-
v3s16(1,0,0), // right
452-
v3s16(0,0,-1), // front
453-
v3s16(0,-1,0), // bottom
454-
v3s16(-1,0,0), // left
455-
};
456-
457-
if(from_nodes.size() == 0)
458-
return;
459-
460-
core::map<v3s16, u8> unlighted_nodes;
461-
core::map<v3s16, u8>::Iterator j;
462-
j = from_nodes.getIterator();
463-
464-
for(; j.atEnd() == false; j++)
465-
{
466-
v3s16 pos = j.getNode()->getKey();
467-
468-
addArea(VoxelArea(pos - v3s16(1,1,1), pos + v3s16(1,1,1)));
469-
470-
//MapNode &n = m_data[m_area.index(pos)];
471-
472-
u8 oldlight = j.getNode()->getValue();
473-
474-
// Loop through 6 neighbors
475-
for(u16 i=0; i<6; i++)
476-
{
477-
// Get the position of the neighbor node
478-
v3s16 n2pos = pos + dirs[i];
479-
480-
u32 n2i = m_area.index(n2pos);
481-
482-
if(m_flags[n2i] & VOXELFLAG_NO_DATA)
483-
continue;
484-
485-
MapNode &n2 = m_data[n2i];
486-
487-
/*
488-
If the neighbor is dimmer than what was specified
489-
as oldlight (the light of the previous node)
490-
*/
491-
if(n2.getLight(bank, nodemgr) < oldlight)
492-
{
493-
/*
494-
And the neighbor is transparent and it has some light
495-
*/
496-
if(nodemgr->get(n2).light_propagates && n2.getLight(bank, nodemgr) != 0)
497-
{
498-
/*
499-
Set light to 0 and add to queue
500-
*/
501-
502-
u8 current_light = n2.getLight(bank, nodemgr);
503-
n2.setLight(bank, 0);
504-
505-
unlighted_nodes.insert(n2pos, current_light);
506-
507-
/*
508-
Remove from light_sources if it is there
509-
NOTE: This doesn't happen nearly at all
510-
*/
511-
/*if(light_sources.find(n2pos))
512-
{
513-
std::cout<<"Removed from light_sources"<<std::endl;
514-
light_sources.remove(n2pos);
515-
}*/
516-
}
517-
}
518-
else{
519-
light_sources.insert(n2pos, true);
520-
}
521-
}
522-
}
523-
524-
/*dstream<<"unspreadLight(): Changed block "
525-
<<blockchangecount<<" times"
526-
<<" for "<<from_nodes.size()<<" nodes"
527-
<<std::endl;*/
528-
529-
if(unlighted_nodes.size() > 0)
530-
unspreadLight(bank, unlighted_nodes, light_sources);
531-
}
532-
#endif
533423

534424
void VoxelManipulator::spreadLight(enum LightBank bank, v3s16 p,
535425
INodeDefManager *nodemgr)
@@ -594,36 +484,9 @@ void VoxelManipulator::spreadLight(enum LightBank bank, v3s16 p,
594484
}
595485
}
596486

597-
#if 0
598-
/*
599-
Lights neighbors of from_nodes, collects all them and then
600-
goes on recursively.
601-
602-
NOTE: This is faster on small areas but will overflow the
603-
stack on large areas. Thus it is not used.
604-
*/
605-
void VoxelManipulator::spreadLight(enum LightBank bank,
606-
core::map<v3s16, bool> & from_nodes)
607-
{
608-
if(from_nodes.size() == 0)
609-
return;
610-
611-
core::map<v3s16, bool> lighted_nodes;
612-
core::map<v3s16, bool>::Iterator j;
613-
j = from_nodes.getIterator();
614-
615-
for(; j.atEnd() == false; j++)
616-
{
617-
v3s16 pos = j.getNode()->getKey();
618-
619-
spreadLight(bank, pos);
620-
}
621-
}
622-
#endif
623487

624488
const MapNode VoxelManipulator::ContentIgnoreNode = MapNode(CONTENT_IGNORE);
625489

626-
#if 1
627490
/*
628491
Lights neighbors of from_nodes, collects all them and then
629492
goes on recursively.
@@ -716,6 +579,5 @@ void VoxelManipulator::spreadLight(enum LightBank bank,
716579
if(!lighted_nodes.empty())
717580
spreadLight(bank, lighted_nodes, nodemgr);
718581
}
719-
#endif
720582

721583
//END

0 commit comments

Comments
 (0)