Jump to content

Photo
- - - - -

OFP Preprocessor Explained


  • Please log in to reply
10 replies to this topic
Thread Starter
faguss
faguss

    Staff Sergeant

  • Members
  • 242 posts

Posted 03 May 2011 - 20:18 #1

Sanctuary asked me to start a topic about so here it is.

OFP Preprocessor Explained (last update 21th September 2011).

This is for Flashpoint, not for ARMA!

Edited by Faguss, 21 September 2011 - 14:00.


f00bar
f00bar

    Corporal

  • Members
  • 98 posts

Posted 04 May 2011 - 12:24 #2

Thanks Faguss. Are there any detailed examples
that could be included with a description of the
benefits gained by using the PreProcessor?

The Bohemia Interactive Community Wiki
also has some OFP specific PreProcessor
reference documentation:

preprocessFile:
http://community.bis.../preprocessFile

PreProcessor Commands:
http://community.bis...cessor_Commands

PreProcessor Errors:
http://community.bis...rocessor_Errors

sanctuary
sanctuary

    First Lieutenant

  • Members
  • 5163 posts

Posted 04 May 2011 - 12:40 #3

A practical example of one of the commands explained in Faguss excellent PDF at "10. #ifdef, #endif – conditional inclusion" is what i used for the GRAA mod option system.

By example, in the config.cpp of the mode , there's a line
#define ENABLE_3RDPALT
if you have this option enabled
or
//#define ENABLE_3RDPALT
if you have it disabled.

Now in the config look for :

class Man:Land

In this class , the 3rd person camera position is defined, and it will be used by every classes that inherit from the class Man:Land (meaning every soldiers as none of them redefine that camera, they still use the one defined in class Man:Land )

The interesting lines are there :
#ifndef ENABLE_3RDPALT
		extCameraPosition[]={0,0.3,-3.5};
#endif

and
#ifdef ENABLE_3RDPALT
		extCameraPosition[]={0.25,-0.1,-1.4};
#endif

The 1st part mean that if in the start of the config, the option is disabled :
//#define ENABLE_3RDPALT
( // mean that the game will not read what follows it, so ENABLE_3RDPALT will never be defined)
extCameraPosition[]={0,0.3,-3.5};
that's the original OFP camera

Now if in the start of the option the ENABLE_3RDPALT is defined (there's no // in front of it) , OFP will then consider the 2nd part the one to use, and so
extCameraPosition[]={0.25,-0.1,-1.4};

.kju -PvPscene-
.kju -PvPscene-

    Brigadier General

  • Members
  • 12275 posts

Posted 04 May 2011 - 13:02 #4

Thanks for sharing and well done Faguss!

Would be best to see this integrated into the BIKI.



Current active projects: None :(

Maintained/assisted projects: IFA3, Blitzkrieg


Help: Got a crash? Report it! What is the RPT log file?


Thread Starter
faguss
faguss

    Staff Sergeant

  • Members
  • 242 posts

Posted 04 May 2011 - 14:29 #5

Thanks Faguss. Are there any detailed examples
that could be included with a description of the
benefits gained by using the PreProcessor?


I won't add any to doc. I encourage readers to paste their own examples here in this topic.

The Bohemia Interactive Community Wiki
also has some OFP specific PreProcessor
reference documentation:


You mean the Arma2 wiki? Not much there comparing to GNU CPP documentation. Only thing I've learned was the include absolute path.

f00bar
f00bar

    Corporal

  • Members
  • 98 posts

Posted 04 May 2011 - 16:34 #6

Thanks for the example Sanctuary.

The BI Wiki refers to the preprocessFile entry
as being introduced in OFP 1.85.

At the bottom of the page, the "See Also" links
point to the PreProcessor Commands entry
which does not explicitly list a program version
but it is listed under:

Categories: Operation Flashpoint: Editing |
ArmA: Addon Configuration | Scripting Topics


---------- Post added at 12:34 PM ---------- Previous post was at 11:52 AM ----------

I also found the discussion in this old (2006) thread useful
in understanding preprocessing in OFP:

Discussion on editing CPP's and getting your work
from o2 to ofp


http://forums.bistud...ead.php?t=47147

sanctuary
sanctuary

    First Lieutenant

  • Members
  • 5163 posts

Posted 04 May 2011 - 22:46 #7

It's not shunning, it's simply that at the time i had a need of those #ifdef #ifndef i had no idea " #else " ever existed for this kind of thing.

Thread Starter
faguss
faguss

    Staff Sergeant

  • Members
  • 242 posts

Posted 05 May 2011 - 14:01 #8

I also found the discussion in this old (2006) thread useful in understanding preprocessing in OFP


Well, before I released the doc I searched on various forums. There's nothing that I haven't knew already.

It's nice of you foobar that you want to help but searching in BI / OFP related sources is (mostly) a waste of time. That's because users are speculating without doing research.

Edited by Faguss, 07 May 2011 - 15:31.


zvukoper
zvukoper

    Staff Sergeant

  • Members
  • 227 posts

Posted 09 May 2011 - 08:05 #9

Faguss, thank you so much for this doc! You've opened my eyes to arma advanced addonmaking. It was all complete mystery to me before reading. Now "I see" :)

Thread Starter
faguss
faguss

    Staff Sergeant

  • Members
  • 242 posts

Posted 24 May 2011 - 20:20 #10

I have updated the document. Check top. Corrected grammar, corrected code examples, added extra info.

Thread Starter
faguss
faguss

    Staff Sergeant

  • Members
  • 242 posts

Posted 21 September 2011 - 14:03 #11

I have updated doc again - small corrections.

Some time ago I had a discussion with Mikero about preprocessor. In ARMAs it's much different from OFP (less friendly). If you're into ARMA editing don't read this file or you'll learn bad habits.