forked from Mirrorlandia_minetest/minetest
Remove unused functions reported by cppcheck (#10463)
Run unused functions reported by cppcheck This change removes a few (but not all) unused functions. Some unused helper functions were not removed due to their complexity and potential of future use.
This commit is contained in:
parent
81c66d6efb
commit
f46509d5e2
15
src/chat.cpp
15
src/chat.cpp
@ -123,16 +123,16 @@ void ChatBuffer::deleteByAge(f32 maxAge)
|
|||||||
deleteOldest(count);
|
deleteOldest(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 ChatBuffer::getColumns() const
|
|
||||||
{
|
|
||||||
return m_cols;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 ChatBuffer::getRows() const
|
u32 ChatBuffer::getRows() const
|
||||||
{
|
{
|
||||||
return m_rows;
|
return m_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatBuffer::scrollTop()
|
||||||
|
{
|
||||||
|
m_scroll = getTopScrollPos();
|
||||||
|
}
|
||||||
|
|
||||||
void ChatBuffer::reformat(u32 cols, u32 rows)
|
void ChatBuffer::reformat(u32 cols, u32 rows)
|
||||||
{
|
{
|
||||||
if (cols == 0 || rows == 0)
|
if (cols == 0 || rows == 0)
|
||||||
@ -220,11 +220,6 @@ void ChatBuffer::scrollBottom()
|
|||||||
m_scroll = getBottomScrollPos();
|
m_scroll = getBottomScrollPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatBuffer::scrollTop()
|
|
||||||
{
|
|
||||||
m_scroll = getTopScrollPos();
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 ChatBuffer::formatChatLine(const ChatLine& line, u32 cols,
|
u32 ChatBuffer::formatChatLine(const ChatLine& line, u32 cols,
|
||||||
std::vector<ChatFormattedLine>& destination) const
|
std::vector<ChatFormattedLine>& destination) const
|
||||||
{
|
{
|
||||||
|
@ -94,8 +94,6 @@ public:
|
|||||||
// Delete lines older than maxAge.
|
// Delete lines older than maxAge.
|
||||||
void deleteByAge(f32 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.
|
// Get number of rows, 0 if reformat has not been called yet.
|
||||||
u32 getRows() const;
|
u32 getRows() const;
|
||||||
// Update console size and reformat all formatted lines.
|
// Update console size and reformat all formatted lines.
|
||||||
|
@ -1665,11 +1665,6 @@ ClientEvent *Client::getClientEvent()
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::connectedToServer()
|
|
||||||
{
|
|
||||||
return m_con->Connected();
|
|
||||||
}
|
|
||||||
|
|
||||||
const Address Client::getServerAddress()
|
const Address Client::getServerAddress()
|
||||||
{
|
{
|
||||||
return m_con->GetPeerAddress(PEER_ID_SERVER);
|
return m_con->GetPeerAddress(PEER_ID_SERVER);
|
||||||
|
@ -338,7 +338,6 @@ public:
|
|||||||
u16 getProtoVersion()
|
u16 getProtoVersion()
|
||||||
{ return m_proto_ver; }
|
{ return m_proto_ver; }
|
||||||
|
|
||||||
bool connectedToServer();
|
|
||||||
void confirmRegistration();
|
void confirmRegistration();
|
||||||
bool m_is_registration_confirmation_state = false;
|
bool m_is_registration_confirmation_state = false;
|
||||||
bool m_simple_singleplayer_mode;
|
bool m_simple_singleplayer_mode;
|
||||||
|
@ -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)
|
u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
|
||||||
{
|
{
|
||||||
// Register object. If failed return zero id
|
// Register object. If failed return zero id
|
||||||
|
@ -36,7 +36,7 @@ ClientMap::ClientMap(
|
|||||||
MapDrawControl &control,
|
MapDrawControl &control,
|
||||||
s32 id
|
s32 id
|
||||||
):
|
):
|
||||||
Map(dout_client, client),
|
Map(client),
|
||||||
scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(),
|
scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(),
|
||||||
RenderingEngine::get_scene_manager(), id),
|
RenderingEngine::get_scene_manager(), id),
|
||||||
m_client(client),
|
m_client(client),
|
||||||
|
@ -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)
|
void MeshMakeData::setCrack(int crack_level, v3s16 crack_pos)
|
||||||
{
|
{
|
||||||
if (crack_level >= 0)
|
if (crack_level >= 0)
|
||||||
|
@ -62,11 +62,6 @@ struct MeshMakeData
|
|||||||
*/
|
*/
|
||||||
void fill(MapBlock *block);
|
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
|
Set the (node) position of a crack
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
set(content_SRCS
|
set(content_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/content.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/content.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/packages.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mods.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/mods.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/subgames.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/subgames.cpp
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
|
@ -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
|
|
@ -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
|
|
@ -136,11 +136,6 @@ void GUIChatConsole::closeConsoleAtOnce()
|
|||||||
recalculateConsolePosition();
|
recalculateConsolePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 GUIChatConsole::getDesiredHeight() const
|
|
||||||
{
|
|
||||||
return m_desired_height_fraction;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUIChatConsole::replaceAndAddToHistory(const std::wstring &line)
|
void GUIChatConsole::replaceAndAddToHistory(const std::wstring &line)
|
||||||
{
|
{
|
||||||
ChatPrompt& prompt = m_chat_backend->getPrompt();
|
ChatPrompt& prompt = m_chat_backend->getPrompt();
|
||||||
|
@ -55,10 +55,6 @@ public:
|
|||||||
// Set whether to close the console after the user presses enter.
|
// Set whether to close the console after the user presses enter.
|
||||||
void setCloseOnEnter(bool close) { m_close_on_enter = close; }
|
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)
|
// Replace actual line when adding the actual to the history (if there is any)
|
||||||
void replaceAndAddToHistory(const std::wstring &line);
|
void replaceAndAddToHistory(const std::wstring &line);
|
||||||
|
|
||||||
|
11
src/log.cpp
11
src/log.cpp
@ -97,16 +97,7 @@ LogBuffer verbose_buf(g_logger, LL_VERBOSE);
|
|||||||
std::ostream *dout_con_ptr = &null_stream;
|
std::ostream *dout_con_ptr = &null_stream;
|
||||||
std::ostream *derr_con_ptr = &verbosestream;
|
std::ostream *derr_con_ptr = &verbosestream;
|
||||||
|
|
||||||
// Server
|
// Common streams
|
||||||
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
|
|
||||||
|
|
||||||
std::ostream rawstream(&raw_buf);
|
std::ostream rawstream(&raw_buf);
|
||||||
std::ostream dstream(&none_buf);
|
std::ostream dstream(&none_buf);
|
||||||
std::ostream errorstream(&error_buf);
|
std::ostream errorstream(&error_buf);
|
||||||
|
10
src/log.h
10
src/log.h
@ -192,14 +192,8 @@ extern std::ostream null_stream;
|
|||||||
|
|
||||||
extern std::ostream *dout_con_ptr;
|
extern std::ostream *dout_con_ptr;
|
||||||
extern std::ostream *derr_con_ptr;
|
extern std::ostream *derr_con_ptr;
|
||||||
extern std::ostream *dout_server_ptr;
|
|
||||||
extern std::ostream *derr_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;
|
extern Logger g_logger;
|
||||||
|
|
||||||
// Writes directly to all LL_NONE log outputs for g_logger with no prefix.
|
// 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 dout_con (*dout_con_ptr)
|
||||||
#define derr_con (*derr_con_ptr)
|
#define derr_con (*derr_con_ptr)
|
||||||
#define dout_server (*dout_server_ptr)
|
|
||||||
|
|
||||||
#ifndef SERVER
|
|
||||||
#define dout_client (*dout_client_ptr)
|
|
||||||
#endif
|
|
||||||
|
63
src/map.cpp
63
src/map.cpp
@ -62,8 +62,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
Map
|
Map
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Map::Map(std::ostream &dout, IGameDef *gamedef):
|
Map::Map(IGameDef *gamedef):
|
||||||
m_dout(dout),
|
|
||||||
m_gamedef(gamedef),
|
m_gamedef(gamedef),
|
||||||
m_nodedef(gamedef->ndef())
|
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,
|
ServerMap::ServerMap(const std::string &savedir, IGameDef *gamedef,
|
||||||
EmergeManager *emerge, MetricsBackend *mb):
|
EmergeManager *emerge, MetricsBackend *mb):
|
||||||
Map(dout_server, gamedef),
|
Map(gamedef),
|
||||||
settings_mgr(g_settings, savedir + DIR_DELIM + "map_meta.txt"),
|
settings_mgr(g_settings, savedir + DIR_DELIM + "map_meta.txt"),
|
||||||
m_emerge(emerge)
|
m_emerge(emerge)
|
||||||
{
|
{
|
||||||
@ -1327,11 +1326,6 @@ u64 ServerMap::getSeed()
|
|||||||
return getMapgenParams()->seed;
|
return getMapgenParams()->seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
s16 ServerMap::getWaterLevel()
|
|
||||||
{
|
|
||||||
return getMapgenParams()->water_level;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ServerMap::blockpos_over_mapgen_limit(v3s16 p)
|
bool ServerMap::blockpos_over_mapgen_limit(v3s16 p)
|
||||||
{
|
{
|
||||||
const s16 mapgen_limit_bp = rangelim(
|
const s16 mapgen_limit_bp = rangelim(
|
||||||
@ -1732,59 +1726,6 @@ void ServerMap::updateVManip(v3s16 pos)
|
|||||||
vm->m_is_dirty = true;
|
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)
|
void ServerMap::save(ModifiedState save_level)
|
||||||
{
|
{
|
||||||
if (!m_map_saving_enabled) {
|
if (!m_map_saving_enabled) {
|
||||||
|
21
src/map.h
21
src/map.h
@ -123,7 +123,7 @@ class Map /*: public NodeContainer*/
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Map(std::ostream &dout, IGameDef *gamedef);
|
Map(IGameDef *gamedef);
|
||||||
virtual ~Map();
|
virtual ~Map();
|
||||||
DISABLE_CLASS_COPY(Map);
|
DISABLE_CLASS_COPY(Map);
|
||||||
|
|
||||||
@ -149,8 +149,6 @@ public:
|
|||||||
MapSector * getSectorNoGenerateNoLock(v2s16 p2d);
|
MapSector * getSectorNoGenerateNoLock(v2s16 p2d);
|
||||||
// Same as the above (there exists no lock anymore)
|
// Same as the above (there exists no lock anymore)
|
||||||
MapSector * getSectorNoGenerate(v2s16 p2d);
|
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
|
This is overloaded by ClientMap and ServerMap to allow
|
||||||
@ -268,11 +266,6 @@ public:
|
|||||||
void setNodeTimer(const NodeTimer &t);
|
void setNodeTimer(const NodeTimer &t);
|
||||||
void removeNodeTimer(v3s16 p);
|
void removeNodeTimer(v3s16 p);
|
||||||
|
|
||||||
/*
|
|
||||||
Misc.
|
|
||||||
*/
|
|
||||||
std::map<v2s16, MapSector*> *getSectorsPtr(){return &m_sectors;}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Variables
|
Variables
|
||||||
*/
|
*/
|
||||||
@ -283,8 +276,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
friend class LuaVoxelManip;
|
friend class LuaVoxelManip;
|
||||||
|
|
||||||
std::ostream &m_dout; // A bit deprecated, could be removed
|
|
||||||
|
|
||||||
IGameDef *m_gamedef;
|
IGameDef *m_gamedef;
|
||||||
|
|
||||||
std::set<MapEventReceiver*> m_event_receivers;
|
std::set<MapEventReceiver*> m_event_receivers;
|
||||||
@ -374,15 +365,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
MapBlock *getBlockOrEmerge(v3s16 p3d);
|
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
|
Database functions
|
||||||
*/
|
*/
|
||||||
@ -414,7 +396,6 @@ public:
|
|||||||
bool isSavingEnabled(){ return m_map_saving_enabled; }
|
bool isSavingEnabled(){ return m_map_saving_enabled; }
|
||||||
|
|
||||||
u64 getSeed();
|
u64 getSeed();
|
||||||
s16 getWaterLevel();
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Fixes lighting in one map block.
|
* Fixes lighting in one map block.
|
||||||
|
@ -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
|
// Returns -MAX_MAP_GENERATION_LIMIT if not found
|
||||||
s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax)
|
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)
|
bool GenerateNotifier::addEvent(GenNotifyType type, v3s16 pos, u32 id)
|
||||||
{
|
{
|
||||||
if (!(m_notify_on & (1 << type)))
|
if (!(m_notify_on & (1 << type)))
|
||||||
|
@ -88,19 +88,17 @@ struct GenNotifyEvent {
|
|||||||
|
|
||||||
class GenerateNotifier {
|
class GenerateNotifier {
|
||||||
public:
|
public:
|
||||||
|
// Use only for temporary Mapgen objects with no map generation!
|
||||||
GenerateNotifier() = default;
|
GenerateNotifier() = default;
|
||||||
GenerateNotifier(u32 notify_on, const std::set<u32> *notify_on_deco_ids);
|
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);
|
bool addEvent(GenNotifyType type, v3s16 pos, u32 id=0);
|
||||||
void getEvents(std::map<std::string, std::vector<v3s16> > &event_map);
|
void getEvents(std::map<std::string, std::vector<v3s16> > &event_map);
|
||||||
void clearEvents();
|
void clearEvents();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u32 m_notify_on = 0;
|
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;
|
std::list<GenNotifyEvent> m_notify_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -186,7 +184,6 @@ public:
|
|||||||
|
|
||||||
static u32 getBlockSeed(v3s16 p, s32 seed);
|
static u32 getBlockSeed(v3s16 p, s32 seed);
|
||||||
static u32 getBlockSeed2(v3s16 p, s32 seed);
|
static u32 getBlockSeed2(v3s16 p, s32 seed);
|
||||||
s16 findGroundLevelFull(v2s16 p2d);
|
|
||||||
s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
|
s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
|
||||||
s16 findLiquidSurface(v2s16 p2d, s16 ymin, s16 ymax);
|
s16 findLiquidSurface(v2s16 p2d, s16 ymin, s16 ymax);
|
||||||
void updateHeightmap(v3s16 nmin, v3s16 nmax);
|
void updateHeightmap(v3s16 nmin, v3s16 nmax);
|
||||||
|
@ -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)
|
int MapgenV6::getGroundLevelAtPoint(v2s16 p)
|
||||||
{
|
{
|
||||||
return baseTerrainLevelFromNoise(p) + MGV6_AVERAGE_MUD_AMOUNT;
|
return baseTerrainLevelFromNoise(p) + MGV6_AVERAGE_MUD_AMOUNT;
|
||||||
|
@ -150,7 +150,6 @@ public:
|
|||||||
|
|
||||||
s16 find_stone_level(v2s16 p2d);
|
s16 find_stone_level(v2s16 p2d);
|
||||||
bool block_is_underground(u64 seed, v3s16 blockpos);
|
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 getHumidity(v2s16 p);
|
||||||
float getTreeAmount(v2s16 p);
|
float getTreeAmount(v2s16 p);
|
||||||
|
@ -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)
|
void tree_trunk_placement(MMVManip &vmanip, v3f p0, TreeDef &tree_definition)
|
||||||
{
|
{
|
||||||
v3s16 p1 = v3s16(myround(p0.X), myround(p0.Y), myround(p0.Z));
|
v3s16 p1 = v3s16(myround(p0.X), myround(p0.Y), myround(p0.Z));
|
||||||
|
@ -76,8 +76,6 @@ namespace treegen {
|
|||||||
const NodeDefManager *ndef, const TreeDef &tree_definition);
|
const NodeDefManager *ndef, const TreeDef &tree_definition);
|
||||||
|
|
||||||
// L-System tree gen helper functions
|
// L-System tree gen helper functions
|
||||||
void tree_node_placement(MMVManip &vmanip, v3f p0,
|
|
||||||
MapNode node);
|
|
||||||
void tree_trunk_placement(MMVManip &vmanip, v3f p0,
|
void tree_trunk_placement(MMVManip &vmanip, v3f p0,
|
||||||
TreeDef &tree_definition);
|
TreeDef &tree_definition);
|
||||||
void tree_leaves_placement(MMVManip &vmanip, v3f p0,
|
void tree_leaves_placement(MMVManip &vmanip, v3f p0,
|
||||||
|
@ -223,13 +223,6 @@ NetworkPacket& NetworkPacket::operator>>(char& dst)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
char NetworkPacket::getChar(u32 offset)
|
|
||||||
{
|
|
||||||
checkReadOffset(offset, 1);
|
|
||||||
|
|
||||||
return readU8(&m_data[offset]);
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkPacket& NetworkPacket::operator<<(char src)
|
NetworkPacket& NetworkPacket::operator<<(char src)
|
||||||
{
|
{
|
||||||
checkDataSize(1);
|
checkDataSize(1);
|
||||||
|
@ -64,7 +64,6 @@ public:
|
|||||||
|
|
||||||
std::string readLongString();
|
std::string readLongString();
|
||||||
|
|
||||||
char getChar(u32 offset);
|
|
||||||
NetworkPacket &operator>>(char &dst);
|
NetworkPacket &operator>>(char &dst);
|
||||||
NetworkPacket &operator<<(char src);
|
NetworkPacket &operator<<(char src);
|
||||||
|
|
||||||
|
@ -679,48 +679,3 @@ size_t write_array_slice_float(
|
|||||||
|
|
||||||
return elem_index - 1;
|
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;
|
|
||||||
}
|
|
||||||
|
@ -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,
|
size_t write_array_slice_float(lua_State *L, int table_index, float *data,
|
||||||
v3u16 data_size, v3u16 slice_offset, v3u16 slice_size);
|
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);
|
|
||||||
|
@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "porting.h"
|
#include "porting.h"
|
||||||
#include "filesys.h"
|
#include "filesys.h"
|
||||||
#include "convert_json.h"
|
#include "convert_json.h"
|
||||||
#include "content/packages.h"
|
|
||||||
#include "content/content.h"
|
#include "content/content.h"
|
||||||
#include "content/subgames.h"
|
#include "content/subgames.h"
|
||||||
#include "serverlist.h"
|
#include "serverlist.h"
|
||||||
|
@ -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)
|
void TestMapSettingsManager::makeUserConfig(Settings *conf)
|
||||||
{
|
{
|
||||||
conf->set("mg_name", "v7");
|
conf->set("mg_name", "v7");
|
||||||
@ -199,7 +174,8 @@ void TestMapSettingsManager::testMapSettingsManager()
|
|||||||
};
|
};
|
||||||
|
|
||||||
SHA1 ctx;
|
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());
|
ctx.addBytes(&metafile_contents[0], metafile_contents.size());
|
||||||
unsigned char *sha1_result = ctx.getDigest();
|
unsigned char *sha1_result = ctx.getDigest();
|
||||||
int resultdiff = memcmp(sha1_result, expected_contents_hash, 20);
|
int resultdiff = memcmp(sha1_result, expected_contents_hash, 20);
|
||||||
|
Loading…
Reference in New Issue
Block a user