Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: DTP on October 14, 2002, 03:32:18 pm

Title: MOD support´, real mod support
Post by: DTP on October 14, 2002, 03:32:18 pm
it seems i just managed to get real mod support into the fs2source,

preliminary tests show it to work well and so far no bugs.

so how did i do it.

Well, i have added yet another commandline arguement.

if you start my exe that is in fs2dtpmod.exe like this

fs2dtpmod.exe -mod mymod

then the game will look for additional files in

Freespace2/mymod/data
Freespace2/mymod/data/tables
Freespace2/mymod/data/models/

and all files found there will be used

any files not found there will be looked for

in

freespace2/
freespace2/data/
freespace2/data/tables.

I´m pretty sure it works, but further testing is needed before i will go ahead and commit it.

this will solve several problems, like when people play with the same pilot in different mods

I´m not sure however if it will accept VP files in
the mod root that in this case would be freespace2/mymod/

but here is what i did
----------------
in cfile/cfile.h around line 392

#define CF_TYPE_MOD_ROOT         36
#define CF_TYPE_MOD_DATA         37
#define CF_TYPE_MOD_MAPS         38
#define CF_TYPE_MOD_TEXT         39
#define CF_TYPE_MOD_MISSIONS      40
#define CF_TYPE_MOD_MODELS         41
#define CF_TYPE_MOD_TABLES         42
#define CF_TYPE_MOD_SOUNDS         43
#define CF_TYPE_MOD_SOUNDS_8B22K   44
#define CF_TYPE_MOD_SOUNDS_16B11K   45
#define CF_TYPE_MOD_VOICE         46
#define CF_TYPE_MOD_VOICE_BRIEFINGS      47
#define CF_TYPE_MOD_VOICE_CMD_BRIEF   48   
#define CF_TYPE_MOD_VOICE_DEBREIFINGS 49
#define CF_TYPE_MOD_VOICE_PERSONAS      50
#define CF_TYPE_MOD_VOICE_SPECIAL   51
#define CF_TYPE_MOD_VOICE_TRAINING   52
#define CF_TYPE_MOD_MUSIC         53
#define CF_TYPE_MOD_MOVIES         54
#define CF_TYPE_MOD_INTERFACE      55
#define CF_TYPE_MOD_FONT         56
#define CF_TYPE_MOD_EFFECTS         57
#define CF_TYPE_MOD_HUD            58
#define CF_TYPE_MOD_PLAYER_MAIN      59
#define CF_TYPE_MOD_PLAYER_IMAGES_MAIN   60
#define CF_TYPE_MOD_CACHE         61
#define CF_TYPE_MOD_PLAYERS         62
#define CF_TYPE_MOD_SINGLE_PLAYERS   63
#define CF_TYPE_MOD_MULTI_PLAYERS   64
#define CF_TYPE_MOD_MULTI_CACHE      65
#define CF_TYPE_MOD_CONFIG         66
#define CF_TYPE_MOD_SQUAD_IMAGES_MAIN   67
#define CF_TYPE_MOD_DEMOS         68
#define CF_TYPE_MOD_CBANIMS         69
#define CF_TYPE_MOD_INTEL_ANIMS      70

#define CF_MAX_PATH_TYPES            71

-----------------
in cfile / cfile.cpp at the very start of function int cfile_init(char *exe_dir, char *cdrom_dir)

{
   if(Cmdline_mod) {
      char modname[256];
      Cmdline_mod = cf_add_modname(Cmdline_mod, "\\");
      strcpy(modname,Cmdline_mod);
      strcpy(Pathtypes[2].path,cf_add_modname(Cmdline_mod,"Data"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[3].path,cf_add_modname(Cmdline_mod,"Data\\Maps"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[4].path,cf_add_modname(Cmdline_mod,"Data\\Text"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[5].path,cf_add_modname(Cmdline_mod,"Data\\Missions"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[6].path,cf_add_modname(Cmdline_mod,"Data\\Models"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[7].path,cf_add_modname(Cmdline_mod,"Data\\Tables"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[8].path,cf_add_modname(Cmdline_mod,"Data\\Sounds"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[9].path,cf_add_modname(Cmdline_mod,"Data\\Sounds\\8b22k"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[10].path,cf_add_modname(Cmdline_mod,"Data\\Sounds\\16b11k"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[11].path,cf_add_modname(Cmdline_mod,"Data\\Voice"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[12].path,cf_add_modname(Cmdline_mod,"Data\\Voice\\Briefing"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[13].path,cf_add_modname(Cmdline_mod,"Data\\Voice\\Command_briefings"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[14].path,cf_add_modname(Cmdline_mod,"Data\\Voice\\Debriefing"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[15].path,cf_add_modname(Cmdline_mod,"Data\\Voice\\Personas"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[16].path,cf_add_modname(Cmdline_mod,"Data\\Voice\\Special"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[17].path,cf_add_modname(Cmdline_mod,"Data\\Voice\\Training"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[18].path,cf_add_modname(Cmdline_mod,"Data\\Music"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[19].path,cf_add_modname(Cmdline_mod,"Data\\Movies"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[20].path,cf_add_modname(Cmdline_mod,"Data\\Interface"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[21].path,cf_add_modname(Cmdline_mod,"Data\\Fonts"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[22].path,cf_add_modname(Cmdline_mod,"Data\\Effects"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[23].path,cf_add_modname(Cmdline_mod,"Data\\Hud"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[24].path,cf_add_modname(Cmdline_mod,"Data\\Players"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[25].path,cf_add_modname(Cmdline_mod,"Data\\Players\\Images"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[26].path,cf_add_modname(Cmdline_mod,"Data\\Data\\Cache"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[27].path,cf_add_modname(Cmdline_mod,"Data\\Players"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[28].path,cf_add_modname(Cmdline_mod,"Data\\Players\\Single"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[29].path,cf_add_modname(Cmdline_mod,"Data\\Players\\Multi"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[30].path,cf_add_modname(Cmdline_mod,"Data\\Players\\MultiData"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[31].path,cf_add_modname(Cmdline_mod,"Data\\Config"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[32].path,cf_add_modname(Cmdline_mod,"Data\\Players\\Squads"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[33].path,cf_add_modname(Cmdline_mod,"Data\\Demos"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[34].path,cf_add_modname(Cmdline_mod,"Data\\CBAnims"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[35].path,cf_add_modname(Cmdline_mod,"Data\\IntelAnims"));
      Cmdline_mod = modname;
      strcpy(Pathtypes[36].path,cf_add_modname(Cmdline_mod,""));
      Cmdline_mod = modname;

      Hold_mod = Pathtypes[7].path; //DTP debugthing
   }

i know that above could be done with a loop like for(i =2;I<37;I++), but im still learning, and believe me, I learned quite a bit about conversions when speaking c++.

and in the same file i added this function that is very similar to *cf_add_ext(*x,*x)

char *cf_add_modname(char *filename, char *ext)
{
   int flen, elen;
   static char path[MAX_PATH_LEN];

   flen = strlen(filename);
   elen = strlen(ext);
   Assert(flen < MAX_PATH_LEN);
   strcpy(path, filename);
   if ((flen < MAX_PATH_LEN) || stricmp(path + flen - elen, ext)) {
      Assert(flen + elen < MAX_PATH_LEN);
      strcat(path, ext);
   }

   return path;
}

I will download some VP files and start checking it out, but so far it looks soooo sweet :D.
Title: MOD support´, real mod support
Post by: Zarax on October 14, 2002, 03:34:31 pm
wow, would be very cool...
Is this feature going to be added to the "official" fs2 open exe?
Title: MOD support´, real mod support
Post by: Inquisitor on October 14, 2002, 03:39:25 pm
I think it might be safe to say yes :)
Title: MOD support´, real mod support
Post by: RandomTiger on October 14, 2002, 03:41:28 pm
If it does what I think it does, great stuff.

Does the work for total conversions like TBP having different hall graphics? What would be fantastic is if you could change between MOD's in the campaign chooser.

Great work. :yes:
Title: MOD support´, real mod support
Post by: RandomTiger on October 14, 2002, 03:42:24 pm
If it does what I think it does, great stuff.

Does the work for total conversions like TBP having different hall graphics? What would be fantastic is if you could change between MOD's in the campaign chooser.

Great work. :yes:
Title: MOD support´, real mod support
Post by: Solatar on October 14, 2002, 04:32:53 pm
We heard you the first time.:D :D ;)
Title: MOD support´, real mod support
Post by: Solatar on October 14, 2002, 04:33:01 pm
I've heard of double posts, but I've never gotten a triple one.
Title: MOD support´, real mod support
Post by: Solatar on October 14, 2002, 04:33:12 pm
Oops, I guess my modem is acting up also.
Title: MOD support´, real mod support
Post by: RandomTiger on October 14, 2002, 04:53:11 pm
:rolleyes:

Very mature Hades.
Looks like this thread has an echo.
Title: MOD support´, real mod support
Post by: Solatar on October 14, 2002, 05:00:57 pm
I must have pressed the button to many times. My connection has been acting up.

And back on topic. Will the player be able to run MOD specific .exe's by running fs2_open, and having it automatically run them?
Title: MOD support´, real mod support
Post by: KARMA on October 14, 2002, 07:06:51 pm
cool
Title: MOD support´, real mod support
Post by: phreak on October 14, 2002, 07:14:18 pm
yay!!!!1
Title: MOD support´, real mod support
Post by: Nico on October 15, 2002, 03:06:45 am
call me stupid, but I didn't get what it was supposed to do :p
Title: MOD support´, real mod support
Post by: DTP on October 15, 2002, 03:59:31 am
Quote
Originally posted by venom2506
call me stupid, but I didn't get what it was supposed to do :p


Instead of copying Table files in and out of the default directories, you will be able to have several table files in directories like freespace2/mymod/data/tables/ and to active them you simply add a commandline switch to the exe like

fs2_open.exe -mymod

and the table file will be used instead of the ones found in the root or in VP files.

this goes for all graphics, sound files aswell.

seems VP files will still have to be in the root dir freespace2/
or it will chrash, but i beleive i have indentified the place where to take action in order for it to accept VP files in other places.

working on that.

for now, only plain files in the mod directory is working.
Title: MOD support´, real mod support
Post by: DTP on October 15, 2002, 04:03:35 am
Quote
Originally posted by Hades
I must have pressed the button to many times. My connection has been acting up.

And back on topic. Will the player be able to run MOD specific .exe's by running fs2_open, and having it automatically run them?


no not mod specific exes, this is built inside fs2_open. and fs2_open.exe dont call any other exe files. read my post above.

it is almost like if you run halflife.exe -game mymod, except it does not call in dll files.

this simply reads all files found in the mod directory and uses them instead of using identical ones found ín the default directories.
Title: MOD support´, real mod support
Post by: LAW ENFORCER on October 15, 2002, 04:32:19 am
ok... how would a mod specific .exe work and can you get that to do the same thing inside FS2 with some interface like the pilot one?
Title: MOD support´, real mod support
Post by: Inquisitor on October 15, 2002, 07:29:20 am
A mod specific exe would work the same way, just be compiled with different options of or have different command line flags indicating different options should be enabled.

fs2_open.exe -gf4fix -mod blah blah for instance.

As for doing it thru a menu: One thing at a time man :)
Title: MOD support´, real mod support
Post by: RandomTiger on October 15, 2002, 08:42:46 am
Oh... please we dont want to have MOD specific exe do we?
Title: MOD support´, real mod support
Post by: Stunaep on October 15, 2002, 08:47:46 am
this would be a gift from heaven!!


BTW, when are we gonna get our hands on the next fs2_open version?
Title: MOD support´, real mod support
Post by: Inquisitor on October 15, 2002, 11:25:50 am
RT: not us, but, if say they downloaded the source, changed some things (like Robotech is doing), then, they would effectively have their own exe. We might inlcude options that are flagged on or off though, like the beam tiling, that would be a runtime choice.

So "we" are not making a mod exe, but we are including options for modders to use, and obviously any mod team with a competent coder could make a custom exe ;)
Title: MOD support´, real mod support
Post by: Sesquipedalian on October 15, 2002, 04:15:02 pm
Hallelujah!  Thank God for DTP.  :)
Title: MOD support´, real mod support
Post by: EdrickV on October 17, 2002, 10:44:58 pm
With a little luck, I think we may be able to get the Robotech MOD's changes (transforming ships via in game POF swapping) merged into the main fs2_open tree so that a seperate exe isn't needed. (The RT MOD's exe was started using the original code so doesn't have all the enhancements that fs2_open has/will have.) The idea we're working on is to have a seperate table that, if present, will specify what ships can transform, how they can transform, and what ship table entries go with each mode.

Our original method used ships with fake "turrets" that when destroyed would "transform" the ship because the turret submodel would be replaced with the destroyed turret submodel. However, with the original exe you couldn't restore the turret submodel. That's where we first got fiddling with the code. (Ronin more then me since he has the better tools.)

Has anyone checked to see if this mod support change will let the game load player info from the mod directory?

As far as easy use of MODs, we could probably make a replacement launcher that would let you chose whether to run FS2 with a particular mod (from a list) or without any mods. And have options for running the original FS2 and other stuff.
Title: MOD support´, real mod support
Post by: DTP on October 18, 2002, 08:12:05 pm
Quote
Originally posted by EdrickV
With a little luck, I think we may be able to get the Robotech MOD's changes (transforming ships via in game POF swapping) merged into the main fs2_open tree so that a seperate exe isn't needed. (The RT MOD's exe was started using the original code so doesn't have all the enhancements that fs2_open has/will have.) The idea we're working on is to have a seperate table that, if present, will specify what ships can transform, how they can transform, and what ship table entries go with each mode.

Our original method used ships with fake "turrets" that when destroyed would "transform" the ship because the turret submodel would be replaced with the destroyed turret submodel. However, with the original exe you couldn't restore the turret submodel. That's where we first got fiddling with the code. (Ronin more then me since he has the better tools.)

Has anyone checked to see if this mod support change will let the game load player info from the mod directory?

As far as easy use of MODs, we could probably make a replacement launcher that would let you chose whether to run FS2 with a particular mod (from a list) or without any mods. And have options for running the original FS2 and other stuff.


It is not committed yet, since I’m "fiddling" with the support for VP files so all u need to have in that directory is a VP file and of course the player directories, so I’m the only one who can answer this.

But player files, the so-called .plr files are read from the mod directory. thus avoiding the playing with the same pilot in several mods.

Also; mission files are also read from the mod directory.
again avoiding the having missions from another mod in the default fs2/data/mission directory.

Right know this is only developer friendly and not very user friendly, since only plain files in the mod directory is supported.

once i get "VP files in mod directory" support. This will be equally user-friendly, since people then can have several mods on their HD in the same directory all the time.

what I aim it to be is to be like the "Quake" method. Where it accepts all .pak files and other files in the mod directory.

Special for us is the player files. A thing Quake or Half-life didn’t have to bother with since it only supported 1 profile.
Title: MOD support´, real mod support
Post by: DTP on October 23, 2002, 08:21:18 pm
look in demo build thread.

VP files are now supported when being in the mod directory.
Title: MOD support´, real mod support
Post by: Inquisitor on October 23, 2002, 09:32:08 pm
Did I miss a committ email?
Title: MOD support´, real mod support
Post by: EdrickV on October 23, 2002, 11:02:30 pm
This will be a nice addition when it's comitted and released. :) I know people want MOD support for multiplayer and I did a little thinking ahead. One thing that will probably be needed, if and when we get MODs working in multiplayer, is a way to make sure that people are using the same MOD when trying to do multiplayer. With this MOD directory feature, it occured to me that we could define a simple text/table type file that would contain a version string identifying that MOD and what version of that MOD it is. Example:

$MODversion:     Robotech MOD 4.0

With MOD support, the MODders could just stick that version file in their VP and the program, when it knows it's using a MOD via the command line argument, could also read in that version string and, if and when they try to do LAN/Internet multiplayer the server could check the MOD version strings of all the clients to make sure they match.
Of course, getting the MOD support finished and actually getting FS2 to work right with MODs in multiplayer would come first. Someone would also have to code the changes in the net code so this may be a while off, but I think it's worth thinking about for the future. :)

"A man's reach should exceed his grasp."
Title: MOD support´, real mod support
Post by: DTP on October 23, 2002, 11:03:35 pm
Quote
Originally posted by DTP
look in demo build thread.

VP files are now supported when being in the mod directory.


correction, on my system, they are, not in CVS yet, still needs some tweaking :o
Title: MOD support´, real mod support
Post by: Bobboau on October 23, 2002, 11:07:34 pm
you know the more I look into it, the more I think, why can't we change the ship\weapon info indexes dynamicly to match those on a server and use the exsisting xfer cod eto transfere the needed files.
I have no idea how to do any multiplayer stuff though.
perhaps we should make a new thread discusing this
Title: MOD support´, real mod support
Post by: EdrickV on October 23, 2002, 11:25:13 pm
Would you really want to download TBP from within FS2? :) I'd rather download MODs using GetRight. Now if it was just a mission you needed, that would be different. D3 has an in-game mission downloader, but that is integrated with the level editor where you specify the location of a zip file to download which it will then uncompress. D3 levels with/without MODs aren't usually very big though. (Maybe up to 3/4 megs.)
Title: MOD support´, real mod support
Post by: Bobboau on October 23, 2002, 11:48:51 pm
most fs mods arn't too big, other than the TCs, think about it this way, if the host has altered tables then make those changes to all clients that join, if you need a new pof or pcx file see if the host has them and if so send them from the host to the client then have the client load them, this way people that want to play around in there new personal fighter in multiplayer can set up a server and people can join and play, maybe have a mod specifyer saying weather or not it is to be downloadable
Title: MOD support´, real mod support
Post by: EdrickV on October 24, 2002, 12:10:53 am
Stuff like that would require some major changes. For starters, the game loads the ship table when the program first starts. So if you made any changes to it you would have to reload it after the game has already started. There would also be potential problems if client player A has a MOD that includes a ship type (let's call it the SF Wasp) and if the server has another SF Wasp that is not the same. (And that kind of thing could happen, I have a model I called the Wasp which would have been SF Wasp in game and so does the 158th. Though mine isn't likely to get finished, and if it does I wouldn't call it the Wasp anymore but I don't know all the ships in all the MODs.) Not to mention that, as I understand the way this exe will work, you can't really start it setup for a particular MOD unless you actually have that MOD. Also, how would the program know which files need to be replaced and with what? What happens if you happen to have a newer version of a MOD then the server does and it tries to replace your "old" ships with it's "newest" ones.
Having a program like FS2 try and download files like that is something of a security risk because you may not know exactly what the files on the server are, whether they're made right, or whether they're made badly or even designed to crash FS2. (Weirder things have happened.) I'm not saying this isn't possible or shouldn't be done, I'm saying it would take a lot of work to do and the result might not be worth it.
Title: MOD support´, real mod support
Post by: Bobboau on October 24, 2002, 01:15:38 am
it wouldn't have to reload it, just swap the ship\weapon info index
if this gets integrated into this mod comand line thing then it could see if you have the mod directory if you don't then get the data you need from the server and any files you need (the ones in the servers mod folder), it might be good to have a mod table that would tell wich files are needed and what version
Title: MOD support´, real mod support
Post by: EdrickV on October 24, 2002, 01:44:20 am
In order for a ship to be usable it's type info has to be in the global ship info structure. In the case of a new ship, you would have to load the table data for the ship. That means, at worst, downloading a ships.tbl to replace the one in use and reloading the entire thing. At best it means downloading the table data specific to that ship and trying to merge it with the existing ships.tbl and then reloading the modified table. (Possibly exceeding the ships.tbl filesize/ship number limits.) And this would all have to be done before the mission is loaded.

I wouldn't want FS2 downloading who knows what from someone else's server. That's like inviting malicious hackers in. (I've actually heard of a MUSHCode virus designed to disrupt/crash MUSH online text based games.) D3's method is better IMHO because it tells you where the zip file is hosted (often multiple sites) and you can chose not to download a file if it's not on a site you would trust. (And when I think of MODs I think of the big ones with multiple new ships and a campaign to go along with them. Like the ones here that I always hear about. T-V War, Robotech MOD, TBP, etc. I don't think of little single ship things like I recently saw in the VW archives.)
Title: MOD support´, real mod support
Post by: Bobboau on October 24, 2002, 02:08:57 am
well you could just change the global info structure like I said, you wouldn't have to reload the table, as the thing is already in the proper structure in the server, you may need to reload models and textures, but you're going to have to do most of that anyway, this would also have the added effect of makeing cheating very hard (as in I have invulnerable super ship and you don't)
Title: MOD support´, real mod support
Post by: EdrickV on October 24, 2002, 02:15:59 am
You can go ahead and try to code if if you think it'll be so easy, but I don't think it is as easy as you think from what I've seen of the code that actually loads the table data in the first place. Just as long as you make it optional because I wouldn't use it.
Title: MOD support´, real mod support
Post by: Bobboau on October 24, 2002, 02:39:37 am
what you mean the stuff_int(&wip->something); stuff?
I don't know networking things but if you give me two weapon ifo structure arays I could swich them easily
Title: MOD support´, real mod support
Post by: EdrickV on October 24, 2002, 02:43:41 am
I meant the whole thing. Code ideas don't mean anything unless someone actually turns theory into practice, and so far we're the only ones talking about your idea.
Title: MOD support´, real mod support
Post by: DTP on November 08, 2002, 07:10:31 am
totally reworked mod support after a pleasant surprise

fs2_open, should, when i get it commited now have full florless modsupport.

but, having trouble with CVS, nothing new to me however,
figured it out in the past, and will figure it out again.