Exemplo n.º 1
0
bool CampaignLoad(CampaignOptions *co, CampaignEntry *entry)
{
	CASSERT(!co->IsLoaded, "loading campaign without unloading last one");
	// Note: use the mode already set by the menus
	const GameMode mode = co->Entry.Mode;
	co->Entry = *entry;
	co->Entry.Mode = mode;
	CampaignSettingInit(&co->Setting);
	if (entry->Mode == GAME_MODE_QUICK_PLAY)
	{
		SetupQuickPlayCampaign(&co->Setting);
		co->IsLoaded = true;
	}
	else
	{
		// Normalise the path
		char buf[CDOGS_PATH_MAX];
		GetDataFilePath(buf, entry->Path);
		if (MapNewLoad(buf, &co->Setting))
		{
			LOG(LM_MAIN, LL_ERROR, "failed to load campaign %s!", buf);
			CASSERT(false, "Failed to load campaign");
		}
		else
		{
			co->IsLoaded = true;
		}
	}

	if (co->IsLoaded)
	{
		LOG(LM_MAIN, LL_INFO, "loaded campaign/dogfight");
	}
	return co->IsLoaded;
}
Exemplo n.º 2
0
void GrafxMakeRandomBackground(
	GraphicsDevice *device,
	CampaignOptions *co, struct MissionOptions *mo, Map *map)
{
	HSV tint;
	CampaignSettingInit(&co->Setting);
	ActorsInit();
	ObjsInit();
	MobObjsInit();
	SetupQuickPlayCampaign(&co->Setting, &gConfig.QuickPlay);
	co->seed = rand();
	tint.h = rand() * 360.0 / RAND_MAX;
	tint.s = rand() * 1.0 / RAND_MAX;
	tint.v = 0.5;
	DrawBuffer buffer;
	DrawBufferInit(&buffer, Vec2iNew(X_TILES, Y_TILES), device);
	co->MissionIndex = 0;
	GrafxMakeBackground(
		device, &buffer, co, mo, map,
		tint, 0, 1, Vec2iCenterOfTile(Vec2iScaleDiv(map->Size, 2)), NULL);
	DrawBufferTerminate(&buffer);
	ActorsTerminate();
	ObjsTerminate();
	MobObjsTerminate();
	RemoveAllWatches();
	MissionOptionsTerminate(mo);
	CampaignSettingTerminate(&co->Setting);
	co->seed = gConfig.Game.RandomSeed;
}
Exemplo n.º 3
0
void GrafxMakeRandomBackground(
	GraphicsDevice *device,
	CampaignOptions *co, struct MissionOptions *mo, Map *map)
{
	CampaignSettingInit(&co->Setting);
	SetupQuickPlayCampaign(&co->Setting);
	const HSV tint = {
		rand() * 360.0 / RAND_MAX, rand() * 1.0 / RAND_MAX, 0.5
	};
	DrawBuffer buffer;
	DrawBufferInit(&buffer, svec2i(X_TILES, Y_TILES), device);
	co->MissionIndex = 0;
	GrafxMakeBackground(
		device, &buffer, co, mo, map, tint, false, svec2_zero(), NULL);
	DrawBufferTerminate(&buffer);
	MissionOptionsTerminate(mo);
	CampaignSettingTerminate(&co->Setting);
}
Exemplo n.º 4
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");
}
Exemplo 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");
}