void CMiniMap::DrawUnit(CUnit* unit) { // the simplest test if (!unit) return; // the next simplest test if (unit->noMinimap) { return; } // blink for damages within the past 3 game seconds if ((unit->lastDamage > (gs->frameNum - 3 * GAME_SPEED)) && (gs->frameNum & 8)) { return; } // includes the visibility check float iconScale; const CIconData* iconData = GetUnitIcon(unit, iconScale); if (iconData == NULL) { return; } // get the position float3 pos; if (gu->spectatingFullView) { pos = unit->midPos; } else { pos = helper->GetUnitErrorPos(unit, gu->myAllyTeam); } // set the color if (unit->commandAI->selected) { glColor3f(1.0f, 1.0f, 1.0f); } else { if (simpleColors) { if (unit->team == gu->myTeam) { glColor3ubv(myColor); } else if (teamHandler->Ally(gu->myAllyTeam, unit->allyteam)) { glColor3ubv(allyColor); } else { glColor3ubv(enemyColor); } } else { glColor3ubv(teamHandler->Team(unit->team)->color); } } iconScale *= iconData->GetSize(); const float sizeX = (iconScale * unitSizeX); const float sizeY = (iconScale * unitSizeY); const float x0 = pos.x - sizeX; const float x1 = pos.x + sizeX; const float y0 = pos.z - sizeY; const float y1 = pos.z + sizeY; iconData->Draw(x0, y0, x1, y1); }
void CMiniMap::DrawUnit(const CUnit* unit) { // the simplest test if (!unit) return; // the next simplest test if (unit->noMinimap) { return; } // includes the visibility check float iconScale; const icon::CIconData* iconData = GetUnitIcon(unit, iconScale); if (iconData == NULL) { return; } // get the position float3 pos; if (gu->spectatingFullView) { pos = unit->midPos; } else { pos = CGameHelper::GetUnitErrorPos(unit, gu->myAllyTeam); } // set the color if (unit->isSelected) { glColor3f(1.0f, 1.0f, 1.0f); } else { if (simpleColors) { if (unit->team == gu->myTeam) { glColor3ubv(myColor); } else if (teamHandler->Ally(gu->myAllyTeam, unit->allyteam)) { glColor3ubv(allyColor); } else { glColor3ubv(enemyColor); } } else { glColor3ubv(teamHandler->Team(unit->team)->color); } } iconScale *= iconData->GetSize(); const float sizeX = (iconScale * unitSizeX); const float sizeY = (iconScale * unitSizeY); const float x0 = pos.x - sizeX; const float x1 = pos.x + sizeX; const float y0 = pos.z - sizeY; const float y1 = pos.z + sizeY; iconData->Draw(x0, y0, x1, y1); }