Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21810
Modified Files:
coord.cpp multi.cpp sectors.cpp sectors.h
Log Message:
newlos
Index: multi.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/multi.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** multi.cpp 15 Aug 2004 02:17:39 -0000 1.14
--- multi.cpp 15 Sep 2004 02:15:28 -0000 1.15
***************
*** 163,167 ****
// Multi Range = BUILDRANGE
! cItemSectorIterator* iter = SectorMaps::instance()->findItems( pos, BUILDRANGE );
for ( cItem*item = iter->first(); item; item = iter->next() )
--- 163,167 ----
// Multi Range = BUILDRANGE
! cItemSectorIterator* iter = SectorMaps::instance()->findMultis( pos, BUILDRANGE );
for ( cItem*item = iter->first(); item; item = iter->next() )
Index: coord.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/coord.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** coord.cpp 15 Sep 2004 01:25:45 -0000 1.55
--- coord.cpp 15 Sep 2004 02:15:28 -0000 1.56
***************
*** 34,37 ****
--- 34,38 ----
#include "muls/multiscache.h"
#include "muls/maps.h"
+ #include "multi.h"
#include "muls/tilecache.h"
***************
*** 199,207 ****
}
! if (!found) {
return true;
}
}
for (; !statics.atEnd(); ++statics) {
const staticrecord &item = *statics;
--- 200,211 ----
}
! delete items;
!
! if (!found) {
return true;
}
}
+ // Find blocking statics
for (; !statics.atEnd(); ++statics) {
const staticrecord &item = *statics;
***************
*** 216,220 ****
if (item.zoff <= pos.z && item.zoff + height >= pos.z) {
! // Either a window or noshoot tile
if (tile.flag2 & 0x30) {
// This will not block if it's "within" our target.
--- 220,224 ----
if (item.zoff <= pos.z && item.zoff + height >= pos.z) {
! // Window and noshoot tiles block
if (tile.flag2 & 0x30) {
// This will not block if it's "within" our target.
***************
*** 226,229 ****
--- 230,308 ----
}
+ // Search for items at the given location
+ cItemSectorIterator *items = SectorMaps::instance()->findItems(pos, 0);
+
+ for (P_ITEM item = items->first(); item; item = items->next()) {
+ // If the item is invisible or a multi, skip past it.
+ if (item->visible() != 0 || item->isMulti()) {
+ continue;
+ }
+
+ tile_st tile = TileCache::instance()->getTile(item->id());
+
+ // Window and noshoot tiles block
+ if (tile.flag2 & 0x30) {
+ // Calculate the correct height
+ int height = tile.height;
+ if (tile.flag2 & 0x04) {
+ height /= 2;
+ }
+
+ // See if the item intersects our current position
+ if (pos.z >= item->pos().z && pos.z <= item->pos().z + height) {
+ // This will not block if it's "within" our target.
+ if (pos.x != target.x || pos.y != target.y || item->pos().z > target.z || item->pos().z + height < target.z) {
+ delete items;
+ return true;
+ }
+ }
+ }
+ }
+
+ delete items;
+
+ // Check for multis around the area
+ cItemSectorIterator *multis = SectorMaps::instance()->findMultis(pos, BUILDRANGE);
+
+ // Check if there is an intersecting item for this multi
+ for (P_MULTI multi = (P_MULTI)multis->first(); multi; multi = (P_MULTI)multis->next()) {
+ // Get all items for this multi
+ MultiDefinition *data = MultiCache::instance()->getMulti(multi->id() - 0x4000);
+ if (data) {
+ QValueVector<multiItem_st> items = data->getEntries();
+ QValueVector<multiItem_st>::iterator it;
+
+ for (it = items.begin(); it != items.end(); ++it) {
+ multiItem_st item = *it;
+ int itemz = item.z + multi->pos().z;
+
+ if (multi->pos().x + item.x != pos.x || multi->pos().y + item.y != pos.y) {
+ continue;
+ }
+
+ tile_st tile = TileCache::instance()->getTile(item.tile);
+
+ // Calculate the correct height
+ int height = tile.height;
+ if (tile.flag2 & 0x04) {
+ height /= 2;
+ }
+
+ // Has to be visible and blocking
+ if (item.visible && tile.flag2 & 0x30) {
+ if (pos.z >= itemz && pos.z <= itemz + height) {
+ // This will not block if it's "within" our target.
+ if (pos.x != target.x || pos.y != target.y || itemz > target.z || itemz + height < target.z) {
+ delete multis;
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ delete multis;
+
return false;
}
Index: sectors.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/sectors.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** sectors.h 7 Sep 2004 03:21:47 -0000 1.12
--- sectors.h 15 Sep 2004 02:15:28 -0000 1.13
***************
*** 132,136 ****
MT_CHARS,
MT_CHARSANDOFFLINE,
! MT_ITEMS
};
--- 132,137 ----
MT_CHARS,
MT_CHARSANDOFFLINE,
! MT_ITEMS,
! MT_MULTIS
};
***************
*** 157,160 ****
--- 158,164 ----
cItemSectorIterator* findItems( unsigned char map, uint x1, uint y1, uint x2, uint y2 );
cItemSectorIterator* findItems( const Coord_cl& center, unsigned char distance );
+
+ cItemSectorIterator* findMultis( const Coord_cl& center, unsigned char distance );
+ cItemSectorIterator* findMultis( unsigned char map, uint x1, uint y1, uint x2, uint y2 );
cCharSectorIterator* findChars( unsigned char map, uint x, uint y, bool includeoffline = false ); // Find items in a specific block
Index: sectors.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/sectors.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** sectors.cpp 7 Sep 2004 03:21:46 -0000 1.30
--- sectors.cpp 15 Sep 2004 02:15:28 -0000 1.31
***************
*** 499,502 ****
--- 499,507 ----
items[offset++] = object;
}
+ } else if (type == MT_MULTIS) {
+ P_ITEM item = dynamic_cast<P_ITEM>(object);
+ if (item && item->isMulti()) {
+ items[offset++] = object;
+ }
} else {
items[offset++] = object;
***************
*** 517,520 ****
--- 522,526 ----
{
case MT_ITEMS:
+ case MT_MULTIS:
return new cItemSectorIterator( offset, items );
***************
*** 543,546 ****
--- 549,553 ----
{
case MT_ITEMS:
+ case MT_MULTIS:
return new cItemSectorIterator( count, items );
***************
*** 560,563 ****
--- 567,575 ----
}
+ cItemSectorIterator* cSectorMaps::findMultis( const Coord_cl& center, unsigned char distance )
+ {
+ return findMultis( center.map, QMAX( ( int ) center.x - ( int ) distance, 0 ), QMAX( ( int ) center.y - ( int ) distance, 0 ), ( int ) center.x + distance, ( int ) center.y + distance );
+ }
+
cCharSectorIterator* cSectorMaps::findChars( const Coord_cl& center, unsigned char distance, bool includeoffline )
{
***************
*** 608,611 ****
--- 620,636 ----
}
+ cItemSectorIterator* cSectorMaps::findMultis( unsigned char map, uint x1, uint y1, uint x2, uint y2 )
+ {
+ std::map<unsigned char, cSectorMap*>::const_iterator it = itemmaps.find( map );
+
+ if ( it == itemmaps.end() )
+ {
+ Console::instance()->log( LOG_ERROR, QString( "Couldn't find a map with the id %1. (cSectorMaps::findMultis)" ).arg( map ) );
+ return new cItemSectorIterator( 0, 0 ); // Return an empty iterator
+ }
+
+ return static_cast<cItemSectorIterator*>( findObjects( MT_MULTIS, it->second, x1, y1, x2, y2 ) );
+ }
+
cCharSectorIterator* cSectorMaps::findChars( unsigned char map, uint x1, uint y1, uint x2, uint y2, bool includeoffline )
{
|