Skyscraper 2.0
scriptproc.h
Go to the documentation of this file.
1/*
2 Skyscraper 2.0 Alpha - Script Processor
3 Copyright (C)2004-2024 Ryan Thoryk
4 https://www.skyscrapersim.net
5 https://sourceforge.net/projects/skyscraper/
6 Contact - ryan@skyscrapersim.net
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21*/
22
23#ifndef SCRIPTPROCESSOR_H
24#define SCRIPTPROCESSOR_H
25
26#include "vm.h"
27
28namespace Skyscraper {
29
31{
32public:
33
34 //sub-classes
35 class Section;
36 class ConfigHandler;
37 class GlobalsSection;
38 class BuildingsSection;
39 class TexturesSection;
40 class CommandsSection;
41 class FloorSection;
42 class ElevatorSection;
44 class VehicleSection;
47
50 bool Run();
51 bool LoadDataFile(const std::string &filename, bool insert = false, int insert_line = 0);
52 bool LoadFromText(const std::string &text);
53 void LoadDefaults();
54 void Start();
56 void Reset();
57 std::vector<std::string> *GetBuildingData();
58 bool IsFunctionDefined(const std::string &name);
59 std::string DumpState();
60 EngineContext* GetEngine();
61 ElevatorCarSection* GetElevatorCarSection();
62 ConfigHandler* GetConfigHandler();
63 bool HasRunloop();
64 bool InRunloop() {return in_runloop;}
65
67
68 //return codes
69 static const int sContinue = 0;
70 static const int sNextLine = 1;
71 static const int sError = 2;
72 static const int sCheckFloors = 3;
73 static const int sBreak = 4;
74 static const int sRecalc = 5;
75 static const int sSkipReset = 6;
76 static const int sExit = 7;
77 static const int sLoopFor = 8;
78
80 {
81 std::string name;
82 std::string value;
83 };
84
85 std::vector<VariableMap> variables; //named user variables
86 std::vector<std::string> nonexistent_files; //missing files list
87
89 int line; //line number
90 std::string LineData; //line text
91 bool NoModels; //if true, disable models for DirectX11 support
92
93private:
94
97
109
111 {
112 std::string Name;
114 std::string LineData;
115 std::vector<std::string> Params;
116 };
117
120 std::vector<std::string> BuildingData;
121 std::vector<std::string> BuildingDataOrig;
123 std::vector<FunctionData> FunctionStack;
125 std::string ReplaceLineData;
131
132 int ScriptError(std::string message, bool warning = false);
133 int ScriptError();
134 int ScriptWarning(std::string message);
135 std::string Calc(const std::string &expression);
136 void StoreCommand(::SBS::Object *object);
137 bool FunctionProc();
138 void CheckFile(const std::string &filename);
139 void GetLineInformation(bool CheckFunctionCall, int &LineNumber, std::string &FunctionName, int &FunctionLine, bool &IsInclude, std::string &IncludeFile, bool &IsIncludeFunction, std::string &IncludeFunctionFile);
140 bool ProcessFunctionParameters();
141 void ProcessUserVariables();
142 int ProcessSections();
143 int ProcessFloorObjects();
144 void Breakpoint();
145 void ProcessExtents();
146 int ProcessForLoops();
147 void ProcessRunloop();
148
150 {
151 std::string name;
152 int line;
153 };
154
155 std::vector<FunctionInfo> functions; //stored functions
156
158 {
159 std::string filename;
163 };
164
165 struct ForInfo
166 {
167 std::string iterator;
168 int line;
169 int i;
170 int start;
171 int end;
172 };
173
174 std::vector<IncludeInfo> includes; //stored include mappings
175 std::vector<ForInfo> ForLoops;
176};
177
178}
179
180#endif
VehicleSection * vehicle_section
Definition scriptproc.h:106
std::vector< FunctionInfo > functions
Definition scriptproc.h:155
std::vector< std::string > nonexistent_files
Definition scriptproc.h:86
std::vector< IncludeInfo > includes
Definition scriptproc.h:174
std::vector< ForInfo > ForLoops
Definition scriptproc.h:175
std::vector< VariableMap > variables
Definition scriptproc.h:85
ControllerSection * controller_section
Definition scriptproc.h:107
std::vector< FunctionData > FunctionStack
Definition scriptproc.h:123
std::vector< std::string > BuildingDataOrig
Definition scriptproc.h:121
GlobalsSection * globals_section
Definition scriptproc.h:99
BuildingsSection * buildings_section
Definition scriptproc.h:100
CallStationSection * callstation_section
Definition scriptproc.h:108
FloorSection * floor_section
Definition scriptproc.h:103
CommandsSection * commands_section
Definition scriptproc.h:102
ElevatorSection * elevator_section
Definition scriptproc.h:104
TexturesSection * textures_section
Definition scriptproc.h:101
ElevatorCarSection * elevatorcar_section
Definition scriptproc.h:105
std::vector< std::string > BuildingData
Definition scriptproc.h:120
std::vector< std::string > Params
Definition scriptproc.h:115
#define VMIMPEXP
Definition vm.h:49