void CompoundHandler::initialize(MainHandler *mh) { m_mainHandler = mh; QListIterator<SectionHandler> msi(m_sections); SectionHandler *sec; for (;(sec=msi.current());++msi) { sec->initialize(this); } if (m_members) { m_members->initialize(mh); } }
bool cBoat::Block(P_ITEM pBoat, short int xmove, short int ymove, int dir)//Check to see if the boat is blocked in front of, behind, or next to it (Depending on direction) // PARAM WARNING: xmove and ymove is unreferenced { int ser, sz, zt, loopexit=0; short x = 0, y = 0, c; bool blocked = false; char type, size = 0, typ = 0; map_st map; land_st land; tile_st tile; ser = calcserial(pBoat->moreb1, pBoat->moreb2, pBoat->moreb3, pBoat->moreb4); P_ITEM t = FindItemBySerial( ser ); P_ITEM p1 = FindItemBySerial( pBoat->morex ); P_ITEM p2 = FindItemBySerial( pBoat->morey ); P_ITEM h = FindItemBySerial( pBoat->morez ); switch(dir) { case 6: // L case 7: // U & L case 0: // U case 1: // U & R x = min( t->pos.x, min( h->pos.x, min( p1->pos.x, p2->pos.x ) ) ); y = min( t->pos.y, min( h->pos.y, min( p1->pos.y, p2->pos.y ) ) ); if ( dir != 6 ) type = 1; else if ( dir == 0 ) type = 2; else type = 3; break; case 2: // R case 3: // D & R case 4: // D case 5: // D & L x = max( t->pos.x, max( h->pos.x, max( p1->pos.x, p2->pos.x ) ) ); y = min( t->pos.y, min( h->pos.y, min( p1->pos.y, p2->pos.y ) ) ); if ( dir != 2 ) type = 1; else if ( dir == 4 ) type = 2; else type = 3; break; } //small = 10x5, med = 11x5 large = 12x5 switch(pBoat->more1)//Now set what size boat it is and move the specail items { case 0x00: case 0x04: if ( type == 1 ) size = 10; else if ( type == 2 ) size = 5; else size = 7; case 0x08: case 0x0C: if ( type == 1 ) size = 11; else if ( type == 2 ) size = 5; else size = 7; case 0x10: case 0x14: if ( type == 1 ) size = 12; else if ( type == 2 ) size = 5; else size = 7; break; } if ( type == 1) y -= (size/2)-1; else x -= (size/2)-1; for ( c=0 ; c<size ; c++ ) { if ( type == 1 ) y++; else if ( type == 2 ) x++; else // type == 3 { x++; y++; } sz = Map->StaticTop(Coord_cl(x,y, pBoat->pos.z, pBoat->pos.map ) ); if (sz==illegal_z) typ=0; //0: map-tile else typ=1; //1: static-tile if (typ==0) { map=Map->SeekMap( Coord_cl( x, y, 0, pBoat->pos.map ) ); Map->SeekLand(map.id, &land); //clConsole.send("map type, water bit: %i\n",land.flag1&0x80); if (!(land.flag1&0x80)) blocked = true; } else { // go through all statics of a given x,y... MapStaticIterator msi(Coord_cl( x, y, 0, pBoat->pos.map )); staticrecord *stat; while ( (stat = msi.Next()) && (++loopexit < MAXLOOPS) ) { msi.GetTile(&tile); zt=stat->zoff+tile.height; //for this part...: Bridges can be shown not valid, //so we will keep setting false until we hit a valid point, //when we hit a valid place, we'll stop, leave block as it was, //if all points are invalid, block is true and we exit as normal. if (!(tile.flag1&0x80) && zt<=70) blocked = true; else if (strcmp((char*)tile.name, "water")) blocked = true; //if (zt>70) water = 1; // every static til with z>70 (mast height?) doesnt block, no matter what water-bit is has } }//if type.... if ( blocked ) return true; }//for c=soze return false; }