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

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 964
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: 964
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: 126
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: 4893
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: 126
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: 4893
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: 964
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: 964
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.

Offline TechCor

  • Full Member
  • ***
  • Posts: 126
Re: Cross Platform Outpost 2 Utility Library
« Reply #33 on: February 10, 2020, 10:36:03 AM »
I'm in the process of moving my projects to VS 2019. No problem with the mission SDK, but OP2 Utility is giving me a deprecation error:

Code: [Select]
Error	C1189	#error:  The <experimental/filesystem> header providing std::experimental::filesystem is deprecated by Microsoft and will be REMOVED. It is superseded by the C++17 <filesystem> header providing std::filesystem. You can define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING to acknowledge that you have received this warning.	

OP2Utility C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\experimental\filesystem 30

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 964
Re: Cross Platform Outpost 2 Utility Library
« Reply #34 on: February 12, 2020, 11:11:14 AM »
TechCor,

Thanks for reporting this. I've noticed in the past for some reason the Visual Studio build of OP2Utility is defaulting to the experimental build of filesystem instead of the final build.

We have a preprocessor directive as an include guard that should be incorporating the newer header on a VS2019 toolset compilation. We need to look into why it is not finding the final build and forcing selection of the experimental build for MSVC.

-Brett

Offline Vagabond

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 964
Re: Cross Platform Outpost 2 Utility Library
« Reply #35 on: February 14, 2020, 07:49:32 PM »
TechCor,

I just created a Pull Request for OP2Utility that should fix the issue. https://github.com/OutpostUniverse/OP2Utility/pull/334

-Brett