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
Scenario loader refactor & bugfix #117
Conversation
Verify ammo in what way? I think that you can probably find code examples for what you need in |
(In general, the scenarios for MM is something I've wanted to update for a long time, but never really got the time to do.) |
A couple of style comments - because I can't comment directly on
Curious - did you notice any performance improvement from replacing the vectors with array lists? |
Oh FFS, stupid tabs ... How did those end up in there again? Anyway, performance wasn't really my concern, given how tiny those files are. It's hard to say either way - on the one hand, the code is not doing any synchronised calls, on the other hand doing things the generic way tends to be slightly slower, on the other other hand, there's a lot of other things going on there like getting rid of implicit StringBuilder usage, using Pattern, using String.split() instead of StringTokenizer, so if that is ever a concern, only profiling would help. |
Ok, added a simple variant using the equipment names in Syntax (note to myself: Update the example file accordingly):
|
Looking at the code in |
Just checked MULParser, and it only cares if it's AmmoType in there. If it is, the parser is totally fine with the LB-X 10 ammo slot being loaded with SRM4 Inferno ammo. |
… weapon's ammo type as well, if there is one
Cool. Heh. Probably wouldn't hurt to have some sanity checking there... |
Added legality checks. Reporting to log, looks like follows:
It can even load the 4th scenario for the Sommerset Strikers, which the current version can't (because 2:3 isn't a valid slot on the Centurion CN9-D and it hits a NPE there). |
Wonder if the CN9-D thing happened after a unit file changed. Probably would be worth having a unit test that at least checks to see if the scenarios can be loaded, just so we can ensure that the scenarios MM ships with are going to work. |
Well, I guess I can quickly add a test class to the whole thing. |
Current output of the tester:
The "Scenario requires missing entity: false" errors are due to lines like The Northwind Highlanders scenario simply has a multi-line description ... (Now I need to see how I can make it into a "should not output anything" unit test ...) |
So, yeah. With the scenarios fixed and all loading, this should be about done. Unless somebody has some other important wishes? |
Well, if you're asking for wishes.... Oh, you mean related to this PR? Nah, seems good to me. |
There where some requests on the forum about the files; Is there a way to set an aerospace units initial altitude in a scenario file? In-particular I'd like to be able to set them as landed. C3 network when playing from a scenario Given a target Creating file. Just to mention a few |
Giving an altitude is easy (done). Setting up C3 network ... isn't. This stuff needs quite a bit of validation post-unit initialisation and has lots of options depending on which network layout people are trying to set up - and some way to clearly communicate errors. I've yet to check how MM handles objectives, so I'd rather leave that out for now. The scenario in that thread actually loads fine ... The Dixie Militia use a non-ASCII character in there (I think it's an em-dash), which might have something to do with it, but I think switching the parsing over to regular expressions killed whatever bug prevented it from loading. |
This fixes most of the remaining problems in SF bug 3189 (Various Scenario Issues), aside of the inability to set ammo type. I'd like to add this too, but it would be helpful if someone would offer a bit of guidance how to query and verify ammo. Something about
EquipmentType.get(ammoString)
, maybe, and then ... what?(Tagged "pending" until that's cleared up, implemented, and tested)