Add spAddTeamResourceStats, for post-game graphs#2608
Conversation
| * | ||
| * @function Spring.AddTeamResourceStats | ||
| * @param teamID integer | ||
| * @param amounts table |
There was a problem hiding this comment.
This should explain the format, do I need to introduce a type for this?
| continue; | ||
|
|
||
| using TS = TeamStatistics; | ||
| std::array <float TS::*, SResourcePack::MAX_RESOURCES> entries; |
There was a problem hiding this comment.
This is annoying, but TeamStatistics is part of the replay/network protocol so I can't turn its members into SResourcePacks.
| } | ||
|
|
||
| for (int i = 0; i < entries.size(); ++i) { | ||
| // Parse by resource index, like `produced = { 1.23, 45.6 }` |
There was a problem hiding this comment.
The inside of this loop should probably end up as some sort of helper utility function eventually.
Edit: #2631
|
I'll build locally. I already had my custom AdjustTeamResourceStats() there so just adapting to this function's expected args should be trivial. |
|
Looking at how stats work vs Spring.GetTeamResources() If i understand it smoothly, they accumulate during TEAM_SLOWUPDATE_RATE Excess doesn't need this in native engine because nothing is excessed between slowupdates If instead of adding to the teamstatistics value, we added/removed from those accumulators I dunno if that would be wanted. => Should that be understood on engine side as:
|
|
Yup, definetly something i'd look into. local function AddResourceAsUnitProduction(unitID, teamID, resType, amount) or ie something like local function AddResourceAsTeamReceived(teamID, resType, amount) 4 functions: I think with that you could get rid of all other resource transfer related function (eventually reimplement them on game side if needed) function Spring.ShareTeamResources(team1, team2, resType, amount) is just a combination of a raw resource manipulation + stats logging and so on |
|
After setting an accumulator for resExcess, similar to other accumulators already used: AdjustUnitResourceStats AdjustTeamResourceStats -> We write into the accumulators Games will be responsible for keeping consistency. |
|
Probably superseded by #3032. |
Draft because untested