← Home SEEBIE90 DOCS
Download PDF
The SOFLAM Integration Core mod is published under the Arma Public License (APL)Example code is free to useSuggestions: Discord to the author

For other modders

Bridges to other mods

The Core knows nothing about drones or about RVX aircraft, and they know nothing about the Core. The link between them is a bridge: a small mod that depends on both. This page says why it has to be a mod of its own, shows the two that exist, and describes the one trap that is easy to fall into when you mirror the registry.

In plain wordsWhy a link between two mods is a mod of its own, the two bridges that exist, and the trap in mirroring the target registry into another system: expired targets leave without a call.

Why a bridge is a mod of its own

EnforceScript resolves every class at compile time. If your mod calls a class from another mod and that mod is not there, the script module does not compile, and a compile error in any loaded mod takes down the whole module – nothing loads, for anyone. A runtime check does not help, because the line has to compile anyway. There is no preprocessor symbol to ask either, unless the other mod defines one.

What is left is the one tool Enfusion offers for “code that exists only with mod X”: a mod of its own with a dependency on X. Whether it is subscribed is the switch. Whoever uses both subscribes the bridge as well; everybody else notices nothing.

The two bridges

BridgeConnects the Core withWhat it does
UAV SOFLAM (Workshop)The UAV mod (MQ-1C)Laser on call: the drone finds the laser spots of the Core by laser code and attacks. The version that goes with Core 3.1.0 also brings the drone as a picture source to the tablet: camera, control, settings, return to home.
SOFLAM Integration X RVX Core (Workshop)RVX_Core by RiverX_96Passes the laser targets of the Core to RVX_Core, so that RVX laser seekers home in on them. One way: the SOFLAM feeds RVX weapons.

Both are small. The RVX bridge is a single file with one modded class.

The pattern: a modded class on the registry

All laser targets of the Core pass through GTG_SOFLAM_LaserTargetManager, on every machine (the registry). That is the narrow point. A bridge derives from it with modded class and passes on what comes in:

Example code – free to useGTG_SOFLAM_RVX_TargetBridge.c (excerpt, names shortened)
modded class GTG_SOFLAM_LaserTargetManager
{
	// what THIS bridge reported to the other side; key = RplId of the creator
	protected ref map<RplId, bool> m_mReported = new map<RplId, bool>();

	override void CreateTarget(RplId creatorId, string code)
	{
		super.CreateTarget(creatorId, code);

		if (!creatorId.IsValid())
			return;

		RVX_LaserTargetManager.getInstance().CreateLaserTarget(creatorId, code);
		m_mReported.Set(creatorId, true);
	}

	override void UpdateTarget(RplId creatorId, vector position, string code)
	{
		super.UpdateTarget(creatorId, position, code);

		if (!creatorId.IsValid())
			return;

		RVX_LaserTargetManager rvx = RVX_LaserTargetManager.getInstance();
		if (!rvx.laserTargetMap.Contains(creatorId))		// RVX writes an update only when the key exists
			rvx.CreateLaserTarget(creatorId, code);

		rvx.UpdateLaserTarget(creatorId, position, code);
		m_mReported.Set(creatorId, true);
	}

	override void RemoveTarget(RplId creatorId)
	{
		super.RemoveTarget(creatorId);

		if (!m_mReported.Contains(creatorId))
			return;

		RVX_LaserTargetManager.getInstance().RemoveLaserTarget(creatorId);
		m_mReported.Remove(creatorId);
	}
}

Note the second hook: the other side’s UpdateLaserTarget does nothing when the key is not there yet, and says nothing about it. A late joiner may see updates before the create. Create it yourself when it is missing.

The trap: targets leave without a call

If the bridge only caught the three methods above, it would leave dead targets on the other side. The registry throws a target out without calling RemoveTarget in two places: the expiry that runs once a second and removes every target that has not reported for five seconds (the last safety if the removal over the network fails), and ClearTargets(). A missile on the other side would keep flying to a laser that is long gone.

So the bridge remembers what it has reported, and clears away exactly that when the registry no longer has it. After every run of the base class:

Example code – free to useGTG_SOFLAM_RVX_TargetBridge.c (excerpt, names shortened)
override event protected void OnUpdatePoint(WorldUpdatePointArgs args)
{
	super.OnUpdatePoint(args);		// the base class runs its expiry

	if (m_mReported.IsEmpty())
		return;

	// collect first, remove afterwards: removing while counting shifts the entries
	array<RplId> gone = {};
	for (int i = 0, count = m_mReported.Count(); i < count; i++)
	{
		RplId creatorId = m_mReported.GetKey(i);
		if (!GetTarget(creatorId))		// the registry has dropped it on its own
			gone.Insert(creatorId);
	}

	RVX_LaserTargetManager rvx = RVX_LaserTargetManager.getInstance();
	foreach (RplId id : gone)
	{
		rvx.RemoveLaserTarget(id);
		m_mReported.Remove(id);
	}
}

override void ClearTargets()
{
	super.ClearTargets();

	RVX_LaserTargetManager rvx = RVX_LaserTargetManager.getInstance();
	for (int i = 0, count = m_mReported.Count(); i < count; i++)
		rvx.RemoveLaserTarget(m_mReported.GetKey(i));

	m_mReported.Clear();
}
Not everything in that map is yoursOnly clear your own entries. The other side keeps its own designators in the same map, and they must never be touched. That is why the bridge keeps a map of what it reported instead of simply emptying the other side.

One way, on purpose

The RVX bridge only writes: the SOFLAM feeds RVX weapons. The other direction, RVX designators for the Core’s weapons, would be a second hook on GetClosestTargetByCode, and it is not included. As long as writing goes one way, no target can come back and show up twice.

Writing your own bridge

  1. A mod of its own with exactly two dependencies besides the base game: the Core and the other mod (step 1).
  2. Hook the three methods, and handle the expiry and ClearTargets() as shown above.
  3. Only touch what you reported. Keep a map of your own entries.
  4. Write one way unless you really need both, and then break the loop before it starts.
  5. Compile against the published copies of both mods before you publish, and test on a dedicated server with a separate client (checklist).
Example code on this page is free to use in your own projects (credit appreciated). The SOFLAM Integration Core mod is published under the Arma Public License (APL). Suggestions: Discord. Arma Reforger / Enfusion are trademarks of Bohemia Interactive.
Impressum · Privacy Policy