From c3aeb496b7016ce85f55da938d1939fa330d1c60 Mon Sep 17 00:00:00 2001 From: Haru Date: Tue, 15 Dec 2015 19:58:38 +0100 Subject: Added const qualifier to the w1~w4 arguments of npc_parse_script Signed-off-by: Haru --- src/map/npc.c | 38 ++++++++++++++++++++++++++++++++------ src/map/npc.h | 2 +- src/map/script.h | 2 +- 3 files changed, 34 insertions(+), 8 deletions(-) (limited to 'src/map') diff --git a/src/map/npc.c b/src/map/npc.c index 1912235b8..0dad88212 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2922,12 +2922,38 @@ const char* npc_skip_script(const char* start, const char* buffer, const char* f return p+1;// return after the last '}' } -/// Parses a npc script. -/// -/// -%TAB%script%TAB%%TAB%-1,{} -/// ,,,%TAB%script%TAB%%TAB%,{} -/// ,,,%TAB%script%TAB%%TAB%,,,{} -const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, int options, int *retval) +/** + * Parses a NPC script. + * + * Example: + * @code + * -script-1,{ + * + * } + * ,,,script,{ + * + * } + * ,,,script,,,{ + * + * } + * @endcode + * + * @param[in] w1 First tab-delimited part of the string to parse. + * @param[in] w2 Second tab-delimited part of the string to parse. + * @param[in] w3 Third tab-delimited part of the string to parse. + * @param[in] w4 Fourth tab-delimited part of the string to parse. + * @param[in] start Pointer to the beginning of the string inside buffer. + * This must point to the same buffer as `buffer`. + * @param[in] buffer Pointer to the buffer containing the script. For + * single-line mapflags not inside a script, this may be + * an empty (but initialized) single-character buffer. + * @param[in] filepath Source file path. + * @param[in] options NPC parse/load options (@see enum npc_parse_options). + * @param[out] retval Pointer to return the success (EXIT_SUCCESS) or failure + * (EXIT_FAILURE) status. May be NULL. + * @return A pointer to the advanced buffer position. + */ +const char *npc_parse_script(const char *w1, const char *w2, const char *w3, const char *w4, const char *start, const char *buffer, const char *filepath, int options, int *retval) { int x, y, dir = 0, m, xs = 0, ys = 0; // [Valaris] thanks to fov struct script_code *scriptroot; diff --git a/src/map/npc.h b/src/map/npc.h index 9f8767877..cdf33962b 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -239,7 +239,7 @@ struct npc_interface { const char* (*parse_unknown_object) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int *retval); void (*convertlabel_db) (struct npc_label_list *label_list, const char *filepath); const char* (*skip_script) (const char *start, const char *buffer, const char *filepath, int *retval); - const char* (*parse_script) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, int options, int *retval); + const char *(*parse_script) (const char *w1, const char *w2, const char *w3, const char *w4, const char *start, const char *buffer, const char *filepath, int options, int *retval); void (*add_to_location) (struct npc_data *nd); bool (*duplicate_script_sub) (struct npc_data *nd, const struct npc_data *snd, int xs, int ys, int options); bool (*duplicate_shop_sub) (struct npc_data *nd, const struct npc_data *snd, int xs, int ys, int options); diff --git a/src/map/script.h b/src/map/script.h index b153cf81a..d4a3d8db2 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -596,7 +596,7 @@ struct script_interface { FILE *lang_export_fp; char *lang_export_file;/* for lang_export_fp */ /* set and unset on npc_parse_script */ - char *parser_current_npc_name; + const char *parser_current_npc_name; /* */ int buildin_mes_offset; int buildin_select_offset; -- cgit v1.2.3-60-g2f50