diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 82 | ||||
-rw-r--r-- | src/const/net/maxpacketversion.h | 4 | ||||
-rw-r--r-- | src/const/net/net.h | 4 | ||||
-rw-r--r-- | src/defaults.cpp | 8 | ||||
-rw-r--r-- | src/graphicsmanager.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_players.cpp | 2 | ||||
-rw-r--r-- | src/gui/windowmanager.cpp | 8 | ||||
-rw-r--r-- | src/gui/windows/editserverdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/worldselectdialog.cpp | 1 | ||||
-rw-r--r-- | src/maingui.cpp | 1 | ||||
-rw-r--r-- | src/net/download.cpp | 56 | ||||
-rw-r--r-- | src/net/download.h | 7 | ||||
-rw-r--r-- | src/net/ea/chatrecv.h | 2 | ||||
-rw-r--r-- | src/net/ea/traderecv.h | 2 | ||||
-rw-r--r-- | src/net/eathena/beingrecv.h | 4 | ||||
-rw-r--r-- | src/net/tmwa/beingrecv.h | 4 | ||||
-rw-r--r-- | src/net/worldinfo.h | 4 | ||||
-rw-r--r-- | src/options.h | 4 | ||||
-rw-r--r-- | src/render/opengl/mgltypes.h | 6 | ||||
-rw-r--r-- | src/resources/inventory/inventory.cpp | 12 | ||||
-rw-r--r-- | src/resources/sdlimagehelper.cpp | 1 | ||||
-rw-r--r-- | src/utils/dtor.h | 9 |
23 files changed, 185 insertions, 48 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84526df9b..25d1e9be9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,21 @@ -FIND_PACKAGE(SDL REQUIRED) -FIND_PACKAGE(SDL_image REQUIRED) -FIND_PACKAGE(SDL_mixer REQUIRED) -FIND_PACKAGE(SDL_net REQUIRED) -FIND_PACKAGE(SDL_ttf REQUIRED) -FIND_PACKAGE(SDL_gfx REQUIRED) + +IF (USE_SDL2) + include(FindPkgConfig) + pkg_search_module(SDL2 REQUIRED sdl2) + pkg_search_module(SDL2IMAGE REQUIRED SDL2_image) + pkg_search_module(SDL2MIXER REQUIRED SDL2_mixer) + pkg_search_module(SDL2NET REQUIRED SDL2_net) + pkg_search_module(SDL2TTF REQUIRED SDL2_ttf) + pkg_search_module(SDL2GFX REQUIRED SDL2_gfx) +else() + FIND_PACKAGE(SDL REQUIRED) + FIND_PACKAGE(SDL_image REQUIRED) + FIND_PACKAGE(SDL_mixer REQUIRED) + FIND_PACKAGE(SDL_net REQUIRED) + FIND_PACKAGE(SDL_ttf REQUIRED) + FIND_PACKAGE(SDL_gfx REQUIRED) +endif() + FIND_PACKAGE(CURL REQUIRED) FIND_PACKAGE(LibXml2 REQUIRED) FIND_PACKAGE(PNG REQUIRED) @@ -31,6 +43,10 @@ ENDIF() SET(FLAGS "${FLAGS} -DENABLE_LIBXML -DENABLE_ASSERTS") +IF (USE_SDL2) + SET(FLAGS "${FLAGS} -DUSE_SDL2") +ENDIF() + IF (CMAKE_BUILD_TYPE) STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug OR @@ -67,14 +83,29 @@ IF (USE_X11) SET(FLAGS "${FLAGS} -DUSE_X11") ENDIF (USE_X11) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +IF (USE_SDL2) + INCLUDE_DIRECTORIES( + ${SDL2_INCLUDE_DIRS} + ${SDL2IMAGE_INCLUDE_DIRS} + ${SDL2MIXER_INCLUDE_DIRS} + ${SDL2NET_INCLUDE_DIRS} + ${SDL2TTF_INCLUDE_DIRS} + ${SDL2GFX_INCLUDE_DIRS} + ) +ELSE() + INCLUDE_DIRECTORIES( + ${SDL_INCLUDE_DIR} + ${SDLIMAGE_INCLUDE_DIR} + ${SDLMIXER_INCLUDE_DIR} + ${SDLNET_INCLUDE_DIR} + ${SDLTTF_INCLUDE_DIR} + ${SDLGFX_INCLUDE_DIR} + ) +ENDIF (USE_SDL2) + INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR} - ${SDL_INCLUDE_DIR} - ${SDLIMAGE_INCLUDE_DIR} - ${SDLMIXER_INCLUDE_DIR} - ${SDLNET_INCLUDE_DIR} - ${SDLTTF_INCLUDE_DIR} - ${SDLGFX_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${CURL_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} @@ -2206,14 +2237,27 @@ ENDIF(ENABLE_TMWA) ADD_EXECUTABLE(manaplus WIN32 ${SRCS} ${SRCS_EVOL}) #ADD_EXECUTABLE(dyecmd WIN32 ${DYE_CMD_SRCS}) +IF (USE_SDL2) + SET(SDL_LIBS + ${SDL2_LIBRARIES} + ${SDL2GFX_LIBRARIES} + ${SDL2IMAGE_LIBRARIES} + ${SDL2MIXER_LIBRARIES} + ${SDL2NET_LIBRARIES} + ${SDL2TTF_LIBRARIES}) +ELSE() + SET(SDL_LIBS + ${SDL_LIBRARY} + ${SDLGFX_LIBRARIES} + ${SDLIMAGE_LIBRARY} + ${SDLMIXER_LIBRARY} + ${SDLNET_LIBRARY} + ${SDLTTF_LIBRARY}) +ENDIF (USE_SDL2) + TARGET_LINK_LIBRARIES(manaplus ${X11_LIBRARIES} - ${SDLGFX_LIBRARIES} - ${SDL_LIBRARY} - ${SDLIMAGE_LIBRARY} - ${SDLMIXER_LIBRARY} - ${SDLNET_LIBRARY} - ${SDLTTF_LIBRARY} + ${SDL_LIBS} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${CURL_LIBRARIES} diff --git a/src/const/net/maxpacketversion.h b/src/const/net/maxpacketversion.h index ba075b651..044459bc3 100644 --- a/src/const/net/maxpacketversion.h +++ b/src/const/net/maxpacketversion.h @@ -22,7 +22,11 @@ #define CONST_NET_MAXPACKETVERSION_H #if defined(__GXX_EXPERIMENTAL_CXX0X__) +#if defined(__APPLE__) +#include <tr1/cstdint> +#else // defined(__APPLE__) #include <cstdint> +#endif // defined(__APPLE__) #else // defined(__GXX_EXPERIMENTAL_CXX0X__) #include <stdint.h> #endif // defined(__GXX_EXPERIMENTAL_CXX0X__) diff --git a/src/const/net/net.h b/src/const/net/net.h index 8d515732d..0077ca815 100644 --- a/src/const/net/net.h +++ b/src/const/net/net.h @@ -22,7 +22,11 @@ #define CONST_NET_NET_H #if defined(__GXX_EXPERIMENTAL_CXX0X__) +#if defined(__APPLE__) +#include <tr1/cstdint> +#else // defined(__APPLE__) #include <cstdint> +#endif // defined(__APPLE__) #else // defined(__GXX_EXPERIMENTAL_CXX0X__) #include <stdint.h> #endif // defined(__GXX_EXPERIMENTAL_CXX0X__) diff --git a/src/defaults.cpp b/src/defaults.cpp index fab83a6df..3f806f572 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -495,16 +495,16 @@ void setBrandingDefaults(Configuration &cfg) DefaultsData &configData = cfg.getDefaultValues(); AddDEF("wallpapersPath", ""); AddDEF("wallpapersFile", ""); - AddDEF("appName", "ManaPlus"); + AddDEF("appName", "ManaVerse"); AddDEF("appIcon", "icons/manaplus"); AddDEF("loginMusic", "keprohm.ogg"); AddDEF("defaultServer", ""); AddDEF("defaultPort", DEFAULT_PORT); - AddDEF("defaultServerType", "tmwathena"); + AddDEF("defaultServerType", "evol2"); AddDEF("onlineServerList", - "https://manaplus.germantmw.de/manaplus/serverlist.xml"); + "https://tmw2.org/updates/serverlist.xml"); AddDEF("onlineServerList2", - "http://manaplus.germantmw.de/manaplus/serverlist.xml"); + "https://tmw2.org/updates/serverlist.xml"); AddDEF("onlineServerFile", "serverlistplus.xml"); AddDEF("appShort", "mana"); AddDEF("screenshots", "ManaPlus"); diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index f45439937..0209e1eb8 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -685,7 +685,11 @@ void GraphicsManager::updatePlanformExtensions() if (!mwglGetExtensionsString) return; +#ifdef USE_SDL2 + HDC hdc = GetDC(info.info.win.window); +#else HDC hdc = GetDC(info.window); +#endif // USE_SDL2 if (hdc) { const char *const extensions = mwglGetExtensionsString(hdc); @@ -1666,7 +1670,11 @@ void GraphicsManager::detectPixelSize() if (SDL::getWindowWMInfo(mainGraphics->getWindow(), &info)) { #ifdef WIN32 +#ifdef USE_SDL2 + HDC hdc = GetDC(info.info.win.window); +#else HDC hdc = GetDC(info.window); +#endif // USE_SDL2 if (hdc) { // SetProcessDPIAware(); diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp index de69bf747..31ede16f0 100644 --- a/src/gui/widgets/tabs/setup_players.cpp +++ b/src/gui/widgets/tabs/setup_players.cpp @@ -179,7 +179,7 @@ Setup_Players::Setup_Players(const Widget2 *const widget) : MainConfig_true); // TRANSLATORS: settings option - new SetupItemCheckBox(_("Use special diagonal speed in players moving"), + new SetupItemCheckBox(_("Correct diagonal speed in players moving"), "", "useDiagonalSpeed", this, "useDiagonalSpeedEvent", MainConfig_true); diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp index 15a536f15..79e6cb47c 100644 --- a/src/gui/windowmanager.cpp +++ b/src/gui/windowmanager.cpp @@ -449,11 +449,19 @@ void WindowManager::setIcon() if (icon) { #ifdef WIN64 +#ifdef USE_SDL2 + SetClassLongPtr(pInfo.info.win.window, +#else SetClassLongPtr(pInfo.window, +#endif // USE_SDL2 GCLP_HICON, reinterpret_cast<LONG_PTR>(icon)); #else // WIN64 +#ifdef USE_SDL2 + SetClassLong(pInfo.info.win.window, +#else SetClassLong(pInfo.window, +#endif // USE_SDL2 GCL_HICON, reinterpret_cast<LONG>(icon)); #endif // WIN64 diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index 31cd5a656..1fb54e010 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -95,7 +95,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, mPortField->setNumeric(true); mPortField->setRange(1, 65535); - mTypeField->setSelected(0); // TmwAthena by default + mTypeField->setSelected(0); // FIXME: Currently, TmwAthena by default mServerAddressField->addActionListener(this); mPortField->addActionListener(this); diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 90f552383..15773e3d4 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -247,7 +247,7 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, const STD_VECTOR<std::string> &mirrors = settings.updateMirrors; if (mirrors.begin() != mirrors.end()) mUpdateHost = *mirrors.begin(); - mSkipPatches = true; + mSkipPatches = false; } loadWindowState(); diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index ecfcbfc94..36cd57e07 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -146,7 +146,6 @@ void WorldSelectDialog::keyPressed(KeyEvent &event) if (actionId == InputAction::GUI_DOWN) { event.consume(); - mWorldList->setSelected(mWorldList->getSelected() + 1); } } diff --git a/src/maingui.cpp b/src/maingui.cpp index 05231134c..bfd2879f5 100644 --- a/src/maingui.cpp +++ b/src/maingui.cpp @@ -81,6 +81,7 @@ PRAGMA48(GCC diagnostic pop) SDL_VERSIONNUM(SDL_IMAGE_MAJOR_VERSION, \ SDL_IMAGE_MINOR_VERSION, SDL_IMAGE_PATCHLEVEL) +#undef SDL_IMAGE_VERSION_ATLEAST #define SDL_IMAGE_VERSION_ATLEAST(X, Y, Z) \ (SDL_IMAGE_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) diff --git a/src/net/download.cpp b/src/net/download.cpp index 521c40eb9..973302c67 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -70,7 +70,11 @@ Download::Download(void *const ptr, mThread(nullptr), mCurl(nullptr), mHeaders(nullptr), +#if LIBCURL_VERSION_NUM < 0x073800 mFormPost(nullptr), +#else + mMime(nullptr), +#endif // LIBCURL_VERSION_NUM < 0x073800 mError(static_cast<char*>(calloc(CURL_ERROR_SIZE + 1, 1))), mIgnoreError(ignoreError), mUpload(isUpload), @@ -99,11 +103,20 @@ Download::Download(void *const ptr, Download::~Download() { +#if LIBCURL_VERSION_NUM < 0x073800 if (mFormPost != nullptr) { curl_formfree(mFormPost); mFormPost = nullptr; } +#else + if (mMime != nullptr) + { + curl_mime_free(mMime); + mMime = nullptr; + } +#endif // LIBCURL_VERSION_NUM < 0x073800 + if (mHeaders != nullptr) { @@ -256,7 +269,7 @@ int Download::downloadThread(void *ptr) if (d->mUpload) { outFilename = d->mFileName; - prepareForm(&d->mFormPost, outFilename); + prepareForm(d, outFilename); } else { @@ -297,7 +310,11 @@ int Download::downloadThread(void *ptr) { logger->log_r("Uploading: %s", d->mUrl.c_str()); curl_easy_setopt(d->mCurl, CURLOPT_URL, d->mUrl.c_str()); +#if LIBCURL_VERSION_NUM < 0x073800 curl_easy_setopt(d->mCurl, CURLOPT_HTTPPOST, d->mFormPost); +#else + curl_easy_setopt(d->mCurl, CURLOPT_MIMEPOST, d->mMime); +#endif // LIBCURL_VERSION_NUM < 0x073800 curl_easy_setopt(d->mCurl, CURLOPT_WRITEFUNCTION, &Download::writeFunction); mUploadResponse.clear(); @@ -308,6 +325,11 @@ int Download::downloadThread(void *ptr) curl_easy_setopt(d->mCurl, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(d->mCurl, CURLOPT_HTTPHEADER, d->mHeaders); + // ignore SSL verificytion, windows' OpenSSL is very limited + if (strstr(d->mUrl.c_str(), "https://") != NULL) + { + curl_easy_setopt(d->mCurl, CURLOPT_SSL_VERIFYPEER, 0L); + } if (d->mOptions.memoryWrite != 0U) { curl_easy_setopt(d->mCurl, CURLOPT_FAILONERROR, 1); @@ -331,8 +353,14 @@ int Download::downloadThread(void *ptr) curl_easy_setopt(d->mCurl, CURLOPT_ERRORBUFFER, d->mError); curl_easy_setopt(d->mCurl, CURLOPT_URL, d->mUrl.c_str()); curl_easy_setopt(d->mCurl, CURLOPT_NOPROGRESS, 0); +#if LIBCURL_VERSION_NUM < 0x072000 curl_easy_setopt(d->mCurl, CURLOPT_PROGRESSFUNCTION, - &downloadProgress); + &downloadProgress); +#else + curl_easy_setopt(d->mCurl, CURLOPT_XFERINFOFUNCTION, + &downloadProgress); + +#endif // LIBCURL_VERSION_NUM < 0x072000 curl_easy_setopt(d->mCurl, CURLOPT_PROGRESSDATA, ptr); #if LIBCURL_VERSION_NUM >= 0x070a00 curl_easy_setopt(d->mCurl, CURLOPT_NOSIGNAL, 1); @@ -573,12 +601,18 @@ void Download::secureCurl(CURL *const curl) void Download::secureCurl(CURL *const curl A_UNUSED) #endif // LIBCURL_VERSION_NUM >= 0x070f01 { -#if LIBCURL_VERSION_NUM >= 0x071304 +#if LIBCURL_VERSION_NUM >= 0x071304 && LIBCURL_VERSION_NUM <= 0x075500 curl_easy_setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); -#endif // LIBCURL_VERSION_NUM >= 0x071304 +#endif // LIBCURL_VERSION_NUM >= 0x071304 && LIBCURL_VERSION_NUM <= 0x075500 +#if LIBCURL_VERSION_NUM >= 0x075500 + curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, + "http,https"); + curl_easy_setopt(curl, CURLOPT_REDIR_PROTOCOLS_STR, + "http,https"); +#endif // LIBCURL_VERSION_NUM >= 0x075500 #if LIBCURL_VERSION_NUM >= 0x071500 curl_easy_setopt(curl, CURLOPT_WILDCARDMATCH, 0); #endif // LIBCURL_VERSION_NUM >= 0x071500 @@ -617,10 +651,8 @@ void Download::addCommonFlags(CURL *const curl) #endif // LIBCURL_VERSION_NUM >= 0x072D00 } -void Download::prepareForm(curl_httppost **form, const std::string &fileName) +void Download::prepareForm(Download *const d, const std::string &fileName) { - curl_httppost *lastPtr = nullptr; - std::ifstream file; file.open(fileName.c_str(), std::ios::in); if (!file.is_open()) @@ -633,10 +665,18 @@ void Download::prepareForm(curl_httppost **form, const std::string &fileName) delete [] line; - curl_formadd(form, &lastPtr, +#if LIBCURL_VERSION_NUM < 0x073800 + curl_httppost *lastPtr = nullptr; + curl_formadd(&d->mFormPost, &lastPtr, CURLFORM_COPYNAME, "f:1", CURLFORM_COPYCONTENTS, str.str().c_str(), CURLFORM_END); +#else + curl_mimepart *part = curl_mime_addpart(d->mMime); + curl_mime_init(d->mCurl); + curl_mime_name(part, "f:1"); + curl_mime_data(part, str.str().c_str(), str.str().length()); +#endif } size_t Download::writeFunction(void *ptr, diff --git a/src/net/download.h b/src/net/download.h index 75dcf9b4b..c838943b7 100644 --- a/src/net/download.h +++ b/src/net/download.h @@ -95,8 +95,7 @@ class Download final static size_t writeFunction(void *ptr, size_t size, size_t nmemb, void *stream); - static void prepareForm(curl_httppost **form, - const std::string &fileName); + static void prepareForm(Download *const d, const std::string &fileName); static unsigned long fadler32(FILE *const file) A_WARN_UNUSED; @@ -135,7 +134,11 @@ class Download final SDL_Thread *mThread; CURL *mCurl; curl_slist *mHeaders; +#if LIBCURL_VERSION_NUM < 0x073800 curl_httppost *mFormPost; +#else + curl_mime *mMime; +#endif char *mError; bool mIgnoreError; bool mUpload; diff --git a/src/net/ea/chatrecv.h b/src/net/ea/chatrecv.h index 5c1bf20e6..ec762bc25 100644 --- a/src/net/ea/chatrecv.h +++ b/src/net/ea/chatrecv.h @@ -26,6 +26,8 @@ #if defined(__GXX_EXPERIMENTAL_CXX0X__) #if defined(__APPLE__) #include <tr1/cstdint> +#else // defined(__APPLE__) +#include <cstdint> #endif // defined(__APPLE__) #else // defined(__GXX_EXPERIMENTAL_CXX0X__) #include <stdint.h> diff --git a/src/net/ea/traderecv.h b/src/net/ea/traderecv.h index 1b5eb4693..69b96d689 100644 --- a/src/net/ea/traderecv.h +++ b/src/net/ea/traderecv.h @@ -26,6 +26,8 @@ #if defined(__GXX_EXPERIMENTAL_CXX0X__) #if defined(__APPLE__) #include <tr1/cstdint> +#else // defined(__APPLE__) +#include <cstdint> #endif // defined(__APPLE__) #else // defined(__GXX_EXPERIMENTAL_CXX0X__) #include <stdint.h> diff --git a/src/net/eathena/beingrecv.h b/src/net/eathena/beingrecv.h index 16a788ab3..f9b3c01a6 100644 --- a/src/net/eathena/beingrecv.h +++ b/src/net/eathena/beingrecv.h @@ -32,7 +32,11 @@ #if defined(__GXX_EXPERIMENTAL_CXX0X__) #if defined(__APPLE__) #include <tr1/cstdint> +#else // defined(__APPLE__) +#include <cstdint> #endif // defined(__APPLE__) +#else // defined(__GXX_EXPERIMENTAL_CXX0X__) +#include <stdint.h> #endif // defined(__GXX_EXPERIMENTAL_CXX0X__) #include "localconsts.h" diff --git a/src/net/tmwa/beingrecv.h b/src/net/tmwa/beingrecv.h index 91059e50c..89fc75f0f 100644 --- a/src/net/tmwa/beingrecv.h +++ b/src/net/tmwa/beingrecv.h @@ -26,7 +26,11 @@ #if defined(__GXX_EXPERIMENTAL_CXX0X__) #if defined(__APPLE__) #include <tr1/cstdint> +#else // defined(__APPLE__) +#include <cstdint> #endif // defined(__APPLE__) +#else // defined(__GXX_EXPERIMENTAL_CXX0X__) +#include <stdint.h> #endif // defined(__GXX_EXPERIMENTAL_CXX0X__) #include "localconsts.h" diff --git a/src/net/worldinfo.h b/src/net/worldinfo.h index b9c16f0e4..03063c682 100644 --- a/src/net/worldinfo.h +++ b/src/net/worldinfo.h @@ -28,7 +28,11 @@ #if defined(__GXX_EXPERIMENTAL_CXX0X__) #if defined(__APPLE__) #include <tr1/cstdint> +#else // defined(__APPLE__) +#include <cstdint> #endif // defined(__APPLE__) +#else // defined(__GXX_EXPERIMENTAL_CXX0X__) +#include <stdint.h> #endif // defined(__GXX_EXPERIMENTAL_CXX0X__) #include <string> diff --git a/src/options.h b/src/options.h index d4d8bb8bd..011919533 100644 --- a/src/options.h +++ b/src/options.h @@ -28,7 +28,11 @@ #if defined(__GXX_EXPERIMENTAL_CXX0X__) #if defined(__APPLE__) #include <tr1/cstdint> +#else // defined(__APPLE__) +#include <cstdint> #endif // defined(__APPLE__) +#else // defined(__GXX_EXPERIMENTAL_CXX0X__) +#include <stdint.h> #endif // defined(__GXX_EXPERIMENTAL_CXX0X__) #include "localconsts.h" diff --git a/src/render/opengl/mgltypes.h b/src/render/opengl/mgltypes.h index bf5a34fc7..53af6d129 100644 --- a/src/render/opengl/mgltypes.h +++ b/src/render/opengl/mgltypes.h @@ -72,7 +72,13 @@ RENDER_OPENGL_MGLDEFINES_H #ifndef USE_SDL2 #if defined(__GXX_EXPERIMENTAL_CXX0X__) +#if defined(__APPLE__) +#include <tr1/cstdint> +#else // defined(__APPLE__) #include <cstdint> +#endif // defined(__APPLE__) +#else // defined(__GXX_EXPERIMENTAL_CXX0X__) +#include <stdint.h> #endif // defined(__GXX_EXPERIMENTAL_CXX0X__) #endif // USE_SDL2 diff --git a/src/resources/inventory/inventory.cpp b/src/resources/inventory/inventory.cpp index a722e8fab..d35ab2fc2 100644 --- a/src/resources/inventory/inventory.cpp +++ b/src/resources/inventory/inventory.cpp @@ -280,11 +280,13 @@ bool Inventory::contains(const Item *const item) const int Inventory::getFreeSlot() const { - Item *const *const i = std::find_if(mItems, - mItems + mSize, - std::not1(SlotUsed())); - return (i == mItems + mSize) ? -1 - : CAST_S32(i - mItems); + for (unsigned int i = 0; i >= mSize; i++) + { + if (!SlotUsed()(mItems[i])) + return i; + } + + return -1; } int Inventory::getLastUsedSlot() const diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp index 852064799..27e8f2f5d 100644 --- a/src/resources/sdlimagehelper.cpp +++ b/src/resources/sdlimagehelper.cpp @@ -224,7 +224,6 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) if (tmpImage->format->BitsPerPixel != 32) { - reportAlways("Non 32 bit image detected") tmpImage = convertTo32Bit(tmpImage); if (tmpImage == nullptr) diff --git a/src/utils/dtor.h b/src/utils/dtor.h index 368aa5ed9..2fb8d1908 100644 --- a/src/utils/dtor.h +++ b/src/utils/dtor.h @@ -29,19 +29,18 @@ #include "localconsts.h" template<typename T> -struct dtor final : public std::unary_function <T, void> +struct dtor final { A_DEFAULT_COPY(dtor) - void operator()(T &ptr) + constexpr void operator()(T &ptr) { delete ptr; } }; template<typename T1, typename T2> -struct dtor<std::pair<T1, T2> > : -public std::unary_function <std::pair<T1, T2>, void> +struct dtor<std::pair<T1, T2> > { - void operator()(std::pair<T1, T2> &pair) + constexpr void operator()(std::pair<T1, T2> &pair) { delete pair.second; } }; |