~ubuntu-branches/ubuntu/natty/spring/natty

« back to all changes in this revision

Viewing changes to rts/Game/SelectedUnits.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Ritchie
  • Date: 2010-09-23 18:56:03 UTC
  • mfrom: (3.1.9 experimental)
  • Revision ID: james.westby@ubuntu.com-20100923185603-st97s5chplo42y7w
Tags: 0.82.5.1+dfsg1-1ubuntu1
* Latest upstream version for online play
* debian/control: Replace (rather than conflict) spring-engine
  - spring-engine will be a dummy package (LP: #612905)
  - also set maintainer to MOTU

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// SelectedUnits.cpp: implementation of the CSelectedUnits class.
2
 
//
3
 
//////////////////////////////////////////////////////////////////////
 
1
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
4
2
 
5
3
#include "StdAfx.h"
6
4
#include <map>
22
20
#include "UI/GuiHandler.h"
23
21
#include "UI/TooltipConsole.h"
24
22
#include "LogOutput.h"
25
 
#include "Rendering/UnitModels/3DOParser.h"
26
23
#include "Rendering/GL/VertexArray.h"
27
24
#include "SelectedUnitsAI.h"
28
25
#include "Sim/Features/Feature.h"
37
34
#include "ConfigHandler.h"
38
35
#include "PlayerHandler.h"
39
36
#include "Camera.h"
40
 
#include "Sound/AudioChannel.h"
 
37
#include "Sound/IEffectChannel.h"
41
38
#include "Util.h"
42
39
 
43
40
extern boost::uint8_t *keys;
634
631
 
635
632
        glLineWidth(cmdColors.QueuedLineWidth());
636
633
 
 
634
        GML_RECMUTEX_LOCK(unit); // DrawCommands
637
635
        GML_RECMUTEX_LOCK(grpsel); // DrawCommands
638
636
        GML_STDMUTEX_LOCK(cai); // DrawCommands
639
637
 
699
697
        float exp = 0.0f, cost = 0.0f, range = 0.0f;
700
698
        float metalMake = 0.0f, metalUse = 0.0f, energyMake = 0.0f, energyUse = 0.0f;
701
699
 
 
700
#define NO_TEAM -32
 
701
#define MULTI_TEAM -64
 
702
        int ctrlTeam = NO_TEAM;
 
703
 
702
704
        CUnitSet::iterator ui;
703
705
        for (ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) {
704
706
                const CUnit* unit = *ui;
716
718
                if (unit->unitDef->maxFuel > 0) {
717
719
                        numFuel++;
718
720
                }
 
721
                if(ctrlTeam == NO_TEAM)
 
722
                        ctrlTeam = unit->team;
 
723
                else if(ctrlTeam != unit->team)
 
724
                        ctrlTeam = MULTI_TEAM;
719
725
        }
720
726
        if ((numFuel > 0) && (maxFuel > 0.0f)) {
721
727
                curFuel = curFuel / numFuel;
730
736
               metalMake,  metalUse,
731
737
               energyMake, energyUse);
732
738
 
733
 
  if (gs->cheatEnabled && (selectedUnits.size() == 1)) {
 
739
  if (gs->cheatEnabled && (num == 1)) {
734
740
        CUnit* unit = *selectedUnits.begin();
735
741
    SNPRINTF(tmp, sizeof(tmp), "\xff\xc0\xc0\xff  [TechLevel %i]",
736
742
             unit->unitDef->techLevel);
737
743
    s += tmp;
738
744
        }
739
745
 
 
746
        std::string ctrlName = "";
 
747
        if(ctrlTeam == MULTI_TEAM)
 
748
                ctrlName = "(Multiple teams)";
 
749
        else if(ctrlTeam != NO_TEAM)
 
750
                ctrlName = teamHandler->Team(ctrlTeam)->GetControllerName();
 
751
        s += "\n\xff\xff\xff\xff" + ctrlName;
 
752
 
740
753
        return s;
741
754
}
742
755