<commit_before>#include "EFFECT2.H"

#include "SPECIFIC.H"
#include "GAMEFLOW.H"
#include "LARA.H"
#include "CONTROL.H"
#include "DRAW.H"
#include "TOMB4FX.H"
#include "EFFECTS.H"

#ifdef PC_VERSION
#include "GAME.H"
#else
#include "SETUP.H"
#endif

#if PSX_VERSION || PSXPC_VERSION || SAT_VERSION
#include "MISC.H"
#include "CALCLARA.H"
#endif


long wibble;
long SplashCount;
long KillEverythingFlag;
long next_spark;

unsigned char TES_extra_tab[] =
{
	0x00, 0x04, 0x07, 0x0A, 0x00, 0x00
};

long DeadlyBounds[6];
struct SPLASH_STRUCT splashes[4];
struct RIPPLE_STRUCT ripples[32];
struct DYNAMIC dynamics[64];
struct SPLASH_SETUP splash_setup;
struct SP_DYNAMIC spark_dynamics[8];
long SmokeWeapon;
long SmokeWindX;
long SmokeWindZ;
long SmokeCountL;
long SmokeCountR;
struct SPARKS spark[128];

void ControlEnemyMissile(short fx_number)//342D0, 347D0
{
	UNIMPLEMENTED();
}

void ControlSmokeEmitter(short item_number)//338B8, 33DB8
{
	UNIMPLEMENTED();
}

void KillEverything()//338AC(<), 33DAC(<) (F)
{
	KillEverythingFlag = 0;
}

void KillAllCurrentItems(short item_number)//3389C, 33D9C (F)
{
	KillEverythingFlag = 1;
}

void TriggerDartSmoke(long x, long y, long z, long xv, long zv, long hit)//335B8, 33AB8
{
	UNIMPLEMENTED();
}

void TriggerWaterfallMist(long x, long y, long z, long angle)//331B4, 336B4
{
	UNIMPLEMENTED();
}

void TriggerSuperJetFlame(struct ITEM_INFO* item, long yvel, long deadly)//32EAC, 333AC (F)
{
	long dx = lara_item->pos.x_pos - item->pos.x_pos;
	long dz = lara_item->pos.z_pos - item->pos.z_pos;

	if (ABS(dx) <= 16384 && ABS(dz) <= 16384)
	{
		long size = (GetRandomControl() & 0x1FF) - yvel;
		struct SPARKS* sptr = &spark[GetFreeSpark()];

		if (size < 512)
			size = 512;

		sptr->On = 1;

		sptr->sR = sptr->sG = (GetRandomControl() & 0x1F) + 48;
		sptr->sB = (GetRandomControl() & 0x3F) - 64;

		sptr->dR = (GetRandomControl() & 0x3F) - 64;
		sptr->dG = (GetRandomControl() & 0x3F) - 128;
		sptr->dB = 32;
		

		sptr->ColFadeSpeed = 8;
		sptr->FadeToBlack = 8;
		sptr->TransType = 2;

		sptr->Life = sptr->sLife = (size >> 9) + (GetRandomControl() & 7) + 16;

		sptr->x = (GetRandomControl() & 0x1F) + item->pos.x_pos - 16;
		sptr->y = (GetRandomControl() & 0x1F) + item->pos.y_pos - 16;
		sptr->z = (GetRandomControl() & 0x1F) + item->pos.z_pos - 16;

		sptr->Friction = 51;
		sptr->MaxYvel = 0;
		
		sptr->Flags = 538;
		if (deadly)
			sptr->Flags = 539;
		sptr->Scalar = 2;

		sptr->dSize = (GetRandomControl() & 0xF) + (size >> 6) + 16;
		sptr->sSize = sptr->Size = sptr->dSize >> 1;

		if ((-(item->trigger_flags & 0xFF) & 7) == 1)
		{
			sptr->Gravity = -16 - (GetRandomControl() & 0x1F);
			sptr->Xvel = (GetRandomControl() & 0xFF) - 128;
			sptr->Yvel = -size;
			sptr->Zvel = (GetRandomControl() & 0xFF) - 128;
			sptr->dSize += sptr->dSize >> 2;
			return;
		}

		sptr->y -= 64;
		sptr->Gravity = -((size >> 9) + GetRandomControl() % (size >> 8));
		sptr->Yvel = (GetRandomControl() & 0xFF) - 128;
		sptr->Xvel = (GetRandomControl() & 0xFF) - 128;
		sptr->Zvel = (GetRandomControl() & 0xFF) - 128;

		if (item->pos.y_rot == 0)
		{
			sptr->Zvel = -(size - (size >> 2));
		}
		else if (item->pos.y_rot == ANGLE(90))
		{
			sptr->Xvel = -(size - (size >> 2));
		}
		else if (item->pos.y_rot == ANGLE(-180))
		{
			sptr->Zvel = size - (size >> 2);
		}
		else
		{
			sptr->Xvel = size - (size >> 2);
		}
	}
}

void DetatchSpark(long num, long type)//32D8C, 3328C (F)
{
	struct FX_INFO* fx = &effects[num];
	struct ITEM_INFO* item = &items[num];	
	struct SPARKS* sptr = &spark[0];

	long lp;
	for(lp = 0; lp < 1024; lp++, sptr++)
	{
		if (sptr->On && sptr->Flags & type && sptr->FxObj == num)
		{
			if (type == 64)
			{
				sptr->x += fx->pos.x_pos;
				sptr->y += fx->pos.y_pos;
				sptr->z += fx->pos.z_pos;

				sptr->Flags &= 0xBF;
			}
			else if(type == 128)
			{
				sptr->x += item->pos.x_pos;
				sptr->y += item->pos.y_pos;
				sptr->z += item->pos.z_pos;

				sptr->Flags &= 0x7F;
			}
		}
	}
}

void TriggerGunSmoke(long x, long y, long z, long xv, long yv, long zv, int a7, int a8, int a9)//8D6D4(<), 8F718(<) (F)
{
	struct SMOKE_SPARKS* spark = &smoke_spark[GetFreeSmokeSpark()];
	unsigned char life, size;

	spark->On = 1;
	spark->sShade = 0;
	spark->dShade = 4 * a9;
	spark->ColFadeSpeed = 4;
	spark->FadeToBlack = 32 - 16 * a7;
	life = (GetRandomControl() & 3) + 40;
	spark->Life = life;
	spark->sLife = life;
	if ((a8 == 1 || a8 == 2 || a8 == 3) && spark->dShade > 64)
		spark->dShade = 64;
	spark->TransType = 2;
	spark->x = (GetRandomControl() & 0x1F) + x - 16;
	spark->y = (GetRandomControl() & 0x1F) + y - 16;
	spark->z = (GetRandomControl() & 0x1F) + z - 16;<commit_msg>[Game]: Disable code trashing memory.<commit_after>#include "EFFECT2.H"

#include "SPECIFIC.H"
#include "GAMEFLOW.H"
#include "LARA.H"
#include "CONTROL.H"
#include "DRAW.H"
#include "TOMB4FX.H"
#include "EFFECTS.H"

#ifdef PC_VERSION
#include "GAME.H"
#else
#include "SETUP.H"
#endif

#if PSX_VERSION || PSXPC_VERSION || SAT_VERSION
#include "MISC.H"
#include "CALCLARA.H"
#endif


long wibble;
long SplashCount;
long KillEverythingFlag;
long next_spark;

unsigned char TES_extra_tab[] =
{
	0x00, 0x04, 0x07, 0x0A, 0x00, 0x00
};

long DeadlyBounds[6];
struct SPLASH_STRUCT splashes[4];
struct RIPPLE_STRUCT ripples[32];
struct DYNAMIC dynamics[64];
struct SPLASH_SETUP splash_setup;
struct SP_DYNAMIC spark_dynamics[8];
long SmokeWeapon;
long SmokeWindX;
long SmokeWindZ;
long SmokeCountL;
long SmokeCountR;
struct SPARKS spark[128];

void ControlEnemyMissile(short fx_number)//342D0, 347D0
{
	UNIMPLEMENTED();
}

void ControlSmokeEmitter(short item_number)//338B8, 33DB8
{
	UNIMPLEMENTED();
}

void KillEverything()//338AC(<), 33DAC(<) (F)
{
	KillEverythingFlag = 0;
}

void KillAllCurrentItems(short item_number)//3389C, 33D9C (F)
{
	KillEverythingFlag = 1;
}

void TriggerDartSmoke(long x, long y, long z, long xv, long zv, long hit)//335B8, 33AB8
{
	UNIMPLEMENTED();
}

void TriggerWaterfallMist(long x, long y, long z, long angle)//331B4, 336B4
{
	UNIMPLEMENTED();
}

void TriggerSuperJetFlame(struct ITEM_INFO* item, long yvel, long deadly)//32EAC, 333AC (F)
{
	long dx = lara_item->pos.x_pos - item->pos.x_pos;
	long dz = lara_item->pos.z_pos - item->pos.z_pos;

	if (ABS(dx) <= 16384 && ABS(dz) <= 16384)
	{
		long size = (GetRandomControl() & 0x1FF) - yvel;
		struct SPARKS* sptr = &spark[GetFreeSpark()];

		if (size < 512)
			size = 512;

		sptr->On = 1;

		sptr->sR = sptr->sG = (GetRandomControl() & 0x1F) + 48;
		sptr->sB = (GetRandomControl() & 0x3F) - 64;

		sptr->dR = (GetRandomControl() & 0x3F) - 64;
		sptr->dG = (GetRandomControl() & 0x3F) - 128;
		sptr->dB = 32;
		

		sptr->ColFadeSpeed = 8;
		sptr->FadeToBlack = 8;
		sptr->TransType = 2;

		sptr->Life = sptr->sLife = (size >> 9) + (GetRandomControl() & 7) + 16;

		sptr->x = (GetRandomControl() & 0x1F) + item->pos.x_pos - 16;
		sptr->y = (GetRandomControl() & 0x1F) + item->pos.y_pos - 16;
		sptr->z = (GetRandomControl() & 0x1F) + item->pos.z_pos - 16;

		sptr->Friction = 51;
		sptr->MaxYvel = 0;
		
		sptr->Flags = 538;
		if (deadly)
			sptr->Flags = 539;
		sptr->Scalar = 2;

		sptr->dSize = (GetRandomControl() & 0xF) + (size >> 6) + 16;
		sptr->sSize = sptr->Size = sptr->dSize >> 1;

		if ((-(item->trigger_flags & 0xFF) & 7) == 1)
		{
			sptr->Gravity = -16 - (GetRandomControl() & 0x1F);
			sptr->Xvel = (GetRandomControl() & 0xFF) - 128;
			sptr->Yvel = -size;
			sptr->Zvel = (GetRandomControl() & 0xFF) - 128;
			sptr->dSize += sptr->dSize >> 2;
			return;
		}

		sptr->y -= 64;
		sptr->Gravity = -((size >> 9) + GetRandomControl() % (size >> 8));
		sptr->Yvel = (GetRandomControl() & 0xFF) - 128;
		sptr->Xvel = (GetRandomControl() & 0xFF) - 128;
		sptr->Zvel = (GetRandomControl() & 0xFF) - 128;

		if (item->pos.y_rot == 0)
		{
			sptr->Zvel = -(size - (size >> 2));
		}
		else if (item->pos.y_rot == ANGLE(90))
		{
			sptr->Xvel = -(size - (size >> 2));
		}
		else if (item->pos.y_rot == ANGLE(-180))
		{
			sptr->Zvel = size - (size >> 2);
		}
		else
		{
			sptr->Xvel = size - (size >> 2);
		}
	}
}

void DetatchSpark(long num, long type)//32D8C, 3328C (F)
{
#if 0///@FIXME this is trashing memory!
	struct FX_INFO* fx = &effects[num];
	struct ITEM_INFO* item = &items[num];	
	struct SPARKS* sptr = &spark[0];

	long lp;
	for(lp = 0; lp < 1024; lp++, sptr++)
	{
		if (sptr->On && sptr->Flags & type && sptr->FxObj == num)
		{
			if (type == 64)
			{
				sptr->x += fx->pos.x_pos;
				sptr->y += fx->pos.y_pos;
				sptr->z += fx->pos.z_pos;

				sptr->Flags &= 0xBF;
			}
			else if(type == 128)
			{
				sptr->x += item->pos.x_pos;
				sptr->y += item->pos.y_pos;
				sptr->z += item->pos.z_pos;

				sptr->Flags &= 0x7F;
			}
		}
	}
#endif
}

void TriggerGunSmoke(long x, long y, long z, long xv, long yv, long zv, int a7, int a8, int a9)//8D6D4(<), 8F718(<) (F)
{
	struct SMOKE_SPARKS* spark = &smoke_spark[GetFreeSmokeSpark()];
	unsigned char life, size;

	spark->On = 1;
	spark->sShade = 0;
	spark->dShade = 4 * a9;
	spark->ColFadeSpeed = 4;
	spark->FadeToBlack = 32 - 16 * a7;
	life = (GetRandomControl() & 3) + 40;
	spark->Life = life;
	spark->sLife = life;
	if ((a8 == 1 || a8 == 2 || a8 == 3) && spark->dShade > 64)
		spark->dShade = 64;
	spark->TransType = 2;
	spark->x = (GetRandomControl() & 0x1F) + x - 16;
	spark->y = (GetRandomControl() & 0x1F) + y - 16;
	spark->z = (GetRandomControl() & 0x1F) + z - 16;
{'fraction_non_alphanumeric': 0.18542267820882763, 'fraction_numerical': 0.055466495671689646, 'mean_word_length': 3.3975563909774436, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 205, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6835650', 'n_tokens_mistral': 4821, 'n_tokens_neox': 4083, 'n_words': 892}