mirror of https://github.com/OpenTTD/OpenTTD
(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)release/0.5
parent
0ec558f99f
commit
6ad4716dc1
4
fios.c
4
fios.c
|
@ -32,6 +32,7 @@ static int _fios_count, _fios_alloc;
|
|||
/* 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,6 +219,7 @@ static FiosItem *FiosGetFileList(int mode, fios_getlist_callback_proc *callback_
|
|||
|
||||
/* found file must be directory, but not '.' or '..' */
|
||||
if (FiosIsValidFile(_fios_path, dirent, &sb) && (sb.st_mode & S_IFDIR) &&
|
||||
(!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;
|
||||
|
@ -250,7 +252,7 @@ static FiosItem *FiosGetFileList(int mode, fios_getlist_callback_proc *callback_
|
|||
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;
|
||||
|
|
10
os2.c
10
os2.c
|
@ -114,11 +114,15 @@ bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb
|
|||
char filename[MAX_PATH];
|
||||
|
||||
snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name);
|
||||
if (stat(filename, sb) != 0) return false;
|
||||
|
||||
return (ent->d_name[0] != '.'); // hidden file
|
||||
return stat(filename, sb) == 0;
|
||||
}
|
||||
|
||||
bool FiosIsHiddenFile(const struct dirent *ent)
|
||||
{
|
||||
return ent->d_name[0] == '.';
|
||||
}
|
||||
|
||||
|
||||
static void ChangeWorkingDirectory(char *exe)
|
||||
{
|
||||
char *s = strrchr(exe, PATHSEPCHAR);
|
||||
|
|
|
@ -823,8 +823,8 @@ static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
|
|||
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;
|
||||
|
|
|
@ -27,6 +27,7 @@ typedef enum RoadStopType {
|
|||
|
||||
enum {
|
||||
INVALID_STATION = 0xFFFF,
|
||||
INITIAL_STATION_RATING = 175,
|
||||
ROAD_STOP_LIMIT = 16,
|
||||
};
|
||||
|
||||
|
|
|
@ -467,7 +467,7 @@ static void StationInitialize(Station *st, TileIndex tile)
|
|||
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 @@ static void UpdateStationRating(Station *st)
|
|||
|
||||
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 @@ void BuildOilRig(TileIndex tile)
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -134,6 +134,14 @@ static int CDECL StationWaitingSorter(const void *a, const void *b)
|
|||
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 @@ static int CDECL StationRatingMaxSorter(const void *a, const void *b)
|
|||
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;
|
||||
|
|
7
unix.c
7
unix.c
|
@ -92,9 +92,12 @@ bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb
|
|||
#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__)
|
||||
|
|
6
win32.c
6
win32.c
|
@ -743,7 +743,6 @@ bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb
|
|||
// 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 @@ bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue