mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 03:28:19 +00:00
790c1cc0aa
This way new players will get DDNet directory, old ones can switch directory if they want, or keep using the old one. If we ever enforce a switch in a future version, this will make it easier since older DDNet versions will also support the DDNet directory already.
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
/* (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. */
|
|
#include <base/system.h>
|
|
#include <engine/shared/datafile.h>
|
|
#include <engine/storage.h>
|
|
|
|
int main(int argc, const char **argv)
|
|
{
|
|
cmdline_fix(&argc, &argv);
|
|
IStorage *pStorage = CreateStorage(IStorage::STORAGETYPE_BASIC, argc, argv);
|
|
int Index, ID = 0, Type = 0, Size;
|
|
void *pPtr;
|
|
char aFileName[IO_MAX_PATH_LENGTH];
|
|
CDataFileReader DataFile;
|
|
CDataFileWriter df;
|
|
|
|
if(!pStorage || argc != 3)
|
|
return -1;
|
|
|
|
str_format(aFileName, sizeof(aFileName), "%s", argv[2]);
|
|
|
|
if(!DataFile.Open(pStorage, argv[1], IStorage::TYPE_ABSOLUTE))
|
|
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);
|
|
Size = DataFile.GetItemSize(Index);
|
|
|
|
// filter ITEMTYPE_EX items, they will be automatically added again
|
|
if(Type == ITEMTYPE_EX)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
df.AddItem(Type, ID, Size, pPtr);
|
|
}
|
|
|
|
// 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();
|
|
cmdline_free(argc, argv);
|
|
return 0;
|
|
}
|