Inside3D!
     

COM_LoadPackFile

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming
View previous topic :: View next topic  
Author Message
Stealth Kill



Joined: 29 Dec 2006
Posts: 83

PostPosted: Sun Dec 14, 2008 2:05 pm    Post subject: COM_LoadPackFile Reply with quote

hi,

How can i use the function COM_LoadPackFile?
I made a Language menu

here is a small part

case 0:
COM_LoadPackFile ("PAKeng");
M_Menu_Main_f();
break;

case 1:
COM_LoadPackFile ("PAKdt");
M_Menu_Main_f();
break;

I removed my singleplayer.lmp from PAK0
and added it to PAKeng and PAKdt with different languages.

The Game starts with the language menu.
If I choose a language it should load the pak file and
go to main menu but
says singleplayer.lmp not found.

i think it doesnīt load the pak file but i donīt know why.
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Sun Dec 14, 2008 10:18 pm    Post subject: Re: COM_LoadPackFile Reply with quote

Stealth Kill wrote:

case 0:
COM_LoadPackFile ("PAKeng");
M_Menu_Main_f();
break;

case 1:
COM_LoadPackFile ("PAKdt");
M_Menu_Main_f();
break;



With the code above, you aren't specifying a directory or a file extension so it isn't finding the file.

Code:
//
// add any pak files in the format pak0.pak pak1.pak, ...
//
   for (i=0 ; ; i++)
   {
      sprintf (pakfile, "%s/pak%i.pak", dir, i);
      pak = COM_LoadPackFile (pakfile);


The sprintf above is printing the directory into the variable with the extension.
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Mon Dec 15, 2008 2:14 am    Post subject: Re: COM_LoadPackFile Reply with quote

Stealth Kill wrote:

case 0:
COM_LoadPackFile ("PAKeng");
M_Menu_Main_f();
break;

case 1:
COM_LoadPackFile ("PAKdt");
M_Menu_Main_f();
break;


ADD: Try these instead COM_LoadPackFile(va("%s/pakeng.pak", dir)) and COM_LoadPackFile(va("%s/pakdt.pak", dir));

Should work, at least as far as properly getting the pak file acknowledged as a place to look for files.

However, it looks like you are doing the above in the menu. The .lmp files are read rather early. Unless you are doing a command line parameter to specify the language, you'd need to get the menu elements reloaded.
Back to top
View user's profile Send private message
Stealth Kill



Joined: 29 Dec 2006
Posts: 83

PostPosted: Mon Dec 15, 2008 2:30 pm    Post subject: Reply with quote

hmmm i donīt know how to reload the menu Sad
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Mon Dec 15, 2008 3:09 pm    Post subject: Reply with quote

Stealth Kill wrote:
hmmm i donīt know how to reload the menu Sad


Sometime later today (several hours from now), I'll help you add it as a command line parameter (i.e. "yourquake -english") which will at least get this initially working for you for testing.

From that point forward, I'll look and see what surprises lie in reloading the menu elements (if any).
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Mon Dec 15, 2008 10:46 pm    Post subject: Reply with quote

The command line parameter method of solving your problem:

In the example, there are 2 pak files named menu-dt.pak and menu-eng.pak.

If "-lang_dt" is added to the command line as such:

c:\quake\quake.exe -lang_dt

It will load the menu-dt.pak, otherwise it will by default use the menu-eng.pak.


common.c wrote:

/*
================
COM_AddGameDirectory

Sets com_gamedir, adds the directory to the head of the path,
then loads and adds pak1.pak pak2.pak ...
================
*/
void COM_AddGameDirectory (char *dir)
{
int i;
searchpath_t *search;
pack_t *pak;
char pakfile[MAX_OSPATH];

strcpy (com_gamedir, dir);

//
// add the directory to the search path
//
search = Hunk_Alloc (sizeof(searchpath_t));
strcpy (search->filename, dir);
search->next = com_searchpaths;
com_searchpaths = search;

//
// add any pak files in the format pak0.pak pak1.pak, ...
//
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;
}

/* Begin modification */
if ((i = COM_CheckParm("-lang_dt"))) { // Check for command line param
// Load German Menu
sprintf (pakfile, "%s/menu-dt.pak", dir); // set filename
} else {
// None specified, load English
sprintf (pakfile, "%s/menu-eng.pak", dir); // set filename
}

pak = COM_LoadPackFile (pakfile); // Try to load it
if (pak) { // If successfully loaded, add to end of search paths
search = Hunk_Alloc (sizeof(searchpath_t));
search->pack = pak;
search->next = com_searchpaths;
com_searchpaths = search;
}

/* End modification */



//
// add the contents of the parms.txt file to the end of the command line
//

}


I didn't test this out but it should work as-is.
Back to top
View user's profile Send private message
Stealth Kill



Joined: 29 Dec 2006
Posts: 83

PostPosted: Tue Dec 23, 2008 12:50 pm    Post subject: Reply with quote

It works thanks Smile

is it possible with a cvar too?

i tried this

Code:

/* Begin modification */
if (i = (language.value == 1)) {
// Load German Menu
sprintf (pakfile, "%s/german.pak", dir); // set filename
} else {
// None specified, load English
sprintf (pakfile, "%s/english.pak", dir); // set filename


if i write this language "1" to my config.cfg
it stilll loads the english.pak.
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Dec 23, 2008 3:57 pm    Post subject: Reply with quote

Stealth Kill wrote:
It works thanks Smile

is it possible with a cvar too?


Not as easily in the way you want to do it. The pakfiles are read at startup. Then the graphics are loaded.

It would almost be easier to load both menus at startup and have both sets of menus available. Then you could use a cvar.
_________________
Tomorrow Never Dies. I feel this Tomorrow knocking on the door ...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group