2
This file is part of Advanced Strategic Command; http://www.asc-hq.de
3
Copyright (C) 1994-2008 Martin Bickel and Marc Schellenberger
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.
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.
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
22
#include "unitaction.h"
24
#include "../vehicle.h"
25
#include "../gamemap.h"
27
UnitAction::UnitAction( Vehicle* unit )
28
: GameAction( unit->getMap() )
30
vehicleID = unit->networkid;
34
UnitAction::UnitAction( GameMap* gamemap )
35
: GameAction( gamemap )
40
UnitAction::UnitAction( GameMap* gamemap, int vehicleID )
41
: GameAction( gamemap )
43
this->vehicleID = vehicleID;
47
Vehicle* UnitAction::getUnit( bool dontThrow )
49
Vehicle* veh = getMap()->getUnit( vehicleID );
50
if ( !veh && !dontThrow )
51
throw ActionResult(21001, "ID is " + ASCString::toString(vehicleID) );
56
const Vehicle* UnitAction::getUnit( bool dontThrow ) const
58
const Vehicle* veh = getMap()->getUnit( vehicleID );
59
if ( !veh && !dontThrow )
60
throw ActionResult(21001, "ID is " + ASCString::toString(vehicleID) );
65
void UnitAction::readData ( tnstream& stream )
67
int version = stream.readInt();
69
throw tinvalidversion ( "UnitAction", 1, version );
71
vehicleID = stream.readInt();
75
void UnitAction::writeData ( tnstream& stream ) const
78
stream.writeInt( vehicleID );