Compiling FlaME under mono

Get some help with creating maps or modding.
Need a map editor or other tools, look here!
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Compiling FlaME under mono

Post by NoQ »

Anyway, here is source/binary that seems to work well for me (hence the filename). Just removed all transparencies from water transition tiles with an imagemagick script; still, there are more graphical glitches around, but they're not critical at all.

To be run like this:

Code: Select all

mono flaME.exe
User avatar
Flail13
Code contributor
Code contributor
Posts: 263
Joined: 16 May 2008, 12:00

Re: Compiling FlaME under mono

Post by Flail13 »

I haven't tried your changes yet, but here is what I was about to post:

Here is patch to fix that. It replaces clsTileset.LoadDirectory

That's a bug I hadn't bothered to fix yet. It was caused by what I had to do to get around the "convert to IntPtr" issue. I hadn't thought of a way to remove the alpha channel yet.

macuser seemed to not like the idea of using Mono. Any idea why that was?

Is MonoDevelop supposed to have context menus to complete what you type? I've tried shift+ctrl+return but gives an error message.

edit: what did the script do?
and you should be able to uncomment: (in frmMain.Initialize)

Code: Select all

'If My.Application.CommandLineArgs.Count >= 1 Then

        '    Dim Path As String = My.Application.CommandLineArgs(0)

        '    Result = Load_Map(Path)

        '    If Not Result.Success Then

        '        MsgBox("Failed to open the command-line map file at " & Path & ". Reason; " & Result.Problem)

        '    End If

        'End If
- that's if Linux passes command line arguments in the same way
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Compiling FlaME under mono

Post by NoQ »

Flail13 wrote:edit: what did the script do?

Code: Select all

#!/bin/bash
type=`echo $1 | sed s#/#' '#g | awk '{print $2}'`
name=`echo $1 | sed s#/#' '#g | awk '{print $3}'`
composite $type/$name $type/tile-17.png ~/tmp.png
mv ~/tmp.png $type/$name
(run like that:

Code: Select all

~/flaME/bin/Debug/tilesets/tertilesc1hw$ find -iname *.png -exec sh s.sh {} \;
~/flaME/bin/Debug/tilesets/tertilesc2hw$ find -iname *.png -exec sh s.sh {} \;
~/flaME/bin/Debug/tilesets/tertilesc3hw$ find -iname *.png -exec sh s.sh {} \;
where s.sh is the script) (so it replaces all transparency with actual water)
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Compiling FlaME under mono

Post by NoQ »

Flail13 wrote:and you should be able to uncomment: (in frmMain.Initialize)
After uncommenting this, loading maps as command line arguments works well.
User avatar
Flail13
Code contributor
Code contributor
Posts: 263
Joined: 16 May 2008, 12:00

Re: Compiling FlaME under mono

Post by Flail13 »

That patch also fixed a bug where RGB(Red, Green, Blue) should be RGB(Blue, Green, Red) in every RGB() in the clsTileset.LoadDirectory(). So if you don't replace it, you need to change them manually. It was causing the terrain to be badly coloured when viewing from a distance.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Compiling FlaME under mono

Post by NoQ »

Update: the patch doesn't work for me. After replacing this function, and replacing all backslashes, i get a crash:

Code: Select all

Unhandled Exception: System.InvalidOperationException: SetPixel cannot be called on indexed bitmaps.
  at System.Drawing.Bitmap.SetPixel (Int32 x, Int32 y, Color color) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:SetPixel (int,int,System.Drawing.Color)
  at flaME.clsTileset.LoadDirectory (System.String Path) [0x00000] in <filename unknown>:0 
  at flaME.frmMain.LoadTilesets () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) flaME.frmMain:LoadTilesets ()
  at flaME.frmMain.Initialize (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Timer.OnTick (System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Timer.FireTick () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Timer:FireTick ()
  at System.Windows.Forms.XplatUIX11.CheckTimers (System.Collections.ArrayList timers, DateTime now) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11.UpdateMessageQueue (System.Windows.Forms.XEventQueue queue, Boolean allowIdle) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11.UpdateMessageQueue (System.Windows.Forms.XEventQueue queue) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11.GetMessage (System.Object queue_id, System.Windows.Forms.MSG& msg, IntPtr handle, Int32 wFilterMin, Int32 wFilterMax) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUI.GetMessage (System.Object queue_id, System.Windows.Forms.MSG& msg, IntPtr hWnd, Int32 wFilterMin, Int32 wFilterMax) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Application.RunLoop (Boolean Modal, System.Windows.Forms.ApplicationContext context) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Application.Run (System.Windows.Forms.ApplicationContext context) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Application.Run (System.Windows.Forms.Form mainForm) [0x00000] in <filename unknown>:0 
  at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun () [0x00000] in <filename unknown>:0 
  at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run (System.String[] commandLine) [0x00000] in <filename unknown>:0 
  at flaME.My.MyApplication.Main (System.String[] Args) [0x00000] in <filename unknown>:0 
It was causing the terrain to be badly coloured when viewing from a distance.
That's exactly what i was talking about!
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Compiling FlaME under mono

Post by NoQ »

That patch also fixed a bug where RGB(Red, Green, Blue) should be RGB(Blue, Green, Red) in every RGB() in the clsTileset.LoadDirectory().
This replacement, together with repainting the tiles, removes all terrain glitches so far (:
>>> Updated version <<<
Last edited by NoQ on 05 Apr 2011, 12:12, edited 2 times in total.
User avatar
Flail13
Code contributor
Code contributor
Posts: 263
Joined: 16 May 2008, 12:00

Re: Compiling FlaME under mono

Post by Flail13 »

that crash is because the script has changed some of the images to "indexed colour". there's two ways to fix it. change the images back to the originals, or remove the patch and just change the RGBs manually. If you cant remove the patch, remove the entire loops that contain "SetPixel", except the first one, in which you just remove:

Code: Select all

If PixelColor.A < 255 Then
    tmpBitmap.CurrentBitmap.setpixel(pixx,pixy,colortranslator.fromole(rgb(128,64,16)))
End If
edit: and dont remove the last few setpixel loops that don't check for alpha
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: Compiling FlaME under mono

Post by NoQ »

Ok, anyway, having updated RGBs manually, i'm satisfied so far! (:
User avatar
Flail13
Code contributor
Code contributor
Posts: 263
Joined: 16 May 2008, 12:00

Re: Compiling FlaME under mono

Post by Flail13 »

I found one more error... in ctrlMapView.Apply_Texture, the six references to AutoCliffBrushRadius need to be changed to TextureBrushRadius.

edit:
I'm making changes to your updated code. I've replaced all the path slashes with variables, so it works on windows and should still work on linux. I'll send you the code again if you want to make some changes.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Compiling FlaME under mono

Post by Per »

Can I recommend putting the sources in a version control system? It will make such collaborative work so much easier.
User avatar
Flail13
Code contributor
Code contributor
Posts: 263
Joined: 16 May 2008, 12:00

Re: Compiling FlaME under mono

Post by Flail13 »

Per wrote:Can I recommend putting the sources in a version control system? It will make such collaborative work so much easier.
I'm open to that idea. Are you suggesting to put it on this site, or hosted elsewhere?
cybersphinx
Inactive
Inactive
Posts: 1695
Joined: 01 Sep 2006, 19:17

Re: Compiling FlaME under mono

Post by cybersphinx »

We don't really host source code here, but use https://github.com/ instead. Alternatives are http://gitorious.org/ (both using git, obviously), https://bitbucket.org/ (Mercurial), http://code.google.com/hosting/ (Mercurial and SVN). Personally, I wouldn't use SVN anymore, or a site without a "fork project" button (like Sourceforge, Gna or Berlios).
User avatar
Flail13
Code contributor
Code contributor
Posts: 263
Joined: 16 May 2008, 12:00

Re: Compiling FlaME under mono

Post by Flail13 »

Here is my updated code. A lot of the details are working better.
NoQ, does this still work on linux?
What's needed to get it working on Mac as well?
User avatar
macuser
Regular
Regular
Posts: 1052
Joined: 19 Mar 2010, 23:35
Location: USA

Re: Compiling FlaME under mono

Post by macuser »

If it works on linux it will work on mac
ArtRev Website

ImageImage

System: AMD Phenom II x4, 4GB RAM, 640GB HD, Nvidia GeForce GT 240 1GB, Mac OS X 10.6