Esempio n. 1
0
int resumeCampaign(tGame * game)
{
	int i, valid;
	int campaign_rows;
	int campaign_columns;

	if (!LoadCampaign(game))
		return FALSE;
	campaign_rows = game->campaign[game->campaign_level-1].rows;
	campaign_columns = game->campaign[game->campaign_level-1].columns;
	
	if (campaign_rows != game->hiddenboard.rows || campaign_columns != game->hiddenboard.columns)
		return FALSE;

	Play(game);
	
	for (i = game->campaign_level; i < game->levels_amount; i++)
	{
		if ((valid = setNewGame(game)) == MALLOC_ERR)
		{
			printf("%s%s%s\n", KERR, MEM_ERR, KDEF);
			return FALSE;
		}
		else if (valid)				
			Play(game);
	}
	return TRUE;
}
Esempio n. 2
0
Progression::Progression(std::string _campaign, std::string _savefile, bool _resume)
{
	state_ = ProgressionState::OK;
	campaign_ = _campaign;
	savefile_ = _savefile;
	good_points_ = 10;
	evil_points_ = 10;


	TiXmlDocument doc("Levels/" + _campaign);
	doc.LoadFile();
	if(!doc.Error())
	{
		if(!LoadCampaign(&doc) || (_resume && LoadSavefile()))
			state_ = ProgressionState::LoadError;
	} else
	{
		Logger::ErrorOut() << "Unable to load campaign " << _campaign << "\n";
		Logger::ErrorOut() << "Error: " << doc.ErrorDesc() << "\n";
		state_ = ProgressionState::LoadError;
	}

	if(cheat_)
	{
		good_points_ = 999;
		evil_points_ = 999;
	}
	disable_save_ = false;
	
}
Esempio n. 3
0
void MenuLoadCampaign(campaign_entry_t *entry)
{
	gOptions.twoPlayers = entry->is_two_player;
	gCampaign.Entry = *entry;
	if (entry->isBuiltin)
	{
		if (entry->mode == CAMPAIGN_MODE_NORMAL)
		{
			SetupBuiltinCampaign(entry->builtinIndex);
		}
		else if (entry->mode == CAMPAIGN_MODE_DOGFIGHT)
		{
			SetupBuiltinDogfight(entry->builtinIndex);
		}
		else
		{
			SetupQuickPlayCampaign(&gCampaign.Setting);
		}
	}
	else
	{
		if (customSetting.missions)
		{
			CFREE(customSetting.missions);
		}
		if (customSetting.characters)
		{
			CFREE(customSetting.characters);
		}
		memset(&customSetting, 0, sizeof(customSetting));

		if (LoadCampaign(entry->path, &customSetting, 0, 0) != CAMPAIGN_OK)
		{
			printf("Failed to load campaign %s!\n", entry->path);
			assert(0);
		}
		gCampaign.Setting = customSetting;
	}
	
	printf(">> Loading campaign/dogfight\n");
}
Esempio n. 4
0
int setCampaign(tGame * game)
{
	int i, valid;
	getCampaignName(game);
	

	if (!LoadCampaign(game))
		return FALSE;

	for (i = 0; i < game->levels_amount; i++)
	{
		if ((valid = setNewGame(game)) == MALLOC_ERR)
		{
			printf("%s%s%s\n", KASK, MEM_ERR,KDEF);
			return FALSE;
		}
		else if (valid)
			Play(game);
	}
	return TRUE;
}
Esempio n. 5
0
void MenuLoadCampaign(campaign_entry_t *entry)
{
	gCampaign.Entry = *entry;
	CampaignSettingTerminate(&gCampaign.Setting);
	if (entry->isBuiltin)
	{
		if (entry->mode == CAMPAIGN_MODE_NORMAL)
		{
			SetupBuiltinCampaign(entry->builtinIndex);
		}
		else if (entry->mode == CAMPAIGN_MODE_DOGFIGHT)
		{
			SetupBuiltinDogfight(entry->builtinIndex);
		}
		else if (entry->mode == CAMPAIGN_MODE_QUICK_PLAY)
		{
			SetupQuickPlayCampaign(&gCampaign.Setting, &gConfig.QuickPlay);
		}
		else
		{
			printf("Unknown game mode!\n");
			assert(0);
		}
	}
	else
	{
		CampaignSettingNew customSetting;
		CampaignSettingInit(&customSetting);

		if (LoadCampaign(entry->path, &customSetting) != CAMPAIGN_OK)
		{
			printf("Failed to load campaign %s!\n", entry->path);
			assert(0);
		}
		memcpy(&gCampaign.Setting, &customSetting, sizeof gCampaign.Setting);
	}

	printf(">> Loading campaign/dogfight\n");
}
Esempio n. 6
0
int SelectCampaign(int dogFight, int cmd)
{
	static int campaignIndex = 0;
	static int dogfightIndex = 0;
	int count, x, y, i, j;
	struct FileEntry *list = dogFight ? dogfightList : campaignList;
	char *prefix = dogFight ? "dogfights/" : "missions/";
	int *index = dogFight ? &dogfightIndex : &campaignIndex;
	struct FileEntry *f;

	for (count = 0, f = list; f != NULL; f = f->next, count++);

	if (cmd == CMD_ESC)
		return MODE_MAIN;

	if (AnyButton(cmd)) {
		for (i = 0, f = list; f != NULL && i < *index;
		     f = f->next, i++);

		if (f && f->name[0]) {
			if (customSetting.missions)
				free(customSetting.missions);
			if (customSetting.characters)
				free(customSetting.characters);
			memset(&customSetting, 0, sizeof(customSetting));

			if (LoadCampaign(GetDataFilePath(join(prefix,f->name)), &customSetting, 0, 0) ==
			    CAMPAIGN_OK)
				gCampaign.setting = &customSetting;
			else
				SetupBuiltin(dogFight, 0);
		} else if (f)
			SetupBuiltin(dogFight, f->data);
		else {
			SetupBuiltin(dogFight, 0);
		}

//  gCampaign.seed = 0;
		PlaySound(SND_HAHAHA, 0, 255);
		printf(">> Entering MODE_PLAY\n");
		return MODE_PLAY;
	}
	
	if (Left(cmd) || Up(cmd)) {
		(*index)--;
		if (*index < 0)
			*index = count - 1;
		PlaySound(SND_SWITCH, 0, 255);
	} else if (Right(cmd) || Down(cmd)) {
		(*index)++;
		if (*index >= count)
			*index = 0;
		PlaySound(SND_SWITCH, 0, 255);
	}	
	
	if (dogFight)
		TextStringSpecial("Select a dogfight scenario:", TEXT_TOP | TEXT_XCENTER, 0, (SCREEN_WIDTH / 12));
	else
		TextStringSpecial("Select a campaign:", TEXT_TOP | TEXT_XCENTER, 0, (SCREEN_WIDTH / 12));

	x = CenterX(240);
	y = CenterY(12 * TextHeight());
	
#define ARROW_UP	"\036"
#define ARROW_DOWN	"\037"
	
	for (i = 0, f = list; f != NULL && i <= *index - 12; f = f->next, i++);

	if (i)
		DisplayMenuItem(CenterX(TextWidth(ARROW_UP)), y - 2 - TextHeight(), ARROW_UP, 0);

	for (j = 0; f != NULL && j < 12; f = f->next, i++, j++) {
		DisplayMenuItem(CenterX(TextWidth(f->info)), y, f->info, i == *index);
		
		if (i == *index) {
			char s[255];

			if (strlen(f->name) == 0)
				sprintf(s, "( Internal )");
			else
				sprintf(s, "( %s )", f->name);

			TextStringSpecial(s, TEXT_XCENTER | TEXT_BOTTOM, 0, (SCREEN_WIDTH / 12));
		}
			
		y += TextHeight();
	}

	if (f)
		DisplayMenuItem(CenterX(TextWidth(ARROW_DOWN)), y + 2, ARROW_DOWN, 0);
		
	return dogFight ? MODE_DOGFIGHT : MODE_CAMPAIGN;
}