コード例 #1
0
ファイル: cp_parse.cpp プロジェクト: Qazzian/ufoai_suspend
/**
 * @brief Read the data for campaigns
 * @sa SAV_GameLoad
 * @sa CP_ResetCampaignData
 */
void CP_ParseCampaignData (void)
{
	const char *type, *name, *text;
	int i;
	campaign_t *campaign;

	/* pre-stage parsing */
	FS_BuildFileList("ufos/*.ufo");
	FS_NextScriptHeader(NULL, NULL, NULL);
	text = NULL;

	while ((type = FS_NextScriptHeader("ufos/*.ufo", &name, &text)) != NULL)
		CP_ParseScriptFirst(type, name, &text);

	/* fill in IDXs for required research techs */
	RS_RequiredLinksAssign();

	/* stage two parsing */
	FS_NextScriptHeader(NULL, NULL, NULL);
	text = NULL;

	Com_DPrintf(DEBUG_CLIENT, "Second stage parsing started...\n");
	while ((type = FS_NextScriptHeader("ufos/*.ufo", &name, &text)) != NULL)
		CP_ParseScriptSecond(type, name, &text);
	INS_LinkTechnologies();

	for (i = 0; i < cgi->csi->numTeamDefs; i++) {
		const teamDef_t *teamDef = &cgi->csi->teamDef[i];
		if (!CHRSH_IsTeamDefAlien(teamDef))
			continue;

		ccs.teamDefTechs[teamDef->idx] = RS_GetTechByID(teamDef->tech);
		if (ccs.teamDefTechs[teamDef->idx] == NULL)
			cgi->Com_Error(ERR_DROP, "Could not find a tech for teamdef %s", teamDef->id);
	}

	for (i = 0, campaign = ccs.campaigns; i < ccs.numCampaigns; i++, campaign++) {
		/* find the relevant markets */
		campaign->marketDef = INV_GetEquipmentDefinitionByID(campaign->market);
		campaign->asymptoticMarketDef = INV_GetEquipmentDefinitionByID(campaign->asymptoticMarket);
	}

	Com_Printf("Campaign data loaded - size " UFO_SIZE_T " bytes\n", sizeof(ccs));
	Com_Printf("...techs: %i\n", ccs.numTechnologies);
	Com_Printf("...buildings: %i\n", ccs.numBuildingTemplates);
	Com_Printf("...ranks: %i\n", ccs.numRanks);
	Com_Printf("...nations: %i\n", ccs.numNations);
	Com_Printf("...cities: %i\n", ccs.numCities);
	Com_Printf("\n");
}
コード例 #2
0
ファイル: cl_game_skirmish.c プロジェクト: chrisglass/ufoai
/**
 * @brief Changed the given cvar to the next/prev equipment definition
 */
static void GAME_SK_ChangeEquip_f (void)
{
	const equipDef_t *ed;
	int index;
	const char *cvarName;

	if (Cmd_Argc() < 2) {
		Com_Printf("Usage: %s <cvarname>\n", Cmd_Argv(0));
		return;
	}

	cvarName = Cmd_Argv(1);
	ed = INV_GetEquipmentDefinitionByID(Cvar_GetString(cvarName));
	index = ed - csi.eds;

	if (Q_streq(Cmd_Argv(0), "sk_prevequip")) {
		index--;
		if (index < 0)
			index = csi.numEDs - 1;
		Cvar_Set(cvarName, csi.eds[index].name);
	} else {
		index++;
		if (index >= csi.numEDs)
			index = 0;
		Cvar_Set(cvarName, csi.eds[index].name);
	}
}
コード例 #3
0
ファイル: cl_game_team.cpp プロジェクト: AresAndy/ufoai
void GAME_AutoTeam (const char* equipmentDefinitionID, int teamMembers)
{
	const equipDef_t* ed = INV_GetEquipmentDefinitionByID(equipmentDefinitionID);
	const char* teamDefID = GAME_GetTeamDef();
	cls.teamSaveSlotIndex = NO_TEAM_SLOT_LOADED;

	GAME_GenerateTeam(teamDefID, ed, teamMembers);
}
コード例 #4
0
ファイル: cl_game_skirmish.c プロジェクト: chrisglass/ufoai
/**
 * @brief Starts a new skirmish game
 */
static void GAME_SK_Start_f (void)
{
	char map[MAX_VAR];
	mapDef_t *md;

	if (!chrDisplayList.num) {
		unsigned int i;
		/** @todo make the teamdef configurable */
		const char *ugvTeamDefID = "phalanx_ugv_phoenix";
		const char *name = Cvar_GetString("cl_equip");
		const equipDef_t *ed = INV_GetEquipmentDefinitionByID(name);
		const size_t size = GAME_GetCharacterArraySize();
		uint32_t maxSoldiers = Cvar_GetInteger("sv_maxsoldiersperplayer");
		uint32_t ugvs = Cvar_GetInteger("cl_ugvs");

		if (maxSoldiers <= 0)
			maxSoldiers = size;

		ugvs = min(ugvs, size - maxSoldiers);
		Com_Printf("Starting skirmish with %i soldiers and %i ugvs\n", maxSoldiers, ugvs);
		GAME_AutoTeam(name, maxSoldiers);
		for (i = 0; i < ugvs; i++)
			GAME_AppendTeamMember(i + maxSoldiers, ugvTeamDefID, ed);
	} else {
		Com_Printf("Using already loaded team with %i members\n", chrDisplayList.num);
	}

	assert(cls.currentSelectedMap >= 0);
	assert(cls.currentSelectedMap < MAX_MAPDEFS);

	md = Com_GetMapDefByIDX(cls.currentSelectedMap);
	if (!md)
		return;

	GAME_SK_SetMissionParameters(md);

	assert(md->map);
	Com_sprintf(map, sizeof(map), "map %s %s %s;", Cvar_GetInteger("mn_serverday") ? "day" : "night", md->map, md->param ? md->param : "");

	/* prepare */
	UI_InitStack(NULL, "singleplayermission", qtrue, qfalse);

	Cbuf_AddText(map);
}
コード例 #5
0
ファイル: cl_game.c プロジェクト: chrisglass/ufoai
static qboolean GAME_Spawn (void)
{
	const size_t size = GAME_GetCharacterArraySize();
	int i;

	/* If there is no active gametype we create a team with default values.
	 * This is e.g. the case when someone starts a map with the map command */
	if (GAME_GetCurrentType() == NULL || chrDisplayList.num == 0) {
		const char *teamDefID = GAME_GetTeamDef();
		const equipDef_t *ed = INV_GetEquipmentDefinitionByID("multiplayer_initial");

		/* inventory structure switched/initialized */
		INV_DestroyInventory(&cls.i);
		INV_InitInventory("client", &cls.i, &csi, &inventoryImport);
		GAME_GenerateTeam(teamDefID, ed, size);
	}

	for (i = 0; i < size; i++)
		cl.chrList.chr[i] = chrDisplayList.chr[i];
	cl.chrList.num = chrDisplayList.num;

	return qtrue;
}