コード例 #1
0
ファイル: ext-thread.c プロジェクト: bsmr-games/lipsofsuna
static void private_thread_main (
	LISysThread* thread,
	void*        data)
{
	LIExtThread* self = data;

	if (self->code != NULL)
	{
		if (!limai_program_execute_string (self->program, self->code))
			lisys_error_report ();
	}
	else
	{
		if (!limai_program_execute_script (self->program, self->file))
			lisys_error_report ();
	}
}
コード例 #2
0
ファイル: main.c プロジェクト: MuskofEphesus/GodHeadLips
int main (int argc, char** argv)
{
	char* path;
	char* launch_name;
	char* launch_args;
	LIMaiProgram* program;

	/* Resolve game directory. */
	path = lipth_paths_get_root ();
	if (path == NULL)
	{
		lisys_error_report ();
		return 1;
	}

	/* Parse command line arguments. */
	launch_name = "default";
	launch_args = NULL;
	if (!private_parse_arguments (argc, argv, &launch_name, &launch_args))
	{
		lisys_error_report ();
		lisys_free (path);
		return 1;
	}

	/* Start the program. */
	program = limai_program_new (path, launch_name, launch_args);
	lisys_free (launch_args);
	if (program == NULL)
	{
		lisys_error_report ();
		lisys_free (path);
		return 1;
	}

	/* Execute mods until one exits without starting a new one. */
	while (program != NULL)
	{
		/* Execute the module until the script exits. */
		if (!limai_program_execute_script (program, "main.lua"))
		{
			lisys_error_report ();
			break;
		}

		/* Check if the module started another one. */
		launch_name = program->launch_name;
		launch_args = program->launch_args;
		if (launch_name == NULL)
			break;
		program->launch_name = NULL;
		program->launch_args = NULL;
		limai_program_free (program);

		/* Unload the old module and load a new one. */
		program = limai_program_new (path, launch_name, launch_args);
		lisys_free (launch_name);
		lisys_free (launch_args);
		if (program == NULL)
		{
			lisys_error_report ();
			break;
		}
	}

	/* Free all resources. */
	limai_program_free (program);
	lisys_free (path);
	SDL_Quit ();

	return 0;
}