| Author |
Message |
zandor70
Joined: 10 Feb 2006 Posts: 79 Location: Italy
|
Posted: Sat Apr 21, 2007 6:39 am Post subject: Bug in function parameter when using syntax Struct { "m |
|
|
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? |
|
 |
|
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
| Author |
Message |
zandor70
Joined: 10 Feb 2006 Posts: 79 Location: Italy
|
Posted: Sat Apr 21, 2007 10:31 am Post subject: List file |
|
|
| 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
|
|
|
 |
|
|
 |
 |
|
 |
 |
|
 |
 |
| Author |
Message |
zandor70
Joined: 10 Feb 2006 Posts: 79 Location: Italy
|
Posted: Sat Apr 21, 2007 10:45 am Post subject: |
|
|
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? |
|
 |
|
|
 |
 |
|
 |
 |
| Author |
Message |
zandor70
Joined: 10 Feb 2006 Posts: 79 Location: Italy
|
Posted: Sat Apr 21, 2007 10:51 am Post subject: |
|
|
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: #
|
|
|
 |
|
|
 |
 |
| Author |
Message |
zandor70
Joined: 10 Feb 2006 Posts: 79 Location: Italy
|
Posted: Sat Apr 21, 2007 10:55 am Post subject: |
|
|
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
|
|
|
 |
|
|
 |
 |
| Author |
Message |
Yukiko
Joined: 02 Feb 2006 Posts: 1094 Location: Southern Central USA
|
Posted: Sat Apr 21, 2007 10:55 pm Post subject: |
|
|
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. |
|
 |
|
|