RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Paperdoll Generator using PHP (MyRunUO)

Kinetix

Wanderer
Paperdoll Generator using PHP (MyRunUO)

Hi, well... I have searched these forums thoroughly, and have checked out anything regarding MyRunUO. I have been unable to find any posts with any ideas on how to generate a hued paperdoll in PHP.

Any sites I have found in PHP who have a paperdoll generator, have been reluctant to release their code for it. :(

The closest I got to creating a paperdoll generator in PHP was writing code to read the hues.mul and get the 32bit RGB colors. I took a shot at reading the gumps, but had no success, it was a bit too complicated - seeing as how they had variable length, I just couldn't seem to get the correct properties from the IDX and get it from the MUL.

This whole problem is because my webserver is Linux-based, and therefore I cannot use ASP - let alone ASP.NET - pages on it. As I cannot use ASP, I cannot use the ultima.dll, since PHP cannot load it.

So I am here to ask if anyone has a paperdoll generator for PHP, and would like to release the code for it. I would greatly appreciate it, thanks for your time.
 

punt59

Wanderer
Kinetix said:
This whole problem is because my webserver is Linux-based, and therefore I cannot use ASP - let alone ASP.NET - pages on it. As I cannot use ASP, I cannot use the ultima.dll, since PHP cannot load it.

So I am here to ask if anyone has a paperdoll generator for PHP, and would like to release the code for it. I would greatly appreciate it, thanks for your time.

Can you use C/C++ to get the gumps images back? Or do you require php process the mul files natively? If you just want a library that works on linux as well as windows to access the mul files, you may want to look at the valley library, located at http://www.sf.net/projects/worldmaker .
 

Kinetix

Wanderer
If it were in C/C++, it'd have to be a linux executable which I could pass parameters to, and it would create the images I require.

As of now, I'm just linking off-site to riven.ru's paperdoll gump generator. But the problem with this is that they only have their own hues, not mine. So the site generates hundreds of black gumps, as they do not have the same hues.

It has also come to my attention that you can load DLLs in Java. Anyone have insight to this?
 

punt59

Wanderer
Kinetix said:
If it were in C/C++, it'd have to be a linux executable which I could pass parameters to, and it would create the images I require.

As of now, I'm just linking off-site to riven.ru's paperdoll gump generator. But the problem with this is that they only have their own hues, not mine. So the site generates hundreds of black gumps, as they do not have the same hues.

It has also come to my attention that you can load DLLs in Java. Anyone have insight to this?

So I must not understand your question. There is a c++ library to get back image data, which workds under windows and linux. Are you asking now for an executable to be made as well? Your original complaint was with ultima being a dll, and not being usable under linux. I am saying there are other libraries that don't require windows. Even if you could have used ultima, you would have had to write a program to use it.

So I am confused.
 

Phantom

Knight
So you know

Mono as support for ASP

So there is an alternative, you can use mono/asp on linux.

And Ultima.dll should have no problems with Mono, or at least worth a try.
 

punt59

Wanderer
How could ultima work under mono?

Phantom said:
So you know

Mono as support for ASP

So there is an alternative, you can use mono/asp on linux.

And Ultima.dll should have no problems with Mono, or at least worth a try.

Unless mono maped the Bitmap class used by the ultima.dll to GTK+, then I don't understand how it would work (ultima.dll uses directx, which I don't think mono is doing).

Even then, he would have to write a program to use the dll. The issue isnt having available libraires to read the gumps on linux, there are. What isn't clear, is he expecting to have to write a wrapper program to translate it tosome image format, or is he expecting to do that in php ? It sitll isn't clear he he plans on manipulating the mul files from php.
 

Iridath

Wanderer
what i did is letting the runuo server create the images (you can use nearly the same code from the aspx file)

then my php code uses these generated graphics.
 

zebany

Wanderer
Do what OSI does.. A paperdoll background image and html layers for all item layers. You can download all images of all items from OSI's my.uo.com pages...
(Or maybe just create a script which connects to OSI's website, downloads an image and cache it to your website. So u can use it from your webspace in future if needed again..)
 

Arya

Wanderer
Ultima.dll doesn't use DirectX. Also Krrios released the source for Ultima.dll so you could ultimately recode the parts on your Linux machine. As far as Ultima.dll on Mono, Ultima uses the _lread function which is a native windows API and therefore incompatible with Mono. I remeber that Ultima.dll uses _lread for the tile matrix, and if it uses it for gumps/hues as well you're out of luck. It might be worth a try though.
 
Arya said:
I remeber that Ultima.dll uses _lread for the tile matrix, and if it uses it for gumps/hues as well you're out of luck. It might be worth a try though.
That's not what I saw. It uses streams so it should be fine, barring problems with Mono.
 

Bradley

Sorceror
Ignacio Vazquez-Abrams said:
That's not what I saw. It uses streams so it should be fine, barring problems with Mono.

snipped from TileMatrixPatch.cs in Ultima.dll
Code:
namespace Ultima
{
	public class TileMatrixPatch
	{
		private int m_LandBlocks, m_StaticBlocks;

		[System.Runtime.InteropServices.DllImport( "Kernel32" )]
		private unsafe static extern int _lread( IntPtr hFile, void *lpBuffer, int wBytes );

It's bring in some windows specific functions from the windows kernel. MONO *minght* be able to pass this off to somethign like Wine, but i doubt it. There are also several kernel32 calls in Processstream. These would all have to be translated to something that MONO could handle.

There are actually quite a few windows specific API calls being made in ultima.dll. Most of them are for dealing with the client however, and could probably easily be stripped form the source code. Art and Gump Code doesn't seem to contain anythign windows specific, so that stuff should eb fine in MONO.
 

xir

Wanderer
Why must one cling to the Ultima.DLL even when it adds unnecessary complications? Punt's library has a similiar interface and would be much better in this situation. All you need is his valley library and a library such as libjpeg/libpng (there are many more) to convert the parsed mul data to an image format. E.g. http://www.libpng.org You could then execute the binary from the php code to create the image (communicating by passing arguments to the executable). The native binary would be much more efficient/stable than what you can piece together with the DLL and the overhead of Mono. Even if you do decide to use the Ultima.DLL I think this is the only way you can approach it.

If this doesn't suit your needs, you could even create a php wrapper for the extraction of gump data with his library and use the php image functions to create/output the image, as php already has interfaces for the necessary image libraries - http://ie.php.net/gd . This technique would be more efficient in my opinion and I doubt you could do this with the DLL without adding yet another layer of code on top of mono to interface with the module components of php.
http://www.zend.com/apidoc/zend.creating.php documents how to make a module in php.

All this is well and good if you are trying to avoid messing with the mul files yourself, but both techniques require more than is needed than to actually just learn how to parse the gump mul file in the first place with php, which would be the best option. So just dig up the mul documentation, look at a few source examples from different libraries and get coding it in php :)


Of course the easiest option as I see it for your situation is just to load the parsed image data into a large database and extract as necessary as many times as you like. This would remove the overhead of converting mul format to image format (since its only done once and then stored.) The database size would probably be comparable to the mul size anyway, so you aren't actually using up any more space. With php's database and image extensions, it should be a doddle then to load an image and apply a hue.

They are my suggestions. Sorry for being so verbose, I do tend to get carried away. Anyway, good luck if you plan to give it a go and let us know what you come up with.
 

Bradley

Sorceror
xir said:
Why must one cling to the Ultima.DLL even when it adds unnecessary complications?

Cause it's written in .NET and doesn't have the overhead of calling into non-managed code.
 

xir

Wanderer
Cause it's written in .NET and doesn't have the overhead of calling into non-managed code.

The "unnecessary complications" I was referring to was in regard to the hassle of getting the DLL to work under mono in Unix when a native library exists that can do the exact job and better under the circumstances available. It's a matter of looking at what is available and using what is best suited for the task at hand. I don't see the need to get something working on an incomplete framework just because you need to run unoptimised managed code. Of course if you feel you must then by all means do so, I am merely offering suggestions on an alternate approach to the problem. :p
 

Arya

Wanderer
Ignacio Vazquez-Abrams said:
Okay, I stand corrected. But the 2 calls to _lread() could easily be changed into stream read calls. In fact, I don't know why _lread() is used there at all.

The _lread calls are there for performance reasons. This is my guess, but when I was writing the MapViewer control I encountered serious perfomance issues when using .NET streams to read large amount of data (such as the map/statics combo). The only way to make it faster has been to use the ReadFile WinAPI function (which I guess eventually uses _lread). Of course if performance isn't an issue for your application, relatively speaking, you can do just fine with .NET IO.
 

punt59

Wanderer
What is the Bitmap then?

Bradley said:
Are you sure about that? I don't remember seeing any references to it in the source code.


Ok, perhaps I should have said windows. But art returns things in a Bitmap class, and this isn't C++. That is windows is it not? (showing my ignorance of windows here). I suppose it could have been converted, but my read of mono as them avoiding any windows display stuff.
 
Top