aboutsummaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
* Some progress on transitioning from MapBlockObject to ActiveObject.Perttu Ahola2011-04-08
|
* stone shovel now needs cobble, not stone.Perttu Ahola2011-04-06
|
* cleaning notes and stuffPerttu Ahola2011-04-06
|
* Server: Only send node removal/addition to client if client's player is near ↵Perttu Ahola2011-04-06
| | | | it. Otherwise set the modified blocks unsent.
* Made mesh update on node removal asynchronous on client, to reduce frametime ↵Perttu Ahola2011-04-06
| | | | spikes
* Made mesh update on node addition asynchronous on client, to reduce ↵Perttu Ahola2011-04-06
| | | | frametime spikes
* fixed the bug of disabled removal of empty chestsPerttu Ahola2011-04-06
|
* Furnace is now usable. Added more tools.Perttu Ahola2011-04-05
| | | | | | --HG-- rename : data/tool_stpick.png => data/tool_stonepick.png rename : data/tool_wpick.png => data/tool_woodpick.png
* forgot the furnace menu files!Perttu Ahola2011-04-05
|
* A more robust format for node metadataPerttu Ahola2011-04-05
|
* initial workings of the furnacePerttu Ahola2011-04-05
|
* changed node metadata format to better accomodate future needs and problemsPerttu Ahola2011-04-05
|
* Fixed chest contents not immediately updating to all playersPerttu Ahola2011-04-04
|
* Modified windows build parameters a bit to make it buildPerttu Ahola2011-04-04
|
* removed reference to script directory in cmake installPerttu Ahola2011-04-04
|
* Chests work now!Perttu Ahola2011-04-04
|
* initial chest metadataPerttu Ahola2011-04-04
|
* now the server buildsPerttu Ahola2011-04-04
|
* still a missing filePerttu Ahola2011-04-04
|
* forgot some filesPerttu Ahola2011-04-04
|
* fully implemented the sign with the new frameworkPerttu Ahola2011-04-04
|
* Node metadata frameworkPerttu Ahola2011-04-04
|
* Made a proper queued thread to client for handling some block mesh updates. ↵Perttu Ahola2011-04-04
| | | | Also made client mutex-free to allow easier adding of new stuff.
* Modified block mesh generation to have clearer input and output. Instead of ↵Perttu Ahola2011-04-03
| | | | being a messy object oriented cludge, it now is a messy cludge with separate parameters.
* commit before some more radical changesPerttu Ahola2011-04-03
|
* copied draft of updateNodeMeshes from backupPerttu Ahola2011-04-03
|
* Removed lua stuffPerttu Ahola2011-04-03
|
* Revert mapgen to best working version (2)Perttu Ahola2011-04-03
|
* tuned water texture and removed two debug prints from serverPerttu Ahola2011-04-02
|
* Mapgen is better now. Not a lot, but a bit!Perttu Ahola2011-04-02
|
* commit before some radical changesPerttu Ahola2011-04-02
|
* mapgen work-in-progressPerttu Ahola2011-03-02
|
* mapgen tweakingPerttu Ahola2011-03-01
|
* tweaked mapgenPerttu Ahola2011-02-28
|
* fixed server sending wrong position of node removalPerttu Ahola2011-02-28
|
* tweaked mapgenPerttu Ahola2011-02-28
|
* added trees (very glitchy) and changed grass texturePerttu Ahola2011-02-28
|
* -Perttu Ahola2011-02-28
|
* A third try on terrain generation. No trees yet.Perttu Ahola2011-02-28
|
* fixed 3d noise and made 2d noise fasterPerttu Ahola2011-02-27
|
* 3d noise stuffPerttu Ahola2011-02-26
|
* fixed a possible infinite loop in ClientEnvironment (dtime counter getting ↵Perttu Ahola2011-02-24
| | | | so small that it doesn't increment the value)
* modified the build system of lua to a more minimal onePerttu Ahola2011-02-24
|
* fixed a path in build system's packaging partPerttu Ahola2011-02-23
|
* updated scripting api a bitPerttu Ahola2011-02-23
| | | | | | --HG-- rename : data/luaobjects/test/client.lua => data/scripts/objects/test/client.lua rename : data/luaobjects/test/server.lua => data/scripts/objects/test/server.lua
* mainly work on object scripting apiPerttu Ahola2011-02-23
|
* removed an old commentPerttu Ahola2011-02-23
|
* Fixed insufficient error handling in narrow_to_wide, which caused a crash if ↵Perttu Ahola2011-02-23
| | | | the path of the userdata directory contained special characters that were not included in the used charset (which is used because of the font)
* some tidyingPerttu Ahola2011-02-21
|
* preliminary lua scripting framework for objectsPerttu Ahola2011-02-21
|
put() { g_logger.removeOutput(this); } void logRaw(LogLevel lev, const std::string &line) { STATIC_ASSERT(ARRLEN(g_level_to_android) == LL_MAX, mismatch_between_android_and_internal_loglevels); __android_log_print(g_level_to_android[lev], PROJECT_NAME_C, "%s", line.c_str()); } }; AndroidSystemLogOutput g_android_log_output; #endif /////////////////////////////////////////////////////////////////////////////// //// //// Logger //// LogLevel Logger::stringToLevel(const std::string &name) { if (name == "none") return LL_NONE; else if (name == "error") return LL_ERROR; else if (name == "warning") return LL_WARNING; else if (name == "action") return LL_ACTION; else if (name == "info") return LL_INFO; else if (name == "verbose") return LL_VERBOSE; else return LL_MAX; } void Logger::addOutput(ILogOutput *out) { addOutputMaxLevel(out, (LogLevel)(LL_MAX - 1)); } void Logger::addOutput(ILogOutput *out, LogLevel lev) { m_outputs[lev].push_back(out); } void Logger::addOutputMasked(ILogOutput *out, LogLevelMask mask) { for (size_t i = 0; i < LL_MAX; i++) { if (mask & LOGLEVEL_TO_MASKLEVEL(i)) m_outputs[i].push_back(out); } } void Logger::addOutputMaxLevel(ILogOutput *out, LogLevel lev) { assert(lev < LL_MAX); for (size_t i = 0; i <= lev; i++) m_outputs[i].push_back(out); } LogLevelMask Logger::removeOutput(ILogOutput *out) { LogLevelMask ret_mask = 0; for (size_t i = 0; i < LL_MAX; i++) { std::vector<ILogOutput *>::iterator it; it = std::find(m_outputs[i].begin(), m_outputs[i].end(), out); if (it != m_outputs[i].end()) { ret_mask |= LOGLEVEL_TO_MASKLEVEL(i); m_outputs[i].erase(it); } } return ret_mask; } void Logger::setLevelSilenced(LogLevel lev, bool silenced) { m_silenced_levels[lev] = silenced; } void Logger::registerThread(const std::string &name) { threadid_t id = thr_get_current_thread_id(); MutexAutoLock lock(m_mutex); m_thread_names[id] = name; } void Logger::deregisterThread() { threadid_t id = thr_get_current_thread_id(); MutexAutoLock lock(m_mutex); m_thread_names.erase(id); } const std::string Logger::getLevelLabel(LogLevel lev) { static const std::string names[] = { "", "ERROR", "WARNING", "ACTION", "INFO", "VERBOSE", }; assert(lev < LL_MAX && lev >= 0); STATIC_ASSERT(ARRLEN(names) == LL_MAX, mismatch_between_loglevel_names_and_enum); return names[lev]; } const std::string Logger::getThreadName() { std::map<threadid_t, std::string>::const_iterator it; threadid_t id = thr_get_current_thread_id(); it = m_thread_names.find(id); if (it != m_thread_names.end()) return it->second; std::ostringstream os; os << "#0x" << std::hex << id; return os.str(); } void Logger::log(LogLevel lev, const std::string &text) { if (m_silenced_levels[lev]) return; const std::string thread_name = getThreadName(); const std::string label = getLevelLabel(lev); const std::string timestamp = getTimestamp(); std::ostringstream os(std::ios_base::binary); os << timestamp << ": " << label << "[" << thread_name << "]: " << text; logToOutputs(lev, os.str(), timestamp, thread_name, text); } void Logger::logRaw(LogLevel lev, const std::string &text) { if (m_silenced_levels[lev]) return; logToOutputsRaw(lev, text); } void Logger::logToOutputsRaw(LogLevel lev, const std::string &line) { MutexAutoLock lock(m_mutex); for (size_t i = 0; i != m_outputs[lev].size(); i++) m_outputs[lev][i]->logRaw(lev, line); } void Logger::logToOutputs(LogLevel lev, const std::string &combined, const std::string &time, const std::string &thread_name, const std::string &payload_text) { MutexAutoLock lock(m_mutex); for (size_t i = 0; i != m_outputs[lev].size(); i++) m_outputs[lev][i]->log(lev, combined, time, thread_name, payload_text); } //// //// *LogOutput methods //// void FileLogOutput::open(const std::string &filename) { m_stream.open(filename.c_str(), std::ios::app | std::ios::ate); if (!m_stream.good()) throw FileNotGoodException("Failed to open log file " + filename + ": " + strerror(errno)); m_stream << "\n\n" "-------------" << std::endl << " Separator" << std::endl << "-------------\n" << std::endl; } //// //// *Buffer methods //// int StringBuffer::overflow(int c) { push_back(c); return c; } std::streamsize StringBuffer::xsputn(const char *s, std::streamsize n) { for (int i = 0; i < n; ++i) push_back(s[i]); return n; } void StringBuffer::push_back(char c) { if (c == '\n' || c == '\r') { if (buffer_index) flush(std::string(buffer, buffer_index)); buffer_index = 0; } else { int index = buffer_index; buffer[index++] = c; if (index >= BUFFER_LENGTH) { flush(std::string(buffer, buffer_index)); buffer_index = 0; } else { buffer_index = index; } } } void LogBuffer::flush(const std::string &buffer) { logger.log(level, buffer); } void RawLogBuffer::flush(const std::string &buffer) { g_logger.logRaw(LL_NONE, buffer); }