diff --git a/source/games/duke/src/gamedef.cpp b/source/games/duke/src/gamedef.cpp index 7a7336d0b..0a6d9da9a 100644 --- a/source/games/duke/src/gamedef.cpp +++ b/source/games/duke/src/gamedef.cpp @@ -1162,24 +1162,25 @@ int parsecommand(int tw) // for now just run an externally parsed command. transnum(); transnum(); break; -#if 0 + case concmd_else: if (checking_ifelse) { checking_ifelse--; - tempscrptr = scriptptr; + tempscrptr = scriptpos(); scriptptr++; //Leave a spot for the fail location parsecommand(); - *tempscrptr = (intptr_t)scriptptr; + setscriptvalue(tempscrptr, scriptpos()); } else { popscriptvalue(); warningcount++; - Printf(TEXTCOLOR_RED " * WARNING.(%s, line %d) Found 'else' with no 'if', ignored.\n", fn, line_number); + Printf(TEXTCOLOR_YELLOW " * WARNING.(%s, line %d) Found 'else' with no 'if', ignored.\n", fn, line_number); } return 0; +#if 0 case concmd_setvar: case concmd_addvar: // syntax: [rand|add|set]var @@ -1509,12 +1510,15 @@ int parsecommand(int tw) // for now just run an externally parsed command. setscriptvalue(tempscrptr, scriptpos()); checking_ifelse++; return 0; -#if 0 case concmd_leftbrace: num_squigilly_brackets++; +#if 0 do done = parsecommand(); while (done == 0); +#else // TRANSITIONAL + C_ParseCommand(1); +#endif return 0; case concmd_rightbrace: num_squigilly_brackets--; @@ -1526,19 +1530,8 @@ int parsecommand(int tw) // for now just run an externally parsed command. return 1; case concmd_betaname: popscriptvalue(); - j = 0; // not used anywhere, just parse over it. - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) // JBF 20040127: end of file checked - { - j++; textptr++; - } - return 0; - case concmd_comment: - popscriptvalue(); //Negate the rem - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) // JBF 20040127: end of file checked - textptr++; - - // line_number++; + skiptoendofline(); return 0; case concmd_definevolumename: @@ -1557,7 +1550,7 @@ int parsecommand(int tw) // for now just run an externally parsed command. textptr++, i++; } parsebuffer.Push(0); - gVolumeNames[j] = FStringTable::MakeMacro(textptr, i); + gVolumeNames[j] = FStringTable::MakeMacro(parsebuffer.Data(), i); return 0; case concmd_defineskillname: popscriptvalue(); @@ -1575,7 +1568,7 @@ int parsecommand(int tw) // for now just run an externally parsed command. textptr++, i++; } parsebuffer.Push(0); - gSkillNames[j] = FStringTable::MakeMacro(textptr, i); + gSkillNames[j] = FStringTable::MakeMacro(parsebuffer.Data(), i); return 0; case concmd_definelevelname: @@ -1596,7 +1589,7 @@ int parsecommand(int tw) // for now just run an externally parsed command. textptr++, i++; } parsebuffer.Push(0); - mapList[j * MAXLEVELS + k].SetFileName(tempbuf); + mapList[j * MAXLEVELS + k].SetFileName(parsebuffer.Data()); while (*textptr == ' ') textptr++; @@ -1685,6 +1678,7 @@ int parsecommand(int tw) // for now just run an externally parsed command. S_DefineSound(k, parsebuffer.Data(), ps, pe, pr, m, vo, 1.f); return 0; } +#if 0 case concmd_endevent: if (parsing_event == 0) { diff --git a/source/games/duke/src/zz_gamedef.cpp b/source/games/duke/src/zz_gamedef.cpp index 09cf393f5..ce89b4bf5 100644 --- a/source/games/duke/src/zz_gamedef.cpp +++ b/source/games/duke/src/zz_gamedef.cpp @@ -1053,7 +1053,16 @@ int32_t C_ParseCommand(int32_t loop) case concmd_ifonboat: case concmd_ifsizedown: case concmd_ifplaybackon: - parsecommand(g_lastKeyword); + case concmd_else: + case concmd_leftbrace: + case concmd_rightbrace: + case concmd_betaname: + case concmd_definevolumename: + case concmd_defineskillname: + case concmd_definelevelname: + case concmd_definequote: + case concmd_definesound: + if (parsecommand(g_lastKeyword)) return 1; continue; case concmd_gamevar: @@ -1172,55 +1181,6 @@ int32_t C_ParseCommand(int32_t loop) continue; - case concmd_else: - { - if (EDUKE32_PREDICT_FALSE(!checking_ifelse)) - { - scriptptr--; - intptr_t *tempscrptr = scriptptr; - warningcount++; - C_ReportError(-1); - - Printf("%s:%d: warning: found `else' with no `if'.\n", g_scriptFileName, line_number); - - if (C_GetKeyword() == concmd_leftbrace) - { - C_GetNextKeyword(); - num_squigilly_brackets++; - - C_ParseCommand(1); - } - else C_ParseCommand(0); - - scriptptr = tempscrptr; - - continue; - } - - intptr_t const lastScriptPtr = scriptptr - apScript - 1; - - g_skipBranch = 0; - checking_ifelse--; - - if (C_CheckMalformedBranch(lastScriptPtr)) - continue; - - intptr_t const offset = (unsigned) (scriptptr-apScript); - - scriptptr++; //Leave a spot for the fail location - - if (!g_gotComment) - C_ParseCommand(0); - - if (C_CheckEmptyBranch(tw, lastScriptPtr)) - continue; - - intptr_t *tempscrptr = (intptr_t *) apScript+offset; - *tempscrptr = (intptr_t) scriptptr; - BITPTR_SET(tempscrptr-apScript); - - continue; - } case concmd_addlogvar: g_labelsOnly = 1; C_GetNextVar(); @@ -1358,296 +1318,7 @@ ifvar: } - case concmd_leftbrace: - if (EDUKE32_PREDICT_FALSE(!(parsing_state || parsing_actor || g_scriptEventOffset))) - { - errorcount++; - C_ReportError(ERROR_SYNTAXERROR); - } - num_squigilly_brackets++; - - C_ParseCommand(1); - continue; - - case concmd_rightbrace: - num_squigilly_brackets--; - - if ((*(scriptptr-2)>>12) == (IFELSE_MAGIC) && - ((*(scriptptr-2) & VM_INSTMASK) == concmd_leftbrace)) // rewrite "{ }" into "nullop" - { - // Printf("%s:%d: rewriting empty braces '{ }' as 'nullop' from right\n",g_szScriptFileName,line_number); - *(scriptptr-2) = concmd_nullop + (IFELSE_MAGIC<<12); - scriptptr -= 2; - - if (C_GetKeyword() != concmd_else && (*(scriptptr-2) & VM_INSTMASK) != concmd_else) - g_skipBranch = 1; - else g_skipBranch = 0; - - j = C_GetKeyword(); - - if (checking_ifelse && j != concmd_else) - checking_ifelse--; - - return 1; - } - - if (EDUKE32_PREDICT_FALSE(num_squigilly_brackets < 0)) - { - C_ReportError(-1); - Printf("%s:%d: error: found more `}' than `{'.\n",g_scriptFileName,line_number); - errorcount++; - } - - if (checking_ifelse && j != concmd_else) - checking_ifelse--; - - return 1; - - case concmd_betaname: - scriptptr--; - j = 0; - skiptoendofline(); - continue; - - case concmd_definevolumename: - scriptptr--; - - C_GetNextValue(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; - - C_SkipSpace(); - - if (EDUKE32_PREDICT_FALSE((unsigned)j > MAXVOLUMES-1)) - { - Printf("%s:%d: error: volume number exceeds maximum volume count.\n", - g_scriptFileName,line_number); - errorcount++; - skiptoendofline(); - continue; - } - - i = strcspn(textptr, "\r\n"); - gVolumeNames[j] = FStringTable::MakeMacro(textptr, i); - textptr+=i; - g_volumeCnt = j+1; - continue; - - case concmd_defineskillname: - scriptptr--; - - C_GetNextValue(LABEL_DEFINE); - scriptptr--; - j = *scriptptr; - - C_SkipSpace(); - - if (EDUKE32_PREDICT_FALSE((unsigned)j >= MAXSKILLS)) - { - Printf("%s:%d: error: skill number exceeds maximum skill count %d.\n", - g_scriptFileName,line_number, MAXSKILLS); - errorcount++; - skiptoendofline(); - continue; - } - - i = strcspn(textptr, "\r\n"); - gSkillNames[j] = FStringTable::MakeMacro(textptr, i); - textptr+=i; - - for (i=0; i MAXVOLUMES-1)) - { - Printf("%s:%d: error: volume number exceeds maximum volume count.\n",g_scriptFileName,line_number); - errorcount++; - skiptoendofline(); - continue; - } - if (EDUKE32_PREDICT_FALSE((unsigned)k > MAXLEVELS-1)) - { - Printf("%s:%d: error: level number exceeds maximum number of levels per episode.\n",g_scriptFileName,line_number); - errorcount++; - skiptoendofline(); - continue; - } - - i = 0; - - tempbuf[i] = '/'; - - while (*textptr != ' ' && *textptr != '\t' && *textptr != 0x0a) - { - tempbuf[i+1] = *textptr; - textptr++,i++; - if (EDUKE32_PREDICT_FALSE(i >= BMAX_PATH)) - { - Printf("%s:%d: error: level file name exceeds limit of %d characters.\n",g_scriptFileName,line_number,BMAX_PATH); - errorcount++; - C_SkipSpace(); - break; - } - } - tempbuf[i+1] = '\0'; - - mapList[j *MAXLEVELS+k].SetFileName(tempbuf); - - C_SkipComments(); - - mapList[j *MAXLEVELS+k].parTime = - (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*60)+ - (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))); - - textptr += 5; - C_SkipSpace(); - - // cheap hack, 0.99 doesn't have the 3D Realms time - if (*(textptr+2) == ':') - { - mapList[j *MAXLEVELS+k].designerTime = - (((*(textptr+0)-'0')*10+(*(textptr+1)-'0'))*60)+ - (((*(textptr+3)-'0')*10+(*(textptr+4)-'0'))); - - textptr += 5; - C_SkipSpace(); - } - else if (g_scriptVersion == 10) g_scriptVersion = 9; - - i = 0; - - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - { - tempbuf[i] = *textptr; - textptr++,i++; - if (EDUKE32_PREDICT_FALSE(i >= 32)) - { - Printf("%s:%d: warning: truncating level name to %d characters.\n", - g_scriptFileName,line_number,32); - warningcount++; - skiptoendofline(); - break; - } - } - - tempbuf[i] = '\0'; - - mapList[j *MAXLEVELS+k].name = tempbuf; - - continue; - - case concmd_definequote: - { - scriptptr--; - - C_GetNextValue(LABEL_DEFINE); - - k = *(scriptptr-1); - - if (EDUKE32_PREDICT_FALSE((unsigned)k >= MAXQUOTES)) - { - Printf("%s:%d: error: quote number exceeds limit of %d.\n",g_scriptFileName,line_number,MAXQUOTES); - errorcount++; - } - else - { - C_AllocQuote(k); - } - - scriptptr--; - - i = 0; - - C_SkipSpace(); - - buffer.Clear(); - while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) - { - buffer.Push(*textptr); - textptr++; - } - buffer.Push(0); - quoteMgr.InitializeQuote(k, buffer.Data(), true); - continue; - } - case concmd_definesound: - { - int ps, pe, vo, pr, m; - - scriptptr--; - C_GetNextValue(LABEL_DEFINE); - - // Ideally we could keep the value of i from C_GetNextValue() instead of having to hash_find() again. - // This depends on tempbuf remaining in place after C_GetNextValue(): - j = findlabel(tempbuf); - - k = scriptptr[-1]; - if ((unsigned)k >= MAXSOUNDS - 1) - { - Printf("%s:%d: error: sound index exceeds limit of %d.\n", g_scriptFileName, line_number, MAXSOUNDS - 1); - errorcount++; - k = MAXSOUNDS - 1; - } - /*else if (g_sounds[k].filename != NULL) - { - Printf("%s:%d: warning: sound %d already defined (%s)\n", g_scriptFileName, line_number, k, g_sounds[k].filename); - warningcount++; - }*/ - - scriptptr--; - i = 0; - C_SkipComments(); - - buffer.Clear(); - - if (*textptr == '\"') - { - textptr++; - while (*textptr && *textptr != '\"') - { - buffer.Push(*textptr++); - } - textptr++; - } - else while (*textptr != ' ' && *textptr != '\t' && *textptr != '\r' && *textptr != '\n') - { - buffer.Push(*textptr++); - } - buffer.Push(0); - - C_GetNextValue(LABEL_DEFINE); - ps = scriptptr[-1]; - C_GetNextValue(LABEL_DEFINE); - pe = scriptptr[-1]; - C_GetNextValue(LABEL_DEFINE); - pr = scriptptr[-1]; - - C_GetNextValue(LABEL_DEFINE); - m = scriptptr[-1]; - - C_GetNextValue(LABEL_DEFINE); - vo = scriptptr[-1]; - scriptptr -= 5; - - int res = S_DefineSound(k, buffer.Data(), ps, pe, pr, m, vo, 1.f); - - continue; - } - + case concmd_endevent: if (EDUKE32_PREDICT_FALSE(!g_scriptEventOffset)) diff --git a/source/games/duke/src/zz_gameexec.cpp b/source/games/duke/src/zz_gameexec.cpp index 87195bc4d..1a8edb0ee 100644 --- a/source/games/duke/src/zz_gameexec.cpp +++ b/source/games/duke/src/zz_gameexec.cpp @@ -1228,7 +1228,7 @@ GAMEEXEC_STATIC void VM_Execute(native_t loop) } else if (tw == concmd_else) { - insptr = (intptr_t *)*(insptr + 1); + insptr = apScript + *(insptr + 1); continue; } else if (tw == concmd_state) diff --git a/source/games/duke/src/zz_text.cpp b/source/games/duke/src/zz_text.cpp index 2ab71c5ed..aac345c34 100644 --- a/source/games/duke/src/zz_text.cpp +++ b/source/games/duke/src/zz_text.cpp @@ -91,7 +91,11 @@ int GameInterface::GetStringTile(int font, const char* t, int f) } } else - return *t - '!' + font; // uses ASCII order + { + int tt = *t; + if (tt >= 'a' && tt <= 'z') tt -= 32; + return tt - '!' + font; // uses ASCII order + } }