# HG changeset patch # User rubidium # Date 1174335444 0 # Node ID 85b7662d0342d1c1b9de47cbe99611ef1d516d35 # Parent 30426b385cde82e25a1759b5fafaa0a2739eeeba (svn r9349) [0.5] -Backport from trunk (r9043, r9062, r9064, r9070): - Fix: the personal (.openttd) directories were hidden in the load/save directory listings (r9043) - Fix: the station list, sorted by cargo rating, now takes stations into account that have no cargo waiting (r9062) - Fix: don't keep on scrolling for non-numeric values in settings, but require reclick (r9064) - Fix: when a bribe failed and you haven't picked up cargo yet, you would never be able to do so for a given station (r9070) diff -r 30426b385cde -r 85b7662d0342 fios.c --- a/fios.c Mon Mar 19 20:05:49 2007 +0000 +++ b/fios.c Mon Mar 19 20:17:24 2007 +0000 @@ -32,6 +32,7 @@ /* OS-specific functions are taken from their respective files (win32/unix/os2 .c) */ extern bool FiosIsRoot(const char *path); extern bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb); +extern bool FiosIsHiddenFile(const struct dirent *ent); extern void FiosGetDrives(void); extern bool FiosGetDiskFreeSpace(const char *path, uint32 *tot); @@ -218,7 +219,8 @@ /* found file must be directory, but not '.' or '..' */ if (FiosIsValidFile(_fios_path, dirent, &sb) && (sb.st_mode & S_IFDIR) && - strcmp(d_name, ".") != 0 && strcmp(d_name, "..") != 0) { + (!FiosIsHiddenFile(dirent) || strncasecmp(d_name, PERSONAL_DIR, strlen(d_name)) == 0) && + strcmp(d_name, ".") != 0 && strcmp(d_name, "..") != 0) { fios = FiosAlloc(); fios->type = FIOS_TYPE_DIR; fios->mtime = 0; @@ -250,7 +252,7 @@ byte type; ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name)); - if (!FiosIsValidFile(_fios_path, dirent, &sb) || !(sb.st_mode & S_IFREG)) continue; + if (!FiosIsValidFile(_fios_path, dirent, &sb) || !(sb.st_mode & S_IFREG) || FiosIsHiddenFile(dirent)) continue; /* File has no extension, skip it */ if ((t = strrchr(d_name, '.')) == NULL) continue; diff -r 30426b385cde -r 85b7662d0342 os2.c --- a/os2.c Mon Mar 19 20:05:49 2007 +0000 +++ b/os2.c Mon Mar 19 20:17:24 2007 +0000 @@ -114,11 +114,15 @@ char filename[MAX_PATH]; snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name); - if (stat(filename, sb) != 0) return false; + return stat(filename, sb) == 0; +} - return (ent->d_name[0] != '.'); // hidden file +bool FiosIsHiddenFile(const struct dirent *ent) +{ + return ent->d_name[0] == '.'; } + static void ChangeWorkingDirectory(char *exe) { char *s = strrchr(exe, PATHSEPCHAR); diff -r 30426b385cde -r 85b7662d0342 settings_gui.c --- a/settings_gui.c Mon Mar 19 20:05:49 2007 +0000 +++ b/settings_gui.c Mon Mar 19 20:17:24 2007 +0000 @@ -823,8 +823,8 @@ if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min; } - /* Set up scroller timeout */ - if (value != oldvalue) { + /* Set up scroller timeout for numeric values */ + if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) { WP(w,def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0); w->flags4 |= 5 << WF_TIMEOUT_SHL; _left_button_clicked = false; diff -r 30426b385cde -r 85b7662d0342 station.h --- a/station.h Mon Mar 19 20:05:49 2007 +0000 +++ b/station.h Mon Mar 19 20:17:24 2007 +0000 @@ -27,6 +27,7 @@ enum { INVALID_STATION = 0xFFFF, + INITIAL_STATION_RATING = 175, ROAD_STOP_LIMIT = 16, }; diff -r 30426b385cde -r 85b7662d0342 station_cmd.c --- a/station_cmd.c Mon Mar 19 20:05:49 2007 +0000 +++ b/station_cmd.c Mon Mar 19 20:17:24 2007 +0000 @@ -467,7 +467,7 @@ ge->waiting_acceptance = 0; ge->days_since_pickup = 0; ge->enroute_from = INVALID_STATION; - ge->rating = 175; + ge->rating = INITIAL_STATION_RATING; ge->last_speed = 0; ge->last_age = 0xFF; ge->feeder_profit = 0; @@ -2473,6 +2473,12 @@ ge = st->goods; do { + /* Slowly increase the rating back to his original level in the case we + * didn't deliver cargo yet to this station. This happens when a bribe + * failed while you didn't moved that cargo yet to a station. */ + if (ge->enroute_from == INVALID_STATION && ge->rating < INITIAL_STATION_RATING) + ge->rating++; + /* Only change the rating if we are moving this cargo */ if (ge->enroute_from != INVALID_STATION) { byte_inc_sat(&ge->enroute_time); byte_inc_sat(&ge->days_since_pickup); @@ -2832,7 +2838,7 @@ st->goods[j].waiting_acceptance = 0; st->goods[j].days_since_pickup = 0; st->goods[j].enroute_from = INVALID_STATION; - st->goods[j].rating = 175; + st->goods[j].rating = INITIAL_STATION_RATING; st->goods[j].last_speed = 0; st->goods[j].last_age = 255; } diff -r 30426b385cde -r 85b7662d0342 station_gui.c --- a/station_gui.c Mon Mar 19 20:05:49 2007 +0000 +++ b/station_gui.c Mon Mar 19 20:17:24 2007 +0000 @@ -134,6 +134,14 @@ return (_internal_sort_order & 1) ? sum2 - sum1 : sum1 - sum2; } +/** + * qsort-compatible version of sorting two stations by maximum rating + * @param a First object to be sorted, must be of type (const Station *) + * @param b Second object to be sorted, must be of type (const Station *) + * @return The sort order + * @retval >0 a should come before b in the list + * @retval <0 b should come before a in the list + */ static int CDECL StationRatingMaxSorter(const void *a, const void *b) { const Station* st1 = *(const Station**)a; @@ -143,8 +151,8 @@ int j; for (j = 0; j < NUM_CARGO; j++) { - if (st1->goods[j].waiting_acceptance & 0xfff) maxr1 = max(maxr1, st1->goods[j].rating); - if (st2->goods[j].waiting_acceptance & 0xfff) maxr2 = max(maxr2, st2->goods[j].rating); + if (st1->goods[j].enroute_from != INVALID_STATION) maxr1 = max(maxr1, st1->goods[j].rating); + if (st2->goods[j].enroute_from != INVALID_STATION) maxr2 = max(maxr2, st2->goods[j].rating); } return (_internal_sort_order & 1) ? maxr2 - maxr1 : maxr1 - maxr2; diff -r 30426b385cde -r 85b7662d0342 unix.c --- a/unix.c Mon Mar 19 20:05:49 2007 +0000 +++ b/unix.c Mon Mar 19 20:17:24 2007 +0000 @@ -92,9 +92,12 @@ #endif snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name); - if (stat(filename, sb) != 0) return false; + return stat(filename, sb) == 0; +} - return (ent->d_name[0] != '.'); // hidden file +bool FiosIsHiddenFile(const struct dirent *ent) +{ + return ent->d_name[0] == '.'; } #if defined(__BEOS__) || defined(__linux__) diff -r 30426b385cde -r 85b7662d0342 win32.c --- a/win32.c Mon Mar 19 20:05:49 2007 +0000 +++ b/win32.c Mon Mar 19 20:17:24 2007 +0000 @@ -743,7 +743,6 @@ // hectonanoseconds between Windows and POSIX epoch static const int64 posix_epoch_hns = 0x019DB1DED53E8000LL; const WIN32_FIND_DATAW *fd = &ent->dir->fd; - if (fd->dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) return false; sb->st_size = ((uint64) fd->nFileSizeHigh << 32) + fd->nFileSizeLow; /* UTC FILETIME to seconds-since-1970 UTC @@ -757,6 +756,11 @@ return true; } +bool FiosIsHiddenFile(const struct dirent *ent) +{ + return (ent->dir->fd.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) != 0; +} + bool FiosGetDiskFreeSpace(const char *path, uint32 *tot) { UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box