unCORr likes PChar arrays
authorsheepluva
Thu, 16 Jan 2014 22:38:43 +0100
changeset 9996 d93fb04619ee
parent 9995 8bf092ddc536
child 9997 879fc2f86c36
unCORr likes PChar arrays
hedgewars/CMakeLists.txt
hedgewars/config.inc.in
hedgewars/uPhysFSLayer.pas
--- a/hedgewars/CMakeLists.txt	Thu Jan 16 23:47:36 2014 +0400
+++ b/hedgewars/CMakeLists.txt	Thu Jan 16 22:38:43 2014 +0100
@@ -20,6 +20,14 @@
     endif()
 endif(UNIX)
 
+# convert list into pascal array
+list(LENGTH FONTS_DIRS ndirs)
+set(FONTS_DIRS_ARRAY "array [0..${ndirs}] of PChar = (")
+foreach(fontdir ${FONTS_DIRS})
+    set(FONTS_DIRS_ARRAY "${FONTS_DIRS_ARRAY}\n'${fontdir}',")
+endforeach(fontdir)
+set(FONTS_DIRS_ARRAY "${FONTS_DIRS_ARRAY}\nnil);\n")
+
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
--- a/hedgewars/config.inc.in	Thu Jan 16 23:47:36 2014 +0400
+++ b/hedgewars/config.inc.in	Thu Jan 16 22:38:43 2014 +0100
@@ -26,4 +26,4 @@
       cRevisionString = '${HEDGEWARS_REVISION}';
       cHashString = '${HEDGEWARS_HASH}';
       cDefaultPathPrefix = '${HEDGEWARS_FULL_DATADIR}/Data';
-      cFontsPaths = '${FONTS_DIRS}';
+      cFontsPaths: ${FONTS_DIRS_ARRAY}
--- a/hedgewars/uPhysFSLayer.pas	Thu Jan 16 23:47:36 2014 +0400
+++ b/hedgewars/uPhysFSLayer.pas	Thu Jan 16 22:38:43 2014 +0100
@@ -146,7 +146,7 @@
 procedure initModule;
 var i: LongInt;
     cPhysfsId: shortstring;
-    fp: AnsiString;
+    fp: PChar;
 begin
 {$IFDEF HWLIBRARY}
     //TODO: http://icculus.org/pipermail/physfs/2011-August/001006.html
@@ -159,22 +159,11 @@
     AddFileLog('[PhysFS] init: ' + inttostr(i));
 
     // mount system fonts paths first
-    fp := cFontsPaths;
-
-    // let's remove paths from fp and mount them until nothing is left
-    while length(fp) > 0 do
+    for i:= low(cFontsPaths) to high(cFontsPaths) do
         begin
-        AddFileLog('lol');
-        // search for ;
-        i := pos(';', fp);
-        // if there is no ; left, read to end
-        if i < 1 then
-            i := length(fp) + 1;
-        // don't mount empty path
-        if i > 2 then
-            pfsMount(copy(fp, 1, i-1), '/Fonts');
-        // remove mounted path from fp
-        fp := copy(fp, i+1, length(fp)-i);
+            fp := cFontsPaths[i];
+            if fp <> nil then
+                pfsMount(fp, '/Fonts');
         end;
 
     pfsMountAtRoot(PathPrefix);