P3: The ballistic ammo gauge shows weapon energy as empty unless it is completely full
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
La larghezza della barra dell'Energia viene calcolata in hudtarget.cpp intorno alla riga 6043, dove fl2i tronca il rapporto prima della moltiplicazione; la ricerca dell'etichetta vicino alla riga 6030 usa un numero di banco dove serve una classe d'arma. Riproduci con -ballistic_gauge e un'arma primaria balistica, controllando la barra a energia parziale. Fatto quando la barra scala con l'energia, l'etichetta usa la classe d'arma corretta e i banchi vuoti (-1) vengono saltati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
When the ballistic ammo gauge is on (-ballistic_gauge, on a ship with a ballistic primary), its Energy bar is either completely full or completely empty. Any weapon energy below 100% draws as an empty bar, so the gauge tells the player they have no energy when they may have almost all of it.
The bar's width is max_w * fl2i(energy / max_reserve) (hudtarget.cpp:6043 on master). fl2i truncates the ratio first, so it is 1 only at full energy and 0 otherwise. Multiplying before truncating (fl2i(max_w * energy / max_reserve)) gives the right width.
Steps to reproduce
- Current master (I used 8afa31842, Debug build), MediaVPs 5.0.2, launched with
-ballistic_gauge. - Use a mod that gives the player's ship a ballistic primary. I made a small test mod: a
weapons.tbmthat adds the"ballistic"flag and$Rearm Rate: 100to the Subach HL-7, and aships.tbmthat gives the GTF Ulysses$PBank Capacity: ( 1000, 1000 ). - Start SM1-01 and drain some weapon energy.
I set the energy from Lua and paused before each screenshot: at 150/150 the Energy bar is full; at 148.5/150 and at 75/150 it is empty.
Expected vs. actual behavior
Expected: the bar is drawn in proportion to the weapon energy left.
Actual: it's full at 100% and empty at anything less.
Two more problems in the same gauge, found by reading the code and not run:
hudtarget.cpp:6030looks upWeapon_infowithcurrent_primary_bank, a bank number rather than a weapon class, so the Energy label's brightness comes from the wrong weapon.hudtarget.cpp:5997and:6060readWeapon_info[primary_bank_weapons[bx]]without checking for -1, which other HUD code guards against for an empty bank. I haven't confirmed an empty primary bank can reach this gauge.
Proposed fixes
- Do the multiplication before the truncation in the bar width, as above. One line.
- Fix the other two lookups in the same pass: use the weapon class in the current bank for the label, and skip banks set to -1.
- Compute the ratio as a float clamped to 0..1, then scale it to the bar width, so energy above the reserve can't overdraw either.
- Lingua principale
- C++
- Stelle
- 488
- Fork
- 184
- Merge medio
- 2g 2h
- PR unite (30g)
- 35
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di scp-fs2open/fs2open.github.com
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
scp-fs2open/fs2open.github.com#7946 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 66/100
scp-fs2open/fs2open.github.com#7932 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
scp-fs2open/fs2open.github.com#7924 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
scp-fs2open/fs2open.github.com#7918 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
scp-fs2open/fs2open.github.com#7917 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di scp-fs2open/fs2open.github.com
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SteveMacenski/slam_toolbox#907 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
HansKristian-Work/dxil-spirv#341 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 6 giorni