(svn r26461) [1.4] -Backport from trunk:

- Fix: Avoid division by 0 when scaling flow values [FS#5970] (r26448)
- Feature: Draw links to match _settings_game.vehicle.road_side [FS#5961] (r26445)
- Change: Use pkg-config for libpng as well (r26435, r26433, r26432)
- Feature: Load button for heightmap list [FS#5953] (r26428)
This commit is contained in:
frosch 2014-04-13 10:52:19 +00:00
parent 42c7cb38fa
commit f8b956bc2c
7 changed files with 72 additions and 129 deletions

View File

@ -1700,17 +1700,18 @@ make_cflags_and_ldflags() {
if [ -n "$png_config" ]; then
CFLAGS="$CFLAGS -DWITH_PNG"
CFLAGS="$CFLAGS `$png_config --cppflags --I_opts | tr '\n\r' ' '`"
CFLAGS="$CFLAGS `$png_config --cflags | tr '\n\r' ' '`"
# The extra flags are unneeded for latest libpng-config, but some versions are so broken...
if [ "$enable_static" != "0" ]; then
if [ "$os" = "OSX" ]; then
LIBS="$LIBS `$png_config --prefix`/lib/libpng.a"
# fontconfig_config goes via pkg-config on all systems, which doesn't know --prefix
# Also, despite the reason we link to the .a file ourself (because we can't use -static), we do need to ask pkg-config about possible other deps
LIBS="$LIBS `$png_config --variable=prefix`/lib/libpng.a `$png_config --libs --static | sed s@-lpng[0-9]*@@`"
else
LIBS="$LIBS `$png_config --static --ldflags | tr '\n\r' ' '`"
LIBS="$LIBS `$png_config --libs --static | tr '\n\r' ' '`"
fi
else
LIBS="$LIBS `$png_config --ldflags | tr '\n\r' ' '`"
LIBS="$LIBS `$png_config --libs | tr '\n\r' ' '`"
fi
fi
@ -2715,80 +2716,64 @@ detect_libtimidity() {
detect_library "$with_libtimidity" "libtimidity" "libtimidity.a" "" "timidity.h"
}
detect_lzma() {
# 0 means no, 1 is auto-detect, 2 is force
if [ "$with_lzma" = "0" ]; then
log 1 "checking liblzma... disabled"
detect_pkg_config() {
# $1 - config-param ($with_lzma value)
# $2 - package name ('liblzma')
# $3 - config name ('lzma_config', sets $lzma_config)
# $4 - minimum module version ('2.3')
lzma_config=""
# 0 means no, 1 is auto-detect, 2 is force
if [ "$1" = "0" ]; then
log 1 "checking $2... disabled"
eval "$3=\"\""
return 0
fi
if [ "$with_lzma" = "1" ] || [ "$with_lzma" = "" ] || [ "$with_lzma" = "2" ]; then
lzma_config="pkg-config liblzma"
log 2 "detecting $2"
if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
pkg_config_call="pkg-config $2"
else
lzma_config="$with_lzma"
pkg_config_call="$1"
fi
version=`$lzma_config --modversion 2>/dev/null`
version=`$pkg_config_call --modversion 2>/dev/null`
ret=$?
log 2 "executing $lzma_config --modversion"
check_version "$4" "$version"
version_ok=$?
log 2 "executing $pkg_config_call --modversion"
log 2 " returned $version"
log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ]; then
log 1 "checking liblzma... not found"
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
log 1 "checking $2... needs at least version $4, $2 NOT enabled"
else
log 1 "checking $2... not found"
fi
# It was forced, so it should be found.
if [ "$with_lzma" != "1" ]; then
log 1 "configure: error: pkg-config liblzma couldn't be found"
log 1 "configure: error: you supplied '$with_lzma', but it seems invalid"
if [ "$1" != "1" ]; then
log 1 "configure: error: pkg-config $2 couldn't be found"
log 1 "configure: error: you supplied '$1', but it seems invalid"
exit 1
fi
lzma_config=""
eval "$3=\"\""
return 0
fi
log 1 "checking liblzma... found"
eval "$3=\"$pkg_config_call\""
log 1 "checking $2... found"
}
detect_lzma() {
detect_pkg_config "$with_lzma" "liblzma" "lzma_config" "5.0"
}
detect_xdg_basedir() {
# 0 means no, 1 is auto-detect, 2 is force
if [ "$with_xdg_basedir" = "0" ]; then
log 1 "checking libxdg_basedir... disabled"
xdg_basedir_config=""
return 0
fi
if [ "$with_xdg_basedir" = "1" ] || [ "$with_xdg_basedir" = "" ] || [ "$with_xdg_basedir" = "2" ]; then
xdg_basedir_config="pkg-config libxdg-basedir"
else
xdg_basedir_config="$with_xdg_basedir"
fi
version=`$xdg_basedir_config --modversion 2>/dev/null`
ret=$?
log 2 "executing $xdg_basedir_config --modversion"
log 2 " returned $version"
log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ]; then
log 1 "checking libxdg_basedir... not found"
# It was forced, so it should be found.
if [ "$with_xdg_basedir" != "1" ]; then
log 1 "configure: error: pkg-config libxdg_basedir couldn't be found"
log 1 "configure: error: you supplied '$with_xdg_basedir', but it seems invalid"
exit 1
fi
xdg_basedir_config=""
return 0
fi
log 1 "checking libxdg_basedir... found"
detect_pkg_config "$with_xdg_basedir" "libxdg-basedir" "xdg_basedir_config" "1.2"
}
detect_png() {
@ -2815,33 +2800,7 @@ detect_png() {
return 0
fi
if [ "$with_png" = "1" ] || [ "$with_png" = "" ] || [ "$with_png" = "2" ]; then
png_config="libpng-config"
else
png_config="$with_png"
fi
version=`$png_config --version 2>/dev/null`
ret=$?
log 2 "executing $png_config --version"
log 2 " returned $version"
log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ]; then
log 1 "checking libpng... not found"
# It was forced, so it should be found.
if [ "$with_png" != "1" ]; then
log 1 "configure: error: libpng-config couldn't be found"
log 1 "configure: error: you supplied '$with_png', but it seems invalid"
exit 1
fi
png_config=""
return 0
fi
log 1 "checking libpng... found"
detect_pkg_config "$with_png" "libpng" "png_config" "1.2"
}
detect_freetype() {
@ -2936,39 +2895,7 @@ detect_fontconfig() {
return 0
fi
if [ "$with_fontconfig" = "1" ] || [ "$with_fontconfig" = "" ] || [ "$with_fontconfig" = "2" ]; then
fontconfig_config="pkg-config fontconfig"
else
fontconfig_config="$with_fontconfig"
fi
version=`$fontconfig_config --modversion 2>/dev/null`
ret=$?
check_version '2.3' "$version"
version_ok=$?
log 2 "executing $fontconfig_config --modversion"
log 2 " returned $version"
log 2 " exit code $ret"
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
log 1 "checking libfontconfig... needs at least version 2.3.0, fontconfig NOT enabled"
else
log 1 "checking libfontconfig... not found"
fi
# It was forced, so it should be found.
if [ "$with_fontconfig" != "1" ]; then
log 1 "configure: error: fontconfig-config couldn't be found"
log 1 "configure: error: you supplied '$with_fontconfig', but it seems invalid"
exit 1
fi
fontconfig_config=""
return 0
fi
log 1 "checking libfontconfig... found"
detect_pkg_config "$with_fontconfig" "fontconfig" "fontconfig_config" "2.3"
}
detect_icu() {

View File

@ -133,9 +133,11 @@ static const NWidgetPart _nested_load_heightmap_dialog_widgets[] = {
SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0), SetFill(1, 0),
SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_LOAD_BUTTON), SetResize(1, 0), SetFill(1, 0),
SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_HEIGHTMAP_TOOLTIP),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),
EndContainer(),
@ -521,16 +523,21 @@ public:
break;
case WID_SL_LOAD_BUTTON:
if (this->selected != NULL && !_load_check_data.HasErrors() && (_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs())) {
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
if (this->selected != NULL && !_load_check_data.HasErrors()) {
const char *name = FiosBrowseTo(this->selected);
SetFiosType(this->selected->type);
strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
strecpy(_file_to_saveload.title, this->selected->title, lastof(_file_to_saveload.title));
ClearErrorMessages();
delete this;
if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
delete this;
ShowHeightmapLoad();
} else if (_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
ClearErrorMessages();
delete this;
}
}
break;
@ -679,6 +686,9 @@ public:
case 1:
/* Selection changes */
if (!gui_scope) break;
if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, this->selected == NULL || _load_check_data.HasErrors());
}
if (_saveload_mode == SLD_LOAD_GAME || _saveload_mode == SLD_LOAD_SCENARIO) {
this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON,
this->selected == NULL || _load_check_data.HasErrors() || !(_load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()));

View File

@ -2668,6 +2668,7 @@ STR_SAVELOAD_SAVE_BUTTON :{BLACK}Save
STR_SAVELOAD_SAVE_TOOLTIP :{BLACK}Save the current game, using the selected name
STR_SAVELOAD_LOAD_BUTTON :{BLACK}Load
STR_SAVELOAD_LOAD_TOOLTIP :{BLACK}Load the selected game
STR_SAVELOAD_LOAD_HEIGHTMAP_TOOLTIP :{BLACK}Load the selected heightmap
STR_SAVELOAD_DETAIL_CAPTION :{BLACK}Game Details
STR_SAVELOAD_DETAIL_NOT_AVAILABLE :{BLACK}No information available
STR_SAVELOAD_DETAIL_COMPANY_INDEX :{SILVER}{COMMA}: {WHITE}{STRING1}

View File

@ -49,8 +49,10 @@ void FlowMapper::Run(LinkGraphJob &job) const
FlowStatMap &flows = node.Flows();
flows.FinalizeLocalConsumption(node.Station());
if (this->scale) {
/* Scale by time the graph has been running without being compressed. */
uint runtime = job.JoinDate() - job.Settings().recalc_time - job.LastCompression();
/* Scale by time the graph has been running without being compressed. Add 1 to avoid
* division by 0 if spawn date == last compression date. This matches
* LinkGraph::Monthly(). */
uint runtime = job.JoinDate() - job.Settings().recalc_time - job.LastCompression() + 1;
for (FlowStatMap::iterator i = flows.begin(); i != flows.end(); ++i) {
i->second.ScaleToMonthly(runtime);
}

View File

@ -220,11 +220,12 @@ void LinkGraphOverlay::DrawContent(Point pta, Point ptb, const LinkProperties &c
/* Move line a bit 90° against its dominant direction to prevent it from
* being hidden below the grey line. */
int side = _settings_game.vehicle.road_side ? 1 : -1;
if (abs(pta.x - ptb.x) < abs(pta.y - ptb.y)) {
int offset_x = (pta.y > ptb.y ? 1 : -1) * this->scale;
int offset_x = (pta.y > ptb.y ? 1 : -1) * side * this->scale;
GfxDrawLine(pta.x + offset_x, pta.y, ptb.x + offset_x, ptb.y, colour, this->scale, dash);
} else {
int offset_y = (pta.x < ptb.x ? 1 : -1) * this->scale;
int offset_y = (pta.x < ptb.x ? 1 : -1) * side * this->scale;
GfxDrawLine(pta.x, pta.y + offset_y, ptb.x, ptb.y + offset_y, colour, this->scale, dash);
}

View File

@ -4314,9 +4314,11 @@ void FlowStat::ReleaseShare(StationID st)
/**
* Scale all shares from link graph's runtime to monthly values.
* @param runtime Time the link graph has been running without compression.
* @pre runtime must be greater than 0 as we don't want infinite flow values.
*/
void FlowStat::ScaleToMonthly(uint runtime)
{
assert(runtime > 0);
SharesMap new_shares;
uint share = 0;
for (SharesMap::iterator i = this->shares.begin(); i != this->shares.end(); ++i) {

View File

@ -23,4 +23,4 @@ enum StoryBookWidgets {
WID_SB_NEXT_PAGE, ///< Next button.
};
#endif /* WIDGETS_STORY_WIDGET_H */
#endif /* WIDGETS_STORY_WIDGET_H */