 Rem File: Cmd079.bas
 Rem Sub: Load.Object
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 079 -- Load.Object."
    Color 7,0
    End
 Endif
 Call Load.Object
Main.Resume:
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub Load.Object
 On Local Error Goto Error.Trap21
 Temp4=False
 Call Check.Room.Items3
 If Temp7!=SFalse Then
    Call Num
    Temp4=UnTrue
    Call Check.User.Items
 Endif
 If Temp7!<=SFalse Then
    Strng="You can't load that!"
    Call IO.O
    Exit Sub
 Endif
 Temp1!=SFalse
 Temp8=False
 If TreasureRecord.Loadable Then
    Temp1!=TreasureRecord.AmmoLoads
    Temp8=True
 Endif
 If TreasureRecord.Launchable Then
    Temp1!=TreasureRecord.LaunchLoads
    Temp8=UnTrue
 Endif
 If Temp8=False Then
    Strng="You can't load that!"
    Call IO.O
    Exit Sub
 Endif
 If Temp1!<=SFalse Or Temp1!>Lof(TreasureFile)/TreasureRecLen Then
    Strng="There's no ammunition!"
    Call IO.O
    Exit Sub
 Endif
 Call Read.Record(TreasureFile,Temp1!)
 Temp9=True
 If Temp8=True Then
    If TreasureRecord.Ammunition=False Then
       Temp9=False
    Endif
 Else
    If TreasureRecord.LaunchAmmo=False Then
       Temp9=False
    Endif
 Endif
 If Temp9=False Then
    Strng="There's no ammunition!"
    Call IO.O
    Exit Sub
 Endif
 Temp9=False
 For Temp2!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
    Call Read.Record(MessWorkFile6,Temp2!)
    If MessWorkRecord6.User=User.Index Then
       If MessWorkRecord6.Index=Temp1! Then
          Temp9=True
          Exit For
       Endif
    Endif
 Next
 If Temp9=False Then
    Temp2!=RoomRecord.First
    If Temp2! Then
       Do While Lost.Carrier=False
          Call Read.Record(RoomInvFile,Temp2!)
          If MessWorkRecord6.Room=SFalse Then
             Exit Do
          Endif
          Temp6!=MessWorkRecord6.Next
          If MessWorkRecord6.Index=Temp1! Then
             Temp9=True
             Exit Do
          Endif
          If Temp6!=SFalse Then
             Exit Do
          Endif
          Temp2!=Temp6!
       Loop
    Endif
 Endif
 If Temp9=False Then
    Strng="There's no ammunition!"
    Call IO.O
    Exit Sub
 Endif
 TempZ=False
 Select Case Temp4
 Case 1
    Call Read.Record(MessWorkFile6,Temp5!)
    If MessWorkRecord6.Charges<32767 Then
       MessWorkRecord6.Charges=MessWorkRecord6.Charges+1
       Call Write.Record(MessWorkFile6,Temp5!)
    Else
       TempZ=True
    Endif
 Case 0
    Call Read.Record(RoomInvFile,Temp5!)
    If MessWorkRecord6.Charges<32767 Then
       MessWorkRecord6.Charges=MessWorkRecord6.Charges+1
       Call Write.Record(RoomInvFile,Temp5!)
    Else
       TempZ=True
    Endif
 End Select
 Graphics.Off=False
 If TempZ Then
    Strng="The device can't load that much!"
 Else
    Strng="You load the device!"
    Temp9=False
    For Temp2!=1! To Lof(MessWorkFile6)/MessWorkRecLen6
       Call Read.Record(MessWorkFile6,Temp2!)
       If MessWorkRecord6.User=User.Index Then
          If MessWorkRecord6.Index=Temp1! Then
             Temp9=True
             Call Discard(Temp2!,True)
             Exit For
          Endif
       Endif
    Next
    If Temp9=False Then
       Temp2!=RoomRecord.First
       If Temp2! Then
          Do While Lost.Carrier=False
             Call Read.Record(RoomInvFile,Temp2!)
             If MessWorkRecord6.Room=SFalse Then
                Exit Do
             Endif
             Temp6!=MessWorkRecord6.Next
             If MessWorkRecord6.Index=Temp1! Then
                Call Delete.List.Node(Temp2!)
                Call Clear.List.Node
                Call Write.Record(RoomInvFile,Temp2!)
                Temp9=True
                Exit Do
             Endif
             If Temp6!=SFalse Then
                Exit Do
             Endif
             Temp2!=Temp6!
          Loop
       Endif
    Endif
 Endif
 Call IO.O
Error.Resume21:
 Exit Sub
Error.Trap21:
 Resume Error.Resume21
End Sub
