Esempio n. 1
0
do_save_game_menu()
{
	newmenu_item m[N_SAVE_SLOTS];
	char *saved_text_ptrs[N_SAVE_SLOTS];
	char menu_text[N_SAVE_SLOTS][GAME_NAME_LEN+1];		//+1 for terminating zero
	int i,choice;

	get_game_list(saved_text_ptrs);

	for (i=0;i<N_SAVE_SLOTS;i++) {

		strcpy(menu_text[i],saved_text_ptrs[i]);

		m[i].type = NM_TYPE_INPUT_MENU;
		m[i].text_len = GAME_NAME_LEN;
		m[i].text = menu_text[i];

		if (!menu_text[i][0])
			strcpy(menu_text[i],TXT_EMPTY);

	}

	choice = newmenu_do4( NULL, TXT_SAVE_GAME_SLOTS, N_SAVE_SLOTS, m, NULL, 0, NULL, -1, -1, 1 );

	if (choice != -1) {
		int ret;

		if ((ret=save_player_game(choice,m[choice].text)) != 0)
			nm_messagebox( NULL,1, TXT_CONTINUE,"%s\n%s\n\n", TXT_SAVE_ERROR, strerror(ret));
	}

}
Esempio n. 2
0
void enter_warp(warp_entity* warp, player_entity* player) {
	save_player_game();
	if (!original_world_exists(warp->world_id)) {
		// TODO: Better handling
		DEBUG(0, NE_WARNING, "Cannot enter warp to non-existing world " << warp->world_id);
		return;
	}
	player->transform.position.xy = chunk_position(warp->chunk);
	player->transform.position.x += (float) warp->tile.x * tile_pixel_size();
	player->transform.position.y += (float) warp->tile.y * tile_pixel_size();
	game_data* game = get_game_data();
	load_player_world(warp->world_id);
	if (game->world.mode != WORLD_PLAY_MODE) {
		DEBUG(0, NE_WARNING, "World " << warp->world_id << " is not playable after warping to it. Unexpected error.");
		DEBUG(0, NE_ERROR, "Exiting game to avoid corrupted save state. Return code: " << EXIT_CODE_WORLD_LOAD_ERROR);
		ne::show_error("It seems world " + std::to_string(warp->world_id) + " did not load correctly. This is an unexpected case, and it might be related to hard drive failure. The game will close to avoid corruption, but you may restart it.");
		exit(EXIT_CODE_WORLD_LOAD_ERROR);
	}
}