Page MenuHomeFeedback Tracker

foreach not pinning references?
Assigned, UrgentPublic

Description

This crashes as GetEntityDamageZoneMap() saying the result is NULL (when it is not).

		foreach (string zone, array<string> zoneNames: m_Vehicle.GetEntityDamageZoneMap()) {
			foreach (string zoneName: zoneNames) {
				Print(zoneName);
			}
		}

This works as it appears to have soft pinned the return?

		auto allZones = m_Vehicle.GetEntityDamageZoneMap();
		foreach (string zone, array<string> zoneNames: allZones) {
			foreach (string zoneName: zoneNames) {
				Print(zoneName);
			}
		}

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 7
Category
General
Steps To Reproduce

Attempt the following on a carscript

		foreach (string zone, array<string> zoneNames: m_Vehicle.GetEntityDamageZoneMap()) {
			foreach (string zoneName: zoneNames) {
				Print(zoneName);
			}
		}

Event Timeline

antihax created this task.Sep 23 2023, 5:42 AM

This may be related or duplicate of https://feedback.bistudio.com/T173049

Geez changed the task status from New to Assigned.Sep 25 2023, 4:13 PM

To clarify this issue, it seems to be an issue with data returned via methods.

This doesn't work:

		if (GetIdentity())
		{
			foreach (WorthyPermissionGroup group : CfgWorthinessHandler.GetGroups())
			{
				if (group.SteamIDs.Find(GetIdentity().GetPlainId()) > -1)
					m_WorthyGroups.Insert(group.groupName);
			}
		}

Whereas this does:

		if (GetIdentity())
		{
			foreach (WorthyPermissionGroup group : CfgWorthinessHandler.m_Data.permissionGroups)
			{
				if (group.SteamIDs.Find(GetIdentity().GetPlainId()) > -1)
					m_WorthyGroups.Insert(group.groupName);
			}
		}

Where GetGroups is defined as follows:

	static set<ref WorthyPermissionGroup> GetGroups()
	{
		return m_Data.permissionGroups;
	}