Regarding error error C2059: syntax error : 'return' , this is the way to fix this specific error:
return stringOutput ? "never" : sObjectMgr->FindCreature(Guid)->GetCreatureData()->spawntimesecs;
The ?: Operator is an expression, and each argument to the operator must be an expression. return is a statement. not an expression.
As an expression, ?: Has exactly one type. but "never" and spawntimesecs are unrelated types. The compiler cannot handle this. these two values ββare not included in the same expression ?: .
You may be able to use a join, but this is not recommended.
A better solution would not use a template at all, since you are not using a type parameter in any polymorphic way:
float GetTimeDeadFloat(uint64 Guid) { return find(Guid) ? dieTracker.find(Guid)->second.seconds : sObjectMgr->FindCreature(Guid)->GetCreatureData()->spawntimesecs; } string GetTimeDeadString(uint64 Guid) { return find(Guid) ? timeToString(dieTracker.find(Guid)->second.seconds) : "never"; } bool find(uint64 Guid) { for(map<uint32, TrackInfo>::iterator itr = dieTracker.begin(); itr != dieTracker.end(); ++itr) { if(itr->second.GUID == Guid) return true; } return false; } string timeToString(float seconds) { string res = timeToString(seconds % 3600 / 60, "Minutes"); res += timeToString(seconds % 86400 / 3600, "Hour"); res += timeToString(seconds / 86400, "Day"); if (secs || res.length() == 0) res += numToString(seconds % 60, "Second"); res += "ago"; return res; } string numToString(uint64 num, string type) { ostringstream ss; if (num) ss << num << " " << type << (num != 1) ? "s" : "" << " "; return ss.str(); }
source share