From 45fcc9de29de762e8dde20a50db4a3184c830e42 Mon Sep 17 00:00:00 2001 From: PilzAdam Date: Sat, 18 May 2013 17:00:47 +0200 Subject: New modsystem Mods are placed in $path_/mods They can be enabled per world in world.mt or the configure world window --- src/guiConfigureWorld.cpp | 59 +++++++++-------------------------------------- 1 file changed, 11 insertions(+), 48 deletions(-) (limited to 'src/guiConfigureWorld.cpp') diff --git a/src/guiConfigureWorld.cpp b/src/guiConfigureWorld.cpp index f94ed7d17..e33e87ef5 100644 --- a/src/guiConfigureWorld.cpp +++ b/src/guiConfigureWorld.cpp @@ -116,40 +116,18 @@ GUIConfigureWorld::GUIConfigureWorld(gui::IGUIEnvironment* env, // mod_names if(!mod.is_modpack && mod_names.count(modname) == 0) - m_new_mod_names.insert(modname); + m_settings.setBool("load_mod_"+modname, false); } - if(!m_new_mod_names.empty()) - { - wchar_t* text = wgettext("Warning: Some mods are not configured yet.\n" - "They will be enabled by default when you save the configuration. "); - GUIMessageMenu *menu = - new GUIMessageMenu(Environment, Parent, -1, m_menumgr, text); - menu->drop(); - delete[] text; - } - - // find missing mods (mentioned in world.mt, but not installed) - std::set missing_mods; for(std::set::iterator it = mod_names.begin(); it != mod_names.end(); ++it) { std::string modname = *it; if(m_addonmods.count(modname) == 0) - missing_mods.insert(modname); + m_settings.remove("load_mod_"+modname); } - if(!missing_mods.empty()) - { - wchar_t* text = wgettext("Warning: Some configured mods are missing.\n" - "Their setting will be removed when you save the configuration. "); - GUIMessageMenu *menu = - new GUIMessageMenu(Environment, Parent, -1, m_menumgr, text); - delete[] text; - for(std::set::iterator it = missing_mods.begin(); - it != missing_mods.end(); ++it) - m_settings.remove("load_mod_"+(*it)); - menu->drop(); - } + std::string worldmtfile = m_wspec.path+DIR_DELIM+"world.mt"; + m_settings.updateConfigFile(worldmtfile.c_str()); } void GUIConfigureWorld::drawMenu() @@ -388,11 +366,6 @@ bool GUIConfigureWorld::OnEvent(const SEvent& event) return true; } case GUI_ID_SAVE: { - for(std::set::iterator it = m_new_mod_names.begin(); - it!= m_new_mod_names.end(); ++it) - { - m_settings.setBool("load_mod_"+(*it),true); - } std::string worldmtfile = m_wspec.path+DIR_DELIM+"world.mt"; m_settings.updateConfigFile(worldmtfile.c_str()); @@ -558,22 +531,14 @@ void GUIConfigureWorld::buildTreeView(std::map mods, buildTreeView(mod.modpack_content, new_node); else { - // set icon for node: ? for new mods, x for disabled mods, - // checkmark for enabled mods - if(m_new_mod_names.count(modname) > 0) - { - new_node->setIcon(QUESTIONMARK_STR); - } + // set icon for node: x for disabled mods, checkmark for enabled mods + bool mod_enabled = false; + if(m_settings.exists("load_mod_"+modname)) + mod_enabled = m_settings.getBool("load_mod_"+modname); + if(mod_enabled) + new_node->setIcon(CHECKMARK_STR); else - { - bool mod_enabled = true; - if(m_settings.exists("load_mod_"+modname)) - mod_enabled = m_settings.getBool("load_mod_"+modname); - if(mod_enabled) - new_node->setIcon(CHECKMARK_STR); - else - new_node->setIcon(CROSS_STR); - } + new_node->setIcon(CROSS_STR); } } } @@ -690,7 +655,6 @@ void GUIConfigureWorld::enableMod(std::string modname) m_nodes.find(modname); if(it != m_nodes.end()) (*it).second->setIcon(CHECKMARK_STR); - m_new_mod_names.erase(modname); //also enable all dependencies for(std::set::iterator it=mspec.depends.begin(); it != mspec.depends.end(); ++it) @@ -715,7 +679,6 @@ void GUIConfigureWorld::disableMod(std::string modname) m_nodes.find(modname); if(it != m_nodes.end()) (*it).second->setIcon(CROSS_STR); - m_new_mod_names.erase(modname); //also disable all mods that depend on this one std::pair::iterator, std::multimap::iterator > rdep = -- cgit v1.2.3 From d00e8bd31a185a4000807de6d21eccce9f86671e Mon Sep 17 00:00:00 2001 From: kwolekr Date: Sun, 19 May 2013 21:26:08 -0400 Subject: Fix nearly all warnings --- src/collision.cpp | 2 +- src/emerge.h | 4 ++-- src/environment.cpp | 6 ------ src/guiConfigureWorld.cpp | 2 -- src/guiCreateWorld.cpp | 2 -- src/guiPasswordChange.cpp | 1 - src/guiVolumeChange.cpp | 1 - src/map.cpp | 10 +++++----- src/mapgen_v6.cpp | 2 -- src/mapgen_v7.cpp | 2 -- src/player.h | 2 +- src/scriptapi_env.cpp | 3 +-- src/scriptapi_types.cpp | 2 +- src/test.cpp | 2 +- src/voxel.cpp | 2 +- 15 files changed, 13 insertions(+), 30 deletions(-) (limited to 'src/guiConfigureWorld.cpp') diff --git a/src/collision.cpp b/src/collision.cpp index 673966b6e..3058426eb 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -298,7 +298,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, f32 distance = speed_f.getLength(); std::vector clientobjects; c_env->getActiveObjects(pos_f,distance * 1.5,clientobjects); - for (int i=0; i < clientobjects.size(); i++) + for (size_t i=0; i < clientobjects.size(); i++) { if ((self == 0) || (self != clientobjects[i].obj)) { objects.push_back((ActiveObject*)clientobjects[i].obj); diff --git a/src/emerge.h b/src/emerge.h index fdca93c06..b42e82d38 100644 --- a/src/emerge.h +++ b/src/emerge.h @@ -31,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc., infostream << "EmergeThread: " x << std::endl; } class Mapgen; -class MapgenParams; -class MapgenFactory; +struct MapgenParams; +struct MapgenFactory; class Biome; class BiomeDefManager; class EmergeThread; diff --git a/src/environment.cpp b/src/environment.cpp index e06b032f2..03b8ef7f6 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -910,7 +910,6 @@ void ServerEnvironment::clearAllObjects() if(obj->getType() == ACTIVEOBJECT_TYPE_PLAYER) continue; u16 id = i->first; - v3f objectpos = obj->getBasePosition(); // Delete static object if block is loaded if(obj->m_static_exists){ MapBlock *block = m_map->getBlockNoCreateNoEx(obj->m_static_block); @@ -1031,8 +1030,6 @@ void ServerEnvironment::step(float dtime) // Ignore disconnected players if(player->peer_id == 0) continue; - - v3f playerpos = player->getPosition(); // Move player->move(dtime, *m_map, 100*BS); @@ -2072,8 +2069,6 @@ void ClientEnvironment::step(float dtime) */ { - v3f lplayerpos = lplayer->getPosition(); - // Apply physics if(free_move == false && is_climbing == false) { @@ -2197,7 +2192,6 @@ void ClientEnvironment::step(float dtime) i != m_players.end(); ++i) { Player *player = *i; - v3f playerpos = player->getPosition(); /* Handle non-local players diff --git a/src/guiConfigureWorld.cpp b/src/guiConfigureWorld.cpp index e33e87ef5..8f5ef937d 100644 --- a/src/guiConfigureWorld.cpp +++ b/src/guiConfigureWorld.cpp @@ -165,8 +165,6 @@ void GUIConfigureWorld::regenerateGui(v2u32 screensize) DesiredRect = rect; recalculateAbsolutePosition(false); - v2s32 size = rect.getSize(); - v2s32 topleft = v2s32(10, 10); /* diff --git a/src/guiCreateWorld.cpp b/src/guiCreateWorld.cpp index caa884bc0..9fc764214 100644 --- a/src/guiCreateWorld.cpp +++ b/src/guiCreateWorld.cpp @@ -112,8 +112,6 @@ void GUICreateWorld::regenerateGui(v2u32 screensize) DesiredRect = rect; recalculateAbsolutePosition(false); - v2s32 size = rect.getSize(); - v2s32 topleft = v2s32(10+80, 10+70); /* diff --git a/src/guiPasswordChange.cpp b/src/guiPasswordChange.cpp index a4d16444d..8b55234c2 100644 --- a/src/guiPasswordChange.cpp +++ b/src/guiPasswordChange.cpp @@ -95,7 +95,6 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) v2s32 size = rect.getSize(); v2s32 topleft_client(40, 0); - v2s32 size_client = size - v2s32(40, 0); /* Add stuff diff --git a/src/guiVolumeChange.cpp b/src/guiVolumeChange.cpp index 4e92b82c2..c272b132d 100644 --- a/src/guiVolumeChange.cpp +++ b/src/guiVolumeChange.cpp @@ -96,7 +96,6 @@ void GUIVolumeChange::regenerateGui(v2u32 screensize) v2s32 size = rect.getSize(); v2s32 topleft_client(40, 0); - v2s32 size_client = size - v2s32(40, 0); int volume=(int)(g_settings->getFloat("sound_volume")*100); /* Add stuff diff --git a/src/map.cpp b/src/map.cpp index 821805d4e..d5ab8eb1e 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -288,10 +288,10 @@ void Map::unspreadLight(enum LightBank bank, continue; // Calculate relative position in block - v3s16 relpos = pos - blockpos_last * MAP_BLOCKSIZE; + //v3s16 relpos = pos - blockpos_last * MAP_BLOCKSIZE; // Get node straight from the block - MapNode n = block->getNode(relpos); + //MapNode n = block->getNode(relpos); u8 oldlight = j->second; @@ -937,7 +937,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n, */ v3s16 toppos = p + v3s16(0,1,0); - v3s16 bottompos = p + v3s16(0,-1,0); + //v3s16 bottompos = p + v3s16(0,-1,0); bool node_under_sunlight = true; std::set light_sources; @@ -1246,7 +1246,7 @@ void Map::removeNodeAndUpdate(v3s16 p, // Get the brightest neighbour node and propagate light from it v3s16 n2p = getBrightestNeighbour(bank, p); try{ - MapNode n2 = getNode(n2p); + //MapNode n2 = getNode(n2p); lightNeighbors(bank, n2p, modified_blocks); } catch(InvalidPositionException &e) @@ -2831,7 +2831,7 @@ ServerMapSector * ServerMap::createSector(v2s16 p2d) sector = new ServerMapSector(this, p2d, m_gamedef); // Sector position on map in nodes - v2s16 nodepos2d = p2d * MAP_BLOCKSIZE; + //v2s16 nodepos2d = p2d * MAP_BLOCKSIZE; /* Insert to container diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index e5ff72a60..eaca33988 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -375,8 +375,6 @@ void MapgenV6::makeChunk(BlockMakeData *data) { v3s16 blockpos = data->blockpos_requested; v3s16 blockpos_min = data->blockpos_min; v3s16 blockpos_max = data->blockpos_max; - v3s16 blockpos_full_min = blockpos_min - v3s16(1,1,1); - v3s16 blockpos_full_max = blockpos_max + v3s16(1,1,1); // Area of central chunk node_min = blockpos_min*MAP_BLOCKSIZE; diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index 2fb5d7b9b..6daa5fc6a 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -152,8 +152,6 @@ void MapgenV7::makeChunk(BlockMakeData *data) { v3s16 blockpos_min = data->blockpos_min; v3s16 blockpos_max = data->blockpos_max; - v3s16 blockpos_full_min = blockpos_min - v3s16(1, 1, 1); - v3s16 blockpos_full_max = blockpos_max + v3s16(1, 1, 1); node_min = blockpos_min * MAP_BLOCKSIZE; node_max = (blockpos_max + v3s16(1, 1, 1)) * MAP_BLOCKSIZE - v3s16(1, 1, 1); full_node_min = (blockpos_min - 1) * MAP_BLOCKSIZE; diff --git a/src/player.h b/src/player.h index fade6de01..63e166b4b 100644 --- a/src/player.h +++ b/src/player.h @@ -87,7 +87,7 @@ class Map; class IGameDef; struct CollisionInfo; class PlayerSAO; -class HudElement; +struct HudElement; class Player { diff --git a/src/scriptapi_env.cpp b/src/scriptapi_env.cpp index efed58e66..a9d9391a7 100644 --- a/src/scriptapi_env.cpp +++ b/src/scriptapi_env.cpp @@ -227,7 +227,6 @@ int EnvRef::l_get_node_light(lua_State *L) time_of_day = 24000.0 * lua_tonumber(L, 3); time_of_day %= 24000; u32 dnr = time_to_daynight_ratio(time_of_day, true); - MapNode n = env->getMap().getNodeNoEx(pos); try{ MapNode n = env->getMap().getNode(pos); INodeDefManager *ndef = env->getGameDef()->ndef(); @@ -373,7 +372,7 @@ int EnvRef::l_add_item(lua_State *L) ServerEnvironment *env = o->m_env; if(env == NULL) return 0; // pos - v3f pos = checkFloatPos(L, 2); + //v3f pos = checkFloatPos(L, 2); // item ItemStack item = read_item(L, 3); if(item.empty() || !item.isKnown(get_server(L)->idef())) diff --git a/src/scriptapi_types.cpp b/src/scriptapi_types.cpp index f30451108..f2f6b6bd8 100644 --- a/src/scriptapi_types.cpp +++ b/src/scriptapi_types.cpp @@ -147,7 +147,7 @@ v3s16 check_v3s16(lua_State *L, int index) video::SColor readARGB8(lua_State *L, int index) { - video::SColor color; + video::SColor color(0); luaL_checktype(L, index, LUA_TTABLE); lua_getfield(L, index, "a"); if(lua_isnumber(L, -1)) diff --git a/src/test.cpp b/src/test.cpp index e1dbfa6b8..3a0316e17 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -464,7 +464,7 @@ struct TestCompress: public TestBase std::string str_decompressed = os_decompressed.str(); UTEST(str_decompressed.size() == data_in.size(), "Output size not" " equal (output: %u, input: %u)", - str_decompressed.size(), data_in.size()); + (unsigned int)str_decompressed.size(), (unsigned int)data_in.size()); for(u32 i=0; i