CreateItemProcess.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2005 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 #include "CreateItemProcess.h"
00021 #include "ItemFactory.h"
00022 #include "Item.h"
00023 
00024 #include "IDataSource.h"
00025 #include "ODataSource.h"
00026 
00027 // p_dynamic_class stuff 
00028 DEFINE_RUNTIME_CLASSTYPE_CODE(CreateItemProcess,Process);
00029 
00030 CreateItemProcess::CreateItemProcess()
00031         : Process()
00032 {
00033 
00034 }
00035 
00036 CreateItemProcess::CreateItemProcess(uint32 shape_, uint32 frame_,
00037                                                                          uint16 quality_, uint16 flags_,
00038                                                                          uint16 npcnum_, uint16 mapnum_,
00039                                                                          uint32 extendedflags_,
00040                                                                          sint32 x_, sint32 y_, sint32 z_)
00041         : shape(shape_), frame(frame_), quality(quality_), flags(flags_),
00042           npcnum(npcnum_), mapnum(mapnum_), extendedflags(extendedflags_),
00043           x(x_), y(y_), z(z_)
00044 {
00045 
00046 }
00047 
00048 CreateItemProcess::~CreateItemProcess(void)
00049 {
00050 
00051 }
00052 
00053 bool CreateItemProcess::run(const uint32)
00054 {
00055         Item *item = ItemFactory::createItem(shape, frame, quality, flags,
00056                                                                                  npcnum, mapnum, extendedflags, true);
00057         item->move(x,y,z);
00058 
00059         result = item->getObjId();
00060 
00061         terminate();
00062 
00063         return true;
00064 }
00065 
00066 void CreateItemProcess::saveData(ODataSource* ods)
00067 {
00068         Process::saveData(ods);
00069 
00070         ods->write4(shape);
00071         ods->write4(frame);
00072         ods->write2(quality);
00073         ods->write2(flags);
00074         ods->write2(npcnum);
00075         ods->write2(mapnum);
00076         ods->write4(extendedflags);
00077         ods->write4(static_cast<uint32>(x));
00078         ods->write4(static_cast<uint32>(y));
00079         ods->write4(static_cast<uint32>(z));
00080 }
00081 
00082 bool CreateItemProcess::loadData(IDataSource* ids, uint32 version)
00083 {
00084         if (!Process::loadData(ids, version)) return false;
00085 
00086         shape = ids->read4();
00087         frame = ids->read4();
00088         quality = ids->read2();
00089         flags = ids->read2();
00090         npcnum = ids->read2();
00091         mapnum = ids->read2();
00092         extendedflags = ids->read4();
00093         x = static_cast<sint32>(ids->read4());
00094         y = static_cast<sint32>(ids->read4());
00095         z = static_cast<sint32>(ids->read4());
00096         return true;
00097 }

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