MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / reload

Method reload

source/game/StarRoot.cpp:179–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179void Root::reload() {
180 Logger::info("Root: Reloading from disk");
181
182 {
183 // We need to lock all the mutexes to reset everything to cause it to be
184 // reloaded, but whenever we lock individual members we should always do it
185 // in the same order (well, the same order*ing* not necessarily the same
186 // order) to avoid deadlocks. This means that we need to enumerate the
187 // finicky, implicit dependency order that we have due to each member's
188 // constructor referencing root recursively. We could avoid doing this
189 // explicitly with C++11's std::lock (if c++11 threading primitives were
190 // finally reliable on all targets), or some other equivalent deadlock
191 // avoidance algorithm.
192
193 // Entity factory depends on all the entity databases and the versioning
194 // database.
195 MutexLocker entityFactoryLock(m_entityFactoryMutex);
196
197 // Species database depends on the item database.
198 MutexLocker speciesDatabaseLock(m_speciesDatabaseMutex);
199
200 // Item database depends on object database and codex database
201 MutexLocker itemDatabaseLock(m_itemDatabaseMutex);
202
203 // These databases depend on various things below, but not the item database
204 MutexLocker objectDatabaseLock(m_objectDatabaseMutex);
205 MutexLocker playerFactoryLock(m_playerFactoryMutex);
206 MutexLocker npcDatabaseLock(m_npcDatabaseMutex);
207 MutexLocker stagehandDatabaseLock(m_stagehandDatabaseMutex);
208 MutexLocker vehicleDatabaseLock(m_vehicleDatabaseMutex);
209 MutexLocker monsterDatabaseLock(m_monsterDatabaseMutex);
210 MutexLocker plantDatabaseLock(m_plantDatabaseMutex);
211 MutexLocker projectileDatabaseLock(m_projectileDatabaseMutex);
212
213 // Biome database depends on liquids, materials, and stored function
214 // databases.
215 MutexLocker biomeDatabaseLock(m_biomeDatabaseMutex);
216
217 // Dungeon definitions database depends on the material and liquids database
218 MutexLocker dungeonDefinitionsLock(m_dungeonDefinitionsMutex);
219 MutexLocker tilesetDatabaseLock(m_tilesetDatabaseMutex);
220
221 MutexLocker statisticsDatabaseLock(m_statisticsDatabaseMutex);
222
223 // Liquids database depends on the materials database
224 MutexLocker liquidsDatabaseLock(m_liquidsDatabaseMutex);
225
226 // Material database depends on particle database
227 MutexLocker materialDatabaseLock(m_materialDatabaseMutex);
228
229 // Databases that depend on functions database.
230 MutexLocker damageDatabaseLock(m_damageDatabaseMutex);
231 MutexLocker effectSourceDatabaseLock(m_effectSourceDatabaseMutex);
232 MutexLocker statusEffectDatabaseLock(m_statusEffectDatabaseMutex);
233 MutexLocker treasureDatabaseLock(m_treasureDatabaseMutex);
234
235 // Databases that don't depend on anything other than assets
236 MutexLocker codexDatabaseLock(m_codexDatabaseMutex);

Callers 2

serverReloadMethod · 0.45
TESTFunction · 0.45

Calls 2

resetMethod · 0.45
triggerMethod · 0.45

Tested by 1

TESTFunction · 0.36