use unordered containers where possible (patch 4 on X)

Also remove some unused parameters/functions
master
Loic Blot 2016-10-06 19:20:12 +02:00 committed by sfan5
parent b66a5d2f88
commit 155288ee98
13 changed files with 63 additions and 99 deletions

View File

@ -347,8 +347,10 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
if(m_bone_position_sent == false){ if(m_bone_position_sent == false){
m_bone_position_sent = true; m_bone_position_sent = true;
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){ for (UNORDERED_MAP<std::string, core::vector2d<v3f> >::const_iterator
std::string str = gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y); ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
std::string str = gob_cmd_update_bone_position((*ii).first,
(*ii).second.X, (*ii).second.Y);
// create message and add to list // create message and add to list
ActiveObjectMessage aom(getId(), true, str); ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom); m_messages_out.push(aom);
@ -383,8 +385,10 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2 os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
os<<serializeLongString(gob_cmd_update_animation( os<<serializeLongString(gob_cmd_update_animation(
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3 m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){ for (UNORDERED_MAP<std::string, core::vector2d<v3f> >::const_iterator
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii) {
os << serializeLongString(gob_cmd_update_bone_position((*ii).first,
(*ii).second.X, (*ii).second.Y)); // m_bone_position.size
} }
os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4 os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
} }
@ -862,7 +866,8 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2 os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
os<<serializeLongString(gob_cmd_update_animation( os<<serializeLongString(gob_cmd_update_animation(
m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3 m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){ for (UNORDERED_MAP<std::string, core::vector2d<v3f> >::const_iterator
ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii) {
os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
} }
os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4 os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
@ -1007,19 +1012,22 @@ void PlayerSAO::step(float dtime, bool send_recommended)
m_messages_out.push(aom); m_messages_out.push(aom);
} }
if(m_bone_position_sent == false){ if (!m_bone_position_sent) {
m_bone_position_sent = true; m_bone_position_sent = true;
for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){ for (UNORDERED_MAP<std::string, core::vector2d<v3f> >::const_iterator
std::string str = gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y); ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii) {
std::string str = gob_cmd_update_bone_position((*ii).first,
(*ii).second.X, (*ii).second.Y);
// create message and add to list // create message and add to list
ActiveObjectMessage aom(getId(), true, str); ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom); m_messages_out.push(aom);
} }
} }
if(m_attachment_sent == false){ if (!m_attachment_sent){
m_attachment_sent = true; m_attachment_sent = true;
std::string str = gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation); std::string str = gob_cmd_update_attachment(m_attachment_parent_id,
m_attachment_bone, m_attachment_position, m_attachment_rotation);
// create message and add to list // create message and add to list
ActiveObjectMessage aom(getId(), true, str); ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom); m_messages_out.push(aom);

View File

@ -112,7 +112,7 @@ private:
bool m_animation_loop; bool m_animation_loop;
bool m_animation_sent; bool m_animation_sent;
std::map<std::string, core::vector2d<v3f> > m_bone_position; UNORDERED_MAP<std::string, core::vector2d<v3f> > m_bone_position;
bool m_bone_position_sent; bool m_bone_position_sent;
int m_attachment_parent_id; int m_attachment_parent_id;
@ -321,7 +321,8 @@ private:
bool m_animation_loop; bool m_animation_loop;
bool m_animation_sent; bool m_animation_sent;
std::map<std::string, core::vector2d<v3f> > m_bone_position; // Stores position and rotation for each bone name // Stores position and rotation for each bone name
UNORDERED_MAP<std::string, core::vector2d<v3f> > m_bone_position;
bool m_bone_position_sent; bool m_bone_position_sent;
int m_attachment_parent_id; int m_attachment_parent_id;

View File

@ -409,8 +409,6 @@ protected:
std::vector<std::pair<FieldSpec, std::vector<std::string> > > m_dropdowns; std::vector<std::pair<FieldSpec, std::vector<std::string> > > m_dropdowns;
ItemSpec *m_selected_item; ItemSpec *m_selected_item;
f32 m_timer1;
f32 m_timer2;
u32 m_selected_amount; u32 m_selected_amount;
bool m_selected_dragging; bool m_selected_dragging;
@ -462,7 +460,7 @@ private:
GUITable::TableOptions table_options; GUITable::TableOptions table_options;
GUITable::TableColumns table_columns; GUITable::TableColumns table_columns;
// used to restore table selection/scroll/treeview state // used to restore table selection/scroll/treeview state
std::map<std::string, GUITable::DynamicData> table_dyndata; UNORDERED_MAP<std::string, GUITable::DynamicData> table_dyndata;
} parserData; } parserData;
typedef struct { typedef struct {

View File

@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "voxel.h" #include "voxel.h"
#include "modifiedstate.h" #include "modifiedstate.h"
#include "util/container.h" #include "util/container.h"
#include "util/cpp11_container.h"
#include "nodetimer.h" #include "nodetimer.h"
#include "map_settings_manager.h" #include "map_settings_manager.h"

View File

@ -1033,7 +1033,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
m_enable_shaders = data->m_use_shaders; m_enable_shaders = data->m_use_shaders;
m_use_tangent_vertices = data->m_use_tangent_vertices; m_use_tangent_vertices = data->m_use_tangent_vertices;
m_enable_vbo = g_settings->getBool("enable_vbo"); m_enable_vbo = g_settings->getBool("enable_vbo");
if (g_settings->getBool("enable_minimap")) { if (g_settings->getBool("enable_minimap")) {
m_minimap_mapblock = new MinimapMapblock; m_minimap_mapblock = new MinimapMapblock;
m_minimap_mapblock->getMinimapNodes( m_minimap_mapblock->getMinimapNodes(
@ -1298,10 +1298,8 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
// Cracks // Cracks
if(crack != m_last_crack) if(crack != m_last_crack)
{ {
for(std::map<u32, std::string>::iterator for (UNORDERED_MAP<u32, std::string>::iterator i = m_crack_materials.begin();
i = m_crack_materials.begin(); i != m_crack_materials.end(); ++i) {
i != m_crack_materials.end(); ++i)
{
scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(i->first); scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(i->first);
std::string basename = i->second; std::string basename = i->second;
@ -1315,9 +1313,9 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
// If the current material is also animated, // If the current material is also animated,
// update animation info // update animation info
std::map<u32, TileSpec>::iterator anim_iter = UNORDERED_MAP<u32, TileSpec>::iterator anim_iter =
m_animation_tiles.find(i->first); m_animation_tiles.find(i->first);
if(anim_iter != m_animation_tiles.end()){ if (anim_iter != m_animation_tiles.end()){
TileSpec &tile = anim_iter->second; TileSpec &tile = anim_iter->second;
tile.texture = new_texture; tile.texture = new_texture;
tile.texture_id = new_texture_id; tile.texture_id = new_texture_id;
@ -1330,10 +1328,8 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
} }
// Texture animation // Texture animation
for(std::map<u32, TileSpec>::iterator for (UNORDERED_MAP<u32, TileSpec>::iterator i = m_animation_tiles.begin();
i = m_animation_tiles.begin(); i != m_animation_tiles.end(); ++i) {
i != m_animation_tiles.end(); ++i)
{
const TileSpec &tile = i->second; const TileSpec &tile = i->second;
// Figure out current frame // Figure out current frame
int frameoffset = m_animation_frame_offsets[i->first]; int frameoffset = m_animation_frame_offsets[i->first];
@ -1443,7 +1439,7 @@ void MeshCollector::append(const TileSpec &tile,
vertices[i].Color, vertices[i].TCoords); vertices[i].Color, vertices[i].TCoords);
p->vertices.push_back(vert); p->vertices.push_back(vert);
} }
} }
for (u32 i = 0; i < numIndices; i++) { for (u32 i = 0; i < numIndices; i++) {
u32 j = indices[i] + vertex_count; u32 j = indices[i] + vertex_count;
@ -1499,7 +1495,7 @@ void MeshCollector::append(const TileSpec &tile,
vertices[i].Normal, c, vertices[i].TCoords); vertices[i].Normal, c, vertices[i].TCoords);
p->vertices.push_back(vert); p->vertices.push_back(vert);
} }
} }
for (u32 i = 0; i < numIndices; i++) { for (u32 i = 0; i < numIndices; i++) {
u32 j = indices[i] + vertex_count; u32 j = indices[i] + vertex_count;

View File

@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irrlichttypes_extrabloated.h" #include "irrlichttypes_extrabloated.h"
#include "client/tile.h" #include "client/tile.h"
#include "voxel.h" #include "voxel.h"
#include "util/cpp11_container.h"
#include <map> #include <map>
class IGameDef; class IGameDef;
@ -121,7 +122,7 @@ public:
if(m_animation_force_timer > 0) if(m_animation_force_timer > 0)
m_animation_force_timer--; m_animation_force_timer--;
} }
void updateCameraOffset(v3s16 camera_offset); void updateCameraOffset(v3s16 camera_offset);
private: private:
@ -144,20 +145,20 @@ private:
// Last crack value passed to animate() // Last crack value passed to animate()
int m_last_crack; int m_last_crack;
// Maps mesh buffer (i.e. material) indices to base texture names // Maps mesh buffer (i.e. material) indices to base texture names
std::map<u32, std::string> m_crack_materials; UNORDERED_MAP<u32, std::string> m_crack_materials;
// Animation info: texture animationi // Animation info: texture animationi
// Maps meshbuffers to TileSpecs // Maps meshbuffers to TileSpecs
std::map<u32, TileSpec> m_animation_tiles; UNORDERED_MAP<u32, TileSpec> m_animation_tiles;
std::map<u32, int> m_animation_frames; // last animation frame UNORDERED_MAP<u32, int> m_animation_frames; // last animation frame
std::map<u32, int> m_animation_frame_offsets; UNORDERED_MAP<u32, int> m_animation_frame_offsets;
// Animation info: day/night transitions // Animation info: day/night transitions
// Last daynight_ratio value passed to animate() // Last daynight_ratio value passed to animate()
u32 m_last_daynight_ratio; u32 m_last_daynight_ratio;
// For each meshbuffer, maps vertex indices to (day,night) pairs // For each meshbuffer, maps vertex indices to (day,night) pairs
std::map<u32, std::map<u32, std::pair<u8, u8> > > m_daynight_diffs; std::map<u32, std::map<u32, std::pair<u8, u8> > > m_daynight_diffs;
// Camera offset info -> do we have to translate the mesh? // Camera offset info -> do we have to translate the mesh?
v3s16 m_camera_offset; v3s16 m_camera_offset;
}; };

View File

@ -1693,9 +1693,7 @@ void Server::handleCommand_RemovedSounds(NetworkPacket* pkt)
*pkt >> id; *pkt >> id;
std::map<s32, ServerPlayingSound>::iterator i = UNORDERED_MAP<s32, ServerPlayingSound>::iterator i = m_playing_sounds.find(id);
m_playing_sounds.find(id);
if (i == m_playing_sounds.end()) if (i == m_playing_sounds.end())
continue; continue;

View File

@ -81,6 +81,7 @@ bool AsyncEngine::registerFunction(const char* name, lua_CFunction func)
if (initDone) { if (initDone) {
return false; return false;
} }
functionList[name] = func; functionList[name] = func;
return true; return true;
} }
@ -203,7 +204,7 @@ void AsyncEngine::pushFinishedJobs(lua_State* L) {
/******************************************************************************/ /******************************************************************************/
void AsyncEngine::prepareEnvironment(lua_State* L, int top) void AsyncEngine::prepareEnvironment(lua_State* L, int top)
{ {
for (std::map<std::string, lua_CFunction>::iterator it = functionList.begin(); for (UNORDERED_MAP<std::string, lua_CFunction>::iterator it = functionList.begin();
it != functionList.end(); it++) { it != functionList.end(); it++) {
lua_pushstring(L, it->first.c_str()); lua_pushstring(L, it->first.c_str());
lua_pushcfunction(L, it->second); lua_pushcfunction(L, it->second);

View File

@ -132,7 +132,7 @@ private:
bool initDone; bool initDone;
// Internal store for registred functions // Internal store for registred functions
std::map<std::string, lua_CFunction> functionList; UNORDERED_MAP<std::string, lua_CFunction> functionList;
// Internal counter to create job IDs // Internal counter to create job IDs
unsigned int jobIdCounter; unsigned int jobIdCounter;

View File

@ -868,7 +868,7 @@ void Server::AsyncRunStep(bool initial_step)
m_clients.unlock(); m_clients.unlock();
// Clear buffered_messages // Clear buffered_messages
for(UNORDERED_MAP<u16, std::vector<ActiveObjectMessage>* >::iterator for (UNORDERED_MAP<u16, std::vector<ActiveObjectMessage>* >::iterator
i = buffered_messages.begin(); i = buffered_messages.begin();
i != buffered_messages.end(); ++i) { i != buffered_messages.end(); ++i) {
delete i->second; delete i->second;
@ -2016,16 +2016,15 @@ s32 Server::playSound(const SimpleSoundSpec &spec,
void Server::stopSound(s32 handle) void Server::stopSound(s32 handle)
{ {
// Get sound reference // Get sound reference
std::map<s32, ServerPlayingSound>::iterator i = UNORDERED_MAP<s32, ServerPlayingSound>::iterator i = m_playing_sounds.find(handle);
m_playing_sounds.find(handle); if (i == m_playing_sounds.end())
if(i == m_playing_sounds.end())
return; return;
ServerPlayingSound &psound = i->second; ServerPlayingSound &psound = i->second;
NetworkPacket pkt(TOCLIENT_STOP_SOUND, 4); NetworkPacket pkt(TOCLIENT_STOP_SOUND, 4);
pkt << handle; pkt << handle;
for(std::set<u16>::iterator i = psound.clients.begin(); for (UNORDERED_SET<u16>::iterator i = psound.clients.begin();
i != psound.clients.end(); ++i) { i != psound.clients.end(); ++i) {
// Send as reliable // Send as reliable
m_clients.send(*i, 0, &pkt, true); m_clients.send(*i, 0, &pkt, true);
@ -2322,7 +2321,7 @@ void Server::sendMediaAnnouncement(u16 peer_id)
NetworkPacket pkt(TOCLIENT_ANNOUNCE_MEDIA, 0, peer_id); NetworkPacket pkt(TOCLIENT_ANNOUNCE_MEDIA, 0, peer_id);
pkt << (u16) m_media.size(); pkt << (u16) m_media.size();
for (std::map<std::string, MediaInfo>::iterator i = m_media.begin(); for (UNORDERED_MAP<std::string, MediaInfo>::iterator i = m_media.begin();
i != m_media.end(); ++i) { i != m_media.end(); ++i) {
pkt << i->first << i->second.sha1_digest; pkt << i->first << i->second.sha1_digest;
} }
@ -2367,7 +2366,7 @@ void Server::sendRequestedMedia(u16 peer_id,
i != tosend.end(); ++i) { i != tosend.end(); ++i) {
const std::string &name = *i; const std::string &name = *i;
if(m_media.find(name) == m_media.end()) { if (m_media.find(name) == m_media.end()) {
errorstream<<"Server::sendRequestedMedia(): Client asked for " errorstream<<"Server::sendRequestedMedia(): Client asked for "
<<"unknown file \""<<(name)<<"\""<<std::endl; <<"unknown file \""<<(name)<<"\""<<std::endl;
continue; continue;
@ -2628,13 +2627,11 @@ void Server::DeleteClient(u16 peer_id, ClientDeletionReason reason)
/* /*
Clear references to playing sounds Clear references to playing sounds
*/ */
for(std::map<s32, ServerPlayingSound>::iterator for (UNORDERED_MAP<s32, ServerPlayingSound>::iterator
i = m_playing_sounds.begin(); i = m_playing_sounds.begin(); i != m_playing_sounds.end();) {
i != m_playing_sounds.end();)
{
ServerPlayingSound &psound = i->second; ServerPlayingSound &psound = i->second;
psound.clients.erase(peer_id); psound.clients.erase(peer_id);
if(psound.clients.empty()) if (psound.clients.empty())
m_playing_sounds.erase(i++); m_playing_sounds.erase(i++);
else else
++i; ++i;

View File

@ -157,7 +157,7 @@ struct ServerSoundParams
struct ServerPlayingSound struct ServerPlayingSound
{ {
ServerSoundParams params; ServerSoundParams params;
std::set<u16> clients; // peer ids UNORDERED_SET<u16> clients; // peer ids
}; };
class Server : public con::PeerHandler, public MapEventReceiver, class Server : public con::PeerHandler, public MapEventReceiver,
@ -243,11 +243,9 @@ public:
std::wstring getStatusString(); std::wstring getStatusString();
// read shutdown state // read shutdown state
inline bool getShutdownRequested() inline bool getShutdownRequested() const { return m_shutdown_requested; }
{ return m_shutdown_requested; }
// request server to shutdown // request server to shutdown
inline void requestShutdown() { m_shutdown_requested = true; }
void requestShutdown(const std::string &msg, bool reconnect) void requestShutdown(const std::string &msg, bool reconnect)
{ {
m_shutdown_requested = true; m_shutdown_requested = true;
@ -323,8 +321,7 @@ public:
const ModSpec* getModSpec(const std::string &modname) const; const ModSpec* getModSpec(const std::string &modname) const;
void getModNames(std::vector<std::string> &modlist); void getModNames(std::vector<std::string> &modlist);
std::string getBuiltinLuaPath(); std::string getBuiltinLuaPath();
inline std::string getWorldPath() const inline std::string getWorldPath() const { return m_path_world; }
{ return m_path_world; }
inline bool isSingleplayer() inline bool isSingleplayer()
{ return m_simple_singleplayer_mode; } { return m_simple_singleplayer_mode; }
@ -356,8 +353,7 @@ public:
bool setSky(Player *player, const video::SColor &bgcolor, bool setSky(Player *player, const video::SColor &bgcolor,
const std::string &type, const std::vector<std::string> &params); const std::string &type, const std::vector<std::string> &params);
bool overrideDayNightRatio(Player *player, bool do_override, bool overrideDayNightRatio(Player *player, bool do_override, float brightness);
float brightness);
/* con::PeerHandler implementation. */ /* con::PeerHandler implementation. */
void peerAdded(con::Peer *peer); void peerAdded(con::Peer *peer);
@ -654,12 +650,12 @@ private:
u16 m_ignore_map_edit_events_peer_id; u16 m_ignore_map_edit_events_peer_id;
// media files known to server // media files known to server
std::map<std::string,MediaInfo> m_media; UNORDERED_MAP<std::string, MediaInfo> m_media;
/* /*
Sounds Sounds
*/ */
std::map<s32, ServerPlayingSound> m_playing_sounds; UNORDERED_MAP<s32, ServerPlayingSound> m_playing_sounds;
s32 m_next_sound_id; s32 m_next_sound_id;
/* /*

View File

@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
std::map<u16, std::vector<v3s16> > FacePositionCache::m_cache; UNORDERED_MAP<u16, std::vector<v3s16> > FacePositionCache::m_cache;
Mutex FacePositionCache::m_cache_mutex; Mutex FacePositionCache::m_cache_mutex;
// Calculate the borders of a "d-radius" cube // Calculate the borders of a "d-radius" cube
// TODO: Make it work without mutex and data races, probably thread-local // TODO: Make it work without mutex and data races, probably thread-local

View File

@ -26,8 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "../irr_v3d.h" #include "../irr_v3d.h"
#include "../irr_aabb3d.h" #include "../irr_aabb3d.h"
#include "../threading/mutex.h" #include "../threading/mutex.h"
#include "cpp11_container.h"
#include <list> #include <list>
#include <map>
#include <vector> #include <vector>
@ -41,26 +41,10 @@ public:
static std::vector<v3s16> getFacePositions(u16 d); static std::vector<v3s16> getFacePositions(u16 d);
private: private:
static void generateFacePosition(u16 d); static void generateFacePosition(u16 d);
static std::map<u16, std::vector<v3s16> > m_cache; static UNORDERED_MAP<u16, std::vector<v3s16> > m_cache;
static Mutex m_cache_mutex; static Mutex m_cache_mutex;
}; };
class IndentationRaiser
{
public:
IndentationRaiser(u16 *indentation)
{
m_indentation = indentation;
(*m_indentation)++;
}
~IndentationRaiser()
{
(*m_indentation)--;
}
private:
u16 *m_indentation;
};
inline s16 getContainerPos(s16 p, s16 d) inline s16 getContainerPos(s16 p, s16 d)
{ {
return (p>=0 ? p : p-d+1) / d; return (p>=0 ? p : p-d+1) / d;
@ -149,23 +133,6 @@ inline bool isInArea(v3s16 p, v3s16 d)
#define rangelim(d, min, max) ((d) < (min) ? (min) : ((d)>(max)?(max):(d))) #define rangelim(d, min, max) ((d) < (min) ? (min) : ((d)>(max)?(max):(d)))
#define myfloor(x) ((x) > 0.0 ? (int)(x) : (int)(x) - 1) #define myfloor(x) ((x) > 0.0 ? (int)(x) : (int)(x) - 1)
inline v3s16 arealim(v3s16 p, s16 d)
{
if(p.X < 0)
p.X = 0;
if(p.Y < 0)
p.Y = 0;
if(p.Z < 0)
p.Z = 0;
if(p.X > d-1)
p.X = d-1;
if(p.Y > d-1)
p.Y = d-1;
if(p.Z > d-1)
p.Z = d-1;
return p;
}
// The naive swap performs better than the xor version // The naive swap performs better than the xor version
#define SWAP(t, x, y) do { \ #define SWAP(t, x, y) do { \
t temp = x; \ t temp = x; \