<commit_before>#include "SeqProjectHeaders.h"
#include "SeqList.h"
#include "SeqSerializer.h"
#include "SeqString.h"
#include "SeqTime.h"

SeqScene::SeqScene(int id, const char *sceneName) :
	id(id),
	nextActionId(0)
{
	name = SeqString::Copy(sceneName);
	channels = new SeqList<SeqChannel*>();
}

SeqScene::SeqScene(SeqSerializer *serializer):
	id(0),
	name(nullptr),
	nextActionId(0)
{
	channels = new SeqList<SeqChannel*>();
	Deserialize(serializer);
}

SeqScene::~SeqScene()
{
	for (int i = 0; i < channels->Count(); i++)
		delete channels->Get(i);
	delete channels;
	delete[] name;
}

void SeqScene::AddChannel(SeqChannelType type, const char *name)
{
	SeqChannel *channel = new SeqChannel(this, name, type);
	AddChannel(channel);
}

void SeqScene::AddChannel(SeqChannel *channel)
{
	channels->Add(channel);
	if (channel->actionId == -1)
		channel->actionId = NextActionId();
	else if (channel->actionId >= nextActionId)
		nextActionId = channel->actionId + 1;
}

void SeqScene::RemoveChannel(const int index)
{
	channels->RemoveAt(index);
}

int SeqScene::GetChannelCount()
{
	return channels->Count();
}

SeqChannel* SeqScene::GetChannel(const int index)
{
	return channels->Get(index);
}

SeqChannel* SeqScene::GetChannelByActionId(const int id)
{
	return GetChannel(GetChannelIndexByActionId(id));
}

int SeqScene::GetChannelIndexByActionId(const int id)
{
	for (int i = 0; i < channels->Count(); i++)
		if (channels->Get(i)->actionId == id)
			return i;
	return -1;
}

int64_t SeqScene::GetLength()
{
	return SEQ_TIME(60.54321);
}

int SeqScene::NextActionId()
{
	return nextActionId++;
}

void SeqScene::Serialize(SeqSerializer *serializer)
{
	serializer->Write(id);
	serializer->Write(name);
	serializer->Write(channels->Count());
	for (int i = 0; i < channels->Count(); i++)
		channels->Get(i)->Serialize(serializer);
}

void SeqScene::Deserialize(SeqSerializer *serializer)
{
	id = serializer->ReadInt();
	name = serializer->ReadString();
	int count = serializer->ReadInt();
	for (int i = 0; i < count; i++)
	{
		SeqChannel *channel = new SeqChannel(this, serializer);
		AddChannel(channel);
	}
}
<commit_msg>This should have been part of previous commit...<commit_after>#include "SeqProjectHeaders.h"
#include "SeqList.h"
#include "SeqSerializer.h"
#include "SeqString.h"
#include "SeqTime.h"

SeqScene::SeqScene(int id, const char *sceneName) :
	id(id),
	lastClip(nullptr),
	nextActionId(0)
{
	name = SeqString::Copy(sceneName);
	channels = new SeqList<SeqChannel*>();
}

SeqScene::SeqScene(SeqSerializer *serializer):
	id(0),
	name(nullptr),
	lastClip(nullptr),
	nextActionId(0)
{
	channels = new SeqList<SeqChannel*>();
	Deserialize(serializer);
}

SeqScene::~SeqScene()
{
	for (int i = 0; i < channels->Count(); i++)
		delete channels->Get(i);
	delete channels;
	delete[] name;
}

void SeqScene::AddChannel(SeqChannelType type, const char *name)
{
	SeqChannel *channel = new SeqChannel(this, name, type);
	AddChannel(channel);
}

void SeqScene::AddChannel(SeqChannel *channel)
{
	channels->Add(channel);
	if (channel->actionId == -1)
		channel->actionId = NextActionId();
	else if (channel->actionId >= nextActionId)
		nextActionId = channel->actionId + 1;
}

void SeqScene::RemoveChannel(const int index)
{
	channels->RemoveAt(index);
}

int SeqScene::GetChannelCount()
{
	return channels->Count();
}

SeqChannel* SeqScene::GetChannel(const int index)
{
	return channels->Get(index);
}

SeqChannel* SeqScene::GetChannelByActionId(const int id)
{
	return GetChannel(GetChannelIndexByActionId(id));
}

int SeqScene::GetChannelIndexByActionId(const int id)
{
	for (int i = 0; i < channels->Count(); i++)
		if (channels->Get(i)->actionId == id)
			return i;
	return -1;
}

void SeqScene::RefreshLastClip()
{
	lastClip = nullptr;
	int64_t latestTime = 0;
	for (int i = 0; i < channels->Count(); i++)
	{
		SeqChannel *channel = channels->Get(i);
		for (int j = 0; j < channel->ClipCount(); j++)
		{
			SeqClip *clip = channel->GetClip(j);
			int64_t rightTime = clip->location.rightTime;
			if (rightTime > latestTime)
			{
				latestTime = rightTime;
				lastClip = clip;
			}
		}
	}
}

int64_t SeqScene::GetLength()
{
	if (lastClip != nullptr)
		return lastClip->location.rightTime;
	else
		return SEQ_TIME_BASE;
}

int SeqScene::NextActionId()
{
	return nextActionId++;
}

void SeqScene::Serialize(SeqSerializer *serializer)
{
	serializer->Write(id);
	serializer->Write(name);
	serializer->Write(channels->Count());
	for (int i = 0; i < channels->Count(); i++)
		channels->Get(i)->Serialize(serializer);
}

void SeqScene::Deserialize(SeqSerializer *serializer)
{
	id = serializer->ReadInt();
	name = serializer->ReadString();
	int count = serializer->ReadInt();
	for (int i = 0; i < count; i++)
	{
		SeqChannel *channel = new SeqChannel(this, serializer);
		AddChannel(channel);
	}
	RefreshLastClip();
}

{'fraction_non_alphanumeric': 0.1603401783862269, 'fraction_numerical': 0.00788218211989214, 'mean_word_length': 5.463806970509383, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 62, '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': '4786552', 'n_tokens_mistral': 1778, 'n_tokens_neox': 1726, 'n_words': 369}