MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / Execute

Method Execute

src/openrct2/interface/InteractiveConsole.cpp:1941–2002  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1939}
1940
1941void InteractiveConsole::Execute(const std::string& s)
1942{
1943 arguments_t argv;
1944 argv.reserve(8);
1945
1946 const utf8* start = s.c_str();
1947 const utf8* end;
1948 bool inQuotes = false;
1949 do
1950 {
1951 while (*start == ' ')
1952 start++;
1953
1954 if (*start == '"')
1955 {
1956 inQuotes = true;
1957 start++;
1958 }
1959 else
1960 {
1961 inQuotes = false;
1962 }
1963
1964 end = start;
1965 while (*end != 0)
1966 {
1967 if (*end == ' ' && !inQuotes)
1968 break;
1969 if (*end == '"' && inQuotes)
1970 break;
1971 end++;
1972 }
1973 size_t length = end - start;
1974
1975 if (length > 0)
1976 {
1977 argv.emplace_back(start, length);
1978 }
1979
1980 start = end;
1981 } while (*end != 0);
1982
1983 if (argv.empty())
1984 return;
1985
1986 bool validCommand = false;
1987 for (const auto& c : console_command_table)
1988 {
1989 if (argv[0] == c.command)
1990 {
1991 argv.erase(argv.begin());
1992 c.func(*this, argv);
1993 validCommand = true;
1994 break;
1995 }
1996 }
1997
1998 if (!validCommand)

Callers 2

ConsoleSetVariableActionFunction · 0.45
ConsoleCommandSetFunction · 0.45

Calls 2

emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected