diff --git a/CMakeLists.txt b/CMakeLists.txt index 432d8c6c5..0cfff99c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,15 +82,9 @@ include(RequireCXXSourceCompiles) CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" USE_GCC_STD_0X) if(USE_GCC_STD_0X) list(APPEND OC_CXX_FLAGS "-std=gnu++0x") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") endif() -# Convert the OC_CXX_FLAGS list to a CMAKE_CXX_FLAGS string -foreach(FLAG ${OC_CXX_FLAGS}) - set(OC_REQUIRED_FLAGS "${OC_REQUIRED_FLAGS} ${FLAG}") -endforeach() - -set(CMAKE_CXX_FLAGS ${OC_REQUIRED_FLAGS}) - REQUIRE_CXX_SOURCE_COMPILES("#include \nint main() { std::unique_ptr a; std::shared_ptr b; }" HAVE_C11_SMART_PTRS) CHECK_CXX_SOURCE_COMPILES("void f(struct D&&); int main() { return 0; }" HAVE_RVALUE_REF) CHECK_CXX_SOURCE_COMPILES("int main() { void *d = nullptr; }" HAVE_NULLPTR) @@ -1135,7 +1129,7 @@ if(UNIX AND NOT APPLE) endif() endif() set_property(TARGET openclonk APPEND PROPERTY COMPILE_DEFINITIONS GLEW_STATIC) -#set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG _DEBUG) +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:_DEBUG>) # This expands some variables in Info.plist as a side-effect. XCode might then # expand a second time, using the same syntax. Try not to get confused by this! @@ -1164,12 +1158,6 @@ if(MSVC) set_property(TARGET openclonk APPEND PROPERTY LINK_FLAGS "/MANIFEST:NO") endif() -# Suppress the console window for mape even though only a main() and not -# a WinMain() entry point is provided. -if(MINGW) - set_target_properties(mape PROPERTIES LINK_FLAGS -mwindows) -endif() - ############################################################################ # Precompiled header support, part 2 (post-target) ############################################################################ @@ -1286,15 +1274,6 @@ endif() CHECK_INCLUDE_FILE_CXX(getopt.h HAVE_GETOPT_H) -find_package(ICONV) -if(ICONV_FOUND) - set(HAVE_ICONV true) - target_link_libraries(openclonk ${ICONV_LIBRARIES}) - if(ICONV_IS_CONST) - set(ICONV_CONST "const") - endif() -endif() - # TinyXML if(WITH_SYSTEM_TINYXML) pkg_search_module(TINYXML REQUIRED tinyxml) @@ -1372,6 +1351,11 @@ if (WIN32) target_link_libraries(c4script ws2_32 winmm) if(MAPE_GTK_FOUND) target_link_libraries(mape winmm) + # Suppress the console window for mape even though only a main() and not + # a WinMain() entry point is provided. + if(MINGW) + set_target_properties(mape PROPERTIES LINK_FLAGS -mwindows) + endif() endif() endif() diff --git a/cmake/FindICONV.cmake b/cmake/FindICONV.cmake deleted file mode 100644 index ad8e9f74a..000000000 --- a/cmake/FindICONV.cmake +++ /dev/null @@ -1,62 +0,0 @@ -# - Try to find Iconv -# Once done this will define -# -# ICONV_FOUND - system has Iconv -# ICONV_INCLUDE_DIR - the Iconv include directory -# ICONV_LIBRARIES - Link these to use Iconv -# ICONV_IS_CONST - the second argument for iconv() is const -# -# This was mostly borrowed from Strigi. LyX also has a (quite -# different) FindICONV: the one in LyX does not check -# second_argument_is_const, but seems to have more fleshed-out support -# for WIN32. There may need to be some merging done. -# Tim Holy, 2008-05-07 - -include(CheckCXXSourceCompiles) - -IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) - # Already in cache, be silent - SET(ICONV_FIND_QUIETLY TRUE) -ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) - -FIND_PATH(ICONV_INCLUDE_DIR iconv.h - /Developer/SDKs/MacOSX10.4u.sdk/usr/include/iconv.h - /Developer/SDKs/MacOSX10.5.sdk/usr/include/iconv.h - /usr/include -) - -FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv2 c - PATHS - /Developer/SDKs/MacOSX10.4u.sdk/usr/lib - /Developer/SDKs/MacOSX10.5.sdk/usr/lib - /usr/lib -) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ICONV REQUIRED_VARS ICONV_LIBRARIES ICONV_INCLUDE_DIR) - -IF(ICONV_FOUND) - set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) - check_cxx_source_compiles(" - #include - int main(){ - iconv_t conv = 0; - const char* in = 0; - size_t ilen = 0; - char* out = 0; - size_t olen = 0; - iconv(conv, &in, &ilen, &out, &olen); - return 0; - } -" ICONV_IS_CONST ) - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_LIBRARIES) -ENDIF(ICONV_FOUND) - -MARK_AS_ADVANCED( - ICONV_INCLUDE_DIR - ICONV_LIBRARIES - ICONV_IS_CONST -) - diff --git a/config.h.cmake b/config.h.cmake index 2c40f049e..d4df94551 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -10,9 +10,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_HISTORY_H 1 -/* Define if you have the iconv() function. */ -#cmakedefine HAVE_ICONV 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H 1 @@ -117,9 +114,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_X11_KEYSYM_H 1 -/* Define as const if the declaration of iconv() needs const. */ -#define ICONV_CONST @ICONV_CONST@ - /* compile without debug options */ #cmakedefine NDEBUG 1 diff --git a/planet/System.ocg/LanguageDE.txt b/planet/System.ocg/LanguageDE.txt index 0e7111ebf..1c2bc90a5 100644 --- a/planet/System.ocg/LanguageDE.txt +++ b/planet/System.ocg/LanguageDE.txt @@ -23,7 +23,6 @@ IDS_BTN_RELOAD=&Aktualisieren IDS_BTN_RENAME=Umbenennen IDS_BTN_RESET=Zurücksetzen IDS_BTN_RESETCONFIG=Konfiguration zurücksetzen -IDS_BTN_RESETKEYBOARD=Alle zurücksetzen IDS_BTN_RESTART=Neu &Starten IDS_BTN_RETRY=Wiederholen IDS_BTN_START=Starten @@ -117,7 +116,6 @@ IDS_CTL_FRONTEND=Menüsystem IDS_CTL_FULLSCREENMODE=Fenstermodus IDS_CTL_GAME=Spiel IDS_CTL_GAMEFUNCTIONS=Spielfunktionen -IDS_CTL_GAMEPADFORMENU=Gamepad zur Menüsteuerung verwenden. IDS_CTL_GAMESPEEDUP=Spielgeschwindigkeit erhöhen IDS_CTL_GAMESPEEDDOWN=Spielgeschwindigkeit verringern IDS_CTL_GFXENGINE=Grafiktreiber @@ -195,7 +193,6 @@ IDS_DESC_ENDTHEROUND=Die Runde beenden. IDS_DESC_EXPECTING=Teilnehmer werden erwartet. IDS_DESC_FONTSIZE=Schriftgröße auswählen. Bei Wechsel der Bildschirmauflösung wird die Schriftgröße automatisch angepasst. IDS_DESC_GAMEMUSIC=Steuert Hintergrundmusik im Spiel. -IDS_DESC_GAMEPADFORMENU=Mit dieser Option kann das Gamepad für die Steuerung des Menüsystems verwendet werden. IDS_DESC_GAMEPAUSED=Spiel ist pausiert IDS_DESC_GAMERUNNING=Spiel läuft IDS_DESC_GAMESOUND=Steuert Geräuscheffekte im Spiel. @@ -235,13 +232,11 @@ IDS_DLGTIP_CANCEL=Aktion abbrechen. IDS_DLGTIP_CHANGECTRL=Wähle eine Steuerung aus um sie anzusehen und zu ändern IDS_DLGTIP_CHAT=Hier Chat-Nachrichten eintippen und mit Enter bestätigen IDS_DLGTIP_CHATWIN=Nachrichten -IDS_DLGTIP_CLASSIC=Clonks laufen weiter, bis sie mit 'Stop' angehalten werden. IDS_DLGTIP_CLEAR=Löscht die Auswahl IDS_DLGTIP_COPY=Kopiert die Auswahl in die Zwischenablage IDS_DLGTIP_CUT=Schneidet die Auswahl aus und kopiert sie in die Zwischenablage IDS_DLGTIP_EXIT=Beendet das Programm. IDS_DLGTIP_GAMEGO=Startet das Spiel. -IDS_DLGTIP_JUMPANDRUN=Clonks halten bei losgelassener Taste an. IDS_DLGTIP_NETWORKGAME=Startet ein Netzwerkspiel oder tritt einem laufenden Netzwerkspiel bei. IDS_DLGTIP_NEWPLAYER=Erzeugt eine neue Spielerdatei. IDS_DLGTIP_OK2=Aktion bestätigen. @@ -272,7 +267,6 @@ IDS_DLG_ABORT=Abbruch IDS_DLG_ABOUT=&Credits IDS_DLG_CANCEL=&Abbrechen IDS_DLG_CHAT=Chat -IDS_DLG_CLASSIC=Klassisch IDS_DLG_CLEAR=Löschen IDS_DLG_CLOSE=&Schließen IDS_DLG_CONTROLS=Steuerung @@ -286,10 +280,8 @@ IDS_DLG_EXACT=Exakte Landschaft IDS_DLG_EXIT=&Beenden IDS_DLG_GAME=Spiel IDS_DLG_GAMEGO=&Starten -IDS_DLG_GAMEPAD=Gamepad IDS_DLG_GRAPHICS=Grafik IDS_DLG_INVALIDENTRY=Ungültige Angaben -IDS_DLG_JUMPANDRUN=Jump'n'Run IDS_DLG_LEAGUESIGNUP=Liga-Anmeldung IDS_DLG_LEAGUESIGNUPCONFIRM=Bestätigung der Liga-Anmeldung IDS_DLG_LEAGUESIGNUPFAILED=Liga-Anmeldung fehlgeschlagen @@ -297,7 +289,6 @@ IDS_DLG_LEAGUESIGNUPON=Liga-Anmeldung auf %s IDS_DLG_LOBBY=Lobby IDS_DLG_LOG=Fehlermeldungen IDS_DLG_MISSIONACCESS=Missionszugang -IDS_DLG_MOVEMENT=Bewegung IDS_DLG_NETSTART=Netzwerkspiel starten IDS_DLG_NETWORK=Netzwerk IDS_DLG_NO=&Nein @@ -593,7 +584,6 @@ IDS_MSG_REMOVEPLR=&Entfernen IDS_MSG_REMOVEPLR_DESC=Nicht mit diesem Spieler beitreten IDS_MSG_REPLAYPLRS=Schau-Spieler IDS_MSG_REPLAYPLRS_DESC=In den Hauptrollen -IDS_MSG_RESETKEYSETS=Standardbelegung für alle Tastaturblöcke bzw. Gamepads wieder herstellen. IDS_MSG_RESOLUTION_DESC=Bildschirmauflösung im Vollbildmodus. IDS_MSG_RESTARTCHANGECFG=Änderungen werden erst übernommen, wenn das Spiel neu gestartet wurde. IDS_MSG_RNDTEAM=Zufallsteam diff --git a/planet/System.ocg/LanguageUS.txt b/planet/System.ocg/LanguageUS.txt index 894c04607..071bdd4d6 100644 --- a/planet/System.ocg/LanguageUS.txt +++ b/planet/System.ocg/LanguageUS.txt @@ -23,7 +23,6 @@ IDS_BTN_RELOAD=Reloa&d IDS_BTN_RENAME=Rename IDS_BTN_RESET=Reset IDS_BTN_RESETCONFIG=Reset configuration -IDS_BTN_RESETKEYBOARD=Reset all IDS_BTN_RESTART=Restart IDS_BTN_RETRY=Retry IDS_BTN_START=Start @@ -118,7 +117,6 @@ IDS_CTL_FRONTEND=Frontend IDS_CTL_FULLSCREENMODE=Window mode IDS_CTL_GAME=Game IDS_CTL_GAMEFUNCTIONS=Game Functions -IDS_CTL_GAMEPADFORMENU=Use gamepad for menu control. IDS_CTL_GAMESPEEDUP=Increase game speed IDS_CTL_GAMESPEEDDOWN=Decrease game speed IDS_CTL_GFXENGINE=Renderer @@ -195,7 +193,6 @@ IDS_DESC_ENDTHEROUND=End the round. IDS_DESC_EXPECTING=Awaiting participants. IDS_DESC_FONTSIZE=Select font size. When you change the screen resolution, the font size will be automatically adjusted. IDS_DESC_GAMEMUSIC=Enable background music in the game. -IDS_DESC_GAMEPADFORMENU=If enabled, you can control the startup menu system with your gamepad. IDS_DESC_GAMEPAUSED=Game is paused IDS_DESC_GAMERUNNING=Game is running IDS_DESC_GAMESOUND=Enable sound effects in the game. @@ -235,13 +232,11 @@ IDS_DLGTIP_CANCEL=Cancel. IDS_DLGTIP_CHANGECTRL=Choose a control set to view and modify it IDS_DLGTIP_CHAT=Enter chat messages here and send them with enter. IDS_DLGTIP_CHATWIN=Messages -IDS_DLGTIP_CLASSIC=Clonks run until they are stopped using the 'stop' key. IDS_DLGTIP_CLEAR=Clears the selection. IDS_DLGTIP_COPY=Copies the selection to the clipboard. IDS_DLGTIP_CUT=Moves the selection to the clipboard. IDS_DLGTIP_EXIT=End the program. IDS_DLGTIP_GAMEGO=Starts the game. -IDS_DLGTIP_JUMPANDRUN=Clonks will stop as soon as the movement key is released. IDS_DLGTIP_NETWORKGAME=Start a network game or join an existing one. IDS_DLGTIP_NEWPLAYER=Create a new player file. IDS_DLGTIP_OK2=Confirm. @@ -272,7 +267,6 @@ IDS_DLG_ABORT=Abort IDS_DLG_ABOUT=&Credits IDS_DLG_CANCEL=Cancel IDS_DLG_CHAT=Chat -IDS_DLG_CLASSIC=Classic IDS_DLG_CLEAR=Clear IDS_DLG_CLOSE=&Close IDS_DLG_CONTROLS=Controls @@ -286,10 +280,8 @@ IDS_DLG_EXACT=Exact landscape IDS_DLG_EXIT=E&xit IDS_DLG_GAME=Game IDS_DLG_GAMEGO=&Start -IDS_DLG_GAMEPAD=Gamepad IDS_DLG_GRAPHICS=Graphics IDS_DLG_INVALIDENTRY=Invalid Entry -IDS_DLG_JUMPANDRUN=Jump'n'Run IDS_DLG_LEAGUESIGNUP=League Login IDS_DLG_LEAGUESIGNUPCONFIRM=Confirm League Login IDS_DLG_LEAGUESIGNUPFAILED=League Login Failed @@ -297,7 +289,6 @@ IDS_DLG_LEAGUESIGNUPON=League Login on %s IDS_DLG_LOBBY=Lobby IDS_DLG_LOG=Error Log IDS_DLG_MISSIONACCESS=Mission Access -IDS_DLG_MOVEMENT=Movement IDS_DLG_NETSTART=Start Network Game IDS_DLG_NETWORK=Network IDS_DLG_NO=&No @@ -593,7 +584,6 @@ IDS_MSG_REMOVEPLR=&Remove IDS_MSG_REMOVEPLR_DESC=Do not join with this player IDS_MSG_REPLAYPLRS=Replay players IDS_MSG_REPLAYPLRS_DESC=Starring -IDS_MSG_RESETKEYSETS=Reset all keyboard blocks (or gamepads respectively). IDS_MSG_RESOLUTION_DESC=Select screen resolution in fullscreen mode. IDS_MSG_RESTARTCHANGECFG=For changes to take effect the program has to be restarted. IDS_MSG_RNDTEAM=Random team diff --git a/src/c4group/C4Language.cpp b/src/c4group/C4Language.cpp index 28b8b2ec2..3139cc426 100644 --- a/src/c4group/C4Language.cpp +++ b/src/c4group/C4Language.cpp @@ -31,15 +31,6 @@ #include #include -#ifdef HAVE_ICONV -#ifdef HAVE_LANGINFO_H -#include -#endif -#include -iconv_t C4Language::host_to_local = iconv_t(-1); -iconv_t C4Language::local_to_host = iconv_t(-1); -#endif - C4Language Languages; //char strLog[2048 + 1]; @@ -157,88 +148,8 @@ void C4Language::Clear() Infos = pNext; } Infos = NULL; -#ifdef HAVE_ICONV - if (local_to_host != iconv_t(-1)) - { - iconv_close(local_to_host); - local_to_host = iconv_t(-1); - } - if (host_to_local != iconv_t(-1)) - { - iconv_close(host_to_local); - host_to_local = iconv_t(-1); - } -#endif } -#ifdef HAVE_ICONV -StdStrBuf C4Language::Iconv(const char * string, iconv_t cd) -{ - if (cd == iconv_t(-1)) - { - return StdStrBuf(string, true); - } - StdStrBuf r; - if (!string) return r; - size_t inlen = strlen(string); - size_t outlen = strlen(string); - r.SetLength(inlen); - const char * inbuf = string; - char * outbuf = r.getMData(); - while (inlen > 0) - { - // Hope that iconv does not change the inbuf... - if ((size_t)(-1) == iconv(cd, const_cast(&inbuf), &inlen, &outbuf, &outlen)) - { - switch (errno) - { - // There is not sufficient room at *outbuf. - case E2BIG: - { - size_t done = outbuf - r.getMData(); - r.Grow(inlen * 2); - outbuf = r.getMData() + done; - outlen += inlen * 2; - break; - } - // An invalid multibyte sequence has been encountered in the input. - case EILSEQ: - ++inbuf; - --inlen; - break; - // An incomplete multibyte sequence has been encountered in the input. - case EINVAL: - default: - if (outlen) r.Shrink(outlen); - return r; - } - } - } - if (outlen) r.Shrink(outlen); - // StdStrBuf has taken care of the terminating zero - return r; -} -StdStrBuf C4Language::IconvSystem(const char * string) -{ - return Iconv(string, local_to_host); -} -StdStrBuf C4Language::IconvClonk(const char * string) -{ - return Iconv(string, host_to_local); -} -#else -StdStrBuf C4Language::IconvSystem(const char * string) -{ - // Just copy through - return StdStrBuf(string, true); -} -StdStrBuf C4Language::IconvClonk(const char * string) -{ - // Just copy through - return StdStrBuf(string, true); -} -#endif - int C4Language::GetPackCount() { return Packs.GetGroupCount(); @@ -533,19 +444,6 @@ bool C4Language::LoadStringTable(C4Group &hGroup, const char *strCode) // Load string table if (!C4LangStringTable::GetSystemStringTable().Load(hGroup, strEntry)) return false; - -#ifdef HAVE_ICONV -#ifdef HAVE_LANGINFO_H - const char * const to_set = nl_langinfo(CODESET); - if (local_to_host == iconv_t(-1)) - local_to_host = iconv_open (to_set ? to_set : "ASCII", "UTF-8"); - if (host_to_local == iconv_t(-1)) - host_to_local = iconv_open ("UTF-8", - to_set ? to_set : "ASCII"); -#else - const char * const to_set = ""; -#endif -#endif // Success return true; } diff --git a/src/c4group/C4Language.h b/src/c4group/C4Language.h index a34cdc6d0..2bbcb4ef3 100644 --- a/src/c4group/C4Language.h +++ b/src/c4group/C4Language.h @@ -23,10 +23,6 @@ #include "c4group/C4GroupSet.h" #include "c4group/C4LangStringTable.h" -#ifdef HAVE_ICONV -#include -#endif - const int C4MaxLanguageInfo = 1024; class C4LanguageInfo @@ -71,9 +67,6 @@ public: C4LanguageInfo *FindInfo(const char *strCode); // Loading of actual resource string table bool LoadLanguage(const char *strLanguages); - // Encoding conversion functions - static StdStrBuf IconvClonk(const char * string); - static StdStrBuf IconvSystem(const char * string); inline bool HasStringTable() const { return !C4LangStringTable::GetSystemStringTable().GetDataBuf().isNull(); } @@ -84,11 +77,6 @@ private: // Loading of actual resource string table bool InitStringTable(const char *strCode); bool LoadStringTable(C4Group &hGroup, const char *strCode); -#ifdef HAVE_ICONV - static iconv_t local_to_host; - static iconv_t host_to_local; - static StdStrBuf Iconv(const char * string, iconv_t cd); -#endif }; extern C4Language Languages; @@ -106,4 +94,4 @@ inline const char *LoadResStr(const char *id) } const char *LoadResStrNoAmp(const char *id); -#endif \ No newline at end of file +#endif diff --git a/src/game/C4Application.h b/src/game/C4Application.h index 196681cda..a5e916707 100644 --- a/src/game/C4Application.h +++ b/src/game/C4Application.h @@ -120,18 +120,4 @@ public: virtual bool IsLowPriority(); }; -class C4ApplicationSec1Timer : protected CStdTimerProc -{ -public: - C4ApplicationSec1Timer() : CStdTimerProc(1000) { } - virtual void OnSec1Timer() = 0; -protected: - virtual bool Execute(int, pollfd *) - { - if (CheckAndReset()) - OnSec1Timer(); - return true; - } -}; - #endif diff --git a/src/gui/C4Gui.h b/src/gui/C4Gui.h index 793a3876c..697d896e9 100644 --- a/src/gui/C4Gui.h +++ b/src/gui/C4Gui.h @@ -33,6 +33,7 @@ #include "C4Application.h" +#include #include #include @@ -2355,7 +2356,7 @@ namespace C4GUI public: InfoDialog(const char *szCaption, int32_t iLineCount); // ctor InfoDialog(const char *szCaption, int iLineCount, const StdStrBuf &sText); // ctor - init w/o timer - ~InfoDialog() { Application.Remove(this); } + ~InfoDialog(); }; // a keyboard event that's only executed if the dialog is activated diff --git a/src/gui/C4GuiDialogs.cpp b/src/gui/C4GuiDialogs.cpp index b123e0687..8ecd77d5a 100644 --- a/src/gui/C4GuiDialogs.cpp +++ b/src/gui/C4GuiDialogs.cpp @@ -1194,6 +1194,10 @@ bool MessageDialog::KeyCopy() pTextWin->UpdateHeight(); //pTextWin->ScrollToBottom(); } + InfoDialog::~InfoDialog() + { + Application.Remove(this); + } void InfoDialog::CreateSubComponents() { diff --git a/src/gui/C4StartupMainDlg.cpp b/src/gui/C4StartupMainDlg.cpp index 1df5f69ea..9615c32e6 100644 --- a/src/gui/C4StartupMainDlg.cpp +++ b/src/gui/C4StartupMainDlg.cpp @@ -136,7 +136,7 @@ C4GUI::ContextMenu *C4StartupMainDlg::OnPlayerSelContextAdd(C4GUI::Element *pBtn if (*GetFilename(szFn) == '.') continue; if (!WildcardMatch(C4CFN_PlayerFiles, GetFilename(szFn))) continue; if (!SIsModule(Config.General.Participants, szFn, NULL, false)) - pCtx->AddItem(C4Language::IconvClonk(GetFilenameOnly(szFn)).getData(), "Let this player join in next game", C4GUI::Ico_Player, + pCtx->AddItem(GetFilenameOnly(szFn), "Let this player join in next game", C4GUI::Ico_Player, new C4GUI::CBMenuHandlerEx(this, &C4StartupMainDlg::OnPlayerSelContextAddPlr, StdCopyStrBuf(szFn)), NULL); } return pCtx; @@ -192,7 +192,7 @@ void C4StartupMainDlg::UpdateParticipants() for (int i = 0; SCopySegment(Config.General.Participants, i, &strPlayer[0], ';', 1024, true); i++) { if (i > 0) strPlayers.append(", "); - strPlayers.append(C4Language::IconvClonk(GetFilenameOnly(&strPlayer[0])).getData()); + strPlayers.append(GetFilenameOnly(&strPlayer[0])); } pParticipantsLbl->SetText(strPlayers.c_str()); } diff --git a/src/gui/C4StartupPlrSelDlg.cpp b/src/gui/C4StartupPlrSelDlg.cpp index 6976ea4e3..39e00b2bc 100644 --- a/src/gui/C4StartupPlrSelDlg.cpp +++ b/src/gui/C4StartupPlrSelDlg.cpp @@ -808,7 +808,7 @@ bool C4StartupPlrSelDlg::CheckPlayerName(const StdStrBuf &Playername, StdStrBuf return false; } // generate valid filename - Filename.Take(C4Language::IconvSystem(Playername.getData())); + Filename.Copy(Playername); // Slashes in Filenames are no good SReplaceChar(Filename.getMData(), '\\', '_'); SReplaceChar(Filename.getMData(), '/', '_'); diff --git a/src/gui/C4StartupScenSelDlg.cpp b/src/gui/C4StartupScenSelDlg.cpp index 729892897..fc51dc73f 100644 --- a/src/gui/C4StartupScenSelDlg.cpp +++ b/src/gui/C4StartupScenSelDlg.cpp @@ -467,7 +467,6 @@ bool C4ScenarioListLoader::Entry::Load(C4Group *pFromGrp, const StdStrBuf *psFil char *szBuf = sName.GrabPointer(); RemoveExtension(szBuf); sName.Take(szBuf); - sName.Take(C4Language::IconvClonk(sName.getData())); // load entry specific stuff that's in the front of the group if (!LoadCustomPre(Group)) return false; diff --git a/src/lib/C4Log.cpp b/src/lib/C4Log.cpp index 9f364385a..27f7c916b 100644 --- a/src/lib/C4Log.cpp +++ b/src/lib/C4Log.cpp @@ -145,23 +145,17 @@ bool LogSilent(const char *szMessage, bool fConsole) } *pDest++='\n'; *pDest = '\0'; -#ifdef HAVE_ICONV - StdStrBuf Line = Languages.IconvSystem(TimeMessage.getData()); -#else - const StdStrBuf &Line = TimeMessage; -#endif - // Save into log file if (C4LogFile) { - fputs(Line.getData(),C4LogFile); + fputs(TimeMessage.getData(),C4LogFile); fflush(C4LogFile); } // Save into record log file, if available if(Control.GetRecord()) { - Control.GetRecord()->GetLogFile()->Write(Line.getData(), strlen(Line.getData())); + Control.GetRecord()->GetLogFile()->Write(TimeMessage.getData(), TimeMessage.getLength()); #ifdef IMMEDIATEREC Control.GetRecord()->GetLogFile()->Flush(); #endif @@ -173,9 +167,9 @@ bool LogSilent(const char *szMessage, bool fConsole) { #if defined(_DEBUG) && defined(_WIN32) // debug: output to VC console - OutputDebugString(Line.GetWideChar()); + OutputDebugString(TimeMessage.GetWideChar()); #endif - fputs(Line.getData(),stdout); + fputs(TimeMessage.getData(),stdout); fflush(stdout); } @@ -338,12 +332,7 @@ bool ShaderLog(const char *szMessage) if (!Application.AssertMainThread()) return false; if (!szMessage) return false; // output into shader log file -#ifdef HAVE_ICONV - StdStrBuf Line = Languages.IconvSystem(szMessage); -#else - StdStrBuf Line; Line.Ref(szMessage); -#endif - fputs(Line.getData(), C4ShaderLogFile); + fputs(szMessage, C4ShaderLogFile); fputs("\n", C4ShaderLogFile); fflush(C4ShaderLogFile); return true; diff --git a/src/network/C4Network2Dialogs.cpp b/src/network/C4Network2Dialogs.cpp index 6a36acf5b..46836def7 100644 --- a/src/network/C4Network2Dialogs.cpp +++ b/src/network/C4Network2Dialogs.cpp @@ -420,6 +420,11 @@ C4Network2ClientListBox::C4Network2ClientListBox(C4Rect &rcBounds, bool fStartup Update(); } +C4Network2ClientListBox::~C4Network2ClientListBox() +{ + Application.Remove(this); +} + void C4Network2ClientListBox::Update() { // sync with client list @@ -524,6 +529,11 @@ C4Network2ClientListDlg::C4Network2ClientListDlg() Update(); } +C4Network2ClientListDlg::~C4Network2ClientListDlg() +{ + if (this==pInstance) pInstance=NULL; Application.Remove(this); +} + void C4Network2ClientListDlg::Update() { // Compose status text diff --git a/src/network/C4Network2Dialogs.h b/src/network/C4Network2Dialogs.h index 84b978f85..7e281ebc7 100644 --- a/src/network/C4Network2Dialogs.h +++ b/src/network/C4Network2Dialogs.h @@ -162,7 +162,7 @@ private: public: C4Network2ClientListBox(C4Rect &rcBounds, bool fStartup); - ~C4Network2ClientListBox() { Application.Remove(this); } + ~C4Network2ClientListBox(); // update by client list void OnSec1Timer() { Update(); } @@ -186,7 +186,7 @@ private: virtual const char *GetID() { return "ClientListDialog"; } public: C4Network2ClientListDlg(); - ~C4Network2ClientListDlg() { if (this==pInstance) pInstance=NULL; Application.Remove(this); } + ~C4Network2ClientListDlg(); void OnSec1Timer() { Update(); } void Update(); diff --git a/src/platform/C4SoundLoaders.h b/src/platform/C4SoundLoaders.h index 408dce9ef..78a79a260 100644 --- a/src/platform/C4SoundLoaders.h +++ b/src/platform/C4SoundLoaders.h @@ -17,6 +17,7 @@ #define INC_C4SoundLoaders #include +#include #include namespace C4SoundLoaders diff --git a/src/platform/C4SoundSystem.cpp b/src/platform/C4SoundSystem.cpp index 0bac68005..3682248bf 100644 --- a/src/platform/C4SoundSystem.cpp +++ b/src/platform/C4SoundSystem.cpp @@ -26,12 +26,70 @@ #include #include #include +#include #include -#if AUDIO_TK == AUDIO_TK_SDL_MIXER -#define USE_RWOPS -#include -#endif +class C4SoundEffect +{ + friend class C4SoundInstance; +public: + C4SoundEffect(); + ~C4SoundEffect(); +public: + char Name[C4MaxSoundName+1]; + int32_t Instances; + int32_t SampleRate, Length; + C4SoundHandle pSample; + C4SoundInstance *FirstInst; + C4SoundEffect *Next; +public: + void Clear(); + bool Load(const char *szFileName, C4Group &hGroup); + bool Load(BYTE *pData, size_t iDataLen, bool fRaw=false); // load directly from memory + void Execute(); + C4SoundInstance *New(bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iCustomFalloffDistance = 0); + C4SoundInstance *GetInstance(C4Object *pObj); + void ClearPointers(C4Object *pObj); + int32_t GetStartedInstanceCount(int32_t iX, int32_t iY, int32_t iRad); // local + int32_t GetStartedInstanceCount(); // global +protected: + void AddInst(C4SoundInstance *pInst); + void RemoveInst(C4SoundInstance *pInst); +}; + +class C4SoundInstance +{ + friend class C4SoundEffect; +protected: + C4SoundInstance(); +public: + ~C4SoundInstance(); +protected: + C4SoundEffect *pEffect; + int32_t iVolume, iPan, iChannel; + C4TimeMilliseconds tStarted; + int32_t iNearInstanceMax; + bool fLooping; + C4Object *pObj; + int32_t iFalloffDistance; + C4SoundInstance *pNext; +public: + C4Object *getObj() const { return pObj; } + bool isStarted() const { return iChannel != -1; } + void Clear(); + bool Create(C4SoundEffect *pEffect, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iNearInstanceMax = 0, int32_t iFalloffDistance = 0); + bool CheckStart(); + bool Start(); + bool Stop(); + bool Playing(); + void Execute(); + void SetVolume(int32_t inVolume) { iVolume = inVolume; } + void SetPan(int32_t inPan) { iPan = inPan; } + void SetVolumeByPos(int32_t x, int32_t y); + void SetObj(C4Object *pnObj) { pObj = pnObj; } + void ClearPointers(C4Object *pObj); + bool Inside(int32_t iX, int32_t iY, int32_t iRad); +}; using namespace C4SoundLoaders; diff --git a/src/platform/C4SoundSystem.h b/src/platform/C4SoundSystem.h index 4be8c2b90..a5797159e 100644 --- a/src/platform/C4SoundSystem.h +++ b/src/platform/C4SoundSystem.h @@ -21,7 +21,6 @@ #define INC_C4SoundSystem #include -#include const int32_t C4MaxSoundName=100, @@ -29,73 +28,11 @@ const int32_t C4NearSoundRadius=50, C4AudibilityRadius=700; -class C4Object; -class C4SoundInstance; - -class C4SoundEffect -{ - friend class C4SoundInstance; -public: - C4SoundEffect(); - ~C4SoundEffect(); -public: - char Name[C4MaxSoundName+1]; - int32_t Instances; - int32_t SampleRate, Length; - C4SoundHandle pSample; - C4SoundInstance *FirstInst; - C4SoundEffect *Next; -public: - void Clear(); - bool Load(const char *szFileName, C4Group &hGroup); - bool Load(BYTE *pData, size_t iDataLen, bool fRaw=false); // load directly from memory - void Execute(); - C4SoundInstance *New(bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iCustomFalloffDistance = 0); - C4SoundInstance *GetInstance(C4Object *pObj); - void ClearPointers(C4Object *pObj); - int32_t GetStartedInstanceCount(int32_t iX, int32_t iY, int32_t iRad); // local - int32_t GetStartedInstanceCount(); // global -protected: - void AddInst(C4SoundInstance *pInst); - void RemoveInst(C4SoundInstance *pInst); -}; - -class C4SoundInstance -{ - friend class C4SoundEffect; -protected: - C4SoundInstance(); -public: - ~C4SoundInstance(); -protected: - C4SoundEffect *pEffect; - int32_t iVolume, iPan, iChannel; - C4TimeMilliseconds tStarted; - int32_t iNearInstanceMax; - bool fLooping; - C4Object *pObj; - int32_t iFalloffDistance; - C4SoundInstance *pNext; -public: - C4Object *getObj() const { return pObj; } - bool isStarted() const { return iChannel != -1; } - void Clear(); - bool Create(C4SoundEffect *pEffect, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj = NULL, int32_t iNearInstanceMax = 0, int32_t iFalloffDistance = 0); - bool CheckStart(); - bool Start(); - bool Stop(); - bool Playing(); - void Execute(); - void SetVolume(int32_t inVolume) { iVolume = inVolume; } - void SetPan(int32_t inPan) { iPan = inPan; } - void SetVolumeByPos(int32_t x, int32_t y); - void SetObj(C4Object *pnObj) { pObj = pnObj; } - void ClearPointers(C4Object *pObj); - bool Inside(int32_t iX, int32_t iY, int32_t iRad); -}; - const int32_t SoundUnloadTime=60, SoundMaxUnloadSize=100000; +class C4SoundInstance; +class C4SoundEffect; + class C4SoundSystem { public: @@ -116,9 +53,9 @@ protected: int32_t RemoveEffect(const char *szFilename); }; -class C4SoundInstance *StartSoundEffect(const char *szSndName, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj=NULL, int32_t iCustomFalloffDistance=0); -class C4SoundInstance *StartSoundEffectAt(const char *szSndName, int32_t iX, int32_t iY, int32_t iVolume = 100, int32_t iCustomFallofDistance=0); -class C4SoundInstance *GetSoundInstance(const char *szSndName, C4Object *pObj); +C4SoundInstance *StartSoundEffect(const char *szSndName, bool fLoop = false, int32_t iVolume = 100, C4Object *pObj=NULL, int32_t iCustomFalloffDistance=0); +C4SoundInstance *StartSoundEffectAt(const char *szSndName, int32_t iX, int32_t iY, int32_t iVolume = 100, int32_t iCustomFallofDistance=0); +C4SoundInstance *GetSoundInstance(const char *szSndName, C4Object *pObj); void StopSoundEffect(const char *szSndName, C4Object *pObj); void SoundLevel(const char *szSndName, C4Object *pObj, int32_t iLevel); void SoundPan(const char *szSndName, C4Object *pObj, int32_t iPan); diff --git a/src/platform/StdScheduler.cpp b/src/platform/StdScheduler.cpp index 7a30a6937..ee32ce79b 100644 --- a/src/platform/StdScheduler.cpp +++ b/src/platform/StdScheduler.cpp @@ -260,12 +260,22 @@ void __cdecl StdSchedulerThread::_ThreadFunc(void *pPar) StdSchedulerThread *pThread = reinterpret_cast(pPar); _endthreadex(pThread->ThreadFunc()); } +void __cdecl StdThread::_ThreadFunc(void *pPar) +{ + StdThread *pThread = reinterpret_cast(pPar); + _endthreadex(pThread->ThreadFunc()); +} #elif defined(HAVE_PTHREAD) void *StdSchedulerThread::_ThreadFunc(void *pPar) { StdSchedulerThread *pThread = reinterpret_cast(pPar); return reinterpret_cast(pThread->ThreadFunc()); } +void *StdThread::_ThreadFunc(void *pPar) +{ + StdThread *pThread = reinterpret_cast(pPar); + return reinterpret_cast(pThread->ThreadFunc()); +} #endif unsigned int StdSchedulerThread::ThreadFunc() diff --git a/src/platform/StdScheduler.h b/src/platform/StdScheduler.h index e53b9e021..341750d5c 100644 --- a/src/platform/StdScheduler.h +++ b/src/platform/StdScheduler.h @@ -123,6 +123,20 @@ public: virtual uint32_t TimerInterval() { return iDelay; } }; +class C4ApplicationSec1Timer : protected CStdTimerProc +{ +public: + C4ApplicationSec1Timer() : CStdTimerProc(1000) { } + virtual void OnSec1Timer() = 0; +protected: + virtual bool Execute(int, pollfd *) + { + if (CheckAndReset()) + OnSec1Timer(); + return true; + } +}; + // A simple alertable proc class CStdNotifyProc : public StdSchedulerProc { diff --git a/src/platform/StdSchedulerPoll.cpp b/src/platform/StdSchedulerPoll.cpp index eeaf5439f..d26e991e0 100644 --- a/src/platform/StdSchedulerPoll.cpp +++ b/src/platform/StdSchedulerPoll.cpp @@ -1,27 +1,20 @@ #include "C4Include.h" #include "StdScheduler.h" + #ifdef HAVE_POLL_H - #include - #include #include #include - -#include - #ifdef HAVE_IO_H #include #endif #ifdef HAVE_SHARE_H #include #endif - #ifdef HAVE_UNISTD_H -// For pipe() #include #endif - #include // Is this process currently signaled? @@ -134,7 +127,7 @@ bool StdScheduler::DoScheduleProcs(int iTimeout) bool any_executed = false; auto tNow = C4TimeMilliseconds::Now(); // Which process? - for (auto i = 0; i < procs.size(); i++) + for (size_t i = 0; i < procs.size(); i++) { auto proc = procs[i]; auto tProcTick = proc->GetNextTick(tNow); @@ -186,8 +179,6 @@ bool StdScheduler::DoScheduleProcs(int iTimeout) #if defined(HAVE_SYS_TIMERFD_H) #include -#include -#include CStdMultimediaTimerProc::CStdMultimediaTimerProc(uint32_t iDelay) { fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC); @@ -230,7 +221,7 @@ void CStdMultimediaTimerProc::GetFDs(std::vector & checkfds) pollfd pfd = { fd, POLLIN, 0 }; checkfds.push_back(pfd); } -#endif +#endif // HAVE_SYS_TIMERFD_H #if !defined(USE_COCOA) void StdScheduler::Added(StdSchedulerProc *pProc) {} @@ -238,11 +229,4 @@ void StdScheduler::Removing(StdSchedulerProc *pProc) {} void StdScheduler::Changed(StdSchedulerProc* pProc) {} void StdScheduler::StartOnCurrentThread() {} #endif - -void *StdThread::_ThreadFunc(void *pPar) -{ - StdThread *pThread = reinterpret_cast(pPar); - return reinterpret_cast(pThread->ThreadFunc()); -} - -#endif +#endif // HAVE_POLL_H diff --git a/src/platform/StdSchedulerWin32.cpp b/src/platform/StdSchedulerWin32.cpp index 663494b23..781c1327c 100644 --- a/src/platform/StdSchedulerWin32.cpp +++ b/src/platform/StdSchedulerWin32.cpp @@ -1,7 +1,7 @@ // Events are Windows-specific #include #include -#ifdef USE_WIN32_WINDOWS +#ifdef STDSCHEDULER_USE_EVENTS #include #include @@ -167,11 +167,4 @@ bool CStdMultimediaTimerProc::CheckAndReset() Event.Reset(); return true; } - -void __cdecl StdThread::_ThreadFunc(void *pPar) -{ - StdThread *pThread = reinterpret_cast(pPar); - _endthreadex(pThread->ThreadFunc()); -} - -#endif \ No newline at end of file +#endif diff --git a/src/res/SDLMain.nib/objects.nib b/src/res/SDLMain.nib/objects.nib deleted file mode 100644 index 66cb3f5fe..000000000 Binary files a/src/res/SDLMain.nib/objects.nib and /dev/null differ diff --git a/src/script/C4Script.cpp b/src/script/C4Script.cpp index c680e6c46..e1a9525a6 100644 --- a/src/script/C4Script.cpp +++ b/src/script/C4Script.cpp @@ -156,7 +156,7 @@ C4Value C4AulDefFunc::Exec(C4PropList * p, C4Value pPars[], bool fPassErrors) #define MAKE_AND_RETURN_ARRAY(values) do { \ C4ValueArray *matrix = new C4ValueArray(sizeof(values) / sizeof(*values)); \ - for (long i = 0; i < sizeof(values) / sizeof(*values); ++i) \ + for (size_t i = 0; i < sizeof(values) / sizeof(*values); ++i) \ (*matrix)[i] = C4VInt(values[i]); \ return matrix; \ } while (0) @@ -273,7 +273,7 @@ static C4Value FnTrans_Mul(C4PropList * _this, C4Value *pars) // unlike in the other Trans_*-functions, we have to put the array into a C4Value manually here C4ValueArray *matrix = new C4ValueArray(sizeof(values) / sizeof(*values)); - for (long i = 0; i < sizeof(values) / sizeof(*values); ++i) + for (size_t i = 0; i < sizeof(values) / sizeof(*values); ++i) (*matrix)[i] = C4VInt(values[i]); return C4VArray(matrix); } diff --git a/tools/osx_bundle_libs b/tools/osx_bundle_libs index 466eccc6c..0710760d4 100755 --- a/tools/osx_bundle_libs +++ b/tools/osx_bundle_libs @@ -23,7 +23,7 @@ _otool="${OTOOL:-otool}" _install_name_tool="${INSTALL_NAME_TOOL:-install_name_tool}" # This regexp should match every lib we want to bundle. -_libs_to_bundle=".*?/lib(jpeg|GLEW|llvm|SDL|SDL_mixer|freetype|ogg|vorbis|vorbisfile|z\.|png[0-9]*|iconv|alut)\.[^ ]+\.dylib" +_libs_to_bundle=".*?/lib(jpeg|GLEW|llvm|SDL|SDL_mixer|freetype|ogg|vorbis|vorbisfile|z\.|png[0-9]*|alut)\.[^ ]+\.dylib" if [ -n "${TARGET_BUILD_DIR}" ]; then cd "${TARGET_BUILD_DIR}" diff --git a/tools/remove_unused_strings.py b/tools/remove_unused_strings.py index 37cc5448d..6e3536b0c 100644 --- a/tools/remove_unused_strings.py +++ b/tools/remove_unused_strings.py @@ -38,8 +38,8 @@ for language_file in language_files: key = keyvalue[0].strip() findkey = key.rstrip("0123456789") - if not search_all_files_in_directory_for_phrase(os.path.normpath("../src"),findkey,language_files) \ - and not search_all_files_in_directory_for_phrase(os.path.normpath("../planet"),findkey,language_files): + if not search_all_files_in_directory_for_phrase(os.path.normpath("../src"),findkey,language_files): + #and not search_all_files_in_directory_for_phrase(os.path.normpath("../planet"),findkey,language_files): unused.append(key) else: fout.write(line)