Skip to content

Convert calls to XmlAttributes::fetch() to templated variant #16

@Quintus

Description

@Quintus

Before today XmlAttributes::fetch() wasn’t templated, but only worked with strings, requiring an absolutely unnecessry conversion of the defaultvalue to a string before it could be converted back. Example:

Old:

// audio/random_sound.cpp
Set_Volume_Reduction_Begin(string_to_float(attributes.fetch("volume_reduction_begin", float_to_string(m_volume_reduction_begin))));

New:

// audio/random_sound.cpp
Set_Volume_Reduction_Begin(attributes.fetch<float>("volume_reduction_begin", m_volume_reduction_begin));

This has been changed for many sprites, but especially the enemies have not been changed yet. You’ll always find these calls in the constructors of cSprite subclasses whith this signature (yes cRandom_Sound is a subclass of cSprite):

// audio/random_sound.h
cRandom_Sound( XmlAttributes &attributes, cSprite_Manager *sprite_manager );

As this is not only nicer to read, but also improves loading performance (the conversion of the defaultvalue is missing), this should be changed soon.

Vale,
Quintus

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions