Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Goober5000 committed Jul 28, 2023
1 parent feadc0b commit f64de84
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
28 changes: 19 additions & 9 deletions code/parse/sexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35574,6 +35574,16 @@ bool usable_in_campaign(int op_id)
}
}

// For tokenizing in SEXP help
#define MAX_SEXP_VARIABLES_1 249
#define TOKEN_LENGTH_1 31
#if (MAX_SEXP_VARIABLES_1) != (MAX_SEXP_VARIABLES - 1)
#error MAX_SEXP_VARIABLES_1 must be equal to MAX_SEXP_VARIABLES - 1!
#endif
#if (TOKEN_LENGTH_1) != (TOKEN_LENGTH - 1)
#error TOKEN_LENGTH_1 must be equal to TOKEN_LENGTH - 1!
#endif

// clang-format off
SCP_vector<sexp_help_struct> Sexp_help = {
{ OP_PLUS, "Plus (Arithmetic operator)\r\n"
Expand Down Expand Up @@ -36733,30 +36743,30 @@ SCP_vector<sexp_help_struct> Sexp_help = {
"arrays and pointers.\r\n\r\nPlease note that only numeric variables are supported. Any "
"attempt to access a string variable will result in a value of SEXP_NAN_FOREVER being returned.\r\n\r\n"
"Takes 1 argument...\r\n"
"\t1:\tIndex of variable, from 0 to " SCP_TOKEN_TO_STR(MAX_SEXP_VARIABLES) " - 1." },
"\t1:\tIndex of variable, from 0 to " SCP_TOKEN_TO_STR(MAX_SEXP_VARIABLES_1) "." },

{ OP_SET_VARIABLE_BY_INDEX, "set-variable-by-index (originally variable-array-set)\r\n"
"\tSets the value of the variable specified by the given index. This is an alternate way "
"to modify variables rather than by their names, and it enables cool features such as "
"arrays and pointers.\r\n\r\nIn contrast to get-variable-by-index, note that this sexp "
"*does* allow the modification of string variables.\r\n\r\n"
"Takes 2 arguments...\r\n"
"\t1:\tIndex of variable, from 0 to " SCP_TOKEN_TO_STR(MAX_SEXP_VARIABLES) " - 1.\r\n"
"\t1:\tIndex of variable, from 0 to " SCP_TOKEN_TO_STR(MAX_SEXP_VARIABLES_1) ".\r\n"
"\t2:\tValue to be set." },

{ OP_COPY_VARIABLE_FROM_INDEX, "copy-variable-from-index\r\n"
"\tRetrieves the value of the variable specified by the given index and stores it in another variable. "
"This is very similar to get-variable-by-index, except the result is stored in a new variable rather than "
"being returned by value. One important difference is that this sexp can be used to copy string variables as well as numeric variables.\r\n\r\n"
"Takes 2 arguments...\r\n"
"\t1:\tIndex of source variable, from 0 to " SCP_TOKEN_TO_STR(MAX_SEXP_VARIABLES) " - 1.\r\n"
"\t1:\tIndex of source variable, from 0 to " SCP_TOKEN_TO_STR(MAX_SEXP_VARIABLES_1) ".\r\n"
"\t2:\tDestination variable. The type of this variable must match the type of the variable referenced by the index." },

{ OP_COPY_VARIABLE_BETWEEN_INDEXES, "copy-variable-between-indexes\r\n"
"\tRetrieves the value of the variable specified by the first index and stores it in the variable specified by the second index. The first variable is not modified.\r\n\r\n"
"Takes 2 arguments...\r\n"
"\t1:\tIndex of source variable, from 0 to " SCP_TOKEN_TO_STR(MAX_SEXP_VARIABLES) " - 1.\r\n"
"\t2:\tIndex of destination variable, from 0 to " SCP_TOKEN_TO_STR(MAX_SEXP_VARIABLES) " - 1. The types of both variables must match." },
"\t1:\tIndex of source variable, from 0 to " SCP_TOKEN_TO_STR(MAX_SEXP_VARIABLES_1) ".\r\n"
"\t2:\tIndex of destination variable, from 0 to " SCP_TOKEN_TO_STR(MAX_SEXP_VARIABLES_1) ". The types of both variables must match." },

// Karajorma/jg18
{ OP_CONTAINER_ADD_TO_LIST, "add-to-list\r\n"
Expand Down Expand Up @@ -37573,7 +37583,7 @@ SCP_vector<sexp_help_struct> Sexp_help = {
// Goober5000
{ OP_STRING_CONCATENATE, "string-concatenate (deprecated in favor of string-concatenate-block)\r\n"
"\tConcatenates two strings, putting the result into a string variable. If the length of the string will "
"exceed the sexp variable token limit (" SCP_TOKEN_TO_STR(TOKEN_LENGTH) " - 1), it will be truncated.\r\n\r\n"
"exceed the sexp variable token limit (" SCP_TOKEN_TO_STR(TOKEN_LENGTH_1) "), it will be truncated.\r\n\r\n"
"Takes 3 arguments...\r\n"
"\t1: First string\r\n"
"\t2: Second string\r\n"
Expand All @@ -37582,15 +37592,15 @@ SCP_vector<sexp_help_struct> Sexp_help = {
// Goober5000
{ OP_STRING_CONCATENATE_BLOCK, "string-concatenate-block\r\n"
"\tConcatenates two or more strings, putting the result into a string variable. If the length of the string will "
"exceed the sexp variable token limit (" SCP_TOKEN_TO_STR(TOKEN_LENGTH) " - 1), it will be truncated.\r\n\r\n"
"exceed the sexp variable token limit (" SCP_TOKEN_TO_STR(TOKEN_LENGTH_1) "), it will be truncated.\r\n\r\n"
"Takes 3 or more arguments...\r\n"
"\t1: String variable to hold the result\r\n"
"\tRest: Strings to concatenate. At least two of these are required; the rest are optional.\r\n" },

// Goober5000
{ OP_STRING_GET_SUBSTRING, "string-get-substring\r\n"
"\tExtracts a substring from a parent string, putting the result into a string variable. If the length of the string will "
"exceed the sexp variable token limit (" SCP_TOKEN_TO_STR(TOKEN_LENGTH) " - 1), it will be truncated.\r\n\r\n"
"exceed the sexp variable token limit (" SCP_TOKEN_TO_STR(TOKEN_LENGTH_1) "), it will be truncated.\r\n\r\n"
"Takes 3 arguments...\r\n"
"\t1: Parent string\r\n"
"\t2: Index at which the substring begins (0-based)\r\n"
Expand All @@ -37600,7 +37610,7 @@ SCP_vector<sexp_help_struct> Sexp_help = {
// Goober5000
{ OP_STRING_SET_SUBSTRING, "string-set-substring\r\n"
"\tReplaces a substring from a parent string with a new string, putting the result into a string variable. If the length of the string will "
"exceed the sexp variable token limit (" SCP_TOKEN_TO_STR(TOKEN_LENGTH) " - 1), it will be truncated.\r\n\r\n"
"exceed the sexp variable token limit (" SCP_TOKEN_TO_STR(TOKEN_LENGTH_1) "), it will be truncated.\r\n\r\n"
"Takes 3 arguments...\r\n"
"\t1: Parent string\r\n"
"\t2: Index at which the substring begins (0-based)\r\n"
Expand Down
8 changes: 7 additions & 1 deletion fred2/freddoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,12 @@ BOOL CFREDDoc::OnOpenDocument(LPCTSTR pathname) {
return TRUE;
}

// For tokenizing
#define MAX_FILENAME_LEN_1 31
#if (MAX_FILENAME_LEN_1) != (MAX_FILENAME_LEN - 1)
#error MAX_FILENAME_LEN_1 must be equal to MAX_FILENAME_LEN - 1!
#endif

BOOL CFREDDoc::OnSaveDocument(LPCTSTR pathname) {
CFred_mission_save save;
DWORD attrib;
Expand All @@ -591,7 +597,7 @@ BOOL CFREDDoc::OnSaveDocument(LPCTSTR pathname) {
auto len = strlen(filename);

if (len >= MAX_FILENAME_LEN)
Fred_main_wnd->MessageBox("The filename is too long for FreeSpace. The game will not be able to read this file. Max length, including extension, is " SCP_TOKEN_TO_STR(MAX_FILENAME_LEN-1) " characters.", NULL, MB_OK | MB_ICONEXCLAMATION);
Fred_main_wnd->MessageBox("The filename is too long for FreeSpace. The game will not be able to read this file. Max length, including extension, is " SCP_TOKEN_TO_STR(MAX_FILENAME_LEN_1) " characters.", NULL, MB_OK | MB_ICONEXCLAMATION);

// drop extension and copy to Mission_filename
auto ext_ch = strrchr(filename, '.');
Expand Down

0 comments on commit f64de84

Please sign in to comment.