<commit_before>/world/TgsNew(datum/tgs_event_handler/event_handler)
	var/tgs_version = world.params[TGS_VERSION_PARAMETER]
	if(!tgs_version)
		return

	var/path = SelectTgsApi(tgs_version)
	if(!path)
		TGS_ERROR_LOG("Found unsupported API version: [tgs_version]. If this is a valid version please report this, backporting is done on demand.")

	var/datum/tgs_api/new_api = new path
	TGS_INFO_LOG("Activated tgstation-server API for version [tgs_version]")

	var/result = new_api.OnWorldNew(event_handler ? event_handler : new /datum/tgs_event_handler/tgs_default)
	if(result && result != TGS_UNIMPLEMENTED)
		TGS_WRITE_GLOBAL(tgs, new_api)

/world/proc/SelectTgsApi(tgs_version)
	var/list/version_bits = splittext(tgs_version, ".")

	var/super = text2num(version_bits[0])
	var/major = text2num(version_bits[1])
	var/minor = text2num(version_bits[2])
	var/patch = text2num(version_bits[3])

	switch(super)
		if(3)
			switch(major)
				if(2)
					return /datum/tgs_api/v3210

	if(super != null && major != null && minor != null && patch != null && tgs_version > TgsMaximumAPIVersion())
		TGS_ERROR_LOG("Detected unknown API version! Defaulting to latest. Update the DMAPI to fix this problem.")
		return /datum/tgs_api/latest

/world/TgsMaximumAPIVersion()
	return "4.0.0.0"

/world/TgsMinimumAPIVersion()
	return "3.2.0.0"

/world/TgsInitializationComplete()
	var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs)
	if(api)<commit_msg>Fix activation message occuring for failed instatiations<commit_after>/world/TgsNew(datum/tgs_event_handler/event_handler)
	var/tgs_version = world.params[TGS_VERSION_PARAMETER]
	if(!tgs_version)
		return

	var/path = SelectTgsApi(tgs_version)
	if(!path)
		TGS_ERROR_LOG("Found unsupported API version: [tgs_version]. If this is a valid version please report this, backporting is done on demand.")

	TGS_INFO_LOG("Activating API for version [tgs_version]")
	var/datum/tgs_api/new_api = new path

	var/result = new_api.OnWorldNew(event_handler ? event_handler : new /datum/tgs_event_handler/tgs_default)
	if(result && result != TGS_UNIMPLEMENTED)
		TGS_WRITE_GLOBAL(tgs, new_api)
	else
		TGS_ERROR_LOG("Failed to activate API!")

/world/proc/SelectTgsApi(tgs_version)
	var/list/version_bits = splittext(tgs_version, ".")

	var/super = text2num(version_bits[0])
	var/major = text2num(version_bits[1])
	var/minor = text2num(version_bits[2])
	var/patch = text2num(version_bits[3])

	switch(super)
		if(3)
			switch(major)
				if(2)
					return /datum/tgs_api/v3210

	if(super != null && major != null && minor != null && patch != null && tgs_version > TgsMaximumAPIVersion())
		TGS_ERROR_LOG("Detected unknown API version! Defaulting to latest. Update the DMAPI to fix this problem.")
		return /datum/tgs_api/latest

/world/TgsMaximumAPIVersion()
	return "4.0.0.0"

/world/TgsMinimumAPIVersion()
	return "3.2.0.0"

/world/TgsInitializationComplete()
	var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs)
	if(api)
{'fraction_non_alphanumeric': 0.12038303693570451, 'fraction_numerical': 0.015047879616963064, 'mean_word_length': 5.290322580645161, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '6314108', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1107, 'n_words': 207}