fitting

package
v0.1.95 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 13 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 DistributionBuckets = 24
View Source
const (
	DogmaEngineVersion = "7.1.0+ek.3"
)
View Source
const DogmaSDEVersion = "3489895"
View Source
const DroneBayFlag = 87

DroneBayFlag is where drones sit on a killmail.

Variables

View Source
var DistributionMetrics = []struct {
	Name, Column string
}{
	{"ehp", "ehp"}, {"dps", "dps_with_reload"}, {"alpha", "alpha"},
	{"repair", "GREATEST(COALESCE(shield_effective_boost,0),COALESCE(armor_effective_repair,0),COALESCE(hull_effective_repair,0),COALESCE(passive_shield_effective,0))"},
	{"speed", "max_velocity"}, {"align", "align_time"},
	{"signature", "signature_radius"}, {"capacitor", "cap_capacity"},
}
View Source
var NPCDamageProfiles = []NPCDamageProfile{
	{ID: "omni", Name: "Omnidamage", EM: .25, Thermal: .25, Kinetic: .25, Explosive: .25},
	normalizedProfile("angels", "Angel Cartel", 0, 0, .22, .62),
	normalizedProfile("blood-raiders", "Blood Raiders", .50, .48, 0, 0),
	normalizedProfile("guristas", "Guristas Pirates", 0, .18, .79, 0),
	normalizedProfile("mordus", "Mordu's Legion", 0, .30, .70, 0),
	normalizedProfile("sansha", "Sansha's Nation", .53, .47, 0, 0),
	normalizedProfile("serpentis", "Serpentis", 0, .55, .45, 0),
	normalizedProfile("triglavian", "Triglavian Collective", 0, .60, 0, .40),
	normalizedProfile("amarr", "Amarr Empire", .47, .42, 0, 0),
	normalizedProfile("caldari", "Caldari State", 0, .48, .51, 0),
	normalizedProfile("gallente", "Gallente Federation", 0, .39, .60, 0),
	normalizedProfile("minmatar", "Minmatar Republic", 0, 0, .31, .50),
}

Functions

func CalculateAndStoreStats added in v0.1.78

func CalculateAndStoreStats(ctx context.Context, pool *pgxpool.Pool, fit *Fitting, shipTypeID int32) error

CalculateAndStoreStats evaluates the representative payload stored for a fit at all-V and persists the fields used by catalogue sorting and filtering.

func CalculateStoredStats added in v0.1.78

func CalculateStoredStats(ctx context.Context, pool *pgxpool.Pool, fitHash string) error

CalculateStoredStats loads the immutable representative payload for a fit.

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 NPCDamageEHPExpression added in v0.1.78

func NPCDamageEHPExpression(alias string, profile NPCDamageProfile) string

NPCDamageEHPExpression returns a SQL expression for layered EHP against a whitelisted profile. The alias must be a trusted identifier supplied by the caller, never request input.

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 DistributionRefresh added in v0.1.78

type DistributionRefresh struct {
	WindowDays int
	Summaries  int64
	Buckets    int64
	Elapsed    time.Duration
}

func RefreshDistributions added in v0.1.78

func RefreshDistributions(ctx context.Context, pool *pgxpool.Pool, days int) (DistributionRefresh, error)

RefreshDistributions rebuilds one complete observation-weighted window. Each canonical fit contributes once to fit_count and once per recorded loss to observation_count. Bounds use P1/P99 so isolated pathological fits do not flatten the useful portion of the histogram; outliers clamp into edge bins.

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.

type NPCDamageProfile added in v0.1.78

type NPCDamageProfile struct {
	ID, Name                        string
	EM, Thermal, Kinetic, Explosive float64
}

NPCDamageProfile is an approximate incoming damage mix. Percentages are normalized from EVE University's listed primary damage types; omitted minor damage varies between individual NPCs and sites.

func NPCProfile added in v0.1.78

func NPCProfile(id string) (NPCDamageProfile, bool)

Jump to

Keyboard shortcuts

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