aboutsummaryrefslogtreecommitdiff
path: root/advtrains_line_automation
Commit message (Expand)AuthorAge
* Stoprail: Set LZB checkpoint speed back to 2orwell962021-02-10
* Fix lots of things around new LZBorwell962021-02-10
* Disable ARS train flag and surrounding usesorwell962021-02-10
* Add K command to station railGabriel Pérez-Cerezo2021-01-08
* Fix schedule_in() crash when RWT is not in number format (H#159)orwell962020-10-07
* Make using the default tracks optional, even in submodsBlockhead2020-07-10
* Apply minetest.formspec_escape() to prevent formspec injection (H#143)MT0.4Blockhead2020-01-04
* Fix RWT initialization when creating new world (H#142)orwell962019-12-18
* Fix scheduler crash (H#133)orwell962019-11-21
* Add "discard all" function to scheduler events and use it to clear schedules ...orwell962019-11-06
* lines: fix very dumb typo breaking the "add" and "diff" functionorwell962019-11-06
* lines: Add rwt adapt mode to adapt to real timeorwell962019-11-06
* lines: document scheduler betterorwell962019-11-06
* Secure inputs to scheduler so that they don't get recognised when executing t...orwell962019-08-29
* Add lines scheduler for reliable railway-time scheduling(which is also safer ...orwell962019-08-26
* math.floor triggers error if it gets something nilGabriel Pérez-Cerezo2019-07-20
* Prevent injection of floating-point delays, that wreck advtrainsGabriel Pérez-Cerezo2019-07-20
* Added option to modify departure speed and door delayGabriel Pérez-Cerezo2019-07-20
* RWTs can be specified in any form, unify converters, repeating time handlingorwell962019-06-19
* Omit cycle in to_Stringorwell962019-06-19
* Railway Time: atlatc interface, improve util functionsorwell962019-06-19
* Railway Time: Basic time counter and utility functionsorwell962019-06-19
* Move LZB system to core and unify approach callback mechanismorwell962019-04-16
* Add ARS rules for stop railsorwell962019-02-19
* Move "Reverse" command in stoprail to directly before departureorwell962019-02-19
* Fix stop rails sometimes not sending stop commandorwell962019-02-16
* Small stoprail fixesorwell962019-02-11
* Minor Bugfixesorwell962019-02-03
* Basic functions of "stop rail", missing ARS rules and signal.orwell962019-01-24
* Point speed restriction railsorwell962019-01-24
* Signs (static signals)orwell962018-12-08
* no debugpringorwell962018-11-29
* Added on_train_approach callback, non-permanent external LZB brakepoints and ...orwell962018-11-29
ass="hl opt">, idef), protocol_version(0), m_sao(NULL), m_dirty(false), m_last_chat_message_sent(time(NULL)), m_chat_message_allowance(5.0f), m_message_rate_overhead(0), hud_hotbar_image(""), hud_hotbar_selected_image("") { if (!RemotePlayer::m_setting_cache_loaded) { RemotePlayer::m_setting_chat_message_limit_per_10sec = g_settings->getFloat("chat_message_limit_per_10sec"); RemotePlayer::m_setting_chat_message_limit_trigger_kick = g_settings->getU16("chat_message_limit_trigger_kick"); RemotePlayer::m_setting_cache_loaded = true; } movement_acceleration_default = g_settings->getFloat("movement_acceleration_default") * BS; movement_acceleration_air = g_settings->getFloat("movement_acceleration_air") * BS; movement_acceleration_fast = g_settings->getFloat("movement_acceleration_fast") * BS; movement_speed_walk = g_settings->getFloat("movement_speed_walk") * BS; movement_speed_crouch = g_settings->getFloat("movement_speed_crouch") * BS; movement_speed_fast = g_settings->getFloat("movement_speed_fast") * BS; movement_speed_climb = g_settings->getFloat("movement_speed_climb") * BS; movement_speed_jump = g_settings->getFloat("movement_speed_jump") * BS; movement_liquid_fluidity = g_settings->getFloat("movement_liquid_fluidity") * BS; movement_liquid_fluidity_smooth = g_settings->getFloat("movement_liquid_fluidity_smooth") * BS; movement_liquid_sink = g_settings->getFloat("movement_liquid_sink") * BS; movement_gravity = g_settings->getFloat("movement_gravity") * BS; } void RemotePlayer::save(std::string savedir, IGameDef *gamedef) { /* * We have to open all possible player files in the players directory * and check their player names because some file systems are not * case-sensitive and player names are case-sensitive. */ // A player to deserialize files into to check their names RemotePlayer testplayer("", gamedef->idef()); savedir += DIR_DELIM; std::string path = savedir + m_name; for (u32 i = 0; i < PLAYER_FILE_ALTERNATE_TRIES; i++) { if (!fs::PathExists(path)) { // Open file and serialize std::ostringstream ss(std::ios_base::binary); serialize(ss); if (!fs::safeWriteToFile(path, ss.str())) { infostream << "Failed to write " << path << std::endl; } setModified(false); return; } // Open file and deserialize std::ifstream is(path.c_str(), std::ios_base::binary); if (!is.good()) { infostream << "Failed to open " << path << std::endl; return; } testplayer.deSerialize(is, path, NULL); is.close(); if (strcmp(testplayer.getName(), m_name) == 0) { // Open file and serialize std::ostringstream ss(std::ios_base::binary); serialize(ss); if (!fs::safeWriteToFile(path, ss.str())) { infostream << "Failed to write " << path << std::endl; } setModified(false); return; } path = savedir + m_name + itos(i); } infostream << "Didn't find free file for player " << m_name << std::endl; return; } void RemotePlayer::deSerialize(std::istream &is, const std::string &playername, PlayerSAO *sao) { Settings args; if (!args.parseConfigLines(is, "PlayerArgsEnd")) { throw SerializationError("PlayerArgsEnd of player " + playername + " not found!"); } m_dirty = true; //args.getS32("version"); // Version field value not used std::string name = args.get("name"); strlcpy(m_name, name.c_str(), PLAYERNAME_SIZE); if (sao) { try { sao->setHPRaw(args.getS32("hp")); } catch(SettingNotFoundException &e) { sao->setHPRaw(PLAYER_MAX_HP); } try { sao->setBasePosition(args.getV3F("position")); } catch (SettingNotFoundException &e) {} try { sao->setPitch(args.getFloat("pitch")); } catch (SettingNotFoundException &e) {} try { sao->setYaw(args.getFloat("yaw")); } catch (SettingNotFoundException &e) {} try { sao->setBreath(args.getS32("breath"), false); } catch (SettingNotFoundException &e) {} } inventory.deSerialize(is); if (inventory.getList("craftpreview") == NULL) { // Convert players without craftpreview inventory.addList("craftpreview", 1); bool craftresult_is_preview = true; if(args.exists("craftresult_is_preview")) craftresult_is_preview = args.getBool("craftresult_is_preview"); if(craftresult_is_preview) { // Clear craftresult inventory.getList("craftresult")->changeItem(0, ItemStack()); } } } void RemotePlayer::serialize(std::ostream &os) { // Utilize a Settings object for storing values Settings args; args.setS32("version", 1); args.set("name", m_name); //args.set("password", m_password); // This should not happen assert(m_sao); args.setS32("hp", m_sao->getHP()); args.setV3F("position", m_sao->getBasePosition()); args.setFloat("pitch", m_sao->getPitch()); args.setFloat("yaw", m_sao->getYaw()); args.setS32("breath", m_sao->getBreath()); args.writeLines(os); os<<"PlayerArgsEnd\n"; inventory.serialize(os); } const RemotePlayerChatResult RemotePlayer::canSendChatMessage() { // Rate limit messages u32 now = time(NULL); float time_passed = now - m_last_chat_message_sent; m_last_chat_message_sent = now; // If this feature is disabled if (m_setting_chat_message_limit_per_10sec <= 0.0) { return RPLAYER_CHATRESULT_OK; } m_chat_message_allowance += time_passed * (m_setting_chat_message_limit_per_10sec / 8.0f); if (m_chat_message_allowance > m_setting_chat_message_limit_per_10sec) { m_chat_message_allowance = m_setting_chat_message_limit_per_10sec; } if (m_chat_message_allowance < 1.0f) { infostream << "Player " << m_name << " chat limited due to excessive message amount." << std::endl; // Kick player if flooding is too intensive m_message_rate_overhead++; if (m_message_rate_overhead > RemotePlayer::m_setting_chat_message_limit_trigger_kick) { return RPLAYER_CHATRESULT_KICK; } return RPLAYER_CHATRESULT_FLOODING; } // Reinit message overhead if (m_message_rate_overhead > 0) { m_message_rate_overhead = 0; } m_chat_message_allowance -= 1.0f; return RPLAYER_CHATRESULT_OK; }