feat(server): save economy hardening and CH5 continuation work

This commit is contained in:
shen
2026-10-22 06:22:23 -07:00
parent c979b53762
commit 5b7442ea37
142 changed files with 5850 additions and 1682 deletions
+8 -6
View File
@@ -22,11 +22,13 @@ inline std::string PortItemExtraHex(const PortItemExtra& extra) {
return result;
}
inline bool PortItemExtraRead(const char* hex,PortItemExtra& extra) {
std::memset(&extra,0,sizeof(extra));
if(!hex || !*hex)return true;
if(std::strlen(hex)!=sizeof(extra)*2)return false;
PortItemExtra decoded = {};
if(!hex)return false;
if(!*hex){extra=decoded;return true;}
if(std::strlen(hex)!=sizeof(decoded)*2)return false;
auto nibble=[](char c){return c>='0' && c<='9'?c-'0':c>='A' && c<='F'?c-'A'+10:c>='a' && c<='f'?c-'a'+10:-1;};
auto p=reinterpret_cast<unsigned char*>(&extra);
for(unsigned i=0;i<sizeof(extra);++i){int a=nibble(hex[2*i]),b=nibble(hex[2*i+1]);if(a<0 || b<0){std::memset(&extra,0,sizeof(extra));return false;}p[i]=(a<<4)|b;}
extra.name[24]=0;return true;
auto p=reinterpret_cast<unsigned char*>(&decoded);
for(unsigned i=0;i<sizeof(decoded);++i){int a=nibble(hex[2*i]),b=nibble(hex[2*i+1]);if(a<0 || b<0)return false;p[i]=static_cast<unsigned char>((a<<4)|b);}
if(decoded.name[24]!=0)return false;
extra=decoded;return true;
}