summaryrefslogtreecommitdiffstats
path: root/src/script/script.cpp
diff options
context:
space:
mode:
authorZaba999 <qrwfw5rp>2012-10-11 23:09:29 +0200
committerZaba999 <qrwfw5rp>2012-10-11 23:09:29 +0200
commit8a932fed3e5700af283017deab3cb1da11cb0dce (patch)
tree892d7a4068c843cb41bd202f078b042027a0a3d0 /src/script/script.cpp
parent3f7f013168e62693601ab57108d329ffaa924439 (diff)
downloadcolobot-8a932fed3e5700af283017deab3cb1da11cb0dce.tar.gz
colobot-8a932fed3e5700af283017deab3cb1da11cb0dce.tar.bz2
colobot-8a932fed3e5700af283017deab3cb1da11cb0dce.zip
Added saving user scripts on game save. Fixed bug in writing script to file.
Diffstat (limited to 'src/script/script.cpp')
-rw-r--r--src/script/script.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 2d76ad3..4df7a51 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -3646,20 +3646,18 @@ bool CScript::ReadScript(const char* filename)
{
FILE* file;
Ui::CEdit* edit;
+ std::string name;
- // TODO: local user dir
- std::string name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
-
- /*if ( strchr(filename, '\\') == 0 )
+ if ( strchr(filename, '/') == 0 ) //we're reading non user script
{
- strcpy(name, "script\\");
- strcat(name, filename);
+ name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
}
else
{
-//? strcpy(name, filename);
- UserDir(name, filename, "");
- }*/
+ name = filename;
+ //TODO: is this needed?
+ // UserDir(name, filename, "");
+ }
file = fopen(name.c_str(), "rb");
if ( file == NULL ) return false;
@@ -3682,22 +3680,20 @@ bool CScript::ReadScript(const char* filename)
bool CScript::WriteScript(const char* filename)
{
Ui::CEdit* edit;
+ std::string name;
- std::string name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
- // TODO: local user dir
- /*if ( strchr(filename, '\\') == 0 )
+ if ( strchr(filename, '/') == 0 ) //we're writing non user script
{
- strcpy(name, "script\\");
- strcat(name, filename);
+ name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
}
else
{
- strcpy(name, filename);
- }*/
+ name = filename;
+ }
if ( m_script == 0 )
{
- // TODO: ? remove(filename);
+ remove(filename);
return false;
}