| 1920 | } |
| 1921 | |
| 1922 | void CResponseSystem::LoadFromBuffer( const char *scriptfile, const char *buffer, CStringPool &includedFiles ) |
| 1923 | { |
| 1924 | includedFiles.Allocate( scriptfile ); |
| 1925 | PushScript( scriptfile, (unsigned char * )buffer ); |
| 1926 | |
| 1927 | if( rr_dumpresponses.GetBool() ) |
| 1928 | { |
| 1929 | DevMsg("Reading: %s\n", scriptfile ); |
| 1930 | } |
| 1931 | |
| 1932 | while ( 1 ) |
| 1933 | { |
| 1934 | ParseToken(); |
| 1935 | if ( !token[0] ) |
| 1936 | { |
| 1937 | break; |
| 1938 | } |
| 1939 | |
| 1940 | if ( !Q_stricmp( token, "#include" ) ) |
| 1941 | { |
| 1942 | ParseInclude( includedFiles ); |
| 1943 | } |
| 1944 | else if ( !Q_stricmp( token, "response" ) ) |
| 1945 | { |
| 1946 | ParseResponse(); |
| 1947 | } |
| 1948 | else if ( !Q_stricmp( token, "criterion" ) || |
| 1949 | !Q_stricmp( token, "criteria" ) ) |
| 1950 | { |
| 1951 | ParseCriterion(); |
| 1952 | } |
| 1953 | else if ( !Q_stricmp( token, "rule" ) ) |
| 1954 | { |
| 1955 | ParseRule(); |
| 1956 | } |
| 1957 | else if ( !Q_stricmp( token, "enumeration" ) ) |
| 1958 | { |
| 1959 | ParseEnumeration(); |
| 1960 | } |
| 1961 | else |
| 1962 | { |
| 1963 | int byteoffset = m_ScriptStack[ 0 ].currenttoken - (const char *)m_ScriptStack[ 0 ].buffer; |
| 1964 | |
| 1965 | Error( "CResponseSystem::LoadFromBuffer: Unknown entry type '%s', expecting 'response', 'criterion', 'enumeration' or 'rules' in file %s(offset:%i)\n", |
| 1966 | token, scriptfile, byteoffset ); |
| 1967 | break; |
| 1968 | } |
| 1969 | } |
| 1970 | |
| 1971 | if ( m_ScriptStack.Count() == 1 ) |
| 1972 | { |
| 1973 | char cur[ 256 ]; |
| 1974 | GetCurrentScript( cur, sizeof( cur ) ); |
| 1975 | DevMsg( 1, "CResponseSystem: %s (%i rules, %i criteria, and %i responses)\n", |
| 1976 | cur, m_Rules.Count(), m_Criteria.Count(), m_Responses.Count() ); |
| 1977 | |
| 1978 | if( rr_dumpresponses.GetBool() ) |
| 1979 | { |