Author Topic: MAPVIEW upgrade  (Read 151314 times)

Offline Alex_D

  • Colonel
  • ****
  • Posts: 386
    • View Profile
Re: MAPVIEW upgrade
« Reply #510 on: August 25, 2021, 05:30:27 pm »
Hi kevL.

I have a question, please forgive me if it was answered before.

One of my problems with maps in general is when I want to re-arrange the terrain orders without altering their index position on the map.

For example I want to switch positions 'JUNGLE' first and 'ROAD' second. And I want the Map program to perform the terrain position swap while retaining the overall indexes.

Is this sort of function implemented by Map View 2 ?

Offline kevL

  • Colonel
  • ****
  • Posts: 374
  • pitchforks and torches
    • View Profile
Re: MAPVIEW upgrade
« Reply #511 on: August 26, 2021, 01:37:51 am »
One of my problems with maps in general is when I want to re-arrange the terrain orders without altering their index position on the map.

For example I want to switch positions 'JUNGLE' first and 'ROAD' second. And I want the Map program to perform the terrain position swap while retaining the overall indexes.

Is this sort of function implemented by Map View 2 ?

good question,

unfortunately there's no automatic way to do that.

note it should be half-possible with Edit|Tilepart Substitution. But since the max #id is capped at the max terrainset #id, it's /not/ possible to shift one terrain's #ids up out of the way of all terrains' #ids, to free them for use by the terrain that's being shifted ... (without doing that, the #ids of the 2 terrains would become mixed together)

I'll think about writing an Edit|swap terrains ... it's not immediately obvious how, though, what with 3+ terrains each having different total parts ... hm,
« Last Edit: August 26, 2021, 01:40:06 am by kevL »

Offline kevL

  • Colonel
  • ****
  • Posts: 374
  • pitchforks and torches
    • View Profile
Re: MAPVIEW upgrade
« Reply #512 on: October 05, 2021, 03:09:09 am »
@Alex_D

Mapview2 4.0.1.0

- Edit|Terrain Swap [Ctrl+W] opens a dialog box for rearranging the order of
  terrains in the current Map's terrainset without the tileset going all wtf.
- fix obscure bug in the TilesetEditor: if button at the bottom was clicked to
  apply allocated terrains to all tilesets that share Map+Path, and such a
  tileset shared the same Category-label as the current tileset, but is in a
  different Group, said tileset failed to update its metadata. Fixed.
- when the button at the bottom of the TilesetEditor is clicked to apply
  allocated terrains to all tilesets that share Map+Path, show an infobox with
  how many tilesets got updated. (It was irksome to click it and nothing seemed
  to happen.)

+ slight refactors to TilesetEditor and TilepartSubstitution etc.

| I'll think about writing an Edit|swap terrains ... it's not immediately obvious how, though, what with 3+ terrains each having different total parts ... hm,

it factored down to this little ditty:

Code: [Select]
for (int i = 0; i != _terCount; ++i) // subtract part-ids until the terrain becomes the 'first' terrain ->
{
    if (order0 == i) break;
    part.SetId -= _partCounts[i];
}

for (int i = 0; i != _terCount; ++i) // add part-ids until the terrain goes to its 'final' position in the terrainset.
{
    if (order1 == i) break;
    part.SetId += partCounts[i];
}

Beta. Take the necessary precautions: Backup your stuff, tks -- this can seriously screw up .MAPs if it goes wrong.
« Last Edit: October 05, 2021, 03:16:43 am by kevL »

Offline Alex_D

  • Colonel
  • ****
  • Posts: 386
    • View Profile
Re: MAPVIEW upgrade
« Reply #513 on: October 06, 2021, 09:59:02 pm »
Thank you kevL

Offline Nord

  • Commander
  • *****
  • Posts: 1330
  • The Gate will open... someday.
    • View Profile
Re: MAPVIEW upgrade
« Reply #514 on: October 16, 2021, 11:31:12 am »
Hi. Noticed that vanilla tftd map of alien base level 1 can not be opened via MapView. Something looks wrong, maybe with map height.

Offline robin

  • Commander
  • *****
  • Posts: 1135
  • ULTIMATE ROOKIE
    • View Profile
Re: MAPVIEW upgrade
« Reply #515 on: October 16, 2021, 12:08:40 pm »
I get this when I try to copy-paste an area of tiles from a map to another.
Happens both if if I try to paste on the same level or on a different level from source map.
The maps use the same MCD libraries.

The MCDs count for these maps exceeds the 255 limit, but all the MCDs in the copy-pasted area are not among the ones beyond that limit.

Let me know if you need more info.
« Last Edit: October 16, 2021, 12:11:08 pm by robin »

Offline robin

  • Commander
  • *****
  • Posts: 1135
  • ULTIMATE ROOKIE
    • View Profile
Re: MAPVIEW upgrade
« Reply #516 on: October 16, 2021, 12:09:32 pm »
double post sry.

Offline kevL

  • Colonel
  • ****
  • Posts: 374
  • pitchforks and torches
    • View Profile
Re: MAPVIEW upgrade
« Reply #517 on: October 16, 2021, 10:05:23 pm »
@robin I think i got it ... gimme a day or so to look it over.

@Nord I don't have TftD myself and so can't check the Maps... is there an error? or is it silent... what happens?

Offline Nord

  • Commander
  • *****
  • Posts: 1330
  • The Gate will open... someday.
    • View Profile
Re: MAPVIEW upgrade
« Reply #518 on: October 17, 2021, 06:07:54 pm »
@Nord I don't have TftD myself and so can't check the Maps... is there an error? or is it silent... what happens?
Here is error message:
Spoiler:
System.OverflowException: Array dimensions exceeded supported range.
   at XCom.SpriteCollection..ctor(String label, Palette pal, Int32 tabwordLength, Byte[] bytesPck, Byte[] bytesTab)
   at XCom.SpritesetsManager.LoadSpriteset(String label, String dir, Int32 tabwordLength, Palette pal, Boolean preserveStaticSpritesets)
   at XCom.Descriptor.CreateTerrain(Int32 id)
   at XCom.MapFileService.LoadDescriptor(Descriptor descriptor, Boolean& treechanged, Boolean browseMapfile, Boolean ignoreRecordsExceeded, RouteNodeCollection routes)
   at MapView.MainViewF.LoadSelectedDescriptor(Boolean browseMapfile, Boolean keepRoutes)
   at MapView.MainViewF.OnMapTreeAfterSelect(Object sender, TreeViewEventArgs e)
   at System.Windows.Forms.TreeView.OnAfterSelect(TreeViewEventArgs e)
   at System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv)
   at System.Windows.Forms.TreeView.WmNotify(Message& m)
   at System.Windows.Forms.TreeView.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Offline kevL

  • Colonel
  • ****
  • Posts: 374
  • pitchforks and torches
    • View Profile
Re: MAPVIEW upgrade
« Reply #519 on: October 18, 2021, 04:56:14 am »
Here is error message:
Spoiler:
System.OverflowException: Array dimensions exceeded supported range.
   at XCom.SpriteCollection..ctor(String label, Palette pal, Int32 tabwordLength, Byte[] bytesPck, Byte[] bytesTab)
   at XCom.SpritesetsManager.LoadSpriteset(String label, String dir, Int32 tabwordLength, Palette pal, Boolean preserveStaticSpritesets)
   at XCom.Descriptor.CreateTerrain(Int32 id)
   at XCom.MapFileService.LoadDescriptor(Descriptor descriptor, Boolean& treechanged, Boolean browseMapfile, Boolean ignoreRecordsExceeded, RouteNodeCollection routes)
   at MapView.MainViewF.LoadSelectedDescriptor(Boolean browseMapfile, Boolean keepRoutes)
   at MapView.MainViewF.OnMapTreeAfterSelect(Object sender, TreeViewEventArgs e)
   at System.Windows.Forms.TreeView.OnAfterSelect(TreeViewEventArgs e)
   at System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv)
   at System.Windows.Forms.TreeView.WmNotify(Message& m)
   at System.Windows.Forms.TreeView.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

@Nord you seem to be using an old version of MapView2. The functs in the stacktrace no longer exist in that form ...pls upgrade and try it again -- let me know if it still borks out,

Offline Nord

  • Commander
  • *****
  • Posts: 1330
  • The Gate will open... someday.
    • View Profile
Re: MAPVIEW upgrade
« Reply #520 on: October 18, 2021, 09:39:28 am »
@Nord you seem to be using an old version of MapView2. The functs in the stacktrace no longer exist in that form ...pls upgrade and try it again -- let me know if it still borks out,
Downloaded version fro 4 october. Still got this:
Spoiler:
System.OverflowException: Array dimensions exceeded supported range.
   at XCom.Spriteset..ctor(String label, Palette pal, Byte[] bytesPck, Byte[] bytesTab, Int32 spritewidth, Int32 spriteheight, Int32 tabwordLength, Boolean createToned)
   at XCom.SpritesetManager.CreateSpriteset(String label, String dir, Palette pal, Boolean createToned, Int32 spritewidth, Int32 spriteheight)
   at XCom.Descriptor.CreateTerrain(Int32 terid)
   at XCom.MapFileService.LoadDescriptor(Descriptor descriptor, Boolean& browseMapfile, Boolean ignoreRecordsExceeded, RouteNodes routes, TreeNode selected)
   at MapView.MainViewF.LoadSelectedDescriptor(Boolean browseMapfile, Boolean keepRoutes)
   at MapView.MainViewF.OnMapTreeAfterSelect(Object sender, TreeViewEventArgs e)
   at System.Windows.Forms.TreeView.OnAfterSelect(TreeViewEventArgs e)
   at System.Windows.Forms.TreeView.TvnSelected(NMTREEVIEW* nmtv)
   at System.Windows.Forms.TreeView.WmNotify(Message& m)
   at System.Windows.Forms.TreeView.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Offline kevL

  • Colonel
  • ****
  • Posts: 374
  • pitchforks and torches
    • View Profile
Re: MAPVIEW upgrade
« Reply #521 on: October 18, 2021, 08:10:28 pm »
vanilla tftd map of alien base level 1

hi Nord, could you link me to a MAP and the terrain files req'd to load

#----- Alien Base Level 1 -----------------------------------------------------#
  - type: ENTRY00
    terrains:
      - SAND
      - UEXT2
      - UEXT3
      - ORGANIC1
      - ENTRY

?

Offline kevL

  • Colonel
  • ****
  • Posts: 374
  • pitchforks and torches
    • View Profile
Re: MAPVIEW upgrade
« Reply #522 on: October 19, 2021, 06:16:20 am »
The release build of Mapview2 was well behaved on my machine, when loading Maps in the tftdSeascapes|Alien Base Level 1 category. I get this error:

Quote
In the MCD file ENTRY part #6 has an invalid death part (id #47 of 12 records).

in the debug build, however, this also gets thrown:

System.ArgumentNullException: Value cannot be null.
Parameter name: image
   at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
   at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
   at MapView.Forms.MainView.MainViewOverlay.DrawSprite(Image sprite, Rectangle rect) in c:\GIT\OpenXCOM.Tools\MapView\Forms\MainView\MainViewPanel\MainViewOverlay.cs:line 2031
   at MapView.Forms.MainView.MainViewOverlay.DrawTile(MapTile tile, Int32 x, Int32 y, Boolean toned) in c:\GIT\OpenXCOM.Tools\MapView\Forms\MainView\MainViewPanel\MainViewOverlay.cs:line 1975
   at MapView.Forms.MainView.MainViewOverlay.DrawRembrandt() in c:\GIT\OpenXCOM.Tools\MapView\Forms\MainView\MainViewPanel\MainViewOverlay.cs:line 1440
   at MapView.Forms.MainView.MainViewOverlay.OnPaint(PaintEventArgs e) in c:\GIT\OpenXCOM.Tools\MapView\Forms\MainView\MainViewPanel\MainViewOverlay.cs:line 1321
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

investigating further, found that Alien Base Level 2 does the same thing with the ORGANIC2 terrain, which is almost identical to the ENTRY terrain (but has 2 less tileparts).

Quote
In the MCD file ORGANIC2 part #6 has an invalid death part (id #47 of 10 records).

potential fix :
Open ENTRY.MCD in McdView (or MCDEdit) and change the deathtile of id #6 from 47 to 7. save ...
Open ORGANIC2.MCD in McdView (or MCDEdit) and change the deathtile of id #6 from 47 to 7. save ...

try it ...,
« Last Edit: October 19, 2021, 06:50:33 am by kevL »

Offline Nord

  • Commander
  • *****
  • Posts: 1330
  • The Gate will open... someday.
    • View Profile
Re: MAPVIEW upgrade
« Reply #523 on: October 19, 2021, 11:42:20 am »
I have open MCD's. And no, they are valid.
MCD part 6 have deathId 7 in ENTRY. ORGANIC2 is fine too.

Offline kevL

  • Colonel
  • ****
  • Posts: 374
  • pitchforks and torches
    • View Profile
Re: MAPVIEW upgrade
« Reply #524 on: October 19, 2021, 04:04:41 pm »
I have open MCD's. And no, they are valid.
MCD part 6 have deathId 7 in ENTRY. ORGANIC2 is fine too.

then pls send me the Map and terrain files for the tileset you are trying to load. The ones you sent me are different ... (and they load, btw).

@robin sry this is taking longer than expected

[edit]
@Nord

Quote
System.OverflowException: Array dimensions exceeded supported range.

at first i thought the error was the usual "index exceeds bounds of the array" but then looked into it ... it looks like, for whatever whacky reason, one or more of the terrains you're trying to load is causing c# to attempt to create an array with indices for > 65000 sprites
« Last Edit: October 20, 2021, 09:12:34 am by kevL »