-
Notifications
You must be signed in to change notification settings - Fork 1
/
regions.h
118 lines (89 loc) · 2.71 KB
/
regions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// -- Region class Added by Tauriel 3/6/1999 To lookup items by region
// This should help for now. BTW- my first attempt at C++
// So forgive any newbie mistakes :)
// -- Side note, I wanted regions to be more generic, but
// now that I have to do this, time doesn't allow for it yet.
#ifndef __Region_h
#define __Region_h
#include "mapstuff.h"
namespace UOX
{
const SI16 MapColSize = 32;
const SI16 MapRowSize = 128;
const SI16 UpperX = static_cast<SI16>(7168 / MapColSize);
const SI16 UpperY = static_cast<SI16>(4096 / MapRowSize);
struct MapResource_st
{
SI16 oreAmt;
UI32 oreTime;
SI16 logAmt;
UI32 logTime;
MapResource_st() : oreAmt( 0 ), oreTime( 0 ), logAmt( 0 ), logTime( 0 )
{
}
};
class CMapRegion
{
private:
CDataList< CItem * > itemData;
CDataList< CChar * > charData;
public:
CDataList< CItem * > * GetItemList( void );
CDataList< CChar * > * GetCharList( void );
CMapRegion()
{
};
~CMapRegion()
{
};
void SaveToDisk( std::ofstream& writeDestination, std::ofstream &houseDestination );
};
class CMapWorld
{
private:
SI16 upperArrayX;
SI16 upperArrayY;
UI16 resourceX;
UI16 resourceY;
std::vector< CMapRegion > mapRegions;
std::vector< MapResource_st > mapResources;
public:
CMapWorld( void );
CMapWorld( UI08 worldNum );
~CMapWorld( void );
CMapRegion * GetMapRegion( SI16 xOffset, SI16 yOffset );
MapResource_st& GetResource( SI16 x, SI16 y );
void LoadResources( UI08 worldNum );
void SaveResources( UI08 worldNUm );
};
class CMapHandler
{
private:
typedef std::vector< CMapWorld * > WORLDLIST;
typedef std::vector< CMapWorld * >::iterator WORLDLIST_ITERATOR;
WORLDLIST mapWorlds;
CMapRegion overFlow;
void LoadFromDisk( std::ifstream& readDestination, int baseValue, int fileSize, int maxSize );
public:
CMapHandler();
~CMapHandler();
void Save( void );
void Load( void );
bool AddItem( CItem *nItem );
bool RemoveItem( CItem *nItem );
bool AddChar( CChar *toAdd );
bool RemoveChar( CChar *toRemove );
bool ChangeRegion( CItem *nItem, SI16 x, SI16 y, UI08 worldNum );
bool ChangeRegion( CChar *nChar, SI16 x, SI16 y, UI08 worldNum );
CMapRegion *GetMapRegion( CBaseObject *mObj );
CMapRegion *GetMapRegion( SI16 xOffset, SI16 yOffset, UI08 worldNumber );
SI16 GetGridX( SI16 x );
SI16 GetGridY( SI16 y );
REGIONLIST PopulateList( SI16 x, SI16 y, UI08 worldNumber );
REGIONLIST PopulateList( CBaseObject *mObj );
CMapWorld * GetMapWorld( UI08 worldNum );
MapResource_st * GetResource( SI16 x, SI16 y, UI08 worldNum );
};
extern CMapHandler *MapRegion;
}
#endif