Skip to content

Commit fa7fe51

Browse files
committedJul 21, 2015
Remove profiler.h include where it's not needed. Remove some unreachable and very old code
1 parent 5ebb423 commit fa7fe51

10 files changed

+14
-149
lines changed
 

Diff for: ‎src/camera.cpp

+12-30
Original file line numberDiff line numberDiff line change
@@ -162,55 +162,37 @@ void Camera::step(f32 dtime)
162162
{
163163
//f32 offset = dtime * m_view_bobbing_speed * 0.035;
164164
f32 offset = dtime * m_view_bobbing_speed * 0.030;
165-
if (m_view_bobbing_state == 2)
166-
{
167-
#if 0
165+
if (m_view_bobbing_state == 2) {
168166
// Animation is getting turned off
169-
if (m_view_bobbing_anim < 0.5)
167+
if (m_view_bobbing_anim < 0.25) {
170168
m_view_bobbing_anim -= offset;
171-
else
169+
} else if (m_view_bobbing_anim > 0.75) {
172170
m_view_bobbing_anim += offset;
173-
if (m_view_bobbing_anim <= 0 || m_view_bobbing_anim >= 1)
174-
{
175-
m_view_bobbing_anim = 0;
176-
m_view_bobbing_state = 0;
177171
}
178-
#endif
179-
#if 1
180-
// Animation is getting turned off
181-
if(m_view_bobbing_anim < 0.25)
182-
{
183-
m_view_bobbing_anim -= offset;
184-
} else if(m_view_bobbing_anim > 0.75) {
185-
m_view_bobbing_anim += offset;
186-
}
187-
if(m_view_bobbing_anim < 0.5)
188-
{
172+
173+
if (m_view_bobbing_anim < 0.5) {
189174
m_view_bobbing_anim += offset;
190-
if(m_view_bobbing_anim > 0.5)
175+
if (m_view_bobbing_anim > 0.5)
191176
m_view_bobbing_anim = 0.5;
192177
} else {
193178
m_view_bobbing_anim -= offset;
194-
if(m_view_bobbing_anim < 0.5)
179+
if (m_view_bobbing_anim < 0.5)
195180
m_view_bobbing_anim = 0.5;
196181
}
197-
if(m_view_bobbing_anim <= 0 || m_view_bobbing_anim >= 1 ||
198-
fabs(m_view_bobbing_anim - 0.5) < 0.01)
199-
{
182+
183+
if (m_view_bobbing_anim <= 0 || m_view_bobbing_anim >= 1 ||
184+
fabs(m_view_bobbing_anim - 0.5) < 0.01) {
200185
m_view_bobbing_anim = 0;
201186
m_view_bobbing_state = 0;
202187
}
203-
#endif
204188
}
205-
else
206-
{
189+
else {
Has conversations. Original line has conversations.
207190
float was = m_view_bobbing_anim;
208191
m_view_bobbing_anim = my_modf(m_view_bobbing_anim + offset);
209192
bool step = (was == 0 ||
210193
(was < 0.5f && m_view_bobbing_anim >= 0.5f) ||
211194
(was > 0.5f && m_view_bobbing_anim <= 0.5f));
212-
if(step)
213-
{
195+
if(step) {
214196
MtEvent *e = new SimpleTriggerEvent("ViewBobbingStep");
215197
m_gamedef->event()->put(e);
216198
}

Diff for: ‎src/collision.cpp

+1-74
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
458458
pos_f += speed_f * nearest_dtime;
459459
dtime -= nearest_dtime;
460460
}
461-
461+
462462
bool is_collision = true;
463463
if(is_unloaded[nearest_boxindex])
464464
is_collision = false;
@@ -561,76 +561,3 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
561561

562562
return result;
563563
}
564-
565-
#if 0
566-
// This doesn't seem to work and isn't used
567-
collisionMoveResult collisionMovePrecise(Map *map, IGameDef *gamedef,
568-
f32 pos_max_d, const aabb3f &box_0,
569-
f32 stepheight, f32 dtime,
570-
v3f &pos_f, v3f &speed_f, v3f &accel_f)
571-
{
572-
//TimeTaker tt("collisionMovePrecise");
573-
ScopeProfiler sp(g_profiler, "collisionMovePrecise avg", SPT_AVG);
574-
575-
collisionMoveResult final_result;
576-
577-
// If there is no speed, there are no collisions
578-
if(speed_f.getLength() == 0)
579-
return final_result;
580-
581-
// Don't allow overly huge dtime
582-
if(dtime > 2.0)
583-
dtime = 2.0;
584-
585-
f32 dtime_downcount = dtime;
586-
587-
u32 loopcount = 0;
588-
do
589-
{
590-
loopcount++;
591-
592-
// Maximum time increment (for collision detection etc)
593-
// time = distance / speed
594-
f32 dtime_max_increment = 1.0;
595-
if(speed_f.getLength() != 0)
596-
dtime_max_increment = pos_max_d / speed_f.getLength();
597-
598-
// Maximum time increment is 10ms or lower
599-
if(dtime_max_increment > 0.01)
600-
dtime_max_increment = 0.01;
601-
602-
f32 dtime_part;
603-
if(dtime_downcount > dtime_max_increment)
604-
{
605-
dtime_part = dtime_max_increment;
606-
dtime_downcount -= dtime_part;
607-
}
608-
else
609-
{
610-
dtime_part = dtime_downcount;
611-
/*
612-
Setting this to 0 (no -=dtime_part) disables an infinite loop
613-
when dtime_part is so small that dtime_downcount -= dtime_part
614-
does nothing
615-
*/
616-
dtime_downcount = 0;
617-
}
618-
619-
collisionMoveResult result = collisionMoveSimple(map, gamedef,
620-
pos_max_d, box_0, stepheight, dtime_part,
621-
pos_f, speed_f, accel_f);
622-
623-
if(result.touching_ground)
624-
final_result.touching_ground = true;
625-
if(result.collides)
626-
final_result.collides = true;
627-
if(result.collides_xz)
628-
final_result.collides_xz = true;
629-
if(result.standing_on_unloaded)
630-
final_result.standing_on_unloaded = true;
631-
}
632-
while(dtime_downcount > 0.001);
633-
634-
return final_result;
635-
}
636-
#endif

Diff for: ‎src/collision.h

-9
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,6 @@ collisionMoveResult collisionMoveSimple(Environment *env,IGameDef *gamedef,
7575
v3f &accel_f,ActiveObject* self=0,
7676
bool collideWithObjects=true);
7777

78-
#if 0
79-
// This doesn't seem to work and isn't used
80-
// Moves using as many iterations as needed
81-
collisionMoveResult collisionMovePrecise(Map *map, IGameDef *gamedef,
82-
f32 pos_max_d, const aabb3f &box_0,
83-
f32 stepheight, f32 dtime,
84-
v3f &pos_f, v3f &speed_f, v3f &accel_f);
85-
#endif
86-
8778
// Helper function:
8879
// Checks for collision of a moving aabbox with a static aabbox
8980
// Returns -1 if no collision, 0 if X collision, 1 if Y collision, 2 if Z collision

Diff for: ‎src/content_sao.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2323
#include "collision.h"
2424
#include "environment.h"
2525
#include "settings.h"
26-
#include "profiler.h"
2726
#include "serialization.h" // For compressZlib
2827
#include "tool.h" // For ToolCapabilities
2928
#include "gamedef.h"

Diff for: ‎src/main.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
4040
#include "game.h"
4141
#include "defaultsettings.h"
4242
#include "gettext.h"
43-
#include "profiler.h"
4443
#include "log.h"
4544
#include "quicktune.h"
4645
#include "httpfetch.h"

Diff for: ‎src/mapgen_singlenode.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2424
#include "map.h"
2525
#include "nodedef.h"
2626
#include "voxelalgorithms.h"
27-
#include "profiler.h"
2827
#include "emerge.h"
2928

3029

Diff for: ‎src/mapgen_v5.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2727
#include "content_sao.h"
2828
#include "nodedef.h"
2929
#include "voxelalgorithms.h"
30-
#include "profiler.h"
3130
#include "settings.h" // For g_settings
3231
#include "emerge.h"
3332
#include "dungeongen.h"

Diff for: ‎src/mapgen_v6.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2828
#include "nodedef.h"
2929
#include "content_mapnode.h" // For content_mapnode_get_new_name
3030
#include "voxelalgorithms.h"
31-
#include "profiler.h"
3231
#include "settings.h" // For g_settings
3332
#include "emerge.h"
3433
#include "dungeongen.h"

Diff for: ‎src/mapgen_v7.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2727
#include "content_sao.h"
2828
#include "nodedef.h"
2929
#include "voxelalgorithms.h"
30-
#include "profiler.h"
3130
#include "settings.h" // For g_settings
3231
#include "emerge.h"
3332
#include "dungeongen.h"

Diff for: ‎src/player.cpp

+1-30
Original file line numberDiff line numberDiff line change
@@ -119,31 +119,12 @@ void Player::accelerateHorizontal(v3f target_speed, f32 max_increase)
119119
f32 dl = d_wanted.getLength();
120120
if(dl > max_increase)
121121
dl = max_increase;
122-
122+
123123
v3f d = d_wanted.normalize() * dl;
124124

125125
m_speed.X += d.X;
126126
m_speed.Z += d.Z;
127127

128-
#if 0 // old code
129-
if(m_speed.X < target_speed.X - max_increase)
130-
m_speed.X += max_increase;
131-
else if(m_speed.X > target_speed.X + max_increase)
132-
m_speed.X -= max_increase;
133-
else if(m_speed.X < target_speed.X)
134-
m_speed.X = target_speed.X;
135-
else if(m_speed.X > target_speed.X)
136-
m_speed.X = target_speed.X;
137-
138-
if(m_speed.Z < target_speed.Z - max_increase)
139-
m_speed.Z += max_increase;
140-
else if(m_speed.Z > target_speed.Z + max_increase)
141-
m_speed.Z -= max_increase;
142-
else if(m_speed.Z < target_speed.Z)
143-
m_speed.Z = target_speed.Z;
144-
else if(m_speed.Z > target_speed.Z)
145-
m_speed.Z = target_speed.Z;
146-
#endif
147128
}
148129

149130
// Vertical acceleration (Y), X and Z directions are ignored
@@ -160,16 +141,6 @@ void Player::accelerateVertical(v3f target_speed, f32 max_increase)
160141

161142
m_speed.Y += d_wanted;
162143

163-
#if 0 // old code
164-
if(m_speed.Y < target_speed.Y - max_increase)
165-
m_speed.Y += max_increase;
166-
else if(m_speed.Y > target_speed.Y + max_increase)
167-
m_speed.Y -= max_increase;
168-
else if(m_speed.Y < target_speed.Y)
169-
m_speed.Y = target_speed.Y;
170-
else if(m_speed.Y > target_speed.Y)
171-
m_speed.Y = target_speed.Y;
172-
#endif
173144
}
174145

175146
v3s16 Player::getLightPosition() const

0 commit comments

Comments
 (0)
Please sign in to comment.