diff options
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/cbottoken.h | 5 | ||||
-rw-r--r-- | src/script/cmdtoken.h | 6 | ||||
-rw-r--r-- | src/script/script.cpp | 40 | ||||
-rw-r--r-- | src/script/script.h | 10 |
4 files changed, 37 insertions, 24 deletions
diff --git a/src/script/cbottoken.h b/src/script/cbottoken.h index 1f2d6e7..f5b7b70 100644 --- a/src/script/cbottoken.h +++ b/src/script/cbottoken.h @@ -14,7 +14,10 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// cbottoken.h +/** + * \file script/cbottoken.h + * \brief Functions to parse some CBot-related tokens + */ #pragma once diff --git a/src/script/cmdtoken.h b/src/script/cmdtoken.h index 812cec7..fe831f1 100644 --- a/src/script/cmdtoken.h +++ b/src/script/cmdtoken.h @@ -14,10 +14,14 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// cmdtoken.h +/** + * \file script/cmdtoken.h + * \brief Functions to parse commands from level files + */ #pragma once + #include "graphics/engine/water.h" #include "graphics/engine/engine.h" #include "graphics/engine/pyro.h" diff --git a/src/script/script.cpp b/src/script/script.cpp index 2d76ad3..8471df5 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -14,24 +14,30 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// script.cpp - #include "script/script.h" +#include "app/app.h" + #include "common/global.h" #include "common/iman.h" #include "common/restext.h" + #include "graphics/engine/terrain.h" #include "graphics/engine/water.h" #include "graphics/engine/text.h" + #include "math/geometry.h" #include "math/vector.h" + #include "object/object.h" #include "object/robotmain.h" #include "object/task/taskmanager.h" + #include "physics/physics.h" + #include "script/cbottoken.h" + #include "ui/interface.h" #include "ui/edit.h" #include "ui/list.h" @@ -3646,20 +3652,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 +3686,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; } diff --git a/src/script/script.h b/src/script/script.h index 5c1118f..dbd66a2 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -14,16 +14,20 @@ // * You should have received a copy of the GNU General Public License // * along with this program. If not, see http://www.gnu.org/licenses/. -// script.h +/** + * \file script/script.h + * \brief CBot script runner + */ #pragma once -#include <stdio.h> - #include "common/event.h" + #include "CBot/CBotDll.h" +#include <stdio.h> + class CInstanceManager; class CObject; |