GameMap refactoring ideas

GameMap refactoring ideas

Postby paul424 » 29 Jul 2012, 13:07

The game Map is still the largest file , having 3K LOC.
Any ideas for refactoring that ? One should find out some separate responsibilty or role which could be put into another class. ...
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: GameMap refactoring ideas

Postby paul424 » 29 Jul 2012, 13:15

/*! \brief Returns the tiles visible from the given start tile out to the specified sight radius.
*
*/
std::vector<Tile*> GameMap::visibleTiles(Tile *startTile, double sightRadius)
From what I can deduce from the code of it it iterates some ray from the startTile over all tiles in sightRadious. Shouldn't we divide the whole map into convex sectors with visibility map : convex sectors -> list< convex sectors> ? It would be difficult first it would be a dynamic process , second the tunnels or dungeons are not convex hulls nor even polygons ....
User avatar
paul424
OD Moderator
 
Posts: 660
Joined: 24 Jan 2012, 13:54

Re: GameMap refactoring ideas

Postby oln » 30 Jul 2012, 10:57

The GameMap class does too many things right now, so the tasks should probably be split up into separate classes. E.g one keeping track of the tile and entity lists, one doing updates, one containing pathfinding, one doing tile utility functions etc.

As for the visibility calculation, it can probably be improved a lot, but that would be premature optimization, and shouldn't be done at this stage.
User avatar
oln
 
Posts: 1020
Joined: 26 Oct 2010, 22:16
Location: Norway

Who is online

Users browsing this forum: No registered users and 1 guest