Page 1 of 1

Moving objects

Posted: Mon Apr 06, 2009 8:57 pm
by Donfrow
Just curious if UI_move_object/obj->move_obect([pos]) is currently working as intended as I cannot seem to get it to work anymore. An example of the code is such,

Move_Test()
{
UI_move_object(241, [1731, 1894]);
}

which appears to do nothing.

I noticed that there was a change to UI_move_object on Feb 28, but I have no idea what Freedom is or if that change would have affected this.

If it isn't something on my end I will submit a bug.

Re: Moving objects

Posted: Mon Apr 06, 2009 9:14 pm
by marzo
241 is supposed to be an NPC, I take it? If so, it should be a negative number (-241) instead as Exult no longer tries to convert positive numbers to NPCs in any instances -- the originals demonstrably did not do this, and doing so causes problems due to SI's buggy usecode.

Re: Moving objects

Posted: Mon Apr 06, 2009 9:33 pm
by Donfrow
Yes, NPC number.

That did the trick. Now to make a whole bunch of negative NPC numbers in scripts and movements!

Thanks, yet again.

Re: Moving objects

Posted: Mon Apr 06, 2009 9:47 pm
by Donfrow
One more thing... does that mean for things like UI_clear_item_flag(obj, flag) if I am clearing an NPC flag it must be negative as well?

Re: Moving objects

Posted: Mon Apr 06, 2009 10:28 pm
by marzo
For all intrinsics and scripts everywhere, only numbers that need to be treated as an NPC must be negative; in the terms of the intrinsic documentation, that would be any 'object' or 'actor' parameter. Everything else is unaffected, and can be positive or negative as needed.

Re: Moving objects

Posted: Mon Apr 06, 2009 10:32 pm
by Donfrow
Well lots of work ahead of me then in fixing the disaster that is my code! Thanks again.

Re: Moving objects

Posted: Mon Apr 06, 2009 10:39 pm
by marzo
I seem to remember strongly suggesting in the past the use of negative numbers when you asked about it; but maybe that is my memory playing tricks. And anyways, I don't want to dig around dozens of threads just to confirm (or refute) that memory...

Re: Moving objects

Posted: Mon Apr 06, 2009 11:07 pm
by Donfrow
It is not a memory trick, you are correct that you mentioned that to me in the past.

I never went back and fixed any of the ones I had completed previously as I had a lot of them like that and they worked at the time. It seems I was delaying the inevitable though.

I think I will finally get around to another piece of advice you had given me and final update my ucc.exe since I am going through a bunch of the code anyway.

When ucc gives the warning "You should prepend 'void' for functions that do not return a value" does that just mean functions such as:

Example object#()() and Example2()

would simply become

void Example object#()() and void Example()

I see that gets rid of the error message but I'm hoping that if I go through and do all that it won't cause issues later on.

Re: Moving objects

Posted: Mon Apr 06, 2009 11:24 pm
by marzo
Re: void: Yes, that is it. The idea comes from C/C++, with 'void' meaning 'has no return'. It has the advantages of making this fact explicit and of maintaining notational consistency. There is the added bonus that 'the Void' is an integral part of Ultima :-)

Re: Moving objects

Posted: Tue Apr 07, 2009 6:39 pm
by Donfrow
That would not include a function where a static variable is updated/set would it? I tend to use those a few times for various reasons.

Re: Moving objects

Posted: Tue Apr 07, 2009 7:07 pm
by marzo
A function has a return only if, somewhere, it uses 'return X;', where X is any variable or expression. If the function never has such a statement, or if it has a simple 'return;', then it is a 'void' function. It has nothing at all to do with static variables or anything of the sort.