Description:
Flags, goalposts, players, and ball will sometimes
disappear while rotating the ITAS player's view.
Cause:
public synchronized void paint(Graphics g) has
difficulty calling drawFlag(FlagInfo flag, Graphics g)
in the last else if statement.
Reasoning:
Not verified: Since this is a synchronous function,
when the last else if is reached, and the function is
called, the synchronous function has already started
again.
Other Reasoning:
It does not appear to be a problem with the function
itself as the layout of drawGoalPost() is very similar.
Known Fix:
As drawFlag() is only called from one place, take the
code from that and insert it directly into the else if
of public synchronized void paint(Graphics g):
/////////////////////////////////////////////
//OLD Code (Not working):
public synchronized void paint(Graphics g)
{
...
else if (!(obj.m_type.compareTo("g l") == 0) && !
(obj.m_type.compareTo("g r") == 0))
{
drawFlag((FlagInfo)(obj), g);
}
}
...
private void drawFlag(FlagInfo flag, Graphics g)
{
int x, y;
Point coordinate = calculatePoint(flag.m_distance,
flag.m_direction, flag_width);
if (flag.m_out) {
g.setColor(flagcolor);
} else {
g.setColor(flagcolor.brighter());
}
g.fillRect(coordinate.x, coordinate.y, flag_width,
flag_width);
}
/////////////////////////////////////////////
//New Code:
/////////////////////////////////////////////
public synchronized void paint(Graphics g)
{
...
else if (!(obj.m_type.compareTo("g l") == 0) && !
(obj.m_type.compareTo("g r") == 0))
{
int x, y;
Point coordinate =
calculatePoint(obj.m_distance, obj.m_direction,
flag_width);
//System.out.println("FLAG
distance: " + F.m_distance + " direction: " +
flag.m_direction + " width: " + flag_width);
g.setColor(flagcolor);
g.fillRect(coordinate.x,
coordinate.y, flag_width, flag_width);
}
}
A fixed version of PlayerCanvas.java is attached in
ZIP format. It includes both ITASAdvanced Standalone
and ITAS Applet fixes.
PlayerCanvas Fix