sm00thslp / hedgewars

Automatically exported from code.google.com/p/hedgewars
GNU General Public License v2.0
0 stars 0 forks source link

Graph in stats screen can’t handle negative numbers #833

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
There’s a problem with the graph seen in the stats screen.
It is not capable of representing negative numbers.

I noticed this bug while experimenting with the Lua API to manipulate the graph.

Below the long line is the complete source code of a script I used for testing. 
To test, simply start a match with 8 teams and activate this script.
The script draws several lines which start at a positive value and will become 
negative eventually. The game immediately ends and will get you to the stats 
screen.
What I expect to see are several straight lines which go downwards. What I 
actually see are lines which are simply cut off at 0.

---------------------------------

HedgewarsScriptLoad("/Scripts/Tracker.lua")

local uniqueTeams = {}

function insertTeam(hog)
    if(GetGearType(hog) == gtHedgehog) then
        WriteLnToConsole("[Stats script] insertTeam called.")
        local name = GetHogTeamName(hog)
        local clanID = GetHogClan(hog)
        if(uniqueTeams[clanID] == nil) then
            uniqueTeams[clanID] = name
            WriteLnToConsole("[Stats script] Team added: "..name)
        end
        trackDeletion(hog)
    end
end

function getAllTeamNames()
    WriteLnToConsole("[Stats script] getAllTeamNames called.")
    runOnGears(insertTeam)
end

function onGameStart()
    WriteLnToConsole("[Stats script] Hello!")
    SendHealthStatsOff()
    getAllTeamNames()

    for i=0,ClansCount-1 do
        for j=1,10 do
            SendStat(siClanHealth, tostring(4-j-i), uniqueTeams[i])
        end
    end
    EndGame()
end

function onGearAdd(gear)
    if(GetGearType(gear) == gtHedgehog) then
        WriteLnToConsole("[Stats script] trackGear.")
        trackGear(gear)
    end
end

Original issue reported on code.google.com by almikes@aol.com on 24 Nov 2014 at 12:54