Author Topic: Cross Platform Outpost 2 Utility Library  (Read 4915 times)

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 941
Re: Cross Platform Outpost 2 Utility Library
« Reply #25 on: November 15, 2019, 11:30:48 AM »
I think this behavior is a bug. I may have forgotten to add an include to the master header and will look at it this evening.

Thanks for pointing it out.

-Brett

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 941
Re: Cross Platform Outpost 2 Utility Library
« Reply #26 on: November 16, 2019, 03:08:44 PM »
@TechCor,

You should be able to pull the master for OP2Utility with the issue you pointed out fixed.

-Brett

Offline TechCor

  • Full Member
  • ***
  • Posts: 105
Re: Cross Platform Outpost 2 Utility Library
« Reply #27 on: November 17, 2019, 11:32:43 PM »
I'm having trouble getting the bitmap stored with ResourceManager. It returns null.

I do something like this (Greatly simplified):
Code: [Select]
ResourceManager resourceManager = new ResourceManager(Outpost2GameDirectory);

Code: [Select]
std::unique_ptr<Stream::BidirectionalReader> stream = resourceManager->GetResourceStream("well0004", true);
// NOTE: I've also tried "well0004.bmp"

if (stream == nullptr)
    return 0; // This happens. Stream is null.

return stream->Length();

Maybe I'm misunderstanding what ResourceManager does. I assumed it would search all the archives in the game directory for "well0004.bmp".

I can successfully get the BMPs using VolFile(Outpost2GameDirectory + "/art.vol") with ReadFileByName.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4861
Re: Cross Platform Outpost 2 Utility Library
« Reply #28 on: November 18, 2019, 01:51:02 PM »
The internal filenames within the VOL files for the tilesets includes the ".bmp" extension. You will need to specify the name exactly, including extension.

The ResourceManager object might be sensitive to things like having a trailing slash at the end of the path. If the path used does not include a trailing slash, try adding one. From your example of using VolFile directly, it looks like the Outpost2GameDirectory value does not include a trailing slash.

Nothing else jumps out at me as possibly wrong. I could check in more detail if you need.

Offline TechCor

  • Full Member
  • ***
  • Posts: 105
Re: Cross Platform Outpost 2 Utility Library
« Reply #29 on: December 24, 2019, 04:22:39 AM »
Hey guys, I'm going to work around this, but there's something I'd like to point out.

You have these very nice convenience functions. I use them to render the map:
Code: [Select]
std::size_t GetTileMappingIndex(std::size_t x, std::size_t y) const;
CellType GetCellType(std::size_t x, std::size_t y) const;
bool GetLavaPossible(std::size_t x, std::size_t y) const;

Only one problem - there aren't any setters!

It appears I have to copy the GetTileIndex implementation to my wrapper so I can modify the tiles.

I assume setters for those methods are all that are needed, and that the other bits of data in the Tile are for save games or something.

Anyway, you need at least some way of modifying tiles by XY coordinates.

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4861
Re: Cross Platform Outpost 2 Utility Library
« Reply #30 on: December 24, 2019, 06:56:35 PM »
Haven't gotten around to implementing it yet. :P

The library was of course developed to support OP2MapImager (and OP2Archive), and so read access had a high priority. Those utilities had no reason to write map data.

I suppose there will be more of a push to develop write capabilities, now that two map editor projects are starting to use OP2Utility.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 941
Re: Cross Platform Outpost 2 Utility Library
« Reply #31 on: December 26, 2019, 10:16:30 PM »
TechCor, I'm working to add the basic setter functions for CellType and LavaPossible. Please keep the requests coming on what you want to see added, changed, or further explained.

GetLavaPossible PR: https://github.com/OutpostUniverse/OP2Utility/pull/330

I would like to add some tile range checks to the code, but it became very complicated very quickly.

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 941
Re: Cross Platform Outpost 2 Utility Library
« Reply #32 on: December 28, 2019, 05:53:28 PM »
Helper functions Map::SetLavaPossible and Map::SetCellType and now implemented in master. there is also a minor update to Stream::FileWriter to improve edge case error messaging.