* fixed endless loop in TypeStorage

* misc stuff
This commit is contained in:
false_genesis 2009-01-31 16:32:57 +00:00
parent 24fbafdd51
commit f11a1112be
4 changed files with 37 additions and 4 deletions

12
bin/data/packet/info.txt Normal file
View File

@ -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)

View File

@ -123,7 +123,7 @@ template<class T> void TypeStorage<T>::Unlink(std::string s)
// removes the pointer from the storage without deleting it, if name is unknown
template<class T> void TypeStorage<T>::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<class T> void TypeStorage<T>::UnlinkByPtr(T *ptr)
template<class T> std::string TypeStorage<T>::GetNameByPtr(T *ptr)
{
for(_TypeIter it = _storage.begin(); it != _storage.end();)
for(_TypeIter it = _storage.begin(); it != _storage.end(); it++)
{
if(it->second == ptr)
{

View File

@ -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;
}

View File

@ -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