diff -Nru blobby-0.8-dfsg/ChangeLog blobby-0.9c/ChangeLog --- blobby-0.8-dfsg/ChangeLog 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/ChangeLog 2011-11-06 15:06:50.000000000 +0000 @@ -1,3 +1,26 @@ +New in Beta 9 (rev. 622) since Alpha 8: +- network game: reduced data transfer +- fixed memleaks +- OGL: improved text rendering speed +- SDL: improved render speed for morphing blobs +- generally improved performance +- limited FPS in menu +- chat +- clock +- blood in SDL mode +- bots sorted +- online replays +- improved bots: difficulty adjustable, better api, better documentation +- customizable rules file + + +New in Alpha 8 (rev. 469) since Alpha 6: +- some graphics improvements +- performance improvements +- names +- credits added + + New in Alpha 6 (rev. 335) since Alpha 5: - More options - Network support diff -Nru blobby-0.8-dfsg/data/CMakeLists.txt blobby-0.9c/data/CMakeLists.txt --- blobby-0.8-dfsg/data/CMakeLists.txt 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/CMakeLists.txt 2011-11-06 15:06:50.000000000 +0000 @@ -1,5 +1,5 @@ macro(add_zip_archive _dir _filetype) - file(GLOB archive_src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${_dir}/*.${_filetype}) + file(GLOB_RECURSE archive_src RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${_dir}/*.${_filetype}) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_dir}.zip COMMAND zip ${CMAKE_CURRENT_BINARY_DIR}/${_dir}.zip ${archive_src} @@ -24,7 +24,11 @@ ${CMAKE_CURRENT_BINARY_DIR}/backgrounds.zip config.xml inputconfig.xml - server.xml) + server.xml + lang_de.xml + lang_en.xml + lang_fr.xml + rules.lua) if (WIN32) install(FILES ${install_files} DESTINATION data) diff -Nru blobby-0.8-dfsg/data/config.xml blobby-0.9c/data/config.xml --- blobby-0.8-dfsg/data/config.xml 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/config.xml 2011-11-06 15:06:50.000000000 +0000 @@ -1,7 +1,7 @@ - + @@ -11,6 +11,7 @@ + @@ -18,14 +19,17 @@ - + - + - + - - + + + + + Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/abbruchbild.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/abbruchbild.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball01.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball01.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball02.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball02.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball03.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball03.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball04.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball04.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball05.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball05.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball06.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball06.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball07.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball07.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball08.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball08.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball09.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball09.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball10.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball10.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball11.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball11.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball12.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball12.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball13.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball13.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball14.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball14.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball15.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball15.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/ball16.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/ball16.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/blobbym1.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/blobbym1.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/blobbym2.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/blobbym2.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/blobbym3.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/blobbym3.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/blobbym4.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/blobbym4.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/blobbym5.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/blobbym5.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/blobZeichenWeiss.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/blobZeichenWeiss.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/bvende.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/bvende.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/cursor.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/cursor.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font00.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font00.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font01.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font01.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font02.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font02.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font03.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font03.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font04.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font04.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font05.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font05.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font06.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font06.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font07.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font07.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font08.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font08.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font09.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font09.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font10.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font10.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font11.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font11.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font12.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font12.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font13.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font13.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font14.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font14.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font15.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font15.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font16.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font16.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font17.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font17.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font18.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font18.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font19.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font19.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font20.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font20.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font21.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font21.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font22.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font22.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font23.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font23.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font24.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font24.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font25.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font25.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font26.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font26.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font27.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font27.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font28.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font28.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font29.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font29.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font30.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font30.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font31.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font31.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font32.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font32.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font33.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font33.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font34.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font34.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font35.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font35.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font36.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font36.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font37.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font37.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font38.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font38.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font39.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font39.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font40.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font40.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font41.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font41.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font42.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font42.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font43.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font43.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font44.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font44.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font45.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font45.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font46.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font46.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font47.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font47.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font48.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font48.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font49.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font49.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font50.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font50.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font51.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font51.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font52.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font52.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font53.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font53.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font00.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font00.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font01.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font01.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font02.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font02.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font03.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font03.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font04.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font04.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font05.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font05.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font06.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font06.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font07.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font07.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font08.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font08.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font09.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font09.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font10.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font10.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font11.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font11.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font12.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font12.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font13.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font13.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font14.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font14.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font15.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font15.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font16.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font16.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font17.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font17.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font18.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font18.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font19.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font19.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font20.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font20.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font21.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font21.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font22.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font22.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font23.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font23.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font24.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font24.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font25.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font25.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font26.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font26.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font27.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font27.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font28.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font28.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font29.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font29.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font30.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font30.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font31.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font31.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font32.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font32.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font33.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font33.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font34.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font34.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font35.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font35.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font36.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font36.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font37.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font37.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font38.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font38.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font39.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font39.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font40.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font40.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font41.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font41.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font42.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font42.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font43.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font43.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font44.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font44.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font45.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font45.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font46.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font46.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font47.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font47.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font48.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font48.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font49.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font49.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font50.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font50.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font51.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font51.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font52.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font52.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/font53.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/font53.bmp differ diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/all-wcprops blobby-0.9c/data/gf2x/font_small/.svn/all-wcprops --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/all-wcprops 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,329 @@ +K 25 +svn:wc:ra_dav:version-url +V 55 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small +END +font10.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font10.bmp +END +font11.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font11.bmp +END +font30.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font30.bmp +END +font12.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font12.bmp +END +font31.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font31.bmp +END +font13.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font13.bmp +END +font14.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font14.bmp +END +font32.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font32.bmp +END +font50.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font50.bmp +END +font15.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font15.bmp +END +font33.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font33.bmp +END +font51.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font51.bmp +END +font16.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font16.bmp +END +font34.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font34.bmp +END +font52.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font52.bmp +END +font17.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font17.bmp +END +font35.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font35.bmp +END +font53.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font53.bmp +END +font18.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font18.bmp +END +font36.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font36.bmp +END +font19.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font19.bmp +END +font37.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font37.bmp +END +font38.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font38.bmp +END +font39.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font39.bmp +END +font00.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font00.bmp +END +font01.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font01.bmp +END +font20.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font20.bmp +END +font02.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font02.bmp +END +font21.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font21.bmp +END +font03.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font03.bmp +END +font22.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font22.bmp +END +font04.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font04.bmp +END +font40.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font40.bmp +END +font23.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font23.bmp +END +font05.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font05.bmp +END +font41.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font41.bmp +END +font24.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font24.bmp +END +font06.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font06.bmp +END +font42.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font42.bmp +END +font25.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font25.bmp +END +font07.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font07.bmp +END +font43.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font43.bmp +END +font26.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font26.bmp +END +font08.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font08.bmp +END +font44.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font44.bmp +END +font27.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font27.bmp +END +font09.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font09.bmp +END +font45.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font45.bmp +END +font28.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font28.bmp +END +font46.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font46.bmp +END +font29.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font29.bmp +END +font47.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font47.bmp +END +font48.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font48.bmp +END +font49.bmp +K 25 +svn:wc:ra_dav:version-url +V 66 +/svnroot/blobby/!svn/ver/563/trunk/data/gf2x/font_small/font49.bmp +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/entries blobby-0.9c/data/gf2x/font_small/.svn/entries --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/entries 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/entries 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,1864 @@ +10 + +dir +634 +https://blobby.svn.sourceforge.net/svnroot/blobby/trunk/data/gf2x/font_small +https://blobby.svn.sourceforge.net/svnroot/blobby + + + +2010-08-13T06:18:19.554296Z +563 +danielknobe + + + + + + + + + + + + + + +5dffb9df-0d16-0410-88a9-e08e82185bbb + +font10.bmp +file + + + + +2011-11-06T15:06:49.828133Z +9ee6a91c7155fef459d7afd0dfd1780d +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font11.bmp +file + + + + +2011-11-06T15:06:49.828133Z +c9951011e5b32fca41d9b8956be01200 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font30.bmp +file + + + + +2011-11-06T15:06:49.828133Z +a55905c6491eb4c6180c8ba5d8c27a14 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font12.bmp +file + + + + +2011-11-06T15:06:49.828133Z +28eac8595ac85f9fdc00ab3f5f4b07c1 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font31.bmp +file + + + + +2011-11-06T15:06:49.828133Z +8d018bc679d586825e065a61413a68fc +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font13.bmp +file + + + + +2011-11-06T15:06:49.828133Z +32b41784439b782c2ecc00100e2b0a8a +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font14.bmp +file + + + + +2011-11-06T15:06:49.828133Z +61e6882759c446b99a002fac7a2a1474 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font32.bmp +file + + + + +2011-11-06T15:06:49.838133Z +5088f5fcd883c5103ee0bd8d13ce76c0 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font50.bmp +file + + + + +2011-11-06T15:06:49.838133Z +34adea3bc9b8ca91b4e29c9066170682 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font15.bmp +file + + + + +2011-11-06T15:06:49.838133Z +2439be68e482c195bd174fa381c79b51 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font33.bmp +file + + + + +2011-11-06T15:06:49.838133Z +a64a8f28b245b109bb3e3048c2e5d933 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font51.bmp +file + + + + +2011-11-06T15:06:49.838133Z +60c794fdcc2138928c1f697da107d1a3 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font16.bmp +file + + + + +2011-11-06T15:06:49.838133Z +287aa9f175a53c1e29602c83d0b39f32 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font34.bmp +file + + + + +2011-11-06T15:06:49.838133Z +6bb095eb28a6a3ee3ad0ee41cf98e2b2 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font52.bmp +file + + + + +2011-11-06T15:06:49.838133Z +f211384e41783c446e359826f0d2c3ac +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font17.bmp +file + + + + +2011-11-06T15:06:49.838133Z +4060315d463b8729771ca34a1ec26cd2 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font35.bmp +file + + + + +2011-11-06T15:06:49.838133Z +bf9eb78dbcac5000b1f4277d5ec0b206 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font53.bmp +file + + + + +2011-11-06T15:06:49.838133Z +05b61422651a8017dbd8ff0e32d6af8b +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font18.bmp +file + + + + +2011-11-06T15:06:49.838133Z +ec8e34953cef605da8b5dda29a22b3cf +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font36.bmp +file + + + + +2011-11-06T15:06:49.838133Z +d433a47e8a2ce4d9389a8b4e5edf44f8 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font19.bmp +file + + + + +2011-11-06T15:06:49.838133Z +f0b6a427e3f0b46dbb678689bc00ce95 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font37.bmp +file + + + + +2011-11-06T15:06:49.838133Z +38d7c91e4224961de1c9279b91b1855e +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font38.bmp +file + + + + +2011-11-06T15:06:49.838133Z +f9fa65086d1041819b96063844c7e2d0 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font39.bmp +file + + + + +2011-11-06T15:06:49.838133Z +e7099021e71f3b1c86c3d4a0a784d9b5 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font00.bmp +file + + + + +2011-11-06T15:06:49.838133Z +a5f70a6aa8e6e42161eab6dbbc21d588 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font01.bmp +file + + + + +2011-11-06T15:06:49.838133Z +0618c6431d248df01c2a3edccaa1da29 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font20.bmp +file + + + + +2011-11-06T15:06:49.838133Z +757710b8e7bfdc5b79485ade937ab286 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font02.bmp +file + + + + +2011-11-06T15:06:49.838133Z +f4d5dc89f762a1c4d872638a3e70b4c2 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font21.bmp +file + + + + +2011-11-06T15:06:49.838133Z +f7dcd95b818d8d618afdbf09cabeeb4c +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font03.bmp +file + + + + +2011-11-06T15:06:49.838133Z +c1692ea0a7fca58860a4d2af929bad79 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font04.bmp +file + + + + +2011-11-06T15:06:49.838133Z +bfebad21b439dbaa6833de0dc5351ec0 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font22.bmp +file + + + + +2011-11-06T15:06:49.838133Z +e7b0765e03e021e35ff187e97788df8d +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font40.bmp +file + + + + +2011-11-06T15:06:49.848133Z +edbf25cc207da2a21b35eb974e872c4c +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font23.bmp +file + + + + +2011-11-06T15:06:49.848133Z +405ffc73b206dedba12037a3e06a4844 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font05.bmp +file + + + + +2011-11-06T15:06:49.848133Z +b8c9d503312e7b397dcf71e625ffbc65 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font41.bmp +file + + + + +2011-11-06T15:06:49.848133Z +75c2c740f2f1557fe7bf89cf0736c525 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font24.bmp +file + + + + +2011-11-06T15:06:49.848133Z +b28a969ead0e3cf994e1a3646d56ca95 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font06.bmp +file + + + + +2011-11-06T15:06:49.848133Z +d4b846d988bf42db147cdbe7395a85f0 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font42.bmp +file + + + + +2011-11-06T15:06:49.848133Z +efa778ac0671c6a4a127ecf9aae26ce2 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font25.bmp +file + + + + +2011-11-06T15:06:49.848133Z +3c9f39c41877d1382a9f7d4bcaffc3c8 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font07.bmp +file + + + + +2011-11-06T15:06:49.848133Z +3b527362e809936bbd33eae35645a458 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font43.bmp +file + + + + +2011-11-06T15:06:49.848133Z +b72f664a2d86c55f1ce6d4165f809ec9 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font26.bmp +file + + + + +2011-11-06T15:06:49.848133Z +ceec5d8ccda4572250fba8e5a2bcf7e7 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font08.bmp +file + + + + +2011-11-06T15:06:49.848133Z +ed1b2b558ab73c6a3737495b8bcd58ea +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font44.bmp +file + + + + +2011-11-06T15:06:49.848133Z +d9569543eee3c2ceae909d54fe60b860 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font27.bmp +file + + + + +2011-11-06T15:06:49.848133Z +119d0c51cb59fb6ad8cdea8b3a89ad08 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font09.bmp +file + + + + +2011-11-06T15:06:49.848133Z +ad19f44f5690dd007a0fb7c7b6093266 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font45.bmp +file + + + + +2011-11-06T15:06:49.848133Z +8a08b10d8c6e78aa6ee37806b04bf842 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font28.bmp +file + + + + +2011-11-06T15:06:49.848133Z +1f383357cca28341afe49808cb162363 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font46.bmp +file + + + + +2011-11-06T15:06:49.848133Z +09c78443718f7b7549572e9312e4a212 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font29.bmp +file + + + + +2011-11-06T15:06:49.848133Z +badcc8bfec03aadf3b2a21ac28faa8ce +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font47.bmp +file + + + + +2011-11-06T15:06:49.848133Z +2d14a806eea3719e9168d496828fa2d8 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font48.bmp +file + + + + +2011-11-06T15:06:49.848133Z +d98a17306f9428484505d526e908d39b +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + +font49.bmp +file + + + + +2011-11-06T15:06:49.848133Z +c1d16a8b114c7b4d1cf300d272c2f883 +2010-08-13T06:18:19.554296Z +563 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +246 + diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font00.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font00.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font00.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font00.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font01.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font01.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font01.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font01.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font02.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font02.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font02.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font02.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font03.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font03.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font03.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font03.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font04.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font04.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font04.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font04.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font05.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font05.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font05.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font05.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font06.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font06.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font06.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font06.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font07.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font07.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font07.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font07.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font08.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font08.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font08.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font08.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font09.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font09.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font09.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font09.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font10.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font10.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font10.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font10.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font11.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font11.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font11.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font11.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font12.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font12.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font12.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font12.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font13.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font13.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font13.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font13.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font14.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font14.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font14.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font14.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font15.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font15.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font15.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font15.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font16.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font16.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font16.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font16.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font17.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font17.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font17.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font17.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font18.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font18.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font18.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font18.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font19.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font19.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font19.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font19.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font20.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font20.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font20.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font20.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font21.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font21.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font21.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font21.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font22.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font22.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font22.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font22.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font23.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font23.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font23.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font23.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font24.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font24.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font24.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font24.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font25.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font25.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font25.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font25.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font26.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font26.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font26.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font26.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font27.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font27.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font27.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font27.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font28.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font28.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font28.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font28.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font29.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font29.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font29.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font29.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font30.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font30.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font30.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font30.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font31.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font31.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font31.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font31.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font32.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font32.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font32.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font32.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font33.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font33.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font33.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font33.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font34.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font34.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font34.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font34.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font35.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font35.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font35.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font35.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font36.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font36.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font36.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font36.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font37.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font37.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font37.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font37.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font38.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font38.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font38.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font38.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font39.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font39.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font39.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font39.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font40.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font40.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font40.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font40.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font41.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font41.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font41.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font41.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font42.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font42.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font42.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font42.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font43.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font43.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font43.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font43.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font44.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font44.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font44.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font44.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font45.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font45.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font45.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font45.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font46.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font46.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font46.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font46.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font47.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font47.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font47.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font47.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font48.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font48.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font48.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font48.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font49.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font49.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font49.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font49.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font50.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font50.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font50.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font50.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font51.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font51.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font51.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font51.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font52.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font52.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font52.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font52.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END diff -Nru blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font53.bmp.svn-base blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font53.bmp.svn-base --- blobby-0.8-dfsg/data/gf2x/font_small/.svn/prop-base/font53.bmp.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/gf2x/font_small/.svn/prop-base/font53.bmp.svn-base 2011-11-06 15:06:49.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:mime-type +V 24 +application/octet-stream +END Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font00.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font00.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font01.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font01.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font02.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font02.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font03.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font03.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font04.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font04.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font05.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font05.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font06.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font06.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font07.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font07.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font08.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font08.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font09.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font09.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font10.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font10.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font11.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font11.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font12.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font12.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font13.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font13.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font14.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font14.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font15.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font15.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font16.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font16.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font17.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font17.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font18.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font18.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font19.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font19.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font20.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font20.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font21.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font21.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font22.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font22.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font23.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font23.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font24.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font24.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font25.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font25.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font26.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font26.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font27.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font27.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font28.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font28.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font29.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font29.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font30.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font30.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font31.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font31.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font32.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font32.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font33.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font33.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font34.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font34.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font35.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font35.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font36.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font36.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font37.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font37.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font38.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font38.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font39.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font39.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font40.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font40.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font41.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font41.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font42.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font42.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font43.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font43.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font44.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font44.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font45.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font45.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font46.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font46.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font47.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font47.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font48.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font48.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font49.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font49.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font50.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font50.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font51.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font51.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font52.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font52.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/font_small/.svn/text-base/font53.bmp.svn-base and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/font_small/.svn/text-base/font53.bmp.svn-base differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/pfeil_oben.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/pfeil_oben.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/pfeil_unten.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/pfeil_unten.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/pokal.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/pokal.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/sch11.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/sch11.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/sch12.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/sch12.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/sch13.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/sch13.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/sch14.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/sch14.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/sch15.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/sch15.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/schball.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/schball.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/schild.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/schild.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/stange.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/stange.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/strand2.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/strand2.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gf2x/titel.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gf2x/titel.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/blood.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/blood.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font00.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font00.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font01.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font01.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font02.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font02.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font03.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font03.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font04.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font04.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font05.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font05.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font06.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font06.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font07.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font07.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font08.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font08.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font09.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font09.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font10.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font10.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font11.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font11.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font12.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font12.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font13.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font13.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font14.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font14.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font15.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font15.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font16.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font16.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font17.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font17.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font18.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font18.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font19.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font19.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font20.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font20.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font21.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font21.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font22.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font22.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font23.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font23.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font24.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font24.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font25.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font25.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font26.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font26.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font27.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font27.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font28.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font28.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font29.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font29.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font30.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font30.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font31.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font31.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font32.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font32.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font33.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font33.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font34.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font34.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font35.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font35.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font36.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font36.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font37.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font37.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font38.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font38.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font39.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font39.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font40.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font40.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font41.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font41.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font42.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font42.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font43.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font43.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font44.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font44.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font45.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font45.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font46.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font46.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font47.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font47.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font48.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font48.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font49.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font49.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font50.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font50.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font51.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font51.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font52.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font52.bmp differ Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/gfx/font_small/font53.bmp and /tmp/zGIqAWId6S/blobby-0.9c/data/gfx/font_small/font53.bmp differ diff -Nru blobby-0.8-dfsg/data/lang_de.xml blobby-0.9c/data/lang_de.xml --- blobby-0.8-dfsg/data/lang_de.xml 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/lang_de.xml 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru blobby-0.8-dfsg/data/lang_en.xml blobby-0.9c/data/lang_en.xml --- blobby-0.8-dfsg/data/lang_en.xml 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/lang_en.xml 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru blobby-0.8-dfsg/data/lang_fr.xml blobby-0.9c/data/lang_fr.xml --- blobby-0.8-dfsg/data/lang_fr.xml 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/lang_fr.xml 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru blobby-0.8-dfsg/data/rules.lua blobby-0.9c/data/rules.lua --- blobby-0.8-dfsg/data/rules.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/rules.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,53 @@ +-- most simple ruleset: for each mistake, the opponent gets a point +-- includes comments for documentation purposes + +-- rules.lua doc +-- function OnMistake +-- IMPLEMENTED BY RULES.lua +-- called when a player makes a mistake +-- when this function is called, servinglayer() returns which player has +-- served (so it is not neccesarily the enemy of the player who made the mistake) +-- param: player - player who made the mistake +-- return: none + +-- when a player makes a mistake, the other one gets a point if he was the serving player +function OnMistake(player) + -- function opponent + -- PREDEFINED + -- param: player - player of whom you want to get the opponent + -- return: opponent of the player, so, for LEFT_PLAYER, RIGHT_PLAYER is returned and vice-versa + + -- function servingplayer + -- PREDEFINED + -- param: none + -- return: which player has served + if( opponent(player) == servingplayer() ) then + -- function score + -- PREDEFINED + -- param: player - player who gets a point + -- return: none + + score(opponent(player)) + end +end + +-- function IsWinning +-- IMPLEMENTED BY RULES.lua +-- called when it is determined whether a player has won +-- params: lscore: score of left player +-- rscore: score of right player +-- return: whether a player has won +function IsWinning(lscore, rscore) + -- constant SCORE_TO_WIN: number of points for a player to win + if lscore >= SCORE_TO_WIN and lscore > rscore + 2 then + return true + end + if rscore >= SCORE_TO_WIN and rscore > lscore + 2 then + return true + end + return false +end + + + + diff -Nru blobby-0.8-dfsg/data/scripts/axji.lua blobby-0.9c/data/scripts/axji.lua --- blobby-0.8-dfsg/data/scripts/axji.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/axji.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -function OnOpponentServe() - moveto(120) -end - -wait = 0 -serv = true -aggroservice = 64 -- versetzung zum Ball je gr�sser desto tiefer fliegt der Service 0-64 - - -function OnServe(ballready) - moveto(ballx()) -- unter den Ball stellen - wait = wait + 1 -- waittimer anwerfen - serv = true -- servflag setzen - if ballready then -- ball bereit - if wait > 90 then -- 90 einheiten gewartet - jump() -- Springen also eigentlich den Ball aufwerfen - wait = 0 -- Wait timer zur�cksetzen - end - end -end - - -function OnGame() - - -- bestimmen wenn der service vertig ist - if (ballx() > 400) then -- sobald der ball auf der anderen seite ist ;) - serv = false -- serv flag zur�cksetzen - end - - if serv then -- sprunganschlag code - moveto(estimate()-aggroservice) -- Bewegt sich unter den Ball und schl�gt mit einer gewissen aggressivit�t an bei 64 knapp �bers Netz - -- warscheinlich w�re ein Match.random() angebracht - if bally() < 550 then -- wenn der Ball wieder runter kommt - jump() - end - else - if (estimate() < 0) then -- Falls der Ball von Hinten kommt - moveto(math.abs(estimate())-100) -- funktioniert noch nicht richtig - else - moveto(estimate()-20) --sonst immer leicht hinter dem Ball bleiben - end - end -end diff -Nru blobby-0.8-dfsg/data/scripts/bert.ai blobby-0.9c/data/scripts/bert.ai --- blobby-0.8-dfsg/data/scripts/bert.ai 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/bert.ai 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -// Note: This still needs to be ported to lua - -var bsizx,bsizy,cpud1; - -function main() { - var i,alti,j,factor,direct, - touchcnt,x,y,delay,bx,by,vbx,vby; - - bsizx=64; - bsizy=64; - - j=side(); - factor=j*2-1; - - delay=0; - while (1) { - stop(); - stopjump(); - - bx=ballx(); - by=bally(); - vbx=bspeedx(); - vby=bspeedy(); - touchcnt=touches(); - x=posx(); - y=posy(); - - direct=1; - - i=estimate(200); - - if (i>-9000) { - alti=i; - - if (j==1) { - if (i>800-bsizx /2) { - i=1600-i-bsizx;direct=0; - } - if (i<405+bsizx /2) { - i=810+bsizx-i;direct=0; - } - if (i<500) { - if (touchcnt<2) { - i=i-bsizx /2; - } - } - } else { - if (i<0+bsizx /2) { - i=-i+bsizx; - direct=0; - } - if (i>395-bsizx /2) { - i=790-bsizx-i; - direct=0; - } - if (i>300) { - if (touchcnt<2) { - i=i+bsizx /2; - } - } - } - - i=i+(bsizx / 3)*factor; - - //if (i>=x+7) right(); - //if (i<=x-7) left(); - moveto(i); - } - stopjump(); - if(vby<=10) - if (factor*(x-bx)<21) - if (factor*(bx-x)<7) - if (abs(bx-x)<120) - if (abs(vby)<65) - if (by>200) - if (by-y>70) - if ((by<400) || (vby==0)) - if (abs(vbx)<20) - if (!balldown()) jump(); - if (random(300)==0) jump(); - if (i>-9000) { - if ((abs(i-x)>75) && (abs(bx-x)<65) && (vby<0) ) { - jump(); - } - } - if (touching()) { - stop(); - } - - if (!launched()) { - delay+=1; - stopjump(); - if (delay>=30) jump(); - } - - wait(); - } //while -} //function - diff -Nru blobby-0.8-dfsg/data/scripts/com_04c.lua blobby-0.9c/data/scripts/com_04c.lua --- blobby-0.8-dfsg/data/scripts/com_04c.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/com_04c.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ --- Flags und runners -wait = 0 -naechsterBallSchmettern = true -- evtl Variablennamen wechseln -angriffsstaerke = 50 -- versetzung zum Ball je grösser desto tiefer fliegt der Service 0-64( 64 ist ca CONST_BALLRADIUS + CONST_BLOBBY_BAUCH_RADIUS) -angriffsstaerkeNeuBerechnen =false -- neuberechnung von angriffsstaerke => Variable Angriffe - --- Konstanten - -CONST_FELD_LAENGE = 800 -CONST_BALL_RADIUS = 31.5 -CONST_GROUND_PLANE = 100 - -CONST_MITTE = CONST_FELD_LAENGE/2 -CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS - - -CONST_BLOBBY_HOEHE = 89 -CONST_BLOBBY_KOPF_RADIUS = 25 -CONST_BLOBBY_BAUCH_RADIUS = 33 -CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS - -CONST_NETZ_RADIUS = 7 -CONST_NETZ_HOEHE = 157 - --- Linke Berührungsebene des Balls falls er ans Netz kommt -CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS - - - -function OnOpponentServe() - moveto(120) - generatenaechsterBallSchmettern() -- der gegner soll den smash ja nicht vorhersagen können -end - -function OnServe(ballready) - moveto(ballx()) - wait = wait + 1 - naechsterBallSchmettern = true - if ballready then - if wait > 90 then - jump() - wait = 0 - end - end -end - -function OnGame() - naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht - target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG) - - if naechsterBallSchmettern then - sprungattacke(angriffsstaerke) - return - end - - -- nun kümmern wir uns um die Bälle die ans netz prallen - if ((target > CONST_NETZ_LINKS) and (ballx() < CONST_NETZ_LINKS)) then - netzappraller(target) - return - end - - moveto(target) - -end - - -function netzappraller(p_target) - moveto(CONST_NETZ_LINKS - (p_target - CONST_NETZ_LINKS) + math.abs(bspeedx()*bspeedx()*1.4)) -end - - - -function sprungattacke(p_angriffsstaerke) - moveto(ballx()-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben - if bally() < 580 then - jump() - end -end - -function naechsterBallSchmetternFlagTesten() - if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt - naechsterBallSchmettern = false - angriffsstaerkeNeuBerechnen = true -- da würde es sicher auch einen Inteligenteren Test geben. - return - end - - if (angriffsstaerkeNeuBerechnen == true) then - generatenaechsterBallSchmettern() - end - - - if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein - naechsterBallSchmettern = false - return - end - - if (touches() == 2) then -- nach der 2. Berührung angreifen - if (bally() > 500) then -- erst wenn der Ball hoeher als 500 fliegt sonst gibt es keinen schönen Schmetterball. - naechsterBallSchmettern = true - end - return - end - - if ((ballx() < (400-CONST_BALL_RADIUS)) and (bally() < 200) and (math.abs(bspeedx()) < 40)) then -- der ball könnte noch drüber fliegen ** noch optimieren - naechsterBallSchmettern = true - return - end -end - -function generatenaechsterBallSchmettern() - angriffsstaerkeNeuBerechnen = false; - angriffsstaerke = math.random(15,64) -- variiert mit der Angriffsstärke also auch mit den Anschlägen -end - -function estimImpact(bx,by,vbx,vby,destY) -- erlaubt ein besseres Estimate mit ein paar umbeding nötigen Angaben - bgrav = 0.28 - - time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) - resultX = (vbx * time1) + bx - - if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der Hinteren Ebene - resultX = math.abs(CONST_BALL_RADIUS - resultX) + CONST_BALL_RADIUS - end - - if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene - resultX = CONST_FELD_LAENGE - (resultX - CONST_FELD_LAENGE) - end - -- test --- if(resultX > CONST_MITTE - CONST_BALL_RADIUS)then --- resultX = -resultX --- end - - return resultX -end - -function cleanMoveTo(position) -- eine nette Spielerei ;) - if (posx() ~= position) then - moveto(position) - end -end diff -Nru blobby-0.8-dfsg/data/scripts/com_04d.lua blobby-0.9c/data/scripts/com_04d.lua --- blobby-0.8-dfsg/data/scripts/com_04d.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/com_04d.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ --- Flags und runners -wait = 0 -naechsterBallSchmettern = true -- evtl Variablennamen wechseln -angriffsstaerke = 50 -- versetzung zum Ball je grösser desto tiefer fliegt der Service 0-64( 64 ist ca CONST_BALLRADIUS + CONST_BLOBBY_BAUCH_RADIUS) -angriffsstaerkeNeuBerechnen =false -- neuberechnung von angriffsstaerke => Variable Angriffe - --- Konstanten - -CONST_FELD_LAENGE = 800 -CONST_BALL_RADIUS = 31.5 -CONST_GROUND_PLANE = 100 - -CONST_MITTE = CONST_FELD_LAENGE/2 -CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS - - -CONST_BLOBBY_HOEHE = 89 -CONST_BLOBBY_KOPF_RADIUS = 25 -CONST_BLOBBY_BAUCH_RADIUS = 33 -CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS - -CONST_NETZ_RADIUS = 7 -CONST_NETZ_HOEHE = 157 - --- Linke Berührungsebene des Balls falls er ans Netz kommt -CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS - - - -function OnOpponentServe() - moveto(120) - generatenaechsterBallSchmettern() -- der gegner soll den smash ja nicht vorhersagen können -end - -function OnServe(ballready) - moveto(ballx()) - wait = wait + 1 - naechsterBallSchmettern = true - if ballready then - if wait > 90 then - jump() - wait = 0 - end - end -end - -function OnGame() - naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht - target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG) - - if target > 440 then - moveto(120) - else - if naechsterBallSchmettern then - sprungattacke(angriffsstaerke) - return - end - - -- nun kümmern wir uns um die Bälle die ans netz prallen - if ((target > CONST_NETZ_LINKS) and (ballx() < CONST_NETZ_LINKS)) then - netzappraller(target) - return - end - - moveto(target) - end -end - - -function netzappraller(p_target) - moveto(CONST_NETZ_LINKS - (p_target - CONST_NETZ_LINKS) + math.abs(bspeedx()*bspeedx()*1.4)) -end - - - -function sprungattacke(p_angriffsstaerke) - moveto(ballx()-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben - if bally() < 580 then - jump() - end -end - -function naechsterBallSchmetternFlagTesten() - if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt - naechsterBallSchmettern = false - angriffsstaerkeNeuBerechnen = true -- da würde es sicher auch einen Inteligenteren Test geben. - return - end - - if (angriffsstaerkeNeuBerechnen == true) then - generatenaechsterBallSchmettern() - end - - - if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein - naechsterBallSchmettern = false - return - end - - if (touches() == 2) then -- nach der 2. Berührung angreifen - if (bally() > 500) then -- erst wenn der Ball hoeher als 500 fliegt sonst gibt es keinen schönen Schmetterball. - naechsterBallSchmettern = true - end - return - end - - if ((ballx() < (400-CONST_BALL_RADIUS)) and (bally() < 200) and (math.abs(bspeedx()) < 40)) then -- der ball könnte noch drüber fliegen ** noch optimieren - naechsterBallSchmettern = true - return - end -end - -function generatenaechsterBallSchmettern() - angriffsstaerkeNeuBerechnen = false; - angriffsstaerke = math.random(20,55) -- variiert mit der Angriffsstärke also auch mit den Anschlägen -end - -function estimImpact(bx,by,vbx,vby,destY) -- erlaubt ein besseres Estimate mit ein paar umbeding nötigen Angaben - bgrav = 0.28 - - time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) - resultX = (vbx * time1) + bx - - if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der Hinteren Ebene - resultX = math.abs(CONST_BALL_RADIUS - resultX) + CONST_BALL_RADIUS - end - - if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene - resultX = CONST_FELD_LAENGE - (resultX - CONST_FELD_LAENGE) - end - - return resultX -end - -function cleanMoveTo(position) -- eine nette Spielerei ;) - if (posx() ~= position) then - moveto(position) - end -end diff -Nru blobby-0.8-dfsg/data/scripts/com_10B2ex.lua blobby-0.9c/data/scripts/com_10B2ex.lua --- blobby-0.8-dfsg/data/scripts/com_10B2ex.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/com_10B2ex.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ --- Com 1.0 extrem Beta 2 Schmetter-Mod --- by Oreon, Axji & Enormator --- Name: com_10eB2_Schmettermod - --- Flags und runners -wait = 0 -naechsterBallSchmettern = true -- evtl Variablennamen wechseln - - --- Weltkonstanten - -CONST_FELD_LAENGE = 800 -CONST_BALL_RADIUS = 31.5 -CONST_GROUND_PLANE = 100 - -CONST_BALL_GRAVITY = 0.28 - -CONST_MITTE = CONST_FELD_LAENGE/2 -CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS - -CONST_BLOBBY_HOEHE = 89 -CONST_BLOBBY_KOPF_RADIUS = 25 -CONST_BLOBBY_BAUCH_RADIUS = 33 -CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS -CONST_BLOBBY_MAXJUMP = 393.625 - -CONST_NETZ_RADIUS = 7 -CONST_NETZ_HOEHE = 323 - --- Ber�hrungsebene des Balls falls er ans Netz kommt -CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS -CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS - --- Charakter -CONST_ANGRIFFSGRUNDWERT_MIN = 30 -CONST_ANGRIFFSGRUNDWERT_MAX = 55 -MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN -MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX -ANGRIFFSEINSCHRAENKUNG_HINTEN = 10 - --- sonstige Einstellungen -servexVersetzung=-7 --Wert ist so gewaehlt, dass der Ball nah ans Netz fliegt, der Gegner ihn aber grade nicht erreichen kann - --- ***ANFANG*** - -function OnOpponentServe() - moveto(130) -end - -function OnServe(ballready) - servex=ballx()+servexVersetzung - naechsterBallSchmettern = true - generatenaechsterBallSchmettern() - moveto(servex) - if ballready and (servex-2 < posx()) and (posx() < servex+2) then - jump() - end -end - -function OnGame() - target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) --X Ziel in Blobbyhoehe - targets = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,2) --X Richtung (-1 oder 1) bei Einschlag - targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE,1) --X Ziel in Netzhoehe (Netzrollerberechnung) - targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,1) --X Ziel in Schmetterhoehe - naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht - - if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann - generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen - end - - if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht - moveto(135) --Dann auf Standartposition warten - else - if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern - naechsterBallSchmettern = true - end - - if naechsterBallSchmettern then - if ((math.abs(bspeedx()) < 4) or (estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,2) < 0)) then - sprungattacke(angriffsstaerke) - else - if (targetJump < CONST_MITTE / 2) then - sprungattacke(-35) --an Rueckwand spielen - else - sprungattacke(0) --weiterleiten - end - end - return - end - - moveto(target) - end -end - - -function sprungattacke(p_angriffsstaerke) - p_angriffsstaerke=math.max(p_angriffsstaerke, MIN_ANGRIFFSSTAERKE + ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so hoch spielen (kommt nicht auf die andere Seite) - p_angriffsstaerke=math.min(p_angriffsstaerke, MAX_ANGRIFFSSTAERKE - ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so tief spielen (kommt ans Netz) - - moveto(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die St�rke des gew�nschten schlages angegeben - - if (bally() < 580) and (bspeedy() < 0) then - jump() - end -end - -function naechsterBallSchmetternFlagTesten() - naechsterBallSchmettern = true -end - -function generatenaechsterBallSchmettern() - angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) -end - -function estimImpact(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding n�tigen Angaben - bgrav = 0.28 - - time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) - resultX = (vbx * time1) + bx - estimbspeedx=bspeedx()/math.abs(bspeedx()) - - if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene - resultX = 2 * CONST_FELD_LAENGE - resultX - estimbspeedx=-estimbspeedx - end - - if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene - resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS - estimbspeedx=-estimbspeedx - KollisionLinks = true - else - KollisionLinks = false - end - - if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind - resultX = 2 * CONST_NETZ_LINKS - resultX - estimbspeedx=-estimbspeedx - end - - if (Frage == 1) then - return resultX - end - if (Frage == 2) then - return estimbspeedx - end -end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/com_10eB1.lua blobby-0.9c/data/scripts/com_10eB1.lua --- blobby-0.8-dfsg/data/scripts/com_10eB1.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/com_10eB1.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ --- Com 1.0 human Beta 1 --- by Oreon, Axji & Enormator - --- Flags und runners -wait = 0 -naechsterBallSchmettern = true -- evtl Variablennamen wechseln - - --- Weltkonstanten - -CONST_FELD_LAENGE = 800 -CONST_BALL_RADIUS = 31.5 -CONST_GROUND_PLANE = 100 - -CONST_BALL_GRAVITY = 0.28 - -CONST_MITTE = CONST_FELD_LAENGE/2 -CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS - -CONST_BLOBBY_HOEHE = 89 -CONST_BLOBBY_KOPF_RADIUS = 25 -CONST_BLOBBY_BAUCH_RADIUS = 33 -CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS -CONST_BLOBBY_MAXJUMP = 393.625 - -CONST_NETZ_RADIUS = 7 -CONST_NETZ_HOEHE = 323 - --- Berührungsebene des Balls falls er ans Netz kommt -CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS -CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS - --- Charakter -CONST_ANGRIFFSGRUNDWERT_MIN = 30 -CONST_ANGRIFFSGRUNDWERT_MAX = 55 -MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN -MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX - - --- ***ANFANG*** - -function OnOpponentServe() - moveto(130) -end - -function OnServe(ballready) - naechsterBallSchmettern = true - generatenaechsterBallSchmettern() - moveto(ballx()) - if ballready and (ballx()-3 < posx()) and (posx() < ballx()+3) then - jump() - end -end - -function OnGame() - naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht - target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) --X Ziel in Blobbyhoehe - targets = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,2) --X Richtung (-1 oder 1) bei Einschlag - targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE,1) --X Ziel in Netzhoehe (Netzrollerberechnung) - targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,1) --X Ziel in Schmetterhoehe - - if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann - generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen - end - - if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht - moveto(135) --Dann auf Standartposition warten - else - if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern - naechsterBallSchmettern = true - end - - if naechsterBallSchmettern then - if ((math.abs(bspeedx()) < 4) or (bspeedx() < 0)) then - sprungattacke(angriffsstaerke) - else - if (targetJump < CONST_MITTE / 2) then - sprungattacke(-30) --an Rueckwand spielen - else - sprungattacke(0) --weiterleiten - end - end - return - end - - moveto(target) - end -end - - -function sprungattacke(p_angriffsstaerke) - if (bally() < 550) and (math.abs(ballx() - posx()) > 200) then -- Falls nicht schmetterbar - moveto (target - 25) --Dann Notloesung versuchen - return - end - - moveto(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben - - if (bally() < 580) and (bspeedy() < 0) then - jump() - end -end - -function naechsterBallSchmetternFlagTesten() - if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt - naechsterBallSchmettern = false - return - end - - if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein - naechsterBallSchmettern = false - return - end - - if (touches() == 1) and (math.abs(bspeedx()) < 2) then -- schon nach der 1ten Beruehrung angreifen wenn der Ball gut kommt - naechsterBallSchmettern = true - return - end - - if (touches() == 2) then -- nach der 2. Berührung angreifen - naechsterBallSchmettern = true - return - end - naechsterBallSchmettern = false -end - -function generatenaechsterBallSchmettern() - angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) -end - -function estimImpact(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding nötigen Angaben - bgrav = 0.28 - - time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) - resultX = (vbx * time1) + bx - estimbspeedx=bspeedx()/math.abs(bspeedx()) - - if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene - resultX = 2 * CONST_FELD_LAENGE - resultX - estimbspeedx=-estimbspeedx - end - - if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene - resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS - estimbspeedx=-estimbspeedx - KollisionLinks = true - else - KollisionLinks = false - end - - if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind - resultX = 2 * CONST_NETZ_LINKS - resultX - estimbspeedx=-estimbspeedx - end - - if (Frage == 1) then - return resultX - end - if (Frage == 2) then - return estimbspeedx - end -end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/com_10eB2.lua blobby-0.9c/data/scripts/com_10eB2.lua --- blobby-0.8-dfsg/data/scripts/com_10eB2.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/com_10eB2.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,164 +0,0 @@ --- Com 1.0 extrem Beta 2 --- by Oreon, Axji & Enormator - --- Flags und runners -wait = 0 -naechsterBallSchmettern = true -- evtl Variablennamen wechseln - - --- Weltkonstanten - -CONST_FELD_LAENGE = 800 -CONST_BALL_RADIUS = 31.5 -CONST_GROUND_PLANE = 100 - -CONST_BALL_GRAVITY = 0.28 - -CONST_MITTE = CONST_FELD_LAENGE/2 -CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS - -CONST_BLOBBY_HOEHE = 89 -CONST_BLOBBY_KOPF_RADIUS = 25 -CONST_BLOBBY_BAUCH_RADIUS = 33 -CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS -CONST_BLOBBY_MAXJUMP = 393.625 - -CONST_NETZ_RADIUS = 7 -CONST_NETZ_HOEHE = 323 - --- Berührungsebene des Balls falls er ans Netz kommt -CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS -CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS - --- Charakter -CONST_ANGRIFFSGRUNDWERT_MIN = 30 -CONST_ANGRIFFSGRUNDWERT_MAX = 55 -MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN -MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX -ANGRIFFSEINSCHRAENKUNG_HINTEN = 10 - --- sonstige Einstellungen -servexVersetzung=-7 --Wert ist so gewaehlt, dass der Ball nah ans Netz fliegt, der Gegner ihn aber grade nicht erreichen kann - --- ***ANFANG*** - -function OnOpponentServe() - moveto(130) -end - -function OnServe(ballready) - servex=ballx()+servexVersetzung - naechsterBallSchmettern = true - generatenaechsterBallSchmettern() - moveto(servex) - if ballready and (servex-2 < posx()) and (posx() < servex+2) then - jump() - end -end - -function OnGame() - target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) --X Ziel in Blobbyhoehe - targets = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,2) --X Richtung (-1 oder 1) bei Einschlag - targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE,1) --X Ziel in Netzhoehe (Netzrollerberechnung) - targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,1) --X Ziel in Schmetterhoehe - naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht - - if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann - generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen - end - - if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht - moveto(135) --Dann auf Standartposition warten - else - if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern - naechsterBallSchmettern = true - end - - if naechsterBallSchmettern then - if ((math.abs(bspeedx()) < 4) or (estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,2) < 0)) then - sprungattacke(angriffsstaerke) - else - if (targetJump < CONST_MITTE / 2) then - sprungattacke(-35) --an Rueckwand spielen - else - sprungattacke(0) --weiterleiten - end - end - return - end - - moveto(target) - end -end - - -function sprungattacke(p_angriffsstaerke) - p_angriffsstaerke=math.max(p_angriffsstaerke, MIN_ANGRIFFSSTAERKE + ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so hoch spielen (kommt nicht auf die andere Seite) - p_angriffsstaerke=math.min(p_angriffsstaerke, MAX_ANGRIFFSSTAERKE - ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so tief spielen (kommt ans Netz) - - moveto(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben - - if (bally() < 580) and (bspeedy() < 0) then - jump() - end -end - -function naechsterBallSchmetternFlagTesten() - if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt - naechsterBallSchmettern = false - return - end - - if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein - naechsterBallSchmettern = false - return - end - - if (touches() == 1) and (math.abs(bspeedx()) < 2) then -- schon nach der 1ten Beruehrung angreifen wenn der Ball gut kommt - naechsterBallSchmettern = true - return - end - - if (touches() == 2) then -- nach der 2. Berührung angreifen - naechsterBallSchmettern = true - return - end - naechsterBallSchmettern = false -end - -function generatenaechsterBallSchmettern() - angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) -end - -function estimImpact(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding nötigen Angaben - bgrav = 0.28 - - time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) - resultX = (vbx * time1) + bx - estimbspeedx=bspeedx()/math.abs(bspeedx()) - - if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene - resultX = 2 * CONST_FELD_LAENGE - resultX - estimbspeedx=-estimbspeedx - end - - if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene - resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS - estimbspeedx=-estimbspeedx - KollisionLinks = true - else - KollisionLinks = false - end - - if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind - resultX = 2 * CONST_NETZ_LINKS - resultX - estimbspeedx=-estimbspeedx - end - - if (Frage == 1) then - return resultX - end - if (Frage == 2) then - return estimbspeedx - end -end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/com_10hB1.lua blobby-0.9c/data/scripts/com_10hB1.lua --- blobby-0.8-dfsg/data/scripts/com_10hB1.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/com_10hB1.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,210 +0,0 @@ --- Com 1.0 human Beta 1 --- by Oreon, Axji & Enormator - --- Flags und runners -wait = 0 -naechsterBallSchmettern = true -- evtl Variablennamen wechseln -quatschFlag = 0 -mood = math.random(1,3)+3 --Startlaune zwischen 4 und 6 - - --- Weltkonstanten - -CONST_FELD_LAENGE = 800 -CONST_BALL_RADIUS = 31.5 -CONST_GROUND_PLANE = 100 - -CONST_BALL_GRAVITY = 0.28 - -CONST_MITTE = CONST_FELD_LAENGE/2 -CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS - -CONST_BLOBBY_HOEHE = 89 -CONST_BLOBBY_KOPF_RADIUS = 25 -CONST_BLOBBY_BAUCH_RADIUS = 33 -CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS -CONST_BLOBBY_MAXJUMP = 393.625 - -CONST_NETZ_RADIUS = 7 -CONST_NETZ_HOEHE = 323 - --- Berührungsebene des Balls falls er ans Netz kommt -CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS -CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS - --- Charakter -CONST_MIN_MOOD = 0 -CONST_MAX_MOOD = 10 - -CONST_ANGRIFFSGRUNDWERT_MIN = 35 -CONST_ANGRIFFSGRUNDWERT_MAX = 60 -MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN-mood -MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX-mood - -CONST_GEDULD = 0.01 --weniger ist mehr Geduld - --- ***ANFANG*** - -function OnOpponentServe() - BallLinks=false - if (LauneBerechnet == false) then - mood=mood-1 --schlechter gelaunt - LauneBerechnen () --anwenden auf Angriffswert - LauneBerechnet = true - end - moveto(130) -end - -function OnServe(ballready) - BallLinks=true - if (LauneBerechnet == false) then - mood=mood+1 --besser gelaunt - LauneBerechnen () --anwenden auf Angriffswert - LauneBerechnet = true - end - naechsterBallSchmettern = true - generatenaechsterBallSchmettern() - - if (quatschFlag == 0) then - quatschFlag = math.random(5,10) - end - if (mood > quatschFlag) then --je besser gelaunt, desto wahrscheinlicher Quatsch - quatschFlag = enormerQuatsch() - else - moveto(ballx()) - if ballready and (ballx()-3 < posx()) and (posx() < ballx()+3) then - jump() - end - end -end - -function OnGame() - debug (mood) - if (BallLinks == (ballx() > CONST_MITTE)) then --Bei jedem Ballwechsel - mood = mood - CONST_GEDULD --um CONST_GEDULD schlechter gelaunt sein - LauneBerechnen () - BallLinks = (ballx() < CONST_MITTE) - end - LauneBerechnet=false --Flag setzen für Berechnung beim Aufschlag - quatschFlag=0 --Flag setzen für Berechnung beim Aufschlag - los=false --Flag setzen für Berechnung beim Aufschlag - naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht - target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG) --X Ziel in Blobbyhoehe - targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE) --X Ziel in Netzhoehe (Netzrollerberechnung) - targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP) --X Ziel in Schmetterhoehe - - if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann - generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen - end - - if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht - moveto(135) --Dann auf Standartposition warten - else - if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern - naechsterBallSchmettern = true - end - - if naechsterBallSchmettern then - sprungattacke(angriffsstaerke) - return - end - - moveto(target) - end -end - - -function sprungattacke(p_angriffsstaerke) - if (bally() < 550) and (math.abs(ballx() - posx()) > 200) then -- Falls nicht schmetterbar - moveto (target - 25) --Dann Notloesung versuchen - return - end - if ((bally() < 600) and (bspeedy() < 0)) or (math.abs(bspeedx()) > 2) or (math.abs(targetJump-posx()) > 40) then -- erst im letzten Moment bewegen -> unvorhersehbar - moveto(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben - end - if (bally() < 580) and (bspeedy() < 0) then - jump() - end -end - -function naechsterBallSchmetternFlagTesten() - if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt - naechsterBallSchmettern = false - return - end - - if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein - naechsterBallSchmettern = false - return - end - - if (touches() == 1) and (math.abs(bspeedx()) < 2) and (mood < CONST_MAX_MOOD) then -- schon nach der 1ten Beruehrung angreifen wenn der Ball gut kommt und er nicht zu gut gelaunt ist - naechsterBallSchmettern = true - return - end - - if (touches() == 2) then -- nach der 2. Berührung angreifen - naechsterBallSchmettern = true - return - end - naechsterBallSchmettern = false -end - -function generatenaechsterBallSchmettern() - angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) -- variiert mit der Laune -end - -function estimImpact(bx,by,vbx,vby,destY) -- erlaubt ein besseres Estimate mit ein paar umbeding nötigen Angaben - bgrav = 0.28 - - time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) - resultX = (vbx * time1) + bx - estimbspeedx=bspeedx() - - if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene - resultX = 2 * CONST_FELD_LAENGE - resultX - estimbspeedx=-estimbspeedx - end - - if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene - resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS - estimbspeedx=-estimbspeedx - KollisionLinks = true - else - KollisionLinks = false - end - - if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind - resultX = 2 * CONST_NETZ_LINKS - resultX - estimbspeedx=-estimbspeedx - end - return resultX -end - -function enormerQuatsch() - if los then - left() - jump() - else - right() - end - if (posx() > 350) then - los=true - end - if (posx() < 60) then - los=false - return CONST_MAX_MOOD + 1 -- MaxLaune+1 kann nie erreicht werden -> stop - end - return quatschFlag -- Wenn nicht fertig, dann nix aendern -end - -function LauneBerechnen () - if (mood < CONST_MIN_MOOD) then - mood = 0 - end - if (mood > CONST_MAX_MOOD) then - mood = 10 - end - MIN_ANGRIFFSSTAERKE=CONST_ANGRIFFSGRUNDWERT_MIN-mood - MAX_ANGRIFFSSTAERKE=CONST_ANGRIFFSGRUNDWERT_MAX-mood -end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/com_10.lua blobby-0.9c/data/scripts/com_10.lua --- blobby-0.8-dfsg/data/scripts/com_10.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/com_10.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ --- Combot 1.0 --- by Oreon, Axji & Enormator - --- Flags und runners -wait = 0 -naechsterBallSchmettern = true -- evtl Variablennamen wechseln - - --- Weltkonstanten - -CONST_FELD_LAENGE = 800 -CONST_BALL_RADIUS = 31.5 -CONST_GROUND_PLANE = 100 - -CONST_BALL_GRAVITY = 0.28 - -CONST_MITTE = CONST_FELD_LAENGE/2 -CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS - -CONST_BLOBBY_HOEHE = 89 -CONST_BLOBBY_KOPF_RADIUS = 25 -CONST_BLOBBY_BAUCH_RADIUS = 33 -CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS -CONST_BLOBBY_MAXJUMP = 393.625 - -CONST_NETZ_RADIUS = 7 -CONST_NETZ_HOEHE = 323 - --- Berührungsebene des Balls falls er ans Netz kommt -CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS -CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS - --- Charakter -CONST_ANGRIFFSGRUNDWERT_MIN = 30 -CONST_ANGRIFFSGRUNDWERT_MAX = 55 -MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN -MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX -ANGRIFFSEINSCHRAENKUNG_HINTEN = 10 - --- sonstige Einstellungen -servexVersetzung=-7 --Wert ist so gewaehlt, dass der Ball nah ans Netz fliegt, der Gegner ihn aber grade nicht erreichen kann - --- ***ANFANG*** - -function OnOpponentServe() - movetoX(130) -end - -function OnServe(ballready) - servex=ballx()+servexVersetzung - naechsterBallSchmettern = true - generatenaechsterBallSchmettern() - if ballready and movetoX(servex) then - jump() - end -end - -function OnGame() - target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) --X Ziel in Blobbyhoehe - targets = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,2) --X Richtung (-1 oder 1) bei Einschlag - targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE,1) --X Ziel in Netzhoehe (Netzrollerberechnung) - targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,1) --X Ziel in Schmetterhoehe - naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht - - if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann - generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen - end - - if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht - movetoX(135) --Dann auf Standartposition warten - else - if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern - naechsterBallSchmettern = true - end - - if naechsterBallSchmettern then - if ((math.abs(bspeedx()) < 4) or (estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,2) < 0)) then - sprungattacke(angriffsstaerke) - else - if (targetJump < CONST_MITTE / 2) then - sprungattacke(-35) --an Rueckwand spielen - else - sprungattacke(0) --weiterleiten - end - end - return - end - - movetoX(target) - end -end - - -function sprungattacke(p_angriffsstaerke) - p_angriffsstaerke=math.max(p_angriffsstaerke, MIN_ANGRIFFSSTAERKE + ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so hoch spielen (kommt nicht auf die andere Seite) - p_angriffsstaerke=math.min(p_angriffsstaerke, MAX_ANGRIFFSSTAERKE - ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so tief spielen (kommt ans Netz) - - movetoX(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben - - if (bally() < 580) and (bspeedy() < 0) then - jump() - end -end - -function naechsterBallSchmetternFlagTesten() - if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt - naechsterBallSchmettern = false - return - end - - if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein - naechsterBallSchmettern = false - return - end - - if (touches() == 1) and (math.abs(bspeedx()) < 2) then -- schon nach der 1ten Beruehrung angreifen wenn der Ball gut kommt - naechsterBallSchmettern = true - return - end - - if (touches() == 2) then -- nach der 2. Berührung angreifen - naechsterBallSchmettern = true - return - end - naechsterBallSchmettern = false -end - -function generatenaechsterBallSchmettern() - angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) -end - -function estimImpact(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding nötigen Angaben - bgrav = 0.28 - - time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) - resultX = (vbx * time1) + bx - estimbspeedx=bspeedx()/math.abs(bspeedx()) - - if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene - resultX = 2 * CONST_FELD_LAENGE - resultX - estimbspeedx=-estimbspeedx - end - - if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene - resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS - estimbspeedx=-estimbspeedx - KollisionLinks = true - else - KollisionLinks = false - end - - if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind - resultX = 2 * CONST_NETZ_LINKS - resultX - estimbspeedx=-estimbspeedx - end - - if (Frage == 1) then - return resultX - end - if (Frage == 2) then - return estimbspeedx - end -end - -function movetoX (x) - if (math.abs(posx()-x)>math.abs(posx()+4.5-x)) then - right() - done=false - else - if (math.abs(posx()-x)>math.abs(posx()-4.5-x)) then - left() - done=false - else - done=true - end - end - return done -end diff -Nru blobby-0.8-dfsg/data/scripts/com_10Schm.lua blobby-0.9c/data/scripts/com_10Schm.lua --- blobby-0.8-dfsg/data/scripts/com_10Schm.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/com_10Schm.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ --- Combot 1.0 - Schmettermod --- by Oreon, Axji & Enormator - --- Flags und runners -wait = 0 -naechsterBallSchmettern = true -- evtl Variablennamen wechseln - - --- Weltkonstanten - -CONST_FELD_LAENGE = 800 -CONST_BALL_RADIUS = 31.5 -CONST_GROUND_PLANE = 100 - -CONST_BALL_GRAVITY = 0.28 - -CONST_MITTE = CONST_FELD_LAENGE/2 -CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS - -CONST_BLOBBY_HOEHE = 89 -CONST_BLOBBY_KOPF_RADIUS = 25 -CONST_BLOBBY_BAUCH_RADIUS = 33 -CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS -CONST_BLOBBY_MAXJUMP = 393.625 - -CONST_NETZ_RADIUS = 7 -CONST_NETZ_HOEHE = 323 - --- Berührungsebene des Balls falls er ans Netz kommt -CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS -CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS - --- Charakter -CONST_ANGRIFFSGRUNDWERT_MIN = 30 -CONST_ANGRIFFSGRUNDWERT_MAX = 55 -MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN -MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX -ANGRIFFSEINSCHRAENKUNG_HINTEN = 10 - --- sonstige Einstellungen -servexVersetzung=-7 --Wert ist so gewaehlt, dass der Ball nah ans Netz fliegt, der Gegner ihn aber grade nicht erreichen kann - --- ***ANFANG*** - -function OnOpponentServe() - movetoX(130) -end - -function OnServe(ballready) - servex=ballx()+servexVersetzung - naechsterBallSchmettern = true - generatenaechsterBallSchmettern() - if ballready and movetoX(servex) then - jump() - end -end - -function OnGame() - target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) --X Ziel in Blobbyhoehe - targets = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,2) --X Richtung (-1 oder 1) bei Einschlag - targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE,1) --X Ziel in Netzhoehe (Netzrollerberechnung) - targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,1) --X Ziel in Schmetterhoehe - naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht - - if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann - generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen - end - - if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht - movetoX(135) --Dann auf Standartposition warten - else - if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern - naechsterBallSchmettern = true - end - - if naechsterBallSchmettern then - if ((math.abs(bspeedx()) < 4) or (estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,2) < 0)) then - sprungattacke(angriffsstaerke) - else - if (targetJump < CONST_MITTE / 2) then - sprungattacke(-35) --an Rueckwand spielen - else - sprungattacke(0) --weiterleiten - end - end - return - end - - movetoX(target) - end -end - - -function sprungattacke(p_angriffsstaerke) - p_angriffsstaerke=math.max(p_angriffsstaerke, MIN_ANGRIFFSSTAERKE + ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so hoch spielen (kommt nicht auf die andere Seite) - p_angriffsstaerke=math.min(p_angriffsstaerke, MAX_ANGRIFFSSTAERKE - ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so tief spielen (kommt ans Netz) - - movetoX(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben - - if (bally() < 580) and (bspeedy() < 0) then - jump() - end -end - -function naechsterBallSchmetternFlagTesten() - naechsterBallSchmettern = true -end - -function generatenaechsterBallSchmettern() - angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) -end - -function estimImpact(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding nötigen Angaben - bgrav = 0.28 - - time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) - resultX = (vbx * time1) + bx - estimbspeedx=bspeedx()/math.abs(bspeedx()) - - if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene - resultX = 2 * CONST_FELD_LAENGE - resultX - estimbspeedx=-estimbspeedx - end - - if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene - resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS - estimbspeedx=-estimbspeedx - KollisionLinks = true - else - KollisionLinks = false - end - - if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind - resultX = 2 * CONST_NETZ_LINKS - resultX - estimbspeedx=-estimbspeedx - end - - if (Frage == 1) then - return resultX - end - if (Frage == 2) then - return estimbspeedx - end -end - -function movetoX (x) - if (math.abs(posx()-x)>math.abs(posx()+4.5-x)) then - right() - done=false - else - if (math.abs(posx()-x)>math.abs(posx()-4.5-x)) then - left() - done=false - else - done=true - end - end - return done -end - diff -Nru blobby-0.8-dfsg/data/scripts/gintonicV6.lua blobby-0.9c/data/scripts/gintonicV6.lua --- blobby-0.8-dfsg/data/scripts/gintonicV6.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/gintonicV6.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,230 +0,0 @@ ---Gin Tonic v6 - No Comments, sorry :P - -CT_ServeSelf = { 152, 163, 180, 195, 205, 240 } -CT_ServeOpp = { 140, 200, 240 } -CT_ServeIndex = 0 -CT_Tolerance = 5 -CT_Action = "" -CT_ShotDecision = 0 -CT_NextGround = 9999 -CT_LastTouches = 0 -CT_LastHeight = 0 - -CT_WaitCounter = 0 -CT_WaitName = "" -CT_WaitMoveTo = 0 - -function IsAt(position) - return (math.abs(posx()-position) <= CT_Tolerance) -end - -function Wait(name, time, moveto) - if (CT_WaitName == name) then - if (CT_WaitCounter == 0) then - return false - end - end - CT_WaitCounter = time - CT_WaitName = name - CT_WaitMoveTo = moveto - return true -end - -function WaitQueue() - if (CT_WaitCounter > 0) then - CT_WaitCounter = CT_WaitCounter - 1 - if (CT_WaitMoveTo > 0) then - if (not IsAt(CT_WaitMoveTo)) then moveto(CT_WaitMoveTo) end - end - return true - else - return false - end -end - -function ResetWait() - CT_WaitCounter = 0 - CT_WaitName = "" -end - -function OnOpponentServe() - if (CT_ServeIndex == 0) then - CT_ServeIndex = math.random(1,3) - end - if (not IsAt(CT_ServeOpp[CT_ServeIndex])) then moveto(CT_ServeOpp[CT_ServeIndex]) end -end - -function OnServe(ballready) - if (WaitQueue()) then return end - if (CT_ServeIndex == 0) then - CT_ServeIndex = math.random(1,6) - end - if (ballready) then - if (Wait("ServeDelay",math.random(28,90),CT_ServeSelf[CT_ServeIndex]+math.random(-150, 150))) then return end - if (IsAt(CT_ServeSelf[CT_ServeIndex])) then - jump() - else - moveto(CT_ServeSelf[CT_ServeIndex]) - end - else - if (posx() < 150) then - jump() - end - moveto(40) - end -end - -function OnGame() - ResetWait() - CT_ServeIndex = 0 - - local timeJump = timeToHitHeight(380, 390, 20) - local timeGround = timeToHitHeight(200, 222, 40) - local timeBlock = timeToOppSmash(390) - local estimhx = r_estimx(timeJump) - local estimGround = r_estimx(timeGround) - local estimBlock = r_estimx(timeBlock) - local block = 0 - local wallcoll = willHitWall(time) - if (timeBlock ~= -1) then block = timeBlock+(estimBlock-400)/13 end - if (timeBlock == -1) then timeBlock = 9999 end - if (timeJump == -1) then estimhx = 9999 end - if (timeGround == -1) then estimGround = 210 end - - if (posy() < CT_LastHeight and posy() > 150 and posy() < 330) then CT_Action = "" end - CT_LastHeight = posy() - - if (CT_Action == "NetBlock") then - if ((posy() < 150) or (timeBlock < 4 and oppy() < 150) or (ballx() <= posx()) or (touches() <= 0 and bspeedx() > 10)) then - CT_Action = "" - else - jump() - moveto(400) - return - end - elseif (CT_Action == "JumpPlayFwd") then - if (posy() < 150) then - CT_Action = "" - else - if (estimhx == 9999) then estimhx = ballx()+bspeedx() end - jump() - if (posy() > 300) then - if (math.abs(bally()-posy()) < 18) then - moveto(ballx()+bspeedx()) - elseif (estimhx < 200) then - if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(3,5) end - moveto(estimhx-10*CT_ShotDecision) - elseif (oppx() > 600 and oppy() < 150) then - if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,6) end - moveto(estimhx-10*CT_ShotDecision) - elseif (oppx() < 600 and oppy() > 180) then - moveto(estimhx-40) - else - moveto(estimhx-60) - end - else - moveto(estimhx-60) - end - return - end - elseif (CT_Action == "JumpPlayRev") then - if (posy() < 150) then - CT_Action = "" - else - if (estimhx == 9999) then estimhx = ballx()+bspeedx() end - jump() - if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,9) end - moveto(estimhx+5*CT_ShotDecision) - return - end - end - - if (touches() ~= CT_LastTouches) then - CT_LastTouches = touches() - CT_NextGround = math.random(-20,20) - end - - if (CT_Action == "") then - if ((ballx() < 400 or bspeedx() < -2) and estimGround < 400) then - if (touches() >= 2) then - moveto(estimGround+(posx()-500)/22) - elseif (math.abs(bspeedx()) > 8) then - moveto(estimGround) - else - moveto(estimGround+CT_NextGround) - end - elseif (estimhx < 600 and math.abs(bspeedx()) < 6) then - moveto(280) - elseif (estimhx > 650) then - moveto(250) - else - moveto(190) - end - end - - if (posy() > 150) then return end - - if (timeBlock >= 17 and timeBlock <= 19) then - if (posx() > 210 and estimBlock > 395 and estimBlock < 640) then - jump() - moveto(400) - CT_Action = "NetBlock" - return - end - end - if (timeJump >= 17 and timeJump <= 19) then - if (bspeedx() <= 7 and estimhx >= 65 and estimhx <= 420 and posx()-estimhx <= 120 and (bspeedx() >= -7 or (not wallcoll))) then - if (estimGround > 400 or bally() > 250) then - CT_Action = "JumpPlayFwd" - CT_ShotDecision = 0 - jump() - end - end - if ((wallcoll or bspeedx() >= -7) and estimhx <= 250 and posx()-estimhx <= 180 and posx()-estimhx >= -120) then - if (estimGround > 400 or bally() > 250) then - if (CT_Action == "JumpPlayFwd" and (touches() >= 2 or math.random(100) > 15)) then return end - CT_Action = "JumpPlayRev" - CT_ShotDecision = 0 - jump() - end - end - end -end - - -function timeToHitHeight(minheight, maxheight, depth) - local i = 0 - for i=1, depth do - if (estimy(i) >= minheight and estimy(i) <= maxheight and estimx(i) <= 420) then - return i - end - end - return -1 -end - -function timeToOppSmash(height) - if (bally() < height) then return -1 end - local i = 0 - for i=1, 17 do - if (estimy(i) < height) then - return i - end - end - return -1 -end - -function r_estimx(time) - local estim = estimx(time) - if estim < 31.5 then estim = 63-estim end - if estim > 768.5 then estim = 1537-estim end - if (bally() < 330) then - if (ballx() < 400 and estim > 400) then estim = 723-estim end - if (ballx() > 400 and estim < 400) then estim = 877-estim end - end - return estim -end - -function willHitWall(time) - if (estimx(time) < 31.5) then return true end - return false -end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/gintonicV7.lua blobby-0.9c/data/scripts/gintonicV7.lua --- blobby-0.8-dfsg/data/scripts/gintonicV7.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/gintonicV7.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,231 +0,0 @@ ---Gin Tonic v7 - No Comments, sorry :P - -CT_ServeSelf = { 152, 163, 180, 195, 205, 240 } -CT_ServeOpp = { 140, 200, 240 } -CT_ServeIndex = 0 -CT_Tolerance = 5 -CT_Action = "" -CT_ShotDecision = 0 -CT_NextGround = 9999 -CT_LastTouches = 0 -CT_LastHeight = 0 - -CT_WaitCounter = 0 -CT_WaitName = "" -CT_WaitMoveTo = 0 - -function IsAt(position) - return (math.abs(posx()-position) <= CT_Tolerance) -end - -function Wait(name, time, moveto) - if (CT_WaitName == name) then - if (CT_WaitCounter == 0) then - return false - end - end - CT_WaitCounter = time - CT_WaitName = name - CT_WaitMoveTo = moveto - return true -end - -function WaitQueue() - if (CT_WaitCounter > 0) then - CT_WaitCounter = CT_WaitCounter - 1 - if (CT_WaitMoveTo > 0) then - if (not IsAt(CT_WaitMoveTo)) then moveto(CT_WaitMoveTo) end - end - return true - else - return false - end -end - -function ResetWait() - CT_WaitCounter = 0 - CT_WaitName = "" -end - -function OnOpponentServe() - if (CT_ServeIndex == 0) then - CT_ServeIndex = math.random(1,3) - end - if (not IsAt(CT_ServeOpp[CT_ServeIndex])) then moveto(CT_ServeOpp[CT_ServeIndex]) end -end - -function OnServe(ballready) - if (WaitQueue()) then return end - if (CT_ServeIndex == 0) then - CT_ServeIndex = math.random(1,6) - end - if (ballready) then - if (Wait("ServeDelay",math.random(28,90),CT_ServeSelf[CT_ServeIndex]+math.random(-150, 150))) then return end - if (IsAt(CT_ServeSelf[CT_ServeIndex])) then - jump() - else - moveto(CT_ServeSelf[CT_ServeIndex]) - end - else - if (posx() < 150) then - jump() - end - moveto(40) - end -end - -function OnGame() - ResetWait() - CT_ServeIndex = 0 - - local timeJump = timeToHitHeight(380, 390, 20) - local timeGround = timeToHitHeight(200, 222, 40) - local timeBlock = timeToOppSmash(390) - local estimhx = r_estimx(timeJump) - local estimGround = r_estimx(timeGround) - local estimBlock = r_estimx(timeBlock) - local block = 0 - local wallcoll = willHitWall(timeJump) - if (timeBlock ~= -1) then block = timeBlock+(estimBlock-400)/13 end - if (timeBlock == -1) then timeBlock = 9999 end - if (timeJump == -1) then estimhx = 9999 end - if (timeGround == -1) then estimGround = 210 end - - if (posy() < CT_LastHeight and posy() > 150 and posy() < 330) then CT_Action = "" end - CT_LastHeight = posy() - - if (CT_Action == "NetBlock") then - if ((posy() < 150) or (timeBlock < 4 and oppy() < 150) or (ballx() <= posx()) or (touches() <= 0 and bspeedx() > 10)) then - CT_Action = "" - else - jump() - moveto(400) - return - end - elseif (CT_Action == "JumpPlayFwd") then - if (posy() < 150) then - CT_Action = "" - else - if (estimhx == 9999) then estimhx = ballx()+bspeedx() end - jump() - if (posy() > 300) then - if (math.abs(bally()-posy()) < 18) then - moveto(ballx()+bspeedx()) - elseif (estimhx < 200) then - if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(3,5) end - moveto(estimhx-10*CT_ShotDecision) - elseif (oppx() > 600 and oppy() < 150) then - if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,6) end - moveto(estimhx-10*CT_ShotDecision) - elseif (oppx() < 600 and oppy() > 180) then - moveto(estimhx-40) - else - moveto(estimhx-60) - end - else - moveto(estimhx-60) - end - return - end - elseif (CT_Action == "JumpPlayRev") then - if (posy() < 150 or touches() ~= CT_LastTouches) then - CT_Action = "" - else - if (estimhx == 9999) then estimhx = ballx()+bspeedx() end - jump() - if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,9) end - moveto(estimhx+5*CT_ShotDecision) - return - end - end - - if (touches() ~= CT_LastTouches) then - CT_LastTouches = touches() - CT_NextGround = math.random(-20,20) - end - - if (CT_Action == "") then - if ((ballx() < 400 or bspeedx() < -2) and estimGround < 400) then - if (touches() >= 2) then - moveto(estimGround+(posx()-500)/22) - elseif (math.abs(bspeedx()) > 8) then - moveto(estimGround) - else - moveto(estimGround+CT_NextGround) - end - elseif (estimhx < 600 and math.abs(bspeedx()) < 6) then - moveto(280) - elseif (estimhx > 650) then - moveto(250) - else - moveto(190) - end - end - - if (posy() > 150) then return end - if (touches() > 2) then return end - - if (timeBlock >= 17 and timeBlock <= 19) then - if (posx() > 210 and estimBlock > 395 and estimBlock < 640 and not wallcoll) then - jump() - moveto(400) - CT_Action = "NetBlock" - return - end - end - if (timeJump >= 17 and timeJump <= 19) then - if (bspeedx() <= 7 and estimhx >= 65 and estimhx <= 420 and posx()-estimhx <= 120 and (bspeedx() >= -7 or not wallcoll)) then - if (estimGround > 400 or bally() > 250) then - CT_Action = "JumpPlayFwd" - CT_ShotDecision = 0 - jump() - end - end - if ((wallcoll or bspeedx() >= -7) and estimhx <= 250 and posx()-estimhx <= 180 and posx()-estimhx >= -120) then - if (estimGround > 400 or bally() > 250) then - if (CT_Action == "JumpPlayFwd" and (touches() >= 2 or math.random(100) > 15)) then return end - CT_Action = "JumpPlayRev" - CT_ShotDecision = 0 - jump() - end - end - end -end - - -function timeToHitHeight(minheight, maxheight, depth) - local i = 0 - for i=1, depth do - if (estimy(i) >= minheight and estimy(i) <= maxheight and estimx(i) <= 420) then - return i - end - end - return -1 -end - -function timeToOppSmash(height) - if (bally() < height) then return -1 end - local i = 0 - for i=1, 17 do - if (estimy(i) < height) then - return i - end - end - return -1 -end - -function r_estimx(time) - local estim = estimx(time) - if estim < 31.5 then estim = 63-estim end - if estim > 768.5 then estim = 1537-estim end - if (bally() < 330) then - if (ballx() < 400 and estim > 400) then estim = 723-estim end - if (ballx() > 400 and estim < 400) then estim = 877-estim end - end - return estim -end - -function willHitWall(time) - if (estimx(time) < 31.5) then return true end - return false -end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/gintonicV8.lua blobby-0.9c/data/scripts/gintonicV8.lua --- blobby-0.8-dfsg/data/scripts/gintonicV8.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/gintonicV8.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,240 +0,0 @@ ---Gin Tonic v8 - No Comments, sorry :P - -CT_ServeSelf = { 152, 163, 180, 195, 205, 240 } -CT_ServeOpp = { 140, 200, 240 } -CT_ServeIndex = 0 -CT_Tolerance = 5 -CT_Action = "" -CT_ShotDecision = 0 -CT_NextGround = 9999 -CT_LastTouches = 9999 -CT_LastHeight = 0 -CT_SkipNextBlock = 0 - -CT_WaitCounter = 0 -CT_WaitName = "" -CT_WaitMoveTo = 0 - -function IsAt(position) - return (math.abs(posx()-position) <= CT_Tolerance) -end - -function Wait(name, time, moveto) - if (CT_WaitName == name) then - if (CT_WaitCounter == 0) then - return false - end - end - CT_WaitCounter = time - CT_WaitName = name - CT_WaitMoveTo = moveto - return true -end - -function WaitQueue() - if (CT_WaitCounter > 0) then - CT_WaitCounter = CT_WaitCounter - 1 - if (CT_WaitMoveTo > 0) then - if (not IsAt(CT_WaitMoveTo)) then moveto(CT_WaitMoveTo) end - end - return true - else - return false - end -end - -function ResetWait() - CT_WaitCounter = 0 - CT_WaitName = "" -end - -function OnOpponentServe() - if (CT_ServeIndex == 0) then - CT_ServeIndex = math.random(1,3) - end - if (not IsAt(CT_ServeOpp[CT_ServeIndex])) then moveto(CT_ServeOpp[CT_ServeIndex]) end -end - -function OnServe(ballready) - if (WaitQueue()) then return end - if (CT_ServeIndex == 0) then - CT_ServeIndex = math.random(1,6) - end - if (ballready) then - if (Wait("ServeDelay",math.random(28,90),CT_ServeSelf[CT_ServeIndex]+math.random(-150, 150))) then return end - if (IsAt(CT_ServeSelf[CT_ServeIndex])) then - jump() - else - moveto(CT_ServeSelf[CT_ServeIndex]) - end - else - if (posx() < 150) then - jump() - end - moveto(40) - end -end - -function OnGame() - ResetWait() - CT_ServeIndex = 0 - - local timeJump = timeToHitHeight(380, 390, 20) - local timeGround = timeToHitHeight(200, 222, 40) - local timeBlock = timeToOppSmash(390) - local estimhx = r_estimx(timeJump) - local estimGround = r_estimx(timeGround) - local estimBlock = r_estimx(timeBlock) - local block = 0 - local wallcoll = willHitWall(timeJump) - if (timeBlock ~= -1) then timeBlock = timeBlock+(estimBlock-400)/13 end - if (timeBlock == -1) then timeBlock = 9999 end - if (timeJump == -1) then estimhx = 9999 end - if (timeGround == -1) then estimGround = 210 end - if (CT_SkipNextBlock == 0) then CT_SkipNextBlock = math.random(1,10) end - - if (posy() < CT_LastHeight and posy() > 150 and posy() < 330) then CT_Action = "" end - CT_LastHeight = posy() - - if (CT_Action == "NetBlock") then - if ((posy() < 150) or (timeBlock <= 8 and oppy() < 150) or (ballx() <= posx()) or (touches() <= 0 and bspeedx() > 9)) then - CT_Action = "" - else - jump() - moveto(400) - return - end - elseif (CT_Action == "JumpPlayFwd") then - if (posy() < 150) then - CT_Action = "" - else - if (estimhx == 9999) then estimhx = ballx()+bspeedx() end - jump() - if (posy() > 300) then - if (math.abs(bally()-posy()) < 18) then - moveto(ballx()+bspeedx()) - elseif (estimhx < 200) then - if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(3,5) end - moveto(estimhx-10*CT_ShotDecision) - elseif (oppx() > 600 and oppy() < 150) then - if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,6) end - moveto(estimhx-10*CT_ShotDecision) - elseif (oppx() < 600 and oppy() > 180) then - moveto(estimhx-40) - else - moveto(estimhx-60) - end - else - moveto(estimhx-50) - end - return - end - elseif (CT_Action == "JumpPlayRev") then - if (posy() < 150 or touches() ~= CT_LastTouches) then - CT_Action = "" - else - if (estimhx == 9999) then estimhx = ballx()+bspeedx() end - jump() - if (CT_ShotDecision == 0 and touches() == 2) then CT_ShotDecision = math.random(5,7) end - if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(3,8) end - if (math.abs(bally()-posy()) < 18) then - moveto(ballx()+bspeedx()) - else - moveto(estimhx+5*CT_ShotDecision) - end - return - end - end - - if (touches() ~= CT_LastTouches) then - CT_LastTouches = touches() - CT_NextGround = math.random(-20,20) - CT_SkipNextBlock = 0 - end - - if (CT_Action == "") then - if ((ballx() < 400 or bspeedx() < -2 or bspeedx() > 10) and estimGround < 400) then - if (touches() >= 2) then - moveto(estimGround+(posx()-500)/22) - elseif (math.abs(bspeedx()) > 8) then - moveto(estimGround) - else - moveto(estimGround+CT_NextGround) - end - elseif (estimhx < 650 and math.abs(bspeedx()) < 6) then - moveto(215) - elseif (estimhx > 650) then - moveto(250) - else - moveto(180) - end - end - - if (posy() > 150) then return end - if (touches() > 2) then return end - - if (timeBlock >= 23 and timeBlock <= 25 and CT_SkipNextBlock ~= 1) then - if (posx() > 210 and estimBlock > 395 and estimBlock < 650 and not wallcoll) then - jump() - moveto(400) - CT_Action = "NetBlock" - return - end - end - if (timeJump >= 17 and timeJump <= 19) then - if (bspeedx() <= 7 and estimhx >= 65 and estimhx <= 420 and posx()-estimhx <= 120 and (bspeedx() >= -7 or not wallcoll)) then - if (estimGround > 400 or bally() > 250) then - CT_Action = "JumpPlayFwd" - CT_ShotDecision = 0 - jump() - end - end - if ((wallcoll or bspeedx() >= -7) and estimhx <= 250 and posx()-estimhx <= 180 and posx()-estimhx >= -120) then - if (estimGround > 400 or bally() > 250) then - if (CT_Action == "JumpPlayFwd" and (touches() >= 2 or math.random(100) > 15)) then return end - CT_Action = "JumpPlayRev" - CT_ShotDecision = 0 - jump() - end - end - end -end - - -function timeToHitHeight(minheight, maxheight, depth) - local i = 0 - for i=1, depth do - if (estimy(i) >= minheight and estimy(i) <= maxheight) then - return i - end - end - return -1 -end - -function timeToOppSmash(height) - if (bally() < height) then return -1 end - local i = 0 - for i=1, 17 do - if (estimy(i) < height) then - return i - end - end - return -1 -end - -function r_estimx(time) - local estim = estimx(time) - if estim < 31.5 then estim = 63-estim end - if estim > 768.5 then estim = 1537-estim end - if (bally() < 330) then - if (ballx() < 400 and estim > 400) then estim = 723-estim end - if (ballx() > 400 and estim < 400) then estim = 877-estim end - end - return estim -end - -function willHitWall(time) - if (estimx(time) < 31.5) then return true end - if (estimx(time) > 768.5) then return true end - return false -end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/hyp010.lua blobby-0.9c/data/scripts/hyp010.lua --- blobby-0.8-dfsg/data/scripts/hyp010.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/hyp010.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,514 +0,0 @@ -g=0.28 -pg=0.88 -v0=14.5 -v_p=4.5 -pj=0.44 -r1=31.5 -p0=0 -p1=0.5 -p2=1 -h=31.5+19+25 - - -estt=0 -nettime=0 -touch=0 -est=0 -p=0.4 -esto1=10 -esto2=10 - - -function yb(y,vy,t) - - return y+(vy-g/10)*t-1/2*g*t^2 - -end - -function move(x) - - if (posx()2.26) then right() - elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() - end - -end - -function tb(y,vy,height,typ) -local sgn=0 - if (typ==1) - then - sgn=-1 - else - sgn=1 - end - if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 - then return -1 - else - return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) - end -end - -function time(t) - - return 1/5*math.ceil(5*t) - -end - -function pos(x) - - local x1,x2 - x1=4.5*math.ceil((1/4.5)*x) - x2=4.5*math.floor((1/4.5)*x) - if (x1<0) or (x2<0) then return 0 - else - if (math.abs(x1-x)146) then - return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) - else - return 0 - end -end - -function time(t) -return 1/5*math.ceil(5*t) -end - - --- - -function collide(x,y,vx,vy,objx,objy,r2) - - local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) - local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) - local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) - local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) - local t=-1 - if (t1150) then t=-1 end - - return t - -end - - - -function estimate(x,y,vx,vy,height,typ) - - local collision=1 - local tw,tn,ts=0,0,0 - local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 - - while(collision==1) do - ts=collide(x,y,vx,vy,400,316,7) - if (vx>0) - then - tw=time((768.5-x)/vx) - tn=time((361.5-x)/vx) - else - tw=time((31.5-x)/vx) - tn=time((438.5-x)/vx) - end - local th=time(tb(y,vy,height,typ)) - local t=10000 - - if ((ts>0) and (ts0) and (tn0) and (twt) - then - if (t==ts) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vy=vy-g*t - xr=x - yr=y - vxr=0 - vyr=0 - n=1 - collision=0 - elseif ((t==tn) or (t==tw)) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vx=-vx - vy=vy-g*t - collision=1 - end - else - tr=tr+th - vxr=vx - vyr=vy-g*th - xr=x+vx*th - yr=yb(y,vy,th) - collision=0 - end - end - if (tr<0) - then - return -1,-1,-1,-1,-1,-1 - else - return xr,yr,vxr,vyr,tr,n - end -end - - -function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) -local x1,y1,vx1,vy1=0,0,0,0 -local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 -local xpos1=xpos -local ypos1=ypos -for t=0,20,0.2 do - - if (jump==1) then - ypos1=yp(tp(ypos)+t) - end - x1=x+vx*t - if (x1<31.5) then x1=2*31.5-x1 end - if (x1>368.5) then x1=2*368.5-x1 end - y1=yb(y,vy,t) - - if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then - local dx=x1-xpos1 - local dy=y1-(ypos1+19) - local l=math.sqrt(dx^2+dy^2) - vx1=dx/l - vy1=dy/l - x1=x1+vx1*3 - y1=y1+vy1*3 - vy1=vy1*13.125 - vx1=vx1*13.125 - x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) - break - end -end - -return x2,y2,x1,y1,vx1,vy1 -end - -function lob() - - if (math.abs(est-esto2)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto2=est - imp=0 - x1=0 - t=30 - while (t>=0) do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5730) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - if (impfimp) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - end - if (imp>740) then break end - end - if (t>12) then t=t-6 else t=t-4 end - end - t2=t2+1 - end - t2=t2-1 - if (x1>0) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else - move(est) - --p=0.5 - end - -end - - -function attack() - - if (math.abs(est-esto1)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 - h2=900 --- debug(-10) - esto1=est - imp=0 - x1=0 - t=30 - while (t>=0) do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.5+10) and (x1f<360) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - xat=xaf - yat=yaf - vxat=vxaf - vyat=vyaf - break - end - end - h2t=yb(yat,vyat,(400-xat)/vxat) - if (h2t316+31.5+10) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - xa=xat - ya=yat - vxa=vxat - vya=vyat - end - h2=yb(ya,vya,(400-xa)/vxa) - if (h2>316+31.5+10) and (h2<316+31.5+45) then break end - end - if (t>12) then t=t-6 - else t=t-4 end - end - t2=t2+1 - end - t2=t2-1 - - if (x1>0) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() - end - else - move(est) - --p=0.9 - end -end - - -function netp() - - if (math.abs(est-esto)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto=est - imp=0 - x1=0 - for t=33,0,-3 do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - end - if (impt>imp) and (impt<431.5) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - end - if (imp>428) then break end - end - end - t2=t2+1 - end - t2=t2-1 - if (x1>0) and (est<368.5) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else - move(est) - end - -end - - -function OnOpponentServe() -y1p=144.5 -if (math.abs(pos(posx())-posx())>1) then move(400) else -move(200) -end -valid=1 - - -end - -function OnServe(ballready) -y1p=144.5 - est=700 - - if (math.abs(pos(posx())-posx())>1) then - move(400) - else - if (math.abs(posx()-180)<2) then - jump() - else - move(180) - end - end -valid=1 -end - - - -function OnGame() - -yp2=y1p -y1p=oppy() -vp=y1p-yp2 - - -esttold=estt -netold=net -toucho=touch -touch=touches() -if (touch400-31.5) then - move (250) - elseif (est<400-10) and (est>400-22) then - move(200) - elseif (est<400) and (est>400-10) then - move(180) - else - move(230) -end - -end diff -Nru blobby-0.8-dfsg/data/scripts/hyp011com.lua blobby-0.9c/data/scripts/hyp011com.lua --- blobby-0.8-dfsg/data/scripts/hyp011com.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/hyp011com.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,634 +0,0 @@ -g=0.28 -pg=0.88 -v0=14.5 -v_p=4.5 -pj=0.44 -r1=31.5 -p0=0 -p1=0.5 -p2=1 -h=31.5+19+25 - - -estt=0 -nettime=0 -touch=0 -est=0 -p=0.4 -esto1=10 -esto2=10 -esto3=10 - - -function yb(y,vy,t) - - return y+(vy-g/10)*t-1/2*g*t^2 - -end - -function move(x) - - if (posx()2.26) then right() - elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() - end - -end - -function tb(y,vy,height,typ) -local sgn=0 - if (typ==1) - then - sgn=-1 - else - sgn=1 - end - if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 - then return -1 - else - return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) - end -end - -function time(t) - - return 1/5*math.ceil(5*t) - -end - -function pos(x) - - local x1,x2 - x1=4.5*math.ceil((1/4.5)*x) - x2=4.5*math.floor((1/4.5)*x) - if (x1<0) or (x2<0) then return 0 - else - if (math.abs(x1-x)146) then - return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) - else - return 0 - end -end - -function time(t) -return 1/5*math.ceil(5*t) -end - - --- - -function collide(x,y,vx,vy,objx,objy,r2) - - local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) - local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) - local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) - local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) - local t=-1 - if (t1150) then t=-1 end - - return t - -end - - - -function estimate(x,y,vx,vy,height,typ) - - local collision=1 - local tw,tn,ts=0,0,0 - local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 - - while(collision==1) do - ts=collide(x,y,vx,vy,400,316,7) - if (vx>0) - then - tw=time((768.5-x)/vx) - tn=time((361.5-x)/vx) - else - tw=time((31.5-x)/vx) - tn=time((438.5-x)/vx) - end - local th=time(tb(y,vy,height,typ)) - local t=10000 - - if ((ts>0) and (ts0) and (tn0) and (twt) - then - if (t==ts) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vy=vy-g*t - xr=x - yr=y - vxr=0 - vyr=0 - n=1 - collision=0 - elseif ((t==tn) or (t==tw)) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vx=-vx - vy=vy-g*t - collision=1 - end - else - tr=tr+th - vxr=vx - vyr=vy-g*th - xr=x+vx*th - yr=yb(y,vy,th) - collision=0 - end - end - if (tr<0) - then - return -1,-1,-1,-1,-1,-1 - else - return xr,yr,vxr,vyr,tr,n - end -end - - -function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) -local x1,y1,vx1,vy1=0,0,0,0 -local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 -local xpos1=xpos -local ypos1=ypos -for t=0,20,0.2 do - - if (jump==1) then - ypos1=yp(tp(ypos)+t) - end - x1=x+vx*t - if (x1<31.5) then x1=2*31.5-x1 end - if (x1>368.5) then x1=2*368.5-x1 end - y1=yb(y,vy,t) - - if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then - local dx=x1-xpos1 - local dy=y1-(ypos1+19) - local l=math.sqrt(dx^2+dy^2) - vx1=dx/l - vy1=dy/l - x1=x1+vx1*3 - y1=y1+vy1*3 - vy1=vy1*13.125 - vx1=vx1*13.125 - x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) - break - end -end - -return x2,y2,x1,y1,vx1,vy1 -end - -function lob() - - if (math.abs(est-esto2)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto2=est - imp=0 - x1=0 - t=30 - while (t>=0) do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5730) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - if (impfimp) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - end - if (imp>740) then break end - end - if (t>12) then t=t-6 else t=t-4 end - end - t2=t2+1 - end - t2=t2-1 - if (x1>0) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else - move(est) - --p=0.5 - end - -end - - -function attack() - - if (math.abs(est-esto1)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 - h2=900 --- debug(-10) - esto1=est - imp=0 - x1=0 - t=30 - while (t>=0) do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.5+10) and (x1f<360) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - xat=xaf - yat=yaf - vxat=vxaf - vyat=vyaf - break - end - end - h2t=yb(yat,vyat,(400-xat)/vxat) - if (h2t316+31.5+10) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - xa=xat - ya=yat - vxa=vxat - vya=vyat - end - h2=yb(ya,vya,(400-xa)/vxa) - if (h2>316+31.5+10) and (h2<316+31.5+45) then break end - end - if (t>12) then t=t-6 - else t=t-4 end - end - t2=t2+1 - end - t2=t2-1 - - if (x1>0) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() - end - else - move(est) - --p=0.9 - end -end - - -function netp() - - if (math.abs(est-esto3)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto3=est - imp=500 - x1=0 - for t=33,0,-3 do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5380) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - end - if (impt0) and (est<368.5) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else - move(est-4.5) - end - -end - - - - - -function posplay() - - if (math.abs(est-esto3)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto3=est - imp=500 - x1=0 - for t=33,0,-3 do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5280) and (impf<340) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - end - if (math.abs(impt-310)0) and (est<368.5) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else - move(est) - end - -end - - - - - - -function OnOpponentServe() -y1p=144.5 -if (math.abs(pos(posx())-posx())>1) then move(400) else -move(200) -end -valid=1 -nettime=0 -phase=0 - -end - -function OnServe(ballready) -nettime=0 -y1p=144.5 -phase=0 - est=700 - - if (math.abs(pos(posx())-posx())>1) then - move(400) - else - if (math.abs(posx()-180)<2) then - jump() - else - move(180) - end - end -valid=1 -end - - - -function OnGame() - -yp2=y1p -y1p=oppy() -vp=y1p-yp2 - - -esttold=estt -netold=net -toucho=touch -touch=touches() -if (touch431.5) or (est<368.5)) then - nettime=10 - phase=4 - elseif (phase==4) and (nettime>0) then - nettime=nettime-1 - else - if (est>431.5) then - phase=3 - elseif (est<431.5) and (est>368.5) then - phase=2 - else - phase=1 - end -end - -if (math.sqrt((ballx()-400)^2+(bally()-316)^2)<(31.5+7)) and (math.sqrt((bspeedx())^2+(bspeedy())^2)<2) then phase=5 end - - ---1 Player ---2 Ball --- debug(0) --- debug(est) --- debug(imp) --- debug(t2) --- --- if (est<(400-31.5)) then --- if (p<1) then netp() --- else lob() --- end --- elseif (est<400-22) and (est>400-31.5) then --- move (250) --- elseif (est<400-10) and (est>400-22) then --- move(200) --- elseif (est<400) and (est>400-10) then --- move(180) --- else --- move(100) --- end -if (phase==3) then - move(100) - elseif (phase==1) then --- if (p<0.4) then --- attack() --- elseif (p>=0.4) and (p<0.7) then --- lob() --- else - if (touches()==0) then - posplay() - elseif (touches()==1) then - netp() - else - attack() - end --- end - elseif (phase==2) then - if (tnet<=tp(393)+1) or (nettime>0) then jump() end - if (math.abs(posx()-360)/4.5-10<=tnet) then - left() - else - right() - end - elseif (phase==4) then - right() - jump() - elseif (phase==5) then - if (posx()>300) then jump() end - right() -end - -end diff -Nru blobby-0.8-dfsg/data/scripts/hyp011.lua blobby-0.9c/data/scripts/hyp011.lua --- blobby-0.8-dfsg/data/scripts/hyp011.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/hyp011.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,634 +0,0 @@ -g=0.28 -pg=0.88 -v0=14.5 -v_p=4.5 -pj=0.44 -r1=31.5 -p0=0 -p1=0.5 -p2=1 -h=31.5+19+25 - - -estt=0 -nettime=0 -touch=0 -est=0 -p=0.4 -esto1=10 -esto2=10 -esto3=10 - - -function yb(y,vy,t) - - return y+(vy-g/10)*t-1/2*g*t^2 - -end - -function move(x) - - if (posx()2.26) then right() - elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() - end - -end - -function tb(y,vy,height,typ) -local sgn=0 - if (typ==1) - then - sgn=-1 - else - sgn=1 - end - if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 - then return -1 - else - return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) - end -end - -function time(t) - - return 1/5*math.ceil(5*t) - -end - -function pos(x) - - local x1,x2 - x1=4.5*math.ceil((1/4.5)*x) - x2=4.5*math.floor((1/4.5)*x) - if (x1<0) or (x2<0) then return 0 - else - if (math.abs(x1-x)146) then - return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) - else - return 0 - end -end - -function time(t) -return 1/5*math.ceil(5*t) -end - - --- - -function collide(x,y,vx,vy,objx,objy,r2) - - local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) - local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) - local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) - local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) - local t=-1 - if (t1150) then t=-1 end - - return t - -end - - - -function estimate(x,y,vx,vy,height,typ) - - local collision=1 - local tw,tn,ts=0,0,0 - local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 - - while(collision==1) do - ts=collide(x,y,vx,vy,400,316,7) - if (vx>0) - then - tw=time((768.5-x)/vx) - tn=time((361.5-x)/vx) - else - tw=time((31.5-x)/vx) - tn=time((438.5-x)/vx) - end - local th=time(tb(y,vy,height,typ)) - local t=10000 - - if ((ts>0) and (ts0) and (tn0) and (twt) - then - if (t==ts) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vy=vy-g*t - xr=x - yr=y - vxr=0 - vyr=0 - n=1 - collision=0 - elseif ((t==tn) or (t==tw)) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vx=-vx - vy=vy-g*t - collision=1 - end - else - tr=tr+th - vxr=vx - vyr=vy-g*th - xr=x+vx*th - yr=yb(y,vy,th) - collision=0 - end - end - if (tr<0) - then - return -1,-1,-1,-1,-1,-1 - else - return xr,yr,vxr,vyr,tr,n - end -end - - -function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) -local x1,y1,vx1,vy1=0,0,0,0 -local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 -local xpos1=xpos -local ypos1=ypos -for t=0,20,0.2 do - - if (jump==1) then - ypos1=yp(tp(ypos)+t) - end - x1=x+vx*t - if (x1<31.5) then x1=2*31.5-x1 end - if (x1>368.5) then x1=2*368.5-x1 end - y1=yb(y,vy,t) - - if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then - local dx=x1-xpos1 - local dy=y1-(ypos1+19) - local l=math.sqrt(dx^2+dy^2) - vx1=dx/l - vy1=dy/l - x1=x1+vx1*3 - y1=y1+vy1*3 - vy1=vy1*13.125 - vx1=vx1*13.125 - x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) - break - end -end - -return x2,y2,x1,y1,vx1,vy1 -end - -function lob() - - if (math.abs(est-esto2)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto2=est - imp=0 - x1=0 - t=30 - while (t>=0) do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5730) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - if (impfimp) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - end - if (imp>740) then break end - end - if (t>12) then t=t-6 else t=t-4 end - end - t2=t2+1 - end - t2=t2-1 - if (x1>0) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else - move(est) - --p=0.5 - end - -end - - -function attack() - - if (math.abs(est-esto1)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 - h2=900 --- debug(-10) - esto1=est - imp=0 - x1=0 - t=30 - while (t>=0) do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.5+10) and (x1f<360) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - xat=xaf - yat=yaf - vxat=vxaf - vyat=vyaf - break - end - end - h2t=yb(yat,vyat,(400-xat)/vxat) - if (h2t316+31.5+10) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - xa=xat - ya=yat - vxa=vxat - vya=vyat - end - h2=yb(ya,vya,(400-xa)/vxa) - if (h2>316+31.5+10) and (h2<316+31.5+45) then break end - end - if (t>12) then t=t-6 - else t=t-4 end - end - t2=t2+1 - end - t2=t2-1 - - if (x1>0) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() - end - else - move(est) - --p=0.9 - end -end - - -function netp() - - if (math.abs(est-esto3)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto3=est - imp=500 - x1=0 - for t=33,0,-3 do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5380) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - end - if (impt0) and (est<368.5) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else - move(est-4.5) - end - -end - - - - - -function posplay() - - if (math.abs(est-esto3)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto3=est - imp=500 - x1=0 - for t=33,0,-3 do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5280) and (impf<340) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - end - if (math.abs(impt-310)0) and (est<368.5) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else - move(est) - end - -end - - - - - - -function OnOpponentServe() -y1p=144.5 -if (math.abs(pos(posx())-posx())>1) then move(400) else -move(200) -end -valid=1 -nettime=0 -phase=0 - -end - -function OnServe(ballready) -nettime=0 -y1p=144.5 -phase=0 - est=700 - - if (math.abs(pos(posx())-posx())>1) then - move(400) - else - if (math.abs(posx()-180)<2) then - jump() - else - move(180) - end - end -valid=1 -end - - - -function OnGame() - -yp2=y1p -y1p=oppy() -vp=y1p-yp2 - - -esttold=estt -netold=net -toucho=touch -touch=touches() -if (touch431.5) or (est<368.5)) then - nettime=10 - phase=4 - elseif (phase==4) and (nettime>0) then - nettime=nettime-1 - else - if (est>431.5) then - phase=3 - elseif (est<431.5) and (est>368.5) then - phase=2 - else - phase=1 - end -end - -if (math.sqrt((ballx()-400)^2+(bally()-316)^2)<(31.5+7)) and (math.sqrt((bspeedx())^2+(bspeedy())^2)<2) then phase=5 end - - ---1 Player ---2 Ball --- debug(0) --- debug(est) --- debug(imp) --- debug(t2) --- --- if (est<(400-31.5)) then --- if (p<1) then netp() --- else lob() --- end --- elseif (est<400-22) and (est>400-31.5) then --- move (250) --- elseif (est<400-10) and (est>400-22) then --- move(200) --- elseif (est<400) and (est>400-10) then --- move(180) --- else --- move(100) --- end -if (phase==3) then - move(100) - elseif (phase==1) then - if (p<0.4) then - attack() - elseif (p>=0.4) and (p<0.7) then - lob() - else - if (touches()==0) then - posplay() - elseif (touches()==1) then - netp() - else - attack() - end - end - elseif (phase==2) then - if (tnet<=tp(393)+1) or (nettime>0) then jump() end - if (math.abs(posx()-360)/4.5-10<=tnet) then - left() - else - right() - end - elseif (phase==4) then - right() - jump() - elseif (phase==5) then - if (posx()>300) then jump() end - right() -end - -end diff -Nru blobby-0.8-dfsg/data/scripts/hyp012.lua blobby-0.9c/data/scripts/hyp012.lua --- blobby-0.8-dfsg/data/scripts/hyp012.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/hyp012.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,649 +0,0 @@ -g=0.28 -pg=0.88 -v0=14.5 -v_p=4.5 -pj=0.44 -r1=31.5 - -h=31.5+19+25 - - -estt=0 -nettime=0 -touch=0 -est=0 -p=math.random()/2+0.5 -esto1=10 -esto2=10 -esto3=10 -esto4=10 - -function yb(y,vy,t) - - return y+(vy-g/10)*t-1/2*g*t^2 - -end - -function move(x) - - if (posx()2.26) then right() - elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() - end - -end - -function tb(y,vy,height,typ) -local sgn=0 - if (typ==1) - then - sgn=-1 - else - sgn=1 - end - if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 - then return -1 - else - return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) - end -end - -function time(t) - - return 1/5*math.ceil(5*t) - -end - -function pos(x) - - local x1,x2 - x1=4.5*math.ceil((1/4.5)*x) - x2=4.5*math.floor((1/4.5)*x) - if (x1<0) or (x2<0) then return 0 - else - if (math.abs(x1-x)146) then - return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) - else - return 0 - end -end - -function time(t) -return 1/5*math.ceil(5*t) -end - - --- - -function collide(x,y,vx,vy,objx,objy,r2) - - local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) - local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) - local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) - local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) - local t=-1 - if (t1150) then t=-1 end - - return t - -end - - - -function estimate(x,y,vx,vy,height,typ) - - local collision=1 - local tw,tn,ts=0,0,0 - local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 - - while(collision==1) do - ts=collide(x,y,vx,vy,400,316,7) - if (vx>0) - then - tw=time((768.5-x)/vx) - tn=time((361.5-x)/vx) - else - tw=time((31.5-x)/vx) - tn=time((438.5-x)/vx) - end - local th=time(tb(y,vy,height,typ)) - local t=10000 - - if ((ts>0) and (ts0) and (tn0) and (twt) - then - if (t==ts) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vy=vy-g*t - xr=x - yr=y - vxr=0 - vyr=0 - n=1 - collision=0 - elseif ((t==tn) or (t==tw)) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vx=-vx - vy=vy-g*t - collision=1 - end - else - tr=tr+th - vxr=vx - vyr=vy-g*th - xr=x+vx*th - yr=yb(y,vy,th) - collision=0 - end - end - if (tr<0) - then - return -1,-1,-1,-1,-1,-1 - else - return xr,yr,vxr,vyr,tr,n - end -end - - -function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) -local x1,y1,vx1,vy1=0,0,0,0 -local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 -local xpos1=xpos -local ypos1=ypos -for t=0,20,0.2 do - - if (jump==1) then - ypos1=yp(tp(ypos)+t) - end - x1=x+vx*t - if (x1<31.5) then x1=2*31.5-x1 end - if (x1>368.5) then x1=2*368.5-x1 end - y1=yb(y,vy,t) - - if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then - local dx=x1-xpos1 - local dy=y1-(ypos1+19) - local l=math.sqrt(dx^2+dy^2) - vx1=dx/l - vy1=dy/l - x1=x1+vx1*3 - y1=y1+vy1*3 - vy1=vy1*13.125 - vx1=vx1*13.125 - x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) - break - end -end - -return x2,y2,x1,y1,vx1,vy1 -end - -function lob() - - if (math.abs(est-esto2)>0.2) then - esto2=est - imp=0 - x1=0 - t=30 - while (t>=0) do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5730) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - if (impfimp) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - end - if (imp>740) then break end - end - if (t>12) then t=t-6 else t=t-4 end - end - t2=t2+1 - end - t2=t2-1 - if (x1>0) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else --- move(est) -p=math.random() -esto2=0 - end - -end - - -function attack() - - if (math.abs(est-esto1)>0.2) then - h2=900 - esto1=est - imp=0 - x1=0 - t=30 - while (t>=0) do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(pos(x2f)+4.5))/4.5400) and (math.abs(posx()-x1f)/4.5+10) and (x1f<360) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - xat=xaf - yat=yaf - vxat=vxaf - vyat=vyaf - break - end - end - h2t=yb(yat,vyat,(400-xat)/vxat) - if (h2t316+31.5+10) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - xa=xat - ya=yat - vxa=vxat - vya=vyat - end - h2=yb(ya,vya,(400-xa)/vxa) - if (h2>316+31.5+10) and (h2<316+31.5+60) then break end - end - if (t>12) then t=t-6 - else t=t-4 end - end - t2=t2+1 - end - t2=t2-1 - - if (x1>0) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() - end - else --- move(est-5) - --p=0.9 -p=math.random() -esto1=0 - end -end - - -function netp() - - if (math.abs(est-esto3)>0.2) then - esto3=est - imp=500 - x1=0 - for t=33,0,-3 do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5380) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - end - if (impt0) and (est<368.5) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else --- move(est-4.5) -p=math.random() -esto3=0 - end - -end - - - - - -function playto(dest) ---310 - - if (math.abs(est-esto4)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto4=est - imp=500 - x1=0 - for t=33,0,-3 do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5dest-30) and (impf0) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - end - if (math.abs(impt-dest)0) and (est<368.5) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else --- move(est) -p=math.random() -esto4=0 - end - -end - - - - - - -function OnOpponentServe() -pp=math.random() - y1p=144.5 - if (math.abs(pos(posx())-posx())>1) then - move(400) - else - move(200) - end - valid=1 - nettime=0 - phase=0 - imp1=0 - imp2=0 - imp=0 - active=1 -end - -function OnServe(ballready) -pp=math.random() - active=1 - nettime=0 - y1p=144.5 - phase=0 - est=700 - imp1=0 - imp2=0 - imp=0 - - if (math.abs(pos(posx())-posx())>1) then - move(400) - else - if (math.abs(posx()-198)<2) then - jump() - else - move(198) - end - end - valid=1 -end - - - -function OnGame() - - yp2=y1p - y1p=oppy() - vp=y1p-yp2 - - if (math.abs(imp1-imp)>0.1) then - imp2=imp1 - imp1=imp - end - - esttold=estt - netold=net - toucho=touch - touch=touches() - if (touch431.5) or (est<368.5)) then - nettime=11 - phase=4 - elseif (phase==4) and (nettime>0) then - nettime=nettime-1 - else - if (est>431.5) then - phase=3 - elseif (est<431.5) and (est>368.5) then - phase=2 - else - phase=1 - end - end - else - phase=6 - end - if (bally()<130) then active=0 end - - if (math.sqrt((ballx()-400)^2+(bally()-316)^2)<(31.5+7)) and (math.sqrt((bspeedx())^2+(bspeedy())^2)<2) then phase=5 end - - if (phase==3) then - move(170) - elseif (phase==1) then - - if (p<0.5) then - if (touch==0) then - playto(310) - elseif (touch==1) then - if (p<0.2) then - netp() - elseif (p>=0.2) and (p<0.35) then - playto(pp*300+450) - elseif (p>=0.35) and (p<0.5) then - attack() - end - else - attack() - end - else - if (touch==0) then - if (p>=0.5) and (p<0.75) then - playto(pp*300+450) - elseif (p>=0.75) and (p<=1.0) then - attack() - end - else - attack() - end - end - elseif (phase==2) then - if (tnet<=tp(393)+1) or (nettime>0) then jump() end - if (math.abs(posx()-360)/4.5-10<=tnet) then - left() - else - right() - end - elseif (phase==4) then - right() - jump() - elseif (phase==5) then - if (posx()>300) then - jump() - end - right() - end - - if ((x1==0) or (imp==0)) and (phase==1) then --- debug(-1) - move(est) - end ---debug(phase) -end diff -Nru blobby-0.8-dfsg/data/scripts/hyp013.lua blobby-0.9c/data/scripts/hyp013.lua --- blobby-0.8-dfsg/data/scripts/hyp013.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/hyp013.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,592 +0,0 @@ -g=0.28 -pg=0.88 -v0=14.5 -v_p=4.5 -pj=0.44 -r1=31.5 -h=31.5+19+25 - estt=0 -p=0.654 - -function reset() - est=0 - imp,imp1,imp2=0,0,0 - - nettime=0 - touch=0 - esto1=0 - esto2=0 - esto3=0 - esto4=0 - esto5=0 - esto6=0 - phase=0 - valid=1 - active=1 - nettime=0 - y1p=posy() -end - -function yb(y,vy,t) - - return y+(vy-g/10)*t-1/2*g*t^2 - -end - -function move(x) - - if (posx()2.26) then right() - elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() - end - -end - -function tb(y,vy,height,typ) - local sgn=0 - if (typ==1) - then - sgn=-1 - else - sgn=1 - end - if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 - then return -1 - else - return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) - end -end - -function time(t) - - return 1/5*math.ceil(5*t) - -end - -function pos2(x) - - local x1,x2 - x1=4.5*math.ceil((1/4.5)*x) - x2=4.5*math.floor((1/4.5)*x) - if (x1<0) or (x2<0) then return 0 - else - if (math.abs(x1-x)146) then - return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) - else - return 0 - end -end - -function time(t) -return 1/5*math.ceil(5*t) -end - - --- - -function collide(x,y,vx,vy,objx,objy,r2) - - local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) - local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) - local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) - local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) - local t=-1 - if (t1150) then t=-1 end - - return t - -end - - - -function estimate(x,y,vx,vy,height,typ) - - local collision=1 - local tw,tn,ts=0,0,0 - local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 - - while(collision==1) do - ts=collide(x,y,vx,vy,400,316,7) - if (vx>0) - then - tw=time((768.5-x)/vx) - tn=time((361.5-x)/vx) - else - tw=time((31.5-x)/vx) - tn=time((438.5-x)/vx) - end - local th=time(tb(y,vy,height,typ)) - local t=10000 - - if ((ts>0) and (ts0) and (tn0) and (twt) - then - if (t==ts) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vy=vy-g*t - xr=x - yr=y - vxr=vx - vyr=vy - n=1 - collision=0 - elseif ((t==tn) or (t==tw)) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vx=-vx - vy=vy-g*t - collision=1 - end - else - tr=tr+th - vxr=vx - vyr=vy-g*th - xr=x+vx*th - yr=yb(y,vy,th) - collision=0 - end - end - if (tr<0) - then - return -1,-1,-1,-1,-1,-1 - else - return xr,yr,vxr,vyr,tr,n - end -end - - -function impact(x,y,vx,vy,xpos,ypos,targety,jum,move) -local x1,y1,vx1,vy1=0,0,0,0 -local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 -local xpos1=xpos -local ypos1=ypos -for t=0,7,0.2 do - - if (jum==1) then - ypos1=yp(tp(ypos)+t) - end - x1=x+vx*t - if (x1<31.5) then x1=2*31.5-x1 end - if (x1>368.5) then x1=2*368.5-x1 end - y1=yb(y,vy,t) - - if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then - local dx=x1-xpos1 - local dy=y1-(ypos1+19) - local l=math.sqrt(dx^2+dy^2) - vx1=dx/l - vy1=dy/l - x1=x1+vx1*3 - y1=y1+vy1*3 - vy1=vy1*13.125 - vx1=vx1*13.125 - x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) - break - - end -end - -return x2,y2,x1,y1,vx1,vy1 -end - -function playto(position) - - if (math.abs(est-esto3)>0.2) then - delta=30 - esto3=est - imp,impt,impf=0,0,0 - x1=0 - t=27 - typ1=60 - typ2=120 - if (position<400) then - n1=2 - n2=-3 - elseif (position>600) then - n1=-4 - n2=-11 - else - n1=-1 - n2=-8 - end - while (t>=0) do - - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(math.ceil((tp2(posy(),vp))))1) and (t2f>1) then - - for x1f=pos(x2f)+n1*4.5,pos(x2f)+n2*4.5,-4.5 do - impf,_,xaf,yaf,vxaf,vyaf=impact(x2f,y2f,vx2f,vy2f,x1f,y1f,220,j,0) - - if (impf>position-delta) and (math.abs(posx()-x1f)/4.5+10) and (x1f<330) and (impfposition+delta) and ((x1f-pos(x2f))/4.5<0) then break end - end - - - end - if (imp>position-delta) and (imp15) then t=t-6 - else t=t-3 end - end - t2=t2+1 - - end - - if (x1>0) and (imp>0) then - t2=t2-1 - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() - end - else - move(est+4.5) - end -end - -function net() - - if (math.abs(est-esto2)>0.2) then - esto2=est - imp,impt,impf=0,0,0 - x1=0 - t=27 - typ1=60 - typ2=120 - - while (t>=0) do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(math.ceil((tp2(posy(),vp))))+21) and (t2f>1) then - for x1f=pos(x2f)-1*4.5,pos(x2f)-10*4.5,-4.5 do - impf,_,xaf,yaf,vxaf,vyaf=impact(x2f,y2f,vx2f,vy2f,x1f,y1f,220,j,0) - if (impf>400) and (math.abs(posx()-x1f)/4.50) and (x1f<330) and (impf<438) then - imp=impf - x1=x1f - y1=y1f - t1=t1f - x2=x2f - y2=y2f - t2=t2f - vx2=vx2f - vy2=vy2f - xa=xaf - ya=yaf - vxa=vxaf - vya=vyaf - break - end - if (imp>400) then break end - end - - - end - if (imp>400) and (imp<438) then break end - if (t>15) then t=t-6 - else t=t-3 end - end - t2=t2+1 - - end - - if (x1>0) and (imp>0) then - t2=t2-1 - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() - end - else - playto(600) - end -end - - -function attack() - - if (math.abs(est-esto1)>0.2) then - h2=900 - esto1=est - imp,impt,impf=0,0,0 - x1=0 - t=27 - typ1=60 - typ2=120 - - while (t>=0) do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(math.ceil((tp2(posy(),vp))))+21) and (t2f>1) then - for x1f=pos(x2f)-20*4.5,pos(x2f)-4*4.5,4.5 do - impf,_,xaf,yaf,vxaf,vyaf=impact(x2f,y2f,vx2f,vy2f,x1f,y1f,220,j,0) - h1=yb(yaf,vyaf,(380-xaf)/vxaf) - h2=yb(yaf,vyaf,(420-xaf)/vxaf) - height=316+7+31.5 - - if (impf>432) and (math.abs(posx()-x1f)/4.5+10) and (x1f<330) and (h2>height+typ1) and (h1>height+typ1) and (h2432) and (h2>height+typ2) then break end - end - - - end - if (imp>0) then break end - if (t>15) then t=t-6 - else t=t-3 end - end - t2=t2+1 - - end - - if (x1>0) and (imp>0) then - t2=t2-1 - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() - end - else - playto(600) - end -end - - - - - -function OnOpponentServe() -reset() - if (math.abs(pos2(posx())-posx())>1) then - move(400) - else - move(200) - end -end - -function OnServe(ballready) -reset() - if (math.abs(pos2(posx())-posx())>1) then - move(400) - else - if (math.abs(posx()-198)<2) then - jump() - else - move(198) - end - end -end - - - -function OnGame() - - yp2=y1p - y1p=posy() - vp=y1p-yp2 - - if (math.abs(imp1-imp)>0.1) then - imp2=imp1 - imp1=imp - end - - esttold=estt - netold=netc - toucho=touch - touch=touches() - if (touch438.5) or (est<361.5)) then - nettime=11 - phase=4 - elseif (phase==4) and (nettime>0) then - nettime=nettime-1 - else - if (est>438.5) then - phase=2 - elseif (est<438.5) and (est>361.5) then - if (((vyestt-g*(80-estt)/vxestt)>0) or (vxestt<0)) and ((360-posx())/4.5=0.2)) then - attack() - else - playto(600) - end - elseif (p>=0.6) and (p<0.9) then - if (p<0.7) and (touch==0) then - playto(300) - else - playto(770) - end --- elseif (p>=0.9) and (p<0.95) then --- playto(480) - else - if (p<0.95) and (touch==0) then - playto(300) - elseif (touch==1) or ((touch==0) and (p>=0.95)) then - playto(480) - else - playto(600) - end - end - elseif (phase==3) then - if (tnet<=tp(393)-3) or (nettime>0) then jump() end - if (math.abs(posx()-360)/4.5-7<=tnet) then - left() - else - right() - end - elseif (phase==4) then - right() - jump() - elseif (phase==5) then - move(200) - elseif (phase==6) then - if (posx()>300) then - jump() - end - right() - end - - if ((x1==0) or (imp==0)) and (phase==1) then - move(est) - end --- debug(0) --- debug(imp) --- debug(est) -end diff -Nru blobby-0.8-dfsg/data/scripts/hyp07.lua blobby-0.9c/data/scripts/hyp07.lua --- blobby-0.8-dfsg/data/scripts/hyp07.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/hyp07.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,409 +0,0 @@ -g=0.28 -pg=0.88 -v0=14.5 -v_p=4.5 -pj=0.44 -r1=31.5 - - - - -function yb(y,vy,t) - - return y+(vy-g/10)*t-1/2*g*t^2 - -end - -function move(x) - - if (posx()2.26) then right() - elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() - end - -end - -function tb(y,vy,height,typ) -local sgn=0 - if (typ==1) - then - sgn=-1 - else - sgn=1 - end - if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 - then return -1 - else - return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) - end -end - -function time(t) - - return 1/5*math.ceil(5*t) - -end - -function pos(x) - - local x1,x2 - x1=4.5*math.ceil((1/4.5)*x) - x2=4.5*math.floor((1/4.5)*x) - if (x1<0) or (x2<0) then return 0 - else - if (math.abs(x1-x) - -function collide(x,y,vx,vy,objx,objy,r2) - - local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) - local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) - local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) - local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) - local t=-1 - if (t1150) then t=-1 end - - return t - -end - - - -function est(x,y,vx,vy,height,typ) - - local collision=1 - local tw,tn,ts=0,0,0 - local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 - - while(collision==1) do - ts=collide(x,y,vx,vy,400,316,7) - if (vx>0) - then - tw=time((768.5-x)/vx) - tn=time((361.5-x)/vx) - else - tw=time((31.5-x)/vx) - tn=time((438.5-x)/vx) - end - local th=time(tb(y,vy,height,typ)) - local t=10000 - - if ((ts>0) and (ts0) and (tn0) and (twt) - then - if (t==ts) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vy=vy-g*t - xr=x - yr=y - vxr=0 - vyr=0 - n=1 - collision=0 - elseif ((t==tn) or (t==tw)) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vx=-vx - vy=vy-g*t - collision=1 - end - else - tr=tr+th - vxr=vx - vyr=vy-g*th - xr=x+vx*th - yr=yb(y,vy,th) - collision=0 - end - end - if (tr<0) - then - return -1,-1,-1,-1,-1,-1 - else - return xr,yr,vxr,vyr,tr,n - end -end - - - - - - - -function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) -local x1,y1,vx1,vy1=0,0,0,0 -local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 -local xpos1=xpos -local ypos1=ypos -for t=0,20,0.2 do - - if (jump==1) then - ypos1=yp(tp(ypos)+t) - end - x1=x+vx*t - if (x1<31.5) then x1=2*31.5-x1 end --- if (x1>360) then x1=2*360-x1 end - y1=yb(y,vy,t) - - if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then - local dx=x1-xpos1 - local dy=y1-(ypos1+19) - local l=math.sqrt(dx^2+dy^2) - vx1=dx/l - vy1=dy/l - x1=x1+vx1*3 - y1=y1+vy1*3 - vy1=vy1*13.125 - vx1=vx1*13.125 - x2,y2,vx2,vy2,t2,nn=est(x1,y1,vx1,vy1,targety,2) - break - end -end - -return x2,y2 -end - - - - - - -function nothing() ---[[ if (math.abs(xe-xo)>0.1) then - xo=xe - for test=30,0,-3 do - t1=test - y1=yp(t1) - t2=math.floor(tb(y,vy,y1+31.5+25+19,2)) - y2=yb(y,vy,t2) - - x2,y2,vx2,vy2,t2,_=est(x,y,vx,vy,y2+0.1) - t2=t2 - if (vx2>2) then - n=0 - elseif (vx2>0.5) then - n=5 - else - n=13 - end - xi,yi=impact(x2,y2,vx2,vy2,pos(x2-n*4.5),y1,220,1,0) - - if (math.abs(posx()-(x2-n*4.5))/4.580) and (t2-1>t1) and (xi>400) then - break - end - end - end - - move(x2-n*4.5) - if (t2<=t1) then - jump() - end - --]] - -end - - - - - - -function OnOpponentServe() -xdo=0 -xe=0 -s=1 -touch=0 -xodo=0 -change=1 -stop=0 -t1,t2,y1,y2,x,y,vx,vy=0,0,0,0,0,0,0,0 -calc=0 -if (math.abs(pos(posx())-posx())>1) then move(400) else -move(200) -end -xo=0 -c=0 -end - -function OnServe(ballready) -xe=0 -s=1 -xodo=0 -xdo=0 -change=1 -touch=0 -stop=0 -t1,t2,y1,y2,x,y,vx,vy=0,0,0,0,0,0,0,0 -xo=0 -c=0 -if (math.abs(pos(posx())-posx())>1) then move(400) else - if (math.abs(posx()-180)<2) then jump() else move(180) end - end -end - -function OnGame() - -if (change==0) and (touches()=te) then jump() end - if (math.abs(posx()-360)/4.50.2) then - xodo=xdo - imp=0 - x1=0 - for t=27,0,-3 do - t1f=t - y1f=yp(t1f) - t2f=math.floor(tb(y,vy,y1f+h,2)) - if (t2f>0) then --- debug(0) --- debug(t2f) - y2f=yb(y,vy,t2f) --- debug(y2f) - vy2f=vy-g*t2f - x2f,y2f,vx2f,vy2f,t2f,_=est(x,y,vx,vy,y2f-vy2f/10,2) --- debug(t2f) --- debug(y2f) --- debug(vy) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - impt=0 - if (t1f<=t2f-2) then - for x1f=pos(x2f)-25*4.5,pos(x2f)+4.5,4.5 do - impf,_=impact(x2f,y2f,vx2f,vy2f,pos(x1f),y1f,220,1,0) - if (impf>440) and (math.abs(posx()-x1f)/4.5400) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - end - if (imp>400) then break end - end - end - end - t2=t2+1 - end - t2=t2-1 - if (s==1) then - move(x1) - if (t2<=t1+0.1) then jump() end - end - else - move(200) - end -end - -if (bally()<140) then s=0 end - --- debug(0) --- debug(x2) --- debug(ballx()) --- debug(y2) --- debug(bally()) --- debug(vx2) --- debug(bspeedx()) --- debug(vy2) --- debug(bspeedy()) --- debug(xe) --- debug(imp) --- debug(t2) --- debug(0) -end - - diff -Nru blobby-0.8-dfsg/data/scripts/hyp09.lua blobby-0.9c/data/scripts/hyp09.lua --- blobby-0.8-dfsg/data/scripts/hyp09.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/hyp09.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,503 +0,0 @@ -g=0.28 -pg=0.88 -v0=14.5 -v_p=4.5 -pj=0.44 -r1=31.5 -p0=0 -p1=0.5 -p2=1 -h=31.5+19+25 - - -estt=0 -nettime=0 -touch=0 -est=0 -p=0.4 -esto=10 - - -function yb(y,vy,t) - - return y+(vy-g/10)*t-1/2*g*t^2 - -end - -function move(x) - - if (posx()2.26) then right() - elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() - end - -end - -function tb(y,vy,height,typ) -local sgn=0 - if (typ==1) - then - sgn=-1 - else - sgn=1 - end - if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 - then return -1 - else - return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) - end -end - -function time(t) - - return 1/5*math.ceil(5*t) - -end - -function pos(x) - - local x1,x2 - x1=4.5*math.ceil((1/4.5)*x) - x2=4.5*math.floor((1/4.5)*x) - if (x1<0) or (x2<0) then return 0 - else - if (math.abs(x1-x)146) then - return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) - else - return 0 - end -end - -function time(t) -return 1/5*math.ceil(5*t) -end - - --- - -function collide(x,y,vx,vy,objx,objy,r2) - - local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) - local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) - local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) - local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) - local t=-1 - if (t1150) then t=-1 end - - return t - -end - - - -function estimate(x,y,vx,vy,height,typ) - - local collision=1 - local tw,tn,ts=0,0,0 - local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 - - while(collision==1) do - ts=collide(x,y,vx,vy,400,316,7) - if (vx>0) - then - tw=time((768.5-x)/vx) - tn=time((361.5-x)/vx) - else - tw=time((31.5-x)/vx) - tn=time((438.5-x)/vx) - end - local th=time(tb(y,vy,height,typ)) - local t=10000 - - if ((ts>0) and (ts0) and (tn0) and (twt) - then - if (t==ts) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vy=vy-g*t - xr=x - yr=y - vxr=0 - vyr=0 - n=1 - collision=0 - elseif ((t==tn) or (t==tw)) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vx=-vx - vy=vy-g*t - collision=1 - end - else - tr=tr+th - vxr=vx - vyr=vy-g*th - xr=x+vx*th - yr=yb(y,vy,th) - collision=0 - end - end - if (tr<0) - then - return -1,-1,-1,-1,-1,-1 - else - return xr,yr,vxr,vyr,tr,n - end -end - - -function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) -local x1,y1,vx1,vy1=0,0,0,0 -local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 -local xpos1=xpos -local ypos1=ypos -for t=0,20,0.2 do - - if (jump==1) then - ypos1=yp(tp(ypos)+t) - end - x1=x+vx*t - if (x1<31.5) then x1=2*31.5-x1 end - if (x1>368.5) then x1=2*368.5-x1 end - y1=yb(y,vy,t) - - if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then - local dx=x1-xpos1 - local dy=y1-(ypos1+19) - local l=math.sqrt(dx^2+dy^2) - vx1=dx/l - vy1=dy/l - x1=x1+vx1*3 - y1=y1+vy1*3 - vy1=vy1*13.125 - vx1=vx1*13.125 - x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) - break - end -end - -return x2,y2,x1,y1,vx1,vy1 -end - -function lob() - - if (math.abs(est-esto)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto=est - imp=0 - x1=0 - for t=33,0,-3 do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5700) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - end - if (impt>imp) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - end - if (imp>740) then break end - end - end - t2=t2+1 - end - t2=t2-1 - if (x1>0) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else - move(est) - end - -end - - -function attack() - - if (math.abs(est-esto)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 - h2=900 --- debug(-10) - esto=est - imp=0 - x1=0 - for t=33,0,-3 do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.5+10) and (x1f<360) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - xat=xaf - yat=yaf - vxat=vxaf - vyat=vyaf - break - end - end - h2t=yb(yat,vyat,(400-xat)/vxat) - if (h2t316+31.5) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - xa=xat - ya=yat - vxa=vxat - vya=vyat - end - h2=yb(ya,vya,(400-xa)/vxa) - if (h2<316+31.5+10) and (h2>316+31.5) then break end - end - end - t2=t2+1 - end - t2=t2-1 - - if (x1>0) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() - end - else - move(est) - end -end - - -function netp() - - if (math.abs(est-esto)>0.2) then - x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - t2g=0 --- debug(-10) - esto=est - imp=0 - x1=0 - for t=33,0,-3 do - if (t==0) then j=0 else j=1 end - t1f=t - y1f=yp(t1f) - t2g=math.floor(tb(y,vy,y1f+h,2)) - y2f=yb(y,vy,t2g) - vy2f=vy-g*t2g - x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.50) then - impt=impf - x1t=x1f - y1t=y1f - t1t=t1f - x2t=x2f - y2t=y2f - t2t=t2f - vx2t=vx2f - vy2t=vy2f - break - end - end - if (impt>imp) and (impt<431.5) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - end - if (imp>428) then break end - end - end - t2=t2+1 - end - t2=t2-1 - if (x1>0) and (est<368.5) then - move(x1) - if (t2<=t1+0.1) and (y1>146) then - jump() end - else - move(est) - end - -end - - -function OnOpponentServe() -y1p=144.5 -if (math.abs(pos(posx())-posx())>1) then move(400) else -move(200) -end -valid=1 - - -end - -function OnServe(ballready) -y1p=144.5 - est=700 - - if (math.abs(pos(posx())-posx())>1) then - move(400) - else - if (math.abs(posx()-180)<2) then - jump() - else - move(180) - end - end -valid=1 -end - - - -function OnGame() - -yp2=y1p -y1p=oppy() -vp=y1p-yp2 - - -esttold=estt -netold=net -toucho=touch -touch=touches() -if (touch400-31.5) then - move (250) - elseif (est<400-10) and (est>400-22) then - move(200) - elseif (est<400) and (est>400-10) then - move(180) - else - move(230) -end - -end diff -Nru blobby-0.8-dfsg/data/scripts/hyp8.lua blobby-0.9c/data/scripts/hyp8.lua --- blobby-0.8-dfsg/data/scripts/hyp8.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/hyp8.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,531 +0,0 @@ -g=0.28 -pg=0.88 -v0=14.5 -v_p=4.5 -pj=0.44 -r1=31.5 -p0=0 -p1=0.5 -p2=1 -h=31.5+19+25 - - -estt=0 -nettime=0 -touch=0 -est=0 -p=0.4 -esto=10 - - -function yb(y,vy,t) - - return y+(vy-g/10)*t-1/2*g*t^2 - -end - -function move(x) - - if (posx()2.26) then right() - elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() - end - -end - -function tb(y,vy,height,typ) -local sgn=0 - if (typ==1) - then - sgn=-1 - else - sgn=1 - end - if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 - then return -1 - else - return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) - end -end - -function time(t) - - return 1/5*math.ceil(5*t) - -end - -function pos(x) - - local x1,x2 - x1=4.5*math.ceil((1/4.5)*x) - x2=4.5*math.floor((1/4.5)*x) - if (x1<0) or (x2<0) then return 0 - else - if (math.abs(x1-x) - -function collide(x,y,vx,vy,objx,objy,r2) - - local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) - local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) - local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) - local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) - local t=-1 - if (t1150) then t=-1 end - - return t - -end - - - -function estimate(x,y,vx,vy,height,typ) - - local collision=1 - local tw,tn,ts=0,0,0 - local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 - - while(collision==1) do - ts=collide(x,y,vx,vy,400,316,7) - if (vx>0) - then - tw=time((768.5-x)/vx) - tn=time((361.5-x)/vx) - else - tw=time((31.5-x)/vx) - tn=time((438.5-x)/vx) - end - local th=time(tb(y,vy,height,typ)) - local t=10000 - - if ((ts>0) and (ts0) and (tn0) and (twt) - then - if (t==ts) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vy=vy-g*t - xr=x - yr=y - vxr=0 - vyr=0 - n=1 - collision=0 - elseif ((t==tn) or (t==tw)) - then - tr=tr+t - x=x+vx*t - y=yb(y,vy,t) - vx=-vx - vy=vy-g*t - collision=1 - end - else - tr=tr+th - vxr=vx - vyr=vy-g*th - xr=x+vx*th - yr=yb(y,vy,th) - collision=0 - end - end - if (tr<0) - then - return -1,-1,-1,-1,-1,-1 - else - return xr,yr,vxr,vyr,tr,n - end -end - - -function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) -local x1,y1,vx1,vy1=0,0,0,0 -local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 -local xpos1=xpos -local ypos1=ypos -for t=0,20,0.2 do - - if (jump==1) then - ypos1=yp(tp(ypos)+t) - end - x1=x+vx*t - if (x1<31.5) then x1=2*31.5-x1 end - if (x1>368.5) then x1=2*368.5-x1 end - y1=yb(y,vy,t) - - if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then - local dx=x1-xpos1 - local dy=y1-(ypos1+19) - local l=math.sqrt(dx^2+dy^2) - vx1=dx/l - vy1=dy/l - x1=x1+vx1*3 - y1=y1+vy1*3 - vy1=vy1*13.125 - vx1=vx1*13.125 - x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) - break - end -end - -return x2,y2,x1,y1,vx1,vy1 -end - - -function netp() - - if (math.abs(est-esto)>0.2) then - esto=est - imp=0 - x1=0 - for t=27,0,-3 do - t1f=t - y1f=yp(t1f) - t2f=math.floor(tb(y,vy,y1f+h,2)) - if (t2f>0) then - y2f=yb(y,vy,t2f) - vy2f=vy-g*t2f - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/10,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - impt=0 - if (t1f<=t2f-2) and (math.abs(posx()-x2f)/4.5400) and (math.abs(posx()-x1f)/4.5imp) and (impt<431.5) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - end - if (imp>415) then break end - end - end - end - t2=t2+1 - end - - t2=t2-1 - move(x1) - if (t2<=t1+0.1) and (y1>150) then jump() end - -end - - - -function lob() - - if (math.abs(est-esto)>0.2) then - esto=est - imp=0 - x1=0 - for t=27,0,-3 do - t1f=t - y1f=yp(t1f) - t2f=math.floor(tb(y,vy,y1f+h,2)) - if (t2f>0) then - y2f=yb(y,vy,t2f) - vy2f=vy-g*t2f - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/10,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - impt=0 - if (t1f<=t2f-2) then - for x1f=pos(x2f)+4.5,pos(x2f)-15*4.5,-4.5 do - impf,_=impact(x2f,y2f,vx2f,vy2f,pos(x1f),y1f,220,1,0) - if (impf>700) and (math.abs(posx()-x1f)/4.5imp) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - end - if (imp>750) then break end - end - end - end - t2=t2+1 - end - - t2=t2-1 - move(x1) - if (t2<=t1+0.1) then jump() end - -end - - - -function attack() -h2=900 - if (math.abs(est-esto)>0.2) then - esto=est - imp=0 - x1=0 - for t=27,0,-3 do - t1f=t - y1f=yp(t1f) - t2f=math.floor(tb(y,vy,y1f+h,2)) - if (t2f>0) then - y2f=yb(y,vy,t2f) - vy2f=vy-g*t2f - x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/10,2) - t1f=math.floor(tp(y2f-h)) - y1f=yp(t1f) - impt=0 - if (t1f<=t2f-2) then - for x1f=pos(x2f)-25*4.5,pos(x2f)+4.5,4.5 do - impf,_,xaf,yaf,vxaf,vyaf=impact(x2f,y2f,vx2f,vy2f,pos(x1f),y1f,220,1,0) - if (impf>400) and (math.abs(posx()-x1f)/4.5316+7+31.5) then - imp=impt - x1=x1t - y1=y1t - t1=t1t - x2=x2t - y2=y2t - t2=t2t - vx2=vx2t - vy2=vy2t - xa=xat - ya=yat - vxa=vxat - vya=vyat - end - h2=yb(ya,vya,(400-xa)/vxa) - if (h2<316+7+31.5+20) and (h2>316+7+20) then break end - end - end - end - t2=t2+1 - t2t=t2t+1 - end - -if (imp>400) then - t2=t2-1 - move(x1) - if (t2<=t1+0.1) then jump() end - else - t2t=t2t-1 - move(x1t) - if (t2t<=t1t+0.1) then jump() end -end - -end - - - - - - -function OnOpponentServe() - -if (math.abs(pos(posx())-posx())>1) then move(400) else -move(200) -end -valid=1 -end - -function OnServe(ballready) - est=700 - - if (math.abs(pos(posx())-posx())>1) then - move(400) - else - if (math.abs(posx()-180)<2) then - jump() - else - move(180) - end - end -valid=1 -end - - - -function OnGame() - -esttold=estt -netold=net - - -x,y,vx,vy=ballx(),bally(),bspeedx(),bspeedy() -estt,_,_,_,tnet,net=estimate(x,y,vx,vy,220) - -if (math.abs(esttold-estt)<0.1) then -- Schutz gegen Fehler bei der estimate-Funktion während Netz/Wandkollisionen - est=estt -end - --- phase1 -> Eigener Angriff --- phase2 -> Gegner hat den Ball --- phase3 -> Netzball blocken --- phase4 -> Ball ist nicht mehr gültig - -if (bally()<144) then valid=0 end - -if (net==1) then -- klare Netzkollision - if (yb(y,vy,(380-x)/vx)>370) then - phase=3 - else - phase=4 - end - else - if (netold==1) then -- Ball hat gerade das Netz getroffen - nettime=8 -- Rest des Kollisionsskriptes abarbeiten - phase=3 - elseif (netold==0) and (nettime>0) then - nettime=nettime-1 -- Zeit runterzählen für den Rest des Kollisionsskriptes - phase=3 - else -- Keine direkte Netzkollision und deren Nachwirkungen - if (est>431.5) and (est<460) and (oppx()<700) then -- Ball kommt nahe ans Netz und der Gegner kann blocken - phase=3 - elseif (est<400-31.5) then -- eigener Angriff - phase=1 - else -- gegnerischer Angriff - phase=2 - end - end -end - -if (valid==0) then phase=5 end -- Ãœberschreibt alle vorherigen Berechnungen - -toucho=touch -touch=touches() - -if (touch=tnet) then jump() end - if (math.abs(posx()-360)/4.5ball_radius) and (x<361.5) then impact=x end -if (x361.5) - then - if (ballx()<361.5) - then - if(ypos(timetox(361.5))3) then moveto(x-40) end - if (timetoy(333)<10) then jump() end - else - x=estimate(333) - if (math.abs((x-20)-posx())>3) then moveto(x-20) end - if (timetoy(333)<10) then jump() end - end -end - -function ueberspielen() - -if (posx()<280) - then - x=estimate(437) - if (math.abs((x-30)-posx())>3) then moveto(x-30) end - if (timetoy(437)<24) then jump() end - else - x=estimate(437) - if (math.abs((x-15)-posx())>3) then moveto(x-15) end - if (timetoy(437)<24) then jump() end - end -end - - -function schmettern() - x=estimate(437) - t=timetoy(437) - if (t>24) and (math.abs((x-90)-posx())>3) then moveto(x-90) end - if (t<24) then jump() end - if (t<5) then right() end -end - --- [Hauptprogramm] - -function OnServe(ballready) - -if (new==nil) then new=1 end -if (new==1) then - j=math.random() - p=math.random(30,55) - new=2 - end - -if (j>0.5) - then - if (math.abs(posx()-200)>3) then moveto(200) else jump() end - else - if (math.abs(posx()-(200-p))>3) then moveto(200-p) else jump() end - end -end - -function OnOpponentServe() -moveto(200) -end - -function OnGame() -new=1 -x=estimate(220.5) - -if (x<420) - then - if (touches()==0) - then - moveto(x) - newp=1 - end - if (touches()==1) - then - if (newp==1) - then - p1=math.random() - newp=2 - end - if (oppx()>300) - then - if(p1>0.4) - then - ueberspielen() - else - schmettern() - end - else - if(p1>0.6) - then - ueberspielen() - else - schmettern() - end - end - end - if (touches()==2) - then - retten() - end - else - moveto(200) -end - -end diff -Nru blobby-0.8-dfsg/data/scripts/hyperion6.lua blobby-0.9c/data/scripts/hyperion6.lua --- blobby-0.8-dfsg/data/scripts/hyperion6.lua 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/data/scripts/hyperion6.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,331 +0,0 @@ --- Dies ist der BlobbyVolley2 Bot "Hyperion" --- geschrieben und getestet wurde der Bot mit der SVN-Version --- Die Version Blobby0.6 hatte verschiedene Bugs, unter anderem bei der oppx() und der estimate() Funktion --- --- Hyperion ver. 0.6 - --- - Einige Konstanten die die physikalische Welt in BlobbyVolley2 beschreiben - -g=0.28 -g_p=0.88 -v0=14.5 -v_p=4.5 -jb_p=0.44 -r1=31.5 - --- - - --- - kleine unkomplizierte Hilfsfunktionen die ich benötige - -function max(a,b) - if (a>b) then - return a - else - return b - end -end - -function min(a,b) - if (a2.6) then right() - elseif (posx()>x) and (math.abs(posx()-x)>2.6) then left() - end -end - -function t1_y(y,vy,height) --- Eingabe: Position und Geschwindigkeit des Balles, Höhe die der Ball erreichen soll --- Ausgabe: Ausgabe der Zeit bis zur Höhe height - if (vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0) then - return -1 - else - return -1/10+vy/g-math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) - end -end - -function t2_y(y,vy,height) --- Eingabe: Position und Geschwindigkeit des Balles, Höhe die der Ball erreichen soll --- Ausgabe: Ausgabe der Zeit bis zur Höhe height - if (vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0) then - return -1 - else - return -1/10+vy/g+math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) - end -end - -function y_p(y,t) --- Eingabe: Position und Geschwindigkeit des Players, Zeitpunkt an dem man die y-Koordinate des Players wissen möchte --- Ausgabe: Höhe des Players nach der Zeit t - return y+(v0+jb_p/2+g_p/10)*t-1/2*(g_p-jb_p)*t^2 -end - -tp_peak=(14.5+0.44/2+0.88/10)/(0.88-0.44) -yp_max=y_p(144.5,tp_peak) - -function time(t) - return 1/5*math.ceil(5*t) -end - -function t2_yp(y,vy,height) -y=144.5 - return (v0+jb_p/2+g_p/10)/(g_p-jb_p)+math.sqrt((v0+jb_p/2+g_p/10)^2/(g_p-jb_p)^2+2*y/(g_p-jb_p)) -end --- - - --- - Komplizierte Funktionen die die Game-Engine nachbilden und so Einschlagpunkte, etc. berechnen. - -function collide(x,y,vx,vy,x2,y2,r2) --- Berechnet, ob und nach welcher Zeit der Ball im Zustand (x,y,vx,vy) mit der Kugel an (x2,y2) mit Radius r2 kollidiert -local leftb=x2-r2-r1 -local rightb=x2+r2+r1 -local lowerb=y2-r2-r1 -local upperb=y2+r2+r1 - -local txlb=time((leftb-x)/vx) -- Zeit zur linken Begrenzung -local txrb=time((rightb-x)/vx) -- Zeit zur rechten Begrenzung -local tyla=time(t1_y(y,vy,lowerb)) --untere Grenze steigend (ascending) -local tyld=time(t2_y(y,vy,lowerb)) --untere Grenze fallend (descending) -local tyua=time(t1_y(y,vy,upperb)) --obere Grenze steigend (ascending) -local tyud=time(t2_y(y,vy,upperb)) --obere Grenze fallend (descending) -local tp=time(vy/g-1/10) -- Zeit bis die Ballkurve auf dem Höhepunkt ist (kann in der Vergangenheit liegen) - -local t1,t2,t_coll=0,0,-1 - -if (vx>0) then - t1=max(max(txlb,tyla),0) - t2=min(txrb,tyld) - else - t1=max(max(txrb,tyla),0) - t2=min(txlb,tyld) -end - -if (t10) - then - t_wall=time((768.5-x)/vx) - t_net=time((361.5-x)/vx) - else - t_wall=time((31.5-x)/vx) - t_net=time((438.5-x)/vx) - end - local t=10000 - if ((t_netsphere>0) and (t_netsphere0) and (t_net0) and (t_wallt) then - if (t==t_netsphere) then - t_ret=t_ret+t - vx_ret=0 - vy_ret=0 - x_ret=400 - y_ret=316 - collision=0 - end - if (t==t_net) or (t==t_wall) then - t_ret=t_ret+t - x=x+vx*t - y=y_b(y,vy,t) - vx=-vx - vy=vy-g*t - collision=1 - end - else - t_ret=t_ret+t_height - vx_ret=vx - vy_ret=vy-g*t_height - x_ret=x+vx*t_height - y_ret=y_b(y,vy,t_height) - collision=0 - end - - -end -- while Ende -return x_ret,y_ret,vx_ret,vy_ret,t_ret -end - - - - -function impact(x,y,vx,vy,xpos,ypos) --- schätzt den Einschlagsort des Balles wenn er mit dem Blobby an Position xpos kollidiert ist und dann losfliegt. --- Funktioniert mit minimalem Fehler - -r1=31.5 -r2=25 ---local x,y,vx,vy,t1=estimate_t(x,y,vx,vy,(ypos+19+25)+31.5) Die Wete haben schon nahe genug zu sein -local t=time(collide(x,y,vx,vy,xpos,ypos+19,25)) -if(t>0) then - x=x+vx*t - y=y_b(y,vy,t) - dx=x-xpos - dy=y-(ypos+19) - l=math.sqrt(dx^2+dy^2) - vx=dx/l - vy=dy/l - x=x+vx*3 - y=y+vy*3 - vy=vy*13.125 - vx=vx*13.125 --- x=x+vx/5 --- y=y+vy/5 - x,y,vx,vy,t=estimate_t(x,y,vx,vy,220.5) - return x,y,vx,vy,t -else - return -1,-1,-1,-1,-1 -end - -end -- Funktionsende - -function xtoplayto(target,height) - -local x,y,vx,vy,t=estimate_t(ballx(),bally(),bspeedx(),bspeedy(),height+(25+19)+31.5+5) -local xpos=estimate_t(ballx(),bally(),bspeedx(),bspeedy(),height+(25+19)+31.5) -local sgn=0 -if (x - --- - High-Level Funktionen die bestimmen wo man s - -function stellen(tox,height) ---t2_yp ---t2_y -if (tox<390) then - -elseif (390410) then - -end - -move(xplayto(tox,posy())) -end - - -function schmettern() - -end - -function ueberspielen() - -end - - - --- - --- - Die Hauptfunktionen des Spiels -function OnOpponentServe() -end - -function OnServe(ballready) -if (math.abs(math.floor(posx()/4.5)-posx()/4.5)<0.4) - then - if(math.abs(180-posx())<2) then jump() else moveto(180) end - else - moveto(400) - end - old=5 -end - -function OnGame() - - - - -x1=ballx() -y1=bally() -vx1=bspeedx() -vy1=bspeedy() -x2=oppx() -y2=163.5 -r2=25 - -xe=estimate_t(x1,y1,vx1,vy1,220.5) ---debug(xe) --- debug(x2) -xr,yr,vxr,vyr,tr=impact(x1,y1,vx1,vy1,x2,144.5) - - --- debug(xr) --- debug(0) - - -if (xe<400) then - - if (touches()==0) then - test=xtoplayto(320,144.5) - move(test) - else - test=xtoplayto(400,144.5) - move(test-3.1) - end - - -elseif (xe==400) then - move(180) -else - move(180) -end -old=touches() -end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/old/axji.lua blobby-0.9c/data/scripts/old/axji.lua --- blobby-0.8-dfsg/data/scripts/old/axji.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/axji.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,43 @@ +function OnOpponentServe() + moveto(120) +end + +wait = 0 +serv = true +aggroservice = 64 -- versetzung zum Ball je gr�sser desto tiefer fliegt der Service 0-64 + + +function OnServe(ballready) + moveto(ballx()) -- unter den Ball stellen + wait = wait + 1 -- waittimer anwerfen + serv = true -- servflag setzen + if ballready then -- ball bereit + if wait > 90 then -- 90 einheiten gewartet + jump() -- Springen also eigentlich den Ball aufwerfen + wait = 0 -- Wait timer zur�cksetzen + end + end +end + + +function OnGame() + + -- bestimmen wenn der service vertig ist + if (ballx() > 400) then -- sobald der ball auf der anderen seite ist ;) + serv = false -- serv flag zur�cksetzen + end + + if serv then -- sprunganschlag code + moveto(estimate()-aggroservice) -- Bewegt sich unter den Ball und schl�gt mit einer gewissen aggressivit�t an bei 64 knapp �bers Netz + -- warscheinlich w�re ein Match.random() angebracht + if bally() < 550 then -- wenn der Ball wieder runter kommt + jump() + end + else + if (estimate() < 0) then -- Falls der Ball von Hinten kommt + moveto(math.abs(estimate())-100) -- funktioniert noch nicht richtig + else + moveto(estimate()-20) --sonst immer leicht hinter dem Ball bleiben + end + end +end diff -Nru blobby-0.8-dfsg/data/scripts/old/bert.ai blobby-0.9c/data/scripts/old/bert.ai --- blobby-0.8-dfsg/data/scripts/old/bert.ai 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/bert.ai 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,99 @@ +// Note: This still needs to be ported to lua + +var bsizx,bsizy,cpud1; + +function main() { + var i,alti,j,factor,direct, + touchcnt,x,y,delay,bx,by,vbx,vby; + + bsizx=64; + bsizy=64; + + j=side(); + factor=j*2-1; + + delay=0; + while (1) { + stop(); + stopjump(); + + bx=ballx(); + by=bally(); + vbx=bspeedx(); + vby=bspeedy(); + touchcnt=touches(); + x=posx(); + y=posy(); + + direct=1; + + i=estimate(200); + + if (i>-9000) { + alti=i; + + if (j==1) { + if (i>800-bsizx /2) { + i=1600-i-bsizx;direct=0; + } + if (i<405+bsizx /2) { + i=810+bsizx-i;direct=0; + } + if (i<500) { + if (touchcnt<2) { + i=i-bsizx /2; + } + } + } else { + if (i<0+bsizx /2) { + i=-i+bsizx; + direct=0; + } + if (i>395-bsizx /2) { + i=790-bsizx-i; + direct=0; + } + if (i>300) { + if (touchcnt<2) { + i=i+bsizx /2; + } + } + } + + i=i+(bsizx / 3)*factor; + + //if (i>=x+7) right(); + //if (i<=x-7) left(); + moveto(i); + } + stopjump(); + if(vby<=10) + if (factor*(x-bx)<21) + if (factor*(bx-x)<7) + if (abs(bx-x)<120) + if (abs(vby)<65) + if (by>200) + if (by-y>70) + if ((by<400) || (vby==0)) + if (abs(vbx)<20) + if (!balldown()) jump(); + if (random(300)==0) jump(); + if (i>-9000) { + if ((abs(i-x)>75) && (abs(bx-x)<65) && (vby<0) ) { + jump(); + } + } + if (touching()) { + stop(); + } + + if (!launched()) { + delay+=1; + stopjump(); + if (delay>=30) jump(); + } + + wait(); + } //while +} //function + diff -Nru blobby-0.8-dfsg/data/scripts/old/com_04c.lua blobby-0.9c/data/scripts/old/com_04c.lua --- blobby-0.8-dfsg/data/scripts/old/com_04c.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/com_04c.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,140 @@ +-- Flags und runners +wait = 0 +naechsterBallSchmettern = true -- evtl Variablennamen wechseln +angriffsstaerke = 50 -- versetzung zum Ball je grösser desto tiefer fliegt der Service 0-64( 64 ist ca CONST_BALLRADIUS + CONST_BLOBBY_BAUCH_RADIUS) +angriffsstaerkeNeuBerechnen =false -- neuberechnung von angriffsstaerke => Variable Angriffe + +-- Konstanten + +CONST_FELD_LAENGE = 800 +CONST_BALL_RADIUS = 31.5 +CONST_GROUND_PLANE = 100 + +CONST_MITTE = CONST_FELD_LAENGE/2 +CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS + + +CONST_BLOBBY_HOEHE = 89 +CONST_BLOBBY_KOPF_RADIUS = 25 +CONST_BLOBBY_BAUCH_RADIUS = 33 +CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS + +CONST_NETZ_RADIUS = 7 +CONST_NETZ_HOEHE = 157 + +-- Linke Berührungsebene des Balls falls er ans Netz kommt +CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS + + + +function OnOpponentServe() + moveto(120) + generatenaechsterBallSchmettern() -- der gegner soll den smash ja nicht vorhersagen können +end + +function OnServe(ballready) + moveto(ballx()) + wait = wait + 1 + naechsterBallSchmettern = true + if ballready then + if wait > 90 then + jump() + wait = 0 + end + end +end + +function OnGame() + naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht + target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG) + + if naechsterBallSchmettern then + sprungattacke(angriffsstaerke) + return + end + + -- nun kümmern wir uns um die Bälle die ans netz prallen + if ((target > CONST_NETZ_LINKS) and (ballx() < CONST_NETZ_LINKS)) then + netzappraller(target) + return + end + + moveto(target) + +end + + +function netzappraller(p_target) + moveto(CONST_NETZ_LINKS - (p_target - CONST_NETZ_LINKS) + math.abs(bspeedx()*bspeedx()*1.4)) +end + + + +function sprungattacke(p_angriffsstaerke) + moveto(ballx()-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben + if bally() < 580 then + jump() + end +end + +function naechsterBallSchmetternFlagTesten() + if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt + naechsterBallSchmettern = false + angriffsstaerkeNeuBerechnen = true -- da würde es sicher auch einen Inteligenteren Test geben. + return + end + + if (angriffsstaerkeNeuBerechnen == true) then + generatenaechsterBallSchmettern() + end + + + if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein + naechsterBallSchmettern = false + return + end + + if (touches() == 2) then -- nach der 2. Berührung angreifen + if (bally() > 500) then -- erst wenn der Ball hoeher als 500 fliegt sonst gibt es keinen schönen Schmetterball. + naechsterBallSchmettern = true + end + return + end + + if ((ballx() < (400-CONST_BALL_RADIUS)) and (bally() < 200) and (math.abs(bspeedx()) < 40)) then -- der ball könnte noch drüber fliegen ** noch optimieren + naechsterBallSchmettern = true + return + end +end + +function generatenaechsterBallSchmettern() + angriffsstaerkeNeuBerechnen = false; + angriffsstaerke = math.random(15,64) -- variiert mit der Angriffsstärke also auch mit den Anschlägen +end + +function estimImpact(bx,by,vbx,vby,destY) -- erlaubt ein besseres Estimate mit ein paar umbeding nötigen Angaben + bgrav = 0.28 + + time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) + resultX = (vbx * time1) + bx + + if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der Hinteren Ebene + resultX = math.abs(CONST_BALL_RADIUS - resultX) + CONST_BALL_RADIUS + end + + if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene + resultX = CONST_FELD_LAENGE - (resultX - CONST_FELD_LAENGE) + end + -- test +-- if(resultX > CONST_MITTE - CONST_BALL_RADIUS)then +-- resultX = -resultX +-- end + + return resultX +end + +function cleanMoveTo(position) -- eine nette Spielerei ;) + if (posx() ~= position) then + moveto(position) + end +end diff -Nru blobby-0.8-dfsg/data/scripts/old/com_04d.lua blobby-0.9c/data/scripts/old/com_04d.lua --- blobby-0.8-dfsg/data/scripts/old/com_04d.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/com_04d.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,139 @@ +-- Flags und runners +wait = 0 +naechsterBallSchmettern = true -- evtl Variablennamen wechseln +angriffsstaerke = 50 -- versetzung zum Ball je grösser desto tiefer fliegt der Service 0-64( 64 ist ca CONST_BALLRADIUS + CONST_BLOBBY_BAUCH_RADIUS) +angriffsstaerkeNeuBerechnen =false -- neuberechnung von angriffsstaerke => Variable Angriffe + +-- Konstanten + +CONST_FELD_LAENGE = 800 +CONST_BALL_RADIUS = 31.5 +CONST_GROUND_PLANE = 100 + +CONST_MITTE = CONST_FELD_LAENGE/2 +CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS + + +CONST_BLOBBY_HOEHE = 89 +CONST_BLOBBY_KOPF_RADIUS = 25 +CONST_BLOBBY_BAUCH_RADIUS = 33 +CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS + +CONST_NETZ_RADIUS = 7 +CONST_NETZ_HOEHE = 157 + +-- Linke Berührungsebene des Balls falls er ans Netz kommt +CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS + + + +function OnOpponentServe() + moveto(120) + generatenaechsterBallSchmettern() -- der gegner soll den smash ja nicht vorhersagen können +end + +function OnServe(ballready) + moveto(ballx()) + wait = wait + 1 + naechsterBallSchmettern = true + if ballready then + if wait > 90 then + jump() + wait = 0 + end + end +end + +function OnGame() + naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht + target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG) + + if target > 440 then + moveto(120) + else + if naechsterBallSchmettern then + sprungattacke(angriffsstaerke) + return + end + + -- nun kümmern wir uns um die Bälle die ans netz prallen + if ((target > CONST_NETZ_LINKS) and (ballx() < CONST_NETZ_LINKS)) then + netzappraller(target) + return + end + + moveto(target) + end +end + + +function netzappraller(p_target) + moveto(CONST_NETZ_LINKS - (p_target - CONST_NETZ_LINKS) + math.abs(bspeedx()*bspeedx()*1.4)) +end + + + +function sprungattacke(p_angriffsstaerke) + moveto(ballx()-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben + if bally() < 580 then + jump() + end +end + +function naechsterBallSchmetternFlagTesten() + if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt + naechsterBallSchmettern = false + angriffsstaerkeNeuBerechnen = true -- da würde es sicher auch einen Inteligenteren Test geben. + return + end + + if (angriffsstaerkeNeuBerechnen == true) then + generatenaechsterBallSchmettern() + end + + + if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein + naechsterBallSchmettern = false + return + end + + if (touches() == 2) then -- nach der 2. Berührung angreifen + if (bally() > 500) then -- erst wenn der Ball hoeher als 500 fliegt sonst gibt es keinen schönen Schmetterball. + naechsterBallSchmettern = true + end + return + end + + if ((ballx() < (400-CONST_BALL_RADIUS)) and (bally() < 200) and (math.abs(bspeedx()) < 40)) then -- der ball könnte noch drüber fliegen ** noch optimieren + naechsterBallSchmettern = true + return + end +end + +function generatenaechsterBallSchmettern() + angriffsstaerkeNeuBerechnen = false; + angriffsstaerke = math.random(20,55) -- variiert mit der Angriffsstärke also auch mit den Anschlägen +end + +function estimImpact(bx,by,vbx,vby,destY) -- erlaubt ein besseres Estimate mit ein paar umbeding nötigen Angaben + bgrav = 0.28 + + time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) + resultX = (vbx * time1) + bx + + if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der Hinteren Ebene + resultX = math.abs(CONST_BALL_RADIUS - resultX) + CONST_BALL_RADIUS + end + + if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene + resultX = CONST_FELD_LAENGE - (resultX - CONST_FELD_LAENGE) + end + + return resultX +end + +function cleanMoveTo(position) -- eine nette Spielerei ;) + if (posx() ~= position) then + moveto(position) + end +end diff -Nru blobby-0.8-dfsg/data/scripts/old/com_10B2ex.lua blobby-0.9c/data/scripts/old/com_10B2ex.lua --- blobby-0.8-dfsg/data/scripts/old/com_10B2ex.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/com_10B2ex.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,146 @@ +-- Com 1.0 extrem Beta 2 Schmetter-Mod +-- by Oreon, Axji & Enormator +-- Name: com_10eB2_Schmettermod + +-- Flags und runners +wait = 0 +naechsterBallSchmettern = true -- evtl Variablennamen wechseln + + +-- Weltkonstanten + +CONST_FELD_LAENGE = 800 +CONST_BALL_RADIUS = 31.5 +CONST_GROUND_PLANE = 100 + +CONST_BALL_GRAVITY = 0.28 + +CONST_MITTE = CONST_FELD_LAENGE/2 +CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS + +CONST_BLOBBY_HOEHE = 89 +CONST_BLOBBY_KOPF_RADIUS = 25 +CONST_BLOBBY_BAUCH_RADIUS = 33 +CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS +CONST_BLOBBY_MAXJUMP = 393.625 + +CONST_NETZ_RADIUS = 7 +CONST_NETZ_HOEHE = 323 + +-- Ber�hrungsebene des Balls falls er ans Netz kommt +CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS +CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS + +-- Charakter +CONST_ANGRIFFSGRUNDWERT_MIN = 30 +CONST_ANGRIFFSGRUNDWERT_MAX = 55 +MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN +MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX +ANGRIFFSEINSCHRAENKUNG_HINTEN = 10 + +-- sonstige Einstellungen +servexVersetzung=-7 --Wert ist so gewaehlt, dass der Ball nah ans Netz fliegt, der Gegner ihn aber grade nicht erreichen kann + +-- ***ANFANG*** + +function OnOpponentServe() + moveto(130) +end + +function OnServe(ballready) + servex=ballx()+servexVersetzung + naechsterBallSchmettern = true + generatenaechsterBallSchmettern() + moveto(servex) + if ballready and (servex-2 < posx()) and (posx() < servex+2) then + jump() + end +end + +function OnGame() + target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) --X Ziel in Blobbyhoehe + targets = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,2) --X Richtung (-1 oder 1) bei Einschlag + targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE,1) --X Ziel in Netzhoehe (Netzrollerberechnung) + targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,1) --X Ziel in Schmetterhoehe + naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht + + if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann + generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen + end + + if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht + moveto(135) --Dann auf Standartposition warten + else + if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern + naechsterBallSchmettern = true + end + + if naechsterBallSchmettern then + if ((math.abs(bspeedx()) < 4) or (estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,2) < 0)) then + sprungattacke(angriffsstaerke) + else + if (targetJump < CONST_MITTE / 2) then + sprungattacke(-35) --an Rueckwand spielen + else + sprungattacke(0) --weiterleiten + end + end + return + end + + moveto(target) + end +end + + +function sprungattacke(p_angriffsstaerke) + p_angriffsstaerke=math.max(p_angriffsstaerke, MIN_ANGRIFFSSTAERKE + ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so hoch spielen (kommt nicht auf die andere Seite) + p_angriffsstaerke=math.min(p_angriffsstaerke, MAX_ANGRIFFSSTAERKE - ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so tief spielen (kommt ans Netz) + + moveto(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die St�rke des gew�nschten schlages angegeben + + if (bally() < 580) and (bspeedy() < 0) then + jump() + end +end + +function naechsterBallSchmetternFlagTesten() + naechsterBallSchmettern = true +end + +function generatenaechsterBallSchmettern() + angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) +end + +function estimImpact(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding n�tigen Angaben + bgrav = 0.28 + + time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) + resultX = (vbx * time1) + bx + estimbspeedx=bspeedx()/math.abs(bspeedx()) + + if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene + resultX = 2 * CONST_FELD_LAENGE - resultX + estimbspeedx=-estimbspeedx + end + + if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene + resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS + estimbspeedx=-estimbspeedx + KollisionLinks = true + else + KollisionLinks = false + end + + if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind + resultX = 2 * CONST_NETZ_LINKS - resultX + estimbspeedx=-estimbspeedx + end + + if (Frage == 1) then + return resultX + end + if (Frage == 2) then + return estimbspeedx + end +end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/old/com_10eB1.lua blobby-0.9c/data/scripts/old/com_10eB1.lua --- blobby-0.8-dfsg/data/scripts/old/com_10eB1.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/com_10eB1.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,162 @@ +-- Com 1.0 human Beta 1 +-- by Oreon, Axji & Enormator + +-- Flags und runners +wait = 0 +naechsterBallSchmettern = true -- evtl Variablennamen wechseln + + +-- Weltkonstanten + +CONST_FELD_LAENGE = 800 +CONST_BALL_RADIUS = 31.5 +CONST_GROUND_PLANE = 100 + +CONST_BALL_GRAVITY = 0.28 + +CONST_MITTE = CONST_FELD_LAENGE/2 +CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS + +CONST_BLOBBY_HOEHE = 89 +CONST_BLOBBY_KOPF_RADIUS = 25 +CONST_BLOBBY_BAUCH_RADIUS = 33 +CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS +CONST_BLOBBY_MAXJUMP = 393.625 + +CONST_NETZ_RADIUS = 7 +CONST_NETZ_HOEHE = 323 + +-- Berührungsebene des Balls falls er ans Netz kommt +CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS +CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS + +-- Charakter +CONST_ANGRIFFSGRUNDWERT_MIN = 30 +CONST_ANGRIFFSGRUNDWERT_MAX = 55 +MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN +MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX + + +-- ***ANFANG*** + +function OnOpponentServe() + moveto(130) +end + +function OnServe(ballready) + naechsterBallSchmettern = true + generatenaechsterBallSchmettern() + moveto(ballx()) + if ballready and (ballx()-3 < posx()) and (posx() < ballx()+3) then + jump() + end +end + +function OnGame() + naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht + target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) --X Ziel in Blobbyhoehe + targets = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,2) --X Richtung (-1 oder 1) bei Einschlag + targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE,1) --X Ziel in Netzhoehe (Netzrollerberechnung) + targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,1) --X Ziel in Schmetterhoehe + + if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann + generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen + end + + if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht + moveto(135) --Dann auf Standartposition warten + else + if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern + naechsterBallSchmettern = true + end + + if naechsterBallSchmettern then + if ((math.abs(bspeedx()) < 4) or (bspeedx() < 0)) then + sprungattacke(angriffsstaerke) + else + if (targetJump < CONST_MITTE / 2) then + sprungattacke(-30) --an Rueckwand spielen + else + sprungattacke(0) --weiterleiten + end + end + return + end + + moveto(target) + end +end + + +function sprungattacke(p_angriffsstaerke) + if (bally() < 550) and (math.abs(ballx() - posx()) > 200) then -- Falls nicht schmetterbar + moveto (target - 25) --Dann Notloesung versuchen + return + end + + moveto(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben + + if (bally() < 580) and (bspeedy() < 0) then + jump() + end +end + +function naechsterBallSchmetternFlagTesten() + if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt + naechsterBallSchmettern = false + return + end + + if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein + naechsterBallSchmettern = false + return + end + + if (touches() == 1) and (math.abs(bspeedx()) < 2) then -- schon nach der 1ten Beruehrung angreifen wenn der Ball gut kommt + naechsterBallSchmettern = true + return + end + + if (touches() == 2) then -- nach der 2. Berührung angreifen + naechsterBallSchmettern = true + return + end + naechsterBallSchmettern = false +end + +function generatenaechsterBallSchmettern() + angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) +end + +function estimImpact(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding nötigen Angaben + bgrav = 0.28 + + time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) + resultX = (vbx * time1) + bx + estimbspeedx=bspeedx()/math.abs(bspeedx()) + + if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene + resultX = 2 * CONST_FELD_LAENGE - resultX + estimbspeedx=-estimbspeedx + end + + if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene + resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS + estimbspeedx=-estimbspeedx + KollisionLinks = true + else + KollisionLinks = false + end + + if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind + resultX = 2 * CONST_NETZ_LINKS - resultX + estimbspeedx=-estimbspeedx + end + + if (Frage == 1) then + return resultX + end + if (Frage == 2) then + return estimbspeedx + end +end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/old/com_10eB2.lua blobby-0.9c/data/scripts/old/com_10eB2.lua --- blobby-0.8-dfsg/data/scripts/old/com_10eB2.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/com_10eB2.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,164 @@ +-- Com 1.0 extrem Beta 2 +-- by Oreon, Axji & Enormator + +-- Flags und runners +wait = 0 +naechsterBallSchmettern = true -- evtl Variablennamen wechseln + + +-- Weltkonstanten + +CONST_FELD_LAENGE = 800 +CONST_BALL_RADIUS = 31.5 +CONST_GROUND_PLANE = 100 + +CONST_BALL_GRAVITY = 0.28 + +CONST_MITTE = CONST_FELD_LAENGE/2 +CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS + +CONST_BLOBBY_HOEHE = 89 +CONST_BLOBBY_KOPF_RADIUS = 25 +CONST_BLOBBY_BAUCH_RADIUS = 33 +CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS +CONST_BLOBBY_MAXJUMP = 393.625 + +CONST_NETZ_RADIUS = 7 +CONST_NETZ_HOEHE = 323 + +-- Berührungsebene des Balls falls er ans Netz kommt +CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS +CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS + +-- Charakter +CONST_ANGRIFFSGRUNDWERT_MIN = 30 +CONST_ANGRIFFSGRUNDWERT_MAX = 55 +MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN +MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX +ANGRIFFSEINSCHRAENKUNG_HINTEN = 10 + +-- sonstige Einstellungen +servexVersetzung=-7 --Wert ist so gewaehlt, dass der Ball nah ans Netz fliegt, der Gegner ihn aber grade nicht erreichen kann + +-- ***ANFANG*** + +function OnOpponentServe() + moveto(130) +end + +function OnServe(ballready) + servex=ballx()+servexVersetzung + naechsterBallSchmettern = true + generatenaechsterBallSchmettern() + moveto(servex) + if ballready and (servex-2 < posx()) and (posx() < servex+2) then + jump() + end +end + +function OnGame() + target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) --X Ziel in Blobbyhoehe + targets = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,2) --X Richtung (-1 oder 1) bei Einschlag + targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE,1) --X Ziel in Netzhoehe (Netzrollerberechnung) + targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,1) --X Ziel in Schmetterhoehe + naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht + + if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann + generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen + end + + if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht + moveto(135) --Dann auf Standartposition warten + else + if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern + naechsterBallSchmettern = true + end + + if naechsterBallSchmettern then + if ((math.abs(bspeedx()) < 4) or (estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,2) < 0)) then + sprungattacke(angriffsstaerke) + else + if (targetJump < CONST_MITTE / 2) then + sprungattacke(-35) --an Rueckwand spielen + else + sprungattacke(0) --weiterleiten + end + end + return + end + + moveto(target) + end +end + + +function sprungattacke(p_angriffsstaerke) + p_angriffsstaerke=math.max(p_angriffsstaerke, MIN_ANGRIFFSSTAERKE + ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so hoch spielen (kommt nicht auf die andere Seite) + p_angriffsstaerke=math.min(p_angriffsstaerke, MAX_ANGRIFFSSTAERKE - ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so tief spielen (kommt ans Netz) + + moveto(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben + + if (bally() < 580) and (bspeedy() < 0) then + jump() + end +end + +function naechsterBallSchmetternFlagTesten() + if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt + naechsterBallSchmettern = false + return + end + + if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein + naechsterBallSchmettern = false + return + end + + if (touches() == 1) and (math.abs(bspeedx()) < 2) then -- schon nach der 1ten Beruehrung angreifen wenn der Ball gut kommt + naechsterBallSchmettern = true + return + end + + if (touches() == 2) then -- nach der 2. Berührung angreifen + naechsterBallSchmettern = true + return + end + naechsterBallSchmettern = false +end + +function generatenaechsterBallSchmettern() + angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) +end + +function estimImpact(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding nötigen Angaben + bgrav = 0.28 + + time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) + resultX = (vbx * time1) + bx + estimbspeedx=bspeedx()/math.abs(bspeedx()) + + if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene + resultX = 2 * CONST_FELD_LAENGE - resultX + estimbspeedx=-estimbspeedx + end + + if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene + resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS + estimbspeedx=-estimbspeedx + KollisionLinks = true + else + KollisionLinks = false + end + + if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind + resultX = 2 * CONST_NETZ_LINKS - resultX + estimbspeedx=-estimbspeedx + end + + if (Frage == 1) then + return resultX + end + if (Frage == 2) then + return estimbspeedx + end +end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/old/com_10hB1.lua blobby-0.9c/data/scripts/old/com_10hB1.lua --- blobby-0.8-dfsg/data/scripts/old/com_10hB1.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/com_10hB1.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,210 @@ +-- Com 1.0 human Beta 1 +-- by Oreon, Axji & Enormator + +-- Flags und runners +wait = 0 +naechsterBallSchmettern = true -- evtl Variablennamen wechseln +quatschFlag = 0 +mood = math.random(1,3)+3 --Startlaune zwischen 4 und 6 + + +-- Weltkonstanten + +CONST_FELD_LAENGE = 800 +CONST_BALL_RADIUS = 31.5 +CONST_GROUND_PLANE = 100 + +CONST_BALL_GRAVITY = 0.28 + +CONST_MITTE = CONST_FELD_LAENGE/2 +CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS + +CONST_BLOBBY_HOEHE = 89 +CONST_BLOBBY_KOPF_RADIUS = 25 +CONST_BLOBBY_BAUCH_RADIUS = 33 +CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS +CONST_BLOBBY_MAXJUMP = 393.625 + +CONST_NETZ_RADIUS = 7 +CONST_NETZ_HOEHE = 323 + +-- Berührungsebene des Balls falls er ans Netz kommt +CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS +CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS + +-- Charakter +CONST_MIN_MOOD = 0 +CONST_MAX_MOOD = 10 + +CONST_ANGRIFFSGRUNDWERT_MIN = 35 +CONST_ANGRIFFSGRUNDWERT_MAX = 60 +MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN-mood +MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX-mood + +CONST_GEDULD = 0.01 --weniger ist mehr Geduld + +-- ***ANFANG*** + +function OnOpponentServe() + BallLinks=false + if (LauneBerechnet == false) then + mood=mood-1 --schlechter gelaunt + LauneBerechnen () --anwenden auf Angriffswert + LauneBerechnet = true + end + moveto(130) +end + +function OnServe(ballready) + BallLinks=true + if (LauneBerechnet == false) then + mood=mood+1 --besser gelaunt + LauneBerechnen () --anwenden auf Angriffswert + LauneBerechnet = true + end + naechsterBallSchmettern = true + generatenaechsterBallSchmettern() + + if (quatschFlag == 0) then + quatschFlag = math.random(5,10) + end + if (mood > quatschFlag) then --je besser gelaunt, desto wahrscheinlicher Quatsch + quatschFlag = enormerQuatsch() + else + moveto(ballx()) + if ballready and (ballx()-3 < posx()) and (posx() < ballx()+3) then + jump() + end + end +end + +function OnGame() + debug (mood) + if (BallLinks == (ballx() > CONST_MITTE)) then --Bei jedem Ballwechsel + mood = mood - CONST_GEDULD --um CONST_GEDULD schlechter gelaunt sein + LauneBerechnen () + BallLinks = (ballx() < CONST_MITTE) + end + LauneBerechnet=false --Flag setzen für Berechnung beim Aufschlag + quatschFlag=0 --Flag setzen für Berechnung beim Aufschlag + los=false --Flag setzen für Berechnung beim Aufschlag + naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht + target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG) --X Ziel in Blobbyhoehe + targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE) --X Ziel in Netzhoehe (Netzrollerberechnung) + targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP) --X Ziel in Schmetterhoehe + + if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann + generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen + end + + if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht + moveto(135) --Dann auf Standartposition warten + else + if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern + naechsterBallSchmettern = true + end + + if naechsterBallSchmettern then + sprungattacke(angriffsstaerke) + return + end + + moveto(target) + end +end + + +function sprungattacke(p_angriffsstaerke) + if (bally() < 550) and (math.abs(ballx() - posx()) > 200) then -- Falls nicht schmetterbar + moveto (target - 25) --Dann Notloesung versuchen + return + end + if ((bally() < 600) and (bspeedy() < 0)) or (math.abs(bspeedx()) > 2) or (math.abs(targetJump-posx()) > 40) then -- erst im letzten Moment bewegen -> unvorhersehbar + moveto(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben + end + if (bally() < 580) and (bspeedy() < 0) then + jump() + end +end + +function naechsterBallSchmetternFlagTesten() + if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt + naechsterBallSchmettern = false + return + end + + if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein + naechsterBallSchmettern = false + return + end + + if (touches() == 1) and (math.abs(bspeedx()) < 2) and (mood < CONST_MAX_MOOD) then -- schon nach der 1ten Beruehrung angreifen wenn der Ball gut kommt und er nicht zu gut gelaunt ist + naechsterBallSchmettern = true + return + end + + if (touches() == 2) then -- nach der 2. Berührung angreifen + naechsterBallSchmettern = true + return + end + naechsterBallSchmettern = false +end + +function generatenaechsterBallSchmettern() + angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) -- variiert mit der Laune +end + +function estimImpact(bx,by,vbx,vby,destY) -- erlaubt ein besseres Estimate mit ein paar umbeding nötigen Angaben + bgrav = 0.28 + + time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) + resultX = (vbx * time1) + bx + estimbspeedx=bspeedx() + + if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene + resultX = 2 * CONST_FELD_LAENGE - resultX + estimbspeedx=-estimbspeedx + end + + if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene + resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS + estimbspeedx=-estimbspeedx + KollisionLinks = true + else + KollisionLinks = false + end + + if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind + resultX = 2 * CONST_NETZ_LINKS - resultX + estimbspeedx=-estimbspeedx + end + return resultX +end + +function enormerQuatsch() + if los then + left() + jump() + else + right() + end + if (posx() > 350) then + los=true + end + if (posx() < 60) then + los=false + return CONST_MAX_MOOD + 1 -- MaxLaune+1 kann nie erreicht werden -> stop + end + return quatschFlag -- Wenn nicht fertig, dann nix aendern +end + +function LauneBerechnen () + if (mood < CONST_MIN_MOOD) then + mood = 0 + end + if (mood > CONST_MAX_MOOD) then + mood = 10 + end + MIN_ANGRIFFSSTAERKE=CONST_ANGRIFFSGRUNDWERT_MIN-mood + MAX_ANGRIFFSSTAERKE=CONST_ANGRIFFSGRUNDWERT_MAX-mood +end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/old/com_10.lua blobby-0.9c/data/scripts/old/com_10.lua --- blobby-0.8-dfsg/data/scripts/old/com_10.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/com_10.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,178 @@ +-- Combot 1.0 +-- by Oreon, Axji & Enormator + +-- Flags und runners +wait = 0 +naechsterBallSchmettern = true -- evtl Variablennamen wechseln + + +-- Weltkonstanten + +CONST_FELD_LAENGE = 800 +CONST_BALL_RADIUS = 31.5 +CONST_GROUND_PLANE = 100 + +CONST_BALL_GRAVITY = 0.28 + +CONST_MITTE = CONST_FELD_LAENGE/2 +CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS + +CONST_BLOBBY_HOEHE = 89 +CONST_BLOBBY_KOPF_RADIUS = 25 +CONST_BLOBBY_BAUCH_RADIUS = 33 +CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS +CONST_BLOBBY_MAXJUMP = 393.625 + +CONST_NETZ_RADIUS = 7 +CONST_NETZ_HOEHE = 323 + +-- Berührungsebene des Balls falls er ans Netz kommt +CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS +CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS + +-- Charakter +CONST_ANGRIFFSGRUNDWERT_MIN = 30 +CONST_ANGRIFFSGRUNDWERT_MAX = 55 +MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN +MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX +ANGRIFFSEINSCHRAENKUNG_HINTEN = 10 + +-- sonstige Einstellungen +servexVersetzung=-7 --Wert ist so gewaehlt, dass der Ball nah ans Netz fliegt, der Gegner ihn aber grade nicht erreichen kann + +-- ***ANFANG*** + +function OnOpponentServe() + movetoX(130) +end + +function OnServe(ballready) + servex=ballx()+servexVersetzung + naechsterBallSchmettern = true + generatenaechsterBallSchmettern() + if ballready and movetoX(servex) then + jump() + end +end + +function OnGame() + target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) --X Ziel in Blobbyhoehe + targets = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,2) --X Richtung (-1 oder 1) bei Einschlag + targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE,1) --X Ziel in Netzhoehe (Netzrollerberechnung) + targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,1) --X Ziel in Schmetterhoehe + naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht + + if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann + generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen + end + + if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht + movetoX(135) --Dann auf Standartposition warten + else + if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern + naechsterBallSchmettern = true + end + + if naechsterBallSchmettern then + if ((math.abs(bspeedx()) < 4) or (estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,2) < 0)) then + sprungattacke(angriffsstaerke) + else + if (targetJump < CONST_MITTE / 2) then + sprungattacke(-35) --an Rueckwand spielen + else + sprungattacke(0) --weiterleiten + end + end + return + end + + movetoX(target) + end +end + + +function sprungattacke(p_angriffsstaerke) + p_angriffsstaerke=math.max(p_angriffsstaerke, MIN_ANGRIFFSSTAERKE + ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so hoch spielen (kommt nicht auf die andere Seite) + p_angriffsstaerke=math.min(p_angriffsstaerke, MAX_ANGRIFFSSTAERKE - ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so tief spielen (kommt ans Netz) + + movetoX(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben + + if (bally() < 580) and (bspeedy() < 0) then + jump() + end +end + +function naechsterBallSchmetternFlagTesten() + if (touches() == 3) then -- falls der Bot einen Anschlag Findet der Direckt punktet so wird der Wer nicht neu berechnet da er dann nciht auf 3 Berührungen kommt + naechsterBallSchmettern = false + return + end + + if (ballx() > CONST_MITTE) then -- wenn der ball auf der Anderen Seite ist soll der bot nicht naechsterBallSchmettern sein + naechsterBallSchmettern = false + return + end + + if (touches() == 1) and (math.abs(bspeedx()) < 2) then -- schon nach der 1ten Beruehrung angreifen wenn der Ball gut kommt + naechsterBallSchmettern = true + return + end + + if (touches() == 2) then -- nach der 2. Berührung angreifen + naechsterBallSchmettern = true + return + end + naechsterBallSchmettern = false +end + +function generatenaechsterBallSchmettern() + angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) +end + +function estimImpact(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding nötigen Angaben + bgrav = 0.28 + + time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) + resultX = (vbx * time1) + bx + estimbspeedx=bspeedx()/math.abs(bspeedx()) + + if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene + resultX = 2 * CONST_FELD_LAENGE - resultX + estimbspeedx=-estimbspeedx + end + + if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene + resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS + estimbspeedx=-estimbspeedx + KollisionLinks = true + else + KollisionLinks = false + end + + if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind + resultX = 2 * CONST_NETZ_LINKS - resultX + estimbspeedx=-estimbspeedx + end + + if (Frage == 1) then + return resultX + end + if (Frage == 2) then + return estimbspeedx + end +end + +function movetoX (x) + if (math.abs(posx()-x)>math.abs(posx()+4.5-x)) then + right() + done=false + else + if (math.abs(posx()-x)>math.abs(posx()-4.5-x)) then + left() + done=false + else + done=true + end + end + return done +end diff -Nru blobby-0.8-dfsg/data/scripts/old/com_10Schm.lua blobby-0.9c/data/scripts/old/com_10Schm.lua --- blobby-0.8-dfsg/data/scripts/old/com_10Schm.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/com_10Schm.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,160 @@ +-- Combot 1.0 - Schmettermod +-- by Oreon, Axji & Enormator + +-- Flags und runners +wait = 0 +naechsterBallSchmettern = true -- evtl Variablennamen wechseln + + +-- Weltkonstanten + +CONST_FELD_LAENGE = 800 +CONST_BALL_RADIUS = 31.5 +CONST_GROUND_PLANE = 100 + +CONST_BALL_GRAVITY = 0.28 + +CONST_MITTE = CONST_FELD_LAENGE/2 +CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS + +CONST_BLOBBY_HOEHE = 89 +CONST_BLOBBY_KOPF_RADIUS = 25 +CONST_BLOBBY_BAUCH_RADIUS = 33 +CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS +CONST_BLOBBY_MAXJUMP = 393.625 + +CONST_NETZ_RADIUS = 7 +CONST_NETZ_HOEHE = 323 + +-- Berührungsebene des Balls falls er ans Netz kommt +CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS +CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS + +-- Charakter +CONST_ANGRIFFSGRUNDWERT_MIN = 30 +CONST_ANGRIFFSGRUNDWERT_MAX = 55 +MIN_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MIN +MAX_ANGRIFFSSTAERKE = CONST_ANGRIFFSGRUNDWERT_MAX +ANGRIFFSEINSCHRAENKUNG_HINTEN = 10 + +-- sonstige Einstellungen +servexVersetzung=-7 --Wert ist so gewaehlt, dass der Ball nah ans Netz fliegt, der Gegner ihn aber grade nicht erreichen kann + +-- ***ANFANG*** + +function OnOpponentServe() + movetoX(130) +end + +function OnServe(ballready) + servex=ballx()+servexVersetzung + naechsterBallSchmettern = true + generatenaechsterBallSchmettern() + if ballready and movetoX(servex) then + jump() + end +end + +function OnGame() + target = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) --X Ziel in Blobbyhoehe + targets = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,2) --X Richtung (-1 oder 1) bei Einschlag + targetNetz = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_NETZ_HOEHE,1) --X Ziel in Netzhoehe (Netzrollerberechnung) + targetJump = estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,1) --X Ziel in Schmetterhoehe + naechsterBallSchmetternFlagTesten() -- schaut ob der bot angreifen soll oder nicht + + if (ballx() > CONST_NETZ_RECHTS) then --Wenn Ball auf rechter Spielfeldseite dann + generatenaechsterBallSchmettern() --Angriffsstaerke neu berechnen + end + + if (target > CONST_MITTE) and (ballx() > CONST_NETZ_RECHTS) then --Wenn der Ball mich nix angeht + movetoX(135) --Dann auf Standartposition warten + else + if (targetNetz > CONST_NETZ_LINKS - 10) then --Bei Netzroller einfach schmettern + naechsterBallSchmettern = true + end + + if naechsterBallSchmettern then + if ((math.abs(bspeedx()) < 4) or (estimImpact(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP,2) < 0)) then + sprungattacke(angriffsstaerke) + else + if (targetJump < CONST_MITTE / 2) then + sprungattacke(-35) --an Rueckwand spielen + else + sprungattacke(0) --weiterleiten + end + end + return + end + + movetoX(target) + end +end + + +function sprungattacke(p_angriffsstaerke) + p_angriffsstaerke=math.max(p_angriffsstaerke, MIN_ANGRIFFSSTAERKE + ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so hoch spielen (kommt nicht auf die andere Seite) + p_angriffsstaerke=math.min(p_angriffsstaerke, MAX_ANGRIFFSSTAERKE - ANGRIFFSEINSCHRAENKUNG_HINTEN * (targetJump / CONST_NETZ_LINKS)) --Weiter hinten nicht ganz so tief spielen (kommt ans Netz) + + movetoX(targetJump-p_angriffsstaerke) -- Bei der Sprungatacke wird die Stärke des gewünschten schlages angegeben + + if (bally() < 580) and (bspeedy() < 0) then + jump() + end +end + +function naechsterBallSchmetternFlagTesten() + naechsterBallSchmettern = true +end + +function generatenaechsterBallSchmettern() + angriffsstaerke = math.random(MIN_ANGRIFFSSTAERKE,MAX_ANGRIFFSSTAERKE) +end + +function estimImpact(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding nötigen Angaben + bgrav = 0.28 + + time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) + resultX = (vbx * time1) + bx + estimbspeedx=bspeedx()/math.abs(bspeedx()) + + if(resultX > CONST_RECHTER_RAND) then -- Korrigieren der Appraller an der Rechten Ebene + resultX = 2 * CONST_FELD_LAENGE - resultX + estimbspeedx=-estimbspeedx + end + + if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene + resultX = math.abs(resultX - CONST_BALL_RADIUS) + CONST_BALL_RADIUS + estimbspeedx=-estimbspeedx + KollisionLinks = true + else + KollisionLinks = false + end + + if (resultX > CONST_NETZ_RECHTS) and (estimbspeedx > 0) and ((KollisionLinks == true) or (ballx() < CONST_NETZ_LINKS)) then -- Abpraller am Netz unterhalb der Kugel erst wenn Netzroller ausgeschlossen sind + resultX = 2 * CONST_NETZ_LINKS - resultX + estimbspeedx=-estimbspeedx + end + + if (Frage == 1) then + return resultX + end + if (Frage == 2) then + return estimbspeedx + end +end + +function movetoX (x) + if (math.abs(posx()-x)>math.abs(posx()+4.5-x)) then + right() + done=false + else + if (math.abs(posx()-x)>math.abs(posx()-4.5-x)) then + left() + done=false + else + done=true + end + end + return done +end + diff -Nru blobby-0.8-dfsg/data/scripts/old/gintonicV6.lua blobby-0.9c/data/scripts/old/gintonicV6.lua --- blobby-0.8-dfsg/data/scripts/old/gintonicV6.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/gintonicV6.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,230 @@ +--Gin Tonic v6 - No Comments, sorry :P + +CT_ServeSelf = { 152, 163, 180, 195, 205, 240 } +CT_ServeOpp = { 140, 200, 240 } +CT_ServeIndex = 0 +CT_Tolerance = 5 +CT_Action = "" +CT_ShotDecision = 0 +CT_NextGround = 9999 +CT_LastTouches = 0 +CT_LastHeight = 0 + +CT_WaitCounter = 0 +CT_WaitName = "" +CT_WaitMoveTo = 0 + +function IsAt(position) + return (math.abs(posx()-position) <= CT_Tolerance) +end + +function Wait(name, time, moveto) + if (CT_WaitName == name) then + if (CT_WaitCounter == 0) then + return false + end + end + CT_WaitCounter = time + CT_WaitName = name + CT_WaitMoveTo = moveto + return true +end + +function WaitQueue() + if (CT_WaitCounter > 0) then + CT_WaitCounter = CT_WaitCounter - 1 + if (CT_WaitMoveTo > 0) then + if (not IsAt(CT_WaitMoveTo)) then moveto(CT_WaitMoveTo) end + end + return true + else + return false + end +end + +function ResetWait() + CT_WaitCounter = 0 + CT_WaitName = "" +end + +function OnOpponentServe() + if (CT_ServeIndex == 0) then + CT_ServeIndex = math.random(1,3) + end + if (not IsAt(CT_ServeOpp[CT_ServeIndex])) then moveto(CT_ServeOpp[CT_ServeIndex]) end +end + +function OnServe(ballready) + if (WaitQueue()) then return end + if (CT_ServeIndex == 0) then + CT_ServeIndex = math.random(1,6) + end + if (ballready) then + if (Wait("ServeDelay",math.random(28,90),CT_ServeSelf[CT_ServeIndex]+math.random(-150, 150))) then return end + if (IsAt(CT_ServeSelf[CT_ServeIndex])) then + jump() + else + moveto(CT_ServeSelf[CT_ServeIndex]) + end + else + if (posx() < 150) then + jump() + end + moveto(40) + end +end + +function OnGame() + ResetWait() + CT_ServeIndex = 0 + + local timeJump = timeToHitHeight(380, 390, 20) + local timeGround = timeToHitHeight(200, 222, 40) + local timeBlock = timeToOppSmash(390) + local estimhx = r_estimx(timeJump) + local estimGround = r_estimx(timeGround) + local estimBlock = r_estimx(timeBlock) + local block = 0 + local wallcoll = willHitWall(time) + if (timeBlock ~= -1) then block = timeBlock+(estimBlock-400)/13 end + if (timeBlock == -1) then timeBlock = 9999 end + if (timeJump == -1) then estimhx = 9999 end + if (timeGround == -1) then estimGround = 210 end + + if (posy() < CT_LastHeight and posy() > 150 and posy() < 330) then CT_Action = "" end + CT_LastHeight = posy() + + if (CT_Action == "NetBlock") then + if ((posy() < 150) or (timeBlock < 4 and oppy() < 150) or (ballx() <= posx()) or (touches() <= 0 and bspeedx() > 10)) then + CT_Action = "" + else + jump() + moveto(400) + return + end + elseif (CT_Action == "JumpPlayFwd") then + if (posy() < 150) then + CT_Action = "" + else + if (estimhx == 9999) then estimhx = ballx()+bspeedx() end + jump() + if (posy() > 300) then + if (math.abs(bally()-posy()) < 18) then + moveto(ballx()+bspeedx()) + elseif (estimhx < 200) then + if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(3,5) end + moveto(estimhx-10*CT_ShotDecision) + elseif (oppx() > 600 and oppy() < 150) then + if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,6) end + moveto(estimhx-10*CT_ShotDecision) + elseif (oppx() < 600 and oppy() > 180) then + moveto(estimhx-40) + else + moveto(estimhx-60) + end + else + moveto(estimhx-60) + end + return + end + elseif (CT_Action == "JumpPlayRev") then + if (posy() < 150) then + CT_Action = "" + else + if (estimhx == 9999) then estimhx = ballx()+bspeedx() end + jump() + if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,9) end + moveto(estimhx+5*CT_ShotDecision) + return + end + end + + if (touches() ~= CT_LastTouches) then + CT_LastTouches = touches() + CT_NextGround = math.random(-20,20) + end + + if (CT_Action == "") then + if ((ballx() < 400 or bspeedx() < -2) and estimGround < 400) then + if (touches() >= 2) then + moveto(estimGround+(posx()-500)/22) + elseif (math.abs(bspeedx()) > 8) then + moveto(estimGround) + else + moveto(estimGround+CT_NextGround) + end + elseif (estimhx < 600 and math.abs(bspeedx()) < 6) then + moveto(280) + elseif (estimhx > 650) then + moveto(250) + else + moveto(190) + end + end + + if (posy() > 150) then return end + + if (timeBlock >= 17 and timeBlock <= 19) then + if (posx() > 210 and estimBlock > 395 and estimBlock < 640) then + jump() + moveto(400) + CT_Action = "NetBlock" + return + end + end + if (timeJump >= 17 and timeJump <= 19) then + if (bspeedx() <= 7 and estimhx >= 65 and estimhx <= 420 and posx()-estimhx <= 120 and (bspeedx() >= -7 or (not wallcoll))) then + if (estimGround > 400 or bally() > 250) then + CT_Action = "JumpPlayFwd" + CT_ShotDecision = 0 + jump() + end + end + if ((wallcoll or bspeedx() >= -7) and estimhx <= 250 and posx()-estimhx <= 180 and posx()-estimhx >= -120) then + if (estimGround > 400 or bally() > 250) then + if (CT_Action == "JumpPlayFwd" and (touches() >= 2 or math.random(100) > 15)) then return end + CT_Action = "JumpPlayRev" + CT_ShotDecision = 0 + jump() + end + end + end +end + + +function timeToHitHeight(minheight, maxheight, depth) + local i = 0 + for i=1, depth do + if (estimy(i) >= minheight and estimy(i) <= maxheight and estimx(i) <= 420) then + return i + end + end + return -1 +end + +function timeToOppSmash(height) + if (bally() < height) then return -1 end + local i = 0 + for i=1, 17 do + if (estimy(i) < height) then + return i + end + end + return -1 +end + +function r_estimx(time) + local estim = estimx(time) + if estim < 31.5 then estim = 63-estim end + if estim > 768.5 then estim = 1537-estim end + if (bally() < 330) then + if (ballx() < 400 and estim > 400) then estim = 723-estim end + if (ballx() > 400 and estim < 400) then estim = 877-estim end + end + return estim +end + +function willHitWall(time) + if (estimx(time) < 31.5) then return true end + return false +end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/old/gintonicV7.lua blobby-0.9c/data/scripts/old/gintonicV7.lua --- blobby-0.8-dfsg/data/scripts/old/gintonicV7.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/gintonicV7.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,231 @@ +--Gin Tonic v7 - No Comments, sorry :P + +CT_ServeSelf = { 152, 163, 180, 195, 205, 240 } +CT_ServeOpp = { 140, 200, 240 } +CT_ServeIndex = 0 +CT_Tolerance = 5 +CT_Action = "" +CT_ShotDecision = 0 +CT_NextGround = 9999 +CT_LastTouches = 0 +CT_LastHeight = 0 + +CT_WaitCounter = 0 +CT_WaitName = "" +CT_WaitMoveTo = 0 + +function IsAt(position) + return (math.abs(posx()-position) <= CT_Tolerance) +end + +function Wait(name, time, moveto) + if (CT_WaitName == name) then + if (CT_WaitCounter == 0) then + return false + end + end + CT_WaitCounter = time + CT_WaitName = name + CT_WaitMoveTo = moveto + return true +end + +function WaitQueue() + if (CT_WaitCounter > 0) then + CT_WaitCounter = CT_WaitCounter - 1 + if (CT_WaitMoveTo > 0) then + if (not IsAt(CT_WaitMoveTo)) then moveto(CT_WaitMoveTo) end + end + return true + else + return false + end +end + +function ResetWait() + CT_WaitCounter = 0 + CT_WaitName = "" +end + +function OnOpponentServe() + if (CT_ServeIndex == 0) then + CT_ServeIndex = math.random(1,3) + end + if (not IsAt(CT_ServeOpp[CT_ServeIndex])) then moveto(CT_ServeOpp[CT_ServeIndex]) end +end + +function OnServe(ballready) + if (WaitQueue()) then return end + if (CT_ServeIndex == 0) then + CT_ServeIndex = math.random(1,6) + end + if (ballready) then + if (Wait("ServeDelay",math.random(28,90),CT_ServeSelf[CT_ServeIndex]+math.random(-150, 150))) then return end + if (IsAt(CT_ServeSelf[CT_ServeIndex])) then + jump() + else + moveto(CT_ServeSelf[CT_ServeIndex]) + end + else + if (posx() < 150) then + jump() + end + moveto(40) + end +end + +function OnGame() + ResetWait() + CT_ServeIndex = 0 + + local timeJump = timeToHitHeight(380, 390, 20) + local timeGround = timeToHitHeight(200, 222, 40) + local timeBlock = timeToOppSmash(390) + local estimhx = r_estimx(timeJump) + local estimGround = r_estimx(timeGround) + local estimBlock = r_estimx(timeBlock) + local block = 0 + local wallcoll = willHitWall(timeJump) + if (timeBlock ~= -1) then block = timeBlock+(estimBlock-400)/13 end + if (timeBlock == -1) then timeBlock = 9999 end + if (timeJump == -1) then estimhx = 9999 end + if (timeGround == -1) then estimGround = 210 end + + if (posy() < CT_LastHeight and posy() > 150 and posy() < 330) then CT_Action = "" end + CT_LastHeight = posy() + + if (CT_Action == "NetBlock") then + if ((posy() < 150) or (timeBlock < 4 and oppy() < 150) or (ballx() <= posx()) or (touches() <= 0 and bspeedx() > 10)) then + CT_Action = "" + else + jump() + moveto(400) + return + end + elseif (CT_Action == "JumpPlayFwd") then + if (posy() < 150) then + CT_Action = "" + else + if (estimhx == 9999) then estimhx = ballx()+bspeedx() end + jump() + if (posy() > 300) then + if (math.abs(bally()-posy()) < 18) then + moveto(ballx()+bspeedx()) + elseif (estimhx < 200) then + if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(3,5) end + moveto(estimhx-10*CT_ShotDecision) + elseif (oppx() > 600 and oppy() < 150) then + if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,6) end + moveto(estimhx-10*CT_ShotDecision) + elseif (oppx() < 600 and oppy() > 180) then + moveto(estimhx-40) + else + moveto(estimhx-60) + end + else + moveto(estimhx-60) + end + return + end + elseif (CT_Action == "JumpPlayRev") then + if (posy() < 150 or touches() ~= CT_LastTouches) then + CT_Action = "" + else + if (estimhx == 9999) then estimhx = ballx()+bspeedx() end + jump() + if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,9) end + moveto(estimhx+5*CT_ShotDecision) + return + end + end + + if (touches() ~= CT_LastTouches) then + CT_LastTouches = touches() + CT_NextGround = math.random(-20,20) + end + + if (CT_Action == "") then + if ((ballx() < 400 or bspeedx() < -2) and estimGround < 400) then + if (touches() >= 2) then + moveto(estimGround+(posx()-500)/22) + elseif (math.abs(bspeedx()) > 8) then + moveto(estimGround) + else + moveto(estimGround+CT_NextGround) + end + elseif (estimhx < 600 and math.abs(bspeedx()) < 6) then + moveto(280) + elseif (estimhx > 650) then + moveto(250) + else + moveto(190) + end + end + + if (posy() > 150) then return end + if (touches() > 2) then return end + + if (timeBlock >= 17 and timeBlock <= 19) then + if (posx() > 210 and estimBlock > 395 and estimBlock < 640 and not wallcoll) then + jump() + moveto(400) + CT_Action = "NetBlock" + return + end + end + if (timeJump >= 17 and timeJump <= 19) then + if (bspeedx() <= 7 and estimhx >= 65 and estimhx <= 420 and posx()-estimhx <= 120 and (bspeedx() >= -7 or not wallcoll)) then + if (estimGround > 400 or bally() > 250) then + CT_Action = "JumpPlayFwd" + CT_ShotDecision = 0 + jump() + end + end + if ((wallcoll or bspeedx() >= -7) and estimhx <= 250 and posx()-estimhx <= 180 and posx()-estimhx >= -120) then + if (estimGround > 400 or bally() > 250) then + if (CT_Action == "JumpPlayFwd" and (touches() >= 2 or math.random(100) > 15)) then return end + CT_Action = "JumpPlayRev" + CT_ShotDecision = 0 + jump() + end + end + end +end + + +function timeToHitHeight(minheight, maxheight, depth) + local i = 0 + for i=1, depth do + if (estimy(i) >= minheight and estimy(i) <= maxheight and estimx(i) <= 420) then + return i + end + end + return -1 +end + +function timeToOppSmash(height) + if (bally() < height) then return -1 end + local i = 0 + for i=1, 17 do + if (estimy(i) < height) then + return i + end + end + return -1 +end + +function r_estimx(time) + local estim = estimx(time) + if estim < 31.5 then estim = 63-estim end + if estim > 768.5 then estim = 1537-estim end + if (bally() < 330) then + if (ballx() < 400 and estim > 400) then estim = 723-estim end + if (ballx() > 400 and estim < 400) then estim = 877-estim end + end + return estim +end + +function willHitWall(time) + if (estimx(time) < 31.5) then return true end + return false +end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/old/gintonicV8.lua blobby-0.9c/data/scripts/old/gintonicV8.lua --- blobby-0.8-dfsg/data/scripts/old/gintonicV8.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/gintonicV8.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,240 @@ +--Gin Tonic v8 - No Comments, sorry :P + +CT_ServeSelf = { 152, 163, 180, 195, 205, 240 } +CT_ServeOpp = { 140, 200, 240 } +CT_ServeIndex = 0 +CT_Tolerance = 5 +CT_Action = "" +CT_ShotDecision = 0 +CT_NextGround = 9999 +CT_LastTouches = 9999 +CT_LastHeight = 0 +CT_SkipNextBlock = 0 + +CT_WaitCounter = 0 +CT_WaitName = "" +CT_WaitMoveTo = 0 + +function IsAt(position) + return (math.abs(posx()-position) <= CT_Tolerance) +end + +function Wait(name, time, moveto) + if (CT_WaitName == name) then + if (CT_WaitCounter == 0) then + return false + end + end + CT_WaitCounter = time + CT_WaitName = name + CT_WaitMoveTo = moveto + return true +end + +function WaitQueue() + if (CT_WaitCounter > 0) then + CT_WaitCounter = CT_WaitCounter - 1 + if (CT_WaitMoveTo > 0) then + if (not IsAt(CT_WaitMoveTo)) then moveto(CT_WaitMoveTo) end + end + return true + else + return false + end +end + +function ResetWait() + CT_WaitCounter = 0 + CT_WaitName = "" +end + +function OnOpponentServe() + if (CT_ServeIndex == 0) then + CT_ServeIndex = math.random(1,3) + end + if (not IsAt(CT_ServeOpp[CT_ServeIndex])) then moveto(CT_ServeOpp[CT_ServeIndex]) end +end + +function OnServe(ballready) + if (WaitQueue()) then return end + if (CT_ServeIndex == 0) then + CT_ServeIndex = math.random(1,6) + end + if (ballready) then + if (Wait("ServeDelay",math.random(28,90),CT_ServeSelf[CT_ServeIndex]+math.random(-150, 150))) then return end + if (IsAt(CT_ServeSelf[CT_ServeIndex])) then + jump() + else + moveto(CT_ServeSelf[CT_ServeIndex]) + end + else + if (posx() < 150) then + jump() + end + moveto(40) + end +end + +function OnGame() + ResetWait() + CT_ServeIndex = 0 + + local timeJump = timeToHitHeight(380, 390, 20) + local timeGround = timeToHitHeight(200, 222, 40) + local timeBlock = timeToOppSmash(390) + local estimhx = r_estimx(timeJump) + local estimGround = r_estimx(timeGround) + local estimBlock = r_estimx(timeBlock) + local block = 0 + local wallcoll = willHitWall(timeJump) + if (timeBlock ~= -1) then timeBlock = timeBlock+(estimBlock-400)/13 end + if (timeBlock == -1) then timeBlock = 9999 end + if (timeJump == -1) then estimhx = 9999 end + if (timeGround == -1) then estimGround = 210 end + if (CT_SkipNextBlock == 0) then CT_SkipNextBlock = math.random(1,10) end + + if (posy() < CT_LastHeight and posy() > 150 and posy() < 330) then CT_Action = "" end + CT_LastHeight = posy() + + if (CT_Action == "NetBlock") then + if ((posy() < 150) or (timeBlock <= 8 and oppy() < 150) or (ballx() <= posx()) or (touches() <= 0 and bspeedx() > 9)) then + CT_Action = "" + else + jump() + moveto(400) + return + end + elseif (CT_Action == "JumpPlayFwd") then + if (posy() < 150) then + CT_Action = "" + else + if (estimhx == 9999) then estimhx = ballx()+bspeedx() end + jump() + if (posy() > 300) then + if (math.abs(bally()-posy()) < 18) then + moveto(ballx()+bspeedx()) + elseif (estimhx < 200) then + if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(3,5) end + moveto(estimhx-10*CT_ShotDecision) + elseif (oppx() > 600 and oppy() < 150) then + if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(4,6) end + moveto(estimhx-10*CT_ShotDecision) + elseif (oppx() < 600 and oppy() > 180) then + moveto(estimhx-40) + else + moveto(estimhx-60) + end + else + moveto(estimhx-50) + end + return + end + elseif (CT_Action == "JumpPlayRev") then + if (posy() < 150 or touches() ~= CT_LastTouches) then + CT_Action = "" + else + if (estimhx == 9999) then estimhx = ballx()+bspeedx() end + jump() + if (CT_ShotDecision == 0 and touches() == 2) then CT_ShotDecision = math.random(5,7) end + if (CT_ShotDecision == 0) then CT_ShotDecision = math.random(3,8) end + if (math.abs(bally()-posy()) < 18) then + moveto(ballx()+bspeedx()) + else + moveto(estimhx+5*CT_ShotDecision) + end + return + end + end + + if (touches() ~= CT_LastTouches) then + CT_LastTouches = touches() + CT_NextGround = math.random(-20,20) + CT_SkipNextBlock = 0 + end + + if (CT_Action == "") then + if ((ballx() < 400 or bspeedx() < -2 or bspeedx() > 10) and estimGround < 400) then + if (touches() >= 2) then + moveto(estimGround+(posx()-500)/22) + elseif (math.abs(bspeedx()) > 8) then + moveto(estimGround) + else + moveto(estimGround+CT_NextGround) + end + elseif (estimhx < 650 and math.abs(bspeedx()) < 6) then + moveto(215) + elseif (estimhx > 650) then + moveto(250) + else + moveto(180) + end + end + + if (posy() > 150) then return end + if (touches() > 2) then return end + + if (timeBlock >= 23 and timeBlock <= 25 and CT_SkipNextBlock ~= 1) then + if (posx() > 210 and estimBlock > 395 and estimBlock < 650 and not wallcoll) then + jump() + moveto(400) + CT_Action = "NetBlock" + return + end + end + if (timeJump >= 17 and timeJump <= 19) then + if (bspeedx() <= 7 and estimhx >= 65 and estimhx <= 420 and posx()-estimhx <= 120 and (bspeedx() >= -7 or not wallcoll)) then + if (estimGround > 400 or bally() > 250) then + CT_Action = "JumpPlayFwd" + CT_ShotDecision = 0 + jump() + end + end + if ((wallcoll or bspeedx() >= -7) and estimhx <= 250 and posx()-estimhx <= 180 and posx()-estimhx >= -120) then + if (estimGround > 400 or bally() > 250) then + if (CT_Action == "JumpPlayFwd" and (touches() >= 2 or math.random(100) > 15)) then return end + CT_Action = "JumpPlayRev" + CT_ShotDecision = 0 + jump() + end + end + end +end + + +function timeToHitHeight(minheight, maxheight, depth) + local i = 0 + for i=1, depth do + if (estimy(i) >= minheight and estimy(i) <= maxheight) then + return i + end + end + return -1 +end + +function timeToOppSmash(height) + if (bally() < height) then return -1 end + local i = 0 + for i=1, 17 do + if (estimy(i) < height) then + return i + end + end + return -1 +end + +function r_estimx(time) + local estim = estimx(time) + if estim < 31.5 then estim = 63-estim end + if estim > 768.5 then estim = 1537-estim end + if (bally() < 330) then + if (ballx() < 400 and estim > 400) then estim = 723-estim end + if (ballx() > 400 and estim < 400) then estim = 877-estim end + end + return estim +end + +function willHitWall(time) + if (estimx(time) < 31.5) then return true end + if (estimx(time) > 768.5) then return true end + return false +end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/old/hyp010.lua blobby-0.9c/data/scripts/old/hyp010.lua --- blobby-0.8-dfsg/data/scripts/old/hyp010.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/hyp010.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,514 @@ +g=0.28 +pg=0.88 +v0=14.5 +v_p=4.5 +pj=0.44 +r1=31.5 +p0=0 +p1=0.5 +p2=1 +h=31.5+19+25 + + +estt=0 +nettime=0 +touch=0 +est=0 +p=0.4 +esto1=10 +esto2=10 + + +function yb(y,vy,t) + + return y+(vy-g/10)*t-1/2*g*t^2 + +end + +function move(x) + + if (posx()2.26) then right() + elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() + end + +end + +function tb(y,vy,height,typ) +local sgn=0 + if (typ==1) + then + sgn=-1 + else + sgn=1 + end + if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 + then return -1 + else + return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) + end +end + +function time(t) + + return 1/5*math.ceil(5*t) + +end + +function pos(x) + + local x1,x2 + x1=4.5*math.ceil((1/4.5)*x) + x2=4.5*math.floor((1/4.5)*x) + if (x1<0) or (x2<0) then return 0 + else + if (math.abs(x1-x)146) then + return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) + else + return 0 + end +end + +function time(t) +return 1/5*math.ceil(5*t) +end + + +-- + +function collide(x,y,vx,vy,objx,objy,r2) + + local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) + local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) + local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) + local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) + local t=-1 + if (t1150) then t=-1 end + + return t + +end + + + +function estimate(x,y,vx,vy,height,typ) + + local collision=1 + local tw,tn,ts=0,0,0 + local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 + + while(collision==1) do + ts=collide(x,y,vx,vy,400,316,7) + if (vx>0) + then + tw=time((768.5-x)/vx) + tn=time((361.5-x)/vx) + else + tw=time((31.5-x)/vx) + tn=time((438.5-x)/vx) + end + local th=time(tb(y,vy,height,typ)) + local t=10000 + + if ((ts>0) and (ts0) and (tn0) and (twt) + then + if (t==ts) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vy=vy-g*t + xr=x + yr=y + vxr=0 + vyr=0 + n=1 + collision=0 + elseif ((t==tn) or (t==tw)) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vx=-vx + vy=vy-g*t + collision=1 + end + else + tr=tr+th + vxr=vx + vyr=vy-g*th + xr=x+vx*th + yr=yb(y,vy,th) + collision=0 + end + end + if (tr<0) + then + return -1,-1,-1,-1,-1,-1 + else + return xr,yr,vxr,vyr,tr,n + end +end + + +function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) +local x1,y1,vx1,vy1=0,0,0,0 +local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 +local xpos1=xpos +local ypos1=ypos +for t=0,20,0.2 do + + if (jump==1) then + ypos1=yp(tp(ypos)+t) + end + x1=x+vx*t + if (x1<31.5) then x1=2*31.5-x1 end + if (x1>368.5) then x1=2*368.5-x1 end + y1=yb(y,vy,t) + + if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then + local dx=x1-xpos1 + local dy=y1-(ypos1+19) + local l=math.sqrt(dx^2+dy^2) + vx1=dx/l + vy1=dy/l + x1=x1+vx1*3 + y1=y1+vy1*3 + vy1=vy1*13.125 + vx1=vx1*13.125 + x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) + break + end +end + +return x2,y2,x1,y1,vx1,vy1 +end + +function lob() + + if (math.abs(est-esto2)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto2=est + imp=0 + x1=0 + t=30 + while (t>=0) do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5730) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + if (impfimp) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + end + if (imp>740) then break end + end + if (t>12) then t=t-6 else t=t-4 end + end + t2=t2+1 + end + t2=t2-1 + if (x1>0) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else + move(est) + --p=0.5 + end + +end + + +function attack() + + if (math.abs(est-esto1)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 + h2=900 +-- debug(-10) + esto1=est + imp=0 + x1=0 + t=30 + while (t>=0) do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.5+10) and (x1f<360) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + xat=xaf + yat=yaf + vxat=vxaf + vyat=vyaf + break + end + end + h2t=yb(yat,vyat,(400-xat)/vxat) + if (h2t316+31.5+10) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + xa=xat + ya=yat + vxa=vxat + vya=vyat + end + h2=yb(ya,vya,(400-xa)/vxa) + if (h2>316+31.5+10) and (h2<316+31.5+45) then break end + end + if (t>12) then t=t-6 + else t=t-4 end + end + t2=t2+1 + end + t2=t2-1 + + if (x1>0) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() + end + else + move(est) + --p=0.9 + end +end + + +function netp() + + if (math.abs(est-esto)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto=est + imp=0 + x1=0 + for t=33,0,-3 do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + end + if (impt>imp) and (impt<431.5) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + end + if (imp>428) then break end + end + end + t2=t2+1 + end + t2=t2-1 + if (x1>0) and (est<368.5) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else + move(est) + end + +end + + +function OnOpponentServe() +y1p=144.5 +if (math.abs(pos(posx())-posx())>1) then move(400) else +move(200) +end +valid=1 + + +end + +function OnServe(ballready) +y1p=144.5 + est=700 + + if (math.abs(pos(posx())-posx())>1) then + move(400) + else + if (math.abs(posx()-180)<2) then + jump() + else + move(180) + end + end +valid=1 +end + + + +function OnGame() + +yp2=y1p +y1p=oppy() +vp=y1p-yp2 + + +esttold=estt +netold=net +toucho=touch +touch=touches() +if (touch400-31.5) then + move (250) + elseif (est<400-10) and (est>400-22) then + move(200) + elseif (est<400) and (est>400-10) then + move(180) + else + move(230) +end + +end diff -Nru blobby-0.8-dfsg/data/scripts/old/hyp011com.lua blobby-0.9c/data/scripts/old/hyp011com.lua --- blobby-0.8-dfsg/data/scripts/old/hyp011com.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/hyp011com.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,634 @@ +g=0.28 +pg=0.88 +v0=14.5 +v_p=4.5 +pj=0.44 +r1=31.5 +p0=0 +p1=0.5 +p2=1 +h=31.5+19+25 + + +estt=0 +nettime=0 +touch=0 +est=0 +p=0.4 +esto1=10 +esto2=10 +esto3=10 + + +function yb(y,vy,t) + + return y+(vy-g/10)*t-1/2*g*t^2 + +end + +function move(x) + + if (posx()2.26) then right() + elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() + end + +end + +function tb(y,vy,height,typ) +local sgn=0 + if (typ==1) + then + sgn=-1 + else + sgn=1 + end + if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 + then return -1 + else + return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) + end +end + +function time(t) + + return 1/5*math.ceil(5*t) + +end + +function pos(x) + + local x1,x2 + x1=4.5*math.ceil((1/4.5)*x) + x2=4.5*math.floor((1/4.5)*x) + if (x1<0) or (x2<0) then return 0 + else + if (math.abs(x1-x)146) then + return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) + else + return 0 + end +end + +function time(t) +return 1/5*math.ceil(5*t) +end + + +-- + +function collide(x,y,vx,vy,objx,objy,r2) + + local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) + local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) + local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) + local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) + local t=-1 + if (t1150) then t=-1 end + + return t + +end + + + +function estimate(x,y,vx,vy,height,typ) + + local collision=1 + local tw,tn,ts=0,0,0 + local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 + + while(collision==1) do + ts=collide(x,y,vx,vy,400,316,7) + if (vx>0) + then + tw=time((768.5-x)/vx) + tn=time((361.5-x)/vx) + else + tw=time((31.5-x)/vx) + tn=time((438.5-x)/vx) + end + local th=time(tb(y,vy,height,typ)) + local t=10000 + + if ((ts>0) and (ts0) and (tn0) and (twt) + then + if (t==ts) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vy=vy-g*t + xr=x + yr=y + vxr=0 + vyr=0 + n=1 + collision=0 + elseif ((t==tn) or (t==tw)) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vx=-vx + vy=vy-g*t + collision=1 + end + else + tr=tr+th + vxr=vx + vyr=vy-g*th + xr=x+vx*th + yr=yb(y,vy,th) + collision=0 + end + end + if (tr<0) + then + return -1,-1,-1,-1,-1,-1 + else + return xr,yr,vxr,vyr,tr,n + end +end + + +function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) +local x1,y1,vx1,vy1=0,0,0,0 +local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 +local xpos1=xpos +local ypos1=ypos +for t=0,20,0.2 do + + if (jump==1) then + ypos1=yp(tp(ypos)+t) + end + x1=x+vx*t + if (x1<31.5) then x1=2*31.5-x1 end + if (x1>368.5) then x1=2*368.5-x1 end + y1=yb(y,vy,t) + + if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then + local dx=x1-xpos1 + local dy=y1-(ypos1+19) + local l=math.sqrt(dx^2+dy^2) + vx1=dx/l + vy1=dy/l + x1=x1+vx1*3 + y1=y1+vy1*3 + vy1=vy1*13.125 + vx1=vx1*13.125 + x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) + break + end +end + +return x2,y2,x1,y1,vx1,vy1 +end + +function lob() + + if (math.abs(est-esto2)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto2=est + imp=0 + x1=0 + t=30 + while (t>=0) do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5730) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + if (impfimp) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + end + if (imp>740) then break end + end + if (t>12) then t=t-6 else t=t-4 end + end + t2=t2+1 + end + t2=t2-1 + if (x1>0) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else + move(est) + --p=0.5 + end + +end + + +function attack() + + if (math.abs(est-esto1)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 + h2=900 +-- debug(-10) + esto1=est + imp=0 + x1=0 + t=30 + while (t>=0) do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.5+10) and (x1f<360) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + xat=xaf + yat=yaf + vxat=vxaf + vyat=vyaf + break + end + end + h2t=yb(yat,vyat,(400-xat)/vxat) + if (h2t316+31.5+10) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + xa=xat + ya=yat + vxa=vxat + vya=vyat + end + h2=yb(ya,vya,(400-xa)/vxa) + if (h2>316+31.5+10) and (h2<316+31.5+45) then break end + end + if (t>12) then t=t-6 + else t=t-4 end + end + t2=t2+1 + end + t2=t2-1 + + if (x1>0) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() + end + else + move(est) + --p=0.9 + end +end + + +function netp() + + if (math.abs(est-esto3)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto3=est + imp=500 + x1=0 + for t=33,0,-3 do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5380) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + end + if (impt0) and (est<368.5) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else + move(est-4.5) + end + +end + + + + + +function posplay() + + if (math.abs(est-esto3)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto3=est + imp=500 + x1=0 + for t=33,0,-3 do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5280) and (impf<340) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + end + if (math.abs(impt-310)0) and (est<368.5) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else + move(est) + end + +end + + + + + + +function OnOpponentServe() +y1p=144.5 +if (math.abs(pos(posx())-posx())>1) then move(400) else +move(200) +end +valid=1 +nettime=0 +phase=0 + +end + +function OnServe(ballready) +nettime=0 +y1p=144.5 +phase=0 + est=700 + + if (math.abs(pos(posx())-posx())>1) then + move(400) + else + if (math.abs(posx()-180)<2) then + jump() + else + move(180) + end + end +valid=1 +end + + + +function OnGame() + +yp2=y1p +y1p=oppy() +vp=y1p-yp2 + + +esttold=estt +netold=net +toucho=touch +touch=touches() +if (touch431.5) or (est<368.5)) then + nettime=10 + phase=4 + elseif (phase==4) and (nettime>0) then + nettime=nettime-1 + else + if (est>431.5) then + phase=3 + elseif (est<431.5) and (est>368.5) then + phase=2 + else + phase=1 + end +end + +if (math.sqrt((ballx()-400)^2+(bally()-316)^2)<(31.5+7)) and (math.sqrt((bspeedx())^2+(bspeedy())^2)<2) then phase=5 end + + +--1 Player +--2 Ball +-- debug(0) +-- debug(est) +-- debug(imp) +-- debug(t2) +-- +-- if (est<(400-31.5)) then +-- if (p<1) then netp() +-- else lob() +-- end +-- elseif (est<400-22) and (est>400-31.5) then +-- move (250) +-- elseif (est<400-10) and (est>400-22) then +-- move(200) +-- elseif (est<400) and (est>400-10) then +-- move(180) +-- else +-- move(100) +-- end +if (phase==3) then + move(100) + elseif (phase==1) then +-- if (p<0.4) then +-- attack() +-- elseif (p>=0.4) and (p<0.7) then +-- lob() +-- else + if (touches()==0) then + posplay() + elseif (touches()==1) then + netp() + else + attack() + end +-- end + elseif (phase==2) then + if (tnet<=tp(393)+1) or (nettime>0) then jump() end + if (math.abs(posx()-360)/4.5-10<=tnet) then + left() + else + right() + end + elseif (phase==4) then + right() + jump() + elseif (phase==5) then + if (posx()>300) then jump() end + right() +end + +end diff -Nru blobby-0.8-dfsg/data/scripts/old/hyp011.lua blobby-0.9c/data/scripts/old/hyp011.lua --- blobby-0.8-dfsg/data/scripts/old/hyp011.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/hyp011.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,634 @@ +g=0.28 +pg=0.88 +v0=14.5 +v_p=4.5 +pj=0.44 +r1=31.5 +p0=0 +p1=0.5 +p2=1 +h=31.5+19+25 + + +estt=0 +nettime=0 +touch=0 +est=0 +p=0.4 +esto1=10 +esto2=10 +esto3=10 + + +function yb(y,vy,t) + + return y+(vy-g/10)*t-1/2*g*t^2 + +end + +function move(x) + + if (posx()2.26) then right() + elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() + end + +end + +function tb(y,vy,height,typ) +local sgn=0 + if (typ==1) + then + sgn=-1 + else + sgn=1 + end + if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 + then return -1 + else + return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) + end +end + +function time(t) + + return 1/5*math.ceil(5*t) + +end + +function pos(x) + + local x1,x2 + x1=4.5*math.ceil((1/4.5)*x) + x2=4.5*math.floor((1/4.5)*x) + if (x1<0) or (x2<0) then return 0 + else + if (math.abs(x1-x)146) then + return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) + else + return 0 + end +end + +function time(t) +return 1/5*math.ceil(5*t) +end + + +-- + +function collide(x,y,vx,vy,objx,objy,r2) + + local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) + local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) + local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) + local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) + local t=-1 + if (t1150) then t=-1 end + + return t + +end + + + +function estimate(x,y,vx,vy,height,typ) + + local collision=1 + local tw,tn,ts=0,0,0 + local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 + + while(collision==1) do + ts=collide(x,y,vx,vy,400,316,7) + if (vx>0) + then + tw=time((768.5-x)/vx) + tn=time((361.5-x)/vx) + else + tw=time((31.5-x)/vx) + tn=time((438.5-x)/vx) + end + local th=time(tb(y,vy,height,typ)) + local t=10000 + + if ((ts>0) and (ts0) and (tn0) and (twt) + then + if (t==ts) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vy=vy-g*t + xr=x + yr=y + vxr=0 + vyr=0 + n=1 + collision=0 + elseif ((t==tn) or (t==tw)) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vx=-vx + vy=vy-g*t + collision=1 + end + else + tr=tr+th + vxr=vx + vyr=vy-g*th + xr=x+vx*th + yr=yb(y,vy,th) + collision=0 + end + end + if (tr<0) + then + return -1,-1,-1,-1,-1,-1 + else + return xr,yr,vxr,vyr,tr,n + end +end + + +function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) +local x1,y1,vx1,vy1=0,0,0,0 +local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 +local xpos1=xpos +local ypos1=ypos +for t=0,20,0.2 do + + if (jump==1) then + ypos1=yp(tp(ypos)+t) + end + x1=x+vx*t + if (x1<31.5) then x1=2*31.5-x1 end + if (x1>368.5) then x1=2*368.5-x1 end + y1=yb(y,vy,t) + + if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then + local dx=x1-xpos1 + local dy=y1-(ypos1+19) + local l=math.sqrt(dx^2+dy^2) + vx1=dx/l + vy1=dy/l + x1=x1+vx1*3 + y1=y1+vy1*3 + vy1=vy1*13.125 + vx1=vx1*13.125 + x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) + break + end +end + +return x2,y2,x1,y1,vx1,vy1 +end + +function lob() + + if (math.abs(est-esto2)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto2=est + imp=0 + x1=0 + t=30 + while (t>=0) do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5730) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + if (impfimp) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + end + if (imp>740) then break end + end + if (t>12) then t=t-6 else t=t-4 end + end + t2=t2+1 + end + t2=t2-1 + if (x1>0) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else + move(est) + --p=0.5 + end + +end + + +function attack() + + if (math.abs(est-esto1)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 + h2=900 +-- debug(-10) + esto1=est + imp=0 + x1=0 + t=30 + while (t>=0) do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.5+10) and (x1f<360) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + xat=xaf + yat=yaf + vxat=vxaf + vyat=vyaf + break + end + end + h2t=yb(yat,vyat,(400-xat)/vxat) + if (h2t316+31.5+10) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + xa=xat + ya=yat + vxa=vxat + vya=vyat + end + h2=yb(ya,vya,(400-xa)/vxa) + if (h2>316+31.5+10) and (h2<316+31.5+45) then break end + end + if (t>12) then t=t-6 + else t=t-4 end + end + t2=t2+1 + end + t2=t2-1 + + if (x1>0) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() + end + else + move(est) + --p=0.9 + end +end + + +function netp() + + if (math.abs(est-esto3)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto3=est + imp=500 + x1=0 + for t=33,0,-3 do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5380) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + end + if (impt0) and (est<368.5) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else + move(est-4.5) + end + +end + + + + + +function posplay() + + if (math.abs(est-esto3)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto3=est + imp=500 + x1=0 + for t=33,0,-3 do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5280) and (impf<340) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + end + if (math.abs(impt-310)0) and (est<368.5) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else + move(est) + end + +end + + + + + + +function OnOpponentServe() +y1p=144.5 +if (math.abs(pos(posx())-posx())>1) then move(400) else +move(200) +end +valid=1 +nettime=0 +phase=0 + +end + +function OnServe(ballready) +nettime=0 +y1p=144.5 +phase=0 + est=700 + + if (math.abs(pos(posx())-posx())>1) then + move(400) + else + if (math.abs(posx()-180)<2) then + jump() + else + move(180) + end + end +valid=1 +end + + + +function OnGame() + +yp2=y1p +y1p=oppy() +vp=y1p-yp2 + + +esttold=estt +netold=net +toucho=touch +touch=touches() +if (touch431.5) or (est<368.5)) then + nettime=10 + phase=4 + elseif (phase==4) and (nettime>0) then + nettime=nettime-1 + else + if (est>431.5) then + phase=3 + elseif (est<431.5) and (est>368.5) then + phase=2 + else + phase=1 + end +end + +if (math.sqrt((ballx()-400)^2+(bally()-316)^2)<(31.5+7)) and (math.sqrt((bspeedx())^2+(bspeedy())^2)<2) then phase=5 end + + +--1 Player +--2 Ball +-- debug(0) +-- debug(est) +-- debug(imp) +-- debug(t2) +-- +-- if (est<(400-31.5)) then +-- if (p<1) then netp() +-- else lob() +-- end +-- elseif (est<400-22) and (est>400-31.5) then +-- move (250) +-- elseif (est<400-10) and (est>400-22) then +-- move(200) +-- elseif (est<400) and (est>400-10) then +-- move(180) +-- else +-- move(100) +-- end +if (phase==3) then + move(100) + elseif (phase==1) then + if (p<0.4) then + attack() + elseif (p>=0.4) and (p<0.7) then + lob() + else + if (touches()==0) then + posplay() + elseif (touches()==1) then + netp() + else + attack() + end + end + elseif (phase==2) then + if (tnet<=tp(393)+1) or (nettime>0) then jump() end + if (math.abs(posx()-360)/4.5-10<=tnet) then + left() + else + right() + end + elseif (phase==4) then + right() + jump() + elseif (phase==5) then + if (posx()>300) then jump() end + right() +end + +end diff -Nru blobby-0.8-dfsg/data/scripts/old/hyp012.lua blobby-0.9c/data/scripts/old/hyp012.lua --- blobby-0.8-dfsg/data/scripts/old/hyp012.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/hyp012.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,649 @@ +g=0.28 +pg=0.88 +v0=14.5 +v_p=4.5 +pj=0.44 +r1=31.5 + +h=31.5+19+25 + + +estt=0 +nettime=0 +touch=0 +est=0 +p=math.random()/2+0.5 +esto1=10 +esto2=10 +esto3=10 +esto4=10 + +function yb(y,vy,t) + + return y+(vy-g/10)*t-1/2*g*t^2 + +end + +function move(x) + + if (posx()2.26) then right() + elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() + end + +end + +function tb(y,vy,height,typ) +local sgn=0 + if (typ==1) + then + sgn=-1 + else + sgn=1 + end + if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 + then return -1 + else + return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) + end +end + +function time(t) + + return 1/5*math.ceil(5*t) + +end + +function pos(x) + + local x1,x2 + x1=4.5*math.ceil((1/4.5)*x) + x2=4.5*math.floor((1/4.5)*x) + if (x1<0) or (x2<0) then return 0 + else + if (math.abs(x1-x)146) then + return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) + else + return 0 + end +end + +function time(t) +return 1/5*math.ceil(5*t) +end + + +-- + +function collide(x,y,vx,vy,objx,objy,r2) + + local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) + local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) + local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) + local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) + local t=-1 + if (t1150) then t=-1 end + + return t + +end + + + +function estimate(x,y,vx,vy,height,typ) + + local collision=1 + local tw,tn,ts=0,0,0 + local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 + + while(collision==1) do + ts=collide(x,y,vx,vy,400,316,7) + if (vx>0) + then + tw=time((768.5-x)/vx) + tn=time((361.5-x)/vx) + else + tw=time((31.5-x)/vx) + tn=time((438.5-x)/vx) + end + local th=time(tb(y,vy,height,typ)) + local t=10000 + + if ((ts>0) and (ts0) and (tn0) and (twt) + then + if (t==ts) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vy=vy-g*t + xr=x + yr=y + vxr=0 + vyr=0 + n=1 + collision=0 + elseif ((t==tn) or (t==tw)) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vx=-vx + vy=vy-g*t + collision=1 + end + else + tr=tr+th + vxr=vx + vyr=vy-g*th + xr=x+vx*th + yr=yb(y,vy,th) + collision=0 + end + end + if (tr<0) + then + return -1,-1,-1,-1,-1,-1 + else + return xr,yr,vxr,vyr,tr,n + end +end + + +function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) +local x1,y1,vx1,vy1=0,0,0,0 +local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 +local xpos1=xpos +local ypos1=ypos +for t=0,20,0.2 do + + if (jump==1) then + ypos1=yp(tp(ypos)+t) + end + x1=x+vx*t + if (x1<31.5) then x1=2*31.5-x1 end + if (x1>368.5) then x1=2*368.5-x1 end + y1=yb(y,vy,t) + + if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then + local dx=x1-xpos1 + local dy=y1-(ypos1+19) + local l=math.sqrt(dx^2+dy^2) + vx1=dx/l + vy1=dy/l + x1=x1+vx1*3 + y1=y1+vy1*3 + vy1=vy1*13.125 + vx1=vx1*13.125 + x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) + break + end +end + +return x2,y2,x1,y1,vx1,vy1 +end + +function lob() + + if (math.abs(est-esto2)>0.2) then + esto2=est + imp=0 + x1=0 + t=30 + while (t>=0) do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5730) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + if (impfimp) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + end + if (imp>740) then break end + end + if (t>12) then t=t-6 else t=t-4 end + end + t2=t2+1 + end + t2=t2-1 + if (x1>0) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else +-- move(est) +p=math.random() +esto2=0 + end + +end + + +function attack() + + if (math.abs(est-esto1)>0.2) then + h2=900 + esto1=est + imp=0 + x1=0 + t=30 + while (t>=0) do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(pos(x2f)+4.5))/4.5400) and (math.abs(posx()-x1f)/4.5+10) and (x1f<360) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + xat=xaf + yat=yaf + vxat=vxaf + vyat=vyaf + break + end + end + h2t=yb(yat,vyat,(400-xat)/vxat) + if (h2t316+31.5+10) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + xa=xat + ya=yat + vxa=vxat + vya=vyat + end + h2=yb(ya,vya,(400-xa)/vxa) + if (h2>316+31.5+10) and (h2<316+31.5+60) then break end + end + if (t>12) then t=t-6 + else t=t-4 end + end + t2=t2+1 + end + t2=t2-1 + + if (x1>0) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() + end + else +-- move(est-5) + --p=0.9 +p=math.random() +esto1=0 + end +end + + +function netp() + + if (math.abs(est-esto3)>0.2) then + esto3=est + imp=500 + x1=0 + for t=33,0,-3 do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5380) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + end + if (impt0) and (est<368.5) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else +-- move(est-4.5) +p=math.random() +esto3=0 + end + +end + + + + + +function playto(dest) +--310 + + if (math.abs(est-esto4)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto4=est + imp=500 + x1=0 + for t=33,0,-3 do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5dest-30) and (impf0) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + end + if (math.abs(impt-dest)0) and (est<368.5) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else +-- move(est) +p=math.random() +esto4=0 + end + +end + + + + + + +function OnOpponentServe() +pp=math.random() + y1p=144.5 + if (math.abs(pos(posx())-posx())>1) then + move(400) + else + move(200) + end + valid=1 + nettime=0 + phase=0 + imp1=0 + imp2=0 + imp=0 + active=1 +end + +function OnServe(ballready) +pp=math.random() + active=1 + nettime=0 + y1p=144.5 + phase=0 + est=700 + imp1=0 + imp2=0 + imp=0 + + if (math.abs(pos(posx())-posx())>1) then + move(400) + else + if (math.abs(posx()-198)<2) then + jump() + else + move(198) + end + end + valid=1 +end + + + +function OnGame() + + yp2=y1p + y1p=oppy() + vp=y1p-yp2 + + if (math.abs(imp1-imp)>0.1) then + imp2=imp1 + imp1=imp + end + + esttold=estt + netold=net + toucho=touch + touch=touches() + if (touch431.5) or (est<368.5)) then + nettime=11 + phase=4 + elseif (phase==4) and (nettime>0) then + nettime=nettime-1 + else + if (est>431.5) then + phase=3 + elseif (est<431.5) and (est>368.5) then + phase=2 + else + phase=1 + end + end + else + phase=6 + end + if (bally()<130) then active=0 end + + if (math.sqrt((ballx()-400)^2+(bally()-316)^2)<(31.5+7)) and (math.sqrt((bspeedx())^2+(bspeedy())^2)<2) then phase=5 end + + if (phase==3) then + move(170) + elseif (phase==1) then + + if (p<0.5) then + if (touch==0) then + playto(310) + elseif (touch==1) then + if (p<0.2) then + netp() + elseif (p>=0.2) and (p<0.35) then + playto(pp*300+450) + elseif (p>=0.35) and (p<0.5) then + attack() + end + else + attack() + end + else + if (touch==0) then + if (p>=0.5) and (p<0.75) then + playto(pp*300+450) + elseif (p>=0.75) and (p<=1.0) then + attack() + end + else + attack() + end + end + elseif (phase==2) then + if (tnet<=tp(393)+1) or (nettime>0) then jump() end + if (math.abs(posx()-360)/4.5-10<=tnet) then + left() + else + right() + end + elseif (phase==4) then + right() + jump() + elseif (phase==5) then + if (posx()>300) then + jump() + end + right() + end + + if ((x1==0) or (imp==0)) and (phase==1) then +-- debug(-1) + move(est) + end +--debug(phase) +end diff -Nru blobby-0.8-dfsg/data/scripts/old/hyp013.lua blobby-0.9c/data/scripts/old/hyp013.lua --- blobby-0.8-dfsg/data/scripts/old/hyp013.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/hyp013.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,592 @@ +g=0.28 +pg=0.88 +v0=14.5 +v_p=4.5 +pj=0.44 +r1=31.5 +h=31.5+19+25 + estt=0 +p=0.654 + +function reset() + est=0 + imp,imp1,imp2=0,0,0 + + nettime=0 + touch=0 + esto1=0 + esto2=0 + esto3=0 + esto4=0 + esto5=0 + esto6=0 + phase=0 + valid=1 + active=1 + nettime=0 + y1p=posy() +end + +function yb(y,vy,t) + + return y+(vy-g/10)*t-1/2*g*t^2 + +end + +function move(x) + + if (posx()2.26) then right() + elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() + end + +end + +function tb(y,vy,height,typ) + local sgn=0 + if (typ==1) + then + sgn=-1 + else + sgn=1 + end + if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 + then return -1 + else + return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) + end +end + +function time(t) + + return 1/5*math.ceil(5*t) + +end + +function pos2(x) + + local x1,x2 + x1=4.5*math.ceil((1/4.5)*x) + x2=4.5*math.floor((1/4.5)*x) + if (x1<0) or (x2<0) then return 0 + else + if (math.abs(x1-x)146) then + return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) + else + return 0 + end +end + +function time(t) +return 1/5*math.ceil(5*t) +end + + +-- + +function collide(x,y,vx,vy,objx,objy,r2) + + local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) + local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) + local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) + local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) + local t=-1 + if (t1150) then t=-1 end + + return t + +end + + + +function estimate(x,y,vx,vy,height,typ) + + local collision=1 + local tw,tn,ts=0,0,0 + local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 + + while(collision==1) do + ts=collide(x,y,vx,vy,400,316,7) + if (vx>0) + then + tw=time((768.5-x)/vx) + tn=time((361.5-x)/vx) + else + tw=time((31.5-x)/vx) + tn=time((438.5-x)/vx) + end + local th=time(tb(y,vy,height,typ)) + local t=10000 + + if ((ts>0) and (ts0) and (tn0) and (twt) + then + if (t==ts) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vy=vy-g*t + xr=x + yr=y + vxr=vx + vyr=vy + n=1 + collision=0 + elseif ((t==tn) or (t==tw)) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vx=-vx + vy=vy-g*t + collision=1 + end + else + tr=tr+th + vxr=vx + vyr=vy-g*th + xr=x+vx*th + yr=yb(y,vy,th) + collision=0 + end + end + if (tr<0) + then + return -1,-1,-1,-1,-1,-1 + else + return xr,yr,vxr,vyr,tr,n + end +end + + +function impact(x,y,vx,vy,xpos,ypos,targety,jum,move) +local x1,y1,vx1,vy1=0,0,0,0 +local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 +local xpos1=xpos +local ypos1=ypos +for t=0,7,0.2 do + + if (jum==1) then + ypos1=yp(tp(ypos)+t) + end + x1=x+vx*t + if (x1<31.5) then x1=2*31.5-x1 end + if (x1>368.5) then x1=2*368.5-x1 end + y1=yb(y,vy,t) + + if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then + local dx=x1-xpos1 + local dy=y1-(ypos1+19) + local l=math.sqrt(dx^2+dy^2) + vx1=dx/l + vy1=dy/l + x1=x1+vx1*3 + y1=y1+vy1*3 + vy1=vy1*13.125 + vx1=vx1*13.125 + x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) + break + + end +end + +return x2,y2,x1,y1,vx1,vy1 +end + +function playto(position) + + if (math.abs(est-esto3)>0.2) then + delta=30 + esto3=est + imp,impt,impf=0,0,0 + x1=0 + t=27 + typ1=60 + typ2=120 + if (position<400) then + n1=2 + n2=-3 + elseif (position>600) then + n1=-4 + n2=-11 + else + n1=-1 + n2=-8 + end + while (t>=0) do + + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(math.ceil((tp2(posy(),vp))))1) and (t2f>1) then + + for x1f=pos(x2f)+n1*4.5,pos(x2f)+n2*4.5,-4.5 do + impf,_,xaf,yaf,vxaf,vyaf=impact(x2f,y2f,vx2f,vy2f,x1f,y1f,220,j,0) + + if (impf>position-delta) and (math.abs(posx()-x1f)/4.5+10) and (x1f<330) and (impfposition+delta) and ((x1f-pos(x2f))/4.5<0) then break end + end + + + end + if (imp>position-delta) and (imp15) then t=t-6 + else t=t-3 end + end + t2=t2+1 + + end + + if (x1>0) and (imp>0) then + t2=t2-1 + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() + end + else + move(est+4.5) + end +end + +function net() + + if (math.abs(est-esto2)>0.2) then + esto2=est + imp,impt,impf=0,0,0 + x1=0 + t=27 + typ1=60 + typ2=120 + + while (t>=0) do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(math.ceil((tp2(posy(),vp))))+21) and (t2f>1) then + for x1f=pos(x2f)-1*4.5,pos(x2f)-10*4.5,-4.5 do + impf,_,xaf,yaf,vxaf,vyaf=impact(x2f,y2f,vx2f,vy2f,x1f,y1f,220,j,0) + if (impf>400) and (math.abs(posx()-x1f)/4.50) and (x1f<330) and (impf<438) then + imp=impf + x1=x1f + y1=y1f + t1=t1f + x2=x2f + y2=y2f + t2=t2f + vx2=vx2f + vy2=vy2f + xa=xaf + ya=yaf + vxa=vxaf + vya=vyaf + break + end + if (imp>400) then break end + end + + + end + if (imp>400) and (imp<438) then break end + if (t>15) then t=t-6 + else t=t-3 end + end + t2=t2+1 + + end + + if (x1>0) and (imp>0) then + t2=t2-1 + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() + end + else + playto(600) + end +end + + +function attack() + + if (math.abs(est-esto1)>0.2) then + h2=900 + esto1=est + imp,impt,impf=0,0,0 + x1=0 + t=27 + typ1=60 + typ2=120 + + while (t>=0) do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(math.ceil((tp2(posy(),vp))))+21) and (t2f>1) then + for x1f=pos(x2f)-20*4.5,pos(x2f)-4*4.5,4.5 do + impf,_,xaf,yaf,vxaf,vyaf=impact(x2f,y2f,vx2f,vy2f,x1f,y1f,220,j,0) + h1=yb(yaf,vyaf,(380-xaf)/vxaf) + h2=yb(yaf,vyaf,(420-xaf)/vxaf) + height=316+7+31.5 + + if (impf>432) and (math.abs(posx()-x1f)/4.5+10) and (x1f<330) and (h2>height+typ1) and (h1>height+typ1) and (h2432) and (h2>height+typ2) then break end + end + + + end + if (imp>0) then break end + if (t>15) then t=t-6 + else t=t-3 end + end + t2=t2+1 + + end + + if (x1>0) and (imp>0) then + t2=t2-1 + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() + end + else + playto(600) + end +end + + + + + +function OnOpponentServe() +reset() + if (math.abs(pos2(posx())-posx())>1) then + move(400) + else + move(200) + end +end + +function OnServe(ballready) +reset() + if (math.abs(pos2(posx())-posx())>1) then + move(400) + else + if (math.abs(posx()-198)<2) then + jump() + else + move(198) + end + end +end + + + +function OnGame() + + yp2=y1p + y1p=posy() + vp=y1p-yp2 + + if (math.abs(imp1-imp)>0.1) then + imp2=imp1 + imp1=imp + end + + esttold=estt + netold=netc + toucho=touch + touch=touches() + if (touch438.5) or (est<361.5)) then + nettime=11 + phase=4 + elseif (phase==4) and (nettime>0) then + nettime=nettime-1 + else + if (est>438.5) then + phase=2 + elseif (est<438.5) and (est>361.5) then + if (((vyestt-g*(80-estt)/vxestt)>0) or (vxestt<0)) and ((360-posx())/4.5=0.2)) then + attack() + else + playto(600) + end + elseif (p>=0.6) and (p<0.9) then + if (p<0.7) and (touch==0) then + playto(300) + else + playto(770) + end +-- elseif (p>=0.9) and (p<0.95) then +-- playto(480) + else + if (p<0.95) and (touch==0) then + playto(300) + elseif (touch==1) or ((touch==0) and (p>=0.95)) then + playto(480) + else + playto(600) + end + end + elseif (phase==3) then + if (tnet<=tp(393)-3) or (nettime>0) then jump() end + if (math.abs(posx()-360)/4.5-7<=tnet) then + left() + else + right() + end + elseif (phase==4) then + right() + jump() + elseif (phase==5) then + move(200) + elseif (phase==6) then + if (posx()>300) then + jump() + end + right() + end + + if ((x1==0) or (imp==0)) and (phase==1) then + move(est) + end +-- debug(0) +-- debug(imp) +-- debug(est) +end diff -Nru blobby-0.8-dfsg/data/scripts/old/hyp07.lua blobby-0.9c/data/scripts/old/hyp07.lua --- blobby-0.8-dfsg/data/scripts/old/hyp07.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/hyp07.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,409 @@ +g=0.28 +pg=0.88 +v0=14.5 +v_p=4.5 +pj=0.44 +r1=31.5 + + + + +function yb(y,vy,t) + + return y+(vy-g/10)*t-1/2*g*t^2 + +end + +function move(x) + + if (posx()2.26) then right() + elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() + end + +end + +function tb(y,vy,height,typ) +local sgn=0 + if (typ==1) + then + sgn=-1 + else + sgn=1 + end + if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 + then return -1 + else + return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) + end +end + +function time(t) + + return 1/5*math.ceil(5*t) + +end + +function pos(x) + + local x1,x2 + x1=4.5*math.ceil((1/4.5)*x) + x2=4.5*math.floor((1/4.5)*x) + if (x1<0) or (x2<0) then return 0 + else + if (math.abs(x1-x) + +function collide(x,y,vx,vy,objx,objy,r2) + + local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) + local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) + local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) + local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) + local t=-1 + if (t1150) then t=-1 end + + return t + +end + + + +function est(x,y,vx,vy,height,typ) + + local collision=1 + local tw,tn,ts=0,0,0 + local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 + + while(collision==1) do + ts=collide(x,y,vx,vy,400,316,7) + if (vx>0) + then + tw=time((768.5-x)/vx) + tn=time((361.5-x)/vx) + else + tw=time((31.5-x)/vx) + tn=time((438.5-x)/vx) + end + local th=time(tb(y,vy,height,typ)) + local t=10000 + + if ((ts>0) and (ts0) and (tn0) and (twt) + then + if (t==ts) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vy=vy-g*t + xr=x + yr=y + vxr=0 + vyr=0 + n=1 + collision=0 + elseif ((t==tn) or (t==tw)) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vx=-vx + vy=vy-g*t + collision=1 + end + else + tr=tr+th + vxr=vx + vyr=vy-g*th + xr=x+vx*th + yr=yb(y,vy,th) + collision=0 + end + end + if (tr<0) + then + return -1,-1,-1,-1,-1,-1 + else + return xr,yr,vxr,vyr,tr,n + end +end + + + + + + + +function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) +local x1,y1,vx1,vy1=0,0,0,0 +local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 +local xpos1=xpos +local ypos1=ypos +for t=0,20,0.2 do + + if (jump==1) then + ypos1=yp(tp(ypos)+t) + end + x1=x+vx*t + if (x1<31.5) then x1=2*31.5-x1 end +-- if (x1>360) then x1=2*360-x1 end + y1=yb(y,vy,t) + + if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then + local dx=x1-xpos1 + local dy=y1-(ypos1+19) + local l=math.sqrt(dx^2+dy^2) + vx1=dx/l + vy1=dy/l + x1=x1+vx1*3 + y1=y1+vy1*3 + vy1=vy1*13.125 + vx1=vx1*13.125 + x2,y2,vx2,vy2,t2,nn=est(x1,y1,vx1,vy1,targety,2) + break + end +end + +return x2,y2 +end + + + + + + +function nothing() +--[[ if (math.abs(xe-xo)>0.1) then + xo=xe + for test=30,0,-3 do + t1=test + y1=yp(t1) + t2=math.floor(tb(y,vy,y1+31.5+25+19,2)) + y2=yb(y,vy,t2) + + x2,y2,vx2,vy2,t2,_=est(x,y,vx,vy,y2+0.1) + t2=t2 + if (vx2>2) then + n=0 + elseif (vx2>0.5) then + n=5 + else + n=13 + end + xi,yi=impact(x2,y2,vx2,vy2,pos(x2-n*4.5),y1,220,1,0) + + if (math.abs(posx()-(x2-n*4.5))/4.580) and (t2-1>t1) and (xi>400) then + break + end + end + end + + move(x2-n*4.5) + if (t2<=t1) then + jump() + end + --]] + +end + + + + + + +function OnOpponentServe() +xdo=0 +xe=0 +s=1 +touch=0 +xodo=0 +change=1 +stop=0 +t1,t2,y1,y2,x,y,vx,vy=0,0,0,0,0,0,0,0 +calc=0 +if (math.abs(pos(posx())-posx())>1) then move(400) else +move(200) +end +xo=0 +c=0 +end + +function OnServe(ballready) +xe=0 +s=1 +xodo=0 +xdo=0 +change=1 +touch=0 +stop=0 +t1,t2,y1,y2,x,y,vx,vy=0,0,0,0,0,0,0,0 +xo=0 +c=0 +if (math.abs(pos(posx())-posx())>1) then move(400) else + if (math.abs(posx()-180)<2) then jump() else move(180) end + end +end + +function OnGame() + +if (change==0) and (touches()=te) then jump() end + if (math.abs(posx()-360)/4.50.2) then + xodo=xdo + imp=0 + x1=0 + for t=27,0,-3 do + t1f=t + y1f=yp(t1f) + t2f=math.floor(tb(y,vy,y1f+h,2)) + if (t2f>0) then +-- debug(0) +-- debug(t2f) + y2f=yb(y,vy,t2f) +-- debug(y2f) + vy2f=vy-g*t2f + x2f,y2f,vx2f,vy2f,t2f,_=est(x,y,vx,vy,y2f-vy2f/10,2) +-- debug(t2f) +-- debug(y2f) +-- debug(vy) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + impt=0 + if (t1f<=t2f-2) then + for x1f=pos(x2f)-25*4.5,pos(x2f)+4.5,4.5 do + impf,_=impact(x2f,y2f,vx2f,vy2f,pos(x1f),y1f,220,1,0) + if (impf>440) and (math.abs(posx()-x1f)/4.5400) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + end + if (imp>400) then break end + end + end + end + t2=t2+1 + end + t2=t2-1 + if (s==1) then + move(x1) + if (t2<=t1+0.1) then jump() end + end + else + move(200) + end +end + +if (bally()<140) then s=0 end + +-- debug(0) +-- debug(x2) +-- debug(ballx()) +-- debug(y2) +-- debug(bally()) +-- debug(vx2) +-- debug(bspeedx()) +-- debug(vy2) +-- debug(bspeedy()) +-- debug(xe) +-- debug(imp) +-- debug(t2) +-- debug(0) +end + + diff -Nru blobby-0.8-dfsg/data/scripts/old/hyp09.lua blobby-0.9c/data/scripts/old/hyp09.lua --- blobby-0.8-dfsg/data/scripts/old/hyp09.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/hyp09.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,503 @@ +g=0.28 +pg=0.88 +v0=14.5 +v_p=4.5 +pj=0.44 +r1=31.5 +p0=0 +p1=0.5 +p2=1 +h=31.5+19+25 + + +estt=0 +nettime=0 +touch=0 +est=0 +p=0.4 +esto=10 + + +function yb(y,vy,t) + + return y+(vy-g/10)*t-1/2*g*t^2 + +end + +function move(x) + + if (posx()2.26) then right() + elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() + end + +end + +function tb(y,vy,height,typ) +local sgn=0 + if (typ==1) + then + sgn=-1 + else + sgn=1 + end + if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 + then return -1 + else + return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) + end +end + +function time(t) + + return 1/5*math.ceil(5*t) + +end + +function pos(x) + + local x1,x2 + x1=4.5*math.ceil((1/4.5)*x) + x2=4.5*math.floor((1/4.5)*x) + if (x1<0) or (x2<0) then return 0 + else + if (math.abs(x1-x)146) then + return (v1p/0.88-1/2+math.sqrt((v1p/0.88-1/2)^2-(144.5-y1p)/0.44)) + else + return 0 + end +end + +function time(t) +return 1/5*math.ceil(5*t) +end + + +-- + +function collide(x,y,vx,vy,objx,objy,r2) + + local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) + local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) + local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) + local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) + local t=-1 + if (t1150) then t=-1 end + + return t + +end + + + +function estimate(x,y,vx,vy,height,typ) + + local collision=1 + local tw,tn,ts=0,0,0 + local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 + + while(collision==1) do + ts=collide(x,y,vx,vy,400,316,7) + if (vx>0) + then + tw=time((768.5-x)/vx) + tn=time((361.5-x)/vx) + else + tw=time((31.5-x)/vx) + tn=time((438.5-x)/vx) + end + local th=time(tb(y,vy,height,typ)) + local t=10000 + + if ((ts>0) and (ts0) and (tn0) and (twt) + then + if (t==ts) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vy=vy-g*t + xr=x + yr=y + vxr=0 + vyr=0 + n=1 + collision=0 + elseif ((t==tn) or (t==tw)) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vx=-vx + vy=vy-g*t + collision=1 + end + else + tr=tr+th + vxr=vx + vyr=vy-g*th + xr=x+vx*th + yr=yb(y,vy,th) + collision=0 + end + end + if (tr<0) + then + return -1,-1,-1,-1,-1,-1 + else + return xr,yr,vxr,vyr,tr,n + end +end + + +function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) +local x1,y1,vx1,vy1=0,0,0,0 +local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 +local xpos1=xpos +local ypos1=ypos +for t=0,20,0.2 do + + if (jump==1) then + ypos1=yp(tp(ypos)+t) + end + x1=x+vx*t + if (x1<31.5) then x1=2*31.5-x1 end + if (x1>368.5) then x1=2*368.5-x1 end + y1=yb(y,vy,t) + + if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then + local dx=x1-xpos1 + local dy=y1-(ypos1+19) + local l=math.sqrt(dx^2+dy^2) + vx1=dx/l + vy1=dy/l + x1=x1+vx1*3 + y1=y1+vy1*3 + vy1=vy1*13.125 + vx1=vx1*13.125 + x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) + break + end +end + +return x2,y2,x1,y1,vx1,vy1 +end + +function lob() + + if (math.abs(est-esto)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto=est + imp=0 + x1=0 + for t=33,0,-3 do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5700) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + end + if (impt>imp) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + end + if (imp>740) then break end + end + end + t2=t2+1 + end + t2=t2-1 + if (x1>0) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else + move(est) + end + +end + + +function attack() + + if (math.abs(est-esto)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 + h2=900 +-- debug(-10) + esto=est + imp=0 + x1=0 + for t=33,0,-3 do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.5+10) and (x1f<360) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + xat=xaf + yat=yaf + vxat=vxaf + vyat=vyaf + break + end + end + h2t=yb(yat,vyat,(400-xat)/vxat) + if (h2t316+31.5) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + xa=xat + ya=yat + vxa=vxat + vya=vyat + end + h2=yb(ya,vya,(400-xa)/vxa) + if (h2<316+31.5+10) and (h2>316+31.5) then break end + end + end + t2=t2+1 + end + t2=t2-1 + + if (x1>0) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() + end + else + move(est) + end +end + + +function netp() + + if (math.abs(est-esto)>0.2) then + x1,y1,t1,x2,y2,t2,vx2,vy2,x1f,y1f,t1f,x2f,y2f,t2f,vx2f,vy2f,x1t,y1t,t1t,x2t,y2t,t2t,vx2t,vy2t=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + t2g=0 +-- debug(-10) + esto=est + imp=0 + x1=0 + for t=33,0,-3 do + if (t==0) then j=0 else j=1 end + t1f=t + y1f=yp(t1f) + t2g=math.floor(tb(y,vy,y1f+h,2)) + y2f=yb(y,vy,t2g) + vy2f=vy-g*t2g + x2f,y2f,vx2f,vy2f,t2f,nn=estimate(x,y,vx,vy,y2f-vy2f/30,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + if (t1f+math.abs(tp2(posy(),vp))1) and (t2f>1) and ((math.abs(posx()-(x2f+4.5))/4.5400) and (math.abs(posx()-x1f)/4.50) then + impt=impf + x1t=x1f + y1t=y1f + t1t=t1f + x2t=x2f + y2t=y2f + t2t=t2f + vx2t=vx2f + vy2t=vy2f + break + end + end + if (impt>imp) and (impt<431.5) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + end + if (imp>428) then break end + end + end + t2=t2+1 + end + t2=t2-1 + if (x1>0) and (est<368.5) then + move(x1) + if (t2<=t1+0.1) and (y1>146) then + jump() end + else + move(est) + end + +end + + +function OnOpponentServe() +y1p=144.5 +if (math.abs(pos(posx())-posx())>1) then move(400) else +move(200) +end +valid=1 + + +end + +function OnServe(ballready) +y1p=144.5 + est=700 + + if (math.abs(pos(posx())-posx())>1) then + move(400) + else + if (math.abs(posx()-180)<2) then + jump() + else + move(180) + end + end +valid=1 +end + + + +function OnGame() + +yp2=y1p +y1p=oppy() +vp=y1p-yp2 + + +esttold=estt +netold=net +toucho=touch +touch=touches() +if (touch400-31.5) then + move (250) + elseif (est<400-10) and (est>400-22) then + move(200) + elseif (est<400) and (est>400-10) then + move(180) + else + move(230) +end + +end diff -Nru blobby-0.8-dfsg/data/scripts/old/hyp8.lua blobby-0.9c/data/scripts/old/hyp8.lua --- blobby-0.8-dfsg/data/scripts/old/hyp8.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/hyp8.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,531 @@ +g=0.28 +pg=0.88 +v0=14.5 +v_p=4.5 +pj=0.44 +r1=31.5 +p0=0 +p1=0.5 +p2=1 +h=31.5+19+25 + + +estt=0 +nettime=0 +touch=0 +est=0 +p=0.4 +esto=10 + + +function yb(y,vy,t) + + return y+(vy-g/10)*t-1/2*g*t^2 + +end + +function move(x) + + if (posx()2.26) then right() + elseif (posx()>x) and (math.abs(posx()-x)>2.26) then left() + end + +end + +function tb(y,vy,height,typ) +local sgn=0 + if (typ==1) + then + sgn=-1 + else + sgn=1 + end + if vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0 + then return -1 + else + return -1/10+vy/g+sgn*math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) + end +end + +function time(t) + + return 1/5*math.ceil(5*t) + +end + +function pos(x) + + local x1,x2 + x1=4.5*math.ceil((1/4.5)*x) + x2=4.5*math.floor((1/4.5)*x) + if (x1<0) or (x2<0) then return 0 + else + if (math.abs(x1-x) + +function collide(x,y,vx,vy,objx,objy,r2) + + local t1=time(math.max(tb(y,vy,objy-(r1+r2),1)-0.2,0)) + local t2=time(tb(y,vy,objy+(r1+r2),1)+0.2) + local t3=time(math.max(tb(y,vy,objy+(r1+r2),2)-0.2,0)) + local t4=time(tb(y,vy,objy-(r1+r2),2)+0.2) + local t=-1 + if (t1150) then t=-1 end + + return t + +end + + + +function estimate(x,y,vx,vy,height,typ) + + local collision=1 + local tw,tn,ts=0,0,0 + local tr,xr,yr,vxr,vyr,n=0,0,0,0,0,0 + + while(collision==1) do + ts=collide(x,y,vx,vy,400,316,7) + if (vx>0) + then + tw=time((768.5-x)/vx) + tn=time((361.5-x)/vx) + else + tw=time((31.5-x)/vx) + tn=time((438.5-x)/vx) + end + local th=time(tb(y,vy,height,typ)) + local t=10000 + + if ((ts>0) and (ts0) and (tn0) and (twt) + then + if (t==ts) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vy=vy-g*t + xr=x + yr=y + vxr=0 + vyr=0 + n=1 + collision=0 + elseif ((t==tn) or (t==tw)) + then + tr=tr+t + x=x+vx*t + y=yb(y,vy,t) + vx=-vx + vy=vy-g*t + collision=1 + end + else + tr=tr+th + vxr=vx + vyr=vy-g*th + xr=x+vx*th + yr=yb(y,vy,th) + collision=0 + end + end + if (tr<0) + then + return -1,-1,-1,-1,-1,-1 + else + return xr,yr,vxr,vyr,tr,n + end +end + + +function impact(x,y,vx,vy,xpos,ypos,targety,jump,move) +local x1,y1,vx1,vy1=0,0,0,0 +local x2,y2,vx2,vy2,t2,nn=0,0,0,0,0,0 +local xpos1=xpos +local ypos1=ypos +for t=0,20,0.2 do + + if (jump==1) then + ypos1=yp(tp(ypos)+t) + end + x1=x+vx*t + if (x1<31.5) then x1=2*31.5-x1 end + if (x1>368.5) then x1=2*368.5-x1 end + y1=yb(y,vy,t) + + if ((xpos1-x1)^2+(ypos1+19-y1)^2<(31.5+25)^2) then + local dx=x1-xpos1 + local dy=y1-(ypos1+19) + local l=math.sqrt(dx^2+dy^2) + vx1=dx/l + vy1=dy/l + x1=x1+vx1*3 + y1=y1+vy1*3 + vy1=vy1*13.125 + vx1=vx1*13.125 + x2,y2,vx2,vy2,t2,nn=estimate(x1,y1,vx1,vy1,targety,2) + break + end +end + +return x2,y2,x1,y1,vx1,vy1 +end + + +function netp() + + if (math.abs(est-esto)>0.2) then + esto=est + imp=0 + x1=0 + for t=27,0,-3 do + t1f=t + y1f=yp(t1f) + t2f=math.floor(tb(y,vy,y1f+h,2)) + if (t2f>0) then + y2f=yb(y,vy,t2f) + vy2f=vy-g*t2f + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/10,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + impt=0 + if (t1f<=t2f-2) and (math.abs(posx()-x2f)/4.5400) and (math.abs(posx()-x1f)/4.5imp) and (impt<431.5) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + end + if (imp>415) then break end + end + end + end + t2=t2+1 + end + + t2=t2-1 + move(x1) + if (t2<=t1+0.1) and (y1>150) then jump() end + +end + + + +function lob() + + if (math.abs(est-esto)>0.2) then + esto=est + imp=0 + x1=0 + for t=27,0,-3 do + t1f=t + y1f=yp(t1f) + t2f=math.floor(tb(y,vy,y1f+h,2)) + if (t2f>0) then + y2f=yb(y,vy,t2f) + vy2f=vy-g*t2f + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/10,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + impt=0 + if (t1f<=t2f-2) then + for x1f=pos(x2f)+4.5,pos(x2f)-15*4.5,-4.5 do + impf,_=impact(x2f,y2f,vx2f,vy2f,pos(x1f),y1f,220,1,0) + if (impf>700) and (math.abs(posx()-x1f)/4.5imp) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + end + if (imp>750) then break end + end + end + end + t2=t2+1 + end + + t2=t2-1 + move(x1) + if (t2<=t1+0.1) then jump() end + +end + + + +function attack() +h2=900 + if (math.abs(est-esto)>0.2) then + esto=est + imp=0 + x1=0 + for t=27,0,-3 do + t1f=t + y1f=yp(t1f) + t2f=math.floor(tb(y,vy,y1f+h,2)) + if (t2f>0) then + y2f=yb(y,vy,t2f) + vy2f=vy-g*t2f + x2f,y2f,vx2f,vy2f,t2f,_=estimate(x,y,vx,vy,y2f-vy2f/10,2) + t1f=math.floor(tp(y2f-h)) + y1f=yp(t1f) + impt=0 + if (t1f<=t2f-2) then + for x1f=pos(x2f)-25*4.5,pos(x2f)+4.5,4.5 do + impf,_,xaf,yaf,vxaf,vyaf=impact(x2f,y2f,vx2f,vy2f,pos(x1f),y1f,220,1,0) + if (impf>400) and (math.abs(posx()-x1f)/4.5316+7+31.5) then + imp=impt + x1=x1t + y1=y1t + t1=t1t + x2=x2t + y2=y2t + t2=t2t + vx2=vx2t + vy2=vy2t + xa=xat + ya=yat + vxa=vxat + vya=vyat + end + h2=yb(ya,vya,(400-xa)/vxa) + if (h2<316+7+31.5+20) and (h2>316+7+20) then break end + end + end + end + t2=t2+1 + t2t=t2t+1 + end + +if (imp>400) then + t2=t2-1 + move(x1) + if (t2<=t1+0.1) then jump() end + else + t2t=t2t-1 + move(x1t) + if (t2t<=t1t+0.1) then jump() end +end + +end + + + + + + +function OnOpponentServe() + +if (math.abs(pos(posx())-posx())>1) then move(400) else +move(200) +end +valid=1 +end + +function OnServe(ballready) + est=700 + + if (math.abs(pos(posx())-posx())>1) then + move(400) + else + if (math.abs(posx()-180)<2) then + jump() + else + move(180) + end + end +valid=1 +end + + + +function OnGame() + +esttold=estt +netold=net + + +x,y,vx,vy=ballx(),bally(),bspeedx(),bspeedy() +estt,_,_,_,tnet,net=estimate(x,y,vx,vy,220) + +if (math.abs(esttold-estt)<0.1) then -- Schutz gegen Fehler bei der estimate-Funktion während Netz/Wandkollisionen + est=estt +end + +-- phase1 -> Eigener Angriff +-- phase2 -> Gegner hat den Ball +-- phase3 -> Netzball blocken +-- phase4 -> Ball ist nicht mehr gültig + +if (bally()<144) then valid=0 end + +if (net==1) then -- klare Netzkollision + if (yb(y,vy,(380-x)/vx)>370) then + phase=3 + else + phase=4 + end + else + if (netold==1) then -- Ball hat gerade das Netz getroffen + nettime=8 -- Rest des Kollisionsskriptes abarbeiten + phase=3 + elseif (netold==0) and (nettime>0) then + nettime=nettime-1 -- Zeit runterzählen für den Rest des Kollisionsskriptes + phase=3 + else -- Keine direkte Netzkollision und deren Nachwirkungen + if (est>431.5) and (est<460) and (oppx()<700) then -- Ball kommt nahe ans Netz und der Gegner kann blocken + phase=3 + elseif (est<400-31.5) then -- eigener Angriff + phase=1 + else -- gegnerischer Angriff + phase=2 + end + end +end + +if (valid==0) then phase=5 end -- Ãœberschreibt alle vorherigen Berechnungen + +toucho=touch +touch=touches() + +if (touch=tnet) then jump() end + if (math.abs(posx()-360)/4.5ball_radius) and (x<361.5) then impact=x end +if (x361.5) + then + if (ballx()<361.5) + then + if(ypos(timetox(361.5))3) then moveto(x-40) end + if (timetoy(333)<10) then jump() end + else + x=estimate(333) + if (math.abs((x-20)-posx())>3) then moveto(x-20) end + if (timetoy(333)<10) then jump() end + end +end + +function ueberspielen() + +if (posx()<280) + then + x=estimate(437) + if (math.abs((x-30)-posx())>3) then moveto(x-30) end + if (timetoy(437)<24) then jump() end + else + x=estimate(437) + if (math.abs((x-15)-posx())>3) then moveto(x-15) end + if (timetoy(437)<24) then jump() end + end +end + + +function schmettern() + x=estimate(437) + t=timetoy(437) + if (t>24) and (math.abs((x-90)-posx())>3) then moveto(x-90) end + if (t<24) then jump() end + if (t<5) then right() end +end + +-- [Hauptprogramm] + +function OnServe(ballready) + +if (new==nil) then new=1 end +if (new==1) then + j=math.random() + p=math.random(30,55) + new=2 + end + +if (j>0.5) + then + if (math.abs(posx()-200)>3) then moveto(200) else jump() end + else + if (math.abs(posx()-(200-p))>3) then moveto(200-p) else jump() end + end +end + +function OnOpponentServe() +moveto(200) +end + +function OnGame() +new=1 +x=estimate(220.5) + +if (x<420) + then + if (touches()==0) + then + moveto(x) + newp=1 + end + if (touches()==1) + then + if (newp==1) + then + p1=math.random() + newp=2 + end + if (oppx()>300) + then + if(p1>0.4) + then + ueberspielen() + else + schmettern() + end + else + if(p1>0.6) + then + ueberspielen() + else + schmettern() + end + end + end + if (touches()==2) + then + retten() + end + else + moveto(200) +end + +end diff -Nru blobby-0.8-dfsg/data/scripts/old/hyperion6.lua blobby-0.9c/data/scripts/old/hyperion6.lua --- blobby-0.8-dfsg/data/scripts/old/hyperion6.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/old/hyperion6.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,331 @@ +-- Dies ist der BlobbyVolley2 Bot "Hyperion" +-- geschrieben und getestet wurde der Bot mit der SVN-Version +-- Die Version Blobby0.6 hatte verschiedene Bugs, unter anderem bei der oppx() und der estimate() Funktion +-- +-- Hyperion ver. 0.6 + +-- - Einige Konstanten die die physikalische Welt in BlobbyVolley2 beschreiben + +g=0.28 +g_p=0.88 +v0=14.5 +v_p=4.5 +jb_p=0.44 +r1=31.5 + +-- + + +-- - kleine unkomplizierte Hilfsfunktionen die ich benötige + +function max(a,b) + if (a>b) then + return a + else + return b + end +end + +function min(a,b) + if (a2.6) then right() + elseif (posx()>x) and (math.abs(posx()-x)>2.6) then left() + end +end + +function t1_y(y,vy,height) +-- Eingabe: Position und Geschwindigkeit des Balles, Höhe die der Ball erreichen soll +-- Ausgabe: Ausgabe der Zeit bis zur Höhe height + if (vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0) then + return -1 + else + return -1/10+vy/g-math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) + end +end + +function t2_y(y,vy,height) +-- Eingabe: Position und Geschwindigkeit des Balles, Höhe die der Ball erreichen soll +-- Ausgabe: Ausgabe der Zeit bis zur Höhe height + if (vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g<0) then + return -1 + else + return -1/10+vy/g+math.sqrt( vy^2/g^2-vy/(5*g)+1/100+2*(y-height)/g ) + end +end + +function y_p(y,t) +-- Eingabe: Position und Geschwindigkeit des Players, Zeitpunkt an dem man die y-Koordinate des Players wissen möchte +-- Ausgabe: Höhe des Players nach der Zeit t + return y+(v0+jb_p/2+g_p/10)*t-1/2*(g_p-jb_p)*t^2 +end + +tp_peak=(14.5+0.44/2+0.88/10)/(0.88-0.44) +yp_max=y_p(144.5,tp_peak) + +function time(t) + return 1/5*math.ceil(5*t) +end + +function t2_yp(y,vy,height) +y=144.5 + return (v0+jb_p/2+g_p/10)/(g_p-jb_p)+math.sqrt((v0+jb_p/2+g_p/10)^2/(g_p-jb_p)^2+2*y/(g_p-jb_p)) +end +-- + + +-- - Komplizierte Funktionen die die Game-Engine nachbilden und so Einschlagpunkte, etc. berechnen. + +function collide(x,y,vx,vy,x2,y2,r2) +-- Berechnet, ob und nach welcher Zeit der Ball im Zustand (x,y,vx,vy) mit der Kugel an (x2,y2) mit Radius r2 kollidiert +local leftb=x2-r2-r1 +local rightb=x2+r2+r1 +local lowerb=y2-r2-r1 +local upperb=y2+r2+r1 + +local txlb=time((leftb-x)/vx) -- Zeit zur linken Begrenzung +local txrb=time((rightb-x)/vx) -- Zeit zur rechten Begrenzung +local tyla=time(t1_y(y,vy,lowerb)) --untere Grenze steigend (ascending) +local tyld=time(t2_y(y,vy,lowerb)) --untere Grenze fallend (descending) +local tyua=time(t1_y(y,vy,upperb)) --obere Grenze steigend (ascending) +local tyud=time(t2_y(y,vy,upperb)) --obere Grenze fallend (descending) +local tp=time(vy/g-1/10) -- Zeit bis die Ballkurve auf dem Höhepunkt ist (kann in der Vergangenheit liegen) + +local t1,t2,t_coll=0,0,-1 + +if (vx>0) then + t1=max(max(txlb,tyla),0) + t2=min(txrb,tyld) + else + t1=max(max(txrb,tyla),0) + t2=min(txlb,tyld) +end + +if (t10) + then + t_wall=time((768.5-x)/vx) + t_net=time((361.5-x)/vx) + else + t_wall=time((31.5-x)/vx) + t_net=time((438.5-x)/vx) + end + local t=10000 + if ((t_netsphere>0) and (t_netsphere0) and (t_net0) and (t_wallt) then + if (t==t_netsphere) then + t_ret=t_ret+t + vx_ret=0 + vy_ret=0 + x_ret=400 + y_ret=316 + collision=0 + end + if (t==t_net) or (t==t_wall) then + t_ret=t_ret+t + x=x+vx*t + y=y_b(y,vy,t) + vx=-vx + vy=vy-g*t + collision=1 + end + else + t_ret=t_ret+t_height + vx_ret=vx + vy_ret=vy-g*t_height + x_ret=x+vx*t_height + y_ret=y_b(y,vy,t_height) + collision=0 + end + + +end -- while Ende +return x_ret,y_ret,vx_ret,vy_ret,t_ret +end + + + + +function impact(x,y,vx,vy,xpos,ypos) +-- schätzt den Einschlagsort des Balles wenn er mit dem Blobby an Position xpos kollidiert ist und dann losfliegt. +-- Funktioniert mit minimalem Fehler + +r1=31.5 +r2=25 +--local x,y,vx,vy,t1=estimate_t(x,y,vx,vy,(ypos+19+25)+31.5) Die Wete haben schon nahe genug zu sein +local t=time(collide(x,y,vx,vy,xpos,ypos+19,25)) +if(t>0) then + x=x+vx*t + y=y_b(y,vy,t) + dx=x-xpos + dy=y-(ypos+19) + l=math.sqrt(dx^2+dy^2) + vx=dx/l + vy=dy/l + x=x+vx*3 + y=y+vy*3 + vy=vy*13.125 + vx=vx*13.125 +-- x=x+vx/5 +-- y=y+vy/5 + x,y,vx,vy,t=estimate_t(x,y,vx,vy,220.5) + return x,y,vx,vy,t +else + return -1,-1,-1,-1,-1 +end + +end -- Funktionsende + +function xtoplayto(target,height) + +local x,y,vx,vy,t=estimate_t(ballx(),bally(),bspeedx(),bspeedy(),height+(25+19)+31.5+5) +local xpos=estimate_t(ballx(),bally(),bspeedx(),bspeedy(),height+(25+19)+31.5) +local sgn=0 +if (x + +-- - High-Level Funktionen die bestimmen wo man s + +function stellen(tox,height) +--t2_yp +--t2_y +if (tox<390) then + +elseif (390410) then + +end + +move(xplayto(tox,posy())) +end + + +function schmettern() + +end + +function ueberspielen() + +end + + + +-- + +-- - Die Hauptfunktionen des Spiels +function OnOpponentServe() +end + +function OnServe(ballready) +if (math.abs(math.floor(posx()/4.5)-posx()/4.5)<0.4) + then + if(math.abs(180-posx())<2) then jump() else moveto(180) end + else + moveto(400) + end + old=5 +end + +function OnGame() + + + + +x1=ballx() +y1=bally() +vx1=bspeedx() +vy1=bspeedy() +x2=oppx() +y2=163.5 +r2=25 + +xe=estimate_t(x1,y1,vx1,vy1,220.5) +--debug(xe) +-- debug(x2) +xr,yr,vxr,vyr,tr=impact(x1,y1,vx1,vy1,x2,144.5) + + +-- debug(xr) +-- debug(0) + + +if (xe<400) then + + if (touches()==0) then + test=xtoplayto(320,144.5) + move(test) + else + test=xtoplayto(400,144.5) + move(test-3.1) + end + + +elseif (xe==400) then + move(180) +else + move(180) +end +old=touches() +end \ No newline at end of file diff -Nru blobby-0.8-dfsg/data/scripts/reduced.lua blobby-0.9c/data/scripts/reduced.lua --- blobby-0.8-dfsg/data/scripts/reduced.lua 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/data/scripts/reduced.lua 2011-11-06 15:06:50.000000000 +0000 @@ -0,0 +1,183 @@ +-- Reduced but very effective bot. +-- Borrows from axji.lua, com_10.lua and com_11.lua as distributed with +-- Blobby Volley. +-- Copyright (C) 2010 Soeren D. Schulze +-- The terms of the GPLv2 or later apply. +-- See the Blobby Volley distribution for the license text. + +modeLock = 0 +timeto = 0 +target = 0 +naivetarget = 0 +estimbspeedx = 0 +direct = true +servrand = nil + +-- Knostanten +CONST_BALL_RADIUS = 31.5 + +CONST_MITTE = 400 + +CONST_BLOBBY_HOEHE = 89 +CONST_BLOBBY_KOPF_RADIUS = 25 +CONST_BLOBBY_BAUCH_RADIUS = 33 + +CONST_NETZ_RADIUS = 7 +CONST_NETZ_HOEHE = 157 + +CONST_FELD_LAENGE = 800 +CONST_BALL_RADIUS = 31.5 +CONST_GROUND_PLANE = 100 + +CONST_BALL_GRAVITY = 0.28 + +CONST_MITTE = CONST_FELD_LAENGE/2 +CONST_RECHTER_RAND = CONST_FELD_LAENGE - CONST_BALL_RADIUS + +-- Berührungsebene des Balls falls er ans Netz kommt +CONST_NETZ_LINKS = CONST_MITTE - CONST_NETZ_RADIUS - CONST_BALL_RADIUS +CONST_NETZ_RECHTS = CONST_MITTE + CONST_NETZ_RADIUS + CONST_BALL_RADIUS + +CONST_BLOBBY_HOEHE = 89 +CONST_BLOBBY_KOPF_RADIUS = 25 +CONST_BLOBBY_BAUCH_RADIUS = 33 +CONST_BLOBBY_KOPF_BERUEHRUNG = CONST_GROUND_PLANE + CONST_BLOBBY_HOEHE + CONST_BALL_RADIUS +CONST_BLOBBY_MAXJUMP = 393.625 + +function OnServe(ballready) + if servrand == nil then + servrand = math.random() + end + moveto(ballx() + servrand * 5) + if ballready and math.abs(posx() - (ballx() + servrand * 5)) < 3 then + jump() + servrand = nil + end +end + +function OnOpponentServe() + moveto(100) +end + +function OnGame() + estimImpactHigh() + + if (not (target == nil)) + and naivetarget < 400 + and (modeLock == 1 + or timeto > math.abs(posx()-highPlayPos())/4.5 + 26) + and touches() < 3 + then + if (timeto < 30) then + modeLock = 1 + else + modeLock = 0 + servrand = nil + end + highPlay() + else + modeLock = 0 + servrand = nil + estimImpactLow() + if (not (target == nil)) + and ((estimbspeedx > 0 and timeto > (target-posx()-10)/4.5) + or (estimbspeedx < 0 and timeto > (posx()-target-10)/4.5) + or naivetarget >= 400) then + lowPlay() + else + -- HEELLPPP... + if not (target == nil) + and naivetarget < 400 then + -- This often saves your ass if you're standing inside a + -- corner and the ball bounces from the wall or the net. + lowPlay() + jump() + end + end + end +end + +function highPlayPos() + if estimbspeedx < 0 then + -- safety againt fast balls + return target - 50 - estimbspeedx*5 + else + return target - 50 + end +end + +function highPlay() + if (target > 400) then + moveto(100) + else + moveto(highPlayPos()) + -- 33 time units for jumping to max height + -- Regarding naive target here. + -- If the ball really bounces back, it would be a bad idea to jump... + if servrand == nil then + servrand = math.random() + end + if naivetarget < 400 and timeto < 28 + servrand then + jump() + end + end +end + + +function lowPlay() + if (target > 400) then + moveto(100) + else + moveto(target) + end +end + +function estimImpactHigh() + estimImpact2(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_MAXJUMP - 25,1) +end + +function estimImpactLow() + estimImpact2(ballx(),bally(),bspeedx(),bspeedy(),CONST_BLOBBY_KOPF_BERUEHRUNG,1) +end + +function estimImpact2(bx,by,vbx,vby,destY,Frage) -- erlaubt ein besseres Estimate mit ein paar unbeding nötigen Angaben + bgrav = 0.28 + + if ((vby^2)-(-2*bgrav*(by-destY))) < 0 then + target = nil + return + end + time1 =(-vby-math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) + --time2 =(-vby+math.sqrt((vby^2)-(-2*bgrav*(by-destY))))/(-bgrav) + timeto = time1 + + if (timeto < 0) then + target = nil + return + end + naivetarget = (vbx * time1) + bx + resultX = naivetarget + estimbspeedx=bspeedx() + + direct = true + + if(resultX > CONST_RECHTER_RAND) then + resultX = 2 * CONST_RECHTER_RAND - resultX + estimbspeedx=-estimbspeedx + direct = true + end + + if(resultX < CONST_BALL_RADIUS) then -- korrigieren der Appraller an der linken Ebene + resultX = 2 * CONST_BALL_RADIUS - resultX + estimbspeedx=-estimbspeedx + direct = false + end + + if (estimbspeedx > 0) and (resultX > CONST_NETZ_LINKS) then + direct = false + resultX = 2 * CONST_NETZ_LINKS - resultX + estimbspeedx=-estimbspeedx + end + + target = resultX +end Binary files /tmp/0srkP_WiN0/blobby-0.8-dfsg/data/sounds/chat.wav and /tmp/zGIqAWId6S/blobby-0.9c/data/sounds/chat.wav differ diff -Nru blobby-0.8-dfsg/debian/blobby-data.install blobby-0.9c/debian/blobby-data.install --- blobby-0.8-dfsg/debian/blobby-data.install 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/blobby-data.install 2011-11-11 11:25:48.000000000 +0000 @@ -1 +1,3 @@ usr/share/blobby/*.zip +usr/share/blobby/rules.lua +usr/share/blobby/lang_*.xml diff -Nru blobby-0.8-dfsg/debian/blobby.desktop blobby-0.9c/debian/blobby.desktop --- blobby-0.8-dfsg/debian/blobby.desktop 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/blobby.desktop 2011-10-20 10:53:49.000000000 +0000 @@ -2,7 +2,7 @@ Type=Application Version=1.0 Name=Blobby Volley 2 -GenericName=Volley-Ball Game +GenericName=Volleyball Game Icon=blobby Exec=blobby Terminal=false diff -Nru blobby-0.8-dfsg/debian/blobby.dirs blobby-0.9c/debian/blobby.dirs --- blobby-0.8-dfsg/debian/blobby.dirs 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/debian/blobby.dirs 2011-10-20 10:35:50.000000000 +0000 @@ -0,0 +1,3 @@ +usr/share/icons/hicolor/32x32/apps +usr/share/icons/hicolor/64x64/apps +usr/share/pixmaps diff -Nru blobby-0.8-dfsg/debian/blobby.install blobby-0.9c/debian/blobby.install --- blobby-0.8-dfsg/debian/blobby.install 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/blobby.install 2011-10-20 10:35:31.000000000 +0000 @@ -1,5 +1,4 @@ debian/blobby.desktop usr/share/applications -debian/blobby.xpm usr/share/pixmaps usr/bin/blobby usr/games usr/share/blobby/config.xml usr/share/blobby/inputconfig.xml diff -Nru blobby-0.8-dfsg/debian/blobby.xpm blobby-0.9c/debian/blobby.xpm --- blobby-0.8-dfsg/debian/blobby.xpm 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/blobby.xpm 1970-01-01 00:00:00.000000000 +0000 @@ -1,402 +0,0 @@ -/* XPM */ -static char * blobby_xpm[] = { -"32 32 367 2", -" c None", -". c #E4E5E5", -"+ c #F9F8F9", -"@ c #FDFDFD", -"# c #FAFAFA", -"$ c #F3F3F3", -"% c #EDEDED", -"& c #F2F2F2", -"* c #F1F1F1", -"= c #EEEFEF", -"- c #ECECEC", -"; c #F4F4F4", -"> c #F7F7F7", -", c #FCFCFC", -"' c #FEFEFE", -") c #F8F8F8", -"! c #E0E0E0", -"~ c #FBFBFB", -"{ c #FFFFFF", -"] c #F6F6F6", -"^ c #F7F8F8", -"/ c #EDEEEE", -"( c #F9F9F9", -"_ c #F0F0F0", -": c #E7E8E7", -"< c #DEDFDF", -"[ c #D4D4D5", -"} c #C6C5C6", -"| c #F2F3F3", -"1 c #F2F2F3", -"2 c #EEEEEE", -"3 c #E9E9E9", -"4 c #DFE0E0", -"5 c #DCDCDC", -"6 c #DFDFDF", -"7 c #DDDEDD", -"8 c #DCDCDD", -"9 c #D2D2D2", -"0 c #CAC9C9", -"a c #FDFDFC", -"b c #F3F4F4", -"c c #FAFAFB", -"d c #E2E2E1", -"e c #E6E6E6", -"f c #EBEBEB", -"g c #EAEAEA", -"h c #E7E7E7", -"i c #E5E6E5", -"j c #DDDDDD", -"k c #DCDBDC", -"l c #E2E2E2", -"m c #E0E1E0", -"n c #D4D4D4", -"o c #C4C4C4", -"p c #C6C5C5", -"q c #FBFAFB", -"r c #E6E7E7", -"s c #E8E9E9", -"t c #D8D8D8", -"u c #DBDADA", -"v c #DADADA", -"w c #D7D7D7", -"x c #D1D1D2", -"y c #C3C3C3", -"z c #BBBBBB", -"A c #D0D0D0", -"B c #F6F7F7", -"C c #F7F8F7", -"D c #E6E7E6", -"E c #E9EAEA", -"F c #E4E4E3", -"G c #E4E4E4", -"H c #E7E8E8", -"I c #E2E3E2", -"J c #DEDEDE", -"K c #D3D4D4", -"L c #D1D1D1", -"M c #D0D0D1", -"N c #CBCBCC", -"O c #C4C3C3", -"P c #B4B4B4", -"Q c #ACACAC", -"R c #EFEFEF", -"S c #D9D9D9", -"T c #DBDBDB", -"U c #E1E1E1", -"V c #DFDFDE", -"W c #D1D0D1", -"X c #C9C8C8", -"Y c #C9C9C9", -"Z c #BFBFBF", -"` c #B0B0B0", -" . c #AAAAAA", -".. c #A5A5A5", -"+. c #EAEBEB", -"@. c #E8E9E8", -"#. c #E4E5E4", -"$. c #E8E8E8", -"%. c #D6D6D6", -"&. c #D8D9D8", -"*. c #D3D2D3", -"=. c #CDCDCD", -"-. c #C2C2C2", -";. c #BFBEBF", -">. c #C0BFC0", -",. c #BDBDBD", -"'. c #B9B8B8", -"). c #AEADAD", -"!. c #A0A0A0", -"~. c #A1A1A1", -"{. c #959696", -"]. c #E3E3E3", -"^. c #E3E2E3", -"/. c #E3E4E3", -"(. c #E0DFDF", -"_. c #DDDCDC", -":. c #C8C8C8", -"<. c #CFCFCF", -"[. c #CBCBCB", -"}. c #BEBEBE", -"|. c #B6B6B6", -"1. c #B5B4B4", -"2. c #B0B1B0", -"3. c #999998", -"4. c #8E8E8E", -"5. c #D8D8D9", -"6. c #E0E0DF", -"7. c #DEDDDD", -"8. c #D5D5D5", -"9. c #CACACA", -"0. c #BCBCBC", -"a. c #C1C0C1", -"b. c #C0C0C0", -"c. c #B9BAB9", -"d. c #ABABAB", -"e. c #A8A8A8", -"f. c #A3A3A3", -"g. c #969696", -"h. c #898889", -"i. c #898888", -"j. c #C8C8C9", -"k. c #CECECE", -"l. c #DAD9DA", -"m. c #D6D5D6", -"n. c #C5C5C5", -"o. c #B2B2B2", -"p. c #B5B5B4", -"q. c #BCBDBC", -"r. c #B7B7B7", -"s. c #B3B3B3", -"t. c #AAA9A9", -"u. c #A2A2A2", -"v. c #9A9A9A", -"w. c #929292", -"x. c #808080", -"y. c #7E7E7E", -"z. c #807F80", -"A. c #D2D2D3", -"B. c #D2D1D2", -"C. c #C7C7C7", -"D. c #BABABA", -"E. c #AFAFAF", -"F. c #B4B4B3", -"G. c #A2A3A2", -"H. c #989898", -"I. c #929192", -"J. c #8A8A89", -"K. c #7A7B7A", -"L. c #707071", -"M. c #7D7D7D", -"N. c #B6B7B6", -"O. c #BABAB9", -"P. c #B8B9B8", -"Q. c #B5B5B5", -"R. c #A6A6A6", -"S. c #9C9C9C", -"T. c #90908F", -"U. c #8A8A8A", -"V. c #8C8C8C", -"W. c #878787", -"X. c #807F7E", -"Y. c #767676", -"Z. c #676768", -"`. c #717171", -" + c #B3B2B2", -".+ c #C2C3C2", -"++ c #C4C4C3", -"@+ c #C1C1C1", -"#+ c #B4B3B3", -"$+ c #B8B8B8", -"%+ c #B7B6B6", -"&+ c #AFAEAF", -"*+ c #9D9D9D", -"=+ c #9FA0A0", -"-+ c #989999", -";+ c #939394", -">+ c #888988", -",+ c #7F807F", -"'+ c #7C7C7C", -")+ c #777676", -"!+ c #6E6E6E", -"~+ c #616262", -"{+ c #656565", -"]+ c #B1B1B1", -"^+ c #B8B9B9", -"/+ c #B7B8B8", -"(+ c #B4B3B4", -"_+ c #B0AFB0", -":+ c #ADADAD", -"<+ c #959495", -"[+ c #949494", -"}+ c #999999", -"|+ c #959595", -"1+ c #909091", -"2+ c #8C8C8D", -"3+ c #838484", -"4+ c #767877", -"5+ c #767778", -"6+ c #696868", -"7+ c #615F60", -"8+ c #5D5E5E", -"9+ c #ABACAB", -"0+ c #A5A6A5", -"a+ c #ADAEAD", -"b+ c #9F9F9F", -"c+ c #8E8D8E", -"d+ c #888888", -"e+ c #8F8F8E", -"f+ c #848484", -"g+ c #777778", -"h+ c #727172", -"i+ c #727373", -"j+ c #6D6D6E", -"k+ c #666667", -"l+ c #616161", -"m+ c #525252", -"n+ c #9E9E9E", -"o+ c #A4A4A4", -"p+ c #AEAEAE", -"q+ c #A7A7A7", -"r+ c #9B9B9B", -"s+ c #939393", -"t+ c #838383", -"u+ c #8A8C8B", -"v+ c #909090", -"w+ c #8C8C8B", -"x+ c #868686", -"y+ c #828282", -"z+ c #6C6C6C", -"A+ c #6F6F6E", -"B+ c #696869", -"C+ c #646363", -"D+ c #5B5C5C", -"E+ c #4F4F4E", -"F+ c #A5A4A2", -"G+ c #A9A9A9", -"H+ c #979797", -"I+ c #828281", -"J+ c #8A8B8A", -"K+ c #7D7D7E", -"L+ c #757675", -"M+ c #646464", -"N+ c #606161", -"O+ c #5D5D5D", -"P+ c #5A5A5A", -"Q+ c #5E5E5E", -"R+ c #9C9C9D", -"S+ c #99999A", -"T+ c #979798", -"U+ c #979697", -"V+ c #8F8F8F", -"W+ c #7F7F7F", -"X+ c #787878", -"Y+ c #6D6E6D", -"Z+ c #535353", -"`+ c #585959", -" @ c #5E5F5F", -".@ c #626262", -"+@ c #9D9E9D", -"@@ c #9A999A", -"#@ c #8D8D8D", -"$@ c #828181", -"%@ c #767677", -"&@ c #7B7C7B", -"*@ c #777677", -"=@ c #59595A", -"-@ c #999899", -";@ c #9B9A9A", -">@ c #8D8E8C", -",@ c #696968", -"'@ c #6A6A6A", -")@ c #666666", -"!@ c #626363", -"~@ c #646465", -"{@ c #939494", -"]@ c #8D8D8C", -"^@ c #9C9B9B", -"/@ c #919191", -"(@ c #8F8F90", -"_@ c #787879", -":@ c #656666", -"<@ c #9A9A9B", -"[@ c #9A9B9B", -"}@ c #98989A", -"|@ c #959695", -"1@ c #737273", -"2@ c #676868", -"3@ c #5B5B5C", -"4@ c #8A898A", -"5@ c #8B8A8B", -"6@ c #949695", -"7@ c #797879", -"8@ c #747373", -"9@ c #717172", -"0@ c #636464", -"a@ c #5F6060", -"b@ c #848483", -"c@ c #868786", -"d@ c #8E8F8F", -"e@ c #8B8B8B", -"f@ c #818080", -"g@ c #7E7D7E", -"h@ c #787778", -"i@ c #6F6E6E", -"j@ c #747474", -"k@ c #717271", -"l@ c #6F6E6F", -"m@ c #696969", -"n@ c #5C5C5C", -"o@ c #7B7B79", -"p@ c #858485", -"q@ c #818281", -"r@ c #727272", -"s@ c #7C7B7C", -"t@ c #7D7D7C", -"u@ c #7A7A7A", -"v@ c #676767", -"w@ c #6D6C6E", -"x@ c #6C6C6D", -"y@ c #666665", -"z@ c #565656", -"A@ c #6B6A6A", -"B@ c #757575", -"C@ c #707171", -"D@ c #6E6E6F", -"E@ c #767777", -"F@ c #747475", -"G@ c #5C5D5D", -"H@ c #757475", -"I@ c #747576", -"J@ c #6C6B6C", -"K@ c #6E6D6E", -"L@ c #707070", -"M@ c #6F6F70", -"N@ c #6A6A6B", -"O@ c #5F5F5F", -"P@ c #585858", -"Q@ c #636363", -"R@ c #6D6B6C", -"S@ c #636263", -"T@ c #5C5C5D", -"U@ c #656464", -"V@ c #666766", -"W@ c #606060", -"X@ c #6D6D6D", -"Y@ c #6B6A6B", -"Z@ c #5D5D5E", -" . + @ # $ % & # ", -" & * @ = - ; ; > , ' , # ) ; ", -" ! ~ { { { ] % ~ ' { ' , # ^ ] & / ! ", -" ) & ~ { { { , * ( ' @ # ) ] _ - : < [ } ", -" { ' | ] { { ' ' 1 2 ] ] ; _ 3 4 5 6 7 8 9 0 ", -" a ' ' ] b , , c ( * d e f g h i j k l m 5 n o p ", -" - # q c ; - $ ] $ _ g j 5 r g s r ! t u v w x y z z ", -" A 3 ] B C $ h D f f E g F 5 G H e I J K L K M N O P P Q ", -" % G R & R - e D g g g g e S T U V 5 t W X Y Y o Z ` ... ", -" g +.m l @.#.F i s $.$.e G d %.9 t &.%.*.=.-.;.>.,.'.).!.~.{. ", -" ].#.u n j m ^.G G /.U (._.u 9 :.=.x <.[.:.}.|.1.P 2. .3.{.4. ", -" 5 5.n w J ! 6.V 7.T v t 8.9 9.0.a.Y :.o b.c.` d.d.e.f.g.h.i. ", -"j.[.k.%.l.v v S t m.n M k.9.n.0.o.p.Z Z q.r.s.t.u.u.!.v.w.x.y.z.", -"e.9.L A.A.A.B.M =.[.C.O Z q.D.c.P E.F.|.s.E.d.G.H.g.g.I.J.K.L.M.", -"N.:.9.9.[.9.:.o b.0.D.c.O.O.D.P.Q.d.R.Q .R.u.S.T.U.V.W.X.Y.Z.`.", -" +0.-..+++@+z |.#+|.$+$+%+|.s.` &+R.*+=+!.S.-+;+>+,+x.'+)+!+~+{+", -"Q ]+^+/+(+E.Q E.(+|.P s.o._+:+d.e.u.<+[+}+|+1+2+3+Y.4+5+L.6+7+8+", -"9+0+a+Q Q ` P r.|.P s.]+_+Q .e.R.b+c+d+[+w.e+U.f+g+h+i+j+k+l+m+", -"R.n+o+E.s.P P P s.o.` p+Q d.q+u.r+s+h.t+u+v+w+x+y+Y.z+A+B+C+D+E+", -"F+~.G+]+o.o.o.]+` p+Q d.q+u.r+H+[+[+[+V.I+J+d+t+K+L+M+N+O+P+P+Q+", -" u...Q p+:+p+Q Q G+u.R+S+T+U+g.H.{.[+V+W+x.f+y.X+Y+P+Z+`+ @.@ ", -" +@n+.. . .e.o+*+-+H.H.S+@@v.H.g.|+v+#@$@%@&@*@!+M+=@P+l+{+{+ ", -" -@;@S.~.n+H.g.-@S.n+n+S.v.H.g.s+v+>@d+x.z+,@'@)@l+N+!@~@{+{+ ", -" {@]@#@;+H.*+b+n+R+^@}+g.[+/@(@V.W.x._@)@Q+:@:@!@M+{+{+{+ ", -" e+J.#@-+S.<@[@}@T+|@[+w.v+V.d+y+'+Y.1@2@3@.@{+{+{+{+{+M+ ", -" 4@5@s+{.6@|+[+w./@4.u+W.$@7@%@Y.8@9@z+Q+D+0@{+{+!@a@ ", -" b@c@d@T.T.4.e@f+f@g@'+h@!+i@j@k@l@m@N+P+n@Q+O+3@ ", -" o@f+p@q@g@h@r@s@t@u@%@i@v@w@x@2@y@{+O+Z+z@O+ ", -" A@r@B@%@C@D@X+u@E@F@!+.@a@)@{+{+{+l+z@G@ ", -" C@H@I@r@J@K@L@M@z+N@O@P@Q@{+{+{+Q@P+ ", -" R@'@S@T@U@V@:@{+!@P@W@{+~+l+ ", -" P@{+X@6+6+Y@M+Z@ "}; diff -Nru blobby-0.8-dfsg/debian/changelog blobby-0.9c/debian/changelog --- blobby-0.8-dfsg/debian/changelog 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/changelog 2011-12-04 11:45:16.000000000 +0000 @@ -1,8 +1,33 @@ -blobby (0.8-dfsg-2build1) oneiric; urgency=low +blobby (0.9c-1) unstable; urgency=low - * Rebuild for tinyxml 2.6.2. + * New upstream release. (LP: #887143) + - Resolves all licensing issues, no need to repackage the upstream + tarball anymore. + * Drop 03_detect_endianness_glibc.patch, merged upstream. + * Refresh patches. + * Enable parallel building. + * Switch to source format 3.0 (quilt). + - Add unapply-patches and abort-on-upstream-changes to local-options. + - Refresh patches. + * Export build flags using /usr/share/dpkg/buildflags.mk. + * Improve package description, thanks to Paul Stewart. (LP: #833458) + * Bump Standards-Version to 3.9.2, no changes needed. + * Move package to the pkg-games team. + * Generate blobby icons during the build. + * Update copyright file to latest DEP-5 spec. + * Pass --fail-missing to dh_install. + * Add 05_server_config_file.patch: append /usr/share/blobby to the server + config search path and write the config to the user's home dir. + (Closes: #648204) - -- Felix Geyer Sat, 28 May 2011 08:52:28 +0200 + -- Felix Geyer Sun, 04 Dec 2011 12:45:10 +0100 + +blobby (0.8-dfsg-2.1) unstable; urgency=low + + * Non-maintainer upload. + * Set DM-Upload-Allowed. + + -- Philipp Kern Mon, 28 Nov 2011 22:39:54 +0100 blobby (0.8-dfsg-2) unstable; urgency=low diff -Nru blobby-0.8-dfsg/debian/control blobby-0.9c/debian/control --- blobby-0.8-dfsg/debian/control 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/control 2011-12-04 11:38:26.000000000 +0000 @@ -1,40 +1,43 @@ Source: blobby Section: games Priority: optional -Maintainer: Felix Geyer -Build-Depends: - debhelper (>= 7.0.50~), - quilt (>= 0.46-7~), - cmake, - zip, - libboost-dev, - libgl1-mesa-dev | libgl-dev, - liblua5.1-0-dev, - libphysfs-dev, - libsdl1.2-dev, - libtinyxml-dev, - zlib1g-dev +Maintainer: Debian Games Team +Uploaders: Felix Geyer +DM-Upload-Allowed: yes +Build-Depends: debhelper (>= 7.4.10~), + cmake, + imagemagick, + zip, + libboost-dev, + libgl1-mesa-dev | libgl-dev, + liblua5.1-0-dev, + libphysfs-dev, + libsdl1.2-dev, + libtinyxml-dev, + zlib1g-dev Homepage: http://sourceforge.net/projects/blobby/ -Standards-Version: 3.8.4 -Vcs-Git: git://git.debian.org/collab-maint/blobby.git -Vcs-Browser: http://git.debian.org/?p=collab-maint/blobby.git +Standards-Version: 3.9.2 +Vcs-Git: git://anonscm.debian.org/pkg-games/blobby.git +Vcs-Browser: http://anonscm.debian.org/git/pkg-games/blobby.git Package: blobby Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, blobby-data (>= ${source:Version}) +Depends: ${shlibs:Depends}, ${misc:Depends}, + blobby-data (>= ${source:Version}) Description: Volleyball game with blobs This package contains the client binary for Blobby Volley 2. . - Arcarde volleyball game with jumping blobs. + Blobby Volley is an arcade volleyball game with jumping blobs. It contains a multiplayer mode and several bots. Package: blobby-server Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, blobby-data (>= ${source:Version}) -Description: Volleyball game with blobs (sever) +Depends: ${shlibs:Depends}, ${misc:Depends}, + blobby-data (>= ${source:Version}) +Description: Volleyball game with blobs (server) This package contains the server binary for Blobby Volley 2. . - Arcarde volleyball game with jumping blobs. + Blobby Volley is an arcade volleyball game with jumping blobs. It contains a multiplayer mode and several bots. Package: blobby-data @@ -43,5 +46,5 @@ Description: Volleyball game with blobs (data files) This package contains the static data for Blobby Volley 2. . - Arcarde volleyball game with jumping blobs. + Blobby Volley is an arcade volleyball game with jumping blobs. It contains a multiplayer mode and several bots. diff -Nru blobby-0.8-dfsg/debian/copyright blobby-0.9c/debian/copyright --- blobby-0.8-dfsg/debian/copyright 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/copyright 2011-10-20 12:22:08.000000000 +0000 @@ -1,6 +1,6 @@ -Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=135 -Name: Blobby Volley 2 -Maintainer: Daniel Knobe +Format-Specification: http://anonscm.debian.org/gitweb/?p=dbnpolicy/policy.git;a=blob;f=copyright-format/copyright-format.xml;hb=b4d036bab75ac794c3500563768d60ad994ae4f1 +Upstream-Name: Blobby Volley 2 +Upstream-Contact: Daniel Knobe Source: http://sourceforge.net/projects/blobby/ Files: * @@ -31,7 +31,7 @@ Files: src/raknet/* Copyright: 2003, Rakkarsoft LLC and Kevin Jenkins. -License: BSD +License: BSD-3-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright @@ -62,12 +62,12 @@ Files: src/raknet/SHA1.* Copyright: Public domain -License: +License: public-domain No license as the code is in public domain. Files: src/raknet/rijndael* Copyright: 1999-2000, Enhanced Software Technologies Inc. -License: BSD +License: BSD-4-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -99,21 +99,21 @@ Files: src/tinyxml/* Copyright: 2000-2007, Lee Thomason 2002-2004, Yves Berquin -License: ZLIB +License: Zlib Files: src/tinyxml/tinystr.* Copyright: 2000-2007, Lee Thomason 2002-2004, Yves Berquin 2005, Tyge Lovset -License: ZLIB +License: Zlib Files: debian/* -Copyright: 2009-2010, Felix Geyer +Copyright: 2009-2011, Felix Geyer License: GPL-2+ On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-2'. -License: ZLIB +License: Zlib This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. diff -Nru blobby-0.8-dfsg/debian/gbp.conf blobby-0.9c/debian/gbp.conf --- blobby-0.8-dfsg/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/debian/gbp.conf 2011-10-20 12:30:30.000000000 +0000 @@ -0,0 +1,2 @@ +[DEFAULT] +pristine-tar = True diff -Nru blobby-0.8-dfsg/debian/patches/01_sdl_default.patch blobby-0.9c/debian/patches/01_sdl_default.patch --- blobby-0.8-dfsg/debian/patches/01_sdl_default.patch 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/patches/01_sdl_default.patch 2011-11-11 10:53:53.000000000 +0000 @@ -1,22 +1,9 @@ Description: Use SDL by default since it's faster without hardware acceleration Author: Felix Geyer -diff -Nur blobby-volley2-0.7~svn430.orig/data/config.xml blobby-volley2-0.7~svn430/data/config.xml ---- blobby-volley2-0.7~svn430.orig/data/config.xml 2008-03-13 22:51:40.000000000 +0100 -+++ blobby-volley2-0.7~svn430/data/config.xml 2008-04-10 20:21:53.000000000 +0200 -@@ -1,7 +1,7 @@ - - - -- -+ - - - -diff -Nur blobby-volley2-0.7~svn430.orig/src/main.cpp blobby-volley2-0.7~svn430/src/main.cpp ---- blobby-volley2-0.7~svn430.orig/src/main.cpp 2008-03-13 22:51:40.000000000 +0100 -+++ blobby-volley2-0.7~svn430/src/main.cpp 2008-04-10 20:22:39.000000000 +0200 -@@ -143,8 +143,8 @@ +--- a/src/main.cpp ++++ b/src/main.cpp +@@ -160,8 +160,8 @@ int main(int argc, char* argv[]) else { std::cerr << "Warning: Unknown renderer selected!"; diff -Nru blobby-0.8-dfsg/debian/patches/02_use_system_lua.patch blobby-0.9c/debian/patches/02_use_system_lua.patch --- blobby-0.8-dfsg/debian/patches/02_use_system_lua.patch 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/patches/02_use_system_lua.patch 2011-11-11 11:19:01.000000000 +0000 @@ -1,27 +1,30 @@ Description: Use system lua library instead of building a local copy Author: Felix Geyer -diff -Nur blobby-volley2-0.7~svn430.orig/src/CMakeLists.txt blobby-volley2-0.7~svn430/src/CMakeLists.txt ---- blobby-volley2-0.7~svn430.orig/src/CMakeLists.txt 2008-03-23 20:24:20.000000000 +0100 -+++ blobby-volley2-0.7~svn430/src/CMakeLists.txt 2008-04-10 20:16:39.000000000 +0200 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(lua) add_subdirectory(tinyxml) add_subdirectory(raknet) -@@ -64,7 +63,7 @@ +@@ -64,11 +63,11 @@ else (CMAKE_SYSTEM_NAME STREQUAL Windows endif (CMAKE_SYSTEM_NAME STREQUAL Windows) add_executable(blobby ${blobby_SRC}) -target_link_libraries(blobby lua raknet tinyxml ${RAKNET_LIBRARIES} ${PHYSFS_LIBRARY} ${SDL_LIBRARY} ${OPENGL_LIBRARIES}) +target_link_libraries(blobby lua5.1 raknet tinyxml ${RAKNET_LIBRARIES} ${PHYSFS_LIBRARY} ${SDL_LIBRARY} ${OPENGL_LIBRARIES}) - if (CMAKE_SYSTEM_NAME STREQUAL Linux) + if (UNIX) add_executable(blobby-server ${blobby-server_SRC}) -diff -Nur blobby-volley2-0.7~svn430.orig/src/ScriptedInputSource.cpp blobby-volley2-0.7~svn430/src/ScriptedInputSource.cpp ---- blobby-volley2-0.7~svn430.orig/src/ScriptedInputSource.cpp 2008-03-13 22:51:40.000000000 +0100 -+++ blobby-volley2-0.7~svn430/src/ScriptedInputSource.cpp 2008-04-10 20:18:39.000000000 +0200 -@@ -22,9 +22,9 @@ +- target_link_libraries(blobby-server lua raknet tinyxml ${RAKNET_LIBRARIES} ${PHYSFS_LIBRARY} ${SDL_LIBRARY}) ++ target_link_libraries(blobby-server lua5.1 raknet tinyxml ${RAKNET_LIBRARIES} ${PHYSFS_LIBRARY} ${SDL_LIBRARY}) + endif (UNIX) + + if (CMAKE_SYSTEM_NAME STREQUAL Windows) +--- a/src/ScriptedInputSource.cpp ++++ b/src/ScriptedInputSource.cpp +@@ -22,9 +22,9 @@ Foundation, Inc., 59 Temple Place, Suite extern "C" { @@ -33,4 +36,19 @@ +#include } - #include + #include +--- a/src/GameLogic.cpp ++++ b/src/GameLogic.cpp +@@ -24,9 +24,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + extern "C" + { +-#include "lua/lua.h" +-#include "lua/lauxlib.h" +-#include "lua/lualib.h" ++#include ++#include ++#include + } + + #include diff -Nru blobby-0.8-dfsg/debian/patches/03_detect_endianness_glibc.patch blobby-0.9c/debian/patches/03_detect_endianness_glibc.patch --- blobby-0.8-dfsg/debian/patches/03_detect_endianness_glibc.patch 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/patches/03_detect_endianness_glibc.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -Description: Fix FTBFS on s390 and sh4 -Author: Felix Geyer -Bug: https://sourceforge.net/apps/mantisbt/blobby/view.php?id=12 -Bug-Debian: http://bugs.debian.org/572025 - -diff --git a/src/raknet/Types.h b/src/raknet/Types.h ---- a/src/raknet/Types.h -+++ b/src/raknet/Types.h -@@ -98,6 +98,18 @@ - * - COMPILER_BORLANDC - */ - -+#include -+ -+#if defined(__GLIBC__) && !defined(HOST_ENDIAN_IS_BIG) && !defined(HOST_ENDIAN_IS_LITTLE) -+ #include -+ -+ #if (__BYTE_ORDER == __LITTLE_ENDIAN) -+ #define HOST_ENDIAN_IS_LITTLE -+ #elif (__BYTE_ORDER == __BIG_ENDIAN) -+ #define HOST_ENDIAN_IS_BIG -+ #endif -+#endif -+ - // CB: Something strange happens with the system includes on - // Linux and BIG_ENDIAN ends up defined at some point, so - // we need to use HOST_ENDIAN_IS_BIG instead. This code is -@@ -140,23 +152,11 @@ namespace cat - // LITTLE_ENDIAN or BIG_ENDIAN (endian.h) - // dalfy - #if !defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN) --#if defined(__sparc) || defined(__sparc__) || defined(__powerpc__) || \ -- defined(__ppc__) || defined(__hppa) || defined(_MIPSEB) || defined(_POWER) || \ -- defined(_M_PPC) || defined(_M_MPPC) || defined(_M_MRX000) || \ -- defined(__POWERPC) || defined(m68k) || defined(powerpc) || \ -- defined(sel) || defined(pyr) || defined(mc68000) || defined(is68k) || \ -- defined(tahoe) || defined(ibm032) || defined(ibm370) || defined(MIPSEB) || \ -- defined(__convex__) || defined(DGUX) || defined(hppa) || defined(apollo) || \ -- defined(_CRAY) || defined(__hp9000) || defined(__hp9000s300) || defined(_AIX) || \ -- defined(__AIX) || defined(__pyr__) || defined(hp9000s700) || defined(_IBMR2) || defined(__ARMEB__) -+#if defined(HOST_ENDIAN_IS_BIG) - - # define BIG_ENDIAN - --#elif defined(__i386__) || defined(i386) || defined(intel) || defined(_M_IX86) || \ -- defined(__amd64) || defined(__amd64__) || \ -- defined(__alpha__) || defined(__alpha) || defined(__ia64) || defined(__ia64__) || \ -- defined(_M_ALPHA) || defined(ns32000) || defined(__ns32000__) || defined(sequent) || \ -- defined(MIPSEL) || defined(_MIPSEL) || defined(sun386) || defined(__sun386__) || defined(__ARMEL__) -+#elif defined(HOST_ENDIAN_IS_LITTLE) - - # define LITTLE_ENDIAN - diff -Nru blobby-0.8-dfsg/debian/patches/04_use_system_tinyxml.patch blobby-0.9c/debian/patches/04_use_system_tinyxml.patch --- blobby-0.8-dfsg/debian/patches/04_use_system_tinyxml.patch 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/patches/04_use_system_tinyxml.patch 2011-11-11 11:05:48.000000000 +0000 @@ -1,18 +1,16 @@ Description: Use system tinyxml library instead of building a local copy Author: Felix Geyer -diff -Nur blobby-0.8-dfsg.orig/src/CMakeLists.txt blobby-0.8-dfsg/src/CMakeLists.txt ---- blobby-0.8-dfsg.orig/src/CMakeLists.txt 2010-04-17 00:43:49.000000000 +0200 -+++ blobby-0.8-dfsg/src/CMakeLists.txt 2010-04-17 00:44:43.474092360 +0200 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(tinyxml) add_subdirectory(raknet) add_definitions(-DTIXML_USE_STL) -diff -Nur blobby-0.8-dfsg.orig/src/ReplayRecorder.cpp blobby-0.8-dfsg/src/ReplayRecorder.cpp ---- blobby-0.8-dfsg.orig/src/ReplayRecorder.cpp 2010-02-26 12:36:23.000000000 +0100 -+++ blobby-0.8-dfsg/src/ReplayRecorder.cpp 2010-04-17 00:45:26.964094447 +0200 -@@ -19,7 +19,7 @@ +--- a/src/ReplayRecorder.cpp ++++ b/src/ReplayRecorder.cpp +@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite #include "ReplayRecorder.h" #include "physfs.h" @@ -20,11 +18,21 @@ +#include #include - #include -diff -Nur blobby-0.8-dfsg.orig/src/UserConfig.cpp blobby-0.8-dfsg/src/UserConfig.cpp ---- blobby-0.8-dfsg.orig/src/UserConfig.cpp 2010-02-26 12:36:23.000000000 +0100 -+++ blobby-0.8-dfsg/src/UserConfig.cpp 2010-04-17 00:45:20.674096589 +0200 -@@ -19,7 +19,7 @@ + #include +--- a/src/TextManager.cpp ++++ b/src/TextManager.cpp +@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + #include + #include +-#include "tinyxml/tinyxml.h" ++#include + #include "Global.h" + #include + +--- a/src/UserConfig.cpp ++++ b/src/UserConfig.cpp +@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite #include #include diff -Nru blobby-0.8-dfsg/debian/patches/05_server_config_file.patch blobby-0.9c/debian/patches/05_server_config_file.patch --- blobby-0.8-dfsg/debian/patches/05_server_config_file.patch 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/debian/patches/05_server_config_file.patch 2011-12-04 11:44:02.000000000 +0000 @@ -0,0 +1,71 @@ +Description: Append /usr/share/blobby to the server config search path + and write the config to the user's home dir. +Author: Felix Geyer +Bug: https://sourceforge.net/apps/mantisbt/blobby/view.php?id=33 +Bug-Debian: http://bugs.debian.org/648204 + +--- a/src/DedicatedServer.cpp ++++ b/src/DedicatedServer.cpp +@@ -35,6 +35,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + #include "raknet/GetTime.h" + // We need no stringcompressor only for the names + ++#include "config.h" ++ + #include "DedicatedServer.h" + #include "InputSource.h" + #include "PhysicWorld.h" +@@ -107,6 +109,8 @@ int main(int argc, char** argv) + Color firstPlayerColor; + + config.loadFile("server.xml"); ++ // make sure the config is present in the user dir ++ config.saveFile("server.xml"); + + int port = config.getInteger("port"); + float speed = config.getFloat("speed"); +@@ -493,6 +497,29 @@ void wait_and_restart_child() + + } + ++// copied from main.cpp, should be moved to a common place ++void probeDir(const std::string& dirname) ++{ ++ if (PHYSFS_isDirectory(dirname.c_str()) == 0) ++ { ++ if (PHYSFS_exists(dirname.c_str())) ++ { ++ PHYSFS_delete(dirname.c_str()); ++ } ++ if (PHYSFS_mkdir(dirname.c_str())) ++ { ++ std::cout << PHYSFS_getWriteDir() << ++ dirname << " created" << std::endl; ++ } ++ else ++ { ++ std::cout << "Warning: Creation of" << ++ PHYSFS_getWriteDir() << dirname << ++ " failed!" << std::endl; ++ } ++ } ++} ++ + void setup_physfs(char* argv0) + { + PHYSFS_init(argv0); +@@ -502,9 +529,14 @@ void setup_physfs(char* argv0) + // Just write in installation directory + PHYSFS_setWriteDir("data"); + #else ++ PHYSFS_addToSearchPath(BLOBBY_INSTALL_PREFIX "/share/blobby", 1); + std::string userdir = PHYSFS_getUserDir(); + std::string userAppend = ".blobby"; + std::string homedir = userdir + userAppend; ++ PHYSFS_addToSearchPath(userdir.c_str(), 0); ++ PHYSFS_setWriteDir(userdir.c_str()); ++ probeDir(userAppend); ++ PHYSFS_removeFromSearchPath(userdir.c_str()); + PHYSFS_addToSearchPath(homedir.c_str(), 0); + PHYSFS_setWriteDir(homedir.c_str()); + #endif diff -Nru blobby-0.8-dfsg/debian/patches/series blobby-0.9c/debian/patches/series --- blobby-0.8-dfsg/debian/patches/series 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/patches/series 2011-12-04 11:39:10.000000000 +0000 @@ -1,4 +1,4 @@ 01_sdl_default.patch 02_use_system_lua.patch -03_detect_endianness_glibc.patch 04_use_system_tinyxml.patch +05_server_config_file.patch diff -Nru blobby-0.8-dfsg/debian/README.source blobby-0.9c/debian/README.source --- blobby-0.8-dfsg/debian/README.source 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/README.source 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -Debian patch system -=================== - -This package uses quilt to manage all modifications to the upstream -source. Changes are stored in the source package as diffs in -debian/patches and applied during the build. - -See /usr/share/doc/quilt/README.source for a detailed explanation. - - -Source repackaging -================== - -The src/raknet folder has been replaced by the one from SVN rev 485 -(https://blobby.svn.sourceforge.net/svnroot/blobby/trunk/src/raknet/). -The only difference is the change of the license: -- all files except Rand.*, SHA1.* and rijndael* have been relicensed - under the BSD license (see the LICENSE file) -- a condition to mail the author has been removed from Rand.cpp - (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498621#52) -The repackaging can be dropped on the next upstream release (after v0.8). diff -Nru blobby-0.8-dfsg/debian/rules blobby-0.9c/debian/rules --- blobby-0.8-dfsg/debian/rules 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/rules 2011-11-11 11:21:57.000000000 +0000 @@ -1,6 +1,18 @@ #!/usr/bin/make -f +DPKG_EXPORT_BUILDFLAGS = 1 +-include /usr/share/dpkg/buildflags.mk + LDFLAGS += -Wl,--as-needed %: - dh --with quilt $@ + dh $@ --parallel + +override_dh_install: + dh_install --fail-missing + convert -transparent black data/gfx/ball01.bmp \ + debian/blobby/usr/share/icons/hicolor/64x64/apps/blobby.png + convert -transparent black data/gfx/ball01.bmp -resize 32x32 \ + debian/blobby/usr/share/icons/hicolor/32x32/apps/blobby.png + convert -transparent black data/gfx/ball01.bmp -resize 32x32 \ + debian/blobby/usr/share/pixmaps/blobby.xpm diff -Nru blobby-0.8-dfsg/debian/source/format blobby-0.9c/debian/source/format --- blobby-0.8-dfsg/debian/source/format 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/source/format 2011-12-04 21:48:31.000000000 +0000 @@ -1 +1 @@ -1.0 +3.0 (quilt) diff -Nru blobby-0.8-dfsg/debian/watch blobby-0.9c/debian/watch --- blobby-0.8-dfsg/debian/watch 2011-12-04 21:48:31.000000000 +0000 +++ blobby-0.9c/debian/watch 2011-11-11 10:57:42.000000000 +0000 @@ -1,5 +1,3 @@ -# format version number, currently 3; this line is compulsory! version=3 -opts=uversionmangle=s/a$//,dversionmangle=s/-dfsg\d*$// \ - http://sf.net/blobby/ blobby2-linux-(.*)\.tar\.gz +http://sf.net/blobby/ blobby2-linux-(.*)\.tar\.gz diff -Nru blobby-0.8-dfsg/doc/ScriptAPI.txt blobby-0.9c/doc/ScriptAPI.txt --- blobby-0.8-dfsg/doc/ScriptAPI.txt 2009-12-26 03:54:47.000000000 +0000 +++ blobby-0.9c/doc/ScriptAPI.txt 2011-11-06 15:06:40.000000000 +0000 @@ -25,6 +25,7 @@ estimx(number) : Estimates ball x component for n timesteps estimy(number) : Estimates ball y component for n timesteps + ballx() : x component of the ball position bally() : y component of the ball position @@ -43,6 +44,14 @@ debug(number) : Prints a number to stderr for debugging purposes +getScore() : own score + +getOppScore() : opponent's score + +getScoreToWin() : score needed to win the match + +getGameTime(): time the game is running (for bots simulating exhaustion) + All functions of the lua math library are also available. You can find their documentation at: http://www.lua.org/manual/5.1/manual.html#5.6 @@ -56,8 +65,3 @@ function OnOpponentServe() : Called after balldown when the opponent has to serve the next ball function OnGame() : Called during the normal game - - -What is missing: - -- Functions to query score (for dynamic strength bots) diff -Nru blobby-0.8-dfsg/src/Blood.cpp blobby-0.9c/src/Blood.cpp --- blobby-0.8-dfsg/src/Blood.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/Blood.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -55,8 +55,9 @@ void BloodManager::step() { - if (!mEnabled) + if (!mEnabled || mParticles.size() == 0) return; + RenderManager::getSingleton().startDrawParticles(); std::list::iterator it = mParticles.begin(); while (it != mParticles.end()) { @@ -67,6 +68,7 @@ if (partPos.y > 600) mParticles.erase(it2); } + RenderManager::getSingleton().endDrawParticles(); } void BloodManager::spillBlood(Vector2 pos, float intensity, int player) diff -Nru blobby-0.8-dfsg/src/Blood.h blobby-0.9c/src/Blood.h --- blobby-0.8-dfsg/src/Blood.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/Blood.h 2011-11-06 15:06:46.000000000 +0000 @@ -32,7 +32,7 @@ public: Blood(Vector2 position, Vector2 direction, int player); void step(); - Vector2 getPosition() { return mPos; } + Vector2 getPosition() const { return mPos; } int mLastFrame; }; diff -Nru blobby-0.8-dfsg/src/BotAPICalculations.cpp blobby-0.9c/src/BotAPICalculations.cpp --- blobby-0.8-dfsg/src/BotAPICalculations.cpp 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/BotAPICalculations.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,189 @@ +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + +#include "BotAPICalculations.h" +#include "GameConstants.h" +#include +#include + +bool FLAG_BOUNCE = false; + +// helpers +float time_to_x_direct(float pos, float vel, float destination); +float time_to_y_direct(float pos, float vel, float destination); +float parabel_time_first(float pos, float vel, float gravity, float destination); + +float make_unsigned(float f) { + return (f > 0 ? f : std::numeric_limits::infinity()); +} + + +void reset_flags() { + FLAG_BOUNCE = false; +} + +float time_to_x(const Vector2& pos, const Vector2& vel, float destination) { + // check whether velocity is valid + if( vel.x == 0 ) + return std::numeric_limits::max(); + + // direct? + float timedirect = time_to_x_direct(pos.x, vel.x, destination); + // needs wall bounce + if( timedirect < 0 ) { + FLAG_BOUNCE = true; + + float wall = vel.x > 0 ? (RIGHT_PLANE - BALL_RADIUS) : BALL_RADIUS; + float twall = time_to_x_direct(pos.x, vel.x, wall); + float net = vel.x > 0 ? (NET_POSITION_X - BALL_RADIUS - NET_RADIUS) : (NET_POSITION_X + BALL_RADIUS + NET_RADIUS); + float tnet = make_unsigned(time_to_x_direct(pos.x, vel.x, net)); + + if ( tnet < twall ) + { + Vector2 nhitpos = Vector2(net, predict_y(pos, vel, tnet)); + if ( nhitpos.y > NET_SPHERE_POSITION - NET_RADIUS - BALL_RADIUS ) + return tnet + time_to_x(nhitpos, vel.reflectX(), destination); + } + Vector2 whitpos = Vector2(wall, predict_y(pos, vel, twall)); + return twall + time_to_x(whitpos, vel.reflectX(), destination); + } + + float net = vel.x > 0 ? (NET_POSITION_X - BALL_RADIUS - NET_RADIUS) : (NET_POSITION_X + BALL_RADIUS + NET_RADIUS); + float tnet = make_unsigned(time_to_x_direct(pos.x, vel.x, net)); + Vector2 nhitpos = Vector2(net, predict_y(pos, vel, tnet)); + + if ( tnet > timedirect || nhitpos.y < NET_SPHERE_POSITION - NET_RADIUS - BALL_RADIUS) + { // if ball is too high or destination is reached before net, no collision can occur + return timedirect; + } + + FLAG_BOUNCE = true; + + // if ball hits net on false side, it is impossible to reach its destination + if( nhitpos.y > pos.y ) { + return std::numeric_limits::max(); + } + + return tnet + time_to_x(nhitpos, vel.reflectX(), destination); + +} + +float time_to_y(const Vector2& pos, const Vector2& vel, float destination) { + return time_to_y_direct(pos.y, vel.y, destination); +} + +float predict_x(const Vector2& pos, const Vector2& vel, float time) { + // can net collision occur + float net = vel.x > 0 ? (NET_POSITION_X - BALL_RADIUS - NET_RADIUS) : (NET_POSITION_X + BALL_RADIUS + NET_RADIUS); + float tnet = make_unsigned( time_to_x_direct(pos.x, vel.x, net) ); + + // calculate estimated hitpos + Vector2 nhitpos = Vector2(net, predict_y(pos, vel, tnet)); + + // can ignore net bounce + if ( tnet > time || nhitpos.y < NET_SPHERE_POSITION - NET_RADIUS - BALL_RADIUS) { + float spos = pos.x + vel.x*time; + if ( spos < BALL_RADIUS) + return 2 * BALL_RADIUS - spos; + else if ( spos > RIGHT_PLANE - BALL_RADIUS ) + return 2*(RIGHT_PLANE - BALL_RADIUS) - spos; + return spos; + } + + // collision with net + return predict_x(nhitpos, vel.reflectX(), time - tnet); + + +} +float predict_y(const Vector2& pos, const Vector2& vel, float time) { + return pos.y + (vel.y + BALL_GRAVITATION/2.0 * time) * time; +} + +float y_at_x(const Vector2& pos, const Vector2& vel, float destination) { + float time = time_to_x(pos, vel, destination); + return predict_y(pos, vel, time); +} +float x_at_y(const Vector2& pos, const Vector2& vel, float destination) { + float time = time_to_y(pos, vel, destination); + return predict_x(pos, vel, time); +} + +float next_event(const Vector2& pos, const Vector2& vel) { + // walls and net + float time_wall; + float time_net; + if( vel.x > 0 ) + { + time_wall = time_to_x_direct(pos.x, vel.x, RIGHT_PLANE - BALL_RADIUS); + time_net = time_to_x_direct(pos.x, vel.x, NET_POSITION_X - NET_RADIUS - BALL_RADIUS); + } else { + time_wall = time_to_x_direct(pos.x, vel.x, LEFT_PLANE + BALL_RADIUS); + time_net = time_to_x_direct(pos.x, vel.x, NET_POSITION_X + NET_RADIUS + BALL_RADIUS); + } + + // ground + float time_ground = time_to_y_direct(pos.y, vel.y, GROUND_PLANE_HEIGHT_MAX - BALL_RADIUS); + + time_net = make_unsigned(time_net); + time_wall = make_unsigned(time_wall); + time_ground = make_unsigned(time_ground); + + if ( time_net < time_wall && time_net < time_ground ) { + FLAG_BOUNCE = true; + return time_net; + } else if ( time_wall < time_net && time_wall < time_ground ) { + FLAG_BOUNCE = true; + return time_wall; + } else { + return time_ground; + } +} + +float time_to_x_direct(float pos, float vel, float destination) { + return (destination - pos) / vel; +} + +float time_to_y_direct(float pos, float vel, float destination) { + return parabel_time_first(pos, vel, BALL_GRAVITATION, destination); +} + +float parabel_time_first(float pos, float vel, float grav, float destination) { + float sq = vel*vel + 2*grav*(destination - pos); + + // if unreachable, return -1 + if ( sq < 0 ) { + return -1; + } + sq = std::sqrt(sq); + + float tmin = (-vel - sq) / grav; + float tmax = (-vel + sq) / grav; + + if ( grav < 0 ) { + float temp = tmin; + tmin = tmax; tmax = temp; + } + + if ( tmin > 0 ) + return tmin; + else if ( tmax > 0 ) + return tmax; + + return -1; +} diff -Nru blobby-0.8-dfsg/src/BotAPICalculations.h blobby-0.9c/src/BotAPICalculations.h --- blobby-0.8-dfsg/src/BotAPICalculations.h 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/BotAPICalculations.h 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,39 @@ +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + +#pragma once + +#include "Vector.h" + +// flags +extern bool FLAG_BOUNCE; + +void reset_flags(); + +float time_to_x(const Vector2& pos, const Vector2& vel, float destination); +float time_to_y(const Vector2& pos, const Vector2& vel, float destination); + +float predict_x(const Vector2& pos, const Vector2& vel, float time); +float predict_y(const Vector2& pos, const Vector2& vel, float time); + +float y_at_x(const Vector2& pos, const Vector2& vel, float destination); +float x_at_y(const Vector2& pos, const Vector2& vel, float destination); + +float next_event(const Vector2& pos, const Vector2& vel); + diff -Nru blobby-0.8-dfsg/src/Clock.cpp blobby-0.9c/src/Clock.cpp --- blobby-0.8-dfsg/src/Clock.cpp 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/Clock.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,71 @@ +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + +#include "Clock.h" + +#include +#include + +Clock::Clock():mRunning(false), mGameTime(0), mLastTime(0) +{ +} + +void Clock::reset() +{ + mRunning = false; + mGameTime = 0; + mLastTime = 0; +} + +void Clock::start() +{ + mLastTime = std::time(0); + mRunning = true; +} + +std::string Clock::getTimeString() const +{ + int seconds = mGameTime % 60; + int minutes = ((mGameTime - seconds)/60) % 60; + int hours = ((mGameTime - 60 * minutes - seconds) / 3600) % 60; + std::stringstream stream; + if(hours > 0) + stream << hours << ":"; + if(minutes < 10) + stream <<"0"; + stream << minutes <<":"; + if(seconds < 10) + stream <<"0"; + stream << seconds; + + return stream.str(); +} + +void Clock::step() +{ + if(mRunning) + { + time_t newTime = std::time(0); + if(newTime > mLastTime) + { + mGameTime += newTime - mLastTime; + } + mLastTime = newTime; + } +} diff -Nru blobby-0.8-dfsg/src/Clock.h blobby-0.9c/src/Clock.h --- blobby-0.8-dfsg/src/Clock.h 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/Clock.h 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,58 @@ +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + +#pragma once + +#include + +class Clock{ + public: + Clock(); + + void start(); + + void stop() { + mRunning = false; + } + + bool isRunning() const { + return mRunning; + } + + void step(); + + int getTime() const { + return mGameTime; + } + + void setTime(int newTime) { + mGameTime = newTime; + } + + void reset(); + + std::string getTimeString() const; + + private: + bool mRunning; + + time_t mGameTime; + time_t mLastTime; + +}; diff -Nru blobby-0.8-dfsg/src/CMakeLists.txt blobby-0.9c/src/CMakeLists.txt --- blobby-0.8-dfsg/src/CMakeLists.txt 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/CMakeLists.txt 2011-11-06 15:06:46.000000000 +0000 @@ -7,8 +7,12 @@ set(common_SRC Global.h + Clock.cpp Clock.h + DuelMatch.cpp DuelMatch.h + ReplayRecorder.cpp ReplayRecorder.h NetworkGame.cpp NetworkGame.h NetworkMessage.cpp NetworkMessage.h + GameLogic.cpp GameLogic.h PhysicWorld.cpp PhysicWorld.h SpeedController.cpp SpeedController.h UserConfig.cpp UserConfig.h @@ -17,7 +21,6 @@ set (blobby_SRC ${common_SRC} Blood.cpp Blood.h TextManager.cpp TextManager.h - DuelMatch.cpp DuelMatch.h main.cpp IMGUI.cpp IMGUI.h InputDevice.cpp InputDevice.h @@ -29,8 +32,8 @@ RenderManagerGL2D.cpp RenderManagerGL2D.h RenderManagerGP2X.cpp RenderManagerGP2X.h RenderManagerSDL.cpp RenderManagerSDL.h - ReplayRecorder.cpp ReplayRecorder.h - ScriptedInputSource.cpp ScriptedInputSource.h + ScriptedInputSource.cpp ScriptedInputSource.h + BotAPICalculations.cpp BotAPICalculations.h SoundManager.cpp SoundManager.h Vector.h state/State.cpp state/State.h @@ -68,9 +71,13 @@ if (UNIX) add_executable(blobby-server ${blobby-server_SRC}) - target_link_libraries(blobby-server raknet tinyxml ${RAKNET_LIBRARIES} ${PHYSFS_LIBRARY} ${SDL_LIBRARY}) + target_link_libraries(blobby-server lua raknet tinyxml ${RAKNET_LIBRARIES} ${PHYSFS_LIBRARY} ${SDL_LIBRARY}) endif (UNIX) +if (CMAKE_SYSTEM_NAME STREQUAL Windows) + set_target_properties(blobby PROPERTIES LINK_FLAGS "-mwindows") # disable the console window +endif (CMAKE_SYSTEM_NAME STREQUAL Windows) + if (WIN32) install(TARGETS blobby DESTINATION .) elseif (UNIX) diff -Nru blobby-0.8-dfsg/src/DedicatedServer.cpp blobby-0.9c/src/DedicatedServer.cpp --- blobby-0.8-dfsg/src/DedicatedServer.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/DedicatedServer.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -18,12 +18,17 @@ =============================================================================*/ #include +#include #include #include #include #include +#include + +#ifndef WIN32 #include #include +#endif #include "raknet/RakServer.h" #include "raknet/PacketEnumerations.h" @@ -37,108 +42,34 @@ #include "UserConfig.h" #include "NetworkMessage.h" #include "SpeedController.h" +#include "RakNetPacket.h" #ifdef WIN32 #undef main + +// function for logging to replacing syslog +enum { + LOG_ERR, + LOG_NOTICE, + LOG_DEBUG +}; +void syslog(int pri, const char* format, ...); + #endif static bool g_run_in_foreground = false; static bool g_print_syslog_to_stderr = false; static bool g_workaround_memleaks = false; -void printHelp() -{ - std::cout << "Usage: blobby-server [OPTION...]" << std::endl; - std::cout << " -m, --memleak-hack Workaround memory leaks by restarting regularly" << std::endl; - std::cout << " -n, --no-daemon Don´t run as background process" << std::endl; - std::cout << " -p, --print-msgs Print messages to stderr" << std::endl; - std::cout << " -h, --help This message" << std::endl; -} +// ... +void printHelp(); +void process_arguments(int argc, char** argv); +void fork_to_background(); +void wait_and_restart_child(); +void setup_physfs(char* argv0); -void process_arguments(int argc, char** argv) -{ - if (argc > 1) - { - for (int i = 1; i < argc; ++i) - { - if (strcmp(argv[i], "--memleak-hack") == 0 || strcmp(argv[i], "-m") == 0) - { - g_workaround_memleaks = true; - continue; - } - if (strcmp(argv[i], "--no-daemon") == 0 || strcmp(argv[i], "-n") == 0) - { - g_run_in_foreground = true; - continue; - } - if (strcmp(argv[i], "--print-msgs") == 0 || strcmp(argv[i], "-p") == 0) - { - g_print_syslog_to_stderr = true; - continue; - } - if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) - { - printHelp(); - exit(3); - } - std::cout << "Unknown option \"" << argv[i] << "\"" << std::endl; - printHelp(); - exit(1); - } - } -} - -void fork_to_background() -{ - pid_t f_return = fork(); - if (f_return == -1) - { - perror("fork"); - exit(1); - } - if (f_return != 0) - { - std::cout << "Running in background as PID " << f_return << std::endl; - exit(0); - } - -} - -void wait_and_restart_child() -{ - pid_t leaking_server; - while ((leaking_server = fork()) > 0) - { - int status; - - // Wait for server to quit and refork - waitpid(leaking_server, &status, 0); - // Error will propably occur again - if (WEXITSTATUS(status) != 0) - { - exit(WEXITSTATUS(status)); - } - } - - if (leaking_server == -1) - { - perror("fork"); - exit(1); - } - -} - -void setup_physfs(char* argv0) -{ - PHYSFS_init(argv0); - PHYSFS_addToSearchPath("data", 1); - std::string userdir = PHYSFS_getUserDir(); - std::string userAppend = ".blobby"; - std::string homedir = userdir + userAppend; - PHYSFS_addToSearchPath(homedir.c_str(), 0); - PHYSFS_setWriteDir(homedir.c_str()); - -} +// functions for processing certain network packets +void createNewGame(); int main(int argc, char** argv) { @@ -157,9 +88,12 @@ int startTime = SDL_GetTicks(); + #ifndef WIN32 int syslog_options = LOG_CONS | LOG_PID | (g_print_syslog_to_stderr ? LOG_PERROR : 0); openlog("blobby-server", syslog_options, LOG_DAEMON); + #endif + setup_physfs(argv[0]); GameList gamelist; @@ -170,6 +104,7 @@ PlayerID firstPlayer; PlayerSide firstPlayerSide = NO_PLAYER; std::string firstPlayerName; + Color firstPlayerColor; config.loadFile("server.xml"); @@ -179,20 +114,27 @@ ServerInfo myinfo(config); - if (!server.Start(200, 0, 0, port)) + if (!server.Start(150, 0, 1, port)) { syslog(LOG_ERR, "Couldn´t bind to port %i, exiting", port); return 2; } SpeedController scontroller(speed); + SpeedController::setMainInstance(&scontroller); syslog(LOG_NOTICE, "Blobby Volley 2 dedicated server version %i.%i started", BLOBBY_VERSION_MINOR, BLOBBY_VERSION_MAJOR); + packet_ptr packet; + while (1) { - Packet* packet; - while ((packet = server.Receive())) + + // ------------------------------------------------------------------------------- + // process all incoming packets , probably relay them to responsible network games + // ------------------------------------------------------------------------------- + + while ((packet = receivePacket(&server))) { switch(packet->data[0]) { @@ -207,8 +149,24 @@ bool cond2 = firstPlayer == packet->playerId; if (cond1 && cond2) firstPlayerSide = NO_PLAYER; - if (playermap[packet->playerId]) + if ( playermap.find(packet->playerId) != playermap.end() ) { + // inject the packet into the game playermap[packet->playerId]->injectPacket(packet); + + // then delete the player ... + // if it was the last player, the game is delete, too. + // thus, give the game a last chance to process the last + // input + + // check, wether game was delete from this, in this case, process manually + if( std::find(gamelist.begin(), gamelist.end(), playermap[packet->playerId]) == gamelist.end()) + { + playermap[packet->playerId]->step(); + } + // then delete + playermap.erase(packet->playerId); + } + clients--; syslog(LOG_DEBUG, "Connection closed, %d clients connected now", clients); break; @@ -216,16 +174,37 @@ case ID_INPUT_UPDATE: case ID_PAUSE: case ID_UNPAUSE: - if (playermap[packet->playerId]) + case ID_CHAT_MESSAGE: + case ID_REPLAY: + if (playermap.find(packet->playerId) != playermap.end()){ playermap[packet->playerId]->injectPacket(packet); + + // check, wether game was delete from this, in this case, process manually + if( std::find(gamelist.begin(), gamelist.end(), playermap[packet->playerId]) == gamelist.end()) + { + playermap[packet->playerId]->step(); + } + + } else { + syslog(LOG_ERR, "player not found!"); + #ifdef DEBUG + std::cout << " received game packet for no longer existing game! " + << (int)packet->data[0] << " - " + << packet->playerId.binaryAddress << " : " << packet->playerId.port + << "\n"; + // only quit in debug mode as this is not a problem endangering the stability + // of the running server, but a situation that should never occur. + return 3; + #endif + } + break; case ID_ENTER_GAME: { RakNet::BitStream stream((char*)packet->data, packet->length, false); - // Ignore ID_ENTER_GAME because we don't need it - stream.IgnoreBits(8 * sizeof(ID_ENTER_GAME)); + stream.IgnoreBytes(1); //ID_ENTER_GAME int playerSide; stream.Read(playerSide); @@ -236,6 +215,11 @@ // ensures that charName is null terminated charName[sizeof(charName)-1] = '\0'; + + // read colour data + int color; + stream.Read(color); + std::string playerName(charName); PlayerSide newSide = (PlayerSide)playerSide; @@ -245,6 +229,7 @@ firstPlayer = packet->playerId; firstPlayerSide = newSide; firstPlayerName = playerName; + firstPlayerColor = color; } else // We have two players now { @@ -262,6 +247,13 @@ std::string rightPlayerName = RIGHT_PLAYER == firstPlayerSide ? firstPlayerName : playerName; + + Color leftColor = + LEFT_PLAYER == firstPlayerSide ? + firstPlayerColor : color; + Color rightColor = + RIGHT_PLAYER == firstPlayerSide ? + firstPlayerColor : color; if (newSide == firstPlayerSide) { @@ -270,13 +262,20 @@ if (newSide == RIGHT_PLAYER) switchSide = LEFT_PLAYER; } - NetworkGame* newgame = new NetworkGame( + boost::shared_ptr newgame (new NetworkGame( server, leftPlayer, rightPlayer, leftPlayerName, rightPlayerName, - switchSide); + leftColor, rightColor, + switchSide) ); + playermap[leftPlayer] = newgame; playermap[rightPlayer] = newgame; gamelist.push_back(newgame); + + #ifdef DEBUG + std::cout << "NEW GAME CREATED:\t"<data, packet->length, false); - int ival; - int major; - int minor; - - stream.Read(ival); - stream.Read(major); - stream.Read(minor); - if (packet->bitSize != 96) - // We need special treatment when the client does - // not know anything about versioning at all. - { - major = BLOBBY_VERSION_MAJOR; - minor = BLOBBY_VERSION_MINOR; - - /* - ServerInfo oldInfo; - oldInfo.activegames = 0; - strncpy(oldInfo.name, - "Please update your Client!", 32); - strncpy(oldInfo.waitingplayer, "", 64); - strncpy(oldInfo.description, - "Your client is to old to connect " - "to this server. Get a new version" - " at " - "blobby.sourceforge.net" - , 192); - - stream.Reset(); - stream.Write(ID_BLOBBY_SERVER_PRESENT); - oldInfo.writeToBitstream(stream); - server.Send(&stream, HIGH_PRIORITY, - RELIABLE_ORDERED, 0, - packet->playerId, false); - */ - - } - - if (major < BLOBBY_VERSION_MAJOR - || (major == BLOBBY_VERSION_MINOR && minor < BLOBBY_VERSION_MINOR)) + // If the client knows nothing about versioning, the version is 0.0 + int major = 0; + int minor = 0; + bool wrongPackageSize = true; + + // actuel client has bytesize 72 + + if(packet->bitSize == 72) + { + stream.IgnoreBytes(1); //ID_BLOBBY_SERVER_PRESENT + stream.Read(major); + stream.Read(minor); + wrongPackageSize = false; + } + + RakNet::BitStream stream2; + + if (wrongPackageSize) + { + printf("major: %d minor: %d\n", major, minor); + stream2.Write((unsigned char)ID_UNKNOWN_CLIENT); + server.Send(&stream2, LOW_PRIORITY, + RELIABLE_ORDERED, 0, packet->playerId, + false); + } + else if (major < BLOBBY_VERSION_MAJOR + || (major == BLOBBY_VERSION_MAJOR && minor < BLOBBY_VERSION_MINOR)) // Check if the packet contains matching version numbers { - stream.Reset(); - stream.Write(ID_OLD_CLIENT); - server.Send(&stream, HIGH_PRIORITY, - RELIABLE_ORDERED, 0, packet->playerId, - false); - } - else if (major != BLOBBY_VERSION_MAJOR || - minor != BLOBBY_VERSION_MINOR) - { - printf("major: %d minor: %d\n", major, minor); - stream.Reset(); - stream.Write(ID_UNKNOWN_CLIENT); - server.Send(&stream, HIGH_PRIORITY, + stream2.Write((unsigned char)ID_OLD_CLIENT); + server.Send(&stream2, LOW_PRIORITY, RELIABLE_ORDERED, 0, packet->playerId, false); } @@ -360,10 +336,9 @@ sizeof(myinfo.waitingplayer) - 1); } - stream.Reset(); - stream.Write(ID_BLOBBY_SERVER_PRESENT); - myinfo.writeToBitstream(stream); - server.Send(&stream, HIGH_PRIORITY, + stream2.Write((unsigned char)ID_BLOBBY_SERVER_PRESENT); + myinfo.writeToBitstream(stream2); + server.Send(&stream2, HIGH_PRIORITY, RELIABLE_ORDERED, 0, packet->playerId, false); } @@ -372,25 +347,25 @@ case ID_RECEIVED_STATIC_DATA: break; default: - syslog(LOG_DEBUG, "Unknown packet %d recieved\n", int(packet->data[0])); + syslog(LOG_DEBUG, "Unknown packet %d received\n", int(packet->data[0])); } } + + // ------------------------------------------------------------------------------- + // now, step through all network games and process input - if a game ended, delete it + // ------------------------------------------------------------------------------- + for (GameList::iterator iter = gamelist.begin(); gamelist.end() != iter; ++iter) { if (!(*iter)->step()) { - PlayerMap::iterator piter = playermap.begin(); - while (piter != playermap.end()) - { - if (piter->second == *iter) - playermap.erase(piter); - ++piter; - } - delete *iter; iter = gamelist.erase(iter); + // workarround to prevent increment of + // past-end-iterator + if(iter == gamelist.end()) + break; } } - server.DeallocatePacket(packet); scontroller.update(); if (g_workaround_memleaks) @@ -406,9 +381,152 @@ } } } - + #ifndef WIN32 usleep(1); + #else + Sleep(1); + #endif } syslog(LOG_NOTICE, "Blobby Volley 2 dedicated server shutting down"); + #ifndef WIN32 closelog(); + #endif +} + +// ----------------------------------------------------------------------------------------- + +void createNewGame() +{ + +} + +// ----------------------------------------------------------------------------------------- + +void printHelp() +{ + std::cout << "Usage: blobby-server [OPTION...]" << std::endl; + std::cout << " -m, --memleak-hack Workaround memory leaks by restarting regularly" << std::endl; + std::cout << " -n, --no-daemon Don´t run as background process" << std::endl; + std::cout << " -p, --print-msgs Print messages to stderr" << std::endl; + std::cout << " -h, --help This message" << std::endl; +} + + +void process_arguments(int argc, char** argv) +{ + if (argc > 1) + { + for (int i = 1; i < argc; ++i) + { + if (strcmp(argv[i], "--memleak-hack") == 0 || strcmp(argv[i], "-m") == 0) + { + g_workaround_memleaks = true; + continue; + } + if (strcmp(argv[i], "--no-daemon") == 0 || strcmp(argv[i], "-n") == 0) + { + g_run_in_foreground = true; + continue; + } + if (strcmp(argv[i], "--print-msgs") == 0 || strcmp(argv[i], "-p") == 0) + { + g_print_syslog_to_stderr = true; + continue; + } + if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) + { + printHelp(); + exit(3); + } + std::cout << "Unknown option \"" << argv[i] << "\"" << std::endl; + printHelp(); + exit(1); + } + } +} + +void fork_to_background() +{ + #ifndef WIN32 + pid_t f_return = fork(); + if (f_return == -1) + { + perror("fork"); + exit(1); + } + if (f_return != 0) + { + std::cout << "Running in background as PID " << f_return << std::endl; + exit(0); + } + #else + std::cerr<<"fork is not available under windows\n"; + #endif +} + + +void wait_and_restart_child() +{ + #ifndef WIN32 + pid_t leaking_server; + while ((leaking_server = fork()) > 0) + { + int status; + + // Wait for server to quit and refork + waitpid(leaking_server, &status, 0); + // Error will propably occur again + if (WEXITSTATUS(status) != 0) + { + exit(WEXITSTATUS(status)); + } + } + + if (leaking_server == -1) + { + perror("fork"); + exit(1); + } + #else + std::cerr<<"fork is not available under windows\n"; + #endif + +} + +void setup_physfs(char* argv0) +{ + PHYSFS_init(argv0); + PHYSFS_addToSearchPath("data", 1); + + #if defined(WIN32) + // Just write in installation directory + PHYSFS_setWriteDir("data"); + #else + std::string userdir = PHYSFS_getUserDir(); + std::string userAppend = ".blobby"; + std::string homedir = userdir + userAppend; + PHYSFS_addToSearchPath(homedir.c_str(), 0); + PHYSFS_setWriteDir(homedir.c_str()); + #endif + } + + +#ifdef WIN32 +#undef main + +void syslog(int pri, const char* format, ...){ + switch(pri){ + case LOG_ERR: + std::cerr << std::time(0)<<": "< #include +#include #include "raknet/NetworkTypes.h" class NetworkGame; -typedef std::map PlayerMap; -typedef std::list GameList; +typedef std::map > PlayerMap; +typedef std::list< boost::shared_ptr > GameList; diff -Nru blobby-0.8-dfsg/src/doxyfile blobby-0.9c/src/doxyfile --- blobby-0.8-dfsg/src/doxyfile 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/doxyfile 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,1631 @@ +# Doxyfile 1.7.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "Blobby Volley Lua API" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = "beta 0.9" + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = lua_api_doc + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = NO + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvances is that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans.ttf + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff -Nru blobby-0.8-dfsg/src/DuelMatch.cpp blobby-0.9c/src/DuelMatch.cpp --- blobby-0.8-dfsg/src/DuelMatch.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/DuelMatch.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -18,17 +18,15 @@ =============================================================================*/ #include "UserConfig.h" -#include "RenderManager.h" -#include "SoundManager.h" #include "DuelMatch.h" -#include "Blood.h" #include DuelMatch* DuelMatch::mMainGame = 0; DuelMatch::DuelMatch(InputSource* linput, InputSource* rinput, - bool output, bool global) + bool global, bool remote):mLogic(createGameLogic("rules.lua")), + mPaused(false), events(0), external_events(0), mRemote(remote) { mGlobal = global; if (mGlobal) @@ -39,28 +37,15 @@ mLeftInput = linput; mRightInput = rinput; - mOutput = output; - - mLeftScore = 0; - mRightScore = 0; - mServingPlayer = NO_PLAYER; - mLeftHitcount = 0; - mRightHitcount = 0; - - mSquishLeft = 0; - mSquishRight = 0; mBallDown = false; - mWinningPlayer = 0; mPhysicWorld.resetPlayer(); mPhysicWorld.step(); UserConfig gameConfig; gameConfig.loadFile("config.xml"); - mScoreToWin = gameConfig.getInteger("scoretowin"); - if (mScoreToWin < 0) - mScoreToWin = 15; + mLogic->setScoreToWin(gameConfig.getInteger("scoretowin")); }; DuelMatch::~DuelMatch() @@ -78,160 +63,144 @@ void DuelMatch::step() { - RenderManager* rmanager = &RenderManager::getSingleton(); - SoundManager* smanager = &SoundManager::getSingleton(); + events = external_events; + // do steps in physic an logic if (mLeftInput) mPhysicWorld.setLeftInput(mLeftInput->getInput()); if (mRightInput) mPhysicWorld.setRightInput(mRightInput->getInput()); + + // in pause mode, step does nothing except input being set + if(mPaused) + return; + + mPhysicWorld.step(); - - if (mOutput) - { - rmanager->setBlob(0, mPhysicWorld.getBlob(LEFT_PLAYER), - mPhysicWorld.getBlobState(LEFT_PLAYER)); - rmanager->setBlob(1, mPhysicWorld.getBlob(RIGHT_PLAYER), - mPhysicWorld.getBlobState(RIGHT_PLAYER)); - rmanager->setBall(mPhysicWorld.getBall(), - mPhysicWorld.getBallRotation()); - } - - // Protection of multiple hit counts when the ball is squeezed - if (0 == mSquishLeft) + mLogic->step(); + + // check for all hit events + if(!mRemote) { if (mPhysicWorld.ballHitLeftPlayer()) - { - if (mOutput) - { - smanager->playSound("sounds/bums.wav", - mPhysicWorld.lastHitIntensity() + BALL_HIT_PLAYER_SOUND_VOLUME); - Vector2 hitPos = mPhysicWorld.getBall() + - (mPhysicWorld.getBlob(LEFT_PLAYER) - mPhysicWorld.getBall()).normalise().scale(31.5); - BloodManager::getSingleton().spillBlood(hitPos, mPhysicWorld.lastHitIntensity(), 0); - } - mLeftHitcount++; - mRightHitcount = 0; - mSquishLeft = 1; - } - } - else - { - mSquishLeft += 1; - if(mSquishLeft > 9) - mSquishLeft=0; - } + events |= EVENT_LEFT_BLOBBY_HIT; - if(0 == mSquishRight) - { if (mPhysicWorld.ballHitRightPlayer()) - { - if (mOutput) - { - smanager->playSound("sounds/bums.wav", - mPhysicWorld.lastHitIntensity() + BALL_HIT_PLAYER_SOUND_VOLUME); - Vector2 hitPos = mPhysicWorld.getBall() + - (mPhysicWorld.getBlob(RIGHT_PLAYER) - mPhysicWorld.getBall()).normalise().scale(31.5); - BloodManager::getSingleton().spillBlood(hitPos, mPhysicWorld.lastHitIntensity(), 1); - } - mRightHitcount++; - mLeftHitcount = 0; - mSquishRight = 1; - } - } - else - { - mSquishRight += 1; - if(mSquishRight > 9) - mSquishRight = 0; - } + events |= EVENT_RIGHT_BLOBBY_HIT; - if (mPhysicWorld.ballHitLeftGround() || mLeftHitcount > 3) - { - if (mLeftHitcount > 3) - mPhysicWorld.dampBall(); - if (mOutput) - smanager->playSound("sounds/pfiff.wav", ROUND_START_SOUND_VOLUME); - if (mServingPlayer == 1) - mRightScore++; - mServingPlayer = RIGHT_PLAYER; - mPhysicWorld.setBallValidity(0); - mBallDown = true; - mRightHitcount = 0; - mLeftHitcount = 0; - mSquishRight = 0; - mSquishLeft = 0; - } + if(mPhysicWorld.ballHitLeftGround()) + events |= EVENT_BALL_HIT_LEFT_GROUND; - if (mPhysicWorld.ballHitRightGround() || mRightHitcount > 3) - { - if(mRightHitcount > 3) - mPhysicWorld.dampBall(); - if (mOutput) - smanager->playSound("sounds/pfiff.wav", ROUND_START_SOUND_VOLUME); - if (mServingPlayer == 0) - mLeftScore++; - mServingPlayer = LEFT_PLAYER; - mPhysicWorld.setBallValidity(0); - mBallDown = true; - mRightHitcount = 0; - mLeftHitcount = 0; - mSquishRight = 0; - mSquishLeft = 0; + if(mPhysicWorld.ballHitRightGround()) + events |= EVENT_BALL_HIT_RIGHT_GROUND; } - - if (mOutput) - { - // This is done seperate from other output because the - // winning screen would display old scores otherwise - rmanager->setScore(mLeftScore, mRightScore, - mServingPlayer == 0, mServingPlayer == 1); + + // process events + if (events & EVENT_LEFT_BLOBBY_HIT) + mLogic->onBallHitsPlayer(LEFT_PLAYER); + + if (events & EVENT_RIGHT_BLOBBY_HIT) + mLogic->onBallHitsPlayer(RIGHT_PLAYER); + + if(events & EVENT_BALL_HIT_LEFT_GROUND) + mLogic->onBallHitsGround(LEFT_PLAYER); + + if(events & EVENT_BALL_HIT_RIGHT_GROUND) + mLogic->onBallHitsGround(RIGHT_PLAYER); + + + + switch(mLogic->getLastErrorSide()){ + case LEFT_PLAYER: + events |= EVENT_ERROR_LEFT; + case RIGHT_PLAYER: + // if the error was caused by the right player + // reset EVENT_ERROR_LEFT + events &= ~EVENT_ERROR_LEFT; + events |= EVENT_ERROR_RIGHT; + if (!(events & EVENT_BALL_HIT_GROUND)) + mPhysicWorld.dampBall(); + + mPhysicWorld.setBallValidity(0); + mBallDown = true; + break; + } if (mPhysicWorld.roundFinished()) { mBallDown = false; - mPhysicWorld.reset(mServingPlayer); + mPhysicWorld.reset(mLogic->getServingPlayer()); + events |= EVENT_RESET; } + + external_events = 0; +} + +void DuelMatch::setScore(int left, int right) +{ + mLogic->setScore(LEFT_PLAYER, left); + mLogic->setScore(RIGHT_PLAYER, right); } +void DuelMatch::trigger(int event) +{ + external_events |= event; +} + +void DuelMatch::pause() +{ + mLogic->onPause(); + mPaused = true; +} +void DuelMatch::unpause() +{ + mLogic->onUnPause(); + mPaused = false; +} PlayerSide DuelMatch::winningPlayer() { - if (mLeftScore >= mScoreToWin && mLeftScore >= mRightScore + 2) - return LEFT_PLAYER; - if (mRightScore >= mScoreToWin && mRightScore >= mLeftScore + 2) - return RIGHT_PLAYER; - return NO_PLAYER; + return mLogic->getWinningPlayer(); } -int DuelMatch::getHitcount(PlayerSide player) +int DuelMatch::getHitcount(PlayerSide player) const { if (player == LEFT_PLAYER) - return mLeftHitcount; + return mLogic->getHits(LEFT_PLAYER); else if (player == RIGHT_PLAYER) - return mRightHitcount; + return mLogic->getHits(RIGHT_PLAYER); else return 0; } -bool DuelMatch::getBallDown() +int DuelMatch::getScore(PlayerSide player) const +{ + return mLogic->getScore(player); +} + +int DuelMatch::getScoreToWin() const +{ + return mLogic->getScoreToWin(); +} + +bool DuelMatch::getBallDown() const { return mBallDown; } -bool DuelMatch::getBallActive() +bool DuelMatch::getBallActive() const { return mPhysicWorld.getBallActive(); } -bool DuelMatch::getBlobJump(PlayerSide player) +bool DuelMatch::getBlobJump(PlayerSide player) const { return mPhysicWorld.getBlobJump(player); } -Vector2 DuelMatch::getBlobPosition(PlayerSide player) +Vector2 DuelMatch::getBlobPosition(PlayerSide player) const { if (player == LEFT_PLAYER) return mPhysicWorld.getBlob(LEFT_PLAYER); @@ -241,36 +210,19 @@ return Vector2(0.0, 0.0); } -Vector2 DuelMatch::getBallPosition() +Vector2 DuelMatch::getBallPosition() const { return mPhysicWorld.getBall(); } -Vector2 DuelMatch::getBallVelocity() +Vector2 DuelMatch::getBallVelocity() const { return mPhysicWorld.getBallVelocity(); } -float DuelMatch::getBallEstimation() -{ - return mPhysicWorld.estimateBallImpact(); -} - -Vector2 DuelMatch::getBallTimeEstimation(int steps) -{ - return mPhysicWorld.estimateBallPosition(steps); -} - -PlayerSide DuelMatch::getServingPlayer() -{ - PlayerSide side = mServingPlayer; - if (side == NO_PLAYER) - { - // This not exactly the situation, but it is necessary to tell - // the script system this value, so it doesn't get confused. - side = LEFT_PLAYER; - } - return side; +PlayerSide DuelMatch::getServingPlayer() const +{ // NO_PLAYER hack was moved into ScriptedInpurSource.cpp + return mLogic->getServingPlayer(); } void DuelMatch::setState(RakNet::BitStream* stream) @@ -278,38 +230,29 @@ mPhysicWorld.setState(stream); } -const PlayerInput* DuelMatch::getPlayersInput() +const PlayerInput* DuelMatch::getPlayersInput() const { return mPhysicWorld.getPlayersInput(); } -void DuelMatch::setPlayersInput(PlayerInput* input) +void DuelMatch::setPlayersInput(const PlayerInput* input) { mPhysicWorld.setLeftInput(input[LEFT_PLAYER]); mPhysicWorld.setRightInput(input[RIGHT_PLAYER]); } -void DuelMatch::setPlayerName(std::string name) -{ - mPlayerName = name; -} - -void DuelMatch::setOpponentName(std::string name) -{ - mOpponentName = name; -} - -std::string DuelMatch::getPlayerName() +void DuelMatch::setServingPlayer(PlayerSide side) { - return mPlayerName; + mLogic->setServingPlayer(side); + mPhysicWorld.reset(side); } -std::string DuelMatch::getOpponentName() +const Clock& DuelMatch::getClock() const { - return mOpponentName; + return mLogic->getClock(); } -void DuelMatch::setServingPlayer(PlayerSide side) +Clock& DuelMatch::getClock() { - mPhysicWorld.reset(side); + return mLogic->getClock(); } diff -Nru blobby-0.8-dfsg/src/DuelMatch.h blobby-0.9c/src/DuelMatch.h --- blobby-0.8-dfsg/src/DuelMatch.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/DuelMatch.h 2011-11-06 15:06:46.000000000 +0000 @@ -20,6 +20,7 @@ #pragma once #include "PhysicWorld.h" +#include "GameLogic.h" #include "Vector.h" // This class represents a single game between two players @@ -38,16 +39,14 @@ // results to the user through RenderManager and SoundManager. // A deacivation of the output is useful on dedicated servers - // Allthough DuelMatch is only ment to implement the ruleset - // and combine input and physics, it would be unpractical to - // export the attributes necessary for output. - // If global is true, the instance registered as the main // game and can be accessed from everywhere. There can only // be one global game at a time, otherwise an assertion fails. + + // If remote is true, only physical responses will be calculated + // but hit events and score events are received from network - DuelMatch(InputSource* linput, InputSource* rinput, - bool output, bool global); + DuelMatch(InputSource* linput, InputSource* rinput, bool global, bool remote); ~DuelMatch(); @@ -58,6 +57,12 @@ // This steps through one frame void step(); + + // this methods allow external input + // events triggered by the network + void setScore(int left, int right); + + void trigger(int event); // This reports the index of the winning player and -1 if the // game is still running @@ -68,39 +73,54 @@ // positions and for lua export, which makes them accessable // for scripted input sources - int getScore(PlayerSide player); - PlayerSide getServingPlayer(); - - int getHitcount(PlayerSide player); - - Vector2 getBallPosition(); - Vector2 getBallVelocity(); - Vector2 getBlobPosition(PlayerSide player); - - bool getBallDown(); - bool getBallActive(); - - // Estimates Ball impact point - float getBallEstimation(); - - Vector2 getBallTimeEstimation(int steps); + int getScore(PlayerSide player) const; + int getScoreToWin() const; + PlayerSide getServingPlayer() const; + + int getHitcount(PlayerSide player) const; + + Vector2 getBallPosition() const; + Vector2 getBallVelocity() const; + Vector2 getBlobPosition(PlayerSide player) const; + + const PhysicWorld& getWorld() const{ return mPhysicWorld; }; + const Clock& getClock() const; + Clock& getClock(); + + bool getBallDown() const; + bool getBallActive() const; + + void pause(); + void unpause(); + + bool isPaused() const{ return mPaused; } // This functions returns true if the player launched // and is jumping at the moment - bool getBlobJump(PlayerSide player); + bool getBlobJump(PlayerSide player) const; - // Set a new state recieved from server over a RakNet BitStream + // Set a new state received from server over a RakNet BitStream void setState(RakNet::BitStream* stream); //Input stuff for recording and playing replays - const PlayerInput* getPlayersInput(); - void setPlayersInput(PlayerInput* input); - - void setPlayerName(std::string name); - void setOpponentName(std::string name); - std::string getPlayerName(); - std::string getOpponentName(); + const PlayerInput* getPlayersInput() const; + void setPlayersInput(const PlayerInput* input); + void setServingPlayer(PlayerSide side); + + enum { + EVENT_LEFT_BLOBBY_HIT = 1, + EVENT_RIGHT_BLOBBY_HIT = 2, + EVENT_BALL_HIT_LEFT_GROUND = 4, + EVENT_BALL_HIT_RIGHT_GROUND = 8, + EVENT_BALL_HIT_GROUND = EVENT_BALL_HIT_LEFT_GROUND | EVENT_BALL_HIT_RIGHT_GROUND, + EVENT_ERROR_LEFT = 16, + EVENT_ERROR_RIGHT = 32, + EVENT_ERROR = EVENT_ERROR_LEFT | EVENT_ERROR_RIGHT, + EVENT_RESET = 64 + }; + + int getEvents() const { return events; } private: static DuelMatch* mMainGame; @@ -111,22 +131,13 @@ InputSource* mLeftInput; InputSource* mRightInput; - int mLeftScore; - int mRightScore; - PlayerSide mServingPlayer; - - int mLeftHitcount; - int mRightHitcount; - - int mSquishLeft; - int mSquishRight; + GameLogic mLogic; bool mBallDown; + + bool mPaused; - bool mOutput; - int mWinningPlayer; - int mScoreToWin; - - std::string mPlayerName; - std::string mOpponentName; + int events; + int external_events; + bool mRemote; }; diff -Nru blobby-0.8-dfsg/src/GameConstants.h blobby-0.9c/src/GameConstants.h --- blobby-0.8-dfsg/src/GameConstants.h 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/GameConstants.h 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,59 @@ +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + +// Border Settings +const float LEFT_PLANE = 0; +const float RIGHT_PLANE = 800.0; +// These numbers should include the blobbys width, but in the original game +// the blobbys can go a bit into the walls too. + + + +// Blobby Settings +const float BLOBBY_HEIGHT = 89; +//const float BLOBBY_WIDTH = 75; // what is the meaning of this value ??????? +const float BLOBBY_UPPER_SPHERE = 19; +const float BLOBBY_UPPER_RADIUS = 25; +const float BLOBBY_LOWER_SPHERE = 13; +const float BLOBBY_LOWER_RADIUS = 33; + +// This is exactly the half of the gravitation, i checked it in +// the original code +const float BLOBBY_JUMP_BUFFER = 0.44; +const float GRAVITATION = 0.88; +const float BLOBBY_JUMP_ACCELERATION = 15.1; + + +// Ball Settings +const float BALL_RADIUS = 31.5; +const float BALL_GRAVITATION = 0.28; +const float BALL_COLLISION_VELOCITY = 13.125; + + +// Volley Ball Net +const float NET_POSITION_X = RIGHT_PLANE / 2; +const float NET_POSITION_Y = 438; +const float NET_RADIUS = 7; +//const float NET_SPHERE = 154; // what is the meaning of this value ??????? +const float NET_SPHERE_POSITION = 284; + +// Ground Settings +const float GROUND_PLANE_HEIGHT_MAX = 500; +const float GROUND_PLANE_HEIGHT = GROUND_PLANE_HEIGHT_MAX - BLOBBY_HEIGHT / 2.0; + diff -Nru blobby-0.8-dfsg/src/GameLogic.cpp blobby-0.9c/src/GameLogic.cpp --- blobby-0.8-dfsg/src/GameLogic.cpp 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/GameLogic.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,453 @@ +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + +#include +#include + +#include "GameLogic.h" + +extern "C" +{ +#include "lua/lua.h" +#include "lua/lauxlib.h" +#include "lua/lualib.h" +} + +#include +#include + +// copied from ScriptedInputSource +// TODO avoid code duplication + +struct ReaderInfo +{ + PHYSFS_file* handle; + char readBuffer[2048]; +}; + +static const char* chunkReader(lua_State* state, void* data, size_t *size) +{ + ReaderInfo* info = (ReaderInfo*) data; + int bytesRead = PHYSFS_read(info->handle, info->readBuffer, 1, 2048); + *size = bytesRead; + if (bytesRead == 0) + { + return 0; + } + else + { + return info->readBuffer; + } +} + + + + +/// how many steps must pass until the next hit can happen +const int SQUISH_TOLERANCE = 10; + + +IGameLogic::IGameLogic(): mLastError(NO_PLAYER), + mServingPlayer(NO_PLAYER), + mWinningPlayer(NO_PLAYER), + mScoreToWin(15) +{ + // init clock + clock.reset(); + clock.start(); + reset(); +} + +IGameLogic::~IGameLogic() { + // nothing to do +} + +int IGameLogic::getScore(PlayerSide side) const +{ + return mScores[side2index(side)]; +} + +void IGameLogic::setScore(PlayerSide side, int score) +{ + mScores[side2index(side)] = score; +} + + +void IGameLogic::setScoreToWin(int stw) +{ + assert(stw > 0); + mScoreToWin = stw; + // when are the values in the lua script updated? + //lua_pushnumber(mState, mScoreToWin); + //lua_setglobal(mState, "SCORE_TO_WIN"); +} + +int IGameLogic::getScoreToWin() const +{ + return mScoreToWin; +} + +PlayerSide IGameLogic::getServingPlayer() const +{ + return mServingPlayer; +} + +void IGameLogic::setServingPlayer(PlayerSide side) +{ + mServingPlayer = side; +} + +int IGameLogic::getHits(PlayerSide side) const +{ + return mTouches[side2index(side)]; +} + +PlayerSide IGameLogic::getWinningPlayer() const +{ + return mWinningPlayer; +} + +Clock& IGameLogic::getClock() +{ + return clock; +} + +PlayerSide IGameLogic::getLastErrorSide() +{ + PlayerSide t = mLastError; + mLastError = NO_PLAYER; + /// reset mLastError to NO_PLAYER + /// why? + return t; +} + +// ------------------------------------------------------------------------------------------------- +// Event Handlers +// ------------------------------------------------------------------------------------------------- +void IGameLogic::step() +{ + clock.step(); + + if(clock.isRunning()) + { + --mSquish[0]; + --mSquish[1]; + } +} + +void IGameLogic::onPause() +{ + clock.stop(); +} +void IGameLogic::onUnPause() +{ + clock.start(); +} + +void IGameLogic::onBallHitsGround(PlayerSide side) +{ + onError(side); +} + +bool IGameLogic::isCollisionValid(PlayerSide side) const +{ + // check whether the ball is squished + return mSquish[side2index(side)] < 0; +} + +void IGameLogic::onBallHitsPlayer(PlayerSide side) +{ + if(!isCollisionValid(side)) + return; + + // otherwise, set the squish value + mSquish[side2index(side)] = SQUISH_TOLERANCE; + + // count the touches + mTouches[side2index(other_side(side))] = 0; + mTouches[side2index(side)]++; + if( mTouches[side2index(side)] > 3 ) + { + // if a player hits a forth time, it is an error + onError(side); + } +} + + +void IGameLogic::score(PlayerSide side) +{ + ++mScores[side2index(side)]; + mTouches[0] = 0; + mTouches[1] = 0; + mWinningPlayer = checkWin(); +} + +void IGameLogic::reset() +{ + mScores[0] = 0; + mScores[1] = 0; + mTouches[0] = 0; + mTouches[1] = 0; + mSquish[0] = 0; + mSquish[1] = 0; +} + +void IGameLogic::onError(PlayerSide side) +{ + mLastError = side; + + mTouches[0] = 0; + mTouches[1] = 0; + mSquish[0] = 0; + mSquish[1] = 0; + + OnMistake(side); + mServingPlayer = other_side(side); +} + + +// ------------------------------------------------------------------------------------------------- + + +class LuaGameLogic : public IGameLogic +{ + public: + LuaGameLogic(const std::string& file); + virtual ~LuaGameLogic(); + + private: + + virtual PlayerSide checkWin() const; + virtual void OnMistake(PlayerSide side); + + // lua functions + static int luaScore(lua_State* state); + static int luaGetOpponent(lua_State* state); + static int luaGetServingPlayer(lua_State* state); + static int luaGetGameTime(lua_State* state); + + // lua state + lua_State* mState; +}; + + + +LuaGameLogic::LuaGameLogic( const std::string& filename ) : mState( lua_open() ) +{ + + lua_pushlightuserdata(mState, this); + lua_setglobal(mState, "__GAME_LOGIC_POINTER"); + + /// \todo how to push parameters??? + /// \todo how to react when mScoreToWin changes? + lua_pushnumber(mState, getScoreToWin()); + lua_setglobal(mState, "SCORE_TO_WIN"); + + // add functions + lua_register(mState, "score", luaScore); + lua_register(mState, "opponent", luaGetOpponent); + lua_register(mState, "servingplayer", luaGetServingPlayer); + lua_register(mState, "time", luaGetGameTime); + + + // now load script file + ReaderInfo info; + /// todo must this be closed somewhere???? + info.handle = PHYSFS_openRead(filename.c_str()); + if (!info.handle) + { + throw FileLoadException(filename); + } + int error = lua_load(mState, chunkReader, &info, filename.c_str()); + PHYSFS_close(info.handle); + if (error == 0) + error = lua_pcall(mState, 0, 6, 0); + + //! \todo thats not good, needs a hardcoded fallback ruleset + if (error) + { + std::cerr << "Lua Error: " << lua_tostring(mState, -1); + std::cerr << std::endl; + ScriptException except; + except.luaerror = lua_tostring(mState, -1); + lua_pop(mState, 1); + lua_close(mState); + throw except; + } + + // check that all functions are available + lua_getglobal(mState, "IsWinning"); + if (!lua_isfunction(mState, -1)) + { + std::cerr << "Script Error: Could not find function IsWinning"; + std::cerr << std::endl; + ScriptException except; + except.luaerror = "Could not find function IsWinning"; + lua_pop(mState, 1); + lua_close(mState); + throw except; + } + lua_getglobal(mState, "OnMistake"); + if (!lua_isfunction(mState, -1)) + { + std::cerr << "Script Error: Could not find function OnMistake"; + std::cerr << std::endl; + ScriptException except; + except.luaerror = "Could not find function OnMistake"; + lua_pop(mState, 1); + lua_close(mState); + throw except; + } +} + +LuaGameLogic::~LuaGameLogic() +{ + lua_close(mState); +} + +PlayerSide LuaGameLogic::checkWin() const +{ + bool won = false; + lua_getglobal(mState, "IsWinning"); + + lua_pushnumber(mState, getScore(LEFT_PLAYER) ); + lua_pushnumber(mState, getScore(RIGHT_PLAYER) ); + if( lua_pcall(mState, 2, 1, 0) ) + { + std::cerr << "Lua Error: " << lua_tostring(mState, -1); + std::cerr << std::endl; + }; + + won = lua_toboolean(mState, -1); + lua_pop(mState, 1); + + if(won) + { + if( getScore(LEFT_PLAYER) > getScore(RIGHT_PLAYER) ) + return LEFT_PLAYER; + + if( getScore(LEFT_PLAYER) < getScore(RIGHT_PLAYER) ) + return RIGHT_PLAYER; + } + + return NO_PLAYER; +} + +void LuaGameLogic::OnMistake(PlayerSide side) +{ + // call lua scoring rules + lua_getglobal(mState, "OnMistake"); + lua_pushnumber(mState, side); + if(lua_pcall(mState, 1, 0, 0)) + { + std::cerr << "Lua Error: " << lua_tostring(mState, -1); + std::cerr << std::endl; + }; +} + +int LuaGameLogic::luaScore(lua_State* state) +{ + int pl = int(lua_tonumber(state, -1) + 0.5); + lua_pop(state, 1); + lua_getglobal(state, "__GAME_LOGIC_POINTER"); + LuaGameLogic* gl = (LuaGameLogic*)lua_touserdata(state, -1); + lua_pop(state, 1); + + gl->score((PlayerSide)pl); + return 0; +} + +int LuaGameLogic::luaGetOpponent(lua_State* state) +{ + int pl = int(lua_tonumber(state, -1) + 0.5); + lua_pop(state, 1); + lua_pushnumber(state, other_side((PlayerSide)pl)); + return 1; +} + +int LuaGameLogic::luaGetServingPlayer(lua_State* state) +{ + lua_getglobal(state, "__GAME_LOGIC_POINTER"); + LuaGameLogic* gl = (LuaGameLogic*)lua_touserdata(state, -1); + lua_pop(state, 1); + + lua_pushnumber(state, gl->getServingPlayer()); + return 1; +} + +int LuaGameLogic::luaGetGameTime(lua_State* state) +{ + lua_getglobal(state, "__GAME_LOGIC_POINTER"); + LuaGameLogic* gl = (LuaGameLogic*)lua_touserdata(state, -1); + lua_pop(state, 1); + + lua_pushnumber(state, gl->getClock().getTime()); + return 1; +} + + +class FallbackGameLogic : public IGameLogic +{ + public: + FallbackGameLogic() + { + + } + virtual ~FallbackGameLogic() + { + + } + + private: + + virtual PlayerSide checkWin() const + { + if( getScore(LEFT_PLAYER) >= getScoreToWin() ) { + return LEFT_PLAYER; + } + + if( getScore(RIGHT_PLAYER) >= getScoreToWin() ) { + return RIGHT_PLAYER; + } + + return NO_PLAYER; + } + + virtual void OnMistake(PlayerSide side) + { + score( other_side(side) ); + } +}; + +GameLogic createGameLogic(const std::string& file) +{ + try + { + return std::auto_ptr( new LuaGameLogic(file) ); + } + catch(...) + { + std::cerr << "Script Error: Could not create LuaGameLogic"; + std::cerr << std::endl; + std::cerr << " Using fallback ruleset"; + std::cerr << std::endl; + return std::auto_ptr(new FallbackGameLogic()); + } + +} diff -Nru blobby-0.8-dfsg/src/GameLogic.h blobby-0.9c/src/GameLogic.h --- blobby-0.8-dfsg/src/GameLogic.h 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/GameLogic.h 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,168 @@ +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + +#pragma once + + +#include + + +#include "Global.h" +#include "Clock.h" + +/// this class is told what happens in the game and it applies the rules to count +/// the points. it is designed as a abstract base class to provide different +/// implementations (ie old/new volleyball rules) +class IGameLogic +{ + public: + // constuctor and destructor + IGameLogic(); + virtual ~IGameLogic(); + + // ----------------------------------------------------------------------------------------- + // Read/Write Basic Data + // ----------------------------------------------------------------------------------------- + + // methods for querying the score/touches of a patricular team + int getScore(PlayerSide side) const; + void setScore(PlayerSide side, int score); // when might need such a method if we add saved games + + int getHits(PlayerSide side) const; + + // method for querying and setting the serving player + PlayerSide getServingPlayer() const; + void setServingPlayer(PlayerSide side); + + + /// returns the winning player or NO_PLAYER if the + /// game still runs + PlayerSide getWinningPlayer() const; + + /// returns who has made the last mistake. + /// after this request, the value is reset + PlayerSide getLastErrorSide(); + + // methods for setting/getting the target score + void setScoreToWin(int stw); + int getScoreToWin() const; + + /// gets the associated clock + Clock& getClock(); + + // ----------------------------------------------------------------------------------------- + // Event - Handlers + // ----------------------------------------------------------------------------------------- + + // methods to inform the game logic what is happening in the game + + + /// called when ball hits ground + void onBallHitsGround(PlayerSide side); + + /// called when ball hits player + void onBallHitsPlayer(PlayerSide side); + + // returns whether the collision was valid (max. 3 hits) + bool isCollisionValid(PlayerSide side) const; + + + // set/unset pause mode + void onPause(); + void onUnPause(); + + /// must be called every step + void step(); + + protected: + /// this method must be called if a team scores + /// is increments the points of that team + void score(PlayerSide side); + + // helper functions + + // convert player side into array index + static inline int side2index(PlayerSide side) + { + assert(side == LEFT_PLAYER || side == RIGHT_PLAYER); + return side - LEFT_PLAYER; + } + + // determine the opposite player side + static inline PlayerSide other_side(PlayerSide side) + { + switch(side) + { + case LEFT_PLAYER: + return RIGHT_PLAYER; + case RIGHT_PLAYER: + return LEFT_PLAYER; + default: + assert(0); + } + } + + private: + // resets score and touches + void reset(); + + // this is called when a player makes a + // mistake + void onError(PlayerSide side); + + /// this function is called by on error, it contains the customizable part of the + /// error handling + virtual void OnMistake(PlayerSide side) = 0; + + /// thic function checks whether a player has won the game + virtual PlayerSide checkWin() const = 0; + + + // data memberss + /// this array contains the scores + int mScores[2]; + /// in this array the number of touches are counted + int mTouches[2]; + /// this is an helper array to prevent counting hits that happen too fast twice + int mSquish[2]; + + /// last side that made an error + PlayerSide mLastError; + /// player that is currently serving + PlayerSide mServingPlayer; + /// player that has won the game + /// \todo do we really need to cache this information here?? + PlayerSide mWinningPlayer; + + /// config parameter: score to win + /// \todo how do we use config parameters with lua rules? + int mScoreToWin; + + /// clock for determining game tome + Clock clock; +}; + +/// typedef to make GameLogic an auto_ptr +/// \todo is auto_ptr the best choice here? +typedef std::auto_ptr GameLogic; + +// function for creating a game logic object +GameLogic createGameLogic(const std::string& rulefile); + + diff -Nru blobby-0.8-dfsg/src/Global.h blobby-0.9c/src/Global.h --- blobby-0.8-dfsg/src/Global.h 2009-12-27 19:00:00.000000000 +0000 +++ blobby-0.9c/src/Global.h 2011-11-06 15:06:46.000000000 +0000 @@ -30,14 +30,17 @@ const int BLOBBY_PORT = 1234; -const int BLOBBY_VERSION_MAJOR = 8; -const int BLOBBY_VERSION_MINOR = 0; +const int BLOBBY_VERSION_MAJOR = 0; +const int BLOBBY_VERSION_MINOR = 92; -const char AppTitle[] = "Blobby Volley 2 version 0.8"; +const char AppTitle[] = "Blobby Volley 2 version 0.9c"; const float ROUND_START_SOUND_VOLUME = 0.2; const float BALL_HIT_PLAYER_SOUND_VOLUME = 0.4; +// max. 1 ms additional latency, but much improved performance +const int RAKNET_THREAD_SLEEP_TIME = 1; + enum PlayerSide { NO_PLAYER = -1, @@ -60,7 +63,10 @@ { Color(int red, int green, int blue) : r(red), g(green), b(blue) {} + Color(unsigned int col) + :r(col&0xff), g((col>>8)&0xff), b((col>>16)&0xff) {} Color() {} + union { struct @@ -81,6 +87,16 @@ { return !(*this == rval); } + + unsigned int toInt() const + { + int i = 0; + i |= r; + i |= g << 8; + i |= b << 16; + return i; + } + }; struct BufferedImage diff -Nru blobby-0.8-dfsg/src/IMGUI.cpp blobby-0.9c/src/IMGUI.cpp --- blobby-0.8-dfsg/src/IMGUI.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/IMGUI.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -22,9 +22,6 @@ #include -#include "InputManager.h" -#include "RenderManager.h" - #include "IMGUI.h" enum ObjectType @@ -32,13 +29,11 @@ IMAGE, OVERLAY, TEXT, - HIGHLIGHTTEXT, - BUTTON, + BUTTON, // Unused! SCROLLBAR, ACTIVESCROLLBAR, EDITBOX, ACTIVEEDITBOX, - HIGHLIGHTEDITBOX, SELECTBOX, ACTIVESELECTBOX, BLOB @@ -54,7 +49,8 @@ std::string text; std::vector entries; int selected; - int lenght; + int length; + unsigned int flags; }; typedef std::queue RenderQueue; @@ -65,7 +61,7 @@ IMGUI::IMGUI() { mQueue = new RenderQueue; - mActiveButton = 0; + mActiveButton = -1; mHeldWidget = 0; mLastKeyAction = NONE; mLastWidget = 0; @@ -107,6 +103,7 @@ void IMGUI::end() { + int FontSize; RenderManager& rmanager = RenderManager::getSingleton(); while (!mQueue->empty()) { @@ -120,10 +117,7 @@ rmanager.drawOverlay(0.6, obj.pos1, obj.pos2, obj.col); break; case TEXT: - rmanager.drawText(obj.text, obj.pos1, false); - break; - case HIGHLIGHTTEXT: - rmanager.drawText(obj.text, obj.pos1, true); + rmanager.drawText(obj.text, obj.pos1, obj.flags); break; case SCROLLBAR: rmanager.drawOverlay(0.4, obj.pos1, obj.pos1 + Vector2(210.0, 26.0)); @@ -132,31 +126,40 @@ case ACTIVESCROLLBAR: rmanager.drawOverlay(0.3, obj.pos1, obj.pos1 + Vector2(210.0, 26.0)); rmanager.drawImage("gfx/scrollbar.bmp",obj.pos1 + Vector2(obj.pos2.x * 200.0 + 5 , 13)); - break; case EDITBOX: - rmanager.drawOverlay(0.4, obj.pos1, obj.pos1 + Vector2(10.0+obj.lenght*24.0, 10.0+24.0)); - rmanager.drawText(obj.text, obj.pos1+Vector2(5.0, 5.0), false); + FontSize = (obj.flags & TF_SMALL_FONT ? FONT_WIDTH_SMALL : FONT_WIDTH_NORMAL); + rmanager.drawOverlay(0.4, obj.pos1, obj.pos1 + Vector2(10+obj.length*FontSize, 10+FontSize)); + rmanager.drawText(obj.text, obj.pos1+Vector2(5, 5), obj.flags); break; case ACTIVEEDITBOX: - rmanager.drawOverlay(0.2, obj.pos1, obj.pos1 + Vector2(10.0+obj.lenght*24.0, 10.0+24.0)); - rmanager.drawText(obj.text, obj.pos1+Vector2(5.0, 5.0), true); + FontSize = (obj.flags & TF_SMALL_FONT ? FONT_WIDTH_SMALL : FONT_WIDTH_NORMAL); + rmanager.drawOverlay(0.2, obj.pos1, obj.pos1 + Vector2(10+obj.length*FontSize, 10+FontSize)); + rmanager.drawText(obj.text, obj.pos1+Vector2(5, 5), obj.flags); if (obj.pos2.x >= 0) - rmanager.drawOverlay(1.0, Vector2((obj.pos2.x)*24.0+obj.pos1.x+5.0, obj.pos1.y+5.0), Vector2((obj.pos2.x)*24.0+obj.pos1.x+5.0+3.0, obj.pos1.y+5.0+24.0), Color(255,255,255)); - break; - case HIGHLIGHTEDITBOX: - rmanager.drawOverlay(0.2, obj.pos1, obj.pos1 + Vector2(10.0+obj.lenght*24.0, 10.0+24.0)); - rmanager.drawText(obj.text, obj.pos1+Vector2(5.0, 5.0), true); + rmanager.drawOverlay(1.0, Vector2((obj.pos2.x)*FontSize+obj.pos1.x+5, obj.pos1.y+5), Vector2((obj.pos2.x)*FontSize+obj.pos1.x+5+3, obj.pos1.y+5+FontSize), Color(255,255,255)); break; case SELECTBOX: + FontSize = (obj.flags & TF_SMALL_FONT ? (FONT_WIDTH_SMALL+LINE_SPACER_SMALL) : (FONT_WIDTH_NORMAL+LINE_SPACER_NORMAL)); rmanager.drawOverlay(0.4, obj.pos1, obj.pos2); for (unsigned int c = 0; c < obj.entries.size(); c++) - rmanager.drawText(obj.entries[c], Vector2(obj.pos1.x+5, obj.pos1.y+(c*24)+5), (c == obj.selected)); + { + if(c == obj.selected) + rmanager.drawText(obj.entries[c], Vector2(obj.pos1.x+5, obj.pos1.y+(c*FontSize)+5), obj.flags | TF_HIGHLIGHT); + else + rmanager.drawText(obj.entries[c], Vector2(obj.pos1.x+5, obj.pos1.y+(c*FontSize)+5), obj.flags); + } break; case ACTIVESELECTBOX: + FontSize = (obj.flags & TF_SMALL_FONT ? (FONT_WIDTH_SMALL+LINE_SPACER_SMALL) : (FONT_WIDTH_NORMAL+LINE_SPACER_NORMAL)); rmanager.drawOverlay(0.2, obj.pos1, obj.pos2); for (unsigned int c = 0; c < obj.entries.size(); c++) - rmanager.drawText(obj.entries[c], Vector2(obj.pos1.x+5, obj.pos1.y+(c*24)+5), (c == obj.selected)); + { + if(c == obj.selected) + rmanager.drawText(obj.entries[c], Vector2(obj.pos1.x+5, obj.pos1.y+(c*FontSize)+5), obj.flags | TF_HIGHLIGHT); + else + rmanager.drawText(obj.entries[c], Vector2(obj.pos1.x+5, obj.pos1.y+(c*FontSize)+5), obj.flags); + } break; case BLOB: rmanager.drawBlob(obj.pos1, obj.col); @@ -185,13 +188,14 @@ mQueue->push(obj); } -void IMGUI::doText(int id, const Vector2& position, const std::string& text) +void IMGUI::doText(int id, const Vector2& position, const std::string& text, unsigned int flags) { QueueObject obj; obj.type = TEXT; obj.id = id; obj.pos1 = position; obj.text = text; + obj.flags = flags; mQueue->push(obj); } @@ -207,7 +211,7 @@ RenderManager::getSingleton().redraw(); } -bool IMGUI::doButton(int id, const Vector2& position, const std::string& text) +bool IMGUI::doButton(int id, const Vector2& position, const std::string& text, unsigned int flags) { bool clicked = false; QueueObject obj; @@ -215,15 +219,36 @@ obj.pos1 = position; obj.text = text; obj.type = TEXT; + obj.flags = flags; if (!mInactive) { + // M.W. : Activate cursorless object-highlighting once the up or down key is pressed. + if (mActiveButton == -1) + { + switch (mLastKeyAction) + { + case DOWN: + mActiveButton = 0; + mLastKeyAction = NONE; + break; + case UP: + mActiveButton = mLastWidget; + mLastKeyAction = NONE; + break; + default: + break; + } + } + + // Highlight first menu object for arrow key navigation. if (mActiveButton == 0 && !mButtonReset) mActiveButton = id; + // React to keyboard input. if (id == mActiveButton) { - obj.type = HIGHLIGHTTEXT; + obj.flags = obj.flags | TF_HIGHLIGHT; switch (mLastKeyAction) { case DOWN: @@ -243,13 +268,14 @@ } } + // React to mouse input. Vector2 mousepos = InputManager::getSingleton()->position(); if (mousepos.x > position.x && mousepos.y > position.y && - mousepos.x < position.x + text.length() * 24 && - mousepos.y < position.y + 24.0) + mousepos.x < position.x + text.length() * (flags & TF_SMALL_FONT ? FONT_WIDTH_SMALL : FONT_WIDTH_NORMAL) && + mousepos.y < position.y + (flags & TF_SMALL_FONT ? FONT_WIDTH_SMALL : FONT_WIDTH_NORMAL)) { - obj.type = HIGHLIGHTTEXT; + obj.flags = obj.flags | TF_HIGHLIGHT; if (InputManager::getSingleton()->click()) { clicked = true; @@ -281,9 +307,29 @@ if (!mInactive) { + // M.W. : Activate cursorless object-highlighting once the up or down key is pressed. + if (mActiveButton == -1) + { + switch (mLastKeyAction) + { + case DOWN: + mActiveButton = 0; + mLastKeyAction = NONE; + break; + case UP: + mActiveButton = mLastWidget; + mLastKeyAction = NONE; + break; + default: + break; + } + } + + // Highlight first menu object for arrow key navigation. if (mActiveButton == 0 && !mButtonReset) mActiveButton = id; - + + // React to keyboard input. if (id == mActiveButton) { obj.type = ACTIVESCROLLBAR; @@ -309,13 +355,16 @@ break; } } - + + // React to mouse input. Vector2 mousepos = InputManager::getSingleton()->position(); if (mousepos.x + 5 > position.x && mousepos.y > position.y && mousepos.x < position.x + 205 && mousepos.y < position.y + 24.0) { + obj.type = ACTIVESCROLLBAR; + if (InputManager::getSingleton()->click()) { mHeldWidget = id; @@ -325,6 +374,11 @@ value = (mousepos.x - position.x) / 200.0; mActiveButton = id; } + + if(InputManager::getSingleton()->mouseWheelUp()) + value += 0.1; + if(InputManager::getSingleton()->mouseWheelDown()) + value -= 0.1; } } @@ -340,40 +394,73 @@ void IMGUI::resetSelection() { mInactive = false; - mActiveButton = 0; + mActiveButton = -1; mButtonReset = true; } -bool IMGUI::doEditbox(int id, const Vector2& position, int length, std::string& text, unsigned& cpos) +bool IMGUI::doEditbox(int id, const Vector2& position, int length, std::string& text, unsigned& cpos, unsigned int flags) { - // lenght does not actually work! + int FontSize = (flags & TF_SMALL_FONT ? FONT_WIDTH_SMALL : FONT_WIDTH_NORMAL); bool changed = false; QueueObject obj; obj.id = id; obj.pos1 = position; obj.type = EDITBOX; - obj.lenght = length; + obj.length = length; // lenght does not actually work! + obj.flags = flags; - Vector2 mousepos = InputManager::getSingleton()->position(); - if (mousepos.x > position.x && - mousepos.y > position.y && - mousepos.x < position.x + length * 24.0 + 10.0 && - mousepos.y < position.y + 24.0 + 10.0) + // React to mouse input. + Vector2 mousepos = InputManager::getSingleton()->position(); + if (mousepos.x > position.x && + mousepos.y > position.y && + mousepos.x < position.x + length * FontSize + 10 && + mousepos.y < position.y + FontSize + 10) + { + obj.flags = obj.flags | TF_HIGHLIGHT; + if (InputManager::getSingleton()->click()) { - obj.type = HIGHLIGHTEDITBOX; - if (InputManager::getSingleton()->click()) - { - if (mousepos.x < position.x + text.length() * 24.0) - cpos = (int)(mousepos.x-position.x-5.0+12)/24; - mActiveButton = id; - } + // Handle click on the text. + if (mousepos.x < position.x + text.length() * FontSize) + cpos = (int) ((mousepos.x-position.x-5+(FontSize/2)) / FontSize); + // Handle click behind the text. + else if (mousepos.x < position.x + length * FontSize + 10) + cpos = (int) text.length(); + mActiveButton = id; } + } if (!mInactive) { + // M.W. : Activate cursorless object-highlighting once the up or down key is pressed. + if (mActiveButton == -1) + { + switch (mLastKeyAction) + { + case DOWN: + mActiveButton = 0; + mLastKeyAction = NONE; + break; + case UP: + mActiveButton = mLastWidget; + mLastKeyAction = NONE; + break; + default: + break; + } + + // M.W. : Initialize the cursor position at the end of the string. + // IMPORTANT: If you make changes to EditBox text that alter the length + // of the text, either call resetSelection() to come back + // to this area of code or update cpos manually to prevent + // crashes due to a misplaced cursor. + cpos = text.length(); + } + + // Highlight first menu object for arrow key navigation. if (mActiveButton == 0 && !mButtonReset) mActiveButton = id; - + + // React to keyboard input. if (id == mActiveButton) { obj.type = ACTIVEEDITBOX; @@ -410,6 +497,11 @@ { text.erase(cpos, 1); } + else if (input == "return") + { + // Workarround for chatwindow! Delete this after GUI-Rework + changed = true; + } // This is a temporary solution until the new // UTF-8 class can tell the real length!!! else if (text.length() < length) @@ -499,23 +591,45 @@ return changed; } -bool IMGUI::doSelectbox(int id, const Vector2& pos1, const Vector2& pos2, const std::vector& entries, int& selected) +bool IMGUI::doSelectbox(int id, const Vector2& pos1, const Vector2& pos2, const std::vector& entries, int& selected, unsigned int flags) { + int FontSize = (flags & TF_SMALL_FONT ? (FONT_WIDTH_SMALL+LINE_SPACER_SMALL) : (FONT_WIDTH_NORMAL+LINE_SPACER_NORMAL)); bool changed = false; QueueObject obj; obj.id = id; obj.pos1 = pos1; obj.pos2 = pos2; obj.type = SELECTBOX; + obj.flags = flags; - const int itemsPerPage = int(pos2.y - pos1.y - 10) / 24; - int first = (int)(selected / itemsPerPage)*itemsPerPage; //the first visible element in the list + const int itemsPerPage = int(pos2.y - pos1.y - 10) / FontSize; + int first = (int)(selected / itemsPerPage)*itemsPerPage; //the first visible element in the list if (!mInactive) { + // M.W. : Activate cursorless object-highlighting once the up or down key is pressed. + if (mActiveButton == -1) + { + switch (mLastKeyAction) + { + case DOWN: + mActiveButton = 0; + mLastKeyAction = NONE; + break; + case UP: + mActiveButton = mLastWidget; + mLastKeyAction = NONE; + break; + default: + break; + } + } + + // Highlight first menu object for arrow key navigation. if (mActiveButton == 0 && !mButtonReset) mActiveButton = id; - + + // React to keyboard input. if (id == mActiveButton) { obj.type = ACTIVESELECTBOX; @@ -550,6 +664,7 @@ } } + // React to mouse input. Vector2 mousepos = InputManager::getSingleton()->position(); if (mousepos.x > pos1.x && mousepos.y > pos1.y && mousepos.x < pos2.x && mousepos.y < pos2.y) { @@ -561,15 +676,25 @@ if (mousepos.x > pos1.x && mousepos.y > pos1.y+5 && mousepos.x < pos2.x-35 && - mousepos.y < pos1.y+5+24*itemsPerPage) + mousepos.y < pos1.y+5+FontSize*itemsPerPage) { if (InputManager::getSingleton()->click()) { - int tmp = (int)((mousepos.y-pos1.y-5) / 24)+first; + int tmp = (int)((mousepos.y-pos1.y-5) / FontSize)+first; if (tmp < entries.size()) selected = tmp; mActiveButton = id; } + if ((InputManager::getSingleton()->mouseWheelUp()) && (selected > 0)) + { + selected--; + changed = true; + } + if ((InputManager::getSingleton()->mouseWheelDown()) && (selected < entries.size()-1)) + { + selected++; + changed = true; + } } //arrows mouseclick: if (mousepos.x > pos2.x-30 && mousepos.x < pos2.x-30+24 && InputManager::getSingleton()->click()) @@ -618,7 +743,7 @@ return false; } -bool IMGUI::usingCursor() +bool IMGUI::usingCursor() const { return mUsingCursor; } diff -Nru blobby-0.8-dfsg/src/IMGUI.h blobby-0.9c/src/IMGUI.h --- blobby-0.8-dfsg/src/IMGUI.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/IMGUI.h 2011-11-06 15:06:46.000000000 +0000 @@ -19,13 +19,15 @@ #pragma once -#include #include #include #include "Vector.h" #include "Global.h" +#include "InputManager.h" +#include "RenderManager.h" + // Warning: This may explode if we use the GUI from several files #define GEN_ID (__LINE__) @@ -50,17 +52,17 @@ void resetSelection(); void doImage(int id, const Vector2& position, const std::string& name); - void doText(int id, const Vector2& position, const std::string& text); + void doText(int id, const Vector2& position, const std::string& text, unsigned int flags = TF_NORMAL); void doOverlay(int id, const Vector2& pos1, const Vector2& pos2, const Color& col = Color(0, 0, 0)); void doCursor(bool draw = true) { mDrawCursor = draw; mUsingCursor = true; } - bool doButton(int id, const Vector2& position, const std::string& text); + bool doButton(int id, const Vector2& position, const std::string& text, unsigned int flags = TF_NORMAL); bool doScrollbar(int id, const Vector2& position, float& value); - bool doEditbox(int id, const Vector2& position, int length, std::string& text, unsigned& cpos); - bool doSelectbox(int id, const Vector2& pos1, const Vector2& pos2, const std::vector& entries, int& selected); + bool doEditbox(int id, const Vector2& position, int length, std::string& text, unsigned& cpos, unsigned int flags = TF_NORMAL); + bool doSelectbox(int id, const Vector2& pos1, const Vector2& pos2, const std::vector& entries, int& selected, unsigned int flags = TF_NORMAL); bool doBlob(int id, const Vector2& position, const Color& col); - bool usingCursor(); + bool usingCursor() const; void doInactiveMode(bool inactive) { mInactive = inactive; } private: IMGUI(); @@ -77,3 +79,4 @@ bool mInactive; bool mUsingCursor; }; + diff -Nru blobby-0.8-dfsg/src/InputDevice.h blobby-0.9c/src/InputDevice.h --- blobby-0.8-dfsg/src/InputDevice.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/InputDevice.h 2011-11-06 15:06:46.000000000 +0000 @@ -19,6 +19,8 @@ #pragma once +#include + #include #include #include "RenderManager.h" @@ -160,9 +162,10 @@ SDL_WarpMouse(600, 310); float blobpos = match->getBlobPosition(mPlayer).x; mMarkerX = mMouseXPos + playerOffset; - if (blobpos + BLOBBY_SPEED < mMarkerX) + if (blobpos + BLOBBY_SPEED * 2 <= mMarkerX) input.right = true; - if (blobpos - BLOBBY_SPEED > mMarkerX) + else + if (blobpos - BLOBBY_SPEED * 2 >= mMarkerX) input.left = true; RenderManager::getSingleton().setMouseMarker(mMarkerX); diff -Nru blobby-0.8-dfsg/src/InputManager.cpp blobby-0.9c/src/InputManager.cpp --- blobby-0.8-dfsg/src/InputManager.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/InputManager.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -128,6 +128,8 @@ mSelect = false; mExit = false; mClick = false; + mMouseWheelUp = false; + mMouseWheelDown = false; mUnclick = false; mLastMouseButton = -1; mLastInputKey = SDLK_UNKNOWN; @@ -176,9 +178,15 @@ mLastMouseButton = event.button.button; switch (event.button.button) { - case 1: + case SDL_BUTTON_LEFT: mClick = true; break; + case SDL_BUTTON_WHEELUP: + mMouseWheelUp = true; + break; + case SDL_BUTTON_WHEELDOWN: + mMouseWheelDown = true; + break; } break; case SDL_MOUSEBUTTONUP: @@ -238,32 +246,32 @@ // GUI-Methods -bool InputManager::up() +bool InputManager::up() const { return mUp; } -bool InputManager::down() +bool InputManager::down() const { return mDown; } -bool InputManager::left() +bool InputManager::left() const { return mLeft; } -bool InputManager::right() +bool InputManager::right() const { return mRight; } -bool InputManager::select() +bool InputManager::select() const { return mSelect; } -bool InputManager::exit() +bool InputManager::exit() const { return mExit; } @@ -274,17 +282,27 @@ return Vector2(mMouseX,mMouseY); } -bool InputManager::click() +bool InputManager::click() const { return mClick; } -bool InputManager::unclick() +bool InputManager::mouseWheelUp() const +{ + return mMouseWheelUp; +} + +bool InputManager::mouseWheelDown() const +{ + return mMouseWheelDown; +} + +bool InputManager::unclick() const { return mUnclick; } -bool InputManager::running() +bool InputManager::running() const { return mRunning; } @@ -583,7 +601,7 @@ return ""; } -std::string InputManager::getLastJoyAction() +std::string InputManager::getLastJoyAction() const { return mLastJoyAction; } diff -Nru blobby-0.8-dfsg/src/InputManager.h blobby-0.9c/src/InputManager.h --- blobby-0.8-dfsg/src/InputManager.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/InputManager.h 2011-11-06 15:06:46.000000000 +0000 @@ -48,6 +48,8 @@ bool mSelect; bool mExit; bool mClick; + bool mMouseWheelUp; + bool mMouseWheelDown; bool mUnclick; int mMouseX; @@ -71,27 +73,29 @@ void beginGame(PlayerSide side); void endGame(); - bool running(); + bool running() const; PlayerInput getGameInput(int player); void updateInput(); // For GUI navigation (Gamepad, Joystick or Keyboard) - bool up(); - bool down(); - bool left(); - bool right(); - bool select(); - bool exit(); // extention for mouse included, so that right click = exit + bool up() const; + bool down() const; + bool left() const; + bool right() const; + bool select() const; + bool exit() const; // extention for mouse included, so that right click = exit std::string getLastTextKey(); std::string getLastActionKey(); - int getLastMouseButton() { return mLastMouseButton; } - std::string getLastJoyAction(); + int getLastMouseButton() const { return mLastMouseButton; } + std::string getLastJoyAction() const; // For GUI navigation (Mouse) Vector2 position(); - bool click(); - bool unclick(); + bool click() const; + bool mouseWheelUp() const; + bool mouseWheelDown() const; + bool unclick() const; // config conversion methods std::string keyToString(SDLKey key); diff -Nru blobby-0.8-dfsg/src/InputSource.h blobby-0.9c/src/InputSource.h --- blobby-0.8-dfsg/src/InputSource.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/InputSource.h 2011-11-06 15:06:46.000000000 +0000 @@ -19,7 +19,7 @@ #pragma once -#include +#include // This struct exists for easy exchange of a single player input frame diff -Nru blobby-0.8-dfsg/src/lua/.svn/all-wcprops blobby-0.9c/src/lua/.svn/all-wcprops --- blobby-0.8-dfsg/src/lua/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/all-wcprops 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,329 @@ +K 25 +svn:wc:ra_dav:version-url +V 42 +/svnroot/blobby/!svn/ver/449/trunk/src/lua +END +lauxlib.c +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lauxlib.c +END +ldebug.c +K 25 +svn:wc:ra_dav:version-url +V 51 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ldebug.c +END +lauxlib.h +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lauxlib.h +END +ldebug.h +K 25 +svn:wc:ra_dav:version-url +V 51 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ldebug.h +END +ltablib.c +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ltablib.c +END +liolib.c +K 25 +svn:wc:ra_dav:version-url +V 51 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/liolib.c +END +lstrlib.c +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lstrlib.c +END +lualib.h +K 25 +svn:wc:ra_dav:version-url +V 51 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lualib.h +END +ldo.c +K 25 +svn:wc:ra_dav:version-url +V 48 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ldo.c +END +ldump.c +K 25 +svn:wc:ra_dav:version-url +V 50 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ldump.c +END +ldo.h +K 25 +svn:wc:ra_dav:version-url +V 48 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ldo.h +END +loslib.c +K 25 +svn:wc:ra_dav:version-url +V 51 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/loslib.c +END +lundump.c +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lundump.c +END +ldblib.c +K 25 +svn:wc:ra_dav:version-url +V 51 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ldblib.c +END +lundump.h +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lundump.h +END +lmem.c +K 25 +svn:wc:ra_dav:version-url +V 49 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lmem.c +END +lmathlib.c +K 25 +svn:wc:ra_dav:version-url +V 53 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lmathlib.c +END +CMakeLists.txt +K 25 +svn:wc:ra_dav:version-url +V 57 +/svnroot/blobby/!svn/ver/426/trunk/src/lua/CMakeLists.txt +END +lstate.c +K 25 +svn:wc:ra_dav:version-url +V 51 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lstate.c +END +ltm.c +K 25 +svn:wc:ra_dav:version-url +V 48 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ltm.c +END +lvm.c +K 25 +svn:wc:ra_dav:version-url +V 48 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lvm.c +END +lmem.h +K 25 +svn:wc:ra_dav:version-url +V 49 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lmem.h +END +lstate.h +K 25 +svn:wc:ra_dav:version-url +V 51 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lstate.h +END +ltm.h +K 25 +svn:wc:ra_dav:version-url +V 48 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ltm.h +END +ltable.c +K 25 +svn:wc:ra_dav:version-url +V 51 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ltable.c +END +lvm.h +K 25 +svn:wc:ra_dav:version-url +V 48 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lvm.h +END +llex.c +K 25 +svn:wc:ra_dav:version-url +V 49 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/llex.c +END +lgc.c +K 25 +svn:wc:ra_dav:version-url +V 48 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lgc.c +END +loadlib.c +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/loadlib.c +END +lfunc.c +K 25 +svn:wc:ra_dav:version-url +V 50 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lfunc.c +END +lopcodes.c +K 25 +svn:wc:ra_dav:version-url +V 53 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lopcodes.c +END +lparser.c +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lparser.c +END +ltable.h +K 25 +svn:wc:ra_dav:version-url +V 51 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/ltable.h +END +llex.h +K 25 +svn:wc:ra_dav:version-url +V 49 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/llex.h +END +lgc.h +K 25 +svn:wc:ra_dav:version-url +V 48 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lgc.h +END +lfunc.h +K 25 +svn:wc:ra_dav:version-url +V 50 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lfunc.h +END +lopcodes.h +K 25 +svn:wc:ra_dav:version-url +V 53 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lopcodes.h +END +lbaselib.c +K 25 +svn:wc:ra_dav:version-url +V 53 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lbaselib.c +END +lparser.h +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lparser.h +END +lzio.c +K 25 +svn:wc:ra_dav:version-url +V 49 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lzio.c +END +linit.c +K 25 +svn:wc:ra_dav:version-url +V 50 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/linit.c +END +lobject.c +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lobject.c +END +llimits.h +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/llimits.h +END +lstring.c +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lstring.c +END +lzio.h +K 25 +svn:wc:ra_dav:version-url +V 49 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lzio.h +END +lapi.c +K 25 +svn:wc:ra_dav:version-url +V 49 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lapi.c +END +lcode.c +K 25 +svn:wc:ra_dav:version-url +V 50 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lcode.c +END +lua.h +K 25 +svn:wc:ra_dav:version-url +V 48 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lua.h +END +lobject.h +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lobject.h +END +lstring.h +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lstring.h +END +lapi.h +K 25 +svn:wc:ra_dav:version-url +V 49 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lapi.h +END +lcode.h +K 25 +svn:wc:ra_dav:version-url +V 50 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/lcode.h +END +luaconf.h +K 25 +svn:wc:ra_dav:version-url +V 52 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/luaconf.h +END +print.c +K 25 +svn:wc:ra_dav:version-url +V 50 +/svnroot/blobby/!svn/ver/449/trunk/src/lua/print.c +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/entries blobby-0.9c/src/lua/.svn/entries --- blobby-0.8-dfsg/src/lua/.svn/entries 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/entries 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,1864 @@ +10 + +dir +634 +https://blobby.svn.sourceforge.net/svnroot/blobby/trunk/src/lua +https://blobby.svn.sourceforge.net/svnroot/blobby + + + +2009-10-05T23:52:41.506969Z +449 +danielknobe + + + + + + + + + + + + + + +5dffb9df-0d16-0410-88a9-e08e82185bbb + +lauxlib.c +file + + + + +2011-11-06T15:06:46.058133Z +036e167458cdea501bd65bac3b28bc1e +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +17417 + +ldebug.c +file + + + + +2011-11-06T15:06:46.058133Z +82c84cf040bf99a5ab821a64b3d17974 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +16840 + +lauxlib.h +file + + + + +2011-11-06T15:06:46.058133Z +9ee455010892bdf666d56ba254ef06e5 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +5777 + +ldebug.h +file + + + + +2011-11-06T15:06:46.058133Z +302eafbfb9fc69dbd9d14f5ab176471f +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1061 + +ltablib.c +file + + + + +2011-11-06T15:06:46.058133Z +25d290590652591f222de3bc384ce9a8 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +7343 + +liolib.c +file + + + + +2011-11-06T15:06:46.068133Z +0b6389d39a7c1fe8ff286919dcac334d +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +13406 + +lstrlib.c +file + + + + +2011-11-06T15:06:46.068133Z +dbaf7cf3c47d558cd0235f69116faf39 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +23481 + +lualib.h +file + + + + +2011-11-06T15:06:46.068133Z +03b9f9c3f7a82bee2f7eab03315eae7d +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1026 + +ldo.c +file + + + + +2011-11-06T15:06:46.068133Z +6ac8b3237c6186ca13f786e546545868 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +14851 + +ldump.c +file + + + + +2011-11-06T15:06:46.068133Z +70784f35ce52f1310af1c582beb1b3b7 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +3114 + +ldo.h +file + + + + +2011-11-06T15:06:46.068133Z +5944c62605bcc1d79caa49970aebeade +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1897 + +loslib.c +file + + + + +2011-11-06T15:06:46.068133Z +e516ae0ffc3d215ea581246517e85c7f +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +5992 + +lundump.c +file + + + + +2011-11-06T15:06:46.068133Z +70843533ca4b52caaea45e0561cf8ced +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +4629 + +ldblib.c +file + + + + +2011-11-06T15:06:46.068133Z +02e4c11fecbdf5466991910c50b549f7 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +10069 + +lundump.h +file + + + + +2011-11-06T15:06:46.068133Z +c1ac612e124b276b85737affc8e816f1 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +890 + +lmem.c +file + + + + +2011-11-06T15:06:46.068133Z +6656f31d1a52aa8031194428787764d7 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +2172 + +lmathlib.c +file + + + + +2011-11-06T15:06:46.068133Z +103b2bbf31c0ed89c373f217559550df +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +5831 + +CMakeLists.txt +file + + + + +2011-11-06T15:06:46.068133Z +6215429694afa734bd7aecb672ea5c01 +2008-03-13T21:51:40.104815Z +426 +yonibear +has-props + + + + + + + + + + + + + + + + + + + + +536 + +lstate.c +file + + + + +2011-11-06T15:06:46.068133Z +c82b593a33e6460cf2254056e9184d6e +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +5674 + +ltm.c +file + + + + +2011-11-06T15:06:46.068133Z +4ef6dd80b6678def7366157b127dd801 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1650 + +lvm.c +file + + + + +2011-11-06T15:06:46.068133Z +009df5dea34190295d8b3c79d6910cc3 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +23126 + +lmem.h +file + + + + +2011-11-06T15:06:46.068133Z +368761f75f040c81f9213c4e0e51192f +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1494 + +lstate.h +file + + + + +2011-11-06T15:06:46.068133Z +0b9a678b6645ac6fc80d215017f50b04 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +5011 + +ltm.h +file + + + + +2011-11-06T15:06:46.068133Z +1397b90da4d859afce633dbbb8c535c2 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1018 + +ltable.c +file + + + + +2011-11-06T15:06:46.078133Z +29c90679a22e5723578a88a267fe463f +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +16263 + +lvm.h +file + + + + +2011-11-06T15:06:46.078133Z +7594c3494d64becc726364fc8ba3ed9f +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1159 + +llex.c +file + + + + +2011-11-06T15:06:46.078133Z +d6b38fc47ecba77449a5957a0b864348 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +12474 + +lgc.c +file + + + + +2011-11-06T15:06:46.078133Z +94ed711f5a231c770b015f62c7fb1ac5 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +20099 + +loadlib.c +file + + + + +2011-11-06T15:06:46.078133Z +4bb5982122e987e8daff9208a6d5a7a3 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +19216 + +lfunc.c +file + + + + +2011-11-06T15:06:46.078133Z +20bdd3463590fa03c54ed57e2168485f +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +4618 + +lparser.c +file + + + + +2011-11-06T15:06:46.078133Z +ee183362e7aa77276b08be18083d77dc +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +36696 + +lopcodes.c +file + + + + +2011-11-06T15:06:46.078133Z +bd304355af8dde4fef9e58476663975a +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +2884 + +ltable.h +file + + + + +2011-11-06T15:06:46.078133Z +301f444a7170b24e293c2323f35115c4 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1184 + +llex.h +file + + + + +2011-11-06T15:06:46.078133Z +0954f33df5b5264df63ad176af6fd8cd +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +2177 + +lgc.h +file + + + + +2011-11-06T15:06:46.078133Z +c24d8d859d1defa912e75d65a06e61c3 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +3159 + +lfunc.h +file + + + + +2011-11-06T15:06:46.088133Z +3a4553282901dc2daa29c535a387e815 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1125 + +lopcodes.h +file + + + + +2011-11-06T15:06:46.088133Z +88a90c5ea4dbec97eb08d306daac2d26 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +8086 + +lbaselib.c +file + + + + +2011-11-06T15:06:46.088133Z +99e7c6c0a82c8ebdfc766114aeed42d7 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +17046 + +lparser.h +file + + + + +2011-11-06T15:06:46.088133Z +85895dd17a4e1bb0ee81c191b0e64b5d +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +2261 + +lzio.c +file + + + + +2011-11-06T15:06:46.088133Z +ea9e7b4a4db44a184580bf0fbefa1600 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1628 + +linit.c +file + + + + +2011-11-06T15:06:46.088133Z +87c49be9d212f531933e19b8a8f4fc9b +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +765 + +lobject.c +file + + + + +2011-11-06T15:06:46.088133Z +7321da04b0f05c85dfe7d37f4cd4400f +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +5498 + +llimits.h +file + + + + +2011-11-06T15:06:46.088133Z +49146162c71b60bac7d70aa68ad987c9 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +2349 + +lstring.c +file + + + + +2011-11-06T15:06:46.088133Z +0ffb701fcc7fc6aeae1d2779b47a1694 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +3110 + +lzio.h +file + + + + +2011-11-06T15:06:46.088133Z +5f93a1157272ff89030b0a1b6f69ed47 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +1556 + +lapi.c +file + + + + +2011-11-06T15:06:46.098133Z +2751d5c9103e098a6eb4850009a6a205 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +22708 + +lcode.c +file + + + + +2011-11-06T15:06:46.098133Z +4c793d782a899cef8efea6c01fe0387a +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +21335 + +lua.h +file + + + + +2011-11-06T15:06:46.098133Z +4d005694d896524f5b8e62d4480de5bb +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +11688 + +lobject.h +file + + + + +2011-11-06T15:06:46.098133Z +5d4be69f06b6832adf6d94a84cfdc58b +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +8502 + +lstring.h +file + + + + +2011-11-06T15:06:46.098133Z +267a74b442487c2d9aa7c7a87f691325 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +814 + +lapi.h +file + + + + +2011-11-06T15:06:46.098133Z +ef97b96a4ca47aa96944985ade67a2cf +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +262 + +lcode.h +file + + + + +2011-11-06T15:06:46.098133Z +88bd055ac668e3262ca79d9e9c5717e3 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +2750 + +luaconf.h +file + + + + +2011-11-06T15:06:46.098133Z +034b876b7026c4f569a9f090b8769b0b +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +22299 + +print.c +file + + + + +2011-11-06T15:06:46.098133Z +a866cf686914f35a76fff22587fb9f66 +2009-10-05T23:52:41.506969Z +449 +danielknobe +has-props + + + + + + + + + + + + + + + + + + + + +4944 + diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/CMakeLists.txt.svn-base blobby-0.9c/src/lua/.svn/prop-base/CMakeLists.txt.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/CMakeLists.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/CMakeLists.txt.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lapi.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lapi.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lapi.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lapi.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lapi.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lapi.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lapi.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lapi.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lauxlib.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lauxlib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lauxlib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lauxlib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lauxlib.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lauxlib.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lauxlib.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lauxlib.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lbaselib.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lbaselib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lbaselib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lbaselib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lcode.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lcode.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lcode.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lcode.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lcode.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lcode.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lcode.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lcode.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ldblib.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/ldblib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ldblib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ldblib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ldebug.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/ldebug.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ldebug.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ldebug.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ldebug.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/ldebug.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ldebug.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ldebug.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ldo.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/ldo.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ldo.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ldo.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ldo.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/ldo.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ldo.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ldo.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ldump.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/ldump.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ldump.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ldump.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lfunc.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lfunc.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lfunc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lfunc.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lfunc.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lfunc.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lfunc.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lfunc.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lgc.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lgc.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lgc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lgc.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lgc.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lgc.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lgc.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lgc.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/linit.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/linit.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/linit.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/linit.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/liolib.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/liolib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/liolib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/liolib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/llex.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/llex.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/llex.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/llex.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/llex.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/llex.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/llex.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/llex.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/llimits.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/llimits.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/llimits.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/llimits.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lmathlib.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lmathlib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lmathlib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lmathlib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lmem.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lmem.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lmem.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lmem.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lmem.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lmem.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lmem.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lmem.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/loadlib.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/loadlib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/loadlib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/loadlib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lobject.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lobject.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lobject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lobject.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lobject.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lobject.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lobject.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lobject.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lopcodes.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lopcodes.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lopcodes.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lopcodes.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lopcodes.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lopcodes.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lopcodes.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lopcodes.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/loslib.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/loslib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/loslib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/loslib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lparser.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lparser.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lparser.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lparser.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lparser.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lparser.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lparser.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lparser.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lstate.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lstate.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lstate.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lstate.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lstate.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lstate.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lstate.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lstate.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lstring.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lstring.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lstring.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lstring.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lstring.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lstring.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lstring.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lstring.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lstrlib.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lstrlib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lstrlib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lstrlib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ltable.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/ltable.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ltable.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ltable.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ltable.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/ltable.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ltable.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ltable.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ltablib.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/ltablib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ltablib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ltablib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ltm.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/ltm.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ltm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ltm.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/ltm.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/ltm.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/ltm.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/ltm.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/luaconf.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/luaconf.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/luaconf.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/luaconf.h.svn-base 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lua.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lua.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lua.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lua.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lualib.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lualib.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lualib.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lualib.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lundump.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lundump.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lundump.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lundump.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lundump.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lundump.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lundump.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lundump.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lvm.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lvm.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lvm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lvm.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lvm.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lvm.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lvm.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lvm.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lzio.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/lzio.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lzio.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lzio.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/lzio.h.svn-base blobby-0.9c/src/lua/.svn/prop-base/lzio.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/lzio.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/lzio.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/prop-base/print.c.svn-base blobby-0.9c/src/lua/.svn/prop-base/print.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/prop-base/print.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/prop-base/print.c.svn-base 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/CMakeLists.txt.svn-base blobby-0.9c/src/lua/.svn/text-base/CMakeLists.txt.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/CMakeLists.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/CMakeLists.txt.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,38 @@ +set (lua_SRC + lapi.c lapi.h + lauxlib.c lauxlib.h + lbaselib.c + lcode.c lcode.h + ldblib.c + ldebug.c ldebug.h + ldo.c ldo.h + ldump.c + lfunc.c lfunc.h + lgc.c lgc.h + linit.c + liolib.c + llex.c llex.h + llimits.h + lmathlib.c + lmem.c lmem.h + loadlib.c + lobject.c lobject.h + lopcodes.c lopcodes.h + loslib.c + lparser.c lparser.h + lstate.c lstate.h + lstring.c lstring.h + lstrlib.c + ltable.c ltable.h + ltablib.c + ltm.c ltm.h + luaconf.h + lua.h + lualib.h + lundump.c lundump.h + lvm.c lvm.h + lzio.c lzio.h + print.c + ) + +add_library(lua STATIC ${lua_SRC}) diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lapi.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lapi.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lapi.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lapi.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,1087 @@ +/* +** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $ +** Lua API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define lapi_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" + + + +const char lua_ident[] = + "$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n" + "$Authors: " LUA_AUTHORS " $\n" + "$URL: www.lua.org $\n"; + + + +#define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) + +#define api_checkvalidindex(L, i) api_check(L, (i) != luaO_nilobject) + +#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} + + + +static TValue *index2adr (lua_State *L, int idx) { + if (idx > 0) { + TValue *o = L->base + (idx - 1); + api_check(L, idx <= L->ci->top - L->base); + if (o >= L->top) return cast(TValue *, luaO_nilobject); + else return o; + } + else if (idx > LUA_REGISTRYINDEX) { + api_check(L, idx != 0 && -idx <= L->top - L->base); + return L->top + idx; + } + else switch (idx) { /* pseudo-indices */ + case LUA_REGISTRYINDEX: return registry(L); + case LUA_ENVIRONINDEX: { + Closure *func = curr_func(L); + sethvalue(L, &L->env, func->c.env); + return &L->env; + } + case LUA_GLOBALSINDEX: return gt(L); + default: { + Closure *func = curr_func(L); + idx = LUA_GLOBALSINDEX - idx; + return (idx <= func->c.nupvalues) + ? &func->c.upvalue[idx-1] + : cast(TValue *, luaO_nilobject); + } + } +} + + +static Table *getcurrenv (lua_State *L) { + if (L->ci == L->base_ci) /* no enclosing function? */ + return hvalue(gt(L)); /* use global table as environment */ + else { + Closure *func = curr_func(L); + return func->c.env; + } +} + + +void luaA_pushobject (lua_State *L, const TValue *o) { + setobj2s(L, L->top, o); + api_incr_top(L); +} + + +LUA_API int lua_checkstack (lua_State *L, int size) { + int res = 1; + lua_lock(L); + if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) + res = 0; /* stack overflow */ + else if (size > 0) { + luaD_checkstack(L, size); + if (L->ci->top < L->top + size) + L->ci->top = L->top + size; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) { + int i; + if (from == to) return; + lua_lock(to); + api_checknelems(from, n); + api_check(from, G(from) == G(to)); + api_check(from, to->ci->top - to->top >= n); + from->top -= n; + for (i = 0; i < n; i++) { + setobj2s(to, to->top++, from->top + i); + } + lua_unlock(to); +} + + +LUA_API void lua_setlevel (lua_State *from, lua_State *to) { + to->nCcalls = from->nCcalls; +} + + +LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { + lua_CFunction old; + lua_lock(L); + old = G(L)->panic; + G(L)->panic = panicf; + lua_unlock(L); + return old; +} + + +LUA_API lua_State *lua_newthread (lua_State *L) { + lua_State *L1; + lua_lock(L); + luaC_checkGC(L); + L1 = luaE_newthread(L); + setthvalue(L, L->top, L1); + api_incr_top(L); + lua_unlock(L); + luai_userstatethread(L, L1); + return L1; +} + + + +/* +** basic stack manipulation +*/ + + +LUA_API int lua_gettop (lua_State *L) { + return cast_int(L->top - L->base); +} + + +LUA_API void lua_settop (lua_State *L, int idx) { + lua_lock(L); + if (idx >= 0) { + api_check(L, idx <= L->stack_last - L->base); + while (L->top < L->base + idx) + setnilvalue(L->top++); + L->top = L->base + idx; + } + else { + api_check(L, -(idx+1) <= (L->top - L->base)); + L->top += idx+1; /* `subtract' index (index is negative) */ + } + lua_unlock(L); +} + + +LUA_API void lua_remove (lua_State *L, int idx) { + StkId p; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + while (++p < L->top) setobjs2s(L, p-1, p); + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_insert (lua_State *L, int idx) { + StkId p; + StkId q; + lua_lock(L); + p = index2adr(L, idx); + api_checkvalidindex(L, p); + for (q = L->top; q>p; q--) setobjs2s(L, q, q-1); + setobjs2s(L, p, L->top); + lua_unlock(L); +} + + +LUA_API void lua_replace (lua_State *L, int idx) { + StkId o; + lua_lock(L); + /* explicit test for incompatible code */ + if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci) + luaG_runerror(L, "no calling environment"); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + if (idx == LUA_ENVIRONINDEX) { + Closure *func = curr_func(L); + api_check(L, ttistable(L->top - 1)); + func->c.env = hvalue(L->top - 1); + luaC_barrier(L, func, L->top - 1); + } + else { + setobj(L, o, L->top - 1); + if (idx < LUA_GLOBALSINDEX) /* function upvalue? */ + luaC_barrier(L, curr_func(L), L->top - 1); + } + L->top--; + lua_unlock(L); +} + + +LUA_API void lua_pushvalue (lua_State *L, int idx) { + lua_lock(L); + setobj2s(L, L->top, index2adr(L, idx)); + api_incr_top(L); + lua_unlock(L); +} + + + +/* +** access functions (stack -> C) +*/ + + +LUA_API int lua_type (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); +} + + +LUA_API const char *lua_typename (lua_State *L, int t) { + UNUSED(L); + return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; +} + + +LUA_API int lua_iscfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return iscfunction(o); +} + + +LUA_API int lua_isnumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + return tonumber(o, &n); +} + + +LUA_API int lua_isstring (lua_State *L, int idx) { + int t = lua_type(L, idx); + return (t == LUA_TSTRING || t == LUA_TNUMBER); +} + + +LUA_API int lua_isuserdata (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return (ttisuserdata(o) || ttislightuserdata(o)); +} + + +LUA_API int lua_rawequal (lua_State *L, int index1, int index2) { + StkId o1 = index2adr(L, index1); + StkId o2 = index2adr(L, index2); + return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaO_rawequalObj(o1, o2); +} + + +LUA_API int lua_equal (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2); + lua_unlock(L); + return i; +} + + +LUA_API int lua_lessthan (lua_State *L, int index1, int index2) { + StkId o1, o2; + int i; + lua_lock(L); /* may call tag method */ + o1 = index2adr(L, index1); + o2 = index2adr(L, index2); + i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 + : luaV_lessthan(L, o1, o2); + lua_unlock(L); + return i; +} + + + +LUA_API lua_Number lua_tonumber (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) + return nvalue(o); + else + return 0; +} + + +LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) { + TValue n; + const TValue *o = index2adr(L, idx); + if (tonumber(o, &n)) { + lua_Integer res; + lua_Number num = nvalue(o); + lua_number2integer(res, num); + return res; + } + else + return 0; +} + + +LUA_API int lua_toboolean (lua_State *L, int idx) { + const TValue *o = index2adr(L, idx); + return !l_isfalse(o); +} + + +LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) { + StkId o = index2adr(L, idx); + if (!ttisstring(o)) { + lua_lock(L); /* `luaV_tostring' may create a new string */ + if (!luaV_tostring(L, o)) { /* conversion failed? */ + if (len != NULL) *len = 0; + lua_unlock(L); + return NULL; + } + luaC_checkGC(L); + o = index2adr(L, idx); /* previous call may reallocate the stack */ + lua_unlock(L); + } + if (len != NULL) *len = tsvalue(o)->len; + return svalue(o); +} + + +LUA_API size_t lua_objlen (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TSTRING: return tsvalue(o)->len; + case LUA_TUSERDATA: return uvalue(o)->len; + case LUA_TTABLE: return luaH_getn(hvalue(o)); + case LUA_TNUMBER: { + size_t l; + lua_lock(L); /* `luaV_tostring' may create a new string */ + l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0); + lua_unlock(L); + return l; + } + default: return 0; + } +} + + +LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!iscfunction(o)) ? NULL : clvalue(o)->c.f; +} + + +LUA_API void *lua_touserdata (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TUSERDATA: return (rawuvalue(o) + 1); + case LUA_TLIGHTUSERDATA: return pvalue(o); + default: return NULL; + } +} + + +LUA_API lua_State *lua_tothread (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + return (!ttisthread(o)) ? NULL : thvalue(o); +} + + +LUA_API const void *lua_topointer (lua_State *L, int idx) { + StkId o = index2adr(L, idx); + switch (ttype(o)) { + case LUA_TTABLE: return hvalue(o); + case LUA_TFUNCTION: return clvalue(o); + case LUA_TTHREAD: return thvalue(o); + case LUA_TUSERDATA: + case LUA_TLIGHTUSERDATA: + return lua_touserdata(L, idx); + default: return NULL; + } +} + + + +/* +** push functions (C -> stack) +*/ + + +LUA_API void lua_pushnil (lua_State *L) { + lua_lock(L); + setnilvalue(L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { + lua_lock(L); + setnvalue(L->top, n); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { + lua_lock(L); + setnvalue(L->top, cast_num(n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { + lua_lock(L); + luaC_checkGC(L); + setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushstring (lua_State *L, const char *s) { + if (s == NULL) + lua_pushnil(L); + else + lua_pushlstring(L, s, strlen(s)); +} + + +LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt, + va_list argp) { + const char *ret; + lua_lock(L); + luaC_checkGC(L); + ret = luaO_pushvfstring(L, fmt, argp); + lua_unlock(L); + return ret; +} + + +LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) { + const char *ret; + va_list argp; + lua_lock(L); + luaC_checkGC(L); + va_start(argp, fmt); + ret = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + lua_unlock(L); + return ret; +} + + +LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { + Closure *cl; + lua_lock(L); + luaC_checkGC(L); + api_checknelems(L, n); + cl = luaF_newCclosure(L, n, getcurrenv(L)); + cl->c.f = fn; + L->top -= n; + while (n--) + setobj2n(L, &cl->c.upvalue[n], L->top+n); + setclvalue(L, L->top, cl); + lua_assert(iswhite(obj2gco(cl))); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushboolean (lua_State *L, int b) { + lua_lock(L); + setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_pushlightuserdata (lua_State *L, void *p) { + lua_lock(L); + setpvalue(L->top, p); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_pushthread (lua_State *L) { + lua_lock(L); + setthvalue(L, L->top, L); + api_incr_top(L); + lua_unlock(L); + return (G(L)->mainthread == L); +} + + + +/* +** get functions (Lua -> stack) +*/ + + +LUA_API void lua_gettable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_gettable(L, t, L->top - 1, L->top - 1); + lua_unlock(L); +} + + +LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_gettable(L, t, &key, L->top); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_rawget (lua_State *L, int idx) { + StkId t; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1)); + lua_unlock(L); +} + + +LUA_API void lua_rawgeti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2s(L, L->top, luaH_getnum(hvalue(o), n)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { + lua_lock(L); + luaC_checkGC(L); + sethvalue(L, L->top, luaH_new(L, narray, nrec)); + api_incr_top(L); + lua_unlock(L); +} + + +LUA_API int lua_getmetatable (lua_State *L, int objindex) { + const TValue *obj; + Table *mt = NULL; + int res; + lua_lock(L); + obj = index2adr(L, objindex); + switch (ttype(obj)) { + case LUA_TTABLE: + mt = hvalue(obj)->metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(obj)->metatable; + break; + default: + mt = G(L)->mt[ttype(obj)]; + break; + } + if (mt == NULL) + res = 0; + else { + sethvalue(L, L->top, mt); + api_incr_top(L); + res = 1; + } + lua_unlock(L); + return res; +} + + +LUA_API void lua_getfenv (lua_State *L, int idx) { + StkId o; + lua_lock(L); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + switch (ttype(o)) { + case LUA_TFUNCTION: + sethvalue(L, L->top, clvalue(o)->c.env); + break; + case LUA_TUSERDATA: + sethvalue(L, L->top, uvalue(o)->env); + break; + case LUA_TTHREAD: + setobj2s(L, L->top, gt(thvalue(o))); + break; + default: + setnilvalue(L->top); + break; + } + api_incr_top(L); + lua_unlock(L); +} + + +/* +** set functions (stack -> Lua) +*/ + + +LUA_API void lua_settable (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + luaV_settable(L, t, L->top - 2, L->top - 1); + L->top -= 2; /* pop index and value */ + lua_unlock(L); +} + + +LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; + lua_lock(L); + api_checknelems(L, 1); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_settable(L, t, &key, L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); +} + + +LUA_API void lua_rawset (lua_State *L, int idx) { + StkId t; + lua_lock(L); + api_checknelems(L, 2); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1); + luaC_barriert(L, hvalue(t), L->top-1); + L->top -= 2; + lua_unlock(L); +} + + +LUA_API void lua_rawseti (lua_State *L, int idx, int n) { + StkId o; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_check(L, ttistable(o)); + setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1); + luaC_barriert(L, hvalue(o), L->top-1); + L->top--; + lua_unlock(L); +} + + +LUA_API int lua_setmetatable (lua_State *L, int objindex) { + TValue *obj; + Table *mt; + lua_lock(L); + api_checknelems(L, 1); + obj = index2adr(L, objindex); + api_checkvalidindex(L, obj); + if (ttisnil(L->top - 1)) + mt = NULL; + else { + api_check(L, ttistable(L->top - 1)); + mt = hvalue(L->top - 1); + } + switch (ttype(obj)) { + case LUA_TTABLE: { + hvalue(obj)->metatable = mt; + if (mt) + luaC_objbarriert(L, hvalue(obj), mt); + break; + } + case LUA_TUSERDATA: { + uvalue(obj)->metatable = mt; + if (mt) + luaC_objbarrier(L, rawuvalue(obj), mt); + break; + } + default: { + G(L)->mt[ttype(obj)] = mt; + break; + } + } + L->top--; + lua_unlock(L); + return 1; +} + + +LUA_API int lua_setfenv (lua_State *L, int idx) { + StkId o; + int res = 1; + lua_lock(L); + api_checknelems(L, 1); + o = index2adr(L, idx); + api_checkvalidindex(L, o); + api_check(L, ttistable(L->top - 1)); + switch (ttype(o)) { + case LUA_TFUNCTION: + clvalue(o)->c.env = hvalue(L->top - 1); + break; + case LUA_TUSERDATA: + uvalue(o)->env = hvalue(L->top - 1); + break; + case LUA_TTHREAD: + sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1)); + break; + default: + res = 0; + break; + } + if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1)); + L->top--; + lua_unlock(L); + return res; +} + + +/* +** `load' and `call' functions (run Lua code) +*/ + + +#define adjustresults(L,nres) \ + { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } + + +#define checkresults(L,na,nr) \ + api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) + + +LUA_API void lua_call (lua_State *L, int nargs, int nresults) { + StkId func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + func = L->top - (nargs+1); + luaD_call(L, func, nresults); + adjustresults(L, nresults); + lua_unlock(L); +} + + + +/* +** Execute a protected call. +*/ +struct CallS { /* data to `f_call' */ + StkId func; + int nresults; +}; + + +static void f_call (lua_State *L, void *ud) { + struct CallS *c = cast(struct CallS *, ud); + luaD_call(L, c->func, c->nresults); +} + + + +LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { + struct CallS c; + int status; + ptrdiff_t func; + lua_lock(L); + api_checknelems(L, nargs+1); + checkresults(L, nargs, nresults); + if (errfunc == 0) + func = 0; + else { + StkId o = index2adr(L, errfunc); + api_checkvalidindex(L, o); + func = savestack(L, o); + } + c.func = L->top - (nargs+1); /* function to be called */ + c.nresults = nresults; + status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func); + adjustresults(L, nresults); + lua_unlock(L); + return status; +} + + +/* +** Execute a protected C call. +*/ +struct CCallS { /* data to `f_Ccall' */ + lua_CFunction func; + void *ud; +}; + + +static void f_Ccall (lua_State *L, void *ud) { + struct CCallS *c = cast(struct CCallS *, ud); + Closure *cl; + cl = luaF_newCclosure(L, 0, getcurrenv(L)); + cl->c.f = c->func; + setclvalue(L, L->top, cl); /* push function */ + api_incr_top(L); + setpvalue(L->top, c->ud); /* push only argument */ + api_incr_top(L); + luaD_call(L, L->top - 2, 0); +} + + +LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { + struct CCallS c; + int status; + lua_lock(L); + c.func = func; + c.ud = ud; + status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0); + lua_unlock(L); + return status; +} + + +LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, + const char *chunkname) { + ZIO z; + int status; + lua_lock(L); + if (!chunkname) chunkname = "?"; + luaZ_init(L, &z, reader, data); + status = luaD_protectedparser(L, &z, chunkname); + lua_unlock(L); + return status; +} + + +LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) { + int status; + TValue *o; + lua_lock(L); + api_checknelems(L, 1); + o = L->top - 1; + if (isLfunction(o)) + status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0); + else + status = 1; + lua_unlock(L); + return status; +} + + +LUA_API int lua_status (lua_State *L) { + return L->status; +} + + +/* +** Garbage-collection function +*/ + +LUA_API int lua_gc (lua_State *L, int what, int data) { + int res = 0; + global_State *g; + lua_lock(L); + g = G(L); + switch (what) { + case LUA_GCSTOP: { + g->GCthreshold = MAX_LUMEM; + break; + } + case LUA_GCRESTART: { + g->GCthreshold = g->totalbytes; + break; + } + case LUA_GCCOLLECT: { + luaC_fullgc(L); + break; + } + case LUA_GCCOUNT: { + /* GC values are expressed in Kbytes: #bytes/2^10 */ + res = cast_int(g->totalbytes >> 10); + break; + } + case LUA_GCCOUNTB: { + res = cast_int(g->totalbytes & 0x3ff); + break; + } + case LUA_GCSTEP: { + lu_mem a = (cast(lu_mem, data) << 10); + if (a <= g->totalbytes) + g->GCthreshold = g->totalbytes - a; + else + g->GCthreshold = 0; + while (g->GCthreshold <= g->totalbytes) { + luaC_step(L); + if (g->gcstate == GCSpause) { /* end of cycle? */ + res = 1; /* signal it */ + break; + } + } + break; + } + case LUA_GCSETPAUSE: { + res = g->gcpause; + g->gcpause = data; + break; + } + case LUA_GCSETSTEPMUL: { + res = g->gcstepmul; + g->gcstepmul = data; + break; + } + default: res = -1; /* invalid option */ + } + lua_unlock(L); + return res; +} + + + +/* +** miscellaneous functions +*/ + + +LUA_API int lua_error (lua_State *L) { + lua_lock(L); + api_checknelems(L, 1); + luaG_errormsg(L); + lua_unlock(L); + return 0; /* to avoid warnings */ +} + + +LUA_API int lua_next (lua_State *L, int idx) { + StkId t; + int more; + lua_lock(L); + t = index2adr(L, idx); + api_check(L, ttistable(t)); + more = luaH_next(L, hvalue(t), L->top - 1); + if (more) { + api_incr_top(L); + } + else /* no more elements */ + L->top -= 1; /* remove key */ + lua_unlock(L); + return more; +} + + +LUA_API void lua_concat (lua_State *L, int n) { + lua_lock(L); + api_checknelems(L, n); + if (n >= 2) { + luaC_checkGC(L); + luaV_concat(L, n, cast_int(L->top - L->base) - 1); + L->top -= (n-1); + } + else if (n == 0) { /* push empty string */ + setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + api_incr_top(L); + } + /* else n == 1; nothing to do */ + lua_unlock(L); +} + + +LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) { + lua_Alloc f; + lua_lock(L); + if (ud) *ud = G(L)->ud; + f = G(L)->frealloc; + lua_unlock(L); + return f; +} + + +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { + lua_lock(L); + G(L)->ud = ud; + G(L)->frealloc = f; + lua_unlock(L); +} + + +LUA_API void *lua_newuserdata (lua_State *L, size_t size) { + Udata *u; + lua_lock(L); + luaC_checkGC(L); + u = luaS_newudata(L, size, getcurrenv(L)); + setuvalue(L, L->top, u); + api_incr_top(L); + lua_unlock(L); + return u + 1; +} + + + + +static const char *aux_upvalue (StkId fi, int n, TValue **val) { + Closure *f; + if (!ttisfunction(fi)) return NULL; + f = clvalue(fi); + if (f->c.isC) { + if (!(1 <= n && n <= f->c.nupvalues)) return NULL; + *val = &f->c.upvalue[n-1]; + return ""; + } + else { + Proto *p = f->l.p; + if (!(1 <= n && n <= p->sizeupvalues)) return NULL; + *val = f->l.upvals[n-1]->v; + return getstr(p->upvalues[n-1]); + } +} + + +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + lua_lock(L); + name = aux_upvalue(index2adr(L, funcindex), n, &val); + if (name) { + setobj2s(L, L->top, val); + api_incr_top(L); + } + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { + const char *name; + TValue *val; + StkId fi; + lua_lock(L); + fi = index2adr(L, funcindex); + api_checknelems(L, 1); + name = aux_upvalue(fi, n, &val); + if (name) { + L->top--; + setobj(L, val, L->top); + luaC_barrier(L, clvalue(fi), L->top); + } + lua_unlock(L); + return name; +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lapi.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lapi.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lapi.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lapi.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,16 @@ +/* +** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Lua API +** See Copyright Notice in lua.h +*/ + +#ifndef lapi_h +#define lapi_h + + +#include "lobject.h" + + +LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lauxlib.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lauxlib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lauxlib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lauxlib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,652 @@ +/* +** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include +#include + + +/* This file uses only the official API of Lua. +** Any function declared here could be written as an application function. +*/ + +#define lauxlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" + + +#define FREELIST_REF 0 /* free list of references */ + + +/* convert a stack index to positive */ +#define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) : \ + lua_gettop(L) + (i) + 1) + + +/* +** {====================================================== +** Error-report functions +** ======================================================= +*/ + + +LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { + lua_Debug ar; + if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ + return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); + lua_getinfo(L, "n", &ar); + if (strcmp(ar.namewhat, "method") == 0) { + narg--; /* do not count `self' */ + if (narg == 0) /* error is in the self argument itself? */ + return luaL_error(L, "calling " LUA_QS " on bad self (%s)", + ar.name, extramsg); + } + if (ar.name == NULL) + ar.name = "?"; + return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", + narg, ar.name, extramsg); +} + + +LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) { + const char *msg = lua_pushfstring(L, "%s expected, got %s", + tname, luaL_typename(L, narg)); + return luaL_argerror(L, narg, msg); +} + + +static void tag_error (lua_State *L, int narg, int tag) { + luaL_typerror(L, narg, lua_typename(L, tag)); +} + + +LUALIB_API void luaL_where (lua_State *L, int level) { + lua_Debug ar; + if (lua_getstack(L, level, &ar)) { /* check function at level */ + lua_getinfo(L, "Sl", &ar); /* get info about it */ + if (ar.currentline > 0) { /* is there info? */ + lua_pushfstring(L, "%s:%d: ", ar.short_src, ar.currentline); + return; + } + } + lua_pushliteral(L, ""); /* else, no information available... */ +} + + +LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); + return lua_error(L); +} + +/* }====================================================== */ + + +LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def, + const char *const lst[]) { + const char *name = (def) ? luaL_optstring(L, narg, def) : + luaL_checkstring(L, narg); + int i; + for (i=0; lst[i]; i++) + if (strcmp(lst[i], name) == 0) + return i; + return luaL_argerror(L, narg, + lua_pushfstring(L, "invalid option " LUA_QS, name)); +} + + +LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) { + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ + if (!lua_isnil(L, -1)) /* name already in use? */ + return 0; /* leave previous value on top, but return 0 */ + lua_pop(L, 1); + lua_newtable(L); /* create metatable */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */ + return 1; +} + + +LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) { + void *p = lua_touserdata(L, ud); + if (p != NULL) { /* value is a userdata? */ + if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ + lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */ + if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */ + lua_pop(L, 2); /* remove both metatables */ + return p; + } + } + } + luaL_typerror(L, ud, tname); /* else error */ + return NULL; /* to avoid warnings */ +} + + +LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) { + if (!lua_checkstack(L, space)) + luaL_error(L, "stack overflow (%s)", mes); +} + + +LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) { + if (lua_type(L, narg) != t) + tag_error(L, narg, t); +} + + +LUALIB_API void luaL_checkany (lua_State *L, int narg) { + if (lua_type(L, narg) == LUA_TNONE) + luaL_argerror(L, narg, "value expected"); +} + + +LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) { + const char *s = lua_tolstring(L, narg, len); + if (!s) tag_error(L, narg, LUA_TSTRING); + return s; +} + + +LUALIB_API const char *luaL_optlstring (lua_State *L, int narg, + const char *def, size_t *len) { + if (lua_isnoneornil(L, narg)) { + if (len) + *len = (def ? strlen(def) : 0); + return def; + } + else return luaL_checklstring(L, narg, len); +} + + +LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) { + lua_Number d = lua_tonumber(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) { + return luaL_opt(L, luaL_checknumber, narg, def); +} + + +LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) { + lua_Integer d = lua_tointeger(L, narg); + if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ + tag_error(L, narg, LUA_TNUMBER); + return d; +} + + +LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg, + lua_Integer def) { + return luaL_opt(L, luaL_checkinteger, narg, def); +} + + +LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) { + if (!lua_getmetatable(L, obj)) /* no metatable? */ + return 0; + lua_pushstring(L, event); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { + lua_pop(L, 2); /* remove metatable and metafield */ + return 0; + } + else { + lua_remove(L, -2); /* remove only metatable */ + return 1; + } +} + + +LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) { + obj = abs_index(L, obj); + if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ + return 0; + lua_pushvalue(L, obj); + lua_call(L, 1, 1); + return 1; +} + + +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l) { + luaI_openlib(L, libname, l, 0); +} + + +static int libsize (const luaL_Reg *l) { + int size = 0; + for (; l->name; l++) size++; + return size; +} + + +LUALIB_API void luaI_openlib (lua_State *L, const char *libname, + const luaL_Reg *l, int nup) { + if (libname) { + int size = libsize(l); + /* check whether lib already exists */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 1); + lua_getfield(L, -1, libname); /* get _LOADED[libname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, libname, size) != NULL) + luaL_error(L, "name conflict for module " LUA_QS, libname); + lua_pushvalue(L, -1); + lua_setfield(L, -3, libname); /* _LOADED[libname] = new table */ + } + lua_remove(L, -2); /* remove _LOADED table */ + lua_insert(L, -(nup+1)); /* move library table to below upvalues */ + } + for (; l->name; l++) { + int i; + for (i=0; ifunc, nup); + lua_setfield(L, -(nup+2), l->name); + } + lua_pop(L, nup); /* remove upvalues */ +} + + + +/* +** {====================================================== +** getn-setn: size for arrays +** ======================================================= +*/ + +#if defined(LUA_COMPAT_GETN) + +static int checkint (lua_State *L, int topop) { + int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; + lua_pop(L, topop); + return n; +} + + +static void getsizes (lua_State *L) { + lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); + if (lua_isnil(L, -1)) { /* no `size' table? */ + lua_pop(L, 1); /* remove nil */ + lua_newtable(L); /* create it */ + lua_pushvalue(L, -1); /* `size' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(N).__mode = "kv" */ + lua_pushvalue(L, -1); + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); /* store in register */ + } +} + + +LUALIB_API void luaL_setn (lua_State *L, int t, int n) { + t = abs_index(L, t); + lua_pushliteral(L, "n"); + lua_rawget(L, t); + if (checkint(L, 1) >= 0) { /* is there a numeric field `n'? */ + lua_pushliteral(L, "n"); /* use it */ + lua_pushinteger(L, n); + lua_rawset(L, t); + } + else { /* use `sizes' */ + getsizes(L); + lua_pushvalue(L, t); + lua_pushinteger(L, n); + lua_rawset(L, -3); /* sizes[t] = n */ + lua_pop(L, 1); /* remove `sizes' */ + } +} + + +LUALIB_API int luaL_getn (lua_State *L, int t) { + int n; + t = abs_index(L, t); + lua_pushliteral(L, "n"); /* try t.n */ + lua_rawget(L, t); + if ((n = checkint(L, 1)) >= 0) return n; + getsizes(L); /* else try sizes[t] */ + lua_pushvalue(L, t); + lua_rawget(L, -2); + if ((n = checkint(L, 2)) >= 0) return n; + return (int)lua_objlen(L, t); +} + +#endif + +/* }====================================================== */ + + + +LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p, + const char *r) { + const char *wild; + size_t l = strlen(p); + luaL_Buffer b; + luaL_buffinit(L, &b); + while ((wild = strstr(s, p)) != NULL) { + luaL_addlstring(&b, s, wild - s); /* push prefix */ + luaL_addstring(&b, r); /* push replacement in place of pattern */ + s = wild + l; /* continue after `p' */ + } + luaL_addstring(&b, s); /* push last suffix */ + luaL_pushresult(&b); + return lua_tostring(L, -1); +} + + +LUALIB_API const char *luaL_findtable (lua_State *L, int idx, + const char *fname, int szhint) { + const char *e; + lua_pushvalue(L, idx); + do { + e = strchr(fname, '.'); + if (e == NULL) e = fname + strlen(fname); + lua_pushlstring(L, fname, e - fname); + lua_rawget(L, -2); + if (lua_isnil(L, -1)) { /* no such field? */ + lua_pop(L, 1); /* remove this nil */ + lua_createtable(L, 0, (*e == '.' ? 1 : szhint)); /* new table for field */ + lua_pushlstring(L, fname, e - fname); + lua_pushvalue(L, -2); + lua_settable(L, -4); /* set new table into field */ + } + else if (!lua_istable(L, -1)) { /* field has a non-table value? */ + lua_pop(L, 2); /* remove table and value */ + return fname; /* return problematic part of the name */ + } + lua_remove(L, -2); /* remove previous table */ + fname = e + 1; + } while (*e == '.'); + return NULL; +} + + + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + +#define bufflen(B) ((B)->p - (B)->buffer) +#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE - bufflen(B))) + +#define LIMIT (LUA_MINSTACK/2) + + +static int emptybuffer (luaL_Buffer *B) { + size_t l = bufflen(B); + if (l == 0) return 0; /* put nothing on stack */ + else { + lua_pushlstring(B->L, B->buffer, l); + B->p = B->buffer; + B->lvl++; + return 1; + } +} + + +static void adjuststack (luaL_Buffer *B) { + if (B->lvl > 1) { + lua_State *L = B->L; + int toget = 1; /* number of levels to concat */ + size_t toplen = lua_strlen(L, -1); + do { + size_t l = lua_strlen(L, -(toget+1)); + if (B->lvl - toget + 1 >= LIMIT || toplen > l) { + toplen += l; + toget++; + } + else break; + } while (toget < B->lvl); + lua_concat(L, toget); + B->lvl = B->lvl - toget + 1; + } +} + + +LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { + if (emptybuffer(B)) + adjuststack(B); + return B->buffer; +} + + +LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { + while (l--) + luaL_addchar(B, *s++); +} + + +LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { + luaL_addlstring(B, s, strlen(s)); +} + + +LUALIB_API void luaL_pushresult (luaL_Buffer *B) { + emptybuffer(B); + lua_concat(B->L, B->lvl); + B->lvl = 1; +} + + +LUALIB_API void luaL_addvalue (luaL_Buffer *B) { + lua_State *L = B->L; + size_t vl; + const char *s = lua_tolstring(L, -1, &vl); + if (vl <= bufffree(B)) { /* fit into buffer? */ + memcpy(B->p, s, vl); /* put it there */ + B->p += vl; + lua_pop(L, 1); /* remove from stack */ + } + else { + if (emptybuffer(B)) + lua_insert(L, -2); /* put buffer before new value */ + B->lvl++; /* add new value into B stack */ + adjuststack(B); + } +} + + +LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { + B->L = L; + B->p = B->buffer; + B->lvl = 0; +} + +/* }====================================================== */ + + +LUALIB_API int luaL_ref (lua_State *L, int t) { + int ref; + t = abs_index(L, t); + if (lua_isnil(L, -1)) { + lua_pop(L, 1); /* remove from stack */ + return LUA_REFNIL; /* `nil' has a unique fixed reference */ + } + lua_rawgeti(L, t, FREELIST_REF); /* get first free element */ + ref = (int)lua_tointeger(L, -1); /* ref = t[FREELIST_REF] */ + lua_pop(L, 1); /* remove it from stack */ + if (ref != 0) { /* any free element? */ + lua_rawgeti(L, t, ref); /* remove it from list */ + lua_rawseti(L, t, FREELIST_REF); /* (t[FREELIST_REF] = t[ref]) */ + } + else { /* no free elements */ + ref = (int)lua_objlen(L, t); + ref++; /* create new reference */ + } + lua_rawseti(L, t, ref); + return ref; +} + + +LUALIB_API void luaL_unref (lua_State *L, int t, int ref) { + if (ref >= 0) { + t = abs_index(L, t); + lua_rawgeti(L, t, FREELIST_REF); + lua_rawseti(L, t, ref); /* t[ref] = t[FREELIST_REF] */ + lua_pushinteger(L, ref); + lua_rawseti(L, t, FREELIST_REF); /* t[FREELIST_REF] = ref */ + } +} + + + +/* +** {====================================================== +** Load functions +** ======================================================= +*/ + +typedef struct LoadF { + int extraline; + FILE *f; + char buff[LUAL_BUFFERSIZE]; +} LoadF; + + +static const char *getF (lua_State *L, void *ud, size_t *size) { + LoadF *lf = (LoadF *)ud; + (void)L; + if (lf->extraline) { + lf->extraline = 0; + *size = 1; + return "\n"; + } + if (feof(lf->f)) return NULL; + *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); + return (*size > 0) ? lf->buff : NULL; +} + + +static int errfile (lua_State *L, const char *what, int fnameindex) { + const char *serr = strerror(errno); + const char *filename = lua_tostring(L, fnameindex) + 1; + lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); + lua_remove(L, fnameindex); + return LUA_ERRFILE; +} + + +LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { + LoadF lf; + int status, readstatus; + int c; + int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */ + lf.extraline = 0; + if (filename == NULL) { + lua_pushliteral(L, "=stdin"); + lf.f = stdin; + } + else { + lua_pushfstring(L, "@%s", filename); + lf.f = fopen(filename, "r"); + if (lf.f == NULL) return errfile(L, "open", fnameindex); + } + c = getc(lf.f); + if (c == '#') { /* Unix exec. file? */ + lf.extraline = 1; + while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */ + if (c == '\n') c = getc(lf.f); + } + if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ + lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */ + if (lf.f == NULL) return errfile(L, "reopen", fnameindex); + /* skip eventual `#!...' */ + while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; + lf.extraline = 0; + } + ungetc(c, lf.f); + status = lua_load(L, getF, &lf, lua_tostring(L, -1)); + readstatus = ferror(lf.f); + if (filename) fclose(lf.f); /* close file (even in case of errors) */ + if (readstatus) { + lua_settop(L, fnameindex); /* ignore results from `lua_load' */ + return errfile(L, "read", fnameindex); + } + lua_remove(L, fnameindex); + return status; +} + + +typedef struct LoadS { + const char *s; + size_t size; +} LoadS; + + +static const char *getS (lua_State *L, void *ud, size_t *size) { + LoadS *ls = (LoadS *)ud; + (void)L; + if (ls->size == 0) return NULL; + *size = ls->size; + ls->size = 0; + return ls->s; +} + + +LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, + const char *name) { + LoadS ls; + ls.s = buff; + ls.size = size; + return lua_load(L, getS, &ls, name); +} + + +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) { + return luaL_loadbuffer(L, s, strlen(s), s); +} + + + +/* }====================================================== */ + + +static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { + (void)ud; + (void)osize; + if (nsize == 0) { + free(ptr); + return NULL; + } + else + return realloc(ptr, nsize); +} + + +static int panic (lua_State *L) { + (void)L; /* to avoid warnings */ + fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n", + lua_tostring(L, -1)); + return 0; +} + + +LUALIB_API lua_State *luaL_newstate (void) { + lua_State *L = lua_newstate(l_alloc, NULL); + if (L) lua_atpanic(L, &panic); + return L; +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lauxlib.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lauxlib.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lauxlib.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lauxlib.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,174 @@ +/* +** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions for building Lua libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lauxlib_h +#define lauxlib_h + + +#include +#include + +#include "lua.h" + + +#if defined(LUA_COMPAT_GETN) +LUALIB_API int (luaL_getn) (lua_State *L, int t); +LUALIB_API void (luaL_setn) (lua_State *L, int t, int n); +#else +#define luaL_getn(L,i) ((int)lua_objlen(L, i)) +#define luaL_setn(L,i,j) ((void)0) /* no op! */ +#endif + +#if defined(LUA_COMPAT_OPENLIB) +#define luaI_openlib luaL_openlib +#endif + + +/* extra error code for `luaL_load' */ +#define LUA_ERRFILE (LUA_ERRERR+1) + + +typedef struct luaL_Reg { + const char *name; + lua_CFunction func; +} luaL_Reg; + + + +LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname, + const luaL_Reg *l, int nup); +LUALIB_API void (luaL_register) (lua_State *L, const char *libname, + const luaL_Reg *l); +LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); +LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); +LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); +LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, + size_t *l); +LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, + const char *def, size_t *l); +LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); +LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); + +LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); +LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, + lua_Integer def); + +LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); +LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); +LUALIB_API void (luaL_checkany) (lua_State *L, int narg); + +LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); +LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); + +LUALIB_API void (luaL_where) (lua_State *L, int lvl); +LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); + +LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, + const char *const lst[]); + +LUALIB_API int (luaL_ref) (lua_State *L, int t); +LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); + +LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); +LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, + const char *name); +LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); + +LUALIB_API lua_State *(luaL_newstate) (void); + + +LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, + const char *r); + +LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, + const char *fname, int szhint); + + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define luaL_argcheck(L, cond,numarg,extramsg) \ + ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) +#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) +#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) +#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) +#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) +#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) +#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) + +#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) + +#define luaL_dofile(L, fn) \ + (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_dostring(L, s) \ + (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) + +#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) + +#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) + +/* +** {====================================================== +** Generic Buffer manipulation +** ======================================================= +*/ + + + +typedef struct luaL_Buffer { + char *p; /* current position in buffer */ + int lvl; /* number of strings in the stack (level) */ + lua_State *L; + char buffer[LUAL_BUFFERSIZE]; +} luaL_Buffer; + +#define luaL_addchar(B,c) \ + ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ + (*(B)->p++ = (char)(c))) + +/* compatibility only */ +#define luaL_putchar(B,c) luaL_addchar(B,c) + +#define luaL_addsize(B,n) ((B)->p += (n)) + +LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); +LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); +LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); +LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); +LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); +LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); + + +/* }====================================================== */ + + +/* compatibility with ref system */ + +/* pre-defined references */ +#define LUA_NOREF (-2) +#define LUA_REFNIL (-1) + +#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \ + (lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0)) + +#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref)) + +#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref)) + + +#define luaL_reg luaL_Reg + +#endif + + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lbaselib.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lbaselib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lbaselib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lbaselib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,653 @@ +/* +** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $ +** Basic library +** See Copyright Notice in lua.h +*/ + + + +#include +#include +#include +#include + +#define lbaselib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + + +/* +** If your system does not support `stdout', you can just remove this function. +** If you need, you can define your own `print' function, following this +** model but changing `fputs' to put the strings at a proper place +** (a console window or a log file, for instance). +*/ +static int luaB_print (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + int i; + lua_getglobal(L, "tostring"); + for (i=1; i<=n; i++) { + const char *s; + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + s = lua_tostring(L, -1); /* get result */ + if (s == NULL) + return luaL_error(L, LUA_QL("tostring") " must return a string to " + LUA_QL("print")); + if (i>1) fputs("\t", stdout); + fputs(s, stdout); + lua_pop(L, 1); /* pop result */ + } + fputs("\n", stdout); + return 0; +} + + +static int luaB_tonumber (lua_State *L) { + int base = luaL_optint(L, 2, 10); + if (base == 10) { /* standard conversion */ + luaL_checkany(L, 1); + if (lua_isnumber(L, 1)) { + lua_pushnumber(L, lua_tonumber(L, 1)); + return 1; + } + } + else { + const char *s1 = luaL_checkstring(L, 1); + char *s2; + unsigned long n; + luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range"); + n = strtoul(s1, &s2, base); + if (s1 != s2) { /* at least one valid digit? */ + while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */ + if (*s2 == '\0') { /* no invalid trailing characters? */ + lua_pushnumber(L, (lua_Number)n); + return 1; + } + } + } + lua_pushnil(L); /* else not a number */ + return 1; +} + + +static int luaB_error (lua_State *L) { + int level = luaL_optint(L, 2, 1); + lua_settop(L, 1); + if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ + luaL_where(L, level); + lua_pushvalue(L, 1); + lua_concat(L, 2); + } + return lua_error(L); +} + + +static int luaB_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); + return 1; /* no metatable */ + } + luaL_getmetafield(L, 1, "__metatable"); + return 1; /* returns either __metatable field (if present) or metatable */ +} + + +static int luaB_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + if (luaL_getmetafield(L, 1, "__metatable")) + luaL_error(L, "cannot change a protected metatable"); + lua_settop(L, 2); + lua_setmetatable(L, 1); + return 1; +} + + +static void getfunc (lua_State *L, int opt) { + if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); + else { + lua_Debug ar; + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); + luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); + if (lua_getstack(L, level, &ar) == 0) + luaL_argerror(L, 1, "invalid level"); + lua_getinfo(L, "f", &ar); + if (lua_isnil(L, -1)) + luaL_error(L, "no function environment for tail call at level %d", + level); + } +} + + +static int luaB_getfenv (lua_State *L) { + getfunc(L, 1); + if (lua_iscfunction(L, -1)) /* is a C function? */ + lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ + else + lua_getfenv(L, -1); + return 1; +} + + +static int luaB_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + getfunc(L, 0); + lua_pushvalue(L, 2); + if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { + /* change environment of current thread */ + lua_pushthread(L); + lua_insert(L, -2); + lua_setfenv(L, -2); + return 0; + } + else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) + luaL_error(L, + LUA_QL("setfenv") " cannot change environment of given object"); + return 1; +} + + +static int luaB_rawequal (lua_State *L) { + luaL_checkany(L, 1); + luaL_checkany(L, 2); + lua_pushboolean(L, lua_rawequal(L, 1, 2)); + return 1; +} + + +static int luaB_rawget (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_rawget(L, 1); + return 1; +} + +static int luaB_rawset (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checkany(L, 2); + luaL_checkany(L, 3); + lua_settop(L, 3); + lua_rawset(L, 1); + return 1; +} + + +static int luaB_gcinfo (lua_State *L) { + lua_pushinteger(L, lua_getgccount(L)); + return 1; +} + + +static int luaB_collectgarbage (lua_State *L) { + static const char *const opts[] = {"stop", "restart", "collect", + "count", "step", "setpause", "setstepmul", NULL}; + static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, + LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL}; + int o = luaL_checkoption(L, 1, "collect", opts); + int ex = luaL_optint(L, 2, 0); + int res = lua_gc(L, optsnum[o], ex); + switch (optsnum[o]) { + case LUA_GCCOUNT: { + int b = lua_gc(L, LUA_GCCOUNTB, 0); + lua_pushnumber(L, res + ((lua_Number)b/1024)); + return 1; + } + case LUA_GCSTEP: { + lua_pushboolean(L, res); + return 1; + } + default: { + lua_pushnumber(L, res); + return 1; + } + } +} + + +static int luaB_type (lua_State *L) { + luaL_checkany(L, 1); + lua_pushstring(L, luaL_typename(L, 1)); + return 1; +} + + +static int luaB_next (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 2); /* create a 2nd argument if there isn't one */ + if (lua_next(L, 1)) + return 2; + else { + lua_pushnil(L); + return 1; + } +} + + +static int luaB_pairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnil(L); /* and initial value */ + return 3; +} + + +static int ipairsaux (lua_State *L) { + int i = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TTABLE); + i++; /* next value */ + lua_pushinteger(L, i); + lua_rawgeti(L, 1, i); + return (lua_isnil(L, -1)) ? 0 : 2; +} + + +static int luaB_ipairs (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushinteger(L, 0); /* and initial value */ + return 3; +} + + +static int load_aux (lua_State *L, int status) { + if (status == 0) /* OK? */ + return 1; + else { + lua_pushnil(L); + lua_insert(L, -2); /* put before error message */ + return 2; /* return nil plus error message */ + } +} + + +static int luaB_loadstring (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + const char *chunkname = luaL_optstring(L, 2, s); + return load_aux(L, luaL_loadbuffer(L, s, l, chunkname)); +} + + +static int luaB_loadfile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + return load_aux(L, luaL_loadfile(L, fname)); +} + + +/* +** Reader for generic `load' function: `lua_load' uses the +** stack for internal stuff, so the reader cannot change the +** stack top. Instead, it keeps its resulting string in a +** reserved slot inside the stack. +*/ +static const char *generic_reader (lua_State *L, void *ud, size_t *size) { + (void)ud; /* to avoid warnings */ + luaL_checkstack(L, 2, "too many nested functions"); + lua_pushvalue(L, 1); /* get function */ + lua_call(L, 0, 1); /* call it */ + if (lua_isnil(L, -1)) { + *size = 0; + return NULL; + } + else if (lua_isstring(L, -1)) { + lua_replace(L, 3); /* save string in a reserved stack slot */ + return lua_tolstring(L, 3, size); + } + else luaL_error(L, "reader function must return a string"); + return NULL; /* to avoid warnings */ +} + + +static int luaB_load (lua_State *L) { + int status; + const char *cname = luaL_optstring(L, 2, "=(load)"); + luaL_checktype(L, 1, LUA_TFUNCTION); + lua_settop(L, 3); /* function, eventual name, plus one reserved slot */ + status = lua_load(L, generic_reader, NULL, cname); + return load_aux(L, status); +} + + +static int luaB_dofile (lua_State *L) { + const char *fname = luaL_optstring(L, 1, NULL); + int n = lua_gettop(L); + if (luaL_loadfile(L, fname) != 0) lua_error(L); + lua_call(L, 0, LUA_MULTRET); + return lua_gettop(L) - n; +} + + +static int luaB_assert (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_toboolean(L, 1)) + return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); + return lua_gettop(L); +} + + +static int luaB_unpack (lua_State *L) { + int i, e, n; + luaL_checktype(L, 1, LUA_TTABLE); + i = luaL_optint(L, 2, 1); + e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1)); + if (i > e) return 0; /* empty range */ + n = e - i + 1; /* number of elements */ + if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ + return luaL_error(L, "too many results to unpack"); + lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ + while (i++ < e) /* push arg[i + 1...e] */ + lua_rawgeti(L, 1, i); + return n; +} + + +static int luaB_select (lua_State *L) { + int n = lua_gettop(L); + if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { + lua_pushinteger(L, n-1); + return 1; + } + else { + int i = luaL_checkint(L, 1); + if (i < 0) i = n + i; + else if (i > n) i = n; + luaL_argcheck(L, 1 <= i, 1, "index out of range"); + return n - i; + } +} + + +static int luaB_pcall (lua_State *L) { + int status; + luaL_checkany(L, 1); + status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); + lua_pushboolean(L, (status == 0)); + lua_insert(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_xpcall (lua_State *L) { + int status; + luaL_checkany(L, 2); + lua_settop(L, 2); + lua_insert(L, 1); /* put error function under function to be called */ + status = lua_pcall(L, 0, LUA_MULTRET, 1); + lua_pushboolean(L, (status == 0)); + lua_replace(L, 1); + return lua_gettop(L); /* return status + all results */ +} + + +static int luaB_tostring (lua_State *L) { + luaL_checkany(L, 1); + if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ + return 1; /* use its value */ + switch (lua_type(L, 1)) { + case LUA_TNUMBER: + lua_pushstring(L, lua_tostring(L, 1)); + break; + case LUA_TSTRING: + lua_pushvalue(L, 1); + break; + case LUA_TBOOLEAN: + lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); + break; + case LUA_TNIL: + lua_pushliteral(L, "nil"); + break; + default: + lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); + break; + } + return 1; +} + + +static int luaB_newproxy (lua_State *L) { + lua_settop(L, 1); + lua_newuserdata(L, 0); /* create proxy */ + if (lua_toboolean(L, 1) == 0) + return 1; /* no metatable */ + else if (lua_isboolean(L, 1)) { + lua_newtable(L); /* create a new metatable `m' ... */ + lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */ + lua_pushboolean(L, 1); + lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */ + } + else { + int validproxy = 0; /* to check if weaktable[metatable(u)] == true */ + if (lua_getmetatable(L, 1)) { + lua_rawget(L, lua_upvalueindex(1)); + validproxy = lua_toboolean(L, -1); + lua_pop(L, 1); /* remove value */ + } + luaL_argcheck(L, validproxy, 1, "boolean or proxy expected"); + lua_getmetatable(L, 1); /* metatable is valid; get it */ + } + lua_setmetatable(L, 2); + return 1; +} + + +static const luaL_Reg base_funcs[] = { + {"assert", luaB_assert}, + {"collectgarbage", luaB_collectgarbage}, + {"dofile", luaB_dofile}, + {"error", luaB_error}, + {"gcinfo", luaB_gcinfo}, + {"getfenv", luaB_getfenv}, + {"getmetatable", luaB_getmetatable}, + {"loadfile", luaB_loadfile}, + {"load", luaB_load}, + {"loadstring", luaB_loadstring}, + {"next", luaB_next}, + {"pcall", luaB_pcall}, + {"print", luaB_print}, + {"rawequal", luaB_rawequal}, + {"rawget", luaB_rawget}, + {"rawset", luaB_rawset}, + {"select", luaB_select}, + {"setfenv", luaB_setfenv}, + {"setmetatable", luaB_setmetatable}, + {"tonumber", luaB_tonumber}, + {"tostring", luaB_tostring}, + {"type", luaB_type}, + {"unpack", luaB_unpack}, + {"xpcall", luaB_xpcall}, + {NULL, NULL} +}; + + +/* +** {====================================================== +** Coroutine library +** ======================================================= +*/ + +#define CO_RUN 0 /* running */ +#define CO_SUS 1 /* suspended */ +#define CO_NOR 2 /* 'normal' (it resumed another coroutine) */ +#define CO_DEAD 3 + +static const char *const statnames[] = + {"running", "suspended", "normal", "dead"}; + +static int costatus (lua_State *L, lua_State *co) { + if (L == co) return CO_RUN; + switch (lua_status(co)) { + case LUA_YIELD: + return CO_SUS; + case 0: { + lua_Debug ar; + if (lua_getstack(co, 0, &ar) > 0) /* does it have frames? */ + return CO_NOR; /* it is running */ + else if (lua_gettop(co) == 0) + return CO_DEAD; + else + return CO_SUS; /* initial state */ + } + default: /* some error occured */ + return CO_DEAD; + } +} + + +static int luaB_costatus (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + luaL_argcheck(L, co, 1, "coroutine expected"); + lua_pushstring(L, statnames[costatus(L, co)]); + return 1; +} + + +static int auxresume (lua_State *L, lua_State *co, int narg) { + int status = costatus(L, co); + if (!lua_checkstack(co, narg)) + luaL_error(L, "too many arguments to resume"); + if (status != CO_SUS) { + lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]); + return -1; /* error flag */ + } + lua_xmove(L, co, narg); + lua_setlevel(L, co); + status = lua_resume(co, narg); + if (status == 0 || status == LUA_YIELD) { + int nres = lua_gettop(co); + if (!lua_checkstack(L, nres + 1)) + luaL_error(L, "too many results to resume"); + lua_xmove(co, L, nres); /* move yielded values */ + return nres; + } + else { + lua_xmove(co, L, 1); /* move error message */ + return -1; /* error flag */ + } +} + + +static int luaB_coresume (lua_State *L) { + lua_State *co = lua_tothread(L, 1); + int r; + luaL_argcheck(L, co, 1, "coroutine expected"); + r = auxresume(L, co, lua_gettop(L) - 1); + if (r < 0) { + lua_pushboolean(L, 0); + lua_insert(L, -2); + return 2; /* return false + error message */ + } + else { + lua_pushboolean(L, 1); + lua_insert(L, -(r + 1)); + return r + 1; /* return true + `resume' returns */ + } +} + + +static int luaB_auxwrap (lua_State *L) { + lua_State *co = lua_tothread(L, lua_upvalueindex(1)); + int r = auxresume(L, co, lua_gettop(L)); + if (r < 0) { + if (lua_isstring(L, -1)) { /* error object is a string? */ + luaL_where(L, 1); /* add extra info */ + lua_insert(L, -2); + lua_concat(L, 2); + } + lua_error(L); /* propagate error */ + } + return r; +} + + +static int luaB_cocreate (lua_State *L) { + lua_State *NL = lua_newthread(L); + luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, + "Lua function expected"); + lua_pushvalue(L, 1); /* move function to top */ + lua_xmove(L, NL, 1); /* move function from L to NL */ + return 1; +} + + +static int luaB_cowrap (lua_State *L) { + luaB_cocreate(L); + lua_pushcclosure(L, luaB_auxwrap, 1); + return 1; +} + + +static int luaB_yield (lua_State *L) { + return lua_yield(L, lua_gettop(L)); +} + + +static int luaB_corunning (lua_State *L) { + if (lua_pushthread(L)) + lua_pushnil(L); /* main thread is not a coroutine */ + return 1; +} + + +static const luaL_Reg co_funcs[] = { + {"create", luaB_cocreate}, + {"resume", luaB_coresume}, + {"running", luaB_corunning}, + {"status", luaB_costatus}, + {"wrap", luaB_cowrap}, + {"yield", luaB_yield}, + {NULL, NULL} +}; + +/* }====================================================== */ + + +static void auxopen (lua_State *L, const char *name, + lua_CFunction f, lua_CFunction u) { + lua_pushcfunction(L, u); + lua_pushcclosure(L, f, 1); + lua_setfield(L, -2, name); +} + + +static void base_open (lua_State *L) { + /* set global _G */ + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setglobal(L, "_G"); + /* open lib into global table */ + luaL_register(L, "_G", base_funcs); + lua_pushliteral(L, LUA_VERSION); + lua_setglobal(L, "_VERSION"); /* set global _VERSION */ + /* `ipairs' and `pairs' need auxliliary functions as upvalues */ + auxopen(L, "ipairs", luaB_ipairs, ipairsaux); + auxopen(L, "pairs", luaB_pairs, luaB_next); + /* `newproxy' needs a weaktable as upvalue */ + lua_createtable(L, 0, 1); /* new table `w' */ + lua_pushvalue(L, -1); /* `w' will be its own metatable */ + lua_setmetatable(L, -2); + lua_pushliteral(L, "kv"); + lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */ + lua_pushcclosure(L, luaB_newproxy, 1); + lua_setglobal(L, "newproxy"); /* set global `newproxy' */ +} + + +LUALIB_API int luaopen_base (lua_State *L) { + base_open(L); + luaL_register(L, LUA_COLIBNAME, co_funcs); + return 2; +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lcode.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lcode.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lcode.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lcode.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,839 @@ +/* +** $Id: lcode.c,v 2.25.1.3 2007/12/28 15:32:23 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + + +#include + +#define lcode_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "ltable.h" + + +#define hasjumps(e) ((e)->t != (e)->f) + + +static int isnumeral(expdesc *e) { + return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); +} + + +void luaK_nil (FuncState *fs, int from, int n) { + Instruction *previous; + if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ + if (fs->pc == 0) { /* function start? */ + if (from >= fs->nactvar) + return; /* positions are already clean */ + } + else { + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pto = GETARG_B(*previous); + if (pfrom <= from && from <= pto+1) { /* can connect both? */ + if (from+n-1 > pto) + SETARG_B(*previous, from+n-1); + return; + } + } + } + } + luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */ +} + + +int luaK_jump (FuncState *fs) { + int jpc = fs->jpc; /* save list of jumps to here */ + int j; + fs->jpc = NO_JUMP; + j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP); + luaK_concat(fs, &j, jpc); /* keep them on hold */ + return j; +} + + +void luaK_ret (FuncState *fs, int first, int nret) { + luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); +} + + +static int condjump (FuncState *fs, OpCode op, int A, int B, int C) { + luaK_codeABC(fs, op, A, B, C); + return luaK_jump(fs); +} + + +static void fixjump (FuncState *fs, int pc, int dest) { + Instruction *jmp = &fs->f->code[pc]; + int offset = dest-(pc+1); + lua_assert(dest != NO_JUMP); + if (abs(offset) > MAXARG_sBx) + luaX_syntaxerror(fs->ls, "control structure too long"); + SETARG_sBx(*jmp, offset); +} + + +/* +** returns current `pc' and marks it as a jump target (to avoid wrong +** optimizations with consecutive instructions not in the same basic block). +*/ +int luaK_getlabel (FuncState *fs) { + fs->lasttarget = fs->pc; + return fs->pc; +} + + +static int getjump (FuncState *fs, int pc) { + int offset = GETARG_sBx(fs->f->code[pc]); + if (offset == NO_JUMP) /* point to itself represents end of list */ + return NO_JUMP; /* end of list */ + else + return (pc+1)+offset; /* turn offset into absolute position */ +} + + +static Instruction *getjumpcontrol (FuncState *fs, int pc) { + Instruction *pi = &fs->f->code[pc]; + if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) + return pi-1; + else + return pi; +} + + +/* +** check whether list has any jump that do not produce a value +** (or produce an inverted value) +*/ +static int need_value (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) { + Instruction i = *getjumpcontrol(fs, list); + if (GET_OPCODE(i) != OP_TESTSET) return 1; + } + return 0; /* not found */ +} + + +static int patchtestreg (FuncState *fs, int node, int reg) { + Instruction *i = getjumpcontrol(fs, node); + if (GET_OPCODE(*i) != OP_TESTSET) + return 0; /* cannot patch other instructions */ + if (reg != NO_REG && reg != GETARG_B(*i)) + SETARG_A(*i, reg); + else /* no register to put value or register already has the value */ + *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); + + return 1; +} + + +static void removevalues (FuncState *fs, int list) { + for (; list != NO_JUMP; list = getjump(fs, list)) + patchtestreg(fs, list, NO_REG); +} + + +static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, + int dtarget) { + while (list != NO_JUMP) { + int next = getjump(fs, list); + if (patchtestreg(fs, list, reg)) + fixjump(fs, list, vtarget); + else + fixjump(fs, list, dtarget); /* jump to default target */ + list = next; + } +} + + +static void dischargejpc (FuncState *fs) { + patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); + fs->jpc = NO_JUMP; +} + + +void luaK_patchlist (FuncState *fs, int list, int target) { + if (target == fs->pc) + luaK_patchtohere(fs, list); + else { + lua_assert(target < fs->pc); + patchlistaux(fs, list, target, NO_REG, target); + } +} + + +void luaK_patchtohere (FuncState *fs, int list) { + luaK_getlabel(fs); + luaK_concat(fs, &fs->jpc, list); +} + + +void luaK_concat (FuncState *fs, int *l1, int l2) { + if (l2 == NO_JUMP) return; + else if (*l1 == NO_JUMP) + *l1 = l2; + else { + int list = *l1; + int next; + while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */ + list = next; + fixjump(fs, list, l2); + } +} + + +void luaK_checkstack (FuncState *fs, int n) { + int newstack = fs->freereg + n; + if (newstack > fs->f->maxstacksize) { + if (newstack >= MAXSTACK) + luaX_syntaxerror(fs->ls, "function or expression too complex"); + fs->f->maxstacksize = cast_byte(newstack); + } +} + + +void luaK_reserveregs (FuncState *fs, int n) { + luaK_checkstack(fs, n); + fs->freereg += n; +} + + +static void freereg (FuncState *fs, int reg) { + if (!ISK(reg) && reg >= fs->nactvar) { + fs->freereg--; + lua_assert(reg == fs->freereg); + } +} + + +static void freeexp (FuncState *fs, expdesc *e) { + if (e->k == VNONRELOC) + freereg(fs, e->u.s.info); +} + + +static int addk (FuncState *fs, TValue *k, TValue *v) { + lua_State *L = fs->L; + TValue *idx = luaH_set(L, fs->h, k); + Proto *f = fs->f; + int oldsize = f->sizek; + if (ttisnumber(idx)) { + lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); + return cast_int(nvalue(idx)); + } + else { /* constant not found; create a new entry */ + setnvalue(idx, cast_num(fs->nk)); + luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); + setobj(L, &f->k[fs->nk], v); + luaC_barrier(L, f, v); + return fs->nk++; + } +} + + +int luaK_stringK (FuncState *fs, TString *s) { + TValue o; + setsvalue(fs->L, &o, s); + return addk(fs, &o, &o); +} + + +int luaK_numberK (FuncState *fs, lua_Number r) { + TValue o; + setnvalue(&o, r); + return addk(fs, &o, &o); +} + + +static int boolK (FuncState *fs, int b) { + TValue o; + setbvalue(&o, b); + return addk(fs, &o, &o); +} + + +static int nilK (FuncState *fs) { + TValue k, v; + setnilvalue(&v); + /* cannot use nil as key; instead use table itself to represent nil */ + sethvalue(fs->L, &k, fs->h); + return addk(fs, &k, &v); +} + + +void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { + if (e->k == VCALL) { /* expression is an open function call? */ + SETARG_C(getcode(fs, e), nresults+1); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), nresults+1); + SETARG_A(getcode(fs, e), fs->freereg); + luaK_reserveregs(fs, 1); + } +} + + +void luaK_setoneret (FuncState *fs, expdesc *e) { + if (e->k == VCALL) { /* expression is an open function call? */ + e->k = VNONRELOC; + e->u.s.info = GETARG_A(getcode(fs, e)); + } + else if (e->k == VVARARG) { + SETARG_B(getcode(fs, e), 2); + e->k = VRELOCABLE; /* can relocate its simple result */ + } +} + + +void luaK_dischargevars (FuncState *fs, expdesc *e) { + switch (e->k) { + case VLOCAL: { + e->k = VNONRELOC; + break; + } + case VUPVAL: { + e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + case VGLOBAL: { + e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info); + e->k = VRELOCABLE; + break; + } + case VINDEXED: { + freereg(fs, e->u.s.aux); + freereg(fs, e->u.s.info); + e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux); + e->k = VRELOCABLE; + break; + } + case VVARARG: + case VCALL: { + luaK_setoneret(fs, e); + break; + } + default: break; /* there is one value available (somewhere) */ + } +} + + +static int code_label (FuncState *fs, int A, int b, int jump) { + luaK_getlabel(fs); /* those instructions may be jump targets */ + return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); +} + + +static void discharge2reg (FuncState *fs, expdesc *e, int reg) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: { + luaK_nil(fs, reg, 1); + break; + } + case VFALSE: case VTRUE: { + luaK_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0); + break; + } + case VK: { + luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info); + break; + } + case VKNUM: { + luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval)); + break; + } + case VRELOCABLE: { + Instruction *pc = &getcode(fs, e); + SETARG_A(*pc, reg); + break; + } + case VNONRELOC: { + if (reg != e->u.s.info) + luaK_codeABC(fs, OP_MOVE, reg, e->u.s.info, 0); + break; + } + default: { + lua_assert(e->k == VVOID || e->k == VJMP); + return; /* nothing to do... */ + } + } + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +static void discharge2anyreg (FuncState *fs, expdesc *e) { + if (e->k != VNONRELOC) { + luaK_reserveregs(fs, 1); + discharge2reg(fs, e, fs->freereg-1); + } +} + + +static void exp2reg (FuncState *fs, expdesc *e, int reg) { + discharge2reg(fs, e, reg); + if (e->k == VJMP) + luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ + if (hasjumps(e)) { + int final; /* position after whole expression */ + int p_f = NO_JUMP; /* position of an eventual LOAD false */ + int p_t = NO_JUMP; /* position of an eventual LOAD true */ + if (need_value(fs, e->t) || need_value(fs, e->f)) { + int fj = (e->k == VJMP) ? NO_JUMP : luaK_jump(fs); + p_f = code_label(fs, reg, 0, 1); + p_t = code_label(fs, reg, 1, 0); + luaK_patchtohere(fs, fj); + } + final = luaK_getlabel(fs); + patchlistaux(fs, e->f, final, reg, p_f); + patchlistaux(fs, e->t, final, reg, p_t); + } + e->f = e->t = NO_JUMP; + e->u.s.info = reg; + e->k = VNONRELOC; +} + + +void luaK_exp2nextreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + freeexp(fs, e); + luaK_reserveregs(fs, 1); + exp2reg(fs, e, fs->freereg - 1); +} + + +int luaK_exp2anyreg (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + if (e->k == VNONRELOC) { + if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ + if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */ + exp2reg(fs, e, e->u.s.info); /* put value on it */ + return e->u.s.info; + } + } + luaK_exp2nextreg(fs, e); /* default */ + return e->u.s.info; +} + + +void luaK_exp2val (FuncState *fs, expdesc *e) { + if (hasjumps(e)) + luaK_exp2anyreg(fs, e); + else + luaK_dischargevars(fs, e); +} + + +int luaK_exp2RK (FuncState *fs, expdesc *e) { + luaK_exp2val(fs, e); + switch (e->k) { + case VKNUM: + case VTRUE: + case VFALSE: + case VNIL: { + if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */ + e->u.s.info = (e->k == VNIL) ? nilK(fs) : + (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) : + boolK(fs, (e->k == VTRUE)); + e->k = VK; + return RKASK(e->u.s.info); + } + else break; + } + case VK: { + if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */ + return RKASK(e->u.s.info); + else break; + } + default: break; + } + /* not a constant in the right range: put it in a register */ + return luaK_exp2anyreg(fs, e); +} + + +void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { + switch (var->k) { + case VLOCAL: { + freeexp(fs, ex); + exp2reg(fs, ex, var->u.s.info); + return; + } + case VUPVAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0); + break; + } + case VGLOBAL: { + int e = luaK_exp2anyreg(fs, ex); + luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info); + break; + } + case VINDEXED: { + int e = luaK_exp2RK(fs, ex); + luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e); + break; + } + default: { + lua_assert(0); /* invalid var kind to store */ + break; + } + } + freeexp(fs, ex); +} + + +void luaK_self (FuncState *fs, expdesc *e, expdesc *key) { + int func; + luaK_exp2anyreg(fs, e); + freeexp(fs, e); + func = fs->freereg; + luaK_reserveregs(fs, 2); + luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key)); + freeexp(fs, key); + e->u.s.info = func; + e->k = VNONRELOC; +} + + +static void invertjump (FuncState *fs, expdesc *e) { + Instruction *pc = getjumpcontrol(fs, e->u.s.info); + lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && + GET_OPCODE(*pc) != OP_TEST); + SETARG_A(*pc, !(GETARG_A(*pc))); +} + + +static int jumponcond (FuncState *fs, expdesc *e, int cond) { + if (e->k == VRELOCABLE) { + Instruction ie = getcode(fs, e); + if (GET_OPCODE(ie) == OP_NOT) { + fs->pc--; /* remove previous OP_NOT */ + return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond); + } + /* else go through */ + } + discharge2anyreg(fs, e); + freeexp(fs, e); + return condjump(fs, OP_TESTSET, NO_REG, e->u.s.info, cond); +} + + +void luaK_goiftrue (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VK: case VKNUM: case VTRUE: { + pc = NO_JUMP; /* always true; do nothing */ + break; + } + case VFALSE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + invertjump(fs, e); + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 0); + break; + } + } + luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */ + luaK_patchtohere(fs, e->t); + e->t = NO_JUMP; +} + + +static void luaK_goiffalse (FuncState *fs, expdesc *e) { + int pc; /* pc of last jump */ + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + pc = NO_JUMP; /* always false; do nothing */ + break; + } + case VTRUE: { + pc = luaK_jump(fs); /* always jump */ + break; + } + case VJMP: { + pc = e->u.s.info; + break; + } + default: { + pc = jumponcond(fs, e, 1); + break; + } + } + luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */ + luaK_patchtohere(fs, e->f); + e->f = NO_JUMP; +} + + +static void codenot (FuncState *fs, expdesc *e) { + luaK_dischargevars(fs, e); + switch (e->k) { + case VNIL: case VFALSE: { + e->k = VTRUE; + break; + } + case VK: case VKNUM: case VTRUE: { + e->k = VFALSE; + break; + } + case VJMP: { + invertjump(fs, e); + break; + } + case VRELOCABLE: + case VNONRELOC: { + discharge2anyreg(fs, e); + freeexp(fs, e); + e->u.s.info = luaK_codeABC(fs, OP_NOT, 0, e->u.s.info, 0); + e->k = VRELOCABLE; + break; + } + default: { + lua_assert(0); /* cannot happen */ + break; + } + } + /* interchange true and false lists */ + { int temp = e->f; e->f = e->t; e->t = temp; } + removevalues(fs, e->f); + removevalues(fs, e->t); +} + + +void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + t->u.s.aux = luaK_exp2RK(fs, k); + t->k = VINDEXED; +} + + +static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { + lua_Number v1, v2, r; + if (!isnumeral(e1) || !isnumeral(e2)) return 0; + v1 = e1->u.nval; + v2 = e2->u.nval; + switch (op) { + case OP_ADD: r = luai_numadd(v1, v2); break; + case OP_SUB: r = luai_numsub(v1, v2); break; + case OP_MUL: r = luai_nummul(v1, v2); break; + case OP_DIV: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_numdiv(v1, v2); break; + case OP_MOD: + if (v2 == 0) return 0; /* do not attempt to divide by 0 */ + r = luai_nummod(v1, v2); break; + case OP_POW: r = luai_numpow(v1, v2); break; + case OP_UNM: r = luai_numunm(v1); break; + case OP_LEN: return 0; /* no constant folding for 'len' */ + default: lua_assert(0); r = 0; break; + } + if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */ + e1->u.nval = r; + return 1; +} + + +static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { + if (constfolding(op, e1, e2)) + return; + else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; + int o1 = luaK_exp2RK(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } + e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); + e1->k = VRELOCABLE; + } +} + + +static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, + expdesc *e2) { + int o1 = luaK_exp2RK(fs, e1); + int o2 = luaK_exp2RK(fs, e2); + freeexp(fs, e2); + freeexp(fs, e1); + if (cond == 0 && op != OP_EQ) { + int temp; /* exchange args to replace by `<' or `<=' */ + temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */ + cond = 1; + } + e1->u.s.info = condjump(fs, op, cond, o1, o2); + e1->k = VJMP; +} + + +void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { + expdesc e2; + e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; + switch (op) { + case OPR_MINUS: { + if (!isnumeral(e)) + luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */ + codearith(fs, OP_UNM, e, &e2); + break; + } + case OPR_NOT: codenot(fs, e); break; + case OPR_LEN: { + luaK_exp2anyreg(fs, e); /* cannot operate on constants */ + codearith(fs, OP_LEN, e, &e2); + break; + } + default: lua_assert(0); + } +} + + +void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { + switch (op) { + case OPR_AND: { + luaK_goiftrue(fs, v); + break; + } + case OPR_OR: { + luaK_goiffalse(fs, v); + break; + } + case OPR_CONCAT: { + luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ + break; + } + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + if (!isnumeral(v)) luaK_exp2RK(fs, v); + break; + } + default: { + luaK_exp2RK(fs, v); + break; + } + } +} + + +void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { + switch (op) { + case OPR_AND: { + lua_assert(e1->t == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->f, e1->f); + *e1 = *e2; + break; + } + case OPR_OR: { + lua_assert(e1->f == NO_JUMP); /* list must be closed */ + luaK_dischargevars(fs, e2); + luaK_concat(fs, &e2->t, e1->t); + *e1 = *e2; + break; + } + case OPR_CONCAT: { + luaK_exp2val(fs, e2); + if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) { + lua_assert(e1->u.s.info == GETARG_B(getcode(fs, e2))-1); + freeexp(fs, e1); + SETARG_B(getcode(fs, e2), e1->u.s.info); + e1->k = VRELOCABLE; e1->u.s.info = e2->u.s.info; + } + else { + luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */ + codearith(fs, OP_CONCAT, e1, e2); + } + break; + } + case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break; + case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break; + case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break; + case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break; + case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break; + case OPR_POW: codearith(fs, OP_POW, e1, e2); break; + case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break; + case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break; + case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break; + case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break; + case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break; + case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break; + default: lua_assert(0); + } +} + + +void luaK_fixline (FuncState *fs, int line) { + fs->f->lineinfo[fs->pc - 1] = line; +} + + +static int luaK_code (FuncState *fs, Instruction i, int line) { + Proto *f = fs->f; + dischargejpc(fs); /* `pc' will change */ + /* put new instruction in code array */ + luaM_growvector(fs->L, f->code, fs->pc, f->sizecode, Instruction, + MAX_INT, "code size overflow"); + f->code[fs->pc] = i; + /* save corresponding line information */ + luaM_growvector(fs->L, f->lineinfo, fs->pc, f->sizelineinfo, int, + MAX_INT, "code size overflow"); + f->lineinfo[fs->pc] = line; + return fs->pc++; +} + + +int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { + lua_assert(getOpMode(o) == iABC); + lua_assert(getBMode(o) != OpArgN || b == 0); + lua_assert(getCMode(o) != OpArgN || c == 0); + return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline); +} + + +int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { + lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); + lua_assert(getCMode(o) == OpArgN); + return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); +} + + +void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { + int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; + int b = (tostore == LUA_MULTRET) ? 0 : tostore; + lua_assert(tostore != 0); + if (c <= MAXARG_C) + luaK_codeABC(fs, OP_SETLIST, base, b, c); + else { + luaK_codeABC(fs, OP_SETLIST, base, b, 0); + luaK_code(fs, cast(Instruction, c), fs->ls->lastline); + } + fs->freereg = base + 1; /* free registers with list values */ +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lcode.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lcode.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lcode.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lcode.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,76 @@ +/* +** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $ +** Code generator for Lua +** See Copyright Notice in lua.h +*/ + +#ifndef lcode_h +#define lcode_h + +#include "llex.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" + + +/* +** Marks the end of a patch list. It is an invalid value both as an absolute +** address, and as a list link (would link an element to itself). +*/ +#define NO_JUMP (-1) + + +/* +** grep "ORDER OPR" if you change these enums +*/ +typedef enum BinOpr { + OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, + OPR_CONCAT, + OPR_NE, OPR_EQ, + OPR_LT, OPR_LE, OPR_GT, OPR_GE, + OPR_AND, OPR_OR, + OPR_NOBINOPR +} BinOpr; + + +typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; + + +#define getcode(fs,e) ((fs)->f->code[(e)->u.s.info]) + +#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) + +#define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) + +LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); +LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); +LUAI_FUNC void luaK_fixline (FuncState *fs, int line); +LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); +LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); +LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); +LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); +LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); +LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); +LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); +LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); +LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); +LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); +LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); +LUAI_FUNC int luaK_jump (FuncState *fs); +LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); +LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); +LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); +LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); +LUAI_FUNC int luaK_getlabel (FuncState *fs); +LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); +LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); +LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); +LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); + + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/ldblib.c.svn-base blobby-0.9c/src/lua/.svn/text-base/ldblib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/ldblib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/ldblib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,397 @@ +/* +** $Id: ldblib.c,v 1.104.1.3 2008/01/21 13:11:21 roberto Exp $ +** Interface from Lua to its debug API +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldblib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +static int db_getregistry (lua_State *L) { + lua_pushvalue(L, LUA_REGISTRYINDEX); + return 1; +} + + +static int db_getmetatable (lua_State *L) { + luaL_checkany(L, 1); + if (!lua_getmetatable(L, 1)) { + lua_pushnil(L); /* no metatable */ + } + return 1; +} + + +static int db_setmetatable (lua_State *L) { + int t = lua_type(L, 2); + luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2, + "nil or table expected"); + lua_settop(L, 2); + lua_pushboolean(L, lua_setmetatable(L, 1)); + return 1; +} + + +static int db_getfenv (lua_State *L) { + lua_getfenv(L, 1); + return 1; +} + + +static int db_setfenv (lua_State *L) { + luaL_checktype(L, 2, LUA_TTABLE); + lua_settop(L, 2); + if (lua_setfenv(L, 1) == 0) + luaL_error(L, LUA_QL("setfenv") + " cannot change environment of given object"); + return 1; +} + + +static void settabss (lua_State *L, const char *i, const char *v) { + lua_pushstring(L, v); + lua_setfield(L, -2, i); +} + + +static void settabsi (lua_State *L, const char *i, int v) { + lua_pushinteger(L, v); + lua_setfield(L, -2, i); +} + + +static lua_State *getthread (lua_State *L, int *arg) { + if (lua_isthread(L, 1)) { + *arg = 1; + return lua_tothread(L, 1); + } + else { + *arg = 0; + return L; + } +} + + +static void treatstackoption (lua_State *L, lua_State *L1, const char *fname) { + if (L == L1) { + lua_pushvalue(L, -2); + lua_remove(L, -3); + } + else + lua_xmove(L1, L, 1); + lua_setfield(L, -2, fname); +} + + +static int db_getinfo (lua_State *L) { + lua_Debug ar; + int arg; + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnSu"); + if (lua_isnumber(L, arg+1)) { + if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) { + lua_pushnil(L); /* level out of range */ + return 1; + } + } + else if (lua_isfunction(L, arg+1)) { + lua_pushfstring(L, ">%s", options); + options = lua_tostring(L, -1); + lua_pushvalue(L, arg+1); + lua_xmove(L, L1, 1); + } + else + return luaL_argerror(L, arg+1, "function or level expected"); + if (!lua_getinfo(L1, options, &ar)) + return luaL_argerror(L, arg+2, "invalid option"); + lua_createtable(L, 0, 2); + if (strchr(options, 'S')) { + settabss(L, "source", ar.source); + settabss(L, "short_src", ar.short_src); + settabsi(L, "linedefined", ar.linedefined); + settabsi(L, "lastlinedefined", ar.lastlinedefined); + settabss(L, "what", ar.what); + } + if (strchr(options, 'l')) + settabsi(L, "currentline", ar.currentline); + if (strchr(options, 'u')) + settabsi(L, "nups", ar.nups); + if (strchr(options, 'n')) { + settabss(L, "name", ar.name); + settabss(L, "namewhat", ar.namewhat); + } + if (strchr(options, 'L')) + treatstackoption(L, L1, "activelines"); + if (strchr(options, 'f')) + treatstackoption(L, L1, "func"); + return 1; /* return table */ +} + + +static int db_getlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + const char *name; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2)); + if (name) { + lua_xmove(L1, L, 1); + lua_pushstring(L, name); + lua_pushvalue(L, -2); + return 2; + } + else { + lua_pushnil(L); + return 1; + } +} + + +static int db_setlocal (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */ + return luaL_argerror(L, arg+1, "level out of range"); + luaL_checkany(L, arg+3); + lua_settop(L, arg+3); + lua_xmove(L, L1, 1); + lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2))); + return 1; +} + + +static int auxupvalue (lua_State *L, int get) { + const char *name; + int n = luaL_checkint(L, 2); + luaL_checktype(L, 1, LUA_TFUNCTION); + if (lua_iscfunction(L, 1)) return 0; /* cannot touch C upvalues from Lua */ + name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n); + if (name == NULL) return 0; + lua_pushstring(L, name); + lua_insert(L, -(get+1)); + return get + 1; +} + + +static int db_getupvalue (lua_State *L) { + return auxupvalue(L, 1); +} + + +static int db_setupvalue (lua_State *L) { + luaL_checkany(L, 3); + return auxupvalue(L, 0); +} + + + +static const char KEY_HOOK = 'h'; + + +static void hookf (lua_State *L, lua_Debug *ar) { + static const char *const hooknames[] = + {"call", "return", "line", "count", "tail return"}; + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushlightuserdata(L, L); + lua_rawget(L, -2); + if (lua_isfunction(L, -1)) { + lua_pushstring(L, hooknames[(int)ar->event]); + if (ar->currentline >= 0) + lua_pushinteger(L, ar->currentline); + else lua_pushnil(L); + lua_assert(lua_getinfo(L, "lS", ar)); + lua_call(L, 2, 0); + } +} + + +static int makemask (const char *smask, int count) { + int mask = 0; + if (strchr(smask, 'c')) mask |= LUA_MASKCALL; + if (strchr(smask, 'r')) mask |= LUA_MASKRET; + if (strchr(smask, 'l')) mask |= LUA_MASKLINE; + if (count > 0) mask |= LUA_MASKCOUNT; + return mask; +} + + +static char *unmakemask (int mask, char *smask) { + int i = 0; + if (mask & LUA_MASKCALL) smask[i++] = 'c'; + if (mask & LUA_MASKRET) smask[i++] = 'r'; + if (mask & LUA_MASKLINE) smask[i++] = 'l'; + smask[i] = '\0'; + return smask; +} + + +static void gethooktable (lua_State *L) { + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_rawget(L, LUA_REGISTRYINDEX); + if (!lua_istable(L, -1)) { + lua_pop(L, 1); + lua_createtable(L, 0, 1); + lua_pushlightuserdata(L, (void *)&KEY_HOOK); + lua_pushvalue(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); + } +} + + +static int db_sethook (lua_State *L) { + int arg, mask, count; + lua_Hook func; + lua_State *L1 = getthread(L, &arg); + if (lua_isnoneornil(L, arg+1)) { + lua_settop(L, arg+1); + func = NULL; mask = 0; count = 0; /* turn off hooks */ + } + else { + const char *smask = luaL_checkstring(L, arg+2); + luaL_checktype(L, arg+1, LUA_TFUNCTION); + count = luaL_optint(L, arg+3, 0); + func = hookf; mask = makemask(smask, count); + } + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_pushvalue(L, arg+1); + lua_rawset(L, -3); /* set new hook */ + lua_pop(L, 1); /* remove hook table */ + lua_sethook(L1, func, mask, count); /* set hooks */ + return 0; +} + + +static int db_gethook (lua_State *L) { + int arg; + lua_State *L1 = getthread(L, &arg); + char buff[5]; + int mask = lua_gethookmask(L1); + lua_Hook hook = lua_gethook(L1); + if (hook != NULL && hook != hookf) /* external hook? */ + lua_pushliteral(L, "external hook"); + else { + gethooktable(L); + lua_pushlightuserdata(L, L1); + lua_rawget(L, -2); /* get hook */ + lua_remove(L, -2); /* remove hook table */ + } + lua_pushstring(L, unmakemask(mask, buff)); + lua_pushinteger(L, lua_gethookcount(L1)); + return 3; +} + + +static int db_debug (lua_State *L) { + for (;;) { + char buffer[250]; + fputs("lua_debug> ", stderr); + if (fgets(buffer, sizeof(buffer), stdin) == 0 || + strcmp(buffer, "cont\n") == 0) + return 0; + if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") || + lua_pcall(L, 0, 0, 0)) { + fputs(lua_tostring(L, -1), stderr); + fputs("\n", stderr); + } + lua_settop(L, 0); /* remove eventual returns */ + } +} + + +#define LEVELS1 12 /* size of the first part of the stack */ +#define LEVELS2 10 /* size of the second part of the stack */ + +static int db_errorfb (lua_State *L) { + int level; + int firstpart = 1; /* still before eventual `...' */ + int arg; + lua_State *L1 = getthread(L, &arg); + lua_Debug ar; + if (lua_isnumber(L, arg+2)) { + level = (int)lua_tointeger(L, arg+2); + lua_pop(L, 1); + } + else + level = (L == L1) ? 1 : 0; /* level 0 may be this own function */ + if (lua_gettop(L) == arg) + lua_pushliteral(L, ""); + else if (!lua_isstring(L, arg+1)) return 1; /* message is not a string */ + else lua_pushliteral(L, "\n"); + lua_pushliteral(L, "stack traceback:"); + while (lua_getstack(L1, level++, &ar)) { + if (level > LEVELS1 && firstpart) { + /* no more than `LEVELS2' more levels? */ + if (!lua_getstack(L1, level+LEVELS2, &ar)) + level--; /* keep going */ + else { + lua_pushliteral(L, "\n\t..."); /* too many levels */ + while (lua_getstack(L1, level+LEVELS2, &ar)) /* find last levels */ + level++; + } + firstpart = 0; + continue; + } + lua_pushliteral(L, "\n\t"); + lua_getinfo(L1, "Snl", &ar); + lua_pushfstring(L, "%s:", ar.short_src); + if (ar.currentline > 0) + lua_pushfstring(L, "%d:", ar.currentline); + if (*ar.namewhat != '\0') /* is there a name? */ + lua_pushfstring(L, " in function " LUA_QS, ar.name); + else { + if (*ar.what == 'm') /* main? */ + lua_pushfstring(L, " in main chunk"); + else if (*ar.what == 'C' || *ar.what == 't') + lua_pushliteral(L, " ?"); /* C function or tail call */ + else + lua_pushfstring(L, " in function <%s:%d>", + ar.short_src, ar.linedefined); + } + lua_concat(L, lua_gettop(L) - arg); + } + lua_concat(L, lua_gettop(L) - arg); + return 1; +} + + +static const luaL_Reg dblib[] = { + {"debug", db_debug}, + {"getfenv", db_getfenv}, + {"gethook", db_gethook}, + {"getinfo", db_getinfo}, + {"getlocal", db_getlocal}, + {"getregistry", db_getregistry}, + {"getmetatable", db_getmetatable}, + {"getupvalue", db_getupvalue}, + {"setfenv", db_setfenv}, + {"sethook", db_sethook}, + {"setlocal", db_setlocal}, + {"setmetatable", db_setmetatable}, + {"setupvalue", db_setupvalue}, + {"traceback", db_errorfb}, + {NULL, NULL} +}; + + +LUALIB_API int luaopen_debug (lua_State *L) { + luaL_register(L, LUA_DBLIBNAME, dblib); + return 1; +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/ldebug.c.svn-base blobby-0.9c/src/lua/.svn/text-base/ldebug.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/ldebug.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/ldebug.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,638 @@ +/* +** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $ +** Debug Interface +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + + +#define ldebug_c +#define LUA_CORE + +#include "lua.h" + +#include "lapi.h" +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); + + +static int currentpc (lua_State *L, CallInfo *ci) { + if (!isLua(ci)) return -1; /* function is not a Lua function? */ + if (ci == L->ci) + ci->savedpc = L->savedpc; + return pcRel(ci->savedpc, ci_func(ci)->l.p); +} + + +static int currentline (lua_State *L, CallInfo *ci) { + int pc = currentpc(L, ci); + if (pc < 0) + return -1; /* only active lua functions have current-line information */ + else + return getline(ci_func(ci)->l.p, pc); +} + + +/* +** this function can be called asynchronous (e.g. during a signal) +*/ +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { + if (func == NULL || mask == 0) { /* turn off hooks? */ + mask = 0; + func = NULL; + } + L->hook = func; + L->basehookcount = count; + resethookcount(L); + L->hookmask = cast_byte(mask); + return 1; +} + + +LUA_API lua_Hook lua_gethook (lua_State *L) { + return L->hook; +} + + +LUA_API int lua_gethookmask (lua_State *L) { + return L->hookmask; +} + + +LUA_API int lua_gethookcount (lua_State *L) { + return L->basehookcount; +} + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { + int status; + CallInfo *ci; + lua_lock(L); + for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { + level--; + if (f_isLua(ci)) /* Lua function? */ + level -= ci->tailcalls; /* skip lost tail calls */ + } + if (level == 0 && ci > L->base_ci) { /* level found? */ + status = 1; + ar->i_ci = cast_int(ci - L->base_ci); + } + else if (level < 0) { /* level is of a lost tail call? */ + status = 1; + ar->i_ci = 0; + } + else status = 0; /* no such level */ + lua_unlock(L); + return status; +} + + +static Proto *getluaproto (CallInfo *ci) { + return (isLua(ci) ? ci_func(ci)->l.p : NULL); +} + + +static const char *findlocal (lua_State *L, CallInfo *ci, int n) { + const char *name; + Proto *fp = getluaproto(ci); + if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) + return name; /* is a local variable in a Lua function */ + else { + StkId limit = (ci == L->ci) ? L->top : (ci+1)->func; + if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */ + return "(*temporary)"; + else + return NULL; + } +} + + +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + luaA_pushobject(L, ci->base + (n - 1)); + lua_unlock(L); + return name; +} + + +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { + CallInfo *ci = L->base_ci + ar->i_ci; + const char *name = findlocal(L, ci, n); + lua_lock(L); + if (name) + setobjs2s(L, ci->base + (n - 1), L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); + return name; +} + + +static void funcinfo (lua_Debug *ar, Closure *cl) { + if (cl->c.isC) { + ar->source = "=[C]"; + ar->linedefined = -1; + ar->lastlinedefined = -1; + ar->what = "C"; + } + else { + ar->source = getstr(cl->l.p->source); + ar->linedefined = cl->l.p->linedefined; + ar->lastlinedefined = cl->l.p->lastlinedefined; + ar->what = (ar->linedefined == 0) ? "main" : "Lua"; + } + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); +} + + +static void info_tailcall (lua_Debug *ar) { + ar->name = ar->namewhat = ""; + ar->what = "tail"; + ar->lastlinedefined = ar->linedefined = ar->currentline = -1; + ar->source = "=(tail call)"; + luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); + ar->nups = 0; +} + + +static void collectvalidlines (lua_State *L, Closure *f) { + if (f == NULL || f->c.isC) { + setnilvalue(L->top); + } + else { + Table *t = luaH_new(L, 0, 0); + int *lineinfo = f->l.p->lineinfo; + int i; + for (i=0; il.p->sizelineinfo; i++) + setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); + sethvalue(L, L->top, t); + } + incr_top(L); +} + + +static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, + Closure *f, CallInfo *ci) { + int status = 1; + if (f == NULL) { + info_tailcall(ar); + return status; + } + for (; *what; what++) { + switch (*what) { + case 'S': { + funcinfo(ar, f); + break; + } + case 'l': { + ar->currentline = (ci) ? currentline(L, ci) : -1; + break; + } + case 'u': { + ar->nups = f->c.nupvalues; + break; + } + case 'n': { + ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; + if (ar->namewhat == NULL) { + ar->namewhat = ""; /* not found */ + ar->name = NULL; + } + break; + } + case 'L': + case 'f': /* handled by lua_getinfo */ + break; + default: status = 0; /* invalid option */ + } + } + return status; +} + + +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { + int status; + Closure *f = NULL; + CallInfo *ci = NULL; + lua_lock(L); + if (*what == '>') { + StkId func = L->top - 1; + luai_apicheck(L, ttisfunction(func)); + what++; /* skip the '>' */ + f = clvalue(func); + L->top--; /* pop function */ + } + else if (ar->i_ci != 0) { /* no tail call? */ + ci = L->base_ci + ar->i_ci; + lua_assert(ttisfunction(ci->func)); + f = clvalue(ci->func); + } + status = auxgetinfo(L, what, ar, f, ci); + if (strchr(what, 'f')) { + if (f == NULL) setnilvalue(L->top); + else setclvalue(L, L->top, f); + incr_top(L); + } + if (strchr(what, 'L')) + collectvalidlines(L, f); + lua_unlock(L); + return status; +} + + +/* +** {====================================================== +** Symbolic Execution and code checker +** ======================================================= +*/ + +#define check(x) if (!(x)) return 0; + +#define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode) + +#define checkreg(pt,reg) check((reg) < (pt)->maxstacksize) + + + +static int precheck (const Proto *pt) { + check(pt->maxstacksize <= MAXSTACK); + check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); + check(!(pt->is_vararg & VARARG_NEEDSARG) || + (pt->is_vararg & VARARG_HASARG)); + check(pt->sizeupvalues <= pt->nups); + check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0); + check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN); + return 1; +} + + +#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) + +int luaG_checkopenop (Instruction i) { + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: + case OP_RETURN: + case OP_SETLIST: { + check(GETARG_B(i) == 0); + return 1; + } + default: return 0; /* invalid instruction after an open call */ + } +} + + +static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { + switch (mode) { + case OpArgN: check(r == 0); break; + case OpArgU: break; + case OpArgR: checkreg(pt, r); break; + case OpArgK: + check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize); + break; + } + return 1; +} + + +static Instruction symbexec (const Proto *pt, int lastpc, int reg) { + int pc; + int last; /* stores position of last instruction that changed `reg' */ + last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ + check(precheck(pt)); + for (pc = 0; pc < lastpc; pc++) { + Instruction i = pt->code[pc]; + OpCode op = GET_OPCODE(i); + int a = GETARG_A(i); + int b = 0; + int c = 0; + check(op < NUM_OPCODES); + checkreg(pt, a); + switch (getOpMode(op)) { + case iABC: { + b = GETARG_B(i); + c = GETARG_C(i); + check(checkArgMode(pt, b, getBMode(op))); + check(checkArgMode(pt, c, getCMode(op))); + break; + } + case iABx: { + b = GETARG_Bx(i); + if (getBMode(op) == OpArgK) check(b < pt->sizek); + break; + } + case iAsBx: { + b = GETARG_sBx(i); + if (getBMode(op) == OpArgR) { + int dest = pc+1+b; + check(0 <= dest && dest < pt->sizecode); + if (dest > 0) { + int j; + /* check that it does not jump to a setlist count; this + is tricky, because the count from a previous setlist may + have the same value of an invalid setlist; so, we must + go all the way back to the first of them (if any) */ + for (j = 0; j < dest; j++) { + Instruction d = pt->code[dest-1-j]; + if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break; + } + /* if 'j' is even, previous value is not a setlist (even if + it looks like one) */ + check((j&1) == 0); + } + } + break; + } + } + if (testAMode(op)) { + if (a == reg) last = pc; /* change register `a' */ + } + if (testTMode(op)) { + check(pc+2 < pt->sizecode); /* check skip */ + check(GET_OPCODE(pt->code[pc+1]) == OP_JMP); + } + switch (op) { + case OP_LOADBOOL: { + if (c == 1) { /* does it jump? */ + check(pc+2 < pt->sizecode); /* check its jump */ + check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST || + GETARG_C(pt->code[pc+1]) != 0); + } + break; + } + case OP_LOADNIL: { + if (a <= reg && reg <= b) + last = pc; /* set registers from `a' to `b' */ + break; + } + case OP_GETUPVAL: + case OP_SETUPVAL: { + check(b < pt->nups); + break; + } + case OP_GETGLOBAL: + case OP_SETGLOBAL: { + check(ttisstring(&pt->k[b])); + break; + } + case OP_SELF: { + checkreg(pt, a+1); + if (reg == a+1) last = pc; + break; + } + case OP_CONCAT: { + check(b < c); /* at least two operands */ + break; + } + case OP_TFORLOOP: { + check(c >= 1); /* at least one result (control variable) */ + checkreg(pt, a+2+c); /* space for results */ + if (reg >= a+2) last = pc; /* affect all regs above its base */ + break; + } + case OP_FORLOOP: + case OP_FORPREP: + checkreg(pt, a+3); + /* go through */ + case OP_JMP: { + int dest = pc+1+b; + /* not full check and jump is forward and do not skip `lastpc'? */ + if (reg != NO_REG && pc < dest && dest <= lastpc) + pc += b; /* do the jump */ + break; + } + case OP_CALL: + case OP_TAILCALL: { + if (b != 0) { + checkreg(pt, a+b-1); + } + c--; /* c = num. returns */ + if (c == LUA_MULTRET) { + check(checkopenop(pt, pc)); + } + else if (c != 0) + checkreg(pt, a+c-1); + if (reg >= a) last = pc; /* affect all registers above base */ + break; + } + case OP_RETURN: { + b--; /* b = num. returns */ + if (b > 0) checkreg(pt, a+b-1); + break; + } + case OP_SETLIST: { + if (b > 0) checkreg(pt, a + b); + if (c == 0) { + pc++; + check(pc < pt->sizecode - 1); + } + break; + } + case OP_CLOSURE: { + int nup, j; + check(b < pt->sizep); + nup = pt->p[b]->nups; + check(pc + nup < pt->sizecode); + for (j = 1; j <= nup; j++) { + OpCode op1 = GET_OPCODE(pt->code[pc + j]); + check(op1 == OP_GETUPVAL || op1 == OP_MOVE); + } + if (reg != NO_REG) /* tracing? */ + pc += nup; /* do not 'execute' these pseudo-instructions */ + break; + } + case OP_VARARG: { + check((pt->is_vararg & VARARG_ISVARARG) && + !(pt->is_vararg & VARARG_NEEDSARG)); + b--; + if (b == LUA_MULTRET) check(checkopenop(pt, pc)); + checkreg(pt, a+b-1); + break; + } + default: break; + } + } + return pt->code[last]; +} + +#undef check +#undef checkjump +#undef checkreg + +/* }====================================================== */ + + +int luaG_checkcode (const Proto *pt) { + return (symbexec(pt, pt->sizecode, NO_REG) != 0); +} + + +static const char *kname (Proto *p, int c) { + if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) + return svalue(&p->k[INDEXK(c)]); + else + return "?"; +} + + +static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, + const char **name) { + if (isLua(ci)) { /* a Lua function? */ + Proto *p = ci_func(ci)->l.p; + int pc = currentpc(L, ci); + Instruction i; + *name = luaF_getlocalname(p, stackpos+1, pc); + if (*name) /* is a local? */ + return "local"; + i = symbexec(p, pc, stackpos); /* try symbolic execution */ + lua_assert(pc != -1); + switch (GET_OPCODE(i)) { + case OP_GETGLOBAL: { + int g = GETARG_Bx(i); /* global index */ + lua_assert(ttisstring(&p->k[g])); + *name = svalue(&p->k[g]); + return "global"; + } + case OP_MOVE: { + int a = GETARG_A(i); + int b = GETARG_B(i); /* move from `b' to `a' */ + if (b < a) + return getobjname(L, ci, b, name); /* get name for `b' */ + break; + } + case OP_GETTABLE: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "field"; + } + case OP_GETUPVAL: { + int u = GETARG_B(i); /* upvalue index */ + *name = p->upvalues ? getstr(p->upvalues[u]) : "?"; + return "upvalue"; + } + case OP_SELF: { + int k = GETARG_C(i); /* key index */ + *name = kname(p, k); + return "method"; + } + default: break; + } + } + return NULL; /* no useful name found */ +} + + +static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { + Instruction i; + if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) + return NULL; /* calling function is not Lua (or is unknown) */ + ci--; /* calling function */ + i = ci_func(ci)->l.p->code[currentpc(L, ci)]; + if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || + GET_OPCODE(i) == OP_TFORLOOP) + return getobjname(L, ci, GETARG_A(i), name); + else + return NULL; /* no useful name can be found */ +} + + +/* only ANSI way to check whether a pointer points to an array */ +static int isinstack (CallInfo *ci, const TValue *o) { + StkId p; + for (p = ci->base; p < ci->top; p++) + if (o == p) return 1; + return 0; +} + + +void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { + const char *name = NULL; + const char *t = luaT_typenames[ttype(o)]; + const char *kind = (isinstack(L->ci, o)) ? + getobjname(L, L->ci, cast_int(o - L->base), &name) : + NULL; + if (kind) + luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", + op, kind, name, t); + else + luaG_runerror(L, "attempt to %s a %s value", op, t); +} + + +void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { + if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; + lua_assert(!ttisstring(p1) && !ttisnumber(p1)); + luaG_typeerror(L, p1, "concatenate"); +} + + +void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { + TValue temp; + if (luaV_tonumber(p1, &temp) == NULL) + p2 = p1; /* first operand is wrong */ + luaG_typeerror(L, p2, "perform arithmetic on"); +} + + +int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { + const char *t1 = luaT_typenames[ttype(p1)]; + const char *t2 = luaT_typenames[ttype(p2)]; + if (t1[2] == t2[2]) + luaG_runerror(L, "attempt to compare two %s values", t1); + else + luaG_runerror(L, "attempt to compare %s with %s", t1, t2); + return 0; +} + + +static void addinfo (lua_State *L, const char *msg) { + CallInfo *ci = L->ci; + if (isLua(ci)) { /* is Lua code? */ + char buff[LUA_IDSIZE]; /* add file:line information */ + int line = currentline(L, ci); + luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); + luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); + } +} + + +void luaG_errormsg (lua_State *L) { + if (L->errfunc != 0) { /* is there an error handling function? */ + StkId errfunc = restorestack(L, L->errfunc); + if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR); + setobjs2s(L, L->top, L->top - 1); /* move argument */ + setobjs2s(L, L->top - 1, errfunc); /* push function */ + incr_top(L); + luaD_call(L, L->top - 2, 1); /* call it */ + } + luaD_throw(L, LUA_ERRRUN); +} + + +void luaG_runerror (lua_State *L, const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + addinfo(L, luaO_pushvfstring(L, fmt, argp)); + va_end(argp); + luaG_errormsg(L); +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/ldebug.h.svn-base blobby-0.9c/src/lua/.svn/text-base/ldebug.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/ldebug.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/ldebug.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,33 @@ +/* +** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions from Debug Interface module +** See Copyright Notice in lua.h +*/ + +#ifndef ldebug_h +#define ldebug_h + + +#include "lstate.h" + + +#define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) + +#define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) + +#define resethookcount(L) (L->hookcount = L->basehookcount) + + +LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, + const char *opname); +LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, + const TValue *p2); +LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaG_errormsg (lua_State *L); +LUAI_FUNC int luaG_checkcode (const Proto *pt); +LUAI_FUNC int luaG_checkopenop (Instruction i); + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/ldo.c.svn-base blobby-0.9c/src/lua/.svn/text-base/ldo.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/ldo.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/ldo.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,518 @@ +/* +** $Id: ldo.c,v 2.38.1.3 2008/01/18 22:31:22 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define ldo_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lundump.h" +#include "lvm.h" +#include "lzio.h" + + + + +/* +** {====================================================== +** Error-recovery functions +** ======================================================= +*/ + + +/* chain list of long jump buffers */ +struct lua_longjmp { + struct lua_longjmp *previous; + luai_jmpbuf b; + volatile int status; /* error code */ +}; + + +void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { + switch (errcode) { + case LUA_ERRMEM: { + setsvalue2s(L, oldtop, luaS_newliteral(L, MEMERRMSG)); + break; + } + case LUA_ERRERR: { + setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling")); + break; + } + case LUA_ERRSYNTAX: + case LUA_ERRRUN: { + setobjs2s(L, oldtop, L->top - 1); /* error message on current top */ + break; + } + } + L->top = oldtop + 1; +} + + +static void restore_stack_limit (lua_State *L) { + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ + int inuse = cast_int(L->ci - L->base_ci); + if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ + luaD_reallocCI(L, LUAI_MAXCALLS); + } +} + + +static void resetstack (lua_State *L, int status) { + L->ci = L->base_ci; + L->base = L->ci->base; + luaF_close(L, L->base); /* close eventual pending closures */ + luaD_seterrorobj(L, status, L->base); + L->nCcalls = L->baseCcalls; + L->allowhook = 1; + restore_stack_limit(L); + L->errfunc = 0; + L->errorJmp = NULL; +} + + +void luaD_throw (lua_State *L, int errcode) { + if (L->errorJmp) { + L->errorJmp->status = errcode; + LUAI_THROW(L, L->errorJmp); + } + else { + L->status = cast_byte(errcode); + if (G(L)->panic) { + resetstack(L, errcode); + lua_unlock(L); + G(L)->panic(L); + } + exit(EXIT_FAILURE); + } +} + + +int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { + struct lua_longjmp lj; + lj.status = 0; + lj.previous = L->errorJmp; /* chain new error handler */ + L->errorJmp = &lj; + LUAI_TRY(L, &lj, + (*f)(L, ud); + ); + L->errorJmp = lj.previous; /* restore old error handler */ + return lj.status; +} + +/* }====================================================== */ + + +static void correctstack (lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->base_ci; ci <= L->ci; ci++) { + ci->top = (ci->top - oldstack) + L->stack; + ci->base = (ci->base - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + } + L->base = (L->base - oldstack) + L->stack; +} + + +void luaD_reallocstack (lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int realsize = newsize + 1 + EXTRA_STACK; + lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + L->stacksize = realsize; + L->stack_last = L->stack+newsize; + correctstack(L, oldstack); +} + + +void luaD_reallocCI (lua_State *L, int newsize) { + CallInfo *oldci = L->base_ci; + luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); + L->size_ci = newsize; + L->ci = (L->ci - oldci) + L->base_ci; + L->end_ci = L->base_ci + L->size_ci - 1; +} + + +void luaD_growstack (lua_State *L, int n) { + if (n <= L->stacksize) /* double size is enough? */ + luaD_reallocstack(L, 2*L->stacksize); + else + luaD_reallocstack(L, L->stacksize + n); +} + + +static CallInfo *growCI (lua_State *L) { + if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ + luaD_throw(L, LUA_ERRERR); + else { + luaD_reallocCI(L, 2*L->size_ci); + if (L->size_ci > LUAI_MAXCALLS) + luaG_runerror(L, "stack overflow"); + } + return ++L->ci; +} + + +void luaD_callhook (lua_State *L, int event, int line) { + lua_Hook hook = L->hook; + if (hook && L->allowhook) { + ptrdiff_t top = savestack(L, L->top); + ptrdiff_t ci_top = savestack(L, L->ci->top); + lua_Debug ar; + ar.event = event; + ar.currentline = line; + if (event == LUA_HOOKTAILRET) + ar.i_ci = 0; /* tail call; no debug information about it */ + else + ar.i_ci = cast_int(L->ci - L->base_ci); + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + L->ci->top = L->top + LUA_MINSTACK; + lua_assert(L->ci->top <= L->stack_last); + L->allowhook = 0; /* cannot call hooks inside a hook */ + lua_unlock(L); + (*hook)(L, &ar); + lua_lock(L); + lua_assert(!L->allowhook); + L->allowhook = 1; + L->ci->top = restorestack(L, ci_top); + L->top = restorestack(L, top); + } +} + + +static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { + int i; + int nfixargs = p->numparams; + Table *htab = NULL; + StkId base, fixed; + for (; actual < nfixargs; ++actual) + setnilvalue(L->top++); +#if defined(LUA_COMPAT_VARARG) + if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */ + int nvar = actual - nfixargs; /* number of extra arguments */ + lua_assert(p->is_vararg & VARARG_HASARG); + luaC_checkGC(L); + htab = luaH_new(L, nvar, 1); /* create `arg' table */ + for (i=0; itop - nvar + i); + /* store counter in field `n' */ + setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); + } +#endif + /* move fixed parameters to final position */ + fixed = L->top - actual; /* first fixed argument */ + base = L->top; /* final position of first argument */ + for (i=0; itop++, fixed+i); + setnilvalue(fixed+i); + } + /* add `arg' parameter */ + if (htab) { + sethvalue(L, L->top++, htab); + lua_assert(iswhite(obj2gco(htab))); + } + return base; +} + + +static StkId tryfuncTM (lua_State *L, StkId func) { + const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); + StkId p; + ptrdiff_t funcr = savestack(L, func); + if (!ttisfunction(tm)) + luaG_typeerror(L, func, "call"); + /* Open a hole inside the stack at `func' */ + for (p = L->top; p > func; p--) setobjs2s(L, p, p-1); + incr_top(L); + func = restorestack(L, funcr); /* previous call may change stack */ + setobj2s(L, func, tm); /* tag method is the new function to be called */ + return func; +} + + + +#define inc_ci(L) \ + ((L->ci == L->end_ci) ? growCI(L) : \ + (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) + + +int luaD_precall (lua_State *L, StkId func, int nresults) { + LClosure *cl; + ptrdiff_t funcr; + if (!ttisfunction(func)) /* `func' is not a function? */ + func = tryfuncTM(L, func); /* check the `function' tag method */ + funcr = savestack(L, func); + cl = &clvalue(func)->l; + L->ci->savedpc = L->savedpc; + if (!cl->isC) { /* Lua function? prepare its call */ + CallInfo *ci; + StkId st, base; + Proto *p = cl->p; + luaD_checkstack(L, p->maxstacksize); + func = restorestack(L, funcr); + if (!p->is_vararg) { /* no varargs? */ + base = func + 1; + if (L->top > base + p->numparams) + L->top = base + p->numparams; + } + else { /* vararg function */ + int nargs = cast_int(L->top - func) - 1; + base = adjust_varargs(L, p, nargs); + func = restorestack(L, funcr); /* previous call may change the stack */ + } + ci = inc_ci(L); /* now `enter' new function */ + ci->func = func; + L->base = ci->base = base; + ci->top = L->base + p->maxstacksize; + lua_assert(ci->top <= L->stack_last); + L->savedpc = p->code; /* starting point */ + ci->tailcalls = 0; + ci->nresults = nresults; + for (st = L->top; st < ci->top; st++) + setnilvalue(st); + L->top = ci->top; + if (L->hookmask & LUA_MASKCALL) { + L->savedpc++; /* hooks assume 'pc' is already incremented */ + luaD_callhook(L, LUA_HOOKCALL, -1); + L->savedpc--; /* correct 'pc' */ + } + return PCRLUA; + } + else { /* if is a C function, call it */ + CallInfo *ci; + int n; + luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ + ci = inc_ci(L); /* now `enter' new function */ + ci->func = restorestack(L, funcr); + L->base = ci->base = ci->func + 1; + ci->top = L->top + LUA_MINSTACK; + lua_assert(ci->top <= L->stack_last); + ci->nresults = nresults; + if (L->hookmask & LUA_MASKCALL) + luaD_callhook(L, LUA_HOOKCALL, -1); + lua_unlock(L); + n = (*curr_func(L)->c.f)(L); /* do the actual call */ + lua_lock(L); + if (n < 0) /* yielding? */ + return PCRYIELD; + else { + luaD_poscall(L, L->top - n); + return PCRC; + } + } +} + + +static StkId callrethooks (lua_State *L, StkId firstResult) { + ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ + luaD_callhook(L, LUA_HOOKRET, -1); + if (f_isLua(L->ci)) { /* Lua function? */ + while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ + luaD_callhook(L, LUA_HOOKTAILRET, -1); + } + return restorestack(L, fr); +} + + +int luaD_poscall (lua_State *L, StkId firstResult) { + StkId res; + int wanted, i; + CallInfo *ci; + if (L->hookmask & LUA_MASKRET) + firstResult = callrethooks(L, firstResult); + ci = L->ci--; + res = ci->func; /* res == final position of 1st result */ + wanted = ci->nresults; + L->base = (ci - 1)->base; /* restore base */ + L->savedpc = (ci - 1)->savedpc; /* restore savedpc */ + /* move results to correct place */ + for (i = wanted; i != 0 && firstResult < L->top; i--) + setobjs2s(L, res++, firstResult++); + while (i-- > 0) + setnilvalue(res++); + L->top = res; + return (wanted - LUA_MULTRET); /* 0 iff wanted == LUA_MULTRET */ +} + + +/* +** Call a function (C or Lua). The function to be called is at *func. +** The arguments are on the stack, right after the function. +** When returns, all the results are on the stack, starting at the original +** function position. +*/ +void luaD_call (lua_State *L, StkId func, int nResults) { + if (++L->nCcalls >= LUAI_MAXCCALLS) { + if (L->nCcalls == LUAI_MAXCCALLS) + luaG_runerror(L, "C stack overflow"); + else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3))) + luaD_throw(L, LUA_ERRERR); /* error while handing stack error */ + } + if (luaD_precall(L, func, nResults) == PCRLUA) /* is a Lua function? */ + luaV_execute(L, 1); /* call it */ + L->nCcalls--; + luaC_checkGC(L); +} + + +static void resume (lua_State *L, void *ud) { + StkId firstArg = cast(StkId, ud); + CallInfo *ci = L->ci; + if (L->status == 0) { /* start coroutine? */ + lua_assert(ci == L->base_ci && firstArg > L->base); + if (luaD_precall(L, firstArg - 1, LUA_MULTRET) != PCRLUA) + return; + } + else { /* resuming from previous yield */ + lua_assert(L->status == LUA_YIELD); + L->status = 0; + if (!f_isLua(ci)) { /* `common' yield? */ + /* finish interrupted execution of `OP_CALL' */ + lua_assert(GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_CALL || + GET_OPCODE(*((ci-1)->savedpc - 1)) == OP_TAILCALL); + if (luaD_poscall(L, firstArg)) /* complete it... */ + L->top = L->ci->top; /* and correct top if not multiple results */ + } + else /* yielded inside a hook: just continue its execution */ + L->base = L->ci->base; + } + luaV_execute(L, cast_int(L->ci - L->base_ci)); +} + + +static int resume_error (lua_State *L, const char *msg) { + L->top = L->ci->base; + setsvalue2s(L, L->top, luaS_new(L, msg)); + incr_top(L); + lua_unlock(L); + return LUA_ERRRUN; +} + + +LUA_API int lua_resume (lua_State *L, int nargs) { + int status; + lua_lock(L); + if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) + return resume_error(L, "cannot resume non-suspended coroutine"); + if (L->nCcalls >= LUAI_MAXCCALLS) + return resume_error(L, "C stack overflow"); + luai_userstateresume(L, nargs); + lua_assert(L->errfunc == 0); + L->baseCcalls = ++L->nCcalls; + status = luaD_rawrunprotected(L, resume, L->top - nargs); + if (status != 0) { /* error? */ + L->status = cast_byte(status); /* mark thread as `dead' */ + luaD_seterrorobj(L, status, L->top); + L->ci->top = L->top; + } + else { + lua_assert(L->nCcalls == L->baseCcalls); + status = L->status; + } + --L->nCcalls; + lua_unlock(L); + return status; +} + + +LUA_API int lua_yield (lua_State *L, int nresults) { + luai_userstateyield(L, nresults); + lua_lock(L); + if (L->nCcalls > L->baseCcalls) + luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); + L->base = L->top - nresults; /* protect stack slots below */ + L->status = LUA_YIELD; + lua_unlock(L); + return -1; +} + + +int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t old_top, ptrdiff_t ef) { + int status; + unsigned short oldnCcalls = L->nCcalls; + ptrdiff_t old_ci = saveci(L, L->ci); + lu_byte old_allowhooks = L->allowhook; + ptrdiff_t old_errfunc = L->errfunc; + L->errfunc = ef; + status = luaD_rawrunprotected(L, func, u); + if (status != 0) { /* an error occurred? */ + StkId oldtop = restorestack(L, old_top); + luaF_close(L, oldtop); /* close eventual pending closures */ + luaD_seterrorobj(L, status, oldtop); + L->nCcalls = oldnCcalls; + L->ci = restoreci(L, old_ci); + L->base = L->ci->base; + L->savedpc = L->ci->savedpc; + L->allowhook = old_allowhooks; + restore_stack_limit(L); + } + L->errfunc = old_errfunc; + return status; +} + + + +/* +** Execute a protected parser. +*/ +struct SParser { /* data to `f_parser' */ + ZIO *z; + Mbuffer buff; /* buffer to be used by the scanner */ + const char *name; +}; + +static void f_parser (lua_State *L, void *ud) { + int i; + Proto *tf; + Closure *cl; + struct SParser *p = cast(struct SParser *, ud); + int c = luaZ_lookahead(p->z); + luaC_checkGC(L); + tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, + &p->buff, p->name); + cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); + cl->l.p = tf; + for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ + cl->l.upvals[i] = luaF_newupval(L); + setclvalue(L, L->top, cl); + incr_top(L); +} + + +int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { + struct SParser p; + int status; + p.z = z; p.name = name; + luaZ_initbuffer(L, &p.buff); + status = luaD_pcall(L, f_parser, &p, savestack(L, L->top), L->errfunc); + luaZ_freebuffer(L, &p.buff); + return status; +} + + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/ldo.h.svn-base blobby-0.9c/src/lua/.svn/text-base/ldo.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/ldo.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/ldo.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,57 @@ +/* +** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ +** Stack and Call structure of Lua +** See Copyright Notice in lua.h +*/ + +#ifndef ldo_h +#define ldo_h + + +#include "lobject.h" +#include "lstate.h" +#include "lzio.h" + + +#define luaD_checkstack(L,n) \ + if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ + luaD_growstack(L, n); \ + else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); + + +#define incr_top(L) {luaD_checkstack(L,1); L->top++;} + +#define savestack(L,p) ((char *)(p) - (char *)L->stack) +#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) + +#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) +#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) + + +/* results from luaD_precall */ +#define PCRLUA 0 /* initiated a call to a Lua function */ +#define PCRC 1 /* did a call to a C function */ +#define PCRYIELD 2 /* C funtion yielded */ + + +/* type of protected functions, to be ran by `runprotected' */ +typedef void (*Pfunc) (lua_State *L, void *ud); + +LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); +LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); +LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); +LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); +LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, + ptrdiff_t oldtop, ptrdiff_t ef); +LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); +LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); +LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); +LUAI_FUNC void luaD_growstack (lua_State *L, int n); + +LUAI_FUNC void luaD_throw (lua_State *L, int errcode); +LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); + +LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); + +#endif + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/ldump.c.svn-base blobby-0.9c/src/lua/.svn/text-base/ldump.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/ldump.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/ldump.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,164 @@ +/* +** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** save precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define ldump_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lundump.h" + +typedef struct { + lua_State* L; + lua_Writer writer; + void* data; + int strip; + int status; +} DumpState; + +#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) +#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) + +static void DumpBlock(const void* b, size_t size, DumpState* D) +{ + if (D->status==0) + { + lua_unlock(D->L); + D->status=(*D->writer)(D->L,b,size,D->data); + lua_lock(D->L); + } +} + +static void DumpChar(int y, DumpState* D) +{ + char x=(char)y; + DumpVar(x,D); +} + +static void DumpInt(int x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpNumber(lua_Number x, DumpState* D) +{ + DumpVar(x,D); +} + +static void DumpVector(const void* b, int n, size_t size, DumpState* D) +{ + DumpInt(n,D); + DumpMem(b,n,size,D); +} + +static void DumpString(const TString* s, DumpState* D) +{ + if (s==NULL || getstr(s)==NULL) + { + size_t size=0; + DumpVar(size,D); + } + else + { + size_t size=s->tsv.len+1; /* include trailing '\0' */ + DumpVar(size,D); + DumpBlock(getstr(s),size,D); + } +} + +#define DumpCode(f,D) DumpVector(f->code,f->sizecode,sizeof(Instruction),D) + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D); + +static void DumpConstants(const Proto* f, DumpState* D) +{ + int i,n=f->sizek; + DumpInt(n,D); + for (i=0; ik[i]; + DumpChar(ttype(o),D); + switch (ttype(o)) + { + case LUA_TNIL: + break; + case LUA_TBOOLEAN: + DumpChar(bvalue(o),D); + break; + case LUA_TNUMBER: + DumpNumber(nvalue(o),D); + break; + case LUA_TSTRING: + DumpString(rawtsvalue(o),D); + break; + default: + lua_assert(0); /* cannot happen */ + break; + } + } + n=f->sizep; + DumpInt(n,D); + for (i=0; ip[i],f->source,D); +} + +static void DumpDebug(const Proto* f, DumpState* D) +{ + int i,n; + n= (D->strip) ? 0 : f->sizelineinfo; + DumpVector(f->lineinfo,n,sizeof(int),D); + n= (D->strip) ? 0 : f->sizelocvars; + DumpInt(n,D); + for (i=0; ilocvars[i].varname,D); + DumpInt(f->locvars[i].startpc,D); + DumpInt(f->locvars[i].endpc,D); + } + n= (D->strip) ? 0 : f->sizeupvalues; + DumpInt(n,D); + for (i=0; iupvalues[i],D); +} + +static void DumpFunction(const Proto* f, const TString* p, DumpState* D) +{ + DumpString((f->source==p || D->strip) ? NULL : f->source,D); + DumpInt(f->linedefined,D); + DumpInt(f->lastlinedefined,D); + DumpChar(f->nups,D); + DumpChar(f->numparams,D); + DumpChar(f->is_vararg,D); + DumpChar(f->maxstacksize,D); + DumpCode(f,D); + DumpConstants(f,D); + DumpDebug(f,D); +} + +static void DumpHeader(DumpState* D) +{ + char h[LUAC_HEADERSIZE]; + luaU_header(h); + DumpBlock(h,LUAC_HEADERSIZE,D); +} + +/* +** dump Lua function as precompiled chunk +*/ +int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) +{ + DumpState D; + D.L=L; + D.writer=w; + D.data=data; + D.strip=strip; + D.status=0; + DumpHeader(&D); + DumpFunction(f,NULL,&D); + return D.status; +} diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lfunc.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lfunc.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lfunc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lfunc.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,174 @@ +/* +** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + + +#include + +#define lfunc_c +#define LUA_CORE + +#include "lua.h" + +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->c.isC = 1; + c->c.env = e; + c->c.nupvalues = cast_byte(nelems); + return c; +} + + +Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { + Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); + luaC_link(L, obj2gco(c), LUA_TFUNCTION); + c->l.isC = 0; + c->l.env = e; + c->l.nupvalues = cast_byte(nelems); + while (nelems--) c->l.upvals[nelems] = NULL; + return c; +} + + +UpVal *luaF_newupval (lua_State *L) { + UpVal *uv = luaM_new(L, UpVal); + luaC_link(L, obj2gco(uv), LUA_TUPVAL); + uv->v = &uv->u.value; + setnilvalue(uv->v); + return uv; +} + + +UpVal *luaF_findupval (lua_State *L, StkId level) { + global_State *g = G(L); + GCObject **pp = &L->openupval; + UpVal *p; + UpVal *uv; + while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { + lua_assert(p->v != &p->u.value); + if (p->v == level) { /* found a corresponding upvalue? */ + if (isdead(g, obj2gco(p))) /* is it dead? */ + changewhite(obj2gco(p)); /* ressurect it */ + return p; + } + pp = &p->next; + } + uv = luaM_new(L, UpVal); /* not found: create a new one */ + uv->tt = LUA_TUPVAL; + uv->marked = luaC_white(g); + uv->v = level; /* current value lives in the stack */ + uv->next = *pp; /* chain it in the proper position */ + *pp = obj2gco(uv); + uv->u.l.prev = &g->uvhead; /* double link it in `uvhead' list */ + uv->u.l.next = g->uvhead.u.l.next; + uv->u.l.next->u.l.prev = uv; + g->uvhead.u.l.next = uv; + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + return uv; +} + + +static void unlinkupval (UpVal *uv) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ + uv->u.l.prev->u.l.next = uv->u.l.next; +} + + +void luaF_freeupval (lua_State *L, UpVal *uv) { + if (uv->v != &uv->u.value) /* is it open? */ + unlinkupval(uv); /* remove from open list */ + luaM_free(L, uv); /* free upvalue */ +} + + +void luaF_close (lua_State *L, StkId level) { + UpVal *uv; + global_State *g = G(L); + while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { + GCObject *o = obj2gco(uv); + lua_assert(!isblack(o) && uv->v != &uv->u.value); + L->openupval = uv->next; /* remove from `open' list */ + if (isdead(g, o)) + luaF_freeupval(L, uv); /* free upvalue */ + else { + unlinkupval(uv); + setobj(L, &uv->u.value, uv->v); + uv->v = &uv->u.value; /* now current value lives here */ + luaC_linkupval(L, uv); /* link upvalue into `gcroot' list */ + } + } +} + + +Proto *luaF_newproto (lua_State *L) { + Proto *f = luaM_new(L, Proto); + luaC_link(L, obj2gco(f), LUA_TPROTO); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->sizecode = 0; + f->sizelineinfo = 0; + f->sizeupvalues = 0; + f->nups = 0; + f->upvalues = NULL; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->lineinfo = NULL; + f->sizelocvars = 0; + f->locvars = NULL; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + + +void luaF_freeproto (lua_State *L, Proto *f) { + luaM_freearray(L, f->code, f->sizecode, Instruction); + luaM_freearray(L, f->p, f->sizep, Proto *); + luaM_freearray(L, f->k, f->sizek, TValue); + luaM_freearray(L, f->lineinfo, f->sizelineinfo, int); + luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); + luaM_freearray(L, f->upvalues, f->sizeupvalues, TString *); + luaM_free(L, f); +} + + +void luaF_freeclosure (lua_State *L, Closure *c) { + int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : + sizeLclosure(c->l.nupvalues); + luaM_freemem(L, c, size); +} + + +/* +** Look for n-th local variable at line `line' in function `func'. +** Returns NULL if not found. +*/ +const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { + int i; + for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { + if (pc < f->locvars[i].endpc) { /* is variable active? */ + local_number--; + if (local_number == 0) + return getstr(f->locvars[i].varname); + } + } + return NULL; /* not found */ +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lfunc.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lfunc.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lfunc.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lfunc.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,34 @@ +/* +** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ +** Auxiliary functions to manipulate prototypes and closures +** See Copyright Notice in lua.h +*/ + +#ifndef lfunc_h +#define lfunc_h + + +#include "lobject.h" + + +#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ + cast(int, sizeof(TValue)*((n)-1))) + +#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ + cast(int, sizeof(TValue *)*((n)-1))) + + +LUAI_FUNC Proto *luaF_newproto (lua_State *L); +LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); +LUAI_FUNC UpVal *luaF_newupval (lua_State *L); +LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); +LUAI_FUNC void luaF_close (lua_State *L, StkId level); +LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); +LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); +LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); +LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, + int pc); + + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lgc.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lgc.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lgc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lgc.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,711 @@ +/* +** $Id: lgc.c,v 2.38.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#include + +#define lgc_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define GCSTEPSIZE 1024u +#define GCSWEEPMAX 40 +#define GCSWEEPCOST 10 +#define GCFINALIZECOST 100 + + +#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) + +#define makewhite(g,x) \ + ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) + +#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) + +#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) + + +#define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) +#define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) + + +#define KEYWEAK bitmask(KEYWEAKBIT) +#define VALUEWEAK bitmask(VALUEWEAKBIT) + + + +#define markvalue(g,o) { checkconsistency(o); \ + if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } + +#define markobject(g,t) { if (iswhite(obj2gco(t))) \ + reallymarkobject(g, obj2gco(t)); } + + +#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) + + +static void removeentry (Node *n) { + lua_assert(ttisnil(gval(n))); + if (iscollectable(gkey(n))) + setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ +} + + +static void reallymarkobject (global_State *g, GCObject *o) { + lua_assert(iswhite(o) && !isdead(g, o)); + white2gray(o); + switch (o->gch.tt) { + case LUA_TSTRING: { + return; + } + case LUA_TUSERDATA: { + Table *mt = gco2u(o)->metatable; + gray2black(o); /* udata are never gray */ + if (mt) markobject(g, mt); + markobject(g, gco2u(o)->env); + return; + } + case LUA_TUPVAL: { + UpVal *uv = gco2uv(o); + markvalue(g, uv->v); + if (uv->v == &uv->u.value) /* closed? */ + gray2black(o); /* open upvalues are never black */ + return; + } + case LUA_TFUNCTION: { + gco2cl(o)->c.gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTABLE: { + gco2h(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TTHREAD: { + gco2th(o)->gclist = g->gray; + g->gray = o; + break; + } + case LUA_TPROTO: { + gco2p(o)->gclist = g->gray; + g->gray = o; + break; + } + default: lua_assert(0); + } +} + + +static void marktmu (global_State *g) { + GCObject *u = g->tmudata; + if (u) { + do { + u = u->gch.next; + makewhite(g, u); /* may be marked, if left from previous GC */ + reallymarkobject(g, u); + } while (u != g->tmudata); + } +} + + +/* move `dead' udata that need finalization to list `tmudata' */ +size_t luaC_separateudata (lua_State *L, int all) { + global_State *g = G(L); + size_t deadmem = 0; + GCObject **p = &g->mainthread->next; + GCObject *curr; + while ((curr = *p) != NULL) { + if (!(iswhite(curr) || all) || isfinalized(gco2u(curr))) + p = &curr->gch.next; /* don't bother with them */ + else if (fasttm(L, gco2u(curr)->metatable, TM_GC) == NULL) { + markfinalized(gco2u(curr)); /* don't need finalization */ + p = &curr->gch.next; + } + else { /* must call its gc method */ + deadmem += sizeudata(gco2u(curr)); + markfinalized(gco2u(curr)); + *p = curr->gch.next; + /* link `curr' at the end of `tmudata' list */ + if (g->tmudata == NULL) /* list is empty? */ + g->tmudata = curr->gch.next = curr; /* creates a circular list */ + else { + curr->gch.next = g->tmudata->gch.next; + g->tmudata->gch.next = curr; + g->tmudata = curr; + } + } + } + return deadmem; +} + + +static int traversetable (global_State *g, Table *h) { + int i; + int weakkey = 0; + int weakvalue = 0; + const TValue *mode; + if (h->metatable) + markobject(g, h->metatable); + mode = gfasttm(g, h->metatable, TM_MODE); + if (mode && ttisstring(mode)) { /* is there a weak mode? */ + weakkey = (strchr(svalue(mode), 'k') != NULL); + weakvalue = (strchr(svalue(mode), 'v') != NULL); + if (weakkey || weakvalue) { /* is really weak? */ + h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ + h->marked |= cast_byte((weakkey << KEYWEAKBIT) | + (weakvalue << VALUEWEAKBIT)); + h->gclist = g->weak; /* must be cleared after GC, ... */ + g->weak = obj2gco(h); /* ... so put in the appropriate list */ + } + } + if (weakkey && weakvalue) return 1; + if (!weakvalue) { + i = h->sizearray; + while (i--) + markvalue(g, &h->array[i]); + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); + if (ttisnil(gval(n))) + removeentry(n); /* remove empty entries */ + else { + lua_assert(!ttisnil(gkey(n))); + if (!weakkey) markvalue(g, gkey(n)); + if (!weakvalue) markvalue(g, gval(n)); + } + } + return weakkey || weakvalue; +} + + +/* +** All marks are conditional because a GC may happen while the +** prototype is still being created +*/ +static void traverseproto (global_State *g, Proto *f) { + int i; + if (f->source) stringmark(f->source); + for (i=0; isizek; i++) /* mark literals */ + markvalue(g, &f->k[i]); + for (i=0; isizeupvalues; i++) { /* mark upvalue names */ + if (f->upvalues[i]) + stringmark(f->upvalues[i]); + } + for (i=0; isizep; i++) { /* mark nested protos */ + if (f->p[i]) + markobject(g, f->p[i]); + } + for (i=0; isizelocvars; i++) { /* mark local-variable names */ + if (f->locvars[i].varname) + stringmark(f->locvars[i].varname); + } +} + + + +static void traverseclosure (global_State *g, Closure *cl) { + markobject(g, cl->c.env); + if (cl->c.isC) { + int i; + for (i=0; ic.nupvalues; i++) /* mark its upvalues */ + markvalue(g, &cl->c.upvalue[i]); + } + else { + int i; + lua_assert(cl->l.nupvalues == cl->l.p->nups); + markobject(g, cl->l.p); + for (i=0; il.nupvalues; i++) /* mark its upvalues */ + markobject(g, cl->l.upvals[i]); + } +} + + +static void checkstacksizes (lua_State *L, StkId max) { + int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ + int s_used = cast_int(max - L->stack); /* part of stack in use */ + if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ + return; /* do not touch the stacks */ + if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) + luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ + condhardstacktests(luaD_reallocCI(L, ci_used + 1)); + if (4*s_used < L->stacksize && + 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) + luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ + condhardstacktests(luaD_reallocstack(L, s_used)); +} + + +static void traversestack (global_State *g, lua_State *l) { + StkId o, lim; + CallInfo *ci; + markvalue(g, gt(l)); + lim = l->top; + for (ci = l->base_ci; ci <= l->ci; ci++) { + lua_assert(ci->top <= l->stack_last); + if (lim < ci->top) lim = ci->top; + } + for (o = l->stack; o < l->top; o++) + markvalue(g, o); + for (; o <= lim; o++) + setnilvalue(o); + checkstacksizes(l, lim); +} + + +/* +** traverse one gray object, turning it to black. +** Returns `quantity' traversed. +*/ +static l_mem propagatemark (global_State *g) { + GCObject *o = g->gray; + lua_assert(isgray(o)); + gray2black(o); + switch (o->gch.tt) { + case LUA_TTABLE: { + Table *h = gco2h(o); + g->gray = h->gclist; + if (traversetable(g, h)) /* table is weak? */ + black2gray(o); /* keep it gray */ + return sizeof(Table) + sizeof(TValue) * h->sizearray + + sizeof(Node) * sizenode(h); + } + case LUA_TFUNCTION: { + Closure *cl = gco2cl(o); + g->gray = cl->c.gclist; + traverseclosure(g, cl); + return (cl->c.isC) ? sizeCclosure(cl->c.nupvalues) : + sizeLclosure(cl->l.nupvalues); + } + case LUA_TTHREAD: { + lua_State *th = gco2th(o); + g->gray = th->gclist; + th->gclist = g->grayagain; + g->grayagain = o; + black2gray(o); + traversestack(g, th); + return sizeof(lua_State) + sizeof(TValue) * th->stacksize + + sizeof(CallInfo) * th->size_ci; + } + case LUA_TPROTO: { + Proto *p = gco2p(o); + g->gray = p->gclist; + traverseproto(g, p); + return sizeof(Proto) + sizeof(Instruction) * p->sizecode + + sizeof(Proto *) * p->sizep + + sizeof(TValue) * p->sizek + + sizeof(int) * p->sizelineinfo + + sizeof(LocVar) * p->sizelocvars + + sizeof(TString *) * p->sizeupvalues; + } + default: lua_assert(0); return 0; + } +} + + +static size_t propagateall (global_State *g) { + size_t m = 0; + while (g->gray) m += propagatemark(g); + return m; +} + + +/* +** The next function tells whether a key or value can be cleared from +** a weak table. Non-collectable objects are never removed from weak +** tables. Strings behave as `values', so are never removed too. for +** other objects: if really collected, cannot keep them; for userdata +** being finalized, keep them in keys, but not in values +*/ +static int iscleared (const TValue *o, int iskey) { + if (!iscollectable(o)) return 0; + if (ttisstring(o)) { + stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ + return 0; + } + return iswhite(gcvalue(o)) || + (ttisuserdata(o) && (!iskey && isfinalized(uvalue(o)))); +} + + +/* +** clear collected entries from weaktables +*/ +static void cleartable (GCObject *l) { + while (l) { + Table *h = gco2h(l); + int i = h->sizearray; + lua_assert(testbit(h->marked, VALUEWEAKBIT) || + testbit(h->marked, KEYWEAKBIT)); + if (testbit(h->marked, VALUEWEAKBIT)) { + while (i--) { + TValue *o = &h->array[i]; + if (iscleared(o, 0)) /* value was collected? */ + setnilvalue(o); /* remove value */ + } + } + i = sizenode(h); + while (i--) { + Node *n = gnode(h, i); + if (!ttisnil(gval(n)) && /* non-empty entry? */ + (iscleared(key2tval(n), 1) || iscleared(gval(n), 0))) { + setnilvalue(gval(n)); /* remove value ... */ + removeentry(n); /* remove entry from table */ + } + } + l = h->gclist; + } +} + + +static void freeobj (lua_State *L, GCObject *o) { + switch (o->gch.tt) { + case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; + case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; + case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; + case LUA_TTABLE: luaH_free(L, gco2h(o)); break; + case LUA_TTHREAD: { + lua_assert(gco2th(o) != L && gco2th(o) != G(L)->mainthread); + luaE_freethread(L, gco2th(o)); + break; + } + case LUA_TSTRING: { + G(L)->strt.nuse--; + luaM_freemem(L, o, sizestring(gco2ts(o))); + break; + } + case LUA_TUSERDATA: { + luaM_freemem(L, o, sizeudata(gco2u(o))); + break; + } + default: lua_assert(0); + } +} + + + +#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) + + +static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { + GCObject *curr; + global_State *g = G(L); + int deadmask = otherwhite(g); + while ((curr = *p) != NULL && count-- > 0) { + if (curr->gch.tt == LUA_TTHREAD) /* sweep open upvalues of each thread */ + sweepwholelist(L, &gco2th(curr)->openupval); + if ((curr->gch.marked ^ WHITEBITS) & deadmask) { /* not dead? */ + lua_assert(!isdead(g, curr) || testbit(curr->gch.marked, FIXEDBIT)); + makewhite(g, curr); /* make it white (for next cycle) */ + p = &curr->gch.next; + } + else { /* must erase `curr' */ + lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); + *p = curr->gch.next; + if (curr == g->rootgc) /* is the first element of the list? */ + g->rootgc = curr->gch.next; /* adjust first */ + freeobj(L, curr); + } + } + return p; +} + + +static void checkSizes (lua_State *L) { + global_State *g = G(L); + /* check size of string hash */ + if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && + g->strt.size > MINSTRTABSIZE*2) + luaS_resize(L, g->strt.size/2); /* table is too big */ + /* check size of buffer */ + if (luaZ_sizebuffer(&g->buff) > LUA_MINBUFFER*2) { /* buffer too big? */ + size_t newsize = luaZ_sizebuffer(&g->buff) / 2; + luaZ_resizebuffer(L, &g->buff, newsize); + } +} + + +static void GCTM (lua_State *L) { + global_State *g = G(L); + GCObject *o = g->tmudata->gch.next; /* get first element */ + Udata *udata = rawgco2u(o); + const TValue *tm; + /* remove udata from `tmudata' */ + if (o == g->tmudata) /* last element? */ + g->tmudata = NULL; + else + g->tmudata->gch.next = udata->uv.next; + udata->uv.next = g->mainthread->next; /* return it to `root' list */ + g->mainthread->next = o; + makewhite(g, o); + tm = fasttm(L, udata->uv.metatable, TM_GC); + if (tm != NULL) { + lu_byte oldah = L->allowhook; + lu_mem oldt = g->GCthreshold; + L->allowhook = 0; /* stop debug hooks during GC tag method */ + g->GCthreshold = 2*g->totalbytes; /* avoid GC steps */ + setobj2s(L, L->top, tm); + setuvalue(L, L->top+1, udata); + L->top += 2; + luaD_call(L, L->top - 2, 0); + L->allowhook = oldah; /* restore hooks */ + g->GCthreshold = oldt; /* restore threshold */ + } +} + + +/* +** Call all GC tag methods +*/ +void luaC_callGCTM (lua_State *L) { + while (G(L)->tmudata) + GCTM(L); +} + + +void luaC_freeall (lua_State *L) { + global_State *g = G(L); + int i; + g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ + sweepwholelist(L, &g->rootgc); + for (i = 0; i < g->strt.size; i++) /* free all string lists */ + sweepwholelist(L, &g->strt.hash[i]); +} + + +static void markmt (global_State *g) { + int i; + for (i=0; imt[i]) markobject(g, g->mt[i]); +} + + +/* mark root set */ +static void markroot (lua_State *L) { + global_State *g = G(L); + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + markobject(g, g->mainthread); + /* make global table be traversed before main stack */ + markvalue(g, gt(g->mainthread)); + markvalue(g, registry(L)); + markmt(g); + g->gcstate = GCSpropagate; +} + + +static void remarkupvals (global_State *g) { + UpVal *uv; + for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + if (isgray(obj2gco(uv))) + markvalue(g, uv->v); + } +} + + +static void atomic (lua_State *L) { + global_State *g = G(L); + size_t udsize; /* total size of userdata to be finalized */ + /* remark occasional upvalues of (maybe) dead threads */ + remarkupvals(g); + /* traverse objects cautch by write barrier and by 'remarkupvals' */ + propagateall(g); + /* remark weak tables */ + g->gray = g->weak; + g->weak = NULL; + lua_assert(!iswhite(obj2gco(g->mainthread))); + markobject(g, L); /* mark running thread */ + markmt(g); /* mark basic metatables (again) */ + propagateall(g); + /* remark gray again */ + g->gray = g->grayagain; + g->grayagain = NULL; + propagateall(g); + udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */ + marktmu(g); /* mark `preserved' userdata */ + udsize += propagateall(g); /* remark, to propagate `preserveness' */ + cleartable(g->weak); /* remove collected objects from weak tables */ + /* flip current white */ + g->currentwhite = cast_byte(otherwhite(g)); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gcstate = GCSsweepstring; + g->estimate = g->totalbytes - udsize; /* first estimate */ +} + + +static l_mem singlestep (lua_State *L) { + global_State *g = G(L); + /*lua_checkmemory(L);*/ + switch (g->gcstate) { + case GCSpause: { + markroot(L); /* start a new collection */ + return 0; + } + case GCSpropagate: { + if (g->gray) + return propagatemark(g); + else { /* no more `gray' objects */ + atomic(L); /* finish mark phase */ + return 0; + } + } + case GCSsweepstring: { + lu_mem old = g->totalbytes; + sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); + if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ + g->gcstate = GCSsweep; /* end sweep-string phase */ + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPCOST; + } + case GCSsweep: { + lu_mem old = g->totalbytes; + g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); + if (*g->sweepgc == NULL) { /* nothing more to sweep? */ + checkSizes(L); + g->gcstate = GCSfinalize; /* end sweep phase */ + } + lua_assert(old >= g->totalbytes); + g->estimate -= old - g->totalbytes; + return GCSWEEPMAX*GCSWEEPCOST; + } + case GCSfinalize: { + if (g->tmudata) { + GCTM(L); + if (g->estimate > GCFINALIZECOST) + g->estimate -= GCFINALIZECOST; + return GCFINALIZECOST; + } + else { + g->gcstate = GCSpause; /* end collection */ + g->gcdept = 0; + return 0; + } + } + default: lua_assert(0); return 0; + } +} + + +void luaC_step (lua_State *L) { + global_State *g = G(L); + l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul; + if (lim == 0) + lim = (MAX_LUMEM-1)/2; /* no limit */ + g->gcdept += g->totalbytes - g->GCthreshold; + do { + lim -= singlestep(L); + if (g->gcstate == GCSpause) + break; + } while (lim > 0); + if (g->gcstate != GCSpause) { + if (g->gcdept < GCSTEPSIZE) + g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/ + else { + g->gcdept -= GCSTEPSIZE; + g->GCthreshold = g->totalbytes; + } + } + else { + lua_assert(g->totalbytes >= g->estimate); + setthreshold(g); + } +} + + +void luaC_fullgc (lua_State *L) { + global_State *g = G(L); + if (g->gcstate <= GCSpropagate) { + /* reset sweep marks to sweep all elements (returning them to white) */ + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + /* reset other collector lists */ + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->gcstate = GCSsweepstring; + } + lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate); + /* finish any pending sweep phase */ + while (g->gcstate != GCSfinalize) { + lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep); + singlestep(L); + } + markroot(L); + while (g->gcstate != GCSpause) { + singlestep(L); + } + setthreshold(g); +} + + +void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { + global_State *g = G(L); + lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + lua_assert(ttype(&o->gch) != LUA_TTABLE); + /* must keep invariant? */ + if (g->gcstate == GCSpropagate) + reallymarkobject(g, v); /* restore invariant */ + else /* don't mind */ + makewhite(g, o); /* mark as white just to avoid other barriers */ +} + + +void luaC_barrierback (lua_State *L, Table *t) { + global_State *g = G(L); + GCObject *o = obj2gco(t); + lua_assert(isblack(o) && !isdead(g, o)); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + black2gray(o); /* make table gray (again) */ + t->gclist = g->grayagain; + g->grayagain = o; +} + + +void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { + global_State *g = G(L); + o->gch.next = g->rootgc; + g->rootgc = o; + o->gch.marked = luaC_white(g); + o->gch.tt = tt; +} + + +void luaC_linkupval (lua_State *L, UpVal *uv) { + global_State *g = G(L); + GCObject *o = obj2gco(uv); + o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ + g->rootgc = o; + if (isgray(o)) { + if (g->gcstate == GCSpropagate) { + gray2black(o); /* closed upvalues need barrier */ + luaC_barrier(L, uv, uv->v); + } + else { /* sweep phase: sweep it (turning it into white) */ + makewhite(g, o); + lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); + } + } +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lgc.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lgc.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lgc.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lgc.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,110 @@ +/* +** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $ +** Garbage Collector +** See Copyright Notice in lua.h +*/ + +#ifndef lgc_h +#define lgc_h + + +#include "lobject.h" + + +/* +** Possible states of the Garbage Collector +*/ +#define GCSpause 0 +#define GCSpropagate 1 +#define GCSsweepstring 2 +#define GCSsweep 3 +#define GCSfinalize 4 + + +/* +** some userful bit tricks +*/ +#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m))) +#define setbits(x,m) ((x) |= (m)) +#define testbits(x,m) ((x) & (m)) +#define bitmask(b) (1<<(b)) +#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2)) +#define l_setbit(x,b) setbits(x, bitmask(b)) +#define resetbit(x,b) resetbits(x, bitmask(b)) +#define testbit(x,b) testbits(x, bitmask(b)) +#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2))) +#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2))) +#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2))) + + + +/* +** Layout for bit use in `marked' field: +** bit 0 - object is white (type 0) +** bit 1 - object is white (type 1) +** bit 2 - object is black +** bit 3 - for userdata: has been finalized +** bit 3 - for tables: has weak keys +** bit 4 - for tables: has weak values +** bit 5 - object is fixed (should not be collected) +** bit 6 - object is "super" fixed (only the main thread) +*/ + + +#define WHITE0BIT 0 +#define WHITE1BIT 1 +#define BLACKBIT 2 +#define FINALIZEDBIT 3 +#define KEYWEAKBIT 3 +#define VALUEWEAKBIT 4 +#define FIXEDBIT 5 +#define SFIXEDBIT 6 +#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) + + +#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) +#define isblack(x) testbit((x)->gch.marked, BLACKBIT) +#define isgray(x) (!isblack(x) && !iswhite(x)) + +#define otherwhite(g) (g->currentwhite ^ WHITEBITS) +#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) + +#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) +#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) + +#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) + +#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) + + +#define luaC_checkGC(L) { \ + condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \ + if (G(L)->totalbytes >= G(L)->GCthreshold) \ + luaC_step(L); } + + +#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),gcvalue(v)); } + +#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \ + luaC_barrierback(L,t); } + +#define luaC_objbarrier(L,p,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ + luaC_barrierf(L,obj2gco(p),obj2gco(o)); } + +#define luaC_objbarriert(L,t,o) \ + { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); } + +LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all); +LUAI_FUNC void luaC_callGCTM (lua_State *L); +LUAI_FUNC void luaC_freeall (lua_State *L); +LUAI_FUNC void luaC_step (lua_State *L); +LUAI_FUNC void luaC_fullgc (lua_State *L); +LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt); +LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); +LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); +LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); + + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/linit.c.svn-base blobby-0.9c/src/lua/.svn/text-base/linit.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/linit.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/linit.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,38 @@ +/* +** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ +** Initialization of libraries for lua.c +** See Copyright Notice in lua.h +*/ + + +#define linit_c +#define LUA_LIB + +#include "lua.h" + +#include "lualib.h" +#include "lauxlib.h" + + +static const luaL_Reg lualibs[] = { + {"", luaopen_base}, + {LUA_LOADLIBNAME, luaopen_package}, + {LUA_TABLIBNAME, luaopen_table}, + {LUA_IOLIBNAME, luaopen_io}, + {LUA_OSLIBNAME, luaopen_os}, + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, + {LUA_DBLIBNAME, luaopen_debug}, + {NULL, NULL} +}; + + +LUALIB_API void luaL_openlibs (lua_State *L) { + const luaL_Reg *lib = lualibs; + for (; lib->func; lib++) { + lua_pushcfunction(L, lib->func); + lua_pushstring(L, lib->name); + lua_call(L, 1, 0); + } +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/liolib.c.svn-base blobby-0.9c/src/lua/.svn/text-base/liolib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/liolib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/liolib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,553 @@ +/* +** $Id: liolib.c,v 2.73.1.3 2008/01/18 17:47:43 roberto Exp $ +** Standard I/O (and system) library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include + +#define liolib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + + +#define IO_INPUT 1 +#define IO_OUTPUT 2 + + +static const char *const fnames[] = {"input", "output"}; + + +static int pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + if (filename) + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + else + lua_pushfstring(L, "%s", strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static void fileerror (lua_State *L, int arg, const char *filename) { + lua_pushfstring(L, "%s: %s", filename, strerror(errno)); + luaL_argerror(L, arg, lua_tostring(L, -1)); +} + + +#define tofilep(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE)) + + +static int io_type (lua_State *L) { + void *ud; + luaL_checkany(L, 1); + ud = lua_touserdata(L, 1); + lua_getfield(L, LUA_REGISTRYINDEX, LUA_FILEHANDLE); + if (ud == NULL || !lua_getmetatable(L, 1) || !lua_rawequal(L, -2, -1)) + lua_pushnil(L); /* not a file */ + else if (*((FILE **)ud) == NULL) + lua_pushliteral(L, "closed file"); + else + lua_pushliteral(L, "file"); + return 1; +} + + +static FILE *tofile (lua_State *L) { + FILE **f = tofilep(L); + if (*f == NULL) + luaL_error(L, "attempt to use a closed file"); + return *f; +} + + + +/* +** When creating file handles, always creates a `closed' file handle +** before opening the actual file; so, if there is a memory error, the +** file is not left opened. +*/ +static FILE **newfile (lua_State *L) { + FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *)); + *pf = NULL; /* file handle is currently `closed' */ + luaL_getmetatable(L, LUA_FILEHANDLE); + lua_setmetatable(L, -2); + return pf; +} + + +/* +** function to (not) close the standard files stdin, stdout, and stderr +*/ +static int io_noclose (lua_State *L) { + lua_pushnil(L); + lua_pushliteral(L, "cannot close standard file"); + return 2; +} + + +/* +** function to close 'popen' files +*/ +static int io_pclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = lua_pclose(L, *p); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +/* +** function to close regular files +*/ +static int io_fclose (lua_State *L) { + FILE **p = tofilep(L); + int ok = (fclose(*p) == 0); + *p = NULL; + return pushresult(L, ok, NULL); +} + + +static int aux_close (lua_State *L) { + lua_getfenv(L, 1); + lua_getfield(L, -1, "__close"); + return (lua_tocfunction(L, -1))(L); +} + + +static int io_close (lua_State *L) { + if (lua_isnone(L, 1)) + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_OUTPUT); + tofile(L); /* make sure argument is a file */ + return aux_close(L); +} + + +static int io_gc (lua_State *L) { + FILE *f = *tofilep(L); + /* ignore closed files */ + if (f != NULL) + aux_close(L); + return 0; +} + + +static int io_tostring (lua_State *L) { + FILE *f = *tofilep(L); + if (f == NULL) + lua_pushliteral(L, "file (closed)"); + else + lua_pushfstring(L, "file (%p)", f); + return 1; +} + + +static int io_open (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +/* +** this function has a separated environment, which defines the +** correct __close for 'popen' files +*/ +static int io_popen (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + const char *mode = luaL_optstring(L, 2, "r"); + FILE **pf = newfile(L); + *pf = lua_popen(L, filename, mode); + return (*pf == NULL) ? pushresult(L, 0, filename) : 1; +} + + +static int io_tmpfile (lua_State *L) { + FILE **pf = newfile(L); + *pf = tmpfile(); + return (*pf == NULL) ? pushresult(L, 0, NULL) : 1; +} + + +static FILE *getiofile (lua_State *L, int findex) { + FILE *f; + lua_rawgeti(L, LUA_ENVIRONINDEX, findex); + f = *(FILE **)lua_touserdata(L, -1); + if (f == NULL) + luaL_error(L, "standard %s file is closed", fnames[findex - 1]); + return f; +} + + +static int g_iofile (lua_State *L, int f, const char *mode) { + if (!lua_isnoneornil(L, 1)) { + const char *filename = lua_tostring(L, 1); + if (filename) { + FILE **pf = newfile(L); + *pf = fopen(filename, mode); + if (*pf == NULL) + fileerror(L, 1, filename); + } + else { + tofile(L); /* check that it's a valid file handle */ + lua_pushvalue(L, 1); + } + lua_rawseti(L, LUA_ENVIRONINDEX, f); + } + /* return current value */ + lua_rawgeti(L, LUA_ENVIRONINDEX, f); + return 1; +} + + +static int io_input (lua_State *L) { + return g_iofile(L, IO_INPUT, "r"); +} + + +static int io_output (lua_State *L) { + return g_iofile(L, IO_OUTPUT, "w"); +} + + +static int io_readline (lua_State *L); + + +static void aux_lines (lua_State *L, int idx, int toclose) { + lua_pushvalue(L, idx); + lua_pushboolean(L, toclose); /* close/not close file when finished */ + lua_pushcclosure(L, io_readline, 2); +} + + +static int f_lines (lua_State *L) { + tofile(L); /* check that it's a valid file handle */ + aux_lines(L, 1, 0); + return 1; +} + + +static int io_lines (lua_State *L) { + if (lua_isnoneornil(L, 1)) { /* no arguments? */ + /* will iterate over default input */ + lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT); + return f_lines(L); + } + else { + const char *filename = luaL_checkstring(L, 1); + FILE **pf = newfile(L); + *pf = fopen(filename, "r"); + if (*pf == NULL) + fileerror(L, 1, filename); + aux_lines(L, lua_gettop(L), 1); + return 1; + } +} + + +/* +** {====================================================== +** READ +** ======================================================= +*/ + + +static int read_number (lua_State *L, FILE *f) { + lua_Number d; + if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) { + lua_pushnumber(L, d); + return 1; + } + else return 0; /* read fails */ +} + + +static int test_eof (lua_State *L, FILE *f) { + int c = getc(f); + ungetc(c, f); + lua_pushlstring(L, NULL, 0); + return (c != EOF); +} + + +static int read_line (lua_State *L, FILE *f) { + luaL_Buffer b; + luaL_buffinit(L, &b); + for (;;) { + size_t l; + char *p = luaL_prepbuffer(&b); + if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { /* eof? */ + luaL_pushresult(&b); /* close buffer */ + return (lua_objlen(L, -1) > 0); /* check whether read something */ + } + l = strlen(p); + if (l == 0 || p[l-1] != '\n') + luaL_addsize(&b, l); + else { + luaL_addsize(&b, l - 1); /* do not include `eol' */ + luaL_pushresult(&b); /* close buffer */ + return 1; /* read at least an `eol' */ + } + } +} + + +static int read_chars (lua_State *L, FILE *f, size_t n) { + size_t rlen; /* how much to read */ + size_t nr; /* number of chars actually read */ + luaL_Buffer b; + luaL_buffinit(L, &b); + rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ + do { + char *p = luaL_prepbuffer(&b); + if (rlen > n) rlen = n; /* cannot read more than asked */ + nr = fread(p, sizeof(char), rlen, f); + luaL_addsize(&b, nr); + n -= nr; /* still have to read `n' chars */ + } while (n > 0 && nr == rlen); /* until end of count or eof */ + luaL_pushresult(&b); /* close buffer */ + return (n == 0 || lua_objlen(L, -1) > 0); +} + + +static int g_read (lua_State *L, FILE *f, int first) { + int nargs = lua_gettop(L) - 1; + int success; + int n; + clearerr(f); + if (nargs == 0) { /* no arguments? */ + success = read_line(L, f); + n = first+1; /* to return 1 result */ + } + else { /* ensure stack space for all results and for auxlib's buffer */ + luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); + success = 1; + for (n = first; nargs-- && success; n++) { + if (lua_type(L, n) == LUA_TNUMBER) { + size_t l = (size_t)lua_tointeger(L, n); + success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); + } + else { + const char *p = lua_tostring(L, n); + luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); + switch (p[1]) { + case 'n': /* number */ + success = read_number(L, f); + break; + case 'l': /* line */ + success = read_line(L, f); + break; + case 'a': /* file */ + read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ + success = 1; /* always success */ + break; + default: + return luaL_argerror(L, n, "invalid format"); + } + } + } + } + if (ferror(f)) + return pushresult(L, 0, NULL); + if (!success) { + lua_pop(L, 1); /* remove last result */ + lua_pushnil(L); /* push nil instead */ + } + return n - first; +} + + +static int io_read (lua_State *L) { + return g_read(L, getiofile(L, IO_INPUT), 1); +} + + +static int f_read (lua_State *L) { + return g_read(L, tofile(L), 2); +} + + +static int io_readline (lua_State *L) { + FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); + int sucess; + if (f == NULL) /* file is already closed? */ + luaL_error(L, "file is already closed"); + sucess = read_line(L, f); + if (ferror(f)) + return luaL_error(L, "%s", strerror(errno)); + if (sucess) return 1; + else { /* EOF */ + if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ + lua_settop(L, 0); + lua_pushvalue(L, lua_upvalueindex(1)); + aux_close(L); /* close it */ + } + return 0; + } +} + +/* }====================================================== */ + + +static int g_write (lua_State *L, FILE *f, int arg) { + int nargs = lua_gettop(L) - 1; + int status = 1; + for (; nargs--; arg++) { + if (lua_type(L, arg) == LUA_TNUMBER) { + /* optimization: could be done exactly as for strings */ + status = status && + fprintf(f, LUA_NUMBER_FMT, lua_tonumber(L, arg)) > 0; + } + else { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + status = status && (fwrite(s, sizeof(char), l, f) == l); + } + } + return pushresult(L, status, NULL); +} + + +static int io_write (lua_State *L) { + return g_write(L, getiofile(L, IO_OUTPUT), 1); +} + + +static int f_write (lua_State *L) { + return g_write(L, tofile(L), 2); +} + + +static int f_seek (lua_State *L) { + static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; + static const char *const modenames[] = {"set", "cur", "end", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, "cur", modenames); + long offset = luaL_optlong(L, 3, 0); + op = fseek(f, offset, mode[op]); + if (op) + return pushresult(L, 0, NULL); /* error */ + else { + lua_pushinteger(L, ftell(f)); + return 1; + } +} + + +static int f_setvbuf (lua_State *L) { + static const int mode[] = {_IONBF, _IOFBF, _IOLBF}; + static const char *const modenames[] = {"no", "full", "line", NULL}; + FILE *f = tofile(L); + int op = luaL_checkoption(L, 2, NULL, modenames); + lua_Integer sz = luaL_optinteger(L, 3, LUAL_BUFFERSIZE); + int res = setvbuf(f, NULL, mode[op], sz); + return pushresult(L, res == 0, NULL); +} + + + +static int io_flush (lua_State *L) { + return pushresult(L, fflush(getiofile(L, IO_OUTPUT)) == 0, NULL); +} + + +static int f_flush (lua_State *L) { + return pushresult(L, fflush(tofile(L)) == 0, NULL); +} + + +static const luaL_Reg iolib[] = { + {"close", io_close}, + {"flush", io_flush}, + {"input", io_input}, + {"lines", io_lines}, + {"open", io_open}, + {"output", io_output}, + {"popen", io_popen}, + {"read", io_read}, + {"tmpfile", io_tmpfile}, + {"type", io_type}, + {"write", io_write}, + {NULL, NULL} +}; + + +static const luaL_Reg flib[] = { + {"close", io_close}, + {"flush", f_flush}, + {"lines", f_lines}, + {"read", f_read}, + {"seek", f_seek}, + {"setvbuf", f_setvbuf}, + {"write", f_write}, + {"__gc", io_gc}, + {"__tostring", io_tostring}, + {NULL, NULL} +}; + + +static void createmeta (lua_State *L) { + luaL_newmetatable(L, LUA_FILEHANDLE); /* create metatable for file handles */ + lua_pushvalue(L, -1); /* push metatable */ + lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ + luaL_register(L, NULL, flib); /* file methods */ +} + + +static void createstdfile (lua_State *L, FILE *f, int k, const char *fname) { + *newfile(L) = f; + if (k > 0) { + lua_pushvalue(L, -1); + lua_rawseti(L, LUA_ENVIRONINDEX, k); + } + lua_pushvalue(L, -2); /* copy environment */ + lua_setfenv(L, -2); /* set it */ + lua_setfield(L, -3, fname); +} + + +static void newfenv (lua_State *L, lua_CFunction cls) { + lua_createtable(L, 0, 1); + lua_pushcfunction(L, cls); + lua_setfield(L, -2, "__close"); +} + + +LUALIB_API int luaopen_io (lua_State *L) { + createmeta(L); + /* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */ + newfenv(L, io_fclose); + lua_replace(L, LUA_ENVIRONINDEX); + /* open library */ + luaL_register(L, LUA_IOLIBNAME, iolib); + /* create (and set) default files */ + newfenv(L, io_noclose); /* close function for default files */ + createstdfile(L, stdin, IO_INPUT, "stdin"); + createstdfile(L, stdout, IO_OUTPUT, "stdout"); + createstdfile(L, stderr, 0, "stderr"); + lua_pop(L, 1); /* pop environment for default files */ + lua_getfield(L, -1, "popen"); + newfenv(L, io_pclose); /* create environment for 'popen' */ + lua_setfenv(L, -2); /* set fenv for 'popen' */ + lua_pop(L, 1); /* pop 'popen' */ + return 1; +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/llex.c.svn-base blobby-0.9c/src/lua/.svn/text-base/llex.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/llex.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/llex.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,461 @@ +/* +** $Id: llex.c,v 2.20.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define llex_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "llex.h" +#include "lobject.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "lzio.h" + + + +#define next(ls) (ls->current = zgetc(ls->z)) + + + + +#define currIsNewline(ls) (ls->current == '\n' || ls->current == '\r') + + +/* ORDER RESERVED */ +const char *const luaX_tokens [] = { + "and", "break", "do", "else", "elseif", + "end", "false", "for", "function", "if", + "in", "local", "nil", "not", "or", "repeat", + "return", "then", "true", "until", "while", + "..", "...", "==", ">=", "<=", "~=", + "", "", "", "", + NULL +}; + + +#define save_and_next(ls) (save(ls, ls->current), next(ls)) + + +static void save (LexState *ls, int c) { + Mbuffer *b = ls->buff; + if (b->n + 1 > b->buffsize) { + size_t newsize; + if (b->buffsize >= MAX_SIZET/2) + luaX_lexerror(ls, "lexical element too long", 0); + newsize = b->buffsize * 2; + luaZ_resizebuffer(ls->L, b, newsize); + } + b->buffer[b->n++] = cast(char, c); +} + + +void luaX_init (lua_State *L) { + int i; + for (i=0; itsv.reserved = cast_byte(i+1); /* reserved word */ + } +} + + +#define MAXSRC 80 + + +const char *luaX_token2str (LexState *ls, int token) { + if (token < FIRST_RESERVED) { + lua_assert(token == cast(unsigned char, token)); + return (iscntrl(token)) ? luaO_pushfstring(ls->L, "char(%d)", token) : + luaO_pushfstring(ls->L, "%c", token); + } + else + return luaX_tokens[token-FIRST_RESERVED]; +} + + +static const char *txtToken (LexState *ls, int token) { + switch (token) { + case TK_NAME: + case TK_STRING: + case TK_NUMBER: + save(ls, '\0'); + return luaZ_buffer(ls->buff); + default: + return luaX_token2str(ls, token); + } +} + + +void luaX_lexerror (LexState *ls, const char *msg, int token) { + char buff[MAXSRC]; + luaO_chunkid(buff, getstr(ls->source), MAXSRC); + msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); + if (token) + luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token)); + luaD_throw(ls->L, LUA_ERRSYNTAX); +} + + +void luaX_syntaxerror (LexState *ls, const char *msg) { + luaX_lexerror(ls, msg, ls->t.token); +} + + +TString *luaX_newstring (LexState *ls, const char *str, size_t l) { + lua_State *L = ls->L; + TString *ts = luaS_newlstr(L, str, l); + TValue *o = luaH_setstr(L, ls->fs->h, ts); /* entry for `str' */ + if (ttisnil(o)) + setbvalue(o, 1); /* make sure `str' will not be collected */ + return ts; +} + + +static void inclinenumber (LexState *ls) { + int old = ls->current; + lua_assert(currIsNewline(ls)); + next(ls); /* skip `\n' or `\r' */ + if (currIsNewline(ls) && ls->current != old) + next(ls); /* skip `\n\r' or `\r\n' */ + if (++ls->linenumber >= MAX_INT) + luaX_syntaxerror(ls, "chunk has too many lines"); +} + + +void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { + ls->decpoint = '.'; + ls->L = L; + ls->lookahead.token = TK_EOS; /* no look-ahead token */ + ls->z = z; + ls->fs = NULL; + ls->linenumber = 1; + ls->lastline = 1; + ls->source = source; + luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ + next(ls); /* read first char */ +} + + + +/* +** ======================================================= +** LEXICAL ANALYZER +** ======================================================= +*/ + + + +static int check_next (LexState *ls, const char *set) { + if (!strchr(set, ls->current)) + return 0; + save_and_next(ls); + return 1; +} + + +static void buffreplace (LexState *ls, char from, char to) { + size_t n = luaZ_bufflen(ls->buff); + char *p = luaZ_buffer(ls->buff); + while (n--) + if (p[n] == from) p[n] = to; +} + + +static void trydecpoint (LexState *ls, SemInfo *seminfo) { + /* format error: try to update decimal point separator */ + struct lconv *cv = localeconv(); + char old = ls->decpoint; + ls->decpoint = (cv ? cv->decimal_point[0] : '.'); + buffreplace(ls, old, ls->decpoint); /* try updated decimal separator */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) { + /* format error with correct decimal point: no more options */ + buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */ + luaX_lexerror(ls, "malformed number", TK_NUMBER); + } +} + + +/* LUA_NUMBER */ +static void read_numeral (LexState *ls, SemInfo *seminfo) { + lua_assert(isdigit(ls->current)); + do { + save_and_next(ls); + } while (isdigit(ls->current) || ls->current == '.'); + if (check_next(ls, "Ee")) /* `E'? */ + check_next(ls, "+-"); /* optional exponent sign */ + while (isalnum(ls->current) || ls->current == '_') + save_and_next(ls); + save(ls, '\0'); + buffreplace(ls, '.', ls->decpoint); /* follow locale for decimal point */ + if (!luaO_str2d(luaZ_buffer(ls->buff), &seminfo->r)) /* format error? */ + trydecpoint(ls, seminfo); /* try to update decimal point separator */ +} + + +static int skip_sep (LexState *ls) { + int count = 0; + int s = ls->current; + lua_assert(s == '[' || s == ']'); + save_and_next(ls); + while (ls->current == '=') { + save_and_next(ls); + count++; + } + return (ls->current == s) ? count : (-count) - 1; +} + + +static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { + int cont = 0; + (void)(cont); /* avoid warnings when `cont' is not used */ + save_and_next(ls); /* skip 2nd `[' */ + if (currIsNewline(ls)) /* string starts with a newline? */ + inclinenumber(ls); /* skip it */ + for (;;) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, (seminfo) ? "unfinished long string" : + "unfinished long comment", TK_EOS); + break; /* to avoid warnings */ +#if defined(LUA_COMPAT_LSTR) + case '[': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `[' */ + cont++; +#if LUA_COMPAT_LSTR == 1 + if (sep == 0) + luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); +#endif + } + break; + } +#endif + case ']': { + if (skip_sep(ls) == sep) { + save_and_next(ls); /* skip 2nd `]' */ +#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 + cont--; + if (sep == 0 && cont >= 0) break; +#endif + goto endloop; + } + break; + } + case '\n': + case '\r': { + save(ls, '\n'); + inclinenumber(ls); + if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ + break; + } + default: { + if (seminfo) save_and_next(ls); + else next(ls); + } + } + } endloop: + if (seminfo) + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), + luaZ_bufflen(ls->buff) - 2*(2 + sep)); +} + + +static void read_string (LexState *ls, int del, SemInfo *seminfo) { + save_and_next(ls); + while (ls->current != del) { + switch (ls->current) { + case EOZ: + luaX_lexerror(ls, "unfinished string", TK_EOS); + continue; /* to avoid warnings */ + case '\n': + case '\r': + luaX_lexerror(ls, "unfinished string", TK_STRING); + continue; /* to avoid warnings */ + case '\\': { + int c; + next(ls); /* do not save the `\' */ + switch (ls->current) { + case 'a': c = '\a'; break; + case 'b': c = '\b'; break; + case 'f': c = '\f'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 't': c = '\t'; break; + case 'v': c = '\v'; break; + case '\n': /* go through */ + case '\r': save(ls, '\n'); inclinenumber(ls); continue; + case EOZ: continue; /* will raise an error next loop */ + default: { + if (!isdigit(ls->current)) + save_and_next(ls); /* handles \\, \", \', and \? */ + else { /* \xxx */ + int i = 0; + c = 0; + do { + c = 10*c + (ls->current-'0'); + next(ls); + } while (++i<3 && isdigit(ls->current)); + if (c > UCHAR_MAX) + luaX_lexerror(ls, "escape sequence too large", TK_STRING); + save(ls, c); + } + continue; + } + } + save(ls, c); + next(ls); + continue; + } + default: + save_and_next(ls); + } + } + save_and_next(ls); /* skip delimiter */ + seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, + luaZ_bufflen(ls->buff) - 2); +} + + +static int llex (LexState *ls, SemInfo *seminfo) { + luaZ_resetbuffer(ls->buff); + for (;;) { + switch (ls->current) { + case '\n': + case '\r': { + inclinenumber(ls); + continue; + } + case '-': { + next(ls); + if (ls->current != '-') return '-'; + /* else is a comment */ + next(ls); + if (ls->current == '[') { + int sep = skip_sep(ls); + luaZ_resetbuffer(ls->buff); /* `skip_sep' may dirty the buffer */ + if (sep >= 0) { + read_long_string(ls, NULL, sep); /* long comment */ + luaZ_resetbuffer(ls->buff); + continue; + } + } + /* else short comment */ + while (!currIsNewline(ls) && ls->current != EOZ) + next(ls); + continue; + } + case '[': { + int sep = skip_sep(ls); + if (sep >= 0) { + read_long_string(ls, seminfo, sep); + return TK_STRING; + } + else if (sep == -1) return '['; + else luaX_lexerror(ls, "invalid long string delimiter", TK_STRING); + } + case '=': { + next(ls); + if (ls->current != '=') return '='; + else { next(ls); return TK_EQ; } + } + case '<': { + next(ls); + if (ls->current != '=') return '<'; + else { next(ls); return TK_LE; } + } + case '>': { + next(ls); + if (ls->current != '=') return '>'; + else { next(ls); return TK_GE; } + } + case '~': { + next(ls); + if (ls->current != '=') return '~'; + else { next(ls); return TK_NE; } + } + case '"': + case '\'': { + read_string(ls, ls->current, seminfo); + return TK_STRING; + } + case '.': { + save_and_next(ls); + if (check_next(ls, ".")) { + if (check_next(ls, ".")) + return TK_DOTS; /* ... */ + else return TK_CONCAT; /* .. */ + } + else if (!isdigit(ls->current)) return '.'; + else { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + } + case EOZ: { + return TK_EOS; + } + default: { + if (isspace(ls->current)) { + lua_assert(!currIsNewline(ls)); + next(ls); + continue; + } + else if (isdigit(ls->current)) { + read_numeral(ls, seminfo); + return TK_NUMBER; + } + else if (isalpha(ls->current) || ls->current == '_') { + /* identifier or reserved word */ + TString *ts; + do { + save_and_next(ls); + } while (isalnum(ls->current) || ls->current == '_'); + ts = luaX_newstring(ls, luaZ_buffer(ls->buff), + luaZ_bufflen(ls->buff)); + if (ts->tsv.reserved > 0) /* reserved word? */ + return ts->tsv.reserved - 1 + FIRST_RESERVED; + else { + seminfo->ts = ts; + return TK_NAME; + } + } + else { + int c = ls->current; + next(ls); + return c; /* single-char tokens (+ - / ...) */ + } + } + } + } +} + + +void luaX_next (LexState *ls) { + ls->lastline = ls->linenumber; + if (ls->lookahead.token != TK_EOS) { /* is there a look-ahead token? */ + ls->t = ls->lookahead; /* use this one */ + ls->lookahead.token = TK_EOS; /* and discharge it */ + } + else + ls->t.token = llex(ls, &ls->t.seminfo); /* read next token */ +} + + +void luaX_lookahead (LexState *ls) { + lua_assert(ls->lookahead.token == TK_EOS); + ls->lookahead.token = llex(ls, &ls->lookahead.seminfo); +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/llex.h.svn-base blobby-0.9c/src/lua/.svn/text-base/llex.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/llex.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/llex.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,81 @@ +/* +** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lexical Analyzer +** See Copyright Notice in lua.h +*/ + +#ifndef llex_h +#define llex_h + +#include "lobject.h" +#include "lzio.h" + + +#define FIRST_RESERVED 257 + +/* maximum length of a reserved word */ +#define TOKEN_LEN (sizeof("function")/sizeof(char)) + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER RESERVED" +*/ +enum RESERVED { + /* terminal symbols denoted by reserved words */ + TK_AND = FIRST_RESERVED, TK_BREAK, + TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, + TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, + TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, + /* other terminal symbols */ + TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER, + TK_NAME, TK_STRING, TK_EOS +}; + +/* number of reserved words */ +#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) + + +/* array with token `names' */ +LUAI_DATA const char *const luaX_tokens []; + + +typedef union { + lua_Number r; + TString *ts; +} SemInfo; /* semantics information */ + + +typedef struct Token { + int token; + SemInfo seminfo; +} Token; + + +typedef struct LexState { + int current; /* current character (charint) */ + int linenumber; /* input line counter */ + int lastline; /* line of last token `consumed' */ + Token t; /* current token */ + Token lookahead; /* look ahead token */ + struct FuncState *fs; /* `FuncState' is private to the parser */ + struct lua_State *L; + ZIO *z; /* input stream */ + Mbuffer *buff; /* buffer for tokens */ + TString *source; /* current source name */ + char decpoint; /* locale decimal point */ +} LexState; + + +LUAI_FUNC void luaX_init (lua_State *L); +LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, + TString *source); +LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); +LUAI_FUNC void luaX_next (LexState *ls); +LUAI_FUNC void luaX_lookahead (LexState *ls); +LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token); +LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s); +LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); + + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/llimits.h.svn-base blobby-0.9c/src/lua/.svn/text-base/llimits.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/llimits.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/llimits.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,128 @@ +/* +** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $ +** Limits, basic types, and some other `installation-dependent' definitions +** See Copyright Notice in lua.h +*/ + +#ifndef llimits_h +#define llimits_h + + +#include +#include + + +#include "lua.h" + + +typedef LUAI_UINT32 lu_int32; + +typedef LUAI_UMEM lu_mem; + +typedef LUAI_MEM l_mem; + + + +/* chars used as small naturals (so that `char' is reserved for characters) */ +typedef unsigned char lu_byte; + + +#define MAX_SIZET ((size_t)(~(size_t)0)-2) + +#define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) + + +#define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ + +/* +** conversion of pointer to integer +** this is for hashing only; there is no problem if the integer +** cannot hold the whole pointer value +*/ +#define IntPoint(p) ((unsigned int)(lu_mem)(p)) + + + +/* type to ensure maximum alignment */ +typedef LUAI_USER_ALIGNMENT_T L_Umaxalign; + + +/* result of a `usual argument conversion' over lua_Number */ +typedef LUAI_UACNUMBER l_uacNumber; + + +/* internal assertions for in-house debugging */ +#ifdef lua_assert + +#define check_exp(c,e) (lua_assert(c), (e)) +#define api_check(l,e) lua_assert(e) + +#else + +#define lua_assert(c) ((void)0) +#define check_exp(c,e) (e) +#define api_check luai_apicheck + +#endif + + +#ifndef UNUSED +#define UNUSED(x) ((void)(x)) /* to avoid warnings */ +#endif + + +#ifndef cast +#define cast(t, exp) ((t)(exp)) +#endif + +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) + + + +/* +** type for virtual-machine instructions +** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) +*/ +typedef lu_int32 Instruction; + + + +/* maximum stack for a Lua function */ +#define MAXSTACK 250 + + + +/* minimum size for the string table (must be power of 2) */ +#ifndef MINSTRTABSIZE +#define MINSTRTABSIZE 32 +#endif + + +/* minimum size for string buffer */ +#ifndef LUA_MINBUFFER +#define LUA_MINBUFFER 32 +#endif + + +#ifndef lua_lock +#define lua_lock(L) ((void) 0) +#define lua_unlock(L) ((void) 0) +#endif + +#ifndef luai_threadyield +#define luai_threadyield(L) {lua_unlock(L); lua_lock(L);} +#endif + + +/* +** macro to control inclusion of some hard tests on stack reallocation +*/ +#ifndef HARDSTACKTESTS +#define condhardstacktests(x) ((void)0) +#else +#define condhardstacktests(x) x +#endif + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lmathlib.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lmathlib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lmathlib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lmathlib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,263 @@ +/* +** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $ +** Standard mathematical library +** See Copyright Notice in lua.h +*/ + + +#include +#include + +#define lmathlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#undef PI +#define PI (3.14159265358979323846) +#define RADIANS_PER_DEGREE (PI/180.0) + + + +static int math_abs (lua_State *L) { + lua_pushnumber(L, fabs(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sin (lua_State *L) { + lua_pushnumber(L, sin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_sinh (lua_State *L) { + lua_pushnumber(L, sinh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cos (lua_State *L) { + lua_pushnumber(L, cos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_cosh (lua_State *L) { + lua_pushnumber(L, cosh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tan (lua_State *L) { + lua_pushnumber(L, tan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_tanh (lua_State *L) { + lua_pushnumber(L, tanh(luaL_checknumber(L, 1))); + return 1; +} + +static int math_asin (lua_State *L) { + lua_pushnumber(L, asin(luaL_checknumber(L, 1))); + return 1; +} + +static int math_acos (lua_State *L) { + lua_pushnumber(L, acos(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan (lua_State *L) { + lua_pushnumber(L, atan(luaL_checknumber(L, 1))); + return 1; +} + +static int math_atan2 (lua_State *L) { + lua_pushnumber(L, atan2(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_ceil (lua_State *L) { + lua_pushnumber(L, ceil(luaL_checknumber(L, 1))); + return 1; +} + +static int math_floor (lua_State *L) { + lua_pushnumber(L, floor(luaL_checknumber(L, 1))); + return 1; +} + +static int math_fmod (lua_State *L) { + lua_pushnumber(L, fmod(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_modf (lua_State *L) { + double ip; + double fp = modf(luaL_checknumber(L, 1), &ip); + lua_pushnumber(L, ip); + lua_pushnumber(L, fp); + return 2; +} + +static int math_sqrt (lua_State *L) { + lua_pushnumber(L, sqrt(luaL_checknumber(L, 1))); + return 1; +} + +static int math_pow (lua_State *L) { + lua_pushnumber(L, pow(luaL_checknumber(L, 1), luaL_checknumber(L, 2))); + return 1; +} + +static int math_log (lua_State *L) { + lua_pushnumber(L, log(luaL_checknumber(L, 1))); + return 1; +} + +static int math_log10 (lua_State *L) { + lua_pushnumber(L, log10(luaL_checknumber(L, 1))); + return 1; +} + +static int math_exp (lua_State *L) { + lua_pushnumber(L, exp(luaL_checknumber(L, 1))); + return 1; +} + +static int math_deg (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)/RADIANS_PER_DEGREE); + return 1; +} + +static int math_rad (lua_State *L) { + lua_pushnumber(L, luaL_checknumber(L, 1)*RADIANS_PER_DEGREE); + return 1; +} + +static int math_frexp (lua_State *L) { + int e; + lua_pushnumber(L, frexp(luaL_checknumber(L, 1), &e)); + lua_pushinteger(L, e); + return 2; +} + +static int math_ldexp (lua_State *L) { + lua_pushnumber(L, ldexp(luaL_checknumber(L, 1), luaL_checkint(L, 2))); + return 1; +} + + + +static int math_min (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmin = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d < dmin) + dmin = d; + } + lua_pushnumber(L, dmin); + return 1; +} + + +static int math_max (lua_State *L) { + int n = lua_gettop(L); /* number of arguments */ + lua_Number dmax = luaL_checknumber(L, 1); + int i; + for (i=2; i<=n; i++) { + lua_Number d = luaL_checknumber(L, i); + if (d > dmax) + dmax = d; + } + lua_pushnumber(L, dmax); + return 1; +} + + +static int math_random (lua_State *L) { + /* the `%' avoids the (rare) case of r==1, and is needed also because on + some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ + lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; + switch (lua_gettop(L)) { /* check number of arguments */ + case 0: { /* no arguments */ + lua_pushnumber(L, r); /* Number between 0 and 1 */ + break; + } + case 1: { /* only upper limit */ + int u = luaL_checkint(L, 1); + luaL_argcheck(L, 1<=u, 1, "interval is empty"); + lua_pushnumber(L, floor(r*u)+1); /* int between 1 and `u' */ + break; + } + case 2: { /* lower and upper limits */ + int l = luaL_checkint(L, 1); + int u = luaL_checkint(L, 2); + luaL_argcheck(L, l<=u, 2, "interval is empty"); + lua_pushnumber(L, floor(r*(u-l+1))+l); /* int between `l' and `u' */ + break; + } + default: return luaL_error(L, "wrong number of arguments"); + } + return 1; +} + + +static int math_randomseed (lua_State *L) { + srand(luaL_checkint(L, 1)); + return 0; +} + + +static const luaL_Reg mathlib[] = { + {"abs", math_abs}, + {"acos", math_acos}, + {"asin", math_asin}, + {"atan2", math_atan2}, + {"atan", math_atan}, + {"ceil", math_ceil}, + {"cosh", math_cosh}, + {"cos", math_cos}, + {"deg", math_deg}, + {"exp", math_exp}, + {"floor", math_floor}, + {"fmod", math_fmod}, + {"frexp", math_frexp}, + {"ldexp", math_ldexp}, + {"log10", math_log10}, + {"log", math_log}, + {"max", math_max}, + {"min", math_min}, + {"modf", math_modf}, + {"pow", math_pow}, + {"rad", math_rad}, + {"random", math_random}, + {"randomseed", math_randomseed}, + {"sinh", math_sinh}, + {"sin", math_sin}, + {"sqrt", math_sqrt}, + {"tanh", math_tanh}, + {"tan", math_tan}, + {NULL, NULL} +}; + + +/* +** Open math library +*/ +LUALIB_API int luaopen_math (lua_State *L) { + luaL_register(L, LUA_MATHLIBNAME, mathlib); + lua_pushnumber(L, PI); + lua_setfield(L, -2, "pi"); + lua_pushnumber(L, HUGE_VAL); + lua_setfield(L, -2, "huge"); +#if defined(LUA_COMPAT_MOD) + lua_getfield(L, -1, "fmod"); + lua_setfield(L, -2, "mod"); +#endif + return 1; +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lmem.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lmem.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lmem.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lmem.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,86 @@ +/* +** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + + +#include + +#define lmem_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" + + + +/* +** About the realloc function: +** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); +** (`osize' is the old size, `nsize' is the new size) +** +** Lua ensures that (ptr == NULL) iff (osize == 0). +** +** * frealloc(ud, NULL, 0, x) creates a new block of size `x' +** +** * frealloc(ud, p, x, 0) frees the block `p' +** (in this specific case, frealloc must return NULL). +** particularly, frealloc(ud, NULL, 0, 0) does nothing +** (which is equivalent to free(NULL) in ANSI C) +** +** frealloc returns NULL if it cannot create or reallocate the area +** (any reallocation to an equal or smaller size cannot fail!) +*/ + + + +#define MINSIZEARRAY 4 + + +void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, + int limit, const char *errormsg) { + void *newblock; + int newsize; + if (*size >= limit/2) { /* cannot double it? */ + if (*size >= limit) /* cannot grow even a little? */ + luaG_runerror(L, errormsg); + newsize = limit; /* still have at least one free place */ + } + else { + newsize = (*size)*2; + if (newsize < MINSIZEARRAY) + newsize = MINSIZEARRAY; /* minimum size */ + } + newblock = luaM_reallocv(L, block, *size, newsize, size_elems); + *size = newsize; /* update only when everything else is OK */ + return newblock; +} + + +void *luaM_toobig (lua_State *L) { + luaG_runerror(L, "memory allocation error: block too big"); + return NULL; /* to avoid warnings */ +} + + + +/* +** generic allocation routine. +*/ +void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { + global_State *g = G(L); + lua_assert((osize == 0) == (block == NULL)); + block = (*g->frealloc)(g->ud, block, osize, nsize); + if (block == NULL && nsize > 0) + luaD_throw(L, LUA_ERRMEM); + lua_assert((nsize == 0) == (block == NULL)); + g->totalbytes = (g->totalbytes - osize) + nsize; + return block; +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lmem.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lmem.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lmem.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lmem.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,49 @@ +/* +** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** Interface to Memory Manager +** See Copyright Notice in lua.h +*/ + +#ifndef lmem_h +#define lmem_h + + +#include + +#include "llimits.h" +#include "lua.h" + +#define MEMERRMSG "not enough memory" + + +#define luaM_reallocv(L,b,on,n,e) \ + ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ + luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ + luaM_toobig(L)) + +#define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) +#define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) +#define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) + +#define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) +#define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) +#define luaM_newvector(L,n,t) \ + cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) + +#define luaM_growvector(L,v,nelems,size,t,limit,e) \ + if ((nelems)+1 > (size)) \ + ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) + +#define luaM_reallocvector(L, v,oldn,n,t) \ + ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) + + +LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, + size_t size); +LUAI_FUNC void *luaM_toobig (lua_State *L); +LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, + size_t size_elem, int limit, + const char *errormsg); + +#endif + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/loadlib.c.svn-base blobby-0.9c/src/lua/.svn/text-base/loadlib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/loadlib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/loadlib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,666 @@ +/* +** $Id: loadlib.c,v 1.52.1.3 2008/08/06 13:29:28 roberto Exp $ +** Dynamic library loader for Lua +** See Copyright Notice in lua.h +** +** This module contains an implementation of loadlib for Unix systems +** that have dlfcn, an implementation for Darwin (Mac OS X), an +** implementation for Windows, and a stub for other systems. +*/ + + +#include +#include + + +#define loadlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* prefix for open functions in C libraries */ +#define LUA_POF "luaopen_" + +/* separator for open functions in C libraries */ +#define LUA_OFSEP "_" + + +#define LIBPREFIX "LOADLIB: " + +#define POF LUA_POF +#define LIB_FAIL "open" + + +/* error codes for ll_loadfunc */ +#define ERRLIB 1 +#define ERRFUNC 2 + +#define setprogdir(L) ((void)0) + + +static void ll_unloadlib (void *lib); +static void *ll_load (lua_State *L, const char *path); +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym); + + + +#if defined(LUA_DL_DLOPEN) +/* +** {======================================================================== +** This is an implementation of loadlib based on the dlfcn interface. +** The dlfcn interface is available in Linux, SunOS, Solaris, IRIX, FreeBSD, +** NetBSD, AIX 4.2, HPUX 11, and probably most other Unix flavors, at least +** as an emulation layer on top of native functions. +** ========================================================================= +*/ + +#include + +static void ll_unloadlib (void *lib) { + dlclose(lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + void *lib = dlopen(path, RTLD_NOW); + if (lib == NULL) lua_pushstring(L, dlerror()); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)dlsym(lib, sym); + if (f == NULL) lua_pushstring(L, dlerror()); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DLL) +/* +** {====================================================================== +** This is an implementation of loadlib for Windows using native functions. +** ======================================================================= +*/ + +#include + + +#undef setprogdir + +static void setprogdir (lua_State *L) { + char buff[MAX_PATH + 1]; + char *lb; + DWORD nsize = sizeof(buff)/sizeof(char); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); + if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) + luaL_error(L, "unable to get ModuleFileName"); + else { + *lb = '\0'; + luaL_gsub(L, lua_tostring(L, -1), LUA_EXECDIR, buff); + lua_remove(L, -2); /* remove original string */ + } +} + + +static void pusherror (lua_State *L) { + int error = GetLastError(); + char buffer[128]; + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, buffer, sizeof(buffer), NULL)) + lua_pushstring(L, buffer); + else + lua_pushfstring(L, "system error %d\n", error); +} + +static void ll_unloadlib (void *lib) { + FreeLibrary((HINSTANCE)lib); +} + + +static void *ll_load (lua_State *L, const char *path) { + HINSTANCE lib = LoadLibraryA(path); + if (lib == NULL) pusherror(L); + return lib; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + lua_CFunction f = (lua_CFunction)GetProcAddress((HINSTANCE)lib, sym); + if (f == NULL) pusherror(L); + return f; +} + +/* }====================================================== */ + + + +#elif defined(LUA_DL_DYLD) +/* +** {====================================================================== +** Native Mac OS X / Darwin Implementation +** ======================================================================= +*/ + +#include + + +/* Mac appends a `_' before C function names */ +#undef POF +#define POF "_" LUA_POF + + +static void pusherror (lua_State *L) { + const char *err_str; + const char *err_file; + NSLinkEditErrors err; + int err_num; + NSLinkEditError(&err, &err_num, &err_file, &err_str); + lua_pushstring(L, err_str); +} + + +static const char *errorfromcode (NSObjectFileImageReturnCode ret) { + switch (ret) { + case NSObjectFileImageInappropriateFile: + return "file is not a bundle"; + case NSObjectFileImageArch: + return "library is for wrong CPU type"; + case NSObjectFileImageFormat: + return "bad format"; + case NSObjectFileImageAccess: + return "cannot access file"; + case NSObjectFileImageFailure: + default: + return "unable to load library"; + } +} + + +static void ll_unloadlib (void *lib) { + NSUnLinkModule((NSModule)lib, NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES); +} + + +static void *ll_load (lua_State *L, const char *path) { + NSObjectFileImage img; + NSObjectFileImageReturnCode ret; + /* this would be a rare case, but prevents crashing if it happens */ + if(!_dyld_present()) { + lua_pushliteral(L, "dyld not present"); + return NULL; + } + ret = NSCreateObjectFileImageFromFile(path, &img); + if (ret == NSObjectFileImageSuccess) { + NSModule mod = NSLinkModule(img, path, NSLINKMODULE_OPTION_PRIVATE | + NSLINKMODULE_OPTION_RETURN_ON_ERROR); + NSDestroyObjectFileImage(img); + if (mod == NULL) pusherror(L); + return mod; + } + lua_pushstring(L, errorfromcode(ret)); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); + if (nss == NULL) { + lua_pushfstring(L, "symbol " LUA_QS " not found", sym); + return NULL; + } + return (lua_CFunction)NSAddressOfSymbol(nss); +} + +/* }====================================================== */ + + + +#else +/* +** {====================================================== +** Fallback for other systems +** ======================================================= +*/ + +#undef LIB_FAIL +#define LIB_FAIL "absent" + + +#define DLMSG "dynamic libraries not enabled; check your Lua installation" + + +static void ll_unloadlib (void *lib) { + (void)lib; /* to avoid warnings */ +} + + +static void *ll_load (lua_State *L, const char *path) { + (void)path; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + + +static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { + (void)lib; (void)sym; /* to avoid warnings */ + lua_pushliteral(L, DLMSG); + return NULL; +} + +/* }====================================================== */ +#endif + + + +static void **ll_register (lua_State *L, const char *path) { + void **plib; + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_gettable(L, LUA_REGISTRYINDEX); /* check library in registry? */ + if (!lua_isnil(L, -1)) /* is there an entry? */ + plib = (void **)lua_touserdata(L, -1); + else { /* no entry yet; create one */ + lua_pop(L, 1); + plib = (void **)lua_newuserdata(L, sizeof(const void *)); + *plib = NULL; + luaL_getmetatable(L, "_LOADLIB"); + lua_setmetatable(L, -2); + lua_pushfstring(L, "%s%s", LIBPREFIX, path); + lua_pushvalue(L, -2); + lua_settable(L, LUA_REGISTRYINDEX); + } + return plib; +} + + +/* +** __gc tag method: calls library's `ll_unloadlib' function with the lib +** handle +*/ +static int gctm (lua_State *L) { + void **lib = (void **)luaL_checkudata(L, 1, "_LOADLIB"); + if (*lib) ll_unloadlib(*lib); + *lib = NULL; /* mark library as closed */ + return 0; +} + + +static int ll_loadfunc (lua_State *L, const char *path, const char *sym) { + void **reg = ll_register(L, path); + if (*reg == NULL) *reg = ll_load(L, path); + if (*reg == NULL) + return ERRLIB; /* unable to load library */ + else { + lua_CFunction f = ll_sym(L, *reg, sym); + if (f == NULL) + return ERRFUNC; /* unable to find function */ + lua_pushcfunction(L, f); + return 0; /* return function */ + } +} + + +static int ll_loadlib (lua_State *L) { + const char *path = luaL_checkstring(L, 1); + const char *init = luaL_checkstring(L, 2); + int stat = ll_loadfunc(L, path, init); + if (stat == 0) /* no errors? */ + return 1; /* return the loaded function */ + else { /* error; error message is on stack top */ + lua_pushnil(L); + lua_insert(L, -2); + lua_pushstring(L, (stat == ERRLIB) ? LIB_FAIL : "init"); + return 3; /* return nil, error message, and where */ + } +} + + + +/* +** {====================================================== +** 'require' function +** ======================================================= +*/ + + +static int readable (const char *filename) { + FILE *f = fopen(filename, "r"); /* try to open file */ + if (f == NULL) return 0; /* open failed */ + fclose(f); + return 1; +} + + +static const char *pushnexttemplate (lua_State *L, const char *path) { + const char *l; + while (*path == *LUA_PATHSEP) path++; /* skip separators */ + if (*path == '\0') return NULL; /* no more templates */ + l = strchr(path, *LUA_PATHSEP); /* find next separator */ + if (l == NULL) l = path + strlen(path); + lua_pushlstring(L, path, l - path); /* template */ + return l; +} + + +static const char *findfile (lua_State *L, const char *name, + const char *pname) { + const char *path; + name = luaL_gsub(L, name, ".", LUA_DIRSEP); + lua_getfield(L, LUA_ENVIRONINDEX, pname); + path = lua_tostring(L, -1); + if (path == NULL) + luaL_error(L, LUA_QL("package.%s") " must be a string", pname); + lua_pushliteral(L, ""); /* error accumulator */ + while ((path = pushnexttemplate(L, path)) != NULL) { + const char *filename; + filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ + if (readable(filename)) /* does file exist and is readable? */ + return filename; /* return that file name */ + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ + } + return NULL; /* not found */ +} + + +static void loaderror (lua_State *L, const char *filename) { + luaL_error(L, "error loading module " LUA_QS " from file " LUA_QS ":\n\t%s", + lua_tostring(L, 1), filename, lua_tostring(L, -1)); +} + + +static int loader_Lua (lua_State *L) { + const char *filename; + const char *name = luaL_checkstring(L, 1); + filename = findfile(L, name, "path"); + if (filename == NULL) return 1; /* library not found in this path */ + if (luaL_loadfile(L, filename) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static const char *mkfuncname (lua_State *L, const char *modname) { + const char *funcname; + const char *mark = strchr(modname, *LUA_IGMARK); + if (mark) modname = mark + 1; + funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); + funcname = lua_pushfstring(L, POF"%s", funcname); + lua_remove(L, -2); /* remove 'gsub' result */ + return funcname; +} + + +static int loader_C (lua_State *L) { + const char *funcname; + const char *name = luaL_checkstring(L, 1); + const char *filename = findfile(L, name, "cpath"); + if (filename == NULL) return 1; /* library not found in this path */ + funcname = mkfuncname(L, name); + if (ll_loadfunc(L, filename, funcname) != 0) + loaderror(L, filename); + return 1; /* library loaded successfully */ +} + + +static int loader_Croot (lua_State *L) { + const char *funcname; + const char *filename; + const char *name = luaL_checkstring(L, 1); + const char *p = strchr(name, '.'); + int stat; + if (p == NULL) return 0; /* is root */ + lua_pushlstring(L, name, p - name); + filename = findfile(L, lua_tostring(L, -1), "cpath"); + if (filename == NULL) return 1; /* root not found */ + funcname = mkfuncname(L, name); + if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { + if (stat != ERRFUNC) loaderror(L, filename); /* real error */ + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); + return 1; /* function not found */ + } + return 1; +} + + +static int loader_preload (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + lua_getfield(L, LUA_ENVIRONINDEX, "preload"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.preload") " must be a table"); + lua_getfield(L, -1, name); + if (lua_isnil(L, -1)) /* not found? */ + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); + return 1; +} + + +static const int sentinel_ = 0; +#define sentinel ((void *)&sentinel_) + + +static int ll_require (lua_State *L) { + const char *name = luaL_checkstring(L, 1); + int i; + lua_settop(L, 1); /* _LOADED table will be at index 2 */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, 2, name); + if (lua_toboolean(L, -1)) { /* is it there? */ + if (lua_touserdata(L, -1) == sentinel) /* check loops */ + luaL_error(L, "loop or previous error loading module " LUA_QS, name); + return 1; /* package is already loaded */ + } + /* else must load it; iterate over available loaders */ + lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); + if (!lua_istable(L, -1)) + luaL_error(L, LUA_QL("package.loaders") " must be a table"); + lua_pushliteral(L, ""); /* error message accumulator */ + for (i=1; ; i++) { + lua_rawgeti(L, -2, i); /* get a loader */ + if (lua_isnil(L, -1)) + luaL_error(L, "module " LUA_QS " not found:%s", + name, lua_tostring(L, -2)); + lua_pushstring(L, name); + lua_call(L, 1, 1); /* call it */ + if (lua_isfunction(L, -1)) /* did it find module? */ + break; /* module loaded successfully */ + else if (lua_isstring(L, -1)) /* loader returned error message? */ + lua_concat(L, 2); /* accumulate it */ + else + lua_pop(L, 1); + } + lua_pushlightuserdata(L, sentinel); + lua_setfield(L, 2, name); /* _LOADED[name] = sentinel */ + lua_pushstring(L, name); /* pass name as argument to module */ + lua_call(L, 1, 1); /* run loaded module */ + if (!lua_isnil(L, -1)) /* non-nil return? */ + lua_setfield(L, 2, name); /* _LOADED[name] = returned value */ + lua_getfield(L, 2, name); + if (lua_touserdata(L, -1) == sentinel) { /* module did not set a value? */ + lua_pushboolean(L, 1); /* use true as result */ + lua_pushvalue(L, -1); /* extra copy to be returned */ + lua_setfield(L, 2, name); /* _LOADED[name] = true */ + } + return 1; +} + +/* }====================================================== */ + + + +/* +** {====================================================== +** 'module' function +** ======================================================= +*/ + + +static void setfenv (lua_State *L) { + lua_Debug ar; + if (lua_getstack(L, 1, &ar) == 0 || + lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ + lua_iscfunction(L, -1)) + luaL_error(L, LUA_QL("module") " not called from a Lua function"); + lua_pushvalue(L, -2); + lua_setfenv(L, -2); + lua_pop(L, 1); +} + + +static void dooptions (lua_State *L, int n) { + int i; + for (i = 2; i <= n; i++) { + lua_pushvalue(L, i); /* get option (a function) */ + lua_pushvalue(L, -2); /* module */ + lua_call(L, 1, 0); + } +} + + +static void modinit (lua_State *L, const char *modname) { + const char *dot; + lua_pushvalue(L, -1); + lua_setfield(L, -2, "_M"); /* module._M = module */ + lua_pushstring(L, modname); + lua_setfield(L, -2, "_NAME"); + dot = strrchr(modname, '.'); /* look for last dot in module name */ + if (dot == NULL) dot = modname; + else dot++; + /* set _PACKAGE as package name (full module name minus last part) */ + lua_pushlstring(L, modname, dot - modname); + lua_setfield(L, -2, "_PACKAGE"); +} + + +static int ll_module (lua_State *L) { + const char *modname = luaL_checkstring(L, 1); + int loaded = lua_gettop(L) + 1; /* index of _LOADED table */ + lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); + lua_getfield(L, loaded, modname); /* get _LOADED[modname] */ + if (!lua_istable(L, -1)) { /* not found? */ + lua_pop(L, 1); /* remove previous result */ + /* try global variable (and create one if it does not exist) */ + if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL) + return luaL_error(L, "name conflict for module " LUA_QS, modname); + lua_pushvalue(L, -1); + lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */ + } + /* check whether table already has a _NAME field */ + lua_getfield(L, -1, "_NAME"); + if (!lua_isnil(L, -1)) /* is table an initialized module? */ + lua_pop(L, 1); + else { /* no; initialize it */ + lua_pop(L, 1); + modinit(L, modname); + } + lua_pushvalue(L, -1); + setfenv(L); + dooptions(L, loaded - 1); + return 0; +} + + +static int ll_seeall (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + if (!lua_getmetatable(L, 1)) { + lua_createtable(L, 0, 1); /* create new metatable */ + lua_pushvalue(L, -1); + lua_setmetatable(L, 1); + } + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); /* mt.__index = _G */ + return 0; +} + + +/* }====================================================== */ + + + +/* auxiliary mark (for internal use) */ +#define AUXMARK "\1" + +static void setpath (lua_State *L, const char *fieldname, const char *envname, + const char *def) { + const char *path = getenv(envname); + if (path == NULL) /* no environment variable? */ + lua_pushstring(L, def); /* use default */ + else { + /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ + path = luaL_gsub(L, path, LUA_PATHSEP LUA_PATHSEP, + LUA_PATHSEP AUXMARK LUA_PATHSEP); + luaL_gsub(L, path, AUXMARK, def); + lua_remove(L, -2); + } + setprogdir(L); + lua_setfield(L, -2, fieldname); +} + + +static const luaL_Reg pk_funcs[] = { + {"loadlib", ll_loadlib}, + {"seeall", ll_seeall}, + {NULL, NULL} +}; + + +static const luaL_Reg ll_funcs[] = { + {"module", ll_module}, + {"require", ll_require}, + {NULL, NULL} +}; + + +static const lua_CFunction loaders[] = + {loader_preload, loader_Lua, loader_C, loader_Croot, NULL}; + + +LUALIB_API int luaopen_package (lua_State *L) { + int i; + /* create new type _LOADLIB */ + luaL_newmetatable(L, "_LOADLIB"); + lua_pushcfunction(L, gctm); + lua_setfield(L, -2, "__gc"); + /* create `package' table */ + luaL_register(L, LUA_LOADLIBNAME, pk_funcs); +#if defined(LUA_COMPAT_LOADLIB) + lua_getfield(L, -1, "loadlib"); + lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); +#endif + lua_pushvalue(L, -1); + lua_replace(L, LUA_ENVIRONINDEX); + /* create `loaders' table */ + lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1); + /* fill it with pre-defined loaders */ + for (i=0; loaders[i] != NULL; i++) { + lua_pushcfunction(L, loaders[i]); + lua_rawseti(L, -2, i+1); + } + lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */ + setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ + setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ + /* store config information */ + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); + lua_setfield(L, -2, "config"); + /* set field `loaded' */ + luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); + lua_setfield(L, -2, "loaded"); + /* set field `preload' */ + lua_newtable(L); + lua_setfield(L, -2, "preload"); + lua_pushvalue(L, LUA_GLOBALSINDEX); + luaL_register(L, NULL, ll_funcs); /* open lib into global table */ + lua_pop(L, 1); + return 1; /* return 'package' table */ +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lobject.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lobject.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lobject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lobject.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,214 @@ +/* +** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $ +** Some generic functions over Lua objects +** See Copyright Notice in lua.h +*/ + +#include +#include +#include +#include +#include + +#define lobject_c +#define LUA_CORE + +#include "lua.h" + +#include "ldo.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "lvm.h" + + + +const TValue luaO_nilobject_ = {{NULL}, LUA_TNIL}; + + +/* +** converts an integer to a "floating point byte", represented as +** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if +** eeeee != 0 and (xxx) otherwise. +*/ +int luaO_int2fb (unsigned int x) { + int e = 0; /* expoent */ + while (x >= 16) { + x = (x+1) >> 1; + e++; + } + if (x < 8) return x; + else return ((e+1) << 3) | (cast_int(x) - 8); +} + + +/* converts back */ +int luaO_fb2int (int x) { + int e = (x >> 3) & 31; + if (e == 0) return x; + else return ((x & 7)+8) << (e - 1); +} + + +int luaO_log2 (unsigned int x) { + static const lu_byte log_2[256] = { + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 + }; + int l = -1; + while (x >= 256) { l += 8; x >>= 8; } + return l + log_2[x]; + +} + + +int luaO_rawequalObj (const TValue *t1, const TValue *t2) { + if (ttype(t1) != ttype(t2)) return 0; + else switch (ttype(t1)) { + case LUA_TNIL: + return 1; + case LUA_TNUMBER: + return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: + return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ + case LUA_TLIGHTUSERDATA: + return pvalue(t1) == pvalue(t2); + default: + lua_assert(iscollectable(t1)); + return gcvalue(t1) == gcvalue(t2); + } +} + + +int luaO_str2d (const char *s, lua_Number *result) { + char *endptr; + *result = lua_str2number(s, &endptr); + if (endptr == s) return 0; /* conversion failed */ + if (*endptr == 'x' || *endptr == 'X') /* maybe an hexadecimal constant? */ + *result = cast_num(strtoul(s, &endptr, 16)); + if (*endptr == '\0') return 1; /* most common case */ + while (isspace(cast(unsigned char, *endptr))) endptr++; + if (*endptr != '\0') return 0; /* invalid trailing characters? */ + return 1; +} + + + +static void pushstr (lua_State *L, const char *str) { + setsvalue2s(L, L->top, luaS_new(L, str)); + incr_top(L); +} + + +/* this function handles only `%d', `%c', %f, %p, and `%s' formats */ +const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { + int n = 1; + pushstr(L, ""); + for (;;) { + const char *e = strchr(fmt, '%'); + if (e == NULL) break; + setsvalue2s(L, L->top, luaS_newlstr(L, fmt, e-fmt)); + incr_top(L); + switch (*(e+1)) { + case 's': { + const char *s = va_arg(argp, char *); + if (s == NULL) s = "(null)"; + pushstr(L, s); + break; + } + case 'c': { + char buff[2]; + buff[0] = cast(char, va_arg(argp, int)); + buff[1] = '\0'; + pushstr(L, buff); + break; + } + case 'd': { + setnvalue(L->top, cast_num(va_arg(argp, int))); + incr_top(L); + break; + } + case 'f': { + setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); + incr_top(L); + break; + } + case 'p': { + char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ + sprintf(buff, "%p", va_arg(argp, void *)); + pushstr(L, buff); + break; + } + case '%': { + pushstr(L, "%"); + break; + } + default: { + char buff[3]; + buff[0] = '%'; + buff[1] = *(e+1); + buff[2] = '\0'; + pushstr(L, buff); + break; + } + } + n += 2; + fmt = e+2; + } + pushstr(L, fmt); + luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); + L->top -= n; + return svalue(L->top - 1); +} + + +const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_pushvfstring(L, fmt, argp); + va_end(argp); + return msg; +} + + +void luaO_chunkid (char *out, const char *source, size_t bufflen) { + if (*source == '=') { + strncpy(out, source+1, bufflen); /* remove first char */ + out[bufflen-1] = '\0'; /* ensures null termination */ + } + else { /* out = "source", or "...source" */ + if (*source == '@') { + size_t l; + source++; /* skip the `@' */ + bufflen -= sizeof(" '...' "); + l = strlen(source); + strcpy(out, ""); + if (l > bufflen) { + source += (l-bufflen); /* get last part of file name */ + strcat(out, "..."); + } + strcat(out, source); + } + else { /* out = [string "string"] */ + size_t len = strcspn(source, "\n\r"); /* stop at first newline */ + bufflen -= sizeof(" [string \"...\"] "); + if (len > bufflen) len = bufflen; + strcpy(out, "[string \""); + if (source[len] != '\0') { /* must truncate? */ + strncat(out, source, len); + strcat(out, "..."); + } + else + strcat(out, source); + strcat(out, "\"]"); + } + } +} diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lobject.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lobject.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lobject.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lobject.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,381 @@ +/* +** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $ +** Type definitions for Lua objects +** See Copyright Notice in lua.h +*/ + + +#ifndef lobject_h +#define lobject_h + + +#include + + +#include "llimits.h" +#include "lua.h" + + +/* tags for values visible from Lua */ +#define LAST_TAG LUA_TTHREAD + +#define NUM_TAGS (LAST_TAG+1) + + +/* +** Extra tags for non-values +*/ +#define LUA_TPROTO (LAST_TAG+1) +#define LUA_TUPVAL (LAST_TAG+2) +#define LUA_TDEADKEY (LAST_TAG+3) + + +/* +** Union of all collectable objects +*/ +typedef union GCObject GCObject; + + +/* +** Common Header for all collectable objects (in macro form, to be +** included in other objects) +*/ +#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked + + +/* +** Common header in struct form +*/ +typedef struct GCheader { + CommonHeader; +} GCheader; + + + + +/* +** Union of all Lua values +*/ +typedef union { + GCObject *gc; + void *p; + lua_Number n; + int b; +} Value; + + +/* +** Tagged Values +*/ + +#define TValuefields Value value; int tt + +typedef struct lua_TValue { + TValuefields; +} TValue; + + +/* Macros to test type */ +#define ttisnil(o) (ttype(o) == LUA_TNIL) +#define ttisnumber(o) (ttype(o) == LUA_TNUMBER) +#define ttisstring(o) (ttype(o) == LUA_TSTRING) +#define ttistable(o) (ttype(o) == LUA_TTABLE) +#define ttisfunction(o) (ttype(o) == LUA_TFUNCTION) +#define ttisboolean(o) (ttype(o) == LUA_TBOOLEAN) +#define ttisuserdata(o) (ttype(o) == LUA_TUSERDATA) +#define ttisthread(o) (ttype(o) == LUA_TTHREAD) +#define ttislightuserdata(o) (ttype(o) == LUA_TLIGHTUSERDATA) + +/* Macros to access values */ +#define ttype(o) ((o)->tt) +#define gcvalue(o) check_exp(iscollectable(o), (o)->value.gc) +#define pvalue(o) check_exp(ttislightuserdata(o), (o)->value.p) +#define nvalue(o) check_exp(ttisnumber(o), (o)->value.n) +#define rawtsvalue(o) check_exp(ttisstring(o), &(o)->value.gc->ts) +#define tsvalue(o) (&rawtsvalue(o)->tsv) +#define rawuvalue(o) check_exp(ttisuserdata(o), &(o)->value.gc->u) +#define uvalue(o) (&rawuvalue(o)->uv) +#define clvalue(o) check_exp(ttisfunction(o), &(o)->value.gc->cl) +#define hvalue(o) check_exp(ttistable(o), &(o)->value.gc->h) +#define bvalue(o) check_exp(ttisboolean(o), (o)->value.b) +#define thvalue(o) check_exp(ttisthread(o), &(o)->value.gc->th) + +#define l_isfalse(o) (ttisnil(o) || (ttisboolean(o) && bvalue(o) == 0)) + +/* +** for internal debug only +*/ +#define checkconsistency(obj) \ + lua_assert(!iscollectable(obj) || (ttype(obj) == (obj)->value.gc->gch.tt)) + +#define checkliveness(g,obj) \ + lua_assert(!iscollectable(obj) || \ + ((ttype(obj) == (obj)->value.gc->gch.tt) && !isdead(g, (obj)->value.gc))) + + +/* Macros to set values */ +#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) + +#define setnvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.n=(x); i_o->tt=LUA_TNUMBER; } + +#define setpvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.p=(x); i_o->tt=LUA_TLIGHTUSERDATA; } + +#define setbvalue(obj,x) \ + { TValue *i_o=(obj); i_o->value.b=(x); i_o->tt=LUA_TBOOLEAN; } + +#define setsvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TSTRING; \ + checkliveness(G(L),i_o); } + +#define setuvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUSERDATA; \ + checkliveness(G(L),i_o); } + +#define setthvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTHREAD; \ + checkliveness(G(L),i_o); } + +#define setclvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TFUNCTION; \ + checkliveness(G(L),i_o); } + +#define sethvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TTABLE; \ + checkliveness(G(L),i_o); } + +#define setptvalue(L,obj,x) \ + { TValue *i_o=(obj); \ + i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TPROTO; \ + checkliveness(G(L),i_o); } + + + + +#define setobj(L,obj1,obj2) \ + { const TValue *o2=(obj2); TValue *o1=(obj1); \ + o1->value = o2->value; o1->tt=o2->tt; \ + checkliveness(G(L),o1); } + + +/* +** different types of sets, according to destination +*/ + +/* from stack to (same) stack */ +#define setobjs2s setobj +/* to stack (not from same stack) */ +#define setobj2s setobj +#define setsvalue2s setsvalue +#define sethvalue2s sethvalue +#define setptvalue2s setptvalue +/* from table to same table */ +#define setobjt2t setobj +/* to table */ +#define setobj2t setobj +/* to new object */ +#define setobj2n setobj +#define setsvalue2n setsvalue + +#define setttype(obj, tt) (ttype(obj) = (tt)) + + +#define iscollectable(o) (ttype(o) >= LUA_TSTRING) + + + +typedef TValue *StkId; /* index to stack elements */ + + +/* +** String headers for string table +*/ +typedef union TString { + L_Umaxalign dummy; /* ensures maximum alignment for strings */ + struct { + CommonHeader; + lu_byte reserved; + unsigned int hash; + size_t len; + } tsv; +} TString; + + +#define getstr(ts) cast(const char *, (ts) + 1) +#define svalue(o) getstr(rawtsvalue(o)) + + + +typedef union Udata { + L_Umaxalign dummy; /* ensures maximum alignment for `local' udata */ + struct { + CommonHeader; + struct Table *metatable; + struct Table *env; + size_t len; + } uv; +} Udata; + + + + +/* +** Function Prototypes +*/ +typedef struct Proto { + CommonHeader; + TValue *k; /* constants used by the function */ + Instruction *code; + struct Proto **p; /* functions defined inside the function */ + int *lineinfo; /* map from opcodes to source lines */ + struct LocVar *locvars; /* information about local variables */ + TString **upvalues; /* upvalue names */ + TString *source; + int sizeupvalues; + int sizek; /* size of `k' */ + int sizecode; + int sizelineinfo; + int sizep; /* size of `p' */ + int sizelocvars; + int linedefined; + int lastlinedefined; + GCObject *gclist; + lu_byte nups; /* number of upvalues */ + lu_byte numparams; + lu_byte is_vararg; + lu_byte maxstacksize; +} Proto; + + +/* masks for new-style vararg */ +#define VARARG_HASARG 1 +#define VARARG_ISVARARG 2 +#define VARARG_NEEDSARG 4 + + +typedef struct LocVar { + TString *varname; + int startpc; /* first point where variable is active */ + int endpc; /* first point where variable is dead */ +} LocVar; + + + +/* +** Upvalues +*/ + +typedef struct UpVal { + CommonHeader; + TValue *v; /* points to stack or to its own value */ + union { + TValue value; /* the value (when closed) */ + struct { /* double linked list (when open) */ + struct UpVal *prev; + struct UpVal *next; + } l; + } u; +} UpVal; + + +/* +** Closures +*/ + +#define ClosureHeader \ + CommonHeader; lu_byte isC; lu_byte nupvalues; GCObject *gclist; \ + struct Table *env + +typedef struct CClosure { + ClosureHeader; + lua_CFunction f; + TValue upvalue[1]; +} CClosure; + + +typedef struct LClosure { + ClosureHeader; + struct Proto *p; + UpVal *upvals[1]; +} LClosure; + + +typedef union Closure { + CClosure c; + LClosure l; +} Closure; + + +#define iscfunction(o) (ttype(o) == LUA_TFUNCTION && clvalue(o)->c.isC) +#define isLfunction(o) (ttype(o) == LUA_TFUNCTION && !clvalue(o)->c.isC) + + +/* +** Tables +*/ + +typedef union TKey { + struct { + TValuefields; + struct Node *next; /* for chaining */ + } nk; + TValue tvk; +} TKey; + + +typedef struct Node { + TValue i_val; + TKey i_key; +} Node; + + +typedef struct Table { + CommonHeader; + lu_byte flags; /* 1<

lsizenode)) + + +#define luaO_nilobject (&luaO_nilobject_) + +LUAI_DATA const TValue luaO_nilobject_; + +#define ceillog2(x) (luaO_log2((x)-1) + 1) + +LUAI_FUNC int luaO_log2 (unsigned int x); +LUAI_FUNC int luaO_int2fb (unsigned int x); +LUAI_FUNC int luaO_fb2int (int x); +LUAI_FUNC int luaO_rawequalObj (const TValue *t1, const TValue *t2); +LUAI_FUNC int luaO_str2d (const char *s, lua_Number *result); +LUAI_FUNC const char *luaO_pushvfstring (lua_State *L, const char *fmt, + va_list argp); +LUAI_FUNC const char *luaO_pushfstring (lua_State *L, const char *fmt, ...); +LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len); + + +#endif + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lopcodes.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lopcodes.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lopcodes.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lopcodes.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,102 @@ +/* +** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** See Copyright Notice in lua.h +*/ + + +#define lopcodes_c +#define LUA_CORE + + +#include "lopcodes.h" + + +/* ORDER OP */ + +const char *const luaP_opnames[NUM_OPCODES+1] = { + "MOVE", + "LOADK", + "LOADBOOL", + "LOADNIL", + "GETUPVAL", + "GETGLOBAL", + "GETTABLE", + "SETGLOBAL", + "SETUPVAL", + "SETTABLE", + "NEWTABLE", + "SELF", + "ADD", + "SUB", + "MUL", + "DIV", + "MOD", + "POW", + "UNM", + "NOT", + "LEN", + "CONCAT", + "JMP", + "EQ", + "LT", + "LE", + "TEST", + "TESTSET", + "CALL", + "TAILCALL", + "RETURN", + "FORLOOP", + "FORPREP", + "TFORLOOP", + "SETLIST", + "CLOSE", + "CLOSURE", + "VARARG", + NULL +}; + + +#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) + +const lu_byte luaP_opmodes[NUM_OPCODES] = { +/* T A B C mode opcode */ + opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ + ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_GETGLOBAL */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ + ,opmode(0, 0, OpArgK, OpArgN, iABx) /* OP_SETGLOBAL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ + ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ + ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ + ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ + ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ + ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ + ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ + ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TEST */ + ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ + ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ + ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ + ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ + ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TFORLOOP */ + ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ + ,opmode(0, 0, OpArgN, OpArgN, iABC) /* OP_CLOSE */ + ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ + ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ +}; + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lopcodes.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lopcodes.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lopcodes.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lopcodes.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,268 @@ +/* +** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $ +** Opcodes for Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lopcodes_h +#define lopcodes_h + +#include "llimits.h" + + +/*=========================================================================== + We assume that instructions are unsigned numbers. + All instructions have an opcode in the first 6 bits. + Instructions can have the following fields: + `A' : 8 bits + `B' : 9 bits + `C' : 9 bits + `Bx' : 18 bits (`B' and `C' together) + `sBx' : signed Bx + + A signed argument is represented in excess K; that is, the number + value is the unsigned value minus K. K is exactly the maximum value + for that argument (so that -max is represented by 0, and +max is + represented by 2*max), which is half the maximum for the corresponding + unsigned argument. +===========================================================================*/ + + +enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ + + +/* +** size and position of opcode arguments. +*/ +#define SIZE_C 9 +#define SIZE_B 9 +#define SIZE_Bx (SIZE_C + SIZE_B) +#define SIZE_A 8 + +#define SIZE_OP 6 + +#define POS_OP 0 +#define POS_A (POS_OP + SIZE_OP) +#define POS_C (POS_A + SIZE_A) +#define POS_B (POS_C + SIZE_C) +#define POS_Bx POS_C + + +/* +** limits for opcode arguments. +** we use (signed) int to manipulate most arguments, +** so they must fit in LUAI_BITSINT-1 bits (-1 for sign) +*/ +#if SIZE_Bx < LUAI_BITSINT-1 +#define MAXARG_Bx ((1<>1) /* `sBx' is signed */ +#else +#define MAXARG_Bx MAX_INT +#define MAXARG_sBx MAX_INT +#endif + + +#define MAXARG_A ((1<>POS_OP) & MASK1(SIZE_OP,0))) +#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ + ((cast(Instruction, o)<>POS_A) & MASK1(SIZE_A,0))) +#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ + ((cast(Instruction, u)<>POS_B) & MASK1(SIZE_B,0))) +#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ + ((cast(Instruction, b)<>POS_C) & MASK1(SIZE_C,0))) +#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ + ((cast(Instruction, b)<>POS_Bx) & MASK1(SIZE_Bx,0))) +#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ + ((cast(Instruction, b)< C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ + +OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ +OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ + +OP_FORLOOP,/* A sBx R(A)+=R(A+2); + if R(A) =) R(A)*/ +OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ + +OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ +} OpCode; + + +#define NUM_OPCODES (cast(int, OP_VARARG) + 1) + + + +/*=========================================================================== + Notes: + (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, + and can be 0: OP_CALL then sets `top' to last_result+1, so + next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. + + (*) In OP_VARARG, if (B == 0) then use actual number of varargs and + set top (like in OP_CALL with C == 0). + + (*) In OP_RETURN, if (B == 0) then return up to `top' + + (*) In OP_SETLIST, if (B == 0) then B = `top'; + if (C == 0) then next `instruction' is real C + + (*) For comparisons, A specifies what condition the test should accept + (true or false). + + (*) All `skips' (pc++) assume that next instruction is a jump +===========================================================================*/ + + +/* +** masks for instruction properties. The format is: +** bits 0-1: op mode +** bits 2-3: C arg mode +** bits 4-5: B arg mode +** bit 6: instruction set register A +** bit 7: operator is a test +*/ + +enum OpArgMask { + OpArgN, /* argument is not used */ + OpArgU, /* argument is used */ + OpArgR, /* argument is a register or a jump offset */ + OpArgK /* argument is a constant or register/constant */ +}; + +LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]; + +#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3)) +#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3)) +#define getCMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3)) +#define testAMode(m) (luaP_opmodes[m] & (1 << 6)) +#define testTMode(m) (luaP_opmodes[m] & (1 << 7)) + + +LUAI_DATA const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */ + + +/* number of list items to accumulate before a SETLIST instruction */ +#define LFIELDS_PER_FLUSH 50 + + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/loslib.c.svn-base blobby-0.9c/src/lua/.svn/text-base/loslib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/loslib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/loslib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,243 @@ +/* +** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $ +** Standard Operating System library +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define loslib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +static int os_pushresult (lua_State *L, int i, const char *filename) { + int en = errno; /* calls to Lua API may change this value */ + if (i) { + lua_pushboolean(L, 1); + return 1; + } + else { + lua_pushnil(L); + lua_pushfstring(L, "%s: %s", filename, strerror(en)); + lua_pushinteger(L, en); + return 3; + } +} + + +static int os_execute (lua_State *L) { + lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); + return 1; +} + + +static int os_remove (lua_State *L) { + const char *filename = luaL_checkstring(L, 1); + return os_pushresult(L, remove(filename) == 0, filename); +} + + +static int os_rename (lua_State *L) { + const char *fromname = luaL_checkstring(L, 1); + const char *toname = luaL_checkstring(L, 2); + return os_pushresult(L, rename(fromname, toname) == 0, fromname); +} + + +static int os_tmpname (lua_State *L) { + char buff[LUA_TMPNAMBUFSIZE]; + int err; + lua_tmpnam(buff, err); + if (err) + return luaL_error(L, "unable to generate a unique filename"); + lua_pushstring(L, buff); + return 1; +} + + +static int os_getenv (lua_State *L) { + lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ + return 1; +} + + +static int os_clock (lua_State *L) { + lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); + return 1; +} + + +/* +** {====================================================== +** Time/Date operations +** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S, +** wday=%w+1, yday=%j, isdst=? } +** ======================================================= +*/ + +static void setfield (lua_State *L, const char *key, int value) { + lua_pushinteger(L, value); + lua_setfield(L, -2, key); +} + +static void setboolfield (lua_State *L, const char *key, int value) { + if (value < 0) /* undefined? */ + return; /* does not set field */ + lua_pushboolean(L, value); + lua_setfield(L, -2, key); +} + +static int getboolfield (lua_State *L, const char *key) { + int res; + lua_getfield(L, -1, key); + res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1); + lua_pop(L, 1); + return res; +} + + +static int getfield (lua_State *L, const char *key, int d) { + int res; + lua_getfield(L, -1, key); + if (lua_isnumber(L, -1)) + res = (int)lua_tointeger(L, -1); + else { + if (d < 0) + return luaL_error(L, "field " LUA_QS " missing in date table", key); + res = d; + } + lua_pop(L, 1); + return res; +} + + +static int os_date (lua_State *L) { + const char *s = luaL_optstring(L, 1, "%c"); + time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL)); + struct tm *stm; + if (*s == '!') { /* UTC? */ + stm = gmtime(&t); + s++; /* skip `!' */ + } + else + stm = localtime(&t); + if (stm == NULL) /* invalid date? */ + lua_pushnil(L); + else if (strcmp(s, "*t") == 0) { + lua_createtable(L, 0, 9); /* 9 = number of fields */ + setfield(L, "sec", stm->tm_sec); + setfield(L, "min", stm->tm_min); + setfield(L, "hour", stm->tm_hour); + setfield(L, "day", stm->tm_mday); + setfield(L, "month", stm->tm_mon+1); + setfield(L, "year", stm->tm_year+1900); + setfield(L, "wday", stm->tm_wday+1); + setfield(L, "yday", stm->tm_yday+1); + setboolfield(L, "isdst", stm->tm_isdst); + } + else { + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ + luaL_addchar(&b, *s); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); + } + return 1; +} + + +static int os_time (lua_State *L) { + time_t t; + if (lua_isnoneornil(L, 1)) /* called without args? */ + t = time(NULL); /* get current time */ + else { + struct tm ts; + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); /* make sure table is at the top */ + ts.tm_sec = getfield(L, "sec", 0); + ts.tm_min = getfield(L, "min", 0); + ts.tm_hour = getfield(L, "hour", 12); + ts.tm_mday = getfield(L, "day", -1); + ts.tm_mon = getfield(L, "month", -1) - 1; + ts.tm_year = getfield(L, "year", -1) - 1900; + ts.tm_isdst = getboolfield(L, "isdst"); + t = mktime(&ts); + } + if (t == (time_t)(-1)) + lua_pushnil(L); + else + lua_pushnumber(L, (lua_Number)t); + return 1; +} + + +static int os_difftime (lua_State *L) { + lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), + (time_t)(luaL_optnumber(L, 2, 0)))); + return 1; +} + +/* }====================================================== */ + + +static int os_setlocale (lua_State *L) { + static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME}; + static const char *const catnames[] = {"all", "collate", "ctype", "monetary", + "numeric", "time", NULL}; + const char *l = luaL_optstring(L, 1, NULL); + int op = luaL_checkoption(L, 2, "all", catnames); + lua_pushstring(L, setlocale(cat[op], l)); + return 1; +} + + +static int os_exit (lua_State *L) { + exit(luaL_optint(L, 1, EXIT_SUCCESS)); +} + +static const luaL_Reg syslib[] = { + {"clock", os_clock}, + {"date", os_date}, + {"difftime", os_difftime}, + {"execute", os_execute}, + {"exit", os_exit}, + {"getenv", os_getenv}, + {"remove", os_remove}, + {"rename", os_rename}, + {"setlocale", os_setlocale}, + {"time", os_time}, + {"tmpname", os_tmpname}, + {NULL, NULL} +}; + +/* }====================================================== */ + + + +LUALIB_API int luaopen_os (lua_State *L) { + luaL_register(L, LUA_OSLIBNAME, syslib); + return 1; +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lparser.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lparser.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lparser.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lparser.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,1339 @@ +/* +** $Id: lparser.c,v 2.42.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + + +#include + +#define lparser_c +#define LUA_CORE + +#include "lua.h" + +#include "lcode.h" +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "llex.h" +#include "lmem.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lparser.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" + + + +#define hasmultret(k) ((k) == VCALL || (k) == VVARARG) + +#define getlocvar(fs, i) ((fs)->f->locvars[(fs)->actvar[i]]) + +#define luaY_checklimit(fs,v,l,m) if ((v)>(l)) errorlimit(fs,l,m) + + +/* +** nodes for block list (list of active blocks) +*/ +typedef struct BlockCnt { + struct BlockCnt *previous; /* chain */ + int breaklist; /* list of jumps out of this loop */ + lu_byte nactvar; /* # active locals outside the breakable structure */ + lu_byte upval; /* true if some variable in the block is an upvalue */ + lu_byte isbreakable; /* true if `block' is a loop */ +} BlockCnt; + + + +/* +** prototypes for recursive non-terminal functions +*/ +static void chunk (LexState *ls); +static void expr (LexState *ls, expdesc *v); + + +static void anchor_token (LexState *ls) { + if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) { + TString *ts = ls->t.seminfo.ts; + luaX_newstring(ls, getstr(ts), ts->tsv.len); + } +} + + +static void error_expected (LexState *ls, int token) { + luaX_syntaxerror(ls, + luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token))); +} + + +static void errorlimit (FuncState *fs, int limit, const char *what) { + const char *msg = (fs->f->linedefined == 0) ? + luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : + luaO_pushfstring(fs->L, "function at line %d has more than %d %s", + fs->f->linedefined, limit, what); + luaX_lexerror(fs->ls, msg, 0); +} + + +static int testnext (LexState *ls, int c) { + if (ls->t.token == c) { + luaX_next(ls); + return 1; + } + else return 0; +} + + +static void check (LexState *ls, int c) { + if (ls->t.token != c) + error_expected(ls, c); +} + +static void checknext (LexState *ls, int c) { + check(ls, c); + luaX_next(ls); +} + + +#define check_condition(ls,c,msg) { if (!(c)) luaX_syntaxerror(ls, msg); } + + + +static void check_match (LexState *ls, int what, int who, int where) { + if (!testnext(ls, what)) { + if (where == ls->linenumber) + error_expected(ls, what); + else { + luaX_syntaxerror(ls, luaO_pushfstring(ls->L, + LUA_QS " expected (to close " LUA_QS " at line %d)", + luaX_token2str(ls, what), luaX_token2str(ls, who), where)); + } + } +} + + +static TString *str_checkname (LexState *ls) { + TString *ts; + check(ls, TK_NAME); + ts = ls->t.seminfo.ts; + luaX_next(ls); + return ts; +} + + +static void init_exp (expdesc *e, expkind k, int i) { + e->f = e->t = NO_JUMP; + e->k = k; + e->u.s.info = i; +} + + +static void codestring (LexState *ls, expdesc *e, TString *s) { + init_exp(e, VK, luaK_stringK(ls->fs, s)); +} + + +static void checkname(LexState *ls, expdesc *e) { + codestring(ls, e, str_checkname(ls)); +} + + +static int registerlocalvar (LexState *ls, TString *varname) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizelocvars; + luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, + LocVar, SHRT_MAX, "too many local variables"); + while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; + f->locvars[fs->nlocvars].varname = varname; + luaC_objbarrier(ls->L, f, varname); + return fs->nlocvars++; +} + + +#define new_localvarliteral(ls,v,n) \ + new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n) + + +static void new_localvar (LexState *ls, TString *name, int n) { + FuncState *fs = ls->fs; + luaY_checklimit(fs, fs->nactvar+n+1, LUAI_MAXVARS, "local variables"); + fs->actvar[fs->nactvar+n] = cast(unsigned short, registerlocalvar(ls, name)); +} + + +static void adjustlocalvars (LexState *ls, int nvars) { + FuncState *fs = ls->fs; + fs->nactvar = cast_byte(fs->nactvar + nvars); + for (; nvars; nvars--) { + getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; + } +} + + +static void removevars (LexState *ls, int tolevel) { + FuncState *fs = ls->fs; + while (fs->nactvar > tolevel) + getlocvar(fs, --fs->nactvar).endpc = fs->pc; +} + + +static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { + int i; + Proto *f = fs->f; + int oldsize = f->sizeupvalues; + for (i=0; inups; i++) { + if (fs->upvalues[i].k == v->k && fs->upvalues[i].info == v->u.s.info) { + lua_assert(f->upvalues[i] == name); + return i; + } + } + /* new one */ + luaY_checklimit(fs, f->nups + 1, LUAI_MAXUPVALUES, "upvalues"); + luaM_growvector(fs->L, f->upvalues, f->nups, f->sizeupvalues, + TString *, MAX_INT, ""); + while (oldsize < f->sizeupvalues) f->upvalues[oldsize++] = NULL; + f->upvalues[f->nups] = name; + luaC_objbarrier(fs->L, f, name); + lua_assert(v->k == VLOCAL || v->k == VUPVAL); + fs->upvalues[f->nups].k = cast_byte(v->k); + fs->upvalues[f->nups].info = cast_byte(v->u.s.info); + return f->nups++; +} + + +static int searchvar (FuncState *fs, TString *n) { + int i; + for (i=fs->nactvar-1; i >= 0; i--) { + if (n == getlocvar(fs, i).varname) + return i; + } + return -1; /* not found */ +} + + +static void markupval (FuncState *fs, int level) { + BlockCnt *bl = fs->bl; + while (bl && bl->nactvar > level) bl = bl->previous; + if (bl) bl->upval = 1; +} + + +static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { + if (fs == NULL) { /* no more levels? */ + init_exp(var, VGLOBAL, NO_REG); /* default is global variable */ + return VGLOBAL; + } + else { + int v = searchvar(fs, n); /* look up at current level */ + if (v >= 0) { + init_exp(var, VLOCAL, v); + if (!base) + markupval(fs, v); /* local will be used as an upval */ + return VLOCAL; + } + else { /* not found at current level; try upper one */ + if (singlevaraux(fs->prev, n, var, 0) == VGLOBAL) + return VGLOBAL; + var->u.s.info = indexupvalue(fs, n, var); /* else was LOCAL or UPVAL */ + var->k = VUPVAL; /* upvalue in this level */ + return VUPVAL; + } + } +} + + +static void singlevar (LexState *ls, expdesc *var) { + TString *varname = str_checkname(ls); + FuncState *fs = ls->fs; + if (singlevaraux(fs, varname, var, 1) == VGLOBAL) + var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ +} + + +static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { + FuncState *fs = ls->fs; + int extra = nvars - nexps; + if (hasmultret(e->k)) { + extra++; /* includes call itself */ + if (extra < 0) extra = 0; + luaK_setreturns(fs, e, extra); /* last exp. provides the difference */ + if (extra > 1) luaK_reserveregs(fs, extra-1); + } + else { + if (e->k != VVOID) luaK_exp2nextreg(fs, e); /* close last expression */ + if (extra > 0) { + int reg = fs->freereg; + luaK_reserveregs(fs, extra); + luaK_nil(fs, reg, extra); + } + } +} + + +static void enterlevel (LexState *ls) { + if (++ls->L->nCcalls > LUAI_MAXCCALLS) + luaX_lexerror(ls, "chunk has too many syntax levels", 0); +} + + +#define leavelevel(ls) ((ls)->L->nCcalls--) + + +static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) { + bl->breaklist = NO_JUMP; + bl->isbreakable = isbreakable; + bl->nactvar = fs->nactvar; + bl->upval = 0; + bl->previous = fs->bl; + fs->bl = bl; + lua_assert(fs->freereg == fs->nactvar); +} + + +static void leaveblock (FuncState *fs) { + BlockCnt *bl = fs->bl; + fs->bl = bl->previous; + removevars(fs->ls, bl->nactvar); + if (bl->upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + /* a block either controls scope or breaks (never both) */ + lua_assert(!bl->isbreakable || !bl->upval); + lua_assert(bl->nactvar == fs->nactvar); + fs->freereg = fs->nactvar; /* free registers */ + luaK_patchtohere(fs, bl->breaklist); +} + + +static void pushclosure (LexState *ls, FuncState *func, expdesc *v) { + FuncState *fs = ls->fs; + Proto *f = fs->f; + int oldsize = f->sizep; + int i; + luaM_growvector(ls->L, f->p, fs->np, f->sizep, Proto *, + MAXARG_Bx, "constant table overflow"); + while (oldsize < f->sizep) f->p[oldsize++] = NULL; + f->p[fs->np++] = func->f; + luaC_objbarrier(ls->L, f, func->f); + init_exp(v, VRELOCABLE, luaK_codeABx(fs, OP_CLOSURE, 0, fs->np-1)); + for (i=0; if->nups; i++) { + OpCode o = (func->upvalues[i].k == VLOCAL) ? OP_MOVE : OP_GETUPVAL; + luaK_codeABC(fs, o, 0, func->upvalues[i].info, 0); + } +} + + +static void open_func (LexState *ls, FuncState *fs) { + lua_State *L = ls->L; + Proto *f = luaF_newproto(L); + fs->f = f; + fs->prev = ls->fs; /* linked list of funcstates */ + fs->ls = ls; + fs->L = L; + ls->fs = fs; + fs->pc = 0; + fs->lasttarget = -1; + fs->jpc = NO_JUMP; + fs->freereg = 0; + fs->nk = 0; + fs->np = 0; + fs->nlocvars = 0; + fs->nactvar = 0; + fs->bl = NULL; + f->source = ls->source; + f->maxstacksize = 2; /* registers 0/1 are always valid */ + fs->h = luaH_new(L, 0, 0); + /* anchor table of constants and prototype (to avoid being collected) */ + sethvalue2s(L, L->top, fs->h); + incr_top(L); + setptvalue2s(L, L->top, f); + incr_top(L); +} + + +static void close_func (LexState *ls) { + lua_State *L = ls->L; + FuncState *fs = ls->fs; + Proto *f = fs->f; + removevars(ls, 0); + luaK_ret(fs, 0, 0); /* final return */ + luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); + f->sizecode = fs->pc; + luaM_reallocvector(L, f->lineinfo, f->sizelineinfo, fs->pc, int); + f->sizelineinfo = fs->pc; + luaM_reallocvector(L, f->k, f->sizek, fs->nk, TValue); + f->sizek = fs->nk; + luaM_reallocvector(L, f->p, f->sizep, fs->np, Proto *); + f->sizep = fs->np; + luaM_reallocvector(L, f->locvars, f->sizelocvars, fs->nlocvars, LocVar); + f->sizelocvars = fs->nlocvars; + luaM_reallocvector(L, f->upvalues, f->sizeupvalues, f->nups, TString *); + f->sizeupvalues = f->nups; + lua_assert(luaG_checkcode(f)); + lua_assert(fs->bl == NULL); + ls->fs = fs->prev; + L->top -= 2; /* remove table and prototype from the stack */ + /* last token read was anchored in defunct function; must reanchor it */ + if (fs) anchor_token(ls); +} + + +Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { + struct LexState lexstate; + struct FuncState funcstate; + lexstate.buff = buff; + luaX_setinput(L, &lexstate, z, luaS_new(L, name)); + open_func(&lexstate, &funcstate); + funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */ + luaX_next(&lexstate); /* read first token */ + chunk(&lexstate); + check(&lexstate, TK_EOS); + close_func(&lexstate); + lua_assert(funcstate.prev == NULL); + lua_assert(funcstate.f->nups == 0); + lua_assert(lexstate.fs == NULL); + return funcstate.f; +} + + + +/*============================================================*/ +/* GRAMMAR RULES */ +/*============================================================*/ + + +static void field (LexState *ls, expdesc *v) { + /* field -> ['.' | ':'] NAME */ + FuncState *fs = ls->fs; + expdesc key; + luaK_exp2anyreg(fs, v); + luaX_next(ls); /* skip the dot or colon */ + checkname(ls, &key); + luaK_indexed(fs, v, &key); +} + + +static void yindex (LexState *ls, expdesc *v) { + /* index -> '[' expr ']' */ + luaX_next(ls); /* skip the '[' */ + expr(ls, v); + luaK_exp2val(ls->fs, v); + checknext(ls, ']'); +} + + +/* +** {====================================================================== +** Rules for Constructors +** ======================================================================= +*/ + + +struct ConsControl { + expdesc v; /* last list item read */ + expdesc *t; /* table descriptor */ + int nh; /* total number of `record' elements */ + int na; /* total number of array elements */ + int tostore; /* number of array elements pending to be stored */ +}; + + +static void recfield (LexState *ls, struct ConsControl *cc) { + /* recfield -> (NAME | `['exp1`]') = exp1 */ + FuncState *fs = ls->fs; + int reg = ls->fs->freereg; + expdesc key, val; + int rkkey; + if (ls->t.token == TK_NAME) { + luaY_checklimit(fs, cc->nh, MAX_INT, "items in a constructor"); + checkname(ls, &key); + } + else /* ls->t.token == '[' */ + yindex(ls, &key); + cc->nh++; + checknext(ls, '='); + rkkey = luaK_exp2RK(fs, &key); + expr(ls, &val); + luaK_codeABC(fs, OP_SETTABLE, cc->t->u.s.info, rkkey, luaK_exp2RK(fs, &val)); + fs->freereg = reg; /* free registers */ +} + + +static void closelistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->v.k == VVOID) return; /* there is no list item */ + luaK_exp2nextreg(fs, &cc->v); + cc->v.k = VVOID; + if (cc->tostore == LFIELDS_PER_FLUSH) { + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); /* flush */ + cc->tostore = 0; /* no more items pending */ + } +} + + +static void lastlistfield (FuncState *fs, struct ConsControl *cc) { + if (cc->tostore == 0) return; + if (hasmultret(cc->v.k)) { + luaK_setmultret(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, LUA_MULTRET); + cc->na--; /* do not count last expression (unknown number of elements) */ + } + else { + if (cc->v.k != VVOID) + luaK_exp2nextreg(fs, &cc->v); + luaK_setlist(fs, cc->t->u.s.info, cc->na, cc->tostore); + } +} + + +static void listfield (LexState *ls, struct ConsControl *cc) { + expr(ls, &cc->v); + luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); + cc->na++; + cc->tostore++; +} + + +static void constructor (LexState *ls, expdesc *t) { + /* constructor -> ?? */ + FuncState *fs = ls->fs; + int line = ls->linenumber; + int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0); + struct ConsControl cc; + cc.na = cc.nh = cc.tostore = 0; + cc.t = t; + init_exp(t, VRELOCABLE, pc); + init_exp(&cc.v, VVOID, 0); /* no value (yet) */ + luaK_exp2nextreg(ls->fs, t); /* fix it at stack top (for gc) */ + checknext(ls, '{'); + do { + lua_assert(cc.v.k == VVOID || cc.tostore > 0); + if (ls->t.token == '}') break; + closelistfield(fs, &cc); + switch(ls->t.token) { + case TK_NAME: { /* may be listfields or recfields */ + luaX_lookahead(ls); + if (ls->lookahead.token != '=') /* expression? */ + listfield(ls, &cc); + else + recfield(ls, &cc); + break; + } + case '[': { /* constructor_item -> recfield */ + recfield(ls, &cc); + break; + } + default: { /* constructor_part -> listfield */ + listfield(ls, &cc); + break; + } + } + } while (testnext(ls, ',') || testnext(ls, ';')); + check_match(ls, '}', '{', line); + lastlistfield(fs, &cc); + SETARG_B(fs->f->code[pc], luaO_int2fb(cc.na)); /* set initial array size */ + SETARG_C(fs->f->code[pc], luaO_int2fb(cc.nh)); /* set initial table size */ +} + +/* }====================================================================== */ + + + +static void parlist (LexState *ls) { + /* parlist -> [ param { `,' param } ] */ + FuncState *fs = ls->fs; + Proto *f = fs->f; + int nparams = 0; + f->is_vararg = 0; + if (ls->t.token != ')') { /* is `parlist' not empty? */ + do { + switch (ls->t.token) { + case TK_NAME: { /* param -> NAME */ + new_localvar(ls, str_checkname(ls), nparams++); + break; + } + case TK_DOTS: { /* param -> `...' */ + luaX_next(ls); +#if defined(LUA_COMPAT_VARARG) + /* use `arg' as default name */ + new_localvarliteral(ls, "arg", nparams++); + f->is_vararg = VARARG_HASARG | VARARG_NEEDSARG; +#endif + f->is_vararg |= VARARG_ISVARARG; + break; + } + default: luaX_syntaxerror(ls, " or " LUA_QL("...") " expected"); + } + } while (!f->is_vararg && testnext(ls, ',')); + } + adjustlocalvars(ls, nparams); + f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); + luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ +} + + +static void body (LexState *ls, expdesc *e, int needself, int line) { + /* body -> `(' parlist `)' chunk END */ + FuncState new_fs; + open_func(ls, &new_fs); + new_fs.f->linedefined = line; + checknext(ls, '('); + if (needself) { + new_localvarliteral(ls, "self", 0); + adjustlocalvars(ls, 1); + } + parlist(ls); + checknext(ls, ')'); + chunk(ls); + new_fs.f->lastlinedefined = ls->linenumber; + check_match(ls, TK_END, TK_FUNCTION, line); + close_func(ls); + pushclosure(ls, &new_fs, e); +} + + +static int explist1 (LexState *ls, expdesc *v) { + /* explist1 -> expr { `,' expr } */ + int n = 1; /* at least one expression */ + expr(ls, v); + while (testnext(ls, ',')) { + luaK_exp2nextreg(ls->fs, v); + expr(ls, v); + n++; + } + return n; +} + + +static void funcargs (LexState *ls, expdesc *f) { + FuncState *fs = ls->fs; + expdesc args; + int base, nparams; + int line = ls->linenumber; + switch (ls->t.token) { + case '(': { /* funcargs -> `(' [ explist1 ] `)' */ + if (line != ls->lastline) + luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)"); + luaX_next(ls); + if (ls->t.token == ')') /* arg list is empty? */ + args.k = VVOID; + else { + explist1(ls, &args); + luaK_setmultret(fs, &args); + } + check_match(ls, ')', '(', line); + break; + } + case '{': { /* funcargs -> constructor */ + constructor(ls, &args); + break; + } + case TK_STRING: { /* funcargs -> STRING */ + codestring(ls, &args, ls->t.seminfo.ts); + luaX_next(ls); /* must use `seminfo' before `next' */ + break; + } + default: { + luaX_syntaxerror(ls, "function arguments expected"); + return; + } + } + lua_assert(f->k == VNONRELOC); + base = f->u.s.info; /* base register for call */ + if (hasmultret(args.k)) + nparams = LUA_MULTRET; /* open call */ + else { + if (args.k != VVOID) + luaK_exp2nextreg(fs, &args); /* close last argument */ + nparams = fs->freereg - (base+1); + } + init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2)); + luaK_fixline(fs, line); + fs->freereg = base+1; /* call remove function and arguments and leaves + (unless changed) one result */ +} + + + + +/* +** {====================================================================== +** Expression parsing +** ======================================================================= +*/ + + +static void prefixexp (LexState *ls, expdesc *v) { + /* prefixexp -> NAME | '(' expr ')' */ + switch (ls->t.token) { + case '(': { + int line = ls->linenumber; + luaX_next(ls); + expr(ls, v); + check_match(ls, ')', '(', line); + luaK_dischargevars(ls->fs, v); + return; + } + case TK_NAME: { + singlevar(ls, v); + return; + } + default: { + luaX_syntaxerror(ls, "unexpected symbol"); + return; + } + } +} + + +static void primaryexp (LexState *ls, expdesc *v) { + /* primaryexp -> + prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */ + FuncState *fs = ls->fs; + prefixexp(ls, v); + for (;;) { + switch (ls->t.token) { + case '.': { /* field */ + field(ls, v); + break; + } + case '[': { /* `[' exp1 `]' */ + expdesc key; + luaK_exp2anyreg(fs, v); + yindex(ls, &key); + luaK_indexed(fs, v, &key); + break; + } + case ':': { /* `:' NAME funcargs */ + expdesc key; + luaX_next(ls); + checkname(ls, &key); + luaK_self(fs, v, &key); + funcargs(ls, v); + break; + } + case '(': case TK_STRING: case '{': { /* funcargs */ + luaK_exp2nextreg(fs, v); + funcargs(ls, v); + break; + } + default: return; + } + } +} + + +static void simpleexp (LexState *ls, expdesc *v) { + /* simpleexp -> NUMBER | STRING | NIL | true | false | ... | + constructor | FUNCTION body | primaryexp */ + switch (ls->t.token) { + case TK_NUMBER: { + init_exp(v, VKNUM, 0); + v->u.nval = ls->t.seminfo.r; + break; + } + case TK_STRING: { + codestring(ls, v, ls->t.seminfo.ts); + break; + } + case TK_NIL: { + init_exp(v, VNIL, 0); + break; + } + case TK_TRUE: { + init_exp(v, VTRUE, 0); + break; + } + case TK_FALSE: { + init_exp(v, VFALSE, 0); + break; + } + case TK_DOTS: { /* vararg */ + FuncState *fs = ls->fs; + check_condition(ls, fs->f->is_vararg, + "cannot use " LUA_QL("...") " outside a vararg function"); + fs->f->is_vararg &= ~VARARG_NEEDSARG; /* don't need 'arg' */ + init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); + break; + } + case '{': { /* constructor */ + constructor(ls, v); + return; + } + case TK_FUNCTION: { + luaX_next(ls); + body(ls, v, 0, ls->linenumber); + return; + } + default: { + primaryexp(ls, v); + return; + } + } + luaX_next(ls); +} + + +static UnOpr getunopr (int op) { + switch (op) { + case TK_NOT: return OPR_NOT; + case '-': return OPR_MINUS; + case '#': return OPR_LEN; + default: return OPR_NOUNOPR; + } +} + + +static BinOpr getbinopr (int op) { + switch (op) { + case '+': return OPR_ADD; + case '-': return OPR_SUB; + case '*': return OPR_MUL; + case '/': return OPR_DIV; + case '%': return OPR_MOD; + case '^': return OPR_POW; + case TK_CONCAT: return OPR_CONCAT; + case TK_NE: return OPR_NE; + case TK_EQ: return OPR_EQ; + case '<': return OPR_LT; + case TK_LE: return OPR_LE; + case '>': return OPR_GT; + case TK_GE: return OPR_GE; + case TK_AND: return OPR_AND; + case TK_OR: return OPR_OR; + default: return OPR_NOBINOPR; + } +} + + +static const struct { + lu_byte left; /* left priority for each binary operator */ + lu_byte right; /* right priority */ +} priority[] = { /* ORDER OPR */ + {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ + {10, 9}, {5, 4}, /* power and concat (right associative) */ + {3, 3}, {3, 3}, /* equality and inequality */ + {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ + {2, 2}, {1, 1} /* logical (and/or) */ +}; + +#define UNARY_PRIORITY 8 /* priority for unary operators */ + + +/* +** subexpr -> (simpleexp | unop subexpr) { binop subexpr } +** where `binop' is any binary operator with a priority higher than `limit' +*/ +static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) { + BinOpr op; + UnOpr uop; + enterlevel(ls); + uop = getunopr(ls->t.token); + if (uop != OPR_NOUNOPR) { + luaX_next(ls); + subexpr(ls, v, UNARY_PRIORITY); + luaK_prefix(ls->fs, uop, v); + } + else simpleexp(ls, v); + /* expand while operators have priorities higher than `limit' */ + op = getbinopr(ls->t.token); + while (op != OPR_NOBINOPR && priority[op].left > limit) { + expdesc v2; + BinOpr nextop; + luaX_next(ls); + luaK_infix(ls->fs, op, v); + /* read sub-expression with higher priority */ + nextop = subexpr(ls, &v2, priority[op].right); + luaK_posfix(ls->fs, op, v, &v2); + op = nextop; + } + leavelevel(ls); + return op; /* return first untreated operator */ +} + + +static void expr (LexState *ls, expdesc *v) { + subexpr(ls, v, 0); +} + +/* }==================================================================== */ + + + +/* +** {====================================================================== +** Rules for Statements +** ======================================================================= +*/ + + +static int block_follow (int token) { + switch (token) { + case TK_ELSE: case TK_ELSEIF: case TK_END: + case TK_UNTIL: case TK_EOS: + return 1; + default: return 0; + } +} + + +static void block (LexState *ls) { + /* block -> chunk */ + FuncState *fs = ls->fs; + BlockCnt bl; + enterblock(fs, &bl, 0); + chunk(ls); + lua_assert(bl.breaklist == NO_JUMP); + leaveblock(fs); +} + + +/* +** structure to chain all variables in the left-hand side of an +** assignment +*/ +struct LHS_assign { + struct LHS_assign *prev; + expdesc v; /* variable (global, local, upvalue, or indexed) */ +}; + + +/* +** check whether, in an assignment to a local variable, the local variable +** is needed in a previous assignment (to a table). If so, save original +** local value in a safe place and use this safe copy in the previous +** assignment. +*/ +static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) { + FuncState *fs = ls->fs; + int extra = fs->freereg; /* eventual position to save local variable */ + int conflict = 0; + for (; lh; lh = lh->prev) { + if (lh->v.k == VINDEXED) { + if (lh->v.u.s.info == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.info = extra; /* previous assignment will use safe copy */ + } + if (lh->v.u.s.aux == v->u.s.info) { /* conflict? */ + conflict = 1; + lh->v.u.s.aux = extra; /* previous assignment will use safe copy */ + } + } + } + if (conflict) { + luaK_codeABC(fs, OP_MOVE, fs->freereg, v->u.s.info, 0); /* make copy */ + luaK_reserveregs(fs, 1); + } +} + + +static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) { + expdesc e; + check_condition(ls, VLOCAL <= lh->v.k && lh->v.k <= VINDEXED, + "syntax error"); + if (testnext(ls, ',')) { /* assignment -> `,' primaryexp assignment */ + struct LHS_assign nv; + nv.prev = lh; + primaryexp(ls, &nv.v); + if (nv.v.k == VLOCAL) + check_conflict(ls, lh, &nv.v); + luaY_checklimit(ls->fs, nvars, LUAI_MAXCCALLS - ls->L->nCcalls, + "variables in assignment"); + assignment(ls, &nv, nvars+1); + } + else { /* assignment -> `=' explist1 */ + int nexps; + checknext(ls, '='); + nexps = explist1(ls, &e); + if (nexps != nvars) { + adjust_assign(ls, nvars, nexps, &e); + if (nexps > nvars) + ls->fs->freereg -= nexps - nvars; /* remove extra values */ + } + else { + luaK_setoneret(ls->fs, &e); /* close last expression */ + luaK_storevar(ls->fs, &lh->v, &e); + return; /* avoid default */ + } + } + init_exp(&e, VNONRELOC, ls->fs->freereg-1); /* default assignment */ + luaK_storevar(ls->fs, &lh->v, &e); +} + + +static int cond (LexState *ls) { + /* cond -> exp */ + expdesc v; + expr(ls, &v); /* read condition */ + if (v.k == VNIL) v.k = VFALSE; /* `falses' are all equal here */ + luaK_goiftrue(ls->fs, &v); + return v.f; +} + + +static void breakstat (LexState *ls) { + FuncState *fs = ls->fs; + BlockCnt *bl = fs->bl; + int upval = 0; + while (bl && !bl->isbreakable) { + upval |= bl->upval; + bl = bl->previous; + } + if (!bl) + luaX_syntaxerror(ls, "no loop to break"); + if (upval) + luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0); + luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); +} + + +static void whilestat (LexState *ls, int line) { + /* whilestat -> WHILE cond DO block END */ + FuncState *fs = ls->fs; + int whileinit; + int condexit; + BlockCnt bl; + luaX_next(ls); /* skip WHILE */ + whileinit = luaK_getlabel(fs); + condexit = cond(ls); + enterblock(fs, &bl, 1); + checknext(ls, TK_DO); + block(ls); + luaK_patchlist(fs, luaK_jump(fs), whileinit); + check_match(ls, TK_END, TK_WHILE, line); + leaveblock(fs); + luaK_patchtohere(fs, condexit); /* false conditions finish the loop */ +} + + +static void repeatstat (LexState *ls, int line) { + /* repeatstat -> REPEAT block UNTIL cond */ + int condexit; + FuncState *fs = ls->fs; + int repeat_init = luaK_getlabel(fs); + BlockCnt bl1, bl2; + enterblock(fs, &bl1, 1); /* loop block */ + enterblock(fs, &bl2, 0); /* scope block */ + luaX_next(ls); /* skip REPEAT */ + chunk(ls); + check_match(ls, TK_UNTIL, TK_REPEAT, line); + condexit = cond(ls); /* read condition (inside scope block) */ + if (!bl2.upval) { /* no upvalues? */ + leaveblock(fs); /* finish scope */ + luaK_patchlist(ls->fs, condexit, repeat_init); /* close the loop */ + } + else { /* complete semantics when there are upvalues */ + breakstat(ls); /* if condition then break */ + luaK_patchtohere(ls->fs, condexit); /* else... */ + leaveblock(fs); /* finish scope... */ + luaK_patchlist(ls->fs, luaK_jump(fs), repeat_init); /* and repeat */ + } + leaveblock(fs); /* finish loop */ +} + + +static int exp1 (LexState *ls) { + expdesc e; + int k; + expr(ls, &e); + k = e.k; + luaK_exp2nextreg(ls->fs, &e); + return k; +} + + +static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { + /* forbody -> DO block */ + BlockCnt bl; + FuncState *fs = ls->fs; + int prep, endfor; + adjustlocalvars(ls, 3); /* control variables */ + checknext(ls, TK_DO); + prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); + enterblock(fs, &bl, 0); /* scope for declared variables */ + adjustlocalvars(ls, nvars); + luaK_reserveregs(fs, nvars); + block(ls); + leaveblock(fs); /* end of scope for declared variables */ + luaK_patchtohere(fs, prep); + endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : + luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); + luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ + luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); +} + + +static void fornum (LexState *ls, TString *varname, int line) { + /* fornum -> NAME = exp1,exp1[,exp1] forbody */ + FuncState *fs = ls->fs; + int base = fs->freereg; + new_localvarliteral(ls, "(for index)", 0); + new_localvarliteral(ls, "(for limit)", 1); + new_localvarliteral(ls, "(for step)", 2); + new_localvar(ls, varname, 3); + checknext(ls, '='); + exp1(ls); /* initial value */ + checknext(ls, ','); + exp1(ls); /* limit */ + if (testnext(ls, ',')) + exp1(ls); /* optional step */ + else { /* default step = 1 */ + luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1)); + luaK_reserveregs(fs, 1); + } + forbody(ls, base, line, 1, 1); +} + + +static void forlist (LexState *ls, TString *indexname) { + /* forlist -> NAME {,NAME} IN explist1 forbody */ + FuncState *fs = ls->fs; + expdesc e; + int nvars = 0; + int line; + int base = fs->freereg; + /* create control variables */ + new_localvarliteral(ls, "(for generator)", nvars++); + new_localvarliteral(ls, "(for state)", nvars++); + new_localvarliteral(ls, "(for control)", nvars++); + /* create declared variables */ + new_localvar(ls, indexname, nvars++); + while (testnext(ls, ',')) + new_localvar(ls, str_checkname(ls), nvars++); + checknext(ls, TK_IN); + line = ls->linenumber; + adjust_assign(ls, 3, explist1(ls, &e), &e); + luaK_checkstack(fs, 3); /* extra space to call generator */ + forbody(ls, base, line, nvars - 3, 0); +} + + +static void forstat (LexState *ls, int line) { + /* forstat -> FOR (fornum | forlist) END */ + FuncState *fs = ls->fs; + TString *varname; + BlockCnt bl; + enterblock(fs, &bl, 1); /* scope for loop and control variables */ + luaX_next(ls); /* skip `for' */ + varname = str_checkname(ls); /* first variable name */ + switch (ls->t.token) { + case '=': fornum(ls, varname, line); break; + case ',': case TK_IN: forlist(ls, varname); break; + default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected"); + } + check_match(ls, TK_END, TK_FOR, line); + leaveblock(fs); /* loop scope (`break' jumps to this point) */ +} + + +static int test_then_block (LexState *ls) { + /* test_then_block -> [IF | ELSEIF] cond THEN block */ + int condexit; + luaX_next(ls); /* skip IF or ELSEIF */ + condexit = cond(ls); + checknext(ls, TK_THEN); + block(ls); /* `then' part */ + return condexit; +} + + +static void ifstat (LexState *ls, int line) { + /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */ + FuncState *fs = ls->fs; + int flist; + int escapelist = NO_JUMP; + flist = test_then_block(ls); /* IF cond THEN block */ + while (ls->t.token == TK_ELSEIF) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + flist = test_then_block(ls); /* ELSEIF cond THEN block */ + } + if (ls->t.token == TK_ELSE) { + luaK_concat(fs, &escapelist, luaK_jump(fs)); + luaK_patchtohere(fs, flist); + luaX_next(ls); /* skip ELSE (after patch, for correct line info) */ + block(ls); /* `else' part */ + } + else + luaK_concat(fs, &escapelist, flist); + luaK_patchtohere(fs, escapelist); + check_match(ls, TK_END, TK_IF, line); +} + + +static void localfunc (LexState *ls) { + expdesc v, b; + FuncState *fs = ls->fs; + new_localvar(ls, str_checkname(ls), 0); + init_exp(&v, VLOCAL, fs->freereg); + luaK_reserveregs(fs, 1); + adjustlocalvars(ls, 1); + body(ls, &b, 0, ls->linenumber); + luaK_storevar(fs, &v, &b); + /* debug information will only see the variable after this point! */ + getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; +} + + +static void localstat (LexState *ls) { + /* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */ + int nvars = 0; + int nexps; + expdesc e; + do { + new_localvar(ls, str_checkname(ls), nvars++); + } while (testnext(ls, ',')); + if (testnext(ls, '=')) + nexps = explist1(ls, &e); + else { + e.k = VVOID; + nexps = 0; + } + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); +} + + +static int funcname (LexState *ls, expdesc *v) { + /* funcname -> NAME {field} [`:' NAME] */ + int needself = 0; + singlevar(ls, v); + while (ls->t.token == '.') + field(ls, v); + if (ls->t.token == ':') { + needself = 1; + field(ls, v); + } + return needself; +} + + +static void funcstat (LexState *ls, int line) { + /* funcstat -> FUNCTION funcname body */ + int needself; + expdesc v, b; + luaX_next(ls); /* skip FUNCTION */ + needself = funcname(ls, &v); + body(ls, &b, needself, line); + luaK_storevar(ls->fs, &v, &b); + luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ +} + + +static void exprstat (LexState *ls) { + /* stat -> func | assignment */ + FuncState *fs = ls->fs; + struct LHS_assign v; + primaryexp(ls, &v.v); + if (v.v.k == VCALL) /* stat -> func */ + SETARG_C(getcode(fs, &v.v), 1); /* call statement uses no results */ + else { /* stat -> assignment */ + v.prev = NULL; + assignment(ls, &v, 1); + } +} + + +static void retstat (LexState *ls) { + /* stat -> RETURN explist */ + FuncState *fs = ls->fs; + expdesc e; + int first, nret; /* registers with returned values */ + luaX_next(ls); /* skip RETURN */ + if (block_follow(ls->t.token) || ls->t.token == ';') + first = nret = 0; /* return no values */ + else { + nret = explist1(ls, &e); /* optional return values */ + if (hasmultret(e.k)) { + luaK_setmultret(fs, &e); + if (e.k == VCALL && nret == 1) { /* tail call? */ + SET_OPCODE(getcode(fs,&e), OP_TAILCALL); + lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); + } + first = fs->nactvar; + nret = LUA_MULTRET; /* return all values */ + } + else { + if (nret == 1) /* only one single value? */ + first = luaK_exp2anyreg(fs, &e); + else { + luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ + first = fs->nactvar; /* return all `active' values */ + lua_assert(nret == fs->freereg - first); + } + } + } + luaK_ret(fs, first, nret); +} + + +static int statement (LexState *ls) { + int line = ls->linenumber; /* may be needed for error messages */ + switch (ls->t.token) { + case TK_IF: { /* stat -> ifstat */ + ifstat(ls, line); + return 0; + } + case TK_WHILE: { /* stat -> whilestat */ + whilestat(ls, line); + return 0; + } + case TK_DO: { /* stat -> DO block END */ + luaX_next(ls); /* skip DO */ + block(ls); + check_match(ls, TK_END, TK_DO, line); + return 0; + } + case TK_FOR: { /* stat -> forstat */ + forstat(ls, line); + return 0; + } + case TK_REPEAT: { /* stat -> repeatstat */ + repeatstat(ls, line); + return 0; + } + case TK_FUNCTION: { + funcstat(ls, line); /* stat -> funcstat */ + return 0; + } + case TK_LOCAL: { /* stat -> localstat */ + luaX_next(ls); /* skip LOCAL */ + if (testnext(ls, TK_FUNCTION)) /* local function? */ + localfunc(ls); + else + localstat(ls); + return 0; + } + case TK_RETURN: { /* stat -> retstat */ + retstat(ls); + return 1; /* must be last statement */ + } + case TK_BREAK: { /* stat -> breakstat */ + luaX_next(ls); /* skip BREAK */ + breakstat(ls); + return 1; /* must be last statement */ + } + default: { + exprstat(ls); + return 0; /* to avoid warnings */ + } + } +} + + +static void chunk (LexState *ls) { + /* chunk -> { stat [`;'] } */ + int islast = 0; + enterlevel(ls); + while (!islast && !block_follow(ls->t.token)) { + islast = statement(ls); + testnext(ls, ';'); + lua_assert(ls->fs->f->maxstacksize >= ls->fs->freereg && + ls->fs->freereg >= ls->fs->nactvar); + ls->fs->freereg = ls->fs->nactvar; /* free registers */ + } + leavelevel(ls); +} + +/* }====================================================================== */ diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lparser.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lparser.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lparser.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lparser.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,82 @@ +/* +** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua Parser +** See Copyright Notice in lua.h +*/ + +#ifndef lparser_h +#define lparser_h + +#include "llimits.h" +#include "lobject.h" +#include "lzio.h" + + +/* +** Expression descriptor +*/ + +typedef enum { + VVOID, /* no value */ + VNIL, + VTRUE, + VFALSE, + VK, /* info = index of constant in `k' */ + VKNUM, /* nval = numerical value */ + VLOCAL, /* info = local register */ + VUPVAL, /* info = index of upvalue in `upvalues' */ + VGLOBAL, /* info = index of table; aux = index of global name in `k' */ + VINDEXED, /* info = table register; aux = index register (or `k') */ + VJMP, /* info = instruction pc */ + VRELOCABLE, /* info = instruction pc */ + VNONRELOC, /* info = result register */ + VCALL, /* info = instruction pc */ + VVARARG /* info = instruction pc */ +} expkind; + +typedef struct expdesc { + expkind k; + union { + struct { int info, aux; } s; + lua_Number nval; + } u; + int t; /* patch list of `exit when true' */ + int f; /* patch list of `exit when false' */ +} expdesc; + + +typedef struct upvaldesc { + lu_byte k; + lu_byte info; +} upvaldesc; + + +struct BlockCnt; /* defined in lparser.c */ + + +/* state needed to generate code for a given function */ +typedef struct FuncState { + Proto *f; /* current function header */ + Table *h; /* table to find (and reuse) elements in `k' */ + struct FuncState *prev; /* enclosing function */ + struct LexState *ls; /* lexical state */ + struct lua_State *L; /* copy of the Lua state */ + struct BlockCnt *bl; /* chain of current blocks */ + int pc; /* next position to code (equivalent to `ncode') */ + int lasttarget; /* `pc' of last `jump target' */ + int jpc; /* list of pending jumps to `pc' */ + int freereg; /* first free register */ + int nk; /* number of elements in `k' */ + int np; /* number of elements in `p' */ + short nlocvars; /* number of elements in `locvars' */ + lu_byte nactvar; /* number of active local variables */ + upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ + unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ +} FuncState; + + +LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, + const char *name); + + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lstate.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lstate.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lstate.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lstate.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,214 @@ +/* +** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstate_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "llex.h" +#include "lmem.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + +#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) +#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) +#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) + + +/* +** Main thread combines a thread state and the global state +*/ +typedef struct LG { + lua_State l; + global_State g; +} LG; + + + +static void stack_init (lua_State *L1, lua_State *L) { + /* initialize CallInfo array */ + L1->base_ci = luaM_newvector(L, BASIC_CI_SIZE, CallInfo); + L1->ci = L1->base_ci; + L1->size_ci = BASIC_CI_SIZE; + L1->end_ci = L1->base_ci + L1->size_ci - 1; + /* initialize stack array */ + L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, TValue); + L1->stacksize = BASIC_STACK_SIZE + EXTRA_STACK; + L1->top = L1->stack; + L1->stack_last = L1->stack+(L1->stacksize - EXTRA_STACK)-1; + /* initialize first ci */ + L1->ci->func = L1->top; + setnilvalue(L1->top++); /* `function' entry for this `ci' */ + L1->base = L1->ci->base = L1->top; + L1->ci->top = L1->top + LUA_MINSTACK; +} + + +static void freestack (lua_State *L, lua_State *L1) { + luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo); + luaM_freearray(L, L1->stack, L1->stacksize, TValue); +} + + +/* +** open parts that may cause memory-allocation errors +*/ +static void f_luaopen (lua_State *L, void *ud) { + global_State *g = G(L); + UNUSED(ud); + stack_init(L, L); /* init stack */ + sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ + sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ + luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ + luaT_init(L); + luaX_init(L); + luaS_fix(luaS_newliteral(L, MEMERRMSG)); + g->GCthreshold = 4*g->totalbytes; +} + + +static void preinit_state (lua_State *L, global_State *g) { + G(L) = g; + L->stack = NULL; + L->stacksize = 0; + L->errorJmp = NULL; + L->hook = NULL; + L->hookmask = 0; + L->basehookcount = 0; + L->allowhook = 1; + resethookcount(L); + L->openupval = NULL; + L->size_ci = 0; + L->nCcalls = L->baseCcalls = 0; + L->status = 0; + L->base_ci = L->ci = NULL; + L->savedpc = NULL; + L->errfunc = 0; + setnilvalue(gt(L)); +} + + +static void close_state (lua_State *L) { + global_State *g = G(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_freeall(L); /* collect all objects */ + lua_assert(g->rootgc == obj2gco(L)); + lua_assert(g->strt.nuse == 0); + luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size, TString *); + luaZ_freebuffer(L, &g->buff); + freestack(L, L); + lua_assert(g->totalbytes == sizeof(LG)); + (*g->frealloc)(g->ud, fromstate(L), state_size(LG), 0); +} + + +lua_State *luaE_newthread (lua_State *L) { + lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State))); + luaC_link(L, obj2gco(L1), LUA_TTHREAD); + preinit_state(L1, G(L)); + stack_init(L1, L); /* init stack */ + setobj2n(L, gt(L1), gt(L)); /* share table of globals */ + L1->hookmask = L->hookmask; + L1->basehookcount = L->basehookcount; + L1->hook = L->hook; + resethookcount(L1); + lua_assert(iswhite(obj2gco(L1))); + return L1; +} + + +void luaE_freethread (lua_State *L, lua_State *L1) { + luaF_close(L1, L1->stack); /* close all upvalues for this thread */ + lua_assert(L1->openupval == NULL); + luai_userstatefree(L1); + freestack(L, L1); + luaM_freemem(L, fromstate(L1), state_size(lua_State)); +} + + +LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { + int i; + lua_State *L; + global_State *g; + void *l = (*f)(ud, NULL, 0, state_size(LG)); + if (l == NULL) return NULL; + L = tostate(l); + g = &((LG *)L)->g; + L->next = NULL; + L->tt = LUA_TTHREAD; + g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT); + L->marked = luaC_white(g); + set2bits(L->marked, FIXEDBIT, SFIXEDBIT); + preinit_state(L, g); + g->frealloc = f; + g->ud = ud; + g->mainthread = L; + g->uvhead.u.l.prev = &g->uvhead; + g->uvhead.u.l.next = &g->uvhead; + g->GCthreshold = 0; /* mark it as unfinished state */ + g->strt.size = 0; + g->strt.nuse = 0; + g->strt.hash = NULL; + setnilvalue(registry(L)); + luaZ_initbuffer(L, &g->buff); + g->panic = NULL; + g->gcstate = GCSpause; + g->rootgc = obj2gco(L); + g->sweepstrgc = 0; + g->sweepgc = &g->rootgc; + g->gray = NULL; + g->grayagain = NULL; + g->weak = NULL; + g->tmudata = NULL; + g->totalbytes = sizeof(LG); + g->gcpause = LUAI_GCPAUSE; + g->gcstepmul = LUAI_GCMUL; + g->gcdept = 0; + for (i=0; imt[i] = NULL; + if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) { + /* memory allocation error: free partial state */ + close_state(L); + L = NULL; + } + else + luai_userstateopen(L); + return L; +} + + +static void callallgcTM (lua_State *L, void *ud) { + UNUSED(ud); + luaC_callGCTM(L); /* call GC metamethods for all udata */ +} + + +LUA_API void lua_close (lua_State *L) { + L = G(L)->mainthread; /* only the main thread can be closed */ + lua_lock(L); + luaF_close(L, L->stack); /* close all upvalues for this thread */ + luaC_separateudata(L, 1); /* separate udata that have GC metamethods */ + L->errfunc = 0; /* no error function during GC metamethods */ + do { /* repeat until no more errors */ + L->ci = L->base_ci; + L->base = L->top = L->ci->base; + L->nCcalls = L->baseCcalls = 0; + } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0); + lua_assert(G(L)->tmudata == NULL); + luai_userstateclose(L); + close_state(L); +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lstate.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lstate.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lstate.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lstate.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,169 @@ +/* +** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $ +** Global State +** See Copyright Notice in lua.h +*/ + +#ifndef lstate_h +#define lstate_h + +#include "lua.h" + +#include "lobject.h" +#include "ltm.h" +#include "lzio.h" + + + +struct lua_longjmp; /* defined in ldo.c */ + + +/* table of globals */ +#define gt(L) (&L->l_gt) + +/* registry */ +#define registry(L) (&G(L)->l_registry) + + +/* extra stack space to handle TM calls and some other extras */ +#define EXTRA_STACK 5 + + +#define BASIC_CI_SIZE 8 + +#define BASIC_STACK_SIZE (2*LUA_MINSTACK) + + + +typedef struct stringtable { + GCObject **hash; + lu_int32 nuse; /* number of elements */ + int size; +} stringtable; + + +/* +** informations about a call +*/ +typedef struct CallInfo { + StkId base; /* base for this function */ + StkId func; /* function index in the stack */ + StkId top; /* top for this function */ + const Instruction *savedpc; + int nresults; /* expected number of results from this function */ + int tailcalls; /* number of tail calls lost under this entry */ +} CallInfo; + + + +#define curr_func(L) (clvalue(L->ci->func)) +#define ci_func(ci) (clvalue((ci)->func)) +#define f_isLua(ci) (!ci_func(ci)->c.isC) +#define isLua(ci) (ttisfunction((ci)->func) && f_isLua(ci)) + + +/* +** `global state', shared by all threads of this state +*/ +typedef struct global_State { + stringtable strt; /* hash table for strings */ + lua_Alloc frealloc; /* function to reallocate memory */ + void *ud; /* auxiliary data to `frealloc' */ + lu_byte currentwhite; + lu_byte gcstate; /* state of garbage collector */ + int sweepstrgc; /* position of sweep in `strt' */ + GCObject *rootgc; /* list of all collectable objects */ + GCObject **sweepgc; /* position of sweep in `rootgc' */ + GCObject *gray; /* list of gray objects */ + GCObject *grayagain; /* list of objects to be traversed atomically */ + GCObject *weak; /* list of weak tables (to be cleared) */ + GCObject *tmudata; /* last element of list of userdata to be GC */ + Mbuffer buff; /* temporary buffer for string concatentation */ + lu_mem GCthreshold; + lu_mem totalbytes; /* number of bytes currently allocated */ + lu_mem estimate; /* an estimate of number of bytes actually in use */ + lu_mem gcdept; /* how much GC is `behind schedule' */ + int gcpause; /* size of pause between successive GCs */ + int gcstepmul; /* GC `granularity' */ + lua_CFunction panic; /* to be called in unprotected errors */ + TValue l_registry; + struct lua_State *mainthread; + UpVal uvhead; /* head of double-linked list of all open upvalues */ + struct Table *mt[NUM_TAGS]; /* metatables for basic types */ + TString *tmname[TM_N]; /* array with tag-method names */ +} global_State; + + +/* +** `per thread' state +*/ +struct lua_State { + CommonHeader; + lu_byte status; + StkId top; /* first free slot in the stack */ + StkId base; /* base of current function */ + global_State *l_G; + CallInfo *ci; /* call info for current function */ + const Instruction *savedpc; /* `savedpc' of current function */ + StkId stack_last; /* last free slot in the stack */ + StkId stack; /* stack base */ + CallInfo *end_ci; /* points after end of ci array*/ + CallInfo *base_ci; /* array of CallInfo's */ + int stacksize; + int size_ci; /* size of array `base_ci' */ + unsigned short nCcalls; /* number of nested C calls */ + unsigned short baseCcalls; /* nested C calls when resuming coroutine */ + lu_byte hookmask; + lu_byte allowhook; + int basehookcount; + int hookcount; + lua_Hook hook; + TValue l_gt; /* table of globals */ + TValue env; /* temporary place for environments */ + GCObject *openupval; /* list of open upvalues in this stack */ + GCObject *gclist; + struct lua_longjmp *errorJmp; /* current error recover point */ + ptrdiff_t errfunc; /* current error handling function (stack index) */ +}; + + +#define G(L) (L->l_G) + + +/* +** Union of all collectable objects +*/ +union GCObject { + GCheader gch; + union TString ts; + union Udata u; + union Closure cl; + struct Table h; + struct Proto p; + struct UpVal uv; + struct lua_State th; /* thread */ +}; + + +/* macros to convert a GCObject into a specific value */ +#define rawgco2ts(o) check_exp((o)->gch.tt == LUA_TSTRING, &((o)->ts)) +#define gco2ts(o) (&rawgco2ts(o)->tsv) +#define rawgco2u(o) check_exp((o)->gch.tt == LUA_TUSERDATA, &((o)->u)) +#define gco2u(o) (&rawgco2u(o)->uv) +#define gco2cl(o) check_exp((o)->gch.tt == LUA_TFUNCTION, &((o)->cl)) +#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h)) +#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p)) +#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define ngcotouv(o) \ + check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv)) +#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th)) + +/* macro to convert any Lua object into a GCObject */ +#define obj2gco(v) (cast(GCObject *, (v))) + + +LUAI_FUNC lua_State *luaE_newthread (lua_State *L); +LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); + +#endif + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lstring.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lstring.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lstring.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lstring.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,111 @@ +/* +** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keeps all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + + +#include + +#define lstring_c +#define LUA_CORE + +#include "lua.h" + +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" + + + +void luaS_resize (lua_State *L, int newsize) { + GCObject **newhash; + stringtable *tb; + int i; + if (G(L)->gcstate == GCSsweepstring) + return; /* cannot resize during GC traverse */ + newhash = luaM_newvector(L, newsize, GCObject *); + tb = &G(L)->strt; + for (i=0; isize; i++) { + GCObject *p = tb->hash[i]; + while (p) { /* for each node in the list */ + GCObject *next = p->gch.next; /* save next */ + unsigned int h = gco2ts(p)->hash; + int h1 = lmod(h, newsize); /* new position */ + lua_assert(cast_int(h%newsize) == lmod(h, newsize)); + p->gch.next = newhash[h1]; /* chain it */ + newhash[h1] = p; + p = next; + } + } + luaM_freearray(L, tb->hash, tb->size, TString *); + tb->size = newsize; + tb->hash = newhash; +} + + +static TString *newlstr (lua_State *L, const char *str, size_t l, + unsigned int h) { + TString *ts; + stringtable *tb; + if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + luaM_toobig(L); + ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); + ts->tsv.len = l; + ts->tsv.hash = h; + ts->tsv.marked = luaC_white(G(L)); + ts->tsv.tt = LUA_TSTRING; + ts->tsv.reserved = 0; + memcpy(ts+1, str, l*sizeof(char)); + ((char *)(ts+1))[l] = '\0'; /* ending 0 */ + tb = &G(L)->strt; + h = lmod(h, tb->size); + ts->tsv.next = tb->hash[h]; /* chain new entry */ + tb->hash[h] = obj2gco(ts); + tb->nuse++; + if (tb->nuse > cast(lu_int32, tb->size) && tb->size <= MAX_INT/2) + luaS_resize(L, tb->size*2); /* too crowded */ + return ts; +} + + +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + GCObject *o; + unsigned int h = cast(unsigned int, l); /* seed */ + size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ + size_t l1; + for (l1=l; l1>=step; l1-=step) /* compute hash */ + h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); + for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; + o != NULL; + o = o->gch.next) { + TString *ts = rawgco2ts(o); + if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { + /* string may be dead */ + if (isdead(G(L), o)) changewhite(o); + return ts; + } + } + return newlstr(L, str, l, h); /* not found */ +} + + +Udata *luaS_newudata (lua_State *L, size_t s, Table *e) { + Udata *u; + if (s > MAX_SIZET - sizeof(Udata)) + luaM_toobig(L); + u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata))); + u->uv.marked = luaC_white(G(L)); /* is not finalized */ + u->uv.tt = LUA_TUSERDATA; + u->uv.len = s; + u->uv.metatable = NULL; + u->uv.env = e; + /* chain it on udata list (after main thread) */ + u->uv.next = G(L)->mainthread->next; + G(L)->mainthread->next = obj2gco(u); + return u; +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lstring.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lstring.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lstring.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lstring.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,31 @@ +/* +** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ +** String table (keep all strings handled by Lua) +** See Copyright Notice in lua.h +*/ + +#ifndef lstring_h +#define lstring_h + + +#include "lgc.h" +#include "lobject.h" +#include "lstate.h" + + +#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) + +#define sizeudata(u) (sizeof(union Udata)+(u)->len) + +#define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) +#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ + (sizeof(s)/sizeof(char))-1)) + +#define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) + +LUAI_FUNC void luaS_resize (lua_State *L, int newsize); +LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); +LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); + + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lstrlib.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lstrlib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lstrlib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lstrlib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,869 @@ +/* +** $Id: lstrlib.c,v 1.132.1.4 2008/07/11 17:27:21 roberto Exp $ +** Standard library for string operations and pattern-matching +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include +#include +#include + +#define lstrlib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +/* macro to `unsign' a character */ +#define uchar(c) ((unsigned char)(c)) + + + +static int str_len (lua_State *L) { + size_t l; + luaL_checklstring(L, 1, &l); + lua_pushinteger(L, l); + return 1; +} + + +static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) { + /* relative string position: negative means back from end */ + if (pos < 0) pos += (ptrdiff_t)len + 1; + return (pos >= 0) ? pos : 0; +} + + +static int str_sub (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t start = posrelat(luaL_checkinteger(L, 2), l); + ptrdiff_t end = posrelat(luaL_optinteger(L, 3, -1), l); + if (start < 1) start = 1; + if (end > (ptrdiff_t)l) end = (ptrdiff_t)l; + if (start <= end) + lua_pushlstring(L, s+start-1, end-start+1); + else lua_pushliteral(L, ""); + return 1; +} + + +static int str_reverse (lua_State *L) { + size_t l; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + while (l--) luaL_addchar(&b, s[l]); + luaL_pushresult(&b); + return 1; +} + + +static int str_lower (lua_State *L) { + size_t l; + size_t i; + luaL_Buffer b; + const char *s = luaL_checklstring(L, 1, &l); + luaL_buffinit(L, &b); + for (i=0; i 0) + luaL_addlstring(&b, s, l); + luaL_pushresult(&b); + return 1; +} + + +static int str_byte (lua_State *L) { + size_t l; + const char *s = luaL_checklstring(L, 1, &l); + ptrdiff_t posi = posrelat(luaL_optinteger(L, 2, 1), l); + ptrdiff_t pose = posrelat(luaL_optinteger(L, 3, posi), l); + int n, i; + if (posi <= 0) posi = 1; + if ((size_t)pose > l) pose = l; + if (posi > pose) return 0; /* empty interval; return no values */ + n = (int)(pose - posi + 1); + if (posi + n <= pose) /* overflow? */ + luaL_error(L, "string slice too long"); + luaL_checkstack(L, n, "string slice too long"); + for (i=0; i= ms->level || ms->capture[l].len == CAP_UNFINISHED) + return luaL_error(ms->L, "invalid capture index"); + return l; +} + + +static int capture_to_close (MatchState *ms) { + int level = ms->level; + for (level--; level>=0; level--) + if (ms->capture[level].len == CAP_UNFINISHED) return level; + return luaL_error(ms->L, "invalid pattern capture"); +} + + +static const char *classend (MatchState *ms, const char *p) { + switch (*p++) { + case L_ESC: { + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); + return p+1; + } + case '[': { + if (*p == '^') p++; + do { /* look for a `]' */ + if (*p == '\0') + luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); + if (*(p++) == L_ESC && *p != '\0') + p++; /* skip escapes (e.g. `%]') */ + } while (*p != ']'); + return p+1; + } + default: { + return p; + } + } +} + + +static int match_class (int c, int cl) { + int res; + switch (tolower(cl)) { + case 'a' : res = isalpha(c); break; + case 'c' : res = iscntrl(c); break; + case 'd' : res = isdigit(c); break; + case 'l' : res = islower(c); break; + case 'p' : res = ispunct(c); break; + case 's' : res = isspace(c); break; + case 'u' : res = isupper(c); break; + case 'w' : res = isalnum(c); break; + case 'x' : res = isxdigit(c); break; + case 'z' : res = (c == 0); break; + default: return (cl == c); + } + return (islower(cl) ? res : !res); +} + + +static int matchbracketclass (int c, const char *p, const char *ec) { + int sig = 1; + if (*(p+1) == '^') { + sig = 0; + p++; /* skip the `^' */ + } + while (++p < ec) { + if (*p == L_ESC) { + p++; + if (match_class(c, uchar(*p))) + return sig; + } + else if ((*(p+1) == '-') && (p+2 < ec)) { + p+=2; + if (uchar(*(p-2)) <= c && c <= uchar(*p)) + return sig; + } + else if (uchar(*p) == c) return sig; + } + return !sig; +} + + +static int singlematch (int c, const char *p, const char *ep) { + switch (*p) { + case '.': return 1; /* matches any char */ + case L_ESC: return match_class(c, uchar(*(p+1))); + case '[': return matchbracketclass(c, p, ep-1); + default: return (uchar(*p) == c); + } +} + + +static const char *match (MatchState *ms, const char *s, const char *p); + + +static const char *matchbalance (MatchState *ms, const char *s, + const char *p) { + if (*p == 0 || *(p+1) == 0) + luaL_error(ms->L, "unbalanced pattern"); + if (*s != *p) return NULL; + else { + int b = *p; + int e = *(p+1); + int cont = 1; + while (++s < ms->src_end) { + if (*s == e) { + if (--cont == 0) return s+1; + } + else if (*s == b) cont++; + } + } + return NULL; /* string ends out of balance */ +} + + +static const char *max_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + ptrdiff_t i = 0; /* counts maximum expand for item */ + while ((s+i)src_end && singlematch(uchar(*(s+i)), p, ep)) + i++; + /* keeps trying to match with the maximum repetitions */ + while (i>=0) { + const char *res = match(ms, (s+i), ep+1); + if (res) return res; + i--; /* else didn't match; reduce 1 repetition to try again */ + } + return NULL; +} + + +static const char *min_expand (MatchState *ms, const char *s, + const char *p, const char *ep) { + for (;;) { + const char *res = match(ms, s, ep+1); + if (res != NULL) + return res; + else if (ssrc_end && singlematch(uchar(*s), p, ep)) + s++; /* try with one more repetition */ + else return NULL; + } +} + + +static const char *start_capture (MatchState *ms, const char *s, + const char *p, int what) { + const char *res; + int level = ms->level; + if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures"); + ms->capture[level].init = s; + ms->capture[level].len = what; + ms->level = level+1; + if ((res=match(ms, s, p)) == NULL) /* match failed? */ + ms->level--; /* undo capture */ + return res; +} + + +static const char *end_capture (MatchState *ms, const char *s, + const char *p) { + int l = capture_to_close(ms); + const char *res; + ms->capture[l].len = s - ms->capture[l].init; /* close capture */ + if ((res = match(ms, s, p)) == NULL) /* match failed? */ + ms->capture[l].len = CAP_UNFINISHED; /* undo capture */ + return res; +} + + +static const char *match_capture (MatchState *ms, const char *s, int l) { + size_t len; + l = check_capture(ms, l); + len = ms->capture[l].len; + if ((size_t)(ms->src_end-s) >= len && + memcmp(ms->capture[l].init, s, len) == 0) + return s+len; + else return NULL; +} + + +static const char *match (MatchState *ms, const char *s, const char *p) { + init: /* using goto's to optimize tail recursion */ + switch (*p) { + case '(': { /* start capture */ + if (*(p+1) == ')') /* position capture? */ + return start_capture(ms, s, p+2, CAP_POSITION); + else + return start_capture(ms, s, p+1, CAP_UNFINISHED); + } + case ')': { /* end capture */ + return end_capture(ms, s, p+1); + } + case L_ESC: { + switch (*(p+1)) { + case 'b': { /* balanced string? */ + s = matchbalance(ms, s, p+2); + if (s == NULL) return NULL; + p+=4; goto init; /* else return match(ms, s, p+4); */ + } + case 'f': { /* frontier? */ + const char *ep; char previous; + p += 2; + if (*p != '[') + luaL_error(ms->L, "missing " LUA_QL("[") " after " + LUA_QL("%%f") " in pattern"); + ep = classend(ms, p); /* points to what is next */ + previous = (s == ms->src_init) ? '\0' : *(s-1); + if (matchbracketclass(uchar(previous), p, ep-1) || + !matchbracketclass(uchar(*s), p, ep-1)) return NULL; + p=ep; goto init; /* else return match(ms, s, ep); */ + } + default: { + if (isdigit(uchar(*(p+1)))) { /* capture results (%0-%9)? */ + s = match_capture(ms, s, uchar(*(p+1))); + if (s == NULL) return NULL; + p+=2; goto init; /* else return match(ms, s, p+2) */ + } + goto dflt; /* case default */ + } + } + } + case '\0': { /* end of pattern */ + return s; /* match succeeded */ + } + case '$': { + if (*(p+1) == '\0') /* is the `$' the last char in pattern? */ + return (s == ms->src_end) ? s : NULL; /* check end of string */ + else goto dflt; + } + default: dflt: { /* it is a pattern item */ + const char *ep = classend(ms, p); /* points to what is next */ + int m = ssrc_end && singlematch(uchar(*s), p, ep); + switch (*ep) { + case '?': { /* optional */ + const char *res; + if (m && ((res=match(ms, s+1, ep+1)) != NULL)) + return res; + p=ep+1; goto init; /* else return match(ms, s, ep+1); */ + } + case '*': { /* 0 or more repetitions */ + return max_expand(ms, s, p, ep); + } + case '+': { /* 1 or more repetitions */ + return (m ? max_expand(ms, s+1, p, ep) : NULL); + } + case '-': { /* 0 or more repetitions (minimum) */ + return min_expand(ms, s, p, ep); + } + default: { + if (!m) return NULL; + s++; p=ep; goto init; /* else return match(ms, s+1, ep); */ + } + } + } + } +} + + + +static const char *lmemfind (const char *s1, size_t l1, + const char *s2, size_t l2) { + if (l2 == 0) return s1; /* empty strings are everywhere */ + else if (l2 > l1) return NULL; /* avoids a negative `l1' */ + else { + const char *init; /* to search for a `*s2' inside `s1' */ + l2--; /* 1st char will be checked by `memchr' */ + l1 = l1-l2; /* `s2' cannot be found after that */ + while (l1 > 0 && (init = (const char *)memchr(s1, *s2, l1)) != NULL) { + init++; /* 1st char is already checked */ + if (memcmp(init, s2+1, l2) == 0) + return init-1; + else { /* correct `l1' and `s1' to try again */ + l1 -= init-s1; + s1 = init; + } + } + return NULL; /* not found */ + } +} + + +static void push_onecapture (MatchState *ms, int i, const char *s, + const char *e) { + if (i >= ms->level) { + if (i == 0) /* ms->level == 0, too */ + lua_pushlstring(ms->L, s, e - s); /* add whole match */ + else + luaL_error(ms->L, "invalid capture index"); + } + else { + ptrdiff_t l = ms->capture[i].len; + if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); + if (l == CAP_POSITION) + lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1); + else + lua_pushlstring(ms->L, ms->capture[i].init, l); + } +} + + +static int push_captures (MatchState *ms, const char *s, const char *e) { + int i; + int nlevels = (ms->level == 0 && s) ? 1 : ms->level; + luaL_checkstack(ms->L, nlevels, "too many captures"); + for (i = 0; i < nlevels; i++) + push_onecapture(ms, i, s, e); + return nlevels; /* number of strings pushed */ +} + + +static int str_find_aux (lua_State *L, int find) { + size_t l1, l2; + const char *s = luaL_checklstring(L, 1, &l1); + const char *p = luaL_checklstring(L, 2, &l2); + ptrdiff_t init = posrelat(luaL_optinteger(L, 3, 1), l1) - 1; + if (init < 0) init = 0; + else if ((size_t)(init) > l1) init = (ptrdiff_t)l1; + if (find && (lua_toboolean(L, 4) || /* explicit request? */ + strpbrk(p, SPECIALS) == NULL)) { /* or no special characters? */ + /* do a plain search */ + const char *s2 = lmemfind(s+init, l1-init, p, l2); + if (s2) { + lua_pushinteger(L, s2-s+1); + lua_pushinteger(L, s2-s+l2); + return 2; + } + } + else { + MatchState ms; + int anchor = (*p == '^') ? (p++, 1) : 0; + const char *s1=s+init; + ms.L = L; + ms.src_init = s; + ms.src_end = s+l1; + do { + const char *res; + ms.level = 0; + if ((res=match(&ms, s1, p)) != NULL) { + if (find) { + lua_pushinteger(L, s1-s+1); /* start */ + lua_pushinteger(L, res-s); /* end */ + return push_captures(&ms, NULL, 0) + 2; + } + else + return push_captures(&ms, s1, res); + } + } while (s1++ < ms.src_end && !anchor); + } + lua_pushnil(L); /* not found */ + return 1; +} + + +static int str_find (lua_State *L) { + return str_find_aux(L, 1); +} + + +static int str_match (lua_State *L) { + return str_find_aux(L, 0); +} + + +static int gmatch_aux (lua_State *L) { + MatchState ms; + size_t ls; + const char *s = lua_tolstring(L, lua_upvalueindex(1), &ls); + const char *p = lua_tostring(L, lua_upvalueindex(2)); + const char *src; + ms.L = L; + ms.src_init = s; + ms.src_end = s+ls; + for (src = s + (size_t)lua_tointeger(L, lua_upvalueindex(3)); + src <= ms.src_end; + src++) { + const char *e; + ms.level = 0; + if ((e = match(&ms, src, p)) != NULL) { + lua_Integer newstart = e-s; + if (e == src) newstart++; /* empty match? go at least one position */ + lua_pushinteger(L, newstart); + lua_replace(L, lua_upvalueindex(3)); + return push_captures(&ms, src, e); + } + } + return 0; /* not found */ +} + + +static int gmatch (lua_State *L) { + luaL_checkstring(L, 1); + luaL_checkstring(L, 2); + lua_settop(L, 2); + lua_pushinteger(L, 0); + lua_pushcclosure(L, gmatch_aux, 3); + return 1; +} + + +static int gfind_nodef (lua_State *L) { + return luaL_error(L, LUA_QL("string.gfind") " was renamed to " + LUA_QL("string.gmatch")); +} + + +static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + size_t l, i; + const char *news = lua_tolstring(ms->L, 3, &l); + for (i = 0; i < l; i++) { + if (news[i] != L_ESC) + luaL_addchar(b, news[i]); + else { + i++; /* skip ESC */ + if (!isdigit(uchar(news[i]))) + luaL_addchar(b, news[i]); + else if (news[i] == '0') + luaL_addlstring(b, s, e - s); + else { + push_onecapture(ms, news[i] - '1', s, e); + luaL_addvalue(b); /* add capture to accumulated result */ + } + } + } +} + + +static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, + const char *e) { + lua_State *L = ms->L; + switch (lua_type(L, 3)) { + case LUA_TNUMBER: + case LUA_TSTRING: { + add_s(ms, b, s, e); + return; + } + case LUA_TFUNCTION: { + int n; + lua_pushvalue(L, 3); + n = push_captures(ms, s, e); + lua_call(L, n, 1); + break; + } + case LUA_TTABLE: { + push_onecapture(ms, 0, s, e); + lua_gettable(L, 3); + break; + } + } + if (!lua_toboolean(L, -1)) { /* nil or false? */ + lua_pop(L, 1); + lua_pushlstring(L, s, e - s); /* keep original text */ + } + else if (!lua_isstring(L, -1)) + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_addvalue(b); /* add result to accumulator */ +} + + +static int str_gsub (lua_State *L) { + size_t srcl; + const char *src = luaL_checklstring(L, 1, &srcl); + const char *p = luaL_checkstring(L, 2); + int tr = lua_type(L, 3); + int max_s = luaL_optint(L, 4, srcl+1); + int anchor = (*p == '^') ? (p++, 1) : 0; + int n = 0; + MatchState ms; + luaL_Buffer b; + luaL_argcheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING || + tr == LUA_TFUNCTION || tr == LUA_TTABLE, 3, + "string/function/table expected"); + luaL_buffinit(L, &b); + ms.L = L; + ms.src_init = src; + ms.src_end = src+srcl; + while (n < max_s) { + const char *e; + ms.level = 0; + e = match(&ms, src, p); + if (e) { + n++; + add_value(&ms, &b, src, e); + } + if (e && e>src) /* non empty match? */ + src = e; /* skip it */ + else if (src < ms.src_end) + luaL_addchar(&b, *src++); + else break; + if (anchor) break; + } + luaL_addlstring(&b, src, ms.src_end-src); + luaL_pushresult(&b); + lua_pushinteger(L, n); /* number of substitutions */ + return 2; +} + +/* }====================================================== */ + + +/* maximum size of each formatted item (> len(format('%99.99f', -1e308))) */ +#define MAX_ITEM 512 +/* valid flags in a format specification */ +#define FLAGS "-+ #0" +/* +** maximum size of each format specification (such as '%-099.99d') +** (+10 accounts for %99.99x plus margin of error) +*/ +#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10) + + +static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + luaL_addchar(b, '"'); + while (l--) { + switch (*s) { + case '"': case '\\': case '\n': { + luaL_addchar(b, '\\'); + luaL_addchar(b, *s); + break; + } + case '\r': { + luaL_addlstring(b, "\\r", 2); + break; + } + case '\0': { + luaL_addlstring(b, "\\000", 4); + break; + } + default: { + luaL_addchar(b, *s); + break; + } + } + s++; + } + luaL_addchar(b, '"'); +} + +static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { + const char *p = strfrmt; + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ + if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) + luaL_error(L, "invalid format (repeated flags)"); + if (isdigit(uchar(*p))) p++; /* skip width */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + if (*p == '.') { + p++; + if (isdigit(uchar(*p))) p++; /* skip precision */ + if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ + } + if (isdigit(uchar(*p))) + luaL_error(L, "invalid format (width or precision too long)"); + *(form++) = '%'; + strncpy(form, strfrmt, p - strfrmt + 1); + form += p - strfrmt + 1; + *form = '\0'; + return p; +} + + +static void addintlen (char *form) { + size_t l = strlen(form); + char spec = form[l - 1]; + strcpy(form + l - 1, LUA_INTFRMLEN); + form[l + sizeof(LUA_INTFRMLEN) - 2] = spec; + form[l + sizeof(LUA_INTFRMLEN) - 1] = '\0'; +} + + +static int str_format (lua_State *L) { + int arg = 1; + size_t sfl; + const char *strfrmt = luaL_checklstring(L, arg, &sfl); + const char *strfrmt_end = strfrmt+sfl; + luaL_Buffer b; + luaL_buffinit(L, &b); + while (strfrmt < strfrmt_end) { + if (*strfrmt != L_ESC) + luaL_addchar(&b, *strfrmt++); + else if (*++strfrmt == L_ESC) + luaL_addchar(&b, *strfrmt++); /* %% */ + else { /* format item */ + char form[MAX_FORMAT]; /* to store the format (`%...') */ + char buff[MAX_ITEM]; /* to store the formatted item */ + arg++; + strfrmt = scanformat(L, strfrmt, form); + switch (*strfrmt++) { + case 'c': { + sprintf(buff, form, (int)luaL_checknumber(L, arg)); + break; + } + case 'd': case 'i': { + addintlen(form); + sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'o': case 'u': case 'x': case 'X': { + addintlen(form); + sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); + break; + } + case 'e': case 'E': case 'f': + case 'g': case 'G': { + sprintf(buff, form, (double)luaL_checknumber(L, arg)); + break; + } + case 'q': { + addquoted(L, &b, arg); + continue; /* skip the 'addsize' at the end */ + } + case 's': { + size_t l; + const char *s = luaL_checklstring(L, arg, &l); + if (!strchr(form, '.') && l >= 100) { + /* no precision and string is too long to be formatted; + keep original string */ + lua_pushvalue(L, arg); + luaL_addvalue(&b); + continue; /* skip the `addsize' at the end */ + } + else { + sprintf(buff, form, s); + break; + } + } + default: { /* also treat cases `pnLlh' */ + return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " + LUA_QL("format"), *(strfrmt - 1)); + } + } + luaL_addlstring(&b, buff, strlen(buff)); + } + } + luaL_pushresult(&b); + return 1; +} + + +static const luaL_Reg strlib[] = { + {"byte", str_byte}, + {"char", str_char}, + {"dump", str_dump}, + {"find", str_find}, + {"format", str_format}, + {"gfind", gfind_nodef}, + {"gmatch", gmatch}, + {"gsub", str_gsub}, + {"len", str_len}, + {"lower", str_lower}, + {"match", str_match}, + {"rep", str_rep}, + {"reverse", str_reverse}, + {"sub", str_sub}, + {"upper", str_upper}, + {NULL, NULL} +}; + + +static void createmetatable (lua_State *L) { + lua_createtable(L, 0, 1); /* create metatable for strings */ + lua_pushliteral(L, ""); /* dummy string */ + lua_pushvalue(L, -2); + lua_setmetatable(L, -2); /* set string metatable */ + lua_pop(L, 1); /* pop dummy string */ + lua_pushvalue(L, -2); /* string library... */ + lua_setfield(L, -2, "__index"); /* ...is the __index metamethod */ + lua_pop(L, 1); /* pop metatable */ +} + + +/* +** Open string library +*/ +LUALIB_API int luaopen_string (lua_State *L) { + luaL_register(L, LUA_STRLIBNAME, strlib); +#if defined(LUA_COMPAT_GFIND) + lua_getfield(L, -1, "gmatch"); + lua_setfield(L, -2, "gfind"); +#endif + createmetatable(L); + return 1; +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/ltable.c.svn-base blobby-0.9c/src/lua/.svn/text-base/ltable.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/ltable.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/ltable.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,588 @@ +/* +** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + + +/* +** Implementation of tables (aka arrays, objects, or hash tables). +** Tables keep its elements in two parts: an array part and a hash part. +** Non-negative integer keys are all candidates to be kept in the array +** part. The actual size of the array is the largest `n' such that at +** least half the slots between 0 and n are in use. +** Hash uses a mix of chained scatter table with Brent's variation. +** A main invariant of these tables is that, if an element is not +** in its main position (i.e. the `original' position that its hash gives +** to it), then the colliding element is in its own main position. +** Hence even when the load factor reaches 100%, performance remains good. +*/ + +#include +#include + +#define ltable_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lgc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstate.h" +#include "ltable.h" + + +/* +** max size of array part is 2^MAXBITS +*/ +#if LUAI_BITSINT > 26 +#define MAXBITS 26 +#else +#define MAXBITS (LUAI_BITSINT-2) +#endif + +#define MAXASIZE (1 << MAXBITS) + + +#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) + +#define hashstr(t,str) hashpow2(t, (str)->tsv.hash) +#define hashboolean(t,p) hashpow2(t, p) + + +/* +** for some types, it is better to avoid modulus by power of 2, as +** they tend to have many 2 factors. +*/ +#define hashmod(t,n) (gnode(t, ((n) % ((sizenode(t)-1)|1)))) + + +#define hashpointer(t,p) hashmod(t, IntPoint(p)) + + +/* +** number of ints inside a lua_Number +*/ +#define numints cast_int(sizeof(lua_Number)/sizeof(int)) + + + +#define dummynode (&dummynode_) + +static const Node dummynode_ = { + {{NULL}, LUA_TNIL}, /* value */ + {{{NULL}, LUA_TNIL, NULL}} /* key */ +}; + + +/* +** hash for lua_Numbers +*/ +static Node *hashnum (const Table *t, lua_Number n) { + unsigned int a[numints]; + int i; + if (luai_numeq(n, 0)) /* avoid problems with -0 */ + return gnode(t, 0); + memcpy(a, &n, sizeof(a)); + for (i = 1; i < numints; i++) a[0] += a[i]; + return hashmod(t, a[0]); +} + + + +/* +** returns the `main' position of an element in a table (that is, the index +** of its hash value) +*/ +static Node *mainposition (const Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNUMBER: + return hashnum(t, nvalue(key)); + case LUA_TSTRING: + return hashstr(t, rawtsvalue(key)); + case LUA_TBOOLEAN: + return hashboolean(t, bvalue(key)); + case LUA_TLIGHTUSERDATA: + return hashpointer(t, pvalue(key)); + default: + return hashpointer(t, gcvalue(key)); + } +} + + +/* +** returns the index for `key' if `key' is an appropriate key to live in +** the array part of the table, -1 otherwise. +*/ +static int arrayindex (const TValue *key) { + if (ttisnumber(key)) { + lua_Number n = nvalue(key); + int k; + lua_number2int(k, n); + if (luai_numeq(cast_num(k), n)) + return k; + } + return -1; /* `key' did not match some condition */ +} + + +/* +** returns the index of a `key' for table traversals. First goes all +** elements in the array part, then elements in the hash part. The +** beginning of a traversal is signalled by -1. +*/ +static int findindex (lua_State *L, Table *t, StkId key) { + int i; + if (ttisnil(key)) return -1; /* first iteration */ + i = arrayindex(key); + if (0 < i && i <= t->sizearray) /* is `key' inside array part? */ + return i-1; /* yes; that's the index (corrected to C) */ + else { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + /* key may be dead already, but it is ok to use it in `next' */ + if (luaO_rawequalObj(key2tval(n), key) || + (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && + gcvalue(gkey(n)) == gcvalue(key))) { + i = cast_int(n - gnode(t, 0)); /* key index in hash table */ + /* hash elements are numbered after array ones */ + return i + t->sizearray; + } + else n = gnext(n); + } while (n); + luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ + return 0; /* to avoid warnings */ + } +} + + +int luaH_next (lua_State *L, Table *t, StkId key) { + int i = findindex(L, t, key); /* find original element */ + for (i++; i < t->sizearray; i++) { /* try first array part */ + if (!ttisnil(&t->array[i])) { /* a non-nil value? */ + setnvalue(key, cast_num(i+1)); + setobj2s(L, key+1, &t->array[i]); + return 1; + } + } + for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */ + if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */ + setobj2s(L, key, key2tval(gnode(t, i))); + setobj2s(L, key+1, gval(gnode(t, i))); + return 1; + } + } + return 0; /* no more elements */ +} + + +/* +** {============================================================= +** Rehash +** ============================================================== +*/ + + +static int computesizes (int nums[], int *narray) { + int i; + int twotoi; /* 2^i */ + int a = 0; /* number of elements smaller than 2^i */ + int na = 0; /* number of elements to go to array part */ + int n = 0; /* optimal size for array part */ + for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) { + if (nums[i] > 0) { + a += nums[i]; + if (a > twotoi/2) { /* more than half elements present? */ + n = twotoi; /* optimal size (till now) */ + na = a; /* all elements smaller than n will go to array part */ + } + } + if (a == *narray) break; /* all elements already counted */ + } + *narray = n; + lua_assert(*narray/2 <= na && na <= *narray); + return na; +} + + +static int countint (const TValue *key, int *nums) { + int k = arrayindex(key); + if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */ + nums[ceillog2(k)]++; /* count as such */ + return 1; + } + else + return 0; +} + + +static int numusearray (const Table *t, int *nums) { + int lg; + int ttlg; /* 2^lg */ + int ause = 0; /* summation of `nums' */ + int i = 1; /* count to traverse all array keys */ + for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */ + int lc = 0; /* counter */ + int lim = ttlg; + if (lim > t->sizearray) { + lim = t->sizearray; /* adjust upper limit */ + if (i > lim) + break; /* no more elements to count */ + } + /* count elements in range (2^(lg-1), 2^lg] */ + for (; i <= lim; i++) { + if (!ttisnil(&t->array[i-1])) + lc++; + } + nums[lg] += lc; + ause += lc; + } + return ause; +} + + +static int numusehash (const Table *t, int *nums, int *pnasize) { + int totaluse = 0; /* total number of elements */ + int ause = 0; /* summation of `nums' */ + int i = sizenode(t); + while (i--) { + Node *n = &t->node[i]; + if (!ttisnil(gval(n))) { + ause += countint(key2tval(n), nums); + totaluse++; + } + } + *pnasize += ause; + return totaluse; +} + + +static void setarrayvector (lua_State *L, Table *t, int size) { + int i; + luaM_reallocvector(L, t->array, t->sizearray, size, TValue); + for (i=t->sizearray; iarray[i]); + t->sizearray = size; +} + + +static void setnodevector (lua_State *L, Table *t, int size) { + int lsize; + if (size == 0) { /* no elements to hash part? */ + t->node = cast(Node *, dummynode); /* use common `dummynode' */ + lsize = 0; + } + else { + int i; + lsize = ceillog2(size); + if (lsize > MAXBITS) + luaG_runerror(L, "table overflow"); + size = twoto(lsize); + t->node = luaM_newvector(L, size, Node); + for (i=0; ilsizenode = cast_byte(lsize); + t->lastfree = gnode(t, size); /* all positions are free */ +} + + +static void resize (lua_State *L, Table *t, int nasize, int nhsize) { + int i; + int oldasize = t->sizearray; + int oldhsize = t->lsizenode; + Node *nold = t->node; /* save old hash ... */ + if (nasize > oldasize) /* array part must grow? */ + setarrayvector(L, t, nasize); + /* create new hash part with appropriate size */ + setnodevector(L, t, nhsize); + if (nasize < oldasize) { /* array part must shrink? */ + t->sizearray = nasize; + /* re-insert elements from vanishing slice */ + for (i=nasize; iarray[i])) + setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]); + } + /* shrink array */ + luaM_reallocvector(L, t->array, oldasize, nasize, TValue); + } + /* re-insert elements from hash part */ + for (i = twoto(oldhsize) - 1; i >= 0; i--) { + Node *old = nold+i; + if (!ttisnil(gval(old))) + setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old)); + } + if (nold != dummynode) + luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */ +} + + +void luaH_resizearray (lua_State *L, Table *t, int nasize) { + int nsize = (t->node == dummynode) ? 0 : sizenode(t); + resize(L, t, nasize, nsize); +} + + +static void rehash (lua_State *L, Table *t, const TValue *ek) { + int nasize, na; + int nums[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */ + int i; + int totaluse; + for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */ + nasize = numusearray(t, nums); /* count keys in array part */ + totaluse = nasize; /* all those keys are integer keys */ + totaluse += numusehash(t, nums, &nasize); /* count keys in hash part */ + /* count extra key */ + nasize += countint(ek, nums); + totaluse++; + /* compute new size for array part */ + na = computesizes(nums, &nasize); + /* resize the table to new computed sizes */ + resize(L, t, nasize, totaluse - na); +} + + + +/* +** }============================================================= +*/ + + +Table *luaH_new (lua_State *L, int narray, int nhash) { + Table *t = luaM_new(L, Table); + luaC_link(L, obj2gco(t), LUA_TTABLE); + t->metatable = NULL; + t->flags = cast_byte(~0); + /* temporary values (kept only if some malloc fails) */ + t->array = NULL; + t->sizearray = 0; + t->lsizenode = 0; + t->node = cast(Node *, dummynode); + setarrayvector(L, t, narray); + setnodevector(L, t, nhash); + return t; +} + + +void luaH_free (lua_State *L, Table *t) { + if (t->node != dummynode) + luaM_freearray(L, t->node, sizenode(t), Node); + luaM_freearray(L, t->array, t->sizearray, TValue); + luaM_free(L, t); +} + + +static Node *getfreepos (Table *t) { + while (t->lastfree-- > t->node) { + if (ttisnil(gkey(t->lastfree))) + return t->lastfree; + } + return NULL; /* could not find a free place */ +} + + + +/* +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. +*/ +static TValue *newkey (lua_State *L, Table *t, const TValue *key) { + Node *mp = mainposition(t, key); + if (!ttisnil(gval(mp)) || mp == dummynode) { + Node *othern; + Node *n = getfreepos(t); /* get a free place */ + if (n == NULL) { /* cannot find a free place? */ + rehash(L, t, key); /* grow table */ + return luaH_set(L, t, key); /* re-insert key into grown table */ + } + lua_assert(n != dummynode); + othern = mainposition(t, key2tval(mp)); + if (othern != mp) { /* is colliding node out of its main position? */ + /* yes; move colliding node into free position */ + while (gnext(othern) != mp) othern = gnext(othern); /* find previous */ + gnext(othern) = n; /* redo the chain with `n' in place of `mp' */ + *n = *mp; /* copy colliding node into free pos. (mp->next also goes) */ + gnext(mp) = NULL; /* now `mp' is free */ + setnilvalue(gval(mp)); + } + else { /* colliding node is in its own main position */ + /* new node will go into free position */ + gnext(n) = gnext(mp); /* chain new position */ + gnext(mp) = n; + mp = n; + } + } + gkey(mp)->value = key->value; gkey(mp)->tt = key->tt; + luaC_barriert(L, t, key); + lua_assert(ttisnil(gval(mp))); + return gval(mp); +} + + +/* +** search function for integers +*/ +const TValue *luaH_getnum (Table *t, int key) { + /* (1 <= key && key <= t->sizearray) */ + if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) + return &t->array[key-1]; + else { + lua_Number nk = cast_num(key); + Node *n = hashnum(t, nk); + do { /* check whether `key' is somewhere in the chain */ + if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } +} + + +/* +** search function for strings +*/ +const TValue *luaH_getstr (Table *t, TString *key) { + Node *n = hashstr(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (ttisstring(gkey(n)) && rawtsvalue(gkey(n)) == key) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; +} + + +/* +** main search function +*/ +const TValue *luaH_get (Table *t, const TValue *key) { + switch (ttype(key)) { + case LUA_TNIL: return luaO_nilobject; + case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); + case LUA_TNUMBER: { + int k; + lua_Number n = nvalue(key); + lua_number2int(k, n); + if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ + return luaH_getnum(t, k); /* use specialized version */ + /* else go through */ + } + default: { + Node *n = mainposition(t, key); + do { /* check whether `key' is somewhere in the chain */ + if (luaO_rawequalObj(key2tval(n), key)) + return gval(n); /* that's it */ + else n = gnext(n); + } while (n); + return luaO_nilobject; + } + } +} + + +TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { + const TValue *p = luaH_get(t, key); + t->flags = 0; + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + if (ttisnil(key)) luaG_runerror(L, "table index is nil"); + else if (ttisnumber(key) && luai_numisnan(nvalue(key))) + luaG_runerror(L, "table index is NaN"); + return newkey(L, t, key); + } +} + + +TValue *luaH_setnum (lua_State *L, Table *t, int key) { + const TValue *p = luaH_getnum(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setnvalue(&k, cast_num(key)); + return newkey(L, t, &k); + } +} + + +TValue *luaH_setstr (lua_State *L, Table *t, TString *key) { + const TValue *p = luaH_getstr(t, key); + if (p != luaO_nilobject) + return cast(TValue *, p); + else { + TValue k; + setsvalue(L, &k, key); + return newkey(L, t, &k); + } +} + + +static int unbound_search (Table *t, unsigned int j) { + unsigned int i = j; /* i is zero or a present index */ + j++; + /* find `i' and `j' such that i is present and j is not */ + while (!ttisnil(luaH_getnum(t, j))) { + i = j; + j *= 2; + if (j > cast(unsigned int, MAX_INT)) { /* overflow? */ + /* table was built with bad purposes: resort to linear search */ + i = 1; + while (!ttisnil(luaH_getnum(t, i))) i++; + return i - 1; + } + } + /* now do a binary search between them */ + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(luaH_getnum(t, m))) j = m; + else i = m; + } + return i; +} + + +/* +** Try to find a boundary in table `t'. A `boundary' is an integer index +** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). +*/ +int luaH_getn (Table *t) { + unsigned int j = t->sizearray; + if (j > 0 && ttisnil(&t->array[j - 1])) { + /* there is a boundary in the array part: (binary) search for it */ + unsigned int i = 0; + while (j - i > 1) { + unsigned int m = (i+j)/2; + if (ttisnil(&t->array[m - 1])) j = m; + else i = m; + } + return i; + } + /* else must find a boundary in hash part */ + else if (t->node == dummynode) /* hash part is empty? */ + return j; /* that is easy... */ + else return unbound_search(t, j); +} + + + +#if defined(LUA_DEBUG) + +Node *luaH_mainposition (const Table *t, const TValue *key) { + return mainposition(t, key); +} + +int luaH_isdummy (Node *n) { return n == dummynode; } + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/ltable.h.svn-base blobby-0.9c/src/lua/.svn/text-base/ltable.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/ltable.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/ltable.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,40 @@ +/* +** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua tables (hash) +** See Copyright Notice in lua.h +*/ + +#ifndef ltable_h +#define ltable_h + +#include "lobject.h" + + +#define gnode(t,i) (&(t)->node[i]) +#define gkey(n) (&(n)->i_key.nk) +#define gval(n) (&(n)->i_val) +#define gnext(n) ((n)->i_key.nk.next) + +#define key2tval(n) (&(n)->i_key.tvk) + + +LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); +LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); +LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); +LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); +LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); +LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); +LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); +LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); +LUAI_FUNC void luaH_free (lua_State *L, Table *t); +LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); +LUAI_FUNC int luaH_getn (Table *t); + + +#if defined(LUA_DEBUG) +LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); +LUAI_FUNC int luaH_isdummy (Node *n); +#endif + + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/ltablib.c.svn-base blobby-0.9c/src/lua/.svn/text-base/ltablib.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/ltablib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/ltablib.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,287 @@ +/* +** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $ +** Library for Table Manipulation +** See Copyright Notice in lua.h +*/ + + +#include + +#define ltablib_c +#define LUA_LIB + +#include "lua.h" + +#include "lauxlib.h" +#include "lualib.h" + + +#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) + + +static int foreachi (lua_State *L) { + int i; + int n = aux_getn(L, 1); + luaL_checktype(L, 2, LUA_TFUNCTION); + for (i=1; i <= n; i++) { + lua_pushvalue(L, 2); /* function */ + lua_pushinteger(L, i); /* 1st argument */ + lua_rawgeti(L, 1, i); /* 2nd argument */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 1); /* remove nil result */ + } + return 0; +} + + +static int foreach (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); + luaL_checktype(L, 2, LUA_TFUNCTION); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pushvalue(L, 2); /* function */ + lua_pushvalue(L, -3); /* key */ + lua_pushvalue(L, -3); /* value */ + lua_call(L, 2, 1); + if (!lua_isnil(L, -1)) + return 1; + lua_pop(L, 2); /* remove value and result */ + } + return 0; +} + + +static int maxn (lua_State *L) { + lua_Number max = 0; + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushnil(L); /* first key */ + while (lua_next(L, 1)) { + lua_pop(L, 1); /* remove value */ + if (lua_type(L, -1) == LUA_TNUMBER) { + lua_Number v = lua_tonumber(L, -1); + if (v > max) max = v; + } + } + lua_pushnumber(L, max); + return 1; +} + + +static int getn (lua_State *L) { + lua_pushinteger(L, aux_getn(L, 1)); + return 1; +} + + +static int setn (lua_State *L) { + luaL_checktype(L, 1, LUA_TTABLE); +#ifndef luaL_setn + luaL_setn(L, 1, luaL_checkint(L, 2)); +#else + luaL_error(L, LUA_QL("setn") " is obsolete"); +#endif + lua_pushvalue(L, 1); + return 1; +} + + +static int tinsert (lua_State *L) { + int e = aux_getn(L, 1) + 1; /* first empty element */ + int pos; /* where to insert new element */ + switch (lua_gettop(L)) { + case 2: { /* called with only 2 arguments */ + pos = e; /* insert new element at the end */ + break; + } + case 3: { + int i; + pos = luaL_checkint(L, 2); /* 2nd argument is the position */ + if (pos > e) e = pos; /* `grow' array if necessary */ + for (i = e; i > pos; i--) { /* move up elements */ + lua_rawgeti(L, 1, i-1); + lua_rawseti(L, 1, i); /* t[i] = t[i-1] */ + } + break; + } + default: { + return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); + } + } + luaL_setn(L, 1, e); /* new size */ + lua_rawseti(L, 1, pos); /* t[pos] = v */ + return 0; +} + + +static int tremove (lua_State *L) { + int e = aux_getn(L, 1); + int pos = luaL_optint(L, 2, e); + if (!(1 <= pos && pos <= e)) /* position is outside bounds? */ + return 0; /* nothing to remove */ + luaL_setn(L, 1, e - 1); /* t.n = n-1 */ + lua_rawgeti(L, 1, pos); /* result = t[pos] */ + for ( ;pos= P */ + while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { + if (i>u) luaL_error(L, "invalid order function for sorting"); + lua_pop(L, 1); /* remove a[i] */ + } + /* repeat --j until a[j] <= P */ + while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { + if (j + +#define ltm_c +#define LUA_CORE + +#include "lua.h" + +#include "lobject.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" + + + +const char *const luaT_typenames[] = { + "nil", "boolean", "userdata", "number", + "string", "table", "function", "userdata", "thread", + "proto", "upval" +}; + + +void luaT_init (lua_State *L) { + static const char *const luaT_eventname[] = { /* ORDER TM */ + "__index", "__newindex", + "__gc", "__mode", "__eq", + "__add", "__sub", "__mul", "__div", "__mod", + "__pow", "__unm", "__len", "__lt", "__le", + "__concat", "__call" + }; + int i; + for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); + luaS_fix(G(L)->tmname[i]); /* never collect these names */ + } +} + + +/* +** function to be used with macro "fasttm": optimized for absence of +** tag methods +*/ +const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { + const TValue *tm = luaH_getstr(events, ename); + lua_assert(event <= TM_EQ); + if (ttisnil(tm)) { /* no tag method? */ + events->flags |= cast_byte(1u<metatable; + break; + case LUA_TUSERDATA: + mt = uvalue(o)->metatable; + break; + default: + mt = G(L)->mt[ttype(o)]; + } + return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/ltm.h.svn-base blobby-0.9c/src/lua/.svn/text-base/ltm.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/ltm.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/ltm.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,54 @@ +/* +** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ +** Tag methods +** See Copyright Notice in lua.h +*/ + +#ifndef ltm_h +#define ltm_h + + +#include "lobject.h" + + +/* +* WARNING: if you change the order of this enumeration, +* grep "ORDER TM" +*/ +typedef enum { + TM_INDEX, + TM_NEWINDEX, + TM_GC, + TM_MODE, + TM_EQ, /* last tag method with `fast' access */ + TM_ADD, + TM_SUB, + TM_MUL, + TM_DIV, + TM_MOD, + TM_POW, + TM_UNM, + TM_LEN, + TM_LT, + TM_LE, + TM_CONCAT, + TM_CALL, + TM_N /* number of elements in the enum */ +} TMS; + + + +#define gfasttm(g,et,e) ((et) == NULL ? NULL : \ + ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) + +#define fasttm(l,et,e) gfasttm(G(l), et, e) + +LUAI_DATA const char *const luaT_typenames[]; + + +LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); +LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, + TMS event); +LUAI_FUNC void luaT_init (lua_State *L); + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/luaconf.h.svn-base blobby-0.9c/src/lua/.svn/text-base/luaconf.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/luaconf.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/luaconf.h.svn-base 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,763 @@ +/* +** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $ +** Configuration file for Lua +** See Copyright Notice in lua.h +*/ + + +#ifndef lconfig_h +#define lconfig_h + +#include +#include + + +/* +** ================================================================== +** Search for "@@" to find all configurable definitions. +** =================================================================== +*/ + + +/* +@@ LUA_ANSI controls the use of non-ansi features. +** CHANGE it (define it) if you want Lua to avoid the use of any +** non-ansi feature or library. +*/ +#if defined(__STRICT_ANSI__) +#define LUA_ANSI +#endif + + +#if !defined(LUA_ANSI) && defined(_WIN32) +#define LUA_WIN +#endif + +#if defined(LUA_USE_LINUX) +#define LUA_USE_POSIX +#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ +#define LUA_USE_READLINE /* needs some extra libraries */ +#endif + +#if defined(LUA_USE_MACOSX) +#define LUA_USE_POSIX +#define LUA_DL_DYLD /* does not need extra library */ +#endif + + + +/* +@@ LUA_USE_POSIX includes all functionallity listed as X/Open System +@* Interfaces Extension (XSI). +** CHANGE it (define it) if your system is XSI compatible. +*/ +#if defined(LUA_USE_POSIX) +#define LUA_USE_MKSTEMP +#define LUA_USE_ISATTY +#define LUA_USE_POPEN +#define LUA_USE_ULONGJMP +#endif + + +/* +@@ LUA_PATH and LUA_CPATH are the names of the environment variables that +@* Lua check to set its paths. +@@ LUA_INIT is the name of the environment variable that Lua +@* checks for initialization code. +** CHANGE them if you want different names. +*/ +#define LUA_PATH "LUA_PATH" +#define LUA_CPATH "LUA_CPATH" +#define LUA_INIT "LUA_INIT" + + +/* +@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for +@* Lua libraries. +@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for +@* C libraries. +** CHANGE them if your machine has a non-conventional directory +** hierarchy or if you want to install your libraries in +** non-conventional directories. +*/ +#if defined(_WIN32) +/* +** In Windows, any exclamation mark ('!') in the path is replaced by the +** path of the directory of the executable file of the current process. +*/ +#define LUA_LDIR "!\\lua\\" +#define LUA_CDIR "!\\" +#define LUA_PATH_DEFAULT \ + ".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua" +#define LUA_CPATH_DEFAULT \ + ".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" + +#else +#define LUA_ROOT "/usr/local/" +#define LUA_LDIR LUA_ROOT "share/lua/5.1/" +#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" +#define LUA_PATH_DEFAULT \ + "./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ + LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" +#define LUA_CPATH_DEFAULT \ + "./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so" +#endif + + +/* +@@ LUA_DIRSEP is the directory separator (for submodules). +** CHANGE it if your machine does not use "/" as the directory separator +** and is not Windows. (On Windows Lua automatically uses "\".) +*/ +#if defined(_WIN32) +#define LUA_DIRSEP "\\" +#else +#define LUA_DIRSEP "/" +#endif + + +/* +@@ LUA_PATHSEP is the character that separates templates in a path. +@@ LUA_PATH_MARK is the string that marks the substitution points in a +@* template. +@@ LUA_EXECDIR in a Windows path is replaced by the executable's +@* directory. +@@ LUA_IGMARK is a mark to ignore all before it when bulding the +@* luaopen_ function name. +** CHANGE them if for some reason your system cannot use those +** characters. (E.g., if one of those characters is a common character +** in file/directory names.) Probably you do not need to change them. +*/ +#define LUA_PATHSEP ";" +#define LUA_PATH_MARK "?" +#define LUA_EXECDIR "!" +#define LUA_IGMARK "-" + + +/* +@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. +** CHANGE that if ptrdiff_t is not adequate on your machine. (On most +** machines, ptrdiff_t gives a good choice between int or long.) +*/ +#define LUA_INTEGER ptrdiff_t + + +/* +@@ LUA_API is a mark for all core API functions. +@@ LUALIB_API is a mark for all standard library functions. +** CHANGE them if you need to define those functions in some special way. +** For instance, if you want to create one Windows DLL with the core and +** the libraries, you may want to use the following definition (define +** LUA_BUILD_AS_DLL to get it). +*/ +#if defined(LUA_BUILD_AS_DLL) + +#if defined(LUA_CORE) || defined(LUA_LIB) +#define LUA_API __declspec(dllexport) +#else +#define LUA_API __declspec(dllimport) +#endif + +#else + +#define LUA_API extern + +#endif + +/* more often than not the libs go together with the core */ +#define LUALIB_API LUA_API + + +/* +@@ LUAI_FUNC is a mark for all extern functions that are not to be +@* exported to outside modules. +@@ LUAI_DATA is a mark for all extern (const) variables that are not to +@* be exported to outside modules. +** CHANGE them if you need to mark them in some special way. Elf/gcc +** (versions 3.2 and later) mark them as "hidden" to optimize access +** when Lua is compiled as a shared library. +*/ +#if defined(luaall_c) +#define LUAI_FUNC static +#define LUAI_DATA /* empty */ + +#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \ + defined(__ELF__) +#define LUAI_FUNC __attribute__((visibility("hidden"))) extern +#define LUAI_DATA LUAI_FUNC + +#else +#define LUAI_FUNC extern +#define LUAI_DATA extern +#endif + + + +/* +@@ LUA_QL describes how error messages quote program elements. +** CHANGE it if you want a different appearance. +*/ +#define LUA_QL(x) "'" x "'" +#define LUA_QS LUA_QL("%s") + + +/* +@@ LUA_IDSIZE gives the maximum size for the description of the source +@* of a function in debug information. +** CHANGE it if you want a different size. +*/ +#define LUA_IDSIZE 60 + + +/* +** {================================================================== +** Stand-alone configuration +** =================================================================== +*/ + +#if defined(lua_c) || defined(luaall_c) + +/* +@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that +@* is, whether we're running lua interactively). +** CHANGE it if you have a better definition for non-POSIX/non-Windows +** systems. +*/ +#if defined(LUA_USE_ISATTY) +#include +#define lua_stdin_is_tty() isatty(0) +#elif defined(LUA_WIN) +#include +#include +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#else +#define lua_stdin_is_tty() 1 /* assume stdin is a tty */ +#endif + + +/* +@@ LUA_PROMPT is the default prompt used by stand-alone Lua. +@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua. +** CHANGE them if you want different prompts. (You can also change the +** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) +*/ +#define LUA_PROMPT "> " +#define LUA_PROMPT2 ">> " + + +/* +@@ LUA_PROGNAME is the default name for the stand-alone Lua program. +** CHANGE it if your stand-alone interpreter has a different name and +** your system is not able to detect that name automatically. +*/ +#define LUA_PROGNAME "lua" + + +/* +@@ LUA_MAXINPUT is the maximum length for an input line in the +@* stand-alone interpreter. +** CHANGE it if you need longer lines. +*/ +#define LUA_MAXINPUT 512 + + +/* +@@ lua_readline defines how to show a prompt and then read a line from +@* the standard input. +@@ lua_saveline defines how to "save" a read line in a "history". +@@ lua_freeline defines how to free a line read by lua_readline. +** CHANGE them if you want to improve this functionality (e.g., by using +** GNU readline and history facilities). +*/ +#if defined(LUA_USE_READLINE) +#include +#include +#include +#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL) +#define lua_saveline(L,idx) \ + if (lua_strlen(L,idx) > 0) /* non-empty line? */ \ + add_history(lua_tostring(L, idx)); /* add it to history */ +#define lua_freeline(L,b) ((void)L, free(b)) +#else +#define lua_readline(L,b,p) \ + ((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \ + fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */ +#define lua_saveline(L,idx) { (void)L; (void)idx; } +#define lua_freeline(L,b) { (void)L; (void)b; } +#endif + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles +@* as a percentage. +** CHANGE it if you want the GC to run faster or slower (higher values +** mean larger pauses which mean slower collection.) You can also change +** this value dynamically. +*/ +#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */ + + +/* +@@ LUAI_GCMUL defines the default speed of garbage collection relative to +@* memory allocation as a percentage. +** CHANGE it if you want to change the granularity of the garbage +** collection. (Higher values mean coarser collections. 0 represents +** infinity, where each step performs a full collection.) You can also +** change this value dynamically. +*/ +#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ + + + +/* +@@ LUA_COMPAT_GETN controls compatibility with old getn behavior. +** CHANGE it (define it) if you want exact compatibility with the +** behavior of setn/getn in Lua 5.0. +*/ +#undef LUA_COMPAT_GETN + +/* +@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. +** CHANGE it to undefined as soon as you do not need a global 'loadlib' +** function (the function is still available as 'package.loadlib'). +*/ +#undef LUA_COMPAT_LOADLIB + +/* +@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. +** CHANGE it to undefined as soon as your programs use only '...' to +** access vararg parameters (instead of the old 'arg' table). +*/ +#define LUA_COMPAT_VARARG + +/* +@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. +** CHANGE it to undefined as soon as your programs use 'math.fmod' or +** the new '%' operator instead of 'math.mod'. +*/ +#define LUA_COMPAT_MOD + +/* +@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting +@* facility. +** CHANGE it to 2 if you want the old behaviour, or undefine it to turn +** off the advisory error when nesting [[...]]. +*/ +#define LUA_COMPAT_LSTR 1 + +/* +@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. +** CHANGE it to undefined as soon as you rename 'string.gfind' to +** 'string.gmatch'. +*/ +#define LUA_COMPAT_GFIND + +/* +@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' +@* behavior. +** CHANGE it to undefined as soon as you replace to 'luaL_register' +** your uses of 'luaL_openlib' +*/ +#define LUA_COMPAT_OPENLIB + + + +/* +@@ luai_apicheck is the assert macro used by the Lua-C API. +** CHANGE luai_apicheck if you want Lua to perform some checks in the +** parameters it gets from API calls. This may slow down the interpreter +** a bit, but may be quite useful when debugging C code that interfaces +** with Lua. A useful redefinition is to use assert.h. +*/ +#if defined(LUA_USE_APICHECK) +#include +#define luai_apicheck(L,o) { (void)L; assert(o); } +#else +#define luai_apicheck(L,o) { (void)L; } +#endif + + +/* +@@ LUAI_BITSINT defines the number of bits in an int. +** CHANGE here if Lua cannot automatically detect the number of bits of +** your machine. Probably you do not need to change this. +*/ +/* avoid overflows in comparison */ +#if INT_MAX-20 < 32760 +#define LUAI_BITSINT 16 +#elif INT_MAX > 2147483640L +/* int has at least 32 bits */ +#define LUAI_BITSINT 32 +#else +#error "you must define LUA_BITSINT with number of bits in an integer" +#endif + + +/* +@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. +@@ LUAI_INT32 is an signed integer with at least 32 bits. +@@ LUAI_UMEM is an unsigned integer big enough to count the total +@* memory used by Lua. +@@ LUAI_MEM is a signed integer big enough to count the total memory +@* used by Lua. +** CHANGE here if for some weird reason the default definitions are not +** good enough for your machine. (The definitions in the 'else' +** part always works, but may waste space on machines with 64-bit +** longs.) Probably you do not need to change this. +*/ +#if LUAI_BITSINT >= 32 +#define LUAI_UINT32 unsigned int +#define LUAI_INT32 int +#define LUAI_MAXINT32 INT_MAX +#define LUAI_UMEM size_t +#define LUAI_MEM ptrdiff_t +#else +/* 16-bit ints */ +#define LUAI_UINT32 unsigned long +#define LUAI_INT32 long +#define LUAI_MAXINT32 LONG_MAX +#define LUAI_UMEM unsigned long +#define LUAI_MEM long +#endif + + +/* +@@ LUAI_MAXCALLS limits the number of nested calls. +** CHANGE it if you need really deep recursive calls. This limit is +** arbitrary; its only purpose is to stop infinite recursion before +** exhausting memory. +*/ +#define LUAI_MAXCALLS 20000 + + +/* +@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function +@* can use. +** CHANGE it if you need lots of (Lua) stack space for your C +** functions. This limit is arbitrary; its only purpose is to stop C +** functions to consume unlimited stack space. (must be smaller than +** -LUA_REGISTRYINDEX) +*/ +#define LUAI_MAXCSTACK 8000 + + + +/* +** {================================================================== +** CHANGE (to smaller values) the following definitions if your system +** has a small C stack. (Or you may want to change them to larger +** values if your system has a large C stack and these limits are +** too rigid for you.) Some of these constants control the size of +** stack-allocated arrays used by the compiler or the interpreter, while +** others limit the maximum number of recursive calls that the compiler +** or the interpreter can perform. Values too large may cause a C stack +** overflow for some forms of deep constructs. +** =================================================================== +*/ + + +/* +@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and +@* syntactical nested non-terminals in a program. +*/ +#define LUAI_MAXCCALLS 200 + + +/* +@@ LUAI_MAXVARS is the maximum number of local variables per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXVARS 200 + + +/* +@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function +@* (must be smaller than 250). +*/ +#define LUAI_MAXUPVALUES 60 + + +/* +@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. +*/ +#define LUAL_BUFFERSIZE BUFSIZ + +/* }================================================================== */ + + + + +/* +** {================================================================== +@@ LUA_NUMBER is the type of numbers in Lua. +** CHANGE the following definitions only if you want to build Lua +** with a number type different from double. You may also need to +** change lua_number2int & lua_number2integer. +** =================================================================== +*/ + +#define LUA_NUMBER_DOUBLE +#define LUA_NUMBER double + +/* +@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' +@* over a number. +*/ +#define LUAI_UACNUMBER double + + +/* +@@ LUA_NUMBER_SCAN is the format for reading numbers. +@@ LUA_NUMBER_FMT is the format for writing numbers. +@@ lua_number2str converts a number to a string. +@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion. +@@ lua_str2number converts a string to a number. +*/ +#define LUA_NUMBER_SCAN "%lf" +#define LUA_NUMBER_FMT "%.14g" +#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */ +#define lua_str2number(s,p) strtod((s), (p)) + + +/* +@@ The luai_num* macros define the primitive operations over numbers. +*/ +#if defined(LUA_CORE) +#include +#define luai_numadd(a,b) ((a)+(b)) +#define luai_numsub(a,b) ((a)-(b)) +#define luai_nummul(a,b) ((a)*(b)) +#define luai_numdiv(a,b) ((a)/(b)) +#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) +#define luai_numpow(a,b) (pow(a,b)) +#define luai_numunm(a) (-(a)) +#define luai_numeq(a,b) ((a)==(b)) +#define luai_numlt(a,b) ((a)<(b)) +#define luai_numle(a,b) ((a)<=(b)) +#define luai_numisnan(a) (!luai_numeq((a), (a))) +#endif + + +/* +@@ lua_number2int is a macro to convert lua_Number to int. +@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. +** CHANGE them if you know a faster way to convert a lua_Number to +** int (with any rounding method and without throwing errors) in your +** system. In Pentium machines, a naive typecast from double to int +** in C is extremely slow, so any alternative is worth trying. +*/ + +/* On a Pentium, resort to a trick */ +#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ + (defined(__i386) || defined (_M_IX86) || defined(__i386__)) + +/* On a Microsoft compiler, use assembler */ +#if defined(_MSC_VER) + +#define lua_number2int(i,d) __asm fld d __asm fistp i +#define lua_number2integer(i,n) lua_number2int(i, n) + +/* the next trick should work on any Pentium, but sometimes clashes + with a DirectX idiosyncrasy */ +#else + +union luai_Cast { double l_d; long l_l; }; +#define lua_number2int(i,d) \ + { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } +#define lua_number2integer(i,n) lua_number2int(i, n) + +#endif + + +/* this option always works, but may be slow */ +#else +#define lua_number2int(i,d) ((i)=(int)(d)) +#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) + +#endif + +/* }================================================================== */ + + +/* +@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. +** CHANGE it if your system requires alignments larger than double. (For +** instance, if your system supports long doubles and they must be +** aligned in 16-byte boundaries, then you should add long double in the +** union.) Probably you do not need to change this. +*/ +#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } + + +/* +@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling. +** CHANGE them if you prefer to use longjmp/setjmp even with C++ +** or if want/don't to use _longjmp/_setjmp instead of regular +** longjmp/setjmp. By default, Lua handles errors with exceptions when +** compiling as C++ code, with _longjmp/_setjmp when asked to use them, +** and with longjmp/setjmp otherwise. +*/ +#if defined(__cplusplus) +/* C++ exceptions */ +#define LUAI_THROW(L,c) throw(c) +#define LUAI_TRY(L,c,a) try { a } catch(...) \ + { if ((c)->status == 0) (c)->status = -1; } +#define luai_jmpbuf int /* dummy variable */ + +#elif defined(LUA_USE_ULONGJMP) +/* in Unix, try _longjmp/_setjmp (more efficient) */ +#define LUAI_THROW(L,c) _longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#else +/* default handling with long jumps */ +#define LUAI_THROW(L,c) longjmp((c)->b, 1) +#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a } +#define luai_jmpbuf jmp_buf + +#endif + + +/* +@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern +@* can do during pattern-matching. +** CHANGE it if you need more captures. This limit is arbitrary. +*/ +#define LUA_MAXCAPTURES 32 + + +/* +@@ lua_tmpnam is the function that the OS library uses to create a +@* temporary name. +@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam. +** CHANGE them if you have an alternative to tmpnam (which is considered +** insecure) or if you want the original tmpnam anyway. By default, Lua +** uses tmpnam except when POSIX is available, where it uses mkstemp. +*/ +#if defined(loslib_c) || defined(luaall_c) + +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#else +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } +#endif + +#endif + + +/* +@@ lua_popen spawns a new process connected to the current one through +@* the file streams. +** CHANGE it if you have a way to implement it in your system. +*/ +#if defined(LUA_USE_POPEN) + +#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m)) +#define lua_pclose(L,file) ((void)L, (pclose(file) != -1)) + +#elif defined(LUA_WIN) + +#define lua_popen(L,c,m) ((void)L, _popen(c,m)) +#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1)) + +#else + +#define lua_popen(L,c,m) ((void)((void)c, m), \ + luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0) +#define lua_pclose(L,file) ((void)((void)L, file), 0) + +#endif + +/* +@@ LUA_DL_* define which dynamic-library system Lua should use. +** CHANGE here if Lua has problems choosing the appropriate +** dynamic-library system for your platform (either Windows' DLL, Mac's +** dyld, or Unix's dlopen). If your system is some kind of Unix, there +** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for +** it. To use dlopen you also need to adapt the src/Makefile (probably +** adding -ldl to the linker options), so Lua does not select it +** automatically. (When you change the makefile to add -ldl, you must +** also add -DLUA_USE_DLOPEN.) +** If you do not want any kind of dynamic library, undefine all these +** options. +** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD. +*/ +#if defined(LUA_USE_DLOPEN) +#define LUA_DL_DLOPEN +#endif + +#if defined(LUA_WIN) +#define LUA_DL_DLL +#endif + + +/* +@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State +@* (the data goes just *before* the lua_State pointer). +** CHANGE (define) this if you really need that. This value must be +** a multiple of the maximum alignment required for your machine. +*/ +#define LUAI_EXTRASPACE 0 + + +/* +@@ luai_userstate* allow user-specific actions on threads. +** CHANGE them if you defined LUAI_EXTRASPACE and need to do something +** extra when a thread is created/deleted/resumed/yielded. +*/ +#define luai_userstateopen(L) ((void)L) +#define luai_userstateclose(L) ((void)L) +#define luai_userstatethread(L,L1) ((void)L) +#define luai_userstatefree(L) ((void)L) +#define luai_userstateresume(L,n) ((void)L) +#define luai_userstateyield(L,n) ((void)L) + + +/* +@@ LUA_INTFRMLEN is the length modifier for integer conversions +@* in 'string.format'. +@@ LUA_INTFRM_T is the integer type correspoding to the previous length +@* modifier. +** CHANGE them if your system supports long long or does not support long. +*/ + +#if defined(LUA_USELONGLONG) + +#define LUA_INTFRMLEN "ll" +#define LUA_INTFRM_T long long + +#else + +#define LUA_INTFRMLEN "l" +#define LUA_INTFRM_T long + +#endif + + + +/* =================================================================== */ + +/* +** Local configuration. You can use this space to add your redefinitions +** without modifying the main part of the file. +*/ + + + +#endif + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lua.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lua.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lua.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lua.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,388 @@ +/* +** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ +** Lua - An Extensible Extension Language +** Lua.org, PUC-Rio, Brazil (http://www.lua.org) +** See Copyright Notice at the end of this file +*/ + + +#ifndef lua_h +#define lua_h + +#include +#include + + +#include "luaconf.h" + + +#define LUA_VERSION "Lua 5.1" +#define LUA_RELEASE "Lua 5.1.4" +#define LUA_VERSION_NUM 501 +#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" +#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" + + +/* mark for precompiled code (`Lua') */ +#define LUA_SIGNATURE "\033Lua" + +/* option for multiple returns in `lua_pcall' and `lua_call' */ +#define LUA_MULTRET (-1) + + +/* +** pseudo-indices +*/ +#define LUA_REGISTRYINDEX (-10000) +#define LUA_ENVIRONINDEX (-10001) +#define LUA_GLOBALSINDEX (-10002) +#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) + + +/* thread status; 0 is OK */ +#define LUA_YIELD 1 +#define LUA_ERRRUN 2 +#define LUA_ERRSYNTAX 3 +#define LUA_ERRMEM 4 +#define LUA_ERRERR 5 + + +typedef struct lua_State lua_State; + +typedef int (*lua_CFunction) (lua_State *L); + + +/* +** functions that read/write blocks when loading/dumping Lua chunks +*/ +typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); + +typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); + + +/* +** prototype for memory-allocation functions +*/ +typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); + + +/* +** basic types +*/ +#define LUA_TNONE (-1) + +#define LUA_TNIL 0 +#define LUA_TBOOLEAN 1 +#define LUA_TLIGHTUSERDATA 2 +#define LUA_TNUMBER 3 +#define LUA_TSTRING 4 +#define LUA_TTABLE 5 +#define LUA_TFUNCTION 6 +#define LUA_TUSERDATA 7 +#define LUA_TTHREAD 8 + + + +/* minimum Lua stack available to a C function */ +#define LUA_MINSTACK 20 + + +/* +** generic extra include file +*/ +#if defined(LUA_USER_H) +#include LUA_USER_H +#endif + + +/* type of numbers in Lua */ +typedef LUA_NUMBER lua_Number; + + +/* type for integer functions */ +typedef LUA_INTEGER lua_Integer; + + + +/* +** state manipulation +*/ +LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); +LUA_API void (lua_close) (lua_State *L); +LUA_API lua_State *(lua_newthread) (lua_State *L); + +LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + + +/* +** basic stack manipulation +*/ +LUA_API int (lua_gettop) (lua_State *L); +LUA_API void (lua_settop) (lua_State *L, int idx); +LUA_API void (lua_pushvalue) (lua_State *L, int idx); +LUA_API void (lua_remove) (lua_State *L, int idx); +LUA_API void (lua_insert) (lua_State *L, int idx); +LUA_API void (lua_replace) (lua_State *L, int idx); +LUA_API int (lua_checkstack) (lua_State *L, int sz); + +LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); + + +/* +** access functions (stack -> C) +*/ + +LUA_API int (lua_isnumber) (lua_State *L, int idx); +LUA_API int (lua_isstring) (lua_State *L, int idx); +LUA_API int (lua_iscfunction) (lua_State *L, int idx); +LUA_API int (lua_isuserdata) (lua_State *L, int idx); +LUA_API int (lua_type) (lua_State *L, int idx); +LUA_API const char *(lua_typename) (lua_State *L, int tp); + +LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); +LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); + +LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); +LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); +LUA_API int (lua_toboolean) (lua_State *L, int idx); +LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); +LUA_API size_t (lua_objlen) (lua_State *L, int idx); +LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); +LUA_API void *(lua_touserdata) (lua_State *L, int idx); +LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); +LUA_API const void *(lua_topointer) (lua_State *L, int idx); + + +/* +** push functions (C -> stack) +*/ +LUA_API void (lua_pushnil) (lua_State *L); +LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); +LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); +LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); +LUA_API void (lua_pushstring) (lua_State *L, const char *s); +LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, + va_list argp); +LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); +LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); +LUA_API void (lua_pushboolean) (lua_State *L, int b); +LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); +LUA_API int (lua_pushthread) (lua_State *L); + + +/* +** get functions (Lua -> stack) +*/ +LUA_API void (lua_gettable) (lua_State *L, int idx); +LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawget) (lua_State *L, int idx); +LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); +LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); +LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); +LUA_API int (lua_getmetatable) (lua_State *L, int objindex); +LUA_API void (lua_getfenv) (lua_State *L, int idx); + + +/* +** set functions (stack -> Lua) +*/ +LUA_API void (lua_settable) (lua_State *L, int idx); +LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); +LUA_API void (lua_rawset) (lua_State *L, int idx); +LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); +LUA_API int (lua_setmetatable) (lua_State *L, int objindex); +LUA_API int (lua_setfenv) (lua_State *L, int idx); + + +/* +** `load' and `call' functions (load and run Lua code) +*/ +LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); +LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); +LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); +LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, + const char *chunkname); + +LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); + + +/* +** coroutine functions +*/ +LUA_API int (lua_yield) (lua_State *L, int nresults); +LUA_API int (lua_resume) (lua_State *L, int narg); +LUA_API int (lua_status) (lua_State *L); + +/* +** garbage-collection function and options +*/ + +#define LUA_GCSTOP 0 +#define LUA_GCRESTART 1 +#define LUA_GCCOLLECT 2 +#define LUA_GCCOUNT 3 +#define LUA_GCCOUNTB 4 +#define LUA_GCSTEP 5 +#define LUA_GCSETPAUSE 6 +#define LUA_GCSETSTEPMUL 7 + +LUA_API int (lua_gc) (lua_State *L, int what, int data); + + +/* +** miscellaneous functions +*/ + +LUA_API int (lua_error) (lua_State *L); + +LUA_API int (lua_next) (lua_State *L, int idx); + +LUA_API void (lua_concat) (lua_State *L, int n); + +LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); +LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); + + + +/* +** =============================================================== +** some useful macros +** =============================================================== +*/ + +#define lua_pop(L,n) lua_settop(L, -(n)-1) + +#define lua_newtable(L) lua_createtable(L, 0, 0) + +#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) + +#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) + +#define lua_strlen(L,i) lua_objlen(L, (i)) + +#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) +#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) +#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) +#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) +#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) +#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) +#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) + +#define lua_pushliteral(L, s) \ + lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) + +#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) +#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) + +#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) + + + +/* +** compatibility macros and functions +*/ + +#define lua_open() luaL_newstate() + +#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) + +#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) + +#define lua_Chunkreader lua_Reader +#define lua_Chunkwriter lua_Writer + + +/* hack */ +LUA_API void lua_setlevel (lua_State *from, lua_State *to); + + +/* +** {====================================================================== +** Debug API +** ======================================================================= +*/ + + +/* +** Event codes +*/ +#define LUA_HOOKCALL 0 +#define LUA_HOOKRET 1 +#define LUA_HOOKLINE 2 +#define LUA_HOOKCOUNT 3 +#define LUA_HOOKTAILRET 4 + + +/* +** Event masks +*/ +#define LUA_MASKCALL (1 << LUA_HOOKCALL) +#define LUA_MASKRET (1 << LUA_HOOKRET) +#define LUA_MASKLINE (1 << LUA_HOOKLINE) +#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) + +typedef struct lua_Debug lua_Debug; /* activation record */ + + +/* Functions to be called by the debuger in specific events */ +typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); + + +LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); +LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); +LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); +LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); +LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); + +LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); +LUA_API lua_Hook lua_gethook (lua_State *L); +LUA_API int lua_gethookmask (lua_State *L); +LUA_API int lua_gethookcount (lua_State *L); + + +struct lua_Debug { + int event; + const char *name; /* (n) */ + const char *namewhat; /* (n) `global', `local', `field', `method' */ + const char *what; /* (S) `Lua', `C', `main', `tail' */ + const char *source; /* (S) */ + int currentline; /* (l) */ + int nups; /* (u) number of upvalues */ + int linedefined; /* (S) */ + int lastlinedefined; /* (S) */ + char short_src[LUA_IDSIZE]; /* (S) */ + /* private part */ + int i_ci; /* active function */ +}; + +/* }====================================================================== */ + + +/****************************************************************************** +* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +******************************************************************************/ + + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lualib.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lualib.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lualib.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lualib.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,53 @@ +/* +** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua standard libraries +** See Copyright Notice in lua.h +*/ + + +#ifndef lualib_h +#define lualib_h + +#include "lua.h" + + +/* Key to file-handle type */ +#define LUA_FILEHANDLE "FILE*" + + +#define LUA_COLIBNAME "coroutine" +LUALIB_API int (luaopen_base) (lua_State *L); + +#define LUA_TABLIBNAME "table" +LUALIB_API int (luaopen_table) (lua_State *L); + +#define LUA_IOLIBNAME "io" +LUALIB_API int (luaopen_io) (lua_State *L); + +#define LUA_OSLIBNAME "os" +LUALIB_API int (luaopen_os) (lua_State *L); + +#define LUA_STRLIBNAME "string" +LUALIB_API int (luaopen_string) (lua_State *L); + +#define LUA_MATHLIBNAME "math" +LUALIB_API int (luaopen_math) (lua_State *L); + +#define LUA_DBLIBNAME "debug" +LUALIB_API int (luaopen_debug) (lua_State *L); + +#define LUA_LOADLIBNAME "package" +LUALIB_API int (luaopen_package) (lua_State *L); + + +/* open all previous libraries */ +LUALIB_API void (luaL_openlibs) (lua_State *L); + + + +#ifndef lua_assert +#define lua_assert(x) ((void)0) +#endif + + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lundump.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lundump.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lundump.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lundump.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,227 @@ +/* +** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#include + +#define lundump_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lmem.h" +#include "lobject.h" +#include "lstring.h" +#include "lundump.h" +#include "lzio.h" + +typedef struct { + lua_State* L; + ZIO* Z; + Mbuffer* b; + const char* name; +} LoadState; + +#ifdef LUAC_TRUST_BINARIES +#define IF(c,s) +#define error(S,s) +#else +#define IF(c,s) if (c) error(S,s) + +static void error(LoadState* S, const char* why) +{ + luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why); + luaD_throw(S->L,LUA_ERRSYNTAX); +} +#endif + +#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size)) +#define LoadByte(S) (lu_byte)LoadChar(S) +#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x)) +#define LoadVector(S,b,n,size) LoadMem(S,b,n,size) + +static void LoadBlock(LoadState* S, void* b, size_t size) +{ + size_t r=luaZ_read(S->Z,b,size); + IF (r!=0, "unexpected end"); +} + +static int LoadChar(LoadState* S) +{ + char x; + LoadVar(S,x); + return x; +} + +static int LoadInt(LoadState* S) +{ + int x; + LoadVar(S,x); + IF (x<0, "bad integer"); + return x; +} + +static lua_Number LoadNumber(LoadState* S) +{ + lua_Number x; + LoadVar(S,x); + return x; +} + +static TString* LoadString(LoadState* S) +{ + size_t size; + LoadVar(S,size); + if (size==0) + return NULL; + else + { + char* s=luaZ_openspace(S->L,S->b,size); + LoadBlock(S,s,size); + return luaS_newlstr(S->L,s,size-1); /* remove trailing '\0' */ + } +} + +static void LoadCode(LoadState* S, Proto* f) +{ + int n=LoadInt(S); + f->code=luaM_newvector(S->L,n,Instruction); + f->sizecode=n; + LoadVector(S,f->code,n,sizeof(Instruction)); +} + +static Proto* LoadFunction(LoadState* S, TString* p); + +static void LoadConstants(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->k=luaM_newvector(S->L,n,TValue); + f->sizek=n; + for (i=0; ik[i]); + for (i=0; ik[i]; + int t=LoadChar(S); + switch (t) + { + case LUA_TNIL: + setnilvalue(o); + break; + case LUA_TBOOLEAN: + setbvalue(o,LoadChar(S)!=0); + break; + case LUA_TNUMBER: + setnvalue(o,LoadNumber(S)); + break; + case LUA_TSTRING: + setsvalue2n(S->L,o,LoadString(S)); + break; + default: + error(S,"bad constant"); + break; + } + } + n=LoadInt(S); + f->p=luaM_newvector(S->L,n,Proto*); + f->sizep=n; + for (i=0; ip[i]=NULL; + for (i=0; ip[i]=LoadFunction(S,f->source); +} + +static void LoadDebug(LoadState* S, Proto* f) +{ + int i,n; + n=LoadInt(S); + f->lineinfo=luaM_newvector(S->L,n,int); + f->sizelineinfo=n; + LoadVector(S,f->lineinfo,n,sizeof(int)); + n=LoadInt(S); + f->locvars=luaM_newvector(S->L,n,LocVar); + f->sizelocvars=n; + for (i=0; ilocvars[i].varname=NULL; + for (i=0; ilocvars[i].varname=LoadString(S); + f->locvars[i].startpc=LoadInt(S); + f->locvars[i].endpc=LoadInt(S); + } + n=LoadInt(S); + f->upvalues=luaM_newvector(S->L,n,TString*); + f->sizeupvalues=n; + for (i=0; iupvalues[i]=NULL; + for (i=0; iupvalues[i]=LoadString(S); +} + +static Proto* LoadFunction(LoadState* S, TString* p) +{ + Proto* f; + if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep"); + f=luaF_newproto(S->L); + setptvalue2s(S->L,S->L->top,f); incr_top(S->L); + f->source=LoadString(S); if (f->source==NULL) f->source=p; + f->linedefined=LoadInt(S); + f->lastlinedefined=LoadInt(S); + f->nups=LoadByte(S); + f->numparams=LoadByte(S); + f->is_vararg=LoadByte(S); + f->maxstacksize=LoadByte(S); + LoadCode(S,f); + LoadConstants(S,f); + LoadDebug(S,f); + IF (!luaG_checkcode(f), "bad code"); + S->L->top--; + S->L->nCcalls--; + return f; +} + +static void LoadHeader(LoadState* S) +{ + char h[LUAC_HEADERSIZE]; + char s[LUAC_HEADERSIZE]; + luaU_header(h); + LoadBlock(S,s,LUAC_HEADERSIZE); + IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header"); +} + +/* +** load precompiled chunk +*/ +Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) +{ + LoadState S; + if (*name=='@' || *name=='=') + S.name=name+1; + else if (*name==LUA_SIGNATURE[0]) + S.name="binary string"; + else + S.name=name; + S.L=L; + S.Z=Z; + S.b=buff; + LoadHeader(&S); + return LoadFunction(&S,luaS_newliteral(L,"=?")); +} + +/* +* make header +*/ +void luaU_header (char* h) +{ + int x=1; + memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1); + h+=sizeof(LUA_SIGNATURE)-1; + *h++=(char)LUAC_VERSION; + *h++=(char)LUAC_FORMAT; + *h++=(char)*(char*)&x; /* endianness */ + *h++=(char)sizeof(int); + *h++=(char)sizeof(size_t); + *h++=(char)sizeof(Instruction); + *h++=(char)sizeof(lua_Number); + *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */ +} diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lundump.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lundump.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lundump.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lundump.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,36 @@ +/* +** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ +** load precompiled Lua chunks +** See Copyright Notice in lua.h +*/ + +#ifndef lundump_h +#define lundump_h + +#include "lobject.h" +#include "lzio.h" + +/* load one chunk; from lundump.c */ +LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); + +/* make header; from lundump.c */ +LUAI_FUNC void luaU_header (char* h); + +/* dump one chunk; from ldump.c */ +LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); + +#ifdef luac_c +/* print one chunk; from print.c */ +LUAI_FUNC void luaU_print (const Proto* f, int full); +#endif + +/* for header of binary files -- this is Lua 5.1 */ +#define LUAC_VERSION 0x51 + +/* for header of binary files -- this is the official format */ +#define LUAC_FORMAT 0 + +/* size of header of binary files */ +#define LUAC_HEADERSIZE 12 + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lvm.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lvm.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lvm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lvm.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,763 @@ +/* +** $Id: lvm.c,v 2.63.1.3 2007/12/28 15:32:23 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + + +#include +#include +#include + +#define lvm_c +#define LUA_CORE + +#include "lua.h" + +#include "ldebug.h" +#include "ldo.h" +#include "lfunc.h" +#include "lgc.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lstate.h" +#include "lstring.h" +#include "ltable.h" +#include "ltm.h" +#include "lvm.h" + + + +/* limit for table tag-method chains (to avoid loops) */ +#define MAXTAGLOOP 100 + + +const TValue *luaV_tonumber (const TValue *obj, TValue *n) { + lua_Number num; + if (ttisnumber(obj)) return obj; + if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) { + setnvalue(n, num); + return n; + } + else + return NULL; +} + + +int luaV_tostring (lua_State *L, StkId obj) { + if (!ttisnumber(obj)) + return 0; + else { + char s[LUAI_MAXNUMBER2STR]; + lua_Number n = nvalue(obj); + lua_number2str(s, n); + setsvalue2s(L, obj, luaS_new(L, s)); + return 1; + } +} + + +static void traceexec (lua_State *L, const Instruction *pc) { + lu_byte mask = L->hookmask; + const Instruction *oldpc = L->savedpc; + L->savedpc = pc; + if ((mask & LUA_MASKCOUNT) && L->hookcount == 0) { + resethookcount(L); + luaD_callhook(L, LUA_HOOKCOUNT, -1); + } + if (mask & LUA_MASKLINE) { + Proto *p = ci_func(L->ci)->l.p; + int npc = pcRel(pc, p); + int newline = getline(p, npc); + /* call linehook when enter a new function, when jump back (loop), + or when enter a new line */ + if (npc == 0 || pc <= oldpc || newline != getline(p, pcRel(oldpc, p))) + luaD_callhook(L, LUA_HOOKLINE, newline); + } +} + + +static void callTMres (lua_State *L, StkId res, const TValue *f, + const TValue *p1, const TValue *p2) { + ptrdiff_t result = savestack(L, res); + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + luaD_checkstack(L, 3); + L->top += 3; + luaD_call(L, L->top - 3, 1); + res = restorestack(L, result); + L->top--; + setobjs2s(L, res, L->top); +} + + + +static void callTM (lua_State *L, const TValue *f, const TValue *p1, + const TValue *p2, const TValue *p3) { + setobj2s(L, L->top, f); /* push function */ + setobj2s(L, L->top+1, p1); /* 1st argument */ + setobj2s(L, L->top+2, p2); /* 2nd argument */ + setobj2s(L, L->top+3, p3); /* 3th argument */ + luaD_checkstack(L, 4); + L->top += 4; + luaD_call(L, L->top - 4, 0); +} + + +void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + const TValue *res = luaH_get(h, key); /* do a primitive get */ + if (!ttisnil(res) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ + setobj2s(L, val, res); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTMres(L, val, tm, t, key); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in gettable"); +} + + +void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { + int loop; + for (loop = 0; loop < MAXTAGLOOP; loop++) { + const TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ + if (!ttisnil(oldval) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */ + setobj2t(L, oldval, val); + luaC_barriert(L, h, val); + return; + } + /* else will try the tag method */ + } + else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTM(L, tm, t, key, val); + return; + } + t = tm; /* else repeat with `tm' */ + } + luaG_runerror(L, "loop in settable"); +} + + +static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, + StkId res, TMS event) { + const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ + if (ttisnil(tm)) + tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ + if (ttisnil(tm)) return 0; + callTMres(L, res, tm, p1, p2); + return 1; +} + + +static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2, + TMS event) { + const TValue *tm1 = fasttm(L, mt1, event); + const TValue *tm2; + if (tm1 == NULL) return NULL; /* no metamethod */ + if (mt1 == mt2) return tm1; /* same metatables => same metamethods */ + tm2 = fasttm(L, mt2, event); + if (tm2 == NULL) return NULL; /* no metamethod */ + if (luaO_rawequalObj(tm1, tm2)) /* same metamethods? */ + return tm1; + return NULL; +} + + +static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, + TMS event) { + const TValue *tm1 = luaT_gettmbyobj(L, p1, event); + const TValue *tm2; + if (ttisnil(tm1)) return -1; /* no metamethod? */ + tm2 = luaT_gettmbyobj(L, p2, event); + if (!luaO_rawequalObj(tm1, tm2)) /* different metamethods? */ + return -1; + callTMres(L, L->top, tm1, p1, p2); + return !l_isfalse(L->top); +} + + +static int l_strcmp (const TString *ls, const TString *rs) { + const char *l = getstr(ls); + size_t ll = ls->tsv.len; + const char *r = getstr(rs); + size_t lr = rs->tsv.len; + for (;;) { + int temp = strcoll(l, r); + if (temp != 0) return temp; + else { /* strings are equal up to a `\0' */ + size_t len = strlen(l); /* index of first `\0' in both strings */ + if (len == lr) /* r is finished? */ + return (len == ll) ? 0 : 1; + else if (len == ll) /* l is finished? */ + return -1; /* l is smaller than r (because r is not finished) */ + /* both strings longer than `len'; go on comparing (after the `\0') */ + len++; + l += len; ll -= len; r += len; lr -= len; + } + } +} + + +int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numlt(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; + else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) + return res; + return luaG_ordererror(L, l, r); +} + + +static int lessequal (lua_State *L, const TValue *l, const TValue *r) { + int res; + if (ttype(l) != ttype(r)) + return luaG_ordererror(L, l, r); + else if (ttisnumber(l)) + return luai_numle(nvalue(l), nvalue(r)); + else if (ttisstring(l)) + return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; + else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ + return res; + else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ + return !res; + return luaG_ordererror(L, l, r); +} + + +int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { + const TValue *tm; + lua_assert(ttype(t1) == ttype(t2)); + switch (ttype(t1)) { + case LUA_TNIL: return 1; + case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); + case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ + case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); + case LUA_TUSERDATA: { + if (uvalue(t1) == uvalue(t2)) return 1; + tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, + TM_EQ); + break; /* will try TM */ + } + case LUA_TTABLE: { + if (hvalue(t1) == hvalue(t2)) return 1; + tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ); + break; /* will try TM */ + } + default: return gcvalue(t1) == gcvalue(t2); + } + if (tm == NULL) return 0; /* no TM? */ + callTMres(L, L->top, tm, t1, t2); /* call TM */ + return !l_isfalse(L->top); +} + + +void luaV_concat (lua_State *L, int total, int last) { + do { + StkId top = L->base + last + 1; + int n = 2; /* number of elements handled in this pass (at least 2) */ + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { + if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) + luaG_concaterror(L, top-2, top-1); + } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ + (void)tostring(L, top - 2); /* result is first op (as string) */ + else { + /* at least two string values; get as many as possible */ + size_t tl = tsvalue(top-1)->len; + char *buffer; + int i; + /* collect total length */ + for (n = 1; n < total && tostring(L, top-n-1); n++) { + size_t l = tsvalue(top-n-1)->len; + if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow"); + tl += l; + } + buffer = luaZ_openspace(L, &G(L)->buff, tl); + tl = 0; + for (i=n; i>0; i--) { /* concat all strings */ + size_t l = tsvalue(top-i)->len; + memcpy(buffer+tl, svalue(top-i), l); + tl += l; + } + setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl)); + } + total -= n-1; /* got `n' strings to create 1 new */ + last -= n-1; + } while (total > 1); /* repeat until only 1 result left */ +} + + +static void Arith (lua_State *L, StkId ra, const TValue *rb, + const TValue *rc, TMS op) { + TValue tempb, tempc; + const TValue *b, *c; + if ((b = luaV_tonumber(rb, &tempb)) != NULL && + (c = luaV_tonumber(rc, &tempc)) != NULL) { + lua_Number nb = nvalue(b), nc = nvalue(c); + switch (op) { + case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; + case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; + case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; + case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; + case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; + case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; + case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; + default: lua_assert(0); break; + } + } + else if (!call_binTM(L, rb, rc, ra, op)) + luaG_aritherror(L, rb, rc); +} + + + +/* +** some macros for common tasks in `luaV_execute' +*/ + +#define runtime_check(L, c) { if (!(c)) break; } + +#define RA(i) (base+GETARG_A(i)) +/* to be used after possible stack reallocation */ +#define RB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i)) +#define RC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i)) +#define RKB(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)) +#define RKC(i) check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \ + ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)) +#define KBx(i) check_exp(getBMode(GET_OPCODE(i)) == OpArgK, k+GETARG_Bx(i)) + + +#define dojump(L,pc,i) {(pc) += (i); luai_threadyield(L);} + + +#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; } + + +#define arith_op(op,tm) { \ + TValue *rb = RKB(i); \ + TValue *rc = RKC(i); \ + if (ttisnumber(rb) && ttisnumber(rc)) { \ + lua_Number nb = nvalue(rb), nc = nvalue(rc); \ + setnvalue(ra, op(nb, nc)); \ + } \ + else \ + Protect(Arith(L, ra, rb, rc, tm)); \ + } + + + +void luaV_execute (lua_State *L, int nexeccalls) { + LClosure *cl; + StkId base; + TValue *k; + const Instruction *pc; + reentry: /* entry point */ + lua_assert(isLua(L->ci)); + pc = L->savedpc; + cl = &clvalue(L->ci->func)->l; + base = L->base; + k = cl->p->k; + /* main loop of interpreter */ + for (;;) { + const Instruction i = *pc++; + StkId ra; + if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && + (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { + traceexec(L, pc); + if (L->status == LUA_YIELD) { /* did hook yield? */ + L->savedpc = pc - 1; + return; + } + base = L->base; + } + /* warning!! several calls may realloc the stack and invalidate `ra' */ + ra = RA(i); + lua_assert(base == L->base && L->base == L->ci->base); + lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); + lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); + switch (GET_OPCODE(i)) { + case OP_MOVE: { + setobjs2s(L, ra, RB(i)); + continue; + } + case OP_LOADK: { + setobj2s(L, ra, KBx(i)); + continue; + } + case OP_LOADBOOL: { + setbvalue(ra, GETARG_B(i)); + if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ + continue; + } + case OP_LOADNIL: { + TValue *rb = RB(i); + do { + setnilvalue(rb--); + } while (rb >= ra); + continue; + } + case OP_GETUPVAL: { + int b = GETARG_B(i); + setobj2s(L, ra, cl->upvals[b]->v); + continue; + } + case OP_GETGLOBAL: { + TValue g; + TValue *rb = KBx(i); + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(rb)); + Protect(luaV_gettable(L, &g, rb, ra)); + continue; + } + case OP_GETTABLE: { + Protect(luaV_gettable(L, RB(i), RKC(i), ra)); + continue; + } + case OP_SETGLOBAL: { + TValue g; + sethvalue(L, &g, cl->env); + lua_assert(ttisstring(KBx(i))); + Protect(luaV_settable(L, &g, KBx(i), ra)); + continue; + } + case OP_SETUPVAL: { + UpVal *uv = cl->upvals[GETARG_B(i)]; + setobj(L, uv->v, ra); + luaC_barrier(L, uv, ra); + continue; + } + case OP_SETTABLE: { + Protect(luaV_settable(L, ra, RKB(i), RKC(i))); + continue; + } + case OP_NEWTABLE: { + int b = GETARG_B(i); + int c = GETARG_C(i); + sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); + Protect(luaC_checkGC(L)); + continue; + } + case OP_SELF: { + StkId rb = RB(i); + setobjs2s(L, ra+1, rb); + Protect(luaV_gettable(L, rb, RKC(i), ra)); + continue; + } + case OP_ADD: { + arith_op(luai_numadd, TM_ADD); + continue; + } + case OP_SUB: { + arith_op(luai_numsub, TM_SUB); + continue; + } + case OP_MUL: { + arith_op(luai_nummul, TM_MUL); + continue; + } + case OP_DIV: { + arith_op(luai_numdiv, TM_DIV); + continue; + } + case OP_MOD: { + arith_op(luai_nummod, TM_MOD); + continue; + } + case OP_POW: { + arith_op(luai_numpow, TM_POW); + continue; + } + case OP_UNM: { + TValue *rb = RB(i); + if (ttisnumber(rb)) { + lua_Number nb = nvalue(rb); + setnvalue(ra, luai_numunm(nb)); + } + else { + Protect(Arith(L, ra, rb, rb, TM_UNM)); + } + continue; + } + case OP_NOT: { + int res = l_isfalse(RB(i)); /* next assignment may change this value */ + setbvalue(ra, res); + continue; + } + case OP_LEN: { + const TValue *rb = RB(i); + switch (ttype(rb)) { + case LUA_TTABLE: { + setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); + break; + } + case LUA_TSTRING: { + setnvalue(ra, cast_num(tsvalue(rb)->len)); + break; + } + default: { /* try metamethod */ + Protect( + if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)) + luaG_typeerror(L, rb, "get length of"); + ) + } + } + continue; + } + case OP_CONCAT: { + int b = GETARG_B(i); + int c = GETARG_C(i); + Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L)); + setobjs2s(L, RA(i), base+b); + continue; + } + case OP_JMP: { + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_EQ: { + TValue *rb = RKB(i); + TValue *rc = RKC(i); + Protect( + if (equalobj(L, rb, rc) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LT: { + Protect( + if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_LE: { + Protect( + if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i)) + dojump(L, pc, GETARG_sBx(*pc)); + ) + pc++; + continue; + } + case OP_TEST: { + if (l_isfalse(ra) != GETARG_C(i)) + dojump(L, pc, GETARG_sBx(*pc)); + pc++; + continue; + } + case OP_TESTSET: { + TValue *rb = RB(i); + if (l_isfalse(rb) != GETARG_C(i)) { + setobjs2s(L, ra, rb); + dojump(L, pc, GETARG_sBx(*pc)); + } + pc++; + continue; + } + case OP_CALL: { + int b = GETARG_B(i); + int nresults = GETARG_C(i) - 1; + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + switch (luaD_precall(L, ra, nresults)) { + case PCRLUA: { + nexeccalls++; + goto reentry; /* restart luaV_execute over new Lua function */ + } + case PCRC: { + /* it was a C function (`precall' called it); adjust results */ + if (nresults >= 0) L->top = L->ci->top; + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_TAILCALL: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b; /* else previous instruction set top */ + L->savedpc = pc; + lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); + switch (luaD_precall(L, ra, LUA_MULTRET)) { + case PCRLUA: { + /* tail call: put new frame in place of previous one */ + CallInfo *ci = L->ci - 1; /* previous frame */ + int aux; + StkId func = ci->func; + StkId pfunc = (ci+1)->func; /* previous function index */ + if (L->openupval) luaF_close(L, ci->base); + L->base = ci->base = ci->func + ((ci+1)->base - pfunc); + for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */ + setobjs2s(L, func+aux, pfunc+aux); + ci->top = L->top = func+aux; /* correct top */ + lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); + ci->savedpc = L->savedpc; + ci->tailcalls++; /* one more call lost */ + L->ci--; /* remove new frame */ + goto reentry; + } + case PCRC: { /* it was a C function (`precall' called it) */ + base = L->base; + continue; + } + default: { + return; /* yield */ + } + } + } + case OP_RETURN: { + int b = GETARG_B(i); + if (b != 0) L->top = ra+b-1; + if (L->openupval) luaF_close(L, base); + L->savedpc = pc; + b = luaD_poscall(L, ra); + if (--nexeccalls == 0) /* was previous function running `here'? */ + return; /* no: return */ + else { /* yes: continue its execution */ + if (b) L->top = L->ci->top; + lua_assert(isLua(L->ci)); + lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL); + goto reentry; + } + } + case OP_FORLOOP: { + lua_Number step = nvalue(ra+2); + lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ + lua_Number limit = nvalue(ra+1); + if (luai_numlt(0, step) ? luai_numle(idx, limit) + : luai_numle(limit, idx)) { + dojump(L, pc, GETARG_sBx(i)); /* jump back */ + setnvalue(ra, idx); /* update internal index... */ + setnvalue(ra+3, idx); /* ...and external index */ + } + continue; + } + case OP_FORPREP: { + const TValue *init = ra; + const TValue *plimit = ra+1; + const TValue *pstep = ra+2; + L->savedpc = pc; /* next steps may throw errors */ + if (!tonumber(init, ra)) + luaG_runerror(L, LUA_QL("for") " initial value must be a number"); + else if (!tonumber(plimit, ra+1)) + luaG_runerror(L, LUA_QL("for") " limit must be a number"); + else if (!tonumber(pstep, ra+2)) + luaG_runerror(L, LUA_QL("for") " step must be a number"); + setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); + dojump(L, pc, GETARG_sBx(i)); + continue; + } + case OP_TFORLOOP: { + StkId cb = ra + 3; /* call base */ + setobjs2s(L, cb+2, ra+2); + setobjs2s(L, cb+1, ra+1); + setobjs2s(L, cb, ra); + L->top = cb+3; /* func. + 2 args (state and index) */ + Protect(luaD_call(L, cb, GETARG_C(i))); + L->top = L->ci->top; + cb = RA(i) + 3; /* previous call may change the stack */ + if (!ttisnil(cb)) { /* continue loop? */ + setobjs2s(L, cb-1, cb); /* save control variable */ + dojump(L, pc, GETARG_sBx(*pc)); /* jump back */ + } + pc++; + continue; + } + case OP_SETLIST: { + int n = GETARG_B(i); + int c = GETARG_C(i); + int last; + Table *h; + if (n == 0) { + n = cast_int(L->top - ra) - 1; + L->top = L->ci->top; + } + if (c == 0) c = cast_int(*pc++); + runtime_check(L, ttistable(ra)); + h = hvalue(ra); + last = ((c-1)*LFIELDS_PER_FLUSH) + n; + if (last > h->sizearray) /* needs more space? */ + luaH_resizearray(L, h, last); /* pre-alloc it at once */ + for (; n > 0; n--) { + TValue *val = ra+n; + setobj2t(L, luaH_setnum(L, h, last--), val); + luaC_barriert(L, h, val); + } + continue; + } + case OP_CLOSE: { + luaF_close(L, ra); + continue; + } + case OP_CLOSURE: { + Proto *p; + Closure *ncl; + int nup, j; + p = cl->p->p[GETARG_Bx(i)]; + nup = p->nups; + ncl = luaF_newLclosure(L, nup, cl->env); + ncl->l.p = p; + for (j=0; jl.upvals[j] = cl->upvals[GETARG_B(*pc)]; + else { + lua_assert(GET_OPCODE(*pc) == OP_MOVE); + ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc)); + } + } + setclvalue(L, ra, ncl); + Protect(luaC_checkGC(L)); + continue; + } + case OP_VARARG: { + int b = GETARG_B(i) - 1; + int j; + CallInfo *ci = L->ci; + int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; + if (b == LUA_MULTRET) { + Protect(luaD_checkstack(L, n)); + ra = RA(i); /* previous call may change the stack */ + b = n; + L->top = ra + n; + } + for (j = 0; j < b; j++) { + if (j < n) { + setobjs2s(L, ra + j, ci->base - n + j); + } + else { + setnilvalue(ra + j); + } + } + continue; + } + } + } +} + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lvm.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lvm.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lvm.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lvm.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,36 @@ +/* +** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ +** Lua virtual machine +** See Copyright Notice in lua.h +*/ + +#ifndef lvm_h +#define lvm_h + + +#include "ldo.h" +#include "lobject.h" +#include "ltm.h" + + +#define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) + +#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ + (((o) = luaV_tonumber(o,n)) != NULL)) + +#define equalobj(L,o1,o2) \ + (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) + + +LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); +LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); +LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); +LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); +LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, + StkId val); +LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); +LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lzio.c.svn-base blobby-0.9c/src/lua/.svn/text-base/lzio.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lzio.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lzio.c.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,82 @@ +/* +** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ +** a generic input stream interface +** See Copyright Notice in lua.h +*/ + + +#include + +#define lzio_c +#define LUA_CORE + +#include "lua.h" + +#include "llimits.h" +#include "lmem.h" +#include "lstate.h" +#include "lzio.h" + + +int luaZ_fill (ZIO *z) { + size_t size; + lua_State *L = z->L; + const char *buff; + lua_unlock(L); + buff = z->reader(L, z->data, &size); + lua_lock(L); + if (buff == NULL || size == 0) return EOZ; + z->n = size - 1; + z->p = buff; + return char2int(*(z->p++)); +} + + +int luaZ_lookahead (ZIO *z) { + if (z->n == 0) { + if (luaZ_fill(z) == EOZ) + return EOZ; + else { + z->n++; /* luaZ_fill removed first byte; put back it */ + z->p--; + } + } + return char2int(*z->p); +} + + +void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { + z->L = L; + z->reader = reader; + z->data = data; + z->n = 0; + z->p = NULL; +} + + +/* --------------------------------------------------------------- read --- */ +size_t luaZ_read (ZIO *z, void *b, size_t n) { + while (n) { + size_t m; + if (luaZ_lookahead(z) == EOZ) + return n; /* return number of missing bytes */ + m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ + memcpy(b, z->p, m); + z->n -= m; + z->p += m; + b = (char *)b + m; + n -= m; + } + return 0; +} + +/* ------------------------------------------------------------------------ */ +char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { + if (n > buff->buffsize) { + if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; + luaZ_resizebuffer(L, buff, n); + } + return buff->buffer; +} + + diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/lzio.h.svn-base blobby-0.9c/src/lua/.svn/text-base/lzio.h.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/lzio.h.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/lzio.h.svn-base 2011-11-06 15:06:45.000000000 +0000 @@ -0,0 +1,67 @@ +/* +** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ +** Buffered streams +** See Copyright Notice in lua.h +*/ + + +#ifndef lzio_h +#define lzio_h + +#include "lua.h" + +#include "lmem.h" + + +#define EOZ (-1) /* end of stream */ + +typedef struct Zio ZIO; + +#define char2int(c) cast(int, cast(unsigned char, (c))) + +#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) + +typedef struct Mbuffer { + char *buffer; + size_t n; + size_t buffsize; +} Mbuffer; + +#define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) + +#define luaZ_buffer(buff) ((buff)->buffer) +#define luaZ_sizebuffer(buff) ((buff)->buffsize) +#define luaZ_bufflen(buff) ((buff)->n) + +#define luaZ_resetbuffer(buff) ((buff)->n = 0) + + +#define luaZ_resizebuffer(L, buff, size) \ + (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ + (buff)->buffsize = size) + +#define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) + + +LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); +LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, + void *data); +LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ +LUAI_FUNC int luaZ_lookahead (ZIO *z); + + + +/* --------- Private Part ------------------ */ + +struct Zio { + size_t n; /* bytes still unread */ + const char *p; /* current position in buffer */ + lua_Reader reader; + void* data; /* additional data */ + lua_State *L; /* Lua state (for reader) */ +}; + + +LUAI_FUNC int luaZ_fill (ZIO *z); + +#endif diff -Nru blobby-0.8-dfsg/src/lua/.svn/text-base/print.c.svn-base blobby-0.9c/src/lua/.svn/text-base/print.c.svn-base --- blobby-0.8-dfsg/src/lua/.svn/text-base/print.c.svn-base 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua/.svn/text-base/print.c.svn-base 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,227 @@ +/* +** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ +** print bytecodes +** See Copyright Notice in lua.h +*/ + +#include +#include + +#define luac_c +#define LUA_CORE + +#include "ldebug.h" +#include "lobject.h" +#include "lopcodes.h" +#include "lundump.h" + +#define PrintFunction luaU_print + +#define Sizeof(x) ((int)sizeof(x)) +#define VOID(p) ((const void*)(p)) + +static void PrintString(const TString* ts) +{ + const char* s=getstr(ts); + size_t i,n=ts->tsv.len; + putchar('"'); + for (i=0; ik[i]; + switch (ttype(o)) + { + case LUA_TNIL: + printf("nil"); + break; + case LUA_TBOOLEAN: + printf(bvalue(o) ? "true" : "false"); + break; + case LUA_TNUMBER: + printf(LUA_NUMBER_FMT,nvalue(o)); + break; + case LUA_TSTRING: + PrintString(rawtsvalue(o)); + break; + default: /* cannot happen */ + printf("? type=%d",ttype(o)); + break; + } +} + +static void PrintCode(const Proto* f) +{ + const Instruction* code=f->code; + int pc,n=f->sizecode; + for (pc=0; pc0) printf("[%d]\t",line); else printf("[-]\t"); + printf("%-9s\t",luaP_opnames[o]); + switch (getOpMode(o)) + { + case iABC: + printf("%d",a); + if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (-1-INDEXK(b)) : b); + if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (-1-INDEXK(c)) : c); + break; + case iABx: + if (getBMode(o)==OpArgK) printf("%d %d",a,-1-bx); else printf("%d %d",a,bx); + break; + case iAsBx: + if (o==OP_JMP) printf("%d",sbx); else printf("%d %d",a,sbx); + break; + } + switch (o) + { + case OP_LOADK: + printf("\t; "); PrintConstant(f,bx); + break; + case OP_GETUPVAL: + case OP_SETUPVAL: + printf("\t; %s", (f->sizeupvalues>0) ? getstr(f->upvalues[b]) : "-"); + break; + case OP_GETGLOBAL: + case OP_SETGLOBAL: + printf("\t; %s",svalue(&f->k[bx])); + break; + case OP_GETTABLE: + case OP_SELF: + if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); } + break; + case OP_SETTABLE: + case OP_ADD: + case OP_SUB: + case OP_MUL: + case OP_DIV: + case OP_POW: + case OP_EQ: + case OP_LT: + case OP_LE: + if (ISK(b) || ISK(c)) + { + printf("\t; "); + if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-"); + printf(" "); + if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-"); + } + break; + case OP_JMP: + case OP_FORLOOP: + case OP_FORPREP: + printf("\t; to %d",sbx+pc+2); + break; + case OP_CLOSURE: + printf("\t; %p",VOID(f->p[bx])); + break; + case OP_SETLIST: + if (c==0) printf("\t; %d",(int)code[++pc]); + else printf("\t; %d",c); + break; + default: + break; + } + printf("\n"); + } +} + +#define SS(x) (x==1)?"":"s" +#define S(x) x,SS(x) + +static void PrintHeader(const Proto* f) +{ + const char* s=getstr(f->source); + if (*s=='@' || *s=='=') + s++; + else if (*s==LUA_SIGNATURE[0]) + s="(bstring)"; + else + s="(string)"; + printf("\n%s <%s:%d,%d> (%d instruction%s, %d bytes at %p)\n", + (f->linedefined==0)?"main":"function",s, + f->linedefined,f->lastlinedefined, + S(f->sizecode),f->sizecode*Sizeof(Instruction),VOID(f)); + printf("%d%s param%s, %d slot%s, %d upvalue%s, ", + f->numparams,f->is_vararg?"+":"",SS(f->numparams), + S(f->maxstacksize),S(f->nups)); + printf("%d local%s, %d constant%s, %d function%s\n", + S(f->sizelocvars),S(f->sizek),S(f->sizep)); +} + +static void PrintConstants(const Proto* f) +{ + int i,n=f->sizek; + printf("constants (%d) for %p:\n",n,VOID(f)); + for (i=0; isizelocvars; + printf("locals (%d) for %p:\n",n,VOID(f)); + for (i=0; ilocvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1); + } +} + +static void PrintUpvalues(const Proto* f) +{ + int i,n=f->sizeupvalues; + printf("upvalues (%d) for %p:\n",n,VOID(f)); + if (f->upvalues==NULL) return; + for (i=0; iupvalues[i])); + } +} + +void PrintFunction(const Proto* f, int full) +{ + int i,n=f->sizep; + PrintHeader(f); + PrintCode(f); + if (full) + { + PrintConstants(f); + PrintLocals(f); + PrintUpvalues(f); + } + for (i=0; ip[i],full); +} diff -Nru blobby-0.8-dfsg/src/lua_api_doc.dox blobby-0.9c/src/lua_api_doc.dox --- blobby-0.8-dfsg/src/lua_api_doc.dox 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/lua_api_doc.dox 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,508 @@ +/* This file contains the documentation of the blobby volley lua bot api +in a form readable by doxygen for generating a clearer documentation. +As doxygen is not capable of parsing lua source code, the function +declarations are in C++ syntax, providing parameter and return types, +too (in contrast to lua functions which would be unable to define +type inforamtion) */ + +// ---------------------------------------------------------- +// | documentation of the api function set | +// ---------------------------------------------------------- + +/*! \defgroup lua_api API Documentation + Here you find the documentation of the functions offered + by Blobby Volley's lua interface for scripting a bot. + For each function you get to know what it does, which + parameters are expected and which values are returned. + This documentation is subdivided into several function + groups: + \li Functions for input simulation: \ref command_func "Input" + \li Functions for getting data: \ref ball_func "Ball Information", + \ref blobby_func "Blobby Information", + \ref game_status_func "Game Status" + \li Estimation/Calculation functions: \ref estim_func "Estimation/Calculation" + + All functions of the lua math library are also available. + You can find their documentation at: + http://www.lua.org/manual/5.1/manual.html#5.6 \n + + Besides these functions that are provided by Blobby Volley, + each script can define the functions listed under \ref script_func "Script Functions". + + Note that some of them are required to get your bot + working. + + In addition to these functions, the Blobby Volley 2 Lua API + provides a lot of preset constants to simplify bot + development and make adaption to new circumstances + (e.g. different fieldsize, gravity) easier if that gets implemented. + + \attention + Remember that Lua is \b not able to declare a variables as const. + Thus, it IS possible to change the value of these constants. + + + @{ +*/ + +// ---------------------------------------------------------- +// other +// ---------------------------------------------------------- + +/*! \brief debugging + \details prints \p num to the debugging output (stderr) + \ingroup lua_api +*/ +void debug(float num); + +// ---------------------------------------------------------- +// input performing functions +// ---------------------------------------------------------- + +/*! @{ + \anchor command_func + \name Input Functions +*/ + +//! \brief step to the left +void left(); +//! \brief step to the right +void right(); +/*! \brief simulate jump key + \details Simulates pressing the jump key, so a first call causes the + blobby to jump whereas successive calls (in the next time steps) + make the jump higher +*/ +void jump(); + +/*! \brief Move to position + \details moves to a given position, using a small buffer to avoid + whobbling around the target + \param target destination +*/ +void moveto(int target); + +//! @} + +// ---------------------------------------------------------- +// ball information querying +// ---------------------------------------------------------- + +/*! @{ + \anchor ball_func + \name Ball Information + This set of functions allows the script to query information about \n + ball position, velocity and the number of touches done by the bot. +*/ + + +/*! \brief get number of touches + \details returns the number of touches the player had made since + the opponend had touched the ball last. +*/ +int touches(); + +//! \brief x component of ball position +float ballx(); +//! \brief y component of ball position +float bally(); +//! \brief x component of ball velocity +float bspeedx(); +//! \brief y component of ball velocity +float bspeedy(); + +//! @} + +// ---------------------------------------------------------- +// blob information querying +// ---------------------------------------------------------- + +/*! @{ + \anchor blobby_func + \name Blobby Information +*/ + +//! \brief is blobby launched +//! \return returns true if blobby doesn't stand on the ground +bool launched(); +/*! \brief x component of blobby position + \details returns the x component of the middle of the blobby + \sa oppx(), posy() +*/ +float posx(); +/*! \brief y component of blobby position + \details returns the y component of the middle of the blobby, + i.e. the blobby's top minus half of \ref CONST_BLOBBY_HEIGHT. + \sa oppy(), posx() +*/ +float posy(); +/*! \brief x component of enemy position + \details returns the x component of the middle of the enemy + \sa posx(), oppy() +*/ +float oppx(); +/*! \brief y component of enemy position + \details returns the y component of the middle of the enemy, + i.e. the enemy's top minus half of \ref CONST_BLOBBY_HEIGHT. + \sa posy(), oppy() +*/ +float oppy(); + +//! @} + +// ---------------------------------------------------------- +// game status +// ---------------------------------------------------------- + +/*! @{ + \anchor game_status_func + \name Game Status Information +*/ + +/*! \brief get own score + \sa getOppScore() + \sa getScoreToWin() +*/ +int getScore(); + +/*! \brief get opponent's score + \sa getScore() + \sa getScoreToWin() +*/ +int getOppScore(); + +/*! \brief score required for winning + \sa getScore() + \sa getOppScore() +*/ +int getScoreToWin(); + +//! \brief game time passed so far +//! \return game time in seconds +int getGameTime(); + +//! @} + +// ---------------------------------------------------------- +// estimations +// ---------------------------------------------------------- + +/*! @{ + \anchor estim_func + \name Calculation/Estimation Functions +*/ + +/*! \brief estimates ball impact on ground + \details Calculates the position where the ball is going to + hit the ground. Ignores bounces with walls and the + net. + \deprecated This funcion is relatively useless as both its + purpose (calculating ground impace, where it is + already to late to catch the ball) and its + calculation itself (ignoring bounces) are not good. + As a consequence, it is hardly used in the current + bots so it might be removed in one of the next releases. + \return x component of the estimated position + \sa predictImpact +*/ +float estimate(); + +/*! \brief estimates x position after certain time + \details calculates the estimated x position of the ball after + \p time steps, ignoring bounces with walls and net + \param time Number of steps to anticipate + \deprecated use predictx() for more accurate estimations + \sa estimx() +*/ +float estimx(int time); +/*! \brief estimates y position after certain time + \details calculates the estimated y position of the ball after + \p time steps, ignoring bounces with walls and net + \warning May be a little inaccurate for long timespans as it uses + explicit formulars instead of step-by-step simulation + \param time Number of steps to anticipate + \deprecated use predicty() for more accurate estimations + \sa estimy() +*/ +float estimy(int time); + +/*! \brief estimates ball impact on blobby head + \details Calculates the position where the ball will be + on height with the blobby head. Takes bounces + with the walls into account. + \return x component of the calculated position + \sideeffect Sets \ref FLAG_BOUNCE to true if ball hits a wall before + it reaches its destination. +*/ +float predictImpact(); + +/*! \brief estimates time ball need to hit net top + \details Reckons the time the ball needs to hit the net's + center the next time. Collisions with blobbys, walls + or the ned rod are not calculated. + \attention extensive use may need a lot of cpu power +*/ +float nettime(); + +// ---------------------------------------------------------- +// spec in development +// ---------------------------------------------------------- + +/*! \brief predicts ball position + \details Calculates the position the ball will have after \p + time steps, taking into account bounces with walls + and a simplified model for the net (i.e., the more + complicated collision with the net top is diregarded). + \warning + As this uses explicit formulas instead of simulating + step by step, the results may slightly vary from + the real values. + \sideeffect Sets \ref FLAG_BOUNCE to true if ball hits a wall + during the considered timespan. + \sa predicty(int time); +*/ +float predictx(int time); + +/*! \brief predicts ball position + \details Calculates the position the ball will have after \p + time steps, taking into account bounces with walls + and a simplified model for the net (i.e., the more + complicated collision with the net top is diregarded). + \warning + As this uses explicit formulas instead of simulating + step by step, the results may slightly vary from + the real values. + \sideeffect Sets \ref FLAG_BOUNCE to true if ball hits a wall + during the considered timespan. + \sa predictx(int time); +*/ +float predicty(int time); + +/*! \brief time ball needs to position + \details Calculates the duration until the ball reaches a certain + position the next time. Bounces with the wall and net rod + are calculated correctly, net top is disregarded. + \sideeffect Sets \ref FLAG_BOUNCE to true if ball hits a wall before + reaching its destination. + \sa timetoy(float target) +*/ +float timetox(float target); +/*! \brief time ball needs to position + \details Calculates the duration until the ball reaches a certain + position the next time. Bounces with the wall and net rod + are calculated correctly, net top is disregarded. + \sideeffect Sets \ref FLAG_BOUNCE to true if ball hits a wall before + reaching its destination. + \sa timetoy(float target) +*/ +float timetoy(float target); + +/*! \brief x when ball reaches certain y + \details caluclates the x coordinate the ball has when it + reaches \p target. Equivalent to predictx(timetoy(target)) + \sideeffect Sets \ref FLAG_BOUNCE to true if ball hits a wall before + reaching its destination. + \sa yatx +*/ +float xaty(float target); + +/*! \brief y when ball reaches certain x + \details caluclates the y coordinate the ball has when it + reaches \p target. Equivalent to predicty(timetox(target)) + \sideeffect Sets \ref FLAG_BOUNCE to true if ball hits a wall before + reaching its destination. + \sa xaty +*/ +float yatx(float target); + +/*! \brief time the blobby needs to reach \p target +*/ +float blobtimetox(float target); +/*! \brief time the blobby needs to reach \p target. + \details calculates the time the blobby needs to + reach a certain height. It is assumed that + jump() is called incessantly. +*/ +float blobtimetoy(float target); + +/*! \brief time till next event + \details calculates when the next event will occur. + in this context, event means bouncing against + the wall, the net or hitting the ground. + \sideeffect Sets \ref FLAG_BOUNCE to true if next event + is hitting wall or net. +*/ +float nextevent(); + +//! @} + +// ---------------------------------------------------------- +// functions to be implemented by script +// ---------------------------------------------------------- + +/*! @{ + \anchor script_func + \name Script Functions + These functions are to be implemented by the scripter. \n They + create the bot behaviour and allow response to certain events. \n + Some of them are required for a working bot and marked with + \b required. +*/ + +/*! \brief function for serving + \details Called when the ball went down and the controlled + blob has to serve it next. + \param ballready true when ball is placed + \attention \b required +*/ + +void OnServe(bool ballready); +/*! \brief Oppenent is serving + \details Called after balldown when the opponent has to + serve the next ball +*/ +void OnOpponentServe(); + +/*! \brief Mainloop function + \details Called each step during the normal game + \attention \b required +*/ +void OnGame(); + +/*! \brief ball bounce event + \details Called when ball trajectory changes + (i.e. ball hits border/net/blobby) +*/ +void OnBounce(); + +//! @} + +// ---------------------------------------------------------- +// | constants | +// ---------------------------------------------------------- + +//! width of the playing field +const float CONST_FIELD_WIDTH = 800; +//! y coordinate of the gound plane +const float CONST_GROUND_HEIGHT = 100; +//! strenght of the gravity that affects the ball +const float CONST_BALL_GRAVITY = -0.28; +//! radius of ball +const float CONST_BALL_RADIUS = 31.5; +//! start velocity of jumping blobby +const float CONST_BLOBBY_JUMP = 15.1; +//! radius of the lower sphere of the blobby +const float CONST_BLOBBY_BODY_RADIUS = 33; +//! radius of the upper sphere of the blobby +const float CONST_BLOBBY_HEAD_RADIUS = 25; +//! height of the blobby +const float CONST_BLOBBY_HEIGHT = 89; +//! gravity that affects the blobby if jump() is not called. +//! otherwise, half of this value is used +const float CONST_BLOBBY_GRAVITY = -0.88; +//! y coordinate of the top of the net +const float CONST_NET_HEIGHT = 316; +//! radius of the net / half the breadth +const float CONST_NET_RADIUS = 7; + +// ---------------------------------------------------------- +// | variables | +// ---------------------------------------------------------- + +/*! \brief wall bounce calculated? + \details Is set by some functions to indicate whether + a collision with the wall had to be taken + into account, i.e. the ball hits a wall + during the processed timespan. +*/ +extern bool FLAG_BOUNCE; + +//! @} + +// ---------------------------------------------------------- +// | tutorial | +// ---------------------------------------------------------- + +/*! \mainpage + \page tutorial + In diesem Tutorial werden die Grundlagen von Lua und der Botprogrammierung + von Blobby Volley 2 erläutert. Für weiterführende Informationen gibt es die + Dokumentation der Script-API. \n + + Für Leute, die noch nie programmiert haben, empfehle ich folgendes Tutorial, + um die wichtigsten Grundlagen zu erlernen: + http://robertico.ro.funpic.de/index.php \n + + Vor der Programmierung ist zu beachten, dass Blobby-Skripte in + 'data/scripts' abgelegt werden müssen und die Dateiendung '.lua' tragen + müssen, um vom Spiel erkannt zu werden \n + + Für ein gültiges Blobby-Script müsst ihr 3 Funktionen festlegen: \n + + \code + function OnServe(parameter) + -- Wird aufgerufen wenn der Ball abgepfiffen wurde und man selber angeben + -- soll. Der Parameter gibt an, ob der Ball schon in der Schwebe plaziert ist + end + + function OnOpponentServe() + -- Wird aufgerufen wenn der Gegner angeben soll + end + + function OnGame() + -- Wird ansonsten während des gesamten Spieles aufgerufen + -- Mit -- werden übrigens Kommentare markiert, solltet ihr es noch nicht bemerkt haben ;D + end + \endcode + + Bevor ihr jetzt loslegt, noch etwas zum Koordinatensystem: + Das Spielfeld ist 800 Einheiten breit und 600 Einheiten hoch, ganz an der + alten Blobby-Auflösung orientiert. X wächst dabei nach rechts und Y nach oben. + Damit wäre also 0,0 unten links und 800,600 oben rechts. + Falls ihr euch wundert dass es keine Möglichkeit gibt die eigene Seite + zu bestimmen, das ist Absicht. Programmiert einfach als ob der Bot immer + links stehen würde, das Programm dreht gegebenenfalls alle Koordinaten um. + + Ich werde jetzt einfach mal ein Beispiel zeigen, wie ein simpler Bot aufgebaut + sein kann: + + \code + function OnOpponentServe() + moveto(130) -- Wenn der Gegner spielt, in Ausgangsposition gehen + end + + function OnServe(ballready) + moveto(ballx() - 40) -- Etwas links vom Ball hinstellen + if posx() < ballx() - 37 and posx() > ballx() - 43 then + -- Dieser zugegeben etwas komplizierte Ausdruck bewirkt, dass + -- man sich erstmal unterhalb des Balles befinden muss. Leider muss + -- das so aufwendig gemacht werden, weil moveto() niemals eine Stelle + -- ganz exakt erreicht. + if ballready then + jump() -- Natürlich nur springen wenn der Ball schon bereitsteht + end + end + end + + function OnGame() + if ballx() < 400 then -- Wenn sich der Ball links von der Mitte, + -- also auf unserer Seite befindet + moveto(ballx() - 20) -- Etwas links vom Ball ausrichten + if ballx() < posx() + 50 then + jump() -- Wenn der Ball kurz vor oder hinter dem Blobby ist, springen + end + end + end + \endcode + + + Ich hoffe, dieses Tutorial hat einen Eindruck entwickelt, wie man einen Bot + programmiert. Für weitere Informationen gibt es wie gesagt die + Script-API-Doku. Um fortgeschrittene Bots zu programmieren, solltet ihr + auch nicht immer blind dem Ball hinterherrennen, sondern mit den + estim*-Funktionen Vorhersagen machen. + Ansonsten kann ich euch nur als Tip mitgeben, euren Bot immer wieder zu + beobachten und gegen jede gefundene Schwäche einen Schutzmechanismus + zu entwickeln. + +*/ diff -Nru blobby-0.8-dfsg/src/main.cpp blobby-0.9c/src/main.cpp --- blobby-0.8-dfsg/src/main.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/main.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -42,6 +42,10 @@ #endif #endif +#ifdef WIN32 +#undef main +#endif + void probeDir(const std::string& dirname) { if (PHYSFS_isDirectory(dirname.c_str()) == 0) @@ -122,7 +126,7 @@ #endif #endif } - +#undef main extern "C" int main(int argc, char* argv[]) { @@ -143,14 +147,8 @@ UserConfig gameConfig; gameConfig.loadFile("config.xml"); - if(gameConfig.getString("language") == "german"){ - TextManager::createTextManager(TextManager::GERMAN); - }else if(gameConfig.getString("language") == "english"){ - TextManager::createTextManager(TextManager::ENGLISH); - }else{ - std::cerr << "Warning: Unknown language \""<init(800, 600, false); + if(gameConfig.getString("show_shadow") == "true") + rmanager->showShadow(true); + else + rmanager->showShadow(false); + SpeedController scontroller(gameConfig.getFloat("gamefps")); SpeedController::setMainInstance(&scontroller); scontroller.setDrawFPS(gameConfig.getBool("showfps")); diff -Nru blobby-0.8-dfsg/src/NetworkGame.cpp blobby-0.9c/src/NetworkGame.cpp --- blobby-0.8-dfsg/src/NetworkGame.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/NetworkGame.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -17,20 +17,29 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =============================================================================*/ +#include + #include "NetworkGame.h" #include "NetworkMessage.h" +#include "ReplayRecorder.h" #include "raknet/RakServer.h" #include "raknet/BitStream.h" #include "raknet/GetTime.h" + +#include + // We don't need the stringcompressor NetworkGame::NetworkGame(RakServer& server, PlayerID leftPlayer, PlayerID rightPlayer, std::string leftPlayerName, std::string rightPlayerName, + Color leftColor, Color rightColor, PlayerSide switchedSide) : mServer(server) { - mPhysicWorld.resetPlayer(); + mLeftInput = new DummyInputSource(); + mRightInput = new DummyInputSource(); + mMatch = new DuelMatch(mLeftInput, mRightInput, false, false); mLeftPlayer = leftPlayer; mRightPlayer = rightPlayer; @@ -38,32 +47,32 @@ mLeftPlayerName = leftPlayerName; mRightPlayerName = rightPlayerName; - mLeftScore = 0; - mRightScore = 0; - mServingPlayer = NO_PLAYER; - - mLeftHitcount = 0; - mRightHitcount = 0; - mSquishLeft = 0; - mSquishRight = 0; mWinningPlayer = NO_PLAYER; mPausing = false; + mRecorder = new ReplayRecorder(MODE_RECORDING_DUEL); + mRecorder->setPlayerNames(mLeftPlayerName.c_str(), mRightPlayerName.c_str()); + mRecorder->setServingPlayer(LEFT_PLAYER); + // buffer for playernames char name[16]; // writing data into leftStream RakNet::BitStream leftStream; - leftStream.Write(ID_GAME_READY); + leftStream.Write((unsigned char)ID_GAME_READY); + leftStream.Write((int)SpeedController::getMainInstance()->getGameSpeed()); strncpy(name, mRightPlayerName.c_str(), sizeof(name)); leftStream.Write(name, sizeof(name)); + leftStream.Write(rightColor.toInt()); // writing data into rightStream RakNet::BitStream rightStream; - rightStream.Write(ID_GAME_READY); + rightStream.Write((unsigned char)ID_GAME_READY); + rightStream.Write((int)SpeedController::getMainInstance()->getGameSpeed()); strncpy(name, mLeftPlayerName.c_str(), sizeof(name)); rightStream.Write(name, sizeof(name)); + rightStream.Write(leftColor.toInt()); mServer.Send(&leftStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, mLeftPlayer, false); @@ -73,15 +82,34 @@ NetworkGame::~NetworkGame() { + delete mLeftInput; + delete mRightInput; + delete mMatch; } - -void NetworkGame::injectPacket(Packet* packet) +void NetworkGame::injectPacket(const packet_ptr& packet) { - mPacketQueue.push_back(*packet); + mPacketQueue.push_back(packet); } void NetworkGame::broadcastBitstream(RakNet::BitStream* stream, RakNet::BitStream* switchedstream) { + // checks that stream and switchedstream don't have the same content. + // this is a common mistake that arises from constructs like: + // BitStream stream + // ... fill common data into stream + // BitStream switchedstream + // .. fill data depending on side in both streams + // broadcastBistream(stream, switchedstream) + // + // here, the internal data of switchedstream is the same as stream so all + // changes made with switchedstream are done with stream alike. this was not + // the intention of this construct so it should be caught by this assertion. + /// NEVER USE THIS FUNCTION LIKE broadcastBitstream(str, str), use, broadcastBitstream(str) instead + /// this function is intended for sending two different streams to the two clients + + assert( stream != switchedstream ); + assert( stream->GetData() != switchedstream->GetData() ); + RakNet::BitStream* leftStream = mSwitchedSide == LEFT_PLAYER ? switchedstream : stream; RakNet::BitStream* rightStream = @@ -93,13 +121,22 @@ mRightPlayer, false); } +void NetworkGame::broadcastBitstream(RakNet::BitStream* stream) +{ + + mServer.Send(stream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, + mLeftPlayer, false); + mServer.Send(stream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, + mRightPlayer, false); +} + bool NetworkGame::step() { bool active = true; while (!mPacketQueue.empty()) { - Packet* packet = &mPacketQueue.front(); + packet_ptr packet = mPacketQueue.front(); mPacketQueue.pop_front(); switch(packet->data[0]) @@ -108,9 +145,10 @@ case ID_DISCONNECTION_NOTIFICATION: { RakNet::BitStream stream; - stream.Write(ID_OPPONENT_DISCONNECTED); - broadcastBitstream(&stream, &stream); + stream.Write((unsigned char)ID_OPPONENT_DISCONNECTED); + broadcastBitstream(&stream); mPausing = true; + mMatch->pause(); active = false; break; } @@ -120,8 +158,10 @@ int ival; RakNet::BitStream stream((char*)packet->data, packet->length, false); - stream.Read(ival); - stream.Read(ival); + + // ignore ID_INPUT_UPDATE and ID_TIMESTAMP + stream.IgnoreBytes(1); + stream.IgnoreBytes(1); stream.Read(ival); stream.Read(newInput.left); stream.Read(newInput.right); @@ -131,175 +171,209 @@ { if (mSwitchedSide == LEFT_PLAYER) newInput.swap(); - mPhysicWorld.setLeftInput(newInput); + mLeftInput->setInput(newInput); } if (packet->playerId == mRightPlayer) { if (mSwitchedSide == RIGHT_PLAYER) newInput.swap(); - mPhysicWorld.setRightInput(newInput); + mRightInput->setInput(newInput); } break; } case ID_PAUSE: { RakNet::BitStream stream; - stream.Write(ID_PAUSE); - broadcastBitstream(&stream, &stream); + stream.Write((unsigned char)ID_PAUSE); + broadcastBitstream(&stream); mPausing = true; + mMatch->pause(); break; } case ID_UNPAUSE: { RakNet::BitStream stream; - stream.Write(ID_UNPAUSE); - broadcastBitstream(&stream, &stream); + stream.Write((unsigned char)ID_UNPAUSE); + broadcastBitstream(&stream); mPausing = false; + mMatch->unpause(); + break; + } + case ID_CHAT_MESSAGE: + { RakNet::BitStream stream((char*)packet->data, + packet->length, false); + + stream.IgnoreBytes(1); // ID_CHAT_MESSAGE + char message[31]; + stream.Read(message, sizeof(message)); + + RakNet::BitStream stream2; + stream2.Write((unsigned char)ID_CHAT_MESSAGE); + stream2.Write(message, sizeof(message)); + if (mLeftPlayer == packet->playerId) + mServer.Send(&stream2, LOW_PRIORITY, RELIABLE_ORDERED, 0, mRightPlayer, false); + else + mServer.Send(&stream2, LOW_PRIORITY, RELIABLE_ORDERED, 0, mLeftPlayer, false); + break; + } + case ID_REPLAY: + { + // this should ensure that the created temponaries have unique names + std::stringstream temp; + temp << "replays/"; + temp << RakNet::GetTime(); + temp << packet->playerId.binaryAddress; + std::string file = temp.str(); + mRecorder->save(file); + + PHYSFS_file* fileHandle = PHYSFS_openRead(file.c_str()); + // what should we do if an error occures here? + //if (!fileHandle) + // throw FileLoadException(filename); + int fileLength = PHYSFS_fileLength(fileHandle); + //if (fileLength < 8) {} + char* data = new char[fileLength]; + PHYSFS_read(fileHandle, data, 1, fileLength); + + RakNet::BitStream stream; + stream.Write((unsigned char)ID_REPLAY); + stream.Write(fileLength); + stream.Write(data, fileLength); + mServer.Send(&stream, LOW_PRIORITY, RELIABLE_ORDERED, 0, packet->playerId, false); + + delete[] data; + PHYSFS_close(fileHandle); + PHYSFS_delete(file.c_str()); break; } default: - printf("unknown packet %d recieved\n", + printf("unknown packet %d received\n", int(packet->data[0])); break; } - }; - - if (!mPausing) - mPhysicWorld.step(); - - if (0 == mSquishLeft) - { - if (mPhysicWorld.ballHitLeftPlayer()) - { - RakNet::BitStream stream; - stream.Write(ID_BALL_PLAYER_COLLISION); - stream.Write(mPhysicWorld.lastHitIntensity()); - RakNet::BitStream switchStream(stream); - stream.Write(LEFT_PLAYER); - switchStream.Write(RIGHT_PLAYER); - broadcastBitstream(&stream, &switchStream); - mLeftHitcount++; - mRightHitcount = 0; - mSquishLeft = 1; - } - } - else - { - mSquishLeft += 1; - if(mSquishLeft > 9) - mSquishLeft=0; - } - - if(0 == mSquishRight) - { - if (mPhysicWorld.ballHitRightPlayer()) - { - RakNet::BitStream stream; - stream.Write(ID_BALL_PLAYER_COLLISION); - stream.Write(mPhysicWorld.lastHitIntensity()); - RakNet::BitStream switchStream(stream); - stream.Write(RIGHT_PLAYER); - switchStream.Write(LEFT_PLAYER); - broadcastBitstream(&stream, &switchStream); - mRightHitcount++; - mLeftHitcount = 0; - mSquishRight = 1; - } - } - else - { - mSquishRight += 1; - if(mSquishRight > 9) - mSquishRight=0; } + + // don't record the pauses + if(!mMatch->isPaused()) + mRecorder->record(mMatch->getPlayersInput()); + + mMatch->step(); - if (mPhysicWorld.ballHitLeftGround() || mLeftHitcount > 3) + int events = mMatch->getEvents(); + if(events & DuelMatch::EVENT_LEFT_BLOBBY_HIT) { RakNet::BitStream stream; - stream.Write(ID_BALL_GROUND_COLLISION); + stream.Write((unsigned char)ID_BALL_PLAYER_COLLISION); + stream.Write(mMatch->getWorld().lastHitIntensity()); stream.Write(LEFT_PLAYER); + RakNet::BitStream switchStream; - switchStream.Write(ID_BALL_GROUND_COLLISION); + switchStream.Write((unsigned char)ID_BALL_PLAYER_COLLISION); + switchStream.Write(mMatch->getWorld().lastHitIntensity()); switchStream.Write(RIGHT_PLAYER); + broadcastBitstream(&stream, &switchStream); - - if (mLeftHitcount > 3) - mPhysicWorld.dampBall(); - if (mServingPlayer == 1) - mRightScore++; - mServingPlayer = RIGHT_PLAYER; - mPhysicWorld.setBallValidity(0); - mRightHitcount = 0; - mLeftHitcount = 0; } - - if (mPhysicWorld.ballHitRightGround() || mRightHitcount > 3) + + if(events & DuelMatch::EVENT_RIGHT_BLOBBY_HIT) { RakNet::BitStream stream; - stream.Write(ID_BALL_GROUND_COLLISION); + stream.Write((unsigned char)ID_BALL_PLAYER_COLLISION); + stream.Write(mMatch->getWorld().lastHitIntensity()); stream.Write(RIGHT_PLAYER); - + RakNet::BitStream switchStream; - switchStream.Write(ID_BALL_GROUND_COLLISION); + switchStream.Write((unsigned char)ID_BALL_PLAYER_COLLISION); + switchStream.Write(mMatch->getWorld().lastHitIntensity()); switchStream.Write(LEFT_PLAYER); - + broadcastBitstream(&stream, &switchStream); - - if(mRightHitcount > 3) - mPhysicWorld.dampBall(); - if (mServingPlayer == 0) - mLeftScore++; - mServingPlayer = LEFT_PLAYER; - mPhysicWorld.setBallValidity(0); - mRightHitcount = 0; - mLeftHitcount = 0; } - if (mLeftScore >= 15 && mLeftScore >= mRightScore + 2) + if(events & DuelMatch::EVENT_BALL_HIT_LEFT_GROUND) { RakNet::BitStream stream; - stream.Write(ID_WIN_NOTIFICATION); + stream.Write((unsigned char)ID_BALL_GROUND_COLLISION); stream.Write(LEFT_PLAYER); - RakNet::BitStream switchStream; - switchStream.Write(ID_WIN_NOTIFICATION); + switchStream.Write((unsigned char)ID_BALL_GROUND_COLLISION); switchStream.Write(RIGHT_PLAYER); - broadcastBitstream(&stream, &switchStream); - return active; } - if (mRightScore >= 15 && mRightScore >= mLeftScore + 2) + + if(events & DuelMatch::EVENT_BALL_HIT_RIGHT_GROUND) { RakNet::BitStream stream; - stream.Write(ID_WIN_NOTIFICATION); + // is it correct to send ID_BALL_GROUND_COLLISION even if the + // error was a forth hit of a player? + stream.Write((unsigned char)ID_BALL_GROUND_COLLISION); stream.Write(RIGHT_PLAYER); RakNet::BitStream switchStream; - switchStream.Write(ID_WIN_NOTIFICATION); + switchStream.Write((unsigned char)ID_BALL_GROUND_COLLISION); switchStream.Write(LEFT_PLAYER); broadcastBitstream(&stream, &switchStream); - return active; } + + if(!mPausing) + switch(mMatch->winningPlayer()){ + case LEFT_PLAYER: + { + RakNet::BitStream stream; + stream.Write((unsigned char)ID_WIN_NOTIFICATION); + stream.Write(LEFT_PLAYER); + + RakNet::BitStream switchStream; + switchStream.Write((unsigned char)ID_WIN_NOTIFICATION); + switchStream.Write(RIGHT_PLAYER); + + broadcastBitstream(&stream, &switchStream); + + // if someone has won, the game is paused + mPausing = true; + mMatch->pause(); + return active; + } + break; + case RIGHT_PLAYER: + { + RakNet::BitStream stream; + stream.Write((unsigned char)ID_WIN_NOTIFICATION); + stream.Write(RIGHT_PLAYER); + + RakNet::BitStream switchStream; + switchStream.Write((unsigned char)ID_WIN_NOTIFICATION); + switchStream.Write(LEFT_PLAYER); + + broadcastBitstream(&stream, &switchStream); + + // if someone has won, the game is paused + mPausing = true; + mMatch->pause(); + return active; + } + break; + } - if (mPhysicWorld.roundFinished()) + if (events & DuelMatch::EVENT_RESET) { RakNet::BitStream stream; - stream.Write(ID_BALL_RESET); - stream.Write(mServingPlayer); - stream.Write(mLeftScore); - stream.Write(mRightScore); + stream.Write((unsigned char)ID_BALL_RESET); + stream.Write(mMatch->getServingPlayer()); + stream.Write(mMatch->getScore(LEFT_PLAYER)); + stream.Write(mMatch->getScore(RIGHT_PLAYER)); + stream.Write(mMatch->getClock().getTime()); RakNet::BitStream switchStream; - switchStream.Write(ID_BALL_RESET); + switchStream.Write((unsigned char)ID_BALL_RESET); switchStream.Write( - mServingPlayer == LEFT_PLAYER ? RIGHT_PLAYER : LEFT_PLAYER); - switchStream.Write(mRightScore); - switchStream.Write(mLeftScore); + mMatch->getServingPlayer() == LEFT_PLAYER ? RIGHT_PLAYER : LEFT_PLAYER); + switchStream.Write(mMatch->getScore(RIGHT_PLAYER)); + switchStream.Write(mMatch->getScore(LEFT_PLAYER)); + switchStream.Write(mMatch->getClock().getTime()); broadcastBitstream(&stream, &switchStream); - - mPhysicWorld.reset(mServingPlayer); } if (!mPausing) @@ -312,25 +386,26 @@ void NetworkGame::broadcastPhysicState() { + const PhysicWorld& world = mMatch->getWorld(); RakNet::BitStream stream; - stream.Write(ID_PHYSIC_UPDATE); - stream.Write(ID_TIMESTAMP); + stream.Write((unsigned char)ID_PHYSIC_UPDATE); + stream.Write((unsigned char)ID_TIMESTAMP); stream.Write(RakNet::GetTime()); if (mSwitchedSide == LEFT_PLAYER) - mPhysicWorld.getSwappedState(&stream); + world.getSwappedState(&stream); else - mPhysicWorld.getState(&stream); + world.getState(&stream); mServer.Send(&stream, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0, mLeftPlayer, false); stream.Reset(); - stream.Write(ID_PHYSIC_UPDATE); - stream.Write(ID_TIMESTAMP); + stream.Write((unsigned char)ID_PHYSIC_UPDATE); + stream.Write((unsigned char)ID_TIMESTAMP); stream.Write(RakNet::GetTime()); if (mSwitchedSide == RIGHT_PLAYER) - mPhysicWorld.getSwappedState(&stream); + world.getSwappedState(&stream); else - mPhysicWorld.getState(&stream); + world.getState(&stream); mServer.Send(&stream, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0, mRightPlayer, false); } diff -Nru blobby-0.8-dfsg/src/NetworkGame.h blobby-0.9c/src/NetworkGame.h --- blobby-0.8-dfsg/src/NetworkGame.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/NetworkGame.h 2011-11-06 15:06:46.000000000 +0000 @@ -22,14 +22,17 @@ #include #include "Global.h" -#include "PhysicWorld.h" #include "raknet/NetworkTypes.h" #include "UserConfig.h" #include "SpeedController.h" +#include "InputSource.h" +#include "RakNetPacket.h" +#include "DuelMatch.h" class RakServer; +class ReplayRecorder; -typedef std::list PacketQueue; +typedef std::list PacketQueue; class NetworkGame { @@ -43,11 +46,12 @@ NetworkGame(RakServer& server, PlayerID leftPlayer, PlayerID rightPlayer, std::string leftPlayerName, std::string rightPlayerName, + Color leftColor, Color rightColor, PlayerSide switchedSide = NO_PLAYER); ~NetworkGame(); - void injectPacket(Packet* packet); + void injectPacket(const packet_ptr& packet); // This function processes the queued network packets, // makes a physic step, checks the rules and broadcasts @@ -57,6 +61,7 @@ private: void broadcastBitstream(RakNet::BitStream* stream, RakNet::BitStream* switchedstream); + void broadcastBitstream(RakNet::BitStream* stream); void broadcastPhysicState(); RakServer& mServer; @@ -68,16 +73,12 @@ PacketQueue mPacketQueue; - PhysicWorld mPhysicWorld; - int mLeftScore; - int mRightScore; - PlayerSide mServingPlayer; + DuelMatch* mMatch; + DummyInputSource* mLeftInput; + DummyInputSource* mRightInput; PlayerSide mWinningPlayer; - int mLeftHitcount; - int mRightHitcount; - int mSquishLeft; - int mSquishRight; + ReplayRecorder* mRecorder; bool mPausing; diff -Nru blobby-0.8-dfsg/src/NetworkMessage.cpp blobby-0.9c/src/NetworkMessage.cpp --- blobby-0.8-dfsg/src/NetworkMessage.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/NetworkMessage.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -19,15 +19,17 @@ #include "NetworkMessage.h" #include "UserConfig.h" +#include "SpeedController.h" #include ServerInfo::ServerInfo(RakNet::BitStream& stream, const char* ip) { strncpy(hostname, ip, sizeof(hostname)); - hostname[sizeof(hostname)] = 0; + hostname[sizeof(hostname) - 1] = 0; stream.Read(activegames); + stream.Read(gamespeed); stream.Read(name, sizeof(name)); stream.Read(waitingplayer, sizeof(waitingplayer)); stream.Read(description, sizeof(description)); @@ -41,6 +43,7 @@ strncpy(name, tmp.c_str(), sizeof(name) - 1); tmp = config.getString("description"); strncpy(description, tmp.c_str(), sizeof(description) - 1); + gamespeed = config.getInteger("speed"); } ServerInfo::ServerInfo(const std::string& playername) @@ -48,19 +51,30 @@ memset(this, 0, sizeof(ServerInfo)); strncpy(name, std::string(playername + "'s game").c_str(), sizeof(name) - 1); strncpy(description, "client hosted game", sizeof(description) - 1); + gamespeed = (int)SpeedController::getMainInstance()->getGameSpeed(); } void ServerInfo::writeToBitstream(RakNet::BitStream& stream) { stream.Write(activegames); + stream.Write(gamespeed); stream.Write(name, sizeof(name)); stream.Write(waitingplayer, sizeof(waitingplayer)); stream.Write(description, sizeof(description)); } +const size_t ServerInfo::BLOBBY_SERVER_PRESENT_PACKET_SIZE = sizeof((unsigned char)ID_BLOBBY_SERVER_PRESENT) + + 2 * sizeof(int) // activegames & gamespeed + + 32 // name + + 64 // waiting player + + 192; // description + + + bool operator == (const ServerInfo& lval, const ServerInfo& rval) { return !strncmp(lval.hostname, rval.hostname, sizeof(lval.hostname)); } + diff -Nru blobby-0.8-dfsg/src/NetworkMessage.h blobby-0.9c/src/NetworkMessage.h --- blobby-0.8-dfsg/src/NetworkMessage.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/NetworkMessage.h 2011-11-06 15:06:46.000000000 +0000 @@ -19,7 +19,7 @@ #pragma once -#include +#include #include #include "raknet/PacketEnumerations.h" @@ -42,7 +42,8 @@ ID_BLOBBY_SERVER_PRESENT, ID_OLD_CLIENT, ID_UNKNOWN_CLIENT, - + ID_REPLAY, + ID_CHAT_MESSAGE }; // General Information: @@ -52,7 +53,7 @@ // to a client, the information has to be converted into the view // of the client. -// ID_INPUT_UPDATE: +// ID_INPUT_UPDATE = 63: // Description: // This packet is sent from client to server every frame. // It contains the current input state as three booleans. @@ -73,6 +74,7 @@ // ID_PHYSIC_UPDATE // ID_TIMESTAMP // timestamp (int) +// packet_number (unsigned char) // Physic data (analysed by PhysicWorld) // // ID_WIN_NOTIFICATION @@ -88,12 +90,14 @@ // Description: // Message sent from server to all clients when the ball // is reset to the starting position. It includes an information -// about the current point state. +// about the current point state and is used to synchronize +// the clocks. // Structure: // ID_BALL_RESET // serving player (PlayerSide) // left score (int) // right score (int) +// time (int) // // ID_BALL_GROUND_COLLISION // Description: @@ -124,6 +128,7 @@ // opponent. // Structure: // ID_GAME_READY +// gamespeed (int) // opponentname(char[16]) // // ID_ENTER_GAME @@ -183,6 +188,15 @@ // Structure: // ID_UNKNOWN_CLIENT // +// ID_REPLAY +// Description: +// Sent from client to server to request a replay +// Sent from server to client to transmitt the replay +// Structure: +// ID_REPLAY +// size (int) +// data +// class UserConfig; @@ -195,10 +209,13 @@ void writeToBitstream(RakNet::BitStream& stream); int activegames; + int gamespeed; char hostname[64]; char name[32]; char waitingplayer[64]; char description[192]; + + static const size_t BLOBBY_SERVER_PRESENT_PACKET_SIZE; }; bool operator == (const ServerInfo& lval, const ServerInfo& rval); diff -Nru blobby-0.8-dfsg/src/PhysicWorld.cpp blobby-0.9c/src/PhysicWorld.cpp --- blobby-0.8-dfsg/src/PhysicWorld.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/PhysicWorld.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -18,54 +18,21 @@ =============================================================================*/ #include "PhysicWorld.h" +#include "GameConstants.h" #include "raknet/BitStream.h" +#include + const int TIMESTEP = 5; // calculations per frame const float TIMEOUT_MAX = 2.5; -// Blobby Settings -const float BLOBBY_HEIGHT = 89; -const float BLOBBY_WIDTH = 75; -const float BLOBBY_UPPER_SPHERE = 19; -const float BLOBBY_UPPER_RADIUS = 25; -const float BLOBBY_LOWER_SPHERE = 13; -const float BLOBBY_LOWER_RADIUS = 33; - -// Volley Ball Net -const float NET_POSITION_X = 400; -const float NET_POSITION_Y = 438; -const float NET_RADIUS = 7; -const float NET_SPHERE = 154; -const float NET_SPHERE_POSITION = 284; - -// Ball Settings -const float BALL_RADIUS = 31.5; - -const float GROUND_PLANE_HEIGHT_MAX = 500; -const float GROUND_PLANE_HEIGHT = GROUND_PLANE_HEIGHT_MAX - BLOBBY_HEIGHT / 2.0; - -// Border Settings -const float LEFT_PLANE = 0; -const float RIGHT_PLANE = 800.0; -// These numbers should include the blobbys width, but in the original game -// the blobbys can go a bit into the walls too. - - // Gamefeeling relevant constants: const float BLOBBY_ANIMATION_SPEED = 0.5; -const float BLOBBY_JUMP_ACCELERATION = 15.1; -// This is exactly the half of the gravitation, i checked it in -// the original code -const float BLOBBY_JUMP_BUFFER = 0.44; -const float GRAVITATION = 0.88; -const float BALL_GRAVITATION = 0.28; const float STANDARD_BALL_ANGULAR_VELOCITY = 0.1; const float STANDARD_BALL_HEIGHT = 269 + BALL_RADIUS; -const float BALL_COLLISION_VELOCITY = 13.125; - PhysicWorld::PhysicWorld() { reset(LEFT_PLAYER); @@ -78,7 +45,7 @@ { } -bool PhysicWorld::resetAreaClear() +bool PhysicWorld::resetAreaClear() const { if (blobbyHitGround(LEFT_PLAYER) && blobbyHitGround(RIGHT_PLAYER)) return true; @@ -115,7 +82,7 @@ GROUND_PLANE_HEIGHT); } -bool PhysicWorld::ballHitRightGround() +bool PhysicWorld::ballHitRightGround() const { if (mIsBallValid) if (mBallPosition.y > GROUND_PLANE_HEIGHT && @@ -124,7 +91,7 @@ return false; } -bool PhysicWorld::ballHitLeftGround() +bool PhysicWorld::ballHitLeftGround() const { if (mIsBallValid) if (mBallPosition.y > GROUND_PLANE_HEIGHT && @@ -133,7 +100,7 @@ return false; } -bool PhysicWorld::blobbyHitGround(PlayerSide player) +bool PhysicWorld::blobbyHitGround(PlayerSide player) const { if (player == LEFT_PLAYER) { @@ -158,7 +125,7 @@ mIsBallValid = validity; } -bool PhysicWorld::roundFinished() +bool PhysicWorld::roundFinished() const { if (resetAreaClear()) { @@ -172,13 +139,13 @@ return false; } -float PhysicWorld::lastHitIntensity() +float PhysicWorld::lastHitIntensity() const { float intensity = mLastHitIntensity / 25.0; return intensity < 1.0 ? intensity : 1.0; } -bool PhysicWorld::playerTopBallCollision(int player) +bool PhysicWorld::playerTopBallCollision(int player) const { if (Vector2(mBallPosition, Vector2(mBlobPosition[player].x, @@ -188,7 +155,7 @@ return false; } -inline bool PhysicWorld::playerBottomBallCollision(int player) +inline bool PhysicWorld::playerBottomBallCollision(int player) const { if (Vector2(mBallPosition, Vector2(mBlobPosition[player].x, @@ -198,37 +165,37 @@ return false; } -bool PhysicWorld::ballHitLeftPlayer() +bool PhysicWorld::ballHitLeftPlayer() const { return mBallHitByBlob[LEFT_PLAYER]; } -bool PhysicWorld::ballHitRightPlayer() +bool PhysicWorld::ballHitRightPlayer() const { return mBallHitByBlob[RIGHT_PLAYER]; } -Vector2 PhysicWorld::getBall() +Vector2 PhysicWorld::getBall() const { return mBallPosition; } -float PhysicWorld::getBallRotation() +float PhysicWorld::getBallRotation() const { return mBallRotation; } -float PhysicWorld::getBallSpeed() +float PhysicWorld::getBallSpeed() const { return mBallVelocity.length(); } -Vector2 PhysicWorld::getBlob(PlayerSide player) +Vector2 PhysicWorld::getBlob(PlayerSide player) const { return mBlobPosition[player]; } -float PhysicWorld::getBlobState(PlayerSide player) +float PhysicWorld::getBlobState(PlayerSide player) const { return mBlobState[player]; } @@ -386,16 +353,21 @@ if (mBallPosition.x - BALL_RADIUS <= LEFT_PLANE && mBallVelocity.x < 0.0) { mBallVelocity = mBallVelocity.reflectX(); + // set the ball's position + mBallPosition.x = LEFT_PLANE + BALL_RADIUS; } else if (mBallPosition.x + BALL_RADIUS >= RIGHT_PLANE && mBallVelocity.x > 0.0) { mBallVelocity = mBallVelocity.reflectX(); + // set the ball's position + mBallPosition.x = RIGHT_PLANE - BALL_RADIUS; } else if (mBallPosition.y > NET_SPHERE_POSITION && fabs(mBallPosition.x - NET_POSITION_X) < BALL_RADIUS + NET_RADIUS) { mBallVelocity = mBallVelocity.reflectX(); - mBallPosition += mBallVelocity; + // set the ball's position so that it touches the net + mBallPosition.x = NET_POSITION_X + ((mBallPosition.x - NET_POSITION_X > 0) ?( BALL_RADIUS + NET_RADIUS) : (- BALL_RADIUS - NET_RADIUS)); } else { @@ -405,15 +377,26 @@ if (ballNetDistance < NET_RADIUS + BALL_RADIUS) { - mBallVelocity = mBallVelocity.reflect(Vector2(mBallPosition, - Vector2(NET_POSITION_X, NET_SPHERE_POSITION)) - .normalise()).scale(0.75); - - while (ballNetDistance < NET_RADIUS + BALL_RADIUS) - { - mBallPosition += mBallVelocity; - ballNetDistance = Vector2(mBallPosition, Vector2(NET_POSITION_X, NET_SPHERE_POSITION)).length(); - } + // calculate + Vector2 normal = Vector2(mBallPosition, Vector2(NET_POSITION_X, NET_SPHERE_POSITION)).normalise(); + + // normal component of kinetic energy + float perp_ekin = normal.dotProduct(mBallVelocity); + perp_ekin *= perp_ekin; + // parallel component of kinetic energy + float para_ekin = mBallVelocity.length() * mBallVelocity.length() - perp_ekin; + + // the normal component is damped stronger than the parallel component + // the values are ~ 0.85² and ca. 0.95², because speed is sqrt(ekin) + perp_ekin *= 0.7; + para_ekin *= 0.9; + + float nspeed = sqrt(perp_ekin + para_ekin); + + mBallVelocity = Vector2(mBallVelocity.reflect(normal).normalise().scale(nspeed)); + + // pushes the ball out of the net + mBallPosition = (Vector2(NET_POSITION_X, NET_SPHERE_POSITION) - normal * (NET_RADIUS + BALL_RADIUS)); } // mBallVelocity = mBallVelocity.reflect( Vector2( mBallPosition, Vector2 (NET_POSITION_X, temp) ).normalise()).scale(0.75); } @@ -455,52 +438,81 @@ mBallVelocity = mBallVelocity.scale(0.6); } -Vector2 PhysicWorld::getBallVelocity() +Vector2 PhysicWorld::getBallVelocity() const { return mBallVelocity; } -bool PhysicWorld::getBlobJump(PlayerSide player) +bool PhysicWorld::getBlobJump(PlayerSide player) const { return !blobbyHitGround(player); } -float PhysicWorld::estimateBallImpact() +bool PhysicWorld::getBallActive() const { - float steps; - steps = (mBallVelocity.y - sqrt((mBallVelocity.y * mBallVelocity.y)- - (-2 * BALL_GRAVITATION * (-mBallPosition.y + GROUND_PLANE_HEIGHT_MAX + BALL_RADIUS)))) / (-BALL_GRAVITATION); - return (mBallVelocity.x * steps) + mBallPosition.x; + return mIsGameRunning; } -Vector2 PhysicWorld::estimateBallPosition(int steps) +void writeCompressedToBitStream(RakNet::BitStream* stream, float value, float min, float max) { - Vector2 ret; - ret.x = mBallVelocity.x * float(steps); - ret.y = (mBallVelocity.y + 0.5 * (BALL_GRAVITATION * float(steps))) * float(steps); - return mBallPosition + ret; + assert(min <= value && value <= max); + assert(stream); + unsigned short only2bytes = static_cast((value - min) / (max - min) * std::numeric_limits::max()); + stream->Write(only2bytes); } -bool PhysicWorld::getBallActive() +void readCompressedFromBitStream(RakNet::BitStream* stream, float& value, float min, float max) { - return mIsGameRunning; + unsigned short only2bytes; + stream->Read(only2bytes); + value = static_cast(only2bytes) / static_cast(std::numeric_limits::max()) * (max - min) + min; } + void PhysicWorld::setState(RakNet::BitStream* stream) { - stream->Read(mBlobPosition[LEFT_PLAYER].x); - stream->Read(mBlobPosition[LEFT_PLAYER].y); - stream->Read(mBlobPosition[RIGHT_PLAYER].x); - stream->Read(mBlobPosition[RIGHT_PLAYER].y); - stream->Read(mBallPosition.x); - stream->Read(mBallPosition.y); - - stream->Read(mBlobVelocity[LEFT_PLAYER].x); - stream->Read(mBlobVelocity[LEFT_PLAYER].y); - stream->Read(mBlobVelocity[RIGHT_PLAYER].x); - stream->Read(mBlobVelocity[RIGHT_PLAYER].y); - stream->Read(mBallVelocity.x); - stream->Read(mBallVelocity.y); + bool leftGround; + bool rightGround; + stream->Read(leftGround); + stream->Read(rightGround); + if(leftGround){ + mBlobPosition[LEFT_PLAYER].y = GROUND_PLANE_HEIGHT; + mBlobVelocity[LEFT_PLAYER].y = 0; + }else{ + readCompressedFromBitStream(stream, mBlobPosition[LEFT_PLAYER].y, 0, GROUND_PLANE_HEIGHT); + readCompressedFromBitStream(stream, mBlobVelocity[LEFT_PLAYER].y, -30, 30); + } + + if(rightGround){ + mBlobPosition[RIGHT_PLAYER].y = GROUND_PLANE_HEIGHT; + mBlobVelocity[RIGHT_PLAYER].y = 0; + }else{ + readCompressedFromBitStream(stream, mBlobPosition[RIGHT_PLAYER].y, 0, GROUND_PLANE_HEIGHT); + readCompressedFromBitStream(stream, mBlobVelocity[RIGHT_PLAYER].y, -30, 30); + } + + readCompressedFromBitStream(stream, mBlobPosition[LEFT_PLAYER].x, LEFT_PLANE, NET_POSITION_X); + readCompressedFromBitStream(stream, mBlobPosition[RIGHT_PLAYER].x, NET_POSITION_X, RIGHT_PLANE); + + readCompressedFromBitStream(stream, mBallPosition.x, LEFT_PLANE, RIGHT_PLANE); + // maybe these values is a bit too pessimistic... + // but we have 65535 values, hence it should be precise enough + readCompressedFromBitStream(stream, mBallPosition.y, -500, GROUND_PLANE_HEIGHT_MAX); + + readCompressedFromBitStream(stream, mBallVelocity.x, -30, 30); + readCompressedFromBitStream(stream, mBallVelocity.y, -30, 30); + + // if ball velocity not zero, we must assume that the game is active + // i'm not sure if this would be set correctly otherwise... + // we must use this check with 0.1f because of precision loss when velocities are transmitted + // wo prevent setting a false value when the ball is at the parabels top, we check also if the + // y - position is the starting y position + /// \todo maybe we should simply send a bit which contains this information? + if( std::abs(mBallVelocity.x) > 0.1f || std::abs(mBallVelocity.y) > 0.1f || std::abs(mBallPosition.y - STANDARD_BALL_HEIGHT) > 0.1f) { + mIsGameRunning = true; + } else { + mIsGameRunning = false; + } stream->Read(mPlayerInput[LEFT_PLAYER].left); stream->Read(mPlayerInput[LEFT_PLAYER].right); @@ -510,21 +522,31 @@ stream->Read(mPlayerInput[RIGHT_PLAYER].up); } -void PhysicWorld::getState(RakNet::BitStream* stream) +void PhysicWorld::getState(RakNet::BitStream* stream) const { - stream->Write(mBlobPosition[LEFT_PLAYER].x); - stream->Write(mBlobPosition[LEFT_PLAYER].y); - stream->Write(mBlobPosition[RIGHT_PLAYER].x); - stream->Write(mBlobPosition[RIGHT_PLAYER].y); - stream->Write(mBallPosition.x); - stream->Write(mBallPosition.y); - - stream->Write(mBlobVelocity[LEFT_PLAYER].x); - stream->Write(mBlobVelocity[LEFT_PLAYER].y); - stream->Write(mBlobVelocity[RIGHT_PLAYER].x); - stream->Write(mBlobVelocity[RIGHT_PLAYER].y); - stream->Write(mBallVelocity.x); - stream->Write(mBallVelocity.y); + // if the blobbys are standing on the ground, we need not send + // y position and velocity + stream->Write(blobbyHitGround(LEFT_PLAYER)); + stream->Write(blobbyHitGround(RIGHT_PLAYER)); + + if(!blobbyHitGround(LEFT_PLAYER)){ + writeCompressedToBitStream(stream, mBlobPosition[LEFT_PLAYER].y, 0, GROUND_PLANE_HEIGHT); + writeCompressedToBitStream(stream, mBlobVelocity[LEFT_PLAYER].y, -30, 30); + } + + if(!blobbyHitGround(RIGHT_PLAYER)){ + writeCompressedToBitStream(stream, mBlobPosition[RIGHT_PLAYER].y, 0, GROUND_PLANE_HEIGHT); + writeCompressedToBitStream(stream, mBlobVelocity[RIGHT_PLAYER].y, -30, 30); + } + + writeCompressedToBitStream(stream, mBlobPosition[LEFT_PLAYER].x, LEFT_PLANE, NET_POSITION_X); + writeCompressedToBitStream(stream, mBlobPosition[RIGHT_PLAYER].x, NET_POSITION_X, RIGHT_PLANE); + + writeCompressedToBitStream(stream, mBallPosition.x, LEFT_PLANE, RIGHT_PLANE); + writeCompressedToBitStream(stream, mBallPosition.y, -500, GROUND_PLANE_HEIGHT_MAX); + + writeCompressedToBitStream(stream, mBallVelocity.x, -30, 30); + writeCompressedToBitStream(stream, mBallVelocity.y, -30, 30); stream->Write(mPlayerInput[LEFT_PLAYER].left); stream->Write(mPlayerInput[LEFT_PLAYER].right); @@ -535,21 +557,31 @@ } -void PhysicWorld::getSwappedState(RakNet::BitStream* stream) +void PhysicWorld::getSwappedState(RakNet::BitStream* stream) const { - stream->Write(800 - mBlobPosition[RIGHT_PLAYER].x); - stream->Write(mBlobPosition[RIGHT_PLAYER].y); - stream->Write(800 - mBlobPosition[LEFT_PLAYER].x); - stream->Write(mBlobPosition[LEFT_PLAYER].y); - stream->Write(800 - mBallPosition.x); - stream->Write(mBallPosition.y); - - stream->Write(-mBlobVelocity[RIGHT_PLAYER].x); - stream->Write(mBlobVelocity[RIGHT_PLAYER].y); - stream->Write(-mBlobVelocity[LEFT_PLAYER].x); - stream->Write(mBlobVelocity[LEFT_PLAYER].y); - stream->Write(-mBallVelocity.x); - stream->Write(mBallVelocity.y); + // if the blobbys are standing on the ground, we need not send + // y position and velocity + stream->Write(blobbyHitGround(RIGHT_PLAYER)); + stream->Write(blobbyHitGround(LEFT_PLAYER)); + + if(!blobbyHitGround(LEFT_PLAYER)){ + writeCompressedToBitStream(stream, mBlobPosition[LEFT_PLAYER].y, 0, GROUND_PLANE_HEIGHT); + writeCompressedToBitStream(stream, mBlobVelocity[LEFT_PLAYER].y, -30, 30); + } + + if(!blobbyHitGround(RIGHT_PLAYER)){ + writeCompressedToBitStream(stream, mBlobPosition[RIGHT_PLAYER].y, 0, GROUND_PLANE_HEIGHT); + writeCompressedToBitStream(stream, mBlobVelocity[RIGHT_PLAYER].y, -30, 30); + } + + writeCompressedToBitStream(stream, 800 - mBlobPosition[RIGHT_PLAYER].x, LEFT_PLANE, NET_POSITION_X); + writeCompressedToBitStream(stream, 800 - mBlobPosition[LEFT_PLAYER].x, NET_POSITION_X, RIGHT_PLANE); + + writeCompressedToBitStream(stream, 800 - mBallPosition.x, LEFT_PLANE, RIGHT_PLANE); + writeCompressedToBitStream(stream, mBallPosition.y, -500, GROUND_PLANE_HEIGHT_MAX); + + writeCompressedToBitStream(stream, -mBallVelocity.x, -30, 30); + writeCompressedToBitStream(stream, mBallVelocity.y, -30, 30); stream->Write(mPlayerInput[RIGHT_PLAYER].right); stream->Write(mPlayerInput[RIGHT_PLAYER].left); @@ -559,7 +591,7 @@ stream->Write(mPlayerInput[LEFT_PLAYER].up); } -const PlayerInput* PhysicWorld::getPlayersInput() +const PlayerInput* PhysicWorld::getPlayersInput() const { return mPlayerInput; } diff -Nru blobby-0.8-dfsg/src/PhysicWorld.h blobby-0.9c/src/PhysicWorld.h --- blobby-0.8-dfsg/src/PhysicWorld.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/PhysicWorld.h 2011-11-06 15:06:46.000000000 +0000 @@ -19,8 +19,6 @@ #pragma once -#include - #include "Global.h" #include "Vector.h" #include "InputSource.h" @@ -36,9 +34,9 @@ class PhysicWorld { private: - inline bool playerTopBallCollision(int player); - inline bool playerBottomBallCollision(int player); - bool resetAreaClear(); + inline bool playerTopBallCollision(int player) const; + inline bool playerBottomBallCollision(int player) const; + bool resetAreaClear()const; // Do all blobby-related physic stuff which is independent from states void handleBlob(PlayerSide player); @@ -70,30 +68,28 @@ PhysicWorld(); ~PhysicWorld(); - Vector2 getBallVelocity(); - bool getBlobJump(PlayerSide player); - bool getBallActive(); - float estimateBallImpact(); - Vector2 estimateBallPosition(int steps); + Vector2 getBallVelocity() const; + bool getBlobJump(PlayerSide player) const; + bool getBallActive() const; void setLeftInput(const PlayerInput& input); void setRightInput(const PlayerInput& input); - Vector2 getBlob(PlayerSide player); - Vector2 getBall(); + Vector2 getBlob(PlayerSide player) const; + Vector2 getBall() const; - float getBlobState(PlayerSide player); - float getBallRotation(); + float getBlobState(PlayerSide player) const; + float getBallRotation() const; - float getBallSpeed(); + float getBallSpeed() const; // These functions tell about ball collisions for game logic and sound - bool ballHitLeftPlayer(); - bool ballHitRightPlayer(); - bool ballHitLeftGround(); - bool ballHitRightGround(); + bool ballHitLeftPlayer() const; + bool ballHitRightPlayer() const; + bool ballHitLeftGround() const; + bool ballHitRightGround() const; - bool blobbyHitGround(PlayerSide player); + bool blobbyHitGround(PlayerSide player) const; // Blobby animation methods void blobbyAnimationStep(PlayerSide player); @@ -101,7 +97,7 @@ // This reports the intensity of the collision // which was detected and also queried last. - float lastHitIntensity(); + float lastHitIntensity() const; // Here the game logic can decide whether the ball is valid. // If not, no ball to player collision checking is done, @@ -109,7 +105,7 @@ void setBallValidity(bool validity); // This returns true if the ball is not valid and the ball is steady - bool roundFinished(); + bool roundFinished() const; // This resets everything to the starting situation and // wants to know, which player begins. @@ -124,17 +120,17 @@ // For reducing ball speed after rule violation void dampBall(); - // Set a new state recieved from server over a RakNet BitStream + // Set a new state received from server over a RakNet BitStream void setState(RakNet::BitStream* stream); // Fill a Bitstream with the state - void getState(RakNet::BitStream* stream); + void getState(RakNet::BitStream* stream) const; // Fill a Bitstream with a side reversed state - void getSwappedState(RakNet::BitStream* stream); + void getSwappedState(RakNet::BitStream* stream) const; //Input stuff for recording and playing replays - const PlayerInput* getPlayersInput(); + const PlayerInput* getPlayersInput() const; }; diff -Nru blobby-0.8-dfsg/src/Player.cpp blobby-0.9c/src/Player.cpp --- blobby-0.8-dfsg/src/Player.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/Player.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -36,22 +36,30 @@ } } -void Player::loadFromConfig(const std::string& prefix) +void Player::loadFromConfig(const std::string& prefix, bool initInput) { UserConfig gameConfig; gameConfig.loadFile("config.xml"); - if (gameConfig.getBool(prefix + "_player_human")) { - mInputSource = new LocalInputSource(mPlayerSide); - } else { - mInputSource = new ScriptedInputSource("scripts/" + - gameConfig.getString(prefix + "_script_name"), mPlayerSide); + // init local input + if(initInput){ + if (gameConfig.getBool(prefix + "_player_human")) { + mInputSource = new LocalInputSource(mPlayerSide); + } else { + mInputSource = new ScriptedInputSource("scripts/" + + gameConfig.getString(prefix + "_script_name"), mPlayerSide, gameConfig.getInteger(prefix + "_script_strength")); + } + + mName = gameConfig.getBool(prefix + "_player_human") ? + gameConfig.getString(prefix + "_player_name") : + gameConfig.getString(prefix + "_script_name"); + }else{ + // input is set externally (network) + // so we need not to create any input source + mInputSource = 0; + // don't use bot name if extern input is used + mName = gameConfig.getString(prefix + "_player_name"); } - - mName = gameConfig.getBool(prefix + "_player_human") ? - gameConfig.getString(prefix + "_player_name") : - gameConfig.getString(prefix + "_script_name"); - mInitialised = true; mStaticColor = Color( @@ -80,6 +88,11 @@ } } +void Player::setColor(Color ncol) +{ + mStaticColor = ncol; +} + std::string Player::getName() const { assert(mInitialised); @@ -87,6 +100,11 @@ return mName; } +void Player::setName(const std::string& name) +{ + mName = name; +} + InputSource* Player::getInputSource() const { assert(mInitialised); diff -Nru blobby-0.8-dfsg/src/Player.h blobby-0.9c/src/Player.h --- blobby-0.8-dfsg/src/Player.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/Player.h 2011-11-06 15:06:46.000000000 +0000 @@ -31,11 +31,14 @@ Player(PlayerSide side); ~Player(); - void loadFromConfig(const std::string& prefix); + void loadFromConfig(const std::string& prefix, bool initInput = true); InputSource* getInputSource() const; std::string getName() const; Color getColor() const; + + void setColor(Color ncol); + void setName(const std::string& name); private: bool mInitialised; diff -Nru blobby-0.8-dfsg/src/raknet/HuffmanEncodingTreeFactory.h blobby-0.9c/src/raknet/HuffmanEncodingTreeFactory.h --- blobby-0.8-dfsg/src/raknet/HuffmanEncodingTreeFactory.h 2010-02-16 23:32:32.000000000 +0000 +++ blobby-0.9c/src/raknet/HuffmanEncodingTreeFactory.h 2011-11-06 15:06:43.000000000 +0000 @@ -46,7 +46,7 @@ */ HuffmanEncodingTreeFactory(); /** - * Reset the frequency table. You don't need to call this unless you want to reuse the class for a new tree + * Reset the frequency table. You don't need to call this unless you want to reuse the class for a new tree */ void Reset( void ); /** diff -Nru blobby-0.8-dfsg/src/raknet/LICENSE blobby-0.9c/src/raknet/LICENSE --- blobby-0.8-dfsg/src/raknet/LICENSE 2010-02-18 13:28:15.000000000 +0000 +++ blobby-0.9c/src/raknet/LICENSE 2011-11-06 15:06:43.000000000 +0000 @@ -1,3 +1,6 @@ +RAKNET EMAIL: + + We are allowed to change every file to BSD-License: From - Tue Feb 16 17:22:10 2010 X-Account-Key: account2 @@ -55,3 +58,80 @@ > Blobby Volley 2 > + +RIJNDAEL EMAIL: +From - Thu Mar 25 17:58:29 2010 +X-Account-Key: account2 +X-UIDL: 743025543 +X-Mozilla-Status: 0011 +X-Mozilla-Status2: 00000000 +X-Mozilla-Keys: +Received: from [134.58.240.44] (helo=cavuit02.kulnet.kuleuven.be) + by mx36.web.de with esmtp (WEB.DE 4.110 #4) + id 1NuoF1-0002hE-00 + for daniel-knobe@web.de; Thu, 25 Mar 2010 15:40:59 +0100 +Received: from smtps01.kuleuven.be (smtpshost01.kulnet.kuleuven.be [134.58.240.74]) + by cavuit02.kulnet.kuleuven.be (Postfix) with ESMTP id C557E51C004 + for ; Thu, 25 Mar 2010 15:40:38 +0100 (CET) +Received: from hydrogen.esat.kuleuven.be (hydrogen.esat.kuleuven.be [134.58.56.153]) + by smtps01.kuleuven.be (Postfix) with ESMTP id 7D9F031E702 + for ; Thu, 25 Mar 2010 15:40:38 +0100 (CET) +Received: from [10.33.137.107] (boguspomp.esat.kuleuven.be [10.33.137.107]) + by hydrogen.esat.kuleuven.be (Postfix) with ESMTP id 8D91148002 + for ; Thu, 25 Mar 2010 15:40:38 +0100 (CET) +Message-ID: <4BAB75E6.2020408@esat.kuleuven.be> +Date: Thu, 25 Mar 2010 15:40:38 +0100 +X-Kuleuven: This mail passed the K.U.Leuven mailcluster +From: Vincent Rijmen +Organization: K.U. Leuven +User-Agent: Thunderbird 2.0.0.22 (X11/20090625) +MIME-Version: 1.0 +To: Daniel Knobe +Subject: Re: rijndael license problems +References: <4BA93621.3060605@web.de> <4BA9C2D2.4060400@esat.kuleuven.be> <4BAA3650.30505@web.de> +In-Reply-To: <4BAA3650.30505@web.de> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-KULeuven-Information: Katholieke Universiteit Leuven +X-KULeuven-Scanned: Found to be clean +X-Spam-Status: not spam, SpamAssassin (not cached, score=-50, required 5, + autolearn=disabled, KUL_SMTPS -50.00) +X-KULeuven-Envelope-From: vincent.rijmen@esat.kuleuven.be +Return-Path: vincent.rijmen@esat.kuleuven.be + +This code is public. There is no license. + +Vincent + +Daniel Knobe wrote: +> I'm sorry, it was my mistake. +> Here are the files (hope you use a free license). +> +> We need this version of the files (or a newer with 100% compatible API) +> +> Thanks for your support. +> +> Best regards, +> Daniel Knobe +> +> On 24.03.2010 08:44, Vincent Rijmen wrote: +>> +>> +>> Daniel Knobe wrote: +>>> Hi, +>>> we are using the 3 files below in our game blobby volley 2 +>>> (blobby.sf.net) +>> I did not see any files or file names. +>>> +>>> The problem is, that we can not find the lisensetext :(. We need it, +>>> because we have problems to add our game to debian and ubuntu lucid. +>>> Which version of lisence and version are you using? GPLv2? GPLv3, BSD? +>> None. +>>> +>>> Thanks for your support :). +>>> +>>> Greetz +>>> Daniel +>>> +>> +> diff -Nru blobby-0.8-dfsg/src/raknet/PacketEnumerations.h blobby-0.9c/src/raknet/PacketEnumerations.h --- blobby-0.8-dfsg/src/raknet/PacketEnumerations.h 2010-02-16 23:32:32.000000000 +0000 +++ blobby-0.9c/src/raknet/PacketEnumerations.h 2011-11-06 15:06:43.000000000 +0000 @@ -130,6 +130,7 @@ // In the unlikely event that you need more than 256 types, including the built-in types, then you'll need // to request a special edition with larger identifiers, or change it yourself // + ID_MASTER_REGISTER_USER, diff -Nru blobby-0.8-dfsg/src/raknet/rijndael-boxes.h blobby-0.9c/src/raknet/rijndael-boxes.h --- blobby-0.8-dfsg/src/raknet/rijndael-boxes.h 2008-03-13 21:51:40.000000000 +0000 +++ blobby-0.9c/src/raknet/rijndael-boxes.h 2011-11-06 15:06:43.000000000 +0000 @@ -1,3 +1,5 @@ +// This code is public, take a look in the LICENSE File + word8 Logtable[256] = { 0, 0, 25, 1, 50, 2, 26, 198, 75, 199, 27, 104, 51, 238, 223, 3, 100, 4, 224, 14, 52, 141, 129, 239, 76, 113, 8, 200, 248, 105, 28, 193, diff -Nru blobby-0.8-dfsg/src/raknet/rijndael.cpp blobby-0.9c/src/raknet/rijndael.cpp --- blobby-0.8-dfsg/src/raknet/rijndael.cpp 2008-03-13 21:51:40.000000000 +0000 +++ blobby-0.9c/src/raknet/rijndael.cpp 2011-11-06 15:06:43.000000000 +0000 @@ -4,6 +4,8 @@ * v2.0: Vincent Rijmen */ +// This code is public, take a look in the LICENSE File + /* * taken from the 'aescrypt' project: www.sf.net/projects/aescrypt * See LICENSE-EST for the license applicable to this file diff -Nru blobby-0.8-dfsg/src/raknet/rijndael.h blobby-0.9c/src/raknet/rijndael.h --- blobby-0.8-dfsg/src/raknet/rijndael.h 2008-03-13 21:51:40.000000000 +0000 +++ blobby-0.9c/src/raknet/rijndael.h 2011-11-06 15:06:43.000000000 +0000 @@ -2,6 +2,8 @@ * Optimised ANSI C code */ +// This code is public, take a look in the LICENSE File + /* * taken from the 'aescrypt' project: www.sf.net/projects/aescrypt * See LICENSE-EST for the license applicable to this file diff -Nru blobby-0.8-dfsg/src/raknet/Types.h blobby-0.9c/src/raknet/Types.h --- blobby-0.8-dfsg/src/raknet/Types.h 2010-02-16 23:32:32.000000000 +0000 +++ blobby-0.9c/src/raknet/Types.h 2011-11-06 15:06:43.000000000 +0000 @@ -98,6 +98,18 @@ * - COMPILER_BORLANDC */ +#include + +#if defined(__GLIBC__) && !defined(HOST_ENDIAN_IS_BIG) && !defined(HOST_ENDIAN_IS_LITTLE) + #include + + #if (__BYTE_ORDER == __LITTLE_ENDIAN) + #define HOST_ENDIAN_IS_LITTLE + #elif (__BYTE_ORDER == __BIG_ENDIAN) + #define HOST_ENDIAN_IS_BIG + #endif +#endif + // CB: Something strange happens with the system includes on // Linux and BIG_ENDIAN ends up defined at some point, so // we need to use HOST_ENDIAN_IS_BIG instead. This code is @@ -140,23 +152,11 @@ // LITTLE_ENDIAN or BIG_ENDIAN (endian.h) // dalfy #if !defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN) -#if defined(__sparc) || defined(__sparc__) || defined(__powerpc__) || \ - defined(__ppc__) || defined(__hppa) || defined(_MIPSEB) || defined(_POWER) || \ - defined(_M_PPC) || defined(_M_MPPC) || defined(_M_MRX000) || \ - defined(__POWERPC) || defined(m68k) || defined(powerpc) || \ - defined(sel) || defined(pyr) || defined(mc68000) || defined(is68k) || \ - defined(tahoe) || defined(ibm032) || defined(ibm370) || defined(MIPSEB) || \ - defined(__convex__) || defined(DGUX) || defined(hppa) || defined(apollo) || \ - defined(_CRAY) || defined(__hp9000) || defined(__hp9000s300) || defined(_AIX) || \ - defined(__AIX) || defined(__pyr__) || defined(hp9000s700) || defined(_IBMR2) || defined(__ARMEB__) +#if defined(HOST_ENDIAN_IS_BIG) # define BIG_ENDIAN -#elif defined(__i386__) || defined(i386) || defined(intel) || defined(_M_IX86) || \ - defined(__amd64) || defined(__amd64__) || \ - defined(__alpha__) || defined(__alpha) || defined(__ia64) || defined(__ia64__) || \ - defined(_M_ALPHA) || defined(ns32000) || defined(__ns32000__) || defined(sequent) || \ - defined(MIPSEL) || defined(_MIPSEL) || defined(sun386) || defined(__sun386__) || defined(__ARMEL__) +#elif defined(HOST_ENDIAN_IS_LITTLE) # define LITTLE_ENDIAN diff -Nru blobby-0.8-dfsg/src/RakNetPacket.h blobby-0.9c/src/RakNetPacket.h --- blobby-0.8-dfsg/src/RakNetPacket.h 1970-01-01 00:00:00.000000000 +0000 +++ blobby-0.9c/src/RakNetPacket.h 2011-11-06 15:06:46.000000000 +0000 @@ -0,0 +1,45 @@ +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + +#pragma once + +#include +#include "raknet/RakPeer.h" + +class Packet; + +typedef boost::shared_ptr packet_ptr; + +struct deleter{ + RakPeer* peer; + void operator()(Packet* p){ + peer->DeallocatePacket(p); + } +}; + +inline packet_ptr receivePacket(RakPeer* peer){ + deleter del; + del.peer = peer; + Packet* pptr = peer->Receive(); + if(pptr){ + return packet_ptr(pptr, del); + }else{ + return packet_ptr(); + } +} diff -Nru blobby-0.8-dfsg/src/RenderManager.cpp blobby-0.9c/src/RenderManager.cpp --- blobby-0.8-dfsg/src/RenderManager.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/RenderManager.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -20,6 +20,7 @@ #include "RenderManager.h" #include +#include RenderManager* RenderManager::mSingleton = 0; @@ -44,7 +45,7 @@ 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000); SDL_BlitSurface(surface, 0, newSurface, 0); SDL_SetAlpha(newSurface, SDL_SRCALPHA, surface->format->alpha); - SDL_SetColorKey(newSurface, SDL_SRCCOLORKEY, + SDL_SetColorKey(newSurface, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB(newSurface->format, 0, 0, 0)); SDL_LockSurface(newSurface); @@ -61,9 +62,11 @@ } } SDL_UnlockSurface(newSurface); + // no DisplayFormatAlpha, because of problems with + // OpenGL RenderManager SDL_Surface *convSurface = SDL_DisplayFormat(newSurface); SDL_FreeSurface(newSurface); - return convSurface; + return convSurface; } SDL_Surface* RenderManager::loadSurface(std::string filename) @@ -72,15 +75,30 @@ if (!fileHandle) throw FileLoadException(std::string(filename)); int fileLength = PHYSFS_fileLength(fileHandle); - PHYSFS_uint8* fileBuffer = - new PHYSFS_uint8[fileLength]; + PHYSFS_uint8* fileBuffer = new PHYSFS_uint8[fileLength]; + + // ensures that fileHandle and fileBuffer are freed at end of scope, + BOOST_SCOPE_EXIT( (&fileHandle)(&fileBuffer) ){ + PHYSFS_close(fileHandle); + delete[] fileBuffer; + } BOOST_SCOPE_EXIT_END + PHYSFS_read(fileHandle, fileBuffer, 1, fileLength); SDL_RWops* rwops = SDL_RWFromMem(fileBuffer, fileLength); SDL_Surface* newSurface = SDL_LoadBMP_RW(rwops , 1); if (!newSurface) throw FileLoadException(filename); - delete[] fileBuffer; - PHYSFS_close(fileHandle); + return newSurface; +} + + +SDL_Surface* RenderManager::createEmptySurface(unsigned int width, unsigned int height) +{ + SDL_Surface* newSurface = SDL_CreateRGBSurface( + SDL_SWSURFACE | SDL_SRCALPHA | SDL_SRCCOLORKEY, + width, height, 32, + 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000); + return newSurface; } diff -Nru blobby-0.8-dfsg/src/RenderManagerGL2D.cpp blobby-0.9c/src/RenderManagerGL2D.cpp --- blobby-0.8-dfsg/src/RenderManagerGL2D.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/RenderManagerGL2D.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -1,581 +1,735 @@ -/*============================================================================= -Blobby Volley 2 -Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -=============================================================================*/ - -#include "RenderManager.h" - -#include "RenderManagerGL2D.h" -#include - -#if HAVE_LIBGL - -int RenderManagerGL2D::getNextPOT(int npot) -{ - int pot = 1; - while (pot < npot) - pot *= 2; - return pot; -} - -GLuint RenderManagerGL2D::loadTexture(SDL_Surface *surface, - bool specular) -{ - SDL_Surface* textureSurface; - SDL_Surface* convertedTexture; - - textureSurface = surface; - - // Determine size of padding for 2^n format - int oldX = textureSurface->w; - int oldY = textureSurface->h; - int paddedX = getNextPOT(textureSurface->w); - int paddedY = getNextPOT(textureSurface->h); - - SDL_Rect targetRect; - targetRect.w = oldX; - targetRect.h = oldY; - targetRect.x = (paddedX - oldX) / 2; - targetRect.y = (paddedY - oldY) / 2; - - SDL_SetColorKey(textureSurface, SDL_SRCCOLORKEY, - SDL_MapRGB(textureSurface->format, 0, 0, 0)); - convertedTexture = - SDL_CreateRGBSurface(SDL_SWSURFACE, - paddedX, paddedY, 32, -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); -#else - 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); -#endif - SDL_BlitSurface(textureSurface, 0, convertedTexture, &targetRect); - - if (specular) - { - for (int y = 0; y < convertedTexture->h; ++y) - for (int x = 0; x < convertedTexture->w; ++x) - { - SDL_Color* pixel = - &(((SDL_Color*)convertedTexture->pixels) - [y * convertedTexture->w +x]); - int luminance = int(pixel->r) * 5 - 4 * 256 - 138; - luminance = luminance > 0 ? luminance : 0; - luminance = luminance < 255 ? luminance : 255; - pixel->r = luminance; - pixel->g = luminance; - pixel->b = luminance; - } - } - - GLuint texture; - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, - convertedTexture->w, convertedTexture->h, 0, GL_RGBA, - GL_UNSIGNED_BYTE, convertedTexture->pixels); - SDL_FreeSurface(textureSurface); - SDL_FreeSurface(convertedTexture); - - return texture; -} - -void RenderManagerGL2D::drawQuad(float x, float y) -{ - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); - glVertex2f(0.0 - x / 2.0, 0.0 - y / 2.0); - glTexCoord2f(1.0, 0.0); - glVertex2f(x / 2.0, 0.0 - y / 2.0); - glTexCoord2f(1.0, 1.0); - glVertex2f(x / 2.0, y / 2.0); - glTexCoord2f(0.0, 1.0); - glVertex2f(0.0 - x / 2.0, y / 2.0); - glEnd(); -} - -RenderManagerGL2D::RenderManagerGL2D() - : RenderManager() -{ -} - -RenderManager* RenderManager::createRenderManagerGL2D() -{ - return new RenderManagerGL2D(); -} - -void RenderManagerGL2D::init(int xResolution, int yResolution, bool fullscreen) -{ - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - - Uint32 screenFlags = SDL_OPENGL; - if (fullscreen) - screenFlags |= SDL_FULLSCREEN; - SDL_WM_SetCaption(AppTitle, ""); - SDL_WM_SetIcon(SDL_LoadBMP("data/Icon.bmp"), NULL); - SDL_SetVideoMode(xResolution, yResolution, 0, screenFlags); - SDL_ShowCursor(0); - glDisable(GL_MULTISAMPLE); - - mLeftBlobColor = Color(255, 0, 0); - mRightBlobColor = Color(0, 255, 0); - - SDL_Surface* bgSurface = loadSurface("backgrounds/strand2.bmp"); - BufferedImage* bgBufImage = new BufferedImage; - bgBufImage->w = getNextPOT(bgSurface->w); - bgBufImage->h = getNextPOT(bgSurface->h); - bgBufImage->glHandle = loadTexture(bgSurface, false); - mBackground = bgBufImage->glHandle; - mImageMap["background"] = bgBufImage; - - mBallShadow = loadTexture(loadSurface("gfx/schball.bmp"), false); - mScroll = loadTexture(loadSurface("gfx/scrollbar.bmp"), false); - - for (int i = 1; i <= 16; ++i) - { - char filename[64]; - sprintf(filename, "gfx/ball%02d.bmp", i); - GLuint ballImage = loadTexture(loadSurface(filename), false); - mBall.push_back(ballImage); - } - - for (int i = 1; i <= 5; ++i) - { - char filename[64]; - sprintf(filename, "gfx/blobbym%d.bmp", i); - GLuint blobImage = loadTexture(loadSurface(filename), false); - mBlob.push_back(blobImage); - sprintf(filename, "gfx/blobbym%d.bmp", i); - GLuint blobSpecular = loadTexture(loadSurface(filename), true); - mBlobSpecular.push_back(blobSpecular); - sprintf(filename, "gfx/sch1%d.bmp", i); - GLuint blobShadow = loadTexture(loadSurface(filename), false); - mBlobShadow.push_back(blobShadow); - } - - for (int i = 0; i <= 53; ++i) - { - char filename[64]; - sprintf(filename, "gfx/font%02d.bmp", i); - GLuint newFont = loadTexture(loadSurface(filename), false); - SDL_Surface* fontSurface = loadSurface(filename); - SDL_Surface* highlight = highlightSurface(fontSurface, 60); - SDL_FreeSurface(fontSurface); - - mHighlightFont.push_back(loadTexture(highlight, false)); - mFont.push_back(newFont); - } - - mParticle = loadTexture(loadSurface("gfx/blood.bmp"), false); - - glViewport(0, 0, xResolution, yResolution); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, 800, 600, 0, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - glClearDepth(1.0); - glDepthFunc(GL_LEQUAL); - glEnable(GL_DEPTH_TEST); -} - -void RenderManagerGL2D::deinit() -{ - glDeleteTextures(1, &mBackground); - glDeleteTextures(mBall.size(), &mBall[0]); - glDeleteTextures(1, &mBallShadow); - glDeleteTextures(mBlob.size(), &mBlob[0]); - glDeleteTextures(mBlobSpecular.size(), &mBlobSpecular[0]); - glDeleteTextures(mBlobShadow.size(), &mBlobShadow[0]); - glDeleteTextures(mFont.size(), &mFont[0]); - glDeleteTextures(1, &mScroll); - - for (std::map::iterator iter = mImageMap.begin(); - iter != mImageMap.end(); ++iter) - { - glDeleteTextures(1, &(*iter).second->glHandle); - delete iter->second; - } - - glDeleteTextures(1, &mParticle); -} - -void RenderManagerGL2D::draw() -{ - glClear(GL_DEPTH_BUFFER_BIT); - if (!mDrawGame) - return; - - // General object settings - glEnable(GL_TEXTURE_2D); - glAlphaFunc(GL_GREATER, 0.5); - glEnable(GL_ALPHA_TEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - // The Ball - - glColor4f(1.0, 1.0, 1.0, 1.0); - glBindTexture(GL_TEXTURE_2D, mBall[int(mBallRotation / M_PI / 2 * 16) % 16]); -/* - float opacity = 0.0; - for (std::list::iterator iter = mLastBallStates.begin(); - iter != mLastBallStates.end(); ++iter) - { -// glColor4f(1.0 / MotionBlurIterations, -// 1.0 / MotionBlurIterations, 1.0 / MotionBlurIterations, 1.0 - opacity); - glColor4f(1.0, 1.0, 1.0, opacity); - - - Vector2& ballPosition = *iter; -*/ - glLoadIdentity(); - glTranslatef(mBallPosition.x, mBallPosition.y, 0.5); - - drawQuad(64.0, 64.0); -/* - opacity += 0.1; - } - if (mLastBallStates.size() > MotionBlurIterations) - mLastBallStates.pop_back(); - glDisable(GL_BLEND); -*/ - - // left blob - glLoadIdentity(); - glTranslatef(mLeftBlobPosition.x, mLeftBlobPosition.y, 0.6); - glBindTexture(GL_TEXTURE_2D, mBlob[int(mLeftBlobAnimationState) % 5]); - glColor3ubv(mLeftBlobColor.val); - drawQuad(128.0, 128.0); - - glEnable(GL_BLEND); - glColor4f(1.0, 1.0, 1.0, 1.0); - glBindTexture(GL_TEXTURE_2D, mBlobSpecular[int(mLeftBlobAnimationState) % 5]); - drawQuad(128.0, 128.0); - glDisable(GL_BLEND); - - // right blob - glLoadIdentity(); - glTranslatef(mRightBlobPosition.x, mRightBlobPosition.y, 0.6); - glBindTexture(GL_TEXTURE_2D, mBlob[int(mRightBlobAnimationState) % 5]); - glColor3ubv(mRightBlobColor.val); - drawQuad(128.0, 128.0); - - glEnable(GL_BLEND); - glColor4f(1.0, 1.0, 1.0, 1.0); - glBindTexture(GL_TEXTURE_2D, mBlobSpecular[int(mRightBlobAnimationState) % 5]); - drawQuad(128.0, 128.0); - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - - - // Background - glEnable(GL_TEXTURE_2D); - glColor4f(1.0, 1.0, 1.0, 1.0); - glBindTexture(GL_TEXTURE_2D, mBackground); - glLoadIdentity(); - glTranslatef(400.0, 300.0, -0.5); - drawQuad(1024, 1024); - - // Secure rod - - glLoadIdentity(); - glTranslatef(0.0, 0.0, 1.0); - glColorMask(false, false, false, false); - glBegin(GL_QUADS); - glVertex2f(393.0, 300.0); - glVertex2f(407.0, 300.0); - glVertex2f(407.0, 600.0); - glVertex2f(393.0, 600.0); - glEnd(); - glColorMask(true, true, true, true); - - // Ball marker - - glDisable(GL_TEXTURE_2D); - GLubyte markerColor = SDL_GetTicks() % 1000 >= 500 ? 255 : 0; - glColor3ub(markerColor, markerColor, markerColor); - glLoadIdentity(); - glTranslatef(mBallPosition.x, 7.5, -0.4); - drawQuad(5.0, 5.0); - - // Mouse marker - - glLoadIdentity(); - glTranslatef(mMouseMarkerPosition, 592.5, -0.4); - drawQuad(5.0, 5.0); - - // Generic shadow settings - glEnable(GL_TEXTURE_2D); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - // Blob shadows - Vector2 pos; - - glLoadIdentity(); - pos = blobShadowPosition(mLeftBlobPosition); - glTranslatef(pos.x, pos.y, 0.2); - glColor4ub(mLeftBlobColor.r, mLeftBlobColor.g, mLeftBlobColor.b, 128); - glBindTexture(GL_TEXTURE_2D, mBlobShadow[int(mLeftBlobAnimationState) % 5]); - drawQuad(128.0, 32.0); - - glLoadIdentity(); - pos = blobShadowPosition(mRightBlobPosition); - glTranslatef(pos.x, pos.y, 0.2); - glColor4ub(mRightBlobColor.r, mRightBlobColor.g, mRightBlobColor.b, 128); - glBindTexture(GL_TEXTURE_2D, mBlobShadow[int(mRightBlobAnimationState) % 5]); - drawQuad(128.0, 32.0); - - // Ball shadow - glLoadIdentity(); - pos = ballShadowPosition(mBallPosition); - glTranslatef(pos.x, pos.y, 0.2); - glColor4f(1.0, 1.0, 1.0, 0.5); - glBindTexture(GL_TEXTURE_2D, mBallShadow); - drawQuad(128.0, 32.0); - - glDisable(GL_BLEND); - - // Scores - char textBuffer[64]; - snprintf(textBuffer, 8, mLeftPlayerWarning ? "%02d!" : "%02d", - mLeftPlayerScore); - drawText(textBuffer, Vector2(24, 24), false); - snprintf(textBuffer, 8, mRightPlayerWarning ? "%02d!" : "%02d", - mRightPlayerScore); - drawText(textBuffer, Vector2(728, 24), false); - - // Drawing the names - drawText(mLeftPlayerName, Vector2(12, 550), false); - - drawText(mRightPlayerName, Vector2(788-(24*mRightPlayerName.length()), 550), false); -} - -bool RenderManagerGL2D::setBackground(const std::string& filename) -{ - try - { - SDL_Surface* newSurface = loadSurface(filename); - glDeleteTextures(1, &mBackground); - delete mImageMap["background"]; - BufferedImage *imgBuffer = new BufferedImage; - imgBuffer->w = getNextPOT(newSurface->w); - imgBuffer->h = getNextPOT(newSurface->h); - imgBuffer->glHandle = loadTexture(newSurface, false); - mBackground = imgBuffer->glHandle; - mImageMap["background"] = imgBuffer; - } - catch (FileLoadException) - { - return false; - } - return true; -} - -void RenderManagerGL2D::setBlobColor(int player, Color color) -{ - if (player == LEFT_PLAYER) - mLeftBlobColor = color; - if (player == RIGHT_PLAYER) - mRightBlobColor = color; -} - -void RenderManagerGL2D::setBall(const Vector2& position, float rotation) -{ - mBallPosition = position; - mBallRotation = rotation; - - static int mbCounter = 0; - mbCounter++; - if (mbCounter > 1) - { - mLastBallStates.push_front(position); - mbCounter = 0; - } -} - -void RenderManagerGL2D::setBlob(int player, - const Vector2& position, float animationState) -{ - if (player == LEFT_PLAYER) - { - mLeftBlobPosition = position; - mLeftBlobAnimationState = animationState; - } - - if (player == RIGHT_PLAYER) - { - mRightBlobPosition = position; - mRightBlobAnimationState = animationState; - } -} - -void RenderManagerGL2D::setScore(int leftScore, int rightScore, - bool leftWarning, bool rightWarning) -{ - mLeftPlayerScore = leftScore; - mRightPlayerScore = rightScore; - mLeftPlayerWarning = leftWarning; - mRightPlayerWarning = rightWarning; -} - -void RenderManagerGL2D::setPlayernames(std::string leftName, std::string rightName) -{ - mLeftPlayerName = leftName; - mRightPlayerName = rightName; -} - -void RenderManagerGL2D::drawText(const std::string& text, Vector2 position, bool highlight) -{ - glColor4f(1.0, 1.0, 1.0, 1.0); - glEnable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); - glAlphaFunc(GL_GREATER, 0.5); - glEnable(GL_ALPHA_TEST); - int length = 0; - std::string string = text; - int index = getNextFontIndex(string); - while (index != -1) - { - glLoadIdentity(); - glTranslatef(position.x + length + 12.0, - position.y + 12.0, 0.0); - if (highlight) - glBindTexture(GL_TEXTURE_2D, mHighlightFont[index]); - else - glBindTexture(GL_TEXTURE_2D, mFont[index]); - drawQuad(32.0, 32.0); - index = getNextFontIndex(string); - length += 24; - } - glDisable(GL_ALPHA_TEST); - glEnable(GL_DEPTH_TEST); - glDisable(GL_TEXTURE_2D); -} - -void RenderManagerGL2D::drawImage(const std::string& filename, Vector2 position) -{ - BufferedImage* imageBuffer = mImageMap[filename]; - if (!imageBuffer) - { - imageBuffer = new BufferedImage; - SDL_Surface* newSurface = loadSurface(filename); - imageBuffer->w = getNextPOT(newSurface->w); - imageBuffer->h = getNextPOT(newSurface->h); - imageBuffer->glHandle = loadTexture(newSurface, false); - mImageMap[filename] = imageBuffer; - } - glColor4f(1.0, 1.0, 1.0, 1.0); - glEnable(GL_TEXTURE_2D); - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glAlphaFunc(GL_GREATER, 0.5); - glEnable(GL_ALPHA_TEST); - glLoadIdentity(); - glTranslatef(position.x , position.y, 0.0); - glBindTexture(GL_TEXTURE_2D, imageBuffer->glHandle); - drawQuad(imageBuffer->w, imageBuffer->h); - - glDisable(GL_ALPHA_TEST); - glEnable(GL_DEPTH_TEST); - glDisable(GL_TEXTURE_2D); -} -void RenderManagerGL2D::drawOverlay(float opacity, Vector2 pos1, Vector2 pos2, Color col) -{ - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); - glEnable(GL_BLEND); - - glColor4f(col.r, col.g, col.b, opacity); - glLoadIdentity(); - glBegin(GL_QUADS); - glVertex2f(pos1.x, pos1.y); - glVertex2f(pos1.x, pos2.y); - glVertex2f(pos2.x, pos2.y); - glVertex2f(pos2.x, pos1.y); - glEnd(); - glDisable(GL_BLEND); - glEnable(GL_DEPTH_TEST); -} - -void RenderManagerGL2D::drawBlob(const Vector2& pos, const Color& col) -{ - glEnable(GL_TEXTURE_2D); - glAlphaFunc(GL_GREATER, 0.5); - glEnable(GL_ALPHA_TEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - glLoadIdentity(); - glTranslatef(pos.x, pos.y, 0.6); - glBindTexture(GL_TEXTURE_2D, mBlob[0]); - glColor3ubv(col.val); - drawQuad(128.0, 128.0); - - glEnable(GL_BLEND); - glColor4f(1.0, 1.0, 1.0, 1.0); - glBindTexture(GL_TEXTURE_2D, mBlobSpecular[0]); - drawQuad(128.0, 128.0); - glDisable(GL_BLEND); - - glDisable(GL_ALPHA_TEST); - glDisable(GL_TEXTURE_2D); -} - -void RenderManagerGL2D::drawParticle(const Vector2& pos, int player) -{ - glEnable(GL_TEXTURE_2D); - glAlphaFunc(GL_GREATER, 0.5); - glEnable(GL_ALPHA_TEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - glLoadIdentity(); - glTranslatef(pos.x, pos.y, 0.6); - glBindTexture(GL_TEXTURE_2D, mParticle); - if (player == LEFT_PLAYER) - glColor3ubv(mLeftBlobColor.val); - if (player == RIGHT_PLAYER) - glColor3ubv(mRightBlobColor.val); - if (player > 1) - glColor3ubv(Color(255, 0, 0).val); - drawQuad(9.0, 9.0); - - glDisable(GL_ALPHA_TEST); - glDisable(GL_TEXTURE_2D); -} - -void RenderManagerGL2D::refresh() -{ - SDL_GL_SwapBuffers(); -} - -#else - -RenderManager* RenderManager::createRenderManagerGL2D() -{ - std::cerr << "OpenGL not available! Falling back to SDL renderer" << - std::endl; - return RenderManager::createRenderManagerSDL(); -} - - -#endif +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + +#include "RenderManager.h" + +#include "RenderManagerGL2D.h" +#include + +#if HAVE_LIBGL + +RenderManagerGL2D::Texture::Texture( GLuint tex, int x, int y, int width, int height, int tw, int th ) : w(width), h(height), texture(tex) +{ + assert(x + w <= tw); + assert(y + h <= th); + indices[0] = x / (float)tw; + indices[1] = y / (float)th; + indices[2] = (x + w) / (float)tw; + indices[3] = y / (float)th; + indices[4] = (x + w) / (float)tw; + indices[5] = (y + h) / (float)th; + indices[6] = x / (float)tw; + indices[7] = (y + h) / (float)th; +} +int debugStateChanges = 0; +int debugBindTextureCount = 0; + +// wrapper functions for debugging purposes +void RenderManagerGL2D::glEnable(unsigned int flag) +{ + if(mCurrentFlags.find(flag) != mCurrentFlags.end()) + return; + + debugStateChanges++; + ::glEnable(flag); + mCurrentFlags.insert(flag); +} + +void RenderManagerGL2D::glDisable(unsigned int flag) +{ + if( mCurrentFlags.find(flag) == mCurrentFlags.end() ) + return; + + debugStateChanges++; + ::glDisable(flag); + mCurrentFlags.erase( mCurrentFlags.find(flag) ); +} + +void RenderManagerGL2D::glBindTexture(GLuint texture) +{ + if(mCurrentTexture == texture) + return; + debugBindTextureCount++; + ::glBindTexture(GL_TEXTURE_2D, texture); + mCurrentTexture = texture; +} + + + +int RenderManagerGL2D::getNextPOT(int npot) +{ + int pot = 1; + while (pot < npot) + pot *= 2; + return pot; +} + +GLuint RenderManagerGL2D::loadTexture(SDL_Surface *surface, + bool specular) +{ + SDL_Surface* textureSurface; + SDL_Surface* convertedTexture; + + textureSurface = surface; + + // Determine size of padding for 2^n format + int oldX = textureSurface->w; + int oldY = textureSurface->h; + int paddedX = getNextPOT(textureSurface->w); + int paddedY = getNextPOT(textureSurface->h); + + SDL_Rect targetRect; + targetRect.w = oldX; + targetRect.h = oldY; + targetRect.x = (paddedX - oldX) / 2; + targetRect.y = (paddedY - oldY) / 2; + + SDL_SetColorKey(textureSurface, SDL_SRCCOLORKEY, + SDL_MapRGB(textureSurface->format, 0, 0, 0)); + convertedTexture = + SDL_CreateRGBSurface(SDL_SWSURFACE, + paddedX, paddedY, 32, +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); +#else + 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); +#endif + SDL_BlitSurface(textureSurface, 0, convertedTexture, &targetRect); + + if (specular) + { + for (int y = 0; y < convertedTexture->h; ++y) + for (int x = 0; x < convertedTexture->w; ++x) + { + SDL_Color* pixel = + &(((SDL_Color*)convertedTexture->pixels) + [y * convertedTexture->w +x]); + int luminance = int(pixel->r) * 5 - 4 * 256 - 138; + luminance = luminance > 0 ? luminance : 0; + luminance = luminance < 255 ? luminance : 255; + pixel->r = luminance; + pixel->g = luminance; + pixel->b = luminance; + } + } + + GLuint texture; + glGenTextures(1, &texture); + glBindTexture(texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, + convertedTexture->w, convertedTexture->h, 0, GL_RGBA, + GL_UNSIGNED_BYTE, convertedTexture->pixels); + SDL_FreeSurface(textureSurface); + SDL_FreeSurface(convertedTexture); + + return texture; +} + +void RenderManagerGL2D::drawQuad(float x, float y) +{ + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); + glVertex2f(0.0 - x / 2.0, 0.0 - y / 2.0); + glTexCoord2f(1.0, 0.0); + glVertex2f(x / 2.0, 0.0 - y / 2.0); + glTexCoord2f(1.0, 1.0); + glVertex2f(x / 2.0, y / 2.0); + glTexCoord2f(0.0, 1.0); + glVertex2f(0.0 - x / 2.0, y / 2.0); + glEnd(); +} + +void RenderManagerGL2D::drawQuad2(float x, float y, float w, float h) +{ + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); + glVertex2f(x - w / 2.0, y - h / 2.0); + glTexCoord2f(1.0, 0.0); + glVertex2f(x + w / 2.0, y - h / 2.0); + glTexCoord2f(1.0, 1.0); + glVertex2f(x + w / 2.0, y + h / 2.0); + glTexCoord2f(0.0, 1.0); + glVertex2f(x - w / 2.0, y + h / 2.0); + glEnd(); +} + +void RenderManagerGL2D::drawQuad(float x, float y, const Texture& tex) { + glColor4f(1.0, 1.0, 1.0, 1.0); + glBindTexture(tex.texture); + + float w = tex.w; + float h = tex.h; + glBegin(GL_QUADS); + glTexCoord2f(tex.indices[0], tex.indices[1]); + glVertex2f(x - w / 2.0, y - h / 2.0); + glTexCoord2f(tex.indices[2], tex.indices[3]); + glVertex2f(x + w / 2.0, y - h / 2.0); + glTexCoord2f(tex.indices[4], tex.indices[5]); + glVertex2f(x + w / 2.0, y + h / 2.0); + glTexCoord2f(tex.indices[6], tex.indices[7]); + glVertex2f(x - w / 2.0, y + h / 2.0); + glEnd(); +} + +RenderManagerGL2D::RenderManagerGL2D() + : RenderManager() +{ +} + +RenderManager* RenderManager::createRenderManagerGL2D() +{ + return new RenderManagerGL2D(); +} + +void RenderManagerGL2D::init(int xResolution, int yResolution, bool fullscreen) +{ + mCurrentFlags.insert(GL_DEPTH_TEST); + mCurrentFlags.insert(GL_MULTISAMPLE); + + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + + Uint32 screenFlags = SDL_OPENGL; + if (fullscreen) + screenFlags |= SDL_FULLSCREEN; + SDL_WM_SetCaption(AppTitle, ""); + SDL_WM_SetIcon(SDL_LoadBMP("data/Icon.bmp"), NULL); + SDL_SetVideoMode(xResolution, yResolution, 0, screenFlags); + SDL_ShowCursor(0); + glDisable(GL_MULTISAMPLE); + + mLeftBlobColor = Color(255, 0, 0); + mRightBlobColor = Color(0, 255, 0); + + SDL_Surface* bgSurface = loadSurface("backgrounds/strand2.bmp"); + BufferedImage* bgBufImage = new BufferedImage; + bgBufImage->w = getNextPOT(bgSurface->w); + bgBufImage->h = getNextPOT(bgSurface->h); + bgBufImage->glHandle = loadTexture(bgSurface, false); + mBackground = bgBufImage->glHandle; + mImageMap["background"] = bgBufImage; + + mBallShadow = loadTexture(loadSurface("gfx/schball.bmp"), false); + mScroll = loadTexture(loadSurface("gfx/scrollbar.bmp"), false); + + for (int i = 1; i <= 16; ++i) + { + char filename[64]; + sprintf(filename, "gfx/ball%02d.bmp", i); + GLuint ballImage = loadTexture(loadSurface(filename), false); + mBall.push_back(ballImage); + } + + for (int i = 1; i <= 5; ++i) + { + char filename[64]; + sprintf(filename, "gfx/blobbym%d.bmp", i); + GLuint blobImage = loadTexture(loadSurface(filename), false); + mBlob.push_back(blobImage); + sprintf(filename, "gfx/blobbym%d.bmp", i); + GLuint blobSpecular = loadTexture(loadSurface(filename), true); + mBlobSpecular.push_back(blobSpecular); + sprintf(filename, "gfx/sch1%d.bmp", i); + GLuint blobShadow = loadTexture(loadSurface(filename), false); + mBlobShadow.push_back(blobShadow); + } + + // create text base textures + SDL_Surface* textbase = createEmptySurface(2048, 32); + SDL_Surface* hltextbase = createEmptySurface(2048, 32); + SDL_Surface* smalltextbase = createEmptySurface(1024, 16); + SDL_Surface* hlsmalltextbase = createEmptySurface(1024, 16); + int x = 0; + int sx = 0; + + for (int i = 0; i <= 53; ++i) + { + char filename[64], filename2[64]; + sprintf(filename, "gfx/font%02d.bmp", i); + sprintf(filename2, "gfx/font_small/font%02d.bmp", i); + SDL_Surface* fontSurface = loadSurface(filename); + SDL_Surface* fontSurface2 = loadSurface(filename2); + + GLuint newFont = loadTexture(loadSurface(filename), false); + GLuint newFont2 = loadTexture(loadSurface(filename2), false); + SDL_Surface* highlight = highlightSurface(fontSurface, 60); + SDL_Surface* highlight2 = highlightSurface(fontSurface2, 60); + SDL_FreeSurface(fontSurface); + SDL_FreeSurface(fontSurface2); + + fontSurface = loadSurface(filename); + fontSurface2 = loadSurface(filename2); + + SDL_Rect r = {x, 0, fontSurface->w, fontSurface->h}; + SDL_BlitSurface(fontSurface, 0, textbase, &r); + SDL_BlitSurface(highlight, 0, hltextbase, &r); + r = {sx, 0, fontSurface2->w, fontSurface2->h}; + SDL_BlitSurface(fontSurface2, 0, smalltextbase, &r); + SDL_BlitSurface(highlight2, 0, hlsmalltextbase, &r); + //GLuint ballImage = loadTexture(sf, false); + //mBall.push_back(ballImage); + Texture s = Texture(0, x, 0, fontSurface->w, fontSurface->h, 2048, 32); + mFont.push_back(s); + mHighlightFont.push_back(s); + + s = Texture(0, sx, 0, fontSurface2->w, fontSurface2->h, 1024, 16); + + //mFont.push_back(newFont); + //mHighlightFont.push_back(loadTexture(highlight, false)); + mSmallFont.push_back( s ); + mHighlightSmallFont.push_back( s ); + + x += fontSurface->w; + sx += fontSurface2->w; + + SDL_FreeSurface(fontSurface); + SDL_FreeSurface(fontSurface2); + } + + GLuint texture = loadTexture(textbase, false); + GLuint hltexture = loadTexture(hltextbase, false); + GLuint smalltexture = loadTexture(smalltextbase, false); + GLuint hlsmalltexture = loadTexture(hlsmalltextbase, false); + for (int i = 0; i < mFont.size(); ++i) + { + mFont[i].texture = texture; + mHighlightFont[i].texture = hltexture; + mSmallFont[i].texture = smalltexture; + mHighlightSmallFont[i].texture = hlsmalltexture; + } + + mParticle = loadTexture(loadSurface("gfx/blood.bmp"), false); + + glViewport(0, 0, xResolution, yResolution); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, 800, 600, 0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glClearDepth(1.0); + glDepthFunc(GL_LEQUAL); + glDisable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); + + glAlphaFunc(GL_GREATER, 0.5); + glEnable(GL_ALPHA_TEST); +} + +void RenderManagerGL2D::deinit() +{ + glDeleteTextures(1, &mBackground); + glDeleteTextures(mBall.size(), &mBall[0]); + glDeleteTextures(1, &mBallShadow); + glDeleteTextures(mBlob.size(), &mBlob[0]); + glDeleteTextures(mBlobSpecular.size(), &mBlobSpecular[0]); + glDeleteTextures(mBlobShadow.size(), &mBlobShadow[0]); + glDeleteTextures(1/*mFont.size()*/, &mFont[0].texture); + glDeleteTextures(/*mHighlightFont.size()*/1, &mHighlightFont[0].texture); + glDeleteTextures(/*mSmallFont.size()*/1, &mSmallFont[0].texture); + glDeleteTextures(/*mHighlightSmallFont.size()*/1, &mHighlightSmallFont[0].texture); + glDeleteTextures(1, &mScroll); + + for (std::map::iterator iter = mImageMap.begin(); + iter != mImageMap.end(); ++iter) + { + glDeleteTextures(1, &(*iter).second->glHandle); + delete iter->second; + } + + glDeleteTextures(1, &mParticle); +} + +void RenderManagerGL2D::draw() +{ + glClear(GL_DEPTH_BUFFER_BIT); + if (!mDrawGame) + return; + + // Background + glDisable(GL_ALPHA_TEST); + glColor4f(1.0, 1.0, 1.0, 1.0); + glBindTexture(mBackground); + glLoadIdentity(); + drawQuad2(400.0, 300.0, 1024.0, 1024.0); + + + if(mShowShadow) + { + // Generic shadow settings + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + // Blob shadows + Vector2 pos; + + pos = blobShadowPosition(mLeftBlobPosition); + glColor4ub(mLeftBlobColor.r, mLeftBlobColor.g, mLeftBlobColor.b, 128); + glBindTexture(mBlobShadow[int(mLeftBlobAnimationState) % 5]); + drawQuad2(pos.x, pos.y, 128.0, 32.0); + + pos = blobShadowPosition(mRightBlobPosition); + glColor4ub(mRightBlobColor.r, mRightBlobColor.g, mRightBlobColor.b, 128); + glBindTexture(mBlobShadow[int(mRightBlobAnimationState) % 5]); + drawQuad2(pos.x, pos.y, 128.0, 32.0); + + // Ball shadow + pos = ballShadowPosition(mBallPosition); + glColor4f(1.0, 1.0, 1.0, 0.5); + glBindTexture(mBallShadow); + drawQuad2(pos.x, pos.y, 128.0, 32.0); + + glDisable(GL_BLEND); + } + + glEnable(GL_ALPHA_TEST); + + // General object settings + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + // The Ball + + glColor4f(1.0, 1.0, 1.0, 1.0); + glBindTexture(mBall[int(mBallRotation / M_PI / 2 * 16) % 16]); +/* + float opacity = 0.0; + for (std::list::iterator iter = mLastBallStates.begin(); + iter != mLastBallStates.end(); ++iter) + { +// glColor4f(1.0 / MotionBlurIterations, +// 1.0 / MotionBlurIterations, 1.0 / MotionBlurIterations, 1.0 - opacity); + glColor4f(1.0, 1.0, 1.0, opacity); + + + Vector2& ballPosition = *iter; +*/ + drawQuad2(mBallPosition.x, mBallPosition.y, 64.0, 64.0); + +/* + opacity += 0.1; + } + if (mLastBallStates.size() > MotionBlurIterations) + mLastBallStates.pop_back(); + glDisable(GL_BLEND); +*/ + + // blob normal + // left blob + glBindTexture(mBlob[int(mLeftBlobAnimationState) % 5]); + glColor3ubv(mLeftBlobColor.val); + drawQuad2(mLeftBlobPosition.x, mLeftBlobPosition.y, 128.0, 128.0); + + // right blob + glBindTexture(mBlob[int(mRightBlobAnimationState) % 5]); + glColor3ubv(mRightBlobColor.val); + drawQuad2(mRightBlobPosition.x, mRightBlobPosition.y, 128.0, 128.0); + + // blob specular + glEnable(GL_BLEND); + glColor4f(1.0, 1.0, 1.0, 1.0); + // left blob + glBindTexture(mBlobSpecular[int(mLeftBlobAnimationState) % 5]); + drawQuad2(mLeftBlobPosition.x, mLeftBlobPosition.y, 128.0, 128.0); + + // right blob + glBindTexture(mBlobSpecular[int(mRightBlobAnimationState) % 5]); + drawQuad2(mRightBlobPosition.x, mRightBlobPosition.y, 128.0, 128.0); + + glDisable(GL_BLEND); + + + // Ball marker + glDisable(GL_ALPHA_TEST); + glDisable(GL_TEXTURE_2D); + GLubyte markerColor = SDL_GetTicks() % 1000 >= 500 ? 255 : 0; + glColor3ub(markerColor, markerColor, markerColor); + drawQuad2(mBallPosition.x, 7.5, 5.0, 5.0); + + // Mouse marker + + // Position relativ zu BallMarker + drawQuad2(mMouseMarkerPosition, 592.5, 5.0, 5.0); + + glEnable(GL_TEXTURE_2D); + glEnable(GL_ALPHA_TEST); + + // Scores + char textBuffer[64]; + snprintf(textBuffer, 8, mLeftPlayerWarning ? "%02d!" : "%02d", + mLeftPlayerScore); + drawText(textBuffer, Vector2(24, 24), false); + snprintf(textBuffer, 8, mRightPlayerWarning ? "%02d!" : "%02d", + mRightPlayerScore); + drawText(textBuffer, Vector2(728, 24), false); + + // Drawing the names + drawText(mLeftPlayerName, Vector2(12, 550), false); + + drawText(mRightPlayerName, Vector2(788-(24*mRightPlayerName.length()), 550), false); + + // Drawing the clock + drawText(mTime, Vector2(400 - mTime.length()*12, 24), false); +} + +bool RenderManagerGL2D::setBackground(const std::string& filename) +{ + try + { + SDL_Surface* newSurface = loadSurface(filename); + glDeleteTextures(1, &mBackground); + delete mImageMap["background"]; + BufferedImage *imgBuffer = new BufferedImage; + imgBuffer->w = getNextPOT(newSurface->w); + imgBuffer->h = getNextPOT(newSurface->h); + imgBuffer->glHandle = loadTexture(newSurface, false); + mBackground = imgBuffer->glHandle; + mImageMap["background"] = imgBuffer; + } + catch (FileLoadException) + { + return false; + } + return true; +} + +void RenderManagerGL2D::setBlobColor(int player, Color color) +{ + if (player == LEFT_PLAYER) + mLeftBlobColor = color; + if (player == RIGHT_PLAYER) + mRightBlobColor = color; +} + +void RenderManagerGL2D::showShadow(bool shadow) +{ + mShowShadow = shadow; +} + +void RenderManagerGL2D::setBall(const Vector2& position, float rotation) +{ + mBallPosition = position; + mBallRotation = rotation; + + static int mbCounter = 0; + mbCounter++; + if (mbCounter > 1) + { + mLastBallStates.push_front(position); + mbCounter = 0; + } +} + +void RenderManagerGL2D::setBlob(int player, + const Vector2& position, float animationState) +{ + if (player == LEFT_PLAYER) + { + mLeftBlobPosition = position; + mLeftBlobAnimationState = animationState; + } + + if (player == RIGHT_PLAYER) + { + mRightBlobPosition = position; + mRightBlobAnimationState = animationState; + } +} + +void RenderManagerGL2D::setScore(int leftScore, int rightScore, + bool leftWarning, bool rightWarning) +{ + mLeftPlayerScore = leftScore; + mRightPlayerScore = rightScore; + mLeftPlayerWarning = leftWarning; + mRightPlayerWarning = rightWarning; +} + +void RenderManagerGL2D::setPlayernames(std::string leftName, std::string rightName) +{ + mLeftPlayerName = leftName; + mRightPlayerName = rightName; +} + +void RenderManagerGL2D::setTime(const std::string& t) +{ + mTime = t; +} + +void RenderManagerGL2D::drawText(const std::string& text, Vector2 position, unsigned int flags) +{ + glEnable(GL_TEXTURE_2D); + glEnable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + + glColor4f(1.0, 1.0, 1.0, 1.0); + int FontSize = (flags & TF_SMALL_FONT ? FONT_WIDTH_SMALL : FONT_WIDTH_NORMAL); + std::string string = text; + int index = getNextFontIndex(string); + + float x = position.x - (FontSize / 2); + float y = position.y + (FontSize / 2); + while (index != -1) + { + if (flags & TF_OBFUSCATE) + index = FONT_INDEX_ASTERISK; + + x += FontSize; + if (flags & TF_SMALL_FONT) + if (flags & TF_HIGHLIGHT) + drawQuad(x, y, mHighlightSmallFont[index]); + else + drawQuad(x, y, mSmallFont[index]); + else + if (flags & TF_HIGHLIGHT) + drawQuad(x, y, mHighlightFont[index]); + else + drawQuad(x, y, mFont[index]); + + index = getNextFontIndex(string); + } +} + +void RenderManagerGL2D::drawImage(const std::string& filename, Vector2 position) +{ + glEnable(GL_TEXTURE_2D); + glEnable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + + BufferedImage* imageBuffer = mImageMap[filename]; + if (!imageBuffer) + { + imageBuffer = new BufferedImage; + SDL_Surface* newSurface = loadSurface(filename); + imageBuffer->w = getNextPOT(newSurface->w); + imageBuffer->h = getNextPOT(newSurface->h); + imageBuffer->glHandle = loadTexture(newSurface, false); + mImageMap[filename] = imageBuffer; + } + glColor4f(1.0, 1.0, 1.0, 1.0); + glDisable(GL_BLEND); + //glLoadIdentity(); + //glTranslatef(position.x , position.y, 0.0); + glBindTexture(imageBuffer->glHandle); + drawQuad2(position.x, position.y, imageBuffer->w, imageBuffer->h); +} + +void RenderManagerGL2D::drawOverlay(float opacity, Vector2 pos1, Vector2 pos2, Color col) +{ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_TEXTURE_2D); + glDisable(GL_ALPHA_TEST); + glEnable(GL_BLEND); + + glColor4f(col.r, col.g, col.b, opacity); + //glLoadIdentity(); + glBegin(GL_QUADS); + glVertex2f(pos1.x, pos1.y); + glVertex2f(pos1.x, pos2.y); + glVertex2f(pos2.x, pos2.y); + glVertex2f(pos2.x, pos1.y); + glEnd(); +} + +void RenderManagerGL2D::drawBlob(const Vector2& pos, const Color& col) +{ + glEnable(GL_TEXTURE_2D); + glEnable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + + //glLoadIdentity(); + //glTranslatef(pos.x, pos.y, 0.6); + glBindTexture(mBlob[0]); + glColor3ubv(col.val); + drawQuad2(pos.x, pos.y, 128.0, 128.0); + + glEnable(GL_BLEND); + glColor4f(1.0, 1.0, 1.0, 1.0); + glBindTexture(mBlobSpecular[0]); + drawQuad2(pos.x, pos.y, 128.0, 128.0); + glDisable(GL_BLEND); +} + +void RenderManagerGL2D::startDrawParticles() +{ + glEnable(GL_TEXTURE_2D); + glEnable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glBindTexture(mParticle); + glBegin(GL_QUADS); +} + +void RenderManagerGL2D::drawParticle(const Vector2& pos, int player) +{ + //glLoadIdentity(); + //glTranslatef(pos.x, pos.y, 0.6); + + if (player == LEFT_PLAYER) + glColor3ubv(mLeftBlobColor.val); + if (player == RIGHT_PLAYER) + glColor3ubv(mRightBlobColor.val); + if (player > 1) + glColor3ubv(Color(255, 0, 0).val); + + float w = 9.0; + float h = 9.0; + glTexCoord2f(0.0, 0.0); + glVertex2f(pos.x - w / 2.0, pos.y - h / 2.0); + glTexCoord2f(1.0, 0.0); + glVertex2f(pos.x + w / 2.0, pos.y - h / 2.0); + glTexCoord2f(1.0, 1.0); + glVertex2f(pos.x + w / 2.0, pos.y + h / 2.0); + glTexCoord2f(0.0, 1.0); + glVertex2f(pos.x - w / 2.0, pos.y + h / 2.0); +} + +void RenderManagerGL2D::endDrawParticles() +{ + glEnd(); +} + +void RenderManagerGL2D::refresh() +{ + //std::cout << debugStateChanges << "\n"; + SDL_GL_SwapBuffers(); + debugStateChanges = 0; + //std::cerr << debugBindTextureCount << "\n"; + debugBindTextureCount = 0; + +} + +#else + +RenderManager* RenderManager::createRenderManagerGL2D() +{ + std::cerr << "OpenGL not available! Falling back to SDL renderer" << + std::endl; + return RenderManager::createRenderManagerSDL(); +} + + +#endif diff -Nru blobby-0.8-dfsg/src/RenderManagerGL2D.h blobby-0.9c/src/RenderManagerGL2D.h --- blobby-0.8-dfsg/src/RenderManagerGL2D.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/RenderManagerGL2D.h 2011-11-06 15:06:46.000000000 +0000 @@ -38,12 +38,23 @@ #include #include +#include #include "RenderManager.h" class RenderManagerGL2D : public RenderManager { private: + + struct Texture + { + float indices[8]; + float w, h ; + GLuint texture; + + Texture( GLuint tex, int x, int y, int w, int h, int tw, int th ); + }; + GLuint mBackground; GLuint mBallShadow; @@ -51,8 +62,10 @@ std::vector mBlob; std::vector mBlobSpecular; std::vector mBlobShadow; - std::vector mFont; - std::vector mHighlightFont; + std::vector mFont; + std::vector mHighlightFont; + std::vector mSmallFont; + std::vector mHighlightSmallFont; GLuint mParticle; GLuint mScroll; @@ -65,6 +78,8 @@ Vector2 mRightBlobPosition; float mRightBlobAnimationState; + bool mShowShadow; + int mLeftPlayerScore; int mRightPlayerScore; bool mLeftPlayerWarning; @@ -72,13 +87,23 @@ std::string mLeftPlayerName; std::string mRightPlayerName; + std::string mTime; Color mLeftBlobColor; Color mRightBlobColor; void drawQuad(float x, float y); + void drawQuad2(float x, float y, float width, float height); + void drawQuad(float x, float y, const Texture& tex); GLuint loadTexture(SDL_Surface* surface, bool specular); int getNextPOT(int npot); + + void glEnable(unsigned int flag); + void glDisable(unsigned int flag); + void glBindTexture(GLuint texture); + + GLuint mCurrentTexture; + std::set mCurrentFlags; public: RenderManagerGL2D(); @@ -89,6 +114,7 @@ virtual bool setBackground(const std::string& filename); virtual void setBlobColor(int player, Color color); + virtual void showShadow(bool shadow); virtual void setBall(const Vector2& position, float rotation); virtual void setBlob(int player, const Vector2& position, @@ -98,12 +124,15 @@ bool leftWarning, bool rightWarning); virtual void setPlayernames(std::string leftName, std::string rightName); + virtual void setTime(const std::string& t); - virtual void drawText(const std::string& text, Vector2 position, bool highlight); + virtual void drawText(const std::string& text, Vector2 position, unsigned int flags = TF_NORMAL); virtual void drawImage(const std::string& filename, Vector2 position); virtual void drawOverlay(float opacity, Vector2 pos1, Vector2 pos2, Color col); virtual void drawBlob(const Vector2& pos, const Color& col); + virtual void startDrawParticles(); virtual void drawParticle(const Vector2& pos, int player); + virtual void endDrawParticles(); }; diff -Nru blobby-0.8-dfsg/src/RenderManagerGP2X.cpp blobby-0.9c/src/RenderManagerGP2X.cpp --- blobby-0.8-dfsg/src/RenderManagerGP2X.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/RenderManagerGP2X.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -17,7 +17,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =============================================================================*/ -#include #include #include "RenderManagerGP2X.h" @@ -124,17 +123,25 @@ } - for (int i = 0; i <= 52; ++i) + for (int i = 0; i <= 53; ++i) { - char filename[64]; + char filename[64], filename2[64]; sprintf(filename, "gf2x/font%02d.bmp", i); + sprintf(filename2, "gf2x/font_small/font%02d.bmp", i); SDL_Surface *tempFont = loadSurface(filename); + SDL_Surface *tempFont2 = loadSurface(filename2); SDL_SetColorKey(tempFont, SDL_SRCCOLORKEY, SDL_MapRGB(tempFont->format, 0, 0, 0)); + SDL_SetColorKey(tempFont2, SDL_SRCCOLORKEY, + SDL_MapRGB(tempFont2->format, 0, 0, 0)); SDL_Surface *newFont = SDL_DisplayFormat(tempFont); + SDL_Surface *newFont2 = SDL_DisplayFormat(tempFont2); SDL_FreeSurface(tempFont); + SDL_FreeSurface(tempFont2); mFont.push_back(newFont); mHighlightFont.push_back(highlightSurface(newFont, 60)); + mSmallFont.push_back(newFont2); + mHighlightSmallFont.push_back(highlightSurface(newFont2, 60)); } } @@ -155,7 +162,12 @@ } for (unsigned int i = 0; i < mFont.size(); ++i) + { SDL_FreeSurface(mFont[i]); + SDL_FreeSurface(mHighlightFont[i]); + SDL_FreeSurface(mSmallFont[i]); + SDL_FreeSurface(mHighlightSmallFont[i]); + } } void RenderManagerGP2X::draw() @@ -240,6 +252,9 @@ drawText(mLeftPlayerName, Vector2(12, 550), false); drawText(mRightPlayerName, Vector2(788-(24*mRightPlayerName.length()), 550), false); + + // Drawing the clock + drawText(mTime, Vector2(400 - mTime.length()*12, 24), false); } bool RenderManagerGP2X::setBackground(const std::string& filename) @@ -329,21 +344,38 @@ mRightPlayerWarning = rightWarning; } -void RenderManagerGP2X::drawText(const std::string& text, Vector2 position, bool highlight) +void RenderManagerGP2X::setTime(const std::string& t) +{ + mTime = t; +} + +void RenderManagerGP2X::drawText(const std::string& text, Vector2 position, unsigned int flags) { + int FontSize = (flags & TF_SMALL_FONT ? FONT_WIDTH_SMALL : FONT_WIDTH_NORMAL); int length = 0; std::string string = text; int index = getNextFontIndex(string); while (index != -1) { - length += 24; + if (flags & TF_OBFUSCATE) + index = FONT_INDEX_ASTERISK; + + length += FontSize; SDL_Rect charPosition; - charPosition.x = lround(position.x) + length - 24; + charPosition.x = lround(position.x) + length - FontSize; charPosition.y = lround(position.y); - if (highlight) - SDL_BlitSurface(mHighlightFont[index], 0, mScreen, &charPosition); + + if (flags & TF_SMALL_FONT) + if (flags & TF_HIGHLIGHT) + SDL_BlitSurface( mHighlightSmallFont[index], 0, mScreen, &charPosition ); + else + SDL_BlitSurface( mSmallFont[index], 0, mScreen, &charPosition ); else - SDL_BlitSurface(mFont[index], 0, mScreen, &charPosition); + if (flags & TF_HIGHLIGHT) + SDL_BlitSurface( mHighlightFont[index], 0, mScreen, &charPosition ); + else + SDL_BlitSurface( mFont[index], 0, mScreen, &charPosition ); + index = getNextFontIndex(string); } } diff -Nru blobby-0.8-dfsg/src/RenderManagerGP2X.h blobby-0.9c/src/RenderManagerGP2X.h --- blobby-0.8-dfsg/src/RenderManagerGP2X.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/RenderManagerGP2X.h 2011-11-06 15:06:46.000000000 +0000 @@ -39,6 +39,8 @@ std::vector mFont; std::vector mHighlightFont; + std::vector mSmallFont; + std::vector mHighlightSmallFont; SDL_Surface *mScreen; @@ -56,6 +58,7 @@ std::string mLeftPlayerName; std::string mRightPlayerName; + std::string mTime; SDL_Surface* colorSurface(SDL_Surface *surface, Color color); @@ -76,8 +79,9 @@ virtual void setScore(int leftScore, int rightScore, bool leftWarning, bool rightWarning); + virtual void setTime(const std::string& t); - virtual void drawText(const std::string& text, Vector2 position, bool highlight); + virtual void drawText(const std::string& text, Vector2 position, unsigned int flags = TF_NORMAL); virtual void drawImage(const std::string& filename, Vector2 position) {}; }; diff -Nru blobby-0.8-dfsg/src/RenderManager.h blobby-0.9c/src/RenderManager.h --- blobby-0.8-dfsg/src/RenderManager.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/RenderManager.h 2011-11-06 15:06:46.000000000 +0000 @@ -19,7 +19,6 @@ #pragma once -#include #include #include #include @@ -27,6 +26,31 @@ #include "Vector.h" #include "Global.h" + +// Text definitions +#define FONT_WIDTH_NORMAL 24 // Height and width of the normal font. +#define LINE_SPACER_NORMAL 6 // Extra space between 2 lines in a normal SelectBox. +#define FONT_WIDTH_SMALL 8 // Height and width of the small font. +#define LINE_SPACER_SMALL 2 // Extra space between 2 lines in a small SelectBox. + +#define FONT_INDEX_ASTERISK 36 // M.W. : Currently a dot because there is no asterisk yet. + + +// Text flags (usable for the RenderManager::drawText() flag parameter) +// Just using one byte for now - up to 8 flags. +#define TF_NORMAL 0x00 // 0 == false (backward compatibility for state modules) +#define TF_HIGHLIGHT 0x01 // 1 == true (backward compatibility for state modules) +#define TF_SMALL_FONT 0x02 // Draw a smaller font. (8px instead of 24px) +#define TF_OBFUSCATE 0x04 // Obfuscate the text with asterisks. (for password Editboxes) + +// Text Alignment Flags +#define TF_ALIGN_LEFT 0x00 // Text aligned to the left (default) +#define TF_ALIGN_CENTER 0x08 // Text centered +#define TF_ALIGN_RIGHT 0x10 // Text aligned right + + + + // This rendering class reduces all drawing stuff to a few calls // to refresh the objects states. It also abstracts from specific // graphics APIs. @@ -65,6 +89,7 @@ int getNextFontIndex(std::string& string); SDL_Surface* highlightSurface(SDL_Surface* surface, int luminance); SDL_Surface* loadSurface(std::string filename); + SDL_Surface* createEmptySurface(unsigned int width, unsigned int height); Vector2 blobShadowPosition(const Vector2& position); Vector2 ballShadowPosition(const Vector2& position); @@ -115,6 +140,8 @@ // Colors the standard blob image, which are red and green by default virtual void setBlobColor(int player, Color color) {}; + + virtual void showShadow(bool shadow) {}; // Takes the new balls position and its rotation in radians virtual void setBall(const Vector2& position, float rotation) {}; @@ -132,10 +159,13 @@ // Set the names virtual void setPlayernames(std::string leftName, std::string rightName) {}; + + // Set the time + virtual void setTime(const std::string& time) {}; // This simply draws the given text with its top left corner at the // given position and doesn't care about line feeds. - virtual void drawText(const std::string& text, Vector2 position, bool highlight) {}; + virtual void drawText(const std::string& text, Vector2 position, unsigned int flags = TF_NORMAL) {}; // This loads and draws an image by name // The according Surface is automatically colorkeyed @@ -148,8 +178,12 @@ //Draws a blob virtual void drawBlob(const Vector2& pos, const Color& col){}; + // Enables particle drawing + virtual void startDrawParticles() {}; //Draw blood particle virtual void drawParticle(const Vector2& pos, int player){}; + // Finishes drawing particles + virtual void endDrawParticles() {}; // This forces a redraw of the background, for example // when the windows was minimized diff -Nru blobby-0.8-dfsg/src/RenderManagerSDL.cpp blobby-0.9c/src/RenderManagerSDL.cpp --- blobby-0.8-dfsg/src/RenderManagerSDL.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/RenderManagerSDL.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -1,533 +1,652 @@ -/*============================================================================= -Blobby Volley 2 -Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -=============================================================================*/ - -#include -#include "RenderManagerSDL.h" - - -SDL_Surface* RenderManagerSDL::colorSurface(SDL_Surface *surface, Color color) -{ - SDL_Surface *newSurface = SDL_CreateRGBSurface( - SDL_SWSURFACE | SDL_SRCALPHA | SDL_SRCCOLORKEY, - surface->w, surface->h, 32, - 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000); - SDL_BlitSurface(surface, 0, newSurface, 0); - SDL_SetAlpha(newSurface, SDL_SRCALPHA, surface->format->alpha); - SDL_SetColorKey(newSurface, SDL_SRCCOLORKEY, - SDL_MapRGB(newSurface->format, 0, 0, 0)); - - SDL_LockSurface(newSurface); - for (int y = 0; y < surface->h; ++y) - for (int x = 0; x < surface->w; ++x) - { - SDL_Color* pixel = &(((SDL_Color*)newSurface->pixels) - [y * newSurface->w +x]); - - int rr = (int(pixel->r) * int(color.r)) >> 8; - int rg = (int(pixel->g) * int(color.g)) >> 8; - int rb = (int(pixel->b) * int(color.b)) >> 8; - int fak = int(pixel->r) * 5 - 4 * 256 - 138; - - bool colorkey = !(pixel->r | pixel->g | pixel->b); - - if (fak > 0) - { - rr += fak; - rg += fak; - rb += fak; - } - rr = rr < 255 ? rr : 255; - rg = rg < 255 ? rg : 255; - rb = rb < 255 ? rb : 255; - - // This is clamped to 1 because dark colors would be - // colorkeyed otherwise - if (colorkey) - { - pixel->r = 0; - pixel->g = 0; - pixel->b = 0; - } - else - { - pixel->r = rr > 0 ? rr : 1; - pixel->g = rg > 0 ? rg : 1; - pixel->b = rb > 0 ? rb : 1; - } - } - SDL_UnlockSurface(newSurface); - SDL_Surface *convSurface = SDL_DisplayFormat(newSurface); - SDL_FreeSurface(newSurface); - return convSurface; -} - -RenderManagerSDL::RenderManagerSDL() - : RenderManager() -{ - mBallRotation = 0.0; - mLeftBlobAnimationState = 0.0; - mRightBlobAnimationState = 0.0; -} - -RenderManager* RenderManager::createRenderManagerSDL() -{ - return new RenderManagerSDL(); -} - -void RenderManagerSDL::init(int xResolution, int yResolution, bool fullscreen) -{ - Uint32 screenFlags = SDL_HWSURFACE | SDL_HWACCEL | SDL_DOUBLEBUF; - if (fullscreen) - screenFlags |= SDL_FULLSCREEN; - SDL_WM_SetCaption(AppTitle, ""); - SDL_WM_SetIcon(SDL_LoadBMP("data/Icon.bmp"), NULL); - mScreen = SDL_SetVideoMode(xResolution, yResolution, 0, screenFlags); - SDL_ShowCursor(0); - - mOverlaySurface = SDL_CreateRGBSurface(SDL_HWSURFACE | SDL_SRCALPHA, - mScreen->w, mScreen->h, mScreen->format->BitsPerPixel, - mScreen->format->Rmask, mScreen->format->Gmask, - mScreen->format->Bmask, mScreen->format->Amask); - SDL_Rect screenRect = {0, 0, xResolution, yResolution}; - SDL_FillRect(mOverlaySurface, &screenRect, SDL_MapRGB(mScreen->format, 0, 0, 0)); - - - SDL_Surface* tempBackground = loadSurface("backgrounds/strand2.bmp"); - mBackground = SDL_DisplayFormat(tempBackground); - BufferedImage* bgImage = new BufferedImage; - bgImage->w = mBackground->w; - bgImage->h = mBackground->h; - bgImage->sdlImage = mBackground; - mImageMap["background"] = bgImage; - SDL_FreeSurface(tempBackground); - - for (int i = 1; i <= 16; ++i) - { - char filename[64]; - sprintf(filename, "gfx/ball%02d.bmp", i); - SDL_Surface* ballImage = loadSurface(filename); - SDL_SetColorKey(ballImage, SDL_SRCCOLORKEY, - SDL_MapRGB(ballImage->format, 0, 0, 0)); - SDL_Surface *convertedBallImage = SDL_DisplayFormat(ballImage); - SDL_FreeSurface(ballImage); - mBall.push_back(convertedBallImage); - } - - SDL_Surface *tempBallShadow = loadSurface("gfx/schball.bmp"); - SDL_SetColorKey(tempBallShadow, SDL_SRCCOLORKEY, - SDL_MapRGB(tempBallShadow->format, 0, 0, 0)); - SDL_SetAlpha(tempBallShadow, SDL_SRCALPHA, 127); - mBallShadow = SDL_DisplayFormat(tempBallShadow); - SDL_FreeSurface(tempBallShadow); - - for (int i = 1; i <= 5; ++i) - { - char filename[64]; - sprintf(filename, "gfx/blobbym%d.bmp", i); - SDL_Surface* blobImage = loadSurface(filename); - mStandardBlob.push_back(blobImage); - mLeftBlob.push_back(colorSurface(blobImage, Color(255, 0, 0))); - mRightBlob.push_back(colorSurface(blobImage, Color(0, 255, 0))); - - sprintf(filename, "gfx/sch1%d.bmp", i); - SDL_Surface* blobShadow = loadSurface(filename); - SDL_SetColorKey(blobShadow, SDL_SRCCOLORKEY, - SDL_MapRGB(blobShadow->format, 0, 0, 0)); - SDL_SetAlpha(blobShadow, SDL_SRCALPHA, 127); - mStandardBlobShadow.push_back(blobShadow); - mLeftBlobShadow.push_back( - colorSurface(blobShadow, Color(255, 0, 0))); - mRightBlobShadow.push_back( - colorSurface(blobShadow, Color(0, 255, 0))); - - } - - for (int i = 0; i <= 53; ++i) - { - char filename[64]; - sprintf(filename, "gfx/font%02d.bmp", i); - SDL_Surface *tempFont = loadSurface(filename); - SDL_SetColorKey(tempFont, SDL_SRCCOLORKEY, - SDL_MapRGB(tempFont->format, 0, 0, 0)); - SDL_Surface *newFont = SDL_DisplayFormat(tempFont); - SDL_FreeSurface(tempFont); - mFont.push_back(newFont); - mHighlightFont.push_back(highlightSurface(newFont, 60)); - } - - mScroll = loadSurface("gfx/scrollbar.bmp"); -} - -void RenderManagerSDL::deinit() -{ - SDL_FreeSurface(mOverlaySurface); - SDL_FreeSurface(mBackground); - SDL_FreeSurface(mBallShadow); - SDL_FreeSurface(mScroll); - for (unsigned int i = 0; i < mBall.size(); ++i) - SDL_FreeSurface(mBall[i]); - for (unsigned int i = 0; i < mStandardBlob.size(); ++i) - { - SDL_FreeSurface(mStandardBlob[i]); - SDL_FreeSurface(mStandardBlobShadow[i]); - SDL_FreeSurface(mLeftBlob[i]); - SDL_FreeSurface(mLeftBlobShadow[i]); - SDL_FreeSurface(mRightBlob[i]); - SDL_FreeSurface(mRightBlobShadow[i]); - } - - for (unsigned int i = 0; i < mFont.size(); ++i) - { - SDL_FreeSurface(mFont[i]); - SDL_FreeSurface(mHighlightFont[i]); - } -} - -void RenderManagerSDL::draw() -{ - if (!mDrawGame) - return; - - if (mNeedRedraw) - { - SDL_BlitSurface(mBackground, 0, mScreen, 0); - mNeedRedraw = false; - } - - int animationState; - SDL_Rect position; - - // Ball marker - Uint8 markerColor = SDL_GetTicks() % 1000 >= 500 ? 255 : 0; - position.y = 5; - position.x = lround(mBallPosition.x - 2.5); - position.w = 5; - position.h = 5; - SDL_FillRect(mScreen, &position, SDL_MapRGB(mScreen->format, - markerColor, markerColor, markerColor)); - - // Mouse marker - - position.y = 590; - position.x = lround(mMouseMarkerPosition - 2.5); - position.w = 5; - position.h = 5; - SDL_FillRect(mScreen, &position, SDL_MapRGB(mScreen->format, - markerColor, markerColor, markerColor)); - - // Ball Shadow - position = ballShadowRect(ballShadowPosition(mBallPosition)); - SDL_BlitSurface(mBallShadow, 0, mScreen, &position); - - // Left blob shadow - position = blobShadowRect(blobShadowPosition(mLeftBlobPosition)); - animationState = int(mLeftBlobAnimationState) % 5; - SDL_BlitSurface(mLeftBlobShadow[animationState], 0, mScreen, &position); - - // Right blob shadow - position = blobShadowRect(blobShadowPosition(mRightBlobPosition)); - animationState = int(mRightBlobAnimationState) % 5; - SDL_BlitSurface(mRightBlobShadow[animationState], 0, - mScreen, &position); - - // Restore the rod - position.x = 400 - 7; - position.y = 300; - SDL_Rect rodPosition; - rodPosition.x = 400 - 7; - rodPosition.y = 300; - rodPosition.w = 14; - rodPosition.h = 300; - SDL_BlitSurface(mBackground, &rodPosition, mScreen, &position); - - // Drawing the Ball - position = ballRect(mBallPosition); - animationState = int(mBallRotation / M_PI / 2 * 16) % 16; - SDL_BlitSurface(mBall[animationState], 0, mScreen, &position); - - // Drawing left blob - - position = blobRect(mLeftBlobPosition); - animationState = int(mLeftBlobAnimationState) % 5; - SDL_BlitSurface(mLeftBlob[animationState], 0, mScreen, &position); - - // Drawing right blob - - position = blobRect(mRightBlobPosition); - animationState = int(mRightBlobAnimationState) % 5; - SDL_BlitSurface(mRightBlob[animationState], 0, mScreen, &position); - - // Drawing the score - char textBuffer[8]; - snprintf(textBuffer, 8, mLeftPlayerWarning ? "%02d!" : "%02d", - mLeftPlayerScore); - drawText(textBuffer, Vector2(24, 24), false); - snprintf(textBuffer, 8, mRightPlayerWarning ? "%02d!" : "%02d", - mRightPlayerScore); - drawText(textBuffer, Vector2(800 - 96, 24), false); - - // Drawing the names - drawText(mLeftPlayerName, Vector2(12, 550), false); - - drawText(mRightPlayerName, Vector2(788-(24*mRightPlayerName.length()), 550), false); -} - -bool RenderManagerSDL::setBackground(const std::string& filename) -{ - try - { - SDL_Surface *tempBackground = loadSurface(filename); - SDL_FreeSurface(mBackground); - delete mImageMap["background"]; - BufferedImage* newImage = new BufferedImage; - newImage->w = tempBackground->w; - newImage->h = tempBackground->h; - newImage->sdlImage = SDL_DisplayFormat(tempBackground); - SDL_FreeSurface(tempBackground); - mBackground = newImage->sdlImage; - mImageMap["background"] = newImage; - } - catch (FileLoadException) - { - return false; - } - return true; -} - -void RenderManagerSDL::setBlobColor(int player, Color color) -{ - if (color != mBlobColor[player]) { - mBlobColor[player] = color; - } else { - return; - } - - std::vector *handledBlob = 0; - std::vector *handledBlobShadow = 0; - - if (player == LEFT_PLAYER) - { - handledBlob = &mLeftBlob; - handledBlobShadow = &mLeftBlobShadow; - } - if (player == RIGHT_PLAYER) - { - handledBlob = &mRightBlob; - handledBlobShadow = &mRightBlobShadow; - } - - for (short int i = 0; i < 5; ++i) - { - SDL_FreeSurface((*handledBlob)[i]); - SDL_FreeSurface((*handledBlobShadow)[i]); - } - - handledBlob->clear(); - handledBlobShadow->clear(); - - for (int i = 0; i < 5; ++i) - { - SDL_Surface *tempBlob = - colorSurface(mStandardBlob[i], color); - handledBlob->push_back( - SDL_DisplayFormat(tempBlob)); - SDL_FreeSurface(tempBlob); - - SDL_Surface *tempShadow = colorSurface( - mStandardBlobShadow[i], color); - handledBlobShadow->push_back( - SDL_DisplayFormat(tempShadow)); - SDL_FreeSurface(tempShadow); - } -} - -void RenderManagerSDL::setBall(const Vector2& position, float rotation) -{ - SDL_Rect restore = ballRect(mBallPosition); - SDL_BlitSurface(mBackground, &restore, mScreen, &restore); - restore = ballShadowRect(ballShadowPosition(mBallPosition)); - SDL_BlitSurface(mBackground, &restore, mScreen, &restore); - restore.x = lround(mBallPosition.x - 2.5); - restore.y = 5; - restore.w = 5; - restore.h = 5; - SDL_BlitSurface(mBackground, &restore, mScreen, &restore); - - mBallPosition = position; - mBallRotation = rotation; -} - -void RenderManagerSDL::setMouseMarker(float position) -{ - SDL_Rect restore = { - lround(mMouseMarkerPosition - 2.5), - 590, - 5, - 5 - }; - SDL_BlitSurface(mBackground, &restore, mScreen, &restore); - mMouseMarkerPosition = position; -} - -void RenderManagerSDL::setBlob(int player, - const Vector2& position, float animationState) -{ - SDL_Rect blobRestore; - SDL_Rect shadowRestore; - if (player == LEFT_PLAYER) - { - blobRestore = blobRect(mLeftBlobPosition); - shadowRestore = blobShadowRect( - blobShadowPosition(mLeftBlobPosition)); - mLeftBlobPosition = position; - mLeftBlobAnimationState = animationState; - } - - if (player == RIGHT_PLAYER) - { - blobRestore = blobRect(mRightBlobPosition); - shadowRestore = blobShadowRect( - blobShadowPosition(mRightBlobPosition)); - mRightBlobPosition = position; - mRightBlobAnimationState = animationState; - } - SDL_BlitSurface(mBackground, &blobRestore, mScreen, &blobRestore); - SDL_BlitSurface(mBackground, &shadowRestore, mScreen, &shadowRestore); -} - -void RenderManagerSDL::setScore(int leftScore, int rightScore, - bool leftWarning, bool rightWarning) -{ - SDL_Rect restore = { - 24, - 24, - 96, - 24 - }; - SDL_BlitSurface(mBackground, &restore, mScreen, &restore); - restore.x = 800 - 96; - SDL_BlitSurface(mBackground, &restore, mScreen, &restore); - - mLeftPlayerScore = leftScore; - mRightPlayerScore = rightScore; - mLeftPlayerWarning = leftWarning; - mRightPlayerWarning = rightWarning; -} - -void RenderManagerSDL::setPlayernames(std::string leftName, std::string rightName) -{ - mLeftPlayerName = leftName; - mRightPlayerName = rightName; -} - -void RenderManagerSDL::drawText(const std::string& text, Vector2 position, bool highlight) -{ - int length = 0; - std::string string = text; - int index = getNextFontIndex(string); - while (index != -1) - { - SDL_Rect charPosition; - charPosition.x = lround(position.x) + length; - charPosition.y = lround(position.y); - if (highlight) - SDL_BlitSurface(mHighlightFont[index], 0, mScreen, &charPosition); - else - SDL_BlitSurface(mFont[index], 0, mScreen, &charPosition); - index = getNextFontIndex(string); - length += 24; - } -} - -void RenderManagerSDL::drawImage(const std::string& filename, Vector2 position) -{ - mNeedRedraw = true; - BufferedImage* imageBuffer = mImageMap[filename]; - if (!imageBuffer) - { - imageBuffer = new BufferedImage; - imageBuffer->sdlImage = loadSurface(filename); - SDL_SetColorKey(imageBuffer->sdlImage, SDL_SRCCOLORKEY, - SDL_MapRGB(mScreen->format, 0, 0, 0)); - mImageMap[filename] = imageBuffer; - } - - SDL_Rect blitRect = { - lround(position.x - float(imageBuffer->sdlImage->w) / 2.0), - lround(position.y - float(imageBuffer->sdlImage->h) / 2.0), - lround(position.x + float(imageBuffer->sdlImage->w) / 2.0), - lround(position.y + float(imageBuffer->sdlImage->h) / 2.0), - }; - - SDL_BlitSurface(imageBuffer->sdlImage, 0, mScreen, &blitRect); -} - -void RenderManagerSDL::drawOverlay(float opacity, Vector2 pos1, Vector2 pos2, Color col) -{ - SDL_Rect ovRect; - ovRect.x = lround(pos1.x); - ovRect.y = lround(pos1.y); - ovRect.w = lround(pos2.x - pos1.x); - ovRect.h = lround(pos2.y - pos1.y); - SDL_SetAlpha(mOverlaySurface, SDL_SRCALPHA, lround(opacity * 255)); - - SDL_FillRect(mOverlaySurface, NULL, SDL_MapRGB(mScreen->format, col.r, col.g, col.b)); - - SDL_SetClipRect(mScreen, &ovRect); - SDL_BlitSurface(mOverlaySurface, 0, mScreen, 0); - SDL_SetClipRect(mScreen, 0); -} - -void RenderManagerSDL::drawBlob(const Vector2& pos, const Color& col) -{ - SDL_Rect position; - position.x = lround(pos.x); - position.y = lround(pos.y); - // Workarround, so that surface will only be loaded when color is changed - // Works only when 2 blobs are on the screen (like in IMGUI) - static Color lastColor[2] = {Color( -1, -1, -1), Color( -1, -1, -1)}; - - static int toDraw = 0; - - if (lastColor[toDraw].val != col.val) - { - setBlobColor(toDraw, col); - lastColor[toDraw] = col; - } - - // Second dirty workaround in the function to have the right position of blobs in the GUI - position.x = position.x - (int)(75/2); - position.y = position.y - (int)(89/2); - - if(toDraw == 1) - { - SDL_BlitSurface(mRightBlob[0], 0, mScreen, &position); - toDraw = 0; - } - else - { - SDL_BlitSurface(mLeftBlob[0], 0, mScreen, &position); - toDraw = 1; - } -} - -void RenderManagerSDL::refresh() -{ - SDL_Flip(mScreen); -} +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + +#include +#include "RenderManagerSDL.h" + + +RenderManagerSDL::DynamicColoredSurface RenderManagerSDL::colorSurface(SDL_Surface *surface, Color color) +{ + SDL_Surface *newSurface = SDL_CreateRGBSurface( + SDL_SWSURFACE | SDL_SRCALPHA | SDL_SRCCOLORKEY, + surface->w, surface->h, 32, + 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000); + SDL_BlitSurface(surface, 0, newSurface, 0); + SDL_SetAlpha(newSurface, SDL_SRCALPHA, surface->format->alpha); + SDL_SetColorKey(newSurface, SDL_SRCCOLORKEY, + SDL_MapRGB(newSurface->format, 0, 0, 0)); + + SDL_LockSurface(newSurface); + for (int p = 0; p < newSurface->w * newSurface->h; ++p) + { + SDL_Color* pixel = &(((SDL_Color*)newSurface->pixels)[p]); + + int rr = (int(pixel->r) * int(color.r)) >> 8; + int rg = (int(pixel->g) * int(color.g)) >> 8; + int rb = (int(pixel->b) * int(color.b)) >> 8; + int fak = int(pixel->r) * 5 - 4 * 256 - 138; + + bool colorkey = !(pixel->r | pixel->g | pixel->b); + + if (colorkey) + { + pixel->r = 0; + pixel->g = 0; + pixel->b = 0; + continue; + } + + if (fak > 0) + { + rr += fak; + rg += fak; + rb += fak; + } + rr = rr < 255 ? rr : 255; + rg = rg < 255 ? rg : 255; + rb = rb < 255 ? rb : 255; + + // This is clamped to 1 because dark colors would be + // colorkeyed otherwise + pixel->r = rr > 0 ? rr : 1; + pixel->g = rg > 0 ? rg : 1; + pixel->b = rb > 0 ? rb : 1; + + } + SDL_UnlockSurface(newSurface); + SDL_SetColorKey(newSurface, SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(newSurface->format, 0, 0, 0)); + SDL_Surface *convSurface = SDL_DisplayFormatAlpha(newSurface); + SDL_FreeSurface(newSurface); + return DynamicColoredSurface(convSurface, color); +} + +RenderManagerSDL::RenderManagerSDL() + : RenderManager() +{ + mBallRotation = 0.0; + mLeftBlobAnimationState = 0.0; + mRightBlobAnimationState = 0.0; +} + +RenderManager* RenderManager::createRenderManagerSDL() +{ + return new RenderManagerSDL(); +} + +void RenderManagerSDL::init(int xResolution, int yResolution, bool fullscreen) +{ + + mLeftPlayerNameTexture = 0; + mRightPlayerNameTexture = 0; + + Uint32 screenFlags = SDL_HWSURFACE | SDL_HWACCEL | SDL_DOUBLEBUF; + if (fullscreen) + screenFlags |= SDL_FULLSCREEN; + SDL_WM_SetCaption(AppTitle, ""); + SDL_WM_SetIcon(SDL_LoadBMP("data/Icon.bmp"), NULL); + mScreen = SDL_SetVideoMode(xResolution, yResolution, 0, screenFlags); + SDL_ShowCursor(0); + + mOverlaySurface = SDL_CreateRGBSurface(SDL_HWSURFACE | SDL_SRCALPHA, + mScreen->w, mScreen->h, mScreen->format->BitsPerPixel, + mScreen->format->Rmask, mScreen->format->Gmask, + mScreen->format->Bmask, mScreen->format->Amask); + SDL_Rect screenRect = {0, 0, xResolution, yResolution}; + SDL_FillRect(mOverlaySurface, &screenRect, SDL_MapRGB(mScreen->format, 0, 0, 0)); + + + SDL_Surface* tempBackground = loadSurface("backgrounds/strand2.bmp"); + mBackground = SDL_DisplayFormat(tempBackground); + BufferedImage* bgImage = new BufferedImage; + bgImage->w = mBackground->w; + bgImage->h = mBackground->h; + bgImage->sdlImage = mBackground; + mImageMap["background"] = bgImage; + SDL_FreeSurface(tempBackground); + + for (int i = 1; i <= 16; ++i) + { + char filename[64]; + sprintf(filename, "gfx/ball%02d.bmp", i); + SDL_Surface* ballImage = loadSurface(filename); + SDL_SetColorKey(ballImage, SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(ballImage->format, 0, 0, 0)); + SDL_Surface *convertedBallImage = SDL_DisplayFormatAlpha(ballImage); + SDL_FreeSurface(ballImage); + mBall.push_back(convertedBallImage); + } + + SDL_Surface *tempBallShadow = loadSurface("gfx/schball.bmp"); + SDL_SetColorKey(tempBallShadow, SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(tempBallShadow->format, 0, 0, 0)); + SDL_SetAlpha(tempBallShadow, SDL_SRCALPHA, 127); + mBallShadow = SDL_DisplayFormatAlpha(tempBallShadow); + SDL_FreeSurface(tempBallShadow); + + for (int i = 1; i <= 5; ++i) + { + char filename[64]; + sprintf(filename, "gfx/blobbym%d.bmp", i); + SDL_Surface* blobImage = loadSurface(filename); + mStandardBlob.push_back(blobImage); + mLeftBlob.push_back(colorSurface(blobImage, Color(255, 0, 0))); + mRightBlob.push_back(colorSurface(blobImage, Color(0, 255, 0))); + + sprintf(filename, "gfx/sch1%d.bmp", i); + SDL_Surface* blobShadow = loadSurface(filename); + SDL_SetColorKey(blobShadow, SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(blobShadow->format, 0, 0, 0)); + SDL_SetAlpha(blobShadow, SDL_SRCALPHA, 127); + mStandardBlobShadow.push_back(blobShadow); + mLeftBlobShadow.push_back( + colorSurface(blobShadow, Color(255, 0, 0))); + mRightBlobShadow.push_back( + colorSurface(blobShadow, Color(0, 255, 0))); + + } + + for (int i = 0; i <= 53; ++i) + { + char filename[64], filename2[64]; + sprintf(filename, "gfx/font%02d.bmp", i); + sprintf(filename2, "gfx/font_small/font%02d.bmp", i); + SDL_Surface *tempFont = loadSurface(filename); + SDL_Surface *tempFont2 = loadSurface(filename2); + SDL_SetColorKey(tempFont, SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(tempFont->format, 0, 0, 0)); + SDL_SetColorKey(tempFont2, SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(tempFont2->format, 0, 0, 0)); + SDL_Surface *newFont = SDL_DisplayFormatAlpha(tempFont); + SDL_Surface *newFont2 = SDL_DisplayFormatAlpha(tempFont2); + SDL_FreeSurface(tempFont); + SDL_FreeSurface(tempFont2); + + mFont.push_back(newFont); + mHighlightFont.push_back(highlightSurface(newFont, 60)); + mSmallFont.push_back(newFont2); + mHighlightSmallFont.push_back(highlightSurface(newFont2, 60)); + } + + mScroll = loadSurface("gfx/scrollbar.bmp"); + + mStandardBlobBlood = loadSurface("gfx/blood.bmp"); + mLeftBlobBlood = loadSurface("gfx/blood.bmp"); + mRightBlobBlood = loadSurface("gfx/blood.bmp"); +} + +void RenderManagerSDL::deinit() +{ + SDL_FreeSurface(mOverlaySurface); + SDL_FreeSurface(mBackground); + SDL_FreeSurface(mBallShadow); + SDL_FreeSurface(mScroll); + + SDL_FreeSurface(mLeftBlobBlood); + SDL_FreeSurface(mRightBlobBlood); + + SDL_FreeSurface(mLeftPlayerNameTexture); + SDL_FreeSurface(mRightPlayerNameTexture); + + for (unsigned int i = 0; i < mBall.size(); ++i) + SDL_FreeSurface(mBall[i]); + for (unsigned int i = 0; i < mStandardBlob.size(); ++i) + { + SDL_FreeSurface(mStandardBlob[i]); + SDL_FreeSurface(mStandardBlobShadow[i]); + SDL_FreeSurface(mLeftBlob[i].mSDLsf); + SDL_FreeSurface(mLeftBlobShadow[i].mSDLsf); + SDL_FreeSurface(mRightBlob[i].mSDLsf); + SDL_FreeSurface(mRightBlobShadow[i].mSDLsf); + } + + for (unsigned int i = 0; i < mFont.size(); ++i) + { + SDL_FreeSurface(mFont[i]); + SDL_FreeSurface(mHighlightFont[i]); + SDL_FreeSurface(mSmallFont[i]); + SDL_FreeSurface(mHighlightSmallFont[i]); + } +} + +void RenderManagerSDL::draw() +{ + if (!mDrawGame) + return; + + if (mNeedRedraw) + { + SDL_BlitSurface(mBackground, 0, mScreen, 0); + mNeedRedraw = false; + } + + int animationState; + SDL_Rect position; + + // Ball marker + Uint8 markerColor = SDL_GetTicks() % 1000 >= 500 ? 255 : 0; + position.y = 5; + position.x = lround(mBallPosition.x - 2.5); + position.w = 5; + position.h = 5; + SDL_FillRect(mScreen, &position, SDL_MapRGB(mScreen->format, + markerColor, markerColor, markerColor)); + + // Mouse marker + + position.y = 590; + position.x = lround(mMouseMarkerPosition - 2.5); + position.w = 5; + position.h = 5; + SDL_FillRect(mScreen, &position, SDL_MapRGB(mScreen->format, + markerColor, markerColor, markerColor)); + + if(mShowShadow) + { + // Ball Shadow + position = ballShadowRect(ballShadowPosition(mBallPosition)); + SDL_BlitSurface(mBallShadow, 0, mScreen, &position); + + // Left blob shadow + position = blobShadowRect(blobShadowPosition(mLeftBlobPosition)); + animationState = int(mLeftBlobAnimationState) % 5; + SDL_BlitSurface(mLeftBlobShadow[animationState].mSDLsf, 0, mScreen, &position); + + // Right blob shadow + position = blobShadowRect(blobShadowPosition(mRightBlobPosition)); + animationState = int(mRightBlobAnimationState) % 5; + SDL_BlitSurface(mRightBlobShadow[animationState].mSDLsf, 0, mScreen, &position); + } + + // Restore the rod + position.x = 400 - 7; + position.y = 300; + SDL_Rect rodPosition; + rodPosition.x = 400 - 7; + rodPosition.y = 300; + rodPosition.w = 14; + rodPosition.h = 300; + SDL_BlitSurface(mBackground, &rodPosition, mScreen, &position); + // restore the background for clock + position.x = 400 - mTime.length()*12; + position.y = 24; + rodPosition.x = 400 - mTime.length()*12; + rodPosition.y = 24; + rodPosition.w = mTime.length()*24; + rodPosition.h = 24; + SDL_BlitSurface(mBackground, &rodPosition, mScreen, &position); + + // Drawing the Ball + position = ballRect(mBallPosition); + animationState = int(mBallRotation / M_PI / 2 * 16) % 16; + SDL_BlitSurface(mBall[animationState], 0, mScreen, &position); + + // update blob colors + colorizeBlobs(LEFT_PLAYER); + colorizeBlobs(RIGHT_PLAYER); + + // Drawing left blob + position = blobRect(mLeftBlobPosition); + animationState = int(mLeftBlobAnimationState) % 5; + SDL_BlitSurface(mLeftBlob[animationState].mSDLsf, 0, mScreen, &position); + + // Drawing right blob + position = blobRect(mRightBlobPosition); + animationState = int(mRightBlobAnimationState) % 5; + SDL_BlitSurface(mRightBlob[animationState].mSDLsf, 0, mScreen, &position); + + // Drawing the score + char textBuffer[8]; + snprintf(textBuffer, 8, mLeftPlayerWarning ? "%02d!" : "%02d", + mLeftPlayerScore); + drawText(textBuffer, Vector2(24, 24), false); + snprintf(textBuffer, 8, mRightPlayerWarning ? "%02d!" : "%02d", + mRightPlayerScore); + drawText(textBuffer, Vector2(800 - 96, 24), false); + + // Drawing the names + //drawText(mLeftPlayerName, Vector2(12, 550), false); + SDL_Rect rect; + rect.x = 12; + rect.y = 550; + SDL_BlitSurface(mLeftPlayerNameTexture, 0, mScreen, &rect); + + drawText(mRightPlayerName, Vector2(788-(24*mRightPlayerName.length()), 550), false); + + // Drawing the Clock + drawText(mTime, Vector2(400 - mTime.length()*12, 24), false); +} + +bool RenderManagerSDL::setBackground(const std::string& filename) +{ + try + { + SDL_Surface *tempBackground = loadSurface(filename); + SDL_FreeSurface(mBackground); + delete mImageMap["background"]; + BufferedImage* newImage = new BufferedImage; + newImage->w = tempBackground->w; + newImage->h = tempBackground->h; + newImage->sdlImage = SDL_DisplayFormat(tempBackground); + SDL_FreeSurface(tempBackground); + mBackground = newImage->sdlImage; + mImageMap["background"] = newImage; + } + catch (FileLoadException) + { + return false; + } + return true; +} + +void RenderManagerSDL::setBlobColor(int player, Color color) +{ + if (color != mBlobColor[player]) { + mBlobColor[player] = color; + } else { + return; + } + + SDL_Surface** handledBlobBlood = 0; + + if (player == LEFT_PLAYER) + { + handledBlobBlood = &mLeftBlobBlood; + } + if (player == RIGHT_PLAYER) + { + handledBlobBlood = &mRightBlobBlood; + } + + SDL_FreeSurface(*handledBlobBlood); + *handledBlobBlood = colorSurface(mStandardBlobBlood, color).mSDLsf; + +} + + +void RenderManagerSDL::colorizeBlobs(int player) +{ + std::vector *handledBlob = 0; + std::vector *handledBlobShadow = 0; + int frame; + + if (player == LEFT_PLAYER) + { + handledBlob = &mLeftBlob; + handledBlobShadow = &mLeftBlobShadow; + frame = mLeftBlobAnimationState; + } + if (player == RIGHT_PLAYER) + { + handledBlob = &mRightBlob; + handledBlobShadow = &mRightBlobShadow; + frame = mRightBlobAnimationState; + } + + if( (*handledBlob)[frame].mColor != mBlobColor[player]) + { + SDL_FreeSurface((*handledBlob)[frame].mSDLsf); + (*handledBlob)[frame] = colorSurface(mStandardBlob[frame], mBlobColor[player]); + SDL_FreeSurface((*handledBlobShadow)[frame].mSDLsf); + (*handledBlobShadow)[frame] = colorSurface(mStandardBlobShadow[frame], mBlobColor[player]); + } +} + + +void RenderManagerSDL::showShadow(bool shadow) +{ + mShowShadow = shadow; +} + +void RenderManagerSDL::setBall(const Vector2& position, float rotation) +{ + SDL_Rect restore = ballRect(mBallPosition); + SDL_BlitSurface(mBackground, &restore, mScreen, &restore); + restore = ballShadowRect(ballShadowPosition(mBallPosition)); + SDL_BlitSurface(mBackground, &restore, mScreen, &restore); + restore.x = lround(mBallPosition.x - 2.5); + restore.y = 5; + restore.w = 5; + restore.h = 5; + SDL_BlitSurface(mBackground, &restore, mScreen, &restore); + + mBallPosition = position; + mBallRotation = rotation; +} + +void RenderManagerSDL::setMouseMarker(float position) +{ + SDL_Rect restore = { + lround(mMouseMarkerPosition - 2.5), + 590, + 5, + 5 + }; + SDL_BlitSurface(mBackground, &restore, mScreen, &restore); + mMouseMarkerPosition = position; +} + +void RenderManagerSDL::setBlob(int player, + const Vector2& position, float animationState) +{ + SDL_Rect blobRestore; + SDL_Rect shadowRestore; + if (player == LEFT_PLAYER) + { + blobRestore = blobRect(mLeftBlobPosition); + shadowRestore = blobShadowRect( + blobShadowPosition(mLeftBlobPosition)); + mLeftBlobPosition = position; + mLeftBlobAnimationState = animationState; + } + + if (player == RIGHT_PLAYER) + { + blobRestore = blobRect(mRightBlobPosition); + shadowRestore = blobShadowRect( + blobShadowPosition(mRightBlobPosition)); + mRightBlobPosition = position; + mRightBlobAnimationState = animationState; + } + SDL_BlitSurface(mBackground, &blobRestore, mScreen, &blobRestore); + SDL_BlitSurface(mBackground, &shadowRestore, mScreen, &shadowRestore); +} + +void RenderManagerSDL::setScore(int leftScore, int rightScore, + bool leftWarning, bool rightWarning) +{ + SDL_Rect restore = { + 24, + 24, + 96, + 24 + }; + SDL_BlitSurface(mBackground, &restore, mScreen, &restore); + restore.x = 800 - 96; + SDL_BlitSurface(mBackground, &restore, mScreen, &restore); + + mLeftPlayerScore = leftScore; + mRightPlayerScore = rightScore; + mLeftPlayerWarning = leftWarning; + mRightPlayerWarning = rightWarning; +} + +void RenderManagerSDL::setPlayernames(std::string leftName, std::string rightName) +{ + mLeftPlayerName = leftName; + mRightPlayerName = rightName; + + int tl = mLeftPlayerName.size() * FONT_WIDTH_NORMAL; + SDL_FreeSurface(mLeftPlayerNameTexture); + SDL_Surface* surface = createEmptySurface(tl, 24); + SDL_SetAlpha(surface, SDL_SRCALPHA, 255); + SDL_SetColorKey(surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(surface->format, 0, 0, 0)); + drawTextImpl(mLeftPlayerName, Vector2(0,0), TF_NORMAL, surface); + + mLeftPlayerNameTexture = SDL_DisplayFormatAlpha(surface); + SDL_FreeSurface(surface); + + + tl = mRightPlayerName.size() * FONT_WIDTH_NORMAL; + SDL_FreeSurface(mRightPlayerNameTexture); + surface = createEmptySurface(tl, 24); + SDL_SetAlpha(surface, SDL_SRCALPHA, 255); + SDL_SetColorKey(surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(surface->format, 0, 0, 0)); + drawTextImpl(mRightPlayerName, Vector2(0,0), TF_NORMAL, surface); + + mRightPlayerNameTexture = SDL_DisplayFormatAlpha(surface); + SDL_FreeSurface(surface); +} + +void RenderManagerSDL::setTime(const std::string& t) +{ + mTime = t; +} + + +void RenderManagerSDL::drawText(const std::string& text, Vector2 position, unsigned int flags) +{ + drawTextImpl(text, position, flags, mScreen); +} + +void RenderManagerSDL::drawTextImpl(const std::string& text, Vector2 position, unsigned int flags, SDL_Surface* screen) +{ + int FontSize = (flags & TF_SMALL_FONT ? FONT_WIDTH_SMALL : FONT_WIDTH_NORMAL); + int length = 0; + std::string string = text; + int index = getNextFontIndex(string); + while (index != -1) + { + if (flags & TF_OBFUSCATE) + index = FONT_INDEX_ASTERISK; + + SDL_Rect charPosition; + charPosition.x = lround(position.x) + length; + charPosition.y = lround(position.y); + + if (flags & TF_SMALL_FONT) + if (flags & TF_HIGHLIGHT) + SDL_BlitSurface( mHighlightSmallFont[index], 0, screen, &charPosition ); + else + SDL_BlitSurface( mSmallFont[index], 0, screen, &charPosition ); + else + if (flags & TF_HIGHLIGHT) + SDL_BlitSurface( mHighlightFont[index], 0, screen, &charPosition ); + else + SDL_BlitSurface( mFont[index], 0, screen, &charPosition ); + + index = getNextFontIndex(string); + length += FontSize; + } +} + +void RenderManagerSDL::drawImage(const std::string& filename, Vector2 position) +{ + mNeedRedraw = true; + BufferedImage* imageBuffer = mImageMap[filename]; + if (!imageBuffer) + { + imageBuffer = new BufferedImage; + imageBuffer->sdlImage = loadSurface(filename); + SDL_SetColorKey(imageBuffer->sdlImage, SDL_SRCCOLORKEY | SDL_RLEACCEL, + SDL_MapRGB(mScreen->format, 0, 0, 0)); + mImageMap[filename] = imageBuffer; + } + + SDL_Rect blitRect = { + lround(position.x - float(imageBuffer->sdlImage->w) / 2.0), + lround(position.y - float(imageBuffer->sdlImage->h) / 2.0), + lround(position.x + float(imageBuffer->sdlImage->w) / 2.0), + lround(position.y + float(imageBuffer->sdlImage->h) / 2.0), + }; + + SDL_BlitSurface(imageBuffer->sdlImage, 0, mScreen, &blitRect); +} + +void RenderManagerSDL::drawOverlay(float opacity, Vector2 pos1, Vector2 pos2, Color col) +{ + SDL_Rect ovRect; + ovRect.x = lround(pos1.x); + ovRect.y = lround(pos1.y); + ovRect.w = lround(pos2.x - pos1.x); + ovRect.h = lround(pos2.y - pos1.y); + SDL_SetAlpha(mOverlaySurface, SDL_SRCALPHA, lround(opacity * 255)); + + SDL_FillRect(mOverlaySurface, NULL, SDL_MapRGB(mScreen->format, col.r, col.g, col.b)); + + SDL_SetClipRect(mScreen, &ovRect); + SDL_BlitSurface(mOverlaySurface, 0, mScreen, 0); + SDL_SetClipRect(mScreen, 0); +} + +void RenderManagerSDL::drawBlob(const Vector2& pos, const Color& col) +{ + SDL_Rect position; + position.x = lround(pos.x); + position.y = lround(pos.y); + // Workarround, so that surface will only be loaded when color is changed + // Works only when 2 blobs are on the screen (like in IMGUI) + static Color lastColor[2] = {Color( -1, -1, -1), Color( -1, -1, -1)}; + + static int toDraw = 0; + + if (lastColor[toDraw].val != col.val) + { + setBlobColor(toDraw, col); + lastColor[toDraw] = col; + } + + // Second dirty workaround in the function to have the right position of blobs in the GUI + position.x = position.x - (int)(75/2); + position.y = position.y - (int)(89/2); + + if(toDraw == 1) + { + SDL_BlitSurface(mRightBlob[0].mSDLsf, 0, mScreen, &position); + toDraw = 0; + } + else + { + SDL_BlitSurface(mLeftBlob[0].mSDLsf, 0, mScreen, &position); + toDraw = 1; + } +} + +void RenderManagerSDL::drawParticle(const Vector2& pos, int player) +{ + mNeedRedraw = true; + + SDL_Rect blitRect = { + lround(pos.x - float(9) / 2.0), + lround(pos.y - float(9) / 2.0), + lround(pos.x + float(9) / 2.0), + lround(pos.y + float(9) / 2.0), + }; + + SDL_Surface* blood = player == LEFT_PLAYER ? mLeftBlobBlood : mRightBlobBlood; + + SDL_BlitSurface(blood, 0, mScreen, &blitRect); +} + +void RenderManagerSDL::refresh() +{ + SDL_Flip(mScreen); +} diff -Nru blobby-0.8-dfsg/src/RenderManagerSDL.h blobby-0.9c/src/RenderManagerSDL.h --- blobby-0.8-dfsg/src/RenderManagerSDL.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/RenderManagerSDL.h 2011-11-06 15:06:46.000000000 +0000 @@ -26,6 +26,20 @@ class RenderManagerSDL : public RenderManager { + struct DynamicColoredSurface + { + // constructors + // start surface is expected to have color 0xffffff + DynamicColoredSurface() : mSDLsf(0), mColor(255, 255, 255) {}; + explicit DynamicColoredSurface(SDL_Surface* sf) : mSDLsf(sf), mColor(255, 255, 255) {}; + + DynamicColoredSurface(SDL_Surface* sf, Color c) : mSDLsf(sf), mColor(c) {}; + + SDL_Surface* mSDLsf; + Color mColor; + }; + + SDL_Surface* mBackground; SDL_Surface* mBallShadow; SDL_Surface* mScroll; @@ -33,13 +47,18 @@ std::vector mBall; std::vector mStandardBlob; std::vector mStandardBlobShadow; - std::vector mLeftBlob; - std::vector mLeftBlobShadow; - std::vector mRightBlob; - std::vector mRightBlobShadow; + SDL_Surface* mStandardBlobBlood; + std::vector mLeftBlob; + std::vector mLeftBlobShadow; + SDL_Surface* mLeftBlobBlood; + std::vector mRightBlob; + std::vector mRightBlobShadow; + SDL_Surface* mRightBlobBlood; std::vector mFont; std::vector mHighlightFont; + std::vector mSmallFont; + std::vector mHighlightSmallFont; SDL_Surface *mOverlaySurface; SDL_Surface *mScreen; @@ -51,6 +70,8 @@ Vector2 mRightBlobPosition; float mRightBlobAnimationState; + bool mShowShadow; + int mLeftPlayerScore; int mRightPlayerScore; bool mLeftPlayerWarning; @@ -58,12 +79,20 @@ std::string mLeftPlayerName; std::string mRightPlayerName; + SDL_Surface* mLeftPlayerNameTexture; + SDL_Surface* mRightPlayerNameTexture; + + std::string mTime; // Store color for caching Color mBlobColor[MAX_PLAYERS]; - SDL_Surface* colorSurface(SDL_Surface *surface, Color color); + // colors a surface + // the returned SDL_Surface* is already converted into DisplayFormat + DynamicColoredSurface colorSurface(SDL_Surface *surface, Color color); + void drawTextImpl(const std::string& text, Vector2 position, unsigned int flags, SDL_Surface* screen); + void colorizeBlobs(int player); public: RenderManagerSDL(); @@ -74,6 +103,7 @@ virtual bool setBackground(const std::string& filename); virtual void setBlobColor(int player, Color color); + virtual void showShadow(bool shadow); virtual void setBall(const Vector2& position, float rotation); virtual void setBlob(int player, const Vector2& position, @@ -83,12 +113,14 @@ bool leftWarning, bool rightWarning); virtual void setPlayernames(std::string leftName, std::string rightName); + virtual void setTime(const std::string& t); virtual void setMouseMarker(float position); - virtual void drawText(const std::string& text, Vector2 position, bool highlight); + virtual void drawText(const std::string& text, Vector2 position, unsigned int flags = TF_NORMAL); virtual void drawImage(const std::string& filename, Vector2 position); virtual void drawOverlay(float opacity, Vector2 pos1, Vector2 pos2, Color col); virtual void drawBlob(const Vector2& pos, const Color& col); + virtual void drawParticle(const Vector2& pos, int player); }; diff -Nru blobby-0.8-dfsg/src/ReplayRecorder.cpp blobby-0.9c/src/ReplayRecorder.cpp --- blobby-0.8-dfsg/src/ReplayRecorder.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/ReplayRecorder.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -22,6 +22,7 @@ #include "tinyxml/tinyxml.h" #include +#include #include #include #include @@ -53,10 +54,7 @@ ReplayRecorder::~ReplayRecorder() { - if (mReplayData) - { - delete[] mReplayData; - } + delete[] mReplayData; } bool ReplayRecorder::endOfFile() @@ -145,9 +143,8 @@ PHYSFS_read(fileHandle, &checksum, 1, 4); mBufferSize = fileLength-8; - if (mReplayData != 0) { - delete[] mReplayData; - } + delete[] mReplayData; + mReplayData = new char[mBufferSize]; mBufferSize = PHYSFS_read(fileHandle, mReplayData, 1, mBufferSize); @@ -184,13 +181,13 @@ mSaveData.push_back(packet); } -void ReplayRecorder::setPlayerNames(const std::string left, const std::string right) +void ReplayRecorder::setPlayerNames(const std::string& left, const std::string& right) { mPlayerNames[LEFT_PLAYER] = left; mPlayerNames[RIGHT_PLAYER] = right; } -std::string ReplayRecorder::getPlayerName(const PlayerSide side) +std::string ReplayRecorder::getPlayerName(const PlayerSide side) const { return mPlayerNames[side]; } @@ -206,7 +203,7 @@ } } -PlayerInput* ReplayRecorder::getInput() +const PlayerInput* ReplayRecorder::getInput() { PlayerInput* input = new PlayerInput[MAX_PLAYERS]; const uint8_t packet = mReplayData[mReplayOffset++]; @@ -215,7 +212,7 @@ return input; } -PlayerSide ReplayRecorder::getServingPlayer() +PlayerSide ReplayRecorder::getServingPlayer() const { return mServingPlayer; } diff -Nru blobby-0.8-dfsg/src/ReplayRecorder.h blobby-0.9c/src/ReplayRecorder.h --- blobby-0.8-dfsg/src/ReplayRecorder.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/ReplayRecorder.h 2011-11-06 15:06:46.000000000 +0000 @@ -19,7 +19,7 @@ #pragma once -#include +#include #include #include @@ -75,13 +75,13 @@ bool endOfFile(); void record(const PlayerInput* input); - void setPlayerNames(const std::string left, const std::string right); + void setPlayerNames(const std::string& left, const std::string& right); - std::string getPlayerName(const PlayerSide side); + std::string getPlayerName(const PlayerSide side) const; - PlayerInput* getInput(); + const PlayerInput* getInput(); - PlayerSide getServingPlayer(); + PlayerSide getServingPlayer() const; void setServingPlayer(PlayerSide side); PacketType getPacketType(); diff -Nru blobby-0.8-dfsg/src/ScriptedInputSource.cpp blobby-0.9c/src/ScriptedInputSource.cpp --- blobby-0.8-dfsg/src/ScriptedInputSource.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/ScriptedInputSource.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -19,6 +19,8 @@ #include "ScriptedInputSource.h" #include "DuelMatch.h" +#include "GameConstants.h" +#include "BotAPICalculations.h" extern "C" { @@ -27,9 +29,63 @@ #include "lua/lualib.h" } +#include #include #include #include +#include + +DuelMatch* ScriptedInputSource::mMatch = 0; +ScriptedInputSource* ScriptedInputSource::mCurrentSource = 0; + +struct pos_x; +struct pos_y; +struct vel_x; +struct vel_y; + +template +float convert(float f); + +template +struct ScriptedInputSource::coordinate { + coordinate(float f) : value(convert(f)) { + } + coordinate(double f) : value(convert(f)) { + } + + operator float() const { + return value; + } + + float value; + + private: + // other constructors ar prohibited ! + template + coordinate(U u); + + static float convert(float f); +}; + +// functions for coodinate transformation +template<> +float ScriptedInputSource::coordinate::convert (float val) { + return mCurrentSource->mSide == LEFT_PLAYER ? val : RIGHT_PLANE - val; +} + +template<> +float ScriptedInputSource::coordinate::convert (float val) { + return 600.f - val; +} +template<> +float ScriptedInputSource::coordinate::convert (float val) { + return mCurrentSource->mSide == LEFT_PLAYER ? val : -val; +} +template<> +float ScriptedInputSource::coordinate::convert (float val) { + return -val; +} + struct ReaderInfo @@ -54,12 +110,37 @@ } ScriptedInputSource::ScriptedInputSource(const std::string& filename, - PlayerSide playerside) + PlayerSide playerside, unsigned int difficulty): mLastBallSpeed(0), + mMaxDelay(difficulty), mCurDelay(difficulty), mSide(playerside) { mStartTime = SDL_GetTicks(); mState = lua_open(); - lua_pushnumber(mState, playerside); - lua_setglobal(mState, "blobby_side"); + + // set game constants + lua_pushnumber(mState, RIGHT_PLANE); + lua_setglobal(mState, "CONST_FIELD_WIDTH"); + lua_pushnumber(mState, 600 - GROUND_PLANE_HEIGHT_MAX); + lua_setglobal(mState, "CONST_GROUND_HEIGHT"); + lua_pushnumber(mState, -BALL_GRAVITATION); + lua_setglobal(mState, "CONST_BALL_GRAVITY"); + lua_pushnumber(mState, BALL_RADIUS); + lua_setglobal(mState, "CONST_BALL_RADIUS"); + lua_pushnumber(mState, BLOBBY_JUMP_ACCELERATION); + lua_setglobal(mState, "CONST_BLOBBY_JUMP"); + lua_pushnumber(mState, BLOBBY_LOWER_RADIUS); + lua_setglobal(mState, "CONST_BLOBBY_BODY_RADIUS"); + lua_pushnumber(mState, BLOBBY_UPPER_RADIUS); + lua_setglobal(mState, "CONST_BLOBBY_HEAD_RADIUS"); + lua_pushnumber(mState, BLOBBY_HEIGHT); + lua_setglobal(mState, "CONST_BLOBBY_HEIGHT"); + lua_pushnumber(mState, -GRAVITATION); + lua_setglobal(mState, "CONST_BLOBBY_GRAVITY"); + lua_pushnumber(mState, 600 - NET_SPHERE_POSITION); + lua_setglobal(mState, "CONST_NET_HEIGHT"); + lua_pushnumber(mState, NET_RADIUS); + lua_setglobal(mState, "CONST_NET_RADIUS"); + + luaopen_math(mState); lua_register(mState, "touches", touches); lua_register(mState, "launched", launched); @@ -79,6 +160,20 @@ lua_register(mState, "estimate", estimate); lua_register(mState, "estimx", estimx); lua_register(mState, "estimy", estimy); + lua_register(mState, "timetox", timetox); + lua_register(mState, "timetoy", timetoy); + lua_register(mState, "predictx", predictx); + lua_register(mState, "predicty", predicty); + lua_register(mState, "xaty", xaty); + lua_register(mState, "yatx", yatx); + lua_register(mState, "nextevent", nextevent); + lua_register(mState, "predictImpact", predictImpact); + lua_register(mState, "getScore", getScore); + lua_register(mState, "getOppScore", getOppScore); + lua_register(mState, "getScoreToWin", getScoreToWin); + lua_register(mState, "getGameTime", getGameTime); + + //lua_register(mState, "parabel", parabel); ReaderInfo info; info.handle = PHYSFS_openRead(filename.c_str()); @@ -91,7 +186,7 @@ PHYSFS_close(info.handle); if (error == 0) error = lua_pcall(mState, 0, 6, 0); - if (error) + if (error) { std::cerr << "Lua Error: " << lua_tostring(mState, -1); std::cerr << std::endl; @@ -101,7 +196,47 @@ lua_close(mState); throw except; } + + + // check whether all required lua functions are available + bool onserve, ongame, onoppserve; + lua_getglobal(mState, "OnServe"); + onserve = lua_isfunction(mState, -1); + lua_getglobal(mState, "OnGame"); + ongame = lua_isfunction(mState, -1); + lua_getglobal(mState, "OnOpponentServe"); + onoppserve = lua_isfunction(mState, -1); + if (!onserve || !ongame ||!onoppserve) + { + std::string error_message = "Missing bot function "; + error_message += onserve ? "" : "OnServe() "; + error_message += ongame ? "" : "OnGame() "; + error_message += onoppserve ? "" : "OnOpponentServe() "; + std::cerr << "Lua Error: " << error_message << std::endl; + + ScriptException except; + except.luaerror = error_message; + lua_pop(mState, 1); + lua_close(mState); + throw except; + } + + // record which of the optional functions are available + lua_getglobal(mState, "OnBounce"); + mOnBounce = lua_isfunction(mState, -1); + + if(!mOnBounce) std::cerr << "Lua Warning: Missing function OnBounce" << std::endl; + lua_pop(mState, lua_gettop(mState)); + + // init delay + mBallPositions.set_capacity(mMaxDelay + 1); + mBallVelocities.set_capacity(mMaxDelay + 1); + + for(unsigned int i = 0; i < mMaxDelay + 1; ++i) { + mBallPositions.push_back(Vector2(0,0)); + mBallVelocities.push_back(Vector2(0,0)); + } } ScriptedInputSource::~ScriptedInputSource() @@ -112,59 +247,79 @@ PlayerInput ScriptedInputSource::getInput() { bool serving = false; - lua_pushboolean(mState, false); - lua_pushboolean(mState, false); - lua_pushboolean(mState, false); - lua_setglobal(mState, "blobby_moveleft"); - lua_setglobal(mState, "blobby_moveright"); - lua_setglobal(mState, "blobby_moveup"); - - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) + // reset input + mLeft = false; + mRight = false; + mJump = false; + + mCurrentSource = this; + mMatch = DuelMatch::getMainGame(); + if (mMatch == 0) { return PlayerInput(); } - PlayerSide player = getSide(mState); - int error; - if (!match->getBallActive() && player == match->getServingPlayer()) + // ball position and velocity update + mBallPositions.push_back(mMatch->getBallPosition()); + mBallVelocities.push_back(mMatch->getBallVelocity()); + + // adapt current delay + char action = rand() % 8; + switch(action) { + case 0: + case 1: + mCurDelay--; + break; + case 2: + case 3: + mCurDelay++; + } + + if ( mLastBallSpeed != DuelMatch::getMainGame()->getBallVelocity().x ) { + mLastBallSpeed = DuelMatch::getMainGame()->getBallVelocity().x; + // reaction time after bounce + mCurDelay += rand() % (mMaxDelay+1); + } + + if(mCurDelay == -1) + mCurDelay = 0; + if(mCurDelay > mMaxDelay) + mCurDelay = mMaxDelay; + + int error = 0; + + if (!mMatch->getBallActive() && mSide == + // if no player is serving player, assume the left one is + (mMatch->getServingPlayer() == NO_PLAYER ? LEFT_PLAYER : mMatch->getServingPlayer() )) { serving = true; lua_getglobal(mState, "OnServe"); - if (!lua_isfunction(mState, -1)) - { - lua_pop(mState, 1); - std::cerr << "Lua Error: Could not find function "; - std::cerr << "OnServe()" << std::endl; - return PlayerInput(); - } - lua_pushboolean(mState, !match->getBallDown()); + lua_pushboolean(mState, !mMatch->getBallDown()); error = lua_pcall(mState, 1, 0, 0); } - else if (!match->getBallActive() && player != match->getServingPlayer()) + else if (!mMatch->getBallActive() && mCurrentSource->mSide != + (mMatch->getServingPlayer() == NO_PLAYER ? LEFT_PLAYER : mMatch->getServingPlayer() )) { lua_getglobal(mState, "OnOpponentServe"); - if (!lua_isfunction(mState, -1)) - { - lua_pop(mState, 1); - std::cerr << "Lua Error: Could not find function "; - std::cerr << "OnOpponentServe()" << std::endl; - return PlayerInput(); - } error = lua_pcall(mState, 0, 0, 0); } else { - lua_getglobal(mState, "OnGame"); - if (!lua_isfunction(mState, -1)) - { - lua_pop(mState, 1); - std::cerr << "Lua Error: Could not find function "; - std::cerr << "OnGame()" << std::endl; - return PlayerInput(); + if ( mOnBounce && mLastBallSpeedVirtual != getBallVelocity().x ) { + mLastBallSpeedVirtual = getBallVelocity().x; + lua_getglobal(mState, "OnBounce"); + error = lua_pcall(mState, 0, 0, 0); + if (error) + { + std::cerr << "Lua Error: " << lua_tostring(mState, -1); + std::cerr << std::endl; + lua_pop(mState, 1); + } } + lua_getglobal(mState, "OnGame"); error = lua_pcall(mState, 0, 0, 0); } + if (error) { std::cerr << "Lua Error: " << lua_tostring(mState, -1); @@ -172,14 +327,10 @@ lua_pop(mState, 1); } - lua_getglobal(mState, "blobby_moveleft"); - lua_getglobal(mState, "blobby_moveright"); - lua_getglobal(mState, "blobby_moveup"); - bool wantLeft = lua_toboolean(mState, -3); - bool wantRight = lua_toboolean(mState, -2); - bool wantUp = lua_toboolean(mState, -1); - lua_pop(mState, 3); - PlayerInput currentInput = PlayerInput(wantLeft, wantRight, wantUp); + // swap left/right if side is swapped + if ( mSide == RIGHT_PLAYER ) + std::swap(mLeft, mRight); + PlayerInput currentInput = PlayerInput(mLeft, mRight, mJump); int stacksize = lua_gettop(mState); if (stacksize > 0) @@ -196,38 +347,20 @@ return currentInput; } -PlayerSide ScriptedInputSource::getSide(lua_State* state) -{ - lua_getglobal(state, "blobby_side"); - PlayerSide player = (PlayerSide)lua_tonumber(state, -1); - lua_pop(state, 1); - return player; +void ScriptedInputSource::setflags(lua_State* state) { + lua_pushnumber(state, FLAG_BOUNCE); + lua_setglobal(state, "FLAG_BOUNCE"); } int ScriptedInputSource::touches(lua_State* state) { - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) - { - lua_pushnumber(state, 0); - return 1; - } - lua_getglobal(state, "blobby_side"); - PlayerSide player = (PlayerSide)lua_tonumber(state, -1); - lua_pop(state, -1); - lua_pushnumber(state, match->getHitcount(player)); + lua_pushnumber(state, mMatch->getHitcount(mCurrentSource->mSide)); return 1; } int ScriptedInputSource::launched(lua_State* state) { - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) - { - lua_pushboolean(state, false); - return 1; - } - lua_pushnumber(state, match->getBlobJump(getSide(state))); + lua_pushnumber(state, mMatch->getBlobJump(mCurrentSource->mSide)); return 1; } @@ -241,32 +374,19 @@ int ScriptedInputSource::jump(lua_State* state) { - lua_pushboolean(state, true); - lua_setglobal(state, "blobby_moveup"); + mCurrentSource->mJump = true; return 0; } int ScriptedInputSource::left(lua_State* state) { - lua_pushboolean(state, true); - if (getSide(state) == LEFT_PLAYER) - lua_setglobal(state, "blobby_moveleft"); - else if (getSide(state) == RIGHT_PLAYER) - lua_setglobal(state, "blobby_moveright"); - else - lua_pop(state, 1); + mCurrentSource->mLeft = true; return 0; } int ScriptedInputSource::right(lua_State* state) { - lua_pushboolean(state, true); - if (getSide(state) == LEFT_PLAYER) - lua_setglobal(state, "blobby_moveright"); - else if (getSide(state) == RIGHT_PLAYER) - lua_setglobal(state, "blobby_moveleft"); - else - lua_pop(state, 1); + mCurrentSource->mRight = true; return 0; } @@ -274,196 +394,236 @@ { float target = lua_tonumber(state, -1); lua_pop(state, 1); - DuelMatch* match = DuelMatch::getMainGame(); - if (match != 0) - { - PlayerSide player = getSide(state); - float position = match->getBlobPosition(player).x; - if (player == RIGHT_PLAYER) - { -// target = 800.0 - target; - position = 800.0 - position; - } - if (position > target + 2) - left(state); - if (position < target - 2) - right(state); - } + coordinate position = mMatch->getBlobPosition(mCurrentSource->mSide).x; + + if (position > target + 2) + mCurrentSource->mLeft = true; + if (position < target - 2) + mCurrentSource->mRight = true; return 0; } +const Vector2& ScriptedInputSource::getBallPosition() { + return mCurrentSource->mBallPositions[mCurrentSource->mMaxDelay - mCurrentSource->mCurDelay]; +} +const Vector2& ScriptedInputSource::getBallVelocity() { + return mCurrentSource->mBallVelocities[mCurrentSource->mMaxDelay - mCurrentSource->mCurDelay]; +} + int ScriptedInputSource::ballx(lua_State* state) { - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) - { - lua_pushnumber(state, 400.0); - return 1; - } - float pos = match->getBallPosition().x; - if (getSide(state) == RIGHT_PLAYER) - pos = 800.0 - pos; + coordinate pos = getBallPosition().x; lua_pushnumber(state, pos); return 1; } int ScriptedInputSource::bally(lua_State* state) { - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) - { - lua_pushnumber(state, 150.0); - return 1; - } - float pos = match->getBallPosition().y; - pos = 600.0 - pos; + coordinate pos = getBallPosition().y; lua_pushnumber(state, pos); return 1; } int ScriptedInputSource::bspeedx(lua_State* state) { - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) - { - lua_pushnumber(state, 0.0); - return 1; - } - float vel = match->getBallVelocity().x; - if (getSide(state) == RIGHT_PLAYER) - vel = -vel; + coordinate vel = getBallVelocity().x; lua_pushnumber(state, vel); return 1; } int ScriptedInputSource::bspeedy(lua_State* state) { - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) - { - lua_pushnumber(state, 0.0); - return 1; - } - float vel = match->getBallVelocity().y; - vel = -vel; + coordinate vel = getBallVelocity().y; lua_pushnumber(state, vel); return 1; } int ScriptedInputSource::posx(lua_State* state) { - PlayerSide player = getSide(state); - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) - { - lua_pushnumber(state, 0.0); - return 1; - } - float pos = match->getBlobPosition(player).x; - if (player == RIGHT_PLAYER) - pos = 800.0 - pos; + coordinate pos = mMatch->getBlobPosition(mCurrentSource->mSide).x; lua_pushnumber(state, pos); return 1; } int ScriptedInputSource::posy(lua_State* state) { - lua_getglobal(state, "blobby_side"); - PlayerSide player = (PlayerSide)lua_tonumber(state, -1); - lua_pop(state, 1); - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) - { - lua_pushnumber(state, 0.0); - return 1; - } - float pos = match->getBlobPosition(player).y; - pos = 600.0 - pos; + coordinate pos = mMatch->getBlobPosition(mCurrentSource->mSide).y; lua_pushnumber(state, pos); return 1; } int ScriptedInputSource::oppx(lua_State* state) { - PlayerSide player = getSide(state); - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) - { - lua_pushnumber(state, 0.0); - return 1; - } PlayerSide invPlayer = - player == LEFT_PLAYER ? RIGHT_PLAYER : LEFT_PLAYER; - float pos = match->getBlobPosition(invPlayer).x; - if (invPlayer == LEFT_PLAYER) - pos = 800.0 - pos; + mCurrentSource->mSide == LEFT_PLAYER ? RIGHT_PLAYER : LEFT_PLAYER; + coordinate pos = mMatch->getBlobPosition(invPlayer).x; lua_pushnumber(state, pos); return 1; } int ScriptedInputSource::oppy(lua_State* state) { - PlayerSide player = getSide(state); - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) - { - lua_pushnumber(state, 0.0); - return 1; - } PlayerSide invPlayer = - player == LEFT_PLAYER ? RIGHT_PLAYER : LEFT_PLAYER; - float pos = match->getBlobPosition(invPlayer).y; - pos = 600.0 - pos; + mCurrentSource->mSide == LEFT_PLAYER ? RIGHT_PLAYER : LEFT_PLAYER; + coordinate pos = mMatch->getBlobPosition(invPlayer).y; lua_pushnumber(state, pos); return 1; } int ScriptedInputSource::estimate(lua_State* state) { - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) + static bool warning_issued = false; + if( !warning_issued ) { - lua_pushnumber(state, 400.0); - return 1; + warning_issued = true; + std::cerr << "Lua Warning: function estimate() is deprecated!" << std::endl; } - float estim = match->getBallEstimation(); - if (getSide(state) == RIGHT_PLAYER) - estim = 800.0 - estim; + + Vector2 pos = getBallPosition(); + const Vector2& vel = getBallVelocity(); + + float time = (vel.y - std::sqrt((vel.y * vel.y)- (-2 * BALL_GRAVITATION * (-pos.y + GROUND_PLANE_HEIGHT_MAX - BALL_RADIUS)))) / (-BALL_GRAVITATION); + + coordinate estim = pos.x + vel.x * time; + lua_pushnumber(state, estim); return 1; } int ScriptedInputSource::estimx(lua_State* state) { - int num = lround(lua_tonumber(state, -1)); - lua_pop(state, 1); - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) + static bool warning_issued = false; + if( !warning_issued ) { - lua_pushnumber(state, 0.0); - return 1; + warning_issued = true; + std::cerr << "Lua Warning: function estimx() is deprecated!" << std::endl; } - float estim = match->getBallTimeEstimation(num).x; - if (getSide(state) == RIGHT_PLAYER) - estim = 800.0 - estim; + int num = lround(lua_tonumber(state, -1)); + lua_pop(state, 1); + coordinate estim = getBallPosition().x + num * getBallVelocity().x; + lua_pushnumber(state, estim); return 1; } int ScriptedInputSource::estimy(lua_State* state) { - int num = lround(lua_tonumber(state, -1)); - lua_pop(state, 1); - DuelMatch* match = DuelMatch::getMainGame(); - if (match == 0) + static bool warning_issued = false; + if( !warning_issued ) { - lua_pushnumber(state, 0.0); - return 1; + warning_issued = true; + std::cerr << "Lua Warning: function estimy() is deprecated!" << std::endl; } - float estim = match->getBallTimeEstimation(num).y; - estim = 600.0 - estim; + int num = lround(lua_tonumber(state, -1)); + lua_pop(state, 1); + coordinate estim = getBallPosition().y + num * (getBallVelocity().y + 0.5*BALL_GRAVITATION*num); lua_pushnumber(state, estim); return 1; } +int ScriptedInputSource::predictx(lua_State* state) { + reset_flags(); + float time = lua_tonumber(state, -1); + lua_pop(state, 1); + coordinate estim = predict_x(getBallPosition(), getBallVelocity(), time); + lua_pushnumber(state, estim); + setflags(state); + return 1; +} +int ScriptedInputSource::predicty(lua_State* state) { + reset_flags(); + float time = lua_tonumber(state, -1); + lua_pop(state, 1); + coordinate estim = predict_y(getBallPosition(), getBallVelocity(), time); + lua_pushnumber(state, estim); + setflags(state); + return 1; +} +int ScriptedInputSource::timetox(lua_State* state) { + reset_flags(); + coordinate destination = lua_tonumber(state, -1); + lua_pop(state, 1); + + float time = time_to_x(getBallPosition(), getBallVelocity(), destination); + + lua_pushnumber(state, time); + setflags(state); + return 1; +} +int ScriptedInputSource::timetoy(lua_State* state) { + reset_flags(); + coordinate destination = lua_tonumber(state, -1); + lua_pop(state, 1); + + float time = time_to_y(getBallPosition(), getBallVelocity(), destination); + + lua_pushnumber(state, time); + setflags(state); + return 1; +} +int ScriptedInputSource::xaty(lua_State* state) { + reset_flags(); + coordinate destination = lua_tonumber(state, -1); + lua_pop(state, 1); + + coordinate x = x_at_y(getBallPosition(), getBallVelocity(), destination); + + lua_pushnumber(state, x); + setflags(state); + return 1; +} +int ScriptedInputSource::yatx(lua_State* state) { + reset_flags(); + coordinate destination = lua_tonumber(state, -1); + lua_pop(state, 1); + + coordinate y = y_at_x(getBallPosition(), getBallVelocity(), destination); + lua_pushnumber(state, y); + setflags(state); + return 1; +} + +int ScriptedInputSource::predictImpact(lua_State* state) { + reset_flags(); + coordinate x = x_at_y(getBallPosition(), getBallVelocity(), GROUND_PLANE_HEIGHT_MAX - BLOBBY_HEIGHT - BALL_RADIUS); + lua_pushnumber(state, x); + setflags(state); + return 1; +} + +int ScriptedInputSource::nextevent(lua_State* state) { + reset_flags(); + float time = next_event(getBallPosition(), getBallVelocity()); + lua_pushnumber(state, time); + setflags(state); + return 1; +} + +int ScriptedInputSource::getScore(lua_State* state) +{ + float score = mMatch->getScore( mCurrentSource->mSide ); + lua_pushnumber(state, score); + return 1; +} + +int ScriptedInputSource::getOppScore(lua_State* state) +{ + float score = mMatch->getScore( mCurrentSource->mSide == LEFT_PLAYER ? RIGHT_PLAYER: LEFT_PLAYER ); + lua_pushnumber(state, score); + return 1; +} + +int ScriptedInputSource::getScoreToWin(lua_State* state) +{ + float score = mMatch->getScoreToWin(); + lua_pushnumber(state, score); + return 1; +} + +int ScriptedInputSource::getGameTime(lua_State* state) +{ + float time = mMatch->getClock().getTime(); + lua_pushnumber(state, time); + return 1; +} diff -Nru blobby-0.8-dfsg/src/ScriptedInputSource.h blobby-0.9c/src/ScriptedInputSource.h --- blobby-0.8-dfsg/src/ScriptedInputSource.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/ScriptedInputSource.h 2011-11-06 15:06:46.000000000 +0000 @@ -21,9 +21,10 @@ #include "Global.h" #include "InputSource.h" +#include "Vector.h" +#include -#include - +#include // ScriptedInputSource provides an implementation of InputSource, which uses // Lua scripts to get its input. The given script is automatically initialised // and provided with an interface to the game. @@ -34,6 +35,7 @@ const int WAITING_TIME = 1500; class lua_State; +class DuelMatch; class ScriptedInputSource : public InputSource { @@ -41,35 +43,92 @@ // The constructor automatically loads and initializes the script // with the given filename. The side parameter tells the script // which side is it on. - ScriptedInputSource(const std::string& filename, PlayerSide side); + ScriptedInputSource(const std::string& filename, PlayerSide side, unsigned int difficulty); ~ScriptedInputSource(); virtual PlayerInput getInput(); private: - static PlayerSide getSide(lua_State* state); + // this variable saves the current match + // it is set each step in getInput + // as in current design, only in single match mode bots are allowed + // it would even be enough to set it once, but we may change this + // for making bot tournaments^^, so the idea of setting it for each + // bot seems better to me + static DuelMatch* mMatch; + static ScriptedInputSource* mCurrentSource; - static int side(lua_State* state); - static int touches(lua_State* state); - static int balldown(lua_State* state); - static int launched(lua_State* state); + // helpers static int debug(lua_State* state); + static void setflags(lua_State* state); + // coordinate system conversion + template + struct coordinate; + + // commands static int jump(lua_State* state); static int left(lua_State* state); static int right(lua_State* state); static int moveto(lua_State* state); + + // ball information + // internals + static const Vector2& getBallPosition(); + static const Vector2& getBallVelocity(); + static int touches(lua_State* state); static int ballx(lua_State* state); static int bally(lua_State* state); static int bspeedx(lua_State* state); static int bspeedy(lua_State* state); + + // blob information + static int launched(lua_State* state); static int posx(lua_State* state); static int posy(lua_State* state); static int oppx(lua_State* state); static int oppy(lua_State* state); - static int estimate(lua_State* state); - static int estimx(lua_State* state); - static int estimy(lua_State* state); + + // game status + static int getScore(lua_State* state); + static int getOppScore(lua_State* state); + static int getScoreToWin(lua_State* state); + static int getGameTime(lua_State* state); + + // predictions + static int estimate(lua_State* state); // deprecated + static int estimx(lua_State* state); // deprecated + static int estimy(lua_State* state); // deprecated + + static int predictx(lua_State* state); + static int predicty(lua_State* state); + static int timetox(lua_State* state); + static int timetoy(lua_State* state); + static int xaty(lua_State* state); + static int yatx(lua_State* state); + + static int nextevent(lua_State* state); + static int predictImpact(lua_State* state); + lua_State* mState; unsigned int mStartTime; + + // ki strength values + unsigned int mMaxDelay; + unsigned int mCurDelay; + + // which functions are available + bool mOnBounce; + + // ball position and velocity in adapted coordinate system + boost::circular_buffer mBallPositions; + boost::circular_buffer mBallVelocities; + + float mLastBallSpeed; + float mLastBallSpeedVirtual; + + PlayerSide mSide; + + // input data + bool mLeft, mRight, mJump; }; diff -Nru blobby-0.8-dfsg/src/SoundManager.cpp blobby-0.9c/src/SoundManager.cpp --- blobby-0.8-dfsg/src/SoundManager.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/SoundManager.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -153,6 +153,9 @@ std::list::iterator nextIter = ++iter; playingSound.erase(eraseIter); iter = nextIter; + // prevents increment of past-end-interator + if(iter == playingSound.end()) + break; } else { diff -Nru blobby-0.8-dfsg/src/SoundManager.h blobby-0.9c/src/SoundManager.h --- blobby-0.8-dfsg/src/SoundManager.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/SoundManager.h 2011-11-06 15:06:46.000000000 +0000 @@ -20,7 +20,7 @@ #pragma once #include -#include +#include #include #include diff -Nru blobby-0.8-dfsg/src/SpeedController.cpp blobby-0.9c/src/SpeedController.cpp --- blobby-0.8-dfsg/src/SpeedController.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/SpeedController.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =============================================================================*/ -#include +#include // for std::max #include "SpeedController.h" #include @@ -45,7 +45,7 @@ mGameFPS = fps; } -bool SpeedController::doFramedrop() +bool SpeedController::doFramedrop() const { return mFramedrop; } diff -Nru blobby-0.8-dfsg/src/SpeedController.h blobby-0.9c/src/SpeedController.h --- blobby-0.8-dfsg/src/SpeedController.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/SpeedController.h 2011-11-06 15:06:46.000000000 +0000 @@ -36,14 +36,15 @@ ~SpeedController(); void setGameSpeed(float fps); + float getGameSpeed() const{return mGameFPS;} // This reports whether a framedrop is necessary to hold the real FPS - bool doFramedrop(); + bool doFramedrop() const; //gives the caller the fps of the drawed frames: - int getFPS() { return mFPS; } + int getFPS() const { return mFPS; } void setDrawFPS(bool draw) { mDrawFPS = draw; } //help methods - bool getDrawFPS() { return mDrawFPS; } + bool getDrawFPS() const { return mDrawFPS; } // This updates everything and waits the necessary time void update(); diff -Nru blobby-0.8-dfsg/src/state/LocalGameState.cpp blobby-0.9c/src/state/LocalGameState.cpp --- blobby-0.8-dfsg/src/state/LocalGameState.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/state/LocalGameState.cpp 2011-11-06 15:06:44.000000000 +0000 @@ -20,6 +20,7 @@ #include "LocalGameState.h" #include +#include #include "DuelMatch.h" #include "InputManager.h" @@ -27,6 +28,9 @@ #include "ReplayRecorder.h" #include "SoundManager.h" #include "TextManager.h" +#include "SpeedController.h" +#include "Blood.h" +#include LocalGameState::~LocalGameState() { @@ -40,24 +44,25 @@ mLeftPlayer(LEFT_PLAYER), mRightPlayer(RIGHT_PLAYER) { - mPaused = false; mSaveReplay = false; mWinner = false; - std::stringstream temp; - temp << time(0); - mFilename = temp.str(); + mFilename = boost::lexical_cast (std::time(0)); mLeftPlayer.loadFromConfig("left"); mRightPlayer.loadFromConfig("right"); + UserConfig gameConfig; + gameConfig.loadFile("config.xml"); + SpeedController::getMainInstance()->setGameSpeed((float)gameConfig.getInteger("gamefps")); + SoundManager::getSingleton().playSound("sounds/pfiff.wav", ROUND_START_SOUND_VOLUME); mRecorder = new ReplayRecorder(MODE_RECORDING_DUEL); mRecorder->setPlayerNames(mLeftPlayer.getName(), mRightPlayer.getName()); mRecorder->setServingPlayer(LEFT_PLAYER); - mMatch = new DuelMatch(mLeftPlayer.getInputSource(), mRightPlayer.getInputSource(), true, true); + mMatch = new DuelMatch(mLeftPlayer.getInputSource(), mRightPlayer.getInputSource(), true, false); RenderManager::getSingleton().setPlayernames(mLeftPlayer.getName(), mRightPlayer.getName()); IMGUI::getSingleton().resetSelection(); @@ -90,16 +95,17 @@ } imgui.doCursor(); } - else if (mPaused) + else if (mMatch->isPaused()) { imgui.doOverlay(GEN_ID, Vector2(180, 200), Vector2(670, 400)); imgui.doText(GEN_ID, Vector2(281, 260), TextManager::getSingleton()->getString(TextManager::LBL_CONF_QUIT)); - if (imgui.doButton(GEN_ID, Vector2(530, 300), TextManager::getSingleton()->getString(TextManager::LBL_NO))) - mPaused = false; + if (imgui.doButton(GEN_ID, Vector2(530, 300), TextManager::getSingleton()->getString(TextManager::LBL_NO))){ + mMatch->unpause(); + } if (imgui.doButton(GEN_ID, Vector2(260, 300), TextManager::getSingleton()->getString(TextManager::LBL_YES))) { - delete this; - mCurrentState = new MainMenuState; + deleteCurrentState(); + setCurrentState(new MainMenuState); } if (imgui.doButton(GEN_ID, Vector2(293, 340), TextManager::getSingleton()->getString(TextManager::RP_SAVE))) { @@ -123,13 +129,13 @@ imgui.doText(GEN_ID, Vector2(274, 300), TextManager::getSingleton()->getString(TextManager::GAME_WIN)); if (imgui.doButton(GEN_ID, Vector2(290, 350), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { - delete mCurrentState; - mCurrentState = new MainMenuState(); + deleteCurrentState(); + setCurrentState(new MainMenuState()); } if (imgui.doButton(GEN_ID, Vector2(400, 350), TextManager::getSingleton()->getString(TextManager::GAME_TRY_AGAIN))) { - delete mCurrentState; - mCurrentState = new LocalGameState(); + deleteCurrentState(); + setCurrentState(new LocalGameState()); } if (imgui.doButton(GEN_ID, Vector2(320, 390), TextManager::getSingleton()->getString(TextManager::RP_SAVE))) { @@ -145,21 +151,21 @@ mSaveReplay = false; IMGUI::getSingleton().resetSelection(); } - else if (mPaused) + else if (mMatch->isPaused()) { - delete this; - mCurrentState = new MainMenuState; + deleteCurrentState(); + setCurrentState(new MainMenuState); } else { RenderManager::getSingleton().redraw(); - mPaused = true; + mMatch->pause(); } } else if (mRecorder->endOfFile()) { - delete this; - mCurrentState = new MainMenuState; + deleteCurrentState(); + setCurrentState(new MainMenuState); } else { @@ -169,6 +175,7 @@ if (mMatch->winningPlayer() != NO_PLAYER) mWinner = true; + presentGame(*mMatch); rmanager->setBlobColor(LEFT_PLAYER, mLeftPlayer.getColor()); rmanager->setBlobColor(RIGHT_PLAYER, mRightPlayer.getColor()); } diff -Nru blobby-0.8-dfsg/src/state/LocalGameState.h blobby-0.9c/src/state/LocalGameState.h --- blobby-0.8-dfsg/src/state/LocalGameState.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/state/LocalGameState.h 2011-11-06 15:06:44.000000000 +0000 @@ -28,9 +28,6 @@ Player mLeftPlayer; Player mRightPlayer; - bool mLeftOscillate; - bool mRightOscillate; - bool mPaused; bool mSaveReplay; bool mWinner; std::string mFilename; diff -Nru blobby-0.8-dfsg/src/state/NetworkState.cpp blobby-0.9c/src/state/NetworkState.cpp --- blobby-0.8-dfsg/src/state/NetworkState.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/state/NetworkState.cpp 2011-11-06 15:06:44.000000000 +0000 @@ -19,25 +19,29 @@ #include #include +#include #include "NetworkState.h" #include "NetworkMessage.h" #include "NetworkGame.h" #include "TextManager.h" - -#include "ReplayRecorder.h" +#include "Blood.h" #include "raknet/RakClient.h" #include "raknet/PacketEnumerations.h" #include "raknet/GetTime.h" +#include + +#include + #include "IMGUI.h" #include "SoundManager.h" #include "LocalInputSource.h" #include "raknet/RakServer.h" +#include "RakNetPacket.h" // We don't need the stringcompressor - NetworkSearchState::NetworkSearchState() { IMGUI::getSingleton().resetSelection(); @@ -47,25 +51,11 @@ mEnteringServer = false; mPingClient = new RakClient; - broadcast(); } NetworkSearchState::~NetworkSearchState() { - UserConfig config; - try - { - config.loadFile("config.xml"); - if (mScannedServers.size() > 0) - config.setString("network_last_server", - mScannedServers.at(mSelectedServer).hostname); - config.saveFile("config.xml"); - } - catch (std::exception& e) - { - std::cerr << "ERROR! in ~NetworkSearchState() " << e.what() << std::endl; - } - + // Disconnect from servers for (ClientList::iterator iter = mQueryClients.begin(); iter != mQueryClients.end(); iter++) { @@ -79,15 +69,16 @@ } void NetworkSearchState::step() -{ - Packet* packet; - +{ + packet_ptr packet; + for (ClientList::iterator iter = mQueryClients.begin(); iter != mQueryClients.end(); iter++) { bool skip = false; + bool skip_iter = false; if (!skip) - while ((packet = (*iter)->Receive()) && !skip) + while ((packet = receivePacket(*iter)) && !skip) { switch(packet->data[0]) { @@ -98,43 +89,55 @@ packet->playerId)); RakNet::BitStream stream; - stream.Write(ID_BLOBBY_SERVER_PRESENT); + stream.Write((unsigned char)ID_BLOBBY_SERVER_PRESENT); stream.Write(BLOBBY_VERSION_MAJOR); stream.Write(BLOBBY_VERSION_MINOR); - (*iter)->Send(&stream, HIGH_PRIORITY, + (*iter)->Send(&stream, LOW_PRIORITY, RELIABLE_ORDERED, 0); break; } case ID_BLOBBY_SERVER_PRESENT: { + //FIXME: We must copy the needed informations, so that we can call DeallocatePacket(packet) + //FIXME: The client finds a server at this point, which is not valid RakNet::BitStream stream((char*)packet->data, packet->length, false); printf("server is a blobby server\n"); - int ival; - stream.Read(ival); + stream.IgnoreBytes(1); //ID_BLOBBY_SERVER_PRESENT ServerInfo info(stream, (*iter)->PlayerIDToDottedIP( packet->playerId)); + if (std::find( mScannedServers.begin(), mScannedServers.end(), - info) == mScannedServers.end()) + info) == mScannedServers.end() + // check whether the packet sizes match + && packet->length == ServerInfo::BLOBBY_SERVER_PRESENT_PACKET_SIZE ){ mScannedServers.push_back(info); + } + // the RakClient will be deleted, so + // we must free the packet here + packet.reset(); (*iter)->Disconnect(50); delete *iter; iter = mQueryClients.erase(iter); + if (iter == mQueryClients.end()) + skip_iter = true; skip = true; break; } default: break; } + if (skip) break; } + if (skip_iter) + break; } - - while (packet = mPingClient->Receive()) + while (packet = receivePacket(mPingClient)) { switch (packet->data[0]) { @@ -144,7 +147,7 @@ printf("got ping response by \"%s\", trying to connect\n", hostname.c_str()); RakClient* newClient = new RakClient; newClient->Connect( - hostname.c_str(), BLOBBY_PORT, 0, 0, 0); + hostname.c_str(), BLOBBY_PORT, 0, 0, RAKNET_THREAD_SLEEP_TIME); mQueryClients.push_back(newClient); } default: @@ -165,7 +168,7 @@ } if (imgui.doButton(GEN_ID, Vector2(10, 20), TextManager::getSingleton()->getString(TextManager::NET_SERVER_SCAN))) - broadcast(); + searchServers(); if (imgui.doButton(GEN_ID, Vector2(420, 20), TextManager::getSingleton()->getString(TextManager::NET_DIRECT_CONNECT)) && !mEnteringServer) @@ -201,8 +204,8 @@ if (imgui.doButton(GEN_ID, Vector2(270.0, 300.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { //std::string server = mScannedServers[mSelectedServer].hostname; - delete this; - mCurrentState = new NetworkGameState(mEnteredServer.c_str(), BLOBBY_PORT); + deleteCurrentState(); + setCurrentState(new NetworkGameState(mEnteredServer.c_str(), BLOBBY_PORT)); return; } if (imgui.doButton(GEN_ID, Vector2(370.0, 300.0), TextManager::getSingleton()->getString(TextManager::LBL_CANCEL))) @@ -228,10 +231,14 @@ waitingplayer << TextManager::getSingleton()->getString(TextManager::NET_WAITING_PLAYER) << mScannedServers[mSelectedServer].waitingplayer; imgui.doText(GEN_ID, Vector2(50, 190), waitingplayer.str()); + std::stringstream gamespeed; + gamespeed << TextManager::getSingleton()->getString(TextManager::OP_SPEED)<<" " + << int(100.0 / 75.0 * mScannedServers[mSelectedServer].gamespeed)<<"%"; + imgui.doText(GEN_ID, Vector2(50, 220), gamespeed.str()); std::string description = mScannedServers[mSelectedServer].description; for (int i = 0; i < description.length(); i += 29) { - imgui.doText(GEN_ID, Vector2(50, 220 + i / 29 * 30), + imgui.doText(GEN_ID, Vector2(50, 250 + i / 29 * 30), description.substr(i, 29)); } @@ -246,8 +253,8 @@ if (imgui.doButton(GEN_ID, Vector2(450, 480), TextManager::getSingleton()->getString(TextManager::NET_HOST_GAME)) && !mDisplayInfo) { - delete this; - mCurrentState = new NetworkHostState(); + deleteCurrentState(); + setCurrentState(new NetworkHostState()); return; } @@ -255,68 +262,94 @@ && !mScannedServers.empty()) { std::string server = mScannedServers[mSelectedServer].hostname; - delete this; - mCurrentState = new NetworkGameState(server.c_str(), BLOBBY_PORT); + deleteCurrentState(); + setCurrentState(new NetworkGameState(server.c_str(), BLOBBY_PORT)); } if (imgui.doButton(GEN_ID, Vector2(480, 530), TextManager::getSingleton()->getString(TextManager::LBL_CANCEL))) { - delete this; - mCurrentState = new MainMenuState; + deleteCurrentState(); + setCurrentState(new MainMenuState); } } -void NetworkSearchState::broadcast() +// the different networkmodi classes (online/LAN) +OnlineSearchState::OnlineSearchState() +{ + searchServers(); +} + + +void OnlineSearchState::searchServers() { mScannedServers.clear(); - mPingClient->PingServer("255.255.255.255", BLOBBY_PORT, 0, true); - mPingClient->PingServer("blobby.openanno.org", BLOBBY_PORT, 0, true); + //TODO: Insert Masterserverconnection code here! At the moment we are using the old code here! + mPingClient->PingServer("blobby.blub-game.com", BLOBBY_PORT, 0, true); + mPingClient->PingServer("pgb.game-host.org", BLOBBY_PORT, 0, true); + UserConfig config; config.loadFile("config.xml"); mPingClient->PingServer( config.getString("network_last_server").c_str(), BLOBBY_PORT, 0, true); + +} + +LANSearchState::LANSearchState() +{ + searchServers(); } -NetworkGameState::NetworkGameState(const std::string& servername, Uint16 port) +void LANSearchState::searchServers() { + mScannedServers.clear(); + mPingClient->PingServer("255.255.255.255", BLOBBY_PORT, 0, true); +} + +NetworkGameState::NetworkGameState(const std::string& servername, Uint16 port): + mLeftPlayer(LEFT_PLAYER), + mRightPlayer(RIGHT_PLAYER) +{ IMGUI::getSingleton().resetSelection(); mWinningPlayer = NO_PLAYER; UserConfig config; config.loadFile("config.xml"); mOwnSide = (PlayerSide)config.getInteger("network_side"); + mUseRemoteColor = config.getBool("use_remote_color"); mLocalInput = new LocalInputSource(mOwnSide); mSaveReplay = false; - std::stringstream temp; - temp << time(0); - mFilename = temp.str(); - - // FIXME: We load the colors from config atm - mLeftColor = Color(config.getInteger("left_blobby_color_r"), - config.getInteger("left_blobby_color_g"), - config.getInteger("left_blobby_color_b")); - mRightColor = Color(config.getInteger("right_blobby_color_r"), - config.getInteger("right_blobby_color_g"), - config.getInteger("right_blobby_color_b")); - mLeftOscillate = config.getBool("left_blobby_oscillate"); - mRightOscillate = config.getBool("right_blobby_oscillate"); + mFilename = boost::lexical_cast (std::time(0)); - RenderManager::getSingleton().setBlobColor(0, mLeftColor); - RenderManager::getSingleton().setBlobColor(1, mRightColor); RenderManager::getSingleton().redraw(); mClient = new RakClient(); - if (mClient->Connect(servername.c_str(), port, 0, 0, 0)) + if (mClient->Connect(servername.c_str(), port, 0, 0, RAKNET_THREAD_SLEEP_TIME)) mNetworkState = CONNECTING; else mNetworkState = CONNECTION_FAILED; - mPhysicWorld.resetPlayer(); - - mReplayRecorder = new ReplayRecorder(MODE_RECORDING_DUEL); - - mFakeMatch = new DuelMatch(0, 0, false, true); - mFakeMatch->setPlayerName(config.getString(mOwnSide ? "right_player_name" : "left_player_name")); + mFakeMatch = new DuelMatch(0, 0, true, true); + // game is not started until two players are connected + mFakeMatch->pause(); + + // load/init players + mLeftPlayer.loadFromConfig("left", false); + mRightPlayer.loadFromConfig("right", false); + if(mOwnSide == LEFT_PLAYER){ + mRightPlayer.setName(""); + mLocalPlayer = &mLeftPlayer; + mRemotePlayer = &mRightPlayer; + }else{ + mLeftPlayer.setName(""); + mLocalPlayer = &mRightPlayer; + mRemotePlayer = &mLeftPlayer; + } + RenderManager::getSingleton().setScore(0, 0, false, false); + RenderManager::getSingleton().setPlayernames(mLeftPlayer.getName(), mRightPlayer.getName()); + + mSelectedChatmessage = 0; + mChatCursorPosition = 0; + mChattext = ""; } NetworkGameState::~NetworkGameState() @@ -324,7 +357,6 @@ mClient->Disconnect(50); delete mLocalInput; delete mClient; - delete mReplayRecorder; delete mFakeMatch; } @@ -333,27 +365,27 @@ IMGUI& imgui = IMGUI::getSingleton(); RenderManager* rmanager = &RenderManager::getSingleton(); - Packet* packet; - while (packet = mClient->Receive()) + packet_ptr packet; + while (packet = receivePacket(mClient)) { switch(packet->data[0]) { case ID_CONNECTION_REQUEST_ACCEPTED: { RakNet::BitStream stream; - stream.Write(ID_ENTER_GAME); + stream.Write((unsigned char)ID_ENTER_GAME); stream.Write(mOwnSide); // Send playername char myname[16]; - strncpy(myname, mFakeMatch->getPlayerName().c_str(), sizeof(myname)); + strncpy(myname, mLocalPlayer->getName().c_str(), sizeof(myname)); stream.Write(myname, sizeof(myname)); - mClient->Send(&stream, HIGH_PRIORITY, RELIABLE_ORDERED, 0); + // send color settings + stream.Write(mLocalPlayer->getColor().toInt()); - // Send playercolor + mClient->Send(&stream, HIGH_PRIORITY, RELIABLE_ORDERED, 0); - RenderManager::getSingleton().setPlayernames(mOwnSide ? "" : mFakeMatch->getPlayerName(), mOwnSide ? mFakeMatch->getPlayerName() : ""); mNetworkState = WAITING_FOR_OPPONENT; break; } @@ -361,22 +393,25 @@ { RakNet::BitStream stream((char*)packet->data, packet->length, false); int ival; - stream.Read(ival); - stream.Read(ival); //ID_TIMESTAMP + stream.IgnoreBytes(1); //ID_PHYSIC_UPDATE + stream.IgnoreBytes(1); //ID_TIMESTAMP stream.Read(ival); //TODO: un-lag based on timestamp delta - RakNet::BitStream streamCopy = RakNet::BitStream(stream); //printf("Physic packet received. Time: %d\n", ival); - mPhysicWorld.setState(&stream); - mFakeMatch->setState(&streamCopy); - mReplayRecorder->record(mPhysicWorld.getPlayersInput()); + mFakeMatch->setState(&stream); break; } case ID_WIN_NOTIFICATION: { - int ival; RakNet::BitStream stream((char*)packet->data, packet->length, false); - stream.Read(ival); + stream.IgnoreBytes(1); //ID_WIN_NOTIFICATION stream.Read((int&)mWinningPlayer); + + // last point must not be added anymore, because + // the score is also simulated local so it is already + // right. under strange circumstances this need not + // be true, but then the score is set to the correy value + // by ID_BALL_RESET + mNetworkState = PLAYER_WON; break; } @@ -389,45 +424,74 @@ } case ID_BALL_RESET: { - int ival; RakNet::BitStream stream((char*)packet->data, packet->length, false); - stream.Read(ival); + stream.IgnoreBytes(1); //ID_BALL_RESET stream.Read((int&)mServingPlayer); - stream.Read(mLeftScore); - stream.Read(mRightScore); - mPhysicWorld.reset(mServingPlayer); - if (mLeftScore == 0 && mRightScore == 0) - mReplayRecorder->setServingPlayer(mServingPlayer); - rmanager->setScore(mLeftScore, mRightScore, - mServingPlayer == 0, mServingPlayer == 1); + + // read and set new score + int nLeftScore; + int nRightScore; + int time; + stream.Read(nLeftScore); + stream.Read(nRightScore); + stream.Read(time); + mFakeMatch->setScore(nLeftScore, nRightScore); + mFakeMatch->setServingPlayer(mServingPlayer); + // sync the clocks... normally, they should not differ + mFakeMatch->getClock().setTime(time); break; } case ID_BALL_GROUND_COLLISION: { - SoundManager::getSingleton().playSound("sounds/pfiff.wav", ROUND_START_SOUND_VOLUME); - mPhysicWorld.setBallValidity(false); + int side; + RakNet::BitStream stream((char*)packet->data, packet->length, false); + stream.IgnoreBytes(1); //ID_BALL_GROUND_COLLISION + stream.Read(side); + switch((PlayerSide)side){ + case LEFT_PLAYER: + mFakeMatch->trigger(DuelMatch::EVENT_BALL_HIT_LEFT_GROUND); + break; + case RIGHT_PLAYER: + mFakeMatch->trigger(DuelMatch::EVENT_BALL_HIT_RIGHT_GROUND); + break; + default: + assert(0); + } break; } case ID_BALL_PLAYER_COLLISION: { - int ival; float intensity; + int side; RakNet::BitStream stream((char*)packet->data, packet->length, false); - stream.Read(ival); + stream.IgnoreBytes(1); //ID_PLAYER_BALL_COLLISION + // FIXME ensure that this intensity is used stream.Read(intensity); - SoundManager::getSingleton().playSound("sounds/bums.wav", - intensity + BALL_HIT_PLAYER_SOUND_VOLUME); - mPhysicWorld.setBallValidity(false); + stream.Read(side); + switch((PlayerSide)side){ + case LEFT_PLAYER: + mFakeMatch->trigger(DuelMatch::EVENT_LEFT_BLOBBY_HIT); + break; + case RIGHT_PLAYER: + mFakeMatch->trigger(DuelMatch::EVENT_RIGHT_BLOBBY_HIT); + break; + default: + assert(0); + } break; } case ID_PAUSE: - if (mNetworkState = PLAYING) + if (mNetworkState == PLAYING) + { mNetworkState = PAUSING; + mFakeMatch->pause(); + } break; case ID_UNPAUSE: if (mNetworkState == PAUSING) { mNetworkState = PLAYING; + mFakeMatch->unpause(); } break; case ID_GAME_READY: @@ -435,31 +499,47 @@ char charName[16]; RakNet::BitStream stream((char*)packet->data, packet->length, false); - // ignore ID_GAME_READY - stream.IgnoreBits(8 * sizeof(ID_GAME_READY)); + stream.IgnoreBytes(1); // ignore ID_GAME_READY + // read gamespeed + int speed; + stream.Read(speed); + SpeedController::getMainInstance()->setGameSpeed(speed); + // read playername stream.Read(charName, sizeof(charName)); // ensures that charName is null terminated charName[sizeof(charName)-1] = '\0'; - mFakeMatch->setOpponentName(std::string(charName)); - if (mOwnSide) - { - RenderManager::getSingleton().setPlayernames(mFakeMatch->getOpponentName(), mFakeMatch->getPlayerName()); - mReplayRecorder->setPlayerNames(mFakeMatch->getOpponentName(), mFakeMatch->getPlayerName()); - } - else - { - RenderManager::getSingleton().setPlayernames(mFakeMatch->getPlayerName(), mFakeMatch->getOpponentName()); - mReplayRecorder->setPlayerNames(mFakeMatch->getPlayerName(), mFakeMatch->getOpponentName()); + // read colors + int temp; + stream.Read(temp); + Color ncolor = temp; + + mRemotePlayer->setName(std::string(charName)); + + // set names in render manager + RenderManager::getSingleton().setPlayernames(mLeftPlayer.getName(), mRightPlayer.getName()); + + // check whether to use remote player color + if(mUseRemoteColor){ + mRemotePlayer->setColor(ncolor); + RenderManager::getSingleton().setBlobColor(LEFT_PLAYER, mLeftPlayer.getColor()); + RenderManager::getSingleton().setBlobColor(RIGHT_PLAYER, mRightPlayer.getColor()); + RenderManager::getSingleton().redraw(); } + // Workarround for SDL-Renderer // Hides the GUI when networkgame starts rmanager->redraw(); mNetworkState = PLAYING; + // start game + mFakeMatch->unpause(); + + // game ready whistle + SoundManager::getSingleton().playSound("sounds/pfiff.wav", ROUND_START_SOUND_VOLUME); break; } case ID_CONNECTION_ATTEMPT_FAILED: @@ -482,39 +562,60 @@ break; case ID_REMOTE_EXISTING_CONNECTION: break; + case ID_CHAT_MESSAGE: + { + RakNet::BitStream stream((char*)packet->data, packet->length, false); + stream.IgnoreBytes(1); // ID_CHAT_MESSAGE + // Insert Message in the log and focus the last element + char message[31]; + stream.Read(message, sizeof(message)); + message[30] = '\0'; + + // Insert Message in the log and focus the last element + mChatlog.push_back((std::string) message); + mSelectedChatmessage = mChatlog.size() - 1; + SoundManager::getSingleton().playSound("sounds/chat.wav", ROUND_START_SOUND_VOLUME); + break; + } + case ID_REPLAY: + { + RakNet::BitStream stream((char*)packet->data, packet->length, false); + stream.IgnoreBytes(1); // ID_REPLAY + int length; + stream.Read(length); + char* data = new char[length]; + stream.Read(data, length); + PHYSFS_file* fileHandle = PHYSFS_openWrite((std::string("replays/") + mFilename + std::string(".bvr")).c_str()); + if (!fileHandle) + { + std::cerr << "Warning: Unable to write to "; + std::cerr << PHYSFS_getWriteDir() << std::string("replays/") + mFilename + std::string(".bvr"); + std::cerr << std::endl; + return; + } + + PHYSFS_write(fileHandle, data, 1, length); + PHYSFS_close(fileHandle); + break; + } default: printf("Received unknown Packet %d\n", packet->data[0]); + std::cout<data<<"\n"; break; } - mClient->DeallocatePacket(packet); } PlayerInput input = mNetworkState == PLAYING ? mLocalInput->getInput() : PlayerInput(); - rmanager->setBlob(0, mPhysicWorld.getBlob(LEFT_PLAYER), - mPhysicWorld.getBlobState(LEFT_PLAYER)); - rmanager->setBlob(1, mPhysicWorld.getBlob(RIGHT_PLAYER), - mPhysicWorld.getBlobState(RIGHT_PLAYER)); - rmanager->setBall(mPhysicWorld.getBall(), - mPhysicWorld.getBallRotation()); - - float time = float(SDL_GetTicks()) / 1000.0; - if (mLeftOscillate) - rmanager->setBlobColor(0, Color( - int((sin(time*2) + 1.0) * 128), - int((sin(time*4) + 1.0) * 128), - int((sin(time*3) + 1.0) * 128))); - if (mRightOscillate) - rmanager->setBlobColor(1, Color( - int((cos(time*2) + 1.0) * 128), - int((cos(time*4) + 1.0) * 128), - int((cos(time*3) + 1.0) * 128))); + presentGame(*mFakeMatch); + rmanager->setBlobColor(LEFT_PLAYER, mLeftPlayer.getColor()); + rmanager->setBlobColor(RIGHT_PLAYER, mRightPlayer.getColor()); if (InputManager::getSingleton()->exit() && mNetworkState != PLAYING) { - delete mCurrentState; - mCurrentState = new MainMenuState; + deleteCurrentState(); + setCurrentState(new MainMenuState); } else if (InputManager::getSingleton()->exit() && mSaveReplay) { @@ -531,7 +632,10 @@ { if (mFilename != "") { - mReplayRecorder->save(std::string("replays/") + mFilename + std::string(".bvr")); + // request replay from server + RakNet::BitStream stream; + stream.Write((unsigned char)ID_REPLAY); + mClient->Send(&stream, LOW_PRIORITY, RELIABLE_ORDERED, 0); } mSaveReplay = false; imgui.resetSelection(); @@ -571,8 +675,8 @@ if (imgui.doButton(GEN_ID, Vector2(230.0, 300.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { - delete mCurrentState; - mCurrentState = new MainMenuState; + deleteCurrentState(); + setCurrentState(new MainMenuState); } if (imgui.doButton(GEN_ID, Vector2(350.0, 300.0), TextManager::getSingleton()->getString(TextManager::RP_SAVE))) { @@ -591,8 +695,8 @@ if (imgui.doButton(GEN_ID, Vector2(230.0, 320.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { - delete mCurrentState; - mCurrentState = new MainMenuState; + deleteCurrentState(); + setCurrentState(new MainMenuState); } if (imgui.doButton(GEN_ID, Vector2(350.0, 320.0), TextManager::getSingleton()->getString(TextManager::RP_SAVE))) { @@ -611,8 +715,8 @@ if (imgui.doButton(GEN_ID, Vector2(350.0, 300.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { - delete mCurrentState; - mCurrentState = new MainMenuState; + deleteCurrentState(); + setCurrentState(new MainMenuState); } break; } @@ -626,24 +730,24 @@ if (imgui.doButton(GEN_ID, Vector2(350.0, 300.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { - delete mCurrentState; - mCurrentState = new MainMenuState; + deleteCurrentState(); + setCurrentState(new MainMenuState); } break; } case PLAYING: { - mPhysicWorld.step(); mFakeMatch->step(); + if (InputManager::getSingleton()->exit()) { RakNet::BitStream stream; - stream.Write(ID_PAUSE); + stream.Write((unsigned char)ID_PAUSE); mClient->Send(&stream, HIGH_PRIORITY, RELIABLE_ORDERED, 0); } RakNet::BitStream stream; - stream.Write(ID_INPUT_UPDATE); - stream.Write(ID_TIMESTAMP); + stream.Write((unsigned char)ID_INPUT_UPDATE); + stream.Write((unsigned char)ID_TIMESTAMP); stream.Write(RakNet::GetTime()); stream.Write(input.left); stream.Write(input.right); @@ -655,17 +759,17 @@ { std::stringstream tmp; if(mWinningPlayer==LEFT_PLAYER) - tmp << (mOwnSide ? mFakeMatch->getOpponentName() : mFakeMatch->getPlayerName()); + tmp << mLeftPlayer.getName(); else - tmp << (mOwnSide ? mFakeMatch->getPlayerName() : mFakeMatch->getOpponentName()); + tmp << mRightPlayer.getName(); imgui.doOverlay(GEN_ID, Vector2(200, 150), Vector2(700, 450)); imgui.doImage(GEN_ID, Vector2(200, 250), "gfx/pokal.bmp"); imgui.doText(GEN_ID, Vector2(274, 240), tmp.str()); imgui.doText(GEN_ID, Vector2(274, 300), TextManager::getSingleton()->getString(TextManager::GAME_WIN)); if (imgui.doButton(GEN_ID, Vector2(290, 360), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { - delete mCurrentState; - mCurrentState = new MainMenuState(); + deleteCurrentState(); + setCurrentState(new MainMenuState()); } if (imgui.doButton(GEN_ID, Vector2(380, 360), TextManager::getSingleton()->getString(TextManager::RP_SAVE))) { @@ -677,20 +781,42 @@ } case PAUSING: { - imgui.doOverlay(GEN_ID, Vector2(200, 200), Vector2(650, 400)); - imgui.doText(GEN_ID, Vector2(300, 260), TextManager::getSingleton()->getString(TextManager::GAME_PAUSED)); - if (imgui.doButton(GEN_ID, Vector2(230, 330), TextManager::getSingleton()->getString(TextManager::LBL_CONTINUE))) + imgui.doOverlay(GEN_ID, Vector2(200, 30), Vector2(650, 180)); + imgui.doText(GEN_ID, Vector2(300, 40), TextManager::getSingleton()->getString(TextManager::GAME_PAUSED)); + if (imgui.doButton(GEN_ID, Vector2(230, 100), TextManager::getSingleton()->getString(TextManager::LBL_CONTINUE))) { RakNet::BitStream stream; - stream.Write(ID_UNPAUSE); + stream.Write((unsigned char)ID_UNPAUSE); mClient->Send(&stream, HIGH_PRIORITY, RELIABLE_ORDERED, 0); } - if (imgui.doButton(GEN_ID, Vector2(500, 330), TextManager::getSingleton()->getString(TextManager::GAME_QUIT))) + // Chat + imgui.doSelectbox(GEN_ID, Vector2(10, 190), Vector2(790, 450), mChatlog, mSelectedChatmessage); + if (imgui.doEditbox(GEN_ID, Vector2(10, 460), 30, mChattext, mChatCursorPosition)) + { + + // GUI-Hack, so that we can send messages + if ((InputManager::getSingleton()->getLastActionKey() == "return") && (mChattext != "")) + { + RakNet::BitStream stream; + char message[31]; + + strncpy(message, mChattext.c_str(), sizeof(message)); + stream.Write((unsigned char)ID_CHAT_MESSAGE); + stream.Write(message, sizeof(message)); + mClient->Send(&stream, LOW_PRIORITY, RELIABLE_ORDERED, 0); + mChatlog.push_back(mChattext); + mSelectedChatmessage = mChatlog.size() - 1; + mChattext = ""; + mChatCursorPosition = 0; + SoundManager::getSingleton().playSound("sounds/chat.wav", ROUND_START_SOUND_VOLUME); + } + } + if (imgui.doButton(GEN_ID, Vector2(500, 100), TextManager::getSingleton()->getString(TextManager::GAME_QUIT))) { - delete this; - mCurrentState = new MainMenuState; + deleteCurrentState(); + setCurrentState(new MainMenuState); } - if (imgui.doButton(GEN_ID, Vector2(310, 370), TextManager::getSingleton()->getString(TextManager::RP_SAVE))) + if (imgui.doButton(GEN_ID, Vector2(310, 130), TextManager::getSingleton()->getString(TextManager::RP_SAVE))) { mSaveReplay = true; imgui.resetSelection(); @@ -712,24 +838,25 @@ NetworkHostState::~NetworkHostState() { delete mGameState; - if (mNetworkGame) - delete mNetworkGame; + delete mNetworkGame; mServer->Disconnect(1); delete mServer; } void NetworkHostState::step() { - Packet* packet; - while (packet = mServer->Receive()) + packet_ptr packet; + while (packet = receivePacket(mServer)) { switch (packet->data[0]) { case ID_DISCONNECTION_NOTIFICATION: case ID_CONNECTION_LOST: case ID_INPUT_UPDATE: + case ID_CHAT_MESSAGE: case ID_PAUSE: case ID_UNPAUSE: + case ID_REPLAY: { if (packet->playerId == mLocalPlayer || packet->playerId == mRemotePlayer) @@ -754,7 +881,7 @@ sizeof(myinfo.waitingplayer) - 1); } RakNet::BitStream stream; - stream.Write(ID_BLOBBY_SERVER_PRESENT); + stream.Write((unsigned char)ID_BLOBBY_SERVER_PRESENT); myinfo.writeToBitstream(stream); mServer->Send(&stream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, @@ -767,15 +894,18 @@ RakNet::BitStream stream((char*)packet->data, packet->length, false); - // ignore ID_ENTER_GAME - stream.IgnoreBits(8 * sizeof(ID_ENTER_GAME)); + stream.IgnoreBytes(1); //ID_ENTER_GAME - // read playername + // read playername and side stream.Read(ival); char charName[16]; stream.Read(charName, sizeof(charName)); + // read colour data + int color; + stream.Read(color); + // ensures that charName is null terminated charName[sizeof(charName)-1] = '\0'; @@ -787,6 +917,16 @@ mLocalPlayerSide = newSide; mLocalPlayer = packet->playerId; mLocalPlayerName = playerName; + + // set the color + switch(newSide){ + case LEFT_PLAYER: + mLeftColor = color; + break; + case RIGHT_PLAYER: + mRightColor = color; + break; + } } else { @@ -804,6 +944,8 @@ rightPlayer = packet->playerId; leftPlayerName = mLocalPlayerName; rightPlayerName = playerName; + // set other color + mRightColor = color; } else { @@ -811,6 +953,8 @@ rightPlayer = mLocalPlayer; leftPlayerName = playerName; rightPlayerName = mLocalPlayerName; + // set other color + mLeftColor = color; } PlayerSide switchSide = NO_PLAYER; @@ -825,13 +969,14 @@ mNetworkGame = new NetworkGame( *mServer, leftPlayer, rightPlayer, leftPlayerName, rightPlayerName, + mLeftColor, mRightColor, switchSide); } } } } mGameState->step(); - if (dynamic_cast(mCurrentState) != 0) + if (dynamic_cast(getCurrentState()) != 0) { if (mNetworkGame) { diff -Nru blobby-0.8-dfsg/src/state/NetworkState.h blobby-0.9c/src/state/NetworkState.h --- blobby-0.8-dfsg/src/state/NetworkState.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/state/NetworkState.h 2011-11-06 15:06:44.000000000 +0000 @@ -38,14 +38,19 @@ virtual ~NetworkSearchState(); virtual void step(); -private: - void broadcast(); + // onlinegames connect to the masterserver + // LAN games send a broadcast to local network + virtual void searchServers() = 0; + +protected: + std::vector mScannedServers; + RakClient* mPingClient; +private: typedef std::list ClientList; - RakClient* mPingClient; - std::vector mScannedServers; + ClientList mQueryClients; int mSelectedServer; @@ -56,12 +61,29 @@ unsigned mServerBoxPosition; }; +class OnlineSearchState : public NetworkSearchState +{ +public: + OnlineSearchState(); + virtual ~OnlineSearchState() {}; + virtual void searchServers(); +}; + +class LANSearchState : public NetworkSearchState +{ +public: + LANSearchState(); + virtual ~LANSearchState() {}; + virtual void searchServers(); +}; + class NetworkGameState : public State { public: NetworkGameState(const std::string& servername, Uint16 port); virtual ~NetworkGameState(); virtual void step(); + private: enum { @@ -76,15 +98,15 @@ PAUSING } mNetworkState; - Color mLeftColor; - Color mRightColor; - bool mLeftOscillate; - bool mRightOscillate; + Player mLeftPlayer; + Player mRightPlayer; + + Player* mLocalPlayer; + Player* mRemotePlayer; + + bool mUseRemoteColor; InputSource* mLocalInput; - PhysicWorld mPhysicWorld; - int mLeftScore; - int mRightScore; PlayerSide mServingPlayer; bool mSaveReplay; @@ -94,9 +116,14 @@ PlayerSide mOwnSide; PlayerSide mWinningPlayer; - ReplayRecorder* mReplayRecorder; DuelMatch* mFakeMatch; // This hack is necessary to let MouseInputDevice // access the necessary game variables + + // Chat Vars + std::vector mChatlog; + int mSelectedChatmessage; + unsigned mChatCursorPosition; + std::string mChattext; }; @@ -118,6 +145,8 @@ PlayerSide mLocalPlayerSide; PlayerID mLocalPlayer; PlayerID mRemotePlayer; + Color mLeftColor; + Color mRightColor; std::string mLocalPlayerName; std::string mRemotePlayerName; }; diff -Nru blobby-0.8-dfsg/src/state/OptionsState.cpp blobby-0.9c/src/state/OptionsState.cpp --- blobby-0.8-dfsg/src/state/OptionsState.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/state/OptionsState.cpp 2011-11-06 15:06:44.000000000 +0000 @@ -29,6 +29,7 @@ #include #include +#include OptionState::OptionState() { @@ -64,6 +65,9 @@ mPlayerName[RIGHT_PLAYER] = mOptionConfig.getString("right_player_name"); mPlayerNamePosition[RIGHT_PLAYER] = 0; mPlayerNamePosition[LEFT_PLAYER] = 0; + + mBotStrength[LEFT_PLAYER] = mOptionConfig.getInteger("left_script_strength"); + mBotStrength[RIGHT_PLAYER] = mOptionConfig.getInteger("right_script_strength"); } OptionState::~OptionState() @@ -97,12 +101,16 @@ } mOptionConfig.setString("left_player_name", mPlayerName[LEFT_PLAYER]); mOptionConfig.setString("right_player_name", mPlayerName[RIGHT_PLAYER]); + mOptionConfig.setInteger("left_script_strength", mBotStrength[LEFT_PLAYER]); + mOptionConfig.setInteger("right_script_strength", mBotStrength[RIGHT_PLAYER]); mOptionConfig.saveFile("config.xml"); } } void OptionState::step() { + const int MAX_BOT_DELAY = 25; // 25 frames = 0.33s (gamespeed: normal) + IMGUI& imgui = IMGUI::getSingleton(); imgui.doCursor(); imgui.doImage(GEN_ID, Vector2(400.0, 300.0), "background"); @@ -113,36 +121,53 @@ imgui.doSelectbox(GEN_ID, Vector2(5.0, 50.0), Vector2(375.0, 300.0), mScriptNames, mPlayerOptions[LEFT_PLAYER]); imgui.doSelectbox(GEN_ID, Vector2(425.0, 50.0), Vector2(795.0, 300.0), mScriptNames, mPlayerOptions[RIGHT_PLAYER]); + + imgui.doText(GEN_ID, Vector2(270.0, 310.0), TextManager::getSingleton()->getString(TextManager::OP_DIFFICULTY) ); + + float f = 1.f - (float)mBotStrength[0] / MAX_BOT_DELAY; + imgui.doScrollbar(GEN_ID, Vector2(15.0, 350.0), f); + mBotStrength[0] = static_cast ((1.f-f) * MAX_BOT_DELAY + 0.5f); + imgui.doText(GEN_ID, Vector2(235.0, 350.0), f > 0.66 ? TextManager::getSingleton()->getString(TextManager::OP_STRONG) : + (f > 0.33 ? TextManager::getSingleton()->getString(TextManager::OP_MEDIUM): + TextManager::getSingleton()->getString(TextManager::OP_WEAK))); + + f = 1.f - (float)mBotStrength[1] / MAX_BOT_DELAY; + imgui.doScrollbar(GEN_ID, Vector2(440.0, 350.0), f); + mBotStrength[1] = static_cast ((1.f - f) * MAX_BOT_DELAY + 0.5f); + imgui.doText(GEN_ID, Vector2(660.0, 350.0), f > 0.66 ? TextManager::getSingleton()->getString(TextManager::OP_STRONG) : + (f > 0.33 ? TextManager::getSingleton()->getString(TextManager::OP_MEDIUM): + TextManager::getSingleton()->getString(TextManager::OP_WEAK))); - if (imgui.doButton(GEN_ID, Vector2(40.0, 360.0), TextManager::getSingleton()->getString(TextManager::OP_INPUT_OP))) + if (imgui.doButton(GEN_ID, Vector2(40.0, 390.0), TextManager::getSingleton()->getString(TextManager::OP_INPUT_OP))) { mSaveConfig = true; - delete this; - mCurrentState = new InputOptionsState(); + deleteCurrentState(); + setCurrentState(new InputOptionsState()); } - if (imgui.doButton(GEN_ID, Vector2(40.0, 400.0), TextManager::getSingleton()->getString(TextManager::OP_GFX_OP))) + if (imgui.doButton(GEN_ID, Vector2(40.0, 430.0), TextManager::getSingleton()->getString(TextManager::OP_GFX_OP))) { mSaveConfig = true; - delete this; - mCurrentState = new GraphicOptionsState(); + deleteCurrentState(); + setCurrentState(new GraphicOptionsState()); } - if (imgui.doButton(GEN_ID, Vector2(40.0, 440.0), TextManager::getSingleton()->getString(TextManager::OP_MISC))) + if (imgui.doButton(GEN_ID, Vector2(40.0, 470.0), TextManager::getSingleton()->getString(TextManager::OP_MISC))) { mSaveConfig = true; - delete this; - mCurrentState = new MiscOptionsState(); + deleteCurrentState(); + setCurrentState(new MiscOptionsState()); } if (imgui.doButton(GEN_ID, Vector2(224.0, 530.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { mSaveConfig = true; - delete this; - mCurrentState = new MainMenuState(); + deleteCurrentState(); + deleteCurrentState(); + setCurrentState(new MainMenuState()); } if (imgui.doButton(GEN_ID, Vector2(424.0, 530.0), TextManager::getSingleton()->getString(TextManager::LBL_CANCEL))) { - delete this; - mCurrentState = new MainMenuState(); + deleteCurrentState(); + setCurrentState(new MainMenuState()); } } @@ -161,6 +186,7 @@ mB2 = mOptionConfig.getInteger("right_blobby_color_b"); mLeftMorphing = mOptionConfig.getBool("left_blobby_oscillate"); mRightMorphing = mOptionConfig.getBool("right_blobby_oscillate"); + mShowShadow = mOptionConfig.getBool("show_shadow"); } GraphicOptionsState::~GraphicOptionsState() @@ -179,7 +205,17 @@ RenderManager::getSingleton().setBackground( std::string("backgrounds/") + mOptionConfig.getString("background")); + RenderManager::getSingleton().showShadow(mShowShadow); } + else + { + if(mOptionConfig.getBool("show_shadow") != mShowShadow) + { + RenderManager::getSingleton().showShadow(mShowShadow); + mOptionConfig.setBool("show_shadow", mShowShadow); + } + } + mOptionConfig.setInteger("left_blobby_color_r", mR1); mOptionConfig.setInteger("left_blobby_color_g", mG1); mOptionConfig.setInteger("left_blobby_color_b", mB1); @@ -200,58 +236,68 @@ imgui.doImage(GEN_ID, Vector2(400.0, 300.0), "background"); imgui.doOverlay(GEN_ID, Vector2(0.0, 0.0), Vector2(800.0, 600.0)); - imgui.doText(GEN_ID, Vector2(34.0, 50.0), TextManager::getSingleton()->getString(TextManager::OP_VIDEO)); + imgui.doText(GEN_ID, Vector2(34.0, 10.0), TextManager::getSingleton()->getString(TextManager::OP_VIDEO)); - if (imgui.doButton(GEN_ID, Vector2(34.0, 80.0), TextManager::getSingleton()->getString(TextManager::OP_FULLSCREEN))) + if (imgui.doButton(GEN_ID, Vector2(34.0, 40.0), TextManager::getSingleton()->getString(TextManager::OP_FULLSCREEN))) mFullscreen = true; - if (imgui.doButton(GEN_ID, Vector2(34.0, 110.0), TextManager::getSingleton()->getString(TextManager::OP_WINDOW))) + if (imgui.doButton(GEN_ID, Vector2(34.0, 70.0), TextManager::getSingleton()->getString(TextManager::OP_WINDOW))) mFullscreen = false; if (mFullscreen) - imgui.doImage(GEN_ID, Vector2(18.0, 92.0), "gfx/pfeil_rechts.bmp"); + imgui.doImage(GEN_ID, Vector2(18.0, 52.0), "gfx/pfeil_rechts.bmp"); else - imgui.doImage(GEN_ID, Vector2(18.0, 122.0), "gfx/pfeil_rechts.bmp"); + imgui.doImage(GEN_ID, Vector2(18.0, 82.0), "gfx/pfeil_rechts.bmp"); - imgui.doText(GEN_ID, Vector2(444.0, 50.0), TextManager::getSingleton()->getString(TextManager::OP_RENDER_DEVICE)); - if (imgui.doButton(GEN_ID, Vector2(444.0, 80.0), "OpenGL")) + imgui.doText(GEN_ID, Vector2(444.0, 10.0), TextManager::getSingleton()->getString(TextManager::OP_RENDER_DEVICE)); + if (imgui.doButton(GEN_ID, Vector2(444.0, 40.0), "OpenGL")) mRenderer = "OpenGL"; - if (imgui.doButton(GEN_ID, Vector2(444.0, 110.0), "SDL")) + if (imgui.doButton(GEN_ID, Vector2(444.0, 70.0), "SDL")) mRenderer = "SDL"; if (mRenderer == "OpenGL") - imgui.doImage(GEN_ID, Vector2(428.0, 92.0), "gfx/pfeil_rechts.bmp"); + imgui.doImage(GEN_ID, Vector2(428.0, 52.0), "gfx/pfeil_rechts.bmp"); else - imgui.doImage(GEN_ID, Vector2(428.0, 122.0), "gfx/pfeil_rechts.bmp"); + imgui.doImage(GEN_ID, Vector2(428.0, 82.0), "gfx/pfeil_rechts.bmp"); + + imgui.doText(GEN_ID, Vector2(34.0, 110.0), TextManager::getSingleton()->getString(TextManager::OP_SHOW_SHADOW)); + if (imgui.doButton(GEN_ID, Vector2(72.0, 140), TextManager::getSingleton()->getString(TextManager::LBL_YES))) + mShowShadow = true; + if (imgui.doButton(GEN_ID, Vector2(220.0, 140), TextManager::getSingleton()->getString(TextManager::LBL_NO))) + mShowShadow = false; + if (mShowShadow) + imgui.doImage(GEN_ID, Vector2(54.0, 152.0), "gfx/pfeil_rechts.bmp"); + else + imgui.doImage(GEN_ID, Vector2(204.0, 152.0), "gfx/pfeil_rechts.bmp"); //Blob colors: - imgui.doText(GEN_ID, Vector2(280.0, 170.0), TextManager::getSingleton()->getString(TextManager::OP_BLOB_COLORS)); + imgui.doText(GEN_ID, Vector2(280.0, 190.0), TextManager::getSingleton()->getString(TextManager::OP_BLOB_COLORS)); //left blob: - imgui.doText(GEN_ID, Vector2(34.0, 220.0), TextManager::getSingleton()->getString(TextManager::OP_LEFT_PLAYER)); + imgui.doText(GEN_ID, Vector2(34.0, 230.0), TextManager::getSingleton()->getString(TextManager::OP_LEFT_PLAYER)); { - imgui.doText(GEN_ID, Vector2(34.0, 250), TextManager::getSingleton()->getString(TextManager::OP_RED)); + imgui.doText(GEN_ID, Vector2(34.0, 260), TextManager::getSingleton()->getString(TextManager::OP_RED)); float r1 = (float)mR1/255; - imgui.doScrollbar(GEN_ID, Vector2(160.0, 250.0), r1); + imgui.doScrollbar(GEN_ID, Vector2(160.0, 260.0), r1); mR1 = (int)(r1*255); } { - imgui.doText(GEN_ID, Vector2(34.0, 280), TextManager::getSingleton()->getString(TextManager::OP_GREEN)); + imgui.doText(GEN_ID, Vector2(34.0, 290), TextManager::getSingleton()->getString(TextManager::OP_GREEN)); float g1 = (float)mG1/255; - imgui.doScrollbar(GEN_ID, Vector2(160.0, 280.0), g1); + imgui.doScrollbar(GEN_ID, Vector2(160.0, 290.0), g1); mG1 = (int)(g1*255); } { - imgui.doText(GEN_ID, Vector2(34.0, 310), TextManager::getSingleton()->getString(TextManager::OP_BLUE)); + imgui.doText(GEN_ID, Vector2(34.0, 320), TextManager::getSingleton()->getString(TextManager::OP_BLUE)); float b1 = (float)mB1/255; - imgui.doScrollbar(GEN_ID, Vector2(160.0, 310), b1); + imgui.doScrollbar(GEN_ID, Vector2(160.0, 320), b1); mB1 = (int)(b1*255); } - imgui.doText(GEN_ID, Vector2(34.0, 350), TextManager::getSingleton()->getString(TextManager::OP_MORPHING)); - if (imgui.doButton(GEN_ID, Vector2(72.0, 380), TextManager::getSingleton()->getString(TextManager::LBL_YES))) + imgui.doText(GEN_ID, Vector2(34.0, 360), TextManager::getSingleton()->getString(TextManager::OP_MORPHING)); + if (imgui.doButton(GEN_ID, Vector2(72.0, 390), TextManager::getSingleton()->getString(TextManager::LBL_YES))) mLeftMorphing = true; - if (imgui.doButton(GEN_ID, Vector2(220.0, 380), TextManager::getSingleton()->getString(TextManager::LBL_NO))) + if (imgui.doButton(GEN_ID, Vector2(220.0, 390), TextManager::getSingleton()->getString(TextManager::LBL_NO))) mLeftMorphing = false; if (mLeftMorphing) - imgui.doImage(GEN_ID, Vector2(54.0, 392.0), "gfx/pfeil_rechts.bmp"); + imgui.doImage(GEN_ID, Vector2(54.0, 402.0), "gfx/pfeil_rechts.bmp"); else - imgui.doImage(GEN_ID, Vector2(204.0, 392.0), "gfx/pfeil_rechts.bmp"); + imgui.doImage(GEN_ID, Vector2(204.0, 402.0), "gfx/pfeil_rechts.bmp"); //draw left blob: { float time = float(SDL_GetTicks()) / 1000.0; @@ -260,38 +306,38 @@ ourCol = Color(int((sin(time*2) + 1.0) * 128), int((sin(time*4) + 1.0) * 128), int((sin(time*3) + 1.0) * 128)); - imgui.doBlob(GEN_ID, Vector2(120, 490), ourCol); + imgui.doBlob(GEN_ID, Vector2(110, 500), ourCol); } //right blob: - imgui.doText(GEN_ID, Vector2(434.0, 220.0), TextManager::getSingleton()->getString(TextManager::OP_RIGHT_PLAYER)); + imgui.doText(GEN_ID, Vector2(434.0, 230.0), TextManager::getSingleton()->getString(TextManager::OP_RIGHT_PLAYER)); { - imgui.doText(GEN_ID, Vector2(434.0, 250), TextManager::getSingleton()->getString(TextManager::OP_RED)); + imgui.doText(GEN_ID, Vector2(434.0, 260), TextManager::getSingleton()->getString(TextManager::OP_RED)); float r2 = (float)mR2/255; - imgui.doScrollbar(GEN_ID, Vector2(560.0, 250.0), r2); + imgui.doScrollbar(GEN_ID, Vector2(560.0, 260.0), r2); mR2 = (int)(r2*255); } { - imgui.doText(GEN_ID, Vector2(434.0, 280), TextManager::getSingleton()->getString(TextManager::OP_GREEN)); + imgui.doText(GEN_ID, Vector2(434.0, 290), TextManager::getSingleton()->getString(TextManager::OP_GREEN)); float g2 = (float)mG2/255; - imgui.doScrollbar(GEN_ID, Vector2(560.0, 280.0), g2); + imgui.doScrollbar(GEN_ID, Vector2(560.0, 290.0), g2); mG2 = (int)(g2*255); } { - imgui.doText(GEN_ID, Vector2(434.0, 310), TextManager::getSingleton()->getString(TextManager::OP_BLUE)); + imgui.doText(GEN_ID, Vector2(434.0, 320), TextManager::getSingleton()->getString(TextManager::OP_BLUE)); float b2 = (float)mB2/255; - imgui.doScrollbar(GEN_ID, Vector2(560.0, 310), b2); + imgui.doScrollbar(GEN_ID, Vector2(560.0, 320), b2); mB2 = (int)(b2*255); } - imgui.doText(GEN_ID, Vector2(434.0, 350), TextManager::getSingleton()->getString(TextManager::OP_MORPHING)); - if (imgui.doButton(GEN_ID, Vector2(472.0, 380), TextManager::getSingleton()->getString(TextManager::LBL_YES))) + imgui.doText(GEN_ID, Vector2(434.0, 360), TextManager::getSingleton()->getString(TextManager::OP_MORPHING)); + if (imgui.doButton(GEN_ID, Vector2(472.0, 390), TextManager::getSingleton()->getString(TextManager::LBL_YES))) mRightMorphing = true; - if (imgui.doButton(GEN_ID, Vector2(620.0, 380), TextManager::getSingleton()->getString(TextManager::LBL_NO))) + if (imgui.doButton(GEN_ID, Vector2(620.0, 390), TextManager::getSingleton()->getString(TextManager::LBL_NO))) mRightMorphing = false; if (mRightMorphing) - imgui.doImage(GEN_ID, Vector2(454.0, 392.0), "gfx/pfeil_rechts.bmp"); + imgui.doImage(GEN_ID, Vector2(454.0, 402.0), "gfx/pfeil_rechts.bmp"); else - imgui.doImage(GEN_ID, Vector2(604.0, 392.0), "gfx/pfeil_rechts.bmp"); + imgui.doImage(GEN_ID, Vector2(604.0, 402.0), "gfx/pfeil_rechts.bmp"); //draw right blob: { float time = float(SDL_GetTicks()) / 1000.0; @@ -300,19 +346,19 @@ ourCol = Color(int((cos(time*2) + 1.0) * 128), int((cos(time*4) + 1.0) * 128), int((cos(time*3) + 1.0) * 128)); - imgui.doBlob(GEN_ID, Vector2(660, 490), ourCol); + imgui.doBlob(GEN_ID, Vector2(670, 500), ourCol); } if (imgui.doButton(GEN_ID, Vector2(224.0, 530.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { mSaveConfig = true; - delete this; - mCurrentState = new OptionState(); + deleteCurrentState(); + setCurrentState(new OptionState()); } if (imgui.doButton(GEN_ID, Vector2(424.0, 530.0), TextManager::getSingleton()->getString(TextManager::LBL_CANCEL))) { - delete this; - mCurrentState = new OptionState(); + deleteCurrentState(); + setCurrentState(new OptionState()); } } @@ -378,9 +424,16 @@ std::string lastActionKey = InputManager::getSingleton()->getLastActionKey(); - //left player side: + // left player side: imgui.doText(GEN_ID, Vector2(34.0, 10.0), TextManager::getSingleton()->getString(TextManager::OP_LEFT_PLAYER)); - if (imgui.doButton(GEN_ID, Vector2(80.0, 60.0), mLeftBlobbyDevice)) + // dirty hack for languagesupport + TextManager::STRING deviceLanguage = TextManager::OP_JOYSTICK; + if (mLeftBlobbyDevice[0] == 'k') + deviceLanguage = TextManager::OP_KEYBOARD; + else if (mLeftBlobbyDevice[0] == 'm') + deviceLanguage = TextManager::OP_MOUSE; + + if (imgui.doButton(GEN_ID, Vector2(80.0, 60.0), TextManager::getSingleton()->getString(deviceLanguage))) { if (mLeftBlobbyDevice == "mouse") { @@ -493,7 +546,14 @@ //right player side: imgui.doText(GEN_ID, Vector2(434.0, 10.0), TextManager::getSingleton()->getString(TextManager::OP_RIGHT_PLAYER)); - if (imgui.doButton(GEN_ID, Vector2(480.0, 60.0), mRightBlobbyDevice)) + // dirty hack for languagesupport + deviceLanguage = TextManager::OP_JOYSTICK; + if (mRightBlobbyDevice[0] == 'k') + deviceLanguage = TextManager::OP_KEYBOARD; + else if (mRightBlobbyDevice[0] == 'm') + deviceLanguage = TextManager::OP_MOUSE; + + if (imgui.doButton(GEN_ID, Vector2(480.0, 60.0), TextManager::getSingleton()->getString(deviceLanguage))) { if (mRightBlobbyDevice == "mouse") { @@ -747,13 +807,13 @@ if (imgui.doButton(GEN_ID, Vector2(224.0, 530.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { mSaveConfig = true; - delete this; - mCurrentState = new OptionState(); + deleteCurrentState(); + setCurrentState(new OptionState()); } if (imgui.doButton(GEN_ID, Vector2(424.0, 530.0), TextManager::getSingleton()->getString(TextManager::LBL_CANCEL))) { - delete this; - mCurrentState = new OptionState(); + deleteCurrentState(); + setCurrentState(new OptionState()); } } @@ -783,6 +843,7 @@ mMute = mOptionConfig.getBool("mute"); mGameFPS = mOptionConfig.getInteger("gamefps"); mNetworkSide = mOptionConfig.getInteger("network_side"); + mLanguage = mOptionConfig.getString("language"); } MiscOptionsState::~MiscOptionsState() @@ -795,6 +856,7 @@ mOptionConfig.setBool("mute", mMute); mOptionConfig.setInteger("gamefps", mGameFPS); mOptionConfig.setInteger("network_side", mNetworkSide); + mOptionConfig.setString("language", mLanguage); if (mBackground > -1) mOptionConfig.setString("background", mBackgrounds[mBackground]); mOptionConfig.saveFile("config.xml"); @@ -803,8 +865,8 @@ BloodManager::getSingleton().enable(mOptionConfig.getBool("blood")); SoundManager::getSingleton().setVolume(mOptionConfig.getFloat("global_volume")); SoundManager::getSingleton().setMute(mOptionConfig.getBool("mute")); - SpeedController::getMainInstance()->setGameSpeed(mOptionConfig.getInteger("gamefps")); RenderManager::getSingleton().setBackground(std::string("backgrounds/") + mOptionConfig.getString("background")); + TextManager::switchLanguage(mOptionConfig.getString("language")); } void MiscOptionsState::step() @@ -887,21 +949,33 @@ mGameFPS = 90; if (imgui.doButton(GEN_ID, Vector2(410.0, 450.0), TextManager::getSingleton()->getString(TextManager::OP_VFAST))) mGameFPS = 120; - SpeedController::getMainInstance()->setGameSpeed(mGameFPS); std::stringstream FPSInPercent; FPSInPercent << int((float)mGameFPS/75*100); - imgui.doText(GEN_ID, Vector2(515.0, 330.0), FPSInPercent.str()+="%"); + FPSInPercent << "%"; + imgui.doText(GEN_ID, Vector2(515.0, 330.0), FPSInPercent.str()); + + //! \todo this must be reworket + std::map::iterator olang = TextManager::language_names.find(TextManager::getSingleton()->getLang()); + if(++olang == TextManager::language_names.end()){ + olang = TextManager::language_names.begin(); + } + if (imgui.doButton(GEN_ID, Vector2(300.0, 490.0), (*olang).second)){ + //! \todo autogenerierte liste mit allen lang_ dateien, namen auslesen + mLanguage = (*olang).first; + TextManager::switchLanguage(mLanguage); + + } if (imgui.doButton(GEN_ID, Vector2(224.0, 530.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { mSaveConfig = true; - delete this; - mCurrentState = new OptionState(); + deleteCurrentState(); + setCurrentState(new OptionState()); } if (imgui.doButton(GEN_ID, Vector2(424.0, 530.0), TextManager::getSingleton()->getString(TextManager::LBL_CANCEL))) { - delete this; - mCurrentState = new OptionState(); + deleteCurrentState(); + setCurrentState(new OptionState()); } } diff -Nru blobby-0.8-dfsg/src/state/OptionsState.h blobby-0.9c/src/state/OptionsState.h --- blobby-0.8-dfsg/src/state/OptionsState.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/state/OptionsState.h 2011-11-06 15:06:44.000000000 +0000 @@ -36,6 +36,7 @@ bool mSaveConfig; std::string mPlayerName[MAX_PLAYERS]; unsigned mPlayerNamePosition[MAX_PLAYERS]; + unsigned mBotStrength[MAX_PLAYERS]; }; class GraphicOptionsState : public State @@ -51,6 +52,7 @@ std::string mRenderer; int mR1, mG1, mB1, mR2, mG2, mB2; bool mLeftMorphing, mRightMorphing; + bool mShowShadow; }; class InputOptionsState : public State @@ -102,4 +104,5 @@ bool mShowBlood; bool mSaveConfig; int mNetworkSide; + std::string mLanguage; }; diff -Nru blobby-0.8-dfsg/src/state/State.cpp blobby-0.9c/src/state/State.cpp --- blobby-0.8-dfsg/src/state/State.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/state/State.cpp 2011-11-06 15:06:44.000000000 +0000 @@ -28,6 +28,8 @@ #include "NetworkState.h" #include "OptionsState.h" #include "TextManager.h" +#include "SpeedController.h" +#include "Blood.h" #include #include @@ -48,9 +50,60 @@ return mCurrentState; } +void State::deleteCurrentState(){ + delete mCurrentState; + mCurrentState = 0; +} +void State::setCurrentState(State* newState){ + assert(!mCurrentState); + mCurrentState = newState; +} + +void State::presentGame(const DuelMatch& match) +{ + RenderManager& rmanager = RenderManager::getSingleton(); + SoundManager& smanager = SoundManager::getSingleton(); + + rmanager.setScore(match.getScore(LEFT_PLAYER), match.getScore(RIGHT_PLAYER), + match.getServingPlayer() == LEFT_PLAYER, match.getServingPlayer() == RIGHT_PLAYER); + + rmanager.setBlob(LEFT_PLAYER, match.getBlobPosition(LEFT_PLAYER), + match.getWorld().getBlobState(LEFT_PLAYER)); + rmanager.setBlob(RIGHT_PLAYER, match.getBlobPosition(RIGHT_PLAYER), + match.getWorld().getBlobState(RIGHT_PLAYER)); + + rmanager.setBall(match.getBallPosition(), match.getWorld().getBallRotation()); + + rmanager.setTime(match.getClock().getTimeString()); + + int events = match.getEvents(); + if(events & DuelMatch::EVENT_LEFT_BLOBBY_HIT) + { + smanager.playSound("sounds/bums.wav", match.getWorld().lastHitIntensity() + BALL_HIT_PLAYER_SOUND_VOLUME); + Vector2 hitPos = match.getBallPosition() + + (match.getBlobPosition(LEFT_PLAYER) - match.getBallPosition()).normalise().scale(31.5); + BloodManager::getSingleton().spillBlood(hitPos, match.getWorld().lastHitIntensity(), 0); + } + + if (events & DuelMatch::EVENT_RIGHT_BLOBBY_HIT) + { + smanager.playSound("sounds/bums.wav", match.getWorld().lastHitIntensity() + BALL_HIT_PLAYER_SOUND_VOLUME); + Vector2 hitPos = match.getBallPosition() + + (match.getBlobPosition(RIGHT_PLAYER) - match.getBallPosition()).normalise().scale(31.5); + BloodManager::getSingleton().spillBlood(hitPos, match.getWorld().lastHitIntensity(), 1); + } + + if (events & DuelMatch::EVENT_ERROR) + smanager.playSound("sounds/pfiff.wav", ROUND_START_SOUND_VOLUME); + +} + MainMenuState::MainMenuState() { IMGUI::getSingleton().resetSelection(); + + // set main menu fps + SpeedController::getMainInstance()->setGameSpeed(75); } MainMenuState::~MainMenuState() @@ -66,17 +119,22 @@ imgui.doImage(GEN_ID, Vector2(400.0, 300.0), "background"); imgui.doOverlay(GEN_ID, Vector2(0.0, 0.0), Vector2(800.0, 600.0)); imgui.doImage(GEN_ID, Vector2(250.0, 210.0), "gfx/titel.bmp"); - if (imgui.doButton(GEN_ID, Vector2(484, 370.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_NETWORK))) + if (imgui.doButton(GEN_ID, Vector2(434, 350.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_ONLINE))) + { + deleteCurrentState(); + setCurrentState(new OnlineSearchState()); + } + if (imgui.doButton(GEN_ID, Vector2(434, 380.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_LAN))) { - delete mCurrentState; - mCurrentState = new NetworkSearchState(); + deleteCurrentState(); + setCurrentState(new LANSearchState()); } - if (imgui.doButton(GEN_ID, Vector2(484.0, 400.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_START))) + if (imgui.doButton(GEN_ID, Vector2(434.0, 410.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_START))) { - delete mCurrentState; try { - mCurrentState = new LocalGameState(); + deleteCurrentState(); + setCurrentState(new LocalGameState()); } catch (ScriptException except) { @@ -84,32 +142,32 @@ fprintf(file, "Lua Error: %s\n", except.luaerror.c_str()); fclose(file); - mCurrentState = new MainMenuState(); } } - if (imgui.doButton(GEN_ID, Vector2(484.0, 430.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_OPTIONS))) + if (imgui.doButton(GEN_ID, Vector2(434.0, 440.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_OPTIONS))) { - delete mCurrentState; - mCurrentState = new OptionState(); + deleteCurrentState(); + setCurrentState(new OptionState()); } - if (imgui.doButton(GEN_ID, Vector2(484.0, 460.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_REPLAY))) + if (imgui.doButton(GEN_ID, Vector2(434.0, 470.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_REPLAY))) { - delete mCurrentState; - mCurrentState = new ReplayMenuState(); + deleteCurrentState(); + setCurrentState(new ReplayMenuState()); } - if (imgui.doButton(GEN_ID, Vector2(484.0, 490.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_CREDITS))) + if (imgui.doButton(GEN_ID, Vector2(434.0, 500.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_CREDITS))) { - delete mCurrentState; - mCurrentState = new CreditsState(); + deleteCurrentState(); + setCurrentState(new CreditsState()); } - if (imgui.doButton(GEN_ID, Vector2(484.0, 520.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_EXIT))) + if (imgui.doButton(GEN_ID, Vector2(434.0, 530.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_EXIT))) { RenderManager::getSingleton().deinit(); SoundManager::getSingleton().deinit(); + deleteCurrentState(); SDL_Quit(); exit(0); } @@ -127,31 +185,36 @@ imgui.doCursor(); imgui.doImage(GEN_ID, Vector2(400.0, 300.0), "background"); imgui.doOverlay(GEN_ID, Vector2(0.0, 0.0), Vector2(800.0, 600.0)); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition), TextManager::getSingleton()->getString(TextManager::CRD_PROGRAMMERS)); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+30), "Jonathan Sieber"); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+60), "(jonathan_sieber(at)yahoo.de)"); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+95), "Daniel Knobe"); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+125), "(daniel-knobe(at)web.de)"); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+160), "Sven Rech"); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+190), "(svenrech(at)gmx.de)"); - - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+230), TextManager::getSingleton()->getString(TextManager::CRD_GRAPHICS)); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+260), "Silvio Mummert"); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+290), "(mummertathome(at)t-online.de)"); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+325), "Richard Bertrand"); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+355), "(ricbertrand(at)hotmail.com)"); - - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+400), TextManager::getSingleton()->getString(TextManager::CRD_THX)); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+430), "Daniel Skoraszewsky"); - imgui.doText(GEN_ID, Vector2(40.0, mYPosition+460), "(skoraszewsky(at)t-online.de)"); + + const float xPosition = 50; + + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition), TextManager::getSingleton()->getString(TextManager::CRD_PROGRAMMERS)); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+30), "Daniel Knobe"); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+60), " (daniel-knobe(at)web.de)", TF_SMALL_FONT); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+85), "Jonathan Sieber"); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+115), " (jonathan_sieber(at)yahoo.de)", TF_SMALL_FONT); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+140), "Sven Rech"); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+170), " (svenrech(at)gmx.de)", TF_SMALL_FONT); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+195), "Erik Schultheis"); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+225), " (erik-schutlheis(at)freenet.de)", TF_SMALL_FONT); + + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+255), TextManager::getSingleton()->getString(TextManager::CRD_GRAPHICS)); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+285), "Silvio Mummert"); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+315), " (mummertathome(at)t-online.de)", TF_SMALL_FONT); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+340), "Richard Bertrand"); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+370), " (ricbertrand(at)hotmail.com)", TF_SMALL_FONT); + + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+415), TextManager::getSingleton()->getString(TextManager::CRD_THX)); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+445), "Daniel Skoraszewsky"); + imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+475), " (skoraszewsky(at)t-online.de)", TF_SMALL_FONT); if (mYPosition > 20) mYPosition -= 2.5; - if (imgui.doButton(GEN_ID, Vector2(400.0, 560.0), TextManager::getSingleton()->getString(TextManager::LBL_MAINMENU))) + if (imgui.doButton(GEN_ID, Vector2(400.0, 560.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { - delete this; - mCurrentState = new MainMenuState(); + deleteCurrentState(); + setCurrentState(new MainMenuState()); return; } } @@ -192,7 +255,7 @@ { mReplayRecorder->load(std::string("replays/" + mReplayFiles[mSelectedReplay] + ".bvr")); mReplaying = true; - mReplayMatch = new DuelMatch(0, 0, true, true); + mReplayMatch = new DuelMatch(0, 0, true, false); mReplayMatch->setServingPlayer(mReplayRecorder->getServingPlayer()); RenderManager::getSingleton().setPlayernames( mReplayRecorder->getPlayerName(LEFT_PLAYER), mReplayRecorder->getPlayerName(RIGHT_PLAYER)); @@ -220,6 +283,7 @@ mReplayMatch->step(); } + presentGame(*mReplayMatch); rmanager->setBlobColor(LEFT_PLAYER, mLeftPlayer.getColor()); rmanager->setBlobColor(RIGHT_PLAYER, mRightPlayer.getColor()); @@ -228,9 +292,9 @@ { std::stringstream tmp; if(side == LEFT_PLAYER) - tmp << mReplayMatch->getPlayerName(); + tmp << mReplayRecorder->getPlayerName(LEFT_PLAYER); else - tmp << mReplayMatch->getOpponentName(); + tmp << mReplayRecorder->getPlayerName(RIGHT_PLAYER); imgui.doOverlay(GEN_ID, Vector2(200, 150), Vector2(650, 450)); imgui.doImage(GEN_ID, Vector2(200, 250), "gfx/pokal.bmp"); imgui.doText(GEN_ID, Vector2(274, 250), tmp.str()); @@ -273,8 +337,8 @@ } else if (imgui.doButton(GEN_ID, Vector2(424.0, 10.0), TextManager::getSingleton()->getString(TextManager::LBL_CANCEL))) { - delete this; - mCurrentState = new MainMenuState(); + deleteCurrentState(); + setCurrentState(new MainMenuState()); } else imgui.doSelectbox(GEN_ID, Vector2(34.0, 50.0), Vector2(634.0, 550.0), mReplayFiles, mSelectedReplay); diff -Nru blobby-0.8-dfsg/src/state/State.h blobby-0.9c/src/state/State.h --- blobby-0.8-dfsg/src/state/State.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/state/State.h 2011-11-06 15:06:44.000000000 +0000 @@ -31,11 +31,17 @@ class State { private: - + static State* mCurrentState; protected: State(); - static State* mCurrentState; + void deleteCurrentState(); + void setCurrentState(State* newState); + // static protected helper function that + // draws the game. It is in State because + // this functionality is shared by + // LocalGameState, NetworkGameState and ReplayMenuState + static void presentGame(const DuelMatch& match); public: virtual ~State() {} virtual void step() = 0; diff -Nru blobby-0.8-dfsg/src/TextManager.cpp blobby-0.9c/src/TextManager.cpp --- blobby-0.8-dfsg/src/TextManager.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/TextManager.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -1,192 +1,51 @@ +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + + #include "TextManager.h" +#include +#include +#include "tinyxml/tinyxml.h" +#include "Global.h" +#include + TextManager* TextManager::mSingleton = 0; -TextManager* TextManager::createTextManager(LANGUAGE l){ - if(mSingleton) - delete mSingleton; - mSingleton = new TextManager(); - - switch(l){ - case ENGLISH: - mSingleton->mStrings[LBL_OK] = "ok"; - mSingleton->mStrings[LBL_CANCEL] = "cancel"; - mSingleton->mStrings[LBL_YES] = "yes"; - mSingleton->mStrings[LBL_NO] = "no"; - mSingleton->mStrings[LBL_MAINMENU] = "back to main menu"; - mSingleton->mStrings[LBL_CONF_QUIT] = "really quit?"; - mSingleton->mStrings[LBL_CONTINUE] = "continue"; - - mSingleton->mStrings[MNU_LABEL_NETWORK] = "network game"; - mSingleton->mStrings[MNU_LABEL_START] = "start"; - mSingleton->mStrings[MNU_LABEL_OPTIONS] = "options"; - mSingleton->mStrings[MNU_LABEL_REPLAY] = "watch replay"; - mSingleton->mStrings[MNU_LABEL_CREDITS] = "credits"; - mSingleton->mStrings[MNU_LABEL_EXIT] = "exit"; - - mSingleton->mStrings[CRD_PROGRAMMERS] = "programmers:"; - mSingleton->mStrings[CRD_GRAPHICS] = "graphics:"; - mSingleton->mStrings[CRD_THX] = "special thanks at:"; - - mSingleton->mStrings[RP_SHOW_AGAIN] = "show again"; - mSingleton->mStrings[RP_PLAY] = "play"; - mSingleton->mStrings[RP_DELETE] = "delete"; - mSingleton->mStrings[RP_CHECKSUM] = "checksum error"; - mSingleton->mStrings[RP_FILE_CORRUPT] = "file is corrupt"; - mSingleton->mStrings[RP_SAVE_NAME] = "name of the replay:"; - mSingleton->mStrings[RP_SAVE] = "save replay"; - - mSingleton->mStrings[GAME_WIN] = "has won the game!"; - mSingleton->mStrings[GAME_TRY_AGAIN] = "try again"; - mSingleton->mStrings[GAME_WAITING] = "waiting for opponent..."; - mSingleton->mStrings[GAME_OPP_LEFT] = "opponent left the game"; - mSingleton->mStrings[GAME_PAUSED] = "game paused"; - mSingleton->mStrings[GAME_QUIT] = "quit"; - - mSingleton->mStrings[NET_SERVER_SCAN] = "scan for servers"; - mSingleton->mStrings[NET_DIRECT_CONNECT] = "direct connect"; - mSingleton->mStrings[NET_SERVER_INFO] = "server info"; - mSingleton->mStrings[NET_ACTIVE_GAMES] = "active games: "; - mSingleton->mStrings[NET_WAITING_PLAYER] = "waiting player: "; - mSingleton->mStrings[NET_HOST_GAME] = "host game"; - mSingleton->mStrings[NET_CONNECTING] = "connecting to server ..."; - mSingleton->mStrings[NET_DISCONNECT] = "disconnected from server"; - mSingleton->mStrings[NET_CON_FAILED] = "connection failed"; - mSingleton->mStrings[NET_SERVER_FULL] = "server full"; - - mSingleton->mStrings[OP_INPUT_OP] = "input options"; - mSingleton->mStrings[OP_GFX_OP] = "graphic options"; - mSingleton->mStrings[OP_MISC] = "misc options"; - mSingleton->mStrings[OP_VIDEO] = "video settings"; - mSingleton->mStrings[OP_FULLSCREEN] = "fullscreen mode"; - mSingleton->mStrings[OP_WINDOW] = "window mode"; - mSingleton->mStrings[OP_RENDER_DEVICE] = "render device"; - mSingleton->mStrings[OP_BLOB_COLORS] = "blob colors"; - mSingleton->mStrings[OP_LEFT_PLAYER] = "left player"; - mSingleton->mStrings[OP_RIGHT_PLAYER] = "right player"; - mSingleton->mStrings[OP_RED] = "red"; - mSingleton->mStrings[OP_GREEN] = "green"; - mSingleton->mStrings[OP_BLUE] = "blue"; - mSingleton->mStrings[OP_MORPHING] = "morphing blob?"; - mSingleton->mStrings[OP_JUMP_BUTTON] = "jump button"; - mSingleton->mStrings[OP_SET_ALL] = "set all"; - mSingleton->mStrings[OP_LEFT_KEY] = "left key"; - mSingleton->mStrings[OP_RIGHT_KEY] = "right key"; - mSingleton->mStrings[OP_JUMP_KEY] = "jump key"; - mSingleton->mStrings[OP_LEFT_BUTTON] = "left button"; - mSingleton->mStrings[OP_RIGHT_BUTTON] = "right_button"; - mSingleton->mStrings[OP_PRESS_MOUSE_BUTTON] = "press mouse button for"; - mSingleton->mStrings[OP_PRESS_KEY_FOR] = "press key for"; - mSingleton->mStrings[OP_MOVING_LEFT] = "moving left"; - mSingleton->mStrings[OP_MOVING_RIGHT] = "moving right"; - mSingleton->mStrings[OP_JUMPING] = "jumping"; - mSingleton->mStrings[OP_PRESS_BUTTON_FOR] = "press button for"; - mSingleton->mStrings[OP_BACKGROUND] = "background:"; - mSingleton->mStrings[OP_VOLUME] = "volume:"; - mSingleton->mStrings[OP_MUTE] = "mute"; - mSingleton->mStrings[OP_FPS] = "show fps"; - mSingleton->mStrings[OP_BLOOD] = "show blood"; - mSingleton->mStrings[OP_NETWORK_SIDE] = "network side:"; - mSingleton->mStrings[OP_LEFT] = "left"; - mSingleton->mStrings[OP_RIGHT] = "right"; - mSingleton->mStrings[OP_SPEED] = "gamespeed:"; - mSingleton->mStrings[OP_VSLOW] = "very slow"; - mSingleton->mStrings[OP_SLOW] = "slow"; - mSingleton->mStrings[OP_DEFAULT] = "default"; - mSingleton->mStrings[OP_FAST] = "fast"; - mSingleton->mStrings[OP_VFAST] = "very fast"; - - break; - case GERMAN: - mSingleton->mStrings[LBL_OK] = "ok"; - mSingleton->mStrings[LBL_CANCEL] = "abbrechen"; - mSingleton->mStrings[LBL_YES] = "ja"; - mSingleton->mStrings[LBL_NO] = "nein"; - mSingleton->mStrings[LBL_MAINMENU] = "hauptmenü"; - mSingleton->mStrings[LBL_CONF_QUIT] = "wirklich beenden?"; - mSingleton->mStrings[LBL_CONTINUE] = "fortsetzen"; - - mSingleton->mStrings[MNU_LABEL_NETWORK] = "netzwerkspiel"; - mSingleton->mStrings[MNU_LABEL_START] = "start"; - mSingleton->mStrings[MNU_LABEL_OPTIONS] = "optionen"; - mSingleton->mStrings[MNU_LABEL_REPLAY] = "spiel ansehen"; - mSingleton->mStrings[MNU_LABEL_CREDITS] = "credits"; - mSingleton->mStrings[MNU_LABEL_EXIT] = "beenden"; - - mSingleton->mStrings[CRD_PROGRAMMERS] = "programmierer:"; - mSingleton->mStrings[CRD_GRAPHICS] = "grafik:"; - mSingleton->mStrings[CRD_THX] = "besonderer dank an:"; - - mSingleton->mStrings[RP_SHOW_AGAIN] = "nochmal ansehen"; - mSingleton->mStrings[RP_PLAY] = "abspielen"; - mSingleton->mStrings[RP_DELETE] = "löschen"; - mSingleton->mStrings[RP_CHECKSUM] = "checksum error"; - mSingleton->mStrings[RP_FILE_CORRUPT] = "datei beschädigt"; - mSingleton->mStrings[RP_SAVE_NAME] = "name des replays:"; - mSingleton->mStrings[RP_SAVE] = "replay speichern"; - - - mSingleton->mStrings[GAME_WIN] = "hat gewonnen!"; - mSingleton->mStrings[GAME_TRY_AGAIN] = "nochmal"; - mSingleton->mStrings[GAME_WAITING] = "warte auf mitspieler"; - mSingleton->mStrings[GAME_OPP_LEFT] = "gegner hat das spiel verlassen"; - mSingleton->mStrings[GAME_PAUSED] = "spiel pausiert"; - mSingleton->mStrings[GAME_QUIT] = "verlassen"; - - mSingleton->mStrings[NET_SERVER_SCAN] = "server suchen"; - mSingleton->mStrings[NET_DIRECT_CONNECT] = "direktverbindung"; - mSingleton->mStrings[NET_SERVER_INFO] = "server info"; - mSingleton->mStrings[NET_ACTIVE_GAMES] = "aktive spiel: "; - mSingleton->mStrings[NET_WAITING_PLAYER] = "wartender spieler: "; - mSingleton->mStrings[NET_HOST_GAME] = "spiel hosten"; - mSingleton->mStrings[NET_CONNECTING] = "verbindungsaufbau..."; - mSingleton->mStrings[NET_DISCONNECT] = "verbindung unterbrochen"; - mSingleton->mStrings[NET_CON_FAILED] = "verbindungsfehler"; - mSingleton->mStrings[NET_SERVER_FULL] = "server voll"; - - mSingleton->mStrings[OP_INPUT_OP] = "eingabeoptionen"; - mSingleton->mStrings[OP_GFX_OP] = "grafikoptionen"; - mSingleton->mStrings[OP_MISC] = "weitere optionen"; - mSingleton->mStrings[OP_VIDEO] = "video"; - mSingleton->mStrings[OP_FULLSCREEN] = "vollbild"; - mSingleton->mStrings[OP_WINDOW] = "fenster"; - mSingleton->mStrings[OP_RENDER_DEVICE] = "render device"; - mSingleton->mStrings[OP_BLOB_COLORS] = "blobbyfarben"; - mSingleton->mStrings[OP_LEFT_PLAYER] = "linker spieler"; - mSingleton->mStrings[OP_RIGHT_PLAYER] = "rechter spieler"; - mSingleton->mStrings[OP_RED] = "rot"; - mSingleton->mStrings[OP_GREEN] = "grün"; - mSingleton->mStrings[OP_BLUE] = "blau"; - mSingleton->mStrings[OP_MORPHING] = "morphing blob?"; - mSingleton->mStrings[OP_JUMP_BUTTON] = "springen"; - mSingleton->mStrings[OP_SET_ALL] = "alle setzen"; - mSingleton->mStrings[OP_LEFT_KEY] = "taste links"; - mSingleton->mStrings[OP_RIGHT_KEY] = "taste rechts"; - mSingleton->mStrings[OP_JUMP_KEY] = "taste sprung"; - mSingleton->mStrings[OP_LEFT_BUTTON] = "button links"; - mSingleton->mStrings[OP_RIGHT_BUTTON] = "button rechts"; - mSingleton->mStrings[OP_PRESS_MOUSE_BUTTON] = "maustaste drücken für"; - mSingleton->mStrings[OP_PRESS_KEY_FOR] = "taste drücken für"; - mSingleton->mStrings[OP_MOVING_LEFT] = "nach links"; - mSingleton->mStrings[OP_MOVING_RIGHT] = "nach rechts"; - mSingleton->mStrings[OP_JUMPING] = "springen"; - mSingleton->mStrings[OP_PRESS_BUTTON_FOR] = "taste drücken für"; - mSingleton->mStrings[OP_BACKGROUND] = "hintergrund:"; - mSingleton->mStrings[OP_VOLUME] = "lautstärke:"; - mSingleton->mStrings[OP_MUTE] = "stumm"; - mSingleton->mStrings[OP_FPS] = "fps"; - mSingleton->mStrings[OP_BLOOD] = "zeige blut"; - mSingleton->mStrings[OP_NETWORK_SIDE] = "netzwerkseite:"; - mSingleton->mStrings[OP_LEFT] = "links"; - mSingleton->mStrings[OP_RIGHT] = "rechts"; - mSingleton->mStrings[OP_SPEED] = "Geschwindigkeit:"; - mSingleton->mStrings[OP_VSLOW] = "sehr langsam"; - mSingleton->mStrings[OP_SLOW] = "langsam"; - mSingleton->mStrings[OP_DEFAULT] = "normal"; - mSingleton->mStrings[OP_FAST] = "schnell"; - mSingleton->mStrings[OP_VFAST] = "sehr schnell"; - break; +TextManager* TextManager::createTextManager(std::string langname){ + delete mSingleton; + + mSingleton = new TextManager(langname); + + std::string langfile = "lang_"+langname+".xml"; + + bool loaded = false; + try{ + loaded = mSingleton->loadFromXML(langfile); + }catch(FileLoadException& fle){ + std::cerr << fle.what() << std::endl; + }; + + if(!loaded){ + std::cerr << "error loading language " << langfile << "!" << std::endl; + std::cerr << "\tfalling back to english" << std::endl; } } @@ -194,10 +53,191 @@ return mSingleton; } -TextManager::TextManager(){ +TextManager::TextManager(std::string l):lang(l){ mStrings.resize(COUNT); + setDefault(); +} + +void TextManager::switchLanguage(std::string langname){ + // if old and new language are the same, nothing must be done + if(langname == mSingleton->lang) + return; + + // otherwise, the old TextManager is destroyed and a new one is created + createTextManager(langname); } const std::string& TextManager::getString(STRING str) const{ return mStrings[str]; } +std::string TextManager::getLang() const{ + return lang; +} + +bool TextManager::loadFromXML(std::string file){ + // create and load file + PHYSFS_file* fileHandle = PHYSFS_openRead(file.c_str()); + if (!fileHandle) + throw FileLoadException(file); + + int fileLength = PHYSFS_fileLength(fileHandle); + char* fileBuffer = new char[fileLength + 1]; + PHYSFS_read(fileHandle, fileBuffer, 1, fileLength); + fileBuffer[fileLength] = 0; + + + // parse file + TiXmlDocument language_data; + language_data.Parse(fileBuffer); + delete[] fileBuffer; + PHYSFS_close(fileHandle); + + if (language_data.Error()) + { + std::cerr << "Warning: Parse error in " << file; + std::cerr << "!" << std::endl; + } + + TiXmlElement* language = language_data.FirstChildElement("language"); + if (!language) + return false; + + // this loop assumes that the strings in the xml file are in the correct order + // in each step, it reads the next string element and writes it to the next position in mStrings + for ( TiXmlElement* stringel = language->FirstChildElement("string"); + stringel; + stringel = stringel->NextSiblingElement("string")){ + + + std::string label; + const char* e = stringel->Attribute("english"); + const char* t = stringel->Attribute("translation"); + if (t && e){ + // search the english string and replace it with the translation + std::vector::iterator found = std::find(mStrings.begin(), mStrings.end(), e); + if(found != mStrings.end()) + *found = t; + else + std::cerr<<"error in language file: entry "< "< TextManager::language_names; + +struct lang_init{ + lang_init(){ + TextManager::language_names["de"] = "deutsch"; + TextManager::language_names["en"] = "english"; + TextManager::language_names["fr"] = "francais"; + } +}; +static lang_init init; + + diff -Nru blobby-0.8-dfsg/src/TextManager.h blobby-0.9c/src/TextManager.h --- blobby-0.8-dfsg/src/TextManager.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/TextManager.h 2011-11-06 15:06:46.000000000 +0000 @@ -1,36 +1,54 @@ +/*============================================================================= +Blobby Volley 2 +Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +=============================================================================*/ + + #pragma once #include #include +#include // class for managing the text // multilanguage support +// the string can be loaded from a xml file +// -#include -#include +#ifndef TIXML_USE_STL #include "tinystr.h" -// TiXmlString constructor, based on a C string -TiXmlString::TiXmlString (const char* instring) -{ - unsigned newlen; - char * newstring; - - if (!instring) - { - allocated = 0; - cstring = NULL; - current_length = 0; - return; - } - newlen = strlen (instring) + 1; - newstring = new char [newlen]; - memcpy (newstring, instring, newlen); - // strcpy (newstring, instring); - allocated = newlen; - cstring = newstring; - current_length = newlen - 1; -} - -// TiXmlString copy constructor -TiXmlString::TiXmlString (const TiXmlString& copy) -{ - unsigned newlen; - char * newstring; - - // Prevent copy to self! - if ( © == this ) - return; - - if (! copy . allocated) - { - allocated = 0; - cstring = NULL; - current_length = 0; - return; - } - newlen = copy . length () + 1; - newstring = new char [newlen]; - // strcpy (newstring, copy . cstring); - memcpy (newstring, copy . cstring, newlen); - allocated = newlen; - cstring = newstring; - current_length = newlen - 1; -} - -// TiXmlString = operator. Safe when assign own content -void TiXmlString ::operator = (const char * content) -{ - unsigned newlen; - char * newstring; - - if (! content) - { - empty_it (); - return; - } - newlen = strlen (content) + 1; - newstring = new char [newlen]; - // strcpy (newstring, content); - memcpy (newstring, content, newlen); - empty_it (); - allocated = newlen; - cstring = newstring; - current_length = newlen - 1; -} +// Error value for find primitive +const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); -// = operator. Safe when assign own content -void TiXmlString ::operator = (const TiXmlString & copy) -{ - unsigned newlen; - char * newstring; - if (! copy . length ()) - { - empty_it (); - return; - } - newlen = copy . length () + 1; - newstring = new char [newlen]; - // strcpy (newstring, copy . c_str ()); - memcpy (newstring, copy . c_str (), newlen); - empty_it (); - allocated = newlen; - cstring = newstring; - current_length = newlen - 1; -} +// Null rep. +TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; -// append a const char * to an existing TiXmlString -void TiXmlString::append( const char* str, int len ) +void TiXmlString::reserve (size_type cap) { - char * new_string; - unsigned new_alloc, new_size, size_suffix; - - // don't use strlen - it can overrun the len passed in! - const char* p = str; - size_suffix = 0; - - while ( *p && size_suffix < (unsigned)len ) + if (cap > capacity()) { - ++p; - ++size_suffix; + TiXmlString tmp; + tmp.init(length(), cap); + memcpy(tmp.start(), data(), length()); + swap(tmp); } - if ( !size_suffix) - return; - - new_size = length () + size_suffix + 1; - // check if we need to expand - if (new_size > allocated) - { - // compute new size - new_alloc = assign_new_size (new_size); - - // allocate new buffer - new_string = new char [new_alloc]; - new_string [0] = 0; - - // copy the previous allocated buffer into this one - if (allocated && cstring) - // strcpy (new_string, cstring); - memcpy (new_string, cstring, length ()); - - // append the suffix. It does exist, otherwize we wouldn't be expanding - // strncat (new_string, str, len); - memcpy (new_string + length (), - str, - size_suffix); - - // return previsously allocated buffer if any - if (allocated && cstring) - delete [] cstring; - - // update member variables - cstring = new_string; - allocated = new_alloc; - } - else - { - // we know we can safely append the new string - // strncat (cstring, str, len); - memcpy (cstring + length (), - str, - size_suffix); - } - current_length = new_size - 1; - cstring [current_length] = 0; } -// append a const char * to an existing TiXmlString -void TiXmlString::append( const char * suffix ) +TiXmlString& TiXmlString::assign(const char* str, size_type len) { - char * new_string; - unsigned new_alloc, new_size; - - new_size = length () + strlen (suffix) + 1; - // check if we need to expand - if (new_size > allocated) - { - // compute new size - new_alloc = assign_new_size (new_size); - - // allocate new buffer - new_string = new char [new_alloc]; - new_string [0] = 0; - - // copy the previous allocated buffer into this one - if (allocated && cstring) - memcpy (new_string, cstring, 1 + length ()); - // strcpy (new_string, cstring); - - // append the suffix. It does exist, otherwize we wouldn't be expanding - // strcat (new_string, suffix); - memcpy (new_string + length (), - suffix, - strlen (suffix) + 1); - - // return previsously allocated buffer if any - if (allocated && cstring) - delete [] cstring; - - // update member variables - cstring = new_string; - allocated = new_alloc; - } - else - { - // we know we can safely append the new string - // strcat (cstring, suffix); - memcpy (cstring + length (), - suffix, - strlen (suffix) + 1); - } - current_length = new_size - 1; + size_type cap = capacity(); + if (len > cap || cap > 3*(len + 8)) + { + TiXmlString tmp; + tmp.init(len); + memcpy(tmp.start(), str, len); + swap(tmp); + } + else + { + memmove(start(), str, len); + set_size(len); + } + return *this; } -// Check for TiXmlString equuivalence -//bool TiXmlString::operator == (const TiXmlString & compare) const -//{ -// return (! strcmp (c_str (), compare . c_str ())); -//} - -//unsigned TiXmlString::length () const -//{ -// if (allocated) -// // return strlen (cstring); -// return current_length; -// return 0; -//} - -unsigned TiXmlString::find (char tofind, unsigned offset) const +TiXmlString& TiXmlString::append(const char* str, size_type len) { - char * lookup; - - if (offset >= length ()) - return (unsigned) notfound; - for (lookup = cstring + offset; * lookup; lookup++) - if (* lookup == tofind) - return lookup - cstring; - return (unsigned) notfound; + size_type newsize = length() + len; + if (newsize > capacity()) + { + reserve (newsize + capacity()); + } + memmove(finish(), str, len); + set_size(newsize); + return *this; } -bool TiXmlString::operator == (const TiXmlString & compare) const +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) { - if ( allocated && compare.allocated ) - { - assert( cstring ); - assert( compare.cstring ); - return ( strcmp( cstring, compare.cstring ) == 0 ); - } - return false; + TiXmlString tmp; + tmp.reserve(a.length() + b.length()); + tmp += a; + tmp += b; + return tmp; } - -bool TiXmlString::operator < (const TiXmlString & compare) const +TiXmlString operator + (const TiXmlString & a, const char* b) { - if ( allocated && compare.allocated ) - { - assert( cstring ); - assert( compare.cstring ); - return ( strcmp( cstring, compare.cstring ) > 0 ); - } - return false; + TiXmlString tmp; + TiXmlString::size_type b_len = static_cast( strlen(b) ); + tmp.reserve(a.length() + b_len); + tmp += a; + tmp.append(b, b_len); + return tmp; } - -bool TiXmlString::operator > (const TiXmlString & compare) const +TiXmlString operator + (const char* a, const TiXmlString & b) { - if ( allocated && compare.allocated ) - { - assert( cstring ); - assert( compare.cstring ); - return ( strcmp( cstring, compare.cstring ) < 0 ); - } - return false; + TiXmlString tmp; + TiXmlString::size_type a_len = static_cast( strlen(a) ); + tmp.reserve(a_len + b.length()); + tmp.append(a, a_len); + tmp += b; + return tmp; } diff -Nru blobby-0.8-dfsg/src/tinyxml/tinystr.h blobby-0.9c/src/tinyxml/tinystr.h --- blobby-0.8-dfsg/src/tinyxml/tinystr.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/tinyxml/tinystr.h 2011-11-06 15:06:46.000000000 +0000 @@ -2,42 +2,63 @@ www.sourceforge.net/projects/tinyxml Original file by Yves Berquin. -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source +3. This notice may not be removed or altered from any source distribution. */ -#include "tinyxml.h" - +/* + * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005. + * + * - completely rewritten. compact, clean, and fast implementation. + * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems) + * - fixed reserve() to work as per specification. + * - fixed buggy compares operator==(), operator<(), and operator>() + * - fixed operator+=() to take a const ref argument, following spec. + * - added "copy" constructor with length, and most compare operators. + * - added swap(), clear(), size(), capacity(), operator+(). + */ #ifndef TIXML_USE_STL #ifndef TIXML_STRING_INCLUDED #define TIXML_STRING_INCLUDED -#ifdef _MSC_VER -#pragma warning( disable : 4786 ) // Debugger truncating names. +#include +#include + +/* The support for explicit isn't that universal, and it isn't really + required - it is used to check that the TiXmlString class isn't incorrectly + used. Be nice to old compilers and macro it here: +*/ +#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + #define TIXML_EXPLICIT explicit +#elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + #define TIXML_EXPLICIT explicit +#else + #define TIXML_EXPLICIT #endif -#include /* - TiXmlString is an emulation of the std::string template. + TiXmlString is an emulation of a subset of the std::string template. Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. Only the member functions relevant to the TinyXML project have been implemented. The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase @@ -46,196 +67,252 @@ class TiXmlString { public : - // TiXmlString constructor, based on a string - TiXmlString (const char * instring); + // The size type used + typedef size_t size_type; - // TiXmlString empty constructor - TiXmlString () - { - allocated = 0; - cstring = NULL; - current_length = 0; - } - - // TiXmlString copy constructor - TiXmlString (const TiXmlString& copy); - - // TiXmlString destructor - ~ TiXmlString () - { - empty_it (); - } - - // Convert a TiXmlString into a classical char * - const char * c_str () const - { - if (allocated) - return cstring; - return ""; - } - - // Return the length of a TiXmlString - unsigned length () const - { - return ( allocated ) ? current_length : 0; - } - - // TiXmlString = operator - void operator = (const char * content); - - // = operator - void operator = (const TiXmlString & copy); - - // += operator. Maps to append - TiXmlString& operator += (const char * suffix) - { - append (suffix); - return *this; - } + // Error value for find primitive + static const size_type npos; // = -1; - // += operator. Maps to append - TiXmlString& operator += (char single) - { - append (single); - return *this; - } - // += operator. Maps to append - TiXmlString& operator += (TiXmlString & suffix) - { - append (suffix); - return *this; - } - bool operator == (const TiXmlString & compare) const; - bool operator < (const TiXmlString & compare) const; - bool operator > (const TiXmlString & compare) const; - - // Checks if a TiXmlString is empty - bool empty () const - { - return length () ? false : true; - } - - // single char extraction - const char& at (unsigned index) const - { - assert( index < length ()); - return cstring [index]; - } - - // find a char in a string. Return TiXmlString::notfound if not found - unsigned find (char lookup) const - { - return find (lookup, 0); - } - - // find a char in a string from an offset. Return TiXmlString::notfound if not found - unsigned find (char tofind, unsigned offset) const; - - /* Function to reserve a big amount of data when we know we'll need it. Be aware that this - function clears the content of the TiXmlString if any exists. - */ - void reserve (unsigned size) - { - empty_it (); - if (size) - { - allocated = size; - cstring = new char [size]; - cstring [0] = 0; - current_length = 0; - } - } - - // [] operator - char& operator [] (unsigned index) const - { - assert( index < length ()); - return cstring [index]; - } - - // Error value for find primitive - enum { notfound = 0xffffffff, - npos = notfound }; - - void append (const char *str, int len ); - - protected : - - // The base string - char * cstring; - // Number of chars allocated - unsigned allocated; - // Current string size - unsigned current_length; - - // New size computation. It is simplistic right now : it returns twice the amount - // we need - unsigned assign_new_size (unsigned minimum_to_allocate) - { - return minimum_to_allocate * 2; - } - - // Internal function that clears the content of a TiXmlString - void empty_it () - { - if (cstring) - delete [] cstring; - cstring = NULL; - allocated = 0; - current_length = 0; - } - - void append (const char *suffix ); - - // append function for another TiXmlString - void append (const TiXmlString & suffix) - { - append (suffix . c_str ()); - } - - // append for a single char. - void append (char single) - { - if ( cstring && current_length < (allocated-1) ) + // TiXmlString empty constructor + TiXmlString () : rep_(&nullrep_) + { + } + + // TiXmlString copy constructor + TiXmlString ( const TiXmlString & copy) : rep_(0) + { + init(copy.length()); + memcpy(start(), copy.data(), length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) + { + init( static_cast( strlen(copy) )); + memcpy(start(), copy, length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) + { + init(len); + memcpy(start(), str, len); + } + + // TiXmlString destructor + ~TiXmlString () + { + quit(); + } + + // = operator + TiXmlString& operator = (const char * copy) + { + return assign( copy, (size_type)strlen(copy)); + } + + // = operator + TiXmlString& operator = (const TiXmlString & copy) + { + return assign(copy.start(), copy.length()); + } + + + // += operator. Maps to append + TiXmlString& operator += (const char * suffix) + { + return append(suffix, static_cast( strlen(suffix) )); + } + + // += operator. Maps to append + TiXmlString& operator += (char single) + { + return append(&single, 1); + } + + // += operator. Maps to append + TiXmlString& operator += (const TiXmlString & suffix) + { + return append(suffix.data(), suffix.length()); + } + + + // Convert a TiXmlString into a null-terminated char * + const char * c_str () const { return rep_->str; } + + // Convert a TiXmlString into a char * (need not be null terminated). + const char * data () const { return rep_->str; } + + // Return the length of a TiXmlString + size_type length () const { return rep_->size; } + + // Alias for length() + size_type size () const { return rep_->size; } + + // Checks if a TiXmlString is empty + bool empty () const { return rep_->size == 0; } + + // Return capacity of string + size_type capacity () const { return rep_->capacity; } + + + // single char extraction + const char& at (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // [] operator + char& operator [] (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // find a char in a string. Return TiXmlString::npos if not found + size_type find (char lookup) const + { + return find(lookup, 0); + } + + // find a char in a string from an offset. Return TiXmlString::npos if not found + size_type find (char tofind, size_type offset) const + { + if (offset >= length()) return npos; + + for (const char* p = c_str() + offset; *p != '\0'; ++p) + { + if (*p == tofind) return static_cast< size_type >( p - c_str() ); + } + return npos; + } + + void clear () + { + //Lee: + //The original was just too strange, though correct: + // TiXmlString().swap(*this); + //Instead use the quit & re-init: + quit(); + init(0,0); + } + + /* Function to reserve a big amount of data when we know we'll need it. Be aware that this + function DOES NOT clear the content of the TiXmlString if any exists. + */ + void reserve (size_type cap); + + TiXmlString& assign (const char* str, size_type len); + + TiXmlString& append (const char* str, size_type len); + + void swap (TiXmlString& other) + { + Rep* r = rep_; + rep_ = other.rep_; + other.rep_ = r; + } + + private: + + void init(size_type sz) { init(sz, sz); } + void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } + char* start() const { return rep_->str; } + char* finish() const { return rep_->str + rep_->size; } + + struct Rep + { + size_type size, capacity; + char str[1]; + }; + + void init(size_type sz, size_type cap) + { + if (cap) { - cstring[ current_length ] = single; - ++current_length; - cstring[ current_length ] = 0; + // Lee: the original form: + // rep_ = static_cast(operator new(sizeof(Rep) + cap)); + // doesn't work in some cases of new being overloaded. Switching + // to the normal allocation, although use an 'int' for systems + // that are overly picky about structure alignment. + const size_type bytesNeeded = sizeof(Rep) + cap; + const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); + rep_ = reinterpret_cast( new int[ intsNeeded ] ); + + rep_->str[ rep_->size = sz ] = '\0'; + rep_->capacity = cap; } else { - char smallstr [2]; - smallstr [0] = single; - smallstr [1] = 0; - append (smallstr); + rep_ = &nullrep_; } - } + } + + void quit() + { + if (rep_ != &nullrep_) + { + // The rep_ is really an array of ints. (see the allocator, above). + // Cast it back before delete, so the compiler won't incorrectly call destructors. + delete [] ( reinterpret_cast( rep_ ) ); + } + } + + Rep * rep_; + static Rep nullrep_; } ; -/* + +inline bool operator == (const TiXmlString & a, const TiXmlString & b) +{ + return ( a.length() == b.length() ) // optimization on some platforms + && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare +} +inline bool operator < (const TiXmlString & a, const TiXmlString & b) +{ + return strcmp(a.c_str(), b.c_str()) < 0; +} + +inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } +inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } +inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } +inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } + +inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } +inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } +inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } +inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); +TiXmlString operator + (const TiXmlString & a, const char* b); +TiXmlString operator + (const char* a, const TiXmlString & b); + + +/* TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. Only the operators that we need for TinyXML have been developped. */ class TiXmlOutStream : public TiXmlString { public : - TiXmlOutStream () : TiXmlString () {} - // TiXmlOutStream << operator. Maps to TiXmlString::append - TiXmlOutStream & operator << (const char * in) - { - append (in); - return (* this); - } - - // TiXmlOutStream << operator. Maps to TiXmlString::append - TiXmlOutStream & operator << (const TiXmlString & in) - { - append (in . c_str ()); - return (* this); - } + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const TiXmlString & in) + { + *this += in; + return *this; + } + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const char * in) + { + *this += in; + return *this; + } + } ; #endif // TIXML_STRING_INCLUDED diff -Nru blobby-0.8-dfsg/src/tinyxml/tinyxml.cpp blobby-0.9c/src/tinyxml/tinyxml.cpp --- blobby-0.8-dfsg/src/tinyxml/tinyxml.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/tinyxml/tinyxml.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -1,6 +1,6 @@ /* www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any @@ -23,23 +23,32 @@ */ #include -#include "tinyxml.h" #ifdef TIXML_USE_STL #include +#include #endif +#include "tinyxml.h" + bool TiXmlBase::condenseWhiteSpace = true; -void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_OSTREAM* stream ) +// Microsoft compiler security +FILE* TiXmlFOpen( const char* filename, const char* mode ) { - TIXML_STRING buffer; - PutString( str, &buffer ); - (*stream) << buffer; + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + FILE* fp = 0; + errno_t err = fopen_s( &fp, filename, mode ); + if ( !err && fp ) + return fp; + return 0; + #else + return fopen( filename, mode ); + #endif } -void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) +void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) { int i=0; @@ -100,8 +109,16 @@ // Easy pass at non-alpha/numeric/symbol // Below 32 is symbolic. char buf[ 32 ]; - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - outString->append( buf, strlen( buf ) ); + + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); + #else + sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); + #endif + + //*ME: warning C4267: convert 'size_t' to 'int' + //*ME: Int-Cast to make compiler happy ... + outString->append( buf, (int)strlen( buf ) ); ++i; } else @@ -115,24 +132,6 @@ } -// <-- Strange class for a bug fix. Search for STL_STRING_BUG -TiXmlBase::StringToBuffer::StringToBuffer( const TIXML_STRING& str ) -{ - buffer = new char[ str.length()+1 ]; - if ( buffer ) - { - strcpy( buffer, str.c_str() ); - } -} - - -TiXmlBase::StringToBuffer::~StringToBuffer() -{ - delete [] buffer; -} -// End strange bug fix. --> - - TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() { parent = 0; @@ -184,6 +183,16 @@ TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) { + assert( node->parent == 0 || node->parent == this ); + assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); + + if ( node->Type() == TiXmlNode::DOCUMENT ) + { + delete node; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + node->parent = this; node->prev = lastChild; @@ -201,6 +210,11 @@ TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) { + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } TiXmlNode* node = addThis.Clone(); if ( !node ) return 0; @@ -211,8 +225,14 @@ TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) { - if ( !beforeThis || beforeThis->parent != this ) + if ( !beforeThis || beforeThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; + } TiXmlNode* node = addThis.Clone(); if ( !node ) @@ -237,8 +257,14 @@ TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) { - if ( !afterThis || afterThis->parent != this ) + if ( !afterThis || afterThis->parent != this ) { + return 0; + } + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); return 0; + } TiXmlNode* node = addThis.Clone(); if ( !node ) @@ -311,29 +337,31 @@ return true; } -TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const +const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const { - TiXmlNode* node; + const TiXmlNode* node; for ( node = firstChild; node; node = node->next ) { - if ( node->SValue() == TIXML_STRING( _value )) + if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } -TiXmlNode* TiXmlNode::LastChild( const char * _value ) const + +const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const { - TiXmlNode* node; + const TiXmlNode* node; for ( node = lastChild; node; node = node->prev ) { - if ( node->SValue() == TIXML_STRING (_value)) + if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } -TiXmlNode* TiXmlNode::IterateChildren( TiXmlNode* previous ) const + +const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const { if ( !previous ) { @@ -346,7 +374,8 @@ } } -TiXmlNode* TiXmlNode::IterateChildren( const char * val, TiXmlNode* previous ) const + +const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const { if ( !previous ) { @@ -359,32 +388,39 @@ } } -TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const + +const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const { - TiXmlNode* node; + const TiXmlNode* node; for ( node = next; node; node = node->next ) { - if ( node->SValue() == TIXML_STRING (_value)) + if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } -TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const +const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const { - TiXmlNode* node; + const TiXmlNode* node; for ( node = prev; node; node = node->prev ) { - if ( node->SValue() == TIXML_STRING (_value)) + if ( strcmp( node->Value(), _value ) == 0 ) return node; } return 0; } + void TiXmlElement::RemoveAttribute( const char * name ) { + #ifdef TIXML_USE_STL + TIXML_STRING str( name ); + TiXmlAttribute* node = attributeSet.Find( str ); + #else TiXmlAttribute* node = attributeSet.Find( name ); + #endif if ( node ) { attributeSet.Remove( node ); @@ -392,9 +428,9 @@ } } -TiXmlElement* TiXmlNode::FirstChildElement() const +const TiXmlElement* TiXmlNode::FirstChildElement() const { - TiXmlNode* node; + const TiXmlNode* node; for ( node = FirstChild(); node; @@ -406,9 +442,10 @@ return 0; } -TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const + +const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const { - TiXmlNode* node; + const TiXmlNode* node; for ( node = FirstChild( _value ); node; @@ -421,13 +458,13 @@ } -TiXmlElement* TiXmlNode::NextSiblingElement() const +const TiXmlElement* TiXmlNode::NextSiblingElement() const { - TiXmlNode* node; + const TiXmlNode* node; for ( node = NextSibling(); - node; - node = node->NextSibling() ) + node; + node = node->NextSibling() ) { if ( node->ToElement() ) return node->ToElement(); @@ -435,13 +472,14 @@ return 0; } -TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const + +const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const { - TiXmlNode* node; + const TiXmlNode* node; for ( node = NextSibling( _value ); - node; - node = node->NextSibling( _value ) ) + node; + node = node->NextSibling( _value ) ) { if ( node->ToElement() ) return node->ToElement(); @@ -450,8 +488,7 @@ } - -TiXmlDocument* TiXmlNode::GetDocument() const +const TiXmlDocument* TiXmlNode::GetDocument() const { const TiXmlNode* node; @@ -515,82 +552,200 @@ } -const char * TiXmlElement::Attribute( const char * name ) const +const char* TiXmlElement::Attribute( const char* name ) const { - TiXmlAttribute* node = attributeSet.Find( name ); - + const TiXmlAttribute* node = attributeSet.Find( name ); if ( node ) return node->Value(); + return 0; +} + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return &node->ValueStr(); return 0; } +#endif -const char * TiXmlElement::Attribute( const char * name, int* i ) const +const char* TiXmlElement::Attribute( const char* name, int* i ) const { - const char * s = Attribute( name ); + const char* s = Attribute( name ); if ( i ) { - if ( s ) + if ( s ) { *i = atoi( s ); - else + } + else { *i = 0; + } } return s; } -const char * TiXmlElement::Attribute( const char * name, double* d ) const +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const { - const char * s = Attribute( name ); + const std::string* s = Attribute( name ); + if ( i ) + { + if ( s ) { + *i = atoi( s->c_str() ); + } + else { + *i = 0; + } + } + return s; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, double* d ) const +{ + const char* s = Attribute( name ); if ( d ) { - if ( s ) + if ( s ) { *d = atof( s ); - else + } + else { *d = 0; + } } return s; } +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const +{ + const std::string* s = Attribute( name ); + if ( d ) + { + if ( s ) { + *d = atof( s->c_str() ); + } + else { + *d = 0; + } + } + return s; +} +#endif + + int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const { - TiXmlAttribute* node = attributeSet.Find( name ); + const TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) return TIXML_NO_ATTRIBUTE; + return node->QueryIntValue( ival ); +} + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; return node->QueryIntValue( ival ); } +#endif int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const { - TiXmlAttribute* node = attributeSet.Find( name ); + const TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) return TIXML_NO_ATTRIBUTE; + return node->QueryDoubleValue( dval ); +} + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; return node->QueryDoubleValue( dval ); } +#endif void TiXmlElement::SetAttribute( const char * name, int val ) { char buf[64]; - sprintf( buf, "%d", val ); + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%d", val ); + #else + sprintf( buf, "%d", val ); + #endif SetAttribute( name, buf ); } +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& name, int val ) +{ + std::ostringstream oss; + oss << val; + SetAttribute( name, oss.str() ); +} +#endif + + void TiXmlElement::SetDoubleAttribute( const char * name, double val ) { - char buf[128]; - sprintf( buf, "%f", val ); + char buf[256]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%f", val ); + #else + sprintf( buf, "%f", val ); + #endif SetAttribute( name, buf ); } -void TiXmlElement::SetAttribute( const char * name, const char * _value ) +void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) +{ + #ifdef TIXML_USE_STL + TIXML_STRING _name( cname ); + TIXML_STRING _value( cvalue ); + #else + const char* _name = cname; + const char* _value = cvalue; + #endif + + TiXmlAttribute* node = attributeSet.Find( _name ); + if ( node ) + { + node->SetValue( _value ); + return; + } + + TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue ); + if ( attrib ) + { + attributeSet.Add( attrib ); + } + else + { + TiXmlDocument* document = GetDocument(); + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value ) { TiXmlAttribute* node = attributeSet.Find( name ); if ( node ) @@ -610,18 +765,20 @@ if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); } } +#endif + void TiXmlElement::Print( FILE* cfile, int depth ) const { int i; - for ( i=0; iNext() ) { fprintf( cfile, " " ); @@ -656,39 +813,10 @@ node->Print( cfile, depth+1 ); } fprintf( cfile, "\n" ); - for( i=0; i", value.c_str() ); - } -} - -void TiXmlElement::StreamOut( TIXML_OSTREAM * stream ) const -{ - (*stream) << "<" << value; - - TiXmlAttribute* attrib; - for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) - { - (*stream) << " "; - attrib->StreamOut( stream ); - } - - // If this node has children, give it a closing tag. Else - // make it an empty tag. - TiXmlNode* node; - if ( firstChild ) - { - (*stream) << ">"; - - for ( node = firstChild; node; node=node->NextSibling() ) - { - node->StreamOut( stream ); + for( i=0; i"; - } - else - { - (*stream) << " />"; + fprintf( cfile, "", value.c_str() ); } } @@ -700,7 +828,7 @@ // Element class: // Clone the attributes, then clone the children. - TiXmlAttribute* attribute = 0; + const TiXmlAttribute* attribute = 0; for( attribute = attributeSet.First(); attribute; attribute = attribute->Next() ) @@ -715,6 +843,19 @@ } } +bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this, attributeSet.First() ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + TiXmlNode* TiXmlElement::Clone() const { @@ -727,15 +868,30 @@ } +const char* TiXmlElement::GetText() const +{ + const TiXmlNode* child = this->FirstChild(); + if ( child ) { + const TiXmlText* childText = child->ToText(); + if ( childText ) { + return childText->Value(); + } + } + return 0; +} + + TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) { tabsize = 4; + useMicrosoftBOM = false; ClearError(); } TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) { tabsize = 4; + useMicrosoftBOM = false; value = documentName; ClearError(); } @@ -745,6 +901,7 @@ TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) { tabsize = 4; + useMicrosoftBOM = false; value = documentName; ClearError(); } @@ -767,104 +924,208 @@ bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) { // See STL_STRING_BUG below. - StringToBuffer buf( value ); + //StringToBuffer buf( value ); - if ( buf.buffer && LoadFile( buf.buffer, encoding ) ) - return true; - - return false; + return LoadFile( Value(), encoding ); } bool TiXmlDocument::SaveFile() const { // See STL_STRING_BUG below. - StringToBuffer buf( value ); - - if ( buf.buffer && SaveFile( buf.buffer ) ) - return true; - - return false; +// StringToBuffer buf( value ); +// +// if ( buf.buffer && SaveFile( buf.buffer ) ) +// return true; +// +// return false; + return SaveFile( Value() ); } -bool TiXmlDocument::LoadFile( const char* filename, TiXmlEncoding encoding ) +bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) { - // Delete the existing data: - Clear(); - location.Clear(); - // There was a really terrifying little bug here. The code: // value = filename // in the STL case, cause the assignment method of the std::string to // be called. What is strange, is that the std::string had the same // address as it's c_str() method, and so bad things happen. Looks // like a bug in the Microsoft STL implementation. - // See STL_STRING_BUG above. - // Fixed with the StringToBuffer class. + // Add an extra string to avoid the crash. + TIXML_STRING filename( _filename ); value = filename; - FILE* file = fopen( value.c_str (), "r" ); + // reading in binary mode so that tinyxml can normalize the EOL + FILE* file = TiXmlFOpen( value.c_str (), "rb" ); if ( file ) { - // Get the file size, so we can pre-allocate the string. HUGE speed impact. - long length = 0; - fseek( file, 0, SEEK_END ); - length = ftell( file ); - fseek( file, 0, SEEK_SET ); + bool result = LoadFile( file, encoding ); + fclose( file ); + return result; + } + else + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } +} - // Strange case, but good to handle up front. - if ( length == 0 ) - { - fclose( file ); - return false; - } +bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) +{ + if ( !file ) + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } - // If we have a file, assume it is all one big XML file, and read it in. - // The document parser may decide the document ends sooner than the entire file, however. - TIXML_STRING data; - data.reserve( length ); + // Delete the existing data: + Clear(); + location.Clear(); - const int BUF_SIZE = 2048; - char buf[BUF_SIZE]; + // Get the file size, so we can pre-allocate the string. HUGE speed impact. + long length = 0; + fseek( file, 0, SEEK_END ); + length = ftell( file ); + fseek( file, 0, SEEK_SET ); - while( fgets( buf, BUF_SIZE, file ) ) - { - data += buf; - } - fclose( file ); + // Strange case, but good to handle up front. + if ( length <= 0 ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // If we have a file, assume it is all one big XML file, and read it in. + // The document parser may decide the document ends sooner than the entire file, however. + TIXML_STRING data; + data.reserve( length ); + + // Subtle bug here. TinyXml did use fgets. But from the XML spec: + // 2.11 End-of-Line Handling + // + // + // ...the XML processor MUST behave as if it normalized all line breaks in external + // parsed entities (including the document entity) on input, before parsing, by translating + // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to + // a single #xA character. + // + // + // It is not clear fgets does that, and certainly isn't clear it works cross platform. + // Generally, you expect fgets to translate from the convention of the OS to the c/unix + // convention, and not work generally. + + /* + while( fgets( buf, sizeof(buf), file ) ) + { + data += buf; + } + */ + + char* buf = new char[ length+1 ]; + buf[0] = 0; + + if ( fread( buf, length, 1, file ) != 1 ) { + delete [] buf; + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + const char* lastPos = buf; + const char* p = buf; - Parse( data.c_str(), 0, encoding ); + buf[length] = 0; + while( *p ) { + assert( p < (buf+length) ); + if ( *p == 0xa ) { + // Newline character. No special rules for this. Append all the characters + // since the last string, and include the newline. + data.append( lastPos, (p-lastPos+1) ); // append, include the newline + ++p; // move past the newline + lastPos = p; // and point to the new buffer (may be 0) + assert( p <= (buf+length) ); + } + else if ( *p == 0xd ) { + // Carriage return. Append what we have so far, then + // handle moving forward in the buffer. + if ( (p-lastPos) > 0 ) { + data.append( lastPos, p-lastPos ); // do not add the CR + } + data += (char)0xa; // a proper newline - if ( Error() ) - return false; - else - return true; + if ( *(p+1) == 0xa ) { + // Carriage return - new line sequence + p += 2; + lastPos = p; + assert( p <= (buf+length) ); + } + else { + // it was followed by something else...that is presumably characters again. + ++p; + lastPos = p; + assert( p <= (buf+length) ); + } + } + else { + ++p; + } } - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; + // Handle any left over characters. + if ( p-lastPos ) { + data.append( lastPos, p-lastPos ); + } + delete [] buf; + buf = 0; + + Parse( data.c_str(), 0, encoding ); + + if ( Error() ) + return false; + else + return true; } + bool TiXmlDocument::SaveFile( const char * filename ) const { // The old c stuff lives on... - FILE* fp = fopen( filename, "w" ); + FILE* fp = TiXmlFOpen( filename, "w" ); if ( fp ) { - Print( fp, 0 ); + bool result = SaveFile( fp ); fclose( fp ); - return true; + return result; } return false; } +bool TiXmlDocument::SaveFile( FILE* fp ) const +{ + if ( useMicrosoftBOM ) + { + const unsigned char TIXML_UTF_LEAD_0 = 0xefU; + const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; + const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + + fputc( TIXML_UTF_LEAD_0, fp ); + fputc( TIXML_UTF_LEAD_1, fp ); + fputc( TIXML_UTF_LEAD_2, fp ); + } + Print( fp, 0 ); + return (ferror(fp) == 0); +} + + void TiXmlDocument::CopyTo( TiXmlDocument* target ) const { TiXmlNode::CopyTo( target ); target->error = error; - target->errorDesc = errorDesc.c_str (); + target->errorId = errorId; + target->errorDesc = errorDesc; + target->tabsize = tabsize; + target->errorLocation = errorLocation; + target->useMicrosoftBOM = useMicrosoftBOM; TiXmlNode* node = 0; for ( node = firstChild; node; node = node->NextSibling() ) @@ -887,31 +1148,30 @@ void TiXmlDocument::Print( FILE* cfile, int depth ) const { - TiXmlNode* node; - for ( node=FirstChild(); node; node=node->NextSibling() ) + assert( cfile ); + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) { node->Print( cfile, depth ); fprintf( cfile, "\n" ); } } -void TiXmlDocument::StreamOut( TIXML_OSTREAM * out ) const + +bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const { - TiXmlNode* node; - for ( node=FirstChild(); node; node=node->NextSibling() ) + if ( visitor->VisitEnter( *this ) ) { - node->StreamOut( out ); - - // Special rule for streams: stop after the root element. - // The stream in code will only read one element, so don't - // write more than one. - if ( node->ToElement() ) - break; + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } } + return visitor->VisitExit( *this ); } -TiXmlAttribute* TiXmlAttribute::Next() const +const TiXmlAttribute* TiXmlAttribute::Next() const { // We are using knowledge of the sentinel. The sentinel // have a value or name. @@ -920,8 +1180,18 @@ return next; } +/* +TiXmlAttribute* TiXmlAttribute::Next() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} +*/ -TiXmlAttribute* TiXmlAttribute::Previous() const +const TiXmlAttribute* TiXmlAttribute::Previous() const { // We are using knowledge of the sentinel. The sentinel // have a value or name. @@ -930,49 +1200,53 @@ return prev; } +/* +TiXmlAttribute* TiXmlAttribute::Previous() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} +*/ -void TiXmlAttribute::Print( FILE* cfile, int /*depth*/ ) const +void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const { TIXML_STRING n, v; - PutString( name, &n ); - PutString( value, &v ); + EncodeString( name, &n ); + EncodeString( value, &v ); - if (value.find ('\"') == TIXML_STRING::npos) + if (value.find ('\"') == TIXML_STRING::npos) { + if ( cfile ) { fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); - else - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); -} - - -void TiXmlAttribute::StreamOut( TIXML_OSTREAM * stream ) const -{ - if (value.find( '\"' ) != TIXML_STRING::npos) - { - PutString( name, stream ); - (*stream) << "=" << "'"; - PutString( value, stream ); - (*stream) << "'"; + } + if ( str ) { + (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; + } } - else - { - PutString( name, stream ); - (*stream) << "=" << "\""; - PutString( value, stream ); - (*stream) << "\""; + else { + if ( cfile ) { + fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); + } + if ( str ) { + (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; + } } } + int TiXmlAttribute::QueryIntValue( int* ival ) const { - if ( sscanf( value.c_str(), "%d", ival ) == 1 ) + if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; } int TiXmlAttribute::QueryDoubleValue( double* dval ) const { - if ( sscanf( value.c_str(), "%lf", dval ) == 1 ) + if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; } @@ -980,23 +1254,31 @@ void TiXmlAttribute::SetIntValue( int _value ) { char buf [64]; - sprintf (buf, "%d", _value); + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); + #else + sprintf (buf, "%d", _value); + #endif SetValue (buf); } void TiXmlAttribute::SetDoubleValue( double _value ) { - char buf [64]; - sprintf (buf, "%lf", _value); + char buf [256]; + #if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value); + #else + sprintf (buf, "%lf", _value); + #endif SetValue (buf); } -const int TiXmlAttribute::IntValue() const +int TiXmlAttribute::IntValue() const { return atoi (value.c_str ()); } -const double TiXmlAttribute::DoubleValue() const +double TiXmlAttribute::DoubleValue() const { return atof (value.c_str ()); } @@ -1017,25 +1299,24 @@ void TiXmlComment::Print( FILE* cfile, int depth ) const { + assert( cfile ); for ( int i=0; i", value.c_str() ); } -void TiXmlComment::StreamOut( TIXML_OSTREAM * stream ) const + +void TiXmlComment::CopyTo( TiXmlComment* target ) const { - (*stream) << ""; + TiXmlNode::CopyTo( target ); } -void TiXmlComment::CopyTo( TiXmlComment* target ) const +bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const { - TiXmlNode::CopyTo( target ); + return visitor->Visit( *this ); } @@ -1051,23 +1332,37 @@ } -void TiXmlText::Print( FILE* cfile, int /*depth*/ ) const +void TiXmlText::Print( FILE* cfile, int depth ) const { - TIXML_STRING buffer; - PutString( value, &buffer ); - fprintf( cfile, "%s", buffer.c_str() ); + assert( cfile ); + if ( cdata ) + { + int i; + fprintf( cfile, "\n" ); + for ( i=0; i\n", value.c_str() ); // unformatted output + } + else + { + TIXML_STRING buffer; + EncodeString( value, &buffer ); + fprintf( cfile, "%s", buffer.c_str() ); + } } -void TiXmlText::StreamOut( TIXML_OSTREAM * stream ) const +void TiXmlText::CopyTo( TiXmlText* target ) const { - PutString( value, stream ); + TiXmlNode::CopyTo( target ); + target->cdata = cdata; } -void TiXmlText::CopyTo( TiXmlText* target ) const +bool TiXmlText::Accept( TiXmlVisitor* visitor ) const { - TiXmlNode::CopyTo( target ); + return visitor->Visit( *this ); } @@ -1122,42 +1417,25 @@ } -void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/ ) const -{ - fprintf (cfile, ""); -} - -void TiXmlDeclaration::StreamOut( TIXML_OSTREAM * stream ) const +void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const { - (*stream) << ""; + if ( cfile ) fprintf( cfile, "?>" ); + if ( str ) (*str) += "?>"; } @@ -1171,6 +1449,12 @@ } +bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + TiXmlNode* TiXmlDeclaration::Clone() const { TiXmlDeclaration* clone = new TiXmlDeclaration(); @@ -1191,15 +1475,15 @@ } -void TiXmlUnknown::StreamOut( TIXML_OSTREAM * stream ) const +void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const { - (*stream) << "<" << value << ">"; // Don't use entities here! It is unknown. + TiXmlNode::CopyTo( target ); } -void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const +bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const { - TiXmlNode::CopyTo( target ); + return visitor->Visit( *this ); } @@ -1231,7 +1515,11 @@ void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) { + #ifdef TIXML_USE_STL + assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. + #else assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. + #endif addMe->next = &sentinel; addMe->prev = sentinel.prev; @@ -1258,21 +1546,56 @@ assert( 0 ); // we tried to remove a non-linked attribute. } -TiXmlAttribute* TiXmlAttributeSet::Find( const char * name ) const + +#ifdef TIXML_USE_STL +const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const { - TiXmlAttribute* node; + for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; +} - for( node = sentinel.next; node != &sentinel; node = node->next ) +/* +TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) { if ( node->name == name ) return node; } return 0; } +*/ +#endif +const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const +{ + for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; +} + +/* +TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; +} +*/ + #ifdef TIXML_USE_STL -TIXML_ISTREAM & operator >> (TIXML_ISTREAM & in, TiXmlNode & base) +std::istream& operator>> (std::istream & in, TiXmlNode & base) { TIXML_STRING tag; tag.reserve( 8 * 1000 ); @@ -1284,21 +1607,26 @@ #endif -TIXML_OSTREAM & operator<< (TIXML_OSTREAM & out, const TiXmlNode & base) +#ifdef TIXML_USE_STL +std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) { - base.StreamOut (& out); + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out << printer.Str(); + return out; } -#ifdef TIXML_USE_STL -std::string & operator<< (std::string& out, const TiXmlNode& base ) +std::string& operator<< (std::string& out, const TiXmlNode& base ) { - std::ostringstream os_stream( std::ostringstream::out ); - base.StreamOut( &os_stream ); - - out.append( os_stream.str() ); - return out; + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out.append( printer.Str() ); + + return out; } #endif @@ -1425,3 +1753,136 @@ } return TiXmlHandle( 0 ); } + + +bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) +{ + DoIndent(); + buffer += "<"; + buffer += element.Value(); + + for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) + { + buffer += " "; + attrib->Print( 0, 0, &buffer ); + } + + if ( !element.FirstChild() ) + { + buffer += " />"; + DoLineBreak(); + } + else + { + buffer += ">"; + if ( element.FirstChild()->ToText() + && element.LastChild() == element.FirstChild() + && element.FirstChild()->ToText()->CDATA() == false ) + { + simpleTextPrint = true; + // no DoLineBreak()! + } + else + { + DoLineBreak(); + } + } + ++depth; + return true; +} + + +bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) +{ + --depth; + if ( !element.FirstChild() ) + { + // nothing. + } + else + { + if ( simpleTextPrint ) + { + simpleTextPrint = false; + } + else + { + DoIndent(); + } + buffer += ""; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlText& text ) +{ + if ( text.CDATA() ) + { + DoIndent(); + buffer += ""; + DoLineBreak(); + } + else if ( simpleTextPrint ) + { + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + } + else + { + DoIndent(); + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) +{ + DoIndent(); + declaration.Print( 0, 0, &buffer ); + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlComment& comment ) +{ + DoIndent(); + buffer += ""; + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) +{ + DoIndent(); + buffer += "<"; + buffer += unknown.Value(); + buffer += ">"; + DoLineBreak(); + return true; +} + diff -Nru blobby-0.8-dfsg/src/tinyxml/tinyxmlerror.cpp blobby-0.9c/src/tinyxml/tinyxmlerror.cpp --- blobby-0.8-dfsg/src/tinyxml/tinyxmlerror.cpp 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/tinyxml/tinyxmlerror.cpp 2011-11-06 15:06:46.000000000 +0000 @@ -1,6 +1,6 @@ /* www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any @@ -26,7 +26,7 @@ // The goal of the seperate error file is to make the first // step towards localization. tinyxml (currently) only supports -// latin-1, but at least the error messages could now be translated. +// english error messages, but the could now be translated. // // It also cleans up the code a bit. // @@ -48,4 +48,6 @@ "Error parsing Declaration.", "Error document empty.", "Error null (0) or unexpected EOF found in input stream.", + "Error parsing CDATA.", + "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", }; diff -Nru blobby-0.8-dfsg/src/tinyxml/tinyxml.h blobby-0.9c/src/tinyxml/tinyxml.h --- blobby-0.8-dfsg/src/tinyxml/tinyxml.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/tinyxml/tinyxml.h 2011-11-06 15:06:46.000000000 +0000 @@ -1,6 +1,6 @@ /* www.sourceforge.net/projects/tinyxml -Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any @@ -26,11 +26,8 @@ #ifndef TINYXML_INCLUDED #define TINYXML_INCLUDED -//#ifdef TIXML_USE_STL -// #define TIXML_USE_STL -//#endif - #ifdef _MSC_VER +#pragma warning( push ) #pragma warning( disable : 4530 ) #pragma warning( disable : 4786 ) #endif @@ -46,25 +43,45 @@ #define DEBUG #endif -#if defined( DEBUG ) && defined( _MSC_VER ) -#include -#define TIXML_LOG OutputDebugString -#else -#define TIXML_LOG printf -#endif - #ifdef TIXML_USE_STL #include #include - #define TIXML_STRING std::string - #define TIXML_ISTREAM std::istream - #define TIXML_OSTREAM std::ostream + #include + #define TIXML_STRING std::string #else #include "tinystr.h" - #define TIXML_STRING TiXmlString - #define TIXML_OSTREAM TiXmlOutStream + #define TIXML_STRING TiXmlString #endif +// Deprecated library function hell. Compilers want to use the +// new safe versions. This probably doesn't fully address the problem, +// but it gets closer. There are too many compilers for me to fully +// test. If you get compilation troubles, undefine TIXML_SAFE +#define TIXML_SAFE + +#ifdef TIXML_SAFE + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + // Microsoft visual studio, version 2005 and higher. + #define TIXML_SNPRINTF _snprintf_s + #define TIXML_SNSCANF _snscanf_s + #define TIXML_SSCANF sscanf_s + #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + //#pragma message( "Using _sn* functions." ) + #define TIXML_SNPRINTF _snprintf + #define TIXML_SNSCANF _snscanf + #define TIXML_SSCANF sscanf + #elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + //#warning( "Using sn* functions." ) + #define TIXML_SNPRINTF snprintf + #define TIXML_SNSCANF snscanf + #define TIXML_SSCANF sscanf + #else + #define TIXML_SSCANF sscanf + #endif +#endif + class TiXmlDocument; class TiXmlElement; class TiXmlComment; @@ -75,8 +92,8 @@ class TiXmlParsingData; const int TIXML_MAJOR_VERSION = 2; -const int TIXML_MINOR_VERSION = 3; -const int TIXML_PATCH_VERSION = 2; +const int TIXML_MINOR_VERSION = 5; +const int TIXML_PATCH_VERSION = 3; /* Internal structure for tracking location of items in the XML file. @@ -91,6 +108,49 @@ }; +/** + If you call the Accept() method, it requires being passed a TiXmlVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves + are simple called with Visit(). + + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, no children of this node or its sibilings will be Visited. + + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. + + Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. + + You should never change the document from a callback. + + @sa TiXmlNode::Accept() +*/ +class TiXmlVisitor +{ +public: + virtual ~TiXmlVisitor() {} + + /// Visit a document. + virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } + /// Visit a document. + virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } + + /// Visit an element. + virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } + /// Visit an element. + virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } + + /// Visit a declaration + virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } + /// Visit a text node + virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } + /// Visit a comment node + virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } + /// Visit an unknow node + virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } +}; + // Only used by Attribute::Query functions enum { @@ -139,11 +199,15 @@ friend class TiXmlDocument; public: - TiXmlBase() : userData(0) {} - virtual ~TiXmlBase() {} + TiXmlBase() : userData(0) {} + virtual ~TiXmlBase() {} - /** All TinyXml classes can print themselves to a filestream. - This is a formatted print, and will insert tabs and newlines. + /** All TinyXml classes can print themselves to a filestream + or the string class (TiXmlString in non-STL mode, std::string + in STL mode.) Either or both cfile and str can be null. + + This is a formatted print, and will insert + tabs and newlines. (For an unformatted stream, use the << operator.) */ @@ -153,7 +217,7 @@ not. In order to make everyone happy, these global, static functions are provided to set whether or not TinyXml will condense all white space into a single space or not. The default is to condense. Note changing this - values is not thread safe. + value is not thread safe. */ static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } @@ -181,8 +245,9 @@ int Row() const { return location.row + 1; } int Column() const { return location.col + 1; } ///< See Row() - void SetUserData( void* user ) { userData = user; } - void* GetUserData() { return userData; } + void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. + void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. + const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. // Table that returs, for a given lead byte, the total number of bytes // in the UTF-8 sequence. @@ -192,29 +257,51 @@ TiXmlParsingData* data, TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; -protected: + /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, + or they will be transformed into entities! + */ + static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); - // See STL_STRING_BUG - // Utility class to overcome a bug. - class StringToBuffer + enum { - public: - StringToBuffer( const TIXML_STRING& str ); - ~StringToBuffer(); - char* buffer; + TIXML_NO_ERROR = 0, + TIXML_ERROR, + TIXML_ERROR_OPENING_FILE, + TIXML_ERROR_OUT_OF_MEMORY, + TIXML_ERROR_PARSING_ELEMENT, + TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, + TIXML_ERROR_READING_ELEMENT_VALUE, + TIXML_ERROR_READING_ATTRIBUTES, + TIXML_ERROR_PARSING_EMPTY, + TIXML_ERROR_READING_END_TAG, + TIXML_ERROR_PARSING_UNKNOWN, + TIXML_ERROR_PARSING_COMMENT, + TIXML_ERROR_PARSING_DECLARATION, + TIXML_ERROR_DOCUMENT_EMPTY, + TIXML_ERROR_EMBEDDED_NULL, + TIXML_ERROR_PARSING_CDATA, + TIXML_ERROR_DOCUMENT_TOP_ONLY, + + TIXML_ERROR_STRING_COUNT }; - static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); - inline static bool IsWhiteSpace( char c ) +protected: + + static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); + inline static bool IsWhiteSpace( char c ) { return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); } - - virtual void StreamOut (TIXML_OSTREAM *) const = 0; + inline static bool IsWhiteSpace( int c ) + { + if ( c < 256 ) + return IsWhiteSpace( (char) c ); + return false; // Again, only truly correct for English/Latin...but usually works. + } #ifdef TIXML_USE_STL - static bool StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag ); - static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag ); + static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); + static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); #endif /* Reads an XML name into the string provided. Returns @@ -243,7 +330,7 @@ assert( p ); if ( encoding == TIXML_ENCODING_UTF8 ) { - *length = utf8ByteTable[ *((unsigned char*)p) ]; + *length = utf8ByteTable[ *((const unsigned char*)p) ]; assert( *length >= 0 && *length < 5 ); } else @@ -260,7 +347,11 @@ } else if ( *length ) { - strncpy( _value, p, *length ); + //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), + // and the null terminator isn't needed + for( int i=0; p[i] && i<*length; ++i ) { + _value[i] = p[i]; + } return p + (*length); } else @@ -270,41 +361,14 @@ } } - // Puts a string to a stream, expanding entities as it goes. - // Note this should not contian the '<', '>', etc, or they will be transformed into entities! - static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out ); - - static void PutString( const TIXML_STRING& str, TIXML_STRING* out ); - // Return true if the next characters in the stream are any of the endTag sequences. // Ignore case only works for english, and should only be relied on when comparing - // to Engilish words: StringEqual( p, "version", true ) is fine. + // to English words: StringEqual( p, "version", true ) is fine. static bool StringEqual( const char* p, const char* endTag, bool ignoreCase, TiXmlEncoding encoding ); - - enum - { - TIXML_NO_ERROR = 0, - TIXML_ERROR, - TIXML_ERROR_OPENING_FILE, - TIXML_ERROR_OUT_OF_MEMORY, - TIXML_ERROR_PARSING_ELEMENT, - TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, - TIXML_ERROR_READING_ELEMENT_VALUE, - TIXML_ERROR_READING_ATTRIBUTES, - TIXML_ERROR_PARSING_EMPTY, - TIXML_ERROR_READING_END_TAG, - TIXML_ERROR_PARSING_UNKNOWN, - TIXML_ERROR_PARSING_COMMENT, - TIXML_ERROR_PARSING_DECLARATION, - TIXML_ERROR_DOCUMENT_EMPTY, - TIXML_ERROR_EMBEDDED_NULL, - - TIXML_ERROR_STRING_COUNT - }; static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; TiXmlCursor location; @@ -391,9 +455,6 @@ /// Appends the XML node or attribute to a std::string. friend std::string& operator<< (std::string& out, const TiXmlNode& base ); - #else - // Used internally, not part of the public API. - friend TIXML_OSTREAM& operator<< (TIXML_OSTREAM& out, const TiXmlNode& base); #endif /** The types of XML nodes supported by TinyXml. (All the @@ -424,7 +485,17 @@ The subclasses will wrap this function. */ - const char * Value() const { return value.c_str (); } + const char *Value() const { return value.c_str (); } + + #ifdef TIXML_USE_STL + /** Return Value() as a std::string. If you only use STL, + this is more efficient than calling Value(). + Only available in STL mode. + */ + const std::string& ValueStr() const { return value; } + #endif + + const TIXML_STRING& ValueTStr() const { return value; } /** Changes the value of the node. Defined as: @verbatim @@ -439,28 +510,38 @@ #ifdef TIXML_USE_STL /// STL std::string form. - void SetValue( const std::string& _value ) - { - StringToBuffer buf( _value ); - SetValue( buf.buffer ? buf.buffer : "" ); - } + void SetValue( const std::string& _value ) { value = _value; } #endif /// Delete all the children of this node. Does not affect 'this'. void Clear(); /// One step up the DOM. - TiXmlNode* Parent() const { return parent; } - - TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. - TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* Parent() { return parent; } + const TiXmlNode* Parent() const { return parent; } - TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. - TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. + TiXmlNode* FirstChild() { return firstChild; } + const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + /// The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* FirstChild( const char * _value ) { + // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) + // call the method, cast the return back to non-const. + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); + } + const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. + TiXmlNode* LastChild() { return lastChild; } + + const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + TiXmlNode* LastChild( const char * _value ) { + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); + } #ifdef TIXML_USE_STL - TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. #endif /** An alternate way to walk the children of a node. @@ -479,13 +560,20 @@ the next one. If the previous child is null, it returns the first. IterateChildren will return null when done. */ - TiXmlNode* IterateChildren( TiXmlNode* previous ) const; + const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); + } /// This flavor of IterateChildren searches for children with a particular 'value' - TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ) const; + const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); + } #ifdef TIXML_USE_STL - TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. #endif /** Add a new node related to this. Adds a child past the LastChild. @@ -524,74 +612,132 @@ bool RemoveChild( TiXmlNode* removeThis ); /// Navigate to a sibling node. - TiXmlNode* PreviousSibling() const { return prev; } + const TiXmlNode* PreviousSibling() const { return prev; } + TiXmlNode* PreviousSibling() { return prev; } /// Navigate to a sibling node. - TiXmlNode* PreviousSibling( const char * ) const; + const TiXmlNode* PreviousSibling( const char * ) const; + TiXmlNode* PreviousSibling( const char *_prev ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); + } #ifdef TIXML_USE_STL - TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. #endif /// Navigate to a sibling node. - TiXmlNode* NextSibling() const { return next; } + const TiXmlNode* NextSibling() const { return next; } + TiXmlNode* NextSibling() { return next; } /// Navigate to a sibling node with the given 'value'. - TiXmlNode* NextSibling( const char * ) const; + const TiXmlNode* NextSibling( const char * ) const; + TiXmlNode* NextSibling( const char* _next ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); + } /** Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element. */ - TiXmlElement* NextSiblingElement() const; + const TiXmlElement* NextSiblingElement() const; + TiXmlElement* NextSiblingElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); + } /** Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element. */ - TiXmlElement* NextSiblingElement( const char * ) const; + const TiXmlElement* NextSiblingElement( const char * ) const; + TiXmlElement* NextSiblingElement( const char *_next ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); + } #ifdef TIXML_USE_STL - TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. #endif /// Convenience function to get through elements. - TiXmlElement* FirstChildElement() const; + const TiXmlElement* FirstChildElement() const; + TiXmlElement* FirstChildElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); + } /// Convenience function to get through elements. - TiXmlElement* FirstChildElement( const char * value ) const; + const TiXmlElement* FirstChildElement( const char * _value ) const; + TiXmlElement* FirstChildElement( const char * _value ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); + } #ifdef TIXML_USE_STL - TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. #endif /** Query the type (as an enumerated value, above) of this node. The possible types are: DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, and DECLARATION. */ - virtual int Type() const { return type; } + int Type() const { return type; } /** Return a pointer to the Document this node lives in. Returns null if not in a document. */ - TiXmlDocument* GetDocument() const; + const TiXmlDocument* GetDocument() const; + TiXmlDocument* GetDocument() { + return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); + } /// Returns true if this node has no children. bool NoChildren() const { return !firstChild; } - TiXmlDocument* ToDocument() const { return ( this && type == DOCUMENT ) ? (TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - TiXmlElement* ToElement() const { return ( this && type == ELEMENT ) ? (TiXmlElement*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - TiXmlComment* ToComment() const { return ( this && type == COMMENT ) ? (TiXmlComment*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - TiXmlUnknown* ToUnknown() const { return ( this && type == UNKNOWN ) ? (TiXmlUnknown*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - TiXmlText* ToText() const { return ( this && type == TEXT ) ? (TiXmlText*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. - TiXmlDeclaration* ToDeclaration() const { return ( this && type == DECLARATION ) ? (TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. /** Create an exact duplicate of this node and return it. The memory must be deleted by the caller. */ virtual TiXmlNode* Clone() const = 0; + /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the + XML tree will be conditionally visited and the host will be called back + via the TiXmlVisitor interface. + + This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML is unchanged by using this + interface versus any other.) + + The interface has been based on ideas from: + + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + + Which are both good references for "visiting". + + An example of using Accept(): + @verbatim + TiXmlPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ + virtual bool Accept( TiXmlVisitor* visitor ) const = 0; + protected: TiXmlNode( NodeType _type ); @@ -601,15 +747,12 @@ #ifdef TIXML_USE_STL // The real work of the input operator. - virtual void StreamIn( TIXML_ISTREAM* in, TIXML_STRING* tag ) = 0; + virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; #endif // Figure out what is at *p, and parse it. Returns null if it is not an xml node. TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); - // Internal Value function returning a TIXML_STRING - const TIXML_STRING& SValue() const { return value ; } - TiXmlNode* parent; NodeType type; @@ -666,10 +809,16 @@ prev = next = 0; } - const char* Name() const { return name.c_str (); } ///< Return the name of this attribute. - const char* Value() const { return value.c_str (); } ///< Return the value of this attribute. - const int IntValue() const; ///< Return the value of this attribute, converted to an integer. - const double DoubleValue() const; ///< Return the value of this attribute, converted to a double. + const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. + const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. + #ifdef TIXML_USE_STL + const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. + #endif + int IntValue() const; ///< Return the value of this attribute, converted to an integer. + double DoubleValue() const; ///< Return the value of this attribute, converted to a double. + + // Get the tinyxml string representation + const TIXML_STRING& NameTStr() const { return name; } /** QueryIntValue examines the value string. It is an alternative to the IntValue() method with richer error checking. @@ -680,35 +829,34 @@ A specialized but useful call. Note that for success it returns 0, which is the opposite of almost all other TinyXml calls. */ - int QueryIntValue( int* value ) const; + int QueryIntValue( int* _value ) const; /// QueryDoubleValue examines the value string. See QueryIntValue(). - int QueryDoubleValue( double* value ) const; + int QueryDoubleValue( double* _value ) const; void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. void SetValue( const char* _value ) { value = _value; } ///< Set the value. - void SetIntValue( int value ); ///< Set the value from an integer. - void SetDoubleValue( double value ); ///< Set the value from a double. + void SetIntValue( int _value ); ///< Set the value from an integer. + void SetDoubleValue( double _value ); ///< Set the value from a double. #ifdef TIXML_USE_STL /// STL std::string form. - void SetName( const std::string& _name ) - { - StringToBuffer buf( _name ); - SetName ( buf.buffer ? buf.buffer : "error" ); - } + void SetName( const std::string& _name ) { name = _name; } /// STL std::string form. - void SetValue( const std::string& _value ) - { - StringToBuffer buf( _value ); - SetValue( buf.buffer ? buf.buffer : "error" ); - } + void SetValue( const std::string& _value ) { value = _value; } #endif /// Get the next sibling attribute in the DOM. Returns null at end. - TiXmlAttribute* Next() const; + const TiXmlAttribute* Next() const; + TiXmlAttribute* Next() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); + } + /// Get the previous sibling attribute in the DOM. Returns null at beginning. - TiXmlAttribute* Previous() const; + const TiXmlAttribute* Previous() const; + TiXmlAttribute* Previous() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); + } bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } @@ -720,9 +868,11 @@ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); // Prints this Attribute to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - virtual void StreamOut( TIXML_OSTREAM * out ) const; // [internal use] // Set the document pointer so the attribute can report errors. void SetDocument( TiXmlDocument* doc ) { document = doc; } @@ -760,11 +910,29 @@ void Add( TiXmlAttribute* attribute ); void Remove( TiXmlAttribute* attribute ); - TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - TiXmlAttribute* Find( const char * name ) const; + const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + + const TiXmlAttribute* Find( const char* _name ) const; + TiXmlAttribute* Find( const char* _name ) { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); + } + #ifdef TIXML_USE_STL + const TiXmlAttribute* Find( const std::string& _name ) const; + TiXmlAttribute* Find( const std::string& _name ) { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); + } + + #endif private: + //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), + //*ME: this class must be also use a hidden/disabled copy-constructor !!! + TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed + void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) + TiXmlAttribute sentinel; }; @@ -818,37 +986,73 @@ an integer, it returns TIXML_WRONG_TYPE. If the attribute does not exist, then TIXML_NO_ATTRIBUTE is returned. */ - int QueryIntAttribute( const char* name, int* value ) const; + int QueryIntAttribute( const char* name, int* _value ) const; /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). - int QueryDoubleAttribute( const char* name, double* value ) const; + int QueryDoubleAttribute( const char* name, double* _value ) const; + /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). + int QueryFloatAttribute( const char* name, float* _value ) const { + double d; + int result = QueryDoubleAttribute( name, &d ); + if ( result == TIXML_SUCCESS ) { + *_value = (float)d; + } + return result; + } + + #ifdef TIXML_USE_STL + /** Template form of the attribute query which will try to read the + attribute into the specified type. Very easy, very powerful, but + be careful to make sure to call this with the correct type. + + NOTE: This method doesn't work correctly for 'string' types. + + @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE + */ + template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + std::stringstream sstream( node->ValueStr() ); + sstream >> *outValue; + if ( !sstream.fail() ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; + } + /* + This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string" + but template specialization is hard to get working cross-compiler. Leaving the bug for now. + + // The above will fail for std::string because the space character is used as a seperator. + // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string + template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + *outValue = node->ValueStr(); + return TIXML_SUCCESS; + } + */ + #endif /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ - void SetAttribute( const char* name, const char * value ); + void SetAttribute( const char* name, const char * _value ); #ifdef TIXML_USE_STL - const char* Attribute( const std::string& name ) const { return Attribute( name.c_str() ); } - const char* Attribute( const std::string& name, int* i ) const { return Attribute( name.c_str(), i ); } - const char* Attribute( const std::string& name, double* d ) const { return Attribute( name.c_str(), d ); } - int QueryIntAttribute( const std::string& name, int* value ) const { return QueryIntAttribute( name.c_str(), value ); } - int QueryDoubleAttribute( const std::string& name, double* value ) const { return QueryDoubleAttribute( name.c_str(), value ); } + const std::string* Attribute( const std::string& name ) const; + const std::string* Attribute( const std::string& name, int* i ) const; + const std::string* Attribute( const std::string& name, double* d ) const; + int QueryIntAttribute( const std::string& name, int* _value ) const; + int QueryDoubleAttribute( const std::string& name, double* _value ) const; /// STL std::string form. - void SetAttribute( const std::string& name, const std::string& _value ) - { - StringToBuffer n( name ); - StringToBuffer v( _value ); - if ( n.buffer && v.buffer ) - SetAttribute (n.buffer, v.buffer ); - } + void SetAttribute( const std::string& name, const std::string& _value ); ///< STL std::string form. - void SetAttribute( const std::string& name, int _value ) - { - StringToBuffer n( name ); - if ( n.buffer ) - SetAttribute (n.buffer, _value); - } + void SetAttribute( const std::string& name, int _value ); #endif /** Sets an attribute of name to a given value. The attribute @@ -868,8 +1072,44 @@ void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. #endif - TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. - TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. + const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. + TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } + const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. + TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, GetText() is limited compared to getting the TiXmlText child + and accessing it directly. + + If the first child of 'this' is a TiXmlText, the GetText() + returns the character string of the Text node, else null is returned. + + This is a convenient method for getting the text of simple contained text: + @verbatim + This is text + const char* str = fooElement->GetText(); + @endverbatim + + 'str' will be a pointer to "This is text". + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + This is text + @endverbatim + + then the value of str would be null. The first child node isn't a text node, it is + another element. From this XML: + @verbatim + This is text + @endverbatim + GetText() will return "This is ". + + WARNING: GetText() accesses a child node - don't become confused with the + similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are + safe type casts on the referenced node. + */ + const char* GetText() const; /// Creates a new Element and returns it - the returned element is a copy. virtual TiXmlNode* Clone() const; @@ -881,6 +1121,13 @@ */ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + protected: void CopyTo( TiXmlElement* target ) const; @@ -888,10 +1135,8 @@ // Used to be public [internal use] #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif - virtual void StreamOut( TIXML_OSTREAM * out ) const; - /* [internal use] Reads the "value" of the element -- another element, or text. This should terminate with the current end tag. @@ -911,6 +1156,10 @@ public: /// Constructs an empty comment. TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {} + /// Construct a comment from text. + TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) { + SetValue( _value ); + } TiXmlComment( const TiXmlComment& ); void operator=( const TiXmlComment& base ); @@ -918,7 +1167,7 @@ /// Returns a copy of this Comment. virtual TiXmlNode* Clone() const; - /// Write this Comment to a FILE stream. + // Write this Comment to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; /* Attribtue parsing starts: at the ! of the !-- @@ -926,30 +1175,44 @@ */ virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + protected: void CopyTo( TiXmlComment* target ) const; // used to be public #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif - virtual void StreamOut( TIXML_OSTREAM * out ) const; +// virtual void StreamOut( TIXML_OSTREAM * out ) const; private: }; -/** XML text. Contained in an element. +/** XML text. A text node can have 2 ways to output the next. "normal" output + and CDATA. It will default to the mode it was parsed from the XML file and + you generally want to leave it alone, but you can change the output mode with + SetCDATA() and query it with CDATA(). */ class TiXmlText : public TiXmlNode { friend class TiXmlElement; public: - /// Constructor. - TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT) + /** Constructor for text element. By default, it is treated as + normal, encoded text. If you want it be output as a CDATA text + element, set the parameter _cdata to 'true' + */ + TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT) { SetValue( initValue ); + cdata = false; } virtual ~TiXmlText() {} @@ -958,30 +1221,43 @@ TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) { SetValue( initValue ); + cdata = false; } #endif TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); } void operator=( const TiXmlText& base ) { base.CopyTo( this ); } - /// Write this text object to a FILE stream. + // Write this text object to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; + /// Queries whether this represents text using a CDATA section. + bool CDATA() const { return cdata; } + /// Turns on or off a CDATA representation of text. + void SetCDATA( bool _cdata ) { cdata = _cdata; } + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + protected : /// [internal use] Creates a new Element and returns it. virtual TiXmlNode* Clone() const; void CopyTo( TiXmlText* target ) const; - virtual void StreamOut ( TIXML_OSTREAM * out ) const; bool Blank() const; // returns true if all white space and new lines // [internal use] #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif private: + bool cdata; // true if this should be input and output as a CDATA style text element }; @@ -1030,18 +1306,27 @@ /// Creates a copy of this Declaration and returns it. virtual TiXmlNode* Clone() const; - /// Print this declaration to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; + // Print this declaration to a FILE stream. + virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + protected: void CopyTo( TiXmlDeclaration* target ) const; // used to be public #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif - virtual void StreamOut ( TIXML_OSTREAM * out) const; private: @@ -1069,18 +1354,24 @@ /// Creates a copy of this Unknown and returns it. virtual TiXmlNode* Clone() const; - /// Print this Unknown to a FILE stream. + // Print this Unknown to a FILE stream. virtual void Print( FILE* cfile, int depth ) const; virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + protected: void CopyTo( TiXmlUnknown* target ) const; #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif - virtual void StreamOut ( TIXML_OSTREAM * out ) const; private: @@ -1120,17 +1411,27 @@ bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); /// Save a file using the given filename. Returns true if successful. bool SaveFile( const char * filename ) const; + /** Load a file using the given FILE*. Returns true if successful. Note that this method + doesn't stream - the entire object pointed at by the FILE* + will be interpreted as an XML file. TinyXML doesn't stream in XML from the current + file location. Streaming may be added in the future. + */ + bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given FILE*. Returns true if successful. + bool SaveFile( FILE* ) const; #ifdef TIXML_USE_STL bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. { - StringToBuffer f( filename ); - return ( f.buffer && LoadFile( f.buffer, encoding )); +// StringToBuffer f( filename ); +// return ( f.buffer && LoadFile( f.buffer, encoding )); + return LoadFile( filename.c_str(), encoding ); } bool SaveFile( const std::string& filename ) const ///< STL std::string version. { - StringToBuffer f( filename ); - return ( f.buffer && SaveFile( f.buffer )); +// StringToBuffer f( filename ); +// return ( f.buffer && SaveFile( f.buffer )); + return SaveFile( filename.c_str() ); } #endif @@ -1144,7 +1445,8 @@ In well formed XML, there should only be one. TinyXml is tolerant of multiple elements at the document level. */ - TiXmlElement* RootElement() const { return FirstChildElement(); } + const TiXmlElement* RootElement() const { return FirstChildElement(); } + TiXmlElement* RootElement() { return FirstChildElement(); } /** If an error occurs, Error will be set to true. Also, - The ErrorId() will contain the integer identifier of the error (not generally useful) @@ -1159,7 +1461,7 @@ /** Generally, you probably want the error string ( ErrorDesc() ). But if you prefer the ErrorId, this function will fetch it. */ - const int ErrorId() const { return errorId; } + int ErrorId() const { return errorId; } /** Returns the location (if known) of the error. The first column is column 1, and the first row is row 1. A value of 0 means the row and column wasn't applicable @@ -1168,10 +1470,14 @@ @sa SetTabSize, Row, Column */ - int ErrorRow() { return errorLocation.row+1; } - int ErrorCol() { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() + int ErrorRow() const { return errorLocation.row+1; } + int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() - /** By calling this method, with a tab size + /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) + to report the correct values for row and column. It does not change the output + or input in any way. + + By calling this method, with a tab size greater than 0, the row and column of each node and attribute is stored when the file is loaded. Very useful for tracking the DOM back in to the source file. @@ -1205,20 +1511,32 @@ //errorLocation.last = 0; } - /** Dump the document to standard out. */ + /** Write the document to standard out using formatted printing ("pretty print"). */ void Print() const { Print( stdout, 0 ); } + /* Write the document to a string using formatted printing ("pretty print"). This + will allocate a character array (new char[]) and return it as a pointer. The + calling code pust call delete[] on the return char* to avoid a memory leak. + */ + //char* PrintToMemory() const; + /// Print this Document to a FILE stream. virtual void Print( FILE* cfile, int depth = 0 ) const; // [internal use] void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + protected : - virtual void StreamOut ( TIXML_OSTREAM * out) const; // [internal use] virtual TiXmlNode* Clone() const; #ifdef TIXML_USE_STL - virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); #endif private: @@ -1229,6 +1547,7 @@ TIXML_STRING errorDesc; int tabsize; TiXmlCursor errorLocation; + bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. }; @@ -1272,7 +1591,7 @@ @verbatim TiXmlHandle docHandle( &document ); - TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).Element(); + TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); if ( child2 ) { // do something useful @@ -1291,7 +1610,7 @@ int i=0; while ( true ) { - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).Element(); + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); if ( !child ) break; // do something @@ -1304,7 +1623,7 @@ to. Instead, prefer: @verbatim - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).Element(); + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); for( child; child; child=child->NextSiblingElement() ) { @@ -1316,7 +1635,7 @@ { public: /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. - TiXmlHandle( TiXmlNode* node ) { this->node = node; } + TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } /// Copy constructor TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } @@ -1357,19 +1676,127 @@ TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } #endif - /// Return the handle as a TiXmlNode. This may return null. - TiXmlNode* Node() const { return node; } - /// Return the handle as a TiXmlElement. This may return null. - TiXmlElement* Element() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } - /// Return the handle as a TiXmlText. This may return null. - TiXmlText* Text() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } - /// Return the handle as a TiXmlUnknown. This may return null; - TiXmlUnknown* Unknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } + /** Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* ToNode() const { return node; } + /** Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } + /** Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } + /** Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } + + /** @deprecated use ToNode. + Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* Node() const { return ToNode(); } + /** @deprecated use ToElement. + Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* Element() const { return ToElement(); } + /** @deprecated use ToText() + Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* Text() const { return ToText(); } + /** @deprecated use ToUnknown() + Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* Unknown() const { return ToUnknown(); } private: TiXmlNode* node; }; +/** Print to memory functionality. The TiXmlPrinter is useful when you need to: + + -# Print to memory (especially in non-STL mode) + -# Control formatting (line endings, etc.) + + When constructed, the TiXmlPrinter is in its default "pretty printing" mode. + Before calling Accept() you can call methods to control the printing + of the XML document. After TiXmlNode::Accept() is called, the printed document can + be accessed via the CStr(), Str(), and Size() methods. + + TiXmlPrinter uses the Visitor API. + @verbatim + TiXmlPrinter printer; + printer.SetIndent( "\t" ); + + doc.Accept( &printer ); + fprintf( stdout, "%s", printer.CStr() ); + @endverbatim +*/ +class TiXmlPrinter : public TiXmlVisitor +{ +public: + TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), + buffer(), indent( " " ), lineBreak( "\n" ) {} + + virtual bool VisitEnter( const TiXmlDocument& doc ); + virtual bool VisitExit( const TiXmlDocument& doc ); + + virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); + virtual bool VisitExit( const TiXmlElement& element ); + + virtual bool Visit( const TiXmlDeclaration& declaration ); + virtual bool Visit( const TiXmlText& text ); + virtual bool Visit( const TiXmlComment& comment ); + virtual bool Visit( const TiXmlUnknown& unknown ); + + /** Set the indent characters for printing. By default 4 spaces + but tab (\t) is also useful, or null/empty string for no indentation. + */ + void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } + /// Query the indention string. + const char* Indent() { return indent.c_str(); } + /** Set the line breaking string. By default set to newline (\n). + Some operating systems prefer other characters, or can be + set to the null/empty string for no indenation. + */ + void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } + /// Query the current line breaking string. + const char* LineBreak() { return lineBreak.c_str(); } + + /** Switch over to "stream printing" which is the most dense formatting without + linebreaks. Common when the XML is needed for network transmission. + */ + void SetStreamPrinting() { indent = ""; + lineBreak = ""; + } + /// Return the result. + const char* CStr() { return buffer.c_str(); } + /// Return the length of the result string. + size_t Size() { return buffer.size(); } + + #ifdef TIXML_USE_STL + /// Return the result. + const std::string& Str() { return buffer; } + #endif + +private: + void DoIndent() { + for( int i=0; i +#include + +#include "tinyxml.h" //#define DEBUG_PARSER +#if defined( DEBUG_PARSER ) +# if defined( DEBUG ) && defined( _MSC_VER ) +# include +# define TIXML_LOG OutputDebugString +# else +# define TIXML_LOG printf +# endif +#endif // Note tha "PutString" hardcodes the same list. This // is less flexible than it appears. Changing the entries @@ -49,7 +59,9 @@ // ef bf be // ef bf bf - +const unsigned char TIXML_UTF_LEAD_0 = 0xefU; +const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; +const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; const int TiXmlBase::utf8ByteTable[256] = { @@ -114,7 +126,7 @@ } -/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ) +/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) { // This will only work for low-ascii, everything else is assumed to be a valid // letter. I'm not sure this is the best approach, but it is quite tricky trying @@ -135,7 +147,7 @@ } -/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ) +/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) { // This will only work for low-ascii, everything else is assumed to be a valid // letter. I'm not sure this is the best approach, but it is quite tricky trying @@ -199,8 +211,11 @@ while ( p < now ) { + // Treat p as unsigned, so we have a happy compiler. + const unsigned char* pU = (const unsigned char*)p; + // Code contributed by Fletcher Dunn: (modified by lee) - switch (*p) { + switch (*pU) { case 0: // We *should* never get here, but in case we do, don't // advance past the terminating null character, ever @@ -243,18 +258,18 @@ col = (col / tabsize + 1) * tabsize; break; - case (char)(0xef): + case TIXML_UTF_LEAD_0: if ( encoding == TIXML_ENCODING_UTF8 ) { if ( *(p+1) && *(p+2) ) { // In these cases, don't advance the column. These are // 0-width spaces. - if ( *(p+1)==(char)(0xbb) && *(p+2)==(char)(0xbf) ) + if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) p += 3; - else if ( *(p+1)==(char)(0xbf) && *(p+2)==(char)(0xbe) ) + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) p += 3; - else if ( *(p+1)==(char)(0xbf) && *(p+2)==(char)(0xbf) ) + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) p += 3; else { p +=3; ++col; } // A normal character. @@ -271,7 +286,7 @@ if ( encoding == TIXML_ENCODING_UTF8 ) { // Eat the 1 to 4 byte utf8 character. - int step = TiXmlBase::utf8ByteTable[*((unsigned char*)p)]; + int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; if ( step == 0 ) step = 1; // Error case from bad encoding, but handle gracefully. p += step; @@ -306,24 +321,26 @@ { while ( *p ) { + const unsigned char* pU = (const unsigned char*)p; + // Skip the stupid Microsoft UTF-8 Byte order marks - if ( *(p+0)==(char) 0xef - && *(p+1)==(char) 0xbb - && *(p+2)==(char) 0xbf ) + if ( *(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==TIXML_UTF_LEAD_1 + && *(pU+2)==TIXML_UTF_LEAD_2 ) { p += 3; continue; } - else if(*(p+0)==(char) 0xef - && *(p+1)==(char) 0xbf - && *(p+2)==(char) 0xbe ) + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbeU ) { p += 3; continue; } - else if(*(p+0)==(char) 0xef - && *(p+1)==(char) 0xbf - && *(p+2)==(char) 0xbf ) + else if(*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbfU ) { p += 3; continue; @@ -345,7 +362,7 @@ } #ifdef TIXML_USE_STL -/*static*/ bool TiXmlBase::StreamWhiteSpace( TIXML_ISTREAM * in, TIXML_STRING * tag ) +/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) { for( ;; ) { @@ -360,7 +377,7 @@ } } -/*static*/ bool TiXmlBase::StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag ) +/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) { //assert( character > 0 && character < 128 ); // else it won't work in utf-8 while ( in->good() ) @@ -378,8 +395,14 @@ } #endif +// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The +// "assign" optimization removes over 10% of the execution time. +// const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) { + // Oddly, not supported on some comilers, + //name->clear(); + // So use this: *name = ""; assert( p ); @@ -393,6 +416,7 @@ if ( p && *p && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) { + const char* start = p; while( p && *p && ( IsAlphaNum( (unsigned char ) *p, encoding ) || *p == '_' @@ -400,9 +424,12 @@ || *p == '.' || *p == ':' ) ) { - (*name) += *p; + //(*name) += *p; // expensive ++p; } + if ( p-start > 0 ) { + name->assign( start, p-start ); + } return p; } return 0; @@ -418,7 +445,7 @@ if ( *(p+1) && *(p+1) == '#' && *(p+2) ) { unsigned long ucs = 0; - unsigned delta = 0; + ptrdiff_t delta = 0; unsigned mult = 1; if ( *(p+2) == 'x' ) @@ -498,6 +525,8 @@ // So it wasn't an entity, its unrecognized, or something like that. *value = *p; // Don't put back the last one, since we return it! + //*length = 1; // Leave unrecognized entities - this doesn't really work. + // Just writes strange XML. return p+1; } @@ -602,12 +631,14 @@ } } } - return p + strlen( endTag ); + if ( p ) + p += strlen( endTag ); + return p; } #ifdef TIXML_USE_STL -void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) +void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) { // The basic issue with a document is that we don't know what we're // streaming. Read something presumed to be a tag (and hope), then @@ -703,11 +734,13 @@ if ( encoding == TIXML_ENCODING_UNKNOWN ) { // Check for the Microsoft UTF-8 lead bytes. - if ( *(p+0) && *(p+0) == (char)(0xef) - && *(p+1) && *(p+1) == (char)(0xbb) - && *(p+2) && *(p+2) == (char)(0xbf) ) + const unsigned char* pU = (const unsigned char*)p; + if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 + && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 + && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) { encoding = TIXML_ENCODING_UTF8; + useMicrosoftBOM = true; } } @@ -752,6 +785,12 @@ p = SkipWhiteSpace( p, encoding ); } + // Was this empty? + if ( !firstChild ) { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); + return 0; + } + // All is well. return p; } @@ -770,7 +809,6 @@ errorLocation.Clear(); if ( pError && data ) { - //TiXmlParsingData data( pError, prevData ); data->Stamp( pError, encoding ); errorLocation = data->Cursor(); } @@ -805,6 +843,7 @@ const char* xmlHeader = { "SetCDATA( true ); + returnNode = text; + } else if ( StringEqual( p, dtdHeader, false, encoding ) ) { #ifdef DEBUG_PARSER @@ -858,7 +906,7 @@ #ifdef TIXML_USE_STL -void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) +void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) { // We're called with some amount of pre-parsing. That is, some of "this" // element is in "tag". Go ahead and stream to the closing ">" @@ -893,6 +941,7 @@ { // There is more. Could be: // text + // cdata text (which looks like another node) // closing tag // another node. for ( ;; ) @@ -915,7 +964,7 @@ // We should be at a "<", regardless. if ( !in->good() ) return; assert( in->peek() == '<' ); - int tagIndex = tag->length(); + int tagIndex = (int) tag->length(); bool closingTag = false; bool firstCharFound = false; @@ -940,6 +989,17 @@ *tag += (char) c; in->get(); + // Early out if we find the CDATA id. + if ( c == '[' && tag->size() >= 9 ) + { + size_t len = tag->size(); + const char* start = tag->c_str() + len - 9; + if ( strcmp( start, "Stamp( p, encoding ); @@ -1055,8 +1114,12 @@ // elements -- read the end tag, and return. ++p; p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens. - if ( !p || !*p ) + if ( !p || !*p ) { + // We were looking for the end tag, but found nothing. + // Fix for [ 1663758 ] Failure to report error on bad XML + if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); return 0; + } // We should find the end tag now if ( StringEqual( p, endTag.c_str(), false, encoding ) ) @@ -1081,7 +1144,7 @@ } attrib->SetDocument( document ); - const char* pErr = p; + pErr = p; p = attrib->Parse( p, data, encoding ); if ( !p || !*p ) @@ -1092,7 +1155,11 @@ } // Handle the strange case of double attributes: + #ifdef TIXML_USE_STL + TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() ); + #else TiXmlAttribute* node = attributeSet.Find( attrib->Name() ); + #endif if ( node ) { node->SetValue( attrib->Value() ); @@ -1111,9 +1178,10 @@ { TiXmlDocument* document = GetDocument(); - const char* pWithWhiteSpace = p; // Read in text and elements in any order. + const char* pWithWhiteSpace = p; p = SkipWhiteSpace( p, encoding ); + while ( p && *p ) { if ( *p != '<' ) @@ -1146,7 +1214,8 @@ else { // We hit a '<' - // Have we hit a new element or an end tag? + // Have we hit a new element or an end tag? This could also be + // a TiXmlText in the "CDATA" style. if ( StringEqual( p, "good() ) { @@ -1206,7 +1276,6 @@ TiXmlDocument* document = GetDocument(); p = SkipWhiteSpace( p, encoding ); -// TiXmlParsingData data( p, prevData ); if ( data ) { data->Stamp( p, encoding ); @@ -1236,7 +1305,7 @@ } #ifdef TIXML_USE_STL -void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) +void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag ) { while ( in->good() ) { @@ -1270,7 +1339,6 @@ p = SkipWhiteSpace( p, encoding ); -// TiXmlParsingData data( p, prevData ); if ( data ) { data->Stamp( p, encoding ); @@ -1285,7 +1353,35 @@ return 0; } p += strlen( startTag ); - p = ReadText( p, &value, false, endTag, false, encoding ); + + // [ 1475201 ] TinyXML parses entities in comments + // Oops - ReadText doesn't work, because we don't want to parse the entities. + // p = ReadText( p, &value, false, endTag, false, encoding ); + // + // from the XML spec: + /* + [Definition: Comments may appear anywhere in a document outside other markup; in addition, + they may appear within the document type declaration at places allowed by the grammar. + They are not part of the document's character data; an XML processor MAY, but need not, + make it possible for an application to retrieve the text of comments. For compatibility, + the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity + references MUST NOT be recognized within comments. + + An example of a comment: + + + */ + + value = ""; + // Keep all the white space. + while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) + { + value.append( p, 1 ); + ++p; + } + if ( p ) + p += strlen( endTag ); + return p; } @@ -1295,11 +1391,10 @@ p = SkipWhiteSpace( p, encoding ); if ( !p || !*p ) return 0; - int tabsize = 4; - if ( document ) - tabsize = document->TabSize(); +// int tabsize = 4; +// if ( document ) +// tabsize = document->TabSize(); -// TiXmlParsingData data( p, prevData ); if ( data ) { data->Stamp( p, encoding ); @@ -1329,17 +1424,19 @@ } const char* end; + const char SINGLE_QUOTE = '\''; + const char DOUBLE_QUOTE = '\"'; - if ( *p == '\'' ) + if ( *p == SINGLE_QUOTE ) { ++p; - end = "\'"; + end = "\'"; // single quote in string p = ReadText( p, &value, false, end, false, encoding ); } - else if ( *p == '"' ) + else if ( *p == DOUBLE_QUOTE ) { ++p; - end = "\""; + end = "\""; // double quote in string p = ReadText( p, &value, false, end, false, encoding ); } else @@ -1348,10 +1445,17 @@ // But this is such a common error that the parser will try // its best, even without them. value = ""; - while ( p && *p // existence + while ( p && *p // existence && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace - && *p != '/' && *p != '>' ) // tag end + && *p != '/' && *p != '>' ) // tag end { + if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { + // [ 1451649 ] Attribute values with trailing quotes not handled correctly + // We did not have an opening quote but seem to have a + // closing one. Give up and throw an error. + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } value += *p; ++p; } @@ -1360,13 +1464,15 @@ } #ifdef TIXML_USE_STL -void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) +void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) { while ( in->good() ) { int c = in->peek(); - if ( c == '<' ) + if ( !cdata && (c == '<' ) ) + { return; + } if ( c <= 0 ) { TiXmlDocument* document = GetDocument(); @@ -1376,7 +1482,15 @@ } (*tag) += (char) c; - in->get(); + in->get(); // "commits" the peek made above + + if ( cdata && c == '>' && tag->size() >= 3 ) { + size_t len = tag->size(); + if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { + // terminator of cdata. + return; + } + } } } #endif @@ -1384,23 +1498,55 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) { value = ""; -// TiXmlParsingData data( p, prevData ); + TiXmlDocument* document = GetDocument(); + if ( data ) { data->Stamp( p, encoding ); location = data->Cursor(); } - bool ignoreWhite = true; - const char* end = "<"; - p = ReadText( p, &value, ignoreWhite, end, false, encoding ); - if ( p ) - return p-1; // don't truncate the '<' - return 0; + const char* const startTag = ""; + + if ( cdata || StringEqual( p, startTag, false, encoding ) ) + { + cdata = true; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // Keep all the white space, ignore the encoding, etc. + while ( p && *p + && !StringEqual( p, endTag, false, encoding ) + ) + { + value += *p; + ++p; + } + + TIXML_STRING dummy; + p = ReadText( p, &dummy, false, endTag, false, encoding ); + return p; + } + else + { + bool ignoreWhite = true; + + const char* end = "<"; + p = ReadText( p, &value, ignoreWhite, end, false, encoding ); + if ( p ) + return p-1; // don't truncate the '<' + return 0; + } } #ifdef TIXML_USE_STL -void TiXmlDeclaration::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) +void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) { while ( in->good() ) { @@ -1434,7 +1580,6 @@ if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); return 0; } -// TiXmlParsingData data( p, prevData ); if ( data ) { data->Stamp( p, _encoding ); diff -Nru blobby-0.8-dfsg/src/UserConfig.h blobby-0.9c/src/UserConfig.h --- blobby-0.8-dfsg/src/UserConfig.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/UserConfig.h 2011-11-06 15:06:46.000000000 +0000 @@ -19,7 +19,7 @@ #pragma once -#include +#include #include struct UserConfigVar diff -Nru blobby-0.8-dfsg/src/Vector.h blobby-0.9c/src/Vector.h --- blobby-0.8-dfsg/src/Vector.h 2009-12-26 03:54:49.000000000 +0000 +++ blobby-0.9c/src/Vector.h 2011-11-06 15:06:46.000000000 +0000 @@ -42,16 +42,16 @@ void clear(); - Vector2 reflectX(); - Vector2 reflectY(); - Vector2 scale(float factor); - Vector2 scaleX(float factor); - Vector2 scaleY(float factor); + Vector2 reflectX() const; + Vector2 reflectY() const; + Vector2 scale(float factor) const; + Vector2 scaleX(float factor) const; + Vector2 scaleY(float factor) const; float length() const; Vector2 normalise(); - Vector2 contraVector(); + Vector2 contraVector() const ; - inline Vector2 halfVector(const Vector2& vec) + inline Vector2 halfVector(const Vector2& vec) const { return Vector2(x + (vec.x - x) / 2, y + (vec.y - y) / 2); } @@ -88,7 +88,7 @@ return Vector2(x * scalar, y * scalar); } - inline Vector2 operator * (Vector2 vector) const + inline Vector2 operator * (const Vector2& vector) const { return Vector2(x * vector.x, y * vector.y); } @@ -105,21 +105,21 @@ return Vector2(-x, -y); } - inline Vector2& operator += (Vector2 vector) + inline Vector2& operator += (const Vector2& vector) { x += vector.x; y += vector.y; return *this; } - inline Vector2& operator -= (Vector2 vector) + inline Vector2& operator -= (const Vector2& vector) { x -= vector.x; y -= vector.y; return *this; } - inline Vector2& operator *= (Vector2 vector) + inline Vector2& operator *= (const Vector2& vector) { x *= vector.x; y *= vector.y; @@ -127,17 +127,17 @@ } - inline float dotProduct(const Vector2& vector) + inline float dotProduct(const Vector2& vector) const { return x * vector.x + y * vector.y; } - inline float crossProduct(const Vector2& vector) + inline float crossProduct(const Vector2& vector) const { return x * vector.y - y * vector.x; } - inline Vector2 reflect(const Vector2& normal) + inline Vector2 reflect(const Vector2& normal) const { return Vector2(*this - (normal * 2 * dotProduct(normal))); } @@ -145,45 +145,40 @@ }; -inline Vector2::Vector2() +inline Vector2::Vector2() : x(0), y(0) { - this->x=0; - this->y=0; } -inline Vector2::Vector2(float x, float y) +inline Vector2::Vector2(float a, float b) : x(a), y(b) { - this->x=x; - this->y=y; } -inline Vector2::Vector2(const Vector2& v1, const Vector2& v2) +inline Vector2::Vector2(const Vector2& v1, const Vector2& v2) : x(v2.x - v1.x), y(v2.y - v1.y) { - x = v2.x - v1.x; - y = v2.y - v1.y; + } -inline Vector2 Vector2::reflectX() +inline Vector2 Vector2::reflectX() const { return Vector2(-x, y); } -inline Vector2 Vector2::reflectY() +inline Vector2 Vector2::reflectY() const { return Vector2(x, -y); } -inline Vector2 Vector2::scale(float factor) +inline Vector2 Vector2::scale(float factor) const { return Vector2(x * factor, y * factor); } -inline Vector2 Vector2::scaleX(float factor) +inline Vector2 Vector2::scaleX(float factor) const { return Vector2(x * factor, y); } -inline Vector2 Vector2::scaleY(float factor) +inline Vector2 Vector2::scaleY(float factor) const { return Vector2(x, y * factor); } @@ -218,7 +213,7 @@ return *this; } -inline Vector2 Vector2::contraVector() +inline Vector2 Vector2::contraVector() const { return Vector2(-x, -y); } @@ -229,7 +224,7 @@ y = 0.0; } -inline bool operator < (Vector2 v1, Vector2 v2) +inline bool operator < (const Vector2& v1, const Vector2& v2) { if (v1.x < v2.x) if (v1.y < v2.y) @@ -238,7 +233,7 @@ } -inline bool operator > (Vector2 v1, Vector2 v2) +inline bool operator > (const Vector2& v1, const Vector2& v2) { if (v1.x > v2.x) if (v1.y > v2.y) diff -Nru blobby-0.8-dfsg/TODO blobby-0.9c/TODO --- blobby-0.8-dfsg/TODO 2009-12-26 03:54:55.000000000 +0000 +++ blobby-0.9c/TODO 2011-11-06 15:06:50.000000000 +0000 @@ -2,17 +2,36 @@ coderework: - new clean rendererarchitecture +- multithreading + fps independent physics +- new gui system +- more lua scripting features: - option for 3 types of shadow (off, pixelshadow, alphablendingshadow) -- chatfuncion - lobbysystem +- full unicode support (e.g. for Russian characters) +- improve replays (fast forward, rewind, etc) +- improve bot system (more commands etc) +- more dedicated server options (black/whitelist, statistics, etc) bugs: -- glitsches in IMGUI if you redraw a whole site in the menu -- wrong servername in hosted game by blobbyclient -- graphicglitch if you start a networkgame -- wrong blobbycolors in networkgame +- mouse-input does not work very good in online-game +- net bugs: + - squeezing ball through blocking blobby ? + Please try to verify this + +- only two hits acceptet under special circumstances? + Replay which shows this problem + +- mouse freezed in upper right corner after leaving the game (fullscreen mode, SDL) data: -- new smaller font +- new smaller font (current one too small?) +- monochrome font +- more translation + +FOR 0.9 final: + auto select chat editbox + mouse freeze bug? hopefully + esc key in chat \ No newline at end of file