From 24da8433d0028d2fbfa6ac34a0d5e7ee7b496477 Mon Sep 17 00:00:00 2001 From: airstruck Date: Thu, 7 Jul 2016 21:13:49 +0200 Subject: [PATCH 01/10] Expose axis vector of PrismaticJoint and WheelJoint (fixes #1176) --- changes.txt | 1 + src/modules/physics/box2d/PrismaticJoint.cpp | 6 ++++++ src/modules/physics/box2d/PrismaticJoint.h | 7 +++++++ src/modules/physics/box2d/WheelJoint.cpp | 6 ++++++ src/modules/physics/box2d/WheelJoint.h | 7 +++++++ src/modules/physics/box2d/wrap_PrismaticJoint.cpp | 8 ++++++++ src/modules/physics/box2d/wrap_WheelJoint.cpp | 8 ++++++++ 7 files changed, 43 insertions(+) diff --git a/changes.txt b/changes.txt index c2191a4d9..10f99fc13 100644 --- a/changes.txt +++ b/changes.txt @@ -6,6 +6,7 @@ Released: N/A * Added lovec.exe in Windows. It is the same as love.exe but built with the Console subsystem, so it always uses or provides a console. * Added 'shaderswitches' field to the table returned by love.graphics.getStats. * Added Quad:getTextureDimensions. + * Added PrismaticJoint:getAxis and WheelJoint:getAxis. * Fixed love on iOS 6. * Fixed os.execute always returning -1 on Linux. diff --git a/src/modules/physics/box2d/PrismaticJoint.cpp b/src/modules/physics/box2d/PrismaticJoint.cpp index cd56aa96d..69f182074 100644 --- a/src/modules/physics/box2d/PrismaticJoint.cpp +++ b/src/modules/physics/box2d/PrismaticJoint.cpp @@ -138,6 +138,12 @@ int PrismaticJoint::getLimits(lua_State *L) return 2; } +int PrismaticJoint::getAxis(lua_State *L) +{ + lua_pushnumber(L, joint->GetLocalAxisA().x); + lua_pushnumber(L, joint->GetLocalAxisA().y); + return 2; +} } // box2d } // physics diff --git a/src/modules/physics/box2d/PrismaticJoint.h b/src/modules/physics/box2d/PrismaticJoint.h index 5a34b2c84..584691544 100644 --- a/src/modules/physics/box2d/PrismaticJoint.h +++ b/src/modules/physics/box2d/PrismaticJoint.h @@ -134,6 +134,13 @@ public: **/ int getLimits(lua_State *L); + /** + * Gets the axis unit vector, relative to body1. + * @returns The X component of the axis unit vector. + * @returns The Y component of the axis unit vector. + **/ + int getAxis(lua_State *L); + private: // The Box2D prismatic joint object. diff --git a/src/modules/physics/box2d/WheelJoint.cpp b/src/modules/physics/box2d/WheelJoint.cpp index b28220ce5..bd066c157 100644 --- a/src/modules/physics/box2d/WheelJoint.cpp +++ b/src/modules/physics/box2d/WheelJoint.cpp @@ -113,6 +113,12 @@ float WheelJoint::getSpringDampingRatio() const return joint->GetSpringDampingRatio(); } +int WheelJoint::getAxis(lua_State *L) +{ + lua_pushnumber(L, joint->GetLocalAxisA().x); + lua_pushnumber(L, joint->GetLocalAxisA().y); + return 2; +} } // box2d } // physics diff --git a/src/modules/physics/box2d/WheelJoint.h b/src/modules/physics/box2d/WheelJoint.h index 7d1b4600a..b08d28104 100644 --- a/src/modules/physics/box2d/WheelJoint.h +++ b/src/modules/physics/box2d/WheelJoint.h @@ -114,6 +114,13 @@ public: **/ float getSpringDampingRatio() const; + /** + * Gets the axis unit vector, relative to body1. + * @returns The X component of the axis unit vector. + * @returns The Y component of the axis unit vector. + **/ + int getAxis(lua_State *L); + private: // The Box2D wheel joint object. diff --git a/src/modules/physics/box2d/wrap_PrismaticJoint.cpp b/src/modules/physics/box2d/wrap_PrismaticJoint.cpp index abd1895bc..c9e1b972c 100644 --- a/src/modules/physics/box2d/wrap_PrismaticJoint.cpp +++ b/src/modules/physics/box2d/wrap_PrismaticJoint.cpp @@ -164,6 +164,13 @@ int w_PrismaticJoint_getLimits(lua_State *L) return t->getLimits(L); } +int w_PrismaticJoint_getAxis(lua_State *L) +{ + PrismaticJoint *t = luax_checkprismaticjoint(L, 1); + lua_remove(L, 1); + return t->getAxis(L); +} + static const luaL_Reg w_PrismaticJoint_functions[] = { { "getJointTranslation", w_PrismaticJoint_getJointTranslation }, @@ -183,6 +190,7 @@ static const luaL_Reg w_PrismaticJoint_functions[] = { "getLowerLimit", w_PrismaticJoint_getLowerLimit }, { "getUpperLimit", w_PrismaticJoint_getUpperLimit }, { "getLimits", w_PrismaticJoint_getLimits }, + { "getAxis", w_PrismaticJoint_getAxis }, { 0, 0 } }; diff --git a/src/modules/physics/box2d/wrap_WheelJoint.cpp b/src/modules/physics/box2d/wrap_WheelJoint.cpp index 5ec454a77..4a6ee66b7 100644 --- a/src/modules/physics/box2d/wrap_WheelJoint.cpp +++ b/src/modules/physics/box2d/wrap_WheelJoint.cpp @@ -132,6 +132,13 @@ int w_WheelJoint_getSpringDampingRatio(lua_State *L) return 1; } +int w_WheelJoint_getAxis(lua_State *L) +{ + WheelJoint *t = luax_checkwheeljoint(L, 1); + lua_remove(L, 1); + return t->getAxis(L); +} + static const luaL_Reg w_WheelJoint_functions[] = { { "getJointTranslation", w_WheelJoint_getJointTranslation }, @@ -147,6 +154,7 @@ static const luaL_Reg w_WheelJoint_functions[] = { "getSpringFrequency", w_WheelJoint_getSpringFrequency }, { "setSpringDampingRatio", w_WheelJoint_setSpringDampingRatio }, { "getSpringDampingRatio", w_WheelJoint_getSpringDampingRatio }, + { "getAxis", w_WheelJoint_getAxis }, { 0, 0 } }; From 9a2f99dc3de86b75af6ab62cfdba59cee875185a Mon Sep 17 00:00:00 2001 From: airstruck Date: Thu, 7 Jul 2016 21:18:35 +0200 Subject: [PATCH 02/10] Added 2-point version of love.physics.newRevoluteJoint (fixes #1175) --- changes.txt | 1 + src/modules/physics/box2d/Physics.cpp | 4 ++-- src/modules/physics/box2d/Physics.h | 8 +++++--- src/modules/physics/box2d/RevoluteJoint.cpp | 5 +++-- src/modules/physics/box2d/RevoluteJoint.h | 2 +- src/modules/physics/box2d/wrap_Physics.cpp | 21 +++++++++++++++++---- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/changes.txt b/changes.txt index 10f99fc13..9f7684f8d 100644 --- a/changes.txt +++ b/changes.txt @@ -7,6 +7,7 @@ Released: N/A * Added 'shaderswitches' field to the table returned by love.graphics.getStats. * Added Quad:getTextureDimensions. * Added PrismaticJoint:getAxis and WheelJoint:getAxis. + * Added 2-point version of love.physics.newRevoluteJoint. * Fixed love on iOS 6. * Fixed os.execute always returning -1 on Linux. diff --git a/src/modules/physics/box2d/Physics.cpp b/src/modules/physics/box2d/Physics.cpp index 8673c1ada..778cc4566 100644 --- a/src/modules/physics/box2d/Physics.cpp +++ b/src/modules/physics/box2d/Physics.cpp @@ -223,9 +223,9 @@ MouseJoint *Physics::newMouseJoint(Body *body, float x, float y) return new MouseJoint(body, x, y); } -RevoluteJoint *Physics::newRevoluteJoint(Body *body1, Body *body2, float x, float y, bool collideConnected) +RevoluteJoint *Physics::newRevoluteJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, bool collideConnected) { - return new RevoluteJoint(body1, body2, x, y, collideConnected); + return new RevoluteJoint(body1, body2, xA, yA, xB, yB, collideConnected); } PrismaticJoint *Physics::newPrismaticJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, float ax, float ay, bool collideConnected) diff --git a/src/modules/physics/box2d/Physics.h b/src/modules/physics/box2d/Physics.h index 113506379..febe272b9 100644 --- a/src/modules/physics/box2d/Physics.h +++ b/src/modules/physics/box2d/Physics.h @@ -171,11 +171,13 @@ public: /** * Creates a new RevoluteJoint connecting body1 with body2. - * @param x Anchor along the x-axis. (World coordinates) - * @param y Anchor along the y-axis. (World coordinates) + * @param xA Anchor for body 1 along the x-axis. (World coordinates) + * @param yA Anchor for body 1 along the y-axis. (World coordinates) + * @param xB Anchor for body 2 along the x-axis. (World coordinates) + * @param yB Anchor for body 2 along the y-axis. (World coordinates) * @param collideConnected Whether the connected bodies should collide with each other. Defaults to false. **/ - RevoluteJoint *newRevoluteJoint(Body *body1, Body *body2, float x, float y, bool collideConnected); + RevoluteJoint *newRevoluteJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, bool collideConnected); /** * Creates a new PrismaticJoint connecting body1 with body2. diff --git a/src/modules/physics/box2d/RevoluteJoint.cpp b/src/modules/physics/box2d/RevoluteJoint.cpp index 513b1fa86..de9596328 100644 --- a/src/modules/physics/box2d/RevoluteJoint.cpp +++ b/src/modules/physics/box2d/RevoluteJoint.cpp @@ -34,12 +34,13 @@ namespace physics namespace box2d { -RevoluteJoint::RevoluteJoint(Body *body1, Body *body2, float x, float y, bool collideConnected) +RevoluteJoint::RevoluteJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, bool collideConnected) : Joint(body1, body2) , joint(NULL) { b2RevoluteJointDef def; - def.Initialize(body1->body, body2->body, Physics::scaleDown(b2Vec2(x,y))); + def.Initialize(body1->body, body2->body, Physics::scaleDown(b2Vec2(xA,yA))); + def.localAnchorB = body2->body->GetLocalPoint(Physics::scaleDown(b2Vec2(xB, yB))); def.collideConnected = collideConnected; joint = (b2RevoluteJoint *)createJoint(&def); } diff --git a/src/modules/physics/box2d/RevoluteJoint.h b/src/modules/physics/box2d/RevoluteJoint.h index d3412e3c4..ee490380d 100644 --- a/src/modules/physics/box2d/RevoluteJoint.h +++ b/src/modules/physics/box2d/RevoluteJoint.h @@ -42,7 +42,7 @@ public: /** * Creates a new RevoluteJoint connecting body1 and body2. **/ - RevoluteJoint(Body *body1, Body *body2, float x, float y, bool collideConnected); + RevoluteJoint(Body *body1, Body *body2, float xA, float yA, float xB, float yB, bool collideConnected); virtual ~RevoluteJoint(); diff --git a/src/modules/physics/box2d/wrap_Physics.cpp b/src/modules/physics/box2d/wrap_Physics.cpp index ef6327c67..8ed78b48e 100644 --- a/src/modules/physics/box2d/wrap_Physics.cpp +++ b/src/modules/physics/box2d/wrap_Physics.cpp @@ -215,12 +215,25 @@ int w_newRevoluteJoint(lua_State *L) { Body *body1 = luax_checkbody(L, 1); Body *body2 = luax_checkbody(L, 2); - float x = (float)luaL_checknumber(L, 3); - float y = (float)luaL_checknumber(L, 4); - bool collideConnected = luax_optboolean(L, 5, false); + float xA = (float)luaL_checknumber(L, 3); + float yA = (float)luaL_checknumber(L, 4); + float xB, yB; + bool collideConnected; + if (lua_gettop(L) >= 6) + { + xB = (float)luaL_checknumber(L, 5); + yB = (float)luaL_checknumber(L, 6); + collideConnected = luax_optboolean(L, 7, false); + } + else + { + xB = xA; + yB = yA; + collideConnected = luax_optboolean(L, 5, false); + } RevoluteJoint *j; luax_catchexcept(L, [&]() { - j = instance()->newRevoluteJoint(body1, body2, x, y, collideConnected); + j = instance()->newRevoluteJoint(body1, body2, xA, yA, xB, yB, collideConnected); }); luax_pushtype(L, PHYSICS_REVOLUTE_JOINT_ID, j); j->release(); From f66011de2f68846a090c07c77416c56b8fb3de20 Mon Sep 17 00:00:00 2001 From: rude Date: Tue, 12 Jul 2016 21:25:23 +0200 Subject: [PATCH 03/10] Return correct size from b64_decode. The current implementation does not take into account padding (and yet it does actually depend on padding), or skipped whitespace/gibberish characters. The actual size can be computed by subtracting the padding and gibberish bytes, but in this case it's easier to just return the actual number of bytes written. --- src/common/b64.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/common/b64.cpp b/src/common/b64.cpp index aa2f6f5df..bc3bd6f62 100644 --- a/src/common/b64.cpp +++ b/src/common/b64.cpp @@ -34,9 +34,11 @@ static void b64_decode_block(char in[4], char out[3]) char *b64_decode(const char *src, int slen, int &size) { - size = (slen / 4) * 3; + // Actual output may be smaller due to padding and/or whitespace in the + // base64-encoded string. + int max_size = (slen / 4) * 3; - char *dst = new char[size]; + char *dst = new char[max_size]; char *d = dst; char in[4] = {0}, out[3], v; @@ -70,10 +72,12 @@ char *b64_decode(const char *src, int slen, int &size) { b64_decode_block(in, out); for (i = 0; i < len - 1; i++) - *(d++) = out[i]; + *(d++) = out[i]; } } + size = int(d - dst); + return dst; } From b0effb5570a969131742aa76e95a9dd63dac21de Mon Sep 17 00:00:00 2001 From: rude Date: Wed, 13 Jul 2016 21:26:50 +0100 Subject: [PATCH 04/10] Make CMakeLists.txt more decoupled from Megasource. --- CMakeLists.txt | 202 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 134 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cddf70019..4b21051db 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,13 +27,6 @@ cmake_minimum_required(VERSION 2.8) project(love) -if(NOT MEGA) - message(FATAL_ERROR " -It is currently only possible to build with megasource on Windows. -Please see http://bitbucket.org/rude/megasource -") -endif() - set(LOVE_EXE_NAME love) set(LOVE_LIB_NAME liblove) @@ -66,17 +59,112 @@ message(STATUS "Target platform: ${LOVE_TARGET_PLATFORM}") find_package(OpenGL) -if(${LOVE_JIT}) - set(MEGA_LUA ${MEGA_LUAJIT_LIB}) - set(MEGA_EXTRA_INCLUDE ${MEGA_LUAJIT_INCLUDE}) - set(MEGA_EXTRA_DLLS ${MEGA_LUAJIT_DLL}) - set(MEGA_EXTRA_DEPENDECIES luajit) +if(MEGA) + # LOVE_MSVC_DLLS contains runtime DLLs that should be bundled with the love + # binary (in e.g. the installer). Example: msvcp140.dll. + set(LOVE_MSVC_DLLS ${MEGA_MSVC_DLLS}) + + # LOVE_INCLUDE_DIRS contains the search directories for #include. It's mostly + # not needed for MEGA builds, since almost all the libraries (except LuaJIT) + # are CMake targets, causing include paths to be added automatically. + set(LOVE_INCLUDE_DIRS) + + # SDL2 links with some DirectX libraries, and we apparently also + # pull those libraries in for linkage because we link with SDL2. + set(LOVE_LINK_DIRS ${SDL_LINK_DIR}) + + set(LOVE_LINK_LIBRARIES + ${OPENGL_gl_LIBRARY} + ${MEGA_FREETYPE} + ${MEGA_LIBOGG} + ${MEGA_LIBVORBISFILE} + ${MEGA_LIBVORBIS} + ${MEGA_LIBTHEORA} + ${MEGA_MODPLUG} + ${MEGA_OPENAL} + ${MEGA_PHYSFS} + ${MEGA_SDL2MAIN} + ${MEGA_SDL2} + ${MEGA_ZLIB} + ) + + # These DLLs are moved next to the love binary in a post-build step to + # love runnable from inside Visual Studio. + # + # LOVE_MOVE_DLLS can contain CMake targets, in which case the target's + # output is assumed to be a DLL, or it can contain paths to actual files. + # We detect whether or not each item is a target, and take the appropriate + # action. + set(LOVE_MOVE_DLLS + ${MEGA_SDL2} + ${MEGA_OPENAL} + ) + + if(LOVE_MPG123) + set(LOVE_LINK_LIBRARIES + ${LOVE_LINK_LIBRARIES} + ${MEGA_MPEG123} + ) + set(LOVE_MOVE_DLLS + ${LOVE_MOVE_DLLS} + ${MEGA_MPEG123} + ) + endif() + + if(LOVE_JIT) + set(LOVE_LUA_LIBRARY ${MEGA_LUAJIT_LIB}) + # LOVE_EXTRA_DLLS are non-runtime DLLs which should be bundled with the + # love binary in installers, etc. It's only needed for external + # (non-CMake) targets, i.e. LuaJIT. + set(LOVE_EXTRA_DLLS ${MEGA_LUAJIT_DLL}) + set(LOVE_EXTRA_DEPENDECIES luajit) + + set(LOVE_INCLUDE_DIRS + ${LOVE_INCLUDE_DIRS} + ${MEGA_LUAJIT_INCLUDE} + ) + set(LOVE_LINK_LIBRARIES + ${LOVE_LINK_LIBRARIES} + ${LOVE_LUA_LIBRARY} + ) + set(LOVE_MOVE_DLLS + ${LOVE_MOVE_DLLS} + ${MEGA_LUAJIT_DLL} + ) + else() + set(LOVE_LUA_LIBRARY ${MEGA_LUA51}) + + set(LOVE_LINK_LIBRARIES + ${LOVE_LINK_LIBRARIES} + ${LOVE_LUA_LIBRARY} + ) + set(LOVE_MOVE_DLLS + ${LOVE_MOVE_DLLS} + ${LOVE_LUA_LIBRARY} + ) + # MEGA_LUA51 is a CMake target, so includes are handled + # automatically. + endif() else() - set(MEGA_LUA ${MEGA_LUA51}) - # MEGA_LUA51 is a CMake target, so includes are handled - # automatically. + message(FATAL_ERROR " +It is currently only possible to build with megasource on Windows. +Please see http://bitbucket.org/rude/megasource +") endif() +### +### No Megasource-specific stuff beyond this point! +### + +function(disable_warnings ARG_TARGET) + get_target_property(OLD_FLAGS ${ARG_TARGET} COMPILE_FLAGS) + set(NEW_FLAGS -W0) + if(OLD_FLAGS) + set(NEW_FLAGS "${OLD_FLAGS} ${NEW_FLAGS}") + endif() + set_target_properties(${ARG_TARGET} PROPERTIES COMPILE_FLAGS ${NEW_FLAGS}) +endfunction() + # # common # @@ -1028,7 +1116,7 @@ set(LOVE_SRC_3P_ENET ) add_library(love_3p_enet ${LOVE_SRC_3P_ENET}) -target_link_libraries(love_3p_enet ${MEGA_LUA}) +target_link_libraries(love_3p_enet ${LOVE_LUA_LIBRARY}) target_include_directories(love_3p_enet PUBLIC src/libraries/enet/libenet/include) # @@ -1114,7 +1202,7 @@ set(LOVE_SRC_3P_LUASOCKET ) add_library(love_3p_luasocket ${LOVE_SRC_3P_LUASOCKET}) -target_link_libraries(love_3p_luasocket ${MEGA_LUA}) +target_link_libraries(love_3p_luasocket ${LOVE_LUA_LIBRARY}) # # Lua 5.3's UTF-8 library @@ -1127,7 +1215,7 @@ set(LOVE_SRC_3P_LUAUTF8 ) add_library(love_3p_luautf8 ${LOVE_SRC_3P_LUAUTF8}) -target_link_libraries(love_3p_luautf8 ${MEGA_LUA}) +target_link_libraries(love_3p_luautf8 ${LOVE_LUA_LIBRARY}) # # lz4 @@ -1248,40 +1336,10 @@ include_directories( src src/libraries src/modules - ${MEGA_EXTRA_INCLUDE} + ${LOVE_INCLUDE_DIRS} ) -# SDL2 links with some DirectX libraries, and we apparently also -# pull those libraries in for linkage because we link with SDL2. -link_directories(${SDL_LINK_DIR}) - -set(LOVE_MEGA_3P - ${MEGA_FREETYPE} - ${MEGA_LIBOGG} - ${MEGA_LIBVORBISFILE} - ${MEGA_LIBVORBIS} - ${MEGA_LIBTHEORA} - ${MEGA_LUA} - ${MEGA_MODPLUG} - ${MEGA_OPENAL} - ${MEGA_PHYSFS} - ${MEGA_SDL2MAIN} - ${MEGA_SDL2} - ${MEGA_ZLIB} -) - -if(LOVE_MPG123) - set(LOVE_MEGA_3P - ${LOVE_MEGA_3P} - ${MEGA_MPEG123} - ) -endif() - - -set(LOVE_LINK_LIBRARIES - ${OPENGL_gl_LIBRARY} - ${LOVE_MEGA_3P} -) +link_directories(${LOVE_LINK_DIRS}) set(LOVE_RC) @@ -1300,8 +1358,8 @@ endif() add_library(${LOVE_LIB_NAME} SHARED ${LOVE_LIB_SRC} ${LOVE_RC}) target_link_libraries(${LOVE_LIB_NAME} ${LOVE_LINK_LIBRARIES} ${LOVE_3P}) -if(MEGA_EXTRA_DEPENDECIES) - add_dependencies(${LOVE_LIB_NAME} ${MEGA_EXTRA_DEPENDECIES}) +if(LOVE_EXTRA_DEPENDECIES) + add_dependencies(${LOVE_LIB_NAME} ${LOVE_EXTRA_DEPENDECIES}) endif() if(MSVC) @@ -1320,21 +1378,29 @@ if(MSVC) target_link_libraries(${LOVE_CONSOLE_EXE_NAME} ${LOVE_LIB_NAME}) endif() +function(post_step_move_dll ARG_POST_TARGET ARG_TARGET_OR_FILE) + if(TARGET ${ARG_TARGET_OR_FILE}) + add_custom_command(TARGET ${ARG_POST_TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + $ + ${CMAKE_CURRENT_BINARY_DIR}/$/$) + else() + get_filename_component(TEMP_FILENAME ${ARG_TARGET_OR_FILE} NAME) + add_custom_command(TARGET ${ARG_POST_TARGET} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${ARG_TARGET_OR_FILE} + ${CMAKE_CURRENT_BINARY_DIR}/$/${TEMP_FILENAME}) + endif() +endfunction() # Add post build steps to move the DLLs next to the binary. Otherwise # running/debugging the binary will not work from inside VS. -if(LOVE_MPG123) - add_move_dll(love ${MEGA_MPEG123}) +if(LOVE_MOVE_DLLS) + foreach(DLL ${LOVE_MOVE_DLLS}) + post_step_move_dll(love ${DLL}) + endforeach() endif() -add_move_dll(love ${MEGA_SDL2}) -add_move_dll(love ${MEGA_OPENAL}) - -if(LOVE_JIT) - add_move_file(love ${MEGA_LUAJIT_DLL}) -else() - add_move_dll(love ${MEGA_LUA51}) -endif() ################################### # Version @@ -1364,21 +1430,21 @@ message(STATUS "Version: ${LOVE_VERSION_STR}") install(TARGETS ${LOVE_EXE_NAME} ${LOVE_CONSOLE_EXE_NAME} ${LOVE_LIB_NAME} RUNTIME DESTINATION .) # Extra DLLs. -if(MEGA_EXTRA_DLLS) - foreach(DLL ${MEGA_EXTRA_DLLS}) +if(LOVE_EXTRA_DLLS) + foreach(DLL ${LOVE_EXTRA_DLLS}) get_filename_component(DLL_NAME ${DLL} NAME) message(STATUS "Extra DLL: ${DLL_NAME}") endforeach() - install(FILES ${MEGA_EXTRA_DLLS} DESTINATION .) + install(FILES ${LOVE_EXTRA_DLLS} DESTINATION .) endif() # Dynamic runtime libs. -if(MEGA_MSVC_DLLS) - foreach(DLL ${MEGA_MSVC_DLLS}) +if(LOVE_MSVC_DLLS) + foreach(DLL ${LOVE_MSVC_DLLS}) get_filename_component(DLL_NAME ${DLL} NAME) message(STATUS "Runtime DLL: ${DLL_NAME}") endforeach() - install(FILES ${MEGA_MSVC_DLLS} DESTINATION .) + install(FILES ${LOVE_MSVC_DLLS} DESTINATION .) endif() # Copy a text file from CMAKE_CURRENT_SOURCE_DIR to CMAKE_CURRENT_BINARY_DIR. From f6154998dcc3f93772508b2dfc563f107b2d4fd4 Mon Sep 17 00:00:00 2001 From: rude Date: Wed, 13 Jul 2016 22:19:09 +0100 Subject: [PATCH 05/10] Use nsis-unicode for AppVeyor build. --- extra/appveyor/appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/appveyor/appveyor.yml b/extra/appveyor/appveyor.yml index 283dc3842..e9cb74517 100644 --- a/extra/appveyor/appveyor.yml +++ b/extra/appveyor/appveyor.yml @@ -11,7 +11,7 @@ init: install: # We need to install NSIS to create the packaged installer executable. -- choco install nsis -y +- choco install nsis-unicode -y # Move all woking directory items except `appveyor.yml` to `love` subdirectory. - md love From ba1a234543a15e7d439e83d38c5b5fcf0b9d1b6b Mon Sep 17 00:00:00 2001 From: rude Date: Wed, 13 Jul 2016 22:42:06 +0100 Subject: [PATCH 06/10] =?UTF-8?q?Use=20L=C3=96VE=20in=20NSIS=20once=20agai?= =?UTF-8?q?n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b21051db..620ca9f63 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1485,7 +1485,7 @@ set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.md") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt") set(CPACK_NSIS_EXECUTABLES_DIRECTORY .) -set(CPACK_NSIS_PACKAGE_NAME "LOVE") +set(CPACK_NSIS_PACKAGE_NAME "LÖVE") set(CPACK_NSIS_DISPLAY_NAME "LOVE ${LOVE_VERSION_STR}") set(CPACK_NSIS_MODIFY_PATH OFF) @@ -1506,7 +1506,7 @@ set(NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/extra/nsis\\\\love.ico") set(NSIS_MUI_UNICON "${CMAKE_CURRENT_SOURCE_DIR}/extra/nsis\\\\love.ico") set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE " - !define MUI_WELCOMEPAGE_TITLE \\\"LOVE ${LOVE_VERSION_STR} Setup\\\" + !define MUI_WELCOMEPAGE_TITLE \\\"LÖVE ${LOVE_VERSION_STR} Setup\\\" !define MUI_WELCOMEFINISHPAGE_BITMAP \\\"${NSIS_LEFT_BMP}\\\" !define MUI_HEADERIMAGE_BITMAP \\\"${NSIS_TOP_BMP}\\\" !define MUI_ICON \\\"${NSIS_MUI_ICON}\\\" From 7266fa4fc5c74f627af26ea8aacf22bbc4e846e7 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Thu, 14 Jul 2016 14:22:38 +0200 Subject: [PATCH 07/10] Fix memory leak in Text:set (fixes #1181) --- src/modules/graphics/opengl/Text.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/graphics/opengl/Text.cpp b/src/modules/graphics/opengl/Text.cpp index 8b66fafa5..79deac7f4 100644 --- a/src/modules/graphics/opengl/Text.cpp +++ b/src/modules/graphics/opengl/Text.cpp @@ -129,6 +129,7 @@ void Text::addTextData(const TextData &t) { voffset = 0; draw_commands.clear(); + text_data.clear(); } uploadVertices(vertices, voffset); From 64ee986984eec681c5184549c1d0159851d02348 Mon Sep 17 00:00:00 2001 From: rude Date: Thu, 14 Jul 2016 16:29:45 +0200 Subject: [PATCH 08/10] =?UTF-8?q?Make=20L=C3=96VE=20buildable=20(barely)?= =?UTF-8?q?=20with=20Megasource=20on=20Mac.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 26 ++++++++++++++++++++++++++ src/common/macosx.mm | 6 +++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 620ca9f63..505ce80b3 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,8 @@ project(love) set(LOVE_EXE_NAME love) set(LOVE_LIB_NAME liblove) +set (CMAKE_CXX_STANDARD 11) + if(MSVC) set(LOVE_CONSOLE_EXE_NAME lovec) endif() @@ -46,6 +48,9 @@ option(LOVE_JIT "Use LuaJIT" TRUE) option(LOVE_MPG123 "Use mpg123" TRUE) if(LOVE_JIT) + if(APPLE) + message(FATAL_ERROR "JIT not supported yet on Mac. Please use -DLOVE_JIT=0.") + endif() message(STATUS "LuaJIT: Enabled") else() message(STATUS "LuaJIT: Disabled") @@ -69,6 +74,12 @@ if(MEGA) # are CMake targets, causing include paths to be added automatically. set(LOVE_INCLUDE_DIRS) + if(APPLE) + # Some files do #include , but building with megasource + # requires #include . + add_definitions(-DLOVE_MACOSX_SDL_DIRECT_INCLUDE) + endif () + # SDL2 links with some DirectX libraries, and we apparently also # pull those libraries in for linkage because we link with SDL2. set(LOVE_LINK_DIRS ${SDL_LINK_DIR}) @@ -207,6 +218,12 @@ set(LOVE_SRC_COMMON src/common/wrap_Data.h ) +if (APPLE) + set(LOVE_SRC_COMMON ${LOVE_SRC_COMMON} + src/common/macosx.mm + ) +endif() + source_group("common" FILES ${LOVE_SRC_COMMON}) # @@ -1194,6 +1211,12 @@ if(MSVC) src/libraries/luasocket/libluasocket/wsocket.c src/libraries/luasocket/libluasocket/wsocket.h ) +else() + set(LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET + ${LOVE_SRC_3P_LUASOCKET_LIBLUASOCKET} + src/libraries/luasocket/libluasocket/usocket.c + src/libraries/luasocket/libluasocket/usocket.h + ) endif() set(LOVE_SRC_3P_LUASOCKET @@ -1401,6 +1424,9 @@ if(LOVE_MOVE_DLLS) endforeach() endif() +if (NOT MSVC) + return() +endif() ################################### # Version diff --git a/src/common/macosx.mm b/src/common/macosx.mm index b6e3cad5e..b9055faf1 100644 --- a/src/common/macosx.mm +++ b/src/common/macosx.mm @@ -25,7 +25,11 @@ #import #import -#include +#ifdef LOVE_MACOSX_SDL_DIRECT_INCLUDE +# include +#else +# include +#endif namespace love { From 65f53a491f9a95d4e6cb7fe69648a6a759550a5c Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Thu, 14 Jul 2016 16:39:29 +0200 Subject: [PATCH 09/10] Make MouseJoint:getBodies() return only one body (fixes #1179) Override Joint's Body getters in MouseJoint, to make the second (user-supplied) body the first body returned, and return nil for the second (internal) body --- changes.txt | 1 + src/modules/physics/box2d/Joint.h | 4 ++-- src/modules/physics/box2d/MouseJoint.cpp | 10 ++++++++++ src/modules/physics/box2d/MouseJoint.h | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/changes.txt b/changes.txt index 9f7684f8d..4f248a132 100644 --- a/changes.txt +++ b/changes.txt @@ -21,6 +21,7 @@ Released: N/A * Fixed the default shader improperly applying gamma correction to per-vertex colors when gamma correction is requested but not supported on OpenGL ES. * Fixed text coloring breaking because of an empty string. * Fixed large burst of particles when dramatically increasing the emission rate of a ParticleSystem. + * Fixed MouseJoint:getBodies unconditionally erroring. * Improved performance of Channel methods by roughly 2x in many cases. diff --git a/src/modules/physics/box2d/Joint.h b/src/modules/physics/box2d/Joint.h index dd6be8e1c..258234985 100644 --- a/src/modules/physics/box2d/Joint.h +++ b/src/modules/physics/box2d/Joint.h @@ -84,8 +84,8 @@ public: **/ Type getType() const; - Body *getBodyA() const; - Body *getBodyB() const; + virtual Body *getBodyA() const; + virtual Body *getBodyB() const; /** * Gets the anchor positions of the Joint in world diff --git a/src/modules/physics/box2d/MouseJoint.cpp b/src/modules/physics/box2d/MouseJoint.cpp index b037a9c79..08e41d35e 100644 --- a/src/modules/physics/box2d/MouseJoint.cpp +++ b/src/modules/physics/box2d/MouseJoint.cpp @@ -91,6 +91,16 @@ float MouseJoint::getDampingRatio() const return joint->GetDampingRatio(); } +Body *MouseJoint::getBodyA() const +{ + return Joint::getBodyB(); +} + +Body *MouseJoint::getBodyB() const +{ + return nullptr; +} + } // box2d } // physics } // love diff --git a/src/modules/physics/box2d/MouseJoint.h b/src/modules/physics/box2d/MouseJoint.h index 803bf4b94..bf365e8d2 100644 --- a/src/modules/physics/box2d/MouseJoint.h +++ b/src/modules/physics/box2d/MouseJoint.h @@ -95,6 +95,9 @@ public: **/ float getDampingRatio() const; + virtual Body *getBodyA() const; + virtual Body *getBodyB() const; + private: // The Box2D MouseJoint object. b2MouseJoint *joint; From bf601470e1cfd9dc849dcfb633c75c59eb6a02d6 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Thu, 14 Jul 2016 16:41:08 +0200 Subject: [PATCH 10/10] Update changelog --- changes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changes.txt b/changes.txt index 4f248a132..1dad9943d 100644 --- a/changes.txt +++ b/changes.txt @@ -22,6 +22,7 @@ Released: N/A * Fixed text coloring breaking because of an empty string. * Fixed large burst of particles when dramatically increasing the emission rate of a ParticleSystem. * Fixed MouseJoint:getBodies unconditionally erroring. + * Fixed memory leak in Text:set. * Improved performance of Channel methods by roughly 2x in many cases.