mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
CON syntax extension: the empty "[]" shortcut for accessing a struct at index THISACTOR can now be omitted.
This allows cleaner syntax such as "geta .x temp", "ife sprite.x temp", etc. git-svn-id: https://svn.eduke32.com/eduke32@7238 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
7fd81960e2
commit
6d7537aa27
1 changed files with 14 additions and 10 deletions
|
@ -982,7 +982,7 @@ static inline bool isaltok(const char c)
|
||||||
|
|
||||||
static inline bool C_IsLabelChar(const char c, int32_t const i)
|
static inline bool C_IsLabelChar(const char c, int32_t const i)
|
||||||
{
|
{
|
||||||
return (isalnum(c) || c == '_' || c == '*' || c == '?' || (i > 0 && (c == '+' || c == '-' || c == '.')));
|
return (isalnum(c) || c == '_' || c == '*' || c == '?' || (i > 0 && (c == '+' || c == '-')));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t C_GetLabelNameID(const memberlabel_t *pLabel, hashtable_t const * const table, const char *psz)
|
static inline int32_t C_GetLabelNameID(const memberlabel_t *pLabel, hashtable_t const * const table, const char *psz)
|
||||||
|
@ -1219,10 +1219,10 @@ static void C_GetNextVarType(int32_t type)
|
||||||
|
|
||||||
C_SkipComments();
|
C_SkipComments();
|
||||||
|
|
||||||
if (*textptr == '[') //read of array as a gamevar
|
if (*textptr == '[' || *textptr == '.') //read of array as a gamevar
|
||||||
{
|
{
|
||||||
flags |= GV_FLAG_ARRAY;
|
flags |= GV_FLAG_ARRAY;
|
||||||
textptr++;
|
if (*textptr != '.') textptr++;
|
||||||
id=GetADefID(LAST_LABEL);
|
id=GetADefID(LAST_LABEL);
|
||||||
|
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
|
@ -1247,7 +1247,7 @@ static void C_GetNextVarType(int32_t type)
|
||||||
if ((flags & GV_FLAG_STRUCT) && id - g_structVarIDs == STRUCT_USERDEF)
|
if ((flags & GV_FLAG_STRUCT) && id - g_structVarIDs == STRUCT_USERDEF)
|
||||||
{
|
{
|
||||||
// userdef doesn't really have an array index
|
// userdef doesn't really have an array index
|
||||||
while (*textptr != ']')
|
while (*textptr != '.')
|
||||||
{
|
{
|
||||||
if (*textptr == 0xa || *textptr == 0)
|
if (*textptr == 0xa || *textptr == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -1259,7 +1259,7 @@ static void C_GetNextVarType(int32_t type)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (*textptr == ']')
|
if (*textptr == ']' || *textptr == '.')
|
||||||
{
|
{
|
||||||
scriptWriteValue(g_thisActorVarID);
|
scriptWriteValue(g_thisActorVarID);
|
||||||
}
|
}
|
||||||
|
@ -1269,13 +1269,14 @@ static void C_GetNextVarType(int32_t type)
|
||||||
C_SkipComments();
|
C_SkipComments();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE(*textptr != ']'))
|
if (EDUKE32_PREDICT_FALSE(*textptr != ']' && *textptr != '.'))
|
||||||
{
|
{
|
||||||
g_errorCnt++;
|
g_errorCnt++;
|
||||||
C_ReportError(ERROR_GAMEARRAYBNC);
|
C_ReportError(ERROR_GAMEARRAYBNC);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
textptr++;
|
|
||||||
|
if (*textptr != '.') textptr++;
|
||||||
|
|
||||||
//writing arrays in this way is not supported because it would require too many changes to other code
|
//writing arrays in this way is not supported because it would require too many changes to other code
|
||||||
|
|
||||||
|
@ -1400,6 +1401,7 @@ static void C_GetNextVarType(int32_t type)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
id=GetDefID(LAST_LABEL);
|
id=GetDefID(LAST_LABEL);
|
||||||
if (id<0) //gamevar not found
|
if (id<0) //gamevar not found
|
||||||
{
|
{
|
||||||
|
@ -1562,16 +1564,18 @@ static int C_GetStructureIndexes(bool const labelsonly, hashtable_t const * cons
|
||||||
{
|
{
|
||||||
C_SkipComments();
|
C_SkipComments();
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE(*textptr++ != '['))
|
if (EDUKE32_PREDICT_FALSE(*textptr != '[' && *textptr != '.'))
|
||||||
{
|
{
|
||||||
g_errorCnt++;
|
g_errorCnt++;
|
||||||
C_ReportError(ERROR_SYNTAXERROR);
|
C_ReportError(ERROR_SYNTAXERROR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*textptr != '.') textptr++;
|
||||||
|
|
||||||
C_SkipComments();
|
C_SkipComments();
|
||||||
|
|
||||||
if (*textptr == ']')
|
if (*textptr == ']' || *textptr == '.')
|
||||||
{
|
{
|
||||||
scriptWriteValue(g_thisActorVarID);
|
scriptWriteValue(g_thisActorVarID);
|
||||||
}
|
}
|
||||||
|
@ -1582,7 +1586,7 @@ static int C_GetStructureIndexes(bool const labelsonly, hashtable_t const * cons
|
||||||
g_labelsOnly = 0;
|
g_labelsOnly = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
textptr++;
|
if (*textptr != '.') textptr++;
|
||||||
|
|
||||||
C_SkipComments();
|
C_SkipComments();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue