/* Minetest-c55 Copyright (C) 2010 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 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 General Public License for more details. You should have received a copy of the GNU 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. */ #include "voxel.h" #include "map.h" #include "utility.h" // For TimeTaker #include "gettime.h" #include "content_mapnode.h" /* Debug stuff */ u32 addarea_time = 0; u32 emerge_time = 0; u32 emerge_load_time = 0; u32 clearflag_time = 0; //u32 getwaterpressure_time = 0; //u32 spreadwaterpressure_time = 0; u32 updateareawaterpressure_time = 0; u32 flowwater_pre_time = 0; VoxelManipulator::VoxelManipulator(): m_data(NULL), m_flags(NULL) { } VoxelManipulator::~VoxelManipulator() { clear(); if(m_data) delete[] m_data; if(m_flags) delete[] m_flags; } void VoxelManipulator::clear() { // Reset area to volume=0 m_area = VoxelArea(); if(m_data) delete[] m_data; m_data = NULL; if(m_flags) delete[] m_flags; m_flags = NULL; } void VoxelManipulator::print(std::ostream &o, VoxelPrintMode mode) { v3s16 em = m_area.getExtent(); v3s16 of = m_area.MinEdge; o<<"size: "<=m_area.MinEdge.Y; y--) { if(em.X >= 3 && em.Y >= 3) { if (y==m_area.MinEdge.Y+2) o<<"^ "; else if(y==m_area.MinEdge.Y+1) o<<"| "; else if(y==m_area.MinEdge.Y+0) o<<"y x-> "; else o<<" "; } for(s32 z=m_area.MinEdge.Z; z<=m_area.MaxEdge.Z; z++) { for(s32 x=m_area.MinEdge.X; x<=m_area.MaxEdge.X; x++) { u8 f = m_flags[m_area.index(x,y,z)]; char c; if(f & VOXELFLAG_NOT_LOADED) c = 'N'; else if(f & VOXELFLAG_INEXISTENT) c = 'I'; else { c = 'X'; content_t m = m_data[m_area.index(x,y,z)].getContent(); u8 pr = m_data[m_area.index(x,y,z)].param2; if(mode == VOXELPRINT_MATERIAL) { if(m <= 9) c = m + '0'; } else if(mode == VOXELPRINT_WATERPRESSURE) { if(m == CONTENT_WATER) { c = 'w'; if(pr <= 9) c = pr + '0'; } else if(m == CONTENT_AIR) { c = ' '; } else { c = '#'; } } } o</* Minetest Copyright (C) 2013 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 GETTEXT_HEADER #define GETTEXT_HEADER #include "config.h" // for USE_GETTEXT #include "log.h" #if USE_GETTEXT #include <libintl.h> #else #define gettext(String) String #endif #define _(String) gettext(String) #define gettext_noop(String) String #define N_(String) gettext_noop (String) #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #endif #include <windows.h> #endif // #if defined(_WIN32) #ifdef _MSC_VER void init_gettext(const char *path,std::string configured_language,int argc, char** argv); #else void init_gettext(const char *path,std::string configured_language); #endif /******************************************************************************/ inline wchar_t* chartowchar_t(const char *str) { wchar_t* nstr = 0; #if defined(_WIN32) int nResult = MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) str, -1, 0, 0 ); if( nResult == 0 ) { errorstream<<"gettext: MultiByteToWideChar returned null"<<std::endl; } else { nstr = new wchar_t[nResult]; MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) str, -1, (WCHAR *) nstr, nResult ); } #else size_t l = strlen(str)+1; nstr = new wchar_t[l]; mbstowcs(nstr, str, l); #endif return nstr; } /******************************************************************************/ inline wchar_t* wgettext(const char *str) { return chartowchar_t(gettext(str)); } /******************************************************************************/ inline std::wstring wstrgettext(std::string text) { wchar_t* wlabel = wgettext(text.c_str()); std::wstring out = (std::wstring)wlabel; delete[] wlabel; return out; } #endif ode &n = m_data[i]; u8 oldlight = n.getLight(bank); u8 newlight = diminish_light(oldlight); // Loop through 6 neighbors for(u16 i=0; i<6; i++) { // Get the position of the neighbor node v3s16 n2pos = pos + dirs[i]; try { u32 n2i = m_area.index(n2pos); if(m_flags[n2i] & VOXELFLAG_INEXISTENT) continue; MapNode &n2 = m_data[n2i]; /* If the neighbor is brighter than the current node, add to list (it will light up this node on its turn) */ if(n2.getLight(bank) > undiminish_light(oldlight)) { lighted_nodes.insert(n2pos, true); } /* If the neighbor is dimmer than how much light this node would spread on it, add to list */ if(n2.getLight(bank) < newlight) { if(n2.light_propagates()) { n2.setLight(bank, newlight); lighted_nodes.insert(n2pos, true); } } } catch(InvalidPositionException &e) { continue; } } } /*dstream<<"spreadLight(): Changed block " < 0) spreadLight(bank, lighted_nodes); } #endif //END