Engine/Frontend:
* Changed the Lua file loading to take paths relative to the data dir instead of absolute paths to ensure demo/savegame portability
--- a/QTfrontend/game.cpp Thu Sep 30 11:50:32 2010 -0400
+++ b/QTfrontend/game.cpp Thu Sep 30 18:38:45 2010 +0200
@@ -357,7 +357,7 @@
void HWGame::StartTraining(const QString & file)
{
gameType = gtTraining;
- training = datadir->absolutePath() + "/Missions/Training/" + file + ".lua";
+ training = "Missions/Training/" + file + ".lua";
demo.clear();
Start();
SetGameState(gsStarted);
@@ -366,7 +366,7 @@
void HWGame::StartCampaign(const QString & file)
{
gameType = gtCampaign;
- campaign = datadir->absolutePath() + "/Missions/Campaign/" + file + ".lua";
+ campaign = "Missions/Campaign/" + file + ".lua";
demo.clear();
Start();
SetGameState(gsStarted);
--- a/QTfrontend/gamecfgwidget.cpp Thu Sep 30 11:50:32 2010 -0400
+++ b/QTfrontend/gamecfgwidget.cpp Thu Sep 30 18:38:45 2010 +0200
@@ -167,8 +167,7 @@
{
sl.append("emap " + currentMap);
if(pMapContainer->getCurrentIsMission())
- sl.append(QString("escript %1/Maps/%2/map.lua")
- .arg(datadir->absolutePath())
+ sl.append(QString("escript Maps/%1/map.lua")
.arg(currentMap));
}
sl.append("etheme " + pMapContainer->getCurrentTheme());
--- a/hedgewars/uScript.pas Thu Sep 30 11:50:32 2010 -0400
+++ b/hedgewars/uScript.pas Thu Sep 30 18:38:45 2010 +0200
@@ -875,7 +875,7 @@
procedure ScriptLoad(name : shortstring);
var ret : LongInt;
begin
-ret:= luaL_loadfile(luaState, Str2PChar(name));
+ret:= luaL_loadfile(luaState, Str2PChar(Pathz[ptData] + '/' + name));
if ret <> 0 then
begin
LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');