void pilot::BinaryFileHandler::startArrayWrite(const char*, size_t size, bool short_index) {
	if (short_index) {
		cfwrite_ushort((short)size, _cfp);
	} else {
		cfwrite_int((int)size, _cfp);
	}
}
void pilotfile::startSection(Section::id section_id)
{
	Assert( cfp );

	const int zero = 0;

	cfwrite_ushort( (ushort)section_id, cfp );

	// to be updated when endSection() is called
	cfwrite_int(zero, cfp);

	// starting offset, for size of section
	m_size_offset = cftell(cfp);
}
void pilot::BinaryFileHandler::startSectionWrite(Section id) {
	if (id == Section::Unnamed) {
		_sectionOffsets.push_back({id, 0});
		return;
	}

	cfwrite_ushort((ushort) id, _cfp);

	// to be updated when endSection() is called
	cfwrite_int(0, _cfp);

	// starting offset, for size of section
	_sectionOffsets.push_back({id, (size_t)cftell(_cfp)});
}
示例#4
0
void pilotfile::csg_write_loadout()
{
	int idx, j;

	startSection(Section::Loadout);

	// base info
	cfwrite_string_len(Player_loadout.filename, cfp);
	cfwrite_string_len(Player_loadout.last_modified, cfp);

	// ship pool
	for (idx = 0; idx < static_cast<int>(Ship_info.size()); idx++) {
		cfwrite_int(Player_loadout.ship_pool[idx], cfp);
	}

	// weapon pool
	for (idx = 0; idx < Num_weapon_types; idx++) {
		cfwrite_int(Player_loadout.weapon_pool[idx], cfp);
	}

	// play ship loadout
	cfwrite_ushort(MAX_WSS_SLOTS, cfp);

	for (idx = 0; idx < MAX_WSS_SLOTS; idx++) {
		wss_unit *slot = &Player_loadout.unit_data[idx];

		// ship
		cfwrite_int(slot->ship_class, cfp);

		// primary weapons
		cfwrite_int(MAX_SHIP_PRIMARY_BANKS, cfp);

		for (j = 0; j < MAX_SHIP_PRIMARY_BANKS; j++) {
			cfwrite_int(slot->wep[j], cfp);
			cfwrite_int(slot->wep_count[j], cfp);
		}

		// secondary weapons
		cfwrite_int(MAX_SHIP_SECONDARY_BANKS, cfp);

		for (j = 0; j < MAX_SHIP_SECONDARY_BANKS; j++) {
			cfwrite_int(slot->wep[j+MAX_SHIP_PRIMARY_BANKS], cfp);
			cfwrite_int(slot->wep_count[j+MAX_SHIP_PRIMARY_BANKS], cfp);
		}
	}

	endSection();
}
void pilotfile_convert::csg_export_loadout()
{
	startSection(Section::Loadout);

	// base info
	cfwrite_string_len(csg->loadout.filename.c_str(), cfp);
	cfwrite_string_len(csg->loadout.last_modified.c_str(), cfp);

	// ship pool
	size_t list_size = csg->loadout.ship_pool.size();

	for (size_t idx = 0; idx < list_size; idx++) {
		cfwrite_int(csg->loadout.ship_pool[idx], cfp);
	}

	// weapon pool
	list_size = csg->loadout.weapon_pool.size();

	for (size_t idx = 0; idx < list_size; idx++) {
		cfwrite_int(csg->loadout.weapon_pool[idx], cfp);
	}

	// play ship loadout
	cfwrite_ushort(12, cfp);

	for (size_t idx = 0; idx < 12; idx++) {
		// ship
		cfwrite_int(csg->loadout.slot[idx].ship_index, cfp);

		// primary weapons
		cfwrite_int(3, cfp);

		for (size_t j = 0; j < 3; j++) {
			cfwrite_int(csg->loadout.slot[idx].wep[j], cfp);
			cfwrite_int(csg->loadout.slot[idx].wep_count[j], cfp);
		}

		// secondary weapons
		cfwrite_int(4, cfp);

		for (size_t j = 0; j < 4; j++) {
			cfwrite_int(csg->loadout.slot[idx].wep[j+3], cfp);
			cfwrite_int(csg->loadout.slot[idx].wep_count[j+3], cfp);
		}
	}

	endSection();
}
示例#6
0
void pilotfile::csg_write_controls()
{
	int idx;

	startSection(Section::Controls);

	cfwrite_ushort(CCFG_MAX, cfp);

	for (idx = 0; idx < CCFG_MAX; idx++) {
		cfwrite_short(Control_config[idx].key_id, cfp);
		cfwrite_short(Control_config[idx].joy_id, cfp);
		// placeholder? for future mouse_id?
		cfwrite_short(-1, cfp);
	}

	endSection();
}
示例#7
0
文件: plr.cpp 项目: sobczyk/fs2open
void pilotfile::plr_write_controls()
{
    int idx;

    startSection(Section::Controls);

    cfwrite_ushort(CCFG_MAX, cfp);

    for (idx = 0; idx < CCFG_MAX; idx++) {
        cfwrite_short(Control_config[idx].key_id, cfp);
        cfwrite_short(Control_config[idx].joy_id, cfp);
        // placeholder? for future mouse_id?
        cfwrite_short(-1, cfp);
    }

    cfwrite_int(NUM_JOY_AXIS_ACTIONS, cfp);

    for (idx = 0; idx < NUM_JOY_AXIS_ACTIONS; idx++) {
        cfwrite_int(Axis_map_to[idx], cfp);
        cfwrite_int(Invert_axis[idx], cfp);
    }

    endSection();
}
void pilotfile_convert::plr_export_controls()
{
	unsigned int idx;

	startSection(Section::Controls);

	cfwrite_ushort((unsigned short)plr->controls.size(), cfp);

	for (idx = 0; idx < plr->controls.size(); idx++) {
		cfwrite_short(plr->controls[idx].key_id, cfp);
		cfwrite_short(plr->controls[idx].joy_id, cfp);
		// placeholder? for future mouse_id?
		cfwrite_short(-1, cfp);
	}

	// extra joystick stuff
	cfwrite_int(MAX_JOY_AXES_CONV, cfp);
	for (idx = 0; idx < MAX_JOY_AXES_CONV; idx++) {
		cfwrite_int(plr->joy_axis_map_to[idx], cfp);
		cfwrite_int(plr->joy_invert_axis[idx], cfp);
	}

	endSection();
}