@@ -13,14 +13,13 @@ namespace KBEngine
1313 public class PersistentInofs
1414 {
1515 string _persistentDataPath = "" ;
16- string _digest = "" ;
17-
18- string _lastloaded = "" ;
16+ bool _isGood = false ;
1917
2018 public PersistentInofs ( string path )
2119 {
2220 _persistentDataPath = path ;
2321 installEvents ( ) ;
22+ _isGood = loadAll ( ) ;
2423 }
2524
2625 void installEvents ( )
@@ -32,26 +31,24 @@ void installEvents()
3231 KBEngine . Event . registerOut ( "onScriptVersionNotMatch" , this , "onScriptVersionNotMatch" ) ;
3332 }
3433
35- string _getSuffix ( )
34+ public bool isGood ( )
3635 {
37- return _digest + "." + KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion + "." +
38- KBEngineApp . app . getInitArgs ( ) . ip + "." + KBEngineApp . app . getInitArgs ( ) . port ;
36+ return _isGood ;
3937 }
4038
4139 public bool loadAll ( )
4240 {
43- if ( _lastloaded == _getSuffix ( ) )
44- return true ;
45-
46- KBEngineApp . app . resetMessages ( ) ;
47-
48- byte [ ] loginapp_onImportClientMessages = loadFile ( _persistentDataPath , "loginapp_clientMessages." + _getSuffix ( ) ) ;
41+ byte [ ] loginapp_onImportClientMessages = loadFile ( _persistentDataPath , "loginapp_clientMessages." +
42+ KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
4943
50- byte [ ] baseapp_onImportClientMessages = loadFile ( _persistentDataPath , "baseapp_clientMessages." + _getSuffix ( ) ) ;
44+ byte [ ] baseapp_onImportClientMessages = loadFile ( _persistentDataPath , "baseapp_clientMessages." +
45+ KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
5146
52- byte [ ] onImportServerErrorsDescr = loadFile ( _persistentDataPath , "serverErrorsDescr." + _getSuffix ( ) ) ;
47+ byte [ ] onImportServerErrorsDescr = loadFile ( _persistentDataPath , "serverErrorsDescr." +
48+ KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
5349
54- byte [ ] onImportClientEntityDef = loadFile ( _persistentDataPath , "clientEntityDef." + _getSuffix ( ) ) ;
50+ byte [ ] onImportClientEntityDef = loadFile ( _persistentDataPath , "clientEntityDef." +
51+ KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
5552
5653 if ( loginapp_onImportClientMessages . Length > 0 && baseapp_onImportClientMessages . Length > 0 )
5754 {
@@ -65,41 +62,35 @@ public bool loadAll()
6562 }
6663 catch ( Exception e )
6764 {
68- Dbg . ERROR_MSG ( "PersistentInofs::loadAll(): is error(" + e . ToString ( ) + ")! lastloaded=" + _lastloaded ) ;
65+ Dbg . ERROR_MSG ( "PersistentInofs::loadAll(): is error(" + e . ToString ( ) + ")!" ) ;
6966 clearMessageFiles ( ) ;
7067 return false ;
7168 }
7269 }
7370
74- _lastloaded = _getSuffix ( ) ;
7571 return true ;
7672 }
7773
7874 public void onImportClientMessages ( string currserver , byte [ ] stream )
7975 {
80- if ( _lastloaded == _getSuffix ( ) )
81- return ;
82-
8376 if ( currserver == "loginapp" )
84- createFile ( _persistentDataPath , "loginapp_clientMessages." + _getSuffix ( ) , stream ) ;
77+ createFile ( _persistentDataPath , "loginapp_clientMessages." +
78+ KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion , stream ) ;
8579 else
86- createFile ( _persistentDataPath , "baseapp_clientMessages." + _getSuffix ( ) , stream ) ;
80+ createFile ( _persistentDataPath , "baseapp_clientMessages." +
81+ KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion , stream ) ;
8782 }
8883
8984 public void onImportServerErrorsDescr ( byte [ ] stream )
9085 {
91- if ( _lastloaded == _getSuffix ( ) )
92- return ;
93-
94- createFile ( _persistentDataPath , "serverErrorsDescr." + _getSuffix ( ) , stream ) ;
86+ createFile ( _persistentDataPath , "serverErrorsDescr." +
87+ KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion , stream ) ;
9588 }
9689
9790 public void onImportClientEntityDef ( byte [ ] stream )
9891 {
99- if ( _lastloaded == _getSuffix ( ) )
100- return ;
101-
102- createFile ( _persistentDataPath , "clientEntityDef." + _getSuffix ( ) , stream ) ;
92+ createFile ( _persistentDataPath , "clientEntityDef." +
93+ KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion , stream ) ;
10394 }
10495
10596 public void onVersionNotMatch ( string verInfo , string serVerInfo )
@@ -120,33 +111,20 @@ public void onServerDigest(string currserver, string serverProtocolMD5, string s
120111 return ;
121112 }
122113
123- _digest = serverProtocolMD5 + serverEntitydefMD5 ;
124-
125- if ( _lastloaded == _getSuffix ( ) )
126- return ;
127-
128- if ( loadFile ( _persistentDataPath , serverProtocolMD5 + serverEntitydefMD5 + "." +
129- KBEngineApp . app . getInitArgs ( ) . ip + "." + KBEngineApp . app . getInitArgs ( ) . port ) . Length == 0 )
114+ if ( loadFile ( _persistentDataPath , serverProtocolMD5 + serverEntitydefMD5 ) . Length == 0 )
130115 {
131116 clearMessageFiles ( ) ;
132- createFile ( _persistentDataPath , serverProtocolMD5 + serverEntitydefMD5 + "." +
133- KBEngineApp . app . getInitArgs ( ) . ip + "." + KBEngineApp . app . getInitArgs ( ) . port , new byte [ 1 ] ) ;
134- }
135- else
136- {
137- loadAll ( ) ;
117+ createFile ( _persistentDataPath , serverProtocolMD5 + serverEntitydefMD5 , new byte [ 1 ] ) ;
138118 }
139119 }
140120
141121 public void clearMessageFiles ( )
142122 {
143- deleteFile ( _persistentDataPath , "loginapp_clientMessages." + _getSuffix ( ) ) ;
144- deleteFile ( _persistentDataPath , "baseapp_clientMessages." + _getSuffix ( ) ) ;
145- deleteFile ( _persistentDataPath , "serverErrorsDescr." + _getSuffix ( ) ) ;
146- deleteFile ( _persistentDataPath , "clientEntityDef." + _getSuffix ( ) ) ;
123+ deleteFile ( _persistentDataPath , "loginapp_clientMessages." + KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
124+ deleteFile ( _persistentDataPath , "baseapp_clientMessages." + KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
125+ deleteFile ( _persistentDataPath , "serverErrorsDescr." + KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
126+ deleteFile ( _persistentDataPath , "clientEntityDef." + KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
147127 KBEngineApp . app . resetMessages ( ) ;
148-
149- _lastloaded = "" ;
150128 }
151129
152130 public void createFile ( string path , string name , byte [ ] datas )
0 commit comments