glest-source icon indicating copy to clipboard operation
glest-source copied to clipboard

need error checking for morph skill:speed

Open andy5995 opened this issue 7 years ago • 2 comments

This happened in a scenario.

If a large number is used in the morph skill ( )

When the unit goes to morph, the status goes to 0 and never changes.

As you can see from this screenshot, the morph speed is altered (because the data type can't hold the number that large).

some error checking needs to be put in place to make sure values used are smaller than the storage space.

It's safe to assume that this bug affects all the variables used in the xml data files, not just the speed setting for the morph skill.

screenshot_2018-02-24_14-15-52

andy5995 avatar Feb 24 '18 20:02 andy5995

We'll use 99999 as the largest allowed number, so

if speed > 99999 or < 0

This will also need to be added to the code that validates scenarios from the command line (--validate-scenario=)

Relevant sections of code to look at.

https://github.com/ZetaGlest/zetaglest-source/blob/51e29e4c383c116152f6ffa84653f562a9af7293/source/glest_game/types/skill_type.cpp#L1111

https://github.com/ZetaGlest/zetaglest-source/blob/51e29e4c383c116152f6ffa84653f562a9af7293/source/shared_lib/sources/xml/xml_parser.cpp#L901-L904

I'm not sure yet where best to stick any kind of error-checking.

andy5995 avatar Feb 26 '18 19:02 andy5995

So far, I think in this function would be the best spot to do the error check

https://github.com/ZetaGlest/zetaglest-source/blob/51e29e4c383c116152f6ffa84653f562a9af7293/source/glest_game/types/skill_type.cpp#L1892-L1897

andy5995 avatar Feb 26 '18 19:02 andy5995