1
1
#ifndef PH_ITEM_LIST_H
2
2
#define PH_ITEM_LIST_H
3
+ #include " xrCore/xrDebug_macros.h" // for pragma todo. Remove once resolved.
3
4
/*
4
- #define DECLARE_PHLIST_ITEM(class_name) public:\
5
+ #define DECLARE_PHLIST_ITEM(class_name) public:\
5
6
class CPHListItem\
6
7
{\
7
8
friend class CPHItemList<class_name>;\
21
22
friend class CPHItemStack<class_name>; \
22
23
u16 stack_pos;
23
24
24
- // #define TPI(item) ((T::CPHListItem*)item)
25
+ // #define TPI(item) ((T::CPHListItem*)item)
25
26
26
27
template <class T >
27
28
class CPHItemList
@@ -33,8 +34,7 @@ class CPHItemList
33
34
u16 size;
34
35
35
36
public:
36
- class iterator ;
37
- typedef class iterator
37
+ class iterator
38
38
{
39
39
T* my_ptr;
40
40
@@ -49,24 +49,27 @@ class CPHItemList
49
49
u16 count () { return size; }
50
50
void push_back (T* item)
51
51
{
52
+ VERIFY2 (size < 65535 , " CPHItemList overflow" );
52
53
*(last_tome) = item;
53
54
item->tome = last_tome;
54
55
last_tome = &((item)->next );
55
56
item->next = 0 ;
56
57
size++;
57
58
}
58
- void move_items (CPHItemList<T>& sourse_list )
59
+ void move_items (CPHItemList<T>& source_list )
59
60
{
60
- if (!sourse_list .first_next )
61
+ if (!source_list .first_next )
61
62
return ;
62
- *(last_tome) = sourse_list.first_next ;
63
- sourse_list.first_next ->tome = last_tome;
64
- last_tome = sourse_list.last_tome ;
65
- size = size + sourse_list.size ;
66
- sourse_list.empty ();
63
+ VERIFY2 (size + source_list.size < 65535 , " CPHItemList overflow" );
64
+ *(last_tome) = source_list.first_next ;
65
+ source_list.first_next ->tome = last_tome;
66
+ last_tome = source_list.last_tome ;
67
+ size += source_list.size ;
68
+ source_list.empty ();
67
69
}
68
70
void erase (iterator i)
69
71
{
72
+ VERIFY2 (size != 0 , " CPHItemList underflow" );
70
73
T* item = *i;
71
74
T* next = item->next ;
72
75
*(item->tome ) = next;
@@ -96,10 +99,11 @@ class CPHItemStack : public CPHItemList<T>
96
99
CPHItemList<T>::push_back (item);
97
100
}
98
101
};
99
- #define DEFINE_PHITEM_LIST (T, N, I ) \
100
- typedef CPHItemList<T> N; \
102
+ #define DEFINE_PHITEM_LIST (T, N, I )\
103
+ typedef CPHItemList<T> N;\
101
104
typedef CPHItemList<T>::iterator I;
102
- #define DEFINE_PHITEM_STACK (T, N, I ) \
103
- typedef CPHItemStack<T> N; \
105
+ #define DEFINE_PHITEM_STACK (T, N, I )\
106
+ typedef CPHItemStack<T> N;\
104
107
typedef CPHItemStack<T>::iterator I;
105
- #endif
108
+
109
+ #endif // PH_ITEM_LIST_H
0 commit comments