clintbellanger / flare

Free Libre Action Roleplaying Engine
http://clintbellanger.net/rpg/
GNU General Public License v3.0
166 stars 41 forks source link

Introduce generic enemy class caches to reduce intermap change loading times. #979

Closed stefanbeller closed 11 years ago

stefanbeller commented 11 years ago

As of now the map change takes quite long because of loading data.

This is because every enemy instance loads and parses the config files on its own. So the more enemies the longer it takes to load.

We should load one enemy type only once and any created instance of that type will just copy the memory of the preloaded type. The only adjustments to be made are the position and direction?

clintbellanger commented 11 years ago

Position and direction are the only differences, as far as I know.

This mechanism needs to be in the EnemyManager, when it's reading the new enemy queue from the Map object.

The way I planned to do it: before loading an enemy file, check to see if we've already loaded this enemy type during this map. If so, create a copy of those values instead of loading the same file(s) again from disk. Starting from a blank cache and doing this process on each map load would be a big improvement. We sort of do something similar for the enemy art/sounds, but those have a single copy in EnemyManager anyway.

If we wanted to get fancier, we could keep base copies of the enemy info in EnemyManager even across map loads. Then after loading all creatures for a new map, dump enemies not used during this map out of the cache.

stefanbeller commented 11 years ago

This has been introduced in https://github.com/clintbellanger/flare-engine/pull/10 Closing this.