It is currently Thu Nov 20, 2008 3:02 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 17 posts ] 
Author Message
 Post subject: Bug in function parameter when using syntax Struct { "m
PostPosted: Sat Apr 21, 2007 2:39 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
Bug in function parameter when using syntax
Struct { "member_name" := member_value }

I have discovered that if I use a function like
npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, 0);
the parameter loc.x is passed as integer value, but if I use syntax:
npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, Struct { "facing" := who.facing });
then instead of member x of loc (loc.x) is passed as second parameter the entire struct "loc"....

This is 100% sure a little core bug in parameter function.
The syntax Struct { "member" := value }
should not be used calling functions?

_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 4:16 am 
Offline
POL Developer
User avatar

Joined: Sun Feb 12, 2006 9:50 pm
Posts: 836
Location: Indiana, USA
that struct is formed incorrectly. Read core-changes.txt on how to correctly build/create a struct.

_________________
POL Developer - The Penguin Scripter


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 5:58 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
In core changes I have found syntax like:

Code:
      var t := struct { a, b, c };                                  // basic
      var t := struct { a := 4, b := "hey", m := foo(bar(4)) };     // initialized
      var t := struct { a := 4, b := struct { g,h,i }, c };         // with nested structures

_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 6:14 am 
Offline
POL Developer
User avatar

Joined: Sun Feb 12, 2006 9:50 pm
Posts: 836
Location: Indiana, USA
ok, but do me a favor, try building the struct before the function call, and see if that makes a difference with your two bugs. That gives me something to work with a bit more too (I suck at dealing with the ECompile errors, just so you know in advance, hehe).

_________________
POL Developer - The Penguin Scripter


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 6:18 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
Ah yes... sorry.
If I declare the struct outside the function call, it i ok.
If I use:
Code:
var tmp := Struct { "facing" := who.facing };
npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, tmp);

I have no problem.

I think this bug is also on pol096.
Thje problem is only when you declare the struct and define function parameter at the same time.

_________________
Zandor


Top
 Profile  
 
 Post subject: List file
PostPosted: Sat Apr 21, 2007 6:31 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
Code:
      print("trasmitted x="+loc.x+" y="+loc.y+" z="+loc.z); //DEBUG
      npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, Struct { "facing" := who.facing });


in .lst file:
Code:
print("trasmitted x="+loc.x+" y="+loc.y+" z="+loc.z); //DEBUG
166: "trasmitted x="
167: local #4
168: get member id 'x' (0)
169: +
170: " y="
171: +
172: local #4
173: get member id 'y' (1)
174: +
175: " z="
176: +
177: local #4
178: get member id 'z' (2)
179: +
180: Func(1,0): Print
181: #
npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, Struct { "fa
182: local #5
183: local #7
184: local #4
185: local #4
186: get member id 'y' (1)
187: local #4
188: get member id 'z' (2)
189: local #0
190: get member id 'realm' (113)
191: struct
192: local #0
193: get member id 'facing' (9)
194: addmember-assign(facing)
195: 0L

_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 6:32 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
mm but
get member id 'x'
where is in .lst file?

_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 6:35 am 
Offline
POL Developer
User avatar

Joined: Sun Feb 12, 2006 9:50 pm
Posts: 836
Location: Indiana, USA
Exactly. Could you post the same thing, where you create the struct first, and post the lst involving where it sends the function again please? :)

Sorry, at work, but trying to get as much info as possible.

_________________
POL Developer - The Penguin Scripter


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 6:45 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
code:
Code:
      print("trasmitted x="+loc.x+" y="+loc.y+" z="+loc.z); //DEBUG
      var tmp := Struct { "facing" := who.facing };
      npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, tmp);


and .lst section:
Code:
var tmp := Struct { "facing" := who.facing };
182: decl local #0
183: struct
184: local #0
185: get member id 'facing' (9)
186: addmember-assign(facing)
187: :=
188: #
npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, tmp);
189: local #7
190: local #4
191: get member id 'x' (0)
192: local #4
193: get member id 'y' (1)
194: local #4
195: get member id 'z' (2)
196: local #0
197: get member id 'realm' (113)
198: local #10
199: 0L
200: makelocal
201: jmp userfunc @274


mm but where finished tmp?

_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 6:47 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
I have tryed and in game it take correct facing while I create npc....

_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 6:51 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
This is more complete:
Code:
     loc := TargetCoordinates(who);
    if (loc)
      print("trasmitted x="+loc.x+" y="+loc.y+" z="+loc.z); //DEBUG
      var tmp := Struct { "facing" := who.facing };
      npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, tmp);
       if (npc.errortext)
          SendSysMessage(who, "NPC " + template + " Creation Failed: " + npc.errortext);
       endif
    else
      break;
      SendSysMessage(who, "Aborted.");
    endif


and list file:
Code:
loc := TargetCoordinates(who);
161: local #0
162: Func(2,14): TargetCoordinates
163: local4 :=
if (loc)
164: local #4
165: if false goto 221
print("trasmitted x="+loc.x+" y="+loc.y+" z="+loc.z); //DEBUG
166: "trasmitted x="
167: local #4
168: get member id 'x' (0)
169: +
170: " y="
171: +
172: local #4
173: get member id 'y' (1)
174: +
175: " z="
176: +
177: local #4
178: get member id 'z' (2)
179: +
180: Func(1,0): Print
181: #
var tmp := Struct { "facing" := who.facing };
182: decl local #0
183: struct
184: local #0
185: get member id 'facing' (9)
186: addmember-assign(facing)
187: :=
188: #
npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, tmp);
189: local #7
190: local #4
191: get member id 'x' (0)
192: local #4
193: get member id 'y' (1)
194: local #4
195: get member id 'z' (2)
196: local #0
197: get member id 'realm' (113)
198: local #10
199: 0L
200: makelocal
201: jmp userfunc @274
202: local5 :=
if (npc.errortext)
203: local #5
204: get member 'errortext'
205: if false goto 219
SendSysMessage(who, "NPC " + template + " Creation Failed: " + npc.errortext);
206: local #0
207: "NPC "
208: local #7
209: +
210: " Creation Failed: "
211: +
212: local #5
213: get member 'errortext'
214: +
215: 3L
216: 1000L
217: Func(2,7): SendSysMessage
218: #
219: leave block(1)
220: goto228
break;
221: goto271
SendSysMessage(who, "Aborted.");
222: local #0
223: "Aborted."
224: 3L
225: 1000L
226: Func(2,7): SendSysMessage
227: #


_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 6:55 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
And more complete with bugged code:
Code:
     loc := TargetCoordinates(who);
      print("trasmitted x="+loc.x+" y="+loc.y+" z="+loc.z); //DEBUG
      npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, Struct { "facing" := who.facing } );
       if (npc.errortext)
          SendSysMessage(who, "NPC " + template + " Creation Failed: " + npc.errortext);
       endif
    else
      break;
      SendSysMessage(who, "Aborted.");
    endif


and list file:
Code:
loc := TargetCoordinates(who);
161: local #0
162: Func(2,14): TargetCoordinates
163: local4 :=
if (loc)
164: local #4
165: if false goto 216
print("trasmitted x="+loc.x+" y="+loc.y+" z="+loc.z); //DEBUG
166: "trasmitted x="
167: local #4
168: get member id 'x' (0)
169: +
170: " y="
171: +
172: local #4
173: get member id 'y' (1)
174: +
175: " z="
176: +
177: local #4
178: get member id 'z' (2)
179: +
180: Func(1,0): Print
181: #
npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, Struct { "fa
182: local #5
183: local #7
184: local #4
185: local #4
186: get member id 'y' (1)
187: local #4
188: get member id 'z' (2)
189: local #0
190: get member id 'realm' (113)
191: struct
192: local #0
193: get member id 'facing' (9)
194: addmember-assign(facing)
195: 0L
196: makelocal
197: jmp userfunc @269
198: set member id 'x' (0) #
if (npc.errortext)
199: local #5
200: get member 'errortext'
201: if false goto 215
SendSysMessage(who, "NPC " + template + " Creation Failed: " + npc.errortext);
202: local #0
203: "NPC "
204: local #7
205: +
206: " Creation Failed: "
207: +
208: local #5
209: get member 'errortext'
210: +
211: 3L
212: 1000L
213: Func(2,7): SendSysMessage
214: #
215: goto223
break;
216: goto266
SendSysMessage(who, "Aborted.");
217: local #0
218: "Aborted."
219: 3L

_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 6:55 pm 
Offline
Certified POL Expert
User avatar

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1207
Location: Southern Central USA
If I may, at the risk of being wrong,I think the bug is in the order of the parameters being passed.
You have:
Code:
npc := CreateNpcTemplate(template, loc.x, loc.y, loc.z, who.realm, Struct { "facing" := who.facing } );


and the definition in UO.EM for the CreateNpcFromTemplate is:
Code:
CreateNpcFromTemplate( template, x, y, z, override_properties := 0, realm := _DEFAULT_REALM);


In your example you have the flags and realm parameters reversed. So make sure in your function CreateNpcTemplate that when you call the internal CreateNpcFromTemplate that you have them in the right order.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 8:47 pm 
Offline
POL Developer
User avatar

Joined: Sun Feb 12, 2006 9:50 pm
Posts: 836
Location: Indiana, USA
that's cuz it's a custom function.... notice his is CreateNPCTemplate.... which calls it. Read his code ;)

_________________
POL Developer - The Penguin Scripter


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 21, 2007 10:40 pm 
Offline
Certified POL Expert
User avatar

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1207
Location: Southern Central USA
[Edited by Yukiko]

Uhm... Sorry. I guess I am blonde.
That and I don't read things thoroughly.

Just pretend like I never replied in this thread.

*sits quietly off to the side of the room*

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Last edited by Yukiko on Sun Apr 22, 2007 6:46 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 22, 2007 12:16 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
The error is shown in print() when I display parameters first calling function and after called function (inside function body). The function name is not important. THe tests are in post
http://forums.polserver.com/viewtopic.php?p=8103#8103

_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 16, 2007 8:41 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
News for this bug in new core 2007-07-15?
Dev team need other info to try to fix?

_________________
Zandor


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl