fitting

package
v0.1.67 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package fitting turns a killmail's item list into a stable fit identity.

Three things come out of one killmail:

  • fit_hash sha256 over the ship and its fitted modules
  • family_hash the same, with each module replaced by its T1 root, so meta and faction variants of one doctrine cluster together
  • items the render payload — modules with their loaded charge, plus drone rows carrying a bay total

The hash format is a compatibility contract, not an implementation detail. Roughly 400,000 fits are stored under hashes produced by the TypeScript, and a hash that differs by so much as a separator orphans all of them. So the serialisation below is reproduced exactly — including the decisions that look arbitrary.

The one worth calling out: charges and drones are deliberately NOT part of the hash. Two Rifters with identical modules and different ammo are the same fit. That was chosen so the enrichment columns could be added later without invalidating what was already on disk, and it stays that way.

Index

Constants

View Source
const (
	SlotHigh      = 1
	SlotMed       = 2
	SlotLow       = 3
	SlotRig       = 4
	SlotSubsystem = 5
	SlotDrone     = 6
)

Slot groups, numbered to match the in-game and EFT layout — high, med, low, rig, subsystem, drone — so the frontend renders a fit without remapping.

View Source
const DroneBayFlag = 87

DroneBayFlag is where drones sit on a killmail.

Variables

This section is empty.

Functions

func IsShipType

func IsShipType(cache *eve.Cache, typeID int32) bool

IsShipType reports whether a hull is a ship.

Resolved through group to category because CCP's SDE does not populate a category on types, only on groups. Callers use it to skip pods, structures and deployables, where a fit means nothing.

func SlotGroupForFlag

func SlotGroupForFlag(flag int32) int32

SlotGroupForFlag maps an SDE inventory flag to a slot group.

The ranges are verified against inv_flags: 11-18 low, 19-26 med, 27-34 high, 92-99 rig (eight exist even though most hulls use three), 125-132 subsystem.

Fighter tubes and bays are deliberately absent. They are not covered by the partial index on killmail_items, so including them would turn every carrier and supercarrier fit lookup into a full scan — rare enough to wait for a dedicated index.

func Store

func Store(ctx context.Context, pool *pgxpool.Pool, f *Fitting, link Link) error

Store writes a fit and links it to the killmail it came from.

Types

type ExtractedItem

type ExtractedItem struct {
	SlotGroup    int32
	Ordinal      int32
	TypeID       int32
	ChargeTypeID int32
	Quantity     int32
}

ExtractedItem is one row of the render payload.

type Fitting

type Fitting struct {
	FitHash    string
	FamilyHash string
	Items      []ExtractedItem
}

Fitting is the extracted identity and payload.

func Extract

func Extract(cache *eve.Cache, shipTypeID int32, items []Item) *Fitting

Extract builds the fit identity for a hull and its items.

Returns nil when there is no fit: an empty hull, or one carrying only drones. A fit identity needs at least one fitted module to mean anything, so a pod with a drone bay does not get one.

type Item

type Item struct {
	TypeID int32
	FlagID int32

	// ParentIndex is >= 0 for an item inside a container. Only top-level items
	// are fitted hardware; anything nested is cargo.
	ParentIndex int32

	// Quantity is dropped plus destroyed. Only drones use it — a bay holds
	// several of one type and the count has to round-trip.
	Quantity int32
}

Item is one killmail item, reduced to what the extractor needs.

func (Item) TopLevel

func (i Item) TopLevel() bool

TopLevel reports whether the item is fitted rather than in a container.

type Link struct {
	KillmailID          int64
	ShipTypeID          int32
	KillTime            time.Time
	VictimAllianceID    int32
	VictimCorporationID int32
}

Link is the killmail context a fit was observed in.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL