2011-11-03 22:01:55 -07:00
|
|
|
#include "cRedstone.h"
|
2011-11-04 00:50:18 -07:00
|
|
|
#include "cRoot.h"
|
2011-11-03 22:01:55 -07:00
|
|
|
#include "cWorld.h"
|
2011-11-04 09:05:18 -07:00
|
|
|
#include "BlockID.h"
|
2011-11-03 22:01:55 -07:00
|
|
|
|
|
|
|
cRedstone::cRedstone( cWorld* a_World )
|
|
|
|
:m_World ( a_World )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void cRedstone::ChangeRedstoneTorch( int fillx, int filly, int fillz, bool added )
|
|
|
|
{
|
|
|
|
char metadata = 0;
|
|
|
|
if (added) {
|
|
|
|
metadata = 15;
|
|
|
|
} else {
|
|
|
|
metadata = 0;
|
|
|
|
}
|
2011-11-04 00:50:18 -07:00
|
|
|
|
2011-11-05 12:31:25 -07:00
|
|
|
//cWorld* World = cRoot::Get()->GetWorld();
|
2011-11-04 00:50:18 -07:00
|
|
|
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx+1, filly, fillz ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx+1, filly, fillz, metadata );
|
|
|
|
}
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx-1, filly, fillz ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx-1, filly, fillz, metadata );
|
|
|
|
}
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx, filly, fillz+1 ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx, filly, fillz+1, metadata );
|
|
|
|
}
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx, filly, fillz-1 ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx, filly, fillz-1, metadata );
|
|
|
|
}
|
|
|
|
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx+1, filly, fillz ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx+1, filly-1, fillz, metadata );
|
|
|
|
}
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx-1, filly, fillz ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx-1, filly-1, fillz, metadata );
|
|
|
|
}
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx, filly, fillz+1 ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx, filly-1, fillz+1, metadata );
|
|
|
|
}
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx, filly, fillz-1 ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx, filly-1, fillz-1, metadata );
|
|
|
|
}
|
|
|
|
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx+1, filly, fillz ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx+1, filly+1, fillz, metadata );
|
|
|
|
}
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx-1, filly, fillz ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx-1, filly+1, fillz, metadata );
|
|
|
|
}
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx, filly, fillz+1 ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx, filly+1, fillz+1, metadata );
|
|
|
|
}
|
2011-11-05 12:31:25 -07:00
|
|
|
if ( ( (int)m_World->GetBlock( fillx, filly, fillz-1 ) == E_BLOCK_REDSTONE_WIRE) ) {
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone( fillx, filly+1, fillz-1, metadata );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cRedstone::LightRedstone( int fillx, int filly, int fillz, char metadata)
|
|
|
|
{
|
2011-11-05 12:31:25 -07:00
|
|
|
//cWorld* World = cRoot::Get()->GetWorld();
|
|
|
|
if ( ( (int)m_World->GetBlock( fillx, filly, fillz ) == E_BLOCK_REDSTONE_WIRE) && ( (int)m_World->GetBlockMeta( fillx, filly, fillz) != metadata ) ) {
|
|
|
|
m_World->FastSetBlock( fillx, filly, fillz, (char)E_BLOCK_REDSTONE_WIRE, metadata );
|
2011-11-03 22:01:55 -07:00
|
|
|
LightRedstone(fillx-1,filly,fillz,metadata);
|
|
|
|
LightRedstone(fillx+1,filly,fillz,metadata);
|
|
|
|
LightRedstone(fillx,filly,fillz-1,metadata);
|
|
|
|
LightRedstone(fillx,filly,fillz+1,metadata);
|
|
|
|
|
|
|
|
LightRedstone(fillx-1,filly-1,fillz,metadata);
|
|
|
|
LightRedstone(fillx+1,filly-1,fillz,metadata);
|
|
|
|
LightRedstone(fillx,filly-1,fillz-1,metadata);
|
|
|
|
LightRedstone(fillx,filly-1,fillz+1,metadata);
|
|
|
|
|
|
|
|
LightRedstone(fillx-1,filly+1,fillz,metadata);
|
|
|
|
LightRedstone(fillx+1,filly+1,fillz,metadata);
|
|
|
|
LightRedstone(fillx,filly+1,fillz-1,metadata);
|
|
|
|
LightRedstone(fillx,filly+1,fillz+1,metadata);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|