ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
Damned LiveUpdate / Callback Query Crashes (Sdk)
Damned LiveUpdate / Callback Query Crashes // Sdkstrike rapierSep 19, 2002, 3:25pm
Howdy Everyone,
Im currently experiencing a little technical difficult when it comes to query and live update. Ive just created a bot for the CY Awards that is a GUI controled lighting / object controler for controling stage lights, doors etc. I programmed it straight though without testing it going on what I know works, however for some whappy reason it dosent. Whenever I do a query and set live update after its finished on either 3x3 or 5x5 the program calls aw_event_cell_begin at no point until I change an object, however once I do change an object (source included) it all goes to pot and it recieves about 10 aw_event_cell_begin calls, the objects start returing back that they could not find the origional (when I know its there by using another bot and have confirmed its X, Z and Number) bit then after 1 or 2 it just crashes, sometimes it builds about 20 objects. And during the CY's this is not preferable. LOL... I wonder if anyone can help, sorry about HTML. Option Explicit Dim FiveXFive As Boolean Dim sect_x As Long Dim sect_z As Long Dim cell_x As Long Dim cell_z As Long Dim ObCount As Long Private Sub sdk_EventObjectAdd() Dim ObX As Long, ObZ As Long, ObSes As Long, ObMod As String, ObOwner As Long, rc As Long, ObNum As Long Dim ObY As Long, ObYAW As Long, obmodel As String, ObAction As String, ObDescription, ObTilt As Long, ObRoll As Long ObOwner = sdk.aw_int(AW_OBJECT_OWNER) ObNum = sdk.aw_int(AW_OBJECT_NUMBER) ObX = sdk.aw_int(AW_OBJECT_X) ObZ = sdk.aw_int(AW_OBJECT_Z) ObY = sdk.aw_int(AW_OBJECT_Y) ObTilt = sdk.aw_int(AW_OBJECT_TILT) ObRoll = sdk.aw_int(AW_OBJECT_ROLL) ObYAW = sdk.aw_int(AW_OBJECT_YAW) ObSes = sdk.aw_int(AW_OBJECT_SESSION) ObNum = sdk.aw_int(AW_OBJECT_NUMBER) obmodel = sdk.aw_string(AW_OBJECT_MODEL) ObDescription = sdk.aw_string(AW_OBJECT_DESCRIPTION) ObAction = sdk.aw_string(AW_OBJECT_ACTION) ObCount = ObCount + 1 Me.Caption = "Starbeam Nova - " & ObCount PrgBuffer.Value = (100 / 5000) * ObCount Dim i As Long 'Handle Objects here For i = 0 To 5000 If Obj(i).Number = 0 Then Obj(i).Number = ObNum Obj(i).Owner = ObOwner Obj(i).Model = obmodel Obj(i).Description = ObDescription Obj(i).Action = ObAction Obj(i).X = ObX Obj(i).Y = ObY Obj(i).Z = ObZ Obj(i).YAW = ObYAW Obj(i).Tilt = ObTilt Obj(i).Roll = ObRoll Exit Sub End If Next i End Sub Private Sub sdk_EventObjectDelete() Dim i As Long, ObNum As Long ObNum = sdk.aw_int(AW_OBJECT_NUMBER) ObCount = ObCount - 1 Me.Caption = "Starbeam Nova - " & ObCount PrgBuffer.Value = (100 / 5000) * ObCount For i = 0 To 5000 If Obj(i).Number = ObNum Then Obj(i).Number = 0 Obj(i).Owner = 0 Obj(i).Model = "" Obj(i).Description = "" Obj(i).Action = "" Obj(i).X = 0 Obj(i).Y = 0 Obj(i).Z = 0 Obj(i).YAW = 0 Obj(i).Tilt = 0 Obj(i).Roll = 0 Exit Sub End If Next i End Sub Public Sub QueryNow(X As Long, Z As Long) cell_z = Z 'or whatever cell_x = X 'or whatever ' Set the sector to query sect_z = sdk.aw_sector_from_cell(cell_z) sect_x = sdk.aw_sector_from_cell(cell_x) ' Perform the query Display "Begining query at " & cell_x & " by " & cell_z, vbBlack If FiveXFive = False Then sdk.aw_query sect_x, sect_z Else sdk.aw_query_5x5 sect_x, sect_z End If End Sub Private Sub sdk_CallbackQuery(ByVal rc As Long) ' Continue the query until it is complete If Not sdk.aw_bool(AW_QUERY_COMPLETE) Then If FiveXFive = False Then sdk.aw_query sect_x, sect_z Else sdk.aw_query_5x5 sect_x, sect_z End If Exit Sub Else Display "Query Complete", vbBlack End If 'Do stuff here End Sub Private Sub sdk_EventCellBegin() Dim X As Long Dim Z As Long If FiveXFive = False Then ' Get the current cell cell_x = sdk.aw_int(AW_CELL_X) cell_z = sdk.aw_int(AW_CELL_Z) ' Calculate the sector the cell is in X = sdk.aw_sector_from_cell(cell_x) - sect_x Z = sdk.aw_sector_from_cell(cell_z) - sect_z ' ' Sanity Check, X and Z may be either -1, 0, or 1 If (X < -1 Or X > 1 Or Z < -1 Or Z > 1) Then Exit Sub End If ' Update the Sequence variable for the current sector 'You can use this syntax too sdk.aw_seq_3x3(z + 1, x + 1) = sdk.aw_int(AW_CELL_SEQUENCE) sdk.aw_sequence_set AW_SEQUENCE_3X3, (Z + 1), (X + 1), sdk.aw_int(AW_CELL_SEQUENCE) Else ' Get the current cell cell_x = sdk.aw_int(AW_CELL_X) cell_z = sdk.aw_int(AW_CELL_Z) ' Calculate the sector the cell is in X = sdk.aw_sector_from_cell(cell_x) - sect_x Z = sdk.aw_sector_from_cell(cell_z) - sect_z ' ' Sanity Check, X and Z may be either -2, -1, 0, 1, 2 If (X < -2 Or X > 2 Or Z < -2 Or Z > 2) Then Exit Sub End If ' Update the Sequence variable for the current sector 'You can use this syntax too sdk.aw_seq_5x5(z + 2, x + 2) = sdk.aw_int(AW_CELL_SEQUENCE) sdk.aw_sequence_set AW_SEQUENCE_5X5, (Z + 2), (X + 2), sdk.aw_int(AW_CELL_SEQUENCE) End If End Sub Private Sub sdk_EventCellObject() Dim ObX As Long, ObZ As Long, ObSes As Long, ObMod As String, ObOwner As Long, rc As Long, ObNum As Long Dim ObY As Long, ObYAW As Long, obmodel As String, ObAction As String, ObDescription, ObTilt As Long, ObRoll As Long ObOwner = sdk.aw_int(AW_OBJECT_OWNER) ObNum = sdk.aw_int(AW_OBJECT_NUMBER) ObX = sdk.aw_int(AW_OBJECT_X) ObZ = sdk.aw_int(AW_OBJECT_Z) ObY = sdk.aw_int(AW_OBJECT_Y) ObTilt = sdk.aw_int(AW_OBJECT_TILT) ObRoll = sdk.aw_int(AW_OBJECT_ROLL) ObYAW = sdk.aw_int(AW_OBJECT_YAW) ObSes = sdk.aw_int(AW_OBJECT_SESSION) ObNum = sdk.aw_int(AW_OBJECT_NUMBER) obmodel = sdk.aw_string(AW_OBJECT_MODEL) ObDescription = sdk.aw_string(AW_OBJECT_DESCRIPTION) ObAction = sdk.aw_string(AW_OBJECT_ACTION) ObCount = ObCount + 1 Me.Caption = "Starbeam Nova - " & ObCount PrgBuffer.Value = (100 / 5000) * ObCount Dim i As Long 'Handle Objects here For i = 0 To 5000 If Obj(i).Number = 0 Then Obj(i).Number = ObNum Obj(i).Owner = ObOwner Obj(i).Model = obmodel Obj(i).Description = ObDescription Obj(i).Action = ObAction Obj(i).X = ObX Obj(i).Y = ObY Obj(i).Z = ObZ Obj(i).YAW = ObYAW Obj(i).Tilt = ObTilt Obj(i).Roll = ObRoll Exit Sub End If Next i End Sub Function ChangeObject(Key As String, SetID As Integer, LocalID As Integer) Dim i As Long, rc As Long, tCount As Long, StrAction As String If data(SetID).DataPot(LocalID) = "void" Then StrAction = "%key" Else StrAction = data(SetID).DataPot(LocalID) End If StrAction = Replace(StrAction, "%key", "<" & data(SetID).Key & ">") For i = 0 To 5000 If Obj(i).Number <> 0 Then If CBool(InStr(1, LCase(Obj(i).Action), "<" & LCase(data(SetID).Key) & ">")) = True Then sdk.aw_int_set AW_OBJECT_OLD_NUMBER, Obj(i).Number sdk.aw_int_set AW_OBJECT_OLD_X, Obj(i).X sdk.aw_int_set AW_OBJECT_OLD_Z, Obj(i).Z sdk.aw_string_set AW_OBJECT_MODEL, Obj(i).Model sdk.aw_string_set AW_OBJECT_DESCRIPTION, Obj(i).Model sdk.aw_string_set AW_OBJECT_ACTION, StrAction sdk.aw_int_set AW_OBJECT_X, Obj(i).X sdk.aw_int_set AW_OBJECT_Y, Obj(i).Y sdk.aw_int_set AW_OBJECT_Z, Obj(i).Z sdk.aw_int_set AW_OBJECT_YAW, Obj(i).YAW sdk.aw_int_set AW_OBJECT_TILT, Obj(i).Tilt sdk.aw_int_set AW_OBJECT_ROLL, Obj(i).Roll sdk.aw_int_set AW_OBJECT_OWNER, Obj(i).Owner rc = sdk.aw_object_change If rc Then Display "Could not set object '" & Key & "' with " & LocalID & " of " & SetID & " - Reason: " & RC_Lookup(rc), vbRed Else tCount = tCount + 1 End If End If End If Next i If tCount = 0 Then Display "Could not set object '" & Key & " with " & LocalID & " of " & SetID & " - Reason: None Found", vbRed Else Display "Set object(s) '" & Key & "' with " & LocalID & " of " & SetID & " on " & tCount & " items", vbBlack End If End Function Data(x) is a global variable of a data type... Type DataSet Name As String Key As String Count As Integer DataPot(30) As String DataName(30) As String End Type And AW_WAIT is called every 500 / 1000 ms for 0ms It just seems to be goig nuts, it recieves the command to do a loop of all the objects in it, but then after its built the objects it goes kablammo. If I pause the bot mid crash it will show me that the objects have been built, so maybe its a callback or something? If anyone does know any reason why this is happening please tell me as my bots currently as effective after the first click as putting... While (0 = 0) 'This acomplishes stuff all except making the program freeze and not send the windows API its V_REDRAW / H_REDRAW data for 'Hwind do events loop baronSep 21, 2002, 4:53am
Looks like your program never enters live update due to an old VB story and how it converts int to boolean.
tmp=sdk.aw_bool(AW_QUERY_COMPLETE) "If (Not tmp)" is evaluated as true until tmp = -1; the dll returns tmp=0 for sdk.aw_bool(AW_QUERY_COMPLETE) =False and tmp=1 for sdk.aw_bool(AW_QUERY_COMPLETE) =True. So what happens is you call aw_query with your timer's interval even though the sequence is updated...the seq you send matches so no data is sent. As soon as sequence changes due to an object change you have a valid new query. If you use "If sdk.aw_bool(AW_QUERY_COMPLETE)=False" all should be fine, your program stops calling aw_query, enters live update and starts receiving AW_EVENT_OBJECT_*. -Baron [View Quote] strike rapierSep 21, 2002, 7:51am
*Bows down to Baron*
Thanks a tonne! Ive just changed it on all the projects I used it in, it works perfectly now :D - Mark [View Quote] |