Renamed some of Get() methods to Find(), read more
From now on, ideally any function with "get" in the name should always return a valid value. A function with "find" in the name, however, does the same thing, but may also return an invalid result such as an error code.
This commit is contained in:
@@ -294,7 +294,7 @@ void CharacterManager::UnloadIf(std::function<bool(std::pair<const int, Characte
|
||||
//Define the accessors and mutators
|
||||
//-------------------------
|
||||
|
||||
CharacterData* CharacterManager::Get(int uid) {
|
||||
CharacterData* CharacterManager::Find(int uid) {
|
||||
std::map<int, CharacterData>::iterator it = elementMap.find(uid);
|
||||
|
||||
if (it == elementMap.end()) {
|
||||
@@ -304,7 +304,7 @@ CharacterData* CharacterManager::Get(int uid) {
|
||||
return &it->second;
|
||||
}
|
||||
|
||||
CharacterData* CharacterManager::Get(std::string handle) {
|
||||
CharacterData* CharacterManager::Find(std::string handle) {
|
||||
for (std::map<int, CharacterData>::iterator it = elementMap.begin(); it != elementMap.end(); ++it) {
|
||||
if (it->second.GetHandle() == handle) {
|
||||
return &it->second;
|
||||
|
||||
@@ -42,8 +42,8 @@ public:
|
||||
void UnloadIf(std::function<bool(std::pair<const int, CharacterData const&>)> fn);
|
||||
|
||||
//accessors and mutators
|
||||
CharacterData* Get(int uid);
|
||||
CharacterData* Get(std::string handle);
|
||||
CharacterData* Find(int uid);
|
||||
CharacterData* Find(std::string handle);
|
||||
int GetLoadedCount();
|
||||
int GetTotalCount();
|
||||
std::map<int, CharacterData>* GetContainer();
|
||||
|
||||
@@ -55,11 +55,11 @@ static int getCharacter(lua_State* L) {
|
||||
|
||||
switch(lua_type(L, 1)) {
|
||||
case LUA_TNUMBER:
|
||||
characterData = characterMgr.Get(lua_tointeger(L, 1));
|
||||
characterData = characterMgr.Find(lua_tointeger(L, 1));
|
||||
break;
|
||||
case LUA_TSTRING:
|
||||
//access characters via their handles
|
||||
characterData = characterMgr.Get(lua_tostring(L, 1));
|
||||
characterData = characterMgr.Find(lua_tostring(L, 1));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user