Not logged inOpenClonk Forum
Up Topic Development / Scenario & Object Development / Interresting mistakes in some objects' DefCore.txt's Picture
- - By Gamer [de] Date 2013-02-28 17:37
Hello,

while I was programming on the part where my editor reads the coordinates from the Picture line from DefCore.txt, I found a few mistakes in some objects. Let me explain:

Let's take a look at the Dynamite.ocd object.
In its Defcore, it says:
Picture=16,0,64,64

The Graphics.4.png is:


That graphics file has width of 78 px and a height of 64 px.

My program reads in the coordinates of the start point. In this example:
Point startpoint = new Point(16,0);

And the width is taken from the last 2 numbers.
Size size = new Size(64,64);

It then createas a rectangle with the startpoint and the size.
Rectangle r = new Rectangle(startpoint,size);

When it tried to display the graphics, it just exited with a "not enough RAM" exception. This exception also appears when rectangle is out of the image's range.

As I said before, the width of the Graphics is 78.
The Startpoint is at x = 16 and the Width is 64. 16 + 64 = 80.
Since the Graphics.png has only a width of 78, it can't display the rectangle which is given by the Picture line in the DefCore.txt.
The graphic.png is 2 pixels too small.

This appears to be the case only in some objects, and for others it works. (E.g. Bread graphics cropping works fine,  Dynamites don't).

To show you that it really works, here is a before-after cropping picture.
Just Displaying the Graphics.png (in that Messagebox are the read coordinates for the picture)

After cropping according to read coordinates:
Parent - By Gamer [de] Date 2013-02-28 17:48
Also occurs in: Objects.ocd\Libraries\Animal.ocd
DefCore.txt: 0,0,64,64 , Graphics.png only 1 x 1 px big
Same for Objects.ocd\Libraries\ClonkControl.ocd
Flagpole.ocd's Defcore tells Engine to display a Picture with Heigth of 94, Graphics only 75 px high.
Parent - - By Sven2 [de] Date 2013-02-28 18:07
While the graphics you mention are probably just buggy, the ability to define facet rectangles outside the actual graphics is a useful feature if you plan to set external graphics using SetGraphics ingame. For example, a specialized rock definition might contain 1x1 pixel graphics and just set the rock graphics in its Initialize function.

In other words: Your frontend should better not crash on such graphics.
Parent - By Gamer [de] Date 2013-02-28 18:15
Right now it just displays the raw graphics file if it cannot display the cropped file. Well, atleast I've found some incorrectly set Picture lines.
Parent - By Newton [de] Date 2013-02-28 19:30
Additional to what Sven2 said: Cool that you found that! Care to supply a patch for the graphics that are definitely set wrong?
Up Topic Development / Scenario & Object Development / Interresting mistakes in some objects' DefCore.txt's Picture

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill