mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-08 15:30:00 +00:00
Fix: Dereference of past-the-end iterator in linkgraph overlay tooltip (#10145)
This commit is contained in:
parent
7711907a6b
commit
e931f3061f
@ -379,16 +379,20 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond)
|
|||||||
char *buf_end = buf;
|
char *buf_end = buf;
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
/* Fill buf with more information if this is a bidirectional link. */
|
/* Fill buf with more information if this is a bidirectional link. */
|
||||||
|
uint32 back_time = 0;
|
||||||
auto k = this->cached_links[j->first].find(i->first);
|
auto k = this->cached_links[j->first].find(i->first);
|
||||||
|
if (k != this->cached_links[j->first].end()) {
|
||||||
const auto &back = k->second;
|
const auto &back = k->second;
|
||||||
if (k != this->cached_links[j->first].end() && back.Usage() > 0) {
|
back_time = back.time;
|
||||||
|
if (back.Usage() > 0) {
|
||||||
SetDParam(0, back.cargo);
|
SetDParam(0, back.cargo);
|
||||||
SetDParam(1, back.Usage());
|
SetDParam(1, back.Usage());
|
||||||
SetDParam(2, back.Usage() * 100 / (back.capacity + 1));
|
SetDParam(2, back.Usage() * 100 / (back.capacity + 1));
|
||||||
buf_end = GetString(buf, STR_LINKGRAPH_STATS_TOOLTIP_RETURN_EXTENSION, lastof(buf));
|
buf_end = GetString(buf, STR_LINKGRAPH_STATS_TOOLTIP_RETURN_EXTENSION, lastof(buf));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Add information about the travel time if known. */
|
/* Add information about the travel time if known. */
|
||||||
const auto time = link.time ? back.time ? ((link.time + back.time) / 2) : link.time : back.time;
|
const auto time = link.time ? back_time ? ((link.time + back_time) / 2) : link.time : back_time;
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
SetDParam(0, time);
|
SetDParam(0, time);
|
||||||
buf_end = GetString(buf_end, STR_LINKGRAPH_STATS_TOOLTIP_TIME_EXTENSION, lastof(buf));
|
buf_end = GetString(buf_end, STR_LINKGRAPH_STATS_TOOLTIP_TIME_EXTENSION, lastof(buf));
|
||||||
|
Loading…
Reference in New Issue
Block a user