Home   Help Search Login Register  

Author Topic: How to use #include in a description.ext  (Read 6493 times)

0 Members and 1 Guest are viewing this topic.

Offline dr. seltsam

  • Members
  • *
How to use #include in a description.ext
« on: 22 Sep 2010, 19:46:38 »

Walter_E_Kurtz

  • Guest
Re: How to use #include in a description.ext
« Reply #1 on: 24 Sep 2010, 13:31:32 »
I think you can only use #include in files that are actually processed in some manner - this means config.cpp and resource.cpp. I take cpp to stand for C++ (C plus plus).

You would have to put ALL possible sounds / resources in the description.ext and modify your script to pick the correct one.

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: How to use #include in a description.ext
« Reply #2 on: 25 Sep 2010, 09:23:34 »
include in .ext works fine (at least a2+, yet ofp should be no different).

missionName.worldTag\subFolder\myFile.hpp

#include "subfolder\myFile.hpp"

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: How to use #include in a description.ext
« Reply #3 on: 25 Sep 2010, 16:09:03 »
My experience in ArmA 2 shows that(maybe the same for OFP) :


- You DO NOT need a semicolon at the end of the line
- the target .hpp file MUST be either in the MAIN directory or SUB-FOLDER of the mission.
For example :
Code: [Select]
#include "subFolder1\myFile.hpp" will work
but
Code: [Select]
#include "subFolder1\folder1\myFile.hpp" will CRASH the game

If you've already learnt those things,they may still be useful for others.
---------------------------------------------------------------------------------
And you better define the CfgSounds and others in the description.ext and just put the contents in a seperate file.

Example :


description.ext
Code: [Select]
class CfgSounds
{
#include "sound\mySounds.hpp"
};

mySounds.hpp
Code: [Select]
class sound1
{
sound1 properties here
};
class sound2
{
sound2 properties here
};

Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline faguss

  • Members
  • *
    • Faguss' Website
Re: How to use #include in a description.ext
« Reply #4 on: 25 Sep 2010, 23:59:17 »
Quote
What file extension do i need?
Extension does not matter. It's part of the name. If you'll paint black dude in white he may look white but still be black dude.

Quote
processed in some manner
What the hell does that mean? Resource and config are simple ANSI text files. Sorry, I missunderstood. Description is processed in the same way as config and resource. And cpp stands for C preprocessor.

Quote
My experience in ArmA 2
This is not ARMA2. In OFP it's different. Source directory is game root folder. So to include file from mission folder you would have go all the way up:

Code: [Select]
#include "Users\<your name>\missions\<your mission>\<file>
« Last Edit: 27 Apr 2011, 21:18:38 by faguss »

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: How to use #include in a description.ext
« Reply #5 on: 26 Sep 2010, 16:31:24 »
Oh I didn't realized that....
I was just telling what I found in ARMA 2 and I thought they may still be same.

if the mission has this code in its description.ext ,
#include "Users\missionCreator\missions\mission1\config1.hpp"
and its being packed (pbo'ed) and uploaded to online. then downloaded by player...

Will that code still work on the player's machine? because the path will not be the same!

Regards,
Haroon1992
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline faguss

  • Members
  • *
    • Faguss' Website
Re: How to use #include in a description.ext
« Reply #6 on: 26 Sep 2010, 19:18:13 »
It's not a problem assuming that mission ends up where it supposed to be: \Operation Flashpoint\Missions\.
Then the code would be:

Code: [Select]
#include "missions\__cur_sp.<island>\<file name>"
For multiplayer:

Code: [Select]
#include "mpmissions\__cur_mp.<island>\<file name>"

Offline dr. seltsam

  • Members
  • *
Re: How to use #include in a description.ext
« Reply #7 on: 26 Sep 2010, 22:29:34 »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: How to use #include in a description.ext
« Reply #8 on: 28 Sep 2010, 14:59:14 »
max,

All an include statement does is literally cut and paste the text from one file into another.

Anything paths and upper case letters inside the pbo mission will be properly converted by the linux ded server i.e. \ changed to / and upper case converted to lower case. I don't know anything about the include path, but if no one has used it before in other missions there may be a reason.

Try using an #include for a nonexistent file and see if it crashes OFP. If not then you can supply all three include possibilities. And pray like hell no one renames your mission pbo.

Quote
Can i have such a file included in the description.ext with other cfgSounds and rscTitles already existing in the description.ext?
This you can test. Make two separate cfgSounds in one description.ext and see if sounds get properly defined. I suspect they will not.
« Last Edit: 28 Sep 2010, 15:17:33 by Mr.Peanut »
urp!

Walter_E_Kurtz

  • Guest
Re: How to use #include in a description.ext
« Reply #9 on: 29 Sep 2010, 17:49:04 »
Dr. Seltsam,
   #include is a pre-processor command, so see if you can make sense of the BIKI on the subject.

All I can say is that I have only ever encountered such pre-processor commands with addons (and mods) in the config.

Going back to your original question, try creating an addon called Zombie.pbo, then your paths would be correct and you could see if the #include worked in the mission:
Quote
#include "Zombie\Zombie_Config.txt"

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: How to use #include in a description.ext
« Reply #10 on: 30 Sep 2010, 15:24:01 »
For an addon don't you have to start the path with the slash? i.e.
Code: [Select]
#include "\Zombie\Zombie_Config.txt"
urp!

Offline dr. seltsam

  • Members
  • *
Re: How to use #include in a description.ext
« Reply #11 on: 01 Oct 2010, 01:15:53 »
I tried several versions by now..
It works if i write the path beginning from the OFP main directory to the description.ext:

Code: [Select]
#include "Users\myName\missions\Demo_Zombie.Intro\Zombie\Zombie_Config.hpp"

But this is not a real option, it has to work with a relative path beginning from the mission folder. Can anybody provide a very simple made demo mission with an #include statement only to prove the concept? I would be able to copy this technique and build up my Config.hpp or Config.h ?? from it into my mission.
:)
« Last Edit: 01 Oct 2010, 02:27:33 by dr. seltsam »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: How to use #include in a description.ext
« Reply #12 on: 01 Oct 2010, 13:44:51 »
max,
it sounds like what you are trying to do (define resources) should be done in the addon itself, not the mission. is there a reason it has to be in the mission?
urp!

Walter_E_Kurtz

  • Guest
Re: How to use #include in a description.ext
« Reply #13 on: 01 Oct 2010, 22:27:27 »
My emphasis; quoting from here.
Quote from: Suma (Ondrej Spanel, BIS Lead Programmer)
We never used #include in description.ext and I am therefore unable to tell you how it should work. I would expect there will be problems with the paths where preprocessor looks for the included files. I assume the current directory during description.ext loading is not where description.ext is, but in the OFP folder (where exe is).

Perhaps someone with an understanding of C/C++ could manipulate the __FILE__ command into outputting the path to your mission. I couldn't get it to work.

Similarly, efforts at using ..\ for a relative path also failed.

Offline faguss

  • Members
  • *
    • Faguss' Website
Re: How to use #include in a description.ext
« Reply #14 on: 05 Oct 2010, 20:49:02 »
Quote
@Faguss:
When i test the mission in the editor the folder is:
When the mission is saved to multiplayer or (my guess is) saved on a dedicated server:
Take a look again on the code I've wrote. In the <brackets> put custom text. Sorry, I can't make it simpler.

Quote
Try using an #include for a nonexistent file and see if it crashes OFP
Of course it will crash as you're trying to work with something that does not exist.

Quote
pray like hell no one renames your mission pbo.
Doesn't matter as long as the island extension stays the same.

Quote
For an addon don't you have to start the path with the slash?
No. Why the idea? Never tested?

Quote
But this is not a real option, it has to work with a relative path beginning from the mission folder
There is no such method and there won't be. Get it over with.

Quote
manipulate the __FILE__ command
OFP does not support such macros. They are less of a command and more of a constant variable.

Quote
using ..\
Why would you want to leave the game folder?
« Last Edit: 27 Apr 2011, 21:21:45 by faguss »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: How to use #include in a description.ext
« Reply #15 on: 07 Oct 2010, 01:10:22 »
Quote
No. Why the idea? Never tested?
Why the idea? Because in addons I have looked at paths start with a backslash. You may have noticed also that my comment ended with a question mark. This was to indicate that it was a question.

My next statement will not end with a question mark because it is not a question. text deleted
« Last Edit: 25 Oct 2010, 18:46:07 by Mr.Peanut »
urp!

Offline faguss

  • Members
  • *
    • Faguss' Website
Re: How to use #include in a description.ext
« Reply #16 on: 07 Oct 2010, 09:31:43 »
Quote
Because in addons I have looked at paths start with a backslash.
Then I guess you were checking addons for the wrong game because in OFP if you'll start include path with backslash then the game will crash.

text deleted
« Last Edit: 27 Apr 2011, 21:24:36 by faguss »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: How to use #include in a description.ext
« Reply #17 on: 07 Oct 2010, 16:27:04 »
Not an addon for the wrong game, but extrapolating from the path required for everything else in addons, but now obviously excluding include statement paths.  Hence the question mark at the end of my original comment.
text deleted
« Last Edit: 25 Oct 2010, 18:46:27 by Mr.Peanut »
urp!

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: How to use #include in a description.ext
« Reply #18 on: 07 Oct 2010, 17:07:25 »
Okay gents, this thread has fallen below OFPEC's usual standard. Please drop the bickering tone, and stay on topic.

Offline dr. seltsam

  • Members
  • *
Re: How to use #include in a description.ext
« Reply #19 on: 07 Oct 2010, 19:10:09 »
Quote
is there a reason it has to be in the mission?
Code: [Select]
#include "Users\myName\missions\Demo_Zombie.Intro\Zombie\Zombie_Config.hpp"
... This works in the editor, and.. after i exported the mission to multiplayer (it was in the folder MPMissions then) it still worked !!! Very nice. My guess is that it will also work on a dedicated server then. So the preprocessing of the description.ext is done when i load a mission into the editor?

Well.. the drawback is.. i cannot have class cfgSounds or class rscTitles twice. I can have it in the Zombie_Config.hpp or

Walter_E_Kurtz

  • Guest
Re: How to use #include in a description.ext
« Reply #20 on: 07 Oct 2010, 22:44:41 »
I feel you still ought to double-check by either deleting or renaming the un-exported version.

Yes, pre-processing of description.ext is performed on loading the mission in the editor and only on loading - if you make any changes to description.ext you have to re-load to see them, you cannot just preview.

Offline haroon1992

  • Members
  • *
  • My life is hopeless...
Re: How to use #include in a description.ext
« Reply #21 on: 10 Oct 2010, 11:08:04 »
Quote
if you make any changes to description.ext you have to re-load to see them, you cannot just preview.

For me, I just "Save" the game to make the game reconize the changes in the description.ext.
And its a better and safer way, in case you've done something stupid in the description.ext and the game has crashed.


Regards,
Haroon1992
Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. :(

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: How to use #include in a description.ext
« Reply #22 on: 13 Dec 2010, 01:30:20 »
I am forever indebted to this thread and Faguss' answers. Helped me solve a broken addon cross-dependency on a linux ded server.  :good:
urp!