~ubuntu-branches/ubuntu/maverick/asc/maverick

« back to all changes in this revision

Viewing changes to source/actions/unitaction.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Moritz Muehlenhoff, Moritz Muehlenhoff, Barry deFreese, Alexander Reichle-Schmehl
  • Date: 2010-01-01 22:11:14 UTC
  • mfrom: (1.1.6 upstream) (2.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100101221114-qfg9ogppdfcte4m7
Tags: 2.4.0.0-1
[ Moritz Muehlenhoff ]
* New upstream release. (2.4.0)
  - Drop obsolete patches
  - Initializes map_edit properly. (Closes: #534171).
* Update to standards version 3.8.3
* Switch to source format 3.0 (quilt) (Closes: #538430)
* Adding myself to uploaders

[ Barry deFreese ]
* New upstream release. (2.2.0)

[ Alexander Reichle-Schmehl ]
* Adopt debian/control to my new name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
     This file is part of Advanced Strategic Command; http://www.asc-hq.de
 
3
     Copyright (C) 1994-2008  Martin Bickel  and  Marc Schellenberger
 
4
 
 
5
     This program is free software; you can redistribute it and/or modify
 
6
     it under the terms of the GNU General Public License as published by
 
7
     the Free Software Foundation; either version 2 of the License, or
 
8
     (at your option) any later version.
 
9
 
 
10
     This program is distributed in the hope that it will be useful,
 
11
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
     GNU General Public License for more details.
 
14
 
 
15
     You should have received a copy of the GNU General Public License
 
16
     along with this program; see the file COPYING. If not, write to the 
 
17
     Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
 
18
     Boston, MA  02111-1307  USA
 
19
*/
 
20
 
 
21
 
 
22
#include "unitaction.h"
 
23
 
 
24
#include "../vehicle.h"
 
25
#include "../gamemap.h"
 
26
 
 
27
UnitAction::UnitAction( Vehicle* unit )
 
28
   : GameAction( unit->getMap() )
 
29
{
 
30
   vehicleID = unit->networkid;
 
31
}     
 
32
 
 
33
 
 
34
UnitAction::UnitAction( GameMap* gamemap )
 
35
   : GameAction( gamemap )
 
36
{
 
37
   vehicleID = -1;
 
38
}     
 
39
     
 
40
UnitAction::UnitAction( GameMap* gamemap, int vehicleID )
 
41
   : GameAction( gamemap )
 
42
{
 
43
   this->vehicleID = vehicleID;
 
44
}
 
45
      
 
46
      
 
47
Vehicle* UnitAction::getUnit( bool dontThrow )
 
48
{
 
49
   Vehicle* veh = getMap()->getUnit( vehicleID );
 
50
   if ( !veh && !dontThrow )
 
51
      throw ActionResult(21001, "ID is " + ASCString::toString(vehicleID) );
 
52
   else
 
53
      return veh;
 
54
}
 
55
      
 
56
const Vehicle* UnitAction::getUnit( bool dontThrow ) const 
 
57
{
 
58
   const Vehicle* veh = getMap()->getUnit( vehicleID );
 
59
   if ( !veh && !dontThrow )
 
60
      throw ActionResult(21001, "ID is " + ASCString::toString(vehicleID) );
 
61
   else
 
62
      return veh;
 
63
}
 
64
 
 
65
void UnitAction::readData ( tnstream& stream ) 
 
66
{
 
67
   int version = stream.readInt();
 
68
   if ( version != 1 )
 
69
      throw tinvalidversion ( "UnitAction", 1, version );
 
70
   
 
71
   vehicleID = stream.readInt();
 
72
};
 
73
      
 
74
      
 
75
void UnitAction::writeData ( tnstream& stream )  const
 
76
{
 
77
   stream.writeInt( 1 );
 
78
   stream.writeInt( vehicleID );
 
79
};
 
80
 
 
81