about summary refs log tree commit diff
path: root/src/engine/shared/storage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/shared/storage.cpp')
-rw-r--r--src/engine/shared/storage.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/engine/shared/storage.cpp b/src/engine/shared/storage.cpp
index 1d0e2f78..6f2399d7 100644
--- a/src/engine/shared/storage.cpp
+++ b/src/engine/shared/storage.cpp
@@ -18,7 +18,7 @@ public:
 		m_aDatadir[0] = 0;
 	}
 	
-	int Init(const char *pApplicationName, const char *pArgv0)
+	int Init(const char *pApplicationName, int NumArgs, const char **ppArguments)
 	{
 		char aPath[1024] = {0};
 		fs_storage_path(pApplicationName, m_aApplicationSavePath, sizeof(m_aApplicationSavePath));
@@ -39,8 +39,18 @@ public:
 			str_format(aPath, sizeof(aPath), "%s/demos", m_aApplicationSavePath);
 			fs_makedir(aPath);
 		}
+
+		// check for datadir override
+		for(int i = 1; i < NumArgs; i++)
+		{
+			if(ppArguments[i][0] == '-' && ppArguments[i][1] == 'd' && ppArguments[i][2] == 0 && NumArgs - i > 1)
+			{
+				str_copy(m_aDatadir, ppArguments[i+1], sizeof(m_aDatadir));
+				break;
+			}
+		}
 		
-		return FindDatadir(pArgv0);
+		return FindDatadir(ppArguments[0]);
 	}
 		
 	int FindDatadir(const char *pArgv0)
@@ -184,10 +194,10 @@ public:
 		return 0;		
 	}
 
-	static IStorage *Create(const char *pApplicationName, const char *pArgv0)
+	static IStorage *Create(const char *pApplicationName, int NumArgs, const char **ppArguments)
 	{
 		CStorage *p = new CStorage();
-		if(p->Init(pApplicationName, pArgv0))
+		if(p->Init(pApplicationName, NumArgs, ppArguments))
 		{
 			delete p;
 			p = 0;
@@ -196,4 +206,4 @@ public:
 	}
 };
 
-IStorage *CreateStorage(const char *pApplicationName, const char *pArgv0) { return CStorage::Create(pApplicationName, pArgv0); }
+IStorage *CreateStorage(const char *pApplicationName, int NumArgs, const char **ppArguments) { return CStorage::Create(pApplicationName, NumArgs, ppArguments); }