View Issue Details

IDProjectCategoryView StatusLast Update
0000927Spring engineUnit Scriptingpublic2008-10-19 00:02
ReporterTheFatController Assigned Toimbaczek  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.76b1 
Summary0000927: LUA Spring.GetTeamResources does not return "received" for one player on each team
DescriptionThis has caused problems in my metal maker widget

Spring.GetTeamResources always reports 0 for energy received from allies for the player with the highest ID number on each team.

To reproduce use the attached widget and watch a replay, which ever player has the highest ID number by their name on either team will never be reported as receiving energy from their allies even when they are.
TagsNo tags attached.
Attached Files
erec_spy.lua (Attachment missing)
927.sdf (Attachment missing)
Checked infolog.txt for Errors

Activities

tvo

2008-05-21 17:13

reporter   ~0002308

I didn't try to reproduce but looked at SVN trunk code and I can't explain it from that.

LuaSyncedRead::GetTeamResources is trivially simple, it just gets it's values from CTeam.

CTeam does most complex stuff with resources in CTeam::SlowUpdate, I looked at that method too but it seems correct (don't see any reason that may cause one team to have 0 energyReceived)

Does it still happen in SVN trunk at all?

TheFatController

2008-10-18 16:43

reporter   ~0002987

This bug is still present

Try opening any demo recorded in the new spring version, turn on the erec_spy widget and watch the person with the highest number by their name for a given team, the script will never output any value cause received is always being passed as 0.

imbaczek

2008-10-18 21:48

reporter   ~0002988

this is the whole function:

int LuaSyncedRead::GetTeamResources(lua_State* L)
{
    const CTeam* team = ParseTeam(L, __FUNCTION__, 1);
    if (team == NULL) {
        return 0;
    }
    const int teamID = team->teamNum;

    if (!IsAlliedTeam(teamID)) {
        return 0;
    }

    const string type = luaL_checkstring(L, 2);
    if (type == "metal") {
        lua_pushnumber(L, team->metal);
        lua_pushnumber(L, team->metalStorage);
        lua_pushnumber(L, team->prevMetalPull);
        lua_pushnumber(L, team->prevMetalIncome);
        lua_pushnumber(L, team->prevMetalExpense);
        lua_pushnumber(L, team->metalShare);
        lua_pushnumber(L, team->metalSent);
        lua_pushnumber(L, team->metalReceived);
        return 8;
    }
    else if (type == "energy") {
        lua_pushnumber(L, team->energy);
        lua_pushnumber(L, team->energyStorage);
        lua_pushnumber(L, team->prevEnergyPull);
        lua_pushnumber(L, team->prevEnergyIncome);
        lua_pushnumber(L, team->prevEnergyExpense);
        lua_pushnumber(L, team->energyShare);
        lua_pushnumber(L, team->energySent);
        lua_pushnumber(L, team->energyReceived);
        return 8;
    }

    return 0;
}

not really a place that can break. the bug must be somewhere else and deeper in the engine.

imbaczek

2008-10-18 22:53

reporter   ~0002989

Last edited: 2008-10-18 22:58

attached a replay that reproduces the issue.

btw you'll probably have to edit ai paths (or remove them altogether.)

imbaczek

2008-10-18 23:40

reporter   ~0002990

Last edited: 2008-10-18 23:44

Team::SlowUpdate makes no sense: (allies are 0+2 and 1+3)

[ 1056] reseting energyReceived for team 0
[ 1056] team 2 esent=0.000000 erecv=25.000000 edif=25.000000
[ 1056] reseting energyReceived for team 1
[ 1056] team 3 esent=0.000000 erecv=0.000000 edif=0.000000
[ 1056] reseting energyReceived for team 2
[ 1056] team 0 esent=25.000000 erecv=0.000000 edif=0.000000
[ 1056] reseting energyReceived for team 3
[ 1056] team 1 esent=0.000000 erecv=0.000000 edif=0.000000
[ 1056] reseting energyReceived for team 4

edit: fix on the way...

imbaczek

2008-10-19 00:02

reporter   ~0002991

r6818

Issue History

Date Modified Username Field Change
2008-05-08 19:50 TheFatController New Issue
2008-05-08 19:50 TheFatController File Added: erec_spy.lua
2008-05-21 17:13 tvo Note Added: 0002308
2008-10-18 16:43 TheFatController Note Added: 0002987
2008-10-18 21:48 imbaczek Note Added: 0002988
2008-10-18 22:51 imbaczek File Added: 927.sdf
2008-10-18 22:53 imbaczek Note Added: 0002989
2008-10-18 22:53 imbaczek Status new => confirmed
2008-10-18 22:58 imbaczek Note Edited: 0002989
2008-10-18 23:40 imbaczek Note Added: 0002990
2008-10-18 23:44 imbaczek Note Edited: 0002990
2008-10-19 00:02 imbaczek Status confirmed => resolved
2008-10-19 00:02 imbaczek Resolution open => fixed
2008-10-19 00:02 imbaczek Assigned To => imbaczek
2008-10-19 00:02 imbaczek Note Added: 0002991