00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
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 }