mirror of https://github.com/OpenTTD/OpenTTD
(svn r8178) -Backport from turnk (r8049, r8079, r8080, r8135):
- oe more news-window fix and fix up ShowLastNewsMessage (r8049) - float division by 0 in YAPF code on Win9x (r8079, r8080) - do not assert when removing duplicates would remove non-static grf (r8135)release/0.5
parent
8576c2cc40
commit
c73bbe531e
|
@ -158,7 +158,7 @@ static void RemoveDuplicatesFromGRFConfigList(GRFConfig *list)
|
|||
|
||||
for (prev = list, cur = list->next; cur != NULL; prev = cur, cur = cur->next) {
|
||||
if (cur->grfid != list->grfid) continue;
|
||||
assert(HASBIT(cur->flags, GCF_STATIC));
|
||||
|
||||
prev->next = cur->next;
|
||||
ClearGRFConfig(&cur);
|
||||
cur = prev; // Just go back one so it continues as normal later on
|
||||
|
|
29
news_gui.c
29
news_gui.c
|
@ -272,7 +272,6 @@ void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b)
|
|||
if (_total_news == MAX_NEWS && (_oldest_news == _current_news || _oldest_news == _forced_news))
|
||||
MoveToNextItem();
|
||||
|
||||
_forced_news = INVALID_NEWS;
|
||||
if (_total_news < MAX_NEWS) _total_news++;
|
||||
|
||||
/* Increase _latest_news. If we have no news yet, use _oldest news as an
|
||||
|
@ -555,16 +554,17 @@ static void ShowNewsMessage(NewsID i)
|
|||
|
||||
void ShowLastNewsMessage(void)
|
||||
{
|
||||
switch (_forced_news) {
|
||||
case INVALID_NEWS: // Not forced any news yet, show the current one
|
||||
ShowNewsMessage(_current_news);
|
||||
break;
|
||||
case 0: //
|
||||
ShowNewsMessage(_total_news != MAX_NEWS ? _latest_news : MAX_NEWS - 1);
|
||||
break;
|
||||
default: // 'Scrolling' through news history show each one in turn
|
||||
ShowNewsMessage(_forced_news - 1);
|
||||
break;
|
||||
if (_forced_news == INVALID_NEWS) {
|
||||
/* Not forced any news yet, show the current one, unless a news window is
|
||||
* open (which can only be the current one), then show the previous item */
|
||||
const Window *w = FindWindowById(WC_NEWS_WINDOW, 0);
|
||||
ShowNewsMessage((w == NULL) ? _current_news : decreaseIndex(_current_news));
|
||||
} else if (_forced_news == _oldest_news) {
|
||||
/* We have reached the oldest news, start anew with the latest */
|
||||
ShowNewsMessage(_latest_news);
|
||||
} else {
|
||||
/* 'Scrolling' through news history show each one in turn */
|
||||
ShowNewsMessage(decreaseIndex(_forced_news));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -889,7 +889,10 @@ void DeleteVehicleNews(VehicleID vid, StringID news)
|
|||
(news == INVALID_STRING_ID || ni->string_id == news)) {
|
||||
Window *w;
|
||||
|
||||
if (_forced_news == n || _current_news == n) MoveToNextItem();
|
||||
/* If we delete a forced news and it is just before the current news
|
||||
* then we need to advance to the next news (if any) */
|
||||
if (_forced_news == n) MoveToNextItem();
|
||||
if (_forced_news == INVALID_NEWS && _current_news == n) MoveToNextItem();
|
||||
_total_news--;
|
||||
|
||||
/* If this is the last news item, invalidate _latest_news */
|
||||
|
@ -908,7 +911,7 @@ void DeleteVehicleNews(VehicleID vid, StringID news)
|
|||
* We also need an update of the current, forced and visible (open window)
|
||||
* news's as this shifting could change the items they were pointing to */
|
||||
if (_total_news != 0) {
|
||||
NewsID i, visible_news;
|
||||
NewsID visible_news, i;
|
||||
w = FindWindowById(WC_NEWS_WINDOW, 0);
|
||||
visible_news = (w != NULL) ? (NewsID)(WP(w, news_d).ni - _news_items) : INVALID_NEWS;
|
||||
|
||||
|
|
|
@ -106,19 +106,21 @@ public:
|
|||
* - or the open list is empty (no route to destination).
|
||||
* - or the maximum amount of loops reached - m_max_search_nodes (default = 10000)
|
||||
* @return true if the path was found */
|
||||
inline bool FindPath(const Vehicle* v)
|
||||
inline bool FindPath(const Vehicle *v)
|
||||
{
|
||||
m_veh = v;
|
||||
|
||||
#ifndef NO_DEBUG_MESSAGES
|
||||
CPerformanceTimer perf;
|
||||
perf.Start();
|
||||
#endif /* !NO_DEBUG_MESSAGES */
|
||||
|
||||
Yapf().PfSetStartupNodes();
|
||||
|
||||
while (true) {
|
||||
m_num_steps++;
|
||||
Node* n = m_nodes.GetBestOpenNode();
|
||||
if (n == NULL)
|
||||
break;
|
||||
Node *n = m_nodes.GetBestOpenNode();
|
||||
if (n == NULL) break;
|
||||
|
||||
// if the best open node was worse than the best path found, we can finish
|
||||
if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate())
|
||||
|
@ -135,18 +137,25 @@ public:
|
|||
}
|
||||
bool bDestFound = (m_pBestDestNode != NULL);
|
||||
|
||||
int16 veh_idx = (m_veh != NULL) ? m_veh->unitnumber : 0;
|
||||
|
||||
// if (veh_idx != 433) return bDestFound;
|
||||
|
||||
#ifndef NO_DEBUG_MESSAGES
|
||||
perf.Stop();
|
||||
if (_debug_yapf_level >= 3) {
|
||||
int t = perf.Get(1000000);
|
||||
_total_pf_time_us += t;
|
||||
|
||||
UnitID veh_idx = (m_veh != NULL) ? m_veh->unitnumber : 0;
|
||||
char ttc = Yapf().TransportTypeChar();
|
||||
float cache_hit_ratio = (float)m_stats_cache_hits / (float)(m_stats_cache_hits + m_stats_cost_calcs) * 100.0f;
|
||||
float cache_hit_ratio = (m_stats_cache_hits == 0) ? 0.0f : ((float)m_stats_cache_hits / (float)(m_stats_cache_hits + m_stats_cost_calcs) * 100.0f);
|
||||
int cost = bDestFound ? m_pBestDestNode->m_cost : -1;
|
||||
int dist = bDestFound ? m_pBestDestNode->m_estimate - m_pBestDestNode->m_cost : -1;
|
||||
DEBUG(yapf, 3)("[YAPF][YAPF%c]%c%4d- %d us - %d rounds - %d open - %d closed - CHR %4.1f%% - c%d(sc%d, ts%d, o%d) -- ", ttc, bDestFound ? '-' : '!', veh_idx, t, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(), cache_hit_ratio, cost, dist, m_perf_cost.Get(1000000), m_perf_slope_cost.Get(1000000), m_perf_ts_cost.Get(1000000), m_perf_other_cost.Get(1000000));
|
||||
|
||||
DEBUG(yapf, 3) ("[YAPF%c]%c%4d- %d us - %d rounds - %d open - %d closed - CHR %4.1f%% - c%d(sc%d, ts%d, o%d) -- ",
|
||||
ttc, bDestFound ? '-' : '!', veh_idx, t, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(),
|
||||
cache_hit_ratio, cost, dist, m_perf_cost.Get(1000000), m_perf_slope_cost.Get(1000000),
|
||||
m_perf_ts_cost.Get(1000000), m_perf_other_cost.Get(1000000)
|
||||
);
|
||||
}
|
||||
#endif /* !NO_DEBUG_MESSAGES */
|
||||
return bDestFound;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue