Ejemplo n.º 1
0
        bool CanTravelOn(Vector path)
        {
            int i;

            if (!this.power) // no power specified, means can travel anywhere
            {
                return(true);
            }
            for (i = 0; i < path._size; ++i)
            {
                Track *trk = path.TrackAt(i);
                if (trk.type == TEXT) // we reached an exit
                {
                    return(true);
                }
                if (!trk.power)
                {
                    return(false);
                }
                if (wxStrcmp(trk.power, this.power))
                {
                    return(false); // different power specified (e.g. 3000V vs. 10000V)
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public bool GetPropertyValue(String prop, ExprValue result)
        {
#if false
            bool    res;
            Vector *path;
            int     i;

            Signal *s = this;
            wxStrncat(expr_buff, prop, sizeof(expr_buff) - 1);

            if (!wxStrcmp(prop, wxPorting.T("aspect")))
            {
                result._op  = String;
                result._txt = s.GetAspect();
                wxSnprintf(expr_buff + Globals.wxStrlen(expr_buff),
                           sizeof(expr_buff) / sizeof(char) - Globals.wxStrlen(expr_buff), wxPorting.T("{%s}"), result._txt);
                return(true);
            }
            if (!wxStrcmp(prop, wxPorting.T("auto")))
            {
                result._op  = Number;
                result._val = s.fleeted;
                wxSnprintf(expr_buff + Globals.wxStrlen(expr_buff),
                           sizeof(expr_buff) / sizeof(char) - Globals.wxStrlen(expr_buff), wxPorting.T("{%d}"), result._val);
                return(true);
            }
            if (!wxStrcmp(prop, wxPorting.T("enabled")))
            {
                result._op  = Number;
                result._val = s.fleeted && s.nowfleeted;
                wxSnprintf(expr_buff + Globals.wxStrlen(expr_buff),
                           sizeof(expr_buff) / sizeof(char) - Globals.wxStrlen(expr_buff), wxPorting.T("{%d}"), result._val);
                return(true);
            }

            result._op  = Number;
            result._val = 0;
            if (!wxStrcmp(prop, wxPorting.T("switchThrown")))
            {
                res = s.GetNextPath(&path);
                if (!path)
                {
                    return(res);
                }

                for (i = 0; i < path._size; ++i)
                {
                    Track *trk = path.TrackAt(i);

                    if (trk.type != SWITCH)
                    {
                        continue;
                    }
                    switch (trk.direction)
                    {
                    case 10:    // these are Y switches, which are always
                    case 11:    // considered as going to the main line,
                    case 22:    // thus ignored as far as signals are concerned.
                    case 23:
                        continue;
                    }
                    if (trk.switched)
                    {
                        result._val = 1;
                        break;
                    }
                }
                wxSnprintf(expr_buff + Globals.wxStrlen(expr_buff),
                           sizeof(expr_buff) / sizeof(char) - Globals.wxStrlen(expr_buff),
                           wxPorting.T("{%s}"), result._val ? wxPorting.T("switchThrown") : wxPorting.T("switchNotThrown"));
                Vector_delete(path);
                return(true);
            }
            if (!wxStrcmp(prop, wxPorting.T("nextLimit")))
            {
                res = s.GetNextPath(&path);
                if (!path)
                {
                    return(res);
                }

                int j;
                int lowSpeed = 1000;

                for (i = 0; i < path._size; ++i)
                {
                    Track *trk = path.TrackAt(i);

                    for (j = 0; j < NTTYPES; ++j)
                    {
                        if (trk.speed[j] && trk.speed[j] < lowSpeed)
                        {
                            lowSpeed = trk.speed[j];
                        }
                    }
                }
                result._val = lowSpeed;
                Vector_delete(path);
                wxSnprintf(expr_buff + Globals.wxStrlen(expr_buff),
                           sizeof(expr_buff) / sizeof(char) - Globals.wxStrlen(expr_buff), wxPorting.T("{%d}"), lowSpeed);
                return(true);
            }
            if (!wxStrcmp(prop, wxPorting.T("nextLength")))
            {
                res = s.GetNextPath(&path);
                if (!path)
                {
                    return(res);
                }

                int length = 0;

                for (i = 0; i < path._size; ++i)
                {
                    Track *trk = path.TrackAt(i);
                    length += trk.length;
                }
                result._val = length;
                Vector_delete(path);
                wxSnprintf(expr_buff + Globals.wxStrlen(expr_buff),
                           sizeof(expr_buff) / sizeof(char) - Globals.wxStrlen(expr_buff), wxPorting.T("{%d}"), length);
                return(true);
            }
            if (!wxStrcmp(prop, wxPorting.T("nextApproach")))
            {
                return(GetApproach(result));
            }
            if (!wxStrcmp(prop, wxPorting.T("nextIsApproach")))
            {
                res         = GetApproach(result);
                result._op  = Number;
                result._val = res == true;
                return(true);
            }
            if (!wxStrcmp(prop, wxPorting.T("nextStation")))
            {
                result._op  = String;
                result._txt = wxPorting.T("");

                res = s.GetNextPath(&path);
                if (!path)
                {
                    return(res);
                }

                for (i = 0; i < path._size; ++i)
                {
                    Track *trk = path.TrackAt(i);

                    if (!trk.isstation)
                    {
                        continue;
                    }
                    result._txt = trk.station;
                    break;
                }
                Vector_delete(path);
                expr_buff + Globals.wxStrlen(expr_buff) = String.Format(wxPorting.T("{%s}"), result._txt);
                return(true);
            }
            if (!wxStrcmp(prop, wxPorting.T("color")))
            {
                result._op  = String;
                result._txt = wxPorting.T("");
                if (s.controls)
                {
                    result._txt = GetColorName(s.controls.fgcolor);
                }
                return(true);
            }
#endif
            return(false);
        }