Author Topic: Deleting tilesets from Outpost 2 Maps  (Read 4436 times)

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1015
Deleting tilesets from Outpost 2 Maps
« on: April 28, 2018, 09:47:17 AM »
Hey everyone,

I have a local branch on OP2Utility that allows deleting a tileset from the MapData struct. It is pretty complicated though:

How a tileset is deleted:
  • Find if a TileSetSource exists with given name
  • Record tilesetSourceIndex and TileSetSource's TileCount
  • Delete the TilesetSrouce
  • Delete all TileInfos that originate from the TilesetSource
  • Decrement all TileInfo's index to it's source TileSetSource (This way they do not index to the wrong tilesetSource)
  • Set all Tiles on the map that came from the deleted tileset to a TileIndex 0 (usually blue)
  • Decrement by one all Tiles on the map that have TileInfoIndices greater than the deleted TileSetSource (This way they match up with the new indexing of the TileInfo container.)
  • Perform the same previous 2 operations on all TileGroups (This prevents a TileGroup from referencing a deleted tile and updates TileGroups with the new indexing of the TileInfo container.)
  • Abort the operation if the tileset exists on a TerrainType
  • Decrement all TerrainType TileInfos indexes that were decremented above

Okay, so this is not very useful right now. Mostly because of that second to last step where it is aborted if the tileset exists on a TerrainType. TerrainTypes represent multiple tilesets and how they interact. All tilesets in Outpost 2 belong to a TerrainType besides the first well that is just a blue tile. I did test the operation, and it worked properly by deleting Well0000.

I could design the algorithm to work by removing the removed tilesetSource range from the affected TerrainType. However, if this tileset were added back in, it would not automatically be restored into the TerrainType. And if you say deleted the tileset that had the tubes on it for the sand tiles, I doubt this would go well when you played. However, if you were smart, you could delete all sand tilesets and then everything would probably work fine. Then you would have a bunch of available tiles to design something else on.

So, for now I think I'll finish this branch up, which will allow for adding and deleting tilesets (as long as they do not belong to a TileType, which makes its usefulness limited).

We will have to decide how we want to handle adding new tilesets with the association of TerrainTypes. Since TerrainTypes span multiple tilesets, it isn't a clean solution. Maybe the 2 questions worth asking are

1. Leeor, do you plan on the Mapper supporting adding tilesets, and if so how do we want to handle tile metadata associated with a new tileset?

Creating, Adding, and removing tilesets could actually happen in a third-party tool. Maybe a command-line tool that consumes some sort of Yaml or Json or XML format with a raw tileset to add it into a map outside of the Mapper. This might save a lot of time hooking some sort of complex GUI screen into the Mapper to set it all up. But it isn't as slick as including it in the Mapper.

2. Is anyone burning to have the ability to extend Outpost 2 with new tilesets? If so, I'm going to happily work on this feature. If not, maybe just leaving it at this weak attempt for now indefinetly. I do want to commit it into the code base though even if it is just there to show someone in the future what to mostly do to delete a tileset.

Thanks,
Brett

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2352
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: Deleting tilesets from Outpost 2 Maps
« Reply #1 on: April 28, 2018, 10:15:13 PM »
1. Leeor, do you plan on the Mapper supporting adding tilesets, and if so how do we want to handle tile metadata associated with a new tileset?

Creating, Adding, and removing tilesets could actually happen in a third-party tool. Maybe a command-line tool that consumes some sort of Yaml or Json or XML format with a raw tileset to add it into a map outside of the Mapper. This might save a lot of time hooking some sort of complex GUI screen into the Mapper to set it all up. But it isn't as slick as including it in the Mapper.

I hadn't considered it but I'm not opposed to it. I know it's been something that was talked about a lot in the past and we've seen replacement tilesets like the Greenworld and Iceworld sets so perhaps it's something that should be done?

2. Is anyone burning to have the ability to extend Outpost 2 with new tilesets? If so, I'm going to happily work on this feature. If not, maybe just leaving it at this weak attempt for now indefinetly. I do want to commit it into the code base though even if it is just there to show someone in the future what to mostly do to delete a tileset.

I semi-answered this above, but I'd say if it's something that can be done we should consider it.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: Deleting tilesets from Outpost 2 Maps
« Reply #2 on: April 29, 2018, 08:06:14 AM »
Yes, this may give you some idea of how ugly the OP2Editor code got for copy/pasting tiles between maps. What if the maps had different tilesets, or the same tilesets mapped in a different order.


I really want to create JSON data sets of a lot of the game data. This has been on my mind for a while now. I think having people rely on binary processing tools limits people's ability to inspect and learn about the game. I'd like to start on a set of tools that can extract various game data into human readable formats, that are also machine processable. I think JSON would be an excellent candidate.

This idea include the map files. I would like to be able to dump .map files into some kind of standard JSON format. I'd also like to extract certain info from map files, which is more rightly associated with tilesets, such as the tile groups. The terrain data also probably falls in that category.

There's also a lot of hardcoded constants within the game which I'd like to have extracted, such as animation index values. Though that's a whole other story.