• entries
    503
  • comments
    1888
  • views
    333756

EEK!

Sign in to follow this  

233 views

So, last night while working on the lost region (which is becoming even more awesome, by the way.) I ran into a scripting issue.

In the past we've had some occasional 'phantom bugs' (The Phantom of the Script Code (where is ALW when you need him[grin])) in scripting, but most of them could be solved by realizing a syntax error in the code. Some, however, would not go away, and last night I had finally had enough of it.

I had a script, which was totaly syntax correct, but for some reason it would do this.


OnMouseClick()
{
LockPlayer(true);
if(some_condition1)
{
if(some_condition2)
{
if(some_condition3)
{
SomeFunction();
}
}
}<-returns from the function here
LockPlayer(false);
}<-instead of here



this was very disturbing, but now, that I found somthing I could easily reproduce, I decided that this was definetly a bug (not a syntax issue).

after stepping through the ScriptProcess executor code (omg, so horrible to watch code execute code lol), I realized a fatal flaw in the Queue Next Instruction code (which was used 9 times in the executor).

The bug basically said:

1.If I am jumping out of a branch, find my next sibling instruction.

2.If I dont have a next sibling instruction, go to my parent's next sibling instruction.


and that is where the logic ends.


now this works in the case of:

if()
{
if()
{
Func();<-instruction head
}
<-next sibling(nothing)
}
Func(); <-parent's next sibling(function)


however when you have this:


if()
{
if()
{
if()
{
Func();<-instruction head
}
<-next sibling(nothing)
}
<-parent's next sibling(nothing)
}
Func(); <-parent's parent's next sibling(function)


it only looks backwards up to the parent's next sibling, which can potentially be nothing.

In this case, the queue next instruction code returns a null instruction, which signals the executor that we are done, so it returns before finishing the rest of the exection, in short.

NOT GOOD!

So, since this large(20 lines) block of code was duplicated 9 times in the executor, i made it into a function.

To both reduce code size and code redundancy(and thus variations(bugs) between the duplicates)
(see, post optomization is very plesant =D),

And then I modified it so that it would cascade backwards until it finds either:

1.the next sibling to execute: execute it.
2.the end of the root function: return.

This solved the problem, and now all is good in script land. =D

Hopefuly there are no others lurking about =)

Chances are there arnt, since the scripting engine has been used a lot, under many different pieces of code, so it is hard to belive another such bug exists. Then again, we were able to use the scripting engine for near on a year (albeit noticing bugs) without having and serious crash. So, who knows =D
Sign in to follow this  


4 Comments


Recommended Comments

There once was a pesant miner, Garran Leowyn, who lived in the eastern lands.

He, like all of his people were under oppression from a cruel diety.

He made up his mind to flee the eastern lands, and escape tyrany.

He gathered his followers and, in secret, the built a ship.

In the early morning they all set sail on the ship.

The diety realized this, and sent great storms to topple thier ship.

Through luck and skill they survived the storms.

The diety in his wroth sent a cataclysmic blizzard which froze the eastern lands, wiping out all remaining life.

The fleeing band of pesants followed a bright glowing star in the sky, and soon came upon land.

They journeyed through this land westward, until they came upon grassy plains with rolling hills and mountains.

They made thier homes next to a large mountain.

The established a monarchy, crowning the pesant miner as king, and they became, The Leowyn Kingdom.

While building thier castle they discovered an underground land, filled with bones of the dead and strange devices.

They discovered a well in this land, a well filled with a glowing blue liquid, which evaporated easily in air.

This liquid, they named, Mana, and found that it could empower a being with special abilities.

Soon after this discovery, word traveled west, and was heard by a country of warriors, The Ashidians.

Thier land was in a region known as the fire-fields, where underground magma would creep up and set things aflame.

The Ashidians, hearing of the discovery of yet another mana well, sought to take it for thier own.

The Ashidians launched an assault Leowyns, atempting to take thier castle, Iridine.

The Leowyns had become skilled in magic, and fought the Ashidians.

The Leowyns eventually beat off the Ashidian attack, and after packing hundreds of thousands of bottles of mana, they marched west to counter-attack.

The Ashidians could not withstand this new foe, so greatly equiped and vengeful.

The Ashidians were conquored, all either dead or scattered.

The Leowyn army returned home, to enjoy the peace of post war.

It was discovered that the mana which was taken from the leowyn well, was Tainted Mana.

It was belived that the mana spring had flowed into an area of lead deposits.

Many Leowyns subsequently died from mana poisioning on the journey home.

Those who survived, suffered from madness, ususaly resulting in suicide or death.

It was now clear why the underground city was filled with bones.

Soon after, driven by madness from mana poisoning, cast himself into the mana well and was disolved.

They sealed off the underground entrance to the well and the Lost Region.

And for hundreds of years it has remained sealed.

The Leowyn people, devoid of an enemy soon slipped into relaxation, and forgot the ways of magic and war.

But the Ashidian decendants, scattered in the surrounding mountains, did not forget, and the time is now drawing near to the time when the Ashidians will attempt thier revenge!

-Condensed version of: The Morning's Wrath Backstory =)
By Raymond Jacobs and Zac Todd

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now