summaryrefslogtreecommitdiff
path: root/src/map/script.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.h')
-rw-r--r--src/map/script.h61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/map/script.h b/src/map/script.h
index a1fbe31f0..61c6a4583 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -394,11 +394,20 @@ struct script_data {
struct reg_db *ref; ///< Reference to the scope's variables
};
+/**
+ * A script string buffer, used to hold strings used by the script engine.
+ */
+VECTOR_STRUCT_DECL(script_string_buf, char);
+
+/**
+ * Script buffer, used to hold parsed script data.
+ */
+VECTOR_STRUCT_DECL(script_buf, unsigned char);
+
// Moved defsp from script_state to script_stack since
// it must be saved when script state is RERUNLINE. [Eoe / jA 1094]
struct script_code {
- int script_size;
- unsigned char *script_buf;
+ struct script_buf script_buf;
struct reg_db local; ///< Local (npc) vars
unsigned short instances;
};
@@ -493,8 +502,8 @@ struct script_syntax_data {
int index; // Number of the syntax used in the script
int last_func; // buildin index of the last parsed function
unsigned int nested_call; //Dont really know what to call this
- bool lang_macro_active;
- struct DBMap *strings; // string map parsed (used when exporting strings only)
+ bool lang_macro_active; // Used to generate translation strings
+ bool lang_macro_fmtstring_active; // Used to generate translation strings
struct DBMap *translation_db; //non-null if this npc has any translated strings to be linked
};
@@ -517,16 +526,16 @@ struct script_array {
unsigned int *members;/* member list */
};
-struct script_string_buf {
- char *ptr;
- size_t pos,size;
+struct string_translation_entry {
+ uint8 lang_id;
+ char string[];
};
struct string_translation {
int string_id;
uint8 translations;
- unsigned int len;
- char *buf;
+ int len;
+ uint8 *buf; // Array of struct string_translation_entry
};
/**
@@ -576,8 +585,7 @@ struct script_interface {
/* */
/// temporary buffer for passing around compiled bytecode
/// @see add_scriptb, set_label, parse_script
- unsigned char* buf;
- int pos, size;
+ struct script_buf buf;
/* */
struct script_syntax_data syntax;
/* */
@@ -611,26 +619,22 @@ struct script_interface {
/* */
unsigned int *generic_ui_array;
unsigned int generic_ui_array_size;
- /* Set during startup when attempting to export the lang, unset after server initialization is over */
- FILE *lang_export_fp;
- char *lang_export_file;/* for lang_export_fp */
/* set and unset on npc_parse_script */
const char *parser_current_npc_name;
/* */
int buildin_mes_offset;
+ int buildin_mesf_offset;
int buildin_select_offset;
int buildin_lang_macro_offset;
+ int buildin_lang_macro_fmtstring_offset;
/* */
struct DBMap *translation_db;/* npc_name => DBMap (strings) */
- char **translation_buf;/* */
- uint32 translation_buf_size;
+ VECTOR_DECL(uint8 *) translation_buf;
/* */
char **languages;
uint8 max_lang_id;
/* */
- struct script_string_buf parse_simpleexpr_str;
- struct script_string_buf lang_export_line_buf;
- struct script_string_buf lang_export_unescaped_buf;
+ struct script_string_buf parse_simpleexpr_strbuf;
/* */
int parse_cleanup_timer_id;
/* */
@@ -706,8 +710,8 @@ struct script_interface {
const char * (*parse_syntax_close) (const char *p);
const char * (*parse_syntax_close_sub) (const char *p, int *flag);
const char * (*parse_syntax) (const char *p);
- c_op (*get_com) (unsigned char *scriptbuf, int *pos);
- int (*get_num) (unsigned char *scriptbuf, int *pos);
+ c_op (*get_com) (const struct script_buf *scriptbuf, int *pos);
+ int (*get_num) (const struct script_buf *scriptbuf, int *pos);
const char* (*op2name) (int op);
void (*reportsrc) (struct script_state *st);
void (*reportdata) (struct script_data *data);
@@ -724,10 +728,15 @@ struct script_interface {
int (*add_word) (const char *p);
const char* (*parse_callfunc) (const char *p, int require_paren, int is_custom);
void (*parse_nextline) (bool first, const char *p);
- const char* (*parse_variable) (const char *p);
- const char* (*parse_simpleexpr) (const char *p);
- const char* (*parse_expr) (const char *p);
- const char* (*parse_line) (const char *p);
+ const char *(*parse_variable) (const char *p);
+ const char *(*parse_simpleexpr) (const char *p);
+ const char *(*parse_simpleexpr_paren) (const char *p);
+ const char *(*parse_simpleexpr_number) (const char *p);
+ const char *(*parse_simpleexpr_string) (const char *p);
+ const char *(*parse_simpleexpr_name) (const char *p);
+ void (*add_translatable_string) (const struct script_string_buf *string, const char *start_point);
+ const char *(*parse_expr) (const char *p);
+ const char *(*parse_line) (const char *p);
void (*read_constdb) (void);
void (*constdb_comment) (const char *comment);
void (*load_parameters) (void);
@@ -807,7 +816,7 @@ struct script_interface {
unsigned short (*mapindexname2id) (struct script_state *st, const char* name);
int (*string_dup) (char *str);
void (*load_translations) (void);
- void (*load_translation) (const char *file, uint8 lang_id, uint32 *total);
+ int (*load_translation) (const char *file, uint8 lang_id);
int (*translation_db_destroyer) (union DBKey key, struct DBData *data, va_list ap);
void (*clear_translations) (bool reload);
int (*parse_cleanup_timer) (int tid, int64 tick, int id, intptr_t data);