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.
This approach seems wrong to me, and is further compounded by the fact this is a bug in an application, and not in WINE specifically; Under the correct circumstances, Windows will return a "non-sorted" list of files and in those cases Civilization V breaks. The flipside is that in the most common case, it works correctly, and furthermore, given how easy it is to assume that Find*File does return a sorted list, I won't be surprised if this issue has cropped up elsewhere (figuring out the underlying cause was exceedingly annoying). Any insight in to what the most correct course of action would be most appreciated
I'm perfectly willing to put the legwork in fixing this bug, but I want to make sure I'm fixing it in a way that will be accepted :-).
Regards, Michael