Example #1
0
  //
  // Initialize system
  //
  void Init(Bool editModeIn)
  {
    ASSERT(!sysInit);

    editMode = editModeIn;

    U16 initialVal = U16(0);

    ASSERT(WorldCtrl::CellMapX());
    ASSERT(WorldCtrl::CellMapZ());

    // Initialise arrays
    for (U32 t = 0; t < Game::MAX_TEAMS; t++)
    {
      teamRemap[t]      = Game::MAX_TEAMS;
      invTeamRemap[t]   = Game::MAX_TEAMS;
      teamDirtyClust[t] = NULL;
      teamLastRescan[t] = U32_MAX;
    }

    if (editMode)
    {
      // If we're in the editor, setup for all teams
      teamCount = Game::MAX_TEAMS;

      for (U32 t = 0; t < Game::MAX_TEAMS; t++)
      {
        teamRemap[t] = U8(t);
        invTeamRemap[t] = U8(t);
      }
    }
    else
    {
      teamCount = Team::NumTeams();

      // Fill in remap entries for teams with id's
      for (U32 t = 0, t2 = 0; t < Game::MAX_TEAMS; t++)
      {
        Team *teamPtr = Team::Id2Team(t);

        if (teamPtr)
        {
          ASSERT(teamPtr->GetId() < Game::MAX_TEAMS)

          // Map team id back to sequential index
          teamRemap[teamPtr->GetId()] = U8(t2);

          // Map sequential team index to team id
          invTeamRemap[t2] = U8(teamPtr->GetId());

          ++t2;
        }
      }
      ASSERT(t2 == teamCount)
    }

    #ifdef DEVELOPMENT
    {
      // Log remap tables and test sync
      char s1[Game::MAX_TEAMS+1];
      char s2[Game::MAX_TEAMS+1];

      s1[Game::MAX_TEAMS] = s2[Game::MAX_TEAMS] = 0;
      for (U32 i = 0; i < Game::MAX_TEAMS; i++)
      {
        s1[i] = teamRemap[i] < Game::MAX_TEAMS ? char(teamRemap[i] + '0') : '.';
        s2[i] = invTeamRemap[i] < Game::MAX_TEAMS ? char(invTeamRemap[i] + '0') : '.';
      }

      //LOG_DIAG(("SightRemap [%s] [%s]", s1, s2))
      SYNC("SightRemap [" << s1 << "] [" << s2 << ']')
    }
    #endif

    // Allocate seeing array
    for (U32 level = 0; level < Map::LV_MAX; ++level)
    {
      for (U32 team = 0; team < teamCount; ++team)
      {
        seeMap[level][team] = new U16*[WorldCtrl::CellMapZ()];
        seeMap[level][team][0] = new U16[WorldCtrl::CellMapX() * WorldCtrl::CellMapZ()];

        for (U32 i = 1; i < WorldCtrl::CellMapZ(); ++i)
        {
          seeMap[level][team][i] = &seeMap[level][team][i - 1][WorldCtrl::CellMapX()];
        }

        // Set initial fog value for all tiles
        for (U32 z = 0; z < WorldCtrl::CellMapZ(); ++z)
        {
          for (U32 x = 0; x < WorldCtrl::CellMapX(); ++x)
          {
            seeMap[level][team][z][x] = initialVal;
          }
        }
      }
    }

    // Round x clusters up to the nearest 8 for the bit array
    mapClustXon8 = ((WorldCtrl::ClusterMapX() + 7) & (~7)) >> 3;

    // Allocate cluster update array
    displayDirtyCells = new BitArray2d(WorldCtrl::CellMapX(), WorldCtrl::CellMapZ());

    for (t = 0; t < teamCount; t++)
    {
      // Allocate team cluster update array
      teamDirtyClust[t] = new U8[mapClustXon8 * WorldCtrl::ClusterMapZ()];

      // Undirty all clusters
      memset(teamDirtyClust[t], 0, mapClustXon8 * WorldCtrl::ClusterMapZ());
    }

    // Initialise radius division lookup table
    for (U32 r = 0; r < MAXR; ++r)
    {
      invRadTbl[r] = (r == 0) ? 10000.0F : (1.0F / F32(r * WC_CELLSIZE));
    }

    // Initialise the terrain - set it all to shrouded
    SetAllFog(Terrain::fogFactorsS32[0]);

    // Create varsys commands
    VarSys::RegisterHandler("coregame.sight", CmdHandler);

    #ifdef DEVELOPMENT

    // Development commands
    VarSys::CreateCmd("coregame.sight.info");
    VarSys::CreateCmd("coregame.sight.map");
    VarSys::CreateInteger("coregame.sight.debugmode", FALSE, VarSys::DEFAULT, &debugMode);
    VarSys::CreateInteger("coregame.sight.debugscan", FALSE, VarSys::DEFAULT, &debugScan);

    #endif

   
    // The update rate of LOS display   moved to terrain.shroud.rate
//    VarSys::CreateInteger("coregame.sight.updaterate", 2, VarSys::DEFAULT, &displayRate);
//    displayRate->SetIntegerRange(0, 100);

    #ifdef DEVELOPMENT

    sweepTime.Reset();
    unSweepTime.Reset();
    updateDisp.Reset();
    dirtyCellTime.Reset();

    #endif

    // Should all units be visible?
    showAllUnits = FALSE;

    // System is initialised
    sysInit = TRUE;
  }
Example #2
0
_CGUL_EXPORT CGUL::String CGUL::FatalException::GetReason() const
{
    return U8("User defined error.");
}
Example #3
0
//
// ICTicker::DrawSelf
//
// Draw the control
//
void ICTicker::DrawSelf(PaintInfo &pi)
{
  // Draw background
  DrawCtrlBackground(pi, GetTexture());

  // Draw frame
  DrawCtrlFrame(pi);

  // If there is a font then draw the control's text
  if (pi.font)
  {
    // Is there any text to be drawn
    if (currentMessage)
    {
      Color c = pi.colors->fg[ColorIndex()];
      c.a = U8(alpha);

      // Display the text
      pi.font->Draw
      (
        pi.client.p0.x + offsetX, 
        pi.client.p0.y + offsetY, 
        currentMessage->text, 
        currentMessage->length, 
        c,
        &pi.client
      );

      // Calcalate the width of the text
      //int width = pi.font->Width(currentMessage->text, currentMessage->length);
      
      switch (currentMessage->direction)
      {
        /*
        case DIR_LEFT:
          // Pause in the middle
          if (counter && offsetX <= ((pi.client.Width() - width) / 2))
          {
            counter--;
            break;
          }
           
          offsetX -= speed;
          if (offsetX < -width)
          {
            NextMessage();
          }
          break;

        case DIR_RIGHT:
          // Pause in the middle
          if (counter && offsetX >= ((pi.client.Width() - width) / 2))
          {
            counter--;
            break;
          }

          offsetX += speed;
          if (offsetX > pi.client.Width())
          {
            NextMessage();
          }
          break;

        case DIR_UP:
          // Pause in the middle
          if (counter && offsetY <= ((pi.client.Height() - S32(pi.font->Height())) / 2))
          {
            counter--;
            break;
          }

          offsetY -= speed;
          if (offsetY < -pi.font->Height())
          {
            NextMessage();
          }
          break;

        case DIR_DOWN:
          // Pause in the middle
          if (counter && offsetY >= ((pi.client.Height() - S32(pi.font->Height())) / 2))
          {
            counter--;
            break;
          }

          offsetY += speed;
          if (offsetY > pi.client.Height())
          {
            NextMessage();
          }
          break;
      */
        case DIR_ALPHA:
        default:
        {
          // Pause in the middle
          if (counter && alpha >= 255)
          {
            counter--;
            alphaDir = -S32(speed);
            break;
          }

          alpha += alphaDir;
          if (alpha > 255)
          {
            alpha = 255;
          }

          if (alpha <= 0)
          {
            NextMessage();
          }
          break;
        }
      }
    }
  }
}
Example #4
0
static void safer_decrypt
(
	const kripto_block *s,
	const void *ct,
	void *pt
)
{
	uint8_t x0 = CU8(ct)[0];
	uint8_t x1 = CU8(ct)[1];
	uint8_t x2 = CU8(ct)[2];
	uint8_t x3 = CU8(ct)[3];
	uint8_t x4 = CU8(ct)[4];
	uint8_t x5 = CU8(ct)[5];
	uint8_t x6 = CU8(ct)[6];
	uint8_t x7 = CU8(ct)[7];
	uint8_t t;
	unsigned int i = (s->rounds << 4) + 8;

	x7 ^= s->k[--i];
	x6 -= s->k[--i];
	x5 -= s->k[--i];
	x4 ^= s->k[--i];
	x3 ^= s->k[--i];
	x2 -= s->k[--i];
	x1 -= s->k[--i];
	x0 ^= s->k[--i];

	while(i)
	{
		t = x4; x4 = x1; x1 = x2; x2 = t;
		t = x5; x5 = x3; x3 = x6; x6 = t;

		x0 -= x4; x1 -= x5; x2 -= x6; x3 -= x7;
		x4 -= x0; x5 -= x1; x6 -= x2; x7 -= x3;

		x0 -= x2; x4 -= x6; x1 -= x3; x5 -= x7;
		x2 -= x0; x6 -= x4; x3 -= x1; x7 -= x5;

		x0 -= x1; x2 -= x3; x4 -= x5; x6 -= x7;
		x1 -= x0; x3 -= x2; x5 -= x4; x7 -= x6;

		x7 -= s->k[--i];
		x6 ^= s->k[--i];
		x5 ^= s->k[--i];
		x4 -= s->k[--i];
		x3 -= s->k[--i];
		x2 ^= s->k[--i];
		x1 ^= s->k[--i];
		x0 -= s->k[--i];

		x7 = LOG(x7) ^ s->k[--i];
		x6 = EXP(x6) - s->k[--i];
		x5 = EXP(x5) - s->k[--i];
		x4 = LOG(x4) ^ s->k[--i];
		x3 = LOG(x3) ^ s->k[--i];
		x2 = EXP(x2) - s->k[--i];
		x1 = EXP(x1) - s->k[--i];
		x0 = LOG(x0) ^ s->k[--i];
	}

	U8(pt)[0] = x0;
	U8(pt)[1] = x1;
	U8(pt)[2] = x2;
	U8(pt)[3] = x3;
	U8(pt)[4] = x4;
	U8(pt)[5] = x5;
	U8(pt)[6] = x6;
	U8(pt)[7] = x7;
}
Example #5
0
// [RLVa:KB] - Checked: 2009-07-07 (RLVa-1.0.0d) | Modified: RLVa-0.2.2a
void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel)
// [/RLVa:KB]
{
// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0a
	// Only process chat messages (ie not CHAT_TYPE_START, CHAT_TYPE_STOP, etc)
	if ( (rlv_handler_t::isEnabled()) && ( (CHAT_TYPE_WHISPER == type) || (CHAT_TYPE_NORMAL == type) || (CHAT_TYPE_SHOUT == type) ) )
	{
		if (0 == channel)
		{
			// (We already did this before, but LLChatHandler::handle() calls this directly)
			if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATNORMAL)) )
				type = CHAT_TYPE_WHISPER;
			else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATSHOUT)) )
				type = CHAT_TYPE_NORMAL;
			else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) )
				type = CHAT_TYPE_NORMAL;

			// Redirect chat if needed
			if ( ( (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT) || (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE)) ) && 
				 (gRlvHandler.redirectChatOrEmote(utf8_out_text)) ) )
			{
				return;
			}

			// Filter public chat if sendchat restricted
			if (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT))
				gRlvHandler.filterChat(utf8_out_text, true);
		}
		else
		{
			// Don't allow chat on a non-public channel if sendchannel restricted (unless the channel is an exception)
			if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHANNEL)) && (!gRlvHandler.isException(RLV_BHVR_SENDCHANNEL, channel)) )
				return;

			// Don't allow chat on debug channel if @sendchat, @redirchat or @rediremote restricted (shows as public chat on viewers)
			if (CHAT_CHANNEL_DEBUG == channel)
			{
				bool fIsEmote = RlvUtil::isEmote(utf8_out_text);
				if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) || 
					 ((!fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT))) || 
					 ((fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE))) )
				{
					return;
				}
			}
		}
	}
// [/RLVa:KB]

	// Split messages that are too long, same code like in llimpanel.cpp
	U32 split = MAX_MSG_BUF_SIZE - 1;
	U32 pos = 0;
	U32 total = utf8_out_text.length();

    // Don't break null messages
	if (total == 0)
	{
		really_send_chat_from_viewer(utf8_out_text, type, channel);
	}

	while (pos < total)
	{
		U32 next_split = split;

		if (pos + next_split > total)
		{
			next_split = total - pos;
		}
		else
		{
			// don't split utf-8 bytes
			while (U8(utf8_out_text[pos + next_split]) != 0x20	// space
				&& U8(utf8_out_text[pos + next_split]) != 0x21	// !
				&& U8(utf8_out_text[pos + next_split]) != 0x2C	// ,
				&& U8(utf8_out_text[pos + next_split]) != 0x2E	// .
				&& U8(utf8_out_text[pos + next_split]) != 0x3F	// ?
				&& next_split > 0)
			{
				--next_split;
			}

			if (next_split == 0)
			{
				next_split = split;
				LL_WARNS("Splitting") << "utf-8 couldn't be split correctly" << LL_ENDL;
			}
			else
			{
				++next_split;
			}
		}

		std::string send = utf8_out_text.substr(pos, next_split);
		pos += next_split;

		really_send_chat_from_viewer(send, type, channel);
	}
}
void J2716AnalyzerResults::GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base )
{
	ClearResultStrings();
	Frame frame = GetFrame( frame_index );
	U8 u8TempCrc = 0;
	char ai8Data1Str[ 64 ];
	char ai8Data2Str[ 64 ];
	char ai8TicksStr[ 16 ];
	char ai8TimeStr[ 16 ];
	U8 u8Ticks = 0;
	const double kdMicro = 1E-6;
	const double kdRoundError = 1E-19;
	double dFramePeriod = double( 0 );

	dFramePeriod = ( double( frame.mEndingSampleInclusive ) - double( frame.mStartingSampleInclusive ) ) / double( mAnalyzer->GetSampleRate( ) ) + kdRoundError;
	u8Ticks = U8( dFramePeriod / double( mSettings->mBitRate*kdMicro ) );

	AnalyzerHelpers::GetNumberString( frame.mData1 , display_base , 2 , &ai8Data1Str[ 0 ] , sizeof( ai8Data1Str ) );
	AnalyzerHelpers::GetNumberString( u8Ticks , Decimal , 2 , &ai8TicksStr[ 0 ] , sizeof( ai8TicksStr ) );

	switch( frame.mType )
	{
		case SENTSync:
		AnalyzerHelpers::GetTimeString( frame.mEndingSampleInclusive , frame.mStartingSampleInclusive , mAnalyzer->GetSampleRate() , &ai8TimeStr[ 0 ] , 9/* x.xxxxxx + '\0'  */ );
		AddResultString( "SYNC " );
		AddResultString( "SYNC Field ~" , ai8TicksStr , " ticks" );
		AddResultString( "SYNC Field ~" , ai8TicksStr , " ticks [" , ai8TimeStr , " s]" );
		break;
		case SENTStatus:
		AddResultString( "STAT " );
		AddResultString( "STATUS " );
		AddResultString( "STATUS " , ai8Data1Str );
		AddResultString( "STATUS " , ai8Data1Str ," ~" , ai8TicksStr , " ticks" );
		break;
		case SENTData:
		AnalyzerHelpers::GetNumberString( frame.mData2 , Decimal , 8 , &ai8Data2Str[ 0 ] , sizeof( ai8Data2Str ) );
		AddResultString( "DATA " );
		AddResultString( "DATA " , ai8Data2Str );
		AddResultString( "DATA " , ai8Data2Str , " [" , ai8Data1Str , "]" );
		break;
		case SENTCrc:
		//u8TempCrc =mAnalyzer
		if( frame.mData1 == frame.mData2 )
		{
			AddResultString( "CRC " );
			AddResultString( "CRC OK" );
			AddResultString( "CRC OK [" , ai8Data1Str , "]" );
		}
		else
		{
			AnalyzerHelpers::GetNumberString( frame.mData2 , display_base , 2 , &ai8Data2Str[ 0 ] , sizeof( ai8Data2Str ) );
			AddResultString( "CRC! " );
			AddResultString( "CRC! Rx[" , ai8Data1Str , "] Calc{" , ai8Data2Str , "}" );
		}
		break;
		case SENTPause:
		AnalyzerHelpers::GetTimeString( frame.mEndingSampleInclusive , frame.mStartingSampleInclusive , mAnalyzer->GetSampleRate() , &ai8TimeStr[ 0 ] , 9/* x.xxxxxx */ );
		AddResultString( "PAUSE " );
		AddResultString( "PAUSE ~" , ai8TicksStr , " ticks" );
		AddResultString( "PAUSE ~" , ai8TicksStr , " ticks [",ai8TimeStr , " s]" );
		break;
		default:
		//frame.mFlags |= DISPLAY_AS_ERROR_FLAG;
		AnalyzerHelpers::GetNumberString( frame.mData2 , Decimal , 8 , &ai8Data2Str[ 0 ] , sizeof( ai8Data2Str ) );
		AnalyzerHelpers::GetTimeString( frame.mEndingSampleInclusive , frame.mStartingSampleInclusive , mAnalyzer->GetSampleRate() , &ai8TimeStr[ 0 ] , 9/* x.xxxxxx */ );
		AddResultString( "?? " );
		AddResultString( "?? " , ai8TicksStr );
		AddResultString( "?? " , ai8TicksStr , " Ticks @ " , ai8TimeStr , " s" );
		break;
	}
}
void LLImageRaw::compositeRowScaled4onto3( U8* in, U8* out, S32 in_pixel_len, S32 out_pixel_len )
{
	llassert( getComponents() == 3 );

	const S32 IN_COMPONENTS = 4;
	const S32 OUT_COMPONENTS = 3;

	const F32 ratio = F32(in_pixel_len) / out_pixel_len; // ratio of old to new
	const F32 norm_factor = 1.f / ratio;

	for( S32 x = 0; x < out_pixel_len; x++ )
	{
		// Sample input pixels in range from sample0 to sample1.
		// Avoid floating point accumulation error... don't just add ratio each time.  JC
		const F32 sample0 = x * ratio;
		const F32 sample1 = (x+1) * ratio;
		const S32 index0 = S32(sample0);			// left integer (floor)
		const S32 index1 = S32(sample1);			// right integer (floor)
		const F32 fract0 = 1.f - (sample0 - F32(index0));	// spill over on left
		const F32 fract1 = sample1 - F32(index1);			// spill-over on right

		U8 in_scaled_r;
		U8 in_scaled_g;
		U8 in_scaled_b;
		U8 in_scaled_a;

		if( index0 == index1 )
		{
			// Interval is embedded in one input pixel
			S32 t1 = index0 * IN_COMPONENTS;
			in_scaled_r = in[t1 + 0];
			in_scaled_g = in[t1 + 0];
			in_scaled_b = in[t1 + 0];
			in_scaled_a = in[t1 + 0];
		}
		else
		{
			// Left straddle
			S32 t1 = index0 * IN_COMPONENTS;
			F32 r = in[t1 + 0] * fract0;
			F32 g = in[t1 + 1] * fract0;
			F32 b = in[t1 + 2] * fract0;
			F32 a = in[t1 + 3] * fract0;
		
			// Central interval
			for( S32 u = index0 + 1; u < index1; u++ )
			{
				S32 t2 = u * IN_COMPONENTS;
				r += in[t2 + 0];
				g += in[t2 + 1];
				b += in[t2 + 2];
				a += in[t2 + 3];
			}

			// right straddle
			// Watch out for reading off of end of input array.
			if( fract1 && index1 < in_pixel_len )
			{
				S32 t3 = index1 * IN_COMPONENTS;
				r += in[t3 + 0] * fract1;
				g += in[t3 + 1] * fract1;
				b += in[t3 + 2] * fract1;
				a += in[t3 + 3] * fract1;
			}

			r *= norm_factor;
			g *= norm_factor;
			b *= norm_factor;
			a *= norm_factor;

			in_scaled_r = U8(llround(r));
			in_scaled_g = U8(llround(g));
			in_scaled_b = U8(llround(b));
			in_scaled_a = U8(llround(a));
		}

		if( in_scaled_a )
		{
			if( 255 == in_scaled_a )
			{
				out[0] = in_scaled_r;
				out[1] = in_scaled_g;
				out[2] = in_scaled_b;
			}
			else
			{
				U8 transparency = 255 - in_scaled_a;
				out[0] = fastFractionalMult( out[0], transparency ) + fastFractionalMult( in_scaled_r, in_scaled_a );
				out[1] = fastFractionalMult( out[1], transparency ) + fastFractionalMult( in_scaled_g, in_scaled_a );
				out[2] = fastFractionalMult( out[2], transparency ) + fastFractionalMult( in_scaled_b, in_scaled_a );
			}
		}
		out += OUT_COMPONENTS;
	}
}
Example #8
0
void AtlasOldMesher::write(Stream *s, const S8 level, bool doWriteCollision)
{
   AssertISV(mIndices.size(), "AtlasOldMesher::write - no indices to write?!?");

   // First, figure our bounds.
   updateBounds();

   // Then, run the tristripper, get our geometry a bit more optimal.
   ///optimize();

   // We start at the appropriate position in the TOC. It's great!

   // Write min & max y values.  This can be used to reconstruct
   // the bounding box.
   s->write(mMinZ);
   s->write(mMaxZ);

   // Write a placeholder for the mesh data file pos.
   U32 currentPos = s->getPosition();
   s->write(U32(0));

   // write out the vertex data at the *end* of the file.
   s->setPosition(s->getStreamSize());
   U32 meshPos = s->getPosition();

   // Write a sentinel.
   s->write(U32(0xbeef1234));

   // Make sure the vertex buffer is not too big.
   if(mVerts.size() > 0xFFFF)
   {
      AssertISV(false,
         "AtlasOldMesher::write - too many vertices! (> 65535) Try making a deeper tree!");
   }

   // Write vertices.  All verts contain morph info.
   s->write(U16(mVerts.size()));
   for (int i = 0; i < mVerts.size(); i++)
      writeVertex(s, &mVerts[i], level);

   // Write the index buffer.
   s->write(S32(mIndices.size()));
   for(S32 i=0; i<mIndices.size(); i++)
      s->write(mIndices[i]);

   // Write the triangle count.
   s->write(U32(mIndices.size()) / 3);

   gOldChunkGenStats.outputRealTriangles += mIndices.size() / 3;

   // Now, we have to make our collision info...
   if(doWriteCollision)
   {
      s->write(U8(1));
      writeCollision(s);
   }
   else
   {
      s->write(U8(0));
   }

   // write the postscript.
   s->write(U32(0xb1e2e3f4));

   // Rewind, and fill in the mesh data file pos.
   s->setPosition(currentPos);
   s->write(meshPos);

   // Con::printf("    - %d indices, %d verts, meshOffset=%d", mIndices.size(), mVerts.size(), meshPos);
}
//void send_chat_from_viewer(const std::string& utf8_out_text, EChatType type, S32 channel)
// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-0.2.2a
void send_chat_from_viewer(std::string utf8_out_text, EChatType type, S32 channel)
// [/RLVa:KB]
{
// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0b) | Modified: RLVa-1.2.0a
	// Only process chat messages (ie not CHAT_TYPE_START, CHAT_TYPE_STOP, etc)
	if ( (rlv_handler_t::isEnabled()) && ( (CHAT_TYPE_WHISPER == type) || (CHAT_TYPE_NORMAL == type) || (CHAT_TYPE_SHOUT == type) ) )
	{
		if (0 == channel)
		{
			// (We already did this before, but LLChatHandler::handle() calls this directly)
			if ( ((CHAT_TYPE_SHOUT == type) || (CHAT_TYPE_NORMAL == type)) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATNORMAL)) )
				type = CHAT_TYPE_WHISPER;
			else if ( (CHAT_TYPE_SHOUT == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATSHOUT)) )
				type = CHAT_TYPE_NORMAL;
			else if ( (CHAT_TYPE_WHISPER == type) && (gRlvHandler.hasBehaviour(RLV_BHVR_CHATWHISPER)) )
				type = CHAT_TYPE_NORMAL;

			// Redirect chat if needed
			if ( ( (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT) || (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE)) ) && 
				 (gRlvHandler.redirectChatOrEmote(utf8_out_text)) ) )
			{
				return;
			}

			// Filter public chat if sendchat restricted
			if (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT))
				gRlvHandler.filterChat(utf8_out_text, true);
		}
		else
		{
			// Don't allow chat on a non-public channel if sendchannel restricted (unless the channel is an exception)
			if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHANNEL)) && (!gRlvHandler.isException(RLV_BHVR_SENDCHANNEL, channel)) )
				return;

			// Don't allow chat on debug channel if @sendchat, @redirchat or @rediremote restricted (shows as public chat on viewers)
			if (CHAT_CHANNEL_DEBUG == channel)
			{
				bool fIsEmote = RlvUtil::isEmote(utf8_out_text);
				if ( (gRlvHandler.hasBehaviour(RLV_BHVR_SENDCHAT)) || 
					 ((!fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIRCHAT))) || 
					 ((fIsEmote) && (gRlvHandler.hasBehaviour(RLV_BHVR_REDIREMOTE))) )
				{
					return;
				}
			}
		}
	}
// [/RLVa:KB]

//<FS:TS> FIRE-787: break up too long chat lines into multiple messages
	U32 split = MAX_MSG_BUF_SIZE - 1;
	U32 pos = 0;
	U32 total = utf8_out_text.length();

	// Don't break null messages
	if (total == 0)
	{
		really_send_chat_from_viewer(utf8_out_text, type, channel);
	}

	while (pos < total)
	{
		U32 next_split = split;

		if (pos + next_split > total)
		{
			// just send the rest of the message
			next_split = total - pos;
		}
		else
		{
			// first, try to split at a space
			while((U8(utf8_out_text[pos + next_split]) != ' ')
				&& (next_split > 0))
			{
				--next_split;
			}
			
			if (next_split == 0)
			{
				next_split = split;
				// no space found, split somewhere not in the middle of UTF-8
				while((U8(utf8_out_text[pos + next_split]) >= 0x80)
					&& (U8(utf8_out_text[pos + next_split]) < 0xC0)
					&& (next_split > 0))
				{
					--next_split;
				}
			}

			if(next_split == 0)
			{
				next_split = split;
				LL_WARNS("Splitting") <<
					"utf-8 couldn't be split correctly" << LL_ENDL;
			}
		}

		std::string send = utf8_out_text.substr(pos, next_split);
		pos += next_split;

		// *FIXME: Queue messages and wait for server
		really_send_chat_from_viewer(send, type, channel);
	}

	// moved here so we don't bump the count for every message segment
	add(LLStatViewer::CHAT_COUNT,1);
//</FS:TS> FIRE-787
}
Example #10
0
void BemGame::DrawFrame()
{
	AddText( engine );
	int i;

	// The whole demo works because it takes exactly 12 ticks for a 
	// Drone or Brain to walk one tile. So every 12 subticks
	// we calculate a new direction for the actor.
	subtick++;
	tick++;
	teleFrame++;

	if ( subtick == SUBTICK )
	{
		subtick = 0;
		for ( i=0; i<numActors; i++ )
		{
			ProcessMap( &actor[i] );
		}
	}

	// calculate the tinting, from map 4.5,4.5
 	float rad = float( tick ) / 45.0;
 	float fred   = fabs( sin( rad*1.5 ) ) * 0.5;
 	float fgreen = fabs( sin( rad*2.5 ) ) * 0.5;
 	float fblue  = fabs( sin( rad*3.5 ) ) * 0.5;
 	float falpha = fabs( sin( rad ) ) * 0.3;
	
	KrColorTransform gizmoColor;
	gizmoColor.TintRed(   U8( fred * 255.0 ));
	gizmoColor.TintGreen( U8( fgreen * 255.0 ));
	gizmoColor.TintBlue(  U8( fblue * 255.0 ));
	gizmoColor.TintAlpha( U8( falpha * 255.0 ));
	gizmo->SetColor( gizmoColor );

	// update all the actors.
	for( i=0; i<numActors; i++ )
	{
		KrColorTransform actorColor;
		float d = DistanceFromCenter( &actor[i] );
		if ( d < 3.0 )
		{
			float fraction = 1.0 - d / 3.0;
			actorColor.TintRed(   U8( fred * 255.0 * fraction ));
			actorColor.TintGreen( U8( fgreen * 255.0 * fraction ));
			actorColor.TintBlue(  U8( fblue * 255.0 * fraction ));
			actorColor.TintAlpha( U8( falpha * 255.0 * fraction ));
		}
		actor[i].sprite->SetColor( actorColor );

		actor[i].sprite->DoStep();

		// In order to sort with the particles, sort with
		// the world Y.
		GlFixed wx, wy, wz, tx, ty;

		isoMath->ScreenToFlatTile(	actor[i].sprite->X(), 
									actor[i].sprite->Y(),
									0, &tx, &ty );
		isoMath->TileToWorld( tx, ty, 0, &wx, &wy, &wz );
		actor[i].sprite->SetZDepth( -wy.v );
	}

	// The teleport in and out special effect. Done "by hand"
	// counting frames with a switch. Looks cool and tests
	// the visibility stuff.
	if ( teleFrame > 9 && numActors > 0 )
	{
		KrColorTransform cform;

		switch ( teleFrame )
		{
			case 10:
				teleSprite = actor[ random.Rand( numActors ) ].sprite;
				cform.Brighten( 128 );
				break;

			case 11:
				cform.Brighten( 200 );
				cform.SetAlpha( 220 );
				break;

			case 12:
			case 13:
				cform.Brighten( 255 );
				cform.SetAlpha( 200 );
				break;

			case 14:
				{
					GlFixed x, y;
					isoMath->ScreenToFlatTile(	teleSprite->X(),
												teleSprite->Y(),
												0, &x, &y );
					AddParticles( x, y );
					teleSprite->SetVisible( false );
				}
				break;

			case 35:
			case 36:
			case 37:
			case 38:
			case 39:
			case 40:
				teleSprite->SetVisible( true );
				cform.TintBlue( 240 - 30 * ( teleFrame - 35 ) );
				cform.SetAlpha( 100 + 20 * ( teleFrame - 35 ) );
				break;
				
			case 41:
				teleFrame = 0;
				break;

			default:
				break;
		}
		teleSprite->SetColor( cform );
	}

	MoveParticles();

	// Since the map coordinates only change if the subtick rolled
	// over, we only change the mini map every 12 frames.
	if ( subtick == 0 )
		DrawMiniMap();

	if ( UseWindows() )
		ProcessRightWindow();

	engine->Draw();
}
void ImportTracker::get_update(S32 newid, BOOL justCreated, BOOL createSelected)
{
	switch (state)
	{
		//lgg crap
		case WAND:
			if(justCreated && createSelected)
			{
				numberExpected--;
				if(numberExpected<=0)
					state=IDLE;
				LLMessageSystem* msg = gMessageSystem;
				msg->newMessageFast(_PREHASH_ObjectImage);
				msg->nextBlockFast(_PREHASH_AgentData);
				msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
				msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());	
				msg->nextBlockFast(_PREHASH_ObjectData);				
				msg->addU32Fast(_PREHASH_ObjectLocalID,  (U32)newid);
				msg->addStringFast(_PREHASH_MediaURL, NULL);
	
				LLPrimitive obj;
				obj.setNumTEs(U8(10));	
				S32 shinnyLevel = 0;
				static std::string* shinystr = rebind_llcontrol<std::string>("EmeraldBuildPrefs_Shiny", &gSavedSettings, true);
				if(*shinystr == "None") shinnyLevel = 0;
				if(*shinystr == "Low") shinnyLevel = 1;
				if(*shinystr == "Medium") shinnyLevel = 2;
				if(*shinystr == "High") shinnyLevel = 3;
				
				for (int i = 0; i < 10; i++)
				{
					static std::string* buildpreftex = rebind_llcontrol<std::string>("EmeraldBuildPrefs_Texture", &gSavedSettings, true);

					LLTextureEntry tex =  LLTextureEntry(LLUUID(*buildpreftex));
					tex.setColor(gSavedSettings.getColor4("EmeraldBuildPrefs_Color"));
					tex.setAlpha(1.0 - ((gSavedSettings.getF32("EmeraldBuildPrefs_Alpha")) / 100.0));
					tex.setGlow(gSavedSettings.getF32("EmeraldBuildPrefs_Glow"));
					if(gSavedSettings.getBOOL("EmeraldBuildPrefs_FullBright"))
					{
						tex.setFullbright(TEM_FULLBRIGHT_MASK);
					}
									
					tex.setShiny((U8) shinnyLevel & TEM_SHINY_MASK);
					
					obj.setTE(U8(i), tex);
				}
	
				obj.packTEMessage(gMessageSystem);
	
				msg->sendReliable(gAgent.getRegion()->getHost());
				
				msg->newMessage("ObjectFlagUpdate");
				msg->nextBlockFast(_PREHASH_AgentData);
				msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
				msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
				msg->addU32Fast(_PREHASH_ObjectLocalID, (U32)newid );
				msg->addBOOLFast(_PREHASH_UsePhysics, gSavedSettings.getBOOL("EmeraldBuildPrefs_Physical"));
				msg->addBOOL("IsTemporary", gSavedSettings.getBOOL("EmeraldBuildPrefs_Temporary"));
				msg->addBOOL("IsPhantom", gSavedSettings.getBOOL("EmeraldBuildPrefs_Phantom") );
				msg->addBOOL("CastsShadows", true );
				msg->sendReliable(gAgent.getRegion()->getHost());

				if(gSavedSettings.getBOOL("EmeraldBuildPrefs_EmbedItem"))
				{
					LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem((LLUUID)gSavedSettings.getString("EmeraldBuildPrefs_Item"));
					LLViewerObject* objectp = find((U32)newid);
					if(objectp)
						if(item)
						{
							if(item->getType()==LLAssetType::AT_LSL_TEXT)
							{
								LLToolDragAndDrop::dropScript(objectp,
									item,
									TRUE,
									LLToolDragAndDrop::SOURCE_AGENT,
									gAgent.getID());
							}else
							{
								LLToolDragAndDrop::dropInventory(objectp,item,LLToolDragAndDrop::SOURCE_AGENT,gAgent.getID());
							}
						}
				}
				
				//llinfos << "LGG SENDING CUBE TEXTURE.." << llendl;
			}
		break;
		case BUILDING:
			
			if (justCreated && (int)localids.size() < linkset.size())
			{
				localids.push_back(newid);
				localids.sort();
				localids.unique();

				linkset[localids.size() -1]["LocalID"] = newid;
				LLSD prim = linkset[localids.size() -1];

				//MAKERIGHT
				if (!(prim).has("Updated"))
				{
					++updated;
					send_shape(prim);
					send_image(prim);
					send_extras(prim);
					send_namedesc(prim);
					send_vectors(prim,updated);
					send_properties(prim, updated);
					send_inventory(prim);
					(prim)["Updated"] = true;
				}
				if ((int)localids.size() < linkset.size())
				{
					plywood_above_head();
					return;
				}
				else
				{
					if (updated >= linkset.size())
					{
						updated=0;
						llinfos << "FINISHED BUILDING, LINKING.." << llendl;
						state = LINKING;
						link();
					}
				}
			}
		break;
		case LINKING:
			link();
		break;
	}
}
Example #12
0
BOOL LLFace::getGeometryVolume(const LLVolume& volume,
							   const S32 &f,
								const LLMatrix4& mat_vert_in, const LLMatrix3& mat_norm_in,
								const U16 &index_offset,
								bool force_rebuild)
{
	llassert(verify());
	const LLVolumeFace &vf = volume.getVolumeFace(f);
	S32 num_vertices = (S32)vf.mNumVertices;
	S32 num_indices = (S32) vf.mNumIndices;
	
	if (mVertexBuffer.notNull())
	{
		if (num_indices + (S32) mIndicesIndex > mVertexBuffer->getNumIndices())
		{
			llwarns	<< "Index buffer overflow!" << llendl;
			llwarns << "Indices Count: " << mIndicesCount
					<< " VF Num Indices: " << num_indices
					<< " Indices Index: " << mIndicesIndex
					<< " VB Num Indices: " << mVertexBuffer->getNumIndices() << llendl;
			llwarns	<< "Last Indices Count: " << mLastIndicesCount
					<< " Last Indices Index: " << mLastIndicesIndex
					<< " Face Index: " << f
					<< " Pool Type: " << mPoolType << llendl;
			return FALSE;
		}

		if (num_vertices + mGeomIndex > mVertexBuffer->getNumVerts())
		{
			llwarns << "Vertex buffer overflow!" << llendl;
			return FALSE;
		}
	}

	LLStrider<LLVector3> vertices;
	LLStrider<LLVector2> tex_coords;
	LLStrider<LLVector2> tex_coords2;
	LLStrider<LLVector3> normals;
	LLStrider<LLColor4U> colors;
	LLStrider<LLVector3> binormals;
	LLStrider<U16> indicesp;
#if MESH_ENABLED
	LLStrider<LLVector4> weights;
#endif //MESH_ENABLED

	BOOL full_rebuild = force_rebuild || mDrawablep->isState(LLDrawable::REBUILD_VOLUME);
	
	BOOL global_volume = mDrawablep->getVOVolume()->isVolumeGlobal();
	LLVector3 scale;
	if (global_volume)
	{
		scale.setVec(1,1,1);
	}
	else
	{
		scale = mVObjp->getScale();
	}
	
	bool rebuild_pos = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_POSITION);
	bool rebuild_color = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_COLOR);
	bool rebuild_tcoord = full_rebuild || mDrawablep->isState(LLDrawable::REBUILD_TCOORD);
	bool rebuild_normal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);
	bool rebuild_binormal = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_BINORMAL);
#if MESH_ENABLED
	bool rebuild_weights = rebuild_pos && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_WEIGHT4);
#endif //MESH_ENABLED

	const LLTextureEntry *tep = mVObjp->getTE(f);
	if (!tep) rebuild_color = FALSE;	// can't get color when tep is NULL
	U8  bump_code = tep ? tep->getBumpmap() : 0;


	
	BOOL is_static = mDrawablep->isStatic();
	BOOL is_global = is_static;

	LLVector3 center_sum(0.f, 0.f, 0.f);
	
	if (is_global)
	{
		setState(GLOBAL);
	}
	else
	{
		clearState(GLOBAL);
	}

	LLColor4U color = (tep ? LLColor4U(tep->getColor()) : LLColor4U::white);

	if (rebuild_color)	// FALSE if tep == NULL
	{
		if (tep)
		{
			GLfloat alpha[4] =
			{
				0.00f,
				0.25f,
				0.5f,
				0.75f
			};
			
			if (getPoolType() != LLDrawPool::POOL_ALPHA && (LLPipeline::sRenderDeferred || (LLPipeline::sRenderBump && tep->getShiny())))
			{
				color.mV[3] = U8 (alpha[tep->getShiny()] * 255);
			}
		}
	}

    // INDICES
	if (full_rebuild)
	{
		mVertexBuffer->getIndexStrider(indicesp, mIndicesIndex);
		for (U32 i = 0; i < (U32) num_indices; i++)
		{
			indicesp[i] = vf.mIndices[i] + index_offset;
		}

		//mVertexBuffer->setBuffer(0);
	}
	
	LLMatrix4a mat_normal;
	mat_normal.loadu(mat_norm_in);
	
	//if it's not fullbright and has no normals, bake sunlight based on face normal
	//bool bake_sunlight = !getTextureEntry()->getFullbright() &&
	//  !mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL);

	F32 r = 0, os = 0, ot = 0, ms = 0, mt = 0, cos_ang = 0, sin_ang = 0;

	if (rebuild_tcoord)
	{
		bool do_xform;
			
		if (tep)
		{
			r  = tep->getRotation();
			os = tep->mOffsetS;
			ot = tep->mOffsetT;
			ms = tep->mScaleS;
			mt = tep->mScaleT;
			cos_ang = cos(r);
			sin_ang = sin(r);

			if (cos_ang != 1.f || 
				sin_ang != 0.f ||
				os != 0.f ||
				ot != 0.f ||
				ms != 1.f ||
				mt != 1.f)
			{
				do_xform = true;
			}
			else
			{
				do_xform = false;
			}	
		}
		else
		{
			do_xform = false;
		}
						
		//bump setup
		LLVector4a binormal_dir( -sin_ang, cos_ang, 0.f );
		LLVector4a bump_s_primary_light_ray(0.f, 0.f, 0.f);
		LLVector4a bump_t_primary_light_ray(0.f, 0.f, 0.f);

		LLQuaternion bump_quat;
		if (mDrawablep->isActive())
		{
			bump_quat = LLQuaternion(mDrawablep->getRenderMatrix());
		}
		
		if (bump_code)
		{
			mVObjp->getVolume()->genBinormals(f);
			F32 offset_multiple; 
			switch( bump_code )
			{
				case BE_NO_BUMP:
				offset_multiple = 0.f;
				break;
				case BE_BRIGHTNESS:
				case BE_DARKNESS:
				if( mTexture.notNull() && mTexture->hasGLTexture())
				{
					// Offset by approximately one texel
					S32 cur_discard = mTexture->getDiscardLevel();
					S32 max_size = llmax( mTexture->getWidth(), mTexture->getHeight() );
					max_size <<= cur_discard;
					const F32 ARTIFICIAL_OFFSET = 2.f;
					offset_multiple = ARTIFICIAL_OFFSET / (F32)max_size;
				}
				else
				{
					offset_multiple = 1.f/256;
				}
				break;

				default:  // Standard bumpmap textures.  Assumed to be 256x256
				offset_multiple = 1.f / 256;
				break;
			}

			F32 s_scale = 1.f;
			F32 t_scale = 1.f;
			if( tep )
			{
				tep->getScale( &s_scale, &t_scale );
			}
			// Use the nudged south when coming from above sun angle, such
			// that emboss mapping always shows up on the upward faces of cubes when 
			// it's noon (since a lot of builders build with the sun forced to noon).
			LLVector3   sun_ray  = gSky.mVOSkyp->mBumpSunDir;
			LLVector3   moon_ray = gSky.getMoonDirection();
			LLVector3& primary_light_ray = (sun_ray.mV[VZ] > 0) ? sun_ray : moon_ray;

			bump_s_primary_light_ray.load3((offset_multiple * s_scale * primary_light_ray).mV);
			bump_t_primary_light_ray.load3((offset_multiple * t_scale * primary_light_ray).mV);
		}

		U8 texgen = getTextureEntry()->getTexGen();
		if (rebuild_tcoord && texgen != LLTextureEntry::TEX_GEN_DEFAULT)
		{ //planar texgen needs binormals
			mVObjp->getVolume()->genBinormals(f);
		}

		U8 tex_mode = 0;
	
		if (isState(TEXTURE_ANIM))
		{
			LLVOVolume* vobj = (LLVOVolume*) (LLViewerObject*) mVObjp;	
			tex_mode = vobj->mTexAnimMode;

			if (!tex_mode)
			{
				clearState(TEXTURE_ANIM);
			}
			else
			{
				os = ot = 0.f;
				r = 0.f;
				cos_ang = 1.f;
				sin_ang = 0.f;
				ms = mt = 1.f;

				do_xform = false;
			}

			if (getVirtualSize() >= MIN_TEX_ANIM_SIZE)
			{ //don't override texture transform during tc bake
				tex_mode = 0;
			}
		}
	
		LLVector4a scalea;
		scalea.load3(scale.mV);

		bool do_bump = bump_code && mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_TEXCOORD1);
		bool do_tex_mat = tex_mode && mTextureMatrix;

		if (!do_bump)
		{ //not in atlas or not bump mapped, might be able to do a cheap update
			mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex);

			if (texgen != LLTextureEntry::TEX_GEN_PLANAR)
			{
				if (!do_tex_mat)
				{
					if (!do_xform)
					{
						tex_coords.assignArray((U8*) vf.mTexCoords, sizeof(vf.mTexCoords[0]), num_vertices);
					}
					else
					{
						for (S32 i = 0; i < num_vertices; i++)
						{	
							LLVector2 tc(vf.mTexCoords[i]);
							xform(tc, cos_ang, sin_ang, os, ot, ms, mt);
							*tex_coords++ = tc;	
						}
					}
				}
				else
				{ //do tex mat, no texgen, no atlas, no bump
					for (S32 i = 0; i < num_vertices; i++)
					{	
						LLVector2 tc(vf.mTexCoords[i]);
						//LLVector4a& norm = vf.mNormals[i];
						//LLVector4a& center = *(vf.mCenter);

						LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
						tmp = tmp * *mTextureMatrix;
						tc.mV[0] = tmp.mV[0];
						tc.mV[1] = tmp.mV[1];
						*tex_coords++ = tc;	
					}
				}
			}
			else
			{ //no bump, no atlas, tex gen planar
				if (do_tex_mat)
				{
					for (S32 i = 0; i < num_vertices; i++)
					{	
						LLVector2 tc(vf.mTexCoords[i]);
						LLVector4a& norm = vf.mNormals[i];
						LLVector4a& center = *(vf.mCenter);
						LLVector4a vec = vf.mPositions[i];	
						vec.mul(scalea);
						planarProjection(tc, norm, center, vec);
						
						LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
						tmp = tmp * *mTextureMatrix;
						tc.mV[0] = tmp.mV[0];
						tc.mV[1] = tmp.mV[1];
				
						*tex_coords++ = tc;	
					}
				}
				else
				{
					for (S32 i = 0; i < num_vertices; i++)
					{	
						LLVector2 tc(vf.mTexCoords[i]);
						LLVector4a& norm = vf.mNormals[i];
						LLVector4a& center = *(vf.mCenter);
						LLVector4a vec = vf.mPositions[i];	
						vec.mul(scalea);
						planarProjection(tc, norm, center, vec);
						
						xform(tc, cos_ang, sin_ang, os, ot, ms, mt);

						*tex_coords++ = tc;	
					}
				}
			}

			//mVertexBuffer->setBuffer(0);
		}
		else
		{ //either bump mapped or in atlas, just do the whole expensive loop
			mVertexBuffer->getTexCoord0Strider(tex_coords, mGeomIndex);

			std::vector<LLVector2> bump_tc;
		
			for (S32 i = 0; i < num_vertices; i++)
			{	
				LLVector2 tc(vf.mTexCoords[i]);
			
				LLVector4a& norm = vf.mNormals[i];
				
				LLVector4a& center = *(vf.mCenter);
		   
				if (texgen != LLTextureEntry::TEX_GEN_DEFAULT)
				{
					LLVector4a vec = vf.mPositions[i];
				
					vec.mul(scalea);

					switch (texgen)
					{
						case LLTextureEntry::TEX_GEN_PLANAR:
							planarProjection(tc, norm, center, vec);
							break;
						case LLTextureEntry::TEX_GEN_SPHERICAL:
							sphericalProjection(tc, norm, center, vec);
							break;
						case LLTextureEntry::TEX_GEN_CYLINDRICAL:
							cylindricalProjection(tc, norm, center, vec);
							break;
						default:
							break;
					}		
				}

				if (tex_mode && mTextureMatrix)
				{
					LLVector3 tmp(tc.mV[0], tc.mV[1], 0.f);
					tmp = tmp * *mTextureMatrix;
					tc.mV[0] = tmp.mV[0];
					tc.mV[1] = tmp.mV[1];
				}
				else
				{
					xform(tc, cos_ang, sin_ang, os, ot, ms, mt);
				}


				*tex_coords++ = tc;
				if (do_bump)
				{
					bump_tc.push_back(tc);
				}
			}

			//mVertexBuffer->setBuffer(0);


			if (do_bump)
			{
				mVertexBuffer->getTexCoord1Strider(tex_coords2, mGeomIndex);
		
				for (S32 i = 0; i < num_vertices; i++)
				{
					LLVector4a tangent;
					tangent.setCross3(vf.mBinormals[i], vf.mNormals[i]);

					LLMatrix4a tangent_to_object;
					tangent_to_object.setRows(tangent, vf.mBinormals[i], vf.mNormals[i]);
					LLVector4a t;
					tangent_to_object.rotate(binormal_dir, t);
					LLVector4a binormal;
					mat_normal.rotate(t, binormal);
						
					//VECTORIZE THIS
					if (mDrawablep->isActive())
					{
						LLVector3 t;
						t.set(binormal.getF32ptr());
						t *= bump_quat;
						binormal.load3(t.mV);
					}

					binormal.normalize3fast();
					LLVector2 tc = bump_tc[i];
					tc += LLVector2( bump_s_primary_light_ray.dot3(tangent).getF32(), bump_t_primary_light_ray.dot3(binormal).getF32() );
					
					*tex_coords2++ = tc;
				}

				//mVertexBuffer->setBuffer(0);
			}
		}
	}

	if (rebuild_pos)
	{
		llassert(num_vertices > 0);
		mVertexBuffer->getVertexStrider(vertices, mGeomIndex);
		LLMatrix4a mat_vert;
		mat_vert.loadu(mat_vert_in);
		
		LLVector4a* src = vf.mPositions;
		LLVector4a position;
		for (S32 i = 0; i < num_vertices; i++)
		{
			mat_vert.affineTransform(src[i], position);
			vertices[i].set(position.getF32ptr());
		}
			
			
		//mVertexBuffer->setBuffer(0);
	}
		
	if (rebuild_normal)
	{
		mVertexBuffer->getNormalStrider(normals, mGeomIndex);
		for (S32 i = 0; i < num_vertices; i++)
		{	
			LLVector4a normal;
			mat_normal.rotate(vf.mNormals[i], normal);
			normal.normalize3fast();
			normals[i].set(normal.getF32ptr());
		}

		//mVertexBuffer->setBuffer(0);
	}
		
	if (rebuild_binormal)
	{
		mVertexBuffer->getBinormalStrider(binormals, mGeomIndex);
		for (S32 i = 0; i < num_vertices; i++)
		{	
			LLVector4a binormal;
			mat_normal.rotate(vf.mBinormals[i], binormal);
			binormal.normalize3fast();
			binormals[i].set(binormal.getF32ptr());
		}

		//mVertexBuffer->setBuffer(0);
	}
	
#if MESH_ENABLED
	if (rebuild_weights && vf.mWeights)
	{
		mVertexBuffer->getWeight4Strider(weights, mGeomIndex);
		weights.assignArray((U8*) vf.mWeights, sizeof(vf.mWeights[0]), num_vertices);
		//mVertexBuffer->setBuffer(0);
	}
#endif //MESH_ENABLED

	if (rebuild_color)
	{
		mVertexBuffer->getColorStrider(colors, mGeomIndex);
		for (S32 i = 0; i < num_vertices; i++)
		{
			colors[i] = color;	
		}

		//mVertexBuffer->setBuffer(0);
	}

	if (rebuild_tcoord)
	{
		mTexExtents[0].setVec(0,0);
		mTexExtents[1].setVec(1,1);
		xform(mTexExtents[0], cos_ang, sin_ang, os, ot, ms, mt);
		xform(mTexExtents[1], cos_ang, sin_ang, os, ot, ms, mt);
		
		F32 es = vf.mTexCoordExtents[1].mV[0] - vf.mTexCoordExtents[0].mV[0] ;
		F32 et = vf.mTexCoordExtents[1].mV[1] - vf.mTexCoordExtents[0].mV[1] ;
		mTexExtents[0][0] *= es ;
		mTexExtents[1][0] *= es ;
		mTexExtents[0][1] *= et ;
		mTexExtents[1][1] *= et ;
	}

	mLastVertexBuffer = mVertexBuffer;
	mLastGeomCount = mGeomCount;
	mLastGeomIndex = mGeomIndex;
	mLastIndicesCount = mIndicesCount;
	mLastIndicesIndex = mIndicesIndex;

	return TRUE;
}
Example #13
0
// Singu Note: LLFloaterIMSession::sendMsg
void LLFloaterIMPanel::onSendMsg()
{
	if (!gAgent.isGodlike() 
		&& (mSessionType == P2P_SESSION)
		&& mOtherParticipantUUID.isNull())
	{
		llinfos << "Cannot send IM to everyone unless you're a god." << llendl;
		return;
	}

	if (mInputEditor)
	{
		LLWString text = mInputEditor->getConvertedText();
		if(!text.empty())
		{
			// store sent line in history, duplicates will get filtered
			if (mInputEditor) mInputEditor->updateHistory();
			// Truncate and convert to UTF8 for transport
			std::string utf8_text = wstring_to_utf8str(text);
			bool action = convert_roleplay_text(utf8_text);
			if (!action && mRPMode)
				utf8_text = "((" + utf8_text + "))";

// [RLVa:KB] - Checked: 2010-11-30 (RLVa-1.3.0)
			if ( (RlvActions::hasBehaviour(RLV_BHVR_SENDIM)) || (RlvActions::hasBehaviour(RLV_BHVR_SENDIMTO)) )
			{
				bool fRlvFilter = false;
				switch (mSessionType)
				{
					case P2P_SESSION:	// One-on-one IM
						fRlvFilter = !RlvActions::canSendIM(mOtherParticipantUUID);
						break;
					case GROUP_SESSION:	// Group chat
						fRlvFilter = !RlvActions::canSendIM(mSessionUUID);
						break;
					case ADHOC_SESSION:	// Conference chat: allow if all participants can be sent an IM
						{
							if (!mSpeakers)
							{
								fRlvFilter = true;
								break;
							}

							LLSpeakerMgr::speaker_list_t speakers;
							mSpeakers->getSpeakerList(&speakers, TRUE);
							for (LLSpeakerMgr::speaker_list_t::const_iterator itSpeaker = speakers.begin(); 
									itSpeaker != speakers.end(); ++itSpeaker)
							{
								const LLSpeaker* pSpeaker = *itSpeaker;
								if ( (gAgentID != pSpeaker->mID) && (!RlvActions::canSendIM(pSpeaker->mID)) )
								{
									fRlvFilter = true;
									break;
								}
							}
						}
						break;
					default:
						fRlvFilter = true;
						break;
				}

				if (fRlvFilter)
				{
					utf8_text = RlvStrings::getString(RLV_STRING_BLOCKED_SENDIM);
				}
			}
// [/RLVa:KB]

			if ( mSessionInitialized )
			{
				// Split messages that are too long, same code like in llimpanel.cpp
				U32 split = MAX_MSG_BUF_SIZE - 1;
				U32 pos = 0;
				U32 total = utf8_text.length();

				while (pos < total)
				{
					U32 next_split = split;

					if (pos + next_split > total)
					{
						next_split = total - pos;
					}
					else
					{
						// don't split utf-8 bytes
						while (U8(utf8_text[pos + next_split]) != 0x20	// space
							&& U8(utf8_text[pos + next_split]) != 0x21	// !
							&& U8(utf8_text[pos + next_split]) != 0x2C	// ,
							&& U8(utf8_text[pos + next_split]) != 0x2E	// .
							&& U8(utf8_text[pos + next_split]) != 0x3F	// ?
							&& next_split > 0)
						{
							--next_split;
						}

						if (next_split == 0)
						{
							next_split = split;
							LL_WARNS("Splitting") << "utf-8 couldn't be split correctly" << LL_ENDL;
						}
						else
						{
							++next_split;
						}
					}

					std::string send = utf8_text.substr(pos, next_split);
					pos += next_split;
					LL_DEBUGS("Splitting") << "Pos: " << pos << " next_split: " << next_split << LL_ENDL;

					deliver_message(send,
									mSessionUUID,
									mOtherParticipantUUID,
									mDialog);
				}

				// local echo
				if((mSessionType == P2P_SESSION) &&
				   (mOtherParticipantUUID.notNull()))
				{
					std::string name;
					gAgent.buildFullname(name);

					// Look for actions here.
					if (action)
					{
						utf8_text.replace(0,3,"");
					}
					else
					{
						utf8_text.insert(0, ": ");
					}

					bool other_was_typing = mOtherTyping;
					addHistoryLine(utf8_text, gSavedSettings.getColor("UserChatColor"), true, gAgentID, name);
					if (other_was_typing) addTypingIndicator(mOtherTypingName);
				}
			}
			else
			{
				//queue up the message to send once the session is
				//initialized
				mQueuedMsgsForInit.append(utf8_text);
			}
		}

		LLViewerStats::getInstance()->incStat(LLViewerStats::ST_IM_COUNT);

		mInputEditor->setText(LLStringUtil::null);
	}

	// Don't need to actually send the typing stop message, the other
	// client will infer it from receiving the message.
	mTyping = false;
	mSentTypingState = true;
}
Example #14
0
_CGUL_EXPORT CGUL::String CGUL::SystemCode::GetInfo() const
{
    if (type == TYPE_NONE)
    {
        return U8("None");
    }

    CGUL::String info;
    switch (type)
    {
        case TYPE_WINAPI:
            info += U8("WinAPI");
            break;
        case TYPE_ERRNO:
            info += U8("Errno");
            break;
        case TYPE_NETWORK:
            info += U8("Network");
            break;
        case TYPE_SSL:
            info += U8("SSL");
            break;
        case TYPE_ADDR_INFO:
            info += U8("Address Info");
            break;
    }
    info += U8(" Error ") + String::From(code);

    CGUL::String reason;

    if (type == TYPE_WINAPI)
    {
#       ifdef CGUL_WINDOWS
#       endif
    }

    if (type == TYPE_NETWORK || type == TYPE_ERRNO)
    {
#       ifdef CGUL_LINUX
        static struct { int value; const char* str; } errnoList[] =
        {
            { E2BIG,           "E2BIG" },
            { EACCES,          "EACCES" },
            { EADDRINUSE,      "EADDRINUSE" },
            { EADDRNOTAVAIL,   "EADDRNOTAVAIL" },
            { EAFNOSUPPORT,    "EAFNOSUPPORT" },
            { EAGAIN,          "EAGAIN" },
            { EALREADY,        "EALREADY" },
            { EBADE,           "EBADE" },
            { EBADF,           "EBADF" },
            { EBADFD,          "EBADFD" },
            { EBADMSG,         "EBADMSG" },
            { EBADR,           "EBADR" },
            { EBADRQC,         "EBADRQC" },
            { EBADSLT,         "EBADSLT" },
            { EBUSY,           "EBUSY" },
            { ECANCELED,       "ECANCELED" },
            { ECHILD,          "ECHILD" },
            { ECHRNG,          "ECHRNG" },
            { ECOMM,           "ECOMM" },
            { ECONNABORTED,    "ECONNABORTED" },
            { ECONNREFUSED,    "ECONNREFUSED" },
            { ECONNRESET,      "ECONNRESET" },
            { EDEADLK,         "EDEADLK" },
            { EDEADLOCK,       "EDEADLOCK" },
            { EDESTADDRREQ,    "EDESTADDRREQ" },
            { EDOM,            "EDOM" },
            { EDQUOT,          "EDQUOT" },
            { EEXIST,          "EEXIST" },
            { EFAULT,          "EFAULT" },
            { EFBIG,           "EFBIG" },
            { EHOSTDOWN,       "EHOSTDOWN" },
            { EHOSTUNREACH,    "EHOSTUNREACH" },
            { EIDRM,           "EIDRM" },
            { EILSEQ,          "EILSEQ" },
            { EINPROGRESS,     "EINPROGRESS" },
            { EINTR,           "EINTR" },
            { EINVAL,          "EINVAL" },
            { EIO,             "EIO" },
            { EISCONN,         "EISCONN" },
            { EISDIR,          "EISDIR" },
            { EISNAM,          "EISNAM" },
            { EKEYEXPIRED,     "EKEYEXPIRED" },
            { EKEYREJECTED,    "EKEYREJECTED" },
            { EKEYREVOKED,     "EKEYREVOKED" },
            { EL2HLT,          "EL2HLT" },
            { EL2NSYNC,        "EL2NSYNC" },
            { EL3HLT,          "EL3HLT" },
            { EL3RST,          "EL3RST" },
            { ELIBACC,         "ELIBACC" },
            { ELIBBAD,         "ELIBBAD" },
            { ELIBMAX,         "ELIBMAX" },
            { ELIBSCN,         "ELIBSCN" },
            { ELIBEXEC,        "ELIBEXEC" },
            { ELOOP,           "ELOOP" },
            { EMEDIUMTYPE,     "EMEDIUMTYPE" },
            { EMFILE,          "EMFILE" },
            { EMLINK,          "EMLINK" },
            { EMSGSIZE,        "EMSGSIZE" },
            { EMULTIHOP,       "EMULTIHOP" },
            { ENAMETOOLONG,    "ENAMETOOLONG" },
            { ENETDOWN,        "ENETDOWN" },
            { ENETRESET,       "ENETRESET" },
            { ENETUNREACH,     "ENETUNREACH" },
            { ENFILE,          "ENFILE" },
            { ENOBUFS,         "ENOBUFS" },
            { ENODATA,         "ENODATA" },
            { ENODEV,          "ENODEV" },
            { ENOENT,          "ENOENT" },
            { ENOEXEC,         "ENOEXEC" },
            { ENOKEY,          "ENOKEY" },
            { ENOLCK,          "ENOLCK" },
            { ENOLINK,         "ENOLINK" },
            { ENOMEDIUM,       "ENOMEDIUM" },
            { ENOMEM,          "ENOMEM" },
            { ENOMSG,          "ENOMSG" },
            { ENONET,          "ENONET" },
            { ENOPKG,          "ENOPKG" },
            { ENOPROTOOPT,     "ENOPROTOOPT" },
            { ENOSPC,          "ENOSPC" },
            { ENOSR,           "ENOSR" },
            { ENOSTR,          "ENOSTR" },
            { ENOSYS,          "ENOSYS" },
            { ENOTBLK,         "ENOTBLK" },
            { ENOTCONN,        "ENOTCONN" },
            { ENOTDIR,         "ENOTDIR" },
            { ENOTEMPTY,       "ENOTEMPTY" },
            { ENOTSOCK,        "ENOTSOCK" },
            { ENOTSUP,         "ENOTSUP" },
            { ENOTTY,          "ENOTTY" },
            { ENOTUNIQ,        "ENOTUNIQ" },
            { ENXIO,           "ENXIO" },
            { EOPNOTSUPP,      "EOPNOTSUPP" },
            { EOVERFLOW,       "EOVERFLOW" },
            { EPERM,           "EPERM" },
            { EPFNOSUPPORT,    "EPFNOSUPPORT" },
            { EPIPE,           "EPIPE" },
            { EPROTO,          "EPROTO" },
            { EPROTONOSUPPORT, "EPROTONOSUPPORT" },
            { EPROTOTYPE,      "EPROTOTYPE" },
            { ERANGE,          "ERANGE" },
            { EREMCHG,         "EREMCHG" },
            { EREMOTE,         "EREMOTE" },
            { EREMOTEIO,       "EREMOTEIO" },
            { ERESTART,        "ERESTART" },
            { EROFS,           "EROFS" },
            { ESHUTDOWN,       "ESHUTDOWN" },
            { ESPIPE,          "ESPIPE" },
            { ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT" },
            { ESRCH,           "ESRCH" },
            { ESTALE,          "ESTALE" },
            { ESTRPIPE,        "ESTRPIPE" },
            { ETIME,           "ETIME" },
            { ETIMEDOUT,       "ETIMEDOUT" },
            { ETXTBSY,         "ETXTBSY" },
            { EUCLEAN,         "EUCLEAN" },
            { EUNATCH,         "EUNATCH" },
            { EUSERS,          "EUSERS" },
            { EWOULDBLOCK,     "EWOULDBLOCK" },
            { EXDEV,           "EXDEV" },
            { EXFULL,          "EXFULL" }
        };

        for (unsigned int i = 0; i < sizeof(errnoList) / (sizeof(int) + sizeof(const char*)); i++)
        {
            if (code == errnoList[i].value)
            {
                // Some operating systems shared values for errno error enumerations. The below
                // code will create a list of errno enums that were equal to the error code.
                if (reason == U8(""))
                {
                    reason = errnoList[i].str;
                }
                else
                {
                    reason += U8(", ") + errnoList[i].str;
                }
            }
        }
#       endif
    }

    if (type == TYPE_NETWORK)
    {
#       ifdef CGUL_WINDOWS
#       endif
    }

    if (type == TYPE_ADDR_INFO)
    {
        switch (code)
        {
#           ifndef CGUL_WINDOWS
            case EAI_ADDRFAMILY: reason = "EAI_ADDRFAMILY"; break;
#           endif
            case EAI_AGAIN:      reason = "EAI_AGAIN";      break;
            case EAI_BADFLAGS:   reason = "EAI_BADFLAGS";   break;
            case EAI_FAIL:       reason = "EAI_FAIL";       break;
            case EAI_FAMILY:     reason = "EAI_FAMILY";     break;
            case EAI_MEMORY:     reason = "EAI_MEMORY";     break;
#           ifndef CGUL_WINDOWS
            case EAI_NODATA:     reason = "EAI_NODATA";     break;
#           endif
            case EAI_NONAME:     reason = "EAI_NONAME";     break;
            case EAI_SERVICE:    reason = "EAI_SERVICE";    break;
            case EAI_SOCKTYPE:   reason = "EAI_SOCKTYPE";   break;
#           ifndef CGUL_WINDOWS
            case EAI_SYSTEM:     reason = "EAI_SYSTEM";     break;
#           endif
        }
    }

    if (!reason.IsEmpty())
    {
        info += U8(" (") + reason + U8(")");
    }

    return info;
}
Example #15
0
//
// Capture one character into given array index
//
void CaptureOneChar(HDC hDC, int i, int charValue, int yShift)
{
	int x, y, xx, yy;
	SIZE charSize;

	// Display the character
	InvalidateRect(appWnd, NULL, TRUE);
	UpdateWindow(appWnd);

  if (UnicodeMode())
  {
    CH str[2] = { CH(charValue), 0 };

    GetTextExtentPoint32W(hDC, str, 1, &charSize);
		TextOutW(hDC, 0, 0, str, 1);
  }
  else
  {
    char str[2] = { char(charValue), 0};

    GetTextExtentPoint32(hDC, str, 1, &charSize);
		TextOut(hDC, 0, 0, str, 1);
  }
	GdiFlush();

	// Clear character rectangle
	RECT charRect;
	charRect.left = LONG_MAX;
	charRect.top = LONG_MAX;
	charRect.right = LONG_MIN;
	charRect.bottom = LONG_MIN;
	bool setRect = false;

	// Determine clipping rectangle
	for (y = 0; y < charSize.cy; y++)
	{
		for (x = 0; x < charSize.cx; x++)
		{
			// Capture the pixel
			COLORREF clr = GetPixel(hDC, x, y + yShift);

			// If the pixel is not white...
			if (GetRValue(clr) < 255)
			{
				// Update the character rectangle
				if (charRect.left > x)
					charRect.left = x;
				if (charRect.top > y)
					charRect.top = y;
				if (charRect.right < x)
					charRect.right = x;
				if (charRect.bottom < y)
					charRect.bottom = y;
				setRect = true;
			}
		}
	}

	if (setRect)
	{
		// Calculate x shift
		int xShift = charRect.left % appFontScale;

		// Rescale the size
		charSize.cx = (charSize.cx + appFontScale - 1) / appFontScale;
		charSize.cy = (charSize.cy + appFontScale - 1) / appFontScale;

		// Rescale the rectangle
		charRect.left = (charRect.left - xShift) / appFontScale;
		charRect.top = charRect.top / appFontScale;
		charRect.right = (charRect.right - xShift) / appFontScale + 1;
		charRect.bottom = (charRect.bottom) / appFontScale + 1;

		// Get width and height
		int w = charRect.right - charRect.left;
		int h = charRect.bottom - charRect.top;

		// Create a new character image
		CharImage *charImage = (CharImage *)
			new BYTE [sizeof(CharImage) + w * h];

		// Push the character image into the character list
		charImageList[i] = charImage;

		// Store the character dimensions
		charImage->charWidth = (BYTE)w;
		charImage->charHeight = (BYTE)h;

		// Start in the upper left corner
		BYTE *pixel = charImage->charData;

		// Capture the character
		for (y = charRect.top; y < charRect.bottom; y++)
		{
			for (x = charRect.left; x < charRect.right; x++)
			{
				// Clear the pixel sum
				DWORD sum = 0;

				// Average value over block
				for (yy = (y) * appFontScale; yy < (y + 1) * appFontScale; yy++)
				{
					for (xx = (x) * appFontScale; xx < (x + 1) * appFontScale; xx++)
					{
						// Capture the pixel
						COLORREF clr = GetPixel(hDC, xx + xShift, yy + yShift);

						// Add pixel intensity to sum
						sum += GetRValue(clr);
					}
				}

				// Get the average pixel intensity
				sum = (sum + sum + appFontScale2) / (appFontScale2 + appFontScale2);

				// Store the pixel value
				*pixel++ = U8(0xFF - (BYTE)sum);
			}
		}

		// Get the current character header
		CharHeader *charHeader = &charHeaderList[i];

		// Fill in the character header
		charHeader->charValue = (CH)charValue;
		charHeader->fullWidth = (BYTE)charSize.cx;
		charHeader->rectX0 = (BYTE)charRect.left;
		charHeader->rectY0 = (BYTE)charRect.top;
		charHeader->rectX1 = (BYTE)charRect.right;
		charHeader->rectY1 = (BYTE)charRect.bottom;
	}
	else
	{
		// Rescale the size
		charSize.cx = (charSize.cx + appFontScale - 1) / appFontScale;
		charSize.cy = (charSize.cy + appFontScale - 1) / appFontScale;

		// Create a new character image
		CharImage *charImage = (CharImage *)
			new BYTE [sizeof(CharImage)];

		// Push the character image into the character list
		charImageList[i] = charImage;

		// Zero width and height
		charImage->charWidth = 0;
		charImage->charHeight = 0;

		// Get the current character header
		CharHeader *charHeader = &charHeaderList[i];

		// Fill in the character header
		charHeader->charValue = (CH)charValue;
		charHeader->fullWidth = (BYTE)charSize.cx;
		charHeader->rectX0 = 0;
		charHeader->rectY0 = 0;
		charHeader->rectX1 = 0;
		charHeader->rectY1 = 0;
	}
}
Example #16
0
void color3f( F32 red, F32 green, F32 blue )
{
   mCurColor.set( U8( red * 255 ), U8( green * 255 ), U8( blue * 255 ) );
}
Example #17
0
///
/// Generates source code for the bishop rays.
///
void CFiestyGen::genBishopRays()
{
    std::cout << "const SBishopRays CGen::mbbBishopRays[CSqix::kNumSquares] = {";
    for ( U8 sq =  0; sq < CSqix::kNumSquares; sq++ )
    {
        CSqix sqix( sq );
        U8 bishopRank = U8( sqix.getRank().get() );
        U8 bishopFile = U8( sqix.getFile().get() );
        CBitBoard bbNorthEast( 0ULL );
		CBitBoard bbSouthEast( 0ULL );
		CBitBoard bbSouthWest( 0ULL );
		CBitBoard bbNorthWest( 0ULL );

		//
		//	Loop setting the north-east bits
		//
        S8 r = bishopRank + 1;
        S8 f = bishopFile + 1;
		while ( r <= S8( ERank::kRank8 ) && f <= S8( EFile::kFileH ) )
        {
			bbNorthEast.setSquare( CSqix( ERank( r ), EFile( f ) ).get() );
            r++;
            f++;
        }

		//
		//	Loop setting the south-east bits
		//
        r = bishopRank - 1;
        f = bishopFile + 1;
		while ( r >= S8( ERank::kRank1 ) && f <= S8( EFile::kFileH ) )
        {
			bbSouthEast.setSquare( CSqix( ERank( r ), EFile( f ) ).get() );
            r--;
            f++;
        }

		//
		//	Loop setting the south-west bits
		//
        r = bishopRank - 1;
        f = bishopFile - 1;
		while ( r >= S8( ERank::kRank1 ) && f >= S8( EFile::kFileA ) )
        {
			bbSouthWest.setSquare( CSqix( ERank( r ), EFile( f ) ).get() );
            r--;
            f--;
        }

		//
		//	Loop setting the north-west bits
		//
        r = bishopRank + 1;
        f = bishopFile - 1;
		while ( r <= S8( ERank::kRank8 ) && f >= S8( EFile::kFileA ) )
        {
			bbNorthWest.setSquare( CSqix( ERank( r ), EFile( f ) ).get() );
            r++;
            f--;
        }

#ifdef BBTRACE
       printBitBoardDiagram( sqix.asAbbr() + " NorthEast",  bbNorthEast );
       printBitBoardDiagram( sqix.asAbbr() + " SouthEast",  bbSouthEast );
       printBitBoardDiagram( sqix.asAbbr() + " SouthWest",  bbSouthWest );
       printBitBoardDiagram( sqix.asAbbr() + " NorthWest",  bbNorthWest );
#endif

       std::cout << "\n    /* " << sqix.asAbbr() << " */ { "
            << bbNorthEast.asAbbr() << "ULL" << ", "
            << bbSouthEast.asAbbr() << "ULL" << ", "
            << bbSouthWest.asAbbr() << "ULL" << ", "
            << bbNorthWest.asAbbr() << "ULL" << " }";
        if ( sq != CSqix::kNumSquares - 1 )
            std::cout << ", ";
    }
    std::cout << "};\n" << std::flush;
}
Example #18
0
void color4f( F32 red, F32 green, F32 blue, F32 alpha )
{
   mCurColor.set( U8( red * 255 ), U8( green * 255 ), U8( blue * 255 ), U8( alpha * 255 ) );
}
void LLImageRaw::copyLineScaled( U8* in, U8* out, S32 in_pixel_len, S32 out_pixel_len, S32 in_pixel_step, S32 out_pixel_step )
{
	const S32 components = getComponents();
	llassert( components >= 1 && components <= 4 );

	const F32 ratio = F32(in_pixel_len) / out_pixel_len; // ratio of old to new
	const F32 norm_factor = 1.f / ratio;

	S32 goff = components >= 2 ? 1 : 0;
	S32 boff = components >= 3 ? 2 : 0;
	for( S32 x = 0; x < out_pixel_len; x++ )
	{
		// Sample input pixels in range from sample0 to sample1.
		// Avoid floating point accumulation error... don't just add ratio each time.  JC
		const F32 sample0 = x * ratio;
		const F32 sample1 = (x+1) * ratio;
		const S32 index0 = llfloor(sample0);			// left integer (floor)
		const S32 index1 = llfloor(sample1);			// right integer (floor)
		const F32 fract0 = 1.f - (sample0 - F32(index0));	// spill over on left
		const F32 fract1 = sample1 - F32(index1);			// spill-over on right

		if( index0 == index1 )
		{
			// Interval is embedded in one input pixel
			S32 t0 = x * out_pixel_step * components;
			S32 t1 = index0 * in_pixel_step * components;
			U8* outp = out + t0;
			U8* inp = in + t1;
			for (S32 i = 0; i < components; ++i)
			{
				*outp = *inp;
				++outp;
				++inp;
			}
		}
		else
		{
			// Left straddle
			S32 t1 = index0 * in_pixel_step * components;
			F32 r = in[t1 + 0] * fract0;
			F32 g = in[t1 + goff] * fract0;
			F32 b = in[t1 + boff] * fract0;
			F32 a = 0;
			if( components == 4)
			{
				a = in[t1 + 3] * fract0;
			}
		
			// Central interval
			if (components < 4)
			{
				for( S32 u = index0 + 1; u < index1; u++ )
				{
					S32 t2 = u * in_pixel_step * components;
					r += in[t2 + 0];
					g += in[t2 + goff];
					b += in[t2 + boff];
				}
			}
			else
			{
				for( S32 u = index0 + 1; u < index1; u++ )
				{
					S32 t2 = u * in_pixel_step * components;
					r += in[t2 + 0];
					g += in[t2 + 1];
					b += in[t2 + 2];
					a += in[t2 + 3];
				}
			}

			// right straddle
			// Watch out for reading off of end of input array.
			if( fract1 && index1 < in_pixel_len )
			{
				S32 t3 = index1 * in_pixel_step * components;
				if (components < 4)
				{
					U8 in0 = in[t3 + 0];
					U8 in1 = in[t3 + goff];
					U8 in2 = in[t3 + boff];
					r += in0 * fract1;
					g += in1 * fract1;
					b += in2 * fract1;
				}
				else
				{
					U8 in0 = in[t3 + 0];
					U8 in1 = in[t3 + 1];
					U8 in2 = in[t3 + 2];
					U8 in3 = in[t3 + 3];
					r += in0 * fract1;
					g += in1 * fract1;
					b += in2 * fract1;
					a += in3 * fract1;
				}
			}

			r *= norm_factor;
			g *= norm_factor;
			b *= norm_factor;
			a *= norm_factor;  // skip conditional

			S32 t4 = x * out_pixel_step * components;
			out[t4 + 0] = U8(llround(r));
			if (components >= 2)
				out[t4 + 1] = U8(llround(g));
			if (components >= 3)
				out[t4 + 2] = U8(llround(b));
			if( components == 4)
				out[t4 + 3] = U8(llround(a));
		}
	}
}
void ImportTracker::get_update(S32 newid, BOOL justCreated, BOOL createSelected)
{
	switch (state)
	{
		//lgg crap to change remaining prim parameters from the ascent system build preferences subtab
		case WAND:
			if(justCreated && createSelected)
			{
				numberExpected--;
				if(numberExpected<=0)
					state=IDLE;
				LLMessageSystem* msg = gMessageSystem;
				msg->newMessageFast(_PREHASH_ObjectImage);
				msg->nextBlockFast(_PREHASH_AgentData);
				msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
				msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());	
				msg->nextBlockFast(_PREHASH_ObjectData);				
				msg->addU32Fast(_PREHASH_ObjectLocalID,  (U32)newid);
				msg->addStringFast(_PREHASH_MediaURL, NULL);
//sets texture stuff
				LLPrimitive obj;
				obj.setNumTEs(U8(10));	
				S32 shinnyLevel = 0;
				static LLCachedControl<std::string> sshinystr(gSavedSettings, "EmeraldBuildPrefs_Shiny");
				std::string shinystr = sshinystr;
				//if(shinystr == "None") shinnyLevel = 0; //We're already 0.
				if(shinystr == "Low") shinnyLevel = 1;
				else if(shinystr == "Medium") shinnyLevel = 2;
				else if(shinystr == "High") shinnyLevel = 3;
				
				for (int i = 0; i < 10; i++)
				{
					LLTextureEntry tex =  LLTextureEntry(LLUUID(gSavedSettings.getString("EmeraldBuildPrefs_Texture")));
					tex.setColor(gSavedSettings.getColor4("EmeraldBuildPrefs_Color"));
					tex.setAlpha(1.0 - ((gSavedSettings.getF32("EmeraldBuildPrefs_Alpha")) / 100.0));
					tex.setGlow(gSavedSettings.getF32("EmeraldBuildPrefs_Glow"));
					if(gSavedSettings.getBOOL("EmeraldBuildPrefs_FullBright"))
					{
						tex.setFullbright(TEM_FULLBRIGHT_MASK);
					}
									
					tex.setShiny((U8) shinnyLevel & TEM_SHINY_MASK);
					
					obj.setTE(U8(i), tex);
				}
	
				obj.packTEMessage(gMessageSystem);
	
				msg->sendReliable(gAgent.getRegion()->getHost());
//sets some object parameters
				msg->newMessage("ObjectFlagUpdate");
				msg->nextBlockFast(_PREHASH_AgentData);
				msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
				msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
				msg->addU32Fast(_PREHASH_ObjectLocalID, (U32)newid );
				msg->addBOOLFast(_PREHASH_UsePhysics, gSavedSettings.getBOOL("EmeraldBuildPrefs_Physical"));
				msg->addBOOLFast(_PREHASH_IsTemporary, gSavedSettings.getBOOL("EmeraldBuildPrefs_Temporary"));
				msg->addBOOLFast(_PREHASH_IsPhantom, gSavedSettings.getBOOL("EmeraldBuildPrefs_Phantom") );
				msg->addBOOL("CastsShadows", false );
				msg->sendReliable(gAgent.getRegion()->getHost());

				if(gSavedSettings.getBOOL("EmeraldBuildPrefs_EmbedItem"))
				{
					LLViewerInventoryItem* item = (LLViewerInventoryItem*)gInventory.getItem((LLUUID)gSavedPerAccountSettings.getString("EmeraldBuildPrefs_Item"));
					LLViewerObject* objectp = find((U32)newid);
					if(objectp)
						if(item)
						{
							if(item->getType()==LLAssetType::AT_LSL_TEXT)
							{
								LLToolDragAndDrop::dropScript(objectp,
									item,
									TRUE,
									LLToolDragAndDrop::SOURCE_AGENT,
									gAgent.getID());
							}else
							{
								LLToolDragAndDrop::dropInventory(objectp,item,LLToolDragAndDrop::SOURCE_AGENT,gAgent.getID());
							}
						}
				}
				
				msg->newMessageFast(_PREHASH_ObjectPermissions);
				msg->nextBlockFast(_PREHASH_AgentData);
				msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
				msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
				msg->nextBlockFast(_PREHASH_HeaderData);
				msg->addBOOLFast(_PREHASH_Override, FALSE);
				msg->nextBlockFast(_PREHASH_ObjectData);
				msg->addU32Fast(_PREHASH_ObjectLocalID, (U32)newid);
				msg->addU8Fast(_PREHASH_Field,	PERM_NEXT_OWNER);
				msg->addU8Fast(_PREHASH_Set, PERM_SET_TRUE);
				U32 flags = 0;
				if ( gSavedSettings.getBOOL("NextOwnerCopy") )
				{
					flags |= PERM_COPY;
				}
				if ( gSavedSettings.getBOOL("NextOwnerModify") )
				{
					flags |= PERM_MODIFY;
				}
				bool next_owner_trans;
				if ( next_owner_trans = gSavedSettings.getBOOL("NextOwnerTransfer") )
				{
					flags |= PERM_TRANSFER;
				}
				msg->addU32Fast(_PREHASH_Mask, flags);
				msg->sendReliable(gAgent.getRegion()->getHost());
				if (!next_owner_trans) // Workaround transfer being true by default.
				{
					msg->newMessageFast(_PREHASH_ObjectPermissions);
					msg->nextBlockFast(_PREHASH_AgentData);
					msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
					msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
					msg->nextBlockFast(_PREHASH_HeaderData);
					msg->addBOOLFast(_PREHASH_Override, false);
					msg->nextBlockFast(_PREHASH_ObjectData);
					msg->addU32Fast(_PREHASH_ObjectLocalID, (U32)newid);
					msg->addU8Fast(_PREHASH_Field,	PERM_NEXT_OWNER);
					msg->addU8Fast(_PREHASH_Set, PERM_SET_FALSE);
					msg->addU32Fast(_PREHASH_Mask, PERM_TRANSFER);
					msg->sendReliable(gAgent.getRegion()->getHost());
				}
				//llinfos << "LGG SENDING CUBE TEXTURE.." << llendl;
			}
		break;
/*		case BUILDING:
			
			if (justCreated && (int)localids.size() < linkset.size())
			{
				localids.push_back(newid);
				localids.sort();
				localids.unique();

				linkset[localids.size() -1]["LocalID"] = newid;
				LLSD prim = linkset[localids.size() -1];

				//MAKERIGHT
				if (!(prim).has("Updated"))
				{
					++updated;
					send_shape(prim);
					send_image(prim);
					send_extras(prim);
					send_namedesc(prim);
					send_vectors(prim,updated);
					send_properties(prim, updated);
					send_inventory(prim);
					(prim)["Updated"] = true;
				}
				if ((int)localids.size() < linkset.size())
				{
					plywood_above_head();
					return;
				}
				else
				{
					if (updated >= linkset.size())
					{
						updated=0;
						llinfos << "FINISHED BUILDING, LINKING.." << llendl;
						state = LINKING;
						link();
					}
				}
			}
		break;
		case LINKING:
			link();
		break;*/
	}
}
Example #21
0
static void safer_encrypt
(
	const kripto_block *s,
	const void *pt,
	void *ct
)
{
	uint8_t x0 = CU8(pt)[0];
	uint8_t x1 = CU8(pt)[1];
	uint8_t x2 = CU8(pt)[2];
	uint8_t x3 = CU8(pt)[3];
	uint8_t x4 = CU8(pt)[4];
	uint8_t x5 = CU8(pt)[5];
	uint8_t x6 = CU8(pt)[6];
	uint8_t x7 = CU8(pt)[7];
	uint8_t t;
	unsigned int i = 0;

	while(i < s->rounds << 4)
	{
		x0 = EXP(x0 ^ s->k[i++]);
		x1 = LOG(x1 + s->k[i++]);
		x2 = LOG(x2 + s->k[i++]);
		x3 = EXP(x3 ^ s->k[i++]);
		x4 = EXP(x4 ^ s->k[i++]);
		x5 = LOG(x5 + s->k[i++]);
		x6 = LOG(x6 + s->k[i++]);
		x7 = EXP(x7 ^ s->k[i++]);

		x0 += s->k[i++];
		x1 ^= s->k[i++];
		x2 ^= s->k[i++];
		x3 += s->k[i++];
		x4 += s->k[i++];
		x5 ^= s->k[i++];
		x6 ^= s->k[i++];
		x7 += s->k[i++];

		x1 += x0; x3 += x2; x5 += x4; x7 += x6;
		x0 += x1; x2 += x3; x4 += x5; x6 += x7;

		x2 += x0; x6 += x4; x3 += x1; x7 += x5;
		x0 += x2; x4 += x6; x1 += x3; x5 += x7;

		x4 += x0; x5 += x1; x6 += x2; x7 += x3;
		x0 += x4; x1 += x5; x2 += x6; x3 += x7;

		t = x1; x1 = x4; x4 = x2; x2 = t;
		t = x3; x3 = x5; x5 = x6; x6 = t;
	}

	x0 ^= s->k[i++];
	x1 += s->k[i++];
	x2 += s->k[i++];
	x3 ^= s->k[i++];
	x4 ^= s->k[i++];
	x5 += s->k[i++];
	x6 += s->k[i++];
	x7 ^= s->k[i++];

	U8(ct)[0] = x0;
	U8(ct)[1] = x1;
	U8(ct)[2] = x2;
	U8(ct)[3] = x3;
	U8(ct)[4] = x4;
	U8(ct)[5] = x5;
	U8(ct)[6] = x6;
	U8(ct)[7] = x7;
}
BOOL LLImageTGA::encode(const LLImageRaw* raw_image, F32 encode_time)
{
	llassert_always(raw_image);
	
	deleteData();

	setSize(raw_image->getWidth(), raw_image->getHeight(), raw_image->getComponents());

	// Data from header
	mIDLength = 0;		// Length of identifier string
	mColorMapType = 0;	// 0 = No Map

	// Supported: 2 = Uncompressed true color, 3 = uncompressed monochrome without colormap
	switch( getComponents() )
	{
	case 1:
		mImageType = 3;		
		break;
	case 2:	 // Interpret as intensity plus alpha
	case 3:
	case 4:
		mImageType = 2;		
		break;
	default:
		return FALSE;
	}

	// Color map stuff (unsupported)
	mColorMapIndexLo = 0;		// First color map entry (low order byte)
	mColorMapIndexHi = 0;		// First color map entry (high order byte)
	mColorMapLengthLo = 0;		// Color map length (low order byte)
	mColorMapLengthHi = 0;		// Color map length (high order byte)
	mColorMapDepth = 0;	// Size of color map entry (15, 16, 24, or 32 bits)

	// Image offset relative to origin.
	mXOffsetLo = 0;		// X offset from origin (low order byte)
	mXOffsetHi = 0;		// X offset from origin (hi order byte)
	mYOffsetLo = 0;		// Y offset from origin (low order byte)
	mYOffsetHi = 0;		// Y offset from origin (hi order byte)

	// Height and width
	mWidthLo = U8(getWidth() & 0xFF);			// Width (low order byte)
	mWidthHi = U8((getWidth() >> 8) & 0xFF);	// Width (hi order byte)
	mHeightLo = U8(getHeight() & 0xFF);			// Height (low order byte)
	mHeightHi = U8((getHeight() >> 8) & 0xFF);	// Height (hi order byte)

	S32 bytes_per_pixel;
	switch( getComponents() )
	{
	case 1:
		bytes_per_pixel = 1;		
		break;
	case 3:
		bytes_per_pixel = 3;		
		break;
	case 2:	 // Interpret as intensity plus alpha.  Store as RGBA.
	case 4:
		bytes_per_pixel = 4;		
		break;
	default:
		return FALSE;
	}
	mPixelSize = U8(bytes_per_pixel * 8);		// 8, 16, 24, 32 bits per pixel

	mAttributeBits = (4 == bytes_per_pixel) ? 8 : 0;	// 4 bits: number of attribute bits (alpha) per pixel
	mOriginRightBit = 0;	// 1 bit: origin, 0 = left, 1 = right
	mOriginTopBit = 0;	// 1 bit: origin, 0 = bottom, 1 = top
	mInterleave = 0;	// 2 bits: interleaved flag, 0 = none, 1 = interleaved 2, 2 = interleaved 4


	const S32 TGA_HEADER_SIZE = 18;
	const S32 COLOR_MAP_SIZE = 0;
	mDataOffset = TGA_HEADER_SIZE + mIDLength + COLOR_MAP_SIZE; // Offset from start of data to the actual header.

	S32 pixels = getWidth() * getHeight();
	S32 datasize = mDataOffset + bytes_per_pixel * pixels;
	U8* dst = allocateData(datasize);

	// Write header
	*(dst++) = mIDLength;		
	*(dst++) = mColorMapType;	
	*(dst++) = mImageType;		
	*(dst++) = mColorMapIndexLo;		
	*(dst++) = mColorMapIndexHi;		
	*(dst++) = mColorMapLengthLo;		
	*(dst++) = mColorMapLengthHi;		
	*(dst++) = mColorMapDepth;	
	*(dst++) = mXOffsetLo;		
	*(dst++) = mXOffsetHi;		
	*(dst++) = mYOffsetLo;		
	*(dst++) = mYOffsetHi;		
	*(dst++) = mWidthLo;		
	*(dst++) = mWidthHi;		
	*(dst++) = mHeightLo;		
	*(dst++) = mHeightHi;		
	*(dst++) = mPixelSize;		
	*(dst++) =
		((mInterleave & 3) << 5) |
		((mOriginTopBit & 1) << 4) |
		((mOriginRightBit & 1) << 3) |
		((mAttributeBits & 0xF) << 0);	

	// Write pixels
	const U8* src = raw_image->getData();
	llassert( dst == getData() + mDataOffset );
	S32 i = 0;
	S32 j = 0;
	switch( getComponents() )
	{
	case 1:
		memcpy( dst, src, bytes_per_pixel * pixels );	/* Flawfinder: ignore */
		break;

	case 2:
		while( pixels-- )
		{
			dst[i + 0] = src[j + 0];	// intensity
			dst[i + 1] = src[j + 0];	// intensity
			dst[i + 2] = src[j + 0];	// intensity
			dst[i + 3] = src[j + 1];	// alpha
			i += 4;
			j += 2;
		}
		break;

	case 3:
		while( pixels-- )
		{
			dst[i + 0] = src[i + 2];	// blue
			dst[i + 1] = src[i + 1];	// green
			dst[i + 2] = src[i + 0];	// red
			i += 3;
		}
		break;

	case 4:
		while( pixels-- )
		{
			dst[i + 0] = src[i + 2];	// blue
			dst[i + 1] = src[i + 1];	// green
			dst[i + 2] = src[i + 0];	// red
			dst[i + 3] = src[i + 3];	// alpha
			i += 4;
		}
		break;
	}
	
	return TRUE;
}
void LLFontGL::drawGlyph(S32& glyph_count, LLVector4a* vertex_out, LLVector2* uv_out, LLColor4U* colors_out, const LLRectf& screen_rect, const LLRectf& uv_rect, const LLColor4U& color, U8 style, ShadowType shadow, F32 drop_shadow_strength) const
{
	F32 slant_offset;
	slant_offset = ((style & ITALIC) ? ( -mFontFreetype->getAscenderHeight() * 0.2f) : 0.f);

	//FIXME: bold and drop shadow are mutually exclusive only for convenience
	//Allow both when we need them.
	if (style & BOLD)
	{
		for (S32 pass = 0; pass < 2; pass++)
		{
			LLRectf screen_rect_offset = screen_rect;

			screen_rect_offset.translate((F32)(pass * BOLD_OFFSET), 0.f);
			renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_offset, uv_rect, color, slant_offset);
			glyph_count++;
		}
	}
	else if (shadow == DROP_SHADOW_SOFT)
	{
		LLColor4U shadow_color = LLFontGL::sShadowColor;
		shadow_color.mV[VALPHA] = U8(color.mV[VALPHA] * drop_shadow_strength * DROP_SHADOW_SOFT_STRENGTH);
		for (S32 pass = 0; pass < 5; pass++)
		{
			LLRectf screen_rect_offset = screen_rect;

			switch(pass)
			{
			case 0:
				screen_rect_offset.translate(-1.f, -1.f);
				break;
			case 1:
				screen_rect_offset.translate(1.f, -1.f);
				break;
			case 2:
				screen_rect_offset.translate(1.f, 1.f);
				break;
			case 3:
				screen_rect_offset.translate(-1.f, 1.f);
				break;
			case 4:
				screen_rect_offset.translate(0, -2.f);
				break;
			}
		
			renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_offset, uv_rect, shadow_color, slant_offset);
			glyph_count++;
		}
		renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset);
		glyph_count++;
	}
	else if (shadow == DROP_SHADOW)
	{
		LLColor4U shadow_color = LLFontGL::sShadowColor;
		shadow_color.mV[VALPHA] = U8(color.mV[VALPHA] * drop_shadow_strength);
		LLRectf screen_rect_shadow = screen_rect;
		screen_rect_shadow.translate(1.f, -1.f);
		renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect_shadow, uv_rect, shadow_color, slant_offset);
		glyph_count++;
		renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset);
		glyph_count++;
	}
	else // normal rendering
	{
		renderQuad(&vertex_out[glyph_count * 4], &uv_out[glyph_count * 4], &colors_out[glyph_count * 4], screen_rect, uv_rect, color, slant_offset);
		glyph_count++;
	}
}
  //
  // DrawSelf
  //
  void TimeOfDay::DrawSelf(PaintInfo &pi)
  {
    if (texture && texture->texture)
    {
      // Radius of texture 
      const F32 SCALE = 0.5F;

      const struct { F32 u, v; } UV[4] = 
      {
        { -SCALE, SCALE },
        {  SCALE, SCALE },
        {  SCALE, 0.0F },
        { -SCALE, 0.0F },
      };

      // Middle of day is 90deg rotation, Middle of night is 270deg rotation
      F32 angle = Environment::Light::Azimuth() * PI + PIBY2;

      if (!Environment::Light::IsSunUp())
      {
        angle += PI;
      }

      // Rotate anticlockwise
      //angle = -angle;

      // Calculate UV coordinates, assumes square texture taking up entire image
      F32 cosAngle = F32(cos(angle));
      F32 sinAngle = F32(sin(angle));

      // Scale the alpha down
      Color color = pi.colors->bg[ColorIndex()];

      if (pi.alphaScale < 1.0F)
      {
        color.a = U8(Utils::FtoL(F32(color.a) * pi.alphaScale));
      }

		  // vertices of the rectangle
      U16 offset;
      VertexTL *point = IFace::GetVerts(4, texture->texture, texture->filter, RS_TEXCLAMP, offset);
      IFace::SetIndex(Vid::rectIndices, 6, offset);
        
		  // top left corner
		  point[0].vv.x = (F32)pi.client.p0.x;
		  point[0].vv.y = (F32)pi.client.p0.y;
		  point[0].vv.z = 0.0F;
		  point[0].rhw = 1.0F;
		  point[0].diffuse = color;
		  point[0].specular = 0xFF000000;

			point[0].u = 0.5F + UV[0].u * cosAngle - UV[0].v * sinAngle;
			point[0].v = 0.5F + UV[0].u * sinAngle + UV[0].v * cosAngle;;

		  // top right corner
		  point[1].vv.x = (F32)pi.client.p1.x;
		  point[1].vv.y = (F32)pi.client.p0.y;
		  point[1].vv.z = 0.0F;
		  point[1].rhw = 1.0F;
		  point[1].diffuse = color;
		  point[1].specular = 0xFF000000;

			point[1].u = 0.5F + UV[1].u * cosAngle - UV[1].v * sinAngle;
			point[1].v = 0.5F + UV[1].u * sinAngle + UV[1].v * cosAngle;;

		  // bottom right corner
		  point[2].vv.x = (F32)pi.client.p1.x;
		  point[2].vv.y = (F32)pi.client.p1.y;
		  point[2].vv.z = 0.0F;
		  point[2].rhw = 1.0F;
		  point[2].diffuse = color;
		  point[2].specular = 0xFF000000;

			point[2].u = 0.5F + UV[2].u * cosAngle - UV[2].v * sinAngle;
			point[2].v = 0.5F + UV[2].u * sinAngle + UV[2].v * cosAngle;;

		  // bottom left corner
		  point[3].vv.x = (F32)pi.client.p0.x;
		  point[3].vv.y = (F32)pi.client.p1.y;
		  point[3].vv.z = 0.0F;
		  point[3].rhw = 1.0F;
		  point[3].diffuse = color;
		  point[3].specular = 0xFF000000;

			point[3].u = 0.5F + UV[3].u * cosAngle - UV[3].v * sinAngle;
			point[3].v = 0.5F + UV[3].u * sinAngle + UV[3].v * cosAngle;;

    /*
    // Are we after sunrise and before sunset ?
    if (currentTime > sunriseStartTime && currentTime < sunsetStartTime)
    {
      tempText = "Day";
      tempVal = (sunsetStartTime - currentTime) * 24.0f * 60.0f;
    }
    else
    {
      tempText = "Night";
      tempVal = sunriseStartTime - currentTime;
      if (tempVal < 0.0f)
      {
        tempVal = tempVal + 1.0f;
      }
      tempVal = tempVal * 24.0f * 60.0f;
    }
    */
    }
  }
Example #25
0
_CGUL_EXPORT CGUL::String CGUL::FatalException::GetString() const
{
    return U8("Fatal runtime error: ") + this->error;
}
Example #26
0
void RecordHashValue(PCON pcon, PSTE pste, const CM &cm, int val, hashBound hashf, int depth)
{
#if 1
    if( val >= valMATEscore ) {
        val += depth - 1;
    } else if( val <= -valMATEscore ) {
        val -= depth - 1;
    }
#endif
    int plyrem = pste->plyRem;

//    if( !pcon->hashStore )  // HACK
//        return;
    if( !pcon->hashStore )  // HACK
        plyrem = HASH::pvDepth;

//    (pste)->ttmove = (pste+1)->ttmove;
    /*    if( (pste+1)->ttmove ) {
    //        return;
            plyrem -= 1;
            if( pste->plyRem <= 0 )
                return;
        }*/
    //
    //	Replace allways
    //
    PHASHD phashd = &s_rghashd[HASHKEY_OFFSET(pste->hashkPc) & s_chashdMac];
    U32 thisHashSig = HASHKEY_SIG(pste->hashkPc);
    PHASHD goodSlot = phashd;
    int bestScore = -10000000;
    bool forced = false;
    bool ext = false;
    U32 nodes = 0;
    for(int i = 0; i < BUCKET_SIZE; i++) {
        PHASHD newSlot = (phashd + i);
        // reuse slot if found
        if( newSlot->hashDepth.hashkSig == thisHashSig ) {
            goodSlot = newSlot;
            forced = newSlot->hashDepth.getForced();
            ext = newSlot->hashDepth.getExt();
            nodes = newSlot->hashDepth.count;
            if( true && (plyrem == HASH::pvDepth) /*&& goodSlot->hashDepth.getPlyRem() > plyrem */) {
                // don't overide if it's deeper
                PHASH phash = &goodSlot->hashDepth;
                if( phash->getMove() == 0 )
                    phash->setMove( cm.m );
                //phash->setBound( hashf );
                //phash->setForced( forced );
                //phash->count = nodes;
                //Assert( plyrem >= 0 && plyrem < 125 );
                //phash->plyRem = plyrem;
                phash->seq = HASH::s_seq;
                return;
            }
            /*            if( goodSlot->hashDepth.getBound() != hashf && hashf != hashfEXACT && goodSlot->hashDepth.getBound() != hashfEXACT)
                            hashf = hashf;
                        if( goodSlot->hashDepth.getBound() == hashfBETA && hashf == hashfALPHA && val > goodSlot->hashDepth.val ) {
                            hashf = hashfBETA;
                            val = goodSlot->hashDepth.val;
                        }*/
            break;
        }
#if 0
        // try to find an old slot
        if( (goodSlot->hashDepth.seq == HASH::s_seq)  ) {
            // todo : age is inexact if coming from a previous search
            // we prefer to replace a slot from a previous search
            if( (newSlot->hashDepth.seq != HASH::s_seq)  )
                goodSlot = newSlot;
            // but if we can't we prefer to replace a slot from a lower search depth
            else if( (newSlot->hashDepth.getPlyRem() < goodSlot->hashDepth.getPlyRem()) )
                goodSlot = newSlot;
        } else {
            // we are going to replace a slot from a previous search
            // replace the slot with the lowest search depth
            if( (newSlot->hashDepth.seq != HASH::s_seq) && (newSlot->hashDepth.getPlyRem() < goodSlot->hashDepth.getPlyRem()) )
                goodSlot = newSlot;
        }
#else
        // in this version I try not to replace entries from the previous search
        // because I really need them
        // s_seq    new.seq deltaSeq    u8()
        //  5       4       1           1
        //  5       3       2           2
        //  255     254     1           1
        //  0       255     -255        1
        //  1       255     -254        2
        //  10      11      -1          255
        // note that the hash memory is not initialized
        int deltaSeq = U8(HASH::s_seq - newSlot->hashDepth.seq);  // hanlde wrap around
        int score = 256*(deltaSeq);
//        score += goodSlot->hashDepth.getPlyRem() - newSlot->hashDepth.getPlyRem();
        score -= newSlot->hashDepth.getPlyRem();
        if( score > bestScore ) {
            bestScore = score;
            goodSlot = newSlot;
        }
#endif
    }
    PHASH phash = &goodSlot->hashDepth;
#if 0
    stats.Hdepthinsert++;
    if( s_seq == phash->seq )
        if( phash->hashk != thisHashSig)
            stats.Hcollide++;
#endif
    // else it's an update
    if( HASH::s_seq != phash->seq )
        stats.Hused++;
    Assert(val >= -32768 && val <= 32767);
    phash->val = short(val);
    if (cm.m != 0) {
        phash->setMove( cm.m );
    } else if (phash->hashkSig != thisHashSig)
        phash->setMove( 0 );
    phash->hashkSig = thisHashSig;
    phash->setBound( hashf );
//    phash->setThreat( hasThreat );
    phash->setForced( forced );
    phash->setExt( ext );
    phash->count = nodes;
    Assert( plyrem >= -1 && plyrem < 125 );
    phash->setPlyRem( plyrem );
    phash->seq = HASH::s_seq;
}
Example #27
0
// public static
void LLWorldMap::processMapItemReply(LLMessageSystem* msg, void**)
{
	U32 type;
	msg->getU32Fast(_PREHASH_RequestData, _PREHASH_ItemType, type);

	S32 num_blocks = msg->getNumberOfBlocks("Data");

	for (S32 block=0; block<num_blocks; ++block)
	{
		U32 X, Y;
		std::string name;
		S32 extra, extra2;
		LLUUID uuid;
		msg->getU32Fast(_PREHASH_Data, _PREHASH_X, X, block);
		msg->getU32Fast(_PREHASH_Data, _PREHASH_Y, Y, block);
		msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name, block);
		msg->getUUIDFast(_PREHASH_Data, _PREHASH_ID, uuid, block);
		msg->getS32Fast(_PREHASH_Data, _PREHASH_Extra, extra, block);
		msg->getS32Fast(_PREHASH_Data, _PREHASH_Extra2, extra2, block);

		F32 world_x = (F32)X;
		X /= REGION_WIDTH_UNITS;
		F32 world_y = (F32)Y;
		Y /= REGION_WIDTH_UNITS;
		
		LLItemInfo new_item(world_x, world_y, name, uuid, extra, extra2);
		LLSimInfo* siminfo = LLWorldMap::getInstance()->simInfoFromHandle(new_item.getRegionHandle());

		switch (type)
		{
			case MAP_ITEM_TELEHUB: // telehubs
			{
				// Telehub color, store in extra as 4 U8's
				U8 *color = (U8 *)&new_item.mExtra;

				F32 red = fmod((F32)X * 0.11f, 1.f) * 0.8f;
				F32 green = fmod((F32)Y * 0.11f, 1.f) * 0.8f;
				F32 blue = fmod(1.5f * (F32)(X + Y) * 0.11f, 1.f) * 0.8f;
				F32 add_amt = (X % 2) ? 0.15f : -0.15f;
				add_amt += (Y % 2) ? -0.15f : 0.15f;
				color[0] = U8((red + add_amt) * 255);
				color[1] = U8((green + add_amt) * 255);
				color[2] = U8((blue + add_amt) * 255);
				color[3] = 255;
				
				// extra2 specifies whether this is an infohub or a telehub.
				if (extra2)
				{
					LLWorldMap::getInstance()->mInfohubs.push_back(new_item);
				}
				else
				{
					LLWorldMap::getInstance()->mTelehubs.push_back(new_item);
				}

				break;
			}
			case MAP_ITEM_PG_EVENT: // events
			case MAP_ITEM_MATURE_EVENT:
			case MAP_ITEM_ADULT_EVENT:
			{
				struct tm* timep;
				// Convert to Pacific, based on server's opinion of whether
				// it's daylight savings time there.
				timep = utc_to_pacific_time(extra, gPacificDaylightTime);

				S32 display_hour = timep->tm_hour % 12;
				if (display_hour == 0) display_hour = 12;

				new_item.setTooltip( llformat( "%d:%02d %s",
											  display_hour,
											  timep->tm_min,
											  (timep->tm_hour < 12 ? "AM" : "PM") ) );

				// HACK: store Z in extra2
				new_item.setElevation((F64)extra2);
				if (type == MAP_ITEM_PG_EVENT)
				{
					LLWorldMap::getInstance()->mPGEvents.push_back(new_item);
				}
				else if (type == MAP_ITEM_MATURE_EVENT)
				{
					LLWorldMap::getInstance()->mMatureEvents.push_back(new_item);
				}
				else if (type == MAP_ITEM_ADULT_EVENT)
				{
					LLWorldMap::getInstance()->mAdultEvents.push_back(new_item);
				}

				break;
			}
			case MAP_ITEM_LAND_FOR_SALE: // land for sale
			case MAP_ITEM_LAND_FOR_SALE_ADULT: // adult land for sale 
			{
				new_item.setTooltip(llformat("%d sq. m. %s%d", new_item.mExtra,
					gHippoGridManager->getConnectedGrid()->getCurrencySymbol().c_str(),
					new_item.mExtra2));
				if (type == MAP_ITEM_LAND_FOR_SALE)
				{
					LLWorldMap::getInstance()->mLandForSale.push_back(new_item);
				}
				else if (type == MAP_ITEM_LAND_FOR_SALE_ADULT)
				{
					LLWorldMap::getInstance()->mLandForSaleAdult.push_back(new_item);
				}
				break;
			}
			case MAP_ITEM_CLASSIFIED: // classifieds
			{
				//DEPRECATED: no longer used
				break;
			}
			case MAP_ITEM_AGENT_LOCATIONS: // agent locations
			{
				if (!siminfo)
				{
					llinfos << "siminfo missing for " << new_item.getGlobalPosition().mdV[0] << ", " << new_item.getGlobalPosition().mdV[1] << llendl;
					break;
				}
// 				llinfos << "New Location " << new_item.mName << llendl;

				item_info_list_t& agentcounts = LLWorldMap::getInstance()->mAgentLocationsMap[new_item.getRegionHandle()];

				// Find the last item in the list with a different name and erase them
				item_info_list_t::iterator lastiter;
				for (lastiter = agentcounts.begin(); lastiter!=agentcounts.end(); ++lastiter)
				{
					const LLItemInfo& info = *lastiter;
					if (info.isName(new_item.getName()))
					{
						break;
					}
				}
				if (lastiter != agentcounts.begin())
				{
					agentcounts.erase(agentcounts.begin(), lastiter);
				}
				// Now append the new location
				if (new_item.mExtra > 0)
				{
					agentcounts.push_back(new_item);
				}
				break;
			}
			default:
				break;
		};
	}
}
  void RenderCellMirrorMaskV( Cluster & clus, U32 cellOffset, S32 x, S32 z, U32 clipFlags)
  {
    clipFlags &= ~clipPLANE0;

    S32 x0, xend = x + meterPerClus;
    S32 z0, zend = z + meterPerClus;

    S32 meterStrideX    = heightField.meterPerCell;
    S32 meterStrideZ    = heightField.meterPerCell;
    S32 cellStrideWidth = heightField.cellPitch;

    Cell * c0 = &heightField.cellList[cellOffset];

    VertexC vertmem[25], * dv = vertmem, * ve = vertmem + 25;
    F32 fogs[25], * f = fogs;
    UVPair * uvlist = waterUVList0;
    for (z0 = z; z0 <= zend; z0 += meterStrideZ, c0 += cellStrideWidth)
    {
      Cell * c = c0;
      for (x0 = x; x0 <= xend; x0 += meterStrideX, dv++, c += 1, f++, uvlist++)
      {
        dv->vv.x = (F32) x0;
        dv->vv.z = (F32) z0;
        dv->vv.y = clus.waterHeight;

        dv->nv = waterNorms[0];

        dv->uv = *uvlist;

        dv->diffuse = waterColorMirror;

        if (Vid::Var::Terrain::shroud)
        {
          *f = (F32) c->GetFog() * U8toNormF32;
          dv->diffuse.Modulate( *f, *f, *f);
        }
      }
    }

    if (Vid::Var::Terrain::shroud && clus.shroudCount == 25)
    {
      RenderShroudMirrorMaskV( clus, vertmem, clipFlags);
      return;
    }

    Vid::DrawIndexedPrimitive( 
      PT_TRIANGLELIST,
      FVF_VERTEX,
      vertmem, 25, clusterI, 96, RS_BLEND_MODULATE | renderFlags | ((clipFlags & clipALL) ? 0 : DP_DONOTCLIP) );

    if (waterLayer2)
    {
      U32 a = U32(waterColorMirror.a * *Vid::Var::Terrain::waterAlphaTopFactor);

      UVPair * uvlist = waterUVList1;
      for (dv = vertmem; dv < ve; dv++, uvlist++)
      {
        dv->diffuse.a  = U8(a);
        dv->uv = *uvlist;
      }
      Vid::DrawIndexedPrimitive( 
        PT_TRIANGLELIST,
        FVF_TLVERTEX,
        vertmem, 25, clusterI, 96, RS_BLEND_MODULATE | renderFlags | ((clipFlags & clipALL) ? 0 : DP_DONOTCLIP) );
    }

#ifdef DOSTATISTICS
    if (clipFlags == clipNONE)
    {
      Statistics::noClipTris += 32;
    }
    else
    {
      Statistics::clipTris += 32;
    }
#endif
  }