aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
Commit message (Expand)AuthorAge
...
* some tinkering aroundPerttu Ahola2010-12-25
* slight map generation bugsPerttu Ahola2010-12-25
* builds on both platformsPerttu Ahola2010-12-25
* minecraft-like craftingPerttu Ahola2010-12-25
* disconnect method to connection to be used instead of just timing outPerttu Ahola2010-12-24
* ProgressBarTextureModPerttu Ahola2010-12-24
* small segfault bug fixPerttu Ahola2010-12-24
* base stuff for item->object conversionPerttu Ahola2010-12-24
* changes to handing of digging (non backwards-compatible i guess)Perttu Ahola2010-12-23
* little tinkeringPerttu Ahola2010-12-23
* work-in-progress gui system updating + some settings system updatingPerttu Ahola2010-12-23
* redoing gui stuffPerttu Ahola2010-12-23
* fixed crack animation timing in clientPerttu Ahola2010-12-23
* a mutex added to TempMods which hopefully fixes rare segfaults on clientPerttu Ahola2010-12-23
* added fog to playersPerttu Ahola2010-12-22
* crafting system!Perttu Ahola2010-12-22
* just savin'Perttu Ahola2010-12-22
* some work-in-progressPerttu Ahola2010-12-22
* organizing stuff.Perttu Ahola2010-12-21
* Cracking blocks while diggingPerttu Ahola2010-12-21
* framework for modifying texturesPerttu Ahola2010-12-20
* some tinkering with gui. removed updating of configuration file at endPerttu Ahola2010-12-20
* working time-of-day sending from server to clientPerttu Ahola2010-12-20
* added dedicated server build without irrlichtPerttu Ahola2010-12-19
* day/night working client sidePerttu Ahola2010-12-19
* before adding day/night lightingPerttu Ahola2010-12-18
* settings manager: better default setting handling and updating config file an...Perttu Ahola2010-12-14
* tinkering aroundPerttu Ahola2010-12-14
* pause menu addedPerttu Ahola2010-12-14
* little fixesPerttu Ahola2010-12-14
* better graphics, zlib to work on vc++Perttu Ahola2010-12-14
* in before messing with face drawing orientationPerttu Ahola2010-12-14
* commit before content-tile separationPerttu Ahola2010-12-13
* working nicelyPerttu Ahola2010-12-13
* starting to separate "material" to "content" and "tile"Perttu Ahola2010-12-12
* commit before some radicallish changes to water behaviorPerttu Ahola2010-12-11
* some work-in-progress water stuffPerttu Ahola2010-12-01
* better waterPerttu Ahola2010-11-30
* doc updatePerttu Ahola2010-11-29
* testPerttu Ahola2010-11-29
* default setting change, random tinkeringPerttu Ahola2010-11-29
* Windows bug fixesPerttu Ahola2010-11-29
* fixed face updating slowness bugPerttu Ahola2010-11-29
* sitä sun tätä tekeillä, toimii kivastiPerttu Ahola2010-11-29
* Working version before block send priorization updatePerttu Ahola2010-11-27
* Initial filesPerttu Ahola2010-11-27
LOCALEID, LOCALE_SENGLISHLANGUAGENAME, buffer, LOCALE_NAME_MAX_LENGTH); std::wstring languagename = buffer; /* set both short and long variant */ glb_supported_locales[name] = languagename; glb_supported_locales[name + L"_" + country] = languagename; } return true; } /******************************************************************************/ const char* MSVC_LocaleLookup(const char* raw_shortname) { /* NULL is used to read locale only so we need to return it too */ if (raw_shortname == NULL) return NULL; std::string shortname(raw_shortname); if (shortname == "C") return "C"; if (shortname == "") return ""; static std::string last_raw_value = ""; static std::string last_full_name = ""; static bool first_use = true; if (last_raw_value == shortname) { return last_full_name.c_str(); } if (first_use) { EnumSystemLocalesA(UpdateLocaleCallback, LCID_SUPPORTED | LCID_ALTERNATE_SORTS); first_use = false; } last_raw_value = shortname; if (glb_supported_locales.find(utf8_to_wide(shortname)) != glb_supported_locales.end()) { last_full_name = wide_to_utf8( glb_supported_locales[utf8_to_wide(shortname)]); return last_full_name.c_str(); } /* empty string is system default */ errorstream << "MSVC_LocaleLookup: unsupported locale: \"" << shortname << "\" switching to system default!" << std::endl; return ""; } #endif /******************************************************************************/ void init_gettext(const char *path, const std::string &configured_language, int argc, char *argv[]) { #if USE_GETTEXT // First, try to set user override environment if (!configured_language.empty()) { #ifndef _WIN32 // Add user specified locale to environment setenv("LANGUAGE", configured_language.c_str(), 1); // Reload locale with changed environment setlocale(LC_ALL, ""); #elif defined(_MSC_VER) std::string current_language; const char *env_lang = getenv("LANGUAGE"); if (env_lang) current_language = env_lang; _putenv(("LANGUAGE=" + configured_language).c_str()); SetEnvironmentVariableA("LANGUAGE", configured_language.c_str()); #ifndef SERVER // Hack to force gettext to see the right environment if (current_language != configured_language) { errorstream << "MSVC localization workaround active. " "Restarting " PROJECT_NAME_C " in a new environment!" << std::endl; std::string parameters; for (unsigned int i = 1; i < argc; i++) { if (!parameters.empty()) parameters += ' '; parameters += argv[i]; } const char *ptr_parameters = NULL; if (!parameters.empty()) ptr_parameters = parameters.c_str(); // Allow calling without an extension std::string app_name = argv[0]; if (app_name.compare(app_name.size() - 4, 4, ".exe") != 0) app_name += ".exe"; STARTUPINFO startup_info = {0}; PROCESS_INFORMATION process_info = {0}; bool success = CreateProcess(app_name.c_str(), (char *)ptr_parameters, NULL, NULL, false, DETACHED_PROCESS | CREATE_UNICODE_ENVIRONMENT, NULL, NULL, &startup_info, &process_info); if (success) { exit(0); // NOTREACHED } else { char buffer[1024]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), buffer, sizeof(buffer) - 1, NULL); errorstream << "*******************************************************" << std::endl; errorstream << "CMD: " << app_name << std::endl; errorstream << "Failed to restart with current locale: " << std::endl; errorstream << buffer; errorstream << "Expect language to be broken!" << std::endl; errorstream << "*******************************************************" << std::endl; } } #else errorstream << "*******************************************************" << std::endl; errorstream << "Can't apply locale workaround for server!" << std::endl; errorstream << "Expect language to be broken!" << std::endl; errorstream << "*******************************************************" << std::endl; #endif setlocale(LC_ALL, configured_language.c_str()); #else // Mingw _putenv(("LANGUAGE=" + configured_language).c_str()); setlocale(LC_ALL, ""); #endif // ifndef _WIN32 } else { /* set current system default locale */ setlocale(LC_ALL, ""); } #if defined(_WIN32) if (getenv("LANGUAGE") != 0) { setlocale(LC_ALL, getenv("LANGUAGE")); } #ifdef _MSC_VER else if (getenv("LANG") != 0) { setlocale(LC_ALL, getenv("LANG")); } #endif #endif static std::string name = lowercase(PROJECT_NAME); bindtextdomain(name.c_str(), path); textdomain(name.c_str()); #if defined(_WIN32) // Set character encoding for Win32 char *tdomain = textdomain( (char *) NULL ); if( tdomain == NULL ) { errorstream << "Warning: domainname parameter is the null pointer" << ", default domain is not set" << std::endl; tdomain = (char *) "messages"; } /* char *codeset = */bind_textdomain_codeset( tdomain, "UTF-8" ); //errorstream << "Gettext debug: domainname = " << tdomain << "; codeset = "<< codeset << std::endl; #endif // defined(_WIN32) #else /* set current system default locale */ setlocale(LC_ALL, ""); #endif // if USE_GETTEXT /* no matter what locale is used we need number format to be "C" */ /* to ensure formspec parameters are evaluated correct! */ setlocale(LC_NUMERIC, "C"); infostream << "Message locale is now set to: " << setlocale(LC_ALL, 0) << std::endl; }