some Network changes.

This commit is contained in:
Bob
2010-01-23 16:08:36 +13:00
parent f1e0b46d38
commit 3bb40f7d0e
21 changed files with 282 additions and 363 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRa.GameRules;
using OpenRa.Traits;
@@ -51,5 +52,19 @@ namespace OpenRa
if (oai == null) return 0;
return oai.HP;
}
public static V GetOrAdd<K, V>( this Dictionary<K, V> d, K k )
where V : new()
{
return d.GetOrAdd( k, _ => new V() );
}
public static V GetOrAdd<K, V>( this Dictionary<K, V> d, K k, Func<K, V> createFn )
{
V ret;
if( !d.TryGetValue( k, out ret ) )
d.Add( k, ret = createFn( k ) );
return ret;
}
}
}