Home

Add

Edit

Without Linenumbers

Code in Textfield

Download

  1. '####################################################################################################################################################
    
  2. '####################################################################################################################################################
    
  3. ' EGNP_V1 - Easy Game Net Play Version: (see line 19 till 21)
    
  4. '####################################################################################################################################################
    
  5. '####################################################################################################################################################
    
  6. ' (c) 2013-.... By.: /_\ DeltaLab's Germany - Experimental Computing
    
  7. ' Autor: Martin Wiemann
    
  8. ' IRC: IRC://DeltaLabs.de/#mln
    
  9. ' Idea: 2013.12.31
    
  10. '####################################################################################################################################################
    
  11. ' Free for NON-comercial use. Using the DeltaLab's Server for comercial use is NOT allowed! Mail me if u need more licences: fb@deltalabs.de
    
  12. '####################################################################################################################################################
    
  13. 
    
  14. 
    
  15. 
    
  16. '####################################################################################################################################################
    
  17. #IFNDEF _EGNP_
    
  18.     #DEFINE _EGNP_
    
  19.     #DEFINE EGNP_Version 1.0
    
  20.     #DEFINE EGNP_VersionDate 20140123
    
  21.     #DEFINE EGNP_VersionFull 1.0_20140123 (0.90.1 07-17-2013)
    
  22. '>...
    
  23. #DEFINE EGNP_INT_PubServerHost "deltalabs.de"
    
  24. #DEFINE EGNP_INT_PubServerPort 6007
    
  25. 
    
  26. #DEFINE TSNE_DEF_REUSER
    
  27. #DEFINE TSNE_SUBCALLBACK
    
  28. #DEFINE TSNE_FastEventThread
    
  29. #INCLUDE Once "TSNE_V3.bi"
    
  30. #IF TSNE_VersionDate < 20131223
    
  31.     #ERROR Wrong TSNE-Version! Too old! U need 3.7_20131223 Or higer!
    
  32. #ENDIF
    
  33. 
    
  34. 
    
  35. 
    
  36. '####################################################################################################################################################
    
  37. ' === TODO ===
    
  38. 'highscores
    
  39. 
    
  40. 
    
  41. 
    
  42. '####################################################################################################################################################
    
  43. Enum EGNP_GURU_Enum
    
  44.     EGNP_GURU_Unknown                           = 0
    
  45.     EGNP_GURU_NoError                           = 1
    
  46.     EGNP_GURU_NoErrorCreateAccount              = 2
    
  47.     
    
  48.     EGNP_GURU_ParameterError                    = -1000
    
  49.     EGNP_GURU_IDnotFound                        = -1001
    
  50.     EGNP_GURU_NothingSelected                   = -1002
    
  51. 
    
  52.     EGNP_GURU_InternalError                     = -1900
    
  53.     EGNP_GURU_DATALenError                      = -1901
    
  54.     EGNP_GURU_Timeout                           = -1902
    
  55.     EGNP_GURU_UnknownCMD                        = -1903
    
  56.     EGNP_GURU_CantConnect                       = -1904
    
  57.     EGNP_GURU_ExternalError                     = -1905
    
  58.     EGNP_GURU_CantOpenFile                      = -1906
    
  59.     EGNP_GURU_TransmissionError                 = -1907
    
  60.     EGNP_GURU_ParseLenError                     = -1908
    
  61.     
    
  62.     EGNP_GURU_LoginDenied                       = -1920
    
  63.     EGNP_GURU_NickDenied                        = -1921
    
  64.     EGNP_GURU_CommandDenied                     = -1922
    
  65.     EGNP_GURU_UsernameDenied                    = -1923
    
  66. End Enum
    
  67. 
    
  68. 
    
  69. 
    
  70. '####################################################################################################################################################
    
  71. Enum EGNP_INT_CMD_Enum
    
  72.     EGNP_CMD_Unknown                            = 0
    
  73.     EGNP_CMD_NoError                            = 1
    
  74.     
    
  75.     EGNP_CMD_ServerUnavaible                    = 1100
    
  76.     EGNP_CMD_ServerOffline                      = 1101
    
  77.     EGNP_CMD_ServerFull                         = 1102
    
  78.     EGNP_CMD_ServerConnectionDenied             = 1103
    
  79. 
    
  80.     EGNP_CMD_Ping                               = 1190
    
  81.     EGNP_CMD_Pong                               = 1191
    
  82.     
    
  83.     EGNP_CMD_Crypt1                             = 1200
    
  84.     EGNP_CMD_Crypt2                             = 1201
    
  85.     EGNP_CMD_Crypt3                             = 1202
    
  86.     EGNP_CMD_Ident                              = 1203
    
  87.     EGNP_CMD_ServerAlternative                  = 1204
    
  88.     EGNP_CMD_ServerList                         = 1205
    
  89.     EGNP_CMD_ServerListAdd                      = 1206
    
  90.     EGNP_CMD_ServerListReady                    = 1207
    
  91.     EGNP_CMD_ServerListUpdate                   = 1208
    
  92.     
    
  93.     EGNP_CMD_AccCreate                          = 1210
    
  94.     EGNP_CMD_AccDestroy                         = 1211
    
  95.     EGNP_CMD_AccLogin                           = 1212
    
  96.     EGNP_CMD_AccList                            = 1213
    
  97.     EGNP_CMD_AccSetFlags                        = 1214
    
  98.     EGNP_CMD_AccSetNick                         = 1215
    
  99.     EGNP_CMD_AccSetPass                         = 1216
    
  100.     
    
  101.     EGNP_CMD_Ready                              = 1300
    
  102.     
    
  103.     EGNP_CMD_UserLeave                          = 1400
    
  104.     EGNP_CMD_UserKick                           = 1401
    
  105.     EGNP_CMD_UserJoin                           = 1402
    
  106.     EGNP_CMD_UserMessage                        = 1403
    
  107.     EGNP_CMD_UserData                           = 1404
    
  108.     EGNP_CMD_UserMoveDbl                        = 1405
    
  109.     EGNP_CMD_UserMoveInt                        = 1406
    
  110.     
    
  111.     EGNP_CMD_ScoreList                          = 1420
    
  112.     EGNP_CMD_ScoreAdd                           = 1421
    
  113.     
    
  114. End Enum
    
  115. 
    
  116. 
    
  117. 
    
  118. '####################################################################################################################################################
    
  119. Dim Shared EGNP_INT_Mux                         As Any Ptr
    
  120. 
    
  121. 
    
  122. 
    
  123. '####################################################################################################################################################
    
  124. Enum EGNP_INT_AccountAction_Enum
    
  125.     EGNP_AAE_Unknown                            = 0
    
  126.     EGNP_AAE_Login
    
  127.     EGNP_AAE_Create
    
  128.     EGNP_AAE_Destroy
    
  129.     EGNP_AAE_SetFlags
    
  130. End Enum
    
  131. 
    
  132. 
    
  133. 
    
  134. '####################################################################################################################################################
    
  135. Enum EGNP_INT_UserState_Enum
    
  136.     EGNP_USE_Unknown                            = 0
    
  137.     EGNP_USE_Leave
    
  138.     EGNP_USE_Kicked
    
  139.     EGNP_USE_Join
    
  140. End Enum
    
  141. 
    
  142. 
    
  143. 
    
  144. '####################################################################################################################################################
    
  145. Enum EGNP_INT_ClientState_Enum
    
  146.     EGNP_CSE_Unknown                            = 0
    
  147.     EGNP_CSE_Disconnected                       = &B00001000
    
  148.     EGNP_CSE_DisconnectedTimeout                = &B00001001
    
  149.     EGNP_CSE_DisconnectedUnavaible              = &B00001011
    
  150.     EGNP_CSE_DisconnectedFull                   = &B00001100
    
  151.     EGNP_CSE_DisconnectedConnectionDenied       = &B00001101
    
  152.     EGNP_CSE_Connecting                         = &B00010000
    
  153.     EGNP_CSE_Connected                          = &B00010001
    
  154.     EGNP_CSE_Ident                              = &B00100000
    
  155.     EGNP_CSE_Login                              = &B01000000
    
  156.     EGNP_CSE_Ready                              = &B10000000
    
  157. End Enum
    
  158. 
    
  159. 
    
  160. 
    
  161. '####################################################################################################################################################
    
  162. Enum EGNP_MessageType_Enum
    
  163.     EGNP_MTE_Regular                            = 0
    
  164.     EGNP_MTE_Private
    
  165.     EGNP_MTE_Notice
    
  166.     EGNP_MTE_Hightlighted
    
  167. End Enum
    
  168. 
    
  169. 
    
  170. 
    
  171. '####################################################################################################################################################
    
  172. Enum EGNP_AccountPermissions_Enum
    
  173.     EGNP_APE_AnonymouseUser                     = &B00000000000000000000000000000000
    
  174.     EGNP_APE_Registered                         = &B00000000000000000000000000000001
    
  175.     EGNP_APE_Banned                             = &B00000000000000000000000000000010
    
  176.     EGNP_APE_Owner                              = &B00000000000000000000000000010000
    
  177.     EGNP_APE_Moderator                          = &B00000000000000000000000000100000
    
  178.     EGNP_APE_SuperModerator                     = &B00000000000000000000000001000000
    
  179.     EGNP_APE_Administrator                      = &B00000000000000000000000010000000
    
  180. End Enum
    
  181. 
    
  182. 
    
  183. 
    
  184. '####################################################################################################################################################
    
  185. Type EGNP_Callback_Type
    
  186.     V_StateConnection                           As Sub  (V_ClientID As Uinteger, V_State As EGNP_INT_ClientState_Enum)
    
  187.     V_StateUser                                 As Sub  (V_UserID As Uinteger, V_State As EGNP_INT_UserState_Enum, Byref RV_MyPtr As Any Ptr)
    
  188.     V_Message                                   As Sub  (V_FromUserID As Uinteger, V_ToUserID As Uinteger, Byref V_Message As String, V_MessageType As EGNP_MessageType_Enum, Byref RV_FromMyPtr As Any Ptr, Byref RV_ToMyPtr As Any Ptr)
    
  189.     V_Data                                      As Sub  (V_FromUserID As Uinteger, V_ToUserID As Uinteger, Byref V_Data As String, Byref RV_FromMyPtr As Any Ptr, Byref RV_ToMyPtr As Any Ptr)
    
  190.     V_MoveDbl                                   As Sub  (V_FromUserID As Uinteger, V_ToUserID As Uinteger, V_X As Double, V_Y As Double, V_Z As Double, V_Int As Integer, Byref RV_FromMyPtr As Any Ptr, Byref RV_ToMyPtr As Any Ptr)
    
  191.     V_MoveInt                                   As Sub  (V_FromUserID As Uinteger, V_ToUserID As Uinteger, V_X As Integer, V_Y As Integer, V_Z As Integer, V_Int As Integer, Byref RV_FromMyPtr As Any Ptr, Byref RV_ToMyPtr As Any Ptr)
    
  192.     
    
  193.     V_Server_ConnectionRequest                  As Sub  (V_ServerID As Uinteger, V_IPA As String, Byref R_Cancel As Integer)
    
  194.     V_Server_StateUser                          As Sub  (V_ServerID As Uinteger, V_UserID As Uinteger, V_State As EGNP_INT_UserState_Enum, Byref RV_MyPtr As Any Ptr, Byref R_Cancel As Integer)
    
  195.     V_Server_AccountAction                      As Sub  (V_ServerID As Uinteger, V_UserID As Uinteger, V_Action As EGNP_INT_AccountAction_Enum, Byref V_Username As String, Byref RV_UserFlags As EGNP_AccountPermissions_Enum, Byref RV_MyPtr As Any Ptr, Byref R_Cancel As Integer)
    
  196.     V_Server_Message                            As Sub  (V_ServerID As Uinteger, V_FromUserID As Uinteger, V_ToUserID As Uinteger, Byref V_Message As String, V_MessageType As EGNP_MessageType_Enum, Byref RV_FromMyPtr As Any Ptr, Byref RV_ToMyPtr As Any Ptr, Byref R_Cancel As Integer)
    
  197.     V_Server_Data                               As Sub  (V_ServerID As Uinteger, V_FromUserID As Uinteger, V_ToUserID As Uinteger, Byref V_Data As String, Byref RV_FromMyPtr As Any Ptr, Byref RV_ToMyPtr As Any Ptr, Byref R_Cancel As Integer)
    
  198.     V_Server_MoveDbl                            As Sub  (V_ServerID As Uinteger, V_FromUserID As Uinteger, V_ToUserID As Uinteger, V_X As Double, V_Y As Double, V_Z As Double, V_Int As Integer, Byref RV_FromMyPtr As Any Ptr, Byref RV_ToMyPtr As Any Ptr, Byref R_Cancel As Integer)
    
  199.     V_Server_MoveInt                            As Sub  (V_ServerID As Uinteger, V_FromUserID As Uinteger, V_ToUserID As Uinteger, V_X As Integer, V_Y As Integer, V_Z As Integer, V_Int As Integer, Byref RV_FromMyPtr As Any Ptr, Byref RV_ToMyPtr As Any Ptr, Byref R_Cancel As Integer)
    
  200. End Type
    
  201. 
    
  202. 
    
  203. 
    
  204. '####################################################################################################################################################
    
  205. Enum EGNP_ServerFlags_Enum
    
  206.     EGNP_SFE_Serverpass                         = &B00000000000000000000000000000001
    
  207.     EGNP_SFE_Account                            = &B00000000000000000000000000000010
    
  208. End Enum
    
  209. 
    
  210. 
    
  211. 
    
  212. '####################################################################################################################################################
    
  213. Type EGNP_User_Type
    
  214.     V_Next                                      As EGNP_User_Type Ptr
    
  215.     V_Prev                                      As EGNP_User_Type Ptr
    
  216.     
    
  217.     V_ClientID                                  As Uinteger
    
  218.     V_Nickname                                  As String
    
  219.     V_UserFlags                                 As EGNP_AccountPermissions_Enum
    
  220.     V_MyPtr                                     As Any Ptr
    
  221. End Type
    
  222. 
    
  223. 
    
  224. 
    
  225. '####################################################################################################################################################
    
  226. Type EGNP_INT_ClientAnswer_Type
    
  227.     V_Next                                      As EGNP_INT_ClientAnswer_Type Ptr
    
  228.     V_Prev                                      As EGNP_INT_ClientAnswer_Type Ptr
    
  229.     
    
  230.     V_TimeOut                                   As Double
    
  231.     V_Serial                                    As Double
    
  232.     V_CMD                                       As EGNP_INT_CMD_Enum
    
  233.     V_Answer                                    As String
    
  234. End Type
    
  235. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  236. Type EGNP_INT_Client_Type
    
  237.     V_Next                                      As EGNP_INT_Client_Type Ptr
    
  238.     V_Prev                                      As EGNP_INT_Client_Type Ptr
    
  239.     
    
  240.     V_TSNEIDTCP                                 As Uinteger
    
  241.     V_TSNEIDUDPRX                               As Uinteger
    
  242.     V_TSNEIDUDPTX                               As Uinteger
    
  243.     
    
  244.     V_DataTCP                                   As String
    
  245.     V_DataUDP                                   As String
    
  246.     
    
  247.     V_Callbacks                                 As EGNP_Callback_Type
    
  248.     V_State                                     As EGNP_INT_ClientState_Enum
    
  249.     V_LCMD                                      As EGNP_INT_CMD_Enum
    
  250.     
    
  251.     V_Host                                      As String
    
  252.     V_PortTCP                                   As Ushort
    
  253.     V_PortUDP                                   As Ushort
    
  254.     V_Nickname                                  As String
    
  255.     V_PasswordServer                            As String
    
  256.     V_Username                                  As String
    
  257.     V_Password                                  As String
    
  258.     V_AutoReconnect                             As Integer
    
  259.     
    
  260.     V_ServerName                                As String
    
  261.     V_ServerDescription                         As String
    
  262.     V_ServerMaxPlayer                           As Ushort
    
  263.     V_ServerPublic                              As Integer
    
  264.     V_ServerUseServerPass                       As Integer
    
  265.     V_ServerUseAccount                          As Integer
    
  266.     
    
  267.     V_CryptKeyRX                                As String
    
  268.     V_CryptKeyTX                                As String
    
  269.     
    
  270.     V_MyID                                      As Uinteger
    
  271.     
    
  272.     V_UserF                                     As EGNP_User_Type Ptr
    
  273.     V_UserL                                     As EGNP_User_Type Ptr
    
  274.     
    
  275.     V_AnswerF                                   As EGNP_INT_ClientAnswer_Type Ptr
    
  276.     V_AnswerL                                   As EGNP_INT_ClientAnswer_Type Ptr
    
  277.     
    
  278. '   V_LSerialMsg                                as ULongInt
    
  279. '   V_LSerialDat                                as ULongInt
    
  280. '   V_LSerialDbl                                as ULongInt
    
  281. '   V_LSerialInt                                as ULongInt
    
  282. End Type
    
  283. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  284. Dim Shared EGNP_INT_Client_F                    As EGNP_INT_Client_Type Ptr
    
  285. Dim Shared EGNP_INT_Client_L                    As EGNP_INT_Client_Type Ptr
    
  286. 
    
  287. 
    
  288. 
    
  289. '####################################################################################################################################################
    
  290. Type EGNP_INT_Server_Type_ As EGNP_INT_Server_Type
    
  291. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  292. Type EGNP_INT_ServerClient_Type
    
  293.     V_Next                                      As EGNP_INT_ServerClient_Type Ptr
    
  294.     V_Prev                                      As EGNP_INT_ServerClient_Type Ptr
    
  295.     
    
  296.     V_Server                                    As EGNP_INT_Server_Type_ Ptr
    
  297.     
    
  298.     V_TSNEID                                    As Uinteger
    
  299.     V_TimeCon                                   As Double
    
  300.     V_TimeOut                                   As Double
    
  301.     V_TimePing                                  As Double
    
  302.     V_IPA                                       As String
    
  303.     
    
  304.     V_PingC                                     As Integer
    
  305.     V_DataTCP                                   As String
    
  306.     V_DataUDP                                   As String
    
  307.     
    
  308.     V_State                                     As EGNP_INT_ClientState_Enum
    
  309.     
    
  310.     V_Nickname                                  As String
    
  311.     V_NicknameL                                 As String
    
  312.     V_Username                                  As String
    
  313.     V_UserFlags                                 As EGNP_AccountPermissions_Enum
    
  314.     V_MyPtr                                     As Any Ptr
    
  315.     
    
  316.     V_PPKLen                                    As Integer
    
  317.     V_PPKPri                                    As String
    
  318.     V_PPKPub                                    As String
    
  319.     V_PPKSum                                    As String
    
  320.     V_PPKMix                                    As String
    
  321.     V_CryptKeyRX                                As String
    
  322.     V_CryptKeyTX                                As String
    
  323. End Type
    
  324. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  325. Type EGNP_Account_Type
    
  326.     V_ClientID                                  As Uinteger
    
  327.     V_Username                                  As String
    
  328.     V_Nickname                                  As String
    
  329.     V_UserFlags                                 As EGNP_AccountPermissions_Enum
    
  330. End Type
    
  331. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  332. Type EGNP_INT_Account_Type
    
  333.     V_Next                                      As EGNP_INT_Account_Type Ptr
    
  334.     V_Prev                                      As EGNP_INT_Account_Type Ptr
    
  335.     
    
  336.     V_Username                                  As String
    
  337.     V_UsernameL                                 As String
    
  338.     V_Password                                  As String
    
  339.     V_Nickname                                  As String
    
  340.     V_UserFlags                                 As EGNP_AccountPermissions_Enum
    
  341. End Type
    
  342. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  343. Type EGNP_INT_Server_Type
    
  344.     V_Next                                      As EGNP_INT_Server_Type Ptr
    
  345.     V_Prev                                      As EGNP_INT_Server_Type Ptr
    
  346.     
    
  347.     V_CreateTime                                As Double
    
  348.     
    
  349.     V_GameName                                  As String
    
  350.     V_GameVersion                               As Uinteger
    
  351.     
    
  352.     V_PortTCP                                   As Ushort
    
  353.     V_PortUDP                                   As Ushort
    
  354.     
    
  355.     V_Callbacks                                 As EGNP_Callback_Type
    
  356.     V_Password                                  As String
    
  357.     V_MaxPlayer                                 As Ushort
    
  358.     V_Public                                    As Integer
    
  359.     V_UseAccounts                               As Integer
    
  360.     V_Name                                      As String
    
  361.     V_Description                               As String
    
  362.     
    
  363.     V_AccountF                                  As EGNP_INT_Account_Type Ptr
    
  364.     V_AccountL                                  As EGNP_INT_Account_Type Ptr
    
  365.     V_AccountFile                               As String
    
  366.     
    
  367.     V_ClientF                                   As EGNP_INT_ServerClient_Type Ptr
    
  368.     V_ClientL                                   As EGNP_INT_ServerClient_Type Ptr
    
  369.     V_ClientC                                   As Uinteger
    
  370.     
    
  371.     V_Enabled                                   As Integer
    
  372.     
    
  373.     V_PublicUpdate                              As Integer
    
  374.     V_PublicKey                                 As String
    
  375.     V_PublicTime                                As Double
    
  376.     
    
  377.     V_TSNEIDTCP                                 As Uinteger
    
  378.     V_TSNEIDUDPRX                               As Uinteger
    
  379.     V_TSNEIDUDPTX                               As Uinteger
    
  380.     
    
  381. End Type
    
  382. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  383. Dim Shared EGNP_INT_Server_F                    As EGNP_INT_Server_Type Ptr
    
  384. Dim Shared EGNP_INT_Server_L                    As EGNP_INT_Server_Type Ptr
    
  385. 
    
  386. 
    
  387. 
    
  388. '####################################################################################################################################################
    
  389. Type EGNP_INT_PublicServer_Type
    
  390.     V_Next                                      As EGNP_INT_PublicServer_Type Ptr
    
  391.     V_Prev                                      As EGNP_INT_PublicServer_Type Ptr
    
  392.     V_IPA                                       As String
    
  393.     V_Port                                      As Ushort
    
  394.     V_GameName                                  As String
    
  395.     V_GameVersion                               As Uinteger
    
  396.     V_Name                                      As String
    
  397.     V_Desc                                      As String
    
  398.     V_Flags                                     As EGNP_ServerFlags_Enum
    
  399.     V_PlayerMax                                 As Uinteger
    
  400.     V_PlayerCur                                 As Uinteger
    
  401. End Type
    
  402. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  403. Dim Shared EGNP_INT_ServerPubSLF                As EGNP_INT_PublicServer_Type Ptr
    
  404. Dim Shared EGNP_INT_ServerPubSLL                As EGNP_INT_PublicServer_Type Ptr
    
  405. Dim Shared EGNP_INT_ServerPubSLTime             As Double
    
  406. Dim Shared EGNP_INT_ServerPubTSNEID             As Uinteger
    
  407. Dim Shared EGNP_INT_ServerPubData               As String
    
  408. Dim Shared EGNP_INT_ServerPubThread             As Any Ptr
    
  409. Dim Shared EGNP_INT_ServerPubExit               As Integer
    
  410. 
    
  411. 
    
  412. 
    
  413. '####################################################################################################################################################
    
  414. Dim Shared EGNP_INT_CMDSerial                   As Double
    
  415. 
    
  416. 
    
  417. 
    
  418. '####################################################################################################################################################
    
  419. Function EGNP_INT_GETCMDDESC(V_CMDCode As Integer) As String
    
  420. Select Case V_CMDCode
    
  421.     Case EGNP_GURU_Unknown                          : Return "[    0] UNKNOWN"
    
  422.     Case EGNP_GURU_NoError                          : Return "[    1] E-NO   "
    
  423.     Case EGNP_GURU_ParameterError                   : Return "[-1000] E-PARAM"
    
  424.     Case EGNP_GURU_IDnotFound                       : Return "[-1001] IDnotFo"
    
  425.     Case EGNP_GURU_NothingSelected                  : Return "[-1002] NotiSel"
    
  426.     Case EGNP_GURU_InternalError                    : Return "[-1900] E-INT  "
    
  427.     Case EGNP_GURU_DATALenError                     : Return "[-1901] E-DATLE"
    
  428.     Case EGNP_GURU_Timeout                          : Return "[-1902] TIMEOUT"
    
  429.     Case EGNP_GURU_UnknownCMD                       : Return "[-1903] UnkoCMD"
    
  430.     Case EGNP_GURU_CantConnect                      : Return "[-1904] CantCon"
    
  431.     Case EGNP_GURU_ExternalError                    : Return "[-1905] E-EXT  "
    
  432.     Case EGNP_GURU_CantOpenFile                     : Return "[-1906] CantOpe"
    
  433.     Case EGNP_GURU_TransmissionError                : Return "[-1907] E-Trans"
    
  434.     Case EGNP_GURU_ParseLenError                    : Return "[-1908] E-PaLen"
    
  435.     Case EGNP_GURU_LoginDenied                      : Return "[-1910] Log-Den"
    
  436.     Case EGNP_GURU_NickDenied                       : Return "[-1911] Nic-Den"
    
  437.     Case EGNP_GURU_CommandDenied                    : Return "[-1912] CMD-Den"
    
  438.     Case EGNP_CMD_ServerUnavaible                   : Return "[ 1100] Unavaib"
    
  439.     Case EGNP_CMD_ServerOffline                     : Return "[ 1101] Offline"
    
  440.     Case EGNP_CMD_ServerFull                        : Return "[ 1102] Full   "
    
  441.     Case EGNP_CMD_ServerConnectionDenied            : Return "[ 1103] Con-Den"
    
  442.     Case EGNP_CMD_Ping                              : Return "[ 1190] PING   "
    
  443.     Case EGNP_CMD_Pong                              : Return "[ 1191] PONG   "
    
  444.     Case EGNP_CMD_Crypt1                            : Return "[ 1200] Crypt-1"
    
  445.     Case EGNP_CMD_Crypt2                            : Return "[ 1201] Crypt-2"
    
  446.     Case EGNP_CMD_Crypt3                            : Return "[ 1202] Crypt-3"
    
  447.     Case EGNP_CMD_Ident                             : Return "[ 1203] Ident  "
    
  448.     Case EGNP_CMD_ServerAlternative                 : Return "[ 1204] SerAlt "
    
  449.     Case EGNP_CMD_ServerList                        : Return "[ 1205] SerL   "
    
  450.     Case EGNP_CMD_ServerListAdd                     : Return "[ 1206] SerLAdd"
    
  451.     Case EGNP_CMD_ServerListReady                   : Return "[ 1207] SerLRed"
    
  452.     Case EGNP_CMD_ServerListUpdate                  : Return "[ 1208] SerLUpd"
    
  453.     Case EGNP_CMD_AccCreate                         : Return "[ 1210] AccCrea"
    
  454.     Case EGNP_CMD_AccDestroy                        : Return "[ 1211] AccDest"
    
  455.     Case EGNP_CMD_AccLogin                          : Return "[ 1212] AccLogi"
    
  456.     Case EGNP_CMD_AccList                           : Return "[ 1213] AccList"
    
  457.     Case EGNP_CMD_AccSetFlags                       : Return "[ 1213] AccSFla"
    
  458.     Case EGNP_CMD_AccSetNick                        : Return "[ 1213] AccNick"
    
  459.     Case EGNP_CMD_AccSetPass                        : Return "[ 1213] AccPass"
    
  460.     Case EGNP_CMD_Ready                             : Return "[ 1300] Ready  "
    
  461.     Case EGNP_CMD_UserLeave                         : Return "[ 1400] UsrLeav"
    
  462.     Case EGNP_CMD_UserKick                          : Return "[ 1401] UsrKick"
    
  463.     Case EGNP_CMD_UserJoin                          : Return "[ 1402] UsrJoin"
    
  464.     Case EGNP_CMD_UserMessage                       : Return "[ 1403] UsrMsg "
    
  465.     Case EGNP_CMD_UserData                          : Return "[ 1404] UsrData"
    
  466.     Case EGNP_CMD_UserMoveDbl                       : Return "[ 1405] UsrMDbl"
    
  467.     Case EGNP_CMD_UserMoveInt                       : Return "[ 1406] UsrMInt"
    
  468.     Case EGNP_CMD_ScoreList                         : Return "[ 1420] ScorLis"
    
  469.     Case EGNP_CMD_ScoreAdd                          : Return "[ 1421] ScorAdd"
    
  470.     Case Else                                       : Return "[" & Space(5 - Len(Str(V_CMDCode))) & Str(V_CMDCode) & "        "
    
  471. End Select
    
  472. End Function
    
  473. 
    
  474. 
    
  475. 
    
  476. '####################################################################################################################################################
    
  477. Function EGNP_GetGURUDescription(V_GURU As EGNP_GURU_Enum) As String
    
  478. Select Case V_GURU
    
  479.     Case EGNP_GURU_ParameterError               : Return "Parametererror"
    
  480.     Case EGNP_GURU_IDnotFound                   : Return "ID not found"
    
  481.     Case EGNP_GURU_NothingSelected              : Return "Nothing selected"
    
  482. 
    
  483.     Case EGNP_GURU_InternalError                : Return "Internal error"
    
  484.     Case EGNP_GURU_DATALenError                 : Return "DATALEN error"
    
  485.     Case EGNP_GURU_Timeout                      : Return "Timeout"
    
  486.     Case EGNP_GURU_UnknownCMD                   : Return "Unknown CMD"
    
  487.     Case EGNP_GURU_ParseLenError                : Return "PARAMETERDATALEN error"
    
  488. 
    
  489.     Case EGNP_CMD_ServerUnavaible               : Return "Server unavaible"
    
  490.     Case EGNP_CMD_ServerOffline                 : Return "Server offline"
    
  491.     Case EGNP_CMD_ServerFull                    : Return "Server full"
    
  492.     Case EGNP_GURU_CantConnect                  : Return "Can't connect"
    
  493.     
    
  494.     Case EGNP_GURU_ExternalError                : Return "External error"
    
  495.     Case EGNP_GURU_CantOpenFile                 : Return "Can't open file"
    
  496.     Case EGNP_GURU_TransmissionError            : Return "Transmission error"
    
  497.     
    
  498.     Case EGNP_GURU_LoginDenied                  : Return "Login denied"
    
  499.     Case EGNP_GURU_NickDenied                   : Return "Nickname in use or not allowed to use"
    
  500.     Case EGNP_GURU_CommandDenied                : Return "Command denied"
    
  501.     Case EGNP_GURU_UsernameDenied               : Return "Username in use or not allowed to use"
    
  502.     
    
  503.     Case EGNP_CMD_ServerUnavaible               : Return "Server unavaible"
    
  504.     Case EGNP_CMD_ServerOffline                 : Return "Server offline"
    
  505.     Case EGNP_CMD_ServerFull                    : Return "Server full"
    
  506.     Case EGNP_CMD_ServerConnectionDenied        : Return "Connection denied"
    
  507.     Case Else: Return TSNE_GetGURUCode(V_GURU)
    
  508. End Select
    
  509. End Function
    
  510. 
    
  511. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  512. Function EGNP_GetConnectionStateDescription(V_State As EGNP_INT_ClientState_Enum) As String
    
  513. Select Case V_State
    
  514.     Case EGNP_CSE_Unknown                       : Return "Unknown."
    
  515.     Case EGNP_CSE_Disconnected                  : Return "Disconnected."
    
  516.     Case EGNP_CSE_DisconnectedTimeout           : Return "Disconnected. Timeout."
    
  517.     Case EGNP_CSE_DisconnectedUnavaible         : Return "Disconnected. Server unavaible."
    
  518.     Case EGNP_CSE_DisconnectedFull              : Return "Disconnected. Server full."
    
  519.     Case EGNP_CSE_DisconnectedConnectionDenied  : Return "Disconnected. Connection denied."
    
  520.     Case EGNP_CSE_Connecting                    : Return "Connecting..."
    
  521.     Case EGNP_CSE_Connected                     : Return "Connected!"
    
  522.     Case EGNP_CSE_Ready                         : Return "Ready!"
    
  523.     
    
  524.     Case Else: Return "Unknown connection state!"
    
  525. End Select
    
  526. End Function
    
  527. 
    
  528. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  529. Function EGNP_GetUserStateDescription(V_State As EGNP_INT_UserState_Enum) As String
    
  530. Select Case V_State
    
  531.     Case EGNP_USE_Unknown                       : Return "Unknown."
    
  532.     Case EGNP_USE_Leave                         : Return "Leave."
    
  533.     Case EGNP_USE_Kicked                        : Return "Kicked."
    
  534.     Case EGNP_USE_Join                          : Return "Join."
    
  535.     
    
  536.     Case Else: Return "Unknown user state!"
    
  537. End Select
    
  538. End Function
    
  539. 
    
  540. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  541. Function EGNP_GetAccountActionDescription(V_Action As EGNP_INT_AccountAction_Enum) As String
    
  542. Select Case V_Action
    
  543.     Case EGNP_AAE_Unknown                       : Return "Unknown."
    
  544.     Case EGNP_AAE_Login                         : Return "Login."
    
  545.     Case EGNP_AAE_Create                        : Return "Create."
    
  546.     Case EGNP_AAE_Destroy                       : Return "Destroy."
    
  547.     Case EGNP_AAE_SetFlags                      : Return "SetFlags."
    
  548.     
    
  549.     Case Else: Return "Unknown user state!"
    
  550. End Select
    
  551. End Function
    
  552. 
    
  553. 
    
  554. 
    
  555. '####################################################################################################################################################
    
  556. Function OSC_Crypt(Byval V_Username As String, Byval V_Passwort As String, Byval V_Rechte As String, Byval V_CryptDeep As Ubyte) As String
    
  557. Dim V As Integer
    
  558. Dim X As Integer
    
  559. Dim Y As Integer
    
  560. Dim Z As Integer
    
  561. Dim T As String
    
  562. Dim ASCIICode As Ubyte
    
  563. For V = 1 To V_CryptDeep
    
  564.     ASCIICode Xor= Cbyte((V_CryptDeep - V + 1) Mod 255)
    
  565.     For X = 1 To Len(V_Username)
    
  566.         ASCIICode Xor= V_Username[X - 1]
    
  567.         For Y = 1 To Len(V_Passwort)
    
  568.             ASCIICode Xor= V_Passwort[Y - 1]
    
  569.             If Len(V_Rechte) > 0 Then
    
  570.                 For Z = 1 To Len(V_Rechte)
    
  571.                     ASCIICode Xor= V_Rechte[Z - 1]
    
  572.                 Next
    
  573.             End If
    
  574.             T += Chr(ASCIICode)
    
  575.             ASCIICode Xor= Cbyte(X Mod 255)
    
  576.         Next
    
  577.     Next
    
  578. Next
    
  579. Return T
    
  580. End Function
    
  581. 
    
  582. 
    
  583. 
    
  584. '####################################################################################################################################################
    
  585. Function EGNP_INT_BuildCMD(V_CMD As EGNP_INT_CMD_Enum, V_Data As String = "") As String
    
  586. Dim TLen As Uinteger = 4 + Len(V_Data)
    
  587. Return Chr((TLen Shr 24) And 255, (TLen Shr 16) And 255, (TLen Shr 8) And 255, TLen And 255, (V_CMD Shr 24) And 255, (V_CMD Shr 16) And 255, (V_CMD Shr 8) And 255, V_CMD And 255) & V_Data
    
  588. End Function
    
  589. 
    
  590. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  591. Function EGNP_INT_BuildString(V_Data As String) As String
    
  592. Dim TLen As Uinteger = 4 + Len(V_Data)
    
  593. Return Chr((TLen Shr 24) And 255, (TLen Shr 16) And 255, (TLen Shr 8) And 255, TLen And 255) & V_Data
    
  594. End Function
    
  595. 
    
  596. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  597. Function EGNP_INT_BuildUShort(V_Data As Ushort) As String
    
  598. Return Chr((V_Data Shr 8) And 255, V_Data And 255)
    
  599. End Function
    
  600. 
    
  601. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  602. Function EGNP_INT_BuildUInteger(V_Data As Uinteger) As String
    
  603. Return Chr((V_Data Shr 24) And 255, (V_Data Shr 16) And 255, (V_Data Shr 8) And 255, V_Data And 255)
    
  604. End Function
    
  605. 
    
  606. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  607. Function EGNP_INT_BuildDouble(V_Data As Double) As String
    
  608. Dim T As String = Space(8)
    
  609. *Cast(Double Ptr, @T[0]) = V_Data
    
  610. Return T
    
  611. End Function
    
  612. 
    
  613. 
    
  614. 
    
  615. '####################################################################################################################################################
    
  616. Function EGNP_INT_GetString(Byref RV_Data As String, Byref R_Data As String) As EGNP_GURU_Enum
    
  617. If Len(RV_Data) < 4 Then Return EGNP_GURU_ParseLenError
    
  618. Dim TLen As Uinteger = (RV_Data[0] Shl 24) Or (RV_Data[1] Shl 16) Or (RV_Data[2] Shl 8) Or RV_Data[3]
    
  619. If TLen > &HFFFFF Then Return EGNP_GURU_ParseLenError
    
  620. If Len(RV_Data) < TLen Then Return EGNP_GURU_ParseLenError
    
  621. R_Data = Mid(RV_Data, 5, TLen - 4)
    
  622. RV_Data = Mid(RV_Data, TLen + 1)
    
  623. Return EGNP_GURU_NoError
    
  624. End Function
    
  625. 
    
  626. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  627. Function EGNP_INT_GetUShort(Byref RV_Data As String, Byref R_Data As Ushort) As EGNP_GURU_Enum
    
  628. If Len(RV_Data) < 2 Then Return EGNP_GURU_ParseLenError
    
  629. R_Data = (RV_Data[0] Shl 8) Or RV_Data[1]
    
  630. RV_Data = Mid(RV_Data, 3)
    
  631. Return EGNP_GURU_NoError
    
  632. End Function
    
  633. 
    
  634. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  635. Function EGNP_INT_GetUInteger(Byref RV_Data As String, Byref R_Data As Uinteger) As EGNP_GURU_Enum
    
  636. If Len(RV_Data) < 4 Then Return EGNP_GURU_ParseLenError
    
  637. R_Data = (RV_Data[0] Shl 24) Or (RV_Data[1] Shl 16) Or (RV_Data[2] Shl 8) Or RV_Data[3]
    
  638. RV_Data = Mid(RV_Data, 5)
    
  639. Return EGNP_GURU_NoError
    
  640. End Function
    
  641. 
    
  642. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  643. Function EGNP_INT_GetDouble(Byref RV_Data As String, Byref R_Data As Double) As EGNP_GURU_Enum
    
  644. If Len(RV_Data) < 8 Then Return EGNP_GURU_ParseLenError
    
  645. R_Data = *Cast(Double Ptr, @RV_Data[0])
    
  646. RV_Data = Mid(RV_Data, 9)
    
  647. Return EGNP_GURU_NoError
    
  648. End Function
    
  649. 
    
  650. 
    
  651. 
    
  652. '####################################################################################################################################################
    
  653. Function EGNP_INT_AsyncSendToOne(V_TSNEID As Uinteger, V_Data As String, V_Async As Integer = 1) As Integer
    
  654. 'If Len(V_Data) >= 8 Then
    
  655. '   Dim TCMD as EGNP_INT_CMD_Enum
    
  656. '   TCMD = (V_Data[4] shl 24) or (V_Data[5] shl 16) or (V_Data[6] shl 8) or V_Data[7]
    
  657. '   Print #1, "OUT >" & EGNP_INT_GETCMDDESC(TCMD) & "<___>" & Len(V_Data) & "<"
    
  658. 'Else: Print #1, "OUT >[?????]        <___>" & Len(V_Data) & "<"
    
  659. 'End If
    
  660. Return TSNE_Data_Send(V_TSNEID, V_Data)
    
  661. Return TSNE_Data_Send(V_TSNEID, V_Data, , , , V_Async)
    
  662. End Function
    
  663. 
    
  664. 
    
  665. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  666. Sub EGNP_INT_AsyncSendToAll(V_ServerPtr As EGNP_INT_Server_Type Ptr, V_Data As String)
    
  667. If V_ServerPtr = 0 Then Exit Sub
    
  668. Dim TCPtr As EGNP_INT_ServerClient_Type Ptr = V_ServerPtr->V_ClientF
    
  669. Do Until TCPtr = 0
    
  670.     If (TCPtr->V_State And EGNP_CSE_Ready) = 0 Then TCPtr = TCPtr->V_Next: Continue Do
    
  671.     TSNE_Data_Send(TCPtr->V_TSNEID, V_Data, , , , 1)
    
  672.     TCPtr = TCPtr->V_Next
    
  673. Loop
    
  674. End Sub
    
  675. 
    
  676. 
    
  677. 
    
  678. '####################################################################################################################################################
    
  679. Sub EGNP_INT_Public_Disconnected(Byval V_TSNEID As Uinteger, Byval V_ClientPtr As EGNP_INT_Client_Type Ptr)
    
  680. Mutexlock(EGNP_INT_Mux)
    
  681. EGNP_INT_ServerPubTSNEID = 0
    
  682. Mutexunlock(EGNP_INT_Mux)
    
  683. End Sub
    
  684. 
    
  685. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  686. Sub EGNP_INT_Public_NewData(Byval V_TSNEID As Uinteger, Byref V_Data As String, Byval V_ClientPtr As EGNP_INT_Client_Type Ptr)
    
  687. Dim TLen As Uinteger
    
  688. Dim TCMD As EGNP_INT_CMD_Enum
    
  689. Dim TData As String
    
  690. Dim T As String
    
  691. Dim TS(1 To 4) As String
    
  692. Dim TUS As Ushort
    
  693. Dim TUI(1 To 6) As Uinteger
    
  694. Dim TD(1 To 3) As Double
    
  695. Dim RV As EGNP_GURU_Enum
    
  696. Dim TSPtr As EGNP_INT_Server_Type Ptr
    
  697. Dim TSPtrC As EGNP_INT_Server_Type Ptr
    
  698. Mutexlock(EGNP_INT_Mux)
    
  699. EGNP_INT_ServerPubData += V_Data
    
  700. Do
    
  701.     If Len(EGNP_INT_ServerPubData) < 8 Then Mutexunlock(EGNP_INT_Mux): Exit Sub
    
  702.     If Len(EGNP_INT_ServerPubData) > &HFFFFF Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_DATALenError)): Exit Sub
    
  703.     TLen = (EGNP_INT_ServerPubData[0] Shl 24) Or (EGNP_INT_ServerPubData[1] Shl 16) Or (EGNP_INT_ServerPubData[2] Shl 8) Or EGNP_INT_ServerPubData[3]
    
  704.     If TLen > &HFFFFFF Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_DATALenError)): Exit Sub
    
  705.     If Len(EGNP_INT_ServerPubData) < TLen Then Mutexunlock(EGNP_INT_Mux): Exit Sub
    
  706.     TCMD = (EGNP_INT_ServerPubData[4] Shl 24) Or (EGNP_INT_ServerPubData[5] Shl 16) Or (EGNP_INT_ServerPubData[6] Shl 8) Or EGNP_INT_ServerPubData[7]
    
  707.     TData = Mid(EGNP_INT_ServerPubData, 9, TLen - 4)
    
  708.     EGNP_INT_ServerPubData = Mid(EGNP_INT_ServerPubData, TLen + 5)
    
  709.     T = ""
    
  710.     'Print "CMD >" & Str(TCMD) & "<___>" & TLen & "<___>" & Len(TData) & "<"
    
  711.     Select Case TCMD
    
  712.         Case EGNP_CMD_ServerList
    
  713.             Do Until EGNP_INT_ServerPubSLF = 0
    
  714.                 EGNP_INT_ServerPubSLL = EGNP_INT_ServerPubSLF->V_Next
    
  715.                 Deallocate(EGNP_INT_ServerPubSLF)
    
  716.                 EGNP_INT_ServerPubSLF = EGNP_INT_ServerPubSLL
    
  717.             Loop
    
  718.             EGNP_INT_ServerPubSLL = Callocate(Sizeof(EGNP_INT_PublicServer_Type))
    
  719.             EGNP_INT_ServerPubSLF = EGNP_INT_ServerPubSLL
    
  720.             EGNP_INT_ServerPubSLL->V_Name = "Manual select"
    
  721.             
    
  722.         Case EGNP_CMD_ServerListAdd
    
  723.             RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  724.             RV = EGNP_INT_GetUShort(TData, TUS):        If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  725.             RV = EGNP_INT_GetString(TData, TS(2)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  726.             RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  727.             RV = EGNP_INT_GetString(TData, TS(3)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  728.             RV = EGNP_INT_GetString(TData, TS(4)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  729.             RV = EGNP_INT_GetUInteger(TData, TUI(2)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  730.             RV = EGNP_INT_GetUInteger(TData, TUI(3)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  731.             RV = EGNP_INT_GetUInteger(TData, TUI(4)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  732.             EGNP_INT_ServerPubSLL->V_Next = Callocate(Sizeof(EGNP_INT_PublicServer_Type))
    
  733.             EGNP_INT_ServerPubSLL->V_Next->V_Prev = EGNP_INT_ServerPubSLL
    
  734.             EGNP_INT_ServerPubSLL = EGNP_INT_ServerPubSLL->V_Next
    
  735.             With *EGNP_INT_ServerPubSLL
    
  736.                 .V_IPA          = TS(1)
    
  737.                 .V_Port         = TUS
    
  738.                 .V_GameName     = TS(2)
    
  739.                 .V_GameVersion  = TUI(1)
    
  740.                 .V_Name         = TS(3)
    
  741.                 .V_Desc         = TS(4)
    
  742.                 .V_Flags        = TUI(2)
    
  743.                 .V_PlayerMax    = TUI(3)
    
  744.                 .V_PlayerCur    = TUI(4)
    
  745.             End With
    
  746.             
    
  747.         Case EGNP_CMD_ServerListReady
    
  748.             EGNP_INT_ServerPubSLTime = Timer()
    
  749.             
    
  750.         Case EGNP_CMD_ServerListUpdate
    
  751.             RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  752.             RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  753.             TSPtrC = Cast(EGNP_INT_Server_Type Ptr, TUI(1))
    
  754.             TSPtr = EGNP_INT_Server_F
    
  755.             Do Until TSPtr = 0
    
  756.                 If TSPtr = TSPtrC Then If TSPtr->V_PublicKey = "" Then TSPtr->V_PublicKey = TS(1): Exit Do
    
  757.                 TSPtr = TSPtr->V_Next
    
  758.             Loop
    
  759.             
    
  760.         Case EGNP_GURU_UnknownCMD
    
  761.         Case EGNP_GURU_CommandDenied
    
  762.         Case Else: Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  763.     End Select
    
  764. Loop
    
  765. Mutexunlock(EGNP_INT_Mux)
    
  766. End Sub
    
  767. 
    
  768. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  769. Sub EGNP_INT_MainThead(Nothing As Any Ptr)
    
  770. 'USleep 1000000
    
  771. Sleep 1000, 1
    
  772. Dim T As String
    
  773. Dim TFlag As EGNP_ServerFlags_Enum
    
  774. Dim TSPtr As EGNP_INT_Server_Type Ptr
    
  775. Dim TCPtr As EGNP_INT_ServerClient_Type Ptr
    
  776. Do
    
  777.     Mutexlock(EGNP_INT_Mux)
    
  778.     If EGNP_INT_ServerPubExit = 1 Then Mutexunlock(EGNP_INT_Mux): Exit Do
    
  779.     TSPtr = EGNP_INT_Server_F
    
  780.     Do Until TSPtr = 0
    
  781.         With *TSPtr
    
  782.             'TCPtr = .V_ClientF
    
  783.             'Do Until TCPtr = 0
    
  784.             '   If TCPtr->V_TimePing < Timer() Then
    
  785.             '       TCPtr->V_TimePing = Timer() + 10
    
  786.             '       If TCPtr->V_PingC = 0 Then
    
  787.             '           TCPtr->V_PingC += 1
    
  788.             '           EGNP_INT_AsyncSendToOne(TCPtr->V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_PING))
    
  789.             '       Else: TSNE_Disconnect(TCPtr->V_TSNEID)
    
  790.             '       End If
    
  791.             '   End If
    
  792.             '   TCPtr = TCPtr->V_Next
    
  793.             'Loop
    
  794.             'Print "UPDATE-check!:" & fix(.V_PublicTime - Timer())
    
  795.             If .V_Public <> 1 Then TSPtr = TSPtr->V_Next: Continue Do
    
  796.             'If .V_PublicUpdate = 1 Then If .V_PublicTime + 5 > Timer() Then .V_PublicTime = Timer() + 5
    
  797.             If .V_PublicTime > Timer() Then TSPtr = TSPtr->V_Next: Continue Do
    
  798.             If EGNP_INT_ServerPubTSNEID = 0 Then
    
  799.                 EGNP_INT_ServerPubData = ""
    
  800.                 TSNE_Create_Client(EGNP_INT_ServerPubTSNEID, EGNP_INT_PubServerHost, EGNP_INT_PubServerPort, @EGNP_INT_Public_Disconnected, 0, @EGNP_INT_Public_NewData)
    
  801.             End If
    
  802.             If TSNE_WaitConnected(EGNP_INT_ServerPubTSNEID) <> TSNE_Const_NoError Then Exit Do
    
  803.             .V_PublicUpdate = 0
    
  804.             .V_PublicTime = Timer() + (60 * 1) '1min update-cycle
    
  805.             'Print ""UPDATE!
    
  806.             T = ""
    
  807.             T += EGNP_INT_BuildUInteger(Cast(Uinteger, TSPtr))
    
  808.             T += EGNP_INT_BuildString(.V_PublicKey)
    
  809.             T += EGNP_INT_BuildUShort(.V_PortTCP)
    
  810.             T += EGNP_INT_BuildUShort(.V_PortUDP)
    
  811.             T += EGNP_INT_BuildString(.V_GameName)
    
  812.             T += EGNP_INT_BuildUInteger(.V_GameVersion)
    
  813.             T += EGNP_INT_BuildString(.V_Name)
    
  814.             T += EGNP_INT_BuildString(.V_Description)
    
  815.             TFlag = 0
    
  816.             If .V_Password <> "" Then TFlag Or= EGNP_SFE_ServerPass
    
  817.             If .V_UseAccounts = 1 Then TFlag Or= EGNP_SFE_Account
    
  818.             T += EGNP_INT_BuildUInteger(TFlag)
    
  819.             T += EGNP_INT_BuildUInteger(.V_MaxPlayer)
    
  820.             T += EGNP_INT_BuildUInteger(.V_ClientC)
    
  821.             EGNP_INT_AsyncSendToOne(EGNP_INT_ServerPubTSNEID, EGNP_INT_BuildCMD(EGNP_CMD_ServerListUpdate, T))
    
  822.         End With
    
  823.         TSPtr = TSPtr->V_Next
    
  824.     Loop
    
  825.     Mutexunlock(EGNP_INT_Mux)
    
  826.     'USleep 1000000
    
  827.     Sleep 1000, 1
    
  828. Loop
    
  829. End Sub
    
  830. 
    
  831. 
    
  832. 
    
  833. '####################################################################################################################################################
    
  834. Sub EGNP_INT_Construct() Constructor
    
  835. EGNP_INT_Mux = Mutexcreate()
    
  836. Randomize(Timer())
    
  837. Mutexlock(EGNP_INT_Mux)
    
  838. EGNP_INT_ServerPubExit = 0
    
  839. EGNP_INT_ServerPubThread = Threadcreate(Cast(Any Ptr, @EGNP_INT_MainThead))
    
  840. Mutexunlock(EGNP_INT_Mux)
    
  841. End Sub
    
  842. 
    
  843. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  844. Sub EGNP_INT_Destruct() Destructor
    
  845. Mutexlock(EGNP_INT_Mux)
    
  846. EGNP_INT_ServerPubExit = 1
    
  847. Mutexunlock(EGNP_INT_Mux)
    
  848. Threadwait(EGNP_INT_ServerPubThread)
    
  849. EGNP_INT_ServerPubThread = 0
    
  850. Mutexdestroy(EGNP_INT_Mux)
    
  851. EGNP_INT_Mux = 0
    
  852. End Sub
    
  853. 
    
  854. 
    
  855. 
    
  856. '####################################################################################################################################################
    
  857. Function EGNP_INT_User_Add(V_ClientPtr As EGNP_INT_Client_Type Ptr, V_ClientID As Uinteger, V_Nickname As String, V_UserFlags As EGNP_AccountPermissions_Enum) As EGNP_User_Type Ptr
    
  858. If V_ClientPtr = 0 Then Return 0
    
  859. With *V_ClientPtr
    
  860.     If .V_UserL <> 0 Then
    
  861.         .V_UserL->V_Next = Callocate(Sizeof(EGNP_User_Type))
    
  862.         .V_UserL->V_Next->V_Prev = .V_UserL
    
  863.         .V_UserL = .V_UserL->V_Next
    
  864.     Else
    
  865.         .V_UserL = Callocate(Sizeof(EGNP_User_Type))
    
  866.         .V_UserF = .V_UserL
    
  867.     End If
    
  868.     With *.V_UserL
    
  869.         .V_ClientID     = V_ClientID
    
  870.         .V_Nickname     = V_Nickname
    
  871.         .V_UserFlags    = V_UserFlags
    
  872.     End With
    
  873.     Return .V_UserL
    
  874. End With
    
  875. End Function
    
  876. 
    
  877. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  878. Function EGNP_INT_User_Get(V_ClientPtr As EGNP_INT_Client_Type Ptr, V_ClientID As Uinteger) As EGNP_User_Type Ptr
    
  879. If V_ClientPtr = 0 Then Return 0
    
  880. Dim TCPtr As EGNP_User_Type Ptr = V_ClientPtr->V_UserF
    
  881. Do Until TCPtr = 0
    
  882.     If TCPtr->V_ClientID = V_ClientID Then Return TCPtr
    
  883.     TCPtr = TCPtr->V_Next
    
  884. Loop
    
  885. Return 0
    
  886. End Function
    
  887. 
    
  888. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  889. Sub EGNP_INT_User_Del(V_ClientPtr As EGNP_INT_Client_Type Ptr, V_ClientID As Uinteger)
    
  890. Dim TCPtr As EGNP_User_Type Ptr = EGNP_INT_User_Get(V_ClientPtr, V_ClientID)
    
  891. If TCPtr = 0 Then Exit Sub
    
  892. If TCPtr->V_Next <> 0 Then TCPtr->V_Next->V_Prev = TCPtr->V_Prev
    
  893. If TCPtr->V_Prev <> 0 Then TCPtr->V_Prev->V_Next = TCPtr->V_Next
    
  894. If V_ClientPtr->V_UserF = TCPtr Then V_ClientPtr->V_UserF = TCPtr->V_Next
    
  895. If V_ClientPtr->V_UserL = TCPtr Then V_ClientPtr->V_UserL = TCPtr->V_Prev
    
  896. Deallocate(TCPtr)
    
  897. End Sub
    
  898. 
    
  899. 
    
  900. 
    
  901. '####################################################################################################################################################
    
  902. Function EGNP_INT_Client_GetByID(V_ServerPtr As EGNP_INT_Server_Type Ptr, V_ClientID As Uinteger) As EGNP_INT_ServerClient_Type Ptr
    
  903. If V_ServerPtr = 0 Then Return 0
    
  904. Dim TSPtr As EGNP_INT_ServerClient_Type Ptr = Cast(EGNP_INT_ServerClient_Type Ptr, V_ClientID)
    
  905. Dim TCPtr As EGNP_INT_ServerClient_Type Ptr = V_ServerPtr->V_ClientF
    
  906. Do Until TCPtr = 0
    
  907.     If TCPtr = TSPtr Then Return TCPtr
    
  908.     TCPtr = TCPtr->V_Next
    
  909. Loop
    
  910. Return 0
    
  911. End Function
    
  912. 
    
  913. 
    
  914. 
    
  915. '####################################################################################################################################################
    
  916. Function EGNP_INT_Server_AccountAdd(V_ServerPtr As EGNP_INT_Server_Type Ptr, V_Username As String, V_Password As String, V_Nickname As String, V_Flags As EGNP_AccountPermissions_Enum = EGNP_APE_Registered) As EGNP_GURU_Enum
    
  917. If V_ServerPtr = 0 Then Return EGNP_GURU_ParameterError
    
  918. If V_Username = "" Then Return EGNP_GURU_ParameterError
    
  919. If V_Password = "" Then Return EGNP_GURU_ParameterError
    
  920. If V_Nickname = "" Then Return EGNP_GURU_ParameterError
    
  921. Dim S As String = Lcase(V_Username)
    
  922. If V_ServerPtr->V_UseAccounts <> 1 Then Return EGNP_GURU_ParameterError
    
  923. If V_ServerPtr->V_AccountFile = "" Then Return EGNP_GURU_ParameterError
    
  924. Dim TAPtr As EGNP_INT_Account_Type Ptr = V_ServerPtr->V_AccountF
    
  925. Do Until TAPtr = 0
    
  926.     If TAPtr->V_UsernameL = S Then Return EGNP_GURU_UsernameDenied
    
  927.     TAPtr = TAPtr->V_Next
    
  928. Loop
    
  929. Dim T As String
    
  930. T += EGNP_INT_BuildUInteger(0)
    
  931. T += EGNP_INT_BuildString(V_Username)
    
  932. T += EGNP_INT_BuildString(V_Password)
    
  933. T += EGNP_INT_BuildString(V_Nickname)
    
  934. Dim TLen As Uinteger = Len(T)
    
  935. Dim TFN As Integer = Freefile()
    
  936. If Open(V_ServerPtr->V_AccountFile For Append As #TFN) <> 0 Then Return EGNP_GURU_CantOpenFile
    
  937. Print #TFN, Chr((TLen Shr 24) And 255, (TLen Shr 16) And 255, (TLen Shr 8) And 255, TLen And 255) & T;
    
  938. Close #TFN
    
  939. With *V_ServerPtr
    
  940.     If .V_AccountL <> 0 Then
    
  941.         .V_AccountL->V_Next = Callocate(Sizeof(EGNP_INT_Account_Type))
    
  942.         .V_AccountL->V_Next->V_Prev = .V_AccountL
    
  943.         .V_AccountL = .V_AccountL->V_Next
    
  944.     Else
    
  945.         .V_AccountL = Callocate(Sizeof(EGNP_INT_Account_Type))
    
  946.         .V_AccountF = .V_AccountL
    
  947.     End If
    
  948.     With *.V_AccountL
    
  949.         .V_Username     = V_Username
    
  950.         .V_UsernameL    = Lcase(.V_Username)
    
  951.         .V_Password     = V_Password
    
  952.         .V_Nickname     = V_Nickname
    
  953.         .V_UserFlags    = EGNP_APE_Registered Or V_Flags
    
  954.     End With
    
  955. End With
    
  956. Return EGNP_GURU_NoError
    
  957. End Function
    
  958. 
    
  959. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  960. Function EGNP_INT_Server_AccountRestore(V_ServerPtr As EGNP_INT_Server_Type Ptr) As EGNP_GURU_Enum
    
  961. If V_ServerPtr = 0 Then Return EGNP_GURU_ParameterError
    
  962. Dim T As String
    
  963. Dim D As String
    
  964. Dim TLen As Uinteger
    
  965. If V_ServerPtr->V_AccountFile = "" Then Return EGNP_GURU_ParameterError
    
  966. If Kill(V_ServerPtr->V_AccountFile) <> 0 Then Return EGNP_GURU_CantOpenFile
    
  967. Dim TFN As Integer = Freefile()
    
  968. If Open(V_ServerPtr->V_AccountFile For Binary As #TFN) <> 0 Then Return EGNP_GURU_CantOpenFile
    
  969. Dim TAPtr As EGNP_INT_Account_Type Ptr = V_ServerPtr->V_AccountF
    
  970. Do Until TAPtr = 0
    
  971.     With *TAPtr
    
  972.         T = ""
    
  973.         T += EGNP_INT_BuildUInteger(.V_UserFlags)
    
  974.         T += EGNP_INT_BuildString(.V_Username)
    
  975.         T += EGNP_INT_BuildString(.V_Password)
    
  976.         T += EGNP_INT_BuildString(.V_Nickname)
    
  977.         TLen = Len(T)
    
  978.         D += Chr((TLen Shr 24) And 255, (TLen Shr 16) And 255, (TLen Shr 8) And 255, TLen And 255) & T
    
  979.     End With
    
  980.     TAPtr = TAPtr->V_Next
    
  981. Loop
    
  982. Print #TFN, D;
    
  983. Close #TFN
    
  984. Return EGNP_GURU_NoError
    
  985. End Function
    
  986. 
    
  987. 
    
  988. 
    
  989. '####################################################################################################################################################
    
  990. Sub EGNP_INT_Server_Disconnected(Byval V_TSNEID As Uinteger, Byval V_ClientPtr As EGNP_INT_ServerClient_Type Ptr)
    
  991. 'Print "SDIS:" & Str(V_ClientPtr)
    
  992. If V_ClientPtr = 0 Then Exit Sub
    
  993. Mutexlock(EGNP_INT_Mux)
    
  994. Dim TDoCall As Integer = Iif((V_ClientPtr->V_State And EGNP_CSE_Ready) <> 0, 1, 0)
    
  995. V_ClientPtr->V_State = EGNP_CSE_Disconnected
    
  996. Dim TSPtr As EGNP_INT_Server_Type Ptr = V_ClientPtr->V_Server
    
  997. If V_ClientPtr->V_Next <> 0 Then V_ClientPtr->V_Next->V_Prev = V_ClientPtr->V_Prev
    
  998. If V_ClientPtr->V_Prev <> 0 Then V_ClientPtr->V_Prev->V_Next = V_ClientPtr->V_Next
    
  999. If TSPtr->V_ClientF = V_ClientPtr Then TSPtr->V_ClientF = V_ClientPtr->V_Next
    
  1000. If TSPtr->V_ClientL = V_ClientPtr Then TSPtr->V_ClientL = V_ClientPtr->V_Prev
    
  1001. If TSPtr->V_ClientC > 0 Then TSPtr->V_ClientC -= 1
    
  1002. EGNP_INT_AsyncSendToAll(V_ClientPtr->V_Server, EGNP_INT_BuildCMD(EGNP_CMD_UserLeave, EGNP_INT_BuildUInteger(Cast(Uinteger, V_ClientPtr))))
    
  1003. Dim TCallbacks As EGNP_Callback_Type = V_ClientPtr->V_Server->V_Callbacks
    
  1004. V_ClientPtr->V_Server->V_PublicUpdate = 1
    
  1005. Dim TServID As Uinteger = Cast(Uinteger, V_ClientPtr->V_Server)
    
  1006. Mutexunlock(EGNP_INT_Mux)
    
  1007. Dim TMyPtrFrom As Any Ptr = V_ClientPtr->V_MyPtr
    
  1008. Dim TCRV As Integer
    
  1009. If TDoCall = 1 Then If TCallbacks.V_Server_StateUser <> 0 Then TCallbacks.V_Server_StateUser(TServID, Cast(Uinteger, V_ClientPtr), EGNP_USE_Leave, TMyPtrFrom, TCRV)
    
  1010. Deallocate(V_ClientPtr)
    
  1011. End Sub
    
  1012. 
    
  1013. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1014. Sub EGNP_INT_Server_Connected(Byval V_TSNEID As Uinteger, Byval V_ClientPtr As EGNP_INT_ServerClient_Type Ptr)
    
  1015. 'Print ""SCON
    
  1016. If V_ClientPtr = 0 Then TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1017. Mutexlock(EGNP_INT_Mux)
    
  1018. V_ClientPtr->V_State = EGNP_CSE_Connected
    
  1019. Dim T As String
    
  1020. With *V_ClientPtr
    
  1021.     T += EGNP_INT_BuildString(.V_Server->V_Name)
    
  1022.     T += EGNP_INT_BuildString(.V_Server->V_Description)
    
  1023.     T += EGNP_INT_BuildUShort(.V_Server->V_MaxPlayer)
    
  1024.     T += Chr(Iif(.V_Server->V_Public = 1, 1, 0))
    
  1025.     T += Chr(Iif(.V_Server->V_UseAccounts = 1, 1, 0))
    
  1026.     T += Chr(Iif(.V_Server->V_Password <> "", 1, 0))
    
  1027. End With
    
  1028. Mutexunlock(EGNP_INT_Mux)
    
  1029. If EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_Ident, T)) <> TSNE_Const_NoError Then TSNE_Disconnect(V_TSNEID)
    
  1030. End Sub
    
  1031. 
    
  1032. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1033. Sub EGNP_INT_Server_ConnectionDenied(Byval V_TSNEID As Uinteger, Byval V_ClientPtr As EGNP_INT_ServerClient_Type Ptr)
    
  1034. 'Print ""SDEN
    
  1035. EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(Cast(Uinteger, V_ClientPtr)))
    
  1036. TSNE_Disconnect(V_TSNEID)
    
  1037. End Sub
    
  1038. 
    
  1039. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1040. Sub EGNP_INT_Server_NewData(Byval V_TSNEID As Uinteger, Byref V_Data As String, Byval V_ClientPtr As EGNP_INT_ServerClient_Type Ptr)
    
  1041. 'Print "SDAT:" & Len(V_Data)
    
  1042. If V_ClientPtr = 0 Then TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1043. Dim TLen As Uinteger
    
  1044. Dim TCMD As EGNP_INT_CMD_Enum
    
  1045. Dim TData As String
    
  1046. Dim TData1 As String
    
  1047. Dim TS(1 To 4) As String
    
  1048. Dim TUI(1 To 6) As Uinteger
    
  1049. Dim TD(1 To 3) As Double
    
  1050. Dim RV As EGNP_GURU_Enum
    
  1051. Dim T As String
    
  1052. Dim T1 As String
    
  1053. Dim TCPtr As EGNP_INT_ServerClient_Type Ptr
    
  1054. Dim TCPtrS As EGNP_INT_ServerClient_Type Ptr
    
  1055. Dim TCRV As Integer
    
  1056. Dim TCUID As Uinteger
    
  1057. Dim TCallbacks As EGNP_Callback_Type
    
  1058. Dim TMyPtrFrom As Any Ptr
    
  1059. Dim TMyPtrTo As Any Ptr
    
  1060. Dim TAPtr As EGNP_INT_Account_Type Ptr
    
  1061. Dim TUFlags As EGNP_AccountPermissions_Enum
    
  1062. Dim TSerial As Double
    
  1063. Dim TOK As Integer
    
  1064. Mutexlock(EGNP_INT_Mux)
    
  1065. With *V_ClientPtr
    
  1066.     TCUID = Cast(Uinteger, V_ClientPtr)
    
  1067.     TCallbacks = .V_Server->V_Callbacks
    
  1068.     Dim TServID As Uinteger = Cast(Uinteger, .V_Server)
    
  1069.     .V_DataTCP += V_Data
    
  1070.     .V_TimeOut = Timer() + 60
    
  1071.     Do
    
  1072.         TCRV = 0
    
  1073.         If Len(.V_DataTCP) < 8 Then Mutexunlock(EGNP_INT_Mux): Exit Sub
    
  1074.         If Len(.V_DataTCP) > &HFFFFF Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_DATALenError)): Exit Sub
    
  1075.         TLen = (.V_DataTCP[0] Shl 24) Or (.V_DataTCP[1] Shl 16) Or (.V_DataTCP[2] Shl 8) Or .V_DataTCP[3]
    
  1076.         If TLen > &HFFFFFF Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_DATALenError)): Exit Sub
    
  1077.         If Len(.V_DataTCP) < TLen Then Mutexunlock(EGNP_INT_Mux): Exit Sub
    
  1078.         TCMD = (.V_DataTCP[4] Shl 24) Or (.V_DataTCP[5] Shl 16) Or (.V_DataTCP[6] Shl 8) Or .V_DataTCP[7]
    
  1079.         TData = Mid(.V_DataTCP, 9, TLen - 4)
    
  1080.         .V_DataTCP = Mid(.V_DataTCP, TLen + 5)
    
  1081.         'Print "IN  >" & EGNP_INT_GETCMDDESC(TCMD) & "<___>" & TLen & "<___>" & Len(TData) & "<___>" & Len(.V_DataTCP) & "<"
    
  1082.         Select Case TCMD
    
  1083.             Case EGNP_CMD_ServerOffline, EGNP_CMD_ServerFull: Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1084.             Case EGNP_CMD_Crypt1
    
  1085.                 .V_PPKLen = 255
    
  1086.                 .V_PPKPri = Space(.V_PPKLen)
    
  1087.                 .V_PPKPub = Space(.V_PPKLen)
    
  1088.                 .V_PPKSum = Space(.V_PPKLen)
    
  1089.                 .V_PPKMix = Space(.V_PPKLen)
    
  1090.                 For X As Integer = 0 To .V_PPKLen - 1
    
  1091.                     .V_PPKPri[X] = Int(Rnd * 255)
    
  1092.                     .V_PPKPub[X] = Int(Rnd * 255)
    
  1093.                 Next
    
  1094.                 T = ""
    
  1095.                 T += EGNP_INT_BuildString(.V_PPKPub)
    
  1096.                 
    
  1097.             Case EGNP_CMD_Crypt2
    
  1098.                 For X As Integer = 0 To .V_PPKLen - 1
    
  1099.                     .V_PPKSum[X] = .V_PPKPub[X] Xor .V_PPKPri[X]
    
  1100.                 Next
    
  1101.                 T = ""
    
  1102.                 T += EGNP_INT_BuildString(.V_PPKSum)
    
  1103.                 
    
  1104.             Case EGNP_CMD_Crypt3
    
  1105.                 For X As Integer = 0 To .V_PPKLen - 1
    
  1106.                     .V_PPKSum[X] = .V_PPKSum[X] Xor .V_PPKPri[X]
    
  1107.                 Next
    
  1108.                 
    
  1109.             Case EGNP_CMD_Ident
    
  1110.                 If ((.V_State And EGNP_CSE_Ident) <> 0) Or ((.V_State And EGNP_CSE_Ready) <> 0) Then
    
  1111.                     EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1112.                     Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1113.                 End If
    
  1114.                 RV = EGNP_INT_GetString(TData, TS(1)):  If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1115.                 RV = EGNP_INT_GetString(TData, TS(2)):  If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1116.                 If .V_Server->V_Password <> TS(2) Then
    
  1117.                     Mutexunlock(EGNP_INT_Mux)
    
  1118.                     EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_LoginDenied), 0)
    
  1119.                     TSNE_Disconnect(V_TSNEID): Exit Do
    
  1120.                 End If
    
  1121.                 If Len(TS(1)) > &HFF Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1122.                 T1 = Lcase(TS(1))
    
  1123.                 TCPtr = V_ClientPtr->V_Server->V_ClientF
    
  1124.                 Do Until TCPtr = 0
    
  1125.                     If TCPtr->V_NicknameL <> T1 Then TCPtr = TCPtr->V_Next: Continue Do
    
  1126.                     Mutexunlock(EGNP_INT_Mux)
    
  1127.                     EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_NickDenied), 0)
    
  1128.                     TSNE_Disconnect(V_TSNEID): Exit Do
    
  1129.                 Loop
    
  1130.                 .V_Nickname = TS(1)
    
  1131.                 .V_NicknameL = T1
    
  1132.                 If .V_Server->V_UseAccounts = 0 Then
    
  1133.                     TMyPtrFrom = .V_MyPtr
    
  1134.                     Mutexunlock(EGNP_INT_Mux)
    
  1135.                     If TCallbacks.V_Server_StateUser <> 0 Then TCallbacks.V_Server_StateUser(TServID, TCUID, EGNP_USE_Join, TMyPtrFrom, TCRV)
    
  1136.                     If TCRV <> 0 Then
    
  1137.                         EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_LoginDenied), 0)
    
  1138.                         TSNE_Disconnect(V_TSNEID): Exit Do
    
  1139.                     End If
    
  1140.                     Mutexlock(EGNP_INT_Mux)
    
  1141.                     .V_MyPtr = TMyPtrFrom
    
  1142.                     .V_State = EGNP_CSE_Connected Or EGNP_CSE_Ident Or EGNP_CSE_Ready
    
  1143.                     If EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_Ready, EGNP_INT_BuildUInteger(TCUID)), 0) <> TSNE_Const_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1144.                     .V_Server->V_PublicUpdate = 1
    
  1145.                     T = ""
    
  1146.                     T += EGNP_INT_BuildUInteger(TCUID)
    
  1147.                     T += EGNP_INT_BuildString(.V_Nickname)
    
  1148.                     T += EGNP_INT_BuildUInteger(.V_UserFlags)
    
  1149.                     EGNP_INT_AsyncSendToAll(.V_Server, EGNP_INT_BuildCMD(EGNP_CMD_UserJoin, T))
    
  1150.                     T1 = ""
    
  1151.                     TCPtr = V_ClientPtr->V_Server->V_ClientF
    
  1152.                     Do Until TCPtr = 0
    
  1153.                         If TCPtr = V_ClientPtr Then TCPtr = TCPtr->V_Next: Continue Do
    
  1154.                         If (TCPtr->V_State And EGNP_CSE_Ready) = 0 Then TCPtr = TCPtr->V_Next: Continue Do
    
  1155.                         T = ""
    
  1156.                         T += EGNP_INT_BuildUInteger(Cast(Uinteger, TCPtr))
    
  1157.                         T += EGNP_INT_BuildString(TCPtr->V_Nickname)
    
  1158.                         T += EGNP_INT_BuildUInteger(TCPtr->V_UserFlags)
    
  1159.                         T1 += EGNP_INT_BuildCMD(EGNP_CMD_UserJoin, T)
    
  1160.                         TCPtr = TCPtr->V_Next
    
  1161.                     Loop
    
  1162.                     If T1 <> "" Then If EGNP_INT_AsyncSendToOne(V_TSNEID, T1, 0) <> TSNE_Const_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1163.                 Else
    
  1164.                     .V_State = EGNP_CSE_Connected Or EGNP_CSE_Ident
    
  1165.                     Mutexunlock(EGNP_INT_Mux)
    
  1166.                     For X As Integer = 1 To 100
    
  1167.                         'USleep 10000
    
  1168.                         Sleep 10, 1
    
  1169.                     Next
    
  1170.                     Mutexlock(EGNP_INT_Mux)
    
  1171.                     If EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_AccLogin), 0) <> TSNE_Const_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1172.                 End If
    
  1173.                 
    
  1174.             Case EGNP_CMD_AccLogin
    
  1175.                 If ((.V_State And EGNP_CSE_Ident) = 0) Or ((.V_State And EGNP_CSE_Ready) <> 0) Then
    
  1176.                     EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1177.                     Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1178.                 End If
    
  1179.                 RV = EGNP_INT_GetString(TData, TS(1)):  If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1180.                 RV = EGNP_INT_GetString(TData, TS(2)):  If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1181.                 If Len(TS(1)) < 8       Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1182.                 If Len(TS(2)) < 16      Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1183.                 If Len(TS(1)) > &HFF    Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1184.                 If Len(TS(2)) > &HFFFF  Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1185.                 TMyPtrFrom = .V_MyPtr
    
  1186.                 Mutexunlock(EGNP_INT_Mux)
    
  1187.                 TUFlags = 0
    
  1188.                 If TCallbacks.V_Server_AccountAction <> 0 Then TCallbacks.V_Server_AccountAction(TServID, TCUID, EGNP_AAE_Login, TS(1), TUFlags, TMyPtrFrom, TCRV)
    
  1189.                 If TCRV <> 0 Then
    
  1190.                     EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_LoginDenied), 0)
    
  1191.                     TSNE_Disconnect(V_TSNEID): Exit Do
    
  1192.                 End If
    
  1193.                 Mutexlock(EGNP_INT_Mux)
    
  1194.                 .V_MyPtr = TMyPtrFrom
    
  1195.                 TS(1) = Lcase(TS(1))
    
  1196.                 TAPtr = .V_Server->V_AccountF
    
  1197.                 Do Until TAPtr = 0
    
  1198.                     If TAPtr->V_UsernameL = TS(1) Then
    
  1199.                         If TAPtr->V_Password <> TS(2) Then
    
  1200.                             EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_LoginDenied), 0)
    
  1201.                             Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1202.                         End If
    
  1203.                         .V_Username = TAPtr->V_Username
    
  1204.                         .V_UserFlags = EGNP_APE_Registered Or TAPtr->V_UserFlags Or TUFlags
    
  1205.                         TMyPtrFrom = .V_MyPtr
    
  1206.                         Mutexunlock(EGNP_INT_Mux)
    
  1207.                         If TCallbacks.V_Server_StateUser <> 0 Then TCallbacks.V_Server_StateUser(TServID, TCUID, EGNP_USE_Join, TMyPtrFrom, TCRV)
    
  1208.                         If (.V_UserFlags And EGNP_APE_Banned) <> 0 Then TCRV = 1
    
  1209.                         If TCRV <> 0 Then
    
  1210.                             EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_LoginDenied), 0)
    
  1211.                             TSNE_Disconnect(V_TSNEID): Exit Do
    
  1212.                         End If
    
  1213.                         Mutexlock(EGNP_INT_Mux)
    
  1214.                         .V_MyPtr = TMyPtrFrom
    
  1215.                         .V_State Or= EGNP_CSE_Login Or EGNP_CSE_Ready
    
  1216.                         If EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_Ready, EGNP_INT_BuildUInteger(TCUID)), 0) <> TSNE_Const_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1217.                         .V_Server->V_PublicUpdate = 1
    
  1218.                         T = ""
    
  1219.                         T += EGNP_INT_BuildUInteger(TCUID)
    
  1220.                         T += EGNP_INT_BuildString(.V_Nickname)
    
  1221.                         T += EGNP_INT_BuildUInteger(.V_UserFlags)
    
  1222.                         EGNP_INT_AsyncSendToAll(.V_Server, EGNP_INT_BuildCMD(EGNP_CMD_UserJoin, T))
    
  1223.                         T1 = ""
    
  1224.                         TCPtr = V_ClientPtr->V_Server->V_ClientF
    
  1225.                         Do Until TCPtr = 0
    
  1226.                             If TCPtr = V_ClientPtr Then TCPtr = TCPtr->V_Next: Continue Do
    
  1227.                             If (TCPtr->V_State And EGNP_CSE_Ready) = 0 Then TCPtr = TCPtr->V_Next: Continue Do
    
  1228.                             T = ""
    
  1229.                             T += EGNP_INT_BuildUInteger(Cast(Uinteger, TCPtr))
    
  1230.                             T += EGNP_INT_BuildString(TCPtr->V_Nickname)
    
  1231.                             T += EGNP_INT_BuildUInteger(TCPtr->V_UserFlags)
    
  1232.                             T1 += EGNP_INT_BuildCMD(EGNP_CMD_UserJoin, T)
    
  1233.                             TCPtr = TCPtr->V_Next
    
  1234.                         Loop
    
  1235.                         If T1 <> "" Then If EGNP_INT_AsyncSendToOne(V_TSNEID, T1, 0) <> TSNE_Const_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1236.                         Exit Select
    
  1237.                     End If
    
  1238.                     TAPtr = TAPtr->V_Next
    
  1239.                 Loop
    
  1240.                 EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_LoginDenied), 0)
    
  1241.                 TSNE_Disconnect(V_TSNEID): Exit Do
    
  1242.                 
    
  1243.             Case EGNP_CMD_AccCreate
    
  1244.                 T = ""
    
  1245.                 TOK = 0
    
  1246.                 If ((.V_State And EGNP_CSE_Ident) = 0) Or ((.V_State And EGNP_CSE_Ready) <> 0) Then
    
  1247.                     If .V_Server->V_UseAccounts = 0 Then
    
  1248.                         EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1249.                         Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1250.                     End If
    
  1251.                     If (.V_UserFlags And (EGNP_APE_SuperModerator Or EGNP_APE_Administrator)) = 0 Then
    
  1252.                         EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1253.                         Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1254.                     End If
    
  1255.                     RV = EGNP_INT_GetDouble(TData, TSerial): If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1256.                     T += EGNP_INT_BuildDouble(TSerial)
    
  1257.                     TOK = 1
    
  1258.                 End If
    
  1259.                 RV = EGNP_INT_GetString(TData, TS(1)):  If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1260.                 RV = EGNP_INT_GetString(TData, TS(2)):  If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1261.                 RV = EGNP_INT_GetString(TData, TS(3)):  If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1262.                 If Len(TS(1)) > &HFF    Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1263.                 If Len(TS(2)) > &HFFFF  Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1264.                 If Len(TS(3)) > &HFF    Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1265.                 TMyPtrFrom = .V_MyPtr
    
  1266.                 Mutexunlock(EGNP_INT_Mux)
    
  1267.                 If TCallbacks.V_Server_AccountAction <> 0 Then TCallbacks.V_Server_AccountAction(TServID, TCUID, EGNP_AAE_Create, TS(1), TUFlags, TMyPtrFrom, TCRV)
    
  1268.                 If TCRV <> 0 Then
    
  1269.                     EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_LoginDenied), 0)
    
  1270.                     TSNE_Disconnect(V_TSNEID): Exit Do
    
  1271.                 End If
    
  1272.                 Mutexlock(EGNP_INT_Mux)
    
  1273.                 .V_MyPtr = TMyPtrFrom
    
  1274.                 RV = EGNP_INT_Server_AccountAdd(.V_Server, TS(1), TS(2), TS(3))
    
  1275.                 If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1276.                 If TOK = 0 Then
    
  1277.                     If EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_AccLogin), 0) <> TSNE_Const_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1278.                 Else: If EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_AccCreate, T), 0) <> TSNE_Const_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1279.                 End If
    
  1280.                 
    
  1281.             Case Else
    
  1282.                 If (.V_State And EGNP_CSE_Ready) = 0 Then
    
  1283.                     EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1284.                     Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1285.                 End If
    
  1286.                 Select Case TCMD
    
  1287.                     Case EGNP_CMD_Pong
    
  1288.                         .V_PingC = 0
    
  1289.                         
    
  1290.                     Case EGNP_CMD_UserMessage
    
  1291.                         TData1 = EGNP_INT_BuildUInteger(TCUID) & TData
    
  1292.                         RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1293.                         RV = EGNP_INT_GetUInteger(TData, TUI(2)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1294.                         RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1295.                         If Len(TS(1)) > &HFFF Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1296.                         TCPtrS = EGNP_INT_Client_GetByID(.V_Server, TUI(1))
    
  1297.                         If TCPtrS <> 0 Then TMyPtrTo = TCPtrS->V_MyPtr Else TMyPtrTo = 0
    
  1298.                         TMyPtrFrom = .V_MyPtr
    
  1299.                         Mutexunlock(EGNP_INT_Mux)
    
  1300.                         If TCallbacks.V_Server_Message <> 0 Then TCallbacks.V_Server_Message(TServID, TCUID, TUI(1), TS(1), TUI(2), TMyPtrFrom, TMyPtrTo, TCRV): If TCRV <> 0 Then Mutexlock(EGNP_INT_Mux): Continue Do
    
  1301.                         Mutexlock(EGNP_INT_Mux)
    
  1302.                         .V_MyPtr = TMyPtrFrom
    
  1303.                         If TCPtrS <> 0 Then TCPtrS->V_MyPtr = TMyPtrTo
    
  1304.                         If TUI(1) <> 0 Then
    
  1305.                             TCPtrS = Cast(EGNP_INT_ServerClient_Type Ptr, TUI(1))
    
  1306.                             TCPtr = V_ClientPtr->V_Server->V_ClientF
    
  1307.                             Do Until TCPtr = 0
    
  1308.                                 If TCPtr <> TCPtrS Then TCPtr = TCPtr->V_Next: Continue Do
    
  1309.                                 If (TCPtr->V_State And EGNP_CSE_Ready) = 0 Then TCPtr = TCPtr->V_Next: Continue Do
    
  1310.                                 EGNP_INT_AsyncSendToOne(TCPtr->V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_UserMessage, TData1))
    
  1311.                                 Exit Do
    
  1312.                             Loop
    
  1313.                         Else: EGNP_INT_AsyncSendToAll(.V_Server, EGNP_INT_BuildCMD(EGNP_CMD_UserMessage, TData1))
    
  1314.                         End If
    
  1315.                         
    
  1316.                     Case EGNP_CMD_UserData
    
  1317.                         TData1 = EGNP_INT_BuildUInteger(TCUID) & TData
    
  1318.                         RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1319.                         RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1320.                         If Len(TS(1)) > &HFFFF Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1321.                         TCPtrS = EGNP_INT_Client_GetByID(.V_Server, TUI(1))
    
  1322.                         If TCPtrS <> 0 Then TMyPtrTo = TCPtrS->V_MyPtr Else TMyPtrTo = 0
    
  1323.                         TMyPtrFrom = .V_MyPtr
    
  1324.                         Mutexunlock(EGNP_INT_Mux)
    
  1325.                         If TCallbacks.V_Server_Data <> 0 Then TCallbacks.V_Server_Data(TServID, TCUID, TUI(1), TS(1), TMyPtrFrom, TMyPtrTo, TCRV): If TCRV <> 0 Then Mutexlock(EGNP_INT_Mux): Continue Do
    
  1326.                         Mutexlock(EGNP_INT_Mux)
    
  1327.                         .V_MyPtr = TMyPtrFrom
    
  1328.                         If TCPtrS <> 0 Then TCPtrS->V_MyPtr = TMyPtrTo
    
  1329.                         If TUI(1) <> 0 Then
    
  1330.                             TCPtrS = Cast(EGNP_INT_ServerClient_Type Ptr, TUI(1))
    
  1331.                             TCPtr = V_ClientPtr->V_Server->V_ClientF
    
  1332.                             Do Until TCPtr = 0
    
  1333.                                 If TCPtr <> TCPtrS Then TCPtr = TCPtr->V_Next: Continue Do
    
  1334.                                 If (TCPtr->V_State And EGNP_CSE_Ready) = 0 Then TCPtr = TCPtr->V_Next: Continue Do
    
  1335.                                 EGNP_INT_AsyncSendToOne(TCPtr->V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_UserData, TData1))
    
  1336.                                 Exit Do
    
  1337.                             Loop
    
  1338.                         Else: EGNP_INT_AsyncSendToAll(.V_Server, EGNP_INT_BuildCMD(EGNP_CMD_UserData, TData1))
    
  1339.                         End If
    
  1340.                     
    
  1341.                     Case EGNP_CMD_UserMoveDbl
    
  1342.                         TData1 = EGNP_INT_BuildUInteger(TCUID) & TData
    
  1343.                         RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1344.                         RV = EGNP_INT_GetDouble(TData, TD(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1345.                         RV = EGNP_INT_GetDouble(TData, TD(2)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1346.                         RV = EGNP_INT_GetDouble(TData, TD(3)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1347.                         RV = EGNP_INT_GetUInteger(TData, TUI(5)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1348.                         TCPtrS = EGNP_INT_Client_GetByID(.V_Server, TUI(1))
    
  1349.                         If TCPtrS <> 0 Then TMyPtrTo = TCPtrS->V_MyPtr Else TMyPtrTo = 0
    
  1350.                         TMyPtrFrom = .V_MyPtr
    
  1351.                         Mutexunlock(EGNP_INT_Mux)
    
  1352.                         If TCallbacks.V_Server_MoveDbl <> 0 Then TCallbacks.V_Server_MoveDbl(TServID, TCUID, TUI(1), TD(1), TD(2), TD(3), TUI(5), TMyPtrFrom, TMyPtrTo, TCRV): If TCRV <> 0 Then Mutexlock(EGNP_INT_Mux): Continue Do
    
  1353.                         Mutexlock(EGNP_INT_Mux)
    
  1354.                         .V_MyPtr = TMyPtrFrom
    
  1355.                         If TCPtrS <> 0 Then TCPtrS->V_MyPtr = TMyPtrTo
    
  1356.                         If TUI(1) <> 0 Then
    
  1357.                             TCPtrS = Cast(EGNP_INT_ServerClient_Type Ptr, TUI(1))
    
  1358.                             TCPtr = V_ClientPtr->V_Server->V_ClientF
    
  1359.                             Do Until TCPtr = 0
    
  1360.                                 If TCPtr <> TCPtrS Then TCPtr = TCPtr->V_Next: Continue Do
    
  1361.                                 If (TCPtr->V_State And EGNP_CSE_Ready) = 0 Then TCPtr = TCPtr->V_Next: Continue Do
    
  1362.                                 EGNP_INT_AsyncSendToOne(TCPtr->V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_UserData, TData1))
    
  1363.                                 Exit Do
    
  1364.                             Loop
    
  1365.                         Else: EGNP_INT_AsyncSendToAll(.V_Server, EGNP_INT_BuildCMD(EGNP_CMD_UserMoveDbl, TData1))
    
  1366.                         End If
    
  1367.                     
    
  1368.                     Case EGNP_CMD_UserMoveInt
    
  1369.                         TData1 = EGNP_INT_BuildUInteger(TCUID) & TData
    
  1370.                         RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1371.                         RV = EGNP_INT_GetUInteger(TData, TUI(2)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1372.                         RV = EGNP_INT_GetUInteger(TData, TUI(3)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1373.                         RV = EGNP_INT_GetUInteger(TData, TUI(4)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1374.                         RV = EGNP_INT_GetUInteger(TData, TUI(5)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1375.                         TCPtrS = EGNP_INT_Client_GetByID(.V_Server, TUI(1))
    
  1376.                         If TCPtrS <> 0 Then TMyPtrTo = TCPtrS->V_MyPtr Else TMyPtrTo = 0
    
  1377.                         TMyPtrFrom = .V_MyPtr
    
  1378.                         Mutexunlock(EGNP_INT_Mux)
    
  1379.                         If TCallbacks.V_Server_MoveInt <> 0 Then TCallbacks.V_Server_MoveInt(TServID, TCUID, TUI(1), TUI(2), TUI(3), TUI(4), TUI(5), TMyPtrFrom, TMyPtrTo, TCRV): If TCRV <> 0 Then Mutexlock(EGNP_INT_Mux): Continue Do
    
  1380.                         Mutexlock(EGNP_INT_Mux)
    
  1381.                         .V_MyPtr = TMyPtrFrom
    
  1382.                         If TCPtrS <> 0 Then TCPtrS->V_MyPtr = TMyPtrTo
    
  1383.                         If TUI(1) <> 0 Then
    
  1384.                             TCPtrS = Cast(EGNP_INT_ServerClient_Type Ptr, TUI(1))
    
  1385.                             TCPtr = V_ClientPtr->V_Server->V_ClientF
    
  1386.                             Do Until TCPtr = 0
    
  1387.                                 If TCPtr <> TCPtrS Then TCPtr = TCPtr->V_Next: Continue Do
    
  1388.                                 If (TCPtr->V_State And EGNP_CSE_Ready) = 0 Then TCPtr = TCPtr->V_Next: Continue Do
    
  1389.                                 EGNP_INT_AsyncSendToOne(TCPtr->V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_UserData, TData1))
    
  1390.                                 Exit Do
    
  1391.                             Loop
    
  1392.                         Else: EGNP_INT_AsyncSendToAll(.V_Server, EGNP_INT_BuildCMD(EGNP_CMD_UserMoveInt, TData1))
    
  1393.                         End If
    
  1394.                     
    
  1395.                     Case EGNP_GURU_UnknownCMD
    
  1396.                     
    
  1397.                     Case Else
    
  1398.                         If .V_Server->V_UseAccounts = 0 Then
    
  1399.                             EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1400.                             Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1401.                         End If
    
  1402.                         If (.V_UserFlags And EGNP_APE_Registered) = 0 Then
    
  1403.                             EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1404.                             Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1405.                         End If
    
  1406.                         RV = EGNP_INT_GetDouble(TData, TSerial): If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1407.                         Select Case TCMD
    
  1408.                             Case EGNP_CMD_AccList
    
  1409.                                 If (.V_UserFlags And (EGNP_APE_SuperModerator Or EGNP_APE_Administrator)) = 0 Then
    
  1410.                                     EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1411.                                     Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1412.                                 End If
    
  1413.                                 RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1414.                                 TS(1) = Lcase(TS(1))
    
  1415.                                 T = ""
    
  1416.                                 T += EGNP_INT_BuildDouble(TSerial)
    
  1417.                                 TAPtr = .V_Server->V_AccountF
    
  1418.                                 Do Until TAPtr = 0
    
  1419.                                     If TS(1) <> "" Then If TS(1) <> TAPtr->V_UsernameL Then TAPtr = TAPtr->V_Next: Continue Do
    
  1420.                                     TCPtr = .V_Server->V_ClientF
    
  1421.                                     Do Until TCPtr = 0
    
  1422.                                         If TCPtr->V_Username = TAPtr->V_Username Then Exit Do
    
  1423.                                         TCPtr = TCPtr->V_Next
    
  1424.                                     Loop
    
  1425.                                     If TCPtr <> 0 Then
    
  1426.                                         T += EGNP_INT_BuildUInteger(Cast(Uinteger, TCPtr))
    
  1427.                                     Else: T += EGNP_INT_BuildUInteger(TAPtr->V_UserFlags)
    
  1428.                                     End If
    
  1429.                                     T += EGNP_INT_BuildString(TAPtr->V_Username)
    
  1430.                                     T += EGNP_INT_BuildString(TAPtr->V_Nickname)
    
  1431.                                     T += EGNP_INT_BuildUInteger(TAPtr->V_UserFlags)
    
  1432.                                     TAPtr = TAPtr->V_Next
    
  1433.                                 Loop
    
  1434.                                 EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_AccList, T), 0)
    
  1435.                                 
    
  1436.                             Case EGNP_CMD_AccDestroy
    
  1437.                                 RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1438.                                 If Len(TS(1)) = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1439.                                 TS(1) = Lcase(TS(1))
    
  1440.                                 If Lcase(.V_Username) <> TS(1) Then
    
  1441.                                     If (.V_UserFlags And EGNP_APE_Administrator) = 0 Then
    
  1442.                                         EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1443.                                         Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1444.                                     End If
    
  1445.                                 End If
    
  1446.                                 TAPtr = .V_Server->V_AccountF
    
  1447.                                 Do Until TAPtr = 0
    
  1448.                                     If TS(1) = TAPtr->V_UsernameL Then Exit Do
    
  1449.                                     TAPtr = TAPtr->V_Next
    
  1450.                                 Loop
    
  1451.                                 If TAPtr = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1452.                                 If TAPtr->V_Next <> 0 Then TAPtr->V_Next->V_Prev = TAPtr->V_Prev
    
  1453.                                 If TAPtr->V_Prev <> 0 Then TAPtr->V_Prev->V_Next = TAPtr->V_Next
    
  1454.                                 If .V_Server->V_AccountF = TAPtr Then .V_Server->V_AccountF = TAPtr->V_Next
    
  1455.                                 If .V_Server->V_AccountL = TAPtr Then .V_Server->V_AccountL = TAPtr->V_Prev
    
  1456.                                 Deallocate(TAPtr)
    
  1457.                                 RV = EGNP_INT_Server_AccountRestore(.V_Server)
    
  1458.                                 EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(TCMD, EGNP_INT_BuildDouble(TSerial) & EGNP_INT_BuildUInteger(RV)), 0)
    
  1459.                                 
    
  1460.                             Case EGNP_CMD_AccSetFlags
    
  1461.                                 If (.V_UserFlags And (EGNP_APE_SuperModerator Or EGNP_APE_Administrator)) = 0 Then
    
  1462.                                     EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1463.                                     Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1464.                                 End If
    
  1465.                                 RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1466.                                 RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1467.                                 If Len(TS(1)) = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1468.                                 TS(1) = Lcase(TS(1))
    
  1469.                                 TAPtr = .V_Server->V_AccountF
    
  1470.                                 Do Until TAPtr = 0
    
  1471.                                     If TS(1) = TAPtr->V_UsernameL Then Exit Do
    
  1472.                                     TAPtr = TAPtr->V_Next
    
  1473.                                 Loop
    
  1474.                                 If TAPtr = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1475.                                 TAPtr->V_UserFlags = EGNP_APE_Registered Or TUI(1)
    
  1476.                                 RV = EGNP_INT_Server_AccountRestore(.V_Server)
    
  1477.                                 EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(TCMD, EGNP_INT_BuildDouble(TSerial) & EGNP_INT_BuildUInteger(RV)), 0)
    
  1478.                                 
    
  1479.                             Case EGNP_CMD_AccSetNick
    
  1480.                                 If Lcase(.V_Username) <> TS(1) Then
    
  1481.                                     If (.V_UserFlags And (EGNP_APE_SuperModerator Or EGNP_APE_Administrator)) = 0 Then
    
  1482.                                         EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1483.                                         Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1484.                                     End If
    
  1485.                                 End If
    
  1486.                                 RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1487.                                 RV = EGNP_INT_GetString(TData, TS(2)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1488.                                 If Len(TS(1)) = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1489.                                 If Len(TS(2)) = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1490.                                 TS(1) = Lcase(TS(1))
    
  1491.                                 TAPtr = .V_Server->V_AccountF
    
  1492.                                 Do Until TAPtr = 0
    
  1493.                                     If TS(1) = TAPtr->V_UsernameL Then Exit Do
    
  1494.                                     TAPtr = TAPtr->V_Next
    
  1495.                                 Loop
    
  1496.                                 If TAPtr = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1497.                                 TAPtr->V_Nickname = TS(2)
    
  1498.                                 RV = EGNP_INT_Server_AccountRestore(.V_Server)
    
  1499.                                 EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(TCMD, EGNP_INT_BuildDouble(TSerial) & EGNP_INT_BuildUInteger(RV)), 0)
    
  1500.                                 
    
  1501.                             Case EGNP_CMD_AccSetPass
    
  1502.                                 If Lcase(.V_Username) <> TS(1) Then
    
  1503.                                     If (.V_UserFlags And (EGNP_APE_SuperModerator Or EGNP_APE_Administrator)) = 0 Then
    
  1504.                                         EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1505.                                         Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1506.                                     End If
    
  1507.                                 End If
    
  1508.                                 RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1509.                                 RV = EGNP_INT_GetString(TData, TS(2)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1510.                                 If Len(TS(1)) = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1511.                                 If Len(TS(2)) = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1512.                                 TS(1) = Lcase(TS(1))
    
  1513.                                 TAPtr = .V_Server->V_AccountF
    
  1514.                                 Do Until TAPtr = 0
    
  1515.                                     If TS(1) = TAPtr->V_UsernameL Then Exit Do
    
  1516.                                     TAPtr = TAPtr->V_Next
    
  1517.                                 Loop
    
  1518.                                 If TAPtr = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1519.                                 TAPtr->V_Password = TS(2)
    
  1520.                                 RV = EGNP_INT_Server_AccountRestore(.V_Server)
    
  1521.                                 EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(TCMD, EGNP_INT_BuildDouble(TSerial) & EGNP_INT_BuildUInteger(RV)), 0)
    
  1522.                                 
    
  1523.                             Case EGNP_CMD_UserKick
    
  1524.                                 If (.V_UserFlags And (EGNP_APE_Moderator Or EGNP_APE_SuperModerator Or EGNP_APE_Administrator)) = 0 Then
    
  1525.                                     EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_CommandDenied), 0)
    
  1526.                                     Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1527.                                 End If
    
  1528.                                 RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1529.                                 TCPtr = EGNP_INT_Client_GetByID(.V_Server, TUI(1))
    
  1530.                                 If TCPtr = 0 Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_ParameterError), 0): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1531.                                 TSNE_Disconnect(TCPtr->V_TSNEID)
    
  1532.                                 EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(TCMD, EGNP_INT_BuildDouble(TSerial) & EGNP_INT_BuildUInteger(RV)), 0)
    
  1533.                                 
    
  1534.                             Case Else: If EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_UnknownCMD), 0) <> TSNE_Const_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1535.                         End Select
    
  1536.                 End Select
    
  1537.         End Select
    
  1538.     Loop
    
  1539. End With
    
  1540. Mutexunlock(EGNP_INT_Mux)
    
  1541. End Sub
    
  1542. 
    
  1543. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1544. Sub EGNP_INT_Server_NewConnection(Byval V_TSNEID As Uinteger, Byval V_RequestID As Socket, Byval V_IPA As String)
    
  1545. Dim RV As Integer
    
  1546. Dim TTSNEID As Uinteger
    
  1547. Mutexlock(EGNP_INT_Mux)
    
  1548. Dim TSPtr As EGNP_INT_Server_Type Ptr = EGNP_INT_Server_F
    
  1549. Do Until TSPtr = 0
    
  1550.     If TSPtr->V_TSNEIDTCP = V_TSNEID Then Exit Do
    
  1551.     TSPtr = TSPtr->V_Next
    
  1552. Loop
    
  1553. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): TSNE_Create_Accept(V_RequestID, TTSNEID, "", 0, @EGNP_INT_Server_ConnectionDenied, 0, , , , Cast(Any Ptr, EGNP_GURU_InternalError)): Exit Sub
    
  1554. Dim TServID As Uinteger = Cast(Uinteger, TSPtr)
    
  1555. Dim TCRV As Integer
    
  1556. With *TSPtr
    
  1557.     If .V_Callbacks.V_Server_ConnectionRequest <> 0 Then .V_Callbacks.V_Server_ConnectionRequest(TServID, V_IPA, TCRV)
    
  1558.     If TCRV <> 0 Then Mutexunlock(EGNP_INT_Mux): TSNE_Create_Accept(V_RequestID, TTSNEID, "", 0, @EGNP_INT_Server_ConnectionDenied, 0, , , , Cast(Any Ptr, EGNP_CMD_ServerConnectionDenied)): Exit Sub
    
  1559.     If .V_Enabled = 0 Then Mutexunlock(EGNP_INT_Mux): TSNE_Create_Accept(V_RequestID, TTSNEID, "", 0, @EGNP_INT_Server_ConnectionDenied, 0, , , , Cast(Any Ptr, EGNP_CMD_ServerOffline)): Exit Sub
    
  1560.     If .V_ClientC >= .V_MaxPlayer Then Mutexunlock(EGNP_INT_Mux): TSNE_Create_Accept(V_RequestID, TTSNEID, "", 0, @EGNP_INT_Server_ConnectionDenied, 0, , , , Cast(Any Ptr, EGNP_CMD_ServerFull)): Exit Sub
    
  1561.     Dim TCPtr As EGNP_INT_ServerClient_Type Ptr = Callocate(Sizeof(EGNP_INT_ServerClient_Type))
    
  1562.     Dim TIPA As String
    
  1563.     RV = TSNE_Create_Accept(V_RequestID, TTSNEID, TIPA, @EGNP_INT_Server_Disconnected, @EGNP_INT_Server_Connected, @EGNP_INT_Server_NewData, , , , TCPtr)
    
  1564.     If RV <> TSNE_Const_NoError Then Deallocate(TCPtr): Exit Sub
    
  1565.     If .V_ClientL <> 0 Then
    
  1566.         .V_ClientL->V_Next = TCPtr
    
  1567.         .V_ClientL->V_Next->V_Prev = .V_ClientL
    
  1568.         .V_ClientL = .V_ClientL->V_Next
    
  1569.     Else
    
  1570.         .V_ClientL = TCPtr
    
  1571.         .V_ClientF = .V_ClientL
    
  1572.     End If
    
  1573.     .V_ClientC += 1
    
  1574.     With *.V_ClientL
    
  1575.         .V_Server           = TSPtr
    
  1576.         .V_TSNEID           = TTSNEID
    
  1577.         .V_TimeCon          = Now()
    
  1578.         .V_TimeOut          = Timer() + 60
    
  1579.         .V_TimePing         = Timer() + 10
    
  1580.         .V_IPA              = TIPA
    
  1581.         .V_State            = EGNP_CSE_Connecting
    
  1582.     End With
    
  1583. End With
    
  1584. Mutexunlock(EGNP_INT_Mux)
    
  1585. End Sub
    
  1586. 
    
  1587. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1588. Function EGNP_INT_Server_GetPtrByID(V_ServerID As Uinteger) As EGNP_INT_Server_Type Ptr
    
  1589. Dim TXPtr As EGNP_INT_Server_Type Ptr = Cast(EGNP_INT_Server_Type Ptr, V_ServerID)
    
  1590. Dim TSPtr As EGNP_INT_Server_Type Ptr = EGNP_INT_Server_F
    
  1591. Do Until TSPtr = 0
    
  1592.     If TSPtr = TXPtr Then Return TSPtr
    
  1593.     TSPtr = TSPtr->V_Next
    
  1594. Loop
    
  1595. Return 0
    
  1596. End Function
    
  1597. 
    
  1598. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1599. Function EGNP_Server_Create(Byref R_ServerID As Uinteger, V_Port As Ushort, V_Name As String, V_Description As String, V_Password As String = "", V_MaxPlayer As Ushort = 10, V_UDPPipePort As Ushort = 0) As EGNP_GURU_Enum
    
  1600. If V_MaxPlayer < 1 Then Return EGNP_GURU_ParameterError
    
  1601. If V_Port < 1 Then Return EGNP_GURU_ParameterError
    
  1602. If V_Name = "" Then Return EGNP_GURU_ParameterError
    
  1603. If Len(V_Name) > &HFF Then Return EGNP_GURU_ParameterError
    
  1604. If V_Description = "" Then Return EGNP_GURU_ParameterError
    
  1605. If Len(V_Description) > &HFFF Then Return EGNP_GURU_ParameterError
    
  1606. Dim TTID(1 To 3) As Uinteger
    
  1607. Dim RV As Integer
    
  1608. RV = TSNE_Create_Server(TTID(1), V_Port, 100, @EGNP_INT_Server_NewConnection)
    
  1609. If RV <> TSNE_Const_NoError Then Return RV
    
  1610. 'RV = TSNE_Create_UDP_RX(TTID(2), V_UDPPipePort)
    
  1611. 'If RV <> TSNE_Const_NoError Then TSNE_Disconnect(TTID(1)): Return RV
    
  1612. 'RV = TSNE_Create_UDP_TX(TTID(3), V_UDPPipePort)
    
  1613. 'If RV <> TSNE_Const_NoError Then TSNE_Disconnect(TTID(1)): TSNE_Disconnect(TTID(2)): Return RV
    
  1614. Mutexlock(EGNP_INT_Mux)
    
  1615. If EGNP_INT_Server_L <> 0 Then
    
  1616.     EGNP_INT_Server_L->V_Next = Callocate(Sizeof(EGNP_INT_Server_Type))
    
  1617.     EGNP_INT_Server_L->V_Next->V_Prev = EGNP_INT_Server_L
    
  1618.     EGNP_INT_Server_L = EGNP_INT_Server_L->V_Next
    
  1619. Else
    
  1620.     EGNP_INT_Server_L = Callocate(Sizeof(EGNP_INT_Server_Type))
    
  1621.     EGNP_INT_Server_F = EGNP_INT_Server_L
    
  1622. End If
    
  1623. With *EGNP_INT_Server_L
    
  1624.     .V_CreateTime       = Now()
    
  1625.     .V_Name             = V_Name
    
  1626.     .V_Description      = V_Description
    
  1627.     .V_PortTCP          = V_Port
    
  1628.     .V_Password         = V_Password
    
  1629.     .V_MaxPlayer        = V_MaxPlayer
    
  1630.     .V_PortUDP          = V_UDPPipePort
    
  1631.     .V_Enabled          = 0
    
  1632.     .V_TSNEIDTCP        = TTID(1)
    
  1633.     .V_TSNEIDUDPRX      = TTID(2)
    
  1634.     .V_TSNEIDUDPTX      = TTID(3)
    
  1635. End With
    
  1636. R_ServerID = Cast(Uinteger, EGNP_INT_Server_L)
    
  1637. Mutexunlock(EGNP_INT_Mux)
    
  1638. Return EGNP_GURU_NoError
    
  1639. End Function
    
  1640. 
    
  1641. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1642. Function EGNP_Server_Destroy(V_ServerID As Uinteger) As EGNP_GURU_Enum
    
  1643. Mutexlock(EGNP_INT_Mux)
    
  1644. Dim TSPtr As EGNP_INT_Server_Type Ptr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1645. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  1646. Dim TTID(0 To 3) As Uinteger
    
  1647. With *TSPtr
    
  1648.     If .V_TSNEIDTCP <> 0 Then TTID(1) = .V_TSNEIDTCP: .V_TSNEIDTCP = 0
    
  1649.     If .V_TSNEIDUDPRX <> 0 Then TTID(2) = .V_TSNEIDUDPRX: .V_TSNEIDUDPRX = 0
    
  1650.     If .V_TSNEIDUDPTX <> 0 Then TTID(3) = .V_TSNEIDUDPTX: .V_TSNEIDUDPTX = 0
    
  1651. End With
    
  1652. Mutexunlock(EGNP_INT_Mux)
    
  1653. TSNE_Disconnect(TTID(1))
    
  1654. TSNE_Disconnect(TTID(2))
    
  1655. TSNE_Disconnect(TTID(3))
    
  1656. TSNE_WaitClose(TTID(1))
    
  1657. TSNE_WaitClose(TTID(2))
    
  1658. TSNE_WaitClose(TTID(3))
    
  1659. Mutexlock(EGNP_INT_Mux)
    
  1660. TSPtr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1661. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_InternalError
    
  1662. Dim TCPtr As EGNP_INT_ServerClient_Type Ptr
    
  1663. With *TSPtr
    
  1664.     TCPtr = .V_ClientF
    
  1665.     Do Until TCPtr = 0
    
  1666.         TSNE_Disconnect(TCPtr->V_TSNEID)
    
  1667.         TCPtr = TCPtr->V_Next
    
  1668.     Loop
    
  1669. End With
    
  1670. Mutexunlock(EGNP_INT_Mux)
    
  1671. Do
    
  1672.     Mutexlock(EGNP_INT_Mux)
    
  1673.     TSPtr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1674.     If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_InternalError
    
  1675.     If TSPtr->V_ClientF = 0 Then Mutexunlock(EGNP_INT_Mux): Exit Do
    
  1676.     Mutexunlock(EGNP_INT_Mux)
    
  1677.     'USleep 10000
    
  1678.     Sleep 10, 1
    
  1679. Loop
    
  1680. Mutexlock(EGNP_INT_Mux)
    
  1681. TSPtr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1682. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_InternalError
    
  1683. If TSPtr->V_Next <> 0 Then TSPtr->V_Next->V_Prev = TSPtr->V_Prev
    
  1684. If TSPtr->V_Prev <> 0 Then TSPtr->V_Prev->V_Next = TSPtr->V_Next
    
  1685. If EGNP_INT_Server_F = TSPtr Then EGNP_INT_Server_F = TSPtr->V_Next
    
  1686. If EGNP_INT_Server_L = TSPtr Then EGNP_INT_Server_L = TSPtr->V_Prev
    
  1687. Deallocate(TSPtr)
    
  1688. Mutexunlock(EGNP_INT_Mux)
    
  1689. Return EGNP_GURU_NoError
    
  1690. End Function
    
  1691. 
    
  1692. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1693. Function EGNP_Server_SetCallbacks(V_ServerID As Uinteger, V_Callbacks As EGNP_Callback_Type) As EGNP_GURU_Enum
    
  1694. Mutexlock(EGNP_INT_Mux)
    
  1695. Dim TSPtr As EGNP_INT_Server_Type Ptr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1696. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  1697. TSPtr->V_Callbacks = V_Callbacks
    
  1698. Mutexunlock(EGNP_INT_Mux)
    
  1699. Return EGNP_GURU_NoError
    
  1700. End Function
    
  1701. 
    
  1702. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1703. Function EGNP_Server_Enable(V_ServerID As Uinteger) As EGNP_GURU_Enum
    
  1704. Mutexlock(EGNP_INT_Mux)
    
  1705. Dim TSPtr As EGNP_INT_Server_Type Ptr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1706. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  1707. TSPtr->V_Enabled = 1
    
  1708. Mutexunlock(EGNP_INT_Mux)
    
  1709. Return EGNP_GURU_NoError
    
  1710. End Function
    
  1711. 
    
  1712. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1713. Function EGNP_Server_Disable(V_ServerID As Uinteger) As EGNP_GURU_Enum
    
  1714. Mutexlock(EGNP_INT_Mux)
    
  1715. Dim TSPtr As EGNP_INT_Server_Type Ptr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1716. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  1717. TSPtr->V_Enabled = 0
    
  1718. Mutexunlock(EGNP_INT_Mux)
    
  1719. Return EGNP_GURU_NoError
    
  1720. End Function
    
  1721. 
    
  1722. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1723. Function EGNP_Server_PublicRegister(V_ServerID As Uinteger, V_GameName As String, V_GameVersion As Uinteger, V_Username As String = "", V_Password As String = "") As EGNP_GURU_Enum
    
  1724. If V_Username <> "" Then If Len(V_Username) > &HFFF Then Return EGNP_GURU_ParameterError
    
  1725. If V_Password <> "" Then If Len(V_Password) > &HFFF Then Return EGNP_GURU_ParameterError
    
  1726. Mutexlock(EGNP_INT_Mux)
    
  1727. Dim TSPtr As EGNP_INT_Server_Type Ptr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1728. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  1729. With *TSPtr
    
  1730.     .V_Public       = 1
    
  1731.     .V_PublicUpdate = 1
    
  1732.     .V_GameName     = V_GameName
    
  1733.     .V_GameVersion  = V_GameVersion
    
  1734. End With
    
  1735. Mutexunlock(EGNP_INT_Mux)
    
  1736. Return EGNP_GURU_NoError
    
  1737. End Function
    
  1738. 
    
  1739. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1740. Sub EGNP_INT_Server_AccountClear(Byref RV_AccF As EGNP_INT_Account_Type Ptr, Byref RV_AccL As EGNP_INT_Account_Type Ptr)
    
  1741. Do Until RV_AccF = 0
    
  1742.     RV_AccL = RV_AccF->V_Next
    
  1743.     Deallocate(RV_AccF)
    
  1744.     RV_AccF = RV_AccL
    
  1745. Loop
    
  1746. End Sub
    
  1747. 
    
  1748. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1749. Function EGNP_Server_AccountEnable(V_ServerID As Uinteger, V_AccountFilePathName As String) As EGNP_GURU_Enum
    
  1750. Mutexlock(EGNP_INT_Mux)
    
  1751. Dim TSPtr As EGNP_INT_Server_Type Ptr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1752. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  1753. TSPtr->V_UseAccounts = 1
    
  1754. Dim TFN As Integer = Freefile()
    
  1755. If Open(V_AccountFilePathName For Binary As #TFN) <> 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_CantOpenFile
    
  1756. Dim T As String
    
  1757. Dim TFLen As Uinteger = Lof(TFN)
    
  1758. Dim TFPos As Uinteger
    
  1759. Dim TLen As Integer
    
  1760. Dim RV As Integer
    
  1761. Dim TUser As String
    
  1762. Dim TPass As String
    
  1763. Dim TNick As String
    
  1764. Dim TFlag As EGNP_AccountPermissions_Enum
    
  1765. With *TSPtr
    
  1766.     .V_AccountFile  = V_AccountFilePathName
    
  1767.     EGNP_INT_Server_AccountClear(.V_AccountF, .V_AccountL)
    
  1768.     Do
    
  1769.         If (TFLen - TFPos) < 4 Then
    
  1770.             If (TFLen - TFPos) = 0 Then Mutexunlock(EGNP_INT_Mux): Close #TFN: Return EGNP_GURU_NoError
    
  1771.             EGNP_INT_Server_AccountClear(.V_AccountF, .V_AccountL): Mutexunlock(EGNP_INT_Mux): Close #TFN: Return EGNP_GURU_ParseLenError
    
  1772.         End If
    
  1773.         T = Space(4)
    
  1774.         Get #TFN, TFPos + 1, T: TFPos += Len(T)
    
  1775.         TLen = (T[0] Shl 24) Or (T[1] Shl 16) Or (T[2] Shl 8) Or T[3]
    
  1776.         If TLen > &HFFFFF Then EGNP_INT_Server_AccountClear(.V_AccountF, .V_AccountL): Mutexunlock(EGNP_INT_Mux): Close #TFN: Return EGNP_GURU_ParseLenError
    
  1777.         If (TFPos + TLen) > TFLen Then EGNP_INT_Server_AccountClear(.V_AccountF, .V_AccountL): Mutexunlock(EGNP_INT_Mux): Close #TFN: Return EGNP_GURU_ParseLenError
    
  1778.         T = Space(TLen)
    
  1779.         Get #TFN, TFPos + 1, T: TFPos += Len(T)
    
  1780.         RV = EGNP_INT_GetUInteger(T, TFlag):    If RV <> EGNP_GURU_NoError Then EGNP_INT_Server_AccountClear(.V_AccountF, .V_AccountL): Mutexunlock(EGNP_INT_Mux): Close #TFN: Return EGNP_GURU_ParseLenError
    
  1781.         RV = EGNP_INT_GetString(T, TUser):      If RV <> EGNP_GURU_NoError Then EGNP_INT_Server_AccountClear(.V_AccountF, .V_AccountL): Mutexunlock(EGNP_INT_Mux): Close #TFN: Return EGNP_GURU_ParseLenError
    
  1782.         RV = EGNP_INT_GetString(T, TPass):      If RV <> EGNP_GURU_NoError Then EGNP_INT_Server_AccountClear(.V_AccountF, .V_AccountL): Mutexunlock(EGNP_INT_Mux): Close #TFN: Return EGNP_GURU_ParseLenError
    
  1783.         RV = EGNP_INT_GetString(T, TNick):      If RV <> EGNP_GURU_NoError Then EGNP_INT_Server_AccountClear(.V_AccountF, .V_AccountL): Mutexunlock(EGNP_INT_Mux): Close #TFN: Return EGNP_GURU_ParseLenError
    
  1784.         If .V_AccountL <> 0 Then
    
  1785.             .V_AccountL->V_Next = Callocate(Sizeof(EGNP_INT_Account_Type))
    
  1786.             .V_AccountL->V_Next->V_Prev = .V_AccountL
    
  1787.             .V_AccountL = .V_AccountL->V_Next
    
  1788.         Else
    
  1789.             .V_AccountL = Callocate(Sizeof(EGNP_INT_Account_Type))
    
  1790.             .V_AccountF = .V_AccountL
    
  1791.         End If
    
  1792.         With *.V_AccountL
    
  1793.             .V_Username     = TUser
    
  1794.             .V_UsernameL    = Lcase(.V_Username)
    
  1795.             .V_Password     = TPass
    
  1796.             .V_Nickname     = TNick
    
  1797.             .V_UserFlags    = TFlag
    
  1798.         End With
    
  1799.     Loop
    
  1800. End With
    
  1801. Mutexunlock(EGNP_INT_Mux)
    
  1802. Return EGNP_GURU_NoError
    
  1803. End Function
    
  1804. 
    
  1805. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1806. Function EGNP_Server_AccountAdd(V_ServerID As Uinteger, V_Username As String, V_Password As String, V_Nickname As String, V_Flags As EGNP_AccountPermissions_Enum = EGNP_APE_Registered) As EGNP_GURU_Enum
    
  1807. Mutexlock(EGNP_INT_Mux)
    
  1808. Dim TSPtr As EGNP_INT_Server_Type Ptr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1809. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  1810. Dim RV As EGNP_GURU_Enum = EGNP_INT_Server_AccountAdd(TSPtr, V_Username, OSC_Crypt(V_Username, V_Password, "egnp", 4), V_Nickname, V_Flags)
    
  1811. Mutexunlock(EGNP_INT_Mux)
    
  1812. Return RV
    
  1813. End Function
    
  1814. 
    
  1815. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1816. Function EGNP_Server_SetClientFlag(V_ServerID As Uinteger, V_UserID As Uinteger, V_Flags As EGNP_AccountPermissions_Enum) As EGNP_GURU_Enum
    
  1817. Mutexlock(EGNP_INT_Mux)
    
  1818. Dim TSPtr As EGNP_INT_Server_Type Ptr = EGNP_INT_Server_GetPtrByID(V_ServerID)
    
  1819. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  1820. Dim TSCPtr As EGNP_INT_ServerClient_Type Ptr = EGNP_INT_Client_GetByID(TSPtr, V_UserID)
    
  1821. If TSCPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  1822. TSCPtr->V_UserFlags = V_Flags
    
  1823. Mutexunlock(EGNP_INT_Mux)
    
  1824. Return EGNP_GURU_NoError
    
  1825. End Function
    
  1826. 
    
  1827. 
    
  1828. 
    
  1829. 
    
  1830. 
    
  1831. 
    
  1832. 
    
  1833. '####################################################################################################################################################
    
  1834. '####################################################################################################################################################
    
  1835. '####################################################################################################################################################
    
  1836. 
    
  1837. 
    
  1838. 
    
  1839. 
    
  1840. 
    
  1841. 
    
  1842. 
    
  1843. '####################################################################################################################################################
    
  1844. Sub EGNP_INT_Client_Disconnected(Byval V_TSNEID As Uinteger, Byval V_ClientPtr As EGNP_INT_Client_Type Ptr)
    
  1845. If V_ClientPtr = 0 Then Exit Sub
    
  1846. Mutexlock(EGNP_INT_Mux)
    
  1847. V_ClientPtr->V_State = EGNP_CSE_Disconnected
    
  1848. Dim TCallbacks As EGNP_Callback_Type = V_ClientPtr->V_Callbacks
    
  1849. Mutexunlock(EGNP_INT_Mux)
    
  1850. If TCallbacks.V_StateConnection <> 0 Then TCallbacks.V_StateConnection(Cast(Uinteger, V_ClientPtr), EGNP_CSE_Disconnected)
    
  1851. End Sub
    
  1852. 
    
  1853. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1854. Sub EGNP_INT_Client_Connected(Byval V_TSNEID As Uinteger, Byval V_ClientPtr As EGNP_INT_Client_Type Ptr)
    
  1855. If V_ClientPtr = 0 Then TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1856. Mutexlock(EGNP_INT_Mux)
    
  1857. V_ClientPtr->V_State = EGNP_CSE_Connected
    
  1858. Dim TCallbacks As EGNP_Callback_Type = V_ClientPtr->V_Callbacks
    
  1859. Mutexunlock(EGNP_INT_Mux)
    
  1860. If TCallbacks.V_StateConnection <> 0 Then TCallbacks.V_StateConnection(Cast(Uinteger, V_ClientPtr), EGNP_CSE_Connected)
    
  1861. End Sub
    
  1862. 
    
  1863. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  1864. Sub EGNP_INT_Client_NewData(Byval V_TSNEID As Uinteger, Byref V_Data As String, Byval V_ClientPtr As EGNP_INT_Client_Type Ptr)
    
  1865. 'Print "CDAT:" & V_ClientPtr
    
  1866. If V_ClientPtr = 0 Then TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1867. Dim TLen As Uinteger
    
  1868. Dim TCMD As EGNP_INT_CMD_Enum
    
  1869. Dim TData As String
    
  1870. Dim T As String
    
  1871. Dim TS(1 To 4) As String
    
  1872. Dim TUS As Ushort
    
  1873. Dim TUI(1 To 6) As Uinteger
    
  1874. Dim TD(1 To 3) As Double
    
  1875. Dim RV As EGNP_GURU_Enum
    
  1876. Dim TMyPtrFrom As Any Ptr
    
  1877. Dim TMyPtrTo As Any Ptr
    
  1878. Dim TUPtr As EGNP_User_Type Ptr
    
  1879. Dim TUPtr2 As EGNP_User_Type Ptr
    
  1880. Dim TWPtr As EGNP_INT_ClientAnswer_Type Ptr
    
  1881. Dim TWPtrN As EGNP_INT_ClientAnswer_Type Ptr
    
  1882. Dim TSerial As Double
    
  1883. Mutexlock(EGNP_INT_Mux)
    
  1884. With *V_ClientPtr
    
  1885.     Dim TCallbacks As EGNP_Callback_Type = .V_Callbacks
    
  1886.     Dim TID As Uinteger = Cast(Uinteger, V_ClientPtr)
    
  1887.     .V_DataTCP += V_Data
    
  1888.     Do
    
  1889.         If Len(.V_DataTCP) < 8 Then Mutexunlock(EGNP_INT_Mux): Exit Sub
    
  1890.         If Len(.V_DataTCP) > &HFFFFF Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_DATALenError)): Exit Sub
    
  1891.         TLen = (.V_DataTCP[0] Shl 24) Or (.V_DataTCP[1] Shl 16) Or (.V_DataTCP[2] Shl 8) Or .V_DataTCP[3]
    
  1892.         If TLen > &HFFFFFF Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_GURU_DATALenError)): Exit Sub
    
  1893.         If Len(.V_DataTCP) < TLen Then Mutexunlock(EGNP_INT_Mux): Exit Sub
    
  1894.         TCMD = (.V_DataTCP[4] Shl 24) Or (.V_DataTCP[5] Shl 16) Or (.V_DataTCP[6] Shl 8) Or .V_DataTCP[7]
    
  1895.         TData = Mid(.V_DataTCP, 9, TLen - 4)
    
  1896.         .V_DataTCP = Mid(.V_DataTCP, TLen + 5)
    
  1897.         If TCMD < 0 Then .V_LCMD = TCMD
    
  1898.         T = ""
    
  1899.         'Print #1, "IN  >" & EGNP_INT_GETCMDDESC(TCMD) & "<___>" & TLen & "<___>" & Len(TData) & "<"
    
  1900.         Select Case TCMD
    
  1901.             Case EGNP_CMD_ServerOffline
    
  1902.                 Mutexunlock(EGNP_INT_Mux)
    
  1903.                 TSNE_Disconnect(V_TSNEID)
    
  1904.                 If TCallbacks.V_StateConnection <> 0 Then TCallbacks.V_StateConnection(TID, EGNP_CSE_DisconnectedUnavaible)
    
  1905.                 Exit Do
    
  1906.                 
    
  1907.             Case EGNP_CMD_ServerFull
    
  1908.                 Mutexunlock(EGNP_INT_Mux)
    
  1909.                 TSNE_Disconnect(V_TSNEID)
    
  1910.                 If TCallbacks.V_StateConnection <> 0 Then TCallbacks.V_StateConnection(TID, EGNP_CSE_DisconnectedFull)
    
  1911.                 Exit Do
    
  1912.                 
    
  1913.             Case EGNP_CMD_ServerConnectionDenied
    
  1914.                 Mutexunlock(EGNP_INT_Mux)
    
  1915.                 TSNE_Disconnect(V_TSNEID)
    
  1916.                 If TCallbacks.V_StateConnection <> 0 Then TCallbacks.V_StateConnection(TID, EGNP_CSE_DisconnectedConnectionDenied)
    
  1917.                 Exit Do
    
  1918.                 
    
  1919.             Case EGNP_CMD_Crypt1
    
  1920.             Case EGNP_CMD_Crypt2
    
  1921.             Case EGNP_CMD_Crypt3
    
  1922.             
    
  1923.             Case EGNP_CMD_Ident
    
  1924.                 RV = EGNP_INT_GetString(TData, TS(1)):  If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1925.                 RV = EGNP_INT_GetString(TData, TS(2)):  If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1926.                 RV = EGNP_INT_GetUShort(TData, TUS):    If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1927.                 If Len(TData) < 3 Then                  If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1928.                 .V_ServerName               = TS(1)
    
  1929.                 .V_ServerDescription        = TS(2)
    
  1930.                 .V_ServerMaxPlayer          = TUS
    
  1931.                 .V_ServerPublic             = Iif(TData[0] = 1, 1, 0)
    
  1932.                 .V_ServerUseAccount         = Iif(TData[1] = 1, 1, 0)
    
  1933.                 .V_ServerUseServerPass      = Iif(TData[2] = 1, 1, 0)
    
  1934.                 
    
  1935.                 T = ""
    
  1936.                 T += EGNP_INT_BuildString(.V_Nickname)
    
  1937.                 If .V_ServerUseServerPass = 1 Then
    
  1938.                     T += EGNP_INT_BuildString(.V_PasswordServer)
    
  1939.                 Else: T += EGNP_INT_BuildString("")
    
  1940.                 End If
    
  1941.                 If EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_Ident, T)) <> TSNE_Const_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1942.                 
    
  1943.             Case EGNP_CMD_AccLogin
    
  1944.                 T += EGNP_INT_BuildString(.V_Username)
    
  1945.                 T += EGNP_INT_BuildString(.V_Password)
    
  1946.                 T += EGNP_INT_BuildString(.V_Nickname)
    
  1947.                 If EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(EGNP_CMD_AccLogin, T)) <> TSNE_Const_NoError Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  1948.                 
    
  1949.             Case EGNP_CMD_Ready
    
  1950.                 RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1951.                 .V_State    = EGNP_CSE_Ready
    
  1952.                 .V_MyID     = TUI(1)
    
  1953.                 Mutexunlock(EGNP_INT_Mux)
    
  1954.                 If TCallbacks.V_StateConnection <> 0 Then TCallbacks.V_StateConnection(TID, EGNP_CSE_Ready)
    
  1955.                 Mutexlock(EGNP_INT_Mux)
    
  1956.                 
    
  1957.             Case EGNP_CMD_UserJoin
    
  1958.                 RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1959.                 RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1960.                 RV = EGNP_INT_GetUInteger(TData, TUI(2)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1961.                 TUPtr = EGNP_INT_User_Add(V_ClientPtr, TUI(1), TS(1), TUI(2))
    
  1962.                 If TUPtr = 0 Then Continue Do
    
  1963.                 TMyPtrTo = TUPtr->V_MyPtr
    
  1964.                 Mutexunlock(EGNP_INT_Mux)
    
  1965.                 If TCallbacks.V_StateUser <> 0 Then TCallbacks.V_StateUser(TUI(1), EGNP_USE_Join, TMyPtrTo)
    
  1966.                 Mutexlock(EGNP_INT_Mux)
    
  1967.                 TUPtr->V_MyPtr = TMyPtrTo
    
  1968.                 
    
  1969.             Case EGNP_CMD_UserLeave
    
  1970.                 RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1971.                 TUPtr = EGNP_INT_User_Get(V_ClientPtr, TUI(1))
    
  1972.                 If TUPtr = 0 Then Continue Do
    
  1973.                 TMyPtrTo = TUPtr->V_MyPtr
    
  1974.                 EGNP_INT_User_Del(V_ClientPtr, TUI(1))
    
  1975.                 Mutexunlock(EGNP_INT_Mux)
    
  1976.                 If TCallbacks.V_StateUser <> 0 Then TCallbacks.V_StateUser(TUI(1), EGNP_USE_Leave, TMyPtrTo)
    
  1977.                 Mutexlock(EGNP_INT_Mux)
    
  1978.                 
    
  1979.             Case EGNP_CMD_UserMessage
    
  1980.                 If TCallbacks.V_Message = 0 Then Continue Do
    
  1981.                 RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1982.                 RV = EGNP_INT_GetUInteger(TData, TUI(2)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1983.                 RV = EGNP_INT_GetUInteger(TData, TUI(3)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1984.                 RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1985.                 TUPtr = EGNP_INT_User_Get(V_ClientPtr, TUI(1))
    
  1986.                 If TUPtr <> 0 Then TMyPtrFrom = TUPtr->V_MyPtr Else TMyPtrFrom = 0
    
  1987.                 TUPtr2 = EGNP_INT_User_Get(V_ClientPtr, TUI(2))
    
  1988.                 If TUPtr2 <> 0 Then TMyPtrTo = TUPtr2->V_MyPtr Else TMyPtrTo = 0
    
  1989.                 Mutexunlock(EGNP_INT_Mux)
    
  1990.                 TCallbacks.V_Message(TUI(1), TUI(2), TS(1), TUI(3), TMyPtrTo, TMyPtrFrom)
    
  1991.                 Mutexlock(EGNP_INT_Mux)
    
  1992.                 If TUPtr <> 0 Then TUPtr->V_MyPtr = TMyPtrFrom
    
  1993.                 If TUPtr2 <> 0 Then TUPtr2->V_MyPtr = TMyPtrTo
    
  1994.                 
    
  1995.             Case EGNP_CMD_UserData
    
  1996.                 If TCallbacks.V_Data = 0 Then Continue Do
    
  1997.                 RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1998.                 RV = EGNP_INT_GetUInteger(TData, TUI(2)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  1999.                 RV = EGNP_INT_GetString(TData, TS(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2000.                 TUPtr = EGNP_INT_User_Get(V_ClientPtr, TUI(1))
    
  2001.                 If TUPtr <> 0 Then TMyPtrFrom = TUPtr->V_MyPtr Else TMyPtrFrom = 0
    
  2002.                 TUPtr2 = EGNP_INT_User_Get(V_ClientPtr, TUI(2))
    
  2003.                 If TUPtr2 <> 0 Then TMyPtrTo = TUPtr2->V_MyPtr Else TMyPtrTo = 0
    
  2004.                 Mutexunlock(EGNP_INT_Mux)
    
  2005.                 TCallbacks.V_Data(TUI(1), TUI(2), TS(1), TMyPtrTo, TMyPtrFrom)
    
  2006.                 Mutexlock(EGNP_INT_Mux)
    
  2007.                 If TUPtr <> 0 Then TUPtr->V_MyPtr = TMyPtrFrom
    
  2008.                 If TUPtr2 <> 0 Then TUPtr2->V_MyPtr = TMyPtrTo
    
  2009.                 
    
  2010.             Case EGNP_CMD_UserMoveDbl
    
  2011.                 If TCallbacks.V_MoveInt = 0 Then Continue Do
    
  2012.                 RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2013.                 RV = EGNP_INT_GetUInteger(TData, TUI(2)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2014.                 RV = EGNP_INT_GetDouble(TData, TD(1)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2015.                 RV = EGNP_INT_GetDouble(TData, TD(2)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2016.                 RV = EGNP_INT_GetDouble(TData, TD(3)):      If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2017.                 RV = EGNP_INT_GetUInteger(TData, TUI(6)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2018.                 TUPtr = EGNP_INT_User_Get(V_ClientPtr, TUI(1))
    
  2019.                 If TUPtr <> 0 Then TMyPtrFrom = TUPtr->V_MyPtr Else TMyPtrFrom = 0
    
  2020.                 TUPtr2 = EGNP_INT_User_Get(V_ClientPtr, TUI(2))
    
  2021.                 If TUPtr2 <> 0 Then TMyPtrTo = TUPtr2->V_MyPtr Else TMyPtrTo = 0
    
  2022.                 Mutexunlock(EGNP_INT_Mux)
    
  2023.                 TCallbacks.V_MoveDbl(TUI(1), TUI(2), TD(1), TD(2), TD(3), TUI(6), TMyPtrTo, TMyPtrFrom)
    
  2024.                 Mutexlock(EGNP_INT_Mux)
    
  2025.                 If TUPtr <> 0 Then TUPtr->V_MyPtr = TMyPtrFrom
    
  2026.                 If TUPtr2 <> 0 Then TUPtr2->V_MyPtr = TMyPtrTo
    
  2027.                 
    
  2028.             Case EGNP_CMD_UserMoveInt
    
  2029.                 If TCallbacks.V_MoveInt = 0 Then Continue Do
    
  2030.                 RV = EGNP_INT_GetUInteger(TData, TUI(1)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2031.                 RV = EGNP_INT_GetUInteger(TData, TUI(2)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2032.                 RV = EGNP_INT_GetUInteger(TData, TUI(3)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2033.                 RV = EGNP_INT_GetUInteger(TData, TUI(4)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2034.                 RV = EGNP_INT_GetUInteger(TData, TUI(5)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2035.                 RV = EGNP_INT_GetUInteger(TData, TUI(6)):   If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2036.                 TUPtr = EGNP_INT_User_Get(V_ClientPtr, TUI(1))
    
  2037.                 If TUPtr <> 0 Then TMyPtrFrom = TUPtr->V_MyPtr Else TMyPtrFrom = 0
    
  2038.                 TUPtr2 = EGNP_INT_User_Get(V_ClientPtr, TUI(2))
    
  2039.                 If TUPtr2 <> 0 Then TMyPtrTo = TUPtr2->V_MyPtr Else TMyPtrTo = 0
    
  2040.                 Mutexunlock(EGNP_INT_Mux)
    
  2041.                 TCallbacks.V_MoveInt(TUI(1), TUI(2), TUI(3), TUI(4), TUI(5), TUI(6), TMyPtrTo, TMyPtrFrom)
    
  2042.                 Mutexlock(EGNP_INT_Mux)
    
  2043.                 If TUPtr <> 0 Then TUPtr->V_MyPtr = TMyPtrFrom
    
  2044.                 If TUPtr2 <> 0 Then TUPtr2->V_MyPtr = TMyPtrTo
    
  2045.                 
    
  2046.             Case EGNP_CMD_AccCreate, EGNP_CMD_AccList, EGNP_CMD_AccDestroy, EGNP_CMD_AccSetFlags, EGNP_CMD_AccSetNick, EGNP_CMD_AccSetPass
    
  2047.                 RV = EGNP_INT_GetDouble(TData, TSerial):    If RV <> EGNP_GURU_NoError Then Mutexunlock(EGNP_INT_Mux): EGNP_INT_AsyncSendToOne(V_TSNEID, EGNP_INT_BuildCMD(RV)): TSNE_Disconnect(V_TSNEID): Exit Sub
    
  2048.                 TWPtr = .V_AnswerF
    
  2049.                 Do Until TWPtr = 0
    
  2050.                     TWPtrN = TWPtr->V_Next
    
  2051.                     If TWPtr->V_TimeOut < Timer() Then
    
  2052.                         If TWPtr->V_Next <> 0 Then TWPtr->V_Next->V_Prev = TWPtr->V_Prev
    
  2053.                         If TWPtr->V_Prev <> 0 Then TWPtr->V_Prev->V_Next = TWPtr->V_Next
    
  2054.                         If .V_AnswerF = TWPtr Then .V_AnswerF = TWPtr->V_Next
    
  2055.                         If .V_AnswerL = TWPtr Then .V_AnswerL = TWPtr->V_Prev
    
  2056.                         Deallocate(TWPtr)
    
  2057.                     End If
    
  2058.                     TWPtr = TWPtrN
    
  2059.                 Loop
    
  2060.                 If .V_AnswerL <> 0 Then
    
  2061.                     .V_AnswerL->V_Next = Callocate(Sizeof(EGNP_INT_ClientAnswer_Type))
    
  2062.                     .V_AnswerL->V_Next->V_Prev = .V_AnswerL
    
  2063.                     .V_AnswerL = .V_AnswerL->V_Next
    
  2064.                 Else
    
  2065.                     .V_AnswerL = Callocate(Sizeof(EGNP_INT_ClientAnswer_Type))
    
  2066.                     .V_AnswerF = .V_AnswerL
    
  2067.                 End If
    
  2068.                 With *.V_AnswerL
    
  2069.                     .V_TimeOut  = Timer() + 10
    
  2070.                     .V_Serial   = TSerial
    
  2071.                     .V_CMD      = TCMD
    
  2072.                     .V_Answer   = TData
    
  2073.                 End With
    
  2074.                 
    
  2075.             Case EGNP_GURU_UnknownCMD
    
  2076.             Case EGNP_GURU_LoginDenied
    
  2077.             Case EGNP_GURU_NickDenied
    
  2078.             Case EGNP_GURU_CommandDenied
    
  2079.             Case Else: Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(V_TSNEID): Exit Do
    
  2080.         End Select
    
  2081.     Loop
    
  2082. End With
    
  2083. Mutexunlock(EGNP_INT_Mux)
    
  2084. End Sub
    
  2085. 
    
  2086. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2087. Function EGNP_INT_Client_GetPtrByID(V_ClientID As Uinteger) As EGNP_INT_Client_Type Ptr
    
  2088. Dim TXPtr As EGNP_INT_Client_Type Ptr = Cast(EGNP_INT_Client_Type Ptr, V_ClientID)
    
  2089. Dim TCPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_F
    
  2090. Do Until TCPtr = 0
    
  2091.     If TCPtr = TXPtr Then Return TCPtr
    
  2092.     TCPtr = TCPtr->V_Next
    
  2093. Loop
    
  2094. Return 0
    
  2095. End Function
    
  2096. 
    
  2097. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2098. Function EGNP_Client_Destroy(V_ClientID As Uinteger) As EGNP_GURU_Enum
    
  2099. Mutexlock(EGNP_INT_Mux)
    
  2100. Dim TCPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2101. If TCPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2102. Dim TTSNESocket As TSNE_Socket Ptr
    
  2103. TTSNESocket = TSNE_INT_GetPtr(TCPtr->V_TSNEIDTCP): If TTSNESocket <> 0 Then TTSNESocket->V_Event.V_AnyPtr = 0
    
  2104. TTSNESocket = TSNE_INT_GetPtr(TCPtr->V_TSNEIDUDPTX): If TTSNESocket <> 0 Then TTSNESocket->V_Event.V_AnyPtr = 0
    
  2105. TTSNESocket = TSNE_INT_GetPtr(TCPtr->V_TSNEIDUDPRX): If TTSNESocket <> 0 Then TTSNESocket->V_Event.V_AnyPtr = 0
    
  2106. If TCPtr->V_Next <> 0 Then TCPtr->V_Next->V_Prev = TCPtr->V_Prev
    
  2107. If TCPtr->V_Prev <> 0 Then TCPtr->V_Prev->V_Next = TCPtr->V_Next
    
  2108. If EGNP_INT_Client_F = TCPtr Then EGNP_INT_Client_F = TCPtr->V_Next
    
  2109. If EGNP_INT_Client_L = TCPtr Then EGNP_INT_Client_L = TCPtr->V_Prev
    
  2110. Deallocate(TCPtr)
    
  2111. Mutexunlock(EGNP_INT_Mux)
    
  2112. Return EGNP_GURU_NoError
    
  2113. End Function
    
  2114. 
    
  2115. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2116. Function EGNP_Client_Create(Byref R_ClientID As Uinteger, V_CallbackSet As EGNP_Callback_Type) As EGNP_GURU_Enum
    
  2117. Mutexlock(EGNP_INT_Mux)
    
  2118. If EGNP_INT_Client_L <> 0 Then
    
  2119.     EGNP_INT_Client_L->V_Next = Callocate(Sizeof(EGNP_INT_Client_Type))
    
  2120.     EGNP_INT_Client_L->V_Next->V_Prev = EGNP_INT_Client_L
    
  2121.     EGNP_INT_Client_L = EGNP_INT_Client_L->V_Next
    
  2122. Else
    
  2123.     EGNP_INT_Client_L = Callocate(Sizeof(EGNP_INT_Client_Type))
    
  2124.     EGNP_INT_Client_F = EGNP_INT_Client_L
    
  2125. End If
    
  2126. With *EGNP_INT_Client_L
    
  2127.     .V_LCMD             = EGNP_CMD_ServerUnavaible
    
  2128.     .V_State            = EGNP_CSE_Connecting
    
  2129.     .V_Callbacks        = V_CallbackSet
    
  2130. End With
    
  2131. R_ClientID = Cast(Uinteger, EGNP_INT_Client_L)
    
  2132. Mutexunlock(EGNP_INT_Mux)
    
  2133. Return EGNP_GURU_NoError
    
  2134. End Function
    
  2135. 
    
  2136. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2137. Function EGNP_Client_Disconnect(V_ClientID As Uinteger) As EGNP_GURU_Enum
    
  2138. Mutexlock(EGNP_INT_Mux)
    
  2139. Dim TCPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2140. If TCPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2141. 
    
  2142. Mutexunlock(EGNP_INT_Mux)
    
  2143. Return EGNP_GURU_NoError
    
  2144. End Function
    
  2145. 
    
  2146. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2147. Function EGNP_Client_Connect(V_ClientID As Uinteger, V_Host As String, V_Port As Ushort, V_Nickname As String, V_PasswordServer As String = "", V_Username As String = "", V_Password As String = "", V_PortUDP As Ushort = 0) As EGNP_GURU_Enum
    
  2148. If V_Host = "" Then Return EGNP_GURU_ParameterError
    
  2149. If V_Port < 1 Then Return EGNP_GURU_ParameterError
    
  2150. If V_Nickname = "" Then Return EGNP_GURU_ParameterError
    
  2151. If V_PasswordServer <> "" Then If Len(V_PasswordServer) > &HFFF Then Return EGNP_GURU_ParameterError
    
  2152. If V_Username <> "" Then
    
  2153.     If Len(V_Username) < 4 Then Return EGNP_GURU_ParameterError
    
  2154.     If Len(V_Username) > &HFFF Then Return EGNP_GURU_ParameterError
    
  2155. End If
    
  2156. If V_Password <> "" Then
    
  2157.     If Len(V_Password) < 8 Then Return EGNP_GURU_ParameterError
    
  2158.     If Len(V_Password) > &HFFF Then Return EGNP_GURU_ParameterError
    
  2159. End If
    
  2160. Dim TTID As Uinteger
    
  2161. Dim RV As Integer
    
  2162. Mutexlock(EGNP_INT_Mux)
    
  2163. Dim TCPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2164. If TCPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2165. Dim TCallbacks As EGNP_Callback_Type = TCPtr->V_Callbacks
    
  2166. Mutexunlock(EGNP_INT_Mux)
    
  2167. If TCallbacks.V_StateConnection <> 0 Then TCallbacks.V_StateConnection(Cast(Uinteger, TCPtr), EGNP_CSE_Connecting)
    
  2168. Mutexlock(EGNP_INT_Mux)
    
  2169. RV = TSNE_Create_Client(TTID, V_Host, V_Port, @EGNP_INT_Client_Disconnected, @EGNP_INT_Client_Connected, @EGNP_INT_Client_NewData, , , , Cast(EGNP_INT_Client_Type Ptr, V_ClientID))
    
  2170. If RV <> TSNE_Const_NoError Then
    
  2171.     Mutexunlock(EGNP_INT_Mux)
    
  2172.     If TCallbacks.V_StateConnection <> 0 Then TCallbacks.V_StateConnection(Cast(Uinteger, TCPtr), EGNP_CSE_DisconnectedUnavaible)
    
  2173.     Deallocate(TCPtr)
    
  2174.     Return RV
    
  2175. End If
    
  2176. TCPtr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2177. If TCPtr = 0 Then Mutexunlock(EGNP_INT_Mux): TSNE_Disconnect(TTID): Return EGNP_GURU_ExternalError
    
  2178. With *TCPtr
    
  2179.     .V_Host                 = V_Host
    
  2180.     .V_PortTCP              = V_Port
    
  2181.     .V_PortUDP              = V_PortUDP
    
  2182.     .V_Nickname             = V_Nickname
    
  2183.     .V_PasswordServer       = V_PasswordServer
    
  2184.     .V_Username             = V_Username
    
  2185.     .V_Password             = OSC_Crypt(V_Username, V_Password, "egnp", 4)
    
  2186.     .V_TSNEIDTCP            = TTID
    
  2187. End With
    
  2188. Mutexunlock(EGNP_INT_Mux)
    
  2189. Return EGNP_GURU_NoError
    
  2190. End Function
    
  2191. 
    
  2192. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2193. Function EGNP_Client_WaitConnected(V_ClientID As Uinteger) As EGNP_GURU_Enum
    
  2194. Dim TTot As Double = Timer() + 60
    
  2195. Dim TSPtr As EGNP_INT_Client_Type Ptr
    
  2196. Do
    
  2197.     Mutexlock(EGNP_INT_Mux)
    
  2198.     Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2199.     If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2200.     If (TSPtr->V_State And EGNP_CSE_Disconnected) <> 0 Then
    
  2201.         Dim TLCMD As EGNP_INT_CMD_Enum = TSPtr->V_LCMD
    
  2202.         Mutexunlock(EGNP_INT_Mux)
    
  2203.         Return TLCMD
    
  2204.     End If
    
  2205.     If TSPtr->V_State = EGNP_CSE_Ready Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_NoError
    
  2206.     If TTot < Timer() Then
    
  2207.         TSNE_Disconnect(TSPtr->V_TSNEIDTCP)
    
  2208.         Mutexunlock(EGNP_INT_Mux)
    
  2209.         Return EGNP_GURU_Timeout
    
  2210.     End If
    
  2211.     Mutexunlock(EGNP_INT_Mux)
    
  2212.     'USleep 10000
    
  2213.     Sleep 10, 1
    
  2214. Loop
    
  2215. Return EGNP_GURU_CantConnect
    
  2216. End Function
    
  2217. 
    
  2218. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2219. Function EGNP_Client_GetUserIDByNick(V_ClientID As Uinteger, V_Nickname As String) As Uinteger
    
  2220. If V_ClientID = 0 Then Return 0
    
  2221. If V_Nickname = "" Then Return 0
    
  2222. Dim S As String = Lcase(V_Nickname)
    
  2223. Mutexlock(EGNP_INT_Mux)
    
  2224. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2225. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return 0
    
  2226. Dim TID As Uinteger
    
  2227. Dim TCPtr As EGNP_User_Type Ptr = TSPtr->V_UserF
    
  2228. Do Until TCPtr = 0
    
  2229.     If Lcase(TCPtr->V_Nickname) = S Then
    
  2230.         TID = TCPtr->V_ClientID
    
  2231.         Mutexunlock(EGNP_INT_Mux)
    
  2232.         Return TID
    
  2233.     End If
    
  2234.     TCPtr = TCPtr->V_Next
    
  2235. Loop
    
  2236. Return 0
    
  2237. End Function
    
  2238. 
    
  2239. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2240. Function EGNP_Client_GetMyID(V_ClientID As Uinteger) As Uinteger
    
  2241. Mutexlock(EGNP_INT_Mux)
    
  2242. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2243. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return 0
    
  2244. Function = TSPtr->V_MyID
    
  2245. Mutexunlock(EGNP_INT_Mux)
    
  2246. End Function
    
  2247. 
    
  2248. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2249. Sub EGNP_Client_Lock()
    
  2250. Mutexlock(EGNP_INT_Mux)
    
  2251. End Sub
    
  2252. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2253. Sub EGNP_Client_UnLock()
    
  2254. Mutexunlock(EGNP_INT_Mux)
    
  2255. End Sub
    
  2256. 
    
  2257. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2258. Function EGNP_Client_GetUserTypeByID(V_ClientID As Uinteger, V_UserID As Uinteger) As EGNP_User_Type Ptr
    
  2259. Dim TCPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2260. If TCPtr = 0 Then Return 0
    
  2261. Return EGNP_INT_User_Get(TCPtr, V_UserID)
    
  2262. End Function
    
  2263. 
    
  2264. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2265. Function EGNP_Client_GetUserTypeFirst(V_ClientID As Uinteger) As EGNP_User_Type Ptr
    
  2266. Dim TCPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2267. If TCPtr = 0 Then Return 0
    
  2268. Return TCPtr->V_UserF
    
  2269. End Function
    
  2270. 
    
  2271. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2272. Function EGNP_Client_SendMessage(V_ClientID As Uinteger, V_ToUserID As Uinteger, V_Message As String, V_MessageType As EGNP_MessageType_Enum = EGNP_MTE_Regular) As EGNP_GURU_Enum
    
  2273. If V_Message = "" Then Return EGNP_GURU_ParameterError
    
  2274. If Len(V_Message) > &HFFF Then Return EGNP_GURU_ParameterError
    
  2275. Mutexlock(EGNP_INT_Mux)
    
  2276. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2277. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2278. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2279. Mutexunlock(EGNP_INT_Mux)
    
  2280. Dim T As String
    
  2281. T += EGNP_INT_BuildUInteger(V_ToUserID)
    
  2282. T += EGNP_INT_BuildUInteger(V_MessageType)
    
  2283. T += EGNP_INT_BuildString(V_Message)
    
  2284. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_UserMessage, T)) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2285. Return EGNP_GURU_NoError
    
  2286. End Function
    
  2287. 
    
  2288. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2289. Function EGNP_Client_SendData(V_ClientID As Uinteger, V_ToUserID As Uinteger, V_Data As String) As EGNP_GURU_Enum
    
  2290. If Len(V_Data) > &HFFFF Then Return EGNP_GURU_ParameterError
    
  2291. Mutexlock(EGNP_INT_Mux)
    
  2292. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2293. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2294. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2295. Mutexunlock(EGNP_INT_Mux)
    
  2296. Dim T As String
    
  2297. T += EGNP_INT_BuildUInteger(V_ToUserID)
    
  2298. T += EGNP_INT_BuildString(V_Data)
    
  2299. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_UserData, T)) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2300. Return EGNP_GURU_NoError
    
  2301. End Function
    
  2302. 
    
  2303. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2304. Function EGNP_Client_SendMove Overload (V_ClientID As Uinteger, V_ToUserID As Uinteger, V_X As Integer, V_Y As Integer, V_Z As Integer, V_Int As Integer) As EGNP_GURU_Enum
    
  2305. Mutexlock(EGNP_INT_Mux)
    
  2306. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2307. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2308. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2309. Mutexunlock(EGNP_INT_Mux)
    
  2310. Dim T As String
    
  2311. T += EGNP_INT_BuildUInteger(V_ToUserID)
    
  2312. T += EGNP_INT_BuildUInteger(V_X)
    
  2313. T += EGNP_INT_BuildUInteger(V_Y)
    
  2314. T += EGNP_INT_BuildUInteger(V_Z)
    
  2315. T += EGNP_INT_BuildUInteger(V_Int)
    
  2316. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_UserMoveInt, T)) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2317. Return EGNP_GURU_NoError
    
  2318. End Function
    
  2319. 
    
  2320. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2321. Function EGNP_Client_SendMove Overload (V_ClientID As Uinteger, V_ToUserID As Uinteger, V_X As Double, V_Y As Double, V_Z As Double, V_Int As Integer) As EGNP_GURU_Enum
    
  2322. Mutexlock(EGNP_INT_Mux)
    
  2323. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2324. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2325. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2326. Mutexunlock(EGNP_INT_Mux)
    
  2327. Dim T As String
    
  2328. T += EGNP_INT_BuildUInteger(V_ToUserID)
    
  2329. T += EGNP_INT_BuildDouble(V_X)
    
  2330. T += EGNP_INT_BuildDouble(V_Y)
    
  2331. T += EGNP_INT_BuildDouble(V_Z)
    
  2332. T += EGNP_INT_BuildUInteger(V_Int)
    
  2333. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_UserMoveDbl, T)) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2334. Return EGNP_GURU_NoError
    
  2335. End Function
    
  2336. 
    
  2337. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2338. Function EGNP_INT_WaitAnswer(V_ClientID As Uinteger, V_CMD As EGNP_INT_CMD_Enum, V_Serial As Double, Byref R_Answer As String) As EGNP_GURU_Enum
    
  2339. Dim TTot As Double = Timer() + 10
    
  2340. Dim TSPtr As EGNP_INT_Client_Type Ptr
    
  2341. Dim TWPtr As EGNP_INT_ClientAnswer_Type Ptr
    
  2342. Do
    
  2343.     If TTot < Timer() Then Return EGNP_GURU_Timeout
    
  2344.     Mutexlock(EGNP_INT_Mux)
    
  2345.     TSPtr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2346.     If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2347.     If (TSPtr->V_State And EGNP_CSE_Disconnected) <> 0 Then
    
  2348.         Dim TLCMD As EGNP_INT_CMD_Enum = TSPtr->V_LCMD
    
  2349.         Mutexunlock(EGNP_INT_Mux)
    
  2350.         Return TLCMD
    
  2351.     End If
    
  2352.     With *TSPtr
    
  2353.         TWPtr = .V_AnswerF
    
  2354.         Do Until TWPtr = 0
    
  2355.             If (TWPtr->V_CMD <> V_CMD) Or (TWPtr->V_Serial <> V_Serial) Then TWPtr = TWPtr->V_Next: Continue Do
    
  2356.             If TWPtr->V_Next <> 0 Then TWPtr->V_Next->V_Prev = TWPtr->V_Prev
    
  2357.             If TWPtr->V_Prev <> 0 Then TWPtr->V_Prev->V_Next = TWPtr->V_Next
    
  2358.             If .V_AnswerF = TWPtr Then .V_AnswerF = TWPtr->V_Next
    
  2359.             If .V_AnswerL = TWPtr Then .V_AnswerL = TWPtr->V_Prev
    
  2360.             R_Answer = TWPtr->V_Answer
    
  2361.             Deallocate(TWPtr)
    
  2362.             Mutexunlock(EGNP_INT_Mux)
    
  2363.             Return EGNP_GURU_NoError
    
  2364.         Loop
    
  2365.     End With
    
  2366.     Mutexunlock(EGNP_INT_Mux)
    
  2367.     Sleep 10, 1
    
  2368. Loop
    
  2369. Return EGNP_GURU_InternalError
    
  2370. End Function
    
  2371. 
    
  2372. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2373. Function EGNP_Client_Account_List(V_ClientID As Uinteger, V_UserSelect As String, R_ListD() As EGNP_Account_Type, Byref R_ListC As Uinteger) As EGNP_GURU_Enum
    
  2374. R_ListC = 0
    
  2375. Mutexlock(EGNP_INT_Mux)
    
  2376. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2377. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2378. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2379. Dim T As String
    
  2380. Do
    
  2381.     If EGNP_INT_CMDSerial <> Timer() Then EGNP_INT_CMDSerial = Timer(): Exit Do
    
  2382.     Sleep 1, 1
    
  2383. Loop
    
  2384. Dim TSerial As Double = EGNP_INT_CMDSerial
    
  2385. Mutexunlock(EGNP_INT_Mux)
    
  2386. T += EGNP_INT_BuildDouble(TSerial)
    
  2387. T += EGNP_INT_BuildString(V_UserSelect)
    
  2388. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_AccList, T), 0) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2389. Dim RV As EGNP_GURU_Enum = EGNP_INT_WaitAnswer(V_ClientID, EGNP_CMD_AccList, TSerial, T)
    
  2390. Dim TUser As String
    
  2391. Dim TNick As String
    
  2392. Dim TID As Uinteger
    
  2393. Dim TFlag As EGNP_AccountPermissions_Enum
    
  2394. Do
    
  2395.     If T = "" Then Exit Do
    
  2396.     RV = EGNP_INT_GetUInteger(T, TID):      If RV <> EGNP_GURU_NoError Then R_ListC = 0: Return RV
    
  2397.     RV = EGNP_INT_GetString(T, TUser):      If RV <> EGNP_GURU_NoError Then R_ListC = 0: Return RV
    
  2398.     RV = EGNP_INT_GetString(T, TNick):      If RV <> EGNP_GURU_NoError Then R_ListC = 0: Return RV
    
  2399.     RV = EGNP_INT_GetUInteger(T, TFlag):    If RV <> EGNP_GURU_NoError Then R_ListC = 0: Return RV
    
  2400.     R_ListC += 1
    
  2401.     Redim Preserve R_ListD(R_ListC) As EGNP_Account_Type
    
  2402.     With R_ListD(R_ListC)
    
  2403.         .V_ClientID     = TID
    
  2404.         .V_Username     = TUser
    
  2405.         .V_Nickname     = TNick
    
  2406.         .V_UserFlags    = TFlag
    
  2407.     End With
    
  2408. Loop
    
  2409. Return RV
    
  2410. End Function
    
  2411. 
    
  2412. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2413. Function EGNP_Client_Account_Create(V_ClientID As Uinteger, V_Username As String, V_Password As String, V_Nickname As String) As EGNP_GURU_Enum
    
  2414. Mutexlock(EGNP_INT_Mux)
    
  2415. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2416. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2417. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2418. Dim T As String
    
  2419. Do
    
  2420.     If EGNP_INT_CMDSerial <> Timer() Then EGNP_INT_CMDSerial = Timer(): Exit Do
    
  2421.     Sleep 1, 1
    
  2422. Loop
    
  2423. Dim TSerial As Double = EGNP_INT_CMDSerial
    
  2424. Mutexunlock(EGNP_INT_Mux)
    
  2425. T += EGNP_INT_BuildDouble(TSerial)
    
  2426. T += EGNP_INT_BuildString(V_Username)
    
  2427. T += EGNP_INT_BuildString(OSC_Crypt(V_Username, V_Password, "egnp", 4))
    
  2428. T += EGNP_INT_BuildString(V_Nickname)
    
  2429. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_AccCreate, T), 0) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2430. Dim RV As EGNP_GURU_Enum = EGNP_INT_WaitAnswer(V_ClientID, EGNP_CMD_AccCreate, TSerial, T)
    
  2431. Return RV
    
  2432. End Function
    
  2433. 
    
  2434. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2435. Function EGNP_Client_Account_Destroy(V_ClientID As Uinteger, V_Username As String, V_Password As String) As EGNP_GURU_Enum
    
  2436. Mutexlock(EGNP_INT_Mux)
    
  2437. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2438. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2439. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2440. Dim T As String
    
  2441. Do
    
  2442.     If EGNP_INT_CMDSerial <> Timer() Then EGNP_INT_CMDSerial = Timer(): Exit Do
    
  2443.     Sleep 1, 1
    
  2444. Loop
    
  2445. Dim TSerial As Double = EGNP_INT_CMDSerial
    
  2446. Mutexunlock(EGNP_INT_Mux)
    
  2447. T += EGNP_INT_BuildDouble(TSerial)
    
  2448. T += EGNP_INT_BuildString(V_Username)
    
  2449. T += EGNP_INT_BuildString(OSC_Crypt(V_Username, V_Password, "egnp", 4))
    
  2450. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_AccDestroy, T), 0) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2451. Dim RV As EGNP_GURU_Enum = EGNP_INT_WaitAnswer(V_ClientID, EGNP_CMD_AccDestroy, TSerial, T)
    
  2452. Return RV
    
  2453. End Function
    
  2454. 
    
  2455. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2456. Function EGNP_Client_Account_SetNickname(V_ClientID As Uinteger, V_Username As String, V_Nickname As String) As EGNP_GURU_Enum
    
  2457. Mutexlock(EGNP_INT_Mux)
    
  2458. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2459. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2460. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2461. Dim T As String
    
  2462. Do
    
  2463.     If EGNP_INT_CMDSerial <> Timer() Then EGNP_INT_CMDSerial = Timer(): Exit Do
    
  2464.     Sleep 1, 1
    
  2465. Loop
    
  2466. Dim TSerial As Double = EGNP_INT_CMDSerial
    
  2467. Mutexunlock(EGNP_INT_Mux)
    
  2468. T += EGNP_INT_BuildDouble(TSerial)
    
  2469. T += EGNP_INT_BuildString(V_Username)
    
  2470. T += EGNP_INT_BuildString(V_Nickname)
    
  2471. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_AccSetNick, T), 0) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2472. Dim RV As EGNP_GURU_Enum = EGNP_INT_WaitAnswer(V_ClientID, EGNP_CMD_AccSetNick, TSerial, T)
    
  2473. Return RV
    
  2474. End Function
    
  2475. 
    
  2476. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2477. Function EGNP_Client_Account_SetPassword(V_ClientID As Uinteger, V_Username As String, V_Password As String) As EGNP_GURU_Enum
    
  2478. Mutexlock(EGNP_INT_Mux)
    
  2479. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2480. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2481. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2482. Dim T As String
    
  2483. Do
    
  2484.     If EGNP_INT_CMDSerial <> Timer() Then EGNP_INT_CMDSerial = Timer(): Exit Do
    
  2485.     Sleep 1, 1
    
  2486. Loop
    
  2487. Dim TSerial As Double = EGNP_INT_CMDSerial
    
  2488. Mutexunlock(EGNP_INT_Mux)
    
  2489. T += EGNP_INT_BuildDouble(TSerial)
    
  2490. T += EGNP_INT_BuildString(V_Username)
    
  2491. T += EGNP_INT_BuildString(OSC_Crypt(V_Username, V_Password, "egnp", 4))
    
  2492. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_AccSetPass, T), 0) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2493. Dim RV As EGNP_GURU_Enum = EGNP_INT_WaitAnswer(V_ClientID, EGNP_CMD_AccSetPass, TSerial, T)
    
  2494. Return RV
    
  2495. End Function
    
  2496. 
    
  2497. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2498. Function EGNP_Client_Account_SetFlags(V_ClientID As Uinteger, V_Username As String, V_Flags As EGNP_AccountPermissions_Enum) As EGNP_GURU_Enum
    
  2499. Mutexlock(EGNP_INT_Mux)
    
  2500. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2501. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2502. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2503. Dim T As String
    
  2504. Do
    
  2505.     If EGNP_INT_CMDSerial <> Timer() Then EGNP_INT_CMDSerial = Timer(): Exit Do
    
  2506.     Sleep 1, 1
    
  2507. Loop
    
  2508. Dim TSerial As Double = EGNP_INT_CMDSerial
    
  2509. Mutexunlock(EGNP_INT_Mux)
    
  2510. T += EGNP_INT_BuildDouble(TSerial)
    
  2511. T += EGNP_INT_BuildString(V_Username)
    
  2512. T += EGNP_INT_BuildUInteger(V_Flags)
    
  2513. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_AccSetFlags, T), 0) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2514. Dim RV As EGNP_GURU_Enum = EGNP_INT_WaitAnswer(V_ClientID, EGNP_CMD_AccSetFlags, TSerial, T)
    
  2515. Return RV
    
  2516. End Function
    
  2517. 
    
  2518. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2519. Function EGNP_Client_Kick(V_ClientID As Uinteger, V_KickClientID As Uinteger) As EGNP_GURU_Enum
    
  2520. Mutexlock(EGNP_INT_Mux)
    
  2521. Dim TSPtr As EGNP_INT_Client_Type Ptr = EGNP_INT_Client_GetPtrByID(V_ClientID)
    
  2522. If TSPtr = 0 Then Mutexunlock(EGNP_INT_Mux): Return EGNP_GURU_IDnotFound
    
  2523. Dim TTID As Uinteger = TSPtr->V_TSNEIDTCP
    
  2524. Dim T As String
    
  2525. Do
    
  2526.     If EGNP_INT_CMDSerial <> Timer() Then EGNP_INT_CMDSerial = Timer(): Exit Do
    
  2527.     Sleep 1, 1
    
  2528. Loop
    
  2529. Dim TSerial As Double = EGNP_INT_CMDSerial
    
  2530. Mutexunlock(EGNP_INT_Mux)
    
  2531. T += EGNP_INT_BuildDouble(TSerial)
    
  2532. T += EGNP_INT_BuildUInteger(V_KickClientID)
    
  2533. If EGNP_INT_AsyncSendToOne(TTID, EGNP_INT_BuildCMD(EGNP_CMD_UserKick, T), 0) <> TSNE_Const_NoError Then TSNE_Disconnect(TTID): Return EGNP_GURU_TransmissionError
    
  2534. Dim RV As EGNP_GURU_Enum = EGNP_INT_WaitAnswer(V_ClientID, EGNP_CMD_UserKick, TSerial, T)
    
  2535. Return RV
    
  2536. End Function
    
  2537. 
    
  2538. 
    
  2539. 
    
  2540. 
    
  2541. 
    
  2542. 
    
  2543. 
    
  2544. '####################################################################################################################################################
    
  2545. '####################################################################################################################################################
    
  2546. '####################################################################################################################################################
    
  2547. 
    
  2548. 
    
  2549. 
    
  2550. 
    
  2551. 
    
  2552. 
    
  2553. 
    
  2554. '####################################################################################################################################################
    
  2555. Sub EGNP_INT_Public_DrawSym(V_Img As Any Ptr, V_PosX As Integer, V_PosY As Integer, V_SymID As Integer)
    
  2556. Select Case V_SymID
    
  2557.     Case 0 'ServerPass
    
  2558.         Circle V_Img, (V_PosX + 5, V_PosY + 5), 4, &HFF440000, , , , F
    
  2559.         Circle V_Img, (V_PosX + 5, V_PosY + 5), 2, &HFFFFFFFF, , , , F
    
  2560.         Line V_Img, (V_PosX, V_PosY + 6)-(V_PosX + 10, V_PosY + 11), &HFF440000, BF
    
  2561.         
    
  2562.     Case 1 'Accounts
    
  2563.         Circle V_Img, (V_PosX + 5, V_PosY + 3), 2, &HFF000044, , , , F
    
  2564.         Circle V_Img, (V_PosX + 5, V_PosY + 8), 3, &HFF000044, , , , F
    
  2565.         Line V_Img, (V_PosX + 2, V_PosY + 8)-(V_PosX + 8, V_PosY + 11), &HFF000044, BF
    
  2566.         
    
  2567. End Select
    
  2568. End Sub
    
  2569. 
    
  2570. '----------------------------------------------------------------------------------------------------------------------------------------------------
    
  2571. Function EGNP_Public_ShowListAndGetServer(V_IOWidth As Integer, V_IOHeight As Integer, V_GameName As String, V_GameVersion As Uinteger, Byref RV_Host As String, Byref RV_Port As Ushort, Byref RV_PassServer As String, Byref RV_Nick As String, Byref RV_User As String, Byref RV_Pass As String, Byref R_ServerFlags As EGNP_ServerFlags_Enum) As EGNP_GURU_Enum
    
  2572. R_ServerFlags = 0
    
  2573. If V_IOWidth < 400 Then Return EGNP_GURU_ParameterError
    
  2574. If V_IOHeight < 200 Then Return EGNP_GURU_ParameterError
    
  2575. Dim TImg As Any Ptr = Imagecreate(V_IOWidth, V_IOHeight, &HFFFFFFFF, 32)
    
  2576. Dim TScreenW As Integer
    
  2577. Dim TScreenH As Integer
    
  2578. Dim T As String
    
  2579. Dim TMR As Integer
    
  2580. Dim TMX As Integer
    
  2581. Dim TMY As Integer
    
  2582. Dim TMZ As Integer
    
  2583. Dim TMB As Integer
    
  2584. Dim TMZL As Integer
    
  2585. Dim TMBL As Integer
    
  2586. Dim TKey As String
    
  2587. Dim TKey0 As Integer
    
  2588. Dim TKey1 As Integer
    
  2589. Dim TState As Integer
    
  2590. Dim TTitle As String
    
  2591. Dim TTime As Double = EGNP_INT_ServerPubSLTime
    
  2592. Dim TSLPtr As EGNP_INT_PublicServer_Type Ptr
    
  2593. Screeninfo(TScreenW, TScreenH)
    
  2594. Dim TSPosX As Integer = TScreenW / 2 - V_IOWidth / 2
    
  2595. Dim TSPosY As Integer = TScreenH / 2 - V_IOHeight / 2
    
  2596. Dim TPosX As Integer
    
  2597. Dim TPosY As Integer
    
  2598. Dim TListC As Integer
    
  2599. Dim TListStart As Integer
    
  2600. Dim TListMax As Integer = Fix((V_IOHeight - 62 - 30) / 20)
    
  2601. Dim TListSel As Integer = 0
    
  2602. Dim TListSelFlags As EGNP_ServerFlags_Enum
    
  2603. Dim C As Integer
    
  2604. Dim TInput As String
    
  2605. Dim TInputSel As Integer
    
  2606. Dim THost As String
    
  2607. Dim TPort As Ushort = 6006
    
  2608. Dim TPassServer As String
    
  2609. Dim TNick As String
    
  2610. Dim TUser As String
    
  2611. Dim TPass As String
    
  2612. Dim CX As Integer
    
  2613. Dim TCurPos(1 To 4) As Integer
    
  2614. Dim TCurStart(1 To 4) As Integer
    
  2615. Dim TCurSel As Integer
    
  2616. Dim TTMX As Integer
    
  2617. Dim TTMY As Integer
    
  2618. Dim TRegist As Integer
    
  2619. Dim TRV As EGNP_GURU_Enum = EGNP_GURU_NothingSelected
    
  2620. If RV_Host <> "" Then
    
  2621.     TListSel = 1
    
  2622.     TPort = RV_Port
    
  2623.     THost = RV_Host
    
  2624.     If TPort <> 6006 Then THost += ":" & Str(TPort)
    
  2625.     TPassServer = RV_PassServer
    
  2626.     TNick = RV_Nick
    
  2627.     TUser = RV_User
    
  2628.     TPass = RV_Pass
    
  2629.     TListSelFlags = EGNP_SFE_Serverpass Or EGNP_SFE_Account
    
  2630. End If
    
  2631. Do
    
  2632.     TKey0 = 0
    
  2633.     TKey1 = 0
    
  2634.     TKey = Inkey()
    
  2635.     If Len(TKey) > 0 Then TKey0 = TKey[0]
    
  2636.     If Len(TKey) > 1 Then TKey1 = TKey[1]
    
  2637.     TMR = Getmouse(TMX, TMY, TMZ, TMB)
    
  2638.     If TMR = 0 Then
    
  2639.         If TMZL <> TMZ Then
    
  2640.             TListStart -= TMZ - TMZL
    
  2641.             If TListStart >= (TListC - TListMax) Then TListStart = TListC - TListMax
    
  2642.             If TListStart < 0 Then TListStart = 0
    
  2643.             TMZL = TMZ
    
  2644.         End If
    
  2645.         If TMBL <> TMB Then
    
  2646.             TMBL = TMB
    
  2647.             If TMB = 1 Then
    
  2648.                 TTMX = (TMX - TSPosX)
    
  2649.                 TTMY = (TMY - TSPosY)
    
  2650.                 TCurSel = 0
    
  2651.                 If (TTMX >= 80) And (TTMY >= V_IOHeight - 67) And (TTMX <= V_IOWidth / 2 - 15) And (TTMY <= V_IOHeight - 51) Then
    
  2652.                     TCurSel = 1
    
  2653.                 Elseif (TTMX >= V_IOWidth / 2 + 90) And (TTMY >= V_IOHeight - 67) And (TTMX <= V_IOWidth - 10) And (TTMY <= V_IOHeight - 51) Then
    
  2654.                     TCurSel = 2
    
  2655.                 Elseif (TTMX >= 80) And (TTMY >= V_IOHeight - 47) And (TTMX <= V_IOWidth / 2 - 15) And (TTMY <= V_IOHeight - 31) Then
    
  2656.                     TCurSel = 3
    
  2657.                 Elseif (TTMX >= V_IOWidth / 2 + 90) And (TTMY >= V_IOHeight - 47) And (TTMX <= V_IOWidth - 10) And (TTMY <= V_IOHeight - 31) Then
    
  2658.                     TCurSel = 4
    
  2659.                 Elseif (TTMX >= 4) And (TTMY >= V_IOHeight - 20) And (TTMX <= 100) And (TTMY <= V_IOHeight - 5) Then
    
  2660.                     Exit Do
    
  2661.                 Elseif (TTMX >= V_IOWidth - 104) And (TTMY >= V_IOHeight - 20) And (TTMX <= V_IOWidth - 5) And (TTMY <= V_IOHeight - 5) Then
    
  2662.                     If THost <> "" Then
    
  2663.                         C = Instrrev(THost, ":")
    
  2664.                         If C > 0 Then If Left(THost, C - 1) = "" Then Continue Do
    
  2665.                         RV_Host = ""
    
  2666.                         RV_Port = 6006
    
  2667.                         RV_PassServer = ""
    
  2668.                         RV_User = ""
    
  2669.                         RV_Pass = ""
    
  2670.                         If C > 0 Then
    
  2671.                             RV_Host = Left(THost, C - 1)
    
  2672.                             RV_Port = Cushort(Mid(THost, C + 1))
    
  2673.                         Else
    
  2674.                             RV_Host = THost
    
  2675.                             RV_Port = 6006
    
  2676.                         End If
    
  2677.                         RV_PassServer = TPassServer
    
  2678.                         RV_User = TUser
    
  2679.                         RV_Pass = TPass
    
  2680.                         TRV = EGNP_GURU_NoError
    
  2681.                         'EGNP_GURU_NoErrorCreateAccount
    
  2682.                         Exit Do
    
  2683.                     End If
    
  2684.                     
    
  2685.                 Elseif TTMX < (V_IOWidth - 20) Then
    
  2686.                     C = Fix((TTMY - 4) / 20)
    
  2687.                     If (C >= 1) And (C <= TListMax) Then
    
  2688.                         TListSel = C + TListStart
    
  2689.                         If TListSel > 1 Then
    
  2690.                             C = 0
    
  2691.                             TSLPtr = EGNP_INT_ServerPubSLF
    
  2692.                             Do Until TSLPtr = 0
    
  2693.                                 C += 1
    
  2694.                                 If C = TListSel Then
    
  2695.                                     With *TSLPtr
    
  2696.                                         TPort = .V_Port
    
  2697.                                         THost = .V_IPA
    
  2698.                                         If TPort <> 6006 Then THost += ":" & Str(TPort)
    
  2699.                                         TPassServer = ""
    
  2700.                                         TUser = ""
    
  2701.                                         TPass = ""
    
  2702.                                         TListSelFlags = .V_Flags
    
  2703.                                     End With
    
  2704.                                     Exit Do
    
  2705.                                 End If
    
  2706.                                 TSLPtr = TSLPtr->V_Next
    
  2707.                             Loop
    
  2708.                             For XX As Integer = 1 To 4
    
  2709.                                 TCurStart(XX) = 0
    
  2710.                                 TCurPos(XX) = 0
    
  2711.                             Next
    
  2712.                         Else
    
  2713.                             TPort = RV_Port
    
  2714.                             THost = RV_Host
    
  2715.                             If TPort <> 6006 Then THost += ":" & Str(TPort)
    
  2716.                             TPassServer = RV_PassServer
    
  2717.                             TUser = RV_User
    
  2718.                             TPass = RV_Pass
    
  2719.                             TListSelFlags = EGNP_SFE_Serverpass Or EGNP_SFE_Account
    
  2720.                         End If
    
  2721.                     End If
    
  2722.                 End If
    
  2723.             End If
    
  2724.         End If
    
  2725.     End If
    
  2726.     If TKey0 <> 0 Then
    
  2727.         Select Case TCurSel
    
  2728.             Case 1: TInput = THost
    
  2729.             Case 2: TInput = TPassServer
    
  2730.             Case 3: TInput = TUser
    
  2731.             Case 4: TInput = TPass
    
  2732.         End Select
    
  2733.         Select Case TKey0
    
  2734.             Case 8 'bspace
    
  2735.                 If TCurSel = 0 Then Exit Select
    
  2736.                 If TCurPos(TCurSel) <= 0 Then Exit Select
    
  2737.                 If (TListSel <> 1) And (TCurSel = 1) Then Exit Select
    
  2738.                 If (TCurSel = 2) And ((TListSelFlags And EGNP_SFE_Serverpass) = 0) Then Exit Select
    
  2739.                 If (TCurSel > 2) And ((TListSelFlags And EGNP_SFE_Account) = 0) Then Exit Select
    
  2740.                 TInput = Left(TInput, TCurPos(TCurSel) - 1) & Mid(TInput, TCurPos(TCurSel) + 1)
    
  2741.                 TCurPos(TCurSel) -= 1
    
  2742.                 
    
  2743.             Case 9 'tab
    
  2744.                 CX = TCurSel
    
  2745.                 Do
    
  2746.                     TCurSel += 1
    
  2747.                     If TCurSel > 4 Then TCurSel = 1
    
  2748.                     If TCurSel = CX Then Exit Do
    
  2749.                     Select Case TCurSel
    
  2750.                         Case 1      : Exit Do
    
  2751.                         Case 2      : If (TListSelFlags And EGNP_SFE_Serverpass)    <> 0 Then Exit Do
    
  2752.                         Case 3, 4   : If (TListSelFlags And EGNP_SFE_Account)       <> 0 Then Exit Do
    
  2753.                     End Select
    
  2754.                 Loop
    
  2755.                 TKey0 = 0
    
  2756.                 
    
  2757.             Case 13
    
  2758.                 If THost <> "" Then
    
  2759.                     C = Instrrev(THost, ":")
    
  2760.                     If C > 0 Then If Left(THost, C - 1) = "" Then Continue Do
    
  2761.                     RV_Host = ""
    
  2762.                     RV_Port = 6006
    
  2763.                     RV_PassServer = ""
    
  2764.                     RV_User = ""
    
  2765.                     RV_Pass = ""
    
  2766.                     If C > 0 Then
    
  2767.                         RV_Host = Left(THost, C - 1)
    
  2768.                         RV_Port = Cushort(Mid(THost, C + 1))
    
  2769.                     Else
    
  2770.                         RV_Host = THost
    
  2771.                         RV_Port = 6006
    
  2772.                     End If
    
  2773.                     RV_PassServer = TPassServer
    
  2774.                     RV_User = TUser
    
  2775.                     RV_Pass = TPass
    
  2776.                     TRV = EGNP_GURU_NoError
    
  2777.                     'EGNP_GURU_NoErrorCreateAccount
    
  2778.                     Exit Do
    
  2779.                 End If
    
  2780.                 
    
  2781.             Case 27: Exit Do
    
  2782.             Case 48 To 57 '09
    
  2783.                 If TCurSel = 0 Then Exit Select
    
  2784.                 If (TListSel <> 1) And (TCurSel = 1) Then Exit Select
    
  2785.                 If (TCurSel = 2) And ((TListSelFlags And EGNP_SFE_Serverpass) = 0) Then Exit Select
    
  2786.                 If (TCurSel > 2) And ((TListSelFlags And EGNP_SFE_Account) = 0) Then Exit Select
    
  2787.                 TInput = Left(TInput, TCurPos(TCurSel)) & Chr(TKey0) & Mid(TInput, TCurPos(TCurSel) + 1)
    
  2788.                 TCurPos(TCurSel) += 1
    
  2789.                 
    
  2790.             Case 65 To 90, 97 To 122 'AZaz
    
  2791.                 If TCurSel = 0 Then Exit Select
    
  2792.                 If (TListSel <> 1) And (TCurSel = 1) Then Exit Select
    
  2793.                 If (TCurSel = 2) And ((TListSelFlags And EGNP_SFE_Serverpass) = 0) Then Exit Select
    
  2794.                 If (TCurSel > 2) And ((TListSelFlags And EGNP_SFE_Account) = 0) Then Exit Select
    
  2795.                 TInput = Left(TInput, TCurPos(TCurSel)) & Chr(TKey0) & Mid(TInput, TCurPos(TCurSel) + 1)
    
  2796.                 TCurPos(TCurSel) += 1
    
  2797.                 
    
  2798.             Case 32 To 47, 58 To 64, 123 To 126, 128 To 254 'sonderzeichen
    
  2799.                 Select Case TCurSel
    
  2800.                     Case 1: If (TKey0 <> 58) And (TKey0 <> 46) Then Continue Do
    
  2801.                     Case 0, 3: Continue Do
    
  2802.                 End Select
    
  2803.                 If (TCurSel = 2) And ((TListSelFlags And EGNP_SFE_Serverpass) = 0) Then Exit Select
    
  2804.                 If (TCurSel > 2) And ((TListSelFlags And EGNP_SFE_Account) = 0) Then Exit Select
    
  2805.                 TInput = Left(TInput, TCurPos(TCurSel)) & Chr(TKey0) & Mid(TInput, TCurPos(TCurSel) + 1)
    
  2806.                 TCurPos(TCurSel) += 1
    
  2807.                 
    
  2808.             Case 255
    
  2809.                 Select Case TKey1
    
  2810.                     Case 63: TState = 0
    
  2811.                     Case 71: TCurPos(TCurSel) = 0: TCurStart(TCurSel) = 0
    
  2812.                     Case 72: If TListSel > 1 Then TListSel -= 1
    
  2813.                     Case 75: If TCurPos(TCurSel) > 0 Then TCurPos(TCurSel) -= 1
    
  2814.                     Case 77: If TCurPos(TCurSel) < Len(TInput) Then TCurPos(TCurSel) += 1
    
  2815.                     Case 79: TCurPos(TCurSel) = Len(TInput): If TCurPos(TCurSel) > 10 Then TCurStart(TCurSel) = TCurPos(TCurSel) - 5
    
  2816.                     Case 80: If TListSel < TListC Then TListSel += 1
    
  2817.                     Case 83 'del
    
  2818.                         If TCurSel = 0 Then Exit Select
    
  2819.                         If (TListSel <> 1) And (TCurSel = 1) Then Exit Select
    
  2820.                         If (TCurSel = 2) And ((TListSelFlags And EGNP_SFE_Serverpass) = 0) Then Exit Select
    
  2821.                         If (TCurSel > 2) And ((TListSelFlags And EGNP_SFE_Account) = 0) Then Exit Select
    
  2822.                         If TCurPos(TCurSel) < Len(TInput) Then
    
  2823.                             TInput = Left(TInput, TCurPos(TCurSel)) & Mid(TInput, TCurPos(TCurSel) + 2)
    
  2824.                         End If
    
  2825.                     Case Else: Print #1, "KEY: " & TKey0 & " - " & TKey1
    
  2826.                 End Select
    
  2827.             Case Else: Print #1, "KEY: " & TKey0 & " - " & TKey1
    
  2828.         End Select
    
  2829.         If TKey0 <> 0 Then
    
  2830.             Select Case TCurSel
    
  2831.                 Case 1: THost = TInput
    
  2832.                 Case 2: TPassServer = TInput
    
  2833.                 Case 3: TUser = TInput
    
  2834.                 Case 4: TPass = TInput
    
  2835.             End Select
    
  2836.         End If
    
  2837.     End If
    
  2838.     
    
  2839.     Line TImg, (0, 0)-(V_IOWidth - 1, V_IOHeight - 1), &HFFDDDDDD, BF
    
  2840.     Line TImg, (0, 0)-(V_IOWidth - 1, V_IOHeight - 1), &HFFAAAAAA, B
    
  2841.     Line TImg, (1, 1)-(V_IOWidth - 2, V_IOHeight - 2), &HFF888888, B
    
  2842.     Select Case TState
    
  2843.         Case 0, 1: TTitle = "Connecting to public server..."
    
  2844.         Case 2: TTitle = "Getting serverlist..."
    
  2845.         Case 10
    
  2846.             TTitle = "Please select a server to connect to."
    
  2847.             TPosY = 30
    
  2848.             Line TImg, (2, 23)-(V_IOWidth - 3, 23), &HFF888888
    
  2849.             C = 0
    
  2850.             TSLPtr = EGNP_INT_ServerPubSLF
    
  2851.             Do Until TSLPtr = 0
    
  2852.                 If C >= TListStart Then Exit Do
    
  2853.                 C += 1
    
  2854.                 TSLPtr = TSLPtr->V_Next
    
  2855.             Loop
    
  2856.             CX = 0
    
  2857.             Do Until TSLPtr = 0
    
  2858.                 If CX >= TListMax Then Exit Do
    
  2859.                 C += 1
    
  2860.                 CX += 1
    
  2861.                 With *TSLPtr
    
  2862.                     If TListSel = C Then
    
  2863.                         Line TImg, (2, TPosY - 6)-(V_IOWidth - 3, TPosY + 14), &HFFAAAAEE, BF
    
  2864.                     Else: Line TImg, (2, TPosY - 6)-(V_IOWidth - 3, TPosY + 14), &HFFFFFFFF, BF
    
  2865.                     End If
    
  2866.                     If (.V_Flags And EGNP_SFE_Serverpass)   <> 0 Then EGNP_INT_Public_DrawSym(TImg, 10, TPosY - 3, 0)
    
  2867.                     If (.V_Flags And EGNP_SFE_Account)      <> 0 Then EGNP_INT_Public_DrawSym(TImg, 30, TPosY - 3, 1)
    
  2868.                     T = ""
    
  2869.                     If C > 1 Then T = "[" & Space(Len(Str(.V_PlayerMax)) - Len(Str(.V_PlayerCur))) & Str(.V_PlayerCur) & "/" & Str(.V_PlayerMax) & "]"
    
  2870.                     Draw String TImg, (50, TPosY), T & Space(9 - Len(T)) & " " & .V_Name, &HFF000000
    
  2871.                     Line TImg, (2, TPosY - 6)-(V_IOWidth - 3, TPosY + 14), &HFFCCCCCC, B
    
  2872.                 End With
    
  2873.                 TPosY += 20
    
  2874.                 TSLPtr = TSLPtr->V_Next
    
  2875.             Loop
    
  2876.             Line TImg, (1, 25 + (TListMax * 20))-(V_IOWidth - 2, 25 + (TListMax * 20)), &HFF888888
    
  2877.             
    
  2878.             'scroll
    
  2879.             Line TImg, (V_IOWidth - 20, 23)-(V_IOWidth - 2, V_IOHeight - 75), &HFFCCCCCC, BF
    
  2880.             If TListC > TListMax Then
    
  2881.                 Line TImg, (V_IOWidth - 20, 23 + ((V_IOHeight - 75) - 63) / (TListC - TListMax) * TListStart)-(V_IOWidth - 2, 63 + ((V_IOHeight - 75) - 63) / (TListC - TListMax) * TListStart), &HFFAAAAEE, BF
    
  2882.                 Line TImg, (V_IOWidth - 20, 23 + ((V_IOHeight - 75) - 63) / (TListC - TListMax) * TListStart)-(V_IOWidth - 2, 63 + ((V_IOHeight - 75) - 63) / (TListC - TListMax) * TListStart), &HFF666666, B
    
  2883.             End If
    
  2884.             Line TImg, (V_IOWidth - 20, 23)-(V_IOWidth - 2, V_IOHeight - 75), &HFF666666, B
    
  2885.             
    
  2886.             'host
    
  2887.             Draw String TImg, (6, V_IOHeight - 62), "Host:", &HFF000000
    
  2888.             Line TImg, (80, V_IOHeight - 67)-(V_IOWidth / 2 - 15, V_IOHeight - 51), Iif(TListSel = 1, Iif(TCurSel = 1, &HFFFFFFAA, &HFFFFFFFF), &HFFAAAAAA), BF
    
  2889.             Draw String TImg, (83, V_IOHeight - 62), Mid(THost, TCurStart(1) + 1, Fix(((V_IOWidth / 2 - 15) - 86) / 8)), &HFF000000
    
  2890.             If TCurSel = 1 Then
    
  2891.                 If (TCurPos(TCurSel) - TCurStart(TCurSel)) >= Fix(((V_IOWidth / 2 - 15) - (80)) / 8) Then TCurStart(TCurSel) += 5
    
  2892.                 If (TCurPos(TCurSel) - TCurStart(TCurSel)) < 0 Then TCurStart(TCurSel) -= 5
    
  2893.                 If TCurStart(TCurSel) < 0 Then TCurStart(TCurSel) = 0
    
  2894.                 Line TImg, (81 + (TCurPos(TCurSel) - TCurStart(TCurSel)) * 8, V_IOHeight - 65)-(82 + (TCurPos(TCurSel) - TCurStart(TCurSel)) * 8, V_IOHeight - 53), &H000000, BF
    
  2895.             End If
    
  2896.             Line TImg, (80, V_IOHeight - 67)-(V_IOWidth / 2 - 15, V_IOHeight - 51), &HFF666666, B
    
  2897.             
    
  2898.             'serverpass
    
  2899.             If (TListSelFlags And EGNP_SFE_Serverpass) <> 0 Then
    
  2900.                 Draw String TImg, (V_IOWidth / 2, V_IOHeight - 62), "Serverpass:", &HFF000000
    
  2901.                 Line TImg, (V_IOWidth / 2 + 90, V_IOHeight - 67)-(V_IOWidth - 10, V_IOHeight - 51), Iif((TListSelFlags And EGNP_SFE_Serverpass) <> 0, Iif(TCurSel = 2, &HFFFFFFAA, &HFFFFFFFF), &HFFAAAAAA), BF
    
  2902.                 Draw String TImg, (V_IOWidth / 2 + 93, V_IOHeight - 62), String(Len(Mid(TPassServer, TCurStart(2) + 1, Fix(((V_IOWidth / 2 - 15) - 86) / 8))), 42), &HFF000000
    
  2903.                 If TCurSel = 2 Then
    
  2904.                     If (TCurPos(TCurSel) - TCurStart(TCurSel)) >= Fix(((V_IOWidth - 10) - (V_IOWidth / 2 + 90)) / 8) Then TCurStart(TCurSel) += 5
    
  2905.                     If (TCurPos(TCurSel) - TCurStart(TCurSel)) < 0 Then TCurStart(TCurSel) -= 5
    
  2906.                     If TCurStart(TCurSel) < 0 Then TCurStart(TCurSel) = 0
    
  2907.                     Line TImg, (V_IOWidth / 2 + 91 + (TCurPos(TCurSel) - TCurStart(TCurSel)) * 8, V_IOHeight - 65)-(V_IOWidth / 2 + 92 + (TCurPos(TCurSel) - TCurStart(TCurSel)) * 8, V_IOHeight - 53), &H000000, BF
    
  2908.                 End If
    
  2909.                 Line TImg, (V_IOWidth / 2 + 90, V_IOHeight - 67)-(V_IOWidth - 10, V_IOHeight - 51), &HFF666666, B
    
  2910.             End If
    
  2911.             
    
  2912.             If (TListSelFlags And EGNP_SFE_Account) <> 0 Then
    
  2913.                 'username
    
  2914.                 Draw String TImg, (6, V_IOHeight - 42), "Username:", &HFF000000
    
  2915.                 Line TImg, (80, V_IOHeight - 47)-(V_IOWidth / 2 - 15, V_IOHeight - 31), Iif((TListSelFlags And EGNP_SFE_Account) <> 0, Iif(TCurSel = 3, &HFFFFFFAA, &HFFFFFFFF), &HFFAAAAAA), BF
    
  2916.                 Draw String TImg, (83, V_IOHeight - 42), Mid(TUser, TCurStart(3) + 1, Fix(((V_IOWidth / 2 - 15) - 86) / 8)), &HFF000000
    
  2917.                 If TCurSel = 3 Then
    
  2918.                     If (TCurPos(TCurSel) - TCurStart(TCurSel)) >= Fix(((V_IOWidth / 2 - 15) - (80)) / 8) Then TCurStart(TCurSel) += 5
    
  2919.                     If (TCurPos(TCurSel) - TCurStart(TCurSel)) < 0 Then TCurStart(TCurSel) -= 5
    
  2920.                     If TCurStart(TCurSel) < 0 Then TCurStart(TCurSel) = 0
    
  2921.                     Line TImg, (81 + (TCurPos(TCurSel) - TCurStart(TCurSel)) * 8, V_IOHeight - 45)-(82 + (TCurPos(TCurSel) - TCurStart(TCurSel)) * 8, V_IOHeight - 33), &H000000, BF
    
  2922.                 End If
    
  2923.                 Line TImg, (80, V_IOHeight - 47)-(V_IOWidth / 2 - 15, V_IOHeight - 31), &HFF666666, B
    
  2924.                 
    
  2925.                 'password
    
  2926.                 Draw String TImg, (V_IOWidth / 2, V_IOHeight - 42), "Password:", &HFF000000
    
  2927.                 Line TImg, (V_IOWidth / 2 + 90, V_IOHeight - 47)-(V_IOWidth - 10, V_IOHeight - 31), Iif((TListSelFlags And EGNP_SFE_Account) <> 0, Iif(TCurSel = 4, &HFFFFFFAA, &HFFFFFFFF), &HFFAAAAAA), BF
    
  2928.                 Draw String TImg, (V_IOWidth / 2 + 93, V_IOHeight - 42), String(Len(Mid(TPass, TCurStart(4) + 1, Fix(((V_IOWidth / 2 - 15) - 86) / 8))), 42), &HFF000000
    
  2929.                 If TCurSel = 4 Then
    
  2930.                     If (TCurPos(TCurSel) - TCurStart(TCurSel)) >= Fix(((V_IOWidth - 10) - (V_IOWidth / 2 + 90)) / 8) Then TCurStart(TCurSel) += 5
    
  2931.                     If (TCurPos(TCurSel) - TCurStart(TCurSel)) < 0 Then TCurStart(TCurSel) -= 5
    
  2932.                     If TCurStart(TCurSel) < 0 Then TCurStart(TCurSel) = 0
    
  2933.                     Line TImg, (V_IOWidth / 2 + 91 + (TCurPos(TCurSel) - TCurStart(TCurSel)) * 8, V_IOHeight - 45)-(V_IOWidth / 2 + 92 + (TCurPos(TCurSel) - TCurStart(TCurSel)) * 8, V_IOHeight - 33), &H000000, BF
    
  2934.                 End If
    
  2935.                 Line TImg, (V_IOWidth / 2 + 90, V_IOHeight - 47)-(V_IOWidth - 10, V_IOHeight - 31), &HFF666666, B
    
  2936.             End If
    
  2937.             
    
  2938.             'cancel
    
  2939.             Line TImg, (4, V_IOHeight - 20)-(100, V_IOHeight - 5), &HFFEE6666, BF
    
  2940.             Line TImg, (4, V_IOHeight - 20)-(100, V_IOHeight - 5), &HFF666666, B
    
  2941.             Draw String TImg, (30, V_IOHeight - 15), "Cancel", &HFF000000
    
  2942.             
    
  2943.             If TRegist = 0 Then
    
  2944.                 'connect
    
  2945.                 If (TListSel > 0) And (THost <> "") Then
    
  2946.                     Line TImg, (V_IOWidth - 104, V_IOHeight - 20)-(V_IOWidth - 5, V_IOHeight - 5), &HFF66EE66, BF
    
  2947.                 Else: Line TImg, (V_IOWidth - 104, V_IOHeight - 20)-(V_IOWidth - 5, V_IOHeight - 5), &HFF666666, BF
    
  2948.                 End If
    
  2949.                 Line TImg, (V_IOWidth - 104, V_IOHeight - 20)-(V_IOWidth - 5, V_IOHeight - 5), &HFF666666, B
    
  2950.                 Draw String TImg, (V_IOWidth - 80, V_IOHeight - 15), "Connect", &HFF000000
    
  2951.             End If
    
  2952.             
    
  2953.     End Select
    
  2954.     Draw String TImg, (9, 9), TTitle, &HFF000000
    
  2955.     
    
  2956.     Circle TImg, (TMX - TSPosX, TMY - TSPosY), 3, &HFF666666
    
  2957.     Screenlock()
    
  2958.     Put (TSPosX, TSPosY), TImg, Pset
    
  2959.     Screenunlock()
    
  2960.     Select Case TState
    
  2961.         Case 0
    
  2962.             If EGNP_INT_ServerPubTSNEID = 0 Then
    
  2963.                 EGNP_INT_ServerPubData = ""
    
  2964.                 TSNE_Create_Client(EGNP_INT_ServerPubTSNEID, EGNP_INT_PubServerHost, EGNP_INT_PubServerPort, @EGNP_INT_Public_Disconnected, 0, @EGNP_INT_Public_NewData)
    
  2965.             End If
    
  2966.             TState = 1
    
  2967.         
    
  2968.         Case 1
    
  2969.             If TSNE_WaitConnected(EGNP_INT_ServerPubTSNEID) <> TSNE_Const_NoError Then Exit Do
    
  2970.             TState = 2
    
  2971.             T = ""
    
  2972.             T += EGNP_INT_BuildString(.V_GameName)
    
  2973.             T += EGNP_INT_BuildUInteger(.V_GameVersion)
    
  2974.             EGNP_INT_AsyncSendToOne(EGNP_INT_ServerPubTSNEID, EGNP_INT_BuildCMD(EGNP_CMD_ServerList, T))
    
  2975.             
    
  2976.         Case 2
    
  2977.             If TSNE_IsClosed(EGNP_INT_ServerPubTSNEID) = 1 Then EGNP_INT_ServerPubTSNEID = 0: Exit Do
    
  2978.             If TTime <> EGNP_INT_ServerPubSLTime Then
    
  2979.                 TTime = EGNP_INT_ServerPubSLTime
    
  2980.                 TListC = 0
    
  2981.                 TSLPtr = EGNP_INT_ServerPubSLF
    
  2982.                 Do Until TSLPtr = 0
    
  2983.                     TListC += 1
    
  2984.                     TSLPtr = TSLPtr->V_Next
    
  2985.                 Loop
    
  2986.                 TState = 10
    
  2987.             End If
    
  2988.             
    
  2989.     End Select
    
  2990.     'USleep 10000
    
  2991.     Sleep 10, 1
    
  2992. Loop
    
  2993. Line TImg, (0, 0)-(V_IOWidth - 1, V_IOHeight - 1), &HFFDDDDDD, BF
    
  2994. Line TImg, (0, 0)-(V_IOWidth - 1, V_IOHeight - 1), &HFFBBBBBB, B
    
  2995. Draw String TImg, (5, 5), "Selection success!", &HFF000000
    
  2996. Put (TScreenW / 2 - V_IOWidth / 2, TScreenH / 2 - V_IOHeight / 2), TImg, Pset
    
  2997. Imagedestroy(TImg)
    
  2998. Return TRV
    
  2999. End Function
    
  3000. 
    
  3001. 
    
  3002. 
    
  3003. 
    
  3004. 
    
  3005. 
    
  3006. 
    
  3007. 
    
  3008. 
    
  3009. '####################################################################################################################################################
    
  3010. #ENDIF
    
  3011. 
    
  3012.