diff --git a/bin/data/packet/info.txt b/bin/data/packet/info.txt new file mode 100644 index 0000000..9260d15 --- /dev/null +++ b/bin/data/packet/info.txt @@ -0,0 +1,12 @@ +This directory contains packets or packet parts. +You can change them with a hex editor or similar, +but BE SURE YOU KNOW WHAT YOU ARE DOING! + + + + +Information about the files: + +addon_info.bin - contains the addon data sent to the server in the CMSG_AUTH_SESSION + packet. (Appended to the normal packet) + diff --git a/src/Client/DefScript/TypeStorage.h b/src/Client/DefScript/TypeStorage.h index 691b523..24206ae 100644 --- a/src/Client/DefScript/TypeStorage.h +++ b/src/Client/DefScript/TypeStorage.h @@ -99,7 +99,7 @@ template void TypeStorage::Clear(bool keep) _storage.clear(); return; } - for(_TypeIter it = _storage.begin(); it != _storage.end();) + for(_TypeIter it = _storage.begin(); it != _storage.end(); ) { delete it->second; _storage.erase(it++); @@ -123,7 +123,7 @@ template void TypeStorage::Unlink(std::string s) // removes the pointer from the storage without deleting it, if name is unknown template void TypeStorage::UnlinkByPtr(T *ptr) { - for(_TypeIter it = _storage.begin(); it != _storage.end();) + for(_TypeIter it = _storage.begin(); it != _storage.end(); it++) { if(it->second == ptr) { @@ -135,7 +135,7 @@ template void TypeStorage::UnlinkByPtr(T *ptr) template std::string TypeStorage::GetNameByPtr(T *ptr) { - for(_TypeIter it = _storage.begin(); it != _storage.end();) + for(_TypeIter it = _storage.begin(); it != _storage.end(); it++) { if(it->second == ptr) { diff --git a/src/shared/tools.cpp b/src/shared/tools.cpp index e2cb6b7..eab59f0 100644 --- a/src/shared/tools.cpp +++ b/src/shared/tools.cpp @@ -248,4 +248,24 @@ std::string NormalizeFilename(std::string s) return s; } - +std::string FilesizeFormat(uint32 b) +{ + char buf[15]; + if (b < 1024) + { + sprintf(buf,"%u B",b); + } + else if(b < 1024*1024) + { + sprintf(buf,"%.2f kB",(b / 1024.0f)); + } + else if(b < 1024*1024*1024) + { + sprintf(buf,"%.2f MB",(b / double(1024*1024))); + } + else + { + sprintf(buf,"%.2f GB",(b / double(1024*1024*1024))); + } + return buf; +} diff --git a/src/shared/tools.h b/src/shared/tools.h index 0396483..551a475 100644 --- a/src/shared/tools.h +++ b/src/shared/tools.h @@ -23,5 +23,6 @@ uint32 GetFileSize(const char*); void _FixFileName(std::string&); std::string _PathToFileName(std::string); std::string NormalizeFilename(std::string); +std::string FilesizeFormat(uint32); #endif