[wpdev-commits] wolfpack walking.cpp,1.149,1.150
Brought to you by:
rip,
thiagocorrea
From: spddmn <xxx...@us...> - 2004-09-19 23:01:39
|
Update of /cvsroot/wpdev/wolfpack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30513 Modified Files: walking.cpp Log Message: multi checking Index: walking.cpp =================================================================== RCS file: /cvsroot/wpdev/wolfpack/walking.cpp,v retrieving revision 1.149 retrieving revision 1.150 diff -C2 -d -r1.149 -r1.150 *** walking.cpp 19 Sep 2004 18:41:40 -0000 1.149 --- walking.cpp 19 Sep 2004 23:01:29 -0000 1.150 *************** *** 154,158 **** // TODO: Calculate the REAL average Z Value of that Map Tile here! Otherwise clients will have minor walking problems. map_st mapCell = Maps::instance()->seekMap( pos ); ! //mapBlock.z = mapCell.z;*/ land_st mapTile = TileCache::instance()->getLand( mapCell.id ); --- 154,158 ---- // TODO: Calculate the REAL average Z Value of that Map Tile here! Otherwise clients will have minor walking problems. map_st mapCell = Maps::instance()->seekMap( pos ); ! //mapBlock.z = mapCell.z; land_st mapTile = TileCache::instance()->getLand( mapCell.id ); *************** *** 201,243 **** } ! RegionIterator4Items iIter( pos, 0 ); for ( iIter.Begin(); !iIter.atEnd(); iIter++ ) { ! P_ITEM pItem = iIter.GetData(); if ( !pItem ) continue; ! ! if ( pItem->id() >= 0x4000 ) ! { ! MultiDefinition* def = MultiCache::instance()->getMulti( pItem->id() - 0x4000 ); ! if ( !def ) ! continue; ! QValueVector<multiItem_st> multi = def->getEntries(); ! unsigned int j; ! for ( j = 0; j < multi.size(); ++j ) ! { ! if ( multi[j].visible && ( pItem->pos().x + multi[j].x == pos.x ) && ( pItem->pos().y + multi[j].y == pos.y ) ) ! { ! tile_st tTile = TileCache::instance()->getTile( multi[j].tile ); ! if ( !( ( tTile.flag2 & 0x02 ) || ( tTile.flag1 & 0x40 ) || ( tTile.flag2 & 0x04 ) ) ) ! continue; ! ! stBlockItem blockItem; ! blockItem.height = tTile.height; ! blockItem.z = pItem->pos().z + multi[j].z; ! ! if ( ( tTile.flag2 & 0x02 ) && !( tTile.flag1 & 0x40 ) ) ! blockItem.walkable = true; ! else ! blockItem.walkable = checkWalkable( pChar, pItem->id() ); ! ! blockList.push_back( blockItem ); ! push_heap( blockList.begin(), blockList.end(), compareTiles() ); ! } ! } ! continue; ! } ! else if ( pChar && pChar->isDead() ) { // Doors can be passed by ghosts --- 201,220 ---- } ! ! // We are only interested in items at pos ! // todo: we could impliment blocking for items on the adjacent sides ! // during a diagonal move here, but this has yet to be decided. ! ! RegionIterator4Items iIter( pos, 0 ); ! ! P_ITEM pItem; for ( iIter.Begin(); !iIter.atEnd(); iIter++ ) { ! pItem = iIter.GetData(); if ( !pItem ) continue; ! ! if ( pChar && pChar->isDead() ) { // Doors can be passed by ghosts *************** *** 248,258 **** } - // They need to be at the same x,y,plane coords - if ( ( pItem->pos().x != pos.x ) || ( pItem->pos().y != pos.y ) || ( pItem->pos().map != pos.map ) ) - continue; tile_st tTile = TileCache::instance()->getTile( pItem->id() ); ! // Se above for what the flags mean if ( !( ( tTile.flag2 & 0x02 ) || ( tTile.flag1 & 0x40 ) || ( tTile.flag2 & 0x04 ) ) ) continue; --- 225,232 ---- } tile_st tTile = TileCache::instance()->getTile( pItem->id() ); ! // See above for what the flags mean if ( !( ( tTile.flag2 & 0x02 ) || ( tTile.flag1 & 0x40 ) || ( tTile.flag2 & 0x04 ) ) ) continue; *************** *** 271,283 **** push_heap( blockList.begin(), blockList.end(), compareTiles() ); } - // Now we need to evaluate dynamic items [...] (later) - // TODO: Multis here sort_heap( blockList.begin(), blockList.end(), compareTiles() ); return blockList; }; ! // May a character walk here ? // If yes we auto. set the new z value for pos bool mayWalk( P_CHAR pChar, Coord_cl& pos ) --- 245,295 ---- push_heap( blockList.begin(), blockList.end(), compareTiles() ); } + + + // deal with the multis now, or not. + cItemSectorIterator* iter = SectorMaps::instance()->findMultis( pos, 18 ); // 18 has been tested with castle sides and corners... + for ( pItem = iter->first(); pItem; pItem = iter->next() ) + { + MultiDefinition* def = MultiCache::instance()->getMulti( pItem->id() - 0x4000 ); + if ( !def ) + continue; + QValueVector<multiItem_st> multi = def->getEntries(); + unsigned int j; + for ( j = 0; j < multi.size(); ++j ) + { + if ( multi[j].visible && ( pItem->pos().x + multi[j].x == pos.x ) && ( pItem->pos().y + multi[j].y == pos.y ) ) + { + tile_st tTile = TileCache::instance()->getTile( multi[j].tile ); + if ( !( ( tTile.flag2 & 0x02 ) || ( tTile.flag1 & 0x40 ) || ( tTile.flag2 & 0x04 ) ) ) + continue; + + stBlockItem blockItem; + blockItem.height = tTile.height; + blockItem.z = pItem->pos().z + multi[j].z; + + if ( ( tTile.flag2 & 0x02 ) && !( tTile.flag1 & 0x40 ) ) + blockItem.walkable = true; + else + blockItem.walkable = checkWalkable( pChar, pItem->id() ); + + blockList.push_back( blockItem ); + push_heap( blockList.begin(), blockList.end(), compareTiles() ); + } + } + continue; + } + + delete iter; + + + // Now we need to evaluate dynamic items [...] (later) ?? sort_heap( blockList.begin(), blockList.end(), compareTiles() ); return blockList; + }; ! // May a character walk here ? // If yes we auto. set the new z value for pos bool mayWalk( P_CHAR pChar, Coord_cl& pos ) *************** *** 448,457 **** return false; - /* if( !isValidDirection( dir ) ) - { - pChar->setPathNum( pChar->pathnum() + PATHNUM ); - return; - }*/ - P_PLAYER player = dynamic_cast<P_PLAYER>( pChar ); --- 460,463 ---- *************** *** 496,507 **** } - // Check for Characters in our way - if ( !checkObstacles( pChar, newCoord, running ) ) - { - if ( player && player->socket() ) - player->socket()->denyMove( sequence ); - return false; - } - // Check if the char can move to those new coordinates // It is going to automatically calculate the new coords (!) --- 502,505 ---- *************** *** 598,602 **** bool cMovement::CheckForCharacterAtXYZ( P_CHAR pc, const Coord_cl& pos ) { ! RegionIterator4Chars ri( pos ); for ( ri.Begin(); !ri.atEnd(); ri++ ) { --- 596,605 ---- bool cMovement::CheckForCharacterAtXYZ( P_CHAR pc, const Coord_cl& pos ) { ! // again this seems to me like we are doing too much work. ! // why should we get all chars in the region using default (18), ! // and then loop through them ignoring all those not at exactly the spot we are going (now) on? ! // why not just get those on the one spot we care about anyways? ! ! RegionIterator4Chars ri( pos, 0 ); for ( ri.Begin(); !ri.atEnd(); ri++ ) { *************** *** 607,611 **** { // x=x,y=y, and distance btw z's <= MAX STEP ! if ( ( pc_i->pos().x == pos.x ) && ( pc_i->pos().y == pos.y ) && ( abs( pc_i->pos().z - pos.z ) <= P_M_MAX_Z_CLIMB ) ) { return true; --- 610,614 ---- { // x=x,y=y, and distance btw z's <= MAX STEP ! if ( abs( pc_i->pos().z - pos.z ) <= P_M_MAX_Z_CLIMB ) { return true; |