Cool Pog Tricks

More
21 years 6 months ago #3217 by Flamineo
Replied by Flamineo on topic Cool Pog Tricks
Aye, I've been playing with packages I hadn't looked at much. The Lock package seemed a good way of generating locks unique to a passed in handle without resorting to atomic{}. Since the Lock.Find() workaround has to use atomic{} anyway, globals would, indeed, serve just as well, with probably less overhead.

Please Log in or Create an account to join the conversation.

More
21 years 6 months ago #3235 by Stephen Robertson PS
We never used the lock system, so I don't believe it's been fully tested.

-- Steve
Stephen Robertson
Particle Systems
Independence War Website

-- Steve
Stephen Robertson
I-War series co-designer.

Please Log in or Create an account to join the conversation.

More
21 years 6 months ago #3279 by Flamineo
Replied by Flamineo on topic Cool Pog Tricks

originally posted by Stephen Robertson
We never used the lock system, so I don't believe it's been fully tested.

Thanks: I'll try to stay away from it in future.

Just remembered another nugget of peculiarity that may as well go on the list:

The Stream package doesn't work with sound resource files inside zip archives. To use Stream.Play() for audio playback, you need to unzip the sound files directly into the ./resource tree. This applies to the sounds in resource.zip, as well as any you're adding.

[edit]
Found some new GUI voodoo: not sure how generally useful this is, but it's taken me forever to come up with, so it might save someone some time.

You can persuade multiple windows to operate as a single window for focus purposes by making them all children of a single GUI.CreateWindow() that's set to accept focus, and setting the children not to accept focus -- this is pretty obvious. The drawback is that GUI.CreateWindow() objects don't (?) accept input override functions, so you can't assign an on-click event to the resulting composite window. You can't make the grouper window a GUI.CreateButton() because, as far as I can tell, buttons won't accept children. You can overcome this by making the grouper window a lone entry in an invisible list box with all its normal listbox-y features disabled, then using the list box's on-select event as your on-click function:
Code:
// Holder for composite window grouper = GUI.CreateWindow(x, y, w, h, none); // First detail sub-window detail1 = GUI.CreateStaticWindow(x, y, w, h, grouper); // (...text/texture options for detail1...) // Second detail sub-window detail2 = GUI.CreateStaticWindow(x, y, w, h, grouper); // (...text/texture options for detail2...) // (...additional detail windows...) // Listbox to provide on-click event for grouper window box = GUI.CreateListBox(x, y, w, h, parent, false, false); GUI.DisableHighlight(box); GUI.SetListBoxSelectFunction(box, "package.OnCompositeClick"); GUI.AddListBoxEntry(box, grouper);
That's an awful lot of windows to do not much, but it works; if anyone can see a cleaner approach, I'd love to know about it.
[/edit]

[edit]
Another Sunday, another strange and unnatural pog behaviour identified.

I haven't tested to establish that this is always the case, but I've just traced some extremely odd behaviour to the fact a deleted window doesn't seem to behave as a normal bad handle (although Debug.PrintHandle() still claims it is one).

On a window that'd been destroyed by GUI.DeleteWindow() on an ancestor, 'window == none', '!window', and 'window == GUI.Cast(none)' all returned false. Simplest workaround I could see in this particular case was to test 'GUI.WindowCanvasWidth(window) == 0' instead, which should work as long as you know it can't be true while the window remains current.
[/edit]

[edit]
<sigh> And another one. It appears that INIFile block names can't contain spaces. That probably should have been obvious, but it really wasn't until I realised what was breaking my stuff.
[/edit]

Please Log in or Create an account to join the conversation.

More
21 years 4 months ago #4165 by GrandpaTrout
Replied by GrandpaTrout on topic Cool Pog Tricks
While working on adding cargo pod save/restore to iFleet I finally tracked down how cargo pods work. Many thanks to Flamineo for advice on finding object properties.

Pods have an integer "cargo" property that holds the current cargo type integer.

Pod names are the string name for the cargo type. For instance "Fruit" is the name of type CT_Fruit, value 10.

Pods have an integer "cargo_faction" property that is the ieAllegiance value of the cargo. This is used to display the Shipper.

-Gtrout

Please Log in or Create an account to join the conversation.

More
21 years 1 week ago #6056 by GrandpaTrout
Replied by GrandpaTrout on topic Cool Pog Tricks
A bit of performance measurement:

10,000 waypoint sims were created in 0.15 seconds. So fast it is hard to believe. I ran the test many times. Creation is done in atomic loop. I did not place the sims into the world, just create them.

I can only believe that the sims are being pulled from a pool. Memory allocation should not be this fast. This is so fast, it is not worth building buffer pools. The sim creation is faster than the global access.

-Gtrout

Please Log in or Create an account to join the conversation.

More
21 years 1 week ago #6057 by Shane
Replied by Shane on topic Cool Pog Tricks

I can only believe that the sims are being pulled from a pool. Memory allocation should not be this fast. This is so fast, it is not worth building buffer pools. The sim creation is faster than the global access.

Strange. So, when using the Sandbox, that pause you get when creating a ship is the placement of the sim, and not the creation of the sim? I wonder why it takes so much time to place a sim in the world?

No confusion; just wrong or right ... Only Solutions

Please Log in or Create an account to join the conversation.