diff options
Diffstat (limited to 'src')
29 files changed, 13 insertions, 439 deletions
diff --git a/src/chat.cpp b/src/chat.cpp index c3ed59804..2f65e68b3 100644 --- a/src/chat.cpp +++ b/src/chat.cpp @@ -123,14 +123,14 @@ void ChatBuffer::deleteByAge(f32 maxAge) deleteOldest(count); } -u32 ChatBuffer::getColumns() const +u32 ChatBuffer::getRows() const { - return m_cols; + return m_rows; } -u32 ChatBuffer::getRows() const +void ChatBuffer::scrollTop() { - return m_rows; + m_scroll = getTopScrollPos(); } void ChatBuffer::reformat(u32 cols, u32 rows) @@ -220,11 +220,6 @@ void ChatBuffer::scrollBottom() m_scroll = getBottomScrollPos(); } -void ChatBuffer::scrollTop() -{ - m_scroll = getTopScrollPos(); -} - u32 ChatBuffer::formatChatLine(const ChatLine& line, u32 cols, std::vector<ChatFormattedLine>& destination) const { diff --git a/src/chat.h b/src/chat.h index f84ece206..0b98e4d3c 100644 --- a/src/chat.h +++ b/src/chat.h @@ -94,8 +94,6 @@ public: // Delete lines older than maxAge. void deleteByAge(f32 maxAge); - // Get number of columns, 0 if reformat has not been called yet. - u32 getColumns() const; // Get number of rows, 0 if reformat has not been called yet. u32 getRows() const; // Update console size and reformat all formatted lines. diff --git a/src/client/client.cpp b/src/client/client.cpp index 7fafe0da9..0bd98b256 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1665,11 +1665,6 @@ ClientEvent *Client::getClientEvent() return event; } -bool Client::connectedToServer() -{ - return m_con->Connected(); -} - const Address Client::getServerAddress() { return m_con->GetPeerAddress(PEER_ID_SERVER); diff --git a/src/client/client.h b/src/client/client.h index 8f4aac6e3..bffdc7ec6 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -338,7 +338,6 @@ public: u16 getProtoVersion() { return m_proto_ver; } - bool connectedToServer(); void confirmRegistration(); bool m_is_registration_confirmation_state = false; bool m_simple_singleplayer_mode; diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp index 0b7e92325..f831978a8 100644 --- a/src/client/clientenvironment.cpp +++ b/src/client/clientenvironment.cpp @@ -368,21 +368,6 @@ bool isFreeClientActiveObjectId(const u16 id, } -u16 getFreeClientActiveObjectId(ClientActiveObjectMap &objects) -{ - // try to reuse id's as late as possible - static u16 last_used_id = 0; - u16 startid = last_used_id; - for(;;) { - last_used_id ++; - if (isFreeClientActiveObjectId(last_used_id, objects)) - return last_used_id; - - if (last_used_id == startid) - return 0; - } -} - u16 ClientEnvironment::addActiveObject(ClientActiveObject *object) { // Register object. If failed return zero id diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index 3e4ab2e94..3124313e7 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -36,7 +36,7 @@ ClientMap::ClientMap( MapDrawControl &control, s32 id ): - Map(dout_client, client), + Map(client), scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(), RenderingEngine::get_scene_manager(), id), m_client(client), diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index b59679523..f9332e399 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -81,33 +81,6 @@ void MeshMakeData::fill(MapBlock *block) } } -void MeshMakeData::fillSingleNode(MapNode *node) -{ - m_blockpos = v3s16(0,0,0); - - v3s16 blockpos_nodes = v3s16(0,0,0); - VoxelArea area(blockpos_nodes-v3s16(1,1,1)*MAP_BLOCKSIZE, - blockpos_nodes+v3s16(1,1,1)*MAP_BLOCKSIZE*2-v3s16(1,1,1)); - s32 volume = area.getVolume(); - s32 our_node_index = area.index(1,1,1); - - // Allocate this block + neighbors - m_vmanip.clear(); - m_vmanip.addArea(area); - - // Fill in data - MapNode *data = new MapNode[volume]; - for(s32 i = 0; i < volume; i++) - { - if (i == our_node_index) - data[i] = *node; - else - data[i] = MapNode(CONTENT_AIR, LIGHT_MAX, 0); - } - m_vmanip.copyFrom(data, area, area.MinEdge, area.MinEdge, area.getExtent()); - delete[] data; -} - void MeshMakeData::setCrack(int crack_level, v3s16 crack_pos) { if (crack_level >= 0) diff --git a/src/client/mapblock_mesh.h b/src/client/mapblock_mesh.h index 6af23a656..f8aed40dc 100644 --- a/src/client/mapblock_mesh.h +++ b/src/client/mapblock_mesh.h @@ -63,11 +63,6 @@ struct MeshMakeData void fill(MapBlock *block); /* - Set up with only a single node at (1,1,1) - */ - void fillSingleNode(MapNode *node); - - /* Set the (node) position of a crack */ void setCrack(int crack_level, v3s16 crack_pos); diff --git a/src/content/CMakeLists.txt b/src/content/CMakeLists.txt index 5adcf6b1e..6dd049418 100644 --- a/src/content/CMakeLists.txt +++ b/src/content/CMakeLists.txt @@ -1,6 +1,5 @@ set(content_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/content.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/packages.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mods.cpp ${CMAKE_CURRENT_SOURCE_DIR}/subgames.cpp PARENT_SCOPE diff --git a/src/content/packages.cpp b/src/content/packages.cpp deleted file mode 100644 index 2d488eb76..000000000 --- a/src/content/packages.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* -Minetest -Copyright (C) 2018 rubenwardy <rw@rubenwardy.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. -*/ - -#include "content/packages.h" -#include "log.h" -#include "filesys.h" -#include "porting.h" -#include "settings.h" -#include "content/mods.h" -#include "content/subgames.h" - -std::string Package::getDownloadURL(const std::string &baseURL) const -{ - return baseURL + "/packages/" + author + "/" + name + "/releases/" + - std::to_string(release) + "/download/"; -} - -#if USE_CURL -std::vector<Package> getPackagesFromURL(const std::string &url) -{ - std::vector<std::string> extra_headers; - extra_headers.emplace_back("Accept: application/json"); - - Json::Value json = fetchJsonValue(url, &extra_headers); - if (!json.isArray()) { - errorstream << "Invalid JSON download " << std::endl; - return std::vector<Package>(); - } - - std::vector<Package> packages; - - // Note: `unsigned int` is required to index JSON - for (unsigned int i = 0; i < json.size(); ++i) { - Package package; - - package.author = json[i]["author"].asString(); - package.name = json[i]["name"].asString(); - package.title = json[i]["title"].asString(); - package.type = json[i]["type"].asString(); - package.shortDesc = json[i]["shortDesc"].asString(); - package.release = json[i]["release"].asInt(); - if (json[i].isMember("thumbnail")) - package.thumbnail = json[i]["thumbnail"].asString(); - - if (package.valid()) - packages.push_back(package); - else - errorstream << "Invalid package at " << i << std::endl; - } - - return packages; -} -#endif diff --git a/src/content/packages.h b/src/content/packages.h deleted file mode 100644 index 9029475ef..000000000 --- a/src/content/packages.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -Minetest -Copyright (C) 2018 rubenwardy <rw@rubenwardy.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. -*/ - -#pragma once -#include "config.h" -#include "convert_json.h" -#include "irrlichttypes.h" - -struct Package -{ - std::string author; - std::string name; // Technical name - std::string title; - std::string type; // One of "mod", "game", or "txp" - - std::string shortDesc; - u32 release; - std::string thumbnail; - - bool valid() const - { - return !(author.empty() || name.empty() || title.empty() || - type.empty() || release <= 0); - } - - std::string getDownloadURL(const std::string &baseURL) const; -}; - -#if USE_CURL -std::vector<Package> getPackagesFromURL(const std::string &url); -#else -inline std::vector<Package> getPackagesFromURL(const std::string &url) -{ - return std::vector<Package>(); -} -#endif diff --git a/src/gui/guiChatConsole.cpp b/src/gui/guiChatConsole.cpp index 575c6ab25..ef471106d 100644 --- a/src/gui/guiChatConsole.cpp +++ b/src/gui/guiChatConsole.cpp @@ -136,11 +136,6 @@ void GUIChatConsole::closeConsoleAtOnce() recalculateConsolePosition(); } -f32 GUIChatConsole::getDesiredHeight() const -{ - return m_desired_height_fraction; -} - void GUIChatConsole::replaceAndAddToHistory(const std::wstring &line) { ChatPrompt& prompt = m_chat_backend->getPrompt(); diff --git a/src/gui/guiChatConsole.h b/src/gui/guiChatConsole.h index 7be40e27c..204f9f9cc 100644 --- a/src/gui/guiChatConsole.h +++ b/src/gui/guiChatConsole.h @@ -55,10 +55,6 @@ public: // Set whether to close the console after the user presses enter. void setCloseOnEnter(bool close) { m_close_on_enter = close; } - // Return the desired height (fraction of screen size) - // Zero if the console is closed or getting closed - f32 getDesiredHeight() const; - // Replace actual line when adding the actual to the history (if there is any) void replaceAndAddToHistory(const std::wstring &line); diff --git a/src/log.cpp b/src/log.cpp index 54442c39b..3c61414e9 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -97,16 +97,7 @@ LogBuffer verbose_buf(g_logger, LL_VERBOSE); std::ostream *dout_con_ptr = &null_stream; std::ostream *derr_con_ptr = &verbosestream; -// Server -std::ostream *dout_server_ptr = &infostream; -std::ostream *derr_server_ptr = &errorstream; - -#ifndef SERVER -// Client -std::ostream *dout_client_ptr = &infostream; -std::ostream *derr_client_ptr = &errorstream; -#endif - +// Common streams std::ostream rawstream(&raw_buf); std::ostream dstream(&none_buf); std::ostream errorstream(&error_buf); @@ -192,14 +192,8 @@ extern std::ostream null_stream; extern std::ostream *dout_con_ptr; extern std::ostream *derr_con_ptr; -extern std::ostream *dout_server_ptr; extern std::ostream *derr_server_ptr; -#ifndef SERVER -extern std::ostream *dout_client_ptr; -extern std::ostream *derr_client_ptr; -#endif - extern Logger g_logger; // Writes directly to all LL_NONE log outputs for g_logger with no prefix. @@ -222,8 +216,4 @@ extern std::ostream dstream; #define dout_con (*dout_con_ptr) #define derr_con (*derr_con_ptr) -#define dout_server (*dout_server_ptr) -#ifndef SERVER - #define dout_client (*dout_client_ptr) -#endif diff --git a/src/map.cpp b/src/map.cpp index b9ab7c066..ef7eddb39 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -62,8 +62,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Map */ -Map::Map(std::ostream &dout, IGameDef *gamedef): - m_dout(dout), +Map::Map(IGameDef *gamedef): m_gamedef(gamedef), m_nodedef(gamedef->ndef()) { @@ -1201,7 +1200,7 @@ bool Map::isBlockOccluded(MapBlock *block, v3s16 cam_pos_nodes) */ ServerMap::ServerMap(const std::string &savedir, IGameDef *gamedef, EmergeManager *emerge, MetricsBackend *mb): - Map(dout_server, gamedef), + Map(gamedef), settings_mgr(g_settings, savedir + DIR_DELIM + "map_meta.txt"), m_emerge(emerge) { @@ -1327,11 +1326,6 @@ u64 ServerMap::getSeed() return getMapgenParams()->seed; } -s16 ServerMap::getWaterLevel() -{ - return getMapgenParams()->water_level; -} - bool ServerMap::blockpos_over_mapgen_limit(v3s16 p) { const s16 mapgen_limit_bp = rangelim( @@ -1732,59 +1726,6 @@ void ServerMap::updateVManip(v3s16 pos) vm->m_is_dirty = true; } -s16 ServerMap::findGroundLevel(v2s16 p2d) -{ -#if 0 - /* - Uh, just do something random... - */ - // Find existing map from top to down - s16 max=63; - s16 min=-64; - v3s16 p(p2d.X, max, p2d.Y); - for(; p.Y>min; p.Y--) - { - MapNode n = getNodeNoEx(p); - if(n.getContent() != CONTENT_IGNORE) - break; - } - if(p.Y == min) - goto plan_b; - // If this node is not air, go to plan b - if(getNodeNoEx(p).getContent() != CONTENT_AIR) - goto plan_b; - // Search existing walkable and return it - for(; p.Y>min; p.Y--) - { - MapNode n = getNodeNoEx(p); - if(content_walkable(n.d) && n.getContent() != CONTENT_IGNORE) - return p.Y; - } - - // Move to plan b -plan_b: -#endif - - /* - Determine from map generator noise functions - */ - - s16 level = m_emerge->getGroundLevelAtPoint(p2d); - return level; - - //double level = base_rock_level_2d(m_seed, p2d) + AVERAGE_MUD_AMOUNT; - //return (s16)level; -} - -void ServerMap::createDirs(const std::string &path) -{ - if (!fs::CreateAllDirs(path)) { - m_dout<<"ServerMap: Failed to create directory " - <<"\""<<path<<"\""<<std::endl; - throw BaseException("ServerMap failed to create directory"); - } -} - void ServerMap::save(ModifiedState save_level) { if (!m_map_saving_enabled) { @@ -123,7 +123,7 @@ class Map /*: public NodeContainer*/ { public: - Map(std::ostream &dout, IGameDef *gamedef); + Map(IGameDef *gamedef); virtual ~Map(); DISABLE_CLASS_COPY(Map); @@ -149,8 +149,6 @@ public: MapSector * getSectorNoGenerateNoLock(v2s16 p2d); // Same as the above (there exists no lock anymore) MapSector * getSectorNoGenerate(v2s16 p2d); - // Gets an existing sector or creates an empty one - //MapSector * getSectorCreate(v2s16 p2d); /* This is overloaded by ClientMap and ServerMap to allow @@ -269,11 +267,6 @@ public: void removeNodeTimer(v3s16 p); /* - Misc. - */ - std::map<v2s16, MapSector*> *getSectorsPtr(){return &m_sectors;} - - /* Variables */ @@ -283,8 +276,6 @@ public: protected: friend class LuaVoxelManip; - std::ostream &m_dout; // A bit deprecated, could be removed - IGameDef *m_gamedef; std::set<MapEventReceiver*> m_event_receivers; @@ -374,15 +365,6 @@ public: */ MapBlock *getBlockOrEmerge(v3s16 p3d); - // Helper for placing objects on ground level - s16 findGroundLevel(v2s16 p2d); - - /* - Misc. helper functions for fiddling with directory and file - names when saving - */ - void createDirs(const std::string &path); - /* Database functions */ @@ -414,7 +396,6 @@ public: bool isSavingEnabled(){ return m_map_saving_enabled; } u64 getSeed(); - s16 getWaterLevel(); /*! * Fixes lighting in one map block. diff --git a/src/mapgen/mapgen.cpp b/src/mapgen/mapgen.cpp index 52ef64e7e..e0dfd2d71 100644 --- a/src/mapgen/mapgen.cpp +++ b/src/mapgen/mapgen.cpp @@ -244,26 +244,6 @@ u32 Mapgen::getBlockSeed2(v3s16 p, s32 seed) } -// Returns Y one under area minimum if not found -s16 Mapgen::findGroundLevelFull(v2s16 p2d) -{ - const v3s16 &em = vm->m_area.getExtent(); - s16 y_nodes_max = vm->m_area.MaxEdge.Y; - s16 y_nodes_min = vm->m_area.MinEdge.Y; - u32 i = vm->m_area.index(p2d.X, y_nodes_max, p2d.Y); - s16 y; - - for (y = y_nodes_max; y >= y_nodes_min; y--) { - MapNode &n = vm->m_data[i]; - if (ndef->get(n).walkable) - break; - - VoxelArea::add_y(em, i, -1); - } - return (y >= y_nodes_min) ? y : y_nodes_min - 1; -} - - // Returns -MAX_MAP_GENERATION_LIMIT if not found s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax) { @@ -984,19 +964,6 @@ GenerateNotifier::GenerateNotifier(u32 notify_on, } -void GenerateNotifier::setNotifyOn(u32 notify_on) -{ - m_notify_on = notify_on; -} - - -void GenerateNotifier::setNotifyOnDecoIds( - const std::set<u32> *notify_on_deco_ids) -{ - m_notify_on_deco_ids = notify_on_deco_ids; -} - - bool GenerateNotifier::addEvent(GenNotifyType type, v3s16 pos, u32 id) { if (!(m_notify_on & (1 << type))) diff --git a/src/mapgen/mapgen.h b/src/mapgen/mapgen.h index 0f2977c4c..1487731e2 100644 --- a/src/mapgen/mapgen.h +++ b/src/mapgen/mapgen.h @@ -88,19 +88,17 @@ struct GenNotifyEvent { class GenerateNotifier { public: + // Use only for temporary Mapgen objects with no map generation! GenerateNotifier() = default; GenerateNotifier(u32 notify_on, const std::set<u32> *notify_on_deco_ids); - void setNotifyOn(u32 notify_on); - void setNotifyOnDecoIds(const std::set<u32> *notify_on_deco_ids); - bool addEvent(GenNotifyType type, v3s16 pos, u32 id=0); void getEvents(std::map<std::string, std::vector<v3s16> > &event_map); void clearEvents(); private: u32 m_notify_on = 0; - const std::set<u32> *m_notify_on_deco_ids; + const std::set<u32> *m_notify_on_deco_ids = nullptr; std::list<GenNotifyEvent> m_notify_events; }; @@ -186,7 +184,6 @@ public: static u32 getBlockSeed(v3s16 p, s32 seed); static u32 getBlockSeed2(v3s16 p, s32 seed); - s16 findGroundLevelFull(v2s16 p2d); s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax); s16 findLiquidSurface(v2s16 p2d, s16 ymin, s16 ymax); void updateHeightmap(v3s16 nmin, v3s16 nmax); diff --git a/src/mapgen/mapgen_v6.cpp b/src/mapgen/mapgen_v6.cpp index 8bea5eb69..90a52e031 100644 --- a/src/mapgen/mapgen_v6.cpp +++ b/src/mapgen/mapgen_v6.cpp @@ -341,12 +341,6 @@ float MapgenV6::baseTerrainLevelFromMap(int index) } -s16 MapgenV6::find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision) -{ - return baseTerrainLevelFromNoise(p2d) + MGV6_AVERAGE_MUD_AMOUNT; -} - - int MapgenV6::getGroundLevelAtPoint(v2s16 p) { return baseTerrainLevelFromNoise(p) + MGV6_AVERAGE_MUD_AMOUNT; diff --git a/src/mapgen/mapgen_v6.h b/src/mapgen/mapgen_v6.h index ff565edec..a6e6da8c6 100644 --- a/src/mapgen/mapgen_v6.h +++ b/src/mapgen/mapgen_v6.h @@ -150,7 +150,6 @@ public: s16 find_stone_level(v2s16 p2d); bool block_is_underground(u64 seed, v3s16 blockpos); - s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision); float getHumidity(v2s16 p); float getTreeAmount(v2s16 p); diff --git a/src/mapgen/treegen.cpp b/src/mapgen/treegen.cpp index e7e30c880..e633d800a 100644 --- a/src/mapgen/treegen.cpp +++ b/src/mapgen/treegen.cpp @@ -527,19 +527,6 @@ treegen::error make_ltree(MMVManip &vmanip, v3s16 p0, } -void tree_node_placement(MMVManip &vmanip, v3f p0, MapNode node) -{ - v3s16 p1 = v3s16(myround(p0.X), myround(p0.Y), myround(p0.Z)); - if (!vmanip.m_area.contains(p1)) - return; - u32 vi = vmanip.m_area.index(p1); - if (vmanip.m_data[vi].getContent() != CONTENT_AIR - && vmanip.m_data[vi].getContent() != CONTENT_IGNORE) - return; - vmanip.m_data[vmanip.m_area.index(p1)] = node; -} - - void tree_trunk_placement(MMVManip &vmanip, v3f p0, TreeDef &tree_definition) { v3s16 p1 = v3s16(myround(p0.X), myround(p0.Y), myround(p0.Z)); diff --git a/src/mapgen/treegen.h b/src/mapgen/treegen.h index 447baabb3..59a418824 100644 --- a/src/mapgen/treegen.h +++ b/src/mapgen/treegen.h @@ -76,8 +76,6 @@ namespace treegen { const NodeDefManager *ndef, const TreeDef &tree_definition); // L-System tree gen helper functions - void tree_node_placement(MMVManip &vmanip, v3f p0, - MapNode node); void tree_trunk_placement(MMVManip &vmanip, v3f p0, TreeDef &tree_definition); void tree_leaves_placement(MMVManip &vmanip, v3f p0, diff --git a/src/network/networkpacket.cpp b/src/network/networkpacket.cpp index 4d531b611..6d0abb12c 100644 --- a/src/network/networkpacket.cpp +++ b/src/network/networkpacket.cpp @@ -223,13 +223,6 @@ NetworkPacket& NetworkPacket::operator>>(char& dst) return *this; } -char NetworkPacket::getChar(u32 offset) -{ - checkReadOffset(offset, 1); - - return readU8(&m_data[offset]); -} - NetworkPacket& NetworkPacket::operator<<(char src) { checkDataSize(1); diff --git a/src/network/networkpacket.h b/src/network/networkpacket.h index fc8617651..e77bfb744 100644 --- a/src/network/networkpacket.h +++ b/src/network/networkpacket.h @@ -64,7 +64,6 @@ public: std::string readLongString(); - char getChar(u32 offset); NetworkPacket &operator>>(char &dst); NetworkPacket &operator<<(char src); diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp index eb6ab5331..c00401b58 100644 --- a/src/script/common/c_converter.cpp +++ b/src/script/common/c_converter.cpp @@ -679,48 +679,3 @@ size_t write_array_slice_float( return elem_index - 1; } - - -size_t write_array_slice_u16( - lua_State *L, - int table_index, - u16 *data, - v3u16 data_size, - v3u16 slice_offset, - v3u16 slice_size) -{ - v3u16 pmin, pmax(data_size); - - if (slice_offset.X > 0) { - slice_offset.X--; - pmin.X = slice_offset.X; - pmax.X = MYMIN(slice_offset.X + slice_size.X, data_size.X); - } - - if (slice_offset.Y > 0) { - slice_offset.Y--; - pmin.Y = slice_offset.Y; - pmax.Y = MYMIN(slice_offset.Y + slice_size.Y, data_size.Y); - } - - if (slice_offset.Z > 0) { - slice_offset.Z--; - pmin.Z = slice_offset.Z; - pmax.Z = MYMIN(slice_offset.Z + slice_size.Z, data_size.Z); - } - - const u32 ystride = data_size.X; - const u32 zstride = data_size.X * data_size.Y; - - u32 elem_index = 1; - for (u32 z = pmin.Z; z != pmax.Z; z++) - for (u32 y = pmin.Y; y != pmax.Y; y++) - for (u32 x = pmin.X; x != pmax.X; x++) { - u32 i = z * zstride + y * ystride + x; - lua_pushinteger(L, data[i]); - lua_rawseti(L, table_index, elem_index); - elem_index++; - } - - return elem_index - 1; -} diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h index a4a7079fd..6ad6f3212 100644 --- a/src/script/common/c_converter.h +++ b/src/script/common/c_converter.h @@ -136,5 +136,3 @@ void warn_if_field_exists(lua_State *L, int table, size_t write_array_slice_float(lua_State *L, int table_index, float *data, v3u16 data_size, v3u16 slice_offset, v3u16 slice_size); -size_t write_array_slice_u16(lua_State *L, int table_index, u16 *data, - v3u16 data_size, v3u16 slice_offset, v3u16 slice_size); diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index e49ec4052..0aa2760e9 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "porting.h" #include "filesys.h" #include "convert_json.h" -#include "content/packages.h" #include "content/content.h" #include "content/subgames.h" #include "serverlist.h" diff --git a/src/unittest/test_map_settings_manager.cpp b/src/unittest/test_map_settings_manager.cpp index 0a5c971b9..3d642a9b4 100644 --- a/src/unittest/test_map_settings_manager.cpp +++ b/src/unittest/test_map_settings_manager.cpp @@ -65,31 +65,6 @@ void check_noise_params(const NoiseParams *np1, const NoiseParams *np2) } -std::string read_file_to_string(const std::string &filepath) -{ - std::string buf; - FILE *f = fopen(filepath.c_str(), "rb"); - if (!f) - return ""; - - fseek(f, 0, SEEK_END); - - long filesize = ftell(f); - if (filesize == -1) { - fclose(f); - return ""; - } - rewind(f); - - buf.resize(filesize); - - UASSERTEQ(size_t, fread(&buf[0], 1, filesize, f), 1); - - fclose(f); - return buf; -} - - void TestMapSettingsManager::makeUserConfig(Settings *conf) { conf->set("mg_name", "v7"); @@ -199,7 +174,8 @@ void TestMapSettingsManager::testMapSettingsManager() }; SHA1 ctx; - std::string metafile_contents = read_file_to_string(test_mapmeta_path); + std::string metafile_contents; + UASSERT(fs::ReadFile(test_mapmeta_path, metafile_contents)); ctx.addBytes(&metafile_contents[0], metafile_contents.size()); unsigned char *sha1_result = ctx.getDigest(); int resultdiff = memcmp(sha1_result, expected_contents_hash, 20); |