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.


Messages - luvcraft

Pages: [1]
1
NGUI 3 Support / UICamera.fallThrough
« on: October 07, 2014, 02:11:38 PM »
Can you tell me why UICamera.fallThrough now gets set to UIRoot at UICamera.Start()?

Previously if nothing was hovered, it was nice to just get "null" from UICamera.hoveredObject, and also if there are multiple UIRoots in a scene it will default to whichever one started first, even if it's disabled, which is not ideal.

2
TNet 3 Support / TNSerializer bug
« on: August 25, 2014, 08:03:36 PM »
got another TNSerializer bug for ya! :)

line 752 should be
  1. bw.Write(elemType);
NOT
  1. bw.Write(type);
This one's been driving me nuts for a while (it kept failing to deserialize Lists, telling me that it couldn't covert List[List[foo]] to List[foo]), and I finally got around to digging into it this afternoon. This only affects ILists; you had the code setup correctly for TLists. :)

3
TNet 3 Support / Re: MissingMethodExceptions in 1.9.6
« on: July 15, 2014, 12:16:07 PM »
changing that line on DataNode but leaving TNSerializer as it was still gives me errors when I try to read in a TList of my custom class (it does, however, work just fine with the nested-try fix I suggested)

EDIT: This is fixed in 1.9.6b. Thanks!

4
TNet 3 Support / Re: DataNode Write bug
« on: July 15, 2014, 11:59:40 AM »
The MSDN article is confusing, because it initially says that Boolean.TryParse compares the value to the strings "True" and "False", but then in the remarks it says "The value parameter can be preceded or followed by white space. The comparison is ordinal and case-insensitive.", and in the example it correctly parses "true" and "     true     ":

http://msdn.microsoft.com/en-us/library/system.boolean.tryparse(v=vs.110).aspx

I just tested it myself, and found that it does ignore leading/trailing whitespace and case, so it'll also correctly parse "    true    ", "false\n", "TRUE", "FALSE", "tRuE" and "FaLsE".

  1.     void test() {
  2.         {
  3.             string[] values = { null, System.String.Empty, "True", "False",
  4.                           "true", "false", "    true    ", "false\n", "TRUE", "FALSE",
  5.                           "tRuE", "FaLsE", "T", "F", "yes", "no", "0",
  6.                           "1", "-1", "string" };
  7.             foreach (var value in values) {
  8.                 bool flag;
  9.                 if (System.Boolean.TryParse(value, out flag))
  10.                     Debug.Log("\"" + value + "\" --> " + flag.ToString());
  11.                 else
  12.                     Debug.Log("Can't parse \"" + (value == null ? "<null>" : value) + "\"");
  13.             }
  14.         }
  15.     }
  16.  

also, in your current implementation, "True" resolves as false anyway, because ResolveValue only compares the value to "true" and "false", and doesn't pass it on to SetValue as a bool because ResolveValue is called with a type of "null". I recommend adding
  1. else { // is it a boolean?
  2.                 bool b;
  3.  
  4.                 if (bool.TryParse(line, out b)) {
  5.                     mValue = b;
  6.                     return true;
  7.                 }
  8.             }
  9.  
at 693, and removing the string comparisons at 652.

5
TNet 3 Support / Re: DataNode Write bug
« on: July 14, 2014, 02:37:12 PM »
There's still a bug writing bools in 1.9.6. at DataNode.cs you're missing a
  1. writer.Write('\n');
after writing the bool at line 380, so it breaks the formatting.

also, can you please explain why you're using the strings "true" and "false" instead of writing with value.ToString() and reading with Boolean.TryParse()? Is the string comparison just a lot faster?

6
TNet 3 Support / MissingMethodExceptions in 1.9.6
« on: July 14, 2014, 02:26:14 PM »
I just updated to 1.9.6 and immediately got a bunch of MissingMethodExceptions trying to read my custom classes in from DataNodes, because apparently TNet now expects all custom classes' constructors to take exactly one int as an argument (my classes' constructors take no arguments). I fixed it by changing the Create function at TNSerializer line 272 to the following:

  1.    static public object Create (this Type type, int size)
  2.    {
  3.       try
  4.       {
  5.          return Activator.CreateInstance(type, size);
  6.       }
  7.       catch (Exception ex)
  8.       {
  9.             try
  10.             {
  11.                 return Activator.CreateInstance(type);
  12.             }
  13.             catch (Exception ex2)
  14.             {
  15.                 Debug.LogError(ex2.Message + " | " + ex2.GetType());
  16.                 return null;
  17.             }
  18.       }
  19.    }
  20.  

7
TNet 3 Support / Re: DataNode Write bug
« on: June 30, 2014, 07:14:23 PM »
it looks like booleans are also broken? If I try to include a boolean in the DataNode, it gets stuck in a loop of creating System.Boolean values with a System.Boolean child, which itself has a System.Boolean child... and so on until it crashes from stack overflow.

Adding code to correctly write booleans around line 382 gets them writing correctly, but they don't read correctly (when it tries to read, it passes null as the type to SetValue).

EDIT: Got it reading correctly by adding the following at line 646:

  1.             bool flag;
  2.             if (Boolean.TryParse(line, out flag)) {
  3.                 mValue = flag;
  4.                 return true;
  5.             }
  6.  

there's probably a more elegant way to do that.

8
TNet 3 Support / DataNode Write bug
« on: June 26, 2014, 09:39:39 PM »
if you put an empty List or TNet.List in a DataNode, and then do a non-binary write, it'll write the name of the List, followed immediately by a tab and then the next variable in the DataNode. The DataNode will then break horribly when you try to load it.

For example:

  1. List<int> foo = new List<int>();
  2. int bar = 1;
  3.  

will write as:

  1.         foo     bar = 1
  2.  

the culprit is DataNode.cs line 483 and 497; in both of those cases, the
  1.                                                 writer.Write(" = ");
  2.                                                 writer.Write(Serialization.TypeToName(type));
  3.                                                 writer.Write('\n');
  4.  
should come before the
  1. if (list.Count > 0)

I haven't tested to see if this happens with a binary write.

9
TNet 3 Support / are RFCs guaranteed?
« on: June 23, 2014, 01:23:37 PM »
I'm fairly new to network programming, but I'm making a lot of great headway with TNet.

I have a couple of "newbie" questions, though:

  • Are RFCs guaranteed to reach all connected players on the channel? If I send out an RFC, can I safely assume that all connected players on the channel will receive it, or do I need to implement lots of fallbacks and desynch checks in case there's a missed RFC? Does whether or not the target is "saved" change the answer? (I know it would change the answer for players who connect after the RFC is sent, but does it matter for players who are already connected when the RFC is sent?)
  • Are all players guaranteed to receive RFCs in the same order? If multiple players send RFCs simultaneously, will all of the players receive those RFCs in the same order, or do I need to allow for the possibility of different players executing RFCs in a different order from each other?

A "yes" or "no" answer is OK, but I'd also love to know the reason for the yes or no so I can understand the system (and networking in general) better. Thanks!

EDIT: Based on this thread it looks like the answer to #2 is "yes", which probably means that #1 is "yes", too.

10
TNet 3 Support / RFCs not being called on inactive objects
« on: June 13, 2014, 01:25:12 PM »
I was getting the "Unable to execute function funcName. Did you forget an [RFC] prefix, perhaps?" error when I tried to call RFCs on inactive gameobjects, so I changed line 406 of TNObject.cs to:

      MonoBehaviour[] mbs = GetComponentsInChildren<MonoBehaviour>(true);

and that seems to have fixed it! Could you please apply this change to the project, or let me know if it's a bad idea? Thanks!

11
NGUI 3 Documentation / Re: Localization system
« on: March 19, 2014, 07:47:04 PM »
Just wanted to let you know that ByteReader (v3.5.4 r2) was throwing null reference exceptions for me at line 202, so I changed:
  1. line = line.Replace("\\n", "\n");
  2. if (line == null) return null;
  3.  
to
  1. if (line == null)
  2.    return null;
  3. else
  4.    line = line.Replace("\\n", "\n");
  5.  
and then it was happy. I'm posting this here because it looks like some code you posted further up in this thread, but with two lines swapped. And now that I think about it, I should have just swapped those two lines and left out the "else"...

I suspect a similar problem might crop up at line 194.

Pages: [1]