Skip to content

Instantly share code, notes, and snippets.

@Ratstail91
Created February 21, 2015 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ratstail91/99a36c8624a015b1944a to your computer and use it in GitHub Desktop.
Save Ratstail91/99a36c8624a015b1944a to your computer and use it in GitHub Desktop.
All usages of "Mgr."
Searching 211 files for "Mgr."
C:\Users\Kayne\Desktop\Tortuga\server\server_character_methods.cpp:
30
31 void ServerApplication::hCharacterCreate(CharacterPacket* const argPacket) {
32: int characterIndex = characterMgr.Create(argPacket->accountIndex, argPacket->handle, argPacket->avatar);
33
34 if (characterIndex < 0) {
..
47
48 //push to the rooms
49: roomMgr.PushCharacter(characterMgr.Get(characterIndex));
50
51 //pump this character to all clients
..
58 void ServerApplication::hCharacterDelete(CharacterPacket* const argPacket) {
59 //get the user's data
60: AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
61 if (!accountData) {
62 return;
63 }
64: ClientData* clientData = clientMgr.Get(accountData->GetClientIndex());
65 if (!clientData) {
66 return;
..
74
75 //load the character into memory
76: int characterIndex = characterMgr.Load(argPacket->accountIndex, argPacket->handle, argPacket->avatar);
77
78 if (characterIndex < 0) {
..
91
92 //pop from the rooms
93: roomMgr.PopCharacter(characterMgr.Get(characterIndex));
94
95 //delete the character
96: characterMgr.Delete(characterIndex);
97
98 //pump character delete
..
104
105 void ServerApplication::hCharacterLoad(CharacterPacket* const argPacket) {
106: int characterIndex = characterMgr.Load(argPacket->accountIndex, argPacket->handle, argPacket->avatar);
107
108 if (characterIndex < 0) {
...
127
128 //push to the rooms
129: roomMgr.PushCharacter(characterMgr.Get(characterIndex));
130
131 //pump this character to all clients
...
138 void ServerApplication::hCharacterUnload(CharacterPacket* const argPacket) {
139 //get the entries
140: CharacterData* characterData = characterMgr.Get(argPacket->characterIndex);
141 if (!characterData) {
142 return;
143 }
144
145: AccountData* accountData = accountMgr.Get(characterData->GetOwner());
146 if (!accountData) {
147 return;
148 }
149
150: ClientData* clientData = clientMgr.Get(accountData->GetClientIndex());
151 if (!clientData) {
152 return;
...
160
161 //pop from the rooms
162: roomMgr.PopCharacter(characterData);
163
164 //unload the character
165: characterMgr.Unload(argPacket->characterIndex);
166
167 //pump character delete
...
180 void ServerApplication::hCharacterMovement(CharacterPacket* const argPacket) {
181 //get the specified objects
182: AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
183: CharacterData* characterData = characterMgr.Get(argPacket->characterIndex);
184
185 if (!accountData || !characterData) {
...
188
189 //get this account's client
190: ClientData* clientData = clientMgr.Get(accountData->GetClientIndex());
191
192 //check for fraud
...
212
213 //move the character between rooms
214: roomMgr.PopCharacter(characterData);
215 characterData->SetRoomIndex(argPacket->roomIndex);
216: roomMgr.PushCharacter(characterData);
217
218 //create in the new room
C:\Users\Kayne\Desktop\Tortuga\server\server_connections.cpp:
36
37 void ServerApplication::hPong(ServerPacket* const argPacket) {
38: clientMgr.HandlePong(argPacket);
39 }
40
..
49 newPacket.type = SerialPacketType::BROADCAST_RESPONSE;
50 strncpy(newPacket.name, config["server.name"].c_str(), PACKET_STRING_SIZE);
51: newPacket.playerCount = characterMgr.GetLoadedCount();
52 newPacket.version = NETWORK_VERSION;
53
..
57 void ServerApplication::hJoinRequest(ClientPacket* const argPacket) {
58 //register the client
59: int clientIndex = clientMgr.Create(argPacket->srcAddress);
60
61 //send the client their info
..
67
68 //finished this routine
69: std::cout << "New join, " << clientMgr.GetLoadedCount() << " clients and " << accountMgr.GetLoadedCount() << " accounts total" << std::endl;
70 }
71
72 void ServerApplication::hLoginRequest(ClientPacket* const argPacket) {
73 //get the client data
74: ClientData* clientData = clientMgr.Get(argPacket->clientIndex);
75
76 if (clientData == nullptr || clientData->GetAddress() != argPacket->srcAddress) {
..
80
81 //load the user account
82: int accountIndex = accountMgr.Load(argPacket->username, argPacket->clientIndex);
83
84 //Cannot load
..
108
109 //finished this routine
110: std::cout << "New login, " << clientMgr.GetLoadedCount() << " clients and " << accountMgr.GetLoadedCount() << " accounts total" << std::endl;
111 }
112
113 void ServerApplication::hLogoutRequest(ClientPacket* const argPacket) {
114 //get the account and client data
115: AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
116 if (!accountData) {
117 return;
118 }
119
120: ClientData* clientData = clientMgr.Get(accountData->GetClientIndex());
121 if (!clientData) {
122 std::ostringstream msg;
...
142
143 //finished this routine
144: std::cout << "New logout, " << clientMgr.GetLoadedCount() << " clients and " << accountMgr.GetLoadedCount() << " accounts total" << std::endl;
145 }
146
147 void ServerApplication::hDisconnectRequest(ClientPacket* const argPacket) {
148 //get the client data
149: ClientData* clientData = clientMgr.Get(argPacket->clientIndex);
150 if (!clientData) {
151 return;
...
169
170 //finished this routine
171: std::cout << "New disconnection, " << clientMgr.GetLoadedCount() << " clients and " << accountMgr.GetLoadedCount() << " accounts total" << std::endl;
172 }
173
C:\Users\Kayne\Desktop\Tortuga\server\server_data_queries.cpp:
31 void ServerApplication::hRegionRequest(RegionPacket* const argPacket) {
32 //get the region object, send a rejection on error
33: RoomData* room = roomMgr.Get(argPacket->roomIndex);
34 if (!room) {
35 //build the error message
..
66 CharacterPacket newPacket;
67
68: for (auto& it : *characterMgr.GetContainer()) {
69 if (argPacket->roomIndex != -1 && it.second.GetRoomIndex() != argPacket->roomIndex) {
70 continue;
C:\Users\Kayne\Desktop\Tortuga\server\server_logic.cpp:
102
103 //set the hooks
104: accountMgr.SetDatabase(database);
105: characterMgr.SetDatabase(database);
106
107: roomMgr.SetLuaState(luaState);
108: roomMgr.SetDatabase(database);
109
110 std::cout << "Internal managers initialized" << std::endl;
...
187
188 //Check client connections
189: std::list<int> disconnections = clientMgr.CheckConnections();
190 for(auto const& it : disconnections) {
191 FullClientUnload(it);
...
198 if (simTime < realTime) {
199 while(simTime < realTime) {
200: for (auto& it : *roomMgr.GetContainer()) {
201 it.second.RunFrame();
202 }
...
220
221 //close the managers
222: accountMgr.UnloadAll();
223: characterMgr.UnloadAll();
224: clientMgr.UnloadAll();
225: roomMgr.UnloadAll();
226
227 //APIs
C:\Users\Kayne\Desktop\Tortuga\server\server_methods.cpp:
36 void ServerApplication::hAdminShutdownRequest(ClientPacket* const argPacket) {
37 //get the account and client data
38: AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
39 if (!accountData) {
40 return;
41 }
42: ClientData* clientData = clientMgr.Get(accountData->GetClientIndex());
43 if (!clientData) {
44 std::ostringstream msg;
..
94
95 void ServerApplication::FullClientUnload(int index) {
96: clientMgr.UnloadIf([&](std::pair<const int, ClientData const&> client) -> bool {
97 //skip the wrong clients
98 if (client.first != index) {
..
101
102 //unload associated accounts
103: for (std::map<int, AccountData>::iterator it = accountMgr.GetContainer()->begin(); it != accountMgr.GetContainer()->end(); /* EMPTY */) {
104 if (it->second.GetClientIndex() == index) {
105 FullAccountUnload(it->first);
106: it = accountMgr.GetContainer()->begin();
107 }
108 else {
...
117
118 void ServerApplication::FullAccountUnload(int index) {
119: accountMgr.UnloadIf([&](std::pair<const int, AccountData const&> account) -> bool {
120 //skip the wrong accounts
121 if (account.first != index) {
...
124
125 //unload associated characters
126: for (std::map<int, CharacterData>::iterator it = characterMgr.GetContainer()->begin(); it != characterMgr.GetContainer()->end(); /* EMPTY */) {
127 if (it->second.GetOwner() == index) {
128 FullCharacterUnload(it->first);
129: it = characterMgr.GetContainer()->begin();
130 }
131 else {
...
140
141 void ServerApplication::FullCharacterUnload(int index) {
142: characterMgr.UnloadIf([&](std::pair<const int, CharacterData const&> character) -> bool {
143 //skip the wrong characters
144 if (character.first != index) {
...
147
148 //pop from the rooms
149: roomMgr.PopCharacter(&character.second);
150
151 //pump character unload
...
167
168 void ServerApplication::PumpPacket(SerialPacket* const argPacket) {
169: for (auto& it : *clientMgr.GetContainer()) {
170 network.SendTo(it.second.GetAddress(), argPacket);
171 }
...
173
174 void ServerApplication::PumpPacketProximity(SerialPacket* const argPacket, int roomIndex, Vector2 position, int distance) {
175: RoomData* room = roomMgr.Get(roomIndex);
176
177 if (!room) {
...
181 for (auto& character : *room->GetCharacterList()) {
182 if (distance == -1 || (character->GetOrigin() - position).Length() <= distance) {
183: AccountData* account = accountMgr.Get(character->GetOwner());
184: ClientData* client = clientMgr.Get(account->GetClientIndex());
185 network.SendTo(client->GetAddress(), argPacket);
186 }
...
189
190 void ServerApplication::CopyCharacterToPacket(CharacterPacket* const packet, int characterIndex) {
191: CharacterData* character = characterMgr.Get(characterIndex);
192 if (!character) {
193 throw(std::runtime_error("Failed to copy a character to a packet"));
C:\Users\Kayne\Desktop\Tortuga\server\characters\character_manager_api.cpp:
51 switch(lua_type(L, 1)) {
52 case LUA_TNUMBER:
53: characterData = characterMgr.Get(lua_tointeger(L, 1));
54 break;
55 case LUA_TSTRING:
56 //access characters via their handles
57: characterData = characterMgr.Get(lua_tostring(L, 1));
58 break;
59 }
..
71 static int getLoadedCount(lua_State* L) {
72 CharacterManager& characterMgr = CharacterManager::GetSingleton();
73: lua_pushinteger(L, characterMgr.GetLoadedCount());
74 return 1;
75 }
C:\Users\Kayne\Desktop\Tortuga\server\rooms\room_data.cpp:
73 lua = L;
74 pager.SetLuaState(lua);
75: monsterMgr.SetLuaState(lua);
76: waypointMgr.SetLuaState(lua);
77 return lua;
78 }
..
84 sqlite3* RoomData::SetDatabase(sqlite3* db) {
85 database = db;
86: monsterMgr.SetDatabase(database);
87 return database;
88 }
C:\Users\Kayne\Desktop\Tortuga\server\rooms\room_manager_api.cpp:
27 //create & get the room
28 RoomManager& roomMgr = RoomManager::GetSingleton();
29: int uid = roomMgr.Create(lua_tostring(L, 1), lua_tostring(L, 2));
30: RoomData* room = roomMgr.Get(uid);
31
32 //TODO: initialization parameters here?
..
46 //number
47 int uid = lua_tointeger(L, 1);
48: roomMgr.UnloadIf([uid](std::pair<int, RoomData> it){
49 return it.first == uid;
50 });
..
54 //name
55 std::string name = lua_tostring(L, 1);
56: roomMgr.UnloadIf([name](std::pair<int, RoomData> it){
57 return it.second.GetName() == name;
58 });
..
62 //the room itself
63 std::string name = static_cast<RoomData*>(lua_touserdata(L, 1))->GetName();
64: roomMgr.UnloadIf([name](std::pair<int, RoomData> it){
65 return it.second.GetName() == name;
66 });
..
79 case LUA_TNUMBER:
80 //number
81: room = roomMgr.Get(lua_tointeger(L, 1));
82 break;
83 case LUA_TSTRING:
84 //name
85: room = roomMgr.Get(lua_tostring(L, 1));
86 break;
87 }
..
99 static int setOnCreate(lua_State* L) {
100 RoomManager& roomMgr = RoomManager::GetSingleton();
101: luaL_unref(L, LUA_REGISTRYINDEX, roomMgr.GetCreateReference());
102: roomMgr.SetCreateReference(luaL_ref(L, LUA_REGISTRYINDEX));
103 return 0;
104 }
...
106 static int setOnUnload(lua_State* L) {
107 RoomManager& roomMgr = RoomManager::GetSingleton();
108: luaL_unref(L, LUA_REGISTRYINDEX, roomMgr.GetUnloadReference());
109: roomMgr.SetUnloadReference(luaL_ref(L, LUA_REGISTRYINDEX));
110 return 0;
111 }
84 matches across 8 files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment