Procházet zdrojové kódy

1.enet更新版本
2.行为树编辑器增加设定路径功能

tanghai před 10 roky
rodič
revize
c3f58e74e2

+ 1 - 29
CSharp/App/Editor/app.config

@@ -32,34 +32,6 @@
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
   </startup>
   <appSettings>
-    <add key="IP" value="192.168.11.95" />
-    <add key="Port" value="8888" />
-    <add key="Account" value="egametang@163.com" />
-    <add key="Password" value="163bio1" />
-    <add key="NodePath" value="D:\Source\SLOL\Program\Unity\Assets\Resources\Config\TreeProto.txt" />
-    <add key="ClientSettingsProvider.ServiceUri" value="" />
+    <add key="NodePath" value="D:\Source\SLOL\Program\Unity\Assets\Resources\Config\" />
   </appSettings>
-  <system.serviceModel>
-    <bindings>
-      <netTcpBinding>
-        <binding name="NetTcpBinding_Calculator" />
-      </netTcpBinding>
-    </bindings>
-    <client>
-      <endpoint address="net.tcp://localhost:10000/Calculator/" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Calculator" contract="Proxy.Calculator" name="NetTcpBinding_Calculator">
-      </endpoint>
-    </client>
-  </system.serviceModel>
-  <system.web>
-    <membership defaultProvider="ClientAuthenticationMembershipProvider">
-      <providers>
-        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
-      </providers>
-    </membership>
-    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
-      <providers>
-        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
-      </providers>
-    </roleManager>
-  </system.web>
 </configuration>

+ 1 - 0
CSharp/App/Modules/BehaviorTreeModule/AllTreeView.xaml

@@ -28,6 +28,7 @@
 							<MenuItem Header="新建" Click="MenuItem_New" />
 							<MenuItem Header="删除" Click="MenuItem_Remove" />
 							<MenuItem Header="克隆" Click="MenuItem_Clone" />
+							<MenuItem Header="路径" Click="MenuItem_Path" />
 						</ContextMenu>
 					</ListBox.ContextMenu>
 					<ListBox.ItemTemplate>

+ 23 - 2
CSharp/App/Modules/BehaviorTreeModule/AllTreeView.xaml.cs

@@ -1,8 +1,11 @@
 using System.ComponentModel.Composition;
 using System.Configuration;
+using System.IO;
 using System.Windows;
+using System.Windows.Forms;
 using System.Windows.Input;
 using Infrastructure;
+using Application = System.Windows.Application;
 
 namespace Modules.BehaviorTreeModule
 {
@@ -35,7 +38,7 @@ namespace Modules.BehaviorTreeModule
 
 		private void MenuItem_Open(object sender, RoutedEventArgs e)
 		{
-			string nodePath = ConfigurationManager.AppSettings["NodePath"];
+			string nodePath = Path.Combine(ConfigurationManager.AppSettings["NodePath"], "TreeProto.txt");
 			this.ViewModel.Open(nodePath);
 			this.lbTrees.SelectedIndex = -1;
 			this.treeView.ViewModel = null;
@@ -43,7 +46,7 @@ namespace Modules.BehaviorTreeModule
 
 		private void MenuItem_Save(object sender, RoutedEventArgs e)
 		{
-			string nodePath = ConfigurationManager.AppSettings["NodePath"];
+			string nodePath = Path.Combine(ConfigurationManager.AppSettings["NodePath"], "TreeProto.txt");
 			this.ViewModel.Save(nodePath);
 		}
 
@@ -65,6 +68,24 @@ namespace Modules.BehaviorTreeModule
 			this.treeView.ViewModel = newTreeViewModel;
 		}
 
+		private void MenuItem_Path(object sender, RoutedEventArgs e)
+		{
+			FolderBrowserDialog dialog = new FolderBrowserDialog();
+			dialog.SelectedPath = ConfigurationManager.AppSettings["NodePath"];
+			dialog.ShowDialog();
+			string path = dialog.SelectedPath;
+			if (path.Length < 1 || !Directory.Exists(path))
+			{
+				System.Windows.MessageBox.Show("选择的目录无效");
+				return;
+			}
+			Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
+			cfg.AppSettings.Settings["NodePath"].Value = path;
+			cfg.Save();
+			ConfigurationManager.AppSettings["NodePath"] = path;
+			Application.Current.MainWindow.Title = string.Format("行为树编辑器 当前工作目录[{0}]", ConfigurationManager.AppSettings["NodePath"]);
+		}
+
 		private void MenuItem_Remove(object sender, RoutedEventArgs e)
 		{
 			if (this.lbTrees.SelectedItem == null)

+ 2 - 2
CSharp/Platform/ENet/enet/enet.h

@@ -25,7 +25,7 @@ extern "C"
 
 #define ENET_VERSION_MAJOR 1
 #define ENET_VERSION_MINOR 3
-#define ENET_VERSION_PATCH 12
+#define ENET_VERSION_PATCH 13
 #define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
 #define ENET_VERSION_GET_MAJOR(version) (((version)>>16)&0xFF)
 #define ENET_VERSION_GET_MINOR(version) (((version)>>8)&0xFF)
@@ -208,7 +208,7 @@ enum
    ENET_HOST_RECEIVE_BUFFER_SIZE          = 256 * 1024,
    ENET_HOST_SEND_BUFFER_SIZE             = 256 * 1024,
    ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL  = 1000,
-   ENET_HOST_DEFAULT_MTU                  = 512,
+   ENET_HOST_DEFAULT_MTU                  = 600,
    ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE  = 32 * 1024 * 1024,
    ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA = 32 * 1024 * 1024,
 

+ 1 - 1
CSharp/Platform/ENet/host.c

@@ -102,7 +102,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
     host -> duplicatePeers = ENET_PROTOCOL_MAXIMUM_PEER_ID;
     host -> maximumPacketSize = ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE;
     host -> maximumWaitingData = ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA;
-	host->checksum = enet_crc32;
+	host ->checksum = enet_crc32;
 
     host -> compressor.context = NULL;
     host -> compressor.compress = NULL;

+ 8 - 2
CSharp/Platform/ENet/protocol.c

@@ -764,6 +764,10 @@ enet_protocol_handle_bandwidth_limit (ENetHost * host, ENetPeer * peer, const EN
 
     if (peer -> incomingBandwidth == 0 && host -> outgoingBandwidth == 0)
       peer -> windowSize = ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE;
+    else
+    if (peer -> incomingBandwidth == 0 || host -> outgoingBandwidth == 0)
+      peer -> windowSize = (ENET_MAX (peer -> incomingBandwidth, host -> outgoingBandwidth) /
+                             ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;
     else
       peer -> windowSize = (ENET_MIN (peer -> incomingBandwidth, host -> outgoingBandwidth) /
                              ENET_PEER_WINDOW_SIZE_SCALE) * ENET_PROTOCOL_MINIMUM_WINDOW_SIZE;
@@ -1191,7 +1195,9 @@ commandError:
 static int
 enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event)
 {
-    for (;;)
+    int packets;
+
+    for (packets = 0; packets < 256; ++ packets)
     {
        int receivedLength;
        ENetBuffer buffer;
@@ -1484,7 +1490,7 @@ enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer)
                ! (outgoingCommand -> reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) &&
                (channel -> reliableWindows [(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE ||
                  channel -> usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) | 
-                   (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOW_SIZE - reliableWindow)))))
+                   (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOWS - reliableWindow)))))
              windowWrap = 1;
           if (windowWrap)
           {

+ 3 - 3
CSharp/Platform/ENet/unix.c

@@ -104,7 +104,7 @@ enet_address_set_host (ENetAddress * address, const char * name)
     char buffer [2048];
     int errnum;
 
-#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
     gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
 #else
     hostEntry = gethostbyname_r (name, & hostData, buffer, sizeof (buffer), & errnum);
@@ -162,7 +162,7 @@ enet_address_get_host (const ENetAddress * address, char * name, size_t nameLeng
 
     in.s_addr = address -> host;
 
-#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(linux) || defined(__linux) || defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
     gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & hostEntry, & errnum);
 #else
     hostEntry = gethostbyaddr_r ((char *) & in, sizeof (struct in_addr), AF_INET, & hostData, buffer, sizeof (buffer), & errnum);
@@ -246,7 +246,7 @@ enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value)
     {
         case ENET_SOCKOPT_NONBLOCK:
 #ifdef HAS_FCNTL
-            result = fcntl (socket, F_SETFL, O_NONBLOCK | fcntl (socket, F_GETFL));
+            result = fcntl (socket, F_SETFL, (value ? O_NONBLOCK : 0) | (fcntl (socket, F_GETFL) & ~O_NONBLOCK));
 #else
             result = ioctl (socket, FIONBIO, & value);
 #endif

+ 2 - 1
CSharp/Platform/ENet/win32.c

@@ -4,9 +4,10 @@
 */
 #ifdef _WIN32
 
-#include <time.h>
 #define ENET_BUILDING_LIB 1
 #include "enet/enet.h"
+#include <windows.h>
+#include <mmsystem.h>
 
 static enet_uint32 timeBase = 0;