Open AaronGullickson opened 6 months ago
BotForces may not have game
s, but do we have access to the Bot's client
instance in this context? If so, I believe we can get the game instance from that.
Edit: or is this entirely external to MM, so no Bot either? In that case, yeah, either pass in the game options or encapsulate them in a settings datatype would be my vote.
Entirely external to MM. Its the BotForce assigned to a Scenario. It doesn't get a proper Bot until the game is started in GameThread.
Issue MegaMek/mekhq#3978 occurred because EntityListFile was calling
entity.getGame()
several places but BotForces don't have games. if we want to consolidate the entity XML reading/writing across MM and MHQ (which I think we do) then EntityListFile needs to be more robust in dealing with these kind of issues. I made a short term solution of adding additional checks for game being null but I don't love this solution for the long term.Most of the usages of
entity.getGame()
are to check game options. One relatively easy solution would be to feed in game options to the write methods. MekHQ has game options even if BotForces do not have games. However, I did notice two other places that we depend on game. The first is writing out C3Master information and the second is writing out Force information, so we would need other ways of handling that.The longer-longer term solution would be a (much) bigger rewrite to leave game out of entity. Its kind of weird really. It worked fine when it was just MM and we could always assume that if you had an entity you had a game. But that assumption has long since been broken.