Cpp11 initializers 2 (#5999)

* C++11 patchset 10: continue cleanup on constructors

* Drop obsolete bool MainMenuData::enable_public (setting is called with cURL in server loop)

* More classes cleanup

* More classes cleanup + change NULL tests to boolean tests
This commit is contained in:
Loïc Blot 2017-06-17 19:11:28 +02:00 committed by GitHub
parent 76be103a91
commit 8f7785771b
59 changed files with 326 additions and 639 deletions

View File

@ -221,7 +221,7 @@ Client::~Client()
scene::IAnimatedMesh *mesh = scene::IAnimatedMesh *mesh =
m_device->getSceneManager()->getMeshCache()->getMeshByIndex(0); m_device->getSceneManager()->getMeshCache()->getMeshByIndex(0);
if (mesh != NULL) if (mesh)
m_device->getSceneManager()->getMeshCache()->removeMesh(mesh); m_device->getSceneManager()->getMeshCache()->removeMesh(mesh);
} }
@ -383,7 +383,7 @@ void Client::step(float dtime)
*/ */
// Control local player (0ms) // Control local player (0ms)
LocalPlayer *player = m_env.getLocalPlayer(); LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL); assert(player);
player->applyControl(dtime); player->applyControl(dtime);
// Step environment // Step environment
@ -459,7 +459,7 @@ void Client::step(float dtime)
if (block) { if (block) {
// Delete the old mesh // Delete the old mesh
delete block->mesh; delete block->mesh;
block->mesh = NULL; block->mesh = nullptr;
if (r.mesh) { if (r.mesh) {
minimap_mapblock = r.mesh->moveMinimapMapblock(); minimap_mapblock = r.mesh->moveMinimapMapblock();
@ -1370,7 +1370,7 @@ void Client::addNode(v3s16 p, MapNode n, bool remove_metadata)
void Client::setPlayerControl(PlayerControl &control) void Client::setPlayerControl(PlayerControl &control)
{ {
LocalPlayer *player = m_env.getLocalPlayer(); LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL); assert(player);
player->control = control; player->control = control;
} }
@ -1394,7 +1394,7 @@ bool Client::getLocalInventoryUpdated()
void Client::getLocalInventory(Inventory &dst) void Client::getLocalInventory(Inventory &dst)
{ {
LocalPlayer *player = m_env.getLocalPlayer(); LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL); assert(player);
dst = player->inventory; dst = player->inventory;
} }
@ -1407,7 +1407,7 @@ Inventory* Client::getInventory(const InventoryLocation &loc)
case InventoryLocation::CURRENT_PLAYER: case InventoryLocation::CURRENT_PLAYER:
{ {
LocalPlayer *player = m_env.getLocalPlayer(); LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL); assert(player);
return &player->inventory; return &player->inventory;
} }
break; break;
@ -1496,7 +1496,7 @@ void Client::setCrack(int level, v3s16 pos)
u16 Client::getHP() u16 Client::getHP()
{ {
LocalPlayer *player = m_env.getLocalPlayer(); LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL); assert(player);
return player->hp; return player->hp;
} }
@ -1529,7 +1529,7 @@ void Client::typeChatMessage(const std::wstring &message)
// compatibility code // compatibility code
if (m_proto_ver < 29) { if (m_proto_ver < 29) {
LocalPlayer *player = m_env.getLocalPlayer(); LocalPlayer *player = m_env.getLocalPlayer();
assert(player != NULL); assert(player);
std::wstring name = narrow_to_wide(player->getName()); std::wstring name = narrow_to_wide(player->getName());
pushToChatQueue((std::wstring)L"<" + name + L"> " + message); pushToChatQueue((std::wstring)L"<" + name + L"> " + message);
} }

View File

@ -457,7 +457,7 @@ public:
bool nodedefReceived() bool nodedefReceived()
{ return m_nodedef_received; } { return m_nodedef_received; }
bool mediaReceived() bool mediaReceived()
{ return m_media_downloader == NULL; } { return !m_media_downloader; }
u8 getProtoVersion() u8 getProtoVersion()
{ return m_proto_ver; } { return m_proto_ver; }

View File

@ -357,8 +357,6 @@ bool ClientLauncher::launch_game(std::string &error_message,
if (cmd_args.exists("password")) if (cmd_args.exists("password"))
menudata.password = cmd_args.get("password"); menudata.password = cmd_args.get("password");
menudata.enable_public = g_settings->getBool("server_announce");
// If a world was commanded, append and select it // If a world was commanded, append and select it
if (game_params.world_path != "") { if (game_params.world_path != "") {
worldspec.gameid = getWorldGameId(game_params.world_path, true); worldspec.gameid = getWorldGameId(game_params.world_path, true);

View File

@ -79,11 +79,11 @@ void RemoteClient::GetNextBlocks (
RemotePlayer *player = env->getPlayer(peer_id); RemotePlayer *player = env->getPlayer(peer_id);
// This can happen sometimes; clients and players are not in perfect sync. // This can happen sometimes; clients and players are not in perfect sync.
if (player == NULL) if (!player)
return; return;
PlayerSAO *sao = player->getPlayerSAO(); PlayerSAO *sao = player->getPlayerSAO();
if (sao == NULL) if (!sao)
return; return;
// Won't send anything if already sending // Won't send anything if already sending
@ -275,8 +275,7 @@ void RemoteClient::GetNextBlocks (
bool surely_not_found_on_disk = false; bool surely_not_found_on_disk = false;
bool block_is_invalid = false; bool block_is_invalid = false;
if(block != NULL) if (block) {
{
// Reset usage timer, this block will be of use in the future. // Reset usage timer, this block will be of use in the future.
block->resetUsageTimer(); block->resetUsageTimer();
@ -645,7 +644,7 @@ void ClientInterface::step(float dtime)
void ClientInterface::UpdatePlayerList() void ClientInterface::UpdatePlayerList()
{ {
if (m_env != NULL) { if (m_env) {
std::vector<u16> clients = getClientIDs(); std::vector<u16> clients = getClientIDs();
m_clients_names.clear(); m_clients_names.clear();
@ -664,7 +663,7 @@ void ClientInterface::UpdatePlayerList()
{ {
MutexAutoLock clientslock(m_clients_mutex); MutexAutoLock clientslock(m_clients_mutex);
RemoteClient* client = lockedGetClientNoEx(*i); RemoteClient* client = lockedGetClientNoEx(*i);
if(client != NULL) if (client)
client->PrintInfo(infostream); client->PrintInfo(infostream);
} }

View File

@ -212,11 +212,11 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
if not seen on display if not seen on display
*/ */
if (block->mesh != NULL) if (block->mesh)
block->mesh->updateCameraOffset(m_camera_offset); block->mesh->updateCameraOffset(m_camera_offset);
float range = 100000 * BS; float range = 100000 * BS;
if (m_control.range_all == false) if (!m_control.range_all)
range = m_control.wanted_range * BS; range = m_control.wanted_range * BS;
float d = 0.0; float d = 0.0;
@ -229,7 +229,7 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
/* /*
Ignore if mesh doesn't exist Ignore if mesh doesn't exist
*/ */
if (block->mesh == NULL) { if (!block->mesh) {
blocks_in_range_without_mesh++; blocks_in_range_without_mesh++;
continue; continue;
} }
@ -398,7 +398,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
MapBlock *block = i->second; MapBlock *block = i->second;
// If the mesh of the block happened to get deleted, ignore it // If the mesh of the block happened to get deleted, ignore it
if (block->mesh == NULL) if (!block->mesh)
continue; continue;
float d = 0.0; float d = 0.0;

View File

@ -202,7 +202,7 @@ void TestCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
void TestCAO::removeFromScene(bool permanent) void TestCAO::removeFromScene(bool permanent)
{ {
if(m_node == NULL) if (!m_node)
return; return;
m_node->remove(); m_node->remove();
@ -220,7 +220,7 @@ v3s16 TestCAO::getLightPosition()
void TestCAO::updateNodePos() void TestCAO::updateNodePos()
{ {
if(m_node == NULL) if (!m_node)
return; return;
m_node->setPosition(m_position); m_node->setPosition(m_position);
@ -377,16 +377,16 @@ void ItemCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
void ItemCAO::removeFromScene(bool permanent) void ItemCAO::removeFromScene(bool permanent)
{ {
if(m_node == NULL) if (!m_node)
return; return;
m_node->remove(); m_node->remove();
m_node = NULL; m_node = nullptr;
} }
void ItemCAO::updateLight(u8 light_at_pos) void ItemCAO::updateLight(u8 light_at_pos)
{ {
if(m_node == NULL) if (!m_node)
return; return;
u8 li = decode_light(light_at_pos); u8 li = decode_light(light_at_pos);
@ -401,7 +401,7 @@ v3s16 ItemCAO::getLightPosition()
void ItemCAO::updateNodePos() void ItemCAO::updateNodePos()
{ {
if(m_node == NULL) if (!m_node)
return; return;
m_node->setPosition(m_position); m_node->setPosition(m_position);
@ -428,7 +428,7 @@ void ItemCAO::updateInfoText()
void ItemCAO::updateTexture() void ItemCAO::updateTexture()
{ {
if(m_node == NULL) if (!m_node)
return; return;
// Create an inventory item to see what is its image // Create an inventory item to see what is its image
@ -1155,13 +1155,13 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
updateTextures(m_previous_texture_modifier); updateTextures(m_previous_texture_modifier);
} }
} }
if(getParent() == NULL && fabs(m_prop.automatic_rotate) > 0.001) if(!getParent() && fabs(m_prop.automatic_rotate) > 0.001)
{ {
m_yaw += dtime * m_prop.automatic_rotate * 180 / M_PI; m_yaw += dtime * m_prop.automatic_rotate * 180 / M_PI;
updateNodePos(); updateNodePos();
} }
if (getParent() == NULL && m_prop.automatic_face_movement_dir && if (!getParent() && m_prop.automatic_face_movement_dir &&
(fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001)) (fabs(m_velocity.Z) > 0.001 || fabs(m_velocity.X) > 0.001))
{ {
float optimal_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI float optimal_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI
@ -1408,7 +1408,7 @@ void GenericCAO::updateTextures(std::string mod)
void GenericCAO::updateAnimation() void GenericCAO::updateAnimation()
{ {
if(m_animated_meshnode == NULL) if (!m_animated_meshnode)
return; return;
if (m_animated_meshnode->getStartFrame() != m_animation_range.X || if (m_animated_meshnode->getStartFrame() != m_animation_range.X ||
@ -1426,7 +1426,7 @@ void GenericCAO::updateAnimation()
void GenericCAO::updateBonePosition() void GenericCAO::updateBonePosition()
{ {
if(m_bone_position.empty() || m_animated_meshnode == NULL) if(m_bone_position.empty() || !m_animated_meshnode)
return; return;
m_animated_meshnode->setJointMode(irr::scene::EJUOR_CONTROL); // To write positions to the mesh on render m_animated_meshnode->setJointMode(irr::scene::EJUOR_CONTROL); // To write positions to the mesh on render
@ -1447,7 +1447,7 @@ void GenericCAO::updateBonePosition()
void GenericCAO::updateAttachments() void GenericCAO::updateAttachments()
{ {
if (getParent() == NULL) { // Detach or don't attach if (!getParent()) { // Detach or don't attach
scene::ISceneNode *node = getSceneNode(); scene::ISceneNode *node = getSceneNode();
if (node) { if (node) {
v3f old_position = node->getAbsolutePosition(); v3f old_position = node->getAbsolutePosition();

View File

@ -28,9 +28,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Environment::Environment(IGameDef *gamedef): Environment::Environment(IGameDef *gamedef):
m_gamedef(gamedef),
m_time_of_day_speed(0.0f), m_time_of_day_speed(0.0f),
m_day_count(0) m_day_count(0),
m_gamedef(gamedef)
{ {
m_cache_enable_shaders = g_settings->getBool("enable_shaders"); m_cache_enable_shaders = g_settings->getBool("enable_shaders");
m_cache_active_block_mgmt_interval = g_settings->getFloat("active_block_mgmt_interval"); m_cache_active_block_mgmt_interval = g_settings->getFloat("active_block_mgmt_interval");

View File

@ -2643,7 +2643,7 @@ void Game::openInventory()
*/ */
LocalPlayer *player = client->getEnv().getLocalPlayer(); LocalPlayer *player = client->getEnv().getLocalPlayer();
if (player == NULL || player->getCAO() == NULL) if (!player || !player->getCAO())
return; return;
infostream << "the_game: " << "Launching inventory" << std::endl; infostream << "the_game: " << "Launching inventory" << std::endl;
@ -3402,7 +3402,7 @@ void Game::updateCamera(u32 busy_time, f32 dtime)
GenericCAO *playercao = player->getCAO(); GenericCAO *playercao = player->getCAO();
// If playercao not loaded, don't change camera // If playercao not loaded, don't change camera
if (playercao == NULL) if (!playercao)
return; return;
camera->toggleCameraMode(); camera->toggleCameraMode();

View File

@ -76,12 +76,9 @@ GUIChatConsole::GUIChatConsole(
m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono); m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono);
if (m_font == NULL) if (!m_font) {
{
errorstream << "GUIChatConsole: Unable to load mono font "; errorstream << "GUIChatConsole: Unable to load mono font ";
} } else {
else
{
core::dimension2d<u32> dim = m_font->getDimension(L"M"); core::dimension2d<u32> dim = m_font->getDimension(L"M");
m_fontsize = v2u32(dim.Width, dim.Height); m_fontsize = v2u32(dim.Width, dim.Height);
m_font->grab(); m_font->grab();
@ -353,7 +350,7 @@ void GUIChatConsole::drawText()
void GUIChatConsole::drawPrompt() void GUIChatConsole::drawPrompt()
{ {
if (m_font == NULL) if (!m_font)
return; return;
u32 row = m_chat_backend->getConsoleBuffer().getRows(); u32 row = m_chat_backend->getConsoleBuffer().getRows();

View File

@ -323,7 +323,7 @@ GUIEngine::~GUIEngine()
//clean up texture pointers //clean up texture pointers
for (unsigned int i = 0; i < TEX_LAYER_MAX; i++) { for (unsigned int i = 0; i < TEX_LAYER_MAX; i++) {
if (m_textures[i].texture != NULL) if (m_textures[i].texture)
driver->removeTexture(m_textures[i].texture); driver->removeTexture(m_textures[i].texture);
} }

View File

@ -2004,7 +2004,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
// Add tooltip // Add tooltip
{ {
assert(m_tooltip_element == NULL); assert(!m_tooltip_element);
// Note: parent != this so that the tooltip isn't clipped by the menu rectangle // Note: parent != this so that the tooltip isn't clipped by the menu rectangle
m_tooltip_element = addStaticText(Environment, L"",core::rect<s32>(0,0,110,18)); m_tooltip_element = addStaticText(Environment, L"",core::rect<s32>(0,0,110,18));
m_tooltip_element->enableOverrideColor(true); m_tooltip_element->enableOverrideColor(true);
@ -2157,7 +2157,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
m_tooltip_element->setOverrideFont(m_font); m_tooltip_element->setOverrideFont(m_font);
gui::IGUISkin* skin = Environment->getSkin(); gui::IGUISkin* skin = Environment->getSkin();
sanity_check(skin != NULL); sanity_check(skin);
gui::IGUIFont *old_font = skin->getFont(); gui::IGUIFont *old_font = skin->getFont();
skin->setFont(m_font); skin->setFont(m_font);

View File

@ -75,12 +75,9 @@ GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) : gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) :
GUIModalMenu(env, parent, id, menumgr) GUIModalMenu(env, parent, id, menumgr)
{ {
shift_down = false;
activeKey = -1;
this->key_used_text = NULL;
init_keys(); init_keys();
for(size_t i=0; i<key_settings.size(); i++) for (size_t i = 0; i < key_settings.size(); i++)
this->key_used.push_back(key_settings.at(i)->key); key_used.push_back(key_settings.at(i)->key);
} }
GUIKeyChangeMenu::~GUIKeyChangeMenu() GUIKeyChangeMenu::~GUIKeyChangeMenu()
@ -115,7 +112,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
{ {
removeChildren(); removeChildren();
v2s32 size(745, 430); v2s32 size(745, 430);
core::rect < s32 > rect(screensize.X / 2 - size.X / 2, core::rect < s32 > rect(screensize.X / 2 - size.X / 2,
screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2, screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2,
screensize.Y / 2 + size.Y / 2); screensize.Y / 2 + size.Y / 2);
@ -124,7 +121,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
recalculateAbsolutePosition(false); recalculateAbsolutePosition(false);
v2s32 topleft(0, 0); v2s32 topleft(0, 0);
{ {
core::rect < s32 > rect(0, 0, 600, 40); core::rect < s32 > rect(0, 0, 600, 40);
rect += topleft + v2s32(25, 3); rect += topleft + v2s32(25, 3);
@ -163,7 +160,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
offset += v2s32(0, 25); offset += v2s32(0, 25);
} }
} }
{ {
s32 option_x = offset.X; s32 option_x = offset.X;
s32 option_y = offset.Y + 5; s32 option_y = offset.Y + 5;
@ -209,7 +206,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON, Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON,
text); text);
delete[] text; delete[] text;
} }
} }
void GUIKeyChangeMenu::drawMenu() void GUIKeyChangeMenu::drawMenu()
@ -279,10 +276,10 @@ bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
{ {
if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0 if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0
&& event.KeyInput.PressedDown) { && event.KeyInput.PressedDown) {
bool prefer_character = shift_down; bool prefer_character = shift_down;
KeyPress kp(event.KeyInput, prefer_character); KeyPress kp(event.KeyInput, prefer_character);
bool shift_went_down = false; bool shift_went_down = false;
if(!shift_down && if(!shift_down &&
(event.KeyInput.Key == irr::KEY_SHIFT || (event.KeyInput.Key == irr::KEY_SHIFT ||

View File

@ -65,12 +65,11 @@ private:
void add_key(int id, const wchar_t *button_name, const std::string &setting_name); void add_key(int id, const wchar_t *button_name, const std::string &setting_name);
bool shift_down; bool shift_down = false;
s32 activeKey = -1;
s32 activeKey;
std::vector<KeyPress> key_used; std::vector<KeyPress> key_used;
gui::IGUIStaticText *key_used_text; gui::IGUIStaticText *key_used_text = nullptr;
std::vector<key_setting *> key_settings; std::vector<key_setting *> key_settings;
}; };

View File

@ -27,14 +27,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct MainMenuDataForScript { struct MainMenuDataForScript {
MainMenuDataForScript() : MainMenuDataForScript() {}
reconnect_requested(false)
{}
// Whether the server has requested a reconnect // Whether the server has requested a reconnect
bool reconnect_requested; bool reconnect_requested = false;
std::string errormessage = "";
std::string errormessage;
}; };
struct MainMenuData { struct MainMenuData {
@ -46,22 +43,16 @@ struct MainMenuData {
std::string name; std::string name;
std::string password; std::string password;
// Whether to reconnect // Whether to reconnect
bool do_reconnect; bool do_reconnect = false;
// Server options // Server options
bool enable_public; int selected_world = 0;
int selected_world; bool simple_singleplayer_mode = false;
bool simple_singleplayer_mode;
// Data to be passed to the script // Data to be passed to the script
MainMenuDataForScript script_data; MainMenuDataForScript script_data;
MainMenuData(): MainMenuData() {}
do_reconnect(false),
enable_public(false),
selected_world(0),
simple_singleplayer_mode(false)
{}
}; };
#endif #endif

View File

@ -41,10 +41,7 @@ GUIPasswordChange::GUIPasswordChange(gui::IGUIEnvironment* env,
Client* client Client* client
): ):
GUIModalMenu(env, parent, id, menumgr), GUIModalMenu(env, parent, id, menumgr),
m_client(client), m_client(client)
m_oldpass(L""),
m_newpass(L""),
m_newpass_confirm(L"")
{ {
} }

View File

@ -47,9 +47,9 @@ public:
private: private:
Client *m_client; Client *m_client;
std::wstring m_oldpass; std::wstring m_oldpass = L"";
std::wstring m_newpass; std::wstring m_newpass = L"";
std::wstring m_newpass_confirm; std::wstring m_newpass_confirm = L"";
}; };
#endif #endif

View File

@ -25,8 +25,6 @@ GUIFileSelectMenu::GUIFileSelectMenu(gui::IGUIEnvironment* env,
bool is_file_select) : bool is_file_select) :
GUIModalMenu(env, parent, id, menumgr), GUIModalMenu(env, parent, id, menumgr),
m_title(utf8_to_wide(title)), m_title(utf8_to_wide(title)),
m_accepted(false),
m_text_dst(NULL),
m_formname(formname), m_formname(formname),
m_file_select_dialog(is_file_select) m_file_select_dialog(is_file_select)
{ {

View File

@ -49,11 +49,11 @@ private:
void acceptInput(); void acceptInput();
std::wstring m_title; std::wstring m_title;
bool m_accepted; bool m_accepted = false;
gui::IGUIFileOpenDialog *m_fileOpenDialog; gui::IGUIFileOpenDialog *m_fileOpenDialog = nullptr;
TextDest *m_text_dst; TextDest *m_text_dst = nullptr;
std::string m_formname; std::string m_formname;
bool m_file_select_dialog; bool m_file_select_dialog;

View File

@ -47,22 +47,7 @@ GUITable::GUITable(gui::IGUIEnvironment *env,
ISimpleTextureSource *tsrc ISimpleTextureSource *tsrc
): ):
gui::IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, rectangle), gui::IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, rectangle),
m_tsrc(tsrc), m_tsrc(tsrc)
m_is_textlist(false),
m_has_tree_column(false),
m_selected(-1),
m_sel_column(0),
m_sel_doubleclick(false),
m_keynav_time(0),
m_keynav_buffer(L""),
m_border(true),
m_color(255, 255, 255, 255),
m_background(255, 0, 0, 0),
m_highlight(255, 70, 100, 50),
m_highlight_text(255, 255, 255, 255),
m_rowheight(1),
m_font(NULL),
m_scrollbar(NULL)
{ {
assert(tsrc != NULL); assert(tsrc != NULL);
@ -109,7 +94,7 @@ GUITable::~GUITable()
if (m_font) if (m_font)
m_font->drop(); m_font->drop();
m_scrollbar->remove(); m_scrollbar->remove();
} }

View File

@ -52,18 +52,11 @@ public:
*/ */
struct DynamicData struct DynamicData
{ {
s32 selected; s32 selected = 0;
s32 scrollpos; s32 scrollpos = 0;
s32 keynav_time; s32 keynav_time = 0;
core::stringw keynav_buffer; core::stringw keynav_buffer;
std::set<s32> opened_trees; std::set<s32> opened_trees;
DynamicData()
{
selected = 0;
scrollpos = 0;
keynav_time = 0;
}
}; };
/* /*
@ -187,27 +180,27 @@ protected:
std::vector<Row> m_rows; std::vector<Row> m_rows;
// Table content (only visible; indices into m_rows) // Table content (only visible; indices into m_rows)
std::vector<s32> m_visible_rows; std::vector<s32> m_visible_rows;
bool m_is_textlist; bool m_is_textlist = false;
bool m_has_tree_column; bool m_has_tree_column = false;
// Selection status // Selection status
s32 m_selected; // index of row (1...n), or 0 if none selected s32 m_selected = -1; // index of row (1...n), or 0 if none selected
s32 m_sel_column; s32 m_sel_column = 0;
bool m_sel_doubleclick; bool m_sel_doubleclick = false;
// Keyboard navigation stuff // Keyboard navigation stuff
u64 m_keynav_time; u64 m_keynav_time = 0;
core::stringw m_keynav_buffer; core::stringw m_keynav_buffer = L"";
// Drawing and geometry information // Drawing and geometry information
bool m_border; bool m_border = true;
video::SColor m_color; video::SColor m_color = video::SColor(255, 255, 255, 255);
video::SColor m_background; video::SColor m_background = video::SColor(255, 0, 0, 0);
video::SColor m_highlight; video::SColor m_highlight = video::SColor(255, 70, 100, 50);
video::SColor m_highlight_text; video::SColor m_highlight_text = video::SColor(255, 255, 255, 255);
s32 m_rowheight; s32 m_rowheight = 1;
gui::IGUIFont *m_font; gui::IGUIFont *m_font = nullptr;
gui::IGUIScrollBar *m_scrollbar; gui::IGUIScrollBar *m_scrollbar = nullptr;
// Allocated strings and images // Allocated strings and images
std::vector<core::stringw> m_strings; std::vector<core::stringw> m_strings;

View File

@ -42,12 +42,8 @@ std::map<unsigned long, std::queue<HTTPFetchResult> > g_httpfetch_results;
PcgRandom g_callerid_randomness; PcgRandom g_callerid_randomness;
HTTPFetchRequest::HTTPFetchRequest() : HTTPFetchRequest::HTTPFetchRequest() :
url(""),
caller(HTTPFETCH_DISCARD),
request_id(0),
timeout(g_settings->getS32("curl_timeout")), timeout(g_settings->getS32("curl_timeout")),
connect_timeout(timeout), connect_timeout(timeout),
multipart(false),
useragent(std::string(PROJECT_NAME_C "/") + g_version_hash + " (" + porting::get_sysinfo() + ")") useragent(std::string(PROJECT_NAME_C "/") + g_version_hash + " (" + porting::get_sysinfo() + ")")
{ {
} }

View File

@ -31,15 +31,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
struct HTTPFetchRequest struct HTTPFetchRequest
{ {
std::string url; std::string url = "";
// Identifies the caller (for asynchronous requests) // Identifies the caller (for asynchronous requests)
// Ignored by httpfetch_sync // Ignored by httpfetch_sync
unsigned long caller; unsigned long caller = HTTPFETCH_DISCARD;
// Some number that identifies the request // Some number that identifies the request
// (when the same caller issues multiple httpfetch_async calls) // (when the same caller issues multiple httpfetch_async calls)
unsigned long request_id; unsigned long request_id = 0;
// Timeout for the whole transfer, in milliseconds // Timeout for the whole transfer, in milliseconds
long timeout; long timeout;
@ -49,7 +49,7 @@ struct HTTPFetchRequest
// Indicates if this is multipart/form-data or // Indicates if this is multipart/form-data or
// application/x-www-form-urlencoded. POST-only. // application/x-www-form-urlencoded. POST-only.
bool multipart; bool multipart = false;
// POST fields. Fields are escaped properly. // POST fields. Fields are escaped properly.
// If this is empty a GET request is done instead. // If this is empty a GET request is done instead.
@ -69,23 +69,18 @@ struct HTTPFetchRequest
struct HTTPFetchResult struct HTTPFetchResult
{ {
bool succeeded; bool succeeded = false;
bool timeout; bool timeout = false;
long response_code; long response_code = 0;
std::string data; std::string data = "";
// The caller and request_id from the corresponding HTTPFetchRequest. // The caller and request_id from the corresponding HTTPFetchRequest.
unsigned long caller; unsigned long caller = HTTPFETCH_DISCARD;
unsigned long request_id; unsigned long request_id = 0;
HTTPFetchResult() HTTPFetchResult() {}
: succeeded(false), timeout(false), response_code(0), data(""),
caller(HTTPFETCH_DISCARD), request_id(0)
{
}
HTTPFetchResult(const HTTPFetchRequest &fetch_request) HTTPFetchResult(const HTTPFetchRequest &fetch_request)
: succeeded(false), timeout(false), response_code(0), data(""), : caller(fetch_request.caller), request_id(fetch_request.request_id)
caller(fetch_request.caller), request_id(fetch_request.request_id)
{ {
} }
}; };

View File

@ -51,8 +51,6 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
this->inventory = inventory; this->inventory = inventory;
m_hud_scaling = g_settings->getFloat("hud_scaling"); m_hud_scaling = g_settings->getFloat("hud_scaling");
m_screensize = v2u32(0, 0);
m_displaycenter = v2s32(0, 0);
m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE * porting::getDisplayDensity() + 0.5); m_hotbar_imagesize = floor(HOTBAR_IMAGE_SIZE * porting::getDisplayDensity() + 0.5);
m_hotbar_imagesize *= m_hud_scaling; m_hotbar_imagesize *= m_hud_scaling;
m_padding = m_hotbar_imagesize / 12; m_padding = m_hotbar_imagesize / 12;
@ -77,16 +75,9 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
use_crosshair_image = tsrc->isKnownSourceImage("crosshair.png"); use_crosshair_image = tsrc->isKnownSourceImage("crosshair.png");
hotbar_image = "";
use_hotbar_image = false;
hotbar_selected_image = "";
use_hotbar_selected_image = false;
m_selection_mesh = NULL;
m_selection_boxes.clear(); m_selection_boxes.clear();
m_halo_boxes.clear(); m_halo_boxes.clear();
m_selection_pos = v3f(0.0, 0.0, 0.0);
std::string mode_setting = g_settings->get("node_highlighting"); std::string mode_setting = g_settings->get("node_highlighting");
if (mode_setting == "halo") { if (mode_setting == "halo") {

View File

@ -114,10 +114,10 @@ public:
video::SColor crosshair_argb; video::SColor crosshair_argb;
video::SColor selectionbox_argb; video::SColor selectionbox_argb;
bool use_crosshair_image; bool use_crosshair_image = false;
std::string hotbar_image; std::string hotbar_image = "";
bool use_hotbar_image; bool use_hotbar_image = false;
std::string hotbar_selected_image; std::string hotbar_selected_image = "";
bool use_hotbar_selected_image; bool use_hotbar_selected_image;
Hud(video::IVideoDriver *driver,scene::ISceneManager* smgr, Hud(video::IVideoDriver *driver,scene::ISceneManager* smgr,
@ -170,7 +170,7 @@ private:
v3f m_selection_pos; v3f m_selection_pos;
v3f m_selection_pos_with_offset; v3f m_selection_pos_with_offset;
scene::IMesh* m_selection_mesh; scene::IMesh *m_selection_mesh = nullptr;
video::SColor m_selection_mesh_color; video::SColor m_selection_mesh_color;
v3f m_selected_face_normal; v3f m_selected_face_normal;

View File

@ -62,13 +62,9 @@ namespace gui
intlGUIEditBox::intlGUIEditBox(const wchar_t* text, bool border, intlGUIEditBox::intlGUIEditBox(const wchar_t* text, bool border,
IGUIEnvironment* environment, IGUIElement* parent, s32 id, IGUIEnvironment* environment, IGUIElement* parent, s32 id,
const core::rect<s32>& rectangle) const core::rect<s32>& rectangle)
: IGUIEditBox(environment, parent, id, rectangle), MouseMarking(false), : IGUIEditBox(environment, parent, id, rectangle),
Border(border), OverrideColorEnabled(false), MarkBegin(0), MarkEnd(0), Border(border),
OverrideColor(video::SColor(101,255,255,255)), OverrideFont(0), LastBreakFont(0), FrameRect(rectangle)
Operator(0), BlinkStartTime(0), CursorPos(0), HScrollPos(0), VScrollPos(0), Max(0),
WordWrap(false), MultiLine(false), AutoScroll(true), PasswordBox(false),
PasswordChar(L'*'), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER),
CurrentTextRect(0,0,1,1), FrameRect(rectangle)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("intlintlGUIEditBox"); setDebugName("intlintlGUIEditBox");

View File

@ -145,29 +145,36 @@ namespace gui
bool processMouse(const SEvent& event); bool processMouse(const SEvent& event);
s32 getCursorPos(s32 x, s32 y); s32 getCursorPos(s32 x, s32 y);
bool MouseMarking; bool MouseMarking = false;
bool Border; bool Border;
bool OverrideColorEnabled; bool OverrideColorEnabled = false;
s32 MarkBegin; s32 MarkBegin = 0;
s32 MarkEnd; s32 MarkEnd = 0;
video::SColor OverrideColor; video::SColor OverrideColor = video::SColor(101,255,255,255);
gui::IGUIFont *OverrideFont, *LastBreakFont; gui::IGUIFont *OverrideFont = nullptr;
IOSOperator* Operator; gui::IGUIFont *LastBreakFont = nullptr;
IOSOperator *Operator = nullptr;
u64 BlinkStartTime; u64 BlinkStartTime = 0;
s32 CursorPos; s32 CursorPos = 0;
s32 HScrollPos, VScrollPos; // scroll position in characters s32 HScrollPos = 0;
u32 Max; s32 VScrollPos = 0; // scroll position in characters
u32 Max = 0;
bool WordWrap, MultiLine, AutoScroll, PasswordBox; bool WordWrap = false;
wchar_t PasswordChar; bool MultiLine = false;
EGUI_ALIGNMENT HAlign, VAlign; bool AutoScroll = true;
bool PasswordBox = false;
wchar_t PasswordChar = L'*';
EGUI_ALIGNMENT HAlign = EGUIA_UPPERLEFT;
EGUI_ALIGNMENT VAlign = EGUIA_CENTER;
core::array< core::stringw > BrokenText; core::array<core::stringw> BrokenText;
core::array< s32 > BrokenTextPositions; core::array<s32> BrokenTextPositions;
core::rect<s32> CurrentTextRect, FrameRect; // temporary values core::rect<s32> CurrentTextRect = core::rect<s32>(0,0,1,1);
core::rect<s32> FrameRect; // temporary values
}; };

View File

@ -372,7 +372,6 @@ ItemStack ItemStack::peekItem(u32 peekcount) const
InventoryList::InventoryList(const std::string &name, u32 size, IItemDefManager *itemdef): InventoryList::InventoryList(const std::string &name, u32 size, IItemDefManager *itemdef):
m_name(name), m_name(name),
m_size(size), m_size(size),
m_width(0),
m_itemdef(itemdef) m_itemdef(itemdef)
{ {
clearItems(); clearItems();

View File

@ -33,7 +33,7 @@ struct ToolCapabilities;
struct ItemStack struct ItemStack
{ {
ItemStack(): name(""), count(0), wear(0) {} ItemStack() {}
ItemStack(const std::string &name_, u16 count_, ItemStack(const std::string &name_, u16 count_,
u16 wear, IItemDefManager *itemdef); u16 wear, IItemDefManager *itemdef);
@ -164,9 +164,9 @@ struct ItemStack
/* /*
Properties Properties
*/ */
std::string name; std::string name = "";
u16 count; u16 count = 0;
u16 wear; u16 wear = 0;
ItemStackMetadata metadata; ItemStackMetadata metadata;
}; };
@ -252,7 +252,8 @@ public:
private: private:
std::vector<ItemStack> m_items; std::vector<ItemStack> m_items;
std::string m_name; std::string m_name;
u32 m_size, m_width; u32 m_size;
u32 m_width = 0;
IItemDefManager *m_itemdef; IItemDefManager *m_itemdef;
}; };
@ -307,7 +308,7 @@ private:
std::vector<InventoryList*> m_lists; std::vector<InventoryList*> m_lists;
IItemDefManager *m_itemdef; IItemDefManager *m_itemdef;
bool m_dirty; bool m_dirty = false;
}; };
#endif #endif

View File

@ -278,12 +278,6 @@ struct table_key lookup_keychar(wchar_t Char)
throw UnknownKeycode(os.str().c_str()); throw UnknownKeycode(os.str().c_str());
} }
KeyPress::KeyPress() :
Key(irr::KEY_KEY_CODES_COUNT),
Char(L'\0'),
m_name("")
{}
KeyPress::KeyPress(const char *name) KeyPress::KeyPress(const char *name)
{ {
if (strlen(name) == 0) { if (strlen(name) == 0) {

View File

@ -31,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class KeyPress class KeyPress
{ {
public: public:
KeyPress(); KeyPress() {}
KeyPress(const char *name); KeyPress(const char *name);
KeyPress(const irr::SEvent::SKeyInput &in, bool prefer_character = false); KeyPress(const irr::SEvent::SKeyInput &in, bool prefer_character = false);
@ -50,9 +50,9 @@ protected:
return k > 0 && k < irr::KEY_KEY_CODES_COUNT; return k > 0 && k < irr::KEY_KEY_CODES_COUNT;
} }
irr::EKEY_CODE Key; irr::EKEY_CODE Key = irr::KEY_KEY_CODES_COUNT;
wchar_t Char; wchar_t Char = L'\0';
std::string m_name; std::string m_name = "";
}; };
extern const KeyPress EscapeKey; extern const KeyPress EscapeKey;

View File

@ -34,62 +34,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
LocalPlayer::LocalPlayer(Client *client, const char *name): LocalPlayer::LocalPlayer(Client *client, const char *name):
Player(name, client->idef()), Player(name, client->idef()),
parent(0),
hp(PLAYER_MAX_HP),
isAttached(false),
touching_ground(false),
in_liquid(false),
in_liquid_stable(false),
liquid_viscosity(0),
is_climbing(false),
swimming_vertical(false),
// Movement overrides are multipliers and must be 1 by default
physics_override_speed(1.0f),
physics_override_jump(1.0f),
physics_override_gravity(1.0f),
physics_override_sneak(true),
physics_override_sneak_glitch(false),
physics_override_new_move(true), // Temporary option for old move code
overridePosition(v3f(0,0,0)),
last_position(v3f(0,0,0)),
last_speed(v3f(0,0,0)),
last_pitch(0),
last_yaw(0),
last_keyPressed(0),
last_camera_fov(0),
last_wanted_range(0),
camera_impact(0.f),
makes_footstep_sound(true),
last_animation(NO_ANIM),
hotbar_image(""),
hotbar_selected_image(""),
light_color(255,255,255,255),
hurt_tilt_timer(0.0f),
hurt_tilt_strength(0.0f),
m_position(0,0,0),
m_sneak_node(32767,32767,32767),
m_sneak_node_bb_ymax(0), // To support temporary option for old move code
m_sneak_node_bb_top(0,0,0,0,0,0),
m_sneak_node_exists(false),
m_need_to_get_new_sneak_node(true),
m_sneak_ladder_detected(false),
m_ledge_detected(false),
m_old_node_below(32767,32767,32767),
m_old_node_below_type("air"),
m_can_jump(false),
m_breath(PLAYER_MAX_BREATH),
m_yaw(0),
m_pitch(0),
camera_barely_in_ceiling(false),
m_collisionbox(-BS * 0.30, 0.0, -BS * 0.30, BS * 0.30, BS * 1.75, BS * 0.30),
m_cao(NULL),
m_client(client) m_client(client)
{ {
// Initialize hp to 0, so that no hearts will be shown if server
// doesn't support health points
hp = 0;
eye_offset_first = v3f(0,0,0);
eye_offset_third = v3f(0,0,0);
} }
LocalPlayer::~LocalPlayer() LocalPlayer::~LocalPlayer()

View File

@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "player.h" #include "player.h"
#include "environment.h" #include "environment.h"
#include "constants.h"
#include <list> #include <list>
class Client; class Client;
@ -44,27 +45,29 @@ public:
LocalPlayer(Client *client, const char *name); LocalPlayer(Client *client, const char *name);
virtual ~LocalPlayer(); virtual ~LocalPlayer();
ClientActiveObject *parent; ClientActiveObject *parent = nullptr;
u16 hp; // Initialize hp to 0, so that no hearts will be shown if server
bool isAttached; // doesn't support health points
bool touching_ground; u16 hp = 0;
bool isAttached = false;
bool touching_ground = false;
// This oscillates so that the player jumps a bit above the surface // This oscillates so that the player jumps a bit above the surface
bool in_liquid; bool in_liquid = false;
// This is more stable and defines the maximum speed of the player // This is more stable and defines the maximum speed of the player
bool in_liquid_stable; bool in_liquid_stable = false;
// Gets the viscosity of water to calculate friction // Gets the viscosity of water to calculate friction
u8 liquid_viscosity; u8 liquid_viscosity = 0;
bool is_climbing; bool is_climbing = false;
bool swimming_vertical; bool swimming_vertical = false;
float physics_override_speed; float physics_override_speed = 1.0f;
float physics_override_jump; float physics_override_jump = 1.0f;
float physics_override_gravity; float physics_override_gravity = 1.0f;
bool physics_override_sneak; bool physics_override_sneak = true;
bool physics_override_sneak_glitch; bool physics_override_sneak_glitch = false;
// Temporary option for old move code // Temporary option for old move code
bool physics_override_new_move; bool physics_override_new_move = true;
v3f overridePosition; v3f overridePosition;
@ -83,32 +86,32 @@ public:
// Used to check if anything changed and prevent sending packets if not // Used to check if anything changed and prevent sending packets if not
v3f last_position; v3f last_position;
v3f last_speed; v3f last_speed;
float last_pitch; float last_pitch = 0.0f;
float last_yaw; float last_yaw = 0.0f;
unsigned int last_keyPressed; unsigned int last_keyPressed = 0;
u8 last_camera_fov; u8 last_camera_fov = 0;
u8 last_wanted_range; u8 last_wanted_range = 0;
float camera_impact; float camera_impact = 0.0f;
bool makes_footstep_sound; bool makes_footstep_sound = true;
int last_animation; int last_animation = NO_ANIM;
float last_animation_speed; float last_animation_speed;
std::string hotbar_image; std::string hotbar_image = "";
std::string hotbar_selected_image; std::string hotbar_selected_image = "";
video::SColor light_color; video::SColor light_color = video::SColor(255, 255, 255, 255);
float hurt_tilt_timer; float hurt_tilt_timer = 0.0f;
float hurt_tilt_strength; float hurt_tilt_strength = 0.0f;
GenericCAO *getCAO() const { return m_cao; } GenericCAO *getCAO() const { return m_cao; }
void setCAO(GenericCAO *toset) void setCAO(GenericCAO *toset)
{ {
assert(m_cao == NULL); // Pre-condition assert(!m_cao); // Pre-condition
m_cao = toset; m_cao = toset;
} }
@ -143,35 +146,36 @@ private:
v3f m_position; v3f m_position;
v3s16 m_sneak_node; v3s16 m_sneak_node = v3s16(32767, 32767, 32767);
// Stores the max player uplift by m_sneak_node // Stores the max player uplift by m_sneak_node
// To support temporary option for old move code // To support temporary option for old move code
f32 m_sneak_node_bb_ymax; f32 m_sneak_node_bb_ymax = 0.0f;
// Stores the top bounding box of m_sneak_node // Stores the top bounding box of m_sneak_node
aabb3f m_sneak_node_bb_top; aabb3f m_sneak_node_bb_top = aabb3f(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
// Whether the player is allowed to sneak // Whether the player is allowed to sneak
bool m_sneak_node_exists; bool m_sneak_node_exists = false;
// Whether recalculation of m_sneak_node and its top bbox is needed // Whether recalculation of m_sneak_node and its top bbox is needed
bool m_need_to_get_new_sneak_node; bool m_need_to_get_new_sneak_node = true;
// Whether a "sneak ladder" structure is detected at the players pos // Whether a "sneak ladder" structure is detected at the players pos
// see detectSneakLadder() in the .cpp for more info (always false if disabled) // see detectSneakLadder() in the .cpp for more info (always false if disabled)
bool m_sneak_ladder_detected; bool m_sneak_ladder_detected = false;
// Whether a 2-node-up ledge is detected at the players pos, // Whether a 2-node-up ledge is detected at the players pos,
// see detectLedge() in the .cpp for more info (always false if disabled). // see detectLedge() in the .cpp for more info (always false if disabled).
bool m_ledge_detected; bool m_ledge_detected = false;
// Node below player, used to determine whether it has been removed, // Node below player, used to determine whether it has been removed,
// and its old type // and its old type
v3s16 m_old_node_below; v3s16 m_old_node_below = v3s16(32767, 32767, 32767);
std::string m_old_node_below_type; std::string m_old_node_below_type = "air";
bool m_can_jump; bool m_can_jump = false;
u16 m_breath; u16 m_breath = PLAYER_MAX_BREATH;
f32 m_yaw; f32 m_yaw = 0.0f;
f32 m_pitch; f32 m_pitch = 0.0f;
bool camera_barely_in_ceiling; bool camera_barely_in_ceiling = false;
aabb3f m_collisionbox; aabb3f m_collisionbox = aabb3f(-BS * 0.30f, 0.0f, -BS * 0.30f, BS * 0.30f,
BS * 1.75f, BS * 0.30f);
GenericCAO *m_cao; GenericCAO *m_cao = nullptr;
Client *m_client; Client *m_client;
}; };

View File

@ -319,7 +319,7 @@ static void print_allowed_options(const OptionList &allowed_options)
std::cout << padStringRight(os1.str(), 30); std::cout << padStringRight(os1.str(), 30);
if (i->second.help != NULL) if (i->second.help)
std::cout << i->second.help; std::cout << i->second.help;
std::cout << std::endl; std::cout << std::endl;

View File

@ -125,12 +125,6 @@ class MainGameCallback : public IGameCallback
{ {
public: public:
MainGameCallback(IrrlichtDevice *a_device): MainGameCallback(IrrlichtDevice *a_device):
disconnect_requested(false),
changepassword_requested(false),
changevolume_requested(false),
keyconfig_requested(false),
shutdown_requested(false),
keyconfig_changed(false),
device(a_device) device(a_device)
{ {
} }
@ -169,13 +163,13 @@ public:
} }
bool disconnect_requested; bool disconnect_requested = false;
bool changepassword_requested; bool changepassword_requested = false;
bool changevolume_requested; bool changevolume_requested = false;
bool keyconfig_requested; bool keyconfig_requested = false;
bool shutdown_requested; bool shutdown_requested = false;
bool keyconfig_changed; bool keyconfig_changed = false;
IrrlichtDevice *device; IrrlichtDevice *device;
}; };

View File

@ -65,12 +65,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Map::Map(std::ostream &dout, IGameDef *gamedef): Map::Map(std::ostream &dout, IGameDef *gamedef):
m_dout(dout), m_dout(dout),
m_gamedef(gamedef), m_gamedef(gamedef),
m_sector_cache(NULL), m_nodedef(gamedef->ndef())
m_nodedef(gamedef->ndef()),
m_transforming_liquid_loop_count_multiplier(1.0f),
m_unprocessed_count(0),
m_inc_trending_up_start_time(0),
m_queue_size_timer_started(false)
{ {
} }
@ -1240,8 +1235,7 @@ ServerMap::ServerMap(const std::string &savedir, IGameDef *gamedef,
EmergeManager *emerge): EmergeManager *emerge):
Map(dout_server, gamedef), Map(dout_server, 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)
m_map_metadata_changed(true)
{ {
verbosestream<<FUNCTION_NAME<<std::endl; verbosestream<<FUNCTION_NAME<<std::endl;
@ -2618,8 +2612,6 @@ bool ServerMap::repairBlockLight(v3s16 blockpos,
MMVManip::MMVManip(Map *map): MMVManip::MMVManip(Map *map):
VoxelManipulator(), VoxelManipulator(),
m_is_dirty(false),
m_create_area(false),
m_map(map) m_map(map)
{ {
} }

View File

@ -72,17 +72,13 @@ enum MapEditEventType{
struct MapEditEvent struct MapEditEvent
{ {
MapEditEventType type; MapEditEventType type = MEET_OTHER;
v3s16 p; v3s16 p;
MapNode n; MapNode n = CONTENT_AIR;
std::set<v3s16> modified_blocks; std::set<v3s16> modified_blocks;
u16 already_known_by_peer; u16 already_known_by_peer = 0;
MapEditEvent(): MapEditEvent() {}
type(MEET_OTHER),
n(CONTENT_AIR),
already_known_by_peer(0)
{ }
MapEditEvent * clone() MapEditEvent * clone()
{ {
@ -323,7 +319,7 @@ protected:
std::map<v2s16, MapSector*> m_sectors; std::map<v2s16, MapSector*> m_sectors;
// Be sure to set this to NULL when the cached sector is deleted // Be sure to set this to NULL when the cached sector is deleted
MapSector *m_sector_cache; MapSector *m_sector_cache = nullptr;
v2s16 m_sector_cache_p; v2s16 m_sector_cache_p;
// Queued transforming water nodes // Queued transforming water nodes
@ -336,10 +332,10 @@ protected:
float start_off, float end_off, u32 needed_count); float start_off, float end_off, u32 needed_count);
private: private:
f32 m_transforming_liquid_loop_count_multiplier; f32 m_transforming_liquid_loop_count_multiplier = 1.0f;
u32 m_unprocessed_count; u32 m_unprocessed_count = 0;
u64 m_inc_trending_up_start_time; // milliseconds u64 m_inc_trending_up_start_time = 0; // milliseconds
bool m_queue_size_timer_started; bool m_queue_size_timer_started = false;
}; };
/* /*
@ -501,8 +497,8 @@ private:
Metadata is re-written on disk only if this is true. Metadata is re-written on disk only if this is true.
This is reset to false when written on disk. This is reset to false when written on disk.
*/ */
bool m_map_metadata_changed; bool m_map_metadata_changed = true;
MapDatabase *dbase; MapDatabase *dbase = nullptr;
}; };
@ -521,9 +517,6 @@ public:
m_loaded_blocks.clear(); m_loaded_blocks.clear();
} }
void setMap(Map *map)
{m_map = map;}
void initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max, void initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
bool load_if_inexistent = true); bool load_if_inexistent = true);
@ -531,10 +524,9 @@ public:
void blitBackAll(std::map<v3s16, MapBlock*> * modified_blocks, void blitBackAll(std::map<v3s16, MapBlock*> * modified_blocks,
bool overwrite_generated = true); bool overwrite_generated = true);
bool m_is_dirty; bool m_is_dirty = false;
protected: protected:
bool m_create_area;
Map *m_map; Map *m_map;
/* /*
key = blockpos key = blockpos

View File

@ -27,7 +27,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
MapSettingsManager::MapSettingsManager(Settings *user_settings, MapSettingsManager::MapSettingsManager(Settings *user_settings,
const std::string &map_meta_path): const std::string &map_meta_path):
mapgen_params(NULL),
m_map_meta_path(map_meta_path), m_map_meta_path(map_meta_path),
m_map_settings(new Settings()), m_map_settings(new Settings()),
m_user_settings(user_settings) m_user_settings(user_settings)

View File

@ -45,13 +45,13 @@ struct MapgenParams;
*/ */
class MapSettingsManager { class MapSettingsManager {
public: public:
// Finalized map generation parameters
MapgenParams *mapgen_params;
MapSettingsManager(Settings *user_settings, MapSettingsManager(Settings *user_settings,
const std::string &map_meta_path); const std::string &map_meta_path);
~MapSettingsManager(); ~MapSettingsManager();
// Finalized map generation parameters
MapgenParams *mapgen_params = nullptr;
bool getMapSetting(const std::string &name, std::string *value_out); bool getMapSetting(const std::string &name, std::string *value_out);
bool getMapSettingNoiseParams( bool getMapSettingNoiseParams(

View File

@ -69,36 +69,18 @@ MapBlock::MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy):
m_parent(parent), m_parent(parent),
m_pos(pos), m_pos(pos),
m_pos_relative(pos * MAP_BLOCKSIZE), m_pos_relative(pos * MAP_BLOCKSIZE),
m_gamedef(gamedef), m_gamedef(gamedef)
m_modified(MOD_STATE_WRITE_NEEDED),
m_modified_reason(MOD_REASON_INITIAL),
is_underground(false),
m_lighting_complete(0xFFFF),
m_day_night_differs(false),
m_day_night_differs_expired(true),
m_generated(false),
m_timestamp(BLOCK_TIMESTAMP_UNDEFINED),
m_disk_timestamp(BLOCK_TIMESTAMP_UNDEFINED),
m_usage_timer(0),
m_refcount(0)
{ {
data = NULL;
if(dummy == false) if(dummy == false)
reallocate(); reallocate();
#ifndef SERVER
mesh = NULL;
#endif
} }
MapBlock::~MapBlock() MapBlock::~MapBlock()
{ {
#ifndef SERVER #ifndef SERVER
{ {
//MutexAutoLock lock(mesh_mutex);
delete mesh; delete mesh;
mesh = NULL; mesh = nullptr;
} }
#endif #endif
@ -121,7 +103,7 @@ MapNode MapBlock::getNodeParent(v3s16 p, bool *is_valid_position)
if (isValidPosition(p) == false) if (isValidPosition(p) == false)
return m_parent->getNodeNoEx(getPosRelative() + p, is_valid_position); return m_parent->getNodeNoEx(getPosRelative() + p, is_valid_position);
if (data == NULL) { if (!data) {
if (is_valid_position) if (is_valid_position)
*is_valid_position = false; *is_valid_position = false;
return MapNode(CONTENT_IGNORE); return MapNode(CONTENT_IGNORE);
@ -374,7 +356,7 @@ void MapBlock::actuallyUpdateDayNightDiff()
// Running this function un-expires m_day_night_differs // Running this function un-expires m_day_night_differs
m_day_night_differs_expired = false; m_day_night_differs_expired = false;
if (data == NULL) { if (!data) {
m_day_night_differs = false; m_day_night_differs = false;
return; return;
} }
@ -415,9 +397,7 @@ void MapBlock::actuallyUpdateDayNightDiff()
void MapBlock::expireDayNightDiff() void MapBlock::expireDayNightDiff()
{ {
//INodeDefManager *nodemgr = m_gamedef->ndef(); if (!data) {
if(data == NULL){
m_day_night_differs = false; m_day_night_differs = false;
m_day_night_differs_expired = false; m_day_night_differs_expired = false;
return; return;
@ -554,10 +534,8 @@ void MapBlock::serialize(std::ostream &os, u8 version, bool disk)
if(!ser_ver_supported(version)) if(!ser_ver_supported(version))
throw VersionMismatchException("ERROR: MapBlock format not supported"); throw VersionMismatchException("ERROR: MapBlock format not supported");
if(data == NULL) if (!data)
{
throw SerializationError("ERROR: Not writing dummy block."); throw SerializationError("ERROR: Not writing dummy block.");
}
FATAL_ERROR_IF(version < SER_FMT_VER_LOWEST_WRITE, "Serialisation version error"); FATAL_ERROR_IF(version < SER_FMT_VER_LOWEST_WRITE, "Serialisation version error");

View File

@ -42,63 +42,6 @@ class VoxelManipulator;
#define BLOCK_TIMESTAMP_UNDEFINED 0xffffffff #define BLOCK_TIMESTAMP_UNDEFINED 0xffffffff
/*// Named by looking towards z+
enum{
FACE_BACK=0,
FACE_TOP,
FACE_RIGHT,
FACE_FRONT,
FACE_BOTTOM,
FACE_LEFT
};*/
// NOTE: If this is enabled, set MapBlock to be initialized with
// CONTENT_IGNORE.
/*enum BlockGenerationStatus
{
// Completely non-generated (filled with CONTENT_IGNORE).
BLOCKGEN_UNTOUCHED=0,
// Trees or similar might have been blitted from other blocks to here.
// Otherwise, the block contains CONTENT_IGNORE
BLOCKGEN_FROM_NEIGHBORS=2,
// Has been generated, but some neighbors might put some stuff in here
// when they are generated.
// Does not contain any CONTENT_IGNORE
BLOCKGEN_SELF_GENERATED=4,
// The block and all its neighbors have been generated
BLOCKGEN_FULLY_GENERATED=6
};*/
#if 0
enum
{
NODECONTAINER_ID_MAPBLOCK,
NODECONTAINER_ID_MAPSECTOR,
NODECONTAINER_ID_MAP,
NODECONTAINER_ID_MAPBLOCKCACHE,
NODECONTAINER_ID_VOXELMANIPULATOR,
};
class NodeContainer
{
public:
virtual bool isValidPosition(v3s16 p) = 0;
virtual MapNode getNode(v3s16 p) = 0;
virtual void setNode(v3s16 p, MapNode & n) = 0;
virtual u16 nodeContainerId() const = 0;
MapNode getNodeNoEx(v3s16 p)
{
try{
return getNode(p);
}
catch(InvalidPositionException &e){
return MapNode(CONTENT_IGNORE);
}
}
};
#endif
//// ////
//// MapBlock modified reason flags //// MapBlock modified reason flags
//// ////
@ -128,7 +71,7 @@ public:
//// MapBlock itself //// MapBlock itself
//// ////
class MapBlock /*: public NodeContainer*/ class MapBlock
{ {
public: public:
MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy=false); MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef, bool dummy=false);
@ -198,7 +141,7 @@ public:
inline bool isDummy() inline bool isDummy()
{ {
return (data == NULL); return !data;
} }
inline void unDummify() inline void unDummify()
@ -298,7 +241,7 @@ public:
inline bool isValidPosition(s16 x, s16 y, s16 z) inline bool isValidPosition(s16 x, s16 y, s16 z)
{ {
return data != NULL return data
&& x >= 0 && x < MAP_BLOCKSIZE && x >= 0 && x < MAP_BLOCKSIZE
&& y >= 0 && y < MAP_BLOCKSIZE && y >= 0 && y < MAP_BLOCKSIZE
&& z >= 0 && z < MAP_BLOCKSIZE; && z >= 0 && z < MAP_BLOCKSIZE;
@ -350,7 +293,7 @@ public:
inline MapNode getNodeNoCheck(s16 x, s16 y, s16 z, bool *valid_position) inline MapNode getNodeNoCheck(s16 x, s16 y, s16 z, bool *valid_position)
{ {
*valid_position = data != NULL; *valid_position = data != nullptr;
if (!valid_position) if (!valid_position)
return MapNode(CONTENT_IGNORE); return MapNode(CONTENT_IGNORE);
@ -380,7 +323,7 @@ public:
inline void setNodeNoCheck(s16 x, s16 y, s16 z, MapNode & n) inline void setNodeNoCheck(s16 x, s16 y, s16 z, MapNode & n)
{ {
if (data == NULL) if (!data)
throw InvalidPositionException(); throw InvalidPositionException();
data[z * zstride + y * ystride + x] = n; data[z * zstride + y * ystride + x] = n;
@ -579,7 +522,7 @@ public:
*/ */
#ifndef SERVER // Only on client #ifndef SERVER // Only on client
MapBlockMesh *mesh; MapBlockMesh *mesh = nullptr;
#endif #endif
NodeMetadataList m_node_metadata; NodeMetadataList m_node_metadata;
@ -615,15 +558,15 @@ private:
If NULL, block is a dummy block. If NULL, block is a dummy block.
Dummy blocks are used for caching not-found-on-disk blocks. Dummy blocks are used for caching not-found-on-disk blocks.
*/ */
MapNode *data; MapNode *data = nullptr;
/* /*
- On the server, this is used for telling whether the - On the server, this is used for telling whether the
block has been modified from the one on disk. block has been modified from the one on disk.
- On the client, this is used for nothing. - On the client, this is used for nothing.
*/ */
u32 m_modified; u32 m_modified = MOD_STATE_WRITE_NEEDED;
u32 m_modified_reason; u32 m_modified_reason = MOD_REASON_INITIAL;
/* /*
When propagating sunlight and the above block doesn't exist, When propagating sunlight and the above block doesn't exist,
@ -633,7 +576,7 @@ private:
undeground with nothing visible above the ground except undeground with nothing visible above the ground except
caves. caves.
*/ */
bool is_underground; bool is_underground = false;
/*! /*!
* Each bit indicates if light spreading was finished * Each bit indicates if light spreading was finished
@ -643,33 +586,33 @@ private:
* night X-, night Y-, night Z-, night Z+, night Y+, night X+, * night X-, night Y-, night Z-, night Z+, night Y+, night X+,
* day X-, day Y-, day Z-, day Z+, day Y+, day X+. * day X-, day Y-, day Z-, day Z+, day Y+, day X+.
*/ */
u16 m_lighting_complete; u16 m_lighting_complete = 0xFFFF;
// Whether day and night lighting differs // Whether day and night lighting differs
bool m_day_night_differs; bool m_day_night_differs = false;
bool m_day_night_differs_expired; bool m_day_night_differs_expired = true;
bool m_generated; bool m_generated = false;
/* /*
When block is removed from active blocks, this is set to gametime. When block is removed from active blocks, this is set to gametime.
Value BLOCK_TIMESTAMP_UNDEFINED=0xffffffff means there is no timestamp. Value BLOCK_TIMESTAMP_UNDEFINED=0xffffffff means there is no timestamp.
*/ */
u32 m_timestamp; u32 m_timestamp = BLOCK_TIMESTAMP_UNDEFINED;
// The on-disk (or to-be on-disk) timestamp value // The on-disk (or to-be on-disk) timestamp value
u32 m_disk_timestamp; u32 m_disk_timestamp = BLOCK_TIMESTAMP_UNDEFINED;
/* /*
When the block is accessed, this is set to 0. When the block is accessed, this is set to 0.
Map will unload the block when this reaches a timeout. Map will unload the block when this reaches a timeout.
*/ */
float m_usage_timer; float m_usage_timer = 0;
/* /*
Reference count; currently used for determining if this block is in Reference count; currently used for determining if this block is in
the list of blocks to be drawn. the list of blocks to be drawn.
*/ */
int m_refcount; int m_refcount = 0;
}; };
typedef std::vector<MapBlock*> MapBlockVect; typedef std::vector<MapBlock*> MapBlockVect;

View File

@ -38,11 +38,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
MeshMakeData::MeshMakeData(Client *client, bool use_shaders, MeshMakeData::MeshMakeData(Client *client, bool use_shaders,
bool use_tangent_vertices): bool use_tangent_vertices):
m_vmanip(),
m_blockpos(-1337,-1337,-1337),
m_crack_pos_relative(-1337, -1337, -1337),
m_smooth_lighting(false),
m_show_hud(false),
m_client(client), m_client(client),
m_use_shaders(use_shaders), m_use_shaders(use_shaders),
m_use_tangent_vertices(use_tangent_vertices) m_use_tangent_vertices(use_tangent_vertices)
@ -1073,7 +1068,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
const u16 indices[] = {0,1,2,2,3,0}; const u16 indices[] = {0,1,2,2,3,0};
const u16 indices_alternate[] = {0,1,3,2,3,1}; const u16 indices_alternate[] = {0,1,3,2,3,1};
if (f.layer.texture == NULL) if (!f.layer.texture)
continue; continue;
const u16 *indices_p = const u16 *indices_p =

View File

@ -39,10 +39,10 @@ struct MinimapMapblock;
struct MeshMakeData struct MeshMakeData
{ {
VoxelManipulator m_vmanip; VoxelManipulator m_vmanip;
v3s16 m_blockpos; v3s16 m_blockpos = v3s16(-1337,-1337,-1337);
v3s16 m_crack_pos_relative; v3s16 m_crack_pos_relative = v3s16(-1337,-1337,-1337);
bool m_smooth_lighting; bool m_smooth_lighting = false;
bool m_show_hud; bool m_show_hud = false;
Client *m_client; Client *m_client;
bool m_use_shaders; bool m_use_shaders;

View File

@ -98,25 +98,12 @@ STATIC_ASSERT(
Mapgen::Mapgen() Mapgen::Mapgen()
{ {
generating = false;
id = -1;
seed = 0;
water_level = 0;
mapgen_limit = 0;
flags = 0;
vm = NULL;
ndef = NULL;
biomegen = NULL;
biomemap = NULL;
heightmap = NULL;
} }
Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) : Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids) gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids)
{ {
generating = false;
id = mapgenid; id = mapgenid;
water_level = params->water_level; water_level = params->water_level;
mapgen_limit = params->mapgen_limit; mapgen_limit = params->mapgen_limit;
@ -138,11 +125,7 @@ Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) :
*/ */
seed = (s32)params->seed; seed = (s32)params->seed;
vm = NULL;
ndef = emerge->ndef; ndef = emerge->ndef;
biomegen = NULL;
biomemap = NULL;
heightmap = NULL;
} }
@ -929,7 +912,6 @@ void MapgenBasic::generateDungeons(s16 max_stone_y, MgStoneType stone_type)
GenerateNotifier::GenerateNotifier() GenerateNotifier::GenerateNotifier()
{ {
m_notify_on = 0;
} }

View File

@ -105,7 +105,7 @@ public:
bool peek_events=false); bool peek_events=false);
private: private:
u32 m_notify_on; u32 m_notify_on = 0;
std::set<u32> *m_notify_on_deco_ids; std::set<u32> *m_notify_on_deco_ids;
std::list<GenNotifyEvent> m_notify_events; std::list<GenNotifyEvent> m_notify_events;
}; };
@ -122,37 +122,21 @@ enum MapgenType {
}; };
struct MapgenParams { struct MapgenParams {
MapgenType mgtype; MapgenParams() {}
s16 chunksize;
u64 seed;
s16 water_level;
s16 mapgen_limit;
u32 flags;
BiomeParams *bparams;
s16 mapgen_edge_min;
s16 mapgen_edge_max;
MapgenParams() :
mgtype(MAPGEN_DEFAULT),
chunksize(5),
seed(0),
water_level(1),
mapgen_limit(MAX_MAP_GENERATION_LIMIT),
flags(MG_CAVES | MG_LIGHT | MG_DECORATIONS),
bparams(NULL),
mapgen_edge_min(-MAX_MAP_GENERATION_LIMIT),
mapgen_edge_max(MAX_MAP_GENERATION_LIMIT),
m_sao_limit_min(-MAX_MAP_GENERATION_LIMIT * BS),
m_sao_limit_max(MAX_MAP_GENERATION_LIMIT * BS),
m_mapgen_edges_calculated(false)
{
}
virtual ~MapgenParams(); virtual ~MapgenParams();
MapgenType mgtype = MAPGEN_DEFAULT;
s16 chunksize = 5;
u64 seed = 0;
s16 water_level = 1;
s16 mapgen_limit = MAX_MAP_GENERATION_LIMIT;
u32 flags = MG_CAVES | MG_LIGHT | MG_DECORATIONS;
BiomeParams *bparams = nullptr;
s16 mapgen_edge_min = -MAX_MAP_GENERATION_LIMIT;
s16 mapgen_edge_max = MAX_MAP_GENERATION_LIMIT;
virtual void readParams(const Settings *settings); virtual void readParams(const Settings *settings);
virtual void writeParams(Settings *settings) const; virtual void writeParams(Settings *settings) const;
@ -162,9 +146,9 @@ struct MapgenParams {
private: private:
void calcMapgenEdges(); void calcMapgenEdges();
float m_sao_limit_min; float m_sao_limit_min = -MAX_MAP_GENERATION_LIMIT * BS;
float m_sao_limit_max; float m_sao_limit_max = MAX_MAP_GENERATION_LIMIT * BS;
bool m_mapgen_edges_calculated; bool m_mapgen_edges_calculated = false;
}; };
@ -179,22 +163,22 @@ private:
*/ */
class Mapgen { class Mapgen {
public: public:
s32 seed; s32 seed = 0;
int water_level; int water_level = 0;
int mapgen_limit; int mapgen_limit = 0;
u32 flags; u32 flags = 0;
bool generating; bool generating = false;
int id; int id = -1;
MMVManip *vm; MMVManip *vm = nullptr;
INodeDefManager *ndef; INodeDefManager *ndef = nullptr;
u32 blockseed; u32 blockseed;
s16 *heightmap; s16 *heightmap = nullptr;
biome_t *biomemap; biome_t *biomemap = nullptr;
v3s16 csize; v3s16 csize;
BiomeGen *biomegen; BiomeGen *biomegen = nullptr;
GenerateNotifier gennotify; GenerateNotifier gennotify;
Mapgen(); Mapgen();

View File

@ -82,15 +82,6 @@ MapgenFlat::~MapgenFlat()
MapgenFlatParams::MapgenFlatParams() MapgenFlatParams::MapgenFlatParams()
{ {
spflags = 0;
ground_level = 8;
large_cave_depth = -33;
cave_width = 0.09;
lake_threshold = -0.45;
lake_steepness = 48.0;
hill_threshold = 0.45;
hill_steepness = 64.0;
np_terrain = NoiseParams(0, 1, v3f(600, 600, 600), 7244, 5, 0.6, 2.0); np_terrain = NoiseParams(0, 1, v3f(600, 600, 600), 7244, 5, 0.6, 2.0);
np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0); np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0);
np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0); np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0);

View File

@ -33,14 +33,14 @@ extern FlagDesc flagdesc_mapgen_flat[];
struct MapgenFlatParams : public MapgenParams struct MapgenFlatParams : public MapgenParams
{ {
u32 spflags; u32 spflags = 0;
s16 ground_level; s16 ground_level = 8;
s16 large_cave_depth; s16 large_cave_depth = -33;
float cave_width; float cave_width = 0.09f;
float lake_threshold; float lake_threshold = -0.45f;
float lake_steepness; float lake_steepness = 48.0f;
float hill_threshold; float hill_threshold = 0.45f;
float hill_steepness; float hill_steepness = 64.0f;
NoiseParams np_terrain; NoiseParams np_terrain;
NoiseParams np_filler_depth; NoiseParams np_filler_depth;
NoiseParams np_cave1; NoiseParams np_cave1;

View File

@ -82,18 +82,6 @@ MapgenFractal::~MapgenFractal()
MapgenFractalParams::MapgenFractalParams() MapgenFractalParams::MapgenFractalParams()
{ {
spflags = 0;
cave_width = 0.09;
fractal = 1;
iterations = 11;
scale = v3f(4096.0, 1024.0, 4096.0);
offset = v3f(1.79, 0.0, 0.0);
slice_w = 0.0;
julia_x = 0.33;
julia_y = 0.33;
julia_z = 0.33;
julia_w = 0.33;
np_seabed = NoiseParams(-14, 9, v3f(600, 600, 600), 41900, 5, 0.6, 2.0); np_seabed = NoiseParams(-14, 9, v3f(600, 600, 600), 41900, 5, 0.6, 2.0);
np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0); np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0);
np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0); np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0);

View File

@ -34,17 +34,17 @@ extern FlagDesc flagdesc_mapgen_fractal[];
struct MapgenFractalParams : public MapgenParams struct MapgenFractalParams : public MapgenParams
{ {
u32 spflags; u32 spflags = 0;
float cave_width; float cave_width = 0.09f;
u16 fractal; u16 fractal = 1;
u16 iterations; u16 iterations = 11;
v3f scale; v3f scale = v3f(4096.0, 1024.0, 4096.0);
v3f offset; v3f offset = v3f(1.79, 0.0, 0.0);
float slice_w; float slice_w = 0.0f;
float julia_x; float julia_x = 0.33f;
float julia_y; float julia_y = 0.33f;
float julia_z; float julia_z = 0.33f;
float julia_w; float julia_w = 0.33f;
NoiseParams np_seabed; NoiseParams np_seabed;
NoiseParams np_filler_depth; NoiseParams np_filler_depth;
NoiseParams np_cave1; NoiseParams np_cave1;

View File

@ -80,12 +80,6 @@ MapgenV5::~MapgenV5()
MapgenV5Params::MapgenV5Params() MapgenV5Params::MapgenV5Params()
{ {
spflags = MGV5_CAVERNS;
cave_width = 0.125;
cavern_limit = -256;
cavern_taper = 256;
cavern_threshold = 0.7;
np_filler_depth = NoiseParams(0, 1, v3f(150, 150, 150), 261, 4, 0.7, 2.0); np_filler_depth = NoiseParams(0, 1, v3f(150, 150, 150), 261, 4, 0.7, 2.0);
np_factor = NoiseParams(0, 1, v3f(250, 250, 250), 920381, 3, 0.45, 2.0); np_factor = NoiseParams(0, 1, v3f(250, 250, 250), 920381, 3, 0.45, 2.0);
np_height = NoiseParams(0, 10, v3f(250, 250, 250), 84174, 4, 0.5, 2.0); np_height = NoiseParams(0, 10, v3f(250, 250, 250), 84174, 4, 0.5, 2.0);

View File

@ -34,11 +34,11 @@ extern FlagDesc flagdesc_mapgen_v5[];
struct MapgenV5Params : public MapgenParams struct MapgenV5Params : public MapgenParams
{ {
u32 spflags; u32 spflags = MGV5_CAVERNS;
float cave_width; float cave_width = 0.125f;
s16 cavern_limit; s16 cavern_limit = -256;
s16 cavern_taper; s16 cavern_taper = 256;
float cavern_threshold; float cavern_threshold = 0.7f;
NoiseParams np_filler_depth; NoiseParams np_filler_depth;
NoiseParams np_factor; NoiseParams np_factor;

View File

@ -147,12 +147,6 @@ MapgenV6::~MapgenV6()
MapgenV6Params::MapgenV6Params() MapgenV6Params::MapgenV6Params()
{ {
spflags = MGV6_JUNGLES | MGV6_SNOWBIOMES | MGV6_TREES |
MGV6_BIOMEBLEND | MGV6_MUDFLOW;
freq_desert = 0.45;
freq_beach = 0.15;
np_terrain_base = NoiseParams(-4, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6, 2.0); np_terrain_base = NoiseParams(-4, 20.0, v3f(250.0, 250.0, 250.0), 82341, 5, 0.6, 2.0);
np_terrain_higher = NoiseParams(20, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6, 2.0); np_terrain_higher = NoiseParams(20, 16.0, v3f(500.0, 500.0, 500.0), 85039, 5, 0.6, 2.0);
np_steepness = NoiseParams(0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7, 2.0); np_steepness = NoiseParams(0.85, 0.5, v3f(125.0, 125.0, 125.0), -932, 5, 0.7, 2.0);

View File

@ -56,9 +56,10 @@ enum BiomeV6Type
struct MapgenV6Params : public MapgenParams { struct MapgenV6Params : public MapgenParams {
u32 spflags; u32 spflags = MGV6_JUNGLES | MGV6_SNOWBIOMES | MGV6_TREES |
float freq_desert; MGV6_BIOMEBLEND | MGV6_MUDFLOW;
float freq_beach; float freq_desert = 0.45f;
float freq_beach = 0.15f;
NoiseParams np_terrain_base; NoiseParams np_terrain_base;
NoiseParams np_terrain_higher; NoiseParams np_terrain_higher;
NoiseParams np_steepness; NoiseParams np_steepness;

View File

@ -122,16 +122,6 @@ MapgenV7::~MapgenV7()
MapgenV7Params::MapgenV7Params() MapgenV7Params::MapgenV7Params()
{ {
spflags = MGV7_MOUNTAINS | MGV7_RIDGES | MGV7_CAVERNS;
cave_width = 0.09;
float_mount_density = 0.6;
float_mount_height = 128.0;
floatland_level = 1280;
shadow_limit = 1024;
cavern_limit = -256;
cavern_taper = 256;
cavern_threshold = 0.7;
np_terrain_base = NoiseParams(4, 70, v3f(600, 600, 600), 82341, 5, 0.6, 2.0); np_terrain_base = NoiseParams(4, 70, v3f(600, 600, 600), 82341, 5, 0.6, 2.0);
np_terrain_alt = NoiseParams(4, 25, v3f(600, 600, 600), 5934, 5, 0.6, 2.0); np_terrain_alt = NoiseParams(4, 25, v3f(600, 600, 600), 5934, 5, 0.6, 2.0);
np_terrain_persist = NoiseParams(0.6, 0.1, v3f(2000, 2000, 2000), 539, 3, 0.6, 2.0); np_terrain_persist = NoiseParams(0.6, 0.1, v3f(2000, 2000, 2000), 539, 3, 0.6, 2.0);

View File

@ -35,15 +35,15 @@ extern FlagDesc flagdesc_mapgen_v7[];
struct MapgenV7Params : public MapgenParams { struct MapgenV7Params : public MapgenParams {
u32 spflags; u32 spflags = MGV7_MOUNTAINS | MGV7_RIDGES | MGV7_CAVERNS;
float cave_width; float cave_width = 0.09f;
float float_mount_density; float float_mount_density = 0.6f;
float float_mount_height; float float_mount_height = 128.0f;
s16 floatland_level; s16 floatland_level = 1280;
s16 shadow_limit; s16 shadow_limit = 1024;
s16 cavern_limit; s16 cavern_limit = -256;
s16 cavern_taper; s16 cavern_taper = 256;
float cavern_threshold; float cavern_threshold = 0.7f;
NoiseParams np_terrain_base; NoiseParams np_terrain_base;
NoiseParams np_terrain_alt; NoiseParams np_terrain_alt;

View File

@ -127,16 +127,6 @@ MapgenValleys::~MapgenValleys()
MapgenValleysParams::MapgenValleysParams() MapgenValleysParams::MapgenValleysParams()
{ {
spflags = MGVALLEYS_HUMID_RIVERS | MGVALLEYS_ALT_CHILL;
altitude_chill = 90; // The altitude at which temperature drops by 20C.
large_cave_depth = -33;
lava_features = 0; // How often water will occur in caves.
massive_cave_depth = -256; // highest altitude of massive caves
river_depth = 4; // How deep to carve river channels.
river_size = 5; // How wide to make rivers.
water_features = 0; // How often water will occur in caves.
cave_width = 0.09;
np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0); np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0);
np_cave2 = NoiseParams(0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0); np_cave2 = NoiseParams(0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0);
np_filler_depth = NoiseParams(0.f, 1.2f, v3f(256, 256, 256), 1605, 3, 0.5f, 2.f); np_filler_depth = NoiseParams(0.f, 1.2f, v3f(256, 256, 256), 1605, 3, 0.5f, 2.f);

View File

@ -46,15 +46,15 @@ class BiomeGenOriginal;
struct MapgenValleysParams : public MapgenParams { struct MapgenValleysParams : public MapgenParams {
u32 spflags; u32 spflags = MGVALLEYS_HUMID_RIVERS | MGVALLEYS_ALT_CHILL;
s16 large_cave_depth; s16 large_cave_depth = -33;
s16 massive_cave_depth; s16 massive_cave_depth = -256; // highest altitude of massive caves
u16 altitude_chill; u16 altitude_chill = 90; // The altitude at which temperature drops by 20C.
u16 lava_features; u16 lava_features = 0; // How often water will occur in caves.
u16 river_depth; u16 river_depth = 4; // How deep to carve river channels.
u16 river_size; u16 river_size = 5; // How wide to make rivers.
u16 water_features; u16 water_features = 0; // How often water will occur in caves.
float cave_width; float cave_width = 0.09f;
NoiseParams np_cave1; NoiseParams np_cave1;
NoiseParams np_cave2; NoiseParams np_cave2;
NoiseParams np_filler_depth; NoiseParams np_filler_depth;

View File

@ -23,11 +23,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serialization.h" #include "serialization.h"
MapSector::MapSector(Map *parent, v2s16 pos, IGameDef *gamedef): MapSector::MapSector(Map *parent, v2s16 pos, IGameDef *gamedef):
differs_from_disk(false),
m_parent(parent), m_parent(parent),
m_pos(pos), m_pos(pos),
m_gamedef(gamedef), m_gamedef(gamedef)
m_block_cache(NULL)
{ {
} }
@ -39,7 +37,7 @@ MapSector::~MapSector()
void MapSector::deleteBlocks() void MapSector::deleteBlocks()
{ {
// Clear cache // Clear cache
m_block_cache = NULL; m_block_cache = nullptr;
// Delete all // Delete all
for (std::unordered_map<s16, MapBlock*>::iterator i = m_blocks.begin(); for (std::unordered_map<s16, MapBlock*>::iterator i = m_blocks.begin();
@ -55,13 +53,13 @@ MapBlock * MapSector::getBlockBuffered(s16 y)
{ {
MapBlock *block; MapBlock *block;
if (m_block_cache != NULL && y == m_block_cache_y) { if (m_block_cache && y == m_block_cache_y) {
return m_block_cache; return m_block_cache;
} }
// If block doesn't exist, return NULL // If block doesn't exist, return NULL
std::unordered_map<s16, MapBlock*>::const_iterator n = m_blocks.find(y); std::unordered_map<s16, MapBlock*>::const_iterator n = m_blocks.find(y);
block = (n != m_blocks.end() ? n->second : NULL); block = (n != m_blocks.end() ? n->second : nullptr);
// Cache the last result // Cache the last result
m_block_cache_y = y; m_block_cache_y = y;
@ -100,7 +98,7 @@ void MapSector::insertBlock(MapBlock *block)
s16 block_y = block->getPos().Y; s16 block_y = block->getPos().Y;
MapBlock *block2 = getBlockBuffered(block_y); MapBlock *block2 = getBlockBuffered(block_y);
if(block2 != NULL){ if (block2) {
throw AlreadyExistsException("Block already exists"); throw AlreadyExistsException("Block already exists");
} }
@ -116,7 +114,7 @@ void MapSector::deleteBlock(MapBlock *block)
s16 block_y = block->getPos().Y; s16 block_y = block->getPos().Y;
// Clear from cache // Clear from cache
m_block_cache = NULL; m_block_cache = nullptr;
// Remove from container // Remove from container
m_blocks.erase(block_y); m_blocks.erase(block_y);

View File

@ -66,7 +66,7 @@ public:
bool empty() const { return m_blocks.empty(); } bool empty() const { return m_blocks.empty(); }
// Always false at the moment, because sector contains no metadata. // Always false at the moment, because sector contains no metadata.
bool differs_from_disk; bool differs_from_disk = false;
protected: protected:
@ -80,8 +80,8 @@ protected:
IGameDef *m_gamedef; IGameDef *m_gamedef;
// Last-used block is cached here for quicker access. // Last-used block is cached here for quicker access.
// Be sure to set this to NULL when the cached block is deleted // Be sure to set this to nullptr when the cached block is deleted
MapBlock *m_block_cache; MapBlock *m_block_cache = nullptr;
s16 m_block_cache_y; s16 m_block_cache_y;
/* /*

View File

@ -683,8 +683,7 @@ void Client::handleCommand_Media(NetworkPacket* pkt)
if (num_files == 0) if (num_files == 0)
return; return;
if (m_media_downloader == NULL || if (!m_media_downloader || !m_media_downloader->isStarted()) {
!m_media_downloader->isStarted()) {
const char *problem = m_media_downloader ? const char *problem = m_media_downloader ?
"media has not been requested" : "media has not been requested" :
"all media has been received already"; "all media has been received already";