• R/O
  • SSH

OMP: 提交

Multiplayer platform


Commit MetaInfo

修订版21a7c5eaab85472fcc877aa09a0487096266eb13 (tree)
时间2008-12-06 05:44:18
作者at0fk
Commiterat0fk

Log Message

Faking FreeLibrary().

更改概述

差异

diff -r f385b0cd8b88 -r 21a7c5eaab85 Orbitersdk/samples/OMP/OMPClient/OMPClient.cpp
--- a/Orbitersdk/samples/OMP/OMPClient/OMPClient.cpp Fri Dec 05 21:42:57 2008 +0100
+++ b/Orbitersdk/samples/OMP/OMPClient/OMPClient.cpp Fri Dec 05 21:44:18 2008 +0100
@@ -606,6 +606,7 @@
606606 char vesselID;
607607
608608 bool loaderLock;
609+ bool shutdown;
609610 }
610611 dinfo;
611612
@@ -698,6 +699,7 @@
698699 }
699700 }
700701 }
702+ FreeLibrary(g_hInst); //Decrements reference counter in order to allow release of native DLL
701703 }
702704
703705 void Launcher::Start()
@@ -2095,12 +2097,16 @@
20952097 switch(fdwReason)
20962098 {
20972099 case DLL_PROCESS_ATTACH:
2100+ dinfo.shutdown=false;
20982101 dinfo.loaderLock=true;
20992102 InitModule(hinstDLL);
2100- dinfo.loaderLock=false;
2103+ dinfo.loaderLock=false;
21012104 break;
21022105 case DLL_PROCESS_DETACH:
2103- ExitModule(hinstDLL);
2106+ dinfo.shutdown=true;
2107+ dinfo.loaderLock=true;
2108+ ExitModule(hinstDLL);
2109+ dinfo.loaderLock=false;
21042110 break;
21052111 }
21062112 return TRUE;
diff -r f385b0cd8b88 -r 21a7c5eaab85 Orbitersdk/samples/OMP/Orbiter.Multiplayer.Client/ManagedPart.cs
--- a/Orbitersdk/samples/OMP/Orbiter.Multiplayer.Client/ManagedPart.cs Fri Dec 05 21:42:57 2008 +0100
+++ b/Orbitersdk/samples/OMP/Orbiter.Multiplayer.Client/ManagedPart.cs Fri Dec 05 21:44:18 2008 +0100
@@ -89,42 +89,56 @@
8989 private void sntpLogger(object sender, EventThrowAppenderEventArgs e)
9090 {
9191 IntPtr text = Marshal.StringToHGlobalAnsi(e.Message);
92- logger(4, text);
92+ try
93+ {
94+ logger(4, text);
95+ }
96+ catch (AccessViolationException ex)
97+ {
98+ Stop();
99+ }
93100 Marshal.FreeHGlobal(text);
94101 }
95102
96103 private void ntpClient_Progress(object sender, NTPClientProgressEventArgs e)
97104 {
98- switch (e.Kind)
105+ try
99106 {
100- case NTPClientProgressKind.Pinging:
101- if (Marshal.ReadInt32(clockVisibility)!=0) Marshal.WriteByte(clockPulseVisibility, 1);
102- blocked = false;
103- break;
104- case NTPClientProgressKind.Blocked:
105- if (Marshal.ReadInt32(clockVisibility) != 0) Marshal.WriteInt32(clockVisibility, 2);
106- blocked = true;
107- break;
108- case NTPClientProgressKind.Pinged:
109- if (blocked) Marshal.WriteInt32(clockVisibility, 1);
110- break;
111- case NTPClientProgressKind.Failed:
112- Marshal.WriteInt32(clockVisibility, 0);
113- break;
114- case NTPClientProgressKind.Idle:
115- if (Marshal.ReadInt32(clockVisibility) == 2) Marshal.WriteInt32(clockVisibility, 1);
116- if (Marshal.ReadInt32(clockVisibility) == 0) Marshal.WriteInt32(clockVisibility, 2);
117- Marshal.WriteByte(clockPulseVisibility, 0);
118- break;
119- case NTPClientProgressKind.Offline:
120- Marshal.WriteInt32(clockVisibility, 0);
121- Marshal.WriteByte(clockPulseVisibility, 0);
122- break;
123- case NTPClientProgressKind.Synced:
124- Marshal.WriteInt32(synchronizationMinimum, (int)(ntpClient.SkewMinimum * 1E6));
125- Marshal.WriteInt32(synchronizationMaximum, (int)(ntpClient.SkewMaximum * 1E6));
126- Marshal.WriteInt32(synchronizationAverage, (int)(ntpClient.Skew * 1E6));
127- break;
107+ switch (e.Kind)
108+ {
109+ case NTPClientProgressKind.Pinging:
110+ if (Marshal.ReadInt32(clockVisibility) != 0) Marshal.WriteByte(clockPulseVisibility, 1);
111+ blocked = false;
112+ break;
113+ case NTPClientProgressKind.Blocked:
114+ if (Marshal.ReadInt32(clockVisibility) != 0) Marshal.WriteInt32(clockVisibility, 2);
115+ blocked = true;
116+ break;
117+ case NTPClientProgressKind.Pinged:
118+ if (blocked) Marshal.WriteInt32(clockVisibility, 1);
119+ break;
120+ case NTPClientProgressKind.Failed:
121+ Marshal.WriteInt32(clockVisibility, 0);
122+ break;
123+ case NTPClientProgressKind.Idle:
124+ if (Marshal.ReadInt32(clockVisibility) == 2) Marshal.WriteInt32(clockVisibility, 1);
125+ if (Marshal.ReadInt32(clockVisibility) == 0) Marshal.WriteInt32(clockVisibility, 2);
126+ Marshal.WriteByte(clockPulseVisibility, 0);
127+ break;
128+ case NTPClientProgressKind.Offline:
129+ Marshal.WriteInt32(clockVisibility, 0);
130+ Marshal.WriteByte(clockPulseVisibility, 0);
131+ break;
132+ case NTPClientProgressKind.Synced:
133+ Marshal.WriteInt32(synchronizationMinimum, (int) (ntpClient.SkewMinimum*1E6));
134+ Marshal.WriteInt32(synchronizationMaximum, (int) (ntpClient.SkewMaximum*1E6));
135+ Marshal.WriteInt32(synchronizationAverage, (int) (ntpClient.Skew*1E6));
136+ break;
137+ }
138+ }
139+ catch (AccessViolationException ex)
140+ {
141+ Stop();
128142 }
129143 }
130144 /// <summary>
diff -r f385b0cd8b88 -r 21a7c5eaab85 Orbitersdk/samples/OMP/Orbiter.Multiplayer/NTPClient.cs
--- a/Orbitersdk/samples/OMP/Orbiter.Multiplayer/NTPClient.cs Fri Dec 05 21:42:57 2008 +0100
+++ b/Orbitersdk/samples/OMP/Orbiter.Multiplayer/NTPClient.cs Fri Dec 05 21:44:18 2008 +0100
@@ -313,6 +313,7 @@
313313 }
314314 }
315315 }
316+ else synchronizing = false;
316317 }
317318
318319 /// <summary>
Show on old repository browser