Pol  Revision:4b29d2b
multicr.cpp
Go to the documentation of this file.
1 
8 #include <stddef.h>
9 
10 #include "../../bscript/berror.h"
11 #include "../../clib/clib_endian.h"
12 #include "../../clib/logfacility.h"
13 #include "../../clib/rawtypes.h"
14 #include "../globals/object_storage.h"
15 #include "../item/itemdesc.h"
16 #include "../ufunc.h"
17 #include "boat.h"
18 #include "house.h"
19 #include "multi.h"
20 
21 
22 namespace Pol
23 {
24 namespace Multi
25 {
26 bool isboat( u32 objtype )
27 {
29 }
30 
31 bool ishouse( u32 objtype )
32 {
34 }
35 
36 // scripted_create duplicates some of this work
37 // Dave changed 3/8/3 to use objecthash
38 UMulti* UMulti::create( const Items::ItemDesc& descriptor, u32 serial )
39 {
40  UMulti* multi = nullptr;
41 
42  if ( descriptor.type == Items::ItemDesc::BOATDESC )
43  {
44  multi = new UBoat( descriptor );
45  }
46  else if ( descriptor.type == Items::ItemDesc::HOUSEDESC )
47  {
48  multi = new UHouse( descriptor );
49  }
50  else
51  {
52  ERROR_PRINT << "Tried to create multi 0x" << fmt::hexu( descriptor.objtype )
53  << " but no definition exists in itemdesc.cfg\n";
54  return nullptr;
55  }
56 
57  if ( serial )
58  multi->serial = Core::UseItemSerialNumber( serial );
59  else
61 
62  multi->serial_ext = ctBEu32( multi->serial );
63 
67 
68  return multi;
69 }
70 
71 
73  Realms::Realm* realm, int flags )
74 {
75  if ( descriptor.type == Items::ItemDesc::BOATDESC )
76  return UBoat::scripted_create( descriptor, x, y, z, realm, flags );
77  else if ( descriptor.type == Items::ItemDesc::HOUSEDESC )
78  return UHouse::scripted_create( descriptor, x, y, z, realm, flags );
79  else
80  return new Bscript::BError( "Don't know what kind of multi to make" );
81 }
82 }
83 }
const ItemDesc & find_itemdesc(unsigned int objtype)
Definition: itemdesc.cpp:933
static Bscript::BObjectImp * scripted_create(const Items::ItemDesc &descriptor, u16 x, u16 y, s8 z, Realms::Realm *realm, int flags)
Definition: house.cpp:796
unsigned short u16
Definition: rawtypes.h:26
unsigned int u32
Definition: rawtypes.h:27
bool ishouse(u32 objtype)
Definition: multicr.cpp:31
u32 GetNewItemSerialNumber(void)
Definition: ufunc.cpp:142
bool isboat(u32 objtype)
Definition: multicr.cpp:26
static Bscript::BObjectImp * scripted_create(const Items::ItemDesc &descriptor, u16 x, u16 y, s8 z, Realms::Realm *realm, int flags)
Definition: multicr.cpp:72
u32 UseItemSerialNumber(u32 serial)
Definition: ufunc.cpp:134
signed char s8
Definition: rawtypes.h:29
static UMulti * create(const Items::ItemDesc &descriptor, u32 serial=0)
Definition: multicr.cpp:38
#define ctBEu32(x)
Definition: clib_endian.h:45
bool Insert(UObject *obj)
Definition: objecthash.cpp:30
Realms::Realm * realm
Definition: baseobject.h:56
ObjectStorageManager objStorageManager
static Bscript::BObjectImp * scripted_create(const Items::ItemDesc &descriptor, u16 x, u16 y, s8 z, Realms::Realm *realm, int flags)
Definition: boat.cpp:1639
#define ERROR_PRINT
Definition: logfacility.h:230
Definition: berror.cpp:12