CPlayerColorGraphic shows wrong color when other players' units are selected

Bug #1293004 reported by Andre Novellino Gouvêa
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stratagus
Fix Released
Undecided
cybermind

Bug Description

CPlayerColorGraphic is showing the current player's color instead of the unit's owner color, so that when enemy units are selected, their icon shows up in the current player's color instead of that of their owner.

Related branches

Revision history for this message
Travis (dinky-dye-aussie) wrote :

What version of Stratagus are you using? Also, what platform are you playing it on? WIndows?

Revision history for this message
Andre Novellino Gouvêa (andre-ng) wrote :

Yes, I'm playing on windows (with the binaries you provided on the forum, so commit 8874).

Revision history for this message
Travis (dinky-dye-aussie) wrote :

OK :) Well, I just tried to test your problem out, and when I selected my peasents (red) and then any other player, it never changed color on the other players peasents or even buildings.

could be a scripts issue maybe.

Revision history for this message
Andre Novellino Gouvêa (andre-ng) wrote :

I don't think it is a script issue. Looking at the source code, we can see that the DrawIcon() function (icons.cpp) sets the correct player for the player color:

void CIcon::DrawIcon(const CPlayer &player, const PixelPos &pos) const
{
 CPlayerColorGraphic *g = dynamic_cast<CPlayerColorGraphic *>(this->G);
 if (g) {
  g->DrawPlayerColorFrameClip(player.Index, this->Frame, pos.x, pos.y);
 } else {
  this->G->DrawFrameClip(this->Frame, pos.x, pos.y);
 }
}

However, this is not the function used to create the unit's main icon. That function is DrawUIButton() (uibuttons_proc.cpp). The function is too long to quote here, but here is the relevant part:

 if (pimage->Sprite) {
  CPlayerColorGraphic *colorGraphic = dynamic_cast<CPlayerColorGraphic *>(pimage->Sprite);

  if (colorGraphic && ThisPlayer) {
   colorGraphic->DrawPlayerColorFrameClip(ThisPlayer->Index, pimage->Frame, x, y);
  } else {
   pimage->Sprite->DrawFrame(pimage->Frame, x, y);
  }
 }

As we can see, the function uses "ThisPlayer" instead of the unit's owner to create the icon, which results in the person player's player color being used.

Revision history for this message
cybermind (iddqd-mail) wrote :

Fixed in rev.8883

Changed in stratagus:
status: New → Fix Committed
assignee: nobody → cybermind (iddqd-mail)
cybermind (iddqd-mail)
Changed in stratagus:
status: Fix Committed → Fix Released
milestone: none → 2.3
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.