void Client::typeChatMessage(const std::wstring &message) { // Discard empty line if (message.empty()) return; // If message was ate by script API, don't send it to server if (m_script->on_sending_message(wide_to_utf8(message))) { return; } // Send to others sendChatMessage(message); // Show locally if (message[0] != L'/') { // compatibility code if (m_proto_ver < 29) { LocalPlayer *player = m_env.getLocalPlayer(); assert(player); std::wstring name = narrow_to_wide(player->getName()); pushToChatQueue(new ChatMessage(CHATMESSAGE_TYPE_NORMAL, message, name)); } } }
void Client::makeScreenshot() { irr::video::IVideoDriver *driver = RenderingEngine::get_video_driver(); irr::video::IImage* const raw_image = driver->createScreenShot(); if (!raw_image) return; time_t t = time(NULL); struct tm *tm = localtime(&t); char timetstamp_c[64]; strftime(timetstamp_c, sizeof(timetstamp_c), "%Y%m%d_%H%M%S", tm); std::string filename_base = g_settings->get("screenshot_path") + DIR_DELIM + std::string("screenshot_") + std::string(timetstamp_c); std::string filename_ext = "." + g_settings->get("screenshot_format"); std::string filename; u32 quality = (u32)g_settings->getS32("screenshot_quality"); quality = MYMIN(MYMAX(quality, 0), 100) / 100.0 * 255; // Try to find a unique filename unsigned serial = 0; while (serial < SCREENSHOT_MAX_SERIAL_TRIES) { filename = filename_base + (serial > 0 ? ("_" + itos(serial)) : "") + filename_ext; std::ifstream tmp(filename.c_str()); if (!tmp.good()) break; // File did not apparently exist, we'll go with it serial++; } if (serial == SCREENSHOT_MAX_SERIAL_TRIES) { infostream << "Could not find suitable filename for screenshot" << std::endl; } else { irr::video::IImage* const image = driver->createImage(video::ECF_R8G8B8, raw_image->getDimension()); if (image) { raw_image->copyTo(image); std::ostringstream sstr; if (driver->writeImageToFile(image, filename.c_str(), quality)) { sstr << "Saved screenshot to '" << filename << "'"; } else { sstr << "Failed to save screenshot '" << filename << "'"; } pushToChatQueue(new ChatMessage(CHATMESSAGE_TYPE_SYSTEM, narrow_to_wide(sstr.str()))); infostream << sstr.str() << std::endl; image->drop(); } } raw_image->drop(); }
void Client::handleCommand_DenySudoMode(NetworkPacket* pkt) { ChatMessage *chatMessage = new ChatMessage(CHATMESSAGE_TYPE_SYSTEM, L"Password change denied. Password NOT changed."); pushToChatQueue(chatMessage); // reset everything and be sad deleteAuthData(); }