MCPcopy Create free account
hub / github.com/amule-project/amule / LoadServerMet

Method LoadServerMet

src/ServerList.cpp:94–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92
93
94bool CServerList::LoadServerMet(const CPath& path)
95{
96 AddLogLineN(CFormat(_("Loading server.met file: %s")) % path);
97
98 bool merge = !m_servers.empty();
99
100 if (!path.FileExists()) {
101 AddLogLineN(_("Server.met file not found!"));
102 return false;
103 }
104
105 // Try to unpack the file, might be an archive
106 const char* mets[] = { "server.met", NULL };
107 // Try to unpack the file, might be an archive
108 if (UnpackArchive(path, mets).second != EFT_Met) {
109 AddLogLineC(CFormat(_("Failed to load server.met file '%s', unknown format encountered.")) % path);
110 return false;
111 }
112
113 CFile servermet(path, CFile::read);
114 if ( !servermet.IsOpened() ){
115 AddLogLineN(_("Failed to open server.met!") );
116 return false;
117 }
118
119
120 try {
121 Notify_ServerFreeze();
122
123 uint8_t version = servermet.ReadUInt8();
124
125 if (version != 0xE0 && version != MET_HEADER) {
126 AddLogLineC(CFormat(_("Server.met file corrupt, found invalid versiontag: 0x%x, size %i")) % version % sizeof(version));
127 Notify_ServerThaw();
128 return false;
129 }
130
131 uint32 fservercount = servermet.ReadUInt32();
132
133 ServerMet_Struct sbuffer;
134 uint32 iAddCount = 0;
135
136 for ( uint32 j = 0; j < fservercount; ++j ) {
137 sbuffer.ip = servermet.ReadUInt32();
138 sbuffer.port = servermet.ReadUInt16();
139 sbuffer.tagcount = servermet.ReadUInt32();
140
141 CServer* newserver = new CServer(&sbuffer);
142
143 // Load tags
144 for ( uint32 i = 0; i < sbuffer.tagcount; ++i ) {
145 newserver->AddTagFromFile(&servermet);
146 }
147
148 // Server priorities are not in sorted order
149 // High = 1, Low = 2, Normal = 0, so we have to check
150 // in a less logical fashion.
151 int priority = newserver->GetPreferences();

Callers

nothing calls this directly

Calls 15

CFormatClass · 0.85
UnpackArchiveFunction · 0.85
FileExistsMethod · 0.80
ReadUInt8Method · 0.80
ReadUInt32Method · 0.80
ReadUInt16Method · 0.80
AddTagFromFileMethod · 0.80
GetPreferencesMethod · 0.80
SetPreferenceMethod · 0.80
SetListNameMethod · 0.80
SetDescriptionMethod · 0.80
whatMethod · 0.80

Tested by

no test coverage detected