Skip to content

Launch transportpods from non-player owned map cause caravans missing. #517

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

Open
Sakura-TA opened this issue Feb 28, 2025 · 2 comments
Open
Labels
1.5 Fixes or bugs relating to 1.5 (Not Anomaly). bug Something isn't working.

Comments

@Sakura-TA
Copy link

Should be multifaction problem.
I believe this is because the World Transportpod's Faction was set in FlyShipLeaving.LeaveMap, which happened when ticking the map, this makes all pods launched given Faction same with map owner. The game checks if any pawn in pods belongs to that Faction when arrived, and if no pawn of faction detected, the caravan got missing.
This affacts a lot. One player can't launch pods from other player's factionbase to anywhere except the ArrivalAction is TransportPodsArrivalAction_LandInSpecificCell.
Also some maps would be created for spectator in some mods...

Fix suggestions:
1.Save the pods’ ownership when TryLauch(or somewhere else)
2.Pre&post patch the FlyShipLeaving.LeaveMap to Push/Pop Faction temporarily to make Faction.OfPlayer works correctly here.

@Sakura-TA
Copy link
Author

Made a temporarily patch and works fine for myself.
Still looking for u guys ideas about better solution.

For me 1st choice is to register these events with Faction and let Maptick handle them
2nd is codes here
3rd transpiler to replace Faction.OfPlayer in FlyShipLeaving.LeaveMap with tmpTransportPodsOwnershipDict[this.groupID]

I'll left my codes here insdead of make a pull request as idk where to put the dict..

        static Dictionary<int, Faction> tmpTransportPodsOwnershipDict = new();
        [MpPrefix(typeof(CompLaunchable), nameof(CompLaunchable.TryLaunch))]
        static bool CompLaunchableTryLaunchPrefix(CompLaunchable __instance, int destinationTile, TransportPodsArrivalAction arrivalAction)
        {
            if (Multiplayer.Client == null)
                return true;

            tmpTransportPodsOwnershipDict[__instance.Transporter.groupID] = __instance.parent.Faction;
            return true;
        }
        [MpPrefix(typeof(FlyShipLeaving), nameof(FlyShipLeaving.LeaveMap))]
        static void FlyShipLeavingLeaveMapPrefix(FlyShipLeaving __instance)
        {
            if (Multiplayer.Client == null)
                return ;

            __instance.Map.PushFaction(tmpTransportPodsOwnershipDict[__instance.groupID]);
            return ;

        }
        [MpPostfix(typeof(FlyShipLeaving), nameof(FlyShipLeaving.LeaveMap))]
        static void FlyShipLeavingLeaveMapPostfix(FlyShipLeaving __instance)
        {
            if (Multiplayer.Client == null)
                return;

            __instance.Map.PopFaction();
            tmpTransportPodsOwnershipDict.Remove(__instance.groupID);
            return ;
        }

@notfood notfood added bug Something isn't working. 1.5 Fixes or bugs relating to 1.5 (Not Anomaly). labels Feb 28, 2025
@Sakura-TA
Copy link
Author

SRTS need same implementions here as SRTS COPIED the comp with a new name complaunchableSRTS extends thingcomp.

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). bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants