コード例 #1
0
ファイル: anm_bounds.c プロジェクト: GovanifY/thcrap
char* fn_for_bounds(const char *fn)
{
	const char *dir = json_object_get_string(runconfig_get(), "dat_dump");
	const char *prefix = "bounds-";
	size_t ret_len;
	char *ret = NULL;
	char *game_fn = fn_for_game(fn);
	char *p;

	if(!game_fn) {
		return ret;
	}
	if(!dir) {
		dir = "dat";
	}

	ret_len = strlen(dir) + 1 + strlen(prefix) + strlen(game_fn) + 1;
	ret = malloc(ret_len);
	// Start replacements after the directory
	p = ret + strlen(dir);

	sprintf(ret, "%s/%s%s", dir, prefix, game_fn);

	while(*p++) {
		if(*p == '/' || *p == '\\') {
			*p = '-';
		}
	}
	SAFE_FREE(game_fn);
	return ret;
}
コード例 #2
0
ファイル: thcrap_tasofro.cpp プロジェクト: thpatch/thcrap
int __stdcall thcrap_plugin_init()
{
	int base_tasofro_removed = stack_remove_if_unneeded("base_tasofro");
	if (base_tasofro_removed == 1) {
		return 1;
	}

	const char *game = json_object_get_string(runconfig_get(), "game");
	game_id = game_id_from_string(game);

	if(base_tasofro_removed == -1) {
		if(game_id == TH145) {
			log_mboxf(NULL, MB_OK | MB_ICONINFORMATION,
				"Support for TH14.5 has been moved out of the sandbox.\n"
				"\n"
				"Please reconfigure your patch stack; otherwise, you might "
				"encounter errors or missing functionality after further "
				"updates.\n"
			);
		} else {
			return 1;
		}
	}

	if (game_id >= TH135) {
		return th135_init();
	}
	else {
		return nsml_init();
	}

	return 0;
}
コード例 #3
0
ファイル: textdisp.c プロジェクト: GovanifY/thcrap
// Returns 1 if a font rule was applied, 0 otherwise.
int fontrules_apply(LOGFONTA *lf)
{
	json_t *fontrules = json_object_get(runconfig_get(), "fontrules");
	LOGFONTA rep_full = {0};
	int rep_score = 0;
	int log_header = 0;
	const char *key;
	json_t *val;
	if(!lf) {
		return -1;
	}
	json_object_foreach(fontrules, key, val) {
		LOGFONTA rule = {0};
		int rule_score = fontrule_parse(&rule, key);
		int priority = rule_score >= rep_score;
		const char *rep_str = json_string_value(val);
		if(!fontrule_match(&rule, lf)) {
			continue;
		}
		if(!log_header) {
			log_printf(
				"(Font) Replacement rules applied to %s:\n",
				logfont_stringify(lf)
			);
			log_header = 1;
		}
		fontrule_parse(&rule, rep_str);
		log_printf(
			"(Font) • (%s) → (%s)%s\n",
			key, rep_str, priority ? " (priority)" : ""
		);
		fontrule_apply(&rep_full, &rule, priority);
		rep_score = max(rule_score, rep_score);
	}
コード例 #4
0
ファイル: notify.cpp プロジェクト: thpatch/thcrap
int update_notify_thcrap(void)
{
	const size_t SELF_MSG_SLOT = (size_t)self_body;
	self_result_t ret = SELF_NO_UPDATE;
	json_t *run_cfg = runconfig_get();

	json_t *patches = json_object_get(run_cfg, "patches");
	size_t i;
	json_t *patch_info;
	uint32_t min_build = 0;
	json_array_foreach(patches, i, patch_info) {
		auto cur_min_build = json_object_get_hex(patch_info, "thcrap_version_min");
		min_build = max(min_build, cur_min_build);
	}
コード例 #5
0
ファイル: thcrap_tsa.cpp プロジェクト: thpatch/thcrap
int game_is_trial(void)
{
	static int trial = -2;
	if(trial == -2) {
		json_t *build = json_object_get(runconfig_get(), "build");
		const char *build_str = json_string_value(build);
		size_t build_len = json_string_length(build);

		if(!build_str || build_len < 2) {
			return trial = -1;
		}
		assert(
			(build_str[0] == 'v' && (build_str[1] == '0' || build_str[1] == '1'))
			|| !"invalid build format?"
		);

		trial = build_str[1] == '0';
	}
	return trial;
}
コード例 #6
0
ファイル: thcrap_tsa.cpp プロジェクト: thpatch/thcrap
int __stdcall thcrap_plugin_init()
{
	if(stack_remove_if_unneeded("base_tsa")) {
		return 1;
	}

	const char *game = json_object_get_string(runconfig_get(), "game");
	game_id = game_id_from_string(game);

	// th06_msg
	patchhook_register("msg*.dat", patch_msg_dlg, NULL); // th06-08
	patchhook_register("p*.msg", patch_msg_dlg, NULL); // th09
	patchhook_register("s*.msg", patch_msg_dlg, NULL); // lowest common denominator for th10+
	patchhook_register("msg*.msg", patch_msg_dlg, NULL); // th143
	patchhook_register("e*.msg", patch_msg_end, NULL); // th10+ endings

	patchhook_register("*.anm", patch_anm, tlnote_remove_size_hook);
	// Remove TL notes when retrying a stage
	patchhook_register("*.std", nullptr, tlnote_remove_size_hook);
	return 0;
}