예제 #1
0
static bonus_data_t * create_bonus(const char* text, int value) {
    char* buf, buf2[15];
    bonus_data_t * ret;
    ret = calloc(1,sizeof(bonus_data_t));

    ret->bonus=value;

    /*On initialise le nouveau bonus */
    if (value>0) {
        if (sprintf(buf2, ": %d pts" ,value) == -1) {
            buf2[0]='\0';
        }
    } else {
        buf2[0]='\0';
    }

    if (asprintf(&buf, "%s%s" , text,buf2 ) != -1) {
        ret->bonus_string=buf;
    } else ret->bonus_string = NULL;


    ret->start_time = g_game.time;

    player_data_t* plyr = get_player_data(local_player());
    ret->pos = plyr->pos;
    return ret;
}
예제 #2
0
short count_inventory_lines(short player_index)
{
	player_data *player= get_player_data(player_index);
	bool types[NUMBER_OF_ITEM_TYPES];
	short count= 0;
	short loop;
	
	/* Clean out the header array, so we can count properly */
	for(loop = 0; loop < NUMBER_OF_ITEM_TYPES; ++loop)
		types[loop]= false;
	
	for(loop = 0; loop<NUMBER_OF_DEFINED_ITEMS; ++loop)
	{
		if (loop==_i_knife) continue;
		if (player->items[loop] != NONE)
		{
			count++;
			types[get_item_kind(loop)]= true;
		}
	}
	
	/* Now add in the header lines.. */
	for(loop= 0; loop<NUMBER_OF_ITEM_TYPES; ++loop)
	{
		if(types[loop]) count++;
	}
	
	return count;
}
예제 #3
0
파일: devices.c 프로젝트: DrItanium/moo
void update_action_key(
	short player_index,
	boolean triggered)
{
	short               object_index;
	short               minimum_distance= 0;
	short               target_type;
	struct player_data  *player= get_player_data(player_index);
	
	if(triggered) 
	{
		object_index= find_action_key_target(player_index, MAXIMUM_ACTIVATION_RANGE, &target_type);

		if(object_index != NONE)
		{
			switch(target_type) 
			{
				case _target_is_platform:
					player_touch_platform_state(player_index, object_index);
					break;
				case _target_is_control_panel:
					change_panel_state(player_index, object_index);
					break;

				default:
					vhalt(csprintf(temporary, "%d is not a valid target type", target_type));
					break;
			}
		}
	}
}
예제 #4
0
void game_over_init(void)
{
    winsys_set_display_func( main_loop );
    winsys_set_idle_func( main_loop );
    winsys_set_reshape_func( reshape );
    winsys_set_mouse_func( mouse_cb );
    winsys_set_motion_func( ui_event_motion_func );
    winsys_set_passive_motion_func( ui_event_motion_func );

    remove_all_bonuses();

    halt_sound( "flying_sound" );
    halt_sound( "rock_sound" );
    halt_sound( "ice_sound" );
    halt_sound( "snow_sound" );

    play_music( "game_over" );

    aborted = g_game.race_aborted;

    if ( !aborted ) {
        update_player_score( get_player_data( local_player() ) );
    }

    if ( (!g_game.practicing &&!aborted) || (!g_game.practicing && aborted && !game_abort_is_for_tutorial())) {
        race_won = was_current_race_won();
        init_starting_tutorial_step(-100);
    }

    g_game.needs_save_or_display_rankings=false;
    g_game.rankings_displayed=false;
}
예제 #5
0
// ZZZ: If not already in predictive mode, save off partial game-state for later restoration.
static void
enter_predictive_mode()
{
	if(sPredictedTicks == 0)
	{
		for(short i = 0; i < dynamic_world->player_count; i++)
		{
			sSavedPlayerData[i] = *get_player_data(i);
			if(sSavedPlayerData[i].monster_index != NONE)
			{
				sSavedPlayerMonsterData[i] = *get_monster_data(sSavedPlayerData[i].monster_index);
				if(sSavedPlayerMonsterData[i].object_index != NONE)
				{
					sSavedPlayerObjectData[i] = *get_object_data(sSavedPlayerMonsterData[i].object_index);
					sSavedPlayerObjectNextObject[i] = sSavedPlayerObjectData[i].next_object;
					if(sSavedPlayerObjectData[i].parasitic_object != NONE)
						sSavedPlayerParasiticObjectData[i] = *get_object_data(sSavedPlayerObjectData[i].parasitic_object);
				}
			}
		}
		
		// Sanity checking
		sSavedTickCount = dynamic_world->tick_count;
		sSavedRandomSeed = get_random_seed();
	}
}
예제 #6
0
void bonus_init() {
    assert(bonus_list == NULL);

    player_data_t* plyr = get_player_data(local_player());
    plyr->bonus_tricks=0;

    int i;
    for (i=0; i<8; i++) {
        tricks_count[i]=-1;
    }

    /* On assigne des score plus importants aux tricks pour le half pipe, f fois plus important */
    int f;
    if (!strcmp(get_calculation_mode(),"Half_Pipe")) {
        f=4;
    } else {
        f=1;
    }
    score_for_trick[HYPER_HEAVY_JUMP]=240*f;
    score_for_trick[RAY_STAR_HYBRID_JUMP]=250*f;
    score_for_trick[ROLL_LEFT]=120*f;
    score_for_trick[ROLL_RIGHT]=120*f;
    score_for_trick[SATURN_ICE_FEVER]=230*f;
    score_for_trick[WILD_PINGUIN_SHOW]=200*f;
    score_for_trick[BACK_FLIP]=80*f;
    score_for_trick[BARLOWS_WHEEL]=160*f;
}
예제 #7
0
static bool Lua_Scenery_Valid(int32 index)
{
	if (index < 0 || index >= MAXIMUM_OBJECTS_PER_MAP)
		return false;

	object_data *object = GetMemberWithBounds(objects, index, MAXIMUM_OBJECTS_PER_MAP);
	if (SLOT_IS_USED(object))
	{
		if (GET_OBJECT_OWNER(object) == _object_is_scenery) 
			return true;
		else if (GET_OBJECT_OWNER(object) == _object_is_normal)
		{
			// check to make sure it's not a player's legs or torso
			for (int player_index = 0; player_index < dynamic_world->player_count; player_index++)
			{
				player_data *player = get_player_data(player_index);
				monster_data *monster = get_monster_data(player->monster_index);
				if (monster->object_index == index) 
					return false;
				else
				{
					object_data *object = get_object_data(monster->object_index);
					if (object->parasitic_object == index)
						return false;
				}
			}

			return true;
		}
	}

	return false;
}
예제 #8
0
void adjust_player_for_polygon_height_change(
	short monster_index,
	short polygon_index,
	world_distance new_floor_height,
	world_distance new_ceiling_height)
{
	short player_index= monster_index_to_player_index(monster_index);
	struct player_data *player= get_player_data(player_index);
	struct physics_variables *variables= &player->variables;
	struct polygon_data *polygon= get_polygon_data(polygon_index);
	world_distance old_floor_height= polygon->floor_height;

	(void) (new_ceiling_height);

	if (player->supporting_polygon_index==polygon_index)
	{
		if (FIXED_TO_WORLD(variables->position.z)<=old_floor_height) /* must be <= */
		{
			variables->floor_height= variables->position.z= WORLD_TO_FIXED(new_floor_height);
			if (film_profile.fix_sliding_on_platforms && variables->external_velocity.k < 0) 
			{
				variables->external_velocity.k = 0;
			}

			if (PLAYER_IS_DEAD(player)) variables->external_velocity.k= 0;
		}
	}
}
예제 #9
0
static void m2_swipe_nearby_items(short player_index)
{
	object_data *object;
	object_data *player_object;
	player_data *player= get_player_data(player_index);
	short next_object;
	polygon_data *polygon;
	short *neighbor_indexes;
	short i;

	player_object= get_object_data(get_monster_data(player->monster_index)->object_index);

	polygon= get_polygon_data(player_object->polygon);
	neighbor_indexes= get_map_indexes(polygon->first_neighbor_index, polygon->neighbor_count);
	
	// Skip this step if neighbor indexes were not found
	if (!neighbor_indexes) return;

	for (i=0;i<polygon->neighbor_count;++i)
	{	
		
		polygon_data *neighboring_polygon= get_polygon_data(*neighbor_indexes++);
	
		if (POLYGON_IS_DETACHED(neighboring_polygon))
			continue;
	
		next_object= neighboring_polygon->first_object;

		while(next_object != NONE)
		{
			object= get_object_data(next_object);
			if (GET_OBJECT_OWNER(object)==_object_is_item && !OBJECT_IS_INVISIBLE(object)) 
			{
				if (guess_distance2d((world_point2d *) &player->location, (world_point2d *) &object->location)<=MAXIMUM_ARM_REACH)
				{
					world_distance radius, height;
					
					get_monster_dimensions(player->monster_index, &radius, &height);
	
					if (object->location.z >= player->location.z - MAXIMUM_ARM_REACH && object->location.z <= player->location.z + height &&
						test_item_retrieval(player_object->polygon, &player_object->location, &object->location))
					{
						if(get_item(player_index, next_object))
						{
							/* Start the search again.. */
							next_object= neighboring_polygon->first_object;
							continue;
						}
					}
				}
			}
			
			next_object= object->next_object;
		}
	
	}
}
예제 #10
0
파일: game_window.c 프로젝트: DrItanium/moo
static void draw_player_name(
	void)
{
	struct player_data *player= get_player_data(current_player_index);
	screen_rectangle *player_name_rect= get_interface_rectangle(_player_name_rect);

	_draw_screen_text(player->name, player_name_rect, 
		_center_vertical | _center_horizontal, _player_name_font, 
		player->color+PLAYER_COLOR_BASE_INDEX);
}
예제 #11
0
void racing_init(void) 
{
    player_data_t *plyr = get_player_data( local_player() );
    
    winsys_set_display_func( main_loop );
    winsys_set_idle_func( main_loop );
    winsys_set_reshape_func( reshape );
    winsys_set_mouse_func( NULL );
    winsys_set_motion_func( NULL );
    winsys_set_passive_motion_func( NULL );
    winsys_set_mouse_func( NULL );
    
    /* Initialize view */
    if ( getparam_view_mode() < 0 || 
        getparam_view_mode() >= NUM_VIEW_MODES ) 
    {
        setparam_view_mode( ABOVE );
    }
    set_view_mode( plyr, (view_mode_t)getparam_view_mode() );
    
    /* We need to reset controls here since callbacks won't have been
     called in paused mode. This results in duplication between this
     code and init_physical_simulation.  Oh well. */
    left_turn = right_turn = paddling = False;
    trick_modifier = False;
    charging = False;
    plyr->control.turn_fact = 0.0;
    plyr->control.turn_animation = 0.0;
    plyr->control.is_braking = False;
    plyr->control.is_paddling = False;
    plyr->control.jumping = False;
    plyr->control.jump_charging = False;
    
#ifdef __APPLE__
    plyr->control.is_flying=False;
    plyr->control.fly_total_time=0;
#endif
    
    /* Set last_terrain to a value not used below */
    last_terrain = 0;
    
    if ( g_game.prev_mode != PAUSED ) {
        init_physical_simulation();
    }
    
    last_terrain = 0;
    
    g_game.race_aborted = False;
#ifdef __APPLE__
    g_game.race_time_over = False;
#endif
    
    play_music( "racing" );
    /* play_sound( "start_race", 0 ); */
}
예제 #12
0
파일: game_window.c 프로젝트: DrItanium/moo
void mark_player_inventory_screen_as_dirty(
	short player_index,
	short screen)
{
	struct player_data *player= get_player_data(player_index);

	set_current_inventory_screen(player_index, screen);
	SET_INVENTORY_DIRTY_STATE(player, TRUE);
	
	return;
}
예제 #13
0
void saveAndDisplayRankings() {
    //save score online if a best resul was established
    if (g_game.practicing && !g_game.race_aborted && g_game.race.name!=NULL && did_player_beat_best_results()) {
        int minutes;
        int seconds;
        int hundredths;
        player_data_t *plyr = get_player_data( local_player() );
        get_time_components( g_game.time, &minutes, &seconds, &hundredths);
        //if the player choosed in his prefs not to save score online after ending a race but just to display rankings, the function below
        //will detect this case and redirect to the function displayRankingsAfterRace
    }
    //else display world rankings for this score
    else if (g_game.practicing && !g_game.race_aborted && g_game.race.name!=NULL && !did_player_beat_best_results()) {
        int minutes;
        int seconds;
        int hundredths;
        player_data_t *plyr = get_player_data( local_player() );
        get_time_components( g_game.time, &minutes, &seconds, &hundredths);
    }
}
예제 #14
0
char* editSynchronizeScoresRequest()
{
    
    list_t race_list = NULL;
    list_elem_t cur_elem = NULL;
    player_data_t *plyr = NULL;
    
    open_course_data_t *data;
    
    plyr = get_player_data( local_player() );
    
    g_game.current_event = "__Practice_Event__";
    g_game.current_cup = "__Practice_Cup__";
    g_game.difficulty = 1;
    
    race_list = get_open_courses_list();
    
    cur_elem = get_list_head( race_list );
    
    scalar_t time;
    int herring;
    int score;
    int minutes;
    int seconds;
    int hundredths;
    int i=0;
    char request[10000];
    char* tempRequest;
    strcpy(request,"");
    do
    {
        data = (open_course_data_t*) get_list_elem_data( cur_elem );
        if ( get_saved_race_results( plyr->name,
                                    g_game.current_event,
                                    g_game.current_cup,
                                    data->name,
                                    g_game.difficulty,
                                    &time,
                                    &herring,
                                    &score ) )
        {
            if (i>0) strcat(request,"&");
            get_time_components( time, &minutes, &seconds, &hundredths);
            asprintf(&tempRequest,"piste[%d]=%s&score[%d]=%d&herring[%d]=%d&time[%d]=%02d:%02d:%02d",i,data->name,i,score,i,herring,i,minutes,seconds,hundredths);
            strcat(request,tempRequest);
            free(tempRequest);
            i++;
        }
    }
    while (cur_elem = get_next_list_elem(race_list, cur_elem));
    return request;
}
예제 #15
0
파일: game_window.c 프로젝트: DrItanium/moo
void mark_player_network_stats_as_dirty(
	short player_index)
{
	if (GET_GAME_OPTIONS()&_live_network_stats)
	{
		struct player_data *player= get_player_data(player_index);
	
		set_current_inventory_screen(player_index, _network_statistics);
		SET_INVENTORY_DIRTY_STATE(player, TRUE);
	}
	
	return;
}
예제 #16
0
/* returns the color of the ball or NONE if they don't have one */
short find_player_ball_color(short player_index)
{
	player_data *player = get_player_data(player_index);
	short ball_color = NONE;

	for(ix i = BALL_ITEM_BASE; ball_color==NONE && i < BALL_ITEM_BASE + MAXIMUM_NUMBER_OF_PLAYERS; ++i)
	{
		if(player->items[i] > 0) 
			ball_color = i - BALL_ITEM_BASE;
	}

	return ball_color;	
}
예제 #17
0
int main() {
	int choice, last_game;

	srand(time(0)); // Seed the randomizer with the current time.

	if(get_player_data() == -1)  // Try to read player data from file.
	      register_new_player();    // If there is no data, register a new player.

	while(choice != 7) {
		printf("-=[ Game of Chance Menu ]=-\n");
		printf("1 - Play the Pick a Number game\n");
		printf("2 - Play the No Match Dealer game\n");
		printf("3 - Play the Find the Ace game\n");
		printf("4 - View current high score\n");
		printf("5 - Change your user name\n");
		printf("6 - Reset your account at 100 credits\n");
		printf("7 - Quit\n");
		printf("[Name: %s]\n", player.name);
		printf("[You have %u credits] ->  ", player.credits);
		scanf("%d", &choice);

		if((choice < 1) || (choice > 7))
		      printf("\n[!!] The number %d is an invalid selection.\n\n", choice);
		else if (choice < 4) {          // Otherwise, choice was a game of some sort.
			if(choice != last_game) { // If the function ptr isn't set
				if(choice == 1)        // then point it at the selected game
				      player.current_game = pick_a_number;
				else if(choice == 2)
				      player.current_game = dealer_no_match;
				else
				      player.current_game = find_the_ace;
				last_game = choice;    // and set last_game.
			}
			play_the_game();          // Play the game.
		}
		else if (choice == 4)
		      show_highscore();
		else if (choice == 5) {
			printf("\nChange user name\n");
			printf("Enter your new name: ");
			input_name();
			printf("Your name has been changed.\n\n");
		}
		else if (choice == 6) {
			printf("\nYour account has been reset with 100 credits.\n\n");
			player.credits = 100;
		}
	}
	update_player_data();
	printf("\nThanks for playing! Bye.\n");
}
예제 #18
0
파일: game_window.c 프로젝트: DrItanium/moo
static void set_current_inventory_screen(
	short player_index,
	short screen)
{
	struct player_data *player= get_player_data(player_index);
	
	assert(screen>=0 && screen<7);
	
	player->interface_flags&= ~INVENTORY_MASK_BITS;
	player->interface_flags|= screen;
	player->interface_decay= 5*TICKS_PER_SECOND;
	
	return;
}
예제 #19
0
/* every other field in the player structure should be valid when this call is made */
void initialize_player_physics_variables(
	short player_index)
{
	struct player_data *player= get_player_data(player_index);
	struct monster_data *monster= get_monster_data(player->monster_index);
	struct object_data *object= get_object_data(monster->object_index);
	struct physics_variables *variables= &player->variables;
	struct physics_constants *constants= get_physics_constants_for_model(static_world->physics_model, 0);

//#ifdef DEBUG
	obj_set(*variables, 0x80);
//#endif
	
	variables->head_direction= 0;
	variables->adjusted_yaw= variables->direction= INTEGER_TO_FIXED(object->facing);
	variables->adjusted_pitch= variables->elevation= 0;
	variables->angular_velocity= variables->vertical_angular_velocity= 0;
	variables->velocity= 0, variables->perpendicular_velocity= 0;
	variables->position.x= WORLD_TO_FIXED(object->location.x);
	variables->position.y= WORLD_TO_FIXED(object->location.y);
	variables->position.z= WORLD_TO_FIXED(object->location.z);
	variables->last_position= variables->position;
	variables->last_direction= variables->direction;
	/* .floor_height, .ceiling_height and .media_height will be calculated by instantiate, below */

	variables->external_angular_velocity= 0;
	variables->external_velocity.i= variables->external_velocity.j= variables->external_velocity.k= 0;
	variables->actual_height= constants->height;
	
	variables->step_phase= 0;
	variables->step_amplitude= 0;
	
	variables->action= _player_stationary;
	variables->old_flags= variables->flags= 0; /* not recentering, not above ground, not below ground (i.e., on floor) */

	/* setup shadow variables in player_data structure */
	instantiate_physics_variables(get_physics_constants_for_model(static_world->physics_model, 0),
		&player->variables, player_index, true, true);

#ifdef DIVERGENCE_CHECK
	if (!saved_point_iterations)
	{
		saved_points= new world_point3d[SAVED_POINT_COUNT];
		saved_thetas= new angle[SAVED_POINT_COUNT];
	}
	saved_point_count= 0;
	saved_point_iterations+= 1;
	saved_divergence_warning= false;
#endif
}
예제 #20
0
/*! 
 Callback called when facebook button is clicked
 \author  Emmanuel de Roux
 \date    Created:  2009-09-12
 \date    Modified: 2000-09-12
 */
static void fb_click_cb( button_t *button, void *userdata )
{
	
	scalar_t time;
	open_course_data_t *data;
	data = (open_course_data_t*)get_list_elem_data( cur_elem );
	char* race_name = data->name;
	
	char* mode = g_game.is_speed_only_mode?(char*)Localize("Time Trial","src/race_select.c"):(char*)Localize("classic","src/race_select.c");
	
	char *event,*cup;
	event = g_game.current_event;
	cup = g_game.current_cup;
	
	player_data_t *plyr = get_player_data( local_player() );
	
	int herring, score;
	int minutes, seconds, hundredths;
	
	if (g_game.practicing) {
		if ( get_saved_race_results( plyr->name,
									 event,
									 cup,
									 race_name,
									 g_game.difficulty,
									 &time,
									 &herring,
									 &score ) )
		{
			get_time_components( time, &minutes, &seconds, &hundredths );
		}
		
		if (!g_game.rankings_loaded) {
			facebookPublishDialogDisplayed = false;
			displayRankingsAfterRace(g_game.race.name,plyr->score,plyr->herring,minutes,seconds,hundredths);	
		}
    }
	
	char* scoreTxt;
	
	if (g_game.is_speed_only_mode) asprintf(&scoreTxt, "%02d:%02d:%02d", minutes, seconds, hundredths);
	else asprintf(&scoreTxt, "%d pts", plyr->score );
	
    if (g_game.rankings_loaded==true) { 
		publishNewHighScore(scoreTxt,race_name,mode,g_game.worldRanking,g_game.countryRanking,g_game.totalRanking);
		facebookPublishDialogDisplayed=True;
	}
	
	free(scoreTxt);
}
예제 #21
0
void calc_jump_amt( scalar_t time_step )
{
    player_data_t *plyr = get_player_data( local_player() );
    
    if ( plyr->control.jump_charging ) {
        plyr->control.jump_amt = min( 
                                     MAX_JUMP_AMT, g_game.time - charge_start_time );
    } else if ( plyr->control.jumping ) {
        plyr->control.jump_amt *= 
	    ( 1.0 - ( g_game.time - plyr->control.jump_start_time ) / 
         JUMP_FORCE_DURATION );
    } else {
        plyr->control.jump_amt = 0;
    }
}
예제 #22
0
파일: devices.c 프로젝트: DrItanium/moo
static boolean get_recharge_status(
	short side_index)
{
	short player_index;
	boolean status= FALSE;
	
	for (player_index= 0; player_index<dynamic_world->player_count; ++player_index)
	{
		struct player_data *player= get_player_data(player_index);
		
		if (player->control_panel_side_index==side_index) status= TRUE;
	}
	
	return status;
}
예제 #23
0
void add_new_bonus(const char* text, int value) {

    player_data_t *plyr = get_player_data( local_player() );

    if(!bonus_list) {
        bonus_list = create_bonus(text,value);
        plyr->bonus_tricks+=value;
        return;
    }

    plyr->bonus_tricks+=value;
    bonus_data_t * bonus = bonus_list;
    bonus_list = create_bonus(text, value);
    bonus_list->next = bonus;
    bonus->previous = bonus_list;
}
예제 #24
0
void accelerate_player(
	short monster_index,
	world_distance vertical_velocity,
	angle direction,
	world_distance velocity)
{
	short player_index= monster_index_to_player_index(monster_index);
	struct player_data *player= get_player_data(player_index);
	struct physics_variables *variables= &player->variables;
	struct physics_constants *constants= get_physics_constants_for_model(static_world->physics_model, 0);

	variables->external_velocity.k+= WORLD_TO_FIXED(vertical_velocity);
	variables->external_velocity.k= PIN(variables->external_velocity.k, -constants->terminal_velocity, constants->terminal_velocity);
	
	if (get_monster_definition_external(_monster_marine)->flags & _monster_can_grenade_climb)
	{
		variables->external_velocity.i= (cosine_table[direction]*velocity)>>(TRIG_SHIFT+WORLD_FRACTIONAL_BITS-FIXED_FRACTIONAL_BITS);
		variables->external_velocity.j= (sine_table[direction]*velocity)>>(TRIG_SHIFT+WORLD_FRACTIONAL_BITS-FIXED_FRACTIONAL_BITS);
	} else {
예제 #25
0
파일: tux.c 프로젝트: LeifAndersen/TuxRider
void draw_tux()
{
    if(get_player_data(0)->view.mode == TUXEYE) return;

    GLfloat dummy_colour[]  = { 0.0, 0.0, 0.0, 1.0 };

    /* XXX: For some reason, inserting this call here makes Tux render
     * with correct lighting under Mesa 3.1. I'm guessing it's a Mesa bug.
     */
    glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, dummy_colour );

    set_gl_options( TUX );

    /* Turn on lights
     */
    setup_course_lighting();

    draw_scene_graph( tuxRootNode );
} 
예제 #26
0
파일: game_window.c 프로젝트: DrItanium/moo
void mark_player_inventory_as_dirty(
	short player_index, 
	short dirty_item)
{
	struct player_data *player= get_player_data(player_index);

	/* If the dirty item is not NONE, then goto that item kind display.. */
	if(dirty_item != NONE)
	{
		short item_kind= get_item_kind(dirty_item);
		short current_screen= GET_CURRENT_INVENTORY_SCREEN(player);

		/* Don't change if it is a powerup, or you are in the network statistics screen */		
		if(item_kind != _powerup && item_kind != current_screen) // && current_screen!=_network_statistics)
		{
			/* Goto that type of item.. */
			set_current_inventory_screen(player_index, item_kind);
		}
	}
	SET_INVENTORY_DIRTY_STATE(player, TRUE);
}
예제 #27
0
static void continue_click_cb( button_t *button, void *userdata )
{
    cup_data_t *cup_data;
    player_data_t *plyr = get_player_data( local_player() );
    
    check_assertion( userdata == NULL, "userdata is not null" );
    
    cur_event = listbox_get_current_item( event_listbox );
    event_data = (event_data_t*) get_list_elem_data( cur_event );
    
    cur_cup = listbox_get_current_item( cup_listbox );
    cup_data = (cup_data_t*) get_list_elem_data( cur_cup );
    
    g_game.current_event = get_event_name( event_data );
    g_game.current_cup = get_cup_name( cup_data );
    
    plyr->lives = INIT_NUM_LIVES;
    
    set_game_mode( RACE_SELECT );
    
    ui_set_dirty();
}
예제 #28
0
void calculate_player_item_array(short player_index, short type, short *items, short *counts, short *array_count)
{
	player_data *player = get_player_data(player_index);
	short count= 0;
	
	for(ix loop = 0; loop < NUMBER_OF_DEFINED_ITEMS; ++loop)
	{
		if (loop==_i_knife) 
			continue;
	 	if(player->items[loop] != NONE)
		{
			if(get_item_kind(loop)==type)
			{
				items[count]= loop;
				counts[count]= player->items[loop];
				count++;
			}
		}
	}
	
	*array_count= count;
}
예제 #29
0
void update_player_physics_variables(
	short player_index,
	uint32 action_flags,
	bool predictive)
{
	struct player_data *player= get_player_data(player_index);
	struct physics_variables *variables= &player->variables;
	struct physics_constants *constants= get_physics_constants_for_model(static_world->physics_model, action_flags);

	physics_update(constants, variables, player, action_flags);
	instantiate_physics_variables(constants, variables, player_index, false, !predictive);

#ifdef DIVERGENCE_CHECK
	if (saved_point_count<SAVED_POINT_COUNT)
	{
		struct object_data *object= get_object_data(get_monster_data(player->monster_index)->object_index);
		world_point3d p= object->location;
		world_point3d *q= saved_points+saved_point_count;
		angle *facing= saved_thetas+saved_point_count;
		
		if (saved_point_iterations==1)
		{
			saved_points[saved_point_count]= p;
			*facing= object->facing;
		}
		else
		{
			if (p.x!=q->x||p.y!=q->y||p.z!=q->z||*facing!=object->facing&&!saved_divergence_warning)
			{
				dprintf("divergence @ tick %d: (%d,%d,%d,%d)!=(%d,%d,%d,%d)", saved_point_count,
					q->x, q->y, q->z, *facing, p.x, p.y, p.z, object->facing);
				saved_divergence_warning= true;
			}
		}
		
		saved_point_count+= 1;
	}
#endif
}
void
w_players_in_game2::update_display(bool inFromDynamicWorld /* default=false */) {
	// Start over - wipe out our local player-storage
	clear_vector();
        
        // Wipe out references to players through teams
        for(int i = 0; i < NUMBER_OF_TEAM_COLORS; i++)
            players_on_team[i].clear();

        // Find the number of players
	int num_players;
        if(inFromDynamicWorld)
            num_players = dynamic_world->player_count;
        else
            num_players = displaying_actual_information ? NetGetNumberOfPlayers() : 0;

        // Fill in the entries
	for(int i = 0; i < num_players; i++) {
		player_entry2	thePlayerEntry;

                int	thePlayerTeam;
                int	thePlayerColor;
                
                if(inFromDynamicWorld) {
                    // Get player information from dynamic_world
                    player_data*    thePlayerData   = get_player_data(i);
                    
                    // Copy the player name.  We will store it as a cstring...
                    strncpy(thePlayerEntry.player_name, thePlayerData->name, MAXIMUM_PLAYER_NAME_LENGTH + 1);

                    // Look up colors
                    thePlayerTeam	= thePlayerData->team;
                    thePlayerColor	= thePlayerData->color;
                }
                else {
                    // Get player information from topology
                    player_info*	thePlayerInfo	= (player_info*)NetGetPlayerData(i);
                    
                    // Copy the player name.  We will store it as a cstring...
                    strncpy(thePlayerEntry.player_name, thePlayerInfo->name, MAXIMUM_PLAYER_NAME_LENGTH + 1);

                    // Look up colors
                    thePlayerTeam	= thePlayerInfo->team;
                    thePlayerColor	= thePlayerInfo->color;
                }
                
                // Set the size of the text
                thePlayerEntry.name_width	= text_width(thePlayerEntry.player_name, font, style | styleShadow);
		
                // Get the pixel-color for the player's team (for drawing the name)
		thePlayerEntry.name_pixel_color	= get_dialog_player_color(thePlayerTeam);

                // Set up a player image for the player (funfun)
                thePlayerEntry.player_image = new PlayerImage;
                thePlayerEntry.player_image->setRandomFlatteringView();
                thePlayerEntry.player_image->setPlayerColor(thePlayerColor);
                thePlayerEntry.player_image->setTeamColor(thePlayerTeam);

                // Add the player to our local storage area
		player_entries.push_back(thePlayerEntry);
                
                // Add a reference to the player through his team color
                players_on_team[thePlayerTeam].push_back(i);
	}
                
        dirty = true;
}