@@ -14,6 +14,7 @@ public class PersistentInofs
1414 {
1515 string _persistentDataPath = "" ;
1616 bool _isGood = false ;
17+ string _digest = "" ;
1718
1819 public PersistentInofs ( string path )
1920 {
@@ -36,19 +37,33 @@ public bool isGood()
3637 return _isGood ;
3738 }
3839
40+ string _getSuffix ( )
41+ {
42+ return _digest + "." + KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion + "." +
43+ KBEngineApp . app . getInitArgs ( ) . ip + "." + KBEngineApp . app . getInitArgs ( ) . port ;
44+ }
45+
3946 public bool loadAll ( )
4047 {
41- byte [ ] loginapp_onImportClientMessages = loadFile ( _persistentDataPath , "loginapp_clientMessages." +
42- KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
48+ KBEngineApp . app . resetMessages ( ) ;
49+
50+ byte [ ] kbengine_digest = loadFile ( _persistentDataPath , "kbengine.digest" ) ;
51+ if ( kbengine_digest . Length <= 0 )
52+ {
53+ clearMessageFiles ( ) ;
54+ return false ;
55+ }
56+
57+ System . Text . ASCIIEncoding encoding = new System . Text . ASCIIEncoding ( ) ;
58+ _digest = encoding . GetString ( kbengine_digest ) ;
59+
60+ byte [ ] loginapp_onImportClientMessages = loadFile ( _persistentDataPath , "loginapp_clientMessages." + _getSuffix ( ) ) ;
4361
44- byte [ ] baseapp_onImportClientMessages = loadFile ( _persistentDataPath , "baseapp_clientMessages." +
45- KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
62+ byte [ ] baseapp_onImportClientMessages = loadFile ( _persistentDataPath , "baseapp_clientMessages." + _getSuffix ( ) ) ;
4663
47- byte [ ] onImportServerErrorsDescr = loadFile ( _persistentDataPath , "serverErrorsDescr." +
48- KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
64+ byte [ ] onImportServerErrorsDescr = loadFile ( _persistentDataPath , "serverErrorsDescr." + _getSuffix ( ) ) ;
4965
50- byte [ ] onImportClientEntityDef = loadFile ( _persistentDataPath , "clientEntityDef." +
51- KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion ) ;
66+ byte [ ] onImportClientEntityDef = loadFile ( _persistentDataPath , "clientEntityDef." + _getSuffix ( ) ) ;
5267
5368 if ( loginapp_onImportClientMessages . Length > 0 && baseapp_onImportClientMessages . Length > 0 )
5469 {
@@ -74,23 +89,19 @@ public bool loadAll()
7489 public void onImportClientMessages ( string currserver , byte [ ] stream )
7590 {
7691 if ( currserver == "loginapp" )
77- createFile ( _persistentDataPath , "loginapp_clientMessages." +
78- KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion , stream ) ;
92+ createFile ( _persistentDataPath , "loginapp_clientMessages." + _getSuffix ( ) , stream ) ;
7993 else
80- createFile ( _persistentDataPath , "baseapp_clientMessages." +
81- KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion , stream ) ;
94+ createFile ( _persistentDataPath , "baseapp_clientMessages." + _getSuffix ( ) , stream ) ;
8295 }
8396
8497 public void onImportServerErrorsDescr ( byte [ ] stream )
8598 {
86- createFile ( _persistentDataPath , "serverErrorsDescr." +
87- KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion , stream ) ;
99+ createFile ( _persistentDataPath , "serverErrorsDescr." + _getSuffix ( ) , stream ) ;
88100 }
89101
90102 public void onImportClientEntityDef ( byte [ ] stream )
91103 {
92- createFile ( _persistentDataPath , "clientEntityDef." +
93- KBEngineApp . app . clientVersion + "." + KBEngineApp . app . clientScriptVersion , stream ) ;
104+ createFile ( _persistentDataPath , "clientEntityDef." + _getSuffix ( ) , stream ) ;
94105 }
95106
96107 public void onVersionNotMatch ( string verInfo , string serVerInfo )
@@ -111,19 +122,27 @@ public void onServerDigest(string currserver, string serverProtocolMD5, string s
111122 return ;
112123 }
113124
114- if ( loadFile ( _persistentDataPath , serverProtocolMD5 + serverEntitydefMD5 ) . Length == 0 )
125+ if ( _digest != serverProtocolMD5 + serverEntitydefMD5 )
126+ _digest = serverProtocolMD5 + serverEntitydefMD5 ;
127+ else
128+ return ;
129+
130+ if ( loadFile ( _persistentDataPath , "kbengine.digest" ) . Length == 0 )
115131 {
116132 clearMessageFiles ( ) ;
117- createFile ( _persistentDataPath , serverProtocolMD5 + serverEntitydefMD5 , new byte [ 1 ] ) ;
133+
134+ System . Text . ASCIIEncoding encoding = new System . Text . ASCIIEncoding ( ) ;
135+ createFile ( _persistentDataPath , "kbengine.digest" , encoding . GetBytes ( serverProtocolMD5 + serverEntitydefMD5 ) ) ;
118136 }
119137 }
120138
121139 public void clearMessageFiles ( )
122140 {
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 ) ;
141+ deleteFile ( _persistentDataPath , "kbengine.digest" ) ;
142+ deleteFile ( _persistentDataPath , "loginapp_clientMessages." + _getSuffix ( ) ) ;
143+ deleteFile ( _persistentDataPath , "baseapp_clientMessages." + _getSuffix ( ) ) ;
144+ deleteFile ( _persistentDataPath , "serverErrorsDescr." + _getSuffix ( ) ) ;
145+ deleteFile ( _persistentDataPath , "clientEntityDef." + _getSuffix ( ) ) ;
127146 KBEngineApp . app . resetMessages ( ) ;
128147 }
129148
0 commit comments