Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List

CargoHolder.h

Go to the documentation of this file.
00001 /*
00002 Copyright 2003 - 2005 Elliott Kleinrock, Dan Neely, Kurt W. Over, Damon Domjan
00003 
00004 This file is part of FreeStars, a free clone of the Stars! game.
00005 
00006 FreeStars is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU General Public License as published by
00008 the Free Software Foundation; either version 2 of the License, or
00009 (at your option) any later version.
00010 
00011 FreeStars is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with FreeStars; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 The full GPL Copyright notice should be in the file COPYING.txt
00021 
00022 Contact:
00023 Email Elliott at 9jm0tjj02@sneakemail.com
00024 */
00025 
00030 #if !defined(CargoHolder_h)
00031 #define CargoHolder_h
00032 
00033 #include <deque>
00034 using namespace std;
00035 
00036 class Player;
00037 
00038 #include "FSTypes.h"
00039 #include "Rules.h"
00040 #include "Location.h"
00041 
00042 const long SEEN_OWNER                   = 0x00000001;   // who owns it
00043 const long SEEN_HULL                    = 0x00000002;   // hull of ship or base for planets
00044 const long SEEN_DESIGN                  = 0x00000004;   // full design of ship or base, additional special check for certain races (WM)
00045 const long SEEN_PLANETHAB               = 0x00000008;   // current and starting planetary hab, owners hab is special case for certain races (CA)
00046 const long SEEN_PLANETMC                = 0x00000010;   // mineral concentrations
00047 const long SEEN_PLANETPOP               = 0x00000020;   // display planet pop (actual shown to host and owner)
00048 const long SEEN_INSTALLATIONS   = 0x00000040;   // stuff on the ground
00049 const long SEEN_ORDERS                  = 0x00000080;   // orders
00050 const long SEEN_SCANNER                 = SEEN_OWNER | SEEN_HULL;
00051 const long SEEN_PENSCAN                 = SEEN_OWNER | SEEN_PLANETHAB | SEEN_PLANETMC | SEEN_PLANETPOP;
00052 const long SEEN_BYOWNER                 = 0x0000FFFF;   // what the Owner sees
00053 const long SEEN_HOST                    = 0xFFFFFFFF;   // what the Host sees
00054 
00058 class CargoHolder : public Location {
00059 public:
00060         CargoHolder() : Location(), mOwner(NULL), mAlsoHere(NULL) { Init(); }
00061         CargoHolder(const CargoHolder &source) : Location(source), mOwner(source.mOwner), mAlsoHere(NULL) { Init(); }
00062 //      CargoHolder(int x, int y, Player * owner) : Location(x, y), mOwner(owner) { Init(); }
00063         virtual ~CargoHolder();
00064         void Init();
00065         bool ParseNode(const TiXmlNode * node, Player * player);
00066         virtual bool ParseNode(const TiXmlNode * node);
00067         virtual TiXmlNode * WriteNode(TiXmlNode * node, const Player * viewer) const;
00068         long GetPopulation() const      { return mPopulation; }
00069         TiXmlNode * WriteTransport(TiXmlNode * node) const;
00070 
00071         virtual long GetID() const              { return mID; }
00072         void SetID(long id)             { mID = id; }
00073         void AdjustPopulation(long amount)      { this->mPopulation += amount; }
00074         void AdjustAmounts(long i, long amount);
00075         void ProcessUnload(CargoHolder * dest, long ct, TransferType tt, long value);   // value usage depends on TransferType
00076         void ProcessLoad(CargoHolder * dest, long ct, TransferType tt, long value, bool dunnage);       // value usage depends on TransferType
00077         void TransferCargo(CargoHolder * dest, long ct, long * amount, Player * player);
00078         virtual long GetCargoCapacity() const = 0;
00079         virtual long GetContain(long ct) const;
00080         long GetCargoMass() const;
00081         const Player * GetOwner() const { return mOwner; }
00082         Player * NCGetOwner() const             { return mOwner; }
00083 
00084         virtual long SeenBy(const Player * p) const;
00085         virtual long SeenBy(unsigned long p) const;
00086         virtual void SetSeenBy(long p, long seen)               { mSeenBy[p] |= seen; }
00087         virtual long GetCloak(const Player * player, bool pen) const = 0;
00088         virtual double GetMaxTachyon() const = 0;
00089         virtual long GetScanPen() const = 0;
00090         virtual long GetScanSpace() const = 0;
00091         virtual bool CanLoadBy(const Player * player) const = 0;
00092         virtual void SetCanLoadBy(const Player * player) = 0;
00093         virtual void ResetSeen();
00094         virtual bool CanStealShip() const       { return false; }
00095         virtual bool CanStealPlanet() const     { return false; }
00096 
00097         void SetAlsoHere(deque<CargoHolder *> * locs)   { mAlsoHere = locs; }
00098         deque<CargoHolder *> * GetAlsoHere()                    { return mAlsoHere; }
00099         const deque<CargoHolder *> * GetAlsoHere() const        { return mAlsoHere; }
00100 
00101 protected:
00102         static long TransferAmount(long ct, CargoHolder * from, CargoHolder * to, long Request);
00103         long mPopulation;
00104         deque<long> mContains;
00105         deque<long> mSeenBy;
00106         Player * mOwner;
00107         long mID;
00108         deque<CargoHolder *> * mAlsoHere;
00109 };
00110 
00111 #endif // !defined(CargoHolder_h)

Generated on Mon Aug 8 21:33:42 2005 for Freestars by  doxygen 1.4.2-20050421