Ejemplo n.º 1
0
void
Node::load( DataBuffer& dataBuffer, GenericMap& theMap )
{
    // The first byte...
    uint8 bitField = dataBuffer.readNextByte();
    m_majorRoad = BitUtility::getBit(bitField, MAJOR_ROAD_BIT_NBR);
    m_roadToll = BitUtility::getBit(bitField, ROAD_TOLL_BIT_NBR);
    m_entryRestrictions = ItemTypes::entryrestriction_t((bitField & 0x0C) >> 2);
    m_nbrLanes = ItemTypes::entryrestriction_t((bitField & 0x03));

    // The next three bytes
    m_level = (int8) dataBuffer.readNextByte();

    m_maximumWeight = dataBuffer.readNextByte();
    m_maximumHeight = dataBuffer.readNextByte();

    m_speedLimit = dataBuffer.readNextByte();
    m_junctionType = ItemTypes::junction_t(dataBuffer.readNextByte());
    m_nbrEntryConnections = dataBuffer.readNextShort();
    m_entryConnections = NULL;

    if ( m_nbrEntryConnections > 0 ) {
        m_entryConnections = (Connection *)(theMap.getConnectionAllocator().getNextObject());
        for ( uint32 i=0; i < m_nbrEntryConnections; ++i ) {
            if ( i != 0 ) {
                theMap.getConnectionAllocator().getNextObject();
            }
            m_entryConnections[ i ].load( dataBuffer );
        }
    }
}