File: ObjCScript.h

package info (click to toggle)
descent3 1.5.0%2Bds-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 35,256 kB
  • sloc: cpp: 416,147; ansic: 3,233; sh: 10; makefile: 8
file content (197 lines) | stat: -rw-r--r-- 5,574 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.

--- HISTORICAL COMMENTS FOLLOW ---

 * $Logfile: /DescentIII/Main/editor/ObjCScript.h $
 * $Revision: 1.1.1.1 $
 * $Date: 2003-08-26 03:57:38 $
 * $Author: kevinb $
 *
 * Osiris Script loader for editor
 *
 * $Log: not supported by cvs2svn $
 *
 * 19    6/23/98 3:04p Samir
 * sped up script list generation.
 *
 * 18    5/04/98 3:22p Samir
 * ability to select which scripts you want to generate scriptwiz info
 * for.
 *
 * 17    2/25/98 4:06p Samir
 * Added function to generate a table of all scripts on disk.
 *
 * 16    1/22/98 6:22p Samir
 * Parse script parameters now.
 *
 * 15    9/25/97 5:28p Samir
 * Even newer script code due to more changes in ObjCScript.cpp
 *
 * 14    9/24/97 2:57p Samir
 * New ScriptWizard functionality, without extra commenting in files.
 *
 * 13    9/22/97 5:59p Samir
 * Changed ObjCScript system, so everything is broken, but it shouldn't
 * crash the game.
 *
 * 12    9/12/97 4:15p Samir
 * Upped number of mappable events.
 *
 * 11    9/10/97 2:00p Samir
 * Changed prototype of AddScriptBlock
 *
 * 10    9/09/97 1:04p Samir
 * Added code to create new script and save level script name.
 *
 * 9     9/08/97 4:29p Samir
 * Added EVT_DESTROYED support to editing code.
 *
 * 8     8/21/97 6:00p Samir
 * A whole lot of script editing stuff added for ScriptWizard.
 *
 * 7     8/18/97 12:14p Samir
 * Added function to get the index of a script name in the script list.
 *
 * 6     8/15/97 6:32p Samir
 * Use a more generic editor script interface instead of specifying
 * default scripts, etc.
 *
 * 5     8/13/97 5:39p Samir
 * Use CompileScript to compile a script now, and we compile default
 * script at startup of editor.
 *
 * 4     8/06/97 10:40a Samir
 * Added FreeLevelScript.
 *
 * 3     8/04/97 4:17p Samir
 * Added externals for scripts in editor.
 *
 * $NoKeywords: $
 */

#ifndef OBJCSCRIPT_H
#define OBJCSCRIPT_H

#include "pstypes.h"
#include "objscript.h"

#define MAX_SCRIPTS 256
#define MAX_SCRNAME 32
#define MAX_EVTNAME 32
#define MAX_SCRFILENAME 64
#define DEFAULT_SCRIPT_NAME "default.scr"
#define LEVEL_SCRIPT_NAME "level.scr"

#define DEFAULT_SCRIPT_MASK 0x01
#define CUSTOM_SCRIPT_MASK 0x02
#define ALL_SCRIPT_MASK 0xff

struct tD3XProgram;

#define MAX_SCRPARAMS 256 // icecoldduke fix - getting to compile, not correct.

//	Data structure for a default script name.
// There exists a list of these names too.
struct tScriptName {
  // script info.
  char name[MAX_SCRNAME];
  uint16_t type;
  uint16_t line;
  bool iscustom;
  bool used;

  //	parameters
  int nparms;
  char *paramtypes[MAX_SCRPARAMS];
  char *parameters[MAX_SCRPARAMS];

  tScriptName() {
    for (int i = 0; i < MAX_SCRPARAMS; i++) {
      parameters[i] = NULL;
      paramtypes[i] = NULL;
    }
    used = false;
    nparms = 0;
  }
  ~tScriptName() {
    free_parameters();
    used = false;
  };

  void add_parameter(const char *type, const char *parm);
  void free_parameters();
};

//	per level script.
extern char Level_script_name[];

// Currently loaded script file
extern char *Default_script_source;
extern char *Level_script_source;

// Table of scripts within script file
extern tScriptName Script_names[];

// Script event names
extern char *Script_evt_names[];
extern uint16_t Script_evt_ids[];

bool NewScript(const char *filename);
char *LoadScript(const char *filename);
void SaveScript(const char *filename, char *script);
void FreeScript(char *script);

// resets script list.
void ResetScriptList();

//	enumerates through script files.
char *StartScriptFileList();
char *GetNextScriptFile();
void EndScriptFileList();

// identify indices into script names array from the name.
int FindScriptIDFromName(const char *name);

//	find event id from it's name or vice-versa
char *FindEventNameFromID(int id);
int FindEventIDFromName(const char *name);

//	these functions add ScriptWizard formatting
char *AddScriptBlockToScript(char *script, const char *newname, const char *type_str);
char *AddEventBlockToScript(char *script, const char *evtname, const char *scriptname);

//	generates script list from all script files.
void GenerateScriptListFromAllFiles(int mask = ALL_SCRIPT_MASK);

//	generates script list from one file
void GenerateScriptListFromFile(const char *fname);

//	This function generates ScriptWizard comment header information for script files
//	if it doesn't already have it.  This should be called whenever a script file is loaded and compiled
//	via script wizard.
bool GenerateScriptWizardInfo(tD3XProgram *prog, bool custom);

//	This function actually tries to go throught the script source to find script names.
//	to find a script name we use the following algorithmn
bool GenerateScriptWizardInfo(char *script, bool custom);

//	Generates a program from a script
bool CompileScript(tD3XProgram *program, char *script);
void SaveScriptCode(const char *filename, tD3XProgram *program);

#endif