2012-01-29 19:28:19 +00:00
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
2011-11-04 05:01:55 +00:00
#include "cRedstone.h"
2011-11-06 02:36:05 +00:00
#include "cPiston.h"
2011-11-04 07:50:18 +00:00
#include "cRoot.h"
2011-11-04 05:01:55 +00:00
#include "cWorld.h"
2011-11-04 16:05:18 +00:00
#include "BlockID.h"
2011-11-09 01:31:19 +00:00
#include <iostream>
2012-01-29 19:28:19 +00:00
2011-11-04 05:01:55 +00:00
2012-02-22 15:35:10 +00:00
bool cRedstone :: s_UseRedstone = true ;
2011-11-04 05:01:55 +00:00
cRedstone :: cRedstone ( cWorld * a_World )
: m_World ( a_World )
2011-11-06 20:39:44 +00:00
, m_Metadata ( 0 )
2011-11-09 01:31:19 +00:00
, m_Direction ( 0 )
2011-11-04 05:01:55 +00:00
{
}
2012-02-22 15:35:10 +00:00
2011-11-07 22:59:29 +00:00
void cRedstone :: ChangeRedstone ( int fillx , int filly , int fillz , bool added )
2011-11-04 05:01:55 +00:00
{
2012-02-22 15:35:10 +00:00
if ( ! s_UseRedstone ) return ;
char before ;
//int tempX;
//int tempY;
//int tempZ;
//int state;
//m_Direction
// 0 = x+
// 1 = x-
// 2 = z+
// 3 = z-
// 4 = y+
// 5 = v-
if ( added ) {
m_Metadata = 15 ;
} else {
m_Metadata = 0 ;
}
before = m_Metadata ;
//printf("etb1\n");
CalculateRedstone ( fillx , filly , fillz ); //calculate all item centers.
//printf("etb2\n");
int Block = ( int ) m_World -> GetBlock ( fillx , filly , fillz );
2011-11-06 21:20:38 +00:00
2012-02-22 15:35:10 +00:00
switch ( Block ) //these blocks won't trigger the normal calculaton because they are affected by the redstone around them. So we check each possible channel around them instead.
{
case E_BLOCK_REDSTONE_TORCH_ON :
case E_BLOCK_REDSTONE_TORCH_OFF :
case E_BLOCK_AIR :
case E_BLOCK_PISTON_EXTENSION :
case E_BLOCK_PISTON :
case E_BLOCK_STICKY_PISTON :
{
m_Metadata = 0 ;
m_Direction = 0 ;
CalculateRedstone ( fillx + 1 , filly , fillz );
m_Metadata = 0 ;
m_Direction = 1 ;
CalculateRedstone ( fillx - 1 , filly , fillz );
m_Metadata = 0 ;
m_Direction = 2 ;
CalculateRedstone ( fillx , filly , fillz + 1 );
m_Metadata = 0 ;
m_Direction = 3 ;
CalculateRedstone ( fillx , filly , fillz - 1 );
m_Metadata = 0 ;
CalculateRedstone ( fillx , filly - 1 , fillz );
break ;
}
case E_BLOCK_REDSTONE_WIRE : //special case for redstone wire.
{
m_Direction = 0 ;
CalculateRedstone ( fillx + 1 , filly , fillz );
m_Direction = 1 ;
CalculateRedstone ( fillx - 1 , filly , fillz );
m_Direction = 2 ;
CalculateRedstone ( fillx , filly , fillz + 1 );
m_Direction = 3 ;
CalculateRedstone ( fillx , filly , fillz - 1 );
m_Metadata = 0 ;
CalculateRedstone ( fillx , filly - 1 , fillz );
m_Direction = 4 ;
CalculateRedstone ( fillx + 1 , filly + 1 , fillz );
CalculateRedstone ( fillx - 1 , filly + 1 , fillz );
CalculateRedstone ( fillx , filly + 1 , fillz + 1 );
CalculateRedstone ( fillx , filly + 1 , fillz - 1 );
m_Direction = 5 ;
CalculateRedstone ( fillx + 1 , filly - 1 , fillz );
CalculateRedstone ( fillx - 1 , filly - 1 , fillz );
CalculateRedstone ( fillx , filly - 1 , fillz + 1 );
CalculateRedstone ( fillx , filly - 1 , fillz - 1 );
break ;
}
}
2011-11-09 01:31:19 +00:00
//printf("done here\n");
2011-11-04 05:01:55 +00:00
}
2012-02-22 15:35:10 +00:00
void cRedstone :: CalculateRedstone ( int fillx , int filly , int fillz )
2011-11-04 05:01:55 +00:00
{
2011-11-06 20:39:44 +00:00
2011-11-06 02:36:05 +00:00
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz ) == E_BLOCK_STICKY_PISTON ) || ( ( int ) m_World -> GetBlock ( fillx , filly , fillz ) == E_BLOCK_PISTON ) ) {
2011-11-07 22:59:29 +00:00
char pistonMeta = m_World -> GetBlockMeta ( fillx , filly , fillz );
2011-11-06 20:39:44 +00:00
if ( m_Metadata > 0 ) {
2011-11-07 22:59:29 +00:00
if ( pistonMeta < 6 ) { // only extend if piston is not already extended
cPiston Piston ( m_World );
Piston . ExtendPiston ( fillx , filly , fillz );
}
2011-11-06 02:36:05 +00:00
} else {
2011-11-07 22:59:29 +00:00
if ( pistonMeta > 6 ) { // only retract if piston is not already retracted
cPiston Piston ( m_World );
Piston . RetractPiston ( fillx , filly , fillz );
}
2011-11-06 02:36:05 +00:00
}
2011-11-04 05:01:55 +00:00
2011-11-09 01:31:19 +00:00
} else if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz ) == E_ITEM_LEVER ) || ( ( int ) m_World -> GetBlock ( fillx , filly , fillz ) == E_ITEM_STONE_BUTTON ) ) {
if ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz ) > 6 ) { //button powered
m_Metadata = 15 ; //change meta to 15 only if redstone power device in on possition is found.
if ( ( ( int ) m_World -> GetBlock ( fillx - 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx - 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx - 1 , filly , fillz );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx + 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx + 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx + 1 , filly , fillz );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz - 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz - 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz - 1 );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz + 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz + 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz + 1 );
2011-11-09 01:31:19 +00:00
}
} else {
if ( ( ( int ) m_World -> GetBlock ( fillx - 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx - 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx - 1 , filly , fillz );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx + 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx + 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx + 1 , filly , fillz );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz - 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz - 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz - 1 );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz + 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz + 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz + 1 );
2011-11-09 01:31:19 +00:00
}
}
} else if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz ) == E_BLOCK_STONE_PRESSURE_PLATE ) || ( ( int ) m_World -> GetBlock ( fillx , filly , fillz ) == E_BLOCK_STONE_BUTTON ) ) {
if ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz ) == 1 ) { //plate powered
m_Metadata = 15 ; //change meta to 15 only if redstone power device in on possition is found.
if ( ( ( int ) m_World -> GetBlock ( fillx - 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx - 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx - 1 , filly , fillz );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx + 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx + 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx + 1 , filly , fillz );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz - 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz - 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz - 1 );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz + 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz + 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz + 1 );
2011-11-09 01:31:19 +00:00
}
} else {
if ( ( ( int ) m_World -> GetBlock ( fillx - 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx - 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx - 1 , filly , fillz );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx + 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx + 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx + 1 , filly , fillz );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz - 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz - 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz - 1 );
2011-11-09 01:31:19 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz + 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz + 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz + 1 );
2011-11-09 01:31:19 +00:00
}
}
} else if ( ( int ) m_World -> GetBlock ( fillx , filly , fillz ) == E_BLOCK_REDSTONE_TORCH_ON ) { //If torch is on
//printf("found torch on\n");
m_Metadata = 15 ; //change meta to 15 only if redstone torch in on possition is found.
2011-11-06 20:39:44 +00:00
if ( ( ( int ) m_World -> GetBlock ( fillx - 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx - 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx - 1 , filly , fillz );
2011-11-06 20:39:44 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx + 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx + 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx + 1 , filly , fillz );
2011-11-06 20:39:44 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz - 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz - 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz - 1 );
2011-11-06 20:39:44 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz + 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz + 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz + 1 );
2011-11-06 20:39:44 +00:00
}
2011-11-10 17:03:35 +00:00
2011-11-07 22:59:29 +00:00
} else if ( ( int ) m_World -> GetBlock ( fillx , filly , fillz ) == E_BLOCK_REDSTONE_TORCH_OFF ) { //if the torch is off
2011-11-09 01:31:19 +00:00
//printf("found torch off\n");
// no need to change meta here.
2011-11-06 20:39:44 +00:00
if ( ( ( int ) m_World -> GetBlock ( fillx - 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx - 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx - 1 , filly , fillz );
2011-11-06 20:39:44 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx + 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx + 1 , filly , fillz ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx + 1 , filly , fillz );
2011-11-06 20:39:44 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz - 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz - 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz - 1 );
2011-11-06 20:39:44 +00:00
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz + 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz + 1 ) != m_Metadata ) ) {
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz + 1 );
2011-11-06 20:39:44 +00:00
}
2011-11-09 01:31:19 +00:00
} else if ( ( int ) m_World -> GetBlock ( fillx , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) { //simple fill algorithm for redstone wire.
2011-11-06 20:39:44 +00:00
2011-11-09 01:31:19 +00:00
if ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz ) != m_Metadata ) {
2011-11-06 20:39:44 +00:00
m_World -> FastSetBlock ( fillx , filly , fillz , ( char ) E_BLOCK_REDSTONE_WIRE , m_Metadata );
2011-11-09 01:31:19 +00:00
m_Direction = 0 ;
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx + 1 , filly , fillz );
2011-11-09 01:31:19 +00:00
m_Direction = 1 ;
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx - 1 , filly , fillz );
2011-11-09 01:31:19 +00:00
m_Direction = 2 ;
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz + 1 );
2011-11-09 01:31:19 +00:00
m_Direction = 3 ;
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx , filly , fillz - 1 );
CalculateRedstone ( fillx , filly - 1 , fillz ); //check one block below //similar to same plane
2011-11-09 03:04:56 +00:00
m_Direction = 4 ;
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx + 1 , filly + 1 , fillz );
CalculateRedstone ( fillx - 1 , filly + 1 , fillz );
CalculateRedstone ( fillx , filly + 1 , fillz + 1 );
CalculateRedstone ( fillx , filly + 1 , fillz - 1 );
2011-11-09 03:04:56 +00:00
m_Direction = 5 ;
2012-02-22 15:35:10 +00:00
CalculateRedstone ( fillx + 1 , filly - 1 , fillz );
CalculateRedstone ( fillx - 1 , filly - 1 , fillz );
CalculateRedstone ( fillx , filly - 1 , fillz + 1 );
CalculateRedstone ( fillx , filly - 1 , fillz - 1 );
2011-11-09 01:31:19 +00:00
}
} else { //default, check item for torch attached to it. If meta > 0 then turn that torch off, otherwise turn it on. This change needs to be passed to the next world tick.
//check for torch to east with meta 1 //turn off
//check for torch to west with meta 2 //turn off
//check for torch to south with meta 3 //turn off
//check for torch to north with meta 4 //turn off
//check for torch above with meta 5 //turn off
if ( ( int ) m_World -> GetBlock ( fillx , filly , fillz ) != E_BLOCK_AIR ) {
2011-11-09 03:04:56 +00:00
if ( m_Direction < 4 ) { //redstone wire can only power blocks on the same plane or directly below
2011-11-09 01:31:19 +00:00
if ( ( int ) m_Metadata > 0 ) { //wire powered
//printf("bird: %i dog: %i \n",(int)m_World->GetBlock( fillx, filly+1, fillz ),(int)m_World->GetBlockMeta( fillx, filly+1, fillz));
if ( ( ( int ) m_World -> GetBlock ( fillx + 1 , filly , fillz ) == E_BLOCK_REDSTONE_TORCH_ON ) && ( ( int ) m_World -> GetBlockMeta ( fillx + 1 , filly , fillz ) == 1 ) ) { //east
m_World -> m_RSList . push_back ( fillx + 1 );
m_World -> m_RSList . push_back ( filly );
m_World -> m_RSList . push_back ( fillz );
m_World -> m_RSList . push_back ( 00000 );
}
if ( ( ( int ) m_World -> GetBlock ( fillx - 1 , filly , fillz ) == E_BLOCK_REDSTONE_TORCH_ON ) && ( ( int ) m_World -> GetBlockMeta ( fillx - 1 , filly , fillz ) == 2 ) ) { //west
m_World -> m_RSList . push_back ( fillx - 1 );
m_World -> m_RSList . push_back ( filly );
m_World -> m_RSList . push_back ( fillz );
m_World -> m_RSList . push_back ( 00000 );
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz + 1 ) == E_BLOCK_REDSTONE_TORCH_ON ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz + 1 ) == 3 ) ) { //south
m_World -> m_RSList . push_back ( fillx );
m_World -> m_RSList . push_back ( filly );
m_World -> m_RSList . push_back ( fillz + 1 );
m_World -> m_RSList . push_back ( 00000 );
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz - 1 ) == E_BLOCK_REDSTONE_TORCH_ON ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz - 1 ) == 4 ) ) { //north
m_World -> m_RSList . push_back ( fillx );
m_World -> m_RSList . push_back ( filly );
m_World -> m_RSList . push_back ( fillz - 1 );
m_World -> m_RSList . push_back ( 00000 );
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly + 1 , fillz ) == E_BLOCK_REDSTONE_TORCH_ON ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly + 1 , fillz ) == 5 ) ) { //top
m_World -> m_RSList . push_back ( fillx );
m_World -> m_RSList . push_back ( filly + 1 );
m_World -> m_RSList . push_back ( fillz );
m_World -> m_RSList . push_back ( 00000 );
}
} else { //wire not powered
bool BlockPowered = IsBlockPowered ( fillx , filly , fillz ); //chck this block for other wire turned on or torch turned on below:
if ( BlockPowered == false ) { //if block is not bowered by something else then I need to check for off torches and turn them on.
//printf("echo: %i cruiser: %i \n",(int)m_World->GetBlock( fillx, filly+1, fillz ),(int)m_World->GetBlockMeta( fillx, filly+1, fillz));
if ( ( ( int ) m_World -> GetBlock ( fillx + 1 , filly , fillz ) == E_BLOCK_REDSTONE_TORCH_OFF ) && ( ( int ) m_World -> GetBlockMeta ( fillx + 1 , filly , fillz ) == 1 ) ) { //east
m_World -> m_RSList . push_back ( fillx + 1 );
m_World -> m_RSList . push_back ( filly );
m_World -> m_RSList . push_back ( fillz );
m_World -> m_RSList . push_back ( 11111 );
}
if ( ( ( int ) m_World -> GetBlock ( fillx - 1 , filly , fillz ) == E_BLOCK_REDSTONE_TORCH_OFF ) && ( ( int ) m_World -> GetBlockMeta ( fillx - 1 , filly , fillz ) == 2 ) ) { //west
m_World -> m_RSList . push_back ( fillx - 1 );
m_World -> m_RSList . push_back ( filly );
m_World -> m_RSList . push_back ( fillz );
m_World -> m_RSList . push_back ( 11111 );
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz + 1 ) == E_BLOCK_REDSTONE_TORCH_OFF ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz + 1 ) == 3 ) ) { //south
m_World -> m_RSList . push_back ( fillx );
m_World -> m_RSList . push_back ( filly );
m_World -> m_RSList . push_back ( fillz + 1 );
m_World -> m_RSList . push_back ( 11111 );;
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz - 1 ) == E_BLOCK_REDSTONE_TORCH_OFF ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz - 1 ) == 4 ) ) { //north
m_World -> m_RSList . push_back ( fillx );
m_World -> m_RSList . push_back ( filly );
m_World -> m_RSList . push_back ( fillz - 1 );
m_World -> m_RSList . push_back ( 11111 );
}
if ( ( ( int ) m_World -> GetBlock ( fillx , filly + 1 , fillz ) == E_BLOCK_REDSTONE_TORCH_OFF ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly + 1 , fillz ) == 5 ) ) { //top
m_World -> m_RSList . push_back ( fillx );
m_World -> m_RSList . push_back ( filly + 1 );
m_World -> m_RSList . push_back ( fillz );
m_World -> m_RSList . push_back ( 11111 );
}
}
}
2011-11-09 03:04:56 +00:00
}
2011-11-09 01:31:19 +00:00
}
2011-11-06 20:39:44 +00:00
}
2011-11-09 01:31:19 +00:00
}
2012-02-22 15:35:10 +00:00
2011-11-09 01:31:19 +00:00
bool cRedstone :: IsBlockPowered ( int fillx , int filly , int fillz )
{
if ( ( int ) m_World -> GetBlock ( fillx , filly - 1 , fillz ) == E_BLOCK_REDSTONE_TORCH_ON ) { return true ; }
2011-11-10 17:03:35 +00:00
if ( ( int ) m_World -> GetBlock ( fillx + 1 , filly , fillz ) == E_BLOCK_REDSTONE_TORCH_ON ) { return true ; }
if ( ( int ) m_World -> GetBlock ( fillx - 1 , filly , fillz ) == E_BLOCK_REDSTONE_TORCH_ON ) { return true ; }
if ( ( int ) m_World -> GetBlock ( fillx , filly , fillz + 1 ) == E_BLOCK_REDSTONE_TORCH_ON ) { return true ; }
if ( ( int ) m_World -> GetBlock ( fillx , filly , fillz - 1 ) == E_BLOCK_REDSTONE_TORCH_ON ) { return true ; }
2011-11-09 01:31:19 +00:00
if ( ( ( int ) m_World -> GetBlock ( fillx + 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx + 1 , filly , fillz ) > 0 ) ) { return true ; }
if ( ( ( int ) m_World -> GetBlock ( fillx - 1 , filly , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx - 1 , filly , fillz ) > 0 ) ) { return true ; }
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz + 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz + 1 ) > 0 ) ) { return true ; }
if ( ( ( int ) m_World -> GetBlock ( fillx , filly , fillz - 1 ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly , fillz - 1 ) > 0 ) ) { return true ; }
2011-11-10 17:03:35 +00:00
if ( ( ( int ) m_World -> GetBlock ( fillx , filly + 1 , fillz ) == E_BLOCK_REDSTONE_WIRE ) && ( ( int ) m_World -> GetBlockMeta ( fillx , filly + 1 , fillz ) > 0 ) ) { return true ; }
2011-11-09 01:31:19 +00:00
return false ;
2011-11-06 20:39:44 +00:00
}