directplay add-on

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

stfighter01

Betreff: directplay add-on

BeitragSo, Feb 15, 2004 20:59
Antworten mit Zitat
Benutzer-Profile anzeigen
hab eine abhilfe für alle chat-bastler gemacht die directplay verwenden wollen

Code: [AUSKLAPPEN]

;networkmanager

;der manager ist als Add-on für directplay gedacht
;alle meldungen die von lokalen spieler an andere lokale spieler gesendet wurden, konnten nicht empfangen werden.
;mit diesem addon ist das möglich

;Funktionen:

;-------------------------
;Function sendnetmsg_l(code, msg$, from, to_, important)
;Function RecvNetMsg_l()
;Function netmsgtype_l()
;Function netmsgto_l()
;Function netmsgfrom_l()
;Function netmsgdata_l$()
;Function createnetplayer_l(name$)
;Function deletenetplayer_l(player)
;--------------------------

;diese sind anstatt der alten directplay funktionen zu nutzen, und machen auch genau dasselbe wie die alten
;alle anderen funktionen wie StartNetGame bleiben gleich
;einziger unterschied: es dürfen nur noch codes von 1-97 verwendet werden und
;der code für playerenter ist 98, bzw. NET_enter u.
;der code für playerleave ist 99, bzw. NET_leave
;ausserdem können auch NUR lokale messages verschickt werden mit sendnetmsg(code, msg$, for,    NET_local    , inportant)

Const NET_enter= 98
Const NET_leave= 99
Const NET_local= -1

Type localmsglist
   Field code
   Field msg$
   Field from
   Field to_
End Type

Global NETMSG_code=-1
Global NETMSG_data$= ""
Global NETMSG_from= 0
Global NETMSG_to= 0


 Function sendnetmsg_l(code, msg$, from, to_, important)
   Local mlist.localmsglist
;   If NetPlayerLocal(from)= False Return
   
   If to_ <> NET_local
      If NetPlayerLocal(to_)= False
         SendNetMsg(code, msg$, from, to_, important)   
         If to_<> 0 Return
      EndIf   
   EndIf
   mlist.localmsglist= New localmsglist
   mlist\code= code
   mlist\msg$= msg$
   mlist\from= from
   mlist\to_= to_
      
   Return
End Function

 Function RecvNetMsg_l()
   Local mlist.localmsglist
   Local rcode

   mlist.localmsglist= First localmsglist
   If mlist<> Null
      NETMSG_code= mlist\code
      NETMSG_data$= mlist\msg$
      NETMSG_from= mlist\from
      NETMSG_to= mlist\to_   
      Delete mlist
      Return True
   Else
      NETMSG_code= -1
   EndIf   
   
   Return RecvNetMsg()   
End Function

 Function netmsgtype_l()
   Local code
   If NETMSG_code<> -1
      Return NETMSG_code   
   EndIf
      
   code= NetMsgType()
   If code = 100: code = NET_enter : EndIf
   If code = 102: code = NET_leave : EndIf
   
   Return code
End Function

 Function netmsgto_l()
   If NETMSG_code<> -1
      Return NETMSG_to   
   EndIf
      
   Return NetMsgTo()
End Function

 Function netmsgfrom_l()
   If NETMSG_code<> -1
      Return NETMSG_from   
   EndIf
   
   Return NetMsgFrom()
End Function

 Function netmsgdata_l$()
   If NETMSG_code<> -1
      Return NETMSG_data   
   EndIf
   
   Return NetMsgData$()
End Function

 Function createnetplayer_l(name$)
   Local player
   player= CreateNetPlayer(name$)
   sendnetmsg_l(NET_enter, "enter" ,player, NET_local,0)
   Return player
End Function

 Function deletenetplayer_l(player)
   sendnetmsg_l(NET_leave, "leave" ,player, NET_local,0)
   DeleteNetPlayer(player)
End Function
Denken hilft!

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group