View Full Version: World 'include' Support

DimensioneX Forum > Game Engine Development > World 'include' Support



Title: World 'include' Support
Description: Utils.fetch() Include support


sascanagl - March 3, 2008 02:21 PM (GMT)
As a game developer I want to be able to manage my World definition in smaller, easier to edit chunks. I see that SCRIPTS (by virtue of the Small Basic processor?) allows us to use Includes, but the rest of the World file does not seem to support them.

I've added support to Utils.fetch() to support Include statements for local files. I believe my review of the source shows that the support of HTTP definitions will be identical so I will be refactoring that and possibly pushing it on Tuesday.

However, the code is currently a little more complicated than I care for and I wanted to find out if it is unnecessarily so.

Since I don't know what kind of processing the scripting engine does with Includes, my Utils.fetch() code ignores and does not process Includes inside SCRIPTS or EVENTS tags. It just copies the Include statement to the StringBuffer as the code has always done. This mean the new fetch code has to keep track of the start and stop of SCRIPTS and EVENTS sections of the World file.

So I'm asking:

Is there any special processing of Includes done by the scripts engine?
Would it be safe to also process the Includes in the SCRIPTS during the DXW fetch which brings that content into the World definition file?
Or should I leave SCRIPTS Includes "as-is" for later processing?

Regards,

Carl Nagle

sascanagl - March 4, 2008 05:36 AM (GMT)
OK. A debug session shows me this Utils.fetch was used for much more than just World loading. Scripts and Message files come through here too. So, I added a fetchIncludes instead and invoke that from the WorldLoader while all other fetch() callers use the original function.

I have pushed the mods to Utils and WorldLoader. I tested it using Files and http URLs.

Sample usage:

WORLD
NAME TestLand
IMAGESFOLDER /dimx/image/
AUTHOR Carl Nagle

' **** The quotes in Include are required

Include "Testland_Rooms.dxl"
Include "Testland_Links.dxl"
Include "Testland_Items.dxl"

CHARACTERS

etc...
more Includes anywhere EXCEPT 'inside' SCRIPTS and EVENTS sections.
etc...

Carl Nagle

Cris - March 4, 2008 10:44 AM (GMT)
Hi Carl, welcome on this forum.

I'm replying perhaps a little bit late but I hope it can be of some help.

- As you correctly guessed, Utils.fetch is used to fetch some content from the web and it's being used for several things such as skins.

- One thing I wanted to do was to use Includes on the GUI section of the worlds, because in multi-area projects such as Underworld there's a common GUI part (shared commands) that you need to share across the whole project.

- Problem is, the fetch routine gets some content but was designed to fetch a full block of homogeneous code capable of being parsed independently. example: block of SmallBasic code, SKin code, PAGE code, etc. If I use it to get a portion of the GUI section I would need to change the parser.


So:

>Is there any special processing of Includes done by the scripts engine?
yes usually the block is assumed to be parsable from starting to end, i.e. the engine does not do a block-expand with the fecthed content (perhaps it should)

>Would it be safe to also process the Includes in the SCRIPTS during the DXW fetch which brings that content into the World definition file?
The best approach would be to change the game engine and make a block expansion that is, i fetch the includes, make a big stringbuffer and the parse the whole.
there may be the drawbacks though, otherwise i would have done it from start, but I'm sure you will discover

>Or should I leave SCRIPTS Includes "as-is" for later processing?
Well I think this modification is not trivial and it is hard to start from this one.
Perhaps I would leave it for later, and start getting confidence with the code by editing something else



By the way, I've included you in the developers on the sourceforge project.
You probably can now use CVS also to release.

If your changes affect compatibility with old code it would be a good idea also to create a new module e.g. dimx_7 so that the two branches can live side by side until the devlopers have done the porting to the new branch.

Unfortunately the few game projects I have showcased on the site are mostly closed and I don't think the developers want to get into code adjustments again, so I'm afraid to lose their games...

what do you think?

sascanagl - March 4, 2008 01:00 PM (GMT)
Cris,

My motto on development, especially with open source code, is that it must always be backward compatible. Thus, any code I submit should be compatible with existing games. No changes required by existing users or game developers. Just new optional capabilities.

The addition of Utils.fetchIncludes simply allows a game developer to optionally use Includes. It does not require it. So existing World files will work unmodified. Currently only the WorldLoader calls this function to load the World definition. None of the Script, Skin, or other Client loaders call the new function. The idea here was to avoid any unintentional backward compatibility issues.

The parsers do not have to be modified because the Includes are already done during the load. The parsers will still just see one big full block of homogenous code to be parsed independently.

This enhancement sounds like it has solved your shared GUI problem. You can maintain separate GUI sections, or even portions of GUI sections, and Include them in multiple different World definition files.

Carl Nagle




Hosted for free by InvisionFree