Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
scriptfunc.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
25 #pragma once
26 
27 #include "common/global.h"
28 
29 #include "CBot/CBotDll.h"
30 
31 #include <string>
32 #include <unordered_map>
33 
34 class CObject;
35 class CScript;
36 
37 
39 {
40 public:
41  static void Init();
42 
43 private:
44  static CBotTypResult cNull(CBotVar* &var, void* user);
45  static CBotTypResult cOneFloat(CBotVar* &var, void* user);
46  static CBotTypResult cTwoFloat(CBotVar* &var, void* user);
47  static CBotTypResult cString(CBotVar* &var, void* user);
48  static CBotTypResult cStringString(CBotVar* &var, void* user);
49  static CBotTypResult cEndMission(CBotVar* &var, void* user);
50  static CBotTypResult cPlayMusic(CBotVar* &var, void* user);
51  static CBotTypResult cGetObject(CBotVar* &var, void* user);
52  static CBotTypResult cDelete(CBotVar* &var, void* user);
53  static CBotTypResult cSearch(CBotVar* &var, void* user);
54  static CBotTypResult cRadar(CBotVar* &var, void* user);
55  static CBotTypResult cDetect(CBotVar* &var, void* user);
56  static CBotTypResult cDirection(CBotVar* &var, void* user);
57  static CBotTypResult cCanBuild(CBotVar* &var, void* user);
58  static CBotTypResult cProduce(CBotVar* &var, void* user);
59  static CBotTypResult cDistance(CBotVar* &var, void* user);
60  static CBotTypResult cSpace(CBotVar* &var, void* user);
61  static CBotTypResult cFlatGround(CBotVar* &var, void* user);
62  static CBotTypResult cGoto(CBotVar* &var, void* user);
63  static CBotTypResult cGrabDrop(CBotVar* &var, void* user);
64  static CBotTypResult cReceive(CBotVar* &var, void* user);
65  static CBotTypResult cSend(CBotVar* &var, void* user);
66  static CBotTypResult cDeleteInfo(CBotVar* &var, void* user);
67  static CBotTypResult cTestInfo(CBotVar* &var, void* user);
68  static CBotTypResult cShield(CBotVar* &var, void* user);
69  static CBotTypResult cFire(CBotVar* &var, void* user);
70  static CBotTypResult cAim(CBotVar* &var, void* user);
71  static CBotTypResult cMotor(CBotVar* &var, void* user);
72  static CBotTypResult cTopo(CBotVar* &var, void* user);
73  static CBotTypResult cMessage(CBotVar* &var, void* user);
74  static CBotTypResult cPenDown(CBotVar* &var, void* user);
75  static CBotTypResult cOnePoint(CBotVar* &var, void* user);
76  static CBotTypResult cPoint(CBotVar* &var, void* user);
77  static CBotTypResult cOneObject(CBotVar* &var, void* user);
78 
79 
80  static bool rSin(CBotVar* var, CBotVar* result, int& exception, void* user);
81  static bool rCos(CBotVar* var, CBotVar* result, int& exception, void* user);
82  static bool rTan(CBotVar* var, CBotVar* result, int& exception, void* user);
83  static bool rSqrt(CBotVar* var, CBotVar* result, int& exception, void* user);
84  static bool rPow(CBotVar* var, CBotVar* result, int& exception, void* user);
85  static bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user);
86  static bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user);
87  static bool rFloor(CBotVar* var, CBotVar* result, int& exception, void* user);
88  static bool rCeil(CBotVar* var, CBotVar* result, int& exception, void* user);
89  static bool rRound(CBotVar* var, CBotVar* result, int& exception, void* user);
90  static bool rTrunc(CBotVar* var, CBotVar* result, int& exception, void* user);
91  static bool rEndMission(CBotVar* var, CBotVar* result, int& exception, void* user);
92  static bool rPlayMusic(CBotVar* var, CBotVar* result, int& exception, void* user);
93  static bool rStopMusic(CBotVar* var, CBotVar* result, int& exception, void* user);
94  static bool rGetBuild(CBotVar* var, CBotVar* result, int& exception, void* user);
95  static bool rGetResearchEnable(CBotVar* var, CBotVar* result, int& exception, void* user);
96  static bool rGetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user);
97  static bool rSetBuild(CBotVar* var, CBotVar* result, int& exception, void* user);
98  static bool rSetResearchEnable(CBotVar* var, CBotVar* result, int& exception, void* user);
99  static bool rSetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user);
100  static bool rGetObjectById(CBotVar* var, CBotVar* result, int& exception, void* user);
101  static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user);
102  static bool rProgFunc(CBotVar* var, CBotVar* result, int& exception, void* user);
103  static bool rDelete(CBotVar* var, CBotVar* result, int& exception, void* user);
104  static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user);
105  static bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user);
106  static bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user);
107  static bool rDirection(CBotVar* var, CBotVar* result, int& exception, void* user);
108  static bool rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* user);
109  static bool rBuild(CBotVar* var, CBotVar* result, int& exception, void* user);
110  static bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user);
111  static bool rDistance(CBotVar* var, CBotVar* result, int& exception, void* user);
112  static bool rDistance2d(CBotVar* var, CBotVar* result, int& exception, void* user);
113  static bool rSpace(CBotVar* var, CBotVar* result, int& exception, void* user);
114  static bool rFlatGround(CBotVar* var, CBotVar* result, int& exception, void* user);
115  static bool rWait(CBotVar* var, CBotVar* result, int& exception, void* user);
116  static bool rMove(CBotVar* var, CBotVar* result, int& exception, void* user);
117  static bool rTurn(CBotVar* var, CBotVar* result, int& exception, void* user);
118  static bool rGoto(CBotVar* var, CBotVar* result, int& exception, void* user);
119  static bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user);
120  static bool rGrab(CBotVar* var, CBotVar* result, int& exception, void* user);
121  static bool rDrop(CBotVar* var, CBotVar* result, int& exception, void* user);
122  static bool rSniff(CBotVar* var, CBotVar* result, int& exception, void* user);
123  static bool rReceive(CBotVar* var, CBotVar* result, int& exception, void* user);
124  static bool rSend(CBotVar* var, CBotVar* result, int& exception, void* user);
125  static bool rDeleteInfo(CBotVar* var, CBotVar* result, int& exception, void* user);
126  static bool rTestInfo(CBotVar* var, CBotVar* result, int& exception, void* user);
127  static bool rThump(CBotVar* var, CBotVar* result, int& exception, void* user);
128  static bool rRecycle(CBotVar* var, CBotVar* result, int& exception, void* user);
129  static bool rShield(CBotVar* var, CBotVar* result, int& exception, void* user);
130  static bool rFire(CBotVar* var, CBotVar* result, int& exception, void* user);
131  static bool rAim(CBotVar* var, CBotVar* result, int& exception, void* user);
132  static bool rMotor(CBotVar* var, CBotVar* result, int& exception, void* user);
133  static bool rJet(CBotVar* var, CBotVar* result, int& exception, void* user);
134  static bool rTopo(CBotVar* var, CBotVar* result, int& exception, void* user);
135  static bool rMessage(CBotVar* var, CBotVar* result, int& exception, void* user);
136  static bool rCmdline(CBotVar* var, CBotVar* result, int& exception, void* user);
137  static bool rIsMovie(CBotVar* var, CBotVar* result, int& exception, void* user);
138  static bool rErrMode(CBotVar* var, CBotVar* result, int& exception, void* user);
139  static bool rIPF(CBotVar* var, CBotVar* result, int& exception, void* user);
140  static bool rAbsTime(CBotVar* var, CBotVar* result, int& exception, void* user);
141  static bool rDeleteFile(CBotVar* var, CBotVar* result, int& exception, void* user);
142  static bool rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user);
143  static bool rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user);
144  static bool rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user);
145  static bool rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user);
146  static bool rCameraFocus(CBotVar* var, CBotVar* result, int& exception, void* user);
147 
148 
149  static CBotTypResult cBusy(CBotVar* thisclass, CBotVar* &var);
150  static CBotTypResult cFactory(CBotVar* thisclass, CBotVar* &var);
151  static CBotTypResult cClassNull(CBotVar* thisclass, CBotVar* &var);
152  static CBotTypResult cClassOneFloat(CBotVar* thisclass, CBotVar* &var);
153 
154  static bool rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
155  static bool rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
156  static bool rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
157  static bool rTakeOff(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
158  static bool rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
159 
160 
161  static CBotTypResult cfconstruct (CBotVar* pThis, CBotVar* &pVar);
162  static CBotTypResult cfopen (CBotVar* pThis, CBotVar* &pVar);
163  static CBotTypResult cfclose (CBotVar* pThis, CBotVar* &pVar);
164  static CBotTypResult cfwrite (CBotVar* pThis, CBotVar* &pVar);
165  static CBotTypResult cfread (CBotVar* pThis, CBotVar* &pVar);
166  static CBotTypResult cfeof (CBotVar* pThis, CBotVar* &pVar);
167  static bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception);
168  static bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception);
169  static bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception);
170  static bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception);
171  static bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception);
172  static bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception);
173  static bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception);
174 
175  static CBotTypResult cPointConstructor(CBotVar* pThis, CBotVar* &var);
176  static bool rPointConstructor(CBotVar* pThis, CBotVar* var, CBotVar* pResult, int& Exception);
177 
178 public:
179  static int m_CompteurFileOpen;
180  static std::string m_filesDir;
181 
182 private:
183  static bool Process(CScript* script, CBotVar* result, int &exception);
184  static bool ShouldProcessStop(Error err, int errMode);
185  static CObject* SearchInfo(CScript* script, CObject* object, float power);
186 
187  static std::unordered_map<int, FILE*> m_files;
188  static int m_nextFile;
189 };
Library for interpretation of CBOT language.
Some common, global definitions.
Definition: scriptfunc.h:38
Definition: script.h:58
Error
Type of error or info message.
Definition: global.h:32
CBotTypResult class to define the complete type of a result.
Definition: CBotDll.h:89
Definition: CBotDll.h:561
Definition: object.h:357