From 571503c02e1fb94b71fad31fbcbdc91a4b6274d5 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Wed, 4 Apr 2018 17:49:51 +0200 Subject: [PATCH] Don't use deprecated isFile in love.joystick.loadGamepadMappings (fixes #1391) --- src/modules/graphics/opengl/OpenGL.cpp | 2 +- src/modules/joystick/wrap_JoystickModule.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index edded2370..7c12de620 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -705,7 +705,7 @@ void OpenGL::setVertexAttributes(const vertex::Attributes &attributes, const ver GLboolean normalized = GL_FALSE; GLenum gltype = getGLVertexDataType(attrib.type, normalized); - const void *offsetpointer = BUFFER_OFFSET(bufferinfo.offset + attrib.offsetfromvertex); + const void *offsetpointer = reinterpret_cast(bufferinfo.offset + attrib.offsetfromvertex); bindBuffer(BUFFER_VERTEX, (GLuint) bufferinfo.buffer->getHandle()); glVertexAttribPointer(i, attrib.components, gltype, normalized, attrib.stride, offsetpointer); diff --git a/src/modules/joystick/wrap_JoystickModule.cpp b/src/modules/joystick/wrap_JoystickModule.cpp index 72865a884..7605898fd 100644 --- a/src/modules/joystick/wrap_JoystickModule.cpp +++ b/src/modules/joystick/wrap_JoystickModule.cpp @@ -21,6 +21,7 @@ #include "wrap_JoystickModule.h" #include "wrap_Joystick.h" +#include "filesystem/Filesystem.h" #include "filesystem/wrap_Filesystem.h" #include "sdl/JoystickModule.h" @@ -116,15 +117,15 @@ int w_setGamepadMapping(lua_State *L) int w_loadGamepadMappings(lua_State *L) { - bool isfile = true; - std::string mappings; + bool isfile = false; + std::string mappings = luax_checkstring(L, 1); - if (lua_isstring(L, 1)) + auto fs = Module::getInstance(Module::M_FILESYSTEM); + if (fs) { - lua_pushvalue(L, 1); - luax_convobj(L, -1, "filesystem", "isFile"); - isfile = luax_toboolean(L, -1); - lua_pop(L, 1); + love::filesystem::Filesystem::Info info = {}; + bool exists = fs->getInfo(mappings.c_str(), info); + isfile = exists && info.type == love::filesystem::Filesystem::FILETYPE_FILE; } if (isfile) @@ -132,7 +133,6 @@ int w_loadGamepadMappings(lua_State *L) love::filesystem::FileData *fd = love::filesystem::luax_getfiledata(L, 1); mappings = std::string((const char *) fd->getData(), fd->getSize()); fd->release(); - } else mappings = luax_checkstring(L, 1);