Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. '##############################################################################################################
    
  2. '#include once "TSNEplay_V3."bi
    
  3. #INCLUDE Once "TSNEplay_V31.bi"
    
  4. 
    
  5. 
    
  6. 
    
  7. '##############################################################################################################
    
  8. #INCLUDE Once "fbgfx.bi"
    
  9. 
    
  10. 
    
  11. 
    
  12. '##############################################################################################################
    
  13. Dim Shared G_Mutex      As Any Ptr
    
  14. Dim Shared G_Input      As String
    
  15. 
    
  16. 
    
  17. 
    
  18. '##############################################################################################################
    
  19. Type Player_Type
    
  20.     V_Next              As Player_Type Ptr
    
  21.     V_Prev              As Player_Type Ptr
    
  22.     V_Nickname          As String
    
  23.     V_CurX              As Double
    
  24.     V_CurY              As Double
    
  25.     V_Ready             As Ubyte
    
  26. End Type
    
  27. Dim Shared G_Player_F   As Player_Type Ptr
    
  28. Dim Shared G_Player_L   As Player_Type Ptr
    
  29. Dim Shared G_MyNick     As String
    
  30. Dim Shared G_ServerNick As String : G_ServerNick = "[MANAGER]"
    
  31. 
    
  32. 
    
  33. 
    
  34. '##############################################################################################################
    
  35. Enum StatType_Enum
    
  36.     ST_NetMSG           = 1
    
  37.     ST_UserMSG          = 2
    
  38.     ST_MyMSG            = 3
    
  39.     ST_GlobalMSG        = 4
    
  40. End Enum
    
  41. Type Stat_Type
    
  42.     V_Next              As Stat_Type Ptr
    
  43.     V_Prev              As Stat_Type Ptr
    
  44.     V_Type              As StatType_Enum
    
  45.     V_Text              As String
    
  46.     V_Timeout           As Double
    
  47. End Type
    
  48. Dim Shared G_StatD_F    As Stat_Type Ptr
    
  49. Dim Shared G_StatD_L    As Stat_Type Ptr
    
  50. Dim Shared G_StatD_C    As Uinteger
    
  51. 
    
  52. 
    
  53. 
    
  54. '##############################################################################################################
    
  55. Dim Shared G_Map        As Any Ptr
    
  56. Dim Shared G_MapSize    As Uinteger
    
  57. Dim Shared G_MapWait    As Any Ptr
    
  58. Dim Shared G_MapRun     As Any Ptr
    
  59. Dim Shared G_MapDone    As Any Ptr
    
  60. Dim Shared G_MapFail    As Any Ptr
    
  61. Dim Shared G_State      As Ubyte
    
  62. Dim Shared G_MSG        As String
    
  63. Dim Shared TMX          As Integer
    
  64. Dim Shared TMY          As Integer
    
  65. Dim Shared TMXL         As Integer
    
  66. Dim Shared TMYL         As Integer
    
  67. Dim Shared TMapData     As String
    
  68. 
    
  69. 
    
  70. 
    
  71. '##############################################################################################################
    
  72. Sub StatDELCheck()
    
  73. Mutexlock(G_Mutex)
    
  74. If G_StatD_C <= 0 Then Mutexunlock(G_Mutex): Exit Sub
    
  75. Dim TPtr As Stat_Type Ptr = G_StatD_F
    
  76. Dim TNPtr As Stat_Type Ptr
    
  77. Do Until TPtr = 0
    
  78.     TNPtr = TPtr->V_Next
    
  79.     If (TPtr->V_TimeOut < Timer()) Or (G_StatD_C > 15) Then
    
  80.         If TPtr->V_Next <> 0 Then TPtr->V_Next->V_Prev = TPtr->V_Prev
    
  81.         If TPtr->V_Prev <> 0 Then TPtr->V_Prev->V_Next = TPtr->V_Next
    
  82.         If G_StatD_F = TPtr Then G_StatD_F = TPtr->V_Next
    
  83.         If G_StatD_L = TPtr Then G_StatD_L = TPtr->V_Prev
    
  84.         Deallocate(TPtr)
    
  85.         If G_StatD_C > 0 Then G_StatD_C -= 1
    
  86.     End If
    
  87.     TPtr = TNPtr
    
  88. Loop
    
  89. Mutexunlock(G_Mutex)
    
  90. End Sub
    
  91. 
    
  92. '--------------------------------------------------------------------------------------------------------------
    
  93. Sub StatAdd(V_Type As StatType_Enum, V_Text As String)
    
  94. Mutexlock(G_Mutex)
    
  95. If G_StatD_L <> 0 Then
    
  96.     G_StatD_L->V_Next = Callocate(Sizeof(Stat_Type))
    
  97.     G_StatD_L->V_Next->V_Prev = G_StatD_L
    
  98.     G_StatD_L = G_StatD_L->V_Next
    
  99. Else
    
  100.     G_StatD_L = Callocate(Sizeof(Stat_Type))
    
  101.     G_StatD_F = G_StatD_L
    
  102. End If
    
  103. G_StatD_C += 1
    
  104. With *G_StatD_L
    
  105.     .V_Type = V_Type
    
  106.     .V_Text = V_Text
    
  107.     .V_Timeout = Timer() + 3
    
  108. End With
    
  109. Mutexunlock(G_Mutex)
    
  110. StatDELCheck()
    
  111. End Sub
    
  112. 
    
  113. 
    
  114. 
    
  115. '##############################################################################################################
    
  116. Function PlayerGet(V_Nickname As String) As Player_Type Ptr
    
  117. Dim TPtr As Player_Type Ptr = G_Player_F
    
  118. Do Until TPtr = 0
    
  119.     If TPtr->V_Nickname = V_Nickname Then Return TPtr
    
  120.     TPtr = TPtr->V_Next
    
  121. Loop
    
  122. Return 0
    
  123. End Function
    
  124. 
    
  125. '--------------------------------------------------------------------------------------------------------------
    
  126. Sub PlayerDel(V_Nickname As String)
    
  127. Mutexlock(G_Mutex)
    
  128. Dim TPtr As Player_Type Ptr = PlayerGet(V_Nickname)
    
  129. If TPtr = 0 Then Mutexunlock(G_Mutex): Exit Sub
    
  130. If TPtr->V_Next <> 0 Then TPtr->V_Next->V_Prev = TPtr->V_Prev
    
  131. If TPtr->V_Prev <> 0 Then TPtr->V_Prev->V_Next = TPtr->V_Next
    
  132. If G_Player_F = TPtr Then G_Player_F = TPtr->V_Next
    
  133. If G_Player_L = TPtr Then G_Player_L = TPtr->V_Prev
    
  134. Deallocate(TPtr)
    
  135. Mutexunlock(G_Mutex)
    
  136. End Sub
    
  137. 
    
  138. '--------------------------------------------------------------------------------------------------------------
    
  139. Sub PlayerAdd(V_Nickname As String)
    
  140. Mutexlock(G_Mutex)
    
  141. If G_Player_L <> 0 Then
    
  142.     G_Player_L->V_Next = Callocate(Sizeof(Player_Type))
    
  143.     G_Player_L->V_Next->V_Prev = G_Player_L
    
  144.     G_Player_L = G_Player_L->V_Next
    
  145. Else
    
  146.     G_Player_L = Callocate(Sizeof(Player_Type))
    
  147.     G_Player_F = G_Player_L
    
  148. End If
    
  149. With *G_Player_L
    
  150.     .V_Nickname = V_Nickname
    
  151. End With
    
  152. Mutexunlock(G_Mutex)
    
  153. End Sub
    
  154. 
    
  155. 
    
  156. 
    
  157. '##############################################################################################################
    
  158. Sub DoDraw(V_Lock As Ubyte = 1)
    
  159. Mutexlock(G_Mutex)
    
  160. If V_Lock = 1 Then Screenlock()
    
  161. Dim TMap As Any Ptr = G_MapFail
    
  162. Select Case G_State
    
  163.     Case 5 To 9: TMap = G_MapWait
    
  164.     Case 10: TMap = G_MapRun
    
  165.     Case 11: TMap = G_MapDone
    
  166.     Case Else: TMap = G_MapFail
    
  167. End Select
    
  168. Put (0, 0), TMap, Pset
    
  169. If G_State <> 10 Then Pset (TMX, TMY), &H0000FF00
    
  170. If G_State <> 10 Then
    
  171.     Dim TY As Uinteger = 12
    
  172.     Dim TCol As Uinteger
    
  173.     Dim TPtr As Stat_Type Ptr = G_StatD_L
    
  174.     Do Until TPtr = 0
    
  175.         With *TPtr
    
  176.             Line (0, TY)-(Len(.V_Text) * 8 + 20, TY + 12), &B000000, BF
    
  177.             Select Case .V_Type
    
  178.                 Case ST_NetMSG: TCol = &H00FFFF00
    
  179.                 Case ST_UserMSG: TCol = &H00919CFF
    
  180.                 Case ST_MyMSG: TCol = &H00FF4346
    
  181.                 Case ST_GlobalMSG: TCol = &H00FFFFFF
    
  182.             End Select
    
  183.             Draw String (3, TY + 2), .V_Text, TCol
    
  184.         End With
    
  185.         TY += 12
    
  186.         TPtr = TPtr->V_Prev
    
  187.     Loop
    
  188.     Locate 1, 1
    
  189.     Dim TPC As Uinteger
    
  190.     If G_State <> 10 Then
    
  191.         Dim TUPtr As Player_Type Ptr = G_Player_F
    
  192.         Do Until TUPtr = 0
    
  193.             With *TUPtr
    
  194.                 If .V_Nickname <> G_MyNick Then
    
  195.                     Circle (.V_CurX, .V_CurY), 25, &H00FFFFFF
    
  196.                     Draw String (.V_CurX - 25, .V_CurY - 25), .V_Nickname, &H00FFFFFF
    
  197.                 End If
    
  198.             End With
    
  199.             TUPtr = TUPtr->V_Next
    
  200.         Loop
    
  201.     End If
    
  202.     If G_MSG <> "" Then
    
  203.         Line (400 - 8 - Len(G_MSG) * 4 - 1, 300 - 8 - 1)-(400 + 8 + Len(G_MSG) * 4 + 1, 300 + 8 + 1), &H00000000, BF
    
  204.         Line (400 - 8 - Len(G_MSG) * 4, 300 - 8)-(400 + 8 + Len(G_MSG) * 4, 300 + 8), &H00FFFFFF, BF
    
  205.         Draw String (400 - Len(G_MSG) * 4, 300 - 4), G_MSG, &H00000000
    
  206.     End If
    
  207. End If
    
  208. If G_State <> 10 Then
    
  209.     Circle (TMX, TMY), 25, &H00FFFFFF
    
  210. Else: Circle (TMX, TMY), 25, &H00444444
    
  211. End If
    
  212. If V_Lock = 1 Then Screenunlock()
    
  213. Mutexunlock(G_Mutex)
    
  214. End Sub
    
  215. 
    
  216. 
    
  217. 
    
  218. '##############################################################################################################
    
  219. Sub BlitColor(V_Target As Any Ptr, V_Source As Any Ptr, V_Color As Uinteger, V_RND As Ubyte = 0)
    
  220. Dim TPitchS As Uinteger = Cast(FB.Image Ptr, V_Source)->pitch
    
  221. Dim TPitchT As Uinteger = Cast(FB.Image Ptr, V_Target)->pitch
    
  222. Dim TDX() As Uinteger
    
  223. Dim TDY() As Uinteger
    
  224. Dim TDC As Uinteger
    
  225. Dim TSC As Uinteger
    
  226. For Y As Uinteger = 0 To 599
    
  227.     For X As Uinteger = 0 To 799
    
  228.         TSC = (*Cast(Uinteger Ptr, (Cast(Ubyte Ptr, V_Source) + Sizeof(FB.Image) + Y * TPitchS + X * 4)) And &H00FFFFFF)
    
  229.         Select Case TSC
    
  230.             Case &H00FF00FF
    
  231.                 If V_RND = 0 Then
    
  232.                     *(Cast(Uinteger Ptr, Cast(Ubyte Ptr, V_Target) + Sizeof(FB.Image) + Y * TPitchT + X * 4)) = V_Color
    
  233.                 Else: *(Cast(Uinteger Ptr, Cast(Ubyte Ptr, V_Target) + Sizeof(FB.Image) + Y * TPitchT + X * 4)) = TSC
    
  234.                 End If
    
  235.                 
    
  236.             Case &H000000FF
    
  237.                 If V_RND = 0 Then
    
  238.                     *(Cast(Uinteger Ptr, Cast(Ubyte Ptr, V_Target) + Sizeof(FB.Image) + Y * TPitchT + X * 4)) = &H8080FF
    
  239.                 Else: *(Cast(Uinteger Ptr, Cast(Ubyte Ptr, V_Target) + Sizeof(FB.Image) + Y * TPitchT + X * 4)) = TSC
    
  240.                 End If
    
  241.                 
    
  242.             Case &H00800000
    
  243.                 If V_RND = 1 Then
    
  244.                     *(Cast(Uinteger Ptr, Cast(Ubyte Ptr, V_Target) + Sizeof(FB.Image) + Y * TPitchT + X * 4)) = &H00FFFFFF
    
  245.                     TDC += 1
    
  246.                     Redim Preserve TDX(TDC) As Uinteger
    
  247.                     Redim Preserve TDY(TDC) As Uinteger
    
  248.                     TDX(TDC) = X
    
  249.                     TDY(TDC) = Y
    
  250.                 Else
    
  251.                     *(Cast(Uinteger Ptr, Cast(Ubyte Ptr, V_Target) + Sizeof(FB.Image) + Y * TPitchT + X * 4)) = (*Cast(Uinteger Ptr, (Cast(Ubyte Ptr, V_Source) + Sizeof(FB.Image) + Y * TPitchS + X * 4)) And &H00FFFFFF)
    
  252.                 End If
    
  253.                 
    
  254.             Case Else
    
  255.                 If V_RND = 0 Then
    
  256.                     *(Cast(Uinteger Ptr, Cast(Ubyte Ptr, V_Target) + Sizeof(FB.Image) + Y * TPitchT + X * 4)) = (*Cast(Uinteger Ptr, (Cast(Ubyte Ptr, V_Source) + Sizeof(FB.Image) + Y * TPitchS + X * 4)) And &H00FFFFFF)
    
  257.                 Else: *(Cast(Uinteger Ptr, Cast(Ubyte Ptr, V_Target) + Sizeof(FB.Image) + Y * TPitchT + X * 4)) = TSC
    
  258.                 End If
    
  259.                 
    
  260.         End Select
    
  261.     Next
    
  262. Next
    
  263. If V_RND = 1 Then
    
  264.     If TDC > 0 Then
    
  265.         Dim TX As Uinteger = Int((Rnd * TDC) + 1)
    
  266.         For X As Uinteger = 1 To TDC
    
  267.             If X = TX Then
    
  268.                 Paint V_Target, (TDX(X), TDY(X)), &H00FF0000, &H00000000
    
  269.             Else
    
  270.                 Paint V_Target, (TDX(X), TDY(X)), &H00FE0000, &H00000000
    
  271.             End If
    
  272.         Next
    
  273.     End If
    
  274. End If
    
  275. End Sub
    
  276. 
    
  277. 
    
  278. 
    
  279. '##############################################################################################################
    
  280. Sub PrepareMap()
    
  281. BlitColor(G_Map, G_Map, &H00FF00FF, 1)
    
  282. BlitColor(G_MapWait, G_Map, &H00808000)
    
  283. BlitColor(G_MapRun, G_Map, &H00404040)
    
  284. BlitColor(G_MapDone, G_Map, &H00008000)
    
  285. BlitColor(G_MapFail, G_Map, &H00800000)
    
  286. G_MSG = "Begib dich zum BLAUEM Ausgangspunkt!"
    
  287. End Sub
    
  288. 
    
  289. 
    
  290. 
    
  291. '##############################################################################################################
    
  292. Sub TSNEPlay_StateChange(Byval V_State As TSNEPlay_State_Enum)
    
  293. StatADD(ST_NetMSG, "[NET] " & TSNEPlay_GetStateDesc(V_State))
    
  294. Select Case V_State
    
  295.     Case TSNEPlay_STE_Ready         : G_State = 1
    
  296.     Case Else                       : G_State = 0
    
  297. End Select
    
  298. End Sub
    
  299. 
    
  300. '--------------------------------------------------------------------------------------------------------------
    
  301. Sub TSNEPlay_UserChange(Byval V_Action As TSNEPlay_UserAction_Enum, Byref V_Nickname As String)
    
  302. If V_Nickname = "[SERVER]" Then Exit Sub
    
  303. Select Case V_Action
    
  304.     Case TSNEPlay_UA_Join
    
  305.         PlayerAdd(V_Nickname)
    
  306.         StatADD(ST_NetMSG, "[PLAYER JOIN]   Nickname:" & V_Nickname)
    
  307.         
    
  308.     Case TSNEPlay_UA_Part
    
  309.         Mutexlock(G_Mutex)
    
  310.         Dim TPtr As Player_Type Ptr = PlayerGet(V_Nickname)
    
  311.         If TPtr = 0 Then Mutexunlock(G_Mutex): Exit Sub
    
  312.         Mutexunlock(G_Mutex)
    
  313.         PlayerDel(V_Nickname)
    
  314.         StatADD(ST_NetMSG, "[PLAYER LEAVE]  Nickname:" & V_Nickname)
    
  315.         
    
  316. End Select
    
  317. End Sub
    
  318. 
    
  319. '--------------------------------------------------------------------------------------------------------------
    
  320. Sub TSNEPlay_Get_Message(Byref V_From As String, Byref V_To As String, Byref V_Message As String, Byref V_MessageType As TSNEPlay_Message_Enum)
    
  321. If V_To <> "" Then
    
  322.     StatADD(ST_UserMSG, "[" & V_From & "]: " & V_Message)
    
  323. Else: StatADD(ST_GlobalMSG, "GLOBAL: " & V_Message)
    
  324. End If
    
  325. End Sub
    
  326. 
    
  327. '--------------------------------------------------------------------------------------------------------------
    
  328. Sub TSNEPlay_Get_MoveInt(Byref V_From As String, Byref V_To As String, Byref V_X As Integer, Byref V_Y As Integer, Byref V_Z As Integer, Byref V_A As Integer, Byref V_B As Integer)
    
  329. If V_From = G_MyNick Then Exit Sub
    
  330. Mutexlock(G_Mutex)
    
  331. Dim TPtr As Player_Type Ptr = PlayerGet(V_From)
    
  332. If TPtr = 0 Then Mutexunlock(G_Mutex): Exit Sub
    
  333. With *TPtr
    
  334.     .V_CurX = V_X
    
  335.     .V_CurY = V_Y
    
  336. End With
    
  337. If G_State = 10 Then Pset G_MapRun, (V_X, V_Y), &H0000FF
    
  338. Mutexunlock(G_Mutex)
    
  339. End Sub
    
  340. 
    
  341. '--------------------------------------------------------------------------------------------------------------
    
  342. Sub TSNEPlay_Get_Data(Byref V_From As String, Byref V_To As String, Byref V_Data As String)
    
  343. If V_Data = "" Then Exit Sub
    
  344. If V_From <> "[MANAGER]" Then Exit Sub
    
  345. Select Case V_Data[0]
    
  346.     Case 1
    
  347.         Mutexlock(G_Mutex)
    
  348.         G_MSG = "Lade MAP-Daten..."
    
  349.         Mutexunlock(G_Mutex)
    
  350.         DoDraw()
    
  351.         TMapData = ""
    
  352.         TSNEPlay_ClientSend_Data(Chr(2), V_From)
    
  353.         
    
  354.     Case 2
    
  355.         TMapData += Mid(V_Data, 2)
    
  356.         TSNEPlay_ClientSend_Data(Chr(2), V_From)
    
  357.         
    
  358.     Case 3
    
  359.         Mutexlock(G_Mutex)
    
  360.         G_MSG = "Vorbereiten..."
    
  361.         Mutexunlock(G_Mutex)
    
  362.         DoDraw()
    
  363.         Mutexlock(G_Mutex)
    
  364.         For X As Uinteger = 0 To G_MapSize
    
  365.             Cast(Ubyte Ptr, G_Map)[x] = TMapData[X]
    
  366.         Next
    
  367.         PrepareMap()
    
  368.         G_MSG = "MAP Bereit!"
    
  369.         Mutexunlock(G_Mutex)
    
  370.         TSNEPlay_ClientSend_Data(Chr(10), V_From)
    
  371.         
    
  372.     Case 4
    
  373.         Mutexlock(G_Mutex)
    
  374.         G_State = 2
    
  375.         G_MSG = "Lade MAP-Daten..."
    
  376.         Bload "levels/lvl" & Str(Cuint(Mid(V_Data, 2))) & ".bmp", G_Map
    
  377.         PrepareMap()
    
  378.         Mutexunlock(G_Mutex)
    
  379.         TSNEPlay_ClientSend_Data(Chr(10), V_From)
    
  380.         
    
  381.     Case 106 To 109
    
  382.         Mutexlock(G_Mutex)
    
  383.         G_State = V_Data[0] - 100 + 1
    
  384.         Mutexunlock(G_Mutex)
    
  385.         If G_State = 10 Then DoDraw()
    
  386.         
    
  387. End Select
    
  388. End Sub
    
  389. 
    
  390. 
    
  391. 
    
  392. '##############################################################################################################
    
  393. Sub Main()
    
  394. Windowtitle "Ringelpietz Ohne Anfassen"
    
  395. G_Mutex = Mutexcreate()
    
  396. Randomize Timer()
    
  397. Screenres 800, 600, 32
    
  398. Dim TKey As String
    
  399. Dim TKey1 As Ubyte
    
  400. Dim TKey2 As Ubyte
    
  401. Dim TFL As Ubyte = 0
    
  402. Dim T_Input As String
    
  403. Dim XFN As Integer
    
  404. G_MyNick = Command()
    
  405. If (G_MyNick = "") Or (Lcase(G_MyNick) = "setnick") Then
    
  406.     G_MyNick = ""
    
  407.     XFN = Freefile
    
  408.     Open "nickname.dat" For Binary As XFN
    
  409.     G_MyNick = Space(Lof(XFN))
    
  410.     Get #XFN, 1, G_MyNick
    
  411.     Close #XFN
    
  412.     
    
  413.     If (G_MyNick = "") Or (Lcase(Command()) = "setnick") Then
    
  414.         Cls()
    
  415.         Do
    
  416.             TKey = Inkey()
    
  417.             TKey1 = Asc(Left(TKey, 1))
    
  418.             TKey2 = Asc(Mid(TKey, 2, 1))
    
  419.             Select Case TKey1
    
  420.                 Case 0
    
  421.                 Case 8: If Len(T_Input) > 0 Then T_Input = Mid(T_Input, Len(T_Input) - 1)
    
  422.                 Case 27: End 0
    
  423.                 Case 10, 13
    
  424.                     If T_Input <> "" Then
    
  425.                         G_MyNick = T_Input
    
  426.                         Kill "nickname.dat"
    
  427.                         XFN = Freefile
    
  428.                         Open "nickname.dat" For Binary As XFN
    
  429.                         Print #XFN, G_MyNick;
    
  430.                         Close #XFN
    
  431.                         Exit Do
    
  432.                     End If
    
  433.                 Case 45, 46, 48 To 58, 65 To 90, 97 To 122 'azAZ09.-:
    
  434.                     T_Input += Chr(TKey1)
    
  435.             End Select
    
  436.             Screenlock()
    
  437.             Cls()
    
  438.             Print: Print
    
  439.             Print " Enter a Nickname u want to use!"
    
  440.             Print: Print "  [Exit with ESC]"
    
  441.             Print: Print "  Nickname: " & T_Input
    
  442.             Screenunlock()
    
  443.             Sleep 1, 1
    
  444.         Loop
    
  445.     End If
    
  446. End If
    
  447. G_Map = Imagecreate(800, 600, 32)
    
  448. With *Cast(FB.Image Ptr, G_Map)
    
  449.     G_MapSize = (.pitch * .height * 4) - 1
    
  450. End With
    
  451. G_MapWait = Imagecreate(800, 600, 32)
    
  452. G_MapRun = Imagecreate(800, 600, 32)
    
  453. G_MapDone = Imagecreate(800, 600, 32)
    
  454. G_MapFail = Imagecreate(800, 600, 32)
    
  455. Dim TPitchS As Uinteger = Cast(FB.Image Ptr, G_Map)->pitch
    
  456. G_MSG = "Verbindungsaufbau..."
    
  457. StatADD(ST_NetMSG, "[NET] " & G_MSG)
    
  458. DoDraw()
    
  459. 
    
  460. 
    
  461. Dim TRoomName() As String
    
  462. Dim TRoomMax() As Uinteger
    
  463. Dim TRoomUse() As Uinteger
    
  464. Dim TRoomFlags() As Uinteger
    
  465. Dim TRoomC As Uinteger
    
  466. Dim TMR As Integer
    
  467. Dim TMZ As Integer
    
  468. Dim TMB As Integer
    
  469. Dim TFree As Uinteger
    
  470. Dim TPass As String
    
  471. Dim RV As TSNEPlay_GURU_Enum
    
  472. RV = TSNEPlay_ClientConnect("mln.ath.cx", 43234, "", G_MyNick, "", 1, @TSNEPlay_StateChange)
    
  473. If RV <> TSNEPlay_GURU_NoError Then Screen 0: Print "[ERROR] " & TSNEPlay_GetGURUDesc(RV): Sleep: End -1
    
  474. Dim TSTE As TSNEPlay_State_Enum
    
  475. Do
    
  476.     TSTE = TSNEPlay_Client_GetState()
    
  477.     If TSTE < 0 Then
    
  478.         Screen 0
    
  479.         Select Case TSTE
    
  480.             Case TSNEPlay_STE_Full          : Print "[ERROR] Server full."
    
  481.             Case TSNEPlay_STE_NickInUse     : Print "[ERROR] Nickname in use."
    
  482.             Case TSNEPlay_STE_ServerPassErr : Print "[ERROR] Wrong server password."
    
  483.             Case Else                       : Print "[ERROR] Error while connecting or communicate to or with the server! RV:" & Str(TSTE)
    
  484.         End Select
    
  485.         Sleep
    
  486.         End -1
    
  487.     End If
    
  488.     If TSTE = TSNEPlay_STE_Ready Then Exit Do
    
  489.     G_MSG = TSNEPlay_GetStateDesc(TSTE)
    
  490.     DoDraw()
    
  491.     Sleep 10, 1
    
  492. Loop
    
  493. 
    
  494. RV = TSNEPlay_ClientSend_RoomList("RingelpietzOhneAnfassen", TRoomName(), TRoomMax(), TRoomUse(), TRoomFlags(), TRoomC)
    
  495. If RV <> TSNEPlay_GURU_NoError Then Screen 0: Print "[ERROR] " & TSNEPlay_GetGURUDesc(RV): Sleep: End -1
    
  496. Do
    
  497.     Getmouse(TMX, TMY, TMZ, TMB)
    
  498.     Screenlock()
    
  499.     DoDraw(0)
    
  500.     RV = TSNEPlay_GFX_RoomListIO(0, TMX - 150, TMY - 150, TMZ, TMB, Inkey(), 150, 150, 500, 300, TRoomName(), TRoomMax(), TRoomUse(), TRoomFlags(), TRoomC, TFree, TPass, 0)
    
  501.     Screenunlock()
    
  502.     Select Case RV
    
  503.         Case TSNEPlay_GURU_Abort
    
  504.             Print " (press any key to end app)": Sleep: Screen 0: TSNEPlay_ClientClose(): End 0
    
  505.             
    
  506.         Case TSNEPlay_GURU_OK
    
  507.             RV = TSNEPlay_ClientSend_RoomJoin("RingelpietzOhneAnfassen", TFree, TPass)
    
  508.             Select Case RV
    
  509.                 Case TSNEPlay_GURU_NoError
    
  510.                 Case TSNEPlay_GURU_GameNotExist : Screen 0: Print "[ERROR] Game not exist.": Sleep: End -1
    
  511.                 Case TSNEPlay_GURU_Full         : Screen 0: Print "[ERROR] Room full.": Sleep: End -1
    
  512.                 Case Else: Screen 0: Print "[ERROR] " & TSNEPlay_GetGURUDesc(RV): Sleep: End -1
    
  513.             End Select
    
  514.             Exit Do
    
  515.             
    
  516.     End Select
    
  517.     Sleep 10, 1
    
  518. Loop
    
  519. TSNEPlay_Client_SetCallback(@TSNEPlay_UserChange, @TSNEPlay_Get_Message, @TSNEPlay_Get_MoveInt, , @TSNEPlay_Get_Data)
    
  520. G_MSG = "waiting for server..."
    
  521. Setmouse , , 0
    
  522. Dim TLState As Uinteger
    
  523. Do
    
  524.     Mutexlock(G_Mutex)
    
  525.     If Inkey() = Chr(27) Then
    
  526.         If G_State <> 10 Then
    
  527.             Mutexunlock(G_Mutex)
    
  528.             Exit Do
    
  529.         Else: G_State = 12
    
  530.         End If
    
  531.     End If
    
  532.     TMR = Getmouse(TMX, TMY, TMZ, TMB)
    
  533.     If TMR <> - 1 Then
    
  534.         If TMX < 0 Then TMX = 0
    
  535.         If TMY < 0 Then TMY = 0
    
  536.         If TMX >= 800 Then TMX = 799
    
  537.         If TMY >= 600 Then TMY = 599
    
  538. '       If TMB = 1 then G_State = 10: DoDraw()
    
  539.         Select Case G_State
    
  540.             Case 0
    
  541.             Case 1
    
  542.             
    
  543.             Case 2
    
  544.                 If (*Cast(Uinteger Ptr, (Cast(Ubyte Ptr, G_Map) + Sizeof(FB.Image) + TMY * TPitchS + TMX * 4)) And &H00FFFFFF) = &H8080FF Then
    
  545.                     G_State = 3
    
  546.                     G_MSG = "Warte hier bis die anderen auch Fertig sind!"
    
  547.                 End If
    
  548.                 
    
  549.             Case 3
    
  550.                 If (*Cast(Uinteger Ptr, (Cast(Ubyte Ptr, G_Map) + Sizeof(FB.Image) + TMY * TPitchS + TMX * 4)) And &H00FFFFFF) <> &H8080FF Then
    
  551.                     G_State = 2
    
  552.                     G_MSG = "Begib dich zum BLAUEM Ausgangspunkt!"
    
  553.                 End If
    
  554.                 
    
  555.             Case 5 To 9
    
  556.                 G_MSG = " -!- ACHTUNG --- In " & Str(5 - (G_State - 4)) & "sec. geht es los! --- ACHTUNG -!- "
    
  557.                 
    
  558.             Case 10
    
  559.                 If G_State <> TLState Then
    
  560.                     If (*Cast(Uinteger Ptr, (Cast(Ubyte Ptr, G_Map) + Sizeof(FB.Image) + TMY * TPitchS + TMX * 4)) And &H00FFFFFF) <> &H8080FF Then
    
  561.                         G_State = 12
    
  562.                         G_MSG = "Das ist nicht der Startpunkt! Du bist drausen!"
    
  563.                         TSNEPlay_ClientSend_Data(Chr(G_State), G_ServerNick)
    
  564.                     End If
    
  565.                 Else
    
  566.                     Select Case (*Cast(Uinteger Ptr, (Cast(Ubyte Ptr, G_Map) + Sizeof(FB.Image) + TMY * TPitchS + TMX * 4)) And &H00FFFFFF)
    
  567.                         Case &H00FF00FF
    
  568.                             G_State = 12
    
  569.                             G_MSG = "Du bist drausen!"
    
  570.                             TSNEPlay_ClientSend_Data(Chr(G_State), G_ServerNick)
    
  571.                             
    
  572.                         Case &H00FF0000
    
  573.                             G_State = 11
    
  574.                             G_MSG = "FERTIG! Warte auf die anderen!"
    
  575.                             TSNEPlay_ClientSend_Data(Chr(G_State), G_ServerNick)
    
  576.                             
    
  577.                     End Select
    
  578.                 End If
    
  579.         End Select
    
  580.     End If
    
  581.     TLState = G_State
    
  582.     Mutexunlock(G_Mutex)
    
  583.     If (TMR <> - 1) And ((TMXL <> TMX) Or (TMYL <> TMY)) Then
    
  584.         TSNEPlay_ClientSend_Move(TMX, TMY)
    
  585.         TMXL = TMX
    
  586.         TMYL = TMY
    
  587.     End If
    
  588.     If G_State = 10 Then
    
  589.         Mutexlock(G_Mutex)
    
  590.         Pset G_MapRun, (TMX, TMY), &H0000FF00
    
  591.         Mutexunlock(G_Mutex)
    
  592.     Else
    
  593.         StatDELCheck()
    
  594.     End If
    
  595.     DoDraw()
    
  596.     'Print TMR; " "; TMX; " "; TMY; " "; TMZ; " "; TMB
    
  597.     Sleep 1, 1
    
  598. Loop
    
  599. G_MSG = "Verbindungsabbau..."
    
  600. StatADD(ST_NetMSG, "[NET] " & G_MSG)
    
  601. DoDraw()
    
  602. RV = TSNEPlay_ClientClose()
    
  603. Imagedestroy(G_MapFail)
    
  604. Imagedestroy(G_MapDone)
    
  605. Imagedestroy(G_MapWait)
    
  606. Imagedestroy(G_Map)
    
  607. Setmouse , , 1
    
  608. Screen 0
    
  609. Mutexdestroy(G_Mutex)
    
  610. End Sub
    
  611. 
    
  612. 
    
  613. 
    
  614. '##############################################################################################################
    
  615. Main()
    
  616. End 0
    
  617. 
    
  618. 
    
  619.