Feature #2891

New tool to build the units and weapons array of cfgPatches for a config.

Added by kju almost 6 years ago. Updated almost 6 years ago.

Status:Closed Start date:07/18/2009
Priority:Normal Due date:
Assignee:mikero % Done:

0%

Category:FixAddon (Dos Tools)
Target version:Completed
Affected Version:

Description

Pretext:
The cfgPatches essentially says which units/weapons are defined inside.

Both definitions are required for the mission editor to correctly define
the addons array - the definition of dependencies to addons.

Goal:
Most people dont understand that and its a time wasting job.
So the goal is to automatize this task.

Implementation suggestion:

  • Input: A config.cpp or config.bin
  • Output: A new updated config.cpp, renamed old file to config.cpp.txt/config.bin.txt
  • Workflow:
    • Parse the config and build a complete tree for class cfgVehicles and class cfgWeapons.
    • Build an array/list of all first level 'class item1:' inside both definitions.
      • Note that there may be whitespaces (spaces/tabs) before the colon.
      • First level item's means not 'class item1_1:' inside a 'class item1:'.
      • Do NOT add base class definitions like 'class baseClass;' (semicolon).
      • Empty class definitions are valid and are to be added to the array/list: 'class item1: baseClass {};'.
      • Before remove the 'class', all whitespaces and the colon!
    • Compare the array/list vs a given file, if available. The file is named definedClasses.txt.
      • It contains by default all classes defined the game itself.
      • It is meant to remove BI classes from the array/list.
      • It is meant to be an external for the user modifiable file in case exceptions need to be made or new entries added in addition.
    • Current status are the two lists for vehicle and weapon classes (possible that either one is empty).
    • Add new cfgPatches item with this given header:
 1 class CfgPatches
 2 {
 3     class dummyClassNeedsRenaming
 4     {
 5         units[] = {listOfNewCfgVehicleClasses}; // list to be added by the tool
 6         weapons[] = {listOfNewCfgWeaponClasses}; // list to be added by the tool
 7         requiredVersion = 1.0;
 8         requiredAddons[] = {"CAWeapons2_RPG18","CATracked","CAWeapons_bizon","CAWheeled2_BTR90","CATracked2_BMP3","CA_Modules_ARTY","CAAir","CA_AIR2_Su25","CATracked2_2S6M_Tunguska","CAAir2_F35B","CAweapons_m107","CAWheeled2_V3S","CABuildings","CAWeapons_VSS_vintorez","CAAir2_MQ9PredatorB","CAWeapons_SPG9","CAWeapons_Kord","CAAir2_C130J","CAWheeled2_M1114_Armored","Warfare2","CAAir3_Su34","CAWeapons_2b14_82mm_Mortar","CAWheeled3_TT650","CAWheeled2_MTVR","CAWeapons2","CATracked2_us_m270mlrs","CASounds","CAUI","CATracked2_T90","CAWater2_smallboat_1","Arma2_Ka52","CAWheeled2_TowingTractor","CAWheeled2_GAZ39371","CA_Modules_Alice","CACharacters","CAAir2","CAAir2_Pchela1T","CAAir2_MV22","CAWheeled2_MMT","CAWater","CAWheeled","CAWheeled_Offroad","CAWheeled2_Kamaz","CAAir2_UH1Y","CAWeapons","CAWeapons_M252_81mm_Mortar","CAWeapons_M1014","HALO_Test","CAWheeled2_LAV25","CA_CruiseMissile","CAWeapons_AK","CAWheeled2_VWGolf","CAWeapons_Warfare_weapons","CATracked2_AAV","CAWeapons2_SMAW","CAData","CAA10","CAweapons_ksvk","CAAnimals","CAWater2_fishing_boat","CACharacters2","CAWeapons_Colt1911","CAWheeled3_M1030","CATracked2_T34","CAWeapons_Saiga12K","CAWater2_seafox","CAWeapons_DMR","CAWheeled2_Ikarus","CAWeapons2_HuntingRifle","CAWheeled_Pickup","CAWheeled2_LADA"};
 9     version = "DATETAG"; // is to be added by the tool; format: YYYY-MM-DD; in quotes.
10     };
11     ...
12     //already existing definitions
13 };
  • Note this given requiredAddons definition ensures loading the addon AFTER BI's core addons.
  • Note that the array/list needs to be transformed to be a comma separate list with each item enclosed by quotes:
1 units[] = {"unitA","unitB"};
2 weapons[] = {"weaponA","weaponB","weaponC"};
  • Write config.cpp.

PS: format of the definedClasses.txt

1 All
2 AllVehicles
3 Man
4 ...
5 M1A1
6 ...
7 Land_House17
8 ...

config.cpp (7.6 kB) kju, 08/10/2009 06:37

ofp_editor_config.cpp (23.5 kB) kju, 08/10/2009 07:35

ofp_editor_fixAddon.txt (11.1 kB) kju, 08/10/2009 07:35

oac_core_CfgPatchesUnitsClasses.hpp (17.2 kB) kju, 08/10/2009 07:35

oac_core_fixAddon.txt (1.9 kB) kju, 08/10/2009 07:35

oac_core.zip (6.3 MB) kju, 08/10/2009 07:35

History

Updated by mikero almost 6 years ago

  • Status changed from New to Assigned
  • translation missing: en.field_private changed from 1 to 0

FixAddon has been uploaded for testing

Updated by kju almost 6 years ago

Started testing here. Some thoughts:

original file

1 class CfgPatches 2 { 3 class CAA10 4 { 5 units[] = {"A10"}; 6 weapons[] = {}; 7 requiredVersion = 0.1; 8 requiredAddons[] = {"CAAir","CACharacters2","CAWeapons"}; 9 }; 10 };

fixaddon generated text:

1 class CfgPatches 2 3 { 4 5 class CAA10 6 7 { 8 9 units[]={A10}; 10 11 weapons[]={}; 12 13 requiredVersion = 0.1; 14 15 requiredAddons[]={CAAir,CACharacters2,CAWeapons}; 16 17 }; 18 19 }; 20 Suggested changes:
  • Remove empty line after each element.
  • Put array elements in quotes.
  • Please offer an option to have leading tabs instead of spaces.

Doing more tests now.

Updated by kju almost 6 years ago

Does not find the classes for this config for some reason:

1 T:\pbodll>FixAddon.exe P:\x\Mi28_RUS_CMA\addons\Mi28_RUS_C_CMA\config.cpp 2 FixAddon.exe Version 1.50, Dll Version 2.31 3 class CfgPatches 4 { 5 class Mi28_RUS_C_CMA 6 { 7 units[]={}; 8 weapons[]={}; 9 requiredVersion = 1.02; 10 requiredAddons[]={CAAir2,Mi28_RUS_T_CMA,Mi28_RUS_P_CMA,Mi28_RUS_A_CMA}; 11 }; 12 }; 13 no errors

Updated by kju almost 6 years ago

Some more input.

Check the ofp_editor definition vs the created one.
Also oac_core for comparison attached.

Not saying the source file definitions are fully correct.
Both are not.

There is definiately the need to be able to define BI standard classes
that should never be put into the definition.
At times you are not using the direct external reference like

1 class Car;

Instead at times you have

1 class Car: AllVehicles 2 { 3 class ViewPilot; 4 };

Currently I think car is to be added by fixAddon?
Anyway there should be an exclude list as external text file to stop
certain classes to be put into the units array.

Updated by mikero almost 6 years ago

kju wrote:

Suggested changes:
  • Remove empty line after each element.
  • Put array elements in quotes.
  • Please offer an option to have leading tabs instead of spaces.

this is caused at your end by responding to both a cr AND a linefeed. Dos normally expects both, you, have set it no linux (I assume)

quotes are noisy and only necessary when space chars are in-the-words. Quotes are indeed produced under those (rare) circumstance

tabs will be implemented as an option.

Updated by mikero almost 6 years ago

units[]= eg is only populated by this exe if the class can be detected as public (scope=2)

Mi28_RUS_CMA config.cpp has no public weapons or units based on complete lack of scope definitions (scope=anything)

the only potential reference to this being public is the fact that it inherits from

Mi24_Base, which i assume? is from CAAir2 and is highly unlikely to be public

the exe cannot rely on extern definitions being public models, in fact, they are almost always not.

all in all, this pbo is faulty in that the model cannot be selected in the mission editor

all things considered. the output as it stands, is a good thing (tm). It is alerting you to something fundamentally wrong in the cpp

Updated by mikero almost 6 years ago

There is definiately the need to be able to define BI standard classes to never be inluded

As it stands right now, they can NEVER be inserted in the definition because there is no class body for any of them, unless (and rarely) a specific rebuild over-ride of

class caBlob:caBlob{...}

At times you are not using the direct external reference like

1 class Car;

I never insert extern references. Period

Instead at times you have

1 class Car: AllVehicles 2 > { 3 > class ViewPilot; 4 > };

Currently I think car is to be added by fixAddon?

NO, absolutely not. it has no indication of being public

Anyway there should be an exclude list as external text file to stop
certain classes to be put into the units array.

such as above Car eg, which defeats the purpose of this 'time saving' exe, involving an equally difficult chore (and somewhat ironic) need to list all the classes you DONT want in the units[]=. That being the case, you might as well just edit units[]= by hand.

Updated by kju almost 6 years ago

  • Remove empty line after each element.

this is caused at your end by responding to both a cr AND a linefeed. Dos normally expects both, you, have set it no linux (I assume)

Sorry I don't understand this one mikero. My editor tells me its set to windows format. Means CRLF.


quotes are noisy and only necessary when space chars are in-the-words.

They are useful for better readability as good text editor doing code coloring.


1 class Mi24_Base_RU: Mi24_Base 2 { 3 class Turrets; 4 }; 5 class Mi24_P: Mi24_Base_RU 6 { 7 class Turrets: Turrets 8 { 9 class MainTurret; 10 }; 11 class MFD 12 { 13 class HUD: AirplaneHUD 14 { 15 class Pos10Vector; 16 }; 17 }; 18 }; 19 class CMA_Mi28_RUS: Mi24_P
Mi28_RUS_CMA config.cpp has no public weapons or units based on complete lack of scope definitions (scope=anything)
the only potential reference to this being public is the fact that it inherits from
Mi24_Base, which i assume? is from CAAir2 and is highly unlikely to be public

If you look closely, it is based on Mi24_P - an actual unit class.
You are right that guessing makes no sense. This is what I suggested
to read in an external text file that contains the BI config base:

  • To filter BI classes out of any unit[] definition.
  • To check scope setting.

if the class can be detected as public (scope=2)

Again scope=1 also needs to be part as per the Skype discussion.
If the mission has no MyAddonClass definition in addons array,
while the mission actually uses it, it will be faulty.

There are addons to change scope to either make more classes available
in the editor or to hide them.
Also mission.sqm modification or scripted creation may cause scope=1
classes being used. While scripted creation, is not be found. SQM
modification is.

So again please explain me why scope=1 is not meant to be in units array.
To me it makes no sense and is a problem if not done.


    At times you are not using the direct external reference like
    class Car;

I never insert extern references. Period

:)

You, from what I know, means in English also, every person.
So it is NOT about you and your tools. It is about people have to
write configs.

Updated by mikero almost 6 years ago

huge grin

we're having an argument here about pineapples. where, in fact, you are talking about chickens, and I am discussing apartment buildings.

clearly, you know a lot more about this subject, the actual use of units[]= than i do.

so. two temporary options

-p include protected models in the array
-z assume externs are protected or public (and insert their children as appropriate)

missed translation

"I never insert externs"

i meant that extern classes could not possibly be part of units[]= since they dont declare things inside THIS pbo

A definition file:

i am hostile to this need. I want to avoid that if at all possible. I accept, it may not be possible, but i need to explore ANY other avenue.

that list will be

as long as a piece of string
changed on any revision to the engine(s)
would also have to include any 'community' addon that is needed in this pbo (externs can and do reference non bis officials)

I fully realise all the above is not 100% what you want/need but gets closer

Updated by mikero almost 6 years ago

kju wrote:

If you look closely, it is based on Mi24_P - an actual unit class.

which, in turn has no scope definition and etc, the bottom line is that they are all, ultimately inherited from an unknown scope external

Updated by kju almost 6 years ago

+now declares protected units
+lists protected vs public

Hm is this this?

-p include protected models in the array
-z assume externs are protected or public (and insert their children as appropriate)

Cannot get those two commands to work.

Updated by mikero almost 6 years ago

options z and y added to assume public / protected inheritence respectively from an extern

however, not at all happy with this approach.

an dbase is required, and, it should also manipulate requiredAddons[]= as a result

Updated by kju almost 6 years ago

  • Category set to FixAddon (Dos Tools)
  • Status changed from Assigned to Closed
  • Target version set to Completed

Thanks a lot!

Also available in: Atom PDF