From 86ed6efd8acbf86c7f85d69e51c40d08f421a1ca Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 18 Sep 2012 17:05:11 +0200 Subject: commands: handle property clamping in m_option Instead of clamping property values to the valid range in each property implementation, handle it in the property layer. The functionality to handle clamping for each type is in m_option.c. It's not really clear whether this is really needed. Normally, the raw values for M_PROPERTY_SET come only from m_option_type.parse (setting properties as string) or from m_option_parse.add (using the "switch" input command). However, since this was already done before, and since we _really_ want to be sure only to write valid values, add this code anyway. The newly added warnings/error messages should never actually be printed during normal operation and are for debugging (if they happen, we definitely want to see them). --- m_property.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'm_property.h') diff --git a/m_property.h b/m_property.h index 462dad57fc..eba61a1619 100644 --- a/m_property.h +++ b/m_property.h @@ -159,14 +159,6 @@ char* mp_property_print(const char *name, void* ctx); /// \brief Helper functions for common property types. ///@{ -/// Clamp a value according to \ref m_option::min and \ref m_option::max. -#define M_PROPERTY_CLAMP(prop,val) do { \ - if(((prop)->flags & M_OPT_MIN) && (val) < (prop)->min) \ - (val) = (prop)->min; \ - else if(((prop)->flags & M_OPT_MAX) && (val) > (prop)->max) \ - (val) = (prop)->max; \ - } while(0) - /// Implement get. int m_property_int_ro(const m_option_t* prop,int action, void* arg,int var); -- cgit v1.2.3