Esempio n. 1
0
int setup_tests(void **state) {
	/* Register a basic error handler */
	plog_aux = println;

	/* Register some display functions */
	event_add_handler(EVENT_MESSAGE, event_message, NULL);
	event_add_handler(EVENT_INITSTATUS, event_message, NULL);

	/* Init the game */
	set_file_paths();
	init_angband();

	return 0;
}
Esempio n. 2
0
void function_add(const function_data_t &data, const parser_t &parser)
{
    ASSERT_IS_MAIN_THREAD();

    CHECK(! data.name.empty(),);
    CHECK(data.definition,);
    scoped_lock lock(functions_lock);

    /* Remove the old function */
    function_remove(data.name);

    /* Create and store a new function */
    const wchar_t *filename = reader_current_filename();

    int def_offset = -1;
    if (parser.current_block() != NULL)
    {
        def_offset = parser.line_number_of_character_at_offset(parser.current_block()->tok_pos);
    }

    const function_map_t::value_type new_pair(data.name, function_info_t(data, filename, def_offset, is_autoload));
    loaded_functions.insert(new_pair);

    /* Add event handlers */
    for (std::vector<event_t>::const_iterator iter = data.events.begin(); iter != data.events.end(); ++iter)
    {
        event_add_handler(*iter);
    }
}
Esempio n. 3
0
int timer_dispatch()
{
        int curr = _getms();
        struct timer_node *t;
        struct timer_node *last;

        while(__sync_lock_test_and_set(&TIMER->lock, 1))
                ;

        t = TIMER->list;
        last = TIMER->list;
        while (t) {
                if (t->expire <= curr) {
                        struct timer_node *tmp;
                        struct event_handler e;
                        e.ud = t->ud;
                        e.cb = t->cb;
                        event_add_handler(&e);
                        if (last == TIMER->list)
                                TIMER->list = t->next;
                        else
                                last->next = t->next;
                        tmp = t;
                        t = t->next;
                        free(tmp);
                } else {
                        last = t;
                        t = t->next;
                }
        }

        __sync_lock_release(&TIMER->lock);

        return 0;
}
Esempio n. 4
0
int test_prefs(void *state) {
	bool error = FALSE;
	graphics_mode *mode;

	/* This is a bit of a hack to ensure we have a player struct set up */
	/* Otherwise race/class dependent graphics will crash */
	cmdq_push(CMD_BIRTH_RESET);
	cmdq_execute(CMD_BIRTH);

	event_add_handler(EVENT_MESSAGE, getmsg, &error);

	for (mode = graphics_modes; mode; mode = mode->pNext) {
		/* Skip 'normal' */
		if (mode->grafID == 0) continue;

		printf("Testing mode '%s'.\n", mode->menuname);

		/* Load pref file */
		use_graphics = mode->grafID;
		reset_visuals(TRUE);
	}

	eq(error, FALSE);

	ok;
}
Esempio n. 5
0
/**
 * Init the sound "module".
 */
errr init_sound(const char *soundstr, int argc, char **argv)
{
	int i = 0;
	bool done = false;

	/* Try the modules in the order specified by sound_modules[] */
	while (sound_modules[i].init && !done) {
		if (!soundstr || streq(soundstr, sound_modules[i].name))
			if (0 == sound_modules[i].init(&hooks, argc, argv))
				done = true;
		i++;
	}

	/* Check that we have a sound module to use */
	if (!done)
		return 1;

	/* Open the platform specific sound system */
	if (!hooks.open_audio_hook)
		return 1;

	if (!hooks.open_audio_hook())
		return 1;

	/* Enable sound */
	event_add_handler(EVENT_SOUND, play_sound, NULL);
	atexit(close_audio);

	/* Success */
	return (0);
}
Esempio n. 6
0
static void point_based_start(void)
{
	const char *prompt = "[up/down to move, left/right to modify, 'r' to reset, 'Enter' to accept]";

	/* Clear */
	Term_clear();

	/* Display the player */
	display_player_xtra_info();
	display_player_stat_info();

	prt(prompt, Term->hgt - 1, Term->wid / 2 - strlen(prompt) / 2);

	/* Register handlers for various events - cheat a bit because we redraw
	   the lot at once rather than each bit at a time. */
	event_add_handler(EVENT_BIRTHPOINTS, point_based_points, NULL);	
	event_add_handler(EVENT_STATS, point_based_stats, NULL);	
	event_add_handler(EVENT_GOLD, point_based_misc, NULL);	
}
Esempio n. 7
0
/**
 * Init some stuff
 *
 * This function is used to keep the "path" variable off the stack.
 */
static void init_stuff(void)
{
	char path[1024];

	/* Prepare the path XXX XXX XXX */
	/* This must in some way prepare the "path" variable */
	/* so that it points at the "lib" directory.  Every */
	/* machine handles this in a different way... */
	my_strcpy(path, "XXX XXX XXX", sizeof(path));

	/* Prepare the filepaths */
	init_file_paths(path, path, path);

	/* Set up sound hook */
	event_add_handler(EVENT_SOUND, xxx_sound, NULL);
}
Esempio n. 8
0
void activate(void) {
	create_text_splat(kl("title_1"), 18, 0, &title_1);
	create_text_splat(kl("title_2"), 24, 0, &title_2);
	create_text_splat(kl("byline"), 8, 0, &rotator[0]);
	create_text_splat(kl("ludum"), 8, 0, &rotator[1]);
	create_text_splat(kl("any_key"), 8, 0, &rotator[2]);
	rotate_index = 0;
	rotate_timeout = ROTATE_INTERVAL;
	event_add_handler(&any_key_handler, on_any_key, SDL_KEYUP);
	input_timeout = INPUT_SUPPRESS;
	
	backlight = sprite_thing_get(building_window_backlight);
	foreground = sprite_thing_get(building_window_fg);
	bottom = sprite_thing_get(building_fullwidth);
	dude.type = dude_stand;
	walking = false;
	action_interval = 0;
	position = -24;
}
Esempio n. 9
0
void function_add(const function_data_t &data, const parser_t &parser, int definition_line_offset) {
    ASSERT_IS_MAIN_THREAD();

    CHECK(!data.name.empty(), );
    CHECK(data.definition, );
    scoped_lock locker(functions_lock);

    // Remove the old function.
    function_remove(data.name);

    // Create and store a new function.
    const wchar_t *filename = reader_current_filename();

    const function_map_t::value_type new_pair(
        data.name, function_info_t(data, filename, definition_line_offset, is_autoload));
    loaded_functions.insert(new_pair);

    // Add event handlers.
    for (std::vector<event_t>::const_iterator iter = data.events.begin(); iter != data.events.end();
         ++iter) {
        event_add_handler(*iter);
    }
}
Esempio n. 10
0
void ui_init_birthstate_handlers(void)
{
	event_add_handler(EVENT_ENTER_BIRTH, ui_enter_birthscreen, NULL);
	event_add_handler(EVENT_LEAVE_BIRTH, ui_leave_birthscreen, NULL);
}