Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - devomage

Pages: [1] 2 3
1
TNet 3 Support / SetChannelData
« on: January 08, 2018, 05:56:50 AM »
any chance of allowing the entire channel DataNode to be set at once?  rather than multiple single calls?

  1.  
  2. //
  3. //this does not work - but should (it works for playerdata)
  4. //
  5.  
  6. DataNode data = new DataNode("Version", Player.version);
  7. data.SetChild("type", MSTORM_ChannelType.Guild);
  8. data.SetChild("start", GAME.ServerTime);
  9. data.SetChild("founder", TNManager.playerName);
  10. data.SetChild("is_private", true);
  11. data.SetChild("invited", "");
  12. data.SetChild("name", "Guild");
  13.  
  14. TNManager.SetChannelData(channelID, "", data);
  15.  

  1. //line #1541 of TNGameClient.cs
  2. if (ch != null && !string.IsNullOrEmpty(path))
  3.  

2
TNet 3 Support / SetPlayerSave callback
« on: January 01, 2018, 03:06:46 AM »
  1. TNManager.SetPlayerSave(path, DataNode.SaveType.Text);

It would be great if this had a callback!  Or is there a better way than the following?

  1. protected override void OnSetPlayerData(Player p, string path, DataNode node)
  2. {
  3.         base.OnSetPlayerData(p, path, node);
  4.        
  5.         if (p.name == TNManager.playerName)
  6.         {
  7.                 if (string.IsNullOrEmpty(path))
  8.                 {
  9.                      //SetPlayerSave callback
  10.                 }
  11.         }
  12.         else Debug.Log("OnSetPlayerData: name=" + p.name + " path=" + path + " node=" + node.ToString());
  13. }
  14.  

3
TNet 3 Support / Conditional
« on: June 11, 2017, 02:30:57 AM »
I have a couple mono files where I'd like to use TNET if the user has TNET installed.  I cant seem to find an appropriate conditional within TNET.  What is the best way to deal with this?

Maybe like this?

  1. #if TNET_EXISTS
  2.    //TNET code
  3. #else
  4.    //code that doesnt require TNET
  5. #endif



4
TNet 3 Support / Virtual Server Error
« on: May 26, 2017, 07:31:09 PM »
2 more virtual server errors.  Error #1 I can repro.  Error #2 is likely something to do with TNManager.SetPlayerSave.

Note:
- I have deleted server.dat - before, during, between and after.
- all code works fine as a standalone. zero error's.

These error's happen when you connect/disconnect and then try to re-connect.

Error #1 Repro
----------------------
- Create a new project
- Import TNet and NGUI
- Import the attached "TNet Repro.unitypackage"
- Apply the following mod's

TNPacket.cs:
  1. //add these
  2. Request_TestPacket = 129,
  3. Response_TestPacket = 130,

TNGameServer.cs:
  1. #if STANDALONE
  2.                 Tools.Log("Admins: " + mAdmin.size);
  3.                 Tools.Log("Bans: " + mBan.size);
  4.                 Tools.Print("Game server started on port " + tcpPort + " using protocol version " + Player.version);
  5. #endif
  6.  
  7. Repro_Start();//line #297 insert this

TNGameServer.cs: (insert at line #2694 -- after "public bool Load(string fileName)")
  1. #region repro
  2.  
  3. private void Repro_Start()
  4. {
  5.         onCustomPacket += Repro_OnCustomPacket;
  6. }
  7.  
  8. private void Repro_OnCustomPacket(TcpPlayer player, Buffer buffer, BinaryReader reader, Packet request, bool reliable)
  9. {
  10.         switch (request)
  11.         {
  12.                 case Packet.Request_TestPacket:
  13.                         {
  14.                                 string message = reader.ReadString();
  15.                                
  16.                                 BinaryWriter writer2 = BeginSend(Packet.Response_TestPacket);
  17.                                 writer2.Write("message: " + message);
  18.                                 EndSend(true, player);
  19.  
  20.                                 break;
  21.                         }
  22.                 default:
  23.  
  24.                         Tools.Log("OnCustomPacket: " + string.Format("[{0}] name: {1}   request: {2}", player.id, player.name, request));
  25.  
  26.                         break;
  27.         }
  28. }
  29.  
  30. #endregion




Error #2
----------------------
Couple notes on error #2. 

- If I connect/disconnect -- delete server.dat -- reconnect -- Error #2 does not happen, but the code stops executing and halts progress.  This is why i believe the error is related to TNManager.SetPlayerSave.

- I did a ton of debugging and the packet that is being processed is the SetPlayerSave packet.




5
TNet 3 Support / DataNode children Insert
« on: May 16, 2017, 10:54:07 PM »
Any chance of adding a convenience method to deal with reordering DataNode children?

I do not see a canned method to achieve this...



Something like:
  1. System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
  2. list.Insert(index, item);
  3.  

6
TNet 3 Support / Virtual Server Error
« on: April 23, 2017, 05:51:20 PM »
I have the this code attached to a button click and it spits out the following error...

Any idea what could be causing it?  This does not happen with the same code in a fresh scene/script.  Deleting the server.dat file does nothing.




  1. TNServerInstance.Start("server.dat");
  2. TNManager.Connect();
  3.  


Failed to read past end of stream. at position 75
UnityEngine.Debug:LogError(Object)
TNet.Tools:LogError(String, String, Boolean) (at Assets/TNet/Common/TNTools.cs:1068)
TNet.Serialization:ReadObject(BinaryReader, Object, Int32, Type, Boolean) (at Assets/TNet/Common/TNSerializer.cs:2880)
TNet.Serialization:ReadObject(BinaryReader) (at Assets/TNet/Common/TNSerializer.cs:2500)
TNet.Serialization:ReadDataNode(BinaryReader) (at Assets/TNet/Common/TNSerializer.cs:2381)
TNet.TcpProtocol:VerifyRequestID(BinaryReader, Buffer, Boolean) (at Assets/TNet/Common/TNTcpProtocol.cs:947)
TNet.GameServer:ProcessPlayerPacket(Buffer, TcpPlayer, Boolean) (at Assets/TNet/Server/TNGameServer.cs:1254)
TNet.GameServer:ThreadFunction() (at Assets/TNet/Server/TNGameServer.cs:531)

7
TNet 3 Support / PlayerData + LoadFile problem
« on: February 17, 2017, 03:56:11 AM »
When a player successfully authenticates I use SetPlayerData to store the info.  The info is not available if you use the following code example.


  1. internal static void SUCCESS(int user_id, string username)
  2. {
  3.         //LoginProgress.ToggleCredentials();
  4.        
  5.         TNManager.SetPlayerData("account/phpbb_id", user_id);
  6.         TNManager.SetPlayerData("account/phpbb_accountname", username);
  7.  
  8.         TNManager.LoadFile("path/" + username + ".txt", LoadFile);
  9. }
  10.  
  11. private static void LoadFile(string filename, byte[] data)
  12. {
  13.         //Debug.Log(TNManager.playerData.ToString());
  14.  
  15.  
  16.         //these 2 vars were set previously, but are not available here
  17.         int phpbb_id = TNManager.GetPlayerData<int>("account/phpbb_id");
  18.         string phpbb_accountname = TNManager.GetPlayerData<string>("account/phpbb_accountname");
  19.        
  20. }
  21.  

8
NGUI 3 Support / UITexture not displaying
« on: December 06, 2016, 06:26:05 AM »
I have a UITexture that is using a material with a cutout shader.  The texture stopped displaying after upgrading to 3.11.0.  Previous version was 3.10.2.


3rd party shader code:

  1. Shader "UI/AvatarCutout" {
  2. Properties {
  3.  _MainTex ("Base (RGB)", 2D) = "white" { }
  4.  _Mask ("Culling Mask", 2D) = "white" { }
  5.  _Cutoff ("Alpha cutoff", Range(0.000000,1.000000)) = 0.100000
  6. }
  7. SubShader {
  8.  Tags { "QUEUE"="Transparent" }
  9.  Pass {
  10.   Tags { "QUEUE"="Transparent" }
  11.   ZWrite Off
  12.   Blend SrcAlpha OneMinusSrcAlpha
  13. CGPROGRAM
  14. #pragma vertex vert
  15. #pragma fragment frag
  16. #pragma target 2.0
  17. #include "UnityCG.cginc"
  18. #pragma multi_compile_fog
  19. #define USING_FOG (defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2))
  20.  
  21. // uniforms
  22. float4 _Mask_ST;
  23. float4 _MainTex_ST;
  24.  
  25. // vertex shader input data
  26. struct appdata {
  27.   float3 pos : POSITION;
  28.   float3 uv0 : TEXCOORD0;
  29. };
  30.  
  31. // vertex-to-fragment interpolators
  32. struct v2f {
  33.   fixed4 color : COLOR0;
  34.   float2 uv0 : TEXCOORD0;
  35.   float2 uv1 : TEXCOORD1;
  36.   #if USING_FOG
  37.     fixed fog : TEXCOORD2;
  38.   #endif
  39.   float4 pos : SV_POSITION;
  40. };
  41.  
  42. // vertex shader
  43. v2f vert (appdata IN) {
  44.   v2f o;
  45.   half4 color = half4(0,0,0,1.1);
  46.   float3 eyePos = mul (UNITY_MATRIX_MV, float4(IN.pos,1)).xyz;
  47.   half3 viewDir = 0.0;
  48.   o.color = saturate(color);
  49.   // compute texture coordinates
  50.   o.uv0 = IN.uv0.xy * _Mask_ST.xy + _Mask_ST.zw;
  51.   o.uv1 = IN.uv0.xy * _MainTex_ST.xy + _MainTex_ST.zw;
  52.   // fog
  53.   #if USING_FOG
  54.     float fogCoord = length(eyePos.xyz); // radial fog distance
  55.     UNITY_CALC_FOG_FACTOR(fogCoord);
  56.     o.fog = saturate(unityFogFactor);
  57.   #endif
  58.   // transform position
  59.   o.pos = UnityObjectToClipPos(IN.pos);
  60.   return o;
  61. }
  62.  
  63. // textures
  64. sampler2D _Mask;
  65. sampler2D _MainTex;
  66. fixed _Cutoff;
  67.  
  68. // fragment shader
  69. fixed4 frag (v2f IN) : SV_Target {
  70.   fixed4 col;
  71.   fixed4 tex, tmp0, tmp1, tmp2;
  72.   // SetTexture #0
  73.   tex = tex2D (_Mask, IN.uv0.xy);
  74.   col = tex;
  75.   // SetTexture #1
  76.   tex = tex2D (_MainTex, IN.uv1.xy);
  77.   col.rgb = tex;
  78.   col.a = col.a;
  79.   // alpha test
  80.   if (col.a < _Cutoff) clip(-1);
  81.   // fog
  82.   #if USING_FOG
  83.     col.rgb = lerp (unity_FogColor.rgb, col.rgb, IN.fog);
  84.   #endif
  85.   return col;
  86. }
  87.  
  88. // texenvs
  89. //! TexEnv0: 01010000 01010000 [_Mask]
  90. //! TexEnv1: 01010000 01040004 [_MainTex]
  91. ENDCG
  92.  }
  93. }
  94. }
  95.  

9
NGUI 3 Support / 2D/3D mix
« on: November 29, 2016, 09:05:47 PM »
I have zero experience working with 3D GUI's in NGUI.

How would I accomplish adding a 3D object in front of a 2D GUI.

The Diablo 3 Escape Menu is a perfect example.  There is a 2D GUI behind the 2D Escape overlay.  The 3D character model is on a 3D platform that rotates with the mouse and these 3D objects are in front (depth-wise) of the 2D GUI.

I've thought of trying to make the 3D objects 2D somehow -- but seems like they should stay 3D... 



Any suggestions would be helpful.  Thanks in advance!

10
TNet 3 Support / Stand-alone Server DataNode Error
« on: September 30, 2016, 12:38:14 AM »
i have other DateTime vars that i use - not sure what the deal is with this one.

server response to client:
  1. DataNode resptotarget = new DataNode("response", "friend_request");
  2.  
  3. resptotarget.AddChild("status", true);
  4. resptotarget.AddChild("errmsg", "");
  5.  
  6. resptotarget.AddChild("pid", p.id);
  7. resptotarget.AddChild("phpbb_id", ACCOUNT.phpbb_id);
  8. resptotarget.AddChild("phpbb_accountname", ACCOUNT.phpbb_accountname);
  9. resptotarget.AddChild("is_online", ACCOUNT.is_online);
  10. resptotarget.AddChild("last_active", DateTime.UtcNow);//hardcoded date for testing
  11. resptotarget.AddChild("last_charid", ACCOUNT.last_charid);
  12.  

client receives:
  1. response = "friend_request"
  2.         status = true
  3.         errmsg = ""
  4.         phpbb_id = 48
  5.         phpbb_accountname = "tester"
  6.         is_online = true
  7.         last_active = 636108099220000000
  8.         last_charid = 25
  9.  

causes error:
  1. Unable to convert System.UInt64 (636108099220000000) to System.DateTime
  2. UnityEngine.Debug:LogError(Object)
  3. TNet.Tools:LogError(String, String, Boolean) (at Assets/TNet/Common/TNTools.cs:1075)
  4. TNet.Serialization:ConvertObject(Object, Type, GameObject) (at Assets/TNet/Common/TNSerializer.cs:654)
  5. TNet.Serialization:Convert(Object) (at Assets/TNet/Common/TNSerializer.cs:546)
  6. TNet.DataNode:Get() (at Assets/TNet/Common/DataNode.cs:149)
  7. TNet.DataNode:GetChild(String) (at Assets/TNet/Common/DataNode.cs:434)
  8.  
  9. Server:Response(Packet, BinaryReader, IPEndPoint) (at Assets/.../Scripts/GAME.cs:922)
  10.  
  11. TNet.GameClient:ProcessPacket(Buffer, IPEndPoint) (at Assets/TNet/Client/TNGameClient.cs:967)
  12. TNet.GameClient:ProcessPackets() (at Assets/TNet/Client/TNGameClient.cs:918)
  13. TNet.TNManager:<ProcessPackets>m__17() (at Assets/TNet/Client/TNManager.cs:528)
  14. TNet.TNManager:Update() (at Assets/TNet/Client/TNManager.cs:1823)
  15.  

client receive code:
  1. int phpbb_id = data.GetChild<int>("phpbb_id");
  2. string phpbb_accountname = data.GetChild<string>("phpbb_accountname");
  3. bool is_online = data.GetChild<bool>("is_online");
  4. DateTime last_active = data.GetChild<DateTime>("last_active");//line #922 -- commenting out this line, of course - removes the error
  5. int last_charid = data.GetChild<int>("last_charid");
  6.  

11
TNet 3 Support / Stand-alone Server onPlayerDisconnect
« on: September 24, 2016, 08:04:12 PM »
the Player datanode is null when onPlayerDisconnect fires. 

any chance the Player datanode could get sync'd up with TcpPlayer before the onPlayerDisconnect event is called?

temporary fix:
  1. //void RemovePlayer(TcpPlayer p)
  2. //line #610~
  3. #if STANDALONE
  4.         if (p.id != 0) Tools.Log(p.name + " (" + p.address + "): Disconnected [" + p.id + "]");
  5. #endif
  6.  
  7.         //temp_onPlayerDisconnect(p);//sends TcpPlayer instead of Player -- (TcpPlayer)p.datanode is ok with all data
  8.        
  9.         LeaveAllChannels(p);
  10.  
  11.         p.Release();
  12.         p.savePath = null;
  13.         mPlayerList.Remove(p);
  14.  
  15.  
  16.         if (p.udpEndPoint != null)
  17.         {
  18.                 mDictionaryEP.Remove(p.udpEndPoint);
  19.                 p.udpEndPoint = null;
  20.                 p.udpIsUsable = false;
  21.         }
  22.  
  23.         if (p.id != 0)
  24.         {
  25.                 if (mPlayerDict.Remove(p.id))
  26.                 {
  27.                         if (lobbyLink != null) lobbyLink.SendUpdate(this);
  28.                         if (onPlayerDisconnect != null) onPlayerDisconnect(p);//(Player)p.datanode is null at this point
  29.                 }
  30.                 p.id = 0;
  31.         }
  32.  

12
TNet 3 Support / Stand-alone Server - set channel and player datanode
« on: September 14, 2016, 06:02:41 PM »
what is the correct way to set channel and player datanode values from the server?

currently, i send a packet to the channel host and the host sets values via TNManager.  i would rather omit this step and set values directly from the server.

im assuming follow the "Packet.RequestSetPlayerData" case?

13
TNet 3 Support / TransferToChannel
« on: September 08, 2016, 11:42:38 PM »
It seems odd that TransferToChannel(...) does not automagically set the channel id of the TNO.

with a static scene TNO -- tno.channelID remains 0 after using tno.TransferToChannel

  1. public static void SetChannelID(int id)
  2. {
  3.     instance.tno.TransferToChannel(id);
  4.     //instance.tno.channelID = id;//error
  5. }
  6.  

14
TNet 3 Support / Error
« on: September 04, 2016, 03:39:10 AM »
This error pops up every so often when starting the stand-alone server.

15
TNet 3 Support / DataNode Error
« on: August 16, 2016, 08:57:32 PM »
In the following DataNode:
(I can use bytes in this case, but this error needs attention)

Resolves fine:
  1. int phpbb_id = info.data.GetChild("phpbb_id", 0);

Causes an error:
  1. int min_level = info.data.GetChild("min_level", 0);
  2. int max_level = info.data.GetChild("max_level", 0);
  3.  
  4. //Unable to convert System.Byte (1) to System.Int32

  1. Version = 20160207
  2.         type = "Match"
  3.         phpbb_id = 2
  4.         isPrivate = false
  5.         match_type = "Conquest"
  6.         arena_index = 10
  7.         arenaname = "Dev Map"
  8.         min_level = 1
  9.         max_level = 2
  10.         founder = "Pitch Black"
  11.         duration = 15
  12.         start = 636069937084710000
  13.         rules = "1,2"
  14.         teams = "Order,Yellow"
  15.         invited = ""
  16.  

Pages: [1] 2 3