Page MenuHomeFeedback Tracker

ActionDismantlePart GetText bug
Assigned, UrgentPublic

Description

this is code of original ActionDismantlePart::GetText method

	override string GetText()
	{
		PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
		if ( player )
		{
			ConstructionActionData construction_action_data = player.GetConstructionActionData();
			ConstructionPart constrution_part = construction_action_data.GetTargetPart();
			
			if ( constrution_part )
			{
				return "#dismantle" + " " + constrution_part.GetName();
			}
		}
		
		return "";
	}

It's not correct to search GetGame().GetPlayer() on multiplayer games, so for multiplayers servers return is always empty.

It will be more correct to update m_Text inside OnActionInfoUpdate

this is how I did in my mod:

modded class ActionDismantlePart
{
	string m_TextFixed;
	
	void ActionDismantlePart() {
		m_TextFixed = "#dismantle";
	}
	
	override string GetText() { return m_TextFixed; }
	
	override void OnActionInfoUpdate( PlayerBase player, ActionTarget target, ItemBase item )
	{
		m_TextFixed = "#dismantle";
		Object target_object = target.GetObject();
		if ( target_object && target_object.CanUseConstruction() )
		{
			string part_name = target_object.GetActionComponentName( target.GetComponentIndex() );
			m_TextFixed = "#dismantle " + part_name;
		} else {
			ConstructionActionData construction_action_data = player.GetConstructionActionData();	
			m_TextFixed = "#dismantle " + construction_action_data.GetTargetPart();
		}
	}		
	
}

Details

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

Start server, add logs output, check dismantle action logs

Related Objects

Event Timeline

Geez changed the task status from New to Assigned.May 16 2022, 1:33 PM