Egg.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003-2004 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #include "pent_include.h"
00020 
00021 #include "Egg.h"
00022 #include "GUIApp.h"
00023 #include "getObject.h"
00024 #include "UCMachine.h"
00025 
00026 #include "IDataSource.h"
00027 #include "ODataSource.h"
00028 
00029 DEFINE_RUNTIME_CLASSTYPE_CODE(Egg,Item);
00030 
00031 Egg::Egg() : hatched(false)
00032 {
00033 
00034 }
00035 
00036 
00037 Egg::~Egg()
00038 {
00039 
00040 }
00041 
00042 uint16 Egg::hatch()
00043 {
00044         if (hatched) return 0;
00045         hatched = true;
00046         return callUsecodeEvent_hatch();
00047 }
00048 
00049 void Egg::dumpInfo()
00050 {
00051         Item::dumpInfo();
00052         pout << "range: " << getXRange() << "," << getYRange()
00053                  << ", hatched=" << hatched << std::endl;
00054 }
00055 
00056 void Egg::leaveFastArea()
00057 {
00058         reset();
00059         Item::leaveFastArea();
00060 }
00061 
00062 void Egg::saveData(ODataSource* ods)
00063 {
00064         Item::saveData(ods);
00065 
00066         uint8 h = hatched ? 1 :  0;
00067         ods->write1(h);
00068 }
00069 
00070 bool Egg::loadData(IDataSource* ids, uint32 version)
00071 {
00072         if (!Item::loadData(ids, version)) return false;
00073 
00074         hatched = (ids->read1() != 0);
00075 
00076         return true;
00077 }
00078 
00079 uint32 Egg::I_getEggXRange(const uint8* args, unsigned int /*argsize*/)
00080 {
00081         ARG_EGG_FROM_PTR(egg);
00082         if (!egg) return 0;
00083 
00084         return static_cast<uint32>(egg->getXRange());
00085 }
00086 
00087 uint32 Egg::I_getEggYRange(const uint8* args, unsigned int /*argsize*/)
00088 {
00089         ARG_EGG_FROM_PTR(egg);
00090         if (!egg) return 0;
00091 
00092         return static_cast<uint32>(egg->getYRange());
00093 }
00094 
00095 uint32 Egg::I_setEggXRange(const uint8* args, unsigned int /*argsize*/)
00096 {
00097         ARG_EGG_FROM_PTR(egg);
00098         ARG_UINT16(xr);
00099         if (!egg) return 0;
00100 
00101         egg->setXRange(xr);
00102         return 0;
00103 }
00104 
00105 uint32 Egg::I_setEggYRange(const uint8* args, unsigned int /*argsize*/)
00106 {
00107         ARG_EGG_FROM_PTR(egg);
00108         ARG_UINT16(yr);
00109         if (!egg) return 0;
00110 
00111         egg->setYRange(yr);
00112         return 0;
00113 }
00114 
00115 uint32 Egg::I_getEggId(const uint8* args, unsigned int /*argsize*/)
00116 {
00117         ARG_EGG_FROM_PTR(egg);
00118         if (!egg) return 0;
00119 
00120         return egg->getMapNum();
00121 }
00122 
00123 uint32 Egg::I_setEggId(const uint8* args, unsigned int /*argsize*/)
00124 {
00125         ARG_EGG_FROM_PTR(egg);
00126         ARG_UINT16(eggid);
00127         if (!egg) return 0;
00128 
00129         egg->setMapNum(eggid);
00130         
00131         return 0;
00132 }
00133 

Generated on Fri Jul 27 22:27:14 2007 for pentagram by  doxygen 1.4.7