--- deliantra/server/include/shstr.h 2006/09/04 11:07:59 1.9 +++ deliantra/server/include/shstr.h 2006/09/12 18:15:34 1.10 @@ -84,6 +84,16 @@ return *this; } + + bool operator ==(const shstr &b) + { + return s == b.s; + } + + bool operator !=(const shstr &b) + { + return !(*this == b); + } }; inline int strlen (const shstr &sh) @@ -91,14 +101,27 @@ return sh.length (); } -inline bool operator ==(const shstr &a, const shstr &b) +// only good for mass comparisons to shstr objects +struct shstr_cmp +{ + const char *s; + + explicit shstr_cmp (const char *s) + : s (shstr::find (s)) + { + } + + operator const char *() const { return s; } +}; + +inline bool operator ==(const shstr_cmp &a, const shstr &b) { return a.s == b.s; } -inline bool operator !=(const shstr &a, const shstr &b) +inline bool operator ==(const shstr &a, const shstr_cmp &b) { - return !(a == b); + return b == a; } extern const shstr undead_name; /* Used in hit_player() in main.c */