diff --git a/Distribution/Data/shrink.cfg b/Distribution/Data/shrink.cfg deleted file mode 100644 index 3e5b8fdc8..000000000 --- a/Distribution/Data/shrink.cfg +++ /dev/null @@ -1,442 +0,0 @@ -# All lines are trimmed. Empty lines and lines starting with '#' are ignored -# Table for converting body values to item numbers -# Format: -# BodyItem - -1 0x20DF -2 0x20D8 -3 0x25B8 -4 0x20D9 -5 0x211D -6 0x211A -7 0x25AF -8 0x2582 -9 0x2584 -10 0x2584 -11 0x25C4 -12 0x20D6 -13 0x25D7 -14 0x20D7 -15 0x25D9 -16 0x25DD -17 0x25AE -18 0x20D8 -19 0x25C4 -20 0x25C5 -21 0x25BF -22 0x258F -23 0x25D0 -24 0x25A4 -25 0x25D1 -26 0x25C7 -27 0x25D1 -28 0x25C6 -29 0x2592 -30 0x20DC -31 0x2595 -33 0x20DE -34 0x25D2 -35 0x20DE -36 0x20DE -37 0x25D2 -38 0x2585 -39 0x25A6 -40 0x2586 -41 0x25AE -42 0x25B7 -43 0x2587 -44 0x25B7 -45 0x25B7 -46 0x20D6 -47 0x20FA -48 0x25B9 -49 0x20D6 -50 0x25BC -51 0x20E8 -52 0x25C2 -53 0x20E9 -54 0x20E9 -55 0x20E9 -56 0x25BC -57 0x25BC -58 0x2100 -59 0x20D6 -60 0x20D6 -61 0x20D6 -62 0x20D6 -63 0x2583 -64 0x25A3 -65 0x25A3 -66 0x25C8 -67 0x258E -68 0x258F -69 0x258F -70 0x25CC -71 0x25C9 -72 0x25CB -73 0x2594 -74 0x259F -75 0x212D -76 0x25CD -77 0x25A2 -78 0x25A5 -79 0x25A5 -80 0x258C -81 0x2130 -82 0x25A5 -83 0x25A8 -84 0x25A8 -85 0x25AB -86 0x25AD -87 0x25AC -88 0x2108 -89 0x25C0 -90 0x25C1 -91 0x25C2 -92 0x25C2 -93 0x25C2 -94 0x20E8 -96 0x20E8 -97 0x2596 -98 0x2596 -99 0x25D1 -100 0x25D2 -101 0x2581 -102 0x2584 -103 0x20D6 -104 0x20D6 -105 0x20D6 -106 0x20D6 -107 0x20D7 -108 0x20D7 -109 0x20D7 -110 0x20D7 -111 0x20D7 -112 0x20D7 -113 0x20D7 -114 0x259B -115 0x259B -116 0x259C -117 0x259D -118 0x259E -119 0x259E -120 0x259E -121 0x259E -122 0x25CE -123 0x2589 -124 0x258A -125 0x258B -126 0x258B -127 0x2597 -128 0x25B6 -129 0x25C8 -130 0x258D -131 0x2590 -132 0x25A0 -133 0x2131 -134 0x25A1 -135 0x25A8 -136 0x25A9 -137 0x25AA -138 0x25AF -139 0x25AF -140 0x25B1 -141 0x2106 -142 0x25B7 -143 0x25B7 -144 0x25BA -145 0x20FB -146 0x25BB -147 0x25BD -148 0x25BE -150 0x20FB -151 0x20F1 -152 0x25CA -153 0x2591 -154 0x25A7 -155 0x20EC -157 0x25C3 -158 0x25D6 -159 0x25D8 -160 0x25D8 -161 0x25DA -162 0x25DB -163 0x25DC -164 0x20ED -165 0x2100 -166 0x20D7 -167 0x2118 -168 0x259F -170 0x20F6 -171 0x25B2 -172 0x20D6 -173 0x25C3 -175 0x2589 -176 0x25B6 -177 0x259C -178 0x259C -179 0x259C -180 0x20D6 -181 0x25AE -182 0x25AE -183 0x2106 -184 0x2107 -185 0x2106 -186 0x2107 -187 0x2615 -188 0x2615 -189 0x25B0 -190 0x21F1 -191 0x25A0 -192 0x25CE -193 0x2615 -194 0x2619 -195 0x260F -197 0x20D6 -198 0x20D6 -200 0x2598 -201 0x211B -202 0x2131 -203 0x2101 -204 0x259A -205 0x2125 -206 0x2131 -207 0x20EB -208 0x20D1 -209 0x2580 -210 0x25B2 -211 0x2118 -212 0x211E -213 0x20E1 -214 0x25B5 -215 0x20D0 -216 0x2103 -217 0x2588 -218 0x25B3 -219 0x25B4 -220 0x20F6 -221 0x20FF -223 0x20EB -225 0x25D3 -226 0x2599 -228 0x259E -231 0x20EF -232 0x20EF -233 0x20F0 -234 0x20D4 -237 0x20D4 -238 0x2123 -290 0x2101 -291 0x2126 -292 0x2127 -300 0x2620 -301 0x2621 -302 0x2622 -303 0x2623 -304 0x2624 -305 0x2625 -306 0x2626 -307 0x2627 -308 0x2628 -309 0x2629 -310 0x262A -311 0x262B -312 0x262C -313 0x262D -314 0x262E -315 0x262F -316 0x2630 -317 0x2631 -318 0x2632 -319 0x2633 -400 0x2106 -401 0x2107 -402 0x2106 -403 0x2107 -744 0x2106 -745 0x2107 -746 0x260E -747 0x262A -748 0x25C7 -749 0x25A4 -750 0x2106 -751 0x2107 -752 0x2610 -753 0x258D -754 0x258D -755 0x258D -756 0x260C -757 0x260B -758 0x258D -763 0x260B -764 0x261F -765 0x261E -766 0x25FC -767 0x25F9 -768 0x2612 -769 0x25F9 -770 0x261C -771 0x261D -772 0x25F8 -773 0x25FA -774 0x25FB -775 0x2613 -776 0x2611 -777 0x260D -778 0x261A -779 0x2607 -780 0x2608 -781 0x2604 -782 0x2603 -783 0x2602 -784 0x2605 -785 0x260E -786 0x260A -787 0x260F -788 0x2618 -789 0x2614 -790 0x2616 -791 0x260F -792 0x2609 -793 0x2617 -794 0x2619 -795 0x2611 -796 0x2611 -797 0x20D6 -798 0x20D6 -799 0x2619 -804 0x2602 -805 0x2604 -806 0x2603 -807 0x2602 -808 0x2602 -820 0x259A -825 0x25B2 -826 0x25B3 -827 0x25B4 -828 0x20F6 -831 0x211A -832 0x211A -833 0x211A -834 0x2597 -835 0x2125 -837 0x25C0 -838 0x25C1 -839 0x2615 -840 0x2615 -841 0x2615 -842 0x2615 -843 0x2123 -846 0x2599 -848 0x259E -970 0x2106 -990 0x2106 -991 0x2106 -994 0x2106 -998 0x25A0 - -#SE Mobiles - -246 0x2763 -254 0x2764 -242 0x2765 -199 0x2766 -247 0x2767 -248 0x2768 -196 0x2769 -243 0x276A -240 0x276B -252 0x276C -241 0x276D -251 0x276E -244 0x276F -250 0x2770 -249 0x2771 -255 0x2772 -253 0x2773 -245 0x281B -169 0x281C - -#ML Mobiles -276 0x2D95 -277 0x2D96 - -#SA Mobiles -666 16941 -667 16942 -714 0x4288 -715 0x4289 -716 0x428A -717 0x428B -718 0x428C -719 0x428D -720 0x428E -721 0x428F -722 0x4290 -723 0x4291 -724 0x4292 -334 0x4293 -725 0x4295 -726 0x4296 -727 0x4297 -728 0x4298 -729 0x4299 -830 0x429A -730 0x429B -829 0x429C -732 0x429D -740 0x429E -733 0x429F -741 0x42A0 -734 0x42A1 -735 0x42A2 -736 0x42A3 -737 0x42A4 -705 0x42A5 -826 0x42A6 -738 0x42A7 -742 0x42A8 -739 0x42A9 - -#TOL Mobiles - -95 0x4988 -156 0x4988 - -1068 0x276E -1069 0x9ED5 -1254 0x9844 -1255 0x9844 - -1285 0x9845 -1286 0x9846 -1287 0x9847 -1288 0x9848 -1289 0x9849 -1290 0x984A -1291 0x984B -1292 0x984C -1293 0x984D -1294 0x984E -1308 0x20F5 -1309 0x9844 -1400 0x9DED -1402 0x9D81 -1403 0x9D81 -1404 0x9D81 -1405 0x9DE4 -1406 0x9DB3 -1407 0x9E35 -1408 0x3ECD -1410 0x9ED5 -1415 0x9DED -1416 0x9844 -1417 0x20D6 -1418 0x20D6 -1419 0x20D6 -1420 0x20D6 -1422 0x20D6 -1423 0x211C -1424 0x9DB6 -1425 0x2108 -1426 0x9F08 diff --git a/Distribution/Data/shrink.json b/Distribution/Data/shrink.json new file mode 100644 index 000000000..5cd7cf3c0 --- /dev/null +++ b/Distribution/Data/shrink.json @@ -0,0 +1,426 @@ +{ + "0x0001": "0x20DF", + "0x0002": "0x20D8", + "0x0003": "0x25B8", + "0x0004": "0x20D9", + "0x0005": "0x211D", + "0x0006": "0x211A", + "0x0007": "0x25AF", + "0x0008": "0x2582", + "0x0009": "0x2584", + "0x000a": "0x2584", + "0x000b": "0x25C4", + "0x000c": "0x20D6", + "0x000d": "0x25D7", + "0x000e": "0x20D7", + "0x000f": "0x25D9", + "0x0010": "0x25DD", + "0x0011": "0x25AE", + "0x0012": "0x20D8", + "0x0013": "0x25C4", + "0x0014": "0x25C5", + "0x0015": "0x25BF", + "0x0016": "0x258F", + "0x0017": "0x25D0", + "0x0018": "0x25A4", + "0x0019": "0x25D1", + "0x001a": "0x25C7", + "0x001b": "0x25D1", + "0x001c": "0x25C6", + "0x001d": "0x2592", + "0x001e": "0x20DC", + "0x001f": "0x2595", + "0x0021": "0x20DE", + "0x0022": "0x25D2", + "0x0023": "0x20DE", + "0x0024": "0x20DE", + "0x0025": "0x25D2", + "0x0026": "0x2585", + "0x0027": "0x25A6", + "0x0028": "0x2586", + "0x0029": "0x25AE", + "0x002a": "0x25B7", + "0x002b": "0x2587", + "0x002c": "0x25B7", + "0x002d": "0x25B7", + "0x002e": "0x20D6", + "0x002f": "0x20FA", + "0x0030": "0x25B9", + "0x0031": "0x20D6", + "0x0032": "0x25BC", + "0x0033": "0x20E8", + "0x0034": "0x25C2", + "0x0035": "0x20E9", + "0x0036": "0x20E9", + "0x0037": "0x20E9", + "0x0038": "0x25BC", + "0x0039": "0x25BC", + "0x003a": "0x2100", + "0x003b": "0x20D6", + "0x003c": "0x20D6", + "0x003d": "0x20D6", + "0x003e": "0x20D6", + "0x003f": "0x2583", + "0x0040": "0x25A3", + "0x0041": "0x25A3", + "0x0042": "0x25C8", + "0x0043": "0x258E", + "0x0044": "0x258F", + "0x0045": "0x258F", + "0x0046": "0x25CC", + "0x0047": "0x25C9", + "0x0048": "0x25CB", + "0x0049": "0x2594", + "0x004a": "0x259F", + "0x004b": "0x212D", + "0x004c": "0x25CD", + "0x004d": "0x25A2", + "0x004e": "0x25A5", + "0x004f": "0x25A5", + "0x0050": "0x258C", + "0x0051": "0x2130", + "0x0052": "0x25A5", + "0x0053": "0x25A8", + "0x0054": "0x25A8", + "0x0055": "0x25AB", + "0x0056": "0x25AD", + "0x0057": "0x25AC", + "0x0058": "0x2108", + "0x0059": "0x25C0", + "0x005a": "0x25C1", + "0x005b": "0x25C2", + "0x005c": "0x25C2", + "0x005d": "0x25C2", + "0x005e": "0x20E8", + "0x005f": "0x4988", + "0x0060": "0x20E8", + "0x0061": "0x2596", + "0x0062": "0x2596", + "0x0063": "0x25D1", + "0x0064": "0x25D2", + "0x0065": "0x2581", + "0x0066": "0x2584", + "0x0067": "0x20D6", + "0x0068": "0x20D6", + "0x0069": "0x20D6", + "0x006a": "0x20D6", + "0x006b": "0x20D7", + "0x006c": "0x20D7", + "0x006d": "0x20D7", + "0x006e": "0x20D7", + "0x006f": "0x20D7", + "0x0070": "0x20D7", + "0x0071": "0x20D7", + "0x0072": "0x259B", + "0x0073": "0x259B", + "0x0074": "0x259C", + "0x0075": "0x259D", + "0x0076": "0x259E", + "0x0077": "0x259E", + "0x0078": "0x259E", + "0x0079": "0x259E", + "0x007a": "0x25CE", + "0x007b": "0x2589", + "0x007c": "0x258A", + "0x007d": "0x258B", + "0x007e": "0x258B", + "0x007f": "0x2597", + "0x0080": "0x25B6", + "0x0081": "0x25C8", + "0x0082": "0x258D", + "0x0083": "0x2590", + "0x0084": "0x25A0", + "0x0085": "0x2131", + "0x0086": "0x25A1", + "0x0087": "0x25A8", + "0x0088": "0x25A9", + "0x0089": "0x25AA", + "0x008a": "0x25AF", + "0x008b": "0x25AF", + "0x008c": "0x25B1", + "0x008d": "0x2106", + "0x008e": "0x25B7", + "0x008f": "0x25B7", + "0x0090": "0x25BA", + "0x0091": "0x20FB", + "0x0092": "0x25BB", + "0x0093": "0x25BD", + "0x0094": "0x25BE", + "0x0096": "0x20FB", + "0x0097": "0x20F1", + "0x0098": "0x25CA", + "0x0099": "0x2591", + "0x009a": "0x25A7", + "0x009b": "0x20EC", + "0x009c": "0x4988", + "0x009d": "0x25C3", + "0x009e": "0x25D6", + "0x009f": "0x25D8", + "0x00a0": "0x25D8", + "0x00a1": "0x25DA", + "0x00a2": "0x25DB", + "0x00a3": "0x25DC", + "0x00a4": "0x20ED", + "0x00a5": "0x2100", + "0x00a6": "0x20D7", + "0x00a7": "0x2118", + "0x00a8": "0x259F", + "0x00a9": "0x281C", + "0x00aa": "0x20F6", + "0x00ab": "0x25B2", + "0x00ac": "0x20D6", + "0x00ad": "0x25C3", + "0x00af": "0x2589", + "0x00b0": "0x25B6", + "0x00b1": "0x259C", + "0x00b2": "0x259C", + "0x00b3": "0x259C", + "0x00b4": "0x20D6", + "0x00b5": "0x25AE", + "0x00b6": "0x25AE", + "0x00b7": "0x2106", + "0x00b8": "0x2107", + "0x00b9": "0x2106", + "0x00ba": "0x2107", + "0x00bb": "0x2615", + "0x00bc": "0x2615", + "0x00bd": "0x25B0", + "0x00be": "0x21F1", + "0x00bf": "0x25A0", + "0x00c0": "0x25CE", + "0x00c1": "0x2615", + "0x00c2": "0x2619", + "0x00c3": "0x260F", + "0x00c4": "0x2769", + "0x00c5": "0x20D6", + "0x00c6": "0x20D6", + "0x00c7": "0x2766", + "0x00c8": "0x2598", + "0x00c9": "0x211B", + "0x00ca": "0x2131", + "0x00cb": "0x2101", + "0x00cc": "0x259A", + "0x00cd": "0x2125", + "0x00ce": "0x2131", + "0x00cf": "0x20EB", + "0x00d0": "0x20D1", + "0x00d1": "0x2580", + "0x00d2": "0x25B2", + "0x00d3": "0x2118", + "0x00d4": "0x211E", + "0x00d5": "0x20E1", + "0x00d6": "0x25B5", + "0x00d7": "0x20D0", + "0x00d8": "0x2103", + "0x00d9": "0x2588", + "0x00da": "0x25B3", + "0x00db": "0x25B4", + "0x00dc": "0x20F6", + "0x00dd": "0x20FF", + "0x00df": "0x20EB", + "0x00e1": "0x25D3", + "0x00e2": "0x2599", + "0x00e4": "0x259E", + "0x00e7": "0x20EF", + "0x00e8": "0x20EF", + "0x00e9": "0x20F0", + "0x00ea": "0x20D4", + "0x00ed": "0x20D4", + "0x00ee": "0x2123", + "0x00f0": "0x276B", + "0x00f1": "0x276D", + "0x00f2": "0x2765", + "0x00f3": "0x276A", + "0x00f4": "0x276F", + "0x00f5": "0x281B", + "0x00f6": "0x2763", + "0x00f7": "0x2767", + "0x00f8": "0x2768", + "0x00f9": "0x2771", + "0x00fa": "0x2770", + "0x00fb": "0x276E", + "0x00fc": "0x276C", + "0x00fd": "0x2773", + "0x00fe": "0x2764", + "0x00ff": "0x2772", + "0x0114": "0x2D95", + "0x0115": "0x2D96", + "0x0122": "0x2101", + "0x0123": "0x2126", + "0x0124": "0x2127", + "0x012c": "0x2620", + "0x012d": "0x2621", + "0x012e": "0x2622", + "0x012f": "0x2623", + "0x0130": "0x2624", + "0x0131": "0x2625", + "0x0132": "0x2626", + "0x0133": "0x2627", + "0x0134": "0x2628", + "0x0135": "0x2629", + "0x0136": "0x262A", + "0x0137": "0x262B", + "0x0138": "0x262C", + "0x0139": "0x262D", + "0x013a": "0x262E", + "0x013b": "0x262F", + "0x013c": "0x2630", + "0x013d": "0x2631", + "0x013e": "0x2632", + "0x013f": "0x2633", + "0x014e": "0x4293", + "0x0190": "0x2106", + "0x0191": "0x2107", + "0x0192": "0x2106", + "0x0193": "0x2107", + "0x029a": "0x422d", + "0x029b": "0x422e", + "0x02c1": "0x42A5", + "0x02ca": "0x4288", + "0x02cb": "0x4289", + "0x02cc": "0x428A", + "0x02cd": "0x428B", + "0x02ce": "0x428C", + "0x02cf": "0x428D", + "0x02d0": "0x428E", + "0x02d1": "0x428F", + "0x02d2": "0x4290", + "0x02d3": "0x4291", + "0x02d4": "0x4292", + "0x02d5": "0x4295", + "0x02d6": "0x4296", + "0x02d7": "0x4297", + "0x02d8": "0x4298", + "0x02d9": "0x4299", + "0x02da": "0x429B", + "0x02dc": "0x429D", + "0x02dd": "0x429F", + "0x02de": "0x42A1", + "0x02df": "0x42A2", + "0x02e0": "0x42A3", + "0x02e1": "0x42A4", + "0x02e2": "0x42A7", + "0x02e3": "0x42A9", + "0x02e4": "0x429E", + "0x02e5": "0x42A0", + "0x02e6": "0x42A8", + "0x02e8": "0x2106", + "0x02e9": "0x2107", + "0x02ea": "0x260E", + "0x02eb": "0x262A", + "0x02ec": "0x25C7", + "0x02ed": "0x25A4", + "0x02ee": "0x2106", + "0x02ef": "0x2107", + "0x02f0": "0x2610", + "0x02f1": "0x258D", + "0x02f2": "0x258D", + "0x02f3": "0x258D", + "0x02f4": "0x260C", + "0x02f5": "0x260B", + "0x02f6": "0x258D", + "0x02fb": "0x260B", + "0x02fc": "0x261F", + "0x02fd": "0x261E", + "0x02fe": "0x25FC", + "0x02ff": "0x25F9", + "0x0300": "0x2612", + "0x0301": "0x25F9", + "0x0302": "0x261C", + "0x0303": "0x261D", + "0x0304": "0x25F8", + "0x0305": "0x25FA", + "0x0306": "0x25FB", + "0x0307": "0x2613", + "0x0308": "0x2611", + "0x0309": "0x260D", + "0x030a": "0x261A", + "0x030b": "0x2607", + "0x030c": "0x2608", + "0x030d": "0x2604", + "0x030e": "0x2603", + "0x030f": "0x2602", + "0x0310": "0x2605", + "0x0311": "0x260E", + "0x0312": "0x260A", + "0x0313": "0x260F", + "0x0314": "0x2618", + "0x0315": "0x2614", + "0x0316": "0x2616", + "0x0317": "0x260F", + "0x0318": "0x2609", + "0x0319": "0x2617", + "0x031a": "0x2619", + "0x031b": "0x2611", + "0x031c": "0x2611", + "0x031d": "0x20D6", + "0x031e": "0x20D6", + "0x031f": "0x2619", + "0x0324": "0x2602", + "0x0325": "0x2604", + "0x0326": "0x2603", + "0x0327": "0x2602", + "0x0328": "0x2602", + "0x0334": "0x259A", + "0x0339": "0x25B2", + "0x033a": "0x42A6", + "0x033b": "0x25B4", + "0x033c": "0x20F6", + "0x033d": "0x429C", + "0x033e": "0x429A", + "0x033f": "0x211A", + "0x0340": "0x211A", + "0x0341": "0x211A", + "0x0342": "0x2597", + "0x0343": "0x2125", + "0x0345": "0x25C0", + "0x0346": "0x25C1", + "0x0347": "0x2615", + "0x0348": "0x2615", + "0x0349": "0x2615", + "0x034a": "0x2615", + "0x034b": "0x2123", + "0x034e": "0x2599", + "0x0350": "0x259E", + "0x03ca": "0x2106", + "0x03de": "0x2106", + "0x03df": "0x2106", + "0x03e2": "0x2106", + "0x03e6": "0x25A0", + "0x042c": "0x276E", + "0x042d": "0x9ED5", + "0x04e6": "0x9844", + "0x04e7": "0x9844", + "0x0505": "0x9845", + "0x0506": "0x9846", + "0x0507": "0x9847", + "0x0508": "0x9848", + "0x0509": "0x9849", + "0x050a": "0x984A", + "0x050b": "0x984B", + "0x050c": "0x984C", + "0x050d": "0x984D", + "0x050e": "0x984E", + "0x051c": "0x20F5", + "0x051d": "0x9844", + "0x0578": "0x9DED", + "0x057a": "0x9D81", + "0x057b": "0x9D81", + "0x057c": "0x9D81", + "0x057d": "0x9DE4", + "0x057e": "0x9DB3", + "0x057f": "0x9E35", + "0x0580": "0x3ECD", + "0x0582": "0x9ED5", + "0x0587": "0x9DED", + "0x0588": "0x9844", + "0x0589": "0x20D6", + "0x058a": "0x20D6", + "0x058b": "0x20D6", + "0x058c": "0x20D6", + "0x058e": "0x20D6", + "0x058f": "0x211C", + "0x0590": "0x9DB6", + "0x0591": "0x2108", + "0x0592": "0x9F08" +} diff --git a/Projects/UOContent/Gumps/AdminGump.cs b/Projects/UOContent/Gumps/AdminGump.cs index 617000435..ee64d00a6 100644 --- a/Projects/UOContent/Gumps/AdminGump.cs +++ b/Projects/UOContent/Gumps/AdminGump.cs @@ -1463,22 +1463,13 @@ namespace Server.Gumps public static string FormatByteAmount(long totalBytes) { - if (totalBytes > 1000000000) + return totalBytes switch { - return $"{(double)totalBytes / 1073741824:F1} GB"; - } - - if (totalBytes > 1000000) - { - return $"{(double)totalBytes / 1048576:F1} MB"; - } - - if (totalBytes > 1000) - { - return $"{(double)totalBytes / 1024:F1} KB"; - } - - return $"{totalBytes} Bytes"; + > 1000000000 => $"{(double)totalBytes / 1073741824:F1} GB", + > 1000000 => $"{(double)totalBytes / 1048576:F1} MB", + > 1000 => $"{(double)totalBytes / 1024:F1} KB", + _ => $"{totalBytes} Bytes" + }; } public static void Initialize() diff --git a/Projects/UOContent/Misc/ShrinkTable.cs b/Projects/UOContent/Misc/ShrinkTable.cs index 5b6e05406..2aad42a5d 100644 --- a/Projects/UOContent/Misc/ShrinkTable.cs +++ b/Projects/UOContent/Misc/ShrinkTable.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; -using System.IO; +using System.Runtime.CompilerServices; +using Server.Json; namespace Server { @@ -8,84 +9,44 @@ namespace Server { public const int DefaultItemID = 0x1870; // Yellow virtue stone - private static int[] m_Table; + private static int[] _shrinkTable; // body is the index, value is the item id - public static int Lookup(Mobile m) => Lookup(m.Body.BodyID, DefaultItemID); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int Lookup(Mobile m, int defaultValue = DefaultItemID) => Lookup(m.Body.BodyID, defaultValue); - public static int Lookup(int body) => Lookup(body, DefaultItemID); - - public static int Lookup(Mobile m, int defaultValue) => Lookup(m.Body.BodyID, defaultValue); - - public static int Lookup(int body, int defaultValue) + public static int Lookup(int body, int defaultValue = DefaultItemID) { - m_Table ??= Load(); - var index = body >= 0 && body < m_Table.Length ? m_Table[body] : -1; - if (index < 0) + _shrinkTable ??= Load(); + if (body < 0 || body >= _shrinkTable.Length) { return defaultValue; } - var val = m_Table[body]; + var val = _shrinkTable[body]; return val == 0 ? defaultValue : val; } private static int[] Load() { - var path = Path.Combine(Core.BaseDirectory, "Data/shrink.cfg"); + var table = JsonConfig.Deserialize>("Data/shrink.json") + ?? new Dictionary(); - if (!File.Exists(path)) + int length = 0; + + foreach (var key in table.Keys) { - Console.WriteLine("No table found!"); - return Array.Empty(); + var index = Utility.ToInt32(key); + length = Math.Max(length, index + 1); } - var list = new List<(int, int)>(); - var length = 0; - - using var ip = new StreamReader(path); - string line; - - while ((line = ip.ReadLine()) != null) + var list = new int[length]; + foreach (var (body, item) in table) { - line = line.Trim(); - - if (line.Length == 0 || line.StartsWithOrdinal("#")) - { - continue; - } - - try - { - var split = line.Split('\t'); - - if (split.Length >= 2) - { - var body = Utility.ToInt32(split[0]); - var item = Utility.ToInt32(split[1]); - - if (body < 0) - { - continue; - } - - list.Add((body, item)); - - length = Math.Max(body + 1, length); - } - } - catch - { - // ignored - } + var index = Utility.ToInt32(body); + list[index] = Utility.ToInt32(item); } - var table = new int[length]; - foreach (var (body, item) in list) - { - table[body] = item; - } - - return table; + return list; } } }