| 10854 | } |
| 10855 | |
| 10856 | int CQuake3GameInterface::Evaluate( int p1Type, const char *p1, int p2Type, const char *p2, int operatorType ) |
| 10857 | { |
| 10858 | float f1=0, f2=0; |
| 10859 | vec3_t v1, v2; |
| 10860 | char *c1=0, *c2=0; |
| 10861 | int i1=0, i2=0; |
| 10862 | |
| 10863 | //Always demote to int on float to integer comparisons |
| 10864 | if ( ( ( p1Type == TK_FLOAT ) && ( p2Type == TK_INT ) ) || ( ( p1Type == TK_INT ) && ( p2Type == TK_FLOAT ) ) ) |
| 10865 | { |
| 10866 | p1Type = TK_INT; |
| 10867 | p2Type = TK_INT; |
| 10868 | } |
| 10869 | |
| 10870 | //Cannot compare two disimilar types |
| 10871 | if ( p1Type != p2Type ) |
| 10872 | { |
| 10873 | DebugPrint( WL_ERROR, "Evaluate comparing two disimilar types!\n"); |
| 10874 | return false; |
| 10875 | } |
| 10876 | |
| 10877 | //Format the parameters |
| 10878 | switch ( p1Type ) |
| 10879 | { |
| 10880 | case TK_FLOAT: |
| 10881 | sscanf( p1, "%f", &f1 ); |
| 10882 | sscanf( p2, "%f", &f2 ); |
| 10883 | break; |
| 10884 | |
| 10885 | case TK_INT: |
| 10886 | sscanf( p1, "%d", &i1 ); |
| 10887 | sscanf( p2, "%d", &i2 ); |
| 10888 | break; |
| 10889 | |
| 10890 | case TK_VECTOR: |
| 10891 | sscanf( p1, "%f %f %f", &v1[0], &v1[1], &v1[2] ); |
| 10892 | sscanf( p2, "%f %f %f", &v2[0], &v2[1], &v2[2] ); |
| 10893 | break; |
| 10894 | |
| 10895 | case TK_STRING: |
| 10896 | case TK_IDENTIFIER: |
| 10897 | c1 = (char *) p1; |
| 10898 | c2 = (char *) p2; |
| 10899 | break; |
| 10900 | |
| 10901 | default: |
| 10902 | DebugPrint( WL_WARNING, "Evaluate unknown type used!\n"); |
| 10903 | return false; |
| 10904 | } |
| 10905 | |
| 10906 | //Compare them and return the result |
| 10907 | |
| 10908 | //FIXME: YUCK!!! Better way to do this? |
| 10909 | |
| 10910 | switch ( operatorType ) |
| 10911 | { |
| 10912 | |
| 10913 | // |
no test coverage detected