Inside3D!
     

Tutorial: sv_progs: specify the "progs.dat" to run

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Programming Tutorials
View previous topic :: View next topic  
Author Message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Wed Nov 26, 2008 4:31 pm    Post subject: Tutorial: sv_progs: specify the "progs.dat" to run Reply with quote

You've got a mod ...

And it supports single player and maybe a bots version and if you are particularly creative maybe a 3rd version that supports who knows.

Do you want to distribute awkward zip files with 3 gamedirs ... because standard Quake would require 3 different progs.dat in 3 different gamedirs?

Adding sv_progs capability to GLQuake/WinQuake

DarkPlaces has had this for over 4 years, no doubt some others.

1. sv_main.c

Quote:
a. Right after "server_static_t svs;" at the top, add:

Code:
cvar_t  sv_progs = {"sv_progs", "progs.dat" };


We need to define the new cvar.

b. Right after "Cvar_RegisterVariable (&sv_maxspeed);", add:

Code:
Cvar_RegisterVariable (&sv_progs);


This registers it.

c. Find this and add the yellow

Quote:
// load progs to get entity field count
PR_LoadProgs (sv_progs.string);


We aren't just calling PR_LoadProgs anymore, but telling it what the "progs.dat" name is.


2. progs.h

Quote:
Find this and insert the yellow text replacing the word "void":

Quote:
void PR_LoadProgs (char *progsname);


3. pr_edict.c

Quote:
Goto PR_LoadProgs and make yellow changes:


Quote:
void PR_LoadProgs (char *progsname)
{
int i;

// flush the non-C variable lookup cache
for (i=0 ; i<GEFV_CACHESIZE ; i++)
gefvCache[i].field[0] = 0;

if (!progsname || !*progsname)
Host_Error("PR_LoadProgs: passed empty progsname");


CRC_Init (&pr_crc);

if (!(progs = (dprograms_t *)COM_LoadHunkFile (progsname)))
Sys_Error ("PR_LoadProgs: couldn't load %s", progsname);

Con_DPrintf ("Programs occupy %iK.\n", com_filesize/1024);

for (i=0 ; i<com_filesize ; i++)
CRC_ProcessByte (&pr_crc, ((byte *)progs)[i]);

// byte swap the header
for (i=0 ; i<sizeof(*progs)/4 ; i++)
((int *)progs)[i] = LittleLong ( ((int *)progs)[i] );

if (progs->version != PROG_VERSION)
Sys_Error ("%s has wrong version number (%i should be %i)", progsname, progs->version, PROG_VERSION);

if (progs->crc != PROGHEADER_CRC)
Sys_Error ("%s system vars have been modified, progdefs.h is out of date", progsname);

pr_functions = (dfunction_t *)((byte *)progs + progs->ofs_functions);


All we did was replace the instances of "progs.dat" with "%s" and sprintf the progsname in there.

Plus an empty progsname check.


In Closing

Now you could create a readme.txt with

Quote:
=============
My Readme.txt
=============
glquake -game mycastle +map mycastle
...
( description of mod )
...

We also included a bots version and a dmsp version. Just type "bots" or "dmsp" in the console to run those.

Requires DarkPlaces or <insert name here>


[Those bots/dmsp aliases would be in the autoexec.cfg, i.e. alias bots "sv_progs bots.dat; disconnect; maxplayers 4; map dm6", etc.]
Back to top
View user's profile Send private message
goldenboy



Joined: 05 Sep 2008
Posts: 310
Location: Kiel

PostPosted: Fri Nov 28, 2008 7:30 pm    Post subject: Reply with quote

good, is it also possible to have a command line switch?
Back to top
View user's profile Send private message
Spirit



Joined: 20 Nov 2004
Posts: 476

PostPosted: Fri Nov 28, 2008 8:52 pm    Post subject: Reply with quote

AS usual +sv_progs should work?
_________________
Quake Maps
Back to top
View user's profile Send private message Visit poster's website
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Fri Nov 28, 2008 9:45 pm    Post subject: Reply with quote

Spirit wrote:
AS usual +sv_progs should work?


That'd work, yes.

c:\quake\<your quake>.exe -game whatever +sv_progs bots.dat
Back to top
View user's profile Send private message
Team Xlink



Joined: 25 Jun 2009
Posts: 320

PostPosted: Fri Nov 20, 2009 12:54 am    Post subject: Reply with quote

Is it possible to change it through the quake.cmdline file?
_________________
Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!


Last edited by Team Xlink on Fri Nov 20, 2009 1:05 am; edited 1 time in total
Back to top
View user's profile Send private message
Downsider



Joined: 16 Sep 2008
Posts: 478

PostPosted: Fri Nov 20, 2009 1:03 am    Post subject: Reply with quote

If you read the code, you would know the answer is yes.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Programming Tutorials 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