diff --git a/lib/opengd77base_codeplug.cc b/lib/opengd77base_codeplug.cc index 6545e48c..7a56420c 100644 --- a/lib/opengd77base_codeplug.cc +++ b/lib/opengd77base_codeplug.cc @@ -1469,27 +1469,31 @@ OpenGD77BaseCodeplug::ZoneElement::setName(const QString &name) { writeASCII(Offset::name(), name, Limit::nameLength(), 0xff); } + bool OpenGD77BaseCodeplug::ZoneElement::hasMember(unsigned n) const { if (n >= Limit::memberCount()) return false; - return (0 != member(n)); + return 0 != getUInt16_le(Offset::channels() + Offset::betweenChannels()*n); } + unsigned OpenGD77BaseCodeplug::ZoneElement::member(unsigned n) const { if (n >= Limit::memberCount()) return 0; - return getUInt16_le(Offset::channels()+Offset::betweenChannels()*n); + return getUInt16_le(Offset::channels() + Offset::betweenChannels()*n)-1; } + void OpenGD77BaseCodeplug::ZoneElement::setMember(unsigned n, unsigned idx) { if (n >= Limit::memberCount()) return; - setUInt16_le(Offset::channels()+Offset::betweenChannels()*n, idx); + setUInt16_le(Offset::channels() + Offset::betweenChannels()*n, idx+1); } + void OpenGD77BaseCodeplug::ZoneElement::clearMember(unsigned n) { - setMember(n, 0); + setUInt16_le(Offset::channels() + Offset::betweenChannels()*n, 0); } @@ -2161,12 +2165,12 @@ OpenGD77BaseCodeplug::GroupListElement::hasContactIndex(unsigned int i) const { unsigned int OpenGD77BaseCodeplug::GroupListElement::contactIndex(unsigned int i) const { - return getUInt16_le(Offset::contacts() + i*Offset::betweenContacts())-1; + return getUInt16_le(Offset::contacts() + i*Offset::betweenContacts()) - 1; } void OpenGD77BaseCodeplug::GroupListElement::setContactIndex(unsigned int i, unsigned int contactIdx) { - setUInt16_le(Offset::contacts() + i*Offset::betweenContacts(), contactIdx+1); + setUInt16_le(Offset::contacts() + i*Offset::betweenContacts(), contactIdx + 1); } void diff --git a/lib/opengd77base_codeplug.hh b/lib/opengd77base_codeplug.hh index d2c64ea4..4a36ad6c 100644 --- a/lib/opengd77base_codeplug.hh +++ b/lib/opengd77base_codeplug.hh @@ -805,12 +805,11 @@ public: /** Sets the name of the zone. */ virtual void setName(const QString &name); - /** Returns @c true if a member is stored at the given index. - * That is, if the index is not 0. */ + /** Returns @c true if a member is stored at the given index. */ virtual bool hasMember(unsigned n) const; - /** Returns the n-th member index (+1). */ + /** Returns the n-th member index. */ virtual unsigned member(unsigned n) const; - /** Sets the n-th member index (+1). */ + /** Sets the n-th member index. */ virtual void setMember(unsigned n, unsigned idx); /** Clears the n-th member index. */ virtual void clearMember(unsigned n);