From cd24dbcb8e2a2d088f7be34b6bc6974c2651ae98 Mon Sep 17 00:00:00 2001 From: rude Date: Mon, 4 Jan 2010 20:02:36 +0100 Subject: [PATCH 1/5] Added get/setGroupIndex (#129) and get/setFixedRotation (#113). Also fixed 3000 auto.lua-related warnings in MSVC. --- src/love.cpp | 2 +- src/modules/graphics/opengl/wrap_Graphics.cpp | 2 +- src/modules/physics/box2d/Body.cpp | 13 +++++++++++++ src/modules/physics/box2d/Body.h | 2 ++ src/modules/physics/box2d/Shape.cpp | 14 ++++++++++++++ src/modules/physics/box2d/Shape.h | 3 +++ src/modules/physics/box2d/wrap_Body.cpp | 18 ++++++++++++++++++ src/modules/physics/box2d/wrap_Body.h | 2 ++ src/modules/physics/box2d/wrap_Shape.cpp | 18 ++++++++++++++++++ src/modules/physics/box2d/wrap_Shape.h | 2 ++ src/scripts/auto.lua | 2 +- src/scripts/boot.lua.h | 2 +- src/scripts/graphics.lua.h | 2 +- 13 files changed, 77 insertions(+), 5 deletions(-) diff --git a/src/love.cpp b/src/love.cpp index 53f62a627..f2197281f 100644 --- a/src/love.cpp +++ b/src/love.cpp @@ -294,7 +294,7 @@ int main(int argc, char ** argv) } // Boot - if (luaL_loadbuffer(L, love::boot_lua, sizeof(love::boot_lua), "boot.lua") == 0) + if (luaL_loadbuffer(L, (const char *)love::boot_lua, sizeof(love::boot_lua), "boot.lua") == 0) lua_call(L, 0, 0); lua_close(L); diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index fd77ea038..f60b1e89d 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -892,7 +892,7 @@ namespace opengl luax_register_module(L, w); - if (luaL_loadbuffer(L, graphics_lua, sizeof(graphics_lua), "graphics.lua") == 0) + if (luaL_loadbuffer(L, (const char *)graphics_lua, sizeof(graphics_lua), "graphics.lua") == 0) lua_call(L, 0, 0); return 0; diff --git a/src/modules/physics/box2d/Body.cpp b/src/modules/physics/box2d/Body.cpp index adc8c6a2d..96e5b3abc 100644 --- a/src/modules/physics/box2d/Body.cpp +++ b/src/modules/physics/box2d/Body.cpp @@ -282,6 +282,19 @@ namespace box2d body->WakeUp(); } + void Body::setFixedRotation(bool fixed) + { + if(fixed) + body->m_flags |= b2Body::e_fixedRotationFlag; + else + body->m_flags |= ~(b2Body::e_fixedRotationFlag); + } + + bool Body::getFixedRotation() const + { + return (body->m_flags & b2Body::e_fixedRotationFlag) != 0; + } + b2Vec2 Body::getVector(lua_State * L) { love::luax_assert_argc(L, 2, 2); diff --git a/src/modules/physics/box2d/Body.h b/src/modules/physics/box2d/Body.h index 72a1b69da..8a6f570cd 100644 --- a/src/modules/physics/box2d/Body.h +++ b/src/modules/physics/box2d/Body.h @@ -331,6 +331,8 @@ namespace box2d **/ void wakeUp(); + void setFixedRotation(bool fixed); + bool getFixedRotation() const; private: /** diff --git a/src/modules/physics/box2d/Shape.cpp b/src/modules/physics/box2d/Shape.cpp index 071fad912..a9a51ccdc 100644 --- a/src/modules/physics/box2d/Shape.cpp +++ b/src/modules/physics/box2d/Shape.cpp @@ -183,6 +183,20 @@ namespace box2d return 0; } + void Shape::setGroupIndex(int index) + { + b2FilterData f = shape->GetFilterData(); + f.groupIndex = (uint16)index; + shape->SetFilterData(f); + shape->GetBody()->GetWorld()->Refilter(shape); + } + + int Shape::getGroupIndex() const + { + b2FilterData f = shape->GetFilterData(); + return f.groupIndex; + } + int Shape::getCategory(lua_State * L) { return pushBits(L, shape->GetFilterData().categoryBits); diff --git a/src/modules/physics/box2d/Shape.h b/src/modules/physics/box2d/Shape.h index 099cbc918..b8a527399 100644 --- a/src/modules/physics/box2d/Shape.h +++ b/src/modules/physics/box2d/Shape.h @@ -168,6 +168,9 @@ namespace box2d **/ void getFilterData(int * v); + void setGroupIndex(int index); + int getGroupIndex() const; + int setCategory(lua_State * L); int setMask(lua_State * L); int getCategory(lua_State * L); diff --git a/src/modules/physics/box2d/wrap_Body.cpp b/src/modules/physics/box2d/wrap_Body.cpp index b699fddb6..49f855629 100644 --- a/src/modules/physics/box2d/wrap_Body.cpp +++ b/src/modules/physics/box2d/wrap_Body.cpp @@ -425,6 +425,22 @@ namespace box2d return 0; } + int w_Body_setFixedRotation(lua_State * L) + { + Body * t = luax_checkbody(L, 1); + bool b = luax_toboolean(L, 2); + t->setFixedRotation(b); + return 0; + } + + int w_Body_getFixedRotation(lua_State * L) + { + Body * t = luax_checkbody(L, 1); + bool b = t->getFixedRotation(); + luax_pushboolean(L, b); + return 1; + } + int w_Body_destroy(lua_State * L) { Proxy * p = (Proxy *)lua_touserdata(L, 1); @@ -477,6 +493,8 @@ namespace box2d { "setAllowSleeping", w_Body_setAllowSleeping }, { "putToSleep", w_Body_putToSleep }, { "wakeUp", w_Body_wakeUp }, + { "setFixedRotation", w_Body_setFixedRotation }, + { "getFixedRotation", w_Body_getFixedRotation }, { "destroy", w_Body_destroy }, { 0, 0 } }; diff --git a/src/modules/physics/box2d/wrap_Body.h b/src/modules/physics/box2d/wrap_Body.h index d566d7a12..4fc8f5a5d 100644 --- a/src/modules/physics/box2d/wrap_Body.h +++ b/src/modules/physics/box2d/wrap_Body.h @@ -73,6 +73,8 @@ namespace box2d int w_Body_setAllowSleeping(lua_State * L); int w_Body_putToSleep(lua_State * L); int w_Body_wakeUp(lua_State * L); + int w_Body_setFixedRotation(lua_State * L); + int w_Body_getFixedRotation(lua_State * L); int w_Body_destroy(lua_State * L); int luaopen_body(lua_State * L); diff --git a/src/modules/physics/box2d/wrap_Shape.cpp b/src/modules/physics/box2d/wrap_Shape.cpp index f40701308..41e659580 100644 --- a/src/modules/physics/box2d/wrap_Shape.cpp +++ b/src/modules/physics/box2d/wrap_Shape.cpp @@ -198,6 +198,22 @@ namespace box2d return t->getBoundingBox(L); } + int w_Shape_getGroupIndex(lua_State * L) + { + Shape * t = luax_checkshape(L, 1); + int i = t->getGroupIndex(); + lua_pushinteger(L, i); + return 1; + } + + int w_Shape_setGroupIndex(lua_State * L) + { + Shape * t = luax_checkshape(L, 1); + int i = luaL_checkint(L, 2); + t->setGroupIndex(i); + return 0; + } + int w_Shape_destroy(lua_State * L) { Proxy * p = (Proxy *)lua_touserdata(L, 1); @@ -229,6 +245,8 @@ namespace box2d { "setData", w_Shape_setData }, { "getData", w_Shape_getData }, { "getBoundingBox", w_Shape_getBoundingBox }, + { "getGroupIndex", w_Shape_getGroupIndex }, + { "setGroupIndex", w_Shape_setGroupIndex }, { "destroy", w_Shape_destroy }, { 0, 0 } }; diff --git a/src/modules/physics/box2d/wrap_Shape.h b/src/modules/physics/box2d/wrap_Shape.h index c102e4ff9..921e89f44 100644 --- a/src/modules/physics/box2d/wrap_Shape.h +++ b/src/modules/physics/box2d/wrap_Shape.h @@ -53,6 +53,8 @@ namespace box2d int w_Shape_setData(lua_State * L); int w_Shape_getData(lua_State * L); int w_Shape_getBoundingBox(lua_State * L); + int w_Shape_getGroupIndex(); + int w_Shape_setGroupIndex(); int w_Shape_destroy(lua_State * L); int luaopen_shape(lua_State * L); diff --git a/src/scripts/auto.lua b/src/scripts/auto.lua index 08702f0d7..8687fd1fc 100644 --- a/src/scripts/auto.lua +++ b/src/scripts/auto.lua @@ -28,7 +28,7 @@ function auto(name) end end - local src_output = "const char "..cpp_name.."[] = \n{\n" + local src_output = "const unsigned char "..cpp_name.."[] = \n{\n" for i,line in ipairs(lines) do local concat = {} diff --git a/src/scripts/boot.lua.h b/src/scripts/boot.lua.h index 1c16b2e04..7ece7b050 100644 --- a/src/scripts/boot.lua.h +++ b/src/scripts/boot.lua.h @@ -22,7 +22,7 @@ namespace love { // [boot.lua] -const char boot_lua[] = +const unsigned char boot_lua[] = { 0x1B,0x4C,0x75,0x61,0x51,0x00,0x01,0x04,0x04,0x04,0x08,0x00,0x0A,0x00,0x00, 0x00,0x40,0x62,0x6F,0x6F,0x74,0x2E,0x6C,0x75,0x61,0x00,0x00,0x00,0x00,0x00, diff --git a/src/scripts/graphics.lua.h b/src/scripts/graphics.lua.h index d20342671..95595c0a6 100644 --- a/src/scripts/graphics.lua.h +++ b/src/scripts/graphics.lua.h @@ -22,7 +22,7 @@ namespace love { // [graphics.lua] -const char graphics_lua[] = +const unsigned char graphics_lua[] = { 0x1B,0x4C,0x75,0x61,0x51,0x00,0x01,0x04,0x04,0x04,0x08,0x00,0x0E,0x00,0x00, 0x00,0x40,0x67,0x72,0x61,0x70,0x68,0x69,0x63,0x73,0x2E,0x6C,0x75,0x61,0x00, From 239ddab6aaf96159b6eba1c6e99eff541739efbb Mon Sep 17 00:00:00 2001 From: rude Date: Mon, 4 Jan 2010 20:11:59 +0100 Subject: [PATCH 2/5] Updated readme and changes. --- changes.txt | 12 +++++++++++- readme.txt | 7 +++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/changes.txt b/changes.txt index 404e53b93..0904ba237 100644 --- a/changes.txt +++ b/changes.txt @@ -1,11 +1,21 @@ +LOVE 0.6.1 +---------- + + * Added Shape:setGroupIndex and getGroupIndex. + * Added Body:setFixedRotation and Body:getFixedRotation. + * Added icons and file associations for the debs. + * It's now possible to run a .love from Resources in Mac OSX, thanks to stevejohnson and diordna. + * Fixed a bug with multiple Sources on the same Music. + LOVE 0.6.0 ---------- + * Lost track of 0.6.0 changes a long while ago. Don't trust the list below. + * Added love.graphics.print()/printf(). * Added unicode-translated parameter to love.keypressed(). * Added love.event. * Added love.filesystem.setIdentity(). - * Added experimental support for Lua lanes. * Added OpenAL dependency. * Added SDL_sound dependency. diff --git a/readme.txt b/readme.txt index b1147af00..e89051fca 100644 --- a/readme.txt +++ b/readme.txt @@ -2,13 +2,16 @@ ! WARNING ! ----------- -This software is not complete. This is just a preview. Don't expect to find any interface consistencies between releases at all. With each release, everything you once knew and loved may be brutally murdered. By which I mean removed and/or changed. +This software is not complete. This is just a preview. Don't expect to find any +interface consistencies between releases at all. With each release, everything +you once knew and loved may be brutally murdered. By which I mean removed and/or changed. RUNNING GAMES ------------- -In Windows or other graphical enviroments, just open the .love file you want to run with love.exe (~^-^)~ +In Windows or other graphical enviroments, just open the .love file you want to run +with love.exe (~^-^)~ In a console, type "love" followed by the relative or absolute path to a directory (or archive). From 810f7f4a2856143d9820816140c71ebd1bbede5b Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Mon, 4 Jan 2010 20:18:51 -0600 Subject: [PATCH 3/5] on OS X: no more kludgy linking hack (as long as you use the updated frameworks), turned off Effective C++ warnings (because all they were doing was bloating the logs), and explicitly specified gcc version 4.0 so building works on Snow Leopard (I'm not sure whether it's gcc 4.2's fault, or OpenAL's, but somewhere, something went wrong) --- platform/macosx/love.xcodeproj/project.pbxproj | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/platform/macosx/love.xcodeproj/project.pbxproj b/platform/macosx/love.xcodeproj/project.pbxproj index 41b5a479f..24328bb79 100644 --- a/platform/macosx/love.xcodeproj/project.pbxproj +++ b/platform/macosx/love.xcodeproj/project.pbxproj @@ -1423,7 +1423,6 @@ 8D11072C0486CEB800E47090 /* Sources */, A9255DDE1043185300BA1496 /* Copy Frameworks */, 8D11072E0486CEB800E47090 /* Frameworks */, - A971EA481042798500EAD7F9 /* Change Link Locations */, A9DEC1F51046F3F30049C70C /* Create DMG */, ); buildRules = ( @@ -1466,20 +1465,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - A971EA481042798500EAD7F9 /* Change Link Locations */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Change Link Locations"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "#! /bin/sh\n#Use install_name_tool, make love to search libs in its own framework folder instead\n#*very* hackish.\n\n# IL\ninstall_name_tool -change /Library/Frameworks/IL.framework/Versions/A/IL @executable_path/../Frameworks/IL.framework/Versions/A/IL build/Release/love.app/Contents/MacOS/love\n\n# FreeType\ninstall_name_tool -change /Library/Frameworks/FreeType.framework/Versions/2.3/FreeType @executable_path/../Frameworks/FreeType.framework/Versions/2.3/FreeType build/Release/love.app/Contents/MacOS/love\n\n# SDL\ninstall_name_tool -change /Library/Frameworks/SDL.framework/Versions/A/SDL @executable_path/../Frameworks/SDL.framework/Versions/A/SDL build/Release/love.app/Contents/MacOS/love\n\n# Lua\ninstall_name_tool -change /Library/Frameworks/Lua.framework/Versions/A/Lua @executable_path/../Frameworks/Lua.framework/Versions/A/Lua build/Release/love.app/Contents/MacOS/love\n\n# Ogg\ninstall_name_tool -change /Library/Frameworks/Ogg.framework/Versions/A/Ogg @executable_path/../Frameworks/Ogg.framework/Versions/A/Ogg build/Release/love.app/Contents/MacOS/love\n\ninstall_name_tool -change /Library/Frameworks/Ogg.framework/Versions/A/Ogg @executable_path/../Frameworks/Ogg.framework/Versions/A/Ogg build/Release/love.app/Contents/Frameworks/Vorbis.framework/Versions/A/Vorbis\n\n# Vorbis\ninstall_name_tool -change /Library/Frameworks/Vorbis.framework/Versions/A/Vorbis @executable_path/../Frameworks/Vorbis.framework/Versions/A/Vorbis build/Release/love.app/Contents/MacOS/love\n\n# mpg123\ninstall_name_tool -change /usr/local/lib/libmpg123.0.dylib @executable_path/../Frameworks/mpg123.framework/mpg123 build/Release/love.app/Contents/MacOS/love\n\ninstall_name_tool -change /Library/Frameworks/mpg123.framework/Resources/libltdl.3.dylib @executable_path/../Frameworks/mpg123.framework/Resources/libltdl.3.dylib build/Release/love.app/Contents/Frameworks/mpg123.framework/mpg123\n\n# physfs\ninstall_name_tool -change /Library/Frameworks/physfs.framework @executable_path/../Frameworks/physfs.framework build/Release/love.app/Contents/MacOS/love\n\n# libmodplug\ninstall_name_tool -change /Users/bill/libs/lib/libmodplug.0.dylib @executable_path/../Frameworks/libmodplug.framework/libmodplug build/Release/love.app/Contents/MacOS/love\n\nexit 0"; - }; A9DEC1F51046F3F30049C70C /* Create DMG */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1783,13 +1768,14 @@ GCC_C_LANGUAGE_STANDARD = c99; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = NO; GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = NO; + GCC_VERSION = 4.0; GCC_WARN_64_TO_32_BIT_CONVERSION = NO; GCC_WARN_ABOUT_MISSING_NEWLINE = NO; GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES; GCC_WARN_ABOUT_RETURN_TYPE = NO; GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; + GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO; GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = NO; From 22ab49d167c236501ec29f6127492d05628fedc9 Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Tue, 5 Jan 2010 13:33:52 -0600 Subject: [PATCH 4/5] Fixed bug where disabling keyboard would prevent any handlers from being created. --- src/scripts/boot.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/boot.lua b/src/scripts/boot.lua index f175672d6..2cf732361 100644 --- a/src/scripts/boot.lua +++ b/src/scripts/boot.lua @@ -241,7 +241,7 @@ function love.init() end end - if love.keyboard then + if love.event then love.createhandlers() end From 8d63c73bc4055206514d8262285fe3fd9d51ef5c Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Tue, 5 Jan 2010 13:44:34 -0600 Subject: [PATCH 5/5] new boot.lua run through auto.lua, because I can never remember to do that in one commit. --- src/scripts/boot.lua.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/boot.lua.h b/src/scripts/boot.lua.h index 7ece7b050..9b039d309 100644 --- a/src/scripts/boot.lua.h +++ b/src/scripts/boot.lua.h @@ -457,7 +457,7 @@ const unsigned char boot_lua[] = 0x00,0x86,0x00,0x44,0x00,0x5C,0x00,0x01,0x01,0x16,0x80,0x01,0x80,0x5A,0x01, 0x00,0x00,0x16,0x00,0x01,0x80,0x85,0x41,0x08,0x00,0xC1,0x01,0x0A,0x00,0x00, 0x02,0x00,0x02,0xD5,0x01,0x82,0x03,0x9C,0x41,0x00,0x01,0x61,0x80,0x00,0x00, - 0x16,0x80,0xFD,0x7F,0x45,0x00,0x07,0x00,0x46,0x80,0xC4,0x00,0x5A,0x00,0x00, + 0x16,0x80,0xFD,0x7F,0x45,0x00,0x07,0x00,0x46,0x40,0xC4,0x00,0x5A,0x00,0x00, 0x00,0x16,0x80,0x00,0x80,0x45,0x00,0x07,0x00,0x46,0x40,0xCA,0x00,0x5C,0x40, 0x80,0x00,0x46,0x80,0x41,0x00,0x5A,0x00,0x00,0x00,0x16,0x40,0x09,0x80,0x46, 0x00,0x44,0x00,0x46,0xC0,0xC5,0x00,0x5A,0x00,0x00,0x00,0x16,0x40,0x08,0x80,