Properly and efficiently use split utility headers

This commit is contained in:
Perttu Ahola 2012-06-17 02:40:36 +03:00
parent 1bc37d576c
commit d0ea6f9920
73 changed files with 130 additions and 159 deletions

@ -199,7 +199,6 @@ set(common_SRCS
mapsector.cpp mapsector.cpp
map.cpp map.cpp
player.cpp player.cpp
utility.cpp
test.cpp test.cpp
sha1.cpp sha1.cpp
base64.cpp base64.cpp

@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "gamedef.h" #include "gamedef.h"
#include "sound.h" #include "sound.h"
#include "event.h" #include "event.h"
#include "util/numeric.h"
Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control, Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
IGameDef *gamedef): IGameDef *gamedef):
@ -234,17 +235,17 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize,
#if 1 #if 1
f32 bobknob = 1.2; f32 bobknob = 1.2;
f32 bobtmp = sin(pow(bobfrac, bobknob) * PI); f32 bobtmp = sin(pow(bobfrac, bobknob) * M_PI);
//f32 bobtmp2 = cos(pow(bobfrac, bobknob) * PI); //f32 bobtmp2 = cos(pow(bobfrac, bobknob) * M_PI);
v3f bobvec = v3f( v3f bobvec = v3f(
0.3 * bobdir * sin(bobfrac * PI), 0.3 * bobdir * sin(bobfrac * M_PI),
-0.28 * bobtmp * bobtmp, -0.28 * bobtmp * bobtmp,
0.); 0.);
//rel_cam_pos += 0.2 * bobvec; //rel_cam_pos += 0.2 * bobvec;
//rel_cam_target += 0.03 * bobvec; //rel_cam_target += 0.03 * bobvec;
//rel_cam_up.rotateXYBy(0.02 * bobdir * bobtmp * PI); //rel_cam_up.rotateXYBy(0.02 * bobdir * bobtmp * M_PI);
float f = 1.0; float f = 1.0;
f *= g_settings->getFloat("view_bobbing_amount"); f *= g_settings->getFloat("view_bobbing_amount");
rel_cam_pos += bobvec * f; rel_cam_pos += bobvec * f;
@ -253,10 +254,10 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize,
rel_cam_target.Z -= 0.005 * bobvec.Z * f; rel_cam_target.Z -= 0.005 * bobvec.Z * f;
//rel_cam_target.X -= 0.005 * bobvec.X * f; //rel_cam_target.X -= 0.005 * bobvec.X * f;
//rel_cam_target.Y -= 0.005 * bobvec.Y * f; //rel_cam_target.Y -= 0.005 * bobvec.Y * f;
rel_cam_up.rotateXYBy(-0.03 * bobdir * bobtmp * PI * f); rel_cam_up.rotateXYBy(-0.03 * bobdir * bobtmp * M_PI * f);
#else #else
f32 angle_deg = 1 * bobdir * sin(bobfrac * PI); f32 angle_deg = 1 * bobdir * sin(bobfrac * M_PI);
f32 angle_rad = angle_deg * PI / 180; f32 angle_rad = angle_deg * M_PI / 180;
f32 r = 0.05; f32 r = 0.05;
v3f off = v3f( v3f off = v3f(
r * sin(angle_rad), r * sin(angle_rad),
@ -289,7 +290,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize,
// FOV and aspect ratio // FOV and aspect ratio
m_aspect = (f32)screensize.X / (f32) screensize.Y; m_aspect = (f32)screensize.X / (f32) screensize.Y;
m_fov_y = fov_degrees * PI / 180.0; m_fov_y = fov_degrees * M_PI / 180.0;
// Increase vertical FOV on lower aspect ratios (<16:10) // Increase vertical FOV on lower aspect ratios (<16:10)
m_fov_y *= MYMAX(1.0, MYMIN(1.4, sqrt(16./10. / m_aspect))); m_fov_y *= MYMAX(1.0, MYMIN(1.4, sqrt(16./10. / m_aspect)));
// WTF is this? It can't be right // WTF is this? It can't be right
@ -320,22 +321,22 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize,
if (m_digging_button != -1) if (m_digging_button != -1)
{ {
f32 digfrac = m_digging_anim; f32 digfrac = m_digging_anim;
wield_position.X -= 30 * sin(pow(digfrac, 0.8f) * PI); wield_position.X -= 30 * sin(pow(digfrac, 0.8f) * M_PI);
wield_position.Y += 15 * sin(digfrac * 2 * PI); wield_position.Y += 15 * sin(digfrac * 2 * M_PI);
wield_position.Z += 5 * digfrac; wield_position.Z += 5 * digfrac;
// Euler angles are PURE EVIL, so why not use quaternions? // Euler angles are PURE EVIL, so why not use quaternions?
core::quaternion quat_begin(wield_rotation * core::DEGTORAD); core::quaternion quat_begin(wield_rotation * core::DEGTORAD);
core::quaternion quat_end(v3f(90, -10, -130) * core::DEGTORAD); core::quaternion quat_end(v3f(90, -10, -130) * core::DEGTORAD);
core::quaternion quat_slerp; core::quaternion quat_slerp;
quat_slerp.slerp(quat_begin, quat_end, sin(digfrac * PI)); quat_slerp.slerp(quat_begin, quat_end, sin(digfrac * M_PI));
quat_slerp.toEuler(wield_rotation); quat_slerp.toEuler(wield_rotation);
wield_rotation *= core::RADTODEG; wield_rotation *= core::RADTODEG;
} }
else { else {
f32 bobfrac = my_modf(m_view_bobbing_anim); f32 bobfrac = my_modf(m_view_bobbing_anim);
wield_position.X -= sin(bobfrac*PI*2.0) * 3.0; wield_position.X -= sin(bobfrac*M_PI*2.0) * 3.0;
wield_position.Y += sin(my_modf(bobfrac*2.0)*PI) * 3.0; wield_position.Y += sin(my_modf(bobfrac*2.0)*M_PI) * 3.0;
} }
m_wieldnode->setPosition(wield_position); m_wieldnode->setPosition(wield_position);
m_wieldnode->setRotation(wield_rotation); m_wieldnode->setRotation(wield_rotation);
@ -538,7 +539,7 @@ void Camera::drawWieldedTool()
// Draw the wielded node (in a separate scene manager) // Draw the wielded node (in a separate scene manager)
scene::ICameraSceneNode* cam = m_wieldmgr->getActiveCamera(); scene::ICameraSceneNode* cam = m_wieldmgr->getActiveCamera();
cam->setAspectRatio(m_cameranode->getAspectRatio()); cam->setAspectRatio(m_cameranode->getAspectRatio());
cam->setFOV(72.0*PI/180.0); cam->setFOV(72.0*M_PI/180.0);
cam->setNearValue(0.1); cam->setNearValue(0.1);
cam->setFarValue(100); cam->setFarValue(100);
m_wieldmgr->drawAll(); m_wieldmgr->drawAll();

@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "inventory.h" #include "inventory.h"
#include "mesh.h" #include "mesh.h"
#include "tile.h" #include "tile.h"
#include "utility.h" #include "util/numeric.h"
#include <ICameraSceneNode.h> #include <ICameraSceneNode.h>
class LocalPlayer; class LocalPlayer;

@ -19,10 +19,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "chat.h" #include "chat.h"
#include "debug.h" #include "debug.h"
#include "utility.h"
#include <cassert> #include <cassert>
#include <cctype> #include <cctype>
#include <sstream> #include <sstream>
#include "util/string.h"
#include "util/numeric.h"
ChatBuffer::ChatBuffer(u32 scrollback): ChatBuffer::ChatBuffer(u32 scrollback):
m_scrollback(scrollback), m_scrollback(scrollback),

@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "client.h" #include "client.h"
#include "utility.h"
#include <iostream> #include <iostream>
#include "clientserver.h" #include "clientserver.h"
#include "jmutexautolock.h" #include "jmutexautolock.h"

@ -28,12 +28,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <set> #include <set>
#include <vector> #include <vector>
#include "clientobject.h" #include "clientobject.h"
#include "utility.h" // For IntervalLimiter
#include "gamedef.h" #include "gamedef.h"
#include "inventorymanager.h" #include "inventorymanager.h"
#include "filesys.h" #include "filesys.h"
#include "filecache.h" #include "filecache.h"
#include "localplayer.h" #include "localplayer.h"
#include "util/pointedthing.h"
struct MeshMakeData; struct MeshMakeData;
class MapBlockMesh; class MapBlockMesh;

@ -46,7 +46,7 @@ ClientMap::ClientMap(
m_control(control), m_control(control),
m_camera_position(0,0,0), m_camera_position(0,0,0),
m_camera_direction(0,0,1), m_camera_direction(0,0,1),
m_camera_fov(PI) m_camera_fov(M_PI)
{ {
m_camera_mutex.Init(); m_camera_mutex.Init();
assert(m_camera_mutex.IsInitialized()); assert(m_camera_mutex.IsInitialized());

@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef CLIENTSERVER_HEADER #ifndef CLIENTSERVER_HEADER
#define CLIENTSERVER_HEADER #define CLIENTSERVER_HEADER
#include "utility.h" #include "util/serialize.h"
/* /*
changes by PROTOCOL_VERSION: changes by PROTOCOL_VERSION:

@ -22,10 +22,22 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serialization.h" #include "serialization.h"
#include "log.h" #include "log.h"
#include "porting.h" #include "porting.h"
#include "util/serialize.h"
#include "util/numeric.h"
#include "util/string.h"
namespace con namespace con
{ {
static u16 readPeerId(u8 *packetdata)
{
return readU16(&packetdata[4]);
}
static u8 readChannel(u8 *packetdata)
{
return readU8(&packetdata[6]);
}
BufferedPacket makePacket(Address &address, u8 *data, u32 datasize, BufferedPacket makePacket(Address &address, u8 *data, u32 datasize,
u32 protocol_id, u16 sender_peer_id, u8 channel) u32 protocol_id, u16 sender_peer_id, u8 channel)
{ {

@ -20,14 +20,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef CONNECTION_HEADER #ifndef CONNECTION_HEADER
#define CONNECTION_HEADER #define CONNECTION_HEADER
#include <iostream> #include "irrlichttypes.h"
#include <fstream>
#include "debug.h"
#include "common_irrlicht.h"
#include "socket.h" #include "socket.h"
#include "utility.h"
#include "exceptions.h" #include "exceptions.h"
#include "constants.h" #include "constants.h"
#include "util/pointer.h"
#include "util/container.h"
#include "util/thread.h"
#include <iostream>
#include <fstream>
namespace con namespace con
{ {
@ -107,15 +108,6 @@ public:
{} {}
}; };
inline u16 readPeerId(u8 *packetdata)
{
return readU16(&packetdata[4]);
}
inline u8 readChannel(u8 *packetdata)
{
return readU8(&packetdata[6]);
}
#define SEQNUM_MAX 65535 #define SEQNUM_MAX 65535
inline bool seqnum_higher(u16 higher, u16 lower) inline bool seqnum_higher(u16 higher, u16 lower)
{ {

@ -28,8 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Some things here are legacy crap. Some things here are legacy crap.
*/ */
#define PI 3.14159
/* /*
Connection Connection
*/ */

@ -30,13 +30,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "clientobject.h" #include "clientobject.h"
#include "content_object.h" #include "content_object.h"
#include "mesh.h" #include "mesh.h"
#include "utility.h" // For IntervalLimiter
#include "itemdef.h" #include "itemdef.h"
#include "tool.h" #include "tool.h"
#include "content_cso.h" #include "content_cso.h"
#include "sound.h" #include "sound.h"
#include "nodedef.h" #include "nodedef.h"
#include "localplayer.h" #include "localplayer.h"
#include "util/numeric.h" // For IntervalLimiter
#include "util/serialize.h"
class Settings; class Settings;
struct ToolCapabilities; struct ToolCapabilities;
@ -935,7 +937,7 @@ public:
} }
} }
if(fabs(m_prop.automatic_rotate) > 0.001){ if(fabs(m_prop.automatic_rotate) > 0.001){
m_yaw += dtime * m_prop.automatic_rotate * 180 / PI; m_yaw += dtime * m_prop.automatic_rotate * 180 / M_PI;
updateNodePos(); updateNodePos();
} }
} }
@ -961,7 +963,7 @@ public:
else if(cam_to_entity.Y < -0.75) else if(cam_to_entity.Y < -0.75)
col += 4; col += 4;
else{ else{
float mob_dir = atan2(cam_to_entity.Z, cam_to_entity.X) / PI * 180.; float mob_dir = atan2(cam_to_entity.Z, cam_to_entity.X) / M_PI * 180.;
float dir = mob_dir - m_yaw; float dir = mob_dir - m_yaw;
dir = wrapDegrees_180(dir); dir = wrapDegrees_180(dir);
//infostream<<"id="<<m_id<<" dir="<<dir<<std::endl; //infostream<<"id="<<m_id<<" dir="<<dir<<std::endl;

@ -25,6 +25,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h" #include "nodedef.h"
#include "tile.h" #include "tile.h"
#include "gamedef.h" #include "gamedef.h"
#include "util/numeric.h"
#include "util/serialize.h"
#include "util/directiontables.h"
// Create a cuboid. // Create a cuboid.
// collector - the MeshCollector for the resulting polygons // collector - the MeshCollector for the resulting polygons

@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes.h" #include "irrlichttypes.h"
#include "mapnode.h" #include "mapnode.h"
#include "nodedef.h" #include "nodedef.h"
#include "utility.h"
#include "nameidmapping.h" #include "nameidmapping.h"
#include <map> #include <map>

@ -20,7 +20,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_nodemeta.h" #include "content_nodemeta.h"
#include "inventory.h" #include "inventory.h"
#include "log.h" #include "log.h"
#include "utility.h" #include "util/serialize.h"
#include "util/string.h"
#include "constants.h" // MAP_BLOCKSIZE
#include <sstream> #include <sstream>
#define NODEMETA_GENERIC 1 #define NODEMETA_GENERIC 1

@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "player.h" #include "player.h"
#include "scriptapi.h" #include "scriptapi.h"
#include "genericobject.h" #include "genericobject.h"
#include "util/serialize.h"
core::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types; core::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types;

@ -23,9 +23,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h" #include "log.h"
#include <sstream> #include <sstream>
#include <set> #include <set>
#include "utility.h"
#include "gamedef.h" #include "gamedef.h"
#include "inventory.h" #include "inventory.h"
#include "util/serialize.h"
// Check if input matches recipe // Check if input matches recipe
// Takes recipe groups into account // Takes recipe groups into account

@ -35,8 +35,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "player.h" #include "player.h"
#include "map.h" #include "map.h"
#include <ostream> #include <ostream>
#include "utility.h"
#include "activeobject.h" #include "activeobject.h"
#include "util/container.h"
#include "util/numeric.h"
class Server; class Server;
class ServerEnvironment; class ServerEnvironment;

@ -23,12 +23,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "clientserver.h" #include "clientserver.h"
#include "log.h" #include "log.h"
#include "filesys.h" #include "filesys.h"
#include "utility.h"
#include "hex.h" #include "hex.h"
#include "sha1.h" #include "sha1.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream>
bool FileCache::loadByPath(const std::string &path, std::ostream &os) bool FileCache::loadByPath(const std::string &path, std::ostream &os)
{ {

@ -18,8 +18,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "genericobject.h" #include "genericobject.h"
#include "utility.h"
#include <sstream> #include <sstream>
#include "util/serialize.h"
std::string gob_cmd_set_properties(const ObjectProperties &prop) std::string gob_cmd_set_properties(const ObjectProperties &prop)
{ {

@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "modalMenu.h" #include "modalMenu.h"
#include "utility.h"
#include <string> #include <string>
struct ConfirmDest struct ConfirmDest

@ -27,8 +27,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IGUIStaticText.h> #include <IGUIStaticText.h>
#include <IGUIFont.h> #include <IGUIFont.h>
#include <IGUIListBox.h> #include <IGUIListBox.h>
#include "gettext.h" #include "gettext.h"
#include "util/string.h"
enum enum
{ {

@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "modalMenu.h" #include "modalMenu.h"
#include "utility.h"
#include <string> #include <string>
#include "subgame.h" #include "subgame.h"

@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "modalMenu.h" #include "modalMenu.h"
#include "utility.h"
#include <string> #include <string>
class IRespawnInitiator class IRespawnInitiator

@ -30,6 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IGUIFont.h> #include <IGUIFont.h>
#include "log.h" #include "log.h"
#include "tile.h" // ITextureSource #include "tile.h" // ITextureSource
#include "util/string.h"
#include "util/numeric.h"
void drawItemStack(video::IVideoDriver *driver, void drawItemStack(video::IVideoDriver *driver,
gui::IGUIFont *font, gui::IGUIFont *font,

@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "inventory.h" #include "inventory.h"
#include "inventorymanager.h" #include "inventorymanager.h"
#include "utility.h"
#include "modalMenu.h" #include "modalMenu.h"
class IGameDef; class IGameDef;

@ -23,7 +23,6 @@
#define GUIKEYCHANGEMENU_HEADER #define GUIKEYCHANGEMENU_HEADER
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "utility.h"
#include "modalMenu.h" #include "modalMenu.h"
#include "client.h" #include "client.h"
#include "gettext.h" #include "gettext.h"

@ -36,9 +36,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
// For IGameCallback // For IGameCallback
#include "guiPauseMenu.h" #include "guiPauseMenu.h"
#include "gettext.h" #include "gettext.h"
#include "utility.h"
#include "tile.h" // getTexturePath #include "tile.h" // getTexturePath
#include "filesys.h" #include "filesys.h"
#include "util/string.h"
struct CreateWorldDestMainMenu : public CreateWorldDest struct CreateWorldDestMainMenu : public CreateWorldDest
{ {

@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "modalMenu.h" #include "modalMenu.h"
#include "utility.h"
#include <string> #include <string>
class GUIMessageMenu : public GUIModalMenu class GUIMessageMenu : public GUIModalMenu

@ -21,7 +21,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "modalMenu.h" #include "modalMenu.h"
#include "utility.h"
#include "client.h" #include "client.h"
#include <string> #include <string>

@ -28,8 +28,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <IGUIButton.h> #include <IGUIButton.h>
#include <IGUIStaticText.h> #include <IGUIStaticText.h>
#include <IGUIFont.h> #include <IGUIFont.h>
#include "gettext.h" #include "gettext.h"
#include "util/string.h"
GUIPauseMenu::GUIPauseMenu(gui::IGUIEnvironment* env, GUIPauseMenu::GUIPauseMenu(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id, gui::IGUIElement* parent, s32 id,

@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "modalMenu.h" #include "modalMenu.h"
#include "utility.h"
#include <string> #include <string>
struct TextDest struct TextDest

@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "inventory.h" #include "inventory.h"
#include "serialization.h" #include "serialization.h"
#include "utility.h"
#include "debug.h" #include "debug.h"
#include <sstream> #include <sstream>
#include "log.h" #include "log.h"
@ -27,6 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "strfnd.h" #include "strfnd.h"
#include "content_mapnode.h" // For loading legacy MaterialItems #include "content_mapnode.h" // For loading legacy MaterialItems
#include "nameidmapping.h" // For loading legacy MaterialItems #include "nameidmapping.h" // For loading legacy MaterialItems
#include "util/serialize.h"
#include "util/string.h"
/* /*
ItemStack ItemStack

@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serverobject.h" #include "serverobject.h"
#include "main.h" // for g_settings #include "main.h" // for g_settings
#include "settings.h" #include "settings.h"
#include "utility.h"
#include "craftdef.h" #include "craftdef.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"

@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "tile.h" #include "tile.h"
#endif #endif
#include "log.h" #include "log.h"
#include "utility.h" #include "util/serialize.h"
#include <map> #include <map>
#include <set> #include <set>

@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "localplayer.h" #include "localplayer.h"
#include "main.h" // For g_settings #include "main.h" // For g_settings
#include "event.h" #include "event.h"
#include "collision.h" #include "collision.h"
@ -25,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h" #include "nodedef.h"
#include "settings.h" #include "settings.h"
#include "map.h" #include "map.h"
#include "util/numeric.h"
/* /*
LocalPlayer LocalPlayer

@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapblock.h" #include "mapblock.h"
#include "main.h" #include "main.h"
#include "filesys.h" #include "filesys.h"
#include "utility.h"
#include "voxel.h" #include "voxel.h"
#include "porting.h" #include "porting.h"
#include "mapgen.h" #include "mapgen.h"
@ -32,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "profiler.h" #include "profiler.h"
#include "nodedef.h" #include "nodedef.h"
#include "gamedef.h" #include "gamedef.h"
#include "util/directiontables.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"

@ -26,12 +26,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include "common_irrlicht.h" #include "irrlichttypes.h"
#include "mapnode.h" #include "mapnode.h"
#include "constants.h" #include "constants.h"
#include "voxel.h" #include "voxel.h"
#include "utility.h" // Needed for UniqueQueue, a member of Map
#include "modifiedstate.h" #include "modifiedstate.h"
#include "util/container.h"
extern "C" { extern "C" {
#include "sqlite3.h" #include "sqlite3.h"

@ -34,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SERVER #ifndef SERVER
#include "mapblock_mesh.h" #include "mapblock_mesh.h"
#endif #endif
#include "util/string.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
@ -409,7 +410,7 @@ void MapBlock::actuallyUpdateDayNightDiff()
void MapBlock::expireDayNightDiff() void MapBlock::expireDayNightDiff()
{ {
INodeDefManager *nodemgr = m_gamedef->ndef(); //INodeDefManager *nodemgr = m_gamedef->ndef();
if(data == NULL){ if(data == NULL){
m_day_night_differs = false; m_day_night_differs = false;
@ -976,7 +977,7 @@ void MapBlock::deSerialize_pre22(std::istream &is, u8 version, bool disk)
("MapBlock::deSerialize: no enough input data"); ("MapBlock::deSerialize: no enough input data");
is_underground = tmp; is_underground = tmp;
is.read((char*)*databuf_nodelist, nodecount * ser_length); is.read((char*)*databuf_nodelist, nodecount * ser_length);
if(is.gcount() != nodecount * ser_length) if((u32)is.gcount() != nodecount * ser_length)
throw SerializationError throw SerializationError
("MapBlock::deSerialize: no enough input data"); ("MapBlock::deSerialize: no enough input data");
} }

@ -34,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodemetadata.h" #include "nodemetadata.h"
#include "nodetimer.h" #include "nodetimer.h"
#include "modifiedstate.h" #include "modifiedstate.h"
#include "util/numeric.h" // getContainerPos
class Map; class Map;
class NodeMetadataList; class NodeMetadataList;

@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content_mapblock.h" #include "content_mapblock.h"
#include "noise.h" #include "noise.h"
#include "settings.h" #include "settings.h"
#include "util/directiontables.h"
/* /*
MeshMakeData MeshMakeData

@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define MAPGEN_HEADER #define MAPGEN_HEADER
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "utility.h" // UniqueQueue #include "util/container.h" // UniqueQueue
struct BlockMakeData; struct BlockMakeData;
class MapBlock; class MapBlock;

@ -20,11 +20,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "mapnode.h" #include "mapnode.h"
#include "porting.h" #include "porting.h"
#include <string>
#include "main.h" // For g_settings #include "main.h" // For g_settings
#include "nodedef.h" #include "nodedef.h"
#include "content_mapnode.h" // For mapnode_translate_*_internal #include "content_mapnode.h" // For mapnode_translate_*_internal
#include "serialization.h" // For ser_ver_supported #include "serialization.h" // For ser_ver_supported
#include "util/serialize.h"
#include <string>
#include <sstream>
/* /*
MapNode MapNode

@ -18,7 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "nameidmapping.h" #include "nameidmapping.h"
#include "utility.h" #include "util/serialize.h"
void NameIdMapping::serialize(std::ostream &os) const void NameIdMapping::serialize(std::ostream &os) const
{ {

@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "log.h" #include "log.h"
#include "settings.h" #include "settings.h"
#include "nameidmapping.h" #include "nameidmapping.h"
#include "util/serialize.h"
/* /*
NodeBox NodeBox

@ -30,6 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif #endif
#include "itemgroup.h" #include "itemgroup.h"
#include "sound.h" // SimpleSoundSpec #include "sound.h" // SimpleSoundSpec
#include "constants.h" // BS
class IItemDefManager; class IItemDefManager;
class ITextureSource; class ITextureSource;
class IGameDef; class IGameDef;

@ -18,12 +18,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "nodemetadata.h" #include "nodemetadata.h"
#include "utility.h"
#include "exceptions.h" #include "exceptions.h"
#include "gamedef.h" #include "gamedef.h"
#include "inventory.h" #include "inventory.h"
#include <sstream>
#include "log.h" #include "log.h"
#include "util/serialize.h"
#include "constants.h" // MAP_BLOCKSIZE
#include <sstream>
/* /*
NodeMetadata NodeMetadata

@ -18,8 +18,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "nodetimer.h" #include "nodetimer.h"
#include "utility.h"
#include "log.h" #include "log.h"
#include "util/serialize.h"
#include "constants.h" // MAP_BLOCKSIZE
/* /*
NodeTimer NodeTimer

@ -18,7 +18,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "object_properties.h" #include "object_properties.h"
#include "utility.h" #include "util/serialize.h"
#include <sstream>
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
#define PP2(x) "("<<(x).X<<","<<(x).Y<<")" #define PP2(x) "("<<(x).X<<","<<(x).Y<<")"

@ -19,11 +19,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "player.h" #include "player.h"
#include "constants.h" #include "constants.h"
#include "utility.h"
#include "gamedef.h" #include "gamedef.h"
#include "connection.h" // PEER_ID_INEXISTENT #include "connection.h" // PEER_ID_INEXISTENT
#include "settings.h" #include "settings.h"
#include "content_sao.h" #include "content_sao.h"
#include "util/numeric.h"
Player::Player(IGameDef *gamedef): Player::Player(IGameDef *gamedef):
touching_ground(false), touching_ground(false),

@ -22,10 +22,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include <string> #include <string>
#include "utility.h"
#include <jmutex.h> #include <jmutex.h>
#include <jmutexautolock.h> #include <jmutexautolock.h>
#include <map> #include <map>
#include "util/timetaker.h"
#include "util/numeric.h" // paging()
/* /*
Time profiler Time profiler

@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "quicktune.h" #include "quicktune.h"
#include <jmutex.h> #include <jmutex.h>
#include <jmutexautolock.h> #include <jmutexautolock.h>
#include "utility.h" #include "util/string.h"
std::string QuicktuneValue::getString() std::string QuicktuneValue::getString()
{ {

@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define QVT_SHORTCUTTER_HEADER #define QVT_SHORTCUTTER_HEADER
#include "quicktune.h" #include "quicktune.h"
#include "utility.h"
class QuicktuneShortcutter class QuicktuneShortcutter
{ {

@ -43,10 +43,10 @@ extern "C" {
#include "nodemetadata.h" #include "nodemetadata.h"
#include "mapblock.h" // For getNodeBlockPos #include "mapblock.h" // For getNodeBlockPos
#include "content_nodemeta.h" #include "content_nodemeta.h"
#include "utility.h"
#include "tool.h" #include "tool.h"
#include "daynightratio.h" #include "daynightratio.h"
#include "noise.h" // PseudoRandom for LuaPseudoRandom #include "noise.h" // PseudoRandom for LuaPseudoRandom
#include "util/pointedthing.h"
static void stackDump(lua_State *L, std::ostream &o) static void stackDump(lua_State *L, std::ostream &o)
{ {

@ -18,7 +18,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "serialization.h" #include "serialization.h"
#include "utility.h"
#include "util/serialize.h"
#ifdef _WIN32 #ifdef _WIN32
#define ZLIB_WINAPI #define ZLIB_WINAPI
#endif #endif

@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "exceptions.h" #include "exceptions.h"
#include <iostream> #include <iostream>
#include "utility.h" #include "util/pointer.h"
/* /*
Map format serialization version Map format serialization version

@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "server.h" #include "server.h"
#include "utility.h"
#include <iostream> #include <iostream>
#include <queue> #include <queue>
#include "clientserver.h" #include "clientserver.h"
@ -49,10 +48,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "sha1.h" #include "sha1.h"
#include "base64.h" #include "base64.h"
#include "tool.h" #include "tool.h"
#include "util/string.h"
#include "sound.h" // dummySoundManager #include "sound.h" // dummySoundManager
#include "event_manager.h" #include "event_manager.h"
#include "hex.h" #include "hex.h"
#include "util/string.h"
#include "util/pointedthing.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
@ -676,7 +676,7 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
FOV setting. The default of 72 degrees is fine. FOV setting. The default of 72 degrees is fine.
*/ */
float camera_fov = (72.0*PI/180) * 4./3.; float camera_fov = (72.0*M_PI/180) * 4./3.;
if(isBlockInSight(p, camera_pos, camera_dir, camera_fov, 10000*BS) == false) if(isBlockInSight(p, camera_pos, camera_dir, camera_fov, 10000*BS) == false)
{ {
continue; continue;

@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "connection.h" #include "connection.h"
#include "environment.h" #include "environment.h"
#include "common_irrlicht.h" #include "irrlichttypes.h"
#include <string> #include <string>
#include "porting.h" #include "porting.h"
#include "map.h" #include "map.h"
@ -34,6 +34,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "inventorymanager.h" #include "inventorymanager.h"
#include "subgame.h" #include "subgame.h"
#include "sound.h" #include "sound.h"
#include "util/thread.h"
#include "util/string.h"
struct LuaState; struct LuaState;
typedef struct lua_State lua_State; typedef struct lua_State lua_State;
class IWritableItemDefManager; class IWritableItemDefManager;

@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "servercommand.h" #include "servercommand.h"
#include "utility.h"
#include "settings.h" #include "settings.h"
#include "main.h" // For g_settings #include "main.h" // For g_settings
#include "content_sao.h" #include "content_sao.h"

@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serverobject.h" #include "serverobject.h"
#include <fstream> #include <fstream>
#include "inventory.h" #include "inventory.h"
#include "constants.h" // BS
ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos): ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos):
ActiveObject(0), ActiveObject(0),
@ -66,6 +67,11 @@ void ServerActiveObject::registerType(u16 type, Factory f)
m_types.insert(type, f); m_types.insert(type, f);
} }
float ServerActiveObject::getMinimumSavedMovement()
{
return 2.0*BS;
}
ItemStack ServerActiveObject::getWieldedItem() const ItemStack ServerActiveObject::getWieldedItem() const
{ {
const Inventory *inv = getInventory(); const Inventory *inv = getInventory();

@ -22,9 +22,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes.h" #include "irrlichttypes.h"
#include "activeobject.h" #include "activeobject.h"
#include "utility.h"
#include "inventorymanager.h" #include "inventorymanager.h"
#include "itemgroup.h" #include "itemgroup.h"
#include "util/container.h"
/* /*
@ -96,8 +96,7 @@ public:
{ setBasePosition(pos); } { setBasePosition(pos); }
// If object has moved less than this and data has not changed, // If object has moved less than this and data has not changed,
// saving to disk may be omitted // saving to disk may be omitted
virtual float getMinimumSavedMovement() virtual float getMinimumSavedMovement();
{ return 2.0*BS; }
virtual bool isPeaceful(){return true;} virtual bool isPeaceful(){return true;}

@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SETTINGS_HEADER #ifndef SETTINGS_HEADER
#define SETTINGS_HEADER #define SETTINGS_HEADER
#include "common_irrlicht.h" #include "irrlichttypes.h"
#include <string> #include <string>
#include <jthread.h> #include <jthread.h>
#include <jmutex.h> #include <jmutex.h>
@ -30,8 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include "debug.h" #include "debug.h"
#include "utility.h"
#include "log.h" #include "log.h"
#include "util/string.h"
enum ValueType enum ValueType
{ {

@ -3,11 +3,11 @@
#include "ISceneManager.h" #include "ISceneManager.h"
#include "ICameraSceneNode.h" #include "ICameraSceneNode.h"
#include "S3DVertex.h" #include "S3DVertex.h"
#include "utility.h" // MYMIN
#include "tile.h" // getTexturePath #include "tile.h" // getTexturePath
#include "noise.h" // easeCurve #include "noise.h" // easeCurve
#include "main.h" // g_profiler #include "main.h" // g_profiler
#include "profiler.h" #include "profiler.h"
#include "util/numeric.h" // MYMIN
//! constructor //! constructor
Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id): Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id):

@ -50,7 +50,8 @@ typedef int socket_t;
#include <iostream> #include <iostream>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include "utility.h" #include "util/string.h"
#include "util/numeric.h"
bool socket_enable_debug_output = false; bool socket_enable_debug_output = false;
#define DP socket_enable_debug_output #define DP socket_enable_debug_output

@ -38,8 +38,10 @@ with this program; ifnot, write to the Free Software Foundation, Inc.,
#endif #endif
#include <vorbis/vorbisfile.h> #include <vorbis/vorbisfile.h>
#include "log.h" #include "log.h"
#include "utility.h" // myrand()
#include "filesys.h" #include "filesys.h"
#include "util/numeric.h" // myrand()
#include "debug.h" // assert()
#include "porting.h"
#include <map> #include <map>
#include <vector> #include <vector>
#include <fstream> #include <fstream>

@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include <string> #include <string>
#include <sstream> #include <sstream>
#include "utility.h" #include "util/serialize.h"
struct StaticObject struct StaticObject
{ {

@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "main.h" #include "main.h"
#include "socket.h" #include "socket.h"
#include "connection.h" #include "connection.h"
#include "utility.h"
#include "serialization.h" #include "serialization.h"
#include "voxel.h" #include "voxel.h"
#include <sstream> #include <sstream>
@ -38,6 +37,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/string.h" #include "util/string.h"
#include "voxelalgorithms.h" #include "voxelalgorithms.h"
#include "inventory.h" #include "inventory.h"
#include "util/numeric.h"
#include "util/serialize.h"
/* /*
Asserts that the exception occurs Asserts that the exception occurs

@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "debug.h" #include "debug.h"
#include "main.h" // for g_settings #include "main.h" // for g_settings
#include "filesys.h" #include "filesys.h"
#include "utility.h"
#include "settings.h" #include "settings.h"
#include "mesh.h" #include "mesh.h"
#include <ICameraSceneNode.h> #include <ICameraSceneNode.h>
@ -30,6 +29,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "nodedef.h" // For texture atlas making #include "nodedef.h" // For texture atlas making
#include "gamedef.h" #include "gamedef.h"
#include "util/string.h" #include "util/string.h"
#include "util/container.h"
#include "util/thread.h"
#include "util/numeric.h"
/* /*
A cache from texture name to texture path A cache from texture name to texture path

@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "threads.h" #include "threads.h"
#include "utility.h"
#include <string> #include <string>
class IGameDef; class IGameDef;
@ -205,11 +204,6 @@ struct TileSpec
// Sets everything else except the texture in the material // Sets everything else except the texture in the material
void applyMaterialOptions(video::SMaterial &material) const void applyMaterialOptions(video::SMaterial &material) const
{ {
if(alpha != 255 && material_type != MATERIAL_ALPHA_VERTEX)
dstream<<"WARNING: TileSpec: alpha != 255 "
"but not MATERIAL_ALPHA_VERTEX"
<<std::endl;
if(material_type == MATERIAL_ALPHA_NONE) if(material_type == MATERIAL_ALPHA_NONE)
material.MaterialType = video::EMT_SOLID; material.MaterialType = video::EMT_SOLID;
else if(material_type == MATERIAL_ALPHA_VERTEX) else if(material_type == MATERIAL_ALPHA_VERTEX)
@ -230,7 +224,7 @@ struct TileSpec
} }
AtlasPointer texture; AtlasPointer texture;
// Vertex alpha // Vertex alpha (when MATERIAL_ALPHA_VERTEX is used)
u8 alpha; u8 alpha;
// Material parameters // Material parameters
u8 material_type; u8 material_type;

@ -18,10 +18,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/ */
#include "tool.h" #include "tool.h"
#include "utility.h"
#include "itemdef.h" // For itemgroup_get() #include "itemdef.h" // For itemgroup_get()
#include "log.h" #include "log.h"
#include "inventory.h" #include "inventory.h"
#include "util/serialize.h"
#include "util/numeric.h"
void ToolCapabilities::serialize(std::ostream &os) const void ToolCapabilities::serialize(std::ostream &os) const
{ {

@ -1,20 +0,0 @@
/*
Minetest-c55
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

@ -1,35 +0,0 @@
/*
Minetest-c55
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef UTILITY_HEADER
#define UTILITY_HEADER
// Headers whose content was previously here
#include "util/serialize.h"
#include "util/directiontables.h"
#include "util/pointer.h"
#include "util/string.h"
#include "util/container.h"
#include "util/thread.h"
#include "util/numeric.h"
#include "util/timetaker.h"
#include "util/pointedthing.h"
#endif

@ -19,9 +19,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "voxel.h" #include "voxel.h"
#include "map.h" #include "map.h"
#include "utility.h" // For TimeTaker
#include "gettime.h" #include "gettime.h"
#include "nodedef.h" #include "nodedef.h"
#include "util/timetaker.h"
/* /*
Debug stuff Debug stuff