summaryrefslogtreecommitdiff
path: root/src/main.cpp
Commit message (Expand)AuthorAge
* New world removal GUI codePerttu Ahola2012-03-26
* Make server world selection not brain dead and use gameid 'minetest' instead ...Perttu Ahola2012-03-25
* Add output levels --info and --trace (--verbose is now more verbose)Perttu Ahola2012-03-22
* Flatten share/ and user/ in the source and for the RUN_IN_PLACE buildPerttu Ahola2012-03-20
* Rework directory structurePerttu Ahola2012-03-19
* Create main menu tab "Settings" for client settingsPerttu Ahola2012-03-15
* Add "simple singleplayer mode"; Fix a number of GUI thingsPerttu Ahola2012-03-15
* Save selected tabPerttu Ahola2012-03-15
* Add [new] to world name when supplying a non-existent world on command linePerttu Ahola2012-03-13
* Allow directly supplying world as a parameter, including world.mtPerttu Ahola2012-03-13
* Add confirmation menu and make world deletion possible in GUIPerttu Ahola2012-03-13
* World creation button and dialog and functionalityPerttu Ahola2012-03-13
* Remember selected world by pathPerttu Ahola2012-03-12
* Make finish quicktune and leave it unused (as intended)Perttu Ahola2012-03-12
* Handle certain errors properly when using --goPerttu Ahola2012-03-11
* Use default_game when making a new world using --world without --gameidPerttu Ahola2012-03-11
* World selection box in main menu (and random fixing)Perttu Ahola2012-03-11
* --world implies local gamePerttu Ahola2012-03-11
* --logfile '' = no loggingPerttu Ahola2012-03-11
* Remove useless debug output (log at info level)Perttu Ahola2012-03-11
* --gameid listPerttu Ahola2012-03-11
* command-line/world game selectionPerttu Ahola2012-03-11
* Improve command-line parametersPerttu Ahola2012-03-11
* Prettify --help outputPerttu Ahola2012-03-11
* Move huge comment from the beginning of main.cpp to doc/ancient_main_comment.txtPerttu Ahola2012-03-11
* --verbose, not --info-on-stderrPerttu Ahola2012-03-11
* Clean up log messages everywherePerttu Ahola2012-03-11
* Fix configuration file behaviourPerttu Ahola2012-03-11
* Chat console, including a number of rebases and modifications.Kahrl2012-03-10
* Tidy up server log output a bitPerttu Ahola2012-03-10
* Remove servermain.cpp, use main.cpp with a couple of #ifdefs insteadPerttu Ahola2012-03-10
* Fix addon and configuration file pathsPerttu Ahola2012-03-10
* Initial directory structure reworkPerttu Ahola2012-03-10
* Digging time groups WIPPerttu Ahola2012-03-10
* Add descriptions to command line argumentsJuhani Numminen2012-02-28
* Node placement / mineral / serialization / iron freq / node_dig callbackKahrl2012-01-22
* On SIGINT in main menu, don't connect before shutting downPerttu Ahola2011-12-03
* Note about debug.txt in error message dialog when mod fails to loadPerttu Ahola2011-12-03
* Better mod loading error handlingPerttu Ahola2011-12-03
* Rename menu background to menubg.png, move unknown_block.png and unknown_obje...Perttu Ahola2011-11-29
* Remove content_mapnode.h and nodedef.h #includesPerttu Ahola2011-11-29
* GameDef compilesPerttu Ahola2011-11-29
* Create framework for getting rid of global definitions of node/tool/item/what...Perttu Ahola2011-11-29
* Move ContentFeatures to mapnode_contentfeatures.{h,cpp} and clean stuffPerttu Ahola2011-11-29
* Add option to set water opaque (mainly for stylistic choice)Perttu Ahola2011-11-03
* Disable mipmapping because it is sometimes uglyPerttu Ahola2011-11-03
* Add 3d cloud checkbox in main menu (and rename setting from enable_2d_clouds ...Perttu Ahola2011-11-02
* Improve Connection with threading and some kind of congestion controlPerttu Ahola2011-10-20
* Automate texture listing for texture atlas makingPerttu Ahola2011-10-18
* Fix partly double printed debug.txtceleron552011-10-17
lass="hl com">/* NodeMetadataList */ void NodeMetadataList::serialize(std::ostream &os) const { /* Version 0 is a placeholder for "nothing to see here; go away." */ if(m_data.empty()){ writeU8(os, 0); // version return; } writeU8(os, 1); // version u16 count = m_data.size(); writeU16(os, count); for(std::map<v3s16, NodeMetadata*>::const_iterator i = m_data.begin(); i != m_data.end(); i++) { v3s16 p = i->first; NodeMetadata *data = i->second; u16 p16 = p.Z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + p.Y*MAP_BLOCKSIZE + p.X; writeU16(os, p16); data->serialize(os); } } void NodeMetadataList::deSerialize(std::istream &is, IGameDef *gamedef) { clear(); u8 version = readU8(is); if(version == 0){ // Nothing return; } if(version != 1){ infostream<<__FUNCTION_NAME<<": version "<<version<<" not supported" <<std::endl; throw SerializationError("NodeMetadataList::deSerialize"); } u16 count = readU16(is); for(u16 i=0; i<count; i++) { u16 p16 = readU16(is); v3s16 p; p.Z = p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE; p16 &= MAP_BLOCKSIZE * MAP_BLOCKSIZE - 1; p.Y = p16 / MAP_BLOCKSIZE; p16 &= MAP_BLOCKSIZE - 1; p.X = p16; if(m_data.find(p) != m_data.end()) { infostream<<"WARNING: NodeMetadataList::deSerialize(): " <<"already set data at position" <<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring." <<std::endl; continue; } NodeMetadata *data = new NodeMetadata(gamedef); data->deSerialize(is); m_data[p] = data; } } NodeMetadataList::~NodeMetadataList() { clear(); } std::vector<v3s16> NodeMetadataList::getAllKeys() { std::vector<v3s16> keys; std::map<v3s16, NodeMetadata *>::const_iterator it; for (it = m_data.begin(); it != m_data.end(); ++it) keys.push_back(it->first); return keys; } NodeMetadata *NodeMetadataList::get(v3s16 p) { std::map<v3s16, NodeMetadata *>::const_iterator n = m_data.find(p); if (n == m_data.end()) return NULL; return n->second; } void NodeMetadataList::remove(v3s16 p) { NodeMetadata *olddata = get(p); if (olddata) { delete olddata; m_data.erase(p); } } void NodeMetadataList::set(v3s16 p, NodeMetadata *d) { remove(p); m_data.insert(std::make_pair(p, d)); } void NodeMetadataList::clear() { std::map<v3s16, NodeMetadata*>::iterator it; for (it = m_data.begin(); it != m_data.end(); ++it) { delete it->second; } m_data.clear(); } std::string NodeMetadata::getString(const std::string &name, unsigned short recursion) const { StringMap::const_iterator it = m_stringvars.find(name); if (it == m_stringvars.end()) return ""; return resolveString(it->second, recursion); } void NodeMetadata::setString(const std::string &name, const std::string &var) { if (var.empty()) { m_stringvars.erase(name); } else { m_stringvars[name] = var; } } std::string NodeMetadata::resolveString(const std::string &str, unsigned short recursion) const { if (recursion > 1) { return str; } if (str.substr(0, 2) == "${" && str[str.length() - 1] == '}') { return getString(str.substr(2, str.length() - 3), recursion + 1); } return str; }