Changeset 754 for cpp/frams/param


Ignore:
Timestamp:
03/02/18 18:46:54 (6 years ago)
Author:
Maciej Komosinski
Message:

More strict rules for Param type descriptions and "unlimited range value" and "unlimited string length": "d 0 -1", "f 0 -1", "s 0 0", "s 1 0" (see formatspec.html)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/param.cpp

    r745 r754  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2017  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    801801        {
    802802        case 'd':
    803         {paInt a, b, c; if (getMinMaxIntFromTypeDef(t, a, b, c) == 1) return false; }
     803        {
     804                paInt a, b, c;
     805                int have = getMinMaxIntFromTypeDef(t, a, b, c);
     806                if (have == 1) return false;
     807                if ((have >= 2) && (b < a) && (a != 0) && (b != -1)) return false; // max<min meaning 'undefined' is only allowed as "d 0 -1"
     808        }
    804809                break;
    805810        case 'f':
    806         {double a, b, c; if (getMinMaxDoubleFromTypeDef(t, a, b, c) == 1) return false; }
     811        {
     812                double a, b, c;
     813                int have = getMinMaxDoubleFromTypeDef(t, a, b, c);
     814                if (have == 1) return false;
     815                if ((have >= 2) && (b < a) && (a != 0) && (b != -1)) return false; // max<min meaning 'undefined' is only allowed as "f 0 -1"
     816        }
     817                break;
     818        case 's':
     819        {
     820                int a, b; SString c;
     821                int have = getMinMaxStringFromTypeDef(t, a, b, c);
     822                //if (have == 1) return false; //not sure?
     823                if ((have >= 1) && (!((a == 0) || (a == 1)))) return false; // 'min' for string (single/multi) can be only 0 or 1
     824                if ((have >= 2) && (b < 0)) return false; // max=0 means unlimited, max<0 is not allowed
     825        }
    807826                break;
    808827        }
Note: See TracChangeset for help on using the changeset viewer.