ddnet/src/tools/map_resave.cpp

46 lines
1.1 KiB
C++
Raw Normal View History

2010-11-20 10:37:14 +00:00
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
2010-05-29 07:25:38 +00:00
#include <base/system.h>
#include <engine/shared/datafile.h>
#include <engine/storage.h>
int main(int argc, const char **argv)
{
IStorage *pStorage = CreateStorage("Teeworlds", IStorage::STORAGETYPE_BASIC, argc, argv);
int Index, ID = 0, Type = 0, Size;
2010-05-29 07:25:38 +00:00
void *pPtr;
char aFileName[1024];
CDataFileReader DataFile;
CDataFileWriter df;
if(!pStorage || argc != 3)
2010-05-29 07:25:38 +00:00
return -1;
str_format(aFileName, sizeof(aFileName), "%s", argv[2]);
2010-05-29 07:25:38 +00:00
2010-10-06 21:07:35 +00:00
if(!DataFile.Open(pStorage, argv[1], IStorage::TYPE_ALL))
2010-05-29 07:25:38 +00:00
return -1;
if(!df.Open(pStorage, aFileName))
return -1;
// add all items
for(Index = 0; Index < DataFile.NumItems(); Index++)
{
pPtr = DataFile.GetItem(Index, &Type, &ID);
2010-05-29 07:25:38 +00:00
Size = DataFile.GetItemSize(Index);
df.AddItem(Type, ID, Size, pPtr);
2010-05-29 07:25:38 +00:00
}
// add all data
for(Index = 0; Index < DataFile.NumData(); Index++)
{
pPtr = DataFile.GetData(Index);
Size = DataFile.GetDataSize(Index);
df.AddData(Size, pPtr);
}
DataFile.Close();
df.Finish();
return 0;
}