Start work on physfs support in engine physfslayer
authorunc0rr
Mon, 05 Nov 2012 23:03:32 +0400
branchphysfslayer
changeset 7959 644b757d20e6
parent 7955 85b3970b402a
child 7963 9910f303f5b6
Start work on physfs support in engine
hedgewars/CMakeLists.txt
hedgewars/hwengine.pas
hedgewars/uPhysFSLayer.pas
--- a/hedgewars/CMakeLists.txt	Mon Nov 05 23:03:01 2012 +0400
+++ b/hedgewars/CMakeLists.txt	Mon Nov 05 23:03:32 2012 +0400
@@ -54,6 +54,7 @@
     uLocale.pas
     uMisc.pas
     uMobile.pas
+    uPhysFSLayer.pas
     uRandom.pas
     uRender.pas
     uRenderUtils.pas
@@ -99,6 +100,9 @@
     endif (APPLE)
 endif(BUILD_ENGINE_LIBRARY)
 
+# doesn't work for some reason (doesn't find symbols)
+#set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a" ${pascal_flags})
+
 IF(FPC)
     set(fpc_executable ${FPC})
 ELSE()
--- a/hedgewars/hwengine.pas	Mon Nov 05 23:03:01 2012 +0400
+++ b/hedgewars/hwengine.pas	Mon Nov 05 23:03:32 2012 +0400
@@ -29,9 +29,10 @@
 program hwengine;
 {$ENDIF}
 
-uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uInputHandler,
-     uSound, uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uAILandMarks, uLandTexture, uCollisions,
-     SysUtils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted
+uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uInputHandler
+     , uSound, uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uAILandMarks, uLandTexture, uCollisions
+     , SysUtils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted
+     , uPhysFSLayer
      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF}
      {$IFDEF USE_TOUCH_INTERFACE}, uTouch {$ENDIF}
      {$IFDEF ANDROID}, GLUnit{$ENDIF}
@@ -459,6 +460,7 @@
 
     if complete then
     begin
+        uPhysFSLayer.initModule;
 {$IFDEF ANDROID}GLUnit.initModule;{$ENDIF}
 {$IFDEF USE_TOUCH_INTERFACE}uTouch.initModule;{$ENDIF}
 {$IFDEF USE_VIDEO_RECORDING}uVideoRec.initModule;{$ENDIF}   //stub
@@ -510,6 +512,7 @@
 {$IFDEF USE_VIDEO_RECORDING}uVideoRec.freeModule;{$ENDIF}
 {$IFDEF USE_TOUCH_INTERFACE}uTouch.freeModule;{$ENDIF}  //stub
 {$IFDEF ANDROID}GLUnit.freeModule;{$ENDIF}
+        uPhysFSLayer.freeModule;
     end;
 
     uIO.freeModule;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/uPhysFSLayer.pas	Mon Nov 05 23:03:32 2012 +0400
@@ -0,0 +1,28 @@
+unit uPhysFSLayer;
+
+{$LINKLIB ../bin/libphysfs.a}
+
+interface
+
+procedure initModule;
+procedure freeModule;
+
+implementation
+uses uUtils;
+
+function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external;
+function PHYSFS_deinit() : LongInt; cdecl; external;
+
+function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool); cdecl; external;
+
+procedure initModule;
+begin
+    PHYSFS_init(Str2PChar(ParamStr(0)));
+end;
+
+procedure freeModule;
+begin
+    PHYSFS_deinit;
+end;
+
+end.