diff options
Diffstat (limited to 'src')
73 files changed, 130 insertions, 159 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 324353038..3e9f6d357 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -199,7 +199,6 @@ set(common_SRCS mapsector.cpp map.cpp player.cpp - utility.cpp test.cpp sha1.cpp base64.cpp diff --git a/src/camera.cpp b/src/camera.cpp index dca1c6d34..1ef594eea 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "gamedef.h" #include "sound.h" #include "event.h" +#include "util/numeric.h" Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control, IGameDef *gamedef): @@ -234,17 +235,17 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize, #if 1 f32 bobknob = 1.2; - f32 bobtmp = sin(pow(bobfrac, bobknob) * PI); - //f32 bobtmp2 = cos(pow(bobfrac, bobknob) * PI); + f32 bobtmp = sin(pow(bobfrac, bobknob) * M_PI); + //f32 bobtmp2 = cos(pow(bobfrac, bobknob) * M_PI); v3f bobvec = v3f( - 0.3 * bobdir * sin(bobfrac * PI), + 0.3 * bobdir * sin(bobfrac * M_PI), -0.28 * bobtmp * bobtmp, 0.); //rel_cam_pos += 0.2 * 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; f *= g_settings->getFloat("view_bobbing_amount"); 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.X -= 0.005 * bobvec.X * 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 - f32 angle_deg = 1 * bobdir * sin(bobfrac * PI); - f32 angle_rad = angle_deg * PI / 180; + f32 angle_deg = 1 * bobdir * sin(bobfrac * M_PI); + f32 angle_rad = angle_deg * M_PI / 180; f32 r = 0.05; v3f off = v3f( r * sin(angle_rad), @@ -289,7 +290,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize, // FOV and aspect ratio 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) m_fov_y *= MYMAX(1.0, MYMIN(1.4, sqrt(16./10. / m_aspect))); // 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) { f32 digfrac = m_digging_anim; - wield_position.X -= 30 * sin(pow(digfrac, 0.8f) * PI); - wield_position.Y += 15 * sin(digfrac * 2 * PI); + wield_position.X -= 30 * sin(pow(digfrac, 0.8f) * M_PI); + wield_position.Y += 15 * sin(digfrac * 2 * M_PI); wield_position.Z += 5 * digfrac; // Euler angles are PURE EVIL, so why not use quaternions? core::quaternion quat_begin(wield_rotation * core::DEGTORAD); core::quaternion quat_end(v3f(90, -10, -130) * core::DEGTORAD); 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); wield_rotation *= core::RADTODEG; } else { f32 bobfrac = my_modf(m_view_bobbing_anim); - wield_position.X -= sin(bobfrac*PI*2.0) * 3.0; - wield_position.Y += sin(my_modf(bobfrac*2.0)*PI) * 3.0; + wield_position.X -= sin(bobfrac*M_PI*2.0) * 3.0; + wield_position.Y += sin(my_modf(bobfrac*2.0)*M_PI) * 3.0; } m_wieldnode->setPosition(wield_position); m_wieldnode->setRotation(wield_rotation); @@ -538,7 +539,7 @@ void Camera::drawWieldedTool() // Draw the wielded node (in a separate scene manager) scene::ICameraSceneNode* cam = m_wieldmgr->getActiveCamera(); 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->setFarValue(100); m_wieldmgr->drawAll(); diff --git a/src/camera.h b/src/camera.h index b2c118f38..763c4fd8c 100644 --- a/src/camera.h +++ b/src/camera.h @@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inventory.h" #include "mesh.h" #include "tile.h" -#include "utility.h" +#include "util/numeric.h" #include <ICameraSceneNode.h> class LocalPlayer; diff --git a/src/chat.cpp b/src/chat.cpp index e370d67e4..b9d115bd0 100644 --- a/src/chat.cpp +++ b/src/chat.cpp @@ -19,10 +19,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "chat.h" #include "debug.h" -#include "utility.h" #include <cassert> #include <cctype> #include <sstream> +#include "util/string.h" +#include "util/numeric.h" ChatBuffer::ChatBuffer(u32 scrollback): m_scrollback(scrollback), diff --git a/src/client.cpp b/src/client.cpp index a563949d4..1327feb1f 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "client.h" -#include "utility.h" #include <iostream> #include "clientserver.h" #include "jmutexautolock.h" diff --git a/src/client.h b/src/client.h index 71ab4cc29..6b797e627 100644 --- a/src/client.h +++ b/src/client.h @@ -28,12 +28,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <set> #include <vector> #include "clientobject.h" -#include "utility.h" // For IntervalLimiter #include "gamedef.h" #include "inventorymanager.h" #include "filesys.h" #include "filecache.h" #include "localplayer.h" +#include "util/pointedthing.h" struct MeshMakeData; class MapBlockMesh; diff --git a/src/clientmap.cpp b/src/clientmap.cpp index 0efe2d368..6cf3db8d7 100644 --- a/src/clientmap.cpp +++ b/src/clientmap.cpp @@ -46,7 +46,7 @@ ClientMap::ClientMap( m_control(control), m_camera_position(0,0,0), m_camera_direction(0,0,1), - m_camera_fov(PI) + m_camera_fov(M_PI) { m_camera_mutex.Init(); assert(m_camera_mutex.IsInitialized()); diff --git a/src/clientserver.h b/src/clientserver.h index 86e929f61..4767a65af 100644 --- a/src/clientserver.h +++ b/src/clientserver.h @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef CLIENTSERVER_HEADER #define CLIENTSERVER_HEADER -#include "utility.h" +#include "util/serialize.h" /* changes by PROTOCOL_VERSION: diff --git a/src/connection.cpp b/src/connection.cpp index 6cb655f2f..4f5d095e5 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -22,10 +22,22 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serialization.h" #include "log.h" #include "porting.h" +#include "util/serialize.h" +#include "util/numeric.h" +#include "util/string.h" 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, u32 protocol_id, u16 sender_peer_id, u8 channel) { diff --git a/src/connection.h b/src/connection.h index 51a98ed92..e03c7983f 100644 --- a/src/connection.h +++ b/src/connection.h @@ -20,14 +20,15 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef CONNECTION_HEADER #define CONNECTION_HEADER -#include <iostream> -#include <fstream> -#include "debug.h" -#include "common_irrlicht.h" +#include "irrlichttypes.h" #include "socket.h" -#include "utility.h" #include "exceptions.h" #include "constants.h" +#include "util/pointer.h" +#include "util/container.h" +#include "util/thread.h" +#include <iostream> +#include <fstream> 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 inline bool seqnum_higher(u16 higher, u16 lower) { diff --git a/src/constants.h b/src/constants.h index a65ee6524..97e94b361 100644 --- a/src/constants.h +++ b/src/constants.h @@ -28,8 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc., Some things here are legacy crap. */ -#define PI 3.14159 - /* Connection */ diff --git a/src/content_cao.cpp b/src/content_cao.cpp index cbcf66ef7..c993f3f83 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -30,13 +30,15 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "clientobject.h" #include "content_object.h" #include "mesh.h" -#include "utility.h" // For IntervalLimiter #include "itemdef.h" #include "tool.h" #include "content_cso.h" #include "sound.h" #include "nodedef.h" #include "localplayer.h" +#include "util/numeric.h" // For IntervalLimiter +#include "util/serialize.h" + class Settings; struct ToolCapabilities; @@ -935,7 +937,7 @@ public: } } 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(); } } @@ -961,7 +963,7 @@ public: else if(cam_to_entity.Y < -0.75) col += 4; 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; dir = wrapDegrees_180(dir); //infostream<<"id="<<m_id<<" dir="<<dir<<std::endl; diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 9d95e1758..ebf9fd59e 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -25,6 +25,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "nodedef.h" #include "tile.h" #include "gamedef.h" +#include "util/numeric.h" +#include "util/serialize.h" +#include "util/directiontables.h" // Create a cuboid. // collector - the MeshCollector for the resulting polygons diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index cacd7c88f..6604b36a2 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes.h" #include "mapnode.h" #include "nodedef.h" -#include "utility.h" #include "nameidmapping.h" #include <map> diff --git a/src/content_nodemeta.cpp b/src/content_nodemeta.cpp index 676edfcf3..12c8aa426 100644 --- a/src/content_nodemeta.cpp +++ b/src/content_nodemeta.cpp @@ -20,7 +20,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "content_nodemeta.h" #include "inventory.h" #include "log.h" -#include "utility.h" +#include "util/serialize.h" +#include "util/string.h" +#include "constants.h" // MAP_BLOCKSIZE #include <sstream> #define NODEMETA_GENERIC 1 diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 4d49b68d9..468a39110 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "player.h" #include "scriptapi.h" #include "genericobject.h" +#include "util/serialize.h" core::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types; diff --git a/src/craftdef.cpp b/src/craftdef.cpp index 37fa63a00..ddb334fe2 100644 --- a/src/craftdef.cpp +++ b/src/craftdef.cpp @@ -23,9 +23,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #include <sstream> #include <set> -#include "utility.h" #include "gamedef.h" #include "inventory.h" +#include "util/serialize.h" // Check if input matches recipe // Takes recipe groups into account diff --git a/src/environment.h b/src/environment.h index e7383fa18..710b62ee0 100644 --- a/src/environment.h +++ b/src/environment.h @@ -35,8 +35,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "player.h" #include "map.h" #include <ostream> -#include "utility.h" #include "activeobject.h" +#include "util/container.h" +#include "util/numeric.h" class Server; class ServerEnvironment; diff --git a/src/filecache.cpp b/src/filecache.cpp index 47e346596..716c769aa 100644 --- a/src/filecache.cpp +++ b/src/filecache.cpp @@ -23,12 +23,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "clientserver.h" #include "log.h" #include "filesys.h" -#include "utility.h" #include "hex.h" #include "sha1.h" #include <string> #include <iostream> #include <fstream> +#include <sstream> bool FileCache::loadByPath(const std::string &path, std::ostream &os) { diff --git a/src/genericobject.cpp b/src/genericobject.cpp index 188dc645a..4ab031b5d 100644 --- a/src/genericobject.cpp +++ b/src/genericobject.cpp @@ -18,8 +18,8 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "genericobject.h" -#include "utility.h" #include <sstream> +#include "util/serialize.h" std::string gob_cmd_set_properties(const ObjectProperties &prop) { diff --git a/src/guiConfirmMenu.h b/src/guiConfirmMenu.h index 1cad481e2..0007290b1 100644 --- a/src/guiConfirmMenu.h +++ b/src/guiConfirmMenu.h @@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "modalMenu.h" -#include "utility.h" #include <string> struct ConfirmDest diff --git a/src/guiCreateWorld.cpp b/src/guiCreateWorld.cpp index f4db287ee..a4c528b3e 100644 --- a/src/guiCreateWorld.cpp +++ b/src/guiCreateWorld.cpp @@ -27,8 +27,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <IGUIStaticText.h> #include <IGUIFont.h> #include <IGUIListBox.h> - #include "gettext.h" +#include "util/string.h" enum { diff --git a/src/guiCreateWorld.h b/src/guiCreateWorld.h index 594289047..6de8cdd4e 100644 --- a/src/guiCreateWorld.h +++ b/src/guiCreateWorld.h @@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "modalMenu.h" -#include "utility.h" #include <string> #include "subgame.h" diff --git a/src/guiDeathScreen.h b/src/guiDeathScreen.h index 94639d06c..36adab617 100644 --- a/src/guiDeathScreen.h +++ b/src/guiDeathScreen.h @@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "modalMenu.h" -#include "utility.h" #include <string> class IRespawnInitiator diff --git a/src/guiInventoryMenu.cpp b/src/guiInventoryMenu.cpp index 8bae80a2e..f60c5b455 100644 --- a/src/guiInventoryMenu.cpp +++ b/src/guiInventoryMenu.cpp @@ -30,6 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <IGUIFont.h> #include "log.h" #include "tile.h" // ITextureSource +#include "util/string.h" +#include "util/numeric.h" void drawItemStack(video::IVideoDriver *driver, gui::IGUIFont *font, diff --git a/src/guiInventoryMenu.h b/src/guiInventoryMenu.h index 28335671e..c49a34582 100644 --- a/src/guiInventoryMenu.h +++ b/src/guiInventoryMenu.h @@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "inventory.h" #include "inventorymanager.h" -#include "utility.h" #include "modalMenu.h" class IGameDef; diff --git a/src/guiKeyChangeMenu.h b/src/guiKeyChangeMenu.h index 2bbbf4719..442c0882a 100644 --- a/src/guiKeyChangeMenu.h +++ b/src/guiKeyChangeMenu.h @@ -23,7 +23,6 @@ #define GUIKEYCHANGEMENU_HEADER #include "common_irrlicht.h" -#include "utility.h" #include "modalMenu.h" #include "client.h" #include "gettext.h" diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp index 38ceaea91..8517d2723 100644 --- a/src/guiMainMenu.cpp +++ b/src/guiMainMenu.cpp @@ -36,9 +36,9 @@ with this program; if not, write to the Free Software Foundation, Inc., // For IGameCallback #include "guiPauseMenu.h" #include "gettext.h" -#include "utility.h" #include "tile.h" // getTexturePath #include "filesys.h" +#include "util/string.h" struct CreateWorldDestMainMenu : public CreateWorldDest { diff --git a/src/guiMessageMenu.h b/src/guiMessageMenu.h index bc20cde45..1be69c3b7 100644 --- a/src/guiMessageMenu.h +++ b/src/guiMessageMenu.h @@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "modalMenu.h" -#include "utility.h" #include <string> class GUIMessageMenu : public GUIModalMenu diff --git a/src/guiPasswordChange.h b/src/guiPasswordChange.h index 1748baade..3104840c5 100644 --- a/src/guiPasswordChange.h +++ b/src/guiPasswordChange.h @@ -21,7 +21,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "common_irrlicht.h" #include "modalMenu.h" -#include "utility.h" #include "client.h" #include <string> diff --git a/src/guiPauseMenu.cpp b/src/guiPauseMenu.cpp index ffd1e746d..96fd7d676 100644 --- a/src/guiPauseMenu.cpp +++ b/src/guiPauseMenu.cpp @@ -28,8 +28,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
-
#include "gettext.h"
+#include "util/string.h"
GUIPauseMenu::GUIPauseMenu(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id,
diff --git a/src/guiTextInputMenu.h b/src/guiTextInputMenu.h index 730c20294..2e2aff0f6 100644 --- a/src/guiTextInputMenu.h +++ b/src/guiTextInputMenu.h @@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "modalMenu.h" -#include "utility.h" #include <string> struct TextDest diff --git a/src/inventory.cpp b/src/inventory.cpp index f4a4f2808..0a0a29cd5 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inventory.h" #include "serialization.h" -#include "utility.h" #include "debug.h" #include <sstream> #include "log.h" @@ -27,6 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "strfnd.h" #include "content_mapnode.h" // For loading legacy MaterialItems #include "nameidmapping.h" // For loading legacy MaterialItems +#include "util/serialize.h" +#include "util/string.h" /* ItemStack diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp index 91d43aee5..25257238b 100644 --- a/src/inventorymanager.cpp +++ b/src/inventorymanager.cpp @@ -24,7 +24,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serverobject.h" #include "main.h" // for g_settings #include "settings.h" -#include "utility.h" #include "craftdef.h" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" diff --git a/src/itemdef.cpp b/src/itemdef.cpp index c8771c30c..da33fd322 100644 --- a/src/itemdef.cpp +++ b/src/itemdef.cpp @@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "tile.h" #endif #include "log.h" -#include "utility.h" +#include "util/serialize.h" #include <map> #include <set> diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 3b5d15bae..2bd62dabf 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "localplayer.h" + #include "main.h" // For g_settings #include "event.h" #include "collision.h" @@ -25,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "nodedef.h" #include "settings.h" #include "map.h" +#include "util/numeric.h" /* LocalPlayer diff --git a/src/map.cpp b/src/map.cpp index 275b26029..c6e010c45 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapblock.h" #include "main.h" #include "filesys.h" -#include "utility.h" #include "voxel.h" #include "porting.h" #include "mapgen.h" @@ -32,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "profiler.h" #include "nodedef.h" #include "gamedef.h" +#include "util/directiontables.h" #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 <sstream> -#include "common_irrlicht.h" +#include "irrlichttypes.h" #include "mapnode.h" #include "constants.h" #include "voxel.h" -#include "utility.h" // Needed for UniqueQueue, a member of Map #include "modifiedstate.h" +#include "util/container.h" extern "C" { #include "sqlite3.h" diff --git a/src/mapblock.cpp b/src/mapblock.cpp index c4d3c422e..efe628a4e 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -34,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef SERVER #include "mapblock_mesh.h" #endif +#include "util/string.h" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" @@ -409,7 +410,7 @@ void MapBlock::actuallyUpdateDayNightDiff() void MapBlock::expireDayNightDiff() { - INodeDefManager *nodemgr = m_gamedef->ndef(); + //INodeDefManager *nodemgr = m_gamedef->ndef(); if(data == NULL){ 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"); is_underground = tmp; is.read((char*)*databuf_nodelist, nodecount * ser_length); - if(is.gcount() != nodecount * ser_length) + if((u32)is.gcount() != nodecount * ser_length) throw SerializationError ("MapBlock::deSerialize: no enough input data"); } diff --git a/src/mapblock.h b/src/mapblock.h index 10ffc61ce..81e950255 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -34,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "nodemetadata.h" #include "nodetimer.h" #include "modifiedstate.h" +#include "util/numeric.h" // getContainerPos class Map; class NodeMetadataList; diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index a928b82ff..3f40f9c00 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "content_mapblock.h" #include "noise.h" #include "settings.h" +#include "util/directiontables.h" /* MeshMakeData diff --git a/src/mapgen.h b/src/mapgen.h index b983c857d..1d4ef136d 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -21,7 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define MAPGEN_HEADER #include "common_irrlicht.h" -#include "utility.h" // UniqueQueue +#include "util/container.h" // UniqueQueue struct BlockMakeData; class MapBlock; diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 66c4d52e1..2cffd3e44 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -20,11 +20,13 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "mapnode.h" #include "porting.h" -#include <string> #include "main.h" // For g_settings #include "nodedef.h" #include "content_mapnode.h" // For mapnode_translate_*_internal #include "serialization.h" // For ser_ver_supported +#include "util/serialize.h" +#include <string> +#include <sstream> /* MapNode diff --git a/src/nameidmapping.cpp b/src/nameidmapping.cpp index 7857ffda1..2a436f735 100644 --- a/src/nameidmapping.cpp +++ b/src/nameidmapping.cpp @@ -18,7 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "nameidmapping.h" -#include "utility.h" +#include "util/serialize.h" void NameIdMapping::serialize(std::ostream &os) const { diff --git a/src/nodedef.cpp b/src/nodedef.cpp index d0ce3c19d..80bfae3e7 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #include "settings.h" #include "nameidmapping.h" +#include "util/serialize.h" /* NodeBox diff --git a/src/nodedef.h b/src/nodedef.h index a376da30a..2f2bfe46e 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -30,6 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #endif #include "itemgroup.h" #include "sound.h" // SimpleSoundSpec +#include "constants.h" // BS + class IItemDefManager; class ITextureSource; class IGameDef; diff --git a/src/nodemetadata.cpp b/src/nodemetadata.cpp index be36b9a86..141c779f1 100644 --- a/src/nodemetadata.cpp +++ b/src/nodemetadata.cpp @@ -18,12 +18,13 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "nodemetadata.h" -#include "utility.h" #include "exceptions.h" #include "gamedef.h" #include "inventory.h" -#include <sstream> #include "log.h" +#include "util/serialize.h" +#include "constants.h" // MAP_BLOCKSIZE +#include <sstream> /* NodeMetadata diff --git a/src/nodetimer.cpp b/src/nodetimer.cpp index 448f44eb0..468c177fd 100644 --- a/src/nodetimer.cpp +++ b/src/nodetimer.cpp @@ -18,8 +18,9 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "nodetimer.h" -#include "utility.h" #include "log.h" +#include "util/serialize.h" +#include "constants.h" // MAP_BLOCKSIZE /* NodeTimer diff --git a/src/object_properties.cpp b/src/object_properties.cpp index f13e32d53..e67b78b52 100644 --- a/src/object_properties.cpp +++ b/src/object_properties.cpp @@ -18,7 +18,8 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "object_properties.h" -#include "utility.h" +#include "util/serialize.h" +#include <sstream> #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" #define PP2(x) "("<<(x).X<<","<<(x).Y<<")" diff --git a/src/player.cpp b/src/player.cpp index 2eb2b10ad..d470fa6ff 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -19,11 +19,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "player.h" #include "constants.h" -#include "utility.h" #include "gamedef.h" #include "connection.h" // PEER_ID_INEXISTENT #include "settings.h" #include "content_sao.h" +#include "util/numeric.h" Player::Player(IGameDef *gamedef): touching_ground(false), diff --git a/src/profiler.h b/src/profiler.h index 9264cc2ab..dce7d57e2 100644 --- a/src/profiler.h +++ b/src/profiler.h @@ -22,10 +22,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include <string> -#include "utility.h" #include <jmutex.h> #include <jmutexautolock.h> #include <map> +#include "util/timetaker.h" +#include "util/numeric.h" // paging() /* Time profiler diff --git a/src/quicktune.cpp b/src/quicktune.cpp index 32a834e5f..acd0d721f 100644 --- a/src/quicktune.cpp +++ b/src/quicktune.cpp @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "quicktune.h" #include <jmutex.h> #include <jmutexautolock.h> -#include "utility.h" +#include "util/string.h" std::string QuicktuneValue::getString() { diff --git a/src/quicktune_shortcutter.h b/src/quicktune_shortcutter.h index 138df0475..2e3b5310b 100644 --- a/src/quicktune_shortcutter.h +++ b/src/quicktune_shortcutter.h @@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #define QVT_SHORTCUTTER_HEADER #include "quicktune.h" -#include "utility.h" class QuicktuneShortcutter { diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 35f00b7b5..289ad31f8 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -43,10 +43,10 @@ extern "C" { #include "nodemetadata.h" #include "mapblock.h" // For getNodeBlockPos #include "content_nodemeta.h" -#include "utility.h" #include "tool.h" #include "daynightratio.h" #include "noise.h" // PseudoRandom for LuaPseudoRandom +#include "util/pointedthing.h" static void stackDump(lua_State *L, std::ostream &o) { diff --git a/src/serialization.cpp b/src/serialization.cpp index 64fd4f8ba..28e3d8132 100644 --- a/src/serialization.cpp +++ b/src/serialization.cpp @@ -18,7 +18,8 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "serialization.h" -#include "utility.h" + +#include "util/serialize.h" #ifdef _WIN32 #define ZLIB_WINAPI #endif diff --git a/src/serialization.h b/src/serialization.h index 9eebe3cb7..24648c1fc 100644 --- a/src/serialization.h +++ b/src/serialization.h @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "exceptions.h" #include <iostream> -#include "utility.h" +#include "util/pointer.h" /* Map format serialization version diff --git a/src/server.cpp b/src/server.cpp index 70e33aaf7..f8eaaf9c3 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -18,7 +18,6 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "server.h" -#include "utility.h" #include <iostream> #include <queue> #include "clientserver.h" @@ -49,10 +48,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "sha1.h" #include "base64.h" #include "tool.h" -#include "util/string.h" #include "sound.h" // dummySoundManager #include "event_manager.h" #include "hex.h" +#include "util/string.h" +#include "util/pointedthing.h" #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. */ - 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) { continue; diff --git a/src/server.h b/src/server.h index 676b40f96..18c223ec7 100644 --- a/src/server.h +++ b/src/server.h @@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "connection.h" #include "environment.h" -#include "common_irrlicht.h" +#include "irrlichttypes.h" #include <string> #include "porting.h" #include "map.h" @@ -34,6 +34,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inventorymanager.h" #include "subgame.h" #include "sound.h" +#include "util/thread.h" +#include "util/string.h" + struct LuaState; typedef struct lua_State lua_State; class IWritableItemDefManager; diff --git a/src/servercommand.cpp b/src/servercommand.cpp index cf89f7f56..fc2f22083 100644 --- a/src/servercommand.cpp +++ b/src/servercommand.cpp @@ -17,7 +17,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "servercommand.h" -#include "utility.h" #include "settings.h" #include "main.h" // For g_settings #include "content_sao.h" diff --git a/src/serverobject.cpp b/src/serverobject.cpp index a648db7da..deaa94f2c 100644 --- a/src/serverobject.cpp +++ b/src/serverobject.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serverobject.h" #include <fstream> #include "inventory.h" +#include "constants.h" // BS ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos): ActiveObject(0), @@ -66,6 +67,11 @@ void ServerActiveObject::registerType(u16 type, Factory f) m_types.insert(type, f); } +float ServerActiveObject::getMinimumSavedMovement() +{ + return 2.0*BS; +} + ItemStack ServerActiveObject::getWieldedItem() const { const Inventory *inv = getInventory(); diff --git a/src/serverobject.h b/src/serverobject.h index 635160a03..0130ca1bf 100644 --- a/src/serverobject.h +++ b/src/serverobject.h @@ -22,9 +22,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes.h" #include "activeobject.h" -#include "utility.h" #include "inventorymanager.h" #include "itemgroup.h" +#include "util/container.h" /* @@ -96,8 +96,7 @@ public: { setBasePosition(pos); } // If object has moved less than this and data has not changed, // saving to disk may be omitted - virtual float getMinimumSavedMovement() - { return 2.0*BS; } + virtual float getMinimumSavedMovement(); virtual bool isPeaceful(){return true;} diff --git a/src/settings.h b/src/settings.h index d75b0bec1..16bac8eec 100644 --- a/src/settings.h +++ b/src/settings.h @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef SETTINGS_HEADER #define SETTINGS_HEADER -#include "common_irrlicht.h" +#include "irrlichttypes.h" #include <string> #include <jthread.h> #include <jmutex.h> @@ -30,8 +30,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <fstream> #include <sstream> #include "debug.h" -#include "utility.h" #include "log.h" +#include "util/string.h" enum ValueType { diff --git a/src/sky.cpp b/src/sky.cpp index 76dcac8b7..22b12ca1b 100644 --- a/src/sky.cpp +++ b/src/sky.cpp @@ -3,11 +3,11 @@ #include "ISceneManager.h" #include "ICameraSceneNode.h" #include "S3DVertex.h" -#include "utility.h" // MYMIN #include "tile.h" // getTexturePath #include "noise.h" // easeCurve #include "main.h" // g_profiler #include "profiler.h" +#include "util/numeric.h" // MYMIN //! constructor Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id): diff --git a/src/socket.cpp b/src/socket.cpp index ef339c486..f8afed229 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -50,7 +50,8 @@ typedef int socket_t; #include <iostream> #include <stdlib.h> #include <errno.h> -#include "utility.h" +#include "util/string.h" +#include "util/numeric.h" bool socket_enable_debug_output = false; #define DP socket_enable_debug_output diff --git a/src/sound_openal.cpp b/src/sound_openal.cpp index e95b31b7f..d2f7276a6 100644 --- a/src/sound_openal.cpp +++ b/src/sound_openal.cpp @@ -38,8 +38,10 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #endif #include <vorbis/vorbisfile.h> #include "log.h" -#include "utility.h" // myrand() #include "filesys.h" +#include "util/numeric.h" // myrand() +#include "debug.h" // assert() +#include "porting.h" #include <map> #include <vector> #include <fstream> diff --git a/src/staticobject.h b/src/staticobject.h index d522e2ad7..a55471b7f 100644 --- a/src/staticobject.h +++ b/src/staticobject.h @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include <string> #include <sstream> -#include "utility.h" +#include "util/serialize.h" struct StaticObject { diff --git a/src/test.cpp b/src/test.cpp index 95b204064..63aa09c0b 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -25,7 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "main.h" #include "socket.h" #include "connection.h" -#include "utility.h" #include "serialization.h" #include "voxel.h" #include <sstream> @@ -38,6 +37,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/string.h" #include "voxelalgorithms.h" #include "inventory.h" +#include "util/numeric.h" +#include "util/serialize.h" /* Asserts that the exception occurs diff --git a/src/tile.cpp b/src/tile.cpp index 919298fab..731f3712c 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "debug.h" #include "main.h" // for g_settings #include "filesys.h" -#include "utility.h" #include "settings.h" #include "mesh.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 "gamedef.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 diff --git a/src/tile.h b/src/tile.h index 8b19b4c32..a6609a3a6 100644 --- a/src/tile.h +++ b/src/tile.h @@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "threads.h" -#include "utility.h" #include <string> class IGameDef; @@ -205,11 +204,6 @@ struct TileSpec // Sets everything else except the texture in the material 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) material.MaterialType = video::EMT_SOLID; else if(material_type == MATERIAL_ALPHA_VERTEX) @@ -230,7 +224,7 @@ struct TileSpec } AtlasPointer texture; - // Vertex alpha + // Vertex alpha (when MATERIAL_ALPHA_VERTEX is used) u8 alpha; // Material parameters u8 material_type; diff --git a/src/tool.cpp b/src/tool.cpp index 3fb50420e..c1e268ff1 100644 --- a/src/tool.cpp +++ b/src/tool.cpp @@ -18,10 +18,11 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "tool.h" -#include "utility.h" #include "itemdef.h" // For itemgroup_get() #include "log.h" #include "inventory.h" +#include "util/serialize.h" +#include "util/numeric.h" void ToolCapabilities::serialize(std::ostream &os) const { diff --git a/src/utility.cpp b/src/utility.cpp deleted file mode 100644 index 66127fc3b..000000000 --- a/src/utility.cpp +++ /dev/null @@ -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. -*/ - - diff --git a/src/utility.h b/src/utility.h deleted file mode 100644 index 58e75ce78..000000000 --- a/src/utility.h +++ /dev/null @@ -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 - diff --git a/src/voxel.cpp b/src/voxel.cpp index c8482939e..8fdae79e1 100644 --- a/src/voxel.cpp +++ b/src/voxel.cpp @@ -19,9 +19,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "voxel.h" #include "map.h" -#include "utility.h" // For TimeTaker #include "gettime.h" #include "nodedef.h" +#include "util/timetaker.h" /* Debug stuff |