Author Topic: Bugfix for map list sort order  (Read 1366 times)

SoftCoder

  • PGP
  • Posts: 25
Bugfix for map list sort order
« on: December 26, 2009, 04:01:58 PM »
While looking at the XReal project and figuring out what features need to be ported to that new quake engine (in order to make a new paintball clone), I noticed on my linux version of PB2 (v27) the maps list seems sorted ina random order as returned by the filesystem. For anyone who knows how to re-compile pb2 this can be fixed since you have access to the code which retrieves the maps list.. actually I changed it for all calls to getting file lists. To fix the map sort order edit qcommon/files.c as follows:

navigate  the method:

char **FS_ListFiles (const char *findname, int *numfiles, unsigned musthave, unsigned canthave)

just above the last line (return list;) add this:

qsort (&list[0], nfiles, sizeof(char *), SortList);

Now navigate to the SortList method and change it to:

int SortList (const void *data1, const void *data2)
{
    const char **a = (const char **)data1;
    const char **b = (const char **)data2;
    return strcmp(*a, *b);
}

Recompile and viola.. maps are sorted alphabetically again.



SoftCoder

  • PGP
  • Posts: 25
Re: Bugfix for map list sort order
« Reply #1 on: December 26, 2009, 11:06:32 PM »
If anyone wants the compiled Linux version I zipped the binary (with the 3 shared libs created by the makefile)

http://www.soft-haus.com/games/paintball2.7z


jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Bugfix for map list sort order
« Reply #2 on: December 29, 2009, 02:06:32 AM »
Thanks - I'm not at home right now, so I can't add this change, but I'll try to remember to add it when I get home.  I'm going to try editing it on the CVS from my laptop so I can just grab it before I do another release.

In the mean time, don't use modified client executables while playing online, as it's basically impossible to distinguish between legitimate modifications and cheats.