Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompTargetable.OrderForceTarget causes desync. #519

Open
Sakura-TA opened this issue Feb 28, 2025 · 2 comments
Open

CompTargetable.OrderForceTarget causes desync. #519

Sakura-TA opened this issue Feb 28, 2025 · 2 comments
Labels
1.5 Fixes or bugs relating to 1.5 (Not Anomaly). desync Bug that specifically causes a desynced state.

Comments

@Sakura-TA
Copy link

Sakura-TA commented Feb 28, 2025

This occurs when trying to use item with CompTargetable. The comp cached Pawn caster when select use option and uses it in OrderForceTarget, which synced by MP.
e.g. 'amplifier' from Mod 'Infused'.
It seems Rimworld nolonger use this comp though.

Register SyncWorker for CompTargetable to sync caster can fix this, but I've got no idea where to put the codes, since MP project seems not as active as MPcompat, so I made a issue here. xd

Related RW codes

public override bool SelectedUseOption(Pawn p)
		{
			if (this.PlayerChoosesTarget)
			{
				this.caster = p;     //caster setted here
				Find.Targeter.BeginTargeting(this, null, true, null, null, true);
				return true;
			}
			this.selectedTarget = null;
			return false;
		}
		public void OrderForceTarget(LocalTargetInfo target)
		{
			this.selectedTarget = target.Thing;
			CompUsable compUsable;
			if (this.parent.TryGetComp(out compUsable))
			{
				compUsable.TryStartUseJob(this.caster, target, compUsable.Props.ignoreOtherReservations);
			}
			this.caster = null;
		}
@SokyranTheDragon SokyranTheDragon transferred this issue from rwmt/Multiplayer-Compatibility Feb 28, 2025
@SokyranTheDragon
Copy link
Member

This is causing desyncs with (Ghoul) Resurrector Mech Serums. A sync worker may fix the issue. Probably. We'd need to check how the fields are handled to make sure there's no issues where we replace a correct field value with an incorrect one.

@SokyranTheDragon SokyranTheDragon added desync Bug that specifically causes a desynced state. 1.5 Fixes or bugs relating to 1.5 (Not Anomaly). labels Feb 28, 2025
@Sakura-TA
Copy link
Author

Sakura-TA commented Mar 1, 2025

afaik, this caster field was only for CompTargeter.OrderForceTarget to figure out which pawn calls SelectedUseOption. If caster is synced around OrderForceTarget, would cause issues when 1 player done selection given the jobs and the other player called SelectedUseOption on same thing but on ticks behind, at this point the other player would got his caster replaced. sync SelectedUseOption here would fix this and no more sync worker needed. :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.5 Fixes or bugs relating to 1.5 (Not Anomaly). desync Bug that specifically causes a desynced state.
Projects
None yet
Development

No branches or pull requests

2 participants