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

Check XML resource attributes #126

Merged
merged 29 commits into from
May 27, 2021
Merged

Conversation

AngheloAlf
Copy link
Contributor

@AngheloAlf AngheloAlf commented Apr 28, 2021

ZAPD will now perform more runtime checks for the attributes of each declared resource in the XMLs.

  • Checks if an invalid/unknown attribute was used in a resource.
    • Examples:
    Exception occurred: ZResource::ParseXML: Fatal error while parsing 'object_spot09_obj'.
       Unexpected 'Size' attribute in resource 'Collision'.
       Aborting...
    
    Exception occurred: ZResource::ParseXML: Fatal error while parsing 'object_sd'.
       Unexpected 'Nane' attribute in resource 'Limb'.
       Aborting...
    
  • Checks if a resource is missing a required/mandatory attribute.
    • Example:
    Exception occurred: ZResource::ParseXML: Fatal error while parsing 'object_gi_saw'.
           Missing required attribute 'Name' in resource 'DList'.
           Aborting...
    
  • General cleanup.
  • Change the internal way of ZArray to extract multiples elements. It doesn't need to create a new ZFile anymore.
  • To perform the checks, each ZResource needs to register the valid attributes for each one of them.
    • To do this, 2 new methods are provided.
      • RegisterRequiredAttribute(attr): Defines a mandatory attribute. ZAPD will throw an exception if a required attribute is missing. It's value will be stored in requiredAttributes.
      • RegisterOptionalAttribute(attr, defaultValue = ""). Defines an optional attribute. Each ZResource must check if the attribute is declared or not. It's value will be stored in optionalAttributes.
    • The valid attributes should be registered in the constructor of each ZResource
    • Every ZResource will register the required the following attributes automatically:
      • Name as required.
        • If it is an inner node (for example, subnode of ZArray), then 'Name' isn't required.
      • OutName and Offset as optional.
      • Custom as non-value.
  • Check if Width and Height attributes of ZTexture has only decimal digits, and throw an exception otherwise.

Related PR: #18

This PR will need a few changes in the OoT repo, since some objects are "invalid". I'll PR the needed changes soon PR 799.

Copy link
Contributor

@fig02 fig02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is good oot-side for this now.
This would be good to get in when possible so we can move forward with zeldaret/oot#811

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

Successfully merging this pull request may close these issues.

3 participants