Update of /cvsroot/wpdev/wolfpack/muls
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10137/muls
Modified Files:
maps.h multiscache.cpp multiscache.h
Log Message:
housing updates
Index: maps.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/muls/maps.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** maps.h 1 Oct 2004 19:43:56 -0000 1.5
--- maps.h 21 Oct 2004 12:11:19 -0000 1.6
***************
*** 61,65 ****
#pragma pack()
! class StaticsIterator
{
public:
--- 61,65 ----
#pragma pack()
! class WPEXPORT StaticsIterator
{
public:
***************
*** 101,105 ****
};
! class cMaps : public cComponent
{
QMap<uint, MapsPrivate*> d;
--- 101,105 ----
};
! class WPEXPORT cMaps : public cComponent
{
QMap<uint, MapsPrivate*> d;
Index: multiscache.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/muls/multiscache.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** multiscache.cpp 10 Aug 2004 03:20:29 -0000 1.6
--- multiscache.cpp 21 Oct 2004 12:11:19 -0000 1.7
***************
*** 39,43 ****
#include <algorithm>
! MultiDefinition::MultiDefinition() : width( 0 ), height( 0 )
{
}
--- 39,43 ----
#include <algorithm>
! MultiDefinition::MultiDefinition() : width( 0 ), height( 0 ), left(0), top(0), right(0), bottom(0)
{
}
***************
*** 49,71 ****
return;
unsigned int i = 0;
- int max_X = 0, max_Y = 0, min_X = 0, min_Y = 0;
for ( ; i < items.size(); ++i )
{
! if ( items[max_X].x < items[i].x )
! max_X = i;
! if ( items[max_Y].y < items[i].y )
! max_Y = i;
! if ( items[min_X].x > items[i].x )
! min_X = i;
! if ( items[min_Y].y > items[i].y )
! min_Y = i;
}
// by now we have the dimensions.
! this->width = items[max_X].x + abs( items[min_X].x );
! this->height = items[max_Y].y + abs( items[min_Y].y );
entries = items;
}
/*!
Checks if the given pair of \a x and \a y coordinates
--- 49,92 ----
return;
unsigned int i = 0;
for ( ; i < items.size(); ++i )
{
! if ( items[i].x < left )
! left = items[i].x;
! else if ( items[i].x > right )
! right = items[i].x;
!
! if ( items[i].y < top )
! top = items[i].y;
! else if ( items[i].y > bottom )
! bottom = items[i].y;
}
// by now we have the dimensions.
! this->width = abs(right - left) + 1;
! this->height = abs(bottom - top) + 1;
!
! // copy into grid
! grid.resize(width * height);
! for ( i = 0; i < items.size(); ++i) {
! unsigned int index = (items[i].y - top) * width + (items[i].x - left);
! if (index >= 0 && index < grid.size()) {
! grid[index].append(items[i]);
! }
! }
!
entries = items;
}
+ const QValueVector<multiItem_st> &MultiDefinition::itemsAt(int x, int y) {
+ unsigned int index = (x - left) + (y - top) * width;
+ static QValueVector<multiItem_st> emptyGrid;
+
+ if (index < 0 || index >= grid.size()) {
+ return emptyGrid;
+ } else {
+ return grid[index];
+ }
+ }
+
/*!
Checks if the given pair of \a x and \a y coordinates
***************
*** 233,234 ****
--- 254,257 ----
return 0;
}
+
+
Index: multiscache.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/muls/multiscache.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** multiscache.h 19 Jun 2004 02:06:51 -0000 1.3
--- multiscache.h 21 Oct 2004 12:11:19 -0000 1.4
***************
*** 47,55 ****
protected:
QValueVector<multiItem_st> entries; // sorted list of items
! uint width;
! uint height;
public:
MultiDefinition();
void setItems( const QValueVector<multiItem_st>& items );
bool inMulti( short x, short y );
--- 47,83 ----
protected:
QValueVector<multiItem_st> entries; // sorted list of items
! int left, right, top, bottom;
! unsigned int height, width;
!
! QValueVector< QValueVector<multiItem_st> > grid;
public:
MultiDefinition();
+ const QValueVector<multiItem_st> &itemsAt(int x, int y);
+
+ unsigned int getHeight() {
+ return height;
+ }
+
+ unsigned int getWidth() {
+ return width;
+ }
+
+ int getLeft() {
+ return left;
+ }
+
+ int getRight() {
+ return right;
+ }
+
+ int getBottom() {
+ return bottom;
+ }
+
+ int getTop() {
+ return top;
+ }
+
void setItems( const QValueVector<multiItem_st>& items );
bool inMulti( short x, short y );
|