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

Unable to load missions that contain reference to third-party mods #218

Open
magwo opened this issue Apr 17, 2022 · 9 comments
Open

Unable to load missions that contain reference to third-party mods #218

magwo opened this issue Apr 17, 2022 · 9 comments

Comments

@magwo
Copy link
Contributor

magwo commented Apr 17, 2022

For example with a miz containing an A-4E-C:

  File "coalition.py", line 164, in load_from_dict
    _type=planes.plane_map[imp_unit["type"]],
KeyError: 'A-4E-C'

I suppose there needs to be plane-agnostic handling of unknown modules?

@DanAlbert
Copy link
Collaborator

Liberation handles this by injecting mods into plane_map.

@magwo
Copy link
Contributor Author

magwo commented Apr 17, 2022

Alright, thanks. Will take a look.

@magwo
Copy link
Contributor Author

magwo commented Apr 17, 2022

@DanAlbert Do you think it would be possible to make a generic loader? So mod slots at least can flow unmodified through a load-save operation?

@magwo
Copy link
Contributor Author

magwo commented Apr 17, 2022

I seem to have pretty decent success using this abomination:

                        if imp_unit["type"] not in planes.plane_map:
                            plane_type=type(imp_unit["type"], (PlaneType,), {})
                            plane_type.id=imp_unit["type"]
                        else:
                            plane_type = planes.plane_map[imp_unit["type"]]
                        # plane_type = 
                        plane = Plane(
                            mission.terrain,
                            _id=imp_unit["unitId"],
                            name=self.get_name(mission, imp_unit["name"]),
                            _type=plane_type,
                            _country=_country)
                        plane.load_from_dict(imp_unit)

@DanAlbert
Copy link
Collaborator

IDR the interface off the top of my head, but if the Mission contains any references to the actual type and not just the ID it'd be hard to do. If we could generate the full type on the fly we wouldn't need all the data. The type hierarchy would need to change to differentiate between an ID-only aircraft and a full-day aircraft.

If the only value in Mission is the ID name it sounds doable, but we'd need to make it clear that IDs in Mission may not be available in the type maps (perhaps by making some APIs return an Optional).

@magwo
Copy link
Contributor Author

magwo commented Apr 17, 2022

There was an attempt: #219

@magwo
Copy link
Contributor Author

magwo commented Apr 17, 2022

Perhaps introduce an UnknownPlane / UnknownHelicopter type that the on-the-fly type can inherit?

@magwo
Copy link
Contributor Author

magwo commented Dec 28, 2022

This has become more relevant to me and the community I'm active in due to the release of the Swedish SAAB Sk60 trainer mod. But I've forgotten pretty much everything I did regarding this issue :D

@magwo
Copy link
Contributor Author

magwo commented Dec 28, 2022

We use a setup on our training server were we run DCS Mission Buzzer every morning to generate a new mission with randomized (but realistic) weather and lots of other things.
This is based on a pydcs load/save operation where the buzzer loads a training mission template (containing LOTS of manually crafted training stuff), and saves it with randomized weather and relocated carriers etc.

And I think we will soon want to use the Sk60 mod in this mission template, which requires pydcs to support third-party mods - preferrably transparently so it doesn't just break every time the mod version changes or a new mod is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants