cleaned up content folder creation. Closes #845

This commit is contained in:
oy 2012-01-09 01:38:45 +01:00
parent de8c9b23eb
commit 4073520214
7 changed files with 24 additions and 17 deletions

View file

@ -2272,7 +2272,7 @@ int main(int argc, const char **argv) // ignore_convention
// create the components // create the components
IEngine *pEngine = CreateEngine("Teeworlds"); IEngine *pEngine = CreateEngine("Teeworlds");
IConsole *pConsole = CreateConsole(CFGFLAG_CLIENT); IConsole *pConsole = CreateConsole(CFGFLAG_CLIENT);
IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); // ignore_convention IStorage *pStorage = CreateStorage("Teeworlds", IStorage::STORAGETYPE_CLIENT, argc, argv); // ignore_convention
IConfig *pConfig = CreateConfig(); IConfig *pConfig = CreateConfig();
IEngineSound *pEngineSound = CreateEngineSound(); IEngineSound *pEngineSound = CreateEngineSound();
IEngineInput *pEngineInput = CreateEngineInput(); IEngineInput *pEngineInput = CreateEngineInput();

View file

@ -1675,7 +1675,7 @@ int main(int argc, const char **argv) // ignore_convention
IGameServer *pGameServer = CreateGameServer(); IGameServer *pGameServer = CreateGameServer();
IConsole *pConsole = CreateConsole(CFGFLAG_SERVER|CFGFLAG_ECON); IConsole *pConsole = CreateConsole(CFGFLAG_SERVER|CFGFLAG_ECON);
IEngineMasterServer *pEngineMasterServer = CreateEngineMasterServer(); IEngineMasterServer *pEngineMasterServer = CreateEngineMasterServer();
IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); // ignore_convention IStorage *pStorage = CreateStorage("Teeworlds", IStorage::STORAGETYPE_SERVER, argc, argv); // ignore_convention
IConfig *pConfig = CreateConfig(); IConfig *pConfig = CreateConfig();
pServer->InitRegister(&pServer->m_NetServer, pEngineMasterServer, pConsole); pServer->InitRegister(&pServer->m_NetServer, pEngineMasterServer, pConsole);

View file

@ -30,7 +30,7 @@ public:
m_aUserdir[0] = 0; m_aUserdir[0] = 0;
} }
int Init(const char *pApplicationName, int NumArgs, const char **ppArguments) int Init(const char *pApplicationName, int StorageType, int NumArgs, const char **ppArguments)
{ {
// get userdir // get userdir
fs_storage_path(pApplicationName, m_aUserdir, sizeof(m_aUserdir)); fs_storage_path(pApplicationName, m_aUserdir, sizeof(m_aUserdir));
@ -52,14 +52,17 @@ public:
} }
// add save directories // add save directories
if(m_NumPaths && (!m_aaStoragePaths[TYPE_SAVE][0] || !fs_makedir(m_aaStoragePaths[TYPE_SAVE]))) if(StorageType != STORAGETYPE_BASIC && m_NumPaths && (!m_aaStoragePaths[TYPE_SAVE][0] || !fs_makedir(m_aaStoragePaths[TYPE_SAVE])))
{ {
char aPath[MAX_PATH_LENGTH]; char aPath[MAX_PATH_LENGTH];
fs_makedir(GetPath(TYPE_SAVE, "screenshots", aPath, sizeof(aPath))); if(StorageType == STORAGETYPE_CLIENT)
fs_makedir(GetPath(TYPE_SAVE, "screenshots/auto", aPath, sizeof(aPath))); {
fs_makedir(GetPath(TYPE_SAVE, "maps", aPath, sizeof(aPath))); fs_makedir(GetPath(TYPE_SAVE, "screenshots", aPath, sizeof(aPath)));
fs_makedir(GetPath(TYPE_SAVE, "screenshots/auto", aPath, sizeof(aPath)));
fs_makedir(GetPath(TYPE_SAVE, "maps", aPath, sizeof(aPath)));
fs_makedir(GetPath(TYPE_SAVE, "downloadedmaps", aPath, sizeof(aPath)));
}
fs_makedir(GetPath(TYPE_SAVE, "dumps", aPath, sizeof(aPath))); fs_makedir(GetPath(TYPE_SAVE, "dumps", aPath, sizeof(aPath)));
fs_makedir(GetPath(TYPE_SAVE, "downloadedmaps", aPath, sizeof(aPath)));
fs_makedir(GetPath(TYPE_SAVE, "demos", aPath, sizeof(aPath))); fs_makedir(GetPath(TYPE_SAVE, "demos", aPath, sizeof(aPath)));
fs_makedir(GetPath(TYPE_SAVE, "demos/auto", aPath, sizeof(aPath))); fs_makedir(GetPath(TYPE_SAVE, "demos/auto", aPath, sizeof(aPath)));
} }
@ -389,10 +392,10 @@ public:
GetPath(Type, pDir, pBuffer, BufferSize); GetPath(Type, pDir, pBuffer, BufferSize);
} }
static IStorage *Create(const char *pApplicationName, int NumArgs, const char **ppArguments) static IStorage *Create(const char *pApplicationName, int StorageType, int NumArgs, const char **ppArguments)
{ {
CStorage *p = new CStorage(); CStorage *p = new CStorage();
if(p && p->Init(pApplicationName, NumArgs, ppArguments)) if(p && p->Init(pApplicationName, StorageType, NumArgs, ppArguments))
{ {
dbg_msg("storage", "initialisation failed"); dbg_msg("storage", "initialisation failed");
delete p; delete p;
@ -402,4 +405,4 @@ public:
} }
}; };
IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments) { return CStorage::Create(pApplicationName, NumArgs, ppArguments); } IStorage *CreateStorage(const char *pApplicationName, int StorageType, int NumArgs, const char **ppArguments) { return CStorage::Create(pApplicationName, StorageType, NumArgs, ppArguments); }

View file

@ -12,7 +12,11 @@ public:
enum enum
{ {
TYPE_SAVE = 0, TYPE_SAVE = 0,
TYPE_ALL = -1 TYPE_ALL = -1,
STORAGETYPE_BASIC = 0,
STORAGETYPE_SERVER,
STORAGETYPE_CLIENT,
}; };
virtual void ListDirectory(int Type, const char *pPath, FS_LISTDIR_CALLBACK pfnCallback, void *pUser) = 0; virtual void ListDirectory(int Type, const char *pPath, FS_LISTDIR_CALLBACK pfnCallback, void *pUser) = 0;
@ -24,7 +28,7 @@ public:
virtual void GetCompletePath(int Type, const char *pDir, char *pBuffer, unsigned BufferSize) = 0; virtual void GetCompletePath(int Type, const char *pDir, char *pBuffer, unsigned BufferSize) = 0;
}; };
extern IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments); extern IStorage *CreateStorage(const char *pApplicationName, int StorageType, int NumArgs, const char **ppArguments);
#endif #endif

View file

@ -331,7 +331,7 @@ int main(int argc, const char **argv) // ignore_convention
mem_copy(m_CountDataLegacy.m_Header, SERVERBROWSE_COUNT_LEGACY, sizeof(SERVERBROWSE_COUNT_LEGACY)); mem_copy(m_CountDataLegacy.m_Header, SERVERBROWSE_COUNT_LEGACY, sizeof(SERVERBROWSE_COUNT_LEGACY));
IKernel *pKernel = IKernel::Create(); IKernel *pKernel = IKernel::Create();
IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); IStorage *pStorage = CreateStorage("Teeworlds", IStorage::STORAGETYPE_BASIC, argc, argv);
IConfig *pConfig = CreateConfig(); IConfig *pConfig = CreateConfig();
m_pConsole = CreateConsole(CFGFLAG_MASTER); m_pConsole = CreateConsole(CFGFLAG_MASTER);

View file

@ -6,7 +6,7 @@
int main(int argc, const char **argv) int main(int argc, const char **argv)
{ {
IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); IStorage *pStorage = CreateStorage("Teeworlds", IStorage::STORAGETYPE_BASIC, argc, argv);
int Index, ID = 0, Type = 0, Size; int Index, ID = 0, Type = 0, Size;
void *pPtr; void *pPtr;
char aFileName[1024]; char aFileName[1024];
@ -16,7 +16,7 @@ int main(int argc, const char **argv)
if(!pStorage || argc != 3) if(!pStorage || argc != 3)
return -1; return -1;
str_format(aFileName, sizeof(aFileName), "maps/%s", argv[2]); str_format(aFileName, sizeof(aFileName), "%s", argv[2]);
if(!DataFile.Open(pStorage, argv[1], IStorage::TYPE_ALL)) if(!DataFile.Open(pStorage, argv[1], IStorage::TYPE_ALL))
return -1; return -1;

View file

@ -44,7 +44,7 @@ int MaplistCallback(const char *pName, int IsDir, int DirType, void *pUser)
int main(int argc, const char **argv) // ignore_convention int main(int argc, const char **argv) // ignore_convention
{ {
IKernel *pKernel = IKernel::Create(); IKernel *pKernel = IKernel::Create();
s_pStorage = CreateStorage("Teeworlds", argc, argv); s_pStorage = CreateStorage("Teeworlds", IStorage::STORAGETYPE_BASIC, argc, argv);
s_pEngineMap = CreateEngineMap(); s_pEngineMap = CreateEngineMap();
bool RegisterFail = !pKernel->RegisterInterface(s_pStorage); bool RegisterFail = !pKernel->RegisterInterface(s_pStorage);