Hey all,
I've been working on trying to get Sid Meier's Civilization V
(Civ5) up to a point where it works relatively flawlessly on WINE. The
largest issue is that installing the latest expansion pack has
completely hosed the game under WINE unless some rather ugly workarounds
have been taken. Specifically, the main issue is that Civ5 loads its
data files in the order returned by Find{First,Next}File(), and breaks
spectacularly if that order is disrupted. I documented my findings here:
http://bugs.winehq.org/show_bug.cgi?id=34122
As I sat to look at a possible patch, I'm not sure what I can
actually do. Its clearly stated on the MSDN page that the order returned
is dependent on the underlying filesystem, and Googling suggests that
while NTFS seems to always return in a roughly alphabetical order, FAT32
will return by creation date, and with network drives all bets are off.
I was even able to reproduce similar bugs in Civ5 by launching it from a
network drive (which I had already tested in advance to make sure it
returned an odd file order). FindFirstFile essentially calls down to
NtQueryDirectoryFile, which in turn either calls a system specific
syscall or readdir to get a list of files in a directory.
My first thought is to extend the underlying read_directory_*
functions in ntdll/directory.c so that they return an alphabetized list
(essentially taking the results from getdents/getdirentries/readdir,
sort them, then returning in the sort order whichever entry is next in
line). This would produce a behavior similar (but not identical) to what
is seen when operating under an NTFS filesystem.