Hot update, in layman's terms, is a patch. Players know that they can update the client by restarting the client. They don't need to uninstall and reinstall the app. Compared with stand-alone games, this is also a thing that is used more in online games.
First, the approximate process is as follows:
Are You Ready?
Go!
The content of the luaFileList.json file is generally the key-value pair of the lua file, the key is the lua file path + file name, and the value is the MD5 value:
1
2
3
|
{
"lua/main.lua"
:
"151b0dea5fcd207b1bf0a2d94218de76"
,
}
|
This configuration can be exported by the writer tool:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
public
static
void
ExportLuaJson
(
string
luaRootDir
,
string
outputPath
)
{
if
(
System
.
IO
.
Directory
.
Exists
(
outputPath
)
)
{
FileUtil
.
DeleteFileOrDirectory
(
outputPath
)
;
}
Dictionary
<
string
,
string
>
luaList
=
new
Dictionary
<
string
,
string
>
(
)
;
string
[
]
allLuaList
=
System
.
IO
.
Directory
.
GetFiles
(
luaRootDir
,
"*"
,
System
.
IO
.
SearchOption
.
AllDirectories
)
;
for
(
int
i
=
0
;
i
<
allLuaList
.
Length
;
i
++
)
{
string
filePath
=
allLuaList
[
i
]
;
if
(
filePath
.
EndsWith
(
".meta"
)
)
continue
;
if
(
filePath
.
Contains
(
".svn"
)
)
continue
;
if
(
filePath
.
Contains
(
".bak"
)
)
continue
;
if
(
filePath
.
Contains
(
".bat"
)
)
continue
;
if
(
filePath
.
Contains
(
".txt"
)
)
continue
;
if
(
filePath
.
Contains
(
".DS_Store"
)
)
continue
;
string
luaFilePath
=
filePath
.
Replace
(
"\\"
,
"/"
)
.
Replace
(
luaRootDir
,
""
)
;
string
luaFileMd5
=
GetFileMD5
(
filePath
)
;
luaList
.
Add
(
luaFilePath
,
luaFileMd5
)
;
string
toPath
=
filePath
.
Replace
(
luaRootDir
,
outputPath
)
;
string
toDirectory
=
System
.
IO
.
Path
.
GetDirectoryName
(
toPath
)
;
if
(
!
System
.
IO
.
Directory
.
Exists
(
toDirectory
)
)
{
System
.
IO
.
Directory
.
CreateDirectory
(
toDirectory
)
;
}
FileUtil
.
CopyFileOrDirectoryFollowSymlinks
(
filePath
,
toPath
)
;
}
LitJson
.
JsonWriter
writer
=
new
LitJson
.
JsonWriter
(
)
;
writer
.
PrettyPrint
=
true
;
LitJson
.
JsonMapper
.
ToJson
(
luaList
,
writer
)
;
System
.
IO
.
File
.
WriteAllText
(
outputPath
+
"luaFileList.json"
,
writer
.
TextWriter
.
ToString
(
)
)
;
}
|
There are many interfaces for obtaining MD5 used in the above, so I will not write them here.