|
1 | 1 | --[[
|
2 | 2 | How to use:
|
3 | 3 |
|
4 |
| -Put all lua files into DatabaseRoot then call ExportDatabaseLocalText( tofile = true, newStringBank = false ) ( beware: all your original files will be replaced with optimized files ) |
| 4 | +Put all lua files into DatabaseRoot then call ExportDatabaseLocalText( tofile = true, newStringBank = false ) at the end of file. ( beware: all your original files will be replaced with optimized files ) |
5 | 5 | If you want to exlucde some input files in DatabaseRoot, just add theirs names into ExcludedFiles
|
6 | 6 |
|
7 | 7 |
|
@@ -35,7 +35,7 @@ local StringBankCSVOutput = DatabaseRoot.."/"..DatabaseLocaleTextName..".csv"
|
35 | 35 | local MaxStringBankRedundancy = 100
|
36 | 36 | local MaxStringBankBinSize = 524288
|
37 | 37 | local LocaleTextLeadingTag = '@'
|
38 |
| -local MaxLocalVariableNum = 190 -- lparser.c #define MAXVARS 200 |
| 38 | +local MaxLocalVariableNum = 160 -- lparser.c #define MAXVARS 200 |
39 | 39 | local RefTableName = "__rt"
|
40 | 40 | local DefaultValueTableName = "__default_values"
|
41 | 41 | local PrintTableRefCount = false
|
@@ -161,8 +161,11 @@ local function OrderedForeachByValue( _table, _func )
|
161 | 161 | for _, _v in ipairs( kv ) do
|
162 | 162 | local k = _v[ 1 ]
|
163 | 163 | local v = _v[ 2 ]
|
164 |
| - _func( k, v ) |
| 164 | + if not pcall( _func, k, v ) then |
| 165 | + return false |
| 166 | + end |
165 | 167 | end
|
| 168 | + return true |
166 | 169 | end
|
167 | 170 | end
|
168 | 171 |
|
@@ -1119,7 +1122,7 @@ local function OptimizeDataset( dataset )
|
1119 | 1122 | local max = -1
|
1120 | 1123 | local defaultValue = nil
|
1121 | 1124 | local _defaultValue = "{}"
|
1122 |
| - OrderedForeachByValue( |
| 1125 | + local result = OrderedForeachByValue( |
1123 | 1126 | defaultValueStat,
|
1124 | 1127 | function( value, count )
|
1125 | 1128 | if count >= max then
|
@@ -1150,6 +1153,9 @@ local function OptimizeDataset( dataset )
|
1150 | 1153 | end
|
1151 | 1154 | end
|
1152 | 1155 | )
|
| 1156 | + if not result then |
| 1157 | + error( string.format( "create default value for \"%s\" failed. please make sure all the value's types are the same.", field ) ) |
| 1158 | + end |
1153 | 1159 | if defaultValue ~= nil then
|
1154 | 1160 | defaultValues = defaultValues or {}
|
1155 | 1161 | defaultValues[ field ] = defaultValue
|
|
0 commit comments