Tutorial *126*

Ever hated the fact that Quake will only ever load PAK files that follow the PAK#.PAK naming convention? Ever wanted more appropriate names for your PAK files? This tutorial will show you how to make Quake load any PAK file, not just ones following the PAK#.PAK naming convention.

Before we start, Id like to point out that parts of this code were taken from the Q3Radiant source release, I just found it and worked it into Quake.

All changes are in common.c
At the top of the file, after the line:


#include "quakedef.h"

add:


#include "io.h"

In COM_AddGameDirectory, declare the following at the top of the functions, after the other declarations:


 char dirstring[1024];

 int  handle;

 struct _finddata_t fileinfo;

Now find the code that reads:


 for (i=0 ; ; i++)

 {

  sprintf (pakfile, "%s/pak%i.pak", dir, i);

  pak = COM_LoadPackFile (pakfile);

  if (!pak)

   break;

  search = Hunk_Alloc (sizeof(searchpath_t));

  search->pack = pak;

  search->next = com_searchpaths;

  com_searchpaths = search;

 }

Replace it with the following code:


// add ANY pak file - MrG (biteme@telefragged.com)

      sprintf (dirstring, "%s/*.pak", dir);

      handle = _findfirst (dirstring, &fileinfo);

      if (handle != -1)

      {

        do

        {

          if (fileinfo.name[0] == '.')

            continue;

  sprintf(pakfile,"%s/%s", dir, fileinfo.name);

  pak = COM_LoadPackFile (pakfile);

  if (!pak)

   break;

  search = Hunk_Alloc (sizeof(searchpath_t));

  search->pack = pak;

  search->next = com_searchpaths;

  com_searchpaths = search;

        } while (_findnext( handle, &fileinfo ) != -1);

        _findclose (handle);

      }

// end of PAK code update

Now compile the code. Quake will now load *ANY* PAK file, not just ones that follow the pak#.pak format.


 
Not logged in
Sign up
Login:
Passwd: