From 5c523995bb81fdaa82038ccc0507e828ef8e52b3 Mon Sep 17 00:00:00 2001 From: nkorslund Date: Mon, 1 Jun 2009 13:49:29 +0000 Subject: [PATCH] minor fix for the last commit git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@118 ea6a568a-9f4f-0410-981a-c910a81bb256 --- terrain/terrain.d | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/terrain/terrain.d b/terrain/terrain.d index 6e366b7bbd..ad4d5126c1 100644 --- a/terrain/terrain.d +++ b/terrain/terrain.d @@ -23,15 +23,49 @@ module terrain.terrain; -import terrain.generator; +import std.stdio; +import std.file; +import monster.util.string; + +char[] cacheDir = "cache/terrain/"; void initTerrain(bool doGen) { if(doGen) - generate(); + terr_genData(); terr_setupRendering(); } +// Move elsewhere, make part of the general cache system later +void makeDir(char[] pt) +{ + if(exists(pt)) + { + if(!isdir(pt)) + fail(pt ~ " is not a directory"); + } + else + mkdir(pt); +} + +void fail(char[] msg) +{ + throw new Exception(msg); +} + +void makePath(char[] pt) +{ + assert(!pt.begins("/")); + foreach(int i, char c; pt) + if(c == '/') + makeDir(pt[0..i]); + + if(!pt.ends("/")) + makeDir(pt); +} + extern(C): +void terr_setCacheDir(char *dir); +void terr_genData(); void terr_setupRendering();