PageRenderTime 154ms CodeModel.GetById 64ms app.highlight 83ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/partsyspacket.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 1297 lines | 864 code | 230 blank | 203 comment | 174 complexity | 1b03ab231ff3b2d1dfbe6edc792f8eb5 MD5 | raw file
   1/** 
   2 * @file partsyspacket.cpp
   3 * @brief Object for packing particle system initialization parameters
   4 * before sending them over the network.
   5 *
   6 * $LicenseInfo:firstyear=2000&license=viewerlgpl$
   7 * Second Life Viewer Source Code
   8 * Copyright (C) 2010, Linden Research, Inc.
   9 * 
  10 * This library is free software; you can redistribute it and/or
  11 * modify it under the terms of the GNU Lesser General Public
  12 * License as published by the Free Software Foundation;
  13 * version 2.1 of the License only.
  14 * 
  15 * This library is distributed in the hope that it will be useful,
  16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18 * Lesser General Public License for more details.
  19 * 
  20 * You should have received a copy of the GNU Lesser General Public
  21 * License along with this library; if not, write to the Free Software
  22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  23 * 
  24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  25 * $/LicenseInfo$
  26 */
  27
  28#include "linden_common.h"
  29
  30#include "partsyspacket.h"
  31#include "imageids.h"
  32
  33// this function is global
  34void gSetInitDataDefaults(LLPartInitData *setMe)
  35{
  36	U32 i;
  37
  38	//for(i = 0; i < 18; i++) 
  39	//{
  40	//	setMe->k[i] = 0.0f;
  41	//}
  42
  43	//setMe->kill_p[0] = setMe->kill_p[1] = setMe->kill_p[2] = 0.0f;
  44	//setMe->kill_p[3] = -0.2f; // time parameter, die when t= 5.0f
  45	//setMe->kill_p[4] = 1.0f;
  46	//setMe->kill_p[5] = -0.5f; // or radius == 2 (contracting)
  47	
  48	//setMe->bounce_p[0] = setMe->bounce_p[1] = 
  49	//	setMe->bounce_p[2] = setMe->bounce_p[3] = 0.0f;
  50	//setMe->bounce_p[4] = 1.0f;
  51	
  52	setMe->bounce_b = 1.0f;
  53	// i just changed the meaning of bounce_b
  54	// its now the attenuation from revlecting your velocity across the normal
  55	// set by bounce_p
  56	
  57	//setMe->pos_ranges[0] = setMe->pos_ranges[2] = setMe->pos_ranges[4] = -1.0f;
  58	//setMe->pos_ranges[1] = setMe->pos_ranges[3] = setMe->pos_ranges[5] =  1.0f;
  59
  60	//setMe->vel_ranges[0] = setMe->vel_ranges[2] = setMe->vel_ranges[4] = -1.0f;
  61	//setMe->vel_ranges[1] = setMe->vel_ranges[3] = setMe->vel_ranges[5] =  1.0f;
  62
  63	for(i = 0; i < 3; i++) 
  64	{
  65		setMe->diffEqAlpha[i] = 0.0f;
  66		setMe->diffEqScale[i] = 0.0f;
  67	}
  68
  69	setMe->scale_range[0] = 1.00f;
  70	setMe->scale_range[1] = 5.00f;
  71	setMe->scale_range[2] = setMe->scale_range[3] = 0.0f;
  72
  73	setMe->alpha_range[0] = setMe->alpha_range[1] = 1.0f;
  74	setMe->alpha_range[2] = setMe->alpha_range[3] = 0.0f;
  75
  76	setMe->vel_offset[0] = 0.0f; 
  77	setMe->vel_offset[1] = 0.0f;
  78	setMe->vel_offset[2] = 0.0f; 
  79
  80	// start dropping particles when I'm more then one sim away
  81	setMe->mDistBeginFadeout = 256.0f;
  82	setMe->mDistEndFadeout = 1.414f * 512.0f; 
  83	// stop displaying particles when I'm more then two sim diagonals away
  84
  85	setMe->mImageUuid = IMG_SHOT;
  86
  87	for(i = 0; i < 8; i++)
  88	{
  89		setMe->mFlags[i] = 0x00;
  90	}
  91
  92	setMe->createMe = TRUE;
  93
  94	setMe->maxParticles = 25;
  95	setMe->initialParticles = 25;
  96
  97	//These defaults are for an explosion - a short lived set of debris affected by gravity.
  98		//Action flags default to PART_SYS_AFFECTED_BY_WIND + PART_SYS_AFFECTED_BY_GRAVITY + PART_SYS_DISTANCE_DEATH 
  99	setMe->mFlags[PART_SYS_ACTION_BYTE] = PART_SYS_AFFECTED_BY_WIND | PART_SYS_AFFECTED_BY_GRAVITY | PART_SYS_DISTANCE_DEATH;
 100	setMe->mFlags[PART_SYS_KILL_BYTE] = PART_SYS_DISTANCE_DEATH + PART_SYS_TIME_DEATH;
 101
 102	setMe->killPlaneNormal[0] = 0.0f;setMe->killPlaneNormal[1] = 0.0f;setMe->killPlaneNormal[2] = 1.0f;		//Straight up
 103	setMe->killPlaneZ = 0.0f;	//get local ground z as an approximation if turn on PART_SYS_KILL_PLANE
 104	setMe->bouncePlaneNormal[0] = 0.0f;setMe->bouncePlaneNormal[1] = 0.0f;setMe->bouncePlaneNormal[2] = 1.0f;	//Straight up
 105	setMe->bouncePlaneZ = 0.0f;	//get local ground z as an approximation if turn on PART_SYS_BOUNCE
 106	setMe->spawnRange = 1.0f;
 107	setMe->spawnFrequency = 0.0f;	//Create the instant one dies
 108	setMe->spawnFreqencyRange = 0.0f;
 109	setMe->spawnDirection[0] = 0.0f;setMe->spawnDirection[1] = 0.0f;setMe->spawnDirection[2] = 1.0f;		//Straight up
 110	setMe->spawnDirectionRange = 1.0f;	//global scattering
 111	setMe->spawnVelocity = 0.75f;
 112	setMe->spawnVelocityRange = 0.25f;	//velocity +/- 0.25
 113	setMe->speedLimit = 1.0f;
 114
 115	setMe->windWeight = 0.5f;	//0.0f means looks like a heavy object (if gravity is on), 1.0f means light and fluffy
 116	setMe->currentGravity[0] = 0.0f;setMe->currentGravity[1] = 0.0f;setMe->currentGravity[2] = -9.81f;
 117		//This has to be constant to allow for compression
 118		
 119	setMe->gravityWeight = 0.5f;	//0.0f means boyed by air, 1.0f means it's a lead weight
 120	setMe->globalLifetime = 0.0f;	//Arbitrary, but default is no global die, so doesn't matter
 121	setMe->individualLifetime = 5.0f;
 122	setMe->individualLifetimeRange = 1.0f;	//Particles last 5 secs +/- 1
 123	setMe->alphaDecay = 1.0f;	//normal alpha fadeout
 124	setMe->scaleDecay = 0.0f;	//no scale decay
 125	setMe->distanceDeath = 10.0f;	//die if hit unit radius
 126	setMe->dampMotionFactor = 0.0f;
 127
 128	setMe->windDiffusionFactor[0] = 0.0f; 
 129	setMe->windDiffusionFactor[1] = 0.0f;
 130	setMe->windDiffusionFactor[2] = 0.0f; 
 131}
 132
 133LLPartSysCompressedPacket::LLPartSysCompressedPacket()
 134{
 135	// default constructor for mDefaults called implicitly/automatically here
 136	for(int i = 0; i < MAX_PART_SYS_PACKET_SIZE; i++) 
 137	{
 138		mData[i] = '\0';
 139	}
 140
 141	mNumBytes = 0;
 142
 143	gSetInitDataDefaults(&mDefaults);
 144}
 145
 146LLPartSysCompressedPacket::~LLPartSysCompressedPacket()
 147{
 148	// no dynamic data is stored by this class, do nothing.
 149}
 150
 151void LLPartSysCompressedPacket::writeFlagByte(LLPartInitData *in)
 152{
 153		mData[0] =  mData[1] = mData[2] = '\0';
 154
 155	U32 i;
 156	//for(i = 1; i < 18; i++) {
 157	//	if(in->k[i] != mDefaults.k[i])
 158	//	{
 159	//		mData[0] |= PART_SYS_K_MASK;
 160	//		break;
 161	//	}
 162	//}
 163
 164	if(in->killPlaneZ != mDefaults.killPlaneZ ||
 165		in->killPlaneNormal[0] != mDefaults.killPlaneNormal[0] || 
 166		in->killPlaneNormal[1] != mDefaults.killPlaneNormal[1] ||
 167		in->killPlaneNormal[2] != mDefaults.killPlaneNormal[2] ||
 168		in->distanceDeath != mDefaults.distanceDeath)
 169	{
 170		mData[0] |= PART_SYS_KILL_P_MASK;
 171	}
 172
 173	
 174	
 175	if(in->bouncePlaneZ != mDefaults.bouncePlaneZ ||
 176		in->bouncePlaneNormal[0] != mDefaults.bouncePlaneNormal[0] || 
 177		in->bouncePlaneNormal[1] != mDefaults.bouncePlaneNormal[1] ||
 178		in->bouncePlaneNormal[2] != mDefaults.bouncePlaneNormal[2])
 179	{
 180		mData[0] |= PART_SYS_BOUNCE_P_MASK;
 181	}
 182	
 183	if(in->bounce_b != mDefaults.bounce_b)
 184	{
 185		mData[0] |= PART_SYS_BOUNCE_B_MASK;
 186	}
 187
 188	
 189	//if(in->pos_ranges[0] != mDefaults.pos_ranges[0] || in->pos_ranges[1] != mDefaults.pos_ranges[1] ||
 190	//	in->pos_ranges[2] != mDefaults.pos_ranges[2] || in->pos_ranges[3] != mDefaults.pos_ranges[3] ||
 191	//	in->pos_ranges[4] != mDefaults.pos_ranges[4] || in->pos_ranges[5] != mDefaults.pos_ranges[5])
 192	//{
 193	//	mData[0] |= PART_SYS_POS_RANGES_MASK;
 194	//}
 195	
 196	//if(in->vel_ranges[0] != mDefaults.vel_ranges[0] || in->vel_ranges[1] != mDefaults.vel_ranges[1] ||
 197	//	in->vel_ranges[2] != mDefaults.vel_ranges[2] || in->vel_ranges[3] != mDefaults.vel_ranges[3] ||
 198	//	in->vel_ranges[4] != mDefaults.vel_ranges[4] || in->vel_ranges[5] != mDefaults.vel_ranges[5])
 199	//{
 200//		mData[0] |= PART_SYS_VEL_RANGES_MASK;
 201	//}
 202
 203
 204	if(in->diffEqAlpha[0] != mDefaults.diffEqAlpha[0] || 
 205		in->diffEqAlpha[1] != mDefaults.diffEqAlpha[1] ||
 206		in->diffEqAlpha[2] != mDefaults.diffEqAlpha[2] ||
 207		in->diffEqScale[0] != mDefaults.diffEqScale[0] || 
 208		in->diffEqScale[1] != mDefaults.diffEqScale[1] ||
 209		in->diffEqScale[2] != mDefaults.diffEqScale[2])
 210	{
 211		mData[0] |= PART_SYS_ALPHA_SCALE_DIFF_MASK;
 212	}
 213
 214
 215	if(in->scale_range[0] != mDefaults.scale_range[0] || 
 216		in->scale_range[1] != mDefaults.scale_range[1] ||
 217		in->scale_range[2] != mDefaults.scale_range[2] ||
 218		in->scale_range[3] != mDefaults.scale_range[3])
 219	{
 220		mData[0] |= PART_SYS_SCALE_RANGE_MASK;
 221	}
 222
 223	
 224	if(in->alpha_range[0] != mDefaults.alpha_range[0] || 
 225		in->alpha_range[1] != mDefaults.alpha_range[1] ||
 226		in->alpha_range[2] != mDefaults.alpha_range[2] ||
 227		in->alpha_range[3] != mDefaults.alpha_range[3])
 228	{
 229		mData[2] |= PART_SYS_BYTE_3_ALPHA_MASK;
 230	}
 231
 232	if(in->vel_offset[0] != mDefaults.vel_offset[0] || 
 233		in->vel_offset[1] != mDefaults.vel_offset[1] ||
 234		in->vel_offset[2] != mDefaults.vel_offset[2])
 235	{
 236		mData[0] |= PART_SYS_VEL_OFFSET_MASK;
 237	}
 238
 239
 240	if(in->mImageUuid != mDefaults.mImageUuid)
 241	{
 242		mData[0] |= PART_SYS_M_IMAGE_UUID_MASK;
 243	}
 244
 245	for( i = 0; i < 8; i++)
 246	{
 247		if(in->mFlags[i])
 248		{
 249			mData[1] |= 1<<i;
 250//			llprintline("Flag \"%x\" gets byte \"%x\"\n", i<<i, in->mFlags[i]);
 251		}
 252	}
 253
 254
 255	if(in->spawnRange != mDefaults.spawnRange ||
 256		in->spawnFrequency != mDefaults.spawnFrequency ||
 257		in->spawnFreqencyRange != mDefaults.spawnFreqencyRange ||
 258		in->spawnDirection[0] != mDefaults.spawnDirection[0] || 
 259		in->spawnDirection[1] != mDefaults.spawnDirection[1] ||
 260		in->spawnDirection[2] != mDefaults.spawnDirection[2] ||
 261		in->spawnDirectionRange != mDefaults.spawnDirectionRange ||
 262		in->spawnVelocity != mDefaults.spawnVelocity ||
 263		in->spawnVelocityRange != mDefaults.spawnVelocityRange)
 264	{
 265		mData[3] |= PART_SYS_BYTE_SPAWN_MASK;
 266	}
 267
 268
 269	if(in->windWeight != mDefaults.windWeight ||
 270		in->currentGravity[0] != mDefaults.currentGravity[0] || 
 271		in->currentGravity[1] != mDefaults.currentGravity[1] ||
 272		in->currentGravity[2] != mDefaults.currentGravity[2] ||
 273		in->gravityWeight != mDefaults.gravityWeight)
 274	{
 275		mData[3] |= PART_SYS_BYTE_ENVIRONMENT_MASK;
 276	}
 277
 278	
 279	if(in->globalLifetime != mDefaults.globalLifetime ||
 280		in->individualLifetime != mDefaults.individualLifetime ||
 281		in->individualLifetimeRange != mDefaults.individualLifetimeRange)
 282	{
 283		mData[3] |= PART_SYS_BYTE_LIFESPAN_MASK;
 284	}
 285
 286	
 287	if(in->speedLimit != mDefaults.speedLimit ||
 288		in->alphaDecay != mDefaults.alphaDecay ||
 289		in->scaleDecay != mDefaults.scaleDecay ||
 290		in->dampMotionFactor != mDefaults.dampMotionFactor)
 291	{
 292		mData[3] |= PART_SYS_BYTE_DECAY_DAMP_MASK;
 293	}
 294
 295	if(in->windDiffusionFactor[0] != mDefaults.windDiffusionFactor[0] || 
 296		in->windDiffusionFactor[1] != mDefaults.windDiffusionFactor[1] ||
 297		in->windDiffusionFactor[2] != mDefaults.windDiffusionFactor[2])
 298	{
 299		mData[3] |= PART_SYS_BYTE_WIND_DIFF_MASK;
 300	}
 301}
 302
 303F32 floatFromTwoBytes(S8 bMant, S8 bExp)
 304{
 305	F32 result = bMant;
 306	while(bExp > 0) 
 307	{
 308		result *= 2.0f;
 309		bExp--;
 310	}
 311	while(bExp < 0) 
 312	{
 313		result *= 0.5f;
 314		bExp++;
 315	}
 316	return result;
 317}
 318
 319void twoBytesFromFloat(F32 fIn, S8 &bMant, S8 &bExp)
 320{
 321	bExp = 0;
 322	if(fIn > 127.0f)
 323	{
 324		fIn = 127.0f;
 325	}
 326	if(fIn < -127.0f)
 327	{
 328		fIn = -127.0f;
 329	}
 330	while(fIn < 64 && fIn > -64 && bExp > -127) 
 331	{
 332		fIn *= 2.0f;
 333		bExp--;
 334	}
 335	while((fIn > 128 || fIn < -128) && bExp < 127)
 336	{
 337		fIn *= 0.5f;
 338		bExp++;
 339	}
 340	bMant = (S8)fIn;
 341}
 342
 343	
 344
 345/*
 346U32 LLPartSysCompressedPacket::writeK(LLPartInitData *in, U32 startByte)
 347{
 348	U32 i, kFlag, i_mod_eight;
 349	S8 bMant, bExp;
 350
 351	kFlag = startByte;
 352
 353	startByte += 3; // 3 bytes contain enough room for 18 flag bits
 354	mData[kFlag] = 0x00;
 355//	llprintline("In the writeK\n");
 356
 357	i_mod_eight = 0;
 358	for(i = 0; i < 18; i++) 
 359	{
 360		if(in->k[i] != mDefaults.k[i]) 
 361		{
 362
 363			mData[kFlag] |= 1<<i_mod_eight;
 364			twoBytesFromFloat(in->k[i], bMant, bExp);
 365
 366			mData[startByte++] = bMant;
 367			mData[startByte++] = bExp;
 368		}
 369		i_mod_eight++;
 370		while(i_mod_eight >= 8) 
 371		{
 372			kFlag++;
 373			i_mod_eight -= 8;
 374		}
 375	}
 376	
 377	return startByte;
 378}*/
 379
 380U32 LLPartSysCompressedPacket::writeKill_p(LLPartInitData *in, U32 startByte)
 381{
 382	S8 bMant, bExp;
 383
 384	twoBytesFromFloat(in->killPlaneNormal[0], bMant, bExp);
 385	mData[startByte++] = bMant;
 386	mData[startByte++] = bExp;
 387	twoBytesFromFloat(in->killPlaneNormal[1], bMant, bExp);
 388	mData[startByte++] = bMant;
 389	mData[startByte++] = bExp;
 390	twoBytesFromFloat(in->killPlaneNormal[2], bMant, bExp);
 391	mData[startByte++] = bMant;
 392	mData[startByte++] = bExp;
 393	
 394	twoBytesFromFloat(in->killPlaneZ, bMant, bExp);
 395	mData[startByte++] = bMant;
 396	mData[startByte++] = bExp;
 397	twoBytesFromFloat(in->distanceDeath, bMant, bExp);
 398	mData[startByte++] = bMant;
 399	mData[startByte++] = bExp;
 400
 401	return startByte;
 402}
 403
 404U32 LLPartSysCompressedPacket::writeBounce_p(LLPartInitData *in, U32 startByte)
 405{
 406	S8 bMant, bExp;
 407
 408	twoBytesFromFloat(in->bouncePlaneNormal[0], bMant, bExp);
 409	mData[startByte++] = bMant;
 410	mData[startByte++] = bExp;
 411	twoBytesFromFloat(in->bouncePlaneNormal[1], bMant, bExp);
 412	mData[startByte++] = bMant;
 413	mData[startByte++] = bExp;
 414	twoBytesFromFloat(in->bouncePlaneNormal[2], bMant, bExp);
 415	mData[startByte++] = bMant;
 416	mData[startByte++] = bExp;
 417	
 418
 419	twoBytesFromFloat(in->bouncePlaneZ, bMant, bExp);
 420	mData[startByte++] = bMant;
 421	mData[startByte++] = bExp;
 422
 423	return startByte;
 424}
 425
 426U32 LLPartSysCompressedPacket::writeBounce_b(LLPartInitData *in, U32 startByte)
 427{
 428	S8 bMant, bExp;
 429	twoBytesFromFloat(in->bounce_b, bMant, bExp);
 430	mData[startByte++] = bMant;
 431	mData[startByte++] = bExp;
 432	return startByte;
 433}
 434
 435//U32 LLPartSysCompressedPacket::writePos_ranges(LLPartInitData *in, U32 startByte)
 436//{
 437//	S8 tmp;
 438//	int i;
 439//	for(i = 0; i < 6; i++)
 440//	{
 441//		tmp = (S8) in->pos_ranges[i]; // float to int conversion (keep the sign)
 442//		mData[startByte++] = (U8)tmp; // signed to unsigned typecast
 443//	}
 444//	return startByte;
 445//}
 446
 447//U32 LLPartSysCompressedPacket::writeVel_ranges(LLPartInitData *in, U32 startByte)
 448//{
 449//	S8 tmp;
 450//	int i;
 451//	for(i = 0; i < 6; i++)
 452//	{
 453//		tmp = (S8) in->vel_ranges[i]; // float to int conversion (keep the sign)
 454//		mData[startByte++] = (U8)tmp; // signed to unsigned typecast
 455//	}
 456//	return startByte;
 457//}
 458
 459U32 LLPartSysCompressedPacket::writeAlphaScaleDiffEqn_range(LLPartInitData *in, U32 startByte)
 460{
 461	S8 bExp, bMant;
 462	int i;
 463	for(i = 0; i < 3; i++)
 464	{
 465		twoBytesFromFloat(in->diffEqAlpha[i], bMant, bExp);
 466		mData[startByte++] = bMant;
 467		mData[startByte++] = bExp;
 468	}
 469	for(i = 0; i < 3; i++)
 470	{
 471		twoBytesFromFloat(in->diffEqScale[i], bMant, bExp);
 472		mData[startByte++] = bMant;
 473		mData[startByte++] = bExp;
 474	}
 475	return startByte;
 476}
 477
 478U32 LLPartSysCompressedPacket::writeScale_range(LLPartInitData *in, U32 startByte)
 479{
 480	S8 bExp, bMant;
 481	int i;
 482	for(i = 0; i < 4; i++)
 483	{
 484		twoBytesFromFloat(in->scale_range[i], bMant, bExp);
 485		mData[startByte++] = bMant;
 486		mData[startByte++] = bExp;
 487	}
 488	return startByte;
 489}
 490
 491
 492U32 LLPartSysCompressedPacket::writeAlpha_range(LLPartInitData *in, U32 startByte)
 493{
 494	S8 bExp, bMant;
 495	int i;
 496	for(i = 0; i < 4; i++)
 497	{
 498		twoBytesFromFloat(in->alpha_range[i], bMant, bExp);
 499		mData[startByte++] = bMant;
 500		mData[startByte++] = bExp;
 501	}
 502	return startByte;
 503}
 504
 505U32 LLPartSysCompressedPacket::writeVelocityOffset(LLPartInitData *in, U32 startByte)
 506{
 507	S8 bExp, bMant;
 508	int i;
 509	for(i = 0; i < 3; i++)
 510	{
 511		twoBytesFromFloat(in->vel_offset[i], bMant, bExp);
 512		mData[startByte++] = bMant;
 513		mData[startByte++] = bExp;
 514	}
 515	return startByte;
 516}
 517
 518U32 LLPartSysCompressedPacket::writeUUID(LLPartInitData *in, U32 startByte)
 519{
 520	U8 * bufPtr = mData + startByte;
 521	if(in->mImageUuid == IMG_SHOT) {
 522		mData[startByte++] = 0x01;
 523		return startByte;
 524	}
 525
 526	if(in->mImageUuid == IMG_SPARK) {
 527		mData[startByte++] = 0x02;
 528		return startByte;
 529	}
 530
 531	
 532	if(in->mImageUuid == IMG_BIG_EXPLOSION_1) {
 533		mData[startByte++] = 0x03;
 534		return startByte;
 535	}
 536
 537	if(in->mImageUuid == IMG_BIG_EXPLOSION_2) {
 538		mData[startByte++] = 0x04;
 539		return startByte;
 540	}
 541
 542
 543	if(in->mImageUuid == IMG_SMOKE_POOF) {
 544		mData[startByte++] = 0x05;
 545		return startByte;
 546	}
 547
 548	if(in->mImageUuid == IMG_FIRE) {
 549		mData[startByte++] = 0x06;
 550		return startByte;
 551	}
 552
 553	
 554	if(in->mImageUuid == IMG_EXPLOSION) {
 555		mData[startByte++] = 0x07;
 556		return startByte;
 557	}
 558
 559	if(in->mImageUuid == IMG_EXPLOSION_2) {
 560		mData[startByte++] = 0x08;
 561		return startByte;
 562	}
 563
 564	
 565	if(in->mImageUuid == IMG_EXPLOSION_3) {
 566		mData[startByte++] = 0x09;
 567		return startByte;
 568	}
 569
 570	if(in->mImageUuid == IMG_EXPLOSION_4) {
 571		mData[startByte++] = 0x0A;
 572		return startByte;
 573	}
 574
 575	mData[startByte++] = 0x00; // flag for "read whole UUID"
 576
 577	memcpy(bufPtr, in->mImageUuid.mData, 16);		/* Flawfinder: ignore */
 578	return (startByte+16);
 579}
 580
 581U32 LLPartSysCompressedPacket::writeSpawn(LLPartInitData *in, U32 startByte)
 582{
 583	S8 bExp, bMant;
 584	int i;
 585
 586	twoBytesFromFloat(in->spawnRange, bMant, bExp);
 587	mData[startByte++] = bMant;
 588	mData[startByte++] = bExp;
 589	twoBytesFromFloat(in->spawnFrequency, bMant, bExp);
 590	mData[startByte++] = bMant;
 591	mData[startByte++] = bExp;
 592	twoBytesFromFloat(in->spawnFreqencyRange, bMant, bExp);
 593	mData[startByte++] = bMant;
 594	mData[startByte++] = bExp;
 595
 596	
 597	
 598	for(i = 0; i < 3; i++)
 599	{
 600		twoBytesFromFloat(in->spawnDirection[i], bMant, bExp);
 601		mData[startByte++] = bMant;
 602		mData[startByte++] = bExp;
 603	}
 604
 605	twoBytesFromFloat(in->spawnDirectionRange, bMant, bExp);
 606	mData[startByte++] = bMant;
 607	mData[startByte++] = bExp;
 608	twoBytesFromFloat(in->spawnVelocity, bMant, bExp);
 609	mData[startByte++] = bMant;
 610	mData[startByte++] = bExp;
 611	twoBytesFromFloat(in->spawnVelocityRange, bMant, bExp);
 612	mData[startByte++] = bMant;
 613	mData[startByte++] = bExp;
 614
 615	return startByte;
 616}
 617
 618U32 LLPartSysCompressedPacket::writeEnvironment(LLPartInitData *in, U32 startByte)
 619{
 620	S8 bExp, bMant;
 621	int i;
 622
 623	twoBytesFromFloat(in->windWeight, bMant, bExp);
 624	mData[startByte++] = bMant;
 625	mData[startByte++] = bExp;
 626
 627	for(i = 0; i < 3; i++)
 628	{
 629		twoBytesFromFloat(in->currentGravity[i], bMant, bExp);
 630		mData[startByte++] = bMant;
 631		mData[startByte++] = bExp;
 632	}
 633
 634	twoBytesFromFloat(in->gravityWeight, bMant, bExp);
 635	mData[startByte++] = bMant;
 636	mData[startByte++] = bExp;
 637	return startByte;
 638}	
 639	
 640U32 LLPartSysCompressedPacket::writeLifespan(LLPartInitData *in, U32 startByte)
 641{
 642	S8 bExp, bMant;
 643
 644	twoBytesFromFloat(in->globalLifetime, bMant, bExp);
 645	mData[startByte++] = bMant;
 646	mData[startByte++] = bExp;
 647
 648	twoBytesFromFloat(in->individualLifetime, bMant, bExp);
 649	mData[startByte++] = bMant;
 650	mData[startByte++] = bExp;
 651
 652	twoBytesFromFloat(in->individualLifetimeRange, bMant, bExp);
 653	mData[startByte++] = bMant;
 654	mData[startByte++] = bExp;
 655
 656	return startByte;
 657}
 658	
 659
 660U32 LLPartSysCompressedPacket::writeDecayDamp(LLPartInitData *in, U32 startByte)
 661{
 662	S8 bExp, bMant;
 663
 664	twoBytesFromFloat(in->speedLimit, bMant, bExp);
 665	mData[startByte++] = bMant;
 666	mData[startByte++] = bExp;
 667
 668	twoBytesFromFloat(in->alphaDecay, bMant, bExp);
 669	mData[startByte++] = bMant;
 670	mData[startByte++] = bExp;
 671
 672	twoBytesFromFloat(in->scaleDecay, bMant, bExp);
 673	mData[startByte++] = bMant;
 674	mData[startByte++] = bExp;
 675
 676	twoBytesFromFloat(in->dampMotionFactor, bMant, bExp);
 677	mData[startByte++] = bMant;
 678	mData[startByte++] = bExp;
 679
 680	return startByte;
 681}
 682
 683U32 LLPartSysCompressedPacket::writeWindDiffusionFactor(LLPartInitData *in, U32 startByte)
 684{
 685	S8 bExp, bMant;
 686
 687	twoBytesFromFloat(in->windDiffusionFactor[0], bMant, bExp);
 688	mData[startByte++] = bMant;
 689	mData[startByte++] = bExp;
 690
 691	twoBytesFromFloat(in->windDiffusionFactor[1], bMant, bExp);
 692	mData[startByte++] = bMant;
 693	mData[startByte++] = bExp;
 694
 695	twoBytesFromFloat(in->windDiffusionFactor[2], bMant, bExp);
 696	mData[startByte++] = bMant;
 697	mData[startByte++] = bExp;
 698
 699	return startByte;
 700}
 701
 702
 703
 704
 705
 706	
 707/*
 708U32 LLPartSysCompressedPacket::readK(LLPartInitData *in, U32 startByte)
 709{
 710	U32 i, i_mod_eight, kFlag;
 711	S8 bMant, bExp; // 1 bytes mantissa and exponent for a float
 712	kFlag = startByte;
 713	startByte += 3; // 3 bytes has enough room for 18 bits
 714
 715	i_mod_eight = 0;
 716	for(i = 0; i < 18; i++) 
 717	{
 718		if(mData[kFlag]&(1<<i_mod_eight))  
 719		{
 720
 721			
 722		
 723			bMant = mData[startByte++];
 724			bExp = mData[startByte++];
 725		
 726			
 727			in->k[i] = floatFromTwoBytes(bMant, bExp); // much tighter platform-independent
 728			//                                            way to ship floats
 729
 730		}
 731		i_mod_eight++;
 732		if(i_mod_eight >= 8)
 733		{
 734			i_mod_eight -= 8;
 735			kFlag++;
 736		}
 737	}
 738	
 739	return startByte;
 740}
 741*/
 742
 743U32 LLPartSysCompressedPacket::readKill_p(LLPartInitData *in, U32 startByte)
 744{
 745	S8 bMant, bExp;
 746
 747	bMant = mData[startByte++];
 748	bExp = mData[startByte++];
 749	in->killPlaneNormal[0] = floatFromTwoBytes(bMant, bExp);
 750	bMant = mData[startByte++];
 751	bExp = mData[startByte++];
 752	in->killPlaneNormal[1] = floatFromTwoBytes(bMant, bExp);
 753	bMant = mData[startByte++];
 754	bExp = mData[startByte++];
 755	in->killPlaneNormal[2] = floatFromTwoBytes(bMant, bExp);
 756
 757	bMant = mData[startByte++];
 758	bExp = mData[startByte++];
 759	in->killPlaneZ = floatFromTwoBytes(bMant, bExp);
 760	bMant = mData[startByte++];
 761	bExp = mData[startByte++];
 762	in->distanceDeath = floatFromTwoBytes(bMant, bExp);
 763
 764	return startByte;
 765}
 766
 767U32 LLPartSysCompressedPacket::readBounce_p(LLPartInitData *in, U32 startByte)
 768{
 769
 770	S8 bMant, bExp;
 771
 772	bMant = mData[startByte++];
 773	bExp = mData[startByte++];
 774	in->bouncePlaneNormal[0] = floatFromTwoBytes(bMant, bExp);
 775	bMant = mData[startByte++];
 776	bExp = mData[startByte++];
 777	in->bouncePlaneNormal[1] = floatFromTwoBytes(bMant, bExp);
 778	bMant = mData[startByte++];
 779	bExp = mData[startByte++];
 780	in->bouncePlaneNormal[2] = floatFromTwoBytes(bMant, bExp);
 781
 782	bMant = mData[startByte++];
 783	bExp = mData[startByte++];
 784	in->bouncePlaneZ = floatFromTwoBytes(bMant, bExp);
 785
 786	return startByte;
 787}
 788
 789U32 LLPartSysCompressedPacket::readBounce_b(LLPartInitData *in, U32 startByte)
 790{
 791	S8 bMant, bExp;
 792	bMant = mData[startByte++];
 793	bExp = mData[startByte++];
 794	in->bounce_b = floatFromTwoBytes(bMant, bExp);
 795	return startByte;
 796}
 797
 798
 799//U32 LLPartSysCompressedPacket::readPos_ranges(LLPartInitData *in, U32 startByte)
 800//{
 801//	S8 tmp;
 802//	int i;
 803//	for(i = 0; i < 6; i++)
 804//	{
 805//		tmp = (S8)mData[startByte++];
 806//		in->pos_ranges[i] = tmp;
 807//	}
 808//	return startByte;
 809//}
 810
 811//U32 LLPartSysCompressedPacket::readVel_ranges(LLPartInitData *in, U32 startByte)
 812//{
 813//	S8 tmp;
 814//	int i;
 815//	for(i = 0; i < 6; i++)
 816//	{
 817//		tmp = (S8)mData[startByte++];
 818//		in->vel_ranges[i] = tmp;
 819//	}
 820//	return startByte;
 821//}
 822
 823
 824
 825U32 LLPartSysCompressedPacket::readAlphaScaleDiffEqn_range(LLPartInitData *in, U32 startByte)
 826{
 827	int i;
 828	S8 bMant, bExp;
 829	for(i = 0; i < 3; i++)
 830	{
 831		bMant = mData[startByte++];
 832		bExp = mData[startByte++];
 833		in->diffEqAlpha[i] = floatFromTwoBytes(bMant, bExp);
 834	}
 835	for(i = 0; i < 3; i++)
 836	{
 837		bMant = mData[startByte++];
 838		bExp = mData[startByte++];
 839		in->diffEqScale[i] = floatFromTwoBytes(bMant, bExp);
 840	}
 841	return startByte;
 842}
 843
 844U32 LLPartSysCompressedPacket::readAlpha_range(LLPartInitData *in, U32 startByte)
 845{
 846	int i;
 847	S8 bMant, bExp;
 848	for(i = 0; i < 4; i++)
 849	{
 850		bMant = mData[startByte++];
 851		bExp = mData[startByte++];
 852		in->alpha_range[i] = floatFromTwoBytes(bMant, bExp);
 853	}
 854	return startByte;
 855}
 856
 857U32 LLPartSysCompressedPacket::readScale_range(LLPartInitData *in, U32 startByte)
 858{
 859	int i;
 860	S8 bMant, bExp;
 861	for(i = 0; i < 4; i++)
 862	{
 863		bMant = mData[startByte++];
 864		bExp = mData[startByte++];
 865		in->scale_range[i] = floatFromTwoBytes(bMant, bExp);
 866	}
 867	return startByte;
 868}
 869
 870U32 LLPartSysCompressedPacket::readVelocityOffset(LLPartInitData *in, U32 startByte)
 871{
 872	int i;
 873	S8 bMant, bExp;
 874	for(i = 0; i < 3; i++)
 875	{
 876		bMant = mData[startByte++];
 877		bExp = mData[startByte++];
 878		in->vel_offset[i] = floatFromTwoBytes(bMant, bExp);
 879	}
 880	return startByte;
 881}
 882
 883U32 LLPartSysCompressedPacket::readUUID(LLPartInitData *in, U32 startByte)
 884{
 885	U8 * bufPtr = mData + startByte;
 886	
 887	if(mData[startByte] == 0x01)
 888	{
 889		in->mImageUuid = IMG_SHOT;
 890		return startByte+1;
 891	}
 892	if(mData[startByte] == 0x02)
 893	{
 894		in->mImageUuid = IMG_SPARK;
 895		return startByte+1;
 896	}
 897	if(mData[startByte] == 0x03)
 898	{
 899		in->mImageUuid = IMG_BIG_EXPLOSION_1;
 900		return startByte+1;
 901	}
 902	if(mData[startByte] == 0x04)
 903	{
 904		in->mImageUuid = IMG_BIG_EXPLOSION_2;
 905		return startByte+1;
 906	}
 907	if(mData[startByte] == 0x05)
 908	{
 909		in->mImageUuid = IMG_SMOKE_POOF;
 910		return startByte+1;
 911	}
 912	if(mData[startByte] == 0x06)
 913	{
 914		in->mImageUuid = IMG_FIRE;
 915		return startByte+1;
 916	}
 917	if(mData[startByte] == 0x07)
 918	{
 919		in->mImageUuid = IMG_EXPLOSION;
 920		return startByte+1;
 921	}
 922	if(mData[startByte] == 0x08)
 923	{
 924		in->mImageUuid = IMG_EXPLOSION_2;
 925		return startByte+1;
 926	}
 927	if(mData[startByte] == 0x09)
 928	{
 929		in->mImageUuid = IMG_EXPLOSION_3;
 930		return startByte+1;
 931	}
 932	if(mData[startByte] == 0x0A)
 933	{
 934		in->mImageUuid = IMG_EXPLOSION_4;
 935		return startByte+1;
 936	}
 937
 938	startByte++; // cause we actually have to read the UUID now.
 939	memcpy(in->mImageUuid.mData, bufPtr, 16);		/* Flawfinder: ignore */
 940	return (startByte+16);
 941}
 942
 943
 944
 945
 946U32 LLPartSysCompressedPacket::readSpawn(LLPartInitData *in, U32 startByte)
 947{
 948	S8 bMant, bExp;
 949	U32	i;
 950
 951	bMant = mData[startByte++];
 952	bExp = mData[startByte++];
 953	in->spawnRange = floatFromTwoBytes(bMant, bExp);
 954	bMant = mData[startByte++];
 955	bExp = mData[startByte++];
 956	in->spawnFrequency = floatFromTwoBytes(bMant, bExp);
 957	bMant = mData[startByte++];
 958	bExp = mData[startByte++];
 959	in->spawnFreqencyRange = floatFromTwoBytes(bMant, bExp);
 960
 961	for(i = 0; i < 3; i++)
 962	{
 963		bMant = mData[startByte++];
 964		bExp = mData[startByte++];
 965		in->spawnDirection[i] = floatFromTwoBytes(bMant, bExp);
 966	}
 967
 968	bMant = mData[startByte++];
 969	bExp = mData[startByte++];
 970	in->spawnDirectionRange = floatFromTwoBytes(bMant, bExp);
 971	bMant = mData[startByte++];
 972	bExp = mData[startByte++];
 973	in->spawnVelocity = floatFromTwoBytes(bMant, bExp);
 974	bMant = mData[startByte++];
 975	bExp = mData[startByte++];
 976	in->spawnVelocityRange = floatFromTwoBytes(bMant, bExp);
 977
 978	return startByte;
 979}
 980
 981U32 LLPartSysCompressedPacket::readEnvironment(LLPartInitData *in, U32 startByte)
 982{
 983	S8 bMant, bExp;
 984	U32	i;
 985
 986
 987	bMant = mData[startByte++];
 988	bExp = mData[startByte++];
 989	in->windWeight = floatFromTwoBytes(bMant, bExp);
 990
 991	for(i = 0; i < 3; i++)
 992	{
 993		bMant = mData[startByte++];
 994		bExp = mData[startByte++];
 995		in->currentGravity[i] = floatFromTwoBytes(bMant, bExp);
 996	}
 997
 998	bMant = mData[startByte++];
 999	bExp = mData[startByte++];
1000	in->gravityWeight = floatFromTwoBytes(bMant, bExp);
1001
1002	return startByte;
1003}
1004
1005U32 LLPartSysCompressedPacket::readLifespan(LLPartInitData *in, U32 startByte)
1006{
1007	S8 bMant, bExp;
1008
1009	bMant = mData[startByte++];
1010	bExp = mData[startByte++];
1011	in->globalLifetime = floatFromTwoBytes(bMant, bExp);
1012	bMant = mData[startByte++];
1013	bExp = mData[startByte++];
1014	in->individualLifetime = floatFromTwoBytes(bMant, bExp);
1015	bMant = mData[startByte++];
1016	bExp = mData[startByte++];
1017	in->individualLifetimeRange = floatFromTwoBytes(bMant, bExp);
1018
1019	return startByte;
1020}
1021
1022U32 LLPartSysCompressedPacket::readDecayDamp(LLPartInitData *in, U32 startByte)
1023{
1024	S8 bMant, bExp;
1025
1026	bMant = mData[startByte++];
1027	bExp = mData[startByte++];
1028	in->speedLimit = floatFromTwoBytes(bMant, bExp);
1029	bMant = mData[startByte++];
1030	bExp = mData[startByte++];
1031	in->alphaDecay = floatFromTwoBytes(bMant, bExp);
1032	bMant = mData[startByte++];
1033	bExp = mData[startByte++];
1034	in->scaleDecay = floatFromTwoBytes(bMant, bExp);
1035	bMant = mData[startByte++];
1036	bExp = mData[startByte++];
1037	in->dampMotionFactor = floatFromTwoBytes(bMant, bExp);
1038
1039	return startByte;
1040}
1041
1042U32 LLPartSysCompressedPacket::readWindDiffusionFactor(LLPartInitData *in, U32 startByte)
1043{
1044	int i;
1045	S8 bMant, bExp;
1046	for(i = 0; i < 3; i++)
1047	{
1048		bMant = mData[startByte++];
1049		bExp = mData[startByte++];
1050		in->windDiffusionFactor[i] = floatFromTwoBytes(bMant, bExp);
1051	}
1052	return startByte;
1053}
1054
1055BOOL LLPartSysCompressedPacket::fromLLPartInitData(LLPartInitData *in, U32 &bytesUsed)
1056{
1057
1058	writeFlagByte(in);
1059	U32 currByte = 4;
1060	
1061//	llprintline("calling \"fromLLPartInitData\"\n");
1062
1063	//if(mData[0] & PART_SYS_K_MASK)
1064	//{
1065	//	currByte = writeK(in, 3); // first 3 bytes are reserved for header data
1066	//}
1067	
1068
1069
1070	if(mData[0] & PART_SYS_KILL_P_MASK)
1071	{
1072		currByte = writeKill_p(in, currByte);
1073	}
1074	
1075	if(mData[0] & PART_SYS_BOUNCE_P_MASK)
1076	{
1077		currByte = writeBounce_p(in, currByte);
1078	}
1079	
1080	if(mData[0] & PART_SYS_BOUNCE_B_MASK)
1081	{
1082		currByte = writeBounce_b(in, currByte);
1083	}
1084	
1085	//if(mData[0] & PART_SYS_POS_RANGES_MASK)
1086	//{
1087	//	currByte = writePos_ranges(in, currByte);
1088	//}
1089	
1090	//if(mData[0] & PART_SYS_VEL_RANGES_MASK)
1091	//{
1092	//	currByte = writeVel_ranges(in, currByte);
1093	//}
1094
1095	if(mData[0] & PART_SYS_ALPHA_SCALE_DIFF_MASK)
1096	{
1097		currByte = writeAlphaScaleDiffEqn_range(in, currByte);
1098	}
1099	
1100	if(mData[0] & PART_SYS_SCALE_RANGE_MASK)
1101	{
1102		currByte = writeScale_range(in, currByte);
1103	}
1104	
1105	if(mData[0] & PART_SYS_VEL_OFFSET_MASK)
1106	{
1107		currByte = writeVelocityOffset(in, currByte);
1108	}
1109
1110	if(mData[0] & PART_SYS_M_IMAGE_UUID_MASK)
1111	{
1112		currByte = writeUUID(in, currByte);
1113	}
1114	
1115
1116	if(mData[3] & PART_SYS_BYTE_SPAWN_MASK)
1117	{
1118		currByte = writeSpawn(in, currByte);
1119	}
1120	
1121	if(mData[3] & PART_SYS_BYTE_ENVIRONMENT_MASK)
1122	{
1123		currByte = writeEnvironment(in, currByte);
1124	}
1125	
1126	if(mData[3] & PART_SYS_BYTE_LIFESPAN_MASK)
1127	{
1128		currByte = writeLifespan(in, currByte);
1129	}
1130	
1131	if(mData[3] & PART_SYS_BYTE_DECAY_DAMP_MASK)
1132	{
1133		currByte = writeDecayDamp(in, currByte);
1134	}
1135	
1136	if(mData[3] & PART_SYS_BYTE_WIND_DIFF_MASK)
1137	{
1138		currByte = writeWindDiffusionFactor(in, currByte);
1139	}
1140	
1141
1142	if(mData[2] & PART_SYS_BYTE_3_ALPHA_MASK)
1143	{
1144		currByte = writeAlpha_range(in, currByte);
1145	}
1146
1147	mData[currByte++] = (U8)in->maxParticles;
1148	mData[currByte++] = (U8)in->initialParticles;
1149
1150
1151	U32 flagFlag = 1; // flag indicating which flag bytes are non-zero
1152	//                   yeah, I know, the name sounds funny
1153	for(U32 i = 0; i < 8; i++)
1154	{
1155	
1156//		llprintline("Flag \"%x\" gets byte \"%x\"\n", flagFlag, in->mFlags[i]);
1157		if(mData[1] & flagFlag)
1158		{
1159			mData[currByte++] = in->mFlags[i];
1160//			llprintline("and is valid...\n");
1161		}
1162		flagFlag <<= 1;
1163	}
1164
1165	bytesUsed = mNumBytes = currByte;
1166	
1167	
1168	
1169//	llprintline("returning from \"fromLLPartInitData\" with %d bytes\n", bytesUsed);
1170	
1171	return TRUE;
1172}
1173
1174BOOL LLPartSysCompressedPacket::toLLPartInitData(LLPartInitData *out, U32 *bytesUsed)
1175{
1176	U32 currByte = 4;
1177
1178	gSetInitDataDefaults(out);
1179
1180	if(mData[0] & PART_SYS_KILL_P_MASK)
1181	{
1182		currByte = readKill_p(out, currByte);
1183	}
1184	
1185	if(mData[0] & PART_SYS_BOUNCE_P_MASK)
1186	{
1187		currByte = readBounce_p(out, currByte);
1188	}
1189	
1190	if(mData[0] & PART_SYS_BOUNCE_B_MASK)
1191	{
1192		currByte = readBounce_b(out, currByte);
1193	}
1194	
1195	if(mData[0] & PART_SYS_ALPHA_SCALE_DIFF_MASK)
1196	{
1197		currByte = readAlphaScaleDiffEqn_range(out, currByte);
1198	}
1199	
1200	if(mData[0] & PART_SYS_SCALE_RANGE_MASK)
1201	{
1202		currByte = readScale_range(out, currByte);
1203	}
1204	
1205	if(mData[0] & PART_SYS_VEL_OFFSET_MASK)
1206	{
1207		currByte = readVelocityOffset(out, currByte);
1208	}
1209	
1210	if(mData[0] & PART_SYS_M_IMAGE_UUID_MASK)
1211	{
1212		currByte = readUUID(out, currByte);
1213	}
1214	
1215
1216	if(mData[3] & PART_SYS_BYTE_SPAWN_MASK)
1217	{
1218		currByte = readSpawn(out, currByte);
1219	}
1220	
1221	if(mData[3] & PART_SYS_BYTE_ENVIRONMENT_MASK)
1222	{
1223		currByte = readEnvironment(out, currByte);
1224	}
1225	
1226	if(mData[3] & PART_SYS_BYTE_LIFESPAN_MASK)
1227	{
1228		currByte = readLifespan(out, currByte);
1229	}
1230	
1231	if(mData[3] & PART_SYS_BYTE_DECAY_DAMP_MASK)
1232	{
1233		currByte = readDecayDamp(out, currByte);
1234	}
1235	
1236	if(mData[3] & PART_SYS_BYTE_WIND_DIFF_MASK)
1237	{
1238		currByte = readWindDiffusionFactor(out, currByte);
1239	}
1240	
1241	if(mData[2] & PART_SYS_BYTE_3_ALPHA_MASK)
1242	{
1243		currByte = readAlpha_range(out, currByte);
1244	}
1245
1246	out->maxParticles = mData[currByte++];
1247	out->initialParticles = mData[currByte++];
1248
1249	U32 flagFlag = 1; // flag indicating which flag bytes are non-zero
1250	//                   yeah, I know, the name sounds funny
1251	for(U32 i = 0; i < 8; i++)
1252	{
1253		flagFlag = 1<<i;
1254	
1255		if((mData[1] & flagFlag))
1256		{
1257			out->mFlags[i] = mData[currByte++];
1258		}
1259	}
1260
1261	*bytesUsed = currByte;
1262	return TRUE;
1263}
1264
1265BOOL LLPartSysCompressedPacket::fromUnsignedBytes(U8 *in, U32 bytesUsed)
1266{
1267	if ((in != NULL) && (bytesUsed <= sizeof(mData)))
1268	{
1269		memcpy(mData, in, bytesUsed);	/* Flawfinder: ignore */
1270		mNumBytes = bytesUsed;
1271		return TRUE;
1272	}
1273	else
1274	{
1275		llerrs << "NULL input data or number of bytes exceed mData size" << llendl;
1276		return FALSE;
1277	}
1278}		
1279	
1280
1281U32 LLPartSysCompressedPacket::bufferSize()
1282{
1283	return mNumBytes;
1284}
1285
1286BOOL LLPartSysCompressedPacket::toUnsignedBytes(U8 *out)
1287{
1288	memcpy(out, mData, mNumBytes);		/* Flawfinder: ignore */
1289	return TRUE;
1290}
1291
1292U8 * LLPartSysCompressedPacket::getBytePtr()
1293{
1294	return mData;
1295}
1296
1297