project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/Teamlist.java
Hedgeroid:
- (hopefully) completed the frontlib JNA mappings
- added documentation
- Changed more code to use frontlib for ini reading/writing
- tried to make everything work again that was working before
- Teamlist can now be used to add and remove teams
- Netplay now correctly handles team additions when being room chief
- Fixed TeamCreatorActivity so that editing teams works
package org.hedgewars.hedgeroid.netplay;
import java.util.Collection;
import org.hedgewars.hedgeroid.Datastructures.TeamInGame;
import org.hedgewars.hedgeroid.Datastructures.TeamIngameAttributes;
import android.util.Pair;
public class Teamlist extends ObservableTreeMap<String, Pair<TeamInGame, Long>> {
private long nextId = 1;
public void addTeamWithNewId(TeamInGame team) {
put(team.team.name, Pair.create(team, nextId++));
}
public int getUnusedOrRandomColorIndex() {
Collection<Pair<TeamInGame, Long>> teams = getMap().values();
int[] illegalColors = new int[teams.size()];
int i=0;
for(Pair<TeamInGame, Long> item : teams) {
illegalColors[i] = item.first.ingameAttribs.colorIndex;
i++;
}
return TeamIngameAttributes.randomColorIndex(illegalColors);
}
}