Пример #1
0
void cBlockPistonHandler::ExtendPiston(int pistx, int pisty, int pistz)
{
	BLOCKTYPE pistonBlock;
	NIBBLETYPE pistonMeta;
	m_World->GetBlockTypeMeta(pistx, pisty, pistz, pistonBlock, pistonMeta);
	
	if (IsExtended(pistonMeta))
	{
		// Already extended, bail out
		return;
	}

	int dist = FirstPassthroughBlock(pistx, pisty, pistz, pistonMeta);
	if (dist < 0)
	{
		// FirstPassthroughBlock says piston can't push anything, bail out
		return;
	}

	m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, pistonBlock);
	m_World->BroadcastSoundEffect("tile.piston.out", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f);	
	
	// Drop the breakable block in the line, if appropriate:
	AddPistonDir(pistx, pisty, pistz, pistonMeta, dist + 1);  // "pist" now at the breakable / empty block
	BLOCKTYPE currBlock;
	NIBBLETYPE currMeta;
	m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currMeta);
	if (currBlock != E_BLOCK_AIR)
	{
		cBlockHandler * Handler = BlockHandler(currBlock);
		if (Handler->DoesDropOnUnsuitable())
		{
			cChunkInterface ChunkInterface(m_World->GetChunkMap());
			cBlockInServerPluginInterface PluginInterface(*m_World);
			Handler->DropBlock(ChunkInterface, *m_World, PluginInterface, NULL, pistx, pisty, pistz);
		}
	}
	
	// Push blocks, from the furthest to the nearest:
	int oldx = pistx, oldy = pisty, oldz = pistz;
	NIBBLETYPE currBlockMeta;
	for (int i = dist + 1; i > 1; i--)
	{
		AddPistonDir(pistx, pisty, pistz, pistonMeta, -1);
		m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currBlockMeta);
		m_World->QueueSetBlock( oldx, oldy, oldz, currBlock, currBlockMeta, PISTON_TICK_DELAY);
		oldx = pistx;
		oldy = pisty;
		oldz = pistz;
	}

	int extx = pistx;
	int exty = pisty;
	int extz = pistz;
	AddPistonDir(pistx, pisty, pistz, pistonMeta, -1);
	// "pist" now at piston body, "ext" at future extension
	
	m_World->SetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8);
	m_World->QueueSetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), PISTON_TICK_DELAY);
}
Пример #2
0
// SMsgDirG2ModifyService::Pack
// Virtual method from SmallMessage.  Packs data into message buffer.
void*
SMsgDirG2ModifyService::Pack(void)
{
	WTRACE("SMsgDirG2ModifyService::Pack");
	SetKeyType(KT_SERVICE);
	SetServiceType(WONMsg::SmallDirServerG2);
	if (IsExtended())
	{
		SetMessageType(WONMsg::DirG2ModifyServiceEx);
		SetExtended(true, true);
	}
	else
		SetMessageType(WONMsg::DirG2ModifyService);

	SMsgDirG2UpdateExtendBase::Pack();
	AppendByte(mEntityFlags);
	PackKey(*this);
	Append_PW_STRING(mNewName);

	unsigned char aLen = mNewNetAddress.size();
	AppendByte(aLen);
	if (aLen > 0)
		AppendBytes(aLen, mNewNetAddress.data());

	Append_PW_STRING(mNewDisplayName);
	AppendLong(mNewLifespan);
	PackExtended();
	PackPeerData();

	return GetDataPtr();
}
Пример #3
0
void cBlockPistonHandler::ExtendPiston(Vector3i a_BlockPos, cWorld * a_World)
{
	BLOCKTYPE pistonBlock;
	NIBBLETYPE pistonMeta;
	a_World->GetBlockTypeMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta);

	if (IsExtended(pistonMeta))
	{
		// Already extended, bail out
		return;
	}

	Vector3i pushDir = MetadataToOffset(pistonMeta);

	Vector3iSet blocksPushed;
	if (!CanPushBlock(a_BlockPos + pushDir, a_World, true, blocksPushed, pushDir))
	{
		// Can't push anything, bail out
		return;
	}

	a_World->BroadcastBlockAction(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, 0, pistonMeta, pistonBlock);
	a_World->BroadcastSoundEffect("tile.piston.out", a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, 0.5f, 0.7f);

	PushBlocks(blocksPushed, a_World, pushDir);

	// Set the extension and the piston base correctly
	Vector3i extensionPos = a_BlockPos + pushDir;
	a_World->SetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta | 0x8);
	a_World->SetBlock(
		extensionPos.x, extensionPos.y, extensionPos.z,
		E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0)
	);
}
Пример #4
0
void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
{
	BLOCKTYPE pistonBlock;
	NIBBLETYPE pistonMeta;
	a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta);

	if (!IsExtended(pistonMeta))
	{
		// Already retracted, bail out
		return;
	}

	// Check the extension:
	AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1);
	if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_PISTON_EXTENSION)
	{
		LOGD("%s: Piston without an extension - still extending, or just in an invalid state?", __FUNCTION__);
		return;
	}

	AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
	a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta & ~(8));
	a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 1, pistonMeta & ~(8), pistonBlock);
	a_World->BroadcastSoundEffect("tile.piston.in", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f);
	AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1);

	// Retract the extension, pull block if appropriate
	if (IsSticky(pistonBlock))
	{
		int tempx = a_BlockX, tempy = a_BlockY, tempz = a_BlockZ;
		AddPistonDir(tempx, tempy, tempz, pistonMeta, 1);
		BLOCKTYPE tempBlock;
		NIBBLETYPE tempMeta;
		a_World->GetBlockTypeMeta(tempx, tempy, tempz, tempBlock, tempMeta);
		if (CanPull(tempBlock, tempMeta))
		{
			// Pull the block
			a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, tempBlock, tempMeta, false);
			a_World->SetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, false);

			std::vector<Vector3i> ScheduledBlocks;
			ScheduledBlocks.push_back(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
			ScheduledBlocks.push_back(Vector3i(tempx, tempy, tempz));
			a_World->ScheduleTask(PISTON_TICK_DELAY + 1, new cWorld::cTaskSendBlockToAllPlayers(ScheduledBlocks));
			return;
		}
	}
	
	// Retract without pulling
	a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0, false);

	std::vector<Vector3i> ScheduledBlocks;
	ScheduledBlocks.push_back(Vector3i(a_BlockX, a_BlockY, a_BlockZ));
	a_World->ScheduleTask(PISTON_TICK_DELAY + 1, new cWorld::cTaskSendBlockToAllPlayers(ScheduledBlocks));
}
Пример #5
0
// Default ctor
SMsgDirG2ModifyService::SMsgDirG2ModifyService(bool isExtended) :
	SMsgDirG2UpdateExtendBase(KT_SERVICE, isExtended, isExtended),
	mEntityFlags(0),
	mNewName(),
	mNewNetAddress(),
	mNewDisplayName(),
	mNewLifespan(0)
{
	SetServiceType(WONMsg::SmallDirServerG2);
	SetMessageType(IsExtended() ? WONMsg::DirG2ModifyServiceEx : WONMsg::DirG2ModifyService);
}
Пример #6
0
void cPiston::RetractPiston(int pistx, int pisty, int pistz)
{
	BLOCKTYPE pistonBlock;
	NIBBLETYPE pistonMeta;
	m_World->GetBlockTypeMeta(pistx, pisty, pistz, pistonBlock, pistonMeta);

	if (!IsExtended(pistonMeta))
	{
		// Already retracted, bail out
		return;
	}

	// Check the extension:
	AddDir(pistx, pisty, pistz, pistonMeta, 1);
	if (m_World->GetBlock(pistx, pisty, pistz) != E_BLOCK_PISTON_EXTENSION)
	{
		LOGD("%s: Piston without an extension - still extending, or just in an invalid state?", __FUNCTION__);
		return;
	}
	
	AddDir(pistx, pisty, pistz, pistonMeta, -1);
	m_World->SetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8));
	m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), pistonBlock);
	m_World->BroadcastSoundEffect("tile.piston.in", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f);
	AddDir(pistx, pisty, pistz, pistonMeta, 1);
	
	// Retract the extension, pull block if appropriate
	if (IsSticky(pistonBlock))
	{
		int tempx = pistx, tempy = pisty, tempz = pistz;
		AddDir(tempx, tempy, tempz, pistonMeta, 1);
		BLOCKTYPE tempBlock;
		NIBBLETYPE tempMeta;
		m_World->GetBlockTypeMeta(tempx, tempy, tempz, tempBlock, tempMeta);
		if (CanPull(tempBlock, tempMeta))
		{
			// Pull the block
			m_World->QueueSetBlock(pistx, pisty, pistz, tempBlock, tempMeta, PISTON_TICK_DELAY);
			m_World->QueueSetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
		}
		else
		{
			// Retract without pulling
			m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
		}
	}
	else
	{
		m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY);
	}
}
Пример #7
0
void cBlockPistonHandler::RetractPiston(Vector3i a_BlockPos, cWorld * a_World)
{
	BLOCKTYPE pistonBlock;
	NIBBLETYPE pistonMeta;
	a_World->GetBlockTypeMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta);

	if (!IsExtended(pistonMeta))
	{
		// Already retracted, bail out
		return;
	}

	Vector3i pushDir = MetadataToOffset(pistonMeta);

	// Check the extension:
	Vector3i extensionPos = a_BlockPos + pushDir;
	if (a_World->GetBlock(extensionPos) != E_BLOCK_PISTON_EXTENSION)
	{
		LOGD("%s: Piston without an extension - still extending, or just in an invalid state?", __FUNCTION__);
		return;
	}

	// Remove Extension
	a_World->SetBlock(extensionPos.x, extensionPos.y, extensionPos.z, E_BLOCK_AIR, 0);

	a_World->SetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, pistonBlock, pistonMeta & ~(8));
	a_World->BroadcastBlockAction(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, 1, pistonMeta & ~(8), pistonBlock);
	a_World->BroadcastSoundEffect("tile.piston.in", a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, 0.5f, 0.7f);

	if (!IsSticky(pistonBlock))
	{
		// No need for block pulling, bail out
		return;
	}

	// Get the block to pull
	a_BlockPos += pushDir * 2;
	// Try to "push" the pulling block in the opposite direction
	pushDir *= -1;

	Vector3iSet pushedBlocks;
	if (!CanPushBlock(a_BlockPos, a_World, false, pushedBlocks, pushDir))
	{
		// Not pushable, bail out
		return;
	}

	PushBlocks(pushedBlocks, a_World, pushDir);
}
Пример #8
0
void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
{
	BLOCKTYPE pistonBlock;
	NIBBLETYPE pistonMeta;
	a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta);

	if (!IsExtended(pistonMeta))
	{
		// Already retracted, bail out
		return;
	}

	// Check the extension:
	AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1);
	if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_PISTON_EXTENSION)
	{
		LOGD("%s: Piston without an extension - still extending, or just in an invalid state?", __FUNCTION__);
		return;
	}

	AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
	a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta & ~(8));
	a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 1, pistonMeta & ~(8), pistonBlock);
	a_World->BroadcastSoundEffect("tile.piston.in", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 0.5f, 0.7f);
	AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, 1);

	// Retract the extension, pull block if appropriate
	if (IsSticky(pistonBlock))
	{
		int tempx = a_BlockX, tempy = a_BlockY, tempz = a_BlockZ;
		AddPistonDir(tempx, tempy, tempz, pistonMeta, 1);
		BLOCKTYPE tempBlock;
		NIBBLETYPE tempMeta;
		a_World->GetBlockTypeMeta(tempx, tempy, tempz, tempBlock, tempMeta);
		if (CanPull(tempBlock, tempMeta))
		{
			// Pull the block
			a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, tempBlock, tempMeta);
			a_World->SetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0);
			return;
		}
	}
	
	// Retract without pulling
	a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
}
Пример #9
0
bool cPiston::CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
	switch (a_BlockType)
	{
		case E_BLOCK_ANVIL:
		case E_BLOCK_BED:
		case E_BLOCK_BEDROCK:
		case E_BLOCK_BREWING_STAND:
		case E_BLOCK_CHEST:
		case E_BLOCK_COMMAND_BLOCK:
		case E_BLOCK_DISPENSER:
		case E_BLOCK_DROPPER:
		case E_BLOCK_ENCHANTMENT_TABLE:
		case E_BLOCK_END_PORTAL:
		case E_BLOCK_END_PORTAL_FRAME:
		case E_BLOCK_FURNACE:
		case E_BLOCK_LIT_FURNACE:
		case E_BLOCK_HOPPER:
		case E_BLOCK_JUKEBOX:
		case E_BLOCK_MOB_SPAWNER:
		case E_BLOCK_NETHER_PORTAL:
		case E_BLOCK_NOTE_BLOCK:
		case E_BLOCK_OBSIDIAN:
		case E_BLOCK_PISTON_EXTENSION:
		{
			return false;
		}
		case E_BLOCK_STICKY_PISTON:
		case E_BLOCK_PISTON:
		{
			// A piston can only be pushed if retracted:
			return !IsExtended(a_BlockMeta);
		}
	}
	return true;
}
Пример #10
0
void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
{
	BLOCKTYPE pistonBlock;
	NIBBLETYPE pistonMeta;
	a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta);

	if (IsExtended(pistonMeta))
	{
		// Already extended, bail out
		return;
	}

	int dist = FirstPassthroughBlock(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, a_World);
	if (dist < 0)
	{
		// FirstPassthroughBlock says piston can't push anything, bail out
		return;
	}

	a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 0, pistonMeta, pistonBlock);
	a_World->BroadcastSoundEffect("tile.piston.out", (double)a_BlockX, (double)a_BlockY, (double)a_BlockZ, 0.5f, 0.7f);

	// Drop the breakable block in the line, if appropriate:
	AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, dist + 1);  // "a_Block" now at the breakable / empty block
	BLOCKTYPE currBlock;
	NIBBLETYPE currMeta;
	a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, currBlock, currMeta);
	if (currBlock != E_BLOCK_AIR)
	{
		cBlockHandler * Handler = BlockHandler(currBlock);
		if (Handler->DoesDropOnUnsuitable())
		{
			cChunkInterface ChunkInterface(a_World->GetChunkMap());
			cBlockInServerPluginInterface PluginInterface(*a_World);
			Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, NULL, a_BlockX, a_BlockY, a_BlockZ);
		}
	}

	// Push blocks, from the furthest to the nearest:
	int oldx = a_BlockX, oldy = a_BlockY, oldz = a_BlockZ;
	NIBBLETYPE currBlockMeta;
	std::vector<Vector3i> ScheduledBlocks;
	ScheduledBlocks.reserve(PISTON_MAX_PUSH_DISTANCE);

	for (int i = dist + 1; i > 1; i--)
	{
		AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
		a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, currBlock, currBlockMeta);
		a_World->SetBlock(oldx, oldy, oldz, currBlock, currBlockMeta, false);
		ScheduledBlocks.push_back(Vector3i(oldx, oldy, oldz));
		oldx = a_BlockX;
		oldy = a_BlockY;
		oldz = a_BlockZ;
	}

	int extx = a_BlockX;
	int exty = a_BlockY;
	int extz = a_BlockZ;
	ScheduledBlocks.push_back(Vector3i(extx, exty, extz));
	AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
	// "a_Block" now at piston body, "ext" at future extension

	a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta | 0x8);
	a_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), false);
	a_World->ScheduleTask(PISTON_TICK_DELAY, new cWorld::cTaskSendBlockToAllPlayers(ScheduledBlocks));
}
Пример #11
0
 bool Rossler::HasJacobian() const {
   return (IsExtended() ? false : true);
 }
Пример #12
0
/*****************************************************************************
BLAST_RMapDecode()
Description:
    This routine will decode a shift coded packet to a number representing
    the 
Parameters:
    UserBuf_p           user buffer to place data into
    UserBufSize         how big the user buff is
    SymbolBuf_p         symbol buffer to consume
    SymbolsAvailable    how many symbols present in buffer
    NumDecoded_p        how many data words we decoded
    SymbolsUsed_p       how many symbols we used
    RcProtocol_p        protocol block

Return Value:
    ST_NO_ERROR

See Also:
    BLAST_ShiftEncode
*****************************************************************************/
ST_ErrorCode_t BLAST_RMapDecode(U32                 *UserBuf_p,
                               STBLAST_Symbol_t     *SymbolBuf_p,
                               U32                  SymbolsAvailable,
                               U32                  *NumDecoded_p,
                               const STBLAST_ProtocolParams_t *ProtocolParams_p)
{
    U8  j;
    U8  PayloadHalfLevel;
    U16 HalfLevelDuration;
    U32 SymbolIndex=0;
    U8  Up,Down;
    BOOL TransitionArray[RSTEP_MAX_FRAME_SIZE] = {0}; /* only one BufferElementPerPayload is supported so this can be a fixed value */
    BOOL ExtendedTrace;   
    U8 DeviceId= 0;
    U8 CustomId = 0;
    U8 Address = 0;
    U8 Data = 0;
    *NumDecoded_p = 0;    
      
    /* This is for Ruwido */
    HalfLevelDuration = HALF_LEVEL_DURATION;        
    
#if defined (IR_INVERT)
    Down = 0;   /* define the relationship between    */
    Up   = 1;   /* transition direction and bit value */
#else
    Down = 1;   /* define the relationship between    */
    Up   = 0;   /* transition direction and bit value */
#endif
    
    /* We've now found a starting symbol, so let's decode it
      to a manchester-coded bitmask.*/
    /* traverse the BIT ARRAY, setting bits as we go */
    /* Bit 0 */
    
    PayloadHalfLevel = 1; /* the start of the symbol and START of the bit-period must coincide*/ 
    SymbolIndex = 0; 
   
    TransitionArray[0] = Down;
    ExtendedTrace = IsExtended(SymbolBuf_p[SymbolIndex], SPACE, HalfLevelDuration);

    {
    	/* remaining bits */
        for (j=1; (SymbolIndex < SymbolsAvailable) ; j++)
        {
            /* Remaining payload bits */
            if (TransitionArray[j-1] == Down)
            {                
                if (ExtendedTrace)
                {
                    TransitionArray[j] = Up;
                    ExtendedTrace = IsExtended(SymbolBuf_p[++SymbolIndex], MARK, HalfLevelDuration);
                    if (!ExtendedTrace)
                    {
                        if (SymbolBuf_p[SymbolIndex].SymbolPeriod >= SYMBOL_TIMEOUT) /* Time Out Value */
                        {
                            break;
                        }
                    }
                }
                else
                {
                    TransitionArray[j] = Down;
                    ExtendedTrace = IsExtended(SymbolBuf_p[++SymbolIndex], SPACE, HalfLevelDuration);
                
                }
            }
            else /* last transition was Up */
            {
                if (ExtendedTrace)
                {
                    TransitionArray[j] = Down;
                    ExtendedTrace = IsExtended(SymbolBuf_p[SymbolIndex], SPACE, HalfLevelDuration);
                    if (SymbolBuf_p[SymbolIndex].SymbolPeriod >= SYMBOL_TIMEOUT) /* Time Out Value */
                    {
                        break;
                    }
                }
                else
                {
                    TransitionArray[j] = Up;
                    ExtendedTrace = IsExtended(SymbolBuf_p[++SymbolIndex], MARK, HalfLevelDuration);
                }
            }
        }
    
        Data = 0;
        
        /* Check for start bit */
        if ( TransitionArray[0] != 1 )
        {
            *NumDecoded_p = 0;  
            return ST_NO_ERROR;
        }            	
            
        /* build up Custom Id */
        for ( j = CUSTOMID_BIT_START; j <= CUSTOMID_BIT_END; j++)
        {
            CustomId <<= 1;
            CustomId |= TransitionArray[j];
        }
            
        if ( CustomId != ProtocolParams_p->Ruwido.CustomID )            
        {
            *NumDecoded_p = 0;  
            return ST_NO_ERROR;
        }  
            
        /* build up device Id */
        for ( j = DEVICEID_BIT_START; j <= DEVICEID_BIT_END; j++)
        {
            DeviceId <<= 1;
            DeviceId |= TransitionArray[j];
        }
            
        if ( DeviceId != ProtocolParams_p->Ruwido.DeviceID )            
        {
            *NumDecoded_p = 0;  
            return ST_NO_ERROR;
        }  
            
        /* build up Address field */
        for ( j = ADDRESS_BIT_START; j <= ADDRESS_BIT_END; j++)
        {
            Address <<= 1;
            Address |= TransitionArray[j];
        }
            
        if ( Address != ProtocolParams_p->Ruwido.Address )            
        {
            *NumDecoded_p = 0;  
            return ST_NO_ERROR;
        }  
            
        if ( ProtocolParams_p->Ruwido.FrameLength == RMAP_MAX_FRAME_SIZE/2)
        {
        	     
            /* 1st word contains 8bit command */
            for (j = RMAP_COMMAND_BIT_START; j < RMAP_COMMAND_BIT_END; j++)
            {
                Data <<= 1;
                Data |= (TransitionArray[j]);
            }
        }
        else if (ProtocolParams_p->Ruwido.FrameLength == RSTEP_MAX_FRAME_SIZE/2)
        {
        	     
            /* 1st word contains 8bit command */
            for (j = RSTEP_COMMAND_BIT_START; j < RSTEP_COMMAND_BIT_END; j++)
            {
                Data <<= 1;
                Data |= (TransitionArray[j]);
            }
        }
        else
        {
            *NumDecoded_p = 0;  
            return ST_NO_ERROR;	
        }
        
         
        /* Set the user data element */
       *UserBuf_p = Data;
       *NumDecoded_p = 1;  
            
    }

    return ST_NO_ERROR;
}
Пример #13
0
void cBlockPistonHandler::ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World)
{
	BLOCKTYPE pistonBlock;
	NIBBLETYPE pistonMeta;
	a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta);

	if (IsExtended(pistonMeta))
	{
		// Already extended, bail out
		return;
	}

	int dist = FirstPassthroughBlock(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, a_World);
	if (dist < 0)
	{
		// FirstPassthroughBlock says piston can't push anything, bail out
		return;
	}

	a_World->BroadcastBlockAction(a_BlockX, a_BlockY, a_BlockZ, 0, pistonMeta, pistonBlock);
	a_World->BroadcastSoundEffect("tile.piston.out", static_cast<double>(a_BlockX), static_cast<double>(a_BlockY), static_cast<double>(a_BlockZ), 0.5f, 0.7f);

	// Drop the breakable block in the line, if appropriate:
	AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, dist + 1);  // "a_Block" now at the breakable / empty block
	BLOCKTYPE currBlock;
	NIBBLETYPE currMeta;
	a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, currBlock, currMeta);
	if (currBlock != E_BLOCK_AIR)
	{
		cBlockHandler * Handler = BlockHandler(currBlock);
		if (Handler->DoesDropOnUnsuitable())
		{
			cChunkInterface ChunkInterface(a_World->GetChunkMap());
			cBlockInServerPluginInterface PluginInterface(*a_World);
			Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, nullptr, a_BlockX, a_BlockY, a_BlockZ);
		}
	}

	// Push blocks, from the furthest to the nearest:
	int oldx = a_BlockX, oldy = a_BlockY, oldz = a_BlockZ;
	NIBBLETYPE currBlockMeta;

	for (int i = dist + 1; i > 1; i--)
	{
		AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
		a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, currBlock, currBlockMeta);
		a_World->SetBlock(oldx, oldy, oldz, currBlock, currBlockMeta);
		oldx = a_BlockX;
		oldy = a_BlockY;
		oldz = a_BlockZ;
	}

	int extx = a_BlockX;
	int exty = a_BlockY;
	int extz = a_BlockZ;
	AddPistonDir(a_BlockX, a_BlockY, a_BlockZ, pistonMeta, -1);
	// "a_Block" now at piston body, "ext" at future extension

	a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, pistonBlock, pistonMeta | 0x8);
	a_World->SetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0));
}
Пример #14
0
int			CBuzzSample::GetSampleFormat() {
	if (IsExtended()) {
		return m_pWaveLevel->pSamples[0];
	} else
		return 0;
}
Пример #15
0
void	*	CBuzzSample::GetSampleStart()
{
	if (IsExtended())
		return m_pWaveLevel->pSamples + 4; else
		return m_pWaveLevel->pSamples;
}