Don't use deprecated isFile in love.joystick.loadGamepadMappings (fixes #1391)

This commit is contained in:
Bart van Strien
2018-04-04 17:49:51 +02:00
parent 93372b87a8
commit 571503c02e
2 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -705,7 +705,7 @@ void OpenGL::setVertexAttributes(const vertex::Attributes &attributes, const ver
GLboolean normalized = GL_FALSE; GLboolean normalized = GL_FALSE;
GLenum gltype = getGLVertexDataType(attrib.type, normalized); GLenum gltype = getGLVertexDataType(attrib.type, normalized);
const void *offsetpointer = BUFFER_OFFSET(bufferinfo.offset + attrib.offsetfromvertex); const void *offsetpointer = reinterpret_cast<void*>(bufferinfo.offset + attrib.offsetfromvertex);
bindBuffer(BUFFER_VERTEX, (GLuint) bufferinfo.buffer->getHandle()); bindBuffer(BUFFER_VERTEX, (GLuint) bufferinfo.buffer->getHandle());
glVertexAttribPointer(i, attrib.components, gltype, normalized, attrib.stride, offsetpointer); glVertexAttribPointer(i, attrib.components, gltype, normalized, attrib.stride, offsetpointer);
+8 -8
View File
@@ -21,6 +21,7 @@
#include "wrap_JoystickModule.h" #include "wrap_JoystickModule.h"
#include "wrap_Joystick.h" #include "wrap_Joystick.h"
#include "filesystem/Filesystem.h"
#include "filesystem/wrap_Filesystem.h" #include "filesystem/wrap_Filesystem.h"
#include "sdl/JoystickModule.h" #include "sdl/JoystickModule.h"
@@ -116,15 +117,15 @@ int w_setGamepadMapping(lua_State *L)
int w_loadGamepadMappings(lua_State *L) int w_loadGamepadMappings(lua_State *L)
{ {
bool isfile = true; bool isfile = false;
std::string mappings; std::string mappings = luax_checkstring(L, 1);
if (lua_isstring(L, 1)) auto fs = Module::getInstance<love::filesystem::Filesystem>(Module::M_FILESYSTEM);
if (fs)
{ {
lua_pushvalue(L, 1); love::filesystem::Filesystem::Info info = {};
luax_convobj(L, -1, "filesystem", "isFile"); bool exists = fs->getInfo(mappings.c_str(), info);
isfile = luax_toboolean(L, -1); isfile = exists && info.type == love::filesystem::Filesystem::FILETYPE_FILE;
lua_pop(L, 1);
} }
if (isfile) if (isfile)
@@ -132,7 +133,6 @@ int w_loadGamepadMappings(lua_State *L)
love::filesystem::FileData *fd = love::filesystem::luax_getfiledata(L, 1); love::filesystem::FileData *fd = love::filesystem::luax_getfiledata(L, 1);
mappings = std::string((const char *) fd->getData(), fd->getSize()); mappings = std::string((const char *) fd->getData(), fd->getSize());
fd->release(); fd->release();
} }
else else
mappings = luax_checkstring(L, 1); mappings = luax_checkstring(L, 1);