[CF-Devel] Patch submission: Windows random map issue

crossfire-devel-admin at archives.real-time.com crossfire-devel-admin at archives.real-time.com
Sat Aug 23 04:22:19 CDT 2003


Hello.

A guest on the forum reported random map being broken on server under 
Windows.

Here's a patch to correct that.
It concerns only the server/win32.c file, so shouldn't change anything 
for other platforms.

The 2 fixes are:
* clear errno after last file was found in readdir, since Windows sets 
it to ENOENT (not 0) => CF thinks something fails, which is bad
* d_reclen field on dirent structure was only the length of the name, 
but is used elsewhere as the length of the whole structure. Fixed that 
(note that it won't work on multibyte platforms)

If someone could put that in cvs (after checking it doesn't break 
anything for other platforms :-), many thanks.

Nicolas 'Ryo'
-------------- next part --------------
RCS file: /cvsroot/crossfire/crossfire/server/win32.c,v
retrieving revision 1.2
diff -r1.2 win32.c
30c30
< 
---
>
     
     
     104c104,107
< 			dp->finished = 1;
---
>
     
      			dp->finished = 1;
     
     >
     
            if (ENOENT == errno)
     
     >
     
              /* Clear error set to mean no more files else that breaks things */
     
     >
     
              errno = 0;
     
     111,112c114,116
< 	dp->dent.d_ino = 1;
< 	dp->dent.d_reclen = strlen(dp->dent.d_name);
---
>
     
      	dp->dent.d_ino = 1;
     
     >
     
        /* reclen is used as meaning the length of the whole record */
     
     >
     
      	dp->dent.d_reclen = strlen(dp->dent.d_name) + sizeof(char) + sizeof(dp->dent.d_ino) + sizeof(dp->dent.d_reclen) + sizeof(dp->dent.d_off);
     
     
    


More information about the crossfire mailing list