# HG changeset patch # User sheepluva # Date 1407930079 -7200 # Node ID 07ae8fd1d7d46a780a9bf07785f3abde16cf1453 # Parent caa5b40e405b24b6980552a6c65c8c4fe9817bf1 add test I used for bisecting diff -r caa5b40e405b -r 07ae8fd1d7d4 CMakeLists.txt --- a/CMakeLists.txt Wed Aug 13 13:36:35 2014 +0200 +++ b/CMakeLists.txt Wed Aug 13 13:41:19 2014 +0200 @@ -244,3 +244,4 @@ add_test("LuaAPI:GetGravity/SetGravity" "bin/hwengine" "--prefix" "${TESTSDATADIR}" "--nosound" "--nomusic" ${STATSONLYFLAG} "--lua-test" "${LUAAPITESTS}/gravity_get_set.lua") add_test("DrillRockets_drill" "bin/hwengine" "--prefix" "${TESTSDATADIR}" "--nosound" "--nomusic" ${STATSONLYFLAG} "--lua-test" "${LUATESTS}/drillrockets_drill.lua") add_test("DrillRockets_boom" "bin/hwengine" "--prefix" "${TESTSDATADIR}" "--nosound" "--nomusic" ${STATSONLYFLAG} "--lua-test" "${LUATESTS}/drillrockets_boom.lua") +add_test("HellishFire_burns" "bin/hwengine" "--prefix" "${TESTSDATADIR}" "--nosound" "--nomusic" ${STATSONLYFLAG} "--lua-test" "${LUATESTS}/hellfire_burns.lua") diff -r caa5b40e405b -r 07ae8fd1d7d4 tests/lua/hellfire_burns.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/lua/hellfire_burns.lua Wed Aug 13 13:41:19 2014 +0200 @@ -0,0 +1,109 @@ + + -- taken from http://code.google.com/p/hedgewars/wiki/LuaDrawing + PointsBuffer = '' -- A string to accumulate points in + function AddPoint(x, y, width, erase) + PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff)) + if width then + width = bor(width,0x80) + if erase then + width = bor(width,0x40) + end + PointsBuffer = PointsBuffer .. string.char(width) + else + PointsBuffer = PointsBuffer .. string.char(0) + end + if #PointsBuffer > 245 then + ParseCommand('draw '..PointsBuffer) + PointsBuffer = '' + end + end + function FlushPoints() + if #PointsBuffer > 0 then + ParseCommand('draw '..PointsBuffer) + PointsBuffer = '' + end + end + + +local ta_pointsize = 63 +local ta_radius = (ta_pointsize * 10 + 6) / 2 + +local sqrttwo = math.sqrt(2) + +-- creates round test area +function AddTestArea(testarea) + step = 100 + xstep = step * testarea["xdir"] + ystep = step * testarea["ydir"] + x = testarea["x"] + y = testarea["y"] + if xstep * ystep ~= 0 then + xstep = math.floor(xstep / sqrttwo) + ystep = math.floor(ystep / sqrttwo) + end + AddPoint(x, y, ta_pointsize); + AddPoint(x + xstep, y + ystep, ta_pointsize, true); +end + +-- vertical test area +local taa_v2 = {x= 350, y=1500, xdir= 0, ydir=-1} + +-- fail counter +local nfailed = 0 +local nspawned = 0 +local ndied = 0 + +function onGameInit() + -- At first we have to overwrite/set some global variables + -- that define the map, the game has to load, as well as + -- other things such as the game rules to use, etc. + -- Things we don't modify here will use their default values. + + -- The base number for the random number generator + Seed = 1 + -- The map to be played + MapGen = 2 + -- The theme to be used + Theme = "Bamboo" + -- Game settings and rules + EnableGameFlags(gfOneClanMode, gfDisableWind, gfDisableLandObjects, gfDisableGirders) + CaseFreq = 0 + MinesNum = 0 + Explosives = 0 + + -- No damage please + DamagePercent = 1 + + -- Draw Map + AddPoint(10,30,0) -- hog spawn platform + -- test areas + AddTestArea(taa_v2) + + FlushPoints() + + -- Create the player team + AddTeam("'Zooka Team", 14483456, "Simple", "Island", "Default") + -- And add a hog to it + player = AddHog("Hunter", 0, 1, "NoHat") + -- place it on how spawn platform + SetGearPosition(player, 10, 10) +end + + +function onGameTick20(gear) + if not TestRectForObstacle(300, 1500, 400, 1900, true) then + WriteLnToConsole('HOLE DETECTED') + EndLuaTest(TEST_SUCCESSFUL) + end +end + +function onNewTurn() + WriteLnToConsole('FIRE DID NOT BURN HOLE!') + EndLuaTest(TEST_FAILED) +end + + +function onGameStart() + AddGear(350, 1500, gtHellishBomb, 0, 0, 0, 0) +end +